Mercurial > hg > openttd
changeset 6153:42ef9b98d898 draft
(svn r8897) -Fix
Change the signature of GetNewVehiclePos():
-void GetNewVehiclePos(const Vehicle *v, GetNewVehiclePosResult *gp);
+GetNewVehiclePosResult GetNewVehiclePos(const Vehicle *v);
author | tron <tron@openttd.org> |
---|---|
date | Sun, 25 Feb 2007 10:49:13 +0000 |
parents | 16eaa24b383f |
children | 238db87ae59e |
files | src/aircraft_cmd.cpp src/disaster_cmd.cpp src/roadveh_cmd.cpp src/ship_cmd.cpp src/train_cmd.cpp src/vehicle.cpp src/vehicle.h |
diffstat | 7 files changed, 23 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -1046,8 +1046,7 @@ } /* Move vehicle. */ - GetNewVehiclePosResult gp; - GetNewVehiclePos(v, &gp); + GetNewVehiclePosResult gp = GetNewVehiclePos(v); v->tile = gp.new_tile; /* If vehicle is in the air, use tile coordinate 0. */ @@ -2072,8 +2071,7 @@ v_oldstyle->vehstatus &= ~VS_STOPPED; // make airplane moving v_oldstyle->u.air.state = FLYING; AircraftNextAirportPos_and_Order(v_oldstyle); // move it to the entry point of the airport - GetNewVehiclePosResult gp; - GetNewVehiclePos(v_oldstyle, &gp); // get the position of the plane (to be used for setting) + GetNewVehiclePosResult gp = GetNewVehiclePos(v_oldstyle); v_oldstyle->tile = 0; // aircraft in air is tile=0 /* correct speed of helicopter-rotors */ @@ -2101,8 +2099,7 @@ v->u.air.state = FLYING; /* landing plane needs to be reset to flying height (only if in pause mode upgrade, * in normal mode, plane is reset in AircraftController. It doesn't hurt for FLYING */ - GetNewVehiclePosResult gp; - GetNewVehiclePos(v, &gp); + GetNewVehiclePosResult gp = GetNewVehiclePos(v); /* set new position x,y,z */ SetAircraftPosition(v, gp.x, gp.y, GetAircraftFlyingAltitude(v)); } else {
--- a/src/disaster_cmd.cpp +++ b/src/disaster_cmd.cpp @@ -200,7 +200,6 @@ */ static void DisasterTick_Zeppeliner(Vehicle *v) { - GetNewVehiclePosResult gp; Station *st; int x, y; byte z; @@ -211,7 +210,7 @@ if (v->current_order.dest < 2) { if (HASBIT(v->tick_counter, 0)) return; - GetNewVehiclePos(v, &gp); + GetNewVehiclePosResult gp = GetNewVehiclePos(v); SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); @@ -308,7 +307,6 @@ */ static void DisasterTick_Ufo(Vehicle *v) { - GetNewVehiclePosResult gp; Vehicle *u; uint dist; byte z; @@ -321,7 +319,7 @@ int y = TileY(v->dest_tile) * TILE_SIZE; if (delta(x, v->x_pos) + delta(y, v->y_pos) >= TILE_SIZE) { v->direction = GetDirectionTowards(v, x, y); - GetNewVehiclePos(v, &gp); + GetNewVehiclePosResult gp = GetNewVehiclePos(v); SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); return; } @@ -356,7 +354,7 @@ } v->direction = GetDirectionTowards(v, u->x_pos, u->y_pos); - GetNewVehiclePos(v, &gp); + GetNewVehiclePosResult gp = GetNewVehiclePos(v); z = v->z_pos; if (dist <= TILE_SIZE && z > u->z_pos) z--; @@ -406,13 +404,11 @@ */ static void DisasterTick_Airplane(Vehicle *v) { - GetNewVehiclePosResult gp; - v->tick_counter++; v->u.disaster.image_override = (v->current_order.dest == 1 && HASBIT(v->tick_counter, 2)) ? SPR_F_15_FIRING : 0; - GetNewVehiclePos(v, &gp); + GetNewVehiclePosResult gp = GetNewVehiclePos(v); SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); if (gp.x < (-10 * TILE_SIZE)) { @@ -481,13 +477,11 @@ */ static void DisasterTick_Helicopter(Vehicle *v) { - GetNewVehiclePosResult gp; - v->tick_counter++; v->u.disaster.image_override = (v->current_order.dest == 1 && HASBIT(v->tick_counter, 2)) ? SPR_AH_64A_FIRING : 0; - GetNewVehiclePos(v, &gp); + GetNewVehiclePosResult gp = GetNewVehiclePos(v); SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); if (gp.x > (int)MapSizeX() * TILE_SIZE + 9 * TILE_SIZE - 1) { @@ -568,7 +562,6 @@ */ static void DisasterTick_Big_Ufo(Vehicle *v) { - GetNewVehiclePosResult gp; byte z; Vehicle *u, *w; Town *t; @@ -583,7 +576,7 @@ if (delta(v->x_pos, x) + delta(v->y_pos, y) >= 8) { v->direction = GetDirectionTowards(v, x, y); - GetNewVehiclePos(v, &gp); + GetNewVehiclePosResult gp = GetNewVehiclePos(v); SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); return; } @@ -632,7 +625,7 @@ int y = TileY(v->dest_tile) * TILE_SIZE; if (delta(x, v->x_pos) + delta(y, v->y_pos) >= TILE_SIZE) { v->direction = GetDirectionTowards(v, x, y); - GetNewVehiclePos(v, &gp); + GetNewVehiclePosResult gp = GetNewVehiclePos(v); SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); return; } @@ -665,13 +658,12 @@ */ static void DisasterTick_Big_Ufo_Destroyer(Vehicle *v) { - GetNewVehiclePosResult gp; Vehicle *u; int i; v->tick_counter++; - GetNewVehiclePos(v, &gp); + GetNewVehiclePosResult gp = GetNewVehiclePos(v); SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); if (gp.x > (int)MapSizeX() * TILE_SIZE + 9 * TILE_SIZE - 1) { @@ -711,7 +703,6 @@ */ static void DisasterTick_Submarine(Vehicle *v) { - GetNewVehiclePosResult gp; TileIndex tile; v->tick_counter++; @@ -731,7 +722,7 @@ TrackdirBits r = (TrackdirBits)GetTileTrackStatus(tile, TRANSPORT_WATER); if (TrackdirBitsToTrackBits(r) == TRACK_BIT_ALL && !CHANCE16(1, 90)) { - GetNewVehiclePos(v, &gp); + GetNewVehiclePosResult gp = GetNewVehiclePos(v); SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); return; }
--- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -1357,9 +1357,7 @@ if (v->u.road.state == RVSB_WORMHOLE) { /* Vehicle is entering a depot or is on a bridge or in a tunnel */ - GetNewVehiclePosResult gp; - - GetNewVehiclePos(v, &gp); + GetNewVehiclePosResult gp = GetNewVehiclePos(v); const Vehicle *u = RoadVehFindCloseTo(v, gp.x, gp.y, v->direction); if (u != NULL && u->cur_speed < v->cur_speed) {
--- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -662,7 +662,6 @@ static void ShipController(Vehicle *v) { - GetNewVehiclePosResult gp; uint32 r; const byte *b; Direction dir; @@ -692,7 +691,7 @@ BeginVehicleMove(v); - GetNewVehiclePos(v, &gp); + GetNewVehiclePosResult gp = GetNewVehiclePos(v); if (gp.old_tile == gp.new_tile) { /* Staying in tile */ if (IsShipInDepot(v)) {
--- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -2886,8 +2886,7 @@ for (prev = GetPrevVehicleInChain(v); v != NULL; prev = v, v = v->next) { BeginVehicleMove(v); - GetNewVehiclePosResult gp; - GetNewVehiclePos(v, &gp); + GetNewVehiclePosResult gp = GetNewVehiclePos(v); if (v->u.rail.track != TRACK_BIT_WORMHOLE) { /* Not inside tunnel */ if (gp.old_tile == gp.new_tile) {
--- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -2692,7 +2692,7 @@ } /* returns true if staying in the same tile */ -void GetNewVehiclePos(const Vehicle *v, GetNewVehiclePosResult *gp) +GetNewVehiclePosResult GetNewVehiclePos(const Vehicle *v) { static const int8 _delta_coord[16] = { -1,-1,-1, 0, 1, 1, 1, 0, /* x */ @@ -2702,10 +2702,12 @@ int x = v->x_pos + _delta_coord[v->direction]; int y = v->y_pos + _delta_coord[v->direction + 8]; - gp->x = x; - gp->y = y; - gp->old_tile = v->tile; - gp->new_tile = TileVirtXY(x, y); + GetNewVehiclePosResult gp; + gp.x = x; + gp.y = y; + gp.old_tile = v->tile; + gp.new_tile = TileVirtXY(x, y); + return gp; } static const Direction _new_direction_table[] = {
--- a/src/vehicle.h +++ b/src/vehicle.h @@ -427,7 +427,7 @@ Trackdir GetVehicleTrackdir(const Vehicle* v); /* returns true if staying in the same tile */ -void GetNewVehiclePos(const Vehicle *v, GetNewVehiclePosResult *gp); +GetNewVehiclePosResult GetNewVehiclePos(const Vehicle *v); Direction GetDirectionTowards(const Vehicle* v, int x, int y); #define BEGIN_ENUM_WAGONS(v) do {