mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
(svn r8945) -Codechange: Rename v->load_status to v->vehicle_flags so it can be used for more than just the gradual loading status.
This commit is contained in:
parent
f865f0a445
commit
aadd8a4b44
@ -1284,7 +1284,7 @@ static void HandleAircraftLoading(Vehicle *v, int mode)
|
||||
|
||||
if (CanFillVehicle(v) && (
|
||||
v->current_order.flags & OF_FULL_LOAD ||
|
||||
(_patches.gradual_loading && !HASBIT(v->load_status, LS_LOADING_FINISHED))
|
||||
(_patches.gradual_loading && !HASBIT(v->vehicle_flags, VF_LOADING_FINISHED))
|
||||
)) {
|
||||
SET_EXPENSES_TYPE(EXPENSES_AIRCRAFT_INC);
|
||||
if (LoadUnloadVehicle(v, false)) {
|
||||
|
@ -1352,7 +1352,7 @@ int LoadUnloadVehicle(Vehicle *v, bool just_arrived)
|
||||
* there is nothing left to load. It's easier to clear this if the
|
||||
* conditions haven't been met than attempting to check them all before
|
||||
* enabling though. */
|
||||
SETBIT(v->load_status, LS_LOADING_FINISHED);
|
||||
SETBIT(v->vehicle_flags, VF_LOADING_FINISHED);
|
||||
|
||||
old_player = _current_player;
|
||||
_current_player = v->owner;
|
||||
@ -1371,16 +1371,16 @@ int LoadUnloadVehicle(Vehicle *v, bool just_arrived)
|
||||
if (v->cargo_cap == 0) continue;
|
||||
|
||||
/* If the vehicle has just arrived, set it to unload. */
|
||||
if (just_arrived) SETBIT(v->load_status, LS_CARGO_UNLOADING);
|
||||
if (just_arrived) SETBIT(v->vehicle_flags, VF_CARGO_UNLOADING);
|
||||
|
||||
ge = &st->goods[v->cargo_type];
|
||||
count = GB(ge->waiting_acceptance, 0, 12);
|
||||
|
||||
/* unload? */
|
||||
if (v->cargo_count != 0 && HASBIT(v->load_status, LS_CARGO_UNLOADING)) {
|
||||
if (v->cargo_count != 0 && HASBIT(v->vehicle_flags, VF_CARGO_UNLOADING)) {
|
||||
uint16 amount_unloaded = _patches.gradual_loading ? min(v->cargo_count, load_amount) : v->cargo_count;
|
||||
|
||||
CLRBIT(u->load_status, LS_LOADING_FINISHED);
|
||||
CLRBIT(u->vehicle_flags, VF_LOADING_FINISHED);
|
||||
|
||||
if (v->cargo_source != last_visited && ge->waiting_acceptance & 0x8000 && !(u->current_order.flags & OF_TRANSFER)) {
|
||||
/* deliver goods to the station */
|
||||
@ -1442,8 +1442,8 @@ int LoadUnloadVehicle(Vehicle *v, bool just_arrived)
|
||||
}
|
||||
|
||||
/* The vehicle must have been unloaded because it is either empty, or
|
||||
* the UNLOADING bit is already clear in v->load_status. */
|
||||
CLRBIT(v->load_status, LS_CARGO_UNLOADING);
|
||||
* the UNLOADING bit is already clear in v->vehicle_flags. */
|
||||
CLRBIT(v->vehicle_flags, VF_CARGO_UNLOADING);
|
||||
|
||||
/* We cannot have paid for more cargo than there is on board. */
|
||||
assert(v->cargo_paid_for <= v->cargo_count);
|
||||
@ -1488,7 +1488,7 @@ int LoadUnloadVehicle(Vehicle *v, bool just_arrived)
|
||||
|
||||
if (cap > count) cap = count;
|
||||
if (_patches.gradual_loading) cap = min(cap, load_amount);
|
||||
if (cap < count) CLRBIT(u->load_status, LS_LOADING_FINISHED);
|
||||
if (cap < count) CLRBIT(u->vehicle_flags, VF_LOADING_FINISHED);
|
||||
cargoshare = cap * 10000 / ge->waiting_acceptance;
|
||||
feeder_profit_share = ge->feeder_profit * cargoshare / 10000;
|
||||
v->cargo_count += cap;
|
||||
@ -1515,7 +1515,7 @@ int LoadUnloadVehicle(Vehicle *v, bool just_arrived)
|
||||
uint gradual_loading_wait_time[] = { 40, 20, 10, 20 };
|
||||
|
||||
unloading_time = gradual_loading_wait_time[v->type];
|
||||
if (HASBIT(v->load_status, LS_LOADING_FINISHED)) {
|
||||
if (HASBIT(v->vehicle_flags, VF_LOADING_FINISHED)) {
|
||||
if (anything_loaded) {
|
||||
unloading_time += 20;
|
||||
} else {
|
||||
|
@ -1799,9 +1799,9 @@ bool AfterLoadGame(void)
|
||||
* loading again, even if it didn't actually load anything, so now the
|
||||
* amount of cargo that has been paid for is stored. */
|
||||
FOR_ALL_VEHICLES(v) {
|
||||
if (HASBIT(v->load_status, 2)) {
|
||||
if (HASBIT(v->vehicle_flags, 2)) {
|
||||
v->cargo_paid_for = v->cargo_count;
|
||||
CLRBIT(v->load_status, 2);
|
||||
CLRBIT(v->vehicle_flags, 2);
|
||||
} else {
|
||||
v->cargo_paid_for = 0;
|
||||
}
|
||||
|
@ -748,7 +748,7 @@ static void HandleRoadVehLoading(Vehicle *v)
|
||||
if (--v->load_unload_time_rem != 0) return;
|
||||
|
||||
if (CanFillVehicle(v) && (v->current_order.flags & OF_FULL_LOAD ||
|
||||
(_patches.gradual_loading && !HASBIT(v->load_status, LS_LOADING_FINISHED)))) {
|
||||
(_patches.gradual_loading && !HASBIT(v->vehicle_flags, VF_LOADING_FINISHED)))) {
|
||||
SET_EXPENSES_TYPE(EXPENSES_ROADVEH_INC);
|
||||
if (LoadUnloadVehicle(v, false)) {
|
||||
InvalidateWindow(WC_ROADVEH_LIST, v->owner);
|
||||
|
@ -306,7 +306,7 @@ static void HandleShipLoading(Vehicle *v)
|
||||
|
||||
if (CanFillVehicle(v) && (
|
||||
v->current_order.flags & OF_FULL_LOAD ||
|
||||
(_patches.gradual_loading && !HASBIT(v->load_status, LS_LOADING_FINISHED))
|
||||
(_patches.gradual_loading && !HASBIT(v->vehicle_flags, VF_LOADING_FINISHED))
|
||||
)) {
|
||||
SET_EXPENSES_TYPE(EXPENSES_SHIP_INC);
|
||||
if (LoadUnloadVehicle(v, false)) {
|
||||
|
@ -2515,7 +2515,7 @@ static void HandleTrainLoading(Vehicle *v, bool mode)
|
||||
|
||||
if (CanFillVehicle(v) && (
|
||||
v->current_order.flags & OF_FULL_LOAD ||
|
||||
(_patches.gradual_loading && !HASBIT(v->load_status, LS_LOADING_FINISHED))
|
||||
(_patches.gradual_loading && !HASBIT(v->vehicle_flags, VF_LOADING_FINISHED))
|
||||
)) {
|
||||
v->u.rail.days_since_order_progr = 0; /* Prevent a train lost message for full loading trains */
|
||||
SET_EXPENSES_TYPE(EXPENSES_TRAIN_INC);
|
||||
|
@ -718,7 +718,7 @@ static bool CanFillVehicle_FullLoadAny(Vehicle *v)
|
||||
if (v->cargo_cap == v->cargo_count) {
|
||||
full |= mask;
|
||||
} else if (GB(ge[v->cargo_type].waiting_acceptance, 0, 12) > 0 ||
|
||||
(HASBIT(v->load_status, LS_CARGO_UNLOADING) && (ge[v->cargo_type].waiting_acceptance & 0x8000))) {
|
||||
(HASBIT(v->vehicle_flags, VF_CARGO_UNLOADING) && (ge[v->cargo_type].waiting_acceptance & 0x8000))) {
|
||||
/* If there is any cargo waiting, or this vehicle is still unloading
|
||||
* and the station accepts the cargo, don't leave the station. */
|
||||
keep_loading = true;
|
||||
@ -3049,7 +3049,7 @@ extern const SaveLoad _common_veh_desc[] = {
|
||||
|
||||
SLE_VAR(Vehicle, load_unload_time_rem, SLE_UINT16),
|
||||
SLE_CONDVAR(Vehicle, cargo_paid_for, SLE_UINT16, 45, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Vehicle, load_status, SLE_UINT8, 40, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Vehicle, vehicle_flags, SLE_UINT8, 40, SL_MAX_VERSION),
|
||||
|
||||
SLE_VAR(Vehicle, profit_this_year, SLE_INT32),
|
||||
SLE_VAR(Vehicle, profit_last_year, SLE_INT32),
|
||||
|
@ -83,10 +83,9 @@ enum VehStatus {
|
||||
VS_CRASHED = 0x80,
|
||||
};
|
||||
|
||||
enum LoadStatus {
|
||||
LS_LOADING_FINISHED,
|
||||
LS_CARGO_UNLOADING,
|
||||
/* LS_CARGO_PAID_FOR was here until savegame version 45. */
|
||||
enum VehicleFlags {
|
||||
VF_LOADING_FINISHED,
|
||||
VF_CARGO_UNLOADING,
|
||||
};
|
||||
|
||||
/* Effect vehicle types */
|
||||
@ -294,7 +293,7 @@ struct Vehicle {
|
||||
|
||||
uint16 load_unload_time_rem;
|
||||
uint16 cargo_paid_for; // How much of the cargo currently on board has been paid for.
|
||||
byte load_status;
|
||||
byte vehicle_flags; // Used for gradual loading and other miscellaneous things (@see VehicleFlags enum)
|
||||
|
||||
int32 profit_this_year;
|
||||
int32 profit_last_year;
|
||||
|
Loading…
Reference in New Issue
Block a user