Bug #1493
open"Oh my! You seem to have no capital!"
0%
Description
gtk3.22, gtk4 & gtk4x, all branches
(When you load a saved game, or when you just created your first city) and before Turn Done,
when Shift-home pressed (center view on capital), get msg -
"Oh my! You seem to have no capital!"
In player.c function player_primary_capital(), pplayer->primary_capital_id is 0,
until Turn Done causes plrhand.c function update_capital() to set pplayer->primary_capital_id correctly.
Files
Updated by Marko Lindqvist 7 days ago
Yes, by current rules you get capital, or capital moves at turn change time.
Updated by Dean Brown 3 days ago
- File 1493.patch 1493.patch added
I see 3 ways this issue can happen -
1 built your first city, get a free palace
2 lose your city with palace, get a free palace in another city
3 load a saved game
For 1 & 2, the help says "If you lose the city containing this improvement, it will be rebuilt for free in another of your cities (if the 'savepalace' server setting is enabled)." It doesn't say whether this happens immediately or at turn change time, so I think it's OK to leave things as they are.
For 3, I had a capital when I saved the game, so I should still have it when I reload that saved game - maybe I've got dozens of units to be moved scattered all over and really want Shift-home to work. This simple patch fixes that case, should be OK for all branches.
While investigating, I found something I don't really understand. This is unpatched behavior. In the server when "load xxx" is done, savegame_load() is called and my player pointer has value pplayer = 0x7f8a1b087600, pplayer->primary_capital_id = 0, my city pcity->capital = 0. When the game is started, update_capital() is called, pplayer = 0x7f8a1b087600 is the same player pointer, pplayer->primary_capital_id is now 188, my city pcity->capital is now 1. Then I do the Shift-home, and in the client, player_primary_capital() is called with pplayer = 0x7f8865c6aa00, which is a different player pointer value, and its pplayer->primary_capital_id = 0. At turn change, update_capital() is called again, also with pplayer = 0x7f8a1b087600. Then when I do Shift-home again, in the client, player_primary_capital() is called again with that different player pointer pplayer = 0x7f8865c6aa00 but now the pplayer->primary_capital_id is correct. Do the server and client have separate lists of player pointers? that they somehow try to keep in synch?
Updated by Marko Lindqvist 3 days ago
- Category changed from gtk3.22-client to Server
For S3_3 and main the right thing to do is to save the turn change time capital scores, and not to recalculate score at the load time (middle of the turn, might be different from previous turn change time score).
--
Server and client are separate processes (programs). They cannot have pointers to each others memory.
Updated by Marko Lindqvist 3 days ago
- File 0102-savegame3.c-Save-city-capital-status.patch 0102-savegame3.c-Save-city-capital-status.patch added
Patch for S3_3 and main to save/load capital type.
What is missing is handling the case where we load an older savegame with no capital information. This handling is likely similar in all branches (in S3_1 and S3_2 the savegames just never have the capital information), and could go to a separate ticket.
Updated by Marko Lindqvist 3 days ago
- Status changed from New to In Review
- Assignee set to Marko Lindqvist
- Target version set to 3.3.0-d3f
Marko Lindqvist wrote in #note-4:
What is missing is handling the case where we load an older savegame with no capital information. This handling is likely similar in all branches (in S3_1 and S3_2 the savegames just never have the capital information), and could go to a separate ticket.
The handling is different between S3_1 & S3_2 vs S3_3 & main, so splitting this ticket to three now.
1) This ticket has save/load for the capital information
2) #1523 is about S3_3/main fallback handling of old savegames
3) #1524 is about handling S3_1/S3_2