(svn r23104) -Codechange: prepare the vehicle/sign z for some further changes to reduce casting

This commit is contained in:
rubidium 2011-11-04 11:09:06 +00:00
parent a72544d5e1
commit f01b3e2721
9 changed files with 22 additions and 18 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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);
/**

View File

@ -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

View File

@ -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()
};

View File

@ -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),

View File

@ -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);

View File

@ -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?