Skip to content

Commit 264fbbf

Browse files
committed
Revert Settings.cpp, Settings.h
original code is fine to use as-is
1 parent e52a7d8 commit 264fbbf

2 files changed

Lines changed: 12 additions & 48 deletions

File tree

es-core/src/Settings.cpp

Lines changed: 7 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <vector>
1010

1111
Settings* Settings::sInstance = NULL;
12-
static std::string mEmptyString = "";
1312

1413
// these values are NOT saved to es_settings.xml
1514
// since they're set through command-line arguments, and not the in-program settings menu
@@ -279,55 +278,20 @@ void Settings::processBackwardCompatibility()
279278

280279

281280
//Print a warning message if the setting we're trying to get doesn't already exist in the map, then return the value in the map.
282-
#define SETTINGS_GETSET(type, mapName, getMethodName, setMethodName, defaultValue) type Settings::getMethodName(const std::string& name) \
281+
#define SETTINGS_GETSET(type, mapName, getMethodName, setMethodName) type Settings::getMethodName(const std::string& name) \
283282
{ \
284283
if(mapName.find(name) == mapName.cend()) \
285284
{ \
286-
/* LOG(LogError) << "Tried to use unset setting " << name << "!"; */ \
287-
return defaultValue; \
285+
LOG(LogError) << "Tried to use unset setting " << name << "!"; \
288286
} \
289287
return mapName[name]; \
290288
} \
291-
bool Settings::setMethodName(const std::string& name, type value) \
289+
void Settings::setMethodName(const std::string& name, type value) \
292290
{ \
293-
if(mapName.count(name) == 0 || mapName[name] != value) { \
294291
mapName[name] = value; \
295-
\
296-
if(std::find(settings_dont_save.cbegin(), settings_dont_save.cend(), name) == settings_dont_save.cend()) \
297-
mWasChanged = true; \
298-
\
299-
return true; \
300-
} \
301-
return false; \
302-
}
303-
304-
SETTINGS_GETSET(bool, mBoolMap, getBool, setBool, false);
305-
SETTINGS_GETSET(int, mIntMap, getInt, setInt, 0);
306-
SETTINGS_GETSET(float, mFloatMap, getFloat, setFloat, 0.0f);
307-
308-
309-
std::string Settings::getString(const std::string& name)
310-
{
311-
if(mStringMap.find(name) == mStringMap.cend())
312-
return mEmptyString;
313-
314-
return mStringMap[name];
315292
}
316293

317-
bool Settings::setString(const std::string& name, const std::string& value)
318-
{
319-
if(mStringMap.count(name) == 0 || mStringMap[name] != value)
320-
{
321-
if(value == "" && mStringMap.count(name) == 0)
322-
return false;
323-
324-
mStringMap[name] = value;
325-
326-
if(std::find(settings_dont_save.cbegin(), settings_dont_save.cend(), name) == settings_dont_save.cend())
327-
mWasChanged = true;
328-
329-
return true;
330-
}
331-
332-
return false;
333-
}
294+
SETTINGS_GETSET(bool, mBoolMap, getBool, setBool);
295+
SETTINGS_GETSET(int, mIntMap, getInt, setInt);
296+
SETTINGS_GETSET(float, mFloatMap, getFloat, setFloat);
297+
SETTINGS_GETSET(const std::string&, mStringMap, getString, setString);

es-core/src/Settings.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ class Settings
1919
bool getBool(const std::string& name);
2020
int getInt(const std::string& name);
2121
float getFloat(const std::string& name);
22-
std::string getString(const std::string& name);
22+
const std::string& getString(const std::string& name);
2323

24-
bool setBool(const std::string& name, bool value);
25-
bool setInt(const std::string& name, int value);
26-
bool setFloat(const std::string& name, float value);
27-
bool setString(const std::string& name, const std::string& value);
24+
void setBool(const std::string& name, bool value);
25+
void setInt(const std::string& name, int value);
26+
void setFloat(const std::string& name, float value);
27+
void setString(const std::string& name, const std::string& value);
2828

2929
std::map<std::string, std::string>& getStringMap() { return mStringMap; }
3030

0 commit comments

Comments
 (0)