summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortron <tron@openttd.org>2007-02-25 10:49:13 +0000
committertron <tron@openttd.org>2007-02-25 10:49:13 +0000
commit1ce43c1a3754499902a2749f9db3c426595ab02f (patch)
treef18ec0cd5e3a04d73bbbf9ddae8c4ee638ee9fc4 /src
parent696b895b776ce8a990260d1a6829a93e675aa6c7 (diff)
downloadopenttd-1ce43c1a3754499902a2749f9db3c426595ab02f.tar.xz
(svn r8897) -Fix
Change the signature of GetNewVehiclePos(): -void GetNewVehiclePos(const Vehicle *v, GetNewVehiclePosResult *gp); +GetNewVehiclePosResult GetNewVehiclePos(const Vehicle *v);
Diffstat (limited to 'src')
-rw-r--r--src/aircraft_cmd.cpp9
-rw-r--r--src/disaster_cmd.cpp27
-rw-r--r--src/roadveh_cmd.cpp4
-rw-r--r--src/ship_cmd.cpp3
-rw-r--r--src/train_cmd.cpp3
-rw-r--r--src/vehicle.cpp12
-rw-r--r--src/vehicle.h2
7 files changed, 23 insertions, 37 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index 31455665e..2c56069e9 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -1046,8 +1046,7 @@ static bool AircraftController(Vehicle *v)
}
/* 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 @@ void UpdateOldAircraft(void)
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 @@ void UpdateAirplanesOnNewStation(const Station *st)
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 {
diff --git a/src/disaster_cmd.cpp b/src/disaster_cmd.cpp
index d9e6b8f17..753b75736 100644
--- a/src/disaster_cmd.cpp
+++ b/src/disaster_cmd.cpp
@@ -200,7 +200,6 @@ static void SetDisasterVehiclePos(Vehicle *v, int x, int y, byte z)
*/
static void DisasterTick_Zeppeliner(Vehicle *v)
{
- GetNewVehiclePosResult gp;
Station *st;
int x, y;
byte z;
@@ -211,7 +210,7 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
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_Zeppeliner(Vehicle *v)
*/
static void DisasterTick_Ufo(Vehicle *v)
{
- GetNewVehiclePosResult gp;
Vehicle *u;
uint dist;
byte z;
@@ -321,7 +319,7 @@ static void DisasterTick_Ufo(Vehicle *v)
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 @@ static void DisasterTick_Ufo(Vehicle *v)
}
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 DestructIndustry(Industry *i)
*/
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_Airplane(Vehicle *v)
*/
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_Helicopter_Rotors(Vehicle *v)
*/
static void DisasterTick_Big_Ufo(Vehicle *v)
{
- GetNewVehiclePosResult gp;
byte z;
Vehicle *u, *w;
Town *t;
@@ -583,7 +576,7 @@ static void DisasterTick_Big_Ufo(Vehicle *v)
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 @@ static void DisasterTick_Big_Ufo(Vehicle *v)
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(Vehicle *v)
*/
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_Big_Ufo_Destroyer(Vehicle *v)
*/
static void DisasterTick_Submarine(Vehicle *v)
{
- GetNewVehiclePosResult gp;
TileIndex tile;
v->tick_counter++;
@@ -731,7 +722,7 @@ static void DisasterTick_Submarine(Vehicle *v)
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;
}
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index 37f43540a..5caaaf8a1 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -1357,9 +1357,7 @@ static void RoadVehController(Vehicle *v)
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) {
diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp
index f2b11ea76..d1af28144 100644
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -662,7 +662,6 @@ static const byte _ship_subcoord[4][6][3] = {
static void ShipController(Vehicle *v)
{
- GetNewVehiclePosResult gp;
uint32 r;
const byte *b;
Direction dir;
@@ -692,7 +691,7 @@ static void ShipController(Vehicle *v)
BeginVehicleMove(v);
- GetNewVehiclePos(v, &gp);
+ GetNewVehiclePosResult gp = GetNewVehiclePos(v);
if (gp.old_tile == gp.new_tile) {
/* Staying in tile */
if (IsShipInDepot(v)) {
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index a952f732a..2bde6e7a0 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -2886,8 +2886,7 @@ static void TrainController(Vehicle *v, bool update_image)
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) {
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 9b05e3b0b..09e889dac 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -2692,7 +2692,7 @@ void EndVehicleMove(Vehicle *v)
}
/* 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 @@ void GetNewVehiclePos(const Vehicle *v, GetNewVehiclePosResult *gp)
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[] = {
diff --git a/src/vehicle.h b/src/vehicle.h
index 8ac880e96..789a03896 100644
--- a/src/vehicle.h
+++ b/src/vehicle.h
@@ -427,7 +427,7 @@ typedef struct GetNewVehiclePosResult {
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 {