summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2011-11-04 11:09:06 +0000
committerrubidium <rubidium@openttd.org>2011-11-04 11:09:06 +0000
commitf01b3e2721a5085b7cbae253e04b46a3338d3f43 (patch)
treee1057e5205dfca90fc002f5b0f4d92e3400e1573
parenta72544d5e18a632510c8072b393905473f47bada (diff)
downloadopenttd-f01b3e2721a5085b7cbae253e04b46a3338d3f43.tar.xz
(svn r23104) -Codechange: prepare the vehicle/sign z for some further changes to reduce casting
-rw-r--r--src/aircraft_cmd.cpp2
-rw-r--r--src/disaster_cmd.cpp2
-rw-r--r--src/landscape.cpp2
-rw-r--r--src/landscape.h2
-rw-r--r--src/saveload/oldloader_sl.cpp2
-rw-r--r--src/saveload/signs_sl.cpp17
-rw-r--r--src/saveload/vehicle_sl.cpp9
-rw-r--r--src/signs_base.h2
-rw-r--r--src/vehicle_base.h2
9 files changed, 22 insertions, 18 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index 50793cb1a..ed18682da 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -993,7 +993,7 @@ static bool HandleCrashedAircraft(Aircraft *v)
/* make aircraft crash down to the ground */
if (v->crashed_counter < 500 && st == NULL && ((v->crashed_counter % 3) == 0) ) {
- uint z = GetSlopePixelZ(v->x_pos, v->y_pos);
+ int z = GetSlopePixelZ(v->x_pos, v->y_pos);
v->z_pos -= 1;
if (v->z_pos == z) {
v->crashed_counter = 500;
diff --git a/src/disaster_cmd.cpp b/src/disaster_cmd.cpp
index df6764bc1..821075ce3 100644
--- a/src/disaster_cmd.cpp
+++ b/src/disaster_cmd.cpp
@@ -168,7 +168,7 @@ static void SetDisasterVehiclePos(DisasterVehicle *v, int x, int y, byte z)
int safe_y = Clamp(y - 1, 0, MapMaxY() * TILE_SIZE);
u->x_pos = x;
- u->y_pos = y - 1 - (max(z - GetSlopePixelZ(safe_x, safe_y), 0U) >> 3);
+ u->y_pos = y - 1 - (max(z - GetSlopePixelZ(safe_x, safe_y), 0) >> 3);
safe_y = Clamp(u->y_pos, 0, MapMaxY() * TILE_SIZE);
u->z_pos = GetSlopePixelZ(safe_x, safe_y);
u->direction = v->direction;
diff --git a/src/landscape.cpp b/src/landscape.cpp
index d0562e3aa..1c06bb7c7 100644
--- a/src/landscape.cpp
+++ b/src/landscape.cpp
@@ -274,7 +274,7 @@ uint GetPartialPixelZ(int x, int y, Slope corners)
return z;
}
-uint GetSlopePixelZ(int x, int y)
+int GetSlopePixelZ(int x, int y)
{
TileIndex tile = TileVirtXY(x, y);
diff --git a/src/landscape.h b/src/landscape.h
index a62bde13f..fc0979b82 100644
--- a/src/landscape.h
+++ b/src/landscape.h
@@ -39,7 +39,7 @@ int GetSlopeZInCorner(Slope tileh, Corner corner);
Slope GetFoundationSlope(TileIndex tile, uint *z = NULL);
uint GetPartialPixelZ(int x, int y, Slope corners);
-uint GetSlopePixelZ(int x, int y);
+int GetSlopePixelZ(int x, int y);
void GetSlopePixelZOnEdge(Slope tileh, DiagDirection edge, int *z1, int *z2);
/**
diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp
index c38e0d78d..73ab7a016 100644
--- a/src/saveload/oldloader_sl.cpp
+++ b/src/saveload/oldloader_sl.cpp
@@ -1152,7 +1152,7 @@ static const OldChunks vehicle_chunk[] = {
OCL_SVAR( OC_FILE_U16 | OC_VAR_I32, Vehicle, x_pos ),
OCL_SVAR( OC_FILE_U16 | OC_VAR_I32, Vehicle, y_pos ),
- OCL_SVAR( OC_UINT8, Vehicle, z_pos ),
+ OCL_SVAR( OC_FILE_U8 | OC_VAR_I32, Vehicle, z_pos ),
OCL_SVAR( OC_UINT8, Vehicle, direction ),
OCL_NULL( 2 ), ///< x_offs and y_offs, calculated automatically
OCL_NULL( 2 ), ///< x_extent and y_extent, calculated automatically
diff --git a/src/saveload/signs_sl.cpp b/src/saveload/signs_sl.cpp
index 4d98fad81..b7822ce89 100644
--- a/src/saveload/signs_sl.cpp
+++ b/src/saveload/signs_sl.cpp
@@ -16,14 +16,15 @@
/** Description of a sign within the savegame. */
static const SaveLoad _sign_desc[] = {
- SLE_CONDVAR(Sign, name, SLE_NAME, 0, 83),
- SLE_CONDSTR(Sign, name, SLE_STR, 0, 84, SL_MAX_VERSION),
- SLE_CONDVAR(Sign, x, SLE_FILE_I16 | SLE_VAR_I32, 0, 4),
- SLE_CONDVAR(Sign, y, SLE_FILE_I16 | SLE_VAR_I32, 0, 4),
- SLE_CONDVAR(Sign, x, SLE_INT32, 5, SL_MAX_VERSION),
- SLE_CONDVAR(Sign, y, SLE_INT32, 5, SL_MAX_VERSION),
- SLE_CONDVAR(Sign, owner, SLE_UINT8, 6, SL_MAX_VERSION),
- SLE_VAR(Sign, z, SLE_UINT8),
+ SLE_CONDVAR(Sign, name, SLE_NAME, 0, 83),
+ SLE_CONDSTR(Sign, name, SLE_STR, 0, 84, SL_MAX_VERSION),
+ SLE_CONDVAR(Sign, x, SLE_FILE_I16 | SLE_VAR_I32, 0, 4),
+ SLE_CONDVAR(Sign, y, SLE_FILE_I16 | SLE_VAR_I32, 0, 4),
+ SLE_CONDVAR(Sign, x, SLE_INT32, 5, SL_MAX_VERSION),
+ SLE_CONDVAR(Sign, y, SLE_INT32, 5, SL_MAX_VERSION),
+ SLE_CONDVAR(Sign, owner, SLE_UINT8, 6, SL_MAX_VERSION),
+ SLE_CONDVAR(Sign, z, SLE_FILE_U8 | SLE_VAR_I32, 0, 164),
+ SLE_CONDVAR(Sign, z, SLE_INT32, 164, SL_MAX_VERSION),
SLE_END()
};
diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp
index 05e0e4ca7..9b23d3546 100644
--- a/src/saveload/vehicle_sl.cpp
+++ b/src/saveload/vehicle_sl.cpp
@@ -481,7 +481,8 @@ const SaveLoad *GetVehicleDescription(VehicleType vt)
SLE_CONDVAR(Vehicle, x_pos, SLE_UINT32, 6, SL_MAX_VERSION),
SLE_CONDVAR(Vehicle, y_pos, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
SLE_CONDVAR(Vehicle, y_pos, SLE_UINT32, 6, SL_MAX_VERSION),
- SLE_VAR(Vehicle, z_pos, SLE_UINT8),
+ SLE_CONDVAR(Vehicle, z_pos, SLE_FILE_U8 | SLE_VAR_I32, 0, 164),
+ SLE_CONDVAR(Vehicle, z_pos, SLE_INT32, 164, SL_MAX_VERSION),
SLE_VAR(Vehicle, direction, SLE_UINT8),
SLE_CONDNULL(2, 0, 57),
@@ -676,7 +677,8 @@ const SaveLoad *GetVehicleDescription(VehicleType vt)
SLE_CONDVAR(Vehicle, x_pos, SLE_INT32, 6, SL_MAX_VERSION),
SLE_CONDVAR(Vehicle, y_pos, SLE_FILE_I16 | SLE_VAR_I32, 0, 5),
SLE_CONDVAR(Vehicle, y_pos, SLE_INT32, 6, SL_MAX_VERSION),
- SLE_VAR(Vehicle, z_pos, SLE_UINT8),
+ SLE_CONDVAR(Vehicle, z_pos, SLE_FILE_U8 | SLE_VAR_I32, 0, 164),
+ SLE_CONDVAR(Vehicle, z_pos, SLE_INT32, 164, SL_MAX_VERSION),
SLE_VAR(Vehicle, cur_image, SLE_FILE_U16 | SLE_VAR_U32),
SLE_CONDNULL(5, 0, 57),
@@ -708,7 +710,8 @@ const SaveLoad *GetVehicleDescription(VehicleType vt)
SLE_CONDVAR(Vehicle, x_pos, SLE_INT32, 6, SL_MAX_VERSION),
SLE_CONDVAR(Vehicle, y_pos, SLE_FILE_I16 | SLE_VAR_I32, 0, 5),
SLE_CONDVAR(Vehicle, y_pos, SLE_INT32, 6, SL_MAX_VERSION),
- SLE_VAR(Vehicle, z_pos, SLE_UINT8),
+ SLE_CONDVAR(Vehicle, z_pos, SLE_FILE_U8 | SLE_VAR_I32, 0, 164),
+ SLE_CONDVAR(Vehicle, z_pos, SLE_INT32, 164, SL_MAX_VERSION),
SLE_VAR(Vehicle, direction, SLE_UINT8),
SLE_CONDNULL(5, 0, 57),
diff --git a/src/signs_base.h b/src/signs_base.h
index 2c4ec83f1..3e7b4c465 100644
--- a/src/signs_base.h
+++ b/src/signs_base.h
@@ -25,7 +25,7 @@ struct Sign : SignPool::PoolItem<&_sign_pool> {
ViewportSign sign;
int32 x;
int32 y;
- byte z;
+ int32 z;
OwnerByte owner; // placed by this company. Anyone can delete them though. OWNER_NONE for gray signs from old games.
Sign(Owner owner = INVALID_OWNER);
diff --git a/src/vehicle_base.h b/src/vehicle_base.h
index 9f94f63f4..e7c8fd33e 100644
--- a/src/vehicle_base.h
+++ b/src/vehicle_base.h
@@ -183,7 +183,7 @@ public:
int32 x_pos; ///< x coordinate.
int32 y_pos; ///< y coordinate.
- byte z_pos; ///< z coordinate.
+ int32 z_pos; ///< z coordinate.
DirectionByte direction; ///< facing
OwnerByte owner; ///< Which company owns the vehicle?