Changeset - r3475:8e887b066edc
[Not reviewed]
master
0 1 0
celestar - 19 years ago 2006-04-08 05:44:37
celestar@openttd.org
(svn r4320) -Fix/Codechange: rs->num_vehicles is no longer saved or loaded, but computed on the fly. Partly fixes FS#101
1 file changed with 6 insertions and 2 deletions:
0 comments (0 inline, 0 general)
station_cmd.c
Show inline comments
 
@@ -2740,25 +2740,25 @@ static const SaveLoad _roadstop_desc[] =
 
	SLE_VAR(RoadStop,xy,           SLE_UINT32),
 
	SLE_VAR(RoadStop,used,         SLE_UINT8),
 
	SLE_VAR(RoadStop,status,       SLE_UINT8),
 
	/* Index was saved in some versions, but this is not needed */
 
	SLE_CONDNULL(4, 0, 8),
 
	SLE_VAR(RoadStop,station,      SLE_UINT16),
 
	SLE_VAR(RoadStop,type,         SLE_UINT8),
 

	
 
	SLE_REF(RoadStop,next,         REF_ROADSTOPS),
 
	SLE_REF(RoadStop,prev,         REF_ROADSTOPS),
 

	
 
	SLE_CONDNULL(4, 0, 24),
 
	SLE_CONDVAR(RoadStop, num_vehicles, SLE_UINT8, 25, SL_MAX_VERSION),
 
	SLE_CONDNULL(1, 25, 25),
 

	
 
	SLE_END()
 
};
 

	
 
static const SaveLoad _station_desc[] = {
 
	SLE_CONDVAR(Station, xy,           SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
 
	SLE_CONDVAR(Station, xy,           SLE_UINT32, 6, SL_MAX_VERSION),
 
	SLE_CONDVAR(Station, bus_tile_obsolete,    SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
 
	SLE_CONDVAR(Station, lorry_tile_obsolete,  SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
 
	SLE_CONDVAR(Station, train_tile,   SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
 
	SLE_CONDVAR(Station, train_tile,   SLE_UINT32, 6, SL_MAX_VERSION),
 
	SLE_CONDVAR(Station, airport_tile, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
 
@@ -2901,29 +2901,33 @@ static void Save_ROADSTOP(void)
 

	
 
	FOR_ALL_ROADSTOPS(rs) {
 
		if (rs->used) {
 
			SlSetArrayIndex(rs->index);
 
			SlObject(rs, _roadstop_desc);
 
		}
 
	}
 
}
 

	
 
static void Load_ROADSTOP(void)
 
{
 
	int index;
 
	Vehicle *v;
 

	
 
	while ((index = SlIterateArray()) != -1) {
 
		RoadStop *rs;
 

	
 
		if (!AddBlockIfNeeded(&_roadstop_pool, index))
 
			error("RoadStops: failed loading savegame: too many RoadStops");
 

	
 
		rs = GetRoadStop(index);
 
		rs->num_vehicles = 0;
 
		SlObject(rs, _roadstop_desc);
 
	}
 

	
 
	FOR_ALL_VEHICLES(v) {
 
		if (v->type == VEH_Road && v->u.road.slot != NULL) GetRoadStopByTile(v->dest_tile, v->cargo_type == CT_PASSENGERS ? RS_BUS : RS_TRUCK)->num_vehicles++;
 
	}
 
}
 

	
 
const ChunkHandler _station_chunk_handlers[] = {
 
	{ 'STNS', Save_STNS,      Load_STNS,      CH_ARRAY },
 
	{ 'ROAD', Save_ROADSTOP,  Load_ROADSTOP,  CH_ARRAY | CH_LAST},
 
};
0 comments (0 inline, 0 general)