Various Cleanups (game T-Z)

This commit is contained in:
Schmoozerd 2012-07-19 21:52:26 +02:00
parent 08fd085549
commit 6379a746d7
34 changed files with 2858 additions and 2852 deletions

View file

@ -48,7 +48,7 @@ static bool MapSessionFilterHelper(WorldSession* session, OpcodeHandler const& o
return false;
// we do not process not loggined player packets
Player * plr = session->GetPlayer();
Player* plr = session->GetPlayer();
if (!plr)
return false;
@ -57,7 +57,7 @@ static bool MapSessionFilterHelper(WorldSession* session, OpcodeHandler const& o
}
bool MapSessionFilter::Process(WorldPacket * packet)
bool MapSessionFilter::Process(WorldPacket* packet)
{
OpcodeHandler const& opHandle = opcodeTable[packet->GetOpcode()];
if (opHandle.packetProcessing == PROCESS_INPLACE)
@ -81,16 +81,16 @@ bool WorldSessionFilter::Process(WorldPacket* packet)
}
/// WorldSession constructor
WorldSession::WorldSession(uint32 id, WorldSocket *sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale) :
m_muteTime(mute_time), _player(NULL), m_Socket(sock),_security(sec), _accountId(id), m_expansion(expansion), _logoutTime(0),
m_inQueue(false), m_playerLoading(false), m_playerLogout(false), m_playerRecentlyLogout(false), m_playerSave(false),
m_sessionDbcLocale(sWorld.GetAvailableDbcLocale(locale)), m_sessionDbLocaleIndex(sObjectMgr.GetIndexForLocale(locale)),
m_latency(0), m_tutorialState(TUTORIALDATA_UNCHANGED)
WorldSession::WorldSession(uint32 id, WorldSocket* sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale) :
m_muteTime(mute_time), _player(NULL), m_Socket(sock),_security(sec), _accountId(id), m_expansion(expansion), _logoutTime(0),
m_inQueue(false), m_playerLoading(false), m_playerLogout(false), m_playerRecentlyLogout(false), m_playerSave(false),
m_sessionDbcLocale(sWorld.GetAvailableDbcLocale(locale)), m_sessionDbLocaleIndex(sObjectMgr.GetIndexForLocale(locale)),
m_latency(0), m_tutorialState(TUTORIALDATA_UNCHANGED)
{
if (sock)
{
m_Address = sock->GetRemoteAddress ();
sock->AddReference ();
m_Address = sock->GetRemoteAddress();
sock->AddReference();
}
}
@ -99,26 +99,26 @@ WorldSession::~WorldSession()
{
///- unload player if not unloaded
if (_player)
LogoutPlayer (true);
LogoutPlayer(true);
/// - If have unclosed socket, close it
if (m_Socket)
{
m_Socket->CloseSocket ();
m_Socket->RemoveReference ();
m_Socket->CloseSocket();
m_Socket->RemoveReference();
m_Socket = NULL;
}
///- empty incoming packet queue
WorldPacket* packet = NULL;
while(_recvQueue.next(packet))
while (_recvQueue.next(packet))
delete packet;
}
void WorldSession::SizeError(WorldPacket const& packet, uint32 size) const
{
sLog.outError("Client (account %u) send packet %s (%u) with size " SIZEFMTD " but expected %u (attempt crash server?), skipped",
GetAccountId(),LookupOpcodeName(packet.GetOpcode()),packet.GetOpcode(),packet.size(),size);
GetAccountId(),LookupOpcodeName(packet.GetOpcode()),packet.GetOpcode(),packet.size(),size);
}
/// Get the player name
@ -133,7 +133,7 @@ void WorldSession::SendPacket(WorldPacket const* packet)
if (!m_Socket)
return;
#ifdef MANGOS_DEBUG
#ifdef MANGOS_DEBUG
// Code for network use statistic
static uint64 sendPacketCount = 0;
@ -147,7 +147,7 @@ void WorldSession::SendPacket(WorldPacket const* packet)
time_t cur_time = time(NULL);
if((cur_time - lastTime) < 60)
if ((cur_time - lastTime) < 60)
{
sendPacketCount+=1;
sendPacketBytes+=packet->size();
@ -167,10 +167,10 @@ void WorldSession::SendPacket(WorldPacket const* packet)
sendLastPacketBytes = packet->wpos(); // wpos is real written size
}
#endif // !MANGOS_DEBUG
#endif // !MANGOS_DEBUG
if (m_Socket->SendPacket (*packet) == -1)
m_Socket->CloseSocket ();
if (m_Socket->SendPacket(*packet) == -1)
m_Socket->CloseSocket();
}
/// Add an incoming packet to the queue
@ -180,21 +180,21 @@ void WorldSession::QueuePacket(WorldPacket* new_packet)
}
/// Logging helper for unexpected opcodes
void WorldSession::LogUnexpectedOpcode(WorldPacket* packet, const char *reason)
void WorldSession::LogUnexpectedOpcode(WorldPacket* packet, const char* reason)
{
sLog.outError( "SESSION: received unexpected opcode %s (0x%.4X) %s",
LookupOpcodeName(packet->GetOpcode()),
packet->GetOpcode(),
reason);
sLog.outError("SESSION: received unexpected opcode %s (0x%.4X) %s",
LookupOpcodeName(packet->GetOpcode()),
packet->GetOpcode(),
reason);
}
/// Logging helper for unexpected opcodes
void WorldSession::LogUnprocessedTail(WorldPacket *packet)
void WorldSession::LogUnprocessedTail(WorldPacket* packet)
{
sLog.outError( "SESSION: opcode %s (0x%.4X) have unprocessed tail data (read stop at " SIZEFMTD " from " SIZEFMTD ")",
LookupOpcodeName(packet->GetOpcode()),
packet->GetOpcode(),
packet->rpos(),packet->wpos());
sLog.outError("SESSION: opcode %s (0x%.4X) have unprocessed tail data (read stop at " SIZEFMTD " from " SIZEFMTD ")",
LookupOpcodeName(packet->GetOpcode()),
packet->GetOpcode(),
packet->rpos(),packet->wpos());
}
/// Update the WorldSession (triggered by World update)
@ -217,19 +217,19 @@ bool WorldSession::Update(PacketFilter& updater)
switch (opHandle.status)
{
case STATUS_LOGGEDIN:
if(!_player)
if (!_player)
{
// skip STATUS_LOGGEDIN opcode unexpected errors if player logout sometime ago - this can be network lag delayed packets
if(!m_playerRecentlyLogout)
if (!m_playerRecentlyLogout)
LogUnexpectedOpcode(packet, "the player has not logged in yet");
}
else if(_player->IsInWorld())
else if (_player->IsInWorld())
ExecuteOpcode(opHandle, packet);
// lag can cause STATUS_LOGGEDIN opcodes to arrive after the player started a transfer
break;
case STATUS_LOGGEDIN_OR_RECENTLY_LOGGEDOUT:
if(!_player && !m_playerRecentlyLogout)
if (!_player && !m_playerRecentlyLogout)
{
LogUnexpectedOpcode(packet, "the player has not logged in yet and not recently logout");
}
@ -238,16 +238,16 @@ bool WorldSession::Update(PacketFilter& updater)
ExecuteOpcode(opHandle, packet);
break;
case STATUS_TRANSFER:
if(!_player)
if (!_player)
LogUnexpectedOpcode(packet, "the player has not logged in yet");
else if(_player->IsInWorld())
else if (_player->IsInWorld())
LogUnexpectedOpcode(packet, "the player is still in world");
else
ExecuteOpcode(opHandle, packet);
break;
case STATUS_AUTHED:
// prevent cheating with skip queue wait
if(m_inQueue)
if (m_inQueue)
{
LogUnexpectedOpcode(packet, "the player not pass queue yet");
break;
@ -261,26 +261,26 @@ bool WorldSession::Update(PacketFilter& updater)
ExecuteOpcode(opHandle, packet);
break;
case STATUS_NEVER:
sLog.outError( "SESSION: received not allowed opcode %s (0x%.4X)",
LookupOpcodeName(packet->GetOpcode()),
packet->GetOpcode());
sLog.outError("SESSION: received not allowed opcode %s (0x%.4X)",
LookupOpcodeName(packet->GetOpcode()),
packet->GetOpcode());
break;
case STATUS_UNHANDLED:
DEBUG_LOG("SESSION: received not handled opcode %s (0x%.4X)",
LookupOpcodeName(packet->GetOpcode()),
packet->GetOpcode());
LookupOpcodeName(packet->GetOpcode()),
packet->GetOpcode());
break;
default:
sLog.outError("SESSION: received wrong-status-req opcode %s (0x%.4X)",
LookupOpcodeName(packet->GetOpcode()),
packet->GetOpcode());
LookupOpcodeName(packet->GetOpcode()),
packet->GetOpcode());
break;
}
}
catch (ByteBufferException &)
catch (ByteBufferException&)
{
sLog.outError("WorldSession::Update ByteBufferException occured while parsing a packet (opcode: %u) from client %s, accountid=%i.",
packet->GetOpcode(), GetRemoteAddress().c_str(), GetAccountId());
packet->GetOpcode(), GetRemoteAddress().c_str(), GetAccountId());
if (sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG))
{
DEBUG_LOG("Dumping error causing packet:");
@ -290,7 +290,7 @@ bool WorldSession::Update(PacketFilter& updater)
if (sWorld.getConfig(CONFIG_BOOL_KICK_PLAYER_ON_BAD_PACKET))
{
DETAIL_LOG("Disconnecting session [account id %u / address %s] for badly formatted packet.",
GetAccountId(), GetRemoteAddress().c_str());
GetAccountId(), GetRemoteAddress().c_str());
KickPlayer();
}
@ -300,15 +300,15 @@ bool WorldSession::Update(PacketFilter& updater)
}
///- Cleanup socket pointer if need
if (m_Socket && m_Socket->IsClosed ())
if (m_Socket && m_Socket->IsClosed())
{
m_Socket->RemoveReference ();
m_Socket->RemoveReference();
m_Socket = NULL;
}
//check if we are safe to proceed with logout
//logout procedure should happen only in World::UpdateSessions() method!!!
if(updater.ProcessLogout())
if (updater.ProcessLogout())
{
///- If necessary, log the player out
time_t currTime = time(NULL);
@ -326,7 +326,7 @@ bool WorldSession::Update(PacketFilter& updater)
void WorldSession::LogoutPlayer(bool Save)
{
// finish pending transfers before starting the logout
while(_player && _player->IsBeingTeleportedFar())
while (_player && _player->IsBeingTeleportedFar())
HandleMoveWorldportAckOpcode();
m_playerLogout = true;
@ -355,16 +355,15 @@ void WorldSession::LogoutPlayer(bool Save)
// build set of player who attack _player or who have pet attacking of _player
std::set<Player*> aset;
for(Unit::AttackerSet::const_iterator itr = _player->getAttackers().begin(); itr != _player->getAttackers().end(); ++itr)
for (Unit::AttackerSet::const_iterator itr = _player->getAttackers().begin(); itr != _player->getAttackers().end(); ++itr)
{
Unit* owner = (*itr)->GetOwner(); // including player controlled case
if(owner)
if (owner)
{
if(owner->GetTypeId()==TYPEID_PLAYER)
if (owner->GetTypeId()==TYPEID_PLAYER)
aset.insert((Player*)owner);
}
else
if((*itr)->GetTypeId()==TYPEID_PLAYER)
else if ((*itr)->GetTypeId()==TYPEID_PLAYER)
aset.insert((Player*)(*itr));
}
@ -374,16 +373,16 @@ void WorldSession::LogoutPlayer(bool Save)
_player->RepopAtGraveyard();
// give honor to all attackers from set like group case
for(std::set<Player*>::const_iterator itr = aset.begin(); itr != aset.end(); ++itr)
for (std::set<Player*>::const_iterator itr = aset.begin(); itr != aset.end(); ++itr)
(*itr)->RewardHonor(_player,aset.size());
// give bg rewards and update counters like kill by first from attackers
// this can't be called for all attackers.
if(!aset.empty())
if(BattleGround *bg = _player->GetBattleGround())
if (!aset.empty())
if (BattleGround* bg = _player->GetBattleGround())
bg->HandleKillPlayer(_player,*aset.begin());
}
else if(_player->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))
else if (_player->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))
{
// this will kill character by SPELL_AURA_SPIRIT_OF_REDEMPTION
_player->RemoveSpellsCausingAura(SPELL_AURA_MOD_SHAPESHIFT);
@ -393,11 +392,11 @@ void WorldSession::LogoutPlayer(bool Save)
_player->RepopAtGraveyard();
}
//drop a flag if player is carrying it
if(BattleGround *bg = _player->GetBattleGround())
if (BattleGround* bg = _player->GetBattleGround())
bg->EventPlayerLoggedOut(_player);
///- Teleport to home if the player is in an invalid instance
if(!_player->m_InstanceValid && !_player->isGameMaster())
if (!_player->m_InstanceValid && !_player->isGameMaster())
{
_player->TeleportToHomebind();
//this is a bad place to call for far teleport because we need player to be in world for successful logout
@ -406,12 +405,12 @@ void WorldSession::LogoutPlayer(bool Save)
// FG: finish pending transfers after starting the logout
// this should fix players beeing able to logout and login back with full hp at death position
while(_player->IsBeingTeleportedFar())
while (_player->IsBeingTeleportedFar())
HandleMoveWorldportAckOpcode();
for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
{
if(BattleGroundQueueTypeId bgQueueTypeId = _player->GetBattleGroundQueueTypeId(i))
if (BattleGroundQueueTypeId bgQueueTypeId = _player->GetBattleGroundQueueTypeId(i))
{
_player->RemoveBattleGroundQueueId(bgQueueTypeId);
sBattleGroundMgr.m_BattleGroundQueues[ bgQueueTypeId ].RemovePlayer(_player->GetObjectGuid(), true);
@ -443,7 +442,7 @@ void WorldSession::LogoutPlayer(bool Save)
///- empty buyback items and save the player in the database
// some save parts only correctly work in case player present in map/player_lists (pets, etc)
if(Save)
if (Save)
_player->SaveToDB();
///- Leave all channels before player delete...
@ -454,16 +453,16 @@ void WorldSession::LogoutPlayer(bool Save)
// remove player from the group if he is:
// a) in group; b) not in raid group; c) logging out normally (not being kicked or disconnected)
if(_player->GetGroup() && !_player->GetGroup()->isRaidGroup() && m_Socket)
if (_player->GetGroup() && !_player->GetGroup()->isRaidGroup() && m_Socket)
_player->RemoveFromGroup();
///- Send update to group
if(_player->GetGroup())
if (_player->GetGroup())
_player->GetGroup()->SendUpdate();
///- Broadcast a logout message to the player's friends
sSocialMgr.SendFriendStatus(_player, FRIEND_OFFLINE, _player->GetObjectGuid(), true);
sSocialMgr.RemovePlayerSocial (_player->GetGUIDLow ());
sSocialMgr.RemovePlayerSocial(_player->GetGUIDLow());
///- Remove the player from the world
// the player may not be in the world when logging out
@ -483,8 +482,8 @@ void WorldSession::LogoutPlayer(bool Save)
SetPlayer(NULL); // deleted in Remove/DeleteFromWorld call
///- Send the 'logout complete' packet to the client
WorldPacket data( SMSG_LOGOUT_COMPLETE, 0 );
SendPacket( &data );
WorldPacket data(SMSG_LOGOUT_COMPLETE, 0);
SendPacket(&data);
///- Since each account can only have one online character at any given time, ensure all characters for active account are marked as offline
//No SQL injection as AccountId is uint32
@ -494,7 +493,7 @@ void WorldSession::LogoutPlayer(bool Save)
stmt = CharacterDatabase.CreateStatement(updChars, "UPDATE characters SET online = 0 WHERE account = ?");
stmt.PExecute(GetAccountId());
DEBUG_LOG( "SESSION: Sent SMSG_LOGOUT_COMPLETE Message" );
DEBUG_LOG("SESSION: Sent SMSG_LOGOUT_COMPLETE Message");
}
m_playerLogout = false;
@ -507,7 +506,7 @@ void WorldSession::LogoutPlayer(bool Save)
void WorldSession::KickPlayer()
{
if (m_Socket)
m_Socket->CloseSocket ();
m_Socket->CloseSocket();
}
/// Cancel channeling handler
@ -519,7 +518,7 @@ void WorldSession::SendAreaTriggerMessage(const char* Text, ...)
szStr[0] = '\0';
va_start(ap, Text);
vsnprintf( szStr, 1024, Text, ap );
vsnprintf(szStr, 1024, Text, ap);
va_end(ap);
uint32 length = strlen(szStr)+1;
@ -529,15 +528,15 @@ void WorldSession::SendAreaTriggerMessage(const char* Text, ...)
SendPacket(&data);
}
void WorldSession::SendNotification(const char *format,...)
void WorldSession::SendNotification(const char* format,...)
{
if(format)
if (format)
{
va_list ap;
char szStr [1024];
szStr[0] = '\0';
va_start(ap, format);
vsnprintf( szStr, 1024, format, ap );
vsnprintf(szStr, 1024, format, ap);
va_end(ap);
WorldPacket data(SMSG_NOTIFICATION, (strlen(szStr)+1));
@ -549,13 +548,13 @@ void WorldSession::SendNotification(const char *format,...)
void WorldSession::SendNotification(int32 string_id,...)
{
char const* format = GetMangosString(string_id);
if(format)
if (format)
{
va_list ap;
char szStr [1024];
szStr[0] = '\0';
va_start(ap, string_id);
vsnprintf( szStr, 1024, format, ap );
vsnprintf(szStr, 1024, format, ap);
va_end(ap);
WorldPacket data(SMSG_NOTIFICATION, (strlen(szStr)+1));
@ -571,50 +570,50 @@ void WorldSession::SendSetPhaseShift(uint32 PhaseShift)
SendPacket(&data);
}
const char * WorldSession::GetMangosString( int32 entry ) const
const char* WorldSession::GetMangosString(int32 entry) const
{
return sObjectMgr.GetMangosString(entry,GetSessionDbLocaleIndex());
}
void WorldSession::Handle_NULL( WorldPacket& recvPacket )
void WorldSession::Handle_NULL(WorldPacket& recvPacket)
{
DEBUG_LOG("SESSION: received unimplemented opcode %s (0x%.4X)",
LookupOpcodeName(recvPacket.GetOpcode()),
recvPacket.GetOpcode());
LookupOpcodeName(recvPacket.GetOpcode()),
recvPacket.GetOpcode());
}
void WorldSession::Handle_EarlyProccess( WorldPacket& recvPacket )
void WorldSession::Handle_EarlyProccess(WorldPacket& recvPacket)
{
sLog.outError( "SESSION: received opcode %s (0x%.4X) that must be processed in WorldSocket::OnRead",
LookupOpcodeName(recvPacket.GetOpcode()),
recvPacket.GetOpcode());
sLog.outError("SESSION: received opcode %s (0x%.4X) that must be processed in WorldSocket::OnRead",
LookupOpcodeName(recvPacket.GetOpcode()),
recvPacket.GetOpcode());
}
void WorldSession::Handle_ServerSide( WorldPacket& recvPacket )
void WorldSession::Handle_ServerSide(WorldPacket& recvPacket)
{
sLog.outError("SESSION: received server-side opcode %s (0x%.4X)",
LookupOpcodeName(recvPacket.GetOpcode()),
recvPacket.GetOpcode());
LookupOpcodeName(recvPacket.GetOpcode()),
recvPacket.GetOpcode());
}
void WorldSession::Handle_Deprecated( WorldPacket& recvPacket )
void WorldSession::Handle_Deprecated(WorldPacket& recvPacket)
{
sLog.outError( "SESSION: received deprecated opcode %s (0x%.4X)",
LookupOpcodeName(recvPacket.GetOpcode()),
recvPacket.GetOpcode());
sLog.outError("SESSION: received deprecated opcode %s (0x%.4X)",
LookupOpcodeName(recvPacket.GetOpcode()),
recvPacket.GetOpcode());
}
void WorldSession::SendAuthWaitQue(uint32 position)
{
if(position == 0)
if (position == 0)
{
WorldPacket packet( SMSG_AUTH_RESPONSE, 1 );
packet << uint8( AUTH_OK );
WorldPacket packet(SMSG_AUTH_RESPONSE, 1);
packet << uint8(AUTH_OK);
SendPacket(&packet);
}
else
{
WorldPacket packet( SMSG_AUTH_RESPONSE, 1+4+1 );
WorldPacket packet(SMSG_AUTH_RESPONSE, 1+4+1);
packet << uint8(AUTH_WAIT_QUEUE);
packet << uint32(position);
packet << uint8(0); // unk 3.3.0
@ -636,32 +635,33 @@ void WorldSession::LoadAccountData(QueryResult* result, uint32 mask)
if (mask & (1 << i))
m_accountData[i] = AccountData();
if(!result)
if (!result)
return;
do
{
Field *fields = result->Fetch();
Field* fields = result->Fetch();
uint32 type = fields[0].GetUInt32();
if (type >= NUM_ACCOUNT_DATA_TYPES)
{
sLog.outError("Table `%s` have invalid account data type (%u), ignore.",
mask == GLOBAL_CACHE_MASK ? "account_data" : "character_account_data", type);
mask == GLOBAL_CACHE_MASK ? "account_data" : "character_account_data", type);
continue;
}
if ((mask & (1 << type))==0)
{
sLog.outError("Table `%s` have non appropriate for table account data type (%u), ignore.",
mask == GLOBAL_CACHE_MASK ? "account_data" : "character_account_data", type);
mask == GLOBAL_CACHE_MASK ? "account_data" : "character_account_data", type);
continue;
}
m_accountData[type].Time = time_t(fields[1].GetUInt64());
m_accountData[type].Data = fields[2].GetCppString();
} while (result->NextRow());
}
while (result->NextRow());
delete result;
}
@ -675,7 +675,7 @@ void WorldSession::SetAccountData(AccountDataType type, time_t time_, std::strin
static SqlStatementID delId;
static SqlStatementID insId;
CharacterDatabase.BeginTransaction ();
CharacterDatabase.BeginTransaction();
SqlStatement stmt = CharacterDatabase.CreateStatement(delId, "DELETE FROM account_data WHERE account=? AND type=?");
stmt.PExecute(acc, uint32(type));
@ -683,18 +683,18 @@ void WorldSession::SetAccountData(AccountDataType type, time_t time_, std::strin
stmt = CharacterDatabase.CreateStatement(insId, "INSERT INTO account_data VALUES (?,?,?,?)");
stmt.PExecute(acc, uint32(type), uint64(time_), data.c_str());
CharacterDatabase.CommitTransaction ();
CharacterDatabase.CommitTransaction();
}
else
{
// _player can be NULL and packet received after logout but m_GUID still store correct guid
if(!m_GUIDLow)
if (!m_GUIDLow)
return;
static SqlStatementID delId;
static SqlStatementID insId;
CharacterDatabase.BeginTransaction ();
CharacterDatabase.BeginTransaction();
SqlStatement stmt = CharacterDatabase.CreateStatement(delId, "DELETE FROM character_account_data WHERE guid=? AND type=?");
stmt.PExecute(m_GUIDLow, uint32(type));
@ -702,7 +702,7 @@ void WorldSession::SetAccountData(AccountDataType type, time_t time_, std::strin
stmt = CharacterDatabase.CreateStatement(insId, "INSERT INTO character_account_data VALUES (?,?,?,?)");
stmt.PExecute(m_GUIDLow, uint32(type), uint64(time_), data.c_str());
CharacterDatabase.CommitTransaction ();
CharacterDatabase.CommitTransaction();
}
m_accountData[type].Time = time_;
@ -711,24 +711,24 @@ void WorldSession::SetAccountData(AccountDataType type, time_t time_, std::strin
void WorldSession::SendAccountDataTimes(uint32 mask)
{
WorldPacket data( SMSG_ACCOUNT_DATA_TIMES, 4+1+4+8*4 ); // changed in WotLK
WorldPacket data(SMSG_ACCOUNT_DATA_TIMES, 4+1+4+8*4); // changed in WotLK
data << uint32(time(NULL)); // unix time of something
data << uint8(1);
data << uint32(mask); // type mask
for(uint32 i = 0; i < NUM_ACCOUNT_DATA_TYPES; ++i)
if(mask & (1 << i))
for (uint32 i = 0; i < NUM_ACCOUNT_DATA_TYPES; ++i)
if (mask & (1 << i))
data << uint32(GetAccountData(AccountDataType(i))->Time);// also unix time
SendPacket(&data);
}
void WorldSession::LoadTutorialsData()
{
for ( int aX = 0 ; aX < 8 ; ++aX )
for (int aX = 0 ; aX < 8 ; ++aX)
m_Tutorials[ aX ] = 0;
QueryResult *result = CharacterDatabase.PQuery("SELECT tut0,tut1,tut2,tut3,tut4,tut5,tut6,tut7 FROM character_tutorial WHERE account = '%u'", GetAccountId());
QueryResult* result = CharacterDatabase.PQuery("SELECT tut0,tut1,tut2,tut3,tut4,tut5,tut6,tut7 FROM character_tutorial WHERE account = '%u'", GetAccountId());
if(!result)
if (!result)
{
m_tutorialState = TUTORIALDATA_NEW;
return;
@ -736,12 +736,12 @@ void WorldSession::LoadTutorialsData()
do
{
Field *fields = result->Fetch();
Field* fields = result->Fetch();
for (int iI = 0; iI < 8; ++iI)
m_Tutorials[iI] = fields[iI].GetUInt32();
}
while( result->NextRow() );
while (result->NextRow());
delete result;
@ -751,7 +751,7 @@ void WorldSession::LoadTutorialsData()
void WorldSession::SendTutorialsData()
{
WorldPacket data(SMSG_TUTORIAL_FLAGS, 4*8);
for(uint32 i = 0; i < 8; ++i)
for (uint32 i = 0; i < 8; ++i)
data << m_Tutorials[i];
SendPacket(&data);
}
@ -761,30 +761,30 @@ void WorldSession::SaveTutorialsData()
static SqlStatementID updTutorial ;
static SqlStatementID insTutorial ;
switch(m_tutorialState)
switch (m_tutorialState)
{
case TUTORIALDATA_CHANGED:
{
SqlStatement stmt = CharacterDatabase.CreateStatement(updTutorial, "UPDATE character_tutorial SET tut0=?, tut1=?, tut2=?, tut3=?, tut4=?, tut5=?, tut6=?, tut7=? WHERE account = ?");
for (int i = 0; i < 8; ++i)
stmt.addUInt32(m_Tutorials[i]);
{
SqlStatement stmt = CharacterDatabase.CreateStatement(updTutorial, "UPDATE character_tutorial SET tut0=?, tut1=?, tut2=?, tut3=?, tut4=?, tut5=?, tut6=?, tut7=? WHERE account = ?");
for (int i = 0; i < 8; ++i)
stmt.addUInt32(m_Tutorials[i]);
stmt.addUInt32(GetAccountId());
stmt.Execute();
}
break;
stmt.addUInt32(GetAccountId());
stmt.Execute();
}
break;
case TUTORIALDATA_NEW:
{
SqlStatement stmt = CharacterDatabase.CreateStatement(insTutorial, "INSERT INTO character_tutorial (account,tut0,tut1,tut2,tut3,tut4,tut5,tut6,tut7) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
{
SqlStatement stmt = CharacterDatabase.CreateStatement(insTutorial, "INSERT INTO character_tutorial (account,tut0,tut1,tut2,tut3,tut4,tut5,tut6,tut7) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
stmt.addUInt32(GetAccountId());
for (int i = 0; i < 8; ++i)
stmt.addUInt32(m_Tutorials[i]);
stmt.addUInt32(GetAccountId());
for (int i = 0; i < 8; ++i)
stmt.addUInt32(m_Tutorials[i]);
stmt.Execute();
}
break;
stmt.Execute();
}
break;
case TUTORIALDATA_UNCHANGED:
break;
}
@ -792,17 +792,17 @@ void WorldSession::SaveTutorialsData()
m_tutorialState = TUTORIALDATA_UNCHANGED;
}
void WorldSession::ReadAddonsInfo(WorldPacket &data)
void WorldSession::ReadAddonsInfo(WorldPacket& data)
{
if (data.rpos() + 4 > data.size())
return;
uint32 size;
data >> size;
if(!size)
if (!size)
return;
if(size > 0xFFFFF)
if (size > 0xFFFFF)
{
sLog.outError("WorldSession::ReadAddonsInfo addon info too big, size %u", size);
return;
@ -820,14 +820,14 @@ void WorldSession::ReadAddonsInfo(WorldPacket &data)
uint32 addonsCount;
addonInfo >> addonsCount; // addons count
for(uint32 i = 0; i < addonsCount; ++i)
for (uint32 i = 0; i < addonsCount; ++i)
{
std::string addonName;
uint8 enabled;
uint32 crc, unk1;
// check next addon data format correctness
if(addonInfo.rpos()+1 > addonInfo.size())
if (addonInfo.rpos()+1 > addonInfo.size())
return;
addonInfo >> addonName;
@ -842,7 +842,7 @@ void WorldSession::ReadAddonsInfo(WorldPacket &data)
uint32 unk2;
addonInfo >> unk2;
if(addonInfo.rpos() != addonInfo.size())
if (addonInfo.rpos() != addonInfo.size())
DEBUG_LOG("packet under read!");
}
else
@ -873,7 +873,7 @@ void WorldSession::SendAddonsInfo()
WorldPacket data(SMSG_ADDON_INFO, 4);
for(AddonsList::iterator itr = m_addonsList.begin(); itr != m_addonsList.end(); ++itr)
for (AddonsList::iterator itr = m_addonsList.begin(); itr != m_addonsList.end(); ++itr)
{
uint8 state = 2; // 2 is sent here
data << uint8(state);
@ -916,12 +916,12 @@ void WorldSession::SendAddonsInfo()
SendPacket(&data);
}
void WorldSession::SetPlayer( Player *plr )
void WorldSession::SetPlayer(Player* plr)
{
_player = plr;
// set m_GUID that can be used while player loggined and later until m_playerRecentlyLogout not reset
if(_player)
if (_player)
m_GUIDLow = _player->GetGUIDLow();
}
@ -944,7 +944,7 @@ void WorldSession::SendRedirectClient(std::string& ip, uint16 port)
SendPacket(&pkt);
}
void WorldSession::ExecuteOpcode( OpcodeHandler const& opHandle, WorldPacket* packet )
void WorldSession::ExecuteOpcode(OpcodeHandler const& opHandle, WorldPacket* packet)
{
// need prevent do internal far teleports in handlers because some handlers do lot steps
// or call code that can do far teleports in some conditions unexpectedly for generic way work code