Update to 14.0-beta1
This commit is contained in:
@@ -13,7 +13,6 @@
|
||||
#include "roadveh.h"
|
||||
#include "viewport_func.h"
|
||||
#include "viewport_kdtree.h"
|
||||
#include "date_func.h"
|
||||
#include "command_func.h"
|
||||
#include "news_func.h"
|
||||
#include "aircraft.h"
|
||||
@@ -84,8 +83,8 @@ Station::Station(TileIndex tile) :
|
||||
Station::~Station()
|
||||
{
|
||||
if (CleaningPool()) {
|
||||
for (CargoID c = 0; c < NUM_CARGO; c++) {
|
||||
this->goods[c].cargo.OnCleanPool();
|
||||
for (GoodsEntry &ge : this->goods) {
|
||||
ge.cargo.OnCleanPool();
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -104,9 +103,9 @@ Station::~Station()
|
||||
if (lg == nullptr) continue;
|
||||
|
||||
for (NodeID node = 0; node < lg->Size(); ++node) {
|
||||
Station *st = Station::Get((*lg)[node].Station());
|
||||
Station *st = Station::Get((*lg)[node].station);
|
||||
st->goods[c].flows.erase(this->index);
|
||||
if ((*lg)[node][this->goods[c].node].LastUpdate() != INVALID_DATE) {
|
||||
if ((*lg)[node].HasEdgeTo(this->goods[c].node) && (*lg)[node][this->goods[c].node].LastUpdate() != EconomyTime::INVALID_DATE) {
|
||||
st->goods[c].flows.DeleteFlows(this->index);
|
||||
RerouteCargo(st, c, this->index, st->index);
|
||||
}
|
||||
@@ -149,8 +148,8 @@ Station::~Station()
|
||||
/* Remove all news items */
|
||||
DeleteStationNews(this->index);
|
||||
|
||||
for (CargoID c = 0; c < NUM_CARGO; c++) {
|
||||
this->goods[c].cargo.Truncate();
|
||||
for (GoodsEntry &ge : this->goods) {
|
||||
ge.cargo.Truncate();
|
||||
}
|
||||
|
||||
CargoPacket::InvalidateAllFrom(this->index);
|
||||
@@ -163,13 +162,42 @@ Station::~Station()
|
||||
/**
|
||||
* Invalidating of the JoinStation window has to be done
|
||||
* after removing item from the pool.
|
||||
* @param index index of deleted item
|
||||
*/
|
||||
void BaseStation::PostDestructor(size_t index)
|
||||
void BaseStation::PostDestructor(size_t)
|
||||
{
|
||||
InvalidateWindowData(WC_SELECT_STATION, 0, 0);
|
||||
}
|
||||
|
||||
void BaseStation::SetRoadStopTileData(TileIndex tile, byte data, bool animation)
|
||||
{
|
||||
for (RoadStopTileData &tile_data : this->custom_roadstop_tile_data) {
|
||||
if (tile_data.tile == tile) {
|
||||
if (animation) {
|
||||
tile_data.animation_frame = data;
|
||||
} else {
|
||||
tile_data.random_bits = data;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
RoadStopTileData tile_data;
|
||||
tile_data.tile = tile;
|
||||
tile_data.animation_frame = animation ? data : 0;
|
||||
tile_data.random_bits = animation ? 0 : data;
|
||||
this->custom_roadstop_tile_data.push_back(tile_data);
|
||||
}
|
||||
|
||||
void BaseStation::RemoveRoadStopTileData(TileIndex tile)
|
||||
{
|
||||
for (RoadStopTileData &tile_data : this->custom_roadstop_tile_data) {
|
||||
if (tile_data.tile == tile) {
|
||||
tile_data = this->custom_roadstop_tile_data.back();
|
||||
this->custom_roadstop_tile_data.pop_back();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the primary road stop (the first road stop) that the given vehicle can load/unload.
|
||||
* @param v the vehicle to get the first road stop for
|
||||
@@ -183,7 +211,7 @@ RoadStop *Station::GetPrimaryRoadStop(const RoadVehicle *v) const
|
||||
/* The vehicle cannot go to this roadstop (different roadtype) */
|
||||
if (!HasTileAnyRoadType(rs->xy, v->compatible_roadtypes)) continue;
|
||||
/* The vehicle is articulated and can therefore not go to a standard road stop. */
|
||||
if (IsStandardRoadStopTile(rs->xy) && v->HasArticulatedPart()) continue;
|
||||
if (IsBayRoadStopTile(rs->xy) && v->HasArticulatedPart()) continue;
|
||||
|
||||
/* The vehicle can actually go to this road stop. So, return it! */
|
||||
break;
|
||||
@@ -204,7 +232,7 @@ void Station::AddFacility(StationFacility new_facility_bit, TileIndex facil_xy)
|
||||
}
|
||||
this->facilities |= new_facility_bit;
|
||||
this->owner = _current_company;
|
||||
this->build_date = _date;
|
||||
this->build_date = TimerGameCalendar::date;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -225,7 +253,7 @@ void Station::MarkTilesDirty(bool cargo_change) const
|
||||
/* Don't waste time updating if there are no custom station graphics
|
||||
* that might change. Even if there are custom graphics, they might
|
||||
* not change. Unfortunately we have no way of telling. */
|
||||
if (this->speclist.size() == 0) return;
|
||||
if (this->speclist.empty()) return;
|
||||
}
|
||||
|
||||
for (h = 0; h < train_station.h; h++) {
|
||||
@@ -346,8 +374,8 @@ Rect Station::GetCatchmentRect() const
|
||||
Rect ret = {
|
||||
std::max<int>(this->rect.left - catchment_radius, 0),
|
||||
std::max<int>(this->rect.top - catchment_radius, 0),
|
||||
std::min<int>(this->rect.right + catchment_radius, MapMaxX()),
|
||||
std::min<int>(this->rect.bottom + catchment_radius, MapMaxY())
|
||||
std::min<int>(this->rect.right + catchment_radius, Map::MaxX()),
|
||||
std::min<int>(this->rect.bottom + catchment_radius, Map::MaxY())
|
||||
};
|
||||
|
||||
return ret;
|
||||
@@ -376,11 +404,7 @@ void Station::AddIndustryToDeliver(Industry *ind, TileIndex tile)
|
||||
}
|
||||
|
||||
/* Include only industries that can accept cargo */
|
||||
uint cargo_index;
|
||||
for (cargo_index = 0; cargo_index < lengthof(ind->accepts_cargo); cargo_index++) {
|
||||
if (ind->accepts_cargo[cargo_index] != CT_INVALID) break;
|
||||
}
|
||||
if (cargo_index >= lengthof(ind->accepts_cargo)) return;
|
||||
if (!ind->IsCargoAccepted()) return;
|
||||
|
||||
this->industries_near.insert(IndustryListEntry{distance, ind});
|
||||
}
|
||||
@@ -389,7 +413,8 @@ void Station::AddIndustryToDeliver(Industry *ind, TileIndex tile)
|
||||
* Remove nearby industry from station's industries_near list.
|
||||
* @param ind Industry
|
||||
*/
|
||||
void Station::RemoveIndustryToDeliver(Industry *ind) {
|
||||
void Station::RemoveIndustryToDeliver(Industry *ind)
|
||||
{
|
||||
auto pos = std::find_if(this->industries_near.begin(), this->industries_near.end(), [&](const IndustryListEntry &e) { return e.industry->index == ind->index; });
|
||||
if (pos != this->industries_near.end()) {
|
||||
this->industries_near.erase(pos);
|
||||
@@ -425,11 +450,12 @@ bool Station::CatchmentCoversTown(TownID t) const
|
||||
/**
|
||||
* Recompute tiles covered in our catchment area.
|
||||
* This will additionally recompute nearby towns and industries.
|
||||
* @param no_clear_nearby_lists If Station::RemoveFromAllNearbyLists does not need to be called.
|
||||
*/
|
||||
void Station::RecomputeCatchment()
|
||||
void Station::RecomputeCatchment(bool no_clear_nearby_lists)
|
||||
{
|
||||
this->industries_near.clear();
|
||||
this->RemoveFromAllNearbyLists();
|
||||
if (!no_clear_nearby_lists) this->RemoveFromAllNearbyLists();
|
||||
|
||||
if (this->rect.IsEmpty()) {
|
||||
this->catchment_tiles.Reset();
|
||||
@@ -496,7 +522,9 @@ void Station::RecomputeCatchment()
|
||||
*/
|
||||
/* static */ void Station::RecomputeCatchmentForAll()
|
||||
{
|
||||
for (Station *st : Station::Iterate()) { st->RecomputeCatchment(); }
|
||||
for (Town *t : Town::Iterate()) { t->stations_near.clear(); }
|
||||
for (Industry *i : Industry::Iterate()) { i->stations_near.clear(); }
|
||||
for (Station *st : Station::Iterate()) { st->RecomputeCatchment(true); }
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
Reference in New Issue
Block a user