Update to 15.0-beta1

This commit is contained in:
dP
2024-12-25 20:34:06 +05:00
parent 46dc456049
commit a86fd7c621
963 changed files with 38064 additions and 33792 deletions
+36 -30
View File
@@ -36,7 +36,7 @@ StationPool _station_pool("Station");
INSTANTIATE_POOL_METHODS(Station)
StationKdtree _station_kdtree(Kdtree_StationXYFunc);
StationKdtree _station_kdtree{};
void RebuildStationKdtree()
{
@@ -168,16 +168,14 @@ void BaseStation::PostDestructor(size_t)
InvalidateWindowData(WC_SELECT_STATION, 0, 0);
}
void BaseStation::SetRoadStopTileData(TileIndex tile, byte data, bool animation)
bool BaseStation::SetRoadStopTileData(TileIndex tile, uint8_t 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;
uint8_t &v = animation ? tile_data.animation_frame : tile_data.random_bits;
if (v == data) return false;
v = data;
return true;
}
}
RoadStopTileData tile_data;
@@ -185,6 +183,7 @@ void BaseStation::SetRoadStopTileData(TileIndex tile, byte data, bool animation)
tile_data.animation_frame = animation ? data : 0;
tile_data.random_bits = animation ? 0 : data;
this->custom_roadstop_tile_data.push_back(tile_data);
return data != 0;
}
void BaseStation::RemoveRoadStopTileData(TileIndex tile)
@@ -243,10 +242,7 @@ void Station::AddFacility(StationFacility new_facility_bit, TileIndex facil_xy)
*/
void Station::MarkTilesDirty(bool cargo_change) const
{
TileIndex tile = this->train_station.tile;
int w, h;
if (tile == INVALID_TILE) return;
if (this->train_station.tile == INVALID_TILE) return;
/* cargo_change is set if we're refreshing the tiles due to cargo moving
* around. */
@@ -257,14 +253,10 @@ void Station::MarkTilesDirty(bool cargo_change) const
if (this->speclist.empty()) return;
}
for (h = 0; h < train_station.h; h++) {
for (w = 0; w < train_station.w; w++) {
if (this->TileBelongsToRailStation(tile)) {
MarkTileDirtyByTile(tile);
}
tile += TileDiffXY(1, 0);
for (TileIndex tile : this->train_station) {
if (this->TileBelongsToRailStation(tile)) {
MarkTileDirtyByTile(tile);
}
tile += TileDiffXY(-w, 1);
}
}
@@ -272,7 +264,7 @@ void Station::MarkTilesDirty(bool cargo_change) const
{
assert(this->TileBelongsToRailStation(tile));
TileIndexDiff delta = (GetRailStationAxis(tile) == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1));
TileIndexDiff delta = TileOffsByAxis(GetRailStationAxis(tile));
TileIndex t = tile;
uint len = 0;
@@ -327,13 +319,15 @@ static uint GetTileCatchmentRadius(TileIndex tile, const Station *st)
default: NOT_REACHED();
case STATION_BUOY:
case STATION_WAYPOINT: return CA_NONE;
case STATION_WAYPOINT:
case STATION_ROADWAYPOINT: return CA_NONE;
}
} else {
switch (GetStationType(tile)) {
default: return CA_UNMODIFIED;
case STATION_BUOY:
case STATION_WAYPOINT: return CA_NONE;
case STATION_WAYPOINT:
case STATION_ROADWAYPOINT: return CA_NONE;
}
}
}
@@ -394,7 +388,7 @@ void Station::AddIndustryToDeliver(Industry *ind, TileIndex tile)
uint distance = DistanceMax(this->xy, tile);
/* Don't check further if this industry is already in the list but update the distance if it's closer */
auto pos = std::find_if(this->industries_near.begin(), this->industries_near.end(), [&](const IndustryListEntry &e) { return e.industry->index == ind->index; });
auto pos = std::ranges::find(this->industries_near, ind, &IndustryListEntry::industry);
if (pos != this->industries_near.end()) {
if (pos->distance > distance) {
auto node = this->industries_near.extract(pos);
@@ -416,7 +410,7 @@ void Station::AddIndustryToDeliver(Industry *ind, TileIndex tile)
*/
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; });
auto pos = std::ranges::find(this->industries_near, ind, &IndustryListEntry::industry);
if (pos != this->industries_near.end()) {
this->industries_near.erase(pos);
}
@@ -424,12 +418,24 @@ void Station::RemoveIndustryToDeliver(Industry *ind)
/**
* Remove this station from the nearby stations lists of all towns and industries.
* Remove this station from the nearby stations lists of nearby towns and industries.
*/
void Station::RemoveFromAllNearbyLists()
{
for (Town *t : Town::Iterate()) { t->stations_near.erase(this); }
for (Industry *i : Industry::Iterate()) { i->stations_near.erase(this); }
std::set<TownID> towns;
std::set<IndustryID> industries;
for (const auto &tile : this->catchment_tiles) {
TileType type = GetTileType(tile);
if (type == MP_HOUSE) {
towns.insert(GetTownIndex(tile));
} else if (type == MP_INDUSTRY) {
industries.insert(GetIndustryIndex(tile));
}
}
for (const TownID &townid : towns) { Town::Get(townid)->stations_near.erase(this); }
for (const IndustryID &industryid : industries) { Industry::Get(industryid)->stations_near.erase(this); }
}
/**
@@ -582,7 +588,7 @@ CommandCost StationRect::BeforeAddTile(TileIndex tile, StationRectMode mode)
int h = new_rect.Height();
if (mode != ADD_FORCE && (w > _settings_game.station.station_spread || h > _settings_game.station.station_spread)) {
assert(mode != ADD_TRY);
return_cmd_error(STR_ERROR_STATION_TOO_SPREAD_OUT);
return CommandCost(STR_ERROR_STATION_TOO_SPREAD_OUT);
}
/* spread-out ok, return true */
@@ -601,7 +607,7 @@ CommandCost StationRect::BeforeAddRect(TileIndex tile, int w, int h, StationRect
if (mode == ADD_FORCE || (w <= _settings_game.station.station_spread && h <= _settings_game.station.station_spread)) {
/* Important when the old rect is completely inside the new rect, resp. the old one was empty. */
CommandCost ret = this->BeforeAddTile(tile, mode);
if (ret.Succeeded()) ret = this->BeforeAddTile(TILE_ADDXY(tile, w - 1, h - 1), mode);
if (ret.Succeeded()) ret = this->BeforeAddTile(TileAddXY(tile, w - 1, h - 1), mode);
return ret;
}
return CommandCost();
@@ -682,7 +688,7 @@ bool StationRect::AfterRemoveRect(BaseStation *st, TileArea ta)
assert(this->PtInExtendedRect(TileX(ta.tile) + ta.w - 1, TileY(ta.tile) + ta.h - 1));
bool empty = this->AfterRemoveTile(st, ta.tile);
if (ta.w != 1 || ta.h != 1) empty = empty || this->AfterRemoveTile(st, TILE_ADDXY(ta.tile, ta.w - 1, ta.h - 1));
if (ta.w != 1 || ta.h != 1) empty = empty || this->AfterRemoveTile(st, TileAddXY(ta.tile, ta.w - 1, ta.h - 1));
return empty;
}