1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-16 02:59:10 +00:00

Change: Don't handle 'missing' string parameters as 0.

If not enough parameters are supplied for a string, then a value of 0 was used, which could result in incorrect information being displayed.

Instead, throw an exception and include an error in the string.
This commit is contained in:
2024-01-03 03:03:14 +00:00
parent 5db9266f4b
commit def4fcdf3a
2 changed files with 731 additions and 729 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -95,7 +95,7 @@ public:
T GetNextParameter() T GetNextParameter()
{ {
auto ptr = GetNextParameterPointer(); auto ptr = GetNextParameterPointer();
return static_cast<T>(ptr == nullptr ? 0 : ptr->data); return static_cast<T>(ptr->data);
} }
/** /**
@@ -107,7 +107,6 @@ public:
const char *GetNextParameterString() const char *GetNextParameterString()
{ {
auto ptr = GetNextParameterPointer(); auto ptr = GetNextParameterPointer();
if (ptr == nullptr) return nullptr;
return ptr->string != nullptr ? ptr->string->c_str() : ptr->string_view; return ptr->string != nullptr ? ptr->string->c_str() : ptr->string_view;
} }