summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2005-02-04 14:24:23 +0000
committertruelight <truelight@openttd.org>2005-02-04 14:24:23 +0000
commit97728357e442315962c62927032f1daa97ff107d (patch)
tree9b5dccb928528ebebcb07c1edd681e786d4e0f9f
parent7be92db76f0903c13de0100c5f9211ea8b779bfa (diff)
downloadopenttd-97728357e442315962c62927032f1daa97ff107d.tar.xz
(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)
-rw-r--r--aircraft_cmd.c2
-rw-r--r--roadveh_cmd.c2
-rw-r--r--saveload.c2
-rw-r--r--settings.c8
-rw-r--r--settings_gui.c8
-rw-r--r--ship_cmd.c2
-rw-r--r--train_cmd.c4
-rw-r--r--variables.h10
-rw-r--r--vehicle.c7
-rw-r--r--vehicle.h4
10 files changed, 26 insertions, 23 deletions
diff --git a/aircraft_cmd.c b/aircraft_cmd.c
index 1eefa66f6..fbde61536 100644
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -156,7 +156,7 @@ int32 CmdBuildAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
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
index 63f40e1d1..563ccc7a3 100644
--- a/roadveh_cmd.c
+++ b/roadveh_cmd.c
@@ -113,7 +113,7 @@ int32 CmdBuildRoadVeh(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
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
index 66ac65af7..71596a883 100644
--- 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
index 4e299b7bb..61847f464 100644
--- 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
index c691f2da7..af394b3ae 100644
--- a/settings_gui.c
+++ b/settings_gui.c
@@ -661,10 +661,10 @@ static const PatchEntry _patches_vehicles[] = {
{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
index 42614ed1d..4a6a19ffc 100644
--- a/ship_cmd.c
+++ b/ship_cmd.c
@@ -873,7 +873,7 @@ int32 CmdBuildShip(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
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
index 3f56fa801..5af4f77ab 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -535,7 +535,7 @@ int32 CmdBuildRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
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, uint32 flags, uint32 p1, uint32 p2)
// 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
index 214406b26..69fab868b 100644
--- 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
index 4a0048267..9e56287b5 100644
--- a/vehicle.c
+++ b/vehicle.c
@@ -1762,9 +1762,9 @@ uint32 VehicleEnterTile(Vehicle *v, uint tile, int x, int y)
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
index 716aad77d..9e056edf9 100644
--- 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);