Various Cleanups (game L-M)

This commit is contained in:
Schmoozerd 2012-07-19 21:46:40 +02:00
parent 2bd41afb3e
commit 8d0c106aa4
29 changed files with 2201 additions and 2163 deletions

View file

@ -23,7 +23,7 @@
#include "ObjectMgr.h" #include "ObjectMgr.h"
#include "World.h" #include "World.h"
void WorldSession::HandleLfgJoinOpcode( WorldPacket & recv_data ) void WorldSession::HandleLfgJoinOpcode(WorldPacket& recv_data)
{ {
DEBUG_LOG("CMSG_LFG_JOIN"); DEBUG_LOG("CMSG_LFG_JOIN");
@ -53,14 +53,14 @@ void WorldSession::HandleLfgJoinOpcode( WorldPacket & recv_data )
//SendLfgUpdate(false, LFG_UPDATE_JOIN, dungeons[0]); //SendLfgUpdate(false, LFG_UPDATE_JOIN, dungeons[0]);
} }
void WorldSession::HandleLfgLeaveOpcode( WorldPacket & /*recv_data*/ ) void WorldSession::HandleLfgLeaveOpcode(WorldPacket& /*recv_data*/)
{ {
DEBUG_LOG("CMSG_LFG_LEAVE"); DEBUG_LOG("CMSG_LFG_LEAVE");
//SendLfgUpdate(false, LFG_UPDATE_LEAVE, 0); //SendLfgUpdate(false, LFG_UPDATE_LEAVE, 0);
} }
void WorldSession::HandleSearchLfgJoinOpcode( WorldPacket & recv_data ) void WorldSession::HandleSearchLfgJoinOpcode(WorldPacket& recv_data)
{ {
DEBUG_LOG("CMSG_LFG_SEARCH_JOIN"); DEBUG_LOG("CMSG_LFG_SEARCH_JOIN");
@ -73,14 +73,14 @@ void WorldSession::HandleSearchLfgJoinOpcode( WorldPacket & recv_data )
//SendLfgSearchResults(type, entry); //SendLfgSearchResults(type, entry);
} }
void WorldSession::HandleSearchLfgLeaveOpcode( WorldPacket & recv_data ) void WorldSession::HandleSearchLfgLeaveOpcode(WorldPacket& recv_data)
{ {
DEBUG_LOG("CMSG_LFG_SEARCH_LEAVE"); DEBUG_LOG("CMSG_LFG_SEARCH_LEAVE");
recv_data >> Unused<uint32>(); // join id? recv_data >> Unused<uint32>(); // join id?
} }
void WorldSession::HandleSetLfgCommentOpcode( WorldPacket & recv_data ) void WorldSession::HandleSetLfgCommentOpcode(WorldPacket& recv_data)
{ {
DEBUG_LOG("CMSG_SET_LFG_COMMENT"); DEBUG_LOG("CMSG_SET_LFG_COMMENT");
@ -97,11 +97,11 @@ void WorldSession::SendLfgSearchResults(LfgType type, uint32 entry)
uint8 isGuidsPresent = 0; uint8 isGuidsPresent = 0;
data << uint8(isGuidsPresent); data << uint8(isGuidsPresent);
if(isGuidsPresent) if (isGuidsPresent)
{ {
uint32 guids_count = 0; uint32 guids_count = 0;
data << uint32(guids_count); data << uint32(guids_count);
for(uint32 i = 0; i < guids_count; ++i) for (uint32 i = 0; i < guids_count; ++i)
{ {
data << uint64(0); // player/group guid data << uint64(0); // player/group guid
} }
@ -111,25 +111,25 @@ void WorldSession::SendLfgSearchResults(LfgType type, uint32 entry)
data << uint32(groups_count); // groups count data << uint32(groups_count); // groups count
data << uint32(groups_count); // groups count (total?) data << uint32(groups_count); // groups count (total?)
for(uint32 i = 0; i < groups_count; ++i) for (uint32 i = 0; i < groups_count; ++i)
{ {
data << uint64(1); // group guid data << uint64(1); // group guid
uint32 flags = 0x92; uint32 flags = 0x92;
data << uint32(flags); // flags data << uint32(flags); // flags
if(flags & 0x2) if (flags & 0x2)
{ {
data << uint8(0); // comment string, max len 256 data << uint8(0); // comment string, max len 256
} }
if(flags & 0x10) if (flags & 0x10)
{ {
for(uint32 j = 0; j < 3; ++j) for (uint32 j = 0; j < 3; ++j)
data << uint8(0); // roles data << uint8(0); // roles
} }
if(flags & 0x80) if (flags & 0x80)
{ {
data << uint64(0); // instance guid data << uint64(0); // instance guid
data << uint32(0); // completed encounters data << uint32(0); // completed encounters
@ -144,7 +144,7 @@ void WorldSession::SendLfgSearchResults(LfgType type, uint32 entry)
for (HashMapHolder<Player>::MapType::const_iterator iter = players.begin(); iter != players.end(); ++iter) for (HashMapHolder<Player>::MapType::const_iterator iter = players.begin(); iter != players.end(); ++iter)
{ {
Player *plr = iter->second; Player* plr = iter->second;
if (!plr || plr->GetTeam() != _player->GetTeam()) if (!plr || plr->GetTeam() != _player->GetTeam())
continue; continue;
@ -163,7 +163,7 @@ void WorldSession::SendLfgSearchResults(LfgType type, uint32 entry)
data << uint8(plr->getClass()); data << uint8(plr->getClass());
data << uint8(plr->getRace()); data << uint8(plr->getRace());
for(uint32 i = 0; i < 3; ++i) for (uint32 i = 0; i < 3; ++i)
data << uint8(0); // talent spec x/x/x data << uint8(0); // talent spec x/x/x
data << uint32(0); // armor data << uint32(0); // armor
@ -222,15 +222,15 @@ void WorldSession::SendLfgJoinResult(LfgJoinResult result)
data << uint32(result); data << uint32(result);
data << uint32(0); // ERR_LFG_ROLE_CHECK_FAILED_TIMEOUT = 3, ERR_LFG_ROLE_CHECK_FAILED_NOT_VIABLE = (value - 3 == result) data << uint32(0); // ERR_LFG_ROLE_CHECK_FAILED_TIMEOUT = 3, ERR_LFG_ROLE_CHECK_FAILED_NOT_VIABLE = (value - 3 == result)
if(result == ERR_LFG_NO_SLOTS_PARTY) if (result == ERR_LFG_NO_SLOTS_PARTY)
{ {
uint8 count1 = 0; uint8 count1 = 0;
data << uint8(count1); // players count? data << uint8(count1); // players count?
for(uint32 i = 0; i < count1; ++i) for (uint32 i = 0; i < count1; ++i)
{ {
data << uint64(0); // player guid? data << uint64(0); // player guid?
uint32 count2 = 0; uint32 count2 = 0;
for(uint32 j = 0; j < count2; ++j) for (uint32 j = 0; j < count2; ++j)
{ {
data << uint32(0); // dungeon id/type data << uint32(0); // dungeon id/type
data << uint32(0); // lock status? data << uint32(0); // lock status?
@ -249,22 +249,22 @@ void WorldSession::SendLfgUpdate(bool isGroup, LfgUpdateType updateType, uint32
uint8 extra = updateType == LFG_UPDATE_JOIN ? 1 : 0; uint8 extra = updateType == LFG_UPDATE_JOIN ? 1 : 0;
data << uint8(extra); data << uint8(extra);
if(extra) if (extra)
{ {
data << uint8(0); data << uint8(0);
data << uint8(0); data << uint8(0);
data << uint8(0); data << uint8(0);
if(isGroup) if (isGroup)
{ {
data << uint8(0); data << uint8(0);
for(uint32 i = 0; i < 3; ++i) for (uint32 i = 0; i < 3; ++i)
data << uint8(0); data << uint8(0);
} }
uint8 count = 1; uint8 count = 1;
data << uint8(count); data << uint8(count);
for(uint32 i = 0; i < count; ++i) for (uint32 i = 0; i < count; ++i)
data << uint32(id); data << uint32(id);
data << ""; data << "";
} }

View file

@ -33,7 +33,7 @@
bool ChatHandler::HandleHelpCommand(char* args) bool ChatHandler::HandleHelpCommand(char* args)
{ {
if(!*args) if (!*args)
{ {
ShowHelpForCommand(getCommandTable(), "help"); ShowHelpForCommand(getCommandTable(), "help");
ShowHelpForCommand(getCommandTable(), ""); ShowHelpForCommand(getCommandTable(), "");
@ -66,16 +66,16 @@ bool ChatHandler::HandleAccountCommand(char* args)
bool ChatHandler::HandleStartCommand(char* /*args*/) bool ChatHandler::HandleStartCommand(char* /*args*/)
{ {
Player *chr = m_session->GetPlayer(); Player* chr = m_session->GetPlayer();
if(chr->IsTaxiFlying()) if (chr->IsTaxiFlying())
{ {
SendSysMessage(LANG_YOU_IN_FLIGHT); SendSysMessage(LANG_YOU_IN_FLIGHT);
SetSentErrorMessage(true); SetSentErrorMessage(true);
return false; return false;
} }
if(chr->isInCombat()) if (chr->isInCombat())
{ {
SendSysMessage(LANG_YOU_IN_COMBAT); SendSysMessage(LANG_YOU_IN_COMBAT);
SetSentErrorMessage(true); SetSentErrorMessage(true);
@ -96,7 +96,7 @@ bool ChatHandler::HandleServerInfoCommand(char* /*args*/)
std::string str = secsToTimeString(sWorld.GetUptime()); std::string str = secsToTimeString(sWorld.GetUptime());
char const* full; char const* full;
if(m_session) if (m_session)
full = _FULLVERSION(REVISION_DATE,REVISION_TIME,REVISION_NR,"|cffffffff|Hurl:" REVISION_ID "|h" REVISION_ID "|h|r"); full = _FULLVERSION(REVISION_DATE,REVISION_TIME,REVISION_NR,"|cffffffff|Hurl:" REVISION_ID "|h" REVISION_ID "|h|r");
else else
full = _FULLVERSION(REVISION_DATE,REVISION_TIME,REVISION_NR,REVISION_ID); full = _FULLVERSION(REVISION_DATE,REVISION_TIME,REVISION_NR,REVISION_ID);
@ -124,14 +124,14 @@ bool ChatHandler::HandleServerInfoCommand(char* /*args*/)
bool ChatHandler::HandleDismountCommand(char* /*args*/) bool ChatHandler::HandleDismountCommand(char* /*args*/)
{ {
//If player is not mounted, so go out :) //If player is not mounted, so go out :)
if (!m_session->GetPlayer( )->IsMounted()) if (!m_session->GetPlayer()->IsMounted())
{ {
SendSysMessage(LANG_CHAR_NON_MOUNTED); SendSysMessage(LANG_CHAR_NON_MOUNTED);
SetSentErrorMessage(true); SetSentErrorMessage(true);
return false; return false;
} }
if(m_session->GetPlayer( )->IsTaxiFlying()) if (m_session->GetPlayer()->IsTaxiFlying())
{ {
SendSysMessage(LANG_YOU_IN_FLIGHT); SendSysMessage(LANG_YOU_IN_FLIGHT);
SetSentErrorMessage(true); SetSentErrorMessage(true);
@ -145,10 +145,10 @@ bool ChatHandler::HandleDismountCommand(char* /*args*/)
bool ChatHandler::HandleSaveCommand(char* /*args*/) bool ChatHandler::HandleSaveCommand(char* /*args*/)
{ {
Player *player=m_session->GetPlayer(); Player* player=m_session->GetPlayer();
// save GM account without delay and output message (testing, etc) // save GM account without delay and output message (testing, etc)
if(GetAccessLevel() > SEC_PLAYER) if (GetAccessLevel() > SEC_PLAYER)
{ {
player->SaveToDB(); player->SaveToDB();
SendSysMessage(LANG_PLAYER_SAVED); SendSysMessage(LANG_PLAYER_SAVED);
@ -169,12 +169,12 @@ bool ChatHandler::HandleGMListIngameCommand(char* /*args*/)
{ {
HashMapHolder<Player>::ReadGuard g(HashMapHolder<Player>::GetLock()); HashMapHolder<Player>::ReadGuard g(HashMapHolder<Player>::GetLock());
HashMapHolder<Player>::MapType &m = sObjectAccessor.GetPlayers(); HashMapHolder<Player>::MapType& m = sObjectAccessor.GetPlayers();
for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr) for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
{ {
AccountTypes itr_sec = itr->second->GetSession()->GetSecurity(); AccountTypes itr_sec = itr->second->GetSession()->GetSecurity();
if ((itr->second->isGameMaster() || (itr_sec > SEC_PLAYER && itr_sec <= (AccountTypes)sWorld.getConfig(CONFIG_UINT32_GM_LEVEL_IN_GM_LIST))) && if ((itr->second->isGameMaster() || (itr_sec > SEC_PLAYER && itr_sec <= (AccountTypes)sWorld.getConfig(CONFIG_UINT32_GM_LEVEL_IN_GM_LIST))) &&
(!m_session || itr->second->IsVisibleGloballyFor(m_session->GetPlayer()))) (!m_session || itr->second->IsVisibleGloballyFor(m_session->GetPlayer())))
names.push_back(std::make_pair<std::string, bool>(GetNameLink(itr->second), itr->second->isAcceptWhispers())); names.push_back(std::make_pair<std::string, bool>(GetNameLink(itr->second), itr->second->isAcceptWhispers()));
} }
} }
@ -185,7 +185,7 @@ bool ChatHandler::HandleGMListIngameCommand(char* /*args*/)
char const* accepts = GetMangosString(LANG_GM_ACCEPTS_WHISPER); char const* accepts = GetMangosString(LANG_GM_ACCEPTS_WHISPER);
char const* not_accept = GetMangosString(LANG_GM_NO_WHISPER); char const* not_accept = GetMangosString(LANG_GM_NO_WHISPER);
for(std::list<std::pair< std::string, bool> >::const_iterator iter = names.begin(); iter != names.end(); ++iter) for (std::list<std::pair< std::string, bool> >::const_iterator iter = names.begin(); iter != names.end(); ++iter)
PSendSysMessage("%s - %s", iter->first.c_str(), iter->second ? accepts : not_accept); PSendSysMessage("%s - %s", iter->first.c_str(), iter->second ? accepts : not_accept);
} }
else else
@ -199,15 +199,15 @@ bool ChatHandler::HandleAccountPasswordCommand(char* args)
// allow use from RA, but not from console (not have associated account id) // allow use from RA, but not from console (not have associated account id)
if (!GetAccountId()) if (!GetAccountId())
{ {
SendSysMessage (LANG_RA_ONLY_COMMAND); SendSysMessage(LANG_RA_ONLY_COMMAND);
SetSentErrorMessage (true); SetSentErrorMessage(true);
return false; return false;
} }
// allow or quoted string with possible spaces or literal without spaces // allow or quoted string with possible spaces or literal without spaces
char *old_pass = ExtractQuotedOrLiteralArg(&args); char* old_pass = ExtractQuotedOrLiteralArg(&args);
char *new_pass = ExtractQuotedOrLiteralArg(&args); char* new_pass = ExtractQuotedOrLiteralArg(&args);
char *new_pass_c = ExtractQuotedOrLiteralArg(&args); char* new_pass_c = ExtractQuotedOrLiteralArg(&args);
if (!old_pass || !new_pass || !new_pass_c) if (!old_pass || !new_pass || !new_pass_c)
return false; return false;
@ -218,21 +218,21 @@ bool ChatHandler::HandleAccountPasswordCommand(char* args)
if (password_new != password_new_c) if (password_new != password_new_c)
{ {
SendSysMessage (LANG_NEW_PASSWORDS_NOT_MATCH); SendSysMessage(LANG_NEW_PASSWORDS_NOT_MATCH);
SetSentErrorMessage (true); SetSentErrorMessage(true);
return false; return false;
} }
if (!sAccountMgr.CheckPassword (GetAccountId(), password_old)) if (!sAccountMgr.CheckPassword(GetAccountId(), password_old))
{ {
SendSysMessage (LANG_COMMAND_WRONGOLDPASSWORD); SendSysMessage(LANG_COMMAND_WRONGOLDPASSWORD);
SetSentErrorMessage (true); SetSentErrorMessage(true);
return false; return false;
} }
AccountOpResult result = sAccountMgr.ChangePassword(GetAccountId(), password_new); AccountOpResult result = sAccountMgr.ChangePassword(GetAccountId(), password_new);
switch(result) switch (result)
{ {
case AOR_OK: case AOR_OK:
SendSysMessage(LANG_COMMAND_PASSWORD); SendSysMessage(LANG_COMMAND_PASSWORD);
@ -259,8 +259,8 @@ bool ChatHandler::HandleAccountLockCommand(char* args)
// allow use from RA, but not from console (not have associated account id) // allow use from RA, but not from console (not have associated account id)
if (!GetAccountId()) if (!GetAccountId())
{ {
SendSysMessage (LANG_RA_ONLY_COMMAND); SendSysMessage(LANG_RA_ONLY_COMMAND);
SetSentErrorMessage (true); SetSentErrorMessage(true);
return false; return false;
} }
@ -274,12 +274,12 @@ bool ChatHandler::HandleAccountLockCommand(char* args)
if (value) if (value)
{ {
LoginDatabase.PExecute( "UPDATE account SET locked = '1' WHERE id = '%u'", GetAccountId()); LoginDatabase.PExecute("UPDATE account SET locked = '1' WHERE id = '%u'", GetAccountId());
PSendSysMessage(LANG_COMMAND_ACCLOCKLOCKED); PSendSysMessage(LANG_COMMAND_ACCLOCKLOCKED);
} }
else else
{ {
LoginDatabase.PExecute( "UPDATE account SET locked = '0' WHERE id = '%u'", GetAccountId()); LoginDatabase.PExecute("UPDATE account SET locked = '0' WHERE id = '%u'", GetAccountId());
PSendSysMessage(LANG_COMMAND_ACCLOCKUNLOCKED); PSendSysMessage(LANG_COMMAND_ACCLOCKUNLOCKED);
} }

View file

@ -41,11 +41,11 @@
//-----------------------Npc Commands----------------------- //-----------------------Npc Commands-----------------------
bool ChatHandler::HandleNpcSayCommand(char* args) bool ChatHandler::HandleNpcSayCommand(char* args)
{ {
if(!*args) if (!*args)
return false; return false;
Creature* pCreature = getSelectedCreature(); Creature* pCreature = getSelectedCreature();
if(!pCreature) if (!pCreature)
{ {
SendSysMessage(LANG_SELECT_CREATURE); SendSysMessage(LANG_SELECT_CREATURE);
SetSentErrorMessage(true); SetSentErrorMessage(true);
@ -59,11 +59,11 @@ bool ChatHandler::HandleNpcSayCommand(char* args)
bool ChatHandler::HandleNpcYellCommand(char* args) bool ChatHandler::HandleNpcYellCommand(char* args)
{ {
if(!*args) if (!*args)
return false; return false;
Creature* pCreature = getSelectedCreature(); Creature* pCreature = getSelectedCreature();
if(!pCreature) if (!pCreature)
{ {
SendSysMessage(LANG_SELECT_CREATURE); SendSysMessage(LANG_SELECT_CREATURE);
SetSentErrorMessage(true); SetSentErrorMessage(true);
@ -78,12 +78,12 @@ bool ChatHandler::HandleNpcYellCommand(char* args)
//show text emote by creature in chat //show text emote by creature in chat
bool ChatHandler::HandleNpcTextEmoteCommand(char* args) bool ChatHandler::HandleNpcTextEmoteCommand(char* args)
{ {
if(!*args) if (!*args)
return false; return false;
Creature* pCreature = getSelectedCreature(); Creature* pCreature = getSelectedCreature();
if(!pCreature) if (!pCreature)
{ {
SendSysMessage(LANG_SELECT_CREATURE); SendSysMessage(LANG_SELECT_CREATURE);
SetSentErrorMessage(true); SetSentErrorMessage(true);
@ -108,7 +108,7 @@ bool ChatHandler::HandleNpcWhisperCommand(char* args)
Creature* pCreature = m_session->GetPlayer()->GetMap()->GetCreature(guid); Creature* pCreature = m_session->GetPlayer()->GetMap()->GetCreature(guid);
if(!pCreature || !target || !*args) if (!pCreature || !target || !*args)
return false; return false;
// check online security // check online security
@ -124,7 +124,7 @@ bool ChatHandler::HandleNpcWhisperCommand(char* args)
// global announce // global announce
bool ChatHandler::HandleAnnounceCommand(char* args) bool ChatHandler::HandleAnnounceCommand(char* args)
{ {
if(!*args) if (!*args)
return false; return false;
sWorld.SendWorldText(LANG_SYSTEMMESSAGE,args); sWorld.SendWorldText(LANG_SYSTEMMESSAGE,args);
@ -134,7 +134,7 @@ bool ChatHandler::HandleAnnounceCommand(char* args)
//notification player at the screen //notification player at the screen
bool ChatHandler::HandleNotifyCommand(char* args) bool ChatHandler::HandleNotifyCommand(char* args)
{ {
if(!*args) if (!*args)
return false; return false;
std::string str = GetMangosString(LANG_GLOBAL_NOTIFY); std::string str = GetMangosString(LANG_GLOBAL_NOTIFY);
@ -150,9 +150,9 @@ bool ChatHandler::HandleNotifyCommand(char* args)
//Enable\Dissable GM Mode //Enable\Dissable GM Mode
bool ChatHandler::HandleGMCommand(char* args) bool ChatHandler::HandleGMCommand(char* args)
{ {
if(!*args) if (!*args)
{ {
if(m_session->GetPlayer()->isGameMaster()) if (m_session->GetPlayer()->isGameMaster())
m_session->SendNotification(LANG_GM_ON); m_session->SendNotification(LANG_GM_ON);
else else
m_session->SendNotification(LANG_GM_OFF); m_session->SendNotification(LANG_GM_OFF);
@ -184,9 +184,9 @@ bool ChatHandler::HandleGMCommand(char* args)
// Enables or disables hiding of the staff badge // Enables or disables hiding of the staff badge
bool ChatHandler::HandleGMChatCommand(char* args) bool ChatHandler::HandleGMChatCommand(char* args)
{ {
if(!*args) if (!*args)
{ {
if(m_session->GetPlayer()->isGMChat()) if (m_session->GetPlayer()->isGMChat())
m_session->SendNotification(LANG_GM_CHAT_ON); m_session->SendNotification(LANG_GM_CHAT_ON);
else else
m_session->SendNotification(LANG_GM_CHAT_OFF); m_session->SendNotification(LANG_GM_CHAT_OFF);
@ -257,13 +257,13 @@ bool ChatHandler::HandleGMVisibleCommand(char* args)
bool ChatHandler::HandleGPSCommand(char* args) bool ChatHandler::HandleGPSCommand(char* args)
{ {
WorldObject *obj = NULL; WorldObject* obj = NULL;
if (*args) if (*args)
{ {
if (ObjectGuid guid = ExtractGuidFromLink(&args)) if (ObjectGuid guid = ExtractGuidFromLink(&args))
obj = (WorldObject*)m_session->GetPlayer()->GetObjectByTypeMask(guid, TYPEMASK_CREATURE_OR_GAMEOBJECT); obj = (WorldObject*)m_session->GetPlayer()->GetObjectByTypeMask(guid, TYPEMASK_CREATURE_OR_GAMEOBJECT);
if(!obj) if (!obj)
{ {
SendSysMessage(LANG_PLAYER_NOT_FOUND); SendSysMessage(LANG_PLAYER_NOT_FOUND);
SetSentErrorMessage(true); SetSentErrorMessage(true);
@ -274,7 +274,7 @@ bool ChatHandler::HandleGPSCommand(char* args)
{ {
obj = getSelectedUnit(); obj = getSelectedUnit();
if(!obj) if (!obj)
{ {
SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
SetSentErrorMessage(true); SetSentErrorMessage(true);
@ -300,7 +300,7 @@ bool ChatHandler::HandleGPSCommand(char* args)
zone_y = 0; zone_y = 0;
} }
TerrainInfo const *map = obj->GetTerrain(); TerrainInfo const* map = obj->GetTerrain();
float ground_z = map->GetHeight(obj->GetPositionX(), obj->GetPositionY(), MAX_HEIGHT); float ground_z = map->GetHeight(obj->GetPositionX(), obj->GetPositionY(), MAX_HEIGHT);
float floor_z = map->GetHeight(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ()); float floor_z = map->GetHeight(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ());
@ -314,7 +314,7 @@ bool ChatHandler::HandleGPSCommand(char* args)
if (have_vmap) if (have_vmap)
{ {
if(map->IsOutdoors(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ())) if (map->IsOutdoors(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ()))
PSendSysMessage("You are OUTdoor"); PSendSysMessage("You are OUTdoor");
else else
PSendSysMessage("You are INdoor"); PSendSysMessage("You are INdoor");
@ -322,27 +322,27 @@ bool ChatHandler::HandleGPSCommand(char* args)
else PSendSysMessage("no VMAP available for area info"); else PSendSysMessage("no VMAP available for area info");
PSendSysMessage(LANG_MAP_POSITION, PSendSysMessage(LANG_MAP_POSITION,
obj->GetMapId(), (mapEntry ? mapEntry->name[GetSessionDbcLocale()] : "<unknown>" ), obj->GetMapId(), (mapEntry ? mapEntry->name[GetSessionDbcLocale()] : "<unknown>"),
zone_id, (zoneEntry ? zoneEntry->area_name[GetSessionDbcLocale()] : "<unknown>" ), zone_id, (zoneEntry ? zoneEntry->area_name[GetSessionDbcLocale()] : "<unknown>"),
area_id, (areaEntry ? areaEntry->area_name[GetSessionDbcLocale()] : "<unknown>" ), area_id, (areaEntry ? areaEntry->area_name[GetSessionDbcLocale()] : "<unknown>"),
obj->GetPhaseMask(), obj->GetPhaseMask(),
obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj->GetOrientation(), obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj->GetOrientation(),
cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), obj->GetInstanceId(), cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), obj->GetInstanceId(),
zone_x, zone_y, ground_z, floor_z, have_map, have_vmap ); zone_x, zone_y, ground_z, floor_z, have_map, have_vmap);
DEBUG_LOG("Player %s GPS call for %s '%s' (%s: %u):", DEBUG_LOG("Player %s GPS call for %s '%s' (%s: %u):",
m_session ? GetNameLink().c_str() : GetMangosString(LANG_CONSOLE_COMMAND), m_session ? GetNameLink().c_str() : GetMangosString(LANG_CONSOLE_COMMAND),
(obj->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), obj->GetName(), (obj->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), obj->GetName(),
(obj->GetTypeId() == TYPEID_PLAYER ? "GUID" : "Entry"), (obj->GetTypeId() == TYPEID_PLAYER ? obj->GetGUIDLow(): obj->GetEntry()) ); (obj->GetTypeId() == TYPEID_PLAYER ? "GUID" : "Entry"), (obj->GetTypeId() == TYPEID_PLAYER ? obj->GetGUIDLow(): obj->GetEntry()));
DEBUG_LOG(GetMangosString(LANG_MAP_POSITION), DEBUG_LOG(GetMangosString(LANG_MAP_POSITION),
obj->GetMapId(), (mapEntry ? mapEntry->name[sWorld.GetDefaultDbcLocale()] : "<unknown>" ), obj->GetMapId(), (mapEntry ? mapEntry->name[sWorld.GetDefaultDbcLocale()] : "<unknown>"),
zone_id, (zoneEntry ? zoneEntry->area_name[sWorld.GetDefaultDbcLocale()] : "<unknown>" ), zone_id, (zoneEntry ? zoneEntry->area_name[sWorld.GetDefaultDbcLocale()] : "<unknown>"),
area_id, (areaEntry ? areaEntry->area_name[sWorld.GetDefaultDbcLocale()] : "<unknown>" ), area_id, (areaEntry ? areaEntry->area_name[sWorld.GetDefaultDbcLocale()] : "<unknown>"),
obj->GetPhaseMask(), obj->GetPhaseMask(),
obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj->GetOrientation(), obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj->GetOrientation(),
cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), obj->GetInstanceId(), cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), obj->GetInstanceId(),
zone_x, zone_y, ground_z, floor_z, have_map, have_vmap ); zone_x, zone_y, ground_z, floor_z, have_map, have_vmap);
GridMapLiquidData liquid_status; GridMapLiquidData liquid_status;
GridMapLiquidStatus res = map->getLiquidStatus(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), MAP_ALL_LIQUIDS, &liquid_status); GridMapLiquidStatus res = map->getLiquidStatus(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), MAP_ALL_LIQUIDS, &liquid_status);
@ -422,8 +422,8 @@ bool ChatHandler::HandleNamegoCommand(char* args)
// we are in instance, and can summon only player in our group with us as lead // we are in instance, and can summon only player in our group with us as lead
if (!m_session->GetPlayer()->GetGroup() || !target->GetGroup() || if (!m_session->GetPlayer()->GetGroup() || !target->GetGroup() ||
(target->GetGroup()->GetLeaderGuid() != m_session->GetPlayer()->GetObjectGuid()) || (target->GetGroup()->GetLeaderGuid() != m_session->GetPlayer()->GetObjectGuid()) ||
(m_session->GetPlayer()->GetGroup()->GetLeaderGuid() != m_session->GetPlayer()->GetObjectGuid())) (m_session->GetPlayer()->GetGroup()->GetLeaderGuid() != m_session->GetPlayer()->GetObjectGuid()))
// the last check is a bit excessive, but let it be, just in case // the last check is a bit excessive, but let it be, just in case
{ {
PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,nameLink.c_str()); PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,nameLink.c_str());
@ -463,11 +463,11 @@ bool ChatHandler::HandleNamegoCommand(char* args)
// in point where GM stay // in point where GM stay
Player::SavePositionInDB(target_guid, m_session->GetPlayer()->GetMapId(), Player::SavePositionInDB(target_guid, m_session->GetPlayer()->GetMapId(),
m_session->GetPlayer()->GetPositionX(), m_session->GetPlayer()->GetPositionX(),
m_session->GetPlayer()->GetPositionY(), m_session->GetPlayer()->GetPositionY(),
m_session->GetPlayer()->GetPositionZ(), m_session->GetPlayer()->GetPositionZ(),
m_session->GetPlayer()->GetOrientation(), m_session->GetPlayer()->GetOrientation(),
m_session->GetPlayer()->GetZoneId()); m_session->GetPlayer()->GetZoneId());
} }
return true; return true;
@ -523,7 +523,7 @@ bool ChatHandler::HandleGonameCommand(char* args)
if (!_player->GetMap()->IsBattleGroundOrArena()) if (!_player->GetMap()->IsBattleGroundOrArena())
_player->SetBattleGroundEntryPoint(); _player->SetBattleGroundEntryPoint();
} }
else if(cMap->IsDungeon()) else if (cMap->IsDungeon())
{ {
// we have to go to instance, and can go to player only if: // we have to go to instance, and can go to player only if:
// 1) we are in his group (either as leader or as member) // 1) we are in his group (either as leader or as member)
@ -551,16 +551,16 @@ bool ChatHandler::HandleGonameCommand(char* args)
// if the player or the player's group is bound to another instance // if the player or the player's group is bound to another instance
// the player will not be bound to another one // the player will not be bound to another one
InstancePlayerBind *pBind = _player->GetBoundInstance(target->GetMapId(), target->GetDifficulty(cMap->IsRaid())); InstancePlayerBind* pBind = _player->GetBoundInstance(target->GetMapId(), target->GetDifficulty(cMap->IsRaid()));
if (!pBind) if (!pBind)
{ {
Group *group = _player->GetGroup(); Group* group = _player->GetGroup();
// if no bind exists, create a solo bind // if no bind exists, create a solo bind
InstanceGroupBind *gBind = group ? group->GetBoundInstance(target->GetMapId(), target) : NULL; InstanceGroupBind* gBind = group ? group->GetBoundInstance(target->GetMapId(), target) : NULL;
// if no bind exists, create a solo bind // if no bind exists, create a solo bind
if (!gBind) if (!gBind)
{ {
DungeonPersistentState *save = ((DungeonMap*)target->GetMap())->GetPersistanceState(); DungeonPersistentState* save = ((DungeonMap*)target->GetMap())->GetPersistanceState();
// if player is group leader then we need add group bind // if player is group leader then we need add group bind
if (group && group->IsLeader(_player->GetObjectGuid())) if (group && group->IsLeader(_player->GetObjectGuid()))
@ -570,7 +570,7 @@ bool ChatHandler::HandleGonameCommand(char* args)
} }
} }
if(cMap->IsRaid()) if (cMap->IsRaid())
_player->SetRaidDifficulty(target->GetRaidDifficulty()); _player->SetRaidDifficulty(target->GetRaidDifficulty());
else else
_player->SetDungeonDifficulty(target->GetDungeonDifficulty()); _player->SetDungeonDifficulty(target->GetDungeonDifficulty());
@ -643,7 +643,7 @@ bool ChatHandler::HandleRecallCommand(char* args)
//Edit Player HP //Edit Player HP
bool ChatHandler::HandleModifyHPCommand(char* args) bool ChatHandler::HandleModifyHPCommand(char* args)
{ {
if(!*args) if (!*args)
return false; return false;
int32 hp = atoi(args); int32 hp = atoi(args);
@ -656,7 +656,7 @@ bool ChatHandler::HandleModifyHPCommand(char* args)
return false; return false;
} }
Player *chr = getSelectedPlayer(); Player* chr = getSelectedPlayer();
if (chr == NULL) if (chr == NULL)
{ {
SendSysMessage(LANG_NO_CHAR_SELECTED); SendSysMessage(LANG_NO_CHAR_SELECTED);
@ -672,8 +672,8 @@ bool ChatHandler::HandleModifyHPCommand(char* args)
if (needReportToTarget(chr)) if (needReportToTarget(chr))
ChatHandler(chr).PSendSysMessage(LANG_YOURS_HP_CHANGED, GetNameLink().c_str(), hp, hpm); ChatHandler(chr).PSendSysMessage(LANG_YOURS_HP_CHANGED, GetNameLink().c_str(), hp, hpm);
chr->SetMaxHealth( hpm ); chr->SetMaxHealth(hpm);
chr->SetHealth( hp ); chr->SetHealth(hp);
return true; return true;
} }
@ -681,7 +681,7 @@ bool ChatHandler::HandleModifyHPCommand(char* args)
//Edit Player Mana //Edit Player Mana
bool ChatHandler::HandleModifyManaCommand(char* args) bool ChatHandler::HandleModifyManaCommand(char* args)
{ {
if(!*args) if (!*args)
return false; return false;
int32 mana = atoi(args); int32 mana = atoi(args);
@ -694,7 +694,7 @@ bool ChatHandler::HandleModifyManaCommand(char* args)
return false; return false;
} }
Player *chr = getSelectedPlayer(); Player* chr = getSelectedPlayer();
if (chr == NULL) if (chr == NULL)
{ {
SendSysMessage(LANG_NO_CHAR_SELECTED); SendSysMessage(LANG_NO_CHAR_SELECTED);
@ -710,8 +710,8 @@ bool ChatHandler::HandleModifyManaCommand(char* args)
if (needReportToTarget(chr)) if (needReportToTarget(chr))
ChatHandler(chr).PSendSysMessage(LANG_YOURS_MANA_CHANGED, GetNameLink().c_str(), mana, manam); ChatHandler(chr).PSendSysMessage(LANG_YOURS_MANA_CHANGED, GetNameLink().c_str(), mana, manam);
chr->SetMaxPower(POWER_MANA,manam ); chr->SetMaxPower(POWER_MANA,manam);
chr->SetPower(POWER_MANA, mana ); chr->SetPower(POWER_MANA, mana);
return true; return true;
} }
@ -719,7 +719,7 @@ bool ChatHandler::HandleModifyManaCommand(char* args)
//Edit Player Energy //Edit Player Energy
bool ChatHandler::HandleModifyEnergyCommand(char* args) bool ChatHandler::HandleModifyEnergyCommand(char* args)
{ {
if(!*args) if (!*args)
return false; return false;
int32 energy = atoi(args)*10; int32 energy = atoi(args)*10;
@ -732,7 +732,7 @@ bool ChatHandler::HandleModifyEnergyCommand(char* args)
return false; return false;
} }
Player *chr = getSelectedPlayer(); Player* chr = getSelectedPlayer();
if (!chr) if (!chr)
{ {
SendSysMessage(LANG_NO_CHAR_SELECTED); SendSysMessage(LANG_NO_CHAR_SELECTED);
@ -748,8 +748,8 @@ bool ChatHandler::HandleModifyEnergyCommand(char* args)
if (needReportToTarget(chr)) if (needReportToTarget(chr))
ChatHandler(chr).PSendSysMessage(LANG_YOURS_ENERGY_CHANGED, GetNameLink().c_str(), energy/10, energym/10); ChatHandler(chr).PSendSysMessage(LANG_YOURS_ENERGY_CHANGED, GetNameLink().c_str(), energy/10, energym/10);
chr->SetMaxPower(POWER_ENERGY,energym ); chr->SetMaxPower(POWER_ENERGY,energym);
chr->SetPower(POWER_ENERGY, energy ); chr->SetPower(POWER_ENERGY, energy);
DETAIL_LOG(GetMangosString(LANG_CURRENT_ENERGY),chr->GetMaxPower(POWER_ENERGY)); DETAIL_LOG(GetMangosString(LANG_CURRENT_ENERGY),chr->GetMaxPower(POWER_ENERGY));
@ -759,7 +759,7 @@ bool ChatHandler::HandleModifyEnergyCommand(char* args)
//Edit Player Rage //Edit Player Rage
bool ChatHandler::HandleModifyRageCommand(char* args) bool ChatHandler::HandleModifyRageCommand(char* args)
{ {
if(!*args) if (!*args)
return false; return false;
int32 rage = atoi(args)*10; int32 rage = atoi(args)*10;
@ -772,7 +772,7 @@ bool ChatHandler::HandleModifyRageCommand(char* args)
return false; return false;
} }
Player *chr = getSelectedPlayer(); Player* chr = getSelectedPlayer();
if (chr == NULL) if (chr == NULL)
{ {
SendSysMessage(LANG_NO_CHAR_SELECTED); SendSysMessage(LANG_NO_CHAR_SELECTED);
@ -788,8 +788,8 @@ bool ChatHandler::HandleModifyRageCommand(char* args)
if (needReportToTarget(chr)) if (needReportToTarget(chr))
ChatHandler(chr).PSendSysMessage(LANG_YOURS_RAGE_CHANGED, GetNameLink().c_str(), rage/10, ragem/10); ChatHandler(chr).PSendSysMessage(LANG_YOURS_RAGE_CHANGED, GetNameLink().c_str(), rage/10, ragem/10);
chr->SetMaxPower(POWER_RAGE,ragem ); chr->SetMaxPower(POWER_RAGE,ragem);
chr->SetPower(POWER_RAGE, rage ); chr->SetPower(POWER_RAGE, rage);
return true; return true;
} }
@ -797,7 +797,7 @@ bool ChatHandler::HandleModifyRageCommand(char* args)
// Edit Player Runic Power // Edit Player Runic Power
bool ChatHandler::HandleModifyRunicPowerCommand(char* args) bool ChatHandler::HandleModifyRunicPowerCommand(char* args)
{ {
if(!*args) if (!*args)
return false; return false;
int32 rune = atoi(args)*10; int32 rune = atoi(args)*10;
@ -810,7 +810,7 @@ bool ChatHandler::HandleModifyRunicPowerCommand(char* args)
return false; return false;
} }
Player *chr = getSelectedPlayer(); Player* chr = getSelectedPlayer();
if (chr == NULL) if (chr == NULL)
{ {
SendSysMessage(LANG_NO_CHAR_SELECTED); SendSysMessage(LANG_NO_CHAR_SELECTED);
@ -822,8 +822,8 @@ bool ChatHandler::HandleModifyRunicPowerCommand(char* args)
if (needReportToTarget(chr)) if (needReportToTarget(chr))
ChatHandler(chr).PSendSysMessage(LANG_YOURS_RUNIC_POWER_CHANGED, GetNameLink().c_str(), rune/10, runem/10); ChatHandler(chr).PSendSysMessage(LANG_YOURS_RUNIC_POWER_CHANGED, GetNameLink().c_str(), rune/10, runem/10);
chr->SetMaxPower(POWER_RUNIC_POWER,runem ); chr->SetMaxPower(POWER_RUNIC_POWER,runem);
chr->SetPower(POWER_RUNIC_POWER, rune ); chr->SetPower(POWER_RUNIC_POWER, rune);
return true; return true;
} }
@ -832,7 +832,7 @@ bool ChatHandler::HandleModifyRunicPowerCommand(char* args)
bool ChatHandler::HandleModifyFactionCommand(char* args) bool ChatHandler::HandleModifyFactionCommand(char* args)
{ {
Creature* chr = getSelectedCreature(); Creature* chr = getSelectedCreature();
if(!chr) if (!chr)
{ {
SendSysMessage(LANG_SELECT_CREATURE); SendSysMessage(LANG_SELECT_CREATURE);
SetSentErrorMessage(true); SetSentErrorMessage(true);
@ -841,7 +841,7 @@ bool ChatHandler::HandleModifyFactionCommand(char* args)
if (!*args) if (!*args)
{ {
if(chr) if (chr)
{ {
uint32 factionid = chr->getFaction(); uint32 factionid = chr->getFaction();
uint32 flag = chr->GetUInt32Value(UNIT_FIELD_FLAGS); uint32 flag = chr->GetUInt32Value(UNIT_FIELD_FLAGS);
@ -852,7 +852,7 @@ bool ChatHandler::HandleModifyFactionCommand(char* args)
return true; return true;
} }
if( !chr ) if (!chr)
{ {
SendSysMessage(LANG_NO_CHAR_SELECTED); SendSysMessage(LANG_NO_CHAR_SELECTED);
SetSentErrorMessage(true); SetSentErrorMessage(true);
@ -863,7 +863,7 @@ bool ChatHandler::HandleModifyFactionCommand(char* args)
if (!ExtractUint32KeyFromLink(&args, "Hfaction", factionid)) if (!ExtractUint32KeyFromLink(&args, "Hfaction", factionid))
return false; return false;
if(!sFactionTemplateStore.LookupEntry(factionid)) if (!sFactionTemplateStore.LookupEntry(factionid))
{ {
PSendSysMessage(LANG_WRONG_FACTION, factionid); PSendSysMessage(LANG_WRONG_FACTION, factionid);
SetSentErrorMessage(true); SetSentErrorMessage(true);
@ -893,7 +893,7 @@ bool ChatHandler::HandleModifyFactionCommand(char* args)
} }
//Edit Player TP //Edit Player TP
bool ChatHandler::HandleModifyTalentCommand (char* args) bool ChatHandler::HandleModifyTalentCommand(char* args)
{ {
if (!*args) if (!*args)
return false; return false;
@ -903,14 +903,14 @@ bool ChatHandler::HandleModifyTalentCommand (char* args)
return false; return false;
Unit* target = getSelectedUnit(); Unit* target = getSelectedUnit();
if(!target) if (!target)
{ {
SendSysMessage(LANG_NO_CHAR_SELECTED); SendSysMessage(LANG_NO_CHAR_SELECTED);
SetSentErrorMessage(true); SetSentErrorMessage(true);
return false; return false;
} }
if(target->GetTypeId()==TYPEID_PLAYER) if (target->GetTypeId()==TYPEID_PLAYER)
{ {
// check online security // check online security
if (HasLowerSecurity((Player*)target)) if (HasLowerSecurity((Player*)target))
@ -920,16 +920,16 @@ bool ChatHandler::HandleModifyTalentCommand (char* args)
((Player*)target)->SendTalentsInfoData(false); ((Player*)target)->SendTalentsInfoData(false);
return true; return true;
} }
else if(((Creature*)target)->IsPet()) else if (((Creature*)target)->IsPet())
{ {
Unit *owner = target->GetOwner(); Unit* owner = target->GetOwner();
if(owner && owner->GetTypeId() == TYPEID_PLAYER && ((Pet *)target)->IsPermanentPetFor((Player*)owner)) if (owner && owner->GetTypeId() == TYPEID_PLAYER && ((Pet*)target)->IsPermanentPetFor((Player*)owner))
{ {
// check online security // check online security
if (HasLowerSecurity((Player*)owner)) if (HasLowerSecurity((Player*)owner))
return false; return false;
((Pet *)target)->SetFreeTalentPoints(tp); ((Pet*)target)->SetFreeTalentPoints(tp);
((Player*)owner)->SendTalentsInfoData(true); ((Player*)owner)->SendTalentsInfoData(true);
return true; return true;
} }
@ -951,7 +951,7 @@ bool ChatHandler::HandleTaxiCheatCommand(char* args)
return false; return false;
} }
Player *chr = getSelectedPlayer(); Player* chr = getSelectedPlayer();
if (!chr) if (!chr)
chr=m_session->GetPlayer(); chr=m_session->GetPlayer();
// check online security // check online security
@ -991,7 +991,7 @@ bool ChatHandler::HandleModifyASpeedCommand(char* args)
return false; return false;
} }
Player *chr = getSelectedPlayer(); Player* chr = getSelectedPlayer();
if (chr == NULL) if (chr == NULL)
{ {
SendSysMessage(LANG_NO_CHAR_SELECTED); SendSysMessage(LANG_NO_CHAR_SELECTED);
@ -1005,7 +1005,7 @@ bool ChatHandler::HandleModifyASpeedCommand(char* args)
std::string chrNameLink = GetNameLink(chr); std::string chrNameLink = GetNameLink(chr);
if(chr->IsTaxiFlying()) if (chr->IsTaxiFlying())
{ {
PSendSysMessage(LANG_CHAR_IN_FLIGHT,chrNameLink.c_str()); PSendSysMessage(LANG_CHAR_IN_FLIGHT,chrNameLink.c_str());
SetSentErrorMessage(true); SetSentErrorMessage(true);
@ -1039,7 +1039,7 @@ bool ChatHandler::HandleModifySpeedCommand(char* args)
return false; return false;
} }
Player *chr = getSelectedPlayer(); Player* chr = getSelectedPlayer();
if (chr == NULL) if (chr == NULL)
{ {
SendSysMessage(LANG_NO_CHAR_SELECTED); SendSysMessage(LANG_NO_CHAR_SELECTED);
@ -1053,7 +1053,7 @@ bool ChatHandler::HandleModifySpeedCommand(char* args)
std::string chrNameLink = GetNameLink(chr); std::string chrNameLink = GetNameLink(chr);
if(chr->IsTaxiFlying()) if (chr->IsTaxiFlying())
{ {
PSendSysMessage(LANG_CHAR_IN_FLIGHT,chrNameLink.c_str()); PSendSysMessage(LANG_CHAR_IN_FLIGHT,chrNameLink.c_str());
SetSentErrorMessage(true); SetSentErrorMessage(true);
@ -1084,7 +1084,7 @@ bool ChatHandler::HandleModifySwimCommand(char* args)
return false; return false;
} }
Player *chr = getSelectedPlayer(); Player* chr = getSelectedPlayer();
if (chr == NULL) if (chr == NULL)
{ {
SendSysMessage(LANG_NO_CHAR_SELECTED); SendSysMessage(LANG_NO_CHAR_SELECTED);
@ -1098,7 +1098,7 @@ bool ChatHandler::HandleModifySwimCommand(char* args)
std::string chrNameLink = GetNameLink(chr); std::string chrNameLink = GetNameLink(chr);
if(chr->IsTaxiFlying()) if (chr->IsTaxiFlying())
{ {
PSendSysMessage(LANG_CHAR_IN_FLIGHT,chrNameLink.c_str()); PSendSysMessage(LANG_CHAR_IN_FLIGHT,chrNameLink.c_str());
SetSentErrorMessage(true); SetSentErrorMessage(true);
@ -1129,7 +1129,7 @@ bool ChatHandler::HandleModifyBWalkCommand(char* args)
return false; return false;
} }
Player *chr = getSelectedPlayer(); Player* chr = getSelectedPlayer();
if (chr == NULL) if (chr == NULL)
{ {
SendSysMessage(LANG_NO_CHAR_SELECTED); SendSysMessage(LANG_NO_CHAR_SELECTED);
@ -1143,7 +1143,7 @@ bool ChatHandler::HandleModifyBWalkCommand(char* args)
std::string chrNameLink = GetNameLink(chr); std::string chrNameLink = GetNameLink(chr);
if(chr->IsTaxiFlying()) if (chr->IsTaxiFlying())
{ {
PSendSysMessage(LANG_CHAR_IN_FLIGHT,chrNameLink.c_str()); PSendSysMessage(LANG_CHAR_IN_FLIGHT,chrNameLink.c_str());
SetSentErrorMessage(true); SetSentErrorMessage(true);
@ -1174,7 +1174,7 @@ bool ChatHandler::HandleModifyFlyCommand(char* args)
return false; return false;
} }
Player *chr = getSelectedPlayer(); Player* chr = getSelectedPlayer();
if (chr == NULL) if (chr == NULL)
{ {
SendSysMessage(LANG_NO_CHAR_SELECTED); SendSysMessage(LANG_NO_CHAR_SELECTED);
@ -1209,7 +1209,7 @@ bool ChatHandler::HandleModifyScaleCommand(char* args)
return false; return false;
} }
Unit *target = getSelectedUnit(); Unit* target = getSelectedUnit();
if (target == NULL) if (target == NULL)
{ {
SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
@ -1237,13 +1237,13 @@ bool ChatHandler::HandleModifyScaleCommand(char* args)
//Enable Player mount //Enable Player mount
bool ChatHandler::HandleModifyMountCommand(char* args) bool ChatHandler::HandleModifyMountCommand(char* args)
{ {
if(!*args) if (!*args)
return false; return false;
uint16 mId = 1147; uint16 mId = 1147;
float speed = (float)15; float speed = (float)15;
uint32 num = atoi(args); uint32 num = atoi(args);
switch(num) switch (num)
{ {
case 1: case 1:
mId=14340; mId=14340;
@ -1458,7 +1458,7 @@ bool ChatHandler::HandleModifyMountCommand(char* args)
return false; return false;
} }
Player *chr = getSelectedPlayer(); Player* chr = getSelectedPlayer();
if (!chr) if (!chr)
{ {
SendSysMessage(LANG_NO_CHAR_SELECTED); SendSysMessage(LANG_NO_CHAR_SELECTED);
@ -1477,18 +1477,18 @@ bool ChatHandler::HandleModifyMountCommand(char* args)
chr->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP); chr->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP);
chr->Mount(mId); chr->Mount(mId);
WorldPacket data( SMSG_FORCE_RUN_SPEED_CHANGE, (8+4+1+4) ); WorldPacket data(SMSG_FORCE_RUN_SPEED_CHANGE, (8+4+1+4));
data << chr->GetPackGUID(); data << chr->GetPackGUID();
data << (uint32)0; data << (uint32)0;
data << (uint8)0; //new 2.1.0 data << (uint8)0; //new 2.1.0
data << float(speed); data << float(speed);
chr->SendMessageToSet( &data, true ); chr->SendMessageToSet(&data, true);
data.Initialize( SMSG_FORCE_SWIM_SPEED_CHANGE, (8+4+4) ); data.Initialize(SMSG_FORCE_SWIM_SPEED_CHANGE, (8+4+4));
data << chr->GetPackGUID(); data << chr->GetPackGUID();
data << (uint32)0; data << (uint32)0;
data << float(speed); data << float(speed);
chr->SendMessageToSet( &data, true ); chr->SendMessageToSet(&data, true);
return true; return true;
} }
@ -1499,7 +1499,7 @@ bool ChatHandler::HandleModifyMoneyCommand(char* args)
if (!*args) if (!*args)
return false; return false;
Player *chr = getSelectedPlayer(); Player* chr = getSelectedPlayer();
if (chr == NULL) if (chr == NULL)
{ {
SendSysMessage(LANG_NO_CHAR_SELECTED); SendSysMessage(LANG_NO_CHAR_SELECTED);
@ -1520,7 +1520,7 @@ bool ChatHandler::HandleModifyMoneyCommand(char* args)
int32 newmoney = int32(moneyuser) + addmoney; int32 newmoney = int32(moneyuser) + addmoney;
DETAIL_LOG(GetMangosString(LANG_CURRENT_MONEY), moneyuser, addmoney, newmoney); DETAIL_LOG(GetMangosString(LANG_CURRENT_MONEY), moneyuser, addmoney, newmoney);
if (newmoney <= 0 ) if (newmoney <= 0)
{ {
PSendSysMessage(LANG_YOU_TAKE_ALL_MONEY, GetNameLink(chr).c_str()); PSendSysMessage(LANG_YOU_TAKE_ALL_MONEY, GetNameLink(chr).c_str());
if (needReportToTarget(chr)) if (needReportToTarget(chr))
@ -1536,7 +1536,7 @@ bool ChatHandler::HandleModifyMoneyCommand(char* args)
PSendSysMessage(LANG_YOU_TAKE_MONEY, abs(addmoney), GetNameLink(chr).c_str()); PSendSysMessage(LANG_YOU_TAKE_MONEY, abs(addmoney), GetNameLink(chr).c_str());
if (needReportToTarget(chr)) if (needReportToTarget(chr))
ChatHandler(chr).PSendSysMessage(LANG_YOURS_MONEY_TAKEN, GetNameLink().c_str(), abs(addmoney)); ChatHandler(chr).PSendSysMessage(LANG_YOURS_MONEY_TAKEN, GetNameLink().c_str(), abs(addmoney));
chr->SetMoney( newmoney ); chr->SetMoney(newmoney);
} }
} }
else else
@ -1548,21 +1548,21 @@ bool ChatHandler::HandleModifyMoneyCommand(char* args)
if (addmoney >=MAX_MONEY_AMOUNT) if (addmoney >=MAX_MONEY_AMOUNT)
chr->SetMoney(MAX_MONEY_AMOUNT); chr->SetMoney(MAX_MONEY_AMOUNT);
else else
chr->ModifyMoney( addmoney ); chr->ModifyMoney(addmoney);
} }
DETAIL_LOG(GetMangosString(LANG_NEW_MONEY), moneyuser, addmoney, chr->GetMoney() ); DETAIL_LOG(GetMangosString(LANG_NEW_MONEY), moneyuser, addmoney, chr->GetMoney());
return true; return true;
} }
bool ChatHandler::HandleModifyHonorCommand (char* args) bool ChatHandler::HandleModifyHonorCommand(char* args)
{ {
if (!*args) if (!*args)
return false; return false;
Player *target = getSelectedPlayer(); Player* target = getSelectedPlayer();
if(!target) if (!target)
{ {
SendSysMessage(LANG_PLAYER_NOT_FOUND); SendSysMessage(LANG_PLAYER_NOT_FOUND);
SetSentErrorMessage(true); SetSentErrorMessage(true);
@ -1584,7 +1584,7 @@ bool ChatHandler::HandleModifyHonorCommand (char* args)
bool ChatHandler::HandleTeleCommand(char* args) bool ChatHandler::HandleTeleCommand(char* args)
{ {
if(!*args) if (!*args)
return false; return false;
Player* _player = m_session->GetPlayer(); Player* _player = m_session->GetPlayer();
@ -1610,38 +1610,38 @@ bool ChatHandler::HandleLookupAreaCommand(char* args)
std::string namepart = args; std::string namepart = args;
std::wstring wnamepart; std::wstring wnamepart;
if (!Utf8toWStr (namepart,wnamepart)) if (!Utf8toWStr(namepart,wnamepart))
return false; return false;
uint32 counter = 0; // Counter for figure out that we found smth. uint32 counter = 0; // Counter for figure out that we found smth.
// converting string that we try to find to lower case // converting string that we try to find to lower case
wstrToLower (wnamepart); wstrToLower(wnamepart);
// Search in AreaTable.dbc // Search in AreaTable.dbc
for (uint32 areaflag = 0; areaflag < sAreaStore.GetNumRows (); ++areaflag) for (uint32 areaflag = 0; areaflag < sAreaStore.GetNumRows(); ++areaflag)
{ {
AreaTableEntry const *areaEntry = sAreaStore.LookupEntry (areaflag); AreaTableEntry const* areaEntry = sAreaStore.LookupEntry(areaflag);
if (areaEntry) if (areaEntry)
{ {
int loc = GetSessionDbcLocale (); int loc = GetSessionDbcLocale();
std::string name = areaEntry->area_name[loc]; std::string name = areaEntry->area_name[loc];
if (name.empty()) if (name.empty())
continue; continue;
if (!Utf8FitTo (name, wnamepart)) if (!Utf8FitTo(name, wnamepart))
{ {
loc = 0; loc = 0;
for(; loc < MAX_LOCALE; ++loc) for (; loc < MAX_LOCALE; ++loc)
{ {
if (loc==GetSessionDbcLocale ()) if (loc==GetSessionDbcLocale())
continue; continue;
name = areaEntry->area_name[loc]; name = areaEntry->area_name[loc];
if (name.empty ()) if (name.empty())
continue; continue;
if (Utf8FitTo (name, wnamepart)) if (Utf8FitTo(name, wnamepart))
break; break;
} }
} }
@ -1655,7 +1655,7 @@ bool ChatHandler::HandleLookupAreaCommand(char* args)
else else
ss << areaEntry->ID << " - " << name << " " << localeNames[loc]; ss << areaEntry->ID << " - " << name << " " << localeNames[loc];
SendSysMessage (ss.str ().c_str()); SendSysMessage(ss.str().c_str());
++counter; ++counter;
} }
@ -1663,15 +1663,15 @@ bool ChatHandler::HandleLookupAreaCommand(char* args)
} }
if (counter == 0) // if counter == 0 then we found nth if (counter == 0) // if counter == 0 then we found nth
SendSysMessage (LANG_COMMAND_NOAREAFOUND); SendSysMessage(LANG_COMMAND_NOAREAFOUND);
return true; return true;
} }
//Find tele in game_tele order by name //Find tele in game_tele order by name
bool ChatHandler::HandleLookupTeleCommand(char * args) bool ChatHandler::HandleLookupTeleCommand(char* args)
{ {
if(!*args) if (!*args)
{ {
SendSysMessage(LANG_COMMAND_TELE_PARAMETER); SendSysMessage(LANG_COMMAND_TELE_PARAMETER);
SetSentErrorMessage(true); SetSentErrorMessage(true);
@ -1681,20 +1681,20 @@ bool ChatHandler::HandleLookupTeleCommand(char * args)
std::string namepart = args; std::string namepart = args;
std::wstring wnamepart; std::wstring wnamepart;
if(!Utf8toWStr(namepart,wnamepart)) if (!Utf8toWStr(namepart,wnamepart))
return false; return false;
// converting string that we try to find to lower case // converting string that we try to find to lower case
wstrToLower( wnamepart ); wstrToLower(wnamepart);
std::ostringstream reply; std::ostringstream reply;
GameTeleMap const & teleMap = sObjectMgr.GetGameTeleMap(); GameTeleMap const& teleMap = sObjectMgr.GetGameTeleMap();
for(GameTeleMap::const_iterator itr = teleMap.begin(); itr != teleMap.end(); ++itr) for (GameTeleMap::const_iterator itr = teleMap.begin(); itr != teleMap.end(); ++itr)
{ {
GameTele const* tele = &itr->second; GameTele const* tele = &itr->second;
if(tele->wnameLow.find(wnamepart) == std::wstring::npos) if (tele->wnameLow.find(wnamepart) == std::wstring::npos)
continue; continue;
if (m_session) if (m_session)
@ -1703,7 +1703,7 @@ bool ChatHandler::HandleLookupTeleCommand(char * args)
reply << " " << itr->first << " " << tele->name << "\n"; reply << " " << itr->first << " " << tele->name << "\n";
} }
if(reply.str().empty()) if (reply.str().empty())
SendSysMessage(LANG_COMMAND_TELE_NOLOCATION); SendSysMessage(LANG_COMMAND_TELE_NOLOCATION);
else else
PSendSysMessage(LANG_COMMAND_TELE_LOCATION,reply.str().c_str()); PSendSysMessage(LANG_COMMAND_TELE_LOCATION,reply.str().c_str());
@ -1714,7 +1714,7 @@ bool ChatHandler::HandleLookupTeleCommand(char * args)
//Enable\Dissable accept whispers (for GM) //Enable\Dissable accept whispers (for GM)
bool ChatHandler::HandleWhispersCommand(char* args) bool ChatHandler::HandleWhispersCommand(char* args)
{ {
if(!*args) if (!*args)
{ {
PSendSysMessage(LANG_COMMAND_WHISPERACCEPTING, GetOnOffStr(m_session->GetPlayer()->isAcceptWhispers())); PSendSysMessage(LANG_COMMAND_WHISPERACCEPTING, GetOnOffStr(m_session->GetPlayer()->isAcceptWhispers()));
return true; return true;
@ -1806,7 +1806,7 @@ bool ChatHandler::HandleTeleNameCommand(char* args)
std::string chrNameLink = playerLink(target_name); std::string chrNameLink = playerLink(target_name);
if(target->IsBeingTeleported()==true) if (target->IsBeingTeleported()==true)
{ {
PSendSysMessage(LANG_IS_TELEPORTED, chrNameLink.c_str()); PSendSysMessage(LANG_IS_TELEPORTED, chrNameLink.c_str());
SetSentErrorMessage(true); SetSentErrorMessage(true);
@ -1829,20 +1829,20 @@ bool ChatHandler::HandleTeleNameCommand(char* args)
PSendSysMessage(LANG_TELEPORTING_TO, nameLink.c_str(), GetMangosString(LANG_OFFLINE), tele->name.c_str()); PSendSysMessage(LANG_TELEPORTING_TO, nameLink.c_str(), GetMangosString(LANG_OFFLINE), tele->name.c_str());
Player::SavePositionInDB(target_guid, tele->mapId, Player::SavePositionInDB(target_guid, tele->mapId,
tele->position_x, tele->position_y, tele->position_z, tele->orientation, tele->position_x, tele->position_y, tele->position_z, tele->orientation,
sTerrainMgr.GetZoneId(tele->mapId,tele->position_x,tele->position_y,tele->position_z)); sTerrainMgr.GetZoneId(tele->mapId,tele->position_x,tele->position_y,tele->position_z));
} }
return true; return true;
} }
//Teleport group to given game_tele.entry //Teleport group to given game_tele.entry
bool ChatHandler::HandleTeleGroupCommand(char * args) bool ChatHandler::HandleTeleGroupCommand(char* args)
{ {
if (!*args) if (!*args)
return false; return false;
Player *player = getSelectedPlayer(); Player* player = getSelectedPlayer();
if (!player) if (!player)
{ {
SendSysMessage(LANG_NO_CHAR_SELECTED); SendSysMessage(LANG_NO_CHAR_SELECTED);
@ -1856,7 +1856,7 @@ bool ChatHandler::HandleTeleGroupCommand(char * args)
// id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
GameTele const* tele = ExtractGameTeleFromLink(&args); GameTele const* tele = ExtractGameTeleFromLink(&args);
if(!tele) if (!tele)
{ {
SendSysMessage(LANG_COMMAND_TELE_NOTFOUND); SendSysMessage(LANG_COMMAND_TELE_NOTFOUND);
SetSentErrorMessage(true); SetSentErrorMessage(true);
@ -1865,19 +1865,19 @@ bool ChatHandler::HandleTeleGroupCommand(char * args)
std::string nameLink = GetNameLink(player); std::string nameLink = GetNameLink(player);
Group *grp = player->GetGroup(); Group* grp = player->GetGroup();
if(!grp) if (!grp)
{ {
PSendSysMessage(LANG_NOT_IN_GROUP,nameLink.c_str()); PSendSysMessage(LANG_NOT_IN_GROUP,nameLink.c_str());
SetSentErrorMessage(true); SetSentErrorMessage(true);
return false; return false;
} }
for(GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
{ {
Player *pl = itr->getSource(); Player* pl = itr->getSource();
if(!pl || !pl->GetSession() ) if (!pl || !pl->GetSession())
continue; continue;
// check online security // check online security
@ -1886,7 +1886,7 @@ bool ChatHandler::HandleTeleGroupCommand(char * args)
std::string plNameLink = GetNameLink(pl); std::string plNameLink = GetNameLink(pl);
if(pl->IsBeingTeleported()) if (pl->IsBeingTeleported())
{ {
PSendSysMessage(LANG_IS_TELEPORTED, plNameLink.c_str()); PSendSysMessage(LANG_IS_TELEPORTED, plNameLink.c_str());
continue; continue;
@ -1897,7 +1897,7 @@ bool ChatHandler::HandleTeleGroupCommand(char * args)
ChatHandler(pl).PSendSysMessage(LANG_TELEPORTED_TO_BY, nameLink.c_str()); ChatHandler(pl).PSendSysMessage(LANG_TELEPORTED_TO_BY, nameLink.c_str());
// stop flight if need // stop flight if need
if(pl->IsTaxiFlying()) if (pl->IsTaxiFlying())
{ {
pl->GetMotionMaster()->MovementExpired(); pl->GetMotionMaster()->MovementExpired();
pl->m_taxi.ClearTaxiDestinations(); pl->m_taxi.ClearTaxiDestinations();
@ -1923,11 +1923,11 @@ bool ChatHandler::HandleGroupgoCommand(char* args)
if (HasLowerSecurity(target)) if (HasLowerSecurity(target))
return false; return false;
Group *grp = target->GetGroup(); Group* grp = target->GetGroup();
std::string nameLink = GetNameLink(target); std::string nameLink = GetNameLink(target);
if(!grp) if (!grp)
{ {
PSendSysMessage(LANG_NOT_IN_GROUP,nameLink.c_str()); PSendSysMessage(LANG_NOT_IN_GROUP,nameLink.c_str());
SetSentErrorMessage(true); SetSentErrorMessage(true);
@ -1938,9 +1938,9 @@ bool ChatHandler::HandleGroupgoCommand(char* args)
bool to_instance = gmMap->Instanceable(); bool to_instance = gmMap->Instanceable();
// we are in instance, and can summon only player in our group with us as lead // we are in instance, and can summon only player in our group with us as lead
if ( to_instance && ( if (to_instance && (
!m_session->GetPlayer()->GetGroup() || (grp->GetLeaderGuid() != m_session->GetPlayer()->GetObjectGuid()) || !m_session->GetPlayer()->GetGroup() || (grp->GetLeaderGuid() != m_session->GetPlayer()->GetObjectGuid()) ||
(m_session->GetPlayer()->GetGroup()->GetLeaderGuid() != m_session->GetPlayer()->GetObjectGuid()) ) ) (m_session->GetPlayer()->GetGroup()->GetLeaderGuid() != m_session->GetPlayer()->GetObjectGuid())))
// the last check is a bit excessive, but let it be, just in case // the last check is a bit excessive, but let it be, just in case
{ {
SendSysMessage(LANG_CANNOT_SUMMON_TO_INST); SendSysMessage(LANG_CANNOT_SUMMON_TO_INST);
@ -1948,11 +1948,11 @@ bool ChatHandler::HandleGroupgoCommand(char* args)
return false; return false;
} }
for(GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
{ {
Player *pl = itr->getSource(); Player* pl = itr->getSource();
if(!pl || pl==m_session->GetPlayer() || !pl->GetSession() ) if (!pl || pl==m_session->GetPlayer() || !pl->GetSession())
continue; continue;
// check online security // check online security
@ -1961,7 +1961,7 @@ bool ChatHandler::HandleGroupgoCommand(char* args)
std::string plNameLink = GetNameLink(pl); std::string plNameLink = GetNameLink(pl);
if(pl->IsBeingTeleported()==true) if (pl->IsBeingTeleported()==true)
{ {
PSendSysMessage(LANG_IS_TELEPORTED, plNameLink.c_str()); PSendSysMessage(LANG_IS_TELEPORTED, plNameLink.c_str());
SetSentErrorMessage(true); SetSentErrorMessage(true);
@ -1972,7 +1972,7 @@ bool ChatHandler::HandleGroupgoCommand(char* args)
{ {
Map* plMap = pl->GetMap(); Map* plMap = pl->GetMap();
if ( plMap->Instanceable() && plMap->GetInstanceId() != gmMap->GetInstanceId() ) if (plMap->Instanceable() && plMap->GetInstanceId() != gmMap->GetInstanceId())
{ {
// cannot summon from instance to instance // cannot summon from instance to instance
PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,plNameLink.c_str()); PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,plNameLink.c_str());
@ -1986,7 +1986,7 @@ bool ChatHandler::HandleGroupgoCommand(char* args)
ChatHandler(pl).PSendSysMessage(LANG_SUMMONED_BY, nameLink.c_str()); ChatHandler(pl).PSendSysMessage(LANG_SUMMONED_BY, nameLink.c_str());
// stop flight if need // stop flight if need
if(pl->IsTaxiFlying()) if (pl->IsTaxiFlying())
{ {
pl->GetMotionMaster()->MovementExpired(); pl->GetMotionMaster()->MovementExpired();
pl->m_taxi.ClearTaxiDestinations(); pl->m_taxi.ClearTaxiDestinations();
@ -2004,7 +2004,7 @@ bool ChatHandler::HandleGroupgoCommand(char* args)
return true; return true;
} }
bool ChatHandler::HandleGoHelper( Player* player, uint32 mapid, float x, float y, float const* zPtr, float const* ortPtr) bool ChatHandler::HandleGoHelper(Player* player, uint32 mapid, float x, float y, float const* zPtr, float const* ortPtr)
{ {
float z; float z;
float ort = player->GetOrientation(); float ort = player->GetOrientation();
@ -2017,7 +2017,7 @@ bool ChatHandler::HandleGoHelper( Player* player, uint32 mapid, float x, float y
ort = *ortPtr; ort = *ortPtr;
// check full provided coordinates // check full provided coordinates
if(!MapManager::IsValidMapCoord(mapid,x,y,z,ort)) if (!MapManager::IsValidMapCoord(mapid,x,y,z,ort))
{ {
PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid);
SetSentErrorMessage(true); SetSentErrorMessage(true);
@ -2027,19 +2027,19 @@ bool ChatHandler::HandleGoHelper( Player* player, uint32 mapid, float x, float y
else else
{ {
// we need check x,y before ask Z or can crash at invalide coordinates // we need check x,y before ask Z or can crash at invalide coordinates
if(!MapManager::IsValidMapCoord(mapid,x,y)) if (!MapManager::IsValidMapCoord(mapid,x,y))
{ {
PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid);
SetSentErrorMessage(true); SetSentErrorMessage(true);
return false; return false;
} }
TerrainInfo const *map = sTerrainMgr.LoadTerrain(mapid); TerrainInfo const* map = sTerrainMgr.LoadTerrain(mapid);
z = map->GetWaterOrGroundLevel(x, y, MAX_HEIGHT); z = map->GetWaterOrGroundLevel(x, y, MAX_HEIGHT);
} }
// stop flight if need // stop flight if need
if(player->IsTaxiFlying()) if (player->IsTaxiFlying())
{ {
player->GetMotionMaster()->MovementExpired(); player->GetMotionMaster()->MovementExpired();
player->m_taxi.ClearTaxiDestinations(); player->m_taxi.ClearTaxiDestinations();
@ -2081,7 +2081,7 @@ bool ChatHandler::HandleGoTaxinodeCommand(char* args)
bool ChatHandler::HandleGoCommand(char* args) bool ChatHandler::HandleGoCommand(char* args)
{ {
if(!*args) if (!*args)
return false; return false;
Player* _player = m_session->GetPlayer(); Player* _player = m_session->GetPlayer();
@ -2188,12 +2188,12 @@ bool ChatHandler::HandleGoZoneXYCommand(char* args)
// update to parent zone if exist (client map show only zones without parents) // update to parent zone if exist (client map show only zones without parents)
AreaTableEntry const* zoneEntry = areaEntry->zone ? GetAreaEntryByAreaID(areaEntry->zone) : areaEntry; AreaTableEntry const* zoneEntry = areaEntry->zone ? GetAreaEntryByAreaID(areaEntry->zone) : areaEntry;
MapEntry const *mapEntry = sMapStore.LookupEntry(zoneEntry->mapid); MapEntry const* mapEntry = sMapStore.LookupEntry(zoneEntry->mapid);
if (mapEntry->Instanceable()) if (mapEntry->Instanceable())
{ {
PSendSysMessage(LANG_INVALID_ZONE_MAP, areaEntry->ID, areaEntry->area_name[GetSessionDbcLocale()], PSendSysMessage(LANG_INVALID_ZONE_MAP, areaEntry->ID, areaEntry->area_name[GetSessionDbcLocale()],
mapEntry->MapID, mapEntry->name[GetSessionDbcLocale()]); mapEntry->MapID, mapEntry->name[GetSessionDbcLocale()]);
SetSentErrorMessage(true); SetSentErrorMessage(true);
return false; return false;
} }
@ -2201,7 +2201,7 @@ bool ChatHandler::HandleGoZoneXYCommand(char* args)
if (!Zone2MapCoordinates(x,y,zoneEntry->ID)) if (!Zone2MapCoordinates(x,y,zoneEntry->ID))
{ {
PSendSysMessage(LANG_INVALID_ZONE_MAP, areaEntry->ID, areaEntry->area_name[GetSessionDbcLocale()], PSendSysMessage(LANG_INVALID_ZONE_MAP, areaEntry->ID, areaEntry->area_name[GetSessionDbcLocale()],
mapEntry->MapID, mapEntry->name[GetSessionDbcLocale()]); mapEntry->MapID, mapEntry->name[GetSessionDbcLocale()]);
SetSentErrorMessage(true); SetSentErrorMessage(true);
return false; return false;
} }
@ -2235,10 +2235,10 @@ bool ChatHandler::HandleGoGridCommand(char* args)
bool ChatHandler::HandleModifyDrunkCommand(char* args) bool ChatHandler::HandleModifyDrunkCommand(char* args)
{ {
if(!*args) return false; if (!*args) return false;
uint32 drunklevel = (uint32)atoi(args); uint32 drunklevel = (uint32)atoi(args);
if(drunklevel > 100) if (drunklevel > 100)
drunklevel = 100; drunklevel = 100;
uint16 drunkMod = drunklevel * 0xFFFF / 100; uint16 drunkMod = drunklevel * 0xFFFF / 100;

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -32,22 +32,22 @@
#include "Util.h" #include "Util.h"
#include "DBCStores.h" #include "DBCStores.h"
void WorldSession::HandleAutostoreLootItemOpcode( WorldPacket & recv_data ) void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: CMSG_AUTOSTORE_LOOT_ITEM"); DEBUG_LOG("WORLD: CMSG_AUTOSTORE_LOOT_ITEM");
Player *player = GetPlayer(); Player* player = GetPlayer();
ObjectGuid lguid = player->GetLootGuid(); ObjectGuid lguid = player->GetLootGuid();
Loot *loot; Loot* loot;
uint8 lootSlot; uint8 lootSlot;
Item* pItem = NULL; Item* pItem = NULL;
recv_data >> lootSlot; recv_data >> lootSlot;
switch( lguid.GetHigh()) switch (lguid.GetHigh())
{ {
case HIGHGUID_GAMEOBJECT: case HIGHGUID_GAMEOBJECT:
{ {
GameObject *go = player->GetMap()->GetGameObject(lguid); GameObject* go = player->GetMap()->GetGameObject(lguid);
// not check distance for GO in case owned GO (fishing bobber case, for example) or Fishing hole GO // not check distance for GO in case owned GO (fishing bobber case, for example) or Fishing hole GO
if (!go || ((go->GetOwnerGuid() != _player->GetObjectGuid() && go->GetGoType() != GAMEOBJECT_TYPE_FISHINGHOLE) && !go->IsWithinDistInMap(_player,INTERACTION_DISTANCE))) if (!go || ((go->GetOwnerGuid() != _player->GetObjectGuid() && go->GetGoType() != GAMEOBJECT_TYPE_FISHINGHOLE) && !go->IsWithinDistInMap(_player,INTERACTION_DISTANCE)))
@ -61,7 +61,7 @@ void WorldSession::HandleAutostoreLootItemOpcode( WorldPacket & recv_data )
} }
case HIGHGUID_ITEM: case HIGHGUID_ITEM:
{ {
pItem = player->GetItemByGuid( lguid ); pItem = player->GetItemByGuid(lguid);
if (!pItem || !pItem->HasGeneratedLoot()) if (!pItem || !pItem->HasGeneratedLoot())
{ {
@ -74,7 +74,7 @@ void WorldSession::HandleAutostoreLootItemOpcode( WorldPacket & recv_data )
} }
case HIGHGUID_CORPSE: case HIGHGUID_CORPSE:
{ {
Corpse *bones = player->GetMap()->GetCorpse(lguid); Corpse* bones = player->GetMap()->GetCorpse(lguid);
if (!bones) if (!bones)
{ {
player->SendLootRelease(lguid); player->SendLootRelease(lguid);
@ -90,7 +90,7 @@ void WorldSession::HandleAutostoreLootItemOpcode( WorldPacket & recv_data )
bool ok_loot = pCreature && pCreature->isAlive() == (player->getClass()==CLASS_ROGUE && pCreature->lootForPickPocketed); bool ok_loot = pCreature && pCreature->isAlive() == (player->getClass()==CLASS_ROGUE && pCreature->lootForPickPocketed);
if( !ok_loot || !pCreature->IsWithinDistInMap(_player,INTERACTION_DISTANCE) ) if (!ok_loot || !pCreature->IsWithinDistInMap(_player,INTERACTION_DISTANCE))
{ {
player->SendLootRelease(lguid); player->SendLootRelease(lguid);
return; return;
@ -106,15 +106,15 @@ void WorldSession::HandleAutostoreLootItemOpcode( WorldPacket & recv_data )
} }
} }
QuestItem *qitem = NULL; QuestItem* qitem = NULL;
QuestItem *ffaitem = NULL; QuestItem* ffaitem = NULL;
QuestItem *conditem = NULL; QuestItem* conditem = NULL;
LootItem *item = loot->LootItemInSlot(lootSlot,player,&qitem,&ffaitem,&conditem); LootItem* item = loot->LootItemInSlot(lootSlot,player,&qitem,&ffaitem,&conditem);
if(!item) if (!item)
{ {
player->SendEquipError( EQUIP_ERR_ALREADY_LOOTED, NULL, NULL ); player->SendEquipError(EQUIP_ERR_ALREADY_LOOTED, NULL, NULL);
return; return;
} }
@ -129,10 +129,10 @@ void WorldSession::HandleAutostoreLootItemOpcode( WorldPacket & recv_data )
pItem->SetLootState(ITEM_LOOT_CHANGED); pItem->SetLootState(ITEM_LOOT_CHANGED);
ItemPosCountVec dest; ItemPosCountVec dest;
InventoryResult msg = player->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, item->itemid, item->count ); InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, item->itemid, item->count);
if ( msg == EQUIP_ERR_OK ) if (msg == EQUIP_ERR_OK)
{ {
Item * newitem = player->StoreNewItem( dest, item->itemid, true, item->randomPropertyId); Item* newitem = player->StoreNewItem(dest, item->itemid, true, item->randomPropertyId);
if (qitem) if (qitem)
{ {
@ -154,7 +154,7 @@ void WorldSession::HandleAutostoreLootItemOpcode( WorldPacket & recv_data )
else else
{ {
//not freeforall, notify everyone //not freeforall, notify everyone
if(conditem) if (conditem)
conditem->is_looted=true; conditem->is_looted=true;
loot->NotifyItemRemoved(lootSlot); loot->NotifyItemRemoved(lootSlot);
} }
@ -172,38 +172,38 @@ void WorldSession::HandleAutostoreLootItemOpcode( WorldPacket & recv_data )
player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_EPIC_ITEM, item->itemid, item->count); player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_EPIC_ITEM, item->itemid, item->count);
} }
else else
player->SendEquipError( msg, NULL, NULL, item->itemid ); player->SendEquipError(msg, NULL, NULL, item->itemid);
} }
void WorldSession::HandleLootMoneyOpcode( WorldPacket & /*recv_data*/ ) void WorldSession::HandleLootMoneyOpcode(WorldPacket& /*recv_data*/)
{ {
DEBUG_LOG("WORLD: CMSG_LOOT_MONEY"); DEBUG_LOG("WORLD: CMSG_LOOT_MONEY");
Player *player = GetPlayer(); Player* player = GetPlayer();
ObjectGuid guid = player->GetLootGuid(); ObjectGuid guid = player->GetLootGuid();
if (!guid) if (!guid)
return; return;
Loot *pLoot = NULL; Loot* pLoot = NULL;
Item* pItem = NULL; Item* pItem = NULL;
switch(guid.GetHigh()) switch (guid.GetHigh())
{ {
case HIGHGUID_GAMEOBJECT: case HIGHGUID_GAMEOBJECT:
{ {
GameObject *pGameObject = GetPlayer()->GetMap()->GetGameObject(guid); GameObject* pGameObject = GetPlayer()->GetMap()->GetGameObject(guid);
// not check distance for GO in case owned GO (fishing bobber case, for example) // not check distance for GO in case owned GO (fishing bobber case, for example)
if( pGameObject && (pGameObject->GetOwnerGuid() == _player->GetObjectGuid() || pGameObject->IsWithinDistInMap(_player,INTERACTION_DISTANCE)) ) if (pGameObject && (pGameObject->GetOwnerGuid() == _player->GetObjectGuid() || pGameObject->IsWithinDistInMap(_player,INTERACTION_DISTANCE)))
pLoot = &pGameObject->loot; pLoot = &pGameObject->loot;
break; break;
} }
case HIGHGUID_CORPSE: // remove insignia ONLY in BG case HIGHGUID_CORPSE: // remove insignia ONLY in BG
{ {
Corpse *bones = _player->GetMap()->GetCorpse(guid); Corpse* bones = _player->GetMap()->GetCorpse(guid);
if (bones && bones->IsWithinDistInMap(_player,INTERACTION_DISTANCE) ) if (bones && bones->IsWithinDistInMap(_player,INTERACTION_DISTANCE))
pLoot = &bones->loot; pLoot = &bones->loot;
break; break;
@ -224,7 +224,7 @@ void WorldSession::HandleLootMoneyOpcode( WorldPacket & /*recv_data*/ )
bool ok_loot = pCreature && pCreature->isAlive() == (player->getClass()==CLASS_ROGUE && pCreature->lootForPickPocketed); bool ok_loot = pCreature && pCreature->isAlive() == (player->getClass()==CLASS_ROGUE && pCreature->lootForPickPocketed);
if ( ok_loot && pCreature->IsWithinDistInMap(_player,INTERACTION_DISTANCE) ) if (ok_loot && pCreature->IsWithinDistInMap(_player,INTERACTION_DISTANCE))
pLoot = &pCreature->loot ; pLoot = &pCreature->loot ;
break; break;
@ -239,13 +239,13 @@ void WorldSession::HandleLootMoneyOpcode( WorldPacket & /*recv_data*/ )
if (!guid.IsItem() && player->GetGroup()) //item can be looted only single player if (!guid.IsItem() && player->GetGroup()) //item can be looted only single player
{ {
Group *group = player->GetGroup(); Group* group = player->GetGroup();
std::vector<Player*> playersNear; std::vector<Player*> playersNear;
for(GroupReference *itr = group->GetFirstMember(); itr != NULL; itr = itr->next()) for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{ {
Player* playerGroup = itr->getSource(); Player* playerGroup = itr->getSource();
if(!playerGroup) if (!playerGroup)
continue; continue;
if (player->IsWithinDistInMap(playerGroup,sWorld.getConfig(CONFIG_FLOAT_GROUP_XP_DISTANCE),false)) if (player->IsWithinDistInMap(playerGroup,sWorld.getConfig(CONFIG_FLOAT_GROUP_XP_DISTANCE),false))
playersNear.push_back(playerGroup); playersNear.push_back(playerGroup);
@ -255,7 +255,7 @@ void WorldSession::HandleLootMoneyOpcode( WorldPacket & /*recv_data*/ )
for (std::vector<Player*>::const_iterator i = playersNear.begin(); i != playersNear.end(); ++i) for (std::vector<Player*>::const_iterator i = playersNear.begin(); i != playersNear.end(); ++i)
{ {
(*i)->ModifyMoney( money_per_player ); (*i)->ModifyMoney(money_per_player);
(*i)->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY, money_per_player); (*i)->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY, money_per_player);
WorldPacket data(SMSG_LOOT_MONEY_NOTIFY, 4+1); WorldPacket data(SMSG_LOOT_MONEY_NOTIFY, 4+1);
@ -267,7 +267,7 @@ void WorldSession::HandleLootMoneyOpcode( WorldPacket & /*recv_data*/ )
} }
else else
{ {
player->ModifyMoney( pLoot->gold ); player->ModifyMoney(pLoot->gold);
player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY, pLoot->gold); player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY, pLoot->gold);
WorldPacket data(SMSG_LOOT_MONEY_NOTIFY, 4+1); WorldPacket data(SMSG_LOOT_MONEY_NOTIFY, 4+1);
@ -283,7 +283,7 @@ void WorldSession::HandleLootMoneyOpcode( WorldPacket & /*recv_data*/ )
} }
} }
void WorldSession::HandleLootOpcode( WorldPacket & recv_data ) void WorldSession::HandleLootOpcode(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: CMSG_LOOT"); DEBUG_LOG("WORLD: CMSG_LOOT");
@ -297,7 +297,7 @@ void WorldSession::HandleLootOpcode( WorldPacket & recv_data )
GetPlayer()->SendLoot(guid, LOOT_CORPSE); GetPlayer()->SendLoot(guid, LOOT_CORPSE);
} }
void WorldSession::HandleLootReleaseOpcode( WorldPacket & recv_data ) void WorldSession::HandleLootReleaseOpcode(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: CMSG_LOOT_RELEASE"); DEBUG_LOG("WORLD: CMSG_LOOT_RELEASE");
@ -311,22 +311,22 @@ void WorldSession::HandleLootReleaseOpcode( WorldPacket & recv_data )
void WorldSession::DoLootRelease(ObjectGuid lguid) void WorldSession::DoLootRelease(ObjectGuid lguid)
{ {
Player *player = GetPlayer(); Player* player = GetPlayer();
Loot *loot; Loot* loot;
player->SetLootGuid(ObjectGuid()); player->SetLootGuid(ObjectGuid());
player->SendLootRelease(lguid); player->SendLootRelease(lguid);
player->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_LOOTING); player->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_LOOTING);
if(!player->IsInWorld()) if (!player->IsInWorld())
return; return;
switch(lguid.GetHigh()) switch (lguid.GetHigh())
{ {
case HIGHGUID_GAMEOBJECT: case HIGHGUID_GAMEOBJECT:
{ {
GameObject *go = GetPlayer()->GetMap()->GetGameObject(lguid); GameObject* go = GetPlayer()->GetMap()->GetGameObject(lguid);
// not check distance for GO in case owned GO (fishing bobber case, for example) or Fishing hole GO // not check distance for GO in case owned GO (fishing bobber case, for example) or Fishing hole GO
if (!go || ((go->GetOwnerGuid() != _player->GetObjectGuid() && go->GetGoType() != GAMEOBJECT_TYPE_FISHINGHOLE) && !go->IsWithinDistInMap(_player,INTERACTION_DISTANCE))) if (!go || ((go->GetOwnerGuid() != _player->GetObjectGuid() && go->GetGoType() != GAMEOBJECT_TYPE_FISHINGHOLE) && !go->IsWithinDistInMap(_player,INTERACTION_DISTANCE)))
@ -342,13 +342,13 @@ void WorldSession::DoLootRelease(ObjectGuid lguid)
else if (loot->isLooted() || go->GetGoType() == GAMEOBJECT_TYPE_FISHINGNODE) else if (loot->isLooted() || go->GetGoType() == GAMEOBJECT_TYPE_FISHINGNODE)
{ {
// GO is mineral vein? so it is not removed after its looted // GO is mineral vein? so it is not removed after its looted
if(go->GetGoType() == GAMEOBJECT_TYPE_CHEST) if (go->GetGoType() == GAMEOBJECT_TYPE_CHEST)
{ {
uint32 go_min = go->GetGOInfo()->chest.minSuccessOpens; uint32 go_min = go->GetGOInfo()->chest.minSuccessOpens;
uint32 go_max = go->GetGOInfo()->chest.maxSuccessOpens; uint32 go_max = go->GetGOInfo()->chest.maxSuccessOpens;
// only vein pass this check // only vein pass this check
if(go_min != 0 && go_max > go_min) if (go_min != 0 && go_max > go_min)
{ {
float amount_rate = sWorld.getConfig(CONFIG_FLOAT_RATE_MINING_AMOUNT); float amount_rate = sWorld.getConfig(CONFIG_FLOAT_RATE_MINING_AMOUNT);
float min_amount = go_min*amount_rate; float min_amount = go_min*amount_rate;
@ -357,19 +357,19 @@ void WorldSession::DoLootRelease(ObjectGuid lguid)
go->AddUse(); go->AddUse();
float uses = float(go->GetUseCount()); float uses = float(go->GetUseCount());
if(uses < max_amount) if (uses < max_amount)
{ {
if(uses >= min_amount) if (uses >= min_amount)
{ {
float chance_rate = sWorld.getConfig(CONFIG_FLOAT_RATE_MINING_NEXT); float chance_rate = sWorld.getConfig(CONFIG_FLOAT_RATE_MINING_NEXT);
int32 ReqValue = 175; int32 ReqValue = 175;
LockEntry const *lockInfo = sLockStore.LookupEntry(go->GetGOInfo()->chest.lockId); LockEntry const* lockInfo = sLockStore.LookupEntry(go->GetGOInfo()->chest.lockId);
if(lockInfo) if (lockInfo)
ReqValue = lockInfo->Skill[0]; ReqValue = lockInfo->Skill[0];
float skill = float(player->GetSkillValue(SKILL_MINING))/(ReqValue+25); float skill = float(player->GetSkillValue(SKILL_MINING))/(ReqValue+25);
double chance = pow(0.8*chance_rate,4*(1/double(max_amount))*double(uses)); double chance = pow(0.8*chance_rate,4*(1/double(max_amount))*double(uses));
if(roll_chance_f(float(100.0f*chance+skill))) if (roll_chance_f(float(100.0f*chance+skill)))
{ {
go->SetLootState(GO_READY); go->SetLootState(GO_READY);
} }
@ -386,7 +386,8 @@ void WorldSession::DoLootRelease(ObjectGuid lguid)
go->SetLootState(GO_JUST_DEACTIVATED); go->SetLootState(GO_JUST_DEACTIVATED);
} }
else if (go->GetGoType() == GAMEOBJECT_TYPE_FISHINGHOLE) else if (go->GetGoType() == GAMEOBJECT_TYPE_FISHINGHOLE)
{ // The fishing hole used once more {
// The fishing hole used once more
go->AddUse(); // if the max usage is reached, will be despawned at next tick go->AddUse(); // if the max usage is reached, will be despawned at next tick
if (go->GetUseCount() >= urand(go->GetGOInfo()->fishinghole.minSuccessOpens,go->GetGOInfo()->fishinghole.maxSuccessOpens)) if (go->GetUseCount() >= urand(go->GetGOInfo()->fishinghole.minSuccessOpens,go->GetGOInfo()->fishinghole.maxSuccessOpens))
{ {
@ -407,8 +408,8 @@ void WorldSession::DoLootRelease(ObjectGuid lguid)
} }
case HIGHGUID_CORPSE: // ONLY remove insignia at BG case HIGHGUID_CORPSE: // ONLY remove insignia at BG
{ {
Corpse *corpse = _player->GetMap()->GetCorpse(lguid); Corpse* corpse = _player->GetMap()->GetCorpse(lguid);
if (!corpse || !corpse->IsWithinDistInMap(_player,INTERACTION_DISTANCE) ) if (!corpse || !corpse->IsWithinDistInMap(_player,INTERACTION_DISTANCE))
return; return;
loot = &corpse->loot; loot = &corpse->loot;
@ -422,20 +423,20 @@ void WorldSession::DoLootRelease(ObjectGuid lguid)
} }
case HIGHGUID_ITEM: case HIGHGUID_ITEM:
{ {
Item *pItem = player->GetItemByGuid(lguid ); Item* pItem = player->GetItemByGuid(lguid);
if (!pItem) if (!pItem)
return; return;
switch (pItem->loot.loot_type) switch (pItem->loot.loot_type)
{ {
// temporary loot in stacking items, clear loot state, no auto loot move // temporary loot in stacking items, clear loot state, no auto loot move
case LOOT_MILLING: case LOOT_MILLING:
case LOOT_PROSPECTING: case LOOT_PROSPECTING:
{ {
uint32 count = pItem->GetCount(); uint32 count = pItem->GetCount();
// >=5 checked in spell code, but will work for cheating cases also with removing from another stacks. // >=5 checked in spell code, but will work for cheating cases also with removing from another stacks.
if(count > 5) if (count > 5)
count = 5; count = 5;
// reset loot for allow repeat looting if stack > 5 // reset loot for allow repeat looting if stack > 5
@ -452,7 +453,7 @@ void WorldSession::DoLootRelease(ObjectGuid lguid)
player->AutoStoreLoot(pItem->loot); // can be lost if no space player->AutoStoreLoot(pItem->loot); // can be lost if no space
pItem->loot.clear(); pItem->loot.clear();
pItem->SetLootState(ITEM_LOOT_REMOVED); pItem->SetLootState(ITEM_LOOT_REMOVED);
player->DestroyItem( pItem->GetBagSlot(),pItem->GetSlot(), true); player->DestroyItem(pItem->GetBagSlot(),pItem->GetSlot(), true);
break; break;
} }
// normal persistence loot // normal persistence loot
@ -462,7 +463,7 @@ void WorldSession::DoLootRelease(ObjectGuid lguid)
if (pItem->loot.isLooted()) if (pItem->loot.isLooted())
{ {
pItem->SetLootState(ITEM_LOOT_REMOVED); pItem->SetLootState(ITEM_LOOT_REMOVED);
player->DestroyItem( pItem->GetBagSlot(),pItem->GetSlot(), true); player->DestroyItem(pItem->GetBagSlot(),pItem->GetSlot(), true);
} }
break; break;
} }
@ -475,13 +476,13 @@ void WorldSession::DoLootRelease(ObjectGuid lguid)
Creature* pCreature = GetPlayer()->GetMap()->GetCreature(lguid); Creature* pCreature = GetPlayer()->GetMap()->GetCreature(lguid);
bool ok_loot = pCreature && pCreature->isAlive() == (player->getClass()==CLASS_ROGUE && pCreature->lootForPickPocketed); bool ok_loot = pCreature && pCreature->isAlive() == (player->getClass()==CLASS_ROGUE && pCreature->lootForPickPocketed);
if ( !ok_loot || !pCreature->IsWithinDistInMap(_player,INTERACTION_DISTANCE) ) if (!ok_loot || !pCreature->IsWithinDistInMap(_player,INTERACTION_DISTANCE))
return; return;
loot = &pCreature->loot; loot = &pCreature->loot;
// update next looter // update next looter
if(Group* group = pCreature->GetGroupLootRecipient()) if (Group* group = pCreature->GetGroupLootRecipient())
if (group->GetLooterGuid() == player->GetObjectGuid()) if (group->GetLooterGuid() == player->GetObjectGuid())
group->UpdateLooterGuid(pCreature); group->UpdateLooterGuid(pCreature);
@ -490,7 +491,7 @@ void WorldSession::DoLootRelease(ObjectGuid lguid)
// for example skinning after normal loot // for example skinning after normal loot
pCreature->PrepareBodyLootState(); pCreature->PrepareBodyLootState();
if(!pCreature->isAlive()) if (!pCreature->isAlive())
pCreature->AllLootRemovedFromCorpse(); pCreature->AllLootRemovedFromCorpse();
} }
break; break;
@ -506,7 +507,7 @@ void WorldSession::DoLootRelease(ObjectGuid lguid)
loot->RemoveLooter(player->GetObjectGuid()); loot->RemoveLooter(player->GetObjectGuid());
} }
void WorldSession::HandleLootMasterGiveOpcode( WorldPacket & recv_data ) void WorldSession::HandleLootMasterGiveOpcode(WorldPacket& recv_data)
{ {
uint8 slotid; uint8 slotid;
ObjectGuid lootguid; ObjectGuid lootguid;
@ -520,7 +521,7 @@ void WorldSession::HandleLootMasterGiveOpcode( WorldPacket & recv_data )
return; return;
} }
Player *target = ObjectAccessor::FindPlayer(target_playerguid); Player* target = ObjectAccessor::FindPlayer(target_playerguid);
if (!target) if (!target)
return; return;
@ -529,20 +530,20 @@ void WorldSession::HandleLootMasterGiveOpcode( WorldPacket & recv_data )
if (_player->GetLootGuid() != lootguid) if (_player->GetLootGuid() != lootguid)
return; return;
Loot *pLoot = NULL; Loot* pLoot = NULL;
if (lootguid.IsCreatureOrVehicle()) if (lootguid.IsCreatureOrVehicle())
{ {
Creature *pCreature = GetPlayer()->GetMap()->GetCreature(lootguid); Creature* pCreature = GetPlayer()->GetMap()->GetCreature(lootguid);
if(!pCreature) if (!pCreature)
return; return;
pLoot = &pCreature->loot; pLoot = &pCreature->loot;
} }
else if(lootguid.IsGameObject()) else if (lootguid.IsGameObject())
{ {
GameObject *pGO = GetPlayer()->GetMap()->GetGameObject(lootguid); GameObject* pGO = GetPlayer()->GetMap()->GetGameObject(lootguid);
if(!pGO) if (!pGO)
return; return;
pLoot = &pGO->loot; pLoot = &pGO->loot;
@ -559,19 +560,19 @@ void WorldSession::HandleLootMasterGiveOpcode( WorldPacket & recv_data )
LootItem& item = pLoot->items[slotid]; LootItem& item = pLoot->items[slotid];
ItemPosCountVec dest; ItemPosCountVec dest;
InventoryResult msg = target->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, item.itemid, item.count ); InventoryResult msg = target->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, item.itemid, item.count);
if ( msg != EQUIP_ERR_OK ) if (msg != EQUIP_ERR_OK)
{ {
target->SendEquipError( msg, NULL, NULL, item.itemid ); target->SendEquipError(msg, NULL, NULL, item.itemid);
// send duplicate of error massage to master looter // send duplicate of error massage to master looter
_player->SendEquipError( msg, NULL, NULL, item.itemid ); _player->SendEquipError(msg, NULL, NULL, item.itemid);
return; return;
} }
// now move item from loot to target inventory // now move item from loot to target inventory
Item * newitem = target->StoreNewItem( dest, item.itemid, true, item.randomPropertyId ); Item* newitem = target->StoreNewItem(dest, item.itemid, true, item.randomPropertyId);
target->SendNewItem(newitem, uint32(item.count), false, false, true ); target->SendNewItem(newitem, uint32(item.count), false, false, true);
target->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM, item.itemid, item.count); target->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM, item.itemid, item.count);
target->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_TYPE, pLoot->loot_type, item.count); target->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_TYPE, pLoot->loot_type, item.count);
target->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_EPIC_ITEM, item.itemid, item.count); target->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_EPIC_ITEM, item.itemid, item.count);

View file

@ -27,7 +27,8 @@
#include "DBCStores.h" #include "DBCStores.h"
#include "SQLStorages.h" #include "SQLStorages.h"
static eConfigFloatValues const qualityToRate[MAX_ITEM_QUALITY] = { static eConfigFloatValues const qualityToRate[MAX_ITEM_QUALITY] =
{
CONFIG_FLOAT_RATE_DROP_ITEM_POOR, // ITEM_QUALITY_POOR CONFIG_FLOAT_RATE_DROP_ITEM_POOR, // ITEM_QUALITY_POOR
CONFIG_FLOAT_RATE_DROP_ITEM_NORMAL, // ITEM_QUALITY_NORMAL CONFIG_FLOAT_RATE_DROP_ITEM_NORMAL, // ITEM_QUALITY_NORMAL
CONFIG_FLOAT_RATE_DROP_ITEM_UNCOMMON, // ITEM_QUALITY_UNCOMMON CONFIG_FLOAT_RATE_DROP_ITEM_UNCOMMON, // ITEM_QUALITY_UNCOMMON
@ -37,26 +38,26 @@ static eConfigFloatValues const qualityToRate[MAX_ITEM_QUALITY] = {
CONFIG_FLOAT_RATE_DROP_ITEM_ARTIFACT, // ITEM_QUALITY_ARTIFACT CONFIG_FLOAT_RATE_DROP_ITEM_ARTIFACT, // ITEM_QUALITY_ARTIFACT
}; };
LootStore LootTemplates_Creature( "creature_loot_template", "creature entry", true); LootStore LootTemplates_Creature("creature_loot_template", "creature entry", true);
LootStore LootTemplates_Disenchant( "disenchant_loot_template", "item disenchant id", true); LootStore LootTemplates_Disenchant("disenchant_loot_template", "item disenchant id", true);
LootStore LootTemplates_Fishing( "fishing_loot_template", "area id", true); LootStore LootTemplates_Fishing("fishing_loot_template", "area id", true);
LootStore LootTemplates_Gameobject( "gameobject_loot_template", "gameobject lootid", true); LootStore LootTemplates_Gameobject("gameobject_loot_template", "gameobject lootid", true);
LootStore LootTemplates_Item( "item_loot_template", "item entry with ITEM_FLAG_LOOTABLE", true); LootStore LootTemplates_Item("item_loot_template", "item entry with ITEM_FLAG_LOOTABLE", true);
LootStore LootTemplates_Mail( "mail_loot_template", "mail template id", false); LootStore LootTemplates_Mail("mail_loot_template", "mail template id", false);
LootStore LootTemplates_Milling( "milling_loot_template", "item entry (herb)", true); LootStore LootTemplates_Milling("milling_loot_template", "item entry (herb)", true);
LootStore LootTemplates_Pickpocketing("pickpocketing_loot_template","creature pickpocket lootid", true); LootStore LootTemplates_Pickpocketing("pickpocketing_loot_template","creature pickpocket lootid", true);
LootStore LootTemplates_Prospecting( "prospecting_loot_template", "item entry (ore)", true); LootStore LootTemplates_Prospecting("prospecting_loot_template", "item entry (ore)", true);
LootStore LootTemplates_Reference( "reference_loot_template", "reference id", false); LootStore LootTemplates_Reference("reference_loot_template", "reference id", false);
LootStore LootTemplates_Skinning( "skinning_loot_template", "creature skinning id", true); LootStore LootTemplates_Skinning("skinning_loot_template", "creature skinning id", true);
LootStore LootTemplates_Spell( "spell_loot_template", "spell id (random item creating)",false); LootStore LootTemplates_Spell("spell_loot_template", "spell id (random item creating)",false);
class LootTemplate::LootGroup // A set of loot definitions for items (refs are not allowed) class LootTemplate::LootGroup // A set of loot definitions for items (refs are not allowed)
{ {
public: public:
void AddEntry(LootStoreItem& item); // Adds an entry to the group (at loading stage) void AddEntry(LootStoreItem& item); // Adds an entry to the group (at loading stage)
bool HasQuestDrop() const; // True if group includes at least 1 quest drop entry bool HasQuestDrop() const; // True if group includes at least 1 quest drop entry
bool HasQuestDropForPlayer(Player const * player) const; bool HasQuestDropForPlayer(Player const* player) const;
// The same for active quests of the player // The same for active quests of the player
void Process(Loot& loot) const; // Rolls an item from the group (if any) and adds the item to the loot void Process(Loot& loot) const; // Rolls an item from the group (if any) and adds the item to the loot
float RawTotalChance() const; // Overall chance for the group (without equal chanced items) float RawTotalChance() const; // Overall chance for the group (without equal chanced items)
float TotalChance() const; // Overall chance for the group float TotalChance() const; // Overall chance for the group
@ -68,7 +69,7 @@ class LootTemplate::LootGroup // A set of loot def
LootStoreItemList ExplicitlyChanced; // Entries with chances defined in DB LootStoreItemList ExplicitlyChanced; // Entries with chances defined in DB
LootStoreItemList EqualChanced; // Zero chances - every entry takes the same chance LootStoreItemList EqualChanced; // Zero chances - every entry takes the same chance
LootStoreItem const * Roll() const; // Rolls an item from the group, returns NULL if all miss their chances LootStoreItem const* Roll() const; // Rolls an item from the group, returns NULL if all miss their chances
}; };
//Remove all data and free all memory //Remove all data and free all memory
@ -83,7 +84,7 @@ void LootStore::Clear()
// Actual checks are done within LootTemplate::Verify() which is called for every template // Actual checks are done within LootTemplate::Verify() which is called for every template
void LootStore::Verify() const void LootStore::Verify() const
{ {
for (LootTemplateMap::const_iterator i = m_LootTemplates.begin(); i != m_LootTemplates.end(); ++i ) for (LootTemplateMap::const_iterator i = m_LootTemplates.begin(); i != m_LootTemplates.end(); ++i)
i->second->Verify(*this, i->first); i->second->Verify(*this, i->first);
} }
@ -97,10 +98,10 @@ void LootStore::LoadLootTable()
// Clearing store (for reloading case) // Clearing store (for reloading case)
Clear(); Clear();
sLog.outString( "%s :", GetName()); sLog.outString("%s :", GetName());
// 0 1 2 3 4 5 6 // 0 1 2 3 4 5 6
QueryResult *result = WorldDatabase.PQuery("SELECT entry, item, ChanceOrQuestChance, groupid, mincountOrRef, maxcount, condition_id FROM %s",GetName()); QueryResult* result = WorldDatabase.PQuery("SELECT entry, item, ChanceOrQuestChance, groupid, mincountOrRef, maxcount, condition_id FROM %s",GetName());
if (result) if (result)
{ {
@ -108,7 +109,7 @@ void LootStore::LoadLootTable()
do do
{ {
Field *fields = result->Fetch(); Field* fields = result->Fetch();
bar.step(); bar.step();
uint32 entry = fields[0].GetUInt32(); uint32 entry = fields[0].GetUInt32();
@ -147,12 +148,12 @@ void LootStore::LoadLootTable()
continue; continue;
// Looking for the template of the entry // Looking for the template of the entry
// often entries are put together // often entries are put together
if (m_LootTemplates.empty() || tab->first != entry) if (m_LootTemplates.empty() || tab->first != entry)
{ {
// Searching the template (in case template Id changed) // Searching the template (in case template Id changed)
tab = m_LootTemplates.find(entry); tab = m_LootTemplates.find(entry);
if ( tab == m_LootTemplates.end() ) if (tab == m_LootTemplates.end())
{ {
std::pair< LootTemplateMap::iterator, bool > pr = m_LootTemplates.insert(LootTemplateMap::value_type(entry, new LootTemplate)); std::pair< LootTemplateMap::iterator, bool > pr = m_LootTemplates.insert(LootTemplateMap::value_type(entry, new LootTemplate));
tab = pr.first; tab = pr.first;
@ -165,26 +166,27 @@ void LootStore::LoadLootTable()
tab->second->AddEntry(storeitem); tab->second->AddEntry(storeitem);
++count; ++count;
} while (result->NextRow()); }
while (result->NextRow());
delete result; delete result;
Verify(); // Checks validity of the loot store Verify(); // Checks validity of the loot store
sLog.outString(); sLog.outString();
sLog.outString( ">> Loaded %u loot definitions (%lu templates)", count, (unsigned long)m_LootTemplates.size()); sLog.outString(">> Loaded %u loot definitions (%lu templates)", count, (unsigned long)m_LootTemplates.size());
} }
else else
{ {
sLog.outString(); sLog.outString();
sLog.outErrorDb( ">> Loaded 0 loot definitions. DB table `%s` is empty.",GetName() ); sLog.outErrorDb(">> Loaded 0 loot definitions. DB table `%s` is empty.",GetName());
} }
} }
bool LootStore::HaveQuestLootFor(uint32 loot_id) const bool LootStore::HaveQuestLootFor(uint32 loot_id) const
{ {
LootTemplateMap::const_iterator itr = m_LootTemplates.find(loot_id); LootTemplateMap::const_iterator itr = m_LootTemplates.find(loot_id);
if(itr == m_LootTemplates.end()) if (itr == m_LootTemplates.end())
return false; return false;
// scan loot for quest items // scan loot for quest items
@ -215,20 +217,20 @@ void LootStore::LoadAndCollectLootIds(LootIdSet& ids_set)
{ {
LoadLootTable(); LoadLootTable();
for(LootTemplateMap::const_iterator tab = m_LootTemplates.begin(); tab != m_LootTemplates.end(); ++tab) for (LootTemplateMap::const_iterator tab = m_LootTemplates.begin(); tab != m_LootTemplates.end(); ++tab)
ids_set.insert(tab->first); ids_set.insert(tab->first);
} }
void LootStore::CheckLootRefs(LootIdSet* ref_set) const void LootStore::CheckLootRefs(LootIdSet* ref_set) const
{ {
for(LootTemplateMap::const_iterator ltItr = m_LootTemplates.begin(); ltItr != m_LootTemplates.end(); ++ltItr) for (LootTemplateMap::const_iterator ltItr = m_LootTemplates.begin(); ltItr != m_LootTemplates.end(); ++ltItr)
ltItr->second->CheckLootRefs(ref_set); ltItr->second->CheckLootRefs(ref_set);
} }
void LootStore::ReportUnusedIds(LootIdSet const& ids_set) const void LootStore::ReportUnusedIds(LootIdSet const& ids_set) const
{ {
// all still listed ids isn't referenced // all still listed ids isn't referenced
for(LootIdSet::const_iterator itr = ids_set.begin(); itr != ids_set.end(); ++itr) for (LootIdSet::const_iterator itr = ids_set.begin(); itr != ids_set.end(); ++itr)
sLog.outErrorDb("Table '%s' entry %d isn't %s and not referenced from loot, and then useless.", GetName(), *itr,GetEntryName()); sLog.outErrorDb("Table '%s' entry %d isn't %s and not referenced from loot, and then useless.", GetName(), *itr,GetEntryName());
} }
@ -245,13 +247,13 @@ void LootStore::ReportNotExistedId(uint32 id) const
// RATE_DROP_ITEMS is no longer used for all types of entries // RATE_DROP_ITEMS is no longer used for all types of entries
bool LootStoreItem::Roll(bool rate) const bool LootStoreItem::Roll(bool rate) const
{ {
if(chance>=100.0f) if (chance>=100.0f)
return true; return true;
if(mincountOrRef < 0) // reference case if (mincountOrRef < 0) // reference case
return roll_chance_f(chance* (rate ? sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_ITEM_REFERENCED) : 1.0f)); return roll_chance_f(chance* (rate ? sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_ITEM_REFERENCED) : 1.0f));
ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(itemid); ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(itemid);
float qualityModifier = pProto && rate ? sWorld.getConfig(qualityToRate[pProto->Quality]) : 1.0f; float qualityModifier = pProto && rate ? sWorld.getConfig(qualityToRate[pProto->Quality]) : 1.0f;
@ -275,8 +277,8 @@ bool LootStoreItem::IsValid(LootStore const& store, uint32 entry) const
if (mincountOrRef > 0) // item (quest or non-quest) entry, maybe grouped if (mincountOrRef > 0) // item (quest or non-quest) entry, maybe grouped
{ {
ItemPrototype const *proto = ObjectMgr::GetItemPrototype(itemid); ItemPrototype const* proto = ObjectMgr::GetItemPrototype(itemid);
if(!proto) if (!proto)
{ {
sLog.outErrorDb("Table '%s' entry %d item %d: item entry not listed in `item_template` - skipped", store.GetName(), entry, itemid); sLog.outErrorDb("Table '%s' entry %d item %d: item entry not listed in `item_template` - skipped", store.GetName(), entry, itemid);
return false; return false;
@ -361,13 +363,13 @@ LootItem::LootItem(uint32 itemid_, uint32 count_, uint32 randomSuffix_, int32 ra
} }
// Basic checks for player/item compatibility - if false no chance to see the item in the loot // Basic checks for player/item compatibility - if false no chance to see the item in the loot
bool LootItem::AllowedForPlayer(Player const * player) const bool LootItem::AllowedForPlayer(Player const* player) const
{ {
// DB conditions check // DB conditions check
if (conditionId && !sObjectMgr.IsPlayerMeetToNEWCondition(player, conditionId)) if (conditionId && !sObjectMgr.IsPlayerMeetToNEWCondition(player, conditionId))
return false; return false;
ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(itemid); ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(itemid);
if (!pProto) if (!pProto)
return false; return false;
@ -378,10 +380,10 @@ bool LootItem::AllowedForPlayer(Player const * player) const
if ((pProto->Flags2 & ITEM_FLAG2_ALLIANCE_ONLY) && player->GetTeam() != ALLIANCE) if ((pProto->Flags2 & ITEM_FLAG2_ALLIANCE_ONLY) && player->GetTeam() != ALLIANCE)
return false; return false;
if ( needs_quest ) if (needs_quest)
{ {
// Checking quests for quest-only drop (check only quests requirements in this case) // Checking quests for quest-only drop (check only quests requirements in this case)
if( !player->HasQuestForItem(itemid) ) if (!player->HasQuestForItem(itemid))
return false; return false;
} }
else else
@ -420,7 +422,7 @@ LootSlotType LootItem::GetSlotTypeForSharedLoot(PermissionTypes permission, Play
// //
// Inserts the item into the loot (called by LootTemplate processors) // Inserts the item into the loot (called by LootTemplate processors)
void Loot::AddItem(LootStoreItem const & item) void Loot::AddItem(LootStoreItem const& item)
{ {
if (item.needs_quest) // Quest drop if (item.needs_quest) // Quest drop
{ {
@ -447,7 +449,7 @@ void Loot::AddItem(LootStoreItem const & item)
bool Loot::FillLoot(uint32 loot_id, LootStore const& store, Player* loot_owner, bool personal, bool noEmptyError) bool Loot::FillLoot(uint32 loot_id, LootStore const& store, Player* loot_owner, bool personal, bool noEmptyError)
{ {
// Must be provided // Must be provided
if(!loot_owner) if (!loot_owner)
return false; return false;
LootTemplate const* tab = store.GetLootFor(loot_id); LootTemplate const* tab = store.GetLootFor(loot_id);
@ -462,14 +464,14 @@ bool Loot::FillLoot(uint32 loot_id, LootStore const& store, Player* loot_owner,
items.reserve(MAX_NR_LOOT_ITEMS); items.reserve(MAX_NR_LOOT_ITEMS);
m_questItems.reserve(MAX_NR_QUEST_ITEMS); m_questItems.reserve(MAX_NR_QUEST_ITEMS);
tab->Process(*this, store,store.IsRatesAllowed ()); // Processing is done there, callback via Loot::AddItem() tab->Process(*this, store,store.IsRatesAllowed()); // Processing is done there, callback via Loot::AddItem()
// Setting access rights for group loot case // Setting access rights for group loot case
Group * pGroup=loot_owner->GetGroup(); Group* pGroup=loot_owner->GetGroup();
if(!personal && pGroup) if (!personal && pGroup)
{ {
for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) for (GroupReference* itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
if(Player* pl = itr->getSource()) if (Player* pl = itr->getSource())
FillNotNormalLootFor(pl); FillNotNormalLootFor(pl);
} }
// ... for personal loot // ... for personal loot
@ -498,12 +500,12 @@ void Loot::FillNotNormalLootFor(Player* pl)
QuestItemList* Loot::FillFFALoot(Player* player) QuestItemList* Loot::FillFFALoot(Player* player)
{ {
QuestItemList *ql = new QuestItemList(); QuestItemList* ql = new QuestItemList();
for(uint8 i = 0; i < items.size(); ++i) for (uint8 i = 0; i < items.size(); ++i)
{ {
LootItem &item = items[i]; LootItem& item = items[i];
if(!item.is_looted && item.freeforall && item.AllowedForPlayer(player) ) if (!item.is_looted && item.freeforall && item.AllowedForPlayer(player))
{ {
ql->push_back(QuestItem(i)); ql->push_back(QuestItem(i));
++unlootedCount; ++unlootedCount;
@ -522,12 +524,12 @@ QuestItemList* Loot::FillFFALoot(Player* player)
QuestItemList* Loot::FillQuestLoot(Player* player) QuestItemList* Loot::FillQuestLoot(Player* player)
{ {
if (items.size() == MAX_NR_LOOT_ITEMS) return NULL; if (items.size() == MAX_NR_LOOT_ITEMS) return NULL;
QuestItemList *ql = new QuestItemList(); QuestItemList* ql = new QuestItemList();
for(uint8 i = 0; i < m_questItems.size(); ++i) for (uint8 i = 0; i < m_questItems.size(); ++i)
{ {
LootItem &item = m_questItems[i]; LootItem& item = m_questItems[i];
if(!item.is_looted && item.AllowedForPlayer(player) ) if (!item.is_looted && item.AllowedForPlayer(player))
{ {
ql->push_back(QuestItem(i)); ql->push_back(QuestItem(i));
@ -556,15 +558,15 @@ QuestItemList* Loot::FillQuestLoot(Player* player)
QuestItemList* Loot::FillNonQuestNonFFAConditionalLoot(Player* player) QuestItemList* Loot::FillNonQuestNonFFAConditionalLoot(Player* player)
{ {
QuestItemList *ql = new QuestItemList(); QuestItemList* ql = new QuestItemList();
for(uint8 i = 0; i < items.size(); ++i) for (uint8 i = 0; i < items.size(); ++i)
{ {
LootItem &item = items[i]; LootItem& item = items[i];
if(!item.is_looted && !item.freeforall && item.conditionId && item.AllowedForPlayer(player)) if (!item.is_looted && !item.freeforall && item.conditionId && item.AllowedForPlayer(player))
{ {
ql->push_back(QuestItem(i)); ql->push_back(QuestItem(i));
if(!item.is_counted) if (!item.is_counted)
{ {
++unlootedCount; ++unlootedCount;
item.is_counted=true; item.is_counted=true;
@ -648,7 +650,7 @@ void Loot::NotifyQuestItemRemoved(uint8 questIndex)
} }
} }
void Loot::generateMoneyLoot( uint32 minAmount, uint32 maxAmount ) void Loot::generateMoneyLoot(uint32 minAmount, uint32 maxAmount)
{ {
if (maxAmount > 0) if (maxAmount > 0)
{ {
@ -661,7 +663,7 @@ void Loot::generateMoneyLoot( uint32 minAmount, uint32 maxAmount )
} }
} }
LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem **qitem, QuestItem **ffaitem, QuestItem **conditem) LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem** qitem, QuestItem** ffaitem, QuestItem** conditem)
{ {
LootItem* item = NULL; LootItem* item = NULL;
bool is_looted = true; bool is_looted = true;
@ -671,8 +673,8 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem **qite
QuestItemMap::const_iterator itr = m_playerQuestItems.find(player->GetGUIDLow()); QuestItemMap::const_iterator itr = m_playerQuestItems.find(player->GetGUIDLow());
if (itr != m_playerQuestItems.end() && questSlot < itr->second->size()) if (itr != m_playerQuestItems.end() && questSlot < itr->second->size())
{ {
QuestItem *qitem2 = &itr->second->at(questSlot); QuestItem* qitem2 = &itr->second->at(questSlot);
if(qitem) if (qitem)
*qitem = qitem2; *qitem = qitem2;
item = &m_questItems[qitem2->index]; item = &m_questItems[qitem2->index];
is_looted = qitem2->is_looted; is_looted = qitem2->is_looted;
@ -682,16 +684,16 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem **qite
{ {
item = &items[lootSlot]; item = &items[lootSlot];
is_looted = item->is_looted; is_looted = item->is_looted;
if(item->freeforall) if (item->freeforall)
{ {
QuestItemMap::const_iterator itr = m_playerFFAItems.find(player->GetGUIDLow()); QuestItemMap::const_iterator itr = m_playerFFAItems.find(player->GetGUIDLow());
if (itr != m_playerFFAItems.end()) if (itr != m_playerFFAItems.end())
{ {
for(QuestItemList::const_iterator iter=itr->second->begin(); iter!= itr->second->end(); ++iter) for (QuestItemList::const_iterator iter=itr->second->begin(); iter!= itr->second->end(); ++iter)
if(iter->index==lootSlot) if (iter->index==lootSlot)
{ {
QuestItem *ffaitem2 = (QuestItem*)&(*iter); QuestItem* ffaitem2 = (QuestItem*)&(*iter);
if(ffaitem) if (ffaitem)
*ffaitem = ffaitem2; *ffaitem = ffaitem2;
is_looted = ffaitem2->is_looted; is_looted = ffaitem2->is_looted;
break; break;
@ -703,12 +705,12 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem **qite
QuestItemMap::const_iterator itr = m_playerNonQuestNonFFAConditionalItems.find(player->GetGUIDLow()); QuestItemMap::const_iterator itr = m_playerNonQuestNonFFAConditionalItems.find(player->GetGUIDLow());
if (itr != m_playerNonQuestNonFFAConditionalItems.end()) if (itr != m_playerNonQuestNonFFAConditionalItems.end())
{ {
for(QuestItemList::const_iterator iter=itr->second->begin(); iter!= itr->second->end(); ++iter) for (QuestItemList::const_iterator iter=itr->second->begin(); iter!= itr->second->end(); ++iter)
{ {
if(iter->index==lootSlot) if (iter->index==lootSlot)
{ {
QuestItem *conditem2 = (QuestItem*)&(*iter); QuestItem* conditem2 = (QuestItem*)&(*iter);
if(conditem) if (conditem)
*conditem = conditem2; *conditem = conditem2;
is_looted = conditem2->is_looted; is_looted = conditem2->is_looted;
break; break;
@ -718,7 +720,7 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem **qite
} }
} }
if(is_looted) if (is_looted)
return NULL; return NULL;
return item; return item;
@ -750,7 +752,7 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv)
return b; // nothing output more return b; // nothing output more
} }
Loot &l = lv.loot; Loot& l = lv.loot;
uint8 itemsShown = 0; uint8 itemsShown = 0;
@ -779,10 +781,10 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv)
QuestItemMap::const_iterator nn_itr = lootPlayerNonQuestNonFFAConditionalItems.find(lv.viewer->GetGUIDLow()); QuestItemMap::const_iterator nn_itr = lootPlayerNonQuestNonFFAConditionalItems.find(lv.viewer->GetGUIDLow());
if (nn_itr != lootPlayerNonQuestNonFFAConditionalItems.end()) if (nn_itr != lootPlayerNonQuestNonFFAConditionalItems.end())
{ {
QuestItemList *conditional_list = nn_itr->second; QuestItemList* conditional_list = nn_itr->second;
for (QuestItemList::const_iterator ci = conditional_list->begin() ; ci != conditional_list->end(); ++ci) for (QuestItemList::const_iterator ci = conditional_list->begin() ; ci != conditional_list->end(); ++ci)
{ {
LootItem &item = l.items[ci->index]; LootItem& item = l.items[ci->index];
LootSlotType slot_type = item.GetSlotTypeForSharedLoot(lv.permission, lv.viewer, !ci->is_looted); LootSlotType slot_type = item.GetSlotTypeForSharedLoot(lv.permission, lv.viewer, !ci->is_looted);
if (slot_type >= MAX_LOOT_SLOT_TYPE) if (slot_type >= MAX_LOOT_SLOT_TYPE)
@ -801,10 +803,10 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv)
QuestItemMap::const_iterator q_itr = lootPlayerQuestItems.find(lv.viewer->GetGUIDLow()); QuestItemMap::const_iterator q_itr = lootPlayerQuestItems.find(lv.viewer->GetGUIDLow());
if (q_itr != lootPlayerQuestItems.end()) if (q_itr != lootPlayerQuestItems.end())
{ {
QuestItemList *q_list = q_itr->second; QuestItemList* q_list = q_itr->second;
for (QuestItemList::const_iterator qi = q_list->begin() ; qi != q_list->end(); ++qi) for (QuestItemList::const_iterator qi = q_list->begin() ; qi != q_list->end(); ++qi)
{ {
LootItem &item = l.m_questItems[qi->index]; LootItem& item = l.m_questItems[qi->index];
if (!qi->is_looted && !item.is_looted) if (!qi->is_looted && !item.is_looted)
{ {
b << uint8(l.items.size() + (qi - q_list->begin())); b << uint8(l.items.size() + (qi - q_list->begin()));
@ -819,10 +821,10 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv)
QuestItemMap::const_iterator ffa_itr = lootPlayerFFAItems.find(lv.viewer->GetGUIDLow()); QuestItemMap::const_iterator ffa_itr = lootPlayerFFAItems.find(lv.viewer->GetGUIDLow());
if (ffa_itr != lootPlayerFFAItems.end()) if (ffa_itr != lootPlayerFFAItems.end())
{ {
QuestItemList *ffa_list = ffa_itr->second; QuestItemList* ffa_list = ffa_itr->second;
for (QuestItemList::const_iterator fi = ffa_list->begin() ; fi != ffa_list->end(); ++fi) for (QuestItemList::const_iterator fi = ffa_list->begin() ; fi != ffa_list->end(); ++fi)
{ {
LootItem &item = l.items[fi->index]; LootItem& item = l.items[fi->index];
if (!fi->is_looted && !item.is_looted) if (!fi->is_looted && !item.is_looted)
{ {
b << uint8(fi->index) << item; b << uint8(fi->index) << item;
@ -852,7 +854,7 @@ void LootTemplate::LootGroup::AddEntry(LootStoreItem& item)
} }
// Rolls an item from the group, returns NULL if all miss their chances // Rolls an item from the group, returns NULL if all miss their chances
LootStoreItem const * LootTemplate::LootGroup::Roll() const LootStoreItem const* LootTemplate::LootGroup::Roll() const
{ {
if (!ExplicitlyChanced.empty()) // First explicitly chanced entries are checked if (!ExplicitlyChanced.empty()) // First explicitly chanced entries are checked
{ {
@ -860,7 +862,7 @@ LootStoreItem const * LootTemplate::LootGroup::Roll() const
for (uint32 i=0; i<ExplicitlyChanced.size(); ++i) //check each explicitly chanced entry in the template and modify its chance based on quality. for (uint32 i=0; i<ExplicitlyChanced.size(); ++i) //check each explicitly chanced entry in the template and modify its chance based on quality.
{ {
if(ExplicitlyChanced[i].chance>=100.0f) if (ExplicitlyChanced[i].chance>=100.0f)
return &ExplicitlyChanced[i]; return &ExplicitlyChanced[i];
Roll -= ExplicitlyChanced[i].chance; Roll -= ExplicitlyChanced[i].chance;
@ -887,7 +889,7 @@ bool LootTemplate::LootGroup::HasQuestDrop() const
} }
// True if group includes at least 1 quest drop entry for active quests of the player // True if group includes at least 1 quest drop entry for active quests of the player
bool LootTemplate::LootGroup::HasQuestDropForPlayer(Player const * player) const bool LootTemplate::LootGroup::HasQuestDropForPlayer(Player const* player) const
{ {
for (LootStoreItemList::const_iterator i=ExplicitlyChanced.begin(); i != ExplicitlyChanced.end(); ++i) for (LootStoreItemList::const_iterator i=ExplicitlyChanced.begin(); i != ExplicitlyChanced.end(); ++i)
if (player->HasQuestForItem(i->itemid)) if (player->HasQuestForItem(i->itemid))
@ -901,7 +903,7 @@ bool LootTemplate::LootGroup::HasQuestDropForPlayer(Player const * player) const
// Rolls an item from the group (if any takes its chance) and adds the item to the loot // Rolls an item from the group (if any takes its chance) and adds the item to the loot
void LootTemplate::LootGroup::Process(Loot& loot) const void LootTemplate::LootGroup::Process(Loot& loot) const
{ {
LootStoreItem const * item = Roll(); LootStoreItem const* item = Roll();
if (item != NULL) if (item != NULL)
loot.AddItem(*item); loot.AddItem(*item);
} }
@ -912,7 +914,7 @@ float LootTemplate::LootGroup::RawTotalChance() const
float result = 0; float result = 0;
for (LootStoreItemList::const_iterator i=ExplicitlyChanced.begin(); i != ExplicitlyChanced.end(); ++i) for (LootStoreItemList::const_iterator i=ExplicitlyChanced.begin(); i != ExplicitlyChanced.end(); ++i)
if ( !i->needs_quest ) if (!i->needs_quest)
result += i->chance; result += i->chance;
return result; return result;
@ -937,7 +939,7 @@ void LootTemplate::LootGroup::Verify(LootStore const& lootstore, uint32 id, uint
sLog.outErrorDb("Table '%s' entry %u group %d has total chance > 100%% (%f)", lootstore.GetName(), id, group_id, chance); sLog.outErrorDb("Table '%s' entry %u group %d has total chance > 100%% (%f)", lootstore.GetName(), id, group_id, chance);
} }
if(chance >= 100.0f && !EqualChanced.empty()) if (chance >= 100.0f && !EqualChanced.empty())
{ {
sLog.outErrorDb("Table '%s' entry %u group %d has items with chance=0%% but group total chance >= 100%% (%f)", lootstore.GetName(), id, group_id, chance); sLog.outErrorDb("Table '%s' entry %u group %d has items with chance=0%% but group total chance >= 100%% (%f)", lootstore.GetName(), id, group_id, chance);
} }
@ -947,22 +949,22 @@ void LootTemplate::LootGroup::CheckLootRefs(LootIdSet* ref_set) const
{ {
for (LootStoreItemList::const_iterator ieItr=ExplicitlyChanced.begin(); ieItr != ExplicitlyChanced.end(); ++ieItr) for (LootStoreItemList::const_iterator ieItr=ExplicitlyChanced.begin(); ieItr != ExplicitlyChanced.end(); ++ieItr)
{ {
if(ieItr->mincountOrRef < 0) if (ieItr->mincountOrRef < 0)
{ {
if(!LootTemplates_Reference.GetLootFor(-ieItr->mincountOrRef)) if (!LootTemplates_Reference.GetLootFor(-ieItr->mincountOrRef))
LootTemplates_Reference.ReportNotExistedId(-ieItr->mincountOrRef); LootTemplates_Reference.ReportNotExistedId(-ieItr->mincountOrRef);
else if(ref_set) else if (ref_set)
ref_set->erase(-ieItr->mincountOrRef); ref_set->erase(-ieItr->mincountOrRef);
} }
} }
for (LootStoreItemList::const_iterator ieItr=EqualChanced.begin(); ieItr != EqualChanced.end(); ++ieItr) for (LootStoreItemList::const_iterator ieItr=EqualChanced.begin(); ieItr != EqualChanced.end(); ++ieItr)
{ {
if(ieItr->mincountOrRef < 0) if (ieItr->mincountOrRef < 0)
{ {
if(!LootTemplates_Reference.GetLootFor(-ieItr->mincountOrRef)) if (!LootTemplates_Reference.GetLootFor(-ieItr->mincountOrRef))
LootTemplates_Reference.ReportNotExistedId(-ieItr->mincountOrRef); LootTemplates_Reference.ReportNotExistedId(-ieItr->mincountOrRef);
else if(ref_set) else if (ref_set)
ref_set->erase(-ieItr->mincountOrRef); ref_set->erase(-ieItr->mincountOrRef);
} }
} }
@ -998,7 +1000,7 @@ void LootTemplate::Process(Loot& loot, LootStore const& store, bool rate, uint8
} }
// Rolling non-grouped items // Rolling non-grouped items
for (LootStoreItemList::const_iterator i = Entries.begin() ; i != Entries.end() ; ++i ) for (LootStoreItemList::const_iterator i = Entries.begin() ; i != Entries.end() ; ++i)
{ {
if (!i->Roll(rate)) if (!i->Roll(rate))
continue; // Bad luck for the entry continue; // Bad luck for the entry
@ -1007,10 +1009,10 @@ void LootTemplate::Process(Loot& loot, LootStore const& store, bool rate, uint8
{ {
LootTemplate const* Referenced = LootTemplates_Reference.GetLootFor(-i->mincountOrRef); LootTemplate const* Referenced = LootTemplates_Reference.GetLootFor(-i->mincountOrRef);
if(!Referenced) if (!Referenced)
continue; // Error message already printed at loading stage continue; // Error message already printed at loading stage
for (uint32 loop=0; loop < i->maxcount; ++loop )// Ref multiplicator for (uint32 loop=0; loop < i->maxcount; ++loop) // Ref multiplicator
Referenced->Process(loot, store, rate, i->group); Referenced->Process(loot, store, rate, i->group);
} }
else // Plain entries (not a reference, not grouped) else // Plain entries (not a reference, not grouped)
@ -1018,7 +1020,7 @@ void LootTemplate::Process(Loot& loot, LootStore const& store, bool rate, uint8
} }
// Now processing groups // Now processing groups
for (LootGroups::const_iterator i = Groups.begin( ) ; i != Groups.end( ) ; ++i ) for (LootGroups::const_iterator i = Groups.begin() ; i != Groups.end() ; ++i)
i->Process(loot); i->Process(loot);
} }
@ -1032,22 +1034,22 @@ bool LootTemplate::HasQuestDrop(LootTemplateMap const& store, uint8 groupId) con
return Groups[groupId-1].HasQuestDrop(); return Groups[groupId-1].HasQuestDrop();
} }
for (LootStoreItemList::const_iterator i = Entries.begin(); i != Entries.end(); ++i ) for (LootStoreItemList::const_iterator i = Entries.begin(); i != Entries.end(); ++i)
{ {
if (i->mincountOrRef < 0) // References if (i->mincountOrRef < 0) // References
{ {
LootTemplateMap::const_iterator Referenced = store.find(-i->mincountOrRef); LootTemplateMap::const_iterator Referenced = store.find(-i->mincountOrRef);
if( Referenced ==store.end() ) if (Referenced ==store.end())
continue; // Error message [should be] already printed at loading stage continue; // Error message [should be] already printed at loading stage
if (Referenced->second->HasQuestDrop(store, i->group) ) if (Referenced->second->HasQuestDrop(store, i->group))
return true; return true;
} }
else if ( i->needs_quest ) else if (i->needs_quest)
return true; // quest drop found return true; // quest drop found
} }
// Now processing groups // Now processing groups
for (LootGroups::const_iterator i = Groups.begin() ; i != Groups.end() ; ++i ) for (LootGroups::const_iterator i = Groups.begin() ; i != Groups.end() ; ++i)
if (i->HasQuestDrop()) if (i->HasQuestDrop())
return true; return true;
@ -1065,22 +1067,22 @@ bool LootTemplate::HasQuestDropForPlayer(LootTemplateMap const& store, Player co
} }
// Checking non-grouped entries // Checking non-grouped entries
for (LootStoreItemList::const_iterator i = Entries.begin() ; i != Entries.end() ; ++i ) for (LootStoreItemList::const_iterator i = Entries.begin() ; i != Entries.end() ; ++i)
{ {
if (i->mincountOrRef < 0) // References processing if (i->mincountOrRef < 0) // References processing
{ {
LootTemplateMap::const_iterator Referenced = store.find(-i->mincountOrRef); LootTemplateMap::const_iterator Referenced = store.find(-i->mincountOrRef);
if (Referenced == store.end() ) if (Referenced == store.end())
continue; // Error message already printed at loading stage continue; // Error message already printed at loading stage
if (Referenced->second->HasQuestDropForPlayer(store, player, i->group) ) if (Referenced->second->HasQuestDropForPlayer(store, player, i->group))
return true; return true;
} }
else if ( player->HasQuestForItem(i->itemid) ) else if (player->HasQuestForItem(i->itemid))
return true; // active quest drop found return true; // active quest drop found
} }
// Now checking groups // Now checking groups
for (LootGroups::const_iterator i = Groups.begin(); i != Groups.end(); ++i ) for (LootGroups::const_iterator i = Groups.begin(); i != Groups.end(); ++i)
if (i->HasQuestDropForPlayer(player)) if (i->HasQuestDropForPlayer(player))
return true; return true;
@ -1099,18 +1101,18 @@ void LootTemplate::Verify(LootStore const& lootstore, uint32 id) const
void LootTemplate::CheckLootRefs(LootIdSet* ref_set) const void LootTemplate::CheckLootRefs(LootIdSet* ref_set) const
{ {
for(LootStoreItemList::const_iterator ieItr = Entries.begin(); ieItr != Entries.end(); ++ieItr) for (LootStoreItemList::const_iterator ieItr = Entries.begin(); ieItr != Entries.end(); ++ieItr)
{ {
if(ieItr->mincountOrRef < 0) if (ieItr->mincountOrRef < 0)
{ {
if(!LootTemplates_Reference.GetLootFor(-ieItr->mincountOrRef)) if (!LootTemplates_Reference.GetLootFor(-ieItr->mincountOrRef))
LootTemplates_Reference.ReportNotExistedId(-ieItr->mincountOrRef); LootTemplates_Reference.ReportNotExistedId(-ieItr->mincountOrRef);
else if(ref_set) else if (ref_set)
ref_set->erase(-ieItr->mincountOrRef); ref_set->erase(-ieItr->mincountOrRef);
} }
} }
for(LootGroups::const_iterator grItr = Groups.begin(); grItr != Groups.end(); ++grItr) for (LootGroups::const_iterator grItr = Groups.begin(); grItr != Groups.end(); ++grItr)
grItr->CheckLootRefs(ref_set); grItr->CheckLootRefs(ref_set);
} }
@ -1120,11 +1122,11 @@ void LoadLootTemplates_Creature()
LootTemplates_Creature.LoadAndCollectLootIds(ids_set); LootTemplates_Creature.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot // remove real entries and check existence loot
for(uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i ) for (uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i)
{ {
if(CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i)) if (CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i))
{ {
if(uint32 lootid = cInfo->lootid) if (uint32 lootid = cInfo->lootid)
{ {
if (ids_set.find(lootid) == ids_set.end()) if (ids_set.find(lootid) == ids_set.end())
LootTemplates_Creature.ReportNotExistedId(lootid); LootTemplates_Creature.ReportNotExistedId(lootid);
@ -1133,7 +1135,7 @@ void LoadLootTemplates_Creature()
} }
} }
} }
for(LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr) for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr)
ids_set.erase(*itr); ids_set.erase(*itr);
// for alterac valley we've defined Player-loot inside creature_loot_template id=0 // for alterac valley we've defined Player-loot inside creature_loot_template id=0
@ -1150,11 +1152,11 @@ void LoadLootTemplates_Disenchant()
LootTemplates_Disenchant.LoadAndCollectLootIds(ids_set); LootTemplates_Disenchant.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot // remove real entries and check existence loot
for(uint32 i = 1; i < sItemStorage.MaxEntry; ++i ) for (uint32 i = 1; i < sItemStorage.MaxEntry; ++i)
{ {
if(ItemPrototype const* proto = sItemStorage.LookupEntry<ItemPrototype>(i)) if (ItemPrototype const* proto = sItemStorage.LookupEntry<ItemPrototype>(i))
{ {
if(uint32 lootid = proto->DisenchantID) if (uint32 lootid = proto->DisenchantID)
{ {
if (ids_set.find(lootid) == ids_set.end()) if (ids_set.find(lootid) == ids_set.end())
LootTemplates_Disenchant.ReportNotExistedId(lootid); LootTemplates_Disenchant.ReportNotExistedId(lootid);
@ -1163,7 +1165,7 @@ void LoadLootTemplates_Disenchant()
} }
} }
} }
for(LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr) for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr)
ids_set.erase(*itr); ids_set.erase(*itr);
// output error for any still listed (not referenced from appropriate table) ids // output error for any still listed (not referenced from appropriate table) ids
LootTemplates_Disenchant.ReportUnusedIds(ids_set); LootTemplates_Disenchant.ReportUnusedIds(ids_set);
@ -1175,9 +1177,9 @@ void LoadLootTemplates_Fishing()
LootTemplates_Fishing.LoadAndCollectLootIds(ids_set); LootTemplates_Fishing.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot // remove real entries and check existence loot
for(uint32 i = 1; i < sAreaStore.GetNumRows(); ++i ) for (uint32 i = 1; i < sAreaStore.GetNumRows(); ++i)
{ {
if(AreaTableEntry const* areaEntry = sAreaStore.LookupEntry(i)) if (AreaTableEntry const* areaEntry = sAreaStore.LookupEntry(i))
if (ids_set.find(areaEntry->ID) != ids_set.end()) if (ids_set.find(areaEntry->ID) != ids_set.end())
ids_set.erase(areaEntry->ID); ids_set.erase(areaEntry->ID);
} }
@ -1195,11 +1197,11 @@ void LoadLootTemplates_Gameobject()
LootTemplates_Gameobject.LoadAndCollectLootIds(ids_set); LootTemplates_Gameobject.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot // remove real entries and check existence loot
for(uint32 i = 1; i < sGOStorage.MaxEntry; ++i ) for (uint32 i = 1; i < sGOStorage.MaxEntry; ++i)
{ {
if(GameObjectInfo const* gInfo = sGOStorage.LookupEntry<GameObjectInfo>(i)) if (GameObjectInfo const* gInfo = sGOStorage.LookupEntry<GameObjectInfo>(i))
{ {
if(uint32 lootid = gInfo->GetLootId()) if (uint32 lootid = gInfo->GetLootId())
{ {
if (ids_set.find(lootid) == ids_set.end()) if (ids_set.find(lootid) == ids_set.end())
LootTemplates_Gameobject.ReportNotExistedId(lootid); LootTemplates_Gameobject.ReportNotExistedId(lootid);
@ -1208,7 +1210,7 @@ void LoadLootTemplates_Gameobject()
} }
} }
} }
for(LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr) for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr)
ids_set.erase(*itr); ids_set.erase(*itr);
// output error for any still listed (not referenced from appropriate table) ids // output error for any still listed (not referenced from appropriate table) ids
@ -1221,11 +1223,11 @@ void LoadLootTemplates_Item()
LootTemplates_Item.LoadAndCollectLootIds(ids_set); LootTemplates_Item.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot // remove real entries and check existence loot
for(uint32 i = 1; i < sItemStorage.MaxEntry; ++i ) for (uint32 i = 1; i < sItemStorage.MaxEntry; ++i)
{ {
if(ItemPrototype const* proto = sItemStorage.LookupEntry<ItemPrototype>(i)) if (ItemPrototype const* proto = sItemStorage.LookupEntry<ItemPrototype>(i))
{ {
if (!(proto->Flags & ITEM_FLAG_LOOTABLE)) if (!(proto->Flags & ITEM_FLAG_LOOTABLE))
continue; continue;
if (ids_set.find(proto->ItemId) != ids_set.end() || proto->MaxMoneyLoot > 0) if (ids_set.find(proto->ItemId) != ids_set.end() || proto->MaxMoneyLoot > 0)
@ -1246,10 +1248,10 @@ void LoadLootTemplates_Milling()
LootTemplates_Milling.LoadAndCollectLootIds(ids_set); LootTemplates_Milling.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot // remove real entries and check existence loot
for(uint32 i = 1; i < sItemStorage.MaxEntry; ++i ) for (uint32 i = 1; i < sItemStorage.MaxEntry; ++i)
{ {
ItemPrototype const* proto = sItemStorage.LookupEntry<ItemPrototype>(i); ItemPrototype const* proto = sItemStorage.LookupEntry<ItemPrototype>(i);
if(!proto) if (!proto)
continue; continue;
if (!(proto->Flags & ITEM_FLAG_MILLABLE)) if (!(proto->Flags & ITEM_FLAG_MILLABLE))
@ -1271,11 +1273,11 @@ void LoadLootTemplates_Pickpocketing()
LootTemplates_Pickpocketing.LoadAndCollectLootIds(ids_set); LootTemplates_Pickpocketing.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot // remove real entries and check existence loot
for(uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i ) for (uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i)
{ {
if(CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i)) if (CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i))
{ {
if(uint32 lootid = cInfo->pickpocketLootId) if (uint32 lootid = cInfo->pickpocketLootId)
{ {
if (ids_set.find(lootid) == ids_set.end()) if (ids_set.find(lootid) == ids_set.end())
LootTemplates_Pickpocketing.ReportNotExistedId(lootid); LootTemplates_Pickpocketing.ReportNotExistedId(lootid);
@ -1284,7 +1286,7 @@ void LoadLootTemplates_Pickpocketing()
} }
} }
} }
for(LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr) for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr)
ids_set.erase(*itr); ids_set.erase(*itr);
// output error for any still listed (not referenced from appropriate table) ids // output error for any still listed (not referenced from appropriate table) ids
@ -1297,7 +1299,7 @@ void LoadLootTemplates_Prospecting()
LootTemplates_Prospecting.LoadAndCollectLootIds(ids_set); LootTemplates_Prospecting.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot // remove real entries and check existence loot
for(uint32 i = 1; i < sItemStorage.MaxEntry; ++i ) for (uint32 i = 1; i < sItemStorage.MaxEntry; ++i)
{ {
ItemPrototype const* proto = sItemStorage.LookupEntry<ItemPrototype>(i); ItemPrototype const* proto = sItemStorage.LookupEntry<ItemPrototype>(i);
if (!proto) if (!proto)
@ -1322,8 +1324,8 @@ void LoadLootTemplates_Mail()
LootTemplates_Mail.LoadAndCollectLootIds(ids_set); LootTemplates_Mail.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot // remove real entries and check existence loot
for(uint32 i = 1; i < sMailTemplateStore.GetNumRows(); ++i ) for (uint32 i = 1; i < sMailTemplateStore.GetNumRows(); ++i)
if(sMailTemplateStore.LookupEntry(i)) if (sMailTemplateStore.LookupEntry(i))
if (ids_set.find(i) != ids_set.end()) if (ids_set.find(i) != ids_set.end())
ids_set.erase(i); ids_set.erase(i);
@ -1337,11 +1339,11 @@ void LoadLootTemplates_Skinning()
LootTemplates_Skinning.LoadAndCollectLootIds(ids_set); LootTemplates_Skinning.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot // remove real entries and check existence loot
for(uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i ) for (uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i)
{ {
if(CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i)) if (CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i))
{ {
if(uint32 lootid = cInfo->SkinLootId) if (uint32 lootid = cInfo->SkinLootId)
{ {
if (ids_set.find(lootid) == ids_set.end()) if (ids_set.find(lootid) == ids_set.end())
LootTemplates_Skinning.ReportNotExistedId(lootid); LootTemplates_Skinning.ReportNotExistedId(lootid);
@ -1350,7 +1352,7 @@ void LoadLootTemplates_Skinning()
} }
} }
} }
for(LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr) for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr)
ids_set.erase(*itr); ids_set.erase(*itr);
// output error for any still listed (not referenced from appropriate table) ids // output error for any still listed (not referenced from appropriate table) ids
@ -1363,14 +1365,14 @@ void LoadLootTemplates_Spell()
LootTemplates_Spell.LoadAndCollectLootIds(ids_set); LootTemplates_Spell.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot // remove real entries and check existence loot
for(uint32 spell_id = 1; spell_id < sSpellStore.GetNumRows(); ++spell_id) for (uint32 spell_id = 1; spell_id < sSpellStore.GetNumRows(); ++spell_id)
{ {
SpellEntry const* spellInfo = sSpellStore.LookupEntry (spell_id); SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell_id);
if(!spellInfo) if (!spellInfo)
continue; continue;
// possible cases // possible cases
if( !IsLootCraftingSpell(spellInfo)) if (!IsLootCraftingSpell(spellInfo))
continue; continue;
if (ids_set.find(spell_id) == ids_set.end()) if (ids_set.find(spell_id) == ids_set.end())

View file

@ -47,7 +47,7 @@ enum LootType
LOOT_PICKPOCKETING = 2, LOOT_PICKPOCKETING = 2,
LOOT_FISHING = 3, LOOT_FISHING = 3,
LOOT_DISENCHANTING = 4, LOOT_DISENCHANTING = 4,
// ignored always by client // ignored always by client
LOOT_SKINNING = 6, LOOT_SKINNING = 6,
LOOT_PROSPECTING = 7, LOOT_PROSPECTING = 7,
LOOT_MILLING = 8, LOOT_MILLING = 8,
@ -86,12 +86,12 @@ struct LootStoreItem
// displayid is filled in IsValid() which must be called after // displayid is filled in IsValid() which must be called after
LootStoreItem(uint32 _itemid, float _chanceOrQuestChance, int8 _group, uint16 _conditionId, int32 _mincountOrRef, uint8 _maxcount) LootStoreItem(uint32 _itemid, float _chanceOrQuestChance, int8 _group, uint16 _conditionId, int32 _mincountOrRef, uint8 _maxcount)
: itemid(_itemid), chance(fabs(_chanceOrQuestChance)), mincountOrRef(_mincountOrRef), : itemid(_itemid), chance(fabs(_chanceOrQuestChance)), mincountOrRef(_mincountOrRef),
group(_group), needs_quest(_chanceOrQuestChance < 0), maxcount(_maxcount), conditionId(_conditionId) group(_group), needs_quest(_chanceOrQuestChance < 0), maxcount(_maxcount), conditionId(_conditionId)
{} {}
bool Roll(bool rate) const; // Checks if the entry takes it's chance (at loot generation) bool Roll(bool rate) const; // Checks if the entry takes it's chance (at loot generation)
bool IsValid(LootStore const& store, uint32 entry) const; bool IsValid(LootStore const& store, uint32 entry) const;
// Checks correctness of values // Checks correctness of values
}; };
struct LootItem struct LootItem
@ -115,7 +115,7 @@ struct LootItem
LootItem(uint32 itemid_, uint32 count_, uint32 randomSuffix_ = 0, int32 randomPropertyId_ = 0); LootItem(uint32 itemid_, uint32 count_, uint32 randomSuffix_ = 0, int32 randomPropertyId_ = 0);
// Basic checks for player/item compatibility - if false no chance to see the item in the loot // Basic checks for player/item compatibility - if false no chance to see the item in the loot
bool AllowedForPlayer(Player const * player) const; bool AllowedForPlayer(Player const* player) const;
LootSlotType GetSlotTypeForSharedLoot(PermissionTypes permission, Player* viewer, bool condition_ok = false) const; LootSlotType GetSlotTypeForSharedLoot(PermissionTypes permission, Player* viewer, bool condition_ok = false) const;
}; };
@ -137,7 +137,7 @@ struct Loot;
class LootTemplate; class LootTemplate;
typedef std::vector<QuestItem> QuestItemList; typedef std::vector<QuestItem> QuestItemList;
typedef std::map<uint32, QuestItemList *> QuestItemMap; typedef std::map<uint32, QuestItemList*> QuestItemMap;
typedef std::vector<LootStoreItem> LootStoreItemList; typedef std::vector<LootStoreItem> LootStoreItemList;
typedef UNORDERED_MAP<uint32, LootTemplate*> LootTemplateMap; typedef UNORDERED_MAP<uint32, LootTemplate*> LootTemplateMap;
@ -178,8 +178,8 @@ class LootStore
class LootTemplate class LootTemplate
{ {
class LootGroup; // A set of loot definitions for items (refs are not allowed inside) class LootGroup; // A set of loot definitions for items (refs are not allowed inside)
typedef std::vector<LootGroup> LootGroups; typedef std::vector<LootGroup> LootGroups;
public: public:
// Adds an entry to the group (at loading stage) // Adds an entry to the group (at loading stage)
@ -190,7 +190,7 @@ class LootTemplate
// True if template includes at least 1 quest drop entry // True if template includes at least 1 quest drop entry
bool HasQuestDrop(LootTemplateMap const& store, uint8 GroupId = 0) const; bool HasQuestDrop(LootTemplateMap const& store, uint8 GroupId = 0) const;
// True if template includes at least 1 quest drop for an active quest of the player // True if template includes at least 1 quest drop for an active quest of the player
bool HasQuestDropForPlayer(LootTemplateMap const& store, Player const * player, uint8 GroupId = 0) const; bool HasQuestDropForPlayer(LootTemplateMap const& store, Player const* player, uint8 GroupId = 0) const;
// Checks integrity of the template // Checks integrity of the template
void Verify(LootStore const& store, uint32 Id) const; void Verify(LootStore const& store, uint32 Id) const;
@ -234,66 +234,66 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv);
struct Loot struct Loot
{ {
friend ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv); friend ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv);
QuestItemMap const& GetPlayerQuestItems() const { return m_playerQuestItems; } QuestItemMap const& GetPlayerQuestItems() const { return m_playerQuestItems; }
QuestItemMap const& GetPlayerFFAItems() const { return m_playerFFAItems; } QuestItemMap const& GetPlayerFFAItems() const { return m_playerFFAItems; }
QuestItemMap const& GetPlayerNonQuestNonFFAConditionalItems() const { return m_playerNonQuestNonFFAConditionalItems; } QuestItemMap const& GetPlayerNonQuestNonFFAConditionalItems() const { return m_playerNonQuestNonFFAConditionalItems; }
LootItemList items; LootItemList items;
uint32 gold; uint32 gold;
uint8 unlootedCount; uint8 unlootedCount;
LootType loot_type; // required for achievement system LootType loot_type; // required for achievement system
Loot(uint32 _gold = 0) : gold(_gold), unlootedCount(0), loot_type(LOOT_CORPSE) {} Loot(uint32 _gold = 0) : gold(_gold), unlootedCount(0), loot_type(LOOT_CORPSE) {}
~Loot() { clear(); } ~Loot() { clear(); }
// if loot becomes invalid this reference is used to inform the listener // if loot becomes invalid this reference is used to inform the listener
void addLootValidatorRef(LootValidatorRef* pLootValidatorRef) void addLootValidatorRef(LootValidatorRef* pLootValidatorRef)
{ {
m_LootValidatorRefManager.insertFirst(pLootValidatorRef); m_LootValidatorRefManager.insertFirst(pLootValidatorRef);
} }
// void clear(); // void clear();
void clear() void clear()
{ {
for (QuestItemMap::const_iterator itr = m_playerQuestItems.begin(); itr != m_playerQuestItems.end(); ++itr) for (QuestItemMap::const_iterator itr = m_playerQuestItems.begin(); itr != m_playerQuestItems.end(); ++itr)
delete itr->second; delete itr->second;
m_playerQuestItems.clear(); m_playerQuestItems.clear();
for (QuestItemMap::const_iterator itr = m_playerFFAItems.begin(); itr != m_playerFFAItems.end(); ++itr) for (QuestItemMap::const_iterator itr = m_playerFFAItems.begin(); itr != m_playerFFAItems.end(); ++itr)
delete itr->second; delete itr->second;
m_playerFFAItems.clear(); m_playerFFAItems.clear();
for (QuestItemMap::const_iterator itr = m_playerNonQuestNonFFAConditionalItems.begin(); itr != m_playerNonQuestNonFFAConditionalItems.end(); ++itr) for (QuestItemMap::const_iterator itr = m_playerNonQuestNonFFAConditionalItems.begin(); itr != m_playerNonQuestNonFFAConditionalItems.end(); ++itr)
delete itr->second; delete itr->second;
m_playerNonQuestNonFFAConditionalItems.clear(); m_playerNonQuestNonFFAConditionalItems.clear();
m_playersLooting.clear(); m_playersLooting.clear();
items.clear(); items.clear();
m_questItems.clear(); m_questItems.clear();
gold = 0; gold = 0;
unlootedCount = 0; unlootedCount = 0;
m_LootValidatorRefManager.clearReferences(); m_LootValidatorRefManager.clearReferences();
} }
bool empty() const { return items.empty() && gold == 0; } bool empty() const { return items.empty() && gold == 0; }
bool isLooted() const { return gold == 0 && unlootedCount == 0; } bool isLooted() const { return gold == 0 && unlootedCount == 0; }
void NotifyItemRemoved(uint8 lootIndex); void NotifyItemRemoved(uint8 lootIndex);
void NotifyQuestItemRemoved(uint8 questIndex); void NotifyQuestItemRemoved(uint8 questIndex);
void NotifyMoneyRemoved(); void NotifyMoneyRemoved();
void AddLooter(ObjectGuid guid) { m_playersLooting.insert(guid); } void AddLooter(ObjectGuid guid) { m_playersLooting.insert(guid); }
void RemoveLooter(ObjectGuid guid) { m_playersLooting.erase(guid); } void RemoveLooter(ObjectGuid guid) { m_playersLooting.erase(guid); }
void generateMoneyLoot(uint32 minAmount, uint32 maxAmount); void generateMoneyLoot(uint32 minAmount, uint32 maxAmount);
bool FillLoot(uint32 loot_id, LootStore const& store, Player* loot_owner, bool personal, bool noEmptyError = false); bool FillLoot(uint32 loot_id, LootStore const& store, Player* loot_owner, bool personal, bool noEmptyError = false);
// Inserts the item into the loot (called by LootTemplate processors) // Inserts the item into the loot (called by LootTemplate processors)
void AddItem(LootStoreItem const & item); void AddItem(LootStoreItem const& item);
LootItem* LootItemInSlot(uint32 lootslot, Player* player, QuestItem** qitem = NULL, QuestItem** ffaitem = NULL, QuestItem** conditem = NULL); LootItem* LootItemInSlot(uint32 lootslot, Player* player, QuestItem** qitem = NULL, QuestItem** ffaitem = NULL, QuestItem** conditem = NULL);
uint32 GetMaxSlotInLootFor(Player* player) const; uint32 GetMaxSlotInLootFor(Player* player) const;
private: private:
void FillNotNormalLootFor(Player* player); void FillNotNormalLootFor(Player* player);
@ -315,10 +315,10 @@ struct Loot
struct LootView struct LootView
{ {
Loot &loot; Loot& loot;
Player *viewer; Player* viewer;
PermissionTypes permission; PermissionTypes permission;
LootView(Loot &_loot, Player *_viewer,PermissionTypes _permission = ALL_PERMISSION) LootView(Loot& _loot, Player* _viewer,PermissionTypes _permission = ALL_PERMISSION)
: loot(_loot), viewer(_viewer), permission(_permission) {} : loot(_loot), viewer(_viewer), permission(_permission) {}
}; };

View file

@ -39,9 +39,9 @@
* @param sender The object/player sending this mail. * @param sender The object/player sending this mail.
* @param stationery The stationary associated with this sender. * @param stationery The stationary associated with this sender.
*/ */
MailSender::MailSender( Object* sender, MailStationery stationery ) : m_stationery(stationery) MailSender::MailSender(Object* sender, MailStationery stationery) : m_stationery(stationery)
{ {
switch(sender->GetTypeId()) switch (sender->GetTypeId())
{ {
case TYPEID_UNIT: case TYPEID_UNIT:
m_messageType = MAIL_CREATURE; m_messageType = MAIL_CREATURE;
@ -63,7 +63,7 @@ MailSender::MailSender( Object* sender, MailStationery stationery ) : m_statione
default: default:
m_messageType = MAIL_NORMAL; m_messageType = MAIL_NORMAL;
m_senderId = 0; // will show mail from nonexistent player m_senderId = 0; // will show mail from nonexistent player
sLog.outError( "MailSender::MailSender - Mail have unexpected sender typeid (%u)", sender->GetTypeId()); sLog.outError("MailSender::MailSender - Mail have unexpected sender typeid (%u)", sender->GetTypeId());
break; break;
} }
} }
@ -72,7 +72,7 @@ MailSender::MailSender( Object* sender, MailStationery stationery ) : m_statione
* *
* @param sender the AuctionEntry from which this mail is generated. * @param sender the AuctionEntry from which this mail is generated.
*/ */
MailSender::MailSender( AuctionEntry* sender ) MailSender::MailSender(AuctionEntry* sender)
: m_messageType(MAIL_AUCTION), m_senderId(sender->GetHouseId()), m_stationery(MAIL_STATIONERY_AUCTION) : m_messageType(MAIL_AUCTION), m_senderId(sender->GetHouseId()), m_stationery(MAIL_STATIONERY_AUCTION)
{ {
} }
@ -102,7 +102,7 @@ MailReceiver::MailReceiver(Player* receiver, ObjectGuid receiver_guid) : m_recei
* @param item The item to be added to the MailDraft. * @param item The item to be added to the MailDraft.
* @returns the MailDraft the item was added to. * @returns the MailDraft the item was added to.
*/ */
MailDraft& MailDraft::AddItem( Item* item ) MailDraft& MailDraft::AddItem(Item* item)
{ {
m_items[item->GetGUIDLow()] = item; m_items[item->GetGUIDLow()] = item;
return *this; return *this;
@ -123,7 +123,7 @@ bool MailDraft::prepareItems(Player* receiver)
mailLoot.FillLoot(m_mailTemplateId, LootTemplates_Mail, receiver, true, true); mailLoot.FillLoot(m_mailTemplateId, LootTemplates_Mail, receiver, true, true);
uint32 max_slot = mailLoot.GetMaxSlotInLootFor(receiver); uint32 max_slot = mailLoot.GetMaxSlotInLootFor(receiver);
for(uint32 i = 0; m_items.size() < MAX_MAIL_ITEMS && i < max_slot; ++i) for (uint32 i = 0; m_items.size() < MAX_MAIL_ITEMS && i < max_slot; ++i)
{ {
if (LootItem* lootitem = mailLoot.LootItemInSlot(i, receiver)) if (LootItem* lootitem = mailLoot.LootItemInSlot(i, receiver))
{ {
@ -142,13 +142,13 @@ bool MailDraft::prepareItems(Player* receiver)
* *
* @param inDB A boolean specifying whether the change should be saved to the database or not. * @param inDB A boolean specifying whether the change should be saved to the database or not.
*/ */
void MailDraft::deleteIncludedItems( bool inDB /**= false*/ ) void MailDraft::deleteIncludedItems(bool inDB /**= false*/)
{ {
for(MailItemMap::iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter) for (MailItemMap::iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter)
{ {
Item* item = mailItemIter->second; Item* item = mailItemIter->second;
if(inDB) if (inDB)
CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid='%u'", item->GetGUIDLow()); CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid='%u'", item->GetGUIDLow());
delete item; delete item;
@ -171,11 +171,11 @@ void MailDraft::CloneFrom(MailDraft const& draft)
m_money = draft.GetMoney(); m_money = draft.GetMoney();
m_COD = draft.GetCOD(); m_COD = draft.GetCOD();
for(MailItemMap::const_iterator mailItemIter = draft.m_items.begin(); mailItemIter != draft.m_items.end(); ++mailItemIter) for (MailItemMap::const_iterator mailItemIter = draft.m_items.begin(); mailItemIter != draft.m_items.end(); ++mailItemIter)
{ {
Item* item = mailItemIter->second; Item* item = mailItemIter->second;
if(Item* newitem = item->CloneItem(item->GetCount())) if (Item* newitem = item->CloneItem(item->GetCount()))
{ {
newitem->SaveToDB(); newitem->SaveToDB();
AddItem(newitem); AddItem(newitem);
@ -191,7 +191,7 @@ void MailDraft::CloneFrom(MailDraft const& draft)
*/ */
void MailDraft::SendReturnToSender(uint32 sender_acc, ObjectGuid sender_guid, ObjectGuid receiver_guid) void MailDraft::SendReturnToSender(uint32 sender_acc, ObjectGuid sender_guid, ObjectGuid receiver_guid)
{ {
Player *receiver = sObjectMgr.GetPlayer(receiver_guid); Player* receiver = sObjectMgr.GetPlayer(receiver_guid);
uint32 rc_account = 0; uint32 rc_account = 0;
if (!receiver) if (!receiver)
@ -283,14 +283,14 @@ void MailDraft::SendMailTo(MailReceiver const& receiver, MailSender const& sende
CharacterDatabase.BeginTransaction(); CharacterDatabase.BeginTransaction();
CharacterDatabase.PExecute("INSERT INTO mail (id,messageType,stationery,mailTemplateId,sender,receiver,subject,body,has_items,expire_time,deliver_time,money,cod,checked) " CharacterDatabase.PExecute("INSERT INTO mail (id,messageType,stationery,mailTemplateId,sender,receiver,subject,body,has_items,expire_time,deliver_time,money,cod,checked) "
"VALUES ('%u', '%u', '%u', '%u', '%u', '%u', '%s', '%s', '%u', '" UI64FMTD "','" UI64FMTD "', '%u', '%u', '%u')", "VALUES ('%u', '%u', '%u', '%u', '%u', '%u', '%s', '%s', '%u', '" UI64FMTD "','" UI64FMTD "', '%u', '%u', '%u')",
mailId, sender.GetMailMessageType(), sender.GetStationery(), GetMailTemplateId(), sender.GetSenderId(), receiver.GetPlayerGuid().GetCounter(), safe_subject.c_str(), safe_body.c_str(), (has_items ? 1 : 0), (uint64)expire_time, (uint64)deliver_time, m_money, m_COD, checked); mailId, sender.GetMailMessageType(), sender.GetStationery(), GetMailTemplateId(), sender.GetSenderId(), receiver.GetPlayerGuid().GetCounter(), safe_subject.c_str(), safe_body.c_str(), (has_items ? 1 : 0), (uint64)expire_time, (uint64)deliver_time, m_money, m_COD, checked);
for(MailItemMap::const_iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter) for (MailItemMap::const_iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter)
{ {
Item* item = mailItemIter->second; Item* item = mailItemIter->second;
CharacterDatabase.PExecute("INSERT INTO mail_items (mail_id,item_guid,item_template,receiver) VALUES ('%u', '%u', '%u','%u')", CharacterDatabase.PExecute("INSERT INTO mail_items (mail_id,item_guid,item_template,receiver) VALUES ('%u', '%u', '%u','%u')",
mailId, item->GetGUIDLow(), item->GetEntry(), receiver.GetPlayerGuid().GetCounter()); mailId, item->GetGUIDLow(), item->GetEntry(), receiver.GetPlayerGuid().GetCounter());
} }
CharacterDatabase.CommitTransaction(); CharacterDatabase.CommitTransaction();
@ -299,7 +299,7 @@ void MailDraft::SendMailTo(MailReceiver const& receiver, MailSender const& sende
{ {
pReceiver->AddNewMailDeliverTime(deliver_time); pReceiver->AddNewMailDeliverTime(deliver_time);
Mail *m = new Mail; Mail* m = new Mail;
m->messageID = mailId; m->messageID = mailId;
m->mailTemplateId = GetMailTemplateId(); m->mailTemplateId = GetMailTemplateId();
m->subject = GetSubject(); m->subject = GetSubject();
@ -307,7 +307,7 @@ void MailDraft::SendMailTo(MailReceiver const& receiver, MailSender const& sende
m->money = GetMoney(); m->money = GetMoney();
m->COD = GetCOD(); m->COD = GetCOD();
for(MailItemMap::const_iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter) for (MailItemMap::const_iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter)
{ {
Item* item = mailItemIter->second; Item* item = mailItemIter->second;
m->AddItem(item->GetGUIDLow(), item->GetEntry()); m->AddItem(item->GetGUIDLow(), item->GetEntry());
@ -326,7 +326,7 @@ void MailDraft::SendMailTo(MailReceiver const& receiver, MailSender const& sende
if (!m_items.empty()) if (!m_items.empty())
{ {
for(MailItemMap::iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter) for (MailItemMap::iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter)
pReceiver->AddMItem(mailItemIter->second); pReceiver->AddMItem(mailItemIter->second);
} }
} }
@ -340,7 +340,7 @@ void MailDraft::SendMailTo(MailReceiver const& receiver, MailSender const& sende
* @param receiver reciver of mail * @param receiver reciver of mail
*/ */
void Mail::prepareTemplateItems( Player* receiver ) void Mail::prepareTemplateItems(Player* receiver)
{ {
if (!mailTemplateId || !items.empty()) if (!mailTemplateId || !items.empty())
return; return;
@ -356,7 +356,7 @@ void Mail::prepareTemplateItems( Player* receiver )
CharacterDatabase.PExecute("UPDATE mail SET has_items = 1 WHERE id = %u", messageID); CharacterDatabase.PExecute("UPDATE mail SET has_items = 1 WHERE id = %u", messageID);
uint32 max_slot = mailLoot.GetMaxSlotInLootFor(receiver); uint32 max_slot = mailLoot.GetMaxSlotInLootFor(receiver);
for(uint32 i = 0; items.size() < MAX_MAIL_ITEMS && i < max_slot; ++i) for (uint32 i = 0; items.size() < MAX_MAIL_ITEMS && i < max_slot; ++i)
{ {
if (LootItem* lootitem = mailLoot.LootItemInSlot(i, receiver)) if (LootItem* lootitem = mailLoot.LootItemInSlot(i, receiver))
{ {
@ -369,7 +369,7 @@ void Mail::prepareTemplateItems( Player* receiver )
receiver->AddMItem(item); receiver->AddMItem(item);
CharacterDatabase.PExecute("INSERT INTO mail_items (mail_id,item_guid,item_template,receiver) VALUES ('%u', '%u', '%u','%u')", CharacterDatabase.PExecute("INSERT INTO mail_items (mail_id,item_guid,item_template,receiver) VALUES ('%u', '%u', '%u','%u')",
messageID, item->GetGUIDLow(), item->GetEntry(), receiver->GetGUIDLow()); messageID, item->GetGUIDLow(), item->GetEntry(), receiver->GetGUIDLow());
} }
} }
} }

View file

@ -115,15 +115,15 @@ class MailSender
public: // Constructors public: // Constructors
MailSender() : m_messageType(MAIL_NORMAL), m_senderId(0), m_stationery(MAIL_STATIONERY_DEFAULT) {} MailSender() : m_messageType(MAIL_NORMAL), m_senderId(0), m_stationery(MAIL_STATIONERY_DEFAULT) {}
/** /**
* Creates a new MailSender object. * Creates a new MailSender object.
* *
* @param messageType the type of the mail. * @param messageType the type of the mail.
* @param sender_guidlow_or_entry The lower part of the GUID of the player sending * @param sender_guidlow_or_entry The lower part of the GUID of the player sending
* this mail, or the Entry of the non-player object. * this mail, or the Entry of the non-player object.
* @param stationery The stationary associated with this MailSender. * @param stationery The stationary associated with this MailSender.
* *
*/ */
MailSender(MailMessageType messageType, uint32 sender_guidlow_or_entry, MailStationery stationery = MAIL_STATIONERY_DEFAULT) MailSender(MailMessageType messageType, uint32 sender_guidlow_or_entry, MailStationery stationery = MAIL_STATIONERY_DEFAULT)
: m_messageType(messageType), m_senderId(sender_guidlow_or_entry), m_stationery(stationery) : m_messageType(messageType), m_senderId(sender_guidlow_or_entry), m_stationery(stationery)
{ {
@ -185,19 +185,19 @@ class MailDraft
typedef std::map<uint32, Item*> MailItemMap; typedef std::map<uint32, Item*> MailItemMap;
public: // Constructors public: // Constructors
/** /**
* Creates a new blank MailDraft object * Creates a new blank MailDraft object
* *
*/ */
MailDraft() MailDraft()
: m_mailTemplateId(0), m_mailTemplateItemsNeed(false), m_money(0), m_COD(0) {} : m_mailTemplateId(0), m_mailTemplateItemsNeed(false), m_money(0), m_COD(0) {}
/** /**
* Creates a new MailDraft object using mail template id. * Creates a new MailDraft object using mail template id.
* *
* @param mailTemplateId The ID of the Template to be used. * @param mailTemplateId The ID of the Template to be used.
* @param a boolean specifying whether the mail needs items or not. * @param a boolean specifying whether the mail needs items or not.
* *
*/ */
explicit MailDraft(uint16 mailTemplateId, bool need_items = true) explicit MailDraft(uint16 mailTemplateId, bool need_items = true)
: m_mailTemplateId(mailTemplateId), m_mailTemplateItemsNeed(need_items), m_money(0), m_COD(0) : m_mailTemplateId(mailTemplateId), m_mailTemplateItemsNeed(need_items), m_money(0), m_COD(0)
{} {}
@ -348,9 +348,9 @@ struct Mail
*/ */
bool RemoveItem(uint32 item_guid) bool RemoveItem(uint32 item_guid)
{ {
for(MailItemInfoVec::iterator itr = items.begin(); itr != items.end(); ++itr) for (MailItemInfoVec::iterator itr = items.begin(); itr != items.end(); ++itr)
{ {
if(itr->item_guid == item_guid) if (itr->item_guid == item_guid)
{ {
items.erase(itr); items.erase(itr);
return true; return true;

View file

@ -104,7 +104,7 @@ bool WorldSession::CheckMailBox(ObjectGuid guid)
* *
* @param recv_data the WorldPacket containing the data sent by the client. * @param recv_data the WorldPacket containing the data sent by the client.
*/ */
void WorldSession::HandleSendMail(WorldPacket & recv_data ) void WorldSession::HandleSendMail(WorldPacket& recv_data)
{ {
ObjectGuid mailboxGuid; ObjectGuid mailboxGuid;
uint64 unk3; uint64 unk3;
@ -133,7 +133,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data )
ObjectGuid itemGuids[MAX_MAIL_ITEMS]; ObjectGuid itemGuids[MAX_MAIL_ITEMS];
for(uint8 i = 0; i < items_count; ++i) for (uint8 i = 0; i < items_count; ++i)
{ {
recv_data.read_skip<uint8>(); // item slot in mail, not used recv_data.read_skip<uint8>(); // item slot in mail, not used
recv_data >> itemGuids[i]; recv_data >> itemGuids[i];
@ -160,13 +160,13 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data )
if (!rc) if (!rc)
{ {
DETAIL_LOG("%s is sending mail to %s (GUID: nonexistent!) with subject %s and body %s includes %u items, %u copper and %u COD copper with unk1 = %u, unk2 = %u", DETAIL_LOG("%s is sending mail to %s (GUID: nonexistent!) with subject %s and body %s includes %u items, %u copper and %u COD copper with unk1 = %u, unk2 = %u",
pl->GetGuidStr().c_str(), receiver.c_str(), subject.c_str(), body.c_str(), items_count, money, COD, unk1, unk2); pl->GetGuidStr().c_str(), receiver.c_str(), subject.c_str(), body.c_str(), items_count, money, COD, unk1, unk2);
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_RECIPIENT_NOT_FOUND); pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_RECIPIENT_NOT_FOUND);
return; return;
} }
DETAIL_LOG("%s is sending mail to %s with subject %s and body %s includes %u items, %u copper and %u COD copper with unk1 = %u, unk2 = %u", DETAIL_LOG("%s is sending mail to %s with subject %s and body %s includes %u items, %u copper and %u COD copper with unk1 = %u, unk2 = %u",
pl->GetGuidStr().c_str(), rc.GetString().c_str(), subject.c_str(), body.c_str(), items_count, money, COD, unk1, unk2); pl->GetGuidStr().c_str(), rc.GetString().c_str(), subject.c_str(), body.c_str(), items_count, money, COD, unk1, unk2);
if (pl->GetObjectGuid() == rc) if (pl->GetObjectGuid() == rc)
{ {
@ -184,7 +184,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data )
return; return;
} }
Player *receive = sObjectMgr.GetPlayer(rc); Player* receive = sObjectMgr.GetPlayer(rc);
Team rc_team; Team rc_team;
uint8 mails_count = 0; // do not allow to send to one player more than 100 mails uint8 mails_count = 0; // do not allow to send to one player more than 100 mails
@ -199,7 +199,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data )
rc_team = sObjectMgr.GetPlayerTeamByGUID(rc); rc_team = sObjectMgr.GetPlayerTeamByGUID(rc);
if (QueryResult* result = CharacterDatabase.PQuery("SELECT COUNT(*) FROM mail WHERE receiver = '%u'", rc.GetCounter())) if (QueryResult* result = CharacterDatabase.PQuery("SELECT COUNT(*) FROM mail WHERE receiver = '%u'", rc.GetCounter()))
{ {
Field *fields = result->Fetch(); Field* fields = result->Fetch();
mails_count = fields[0].GetUInt32(); mails_count = fields[0].GetUInt32();
delete result; delete result;
} }
@ -220,12 +220,12 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data )
} }
uint32 rc_account = receive uint32 rc_account = receive
? receive->GetSession()->GetAccountId() ? receive->GetSession()->GetAccountId()
: sObjectMgr.GetPlayerAccountIdByGUID(rc); : sObjectMgr.GetPlayerAccountIdByGUID(rc);
Item* items[MAX_MAIL_ITEMS]; Item* items[MAX_MAIL_ITEMS];
for(uint8 i = 0; i < items_count; ++i) for (uint8 i = 0; i < items_count; ++i)
{ {
if (!itemGuids[i].IsItem()) if (!itemGuids[i].IsItem())
{ {
@ -236,7 +236,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data )
Item* item = pl->GetItemByGuid(itemGuids[i]); Item* item = pl->GetItemByGuid(itemGuids[i]);
// prevent sending bag with items (cheat: can be placed in bag after adding equipped empty bag to mail) // prevent sending bag with items (cheat: can be placed in bag after adding equipped empty bag to mail)
if(!item) if (!item)
{ {
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_MAIL_ATTACHMENT_INVALID); pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_MAIL_ATTACHMENT_INVALID);
return; return;
@ -271,7 +271,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data )
pl->SendMailResult(0, MAIL_SEND, MAIL_OK); pl->SendMailResult(0, MAIL_SEND, MAIL_OK);
pl->ModifyMoney( -int32(reqmoney) ); pl->ModifyMoney(-int32(reqmoney));
pl->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_MAIL, cost); pl->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_MAIL, cost);
bool needItemDelay = false; bool needItemDelay = false;
@ -282,13 +282,13 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data )
{ {
if (items_count > 0) if (items_count > 0)
{ {
for(uint8 i = 0; i < items_count; ++i) for (uint8 i = 0; i < items_count; ++i)
{ {
Item* item = items[i]; Item* item = items[i];
if (GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE)) if (GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE))
{ {
sLog.outCommand(GetAccountId(), "GM %s (Account: %u) mail item: %s (Entry: %u Count: %u) to player: %s (Account: %u)", sLog.outCommand(GetAccountId(), "GM %s (Account: %u) mail item: %s (Entry: %u Count: %u) to player: %s (Account: %u)",
GetPlayerName(), GetAccountId(), item->GetProto()->Name1, item->GetEntry(), item->GetCount(), receiver.c_str(), rc_account); GetPlayerName(), GetAccountId(), item->GetProto()->Name1, item->GetEntry(), item->GetCount(), receiver.c_str(), rc_account);
} }
pl->MoveItemFromInventory(items[i]->GetBagSlot(), item->GetSlot(), true); pl->MoveItemFromInventory(items[i]->GetBagSlot(), item->GetSlot(), true);
@ -309,7 +309,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data )
if (money > 0 && GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE)) if (money > 0 && GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE))
{ {
sLog.outCommand(GetAccountId(),"GM %s (Account: %u) mail money: %u to player: %s (Account: %u)", sLog.outCommand(GetAccountId(),"GM %s (Account: %u) mail money: %u to player: %s (Account: %u)",
GetPlayerName(), GetAccountId(), money, receiver.c_str(), rc_account); GetPlayerName(), GetAccountId(), money, receiver.c_str(), rc_account);
} }
} }
@ -318,9 +318,9 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data )
// will delete item or place to receiver mail list // will delete item or place to receiver mail list
draft draft
.SetMoney(money) .SetMoney(money)
.SetCOD(COD) .SetCOD(COD)
.SendMailTo(MailReceiver(receive, rc), pl, body.empty() ? MAIL_CHECK_MASK_COPIED : MAIL_CHECK_MASK_HAS_BODY, deliver_delay); .SendMailTo(MailReceiver(receive, rc), pl, body.empty() ? MAIL_CHECK_MASK_COPIED : MAIL_CHECK_MASK_HAS_BODY, deliver_delay);
CharacterDatabase.BeginTransaction(); CharacterDatabase.BeginTransaction();
pl->SaveInventoryAndGoldToDB(); pl->SaveInventoryAndGoldToDB();
@ -338,7 +338,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data )
* @param recv_data the packet containing information about the mail the player read. * @param recv_data the packet containing information about the mail the player read.
* *
*/ */
void WorldSession::HandleMailMarkAsRead(WorldPacket & recv_data ) void WorldSession::HandleMailMarkAsRead(WorldPacket& recv_data)
{ {
ObjectGuid mailboxGuid; ObjectGuid mailboxGuid;
uint32 mailId; uint32 mailId;
@ -348,9 +348,9 @@ void WorldSession::HandleMailMarkAsRead(WorldPacket & recv_data )
if (!CheckMailBox(mailboxGuid)) if (!CheckMailBox(mailboxGuid))
return; return;
Player *pl = _player; Player* pl = _player;
if (Mail *m = pl->GetMail(mailId)) if (Mail* m = pl->GetMail(mailId))
{ {
if (pl->unReadMails) if (pl->unReadMails)
--pl->unReadMails; --pl->unReadMails;
@ -368,7 +368,7 @@ void WorldSession::HandleMailMarkAsRead(WorldPacket & recv_data )
* @param recv_data The packet containing information about the mail being deleted. * @param recv_data The packet containing information about the mail being deleted.
* *
*/ */
void WorldSession::HandleMailDelete(WorldPacket & recv_data ) void WorldSession::HandleMailDelete(WorldPacket& recv_data)
{ {
ObjectGuid mailboxGuid; ObjectGuid mailboxGuid;
uint32 mailId; uint32 mailId;
@ -382,7 +382,7 @@ void WorldSession::HandleMailDelete(WorldPacket & recv_data )
Player* pl = _player; Player* pl = _player;
pl->m_mailsUpdated = true; pl->m_mailsUpdated = true;
if(Mail *m = pl->GetMail(mailId)) if (Mail* m = pl->GetMail(mailId))
{ {
// delete shouldn't show up for COD mails // delete shouldn't show up for COD mails
if (m->COD) if (m->COD)
@ -404,7 +404,7 @@ void WorldSession::HandleMailDelete(WorldPacket & recv_data )
* @param recv_data The packet containing information about the mail being returned. * @param recv_data The packet containing information about the mail being returned.
* *
*/ */
void WorldSession::HandleMailReturnToSender(WorldPacket & recv_data ) void WorldSession::HandleMailReturnToSender(WorldPacket& recv_data)
{ {
ObjectGuid mailboxGuid; ObjectGuid mailboxGuid;
uint32 mailId; uint32 mailId;
@ -415,9 +415,9 @@ void WorldSession::HandleMailReturnToSender(WorldPacket & recv_data )
if (!CheckMailBox(mailboxGuid)) if (!CheckMailBox(mailboxGuid))
return; return;
Player *pl = _player; Player* pl = _player;
Mail *m = pl->GetMail(mailId); Mail* m = pl->GetMail(mailId);
if(!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL)) if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL))
{ {
pl->SendMailResult(mailId, MAIL_RETURNED_TO_SENDER, MAIL_ERR_INTERNAL_ERROR); pl->SendMailResult(mailId, MAIL_RETURNED_TO_SENDER, MAIL_ERR_INTERNAL_ERROR);
return; return;
@ -427,7 +427,7 @@ void WorldSession::HandleMailReturnToSender(WorldPacket & recv_data )
//so firstly delete the old one //so firstly delete the old one
CharacterDatabase.BeginTransaction(); CharacterDatabase.BeginTransaction();
CharacterDatabase.PExecute("DELETE FROM mail WHERE id = '%u'", mailId); CharacterDatabase.PExecute("DELETE FROM mail WHERE id = '%u'", mailId);
// needed? // needed?
CharacterDatabase.PExecute("DELETE FROM mail_items WHERE mail_id = '%u'", mailId); CharacterDatabase.PExecute("DELETE FROM mail_items WHERE mail_id = '%u'", mailId);
CharacterDatabase.CommitTransaction(); CharacterDatabase.CommitTransaction();
pl->RemoveMail(mailId); pl->RemoveMail(mailId);
@ -441,11 +441,11 @@ void WorldSession::HandleMailReturnToSender(WorldPacket & recv_data )
else else
draft.SetSubjectAndBody(m->subject, m->body); draft.SetSubjectAndBody(m->subject, m->body);
if(m->HasItems()) if (m->HasItems())
{ {
for(MailItemInfoVec::iterator itr2 = m->items.begin(); itr2 != m->items.end(); ++itr2) for (MailItemInfoVec::iterator itr2 = m->items.begin(); itr2 != m->items.end(); ++itr2)
{ {
if(Item *item = pl->GetMItem(itr2->item_guid)) if (Item* item = pl->GetMItem(itr2->item_guid))
draft.AddItem(item); draft.AddItem(item);
pl->RemoveMItem(itr2->item_guid); pl->RemoveMItem(itr2->item_guid);
@ -462,7 +462,7 @@ void WorldSession::HandleMailReturnToSender(WorldPacket & recv_data )
/** /**
* Handles the packet sent by the client when taking an item from the mail. * Handles the packet sent by the client when taking an item from the mail.
*/ */
void WorldSession::HandleMailTakeItem(WorldPacket & recv_data ) void WorldSession::HandleMailTakeItem(WorldPacket& recv_data)
{ {
ObjectGuid mailboxGuid; ObjectGuid mailboxGuid;
uint32 mailId; uint32 mailId;
@ -477,23 +477,23 @@ void WorldSession::HandleMailTakeItem(WorldPacket & recv_data )
Player* pl = _player; Player* pl = _player;
Mail* m = pl->GetMail(mailId); Mail* m = pl->GetMail(mailId);
if(!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL)) if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL))
{ {
pl->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_INTERNAL_ERROR); pl->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_INTERNAL_ERROR);
return; return;
} }
// prevent cheating with skip client money check // prevent cheating with skip client money check
if(pl->GetMoney() < m->COD) if (pl->GetMoney() < m->COD)
{ {
pl->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_NOT_ENOUGH_MONEY); pl->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_NOT_ENOUGH_MONEY);
return; return;
} }
Item *it = pl->GetMItem(itemId); Item* it = pl->GetMItem(itemId);
ItemPosCountVec dest; ItemPosCountVec dest;
InventoryResult msg = _player->CanStoreItem( NULL_BAG, NULL_SLOT, dest, it, false ); InventoryResult msg = _player->CanStoreItem(NULL_BAG, NULL_SLOT, dest, it, false);
if (msg == EQUIP_ERR_OK) if (msg == EQUIP_ERR_OK)
{ {
m->RemoveItem(itemId); m->RemoveItem(itemId);
@ -502,14 +502,14 @@ void WorldSession::HandleMailTakeItem(WorldPacket & recv_data )
if (m->COD > 0) // if there is COD, take COD money from player and send them to sender by mail if (m->COD > 0) // if there is COD, take COD money from player and send them to sender by mail
{ {
ObjectGuid sender_guid = ObjectGuid(HIGHGUID_PLAYER, m->sender); ObjectGuid sender_guid = ObjectGuid(HIGHGUID_PLAYER, m->sender);
Player *sender = sObjectMgr.GetPlayer(sender_guid); Player* sender = sObjectMgr.GetPlayer(sender_guid);
uint32 sender_accId = 0; uint32 sender_accId = 0;
if( GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE) ) if (GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE))
{ {
std::string sender_name; std::string sender_name;
if(sender) if (sender)
{ {
sender_accId = sender->GetSession()->GetAccountId(); sender_accId = sender->GetSession()->GetAccountId();
sender_name = sender->GetName(); sender_name = sender->GetName();
@ -519,24 +519,24 @@ void WorldSession::HandleMailTakeItem(WorldPacket & recv_data )
// can be calculated early // can be calculated early
sender_accId = sObjectMgr.GetPlayerAccountIdByGUID(sender_guid); sender_accId = sObjectMgr.GetPlayerAccountIdByGUID(sender_guid);
if(!sObjectMgr.GetPlayerNameByGUID(sender_guid, sender_name)) if (!sObjectMgr.GetPlayerNameByGUID(sender_guid, sender_name))
sender_name = sObjectMgr.GetMangosStringForDBCLocale(LANG_UNKNOWN); sender_name = sObjectMgr.GetMangosStringForDBCLocale(LANG_UNKNOWN);
} }
sLog.outCommand(GetAccountId(), "GM %s (Account: %u) receive mail item: %s (Entry: %u Count: %u) and send COD money: %u to player: %s (Account: %u)", sLog.outCommand(GetAccountId(), "GM %s (Account: %u) receive mail item: %s (Entry: %u Count: %u) and send COD money: %u to player: %s (Account: %u)",
GetPlayerName(), GetAccountId(), it->GetProto()->Name1, it->GetEntry(), it->GetCount(), m->COD, sender_name.c_str(), sender_accId); GetPlayerName(), GetAccountId(), it->GetProto()->Name1, it->GetEntry(), it->GetCount(), m->COD, sender_name.c_str(), sender_accId);
} }
else if (!sender) else if (!sender)
sender_accId = sObjectMgr.GetPlayerAccountIdByGUID(sender_guid); sender_accId = sObjectMgr.GetPlayerAccountIdByGUID(sender_guid);
// check player existence // check player existence
if(sender || sender_accId) if (sender || sender_accId)
{ {
MailDraft(m->subject, "") MailDraft(m->subject, "")
.SetMoney(m->COD) .SetMoney(m->COD)
.SendMailTo(MailReceiver(sender, sender_guid), _player, MAIL_CHECK_MASK_COD_PAYMENT); .SendMailTo(MailReceiver(sender, sender_guid), _player, MAIL_CHECK_MASK_COD_PAYMENT);
} }
pl->ModifyMoney( -int32(m->COD) ); pl->ModifyMoney(-int32(m->COD));
} }
m->COD = 0; m->COD = 0;
m->state = MAIL_STATE_CHANGED; m->state = MAIL_STATE_CHANGED;
@ -560,7 +560,7 @@ void WorldSession::HandleMailTakeItem(WorldPacket & recv_data )
/** /**
* Handles the packet sent by the client when taking money from the mail. * Handles the packet sent by the client when taking money from the mail.
*/ */
void WorldSession::HandleMailTakeMoney(WorldPacket & recv_data ) void WorldSession::HandleMailTakeMoney(WorldPacket& recv_data)
{ {
ObjectGuid mailboxGuid; ObjectGuid mailboxGuid;
uint32 mailId; uint32 mailId;
@ -570,10 +570,10 @@ void WorldSession::HandleMailTakeMoney(WorldPacket & recv_data )
if (!CheckMailBox(mailboxGuid)) if (!CheckMailBox(mailboxGuid))
return; return;
Player *pl = _player; Player* pl = _player;
Mail* m = pl->GetMail(mailId); Mail* m = pl->GetMail(mailId);
if(!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL)) if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL))
{ {
pl->SendMailResult(mailId, MAIL_MONEY_TAKEN, MAIL_ERR_INTERNAL_ERROR); pl->SendMailResult(mailId, MAIL_MONEY_TAKEN, MAIL_ERR_INTERNAL_ERROR);
return; return;
@ -597,7 +597,7 @@ void WorldSession::HandleMailTakeMoney(WorldPacket & recv_data )
* Handles the packet sent by the client when requesting the current mail list. * Handles the packet sent by the client when requesting the current mail list.
* It will send a list of all available mails in the players mailbox to the client. * It will send a list of all available mails in the players mailbox to the client.
*/ */
void WorldSession::HandleGetMailList(WorldPacket & recv_data ) void WorldSession::HandleGetMailList(WorldPacket& recv_data)
{ {
ObjectGuid mailboxGuid; ObjectGuid mailboxGuid;
recv_data >> mailboxGuid; recv_data >> mailboxGuid;
@ -616,10 +616,10 @@ void WorldSession::HandleGetMailList(WorldPacket & recv_data )
data << uint8(0); // mail's count data << uint8(0); // mail's count
time_t cur_time = time(NULL); time_t cur_time = time(NULL);
for(PlayerMails::iterator itr = _player->GetMailBegin(); itr != _player->GetMailEnd(); ++itr) for (PlayerMails::iterator itr = _player->GetMailBegin(); itr != _player->GetMailEnd(); ++itr)
{ {
// packet send mail count as uint8, prevent overflow // packet send mail count as uint8, prevent overflow
if(mailsCount >= 254) if (mailsCount >= 254)
{ {
realCount += 1; realCount += 1;
continue; continue;
@ -633,7 +633,7 @@ void WorldSession::HandleGetMailList(WorldPacket & recv_data )
size_t next_mail_size = 2+4+1+((*itr)->messageType == MAIL_NORMAL ? 8 : 4)+4*8+((*itr)->subject.size()+1)+((*itr)->body.size()+1)+1+item_count*(1+4+4+7*3*4+4+4+4+4+4+4+1); size_t next_mail_size = 2+4+1+((*itr)->messageType == MAIL_NORMAL ? 8 : 4)+4*8+((*itr)->subject.size()+1)+((*itr)->body.size()+1)+1+item_count*(1+4+4+7*3*4+4+4+4+4+4+4+1);
if(data.wpos()+next_mail_size > maxPacketSize) if (data.wpos()+next_mail_size > maxPacketSize)
{ {
realCount += 1; realCount += 1;
continue; continue;
@ -643,7 +643,7 @@ void WorldSession::HandleGetMailList(WorldPacket & recv_data )
data << uint32((*itr)->messageID); // Message ID data << uint32((*itr)->messageID); // Message ID
data << uint8((*itr)->messageType); // Message Type data << uint8((*itr)->messageType); // Message Type
switch((*itr)->messageType) switch ((*itr)->messageType)
{ {
case MAIL_NORMAL: // sender guid case MAIL_NORMAL: // sender guid
data << ObjectGuid(HIGHGUID_PLAYER, (*itr)->sender); data << ObjectGuid(HIGHGUID_PLAYER, (*itr)->sender);
@ -670,16 +670,16 @@ void WorldSession::HandleGetMailList(WorldPacket & recv_data )
data << uint8(item_count); // client limit is 0x10 data << uint8(item_count); // client limit is 0x10
for(uint8 i = 0; i < item_count; ++i) for (uint8 i = 0; i < item_count; ++i)
{ {
Item *item = _player->GetMItem((*itr)->items[i].item_guid); Item* item = _player->GetMItem((*itr)->items[i].item_guid);
// item index (0-6?) // item index (0-6?)
data << uint8(i); data << uint8(i);
// item guid low? // item guid low?
data << uint32(item ? item->GetGUIDLow() : 0); data << uint32(item ? item->GetGUIDLow() : 0);
// entry // entry
data << uint32(item ? item->GetEntry() : 0); data << uint32(item ? item->GetEntry() : 0);
for(uint8 j = 0; j < MAX_INSPECTED_ENCHANTMENT_SLOT; ++j) for (uint8 j = 0; j < MAX_INSPECTED_ENCHANTMENT_SLOT; ++j)
{ {
// unsure // unsure
data << uint32(item ? item->GetEnchantmentCharges((EnchantmentSlot)j) : 0); data << uint32(item ? item->GetEnchantmentCharges((EnchantmentSlot)j) : 0);
@ -723,7 +723,7 @@ void WorldSession::HandleGetMailList(WorldPacket & recv_data )
* a new item with the text of the mail and store it in the players inventory (if possible). * a new item with the text of the mail and store it in the players inventory (if possible).
* *
*/ */
void WorldSession::HandleMailCreateTextItem(WorldPacket & recv_data ) void WorldSession::HandleMailCreateTextItem(WorldPacket& recv_data)
{ {
ObjectGuid mailboxGuid; ObjectGuid mailboxGuid;
uint32 mailId; uint32 mailId;
@ -734,7 +734,7 @@ void WorldSession::HandleMailCreateTextItem(WorldPacket & recv_data )
if (!CheckMailBox(mailboxGuid)) if (!CheckMailBox(mailboxGuid))
return; return;
Player *pl = _player; Player* pl = _player;
Mail* m = pl->GetMail(mailId); Mail* m = pl->GetMail(mailId);
if (!m || (m->body.empty() && !m->mailTemplateId) || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL)) if (!m || (m->body.empty() && !m->mailTemplateId) || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL))
@ -743,7 +743,7 @@ void WorldSession::HandleMailCreateTextItem(WorldPacket & recv_data )
return; return;
} }
Item *bodyItem = new Item; // This is not bag and then can be used new Item. Item* bodyItem = new Item; // This is not bag and then can be used new Item.
if (!bodyItem->Create(sObjectMgr.GenerateItemLowGuid(), MAIL_BODY_ITEM_TEMPLATE, pl)) if (!bodyItem->Create(sObjectMgr.GenerateItemLowGuid(), MAIL_BODY_ITEM_TEMPLATE, pl))
{ {
delete bodyItem; delete bodyItem;
@ -772,7 +772,7 @@ void WorldSession::HandleMailCreateTextItem(WorldPacket & recv_data )
DETAIL_LOG("HandleMailCreateTextItem mailid=%u", mailId); DETAIL_LOG("HandleMailCreateTextItem mailid=%u", mailId);
ItemPosCountVec dest; ItemPosCountVec dest;
InventoryResult msg = _player->CanStoreItem( NULL_BAG, NULL_SLOT, dest, bodyItem, false ); InventoryResult msg = _player->CanStoreItem(NULL_BAG, NULL_SLOT, dest, bodyItem, false);
if (msg == EQUIP_ERR_OK) if (msg == EQUIP_ERR_OK)
{ {
m->checked = m->checked | MAIL_CHECK_MASK_COPIED; m->checked = m->checked | MAIL_CHECK_MASK_COPIED;
@ -792,31 +792,31 @@ void WorldSession::HandleMailCreateTextItem(WorldPacket & recv_data )
/** /**
* No idea when this is called. * No idea when this is called.
*/ */
void WorldSession::HandleQueryNextMailTime(WorldPacket & /**recv_data*/ ) void WorldSession::HandleQueryNextMailTime(WorldPacket& /**recv_data*/)
{ {
WorldPacket data(MSG_QUERY_NEXT_MAIL_TIME, 8); WorldPacket data(MSG_QUERY_NEXT_MAIL_TIME, 8);
if( _player->unReadMails > 0 ) if (_player->unReadMails > 0)
{ {
data << uint32(0); // float data << uint32(0); // float
data << uint32(0); // count data << uint32(0); // count
uint32 count = 0; uint32 count = 0;
time_t now = time(NULL); time_t now = time(NULL);
for(PlayerMails::iterator itr = _player->GetMailBegin(); itr != _player->GetMailEnd(); ++itr) for (PlayerMails::iterator itr = _player->GetMailBegin(); itr != _player->GetMailEnd(); ++itr)
{ {
Mail *m = (*itr); Mail* m = (*itr);
// must be not checked yet // must be not checked yet
if(m->checked & MAIL_CHECK_MASK_READ) if (m->checked & MAIL_CHECK_MASK_READ)
continue; continue;
// and already delivered // and already delivered
if(now < m->deliver_time) if (now < m->deliver_time)
continue; continue;
data << ObjectGuid(HIGHGUID_PLAYER, m->sender); // sender guid data << ObjectGuid(HIGHGUID_PLAYER, m->sender); // sender guid
switch(m->messageType) switch (m->messageType)
{ {
case MAIL_AUCTION: case MAIL_AUCTION:
data << uint32(m->sender); // auction house id data << uint32(m->sender); // auction house id
@ -832,7 +832,7 @@ void WorldSession::HandleQueryNextMailTime(WorldPacket & /**recv_data*/ )
data << uint32(0xC6000000); // float unk, time or something data << uint32(0xC6000000); // float unk, time or something
++count; ++count;
if(count == 2) // do not display more than 2 mails if (count == 2) // do not display more than 2 mails
break; break;
} }
data.put<uint32>(4, count); data.put<uint32>(4, count);

File diff suppressed because it is too large Load diff

View file

@ -66,7 +66,7 @@ struct InstanceTemplate
{ {
uint32 map; // instance map uint32 map; // instance map
uint32 parent; // non-continent parent instance (for instance with entrance in another instances) uint32 parent; // non-continent parent instance (for instance with entrance in another instances)
// or 0 (not related to continent 0 map id) // or 0 (not related to continent 0 map id)
uint32 levelMin; uint32 levelMin;
uint32 levelMax; uint32 levelMax;
uint32 script_id; uint32 script_id;
@ -93,9 +93,9 @@ enum LevelRequirementVsMode
class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType> class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>
{ {
friend class MapReference; friend class MapReference;
friend class ObjectGridLoader; friend class ObjectGridLoader;
friend class ObjectWorldLoader; friend class ObjectWorldLoader;
protected: protected:
Map(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode); Map(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode);
@ -106,39 +106,39 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>
// currently unused for normal maps // currently unused for normal maps
bool CanUnload(uint32 diff) bool CanUnload(uint32 diff)
{ {
if(!m_unloadTimer) return false; if (!m_unloadTimer) return false;
if(m_unloadTimer <= diff) return true; if (m_unloadTimer <= diff) return true;
m_unloadTimer -= diff; m_unloadTimer -= diff;
return false; return false;
} }
virtual bool Add(Player *); virtual bool Add(Player*);
virtual void Remove(Player *, bool); virtual void Remove(Player*, bool);
template<class T> void Add(T *); template<class T> void Add(T*);
template<class T> void Remove(T *, bool); template<class T> void Remove(T*, bool);
static void DeleteFromWorld(Player* player); // player object will deleted at call static void DeleteFromWorld(Player* player); // player object will deleted at call
virtual void Update(const uint32&); virtual void Update(const uint32&);
void MessageBroadcast(Player *, WorldPacket *, bool to_self); void MessageBroadcast(Player*, WorldPacket*, bool to_self);
void MessageBroadcast(WorldObject *, WorldPacket *); void MessageBroadcast(WorldObject*, WorldPacket*);
void MessageDistBroadcast(Player *, WorldPacket *, float dist, bool to_self, bool own_team_only = false); void MessageDistBroadcast(Player*, WorldPacket*, float dist, bool to_self, bool own_team_only = false);
void MessageDistBroadcast(WorldObject *, WorldPacket *, float dist); void MessageDistBroadcast(WorldObject*, WorldPacket*, float dist);
float GetVisibilityDistance() const { return m_VisibleDistance; } float GetVisibilityDistance() const { return m_VisibleDistance; }
//function for setting up visibility distance for maps on per-type/per-Id basis //function for setting up visibility distance for maps on per-type/per-Id basis
virtual void InitVisibilityDistance(); virtual void InitVisibilityDistance();
void PlayerRelocation(Player *, float x, float y, float z, float angl); void PlayerRelocation(Player*, float x, float y, float z, float angl);
void CreatureRelocation(Creature *creature, float x, float y, float z, float orientation); void CreatureRelocation(Creature* creature, float x, float y, float z, float orientation);
template<class T, class CONTAINER> void Visit(const Cell& cell, TypeContainerVisitor<T, CONTAINER> &visitor); template<class T, class CONTAINER> void Visit(const Cell& cell, TypeContainerVisitor<T, CONTAINER>& visitor);
bool IsRemovalGrid(float x, float y) const bool IsRemovalGrid(float x, float y) const
{ {
GridPair p = MaNGOS::ComputeGridPair(x, y); GridPair p = MaNGOS::ComputeGridPair(x, y);
return( !getNGrid(p.x_coord, p.y_coord) || getNGrid(p.x_coord, p.y_coord)->GetGridState() == GRID_STATE_REMOVAL ); return(!getNGrid(p.x_coord, p.y_coord) || getNGrid(p.x_coord, p.y_coord)->GetGridState() == GRID_STATE_REMOVAL);
} }
bool IsLoaded(float x, float y) const bool IsLoaded(float x, float y) const
@ -147,13 +147,13 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>
return loaded(p); return loaded(p);
} }
bool GetUnloadLock(const GridPair &p) const { return getNGrid(p.x_coord, p.y_coord)->getUnloadLock(); } bool GetUnloadLock(const GridPair& p) const { return getNGrid(p.x_coord, p.y_coord)->getUnloadLock(); }
void SetUnloadLock(const GridPair &p, bool on) { getNGrid(p.x_coord, p.y_coord)->setUnloadExplicitLock(on); } void SetUnloadLock(const GridPair& p, bool on) { getNGrid(p.x_coord, p.y_coord)->setUnloadExplicitLock(on); }
void LoadGrid(const Cell& cell, bool no_unload = false); void LoadGrid(const Cell& cell, bool no_unload = false);
bool UnloadGrid(const uint32 &x, const uint32 &y, bool pForce); bool UnloadGrid(const uint32& x, const uint32& y, bool pForce);
virtual void UnloadAll(bool pForce); virtual void UnloadAll(bool pForce);
void ResetGridExpiry(NGridType &grid, float factor = 1) const void ResetGridExpiry(NGridType& grid, float factor = 1) const
{ {
grid.ResetTimeTracker((time_t)((float)i_gridExpiry*factor)); grid.ResetTimeTracker((time_t)((float)i_gridExpiry*factor));
} }
@ -166,7 +166,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>
virtual void RemoveAllObjectsInRemoveList(); virtual void RemoveAllObjectsInRemoveList();
bool CreatureRespawnRelocation(Creature *c); // used only in CreatureRelocation and ObjectGridUnloader bool CreatureRespawnRelocation(Creature* c); // used only in CreatureRelocation and ObjectGridUnloader
bool CheckGridIntegrity(Creature* c, bool moved) const; bool CheckGridIntegrity(Creature* c, bool moved) const;
@ -197,7 +197,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>
// can't be NULL for loaded map // can't be NULL for loaded map
MapPersistentState* GetPersistentState() const { return m_persistentState; } MapPersistentState* GetPersistentState() const { return m_persistentState; }
void AddObjectToRemoveList(WorldObject *obj); void AddObjectToRemoveList(WorldObject* obj);
void UpdateObjectVisibility(WorldObject* obj, Cell cell, CellPair cellpair); void UpdateObjectVisibility(WorldObject* obj, Cell cell, CellPair cellpair);
@ -236,21 +236,21 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>
typedef TypeUnorderedMapContainer<AllMapStoredObjectTypes, ObjectGuid> MapStoredObjectTypesContainer; typedef TypeUnorderedMapContainer<AllMapStoredObjectTypes, ObjectGuid> MapStoredObjectTypesContainer;
MapStoredObjectTypesContainer& GetObjectsStore() { return m_objectsStore; } MapStoredObjectTypesContainer& GetObjectsStore() { return m_objectsStore; }
void AddUpdateObject(Object *obj) void AddUpdateObject(Object* obj)
{ {
i_objectsToClientUpdate.insert(obj); i_objectsToClientUpdate.insert(obj);
} }
void RemoveUpdateObject(Object *obj) void RemoveUpdateObject(Object* obj)
{ {
i_objectsToClientUpdate.erase( obj ); i_objectsToClientUpdate.erase(obj);
} }
// DynObjects currently // DynObjects currently
uint32 GenerateLocalLowGuid(HighGuid guidhigh); uint32 GenerateLocalLowGuid(HighGuid guidhigh);
//get corresponding TerrainData object for this particular map //get corresponding TerrainData object for this particular map
const TerrainInfo * GetTerrain() const { return m_TerrainData; } const TerrainInfo* GetTerrain() const { return m_TerrainData; }
void CreateInstanceData(bool load); void CreateInstanceData(bool load);
InstanceData* GetInstanceData() { return i_data; } InstanceData* GetInstanceData() { return i_data; }
@ -262,7 +262,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>
// VMap System // VMap System
bool IsInLineOfSight(float srcX, float srcY, float srcZ, float destX, float destY, float destZ); bool IsInLineOfSight(float srcX, float srcY, float srcZ, float destX, float destY, float destZ);
bool GetObjectHitPos(float srcX, float srcY, float srcZ, float destX, float destY, float destZ, float& resX, float &resY, float& resZ, float pModifyDist); bool GetObjectHitPos(float srcX, float srcY, float srcZ, float destX, float destY, float destZ, float& resX, float& resY, float& resZ, float pModifyDist);
// Get Holder for Creature Linking // Get Holder for Creature Linking
CreatureLinkingHolder* GetCreatureLinkingHolder() { return &m_creatureLinkingHolder; } CreatureLinkingHolder* GetCreatureLinkingHolder() { return &m_creatureLinkingHolder; }
@ -272,22 +272,22 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>
void SetTimer(uint32 t) { i_gridExpiry = t < MIN_GRID_DELAY ? MIN_GRID_DELAY : t; } void SetTimer(uint32 t) { i_gridExpiry = t < MIN_GRID_DELAY ? MIN_GRID_DELAY : t; }
void SendInitSelf( Player * player ); void SendInitSelf(Player* player);
void SendInitTransports( Player * player ); void SendInitTransports(Player* player);
void SendRemoveTransports( Player * player ); void SendRemoveTransports(Player* player);
bool CreatureCellRelocation(Creature *creature, Cell new_cell); bool CreatureCellRelocation(Creature* creature, Cell new_cell);
bool loaded(const GridPair &) const; bool loaded(const GridPair&) const;
void EnsureGridCreated(const GridPair &); void EnsureGridCreated(const GridPair&);
bool EnsureGridLoaded(Cell const&); bool EnsureGridLoaded(Cell const&);
void EnsureGridLoadedAtEnter(Cell const&, Player* player = NULL); void EnsureGridLoadedAtEnter(Cell const&, Player* player = NULL);
void buildNGridLinkage(NGridType* pNGridType) { pNGridType->link(this); } void buildNGridLinkage(NGridType* pNGridType) { pNGridType->link(this); }
template<class T> void AddType(T *obj); template<class T> void AddType(T* obj);
template<class T> void RemoveType(T *obj, bool); template<class T> void RemoveType(T* obj, bool);
NGridType* getNGrid(uint32 x, uint32 y) const NGridType* getNGrid(uint32 x, uint32 y) const
{ {
@ -303,7 +303,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>
void ScriptsProcess(); void ScriptsProcess();
void SendObjectUpdates(); void SendObjectUpdates();
std::set<Object *> i_objectsToClientUpdate; std::set<Object*> i_objectsToClientUpdate;
protected: protected:
MapEntry const* i_mapEntry; MapEntry const* i_mapEntry;
@ -328,12 +328,12 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>
NGridType* i_grids[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]; NGridType* i_grids[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS];
//Shared geodata object with map coord info... //Shared geodata object with map coord info...
TerrainInfo * const m_TerrainData; TerrainInfo* const m_TerrainData;
bool m_bLoadedGrids[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]; bool m_bLoadedGrids[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS];
std::bitset<TOTAL_NUMBER_OF_CELLS_PER_MAP*TOTAL_NUMBER_OF_CELLS_PER_MAP> marked_cells; std::bitset<TOTAL_NUMBER_OF_CELLS_PER_MAP* TOTAL_NUMBER_OF_CELLS_PER_MAP> marked_cells;
std::set<WorldObject *> i_objectsToRemove; std::set<WorldObject*> i_objectsToRemove;
typedef std::multimap<time_t, ScriptAction> ScriptScheduleMap; typedef std::multimap<time_t, ScriptAction> ScriptScheduleMap;
ScriptScheduleMap m_scriptSchedule; ScriptScheduleMap m_scriptSchedule;
@ -350,10 +350,10 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>
// Type specific code for add/remove to/from grid // Type specific code for add/remove to/from grid
template<class T> template<class T>
void AddToGrid(T*, NGridType *, Cell const&); void AddToGrid(T*, NGridType*, Cell const&);
template<class T> template<class T>
void RemoveFromGrid(T*, NGridType *, Cell const&); void RemoveFromGrid(T*, NGridType*, Cell const&);
// Holder for information about linked mobs // Holder for information about linked mobs
CreatureLinkingHolder m_creatureLinkingHolder; CreatureLinkingHolder m_creatureLinkingHolder;
@ -378,11 +378,11 @@ class MANGOS_DLL_SPEC DungeonMap : public Map
public: public:
DungeonMap(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode); DungeonMap(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode);
~DungeonMap(); ~DungeonMap();
bool Add(Player *); bool Add(Player*);
void Remove(Player *, bool); void Remove(Player*, bool);
void Update(const uint32&); void Update(const uint32&);
bool Reset(InstanceResetMethod method); bool Reset(InstanceResetMethod method);
void PermBindAllPlayers(Player *player); void PermBindAllPlayers(Player* player);
void UnloadAll(bool pForce); void UnloadAll(bool pForce);
bool CanEnter(Player* player); bool CanEnter(Player* player);
void SendResetWarnings(uint32 timeLeft) const; void SendResetWarnings(uint32 timeLeft) const;
@ -406,8 +406,8 @@ class MANGOS_DLL_SPEC BattleGroundMap : public Map
~BattleGroundMap(); ~BattleGroundMap();
void Update(const uint32&); void Update(const uint32&);
bool Add(Player *); bool Add(Player*);
void Remove(Player *, bool); void Remove(Player*, bool);
bool CanEnter(Player* player); bool CanEnter(Player* player);
void SetUnload(); void SetUnload();
void UnloadAll(bool pForce); void UnloadAll(bool pForce);
@ -425,14 +425,14 @@ class MANGOS_DLL_SPEC BattleGroundMap : public Map
template<class T, class CONTAINER> template<class T, class CONTAINER>
inline void inline void
Map::Visit(const Cell& cell, TypeContainerVisitor<T, CONTAINER> &visitor) Map::Visit(const Cell& cell, TypeContainerVisitor<T, CONTAINER>& visitor)
{ {
const uint32 x = cell.GridX(); const uint32 x = cell.GridX();
const uint32 y = cell.GridY(); const uint32 y = cell.GridY();
const uint32 cell_x = cell.CellX(); const uint32 cell_x = cell.CellX();
const uint32 cell_y = cell.CellY(); const uint32 cell_y = cell.CellY();
if( !cell.NoCreate() || loaded(GridPair(x,y)) ) if (!cell.NoCreate() || loaded(GridPair(x,y)))
{ {
EnsureGridLoaded(cell); EnsureGridLoaded(cell);
getNGrid(x, y)->Visit(cell_x, cell_y, visitor); getNGrid(x, y)->Visit(cell_x, cell_y, visitor);

View file

@ -40,10 +40,10 @@ MapManager::MapManager()
MapManager::~MapManager() MapManager::~MapManager()
{ {
for(MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter) for (MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter)
delete iter->second; delete iter->second;
for(TransportSet::iterator i = m_Transports.begin(); i != m_Transports.end(); ++i) for (TransportSet::iterator i = m_Transports.begin(); i != m_Transports.end(); ++i)
delete *i; delete *i;
DeleteStateMachine(); DeleteStateMachine();
@ -71,7 +71,7 @@ void MapManager::DeleteStateMachine()
delete si_GridStates[GRID_STATE_REMOVAL]; delete si_GridStates[GRID_STATE_REMOVAL];
} }
void MapManager::UpdateGridState(grid_state_t state, Map& map, NGridType& ngrid, GridInfo& ginfo, const uint32 &x, const uint32 &y, const uint32 &t_diff) void MapManager::UpdateGridState(grid_state_t state, Map& map, NGridType& ngrid, GridInfo& ginfo, const uint32& x, const uint32& y, const uint32& t_diff)
{ {
// TODO: The grid state array itself is static and therefore 100% safe, however, the data // TODO: The grid state array itself is static and therefore 100% safe, however, the data
// the state classes in it accesses is not, since grids are shared across maps (for example // the state classes in it accesses is not, since grids are shared across maps (for example
@ -82,7 +82,7 @@ void MapManager::UpdateGridState(grid_state_t state, Map& map, NGridType& ngrid,
void MapManager::InitializeVisibilityDistanceInfo() void MapManager::InitializeVisibilityDistanceInfo()
{ {
for(MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter) for (MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter)
(*iter).second->InitVisibilityDistance(); (*iter).second->InitVisibilityDistance();
} }
@ -92,24 +92,24 @@ Map* MapManager::CreateMap(uint32 id, const WorldObject* obj)
//if(!obj->IsInWorld()) sLog.outError("GetMap: called for map %d with object (typeid %d, guid %d, mapid %d, instanceid %d) who is not in world!", id, obj->GetTypeId(), obj->GetGUIDLow(), obj->GetMapId(), obj->GetInstanceId()); //if(!obj->IsInWorld()) sLog.outError("GetMap: called for map %d with object (typeid %d, guid %d, mapid %d, instanceid %d) who is not in world!", id, obj->GetTypeId(), obj->GetGUIDLow(), obj->GetMapId(), obj->GetInstanceId());
Guard _guard(*this); Guard _guard(*this);
Map * m = NULL; Map* m = NULL;
const MapEntry* entry = sMapStore.LookupEntry(id); const MapEntry* entry = sMapStore.LookupEntry(id);
if(!entry) if (!entry)
return NULL; return NULL;
if(entry->Instanceable()) if (entry->Instanceable())
{ {
MANGOS_ASSERT(obj->GetTypeId() == TYPEID_PLAYER); MANGOS_ASSERT(obj->GetTypeId() == TYPEID_PLAYER);
//create DungeonMap object //create DungeonMap object
if(obj->GetTypeId() == TYPEID_PLAYER) if (obj->GetTypeId() == TYPEID_PLAYER)
m = CreateInstance(id, (Player*)obj); m = CreateInstance(id, (Player*)obj);
} }
else else
{ {
//create regular non-instanceable map //create regular non-instanceable map
m = FindMap(id); m = FindMap(id);
if( m == NULL ) if (m == NULL)
{ {
m = new WorldMap(id, i_gridCleanUpDelay); m = new WorldMap(id, i_gridCleanUpDelay);
//add map into container //add map into container
@ -136,11 +136,11 @@ Map* MapManager::FindMap(uint32 mapid, uint32 instanceId) const
Guard guard(*this); Guard guard(*this);
MapMapType::const_iterator iter = i_maps.find(MapID(mapid, instanceId)); MapMapType::const_iterator iter = i_maps.find(MapID(mapid, instanceId));
if(iter == i_maps.end()) if (iter == i_maps.end())
return NULL; return NULL;
//this is a small workaround for transports //this is a small workaround for transports
if(instanceId == 0 && iter->second->Instanceable()) if (instanceId == 0 && iter->second->Instanceable())
{ {
assert(false); assert(false);
return NULL; return NULL;
@ -155,18 +155,18 @@ Map* MapManager::FindMap(uint32 mapid, uint32 instanceId) const
*/ */
bool MapManager::CanPlayerEnter(uint32 mapid, Player* player) bool MapManager::CanPlayerEnter(uint32 mapid, Player* player)
{ {
const MapEntry *entry = sMapStore.LookupEntry(mapid); const MapEntry* entry = sMapStore.LookupEntry(mapid);
if(!entry) if (!entry)
return false; return false;
const char *mapName = entry->name[player->GetSession()->GetSessionDbcLocale()]; const char* mapName = entry->name[player->GetSession()->GetSessionDbcLocale()];
if(entry->IsDungeon()) if (entry->IsDungeon())
{ {
if (entry->IsRaid()) if (entry->IsRaid())
{ {
// GMs can avoid raid limitations // GMs can avoid raid limitations
if(!player->isGameMaster() && !sWorld.getConfig(CONFIG_BOOL_INSTANCE_IGNORE_RAID)) if (!player->isGameMaster() && !sWorld.getConfig(CONFIG_BOOL_INSTANCE_IGNORE_RAID))
{ {
// can only enter in a raid group // can only enter in a raid group
Group* group = player->GetGroup(); Group* group = player->GetGroup();
@ -210,9 +210,9 @@ void MapManager::DeleteInstance(uint32 mapid, uint32 instanceId)
Guard _guard(*this); Guard _guard(*this);
MapMapType::iterator iter = i_maps.find(MapID(mapid, instanceId)); MapMapType::iterator iter = i_maps.find(MapID(mapid, instanceId));
if(iter != i_maps.end()) if (iter != i_maps.end())
{ {
Map * pMap = iter->second; Map* pMap = iter->second;
if (pMap->Instanceable()) if (pMap->Instanceable())
{ {
i_maps.erase(iter); i_maps.erase(iter);
@ -227,10 +227,10 @@ void
MapManager::Update(uint32 diff) MapManager::Update(uint32 diff)
{ {
i_timer.Update(diff); i_timer.Update(diff);
if( !i_timer.Passed() ) if (!i_timer.Passed())
return; return;
for(MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter) for (MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter)
iter->second->Update((uint32)i_timer.GetCurrent()); iter->second->Update((uint32)i_timer.GetCurrent());
for (TransportSet::iterator iter = m_Transports.begin(); iter != m_Transports.end(); ++iter) for (TransportSet::iterator iter = m_Transports.begin(); iter != m_Transports.end(); ++iter)
@ -241,11 +241,11 @@ MapManager::Update(uint32 diff)
//remove all maps which can be unloaded //remove all maps which can be unloaded
MapMapType::iterator iter = i_maps.begin(); MapMapType::iterator iter = i_maps.begin();
while(iter != i_maps.end()) while (iter != i_maps.end())
{ {
Map * pMap = iter->second; Map* pMap = iter->second;
//check if map can be unloaded //check if map can be unloaded
if(pMap->CanUnload((uint32)i_timer.GetCurrent())) if (pMap->CanUnload((uint32)i_timer.GetCurrent()))
{ {
pMap->UnloadAll(true); pMap->UnloadAll(true);
delete pMap; delete pMap;
@ -261,7 +261,7 @@ MapManager::Update(uint32 diff)
void MapManager::RemoveAllObjectsInRemoveList() void MapManager::RemoveAllObjectsInRemoveList()
{ {
for(MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter) for (MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter)
iter->second->RemoveAllObjectsInRemoveList(); iter->second->RemoveAllObjectsInRemoveList();
} }
@ -284,10 +284,10 @@ bool MapManager::IsValidMAP(uint32 mapid)
void MapManager::UnloadAll() void MapManager::UnloadAll()
{ {
for(MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter) for (MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter)
iter->second->UnloadAll(true); iter->second->UnloadAll(true);
while(!i_maps.empty()) while (!i_maps.empty())
{ {
delete i_maps.begin()->second; delete i_maps.begin()->second;
i_maps.erase(i_maps.begin()); i_maps.erase(i_maps.begin());
@ -299,11 +299,11 @@ void MapManager::UnloadAll()
uint32 MapManager::GetNumInstances() uint32 MapManager::GetNumInstances()
{ {
uint32 ret = 0; uint32 ret = 0;
for(MapMapType::iterator itr = i_maps.begin(); itr != i_maps.end(); ++itr) for (MapMapType::iterator itr = i_maps.begin(); itr != i_maps.end(); ++itr)
{ {
Map *map = itr->second; Map* map = itr->second;
if(!map->IsDungeon()) continue; if (!map->IsDungeon()) continue;
ret += 1; ret += 1;
} }
return ret; return ret;
} }
@ -311,25 +311,25 @@ uint32 MapManager::GetNumInstances()
uint32 MapManager::GetNumPlayersInInstances() uint32 MapManager::GetNumPlayersInInstances()
{ {
uint32 ret = 0; uint32 ret = 0;
for(MapMapType::iterator itr = i_maps.begin(); itr != i_maps.end(); ++itr) for (MapMapType::iterator itr = i_maps.begin(); itr != i_maps.end(); ++itr)
{ {
Map *map = itr->second; Map* map = itr->second;
if(!map->IsDungeon()) continue; if (!map->IsDungeon()) continue;
ret += map->GetPlayers().getSize(); ret += map->GetPlayers().getSize();
} }
return ret; return ret;
} }
///// returns a new or existing Instance ///// returns a new or existing Instance
///// in case of battlegrounds it will only return an existing map, those maps are created by bg-system ///// in case of battlegrounds it will only return an existing map, those maps are created by bg-system
Map* MapManager::CreateInstance(uint32 id, Player * player) Map* MapManager::CreateInstance(uint32 id, Player* player)
{ {
Map* map = NULL; Map* map = NULL;
Map * pNewMap = NULL; Map* pNewMap = NULL;
uint32 NewInstanceId = 0; // instanceId of the resulting map uint32 NewInstanceId = 0; // instanceId of the resulting map
const MapEntry* entry = sMapStore.LookupEntry(id); const MapEntry* entry = sMapStore.LookupEntry(id);
if(entry->IsBattleGroundOrArena()) if (entry->IsBattleGroundOrArena())
{ {
// find existing bg map for player // find existing bg map for player
NewInstanceId = player->GetBattleGroundId(); NewInstanceId = player->GetBattleGroundId();
@ -357,7 +357,7 @@ Map* MapManager::CreateInstance(uint32 id, Player * player)
} }
//add a new map object into the registry //add a new map object into the registry
if(pNewMap) if (pNewMap)
{ {
i_maps[MapID(id, NewInstanceId)] = pNewMap; i_maps[MapID(id, NewInstanceId)] = pNewMap;
map = pNewMap; map = pNewMap;
@ -366,7 +366,7 @@ Map* MapManager::CreateInstance(uint32 id, Player * player)
return map; return map;
} }
DungeonMap* MapManager::CreateDungeonMap(uint32 id, uint32 InstanceId, Difficulty difficulty, DungeonPersistentState *save) DungeonMap* MapManager::CreateDungeonMap(uint32 id, uint32 InstanceId, Difficulty difficulty, DungeonPersistentState* save)
{ {
// make sure we have a valid map id // make sure we have a valid map id
if (!sMapStore.LookupEntry(id)) if (!sMapStore.LookupEntry(id))
@ -386,7 +386,7 @@ DungeonMap* MapManager::CreateDungeonMap(uint32 id, uint32 InstanceId, Difficult
DEBUG_LOG("MapInstanced::CreateDungeonMap: %s map instance %d for %d created with difficulty %d", save?"":"new ", InstanceId, id, difficulty); DEBUG_LOG("MapInstanced::CreateDungeonMap: %s map instance %d for %d created with difficulty %d", save?"":"new ", InstanceId, id, difficulty);
DungeonMap *map = new DungeonMap(id, i_gridCleanUpDelay, InstanceId, difficulty); DungeonMap* map = new DungeonMap(id, i_gridCleanUpDelay, InstanceId, difficulty);
// Dungeons can have saved instance data // Dungeons can have saved instance data
bool load_data = save != NULL; bool load_data = save != NULL;
@ -403,7 +403,7 @@ BattleGroundMap* MapManager::CreateBattleGroundMap(uint32 id, uint32 InstanceId,
uint8 spawnMode = bracketEntry ? bracketEntry->difficulty : REGULAR_DIFFICULTY; uint8 spawnMode = bracketEntry ? bracketEntry->difficulty : REGULAR_DIFFICULTY;
BattleGroundMap *map = new BattleGroundMap(id, i_gridCleanUpDelay, InstanceId, spawnMode); BattleGroundMap* map = new BattleGroundMap(id, i_gridCleanUpDelay, InstanceId, spawnMode);
MANGOS_ASSERT(map->IsBattleGroundOrArena()); MANGOS_ASSERT(map->IsBattleGroundOrArena());
map->SetBG(bg); map->SetBG(bg);
bg->SetBgMap(map); bg->SetBgMap(map);

View file

@ -36,7 +36,7 @@ struct MANGOS_DLL_DECL MapID
bool operator<(const MapID& val) const bool operator<(const MapID& val) const
{ {
if(nMapId == val.nMapId) if (nMapId == val.nMapId)
return nInstanceId < val.nInstanceId; return nInstanceId < val.nInstanceId;
return nMapId < val.nMapId; return nMapId < val.nMapId;
@ -50,11 +50,11 @@ struct MANGOS_DLL_DECL MapID
class MANGOS_DLL_DECL MapManager : public MaNGOS::Singleton<MapManager, MaNGOS::ClassLevelLockable<MapManager, ACE_Recursive_Thread_Mutex> > class MANGOS_DLL_DECL MapManager : public MaNGOS::Singleton<MapManager, MaNGOS::ClassLevelLockable<MapManager, ACE_Recursive_Thread_Mutex> >
{ {
friend class MaNGOS::OperatorNew<MapManager>; friend class MaNGOS::OperatorNew<MapManager>;
typedef ACE_Recursive_Thread_Mutex LOCK_TYPE; typedef ACE_Recursive_Thread_Mutex LOCK_TYPE;
typedef ACE_Guard<LOCK_TYPE> LOCK_TYPE_GUARD; typedef ACE_Guard<LOCK_TYPE> LOCK_TYPE_GUARD;
typedef MaNGOS::ClassLevelLockable<MapManager, ACE_Recursive_Thread_Mutex>::Lock Guard; typedef MaNGOS::ClassLevelLockable<MapManager, ACE_Recursive_Thread_Mutex>::Lock Guard;
public: public:
typedef std::map<MapID, Map* > MapMapType; typedef std::map<MapID, Map* > MapMapType;
@ -63,7 +63,7 @@ class MANGOS_DLL_DECL MapManager : public MaNGOS::Singleton<MapManager, MaNGOS::
Map* CreateBgMap(uint32 mapid, BattleGround* bg); Map* CreateBgMap(uint32 mapid, BattleGround* bg);
Map* FindMap(uint32 mapid, uint32 instanceId = 0) const; Map* FindMap(uint32 mapid, uint32 instanceId = 0) const;
void UpdateGridState(grid_state_t state, Map& map, NGridType& ngrid, GridInfo& ginfo, const uint32 &x, const uint32 &y, const uint32 &t_diff); void UpdateGridState(grid_state_t state, Map& map, NGridType& ngrid, GridInfo& ginfo, const uint32& x, const uint32& y, const uint32& t_diff);
// only const version for outer users // only const version for outer users
void DeleteInstance(uint32 mapid, uint32 instanceId); void DeleteInstance(uint32 mapid, uint32 instanceId);
@ -73,7 +73,7 @@ class MANGOS_DLL_DECL MapManager : public MaNGOS::Singleton<MapManager, MaNGOS::
void SetGridCleanUpDelay(uint32 t) void SetGridCleanUpDelay(uint32 t)
{ {
if( t < MIN_GRID_DELAY ) if (t < MIN_GRID_DELAY)
i_gridCleanUpDelay = MIN_GRID_DELAY; i_gridCleanUpDelay = MIN_GRID_DELAY;
else else
i_gridCleanUpDelay = t; i_gridCleanUpDelay = t;
@ -81,7 +81,7 @@ class MANGOS_DLL_DECL MapManager : public MaNGOS::Singleton<MapManager, MaNGOS::
void SetMapUpdateInterval(uint32 t) void SetMapUpdateInterval(uint32 t)
{ {
if( t > MIN_MAP_UPDATE_DELAY ) if (t > MIN_MAP_UPDATE_DELAY)
t = MIN_MAP_UPDATE_DELAY; t = MIN_MAP_UPDATE_DELAY;
i_timer.SetInterval(t); i_timer.SetInterval(t);
@ -133,7 +133,7 @@ class MANGOS_DLL_DECL MapManager : public MaNGOS::Singleton<MapManager, MaNGOS::
void LoadTransports(); void LoadTransports();
typedef std::set<Transport *> TransportSet; typedef std::set<Transport*> TransportSet;
TransportSet m_Transports; TransportSet m_Transports;
typedef std::map<uint32, TransportSet> TransportMap; typedef std::map<uint32, TransportSet> TransportMap;
@ -164,14 +164,14 @@ class MANGOS_DLL_DECL MapManager : public MaNGOS::Singleton<MapManager, MaNGOS::
MapManager(); MapManager();
~MapManager(); ~MapManager();
MapManager(const MapManager &); MapManager(const MapManager&);
MapManager& operator=(const MapManager &); MapManager& operator=(const MapManager&);
void InitStateMachine(); void InitStateMachine();
void DeleteStateMachine(); void DeleteStateMachine();
Map* CreateInstance(uint32 id, Player * player); Map* CreateInstance(uint32 id, Player* player);
DungeonMap* CreateDungeonMap(uint32 id, uint32 InstanceId, Difficulty difficulty, DungeonPersistentState *save = NULL); DungeonMap* CreateDungeonMap(uint32 id, uint32 InstanceId, Difficulty difficulty, DungeonPersistentState* save = NULL);
BattleGroundMap* CreateBattleGroundMap(uint32 id, uint32 InstanceId, BattleGround* bg); BattleGroundMap* CreateBattleGroundMap(uint32 id, uint32 InstanceId, BattleGround* bg);
uint32 i_gridCleanUpDelay; uint32 i_gridCleanUpDelay;
@ -184,7 +184,7 @@ inline void MapManager::DoForAllMapsWithMapId(uint32 mapId, Do& _do)
{ {
MapMapType::const_iterator start = i_maps.lower_bound(MapID(mapId,0)); MapMapType::const_iterator start = i_maps.lower_bound(MapID(mapId,0));
MapMapType::const_iterator end = i_maps.lower_bound(MapID(mapId+1,0)); MapMapType::const_iterator end = i_maps.lower_bound(MapID(mapId+1,0));
for(MapMapType::const_iterator itr = start; itr != end; ++itr) for (MapMapType::const_iterator itr = start; itr != end; ++itr)
_do(itr->second); _do(itr->second);
} }

View file

@ -36,14 +36,14 @@
#include "InstanceData.h" #include "InstanceData.h"
#include "ProgressBar.h" #include "ProgressBar.h"
INSTANTIATE_SINGLETON_1( MapPersistentStateManager ); INSTANTIATE_SINGLETON_1(MapPersistentStateManager);
static uint32 resetEventTypeDelay[MAX_RESET_EVENT_TYPE] = { 0, 3600, 900, 300, 60 }; static uint32 resetEventTypeDelay[MAX_RESET_EVENT_TYPE] = { 0, 3600, 900, 300, 60 };
//== MapPersistentState functions ========================== //== MapPersistentState functions ==========================
MapPersistentState::MapPersistentState(uint16 MapId, uint32 InstanceId, Difficulty difficulty) MapPersistentState::MapPersistentState(uint16 MapId, uint32 InstanceId, Difficulty difficulty)
: m_instanceid(InstanceId), m_mapid(MapId), : m_instanceid(InstanceId), m_mapid(MapId),
m_difficulty(difficulty), m_usedByMap(NULL) m_difficulty(difficulty), m_usedByMap(NULL)
{ {
} }
@ -84,7 +84,7 @@ void MapPersistentState::SaveCreatureRespawnTime(uint32 loguid, time_t t)
SqlStatement stmt = CharacterDatabase.CreateStatement(delSpawnTime, "DELETE FROM creature_respawn WHERE guid = ? AND instance = ?"); SqlStatement stmt = CharacterDatabase.CreateStatement(delSpawnTime, "DELETE FROM creature_respawn WHERE guid = ? AND instance = ?");
stmt.PExecute(loguid, m_instanceid); stmt.PExecute(loguid, m_instanceid);
if(t > sWorld.GetGameTime()) if (t > sWorld.GetGameTime())
{ {
stmt = CharacterDatabase.CreateStatement(insSpawnTime, "INSERT INTO creature_respawn VALUES ( ?, ?, ? )"); stmt = CharacterDatabase.CreateStatement(insSpawnTime, "INSERT INTO creature_respawn VALUES ( ?, ?, ? )");
stmt.PExecute(loguid, uint64(t), m_instanceid); stmt.PExecute(loguid, uint64(t), m_instanceid);
@ -109,7 +109,7 @@ void MapPersistentState::SaveGORespawnTime(uint32 loguid, time_t t)
SqlStatement stmt = CharacterDatabase.CreateStatement(delSpawnTime, "DELETE FROM gameobject_respawn WHERE guid = ? AND instance = ?"); SqlStatement stmt = CharacterDatabase.CreateStatement(delSpawnTime, "DELETE FROM gameobject_respawn WHERE guid = ? AND instance = ?");
stmt.PExecute(loguid, m_instanceid); stmt.PExecute(loguid, m_instanceid);
if(t > sWorld.GetGameTime()) if (t > sWorld.GetGameTime())
{ {
stmt = CharacterDatabase.CreateStatement(insSpawnTime, "INSERT INTO gameobject_respawn VALUES ( ?, ?, ? )"); stmt = CharacterDatabase.CreateStatement(insSpawnTime, "INSERT INTO gameobject_respawn VALUES ( ?, ?, ? )");
stmt.PExecute(loguid, uint64(t), m_instanceid); stmt.PExecute(loguid, uint64(t), m_instanceid);
@ -118,7 +118,7 @@ void MapPersistentState::SaveGORespawnTime(uint32 loguid, time_t t)
CharacterDatabase.CommitTransaction(); CharacterDatabase.CommitTransaction();
} }
void MapPersistentState::SetCreatureRespawnTime( uint32 loguid, time_t t ) void MapPersistentState::SetCreatureRespawnTime(uint32 loguid, time_t t)
{ {
if (t > sWorld.GetGameTime()) if (t > sWorld.GetGameTime())
m_creatureRespawnTimes[loguid] = t; m_creatureRespawnTimes[loguid] = t;
@ -129,7 +129,7 @@ void MapPersistentState::SetCreatureRespawnTime( uint32 loguid, time_t t )
} }
} }
void MapPersistentState::SetGORespawnTime( uint32 loguid, time_t t ) void MapPersistentState::SetGORespawnTime(uint32 loguid, time_t t)
{ {
if (t > sWorld.GetGameTime()) if (t > sWorld.GetGameTime())
m_goRespawnTimes[loguid] = t; m_goRespawnTimes[loguid] = t;
@ -148,7 +148,7 @@ void MapPersistentState::ClearRespawnTimes()
UnloadIfEmpty(); UnloadIfEmpty();
} }
void MapPersistentState::AddCreatureToGrid( uint32 guid, CreatureData const* data ) void MapPersistentState::AddCreatureToGrid(uint32 guid, CreatureData const* data)
{ {
CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY); CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY);
uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord;
@ -156,7 +156,7 @@ void MapPersistentState::AddCreatureToGrid( uint32 guid, CreatureData const* dat
m_gridObjectGuids[cell_id].creatures.insert(guid); m_gridObjectGuids[cell_id].creatures.insert(guid);
} }
void MapPersistentState::RemoveCreatureFromGrid( uint32 guid, CreatureData const* data ) void MapPersistentState::RemoveCreatureFromGrid(uint32 guid, CreatureData const* data)
{ {
CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY); CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY);
uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord;
@ -164,7 +164,7 @@ void MapPersistentState::RemoveCreatureFromGrid( uint32 guid, CreatureData const
m_gridObjectGuids[cell_id].creatures.erase(guid); m_gridObjectGuids[cell_id].creatures.erase(guid);
} }
void MapPersistentState::AddGameobjectToGrid( uint32 guid, GameObjectData const* data ) void MapPersistentState::AddGameobjectToGrid(uint32 guid, GameObjectData const* data)
{ {
CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY); CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY);
uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord;
@ -172,7 +172,7 @@ void MapPersistentState::AddGameobjectToGrid( uint32 guid, GameObjectData const*
m_gridObjectGuids[cell_id].gameobjects.insert(guid); m_gridObjectGuids[cell_id].gameobjects.insert(guid);
} }
void MapPersistentState::RemoveGameobjectFromGrid( uint32 guid, GameObjectData const* data ) void MapPersistentState::RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data)
{ {
CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY); CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY);
uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord;
@ -206,21 +206,21 @@ bool WorldPersistentState::CanBeUnload() const
//== DungeonPersistentState functions ===================== //== DungeonPersistentState functions =====================
DungeonPersistentState::DungeonPersistentState( uint16 MapId, uint32 InstanceId, Difficulty difficulty, time_t resetTime, bool canReset, uint32 completedEncountersMask) DungeonPersistentState::DungeonPersistentState(uint16 MapId, uint32 InstanceId, Difficulty difficulty, time_t resetTime, bool canReset, uint32 completedEncountersMask)
: MapPersistentState(MapId, InstanceId, difficulty), m_resetTime(resetTime), m_canReset(canReset), m_completedEncountersMask(completedEncountersMask) : MapPersistentState(MapId, InstanceId, difficulty), m_resetTime(resetTime), m_canReset(canReset), m_completedEncountersMask(completedEncountersMask)
{ {
} }
DungeonPersistentState::~DungeonPersistentState() DungeonPersistentState::~DungeonPersistentState()
{ {
while(!m_playerList.empty()) while (!m_playerList.empty())
{ {
Player *player = *(m_playerList.begin()); Player* player = *(m_playerList.begin());
player->UnbindInstance(GetMapId(), GetDifficulty(), true); player->UnbindInstance(GetMapId(), GetDifficulty(), true);
} }
while(!m_groupList.empty()) while (!m_groupList.empty())
{ {
Group *group = *(m_groupList.begin()); Group* group = *(m_groupList.begin());
group->UnbindInstance(GetMapId(), GetDifficulty(), true); group->UnbindInstance(GetMapId(), GetDifficulty(), true);
} }
} }
@ -239,10 +239,10 @@ void DungeonPersistentState::SaveToDB()
// state instance data too // state instance data too
std::string data; std::string data;
if (Map *map = GetMap()) if (Map* map = GetMap())
{ {
InstanceData *iData = map->GetInstanceData(); InstanceData* iData = map->GetInstanceData();
if(iData && iData->Save()) if (iData && iData->Save())
{ {
data = iData->Save(); data = iData->Save();
CharacterDatabase.escape_string(data); CharacterDatabase.escape_string(data);
@ -276,8 +276,8 @@ InstanceTemplate const* DungeonPersistentState::GetTemplate() const
time_t DungeonPersistentState::GetResetTimeForDB() const time_t DungeonPersistentState::GetResetTimeForDB() const
{ {
// only state the reset time for normal instances // only state the reset time for normal instances
const MapEntry *entry = sMapStore.LookupEntry(GetMapId()); const MapEntry* entry = sMapStore.LookupEntry(GetMapId());
if(!entry || entry->map_type == MAP_RAID || GetDifficulty() == DUNGEON_DIFFICULTY_HEROIC) if (!entry || entry->map_type == MAP_RAID || GetDifficulty() == DUNGEON_DIFFICULTY_HEROIC)
return 0; return 0;
else else
return GetResetTime(); return GetResetTime();
@ -353,8 +353,8 @@ void DungeonResetScheduler::LoadResetTimes()
typedef std::map<uint32, ResetTimeMapDiffType> InstResetTimeMapDiffType; typedef std::map<uint32, ResetTimeMapDiffType> InstResetTimeMapDiffType;
InstResetTimeMapDiffType instResetTime; InstResetTimeMapDiffType instResetTime;
QueryResult *result = CharacterDatabase.Query("SELECT id, map, difficulty, resettime FROM instance WHERE resettime > 0"); QueryResult* result = CharacterDatabase.Query("SELECT id, map, difficulty, resettime FROM instance WHERE resettime > 0");
if( result ) if (result)
{ {
do do
{ {
@ -380,7 +380,7 @@ void DungeonResetScheduler::LoadResetTimes()
// update reset time for normal instances with the max creature respawn time + X hours // update reset time for normal instances with the max creature respawn time + X hours
result = CharacterDatabase.Query("SELECT MAX(respawntime), instance FROM creature_respawn WHERE instance > 0 GROUP BY instance"); result = CharacterDatabase.Query("SELECT MAX(respawntime), instance FROM creature_respawn WHERE instance > 0 GROUP BY instance");
if( result ) if (result)
{ {
do do
{ {
@ -390,7 +390,7 @@ void DungeonResetScheduler::LoadResetTimes()
uint32 instance = fields[1].GetUInt32(); uint32 instance = fields[1].GetUInt32();
InstResetTimeMapDiffType::iterator itr = instResetTime.find(instance); InstResetTimeMapDiffType::iterator itr = instResetTime.find(instance);
if(itr != instResetTime.end() && itr->second.second != resettime) if (itr != instResetTime.end() && itr->second.second != resettime)
{ {
CharacterDatabase.DirectPExecute("UPDATE instance SET resettime = '"UI64FMTD"' WHERE id = '%u'", uint64(resettime), instance); CharacterDatabase.DirectPExecute("UPDATE instance SET resettime = '"UI64FMTD"' WHERE id = '%u'", uint64(resettime), instance);
itr->second.second = resettime; itr->second.second = resettime;
@ -401,15 +401,15 @@ void DungeonResetScheduler::LoadResetTimes()
} }
// schedule the reset times // schedule the reset times
for(InstResetTimeMapDiffType::iterator itr = instResetTime.begin(); itr != instResetTime.end(); ++itr) for (InstResetTimeMapDiffType::iterator itr = instResetTime.begin(); itr != instResetTime.end(); ++itr)
if(itr->second.second > now) if (itr->second.second > now)
ScheduleReset(true, itr->second.second, DungeonResetEvent(RESET_EVENT_NORMAL_DUNGEON, PAIR32_LOPART(itr->second.first),Difficulty(PAIR32_HIPART(itr->second.first)),itr->first)); ScheduleReset(true, itr->second.second, DungeonResetEvent(RESET_EVENT_NORMAL_DUNGEON, PAIR32_LOPART(itr->second.first),Difficulty(PAIR32_HIPART(itr->second.first)),itr->first));
} }
// load the global respawn times for raid/heroic instances // load the global respawn times for raid/heroic instances
uint32 diff = sWorld.getConfig(CONFIG_UINT32_INSTANCE_RESET_TIME_HOUR) * HOUR; uint32 diff = sWorld.getConfig(CONFIG_UINT32_INSTANCE_RESET_TIME_HOUR) * HOUR;
result = CharacterDatabase.Query("SELECT mapid, difficulty, resettime FROM instance_reset"); result = CharacterDatabase.Query("SELECT mapid, difficulty, resettime FROM instance_reset");
if(result) if (result)
{ {
do do
{ {
@ -430,11 +430,12 @@ void DungeonResetScheduler::LoadResetTimes()
// update the reset time if the hour in the configs changes // update the reset time if the hour in the configs changes
uint64 newresettime = (oldresettime / DAY) * DAY + diff; uint64 newresettime = (oldresettime / DAY) * DAY + diff;
if(oldresettime != newresettime) if (oldresettime != newresettime)
CharacterDatabase.DirectPExecute("UPDATE instance_reset SET resettime = '"UI64FMTD"' WHERE mapid = '%u' AND difficulty = '%u'", newresettime, mapid, difficulty); CharacterDatabase.DirectPExecute("UPDATE instance_reset SET resettime = '"UI64FMTD"' WHERE mapid = '%u' AND difficulty = '%u'", newresettime, mapid, difficulty);
SetResetTimeFor(mapid,difficulty,newresettime); SetResetTimeFor(mapid,difficulty,newresettime);
} while(result->NextRow()); }
while (result->NextRow());
delete result; delete result;
} }
@ -444,7 +445,7 @@ void DungeonResetScheduler::LoadResetTimes()
// calculate new global reset times for expired instances and those that have never been reset yet // calculate new global reset times for expired instances and those that have never been reset yet
// add the global reset times to the priority queue // add the global reset times to the priority queue
for(MapDifficultyMap::const_iterator itr = sMapDifficultyMap.begin(); itr != sMapDifficultyMap.end(); ++itr) for (MapDifficultyMap::const_iterator itr = sMapDifficultyMap.begin(); itr != sMapDifficultyMap.end(); ++itr)
{ {
uint32 map_diff_pair = itr->first; uint32 map_diff_pair = itr->first;
uint32 mapid = PAIR32_LOPART(map_diff_pair); uint32 mapid = PAIR32_LOPART(map_diff_pair);
@ -461,14 +462,14 @@ void DungeonResetScheduler::LoadResetTimes()
uint32 period = GetMaxResetTimeFor(mapDiff); uint32 period = GetMaxResetTimeFor(mapDiff);
time_t t = GetResetTimeFor(mapid,difficulty); time_t t = GetResetTimeFor(mapid,difficulty);
if(!t) if (!t)
{ {
// initialize the reset time // initialize the reset time
t = today + period + diff; t = today + period + diff;
CharacterDatabase.DirectPExecute("INSERT INTO instance_reset VALUES ('%u','%u','"UI64FMTD"')", mapid, difficulty, (uint64)t); CharacterDatabase.DirectPExecute("INSERT INTO instance_reset VALUES ('%u','%u','"UI64FMTD"')", mapid, difficulty, (uint64)t);
} }
if(t < now) if (t < now)
{ {
// assume that expired instances have already been cleaned // assume that expired instances have already been cleaned
// calculate the next reset time // calculate the next reset time
@ -481,8 +482,8 @@ void DungeonResetScheduler::LoadResetTimes()
// schedule the global reset/warning // schedule the global reset/warning
ResetEventType type = RESET_EVENT_INFORM_1; ResetEventType type = RESET_EVENT_INFORM_1;
for(; type < RESET_EVENT_INFORM_LAST; type = ResetEventType(type+1)) for (; type < RESET_EVENT_INFORM_LAST; type = ResetEventType(type+1))
if(t - resetEventTypeDelay[type] > now) if (t - resetEventTypeDelay[type] > now)
break; break;
ScheduleReset(true, t - resetEventTypeDelay[type], DungeonResetEvent(type, mapid, difficulty, 0)); ScheduleReset(true, t - resetEventTypeDelay[type], DungeonResetEvent(type, mapid, difficulty, 0));
@ -499,7 +500,7 @@ void DungeonResetScheduler::ScheduleReset(bool add, time_t time, DungeonResetEve
ResetTimeQueue::iterator itr; ResetTimeQueue::iterator itr;
std::pair<ResetTimeQueue::iterator, ResetTimeQueue::iterator> range; std::pair<ResetTimeQueue::iterator, ResetTimeQueue::iterator> range;
range = m_resetTimeQueue.equal_range(time); range = m_resetTimeQueue.equal_range(time);
for(itr = range.first; itr != range.second; ++itr) for (itr = range.first; itr != range.second; ++itr)
{ {
if (itr->second == event) if (itr->second == event)
{ {
@ -508,18 +509,18 @@ void DungeonResetScheduler::ScheduleReset(bool add, time_t time, DungeonResetEve
} }
} }
// in case the reset time changed (should happen very rarely), we search the whole queue // in case the reset time changed (should happen very rarely), we search the whole queue
if(itr == range.second) if (itr == range.second)
{ {
for(itr = m_resetTimeQueue.begin(); itr != m_resetTimeQueue.end(); ++itr) for (itr = m_resetTimeQueue.begin(); itr != m_resetTimeQueue.end(); ++itr)
{ {
if(itr->second == event) if (itr->second == event)
{ {
m_resetTimeQueue.erase(itr); m_resetTimeQueue.erase(itr);
return; return;
} }
} }
if(itr == m_resetTimeQueue.end()) if (itr == m_resetTimeQueue.end())
sLog.outError("DungeonResetScheduler::ScheduleReset: cannot cancel the reset, the event(%d,%d,%d) was not found!", event.type, event.mapid, event.instanceId); sLog.outError("DungeonResetScheduler::ScheduleReset: cannot cancel the reset, the event(%d,%d,%d) was not found!", event.type, event.mapid, event.instanceId);
} }
} }
@ -528,9 +529,9 @@ void DungeonResetScheduler::ScheduleReset(bool add, time_t time, DungeonResetEve
void DungeonResetScheduler::Update() void DungeonResetScheduler::Update()
{ {
time_t now = time(NULL), t; time_t now = time(NULL), t;
while(!m_resetTimeQueue.empty() && (t = m_resetTimeQueue.begin()->first) < now) while (!m_resetTimeQueue.empty() && (t = m_resetTimeQueue.begin()->first) < now)
{ {
DungeonResetEvent &event = m_resetTimeQueue.begin()->second; DungeonResetEvent& event = m_resetTimeQueue.begin()->second;
if (event.type == RESET_EVENT_NORMAL_DUNGEON) if (event.type == RESET_EVENT_NORMAL_DUNGEON)
{ {
// for individual normal instances, max creature respawn + X hours // for individual normal instances, max creature respawn + X hours
@ -597,7 +598,7 @@ MapPersistentStateManager::~MapPersistentStateManager()
*/ */
MapPersistentState* MapPersistentStateManager::AddPersistentState(MapEntry const* mapEntry, uint32 instanceId, Difficulty difficulty, time_t resetTime, bool canReset, bool load /*=false*/, bool initPools /*= true*/, uint32 completedEncountersMask /*= 0*/) MapPersistentState* MapPersistentStateManager::AddPersistentState(MapEntry const* mapEntry, uint32 instanceId, Difficulty difficulty, time_t resetTime, bool canReset, bool load /*=false*/, bool initPools /*= true*/, uint32 completedEncountersMask /*= 0*/)
{ {
if (MapPersistentState *old_save = GetPersistentState(mapEntry->MapID, instanceId)) if (MapPersistentState* old_save = GetPersistentState(mapEntry->MapID, instanceId))
return old_save; return old_save;
if (mapEntry->IsDungeon()) if (mapEntry->IsDungeon())
@ -619,7 +620,7 @@ MapPersistentState* MapPersistentStateManager::AddPersistentState(MapEntry const
DEBUG_LOG("MapPersistentStateManager::AddPersistentState: mapid = %d, instanceid = %d, reset time = %u, canRset = %u", mapEntry->MapID, instanceId, resetTime, canReset ? 1 : 0); DEBUG_LOG("MapPersistentStateManager::AddPersistentState: mapid = %d, instanceid = %d, reset time = %u, canRset = %u", mapEntry->MapID, instanceId, resetTime, canReset ? 1 : 0);
MapPersistentState *state; MapPersistentState* state;
if (mapEntry->IsDungeon()) if (mapEntry->IsDungeon())
{ {
DungeonPersistentState* dungeonState = new DungeonPersistentState(mapEntry->MapID, instanceId, difficulty, resetTime, canReset, completedEncountersMask); DungeonPersistentState* dungeonState = new DungeonPersistentState(mapEntry->MapID, instanceId, difficulty, resetTime, canReset, completedEncountersMask);
@ -644,7 +645,7 @@ MapPersistentState* MapPersistentStateManager::AddPersistentState(MapEntry const
return state; return state;
} }
MapPersistentState *MapPersistentStateManager::GetPersistentState(uint32 mapId, uint32 instanceId) MapPersistentState* MapPersistentStateManager::GetPersistentState(uint32 mapId, uint32 instanceId)
{ {
if (instanceId) if (instanceId)
{ {
@ -698,7 +699,7 @@ void MapPersistentStateManager::RemovePersistentState(uint32 mapId, uint32 insta
} }
} }
void MapPersistentStateManager::_DelHelper(DatabaseType &db, const char *fields, const char *table, const char *queryTail,...) void MapPersistentStateManager::_DelHelper(DatabaseType& db, const char* fields, const char* table, const char* queryTail,...)
{ {
Tokens fieldTokens = StrSplit(fields, ", "); Tokens fieldTokens = StrSplit(fields, ", ");
MANGOS_ASSERT(fieldTokens.size() != 0); MANGOS_ASSERT(fieldTokens.size() != 0);
@ -706,24 +707,25 @@ void MapPersistentStateManager::_DelHelper(DatabaseType &db, const char *fields,
va_list ap; va_list ap;
char szQueryTail [MAX_QUERY_LEN]; char szQueryTail [MAX_QUERY_LEN];
va_start(ap, queryTail); va_start(ap, queryTail);
vsnprintf( szQueryTail, MAX_QUERY_LEN, queryTail, ap ); vsnprintf(szQueryTail, MAX_QUERY_LEN, queryTail, ap);
va_end(ap); va_end(ap);
QueryResult *result = db.PQuery("SELECT %s FROM %s %s", fields, table, szQueryTail); QueryResult* result = db.PQuery("SELECT %s FROM %s %s", fields, table, szQueryTail);
if(result) if (result)
{ {
do do
{ {
Field *fields = result->Fetch(); Field* fields = result->Fetch();
std::ostringstream ss; std::ostringstream ss;
for(size_t i = 0; i < fieldTokens.size(); i++) for (size_t i = 0; i < fieldTokens.size(); i++)
{ {
std::string fieldValue = fields[i].GetCppString(); std::string fieldValue = fields[i].GetCppString();
db.escape_string(fieldValue); db.escape_string(fieldValue);
ss << (i != 0 ? " AND " : "") << fieldTokens[i] << " = '" << fieldValue << "'"; ss << (i != 0 ? " AND " : "") << fieldTokens[i] << " = '" << fieldValue << "'";
} }
db.PExecute("DELETE FROM %s WHERE %s", table, ss.str().c_str()); db.PExecute("DELETE FROM %s WHERE %s", table, ss.str().c_str());
} while (result->NextRow()); }
while (result->NextRow());
delete result; delete result;
} }
} }
@ -756,7 +758,7 @@ void MapPersistentStateManager::CleanupInstances()
bar.step(); bar.step();
sLog.outString(); sLog.outString();
sLog.outString( ">> Instances cleaned up"); sLog.outString(">> Instances cleaned up");
} }
void MapPersistentStateManager::PackInstances() void MapPersistentStateManager::PackInstances()
@ -770,12 +772,12 @@ void MapPersistentStateManager::PackInstances()
// all valid ids are in the instance table // all valid ids are in the instance table
// any associations to ids not in this table are assumed to be // any associations to ids not in this table are assumed to be
// cleaned already in CleanupInstances // cleaned already in CleanupInstances
QueryResult *result = CharacterDatabase.Query("SELECT id FROM instance"); QueryResult* result = CharacterDatabase.Query("SELECT id FROM instance");
if( result ) if (result)
{ {
do do
{ {
Field *fields = result->Fetch(); Field* fields = result->Fetch();
InstanceSet.insert(fields[0].GetUInt32()); InstanceSet.insert(fields[0].GetUInt32());
} }
while (result->NextRow()); while (result->NextRow());
@ -807,11 +809,11 @@ void MapPersistentStateManager::PackInstances()
bar.step(); bar.step();
} }
sLog.outString( ">> Instance numbers remapped, next instance id is %u", InstanceNumber ); sLog.outString(">> Instance numbers remapped, next instance id is %u", InstanceNumber);
sLog.outString(); sLog.outString();
} }
void MapPersistentStateManager::_ResetSave(PersistentStateMap& holder, PersistentStateMap::iterator &itr) void MapPersistentStateManager::_ResetSave(PersistentStateMap& holder, PersistentStateMap::iterator& itr)
{ {
// unbind all players bound to the instance // unbind all players bound to the instance
// do not allow UnbindInstance to automatically unload the InstanceSaves // do not allow UnbindInstance to automatically unload the InstanceSaves
@ -829,7 +831,7 @@ void MapPersistentStateManager::_ResetInstance(uint32 mapid, uint32 instanceId)
if (itr != m_instanceSaveByInstanceId.end()) if (itr != m_instanceSaveByInstanceId.end())
{ {
// delay reset until map unload for loaded map // delay reset until map unload for loaded map
if (Map * iMap = itr->second->GetMap()) if (Map* iMap = itr->second->GetMap())
{ {
MANGOS_ASSERT(iMap->IsDungeon()); MANGOS_ASSERT(iMap->IsDungeon());
@ -847,7 +849,7 @@ void MapPersistentStateManager::_ResetInstance(uint32 mapid, uint32 instanceId)
void MapPersistentStateManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficulty, bool warn, uint32 timeLeft) void MapPersistentStateManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficulty, bool warn, uint32 timeLeft)
{ {
// global reset for all instances of the given map // global reset for all instances of the given map
MapEntry const *mapEntry = sMapStore.LookupEntry(mapid); MapEntry const* mapEntry = sMapStore.LookupEntry(mapid);
if (!mapEntry->Instanceable()) if (!mapEntry->Instanceable())
return; return;
@ -863,7 +865,7 @@ void MapPersistentStateManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficu
} }
// remove all binds to instances of the given map // remove all binds to instances of the given map
for(PersistentStateMap::iterator itr = m_instanceSaveByInstanceId.begin(); itr != m_instanceSaveByInstanceId.end();) for (PersistentStateMap::iterator itr = m_instanceSaveByInstanceId.begin(); itr != m_instanceSaveByInstanceId.end();)
{ {
if (itr->second->GetMapId() == mapid && itr->second->GetDifficulty() == difficulty) if (itr->second->GetMapId() == mapid && itr->second->GetDifficulty() == difficulty)
_ResetSave(m_instanceSaveByInstanceId, itr); _ResetSave(m_instanceSaveByInstanceId, itr);
@ -888,10 +890,10 @@ void MapPersistentStateManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficu
const MapManager::MapMapType& maps = sMapMgr.Maps(); const MapManager::MapMapType& maps = sMapMgr.Maps();
MapManager::MapMapType::const_iterator iter_last = maps.lower_bound(MapID(mapid + 1)); MapManager::MapMapType::const_iterator iter_last = maps.lower_bound(MapID(mapid + 1));
for(MapManager::MapMapType::const_iterator mitr = maps.lower_bound(MapID(mapid)); mitr != iter_last; ++mitr) for (MapManager::MapMapType::const_iterator mitr = maps.lower_bound(MapID(mapid)); mitr != iter_last; ++mitr)
{ {
Map *map2 = mitr->second; Map* map2 = mitr->second;
if(map2->GetId() != mapid) if (map2->GetId() != mapid)
break; break;
if (warn) if (warn)
@ -908,7 +910,7 @@ void MapPersistentStateManager::GetStatistics(uint32& numStates, uint32& numBoun
numBoundGroups = 0; numBoundGroups = 0;
// only instanceable maps have bounds // only instanceable maps have bounds
for(PersistentStateMap::iterator itr = m_instanceSaveByInstanceId.begin(); itr != m_instanceSaveByInstanceId.end(); ++itr) for (PersistentStateMap::iterator itr = m_instanceSaveByInstanceId.begin(); itr != m_instanceSaveByInstanceId.end(); ++itr)
{ {
if (!itr->second->GetMapEntry()->IsDungeon()) if (!itr->second->GetMapEntry()->IsDungeon())
continue; continue;
@ -919,16 +921,16 @@ void MapPersistentStateManager::GetStatistics(uint32& numStates, uint32& numBoun
} }
} }
void MapPersistentStateManager::_CleanupExpiredInstancesAtTime( time_t t ) void MapPersistentStateManager::_CleanupExpiredInstancesAtTime(time_t t)
{ {
_DelHelper(CharacterDatabase, "id, map, instance.difficulty", "instance", "LEFT JOIN instance_reset ON mapid = map AND instance.difficulty = instance_reset.difficulty WHERE (instance.resettime < '"UI64FMTD"' AND instance.resettime > '0') OR (NOT instance_reset.resettime IS NULL AND instance_reset.resettime < '"UI64FMTD"')", (uint64)t, (uint64)t); _DelHelper(CharacterDatabase, "id, map, instance.difficulty", "instance", "LEFT JOIN instance_reset ON mapid = map AND instance.difficulty = instance_reset.difficulty WHERE (instance.resettime < '"UI64FMTD"' AND instance.resettime > '0') OR (NOT instance_reset.resettime IS NULL AND instance_reset.resettime < '"UI64FMTD"')", (uint64)t, (uint64)t);
} }
void MapPersistentStateManager::InitWorldMaps() void MapPersistentStateManager::InitWorldMaps()
{ {
MapPersistentState* state = NULL; // need any from created for shared pool state MapPersistentState* state = NULL; // need any from created for shared pool state
for(uint32 mapid = 0; mapid < sMapStore.GetNumRows(); ++mapid) for (uint32 mapid = 0; mapid < sMapStore.GetNumRows(); ++mapid)
if (MapEntry const* entry = sMapStore.LookupEntry(mapid)) if (MapEntry const* entry = sMapStore.LookupEntry(mapid))
if (!entry->Instanceable()) if (!entry->Instanceable())
state = AddPersistentState(entry, 0, REGULAR_DIFFICULTY, 0, false, true, false); state = AddPersistentState(entry, 0, REGULAR_DIFFICULTY, 0, false, true, false);
@ -945,7 +947,7 @@ void MapPersistentStateManager::LoadCreatureRespawnTimes()
uint32 count = 0; uint32 count = 0;
// 0 1 2 3 4 5 6 // 0 1 2 3 4 5 6
QueryResult *result = CharacterDatabase.Query("SELECT guid, respawntime, map, instance, difficulty, resettime, encountersMask FROM creature_respawn LEFT JOIN instance ON instance = id"); QueryResult* result = CharacterDatabase.Query("SELECT guid, respawntime, map, instance, difficulty, resettime, encountersMask FROM creature_respawn LEFT JOIN instance ON instance = id");
if (!result) if (!result)
{ {
BarGoLink bar(1); BarGoLink bar(1);
@ -994,7 +996,8 @@ void MapPersistentStateManager::LoadCreatureRespawnTimes()
++count; ++count;
} while (result->NextRow()); }
while (result->NextRow());
delete result; delete result;
@ -1010,7 +1013,7 @@ void MapPersistentStateManager::LoadGameobjectRespawnTimes()
uint32 count = 0; uint32 count = 0;
// 0 1 2 3 4 5 6 // 0 1 2 3 4 5 6
QueryResult *result = CharacterDatabase.Query("SELECT guid, respawntime, map, instance, difficulty, resettime, encountersMask FROM gameobject_respawn LEFT JOIN instance ON instance = id"); QueryResult* result = CharacterDatabase.Query("SELECT guid, respawntime, map, instance, difficulty, resettime, encountersMask FROM gameobject_respawn LEFT JOIN instance ON instance = id");
if (!result) if (!result)
{ {
@ -1060,7 +1063,8 @@ void MapPersistentStateManager::LoadGameobjectRespawnTimes()
++count; ++count;
} while (result->NextRow()); }
while (result->NextRow());
delete result; delete result;

View file

@ -56,7 +56,7 @@ class MapPersistentStateManager;
class MapPersistentState class MapPersistentState
{ {
friend class MapPersistentStateManager; friend class MapPersistentStateManager;
protected: protected:
MapPersistentState(uint16 MapId, uint32 InstanceId, Difficulty difficulty); MapPersistentState(uint16 MapId, uint32 InstanceId, Difficulty difficulty);
@ -193,11 +193,11 @@ class DungeonPersistentState : public MapPersistentState
/* online players bound to the instance (perm/solo) /* online players bound to the instance (perm/solo)
does not include the members of the group unless they have permanent saves */ does not include the members of the group unless they have permanent saves */
void AddPlayer(Player *player) { m_playerList.push_back(player); } void AddPlayer(Player* player) { m_playerList.push_back(player); }
bool RemovePlayer(Player *player) { m_playerList.remove(player); return UnloadIfEmpty(); } bool RemovePlayer(Player* player) { m_playerList.remove(player); return UnloadIfEmpty(); }
/* all groups bound to the instance */ /* all groups bound to the instance */
void AddGroup(Group *group) { m_groupList.push_back(group); } void AddGroup(Group* group) { m_groupList.push_back(group); }
bool RemoveGroup(Group *group) { m_groupList.remove(group); return UnloadIfEmpty(); } bool RemoveGroup(Group* group) { m_groupList.remove(group); return UnloadIfEmpty(); }
/* for normal instances this corresponds to max(creature respawn time) + X hours /* for normal instances this corresponds to max(creature respawn time) + X hours
for raid/heroic instances this caches the global respawn time for the map */ for raid/heroic instances this caches the global respawn time for the map */
@ -329,7 +329,7 @@ class DungeonResetScheduler
class MANGOS_DLL_DECL MapPersistentStateManager : public MaNGOS::Singleton<MapPersistentStateManager, MaNGOS::ClassLevelLockable<MapPersistentStateManager, ACE_Thread_Mutex> > class MANGOS_DLL_DECL MapPersistentStateManager : public MaNGOS::Singleton<MapPersistentStateManager, MaNGOS::ClassLevelLockable<MapPersistentStateManager, ACE_Thread_Mutex> >
{ {
friend class DungeonResetScheduler; friend class DungeonResetScheduler;
public: // constructors public: // constructors
MapPersistentStateManager(); MapPersistentStateManager();
~MapPersistentStateManager(); ~MapPersistentStateManager();
@ -346,7 +346,7 @@ class MANGOS_DLL_DECL MapPersistentStateManager : public MaNGOS::Singleton<MapPe
MapPersistentState* AddPersistentState(MapEntry const* mapEntry, uint32 instanceId, Difficulty difficulty, time_t resetTime, bool canReset, bool load = false, bool initPools = true, uint32 completedEncountersMask = 0); MapPersistentState* AddPersistentState(MapEntry const* mapEntry, uint32 instanceId, Difficulty difficulty, time_t resetTime, bool canReset, bool load = false, bool initPools = true, uint32 completedEncountersMask = 0);
// search stored state, can be NULL in result // search stored state, can be NULL in result
MapPersistentState *GetPersistentState(uint32 mapId, uint32 InstanceId); MapPersistentState* GetPersistentState(uint32 mapId, uint32 InstanceId);
void RemovePersistentState(uint32 mapId, uint32 instanceId); void RemovePersistentState(uint32 mapId, uint32 instanceId);
@ -372,8 +372,8 @@ class MANGOS_DLL_DECL MapPersistentStateManager : public MaNGOS::Singleton<MapPe
void _ResetInstance(uint32 mapid, uint32 instanceId); void _ResetInstance(uint32 mapid, uint32 instanceId);
void _CleanupExpiredInstancesAtTime(time_t t); void _CleanupExpiredInstancesAtTime(time_t t);
void _ResetSave(PersistentStateMap& holder, PersistentStateMap::iterator &itr); void _ResetSave(PersistentStateMap& holder, PersistentStateMap::iterator& itr);
void _DelHelper(DatabaseType &db, const char *fields, const char *table, const char *queryTail,...); void _DelHelper(DatabaseType& db, const char* fields, const char* table, const char* queryTail,...);
// used during global instance resets // used during global instance resets
bool lock_instLists; bool lock_instLists;
@ -394,7 +394,7 @@ inline void MapPersistentStateManager::DoForAllStatesWithMapId(uint32 mapId, Do&
if (mapEntry->Instanceable()) if (mapEntry->Instanceable())
{ {
for(PersistentStateMap::iterator itr = m_instanceSaveByInstanceId.begin(); itr != m_instanceSaveByInstanceId.end();) for (PersistentStateMap::iterator itr = m_instanceSaveByInstanceId.begin(); itr != m_instanceSaveByInstanceId.end();)
{ {
if (itr->second->GetMapId() == mapId) if (itr->second->GetMapId() == mapId)
_do((itr++)->second); _do((itr++)->second);

View file

@ -34,7 +34,7 @@ class MANGOS_DLL_SPEC MapReference : public Reference<Map, Player>
void targetObjectDestroyLink() void targetObjectDestroyLink()
{ {
// called from unlink() // called from unlink()
if(isValid()) getTarget()->m_mapRefManager.decSize(); if (isValid()) getTarget()->m_mapRefManager.decSize();
} }
void sourceObjectDestroyLink() void sourceObjectDestroyLink()
{ {
@ -44,9 +44,9 @@ class MANGOS_DLL_SPEC MapReference : public Reference<Map, Player>
public: public:
MapReference() : Reference<Map, Player>() {} MapReference() : Reference<Map, Player>() {}
~MapReference() { unlink(); } ~MapReference() { unlink(); }
MapReference *next() { return (MapReference*)Reference<Map, Player>::next(); } MapReference* next() { return (MapReference*)Reference<Map, Player>::next(); }
MapReference const *next() const { return (MapReference const*)Reference<Map, Player>::next(); } MapReference const* next() const { return (MapReference const*)Reference<Map, Player>::next(); }
MapReference *nockeck_prev() { return (MapReference*)Reference<Map, Player>::nocheck_prev(); } MapReference* nockeck_prev() { return (MapReference*)Reference<Map, Player>::nocheck_prev(); }
MapReference const *nocheck_prev() const { return (MapReference const*)Reference<Map, Player>::nocheck_prev(); } MapReference const* nocheck_prev() const { return (MapReference const*)Reference<Map, Player>::nocheck_prev(); }
}; };
#endif #endif

View file

@ -49,7 +49,7 @@ void MassMailMgr::AddMassMailTask(MailDraft* mailProto, MailSender sender, uint3
struct MassMailerQueryHandler struct MassMailerQueryHandler
{ {
void HandleQueryCallback(QueryResult * result, MailDraft* mailProto, MailSender sender) void HandleQueryCallback(QueryResult* result, MailDraft* mailProto, MailSender sender)
{ {
if (!result) if (!result)
return; return;
@ -58,10 +58,11 @@ struct MassMailerQueryHandler
do do
{ {
Field *fields = result->Fetch(); Field* fields = result->Fetch();
recievers.insert(fields[0].GetUInt32()); recievers.insert(fields[0].GetUInt32());
} while (result->NextRow()); }
while (result->NextRow());
delete result; delete result;
} }
} massMailerQueryHandler; } massMailerQueryHandler;
@ -88,7 +89,7 @@ void MassMailMgr::Update(bool sendall /*= false*/)
task.m_receivers.erase(task.m_receivers.begin()); task.m_receivers.erase(task.m_receivers.begin());
ObjectGuid receiver_guid = ObjectGuid(HIGHGUID_PLAYER, receiver_lowguid); ObjectGuid receiver_guid = ObjectGuid(HIGHGUID_PLAYER, receiver_lowguid);
Player *receiver = sObjectMgr.GetPlayer(receiver_guid); Player* receiver = sObjectMgr.GetPlayer(receiver_guid);
// last case. can be just send // last case. can be just send
if (task.m_receivers.empty()) if (task.m_receivers.empty())
@ -115,7 +116,7 @@ void MassMailMgr::Update(bool sendall /*= false*/)
if (task.m_receivers.empty()) if (task.m_receivers.empty())
m_massMails.pop_front(); m_massMails.pop_front();
} }
while(!m_massMails.empty() && (sendall || maxcount > 0)); while (!m_massMails.empty() && (sendall || maxcount > 0));
} }
void MassMailMgr::GetStatistic(uint32& tasks, uint32& mails, uint32& needTime) const void MassMailMgr::GetStatistic(uint32& tasks, uint32& mails, uint32& needTime) const

File diff suppressed because it is too large Load diff

View file

@ -34,7 +34,7 @@
#include <cassert> #include <cassert>
inline bool isStatic(MovementGenerator *mv) inline bool isStatic(MovementGenerator* mv)
{ {
return (mv == &si_idleMovement); return (mv == &si_idleMovement);
} }
@ -62,9 +62,9 @@ void MotionMaster::Initialize()
MotionMaster::~MotionMaster() MotionMaster::~MotionMaster()
{ {
// just deallocate movement generator, but do not Finalize since it may access to already deallocated owner's memory // just deallocate movement generator, but do not Finalize since it may access to already deallocated owner's memory
while(!empty()) while (!empty())
{ {
MovementGenerator * m = top(); MovementGenerator* m = top();
pop(); pop();
if (!isStatic(m)) if (!isStatic(m))
delete m; delete m;
@ -76,7 +76,7 @@ void MotionMaster::UpdateMotion(uint32 diff)
if (m_owner->hasUnitState(UNIT_STAT_CAN_NOT_MOVE)) if (m_owner->hasUnitState(UNIT_STAT_CAN_NOT_MOVE))
return; return;
MANGOS_ASSERT( !empty() ); MANGOS_ASSERT(!empty());
m_cleanFlag |= MMCF_UPDATE; m_cleanFlag |= MMCF_UPDATE;
if (!top()->Update(*m_owner, diff)) if (!top()->Update(*m_owner, diff))
@ -112,9 +112,9 @@ void MotionMaster::UpdateMotion(uint32 diff)
void MotionMaster::DirectClean(bool reset, bool all) void MotionMaster::DirectClean(bool reset, bool all)
{ {
while( all ? !empty() : size() > 1 ) while (all ? !empty() : size() > 1)
{ {
MovementGenerator *curr = top(); MovementGenerator* curr = top();
pop(); pop();
curr->Finalize(*m_owner); curr->Finalize(*m_owner);
@ -124,7 +124,7 @@ void MotionMaster::DirectClean(bool reset, bool all)
if (!all && reset) if (!all && reset)
{ {
MANGOS_ASSERT( !empty() ); MANGOS_ASSERT(!empty());
top()->Reset(*m_owner); top()->Reset(*m_owner);
} }
} }
@ -142,9 +142,9 @@ void MotionMaster::DelayedClean(bool reset, bool all)
if (!m_expList) if (!m_expList)
m_expList = new ExpireList(); m_expList = new ExpireList();
while( all ? !empty() : size() > 1 ) while (all ? !empty() : size() > 1)
{ {
MovementGenerator *curr = top(); MovementGenerator* curr = top();
pop(); pop();
curr->Finalize(*m_owner); curr->Finalize(*m_owner);
@ -158,13 +158,13 @@ void MotionMaster::DirectExpire(bool reset)
if (empty() || size() == 1) if (empty() || size() == 1)
return; return;
MovementGenerator *curr = top(); MovementGenerator* curr = top();
pop(); pop();
// also drop stored under top() targeted motions // also drop stored under top() targeted motions
while (!empty() && (top()->GetMovementGeneratorType() == CHASE_MOTION_TYPE || top()->GetMovementGeneratorType() == FOLLOW_MOTION_TYPE)) while (!empty() && (top()->GetMovementGeneratorType() == CHASE_MOTION_TYPE || top()->GetMovementGeneratorType() == FOLLOW_MOTION_TYPE))
{ {
MovementGenerator *temp = top(); MovementGenerator* temp = top();
pop(); pop();
temp->Finalize(*m_owner); temp->Finalize(*m_owner);
delete temp; delete temp;
@ -196,7 +196,7 @@ void MotionMaster::DelayedExpire(bool reset)
if (empty() || size() == 1) if (empty() || size() == 1)
return; return;
MovementGenerator *curr = top(); MovementGenerator* curr = top();
pop(); pop();
if (!m_expList) if (!m_expList)
@ -205,10 +205,10 @@ void MotionMaster::DelayedExpire(bool reset)
// also drop stored under top() targeted motions // also drop stored under top() targeted motions
while (!empty() && (top()->GetMovementGeneratorType() == CHASE_MOTION_TYPE || top()->GetMovementGeneratorType() == FOLLOW_MOTION_TYPE)) while (!empty() && (top()->GetMovementGeneratorType() == CHASE_MOTION_TYPE || top()->GetMovementGeneratorType() == FOLLOW_MOTION_TYPE))
{ {
MovementGenerator *temp = top(); MovementGenerator* temp = top();
pop(); pop();
temp ->Finalize(*m_owner); temp ->Finalize(*m_owner);
m_expList->push_back(temp ); m_expList->push_back(temp);
} }
curr->Finalize(*m_owner); curr->Finalize(*m_owner);
@ -233,8 +233,8 @@ void MotionMaster::MoveRandomAroundPoint(float x, float y, float z, float radius
{ {
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s move random.", m_owner->GetGuidStr().c_str()); DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s move random.", m_owner->GetGuidStr().c_str());
Mutate(new RandomMovementGenerator<Creature>(x, y, z, radius, verticalZ)); Mutate(new RandomMovementGenerator<Creature>(x, y, z, radius, verticalZ));
} }
} }
void MotionMaster::MoveTargetedHome() void MotionMaster::MoveTargetedHome()
{ {
@ -256,7 +256,7 @@ void MotionMaster::MoveTargetedHome()
} }
else if (m_owner->GetTypeId() == TYPEID_UNIT && ((Creature*)m_owner)->GetCharmerOrOwnerGuid()) else if (m_owner->GetTypeId() == TYPEID_UNIT && ((Creature*)m_owner)->GetCharmerOrOwnerGuid())
{ {
if (Unit *target = ((Creature*)m_owner)->GetCharmerOrOwner()) if (Unit* target = ((Creature*)m_owner)->GetCharmerOrOwner())
{ {
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s follow to %s", m_owner->GetGuidStr().c_str(), target->GetGuidStr().c_str()); DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s follow to %s", m_owner->GetGuidStr().c_str(), target->GetGuidStr().c_str());
Mutate(new FollowMovementGenerator<Creature>(*target,PET_FOLLOW_DIST,PET_FOLLOW_ANGLE)); Mutate(new FollowMovementGenerator<Creature>(*target,PET_FOLLOW_DIST,PET_FOLLOW_ANGLE));
@ -315,7 +315,7 @@ void MotionMaster::MoveFollow(Unit* target, float dist, float angle)
void MotionMaster::MovePoint(uint32 id, float x, float y, float z, bool generatePath) void MotionMaster::MovePoint(uint32 id, float x, float y, float z, bool generatePath)
{ {
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s targeted point (Id: %u X: %f Y: %f Z: %f)", m_owner->GetGuidStr().c_str(), id, x, y, z ); DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s targeted point (Id: %u X: %f Y: %f Z: %f)", m_owner->GetGuidStr().c_str(), id, x, y, z);
if (m_owner->GetTypeId() == TYPEID_PLAYER) if (m_owner->GetTypeId() == TYPEID_PLAYER)
Mutate(new PointMovementGenerator<Player>(id,x,y,z,generatePath)); Mutate(new PointMovementGenerator<Player>(id,x,y,z,generatePath));
@ -332,7 +332,7 @@ void MotionMaster::MoveSeekAssistance(float x, float y, float z)
else else
{ {
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s seek assistance (X: %f Y: %f Z: %f)", DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s seek assistance (X: %f Y: %f Z: %f)",
m_owner->GetGuidStr().c_str(), x, y, z ); m_owner->GetGuidStr().c_str(), x, y, z);
Mutate(new AssistanceMovementGenerator(x,y,z)); Mutate(new AssistanceMovementGenerator(x,y,z));
} }
} }
@ -346,7 +346,7 @@ void MotionMaster::MoveSeekAssistanceDistract(uint32 time)
else else
{ {
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s is distracted after assistance call (Time: %u)", DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s is distracted after assistance call (Time: %u)",
m_owner->GetGuidStr().c_str(), time ); m_owner->GetGuidStr().c_str(), time);
Mutate(new AssistanceDistractMovementGenerator(time)); Mutate(new AssistanceDistractMovementGenerator(time));
} }
} }
@ -403,13 +403,13 @@ void MotionMaster::MoveTaxiFlight(uint32 path, uint32 pathnode)
else else
{ {
sLog.outError("%s attempt taxi to (nonexistent Path %u node %u)", sLog.outError("%s attempt taxi to (nonexistent Path %u node %u)",
m_owner->GetGuidStr().c_str(), path, pathnode); m_owner->GetGuidStr().c_str(), path, pathnode);
} }
} }
else else
{ {
sLog.outError("%s attempt taxi to (Path %u node %u)", sLog.outError("%s attempt taxi to (Path %u node %u)",
m_owner->GetGuidStr().c_str(), path, pathnode); m_owner->GetGuidStr().c_str(), path, pathnode);
} }
} }
@ -420,15 +420,15 @@ void MotionMaster::MoveDistract(uint32 timer)
Mutate(mgen); Mutate(mgen);
} }
void MotionMaster::Mutate(MovementGenerator *m) void MotionMaster::Mutate(MovementGenerator* m)
{ {
if (!empty()) if (!empty())
{ {
switch(top()->GetMovementGeneratorType()) switch (top()->GetMovementGeneratorType())
{ {
// HomeMovement is not that important, delete it if meanwhile a new comes // HomeMovement is not that important, delete it if meanwhile a new comes
case HOME_MOTION_TYPE: case HOME_MOTION_TYPE:
// DistractMovement interrupted by any other movement // DistractMovement interrupted by any other movement
case DISTRACT_MOTION_TYPE: case DISTRACT_MOTION_TYPE:
case EFFECT_MOTION_TYPE: case EFFECT_MOTION_TYPE:
MovementExpired(false); MovementExpired(false);
@ -447,7 +447,7 @@ void MotionMaster::Mutate(MovementGenerator *m)
void MotionMaster::propagateSpeedChange() void MotionMaster::propagateSpeedChange()
{ {
Impl::container_type::iterator it = Impl::c.begin(); Impl::container_type::iterator it = Impl::c.begin();
for ( ;it != end(); ++it) for (; it != end(); ++it)
{ {
(*it)->unitSpeedChanged(); (*it)->unitSpeedChanged();
} }
@ -461,7 +461,7 @@ MovementGeneratorType MotionMaster::GetCurrentMovementGeneratorType() const
return top()->GetMovementGeneratorType(); return top()->GetMovementGeneratorType();
} }
bool MotionMaster::GetDestination(float &x, float &y, float &z) bool MotionMaster::GetDestination(float& x, float& y, float& z)
{ {
if (m_owner->movespline->Finalized()) if (m_owner->movespline->Finalized())
return false; return false;
@ -496,7 +496,7 @@ void MotionMaster::MoveFall()
if (tz <= INVALID_HEIGHT) if (tz <= INVALID_HEIGHT)
{ {
DEBUG_LOG("MotionMaster::MoveFall: unable retrive a proper height at map %u (x: %f, y: %f, z: %f).", DEBUG_LOG("MotionMaster::MoveFall: unable retrive a proper height at map %u (x: %f, y: %f, z: %f).",
m_owner->GetMap()->GetId(), m_owner->GetPositionX(), m_owner->GetPositionY(), m_owner->GetPositionZ()); m_owner->GetMap()->GetId(), m_owner->GetPositionX(), m_owner->GetPositionY(), m_owner->GetPositionZ());
return; return;
} }

View file

@ -58,14 +58,14 @@ enum MMCleanFlag
MMCF_RESET = 2 // Flag if need top()->Reset() MMCF_RESET = 2 // Flag if need top()->Reset()
}; };
class MANGOS_DLL_SPEC MotionMaster : private std::stack<MovementGenerator *> class MANGOS_DLL_SPEC MotionMaster : private std::stack<MovementGenerator*>
{ {
private: private:
typedef std::stack<MovementGenerator *> Impl; typedef std::stack<MovementGenerator*> Impl;
typedef std::vector<MovementGenerator *> ExpireList; typedef std::vector<MovementGenerator*> ExpireList;
public: public:
explicit MotionMaster(Unit *unit) : m_owner(unit), m_expList(NULL), m_cleanFlag(MMCF_NONE) {} explicit MotionMaster(Unit* unit) : m_owner(unit), m_expList(NULL), m_cleanFlag(MMCF_NONE) {}
~MotionMaster(); ~MotionMaster();
void Initialize(); void Initialize();
@ -118,9 +118,9 @@ class MANGOS_DLL_SPEC MotionMaster : private std::stack<MovementGenerator *>
// will only work in MMgens where we have a target (TARGETED_MOTION_TYPE) // will only work in MMgens where we have a target (TARGETED_MOTION_TYPE)
void UpdateFinalDistanceToTarget(float fDistance); void UpdateFinalDistanceToTarget(float fDistance);
bool GetDestination(float &x, float &y, float &z); bool GetDestination(float& x, float& y, float& z);
private: private:
void Mutate(MovementGenerator *m); // use Move* functions instead void Mutate(MovementGenerator* m); // use Move* functions instead
void DirectClean(bool reset, bool all); void DirectClean(bool reset, bool all);
void DelayedClean(bool reset, bool all); void DelayedClean(bool reset, bool all);
@ -128,8 +128,8 @@ class MANGOS_DLL_SPEC MotionMaster : private std::stack<MovementGenerator *>
void DirectExpire(bool reset); void DirectExpire(bool reset);
void DelayedExpire(bool reset); void DelayedExpire(bool reset);
Unit *m_owner; Unit* m_owner;
ExpireList *m_expList; ExpireList* m_expList;
uint8 m_cleanFlag; uint8 m_cleanFlag;
}; };
#endif #endif

View file

@ -27,14 +27,14 @@ namespace MMAP
{ {
// ######################## MMapFactory ######################## // ######################## MMapFactory ########################
// our global singelton copy // our global singelton copy
MMapManager *g_MMapManager = NULL; MMapManager* g_MMapManager = NULL;
// stores list of mapids which do not use pathfinding // stores list of mapids which do not use pathfinding
std::set<uint32>* g_mmapDisabledIds = NULL; std::set<uint32>* g_mmapDisabledIds = NULL;
MMapManager* MMapFactory::createOrGetMMapManager() MMapManager* MMapFactory::createOrGetMMapManager()
{ {
if(g_MMapManager == NULL) if (g_MMapManager == NULL)
g_MMapManager = new MMapManager(); g_MMapManager = new MMapManager();
return g_MMapManager; return g_MMapManager;
@ -42,7 +42,7 @@ namespace MMAP
void MMapFactory::preventPathfindingOnMaps(const char* ignoreMapIds) void MMapFactory::preventPathfindingOnMaps(const char* ignoreMapIds)
{ {
if(!g_mmapDisabledIds) if (!g_mmapDisabledIds)
g_mmapDisabledIds = new std::set<uint32>(); g_mmapDisabledIds = new std::set<uint32>();
uint32 strLenght = strlen(ignoreMapIds)+1; uint32 strLenght = strlen(ignoreMapIds)+1;
@ -62,18 +62,18 @@ namespace MMAP
bool MMapFactory::IsPathfindingEnabled(uint32 mapId) bool MMapFactory::IsPathfindingEnabled(uint32 mapId)
{ {
return sWorld.getConfig(CONFIG_BOOL_MMAP_ENABLED) return sWorld.getConfig(CONFIG_BOOL_MMAP_ENABLED)
&& g_mmapDisabledIds->find(mapId) == g_mmapDisabledIds->end(); && g_mmapDisabledIds->find(mapId) == g_mmapDisabledIds->end();
} }
void MMapFactory::clear() void MMapFactory::clear()
{ {
if(g_mmapDisabledIds) if (g_mmapDisabledIds)
{ {
delete g_mmapDisabledIds; delete g_mmapDisabledIds;
g_mmapDisabledIds = NULL; g_mmapDisabledIds = NULL;
} }
if(g_MMapManager) if (g_MMapManager)
{ {
delete g_MMapManager; delete g_MMapManager;
g_MMapManager = NULL; g_MMapManager = NULL;
@ -98,7 +98,7 @@ namespace MMAP
// load and init dtNavMesh - read parameters from file // load and init dtNavMesh - read parameters from file
uint32 pathLen = sWorld.GetDataPath().length() + strlen("mmaps/%03i.mmap")+1; uint32 pathLen = sWorld.GetDataPath().length() + strlen("mmaps/%03i.mmap")+1;
char *fileName = new char[pathLen]; char* fileName = new char[pathLen];
snprintf(fileName, pathLen, (sWorld.GetDataPath()+"mmaps/%03i.mmap").c_str(), mapId); snprintf(fileName, pathLen, (sWorld.GetDataPath()+"mmaps/%03i.mmap").c_str(), mapId);
FILE* file = fopen(fileName, "rb"); FILE* file = fopen(fileName, "rb");
@ -143,7 +143,7 @@ namespace MMAP
bool MMapManager::loadMap(uint32 mapId, int32 x, int32 y) bool MMapManager::loadMap(uint32 mapId, int32 x, int32 y)
{ {
// make sure the mmap is loaded and ready to load tiles // make sure the mmap is loaded and ready to load tiles
if(!loadMapData(mapId)) if (!loadMapData(mapId))
return false; return false;
// get this mmap data // get this mmap data
@ -160,10 +160,10 @@ namespace MMAP
// load this tile :: mmaps/MMMXXYY.mmtile // load this tile :: mmaps/MMMXXYY.mmtile
uint32 pathLen = sWorld.GetDataPath().length() + strlen("mmaps/%03i%02i%02i.mmtile")+1; uint32 pathLen = sWorld.GetDataPath().length() + strlen("mmaps/%03i%02i%02i.mmtile")+1;
char *fileName = new char[pathLen]; char* fileName = new char[pathLen];
snprintf(fileName, pathLen, (sWorld.GetDataPath()+"mmaps/%03i%02i%02i.mmtile").c_str(), mapId, x, y); snprintf(fileName, pathLen, (sWorld.GetDataPath()+"mmaps/%03i%02i%02i.mmtile").c_str(), mapId, x, y);
FILE *file = fopen(fileName, "rb"); FILE* file = fopen(fileName, "rb");
if (!file) if (!file)
{ {
sLog.outDebug("MMAP:loadMap: Could not open mmtile file '%s'", fileName); sLog.outDebug("MMAP:loadMap: Could not open mmtile file '%s'", fileName);
@ -185,7 +185,7 @@ namespace MMAP
if (fileHeader.mmapVersion != MMAP_VERSION) if (fileHeader.mmapVersion != MMAP_VERSION)
{ {
sLog.outError("MMAP:loadMap: %03u%02i%02i.mmtile was built with generator v%i, expected v%i", sLog.outError("MMAP:loadMap: %03u%02i%02i.mmtile was built with generator v%i, expected v%i",
mapId, x, y, fileHeader.mmapVersion, MMAP_VERSION); mapId, x, y, fileHeader.mmapVersion, MMAP_VERSION);
return false; return false;
} }
@ -193,7 +193,7 @@ namespace MMAP
MANGOS_ASSERT(data); MANGOS_ASSERT(data);
size_t result = fread(data, fileHeader.size, 1, file); size_t result = fread(data, fileHeader.size, 1, file);
if(!result) if (!result)
{ {
sLog.outError("MMAP:loadMap: Bad header or data in mmap %03u%02i%02i.mmtile", mapId, x, y); sLog.outError("MMAP:loadMap: Bad header or data in mmap %03u%02i%02i.mmtile", mapId, x, y);
fclose(file); fclose(file);
@ -243,7 +243,7 @@ namespace MMAP
dtTileRef tileRef = mmap->mmapLoadedTiles[packedGridPos]; dtTileRef tileRef = mmap->mmapLoadedTiles[packedGridPos];
// unload, and mark as non loaded // unload, and mark as non loaded
if(DT_SUCCESS != mmap->navMesh->removeTile(tileRef, NULL, NULL)) if (DT_SUCCESS != mmap->navMesh->removeTile(tileRef, NULL, NULL))
{ {
// this is technically a memory leak // this is technically a memory leak
// if the grid is later reloaded, dtNavMesh::addTile will return error but no extra memory is used // if the grid is later reloaded, dtNavMesh::addTile will return error but no extra memory is used
@ -277,7 +277,7 @@ namespace MMAP
{ {
uint32 x = (i->first >> 16); uint32 x = (i->first >> 16);
uint32 y = (i->first & 0x0000FFFF); uint32 y = (i->first & 0x0000FFFF);
if(DT_SUCCESS != mmap->navMesh->removeTile(i->second, NULL, NULL)) if (DT_SUCCESS != mmap->navMesh->removeTile(i->second, NULL, NULL))
sLog.outError("MMAP:unloadMap: Could not unload %03u%02i%02i.mmtile from navmesh", mapId, x, y); sLog.outError("MMAP:unloadMap: Could not unload %03u%02i%02i.mmtile from navmesh", mapId, x, y);
else else
{ {
@ -335,10 +335,10 @@ namespace MMAP
MMapData* mmap = loadedMMaps[mapId]; MMapData* mmap = loadedMMaps[mapId];
if (mmap->navMeshQueries.find(instanceId) == mmap->navMeshQueries.end()) if (mmap->navMeshQueries.find(instanceId) == mmap->navMeshQueries.end())
{ {
// allocate mesh query // allocate mesh query
dtNavMeshQuery* query = dtAllocNavMeshQuery(); dtNavMeshQuery* query = dtAllocNavMeshQuery();
MANGOS_ASSERT(query); MANGOS_ASSERT(query);
if(DT_SUCCESS != query->init(mmap->navMesh, 1024)) if (DT_SUCCESS != query->init(mmap->navMesh, 1024))
{ {
dtFreeNavMeshQuery(query); dtFreeNavMeshQuery(query);
sLog.outError("MMAP:GetNavMeshQuery: Failed to initialize dtNavMeshQuery for mapId %03u instanceId %u", mapId, instanceId); sLog.outError("MMAP:GetNavMeshQuery: Failed to initialize dtNavMeshQuery for mapId %03u instanceId %u", mapId, instanceId);

View file

@ -33,7 +33,7 @@ inline void* dtCustomAlloc(int size, dtAllocHint /*hint*/)
inline void dtCustomFree(void* ptr) inline void dtCustomFree(void* ptr)
{ {
delete [] (unsigned char*)ptr; delete [](unsigned char*)ptr;
} }
// move map related classes // move map related classes

View file

@ -34,7 +34,7 @@ struct MmapTileHeader
bool usesLiquids : 1; bool usesLiquids : 1;
MmapTileHeader() : mmapMagic(MMAP_MAGIC), dtVersion(DT_NAVMESH_VERSION), MmapTileHeader() : mmapMagic(MMAP_MAGIC), dtVersion(DT_NAVMESH_VERSION),
mmapVersion(MMAP_VERSION), size(0), usesLiquids(true) {} mmapVersion(MMAP_VERSION), size(0), usesLiquids(true) {}
}; };
enum NavTerrain enum NavTerrain
@ -48,7 +48,7 @@ enum NavTerrain
NAV_UNUSED2 = 0x20, NAV_UNUSED2 = 0x20,
NAV_UNUSED3 = 0x40, NAV_UNUSED3 = 0x40,
NAV_UNUSED4 = 0x80 NAV_UNUSED4 = 0x80
// we only have 8 bits // we only have 8 bits
}; };
#endif // _MOVE_MAP_SHARED_DEFINES_H #endif // _MOVE_MAP_SHARED_DEFINES_H

View file

@ -23,7 +23,7 @@ MovementGenerator::~MovementGenerator()
{ {
} }
bool MovementGenerator::IsActive( Unit& u ) bool MovementGenerator::IsActive(Unit& u)
{ {
// When movement generator list modified from Update movegen object erase delayed, // When movement generator list modified from Update movegen object erase delayed,
// so pointer still valid and be used for check // so pointer still valid and be used for check

View file

@ -34,16 +34,16 @@ class MANGOS_DLL_SPEC MovementGenerator
virtual ~MovementGenerator(); virtual ~MovementGenerator();
// called before adding movement generator to motion stack // called before adding movement generator to motion stack
virtual void Initialize(Unit &) = 0; virtual void Initialize(Unit&) = 0;
// called aftre remove movement generator from motion stack // called aftre remove movement generator from motion stack
virtual void Finalize(Unit &) = 0; virtual void Finalize(Unit&) = 0;
// called before lost top position (before push new movement generator above) // called before lost top position (before push new movement generator above)
virtual void Interrupt(Unit &) = 0; virtual void Interrupt(Unit&) = 0;
// called after return movement generator to top position (after remove above movement generator) // called after return movement generator to top position (after remove above movement generator)
virtual void Reset(Unit &) = 0; virtual void Reset(Unit&) = 0;
virtual bool Update(Unit &, const uint32 &time_diff) = 0; virtual bool Update(Unit&, const uint32& time_diff) = 0;
virtual MovementGeneratorType GetMovementGeneratorType() const = 0; virtual MovementGeneratorType GetMovementGeneratorType() const = 0;
@ -52,7 +52,7 @@ class MANGOS_DLL_SPEC MovementGenerator
virtual void UpdateFinalDistance(float /*fDistance*/) { } virtual void UpdateFinalDistance(float /*fDistance*/) { }
// used by Evade code for select point to evade with expected restart default movement // used by Evade code for select point to evade with expected restart default movement
virtual bool GetResetPosition(Unit &, float& /*x*/, float& /*y*/, float& /*z*/) { return false; } virtual bool GetResetPosition(Unit&, float& /*x*/, float& /*y*/, float& /*z*/) { return false; }
// given destination unreachable? due to pathfinsing or other // given destination unreachable? due to pathfinsing or other
virtual bool IsReachable() const { return true; } virtual bool IsReachable() const { return true; }
@ -66,27 +66,27 @@ template<class T, class D>
class MANGOS_DLL_SPEC MovementGeneratorMedium : public MovementGenerator class MANGOS_DLL_SPEC MovementGeneratorMedium : public MovementGenerator
{ {
public: public:
void Initialize(Unit &u) void Initialize(Unit& u)
{ {
//u->AssertIsType<T>(); //u->AssertIsType<T>();
(static_cast<D*>(this))->Initialize(*((T*)&u)); (static_cast<D*>(this))->Initialize(*((T*)&u));
} }
void Finalize(Unit &u) void Finalize(Unit& u)
{ {
//u->AssertIsType<T>(); //u->AssertIsType<T>();
(static_cast<D*>(this))->Finalize(*((T*)&u)); (static_cast<D*>(this))->Finalize(*((T*)&u));
} }
void Interrupt(Unit &u) void Interrupt(Unit& u)
{ {
//u->AssertIsType<T>(); //u->AssertIsType<T>();
(static_cast<D*>(this))->Interrupt(*((T*)&u)); (static_cast<D*>(this))->Interrupt(*((T*)&u));
} }
void Reset(Unit &u) void Reset(Unit& u)
{ {
//u->AssertIsType<T>(); //u->AssertIsType<T>();
(static_cast<D*>(this))->Reset(*((T*)&u)); (static_cast<D*>(this))->Reset(*((T*)&u));
} }
bool Update(Unit &u, const uint32 &time_diff) bool Update(Unit& u, const uint32& time_diff)
{ {
//u->AssertIsType<T>(); //u->AssertIsType<T>();
return (static_cast<D*>(this))->Update(*((T*)&u), time_diff); return (static_cast<D*>(this))->Update(*((T*)&u), time_diff);
@ -98,11 +98,11 @@ class MANGOS_DLL_SPEC MovementGeneratorMedium : public MovementGenerator
} }
public: public:
// will not link if not overridden in the generators // will not link if not overridden in the generators
void Initialize(T &u); void Initialize(T& u);
void Finalize(T &u); void Finalize(T& u);
void Interrupt(T &u); void Interrupt(T& u);
void Reset(T &u); void Reset(T& u);
bool Update(T &u, const uint32 &time_diff); bool Update(T& u, const uint32& time_diff);
// not need always overwrites // not need always overwrites
bool GetResetPosition(T& /*u*/, float& /*x*/, float& /*y*/, float& /*z*/) { return false; } bool GetResetPosition(T& /*u*/, float& /*x*/, float& /*y*/, float& /*z*/) { return false; }
@ -118,7 +118,7 @@ struct MovementGeneratorFactory : public SelectableMovement
{ {
MovementGeneratorFactory(MovementGeneratorType mgt) : SelectableMovement(mgt) {} MovementGeneratorFactory(MovementGeneratorType mgt) : SelectableMovement(mgt) {}
MovementGenerator* Create(void *) const; MovementGenerator* Create(void*) const;
}; };
typedef FactoryHolder<MovementGenerator,MovementGeneratorType> MovementGeneratorCreator; typedef FactoryHolder<MovementGenerator,MovementGeneratorType> MovementGeneratorCreator;

View file

@ -23,9 +23,9 @@
template<class MOVEMENT_GEN> template<class MOVEMENT_GEN>
inline MovementGenerator* inline MovementGenerator*
MovementGeneratorFactory<MOVEMENT_GEN>::Create(void *data) const MovementGeneratorFactory<MOVEMENT_GEN>::Create(void* data) const
{ {
Creature* creature = reinterpret_cast<Creature *>(data); Creature* creature = reinterpret_cast<Creature*>(data);
return (new MOVEMENT_GEN(*creature)); return (new MOVEMENT_GEN(*creature));
} }
#endif #endif

View file

@ -32,16 +32,16 @@
#include "MapPersistentStateMgr.h" #include "MapPersistentStateMgr.h"
#include "ObjectMgr.h" #include "ObjectMgr.h"
void WorldSession::HandleMoveWorldportAckOpcode( WorldPacket & /*recv_data*/ ) void WorldSession::HandleMoveWorldportAckOpcode(WorldPacket& /*recv_data*/)
{ {
DEBUG_LOG( "WORLD: got MSG_MOVE_WORLDPORT_ACK." ); DEBUG_LOG("WORLD: got MSG_MOVE_WORLDPORT_ACK.");
HandleMoveWorldportAckOpcode(); HandleMoveWorldportAckOpcode();
} }
void WorldSession::HandleMoveWorldportAckOpcode() void WorldSession::HandleMoveWorldportAckOpcode()
{ {
// ignore unexpected far teleports // ignore unexpected far teleports
if(!GetPlayer()->IsBeingTeleportedFar()) if (!GetPlayer()->IsBeingTeleportedFar())
return; return;
// get start teleport coordinates (will used later in fail case) // get start teleport coordinates (will used later in fail case)
@ -49,14 +49,14 @@ void WorldSession::HandleMoveWorldportAckOpcode()
GetPlayer()->GetPosition(old_loc); GetPlayer()->GetPosition(old_loc);
// get the teleport destination // get the teleport destination
WorldLocation &loc = GetPlayer()->GetTeleportDest(); WorldLocation& loc = GetPlayer()->GetTeleportDest();
// possible errors in the coordinate validity check (only cheating case possible) // possible errors in the coordinate validity check (only cheating case possible)
if (!MapManager::IsValidMapCoord(loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z, loc.orientation)) if (!MapManager::IsValidMapCoord(loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z, loc.orientation))
{ {
sLog.outError("WorldSession::HandleMoveWorldportAckOpcode: %s was teleported far to a not valid location " sLog.outError("WorldSession::HandleMoveWorldportAckOpcode: %s was teleported far to a not valid location "
"(map:%u, x:%f, y:%f, z:%f) We port him to his homebind instead..", "(map:%u, x:%f, y:%f, z:%f) We port him to his homebind instead..",
GetPlayer()->GetGuidStr().c_str(), loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z); GetPlayer()->GetGuidStr().c_str(), loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z);
// stop teleportation else we would try this again and again in LogoutPlayer... // stop teleportation else we would try this again and again in LogoutPlayer...
GetPlayer()->SetSemaphoreTeleportFar(false); GetPlayer()->SetSemaphoreTeleportFar(false);
// and teleport the player to a valid place // and teleport the player to a valid place
@ -70,7 +70,7 @@ void WorldSession::HandleMoveWorldportAckOpcode()
Map* map = NULL; Map* map = NULL;
// prevent crash at attempt landing to not existed battleground instance // prevent crash at attempt landing to not existed battleground instance
if(mEntry->IsBattleGroundOrArena()) if (mEntry->IsBattleGroundOrArena())
{ {
if (GetPlayer()->GetBattleGroundId()) if (GetPlayer()->GetBattleGroundId())
map = sMapMgr.FindMap(loc.mapid, GetPlayer()->GetBattleGroundId()); map = sMapMgr.FindMap(loc.mapid, GetPlayer()->GetBattleGroundId());
@ -78,8 +78,8 @@ void WorldSession::HandleMoveWorldportAckOpcode()
if (!map) if (!map)
{ {
DETAIL_LOG("WorldSession::HandleMoveWorldportAckOpcode: %s was teleported far to nonexisten battleground instance " DETAIL_LOG("WorldSession::HandleMoveWorldportAckOpcode: %s was teleported far to nonexisten battleground instance "
" (map:%u, x:%f, y:%f, z:%f) Trying to port him to his previous place..", " (map:%u, x:%f, y:%f, z:%f) Trying to port him to his previous place..",
GetPlayer()->GetGuidStr().c_str(), loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z); GetPlayer()->GetGuidStr().c_str(), loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z);
GetPlayer()->SetSemaphoreTeleportFar(false); GetPlayer()->SetSemaphoreTeleportFar(false);
@ -87,7 +87,7 @@ void WorldSession::HandleMoveWorldportAckOpcode()
if (!GetPlayer()->TeleportTo(old_loc)) if (!GetPlayer()->TeleportTo(old_loc))
{ {
DETAIL_LOG("WorldSession::HandleMoveWorldportAckOpcode: %s cannot be ported to his previous place, teleporting him to his homebind place...", DETAIL_LOG("WorldSession::HandleMoveWorldportAckOpcode: %s cannot be ported to his previous place, teleporting him to his homebind place...",
GetPlayer()->GetGuidStr().c_str()); GetPlayer()->GetGuidStr().c_str());
GetPlayer()->TeleportToHomebind(); GetPlayer()->TeleportToHomebind();
} }
return; return;
@ -118,14 +118,14 @@ void WorldSession::HandleMoveWorldportAckOpcode()
GetPlayer()->ResetMap(); GetPlayer()->ResetMap();
DETAIL_LOG("WorldSession::HandleMoveWorldportAckOpcode: %s was teleported far but couldn't be added to map " DETAIL_LOG("WorldSession::HandleMoveWorldportAckOpcode: %s was teleported far but couldn't be added to map "
" (map:%u, x:%f, y:%f, z:%f) Trying to port him to his previous place..", " (map:%u, x:%f, y:%f, z:%f) Trying to port him to his previous place..",
GetPlayer()->GetGuidStr().c_str(), loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z); GetPlayer()->GetGuidStr().c_str(), loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z);
// Teleport to previous place, if cannot be ported back TP to homebind place // Teleport to previous place, if cannot be ported back TP to homebind place
if (!GetPlayer()->TeleportTo(old_loc)) if (!GetPlayer()->TeleportTo(old_loc))
{ {
DETAIL_LOG("WorldSession::HandleMoveWorldportAckOpcode: %s cannot be ported to his previous place, teleporting him to his homebind place...", DETAIL_LOG("WorldSession::HandleMoveWorldportAckOpcode: %s cannot be ported to his previous place, teleporting him to his homebind place...",
GetPlayer()->GetGuidStr().c_str()); GetPlayer()->GetGuidStr().c_str());
GetPlayer()->TeleportToHomebind(); GetPlayer()->TeleportToHomebind();
} }
return; return;
@ -133,10 +133,10 @@ void WorldSession::HandleMoveWorldportAckOpcode()
// battleground state prepare (in case join to BG), at relogin/tele player not invited // battleground state prepare (in case join to BG), at relogin/tele player not invited
// only add to bg group and object, if the player was invited (else he entered through command) // only add to bg group and object, if the player was invited (else he entered through command)
if(_player->InBattleGround()) if (_player->InBattleGround())
{ {
// cleanup setting if outdated // cleanup setting if outdated
if(!mEntry->IsBattleGroundOrArena()) if (!mEntry->IsBattleGroundOrArena())
{ {
// We're not in BG // We're not in BG
_player->SetBattleGroundId(0, BATTLEGROUND_TYPE_NONE); _player->SetBattleGroundId(0, BATTLEGROUND_TYPE_NONE);
@ -144,9 +144,9 @@ void WorldSession::HandleMoveWorldportAckOpcode()
_player->SetBGTeam(TEAM_NONE); _player->SetBGTeam(TEAM_NONE);
} }
// join to bg case // join to bg case
else if(BattleGround *bg = _player->GetBattleGround()) else if (BattleGround* bg = _player->GetBattleGround())
{ {
if(_player->IsInvitedForBattleGroundInstance(_player->GetBattleGroundId())) if (_player->IsInvitedForBattleGroundInstance(_player->GetBattleGroundId()))
bg->AddPlayer(_player); bg->AddPlayer(_player);
} }
} }
@ -154,9 +154,9 @@ void WorldSession::HandleMoveWorldportAckOpcode()
GetPlayer()->SendInitialPacketsAfterAddToMap(); GetPlayer()->SendInitialPacketsAfterAddToMap();
// flight fast teleport case // flight fast teleport case
if(GetPlayer()->GetMotionMaster()->GetCurrentMovementGeneratorType() == FLIGHT_MOTION_TYPE) if (GetPlayer()->GetMotionMaster()->GetCurrentMovementGeneratorType() == FLIGHT_MOTION_TYPE)
{ {
if(!_player->InBattleGround()) if (!_player->InBattleGround())
{ {
// short preparations to continue flight // short preparations to continue flight
FlightPathMovementGenerator* flight = (FlightPathMovementGenerator*)(GetPlayer()->GetMotionMaster()->top()); FlightPathMovementGenerator* flight = (FlightPathMovementGenerator*)(GetPlayer()->GetMotionMaster()->top());
@ -172,7 +172,7 @@ void WorldSession::HandleMoveWorldportAckOpcode()
if (mInstance) if (mInstance)
{ {
Difficulty diff = GetPlayer()->GetDifficulty(mEntry->IsRaid()); Difficulty diff = GetPlayer()->GetDifficulty(mEntry->IsRaid());
if(MapDifficulty const* mapDiff = GetMapDifficultyData(mEntry->MapID,diff)) if (MapDifficulty const* mapDiff = GetMapDifficultyData(mEntry->MapID,diff))
{ {
if (mapDiff->resetTime) if (mapDiff->resetTime)
{ {
@ -186,11 +186,11 @@ void WorldSession::HandleMoveWorldportAckOpcode()
} }
// mount allow check // mount allow check
if(!mEntry->IsMountAllowed()) if (!mEntry->IsMountAllowed())
_player->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED); _player->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED);
// honorless target // honorless target
if(GetPlayer()->pvpInfo.inHostileArea) if (GetPlayer()->pvpInfo.inHostileArea)
GetPlayer()->CastSpell(GetPlayer(), 2479, true); GetPlayer()->CastSpell(GetPlayer(), 2479, true);
// resummon pet // resummon pet
@ -213,13 +213,13 @@ void WorldSession::HandleMoveTeleportAckOpcode(WorldPacket& recv_data)
DEBUG_LOG("Guid: %s", guid.GetString().c_str()); DEBUG_LOG("Guid: %s", guid.GetString().c_str());
DEBUG_LOG("Counter %u, time %u", counter, time/IN_MILLISECONDS); DEBUG_LOG("Counter %u, time %u", counter, time/IN_MILLISECONDS);
Unit *mover = _player->GetMover(); Unit* mover = _player->GetMover();
Player *plMover = mover->GetTypeId() == TYPEID_PLAYER ? (Player*)mover : NULL; Player* plMover = mover->GetTypeId() == TYPEID_PLAYER ? (Player*)mover : NULL;
if(!plMover || !plMover->IsBeingTeleportedNear()) if (!plMover || !plMover->IsBeingTeleportedNear())
return; return;
if(guid != plMover->GetObjectGuid()) if (guid != plMover->GetObjectGuid())
return; return;
plMover->SetSemaphoreTeleportNear(false); plMover->SetSemaphoreTeleportNear(false);
@ -235,10 +235,10 @@ void WorldSession::HandleMoveTeleportAckOpcode(WorldPacket& recv_data)
plMover->UpdateZone(newzone, newarea); plMover->UpdateZone(newzone, newarea);
// new zone // new zone
if(old_zone != newzone) if (old_zone != newzone)
{ {
// honorless target // honorless target
if(plMover->pvpInfo.inHostileArea) if (plMover->pvpInfo.inHostileArea)
plMover->CastSpell(plMover, 2479, true); plMover->CastSpell(plMover, 2479, true);
} }
@ -249,17 +249,17 @@ void WorldSession::HandleMoveTeleportAckOpcode(WorldPacket& recv_data)
GetPlayer()->ProcessDelayedOperations(); GetPlayer()->ProcessDelayedOperations();
} }
void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data ) void WorldSession::HandleMovementOpcodes(WorldPacket& recv_data)
{ {
uint32 opcode = recv_data.GetOpcode(); uint32 opcode = recv_data.GetOpcode();
DEBUG_LOG("WORLD: Recvd %s (%u, 0x%X) opcode", LookupOpcodeName(opcode), opcode, opcode); DEBUG_LOG("WORLD: Recvd %s (%u, 0x%X) opcode", LookupOpcodeName(opcode), opcode, opcode);
recv_data.hexlike(); recv_data.hexlike();
Unit *mover = _player->GetMover(); Unit* mover = _player->GetMover();
Player *plMover = mover->GetTypeId() == TYPEID_PLAYER ? (Player*)mover : NULL; Player* plMover = mover->GetTypeId() == TYPEID_PLAYER ? (Player*)mover : NULL;
// ignore, waiting processing in WorldSession::HandleMoveWorldportAckOpcode and WorldSession::HandleMoveTeleportAck // ignore, waiting processing in WorldSession::HandleMoveWorldportAckOpcode and WorldSession::HandleMoveTeleportAck
if(plMover && plMover->IsBeingTeleported()) if (plMover && plMover->IsBeingTeleported())
{ {
recv_data.rpos(recv_data.wpos()); // prevent warnings spam recv_data.rpos(recv_data.wpos()); // prevent warnings spam
return; return;
@ -292,7 +292,7 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
mover->SendMessageToSetExcept(&data, _player); mover->SendMessageToSetExcept(&data, _player);
} }
void WorldSession::HandleForceSpeedChangeAckOpcodes(WorldPacket &recv_data) void WorldSession::HandleForceSpeedChangeAckOpcodes(WorldPacket& recv_data)
{ {
uint32 opcode = recv_data.GetOpcode(); uint32 opcode = recv_data.GetOpcode();
DEBUG_LOG("WORLD: Recvd %s (%u, 0x%X) opcode", LookupOpcodeName(opcode), opcode, opcode); DEBUG_LOG("WORLD: Recvd %s (%u, 0x%X) opcode", LookupOpcodeName(opcode), opcode, opcode);
@ -308,7 +308,7 @@ void WorldSession::HandleForceSpeedChangeAckOpcodes(WorldPacket &recv_data)
recv_data >> newspeed; recv_data >> newspeed;
// now can skip not our packet // now can skip not our packet
if(_player->GetObjectGuid() != guid) if (_player->GetObjectGuid() != guid)
{ {
recv_data.rpos(recv_data.wpos()); // prevent warnings spam recv_data.rpos(recv_data.wpos()); // prevent warnings spam
return; return;
@ -322,7 +322,7 @@ void WorldSession::HandleForceSpeedChangeAckOpcodes(WorldPacket &recv_data)
static char const* move_type_name[MAX_MOVE_TYPE] = { "Walk", "Run", "RunBack", "Swim", "SwimBack", "TurnRate", "Flight", "FlightBack", "PitchRate" }; static char const* move_type_name[MAX_MOVE_TYPE] = { "Walk", "Run", "RunBack", "Swim", "SwimBack", "TurnRate", "Flight", "FlightBack", "PitchRate" };
switch(opcode) switch (opcode)
{ {
case CMSG_FORCE_WALK_SPEED_CHANGE_ACK: move_type = MOVE_WALK; force_move_type = MOVE_WALK; break; case CMSG_FORCE_WALK_SPEED_CHANGE_ACK: move_type = MOVE_WALK; force_move_type = MOVE_WALK; break;
case CMSG_FORCE_RUN_SPEED_CHANGE_ACK: move_type = MOVE_RUN; force_move_type = MOVE_RUN; break; case CMSG_FORCE_RUN_SPEED_CHANGE_ACK: move_type = MOVE_RUN; force_move_type = MOVE_RUN; break;
@ -340,31 +340,31 @@ void WorldSession::HandleForceSpeedChangeAckOpcodes(WorldPacket &recv_data)
// skip all forced speed changes except last and unexpected // skip all forced speed changes except last and unexpected
// in run/mounted case used one ACK and it must be skipped.m_forced_speed_changes[MOVE_RUN} store both. // in run/mounted case used one ACK and it must be skipped.m_forced_speed_changes[MOVE_RUN} store both.
if(_player->m_forced_speed_changes[force_move_type] > 0) if (_player->m_forced_speed_changes[force_move_type] > 0)
{ {
--_player->m_forced_speed_changes[force_move_type]; --_player->m_forced_speed_changes[force_move_type];
if(_player->m_forced_speed_changes[force_move_type] > 0) if (_player->m_forced_speed_changes[force_move_type] > 0)
return; return;
} }
if (!_player->GetTransport() && fabs(_player->GetSpeed(move_type) - newspeed) > 0.01f) if (!_player->GetTransport() && fabs(_player->GetSpeed(move_type) - newspeed) > 0.01f)
{ {
if(_player->GetSpeed(move_type) > newspeed) // must be greater - just correct if (_player->GetSpeed(move_type) > newspeed) // must be greater - just correct
{ {
sLog.outError("%sSpeedChange player %s is NOT correct (must be %f instead %f), force set to correct value", sLog.outError("%sSpeedChange player %s is NOT correct (must be %f instead %f), force set to correct value",
move_type_name[move_type], _player->GetName(), _player->GetSpeed(move_type), newspeed); move_type_name[move_type], _player->GetName(), _player->GetSpeed(move_type), newspeed);
_player->SetSpeedRate(move_type,_player->GetSpeedRate(move_type),true); _player->SetSpeedRate(move_type,_player->GetSpeedRate(move_type),true);
} }
else // must be lesser - cheating else // must be lesser - cheating
{ {
BASIC_LOG("Player %s from account id %u kicked for incorrect speed (must be %f instead %f)", BASIC_LOG("Player %s from account id %u kicked for incorrect speed (must be %f instead %f)",
_player->GetName(),_player->GetSession()->GetAccountId(),_player->GetSpeed(move_type), newspeed); _player->GetName(),_player->GetSession()->GetAccountId(),_player->GetSpeed(move_type), newspeed);
_player->GetSession()->KickPlayer(); _player->GetSession()->KickPlayer();
} }
} }
} }
void WorldSession::HandleSetActiveMoverOpcode(WorldPacket &recv_data) void WorldSession::HandleSetActiveMoverOpcode(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: Recvd CMSG_SET_ACTIVE_MOVER"); DEBUG_LOG("WORLD: Recvd CMSG_SET_ACTIVE_MOVER");
recv_data.hexlike(); recv_data.hexlike();
@ -372,15 +372,15 @@ void WorldSession::HandleSetActiveMoverOpcode(WorldPacket &recv_data)
ObjectGuid guid; ObjectGuid guid;
recv_data >> guid; recv_data >> guid;
if(_player->GetMover()->GetObjectGuid() != guid) if (_player->GetMover()->GetObjectGuid() != guid)
{ {
sLog.outError("HandleSetActiveMoverOpcode: incorrect mover guid: mover is %s and should be %s", sLog.outError("HandleSetActiveMoverOpcode: incorrect mover guid: mover is %s and should be %s",
_player->GetMover()->GetGuidStr().c_str(), guid.GetString().c_str()); _player->GetMover()->GetGuidStr().c_str(), guid.GetString().c_str());
return; return;
} }
} }
void WorldSession::HandleMoveNotActiveMoverOpcode(WorldPacket &recv_data) void WorldSession::HandleMoveNotActiveMoverOpcode(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: Recvd CMSG_MOVE_NOT_ACTIVE_MOVER"); DEBUG_LOG("WORLD: Recvd CMSG_MOVE_NOT_ACTIVE_MOVER");
recv_data.hexlike(); recv_data.hexlike();
@ -391,12 +391,12 @@ void WorldSession::HandleMoveNotActiveMoverOpcode(WorldPacket &recv_data)
recv_data >> old_mover_guid.ReadAsPacked(); recv_data >> old_mover_guid.ReadAsPacked();
recv_data >> mi; recv_data >> mi;
if(_player->GetMover()->GetObjectGuid() == old_mover_guid) if (_player->GetMover()->GetObjectGuid() == old_mover_guid)
{ {
sLog.outError("HandleMoveNotActiveMover: incorrect mover guid: mover is %s and should be %s instead of %s", sLog.outError("HandleMoveNotActiveMover: incorrect mover guid: mover is %s and should be %s instead of %s",
_player->GetMover()->GetGuidStr().c_str(), _player->GetMover()->GetGuidStr().c_str(),
_player->GetGuidStr().c_str(), _player->GetGuidStr().c_str(),
old_mover_guid.GetString().c_str()); old_mover_guid.GetString().c_str());
recv_data.rpos(recv_data.wpos()); // prevent warnings spam recv_data.rpos(recv_data.wpos()); // prevent warnings spam
return; return;
} }
@ -404,7 +404,7 @@ void WorldSession::HandleMoveNotActiveMoverOpcode(WorldPacket &recv_data)
_player->m_movementInfo = mi; _player->m_movementInfo = mi;
} }
void WorldSession::HandleDismissControlledVehicle(WorldPacket &recv_data) void WorldSession::HandleDismissControlledVehicle(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: Recvd CMSG_DISMISS_CONTROLLED_VEHICLE"); DEBUG_LOG("WORLD: Recvd CMSG_DISMISS_CONTROLLED_VEHICLE");
recv_data.hexlike(); recv_data.hexlike();
@ -432,15 +432,15 @@ void WorldSession::HandleMountSpecialAnimOpcode(WorldPacket& /*recvdata*/)
GetPlayer()->SendMessageToSet(&data, false); GetPlayer()->SendMessageToSet(&data, false);
} }
void WorldSession::HandleMoveKnockBackAck( WorldPacket & recv_data ) void WorldSession::HandleMoveKnockBackAck(WorldPacket& recv_data)
{ {
DEBUG_LOG("CMSG_MOVE_KNOCK_BACK_ACK"); DEBUG_LOG("CMSG_MOVE_KNOCK_BACK_ACK");
Unit *mover = _player->GetMover(); Unit* mover = _player->GetMover();
Player *plMover = mover->GetTypeId() == TYPEID_PLAYER ? (Player*)mover : NULL; Player* plMover = mover->GetTypeId() == TYPEID_PLAYER ? (Player*)mover : NULL;
// ignore, waiting processing in WorldSession::HandleMoveWorldportAckOpcode and WorldSession::HandleMoveTeleportAck // ignore, waiting processing in WorldSession::HandleMoveWorldportAckOpcode and WorldSession::HandleMoveTeleportAck
if(plMover && plMover->IsBeingTeleported()) if (plMover && plMover->IsBeingTeleported())
{ {
recv_data.rpos(recv_data.wpos()); // prevent warnings spam recv_data.rpos(recv_data.wpos()); // prevent warnings spam
return; return;
@ -468,7 +468,7 @@ void WorldSession::HandleMoveKnockBackAck( WorldPacket & recv_data )
mover->SendMessageToSetExcept(&data, _player); mover->SendMessageToSetExcept(&data, _player);
} }
void WorldSession::HandleMoveHoverAck( WorldPacket& recv_data ) void WorldSession::HandleMoveHoverAck(WorldPacket& recv_data)
{ {
DEBUG_LOG("CMSG_MOVE_HOVER_ACK"); DEBUG_LOG("CMSG_MOVE_HOVER_ACK");
@ -520,11 +520,11 @@ bool WorldSession::VerifyMovementInfo(MovementInfo const& movementInfo, ObjectGu
{ {
// transports size limited // transports size limited
// (also received at zeppelin/lift leave by some reason with t_* as absolute in continent coordinates, can be safely skipped) // (also received at zeppelin/lift leave by some reason with t_* as absolute in continent coordinates, can be safely skipped)
if( movementInfo.GetTransportPos()->x > 50 || movementInfo.GetTransportPos()->y > 50 || movementInfo.GetTransportPos()->z > 100 ) if (movementInfo.GetTransportPos()->x > 50 || movementInfo.GetTransportPos()->y > 50 || movementInfo.GetTransportPos()->z > 100)
return false; return false;
if( !MaNGOS::IsValidMapCoord(movementInfo.GetPos()->x + movementInfo.GetTransportPos()->x, movementInfo.GetPos()->y + movementInfo.GetTransportPos()->y, if (!MaNGOS::IsValidMapCoord(movementInfo.GetPos()->x + movementInfo.GetTransportPos()->x, movementInfo.GetPos()->y + movementInfo.GetTransportPos()->y,
movementInfo.GetPos()->z + movementInfo.GetTransportPos()->z, movementInfo.GetPos()->o + movementInfo.GetTransportPos()->o) ) movementInfo.GetPos()->z + movementInfo.GetTransportPos()->z, movementInfo.GetPos()->o + movementInfo.GetTransportPos()->o))
{ {
return false; return false;
} }
@ -537,9 +537,9 @@ void WorldSession::HandleMoverRelocation(MovementInfo& movementInfo)
{ {
movementInfo.UpdateTime(WorldTimer::getMSTime()); movementInfo.UpdateTime(WorldTimer::getMSTime());
Unit *mover = _player->GetMover(); Unit* mover = _player->GetMover();
if (Player *plMover = mover->GetTypeId() == TYPEID_PLAYER ? (Player*)mover : NULL) if (Player* plMover = mover->GetTypeId() == TYPEID_PLAYER ? (Player*)mover : NULL)
{ {
if (movementInfo.HasMovementFlag(MOVEFLAG_ONTRANSPORT)) if (movementInfo.HasMovementFlag(MOVEFLAG_ONTRANSPORT))
{ {
@ -567,17 +567,17 @@ void WorldSession::HandleMoverRelocation(MovementInfo& movementInfo)
if (movementInfo.HasMovementFlag(MOVEFLAG_SWIMMING) != plMover->IsInWater()) if (movementInfo.HasMovementFlag(MOVEFLAG_SWIMMING) != plMover->IsInWater())
{ {
// now client not include swimming flag in case jumping under water // now client not include swimming flag in case jumping under water
plMover->SetInWater( !plMover->IsInWater() || plMover->GetTerrain()->IsUnderWater(movementInfo.GetPos()->x, movementInfo.GetPos()->y, movementInfo.GetPos()->z) ); plMover->SetInWater(!plMover->IsInWater() || plMover->GetTerrain()->IsUnderWater(movementInfo.GetPos()->x, movementInfo.GetPos()->y, movementInfo.GetPos()->z));
} }
plMover->SetPosition(movementInfo.GetPos()->x, movementInfo.GetPos()->y, movementInfo.GetPos()->z, movementInfo.GetPos()->o); plMover->SetPosition(movementInfo.GetPos()->x, movementInfo.GetPos()->y, movementInfo.GetPos()->z, movementInfo.GetPos()->o);
plMover->m_movementInfo = movementInfo; plMover->m_movementInfo = movementInfo;
if(movementInfo.GetPos()->z < -500.0f) if (movementInfo.GetPos()->z < -500.0f)
{ {
if(plMover->InBattleGround() if (plMover->InBattleGround()
&& plMover->GetBattleGround() && plMover->GetBattleGround()
&& plMover->GetBattleGround()->HandlePlayerUnderMap(_player)) && plMover->GetBattleGround()->HandlePlayerUnderMap(_player))
{ {
// do nothing, the handle already did if returned true // do nothing, the handle already did if returned true
} }
@ -586,11 +586,11 @@ void WorldSession::HandleMoverRelocation(MovementInfo& movementInfo)
// NOTE: this is actually called many times while falling // NOTE: this is actually called many times while falling
// even after the player has been teleported away // even after the player has been teleported away
// TODO: discard movement packets after the player is rooted // TODO: discard movement packets after the player is rooted
if(plMover->isAlive()) if (plMover->isAlive())
{ {
plMover->EnvironmentalDamage(DAMAGE_FALL_TO_VOID, plMover->GetMaxHealth()); plMover->EnvironmentalDamage(DAMAGE_FALL_TO_VOID, plMover->GetMaxHealth());
// pl can be alive if GM/etc // pl can be alive if GM/etc
if(!plMover->isAlive()) if (!plMover->isAlive())
{ {
// change the death state to CORPSE to prevent the death timer from // change the death state to CORPSE to prevent the death timer from
// starting in the next player update // starting in the next player update