mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-16 00:12:51 +00:00
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
This commit is contained in:
parent
d7af8df07b
commit
aac5e2c131
24
engine.h
24
engine.h
@ -241,31 +241,37 @@ static inline bool IsEngineIndex(uint index)
|
|||||||
|
|
||||||
/* Access Vehicle Data */
|
/* Access Vehicle Data */
|
||||||
//#include "table/engines.h"
|
//#include "table/engines.h"
|
||||||
extern EngineInfo _engine_info[TOTAL_NUM_ENGINES];
|
extern const EngineInfo orig_engine_info[TOTAL_NUM_ENGINES];
|
||||||
extern RailVehicleInfo _rail_vehicle_info[NUM_TRAIN_ENGINES];
|
extern const RailVehicleInfo orig_rail_vehicle_info[NUM_TRAIN_ENGINES];
|
||||||
extern ShipVehicleInfo _ship_vehicle_info[NUM_SHIP_ENGINES];
|
extern const ShipVehicleInfo orig_ship_vehicle_info[NUM_SHIP_ENGINES];
|
||||||
extern AircraftVehicleInfo _aircraft_vehicle_info[NUM_AIRCRAFT_ENGINES];
|
extern const AircraftVehicleInfo orig_aircraft_vehicle_info[NUM_AIRCRAFT_ENGINES];
|
||||||
extern RoadVehicleInfo _road_vehicle_info[NUM_ROAD_ENGINES];
|
extern const RoadVehicleInfo orig_road_vehicle_info[NUM_ROAD_ENGINES];
|
||||||
|
|
||||||
static inline RailVehicleInfo *RailVehInfo(uint e)
|
EngineInfo _engine_info[TOTAL_NUM_ENGINES];
|
||||||
|
RailVehicleInfo _rail_vehicle_info[NUM_TRAIN_ENGINES];
|
||||||
|
ShipVehicleInfo _ship_vehicle_info[NUM_SHIP_ENGINES];
|
||||||
|
AircraftVehicleInfo _aircraft_vehicle_info[NUM_AIRCRAFT_ENGINES];
|
||||||
|
RoadVehicleInfo _road_vehicle_info[NUM_ROAD_ENGINES];
|
||||||
|
|
||||||
|
static inline const RailVehicleInfo *RailVehInfo(uint e)
|
||||||
{
|
{
|
||||||
assert(e < lengthof(_rail_vehicle_info));
|
assert(e < lengthof(_rail_vehicle_info));
|
||||||
return &_rail_vehicle_info[e];
|
return &_rail_vehicle_info[e];
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline ShipVehicleInfo *ShipVehInfo(uint e)
|
static inline const ShipVehicleInfo *ShipVehInfo(uint e)
|
||||||
{
|
{
|
||||||
assert(e - SHIP_ENGINES_INDEX < lengthof(_ship_vehicle_info));
|
assert(e - SHIP_ENGINES_INDEX < lengthof(_ship_vehicle_info));
|
||||||
return &_ship_vehicle_info[e - SHIP_ENGINES_INDEX];
|
return &_ship_vehicle_info[e - SHIP_ENGINES_INDEX];
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline AircraftVehicleInfo *AircraftVehInfo(uint e)
|
static inline const AircraftVehicleInfo *AircraftVehInfo(uint e)
|
||||||
{
|
{
|
||||||
assert(e - AIRCRAFT_ENGINES_INDEX < lengthof(_aircraft_vehicle_info));
|
assert(e - AIRCRAFT_ENGINES_INDEX < lengthof(_aircraft_vehicle_info));
|
||||||
return &_aircraft_vehicle_info[e - AIRCRAFT_ENGINES_INDEX];
|
return &_aircraft_vehicle_info[e - AIRCRAFT_ENGINES_INDEX];
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline RoadVehicleInfo *RoadVehInfo(uint e)
|
static inline const RoadVehicleInfo *RoadVehInfo(uint e)
|
||||||
{
|
{
|
||||||
assert(e - ROAD_ENGINES_INDEX < lengthof(_road_vehicle_info));
|
assert(e - ROAD_ENGINES_INDEX < lengthof(_road_vehicle_info));
|
||||||
return &_road_vehicle_info[e - ROAD_ENGINES_INDEX];
|
return &_road_vehicle_info[e - ROAD_ENGINES_INDEX];
|
||||||
|
16
newgrf.c
16
newgrf.c
@ -2191,6 +2191,20 @@ static void InitializeGRFSpecial(void)
|
|||||||
| (_patches.wagon_speed_limits ? (1 << 0x1D) : 0); /* wagonspeedlimits */
|
| (_patches.wagon_speed_limits ? (1 << 0x1D) : 0); /* wagonspeedlimits */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset all NewGRF loaded data
|
||||||
|
* TODO
|
||||||
|
*/
|
||||||
|
static void ResetNewGRFData(void)
|
||||||
|
{
|
||||||
|
// Copy/reset original engine info data
|
||||||
|
memcpy(&_engine_info, &orig_engine_info, sizeof(orig_engine_info));
|
||||||
|
memcpy(&_rail_vehicle_info, &orig_rail_vehicle_info, sizeof(orig_rail_vehicle_info));
|
||||||
|
memcpy(&_ship_vehicle_info, &orig_ship_vehicle_info, sizeof(orig_ship_vehicle_info));
|
||||||
|
memcpy(&_aircraft_vehicle_info, &orig_aircraft_vehicle_info, sizeof(orig_aircraft_vehicle_info));
|
||||||
|
memcpy(&_road_vehicle_info, &orig_road_vehicle_info, sizeof(orig_road_vehicle_info));
|
||||||
|
}
|
||||||
|
|
||||||
static void InitNewGRFFile(const char* filename, int sprite_offset)
|
static void InitNewGRFFile(const char* filename, int sprite_offset)
|
||||||
{
|
{
|
||||||
GRFFile *newfile;
|
GRFFile *newfile;
|
||||||
@ -2374,6 +2388,8 @@ void LoadNewGRF(uint load_index, uint file_index)
|
|||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ResetNewGRFData();
|
||||||
|
|
||||||
/* Load newgrf sprites
|
/* Load newgrf sprites
|
||||||
* in each loading stage, (try to) open each file specified in the config
|
* in each loading stage, (try to) open each file specified in the config
|
||||||
* and load information from it. */
|
* and load information from it. */
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
#define MW(a,b,c,d,e,f) {a,b|0x80,c,d,((e)<<4)|(f)}
|
#define MW(a,b,c,d,e,f) {a,b|0x80,c,d,((e)<<4)|(f)}
|
||||||
|
|
||||||
EngineInfo _engine_info[TOTAL_NUM_ENGINES] = {
|
const EngineInfo orig_engine_info[TOTAL_NUM_ENGINES] = {
|
||||||
MK( 1827, 20, 15, 30, 0, 1), /* 0 Kirby Paul Tank (Steam) */
|
MK( 1827, 20, 15, 30, 0, 1), /* 0 Kirby Paul Tank (Steam) */
|
||||||
MK( 12784, 20, 22, 30, 0, 6), /* 1 MJS 250 (Diesel) */
|
MK( 12784, 20, 22, 30, 0, 6), /* 1 MJS 250 (Diesel) */
|
||||||
MK( 9497, 20, 20, 50, 0, 8), /* 2 Ploddyphut Choo-Choo */
|
MK( 9497, 20, 20, 50, 0, 8), /* 2 Ploddyphut Choo-Choo */
|
||||||
@ -284,7 +284,7 @@ EngineInfo _engine_info[TOTAL_NUM_ENGINES] = {
|
|||||||
MK( 13575, 20, 20, 99, 0, 8), /* 255 */
|
MK( 13575, 20, 20, 99, 0, 8), /* 255 */
|
||||||
};
|
};
|
||||||
|
|
||||||
RailVehicleInfo _rail_vehicle_info[NUM_TRAIN_ENGINES] = {
|
const RailVehicleInfo orig_rail_vehicle_info[NUM_TRAIN_ENGINES] = {
|
||||||
// image_index max_speed (kph) running_cost_base callbackmask shortened factor
|
// image_index max_speed (kph) running_cost_base callbackmask shortened factor
|
||||||
// | flags | power (hp) | running_cost_class | powered wagons power
|
// | flags | power (hp) | running_cost_class | powered wagons power
|
||||||
// | | base_cost | weight | capacity | | powered wagons weight
|
// | | base_cost | weight | capacity | | powered wagons weight
|
||||||
@ -408,7 +408,7 @@ RailVehicleInfo _rail_vehicle_info[NUM_TRAIN_ENGINES] = {
|
|||||||
{ 59, 2, 191, 0, 0, 18, 0, 0, 37, CT_PLASTIC , 0, 0, 0, 0, 0 }, /* 115 */
|
{ 59, 2, 191, 0, 0, 18, 0, 0, 37, CT_PLASTIC , 0, 0, 0, 0, 0 }, /* 115 */
|
||||||
};
|
};
|
||||||
|
|
||||||
ShipVehicleInfo _ship_vehicle_info[NUM_SHIP_ENGINES] = {
|
const ShipVehicleInfo orig_ship_vehicle_info[NUM_SHIP_ENGINES] = {
|
||||||
// image_index cargo_type cargo_amount refittable
|
// image_index cargo_type cargo_amount refittable
|
||||||
// | base_cost | | running_cost |
|
// | base_cost | | running_cost |
|
||||||
// | | max_speed | | sfx |
|
// | | max_speed | | sfx |
|
||||||
@ -428,7 +428,7 @@ ShipVehicleInfo _ship_vehicle_info[NUM_SHIP_ENGINES] = {
|
|||||||
|
|
||||||
/* subtype: &1: regular aircraft (else chopper); &2: crashes easily on small airports */
|
/* subtype: &1: regular aircraft (else chopper); &2: crashes easily on small airports */
|
||||||
/* sfx from somewhere around SND_45_PLANE_CRASHING are toyland plane-sounds */
|
/* sfx from somewhere around SND_45_PLANE_CRASHING are toyland plane-sounds */
|
||||||
AircraftVehicleInfo _aircraft_vehicle_info[NUM_AIRCRAFT_ENGINES] = {
|
const AircraftVehicleInfo orig_aircraft_vehicle_info[NUM_AIRCRAFT_ENGINES] = {
|
||||||
// image_index sfx acceleration
|
// image_index sfx acceleration
|
||||||
// | base_cost | | max_speed
|
// | base_cost | | max_speed
|
||||||
// | | running_cost | | mail_capacity
|
// | | running_cost | | mail_capacity
|
||||||
@ -479,7 +479,7 @@ AircraftVehicleInfo _aircraft_vehicle_info[NUM_AIRCRAFT_ENGINES] = {
|
|||||||
|
|
||||||
/* I hope I got the cargo types right, figuring out which is which for which
|
/* I hope I got the cargo types right, figuring out which is which for which
|
||||||
* climate is a bitch */
|
* climate is a bitch */
|
||||||
RoadVehicleInfo _road_vehicle_info[NUM_ROAD_ENGINES] = {
|
const RoadVehicleInfo orig_road_vehicle_info[NUM_ROAD_ENGINES] = {
|
||||||
// image_index sfx max_speed
|
// image_index sfx max_speed
|
||||||
// | base_cost | | capacity
|
// | base_cost | | capacity
|
||||||
// | | running_cost | | cargo_type
|
// | | running_cost | | cargo_type
|
||||||
|
@ -1516,7 +1516,7 @@ int32 CmdRefitRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
|||||||
if (!CanRefitTo(v, new_cid)) continue;
|
if (!CanRefitTo(v, new_cid)) continue;
|
||||||
|
|
||||||
if (v->cargo_cap != 0) {
|
if (v->cargo_cap != 0) {
|
||||||
RailVehicleInfo *rvi = RailVehInfo(v->engine_type);
|
const RailVehicleInfo *rvi = RailVehInfo(v->engine_type);
|
||||||
uint16 amount = CALLBACK_FAILED;
|
uint16 amount = CALLBACK_FAILED;
|
||||||
|
|
||||||
if (HASBIT(rvi->callbackmask, CBM_REFIT_CAP)) {
|
if (HASBIT(rvi->callbackmask, CBM_REFIT_CAP)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user