Changeset - r1282:086fc2f1272e
[Not reviewed]
master
0 10 0
truelight - 19 years ago 2005-02-04 14:24:23
truelight@openttd.org
(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)
10 files changed with 26 insertions and 23 deletions:
0 comments (0 inline, 0 general)
aircraft_cmd.c
Show inline comments
 
@@ -153,13 +153,13 @@ int32 EstimateAircraftCost(uint16 engine
 

	
 
/* p1 = engine */
 
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;
 

	
 
	if (!IsEngineBuildable(p1, VEH_Aircraft)) return CMD_ERROR;
 

	
roadveh_cmd.c
Show inline comments
 
@@ -110,13 +110,13 @@ int32 EstimateRoadVehCost(byte engine_ty
 
// p1 = engine_type
 
// p2 not used
 
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;
 

	
 
	if (!IsEngineBuildable(p1, VEH_Road)) return CMD_ERROR;
 

	
 
	if (!IsRoadDepotTile((TileIndex)tile)) return CMD_ERROR;
saveload.c
Show inline comments
 
@@ -4,13 +4,13 @@
 
#include "station.h"
 
#include "town.h"
 
#include "player.h"
 
#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
 
};
 

	
 
/******************************************************/
settings.c
Show inline comments
 
@@ -864,16 +864,16 @@ const SettingDesc patch_settings[] = {
 
	{"nonuniform_stations",	SDT_BOOL,		(void*)true,	&_patches.nonuniform_stations,	NULL},
 
	{"always_small_airport",SDT_BOOL,		(void*)false,	&_patches.always_small_airport,	NULL},
 
	{"realistic_acceleration",SDT_BOOL, (void*)false,	&_patches.realistic_acceleration,	NULL},
 
	{"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},
 
	{"servint_roadveh",			SDT_UINT16, (void*)150,		&_patches.servint_roadveh,			NULL},
 
	{"servint_ships",				SDT_UINT16, (void*)360,		&_patches.servint_ships,				NULL},
 
	{"servint_aircraft",		SDT_UINT16, (void*)100,		&_patches.servint_aircraft,			NULL},
settings_gui.c
Show inline comments
 
@@ -658,16 +658,16 @@ static const PatchEntry _patches_vehicle
 

	
 
	{PE_UINT16, PF_0ISDIS | PF_PLAYERBASED, STR_CONFIG_PATCHES_LOST_TRAIN_DAYS, "lost_train_days", &_patches.lost_train_days,	180,720, 60, NULL},
 
	{PE_BOOL,		PF_PLAYERBASED, STR_CONFIG_PATCHES_AUTORENEW_VEHICLE,"autorenew", &_patches.autorenew,								0,  0,  0, NULL},
 
	{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},
 
	{PE_UINT16, PF_0ISDIS, STR_CONFIG_PATCHES_SERVINT_ROADVEH,	"servint_roadveh",  &_patches.servint_roadveh,	5,800,  5, &InValidateDetailsWindow},
 
	{PE_UINT16, PF_0ISDIS, STR_CONFIG_PATCHES_SERVINT_AIRCRAFT, "servint_aircraft", &_patches.servint_aircraft, 5,800,  5, &InValidateDetailsWindow},
 
	{PE_UINT16, PF_0ISDIS, STR_CONFIG_PATCHES_SERVINT_SHIPS,		"servint_ships",    &_patches.servint_ships,		5,800,  5, &InValidateDetailsWindow},
ship_cmd.c
Show inline comments
 
@@ -870,13 +870,13 @@ int32 EstimateShipCost(uint16 engine_typ
 

	
 
// p1 = type to build
 
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;
 

	
 
	if (!IsEngineBuildable(p1, VEH_Ship)) return CMD_ERROR;
 

	
 
	if (!IsShipDepotTile((TileIndex)tile)) return CMD_ERROR;
train_cmd.c
Show inline comments
 
@@ -532,13 +532,13 @@ void AddRearEngineToMultiheadedTrain(Veh
 

	
 
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);
 

	
 
	if (!IsEngineBuildable(p1, VEH_Train)) return CMD_ERROR;
 

	
 
	if (!IsTrainDepotTile((TileIndex)tile)) return CMD_ERROR;
 
@@ -771,13 +771,13 @@ int32 CmdMoveRailVehicle(int x, int y, u
 
	// when moving all wagons, we can't have the same src_head and dst_head
 
	if (p2 & 1 && src_head == dst_head)
 
		return 0;
 

	
 
	// 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);
 

	
 
		if (flags & DC_EXEC)
 
			src->unitnumber = unit_num;
 
	}
variables.h
Show inline comments
 
@@ -8,12 +8,14 @@
 
// ********* START OF SAVE REGION
 

	
 
#if !defined(MAX_PATH)
 
# 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];
 

	
 
VARDEF uint32 _cargo_payment_rates[NUM_CARGO];
 
VARDEF uint16 _cargo_payment_rates_frac[NUM_CARGO];
 
@@ -132,16 +134,16 @@ typedef struct Patches {
 
	bool invisible_trees; // don't show trees when buildings are transparent
 
	bool no_servicing_if_no_breakdowns; // dont send vehicles to depot when breakdowns are disabled
 

	
 
	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
 
	uint16 servint_roadveh;	// service interval for road vehicles
 
	uint16 servint_aircraft;// service interval for aircraft
 
	uint16 servint_ships;		// service interval for ships
vehicle.c
Show inline comments
 
@@ -1759,15 +1759,15 @@ uint32 VehicleEnterTile(Vehicle *v, uint
 
		if (proc != NULL)
 
			proc(v, old_tile, x, y);
 
	}
 
	return result;
 
}
 

	
 
uint GetFreeUnitNumber(byte type)
 
UnitID GetFreeUnitNumber(byte type)
 
{
 
	uint unit_num = 0;
 
	UnitID unit_num = 0;
 
	Vehicle *u;
 

	
 
restart:
 
	unit_num++;
 
	FOR_ALL_VEHICLES(u) {
 
		if (u->type == type && u->owner == _current_player &&
 
@@ -1781,13 +1781,14 @@ restart:
 
// Save and load of vehicles
 
const byte _common_veh_desc[] = {
 
	SLE_VAR(Vehicle,subtype,					SLE_UINT8),
 

	
 
	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),
 
	SLE_CONDVAR(Vehicle,dest_tile,		SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
 
	SLE_CONDVAR(Vehicle,dest_tile,		SLE_UINT32, 6, 255),
 

	
vehicle.h
Show inline comments
 
@@ -97,13 +97,13 @@ struct Vehicle {
 
	uint16 index;			// NOSAVE: Index in vehicle array
 

	
 
	Vehicle *next;		// next
 

	
 
	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
 
	TileIndex dest_tile; // Heading for this tile
 

	
 
	int32 x_pos;			// coordinates
 
@@ -328,13 +328,13 @@ void BeginVehicleMove(Vehicle *v);
 
void EndVehicleMove(Vehicle *v);
 

	
 
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);
 
uint GetWaypointByTile(uint tile);
 

	
 
void DoDeleteDepot(uint tile);
0 comments (0 inline, 0 general)