Thalassicus / cep-bnw

Civ V Communitas Expansion Pack
32 stars 22 forks source link

[16.04.14 stable] CityView production display becomes static #271

Open TymurGubayev opened 10 years ago

TymurGubayev commented 10 years ago

After few turns of the game (27 to be exact) the numbers in top-left corner of cityview aren't changing anymore, no matter what I do. The tooltip of "Production" line says, for example, "3 Hammer from Terrain/2 Hammer from Buildings/ 7 Hammers Total", and this "7" stays there until I end my turn.

GrantSP commented 10 years ago

I'm not sure what you are exactly saying here.

What do you mean by "and this "7" stays there until I end my turn.". Are you expecting a change to occur during your turn?

I have just played out a game for 35 turns, checking my CityView after each turn, everything looks to be updating properly. If perhaps you mean you change the worker assignments, then you have to end your turn for those new assignments to be accounted for. So, if you change from the default to a Production focused city, end your turn and check the values on the next turn.

TymurGubayev commented 10 years ago

usually, if you change tiles you are working, you see the changes in sum production immediately. Otherwise it's hard to calculate what tiles are better to work for current needs. Parts of tooltips are working as expected (if you hover over production number), but the most important summary-part doesn't. One consequence of this behavior is, the "Turns until finished" counter is now static too.

The actual amount of resources you get after finishing a turn is correct, only the UI part is bugged.

GrantSP commented 10 years ago

This is most likely a consequence of the YieldLibrary. You can still get an idea from the yields displayed on each tile. If you are looking to increase the production, work those tiles with more 'hammers'. To be honest I can't recall if there is a difference in this from a vanilla game. I'll do a comparison now. Agreed, it would be more helpful if the yields totals updated immediately, not sure if this is a bug or by design. Perhaps to eliminate lag in processing time.

GrantSP commented 10 years ago

hmm... interesting.

There is a function call in the vanilla CityView.lua called DoUpdateProductionInfo (line 1032). In the modded files this call is made at a different place (line 1702). I wonder why it is moved?

The little I can make from reading the code does seem to indicate the changes are due to using the YieldLibrary to calculate the yields. Someone with more knowledge of the code will have to say for certain one way or the other.

TymurGubayev commented 10 years ago

imho, the problem is in YieldCache being not properly updated: in CityView.lua, line 1681, _CityGetYieldRate function is called, in YieldLibrary.lua, line 1385, function GetYieldCache is called, and if it returns something, the function returns immediately. Unfortunally, the cache is not being updated during turn after 1st "end turn".

TymurGubayev commented 10 years ago

ok, the patch: http://pastebin.com/A562xs24 It adds after each Network.SendDoTask with _TaskTypes.TASK_CHANGE_WORKINGPLOT, Network.SendSetCityAIFocus and Network.SendSetCityAvoidGrowth a call to LuaEvents.DirtyYieldCachePlayer

GrantSP commented 10 years ago

Am I to conclude from this that you, unlike me, actually know how to program?

Why not join in the collaboration of the project here in GitHub?

wolverine2112 commented 10 years ago

This works....good work!