523 } else { |
523 } else { |
524 memset(accepts, 0, sizeof(accepts)); |
524 memset(accepts, 0, sizeof(accepts)); |
525 } |
525 } |
526 |
526 |
527 // Adjust in case our station only accepts fewer kinds of goods |
527 // Adjust in case our station only accepts fewer kinds of goods |
528 for (uint i = 0; i != NUM_CARGO; i++) { |
528 for (CargoID i = 0; i < NUM_CARGO; i++) { |
529 uint amt = min(accepts[i], 15); |
529 uint amt = min(accepts[i], 15); |
530 |
530 |
531 // Make sure the station can accept the goods type. |
531 // Make sure the station can accept the goods type. |
532 bool is_passengers = IsCargoInClass(i, CC_PASSENGERS); |
532 bool is_passengers = IsCargoInClass(i, CC_PASSENGERS); |
533 if ((!is_passengers && !(st->facilities & (byte)~FACIL_BUS_STOP)) || |
533 if ((!is_passengers && !(st->facilities & (byte)~FACIL_BUS_STOP)) || |
2334 Station *st; |
2334 Station *st; |
2335 |
2335 |
2336 FOR_ALL_STATIONS(st) { |
2336 FOR_ALL_STATIONS(st) { |
2337 if (st->owner == owner && |
2337 if (st->owner == owner && |
2338 DistanceManhattan(tile, st->xy) <= radius) { |
2338 DistanceManhattan(tile, st->xy) <= radius) { |
2339 for (uint i = 0; i != NUM_CARGO; i++) { |
2339 for (CargoID i = 0; i < NUM_CARGO; i++) { |
2340 GoodsEntry* ge = &st->goods[i]; |
2340 GoodsEntry* ge = &st->goods[i]; |
2341 |
2341 |
2342 if (ge->enroute_from != INVALID_STATION) { |
2342 if (ge->enroute_from != INVALID_STATION) { |
2343 ge->rating = clamp(ge->rating + amount, 0, 255); |
2343 ge->rating = clamp(ge->rating + amount, 0, 255); |
2344 } |
2344 } |
2345 } |
2345 } |
2346 } |
2346 } |
2347 } |
2347 } |
2348 } |
2348 } |
2349 |
2349 |
2350 static void UpdateStationWaiting(Station *st, int type, uint amount) |
2350 static void UpdateStationWaiting(Station *st, CargoID type, uint amount) |
2351 { |
2351 { |
2352 SB(st->goods[type].waiting_acceptance, 0, 12, |
2352 SB(st->goods[type].waiting_acceptance, 0, 12, |
2353 min(0xFFF, GB(st->goods[type].waiting_acceptance, 0, 12) + amount) |
2353 min(0xFFF, GB(st->goods[type].waiting_acceptance, 0, 12) + amount) |
2354 ); |
2354 ); |
2355 |
2355 |
2551 st->delete_ctr = 0; |
2551 st->delete_ctr = 0; |
2552 st->last_vehicle_type = VEH_INVALID; |
2552 st->last_vehicle_type = VEH_INVALID; |
2553 st->facilities = FACIL_AIRPORT | FACIL_DOCK; |
2553 st->facilities = FACIL_AIRPORT | FACIL_DOCK; |
2554 st->build_date = _date; |
2554 st->build_date = _date; |
2555 |
2555 |
2556 for (uint j = 0; j != NUM_CARGO; j++) { |
2556 for (CargoID j = 0; j < NUM_CARGO; j++) { |
2557 st->goods[j].waiting_acceptance = 0; |
2557 st->goods[j].waiting_acceptance = 0; |
2558 st->goods[j].days_since_pickup = 0; |
2558 st->goods[j].days_since_pickup = 0; |
2559 st->goods[j].enroute_from = INVALID_STATION; |
2559 st->goods[j].enroute_from = INVALID_STATION; |
2560 st->goods[j].enroute_from_xy = INVALID_TILE; |
2560 st->goods[j].enroute_from_xy = INVALID_TILE; |
2561 st->goods[j].rating = INITIAL_STATION_RATING; |
2561 st->goods[j].rating = INITIAL_STATION_RATING; |
2799 |
2799 |
2800 |
2800 |
2801 static void SaveLoad_STNS(Station *st) |
2801 static void SaveLoad_STNS(Station *st) |
2802 { |
2802 { |
2803 SlObject(st, _station_desc); |
2803 SlObject(st, _station_desc); |
2804 for (uint i = 0; i != NUM_CARGO; i++) { |
2804 for (CargoID i = 0; i < NUM_CARGO; i++) { |
2805 SlObject(&st->goods[i], _goods_desc); |
2805 SlObject(&st->goods[i], _goods_desc); |
2806 } |
2806 } |
2807 |
2807 |
2808 if (st->num_specs != 0) { |
2808 if (st->num_specs != 0) { |
2809 /* Allocate speclist memory when loading a game */ |
2809 /* Allocate speclist memory when loading a game */ |