Add GRF variable to use extra station names even when default names remain
This commit is contained in:
@@ -271,6 +271,12 @@ item (FEAT_GLOBALVARS) {
|
|||||||
</dl>
|
</dl>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr><td>extra_station_names_probability</td><td>0 .. 255</td>
|
||||||
|
<td>
|
||||||
|
Sets the probability that an extra station name is used even when the available default names have not been exhausted.<br />
|
||||||
|
Some station names are always used first even when this is non-zero.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<p>Syntax example:
|
<p>Syntax example:
|
||||||
<pre class="code">
|
<pre class="code">
|
||||||
|
@@ -315,6 +315,14 @@
|
|||||||
</table>
|
</table>
|
||||||
</p>
|
</p>
|
||||||
<p>This is indicated by the feature name: <font face="monospace">action0_global_extra_station_names</font>, version 1</p>
|
<p>This is indicated by the feature name: <font face="monospace">action0_global_extra_station_names</font>, version 1</p>
|
||||||
|
<h4 id="global_extra_station_names_probability">Extra station names probability (mappable property: global_extra_station_names_probability)</h4>
|
||||||
|
<p>This sets the probability of using an extra station name even when the available default names have not been exhausted.<br />
|
||||||
|
The range is 0 - 255, where 0 is never (the default) and 255 is always.<br />
|
||||||
|
Some station names are always used first even when this is non-zero.<br />
|
||||||
|
The Action 0 ID field is ignored.<br />
|
||||||
|
The property length is 1 bytes.
|
||||||
|
</p>
|
||||||
|
<p>This is indicated by the feature name: <font face="monospace">action0_global_extra_station_names</font>, version 2</p>
|
||||||
<h4 id="global_lighthouse_generate_amount">Lighthouse object map generation amount (mappable property: global_lighthouse_generate_amount)</h4>
|
<h4 id="global_lighthouse_generate_amount">Lighthouse object map generation amount (mappable property: global_lighthouse_generate_amount)</h4>
|
||||||
<p>This sets the map generation amount value for the lighthouse default object (0 is no generation, 255 is maximum).<br />
|
<p>This sets the map generation amount value for the lighthouse default object (0 is no generation, 255 is maximum).<br />
|
||||||
The Action 0 ID field is ignored. The property length is 1 byte.
|
The Action 0 ID field is ignored. The property length is 1 byte.
|
||||||
|
@@ -231,6 +231,9 @@ static void LoadSpriteTables()
|
|||||||
extern uint _extra_station_names_used;
|
extern uint _extra_station_names_used;
|
||||||
_extra_station_names_used = 0;
|
_extra_station_names_used = 0;
|
||||||
|
|
||||||
|
extern uint8 _extra_station_names_probability;
|
||||||
|
_extra_station_names_probability = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Load the base and extra NewGRF with OTTD required graphics as first NewGRF.
|
* Load the base and extra NewGRF with OTTD required graphics as first NewGRF.
|
||||||
* However, we do not want it to show up in the list of used NewGRFs,
|
* However, we do not want it to show up in the list of used NewGRFs,
|
||||||
|
@@ -97,6 +97,7 @@ void InitializeGame(uint size_x, uint size_y, bool reset_date, bool reset_settin
|
|||||||
_game_load_tick_skip_counter = 0;
|
_game_load_tick_skip_counter = 0;
|
||||||
_game_load_time = 0;
|
_game_load_time = 0;
|
||||||
_extra_station_names_used = 0;
|
_extra_station_names_used = 0;
|
||||||
|
_extra_station_names_probability = 0;
|
||||||
_extra_aspects = 0;
|
_extra_aspects = 0;
|
||||||
_loadgame_DBGL_data.clear();
|
_loadgame_DBGL_data.clear();
|
||||||
if (reset_settings) MakeNewgameSettingsLive();
|
if (reset_settings) MakeNewgameSettingsLive();
|
||||||
|
@@ -2919,6 +2919,12 @@ static ChangeInfoResult GlobalVarChangeInfo(uint gvid, int numinfo, int prop, co
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case A0RPI_GLOBALVAR_EXTRA_STATION_NAMES_PROBABILITY: {
|
||||||
|
if (MappedPropertyLengthMismatch(buf, 1, mapping_entry)) break;
|
||||||
|
_extra_station_names_probability = buf->ReadByte();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case A0RPI_GLOBALVAR_LIGHTHOUSE_GENERATE_AMOUNT:
|
case A0RPI_GLOBALVAR_LIGHTHOUSE_GENERATE_AMOUNT:
|
||||||
case A0RPI_GLOBALVAR_TRANSMITTER_GENERATE_AMOUNT: {
|
case A0RPI_GLOBALVAR_TRANSMITTER_GENERATE_AMOUNT: {
|
||||||
if (MappedPropertyLengthMismatch(buf, 1, mapping_entry)) break;
|
if (MappedPropertyLengthMismatch(buf, 1, mapping_entry)) break;
|
||||||
@@ -2997,6 +3003,7 @@ static ChangeInfoResult GlobalVarReserveInfo(uint gvid, int numinfo, int prop, c
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case A0RPI_GLOBALVAR_EXTRA_STATION_NAMES:
|
case A0RPI_GLOBALVAR_EXTRA_STATION_NAMES:
|
||||||
|
case A0RPI_GLOBALVAR_EXTRA_STATION_NAMES_PROBABILITY:
|
||||||
case A0RPI_GLOBALVAR_LIGHTHOUSE_GENERATE_AMOUNT:
|
case A0RPI_GLOBALVAR_LIGHTHOUSE_GENERATE_AMOUNT:
|
||||||
case A0RPI_GLOBALVAR_TRANSMITTER_GENERATE_AMOUNT:
|
case A0RPI_GLOBALVAR_TRANSMITTER_GENERATE_AMOUNT:
|
||||||
buf->Skip(buf->ReadExtendedByte());
|
buf->Skip(buf->ReadExtendedByte());
|
||||||
|
@@ -39,7 +39,7 @@ extern const GRFFeatureInfo _grf_feature_list[] = {
|
|||||||
GRFFeatureInfo("action0_railtype_recolour", 1),
|
GRFFeatureInfo("action0_railtype_recolour", 1),
|
||||||
GRFFeatureInfo("action0_railtype_extra_aspects", 1),
|
GRFFeatureInfo("action0_railtype_extra_aspects", 1),
|
||||||
GRFFeatureInfo("action0_roadtype_extra_flags", 1),
|
GRFFeatureInfo("action0_roadtype_extra_flags", 1),
|
||||||
GRFFeatureInfo("action0_global_extra_station_names", 1),
|
GRFFeatureInfo("action0_global_extra_station_names", 2),
|
||||||
GRFFeatureInfo("action0_global_default_object_generate_amount", 1),
|
GRFFeatureInfo("action0_global_default_object_generate_amount", 1),
|
||||||
GRFFeatureInfo("action0_signals_programmable_signals", 1),
|
GRFFeatureInfo("action0_signals_programmable_signals", 1),
|
||||||
GRFFeatureInfo("action0_signals_no_entry_signals", 1),
|
GRFFeatureInfo("action0_signals_no_entry_signals", 1),
|
||||||
@@ -78,6 +78,7 @@ extern const GRFPropertyMapDefinition _grf_action0_remappable_properties[] = {
|
|||||||
GRFPropertyMapDefinition(GSF_ROADTYPES, A0RPI_ROADTYPE_EXTRA_FLAGS, "roadtype_extra_flags"),
|
GRFPropertyMapDefinition(GSF_ROADTYPES, A0RPI_ROADTYPE_EXTRA_FLAGS, "roadtype_extra_flags"),
|
||||||
GRFPropertyMapDefinition(GSF_TRAMTYPES, A0RPI_ROADTYPE_EXTRA_FLAGS, "roadtype_extra_flags"),
|
GRFPropertyMapDefinition(GSF_TRAMTYPES, A0RPI_ROADTYPE_EXTRA_FLAGS, "roadtype_extra_flags"),
|
||||||
GRFPropertyMapDefinition(GSF_GLOBALVAR, A0RPI_GLOBALVAR_EXTRA_STATION_NAMES, "global_extra_station_names"),
|
GRFPropertyMapDefinition(GSF_GLOBALVAR, A0RPI_GLOBALVAR_EXTRA_STATION_NAMES, "global_extra_station_names"),
|
||||||
|
GRFPropertyMapDefinition(GSF_GLOBALVAR, A0RPI_GLOBALVAR_EXTRA_STATION_NAMES_PROBABILITY, "global_extra_station_names_probability"),
|
||||||
GRFPropertyMapDefinition(GSF_GLOBALVAR, A0RPI_GLOBALVAR_LIGHTHOUSE_GENERATE_AMOUNT, "global_lighthouse_generate_amount"),
|
GRFPropertyMapDefinition(GSF_GLOBALVAR, A0RPI_GLOBALVAR_LIGHTHOUSE_GENERATE_AMOUNT, "global_lighthouse_generate_amount"),
|
||||||
GRFPropertyMapDefinition(GSF_GLOBALVAR, A0RPI_GLOBALVAR_TRANSMITTER_GENERATE_AMOUNT, "global_transmitter_generate_amount"),
|
GRFPropertyMapDefinition(GSF_GLOBALVAR, A0RPI_GLOBALVAR_TRANSMITTER_GENERATE_AMOUNT, "global_transmitter_generate_amount"),
|
||||||
GRFPropertyMapDefinition(GSF_SIGNALS, A0RPI_SIGNALS_ENABLE_PROGRAMMABLE_SIGNALS, "signals_enable_programmable_signals"),
|
GRFPropertyMapDefinition(GSF_SIGNALS, A0RPI_SIGNALS_ENABLE_PROGRAMMABLE_SIGNALS, "signals_enable_programmable_signals"),
|
||||||
|
@@ -27,6 +27,7 @@ enum Action0RemapPropertyIds {
|
|||||||
A0RPI_RAILTYPE_EXTRA_ASPECTS,
|
A0RPI_RAILTYPE_EXTRA_ASPECTS,
|
||||||
A0RPI_ROADTYPE_EXTRA_FLAGS,
|
A0RPI_ROADTYPE_EXTRA_FLAGS,
|
||||||
A0RPI_GLOBALVAR_EXTRA_STATION_NAMES,
|
A0RPI_GLOBALVAR_EXTRA_STATION_NAMES,
|
||||||
|
A0RPI_GLOBALVAR_EXTRA_STATION_NAMES_PROBABILITY,
|
||||||
A0RPI_GLOBALVAR_LIGHTHOUSE_GENERATE_AMOUNT,
|
A0RPI_GLOBALVAR_LIGHTHOUSE_GENERATE_AMOUNT,
|
||||||
A0RPI_GLOBALVAR_TRANSMITTER_GENERATE_AMOUNT,
|
A0RPI_GLOBALVAR_TRANSMITTER_GENERATE_AMOUNT,
|
||||||
A0RPI_SIGNALS_ENABLE_PROGRAMMABLE_SIGNALS,
|
A0RPI_SIGNALS_ENABLE_PROGRAMMABLE_SIGNALS,
|
||||||
|
@@ -471,6 +471,7 @@ static void ShutdownGame()
|
|||||||
_game_load_tick_skip_counter = 0;
|
_game_load_tick_skip_counter = 0;
|
||||||
_game_load_time = 0;
|
_game_load_time = 0;
|
||||||
_extra_station_names_used = 0;
|
_extra_station_names_used = 0;
|
||||||
|
_extra_station_names_probability = 0;
|
||||||
_extra_aspects = 0;
|
_extra_aspects = 0;
|
||||||
_loadgame_DBGL_data.clear();
|
_loadgame_DBGL_data.clear();
|
||||||
_loadgame_DBGC_data.clear();
|
_loadgame_DBGC_data.clear();
|
||||||
|
@@ -40,6 +40,7 @@ INSTANTIATE_POOL_METHODS(Station)
|
|||||||
|
|
||||||
std::array<ExtraStationNameInfo, MAX_EXTRA_STATION_NAMES> _extra_station_names;
|
std::array<ExtraStationNameInfo, MAX_EXTRA_STATION_NAMES> _extra_station_names;
|
||||||
uint _extra_station_names_used;
|
uint _extra_station_names_used;
|
||||||
|
uint8 _extra_station_names_probability;
|
||||||
|
|
||||||
|
|
||||||
StationKdtree _station_kdtree(Kdtree_StationXYFunc);
|
StationKdtree _station_kdtree(Kdtree_StationXYFunc);
|
||||||
|
@@ -50,6 +50,7 @@ struct ExtraStationNameInfo {
|
|||||||
|
|
||||||
extern std::array<ExtraStationNameInfo, MAX_EXTRA_STATION_NAMES> _extra_station_names;
|
extern std::array<ExtraStationNameInfo, MAX_EXTRA_STATION_NAMES> _extra_station_names;
|
||||||
extern uint _extra_station_names_used;
|
extern uint _extra_station_names_used;
|
||||||
|
extern uint8 _extra_station_names_probability;
|
||||||
|
|
||||||
class FlowStatMap;
|
class FlowStatMap;
|
||||||
|
|
||||||
|
@@ -317,6 +317,42 @@ static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming n
|
|||||||
return STR_SV_STNAME_CENTRAL;
|
return STR_SV_STNAME_CENTRAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool use_extra_names = _extra_station_names_used > 0;
|
||||||
|
auto check_extra_names = [&]() -> bool {
|
||||||
|
if (use_extra_names) {
|
||||||
|
use_extra_names = false;
|
||||||
|
const bool near_water = CountMapSquareAround(tile, CMSAWater) >= 5;
|
||||||
|
std::vector<uint16> candidates;
|
||||||
|
for (uint i = 0; i < _extra_station_names_used; i++) {
|
||||||
|
const ExtraStationNameInfo &info = _extra_station_names[i];
|
||||||
|
if (extra_names[i]) continue;
|
||||||
|
if (!HasBit(info.flags, name_class)) continue;
|
||||||
|
if (HasBit(info.flags, ESNIF_CENTRAL) && !is_central) continue;
|
||||||
|
if (HasBit(info.flags, ESNIF_NOT_CENTRAL) && is_central) continue;
|
||||||
|
if (HasBit(info.flags, ESNIF_NEAR_WATER) && !near_water) continue;
|
||||||
|
if (HasBit(info.flags, ESNIF_NOT_NEAR_WATER) && near_water) continue;
|
||||||
|
candidates.push_back(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!candidates.empty()) {
|
||||||
|
SavedRandomSeeds saved_seeds;
|
||||||
|
SaveRandomSeeds(&saved_seeds);
|
||||||
|
st->extra_name_index = candidates[RandomRange((uint)candidates.size())];
|
||||||
|
RestoreRandomSeeds(saved_seeds);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (_extra_station_names_probability > 0) {
|
||||||
|
SavedRandomSeeds saved_seeds;
|
||||||
|
SaveRandomSeeds(&saved_seeds);
|
||||||
|
bool extra_name = (RandomRange(0xFF) < _extra_station_names_probability) && check_extra_names();
|
||||||
|
RestoreRandomSeeds(saved_seeds);
|
||||||
|
if (extra_name) return STR_SV_STNAME_FALLBACK;
|
||||||
|
}
|
||||||
|
|
||||||
/* Check lakeside */
|
/* Check lakeside */
|
||||||
if (HasBit(free_names, M(STR_SV_STNAME_LAKESIDE)) &&
|
if (HasBit(free_names, M(STR_SV_STNAME_LAKESIDE)) &&
|
||||||
DistanceFromEdge(tile) < 20 &&
|
DistanceFromEdge(tile) < 20 &&
|
||||||
@@ -356,28 +392,7 @@ static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming n
|
|||||||
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));
|
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);
|
if (tmp != 0) return STR_SV_STNAME + FindFirstBit(tmp);
|
||||||
|
|
||||||
if (_extra_station_names_used > 0) {
|
if (check_extra_names()) return STR_SV_STNAME_FALLBACK;
|
||||||
const bool near_water = CountMapSquareAround(tile, CMSAWater) >= 5;
|
|
||||||
std::vector<uint16> candidates;
|
|
||||||
for (uint i = 0; i < _extra_station_names_used; i++) {
|
|
||||||
const ExtraStationNameInfo &info = _extra_station_names[i];
|
|
||||||
if (extra_names[i]) continue;
|
|
||||||
if (!HasBit(info.flags, name_class)) continue;
|
|
||||||
if (HasBit(info.flags, ESNIF_CENTRAL) && !is_central) continue;
|
|
||||||
if (HasBit(info.flags, ESNIF_NOT_CENTRAL) && is_central) continue;
|
|
||||||
if (HasBit(info.flags, ESNIF_NEAR_WATER) && !near_water) continue;
|
|
||||||
if (HasBit(info.flags, ESNIF_NOT_NEAR_WATER) && near_water) continue;
|
|
||||||
candidates.push_back(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!candidates.empty()) {
|
|
||||||
SavedRandomSeeds saved_seeds;
|
|
||||||
SaveRandomSeeds(&saved_seeds);
|
|
||||||
st->extra_name_index = candidates[RandomRange((uint)candidates.size())];
|
|
||||||
RestoreRandomSeeds(saved_seeds);
|
|
||||||
return STR_SV_STNAME_FALLBACK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return STR_SV_STNAME_FALLBACK;
|
return STR_SV_STNAME_FALLBACK;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user