summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2010-05-13 19:57:49 +0200
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2010-05-16 23:25:35 +0200
commit32a27a534582b63324444b4650f08637834232fd (patch)
tree9e7f349f948864e551711a8c479a24cb0496f387
parent1e164776a737b57c54a71f6eab8f93263146b089 (diff)
downloadmanaserv-32a27a534582b63324444b4650f08637834232fd.tar.gz
manaserv-32a27a534582b63324444b4650f08637834232fd.tar.xz
manaserv-32a27a534582b63324444b4650f08637834232fd.zip
Random cleanups, adding const, removing unnecessary clear calls
Reviewed-by: Jared Adams
-rw-r--r--src/account-server/accounthandler.hpp2
-rw-r--r--src/account-server/serverhandler.cpp9
-rw-r--r--src/account-server/storage.cpp6
-rw-r--r--src/common/permissionmanager.hpp4
-rw-r--r--src/game-server/item.hpp4
-rw-r--r--src/net/messagein.hpp18
-rw-r--r--src/sql/sqlite/createTables.sql2
-rw-r--r--src/utils/stringfilter.cpp10
-rw-r--r--src/utils/stringfilter.h23
9 files changed, 29 insertions, 49 deletions
diff --git a/src/account-server/accounthandler.hpp b/src/account-server/accounthandler.hpp
index 4bb3eae..5fa2a06 100644
--- a/src/account-server/accounthandler.hpp
+++ b/src/account-server/accounthandler.hpp
@@ -46,4 +46,4 @@ namespace AccountClientHandler
void process();
}
-#endif
+#endif // ACCOUNTHANDLER_H
diff --git a/src/account-server/serverhandler.cpp b/src/account-server/serverhandler.cpp
index b403763..a6cf21f 100644
--- a/src/account-server/serverhandler.cpp
+++ b/src/account-server/serverhandler.cpp
@@ -133,8 +133,9 @@ static GameServer *getGameServerFromMap(int mapId)
return NULL;
}
-bool GameServerHandler::getGameServerFromMap
- (int mapId, std::string &address, int &port)
+bool GameServerHandler::getGameServerFromMap(int mapId,
+ std::string &address,
+ int &port)
{
if (GameServer *s = ::getGameServerFromMap(mapId))
{
@@ -513,7 +514,9 @@ void GameServerHandler::dumpStatistics(std::ostream &os)
i_end = serverHandler->clients.end(); i != i_end; ++i)
{
GameServer *server = static_cast< GameServer * >(*i);
- if (!server->port) continue;
+ if (!server->port)
+ continue;
+
os << "<gameserver address=\"" << server->address << "\" port=\""
<< server->port << "\">\n";
diff --git a/src/account-server/storage.cpp b/src/account-server/storage.cpp
index 3973506..1c2a175 100644
--- a/src/account-server/storage.cpp
+++ b/src/account-server/storage.cpp
@@ -1902,7 +1902,7 @@ void Storage::deletePost(Letter *letter)
mDb->commitTransaction();
letter->setId(0);
}
- catch(const dal::DbSqlQueryExecFailure &e)
+ catch (const dal::DbSqlQueryExecFailure &e)
{
mDb->rollbackTransaction();
LOG_ERROR("(DALStorage::deletePost) SQL query failure: " << e.what());
@@ -1943,17 +1943,13 @@ void Storage::syncDatabase()
}
if (!xmlStrEqual(node->name, BAD_CAST "item"))
- {
continue;
- }
if (xmlStrEqual(node->name, BAD_CAST "item"))
{
int id = XML::getProperty(node, "id", 0);
if (id < 500)
- {
continue;
- }
int weight = XML::getProperty(node, "weight", 0);
std::string type = XML::getProperty(node, "type", "");
diff --git a/src/common/permissionmanager.hpp b/src/common/permissionmanager.hpp
index aaf2773..5ef951b 100644
--- a/src/common/permissionmanager.hpp
+++ b/src/common/permissionmanager.hpp
@@ -66,6 +66,6 @@ namespace PermissionManager
*/
std::list<std::string> getClassList(const Character* character);
-}
+} // namespace PermissionManager
-#endif
+#endif // PERMISSIONMANAGER_HPP
diff --git a/src/game-server/item.hpp b/src/game-server/item.hpp
index 4aa84c9..98d1fd8 100644
--- a/src/game-server/item.hpp
+++ b/src/game-server/item.hpp
@@ -220,7 +220,7 @@ class ItemClass
/**
* Gets database ID.
*/
- int getDatabaseID()
+ int getDatabaseID() const
{ return mDatabaseID; }
/**
@@ -232,7 +232,7 @@ class ItemClass
/**
* Gets the sprite ID.
*/
- int getSpriteID()
+ int getSpriteID() const
{ return mSpriteID; }
/**
diff --git a/src/net/messagein.hpp b/src/net/messagein.hpp
index 43f562a..7188419 100644
--- a/src/net/messagein.hpp
+++ b/src/net/messagein.hpp
@@ -23,8 +23,6 @@
#include <iosfwd>
-class Packet;
-
/**
* Used for parsing an incoming message.
*/
@@ -39,14 +37,12 @@ class MessageIn
/**
* Returns the message ID.
*/
- int
- getId() const { return mId; }
+ int getId() const { return mId; }
/**
* Returns the total length of this message.
*/
- int
- getLength() const { return mLength; }
+ int getLength() const { return mLength; }
int readByte(); /**< Reads a byte. */
int readShort(); /**< Reads a short. */
@@ -57,18 +53,12 @@ class MessageIn
* that the length of the string is stored in a short at the
* start of the string.
*/
- std::string
- readString(int length = -1);
+ std::string readString(int length = -1);
/**
* Returns the length of unread data.
*/
- int
- getUnreadLength() const { return mLength - mPos; }
-
- /**
- * Returns
- */
+ int getUnreadLength() const { return mLength - mPos; }
private:
const char *mData; /**< Packet data */
diff --git a/src/sql/sqlite/createTables.sql b/src/sql/sqlite/createTables.sql
index 7128984..f4b4b1d 100644
--- a/src/sql/sqlite/createTables.sql
+++ b/src/sql/sqlite/createTables.sql
@@ -172,7 +172,7 @@ CREATE INDEX mana_inventories_owner ON mana_inventories ( owner_id );
CREATE TABLE mana_guilds
(
id INTEGER PRIMARY KEY,
- name TEXT NOT NULL UNIQUE
+ name TEXT NOT NULL UNIQUE
);
-----------------------------------------------------------------------------
diff --git a/src/utils/stringfilter.cpp b/src/utils/stringfilter.cpp
index de46491..4a9d19c 100644
--- a/src/utils/stringfilter.cpp
+++ b/src/utils/stringfilter.cpp
@@ -31,14 +31,12 @@ namespace utils
StringFilter::StringFilter():
mInitialized(false)
{
- mSlangs.clear(); // Does this make any sense here?
loadSlangFilterList();
}
StringFilter::~StringFilter()
{
writeSlangFilterList();
- mSlangs.clear(); // Does this make any sense here?
}
bool StringFilter::loadSlangFilterList()
@@ -71,7 +69,7 @@ void StringFilter::writeSlangFilterList()
//mConfig->setValue("SlangsList", slangsList);
}
-bool StringFilter::filterContent(const std::string& text)
+bool StringFilter::filterContent(const std::string &text) const
{
if (!mInitialized) {
LOG_DEBUG("Slangs List is not initialized.");
@@ -84,7 +82,7 @@ bool StringFilter::filterContent(const std::string& text)
std::transform(text.begin(), text.end(), upperCaseText.begin(),
(int(*)(int))std::toupper);
- for (SlangIterator i = mSlangs.begin(); i != mSlangs.end(); ++i)
+ for (Slangs::const_iterator i = mSlangs.begin(); i != mSlangs.end(); ++i)
{
// We look for slangs into the sentence.
std::string upperCaseSlang = *i;
@@ -100,7 +98,7 @@ bool StringFilter::filterContent(const std::string& text)
return isContentClean;
}
-bool StringFilter::isEmailValid(const std::string& email)
+bool StringFilter::isEmailValid(const std::string &email) const
{
unsigned int min = Configuration::getValue("account_minEmailLength", 7);
unsigned int max = Configuration::getValue("account_maxEmailLength", 128);
@@ -119,7 +117,7 @@ bool StringFilter::isEmailValid(const std::string& email)
(email.find_first_of(' ') == std::string::npos);
}
-bool StringFilter::findDoubleQuotes(const std::string &text)
+bool StringFilter::findDoubleQuotes(const std::string &text) const
{
return (text.find('"', 0) != std::string::npos);
}
diff --git a/src/utils/stringfilter.h b/src/utils/stringfilter.h
index 40eed12..3069f41 100644
--- a/src/utils/stringfilter.h
+++ b/src/utils/stringfilter.h
@@ -28,14 +28,12 @@ namespace utils
{
/**
- * Used to filter content containing bad words. Like username, character's names, chat, ...
+ * Used to filter content containing bad words. Like username, character's
+ * names, chat, ...
*/
class StringFilter
{
public:
- /**
- * ctors.
- */
StringFilter();
~StringFilter();
@@ -46,8 +44,7 @@ class StringFilter
* @return true is the config is loaded succesfully
*
*/
- bool
- loadSlangFilterList();
+ bool loadSlangFilterList();
/**
* Write slang list to the config file.
@@ -55,29 +52,25 @@ class StringFilter
* @return true is the config is loaded succesfully
*
*/
- void
- writeSlangFilterList();
+ void writeSlangFilterList();
/**
* Useful to filter slangs automatically, by instance.
* @return true if the sentence is slangs clear.
*/
- bool
- filterContent(const std::string& text);
+ bool filterContent(const std::string &text) const;
/**
* Tells if an email is valid
*/
- bool
- isEmailValid(const std::string& email);
+ bool isEmailValid(const std::string &email) const;
/**
* find double quotes (") in strings.
- * Very useful not to make SQL Queries bqsed on names crash
+ * Very useful not to make SQL Queries based on names crash
* I placed it here cause where you've got " you can have slangs...
*/
- bool
- findDoubleQuotes(const std::string& text);
+ bool findDoubleQuotes(const std::string &text) const;
private:
typedef std::list<std::string> Slangs;