Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#3236 closed defect (fixed)

[PATCH] Population Altering Techs Bug

Reported by: Nikos Owned by: sanderd17
Priority: Must Have Milestone: Alpha 19
Component: UI & Simulation Keywords: patch
Cc: Patch:

Description

When altering the population cost of units with techs, the production queue of structures uses the old value used on the templates instead of the modified one. Units have their correct, modified pop cost though after being trained.

This can lead to cases where you have the population to support a unit, but you can't summon it.

Attachments (3)

Cost.js.patch (374 bytes ) - added by Vladislav Belov 9 years ago.
Fix population bonus updates
Cost_js_fix_population_cost_and bonus.patch (3.3 KB ) - added by Vladislav Belov 9 years ago.
Fix both issues (cost and bonus)
Cost_js_fix_population_cost_and_bonus_v2.patch (5.0 KB ) - added by Vladislav Belov 9 years ago.

Download all attachments as: .zip

Change History (19)

comment:1 by sanderd17, 9 years ago

Keywords: simple added; tech pop structure removed
Milestone: Alpha 19Backlog

Could you add an example technology (perhaps auto researched) to easily test it?

in reply to:  1 comment:2 by Nikos, 9 years ago

Replying to sanderd17:

Could you add an example technology (perhaps auto researched) to easily test it?

I believe there's none currently in the main game, but you could use this (edited from my mod to function correctly - using elephant cause it takes more than one pop slots, not sure how a 0.5 pop unit would be handled).

{
    "genericName": "Light Infantry",
    "autoResearch": true,
    "modifications": [
        {"value": "Cost/Population", "replace": 2}
    ],
    "affects": ["Elephant"]
}

*The problem shouldn't be in "multiply" but in the way the game handles it, "replace" had the same issue. *Edit: Changing "multiply": 0.5 to "replace": 2.. cause the elephant has 3 pop.. to avoid possible issues described above.

Last edited 9 years ago by sanderd17 (previous) (diff)

comment:3 by Nikos, 9 years ago

I've spotted one more related issue. Adding extra population supply to structures with a tech retains it even if the subject structures are destroyed/deleted.

by Vladislav Belov, 9 years ago

Attachment: Cost.js.patch added

Fix population bonus updates

comment:4 by Vladislav Belov, 9 years ago

Keywords: review patch added
Summary: Population Altering Techs Bug[PATCH] Population Altering Techs Bug

comment:5 by sanderd17, 9 years ago

The patch above indeed fixes the population bonus (as mentioned in comment 3) in a correct way (AFAICS).

However, it doesn't fix the population cost issue (the original issue).

in reply to:  5 comment:6 by Vladislav Belov, 9 years ago

Replying to sanderd17:

However, it doesn't fix the population cost issue (the original issue).

I think that popcost and popbonus issue need divide in two patches. Or for popbonus need create new issue?

Last edited 9 years ago by Vladislav Belov (previous) (diff)

comment:7 by sanderd17, 9 years ago

Yes, you can create a new issue if you like. However, the changes are small and the pieces of code related, so you can have one combined patch too.

comment:8 by leper, 9 years ago

cmpTemplateManager since we moved away from the *Man naming scheme quite some time ago. Also inline the QueryInterface call in this case since this is a system component (thus we can assume its existence in js code) and only used once.

in reply to:  8 comment:9 by Vladislav Belov, 9 years ago

Replying to leper:

cmpTemplateManager since we moved away from the *Man naming scheme quite some time ago. Also inline the QueryInterface call in this case since this is a system component (thus we can assume its existence in js code) and only used once.

I have changed that, but ProductionQueue contents cmpTemplateMan in other lines, it's need to be replaced?

Last edited 9 years ago by Vladislav Belov (previous) (diff)

comment:10 by leper, 9 years ago

Yes.

Also create patches from the topmost directory (so paths in the diff are like binaries/data/mods/public/simulation/components/ProductionQueue.js instead of ProductionQueue.js (makes it easier to apply)).

by Vladislav Belov, 9 years ago

Fix both issues (cost and bonus)

in reply to:  10 comment:11 by Vladislav Belov, 9 years ago

Replying to leper:

Yes.

Also create patches from the topmost directory (so paths in the diff are like binaries/data/mods/public/simulation/components/ProductionQueue.js instead of ProductionQueue.js (makes it easier to apply)).

Ready.

comment:12 by sanderd17, 9 years ago

Did you test your code?

When testing, I found that the population bonus issue was indeed fixed, but the population cost is not what was described in the original issue. Instead, I saw that the population cost was never applied, apart from the production queue stats. So now, when you train a unit, the production queue reserves the number of slots needed, but uses the unmodified cost again when creating the unit.

in reply to:  12 comment:13 by Vladislav Belov, 9 years ago

Replying to sanderd17:

When testing, I found that the population bonus issue was indeed fixed, but the population cost is not what was described in the original issue. Instead, I saw that the population cost was never applied, apart from the production queue stats. So now, when you train a unit, the production queue reserves the number of slots needed, but uses the unmodified cost again when creating the unit.

Entity of unit has creating only after end of production queue. And production queue need modify it. Is it normal (That not entity change itself popcost)?

by Vladislav Belov, 9 years ago

comment:14 by Vladislav Belov, 9 years ago

Priority: Should HaveMust Have

comment:15 by sanderd17, 9 years ago

Owner: set to sanderd17
Resolution: fixed
Status: newclosed

In 16709:

Fix issues with technologies and pop bonus/cost. Patch by Vladislav. Fixes #3236

comment:16 by sanderd17, 9 years ago

Keywords: simple review removed
Milestone: BacklogAlpha 19
Note: See TracTickets for help on using tickets.