summaryrefslogtreecommitdiffstats
path: root/src/game-server/accountconnection.cpp
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/game-server/accountconnection.cpp
parentb552cba2177b36898d432e80fea3f4c2f483a78d (diff)
downloadmanaserv-8e875492a0b3a10bf0a3a52907452535c4fa6ff7.tar.gz
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/game-server/accountconnection.cpp')
-rw-r--r--src/game-server/accountconnection.cpp52
1 files changed, 25 insertions, 27 deletions
diff --git a/src/game-server/accountconnection.cpp b/src/game-server/accountconnection.cpp
index 6d6276d..c2b5a78 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();
}