summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/saveload/saveload.cpp4
-rw-r--r--src/saveload/saveload.h3
-rw-r--r--src/script/api/script_gamesettings.cpp2
-rw-r--r--src/settings.cpp68
-rw-r--r--src/settings_internal.h1
-rw-r--r--src/table/settings.h.preamble6
6 files changed, 5 insertions, 79 deletions
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index 504df30ab..34982ecfe 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -585,7 +585,6 @@ static inline uint SlCalcConvMemLen(VarType conv)
switch (length << 4) {
case SLE_VAR_STRB:
- case SLE_VAR_STRBQ:
case SLE_VAR_STR:
case SLE_VAR_STRQ:
return SlReadArrayLength();
@@ -881,7 +880,6 @@ static inline size_t SlCalcStringLen(const void *ptr, size_t length, VarType con
len = SIZE_MAX;
break;
case SLE_VAR_STRB:
- case SLE_VAR_STRBQ:
str = (const char *)ptr;
len = length;
break;
@@ -920,7 +918,6 @@ static void SlString(void *ptr, size_t length, VarType conv)
switch (GetVarMemType(conv)) {
default: NOT_REACHED();
case SLE_VAR_STRB:
- case SLE_VAR_STRBQ:
len = SlCalcNetStringLen((char *)ptr, length);
break;
case SLE_VAR_STR:
@@ -941,7 +938,6 @@ static void SlString(void *ptr, size_t length, VarType conv)
switch (GetVarMemType(conv)) {
default: NOT_REACHED();
case SLE_VAR_STRB:
- case SLE_VAR_STRBQ:
if (len >= length) {
DEBUG(sl, 1, "String length in savegame is bigger than buffer, truncating");
SlCopyBytes(ptr, length);
diff --git a/src/saveload/saveload.h b/src/saveload/saveload.h
index 50185902d..d28b81692 100644
--- a/src/saveload/saveload.h
+++ b/src/saveload/saveload.h
@@ -446,7 +446,6 @@ enum VarTypes {
SLE_VAR_U64 = 8 << 4,
SLE_VAR_NULL = 9 << 4, ///< useful to write zeros in savegame.
SLE_VAR_STRB = 10 << 4, ///< string (with pre-allocated buffer)
- SLE_VAR_STRBQ = 11 << 4, ///< string enclosed in quotes (with pre-allocated buffer)
SLE_VAR_STR = 12 << 4, ///< string pointer
SLE_VAR_STRQ = 13 << 4, ///< string pointer enclosed in quotes
SLE_VAR_NAME = 14 << 4, ///< old custom name to be converted to a char pointer
@@ -470,7 +469,6 @@ enum VarTypes {
SLE_CHAR = SLE_FILE_I8 | SLE_VAR_CHAR,
SLE_STRINGID = SLE_FILE_STRINGID | SLE_VAR_U32,
SLE_STRINGBUF = SLE_FILE_STRING | SLE_VAR_STRB,
- SLE_STRINGBQUOTE = SLE_FILE_STRING | SLE_VAR_STRBQ,
SLE_STRING = SLE_FILE_STRING | SLE_VAR_STR,
SLE_STRINGQUOTE = SLE_FILE_STRING | SLE_VAR_STRQ,
SLE_NAME = SLE_FILE_STRINGID | SLE_VAR_NAME,
@@ -479,7 +477,6 @@ enum VarTypes {
SLE_UINT = SLE_UINT32,
SLE_INT = SLE_INT32,
SLE_STRB = SLE_STRINGBUF,
- SLE_STRBQ = SLE_STRINGBQUOTE,
SLE_STR = SLE_STRING,
SLE_STRQ = SLE_STRINGQUOTE,
diff --git a/src/script/api/script_gamesettings.cpp b/src/script/api/script_gamesettings.cpp
index bdaeb6c93..2717d4ddd 100644
--- a/src/script/api/script_gamesettings.cpp
+++ b/src/script/api/script_gamesettings.cpp
@@ -19,7 +19,7 @@
{
uint i;
const SettingDesc *sd = GetSettingFromName(setting, &i);
- return sd != nullptr && sd->desc.cmd != SDT_STRING;
+ return sd != nullptr && sd->desc.cmd != SDT_STDSTRING;
}
/* static */ int32 ScriptGameSettings::GetValue(const char *setting)
diff --git a/src/settings.cpp b/src/settings.cpp
index d47c120f0..6882179eb 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -415,8 +415,7 @@ static const void *StringToVal(const SettingDescBase *desc, const char *orig_str
return desc->def;
}
- case SDT_STDSTRING:
- case SDT_STRING: return orig_str;
+ case SDT_STDSTRING: return orig_str;
case SDT_INTLIST: return str;
default: break;
}
@@ -497,35 +496,6 @@ static void Write_ValidateSetting(void *ptr, const SettingDesc *sd, int32 val)
/**
* Set the string value of a setting.
- * @param ptr Pointer to the storage location (might be a pointer to a pointer).
- * @param sld Pointer to the information for the conversions and limitations to apply.
- * @param p The string to save.
- */
-static void Write_ValidateString(void *ptr, const SaveLoad *sld, const char *p)
-{
- switch (GetVarMemType(sld->conv)) {
- case SLE_VAR_STRB:
- case SLE_VAR_STRBQ:
- if (p != nullptr) {
- char *begin = (char*)ptr;
- char *end = begin + sld->length - 1;
- strecpy(begin, p, end);
- str_validate(begin, end, SVS_NONE);
- }
- break;
-
- case SLE_VAR_STR:
- case SLE_VAR_STRQ:
- free(*(char**)ptr);
- *(char**)ptr = p == nullptr ? nullptr : stredup(p);
- break;
-
- default: NOT_REACHED();
- }
-}
-
-/**
- * Set the string value of a setting.
* @param ptr Pointer to the std::string.
* @param sd Pointer to the information for the conversions and limitations to apply.
* @param p The string to save.
@@ -611,10 +581,6 @@ static void IniLoadSettings(IniFile *ini, const SettingDesc *sd, const char *grp
Write_ValidateSetting(ptr, sd, (int32)(size_t)p);
break;
- case SDT_STRING:
- Write_ValidateString(ptr, sld, (const char *)p);
- break;
-
case SDT_STDSTRING:
Write_ValidateStdString(ptr, sd, (const char *)p);
break;
@@ -736,24 +702,6 @@ static void IniSaveSettings(IniFile *ini, const SettingDesc *sd, const char *grp
break;
}
- case SDT_STRING:
- switch (GetVarMemType(sld->conv)) {
- case SLE_VAR_STRB: strecpy(buf, (char*)ptr, lastof(buf)); break;
- case SLE_VAR_STRBQ:seprintf(buf, lastof(buf), "\"%s\"", (char*)ptr); break;
- case SLE_VAR_STR: strecpy(buf, *(char**)ptr, lastof(buf)); break;
-
- case SLE_VAR_STRQ:
- if (*(char**)ptr == nullptr) {
- buf[0] = '\0';
- } else {
- seprintf(buf, lastof(buf), "\"%s\"", *(char**)ptr);
- }
- break;
-
- default: NOT_REACHED();
- }
- break;
-
case SDT_STDSTRING:
switch (GetVarMemType(sld->conv)) {
case SLE_VAR_STR: strecpy(buf, reinterpret_cast<std::string *>(ptr)->c_str(), lastof(buf)); break;
@@ -2123,11 +2071,7 @@ bool SetSettingValue(uint index, const char *value, bool force_newgame)
}
void *ptr = GetVariableAddress((_game_mode == GM_MENU || force_newgame) ? &_settings_newgame : &_settings_game, &sd->save);
- if (sd->desc.cmd == SDT_STRING) {
- Write_ValidateString(ptr, &sd->save, value);
- } else {
- Write_ValidateStdString(ptr, sd, value);
- }
+ Write_ValidateStdString(ptr, sd, value);
if (sd->desc.proc != nullptr) sd->desc.proc(0);
if (_save_config) SaveToConfig();
@@ -2184,7 +2128,7 @@ void IConsoleSetSetting(const char *name, const char *value, bool force_newgame)
}
bool success;
- if (sd->desc.cmd == SDT_STRING || sd->desc.cmd == SDT_STDSTRING) {
+ if (sd->desc.cmd == SDT_STDSTRING) {
success = SetSettingValue(index, value, force_newgame);
} else {
uint32 val;
@@ -2235,9 +2179,7 @@ void IConsoleGetSetting(const char *name, bool force_newgame)
ptr = GetVariableAddress((_game_mode == GM_MENU || force_newgame) ? &_settings_newgame : &_settings_game, &sd->save);
- if (sd->desc.cmd == SDT_STRING) {
- IConsolePrintF(CC_WARNING, "Current value for '%s' is: '%s'", name, (GetVarMemType(sd->save.conv) == SLE_VAR_STRQ) ? *(const char * const *)ptr : (const char *)ptr);
- } else if (sd->desc.cmd == SDT_STDSTRING) {
+ if (sd->desc.cmd == SDT_STDSTRING) {
IConsolePrintF(CC_WARNING, "Current value for '%s' is: '%s'", name, reinterpret_cast<const std::string *>(ptr)->c_str());
} else {
if (sd->desc.cmd == SDT_BOOLX) {
@@ -2268,8 +2210,6 @@ void IConsoleListSettings(const char *prefilter)
if (sd->desc.cmd == SDT_BOOLX) {
seprintf(value, lastof(value), (*(const bool *)ptr != 0) ? "on" : "off");
- } else if (sd->desc.cmd == SDT_STRING) {
- seprintf(value, lastof(value), "%s", (GetVarMemType(sd->save.conv) == SLE_VAR_STRQ) ? *(const char * const *)ptr : (const char *)ptr);
} else if (sd->desc.cmd == SDT_STDSTRING) {
seprintf(value, lastof(value), "%s", reinterpret_cast<const std::string *>(ptr)->c_str());
} else {
diff --git a/src/settings_internal.h b/src/settings_internal.h
index 14d3531a3..d5f237f3c 100644
--- a/src/settings_internal.h
+++ b/src/settings_internal.h
@@ -26,7 +26,6 @@ enum SettingDescType : byte {
SDT_ONEOFMANY = 2, ///< bitmasked number where only ONE bit may be set
SDT_MANYOFMANY = 3, ///< bitmasked number where MULTIPLE bits may be set
SDT_INTLIST = 4, ///< list of integers separated by a comma ','
- SDT_STRING = 5, ///< string with a pre-allocated buffer
SDT_STDSTRING = 6, ///< \c std::string
SDT_END,
/* 9 more possible primitives */
diff --git a/src/table/settings.h.preamble b/src/table/settings.h.preamble
index 14eeb9fdc..826b272d7 100644
--- a/src/table/settings.h.preamble
+++ b/src/table/settings.h.preamble
@@ -73,9 +73,6 @@ static size_t ConvertLandscape(const char *value);
#define SDTG_LIST(name, type, length, flags, guiflags, var, def, str, strhelp, strval, proc, from, to, cat, extra, startup)\
SDTG_GENERAL(name, SDT_INTLIST, SL_ARR, type, flags, guiflags, var, length, def, 0, 0, 0, nullptr, str, strhelp, strval, proc, from, to, cat, extra, startup)
-#define SDTG_STR(name, type, flags, guiflags, var, def, str, strhelp, strval, proc, from, to, cat, extra, startup)\
- SDTG_GENERAL(name, SDT_STRING, SL_STR, type, flags, guiflags, var, sizeof(var), def, 0, 0, 0, nullptr, str, strhelp, strval, proc, from, to, cat, extra, startup)
-
#define SDTG_SSTR(name, type, flags, guiflags, var, def, str, strhelp, strval, proc, from, to, cat, extra, startup)\
SDTG_GENERAL(name, SDT_STDSTRING, SL_STDSTR, type, flags, guiflags, var, sizeof(var), def, 0, 0, 0, nullptr, str, strhelp, strval, proc, from, to, cat, extra, startup)
@@ -104,9 +101,6 @@ static size_t ConvertLandscape(const char *value);
#define SDT_LIST(base, var, type, flags, guiflags, def, str, strhelp, strval, proc, from, to, cat, extra, startup)\
SDT_GENERAL(#var, SDT_INTLIST, SL_ARR, type, flags, guiflags, base, var, lengthof(((base*)8)->var), def, 0, 0, 0, nullptr, str, strhelp, strval, proc, nullptr, from, to, cat, extra, startup)
-#define SDT_STR(base, var, type, flags, guiflags, def, str, strhelp, strval, proc, from, to, cat, extra, startup)\
- SDT_GENERAL(#var, SDT_STRING, SL_STR, type, flags, guiflags, base, var, sizeof(((base*)8)->var), def, 0, 0, 0, nullptr, str, strhelp, strval, proc, nullptr, from, to, cat, extra, startup)
-
#define SDT_SSTR(base, var, type, flags, guiflags, def, str, strhelp, strval, proc, from, to, cat, extra, startup)\
SDT_GENERAL(#var, SDT_STDSTRING, SL_STDSTR, type, flags, guiflags, base, var, sizeof(((base*)8)->var), def, 0, 0, 0, nullptr, str, strhelp, strval, proc, nullptr, from, to, cat, extra, startup)