|
|
|
@ -137,7 +137,7 @@ struct UnmappedChoiceList {
|
|
|
|
|
if (this->strings.find(0) == this->strings.end()) {
|
|
|
|
|
/* In case of a (broken) NewGRF without a default,
|
|
|
|
|
* assume an empty string. */
|
|
|
|
|
grfmsg(1, "choice list misses default value");
|
|
|
|
|
GrfMsg(1, "choice list misses default value");
|
|
|
|
|
this->strings[0] = std::stringstream();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -211,7 +211,7 @@ struct UnmappedChoiceList {
|
|
|
|
|
int idx = (this->type == SCC_GENDER_LIST ? lm->GetReverseMapping(i, true) : i + 1);
|
|
|
|
|
const auto &str = this->strings[this->strings.find(idx) != this->strings.end() ? idx : 0].str();
|
|
|
|
|
size_t len = str.size() + 1;
|
|
|
|
|
if (len > 0xFF) grfmsg(1, "choice list string is too long");
|
|
|
|
|
if (len > 0xFF) GrfMsg(1, "choice list string is too long");
|
|
|
|
|
*d++ = GB(len, 0, 8);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -290,7 +290,7 @@ std::string TranslateTTDPatchCodes(uint32 grfid, uint8 language_id, bool allow_n
|
|
|
|
|
if (allow_newlines) {
|
|
|
|
|
*d++ = 0x0A;
|
|
|
|
|
} else {
|
|
|
|
|
grfmsg(1, "Detected newline in string that does not allow one");
|
|
|
|
|
GrfMsg(1, "Detected newline in string that does not allow one");
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 0x0E: Utf8Encode(d, SCC_TINYFONT); break;
|
|
|
|
@ -392,12 +392,12 @@ std::string TranslateTTDPatchCodes(uint32 grfid, uint8 language_id, bool allow_n
|
|
|
|
|
if (str[0] == '\0') goto string_end;
|
|
|
|
|
if (mapping == nullptr) {
|
|
|
|
|
if (code == 0x10) src++; // Skip the index
|
|
|
|
|
grfmsg(1, "choice list %s marker found when not expected", code == 0x10 ? "next" : "default");
|
|
|
|
|
GrfMsg(1, "choice list {} marker found when not expected", code == 0x10 ? "next" : "default");
|
|
|
|
|
break;
|
|
|
|
|
} else {
|
|
|
|
|
int index = (code == 0x10 ? *src++ : 0);
|
|
|
|
|
if (mapping->strings.find(index) != mapping->strings.end()) {
|
|
|
|
|
grfmsg(1, "duplicate choice list string, ignoring");
|
|
|
|
|
GrfMsg(1, "duplicate choice list string, ignoring");
|
|
|
|
|
} else {
|
|
|
|
|
d = std::ostreambuf_iterator<char>(mapping->strings[index]);
|
|
|
|
|
}
|
|
|
|
@ -406,7 +406,7 @@ std::string TranslateTTDPatchCodes(uint32 grfid, uint8 language_id, bool allow_n
|
|
|
|
|
|
|
|
|
|
case 0x12:
|
|
|
|
|
if (mapping == nullptr) {
|
|
|
|
|
grfmsg(1, "choice list end marker found when not expected");
|
|
|
|
|
GrfMsg(1, "choice list end marker found when not expected");
|
|
|
|
|
} else {
|
|
|
|
|
/* Now we can start flushing everything and clean everything up. */
|
|
|
|
|
mapping->Flush(LanguageMap::GetLanguageMap(grfid, language_id), dest);
|
|
|
|
@ -422,7 +422,7 @@ std::string TranslateTTDPatchCodes(uint32 grfid, uint8 language_id, bool allow_n
|
|
|
|
|
case 0x15:
|
|
|
|
|
if (src[0] == '\0') goto string_end;
|
|
|
|
|
if (mapping != nullptr) {
|
|
|
|
|
grfmsg(1, "choice lists can't be stacked, it's going to get messy now...");
|
|
|
|
|
GrfMsg(1, "choice lists can't be stacked, it's going to get messy now...");
|
|
|
|
|
if (code != 0x14) src++;
|
|
|
|
|
} else {
|
|
|
|
|
static const StringControlCode mp[] = { SCC_GENDER_LIST, SCC_SWITCH_CASE, SCC_PLURAL_LIST };
|
|
|
|
@ -446,7 +446,7 @@ std::string TranslateTTDPatchCodes(uint32 grfid, uint8 language_id, bool allow_n
|
|
|
|
|
case 0x20: Utf8Encode(d, SCC_POP_COLOUR); break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
grfmsg(1, "missing handler for extended format code");
|
|
|
|
|
GrfMsg(1, "missing handler for extended format code");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
@ -477,7 +477,7 @@ std::string TranslateTTDPatchCodes(uint32 grfid, uint8 language_id, bool allow_n
|
|
|
|
|
|
|
|
|
|
string_end:
|
|
|
|
|
if (mapping != nullptr) {
|
|
|
|
|
grfmsg(1, "choice list was incomplete, the whole list is ignored");
|
|
|
|
|
GrfMsg(1, "choice list was incomplete, the whole list is ignored");
|
|
|
|
|
delete mapping;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -590,7 +590,7 @@ StringID AddGRFString(uint32 grfid, uint16 stringid, byte langid_to_add, bool ne
|
|
|
|
|
}
|
|
|
|
|
AddGRFTextToList(_grf_text[id].textholder, langid_to_add, newtext);
|
|
|
|
|
|
|
|
|
|
grfmsg(3, "Added 0x%X: grfid %08X string 0x%X lang 0x%X string '%s' (%X)", id, grfid, stringid, langid_to_add, newtext.c_str(), MakeStringID(TEXT_TAB_NEWGRF_START, id));
|
|
|
|
|
GrfMsg(3, "Added {:#X} grfid {:08X} string {:#X} lang {:#X} string '{}' ({:X})", id, grfid, stringid, langid_to_add, newtext.c_str(), MakeStringID(TEXT_TAB_NEWGRF_START, id));
|
|
|
|
|
|
|
|
|
|
return MakeStringID(TEXT_TAB_NEWGRF_START, id);
|
|
|
|
|
}
|
|
|
|
|