comparison src/station_cmd.cpp @ 6070:444de8263ea4 draft

(svn r8800) -Fix Simplify MoveGoodsToSation() under the assumption that 0 is less or equal than 0
author tron <tron@openttd.org>
date Sun, 18 Feb 2007 11:45:56 +0000
parents 9a52b6496f79
children 0540ac4a12e6
comparison
equal deleted inserted replaced
6069:9a52b6496f79 6070:444de8263ea4
2380 2380
2381 2381
2382 uint MoveGoodsToStation(TileIndex tile, int w, int h, int type, uint amount) 2382 uint MoveGoodsToStation(TileIndex tile, int w, int h, int type, uint amount)
2383 { 2383 {
2384 Station* around[8]; 2384 Station* around[8];
2385 int rad = 0;
2386 2385
2387 for (uint i = 0; i < lengthof(around); i++) around[i] = NULL; 2386 for (uint i = 0; i < lengthof(around); i++) around[i] = NULL;
2388 2387
2389 int w_prod; //width and height of the "producer" of the cargo 2388 int w_prod; //width and height of the "producer" of the cargo
2390 int h_prod; 2389 int h_prod;
2415 (st->town->exclusive_counter == 0 || st->town->exclusivity == st->owner) && // check exclusive transport rights 2414 (st->town->exclusive_counter == 0 || st->town->exclusivity == st->owner) && // check exclusive transport rights
2416 st->goods[type].rating != 0 && 2415 st->goods[type].rating != 0 &&
2417 (!_patches.selectgoods || st->goods[type].last_speed > 0) && // if last_speed is 0, no vehicle has been there. 2416 (!_patches.selectgoods || st->goods[type].last_speed > 0) && // if last_speed is 0, no vehicle has been there.
2418 ((st->facilities & ~FACIL_BUS_STOP) != 0 || type == CT_PASSENGERS) && // if we have other fac. than a bus stop, or the cargo is passengers 2417 ((st->facilities & ~FACIL_BUS_STOP) != 0 || type == CT_PASSENGERS) && // if we have other fac. than a bus stop, or the cargo is passengers
2419 ((st->facilities & ~FACIL_TRUCK_STOP) != 0 || type != CT_PASSENGERS)) { // if we have other fac. than a cargo bay or the cargo is not passengers 2418 ((st->facilities & ~FACIL_TRUCK_STOP) != 0 || type != CT_PASSENGERS)) { // if we have other fac. than a cargo bay or the cargo is not passengers
2420 int x_dist;
2421 int y_dist;
2422
2423 if (_patches.modified_catchment) { 2419 if (_patches.modified_catchment) {
2424 // min and max coordinates of the producer relative 2420 // min and max coordinates of the producer relative
2425 const int x_min_prod = 9; 2421 const int x_min_prod = 9;
2426 const int x_max_prod = 8 + w_prod; 2422 const int x_max_prod = 8 + w_prod;
2427 const int y_min_prod = 9; 2423 const int y_min_prod = 9;
2428 const int y_max_prod = 8 + h_prod; 2424 const int y_max_prod = 8 + h_prod;
2429 2425
2430 rad = FindCatchmentRadius(st); 2426 int rad = FindCatchmentRadius(st);
2431 2427
2432 x_dist = min(w_cur - x_min_prod, x_max_prod - w_cur); 2428 int x_dist = min(w_cur - x_min_prod, x_max_prod - w_cur);
2433 if (w_cur < x_min_prod) { 2429 if (w_cur < x_min_prod) {
2434 x_dist = x_min_prod - w_cur; 2430 x_dist = x_min_prod - w_cur;
2435 } else if (w_cur > x_max_prod) { 2431 } else if (w_cur > x_max_prod) {
2436 x_dist = w_cur - x_max_prod; 2432 x_dist = w_cur - x_max_prod;
2437 } 2433 }
2438 2434
2439 y_dist = min(h_cur - y_min_prod, y_max_prod - h_cur); 2435 int y_dist = min(h_cur - y_min_prod, y_max_prod - h_cur);
2440 if (h_cur < y_min_prod) { 2436 if (h_cur < y_min_prod) {
2441 y_dist = y_min_prod - h_cur; 2437 y_dist = y_min_prod - h_cur;
2442 } else if (h_cur > y_max_prod) { 2438 } else if (h_cur > y_max_prod) {
2443 y_dist = h_cur - y_max_prod; 2439 y_dist = h_cur - y_max_prod;
2444 } 2440 }
2445 } else { 2441
2446 x_dist = 0; 2442 if (x_dist > rad || y_dist > rad) break;
2447 y_dist = 0;
2448 } 2443 }
2449 2444
2450 if (x_dist <= rad && y_dist <= rad) around[i] = st; 2445 around[i] = st;
2451 } 2446 }
2452 break; 2447 break;
2453 } else if (around[i] == st) { 2448 } else if (around[i] == st) {
2454 break; 2449 break;
2455 } 2450 }