summaryrefslogtreecommitdiff
path: root/src/station_cmd.cpp
diff options
context:
space:
mode:
authortron <tron@openttd.org>2007-02-18 11:45:56 +0000
committertron <tron@openttd.org>2007-02-18 11:45:56 +0000
commit8db5c84f6759c2fdaf0d9618dbae741d21cd4b82 (patch)
treeea6c1af05df8fb0d7a7bcbac3675dff9340d96ac /src/station_cmd.cpp
parent6c5b59b6ecf20b45538a543b87832790a9e53677 (diff)
downloadopenttd-8db5c84f6759c2fdaf0d9618dbae741d21cd4b82.tar.xz
(svn r8800) -Fix
Simplify MoveGoodsToSation() under the assumption that 0 is less or equal than 0
Diffstat (limited to 'src/station_cmd.cpp')
-rw-r--r--src/station_cmd.cpp17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 7efd5a821..2ed72b561 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -2382,7 +2382,6 @@ int32 CmdRenameStation(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
uint MoveGoodsToStation(TileIndex tile, int w, int h, int type, uint amount)
{
Station* around[8];
- int rad = 0;
for (uint i = 0; i < lengthof(around); i++) around[i] = NULL;
@@ -2417,9 +2416,6 @@ uint MoveGoodsToStation(TileIndex tile, int w, int h, int type, uint amount)
(!_patches.selectgoods || st->goods[type].last_speed > 0) && // if last_speed is 0, no vehicle has been there.
((st->facilities & ~FACIL_BUS_STOP) != 0 || type == CT_PASSENGERS) && // if we have other fac. than a bus stop, or the cargo is passengers
((st->facilities & ~FACIL_TRUCK_STOP) != 0 || type != CT_PASSENGERS)) { // if we have other fac. than a cargo bay or the cargo is not passengers
- int x_dist;
- int y_dist;
-
if (_patches.modified_catchment) {
// min and max coordinates of the producer relative
const int x_min_prod = 9;
@@ -2427,27 +2423,26 @@ uint MoveGoodsToStation(TileIndex tile, int w, int h, int type, uint amount)
const int y_min_prod = 9;
const int y_max_prod = 8 + h_prod;
- rad = FindCatchmentRadius(st);
+ int rad = FindCatchmentRadius(st);
- x_dist = min(w_cur - x_min_prod, x_max_prod - w_cur);
+ int x_dist = min(w_cur - x_min_prod, x_max_prod - w_cur);
if (w_cur < x_min_prod) {
x_dist = x_min_prod - w_cur;
} else if (w_cur > x_max_prod) {
x_dist = w_cur - x_max_prod;
}
- y_dist = min(h_cur - y_min_prod, y_max_prod - h_cur);
+ int y_dist = min(h_cur - y_min_prod, y_max_prod - h_cur);
if (h_cur < y_min_prod) {
y_dist = y_min_prod - h_cur;
} else if (h_cur > y_max_prod) {
y_dist = h_cur - y_max_prod;
}
- } else {
- x_dist = 0;
- y_dist = 0;
+
+ if (x_dist > rad || y_dist > rad) break;
}
- if (x_dist <= rad && y_dist <= rad) around[i] = st;
+ around[i] = st;
}
break;
} else if (around[i] == st) {