Finally found my derailed train of thought, put it back on track and tested the result:
- Removing the command button does not cause mismatch
- Adding the command button causes mismatch
With that in mind I tried to fix it with these two scripts:
script "add"
(active, don't deactivate upon success)
Code:
*** IF ***
True.
*** THEN ***
[???] Command button: 'Command_UpgradeChinaNeutronShells' is added to all objects of type 'Nuke_ChinaCommandCenter' in slot number 6 (1-12).
Enable Script 'remove'.
script "remove"
(non-active, do deactivate upon success)
Code:
*** IF ***
Player '<Local Player>' has Less Than 1 unit or structure of type 'Nuke_ChinaBarracks'
*** THEN ***
[???] Command button: 'Command_UpgradeChinaNeutronShells' is removed from all objects of type 'Nuke_ChinaCommandCenter'.
The result was quite ridiculous.
The game was off-sync but did not mismatch. On one machine player0 built the upgrade, on the other he didn't. The player's cash was not in sync (verified). And even if player0 built a mobile nuke and used the neutrone shells the shells worked normally on both machines and the game didn't mismatch, which is absolutely surprising. Simply put, on one machine the nuke used neutrone shells without the upgrade having been built. That sounds very alarming, this solution should not be used. Cash being off-sync is a big no (imagine cash requirements for units/buildings).
Then I came up with, quite frankly put, an ingenious solution:
(active, don't deactivate upon success)
Code:
*** IF ***
Player '<Local Player>' has Less Than 1 unit or structure of type 'Nuke_ChinaInternetCenter'
*** THEN ***
[???] Command button: 'Command_UpgradeChinaNeutronShells' is removed from all objects of type 'Nuke_ChinaNuclearMissileLauncher'.
[???] Command button: 'Command_UpgradeChinaNeutronShells' is added to all objects of type 'Nuke_ChinaNuclearMissileLauncher' in slot number 16 (1-12).
*** ELSE ***
Command button: 'Command_UpgradeChinaNeutronShells' is removed from all objects of type 'Nuke_ChinaNuclearMissileLauncher'.
Command button: 'Command_UpgradeChinaNeutronShells' is added to all objects of type 'Nuke_ChinaNuclearMissileLauncher' in slot number 6 (1-12).
Note that one time the slot number is 16, the other time it's 6.
With this trick the game does not desync, because the other machine thinks it's legit if a player built an upgrade that is being listed in slot 16, even though the upgrade is not click-able (not even through the keyboard shortcut), simply because 16 is off-limit. The AI would probably still be able to build the upgrade, but I am quite sure that doesn't matter in this case (plus I don't think AI even uses neutrone shell nukes).
There, however, is one tiny glitch:
In order to update command button positions, the object needs to be re-selected. That means: If one player has the requirements to "see" the command button, and, while having the object selected, loses the requirements, the command button will still be there and click-able until the object is re-selected. It is the same the other way around, the button is not there until the object was re-selected.
If you, absolutely positively, need to fix that tiny bug, this would be the way to force-deselect everything, but will require some more work to check if the condition changed:
Code:
*** IF ***
[prerequities changed]
*** THEN ***
Disable mouse and keyboard input.
Enable mouse and keyboard input.
If you are unsure why and how syncing with LocalPlayer works you might want to check this topic:
http://www.cnclabs.com/f...e-it-in-Multiplayer.aspxEdited by user Saturday, February 9, 2019 9:54:02 AM(UTC)
| Reason: Not specified