aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCraig Robbins <kde.psych@gmail.com>2015-01-25 01:19:40 +1000
committerCraig Robbins <kde.psych@gmail.com>2015-01-25 01:19:40 +1000
commit2c4a5e18619a69159bcace8c03b4ea5642f46836 (patch)
treef22463c9cb1ac5bb9589d5be94d94f89cea45e89 /src
parent800d19270250bb13cc6b2d330199815bf8e96446 (diff)
downloadminetest-2c4a5e18619a69159bcace8c03b4ea5642f46836.tar.gz
minetest-2c4a5e18619a69159bcace8c03b4ea5642f46836.tar.bz2
minetest-2c4a5e18619a69159bcace8c03b4ea5642f46836.zip
Revert "Make the GameGlobalShaderConstantSetter use the settings callback (8% perf improvement in game loop)"
This reverts commit a555e2d9b0ccee452996381a44677b8bec210036.
Diffstat (limited to 'src')
-rw-r--r--src/fontengine.cpp2
-rw-r--r--src/game.cpp20
-rw-r--r--src/settings.cpp10
-rw-r--r--src/settings.h6
4 files changed, 11 insertions, 27 deletions
diff --git a/src/fontengine.cpp b/src/fontengine.cpp
index 2df6bf833..79d53c989 100644
--- a/src/fontengine.cpp
+++ b/src/fontengine.cpp
@@ -36,7 +36,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
FontEngine* g_fontengine = NULL;
/** callback to be used on change of font size setting */
-static void font_setting_changed(const std::string, void *userdata) {
+static void font_setting_changed(const std::string) {
g_fontengine->readSettings();
}
diff --git a/src/game.cpp b/src/game.cpp
index f5a19a7e4..ec025b73f 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -809,31 +809,15 @@ class GameGlobalShaderConstantSetter : public IShaderConstantSetter
bool *m_force_fog_off;
f32 *m_fog_range;
Client *m_client;
- bool m_fogEnabled;
public:
-
- void onSettingsChange(const std::string &name)
- {
- if (name == "enable_fog")
- m_fogEnabled = g_settings->getBool("enable_fog");
- }
-
- static void SettingsCallback(const std::string name, void *userdata)
- {
- reinterpret_cast<GameGlobalShaderConstantSetter*>(userdata)->onSettingsChange(name);
- }
-
GameGlobalShaderConstantSetter(Sky *sky, bool *force_fog_off,
f32 *fog_range, Client *client) :
m_sky(sky),
m_force_fog_off(force_fog_off),
m_fog_range(fog_range),
m_client(client)
- {
- g_settings->registerChangedCallback("enable_fog", SettingsCallback, this);
- }
-
+ {}
~GameGlobalShaderConstantSetter() {}
virtual void onSetConstants(video::IMaterialRendererServices *services,
@@ -856,7 +840,7 @@ public:
// Fog distance
float fog_distance = 10000 * BS;
- if (m_fogEnabled && !*m_force_fog_off)
+ if (g_settings->getBool("enable_fog") && !*m_force_fog_off)
fog_distance = *m_fog_range;
services->setPixelShaderConstant("fogDistance", &fog_distance, 1);
diff --git a/src/settings.cpp b/src/settings.cpp
index 3416066e2..2f515caba 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -965,15 +965,15 @@ void Settings::clearNoLock()
void Settings::registerChangedCallback(std::string name,
- setting_changed_callback cbf, void *userdata)
+ setting_changed_callback cbf)
{
- m_callbacks[name].push_back(std::make_pair(cbf,userdata));
+ m_callbacks[name].push_back(cbf);
}
void Settings::doCallbacks(const std::string name)
{
- std::vector<std::pair<setting_changed_callback,void*> > tempvector;
+ std::vector<setting_changed_callback> tempvector;
{
JMutexAutoLock lock(m_mutex);
if (m_callbacks.find(name) != m_callbacks.end())
@@ -982,9 +982,9 @@ void Settings::doCallbacks(const std::string name)
}
}
- std::vector<std::pair<setting_changed_callback, void*> >::iterator iter;
+ std::vector<setting_changed_callback>::iterator iter;
for (iter = tempvector.begin(); iter != tempvector.end(); iter++)
{
- (iter->first)(name,iter->second);
+ (*iter)(name);
}
}
diff --git a/src/settings.h b/src/settings.h
index 47feb1755..89f7589df 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -32,7 +32,7 @@ class Settings;
struct NoiseParams;
/** function type to register a changed callback */
-typedef void (*setting_changed_callback)(const std::string, void *userdata);
+typedef void (*setting_changed_callback)(const std::string);
enum ValueType {
VALUETYPE_STRING,
@@ -204,7 +204,7 @@ public:
void clear();
void updateValue(const Settings &other, const std::string &name);
void update(const Settings &other);
- void registerChangedCallback(std::string name, setting_changed_callback cbf, void *userdata = NULL);
+ void registerChangedCallback(std::string name, setting_changed_callback cbf);
private:
@@ -215,7 +215,7 @@ private:
std::map<std::string, SettingsEntry> m_settings;
std::map<std::string, SettingsEntry> m_defaults;
- std::map<std::string, std::vector<std::pair<setting_changed_callback,void*> > > m_callbacks;
+ std::map<std::string, std::vector<setting_changed_callback> > m_callbacks;
// All methods that access m_settings/m_defaults directly should lock this.
mutable JMutex m_mutex;
};