-
Notifications
You must be signed in to change notification settings - Fork 64
Conversation
Did a code review only since I can't test atm, and I think it looks good. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, first view looks good.
I would prefer a human-readable combined key instead a calculated one.
e.g.: productionQueueTableKey = localPlayerID + "_" + cityID
I can't see why not, lua is fairly lax as far as keys go - string or number. Might as well make it a string. However I extracted all of this key derivation into a function so that it was easier for me to refactor and experiment, any reader of the code does not have to care how it is done. |
I meen human-readable for debugging (catching the used key). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm feeling pretty neutral on the current key implementation. I'm leaning towards not using string indices since the PP is already a memory leak ridden mess, but the savings would be relatively minor either way, so I leave this decision up to @Kerael.
Either way, I don't plan to merge this change until tomorrow because of the breaking potential. I'd rather get the workshop version pushed out tonight, then let the nightly users experiment with this for a week before we let it out into the wild
I would stick with an existing changeset; while string concatenation might be neat (achieved with .. not +) it is something that might take more CPU. It is a rare action that happens every now and then, but more often than policy changes and that lag annoys me greatly. I don't have much time to test out the change and see if it affects performance on mine (really high spec) let alone a bunch of other PCs... unlikely, but it is a drop in the bucket. Testing: after another 5 hours (and finishing the session with my partner) I noticed that the queues might behave a bit funny when doing quick save and quickly going back to the city. Nothing game breaking, exiting out of the window and back in restores back the queue as it was. Next time when I play some more civ, I might try to replicate it again. (Allow edits from maintainers is set for a reason, if you can make the change and give it a few rounds to check that it works - you are welcome =) ) |
Okay... I was thinking to difficult...
I whould say, that the localPlayerID will never be more than two digits...
Key = (CityID x 100) + localPlayerID;
So the first digits are the City with no limitations and the last two the localPlayerID.
|
This change should help make the keys a little more human readable with minimal performance impact. See discussion [here](CQUI-Org#530 (comment)) for more information
I think I should have time today to give it a go and use some debug messages for instances where I thought I have seen some weirdness in play. With these changes on loading the game from a save file the production queue is confused for the second player until it is reset and requeued, as the first player my wife did not seem to notice anything untoward. While looking at this if I notice that the player ids are indeed only 2 digits (or in a nice order 1,2,3,4,5) I will try the suggested formula. Unless you already loaded up the game and tried some changes. |
Found an hour to check the change and look into cityID/playerID. There are good and bad news. I can't seem to find a way to debug multiplayer (firetuner does not work in multiplayer). In single player though I got some data for playerID and cityID just to get some idea of how they look like. So I am dead certain that changes made by this tweak would have had no effect on single player. Now what happens in multiplayer with playerID is unknown (due to challenges in debugging). Perhaps for networking reasons it would be random number, perhaps it would be 0,1,2,3,4,5... Might as well go with the suggested key, it makes more sense especially now that I see how cityID looks like and looks a lot nicer. New formula still works fine. |
@Kerael You are sure that you use Chris changes how to calculate the key? |
@JHCD used the ones from his commit for a quick check on duel map in hotseat, and a quick singleplayer check with 3 cities to get debugging info. |
Part of issue #271. This is not a complete fix to all hotseat issues; I agree with the author that the code requires further refactoring. The changes were made for a game with my partner in a fairly short time (an hour and a half starting from no knowledge of how civ modding works, but with acceptable experience with lua), it was bugging me too much that the production queue was broken.
In summary the production queue is no longer a table with city numbers as keys, but instead a table of keys that were derived from the city number and the player (city owner).
Testing done: So far I had a single hotseat session for about 10 hours with lots of cities, and a bunch of small sessions that lasted no longer than 5 minutes to test that the changes are functional. The changes seem stable, I had a single crash (in 10 hours) and I have not investigated the cause of the crash but I doubt it was due to these changes.