Merge branches 'upgrade_airport' and 'vehicle_group_info' into jgrpp

This commit is contained in:
Jonathan G Rennison
2015-08-02 18:17:44 +01:00
7 changed files with 212 additions and 49 deletions

View File

@@ -55,6 +55,7 @@ static const NWidgetPart _nested_group_widgets[] = {
SetFill(1, 0), SetResize(0, 1), SetScrollbar(WID_GL_LIST_GROUP_SCROLLBAR), SetFill(1, 0), SetResize(0, 1), SetScrollbar(WID_GL_LIST_GROUP_SCROLLBAR),
NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_GL_LIST_GROUP_SCROLLBAR), NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_GL_LIST_GROUP_SCROLLBAR),
EndContainer(), EndContainer(),
NWidget(WWT_PANEL, COLOUR_GREY, WID_GL_INFO), SetMinimalSize(200, 37), SetFill(1, 0), EndContainer(),
NWidget(NWID_HORIZONTAL), NWidget(NWID_HORIZONTAL),
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_GL_CREATE_GROUP), SetFill(0, 1), NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_GL_CREATE_GROUP), SetFill(0, 1),
SetDataTip(SPR_GROUP_CREATE_TRAIN, STR_GROUP_CREATE_TOOLTIP), SetDataTip(SPR_GROUP_CREATE_TRAIN, STR_GROUP_CREATE_TOOLTIP),
@@ -371,6 +372,9 @@ public:
max_icon_height = max(max_icon_height, GetSpriteSize(this->GetWidget<NWidgetCore>(WID_GL_DELETE_GROUP)->widget_data).height); max_icon_height = max(max_icon_height, GetSpriteSize(this->GetWidget<NWidgetCore>(WID_GL_DELETE_GROUP)->widget_data).height);
max_icon_height = max(max_icon_height, GetSpriteSize(this->GetWidget<NWidgetCore>(WID_GL_REPLACE_PROTECTION)->widget_data).height); max_icon_height = max(max_icon_height, GetSpriteSize(this->GetWidget<NWidgetCore>(WID_GL_REPLACE_PROTECTION)->widget_data).height);
/* ... minus the height of the group info ... */
max_icon_height += 37;
/* Get a multiple of tiny_step_height of that amount */ /* Get a multiple of tiny_step_height of that amount */
size->height = Ceil(size->height - max_icon_height, tiny_step_height); size->height = Ceil(size->height - max_icon_height, tiny_step_height);
break; break;
@@ -527,6 +531,40 @@ public:
DrawGroupInfo(r.top + WD_FRAMERECT_TOP, r.left, r.right, DEFAULT_GROUP); DrawGroupInfo(r.top + WD_FRAMERECT_TOP, r.left, r.right, DEFAULT_GROUP);
break; break;
case WID_GL_INFO: {
Money this_year = 0;
Money last_year = 0;
uint32 occupancy = 0;
uint32 group_vehicles = 0;
for (uint i = 0, vehicle_count = this->vehicles.Length(); i < vehicle_count; i++) {
const Vehicle *v = this->vehicles[i];
assert(v->owner == this->owner);
this_year += v->GetDisplayProfitThisYear();
last_year += v->GetDisplayProfitLastYear();
occupancy += v->trip_occupancy;
group_vehicles++;
}
DrawString(r.left + WD_FRAMERECT_LEFT + 8, r.right - WD_FRAMERECT_RIGHT - 16, r.top + WD_FRAMERECT_TOP + 1, STR_GROUP_PROFIT_THIS_YEAR, TC_BLACK);
SetDParam(0, this_year);
DrawString(r.left + WD_FRAMERECT_LEFT + 8, r.right - WD_FRAMERECT_RIGHT - 16, r.top + WD_FRAMERECT_TOP + 1, STR_JUST_CURRENCY_LONG, TC_BLACK, SA_RIGHT);
DrawString(r.left + WD_FRAMERECT_LEFT + 8, r.right - WD_FRAMERECT_RIGHT - 16, r.top + WD_FRAMERECT_TOP + FONT_HEIGHT_NORMAL + 2, STR_GROUP_PROFIT_LAST_YEAR, TC_BLACK);
SetDParam(0, last_year);
DrawString(r.left + WD_FRAMERECT_LEFT + 8, r.right - WD_FRAMERECT_RIGHT - 16, r.top + WD_FRAMERECT_TOP + FONT_HEIGHT_NORMAL + 2, STR_JUST_CURRENCY_LONG, TC_BLACK, SA_RIGHT);
DrawString(r.left + WD_FRAMERECT_LEFT + 8, r.right - WD_FRAMERECT_RIGHT - 16, r.top + WD_FRAMERECT_TOP + 2 * FONT_HEIGHT_NORMAL + 3, STR_GROUP_OCCUPANCY, TC_BLACK);
if (group_vehicles > 0) {
SetDParam(0, occupancy / group_vehicles);
DrawString(r.left + WD_FRAMERECT_LEFT + 8, r.right - WD_FRAMERECT_RIGHT - 16, r.top + WD_FRAMERECT_TOP + 2 * FONT_HEIGHT_NORMAL + 3, STR_GROUP_OCCUPANCY_VALUE, TC_BLACK, SA_RIGHT);
}
break;
}
case WID_GL_LIST_GROUP: { case WID_GL_LIST_GROUP: {
int y1 = r.top + WD_FRAMERECT_TOP; int y1 = r.top + WD_FRAMERECT_TOP;
int max = min(this->group_sb->GetPosition() + this->group_sb->GetCapacity(), this->groups.Length()); int max = min(this->group_sb->GetPosition() + this->group_sb->GetCapacity(), this->groups.Length());

View File

@@ -3527,6 +3527,11 @@ STR_GROUP_REMOVE_ALL_VEHICLES :Remove all vehi
STR_GROUP_RENAME_CAPTION :{BLACK}Rename a group STR_GROUP_RENAME_CAPTION :{BLACK}Rename a group
STR_GROUP_PROFIT_THIS_YEAR :Profit this year:
STR_GROUP_PROFIT_LAST_YEAR :Profit last year:
STR_GROUP_OCCUPANCY :Current usage:
STR_GROUP_OCCUPANCY_VALUE :{NUM}%
# Build vehicle window # Build vehicle window
STR_BUY_VEHICLE_TRAIN_RAIL_CAPTION :New Rail Vehicles STR_BUY_VEHICLE_TRAIN_RAIL_CAPTION :New Rail Vehicles
STR_BUY_VEHICLE_TRAIN_ELRAIL_CAPTION :New Electric Rail Vehicles STR_BUY_VEHICLE_TRAIN_ELRAIL_CAPTION :New Electric Rail Vehicles

View File

@@ -375,6 +375,8 @@ void AfterLoadVehicles(bool part_of_load)
FOR_ALL_VEHICLES(v) { FOR_ALL_VEHICLES(v) {
assert(v->first != NULL); assert(v->first != NULL);
v->trip_occupancy = CalcPercentVehicleFilled(v, NULL);
switch (v->type) { switch (v->type) {
case VEH_TRAIN: { case VEH_TRAIN: {
Train *t = Train::From(v); Train *t = Train::From(v);

View File

@@ -990,6 +990,47 @@ static CommandCost CheckFlatLandRoadStop(TileArea tile_area, DoCommandFlag flags
return cost; return cost;
} }
/** Checks if an airport can be built at the given area.
* @param tile_area Area to check.
* @param flags Operation to perform.
* @param station StationID of airport allowed in search area.
* @return The cost in case of success, or an error code if it failed.
*/
static CommandCost CheckFlatLandAirport(TileArea tile_area, DoCommandFlag flags, StationID *station)
{
CommandCost cost(EXPENSES_CONSTRUCTION);
int allowed_z = -1;
TILE_AREA_LOOP(tile_cur, tile_area) {
CommandCost ret = CheckBuildableTile(tile_cur, 0, allowed_z, true);
if (ret.Failed()) return ret;
cost.AddCost(ret);
/* if station is set, then allow building on top of an already
* existing airport, either the one in *station if it is not
* INVALID_STATION, or anyone otherwise and store which one
* in *station */
if (station != NULL && IsTileType(tile_cur, MP_STATION)) {
if (!IsAirport(tile_cur)) {
return ClearTile_Station(tile_cur, DC_AUTO); // get error message
} else {
StationID st = GetStationIndex(tile_cur);
if (*station == INVALID_STATION) {
*station = st;
} else if (*station != st) {
return_cmd_error(STR_ERROR_ADJOINS_MORE_THAN_ONE_EXISTING);
}
}
} else {
ret = DoCommand(tile_cur, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (ret.Failed()) return ret;
cost.AddCost(ret);
}
}
return cost;
}
/** /**
* Check whether we can expand the rail part of the given station. * Check whether we can expand the rail part of the given station.
* @param st the station to expand * @param st the station to expand
@@ -1069,16 +1110,16 @@ void GetStationLayout(byte *layout, int numtracks, int plat_len, const StationSp
/** /**
* Find a nearby station that joins this station. * Find a nearby station that joins this station.
* @tparam T the class to find a station for * @tparam T the class to find a station for
* @tparam error_message the error message when building a station on top of others
* @param existing_station an existing station we build over * @param existing_station an existing station we build over
* @param station_to_join the station to join to * @param station_to_join the station to join to
* @param adjacent whether adjacent stations are allowed * @param adjacent whether adjacent stations are allowed
* @param ta the area of the newly build station * @param ta the area of the newly build station
* @param st 'return' pointer for the found station * @param st 'return' pointer for the found station
* @param error_message the error message when building a station on top of others
* @return command cost with the error or 'okay' * @return command cost with the error or 'okay'
*/ */
template <class T, StringID error_message> template <class T>
CommandCost FindJoiningBaseStation(StationID existing_station, StationID station_to_join, bool adjacent, TileArea ta, T **st) CommandCost FindJoiningBaseStation(StationID existing_station, StationID station_to_join, bool adjacent, TileArea ta, T **st, StringID error_message)
{ {
assert(*st == NULL); assert(*st == NULL);
bool check_surrounding = true; bool check_surrounding = true;
@@ -1121,11 +1162,12 @@ CommandCost FindJoiningBaseStation(StationID existing_station, StationID station
* @param adjacent whether adjacent stations are allowed * @param adjacent whether adjacent stations are allowed
* @param ta the area of the newly build station * @param ta the area of the newly build station
* @param st 'return' pointer for the found station * @param st 'return' pointer for the found station
* @param error_message the error message when building a station on top of others
* @return command cost with the error or 'okay' * @return command cost with the error or 'okay'
*/ */
static CommandCost FindJoiningStation(StationID existing_station, StationID station_to_join, bool adjacent, TileArea ta, Station **st) static CommandCost FindJoiningStation(StationID existing_station, StationID station_to_join, bool adjacent, TileArea ta, Station **st, StringID error_message = STR_ERROR_MUST_REMOVE_RAILWAY_STATION_FIRST)
{ {
return FindJoiningBaseStation<Station, STR_ERROR_MUST_REMOVE_RAILWAY_STATION_FIRST>(existing_station, station_to_join, adjacent, ta, st); return FindJoiningBaseStation<Station>(existing_station, station_to_join, adjacent, ta, st, error_message);
} }
/** /**
@@ -1139,7 +1181,7 @@ static CommandCost FindJoiningStation(StationID existing_station, StationID stat
*/ */
CommandCost FindJoiningWaypoint(StationID existing_waypoint, StationID waypoint_to_join, bool adjacent, TileArea ta, Waypoint **wp) CommandCost FindJoiningWaypoint(StationID existing_waypoint, StationID waypoint_to_join, bool adjacent, TileArea ta, Waypoint **wp)
{ {
return FindJoiningBaseStation<Waypoint, STR_ERROR_MUST_REMOVE_RAILWAYPOINT_FIRST>(existing_waypoint, waypoint_to_join, adjacent, ta, wp); return FindJoiningBaseStation<Waypoint>(existing_waypoint, waypoint_to_join, adjacent, ta, wp, STR_ERROR_MUST_REMOVE_RAILWAYPOINT_FIRST);
} }
/** /**
@@ -1731,7 +1773,7 @@ static CommandCost RemoveRoadStop(TileIndex tile, DoCommandFlag flags);
*/ */
static CommandCost FindJoiningRoadStop(StationID existing_stop, StationID station_to_join, bool adjacent, TileArea ta, Station **st) static CommandCost FindJoiningRoadStop(StationID existing_stop, StationID station_to_join, bool adjacent, TileArea ta, Station **st)
{ {
return FindJoiningBaseStation<Station, STR_ERROR_MUST_REMOVE_ROAD_STOP_FIRST>(existing_stop, station_to_join, adjacent, ta, st); return FindJoiningBaseStation<Station>(existing_stop, station_to_join, adjacent, ta, st, STR_ERROR_MUST_REMOVE_ROAD_STOP_FIRST);
} }
/** /**
@@ -2169,6 +2211,37 @@ void UpdateAirportsNoise()
} }
} }
/**
* Checks if an airport can be removed (no aircraft on it or landing)
* @param st Station whose airport is to be removed
* @param flags Operation to perform
* @return Cost or failure of operation
*/
static CommandCost CanRemoveAirport(Station *st, DoCommandFlag flags)
{
const Aircraft *a;
FOR_ALL_AIRCRAFT(a) {
if (!a->IsNormalAircraft()) continue;
if (a->targetairport == st->index && a->state != FLYING)
return_cmd_error(STR_ERROR_AIRCRAFT_IN_THE_WAY);
}
CommandCost cost(EXPENSES_CONSTRUCTION);
TILE_AREA_LOOP(tile_cur, st->airport) {
if (!st->TileBelongsToAirport(tile_cur)) continue;
CommandCost ret = EnsureNoVehicleOnGround(tile_cur);
if (ret.Failed()) return ret;
cost.AddCost(_price[PR_CLEAR_STATION_AIRPORT]);
}
return cost;
}
/** /**
* Place an Airport. * Place an Airport.
* @param tile tile where airport will be built * @param tile tile where airport will be built
@@ -2212,13 +2285,46 @@ CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
return_cmd_error(STR_ERROR_STATION_TOO_SPREAD_OUT); return_cmd_error(STR_ERROR_STATION_TOO_SPREAD_OUT);
} }
CommandCost cost = CheckFlatLand(airport_area, flags); StationID est = INVALID_STATION;
CommandCost cost = CheckFlatLandAirport(airport_area, flags, &est);
if (cost.Failed()) return cost; if (cost.Failed()) return cost;
Station *st = NULL;
ret = FindJoiningStation(est, station_to_join, HasBit(p2, 0), airport_area, &st, STR_ERROR_MUST_DEMOLISH_AIRPORT_FIRST);
if (ret.Failed()) return ret;
/* Distant join */
if (st == NULL && distant_join) st = Station::GetIfValid(station_to_join);
ret = BuildStationPart(&st, flags, reuse, airport_area, (GetAirport(airport_type)->flags & AirportFTAClass::AIRPLANES) ? STATIONNAMING_AIRPORT : STATIONNAMING_HELIPORT);
if (ret.Failed()) return ret;
/* action to be performed */
enum {
AIRPORT_NEW, // airport is a new station
AIRPORT_ADD, // add an airport to an existing station
AIRPORT_UPGRADE, // upgrade the airport in a station
} action =
(est != INVALID_STATION) ? AIRPORT_UPGRADE :
(st != NULL) ? AIRPORT_ADD : AIRPORT_NEW;
if (action == AIRPORT_ADD && st->airport.tile != INVALID_TILE) {
return_cmd_error(STR_ERROR_TOO_CLOSE_TO_ANOTHER_AIRPORT);
}
/* The noise level is the noise from the airport and reduce it to account for the distance to the town center. */ /* The noise level is the noise from the airport and reduce it to account for the distance to the town center. */
AirportTileTableIterator iter(as->table[layout], tile); AirportTileTableIterator iter(as->table[layout], tile);
Town *nearest = AirportGetNearestTown(as, iter); Town *nearest = AirportGetNearestTown(as, iter);
uint newnoise_level = GetAirportNoiseLevelForTown(as, iter, nearest->xy); uint newnoise_level = nearest->noise_reached + GetAirportNoiseLevelForTown(as, iter, nearest->xy);
if (action == AIRPORT_UPGRADE) {
const AirportSpec *old_as = st->airport.GetSpec();
AirportTileTableIterator old_iter(old_as->table[st->airport.layout], st->airport.tile);
Town *old_nearest = AirportGetNearestTown(old_as, old_iter);
if (old_nearest == nearest) {
newnoise_level -= GetAirportNoiseLevelForTown(old_as, old_iter, nearest->xy);
}
}
/* Check if local auth would allow a new airport */ /* Check if local auth would allow a new airport */
StringID authority_refuse_message = STR_NULL; StringID authority_refuse_message = STR_NULL;
@@ -2226,11 +2332,11 @@ CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
if (_settings_game.economy.station_noise_level) { if (_settings_game.economy.station_noise_level) {
/* do not allow to build a new airport if this raise the town noise over the maximum allowed by town */ /* do not allow to build a new airport if this raise the town noise over the maximum allowed by town */
if ((nearest->noise_reached + newnoise_level) > nearest->MaxTownNoise()) { if (newnoise_level > nearest->MaxTownNoise()) {
authority_refuse_message = STR_ERROR_LOCAL_AUTHORITY_REFUSES_NOISE; authority_refuse_message = STR_ERROR_LOCAL_AUTHORITY_REFUSES_NOISE;
authority_refuse_town = nearest; authority_refuse_town = nearest;
} }
} else { } else if (action != AIRPORT_UPGRADE) {
Town *t = ClosestTownFromTile(tile, UINT_MAX); Town *t = ClosestTownFromTile(tile, UINT_MAX);
uint num = 0; uint num = 0;
const Station *st; const Station *st;
@@ -2248,18 +2354,11 @@ CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
return_cmd_error(authority_refuse_message); return_cmd_error(authority_refuse_message);
} }
Station *st = NULL; if (action == AIRPORT_UPGRADE) {
ret = FindJoiningStation(INVALID_STATION, station_to_join, HasBit(p2, 0), airport_area, &st); /* check that the old airport can be removed */
if (ret.Failed()) return ret; CommandCost r = CanRemoveAirport(st, flags);
if (r.Failed()) return r;
/* Distant join */ cost.AddCost(r);
if (st == NULL && distant_join) st = Station::GetIfValid(station_to_join);
ret = BuildStationPart(&st, flags, reuse, airport_area, (GetAirport(airport_type)->flags & AirportFTAClass::AIRPLANES) ? STATIONNAMING_AIRPORT : STATIONNAMING_HELIPORT);
if (ret.Failed()) return ret;
if (st != NULL && st->airport.tile != INVALID_TILE) {
return_cmd_error(STR_ERROR_TOO_CLOSE_TO_ANOTHER_AIRPORT);
} }
for (AirportTileTableIterator iter(as->table[layout], tile); iter != INVALID_TILE; ++iter) { for (AirportTileTableIterator iter(as->table[layout], tile); iter != INVALID_TILE; ++iter) {
@@ -2267,8 +2366,38 @@ CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
} }
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
if (action == AIRPORT_UPGRADE) {
/* delete old airport if upgrading */
const AirportSpec *old_as = st->airport.GetSpec();
AirportTileTableIterator old_iter(old_as->table[st->airport.layout], st->airport.tile);
Town *old_nearest = AirportGetNearestTown(old_as, old_iter);
if (old_nearest != nearest) {
old_nearest->noise_reached -= GetAirportNoiseLevelForTown(old_as, old_iter, old_nearest->xy);
if (_settings_game.economy.station_noise_level) {
SetWindowDirty(WC_TOWN_VIEW, st->town->index);
}
}
TILE_AREA_LOOP(tile_cur, st->airport) {
if (IsHangarTile(tile_cur)) OrderBackup::Reset(tile_cur, false);
DeleteAnimatedTile(tile_cur);
DoClearSquare(tile_cur);
DeleteNewGRFInspectWindow(GSF_AIRPORTTILES, tile_cur);
}
for (uint i = 0; i < st->airport.GetNumHangars(); ++i) {
DeleteWindowById(
WC_VEHICLE_DEPOT, st->airport.GetHangarTile(i)
);
}
st->rect.AfterRemoveRect(st, st->airport);
st->airport.Clear();
}
/* Always add the noise, so there will be no need to recalculate when option toggles */ /* Always add the noise, so there will be no need to recalculate when option toggles */
nearest->noise_reached += newnoise_level; nearest->noise_reached = newnoise_level;
st->AddFacility(FACIL_AIRPORT, tile); st->AddFacility(FACIL_AIRPORT, tile);
st->airport.type = airport_type; st->airport.type = airport_type;
@@ -2291,12 +2420,16 @@ CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
AirportTileAnimationTrigger(st, iter, AAT_BUILT); AirportTileAnimationTrigger(st, iter, AAT_BUILT);
} }
UpdateAirplanesOnNewStation(st); if (action != AIRPORT_NEW) UpdateAirplanesOnNewStation(st);
if (action == AIRPORT_UPGRADE) {
UpdateStationSignCoord(st);
} else {
Company::Get(st->owner)->infrastructure.airport++; Company::Get(st->owner)->infrastructure.airport++;
DirtyCompanyInfrastructureWindows(st->owner); DirtyCompanyInfrastructureWindows(st->owner);
st->UpdateVirtCoord(); st->UpdateVirtCoord();
}
UpdateStationAcceptance(st, false); UpdateStationAcceptance(st, false);
st->RecomputeIndustriesNear(); st->RecomputeIndustriesNear();
InvalidateWindowData(WC_SELECT_STATION, 0, 0); InvalidateWindowData(WC_SELECT_STATION, 0, 0);
@@ -2326,15 +2459,8 @@ static CommandCost RemoveAirport(TileIndex tile, DoCommandFlag flags)
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
} }
tile = st->airport.tile; CommandCost cost = CanRemoveAirport(st, flags);
if (cost.Failed()) return cost;
CommandCost cost(EXPENSES_CONSTRUCTION);
const Aircraft *a;
FOR_ALL_AIRCRAFT(a) {
if (!a->IsNormalAircraft()) continue;
if (a->targetairport == st->index && a->state != FLYING) return CMD_ERROR;
}
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
const AirportSpec *as = st->airport.GetSpec(); const AirportSpec *as = st->airport.GetSpec();
@@ -2344,25 +2470,14 @@ static CommandCost RemoveAirport(TileIndex tile, DoCommandFlag flags)
AirportTileIterator it(st); AirportTileIterator it(st);
Town *nearest = AirportGetNearestTown(as, it); Town *nearest = AirportGetNearestTown(as, it);
nearest->noise_reached -= GetAirportNoiseLevelForTown(as, it, nearest->xy); nearest->noise_reached -= GetAirportNoiseLevelForTown(as, it, nearest->xy);
}
TILE_AREA_LOOP(tile_cur, st->airport) { TILE_AREA_LOOP(tile_cur, st->airport) {
if (!st->TileBelongsToAirport(tile_cur)) continue;
CommandCost ret = EnsureNoVehicleOnGround(tile_cur);
if (ret.Failed()) return ret;
cost.AddCost(_price[PR_CLEAR_STATION_AIRPORT]);
if (flags & DC_EXEC) {
if (IsHangarTile(tile_cur)) OrderBackup::Reset(tile_cur, false); if (IsHangarTile(tile_cur)) OrderBackup::Reset(tile_cur, false);
DeleteAnimatedTile(tile_cur); DeleteAnimatedTile(tile_cur);
DoClearSquare(tile_cur); DoClearSquare(tile_cur);
DeleteNewGRFInspectWindow(GSF_AIRPORTTILES, tile_cur); DeleteNewGRFInspectWindow(GSF_AIRPORTTILES, tile_cur);
} }
}
if (flags & DC_EXEC) {
/* Clear the persistent storage. */ /* Clear the persistent storage. */
delete st->airport.psa; delete st->airport.psa;

View File

@@ -2104,6 +2104,7 @@ void Vehicle::LeaveStation()
st->loading_vehicles.remove(this); st->loading_vehicles.remove(this);
HideFillingPercent(&this->fill_percent_te_id); HideFillingPercent(&this->fill_percent_te_id);
trip_occupancy = CalcPercentVehicleFilled(this, NULL);
if (this->type == VEH_TRAIN && !(this->vehstatus & VS_CRASHED)) { if (this->type == VEH_TRAIN && !(this->vehstatus & VS_CRASHED)) {
/* Trigger station animation (trains only) */ /* Trigger station animation (trains only) */

View File

@@ -250,6 +250,7 @@ public:
uint16 refit_cap; ///< Capacity left over from before last refit. uint16 refit_cap; ///< Capacity left over from before last refit.
VehicleCargoList cargo; ///< The cargo this vehicle is carrying VehicleCargoList cargo; ///< The cargo this vehicle is carrying
uint16 cargo_age_counter; ///< Ticks till cargo is aged next. uint16 cargo_age_counter; ///< Ticks till cargo is aged next.
int8 trip_occupancy; ///< NOSAVE: Occupancy of vehicle of the current trip (updated after leaving a station).
byte day_counter; ///< Increased by one for each day byte day_counter; ///< Increased by one for each day
byte tick_counter; ///< Increased by one for each tick byte tick_counter; ///< Increased by one for each tick

View File

@@ -32,6 +32,7 @@ enum GroupListWidgets {
WID_GL_DELETE_GROUP, ///< Delete group button. WID_GL_DELETE_GROUP, ///< Delete group button.
WID_GL_RENAME_GROUP, ///< Rename group button. WID_GL_RENAME_GROUP, ///< Rename group button.
WID_GL_REPLACE_PROTECTION, ///< Replace protection button. WID_GL_REPLACE_PROTECTION, ///< Replace protection button.
WID_GL_INFO, ///< Group info.
}; };
#endif /* WIDGETS_GROUP_WIDGET_H */ #endif /* WIDGETS_GROUP_WIDGET_H */