forked from mirror/OpenTTD
(svn r955) Replace uint16 for orders with struct Order
This adds no functionality, but is a stepping stone for future improvement (like 16bit order indices) and is easier to read. This changes preserves binary compatibility wrt savegames.
This commit is contained in:
@@ -79,7 +79,9 @@ static void InitializeDisasterVehicle(Vehicle *v, int x, int y, byte z, byte dir
|
||||
v->owner = OWNER_NONE;
|
||||
v->vehstatus = VS_UNCLICKABLE;
|
||||
v->u.disaster.image_override = 0;
|
||||
v->next_order = 0;
|
||||
v->current_order.type = OT_NOTHING;
|
||||
v->current_order.flags = 0;
|
||||
v->current_order.station = 0;
|
||||
|
||||
DisasterVehicleUpdateImage(v);
|
||||
VehiclePositionChanged(v);
|
||||
@@ -141,7 +143,7 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
|
||||
|
||||
++v->tick_counter;
|
||||
|
||||
if (v->next_order < 2) {
|
||||
if (v->current_order.station < 2) {
|
||||
if (v->tick_counter&1)
|
||||
return;
|
||||
|
||||
@@ -149,23 +151,23 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
|
||||
|
||||
SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
|
||||
|
||||
if (v->next_order == 1) {
|
||||
if (v->current_order.station == 1) {
|
||||
if (++v->age == 38) {
|
||||
v->next_order = 2;
|
||||
v->current_order.station = 2;
|
||||
v->age = 0;
|
||||
}
|
||||
|
||||
if ((v->tick_counter&7)==0) {
|
||||
CreateEffectVehicleRel(v, 0, -17, 2, EV_SMOKE_3);
|
||||
}
|
||||
} else if (v->next_order == 0) {
|
||||
} else if (v->current_order.station == 0) {
|
||||
tile = v->tile; /**/
|
||||
|
||||
if (IS_TILETYPE(tile, MP_STATION) &&
|
||||
IS_BYTE_INSIDE(_map5[tile], 8, 0x43) &&
|
||||
IS_HUMAN_PLAYER(_map_owner[tile])) {
|
||||
|
||||
v->next_order = 1;
|
||||
v->current_order.station = 1;
|
||||
v->age = 0;
|
||||
|
||||
SetDParam(0, _map2[tile]);
|
||||
@@ -180,7 +182,7 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
|
||||
return;
|
||||
}
|
||||
|
||||
if (v->next_order > 2) {
|
||||
if (v->current_order.station > 2) {
|
||||
if (++v->age <= 13320)
|
||||
return;
|
||||
|
||||
@@ -223,7 +225,7 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
|
||||
EV_DEMOLISH);
|
||||
}
|
||||
} else if (v->age == 350) {
|
||||
v->next_order = 3;
|
||||
v->current_order.station = 3;
|
||||
v->age = 0;
|
||||
}
|
||||
|
||||
@@ -248,7 +250,7 @@ static void DisasterTick_UFO(Vehicle *v)
|
||||
|
||||
v->u.disaster.image_override = (++v->tick_counter & 8) ? 0xF45 : 0xF44;
|
||||
|
||||
if (v->next_order == 0) {
|
||||
if (v->current_order.station == 0) {
|
||||
// fly around randomly
|
||||
int x = GET_TILE_X(v->dest_tile)*16;
|
||||
int y = GET_TILE_Y(v->dest_tile)*16;
|
||||
@@ -262,7 +264,7 @@ static void DisasterTick_UFO(Vehicle *v)
|
||||
v->dest_tile = TILE_MASK(Random());
|
||||
return;
|
||||
}
|
||||
v->next_order = 1;
|
||||
v->current_order.station = 1;
|
||||
|
||||
FOR_ALL_VEHICLES(u) {
|
||||
if (u->type == VEH_Road && IS_HUMAN_PLAYER(u->owner)) {
|
||||
@@ -336,7 +338,8 @@ static void DisasterTick_2(Vehicle *v)
|
||||
GetNewVehiclePosResult gp;
|
||||
|
||||
v->tick_counter++;
|
||||
v->u.disaster.image_override = (v->next_order == 1 && v->tick_counter&4) ? 0xF4F : 0;
|
||||
v->u.disaster.image_override =
|
||||
(v->current_order.station == 1 && v->tick_counter&4) ? 0xF4F : 0;
|
||||
|
||||
GetNewVehiclePos(v, &gp);
|
||||
SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
|
||||
@@ -346,7 +349,7 @@ static void DisasterTick_2(Vehicle *v)
|
||||
return;
|
||||
}
|
||||
|
||||
if (v->next_order == 2) {
|
||||
if (v->current_order.station == 2) {
|
||||
if (!(v->tick_counter&3)) {
|
||||
Industry *i = DEREF_INDUSTRY(v->dest_tile);
|
||||
int x = GET_TILE_X(i->xy)*16;
|
||||
@@ -360,13 +363,13 @@ static void DisasterTick_2(Vehicle *v)
|
||||
EV_DEMOLISH);
|
||||
|
||||
if (++v->age >= 55)
|
||||
v->next_order = 3;
|
||||
v->current_order.station = 3;
|
||||
}
|
||||
} else if (v->next_order == 1) {
|
||||
} else if (v->current_order.station == 1) {
|
||||
if (++v->age == 112) {
|
||||
Industry *i;
|
||||
|
||||
v->next_order = 2;
|
||||
v->current_order.station = 2;
|
||||
v->age = 0;
|
||||
|
||||
i = DEREF_INDUSTRY(v->dest_tile);
|
||||
@@ -376,7 +379,7 @@ static void DisasterTick_2(Vehicle *v)
|
||||
AddNewsItem(STR_B002_OIL_REFINERY_EXPLOSION, NEWS_FLAGS(NM_THIN,NF_VIEWPORT|NF_TILE,NT_ACCIDENT,0), i->xy, 0);
|
||||
SndPlayTileFx(SND_12_EXPLOSION, i->xy);
|
||||
}
|
||||
} else if (v->next_order == 0) {
|
||||
} else if (v->current_order.station == 0) {
|
||||
int x,y;
|
||||
uint tile;
|
||||
int ind;
|
||||
@@ -394,7 +397,7 @@ static void DisasterTick_2(Vehicle *v)
|
||||
v->dest_tile = ind = _map2[tile];
|
||||
|
||||
if (DEREF_INDUSTRY(ind)->type == IT_OIL_REFINERY) {
|
||||
v->next_order = 1;
|
||||
v->current_order.station = 1;
|
||||
v->age = 0;
|
||||
}
|
||||
}
|
||||
@@ -406,7 +409,8 @@ static void DisasterTick_3(Vehicle *v)
|
||||
GetNewVehiclePosResult gp;
|
||||
|
||||
v->tick_counter++;
|
||||
v->u.disaster.image_override = (v->next_order == 1 && v->tick_counter&4) ? 0xF53 : 0;
|
||||
v->u.disaster.image_override =
|
||||
(v->current_order.station == 1 && v->tick_counter&4) ? 0xF53 : 0;
|
||||
|
||||
GetNewVehiclePos(v, &gp);
|
||||
SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
|
||||
@@ -416,7 +420,7 @@ static void DisasterTick_3(Vehicle *v)
|
||||
return;
|
||||
}
|
||||
|
||||
if (v->next_order == 2) {
|
||||
if (v->current_order.station == 2) {
|
||||
if (!(v->tick_counter&3)) {
|
||||
Industry *i = DEREF_INDUSTRY(v->dest_tile);
|
||||
int x = GET_TILE_X(i->xy)*16;
|
||||
@@ -430,13 +434,13 @@ static void DisasterTick_3(Vehicle *v)
|
||||
EV_DEMOLISH);
|
||||
|
||||
if (++v->age >= 55)
|
||||
v->next_order = 3;
|
||||
v->current_order.station = 3;
|
||||
}
|
||||
} else if (v->next_order == 1) {
|
||||
} else if (v->current_order.station == 1) {
|
||||
if (++v->age == 112) {
|
||||
Industry *i;
|
||||
|
||||
v->next_order = 2;
|
||||
v->current_order.station = 2;
|
||||
v->age = 0;
|
||||
|
||||
i = DEREF_INDUSTRY(v->dest_tile);
|
||||
@@ -446,7 +450,7 @@ static void DisasterTick_3(Vehicle *v)
|
||||
AddNewsItem(STR_B003_FACTORY_DESTROYED_IN_SUSPICIOUS, NEWS_FLAGS(NM_THIN,NF_VIEWPORT|NF_TILE,NT_ACCIDENT,0), i->xy, 0);
|
||||
SndPlayTileFx(SND_12_EXPLOSION, i->xy);
|
||||
}
|
||||
} else if (v->next_order == 0) {
|
||||
} else if (v->current_order.station == 0) {
|
||||
int x,y;
|
||||
uint tile;
|
||||
int ind;
|
||||
@@ -464,7 +468,7 @@ static void DisasterTick_3(Vehicle *v)
|
||||
v->dest_tile = ind = _map2[tile];
|
||||
|
||||
if (DEREF_INDUSTRY(ind)->type == IT_FACTORY) {
|
||||
v->next_order = 1;
|
||||
v->current_order.station = 1;
|
||||
v->age = 0;
|
||||
}
|
||||
}
|
||||
@@ -496,7 +500,7 @@ static void DisasterTick_4(Vehicle *v)
|
||||
|
||||
v->tick_counter++;
|
||||
|
||||
if (v->next_order == 1) {
|
||||
if (v->current_order.station == 1) {
|
||||
int x = GET_TILE_X(v->dest_tile)*16 + 8;
|
||||
int y = GET_TILE_Y(v->dest_tile)*16 + 8;
|
||||
if (abs(v->x_pos - x) + abs(v->y_pos - y) >= 8) {
|
||||
@@ -513,7 +517,7 @@ static void DisasterTick_4(Vehicle *v)
|
||||
return;
|
||||
}
|
||||
|
||||
v->next_order = 2;
|
||||
v->current_order.station = 2;
|
||||
|
||||
FOR_ALL_VEHICLES(u) {
|
||||
if (u->type == VEH_Train || u->type == VEH_Road) {
|
||||
@@ -547,7 +551,7 @@ static void DisasterTick_4(Vehicle *v)
|
||||
u->next = w;
|
||||
InitializeDisasterVehicle(w, -6*16, v->y_pos, 0, 5, 12);
|
||||
w->vehstatus |= VS_DISASTER;
|
||||
} else if (v->next_order < 1) {
|
||||
} else if (v->current_order.station < 1) {
|
||||
|
||||
int x = GET_TILE_X(v->dest_tile)*16;
|
||||
int y = GET_TILE_Y(v->dest_tile)*16;
|
||||
@@ -562,7 +566,7 @@ static void DisasterTick_4(Vehicle *v)
|
||||
v->dest_tile = TILE_MASK(Random());
|
||||
return;
|
||||
}
|
||||
v->next_order = 1;
|
||||
v->current_order.station = 1;
|
||||
|
||||
tile_org = tile = TILE_MASK(Random());
|
||||
do {
|
||||
@@ -594,11 +598,11 @@ static void DisasterTick_4b(Vehicle *v)
|
||||
return;
|
||||
}
|
||||
|
||||
if (v->next_order == 0) {
|
||||
if (v->current_order.station == 0) {
|
||||
u = &_vehicles[v->u.disaster.unk2];
|
||||
if (abs(v->x_pos - u->x_pos) > 16)
|
||||
return;
|
||||
v->next_order = 1;
|
||||
v->current_order.station = 1;
|
||||
|
||||
CreateEffectVehicleRel(u, 0, 7, 8, EV_CRASHED_SMOKE);
|
||||
SndPlayVehicleFx(SND_12_EXPLOSION, u);
|
||||
|
Reference in New Issue
Block a user