mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-16 00:12:51 +00:00
(svn r1393) fix [ 1096026 ]. Autorenew trains should now hopefully work like it did before autoreplace was added
DEREF_ENGINE is now used in autoreplace
This commit is contained in:
parent
cc465f0f35
commit
1e99155d61
@ -1421,7 +1421,7 @@ int32 CmdReplaceVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
if (new_engine_type >= TOTAL_NUM_ENGINES ) return CMD_ERROR;
|
||||
|
||||
// check that the new vehicle type is the same as the original one
|
||||
if (v->type != _engines[new_engine_type].type) return CMD_ERROR;
|
||||
if (v->type != DEREF_ENGINE(new_engine_type)->type) return CMD_ERROR;
|
||||
|
||||
// check that it's the vehicle's owner that requested the replace
|
||||
if (!CheckOwnership(v->owner)) return CMD_ERROR;
|
||||
@ -1465,7 +1465,7 @@ int32 CmdReplaceVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
Engine *e;
|
||||
e = &_engines[new_engine_type];
|
||||
e = DEREF_ENGINE(new_engine_type);
|
||||
|
||||
// TODO make it check if refit is possible before actually doing it
|
||||
|
||||
@ -1606,14 +1606,14 @@ void MaybeReplaceVehicle(Vehicle *v)
|
||||
the last 8 bit is the engine. The 8 bits in front of the engine is free so it have room for 16 bit engine entries */
|
||||
new_engine_and_autoreplace_money = ((_patches.autorenew_money / 100000) << 16) + _autoreplace_array[v->engine_type];
|
||||
|
||||
assert(v->type == _engines[ _autoreplace_array[v->engine_type] ].type);
|
||||
assert(v->type == DEREF_ENGINE(_autoreplace_array[v->engine_type])->type);
|
||||
|
||||
if ( v->type != VEH_Train ) {
|
||||
DoCommandP(v->tile, v->index, new_engine_and_autoreplace_money, NULL, CMD_REPLACE_VEHICLE | CMD_SHOW_NO_ERROR);
|
||||
} else {
|
||||
// checks if any of the engines in the train are either old or listed for replacement
|
||||
do {
|
||||
if ( v->engine_type != _autoreplace_array[v->engine_type] || (v->age - v->max_age) > (_patches.autorenew_months * 30)) {
|
||||
if ( v->engine_type != _autoreplace_array[v->engine_type] || (_patches.autorenew && (v->age - v->max_age) > (_patches.autorenew_months * 30))) {
|
||||
new_engine_and_autoreplace_money = (new_engine_and_autoreplace_money & 0xFFFF0000) + _autoreplace_array[v->engine_type]; // sets the new engine replacement type
|
||||
DoCommandP(v->tile, v->index, new_engine_and_autoreplace_money, NULL, CMD_REPLACE_VEHICLE | CMD_SHOW_NO_ERROR);
|
||||
}
|
||||
|
@ -386,7 +386,7 @@ static void SetupScrollStuffForReplaceWindow(Window *w)
|
||||
}
|
||||
case VEH_Road: {
|
||||
int num = NUM_ROAD_ENGINES;
|
||||
Engine *e = &_engines[ROAD_ENGINES_INDEX];
|
||||
Engine *e = DEREF_ENGINE(ROAD_ENGINES_INDEX);
|
||||
byte cargo;
|
||||
EngineInfo *info;
|
||||
engine_id = ROAD_ENGINES_INDEX;
|
||||
@ -403,7 +403,7 @@ static void SetupScrollStuffForReplaceWindow(Window *w)
|
||||
if ( selected_id[0] != -1 ) { // only draw right array if we have anything in the left one
|
||||
num = NUM_ROAD_ENGINES;
|
||||
engine_id = ROAD_ENGINES_INDEX;
|
||||
e = &_engines[ROAD_ENGINES_INDEX];
|
||||
e = DEREF_ENGINE(ROAD_ENGINES_INDEX);
|
||||
cargo = RoadVehInfo(selected_id[0])->cargo_type;
|
||||
|
||||
do {
|
||||
@ -419,7 +419,7 @@ static void SetupScrollStuffForReplaceWindow(Window *w)
|
||||
|
||||
case VEH_Ship: {
|
||||
int num = NUM_SHIP_ENGINES;
|
||||
Engine *e = &_engines[SHIP_ENGINES_INDEX];
|
||||
Engine *e = DEREF_ENGINE(SHIP_ENGINES_INDEX);
|
||||
byte cargo, refittable;
|
||||
EngineInfo *info;
|
||||
engine_id = SHIP_ENGINES_INDEX;
|
||||
@ -435,7 +435,7 @@ static void SetupScrollStuffForReplaceWindow(Window *w)
|
||||
|
||||
if ( selected_id[0] != -1 ) {
|
||||
num = NUM_SHIP_ENGINES;
|
||||
e = &_engines[SHIP_ENGINES_INDEX];
|
||||
e = DEREF_ENGINE(SHIP_ENGINES_INDEX);
|
||||
engine_id = SHIP_ENGINES_INDEX;
|
||||
cargo = ShipVehInfo(selected_id[0])->cargo_type;
|
||||
refittable = ShipVehInfo(selected_id[0])->refittable;
|
||||
@ -456,7 +456,7 @@ static void SetupScrollStuffForReplaceWindow(Window *w)
|
||||
case VEH_Aircraft:{
|
||||
int num = NUM_AIRCRAFT_ENGINES;
|
||||
byte subtype;
|
||||
Engine *e = &_engines[AIRCRAFT_ENGINES_INDEX];
|
||||
Engine *e = DEREF_ENGINE(AIRCRAFT_ENGINES_INDEX);
|
||||
EngineInfo *info;
|
||||
engine_id = AIRCRAFT_ENGINES_INDEX;
|
||||
|
||||
@ -471,7 +471,7 @@ static void SetupScrollStuffForReplaceWindow(Window *w)
|
||||
|
||||
if ( selected_id[0] != -1 ) {
|
||||
num = NUM_AIRCRAFT_ENGINES;
|
||||
e = &_engines[AIRCRAFT_ENGINES_INDEX];
|
||||
e = DEREF_ENGINE(AIRCRAFT_ENGINES_INDEX);
|
||||
subtype = AircraftVehInfo(selected_id[0])->subtype;
|
||||
engine_id = AIRCRAFT_ENGINES_INDEX;
|
||||
do {
|
||||
@ -523,7 +523,7 @@ static void DrawEngineArrayInReplaceWindow(Window *w, int x, int y, int x2, int
|
||||
|
||||
case VEH_Road: {
|
||||
int num = NUM_ROAD_ENGINES;
|
||||
Engine *e = &_engines[ROAD_ENGINES_INDEX];
|
||||
Engine *e = DEREF_ENGINE(ROAD_ENGINES_INDEX);
|
||||
int engine_id = ROAD_ENGINES_INDEX;
|
||||
byte cargo;
|
||||
EngineInfo *info;
|
||||
@ -557,7 +557,7 @@ static void DrawEngineArrayInReplaceWindow(Window *w, int x, int y, int x2, int
|
||||
|
||||
case VEH_Ship: {
|
||||
int num = NUM_SHIP_ENGINES;
|
||||
Engine *e = &_engines[SHIP_ENGINES_INDEX];
|
||||
Engine *e = DEREF_ENGINE(SHIP_ENGINES_INDEX);
|
||||
int engine_id = SHIP_ENGINES_INDEX;
|
||||
byte cargo, refittable;
|
||||
EngineInfo *info;
|
||||
@ -594,7 +594,7 @@ static void DrawEngineArrayInReplaceWindow(Window *w, int x, int y, int x2, int
|
||||
case VEH_Aircraft: {
|
||||
if ( selected_id[0] != -1 ) {
|
||||
int num = NUM_AIRCRAFT_ENGINES;
|
||||
Engine *e = &_engines[AIRCRAFT_ENGINES_INDEX];
|
||||
Engine *e = DEREF_ENGINE(AIRCRAFT_ENGINES_INDEX);
|
||||
int engine_id = AIRCRAFT_ENGINES_INDEX;
|
||||
byte subtype = AircraftVehInfo(selected_id[0])->subtype;
|
||||
EngineInfo *info;
|
||||
@ -782,9 +782,9 @@ static void ReplaceVehicleWndProc(Window *w, WindowEvent *e)
|
||||
// finds mask for available engines
|
||||
{
|
||||
int engine_avail = 0;
|
||||
if ( !(HASBIT(_engines[NUM_NORMAL_RAIL_ENGINES + NUM_MONORAIL_ENGINES].player_avail, _local_player))) {
|
||||
if ( !(HASBIT(DEREF_ENGINE(NUM_NORMAL_RAIL_ENGINES + NUM_MONORAIL_ENGINES)->player_avail, _local_player))) {
|
||||
engine_avail = 4;
|
||||
if ( !(HASBIT(_engines[NUM_NORMAL_RAIL_ENGINES].player_avail, _local_player)))
|
||||
if ( !(HASBIT(DEREF_ENGINE(NUM_NORMAL_RAIL_ENGINES)->player_avail, _local_player)))
|
||||
engine_avail = 6;
|
||||
}
|
||||
ShowDropDownMenu(w, _rail_types_list, WP(w,replaceveh_d).railtype, 15, engine_avail, 1);
|
||||
|
Loading…
Reference in New Issue
Block a user