diff -r 4bf29d14edba -r c30fe89622df src/oldloader.cpp --- a/src/oldloader.cpp Sat Mar 10 11:07:13 2007 +0000 +++ b/src/oldloader.cpp Sun Mar 11 16:31:18 2007 +0000 @@ -27,7 +27,7 @@ OLD_MAP_SIZE = 256 * 256 }; -typedef struct LoadgameState { +struct LoadgameState { FILE *file; uint chunk_size; @@ -41,10 +41,10 @@ uint total_read; bool failed; -} LoadgameState; +}; /* OldChunk-Type */ -typedef enum OldChunkTypes { +enum OldChunkType { OC_SIMPLE = 0, OC_NULL = 1, OC_CHUNK = 2, @@ -78,20 +78,20 @@ OC_TILE = OC_VAR_U32 | OC_FILE_U16, OC_END = 0 ///< End of the whole chunk, all 32bits set to zero -} OldChunkType; +}; DECLARE_ENUM_AS_BIT_SET(OldChunkType); typedef bool OldChunkProc(LoadgameState *ls, int num); -typedef struct OldChunks { +struct OldChunks { OldChunkType type; ///< Type of field uint32 amount; ///< Amount of fields void *ptr; ///< Pointer where to save the data (may only be set if offset is 0) uint offset; ///< Offset from basepointer (may only be set if ptr is NULL) OldChunkProc *proc; ///< Pointer to function that is called with OC_CHUNK -} OldChunks; +}; /* If it fails, check lines above.. */ assert_compile(sizeof(TileIndex) == 4); @@ -290,7 +290,7 @@ extern uint32 GetOldTownName(uint32 townnameparts, byte old_town_name_type); -static void FixOldTowns(void) +static void FixOldTowns() { Town *town; @@ -303,7 +303,7 @@ } } -static void FixOldStations(void) +static void FixOldStations() { Station *st; @@ -315,7 +315,7 @@ } } -static void FixOldVehicles(void) +static void FixOldVehicles() { /* Check for shared orders, and link them correctly */ Vehicle* v; @@ -374,7 +374,7 @@ static uint16 _old_string_id_2; static uint16 _old_extra_chunk_nums; -static void ReadTTDPatchFlags(void) +static void ReadTTDPatchFlags() { int i; @@ -486,9 +486,9 @@ AssignOrder(GetOrder(num), UnpackOldOrder(_old_order)); /* Relink the orders to eachother (in TTD(Patch) the orders for one - vehicle are behind eachother, with OT_NOTHING as indication that + vehicle are behind eachother, with an invalid order (OT_NOTHING) as indication that it is the last order */ - if (num > 0 && GetOrder(num)->type != OT_NOTHING) + if (num > 0 && GetOrder(num)->IsValid()) GetOrder(num - 1)->next = GetOrder(num); return true; @@ -1068,13 +1068,13 @@ * Basically v->type -= 0x10; would suffice, but play safely */ switch (v->type) { default: NOT_REACHED(); - case 0x00 /*VEH_Invalid */: v->type = VEH_Invalid; res = LoadChunk(ls, NULL, vehicle_empty_chunk); break; - case 0x10 /*VEH_Train */: v->type = VEH_Train; res = LoadChunk(ls, &v->u.rail, vehicle_train_chunk); break; - case 0x11 /*VEH_Road */: v->type = VEH_Road; res = LoadChunk(ls, &v->u.road, vehicle_road_chunk); break; - case 0x12 /*VEH_Ship */: v->type = VEH_Ship; res = LoadChunk(ls, &v->u.ship, vehicle_ship_chunk); break; - case 0x13 /*VEH_Aircraft*/: v->type = VEH_Aircraft; res = LoadChunk(ls, &v->u.air, vehicle_air_chunk); break; - case 0x14 /*VEH_Special */: v->type = VEH_Special; res = LoadChunk(ls, &v->u.special, vehicle_special_chunk); break; - case 0x15 /*VEH_Disaster*/: v->type = VEH_Disaster; res = LoadChunk(ls, &v->u.disaster, vehicle_disaster_chunk); break; + case 0x00 /*VEH_INVALID */: v->type = VEH_INVALID; res = LoadChunk(ls, NULL, vehicle_empty_chunk); break; + case 0x10 /*VEH_TRAIN */: v->type = VEH_TRAIN; res = LoadChunk(ls, &v->u.rail, vehicle_train_chunk); break; + case 0x11 /*VEH_ROAD */: v->type = VEH_ROAD; res = LoadChunk(ls, &v->u.road, vehicle_road_chunk); break; + case 0x12 /*VEH_SHIP */: v->type = VEH_SHIP; res = LoadChunk(ls, &v->u.ship, vehicle_ship_chunk); break; + case 0x13 /*VEH_AIRCRAFT*/: v->type = VEH_AIRCRAFT; res = LoadChunk(ls, &v->u.air, vehicle_air_chunk); break; + case 0x14 /*VEH_SPECIAL */: v->type = VEH_SPECIAL; res = LoadChunk(ls, &v->u.special, vehicle_special_chunk); break; + case 0x15 /*VEH_DISASTER*/: v->type = VEH_DISASTER; res = LoadChunk(ls, &v->u.disaster, vehicle_disaster_chunk); break; } /* This chunk size should always be 10 bytes */ @@ -1209,7 +1209,7 @@ v->string_id = RemapOldStringID(_old_string_id); /* Vehicle-subtype is different in TTD(Patch) */ - if (v->type == VEH_Special) v->subtype = v->subtype >> 1; + if (v->type == VEH_SPECIAL) v->subtype = v->subtype >> 1; } return true; @@ -1611,7 +1611,7 @@ fclose(ls.file); - _pause = 2; + _pause_game = 2; return true; }