Merge branch 'master' into jgrpp
# Conflicts: # cmake/CompileFlags.cmake # src/3rdparty/squirrel/squirrel/sqclosure.h # src/3rdparty/squirrel/squirrel/sqobject.h # src/3rdparty/squirrel/squirrel/sqvm.h # src/aircraft.h # src/airport_gui.cpp # src/blitter/32bpp_sse_func.hpp # src/blitter/null.hpp # src/bridge_gui.cpp # src/build_vehicle_gui.cpp # src/cargotype.h # src/cheat_gui.cpp # src/command.cpp # src/command_func.h # src/company_gui.cpp # src/console_gui.cpp # src/date_gui.cpp # src/depot_gui.cpp # src/dock_gui.cpp # src/economy.cpp # src/error_gui.cpp # src/fileio.cpp # src/fios.cpp # src/fios_gui.cpp # src/fontcache/spritefontcache.h # src/framerate_gui.cpp # src/game/game_text.cpp # src/gamelog.cpp # src/genworld_gui.cpp # src/gfx_layout_fallback.cpp # src/group_gui.cpp # src/highscore_gui.cpp # src/hotkeys.cpp # src/industry_cmd.cpp # src/industry_gui.cpp # src/landscape.cpp # src/main_gui.cpp # src/misc_cmd.cpp # src/misc_gui.cpp # src/network/core/tcp_game.cpp # src/network/core/udp.cpp # src/network/network_chat_gui.cpp # src/network/network_content_gui.cpp # src/network/network_gui.cpp # src/network/network_server.cpp # src/network/network_server.h # src/newgrf_airport.cpp # src/newgrf_airport.h # src/newgrf_airporttiles.cpp # src/newgrf_airporttiles.h # src/newgrf_animation_base.h # src/newgrf_canal.cpp # src/newgrf_commons.h # src/newgrf_config.cpp # src/newgrf_debug_gui.cpp # src/newgrf_engine.cpp # src/newgrf_engine.h # src/newgrf_generic.cpp # src/newgrf_gui.cpp # src/newgrf_house.cpp # src/newgrf_house.h # src/newgrf_industries.cpp # src/newgrf_industries.h # src/newgrf_industrytiles.cpp # src/newgrf_industrytiles.h # src/newgrf_object.cpp # src/newgrf_object.h # src/newgrf_railtype.cpp # src/newgrf_railtype.h # src/newgrf_roadstop.cpp # src/newgrf_roadstop.h # src/newgrf_roadtype.cpp # src/newgrf_roadtype.h # src/newgrf_spritegroup.cpp # src/newgrf_spritegroup.h # src/newgrf_station.cpp # src/newgrf_station.h # src/newgrf_town.cpp # src/newgrf_town.h # src/news_gui.cpp # src/object_gui.cpp # src/order_gui.cpp # src/os/macosx/crashlog_osx.cpp # src/os/unix/crashlog_unix.cpp # src/os/windows/crashlog_win.cpp # src/os/windows/win32.cpp # src/os/windows/win32_main.cpp # src/pathfinder/npf/npf.cpp # src/pathfinder/npf/queue.cpp # src/rail_cmd.cpp # src/rail_gui.cpp # src/road_gui.cpp # src/roadveh.h # src/saveload/saveload.cpp # src/screenshot.cpp # src/script/api/script_text.hpp # src/settings.cpp # src/settings_gui.cpp # src/settings_internal.h # src/settings_table.cpp # src/signs_cmd.cpp # src/signs_gui.cpp # src/smallmap_gui.cpp # src/smallmap_gui.h # src/spriteloader/grf.hpp # src/station_cmd.cpp # src/station_gui.cpp # src/station_map.h # src/statusbar_gui.cpp # src/stdafx.h # src/strgen/strgen.cpp # src/table/newgrf_debug_data.h # src/terraform_gui.cpp # src/timer/timer_game_calendar.cpp # src/timer/timer_window.cpp # src/town.h # src/town_cmd.cpp # src/town_gui.cpp # src/train_gui.cpp # src/transparency_gui.cpp # src/vehicle_gui.cpp # src/water_cmd.cpp # src/waypoint_cmd.cpp # src/widget.cpp # src/widget_type.h # src/widgets/dropdown.cpp # src/widgets/rail_widget.h # src/widgets/terraform_widget.h # src/window.cpp # src/window_gui.h
This commit is contained in:
@@ -209,8 +209,8 @@ enum StationNaming {
|
||||
|
||||
/** Information to handle station action 0 property 24 correctly */
|
||||
struct StationNameInformation {
|
||||
uint32 free_names; ///< Current bitset of free names (we can remove names).
|
||||
bool *indtypes; ///< Array of bools telling whether an industry type has been found.
|
||||
uint32_t free_names; ///< Current bitset of free names (we can remove names).
|
||||
std::bitset<NUM_INDUSTRYTYPES> indtypes; ///< Bit set indicating when an industry type has been found.
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -249,23 +249,22 @@ static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming n
|
||||
};
|
||||
|
||||
const Town *t = st->town;
|
||||
uint32 free_names = UINT32_MAX;
|
||||
|
||||
bool indtypes[NUM_INDUSTRYTYPES];
|
||||
memset(indtypes, 0, sizeof(indtypes));
|
||||
StationNameInformation sni{};
|
||||
sni.free_names = UINT32_MAX;
|
||||
|
||||
std::bitset<MAX_EXTRA_STATION_NAMES> extra_names;
|
||||
|
||||
for (const Station *s : Station::Iterate()) {
|
||||
if ((force_change || s != st) && s->town == t) {
|
||||
if (s->indtype != IT_INVALID) {
|
||||
indtypes[s->indtype] = true;
|
||||
sni.indtypes[s->indtype] = true;
|
||||
StringID name = GetIndustrySpec(s->indtype)->station_name;
|
||||
if (name != STR_UNDEFINED) {
|
||||
/* Filter for other industrytypes with the same name */
|
||||
for (IndustryType it = 0; it < NUM_INDUSTRYTYPES; it++) {
|
||||
const IndustrySpec *indsp = GetIndustrySpec(it);
|
||||
if (indsp->enabled && indsp->station_name == name) indtypes[it] = true;
|
||||
if (indsp->enabled && indsp->station_name == name) sni.indtypes[it] = true;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
@@ -278,7 +277,7 @@ static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming n
|
||||
if (str == M(STR_SV_STNAME_FOREST)) {
|
||||
str = M(STR_SV_STNAME_WOODS);
|
||||
}
|
||||
ClrBit(free_names, str);
|
||||
ClrBit(sni.free_names, str);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -286,7 +285,6 @@ static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming n
|
||||
st->extra_name_index = UINT16_MAX;
|
||||
|
||||
TileIndex indtile = tile;
|
||||
StationNameInformation sni = { free_names, indtypes };
|
||||
if (CircularTileSearch(&indtile, 7, FindNearIndustryName, &sni)) {
|
||||
/* An industry has been found nearby */
|
||||
IndustryType indtype = GetIndustryType(indtile);
|
||||
@@ -299,14 +297,13 @@ static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming n
|
||||
}
|
||||
|
||||
/* Oil rigs/mines name could be marked not free by looking for a near by industry. */
|
||||
free_names = sni.free_names;
|
||||
|
||||
/* check default names */
|
||||
uint32 tmp = free_names & _gen_station_name_bits[name_class];
|
||||
uint32 tmp = sni.free_names & _gen_station_name_bits[name_class];
|
||||
if (tmp != 0) return STR_SV_STNAME + FindFirstBit(tmp);
|
||||
|
||||
/* check mine? */
|
||||
if (HasBit(free_names, M(STR_SV_STNAME_MINES))) {
|
||||
if (HasBit(sni.free_names, M(STR_SV_STNAME_MINES))) {
|
||||
if (CountMapSquareAround(tile, CMSAMine) >= 2) {
|
||||
return STR_SV_STNAME_MINES;
|
||||
}
|
||||
@@ -314,7 +311,7 @@ static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming n
|
||||
|
||||
/* check close enough to town to get central as name? */
|
||||
const bool is_central = DistanceMax(tile, t->xy) < 8;
|
||||
if (HasBit(free_names, M(STR_SV_STNAME)) && (is_central ||
|
||||
if (HasBit(sni.free_names, M(STR_SV_STNAME)) && (is_central ||
|
||||
DistanceSquare(tile, t->xy) <= std::max(t->cache.squared_town_zone_radius[HZB_TOWN_INNER_SUBURB], t->cache.squared_town_zone_radius[HZB_TOWN_OUTER_SUBURB]))) {
|
||||
return STR_SV_STNAME;
|
||||
}
|
||||
@@ -356,19 +353,19 @@ static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming n
|
||||
}
|
||||
|
||||
/* check close enough to town to get central as name? */
|
||||
if (is_central && HasBit(free_names, M(STR_SV_STNAME_CENTRAL))) {
|
||||
if (is_central && HasBit(sni.free_names, M(STR_SV_STNAME_CENTRAL))) {
|
||||
return STR_SV_STNAME_CENTRAL;
|
||||
}
|
||||
|
||||
/* Check lakeside */
|
||||
if (HasBit(free_names, M(STR_SV_STNAME_LAKESIDE)) &&
|
||||
if (HasBit(sni.free_names, M(STR_SV_STNAME_LAKESIDE)) &&
|
||||
DistanceFromEdge(tile) < 20 &&
|
||||
CountMapSquareAround(tile, CMSAWater) >= 5) {
|
||||
return STR_SV_STNAME_LAKESIDE;
|
||||
}
|
||||
|
||||
/* Check woods */
|
||||
if (HasBit(free_names, M(STR_SV_STNAME_WOODS)) && (
|
||||
if (HasBit(sni.free_names, M(STR_SV_STNAME_WOODS)) && (
|
||||
CountMapSquareAround(tile, CMSATree) >= 8 ||
|
||||
CountMapSquareAround(tile, IsTileForestIndustry) >= 2)
|
||||
) {
|
||||
@@ -379,9 +376,9 @@ static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming n
|
||||
int z = GetTileZ(tile);
|
||||
int z2 = GetTileZ(t->xy);
|
||||
if (z < z2) {
|
||||
if (HasBit(free_names, M(STR_SV_STNAME_VALLEY))) return STR_SV_STNAME_VALLEY;
|
||||
if (HasBit(sni.free_names, M(STR_SV_STNAME_VALLEY))) return STR_SV_STNAME_VALLEY;
|
||||
} else if (z > z2) {
|
||||
if (HasBit(free_names, M(STR_SV_STNAME_HEIGHTS))) return STR_SV_STNAME_HEIGHTS;
|
||||
if (HasBit(sni.free_names, M(STR_SV_STNAME_HEIGHTS))) return STR_SV_STNAME_HEIGHTS;
|
||||
}
|
||||
|
||||
/* check direction compared to town */
|
||||
@@ -392,12 +389,28 @@ static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming n
|
||||
~( (1 << M(STR_SV_STNAME_SOUTH)) | (1 << M(STR_SV_STNAME_WEST)) | (1 << M(STR_SV_STNAME_EAST)) ),
|
||||
};
|
||||
|
||||
free_names &= _direction_and_table[
|
||||
sni.free_names &= _direction_and_table[
|
||||
(TileX(tile) < TileX(t->xy)) +
|
||||
(TileY(tile) < TileY(t->xy)) * 2];
|
||||
|
||||
tmp = free_names & ((1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 6) | (1 << 7) | (1 << 12) | (1 << 26) | (1 << 27) | (1 << 28) | (1 << 29) | (1 << 30));
|
||||
if (tmp != 0) return STR_SV_STNAME + FindFirstBit(tmp);
|
||||
/** Bitmask of remaining station names that can be used when a more specific name has not been used. */
|
||||
static const uint32_t fallback_names = (
|
||||
(1U << M(STR_SV_STNAME_NORTH)) |
|
||||
(1U << M(STR_SV_STNAME_SOUTH)) |
|
||||
(1U << M(STR_SV_STNAME_EAST)) |
|
||||
(1U << M(STR_SV_STNAME_WEST)) |
|
||||
(1U << M(STR_SV_STNAME_TRANSFER)) |
|
||||
(1U << M(STR_SV_STNAME_HALT)) |
|
||||
(1U << M(STR_SV_STNAME_EXCHANGE)) |
|
||||
(1U << M(STR_SV_STNAME_ANNEXE)) |
|
||||
(1U << M(STR_SV_STNAME_SIDINGS)) |
|
||||
(1U << M(STR_SV_STNAME_BRANCH)) |
|
||||
(1U << M(STR_SV_STNAME_UPPER)) |
|
||||
(1U << M(STR_SV_STNAME_LOWER))
|
||||
);
|
||||
|
||||
sni.free_names &= fallback_names;
|
||||
if (sni.free_names != 0) return STR_SV_STNAME + FindFirstBit(sni.free_names);
|
||||
|
||||
if (check_extra_names()) return STR_SV_STNAME_FALLBACK;
|
||||
|
||||
@@ -556,7 +569,7 @@ void ClearAllStationCachedNames()
|
||||
* @param st Station to query
|
||||
* @return the expected mask
|
||||
*/
|
||||
static CargoTypes GetAcceptanceMask(const Station *st)
|
||||
CargoTypes GetAcceptanceMask(const Station *st)
|
||||
{
|
||||
CargoTypes mask = 0;
|
||||
|
||||
@@ -566,6 +579,21 @@ static CargoTypes GetAcceptanceMask(const Station *st)
|
||||
return mask;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a mask of the cargo types that are empty at the station.
|
||||
* @param st Station to query
|
||||
* @return the empty mask
|
||||
*/
|
||||
CargoTypes GetEmptyMask(const Station *st)
|
||||
{
|
||||
CargoTypes mask = 0;
|
||||
|
||||
for (CargoID i = 0; i < NUM_CARGO; i++) {
|
||||
if (st->goods[i].CargoTotalCount() == 0) SetBit(mask, i);
|
||||
}
|
||||
return mask;
|
||||
}
|
||||
|
||||
/**
|
||||
* Items contains the two cargo names that are to be accepted or rejected.
|
||||
* msg is the string id of the message to display.
|
||||
@@ -1272,10 +1300,9 @@ static CommandCost CheckFlatLandAirport(AirportTileTableIterator tile_iter, DoCo
|
||||
* Check whether we can expand the rail part of the given station.
|
||||
* @param st the station to expand
|
||||
* @param new_ta the current (and if all is fine new) tile area of the rail part of the station
|
||||
* @param axis the axis of the newly build rail
|
||||
* @return Succeeded or failed command.
|
||||
*/
|
||||
CommandCost CanExpandRailStation(const BaseStation *st, TileArea &new_ta, Axis axis)
|
||||
CommandCost CanExpandRailStation(const BaseStation *st, TileArea &new_ta)
|
||||
{
|
||||
TileArea cur_ta = st->train_station;
|
||||
|
||||
@@ -1563,7 +1590,7 @@ CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32
|
||||
if (ret.Failed()) return ret;
|
||||
|
||||
if (st != nullptr && st->train_station.tile != INVALID_TILE) {
|
||||
ret = CanExpandRailStation(st, new_location, axis);
|
||||
ret = CanExpandRailStation(st, new_location);
|
||||
if (ret.Failed()) return ret;
|
||||
}
|
||||
|
||||
@@ -3145,20 +3172,6 @@ void ClearDockingTilesCheckingNeighbours(TileIndex tile)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a dock tile can be docked from the given direction.
|
||||
* @param t Tile index of dock.
|
||||
* @param d DiagDirection adjacent to dock being tested. (unused)
|
||||
* @return True iff the dock can be docked from the given direction.
|
||||
*/
|
||||
bool IsValidDockingDirectionForDock(TileIndex t, DiagDirection d)
|
||||
{
|
||||
assert(IsDockTile(t));
|
||||
|
||||
StationGfx gfx = GetStationGfx(t);
|
||||
return gfx >= GFX_DOCK_BASE_WATER_PART;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the part of a dock that is land-based
|
||||
* @param t Dock tile to find land part of
|
||||
@@ -3376,7 +3389,7 @@ static void DrawTile_Station(TileInfo *ti, DrawTileProcParams params)
|
||||
gfx = GetAirportGfx(ti->tile);
|
||||
if (gfx >= NEW_AIRPORTTILE_OFFSET) {
|
||||
const AirportTileSpec *ats = AirportTileSpec::Get(gfx);
|
||||
if (ats->grf_prop.spritegroup[0] != nullptr && DrawNewAirportTile(ti, Station::GetByTile(ti->tile), gfx, ats)) {
|
||||
if (ats->grf_prop.spritegroup[0] != nullptr && DrawNewAirportTile(ti, Station::GetByTile(ti->tile), ats)) {
|
||||
return;
|
||||
}
|
||||
/* No sprite group (or no valid one) found, meaning no graphics associated.
|
||||
@@ -3690,12 +3703,12 @@ void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, Ro
|
||||
DrawRailTileSeqInGUI(x, y, t, (st == STATION_WAYPOINT || st == STATION_ROADWAYPOINT) ? 0 : total_offset, 0, pal);
|
||||
}
|
||||
|
||||
static int GetSlopePixelZ_Station(TileIndex tile, uint x, uint y, bool ground_vehicle)
|
||||
static int GetSlopePixelZ_Station(TileIndex tile, uint, uint, bool)
|
||||
{
|
||||
return GetTileMaxPixelZ(tile);
|
||||
}
|
||||
|
||||
static Foundation GetFoundation_Station(TileIndex tile, Slope tileh)
|
||||
static Foundation GetFoundation_Station(TileIndex, Slope tileh)
|
||||
{
|
||||
return FlatteningFoundation(tileh);
|
||||
}
|
||||
@@ -4899,7 +4912,7 @@ const StationList *StationFinder::GetStations()
|
||||
assert(this->w == 1 && this->h == 1);
|
||||
AddNearbyStationsByCatchment(this->tile, &this->stations, Town::GetByTile(this->tile)->stations_near);
|
||||
} else {
|
||||
ForAllStationsAroundTiles(*this, [this](Station *st, TileIndex tile) {
|
||||
ForAllStationsAroundTiles(*this, [this](Station *st, TileIndex) {
|
||||
this->stations.insert(st);
|
||||
return true;
|
||||
});
|
||||
|
Reference in New Issue
Block a user