|
|
|
@ -46,6 +46,8 @@
|
|
|
|
|
#include "settings_type.h"
|
|
|
|
|
#include "map_func.h"
|
|
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
|
|
#include "table/strings.h"
|
|
|
|
|
#include "table/sprites.h"
|
|
|
|
|
#include "table/town_land.h"
|
|
|
|
@ -225,6 +227,9 @@ static GRFFile *GetFileByFilename(const char *filename)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef std::map<StringID *, uint32> StringIDToGRFIDMapping;
|
|
|
|
|
StringIDToGRFIDMapping _string_to_grf_mapping;
|
|
|
|
|
|
|
|
|
|
/** Used when setting an object's property to map to the GRF's strings
|
|
|
|
|
* while taking in consideration the "drift" between TTDPatch string system and OpenTTD's one
|
|
|
|
|
* @param grfid Id of the grf file
|
|
|
|
@ -1387,7 +1392,8 @@ static bool TownHouseChangeInfo(uint hid, int numinfo, int prop, byte **bufp, in
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 0x12: // Building name ID
|
|
|
|
|
housespec->building_name = GRFMappedStringID(grf_load_word(&buf), _cur_grffile->grfid);
|
|
|
|
|
housespec->building_name = grf_load_word(&buf);
|
|
|
|
|
_string_to_grf_mapping[&housespec->building_name] = _cur_grffile->grfid;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 0x13: // Building availability mask
|
|
|
|
@ -1630,25 +1636,30 @@ static bool CargoChangeInfo(uint cid, int numinfo, int prop, byte **bufp, int le
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 0x09: /* String ID for cargo type name */
|
|
|
|
|
cs->name = GRFMappedStringID(grf_load_word(&buf), _cur_grffile->grfid);
|
|
|
|
|
cs->name = grf_load_word(&buf);
|
|
|
|
|
_string_to_grf_mapping[&cs->name] = _cur_grffile->grfid;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 0x0A: /* String for 1 unit of cargo */
|
|
|
|
|
cs->name_single = GRFMappedStringID(grf_load_word(&buf), _cur_grffile->grfid);
|
|
|
|
|
cs->name_single = grf_load_word(&buf);
|
|
|
|
|
_string_to_grf_mapping[&cs->name_single] = _cur_grffile->grfid;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 0x0B:
|
|
|
|
|
/* String for units of cargo. This is different in OpenTTD to TTDPatch
|
|
|
|
|
* (e.g. 10 tonnes of coal) */
|
|
|
|
|
cs->units_volume = GRFMappedStringID(grf_load_word(&buf), _cur_grffile->grfid);
|
|
|
|
|
cs->units_volume = grf_load_word(&buf);
|
|
|
|
|
_string_to_grf_mapping[&cs->units_volume] = _cur_grffile->grfid;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 0x0C: /* String for quantity of cargo (e.g. 10 tonnes of coal) */
|
|
|
|
|
cs->quantifier = GRFMappedStringID(grf_load_word(&buf), _cur_grffile->grfid);
|
|
|
|
|
cs->quantifier = grf_load_word(&buf);
|
|
|
|
|
_string_to_grf_mapping[&cs->quantifier] = _cur_grffile->grfid;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 0x0D: /* String for two letter cargo abbreviation */
|
|
|
|
|
cs->abbrev = GRFMappedStringID(grf_load_word(&buf), _cur_grffile->grfid);
|
|
|
|
|
cs->abbrev = grf_load_word(&buf);
|
|
|
|
|
_string_to_grf_mapping[&cs->abbrev] = _cur_grffile->grfid;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 0x0E: /* Sprite ID for cargo icon */
|
|
|
|
@ -2032,15 +2043,18 @@ static bool IndustriesChangeInfo(uint indid, int numinfo, int prop, byte **bufp,
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 0x0C: // Industry closure message
|
|
|
|
|
indsp->closure_text = GRFMappedStringID(grf_load_word(&buf), _cur_grffile->grfid);
|
|
|
|
|
indsp->closure_text = grf_load_word(&buf);
|
|
|
|
|
_string_to_grf_mapping[&indsp->closure_text] = _cur_grffile->grfid;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 0x0D: // Production increase message
|
|
|
|
|
indsp->production_up_text = GRFMappedStringID(grf_load_word(&buf), _cur_grffile->grfid);
|
|
|
|
|
indsp->production_up_text = grf_load_word(&buf);
|
|
|
|
|
_string_to_grf_mapping[&indsp->production_up_text] = _cur_grffile->grfid;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 0x0E: // Production decrease message
|
|
|
|
|
indsp->production_down_text = GRFMappedStringID(grf_load_word(&buf), _cur_grffile->grfid);
|
|
|
|
|
indsp->production_down_text = grf_load_word(&buf);
|
|
|
|
|
_string_to_grf_mapping[&indsp->production_down_text] = _cur_grffile->grfid;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 0x0F: // Fund cost multiplier
|
|
|
|
@ -2099,7 +2113,8 @@ static bool IndustriesChangeInfo(uint indid, int numinfo, int prop, byte **bufp,
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 0x1B: // New industry text ID
|
|
|
|
|
indsp->new_industry_text = GRFMappedStringID(grf_load_word(&buf), _cur_grffile->grfid);
|
|
|
|
|
indsp->new_industry_text = grf_load_word(&buf);
|
|
|
|
|
_string_to_grf_mapping[&indsp->new_industry_text] = _cur_grffile->grfid;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 0x1C: // Input cargo multipliers for the three input cargo types
|
|
|
|
@ -2111,7 +2126,8 @@ static bool IndustriesChangeInfo(uint indid, int numinfo, int prop, byte **bufp,
|
|
|
|
|
} break;
|
|
|
|
|
|
|
|
|
|
case 0x1F: // Industry name
|
|
|
|
|
indsp->name = GRFMappedStringID(grf_load_word(&buf), _cur_grffile->grfid);
|
|
|
|
|
indsp->name = grf_load_word(&buf);
|
|
|
|
|
_string_to_grf_mapping[&indsp->name] = _cur_grffile->grfid;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 0x20: // Prospecting success chance
|
|
|
|
@ -2129,7 +2145,8 @@ static bool IndustriesChangeInfo(uint indid, int numinfo, int prop, byte **bufp,
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 0x24: // name for nearby station
|
|
|
|
|
indsp->station_name = GRFMappedStringID(grf_load_word(&buf), _cur_grffile->grfid);
|
|
|
|
|
indsp->station_name = grf_load_word(&buf);
|
|
|
|
|
_string_to_grf_mapping[&indsp->station_name] = _cur_grffile->grfid;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
@ -3254,7 +3271,7 @@ static void FeatureNewName(byte *buf, int len)
|
|
|
|
|
if (_cur_grffile->housespec == NULL || _cur_grffile->housespec[GB(id, 0, 8)] == NULL) {
|
|
|
|
|
grfmsg(1, "FeatureNewName: Attempt to name undefined house 0x%X, ignoring.", GB(id, 0, 8));
|
|
|
|
|
} else {
|
|
|
|
|
_cur_grffile->housespec[GB(id, 0, 8)]->building_name = GRFMappedStringID(AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED), 0);
|
|
|
|
|
_cur_grffile->housespec[GB(id, 0, 8)]->building_name = AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
@ -5487,7 +5504,6 @@ static void FinaliseHouseArray()
|
|
|
|
|
for (int i = 0; i < HOUSE_MAX; i++) {
|
|
|
|
|
HouseSpec *hs = file->housespec[i];
|
|
|
|
|
if (hs != NULL) {
|
|
|
|
|
hs->building_name.MapString();
|
|
|
|
|
_house_mngr.SetEntitySpec(hs);
|
|
|
|
|
if (hs->min_date < min_date) min_date = hs->min_date;
|
|
|
|
|
}
|
|
|
|
@ -5518,27 +5534,21 @@ static void FinaliseIndustriesArray()
|
|
|
|
|
/* process the conversion of text at the end, so to be sure everything will be fine
|
|
|
|
|
* and available. Check if it does not return undefind marker, which is a very good sign of a
|
|
|
|
|
* substitute industry who has not changed the string been examined, thus using it as such */
|
|
|
|
|
indsp->name.MapString();
|
|
|
|
|
strid = GetGRFStringID(indsp->grf_prop.grffile->grfid, indsp->name);
|
|
|
|
|
if (strid != STR_UNDEFINED) indsp->name = strid;
|
|
|
|
|
|
|
|
|
|
indsp->closure_text.MapString();
|
|
|
|
|
strid = GetGRFStringID(indsp->grf_prop.grffile->grfid, indsp->closure_text);
|
|
|
|
|
if (strid != STR_UNDEFINED) indsp->closure_text = strid;
|
|
|
|
|
|
|
|
|
|
indsp->production_up_text.MapString();
|
|
|
|
|
strid = GetGRFStringID(indsp->grf_prop.grffile->grfid, indsp->production_up_text);
|
|
|
|
|
if (strid != STR_UNDEFINED) indsp->production_up_text = strid;
|
|
|
|
|
|
|
|
|
|
indsp->production_down_text.MapString();
|
|
|
|
|
strid = GetGRFStringID(indsp->grf_prop.grffile->grfid, indsp->production_down_text);
|
|
|
|
|
if (strid != STR_UNDEFINED) indsp->production_down_text = strid;
|
|
|
|
|
|
|
|
|
|
indsp->new_industry_text.MapString();
|
|
|
|
|
strid = GetGRFStringID(indsp->grf_prop.grffile->grfid, indsp->new_industry_text);
|
|
|
|
|
if (strid != STR_UNDEFINED) indsp->new_industry_text = strid;
|
|
|
|
|
|
|
|
|
|
indsp->station_name.MapString();
|
|
|
|
|
if (indsp->station_name != STR_NULL) {
|
|
|
|
|
/* STR_NULL (0) can be set by grf. It has a meaning regarding assignation of the
|
|
|
|
|
* station's name. Don't wont to loose the value, therefor, do not process. */
|
|
|
|
@ -5581,12 +5591,6 @@ static void MapNewCargoStrings()
|
|
|
|
|
CargoSpec *cs = &_cargo[c];
|
|
|
|
|
/* Don't map if the cargo is unavailable or not from NewGRF */
|
|
|
|
|
if (cs->grfid == 0) continue;
|
|
|
|
|
|
|
|
|
|
cs->name.MapString();
|
|
|
|
|
cs->name_single.MapString();
|
|
|
|
|
cs->units_volume.MapString();
|
|
|
|
|
cs->quantifier.MapString();
|
|
|
|
|
cs->abbrev.MapString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -5811,6 +5815,11 @@ extern void InitGRFTownGeneratorNames();
|
|
|
|
|
|
|
|
|
|
static void AfterLoadGRFs()
|
|
|
|
|
{
|
|
|
|
|
for (StringIDToGRFIDMapping::iterator it = _string_to_grf_mapping.begin(); it != _string_to_grf_mapping.end(); it++) {
|
|
|
|
|
*((*it).first) = MapGRFStringID((*it).second, *((*it).first));
|
|
|
|
|
}
|
|
|
|
|
_string_to_grf_mapping.clear();
|
|
|
|
|
|
|
|
|
|
/* Update the bitmasks for the vehicle lists */
|
|
|
|
|
Player *p;
|
|
|
|
|
FOR_ALL_PLAYERS(p) {
|
|
|
|
@ -5903,11 +5912,3 @@ bool HasGrfMiscBit(GrfMiscBit bit)
|
|
|
|
|
{
|
|
|
|
|
return HasBit(_misc_grf_features, bit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GRFMappedStringID::MapString()
|
|
|
|
|
{
|
|
|
|
|
if (this->grfid == 0) return;
|
|
|
|
|
|
|
|
|
|
this->string = MapGRFStringID(this->grfid, this->string);
|
|
|
|
|
this->grfid = 0;
|
|
|
|
|
}
|
|
|
|
|