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

Method StringToError

src/script/api/script_error.cpp:32–57  ·  view source on GitHub ↗

static */

Source from the content-addressed store, hash-verified

30}
31
32/* static */ ScriptErrorType ScriptError::StringToError(StringID internal_string_id)
33{
34 StringIndexInTab index = GetStringIndex(internal_string_id);
35 switch (GetStringTab(internal_string_id)) {
36 case TEXT_TAB_NEWGRF_START:
37 case TEXT_TAB_GAMESCRIPT_START:
38 return ERR_NEWGRF_SUPPLIED_ERROR; // NewGRF strings.
39
40 case TEXT_TAB_SPECIAL:
41 if (index < 0xE4) break; // Player name
42 [[fallthrough]];
43
44 case TEXT_TAB_TOWN:
45 if (index < 0xC0) break; // Town name
46 /* These strings are 'random' and have no meaning.
47 * They actually shouldn't even be returned as error messages. */
48 return ERR_UNKNOWN;
49
50 default:
51 break;
52 }
53
54 ScriptErrorMap::iterator it = error_map.find(internal_string_id);
55 if (it == error_map.end()) return ERR_UNKNOWN;
56 return it->second;
57}
58
59/* static */ void ScriptError::RegisterErrorMap(StringID internal_string_id, ScriptErrorType ai_error_msg)
60{

Callers

nothing calls this directly

Calls 4

GetStringIndexFunction · 0.85
GetStringTabFunction · 0.85
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected