summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-08-26 02:48:32 +0300
committerAndrei Karas <akaras@inbox.ru>2012-08-26 02:48:32 +0300
commitab596ef3f4215f792feaa9ca1dfe5acb74c67328 (patch)
treeac5a4f31e2fa9c784d7de8d817654d47e21ccac2 /src
parent399f264360f6e8dfa31d0c3ff7d72aad8033888d (diff)
downloadplus-ab596ef3f4215f792feaa9ca1dfe5acb74c67328.tar.gz
plus-ab596ef3f4215f792feaa9ca1dfe5acb74c67328.tar.bz2
plus-ab596ef3f4215f792feaa9ca1dfe5acb74c67328.tar.xz
plus-ab596ef3f4215f792feaa9ca1dfe5acb74c67328.zip
Add const to some classes.
Diffstat (limited to 'src')
-rw-r--r--src/configuration.cpp79
-rw-r--r--src/configuration.h45
-rw-r--r--src/defaults.cpp14
-rw-r--r--src/defaults.h8
-rw-r--r--src/depricatedevent.cpp23
-rw-r--r--src/depricatedevent.h11
-rw-r--r--src/dropshortcut.cpp29
-rw-r--r--src/dropshortcut.h25
-rw-r--r--src/effectmanager.cpp9
-rw-r--r--src/effectmanager.h4
-rw-r--r--src/emoteshortcut.cpp12
-rw-r--r--src/emoteshortcut.h14
-rw-r--r--src/equipment.h4
-rw-r--r--src/flooritem.cpp10
-rw-r--r--src/flooritem.h7
-rw-r--r--src/game.cpp20
-rw-r--r--src/game.h10
17 files changed, 170 insertions, 154 deletions
diff --git a/src/configuration.cpp b/src/configuration.cpp
index a9bfb3bd1..5d2191b59 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -217,7 +217,7 @@ void Configuration::setValue(const std::string &key, const std::string &value)
ConfigurationObject::setValue(key, value);
// Notify listeners
- ListenerMapIterator list = mListenerMap.find(key);
+ const ListenerMapIterator list = mListenerMap.find(key);
if (list != mListenerMap.end())
{
Listeners listeners = list->second;
@@ -238,29 +238,29 @@ std::string ConfigurationObject::getValue(const std::string &key,
const std::string &deflt) const
{
GETLOG();
- Options::const_iterator iter = mOptions.find(key);
+ const Options::const_iterator iter = mOptions.find(key);
return ((iter != mOptions.end()) ? iter->second : deflt);
}
-int ConfigurationObject::getValue(const std::string &key, int deflt) const
+int ConfigurationObject::getValue(const std::string &key, const int deflt) const
{
GETLOG();
- Options::const_iterator iter = mOptions.find(key);
+ const Options::const_iterator iter = mOptions.find(key);
return (iter != mOptions.end()) ? atoi(iter->second.c_str()) : deflt;
}
-int ConfigurationObject::getValueInt(const std::string &key, int deflt) const
+int ConfigurationObject::getValueInt(const std::string &key, const int deflt) const
{
GETLOG();
- Options::const_iterator iter = mOptions.find(key);
+ const Options::const_iterator iter = mOptions.find(key);
return (iter != mOptions.end()) ? atoi(iter->second.c_str()) : deflt;
}
bool ConfigurationObject::getValueBool(const std::string &key,
- bool deflt) const
+ const bool deflt) const
{
GETLOG();
- Options::const_iterator iter = mOptions.find(key);
+ const Options::const_iterator iter = mOptions.find(key);
if (iter != mOptions.end())
return atoi(iter->second.c_str()) != 0 ? true : false;
else
@@ -268,19 +268,19 @@ bool ConfigurationObject::getValueBool(const std::string &key,
}
unsigned ConfigurationObject::getValue(const std::string &key,
- unsigned deflt) const
+ const unsigned deflt) const
{
GETLOG();
- Options::const_iterator iter = mOptions.find(key);
+ const Options::const_iterator iter = mOptions.find(key);
return (iter != mOptions.end()) ? static_cast<unsigned>(
atol(iter->second.c_str())) : deflt;
}
double ConfigurationObject::getValue(const std::string &key,
- double deflt) const
+ const double deflt) const
{
GETLOG();
- Options::const_iterator iter = mOptions.find(key);
+ const Options::const_iterator iter = mOptions.find(key);
return (iter != mOptions.end()) ? atof(iter->second.c_str()) : deflt;
}
@@ -344,7 +344,7 @@ Configuration::~Configuration()
cleanDefaults();
}
-void Configuration::setDefaultValues(DefaultsData *defaultsData)
+void Configuration::setDefaultValues(DefaultsData *const defaultsData)
{
cleanDefaults();
mDefaultsData = defaultsData;
@@ -354,16 +354,17 @@ int Configuration::getIntValue(const std::string &key) const
{
GETLOG();
int defaultValue = 0;
- Options::const_iterator iter = mOptions.find(key);
+ const Options::const_iterator iter = mOptions.find(key);
if (iter == mOptions.end())
{
if (mDefaultsData)
{
- DefaultsData::const_iterator itdef = mDefaultsData->find(key);
+ const DefaultsData::const_iterator itdef
+ = mDefaultsData->find(key);
if (itdef != mDefaultsData->end() && itdef->second)
{
- VariableData::DataType type = static_cast<
+ const VariableData::DataType type = static_cast<const
VariableData::DataType>(itdef->second->getType());
if (type == VariableData::DATA_INT)
{
@@ -413,7 +414,7 @@ int Configuration::resetIntValue(const std::string &key)
int defaultValue = 0;
if (mDefaultsData)
{
- DefaultsData::const_iterator itdef = mDefaultsData->find(key);
+ const DefaultsData::const_iterator itdef = mDefaultsData->find(key);
if (itdef != mDefaultsData->end() && itdef->second
&& itdef->second->getType() == VariableData::DATA_INT)
@@ -435,16 +436,17 @@ std::string Configuration::getStringValue(const std::string &key) const
{
GETLOG();
std::string defaultValue("");
- Options::const_iterator iter = mOptions.find(key);
+ const Options::const_iterator iter = mOptions.find(key);
if (iter == mOptions.end())
{
if (mDefaultsData)
{
- DefaultsData::const_iterator itdef = mDefaultsData->find(key);
+ const DefaultsData::const_iterator
+ itdef = mDefaultsData->find(key);
if (itdef != mDefaultsData->end() && itdef->second)
{
- VariableData::DataType type = static_cast<
+ const VariableData::DataType type = static_cast<const
VariableData::DataType>(itdef->second->getType());
if (type == VariableData::DATA_STRING)
{
@@ -488,16 +490,17 @@ float Configuration::getFloatValue(const std::string &key) const
{
GETLOG();
float defaultValue = 0.0f;
- Options::const_iterator iter = mOptions.find(key);
+ const Options::const_iterator iter = mOptions.find(key);
if (iter == mOptions.end())
{
if (mDefaultsData)
{
- DefaultsData::const_iterator itdef = mDefaultsData->find(key);
+ const DefaultsData::const_iterator itdef
+ = mDefaultsData->find(key);
if (itdef != mDefaultsData->end() && itdef->second)
{
- VariableData::DataType type = static_cast<
+ const VariableData::DataType type = static_cast<
VariableData::DataType>(itdef->second->getType());
if (type == VariableData::DATA_FLOAT)
{
@@ -546,16 +549,17 @@ bool Configuration::getBoolValue(const std::string &key) const
{
GETLOG();
bool defaultValue = false;
- Options::const_iterator iter = mOptions.find(key);
+ const Options::const_iterator iter = mOptions.find(key);
if (iter == mOptions.end())
{
if (mDefaultsData)
{
- DefaultsData::const_iterator itdef = mDefaultsData->find(key);
+ const DefaultsData::const_iterator itdef
+ = mDefaultsData->find(key);
if (itdef != mDefaultsData->end() && itdef->second)
{
- VariableData::DataType type = static_cast<
+ const VariableData::DataType type = static_cast<
VariableData::DataType>(itdef->second->getType());
if (type == VariableData::DATA_BOOL)
{
@@ -620,7 +624,7 @@ bool Configuration::resetBoolValue(const std::string &key)
bool defaultValue = false;
if (mDefaultsData)
{
- DefaultsData::const_iterator itdef = mDefaultsData->find(key);
+ const DefaultsData::const_iterator itdef = mDefaultsData->find(key);
if (itdef != mDefaultsData->end() && itdef->second
&& itdef->second->getType() == VariableData::DATA_BOOL)
@@ -640,7 +644,7 @@ bool Configuration::resetBoolValue(const std::string &key)
}
-void ConfigurationObject::initFromXML(XmlNodePtr parent_node)
+void ConfigurationObject::initFromXML(const XmlNodePtr parent_node)
{
clear();
@@ -657,7 +661,7 @@ void ConfigurationObject::initFromXML(XmlNodePtr parent_node)
if (xmlNameEqual(subnode, name.c_str())
&& subnode->type == XML_ELEMENT_NODE)
{
- ConfigurationObject *cobj = new ConfigurationObject;
+ ConfigurationObject *const cobj = new ConfigurationObject;
cobj->initFromXML(subnode); // recurse
@@ -679,7 +683,7 @@ void ConfigurationObject::initFromXML(XmlNodePtr parent_node)
}
}
-void Configuration::init(const std::string &filename, bool useResManager)
+void Configuration::init(const std::string &filename, const bool useResManager)
{
mDefaultsData = nullptr;
XML::Document doc(filename, useResManager);
@@ -703,7 +707,7 @@ void Configuration::init(const std::string &filename, bool useResManager)
return;
}
- XmlNodePtr rootNode = doc.rootNode();
+ const XmlNodePtr rootNode = doc.rootNode();
if (!rootNode || !xmlNameEqual(rootNode, "configuration"))
{
@@ -714,7 +718,7 @@ void Configuration::init(const std::string &filename, bool useResManager)
initFromXML(rootNode);
}
-void ConfigurationObject::writeToXML(XmlTextWriterPtr writer)
+void ConfigurationObject::writeToXML(const XmlTextWriterPtr writer)
{
for (Options::const_iterator i = mOptions.begin(), i_end = mOptions.end();
i != i_end; ++i)
@@ -739,7 +743,7 @@ void ConfigurationObject::writeToXML(XmlTextWriterPtr writer)
it = mContainerOptions.begin(), it_end = mContainerOptions.end();
it != it_end; ++ it)
{
- const char *name = it->first.c_str();
+ const char *const name = it->first.c_str();
xmlTextWriterStartElement(writer, BAD_CAST "list");
xmlTextWriterWriteAttribute(writer, BAD_CAST "name", BAD_CAST name);
@@ -773,7 +777,8 @@ void Configuration::write()
fclose(testFile);
}
- XmlTextWriterPtr writer = xmlNewTextWriterFilename(mConfigPath.c_str(), 0);
+ const XmlTextWriterPtr writer = xmlNewTextWriterFilename(
+ mConfigPath.c_str(), 0);
if (!writer)
{
@@ -795,18 +800,18 @@ void Configuration::write()
}
void Configuration::addListener(const std::string &key,
- ConfigListener *listener)
+ ConfigListener *const listener)
{
mListenerMap[key].push_front(listener);
}
void Configuration::removeListener(const std::string &key,
- ConfigListener *listener)
+ ConfigListener *const listener)
{
mListenerMap[key].remove(listener);
}
-void Configuration::removeListeners(ConfigListener *listener)
+void Configuration::removeListeners(ConfigListener *const listener)
{
for (ListenerMapIterator it = mListenerMap.begin(),
it_end = mListenerMap.end(); it != it_end; ++ it)
diff --git a/src/configuration.h b/src/configuration.h
index 79fa9b5ba..7435f8596 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -104,15 +104,15 @@ class ConfigurationObject
std::string getValue(const std::string &key,
const std::string &deflt) const;
- int getValue(const std::string &key, int deflt) const;
+ int getValue(const std::string &key, const int deflt) const;
- int getValueInt(const std::string &key, int deflt) const;
+ int getValueInt(const std::string &key, const int deflt) const;
- bool getValueBool(const std::string &key, bool deflt) const;
+ bool getValueBool(const std::string &key, const bool deflt) const;
- unsigned getValue(const std::string &key, unsigned deflt) const;
+ unsigned getValue(const std::string &key, const unsigned deflt) const;
- double getValue(const std::string &key, double deflt) const;
+ double getValue(const std::string &key, const double deflt) const;
/**
* Re-sets all data in the configuration
@@ -201,8 +201,8 @@ class ConfigurationObject
#endif
protected:
- virtual void initFromXML(XmlNodePtr node);
- virtual void writeToXML(XmlTextWriterPtr writer);
+ virtual void initFromXML(const XmlNodePtr parent_node);
+ virtual void writeToXML(const XmlTextWriterPtr writer);
void deleteList(const std::string &name);
@@ -236,14 +236,15 @@ class Configuration : public ConfigurationObject
* @param filename path to config file
* @param useResManager Make use of the resource manager.
*/
- void init(const std::string &filename, bool useResManager = false);
+ void init(const std::string &filename,
+ const bool useResManager = false);
/**
* Set the default values for each keys.
*
* @param defaultsData data used as defaults.
*/
- void setDefaultValues(DefaultsData *defaultsData);
+ void setDefaultValues(DefaultsData *const defaultsData);
/**
* Writes the current settings back to the config file.
@@ -253,45 +254,47 @@ class Configuration : public ConfigurationObject
/**
* Adds a listener to the listen list of the specified config option.
*/
- void addListener(const std::string &key, ConfigListener *listener);
+ void addListener(const std::string &key,
+ ConfigListener *const listener);
/**
* Removes a listener from the listen list of the specified config
* option.
*/
- void removeListener(const std::string &key, ConfigListener *listener);
+ void removeListener(const std::string &key,
+ ConfigListener *const listener);
- void removeListeners(ConfigListener *listener);
+ void removeListeners(ConfigListener *const listener);
void setValue(const std::string &key, const std::string &value);
void setSilent(const std::string &key, const std::string &value);
- inline void setValue(const std::string &key, const char *value)
+ inline void setValue(const std::string &key, const char *const value)
{ if (value) setValue(key, std::string(value)); }
- inline void setSilent(const std::string &key, const char *value)
+ inline void setSilent(const std::string &key, const char *const value)
{ if (value) setSilent(key, std::string(value)); }
- inline void setValue(const std::string &key, float value)
+ inline void setValue(const std::string &key, const float value)
{ setValue(key, toString(value)); }
- inline void setValue(const std::string &key, double value)
+ inline void setValue(const std::string &key, const double value)
{ setValue(key, toString(value)); }
- inline void setValue(const std::string &key, int value)
+ inline void setValue(const std::string &key, const int value)
{ setValue(key, toString(value)); }
- inline void setValueInt(const std::string &key, int value)
+ inline void setValueInt(const std::string &key, const int value)
{ setValue(key, toString(value)); }
- inline void setValue(const std::string &key, unsigned value)
+ inline void setValue(const std::string &key, const unsigned value)
{ setValue(key, toString(value)); }
- inline void setValue(const std::string &key, bool value)
+ inline void setValue(const std::string &key, const bool value)
{ setValue(key, value ? "1" : "0"); }
- inline void setSilent(const std::string &key, bool value)
+ inline void setSilent(const std::string &key, const bool value)
{ setSilent(key, value ? "1" : "0"); }
int resetIntValue(const std::string &key);
diff --git a/src/defaults.cpp b/src/defaults.cpp
index c7bf8bbb2..92c11164e 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -31,17 +31,17 @@
#include "debug.h"
-VariableData* createData(int defData)
+VariableData* createData(const int defData)
{
return new IntData(defData);
}
-VariableData* createData(double defData)
+VariableData* createData(const double defData)
{
return new FloatData(defData);
}
-VariableData* createData(float defData)
+VariableData* createData(const float defData)
{
return new FloatData(defData);
}
@@ -56,7 +56,7 @@ VariableData* createData(const char* defData)
return new StringData(defData);
}
-VariableData* createData(bool defData)
+VariableData* createData(const bool defData)
{
return new BoolData(defData);
}
@@ -67,7 +67,7 @@ VariableData* createData(bool defData)
DefaultsData* getConfigDefaults()
{
- DefaultsData* configData = new DefaultsData;
+ DefaultsData *const configData = new DefaultsData;
// Init main config defaults
AddDEF("OverlayDetail", 2);
AddDEF("speechBubbleAlpha", 1.0f);
@@ -267,7 +267,7 @@ DefaultsData* getConfigDefaults()
DefaultsData* getBrandingDefaults()
{
- DefaultsData* configData = new DefaultsData;
+ DefaultsData *const configData = new DefaultsData;
// Init config defaults
AddDEF("wallpapersPath", "");
AddDEF("wallpapersFile", "");
@@ -306,7 +306,7 @@ DefaultsData* getBrandingDefaults()
DefaultsData* getPathsDefaults()
{
- DefaultsData* configData = new DefaultsData;
+ DefaultsData *const configData = new DefaultsData;
// Init paths.xml defaults
AddDEF("itemIcons", "graphics/items/");
AddDEF("unknownItemFile", "unknown-item.png");
diff --git a/src/defaults.h b/src/defaults.h
index fc74f76c8..3fb274e85 100644
--- a/src/defaults.h
+++ b/src/defaults.h
@@ -28,12 +28,12 @@
typedef std::map<std::string, VariableData*> DefaultsData;
-VariableData* createData(int defData);
-VariableData* createData(double defData);
-VariableData* createData(float defData);
+VariableData* createData(const int defData);
+VariableData* createData(const double defData);
+VariableData* createData(const float defData);
VariableData* createData(const std::string &defData);
VariableData* createData(const char* defData);
-VariableData* createData(bool defData);
+VariableData* createData(const bool defData);
DefaultsData* getConfigDefaults();
DefaultsData* getBrandingDefaults();
DefaultsData* getPathsDefaults();
diff --git a/src/depricatedevent.cpp b/src/depricatedevent.cpp
index d6a1f2935..81c1e1c14 100644
--- a/src/depricatedevent.cpp
+++ b/src/depricatedevent.cpp
@@ -39,7 +39,7 @@ DepricatedEvent::~DepricatedEvent()
}
}
-void DepricatedEvent::setInt(const std::string &key, int value)
+void DepricatedEvent::setInt(const std::string &key, const int value)
throw (BadDepricatedEvent)
{
if (mData.find(key) != mData.end())
@@ -51,7 +51,7 @@ void DepricatedEvent::setInt(const std::string &key, int value)
int DepricatedEvent::getInt(const std::string &key) const
throw (BadDepricatedEvent)
{
- VariableMap::const_iterator it = mData.find(key);
+ const VariableMap::const_iterator it = mData.find(key);
if (it == mData.end())
throw BAD_KEY;
@@ -74,7 +74,7 @@ void DepricatedEvent::setString(const std::string &key,
const std::string &DepricatedEvent::getString(const std::string &key)
const throw (BadDepricatedEvent)
{
- VariableMap::const_iterator it = mData.find(key);
+ const VariableMap::const_iterator it = mData.find(key);
if (it == mData.end())
throw BAD_KEY;
@@ -85,7 +85,7 @@ const std::string &DepricatedEvent::getString(const std::string &key)
}
-void DepricatedEvent::setFloat(const std::string &key, double value)
+void DepricatedEvent::setFloat(const std::string &key, const double value)
throw (BadDepricatedEvent)
{
if (mData.find(key) != mData.end())
@@ -97,7 +97,7 @@ void DepricatedEvent::setFloat(const std::string &key, double value)
double DepricatedEvent::getFloat(const std::string &key) const
throw (BadDepricatedEvent)
{
- VariableMap::const_iterator it = mData.find(key);
+ const VariableMap::const_iterator it = mData.find(key);
if (it == mData.end())
throw BAD_KEY;
@@ -107,9 +107,10 @@ double DepricatedEvent::getFloat(const std::string &key) const
return static_cast<FloatData *>(it->second)->getData();
}
-void DepricatedEvent::trigger(Channels channel, const DepricatedEvent &event)
+void DepricatedEvent::trigger(const Channels channel,
+ const DepricatedEvent &event)
{
- ListenMap::const_iterator it = mBindings.find(channel);
+ const ListenMap::const_iterator it = mBindings.find(channel);
// Make sure something is listening
if (it == mBindings.end())
@@ -117,7 +118,7 @@ void DepricatedEvent::trigger(Channels channel, const DepricatedEvent &event)
// Loop though all listeners
ListenerSet::const_iterator lit = it->second.begin();
- ListenerSet::const_iterator lit_end = it->second.end();
+ const ListenerSet::const_iterator lit_end = it->second.end();
while (lit != lit_end)
{
if (*lit)
@@ -126,7 +127,7 @@ void DepricatedEvent::trigger(Channels channel, const DepricatedEvent &event)
}
}
-void DepricatedEvent::remove(Listener *listener)
+void DepricatedEvent::remove(Listener *const listener)
{
ListenMap::iterator it = mBindings.begin();
while (it != mBindings.end())
@@ -136,12 +137,12 @@ void DepricatedEvent::remove(Listener *listener)
}
}
-void DepricatedEvent::bind(Listener *listener, Channels channel)
+void DepricatedEvent::bind(Listener *const listener, const Channels channel)
{
mBindings[channel].insert(listener);
}
-void DepricatedEvent::unbind(Listener *listener, Channels channel)
+void DepricatedEvent::unbind(Listener *const listener, const Channels channel)
{
mBindings[channel].erase(listener);
}
diff --git a/src/depricatedevent.h b/src/depricatedevent.h
index 6e7eed448..7262a0a37 100644
--- a/src/depricatedevent.h
+++ b/src/depricatedevent.h
@@ -121,7 +121,8 @@ class DepricatedEvent
// String passed can be retivered with getName()
// and is to used to identify what type of event
// this is.
- DepricatedEvent(DepricatedEvents name) : mDepricatedEventName(name)
+ DepricatedEvent(const DepricatedEvents name) :
+ mDepricatedEventName(name)
{ }
~DepricatedEvent();
@@ -151,14 +152,14 @@ class DepricatedEvent
const throw (BadDepricatedEvent);
// Sends event to all listener on the channel
- static void trigger(Channels channel, const DepricatedEvent &event);
+ static void trigger(const Channels channel, const DepricatedEvent &event);
// Removes a listener from all channels
- static void remove(Listener *listener);
+ static void remove(Listener *const listener);
// Adds or removes a listener to a channel.
- static void bind(Listener *listener, Channels channel);
- static void unbind(Listener *listener, Channels channel);
+ static void bind(Listener *const listener, const Channels channel);
+ static void unbind(Listener *const listener, const Channels channel);
private:
DepricatedEvents mDepricatedEventName;
diff --git a/src/dropshortcut.cpp b/src/dropshortcut.cpp
index da1acc496..6fe67ce06 100644
--- a/src/dropshortcut.cpp
+++ b/src/dropshortcut.cpp
@@ -52,9 +52,9 @@ DropShortcut::~DropShortcut()
// save();
}
-void DropShortcut::load(bool oldConfig)
+void DropShortcut::load(const bool oldConfig)
{
- Configuration *cfg;
+ const Configuration *cfg;
if (oldConfig)
cfg = &config;
else
@@ -62,8 +62,8 @@ void DropShortcut::load(bool oldConfig)
for (int i = 0; i < DROP_SHORTCUT_ITEMS; i++)
{
- int itemId = cfg->getValue("drop" + toString(i), -1);
- unsigned char itemColor = static_cast<unsigned char>(
+ const int itemId = cfg->getValue("drop" + toString(i), -1);
+ const unsigned char itemColor = static_cast<unsigned char>(
cfg->getValue("dropColor" + toString(i), -1));
if (itemId != -1)
@@ -74,7 +74,7 @@ void DropShortcut::load(bool oldConfig)
}
}
-void DropShortcut::save()
+void DropShortcut::save() const
{
for (int i = 0; i < DROP_SHORTCUT_ITEMS; i++)
{
@@ -93,7 +93,7 @@ void DropShortcut::save()
}
}
-void DropShortcut::dropFirst()
+void DropShortcut::dropFirst() const
{
if (!player_node)
return;
@@ -106,7 +106,8 @@ void DropShortcut::dropFirst()
if (itemId > 0)
{
- Item *item = PlayerInfo::getInventory()->findItem(itemId, itemColor);
+ const Item *const item = PlayerInfo::getInventory()
+ ->findItem(itemId, itemColor);
if (item && item->getQuantity())
{
if (player_node->isServerBuggy())
@@ -123,7 +124,7 @@ void DropShortcut::dropFirst()
}
}
-void DropShortcut::dropItems(int cnt)
+void DropShortcut::dropItems(const int cnt)
{
if (!player_node)
return;
@@ -150,9 +151,9 @@ void DropShortcut::dropItems(int cnt)
}
}
-bool DropShortcut::dropItem(int cnt)
+bool DropShortcut::dropItem(const int cnt)
{
- const Inventory *inv = PlayerInfo::getInventory();
+ const Inventory *const inv = PlayerInfo::getInventory();
if (!inv)
return false;
@@ -166,7 +167,7 @@ bool DropShortcut::dropItem(int cnt)
}
if (itemId > 0)
{
- Item *item = inv->findItem(itemId, itemColor);
+ const Item *const item = inv->findItem(itemId, itemColor);
if (item && item->getQuantity() > 0)
{
Net::getInventoryHandler()->dropItem(item, cnt);
@@ -186,7 +187,7 @@ bool DropShortcut::dropItem(int cnt)
}
if (itemId > 0)
{
- Item *item = inv->findItem(itemId, itemColor);
+ const Item *const item = inv->findItem(itemId, itemColor);
if (item && item->getQuantity() > 0)
{
Net::getInventoryHandler()->dropItem(item, cnt);
@@ -199,7 +200,7 @@ bool DropShortcut::dropItem(int cnt)
return false;
}
-void DropShortcut::setItemSelected(Item *item)
+void DropShortcut::setItemSelected(const Item *const item)
{
if (item)
{
@@ -213,7 +214,7 @@ void DropShortcut::setItemSelected(Item *item)
}
}
-void DropShortcut::setItem(int index)
+void DropShortcut::setItem(const int index)
{
if (index < 0 || index >= DROP_SHORTCUT_ITEMS)
return;
diff --git a/src/dropshortcut.h b/src/dropshortcut.h
index 0e56a9728..4f88e8b1b 100644
--- a/src/dropshortcut.h
+++ b/src/dropshortcut.h
@@ -46,22 +46,22 @@ class DropShortcut
/**
* Load the configuration information.
*/
- void load(bool oldConfig = false);
+ void load(const bool oldConfig = false);
/**
* Save the configuration information.
*/
- void save();
+ void save() const;
/**
* Returns the shortcut item ID specified by the index.
*
* @param index Index of the shortcut item.
*/
- int getItem(int index) const
+ int getItem(const int index) const
{ return mItems[index]; }
- unsigned char getItemColor(int index) const
+ unsigned char getItemColor(const int index) const
{ return mItemColors[index]; }
/**
@@ -81,7 +81,7 @@ class DropShortcut
*
* @param index Index of the items.
*/
- void setItem(int index);
+ void setItem(const int index);
/**
* Adds an item to the items store specified by the index.
@@ -89,7 +89,8 @@ class DropShortcut
* @param index Index of the item.
* @param itemId ID of the item.
*/
- void setItems(int index, int itemId, unsigned char color)
+ void setItems(const int index, const int itemId,
+ const unsigned char color)
{ mItems[index] = itemId; mItemColors[index] = color; save(); }
/**
@@ -97,10 +98,10 @@ class DropShortcut
*
* @param itemId The ID of the item that is to be assigned.
*/
- void setItemSelected(int itemId)
+ void setItemSelected(const int itemId)
{ mItemSelected = itemId; }
- void setItemSelected(Item *item);
+ void setItemSelected(const Item *const item);
/**
* A flag to check if the item is selected.
@@ -111,7 +112,7 @@ class DropShortcut
/**
* Remove a item from the shortcut.
*/
- void removeItem(int index)
+ void removeItem(const int index)
{ mItems[index] = -1; save(); }
/**
@@ -134,12 +135,12 @@ class DropShortcut
/**
* Drop first item.
*/
- void dropFirst();
+ void dropFirst() const;
/**
* Drop all items in cicle.
*/
- void dropItems(int cnt = 1);
+ void dropItems(const int cnt = 1);
void clear();
@@ -148,7 +149,7 @@ class DropShortcut
/**
* Drop item in cicle.
*/
- bool dropItem(int cnt = 1);
+ bool dropItem(const int cnt = 1);
int mItems[DROP_SHORTCUT_ITEMS];
unsigned char mItemColors[DROP_SHORTCUT_ITEMS];
diff --git a/src/effectmanager.cpp b/src/effectmanager.cpp
index 5663b95b8..42c6d471d 100644
--- a/src/effectmanager.cpp
+++ b/src/effectmanager.cpp
@@ -32,7 +32,7 @@
EffectManager::EffectManager()
{
XML::Document doc("effects.xml");
- XmlNodePtr root = doc.rootNode();
+ const XmlNodePtr root = doc.rootNode();
if (!root || !xmlNameEqual(root, "being-effects"))
{
@@ -61,7 +61,7 @@ EffectManager::~EffectManager()
{
}
-bool EffectManager::trigger(int id, Being* being)
+bool EffectManager::trigger(const int id, Being *const being)
{
if (!being || !particleEngine)
return false;
@@ -75,7 +75,8 @@ bool EffectManager::trigger(int id, Being* being)
rValue = true;
if (!(*i).GFX.empty())
{
- Particle *selfFX = particleEngine->addEffect((*i).GFX, 0, 0);
+ Particle *const selfFX = particleEngine->addEffect(
+ (*i).GFX, 0, 0);
being->controlParticle(selfFX);
}
if (!(*i).SFX.empty())
@@ -86,7 +87,7 @@ bool EffectManager::trigger(int id, Being* being)
return rValue;
}
-bool EffectManager::trigger(int id, int x, int y)
+bool EffectManager::trigger(const int id, const int x, const int y)
{
if (!particleEngine)
return false;
diff --git a/src/effectmanager.h b/src/effectmanager.h
index 7b71069fe..4c79b3e40 100644
--- a/src/effectmanager.h
+++ b/src/effectmanager.h
@@ -46,13 +46,13 @@ class EffectManager
* Triggers a effect with the id, at
* the specified being.
*/
- bool trigger(int id, Being* being);
+ bool trigger(const int id, Being *const being);
/**
* Triggers a effect with the id, at
* the specified x and y coordinate.
*/
- bool trigger(int id, int x, int y);
+ bool trigger(const int id, const int x, const int y);
private:
std::vector<EffectDescription> mEffects;
diff --git a/src/emoteshortcut.cpp b/src/emoteshortcut.cpp
index 72495b361..365fd4747 100644
--- a/src/emoteshortcut.cpp
+++ b/src/emoteshortcut.cpp
@@ -48,7 +48,7 @@ void EmoteShortcut::load()
i <= EmoteDB::getLast() && j < SHORTCUT_EMOTES;
i++)
{
- const AnimatedSprite* sprite = EmoteDB::getAnimation(i, true);
+ const AnimatedSprite *const sprite = EmoteDB::getAnimation(i, true);
if (sprite)
{
mEmotes[j] = static_cast<unsigned char>(i + 1);
@@ -57,18 +57,18 @@ void EmoteShortcut::load()
}
}
-void EmoteShortcut::save()
+void EmoteShortcut::save() const
{
for (int i = 0; i < SHORTCUT_EMOTES; i++)
{
- unsigned char emoteId = mEmotes[i] ? mEmotes[i]
- : static_cast<unsigned char>(0);
+ const unsigned char emoteId = mEmotes[i] ? mEmotes[i]
+ : static_cast<unsigned char>(0);
serverConfig.setValue("emoteshortcut" + toString(i),
- static_cast<unsigned int>(emoteId));
+ static_cast<unsigned int>(emoteId));
}
}
-void EmoteShortcut::useEmote(int index)
+void EmoteShortcut::useEmote(const int index) const
{
if (!player_node)
return;
diff --git a/src/emoteshortcut.h b/src/emoteshortcut.h
index f43585a0e..e9c52827c 100644
--- a/src/emoteshortcut.h
+++ b/src/emoteshortcut.h
@@ -50,7 +50,7 @@ class EmoteShortcut
*
* @param index Index of the shortcut Emote.
*/
- unsigned char getEmote(int index) const
+ unsigned char getEmote(const int index) const
{ return mEmotes[index]; }
/**
@@ -70,7 +70,7 @@ class EmoteShortcut
*
* @param index Index of the emotes.
*/
- void setEmote(int index)
+ void setEmote(const int index)
{ mEmotes[index] = mEmoteSelected; }
/**
@@ -79,7 +79,7 @@ class EmoteShortcut
* @param index Index of the emote.
* @param emoteId ID of the emote.
*/
- void setEmotes(int index, unsigned char emoteId)
+ void setEmotes(const int index, const unsigned char emoteId)
{ mEmotes[index] = emoteId; }
/**
@@ -87,7 +87,7 @@ class EmoteShortcut
*
* @param emoteId The ID of the emote that is to be assigned.
*/
- void setEmoteSelected(unsigned char emoteId)
+ void setEmoteSelected(const unsigned char emoteId)
{ mEmoteSelected = emoteId; }
/**
@@ -99,7 +99,7 @@ class EmoteShortcut
/**
* Remove a Emote from the shortcut.
*/
- void removeEmote(int index)
+ void removeEmote(const int index)
{ if (index >= 0 && index < SHORTCUT_EMOTES) mEmotes[index] = 0; }
/**
@@ -107,13 +107,13 @@ class EmoteShortcut
*
* @param index Index of the emote shortcut.
*/
- void useEmote(int index);
+ void useEmote(const int index) const;
private:
/**
* Save the configuration information.
*/
- void save();
+ void save() const;
unsigned char mEmotes[SHORTCUT_EMOTES]; /**< The emote stored. */
unsigned char mEmoteSelected; /**< The emote held
diff --git a/src/equipment.h b/src/equipment.h
index 48d538081..176790f0f 100644
--- a/src/equipment.h
+++ b/src/equipment.h
@@ -76,7 +76,7 @@ class Equipment
/**
* Get equipment at the given slot.
*/
- Item *getEquipment(int index) const
+ Item *getEquipment(const int index) const
{ return mBackend ? mBackend->getEquipment(index) : nullptr; }
/**
@@ -90,7 +90,7 @@ class Equipment
*/
void setEquipment(int index, int id, int quantity = 0);
- void setBackend(Backend *backend)
+ void setBackend(Backend *const backend)
{ mBackend = backend; }
Backend *getBackend() const
diff --git a/src/flooritem.cpp b/src/flooritem.cpp
index f612713da..7826f7855 100644
--- a/src/flooritem.cpp
+++ b/src/flooritem.cpp
@@ -34,8 +34,10 @@
#include "debug.h"
-FloorItem::FloorItem(int id, int itemId, int x, int y, Map *map, int amount,
- unsigned char color, int subX, int subY):
+FloorItem::FloorItem(const int id, const int itemId, const int x, const int y,
+ Map *const map, const int amount,
+ const unsigned char color,
+ int subX, int subY):
ActorSprite(id),
mItemId(itemId),
mX(x),
@@ -52,7 +54,7 @@ FloorItem::FloorItem(int id, int itemId, int x, int y, Map *map, int amount,
const ItemInfo &info = ItemDB::get(itemId);
if (map)
{
- int max = info.getMaxFloorOffset();
+ const int max = info.getMaxFloorOffset();
if (subX > max)
subX = max;
else if (subX < -max)
@@ -100,7 +102,7 @@ bool FloorItem::draw(Graphics *graphics, int offsetX, int offsetY) const
if (mHighlight)
{
- int curTime = cur_time;
+ const int curTime = cur_time;
font = gui->getFont();
if (mDropTime < curTime)
{
diff --git a/src/flooritem.h b/src/flooritem.h
index 1d1947379..42a543aea 100644
--- a/src/flooritem.h
+++ b/src/flooritem.h
@@ -46,8 +46,9 @@ class FloorItem : public ActorSprite
* @param subX the x pixel relative position
* @param subY the y pixel relative position
*/
- FloorItem(int id, int itemId, int x, int y, Map *map, int amount,
- unsigned char color, int subX, int subY);
+ FloorItem(const int id, const int itemId, const int x, const int y,
+ Map *const map, const int amount, const unsigned char color,
+ int subX, int subY);
Type getType() const
{ return FLOOR_ITEM; }
@@ -86,7 +87,7 @@ class FloorItem : public ActorSprite
bool getShowMsg() const
{ return mShowMsg; }
- void setShowMsg(bool n)
+ void setShowMsg(const bool n)
{ mShowMsg = n; }
void disableHightlight()
diff --git a/src/game.cpp b/src/game.cpp
index f00123af3..3672a3ea8 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -384,7 +384,7 @@ Game::Game():
viewport = new Viewport;
viewport->setSize(mainGraphics->mWidth, mainGraphics->mHeight);
- gcn::Container *top = static_cast<gcn::Container*>(gui->getTop());
+ gcn::Container *const top = static_cast<gcn::Container*>(gui->getTop());
top->add(viewport);
viewport->requestMoveToBottom();
@@ -488,7 +488,7 @@ bool Game::createScreenshot()
return saveScreenshot(screenshot);
}
-bool Game::saveScreenshot(SDL_Surface *screenshot)
+bool Game::saveScreenshot(SDL_Surface *const screenshot)
{
static unsigned int screenshotCount = 0;
// Search for an unused screenshot name
@@ -606,7 +606,7 @@ void Game::slowLogic()
if (viewport && !errorMessage.empty())
{
- Map *map = viewport->getCurrentMap();
+ Map *const map = viewport->getCurrentMap();
if (map)
{
logger->log("state: %d", Client::getState());
@@ -838,7 +838,7 @@ void Game::handleMove()
}
}
-void Game::handleActive(SDL_Event &event)
+void Game::handleActive(const SDL_Event &event)
{
// logger->log("SDL_ACTIVEEVENT");
// logger->log("state: %d", (int)event.active.state);
@@ -979,12 +979,12 @@ void Game::changeMap(const std::string &mapPath)
std::string realFullMap = paths.getValue("maps", "maps/")
+ MapDB::getMapName(mMapName) + ".tmx";
- ResourceManager *resman = ResourceManager::getInstance();
+ ResourceManager *const resman = ResourceManager::getInstance();
if (!resman->exists(realFullMap))
realFullMap += ".gz";
// Attempt to load the new map
- Map *newMap = MapReader::readMap(fullMap, realFullMap);
+ Map *const newMap = MapReader::readMap(fullMap, realFullMap);
if (!newMap)
{
@@ -1044,7 +1044,7 @@ void Game::changeMap(const std::string &mapPath)
DepricatedEvent::trigger(CHANNEL_GAME, event);
}
-void Game::updateHistory(SDL_Event &event)
+void Game::updateHistory(const SDL_Event &event)
{
if (!player_node || !player_node->getAttackType())
return;
@@ -1053,8 +1053,8 @@ void Game::updateHistory(SDL_Event &event)
{
bool old = false;
- int key = keyboard.getKeyIndex(event);
- int time = cur_time;
+ const int key = keyboard.getKeyIndex(event);
+ const int time = cur_time;
int idx = -1;
for (int f = 0; f < MAX_LASTKEYS; f ++)
{
@@ -1144,7 +1144,7 @@ void Game::closeDialogs()
}
}
-void Game::videoResized(int width, int height)
+void Game::videoResized(const int width, const int height) const
{
if (viewport)
viewport->setSize(width, height);
diff --git a/src/game.h b/src/game.h
index 6fc42be42..5ea45863a 100644
--- a/src/game.h
+++ b/src/game.h
@@ -83,7 +83,7 @@ class Game
void handleMove();
- void handleActive(SDL_Event &event);
+ void handleActive(const SDL_Event &event);
void changeMap(const std::string &mapName);
@@ -107,17 +107,17 @@ class Game
static void closeDialogs();
- void videoResized(int width, int height);
+ void videoResized(const int width, const int height) const;
- bool getValidSpeed()
+ bool getValidSpeed() const
{ return mValidSpeed; }
static bool createScreenshot();
- static bool saveScreenshot(SDL_Surface *screenshot);
+ static bool saveScreenshot(SDL_Surface *const screenshot);
private:
- void updateHistory(SDL_Event &event);
+ void updateHistory(const SDL_Event &event);
void checkKeys();