Skip to content

Commit

Permalink
FIX: loading of roadsings broken for player >=8 and old versions
Browse files Browse the repository at this point in the history
	CHG: create lost players during game laoding to recover more from broken savegames

git-svn-id: svn://tron.homeunix.org/simutrans/simutrans/trunk@11403 8aca7d54-2c30-db11-9de9-000461428c89
  • Loading branch information
prissi committed Sep 8, 2024
1 parent 98b456a commit 7038619
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 10 deletions.
2 changes: 2 additions & 0 deletions simutrans/history.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FIX: open schedule get applied during rw (reload, quit, change language), line window crashes
CHG: no way foreground draw in stations and depots (and other buildings)
FIX: loading of roadsings broken for player >=8 and old versions
CHG: create lost players during game laoding to recover more from broken savegames


Release of 124.2.2 (r11400 on 2-Sep-2024):
Expand Down
5 changes: 2 additions & 3 deletions src/simutrans/obj/roadsign.cc
Original file line number Diff line number Diff line change
Expand Up @@ -631,11 +631,10 @@ void roadsign_t::rdwr(loadsave_t *file)
}
// init ownership of private ways signs
if( desc && desc->is_private_way() ) {
ticks_ns = 0xFD;
ticks_ow = 0xFF;
if( file->is_version_less(124, 2) ) {
// private sign mask now in ticks_ow and ticks_offset
ticks_ns = ticks_offset;
ticks_offset = ticks_ns;
ticks_ns = 0xFF;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/simutrans/simconvoi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2268,7 +2268,7 @@ void convoi_t::rdwr(loadsave_t *file)
if(vehicle_count > fahr.get_count()) {
fahr.resize(vehicle_count, NULL);
}
owner = welt->get_player( owner_n );
owner = welt->get_player_or_create( owner_n );

// sanity check for values ... plus correction
if(sp_soll < 0) {
Expand Down
6 changes: 1 addition & 5 deletions src/simutrans/simhalt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2781,11 +2781,7 @@ void haltestelle_t::rdwr(loadsave_t *file)
}

if(file->is_loading()) {
owner = welt->get_player(owner_n);
if (!owner) {
dbg->fatal("haltestelle_t::rdwr", "Halt (%hu) has no owner!", self.get_id());
}

owner = welt->get_player_or_create(owner_n);
k.rdwr( file );
while(k!=koord3d::invalid) {
grund_t *gr = welt->lookup(k);
Expand Down
12 changes: 12 additions & 0 deletions src/simutrans/world/simworld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3978,6 +3978,18 @@ static pthread_mutex_t height_mutex;
static recursive_mutex_maker_t height_mutex_maker(height_mutex);
#endif

player_t* karte_t::get_player_or_create(uint8 n)
{
n &= 15;
if (players[n]) {
return players[n];
}
dbg->error("get_player()", "No player %d in this game -> make a new one", n);
players[n] = new player_t(n);
return players[n];
}



void karte_t::plans_finish_rd( sint16 x_min, sint16 x_max, sint16 y_min, sint16 y_max )
{
Expand Down
4 changes: 3 additions & 1 deletion src/simutrans/world/simworld.h
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,9 @@ class karte_t : public surface_t
* Player management here
*/
uint8 sp2num(player_t *player);
player_t * get_player(uint8 n) const { return players[n&15]; }
player_t* get_player(uint8 n) const { return players[n&15]; }
// return player or gives error and cerates player to recover broken savegames
player_t* get_player_or_create(uint8 n);
player_t* get_active_player() const { return active_player; }
uint8 get_active_player_nr() const { return active_player_nr; }
void switch_active_player(uint8 nr, bool silent);
Expand Down

0 comments on commit 7038619

Please sign in to comment.