568 bool is_passengers = IsCargoInClass(i, CC_PASSENGERS); |
568 bool is_passengers = IsCargoInClass(i, CC_PASSENGERS); |
569 if ((!is_passengers && !(st->facilities & (byte)~FACIL_BUS_STOP)) || |
569 if ((!is_passengers && !(st->facilities & (byte)~FACIL_BUS_STOP)) || |
570 (is_passengers && !(st->facilities & (byte)~FACIL_TRUCK_STOP))) |
570 (is_passengers && !(st->facilities & (byte)~FACIL_TRUCK_STOP))) |
571 amt = 0; |
571 amt = 0; |
572 |
572 |
573 st->goods[i].acceptance = (amt >= 8); |
573 SB(st->goods[i].acceptance_pickup, GoodsEntry::ACCEPTANCE, 1, amt >= 8); |
574 } |
574 } |
575 |
575 |
576 // Only show a message in case the acceptance was actually changed. |
576 // Only show a message in case the acceptance was actually changed. |
577 uint new_acc = GetAcceptanceMask(st); |
577 uint new_acc = GetAcceptanceMask(st); |
578 if (old_acc == new_acc) |
578 if (old_acc == new_acc) |
2382 GoodsEntry *ge = st->goods; |
2382 GoodsEntry *ge = st->goods; |
2383 do { |
2383 do { |
2384 /* Slowly increase the rating back to his original level in the case we |
2384 /* Slowly increase the rating back to his original level in the case we |
2385 * didn't deliver cargo yet to this station. This happens when a bribe |
2385 * didn't deliver cargo yet to this station. This happens when a bribe |
2386 * failed while you didn't moved that cargo yet to a station. */ |
2386 * failed while you didn't moved that cargo yet to a station. */ |
2387 if (ge->days_since_pickup == 255 && ge->rating < INITIAL_STATION_RATING) |
2387 if (!HASBIT(ge->acceptance_pickup, GoodsEntry::PICKUP) && ge->rating < INITIAL_STATION_RATING) { |
2388 ge->rating++; |
2388 ge->rating++; |
|
2389 } |
|
2390 |
2389 /* Only change the rating if we are moving this cargo */ |
2391 /* Only change the rating if we are moving this cargo */ |
2390 if (ge->last_speed != 0) { |
2392 if (HASBIT(ge->acceptance_pickup, GoodsEntry::PICKUP)) { |
2391 byte_inc_sat(&ge->days_since_pickup); |
2393 byte_inc_sat(&ge->days_since_pickup); |
2392 |
2394 |
2393 int rating = 0; |
2395 int rating = 0; |
2394 |
2396 |
2395 { |
2397 { |
2517 if (st->owner == owner && |
2519 if (st->owner == owner && |
2518 DistanceManhattan(tile, st->xy) <= radius) { |
2520 DistanceManhattan(tile, st->xy) <= radius) { |
2519 for (CargoID i = 0; i < NUM_CARGO; i++) { |
2521 for (CargoID i = 0; i < NUM_CARGO; i++) { |
2520 GoodsEntry* ge = &st->goods[i]; |
2522 GoodsEntry* ge = &st->goods[i]; |
2521 |
2523 |
2522 if (ge->days_since_pickup != 255) { |
2524 if (ge->acceptance_pickup != 0) { |
2523 ge->rating = clamp(ge->rating + amount, 0, 255); |
2525 ge->rating = clamp(ge->rating + amount, 0, 255); |
2524 } |
2526 } |
2525 } |
2527 } |
2526 } |
2528 } |
2527 } |
2529 } |
2614 |
2616 |
2615 for (uint i = 0; i != lengthof(around); i++) { |
2617 for (uint i = 0; i != lengthof(around); i++) { |
2616 if (around[i] == NULL) { |
2618 if (around[i] == NULL) { |
2617 if (!st->IsBuoy() && |
2619 if (!st->IsBuoy() && |
2618 (st->town->exclusive_counter == 0 || st->town->exclusivity == st->owner) && // check exclusive transport rights |
2620 (st->town->exclusive_counter == 0 || st->town->exclusivity == st->owner) && // check exclusive transport rights |
2619 st->goods[type].rating != 0 && st->goods[type].last_speed != 0 && // we actually service the station |
2621 st->goods[type].rating != 0 && // when you've got the lowest rating you can get, it's better not to give cargo anymore |
2620 (!_patches.selectgoods || st->goods[type].last_speed > 0) && // if last_speed is 0, no vehicle has been there. |
2622 (!_patches.selectgoods || st->goods[type].last_speed > 0) && // we are servicing the station (or cargo is dumped on all stations) |
2621 ((st->facilities & ~FACIL_BUS_STOP) != 0 || IsCargoInClass(type, CC_PASSENGERS)) && // if we have other fac. than a bus stop, or the cargo is passengers |
2623 ((st->facilities & ~FACIL_BUS_STOP) != 0 || IsCargoInClass(type, CC_PASSENGERS)) && // if we have other fac. than a bus stop, or the cargo is passengers |
2622 ((st->facilities & ~FACIL_TRUCK_STOP) != 0 || !IsCargoInClass(type, CC_PASSENGERS))) { // if we have other fac. than a cargo bay or the cargo is not passengers |
2624 ((st->facilities & ~FACIL_TRUCK_STOP) != 0 || !IsCargoInClass(type, CC_PASSENGERS))) { // if we have other fac. than a cargo bay or the cargo is not passengers |
2623 if (_patches.modified_catchment) { |
2625 if (_patches.modified_catchment) { |
2624 // min and max coordinates of the producer relative |
2626 // min and max coordinates of the producer relative |
2625 const int x_min_prod = 9; |
2627 const int x_min_prod = 9; |
2744 st->last_vehicle_type = VEH_INVALID; |
2746 st->last_vehicle_type = VEH_INVALID; |
2745 st->facilities = FACIL_AIRPORT | FACIL_DOCK; |
2747 st->facilities = FACIL_AIRPORT | FACIL_DOCK; |
2746 st->build_date = _date; |
2748 st->build_date = _date; |
2747 |
2749 |
2748 for (CargoID j = 0; j < NUM_CARGO; j++) { |
2750 for (CargoID j = 0; j < NUM_CARGO; j++) { |
2749 st->goods[j].acceptance = false; |
2751 st->goods[j].acceptance_pickup = 0; |
2750 st->goods[j].days_since_pickup = 255; |
2752 st->goods[j].days_since_pickup = 255; |
2751 st->goods[j].rating = INITIAL_STATION_RATING; |
2753 st->goods[j].rating = INITIAL_STATION_RATING; |
2752 st->goods[j].last_speed = 0; |
2754 st->goods[j].last_speed = 0; |
2753 st->goods[j].last_age = 255; |
2755 st->goods[j].last_age = 255; |
2754 } |
2756 } |
2975 static uint16 _cargo_days; |
2977 static uint16 _cargo_days; |
2976 static Money _cargo_feeder_share; |
2978 static Money _cargo_feeder_share; |
2977 |
2979 |
2978 static const SaveLoad _goods_desc[] = { |
2980 static const SaveLoad _goods_desc[] = { |
2979 SLEG_CONDVAR( _waiting_acceptance, SLE_UINT16, 0, 67), |
2981 SLEG_CONDVAR( _waiting_acceptance, SLE_UINT16, 0, 67), |
2980 SLE_CONDVAR(GoodsEntry, acceptance, SLE_BOOL, 68, SL_MAX_VERSION), |
2982 SLE_CONDVAR(GoodsEntry, acceptance_pickup, SLE_UINT8, 68, SL_MAX_VERSION), |
2981 SLE_CONDNULL(2, 51, 67), |
2983 SLE_CONDNULL(2, 51, 67), |
2982 SLE_VAR(GoodsEntry, days_since_pickup, SLE_UINT8), |
2984 SLE_VAR(GoodsEntry, days_since_pickup, SLE_UINT8), |
2983 SLE_VAR(GoodsEntry, rating, SLE_UINT8), |
2985 SLE_VAR(GoodsEntry, rating, SLE_UINT8), |
2984 SLEG_CONDVAR( _cargo_source, SLE_FILE_U8 | SLE_VAR_U16, 0, 6), |
2986 SLEG_CONDVAR( _cargo_source, SLE_FILE_U8 | SLE_VAR_U16, 0, 6), |
2985 SLEG_CONDVAR( _cargo_source, SLE_UINT16, 7, 67), |
2987 SLEG_CONDVAR( _cargo_source, SLE_UINT16, 7, 67), |
3011 uint num_cargo = CheckSavegameVersion(55) ? 12 : NUM_CARGO; |
3013 uint num_cargo = CheckSavegameVersion(55) ? 12 : NUM_CARGO; |
3012 for (CargoID i = 0; i < num_cargo; i++) { |
3014 for (CargoID i = 0; i < num_cargo; i++) { |
3013 GoodsEntry *ge = &st->goods[i]; |
3015 GoodsEntry *ge = &st->goods[i]; |
3014 SlObject(ge, _goods_desc); |
3016 SlObject(ge, _goods_desc); |
3015 if (CheckSavegameVersion(68)) { |
3017 if (CheckSavegameVersion(68)) { |
3016 ge->acceptance = HASBIT(_waiting_acceptance, 15); |
3018 SB(ge->acceptance_pickup, GoodsEntry::ACCEPTANCE, 1, HASBIT(_waiting_acceptance, 15)); |
3017 if (GB(_waiting_acceptance, 0, 12) != 0) { |
3019 if (GB(_waiting_acceptance, 0, 12) != 0) { |
3018 /* Don't construct the packet with station here, because that'll fail with old savegames */ |
3020 /* Don't construct the packet with station here, because that'll fail with old savegames */ |
3019 CargoPacket *cp = new CargoPacket(); |
3021 CargoPacket *cp = new CargoPacket(); |
3020 /* In old versions, enroute_from used 0xFF as INVALID_STATION */ |
3022 /* In old versions, enroute_from used 0xFF as INVALID_STATION */ |
3021 cp->source = (CheckSavegameVersion(7) && _cargo_source == 0xFF) ? INVALID_STATION : _cargo_source; |
3023 cp->source = (CheckSavegameVersion(7) && _cargo_source == 0xFF) ? INVALID_STATION : _cargo_source; |
3023 cp->days_in_transit = _cargo_days; |
3025 cp->days_in_transit = _cargo_days; |
3024 cp->feeder_share = _cargo_feeder_share; |
3026 cp->feeder_share = _cargo_feeder_share; |
3025 cp->source_xy = _cargo_source_xy; |
3027 cp->source_xy = _cargo_source_xy; |
3026 cp->days_in_transit = _cargo_days; |
3028 cp->days_in_transit = _cargo_days; |
3027 cp->feeder_share = _cargo_feeder_share; |
3029 cp->feeder_share = _cargo_feeder_share; |
|
3030 SB(ge->acceptance_pickup, GoodsEntry::PICKUP, 1, 1); |
3028 ge->cargo.Append(cp); |
3031 ge->cargo.Append(cp); |
3029 } else { |
|
3030 ge->days_since_pickup = 255; |
|
3031 } |
3032 } |
3032 } |
3033 } |
3033 } |
3034 } |
3034 |
3035 |
3035 if (st->num_specs != 0) { |
3036 if (st->num_specs != 0) { |