# HG changeset patch # User truelight # Date 2005-02-04 14:24:23 # Node ID 086fc2f1272e0d7d7214630c313fc3808d62de0f # Parent 0c84db999f63168d34a9e5d818b7184121f52a69 (svn r1786) -Fix: unitnumber is increased to 16bit, so now you can have up to 5000 trains in one game (instead of the 240 which was the current value). Default max allowed vehicles per type is changed: Trains: 500 (old 80) Road: 500 (old 80) Ships: 200 (old 40) Aicraft: 300 (old 50) (Tnx to Celestar and Darkvater for checking the patch) diff --git a/aircraft_cmd.c b/aircraft_cmd.c --- a/aircraft_cmd.c +++ b/aircraft_cmd.c @@ -156,7 +156,7 @@ int32 CmdBuildAircraft(int x, int y, uin { int32 value; Vehicle *vl[3], *v, *u, *w; - byte unit_num; + UnitID unit_num; uint tile = TILE_FROM_XY(x,y); const AircraftVehicleInfo *avi = AircraftVehInfo(p1); Engine *e; diff --git a/roadveh_cmd.c b/roadveh_cmd.c --- a/roadveh_cmd.c +++ b/roadveh_cmd.c @@ -113,7 +113,7 @@ int32 CmdBuildRoadVeh(int x, int y, uint { int32 cost; Vehicle *v; - byte unit_num; + UnitID unit_num; uint tile = TILE_FROM_XY(x,y); Engine *e; diff --git a/saveload.c b/saveload.c --- a/saveload.c +++ b/saveload.c @@ -7,7 +7,7 @@ #include "saveload.h" enum { - SAVEGAME_MAJOR_VERSION = 7, + SAVEGAME_MAJOR_VERSION = 8, SAVEGAME_MINOR_VERSION = 0, SAVEGAME_LOADABLE_VERSION = (SAVEGAME_MAJOR_VERSION << 8) + SAVEGAME_MINOR_VERSION diff --git a/settings.c b/settings.c --- a/settings.c +++ b/settings.c @@ -867,10 +867,10 @@ const SettingDesc patch_settings[] = { {"forbid_90_deg", SDT_BOOL, (void*)false, &_patches.forbid_90_deg, NULL}, {"improved_load", SDT_BOOL, (void*)false, &_patches.improved_load, NULL}, - {"max_trains", SDT_UINT8, (void*)80, &_patches.max_trains, NULL}, - {"max_roadveh", SDT_UINT8, (void*)80, &_patches.max_roadveh, NULL}, - {"max_aircraft", SDT_UINT8, (void*)40, &_patches.max_aircraft, NULL}, - {"max_ships", SDT_UINT8, (void*)50, &_patches.max_ships, NULL}, + {"max_trains", SDT_UINT16, (void*)500, &_patches.max_trains, NULL}, + {"max_roadveh", SDT_UINT16, (void*)500, &_patches.max_roadveh, NULL}, + {"max_aircraft", SDT_UINT16, (void*)200, &_patches.max_aircraft, NULL}, + {"max_ships", SDT_UINT16, (void*)300, &_patches.max_ships, NULL}, {"servint_ispercent", SDT_BOOL, (void*)false, &_patches.servint_ispercent, NULL}, {"servint_trains", SDT_UINT16, (void*)150, &_patches.servint_trains, NULL}, diff --git a/settings_gui.c b/settings_gui.c --- a/settings_gui.c +++ b/settings_gui.c @@ -661,10 +661,10 @@ static const PatchEntry _patches_vehicle {PE_INT16, PF_PLAYERBASED, STR_CONFIG_PATCHES_AUTORENEW_MONTHS, "autorenew_months", &_patches.autorenew_months, -12, 12, 1, NULL}, {PE_CURRENCY, PF_PLAYERBASED, STR_CONFIG_PATCHES_AUTORENEW_MONEY,"autorenew_money", &_patches.autorenew_money, 0, 2000000, 100000, NULL}, - {PE_UINT8, 0, STR_CONFIG_PATCHES_MAX_TRAINS, "max_trains", &_patches.max_trains, 0,240, 10, NULL}, - {PE_UINT8, 0, STR_CONFIG_PATCHES_MAX_ROADVEH, "max_roadveh", &_patches.max_roadveh, 0,240, 10, NULL}, - {PE_UINT8, 0, STR_CONFIG_PATCHES_MAX_AIRCRAFT, "max_aircraft", &_patches.max_aircraft, 0,240, 10, NULL}, - {PE_UINT8, 0, STR_CONFIG_PATCHES_MAX_SHIPS, "max_ships", &_patches.max_ships, 0,240, 10, NULL}, + {PE_UINT16, 0, STR_CONFIG_PATCHES_MAX_TRAINS, "max_trains", &_patches.max_trains, 0,5000, 50, NULL}, + {PE_UINT16, 0, STR_CONFIG_PATCHES_MAX_ROADVEH, "max_roadveh", &_patches.max_roadveh, 0,5000, 50, NULL}, + {PE_UINT16, 0, STR_CONFIG_PATCHES_MAX_AIRCRAFT, "max_aircraft", &_patches.max_aircraft, 0,5000, 50, NULL}, + {PE_UINT16, 0, STR_CONFIG_PATCHES_MAX_SHIPS, "max_ships", &_patches.max_ships, 0,5000, 50, NULL}, {PE_BOOL, 0, STR_CONFIG_PATCHES_SERVINT_ISPERCENT,"servint_isperfect",&_patches.servint_ispercent, 0, 0, 0, &CheckInterval}, {PE_UINT16, PF_0ISDIS, STR_CONFIG_PATCHES_SERVINT_TRAINS, "servint_trains", &_patches.servint_trains, 5,800, 5, &InValidateDetailsWindow}, diff --git a/ship_cmd.c b/ship_cmd.c --- a/ship_cmd.c +++ b/ship_cmd.c @@ -873,7 +873,7 @@ int32 CmdBuildShip(int x, int y, uint32 { int32 value; Vehicle *v; - uint unit_num; + UnitID unit_num; uint tile = TILE_FROM_XY(x,y); Engine *e; diff --git a/train_cmd.c b/train_cmd.c --- a/train_cmd.c +++ b/train_cmd.c @@ -535,7 +535,7 @@ int32 CmdBuildRailVehicle(int x, int y, const RailVehicleInfo *rvi; int value,dir; Vehicle *v, *u; - byte unit_num; + UnitID unit_num; Engine *e; uint tile = TILE_FROM_XY(x,y); @@ -774,7 +774,7 @@ int32 CmdMoveRailVehicle(int x, int y, u // moving a loco to a new line?, then we need to assign a unitnumber. if (dst == NULL && src->subtype != TS_Front_Engine && is_loco) { - uint unit_num = GetFreeUnitNumber(VEH_Train); + UnitID unit_num = GetFreeUnitNumber(VEH_Train); if (unit_num > _patches.max_trains) return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); diff --git a/variables.h b/variables.h --- a/variables.h +++ b/variables.h @@ -11,6 +11,8 @@ # define MAX_PATH 260 #endif +typedef uint16 UnitID; //! All unitnumber stuff is of this type (or anyway, should be) + // Prices and also the fractional part. VARDEF Prices _price; VARDEF uint16 _price_frac[NUM_PRICES]; @@ -135,10 +137,10 @@ typedef struct Patches { uint8 toolbar_pos; // position of toolbars, 0=left, 1=center, 2=right uint8 window_snap_radius; // Windows snap at each other if closer than this - byte max_trains; //max trains in game per player (these are 8bit because the unitnumber field can't hold more) - byte max_roadveh; //max trucks in game per player - byte max_aircraft; //max planes in game per player - byte max_ships; //max ships in game per player + UnitID max_trains; //max trains in game per player (these are 16bit because the unitnumber field can't hold more) + UnitID max_roadveh; //max trucks in game per player + UnitID max_aircraft; //max planes in game per player + UnitID max_ships; //max ships in game per player bool servint_ispercent; // service intervals are in percents uint16 servint_trains; // service interval for trains diff --git a/vehicle.c b/vehicle.c --- a/vehicle.c +++ b/vehicle.c @@ -1762,9 +1762,9 @@ uint32 VehicleEnterTile(Vehicle *v, uint return result; } -uint GetFreeUnitNumber(byte type) +UnitID GetFreeUnitNumber(byte type) { - uint unit_num = 0; + UnitID unit_num = 0; Vehicle *u; restart: @@ -1784,7 +1784,8 @@ const byte _common_veh_desc[] = { SLE_REF(Vehicle,next, REF_VEHICLE_OLD), SLE_VAR(Vehicle,string_id, SLE_STRINGID), - SLE_VAR(Vehicle,unitnumber, SLE_UINT8), + SLE_CONDVAR(Vehicle,unitnumber, SLE_FILE_U8 | SLE_VAR_U16, 0, 7), + SLE_CONDVAR(Vehicle,unitnumber, SLE_UINT16, 8, 255), SLE_VAR(Vehicle,owner, SLE_UINT8), SLE_CONDVAR(Vehicle,tile, SLE_FILE_U16 | SLE_VAR_U32, 0, 5), SLE_CONDVAR(Vehicle,tile, SLE_UINT32, 6, 255), diff --git a/vehicle.h b/vehicle.h --- a/vehicle.h +++ b/vehicle.h @@ -100,7 +100,7 @@ struct Vehicle { StringID string_id; // Displayed string - byte unitnumber; // unit number, for display purposes only + UnitID unitnumber; // unit number, for display purposes only byte owner; // which player owns the vehicle? TileIndex tile; // Current tile index @@ -331,7 +331,7 @@ bool IsAircraftHangarTile(TileIndex tile void ShowAircraftViewWindow(Vehicle *v); bool IsShipDepotTile(TileIndex tile); -uint GetFreeUnitNumber(byte type); +UnitID GetFreeUnitNumber(byte type); int LoadUnloadVehicle(Vehicle *v); int GetDepotByTile(uint tile);