Changeset - r17292:d19d0b18c8d8
[Not reviewed]
master
0 1 0
smatz - 14 years ago 2011-02-09 18:56:40
smatz@openttd.org
(svn r22042) -Fix: when loading a TTO/TTD savegame, verify we can allocate a CargoPacket before actually trying to do so
1 file changed with 2 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/saveload/oldloader_sl.cpp
Show inline comments
 
@@ -701,25 +701,25 @@ static const OldChunks goods_chunk[] = {
 
static bool LoadOldGood(LoadgameState *ls, int num)
 
{
 
	/* for TTO games, 12th (num == 11) goods entry is created in the Station constructor */
 
	if (_savegame_type == SGT_TTO && num == 11) return true;
 

	
 
	Station *st = Station::Get(_current_station_id);
 
	GoodsEntry *ge = &st->goods[num];
 

	
 
	if (!LoadChunk(ls, ge, goods_chunk)) return false;
 

	
 
	SB(ge->acceptance_pickup, GoodsEntry::ACCEPTANCE, 1, HasBit(_waiting_acceptance, 15));
 
	SB(ge->acceptance_pickup, GoodsEntry::PICKUP, 1, _cargo_source != 0xFF);
 
	if (GB(_waiting_acceptance, 0, 12) != 0) {
 
	if (GB(_waiting_acceptance, 0, 12) != 0 && CargoPacket::CanAllocateItem()) {
 
		ge->cargo.Append(new CargoPacket(GB(_waiting_acceptance, 0, 12), _cargo_days, (_cargo_source == 0xFF) ? INVALID_STATION : _cargo_source, 0, 0));
 
	}
 

	
 
	return true;
 
}
 

	
 
static const OldChunks station_chunk[] = {
 
	OCL_SVAR(   OC_TILE, Station, xy ),
 
	OCL_VAR ( OC_UINT32,   1, &_old_town_index ),
 

	
 
	OCL_NULL( 4 ), ///< bus/lorry tile
 
	OCL_SVAR(   OC_TILE, Station, train_station.tile ),
 
@@ -1338,25 +1338,25 @@ bool LoadOldVehicle(LoadgameState *ls, i
 
			}
 
		}
 

	
 
		if (_old_order_ptr != 0 && _old_order_ptr != 0xFFFFFFFF) {
 
			uint max = _savegame_type == SGT_TTO ? 3000 : 5000;
 
			uint old_id = RemapOrderIndex(_old_order_ptr);
 
			if (old_id < max) v->orders.old = Order::Get(old_id); // don't accept orders > max number of orders
 
		}
 
		v->current_order.AssignOrder(UnpackOldOrder(_old_order));
 

	
 
		v->next = (Vehicle *)(size_t)_old_next_ptr;
 

	
 
		if (_cargo_count != 0) {
 
		if (_cargo_count != 0 && CargoPacket::CanAllocateItem()) {
 
			StationID source =    (_cargo_source == 0xFF) ? INVALID_STATION : _cargo_source;
 
			TileIndex source_xy = (source != INVALID_STATION) ? Station::Get(source)->xy : 0;
 
			v->cargo.Append(new CargoPacket(_cargo_count, _cargo_days, source, source_xy, source_xy));
 
		}
 
	}
 

	
 
	return true;
 
}
 

	
 
static const OldChunks sign_chunk[] = {
 
	OCL_VAR ( OC_UINT16, 1, &_old_string_id ),
 
	OCL_SVAR( OC_FILE_U16 | OC_VAR_I32, Sign, x ),
0 comments (0 inline, 0 general)