MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / GetStringPtr

Function GetStringPtr

src/strings.cpp:313–326  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

311}
312
313std::string_view GetStringPtr(StringID string)
314{
315 switch (GetStringTab(string)) {
316 case TEXT_TAB_GAMESCRIPT_START: return GetGameStringPtr(GetStringIndex(string));
317 /* 0xD0xx and 0xD4xx IDs have been converted earlier. */
318 case TEXT_TAB_OLD_NEWGRF: NOT_REACHED();
319 case TEXT_TAB_NEWGRF_START: return GetGRFStringPtr(GetStringIndex(string));
320 default: {
321 const size_t offset = _langpack.langtab_start[GetStringTab(string)] + GetStringIndex(string).base();
322 if (offset < _langpack.strings.size()) return _langpack.strings[offset];
323 return "(undefined string)";
324 }
325 }
326}
327
328/**
329 * Get a parsed string with most special stringcodes replaced by the string parameters.

Callers 13

GetStringWithArgsFunction · 0.85
FormatYmdStringFunction · 0.85
FormatMonthAndYearFunction · 0.85
FormatTinyOrISODateFunction · 0.85
FormatGenericCurrencyFunction · 0.85
FormatStringFunction · 0.85
GetGRFStringPtrFunction · 0.85
ConDumpRoadTypesFunction · 0.85
ConDumpRailTypesFunction · 0.85
ConDumpCargoTypesFunction · 0.85

Calls 7

GetStringTabFunction · 0.85
GetGameStringPtrFunction · 0.85
GetStringIndexFunction · 0.85
NOT_REACHEDFunction · 0.85
GetGRFStringPtrFunction · 0.85
baseMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected