summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-03-11 17:26:58 +0000
committerrubidium <rubidium@openttd.org>2009-03-11 17:26:58 +0000
commitfb2ea6c9ed56e0cb9daf9035e760934d5f28a585 (patch)
tree812c49cb0cecc9389ca6d00660746cdf9c4c7f63
parent66e0fcdd01f58c9fbc371299730436841a56d9ea (diff)
downloadopenttd-fb2ea6c9ed56e0cb9daf9035e760934d5f28a585.tar.xz
(svn r15672) -Codechange: (left,right,top,bottom)_coord -> coord.(left,right,top,bottom), i.e. use Rect.
-rw-r--r--src/saveload/vehicle_sl.cpp2
-rw-r--r--src/sound.cpp4
-rw-r--r--src/vehicle.cpp47
-rw-r--r--src/vehicle_base.h5
4 files changed, 26 insertions, 32 deletions
diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp
index f5564e3f0..8d614fbbd 100644
--- a/src/saveload/vehicle_sl.cpp
+++ b/src/saveload/vehicle_sl.cpp
@@ -359,7 +359,7 @@ void AfterLoadVehicles(bool part_of_load)
default: break;
}
- v->left_coord = INVALID_COORD;
+ v->coord.left = INVALID_COORD;
VehiclePositionChanged(v);
}
}
diff --git a/src/sound.cpp b/src/sound.cpp
index 9995ec190..1c476a9bb 100644
--- a/src/sound.cpp
+++ b/src/sound.cpp
@@ -245,8 +245,8 @@ void SndPlayTileFx(SoundFx sound, TileIndex tile)
void SndPlayVehicleFx(SoundFx sound, const Vehicle *v)
{
SndPlayScreenCoordFx(sound,
- v->left_coord, v->right_coord,
- v->top_coord, v->top_coord
+ v->coord.left, v->coord.right,
+ v->coord.top, v->coord.bottom
);
}
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index acd7f27dc..2b44950c8 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -197,20 +197,20 @@ void VehiclePositionChanged(Vehicle *v)
UpdateVehiclePosHash(v, pt.x, pt.y);
- v->left_coord = pt.x;
- v->top_coord = pt.y;
- v->right_coord = pt.x + spr->width + 2;
- v->bottom_coord = pt.y + spr->height + 2;
+ v->coord.left = pt.x;
+ v->coord.top = pt.y;
+ v->coord.right = pt.x + spr->width + 2;
+ v->coord.bottom = pt.y + spr->height + 2;
}
Vehicle::Vehicle()
{
this->type = VEH_INVALID;
- this->left_coord = INVALID_COORD;
+ this->coord.left = INVALID_COORD;
this->group_id = DEFAULT_GROUP;
this->fill_percent_te_id = INVALID_TE_ID;
this->first = this;
- this->colourmap = PAL_NONE;
+ this->colourmap = PAL_NONE;
}
/**
@@ -439,8 +439,8 @@ static void UpdateVehiclePosHash(Vehicle *v, int x, int y)
UpdateNewVehiclePosHash(v, x == INVALID_COORD);
Vehicle **old_hash, **new_hash;
- int old_x = v->left_coord;
- int old_y = v->top_coord;
+ int old_x = v->coord.left;
+ int old_y = v->coord.top;
new_hash = (x == INVALID_COORD) ? NULL : &_vehicle_position_hash[GEN_HASH(x, y)];
old_hash = (old_x == INVALID_COORD) ? NULL : &_vehicle_position_hash[GEN_HASH(old_x, old_y)];
@@ -816,10 +816,10 @@ void ViewportAddVehicles(DrawPixelInfo *dpi)
while (v != NULL) {
if (!(v->vehstatus & VS_HIDDEN) &&
- l <= v->right_coord &&
- t <= v->bottom_coord &&
- r >= v->left_coord &&
- b >= v->top_coord) {
+ l <= v->coord.right &&
+ t <= v->coord.bottom &&
+ r >= v->coord.left &&
+ b >= v->coord.top) {
DoDrawVehicle(v);
}
v = v->next_hash;
@@ -844,12 +844,12 @@ Vehicle *CheckClickOnVehicle(const ViewPort *vp, int x, int y)
FOR_ALL_VEHICLES(v) {
if ((v->vehstatus & (VS_HIDDEN | VS_UNCLICKABLE)) == 0 &&
- x >= v->left_coord && x <= v->right_coord &&
- y >= v->top_coord && y <= v->bottom_coord) {
+ x >= v->coord.left && x <= v->coord.right &&
+ y >= v->coord.top && y <= v->coord.bottom) {
dist = max(
- abs(((v->left_coord + v->right_coord) >> 1) - x),
- abs(((v->top_coord + v->bottom_coord) >> 1) - y)
+ abs(((v->coord.left + v->coord.right) >> 1) - x),
+ abs(((v->coord.top + v->coord.bottom) >> 1) - y)
);
if (dist < best_dist) {
@@ -1641,10 +1641,7 @@ static Rect _old_vehicle_coords; ///< coords of vehicle before it has moved
*/
void BeginVehicleMove(const Vehicle *v)
{
- _old_vehicle_coords.left = v->left_coord;
- _old_vehicle_coords.top = v->top_coord;
- _old_vehicle_coords.right = v->right_coord;
- _old_vehicle_coords.bottom = v->bottom_coord;
+ _old_vehicle_coords = v->coord;
}
/**
@@ -1656,10 +1653,10 @@ void BeginVehicleMove(const Vehicle *v)
void EndVehicleMove(const Vehicle *v)
{
MarkAllViewportsDirty(
- min(_old_vehicle_coords.left, v->left_coord),
- min(_old_vehicle_coords.top, v->top_coord),
- max(_old_vehicle_coords.right, v->right_coord) + 1,
- max(_old_vehicle_coords.bottom, v->bottom_coord) + 1
+ min(_old_vehicle_coords.left, v->coord.left),
+ min(_old_vehicle_coords.top, v->coord.top),
+ max(_old_vehicle_coords.right, v->coord.right) + 1,
+ max(_old_vehicle_coords.bottom, v->coord.bottom) + 1
);
}
@@ -1673,7 +1670,7 @@ void EndVehicleMove(const Vehicle *v)
*/
void MarkSingleVehicleDirty(const Vehicle *v)
{
- MarkAllViewportsDirty(v->left_coord, v->top_coord, v->right_coord + 1, v->bottom_coord + 1);
+ MarkAllViewportsDirty(v->coord.left, v->coord.top, v->coord.right + 1, v->coord.bottom + 1);
}
/**
diff --git a/src/vehicle_base.h b/src/vehicle_base.h
index b4ae0be97..9a224d2de 100644
--- a/src/vehicle_base.h
+++ b/src/vehicle_base.h
@@ -231,10 +231,7 @@ public:
/* Boundaries for the current position in the world and a next hash link.
* NOSAVE: All of those can be updated with VehiclePositionChanged() */
- int32 left_coord;
- int32 top_coord;
- int32 right_coord;
- int32 bottom_coord;
+ Rect coord;
Vehicle *next_hash;
Vehicle *next_new_hash;
Vehicle **old_new_hash;