mirror of https://github.com/OpenTTD/OpenTTD
(svn r20815) -Revert (r20814): wrong patch at wrong time...
parent
9a0a753d96
commit
b01c63cd23
|
@ -211,9 +211,8 @@
|
||||||
* 146 20446
|
* 146 20446
|
||||||
* 147 20621
|
* 147 20621
|
||||||
* 148 20659
|
* 148 20659
|
||||||
* 149 TODO
|
|
||||||
*/
|
*/
|
||||||
extern const uint16 SAVEGAME_VERSION = 149; ///< current savegame version of OpenTTD
|
extern const uint16 SAVEGAME_VERSION = 148; ///< current savegame version of OpenTTD
|
||||||
|
|
||||||
SavegameType _savegame_type; ///< type of savegame we are loading
|
SavegameType _savegame_type; ///< type of savegame we are loading
|
||||||
|
|
||||||
|
|
|
@ -238,7 +238,6 @@ const SaveLoad *GetGoodsDesc()
|
||||||
SLE_VAR(GoodsEntry, last_age, SLE_UINT8),
|
SLE_VAR(GoodsEntry, last_age, SLE_UINT8),
|
||||||
SLEG_CONDVAR( _cargo_feeder_share, SLE_FILE_U32 | SLE_VAR_I64, 14, 64),
|
SLEG_CONDVAR( _cargo_feeder_share, SLE_FILE_U32 | SLE_VAR_I64, 14, 64),
|
||||||
SLEG_CONDVAR( _cargo_feeder_share, SLE_INT64, 65, 67),
|
SLEG_CONDVAR( _cargo_feeder_share, SLE_INT64, 65, 67),
|
||||||
SLE_CONDVAR(GoodsEntry, amount_fract, SLE_UINT8, 149, SL_MAX_VERSION),
|
|
||||||
SLE_CONDLST(GoodsEntry, cargo.packets, REF_CARGO_PACKET, 68, SL_MAX_VERSION),
|
SLE_CONDLST(GoodsEntry, cargo.packets, REF_CARGO_PACKET, 68, SL_MAX_VERSION),
|
||||||
|
|
||||||
SLE_END()
|
SLE_END()
|
||||||
|
|
|
@ -42,7 +42,6 @@ struct GoodsEntry {
|
||||||
byte rating;
|
byte rating;
|
||||||
byte last_speed;
|
byte last_speed;
|
||||||
byte last_age;
|
byte last_age;
|
||||||
byte amount_fract; ///< Fractional part of the amount in the cargo list
|
|
||||||
StationCargoList cargo; ///< The cargo packets of cargo waiting in this station
|
StationCargoList cargo; ///< The cargo packets of cargo waiting in this station
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -3190,13 +3190,7 @@ void ModifyStationRatingAround(TileIndex tile, Owner owner, int amount, uint rad
|
||||||
|
|
||||||
static void UpdateStationWaiting(Station *st, CargoID type, uint amount, SourceType source_type, SourceID source_id)
|
static void UpdateStationWaiting(Station *st, CargoID type, uint amount, SourceType source_type, SourceID source_id)
|
||||||
{
|
{
|
||||||
amount += st->goods[type].amount_fract;
|
st->goods[type].cargo.Append(new CargoPacket(st->index, st->xy, amount, source_type, source_id));
|
||||||
st->goods[type].amount_fract = GB(amount, 0, 8);
|
|
||||||
|
|
||||||
/* No new "real" cargo item yet. */
|
|
||||||
if (amount <= UINT8_MAX) return;
|
|
||||||
|
|
||||||
st->goods[type].cargo.Append(new CargoPacket(st->index, st->xy, amount >> 8, source_type, source_id));
|
|
||||||
SetBit(st->goods[type].acceptance_pickup, GoodsEntry::PICKUP);
|
SetBit(st->goods[type].acceptance_pickup, GoodsEntry::PICKUP);
|
||||||
|
|
||||||
TriggerStationAnimation(st, st->xy, SAT_NEW_CARGO, type);
|
TriggerStationAnimation(st, st->xy, SAT_NEW_CARGO, type);
|
||||||
|
@ -3334,14 +3328,11 @@ uint MoveGoodsToStation(CargoID type, uint amount, SourceType source_type, Sourc
|
||||||
/* no stations around at all? */
|
/* no stations around at all? */
|
||||||
if (st1 == NULL) return 0;
|
if (st1 == NULL) return 0;
|
||||||
|
|
||||||
/* From now we'll calculate with fractal cargo amounts.
|
|
||||||
* First determine how much cargo we really have. */
|
|
||||||
amount *= best_rating1 + 1;
|
|
||||||
|
|
||||||
if (st2 == NULL) {
|
if (st2 == NULL) {
|
||||||
/* only one station around */
|
/* only one station around */
|
||||||
UpdateStationWaiting(st1, type, amount, source_type, source_id);
|
uint moved = amount * best_rating1 / 256 + 1;
|
||||||
return amount >> 8;
|
UpdateStationWaiting(st1, type, moved, source_type, source_id);
|
||||||
|
return moved;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* several stations around, the best two (highest rating) are in st1 and st2 */
|
/* several stations around, the best two (highest rating) are in st1 and st2 */
|
||||||
|
@ -3349,19 +3340,26 @@ uint MoveGoodsToStation(CargoID type, uint amount, SourceType source_type, Sourc
|
||||||
assert(st2 != NULL);
|
assert(st2 != NULL);
|
||||||
assert(best_rating1 != 0 || best_rating2 != 0);
|
assert(best_rating1 != 0 || best_rating2 != 0);
|
||||||
|
|
||||||
/* Then determine the amount the worst station gets. We do it this way as the
|
/* the 2nd highest one gets a penalty */
|
||||||
* best should get a bonus, which in this case is the rounding difference from
|
best_rating2 >>= 1;
|
||||||
* this calculation. In reality that will mean the bonus will be pretty low.
|
|
||||||
* Nevertheless, the best station should always get the most cargo regardless
|
|
||||||
* of rounding issues. */
|
|
||||||
uint worst_cargo = amount * best_rating2 / (best_rating1 + best_rating2);
|
|
||||||
assert(worst_cargo < (amount - worst_cargo));
|
|
||||||
|
|
||||||
/* And then send the cargo to the stations! */
|
/* amount given to station 1 */
|
||||||
UpdateStationWaiting(st1, type, amount - worst_cargo, source_type, source_id);
|
uint t = (best_rating1 * (amount + 1)) / (best_rating1 + best_rating2);
|
||||||
UpdateStationWaiting(st2, type, worst_cargo, source_type, source_id);
|
|
||||||
|
|
||||||
return amount >> 8;
|
uint moved = 0;
|
||||||
|
if (t != 0) {
|
||||||
|
moved = t * best_rating1 / 256 + 1;
|
||||||
|
amount -= t;
|
||||||
|
UpdateStationWaiting(st1, type, moved, source_type, source_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (amount != 0) {
|
||||||
|
amount = amount * best_rating2 / 256 + 1;
|
||||||
|
moved += amount;
|
||||||
|
UpdateStationWaiting(st2, type, amount, source_type, source_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return moved;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuildOilRig(TileIndex tile)
|
void BuildOilRig(TileIndex tile)
|
||||||
|
|
Loading…
Reference in New Issue