[Solved] City:GetBuildQueue():FinishProgress() Issue in MP

Fampat

Chieftain
Joined
Jan 19, 2019
Messages
42
Location
Germany
Hi!
iam fiddling with some code to finish the current production in a city.
While in singleplayer it workes without an issue, in network-multiplayer it always leads to a desync on turn-change, but only if the host is executing this.

Since the search-results on the forums dont get me an aswer if there is anything wrong with the usage of this action i thought i bring it up, maybe someone has an idea of what could be wrong or if it could be a bug in the action in firaxis side.

Code in gameplay-script:

Code:
function OnCompleteProduction(playerId, cityId)
    local pCity = Players[playerId]:GetCities():FindID(cityId);
    local cityBuildQueue = pCity:GetBuildQueue();

    -- ...by finishing productions
    cityBuildQueue:FinishProgress();

    WriteToLog("Finished production in city: "..cityId);
end

Get called via ExposedMember on a click-action bound to a button on the ui.

Gameplay-context initialize:
Code:
ExposedMembers.MOD_StillAUsefulMaterial.CompleteProduction = OnCompleteProduction;

UI-context button action:
Code:
ExposedMembers.MOD_StillAUsefulMaterial.CompleteProduction(ownerId, cityId);

The entire code:
- Gameplay: https://github.com/fampat/fampat-ci...atch__may_20/Scripts/StillAUsefulMaterial.lua
- UI: https://github.com/fampat/fampat-ci..._20/Base/Assets/UI/Additions/IronMaterial.lua

Any have a similar experience or can confirm its bugged using City:GetBuildQueue():FinishProgress() as host in network-multiplayer?

Thanks for you time!
 
If OnCompleteProduction is called by a UI action, that code will execute only on the PC of the player doing the action.

You need to change the code so the UI button will generate a call to that function on all PC, see the Red Death scenario for an example.

Edit: using UI.RequestPlayerOperation
 
Last edited:
Top Bottom