diff options
author | rubidium42 <rubidium@openttd.org> | 2021-05-30 11:40:54 +0200 |
---|---|---|
committer | rubidium42 <rubidium42@users.noreply.github.com> | 2021-06-13 10:26:58 +0200 |
commit | e588923bff12e0c46aaab72fdca3e8b5cb211081 (patch) | |
tree | 0388d8f8f4f4e4564d2b44e0300032c1327037ce /src | |
parent | ca9c50607eeca1657f7da4a06fe4486574e97139 (diff) | |
download | openttd-e588923bff12e0c46aaab72fdca3e8b5cb211081.tar.xz |
Codechange: add std::string accepting SetDParamStr to ErrorMessageData
Diffstat (limited to 'src')
-rw-r--r-- | src/error.h | 1 | ||||
-rw-r--r-- | src/error_gui.cpp | 10 | ||||
-rw-r--r-- | src/newgrf_debug_gui.cpp | 2 | ||||
-rw-r--r-- | src/openttd.cpp | 6 | ||||
-rw-r--r-- | src/spriteloader/grf.cpp | 2 |
5 files changed, 16 insertions, 5 deletions
diff --git a/src/error.h b/src/error.h index 9c445fc48..06440c127 100644 --- a/src/error.h +++ b/src/error.h @@ -52,6 +52,7 @@ public: void SetDParam(uint n, uint64 v); void SetDParamStr(uint n, const char *str); + void SetDParamStr(uint n, const std::string &str); void CopyOutDParams(); }; diff --git a/src/error_gui.cpp b/src/error_gui.cpp index 70b403a68..06c0c44e0 100644 --- a/src/error_gui.cpp +++ b/src/error_gui.cpp @@ -164,6 +164,16 @@ void ErrorMessageData::SetDParamStr(uint n, const char *str) this->strings[n] = stredup(str); } +/** + * Set a rawstring parameter. + * @param n Parameter index + * @param str Raw string + */ +void ErrorMessageData::SetDParamStr(uint n, const std::string &str) +{ + this->SetDParamStr(n, str.c_str()); +} + /** Define a queue with errors. */ typedef std::list<ErrorMessageData> ErrorList; /** The actual queue with errors. */ diff --git a/src/newgrf_debug_gui.cpp b/src/newgrf_debug_gui.cpp index 9453f5de9..ec221e2f3 100644 --- a/src/newgrf_debug_gui.cpp +++ b/src/newgrf_debug_gui.cpp @@ -828,7 +828,7 @@ struct SpriteAlignerWindow : Window { switch (widget) { case WID_SA_CAPTION: SetDParam(0, this->current_sprite); - SetDParamStr(1, GetOriginFile(this->current_sprite)->GetSimplifiedFilename().c_str()); + SetDParamStr(1, GetOriginFile(this->current_sprite)->GetSimplifiedFilename()); break; case WID_SA_OFFSETS_ABS: diff --git a/src/openttd.cpp b/src/openttd.cpp index fcd8fcd34..7800fba84 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -707,7 +707,7 @@ int openttd_main(int argc, char *argv[]) BaseGraphics::SetSet({}); ErrorMessageData msg(STR_CONFIG_ERROR, STR_CONFIG_ERROR_INVALID_BASE_GRAPHICS_NOT_FOUND); - msg.SetDParamStr(0, graphics_set.c_str()); + msg.SetDParamStr(0, graphics_set); ScheduleErrorMessage(msg); } } @@ -766,7 +766,7 @@ int openttd_main(int argc, char *argv[]) usererror("Failed to find a sounds set. Please acquire a sounds set for OpenTTD. See section 1.4 of README.md."); } else { ErrorMessageData msg(STR_CONFIG_ERROR, STR_CONFIG_ERROR_INVALID_BASE_SOUNDS_NOT_FOUND); - msg.SetDParamStr(0, sounds_set.c_str()); + msg.SetDParamStr(0, sounds_set); ScheduleErrorMessage(msg); } } @@ -778,7 +778,7 @@ int openttd_main(int argc, char *argv[]) usererror("Failed to find a music set. Please acquire a music set for OpenTTD. See section 1.4 of README.md."); } else { ErrorMessageData msg(STR_CONFIG_ERROR, STR_CONFIG_ERROR_INVALID_BASE_MUSIC_NOT_FOUND); - msg.SetDParamStr(0, music_set.c_str()); + msg.SetDParamStr(0, music_set); ScheduleErrorMessage(msg); } } diff --git a/src/spriteloader/grf.cpp b/src/spriteloader/grf.cpp index fae87b87f..5a49a0c8a 100644 --- a/src/spriteloader/grf.cpp +++ b/src/spriteloader/grf.cpp @@ -35,7 +35,7 @@ static bool WarnCorruptSprite(const SpriteFile &file, size_t file_pos, int line) { static byte warning_level = 0; if (warning_level == 0) { - SetDParamStr(0, file.GetSimplifiedFilename().c_str()); + SetDParamStr(0, file.GetSimplifiedFilename()); ShowErrorMessage(STR_NEWGRF_ERROR_CORRUPT_SPRITE, INVALID_STRING_ID, WL_ERROR); } DEBUG(sprite, warning_level, "[%i] Loading corrupted sprite from %s at position %i", line, file.GetSimplifiedFilename().c_str(), (int)file_pos); |