diff --git a/src/gamelog.cpp b/src/gamelog.cpp index 400c0d22fb..b21823c95b 100644 --- a/src/gamelog.cpp +++ b/src/gamelog.cpp @@ -415,7 +415,7 @@ void GamelogRevision() if (lc == NULL) return; memset(lc->revision.text, 0, sizeof(lc->revision.text)); - strecpy(lc->revision.text, _openttd_revision, lastof(lc->revision.text)); + strecpy(lc->revision.text, _openttd_revision, lastof(lc->revision.text), true); lc->revision.slver = SAVEGAME_VERSION; lc->revision.modified = _openttd_revision_modified; lc->revision.newgrf = _openttd_newgrf_version; diff --git a/src/string.cpp b/src/string.cpp index 1ceae6061b..677152ef1e 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -87,8 +87,7 @@ char *strecat(char *dst, const char *src, const char *last) * * Copies the source string to the destination buffer with respect of the * terminating null-character and the last pointer to the last element in - * the destination buffer. If the last pointer is set to NULL no boundary - * check is performed. + * the destination buffer. * * @note usage: strecpy(dst, src, lastof(dst)); * @note lastof() applies only to fixed size arrays @@ -96,9 +95,10 @@ char *strecat(char *dst, const char *src, const char *last) * @param dst The destination buffer * @param src The buffer containing the string to copy * @param last The pointer to the last element of the destination buffer + * @param quiet_mode If set to true, emitted warning for truncating the input string is emitted at level 1 instead of 0 * @return The pointer to the terminating null-character in the destination buffer */ -char *strecpy(char *dst, const char *src, const char *last) +char *strecpy(char *dst, const char *src, const char *last, bool quiet_mode) { assert(dst <= last); while (dst != last && *src != '\0') { @@ -110,7 +110,7 @@ char *strecpy(char *dst, const char *src, const char *last) #if defined(STRGEN) || defined(SETTINGSGEN) error("String too long for destination buffer"); #else /* STRGEN || SETTINGSGEN */ - DEBUG(misc, 0, "String too long for destination buffer"); + DEBUG(misc, quiet_mode ? 1 : 0, "String too long for destination buffer"); #endif /* STRGEN || SETTINGSGEN */ } return dst; diff --git a/src/string_func.h b/src/string_func.h index dd9b42600d..4bc401630b 100644 --- a/src/string_func.h +++ b/src/string_func.h @@ -32,7 +32,7 @@ #include "string_type.h" char *strecat(char *dst, const char *src, const char *last); -char *strecpy(char *dst, const char *src, const char *last); +char *strecpy(char *dst, const char *src, const char *last, bool quiet_mode = false); char *stredup(const char *src, const char *last = NULL); int CDECL seprintf(char *str, const char *last, const char *format, ...) WARN_FORMAT(3, 4);