summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/account-server/account.hpp20
-rw-r--r--src/account-server/accounthandler.cpp5
-rw-r--r--src/account-server/accounthandler.hpp2
-rw-r--r--src/account-server/character.cpp17
-rw-r--r--src/account-server/character.hpp14
-rw-r--r--src/account-server/dalstorage.cpp98
-rw-r--r--src/account-server/dalstorage.hpp22
-rw-r--r--src/account-server/dalstoragesql.hpp30
-rw-r--r--src/account-server/serverhandler.cpp9
-rw-r--r--src/account-server/serverhandler.hpp2
-rw-r--r--src/chat-server/chatchannelmanager.cpp2
-rw-r--r--src/common/configuration.cpp12
-rw-r--r--src/common/configuration.hpp10
-rw-r--r--src/game-server/accountconnection.cpp15
-rw-r--r--src/game-server/accountconnection.hpp8
-rw-r--r--src/game-server/being.cpp6
-rw-r--r--src/game-server/being.hpp12
-rw-r--r--src/game-server/character.cpp4
-rw-r--r--src/game-server/character.hpp6
-rw-r--r--src/game-server/command.cpp32
-rw-r--r--src/game-server/commandhandler.cpp37
-rw-r--r--src/game-server/eventlistener.hpp14
-rw-r--r--src/game-server/gamehandler.cpp21
-rw-r--r--src/game-server/gamehandler.hpp8
-rw-r--r--src/game-server/item.hpp6
-rw-r--r--src/game-server/itemmanager.cpp2
-rw-r--r--src/game-server/itemmanager.hpp4
-rw-r--r--src/game-server/mapcomposite.cpp30
-rw-r--r--src/game-server/mapcomposite.hpp30
-rw-r--r--src/game-server/mapmanager.cpp6
-rw-r--r--src/game-server/mapmanager.hpp6
-rw-r--r--src/game-server/mapreader.cpp6
-rw-r--r--src/game-server/mapreader.hpp15
-rw-r--r--src/game-server/monster.cpp2
-rw-r--r--src/game-server/monster.hpp4
-rw-r--r--src/game-server/monstermanager.cpp2
-rw-r--r--src/game-server/monstermanager.hpp4
-rw-r--r--src/game-server/postman.hpp4
-rw-r--r--src/game-server/quest.cpp22
-rw-r--r--src/game-server/quest.hpp18
-rw-r--r--src/game-server/resourcemanager.cpp4
-rw-r--r--src/game-server/resourcemanager.hpp4
-rw-r--r--src/game-server/spawnarea.hpp2
-rw-r--r--src/game-server/state.cpp16
-rw-r--r--src/game-server/state.hpp4
-rw-r--r--src/game-server/thing.cpp8
-rw-r--r--src/game-server/thing.hpp8
-rw-r--r--src/game-server/trigger.hpp4
-rw-r--r--src/net/connection.cpp7
-rw-r--r--src/net/connection.hpp4
-rw-r--r--src/net/messagein.cpp4
-rw-r--r--src/point.h4
-rw-r--r--src/scripting/lua.cpp10
-rw-r--r--src/scripting/luascript.cpp16
-rw-r--r--src/scripting/luascript.hpp15
-rw-r--r--src/scripting/script.cpp9
-rw-r--r--src/scripting/script.hpp15
-rw-r--r--src/serialize/characterdata.hpp6
-rw-r--r--src/utils/logger.cpp16
-rw-r--r--src/utils/logger.h7
-rw-r--r--src/utils/tokencollector.cpp4
-rw-r--r--src/utils/tokencollector.hpp8
-rw-r--r--src/utils/xml.cpp8
-rw-r--r--src/utils/xml.hpp10
64 files changed, 392 insertions, 368 deletions
diff --git a/src/account-server/account.hpp b/src/account-server/account.hpp
index d03b2657..b3758a2e 100644
--- a/src/account-server/account.hpp
+++ b/src/account-server/account.hpp
@@ -51,7 +51,7 @@ class Account
*
* @param name the user name.
*/
- void setName(std::string const &name)
+ void setName(const std::string &name)
{ mName = name; }
@@ -60,7 +60,7 @@ class Account
*
* @return the user name.
*/
- std::string const &getName() const
+ const std::string &getName() const
{ return mName; }
@@ -74,7 +74,7 @@ class Account
*
* @param password the user password (hashed with salt).
*/
- void setPassword(std::string const &password)
+ void setPassword(const std::string &password)
{ mPassword = password; }
@@ -83,7 +83,7 @@ class Account
*
* @return the user password (hashed with salt).
*/
- std::string const &getPassword() const
+ const std::string &getPassword() const
{ return mPassword; }
@@ -93,7 +93,7 @@ class Account
*
* @param email the user email address (hashed).
*/
- void setEmail(std::string const &email)
+ void setEmail(const std::string &email)
{ mEmail = email; }
@@ -102,7 +102,7 @@ class Account
*
* @return the user email address (hashed).
*/
- std::string const &getEmail() const
+ const std::string &getEmail() const
{ return mEmail; }
@@ -161,7 +161,7 @@ class Account
*
* @return all the characters.
*/
- Characters const &getCharacters() const
+ const Characters &getCharacters() const
{ return mCharacters; }
/**
@@ -205,11 +205,9 @@ class Account
void setLastLogin(time_t time);
private:
- Account(Account const &rhs);
- Account &operator=(Account const &rhs);
+ Account(const Account &rhs);
+ Account &operator=(const Account &rhs);
-
- private:
std::string mName; /**< User name */
std::string mPassword; /**< User password (hashed with salt) */
std::string mEmail; /**< User email address (hashed) */
diff --git a/src/account-server/accounthandler.cpp b/src/account-server/accounthandler.cpp
index 425a42ac..e785d809 100644
--- a/src/account-server/accounthandler.cpp
+++ b/src/account-server/accounthandler.cpp
@@ -108,7 +108,7 @@ void AccountClientHandler::process()
accountHandler->process(50);
}
-void AccountClientHandler::prepareReconnect(std::string const &token, int id)
+void AccountClientHandler::prepareReconnect(const std::string &token, int id)
{
accountHandler->mTokenCollector.addPendingConnect(token, id);
}
@@ -129,7 +129,8 @@ void AccountHandler::computerDisconnected(NetComputer *comp)
delete computer; // ~AccountClient unsets the account
}
-static void sendCharacterData(AccountClient &computer, int slot, Character const &ch)
+static void sendCharacterData(AccountClient &computer, int slot,
+ const Character &ch)
{
MessageOut charInfo(APMSG_CHAR_INFO);
charInfo.writeByte(slot);
diff --git a/src/account-server/accounthandler.hpp b/src/account-server/accounthandler.hpp
index cada0bfe..e509cb06 100644
--- a/src/account-server/accounthandler.hpp
+++ b/src/account-server/accounthandler.hpp
@@ -39,7 +39,7 @@ namespace AccountClientHandler
/**
* Prepares a connection for a client coming from a game server.
*/
- void prepareReconnect(std::string const &token, int accountID);
+ void prepareReconnect(const std::string &token, int accountID);
/**
* Processes messages received by the connection handler.
diff --git a/src/account-server/character.cpp b/src/account-server/character.cpp
index 68c8b250..0f0a261e 100644
--- a/src/account-server/character.cpp
+++ b/src/account-server/character.cpp
@@ -22,10 +22,19 @@
#include "account-server/account.hpp"
-Character::Character(std::string const &name, int id):
- mName(name), mDatabaseID(id), mAccountID(-1), mAccount(NULL), mPos(0,0), mMapId(0),
- mGender(0), mHairStyle(0), mHairColor(0), mLevel(0), mCharacterPoints(0),
- mCorrectionPoints(0), mAccountLevel(0)
+Character::Character(const std::string &name, int id):
+ mName(name),
+ mDatabaseID(id),
+ mAccountID(-1),
+ mAccount(NULL),
+ mMapId(0),
+ mGender(0),
+ mHairStyle(0),
+ mHairColor(0),
+ mLevel(0),
+ mCharacterPoints(0),
+ mCorrectionPoints(0),
+ mAccountLevel(0)
{
for (int i = 0; i < CHAR_ATTR_NB; ++i)
{
diff --git a/src/account-server/character.hpp b/src/account-server/character.hpp
index d63a0b0b..be53b9d1 100644
--- a/src/account-server/character.hpp
+++ b/src/account-server/character.hpp
@@ -35,7 +35,7 @@ class Character
{
public:
- Character(std::string const &name, int id = -1);
+ Character(const std::string &name, int id = -1);
/**
* Gets the database id of the character.
@@ -59,8 +59,8 @@ class Character
/**
* Gets the name of the character.
*/
- std::string const &getName() const { return mName; }
- void setName(const std::string& name) { mName = name; }
+ const std::string &getName() const { return mName; }
+ void setName(const std::string &name) { mName = name; }
/**
* Gets the gender of the character (male / female).
@@ -123,7 +123,7 @@ class Character
/**
* Gets the position of the character on the map.
*/
- Point const &getPosition() const { return mPos; }
+ const Point &getPosition() const { return mPos; }
void setPosition(const Point &p) { mPos = p; }
/** Add a guild to the character */
@@ -136,7 +136,7 @@ class Character
/**
* Gets a reference on the possessions.
*/
- Possessions const &getPossessions() const
+ const Possessions &getPossessions() const
{ return mPossessions; }
/**
@@ -159,8 +159,8 @@ class Character
private:
- Character(Character const &);
- Character &operator=(Character const &);
+ Character(const Character &);
+ Character &operator=(const Character &);
Possessions mPossessions; //!< All the possesions of the character.
std::string mName; //!< Name of the character.
diff --git a/src/account-server/dalstorage.cpp b/src/account-server/dalstorage.cpp
index 086487f3..5cf8ebf6 100644
--- a/src/account-server/dalstorage.cpp
+++ b/src/account-server/dalstorage.cpp
@@ -117,10 +117,10 @@ void DALStorage::close()
mDb->disconnect();
}
-Account *DALStorage::getAccountBySQL(std::string const &query)
+Account *DALStorage::getAccountBySQL(const std::string &query)
{
try {
- dal::RecordSet const &accountInfo = mDb->execSql(query);
+ const dal::RecordSet &accountInfo = mDb->execSql(query);
// if the account is not even in the database then
// we have no choice but to return nothing.
@@ -158,7 +158,7 @@ Account *DALStorage::getAccountBySQL(std::string const &query)
std::ostringstream sql;
sql << "select id from " << CHARACTERS_TBL_NAME << " where user_id = '"
<< id << "';";
- dal::RecordSet const &charInfo = mDb->execSql(sql.str());
+ const dal::RecordSet &charInfo = mDb->execSql(sql.str());
if (!charInfo.isEmpty())
{
@@ -191,7 +191,7 @@ Account *DALStorage::getAccountBySQL(std::string const &query)
return account;
}
- catch (dal::DbSqlQueryExecFailure const &e)
+ catch (const dal::DbSqlQueryExecFailure &e)
{
LOG_ERROR("DALStorage::getAccountBySQL: " << e.what());
return NULL; // TODO: Throw exception here
@@ -201,7 +201,7 @@ Account *DALStorage::getAccountBySQL(std::string const &query)
/**
* Get an account by user name.
*/
-Account *DALStorage::getAccount(std::string const &userName)
+Account *DALStorage::getAccount(const std::string &userName)
{
std::ostringstream sql;
sql << "select * from " << ACCOUNTS_TBL_NAME << " where username = \"" << userName << "\";";
@@ -218,7 +218,7 @@ Account *DALStorage::getAccount(int accountID)
return getAccountBySQL(sql.str());
}
-Character *DALStorage::getCharacterBySQL(std::string const &query, Account *owner)
+Character *DALStorage::getCharacterBySQL(const std::string &query, Account *owner)
{
Character *character;
@@ -227,7 +227,7 @@ Character *DALStorage::getCharacterBySQL(std::string const &query, Account *owne
string_to< unsigned > toUint;
try {
- dal::RecordSet const &charInfo = mDb->execSql(query);
+ const dal::RecordSet &charInfo = mDb->execSql(query);
// if the character is not even in the database then
// we have no choice but to return nothing.
@@ -281,7 +281,7 @@ Character *DALStorage::getCharacterBySQL(std::string const &query, Account *owne
std::ostringstream s;
s << "select level from " << ACCOUNTS_TBL_NAME
<< " where id = '" << id << "';";
- dal::RecordSet const &levelInfo = mDb->execSql(s.str());
+ const dal::RecordSet &levelInfo = mDb->execSql(s.str());
character->setAccountLevel(toUint(levelInfo(0, 0)), true);
}
@@ -291,7 +291,7 @@ Character *DALStorage::getCharacterBySQL(std::string const &query, Account *owne
<< "FROM " << CHAR_SKILLS_TBL_NAME << " "
<< "WHERE char_id = " << character->getDatabaseID();
- dal::RecordSet const &skillInfo = mDb->execSql(s.str());
+ const dal::RecordSet &skillInfo = mDb->execSql(s.str());
if (!skillInfo.isEmpty())
{
const unsigned int nRows = skillInfo.rows();
@@ -303,7 +303,7 @@ Character *DALStorage::getCharacterBySQL(std::string const &query, Account *owne
}
}
}
- catch (dal::DbSqlQueryExecFailure const &e)
+ catch (const dal::DbSqlQueryExecFailure &e)
{
LOG_ERROR("(DALStorage::getCharacter #1) SQL query failure: " << e.what());
return NULL;
@@ -315,7 +315,7 @@ Character *DALStorage::getCharacterBySQL(std::string const &query, Account *owne
sql << " select * from " << INVENTORIES_TBL_NAME << " where owner_id = '"
<< character->getDatabaseID() << "' order by slot asc;";
- dal::RecordSet const &itemInfo = mDb->execSql(sql.str());
+ const dal::RecordSet &itemInfo = mDb->execSql(sql.str());
if (!itemInfo.isEmpty())
{
Possessions &poss = character->getPossessions();
@@ -351,7 +351,7 @@ Character *DALStorage::getCharacterBySQL(std::string const &query, Account *owne
}
}
}
- catch (dal::DbSqlQueryExecFailure const &e)
+ catch (const dal::DbSqlQueryExecFailure &e)
{
LOG_ERROR("(DALStorage::getCharacter #2) SQL query failure: " << e.what());
return NULL;
@@ -412,19 +412,19 @@ DALStorage::getEmailList()
}
#endif
-bool DALStorage::doesUserNameExist(std::string const &name)
+bool DALStorage::doesUserNameExist(const std::string &name)
{
try {
std::ostringstream sql;
sql << "select count(username) from " << ACCOUNTS_TBL_NAME
<< " where username = \"" << name << "\";";
- dal::RecordSet const &accountInfo = mDb->execSql(sql.str());
+ const dal::RecordSet &accountInfo = mDb->execSql(sql.str());
std::istringstream ssStream(accountInfo(0, 0));
unsigned int iReturn = 1;
ssStream >> iReturn;
return iReturn != 0;
- } catch (std::exception const &e) {
+ } catch (const std::exception &e) {
// TODO: throw an exception.
LOG_ERROR("(DALStorage::doesUserNameExist) SQL query failure: " << e.what());
}
@@ -436,19 +436,19 @@ bool DALStorage::doesUserNameExist(std::string const &name)
* Tells if the email address already exists
* @return true if the email address exists.
*/
-bool DALStorage::doesEmailAddressExist(std::string const &email)
+bool DALStorage::doesEmailAddressExist(const std::string &email)
{
try {
std::ostringstream sql;
sql << "select count(email) from " << ACCOUNTS_TBL_NAME
<< " where upper(email) = upper(\"" << email << "\");";
- dal::RecordSet const &accountInfo = mDb->execSql(sql.str());
+ const dal::RecordSet &accountInfo = mDb->execSql(sql.str());
std::istringstream ssStream(accountInfo(0, 0));
unsigned int iReturn = 1;
ssStream >> iReturn;
return iReturn != 0;
- } catch (std::exception const &e) {
+ } catch (const std::exception &e) {
// TODO: throw an exception.
LOG_ERROR("(DALStorage::doesEmailAddressExist) SQL query failure: " << e.what());
}
@@ -466,13 +466,13 @@ bool DALStorage::doesCharacterNameExist(const std::string& name)
std::ostringstream sql;
sql << "select count(name) from " << CHARACTERS_TBL_NAME
<< " where name = \"" << name << "\";";
- dal::RecordSet const &accountInfo = mDb->execSql(sql.str());
+ const dal::RecordSet &accountInfo = mDb->execSql(sql.str());
std::istringstream ssStream(accountInfo(0, 0));
int iReturn = 1;
ssStream >> iReturn;
return iReturn != 0;
- } catch (std::exception const &e) {
+ } catch (const std::exception &e) {
// TODO: throw an exception.
LOG_ERROR("(DALStorage::doesCharacterNameExist) SQL query failure: "
<< e.what());
@@ -588,7 +588,7 @@ bool DALStorage::updateCharacter(Character *character,
<< character->getDatabaseID() << ", ";
std::string base = sql.str();
- Possessions const &poss = character->getPossessions();
+ const Possessions &poss = character->getPossessions();
for (int j = 0; j < EQUIPMENT_SLOTS; ++j)
{
@@ -1087,7 +1087,7 @@ std::list<Guild*> DALStorage::getGuildList()
return guilds;
}
-std::string DALStorage::getQuestVar(int id, std::string const &name)
+std::string DALStorage::getQuestVar(int id, const std::string &name)
{
try
{
@@ -1095,11 +1095,11 @@ std::string DALStorage::getQuestVar(int id, std::string const &name)
query << "select value from " << QUESTS_TBL_NAME
<< " where owner_id = '" << id << "' and name = '"
<< name << "';";
- dal::RecordSet const &info = mDb->execSql(query.str());
+ const dal::RecordSet &info = mDb->execSql(query.str());
if (!info.isEmpty()) return info(0, 0);
}
- catch (dal::DbSqlQueryExecFailure const &e)
+ catch (const dal::DbSqlQueryExecFailure &e)
{
LOG_ERROR("(DALStorage::getQuestVar) SQL query failure: " << e.what());
}
@@ -1107,7 +1107,7 @@ std::string DALStorage::getQuestVar(int id, std::string const &name)
return std::string();
}
-std::string DALStorage::getWorldStateVar(std::string const &name, int map_id)
+std::string DALStorage::getWorldStateVar(const std::string &name, int map_id)
{
try
{
@@ -1123,11 +1123,11 @@ std::string DALStorage::getWorldStateVar(std::string const &name, int map_id)
}
query << ";";
- dal::RecordSet const &info = mDb->execSql(query.str());
+ const dal::RecordSet &info = mDb->execSql(query.str());
if (!info.isEmpty()) return info(0, 0);
}
- catch (dal::DbSqlQueryExecFailure const &e)
+ catch (const dal::DbSqlQueryExecFailure &e)
{
LOG_ERROR("(DALStorage::getWorldStateVar) SQL query failure: " << e.what());
}
@@ -1135,14 +1135,14 @@ std::string DALStorage::getWorldStateVar(std::string const &name, int map_id)
return std::string();
}
-void DALStorage::setWorldStateVar(std::string const &name, std::string const &value)
+void DALStorage::setWorldStateVar(const std::string &name, const std::string &value)
{
return setWorldStateVar(name, -1, value);
}
-void DALStorage::setWorldStateVar(std::string const &name,
+void DALStorage::setWorldStateVar(const std::string &name,
int map_id,
- std::string const &value)
+ const std::string &value)
{
try
{
@@ -1198,14 +1198,14 @@ void DALStorage::setWorldStateVar(std::string const &name,
<< "'" << time(NULL) << "');";
mDb->execSql(insertStateVar.str());
}
- catch (dal::DbSqlQueryExecFailure const &e)
+ catch (const dal::DbSqlQueryExecFailure &e)
{
LOG_ERROR("(DALStorage::setWorldStateVar) SQL query failure: " << e.what());
}
}
-void DALStorage::setQuestVar(int id, std::string const &name,
- std::string const &value)
+void DALStorage::setQuestVar(int id, const std::string &name,
+ const std::string &value)
{
try
{
@@ -1223,7 +1223,7 @@ void DALStorage::setQuestVar(int id, std::string const &name,
<< id << "', '" << name << "', '" << value << "');";
mDb->execSql(query2.str());
}
- catch (dal::DbSqlQueryExecFailure const &e)
+ catch (const dal::DbSqlQueryExecFailure &e)
{
LOG_ERROR("(DALStorage::setQuestVar) SQL query failure: " << e.what());
}
@@ -1236,7 +1236,7 @@ void DALStorage::banCharacter(int id, int duration)
std::ostringstream query;
query << "select user_id from " << CHARACTERS_TBL_NAME
<< " where id = '" << id << "';";
- dal::RecordSet const &info = mDb->execSql(query.str());
+ const dal::RecordSet &info = mDb->execSql(query.str());
if (info.isEmpty())
{
LOG_ERROR("Tried to ban an unknown user.");
@@ -1250,7 +1250,7 @@ void DALStorage::banCharacter(int id, int duration)
<< "' where id = '" << info(0, 0) << "';";
mDb->execSql(sql.str());
}
- catch (dal::DbSqlQueryExecFailure const &e)
+ catch (const dal::DbSqlQueryExecFailure &e)
{
LOG_ERROR("(DALStorage::banAccount) SQL query failure: " << e.what());
}
@@ -1314,7 +1314,7 @@ void DALStorage::delCharacter(int charId, bool startTransaction = true) const
if (startTransaction)
mDb->commitTransaction();
}
- catch (dal::DbSqlQueryExecFailure const &e)
+ catch (const dal::DbSqlQueryExecFailure &e)
{
if (startTransaction)
mDb->rollbackTransaction();
@@ -1340,7 +1340,7 @@ void DALStorage::checkBannedAccounts()
<< " AND banned <= " << time(NULL) << ";";
mDb->execSql(sql.str());
}
- catch (dal::DbSqlQueryExecFailure const &e)
+ catch (const dal::DbSqlQueryExecFailure &e)
{
LOG_ERROR("(DALStorage::checkBannedAccounts) SQL query failure: " << e.what());
}
@@ -1356,7 +1356,7 @@ void DALStorage::setAccountLevel(int id, int level)
<< " where id = " << id << ";";
mDb->execSql(sql.str());
}
- catch (dal::DbSqlQueryExecFailure const &e)
+ catch (const dal::DbSqlQueryExecFailure &e)
{
LOG_ERROR("(DALStorage::setAccountLevel) SQL query failure: " << e.what());
}
@@ -1372,7 +1372,7 @@ void DALStorage::setPlayerLevel(int id, int level)
<< " where id = " << id << ";";
mDb->execSql(sql.str());
}
- catch (dal::DbSqlQueryExecFailure const &e)
+ catch (const dal::DbSqlQueryExecFailure &e)
{
LOG_ERROR("(DALStorage::setPlayerLevel) SQL query failure: " << e.what());
}
@@ -1435,7 +1435,7 @@ Post* DALStorage::getStoredPost(int playerId)
sql << "SELECT * FROM " << POST_TBL_NAME
<< " WHERE receiver_id = " << playerId;
- dal::RecordSet const &post = mDb->execSql(sql.str());
+ const dal::RecordSet &post = mDb->execSql(sql.str());
if (post.isEmpty())
{
@@ -1488,7 +1488,7 @@ void DALStorage::deletePost(Letter* letter)
mDb->commitTransaction();
letter->setId(0);
}
- catch(dal::DbSqlQueryExecFailure const &e)
+ catch(const dal::DbSqlQueryExecFailure &e)
{
mDb->rollbackTransaction();
LOG_ERROR("(DALStorage::deletePost) SQL query failure: " << e.what());
@@ -1581,7 +1581,7 @@ void DALStorage::SyncDatabase(void)
}
itmCount++;
}
- catch (dal::DbSqlQueryExecFailure const &e)
+ catch (const dal::DbSqlQueryExecFailure &e)
{
LOG_ERROR("(DALStorage::SyncDatabase) SQL query failure: " << e.what());
}
@@ -1623,7 +1623,7 @@ void DALStorage::setOnlineStatus(int charId, bool online)
}
- catch (dal::DbSqlQueryExecFailure const &e)
+ catch (const dal::DbSqlQueryExecFailure &e)
{
LOG_ERROR("(DALStorage::setOnlineStatus) SQL query failure: " << e.what());
}
@@ -1639,7 +1639,7 @@ void DALStorage::addTransaction(const Transaction &trans)
<< ", '" << trans.mMessage << "', " << time(NULL) << ")";
mDb->execSql(sql.str());
}
- catch (dal::DbSqlQueryExecFailure const &e)
+ catch (const dal::DbSqlQueryExecFailure &e)
{
LOG_ERROR("(DALStorage::addTransaction) SQL query failure: " << e.what());
}
@@ -1654,7 +1654,7 @@ std::vector<Transaction> DALStorage::getTransactions(unsigned int num)
{
std::stringstream sql;
sql << "SELECT * FROM " << TRANSACTION_TBL_NAME;
- dal::RecordSet const &rec = mDb->execSql(sql.str());
+ const dal::RecordSet &rec = mDb->execSql(sql.str());
int size = rec.rows();
int start = size - num;
@@ -1668,7 +1668,7 @@ std::vector<Transaction> DALStorage::getTransactions(unsigned int num)
transactions.push_back(trans);
}
}
- catch (dal::DbSqlQueryExecFailure const &e)
+ catch (const dal::DbSqlQueryExecFailure &e)
{
LOG_ERROR("(DALStorage::getTransactions) SQL query failure: " << e.what());
}
@@ -1686,7 +1686,7 @@ std::vector<Transaction> DALStorage::getTransactions(time_t date)
std::stringstream sql;
sql << "SELECT * FROM " << TRANSACTION_TBL_NAME << " WHERE time > "
<< date;
- dal::RecordSet const &rec = mDb->execSql(sql.str());
+ const dal::RecordSet &rec = mDb->execSql(sql.str());
for (unsigned int i = 0; i < rec.rows(); ++i)
{
@@ -1697,7 +1697,7 @@ std::vector<Transaction> DALStorage::getTransactions(time_t date)
transactions.push_back(trans);
}
}
- catch (dal::DbSqlQueryExecFailure const &e)
+ catch (const dal::DbSqlQueryExecFailure &e)
{
LOG_ERROR("(DALStorage::getTransactions) SQL query failure: " << e.what());
}
diff --git a/src/account-server/dalstorage.hpp b/src/account-server/dalstorage.hpp
index 8ff796af..8778b64c 100644
--- a/src/account-server/dalstorage.hpp
+++ b/src/account-server/dalstorage.hpp
@@ -182,19 +182,19 @@ class DALStorage
* Tells if the user name already exists.
* @return true if the user name exists.
*/
- bool doesUserNameExist(std::string const &name);
+ bool doesUserNameExist(const std::string &name);
/**
* Tells if the email address already exists.
* @return true if the email address exists.
*/
- bool doesEmailAddressExist(std::string const &email);
+ bool doesEmailAddressExist(const std::string &email);
/**
* Tells if the character name already exists.
* @return true if the character name exists.
*/
- bool doesCharacterNameExist(std::string const &name);
+ bool doesCharacterNameExist(const std::string &name);
/**
* Updates the data for a single character, does not update the
@@ -274,12 +274,12 @@ class DALStorage
/**
* Gets the value of a quest variable.
*/
- std::string getQuestVar(int id, std::string const &);
+ std::string getQuestVar(int id, const std::string &);
/**
* Sets the value of a quest variable.
*/
- void setQuestVar(int id, std::string const &, std::string const &);
+ void setQuestVar(int id, const std::string &, const std::string &);
/**
* Gets the string value of a map specific world state variable.
@@ -287,7 +287,7 @@ class DALStorage
* @param name Name of the requested world-state variable.
* @param map_id Id of the specific map.
*/
- std::string getWorldStateVar(std::string const &name, int map_id = -1);
+ std::string getWorldStateVar(const std::string &name, int map_id = -1);
/**
* Sets the value of a world state variable.
@@ -295,7 +295,7 @@ class DALStorage
* @param name Name of the world-state vairable.
* @param value New value of the world-state variable.
*/
- void setWorldStateVar(std::string const &name, std::string const &value);
+ void setWorldStateVar(const std::string &name, const std::string &value);
/**
* Sets the value of a world state variable of a specific map.
@@ -304,8 +304,8 @@ class DALStorage
* @param map_id ID of the specific map
* @param value New value of the world-state variable.
*/
- void setWorldStateVar(std::string const &name, int map_id,
- std::string const &value);
+ void setWorldStateVar(const std::string &name, int map_id,
+ const std::string &value);
/**
* Set the level on an account
@@ -401,7 +401,7 @@ class DALStorage
*
* @return the account found by the query
*/
- Account *getAccountBySQL(std::string const &query);
+ Account *getAccountBySQL(const std::string &query);
/**
@@ -412,7 +412,7 @@ class DALStorage
*
* @return the character found by the query.
*/
- Character *getCharacterBySQL(std::string const &query, Account *owner);
+ Character *getCharacterBySQL(const std::string &query, Account *owner);
/**
* Synchronizes the base data in the connected SQL database with the xml
diff --git a/src/account-server/dalstoragesql.hpp b/src/account-server/dalstoragesql.hpp
index 34cdec5b..1661baa6 100644
--- a/src/account-server/dalstoragesql.hpp
+++ b/src/account-server/dalstoragesql.hpp
@@ -62,85 +62,85 @@
/**
* TABLE: tmw_accounts.
*/
-static char const *ACCOUNTS_TBL_NAME = "tmw_accounts";
+static const char *ACCOUNTS_TBL_NAME = "tmw_accounts";
/**
* TABLE: tmw_characters.
* - gender is 0 for male, 1 for female.
*/
-static char const *CHARACTERS_TBL_NAME = "tmw_characters";
+static const char *CHARACTERS_TBL_NAME = "tmw_characters";
/**
* TABLE: tmw_char_skills.
*/
-static char const *CHAR_SKILLS_TBL_NAME = "tmw_char_skills";
+static const char *CHAR_SKILLS_TBL_NAME = "tmw_char_skills";
/**
* TABLE: tmw_inventories.
*/
-static char const *INVENTORIES_TBL_NAME("tmw_inventories");
+static const char *INVENTORIES_TBL_NAME("tmw_inventories");
/**
* TABLE: tmw_items.
*/
-static char const *ITEMS_TBL_NAME("tmw_items");
+static const char *ITEMS_TBL_NAME("tmw_items");
/**
* TABLE: tmw_guilds.
* Store player guilds
*/
-static char const *GUILDS_TBL_NAME = "tmw_guilds";
+static const char *GUILDS_TBL_NAME = "tmw_guilds";
/**
* TABLE: tmw_guild_members.
* Store guild members
*/
-static char const *GUILD_MEMBERS_TBL_NAME = "tmw_guild_members";
+static const char *GUILD_MEMBERS_TBL_NAME = "tmw_guild_members";
/**
* TABLE: tmw_quests.
*/
-static char const *QUESTS_TBL_NAME = "tmw_quests";
+static const char *QUESTS_TBL_NAME = "tmw_quests";
/**
* TABLE: tmw_world_states
*/
-static char const *WORLD_STATES_TBL_NAME = "tmw_world_states";
+static const char *WORLD_STATES_TBL_NAME = "tmw_world_states";
/**
* TABLE: tmw_post
* Store letters sent by characters
*/
-static char const *POST_TBL_NAME = "tmw_post";
+static const char *POST_TBL_NAME = "tmw_post";
/**
* TABLE: tmw_post_attachments
* Store attachments per letter.
*/
-static char const *POST_ATTACHMENTS_TBL_NAME = "tmw_post_attachments";
+static const char *POST_ATTACHMENTS_TBL_NAME = "tmw_post_attachments";
/**
* TABLE: tmw_auctions
* Store items auctions.
*/
-static char const *AUCTION_TBL_NAME = "tmw_auctions";
+static const char *AUCTION_TBL_NAME = "tmw_auctions";
/**
* TABLE: tmw_auction_bids
* Store bids on auctions.
*/
-static char const *AUCTION_BIDS_TBL_NAME = "tmw_auction_bids";
+static const char *AUCTION_BIDS_TBL_NAME = "tmw_auction_bids";
/**
* TABLE: tmw_online_list
* List currently online users.
*/
-static char const *ONLINE_USERS_TBL_NAME = "tmw_online_list";
+static const char *ONLINE_USERS_TBL_NAME = "tmw_online_list";
/**
* TABLE: tmw_transactions
* Stores all transactions
*/
-static char const *TRANSACTION_TBL_NAME = "tmw_transactions";
+static const char *TRANSACTION_TBL_NAME = "tmw_transactions";
#endif // _TMWSERV_DALSTORAGE_SQL_H_
diff --git a/src/account-server/serverhandler.cpp b/src/account-server/serverhandler.cpp
index f5409b6a..56aba6ba 100644
--- a/src/account-server/serverhandler.cpp
+++ b/src/account-server/serverhandler.cpp
@@ -144,8 +144,8 @@ bool GameServerHandler::getGameServerFromMap
return false;
}
-static void registerGameClient
- (GameServer *s, std::string const &token, Character *ptr)
+static void registerGameClient(GameServer *s, const std::string &token,
+ Character *ptr)
{
MessageOut msg(AGMSG_PLAYER_ENTER);
msg.writeString(token, MAGIC_TOKEN_LENGTH);
@@ -155,7 +155,8 @@ static void registerGameClient
s->send(msg);
}
-void GameServerHandler::registerClient(std::string const &token, Character *ptr)
+void GameServerHandler::registerClient(const std::string &token,
+ Character *ptr)
{
GameServer *s = ::getGameServerFromMap(ptr->getMapId());
assert(s);
@@ -506,7 +507,7 @@ void GameServerHandler::dumpStatistics(std::ostream &os)
for (ServerStatistics::const_iterator j = server->maps.begin(),
j_end = server->maps.end(); j != j_end; ++j)
{
- MapStatistics const &m = j->second;
+ const MapStatistics &m = j->second;
os << "<map id=\"" << j->first << "\" nb_things=\"" << m.nbThings
<< "\" nb_monsters=\"" << m.nbMonsters << "\">\n";
for (std::vector< int >::const_iterator k = m.players.begin(),
diff --git a/src/account-server/serverhandler.hpp b/src/account-server/serverhandler.hpp
index 646ebf4c..f89c6ddc 100644
--- a/src/account-server/serverhandler.hpp
+++ b/src/account-server/serverhandler.hpp
@@ -50,7 +50,7 @@ namespace GameServerHandler
/**
* Warns a game server about a soon-to-connect client.
*/
- void registerClient(std::string const &token, Character *);
+ void registerClient(const std::string &token, Character *);
/**
* Dumps per-server statistics into given stream
diff --git a/src/chat-server/chatchannelmanager.cpp b/src/chat-server/chatchannelmanager.cpp
index d78e4bb2..7ec80072 100644
--- a/src/chat-server/chatchannelmanager.cpp
+++ b/src/chat-server/chatchannelmanager.cpp
@@ -114,7 +114,7 @@ std::list<const ChatChannel*> ChatChannelManager::getPublicChannels()
return channels;
}
-int ChatChannelManager::getChannelId(std::string const &channelName)
+int ChatChannelManager::getChannelId(const std::string &channelName)
{
for (ChatChannels::const_iterator i = mChatChannels.begin(),
i_end = mChatChannels.end();
diff --git a/src/common/configuration.cpp b/src/common/configuration.cpp
index 6037029e..4b52b65e 100644
--- a/src/common/configuration.cpp
+++ b/src/common/configuration.cpp
@@ -33,7 +33,7 @@ static std::map< std::string, std::string > options;
/**< Location of config file. */
static std::string configPath;
-void Configuration::initialize(std::string const &filename)
+void Configuration::initialize(const std::string &filename)
{
configPath = filename;
@@ -92,27 +92,27 @@ void Configuration::deinitialize()
}
}
-void Configuration::setValue(std::string const &key, std::string const &value)
+void Configuration::setValue(const std::string &key, const std::string &value)
{
options[key] = value;
}
-void Configuration::setValue(std::string const &key, int value)
+void Configuration::setValue(const std::string &key, int value)
{
std::ostringstream ss;
ss << value;
setValue(key, ss.str());
}
-std::string const &Configuration::getValue(std::string const &key,
- std::string const &deflt)
+const std::string &Configuration::getValue(const std::string &key,
+ const std::string &deflt)
{
std::map<std::string, std::string>::iterator iter = options.find(key);
if (iter == options.end()) return deflt;
return iter->second;
}
-int Configuration::getValue(std::string const &key, int deflt)
+int Configuration::getValue(const std::string &key, int deflt)
{
std::map<std::string, std::string>::iterator iter = options.find(key);
if (iter == options.end()) return deflt;
diff --git a/src/common/configuration.hpp b/src/common/configuration.hpp
index 8da25978..1c1a9ce0 100644
--- a/src/common/configuration.hpp
+++ b/src/common/configuration.hpp
@@ -30,7 +30,7 @@ namespace Configuration
* Loads the configuration options into memory.
* @param filename path to the configuration file .
*/
- void initialize(std::string const &filename);
+ void initialize(const std::string &filename);
/**
* Writes the current settings back to the configuration file.
@@ -42,28 +42,28 @@ namespace Configuration
* @param key option identifier.
* @param value Value.
*/
- void setValue(std::string const &key, std::string const &value);
+ void setValue(const std::string &key, const std::string &value);
/**
* Sets an option to a given value.
* @param key option identifier.
* @param value value.
*/
- void setValue(std::string const &key, int value);
+ void setValue(const std::string &key, int value);
/**
* Gets an option as a string.
* @param key option identifier.
* @param deflt default value.
*/
- std::string const &getValue(std::string const &key, std::string const &deflt);
+ const std::string &getValue(const std::string &key, const std::string &deflt);
/**
* Gets an option as a string.
* @param key option identifier.
* @param deflt default value.
*/
- int getValue(std::string const &key, int deflt);
+ int getValue(const std::string &key, int deflt);
}
#ifndef DEFAULT_SERVER_PORT
diff --git a/src/game-server/accountconnection.cpp b/src/game-server/accountconnection.cpp
index 10bc6b46..41f71627 100644
--- a/src/game-server/accountconnection.cpp
+++ b/src/game-server/accountconnection.cpp
@@ -73,7 +73,7 @@ bool AccountConnection::start()
msg.writeString(gameServerAddress);
msg.writeShort(gameServerPort);
msg.writeLong(ItemManager::GetDatabaseVersion());
- MapManager::Maps const &m = MapManager::getMaps();
+ const MapManager::Maps &m = MapManager::getMaps();
for (MapManager::Maps::const_iterator i = m.begin(), i_end = m.end();
i != i_end; ++i)
{
@@ -195,7 +195,8 @@ void AccountConnection::processMessage(MessageIn &msg)
}
}
-void AccountConnection::playerReconnectAccount(int id, std::string const &magic_token)
+void AccountConnection::playerReconnectAccount(int id,
+ const std::string &magic_token)
{
LOG_DEBUG("Send GAMSG_PLAYER_RECONNECT.");
MessageOut msg(GAMSG_PLAYER_RECONNECT);
@@ -204,7 +205,7 @@ void AccountConnection::playerReconnectAccount(int id, std::string const &magic_
send(msg);
}
-void AccountConnection::requestQuestVar(Character *ch, std::string const &name)
+void AccountConnection::requestQuestVar(Character *ch, const std::string &name)
{
MessageOut msg(GAMSG_GET_QUEST);
msg.writeLong(ch->getDatabaseID());
@@ -212,8 +213,8 @@ void AccountConnection::requestQuestVar(Character *ch, std::string const &name)
send(msg);
}
-void AccountConnection::updateQuestVar(Character *ch, std::string const &name,
- std::string const &value)
+void AccountConnection::updateQuestVar(Character *ch, const std::string &name,
+ const std::string &value)
{
MessageOut msg(GAMSG_SET_QUEST);
msg.writeLong(ch->getDatabaseID());
@@ -233,7 +234,7 @@ void AccountConnection::banCharacter(Character *ch, int duration)
void AccountConnection::sendStatistics()
{
MessageOut msg(GAMSG_STATISTICS);
- MapManager::Maps const &maps = MapManager::getMaps();
+ const MapManager::Maps &maps = MapManager::getMaps();
for (MapManager::Maps::const_iterator i = maps.begin(),
i_end = maps.end(); i != i_end; ++i)
{
@@ -242,7 +243,7 @@ void AccountConnection::sendStatistics()
msg.writeShort(i->first);
int nbThings = 0, nbMonsters = 0;
typedef std::vector< Thing * > Things;
- Things const &things = m->getEverything();
+ const Things &things = m->getEverything();
std::vector< int > players;
for (Things::const_iterator j = things.begin(),
j_end = things.end(); j != j_end; ++j)
diff --git a/src/game-server/accountconnection.hpp b/src/game-server/accountconnection.hpp
index da42ea97..1cbe6d82 100644
--- a/src/game-server/accountconnection.hpp
+++ b/src/game-server/accountconnection.hpp
@@ -73,18 +73,18 @@ class AccountConnection : public Connection
/**
* Prepares the account server for a reconnecting player
*/
- void playerReconnectAccount(int id, std::string const &magic_token);
+ void playerReconnectAccount(int id, const std::string &magic_token);
/**
* Requests the value of a quest variable from the database.
*/
- void requestQuestVar(Character *, std::string const &);
+ void requestQuestVar(Character *, const std::string &);
/**
* Pushes a new quest value to the database.
*/
- void updateQuestVar(Character *, std::string const &name,
- std::string const &value);
+ void updateQuestVar(Character *, const std::string &name,
+ const std::string &value);
/**
* Sends ban message.
diff --git a/src/game-server/being.cpp b/src/game-server/being.cpp
index 7319bcbe..a1991551 100644
--- a/src/game-server/being.cpp
+++ b/src/game-server/being.cpp
@@ -46,7 +46,7 @@ Being::Being(ThingType type):
}
}
-int Being::damage(Actor *, Damage const &damage)
+int Being::damage(Actor *, const Damage &damage)
{
if (mAction == DEAD)
return 0;
@@ -108,7 +108,7 @@ void Being::died()
for (Listeners::iterator i = mListeners.begin(),
i_end = mListeners.end(); i != i_end;)
{
- EventListener const &l = **i;
+ const EventListener &l = **i;
++i; // In case the listener removes itself from the list on the fly.
if (l.dispatch->died) l.dispatch->died(&l, this);
}
@@ -218,7 +218,7 @@ int Being::directionToAngle(int direction)
}
}
-void Being::performAttack(Damage const &damage, AttackZone const *attackZone)
+void Being::performAttack(const Damage &damage, const AttackZone *attackZone)
{
Point ppos = getPosition();
const int attackAngle = directionToAngle(getDirection());
diff --git a/src/game-server/being.hpp b/src/game-server/being.hpp
index 500754e4..92957096 100644
--- a/src/game-server/being.hpp
+++ b/src/game-server/being.hpp
@@ -138,7 +138,7 @@ class Being : public Actor
* stats, deducts the result from the hitpoints and adds the result to
* the HitsTaken list.
*/
- virtual int damage(Actor *source, Damage const &damage);
+ virtual int damage(Actor *source, const Damage &damage);
/**
* Changes status and calls all the "died" listeners.
@@ -153,7 +153,7 @@ class Being : public Actor
/**
* Gets the destination coordinates of the being.
*/
- Point const &getDestination() const
+ const Point &getDestination() const
{ return mDst; }
/**
@@ -193,7 +193,7 @@ class Being : public Actor
/**
* Gets the damage list.
*/
- Hits const &getHitsTaken() const
+ const Hits &getHitsTaken() const
{ return mHitsTaken; }
/**
@@ -205,7 +205,7 @@ class Being : public Actor
/**
* Performs an attack.
*/
- void performAttack(Damage const &, AttackZone const *attackZone);
+ void performAttack(const Damage &, const AttackZone *attackZone);
/**
* Sets the current action.
@@ -284,8 +284,8 @@ class Being : public Actor
std::vector< Attribute > mAttributes;
private:
- Being(Being const &rhs);
- Being &operator=(Being const &rhs);
+ Being(const Being &rhs);
+ Being &operator=(const Being &rhs);
std::list<PATH_NODE> mPath;
Point mOld; /**< Old coordinates. */
diff --git a/src/game-server/character.cpp b/src/game-server/character.cpp
index 1d32914f..f9a9b588 100644
--- a/src/game-server/character.cpp
+++ b/src/game-server/character.cpp
@@ -139,7 +139,7 @@ void Character::perform()
if (ic)
{
// weapon fighting
- ItemModifiers const &mods = ic->getModifiers();
+ const ItemModifiers &mods = ic->getModifiers();
damage.element = mods.getValue(MOD_ELEMENT_TYPE);
performAttack(damage, ic->getAttackZone());
}
@@ -502,7 +502,7 @@ void Character::disconnected()
for (Listeners::iterator i = mListeners.begin(),
i_end = mListeners.end(); i != i_end;)
{
- EventListener const &l = **i;
+ const EventListener &l = **i;
++i; // In case the listener removes itself from the list on the fly.
if (l.dispatch->disconnected) l.dispatch->disconnected(&l, this);
}
diff --git a/src/game-server/character.hpp b/src/game-server/character.hpp
index 33be114e..f930c33b 100644
--- a/src/game-server/character.hpp
+++ b/src/game-server/character.hpp
@@ -102,7 +102,7 @@ class Character : public Being
/**
* Gets a reference on the possessions.
*/
- Possessions const &getPossessions() const
+ const Possessions &getPossessions() const
{ return mPossessions; }
/**
@@ -309,8 +309,8 @@ class Character : public Being
{ return 0x82; } // blocked by walls and monsters ( bin 1000 0010)
private:
- Character(Character const &);
- Character &operator=(Character const &);
+ Character(const Character &);
+ Character &operator=(const Character &);
static const float EXPCURVE_EXPONENT;
static const float EXPCURVE_FACTOR;
diff --git a/src/game-server/command.cpp b/src/game-server/command.cpp
index ef8f649b..8d5bd27f 100644
--- a/src/game-server/command.cpp
+++ b/src/game-server/command.cpp
@@ -38,8 +38,8 @@ static T proxy_cast(intptr_t v)
{ return (T)v; }
template<>
-std::string const &proxy_cast(intptr_t v)
-{ return *(std::string const *)v; }
+const std::string &proxy_cast(intptr_t v)
+{ return *(const std::string *)v; }
template< typename T1 >
static void proxy(void (*f)(), Character *from, intptr_t const args[1])
@@ -79,7 +79,7 @@ template< typename T > struct Argument;
template<> struct Argument< int >
{ static char const type = 'n'; };
-template<> struct Argument< std::string const & >
+template<> struct Argument< const std::string & >
{ static char const type = 's'; };
template<> struct Argument< Character * >
{ static char const type = 'c'; };
@@ -95,7 +95,7 @@ template<> struct Argument< MonsterClass * >
*/
struct Command
{
- char const *name;
+ const char *name;
void (*handler)(void (*f)(), Character *, intptr_t const[]);
void (*target)();
char type[4];
@@ -106,7 +106,7 @@ struct Command
* Creates a command with a 1-parameter handler.
*/
template< typename T1 >
-static Command handle(char const *name, int level,
+static Command handle(const char *name, int level,
void (*f)(Character *, T1))
{
Command c;
@@ -123,7 +123,7 @@ static Command handle(char const *name, int level,
* Creates a command with a 2-parameter handler.
*/
template< typename T1, typename T2 >
-static Command handle(char const *name, int level,
+static Command handle(const char *name, int level,
void (*f)(Character *, T1, T2))
{
Command c;
@@ -141,7 +141,7 @@ static Command handle(char const *name, int level,
* Creates a command with a 3-parameter handler.
*/
template< typename T1, typename T2, typename T3 >
-static Command handle(char const *name, int level,
+static Command handle(const char *name, int level,
void (*f)(Character *, T1, T2, T3))
{
Command c;
@@ -160,7 +160,7 @@ static Command handle(char const *name, int level,
* Creates a command with a 4-parameter handler.
*/
template< typename T1, typename T2, typename T3, typename T4 >
-static Command handle(char const *name, int level,
+static Command handle(const char *name, int level,
void (*f)(Character *, T1, T2, T3, T4))
{
Command c;
@@ -201,7 +201,7 @@ static void drop(Character *from, ItemClass *it, int nb)
static void spawn(Character *from, MonsterClass *specy, int nb)
{
MapComposite *map = from->getMap();
- Point const &pos = from->getPosition();
+ const Point &pos = from->getPosition();
for (int i = 0; i < nb; ++i)
{
@@ -220,18 +220,18 @@ static void spawn(Character *from, MonsterClass *specy, int nb)
static void goto_(Character *from, Character *ch)
{
MapComposite *m = ch->getMap();
- Point const &pos = ch->getPosition();
+ const Point &pos = ch->getPosition();
GameState::warp(from, m, pos.x, pos.y);
}
static void recall(Character *from, Character *ch)
{
MapComposite *m = from->getMap();
- Point const &pos = from->getPosition();
+ const Point &pos = from->getPosition();
GameState::warp(ch, m, pos.x, pos.y);
}
-static void reload(Character *, std::string const &db)
+static void reload(Character *, const std::string &db)
{
if (db == "items")
{
@@ -243,7 +243,7 @@ static void reload(Character *, std::string const &db)
}
}
-static void ban(Character *from, Character *ch, std::string const &duration)
+static void ban(Character *from, Character *ch, const std::string &duration)
{
if (from->getAccountLevel() <= ch->getAccountLevel())
{
@@ -285,7 +285,7 @@ static Command const commands[] =
/**
* Send a message to the given character from the server.
*/
-static void say(Character * ch, std::string const &message)
+static void say(Character * ch, const std::string &message)
{
GameState::sayTo(ch, NULL, message);
}
@@ -294,9 +294,9 @@ static void say(Character * ch, std::string const &message)
/**
* Parses a command and executes its associated handler.
*/
-void runCommand(Character *ch, std::string const &text)
+void runCommand(Character *ch, const std::string &text)
{
- Command const *c = NULL;
+ const Command *c = NULL;
std::string::size_type npos = std::string::npos;
std::string::size_type pos = text.find(' ');
// remove the first letter which signifies it was a command
diff --git a/src/game-server/commandhandler.cpp b/src/game-server/commandhandler.cpp
index 3e61fe8f..cf263103 100644
--- a/src/game-server/commandhandler.cpp
+++ b/src/game-server/commandhandler.cpp
@@ -22,21 +22,22 @@
#include <sstream>
#include "defines.h"
-#include "commandhandler.hpp"
-#include "accountconnection.hpp"
-#include "character.hpp"
-#include "gamehandler.hpp"
-#include "inventory.hpp"
-#include "item.hpp"
-#include "itemmanager.hpp"
-#include "mapmanager.hpp"
-#include "monster.hpp"
-#include "monstermanager.hpp"
-#include "state.hpp"
-
-#include "../common/transaction.hpp"
-
-#include "../utils/string.hpp"
+
+#include "game-server/commandhandler.hpp"
+#include "game-server/accountconnection.hpp"
+#include "game-server/character.hpp"
+#include "game-server/gamehandler.hpp"
+#include "game-server/inventory.hpp"
+#include "game-server/item.hpp"
+#include "game-server/itemmanager.hpp"
+#include "game-server/mapmanager.hpp"
+#include "game-server/monster.hpp"
+#include "game-server/monstermanager.hpp"
+#include "game-server/state.hpp"
+
+#include "common/transaction.hpp"
+
+#include "utils/string.hpp"
static void say(const std::string error, Character *player)
{
@@ -418,7 +419,7 @@ static void handleSpawn(Character *player, std::string &args)
{
MonsterClass *mc;
MapComposite *map = player->getMap();
- Point const &pos = player->getPosition();
+ const Point &pos = player->getPosition();
int value, id;
// get the arguments
@@ -504,7 +505,7 @@ static void handleGoto(Character *player, std::string &args)
// move the player to where the other player is
MapComposite *map = other->getMap();
- Point const &pos = other->getPosition();
+ const Point &pos = other->getPosition();
GameState::warp(player, map, pos.x, pos.y);
}
@@ -533,7 +534,7 @@ static void handleRecall(Character *player, std::string &args)
// move the other player to where the player is
MapComposite *map = player->getMap();
- Point const &pos = player->getPosition();
+ const Point &pos = player->getPosition();
GameState::warp(other, map, pos.x, pos.y);
}
diff --git a/src/game-server/eventlistener.hpp b/src/game-server/eventlistener.hpp
index 827a0802..fe59124f 100644
--- a/src/game-server/eventlistener.hpp
+++ b/src/game-server/eventlistener.hpp
@@ -32,8 +32,8 @@ struct EventDispatch;
*/
struct EventListener
{
- EventDispatch const *dispatch;
- EventListener(EventDispatch const *d): dispatch(d) {}
+ const EventDispatch *dispatch;
+ EventListener(const EventDispatch *d): dispatch(d) {}
};
/**
@@ -44,22 +44,22 @@ struct EventDispatch
/**
* Called just after something is inserted in a map.
*/
- void (*inserted)(EventListener const *, Thing *);
+ void (*inserted)(const EventListener *, Thing *);
/**
* Called just before something is removed from a map.
*/
- void (*removed)(EventListener const *, Thing *);
+ void (*removed)(const EventListener *, Thing *);
/**
* Called just after a being has died.
*/
- void (*died)(EventListener const *, Being *);
+ void (*died)(const EventListener *, Being *);
/**
* Called just before a character is deleted.
*/
- void (*disconnected)(EventListener const *, Character *);
+ void (*disconnected)(const EventListener *, Character *);
/**
* Initializes dispatch methods as missing.
@@ -87,7 +87,7 @@ struct EventListenerFactory
template< class U, void (T::*F)(U *), class V = U >
struct create
{
- static void function(EventListener const *d, V *u)
+ static void function(const EventListener *d, V *u)
{
/* Get the address of the T object by substracting the offset of D
from the pointer d. */
diff --git a/src/game-server/gamehandler.cpp b/src/game-server/gamehandler.cpp
index 2ce443c1..42e9ce7a 100644
--- a/src/game-server/gamehandler.cpp
+++ b/src/game-server/gamehandler.cpp
@@ -95,8 +95,8 @@ void GameHandler::prepareServerChange(Character *ch)
client->status = CLIENT_CHANGE_SERVER;
}
-void GameHandler::completeServerChange(int id, std::string const &token,
- std::string const &address, int port)
+void GameHandler::completeServerChange(int id, const std::string &token,
+ const std::string &address, int port)
{
for (NetComputers::const_iterator i = clients.begin(),
i_end = clients.end(); i != i_end; ++i)
@@ -135,7 +135,7 @@ void GameHandler::updateCharacter(int charid, int partyid)
static Actor *findActorNear(Actor *p, int id)
{
MapComposite *map = p->getMap();
- Point const &ppos = p->getPosition();
+ const Point &ppos = p->getPosition();
// See map.hpp for tiles constants
const int pixelDist = DEFAULT_TILE_WIDTH * TILES_TO_BE_NEAR;
for (ActorIterator i(map->getAroundPointIterator(ppos, pixelDist)); i; ++i)
@@ -151,7 +151,7 @@ static Actor *findActorNear(Actor *p, int id)
static Character *findCharacterNear(Actor *p, int id)
{
MapComposite *map = p->getMap();
- Point const &ppos = p->getPosition();
+ const Point &ppos = p->getPosition();
// See map.hpp for tiles constants
const int pixelDist = DEFAULT_TILE_WIDTH * TILES_TO_BE_NEAR;
for (CharacterIterator i(map->getAroundPointIterator(ppos,
@@ -577,7 +577,7 @@ void GameHandler::sendTo(Character *beingPtr, MessageOut &msg)
client->send(msg);
}
-void GameHandler::addPendingCharacter(std::string const &token, Character *ch)
+void GameHandler::addPendingCharacter(const std::string &token, Character *ch)
{
/* First, check if the character is already on the map. This may happen if
a client just lost its connection, and logged to the account server
@@ -615,8 +615,7 @@ void GameHandler::addPendingCharacter(std::string const &token, Character *ch)
mTokenCollector.addPendingConnect(token, ch);
}
-void
-GameHandler::tokenMatched(GameClient* computer, Character* character)
+void GameHandler::tokenMatched(GameClient* computer, Character* character)
{
computer->character = character;
computer->status = CLIENT_CONNECTED;
@@ -645,8 +644,7 @@ GameHandler::tokenMatched(GameClient* computer, Character* character)
}
}
-void
-GameHandler::deletePendingClient(GameClient* computer)
+void GameHandler::deletePendingClient(GameClient* computer)
{
// Something might have changed since it was inserted
if (computer->status != CLIENT_QUEUED) return;
@@ -658,13 +656,12 @@ GameHandler::deletePendingClient(GameClient* computer)
computer->disconnect(msg);
}
-void
-GameHandler::deletePendingConnect(Character* character)
+void GameHandler::deletePendingConnect(Character* character)
{
delete character;
}
-GameClient *GameHandler::getClientByNameSlow(std::string const &name)
+GameClient *GameHandler::getClientByNameSlow(const std::string &name)
{
for (NetComputers::const_iterator i = clients.begin(),
i_end = clients.end(); i != i_end; ++i)
diff --git a/src/game-server/gamehandler.hpp b/src/game-server/gamehandler.hpp
index 0ae0d495..b3370348 100644
--- a/src/game-server/gamehandler.hpp
+++ b/src/game-server/gamehandler.hpp
@@ -77,8 +77,8 @@ class GameHandler: public ConnectionHandler
/**
* Completes a server change for given character ID.
*/
- void completeServerChange(int id, std::string const &token,
- std::string const &address, int port);
+ void completeServerChange(int id, const std::string &token,
+ const std::string &address, int port);
/**
* Updates the party id of the character
@@ -89,7 +89,7 @@ class GameHandler: public ConnectionHandler
* Registers a character that should soon be claimed by a client.
* @param token token used by the client when connecting.
*/
- void addPendingCharacter(std::string const &token, Character *);
+ void addPendingCharacter(const std::string &token, Character *);
/**
* Combines a client with its character.
@@ -116,7 +116,7 @@ class GameHandler: public ConnectionHandler
* Gets the client associated to a character name. This method is slow,
* so it should never be called for regular operations.
*/
- GameClient *getClientByNameSlow(std::string const &);
+ GameClient *getClientByNameSlow(const std::string &);
protected:
NetComputer *computerConnected(ENetPeer *);
diff --git a/src/game-server/item.hpp b/src/game-server/item.hpp
index 4da82cf7..828328ba 100644
--- a/src/game-server/item.hpp
+++ b/src/game-server/item.hpp
@@ -231,13 +231,13 @@ class ItemClass
/**
* Gets item modifiers.
*/
- ItemModifiers const &getModifiers() const
+ const ItemModifiers &getModifiers() const
{ return mModifiers; }
/**
* Sets item modifiers.
*/
- void setModifiers(ItemModifiers const &modifiers)
+ void setModifiers(const ItemModifiers &modifiers)
{ mModifiers = modifiers; }
/**
@@ -272,7 +272,7 @@ class ItemClass
/**
* Gets attack zone of weapon (returns NULL for non-weapon items)
*/
- AttackZone const *getAttackZone() const
+ const AttackZone *getAttackZone() const
{ return mAttackZone ; }
diff --git a/src/game-server/itemmanager.cpp b/src/game-server/itemmanager.cpp
index e275d1a6..ac0ea7d2 100644
--- a/src/game-server/itemmanager.cpp
+++ b/src/game-server/itemmanager.cpp
@@ -39,7 +39,7 @@ static ItemClasses itemClasses; /**< Item reference */
static std::string itemReferenceFile;
static unsigned int itemDatabaseVersion = 0; /**< Version of the loaded items database file.*/
-void ItemManager::initialize(std::string const &file)
+void ItemManager::initialize(const std::string &file)
{
itemReferenceFile = file;
reload();
diff --git a/src/game-server/itemmanager.hpp b/src/game-server/itemmanager.hpp
index a99dffb5..ec2c5c6d 100644
--- a/src/game-server/itemmanager.hpp
+++ b/src/game-server/itemmanager.hpp
@@ -28,12 +28,10 @@ class ItemClass;
namespace ItemManager
{
-
-
/**
* Loads item reference file.
*/
- void initialize(std::string const &);
+ void initialize(const std::string &);
/**
* Reloads item reference file.
diff --git a/src/game-server/mapcomposite.cpp b/src/game-server/mapcomposite.cpp
index d77f73ba..df252761 100644
--- a/src/game-server/mapcomposite.cpp
+++ b/src/game-server/mapcomposite.cpp
@@ -140,7 +140,7 @@ static void addZone(MapRegion &r, unsigned z)
}
}
-ZoneIterator::ZoneIterator(MapRegion const &r, MapContent const *m)
+ZoneIterator::ZoneIterator(const MapRegion &r, const MapContent *m)
: region(r), pos(0), map(m)
{
current = &map->zones[r.empty() ? 0 : r[0]];
@@ -165,7 +165,7 @@ void ZoneIterator::operator++()
}
}
-CharacterIterator::CharacterIterator(ZoneIterator const &it)
+CharacterIterator::CharacterIterator(const ZoneIterator &it)
: iterator(it), pos(0)
{
while (iterator && (*iterator)->nbCharacters == 0) ++iterator;
@@ -188,7 +188,7 @@ void CharacterIterator::operator++()
}
}
-BeingIterator::BeingIterator(ZoneIterator const &it)
+BeingIterator::BeingIterator(const ZoneIterator &it)
: iterator(it), pos(0)
{
while (iterator && (*iterator)->nbMovingObjects == 0) ++iterator;
@@ -211,7 +211,7 @@ void BeingIterator::operator++()
}
}
-FixedActorIterator::FixedActorIterator(ZoneIterator const &it)
+FixedActorIterator::FixedActorIterator(const ZoneIterator &it)
: iterator(it), pos(0)
{
while (iterator && (*iterator)->nbMovingObjects == (*iterator)->objects.size()) ++iterator;
@@ -238,7 +238,7 @@ void FixedActorIterator::operator++()
}
}
-ActorIterator::ActorIterator(ZoneIterator const &it)
+ActorIterator::ActorIterator(const ZoneIterator &it)
: iterator(it), pos(0)
{
while (iterator && (*iterator)->objects.empty()) ++iterator;
@@ -395,7 +395,7 @@ void MapContent::deallocate(Actor *obj)
buckets[id / 256]->deallocate(id % 256);
}
-void MapContent::fillRegion(MapRegion &r, Point const &p, int radius) const
+void MapContent::fillRegion(MapRegion &r, const Point &p, int radius) const
{
int ax = p.x > radius ? (p.x - radius) / zoneDiam : 0,
ay = p.y > radius ? (p.y - radius) / zoneDiam : 0,
@@ -410,7 +410,7 @@ void MapContent::fillRegion(MapRegion &r, Point const &p, int radius) const
}
}
-void MapContent::fillRegion(MapRegion &r, Rectangle const &p) const
+void MapContent::fillRegion(MapRegion &r, const Rectangle &p) const
{
int ax = p.x / zoneDiam,
ay = p.y / zoneDiam,
@@ -425,13 +425,17 @@ void MapContent::fillRegion(MapRegion &r, Rectangle const &p) const
}
}
-MapZone& MapContent::getZone(Point const &pos) const
+MapZone& MapContent::getZone(const Point &pos) const
{
return zones[(pos.x / zoneDiam) + (pos.y / zoneDiam) * mapWidth];
}
-MapComposite::MapComposite(int id, std::string const &name):
- mMap(NULL), mContent(NULL), mScript(NULL), mName(name), mID(id)
+MapComposite::MapComposite(int id, const std::string &name):
+ mMap(NULL),
+ mContent(NULL),
+ mScript(NULL),
+ mName(name),
+ mID(id)
{
}
@@ -442,7 +446,7 @@ MapComposite::~MapComposite()
delete mScript;
}
-ZoneIterator MapComposite::getAroundPointIterator(Point const &p, int radius) const
+ZoneIterator MapComposite::getAroundPointIterator(const Point &p, int radius) const
{
MapRegion r;
mContent->fillRegion(r, p, radius);
@@ -456,7 +460,7 @@ ZoneIterator MapComposite::getAroundActorIterator(Actor *obj, int radius) const
return ZoneIterator(r, mContent);
}
-ZoneIterator MapComposite::getInsideRectangleIterator(Rectangle const &p) const
+ZoneIterator MapComposite::getInsideRectangleIterator(const Rectangle &p) const
{
MapRegion r;
mContent->fillRegion(r, p);
@@ -581,7 +585,7 @@ void MapComposite::update()
}
}
-std::vector< Thing * > const &MapComposite::getEverything() const
+const std::vector< Thing * > &MapComposite::getEverything() const
{
return mContent->things;
}
diff --git a/src/game-server/mapcomposite.hpp b/src/game-server/mapcomposite.hpp
index ccec1db1..c55cfcdf 100644
--- a/src/game-server/mapcomposite.hpp
+++ b/src/game-server/mapcomposite.hpp
@@ -58,9 +58,9 @@ struct ZoneIterator
MapRegion region; /**< Zones to visit. Empty means the entire map. */
unsigned pos;
MapZone *current;
- MapContent const *map;
+ const MapContent *map;
- ZoneIterator(MapRegion const &, MapContent const *);
+ ZoneIterator(const MapRegion &, const MapContent *);
void operator++();
MapZone *operator*() const { return current; }
operator bool() const { return current; }
@@ -75,7 +75,7 @@ struct CharacterIterator
unsigned short pos;
Character *current;
- CharacterIterator(ZoneIterator const &);
+ CharacterIterator(const ZoneIterator &);
void operator++();
Character *operator*() const { return current; }
operator bool() const { return iterator; }
@@ -90,7 +90,7 @@ struct BeingIterator
unsigned short pos;
Being *current;
- BeingIterator(ZoneIterator const &);
+ BeingIterator(const ZoneIterator &);
void operator++();
Being *operator*() const { return current; }
operator bool() const { return iterator; }
@@ -105,7 +105,7 @@ struct FixedActorIterator
unsigned short pos;
Actor *current;
- FixedActorIterator(ZoneIterator const &);
+ FixedActorIterator(const ZoneIterator &);
void operator++();
Actor *operator*() const { return current; }
operator bool() const { return iterator; }
@@ -120,7 +120,7 @@ struct ActorIterator
unsigned short pos;
Actor *current;
- ActorIterator(ZoneIterator const &);
+ ActorIterator(const ZoneIterator &);
void operator++();
Actor *operator*() const { return current; }
operator bool() const { return iterator; }
@@ -190,17 +190,17 @@ struct MapContent
/**
* Fills a region of zones within the range of a point.
*/
- void fillRegion(MapRegion &, Point const &, int) const;
+ void fillRegion(MapRegion &, const Point &, int) const;
/**
* Fills a region of zones inside a rectangle.
*/
- void fillRegion(MapRegion &, Rectangle const &) const;
+ void fillRegion(MapRegion &, const Rectangle &) const;
/**
* Gets zone at given position.
*/
- MapZone &getZone(Point const &pos) const;
+ MapZone &getZone(const Point &pos) const;
/**
* Things (items, characters, monsters, etc) located on the map.
@@ -232,7 +232,7 @@ class MapComposite
/**
* Constructor.
*/
- MapComposite(int id, std::string const &name);
+ MapComposite(int id, const std::string &name);
/**
* Destructor.
@@ -278,7 +278,7 @@ class MapComposite
/**
* Gets the name of this map.
*/
- std::string const &getName() const
+ const std::string &getName() const
{ return mName; }
/**
@@ -310,12 +310,12 @@ class MapComposite
/**
* Gets an iterator on the objects inside a given rectangle.
*/
- ZoneIterator getInsideRectangleIterator(Rectangle const &) const;
+ ZoneIterator getInsideRectangleIterator(const Rectangle &) const;
/**
* Gets an iterator on the objects around a given point.
*/
- ZoneIterator getAroundPointIterator(Point const &, int radius) const;
+ ZoneIterator getAroundPointIterator(const Point &, int radius) const;
/**
* Gets an iterator on the objects around a given actor.
@@ -331,10 +331,10 @@ class MapComposite
/**
* Gets everything related to the map.
*/
- std::vector< Thing * > const &getEverything() const;
+ const std::vector< Thing * > &getEverything() const;
private:
- MapComposite(MapComposite const &);
+ MapComposite(const MapComposite &);
Map *mMap; /**< Actual map. */
MapContent *mContent; /**< Entities on the map. */
diff --git a/src/game-server/mapmanager.cpp b/src/game-server/mapmanager.cpp
index 2cc37de3..0e682afa 100644
--- a/src/game-server/mapmanager.cpp
+++ b/src/game-server/mapmanager.cpp
@@ -35,12 +35,12 @@
*/
static MapManager::Maps maps;
-MapManager::Maps const &MapManager::getMaps()
+const MapManager::Maps &MapManager::getMaps()
{
return maps;
}
-void MapManager::initialize(std::string const &mapReferenceFile)
+void MapManager::initialize(const std::string &mapReferenceFile)
{
int size;
char *data = ResourceManager::loadFile(mapReferenceFile, size);
@@ -103,7 +103,7 @@ MapComposite *MapManager::getMap(int mapId)
return (i != maps.end()) ? i->second : NULL;
}
-MapComposite *MapManager::getMap(std::string const &mapName)
+MapComposite *MapManager::getMap(const std::string &mapName)
{
Maps::iterator i;
for (i = maps.begin(); i != maps.end(); ++i)
diff --git a/src/game-server/mapmanager.hpp b/src/game-server/mapmanager.hpp
index e3fde61a..23675974 100644
--- a/src/game-server/mapmanager.hpp
+++ b/src/game-server/mapmanager.hpp
@@ -34,7 +34,7 @@ namespace MapManager
/**
* Loads map reference file and prepares maps.
*/
- void initialize(std::string const &mapReferenceFile);
+ void initialize(const std::string &mapReferenceFile);
/**
* Destroy loaded maps.
@@ -51,12 +51,12 @@ namespace MapManager
/**
* Returns the requested map
*/
- MapComposite *getMap(std::string const &mapName);
+ MapComposite *getMap(const std::string &mapName);
/**
* Returns all the maps.
*/
- Maps const &getMaps();
+ const Maps &getMaps();
/**
* Sets the activity status of the map.
diff --git a/src/game-server/mapreader.cpp b/src/game-server/mapreader.cpp
index 758b37ee..fdf8e997 100644
--- a/src/game-server/mapreader.cpp
+++ b/src/game-server/mapreader.cpp
@@ -114,7 +114,7 @@ void MapReader::readMap(const std::string &filename, MapComposite *composite)
}
}
-Map* MapReader::readMap(xmlNodePtr node, std::string const &path,
+Map* MapReader::readMap(xmlNodePtr node, const std::string &path,
MapComposite *composite, std::vector<Thing *> &things)
{
// Take the filename off the path
@@ -419,9 +419,9 @@ void MapReader::readLayer(xmlNodePtr node, Map *map)
return;
}
- int len = strlen((char const *)dataChild->content) + 1;
+ int len = strlen((const char *) dataChild->content) + 1;
char *charData = new char[len + 1];
- char const *charStart = (char const *)dataChild->content;
+ const char *charStart = (const char *) dataChild->content;
char *charIndex = charData;
while (*charStart)
diff --git a/src/game-server/mapreader.hpp b/src/game-server/mapreader.hpp
index d9b68c4e..d5677007 100644
--- a/src/game-server/mapreader.hpp
+++ b/src/game-server/mapreader.hpp
@@ -40,15 +40,17 @@ class MapReader
/**
* Read an XML map from a file.
*/
- static void readMap(const std::string &filename, MapComposite *composite);
+ static void readMap(const std::string &filename,
+ MapComposite *composite);
private:
/**
- * Read an XML map from a parsed XML tree, and populate things with objects
- * in that map.
+ * Read an XML map from a parsed XML tree, and populate things with
+ * objects in that map.
*/
- static Map* readMap(xmlNodePtr node, std::string const &path,
- MapComposite *composite, std::vector<Thing *> &things);
+ static Map *readMap(xmlNodePtr node, const std::string &path,
+ MapComposite *composite,
+ std::vector<Thing *> &things);
/**
* Reads a map layer and adds it to the given map.
@@ -58,7 +60,8 @@ class MapReader
/**
* Get the string value from the given object property node.
*/
- static std::string getObjectProperty(xmlNodePtr node, const std::string &def);
+ static std::string getObjectProperty(xmlNodePtr node,
+ const std::string &def);
/**
* Get the integer value from the given object property node.
diff --git a/src/game-server/monster.cpp b/src/game-server/monster.cpp
index a5a5f2ec..9c5fb044 100644
--- a/src/game-server/monster.cpp
+++ b/src/game-server/monster.cpp
@@ -319,7 +319,7 @@ void Monster::forgetTarget(Thing *t)
}
}
-int Monster::damage(Actor *source, Damage const &damage)
+int Monster::damage(Actor *source, const Damage &damage)
{
int HPLoss = Being::damage(source, damage);
if (HPLoss && source && source->getType() == OBJECT_CHARACTER)
diff --git a/src/game-server/monster.hpp b/src/game-server/monster.hpp
index b7c5947f..c25d853e 100644
--- a/src/game-server/monster.hpp
+++ b/src/game-server/monster.hpp
@@ -88,7 +88,7 @@ class MonsterClass
* Sets monster drops. These are the items the monster drops when it
* dies.
*/
- void setDrops(MonsterDrops const &v)
+ void setDrops(const MonsterDrops &v)
{ mDrops = v; }
/**
@@ -249,7 +249,7 @@ class Monster : public Being
/**
* Calls the damage function in Being and updates the aggro list
*/
- virtual int damage(Actor *source, Damage const &damage);
+ virtual int damage(Actor *source, const Damage &damage);
/**
* Removes a being from the anger list.
diff --git a/src/game-server/monstermanager.cpp b/src/game-server/monstermanager.cpp
index 022467d8..d7f301c8 100644
--- a/src/game-server/monstermanager.cpp
+++ b/src/game-server/monstermanager.cpp
@@ -57,7 +57,7 @@ Element elementFromString (const std::string &name)
return val == table.end() ? ELEMENT_ILLEGAL : (*val).second;
}
-void MonsterManager::initialize(std::string const &file)
+void MonsterManager::initialize(const std::string &file)
{
monsterReferenceFile = file;
reload();
diff --git a/src/game-server/monstermanager.hpp b/src/game-server/monstermanager.hpp
index ec84ca09..8af9a662 100644
--- a/src/game-server/monstermanager.hpp
+++ b/src/game-server/monstermanager.hpp
@@ -31,7 +31,7 @@ namespace MonsterManager
/**
* Loads monster reference file.
*/
- void initialize(std::string const &);
+ void initialize(const std::string &);
/**
* Reloads monster reference file.
@@ -46,7 +46,7 @@ namespace MonsterManager
/**
* Gets the MonsterClass having the given ID.
*/
- MonsterClass *getMonster(int);
+ MonsterClass *getMonster(int id);
}
#endif
diff --git a/src/game-server/postman.hpp b/src/game-server/postman.hpp
index c9b02b0a..ed9d0c1f 100644
--- a/src/game-server/postman.hpp
+++ b/src/game-server/postman.hpp
@@ -28,8 +28,8 @@ class Character;
struct PostCallback
{
- void (*handler)(Character *, std::string const &sender,
- std::string const &letter, void *data);
+ void (*handler)(Character *, const std::string &sender,
+ const std::string &letter, void *data);
void *data;
};
diff --git a/src/game-server/quest.cpp b/src/game-server/quest.cpp
index 06dc2a4c..2e8c2c2c 100644
--- a/src/game-server/quest.cpp
+++ b/src/game-server/quest.cpp
@@ -45,7 +45,7 @@ typedef std::map< int, PendingQuest > PendingQuests;
static PendingQuests pendingQuests;
-bool getQuestVar(Character *ch, std::string const &name, std::string &value)
+bool getQuestVar(Character *ch, const std::string &name, std::string &value)
{
std::map< std::string, std::string >::iterator
i = ch->questCache.find(name);
@@ -54,8 +54,8 @@ bool getQuestVar(Character *ch, std::string const &name, std::string &value)
return true;
}
-void setQuestVar(Character *ch, std::string const &name,
- std::string const &value)
+void setQuestVar(Character *ch, const std::string &name,
+ const std::string &value)
{
std::map< std::string, std::string >::iterator
i = ch->questCache.lower_bound(name);
@@ -79,9 +79,9 @@ void setQuestVar(Character *ch, std::string const &name,
*/
struct QuestDeathListener: EventDispatch
{
- static void partialRemove(EventListener const *, Thing *);
+ static void partialRemove(const EventListener *, Thing *);
- static void fullRemove(EventListener const *, Character *);
+ static void fullRemove(const EventListener *, Character *);
QuestDeathListener()
{
@@ -93,7 +93,7 @@ struct QuestDeathListener: EventDispatch
static QuestDeathListener questDeathDummy;
static EventListener questDeathListener(&questDeathDummy);
-void QuestDeathListener::partialRemove(EventListener const *, Thing *t)
+void QuestDeathListener::partialRemove(const EventListener *, Thing *t)
{
int id = static_cast< Character * >(t)->getDatabaseID();
PendingVariables &variables = pendingQuests[id].variables;
@@ -106,15 +106,15 @@ void QuestDeathListener::partialRemove(EventListener const *, Thing *t)
// The listener is kept in case a fullRemove is needed later.
}
-void QuestDeathListener::fullRemove(EventListener const *, Character *ch)
+void QuestDeathListener::fullRemove(const EventListener *, Character *ch)
{
ch->removeListener(&questDeathListener);
// Remove anything related to this character.
pendingQuests.erase(ch->getDatabaseID());
}
-void recoverQuestVar(Character *ch, std::string const &name,
- QuestCallback const &f)
+void recoverQuestVar(Character *ch, const std::string &name,
+ const QuestCallback &f)
{
assert(ch->questCache.find(name) == ch->questCache.end());
int id = ch->getDatabaseID();
@@ -131,8 +131,8 @@ void recoverQuestVar(Character *ch, std::string const &name,
accountHandler->requestQuestVar(ch, name);
}
-void recoveredQuestVar(int id, std::string const &name,
- std::string const &value)
+void recoveredQuestVar(int id, const std::string &name,
+ const std::string &value)
{
PendingQuests::iterator i = pendingQuests.find(id);
if (i == pendingQuests.end()) return;
diff --git a/src/game-server/quest.hpp b/src/game-server/quest.hpp
index 614f7571..917a093b 100644
--- a/src/game-server/quest.hpp
+++ b/src/game-server/quest.hpp
@@ -28,8 +28,8 @@ class Character;
struct QuestCallback
{
- void (*handler)(Character *, std::string const &name,
- std::string const &value, void *data);
+ void (*handler)(Character *, const std::string &name,
+ const std::string &value, void *data);
void *data;
};
@@ -37,25 +37,25 @@ struct QuestCallback
* Gets the value associated to a quest variable.
* @return false if no value was in cache.
*/
-bool getQuestVar(Character *, std::string const &name, std::string &value);
+bool getQuestVar(Character *, const std::string &name, std::string &value);
/**
* Sets the value associated to a quest variable.
*/
-void setQuestVar(Character *, std::string const &name,
- std::string const &value);
+void setQuestVar(Character *, const std::string &name,
+ const std::string &value);
/**
* Starts the recovery of a variable and returns immediatly. The callback will
* be called once the value has been recovered.
*/
-void recoverQuestVar(Character *, std::string const &name,
- QuestCallback const &);
+void recoverQuestVar(Character *, const std::string &name,
+ const QuestCallback &);
/**
* Called by the handler of the account server when a value is received.
*/
-void recoveredQuestVar(int id, std::string const &name,
- std::string const &value);
+void recoveredQuestVar(int id, const std::string &name,
+ const std::string &value);
#endif
diff --git a/src/game-server/resourcemanager.cpp b/src/game-server/resourcemanager.cpp
index 9a4b2a08..1eb8cba8 100644
--- a/src/game-server/resourcemanager.cpp
+++ b/src/game-server/resourcemanager.cpp
@@ -111,12 +111,12 @@ void ResourceManager::initialize()
#endif
}
-bool ResourceManager::exists(std::string const &path)
+bool ResourceManager::exists(const std::string &path)
{
return PHYSFS_exists(path.c_str());
}
-char *ResourceManager::loadFile(std::string const &fileName, int &fileSize)
+char *ResourceManager::loadFile(const std::string &fileName, int &fileSize)
{
// Attempt to open the specified file using PhysicsFS
PHYSFS_file* file = PHYSFS_openRead(fileName.c_str());
diff --git a/src/game-server/resourcemanager.hpp b/src/game-server/resourcemanager.hpp
index 9df36abe..7c346f19 100644
--- a/src/game-server/resourcemanager.hpp
+++ b/src/game-server/resourcemanager.hpp
@@ -34,7 +34,7 @@ namespace ResourceManager
/**
* Checks whether the given file or directory exists in the search path
*/
- bool exists(std::string const &path);
+ bool exists(const std::string &path);
/**
* Allocates data into a buffer pointer for raw data loading. The
@@ -47,7 +47,7 @@ namespace ResourceManager
* or <code>NULL</code> on failure.
* @note The array contains an extra \0 character at position fileSize.
*/
- char *loadFile(std::string const &fileName, int &fileSize);
+ char *loadFile(const std::string &fileName, int &fileSize);
}
#endif
diff --git a/src/game-server/spawnarea.hpp b/src/game-server/spawnarea.hpp
index c99450ac..cacec07b 100644
--- a/src/game-server/spawnarea.hpp
+++ b/src/game-server/spawnarea.hpp
@@ -36,7 +36,7 @@ class MonsterClass;
class SpawnArea : public Thing
{
public:
- SpawnArea(MapComposite *, MonsterClass *, Rectangle const &zone,
+ SpawnArea(MapComposite *, MonsterClass *, const Rectangle &zone,
int maxBeings, int spawnRate);
void update();
diff --git a/src/game-server/state.cpp b/src/game-server/state.cpp
index f0997174..2033c4bf 100644
--- a/src/game-server/state.cpp
+++ b/src/game-server/state.cpp
@@ -71,7 +71,7 @@ static DelayedEvents delayedEvents;
static void updateMap(MapComposite *map)
{
// 1. update object status.
- std::vector< Thing * > const &things = map->getEverything();
+ const std::vector< Thing * > &things = map->getEverything();
for (std::vector< Thing * >::const_iterator i = things.begin(),
i_end = things.end(); i != i_end; ++i)
{
@@ -103,7 +103,7 @@ static void updateMap(MapComposite *map)
*/
static void serializeLooks(Character *ch, MessageOut &msg, bool full)
{
- Possessions const &poss = ch->getPossessions();
+ const Possessions &poss = ch->getPossessions();
static int const nb_slots = 4;
static int const slots[nb_slots] =
{
@@ -239,7 +239,7 @@ static void informPlayer(MapComposite *map, Character *p)
if (o->canFight())
{
Being *victim = static_cast< Being * >(o);
- Hits const &hits = victim->getHitsTaken();
+ const Hits &hits = victim->getHitsTaken();
for (Hits::const_iterator j = hits.begin(),
j_end = hits.end(); j != j_end; ++j)
{
@@ -447,7 +447,7 @@ void GameState::update(int worldTime)
# endif
// Update game state (update AI, etc.)
- MapManager::Maps const &maps = MapManager::getMaps();
+ const MapManager::Maps &maps = MapManager::getMaps();
for (MapManager::Maps::const_iterator m = maps.begin(), m_end = maps.end(); m != m_end; ++m)
{
MapComposite *map = m->second;
@@ -492,7 +492,7 @@ void GameState::update(int worldTime)
for (DelayedEvents::iterator i = delayedEvents.begin(),
i_end = delayedEvents.end(); i != i_end; ++i)
{
- DelayedEvent const &e = i->second;
+ const DelayedEvent &e = i->second;
Actor *o = i->first;
switch (e.type)
{
@@ -728,7 +728,7 @@ void GameState::warp(Character *ptr, MapComposite *map, int x, int y)
/**
* Enqueues an event. It will be executed at end of update.
*/
-static void enqueueEvent(Actor *ptr, DelayedEvent const &e)
+static void enqueueEvent(Actor *ptr, const DelayedEvent &e)
{
std::pair< DelayedEvents::iterator, bool > p =
delayedEvents.insert(std::make_pair(ptr, e));
@@ -757,7 +757,7 @@ void GameState::enqueueWarp(Character *ptr, MapComposite *m, int x, int y)
enqueueEvent(ptr, e);
}
-void GameState::sayAround(Actor *obj, std::string const &text)
+void GameState::sayAround(Actor *obj, const std::string &text)
{
Point speakerPosition = obj->getPosition();
int visualRange = Configuration::getValue("visualRange", 320);
@@ -771,7 +771,7 @@ void GameState::sayAround(Actor *obj, std::string const &text)
}
}
-void GameState::sayTo(Actor *destination, Actor *source, std::string const &text)
+void GameState::sayTo(Actor *destination, Actor *source, const std::string &text)
{
if (destination->getType() != OBJECT_CHARACTER)
return; //only characters will read it anyway
diff --git a/src/game-server/state.hpp b/src/game-server/state.hpp
index e08073b7..60e63b0e 100644
--- a/src/game-server/state.hpp
+++ b/src/game-server/state.hpp
@@ -92,12 +92,12 @@ namespace GameState
* Says something to an actor.
* @note passing NULL as source generates a message from "Server:"
*/
- void sayTo(Actor *destination, Actor *source, std::string const &text);
+ void sayTo(Actor *destination, Actor *source, const std::string &text);
/**
* Says something to everything around an actor.
*/
- void sayAround(Actor *, std::string const &text);
+ void sayAround(Actor *, const std::string &text);
/**
* Says something to every player on the server.
diff --git a/src/game-server/thing.cpp b/src/game-server/thing.cpp
index ad33b247..3aa7129e 100644
--- a/src/game-server/thing.cpp
+++ b/src/game-server/thing.cpp
@@ -35,12 +35,12 @@ Thing::~Thing()
assert(mListeners.empty());
}
-void Thing::addListener(EventListener const *l)
+void Thing::addListener(const EventListener *l)
{
mListeners.insert(l);
}
-void Thing::removeListener(EventListener const *l)
+void Thing::removeListener(const EventListener *l)
{
mListeners.erase(l);
}
@@ -50,7 +50,7 @@ void Thing::inserted()
for (Listeners::iterator i = mListeners.begin(),
i_end = mListeners.end(); i != i_end;)
{
- EventListener const &l = **i;
+ const EventListener &l = **i;
++i; // In case the listener removes itself from the list on the fly.
if (l.dispatch->inserted) l.dispatch->inserted(&l, this);
}
@@ -61,7 +61,7 @@ void Thing::removed()
for (Listeners::iterator i = mListeners.begin(),
i_end = mListeners.end(); i != i_end;)
{
- EventListener const &l = **i;
+ const EventListener &l = **i;
++i; // In case the listener removes itself from the list on the fly.
if (l.dispatch->removed) l.dispatch->removed(&l, this);
}
diff --git a/src/game-server/thing.hpp b/src/game-server/thing.hpp
index b87ea657..33ffa908 100644
--- a/src/game-server/thing.hpp
+++ b/src/game-server/thing.hpp
@@ -44,7 +44,7 @@ enum ThingType
};
/**
- * Base class for in-game objects. Knows only its type and the map is resides
+ * Base class for in-game objects. Knows only its type and the map it resides
* on. Provides listeners.
*/
class Thing
@@ -107,12 +107,12 @@ class Thing
/**
* Adds a new listener.
*/
- void addListener(EventListener const *);
+ void addListener(const EventListener *);
/**
* Removes an existing listener.
*/
- void removeListener(EventListener const *);
+ void removeListener(const EventListener *);
/**
* Calls all the "inserted" listeners.
@@ -125,7 +125,7 @@ class Thing
virtual void removed();
protected:
- typedef std::set< EventListener const * > Listeners;
+ typedef std::set< const EventListener * > Listeners;
Listeners mListeners; /**< List of event listeners. */
private:
diff --git a/src/game-server/trigger.hpp b/src/game-server/trigger.hpp
index c134263a..d99fb769 100644
--- a/src/game-server/trigger.hpp
+++ b/src/game-server/trigger.hpp
@@ -51,7 +51,7 @@ class WarpAction : public TriggerAction
class ScriptAction : public TriggerAction
{
public:
- ScriptAction(Script *script, std::string function, int arg)
+ ScriptAction(Script *script, const std::string &function, int arg)
: mScript(script), mFunction(function), mArg(arg) {}
virtual void process(Actor *obj);
@@ -68,7 +68,7 @@ class TriggerArea : public Thing
/**
* Creates a rectangular trigger for a given map.
*/
- TriggerArea(MapComposite *m, Rectangle const &r, TriggerAction *ptr, bool once)
+ TriggerArea(MapComposite *m, const Rectangle &r, TriggerAction *ptr, bool once)
: Thing(OBJECT_OTHER, m), mZone(r), mAction(ptr), mOnce(once) {}
virtual void update();
diff --git a/src/net/connection.cpp b/src/net/connection.cpp
index 0b1f6079..18d6e2cb 100644
--- a/src/net/connection.cpp
+++ b/src/net/connection.cpp
@@ -31,7 +31,7 @@ Connection::Connection():
{
}
-bool Connection::start(std::string const &address, int port)
+bool Connection::start(const std::string &address, int port)
{
ENetAddress enetAddress;
enet_address_set_host(&enetAddress, address.c_str());
@@ -42,7 +42,8 @@ bool Connection::start(std::string const &address, int port)
0 /* assume any amount of incoming bandwidth */,
0 /* assume any amount of outgoing bandwidth */);
- if (!mLocal) return false;
+ if (!mLocal)
+ return false;
// Initiate the connection, allocating channel 0.
mRemote = enet_host_connect(mLocal, &enetAddress, 1);
@@ -77,7 +78,7 @@ bool Connection::isConnected() const
return mRemote && mRemote->state == ENET_PEER_STATE_CONNECTED;
}
-void Connection::send(MessageOut const &msg, bool reliable, unsigned channel)
+void Connection::send(const MessageOut &msg, bool reliable, unsigned channel)
{
if (!mRemote) {
LOG_WARN("Can't send message to unconnected host! (" << msg << ")");
diff --git a/src/net/connection.hpp b/src/net/connection.hpp
index f815d46b..2beeb04a 100644
--- a/src/net/connection.hpp
+++ b/src/net/connection.hpp
@@ -43,7 +43,7 @@ class Connection
* Connects to the given host/port and waits until the connection is
* established. Returns false if it fails to connect.
*/
- bool start(std::string const &, int);
+ bool start(const std::string &, int);
/**
* Disconnects.
@@ -58,7 +58,7 @@ class Connection
/**
* Sends a message to the remote host.
*/
- void send(MessageOut const &msg, bool reliable = true,
+ void send(const MessageOut &msg, bool reliable = true,
unsigned channel = 0);
/**
diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp
index 714def5e..767ed4c6 100644
--- a/src/net/messagein.cpp
+++ b/src/net/messagein.cpp
@@ -89,8 +89,8 @@ std::string MessageIn::readString(int length)
}
// Read the string
- char const *stringBeg = mData + mPos;
- char const *stringEnd = (char const *)memchr(stringBeg, '\0', length);
+ const char *stringBeg = mData + mPos;
+ const char *stringEnd = (const char *)memchr(stringBeg, '\0', length);
std::string readString(stringBeg,
stringEnd ? stringEnd - stringBeg : length);
mPos += length;
diff --git a/src/point.h b/src/point.h
index 5d01f9c1..d6ec0841 100644
--- a/src/point.h
+++ b/src/point.h
@@ -43,7 +43,7 @@ class Point
/**
* Check whether the given point is within range of this point.
*/
- bool inRangeOf(Point const &p, int radius) const
+ bool inRangeOf(const Point &p, int radius) const
{
return std::abs(x - p.x) <= radius &&
std::abs(y - p.y) <= radius;
@@ -72,7 +72,7 @@ class Rectangle
unsigned short w; /**< width */
unsigned short h; /**< height */
- bool contains(Point const &p) const
+ bool contains(const Point &p) const
{
return (unsigned short)(p.x - x) < w &&
(unsigned short)(p.y - y) < h;
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp
index 9ddc68e0..c2c6baf9 100644
--- a/src/scripting/lua.cpp
+++ b/src/scripting/lua.cpp
@@ -68,7 +68,7 @@ static int npc_message(lua_State *s)
NPC *p = getNPC(s, 1);
Character *q = getCharacter(s, 2);
size_t l;
- char const *m = lua_tolstring(s, 3, &l);
+ const char *m = lua_tolstring(s, 3, &l);
if (!p || !q || !m)
{
raiseScriptError(s, "npc_message called with incorrect parameters.");
@@ -98,7 +98,7 @@ static int npc_choice(lua_State *s)
msg.writeShort(p->getPublicID());
for (int i = 3, i_end = lua_gettop(s); i <= i_end; ++i)
{
- char const *m = lua_tostring(s, i);
+ const char *m = lua_tostring(s, i);
if (!m)
{
raiseScriptError(s, "npc_Choice called with incorrect parameters.");
@@ -601,7 +601,7 @@ static int chr_get_quest(lua_State *s)
raiseScriptError(s, "chr_get_quest called for nonexistent character.");
}
- char const *m = lua_tostring(s, 2);
+ const char *m = lua_tostring(s, 2);
if (!m || m[0] == 0)
{
raiseScriptError(s, "chr_get_quest called with incorrect parameters.");
@@ -629,8 +629,8 @@ static int chr_get_quest(lua_State *s)
static int chr_set_quest(lua_State *s)
{
Character *q = getCharacter(s, 1);
- char const *m = lua_tostring(s, 2);
- char const *n = lua_tostring(s, 3);
+ const char *m = lua_tostring(s, 2);
+ const char *n = lua_tostring(s, 3);
if (!m || !n || m[0] == 0)
{
raiseScriptError(s, "chr_set_quest called with incorrect parameters.");
diff --git a/src/scripting/luascript.cpp b/src/scripting/luascript.cpp
index c88b95fd..a28c4a9a 100644
--- a/src/scripting/luascript.cpp
+++ b/src/scripting/luascript.cpp
@@ -32,7 +32,7 @@ LuaScript::~LuaScript()
lua_close(mState);
}
-void LuaScript::prepare(std::string const &name)
+void LuaScript::prepare(const std::string &name)
{
assert(nbArgs == -1);
lua_getglobal(mState, name.c_str());
@@ -47,7 +47,7 @@ void LuaScript::push(int v)
++nbArgs;
}
-void LuaScript::push(std::string const &v)
+void LuaScript::push(const std::string &v)
{
assert(nbArgs >= 0);
lua_pushstring(mState, v.c_str());
@@ -68,7 +68,7 @@ int LuaScript::execute()
nbArgs = -1;
if (res || !(lua_isnil(mState, 1) || lua_isnumber(mState, 1)))
{
- char const *s = lua_tostring(mState, 1);
+ const char *s = lua_tostring(mState, 1);
LOG_WARN("Lua Script Error" << std::endl
<< " Script : " << mScriptFile << std::endl
@@ -83,7 +83,7 @@ int LuaScript::execute()
mCurFunction = "";
}
-void LuaScript::load(char const *prog)
+void LuaScript::load(const char *prog)
{
int res = luaL_loadstring(mState, prog);
@@ -128,8 +128,8 @@ void LuaScript::processRemoveEvent(Thing *being)
/**
* Called when the server has recovered the value of a quest variable.
*/
-void LuaScript::getQuestCallback(Character *q, std::string const &name,
- std::string const &value, void *data)
+void LuaScript::getQuestCallback(Character *q, const std::string &name,
+ const std::string &value, void *data)
{
LuaScript *s = static_cast< LuaScript * >(data);
assert(s->nbArgs == -1);
@@ -144,8 +144,8 @@ void LuaScript::getQuestCallback(Character *q, std::string const &name,
/**
* Called when the server has recovered the post for a user
*/
-void LuaScript::getPostCallback(Character *q, std::string const &sender,
- std::string const &letter, void *data)
+void LuaScript::getPostCallback(Character *q, const std::string &sender,
+ const std::string &letter, void *data)
{
// get the script
LuaScript *s = static_cast<LuaScript*>(data);
diff --git a/src/scripting/luascript.hpp b/src/scripting/luascript.hpp
index d4dc116e..398fbecf 100644
--- a/src/scripting/luascript.hpp
+++ b/src/scripting/luascript.hpp
@@ -36,7 +36,8 @@ class LuaScript: public Script
{
public:
/**
- * Constructor.
+ * Constructor. Initializes a new Lua state, registers the native API
+ * and loads the libtmw.lua file.
*/
LuaScript();
@@ -45,9 +46,9 @@ class LuaScript: public Script
*/
~LuaScript();
- void load(char const *);
+ void load(const char *);
- void prepare(std::string const &);
+ void prepare(const std::string &);
void push(int);
@@ -57,11 +58,11 @@ class LuaScript: public Script
int execute();
- static void getQuestCallback(Character *, std::string const &,
- std::string const &, void *);
+ static void getQuestCallback(Character *, const std::string &,
+ const std::string &, void *);
- static void getPostCallback(Character *, std::string const &,
- std::string const &, void *);
+ static void getPostCallback(Character *, const std::string &,
+ const std::string &, void *);
void processDeathEvent(Being* thing);
diff --git a/src/scripting/script.cpp b/src/scripting/script.cpp
index f334eb19..e343b558 100644
--- a/src/scripting/script.cpp
+++ b/src/scripting/script.cpp
@@ -36,7 +36,7 @@ Script::Script():
mEventListener(&scriptEventDispatch)
{}
-void Script::registerEngine(std::string const &name, Factory f)
+void Script::registerEngine(const std::string &name, Factory f)
{
if (!engines)
{
@@ -49,7 +49,7 @@ void Script::registerEngine(std::string const &name, Factory f)
(*engines)[name] = f;
}
-Script *Script::create(std::string const &engine)
+Script *Script::create(const std::string &engine)
{
if (engines)
{
@@ -69,7 +69,7 @@ void Script::update()
execute();
}
-bool Script::loadFile(std::string const &name)
+bool Script::loadFile(const std::string &name)
{
int size;
char *buffer = ResourceManager::loadFile(name, size);
@@ -84,7 +84,8 @@ bool Script::loadFile(std::string const &name)
}
}
-void Script::loadNPC(std::string const &name, int id, int x, int y, char const *prog)
+void Script::loadNPC(const std::string &name, int id, int x, int y,
+ const char *prog)
{
load(prog);
prepare("create_npc_delayed");
diff --git a/src/scripting/script.hpp b/src/scripting/script.hpp
index 24a415ef..1674e483 100644
--- a/src/scripting/script.hpp
+++ b/src/scripting/script.hpp
@@ -41,12 +41,12 @@ class Script
/**
* Registers a new scripting engine.
*/
- static void registerEngine(std::string const &, Factory);
+ static void registerEngine(const std::string &, Factory);
/**
* Creates a new script context for a given engine.
*/
- static Script *create(std::string const &engine);
+ static Script *create(const std::string &engine);
/**
* Constructor.
@@ -62,19 +62,20 @@ class Script
* Loads a chunk of text into script context and executes its global
* statements.
*/
- virtual void load(char const *) = 0;
+ virtual void load(const char *) = 0;
/**
* Loads a text file into script context and executes its global
* statements.
*/
- virtual bool loadFile(std::string const &);
+ virtual bool loadFile(const std::string &);
/**
* Loads a chunk of text and considers it as an NPC handler. This
* handler will later be used to create the given NPC.
*/
- virtual void loadNPC(std::string const &name, int id, int x, int y, char const *);
+ virtual void loadNPC(const std::string &name, int id, int x, int y,
+ const char *);
/**
* Called every tick for the script to manage its data.
@@ -86,7 +87,7 @@ class Script
* Prepares a call to the given function.
* Only one function can be prepared at once.
*/
- virtual void prepare(std::string const &name) = 0;
+ virtual void prepare(const std::string &name) = 0;
/**
* Pushes an integer argument for the function being prepared.
@@ -96,7 +97,7 @@ class Script
/**
* Pushes a string argument for the function being prepared.
*/
- virtual void push(std::string const &) = 0;
+ virtual void push(const std::string &) = 0;
/**
* Pushes a pointer argument to a game entity.
diff --git a/src/serialize/characterdata.hpp b/src/serialize/characterdata.hpp
index 7943f3ac..a93768b8 100644
--- a/src/serialize/characterdata.hpp
+++ b/src/serialize/characterdata.hpp
@@ -28,7 +28,7 @@
#include "point.h"
template< class T >
-void serializeCharacterData(T const &data, MessageOut &msg)
+void serializeCharacterData(const T &data, MessageOut &msg)
{
msg.writeByte(data.getAccountLevel());
msg.writeByte(data.getGender());
@@ -50,11 +50,11 @@ void serializeCharacterData(T const &data, MessageOut &msg)
msg.writeShort(data.getMapId());
- Point const &pos = data.getPosition();
+ const Point &pos = data.getPosition();
msg.writeShort(pos.x);
msg.writeShort(pos.y);
- Possessions const &poss = data.getPossessions();
+ const Possessions &poss = data.getPossessions();
msg.writeLong(poss.money);
for (int j = 0; j < EQUIPMENT_SLOTS; ++j)
{
diff --git a/src/utils/logger.cpp b/src/utils/logger.cpp
index eab8c39d..e3b48c38 100644
--- a/src/utils/logger.cpp
+++ b/src/utils/logger.cpp
@@ -65,7 +65,7 @@ static std::string getCurrentTime()
return os.str();
}
-void Logger::output(std::ostream &os, std::string const &msg, char const *prefix)
+void Logger::output(std::ostream &os, const std::string &msg, const char *prefix)
{
if (mHasTimestamp)
{
@@ -80,7 +80,7 @@ void Logger::output(std::ostream &os, std::string const &msg, char const *prefix
os << msg << std::endl;
}
-void Logger::setLogFile(std::string const &logFile)
+void Logger::setLogFile(const std::string &logFile)
{
// Close the current log file.
if (mLogFile.is_open())
@@ -103,10 +103,16 @@ void Logger::setLogFile(std::string const &logFile)
}
}
-void Logger::output(std::string const& msg, Level atVerbosity)
+void Logger::output(const std::string &msg, Level atVerbosity)
{
- static char const *prefixes[] =
- { "[FTL]", "[ERR]", "[WRN]", "[INF]", "[DBG]" };
+ static const char *prefixes[] =
+ {
+ "[FTL]",
+ "[ERR]",
+ "[WRN]",
+ "[INF]",
+ "[DBG]"
+ };
if (mVerbosity >= atVerbosity)
{
diff --git a/src/utils/logger.h b/src/utils/logger.h
index 026696a6..e23fdceb 100644
--- a/src/utils/logger.h
+++ b/src/utils/logger.h
@@ -91,7 +91,7 @@ class Logger
*
* @exception std::ios::failure if the log file could not be opened.
*/
- static void setLogFile(std::string const &logFile);
+ static void setLogFile(const std::string &logFile);
/**
* Add/removes the timestamp.
@@ -129,7 +129,7 @@ class Logger
*
* @exception std::ios::failure.
*/
- static void output(std::string const &msg, Level atVerbosity);
+ static void output(const std::string &msg, Level atVerbosity);
static Level mVerbosity; /**< Verbosity level. */
private:
@@ -145,7 +145,8 @@ class Logger
*
* @exception std::ios::failure.
*/
- static void output(std::ostream &os, std::string const &msg, char const *prefix);
+ static void output(std::ostream &os, const std::string &msg,
+ const char *prefix);
};
diff --git a/src/utils/tokencollector.cpp b/src/utils/tokencollector.cpp
index 0719b444..df21e631 100644
--- a/src/utils/tokencollector.cpp
+++ b/src/utils/tokencollector.cpp
@@ -27,7 +27,7 @@
failure, especially a timeout. So we search the lists forward when removing
data, in order to start from the older ones. */
-void TokenCollectorBase::insertClient(std::string const &token, intptr_t data)
+void TokenCollectorBase::insertClient(const std::string &token, intptr_t data)
{
for (std::list<Item>::reverse_iterator it = mPendingConnects.rbegin(),
it_end = mPendingConnects.rend(); it != it_end; ++it)
@@ -51,7 +51,7 @@ void TokenCollectorBase::insertClient(std::string const &token, intptr_t data)
removeOutdated(current);
}
-void TokenCollectorBase::insertConnect(std::string const &token, intptr_t data)
+void TokenCollectorBase::insertConnect(const std::string &token, intptr_t data)
{
for (std::list<Item>::reverse_iterator it = mPendingClients.rbegin(),
it_end = mPendingClients.rend(); it != it_end; ++it)
diff --git a/src/utils/tokencollector.hpp b/src/utils/tokencollector.hpp
index c2403884..332bd1a0 100644
--- a/src/utils/tokencollector.hpp
+++ b/src/utils/tokencollector.hpp
@@ -61,9 +61,9 @@ class TokenCollectorBase
virtual void foundMatch(intptr_t client, intptr_t connect) = 0;
TokenCollectorBase();
virtual ~TokenCollectorBase();
- void insertClient(std::string const &, intptr_t);
+ void insertClient(const std::string &, intptr_t);
void removeClient(intptr_t);
- void insertConnect(std::string const &, intptr_t);
+ void insertConnect(const std::string &, intptr_t);
void removeOutdated(time_t);
};
@@ -104,14 +104,14 @@ class TokenCollector: private TokenCollectorBase
* Checks if the server expected this client token. If so, calls
* Handler::tokenMatched. Otherwise marks the client as pending.
*/
- void addPendingClient(std::string const &token, Client data)
+ void addPendingClient(const std::string &token, Client data)
{ insertClient(token, (intptr_t)data); }
/**
* Checks if a client already registered this token. If so, calls
* Handler::tokenMatched. Otherwise marks the data as pending.
*/
- void addPendingConnect(std::string const &token, ServerData data)
+ void addPendingConnect(const std::string &token, ServerData data)
{ insertConnect(token, (intptr_t)data); }
/**
diff --git a/src/utils/xml.cpp b/src/utils/xml.cpp
index 9527658a..55380275 100644
--- a/src/utils/xml.cpp
+++ b/src/utils/xml.cpp
@@ -26,7 +26,7 @@
namespace XML
{
-int getProperty(xmlNodePtr node, char const *name, int def)
+int getProperty(xmlNodePtr node, const char *name, int def)
{
if (xmlChar *prop = xmlGetProp(node, BAD_CAST name))
{
@@ -37,8 +37,7 @@ int getProperty(xmlNodePtr node, char const *name, int def)
return def;
}
-double
-getFloatProperty(xmlNodePtr node, const char* name, double def)
+double getFloatProperty(xmlNodePtr node, const char* name, double def)
{
double &ret = def;
@@ -51,7 +50,8 @@ getFloatProperty(xmlNodePtr node, const char* name, double def)
return ret;
}
-std::string getProperty(xmlNodePtr node, char const *name, std::string const &def)
+std::string getProperty(xmlNodePtr node, const char *name,
+ const std::string &def)
{
if (xmlChar *prop = xmlGetProp(node, BAD_CAST name))
{
diff --git a/src/utils/xml.hpp b/src/utils/xml.hpp
index 652d1e8c..44d0e7cc 100644
--- a/src/utils/xml.hpp
+++ b/src/utils/xml.hpp
@@ -26,25 +26,25 @@
#include <libxml/tree.h>
#include "defines.h"
-#include "../game-server/item.hpp"
+#include "game-server/item.hpp"
namespace XML
{
/**
* Gets an integer property from an xmlNodePtr.
*/
- int getProperty(xmlNodePtr node, char const *name, int def);
+ int getProperty(xmlNodePtr node, const char *name, int def);
/**
* Gets a string property from an xmlNodePtr.
*/
- std::string getProperty(xmlNodePtr node, char const *name, std::string const &def);
+ std::string getProperty(xmlNodePtr node, const char *name,
+ const std::string &def);
/**
* Gets an floating point property from an xmlNodePtr.
*/
- double
- getFloatProperty(xmlNodePtr node, const char *name, double def);
+ double getFloatProperty(xmlNodePtr node, const char *name, double def);
}
#define for_each_xml_child_node(var, parent) \