summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2008-12-12 22:50:21 +0100
committerBjørn Lindeijer <bjorn@lindeijer.nl>2008-12-12 22:50:21 +0100
commit8e875492a0b3a10bf0a3a52907452535c4fa6ff7 (patch)
tree3b3f90c9eaf71638292f20b43d50371af2070cc0 /src
parentb552cba2177b36898d432e80fea3f4c2f483a78d (diff)
downloadmanaserv-8e875492a0b3a10bf0a3a52907452535c4fa6ff7.tar.gz
manaserv-8e875492a0b3a10bf0a3a52907452535c4fa6ff7.tar.bz2
manaserv-8e875492a0b3a10bf0a3a52907452535c4fa6ff7.tar.xz
manaserv-8e875492a0b3a10bf0a3a52907452535c4fa6ff7.zip
Fixed game server crash and code style
The game server crashed when it was closed while it still hadn't been able to connect to the account server, due to an uninitialized pointer. Code style fixes. Don't use 'const' for arguments that are passed by value and start variable names with lowercase.
Diffstat (limited to 'src')
-rw-r--r--src/account-server/main-account.cpp4
-rw-r--r--src/game-server/accountconnection.cpp52
-rw-r--r--src/game-server/accountconnection.hpp53
3 files changed, 56 insertions, 53 deletions
diff --git a/src/account-server/main-account.cpp b/src/account-server/main-account.cpp
index f2373d28..90c30a51 100644
--- a/src/account-server/main-account.cpp
+++ b/src/account-server/main-account.cpp
@@ -142,8 +142,8 @@ static void initialize()
Logger::setTeeMode(true);
Configuration::initialize(configPath);
- LOG_INFO("Using Config File: " << configPath);
- LOG_INFO("Using Log File: " << logPath);
+ LOG_INFO("Using config file: " << configPath);
+ LOG_INFO("Using log file: " << logPath);
// Open database
try {
diff --git a/src/game-server/accountconnection.cpp b/src/game-server/accountconnection.cpp
index 6d6276d8..c2b5a78e 100644
--- a/src/game-server/accountconnection.cpp
+++ b/src/game-server/accountconnection.cpp
@@ -38,12 +38,14 @@
#include "utils/tokendispenser.hpp"
#include "utils/tokencollector.hpp"
+AccountConnection::AccountConnection():
+ mSyncBuffer(0)
+{
+}
+
AccountConnection::~AccountConnection()
{
- if (mSyncBuffer)
- {
- delete (mSyncBuffer);
- }
+ delete mSyncBuffer;
}
bool AccountConnection::start()
@@ -323,7 +325,8 @@ void AccountConnection::syncChanges(bool force)
mSyncMessages > SYNC_BUFFER_LIMIT ||
mSyncBuffer->getLength() > SYNC_BUFFER_SIZE )
{
- LOG_DEBUG("Sending GAMSG_PLAYER_SYNC with " << mSyncMessages << " messages." );
+ LOG_DEBUG("Sending GAMSG_PLAYER_SYNC with "
+ << mSyncMessages << " messages." );
// attach end-of-buffer flag
mSyncBuffer->writeByte(SYNC_END_OF_BUFFER);
@@ -339,42 +342,37 @@ void AccountConnection::syncChanges(bool force)
}
}
-void AccountConnection::updateCharacterPoints(const int CharId, const int CharPoints,
- const int CorrPoints, const int AttribId, const int AttribValue )
+void AccountConnection::updateCharacterPoints(int charId, int charPoints,
+ int corrPoints,
+ int attribId,
+ int attribValue)
{
mSyncMessages++;
mSyncBuffer->writeByte(SYNC_CHARACTER_POINTS);
- mSyncBuffer->writeLong(CharId);
- mSyncBuffer->writeLong(CharPoints);
- mSyncBuffer->writeLong(CorrPoints);
- mSyncBuffer->writeByte(AttribId);
- mSyncBuffer->writeLong(AttribValue);
+ mSyncBuffer->writeLong(charId);
+ mSyncBuffer->writeLong(charPoints);
+ mSyncBuffer->writeLong(corrPoints);
+ mSyncBuffer->writeByte(attribId);
+ mSyncBuffer->writeLong(attribValue);
syncChanges();
}
-void AccountConnection::updateExperience(const int CharId, const int SkillId,
- const int SkillValue)
+void AccountConnection::updateExperience(int charId, int skillId,
+ int skillValue)
{
mSyncMessages++;
mSyncBuffer->writeByte(SYNC_CHARACTER_SKILL);
- mSyncBuffer->writeLong(CharId);
- mSyncBuffer->writeByte(SkillId);
- mSyncBuffer->writeLong(SkillValue);
+ mSyncBuffer->writeLong(charId);
+ mSyncBuffer->writeByte(skillId);
+ mSyncBuffer->writeLong(skillValue);
syncChanges();
}
-void AccountConnection::updateOnlineStatus(const int CharId, const bool Online)
+void AccountConnection::updateOnlineStatus(int charId, bool online)
{
mSyncMessages++;
mSyncBuffer->writeByte(SYNC_ONLINE_STATUS);
- mSyncBuffer->writeLong(CharId);
- if (Online)
- {
- mSyncBuffer->writeByte(0x01);
- }
- else
- {
- mSyncBuffer->writeByte(0x00);
- }
+ mSyncBuffer->writeLong(charId);
+ mSyncBuffer->writeByte(online ? 0x01 : 0x00);
syncChanges();
}
diff --git a/src/game-server/accountconnection.hpp b/src/game-server/accountconnection.hpp
index 5b21c0ac..6e7bd1b5 100644
--- a/src/game-server/accountconnection.hpp
+++ b/src/game-server/accountconnection.hpp
@@ -49,10 +49,14 @@ class Character;
class AccountConnection : public Connection
{
public:
+ /**
+ * Constructor.
+ */
+ AccountConnection();
/**
- * Destructor
- */
+ * Destructor.
+ */
~AccountConnection();
/**
@@ -117,34 +121,37 @@ class AccountConnection : public Connection
void syncChanges(bool force = false);
/**
- * Write a modification message about character points to the sync buffer.
+ * Write a modification message about character points to the sync
+ * buffer.
*
- * @param CharId ID of the character
- * @param CharPoints Number of character points left for the character
- * @param CorrPoints Number of correction points left for the character
- * @param AttribId ID of the modified attribute
- * @param AttribValue New value of the modified attribute
+ * @param charId ID of the character
+ * @param charPoints character points left for the character
+ * @param corrPoints correction points left for the character
+ * @param attribId ID of the modified attribute
+ * @param attribValue New value of the modified attribute
*/
- void updateCharacterPoints(const int CharId, const int CharPoints,
- const int CorrPoints, const int AttribId,
- const int AttribValue);
+ void updateCharacterPoints(int charId, int charPoints,
+ int corrPoints, int attribId,
+ int attribValue);
/**
- * Write a modification message about character skills to the sync buffer.
- * @param CharId ID of the character
- * @param SkillId ID of the skill
- * @param SkillValue new skill points
+ * Write a modification message about character skills to the sync
+ * buffer.
+ *
+ * @param charId ID of the character
+ * @param skillId ID of the skill
+ * @param skillValue new skill points
*/
- void updateExperience(const int CharId, const int SkillId,
- const int SkillValue);
+ void updateExperience(int charId, int skillId, int skillValue);
/**
- * Update the status of a character to online (true) or offline (false).
+ * Update the status of a character to online (true) or offline
+ * (false).
*
- * @param CharId Id of the character.
- * @param Online True to flag the character as being online.
+ * @param charId Id of the character.
+ * @param online True to flag the character as being online.
*/
- void updateOnlineStatus(const int CharId, const bool Online);
+ void updateOnlineStatus(int charId, bool online);
protected:
/**
@@ -153,12 +160,10 @@ class AccountConnection : public Connection
virtual void processMessage(MessageIn &);
private:
-
MessageOut* mSyncBuffer; /**< Message buffer to store sync data. */
int mSyncMessages; /**< Number of messages in the sync buffer. */
-
};
extern AccountConnection *accountHandler;
-#endif
+#endif // _TMW_ACCOUNTCONNECTION_H_