Station rating: Track last visited vehicle type separately per-cargo
This commit is contained in:
@@ -1928,7 +1928,7 @@ static void LoadUnloadVehicle(Vehicle *front)
|
|||||||
anything_loaded = true;
|
anything_loaded = true;
|
||||||
|
|
||||||
st->time_since_load = 0;
|
st->time_since_load = 0;
|
||||||
st->last_vehicle_type = v->type;
|
ge->last_vehicle_type = v->type;
|
||||||
|
|
||||||
if (ge->cargo.TotalCount() == 0) {
|
if (ge->cargo.TotalCount() == 0) {
|
||||||
TriggerStationRandomisation(st, st->xy, SRT_CARGO_TAKEN, v->cargo_type);
|
TriggerStationRandomisation(st, st->xy, SRT_CARGO_TAKEN, v->cargo_type);
|
||||||
|
@@ -1480,7 +1480,9 @@ bool AfterLoadGame()
|
|||||||
if (IsSavegameVersionBefore(26)) {
|
if (IsSavegameVersionBefore(26)) {
|
||||||
Station *st;
|
Station *st;
|
||||||
FOR_ALL_STATIONS(st) {
|
FOR_ALL_STATIONS(st) {
|
||||||
st->last_vehicle_type = VEH_INVALID;
|
for (CargoID c = 0; c < NUM_CARGO; c++) {
|
||||||
|
st->goods[c].last_vehicle_type = VEH_INVALID;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -85,6 +85,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
|
|||||||
{ XSLFI_TRAIN_THROUGH_LOAD, XSCF_NULL, 1, 1, "train_through_load", NULL, NULL, NULL },
|
{ XSLFI_TRAIN_THROUGH_LOAD, XSCF_NULL, 1, 1, "train_through_load", NULL, NULL, NULL },
|
||||||
{ XSLFI_ORDER_EXTRA_DATA, XSCF_NULL, 1, 1, "order_extra_data", NULL, NULL, NULL },
|
{ XSLFI_ORDER_EXTRA_DATA, XSCF_NULL, 1, 1, "order_extra_data", NULL, NULL, NULL },
|
||||||
{ XSLFI_WHOLE_MAP_CHUNK, XSCF_NULL, 1, 1, "whole_map_chunk", NULL, NULL, "WMAP" },
|
{ XSLFI_WHOLE_MAP_CHUNK, XSCF_NULL, 1, 1, "whole_map_chunk", NULL, NULL, "WMAP" },
|
||||||
|
{ XSLFI_ST_LAST_VEH_TYPE, XSCF_NULL, 1, 1, "station_last_veh_type", NULL, NULL, NULL },
|
||||||
{ XSLFI_NULL, XSCF_NULL, 0, 0, NULL, NULL, NULL, NULL },// This is the end marker
|
{ XSLFI_NULL, XSCF_NULL, 0, 0, NULL, NULL, NULL, NULL },// This is the end marker
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -59,6 +59,7 @@ enum SlXvFeatureIndex {
|
|||||||
XSLFI_TRAIN_THROUGH_LOAD, ///< Train through load/unload
|
XSLFI_TRAIN_THROUGH_LOAD, ///< Train through load/unload
|
||||||
XSLFI_ORDER_EXTRA_DATA, ///< Order extra data field(s)
|
XSLFI_ORDER_EXTRA_DATA, ///< Order extra data field(s)
|
||||||
XSLFI_WHOLE_MAP_CHUNK, ///< Whole map chunk
|
XSLFI_WHOLE_MAP_CHUNK, ///< Whole map chunk
|
||||||
|
XSLFI_ST_LAST_VEH_TYPE, ///< Per-cargo station last vehicle type
|
||||||
|
|
||||||
XSLFI_RIFF_HEADER_60_BIT, ///< Size field in RIFF chunk header is 60 bit
|
XSLFI_RIFF_HEADER_60_BIT, ///< Size field in RIFF chunk header is 60 bit
|
||||||
XSLFI_HEIGHT_8_BIT, ///< Map tile height is 8 bit instead of 4 bit, but savegame version may be before this became true in trunk
|
XSLFI_HEIGHT_8_BIT, ///< Map tile height is 8 bit instead of 4 bit, but savegame version may be before this became true in trunk
|
||||||
|
@@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
#include "../safeguards.h"
|
#include "../safeguards.h"
|
||||||
|
|
||||||
|
static byte _old_last_vehicle_type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the buoy orders to be waypoint orders.
|
* Update the buoy orders to be waypoint orders.
|
||||||
* @param o the order 'list' to check.
|
* @param o the order 'list' to check.
|
||||||
@@ -219,7 +221,7 @@ static const SaveLoad _old_station_desc[] = {
|
|||||||
SLE_CONDVAR(Station, airport.flags, SLE_UINT64, 46, SL_MAX_VERSION),
|
SLE_CONDVAR(Station, airport.flags, SLE_UINT64, 46, SL_MAX_VERSION),
|
||||||
|
|
||||||
SLE_CONDNULL(2, 0, 25), ///< last-vehicle
|
SLE_CONDNULL(2, 0, 25), ///< last-vehicle
|
||||||
SLE_CONDVAR(Station, last_vehicle_type, SLE_UINT8, 26, SL_MAX_VERSION),
|
SLEG_CONDVAR_X(_old_last_vehicle_type, SLE_UINT8, 26, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_ST_LAST_VEH_TYPE, 0, 0)),
|
||||||
|
|
||||||
SLE_CONDNULL(2, 3, 25), ///< custom station class and id
|
SLE_CONDNULL(2, 3, 25), ///< custom station class and id
|
||||||
SLE_CONDVAR(Station, build_date, SLE_FILE_U16 | SLE_VAR_I32, 3, 30),
|
SLE_CONDVAR(Station, build_date, SLE_FILE_U16 | SLE_VAR_I32, 3, 30),
|
||||||
@@ -306,6 +308,7 @@ const SaveLoad *GetGoodsDesc()
|
|||||||
SLE_CONDVAR(GoodsEntry, node, SLE_UINT16, 183, SL_MAX_VERSION),
|
SLE_CONDVAR(GoodsEntry, node, SLE_UINT16, 183, SL_MAX_VERSION),
|
||||||
SLEG_CONDVAR( _num_flows, SLE_UINT32, 183, SL_MAX_VERSION),
|
SLEG_CONDVAR( _num_flows, SLE_UINT32, 183, SL_MAX_VERSION),
|
||||||
SLE_CONDVAR(GoodsEntry, max_waiting_cargo, SLE_UINT32, 183, SL_MAX_VERSION),
|
SLE_CONDVAR(GoodsEntry, max_waiting_cargo, SLE_UINT32, 183, SL_MAX_VERSION),
|
||||||
|
SLE_CONDVAR_X(GoodsEntry, last_vehicle_type, SLE_UINT8, 0, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_ST_LAST_VEH_TYPE, 1)),
|
||||||
SLE_END()
|
SLE_END()
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -379,6 +382,7 @@ static void Load_STNS()
|
|||||||
SB(ge->status, GoodsEntry::GES_RATING, 1, 1);
|
SB(ge->status, GoodsEntry::GES_RATING, 1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (SlXvIsFeatureMissing(XSLFI_ST_LAST_VEH_TYPE)) ge->last_vehicle_type = _old_last_vehicle_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (st->num_specs != 0) {
|
if (st->num_specs != 0) {
|
||||||
@@ -460,7 +464,7 @@ static const SaveLoad _station_desc[] = {
|
|||||||
|
|
||||||
SLE_VAR(Station, time_since_load, SLE_UINT8),
|
SLE_VAR(Station, time_since_load, SLE_UINT8),
|
||||||
SLE_VAR(Station, time_since_unload, SLE_UINT8),
|
SLE_VAR(Station, time_since_unload, SLE_UINT8),
|
||||||
SLE_VAR(Station, last_vehicle_type, SLE_UINT8),
|
SLEG_CONDVAR_X(_old_last_vehicle_type, SLE_UINT8, 0, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_ST_LAST_VEH_TYPE, 0, 0)),
|
||||||
SLE_VAR(Station, had_vehicle_of_type, SLE_UINT8),
|
SLE_VAR(Station, had_vehicle_of_type, SLE_UINT8),
|
||||||
SLE_VEC(Station, loading_vehicles, REF_VEHICLE),
|
SLE_VEC(Station, loading_vehicles, REF_VEHICLE),
|
||||||
SLE_CONDVAR(Station, always_accepted, SLE_UINT32, 127, SL_MAX_VERSION),
|
SLE_CONDVAR(Station, always_accepted, SLE_UINT32, 127, SL_MAX_VERSION),
|
||||||
@@ -601,6 +605,7 @@ static void Load_STNN()
|
|||||||
assert(pair.second.empty());
|
assert(pair.second.empty());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (SlXvIsFeatureMissing(XSLFI_ST_LAST_VEH_TYPE)) st->goods[i].last_vehicle_type = _old_last_vehicle_type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -60,8 +60,7 @@ Station::Station(TileIndex tile) :
|
|||||||
dock_station(INVALID_TILE, 0, 0),
|
dock_station(INVALID_TILE, 0, 0),
|
||||||
indtype(IT_INVALID),
|
indtype(IT_INVALID),
|
||||||
time_since_load(255),
|
time_since_load(255),
|
||||||
time_since_unload(255),
|
time_since_unload(255)
|
||||||
last_vehicle_type(VEH_INVALID)
|
|
||||||
{
|
{
|
||||||
/* this->random_bits is set in Station::AddFacility() */
|
/* this->random_bits is set in Station::AddFacility() */
|
||||||
}
|
}
|
||||||
|
@@ -216,6 +216,7 @@ struct GoodsEntry {
|
|||||||
GoodsEntry() :
|
GoodsEntry() :
|
||||||
status(0),
|
status(0),
|
||||||
time_since_pickup(255),
|
time_since_pickup(255),
|
||||||
|
last_vehicle_type(VEH_INVALID),
|
||||||
rating(INITIAL_STATION_RATING),
|
rating(INITIAL_STATION_RATING),
|
||||||
last_speed(0),
|
last_speed(0),
|
||||||
last_age(255),
|
last_age(255),
|
||||||
@@ -234,6 +235,8 @@ struct GoodsEntry {
|
|||||||
*/
|
*/
|
||||||
byte time_since_pickup;
|
byte time_since_pickup;
|
||||||
|
|
||||||
|
byte last_vehicle_type;
|
||||||
|
|
||||||
byte rating; ///< %Station rating for this cargo.
|
byte rating; ///< %Station rating for this cargo.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -470,7 +473,6 @@ public:
|
|||||||
byte time_since_load;
|
byte time_since_load;
|
||||||
byte time_since_unload;
|
byte time_since_unload;
|
||||||
|
|
||||||
byte last_vehicle_type;
|
|
||||||
std::vector<Vehicle *> loading_vehicles;
|
std::vector<Vehicle *> loading_vehicles;
|
||||||
GoodsEntry goods[NUM_CARGO]; ///< Goods at this station
|
GoodsEntry goods[NUM_CARGO]; ///< Goods at this station
|
||||||
CargoTypes always_accepted; ///< Bitmask of always accepted cargo types (by houses, HQs, industry tiles when industry doesn't accept cargo)
|
CargoTypes always_accepted; ///< Bitmask of always accepted cargo types (by houses, HQs, industry tiles when industry doesn't accept cargo)
|
||||||
|
@@ -3485,7 +3485,7 @@ static void UpdateStationRating(Station *st)
|
|||||||
|
|
||||||
uint32 var18 = min(ge->time_since_pickup, 0xFF) | (min(ge->max_waiting_cargo, 0xFFFF) << 8) | (min(last_speed, 0xFF) << 24);
|
uint32 var18 = min(ge->time_since_pickup, 0xFF) | (min(ge->max_waiting_cargo, 0xFFFF) << 8) | (min(last_speed, 0xFF) << 24);
|
||||||
/* Convert to the 'old' vehicle types */
|
/* Convert to the 'old' vehicle types */
|
||||||
uint32 var10 = (st->last_vehicle_type == VEH_INVALID) ? 0x0 : (st->last_vehicle_type + 0x10);
|
uint32 var10 = (ge->last_vehicle_type == VEH_INVALID) ? 0x0 : (ge->last_vehicle_type + 0x10);
|
||||||
uint16 callback = GetCargoCallback(CBID_CARGO_STATION_RATING_CALC, var10, var18, cs);
|
uint16 callback = GetCargoCallback(CBID_CARGO_STATION_RATING_CALC, var10, var18, cs);
|
||||||
if (callback != CALLBACK_FAILED) {
|
if (callback != CALLBACK_FAILED) {
|
||||||
skip = true;
|
skip = true;
|
||||||
@@ -3501,7 +3501,7 @@ static void UpdateStationRating(Station *st)
|
|||||||
if (b >= 0) rating += b >> 2;
|
if (b >= 0) rating += b >> 2;
|
||||||
|
|
||||||
byte waittime = ge->time_since_pickup;
|
byte waittime = ge->time_since_pickup;
|
||||||
if (st->last_vehicle_type == VEH_SHIP) waittime >>= 2;
|
if (ge->last_vehicle_type == VEH_SHIP) waittime >>= 2;
|
||||||
(waittime > 21) ||
|
(waittime > 21) ||
|
||||||
(rating += 25, waittime > 12) ||
|
(rating += 25, waittime > 12) ||
|
||||||
(rating += 25, waittime > 6) ||
|
(rating += 25, waittime > 6) ||
|
||||||
|
Reference in New Issue
Block a user