converted all tabs to 4 spaces

This commit is contained in:
Yehonal
2016-06-26 19:23:57 +02:00
parent 52f305111c
commit f6eefedcd5
717 changed files with 132388 additions and 132388 deletions

View File

@@ -102,7 +102,7 @@ void WorldSession::HandleArenaTeamInviteOpcode(WorldPacket & recvData)
if (player->getLevel() < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", invitedName, ERR_ARENA_TEAM_TARGET_TOO_LOW_S);
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", invitedName, ERR_ARENA_TEAM_TARGET_TOO_LOW_S);
return;
}
@@ -123,15 +123,15 @@ void WorldSession::HandleArenaTeamInviteOpcode(WorldPacket & recvData)
if (player->GetSocial()->HasIgnore(GetPlayer()->GetGUIDLow()))
return;
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && player->GetTeamId() != GetPlayer()->GetTeamId())
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", "", ERR_ARENA_TEAM_NOT_ALLIED);
return;
}
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && player->GetTeamId() != GetPlayer()->GetTeamId())
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", "", ERR_ARENA_TEAM_NOT_ALLIED);
return;
}
if (player->GetArenaTeamId(arenaTeam->GetSlot()))
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", invitedName, ERR_ALREADY_IN_ARENA_TEAM_S);
SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", invitedName, ERR_ALREADY_IN_ARENA_TEAM_S);
return;
}
@@ -174,12 +174,12 @@ void WorldSession::HandleArenaTeamAcceptOpcode(WorldPacket & /*recvData*/)
return;
}
// Only allow members of the other faction to join the team if cross faction interaction is enabled
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && _player->GetTeamId() != sObjectMgr->GetPlayerTeamIdByGUID(arenaTeam->GetCaptain()))
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", "", ERR_ARENA_TEAM_NOT_ALLIED);
return;
}
// Only allow members of the other faction to join the team if cross faction interaction is enabled
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && _player->GetTeamId() != sObjectMgr->GetPlayerTeamIdByGUID(arenaTeam->GetCaptain()))
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", "", ERR_ARENA_TEAM_NOT_ALLIED);
return;
}
// Add player to team
if (!arenaTeam->AddMember(_player->GetGUID()))

View File

@@ -121,9 +121,9 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recvData)
recvData >> itemsCount;
uint64 itemGUIDs[MAX_AUCTION_ITEMS]; // 160 slot = 4x 36 slot bag + backpack 16 slot
memset(itemGUIDs, 0, sizeof(itemGUIDs));
memset(itemGUIDs, 0, sizeof(itemGUIDs));
uint32 count[MAX_AUCTION_ITEMS];
memset(count, 0, sizeof(count));
memset(count, 0, sizeof(count));
if (itemsCount > MAX_AUCTION_ITEMS)
{
@@ -190,7 +190,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recvData)
Item* items[MAX_AUCTION_ITEMS];
uint32 finalCount = 0;
uint32 itemEntry = 0;
uint32 itemEntry = 0;
for (uint32 i = 0; i < itemsCount; ++i)
{
@@ -266,10 +266,10 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recvData)
AuctionEntry* AH = new AuctionEntry;
AH->Id = sObjectMgr->GenerateAuctionID();
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
AH->auctioneer = 23442;
else
AH->auctioneer = GUID_LOPART(auctioneer);
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
AH->auctioneer = 23442;
else
AH->auctioneer = GUID_LOPART(auctioneer);
// Required stack size of auction matches to current item stack size, just move item to auctionhouse
if (itemsCount == 1 && item->GetCount() == count[i])
@@ -635,17 +635,17 @@ void WorldSession::HandleAuctionListBidderItems(WorldPacket & recvData)
//this void sends player info about his auctions
void WorldSession::HandleAuctionListOwnerItems(WorldPacket & recvData)
{
// pussywizard:
const uint32 delay = 4500;
const uint32 now = World::GetGameTimeMS();
if (_lastAuctionListOwnerItemsMSTime > now) // list is pending
return;
uint32 diff = getMSTimeDiff(_lastAuctionListOwnerItemsMSTime, now);
if (diff > delay)
diff = delay;
// pussywizard:
const uint32 delay = 4500;
const uint32 now = World::GetGameTimeMS();
if (_lastAuctionListOwnerItemsMSTime > now) // list is pending
return;
uint32 diff = getMSTimeDiff(_lastAuctionListOwnerItemsMSTime, now);
if (diff > delay)
diff = delay;
_lastAuctionListOwnerItemsMSTime = now + delay; // set longest possible here, actual exectuing will change this to getMSTime of that moment
_player->m_Events.AddEvent(new AuctionListOwnerItemsDelayEvent(recvData, _player->GetGUID(), true), _player->m_Events.CalculateTime(delay-diff));
_lastAuctionListOwnerItemsMSTime = now + delay; // set longest possible here, actual exectuing will change this to getMSTime of that moment
_player->m_Events.AddEvent(new AuctionListOwnerItemsDelayEvent(recvData, _player->GetGUID(), true), _player->m_Events.CalculateTime(delay-diff));
}
void WorldSession::HandleAuctionListOwnerItemsEvent(WorldPacket & recvData)
@@ -717,19 +717,19 @@ void WorldSession::HandleAuctionListItems(WorldPacket & recvData)
recvData.read_skip<uint8>();
}
// remove fake death
if (_player->HasUnitState(UNIT_STATE_DIED))
_player->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
// remove fake death
if (_player->HasUnitState(UNIT_STATE_DIED))
_player->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
// pussywizard:
const uint32 delay = 2000;
const uint32 now = World::GetGameTimeMS();
uint32 diff = getMSTimeDiff(_lastAuctionListItemsMSTime, now);
if (diff > delay)
diff = delay;
_lastAuctionListItemsMSTime = now + delay - diff;
TRINITY_GUARD(ACE_Thread_Mutex, AsyncAuctionListingMgr::GetTempLock());
AsyncAuctionListingMgr::GetTempList().push_back( AuctionListItemsDelayEvent(delay-diff, _player->GetGUID(), guid, searchedname, listfrom, levelmin, levelmax, usable, auctionSlotID, auctionMainCategory, auctionSubCategory, quality, getAll) );
// pussywizard:
const uint32 delay = 2000;
const uint32 now = World::GetGameTimeMS();
uint32 diff = getMSTimeDiff(_lastAuctionListItemsMSTime, now);
if (diff > delay)
diff = delay;
_lastAuctionListItemsMSTime = now + delay - diff;
TRINITY_GUARD(ACE_Thread_Mutex, AsyncAuctionListingMgr::GetTempLock());
AsyncAuctionListingMgr::GetTempList().push_back( AuctionListItemsDelayEvent(delay-diff, _player->GetGUID(), guid, searchedname, listfrom, levelmin, levelmax, usable, auctionSlotID, auctionMainCategory, auctionSubCategory, quality, getAll) );
}
void WorldSession::HandleAuctionListPendingSales(WorldPacket & recvData)

View File

@@ -82,25 +82,25 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket & recvData)
recvData >> instanceId; // instance id, 0 if First Available selected
recvData >> joinAsGroup; // join as group
// entry not found
// entry not found
if (!sBattlemasterListStore.LookupEntry(bgTypeId_))
return;
// chosen battleground type is disabled
// chosen battleground type is disabled
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_BATTLEGROUND, bgTypeId_, NULL))
{
ChatHandler(this).PSendSysMessage(LANG_BG_DISABLED);
return;
}
// get queue typeid and random typeid to check if already queued for them
// get queue typeid and random typeid to check if already queued for them
BattlegroundTypeId bgTypeId = BattlegroundTypeId(bgTypeId_);
BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(bgTypeId, 0);
BattlegroundQueueTypeId bgQueueTypeIdRandom = BattlegroundMgr::BGQueueTypeId(BATTLEGROUND_RB, 0);
// safety check - bgQueueTypeId == BATTLEGROUND_QUEUE_NONE if tried to queue for arena using this function
if (bgQueueTypeId == BATTLEGROUND_QUEUE_NONE)
return;
// safety check - bgQueueTypeId == BATTLEGROUND_QUEUE_NONE if tried to queue for arena using this function
if (bgQueueTypeId == BATTLEGROUND_QUEUE_NONE)
return;
// get bg template
Battleground* bgt = sBattlegroundMgr->GetBattlegroundTemplate(bgTypeId);
@@ -112,62 +112,62 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket & recvData)
if (!bracketEntry)
return;
// pussywizard: if trying to queue for already queued
// just remove from queue and it will requeue!
uint32 qSlot = _player->GetBattlegroundQueueIndex(bgQueueTypeId);
if (qSlot < PLAYER_MAX_BATTLEGROUND_QUEUES)
{
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
// pussywizard: if trying to queue for already queued
// just remove from queue and it will requeue!
uint32 qSlot = _player->GetBattlegroundQueueIndex(bgQueueTypeId);
if (qSlot < PLAYER_MAX_BATTLEGROUND_QUEUES)
{
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
if (bgQueue.IsPlayerInvitedToRatedArena(_player->GetGUID()))
{
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, ERR_BATTLEGROUND_JOIN_FAILED);
SendPacket(&data);
return;
}
if (bgQueue.IsPlayerInvitedToRatedArena(_player->GetGUID()))
{
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, ERR_BATTLEGROUND_JOIN_FAILED);
SendPacket(&data);
return;
}
bgQueue.RemovePlayer(_player->GetGUID(), false, qSlot);
_player->RemoveBattlegroundQueueId(bgQueueTypeId);
}
bgQueue.RemovePlayer(_player->GetGUID(), false, qSlot);
_player->RemoveBattlegroundQueueId(bgQueueTypeId);
}
// must have free queue slot
if (!_player->HasFreeBattlegroundQueueId())
{
// must have free queue slot
if (!_player->HasFreeBattlegroundQueueId())
{
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, ERR_BATTLEGROUND_TOO_MANY_QUEUES);
SendPacket(&data);
return;
}
}
// queue result (default ok)
GroupJoinBattlegroundResult err = GroupJoinBattlegroundResult(bgt->GetBgTypeID());
// queue result (default ok)
GroupJoinBattlegroundResult err = GroupJoinBattlegroundResult(bgt->GetBgTypeID());
// check if player can queue:
if (!joinAsGroup)
{
if (GetPlayer()->InBattleground()) // currently in battleground
if (GetPlayer()->InBattleground()) // currently in battleground
err = ERR_BATTLEGROUND_NOT_IN_BATTLEGROUND;
else if (GetPlayer()->isUsingLfg()) // using lfg system
else if (GetPlayer()->isUsingLfg()) // using lfg system
err = ERR_LFG_CANT_USE_BATTLEGROUND;
else if (!_player->CanJoinToBattleground()) // has deserter debuff
else if (!_player->CanJoinToBattleground()) // has deserter debuff
err = ERR_GROUP_JOIN_BATTLEGROUND_DESERTERS;
else if (_player->InBattlegroundQueueForBattlegroundQueueType(bgQueueTypeIdRandom)) // queued for random bg, so can't queue for anything else
else if (_player->InBattlegroundQueueForBattlegroundQueueType(bgQueueTypeIdRandom)) // queued for random bg, so can't queue for anything else
err = ERR_IN_RANDOM_BG;
else if (_player->InBattlegroundQueue() && bgTypeId == BATTLEGROUND_RB) // already in queue, so can't queue for random
else if (_player->InBattlegroundQueue() && bgTypeId == BATTLEGROUND_RB) // already in queue, so can't queue for random
err = ERR_IN_NON_RANDOM_BG;
else if (_player->InBattlegroundQueueForBattlegroundQueueType(BATTLEGROUND_QUEUE_2v2) ||
_player->InBattlegroundQueueForBattlegroundQueueType(BATTLEGROUND_QUEUE_3v3) ||
_player->InBattlegroundQueueForBattlegroundQueueType(BATTLEGROUND_QUEUE_5v5)) // can't be already queued for arenas
err = ERR_BATTLEGROUND_QUEUED_FOR_RATED;
else if (_player->InBattlegroundQueueForBattlegroundQueueType(BATTLEGROUND_QUEUE_2v2) ||
_player->InBattlegroundQueueForBattlegroundQueueType(BATTLEGROUND_QUEUE_3v3) ||
_player->InBattlegroundQueueForBattlegroundQueueType(BATTLEGROUND_QUEUE_5v5)) // can't be already queued for arenas
err = ERR_BATTLEGROUND_QUEUED_FOR_RATED;
if (err <= 0)
{
if (err <= 0)
{
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, err);
SendPacket(&data);
return;
}
}
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
GroupQueueInfo* ginfo = bgQueue.AddGroup(_player, NULL, bracketEntry, false, false, 0, 0, 0);
@@ -175,12 +175,12 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket & recvData)
uint32 queueSlot = _player->AddBattlegroundQueueId(bgQueueTypeId);
// send status packet
// send status packet
WorldPacket data;
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bgt, queueSlot, STATUS_WAIT_QUEUE, avgWaitTime, 0, 0, TEAM_NEUTRAL);
SendPacket(&data);
}
// check if group can queue:
// check if group can queue:
else
{
Group* grp = _player->GetGroup();
@@ -188,48 +188,48 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket & recvData)
if (!grp || grp->GetLeaderGUID() != _player->GetGUID())
return;
// pussywizard: for party members - remove queues for which leader is not queued to!
std::set<uint32> leaderQueueTypeIds;
for (uint32 i=0; i<PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
leaderQueueTypeIds.insert((uint32)_player->GetBattlegroundQueueTypeId(i));
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
if (Player* member = itr->GetSource())
for (uint32 i=0; i<PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
if (BattlegroundQueueTypeId mqtid = member->GetBattlegroundQueueTypeId(i))
if (leaderQueueTypeIds.count((uint32)mqtid) == 0)
{
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(mqtid);
// pussywizard: for party members - remove queues for which leader is not queued to!
std::set<uint32> leaderQueueTypeIds;
for (uint32 i=0; i<PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
leaderQueueTypeIds.insert((uint32)_player->GetBattlegroundQueueTypeId(i));
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
if (Player* member = itr->GetSource())
for (uint32 i=0; i<PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
if (BattlegroundQueueTypeId mqtid = member->GetBattlegroundQueueTypeId(i))
if (leaderQueueTypeIds.count((uint32)mqtid) == 0)
{
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(mqtid);
if (bgQueue.IsPlayerInvitedToRatedArena(member->GetGUID()))
{
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, ERR_BATTLEGROUND_JOIN_FAILED);
SendPacket(&data);
return;
}
if (bgQueue.IsPlayerInvitedToRatedArena(member->GetGUID()))
{
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, ERR_BATTLEGROUND_JOIN_FAILED);
SendPacket(&data);
return;
}
bgQueue.RemovePlayer(member->GetGUID(), false, i);
member->RemoveBattlegroundQueueId(mqtid);
}
bgQueue.RemovePlayer(member->GetGUID(), false, i);
member->RemoveBattlegroundQueueId(mqtid);
}
if (_player->InBattlegroundQueueForBattlegroundQueueType(bgQueueTypeIdRandom)) // queued for random bg, so can't queue for anything else
if (_player->InBattlegroundQueueForBattlegroundQueueType(bgQueueTypeIdRandom)) // queued for random bg, so can't queue for anything else
err = ERR_IN_RANDOM_BG;
else if (_player->InBattlegroundQueue() && bgTypeId == BATTLEGROUND_RB) // already in queue, so can't queue for random
else if (_player->InBattlegroundQueue() && bgTypeId == BATTLEGROUND_RB) // already in queue, so can't queue for random
err = ERR_IN_NON_RANDOM_BG;
else if (_player->InBattlegroundQueueForBattlegroundQueueType(BATTLEGROUND_QUEUE_2v2) ||
_player->InBattlegroundQueueForBattlegroundQueueType(BATTLEGROUND_QUEUE_3v3) ||
_player->InBattlegroundQueueForBattlegroundQueueType(BATTLEGROUND_QUEUE_5v5)) // can't be already queued for arenas
err = ERR_BATTLEGROUND_QUEUED_FOR_RATED;
else if (_player->InBattlegroundQueueForBattlegroundQueueType(BATTLEGROUND_QUEUE_2v2) ||
_player->InBattlegroundQueueForBattlegroundQueueType(BATTLEGROUND_QUEUE_3v3) ||
_player->InBattlegroundQueueForBattlegroundQueueType(BATTLEGROUND_QUEUE_5v5)) // can't be already queued for arenas
err = ERR_BATTLEGROUND_QUEUED_FOR_RATED;
if (err > 0)
err = grp->CanJoinBattlegroundQueue(bgt, bgQueueTypeId, 0, bgt->GetMaxPlayersPerTeam(), false, 0);
if (err > 0)
err = grp->CanJoinBattlegroundQueue(bgt, bgQueueTypeId, 0, bgt->GetMaxPlayersPerTeam(), false, 0);
bool isPremade = (grp->GetMembersCount() >= bgt->GetMinPlayersPerTeam() && bgTypeId != BATTLEGROUND_RB);
uint32 avgWaitTime = 0;
if (err > 0)
{
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
GroupQueueInfo* ginfo = bgQueue.AddGroup(_player, grp, bracketEntry, false, isPremade, 0, 0, 0);
avgWaitTime = bgQueue.GetAverageQueueWaitTime(ginfo);
}
@@ -362,11 +362,11 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recvData)
recvData >> arenaType >> unk2 >> bgTypeId_ >> unk >> action;
// bgTypeId not valid
// bgTypeId not valid
if (!sBattlemasterListStore.LookupEntry(bgTypeId_))
return;
// player not in any queue, so can't really answer
// player not in any queue, so can't really answer
if (!_player->InBattlegroundQueue())
return;
@@ -414,49 +414,49 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recvData)
action = 0;
}
// get player queue slot index for this bg (can be in up to 2 queues at the same time)
// get player queue slot index for this bg (can be in up to 2 queues at the same time)
uint32 queueSlot = _player->GetBattlegroundQueueIndex(bgQueueTypeId);
WorldPacket data;
switch (action)
{
case 1: // accept
{
// set entry point if not in battleground
if (!_player->InBattleground())
_player->SetEntryPoint();
{
// set entry point if not in battleground
if (!_player->InBattleground())
_player->SetEntryPoint();
// resurrect the player
if (!_player->IsAlive())
{
_player->ResurrectPlayer(1.0f);
_player->SpawnCorpseBones();
}
// resurrect the player
if (!_player->IsAlive())
{
_player->ResurrectPlayer(1.0f);
_player->SpawnCorpseBones();
}
// remove player from all bg queues
for (uint32 qslot = 0; qslot < PLAYER_MAX_BATTLEGROUND_QUEUES; ++qslot)
if (BattlegroundQueueTypeId q = _player->GetBattlegroundQueueTypeId(qslot))
{
BattlegroundQueue& queue = sBattlegroundMgr->GetBattlegroundQueue(q);
queue.RemovePlayer(_player->GetGUID(), (bgQueueTypeId == q), qslot);
_player->RemoveBattlegroundQueueId(q);
}
// remove player from all bg queues
for (uint32 qslot = 0; qslot < PLAYER_MAX_BATTLEGROUND_QUEUES; ++qslot)
if (BattlegroundQueueTypeId q = _player->GetBattlegroundQueueTypeId(qslot))
{
BattlegroundQueue& queue = sBattlegroundMgr->GetBattlegroundQueue(q);
queue.RemovePlayer(_player->GetGUID(), (bgQueueTypeId == q), qslot);
_player->RemoveBattlegroundQueueId(q);
}
// send status packet
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_IN_PROGRESS, 0, bg->GetStartTime(), bg->GetArenaType(), ginfo.teamId);
SendPacket(&data);
// send status packet
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_IN_PROGRESS, 0, bg->GetStartTime(), bg->GetArenaType(), ginfo.teamId);
SendPacket(&data);
_player->SetBattlegroundId(bg->GetInstanceID(), bg->GetBgTypeID(), queueSlot, true, bgTypeId == BATTLEGROUND_RB, ginfo.teamId);
_player->SetBattlegroundId(bg->GetInstanceID(), bg->GetBgTypeID(), queueSlot, true, bgTypeId == BATTLEGROUND_RB, ginfo.teamId);
sBattlegroundMgr->SendToBattleground(_player, ginfo.IsInvitedToBGInstanceGUID, bgTypeId);
}
sBattlegroundMgr->SendToBattleground(_player, ginfo.IsInvitedToBGInstanceGUID, bgTypeId);
}
break;
case 0: // leave queue
{
bgQueue.RemovePlayer(_player->GetGUID(), false, queueSlot);
_player->RemoveBattlegroundQueueId(bgQueueTypeId);
}
break;
{
bgQueue.RemovePlayer(_player->GetGUID(), false, queueSlot);
_player->RemoveBattlegroundQueueId(bgQueueTypeId);
}
break;
default:
break;
}
@@ -482,63 +482,63 @@ void WorldSession::HandleBattlefieldLeaveOpcode(WorldPacket& recvData)
void WorldSession::HandleBattlefieldStatusOpcode(WorldPacket & /*recvData*/)
{
// requested at login and on map change
// send status for current queues and current bg
// requested at login and on map change
// send status for current queues and current bg
WorldPacket data;
WorldPacket data;
// for current bg send STATUS_IN_PROGRESS
if (Battleground* bg = _player->GetBattleground())
if (bg->GetPlayers().count(_player->GetGUID()))
{
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, _player->GetCurrentBattlegroundQueueSlot(), STATUS_IN_PROGRESS, bg->GetEndTime(), bg->GetStartTime(), bg->GetArenaType(), _player->GetBgTeamId());
SendPacket(&data);
}
// for current bg send STATUS_IN_PROGRESS
if (Battleground* bg = _player->GetBattleground())
if (bg->GetPlayers().count(_player->GetGUID()))
{
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, _player->GetCurrentBattlegroundQueueSlot(), STATUS_IN_PROGRESS, bg->GetEndTime(), bg->GetStartTime(), bg->GetArenaType(), _player->GetBgTeamId());
SendPacket(&data);
}
// for queued bgs send STATUS_WAIT_JOIN or STATUS_WAIT_QUEUE
for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
{
// check if in queue
BattlegroundQueueTypeId bgQueueTypeId = _player->GetBattlegroundQueueTypeId(i);
if (!bgQueueTypeId)
continue;
// for queued bgs send STATUS_WAIT_JOIN or STATUS_WAIT_QUEUE
for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
{
// check if in queue
BattlegroundQueueTypeId bgQueueTypeId = _player->GetBattlegroundQueueTypeId(i);
if (!bgQueueTypeId)
continue;
// get group info from queue
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
GroupQueueInfo ginfo;
if (!bgQueue.GetPlayerGroupInfoData(_player->GetGUID(), &ginfo))
continue;
// get group info from queue
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
GroupQueueInfo ginfo;
if (!bgQueue.GetPlayerGroupInfoData(_player->GetGUID(), &ginfo))
continue;
BattlegroundTypeId bgTypeId = BattlegroundMgr::BGTemplateId(bgQueueTypeId);
// if invited - send STATUS_WAIT_JOIN
if (ginfo.IsInvitedToBGInstanceGUID)
{
Battleground* bg = sBattlegroundMgr->GetBattleground(ginfo.IsInvitedToBGInstanceGUID);
if (!bg)
continue;
// if invited - send STATUS_WAIT_JOIN
if (ginfo.IsInvitedToBGInstanceGUID)
{
Battleground* bg = sBattlegroundMgr->GetBattleground(ginfo.IsInvitedToBGInstanceGUID);
if (!bg)
continue;
uint32 remainingTime = (World::GetGameTimeMS() < ginfo.RemoveInviteTime ? getMSTimeDiff(World::GetGameTimeMS(), ginfo.RemoveInviteTime) : 1);
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, i, STATUS_WAIT_JOIN, remainingTime, 0, ginfo.ArenaType, TEAM_NEUTRAL, bg->isRated(), ginfo.BgTypeId);
SendPacket(&data);
}
// if not invited - send STATUS_WAIT_QUEUE
else
{
Battleground* bgt = sBattlegroundMgr->GetBattlegroundTemplate(bgTypeId);
if (!bgt)
continue;
uint32 remainingTime = (World::GetGameTimeMS() < ginfo.RemoveInviteTime ? getMSTimeDiff(World::GetGameTimeMS(), ginfo.RemoveInviteTime) : 1);
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, i, STATUS_WAIT_JOIN, remainingTime, 0, ginfo.ArenaType, TEAM_NEUTRAL, bg->isRated(), ginfo.BgTypeId);
SendPacket(&data);
}
// if not invited - send STATUS_WAIT_QUEUE
else
{
Battleground* bgt = sBattlegroundMgr->GetBattlegroundTemplate(bgTypeId);
if (!bgt)
continue;
// expected bracket entry
PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bgt->GetMapId(), _player->getLevel());
if (!bracketEntry)
continue;
// expected bracket entry
PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bgt->GetMapId(), _player->getLevel());
if (!bracketEntry)
continue;
uint32 avgWaitTime = bgQueue.GetAverageQueueWaitTime(&ginfo);
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bgt, i, STATUS_WAIT_QUEUE, avgWaitTime, getMSTimeDiff(ginfo.JoinTime, World::GetGameTimeMS()), ginfo.ArenaType, TEAM_NEUTRAL, ginfo.IsRated);
SendPacket(&data);
}
}
uint32 avgWaitTime = bgQueue.GetAverageQueueWaitTime(&ginfo);
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bgt, i, STATUS_WAIT_QUEUE, avgWaitTime, getMSTimeDiff(ginfo.JoinTime, World::GetGameTimeMS()), ginfo.ArenaType, TEAM_NEUTRAL, ginfo.IsRated);
SendPacket(&data);
}
}
}
void WorldSession::HandleBattlemasterJoinArena(WorldPacket & recvData)
@@ -550,16 +550,16 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPacket & recvData)
recvData >> guid >> arenaslot >> asGroup >> isRated;
// can't queue for rated without a group
if (isRated && !asGroup)
return;
// find creature by guid
Creature* unit = GetPlayer()->GetMap()->GetCreature(guid);
if (!unit || !unit->IsBattleMaster())
// can't queue for rated without a group
if (isRated && !asGroup)
return;
// get arena type
// find creature by guid
Creature* unit = GetPlayer()->GetMap()->GetCreature(guid);
if (!unit || !unit->IsBattleMaster())
return;
// get arena type
uint8 arenatype = 0;
switch (arenaslot)
{
@@ -581,7 +581,7 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPacket & recvData)
if (!bgt)
return;
// arenas disabled
// arenas disabled
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_BATTLEGROUND, BATTLEGROUND_AA, NULL))
{
ChatHandler(this).PSendSysMessage(LANG_ARENA_DISABLED);
@@ -591,60 +591,60 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPacket & recvData)
BattlegroundTypeId bgTypeId = bgt->GetBgTypeID();
BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(bgTypeId, arenatype);
// expected bracket entry
// expected bracket entry
PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bgt->GetMapId(), _player->getLevel());
if (!bracketEntry)
return;
// pussywizard: if trying to queue for already queued
// just remove from queue and it will requeue!
uint32 qSlot = _player->GetBattlegroundQueueIndex(bgQueueTypeId);
if (qSlot < PLAYER_MAX_BATTLEGROUND_QUEUES)
{
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
// pussywizard: if trying to queue for already queued
// just remove from queue and it will requeue!
uint32 qSlot = _player->GetBattlegroundQueueIndex(bgQueueTypeId);
if (qSlot < PLAYER_MAX_BATTLEGROUND_QUEUES)
{
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
if (bgQueue.IsPlayerInvitedToRatedArena(_player->GetGUID()))
{
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, ERR_BATTLEGROUND_JOIN_FAILED);
SendPacket(&data);
return;
}
if (bgQueue.IsPlayerInvitedToRatedArena(_player->GetGUID()))
{
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, ERR_BATTLEGROUND_JOIN_FAILED);
SendPacket(&data);
return;
}
bgQueue.RemovePlayer(_player->GetGUID(), false, qSlot);
_player->RemoveBattlegroundQueueId(bgQueueTypeId);
}
bgQueue.RemovePlayer(_player->GetGUID(), false, qSlot);
_player->RemoveBattlegroundQueueId(bgQueueTypeId);
}
// must have free queue slot
// pussywizard: allow being queued only in one arena queue, and it even cannot be together with bg queues
if (_player->InBattlegroundQueue())
{
// must have free queue slot
// pussywizard: allow being queued only in one arena queue, and it even cannot be together with bg queues
if (_player->InBattlegroundQueue())
{
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, ERR_BATTLEGROUND_CANNOT_QUEUE_FOR_RATED);
SendPacket(&data);
return;
}
}
// queue result (default ok)
// queue result (default ok)
GroupJoinBattlegroundResult err = GroupJoinBattlegroundResult(bgt->GetBgTypeID());
// check if player can queue:
if (!asGroup)
// check if player can queue:
if (!asGroup)
{
if (GetPlayer()->InBattleground()) // currently in battleground
if (GetPlayer()->InBattleground()) // currently in battleground
err = ERR_BATTLEGROUND_NOT_IN_BATTLEGROUND;
else if (GetPlayer()->isUsingLfg()) // using lfg system
else if (GetPlayer()->isUsingLfg()) // using lfg system
err = ERR_LFG_CANT_USE_BATTLEGROUND;
if (err <= 0)
{
if (err <= 0)
{
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, err);
SendPacket(&data);
return;
}
}
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
GroupQueueInfo* ginfo = bgQueue.AddGroup(_player, NULL, bracketEntry, false, false, 0, 0, 0);
uint32 avgWaitTime = bgQueue.GetAverageQueueWaitTime(ginfo);
@@ -654,73 +654,73 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPacket & recvData)
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bgt, queueSlot, STATUS_WAIT_QUEUE, avgWaitTime, 0, arenatype, TEAM_NEUTRAL);
SendPacket(&data);
}
// check if group can queue:
else
// check if group can queue:
else
{
Group* grp = _player->GetGroup();
Group* grp = _player->GetGroup();
// no group or not a leader
if (!grp || grp->GetLeaderGUID() != _player->GetGUID())
return;
// pussywizard: for party members - remove queues for which leader is not queued to!
std::set<uint32> leaderQueueTypeIds;
for (uint32 i=0; i<PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
leaderQueueTypeIds.insert((uint32)_player->GetBattlegroundQueueTypeId(i));
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
if (Player* member = itr->GetSource())
for (uint32 i=0; i<PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
if (BattlegroundQueueTypeId mqtid = member->GetBattlegroundQueueTypeId(i))
if (leaderQueueTypeIds.count((uint32)mqtid) == 0)
{
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(mqtid);
// pussywizard: for party members - remove queues for which leader is not queued to!
std::set<uint32> leaderQueueTypeIds;
for (uint32 i=0; i<PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
leaderQueueTypeIds.insert((uint32)_player->GetBattlegroundQueueTypeId(i));
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
if (Player* member = itr->GetSource())
for (uint32 i=0; i<PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
if (BattlegroundQueueTypeId mqtid = member->GetBattlegroundQueueTypeId(i))
if (leaderQueueTypeIds.count((uint32)mqtid) == 0)
{
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(mqtid);
if (bgQueue.IsPlayerInvitedToRatedArena(member->GetGUID()))
{
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, ERR_BATTLEGROUND_JOIN_FAILED);
SendPacket(&data);
return;
}
if (bgQueue.IsPlayerInvitedToRatedArena(member->GetGUID()))
{
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, ERR_BATTLEGROUND_JOIN_FAILED);
SendPacket(&data);
return;
}
bgQueue.RemovePlayer(member->GetGUID(), false, i);
member->RemoveBattlegroundQueueId(mqtid);
}
bgQueue.RemovePlayer(member->GetGUID(), false, i);
member->RemoveBattlegroundQueueId(mqtid);
}
uint32 ateamId = 0;
uint32 arenaRating = 0;
uint32 matchmakerRating = 0;
uint32 ateamId = 0;
uint32 arenaRating = 0;
uint32 matchmakerRating = 0;
// additional checks for rated arenas
if (isRated)
{
// pussywizard: for rated matches check if season is in progress!
if (!sWorld->getBoolConfig(CONFIG_ARENA_SEASON_IN_PROGRESS))
return;
// additional checks for rated arenas
if (isRated)
{
// pussywizard: for rated matches check if season is in progress!
if (!sWorld->getBoolConfig(CONFIG_ARENA_SEASON_IN_PROGRESS))
return;
ateamId = _player->GetArenaTeamId(arenaslot);
ateamId = _player->GetArenaTeamId(arenaslot);
// check team existence
ArenaTeam* at = sArenaTeamMgr->GetArenaTeamById(ateamId);
if (!at)
{
SendNotInArenaTeamPacket(arenatype);
return;
}
// check team existence
ArenaTeam* at = sArenaTeamMgr->GetArenaTeamById(ateamId);
if (!at)
{
SendNotInArenaTeamPacket(arenatype);
return;
}
// get team rating for queueing
arenaRating = at->GetRating();
matchmakerRating = at->GetAverageMMR(grp);
if (arenaRating <= 0)
arenaRating = 1;
}
// get team rating for queueing
arenaRating = at->GetRating();
matchmakerRating = at->GetAverageMMR(grp);
if (arenaRating <= 0)
arenaRating = 1;
}
err = grp->CanJoinBattlegroundQueue(bgt, bgQueueTypeId, arenatype, arenatype, (bool)isRated, arenaslot);
uint32 avgWaitTime = 0;
if (err > 0)
{
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
GroupQueueInfo* ginfo = bgQueue.AddGroup(_player, grp, bracketEntry, isRated, false, arenaRating, matchmakerRating, ateamId);
avgWaitTime = bgQueue.GetAverageQueueWaitTime(ginfo);
}
@@ -749,9 +749,9 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPacket & recvData)
member->GetSession()->SendPacket(&data);
}
// pussywizard: schedule update for rated arena
if (ateamId)
sBattlegroundMgr->ScheduleArenaQueueUpdate(ateamId, bgQueueTypeId, bracketEntry->GetBracketId());
// pussywizard: schedule update for rated arena
if (ateamId)
sBattlegroundMgr->ScheduleArenaQueueUpdate(ateamId, bgQueueTypeId, bracketEntry->GetBracketId());
}
}

View File

@@ -141,9 +141,9 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recvData*/)
sentMaps.insert(mapId);
dataBuffer << int32(mapId);
time_t period = sInstanceSaveMgr->GetExtendedResetTimeFor(mapId, (Difficulty)PAIR32_HIPART(itr->first)) - itr->second;
dataBuffer << int32(period); // pussywizard: reset time period
dataBuffer << int32(0); // pussywizard: reset time offset, needed for other than 7-day periods if not aligned with relationTime
time_t period = sInstanceSaveMgr->GetExtendedResetTimeFor(mapId, (Difficulty)PAIR32_HIPART(itr->first)) - itr->second;
dataBuffer << int32(period); // pussywizard: reset time period
dataBuffer << int32(0); // pussywizard: reset time offset, needed for other than 7-day periods if not aligned with relationTime
++boundCounter;
}
@@ -445,15 +445,15 @@ void WorldSession::HandleCalendarEventInvite(WorldPacket& recvData)
else
{
// xinef: Get Data From global storage
if (uint32 guidLow = sWorld->GetGlobalPlayerGUID(name))
{
if (GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(guidLow))
{
inviteeGuid = MAKE_NEW_GUID(guidLow, 0, HIGHGUID_PLAYER);
inviteeTeamId = Player::TeamIdForRace(playerData->race);
inviteeGuildId = playerData->guildId;
}
}
if (uint32 guidLow = sWorld->GetGlobalPlayerGUID(name))
{
if (GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(guidLow))
{
inviteeGuid = MAKE_NEW_GUID(guidLow, 0, HIGHGUID_PLAYER);
inviteeTeamId = Player::TeamIdForRace(playerData->race);
inviteeGuildId = playerData->guildId;
}
}
}
if (!inviteeGuid)
@@ -468,7 +468,7 @@ void WorldSession::HandleCalendarEventInvite(WorldPacket& recvData)
return;
}
// xinef: zomg! sync query
// xinef: zomg! sync query
if (QueryResult result = CharacterDatabase.PQuery("SELECT flags FROM character_social WHERE guid = " UI64FMTD " AND friend = " UI64FMTD, inviteeGuid, playerGuid))
{
Field* fields = result->Fetch();
@@ -700,22 +700,22 @@ void WorldSession::HandleSetSavedInstanceExtend(WorldPacket& recvData)
uint8 toggleExtendOn;
recvData >> mapId >> difficulty>> toggleExtendOn;
const MapEntry* entry = sMapStore.LookupEntry(mapId);
if (!entry || !entry->IsRaid())
return;
InstancePlayerBind* instanceBind = sInstanceSaveMgr->PlayerGetBoundInstance(GetPlayer()->GetGUIDLow(), mapId, Difficulty(difficulty));
if (!instanceBind || !instanceBind->perm || (bool)toggleExtendOn == instanceBind->extended)
const MapEntry* entry = sMapStore.LookupEntry(mapId);
if (!entry || !entry->IsRaid())
return;
instanceBind->extended = (bool)toggleExtendOn;
InstancePlayerBind* instanceBind = sInstanceSaveMgr->PlayerGetBoundInstance(GetPlayer()->GetGUIDLow(), mapId, Difficulty(difficulty));
if (!instanceBind || !instanceBind->perm || (bool)toggleExtendOn == instanceBind->extended)
return;
// update in db
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_INSTANCE_EXTENDED);
stmt->setUInt8(0, toggleExtendOn ? 1 : 0);
stmt->setUInt32(1, GetPlayer()->GetGUIDLow());
stmt->setUInt32(2, instanceBind->save->GetInstanceId());
CharacterDatabase.Execute(stmt);
instanceBind->extended = (bool)toggleExtendOn;
// update in db
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_INSTANCE_EXTENDED);
stmt->setUInt8(0, toggleExtendOn ? 1 : 0);
stmt->setUInt32(1, GetPlayer()->GetGUIDLow());
stmt->setUInt32(2, instanceBind->save->GetInstanceId());
CharacterDatabase.Execute(stmt);
SendCalendarRaidLockoutUpdated(instanceBind->save, (bool)toggleExtendOn);
}

View File

@@ -48,12 +48,12 @@ void WorldSession::HandleJoinChannel(WorldPacket& recvPacket)
return;
if (isdigit(channelName[0]))
return;
return;
// pussywizard: restrict allowed characters in channel name to avoid |0 and possibly other exploits
//if (!ObjectMgr::IsValidChannelName(channelName))
if (channelName.find("|") != std::string::npos || channelName.size() >= 100)
return;
// pussywizard: restrict allowed characters in channel name to avoid |0 and possibly other exploits
//if (!ObjectMgr::IsValidChannelName(channelName))
if (channelName.find("|") != std::string::npos || channelName.size() >= 100)
return;
if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeamId()))
{

View File

@@ -187,13 +187,13 @@ bool LoginQueryHolder::Initialize()
stmt->setUInt32(0, lowGuid);
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_QUEST_STATUS_REW, stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL_ASYNCH);
stmt->setUInt32(0, lowGuid);
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_MAIL, stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL_ASYNCH);
stmt->setUInt32(0, lowGuid);
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_MAIL, stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_BREW_OF_THE_MONTH);
stmt->setUInt32(0, lowGuid);
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_BREW_OF_THE_MONTH, stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_BREW_OF_THE_MONTH);
stmt->setUInt32(0, lowGuid);
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_BREW_OF_THE_MONTH, stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ACCOUNT_INSTANCELOCKTIMES);
stmt->setUInt32(0, m_accountId);
@@ -608,16 +608,16 @@ void WorldSession::HandleCharCreateCallback(PreparedQueryResult result, Characte
;//sLog->outDebug(LOG_FILTER_NETWORKIO, "Character creation %s (account %u) has unhandled tail data: [%u]", createInfo->Name.c_str(), GetAccountId(), unk);
}
// pussywizard:
if (sWorld->GetGlobalPlayerGUID(createInfo->Name))
{
// pussywizard:
if (sWorld->GetGlobalPlayerGUID(createInfo->Name))
{
WorldPacket data(SMSG_CHAR_CREATE, 1);
data << uint8(CHAR_CREATE_NAME_IN_USE);
SendPacket(&data);
delete createInfo;
_charCreateCallback.Reset();
return;
}
}
Player newChar(this);
newChar.GetMotionMaster()->Initialize();
@@ -666,7 +666,7 @@ void WorldSession::HandleCharCreateCallback(PreparedQueryResult result, Characte
;//sLog->outDetail("Account: %d (IP: %s) Create Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), createInfo->Name.c_str(), newChar.GetGUIDLow());
sLog->outChar("Account: %d (IP: %s) Create Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), createInfo->Name.c_str(), newChar.GetGUIDLow());
sScriptMgr->OnPlayerCreate(&newChar);
sWorld->AddGlobalPlayerData(newChar.GetGUIDLow(), GetAccountId(), newChar.GetName(), newChar.getGender(), newChar.getRace(), newChar.getClass(), newChar.getLevel(), 0, 0);
sWorld->AddGlobalPlayerData(newChar.GetGUIDLow(), GetAccountId(), newChar.GetName(), newChar.getGender(), newChar.getRace(), newChar.getClass(), newChar.getLevel(), 0, 0);
newChar.CleanupsBeforeDelete();
delete createInfo;
@@ -711,10 +711,10 @@ void WorldSession::HandleCharDeleteOpcode(WorldPacket& recvData)
return;
}
if (GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(GUID_LOPART(guid)))
{
accountId = playerData->accountId;
name = playerData->name;
if (GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(GUID_LOPART(guid)))
{
accountId = playerData->accountId;
name = playerData->name;
}
// prevent deleting other players' characters using cheating tools
@@ -736,7 +736,7 @@ void WorldSession::HandleCharDeleteOpcode(WorldPacket& recvData)
sCalendarMgr->RemoveAllPlayerEventsAndInvites(guid);
Player::DeleteFromDB(guid, GetAccountId(), true, false);
sWorld->DeleteGlobalPlayerData(GUID_LOPART(guid), name);
sWorld->DeleteGlobalPlayerData(GUID_LOPART(guid), name);
WorldPacket data(SMSG_CHAR_DELETE, 1);
data << (uint8)CHAR_DELETE_SUCCESS;
SendPacket(&data);
@@ -760,92 +760,92 @@ void WorldSession::HandlePlayerLoginOpcode(WorldPacket & recvData)
KickPlayer();
return;
}
// pussywizard:
if (WorldSession* sess = sWorld->FindOfflineSessionForCharacterGUID(GUID_LOPART(playerGuid)))
if (sess->GetAccountId() != GetAccountId())
{
WorldPacket data(SMSG_CHARACTER_LOGIN_FAILED, 1);
data << (uint8)CHAR_LOGIN_DUPLICATE_CHARACTER;
SendPacket(&data);
return;
}
// pussywizard:
if (WorldSession* sess = sWorld->FindOfflineSession(GetAccountId()))
{
Player* p = sess->GetPlayer();
if (!p || sess->IsKicked())
{
WorldPacket data(SMSG_CHARACTER_LOGIN_FAILED, 1);
data << (uint8)CHAR_LOGIN_DUPLICATE_CHARACTER;
SendPacket(&data);
return;
}
// pussywizard:
if (WorldSession* sess = sWorld->FindOfflineSessionForCharacterGUID(GUID_LOPART(playerGuid)))
if (sess->GetAccountId() != GetAccountId())
{
WorldPacket data(SMSG_CHARACTER_LOGIN_FAILED, 1);
data << (uint8)CHAR_LOGIN_DUPLICATE_CHARACTER;
SendPacket(&data);
return;
}
// pussywizard:
if (WorldSession* sess = sWorld->FindOfflineSession(GetAccountId()))
{
Player* p = sess->GetPlayer();
if (!p || sess->IsKicked())
{
WorldPacket data(SMSG_CHARACTER_LOGIN_FAILED, 1);
data << (uint8)CHAR_LOGIN_DUPLICATE_CHARACTER;
SendPacket(&data);
return;
}
if (p->GetGUID() != playerGuid)
sess->KickPlayer(); // no return, go to normal loading
else
{
// pussywizard: players stay ingame no matter what (prevent abuse), but allow to turn it off to stop crashing
if (!sWorld->getBoolConfig(CONFIG_ENABLE_LOGIN_AFTER_DC))
{
WorldPacket data(SMSG_CHARACTER_LOGIN_FAILED, 1);
data << (uint8)CHAR_LOGIN_DUPLICATE_CHARACTER;
SendPacket(&data);
return;
}
if (p->GetGUID() != playerGuid)
sess->KickPlayer(); // no return, go to normal loading
else
{
// pussywizard: players stay ingame no matter what (prevent abuse), but allow to turn it off to stop crashing
if (!sWorld->getBoolConfig(CONFIG_ENABLE_LOGIN_AFTER_DC))
{
WorldPacket data(SMSG_CHARACTER_LOGIN_FAILED, 1);
data << (uint8)CHAR_LOGIN_DUPLICATE_CHARACTER;
SendPacket(&data);
return;
}
uint8 limitA = 10, limitB = 10, limitC = 10; // pussywizard: this somehow froze (probably, ahh crash logs ...), and while (far) have never frozen in LogoutPlayer o_O maybe it's the combination of while(far); while(near);
while (sess->GetPlayer() && (sess->GetPlayer()->IsBeingTeleportedFar() || (sess->GetPlayer()->IsInWorld() && sess->GetPlayer()->IsBeingTeleportedNear())))
{
if (limitA == 0 || --limitA == 0)
{
sLog->outMisc("HandlePlayerLoginOpcode A");
break;
}
while (sess->GetPlayer() && sess->GetPlayer()->IsBeingTeleportedFar())
{
if (limitB == 0 || --limitB == 0)
{
sLog->outMisc("HandlePlayerLoginOpcode B");
break;
}
sess->HandleMoveWorldportAckOpcode();
}
while (sess->GetPlayer() && sess->GetPlayer()->IsInWorld() && sess->GetPlayer()->IsBeingTeleportedNear())
{
if (limitC == 0 || --limitC == 0)
{
sLog->outMisc("HandlePlayerLoginOpcode C");
break;
}
Player* plMover = sess->GetPlayer()->m_mover->ToPlayer();
if (!plMover)
break;
WorldPacket pkt(MSG_MOVE_TELEPORT_ACK, 20);
pkt.append(plMover->GetPackGUID());
pkt << uint32(0); // flags
pkt << uint32(0); // time
sess->HandleMoveTeleportAck(pkt);
}
}
if (!p->FindMap() || !p->IsInWorld() || sess->IsKicked())
{
WorldPacket data(SMSG_CHARACTER_LOGIN_FAILED, 1);
data << (uint8)CHAR_LOGIN_DUPLICATE_CHARACTER;
SendPacket(&data);
return;
}
uint8 limitA = 10, limitB = 10, limitC = 10; // pussywizard: this somehow froze (probably, ahh crash logs ...), and while (far) have never frozen in LogoutPlayer o_O maybe it's the combination of while(far); while(near);
while (sess->GetPlayer() && (sess->GetPlayer()->IsBeingTeleportedFar() || (sess->GetPlayer()->IsInWorld() && sess->GetPlayer()->IsBeingTeleportedNear())))
{
if (limitA == 0 || --limitA == 0)
{
sLog->outMisc("HandlePlayerLoginOpcode A");
break;
}
while (sess->GetPlayer() && sess->GetPlayer()->IsBeingTeleportedFar())
{
if (limitB == 0 || --limitB == 0)
{
sLog->outMisc("HandlePlayerLoginOpcode B");
break;
}
sess->HandleMoveWorldportAckOpcode();
}
while (sess->GetPlayer() && sess->GetPlayer()->IsInWorld() && sess->GetPlayer()->IsBeingTeleportedNear())
{
if (limitC == 0 || --limitC == 0)
{
sLog->outMisc("HandlePlayerLoginOpcode C");
break;
}
Player* plMover = sess->GetPlayer()->m_mover->ToPlayer();
if (!plMover)
break;
WorldPacket pkt(MSG_MOVE_TELEPORT_ACK, 20);
pkt.append(plMover->GetPackGUID());
pkt << uint32(0); // flags
pkt << uint32(0); // time
sess->HandleMoveTeleportAck(pkt);
}
}
if (!p->FindMap() || !p->IsInWorld() || sess->IsKicked())
{
WorldPacket data(SMSG_CHARACTER_LOGIN_FAILED, 1);
data << (uint8)CHAR_LOGIN_DUPLICATE_CHARACTER;
SendPacket(&data);
return;
}
sess->SetPlayer(NULL);
SetPlayer(p);
p->SetSession(this);
delete p->PlayerTalkClass;
p->PlayerTalkClass = new PlayerMenu(p->GetSession());
HandlePlayerLoginToCharInWorld(p);
return;
}
}
sess->SetPlayer(NULL);
SetPlayer(p);
p->SetSession(this);
delete p->PlayerTalkClass;
p->PlayerTalkClass = new PlayerMenu(p->GetSession());
HandlePlayerLoginToCharInWorld(p);
return;
}
}
m_playerLoading = true;
@@ -937,22 +937,22 @@ void WorldSession::HandlePlayerLoginFromDB(LoginQueryHolder* holder)
;//sLog->outStaticDebug("WORLD: Sent server info");
}
if (uint32 guildId = Player::GetGuildIdFromStorage(pCurrChar->GetGUIDLow()))
if (uint32 guildId = Player::GetGuildIdFromStorage(pCurrChar->GetGUIDLow()))
{
Guild* guild = sGuildMgr->GetGuildById(guildId);
Guild::Member const* member = guild ? guild->GetMember(pCurrChar->GetGUID()) : NULL;
if (member)
{
pCurrChar->SetInGuild(guildId);
pCurrChar->SetRank(member->GetRankId());
Guild* guild = sGuildMgr->GetGuildById(guildId);
Guild::Member const* member = guild ? guild->GetMember(pCurrChar->GetGUID()) : NULL;
if (member)
{
pCurrChar->SetInGuild(guildId);
pCurrChar->SetRank(member->GetRankId());
guild->SendLoginInfo(this);
}
else
{
sLog->outError("Player %s (GUID: %u) marked as member of not existing guild (id: %u), removing guild membership for player.", pCurrChar->GetName().c_str(), pCurrChar->GetGUIDLow(), guildId);
pCurrChar->SetInGuild(0);
pCurrChar->SetRank(0);
}
}
else
{
sLog->outError("Player %s (GUID: %u) marked as member of not existing guild (id: %u), removing guild membership for player.", pCurrChar->GetName().c_str(), pCurrChar->GetGUIDLow(), guildId);
pCurrChar->SetInGuild(0);
pCurrChar->SetRank(0);
}
}
else
{
@@ -986,7 +986,7 @@ void WorldSession::HandlePlayerLoginFromDB(LoginQueryHolder* holder)
}
}
// Xinef: moved this from below
// Xinef: moved this from below
sObjectAccessor->AddObject(pCurrChar);
if (!pCurrChar->GetMap()->AddPlayerToMap(pCurrChar) || !pCurrChar->CheckInstanceLoginValid())
@@ -1035,15 +1035,15 @@ void WorldSession::HandlePlayerLoginFromDB(LoginQueryHolder* holder)
pCurrChar->SendInstanceResetWarning(pCurrChar->GetMap()->GetId(), pCurrChar->GetMap()->GetDifficulty(), timeleft, true);
}
// pussywizard: ensure that we end up on map with our loaded transport:
if (Transport* t = pCurrChar->GetTransport())
if (!t->IsInMap(pCurrChar))
{
t->RemovePassenger(pCurrChar);
pCurrChar->m_transport = NULL;
pCurrChar->m_movementInfo.transport.Reset();
pCurrChar->m_movementInfo.RemoveMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
}
// pussywizard: ensure that we end up on map with our loaded transport:
if (Transport* t = pCurrChar->GetTransport())
if (!t->IsInMap(pCurrChar))
{
t->RemovePassenger(pCurrChar);
pCurrChar->m_transport = NULL;
pCurrChar->m_movementInfo.transport.Reset();
pCurrChar->m_movementInfo.RemoveMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
}
// friend status
if (GetSecurity() < SEC_GAMEMASTER) // pussywizard: only for non-gms
@@ -1116,29 +1116,29 @@ void WorldSession::HandlePlayerLoginFromDB(LoginQueryHolder* holder)
// Handle Login-Achievements (should be handled after loading)
_player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_ON_LOGIN, 1);
// Xinef: fix vendors falling of player vehicle, due to isBeingLoaded checks
if (pCurrChar->IsInWorld())
{
if (pCurrChar->GetMountBlockId() && !pCurrChar->HasAuraType(SPELL_AURA_MOUNTED))
{
pCurrChar->CastSpell(pCurrChar, pCurrChar->GetMountBlockId(), true);
pCurrChar->SetMountBlockId(0);
// Xinef: fix vendors falling of player vehicle, due to isBeingLoaded checks
if (pCurrChar->IsInWorld())
{
if (pCurrChar->GetMountBlockId() && !pCurrChar->HasAuraType(SPELL_AURA_MOUNTED))
{
pCurrChar->CastSpell(pCurrChar, pCurrChar->GetMountBlockId(), true);
pCurrChar->SetMountBlockId(0);
// Xinef: refresh this in case mount aura changes anything (eg no fly zone)
pCurrChar->UpdateAreaDependentAuras(pCurrChar->GetAreaId());
pCurrChar->UpdateZoneDependentAuras(pCurrChar->GetZoneId());
}
}
// Xinef: refresh this in case mount aura changes anything (eg no fly zone)
pCurrChar->UpdateAreaDependentAuras(pCurrChar->GetAreaId());
pCurrChar->UpdateZoneDependentAuras(pCurrChar->GetZoneId());
}
}
// pussywizard: pvp mode
pCurrChar->RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_PVP_TIMER);
if (pCurrChar->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP))
pCurrChar->UpdatePvP(true, true);
// pussywizard: pvp mode
pCurrChar->RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_PVP_TIMER);
if (pCurrChar->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP))
pCurrChar->UpdatePvP(true, true);
// pussywizard: on login it's not possible to go back to arena as a spectator, HandleMoveWorldportAckOpcode is not sent, so call it here
pCurrChar->SetIsSpectator(false);
// pussywizard: on login it's not possible to go back to arena as a spectator, HandleMoveWorldportAckOpcode is not sent, so call it here
pCurrChar->SetIsSpectator(false);
// xinef: do this after everything is loaded
// xinef: do this after everything is loaded
pCurrChar->ContinueTaxiFlight();
// reset for all pets before pet loading
@@ -1154,156 +1154,156 @@ void WorldSession::HandlePlayerLoginFromDB(LoginQueryHolder* holder)
void WorldSession::HandlePlayerLoginToCharInWorld(Player* pCurrChar)
{
ChatHandler chH = ChatHandler(this);
m_playerLoading = true;
ChatHandler chH = ChatHandler(this);
m_playerLoading = true;
pCurrChar->SendDungeonDifficulty(false);
pCurrChar->SendDungeonDifficulty(false);
WorldPacket data(SMSG_LOGIN_VERIFY_WORLD, 20);
data << pCurrChar->GetMapId();
data << pCurrChar->GetPositionX();
data << pCurrChar->GetPositionY();
data << pCurrChar->GetPositionZ() + pCurrChar->GetHoverHeight();
data << pCurrChar->GetOrientation();
SendPacket(&data);
WorldPacket data(SMSG_LOGIN_VERIFY_WORLD, 20);
data << pCurrChar->GetMapId();
data << pCurrChar->GetPositionX();
data << pCurrChar->GetPositionY();
data << pCurrChar->GetPositionZ() + pCurrChar->GetHoverHeight();
data << pCurrChar->GetOrientation();
SendPacket(&data);
SendAccountDataTimes(PER_CHARACTER_CACHE_MASK);
SendAccountDataTimes(PER_CHARACTER_CACHE_MASK);
data.Initialize(SMSG_FEATURE_SYSTEM_STATUS, 2); // added in 2.2.0
data << uint8(2); // unknown value
data << uint8(0); // enable(1)/disable(0) voice chat interface in client
SendPacket(&data);
data.Initialize(SMSG_FEATURE_SYSTEM_STATUS, 2); // added in 2.2.0
data << uint8(2); // unknown value
data << uint8(0); // enable(1)/disable(0) voice chat interface in client
SendPacket(&data);
// Send MOTD
{
data.Initialize(SMSG_MOTD, 50); // new in 2.0.1
data << (uint32)0;
// Send MOTD
{
data.Initialize(SMSG_MOTD, 50); // new in 2.0.1
data << (uint32)0;
uint32 linecount=0;
std::string str_motd = sWorld->GetMotd();
std::string::size_type pos, nextpos;
uint32 linecount=0;
std::string str_motd = sWorld->GetMotd();
std::string::size_type pos, nextpos;
pos = 0;
while ((nextpos= str_motd.find('@', pos)) != std::string::npos)
{
if (nextpos != pos)
{
data << str_motd.substr(pos, nextpos-pos);
++linecount;
}
pos = nextpos+1;
}
pos = 0;
while ((nextpos= str_motd.find('@', pos)) != std::string::npos)
{
if (nextpos != pos)
{
data << str_motd.substr(pos, nextpos-pos);
++linecount;
}
pos = nextpos+1;
}
if (pos<str_motd.length())
{
data << str_motd.substr(pos);
++linecount;
}
if (pos<str_motd.length())
{
data << str_motd.substr(pos);
++linecount;
}
data.put(0, linecount);
data.put(0, linecount);
SendPacket(&data);
;//sLog->outStaticDebug("WORLD: Sent motd (SMSG_MOTD)");
SendPacket(&data);
;//sLog->outStaticDebug("WORLD: Sent motd (SMSG_MOTD)");
// send server info
if (sWorld->getIntConfig(CONFIG_ENABLE_SINFO_LOGIN) == 1)
chH.PSendSysMessage(_FULLVERSION);
// send server info
if (sWorld->getIntConfig(CONFIG_ENABLE_SINFO_LOGIN) == 1)
chH.PSendSysMessage(_FULLVERSION);
;//sLog->outStaticDebug("WORLD: Sent server info");
}
;//sLog->outStaticDebug("WORLD: Sent server info");
}
data.Initialize(SMSG_LEARNED_DANCE_MOVES, 4+4);
data << uint32(0);
data << uint32(0);
SendPacket(&data);
data.Initialize(SMSG_LEARNED_DANCE_MOVES, 4+4);
data << uint32(0);
data << uint32(0);
SendPacket(&data);
// Xinef: fix possible problem with flag UNIT_FLAG_STUNNED added during logout
if (!pCurrChar->HasUnitState(UNIT_STATE_STUNNED))
pCurrChar->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
// Xinef: fix possible problem with flag UNIT_FLAG_STUNNED added during logout
if (!pCurrChar->HasUnitState(UNIT_STATE_STUNNED))
pCurrChar->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
pCurrChar->SendInitialPacketsBeforeAddToMap();
pCurrChar->SendInitialPacketsBeforeAddToMap();
// necessary actions from AddPlayerToMap:
pCurrChar->GetMap()->SendInitTransports(pCurrChar);
pCurrChar->GetMap()->SendInitSelf(pCurrChar);
pCurrChar->GetMap()->SendZoneDynamicInfo(pCurrChar);
pCurrChar->m_clientGUIDs.clear();
pCurrChar->UpdateObjectVisibility(false);
// necessary actions from AddPlayerToMap:
pCurrChar->GetMap()->SendInitTransports(pCurrChar);
pCurrChar->GetMap()->SendInitSelf(pCurrChar);
pCurrChar->GetMap()->SendZoneDynamicInfo(pCurrChar);
pCurrChar->m_clientGUIDs.clear();
pCurrChar->UpdateObjectVisibility(false);
pCurrChar->CleanupChannels();
pCurrChar->SendInitialPacketsAfterAddToMap();
uint32 currZone, currArea;
pCurrChar->GetZoneAndAreaId(currZone, currArea, false);
pCurrChar->SendInitWorldStates(currZone, currArea);
pCurrChar->SetInGameTime(World::GetGameTimeMS());
pCurrChar->CleanupChannels();
pCurrChar->SendInitialPacketsAfterAddToMap();
uint32 currZone, currArea;
pCurrChar->GetZoneAndAreaId(currZone, currArea, false);
pCurrChar->SendInitWorldStates(currZone, currArea);
pCurrChar->SetInGameTime(World::GetGameTimeMS());
// Xinef: we need to resend all spell mods
for (uint16 Opcode = SMSG_SET_FLAT_SPELL_MODIFIER; Opcode <= SMSG_SET_PCT_SPELL_MODIFIER; ++Opcode) // PCT = FLAT+1
{
uint32 modType = (Opcode == SMSG_SET_FLAT_SPELL_MODIFIER) ? SPELLMOD_FLAT : SPELLMOD_PCT;
for (uint32 opType = SPELLMOD_DAMAGE; opType < MAX_SPELLMOD; ++opType)
{
int32 i = 0;
flag96 _mask = 0;
SpellModList const& spellMods = pCurrChar->GetSpellModList(opType);
if (spellMods.empty())
continue;
// Xinef: we need to resend all spell mods
for (uint16 Opcode = SMSG_SET_FLAT_SPELL_MODIFIER; Opcode <= SMSG_SET_PCT_SPELL_MODIFIER; ++Opcode) // PCT = FLAT+1
{
uint32 modType = (Opcode == SMSG_SET_FLAT_SPELL_MODIFIER) ? SPELLMOD_FLAT : SPELLMOD_PCT;
for (uint32 opType = SPELLMOD_DAMAGE; opType < MAX_SPELLMOD; ++opType)
{
int32 i = 0;
flag96 _mask = 0;
SpellModList const& spellMods = pCurrChar->GetSpellModList(opType);
if (spellMods.empty())
continue;
for (int32 eff = 0; eff < 96; ++eff)
{
if (eff != 0 && eff%32 == 0)
_mask[i++] = 0;
for (int32 eff = 0; eff < 96; ++eff)
{
if (eff != 0 && eff%32 == 0)
_mask[i++] = 0;
_mask[i] = uint32(1) << (eff-(32*i));
int32 val = 0;
for (SpellModList::const_iterator itr = spellMods.begin(); itr != spellMods.end(); ++itr)
if ((*itr)->type == modType && (*itr)->mask & _mask)
val += (*itr)->value;
_mask[i] = uint32(1) << (eff-(32*i));
int32 val = 0;
for (SpellModList::const_iterator itr = spellMods.begin(); itr != spellMods.end(); ++itr)
if ((*itr)->type == modType && (*itr)->mask & _mask)
val += (*itr)->value;
if (val == 0)
continue;
if (val == 0)
continue;
WorldPacket data(Opcode, (1+1+4));
data << uint8(eff);
data << uint8(opType);
data << int32(val);
SendPacket(&data);
}
}
}
if (Group* group = pCurrChar->GetGroup())
group->SendUpdate();
WorldPacket data(Opcode, (1+1+4));
data << uint8(eff);
data << uint8(opType);
data << int32(val);
SendPacket(&data);
}
}
}
if (Group* group = pCurrChar->GetGroup())
group->SendUpdate();
// pussywizard: send instance welcome message as when entering the instance through a portal
if (MapDifficulty const* mapDiff = GetMapDifficultyData(pCurrChar->GetMap()->GetId(), pCurrChar->GetMap()->GetDifficulty()))
if (mapDiff->resetTime)
if (time_t timeReset = sInstanceSaveMgr->GetResetTimeFor(pCurrChar->GetMap()->GetId(), pCurrChar->GetMap()->GetDifficulty()))
{
uint32 timeleft = uint32(timeReset - time(NULL));
GetPlayer()->SendInstanceResetWarning(pCurrChar->GetMap()->GetId(), pCurrChar->GetMap()->GetDifficulty(), timeleft, true);
}
// pussywizard: send instance welcome message as when entering the instance through a portal
if (MapDifficulty const* mapDiff = GetMapDifficultyData(pCurrChar->GetMap()->GetId(), pCurrChar->GetMap()->GetDifficulty()))
if (mapDiff->resetTime)
if (time_t timeReset = sInstanceSaveMgr->GetResetTimeFor(pCurrChar->GetMap()->GetId(), pCurrChar->GetMap()->GetDifficulty()))
{
uint32 timeleft = uint32(timeReset - time(NULL));
GetPlayer()->SendInstanceResetWarning(pCurrChar->GetMap()->GetId(), pCurrChar->GetMap()->GetDifficulty(), timeleft, true);
}
// this shouldn't do anything, becaues offline can't be on taxi, but just in case
pCurrChar->ContinueTaxiFlight();
// this shouldn't do anything, becaues offline can't be on taxi, but just in case
pCurrChar->ContinueTaxiFlight();
// send pet data, action bar, talents, etc.
pCurrChar->PetSpellInitialize();
pCurrChar->SendTalentsInfoData(true);
// send pet data, action bar, talents, etc.
pCurrChar->PetSpellInitialize();
pCurrChar->SendTalentsInfoData(true);
// show time before shutdown if shutdown planned.
if (sWorld->IsShuttingDown())
sWorld->ShutdownMsg(true, pCurrChar);
// show time before shutdown if shutdown planned.
if (sWorld->IsShuttingDown())
sWorld->ShutdownMsg(true, pCurrChar);
if (pCurrChar->IsGameMaster())
SendNotification(LANG_GM_ON);
if (pCurrChar->IsGameMaster())
SendNotification(LANG_GM_ON);
m_playerLoading = false;
m_playerLoading = false;
}
void WorldSession::HandlePlayerLoginToCharOutOfWorld(Player* pCurrChar)
{
ASSERT(false);
ASSERT(false);
}
void WorldSession::HandleSetFactionAtWar(WorldPacket& recvData)
@@ -1474,14 +1474,14 @@ void WorldSession::HandleChangePlayerNameOpcodeCallBack(PreparedQueryResult resu
CharacterDatabase.Execute(stmt);
// Removed declined name from db
if (sWorld->getBoolConfig(CONFIG_DECLINED_NAMES_USED))
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_DECLINED_NAME);
if (sWorld->getBoolConfig(CONFIG_DECLINED_NAMES_USED))
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_DECLINED_NAME);
stmt->setUInt32(0, guidLow);
stmt->setUInt32(0, guidLow);
CharacterDatabase.Execute(stmt);
}
CharacterDatabase.Execute(stmt);
}
sLog->outChar("Account: %d (IP: %s), Character [%s] (guid: %u) Changed name to: %s", GetAccountId(), GetRemoteAddress().c_str(), oldName.c_str(), guidLow, newName.c_str());
@@ -1491,16 +1491,16 @@ void WorldSession::HandleChangePlayerNameOpcodeCallBack(PreparedQueryResult resu
data << newName;
SendPacket(&data);
// xinef: update global data
sWorld->UpdateGlobalNameData(guidLow, oldName, newName);
sWorld->UpdateGlobalPlayerData(guidLow, PLAYER_UPDATE_DATA_NAME, newName);
// xinef: update global data
sWorld->UpdateGlobalNameData(guidLow, oldName, newName);
sWorld->UpdateGlobalPlayerData(guidLow, PLAYER_UPDATE_DATA_NAME, newName);
}
void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recvData)
{
// pussywizard:
if (!sWorld->getBoolConfig(CONFIG_DECLINED_NAMES_USED))
return;
// pussywizard:
if (!sWorld->getBoolConfig(CONFIG_DECLINED_NAMES_USED))
return;
uint64 guid;
@@ -1703,7 +1703,7 @@ void WorldSession::HandleCharCustomize(WorldPacket& recvData)
GetAccountId(), GetRemoteAddress().c_str(), GUID_LOPART(guid));
recvData.rfinish();
KickPlayer();
return;
return;
}
// pussywizard:
@@ -1721,7 +1721,7 @@ void WorldSession::HandleCharCustomize(WorldPacket& recvData)
uint8 gender, skin, face, hairStyle, hairColor, facialHair;
recvData >> gender >> skin >> hairColor >> hairStyle >> facialHair >> face;
// xinef: zomg! sync query
// xinef: zomg! sync query
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_AT_LOGIN);
stmt->setUInt32(0, GUID_LOPART(guid));
@@ -1736,7 +1736,7 @@ void WorldSession::HandleCharCustomize(WorldPacket& recvData)
return;
}
// get the players old (at this moment current) race
// get the players old (at this moment current) race
GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(GUID_LOPART(guid));
if (!playerData)
{
@@ -1808,18 +1808,18 @@ void WorldSession::HandleCharCustomize(WorldPacket& recvData)
CharacterDatabase.Execute(stmt);
if (sWorld->getBoolConfig(CONFIG_DECLINED_NAMES_USED))
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_DECLINED_NAME);
if (sWorld->getBoolConfig(CONFIG_DECLINED_NAMES_USED))
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_DECLINED_NAME);
stmt->setUInt32(0, GUID_LOPART(guid));
stmt->setUInt32(0, GUID_LOPART(guid));
CharacterDatabase.Execute(stmt);
}
CharacterDatabase.Execute(stmt);
}
// xinef: update global data
sWorld->UpdateGlobalNameData(GUID_LOPART(guid), playerData->name, newName);
sWorld->UpdateGlobalPlayerData(GUID_LOPART(guid), PLAYER_UPDATE_DATA_NAME|PLAYER_UPDATE_DATA_GENDER, newName, 0, gender);
// xinef: update global data
sWorld->UpdateGlobalNameData(GUID_LOPART(guid), playerData->name, newName);
sWorld->UpdateGlobalPlayerData(GUID_LOPART(guid), PLAYER_UPDATE_DATA_NAME|PLAYER_UPDATE_DATA_GENDER, newName, 0, gender);
WorldPacket data(SMSG_CHAR_CUSTOMIZE, 1+8+(newName.size()+1)+6);
data << uint8(RESPONSE_SUCCESS);
@@ -1864,12 +1864,12 @@ void WorldSession::HandleEquipmentSetSave(WorldPacket &recvData)
uint64 itemGuid;
recvData.readPackGUID(itemGuid);
// xinef: if client sends 0, it means empty slot
if (itemGuid == 0)
{
eqSet.Items[i] = 0;
continue;
}
// xinef: if client sends 0, it means empty slot
if (itemGuid == 0)
{
eqSet.Items[i] = 0;
continue;
}
// equipment manager sends "1" (as raw GUID) for slots set to "ignore" (don't touch slot at equip set)
if (itemGuid == 1)
@@ -1879,13 +1879,13 @@ void WorldSession::HandleEquipmentSetSave(WorldPacket &recvData)
continue;
}
// xinef: some cheating checks
// xinef: some cheating checks
Item* item = _player->GetItemByPos(INVENTORY_SLOT_BAG_0, i);
if (!item || item->GetGUID() != itemGuid)
{
eqSet.Items[i] = 0;
continue;
}
{
eqSet.Items[i] = 0;
continue;
}
eqSet.Items[i] = GUID_LOPART(itemGuid);
}
@@ -1926,8 +1926,8 @@ void WorldSession::HandleEquipmentSetUse(WorldPacket &recvData)
continue;
Item* item = NULL;
if (itemGuid > 0)
item = _player->GetItemByGuid(itemGuid);
if (itemGuid > 0)
item = _player->GetItemByGuid(itemGuid);
uint16 dstpos = i | (INVENTORY_SLOT_BAG_0 << 8);
@@ -1974,7 +1974,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData)
GetAccountId(), GetRemoteAddress().c_str(), GUID_LOPART(guid));
recvData.rfinish();
KickPlayer();
return;
return;
}
// pussywizard:
@@ -2002,69 +2002,69 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData)
return;
}
// xinef: add some safety checks
if (recvData.GetOpcode() == CMSG_CHAR_FACTION_CHANGE)
{
// if player is in a guild
if (playerData->guildId)
{
WorldPacket data(SMSG_CHAR_FACTION_CHANGE, 1);
data << (uint8)CHAR_CREATE_CHARACTER_IN_GUILD;
SendPacket(&data);
return;
}
// xinef: add some safety checks
if (recvData.GetOpcode() == CMSG_CHAR_FACTION_CHANGE)
{
// if player is in a guild
if (playerData->guildId)
{
WorldPacket data(SMSG_CHAR_FACTION_CHANGE, 1);
data << (uint8)CHAR_CREATE_CHARACTER_IN_GUILD;
SendPacket(&data);
return;
}
// is arena team captain
if (sArenaTeamMgr->GetArenaTeamByCaptain(guid))
{
WorldPacket data(SMSG_CHAR_FACTION_CHANGE, 1);
data << (uint8)CHAR_CREATE_CHARACTER_ARENA_LEADER;
SendPacket(&data);
return;
}
// is arena team captain
if (sArenaTeamMgr->GetArenaTeamByCaptain(guid))
{
WorldPacket data(SMSG_CHAR_FACTION_CHANGE, 1);
data << (uint8)CHAR_CREATE_CHARACTER_ARENA_LEADER;
SendPacket(&data);
return;
}
// check mailbox
if (playerData->mailCount)
{
WorldPacket data(SMSG_CHAR_FACTION_CHANGE, 1);
data << (uint8)CHAR_CREATE_CHARACTER_DELETE_MAIL;
SendPacket(&data);
return;
}
// check mailbox
if (playerData->mailCount)
{
WorldPacket data(SMSG_CHAR_FACTION_CHANGE, 1);
data << (uint8)CHAR_CREATE_CHARACTER_DELETE_MAIL;
SendPacket(&data);
return;
}
// check auctions, current packet is processed single-threaded way, so not a problem
bool has_auctions = false;
for (uint8 i=0; i<2; ++i) // check both neutral and faction-specific AH
{
AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(i == 0 ? 0 : (((1<<(playerData->race-1))&RACEMASK_ALLIANCE) ? 12 : 29));
AuctionHouseObject::AuctionEntryMap::const_iterator itr = auctionHouse->GetAuctionsBegin();
AuctionHouseObject::AuctionEntryMap::const_iterator _end = auctionHouse->GetAuctionsEnd();
for (; itr != _end; ++itr)
{
AuctionEntry* Aentry = itr->second;
if (Aentry && (Aentry->owner == lowGuid || Aentry->bidder == lowGuid))
{
has_auctions = true;
break;
}
}
if (has_auctions)
break;
}
if (has_auctions)
{
WorldPacket data(SMSG_CHAR_FACTION_CHANGE, 1);
data << (uint8)CHAR_CREATE_ERROR;
SendPacket(&data);
return;
}
}
// check auctions, current packet is processed single-threaded way, so not a problem
bool has_auctions = false;
for (uint8 i=0; i<2; ++i) // check both neutral and faction-specific AH
{
AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(i == 0 ? 0 : (((1<<(playerData->race-1))&RACEMASK_ALLIANCE) ? 12 : 29));
AuctionHouseObject::AuctionEntryMap::const_iterator itr = auctionHouse->GetAuctionsBegin();
AuctionHouseObject::AuctionEntryMap::const_iterator _end = auctionHouse->GetAuctionsEnd();
for (; itr != _end; ++itr)
{
AuctionEntry* Aentry = itr->second;
if (Aentry && (Aentry->owner == lowGuid || Aentry->bidder == lowGuid))
{
has_auctions = true;
break;
}
}
if (has_auctions)
break;
}
if (has_auctions)
{
WorldPacket data(SMSG_CHAR_FACTION_CHANGE, 1);
data << (uint8)CHAR_CREATE_ERROR;
SendPacket(&data);
return;
}
}
uint8 oldRace = playerData->race;
uint8 oldRace = playerData->race;
uint8 playerClass = playerData->playerClass;
uint8 level = playerData->level;
// xinef: zomg! sync query
// xinef: zomg! sync query
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_AT_LOGIN_TITLES_MONEY);
stmt->setUInt32(0, lowGuid);
PreparedQueryResult result = CharacterDatabase.Query(stmt);
@@ -2080,15 +2080,15 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData)
Field* fields = result->Fetch();
uint32 at_loginFlags = fields[0].GetUInt16();
char const* knownTitlesStr = fields[1].GetCString();
uint32 money = fields[2].GetUInt32();
uint32 money = fields[2].GetUInt32();
uint32 used_loginFlag = ((recvData.GetOpcode() == CMSG_CHAR_RACE_CHANGE) ? AT_LOGIN_CHANGE_RACE : AT_LOGIN_CHANGE_FACTION);
// xinef: check money
bool valid = Player::TeamIdForRace(oldRace) == Player::TeamIdForRace(race);
if (level < 10 && money <= 0 || level > 10 && level <= 30 && money <= 3000000 || level > 30 && level <= 50 && money <= 10000000 ||
level > 50 && level <= 70 && money <= 50000000 || level > 70 && money <= 200000000)
valid = true;
if (!valid)
// xinef: check money
bool valid = Player::TeamIdForRace(oldRace) == Player::TeamIdForRace(race);
if (level < 10 && money <= 0 || level > 10 && level <= 30 && money <= 3000000 || level > 30 && level <= 50 && money <= 10000000 ||
level > 50 && level <= 70 && money <= 50000000 || level > 70 && money <= 200000000)
valid = true;
if (!valid)
{
WorldPacket data(SMSG_CHAR_FACTION_CHANGE, 1);
data << uint8(CHAR_CREATE_CHARACTER_GOLD_LIMIT);
@@ -2194,10 +2194,10 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData)
sLog->outChar("Account: %d (IP: %s), Character [%s] (guid: %u) Changed Race/Faction to: %s", GetAccountId(), GetRemoteAddress().c_str(), playerData->name.c_str(), lowGuid, newname.c_str());
// xinef: update global data
sWorld->UpdateGlobalNameData(GUID_LOPART(guid), playerData->name, newname);
sWorld->UpdateGlobalPlayerData(GUID_LOPART(guid),
PLAYER_UPDATE_DATA_NAME|PLAYER_UPDATE_DATA_RACE|PLAYER_UPDATE_DATA_GENDER, newname, 0, gender, race);
// xinef: update global data
sWorld->UpdateGlobalNameData(GUID_LOPART(guid), playerData->name, newname);
sWorld->UpdateGlobalPlayerData(GUID_LOPART(guid),
PLAYER_UPDATE_DATA_NAME|PLAYER_UPDATE_DATA_RACE|PLAYER_UPDATE_DATA_GENDER, newname, 0, gender, race);
if (oldRace != race)
{
@@ -2327,24 +2327,24 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData)
}
// Reset guild
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD))
{
if (uint32 guildId = playerData->guildId)
if (Guild* guild = sGuildMgr->GetGuildById(guildId))
guild->DeleteMember(MAKE_NEW_GUID(lowGuid, 0, HIGHGUID_PLAYER), false, false, true);
}
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD))
{
if (uint32 guildId = playerData->guildId)
if (Guild* guild = sGuildMgr->GetGuildById(guildId))
guild->DeleteMember(MAKE_NEW_GUID(lowGuid, 0, HIGHGUID_PLAYER), false, false, true);
}
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND))
{
// Delete Friend List
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SOCIAL_BY_GUID);
stmt->setUInt32(0, lowGuid);
trans->Append(stmt);
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND))
{
// Delete Friend List
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SOCIAL_BY_GUID);
stmt->setUInt32(0, lowGuid);
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SOCIAL_BY_FRIEND);
stmt->setUInt32(0, lowGuid);
trans->Append(stmt);
}
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SOCIAL_BY_FRIEND);
stmt->setUInt32(0, lowGuid);
trans->Append(stmt);
}
// Leave Arena Teams
Player::LeaveAllArenaTeams(guid);

View File

@@ -60,47 +60,47 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recvData)
//sLog->outDebug("CHAT: packet received. type %u, lang %u", type, lang);
// pussywizard: chatting on most chat types requires 2 hours played to prevent spam/abuse
if (AccountMgr::IsPlayerAccount(GetSecurity()))
switch (type)
{
case CHAT_MSG_ADDON:
case CHAT_MSG_PARTY:
case CHAT_MSG_RAID:
case CHAT_MSG_GUILD:
case CHAT_MSG_OFFICER:
case CHAT_MSG_AFK:
case CHAT_MSG_DND:
case CHAT_MSG_RAID_LEADER:
case CHAT_MSG_RAID_WARNING:
case CHAT_MSG_BATTLEGROUND:
case CHAT_MSG_BATTLEGROUND_LEADER:
case CHAT_MSG_PARTY_LEADER:
break;
default:
if (sender->GetTotalPlayedTime() < 2*HOUR)
{
SendNotification("Speaking is allowed after playing for at least 2 hours. You may use party and guild chat.");
recvData.rfinish();
return;
}
}
// pussywizard: chatting on most chat types requires 2 hours played to prevent spam/abuse
if (AccountMgr::IsPlayerAccount(GetSecurity()))
switch (type)
{
case CHAT_MSG_ADDON:
case CHAT_MSG_PARTY:
case CHAT_MSG_RAID:
case CHAT_MSG_GUILD:
case CHAT_MSG_OFFICER:
case CHAT_MSG_AFK:
case CHAT_MSG_DND:
case CHAT_MSG_RAID_LEADER:
case CHAT_MSG_RAID_WARNING:
case CHAT_MSG_BATTLEGROUND:
case CHAT_MSG_BATTLEGROUND_LEADER:
case CHAT_MSG_PARTY_LEADER:
break;
default:
if (sender->GetTotalPlayedTime() < 2*HOUR)
{
SendNotification("Speaking is allowed after playing for at least 2 hours. You may use party and guild chat.");
recvData.rfinish();
return;
}
}
// pussywizard:
switch (type)
{
case CHAT_MSG_SAY:
case CHAT_MSG_YELL:
case CHAT_MSG_EMOTE:
case CHAT_MSG_TEXT_EMOTE:
case CHAT_MSG_AFK:
case CHAT_MSG_DND:
if (sender->IsSpectator())
{
recvData.rfinish();
return;
}
}
// pussywizard:
switch (type)
{
case CHAT_MSG_SAY:
case CHAT_MSG_YELL:
case CHAT_MSG_EMOTE:
case CHAT_MSG_TEXT_EMOTE:
case CHAT_MSG_AFK:
case CHAT_MSG_DND:
if (sender->IsSpectator())
{
recvData.rfinish();
return;
}
}
// prevent talking at unknown language (cheating)
LanguageDesc const* langDesc = GetLanguageDescByID(lang);
@@ -165,38 +165,38 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recvData)
lang = LANG_UNIVERSAL;
else
{
// send in universal language in two side iteration allowed mode
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT))
lang = LANG_UNIVERSAL;
else
{
switch (type)
{
case CHAT_MSG_PARTY:
case CHAT_MSG_PARTY_LEADER:
case CHAT_MSG_RAID:
case CHAT_MSG_RAID_LEADER:
case CHAT_MSG_RAID_WARNING:
// allow two side chat at group channel if two side group allowed
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP))
lang = LANG_UNIVERSAL;
// send in universal language in two side iteration allowed mode
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT))
lang = LANG_UNIVERSAL;
else
{
switch (type)
{
case CHAT_MSG_PARTY:
case CHAT_MSG_PARTY_LEADER:
case CHAT_MSG_RAID:
case CHAT_MSG_RAID_LEADER:
case CHAT_MSG_RAID_WARNING:
// allow two side chat at group channel if two side group allowed
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP))
lang = LANG_UNIVERSAL;
specialMessageLimit = 35;
break;
case CHAT_MSG_GUILD:
case CHAT_MSG_OFFICER:
// allow two side chat at guild channel if two side guild allowed
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD))
lang = LANG_UNIVERSAL;
specialMessageLimit = 35;
break;
case CHAT_MSG_GUILD:
case CHAT_MSG_OFFICER:
// allow two side chat at guild channel if two side guild allowed
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD))
lang = LANG_UNIVERSAL;
specialMessageLimit = 15;
break;
case CHAT_MSG_WHISPER:
if (sender->getLevel() >= 80)
specialMessageLimit = 15;
break;
}
}
specialMessageLimit = 15;
break;
case CHAT_MSG_WHISPER:
if (sender->getLevel() >= 80)
specialMessageLimit = 15;
break;
}
}
// but overwrite it by SPELL_AURA_MOD_LANGUAGE auras (only single case used)
Unit::AuraEffectList const& ModLangAuras = sender->GetAuraEffectsByType(SPELL_AURA_MOD_LANGUAGE);
if (!ModLangAuras.empty())
@@ -252,9 +252,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recvData)
if (lang != LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHAT_FAKE_MESSAGE_PREVENTING))
stripLineInvisibleChars(msg);
// pussywizard:
if (lang != LANG_ADDON && msg.find("|0") != std::string::npos)
return;
// pussywizard:
if (lang != LANG_ADDON && msg.find("|0") != std::string::npos)
return;
if (!ignoreChecks)
{
@@ -264,12 +264,12 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recvData)
if (ChatHandler(this).ParseCommands(msg.c_str()))
return;
if (!_player->CanSpeak())
{
std::string timeStr = secsToTimeString(m_muteTime - time(NULL));
SendNotification(GetTrinityString(LANG_WAIT_BEFORE_SPEAKING), timeStr.c_str());
return;
}
if (!_player->CanSpeak())
{
std::string timeStr = secsToTimeString(m_muteTime - time(NULL));
SendNotification(GetTrinityString(LANG_WAIT_BEFORE_SPEAKING), timeStr.c_str());
return;
}
if (lang != LANG_ADDON)
{
@@ -286,20 +286,20 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recvData)
}
}
// exploit
size_t found1 = msg.find("|Hquest");
if (found1 != std::string::npos)
{
size_t found2 = msg.find(":", found1+8);
size_t found3 = msg.find("|", found1+8);
if (found3 != std::string::npos)
{
if (found2 == std::string::npos)
return;
if (found2 > found3)
return;
}
}
// exploit
size_t found1 = msg.find("|Hquest");
if (found1 != std::string::npos)
{
size_t found2 = msg.find(":", found1+8);
size_t found3 = msg.find("|", found1+8);
if (found3 != std::string::npos)
{
if (found2 == std::string::npos)
return;
if (found2 > found3)
return;
}
}
switch (type)
@@ -348,7 +348,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recvData)
return;
}
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT) && senderIsPlayer && receiverIsPlayer)
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT) && senderIsPlayer && receiverIsPlayer)
if (GetPlayer()->GetTeamId() != receiver->GetTeamId())
{
SendWrongFactionNotice();
@@ -544,8 +544,8 @@ void WorldSession::HandleEmoteOpcode(WorldPacket & recvData)
if (!GetPlayer()->IsAlive() || GetPlayer()->HasUnitState(UNIT_STATE_DIED))
return;
if (GetPlayer()->IsSpectator())
return;
if (GetPlayer()->IsSpectator())
return;
uint32 emote;
recvData >> emote;
@@ -590,7 +590,7 @@ void WorldSession::HandleTextEmoteOpcode(WorldPacket & recvData)
if (!GetPlayer()->IsAlive())
return;
GetPlayer()->UpdateSpeakTime();
GetPlayer()->UpdateSpeakTime();
if (!GetPlayer()->CanSpeak())
{
@@ -599,8 +599,8 @@ void WorldSession::HandleTextEmoteOpcode(WorldPacket & recvData)
return;
}
if (GetPlayer()->IsSpectator())
return;
if (GetPlayer()->IsSpectator())
return;
uint32 text_emote, emoteNum;
uint64 guid;

View File

@@ -83,11 +83,11 @@ void WorldSession::HandleGroupInviteOpcode(WorldPacket& recvData)
return;
}
if (GetPlayer()->IsSpectator() || player->IsSpectator())
{
if (GetPlayer()->IsSpectator() || player->IsSpectator())
{
SendPartyResult(PARTY_OP_INVITE, membername, ERR_INVITE_RESTRICTED);
return;
}
return;
}
// restrict invite to GMs
if (!sWorld->getBoolConfig(CONFIG_ALLOW_GM_GROUP) && !GetPlayer()->IsGameMaster() && player->IsGameMaster())
@@ -97,7 +97,7 @@ void WorldSession::HandleGroupInviteOpcode(WorldPacket& recvData)
}
// can't group with
if (!GetPlayer()->IsGameMaster() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP) && GetPlayer()->GetTeamId() != player->GetTeamId())
if (!GetPlayer()->IsGameMaster() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP) && GetPlayer()->GetTeamId() != player->GetTeamId())
{
SendPartyResult(PARTY_OP_INVITE, membername, ERR_PLAYER_WRONG_FACTION);
return;
@@ -219,11 +219,11 @@ void WorldSession::HandleGroupAcceptOpcode(WorldPacket& recvData)
// Remove player from invitees in any case
group->RemoveInvite(GetPlayer());
if (GetPlayer()->IsSpectator())
{
if (GetPlayer()->IsSpectator())
{
SendPartyResult(PARTY_OP_INVITE, "", ERR_INVITE_RESTRICTED);
return;
}
return;
}
if (group->GetLeaderGUID() == GetPlayer()->GetGUID())
{
@@ -244,7 +244,7 @@ void WorldSession::HandleGroupAcceptOpcode(WorldPacket& recvData)
if (!group->IsCreated())
{
// This can happen if the leader is zoning. To be removed once delayed actions for zoning are implemented
if (!leader || leader->IsSpectator())
if (!leader || leader->IsSpectator())
{
group->RemoveAllInvites();
return;
@@ -303,8 +303,8 @@ void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket& recvData)
return;
}
// Xinef: name is properly filled in packets
sObjectMgr->GetPlayerNameByGUID(guid, name);
// Xinef: name is properly filled in packets
sObjectMgr->GetPlayerNameByGUID(guid, name);
PartyResult res = GetPlayer()->CanUninviteFromGroup();
if (res != ERR_PARTY_RESULT_OK)
@@ -317,12 +317,12 @@ void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket& recvData)
if (!grp)
return;
// Xinef: do not allow to kick with empty reason, this will resend packet with given reason
if (grp->isLFGGroup() && reason.empty())
{
// Xinef: do not allow to kick with empty reason, this will resend packet with given reason
if (grp->isLFGGroup() && reason.empty())
{
SendPartyResult(PARTY_OP_UNINVITE, name, ERR_VOTE_KICK_REASON_NEEDED);
return;
}
}
if (grp->IsLeader(guid) && !grp->isLFGGroup())
{
@@ -447,8 +447,8 @@ void WorldSession::HandleLootMethodOpcode(WorldPacket& recvData)
return;
/** error handling **/
// Xinef: Check if group is LFG
if (!group->IsLeader(GetPlayer()->GetGUID()) || group->isLFGGroup())
// Xinef: Check if group is LFG
if (!group->IsLeader(GetPlayer()->GetGUID()) || group->isLFGGroup())
return;
if (lootMethod > NEED_BEFORE_GREED)

View File

@@ -46,7 +46,7 @@ void WorldSession::HandleGuildCreateOpcode(WorldPacket& recvPacket)
std::string name;
recvPacket >> name;
sLog->outError("CMSG_GUILD_CREATE: Possible hacking-attempt: %s tried to create a guild [Name: %s] using cheats", GetPlayerInfo().c_str(), name.c_str());
sLog->outError("CMSG_GUILD_CREATE: Possible hacking-attempt: %s tried to create a guild [Name: %s] using cheats", GetPlayerInfo().c_str(), name.c_str());
}
void WorldSession::HandleGuildInviteOpcode(WorldPacket& recvPacket)

View File

@@ -256,8 +256,8 @@ void WorldSession::HandleAutoEquipItemOpcode(WorldPacket & recvData)
_player->AutoUnequipOffhandIfNeed();
// Xinef: Call this here after all needed items are equipped
_player->RemoveItemDependentAurasAndCasts((Item*)NULL);
// Xinef: Call this here after all needed items are equipped
_player->RemoveItemDependentAurasAndCasts((Item*)NULL);
}
}
@@ -306,131 +306,131 @@ void WorldSession::HandleDestroyItemOpcode(WorldPacket & recvData)
void ItemTemplate::InitializeQueryData()
{
queryData.Initialize(SMSG_ITEM_QUERY_SINGLE_RESPONSE, 1);
queryData.Initialize(SMSG_ITEM_QUERY_SINGLE_RESPONSE, 1);
queryData << ItemId;
queryData << Class;
queryData << SubClass;
queryData << SoundOverrideSubclass;
queryData << Name1;
queryData << uint8(0x00); //pProto->Name2; // blizz not send name there, just uint8(0x00); <-- \0 = empty string = empty name...
queryData << uint8(0x00); //pProto->Name3; // blizz not send name there, just uint8(0x00);
queryData << uint8(0x00); //pProto->Name4; // blizz not send name there, just uint8(0x00);
queryData << DisplayInfoID;
queryData << Quality;
queryData << Flags;
queryData << Flags2;
queryData << BuyPrice;
queryData << SellPrice;
queryData << InventoryType;
queryData << AllowableClass;
queryData << AllowableRace;
queryData << ItemLevel;
queryData << RequiredLevel;
queryData << RequiredSkill;
queryData << RequiredSkillRank;
queryData << RequiredSpell;
queryData << RequiredHonorRank;
queryData << RequiredCityRank;
queryData << RequiredReputationFaction;
queryData << RequiredReputationRank;
queryData << int32(MaxCount);
queryData << int32(Stackable);
queryData << ContainerSlots;
queryData << StatsCount; // item stats count
for (uint32 i = 0; i < StatsCount; ++i)
{
queryData << ItemStat[i].ItemStatType;
queryData << ItemStat[i].ItemStatValue;
}
queryData << ScalingStatDistribution; // scaling stats distribution
queryData << ScalingStatValue; // some kind of flags used to determine stat values column
for (int i = 0; i < MAX_ITEM_PROTO_DAMAGES; ++i)
{
queryData << Damage[i].DamageMin;
queryData << Damage[i].DamageMax;
queryData << Damage[i].DamageType;
}
queryData << ItemId;
queryData << Class;
queryData << SubClass;
queryData << SoundOverrideSubclass;
queryData << Name1;
queryData << uint8(0x00); //pProto->Name2; // blizz not send name there, just uint8(0x00); <-- \0 = empty string = empty name...
queryData << uint8(0x00); //pProto->Name3; // blizz not send name there, just uint8(0x00);
queryData << uint8(0x00); //pProto->Name4; // blizz not send name there, just uint8(0x00);
queryData << DisplayInfoID;
queryData << Quality;
queryData << Flags;
queryData << Flags2;
queryData << BuyPrice;
queryData << SellPrice;
queryData << InventoryType;
queryData << AllowableClass;
queryData << AllowableRace;
queryData << ItemLevel;
queryData << RequiredLevel;
queryData << RequiredSkill;
queryData << RequiredSkillRank;
queryData << RequiredSpell;
queryData << RequiredHonorRank;
queryData << RequiredCityRank;
queryData << RequiredReputationFaction;
queryData << RequiredReputationRank;
queryData << int32(MaxCount);
queryData << int32(Stackable);
queryData << ContainerSlots;
queryData << StatsCount; // item stats count
for (uint32 i = 0; i < StatsCount; ++i)
{
queryData << ItemStat[i].ItemStatType;
queryData << ItemStat[i].ItemStatValue;
}
queryData << ScalingStatDistribution; // scaling stats distribution
queryData << ScalingStatValue; // some kind of flags used to determine stat values column
for (int i = 0; i < MAX_ITEM_PROTO_DAMAGES; ++i)
{
queryData << Damage[i].DamageMin;
queryData << Damage[i].DamageMax;
queryData << Damage[i].DamageType;
}
// resistances (7)
queryData << Armor;
queryData << HolyRes;
queryData << FireRes;
queryData << NatureRes;
queryData << FrostRes;
queryData << ShadowRes;
queryData << ArcaneRes;
// resistances (7)
queryData << Armor;
queryData << HolyRes;
queryData << FireRes;
queryData << NatureRes;
queryData << FrostRes;
queryData << ShadowRes;
queryData << ArcaneRes;
queryData << Delay;
queryData << AmmoType;
queryData << RangedModRange;
queryData << Delay;
queryData << AmmoType;
queryData << RangedModRange;
for (int s = 0; s < MAX_ITEM_PROTO_SPELLS; ++s)
{
// send DBC data for cooldowns in same way as it used in Spell::SendSpellCooldown
// use `item_template` or if not set then only use spell cooldowns
SpellInfo const* spell = sSpellMgr->GetSpellInfo(Spells[s].SpellId);
if (spell)
{
bool db_data = Spells[s].SpellCooldown >= 0 || Spells[s].SpellCategoryCooldown >= 0;
for (int s = 0; s < MAX_ITEM_PROTO_SPELLS; ++s)
{
// send DBC data for cooldowns in same way as it used in Spell::SendSpellCooldown
// use `item_template` or if not set then only use spell cooldowns
SpellInfo const* spell = sSpellMgr->GetSpellInfo(Spells[s].SpellId);
if (spell)
{
bool db_data = Spells[s].SpellCooldown >= 0 || Spells[s].SpellCategoryCooldown >= 0;
queryData << Spells[s].SpellId;
queryData << Spells[s].SpellTrigger;
queryData << uint32(-abs(Spells[s].SpellCharges));
queryData << Spells[s].SpellId;
queryData << Spells[s].SpellTrigger;
queryData << uint32(-abs(Spells[s].SpellCharges));
if (db_data)
{
queryData << uint32(Spells[s].SpellCooldown);
queryData << uint32(Spells[s].SpellCategory);
queryData << uint32(Spells[s].SpellCategoryCooldown);
}
else
{
queryData << uint32(spell->RecoveryTime);
queryData << uint32(spell->GetCategory());
queryData << uint32(spell->CategoryRecoveryTime);
}
}
else
{
queryData << uint32(0);
queryData << uint32(0);
queryData << uint32(0);
queryData << uint32(-1);
queryData << uint32(0);
queryData << uint32(-1);
}
}
queryData << Bonding;
queryData << Description;
queryData << PageText;
queryData << LanguageID;
queryData << PageMaterial;
queryData << StartQuest;
queryData << LockID;
queryData << int32(Material);
queryData << Sheath;
queryData << RandomProperty;
queryData << RandomSuffix;
queryData << Block;
queryData << ItemSet;
queryData << MaxDurability;
queryData << Area;
queryData << Map; // Added in 1.12.x & 2.0.1 client branch
queryData << BagFamily;
queryData << TotemCategory;
for (int s = 0; s < MAX_ITEM_PROTO_SOCKETS; ++s)
{
queryData << Socket[s].Color;
queryData << Socket[s].Content;
}
queryData << socketBonus;
queryData << GemProperties;
queryData << RequiredDisenchantSkill;
queryData << ArmorDamageModifier;
queryData << Duration; // added in 2.4.2.8209, duration (seconds)
queryData << ItemLimitCategory; // WotLK, ItemLimitCategory
queryData << HolidayId; // Holiday.dbc?
if (db_data)
{
queryData << uint32(Spells[s].SpellCooldown);
queryData << uint32(Spells[s].SpellCategory);
queryData << uint32(Spells[s].SpellCategoryCooldown);
}
else
{
queryData << uint32(spell->RecoveryTime);
queryData << uint32(spell->GetCategory());
queryData << uint32(spell->CategoryRecoveryTime);
}
}
else
{
queryData << uint32(0);
queryData << uint32(0);
queryData << uint32(0);
queryData << uint32(-1);
queryData << uint32(0);
queryData << uint32(-1);
}
}
queryData << Bonding;
queryData << Description;
queryData << PageText;
queryData << LanguageID;
queryData << PageMaterial;
queryData << StartQuest;
queryData << LockID;
queryData << int32(Material);
queryData << Sheath;
queryData << RandomProperty;
queryData << RandomSuffix;
queryData << Block;
queryData << ItemSet;
queryData << MaxDurability;
queryData << Area;
queryData << Map; // Added in 1.12.x & 2.0.1 client branch
queryData << BagFamily;
queryData << TotemCategory;
for (int s = 0; s < MAX_ITEM_PROTO_SOCKETS; ++s)
{
queryData << Socket[s].Color;
queryData << Socket[s].Content;
}
queryData << socketBonus;
queryData << GemProperties;
queryData << RequiredDisenchantSkill;
queryData << ArmorDamageModifier;
queryData << Duration; // added in 2.4.2.8209, duration (seconds)
queryData << ItemLimitCategory; // WotLK, ItemLimitCategory
queryData << HolidayId; // Holiday.dbc?
}
// Only _static_ data send in this packet !!!
@@ -586,7 +586,7 @@ void WorldSession::HandleSellItemOpcode(WorldPacket & recvData)
_player->RemoveItem(pItem->GetBagSlot(), pItem->GetSlot(), true);
pItem->RemoveFromUpdateQueueOf(_player);
_player->AddItemToBuyBackSlot(pItem);
_player->UpdateTitansGrip();
_player->UpdateTitansGrip();
}
uint32 money = pProto->SellPrice * count;
@@ -871,7 +871,7 @@ void WorldSession::HandleAutoStoreBagItemOpcode(WorldPacket & recvData)
_player->RemoveItem(srcbag, srcslot, true);
_player->StoreItem(dest, pItem, true);
_player->UpdateTitansGrip();
_player->UpdateTitansGrip();
}
void WorldSession::HandleBuyBankSlotOpcode(WorldPacket& recvPacket)
@@ -958,7 +958,7 @@ void WorldSession::HandleAutoBankItemOpcode(WorldPacket& recvPacket)
_player->RemoveItem(srcbag, srcslot, true);
_player->ItemRemovedQuestCheck(pItem->GetEntry(), pItem->GetCount());
_player->BankItem(dest, pItem, true);
_player->UpdateTitansGrip();
_player->UpdateTitansGrip();
}
void WorldSession::HandleAutoStoreBankItemOpcode(WorldPacket& recvPacket)
@@ -990,8 +990,8 @@ void WorldSession::HandleAutoStoreBankItemOpcode(WorldPacket& recvPacket)
}
_player->RemoveItem(srcbag, srcslot, true);
if (Item const* storedItem = _player->StoreItem(dest, pItem, true))
_player->ItemAddedQuestCheck(storedItem->GetEntry(), storedItem->GetCount());
if (Item const* storedItem = _player->StoreItem(dest, pItem, true))
_player->ItemAddedQuestCheck(storedItem->GetEntry(), storedItem->GetCount());
}
else // moving from inventory to bank
{
@@ -1005,7 +1005,7 @@ void WorldSession::HandleAutoStoreBankItemOpcode(WorldPacket& recvPacket)
_player->RemoveItem(srcbag, srcslot, true);
_player->BankItem(dest, pItem, true);
_player->UpdateTitansGrip();
_player->UpdateTitansGrip();
}
}
@@ -1107,8 +1107,8 @@ void WorldSession::HandleWrapItemOpcode(WorldPacket& recvData)
return;
}
// xinef: do not allow to wrap removed items, just in case
if (item->GetState() == ITEM_REMOVED)
// xinef: do not allow to wrap removed items, just in case
if (item->GetState() == ITEM_REMOVED)
{
_player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, item, NULL);
return;
@@ -1182,7 +1182,7 @@ void WorldSession::HandleWrapItemOpcode(WorldPacket& recvData)
item->SetState(ITEM_CHANGED, _player);
// after save it will be impossible to remove the item from the queue
_player->SaveInventoryAndGoldToDB(trans);
_player->SaveInventoryAndGoldToDB(trans);
CharacterDatabase.CommitTransaction(trans);

View File

@@ -45,19 +45,19 @@ void BuildPartyLockDungeonBlock(WorldPacket& data, const lfg::LfgLockPartyMap& l
void WorldSession::HandleLfgJoinOpcode(WorldPacket& recvData)
{
if (!sLFGMgr->isOptionEnabled(lfg::LFG_OPTION_ENABLE_DUNGEON_FINDER | lfg::LFG_OPTION_ENABLE_RAID_BROWSER))
{
recvData.rfinish();
return;
}
if (!sLFGMgr->isOptionEnabled(lfg::LFG_OPTION_ENABLE_DUNGEON_FINDER | lfg::LFG_OPTION_ENABLE_RAID_BROWSER))
{
recvData.rfinish();
return;
}
// pussywizard:
if (Group* g = GetPlayer()->GetGroup())
if (g->isLFGGroup() ? g->GetMembersCount() == MAXGROUPSIZE : g->GetLeaderGUID() != GetPlayer()->GetGUID())
{
recvData.rfinish();
return;
}
// pussywizard:
if (Group* g = GetPlayer()->GetGroup())
if (g->isLFGGroup() ? g->GetMembersCount() == MAXGROUPSIZE : g->GetLeaderGUID() != GetPlayer()->GetGUID())
{
recvData.rfinish();
return;
}
uint8 numDungeons;
uint32 roles;
@@ -88,7 +88,7 @@ void WorldSession::HandleLfgJoinOpcode(WorldPacket& recvData)
recvData >> comment;
;//sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_JOIN [" UI64FMTD "] roles: %u, Dungeons: %u, Comment: %s", GetPlayer()->GetGUID(), roles, uint8(newDungeons.size()), comment.c_str());
sLFGMgr->JoinLfg(GetPlayer(), uint8(roles), newDungeons, comment);
sLFGMgr->JoinLfg(GetPlayer(), uint8(roles), newDungeons, comment);
}
void WorldSession::HandleLfgLeaveOpcode(WorldPacket& /*recvData*/)
@@ -273,16 +273,16 @@ void WorldSession::HandleLfrSearchJoinOpcode(WorldPacket& recvData)
{
uint32 dungeonId;
recvData >> dungeonId;
dungeonId = (dungeonId & 0x00FFFFFF); // remove the type from the dungeon entry
sLFGMgr->LfrSearchAdd(GetPlayer(), dungeonId);
sLFGMgr->SendRaidBrowserCachedList(GetPlayer(), dungeonId);
dungeonId = (dungeonId & 0x00FFFFFF); // remove the type from the dungeon entry
sLFGMgr->LfrSearchAdd(GetPlayer(), dungeonId);
sLFGMgr->SendRaidBrowserCachedList(GetPlayer(), dungeonId);
}
void WorldSession::HandleLfrSearchLeaveOpcode(WorldPacket& recvData)
{
uint32 dungeonId;
recvData >> dungeonId;
sLFGMgr->LfrSearchRemove(GetPlayer());
sLFGMgr->LfrSearchRemove(GetPlayer());
}
void WorldSession::HandleLfgGetStatus(WorldPacket& /*recvData*/)
@@ -428,7 +428,7 @@ void WorldSession::SendLfgRoleCheckUpdate(lfg::LfgRoleCheck const& roleCheck)
Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(guid);
data << uint8(player ? player->getLevel() : 0); // Level
for (lfg::LfgRolesMap::const_iterator it = roleCheck.roles.begin(); it != roleCheck.roles.end(); ++it)
for (lfg::LfgRolesMap::const_iterator it = roleCheck.roles.begin(); it != roleCheck.roles.end(); ++it)
{
if (it->first == roleCheck.leader)
continue;
@@ -516,11 +516,11 @@ void WorldSession::SendLfgPlayerReward(lfg::LfgPlayerRewardData const& rewardDat
void WorldSession::SendLfgBootProposalUpdate(lfg::LfgPlayerBoot const& boot)
{
uint64 guid = GetPlayer()->GetGUID();
lfg::LfgAnswer playerVote = boot.votes.find(guid)->second;
lfg::LfgAnswer playerVote = boot.votes.find(guid)->second;
uint8 votesNum = 0;
uint8 agreeNum = 0;
uint32 secsleft = boot.cancelTime - time(NULL);
for (lfg::LfgAnswerContainer::const_iterator it = boot.votes.begin(); it != boot.votes.end(); ++it)
for (lfg::LfgAnswerContainer::const_iterator it = boot.votes.begin(); it != boot.votes.end(); ++it)
{
if (it->second != lfg::LFG_ANSWER_PENDING)
{

View File

@@ -151,7 +151,7 @@ void WorldSession::HandleLootMoneyOpcode(WorldPacket & /*recvData*/)
case HIGHGUID_VEHICLE:
{
Creature* creature = player->GetMap()->GetCreature(guid);
bool lootAllowed = creature && creature->IsAlive() == (player->getClass() == CLASS_ROGUE && creature->loot.loot_type == LOOT_PICKPOCKETING);
bool lootAllowed = creature && creature->IsAlive() == (player->getClass() == CLASS_ROGUE && creature->loot.loot_type == LOOT_PICKPOCKETING);
if (lootAllowed && creature->IsWithinDistInMap(player, INTERACTION_DISTANCE))
{
loot = &creature->loot;
@@ -291,18 +291,18 @@ void WorldSession::DoLootRelease(uint64 lguid)
go->SetLootState(GO_READY);
}
else
{
{
go->SetLootState(GO_JUST_DEACTIVATED);
// Xinef: moved event execution to loot release (after everything is looted)
// Xinef: 99% sure that this worked like this on blizz
// Xinef: prevents exploits with just opening GO and spawning bilions of npcs, which can crash core if you know what you're doin ;)
if (go->GetGoType() == GAMEOBJECT_TYPE_CHEST && go->GetGOInfo()->chest.eventId)
// Xinef: moved event execution to loot release (after everything is looted)
// Xinef: 99% sure that this worked like this on blizz
// Xinef: prevents exploits with just opening GO and spawning bilions of npcs, which can crash core if you know what you're doin ;)
if (go->GetGoType() == GAMEOBJECT_TYPE_CHEST && go->GetGOInfo()->chest.eventId)
{
;//sLog->outDebug(LOG_FILTER_SPELLS_AURAS, "Chest ScriptStart id %u for GO %u", gameObjTarget->GetGOInfo()->chest.eventId, gameObjTarget->GetDBTableGUIDLow());
player->GetMap()->ScriptsStart(sEventScripts, go->GetGOInfo()->chest.eventId, player, go);
}
}
}
loot->clear();
}
@@ -324,7 +324,7 @@ void WorldSession::DoLootRelease(uint64 lguid)
loot = &corpse->loot;
// Xinef: Buggs client? (Opening loot after closing)
// Xinef: Buggs client? (Opening loot after closing)
//if (loot->isLooted())
{
loot->clear();
@@ -337,7 +337,7 @@ void WorldSession::DoLootRelease(uint64 lguid)
if (!pItem)
return;
loot = &pItem->loot;
loot = &pItem->loot;
ItemTemplate const* proto = pItem->GetTemplate();
// destroy only 5 items from stack in case prospecting and milling
@@ -355,16 +355,16 @@ void WorldSession::DoLootRelease(uint64 lguid)
player->DestroyItemCount(pItem, count, true);
}
else if (pItem->loot.isLooted() || !(proto->Flags & ITEM_PROTO_FLAG_OPENABLE))
{
{
player->DestroyItem(pItem->GetBagSlot(), pItem->GetSlot(), true);
return;
}
return;
}
}
else
{
Creature* creature = GetPlayer()->GetMap()->GetCreature(lguid);
bool lootAllowed = creature && creature->IsAlive() == (player->getClass() == CLASS_ROGUE && creature->loot.loot_type == LOOT_PICKPOCKETING);
bool lootAllowed = creature && creature->IsAlive() == (player->getClass() == CLASS_ROGUE && creature->loot.loot_type == LOOT_PICKPOCKETING);
if (!lootAllowed || !creature->IsWithinDistInMap(_player, INTERACTION_DISTANCE))
return;
@@ -415,18 +415,18 @@ void WorldSession::HandleLootMasterGiveOpcode(WorldPacket& recvData)
Player* target = ObjectAccessor::GetPlayer(*_player, MAKE_NEW_GUID(target_playerguid, 0, HIGHGUID_PLAYER));
if (!target)
{
{
_player->SendLootError(lootguid, LOOT_ERROR_PLAYER_NOT_FOUND);
return;
}
}
;//sLog->outDebug(LOG_FILTER_NETWORKIO, "WorldSession::HandleLootMasterGiveOpcode (CMSG_LOOT_MASTER_GIVE, 0x02A3) Target = [%s].", target->GetName().c_str());
if (_player->GetLootGUID() != lootguid)
{
{
_player->SendLootError(lootguid, LOOT_ERROR_DIDNT_KILL);
return;
}
}
if (!_player->IsInRaidWith(target))
{

View File

@@ -33,7 +33,7 @@ bool WorldSession::CanOpenMailBox(uint64 guid)
{
if (guid == _player->GetGUID())
{
sLog->outError("%s attempt open mailbox in cheating way.", _player->GetName().c_str());
sLog->outError("%s attempt open mailbox in cheating way.", _player->GetName().c_str());
return false;
}
else if (IS_GAMEOBJECT_GUID(guid))
@@ -155,11 +155,11 @@ void WorldSession::HandleSendMail(WorldPacket & recvData)
}
else
{
// xinef: get data from global storage
if (GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(GUID_LOPART(rc)))
{
rc_teamId = Player::TeamIdForRace(playerData->race);
mails_count = playerData->mailCount;
// xinef: get data from global storage
if (GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(GUID_LOPART(rc)))
{
rc_teamId = Player::TeamIdForRace(playerData->race);
mails_count = playerData->mailCount;
}
}
//do not allow to have more than 100 mails in mailbox.. mails count is in opcode uint8!!! - so max can be 255..
@@ -169,7 +169,7 @@ void WorldSession::HandleSendMail(WorldPacket & recvData)
return;
}
// test the receiver's Faction... or all items are account bound
// Xinef: check for boa items, not used currently
// Xinef: check for boa items, not used currently
/*bool accountBound = items_count && !money && !COD ? true : false;
for (uint8 i = 0; i < items_count; ++i)
{
@@ -189,7 +189,7 @@ void WorldSession::HandleSendMail(WorldPacket & recvData)
? receive->GetSession()->GetAccountId()
: sObjectMgr->GetPlayerAccountIdByGUID(rc);
if (/*!accountBound*/ GetAccountId() != rc_account && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_MAIL) && player->GetTeamId() != rc_teamId && AccountMgr::IsPlayerAccount(GetSecurity()))
if (/*!accountBound*/ GetAccountId() != rc_account && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_MAIL) && player->GetTeamId() != rc_teamId && AccountMgr::IsPlayerAccount(GetSecurity()))
{
player->SendMailResult(0, MAIL_SEND, MAIL_ERR_NOT_YOUR_TEAM);
return;
@@ -270,8 +270,8 @@ void WorldSession::HandleSendMail(WorldPacket & recvData)
player->MoveItemFromInventory(items[i]->GetBagSlot(), item->GetSlot(), true);
item->DeleteFromInventoryDB(trans); // deletes item from character's inventory
if (item->GetState() == ITEM_UNCHANGED)
item->FSetState(ITEM_CHANGED); // pussywizard: so the item will be saved and owner will be updated in database
if (item->GetState() == ITEM_UNCHANGED)
item->FSetState(ITEM_CHANGED); // pussywizard: so the item will be saved and owner will be updated in database
item->SetOwnerGUID(rc);
item->SaveToDB(trans); // recursive and not have transaction guard into self, item not in inventory and can be save standalone
@@ -282,11 +282,11 @@ void WorldSession::HandleSendMail(WorldPacket & recvData)
needItemDelay = GetAccountId() != rc_account;
}
if( money >= 10*GOLD )
{
CleanStringForMysqlQuery(subject);
CharacterDatabase.PExecute("INSERT INTO log_money VALUES(%u, %u, \"%s\", \"%s\", %u, \"%s\", %u, \"<MAIL> %s\", NOW())", GetAccountId(), player->GetGUIDLow(), player->GetName().c_str(), player->GetSession()->GetRemoteAddress().c_str(), rc_account, receiver.c_str(), money, subject.c_str());
}
if( money >= 10*GOLD )
{
CleanStringForMysqlQuery(subject);
CharacterDatabase.PExecute("INSERT INTO log_money VALUES(%u, %u, \"%s\", \"%s\", %u, \"%s\", %u, \"<MAIL> %s\", NOW())", GetAccountId(), player->GetGUIDLow(), player->GetName().c_str(), player->GetSession()->GetRemoteAddress().c_str(), rc_account, receiver.c_str(), money, subject.c_str());
}
}
// If theres is an item, there is a one hour delivery delay if sent to another account's character.
@@ -354,8 +354,8 @@ void WorldSession::HandleMailDelete(WorldPacket & recvData)
}
m->state = MAIL_STATE_DELETED;
// xinef: update global data
sWorld->UpdateGlobalPlayerMails(player->GetGUIDLow(), -1);
// xinef: update global data
sWorld->UpdateGlobalPlayerMails(player->GetGUIDLow(), -1);
}
player->SendMailResult(mailId, MAIL_DELETED, MAIL_OK);
}
@@ -418,8 +418,8 @@ void WorldSession::HandleMailReturnToSender(WorldPacket & recvData)
delete m; //we can deallocate old mail
player->SendMailResult(mailId, MAIL_RETURNED_TO_SENDER, MAIL_OK);
// xinef: update global data
sWorld->UpdateGlobalPlayerMails(player->GetGUIDLow(), -1);
// xinef: update global data
sWorld->UpdateGlobalPlayerMails(player->GetGUIDLow(), -1);
}
//called when player takes item attached in mail
@@ -445,13 +445,13 @@ void WorldSession::HandleMailTakeItem(WorldPacket & recvData)
}
// verify that the mail has the item to avoid cheaters taking COD items without paying
bool foundItem = false;
for (std::vector<MailItemInfo>::const_iterator itr = m->items.begin(); itr != m->items.end(); ++itr)
if (itr->item_guid == itemId)
{
foundItem = true;
break;
}
bool foundItem = false;
for (std::vector<MailItemInfo>::const_iterator itr = m->items.begin(); itr != m->items.end(); ++itr)
if (itr->item_guid == itemId)
{
foundItem = true;
break;
}
if (!foundItem)
{
player->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_INTERNAL_ERROR);
@@ -480,9 +480,9 @@ void WorldSession::HandleMailTakeItem(WorldPacket & recvData)
uint64 sender_guid = MAKE_NEW_GUID(m->sender, 0, HIGHGUID_PLAYER);
uint32 sender_accId = 0;
Player* sender = ObjectAccessor::FindPlayerInOrOutOfWorld(sender_guid);
if (sender)
sender_accId = sender->GetSession()->GetAccountId();
else
if (sender)
sender_accId = sender->GetSession()->GetAccountId();
else
sender_accId = sObjectMgr->GetPlayerAccountIdByGUID(sender_guid);
// check player existence
@@ -492,15 +492,15 @@ void WorldSession::HandleMailTakeItem(WorldPacket & recvData)
.AddMoney(m->COD)
.SendMailTo(trans, MailReceiver(sender, m->sender), MailSender(MAIL_NORMAL, m->receiver), MAIL_CHECK_MASK_COD_PAYMENT);
if( m->COD >= 10*GOLD )
{
std::string senderName;
if (!sObjectMgr->GetPlayerNameByGUID(sender_guid, senderName))
senderName = sObjectMgr->GetTrinityStringForDBCLocale(LANG_UNKNOWN);
std::string subj = m->subject;
CleanStringForMysqlQuery(subj);
CharacterDatabase.PExecute("INSERT INTO log_money VALUES(%u, %u, \"%s\", \"%s\", %u, \"%s\", %u, \"<COD> %s\", NOW())", GetAccountId(), player->GetGUIDLow(), player->GetName().c_str(), player->GetSession()->GetRemoteAddress().c_str(), sender_accId, senderName.c_str(), m->COD, subj.c_str());
}
if( m->COD >= 10*GOLD )
{
std::string senderName;
if (!sObjectMgr->GetPlayerNameByGUID(sender_guid, senderName))
senderName = sObjectMgr->GetTrinityStringForDBCLocale(LANG_UNKNOWN);
std::string subj = m->subject;
CleanStringForMysqlQuery(subj);
CharacterDatabase.PExecute("INSERT INTO log_money VALUES(%u, %u, \"%s\", \"%s\", %u, \"%s\", %u, \"<COD> %s\", NOW())", GetAccountId(), player->GetGUIDLow(), player->GetName().c_str(), player->GetSession()->GetRemoteAddress().c_str(), sender_accId, senderName.c_str(), m->COD, subj.c_str());
}
}
player->ModifyMoney(-int32(m->COD));

View File

@@ -173,199 +173,199 @@ void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket & recv_data)
void WorldSession::HandleWhoOpcode(WorldPacket& recvData)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd CMSG_WHO Message");
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd CMSG_WHO Message");
time_t now = time(NULL);
if (now < timeWhoCommandAllowed)
return;
timeWhoCommandAllowed = now + 3;
time_t now = time(NULL);
if (now < timeWhoCommandAllowed)
return;
timeWhoCommandAllowed = now + 3;
uint32 matchcount = 0;
uint32 matchcount = 0;
uint32 level_min, level_max, racemask, classmask, zones_count, str_count;
uint32 zoneids[10]; // 10 is client limit
std::string player_name, guild_name;
uint32 level_min, level_max, racemask, classmask, zones_count, str_count;
uint32 zoneids[10]; // 10 is client limit
std::string player_name, guild_name;
recvData >> level_min; // maximal player level, default 0
recvData >> level_max; // minimal player level, default 100 (MAX_LEVEL)
recvData >> player_name; // player name, case sensitive...
recvData >> level_min; // maximal player level, default 0
recvData >> level_max; // minimal player level, default 100 (MAX_LEVEL)
recvData >> player_name; // player name, case sensitive...
recvData >> guild_name; // guild name, case sensitive...
recvData >> guild_name; // guild name, case sensitive...
recvData >> racemask; // race mask
recvData >> classmask; // class mask
recvData >> zones_count; // zones count, client limit = 10 (2.0.10)
recvData >> racemask; // race mask
recvData >> classmask; // class mask
recvData >> zones_count; // zones count, client limit = 10 (2.0.10)
if (zones_count > 10)
return; // can't be received from real client or broken packet
if (zones_count > 10)
return; // can't be received from real client or broken packet
for (uint32 i = 0; i < zones_count; ++i)
{
uint32 temp;
recvData >> temp; // zone id, 0 if zone is unknown...
zoneids[i] = temp;
sLog->outDebug(LOG_FILTER_NETWORKIO, "Zone %u: %u", i, zoneids[i]);
}
for (uint32 i = 0; i < zones_count; ++i)
{
uint32 temp;
recvData >> temp; // zone id, 0 if zone is unknown...
zoneids[i] = temp;
sLog->outDebug(LOG_FILTER_NETWORKIO, "Zone %u: %u", i, zoneids[i]);
}
recvData >> str_count; // user entered strings count, client limit=4 (checked on 2.0.10)
recvData >> str_count; // user entered strings count, client limit=4 (checked on 2.0.10)
if (str_count > 4)
return; // can't be received from real client or broken packet
if (str_count > 4)
return; // can't be received from real client or broken packet
sLog->outDebug(LOG_FILTER_NETWORKIO, "Minlvl %u, maxlvl %u, name %s, guild %s, racemask %u, classmask %u, zones %u, strings %u", level_min, level_max, player_name.c_str(), guild_name.c_str(), racemask, classmask, zones_count, str_count);
sLog->outDebug(LOG_FILTER_NETWORKIO, "Minlvl %u, maxlvl %u, name %s, guild %s, racemask %u, classmask %u, zones %u, strings %u", level_min, level_max, player_name.c_str(), guild_name.c_str(), racemask, classmask, zones_count, str_count);
std::wstring str[4]; // 4 is client limit
for (uint32 i = 0; i < str_count; ++i)
{
std::string temp;
recvData >> temp; // user entered string, it used as universal search pattern(guild+player name)?
std::wstring str[4]; // 4 is client limit
for (uint32 i = 0; i < str_count; ++i)
{
std::string temp;
recvData >> temp; // user entered string, it used as universal search pattern(guild+player name)?
if (!Utf8toWStr(temp, str[i]))
continue;
if (!Utf8toWStr(temp, str[i]))
continue;
wstrToLower(str[i]);
wstrToLower(str[i]);
sLog->outDebug(LOG_FILTER_NETWORKIO, "String %u: %s", i, temp.c_str());
}
sLog->outDebug(LOG_FILTER_NETWORKIO, "String %u: %s", i, temp.c_str());
}
std::wstring wplayer_name;
std::wstring wguild_name;
if (!(Utf8toWStr(player_name, wplayer_name) && Utf8toWStr(guild_name, wguild_name)))
return;
wstrToLower(wplayer_name);
wstrToLower(wguild_name);
std::wstring wplayer_name;
std::wstring wguild_name;
if (!(Utf8toWStr(player_name, wplayer_name) && Utf8toWStr(guild_name, wguild_name)))
return;
wstrToLower(wplayer_name);
wstrToLower(wguild_name);
// client send in case not set max level value 100 but Trinity supports 255 max level,
// update it to show GMs with characters after 100 level
if (level_max >= MAX_LEVEL)
level_max = STRONG_MAX_LEVEL;
// client send in case not set max level value 100 but Trinity supports 255 max level,
// update it to show GMs with characters after 100 level
if (level_max >= MAX_LEVEL)
level_max = STRONG_MAX_LEVEL;
uint32 team = _player->GetTeamId();
uint32 security = GetSecurity();
bool allowTwoSideWhoList = sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_WHO_LIST);
uint32 gmLevelInWhoList = sWorld->getIntConfig(CONFIG_GM_LEVEL_IN_WHO_LIST);
uint32 displaycount = 0;
uint32 team = _player->GetTeamId();
uint32 security = GetSecurity();
bool allowTwoSideWhoList = sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_WHO_LIST);
uint32 gmLevelInWhoList = sWorld->getIntConfig(CONFIG_GM_LEVEL_IN_WHO_LIST);
uint32 displaycount = 0;
WorldPacket data(SMSG_WHO, 50); // guess size
data << uint32(matchcount); // placeholder, count of players matching criteria
data << uint32(displaycount); // placeholder, count of players displayed
WorldPacket data(SMSG_WHO, 50); // guess size
data << uint32(matchcount); // placeholder, count of players matching criteria
data << uint32(displaycount); // placeholder, count of players displayed
TRINITY_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock());
HashMapHolder<Player>::MapType const& m = sObjectAccessor->GetPlayers();
for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
{
if (AccountMgr::IsPlayerAccount(security))
{
// player can see member of other team only if CONFIG_ALLOW_TWO_SIDE_WHO_LIST
if (itr->second->GetTeamId() != team && !allowTwoSideWhoList)
continue;
TRINITY_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock());
HashMapHolder<Player>::MapType const& m = sObjectAccessor->GetPlayers();
for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
{
if (AccountMgr::IsPlayerAccount(security))
{
// player can see member of other team only if CONFIG_ALLOW_TWO_SIDE_WHO_LIST
if (itr->second->GetTeamId() != team && !allowTwoSideWhoList)
continue;
// player can see MODERATOR, GAME MASTER, ADMINISTRATOR only if CONFIG_GM_IN_WHO_LIST
if ((itr->second->GetSession()->GetSecurity() > AccountTypes(gmLevelInWhoList)))
continue;
}
// player can see MODERATOR, GAME MASTER, ADMINISTRATOR only if CONFIG_GM_IN_WHO_LIST
if ((itr->second->GetSession()->GetSecurity() > AccountTypes(gmLevelInWhoList)))
continue;
}
//do not process players which are not in world
if (!(itr->second->IsInWorld()))
continue;
//do not process players which are not in world
if (!(itr->second->IsInWorld()))
continue;
// check if target is globally visible for player
if (!(itr->second->IsVisibleGloballyFor(_player)))
continue;
// check if target is globally visible for player
if (!(itr->second->IsVisibleGloballyFor(_player)))
continue;
// check if target's level is in level range
uint8 lvl = itr->second->getLevel();
if (lvl < level_min || lvl > level_max)
continue;
// check if target's level is in level range
uint8 lvl = itr->second->getLevel();
if (lvl < level_min || lvl > level_max)
continue;
// check if class matches classmask
uint32 class_ = itr->second->getClass();
if (!(classmask & (1 << class_)))
continue;
// check if class matches classmask
uint32 class_ = itr->second->getClass();
if (!(classmask & (1 << class_)))
continue;
// check if race matches racemask
uint32 race = itr->second->getRace();
if (!(racemask & (1 << race)))
continue;
// check if race matches racemask
uint32 race = itr->second->getRace();
if (!(racemask & (1 << race)))
continue;
uint32 pzoneid = itr->second->GetZoneId();
uint8 gender = itr->second->getGender();
uint32 pzoneid = itr->second->GetZoneId();
uint8 gender = itr->second->getGender();
bool z_show = true;
for (uint32 i = 0; i < zones_count; ++i)
{
if (zoneids[i] == pzoneid)
{
z_show = true;
break;
}
bool z_show = true;
for (uint32 i = 0; i < zones_count; ++i)
{
if (zoneids[i] == pzoneid)
{
z_show = true;
break;
}
z_show = false;
}
if (!z_show)
continue;
z_show = false;
}
if (!z_show)
continue;
std::string pname = itr->second->GetName();
std::wstring wpname;
if (!Utf8toWStr(pname, wpname))
continue;
wstrToLower(wpname);
std::string pname = itr->second->GetName();
std::wstring wpname;
if (!Utf8toWStr(pname, wpname))
continue;
wstrToLower(wpname);
if (!(wplayer_name.empty() || wpname.find(wplayer_name) != std::wstring::npos))
continue;
if (!(wplayer_name.empty() || wpname.find(wplayer_name) != std::wstring::npos))
continue;
std::string gname = sGuildMgr->GetGuildNameById(itr->second->GetGuildId());
std::wstring wgname;
if (!Utf8toWStr(gname, wgname))
continue;
wstrToLower(wgname);
std::string gname = sGuildMgr->GetGuildNameById(itr->second->GetGuildId());
std::wstring wgname;
if (!Utf8toWStr(gname, wgname))
continue;
wstrToLower(wgname);
if (!(wguild_name.empty() || wgname.find(wguild_name) != std::wstring::npos))
continue;
if (!(wguild_name.empty() || wgname.find(wguild_name) != std::wstring::npos))
continue;
std::string aname;
if (AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(itr->second->GetZoneId()))
aname = areaEntry->area_name[GetSessionDbcLocale()];
std::string aname;
if (AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(itr->second->GetZoneId()))
aname = areaEntry->area_name[GetSessionDbcLocale()];
bool s_show = true;
for (uint32 i = 0; i < str_count; ++i)
{
if (!str[i].empty())
{
if (wgname.find(str[i]) != std::wstring::npos ||
wpname.find(str[i]) != std::wstring::npos ||
Utf8FitTo(aname, str[i]))
{
s_show = true;
break;
}
s_show = false;
}
}
if (!s_show)
continue;
bool s_show = true;
for (uint32 i = 0; i < str_count; ++i)
{
if (!str[i].empty())
{
if (wgname.find(str[i]) != std::wstring::npos ||
wpname.find(str[i]) != std::wstring::npos ||
Utf8FitTo(aname, str[i]))
{
s_show = true;
break;
}
s_show = false;
}
}
if (!s_show)
continue;
// 49 is maximum player count sent to client - can be overridden
// through config, but is unstable
if ((matchcount++) >= 50 /*sWorld->getIntConfig(CONFIG_MAX_WHO)*/)
continue;
// 49 is maximum player count sent to client - can be overridden
// through config, but is unstable
if ((matchcount++) >= 50 /*sWorld->getIntConfig(CONFIG_MAX_WHO)*/)
continue;
data << pname; // player name
data << gname; // guild name
data << uint32(lvl); // player level
data << uint32(class_); // player class
data << uint32(race); // player race
data << uint8(gender); // player gender
data << uint32(pzoneid); // player zone id
data << pname; // player name
data << gname; // guild name
data << uint32(lvl); // player level
data << uint32(class_); // player class
data << uint32(race); // player race
data << uint8(gender); // player gender
data << uint32(pzoneid); // player zone id
++displaycount;
}
++displaycount;
}
data.put(0, displaycount); // insert right count, count displayed
data.put(4, matchcount); // insert right count, count of matches
data.put(0, displaycount); // insert right count, count displayed
data.put(4, matchcount); // insert right count, count of matches
SendPacket(&data);
;// sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Send SMSG_WHO Message");
SendPacket(&data);
;// sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Send SMSG_WHO Message");
}
@@ -524,17 +524,17 @@ void WorldSession::HandleAddFriendOpcode(WorldPacket & recv_data)
;//sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: %s asked to add friend : '%s'", GetPlayer()->GetName().c_str(), friendName.c_str());
// xinef: Get Data From global storage
uint32 guidLow = sWorld->GetGlobalPlayerGUID(friendName);
if (!guidLow)
return;
// xinef: Get Data From global storage
uint32 guidLow = sWorld->GetGlobalPlayerGUID(friendName);
if (!guidLow)
return;
GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(guidLow);
if (!playerData)
return;
GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(guidLow);
if (!playerData)
return;
uint64 friendGuid = MAKE_NEW_GUID(guidLow, 0, HIGHGUID_PLAYER);
uint32 friendAccountId = playerData->accountId;
uint32 friendAccountId = playerData->accountId;
TeamId teamId = Player::TeamIdForRace(playerData->race);
FriendsResult friendResult = FRIEND_NOT_FOUND;
@@ -544,7 +544,7 @@ void WorldSession::HandleAddFriendOpcode(WorldPacket & recv_data)
{
if (friendGuid == GetPlayer()->GetGUID())
friendResult = FRIEND_SELF;
else if (GetPlayer()->GetTeamId() != teamId && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND) && AccountMgr::IsPlayerAccount(GetSecurity()))
else if (GetPlayer()->GetTeamId() != teamId && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND) && AccountMgr::IsPlayerAccount(GetSecurity()))
friendResult = FRIEND_ENEMY;
else if (GetPlayer()->GetSocial()->HasFriend(guidLow))
friendResult = FRIEND_ALREADY;
@@ -599,9 +599,9 @@ void WorldSession::HandleAddIgnoreOpcode(WorldPacket & recv_data)
;//sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: %s asked to Ignore: '%s'",
// GetPlayer()->GetName().c_str(), ignoreName.c_str());
uint32 lowGuid = sWorld->GetGlobalPlayerGUID(ignoreName);
uint32 lowGuid = sWorld->GetGlobalPlayerGUID(ignoreName);
if (!lowGuid)
return;
return;
uint64 IgnoreGuid = MAKE_NEW_GUID(lowGuid, 0, HIGHGUID_PLAYER);
FriendsResult ignoreResult = FRIEND_IGNORE_NOT_FOUND;
@@ -640,26 +640,26 @@ void WorldSession::HandleCharacterAuraFrozen(PreparedQueryResult result)
if (!GetPlayer())
return;
ChatHandler handler = ChatHandler(this);
ChatHandler handler = ChatHandler(this);
// Select
if (!result)
{
handler.SendSysMessage(LANG_COMMAND_NO_FROZEN_PLAYERS);
return;
}
// Select
if (!result)
{
handler.SendSysMessage(LANG_COMMAND_NO_FROZEN_PLAYERS);
return;
}
// Header of the names
handler.PSendSysMessage(LANG_COMMAND_LIST_FREEZE);
// Header of the names
handler.PSendSysMessage(LANG_COMMAND_LIST_FREEZE);
// Output of the results
do
{
Field* fields = result->Fetch();
std::string player = fields[0].GetString();
handler.PSendSysMessage(LANG_COMMAND_FROZEN_PLAYERS, player.c_str());
}
while (result->NextRow());
// Output of the results
do
{
Field* fields = result->Fetch();
std::string player = fields[0].GetString();
handler.PSendSysMessage(LANG_COMMAND_FROZEN_PLAYERS, player.c_str());
}
while (result->NextRow());
}
void WorldSession::HandleDelIgnoreOpcode(WorldPacket & recv_data)
@@ -757,8 +757,8 @@ void WorldSession::HandleResurrectResponseOpcode(WorldPacket & recv_data)
recv_data >> guid;
recv_data >> status;
// Xinef: Prevent resurrect with prevent resurrection aura
if (GetPlayer()->IsAlive() || GetPlayer()->HasAuraType(SPELL_AURA_PREVENT_RESURRECTION))
// Xinef: Prevent resurrect with prevent resurrection aura
if (GetPlayer()->IsAlive() || GetPlayer()->HasAuraType(SPELL_AURA_PREVENT_RESURRECTION))
return;
if (status == 0)
@@ -1379,7 +1379,7 @@ void WorldSession::HandleResetInstancesOpcode(WorldPacket & /*recv_data*/)
group->ResetInstances(INSTANCE_RESET_ALL, false, _player);
}
else
Player::ResetInstances(_player->GetGUIDLow(), INSTANCE_RESET_ALL, false);
Player::ResetInstances(_player->GetGUIDLow(), INSTANCE_RESET_ALL, false);
}
void WorldSession::HandleSetDungeonDifficultyOpcode(WorldPacket & recv_data)
@@ -1406,17 +1406,17 @@ void WorldSession::HandleSetDungeonDifficultyOpcode(WorldPacket & recv_data)
if (!groupGuy)
continue;
if (!groupGuy->IsInWorld())
{
_player->SendDungeonDifficulty(group != NULL);
if (!groupGuy->IsInWorld())
{
_player->SendDungeonDifficulty(group != NULL);
return;
}
}
if (groupGuy->GetGUID() == _player->GetGUID() ? groupGuy->GetMap()->IsDungeon() : groupGuy->GetMap()->IsNonRaidDungeon())
{
_player->SendDungeonDifficulty(group != NULL);
if (groupGuy->GetGUID() == _player->GetGUID() ? groupGuy->GetMap()->IsDungeon() : groupGuy->GetMap()->IsNonRaidDungeon())
{
_player->SendDungeonDifficulty(group != NULL);
return;
}
}
}
group->ResetInstances(INSTANCE_RESET_CHANGE_DIFFICULTY, false, _player);
@@ -1425,11 +1425,11 @@ void WorldSession::HandleSetDungeonDifficultyOpcode(WorldPacket & recv_data)
}
else
{
if (_player->FindMap() && _player->FindMap()->IsDungeon())
{
_player->SendDungeonDifficulty(group != NULL);
return;
}
if (_player->FindMap() && _player->FindMap()->IsDungeon())
{
_player->SendDungeonDifficulty(group != NULL);
return;
}
Player::ResetInstances(_player->GetGUIDLow(), INSTANCE_RESET_CHANGE_DIFFICULTY, false);
_player->SetDungeonDifficulty(Difficulty(mode));
}
@@ -1453,26 +1453,26 @@ void WorldSession::HandleSetRaidDifficultyOpcode(WorldPacket & recv_data)
{
if (group->IsLeader(_player->GetGUID()))
{
std::set<uint32> foundMaps;
std::set<Map*> foundMapsPtr;
Map* currMap = NULL;
std::set<uint32> foundMaps;
std::set<Map*> foundMapsPtr;
Map* currMap = NULL;
if (uint32 preventionTime = group->GetDifficultyChangePreventionTime())
{
switch (group->GetDifficultyChangePreventionReason())
{
case DIFFICULTY_PREVENTION_CHANGE_BOSS_KILLED:
ChatHandler(this).PSendSysMessage("Raid was in combat recently and may not change difficulty again for %u sec.", preventionTime);
break;
case DIFFICULTY_PREVENTION_CHANGE_RECENTLY_CHANGED:
default:
ChatHandler(this).PSendSysMessage("Raid difficulty has changed recently, and may not change again for %u sec.", preventionTime);
break;
}
if (uint32 preventionTime = group->GetDifficultyChangePreventionTime())
{
switch (group->GetDifficultyChangePreventionReason())
{
case DIFFICULTY_PREVENTION_CHANGE_BOSS_KILLED:
ChatHandler(this).PSendSysMessage("Raid was in combat recently and may not change difficulty again for %u sec.", preventionTime);
break;
case DIFFICULTY_PREVENTION_CHANGE_RECENTLY_CHANGED:
default:
ChatHandler(this).PSendSysMessage("Raid difficulty has changed recently, and may not change again for %u sec.", preventionTime);
break;
}
_player->SendRaidDifficulty(group != NULL);
return;
}
_player->SendRaidDifficulty(group != NULL);
return;
}
for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{
@@ -1480,113 +1480,113 @@ void WorldSession::HandleSetRaidDifficultyOpcode(WorldPacket & recv_data)
if (!groupGuy)
continue;
if (!groupGuy->IsInWorld())
{
_player->SendRaidDifficulty(group != NULL);
if (!groupGuy->IsInWorld())
{
_player->SendRaidDifficulty(group != NULL);
return;
}
}
if ((groupGuy->GetMap()->GetId() == 631 || groupGuy->GetMap()->GetId() == 724) && mode%2 == _player->GetRaidDifficulty()%2 && group->isRaidGroup())
{
if (!currMap)
currMap = groupGuy->GetMap();
foundMaps.insert(groupGuy->GetMap()->GetId());
foundMapsPtr.insert(groupGuy->GetMap());
if (foundMaps.size() > 1 || foundMapsPtr.size() > 1)
{
_player->SendRaidDifficulty(group != NULL);
return;
}
if ((groupGuy->GetMap()->GetId() == 631 || groupGuy->GetMap()->GetId() == 724) && mode%2 == _player->GetRaidDifficulty()%2 && group->isRaidGroup())
{
if (!currMap)
currMap = groupGuy->GetMap();
foundMaps.insert(groupGuy->GetMap()->GetId());
foundMapsPtr.insert(groupGuy->GetMap());
if (foundMaps.size() > 1 || foundMapsPtr.size() > 1)
{
_player->SendRaidDifficulty(group != NULL);
return;
}
if (!groupGuy->IsAlive() || groupGuy->IsInCombat() || groupGuy->GetVictim() || groupGuy->m_mover != groupGuy || groupGuy->IsNonMeleeSpellCast(true) || !groupGuy->GetMotionMaster()->empty() && groupGuy->GetMotionMaster()->GetCurrentMovementGeneratorType() != IDLE_MOTION_TYPE || !groupGuy->movespline->Finalized() || !groupGuy->GetMap()->ToInstanceMap() || !groupGuy->GetMap()->ToInstanceMap()->GetInstanceScript() || groupGuy->GetMap()->ToInstanceMap()->GetInstanceScript()->IsEncounterInProgress() || !groupGuy->Satisfy(sObjectMgr->GetAccessRequirement(groupGuy->GetMap()->GetId(), Difficulty(mode)), groupGuy->GetMap()->GetId(), false))
{
_player->SendRaidDifficulty(group != NULL);
return;
}
}
else if (groupGuy->GetGUID() == _player->GetGUID() ? groupGuy->GetMap()->IsDungeon() : groupGuy->GetMap()->IsRaid())
{
_player->SendRaidDifficulty(group != NULL);
if (!groupGuy->IsAlive() || groupGuy->IsInCombat() || groupGuy->GetVictim() || groupGuy->m_mover != groupGuy || groupGuy->IsNonMeleeSpellCast(true) || !groupGuy->GetMotionMaster()->empty() && groupGuy->GetMotionMaster()->GetCurrentMovementGeneratorType() != IDLE_MOTION_TYPE || !groupGuy->movespline->Finalized() || !groupGuy->GetMap()->ToInstanceMap() || !groupGuy->GetMap()->ToInstanceMap()->GetInstanceScript() || groupGuy->GetMap()->ToInstanceMap()->GetInstanceScript()->IsEncounterInProgress() || !groupGuy->Satisfy(sObjectMgr->GetAccessRequirement(groupGuy->GetMap()->GetId(), Difficulty(mode)), groupGuy->GetMap()->GetId(), false))
{
_player->SendRaidDifficulty(group != NULL);
return;
}
}
else if (groupGuy->GetGUID() == _player->GetGUID() ? groupGuy->GetMap()->IsDungeon() : groupGuy->GetMap()->IsRaid())
{
_player->SendRaidDifficulty(group != NULL);
return;
}
}
}
Map* homeMap571 = sMapMgr->CreateMap(571, NULL);
Map* homeMap0 = sMapMgr->CreateMap(0, NULL);
ASSERT(homeMap0 && homeMap571);
Map* homeMap571 = sMapMgr->CreateMap(571, NULL);
Map* homeMap0 = sMapMgr->CreateMap(0, NULL);
ASSERT(homeMap0 && homeMap571);
std::map<Player*, Position> playerTeleport;
// handle here all players in the instance that are not in the group
if (currMap)
for (Map::PlayerList::const_iterator itr = currMap->GetPlayers().begin(); itr != currMap->GetPlayers().end(); ++itr)
if (Player* p = itr->GetSource())
if (p->GetGroup() != group)
{
if (!p->IsInWorld() || !p->IsAlive() || p->IsInCombat() || p->GetVictim() || p->m_mover != p || p->IsNonMeleeSpellCast(true) || !p->GetMotionMaster()->empty() && p->GetMotionMaster()->GetCurrentMovementGeneratorType() != IDLE_MOTION_TYPE || !p->movespline->Finalized() || !p->GetMap()->ToInstanceMap() || !p->GetMap()->ToInstanceMap()->GetInstanceScript() || p->GetMap()->ToInstanceMap()->GetInstanceScript()->IsEncounterInProgress())
{
_player->SendRaidDifficulty(group != NULL);
return;
}
playerTeleport[p];
}
for (std::map<Player*, Position>::iterator itr = playerTeleport.begin(); itr != playerTeleport.end(); ++itr)
{
Player* p = itr->first;
Map* oldMap = p->GetMap();
oldMap->RemovePlayerFromMap(p, false);
p->ResetMap();
oldMap->AfterPlayerUnlinkFromMap();
p->SetMap(homeMap0);
p->Relocate(0.0f, 0.0f, 0.0f, 0.0f);
if (!p->TeleportTo(571, 5790.20f, 2071.36f, 636.07f, 3.60f))
p->GetSession()->KickPlayer();
}
std::map<Player*, Position> playerTeleport;
// handle here all players in the instance that are not in the group
if (currMap)
for (Map::PlayerList::const_iterator itr = currMap->GetPlayers().begin(); itr != currMap->GetPlayers().end(); ++itr)
if (Player* p = itr->GetSource())
if (p->GetGroup() != group)
{
if (!p->IsInWorld() || !p->IsAlive() || p->IsInCombat() || p->GetVictim() || p->m_mover != p || p->IsNonMeleeSpellCast(true) || !p->GetMotionMaster()->empty() && p->GetMotionMaster()->GetCurrentMovementGeneratorType() != IDLE_MOTION_TYPE || !p->movespline->Finalized() || !p->GetMap()->ToInstanceMap() || !p->GetMap()->ToInstanceMap()->GetInstanceScript() || p->GetMap()->ToInstanceMap()->GetInstanceScript()->IsEncounterInProgress())
{
_player->SendRaidDifficulty(group != NULL);
return;
}
playerTeleport[p];
}
for (std::map<Player*, Position>::iterator itr = playerTeleport.begin(); itr != playerTeleport.end(); ++itr)
{
Player* p = itr->first;
Map* oldMap = p->GetMap();
oldMap->RemovePlayerFromMap(p, false);
p->ResetMap();
oldMap->AfterPlayerUnlinkFromMap();
p->SetMap(homeMap0);
p->Relocate(0.0f, 0.0f, 0.0f, 0.0f);
if (!p->TeleportTo(571, 5790.20f, 2071.36f, 636.07f, 3.60f))
p->GetSession()->KickPlayer();
}
bool anyoneInside = false;
playerTeleport.clear();
for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* groupGuy = itr->GetSource();
if (!groupGuy)
continue;
bool anyoneInside = false;
playerTeleport.clear();
for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* groupGuy = itr->GetSource();
if (!groupGuy)
continue;
if (groupGuy->GetMap()->GetId() == 631 || groupGuy->GetMap()->GetId() == 724)
{
anyoneInside = true;
if (groupGuy->GetMap()->GetId() == 631 || groupGuy->GetMap()->GetId() == 724)
{
anyoneInside = true;
float x,y,z,o;
groupGuy->GetPosition(x,y,z,o);
Map* oldMap = groupGuy->GetMap();
oldMap->RemovePlayerFromMap(groupGuy, false);
groupGuy->ResetMap();
oldMap->AfterPlayerUnlinkFromMap();
groupGuy->SetMap(homeMap571);
groupGuy->Relocate(5790.20f, 2071.36f, 636.07f, 3.60f);
Position dest = {x, y, z+0.1f, o};
playerTeleport[groupGuy] = dest;
}
}
float x,y,z,o;
groupGuy->GetPosition(x,y,z,o);
Map* oldMap = groupGuy->GetMap();
oldMap->RemovePlayerFromMap(groupGuy, false);
groupGuy->ResetMap();
oldMap->AfterPlayerUnlinkFromMap();
groupGuy->SetMap(homeMap571);
groupGuy->Relocate(5790.20f, 2071.36f, 636.07f, 3.60f);
Position dest = {x, y, z+0.1f, o};
playerTeleport[groupGuy] = dest;
}
}
if (!anyoneInside) // pussywizard: don't reset if changing ICC/RS difficulty while inside
group->ResetInstances(INSTANCE_RESET_CHANGE_DIFFICULTY, true, _player);
if (!anyoneInside) // pussywizard: don't reset if changing ICC/RS difficulty while inside
group->ResetInstances(INSTANCE_RESET_CHANGE_DIFFICULTY, true, _player);
group->SetRaidDifficulty(Difficulty(mode));
group->SetDifficultyChangePrevention(DIFFICULTY_PREVENTION_CHANGE_RECENTLY_CHANGED);
group->SetDifficultyChangePrevention(DIFFICULTY_PREVENTION_CHANGE_RECENTLY_CHANGED);
for (std::map<Player*, Position>::iterator itr = playerTeleport.begin(); itr != playerTeleport.end(); ++itr)
{
itr->first->SetRaidDifficulty(Difficulty(mode)); // needed for teleport not to fail
if (!itr->first->TeleportTo(*(foundMaps.begin()), itr->second.GetPositionX(), itr->second.GetPositionY(), itr->second.GetPositionZ(), itr->second.GetOrientation()))
itr->first->GetSession()->KickPlayer();
}
for (std::map<Player*, Position>::iterator itr = playerTeleport.begin(); itr != playerTeleport.end(); ++itr)
{
itr->first->SetRaidDifficulty(Difficulty(mode)); // needed for teleport not to fail
if (!itr->first->TeleportTo(*(foundMaps.begin()), itr->second.GetPositionX(), itr->second.GetPositionY(), itr->second.GetPositionZ(), itr->second.GetOrientation()))
itr->first->GetSession()->KickPlayer();
}
}
}
else
{
if (_player->FindMap() && _player->FindMap()->IsDungeon())
{
_player->SendRaidDifficulty(group != NULL);
return;
}
if (_player->FindMap() && _player->FindMap()->IsDungeon())
{
_player->SendRaidDifficulty(group != NULL);
return;
}
Player::ResetInstances(_player->GetGUIDLow(), INSTANCE_RESET_CHANGE_DIFFICULTY, true);
_player->SetRaidDifficulty(Difficulty(mode));
}
@@ -1621,12 +1621,12 @@ void WorldSession::HandleMoveSetCanFlyAckOpcode(WorldPacket & recv_data)
uint64 guid; // guid - unused
recv_data.readPackGUID(guid);
// pussywizard: typical check for incomming movement packets
if (!_player->m_mover || !_player->m_mover->IsInWorld() || _player->m_mover->IsDuringRemoveFromWorld() || guid != _player->m_mover->GetGUID())
{
recv_data.rfinish(); // prevent warnings spam
return;
}
// pussywizard: typical check for incomming movement packets
if (!_player->m_mover || !_player->m_mover->IsInWorld() || _player->m_mover->IsDuringRemoveFromWorld() || guid != _player->m_mover->GetGUID())
{
recv_data.rfinish(); // prevent warnings spam
return;
}
recv_data.read_skip<uint32>(); // unk

View File

@@ -75,12 +75,12 @@ void WorldSession::HandleMoveWorldportAckOpcode()
// reset instance validity, except if going to an instance inside an instance
if (GetPlayer()->m_InstanceValid == false && !mInstance)
{
{
GetPlayer()->m_InstanceValid = true;
// pussywizard: m_InstanceValid can be false only by leaving a group in an instance => so remove temp binds that could not be removed because player was still on the map!
if (!sInstanceSaveMgr->PlayerIsPermBoundToInstance(GetPlayer()->GetGUIDLow(), oldMap->GetId(), oldMap->GetDifficulty()))
sInstanceSaveMgr->PlayerUnbindInstance(GetPlayer()->GetGUIDLow(), oldMap->GetId(), oldMap->GetDifficulty(), true);
}
// pussywizard: m_InstanceValid can be false only by leaving a group in an instance => so remove temp binds that could not be removed because player was still on the map!
if (!sInstanceSaveMgr->PlayerIsPermBoundToInstance(GetPlayer()->GetGUIDLow(), oldMap->GetId(), oldMap->GetDifficulty()))
sInstanceSaveMgr->PlayerUnbindInstance(GetPlayer()->GetGUIDLow(), oldMap->GetId(), oldMap->GetDifficulty(), true);
}
// relocate the player to the teleport destination
Map* newMap = sMapMgr->CreateMap(loc.GetMapId(), GetPlayer());
@@ -108,34 +108,34 @@ void WorldSession::HandleMoveWorldportAckOpcode()
return;
}
oldMap->AfterPlayerUnlinkFromMap();
oldMap->AfterPlayerUnlinkFromMap();
// pussywizard: transport teleport couldn't teleport us to the same map (some other teleport pending, reqs not met, etc.), but we still have transport set until player moves! clear it if map differs (crashfix)
if (Transport* t = _player->GetTransport())
if (!t->IsInMap(_player))
{
t->RemovePassenger(_player);
_player->m_transport = NULL;
_player->m_movementInfo.transport.Reset();
_player->m_movementInfo.RemoveMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
}
// pussywizard: transport teleport couldn't teleport us to the same map (some other teleport pending, reqs not met, etc.), but we still have transport set until player moves! clear it if map differs (crashfix)
if (Transport* t = _player->GetTransport())
if (!t->IsInMap(_player))
{
t->RemovePassenger(_player);
_player->m_transport = NULL;
_player->m_movementInfo.transport.Reset();
_player->m_movementInfo.RemoveMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
}
if (!_player->getHostileRefManager().isEmpty())
_player->getHostileRefManager().deleteReferences(); // pussywizard: multithreading crashfix
if (!_player->getHostileRefManager().isEmpty())
_player->getHostileRefManager().deleteReferences(); // pussywizard: multithreading crashfix
CellCoord pair(Trinity::ComputeCellCoord(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY()));
Cell cell(pair);
if (!GridCoord(cell.GridX(), cell.GridY()).IsCoordValid())
{
CellCoord pair(Trinity::ComputeCellCoord(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY()));
Cell cell(pair);
if (!GridCoord(cell.GridX(), cell.GridY()).IsCoordValid())
{
KickPlayer();
return;
}
newMap->LoadGrid(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY());
newMap->LoadGrid(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY());
// pussywizard: player supposed to enter bg map
// pussywizard: player supposed to enter bg map
if (_player->InBattleground())
{
// but landed on another map, cleanup data
// but landed on another map, cleanup data
if (!mEntry->IsBattlegroundOrArena())
_player->SetBattlegroundId(0, BATTLEGROUND_TYPE_NONE, PLAYER_MAX_BATTLEGROUND_QUEUES, false, false, TEAM_NEUTRAL);
// everything ok
@@ -146,39 +146,39 @@ void WorldSession::HandleMoveWorldportAckOpcode()
}
}
// pussywizard: arena spectator stuff
{
if (newMap->IsBattleArena() && ((BattlegroundMap*)newMap)->GetBG() && _player->HasPendingSpectatorForBG(((BattlegroundMap*)newMap)->GetInstanceId()))
{
_player->ClearReceivedSpectatorResetFor();
_player->SetIsSpectator(true);
ArenaSpectator::SendCommand(_player, "%sENABLE", SPECTATOR_ADDON_PREFIX);
((BattlegroundMap*)newMap)->GetBG()->AddSpectator(_player);
ArenaSpectator::HandleResetCommand(_player);
}
else
_player->SetIsSpectator(false);
// pussywizard: arena spectator stuff
{
if (newMap->IsBattleArena() && ((BattlegroundMap*)newMap)->GetBG() && _player->HasPendingSpectatorForBG(((BattlegroundMap*)newMap)->GetInstanceId()))
{
_player->ClearReceivedSpectatorResetFor();
_player->SetIsSpectator(true);
ArenaSpectator::SendCommand(_player, "%sENABLE", SPECTATOR_ADDON_PREFIX);
((BattlegroundMap*)newMap)->GetBG()->AddSpectator(_player);
ArenaSpectator::HandleResetCommand(_player);
}
else
_player->SetIsSpectator(false);
GetPlayer()->SetPendingSpectatorForBG(0);
timeWhoCommandAllowed = time(NULL) + sWorld->GetNextWhoListUpdateDelaySecs() + 1; // after exiting arena Subscribe will scan for a player and cached data says he is still in arena, so disallow until next update
GetPlayer()->SetPendingSpectatorForBG(0);
timeWhoCommandAllowed = time(NULL) + sWorld->GetNextWhoListUpdateDelaySecs() + 1; // after exiting arena Subscribe will scan for a player and cached data says he is still in arena, so disallow until next update
if (uint32 inviteInstanceId = _player->GetPendingSpectatorInviteInstanceId())
{
if (Battleground* tbg = sBattlegroundMgr->GetBattleground(inviteInstanceId))
tbg->RemoveToBeTeleported(_player->GetGUID());
_player->SetPendingSpectatorInviteInstanceId(0);
}
}
if (uint32 inviteInstanceId = _player->GetPendingSpectatorInviteInstanceId())
{
if (Battleground* tbg = sBattlegroundMgr->GetBattleground(inviteInstanceId))
tbg->RemoveToBeTeleported(_player->GetGUID());
_player->SetPendingSpectatorInviteInstanceId(0);
}
}
// xinef: do this again, player can be teleported inside bg->AddPlayer(_player)!!!!
CellCoord pair2(Trinity::ComputeCellCoord(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY()));
Cell cell2(pair2);
if (!GridCoord(cell2.GridX(), cell2.GridY()).IsCoordValid())
{
// xinef: do this again, player can be teleported inside bg->AddPlayer(_player)!!!!
CellCoord pair2(Trinity::ComputeCellCoord(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY()));
Cell cell2(pair2);
if (!GridCoord(cell2.GridX(), cell2.GridY()).IsCoordValid())
{
KickPlayer();
return;
}
newMap->LoadGrid(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY());
newMap->LoadGrid(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY());
GetPlayer()->SendInitialPacketsAfterAddToMap();
@@ -256,35 +256,35 @@ void WorldSession::HandleMoveTeleportAck(WorldPacket& recvData)
uint32 old_zone = plMover->GetZoneId();
WorldLocation const& dest = plMover->GetTeleportDest();
Position oldPos(*plMover);
Position oldPos(*plMover);
plMover->UpdatePosition(dest, true);
// xinef: teleport pets if they are not unsummoned
if (Pet* pet = plMover->GetPet())
{
if (!pet->IsWithinDist3d(plMover, plMover->GetMap()->GetVisibilityRange()-5.0f))
pet->NearTeleportTo(plMover->GetPositionX(), plMover->GetPositionY(), plMover->GetPositionZ(), pet->GetOrientation());
}
// xinef: teleport pets if they are not unsummoned
if (Pet* pet = plMover->GetPet())
{
if (!pet->IsWithinDist3d(plMover, plMover->GetMap()->GetVisibilityRange()-5.0f))
pet->NearTeleportTo(plMover->GetPositionX(), plMover->GetPositionY(), plMover->GetPositionZ(), pet->GetOrientation());
}
if (oldPos.GetExactDist2d(plMover) > 100.0f)
{
uint32 newzone, newarea;
plMover->GetZoneAndAreaId(newzone, newarea, true);
plMover->UpdateZone(newzone, newarea);
if (oldPos.GetExactDist2d(plMover) > 100.0f)
{
uint32 newzone, newarea;
plMover->GetZoneAndAreaId(newzone, newarea, true);
plMover->UpdateZone(newzone, newarea);
// new zone
if (old_zone != newzone)
{
// honorless target
if (plMover->pvpInfo.IsHostile)
plMover->CastSpell(plMover, 2479, true);
// new zone
if (old_zone != newzone)
{
// honorless target
if (plMover->pvpInfo.IsHostile)
plMover->CastSpell(plMover, 2479, true);
// in friendly area
else if (plMover->IsPvP() && !plMover->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP))
plMover->UpdatePvP(false, false);
}
}
// in friendly area
else if (plMover->IsPvP() && !plMover->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP))
plMover->UpdatePvP(false, false);
}
}
// resummon pet
GetPlayer()->ResummonPetTemporaryUnSummonedIfAny();
@@ -292,11 +292,11 @@ void WorldSession::HandleMoveTeleportAck(WorldPacket& recvData)
//lets process all delayed operations on successful teleport
GetPlayer()->ProcessDelayedOperations();
plMover->GetMotionMaster()->ReinitializeMovement();
plMover->GetMotionMaster()->ReinitializeMovement();
// pussywizard: client forgets about losing control, resend it
if (plMover->HasUnitState(UNIT_STATE_FLEEING|UNIT_STATE_CONFUSED) || plMover->IsCharmed()) // only in such cases SetClientControl(self, false) is sent
plMover->SetClientControl(plMover, false, true);
// pussywizard: client forgets about losing control, resend it
if (plMover->HasUnitState(UNIT_STATE_FLEEING|UNIT_STATE_CONFUSED) || plMover->IsCharmed()) // only in such cases SetClientControl(self, false) is sent
plMover->SetClientControl(plMover, false, true);
}
void WorldSession::HandleMovementOpcodes(WorldPacket & recvData)
@@ -339,9 +339,9 @@ void WorldSession::HandleMovementOpcodes(WorldPacket & recvData)
if (movementInfo.flags & MOVEMENTFLAG_ONTRANSPORT)
{
// T_POS ON VEHICLES!
if (mover->GetVehicle())
movementInfo.transport.pos = mover->m_movementInfo.transport.pos;
// T_POS ON VEHICLES!
if (mover->GetVehicle())
movementInfo.transport.pos = mover->m_movementInfo.transport.pos;
// transports size limited
// (also received at zeppelin leave by some reason with t_* as absolute in continent coordinates, can be safely skipped)
@@ -404,9 +404,9 @@ void WorldSession::HandleMovementOpcodes(WorldPacket & recvData)
// now client not include swimming flag in case jumping under water
plrMover->SetInWater(!plrMover->IsInWater() || plrMover->GetBaseMap()->IsUnderWater(movementInfo.pos.GetPositionX(), movementInfo.pos.GetPositionY(), movementInfo.pos.GetPositionZ()));
}
// Dont allow to turn on walking if charming other player
if (mover->GetGUID() != _player->GetGUID())
movementInfo.flags &= ~MOVEMENTFLAG_WALKING;
// Dont allow to turn on walking if charming other player
if (mover->GetGUID() != _player->GetGUID())
movementInfo.flags &= ~MOVEMENTFLAG_WALKING;
uint32 mstime = World::GetGameTimeMS();
/*----------------------*/
@@ -415,19 +415,19 @@ void WorldSession::HandleMovementOpcodes(WorldPacket & recvData)
// Xinef: do not allow to move with UNIT_FLAG_DISABLE_MOVE
if (mover->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE))
{
// Xinef: skip moving packets
if (movementInfo.HasMovementFlag(MOVEMENTFLAG_MASK_MOVING))
return;
movementInfo.pos.Relocate(mover->GetPositionX(), mover->GetPositionY(), mover->GetPositionZ());
{
// Xinef: skip moving packets
if (movementInfo.HasMovementFlag(MOVEMENTFLAG_MASK_MOVING))
return;
movementInfo.pos.Relocate(mover->GetPositionX(), mover->GetPositionY(), mover->GetPositionZ());
if (mover->GetTypeId() == TYPEID_UNIT)
{
movementInfo.transport.guid = mover->m_movementInfo.transport.guid;
movementInfo.transport.pos.Relocate(mover->m_movementInfo.transport.pos.GetPositionX(), mover->m_movementInfo.transport.pos.GetPositionY(), mover->m_movementInfo.transport.pos.GetPositionZ());
movementInfo.transport.seat = mover->m_movementInfo.transport.seat;
}
}
if (mover->GetTypeId() == TYPEID_UNIT)
{
movementInfo.transport.guid = mover->m_movementInfo.transport.guid;
movementInfo.transport.pos.Relocate(mover->m_movementInfo.transport.pos.GetPositionX(), mover->m_movementInfo.transport.pos.GetPositionY(), mover->m_movementInfo.transport.pos.GetPositionZ());
movementInfo.transport.seat = mover->m_movementInfo.transport.seat;
}
}
/* process position-change */
WorldPacket data(opcode, recvData.size());
@@ -444,28 +444,28 @@ void WorldSession::HandleMovementOpcodes(WorldPacket & recvData)
if (mover->GetVehicle())
{
mover->SetOrientation(movementInfo.pos.GetOrientation());
mover->UpdatePosition(movementInfo.pos);
mover->UpdatePosition(movementInfo.pos);
return;
}
// pussywizard: previously always mover->UpdatePosition(movementInfo.pos);
if (movementInfo.flags & MOVEMENTFLAG_ONTRANSPORT && mover->GetTransport())
{
float x, y, z, o;
movementInfo.transport.pos.GetPosition(x, y, z, o);
mover->GetTransport()->CalculatePassengerPosition(x, y, z, &o);
mover->UpdatePosition(x, y, z, o);
}
else
mover->UpdatePosition(movementInfo.pos);
// pussywizard: previously always mover->UpdatePosition(movementInfo.pos);
if (movementInfo.flags & MOVEMENTFLAG_ONTRANSPORT && mover->GetTransport())
{
float x, y, z, o;
movementInfo.transport.pos.GetPosition(x, y, z, o);
mover->GetTransport()->CalculatePassengerPosition(x, y, z, &o);
mover->UpdatePosition(x, y, z, o);
}
else
mover->UpdatePosition(movementInfo.pos);
// fall damage generation (ignore in flight case that can be triggered also at lags in moment teleportation to another map).
// Xinef: moved it here, previously StopMoving function called when player died relocated him to last saved coordinates (which were in air)
// fall damage generation (ignore in flight case that can be triggered also at lags in moment teleportation to another map).
// Xinef: moved it here, previously StopMoving function called when player died relocated him to last saved coordinates (which were in air)
if (opcode == MSG_MOVE_FALL_LAND && plrMover && !plrMover->IsInFlight() && (!plrMover->GetTransport() || plrMover->GetTransport()->IsStaticTransport()))
plrMover->HandleFall(movementInfo);
// Xinef: interrupt parachutes upon falling or landing in water
if (opcode == MSG_MOVE_FALL_LAND || opcode == MSG_MOVE_START_SWIM)
mover->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_LANDING); // Parachutes
// Xinef: interrupt parachutes upon falling or landing in water
if (opcode == MSG_MOVE_FALL_LAND || opcode == MSG_MOVE_START_SWIM)
mover->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_LANDING); // Parachutes
if (plrMover) // nothing is charmed, or player charmed
@@ -502,12 +502,12 @@ void WorldSession::HandleForceSpeedChangeAck(WorldPacket &recvData)
recvData.readPackGUID(guid);
// pussywizard: special check, only player mover allowed here
if (guid != _player->m_mover->GetGUID() || guid != _player->GetGUID())
{
recvData.rfinish(); // prevent warnings spam
return;
}
// pussywizard: special check, only player mover allowed here
if (guid != _player->m_mover->GetGUID() || guid != _player->GetGUID())
{
recvData.rfinish(); // prevent warnings spam
return;
}
// continue parse packet
@@ -590,12 +590,12 @@ void WorldSession::HandleMoveNotActiveMover(WorldPacket &recvData)
uint64 old_mover_guid;
recvData.readPackGUID(old_mover_guid);
// pussywizard: typical check for incomming movement packets
if (!_player->m_mover || !_player->m_mover->IsInWorld() || _player->m_mover->IsDuringRemoveFromWorld() || old_mover_guid != _player->m_mover->GetGUID())
{
recvData.rfinish(); // prevent warnings spam
return;
}
// pussywizard: typical check for incomming movement packets
if (!_player->m_mover || !_player->m_mover->IsInWorld() || _player->m_mover->IsDuringRemoveFromWorld() || old_mover_guid != _player->m_mover->GetGUID())
{
recvData.rfinish(); // prevent warnings spam
return;
}
MovementInfo mi;
mi.guid = old_mover_guid;
@@ -619,12 +619,12 @@ void WorldSession::HandleMoveKnockBackAck(WorldPacket & recvData)
uint64 guid;
recvData.readPackGUID(guid);
// pussywizard: typical check for incomming movement packets
if (!_player->m_mover || !_player->m_mover->IsInWorld() || _player->m_mover->IsDuringRemoveFromWorld() || guid != _player->m_mover->GetGUID())
{
recvData.rfinish(); // prevent warnings spam
return;
}
// pussywizard: typical check for incomming movement packets
if (!_player->m_mover || !_player->m_mover->IsInWorld() || _player->m_mover->IsDuringRemoveFromWorld() || guid != _player->m_mover->GetGUID())
{
recvData.rfinish(); // prevent warnings spam
return;
}
recvData.read_skip<uint32>(); // unk
@@ -657,7 +657,7 @@ void WorldSession::HandleMoveHoverAck(WorldPacket& recvData)
recvData.read_skip<uint32>(); // unk
MovementInfo movementInfo;
movementInfo.guid = guid;
movementInfo.guid = guid;
ReadMovementInfo(recvData, &movementInfo);
recvData.read_skip<uint32>(); // unk2
@@ -673,7 +673,7 @@ void WorldSession::HandleMoveWaterWalkAck(WorldPacket& recvData)
recvData.read_skip<uint32>(); // unk
MovementInfo movementInfo;
movementInfo.guid = guid;
movementInfo.guid = guid;
ReadMovementInfo(recvData, &movementInfo);
recvData.read_skip<uint32>(); // unk2
@@ -689,16 +689,16 @@ void WorldSession::HandleSummonResponseOpcode(WorldPacket& recvData)
recvData >> summoner_guid;
recvData >> agree;
if (agree && _player->IsSummonAsSpectator())
{
ChatHandler chc(this);
if (Player* summoner = ObjectAccessor::FindPlayer(summoner_guid))
ArenaSpectator::HandleSpectatorSpectateCommand(&chc, summoner->GetName().c_str());
else
chc.PSendSysMessage("Requested player not found.");
if (agree && _player->IsSummonAsSpectator())
{
ChatHandler chc(this);
if (Player* summoner = ObjectAccessor::FindPlayer(summoner_guid))
ArenaSpectator::HandleSpectatorSpectateCommand(&chc, summoner->GetName().c_str());
else
chc.PSendSysMessage("Requested player not found.");
agree = false;
}
_player->SetSummonAsSpectator(false);
}
_player->SetSummonAsSpectator(false);
_player->SummonIfPossible(agree);
}

View File

@@ -310,13 +310,13 @@ void WorldSession::HandleGossipHelloOpcode(WorldPacket & recvData)
return;
}
// xinef: check if we have ANY npc flags
if (unit->GetUInt32Value(UNIT_NPC_FLAGS) == UNIT_NPC_FLAG_NONE)
return;
// xinef: check if we have ANY npc flags
if (unit->GetUInt32Value(UNIT_NPC_FLAGS) == UNIT_NPC_FLAG_NONE)
return;
// xinef: do not allow to open gossip when npc is in combat
if (unit->GetUInt32Value(UNIT_NPC_FLAGS) == UNIT_NPC_FLAG_GOSSIP && unit->IsInCombat()) // should work on all flags?
return;
// xinef: do not allow to open gossip when npc is in combat
if (unit->GetUInt32Value(UNIT_NPC_FLAGS) == UNIT_NPC_FLAG_GOSSIP && unit->IsInCombat()) // should work on all flags?
return;
// set faction visible if needed
if (FactionTemplateEntry const* factionTemplateEntry = sFactionTemplateStore.LookupEntry(unit->getFaction()))
@@ -327,7 +327,7 @@ void WorldSession::HandleGossipHelloOpcode(WorldPacket & recvData)
//if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
// GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
// xinef: and if he has pure gossip or is banker and moves or is tabard designer?
// xinef: and if he has pure gossip or is banker and moves or is tabard designer?
//if (unit->IsArmorer() || unit->IsCivilian() || unit->IsQuestGiver() || unit->IsServiceProvider() || unit->IsGuard())
{
//if (!unit->GetTransport()) // pussywizard: reverted with new spline (old: without this check, npc would stay in place and the transport would continue moving, so the npc falls off. NPCs on transports don't have waypoints, so stopmoving is not needed)
@@ -727,7 +727,7 @@ void WorldSession::HandleUnstablePetCallback(PreparedQueryResult result, uint32
if (pet)
_player->RemovePet(pet, PET_SAVE_AS_DELETED);
if (!Pet::LoadPetFromDB(_player, PET_LOAD_HANDLE_UNSTABLE_CALLBACK, petEntry, petId))
if (!Pet::LoadPetFromDB(_player, PET_LOAD_HANDLE_UNSTABLE_CALLBACK, petEntry, petId))
{
SendStableResult(STABLE_ERR_STABLE);
return;
@@ -854,7 +854,7 @@ void WorldSession::HandleStableSwapPetCallback(PreparedQueryResult result, uint3
_player->RemovePet(pet, pet->IsAlive() ? PetSaveMode(slot) : PET_SAVE_AS_DELETED);
// summon unstabled pet
if (!Pet::LoadPetFromDB(_player, PET_LOAD_HANDLE_UNSTABLE_CALLBACK, petEntry, petId))
if (!Pet::LoadPetFromDB(_player, PET_LOAD_HANDLE_UNSTABLE_CALLBACK, petEntry, petId))
{
SendStableResult(STABLE_ERR_STABLE);
}

View File

@@ -37,23 +37,23 @@
class LoadPetFromDBQueryHolder : public SQLQueryHolder
{
private:
const uint32 m_petNumber;
const uint32 m_diffTime;
const bool m_current;
const uint32 m_savedHealth;
const uint32 m_savedMana;
const std::string m_actionBar;
const uint32 m_petNumber;
const uint32 m_diffTime;
const bool m_current;
const uint32 m_savedHealth;
const uint32 m_savedMana;
const std::string m_actionBar;
public:
LoadPetFromDBQueryHolder(uint32 petNumber, bool current, uint32 diffTime, std::string actionBar, uint32 health, uint32 mana)
LoadPetFromDBQueryHolder(uint32 petNumber, bool current, uint32 diffTime, std::string actionBar, uint32 health, uint32 mana)
: m_petNumber(petNumber), m_current(current), m_diffTime(diffTime), m_actionBar(actionBar),
m_savedHealth(health), m_savedMana(mana) { }
m_savedHealth(health), m_savedMana(mana) { }
uint32 GetPetNumber() const { return m_petNumber; }
uint32 GetDiffTime() const { return m_diffTime; }
bool GetCurrent() const { return m_current; }
uint32 GetSavedHealth() const { return m_savedHealth; }
uint32 GetSavedMana() const { return m_savedMana; }
std::string GetActionBar() const { return m_actionBar; }
uint32 GetDiffTime() const { return m_diffTime; }
bool GetCurrent() const { return m_current; }
uint32 GetSavedHealth() const { return m_savedHealth; }
uint32 GetSavedMana() const { return m_savedMana; }
std::string GetActionBar() const { return m_actionBar; }
bool Initialize();
};
@@ -64,17 +64,17 @@ bool LoadPetFromDBQueryHolder::Initialize()
bool res = true;
PreparedStatement* stmt = NULL;
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PET_AURA);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PET_AURA);
stmt->setUInt32(0, m_petNumber);
res &= SetPreparedQuery(PET_LOAD_QUERY_LOADAURAS, stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PET_SPELL);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PET_SPELL);
stmt->setUInt32(0, m_petNumber);
res &= SetPreparedQuery(PET_LOAD_QUERY_LOADSPELLS, stmt);
res &= SetPreparedQuery(PET_LOAD_QUERY_LOADSPELLS, stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PET_SPELL_COOLDOWN);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PET_SPELL_COOLDOWN);
stmt->setUInt32(0, m_petNumber);
res &= SetPreparedQuery(PET_LOAD_QUERY_LOADSPELLCOOLDOWN, stmt);
res &= SetPreparedQuery(PET_LOAD_QUERY_LOADSPELLCOOLDOWN, stmt);
return res;
}
@@ -89,41 +89,41 @@ uint8 WorldSession::HandleLoadPetFromDBFirstCallback(PreparedQueryResult result,
Field* fields = result->Fetch();
// Xinef: this can happen if fetch is called twice, impossibru.
if (!fields)
return PET_LOAD_ERROR;
// Xinef: this can happen if fetch is called twice, impossibru.
if (!fields)
return PET_LOAD_ERROR;
Player* owner = GetPlayer();
Player* owner = GetPlayer();
// update for case of current pet "slot = 0"
uint32 petentry = fields[1].GetUInt32();
if (!petentry)
return PET_LOAD_NO_RESULT;
uint8 petSlot = fields[7].GetUInt8();
bool current = petSlot == PET_SAVE_AS_CURRENT;
uint8 petSlot = fields[7].GetUInt8();
bool current = petSlot == PET_SAVE_AS_CURRENT;
uint32 summon_spell_id = fields[15].GetUInt32();
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(summon_spell_id); // CANT BE NULL
bool is_temporary_summoned = spellInfo && spellInfo->GetDuration() > 0;
uint32 pet_number = fields[0].GetUInt32();
uint32 savedhealth = fields[10].GetUInt32();
uint32 savedhealth = fields[10].GetUInt32();
uint32 savedmana = fields[11].GetUInt32();
PetType pet_type = PetType(fields[16].GetUInt8());
PetType pet_type = PetType(fields[16].GetUInt8());
// xinef: BG resurrect, overwrite saved value
if (asynchLoadType == PET_LOAD_BG_RESURRECT)
savedhealth = 1;
// xinef: BG resurrect, overwrite saved value
if (asynchLoadType == PET_LOAD_BG_RESURRECT)
savedhealth = 1;
if (pet_type == HUNTER_PET && savedhealth == 0 && asynchLoadType != PET_LOAD_SUMMON_DEAD_PET)
{
WorldPacket data(SMSG_CAST_FAILED, 1+4+1+4);
if (pet_type == HUNTER_PET && savedhealth == 0 && asynchLoadType != PET_LOAD_SUMMON_DEAD_PET)
{
WorldPacket data(SMSG_CAST_FAILED, 1+4+1+4);
data << uint8(0);
data << uint32(883);
data << uint8(SPELL_FAILED_TARGETS_DEAD);
SendPacket(&data);
owner->RemoveSpellCooldown(883, false);
return PET_LOAD_ERROR;
}
owner->RemoveSpellCooldown(883, false);
return PET_LOAD_ERROR;
}
// check temporary summoned pets like mage water elemental
if (current && is_temporary_summoned)
@@ -138,26 +138,26 @@ uint8 WorldSession::HandleLoadPetFromDBFirstCallback(PreparedQueryResult result,
Map* map = owner->GetMap();
uint32 guid = sObjectMgr->GenerateLowGuid(HIGHGUID_PET);
Pet* pet = new Pet(owner, pet_type);
LoadPetFromDBQueryHolder* holder = new LoadPetFromDBQueryHolder(pet_number, current, uint32(time(NULL) - fields[14].GetUInt32()), fields[13].GetString(), savedhealth, savedmana);
Pet* pet = new Pet(owner, pet_type);
LoadPetFromDBQueryHolder* holder = new LoadPetFromDBQueryHolder(pet_number, current, uint32(time(NULL) - fields[14].GetUInt32()), fields[13].GetString(), savedhealth, savedmana);
if (!pet->Create(guid, map, owner->GetPhaseMask(), petentry, pet_number) || !holder->Initialize())
{
delete pet;
delete holder;
{
delete pet;
delete holder;
return PET_LOAD_ERROR;
}
}
float px, py, pz;
owner->GetClosePoint(px, py, pz, pet->GetObjectSize(), PET_FOLLOW_DIST, pet->GetFollowAngle());
if (!pet->IsPositionValid())
{
sLog->outError("Pet (guidlow %d, entry %d) not loaded. Suggested coordinates isn't valid (X: %f Y: %f)", pet->GetGUIDLow(), pet->GetEntry(), pet->GetPositionX(), pet->GetPositionY());
delete pet;
delete holder;
delete pet;
delete holder;
return PET_LOAD_ERROR;
}
pet->SetLoading(true);
pet->SetLoading(true);
pet->Relocate(px, py, pz, owner->GetOrientation());
pet->setPetType(pet_type);
pet->setFaction(owner->getFaction());
@@ -166,8 +166,8 @@ uint8 WorldSession::HandleLoadPetFromDBFirstCallback(PreparedQueryResult result,
if (pet->IsCritter())
{
map->AddToMap(pet->ToCreature(), true);
pet->SetLoading(false); // xinef, mine
delete holder;
pet->SetLoading(false); // xinef, mine
delete holder;
return PET_LOAD_OK;
}
@@ -184,10 +184,10 @@ uint8 WorldSession::HandleLoadPetFromDBFirstCallback(PreparedQueryResult result,
case SUMMON_PET:
petlevel = owner->getLevel();
if (pet->IsPetGhoul())
pet->SetUInt32Value(UNIT_FIELD_BYTES_0, 0x400); // class = rogue
else
pet->SetUInt32Value(UNIT_FIELD_BYTES_0, 0x800); // class = mage
if (pet->IsPetGhoul())
pet->SetUInt32Value(UNIT_FIELD_BYTES_0, 0x400); // class = rogue
else
pet->SetUInt32Value(UNIT_FIELD_BYTES_0, 0x800); // class = mage
pet->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
// this enables popup window (pet dismiss, cancel)
@@ -211,7 +211,7 @@ uint8 WorldSession::HandleLoadPetFromDBFirstCallback(PreparedQueryResult result,
pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(NULL))); // cast can't be helped here
pet->SetCreatorGUID(owner->GetGUID());
owner->SetMinion(pet, true);
owner->SetMinion(pet, true);
pet->InitStatsForLevel(petlevel);
pet->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, fields[5].GetUInt32());
@@ -260,10 +260,10 @@ uint8 WorldSession::HandleLoadPetFromDBFirstCallback(PreparedQueryResult result,
owner->SendMessageToSet(&data, true);
}
// do it as early as possible!
pet->InitTalentForLevel(); // set original talents points before spell loading
if (!is_temporary_summoned)
pet->GetCharmInfo()->InitPetActionBar();
// do it as early as possible!
pet->InitTalentForLevel(); // set original talents points before spell loading
if (!is_temporary_summoned)
pet->GetCharmInfo()->InitPetActionBar();
map->AddToMap(pet->ToCreature(), true);
if (pet->getPetType() == SUMMON_PET && !current) //all (?) summon pets come with full health when called, but not when they are current
@@ -274,34 +274,34 @@ uint8 WorldSession::HandleLoadPetFromDBFirstCallback(PreparedQueryResult result,
pet->SetPower(POWER_MANA, savedmana > pet->GetMaxPower(POWER_MANA) ? pet->GetMaxPower(POWER_MANA) : savedmana);
}
pet->SetAsynchLoadType(asynchLoadType);
pet->SetAsynchLoadType(asynchLoadType);
// xinef: clear any old result
if (_loadPetFromDBSecondCallback.ready())
{
SQLQueryHolder* param;
_loadPetFromDBSecondCallback.get(param);
delete param;
}
_loadPetFromDBSecondCallback.cancel();
// xinef: clear any old result
if (_loadPetFromDBSecondCallback.ready())
{
SQLQueryHolder* param;
_loadPetFromDBSecondCallback.get(param);
delete param;
}
_loadPetFromDBSecondCallback.cancel();
_loadPetFromDBSecondCallback = CharacterDatabase.DelayQueryHolder((SQLQueryHolder*)holder);
return PET_LOAD_OK;
return PET_LOAD_OK;
}
void WorldSession::HandleLoadPetFromDBSecondCallback(LoadPetFromDBQueryHolder* holder)
{
if (!GetPlayer())
if (!GetPlayer())
return;
Player* owner = GetPlayer();
Pet* pet = owner->GetPet();
if (!pet)
return;
Player* owner = GetPlayer();
Pet* pet = owner->GetPet();
if (!pet)
return;
pet->_LoadAuras(holder->GetPreparedResult(PET_LOAD_QUERY_LOADAURAS), holder->GetDiffTime());
bool current = holder->GetCurrent();
uint32 summon_spell_id = pet->GetUInt32Value(UNIT_CREATED_BY_SPELL);
pet->_LoadAuras(holder->GetPreparedResult(PET_LOAD_QUERY_LOADAURAS), holder->GetDiffTime());
bool current = holder->GetCurrent();
uint32 summon_spell_id = pet->GetUInt32Value(UNIT_CREATED_BY_SPELL);
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(summon_spell_id); // CANT BE NULL
bool is_temporary_summoned = spellInfo && spellInfo->GetDuration() > 0;
@@ -315,7 +315,7 @@ void WorldSession::HandleLoadPetFromDBSecondCallback(LoadPetFromDBQueryHolder* h
pet->InitLevelupSpellsForLevel();
pet->CastPetAuras(current);
pet->GetCharmInfo()->LoadPetActionBar(holder->GetActionBar()); // action bar stored in already read string
pet->GetCharmInfo()->LoadPetActionBar(holder->GetActionBar()); // action bar stored in already read string
}
pet->CleanupActionBar(); // remove unknown spells from action bar after load
@@ -326,16 +326,16 @@ void WorldSession::HandleLoadPetFromDBSecondCallback(LoadPetFromDBQueryHolder* h
//set last used pet number (for use in BG's)
if (owner->GetTypeId() == TYPEID_PLAYER && pet->isControlled() && !pet->isTemporarySummoned() && (pet->getPetType() == SUMMON_PET || pet->getPetType() == HUNTER_PET))
{
{
owner->ToPlayer()->SetLastPetNumber(holder->GetPetNumber());
owner->SetLastPetSpell(pet->GetUInt32Value(UNIT_CREATED_BY_SPELL));
}
owner->SetLastPetSpell(pet->GetUInt32Value(UNIT_CREATED_BY_SPELL));
}
if (pet->getPetType() == SUMMON_PET && !current) //all (?) summon pets come with full health when called, but not when they are current
{
{
pet->SetPower(POWER_MANA, pet->GetMaxPower(POWER_MANA));
pet->SetHealth(pet->GetMaxHealth());
}
pet->SetHealth(pet->GetMaxHealth());
}
else
{
if (!holder->GetSavedHealth() && pet->getPetType() == HUNTER_PET && pet->GetAsynchLoadType() != PET_LOAD_SUMMON_DEAD_PET)
@@ -347,18 +347,18 @@ void WorldSession::HandleLoadPetFromDBSecondCallback(LoadPetFromDBQueryHolder* h
}
}
pet->SetLoading(false);
owner->SetTemporaryUnsummonedPetNumber(0); // clear this only if pet is loaded successfuly
pet->SetLoading(false);
owner->SetTemporaryUnsummonedPetNumber(0); // clear this only if pet is loaded successfuly
// current
if (current && owner->IsPetNeedBeTemporaryUnsummoned())
{
// current
if (current && owner->IsPetNeedBeTemporaryUnsummoned())
{
owner->UnsummonPetTemporaryIfAny();
return;
}
return;
}
pet->HandleAsynchLoadSucceed();
return;
pet->HandleAsynchLoadSucceed();
return;
}
void WorldSession::HandleDismissCritter(WorldPacket &recvData)
@@ -414,7 +414,7 @@ void WorldSession::HandlePetAction(WorldPacket & recvData)
if (!pet->IsAlive())
{
// xinef: allow dissmis dead pets
// xinef: allow dissmis dead pets
SpellInfo const* spell = (flag == ACT_ENABLED || flag == ACT_PASSIVE) ? sSpellMgr->GetSpellInfo(spellid) : NULL;
if ((flag != ACT_COMMAND || spellid != COMMAND_ABANDON) && (!spell || !spell->HasAttribute(SPELL_ATTR0_CASTABLE_WHILE_DEAD)))
return;
@@ -422,7 +422,7 @@ void WorldSession::HandlePetAction(WorldPacket & recvData)
// Xinef: allow to controll players
if (pet->GetTypeId() == TYPEID_PLAYER && flag != ACT_COMMAND && flag != ACT_REACTION)
return;
return;
if (GetPlayer()->m_Controlled.size() == 1)
HandlePetActionHelper(pet, guid1, spellid, flag, guid2);
@@ -431,16 +431,16 @@ void WorldSession::HandlePetAction(WorldPacket & recvData)
//If a pet is dismissed, m_Controlled will change
std::vector<Unit*> controlled;
for (Unit::ControlSet::iterator itr = GetPlayer()->m_Controlled.begin(); itr != GetPlayer()->m_Controlled.end(); ++itr)
{
// xinef: allow to dissmis dead pets
{
// xinef: allow to dissmis dead pets
if ((*itr)->GetEntry() == pet->GetEntry() && ((*itr)->IsAlive() || (flag == ACT_COMMAND && spellid == COMMAND_ABANDON)))
controlled.push_back(*itr);
// xinef: mirror image blizzard crappness
else if ((*itr)->GetEntry() == NPC_MIRROR_IMAGE && flag == ACT_COMMAND && spellid == COMMAND_FOLLOW)
{
(*itr)->InterruptNonMeleeSpells(false);
}
}
// xinef: mirror image blizzard crappness
else if ((*itr)->GetEntry() == NPC_MIRROR_IMAGE && flag == ACT_COMMAND && spellid == COMMAND_FOLLOW)
{
(*itr)->InterruptNonMeleeSpells(false);
}
}
for (std::vector<Unit*>::iterator itr = controlled.begin(); itr != controlled.end(); ++itr)
HandlePetActionHelper(*itr, guid1, spellid, flag, guid2);
@@ -472,7 +472,7 @@ void WorldSession::HandlePetStopAttack(WorldPacket &recvData)
return;
pet->AttackStop();
pet->ClearInPetCombat();
pet->ClearInPetCombat();
}
void WorldSession::HandlePetActionHelper(Unit* pet, uint64 guid1, uint16 spellid, uint16 flag, uint64 guid2)
@@ -491,32 +491,32 @@ void WorldSession::HandlePetActionHelper(Unit* pet, uint64 guid1, uint16 spellid
switch (spellid)
{
case COMMAND_STAY: //flat=1792 //STAY
{
bool controlledMotion = pet->GetMotionMaster()->GetMotionSlotType(MOTION_SLOT_CONTROLLED) != NULL_MOTION_TYPE;
if (!controlledMotion)
{
pet->StopMovingOnCurrentPos();
pet->GetMotionMaster()->Clear(false);
pet->GetMotionMaster()->MoveIdle();
}
{
bool controlledMotion = pet->GetMotionMaster()->GetMotionSlotType(MOTION_SLOT_CONTROLLED) != NULL_MOTION_TYPE;
if (!controlledMotion)
{
pet->StopMovingOnCurrentPos();
pet->GetMotionMaster()->Clear(false);
pet->GetMotionMaster()->MoveIdle();
}
charmInfo->SetCommandState(COMMAND_STAY);
charmInfo->SetIsCommandAttack(false);
charmInfo->SetIsCommandFollow(false);
charmInfo->SetIsFollowing(false);
charmInfo->SetIsReturning(false);
charmInfo->SetIsAtStay(!controlledMotion);
charmInfo->SetIsAtStay(!controlledMotion);
charmInfo->SaveStayPosition(controlledMotion);
charmInfo->SetForcedSpell(0);
charmInfo->SetForcedTargetGUID(0);
charmInfo->SetForcedSpell(0);
charmInfo->SetForcedTargetGUID(0);
break;
}
}
case COMMAND_FOLLOW: //spellid=1792 //FOLLOW
{
{
pet->AttackStop();
pet->InterruptNonMeleeSpells(false);
pet->ClearInPetCombat();
pet->ClearInPetCombat();
pet->GetMotionMaster()->MoveFollow(_player, PET_FOLLOW_DIST, pet->GetFollowAngle());
charmInfo->SetCommandState(COMMAND_FOLLOW);
@@ -526,10 +526,10 @@ void WorldSession::HandlePetActionHelper(Unit* pet, uint64 guid1, uint16 spellid
charmInfo->SetIsCommandFollow(true);
charmInfo->SetIsFollowing(false);
charmInfo->SetForcedSpell(0);
charmInfo->SetForcedTargetGUID(0);
charmInfo->SetForcedSpell(0);
charmInfo->SetForcedTargetGUID(0);
break;
}
}
case COMMAND_ATTACK: //spellid=1792 //ATTACK
{
// Can't attack if owner is pacified
@@ -549,23 +549,23 @@ void WorldSession::HandlePetActionHelper(Unit* pet, uint64 guid1, uint16 spellid
if (!owner->IsValidAttackTarget(TargetUnit))
return;
// pussywizard:
if (Creature* creaturePet = pet->ToCreature())
if (!creaturePet->_CanDetectFeignDeathOf(TargetUnit) || !creaturePet->CanCreatureAttack(TargetUnit) || creaturePet->isTargetNotAcceptableByMMaps(TargetUnit->GetGUID(), sWorld->GetGameTime(), TargetUnit))
return;
// pussywizard:
if (Creature* creaturePet = pet->ToCreature())
if (!creaturePet->_CanDetectFeignDeathOf(TargetUnit) || !creaturePet->CanCreatureAttack(TargetUnit) || creaturePet->isTargetNotAcceptableByMMaps(TargetUnit->GetGUID(), sWorld->GetGameTime(), TargetUnit))
return;
// Not let attack through obstructions
bool checkLos = !MMAP::MMapFactory::IsPathfindingEnabled(pet->GetMap()) ||
(TargetUnit->GetTypeId() == TYPEID_UNIT && (TargetUnit->ToCreature()->isWorldBoss() || TargetUnit->ToCreature()->IsDungeonBoss()));
(TargetUnit->GetTypeId() == TYPEID_UNIT && (TargetUnit->ToCreature()->isWorldBoss() || TargetUnit->ToCreature()->IsDungeonBoss()));
if (checkLos && !pet->IsWithinLOSInMap(TargetUnit))
{
WorldPacket data(SMSG_CAST_FAILED, 1+4+1);
data << uint8(0);
data << uint32(7389);
data << uint8(SPELL_FAILED_LINE_OF_SIGHT);
SendPacket(&data);
return;
if (checkLos && !pet->IsWithinLOSInMap(TargetUnit))
{
WorldPacket data(SMSG_CAST_FAILED, 1+4+1);
data << uint8(0);
data << uint32(7389);
data << uint8(SPELL_FAILED_LINE_OF_SIGHT);
SendPacket(&data);
return;
}
pet->ClearUnitState(UNIT_STATE_FOLLOW);
@@ -601,7 +601,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, uint64 guid1, uint16 spellid
charmInfo->SetIsCommandFollow(false);
charmInfo->SetIsReturning(false);
pet->Attack(TargetUnit, true);
pet->Attack(TargetUnit, true);
pet->SendPetAIReaction(guid1);
}
}
@@ -609,12 +609,12 @@ void WorldSession::HandlePetActionHelper(Unit* pet, uint64 guid1, uint16 spellid
}
case COMMAND_ABANDON: // abandon (hunter pet) or dismiss (summoned pet)
if (pet->GetCharmerGUID() == GetPlayer()->GetGUID())
{
if (pet->IsSummon())
pet->ToTempSummon()->UnSummon();
else
_player->StopCastingCharm();
}
{
if (pet->IsSummon())
pet->ToTempSummon()->UnSummon();
else
_player->StopCastingCharm();
}
else if (pet->GetOwnerGUID() == GetPlayer()->GetGUID())
{
ASSERT(pet->GetTypeId() == TYPEID_UNIT);
@@ -641,14 +641,14 @@ void WorldSession::HandlePetActionHelper(Unit* pet, uint64 guid1, uint16 spellid
{
case REACT_PASSIVE: //passive
pet->AttackStop();
pet->ClearInPetCombat();
pet->ClearInPetCombat();
case REACT_DEFENSIVE: //recovery
case REACT_AGGRESSIVE: //activete
if (pet->GetTypeId() == TYPEID_UNIT)
pet->ToCreature()->SetReactState(ReactStates(spellid));
else
charmInfo->SetPlayerReactState(ReactStates(spellid));
else
charmInfo->SetPlayerReactState(ReactStates(spellid));
break;
}
break;
@@ -687,7 +687,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, uint64 guid1, uint16 spellid
charmInfo->SetIsFollowing(false);
Spell* spell = new Spell(pet, spellInfo, TRIGGERED_NONE);
spell->LoadScripts(); // xinef: load for CheckPetCast
spell->LoadScripts(); // xinef: load for CheckPetCast
SpellCastResult result = spell->CheckPetCast(unit_target);
@@ -740,19 +740,19 @@ void WorldSession::HandlePetActionHelper(Unit* pet, uint64 guid1, uint16 spellid
spell->prepare(&(spell->m_targets));
charmInfo->SetForcedSpell(0);
charmInfo->SetForcedTargetGUID(0);
charmInfo->SetForcedSpell(0);
charmInfo->SetForcedTargetGUID(0);
}
else
{
// dont spam alerts
if (!charmInfo->GetForcedSpell())
{
if (pet->isPossessed() || pet->IsVehicle())
Spell::SendCastResult(GetPlayer(), spellInfo, 0, result);
else
spell->SendPetCastResult(result);
}
// dont spam alerts
if (!charmInfo->GetForcedSpell())
{
if (pet->isPossessed() || pet->IsVehicle())
Spell::SendCastResult(GetPlayer(), spellInfo, 0, result);
else
spell->SendPetCastResult(result);
}
if (!pet->ToCreature()->HasSpellCooldown(spellid))
GetPlayer()->SendClearCooldown(spellid, pet);
@@ -760,8 +760,8 @@ void WorldSession::HandlePetActionHelper(Unit* pet, uint64 guid1, uint16 spellid
spell->finish(false);
delete spell;
// reset specific flags in case of spell fail. AI will reset other flags
pet->PetSpellFail(spellInfo, unit_target, result);
// reset specific flags in case of spell fail. AI will reset other flags
pet->PetSpellFail(spellInfo, unit_target, result);
}
break;
}
@@ -884,86 +884,86 @@ void WorldSession::HandlePetSetAction(WorldPacket & recvData)
}
}
Unit::ControlSet petsSet;
if (checkPet->GetEntry() != GUID_ENPART(petguid))
petsSet.insert(checkPet);
else
petsSet = _player->m_Controlled;
Unit::ControlSet petsSet;
if (checkPet->GetEntry() != GUID_ENPART(petguid))
petsSet.insert(checkPet);
else
petsSet = _player->m_Controlled;
// Xinef: loop all pets with same entry (fixes partial state change for feral spirits)
for (Unit::ControlSet::const_iterator itr = petsSet.begin(); itr != petsSet.end(); ++itr)
{
Unit* pet = *itr;
if (checkPet->GetEntry() == GUID_ENPART(petguid) && pet->GetEntry() != GUID_ENPART(petguid))
continue;
// Xinef: loop all pets with same entry (fixes partial state change for feral spirits)
for (Unit::ControlSet::const_iterator itr = petsSet.begin(); itr != petsSet.end(); ++itr)
{
Unit* pet = *itr;
if (checkPet->GetEntry() == GUID_ENPART(petguid) && pet->GetEntry() != GUID_ENPART(petguid))
continue;
CharmInfo* charmInfo = pet->GetCharmInfo();
if (!charmInfo)
{
sLog->outError("WorldSession::HandlePetSetAction: object (GUID: %u TypeId: %u) is considered pet-like but doesn't have a charminfo!", pet->GetGUIDLow(), pet->GetTypeId());
continue;
}
CharmInfo* charmInfo = pet->GetCharmInfo();
if (!charmInfo)
{
sLog->outError("WorldSession::HandlePetSetAction: object (GUID: %u TypeId: %u) is considered pet-like but doesn't have a charminfo!", pet->GetGUIDLow(), pet->GetTypeId());
continue;
}
// check swap (at command->spell swap client remove spell first in another packet, so check only command move correctness)
if (move_command)
{
uint8 act_state_0 = UNIT_ACTION_BUTTON_TYPE(data[0]);
if (act_state_0 == ACT_COMMAND || act_state_0 == ACT_REACTION)
{
uint32 spell_id_0 = UNIT_ACTION_BUTTON_ACTION(data[0]);
UnitActionBarEntry const* actionEntry_1 = charmInfo->GetActionBarEntry(position[1]);
if (!actionEntry_1 || spell_id_0 != actionEntry_1->GetAction() ||
act_state_0 != actionEntry_1->GetType())
continue;
}
// check swap (at command->spell swap client remove spell first in another packet, so check only command move correctness)
if (move_command)
{
uint8 act_state_0 = UNIT_ACTION_BUTTON_TYPE(data[0]);
if (act_state_0 == ACT_COMMAND || act_state_0 == ACT_REACTION)
{
uint32 spell_id_0 = UNIT_ACTION_BUTTON_ACTION(data[0]);
UnitActionBarEntry const* actionEntry_1 = charmInfo->GetActionBarEntry(position[1]);
if (!actionEntry_1 || spell_id_0 != actionEntry_1->GetAction() ||
act_state_0 != actionEntry_1->GetType())
continue;
}
uint8 act_state_1 = UNIT_ACTION_BUTTON_TYPE(data[1]);
if (act_state_1 == ACT_COMMAND || act_state_1 == ACT_REACTION)
{
uint32 spell_id_1 = UNIT_ACTION_BUTTON_ACTION(data[1]);
UnitActionBarEntry const* actionEntry_0 = charmInfo->GetActionBarEntry(position[0]);
if (!actionEntry_0 || spell_id_1 != actionEntry_0->GetAction() ||
act_state_1 != actionEntry_0->GetType())
continue;
}
}
uint8 act_state_1 = UNIT_ACTION_BUTTON_TYPE(data[1]);
if (act_state_1 == ACT_COMMAND || act_state_1 == ACT_REACTION)
{
uint32 spell_id_1 = UNIT_ACTION_BUTTON_ACTION(data[1]);
UnitActionBarEntry const* actionEntry_0 = charmInfo->GetActionBarEntry(position[0]);
if (!actionEntry_0 || spell_id_1 != actionEntry_0->GetAction() ||
act_state_1 != actionEntry_0->GetType())
continue;
}
}
for (uint8 i = 0; i < count; ++i)
{
uint32 spell_id = UNIT_ACTION_BUTTON_ACTION(data[i]);
uint8 act_state = UNIT_ACTION_BUTTON_TYPE(data[i]);
for (uint8 i = 0; i < count; ++i)
{
uint32 spell_id = UNIT_ACTION_BUTTON_ACTION(data[i]);
uint8 act_state = UNIT_ACTION_BUTTON_TYPE(data[i]);
//if it's act for spell (en/disable/cast) and there is a spell given (0 = remove spell) which pet doesn't know, don't add
if (!((act_state == ACT_ENABLED || act_state == ACT_DISABLED || act_state == ACT_PASSIVE) && spell_id && !pet->HasSpell(spell_id)))
{
if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell_id))
{
//sign for autocast
if (act_state == ACT_ENABLED)
{
if (pet->GetTypeId() == TYPEID_UNIT && pet->IsPet())
((Pet*)pet)->ToggleAutocast(spellInfo, true);
else
for (Unit::ControlSet::iterator itr = GetPlayer()->m_Controlled.begin(); itr != GetPlayer()->m_Controlled.end(); ++itr)
if ((*itr)->GetEntry() == pet->GetEntry())
(*itr)->GetCharmInfo()->ToggleCreatureAutocast(spellInfo, true);
}
//sign for no/turn off autocast
else if (act_state == ACT_DISABLED)
{
if (pet->GetTypeId() == TYPEID_UNIT && pet->IsPet())
((Pet*)pet)->ToggleAutocast(spellInfo, false);
else
for (Unit::ControlSet::iterator itr = GetPlayer()->m_Controlled.begin(); itr != GetPlayer()->m_Controlled.end(); ++itr)
if ((*itr)->GetEntry() == pet->GetEntry())
(*itr)->GetCharmInfo()->ToggleCreatureAutocast(spellInfo, false);
}
}
//if it's act for spell (en/disable/cast) and there is a spell given (0 = remove spell) which pet doesn't know, don't add
if (!((act_state == ACT_ENABLED || act_state == ACT_DISABLED || act_state == ACT_PASSIVE) && spell_id && !pet->HasSpell(spell_id)))
{
if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell_id))
{
//sign for autocast
if (act_state == ACT_ENABLED)
{
if (pet->GetTypeId() == TYPEID_UNIT && pet->IsPet())
((Pet*)pet)->ToggleAutocast(spellInfo, true);
else
for (Unit::ControlSet::iterator itr = GetPlayer()->m_Controlled.begin(); itr != GetPlayer()->m_Controlled.end(); ++itr)
if ((*itr)->GetEntry() == pet->GetEntry())
(*itr)->GetCharmInfo()->ToggleCreatureAutocast(spellInfo, true);
}
//sign for no/turn off autocast
else if (act_state == ACT_DISABLED)
{
if (pet->GetTypeId() == TYPEID_UNIT && pet->IsPet())
((Pet*)pet)->ToggleAutocast(spellInfo, false);
else
for (Unit::ControlSet::iterator itr = GetPlayer()->m_Controlled.begin(); itr != GetPlayer()->m_Controlled.end(); ++itr)
if ((*itr)->GetEntry() == pet->GetEntry())
(*itr)->GetCharmInfo()->ToggleCreatureAutocast(spellInfo, false);
}
}
charmInfo->SetActionBar(position[i], spell_id, ActiveStates(act_state));
}
}
}
charmInfo->SetActionBar(position[i], spell_id, ActiveStates(act_state));
}
}
}
}
void WorldSession::HandlePetRename(WorldPacket & recvData)
@@ -1027,20 +1027,20 @@ void WorldSession::HandlePetRename(WorldPacket & recvData)
SQLTransaction trans = CharacterDatabase.BeginTransaction();
if (isdeclined)
{
if (sWorld->getBoolConfig(CONFIG_DECLINED_NAMES_USED))
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_PET_DECLINEDNAME);
stmt->setUInt32(0, pet->GetCharmInfo()->GetPetNumber());
trans->Append(stmt);
if (sWorld->getBoolConfig(CONFIG_DECLINED_NAMES_USED))
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_PET_DECLINEDNAME);
stmt->setUInt32(0, pet->GetCharmInfo()->GetPetNumber());
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_ADD_CHAR_PET_DECLINEDNAME);
stmt->setUInt32(0, _player->GetGUIDLow());
stmt = CharacterDatabase.GetPreparedStatement(CHAR_ADD_CHAR_PET_DECLINEDNAME);
stmt->setUInt32(0, _player->GetGUIDLow());
for (uint8 i = 0; i < 5; i++)
stmt->setString(i+1, declinedname.name[i]);
for (uint8 i = 0; i < 5; i++)
stmt->setString(i+1, declinedname.name[i]);
trans->Append(stmt);
}
trans->Append(stmt);
}
}
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_PET_NAME);
@@ -1065,7 +1065,7 @@ void WorldSession::HandlePetAbandon(WorldPacket & recvData)
// pet/charmed
Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, guid);
if (pet && pet->ToPet() && pet->ToPet()->getPetType() == HUNTER_PET)
if (pet && pet->ToPet() && pet->ToPet()->getPetType() == HUNTER_PET)
{
if (pet->IsPet())
{
@@ -1096,9 +1096,9 @@ void WorldSession::HandlePetSpellAutocastOpcode(WorldPacket& recvPacket)
if (IS_PLAYER_GUID(guid))
return;
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid);
if (!spellInfo)
return;
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid);
if (!spellInfo)
return;
Creature* checkPet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, guid);
if (!checkPet || (checkPet != _player->GetGuardianPet() && checkPet != _player->GetCharm()))
@@ -1107,37 +1107,37 @@ void WorldSession::HandlePetSpellAutocastOpcode(WorldPacket& recvPacket)
return;
}
Unit::ControlSet petsSet;
if (checkPet->GetEntry() != GUID_ENPART(guid))
petsSet.insert(checkPet);
else
petsSet = _player->m_Controlled;
Unit::ControlSet petsSet;
if (checkPet->GetEntry() != GUID_ENPART(guid))
petsSet.insert(checkPet);
else
petsSet = _player->m_Controlled;
// Xinef: loop all pets with same entry (fixes partial state change for feral spirits)
for (Unit::ControlSet::const_iterator itr = petsSet.begin(); itr != petsSet.end(); ++itr)
{
Unit* pet = *itr;
if (checkPet->GetEntry() == GUID_ENPART(guid) && pet->GetEntry() != GUID_ENPART(guid))
continue;
// Xinef: loop all pets with same entry (fixes partial state change for feral spirits)
for (Unit::ControlSet::const_iterator itr = petsSet.begin(); itr != petsSet.end(); ++itr)
{
Unit* pet = *itr;
if (checkPet->GetEntry() == GUID_ENPART(guid) && pet->GetEntry() != GUID_ENPART(guid))
continue;
// do not add not learned spells/ passive spells
if (!pet->HasSpell(spellid) || !spellInfo->IsAutocastable())
continue;
// do not add not learned spells/ passive spells
if (!pet->HasSpell(spellid) || !spellInfo->IsAutocastable())
continue;
CharmInfo* charmInfo = pet->GetCharmInfo();
if (!charmInfo)
{
sLog->outError("WorldSession::HandlePetSpellAutocastOpcod: object (GUID: %u TypeId: %u) is considered pet-like but doesn't have a charminfo!", pet->GetGUIDLow(), pet->GetTypeId());
continue;
}
CharmInfo* charmInfo = pet->GetCharmInfo();
if (!charmInfo)
{
sLog->outError("WorldSession::HandlePetSpellAutocastOpcod: object (GUID: %u TypeId: %u) is considered pet-like but doesn't have a charminfo!", pet->GetGUIDLow(), pet->GetTypeId());
continue;
}
if (pet->IsPet())
((Pet*)pet)->ToggleAutocast(spellInfo, state);
else
pet->GetCharmInfo()->ToggleCreatureAutocast(spellInfo, state);
if (pet->IsPet())
((Pet*)pet)->ToggleAutocast(spellInfo, state);
else
pet->GetCharmInfo()->ToggleCreatureAutocast(spellInfo, state);
charmInfo->SetSpellAutocast(spellInfo, state);
}
charmInfo->SetSpellAutocast(spellInfo, state);
}
}
void WorldSession::HandlePetCastSpellOpcode(WorldPacket& recvPacket)
@@ -1180,20 +1180,20 @@ void WorldSession::HandlePetCastSpellOpcode(WorldPacket& recvPacket)
targets.Read(recvPacket, caster);
HandleClientCastFlags(recvPacket, castFlags, targets);
bool SetFollow = caster->HasUnitState(UNIT_STATE_FOLLOW);
bool SetFollow = caster->HasUnitState(UNIT_STATE_FOLLOW);
caster->ClearUnitState(UNIT_STATE_FOLLOW);
Spell* spell = new Spell(caster, spellInfo, TRIGGERED_NONE);
spell->m_cast_count = castCount; // probably pending spell cast
spell->m_targets = targets;
spell->LoadScripts();
spell->LoadScripts();
// Xinef: Send default target, fixes return on NeedExplicitUnitTarget
Unit* target = targets.GetUnitTarget();
if (!target && spell->m_spellInfo->NeedsExplicitUnitTarget())
target = _player->GetSelectedUnit();
// Xinef: Send default target, fixes return on NeedExplicitUnitTarget
Unit* target = targets.GetUnitTarget();
if (!target && spell->m_spellInfo->NeedsExplicitUnitTarget())
target = _player->GetSelectedUnit();
SpellCastResult result = spell->CheckPetCast(target);
SpellCastResult result = spell->CheckPetCast(target);
if (result == SPELL_CAST_OK)
{
@@ -1215,8 +1215,8 @@ void WorldSession::HandlePetCastSpellOpcode(WorldPacket& recvPacket)
}
else
{
if (!caster->GetCharmInfo() || !caster->GetCharmInfo()->GetForcedSpell())
spell->SendPetCastResult(result);
if (!caster->GetCharmInfo() || !caster->GetCharmInfo()->GetForcedSpell())
spell->SendPetCastResult(result);
if (caster->GetTypeId() == TYPEID_PLAYER)
{
@@ -1228,17 +1228,17 @@ void WorldSession::HandlePetCastSpellOpcode(WorldPacket& recvPacket)
if (!caster->ToCreature()->HasSpellCooldown(spellId))
GetPlayer()->SendClearCooldown(spellId, caster);
// reset specific flags in case of spell fail. AI will reset other flags
// reset specific flags in case of spell fail. AI will reset other flags
if (caster->IsPet())
caster->PetSpellFail(spellInfo, targets.GetUnitTarget(), result);
caster->PetSpellFail(spellInfo, targets.GetUnitTarget(), result);
}
spell->finish(false);
delete spell;
}
if (SetFollow && !caster->IsInCombat())
caster->AddUnitState(UNIT_STATE_FOLLOW);
if (SetFollow && !caster->IsInCombat())
caster->AddUnitState(UNIT_STATE_FOLLOW);
}
void WorldSession::SendPetNameInvalid(uint32 error, const std::string& name, DeclinedName *declinedName)

View File

@@ -211,21 +211,21 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket & recvData)
// a petition is invalid, if both the owner and the type matches
// we checked above, if this player is in an arenateam, so this must be
// datacorruption
Petition const* petition = sPetitionMgr->GetPetitionByOwnerWithType(_player->GetGUIDLow(), type);
Petition const* petition = sPetitionMgr->GetPetitionByOwnerWithType(_player->GetGUIDLow(), type);
;//sLog->outDebug(LOG_FILTER_NETWORKIO, "Invalid petition GUIDs: %s", ssInvalidPetitionGUIDs.str().c_str());
CharacterDatabase.EscapeString(name);
SQLTransaction trans = CharacterDatabase.BeginTransaction();
if (petition)
{
trans->PAppend("DELETE FROM petition WHERE petitionguid = %u", petition->petitionGuid);
trans->PAppend("DELETE FROM petition_sign WHERE petitionguid = %u", petition->petitionGuid);
// xinef: clear petition store
sPetitionMgr->RemovePetition(petition->petitionGuid);
}
if (petition)
{
trans->PAppend("DELETE FROM petition WHERE petitionguid = %u", petition->petitionGuid);
trans->PAppend("DELETE FROM petition_sign WHERE petitionguid = %u", petition->petitionGuid);
// xinef: clear petition store
sPetitionMgr->RemovePetition(petition->petitionGuid);
}
// xinef: petition pointer is invalid from now on
// xinef: petition pointer is invalid from now on
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PETITION);
stmt->setUInt32(0, _player->GetGUIDLow());
@@ -236,8 +236,8 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket & recvData)
CharacterDatabase.CommitTransaction(trans);
// xinef: fill petition store
sPetitionMgr->AddPetition(charter->GetGUIDLow(), _player->GetGUIDLow(), name, uint8(type));
// xinef: fill petition store
sPetitionMgr->AddPetition(charter->GetGUIDLow(), _player->GetGUIDLow(), name, uint8(type));
}
void WorldSession::HandlePetitionShowSignOpcode(WorldPacket& recvData)
@@ -250,18 +250,18 @@ void WorldSession::HandlePetitionShowSignOpcode(WorldPacket& recvData)
// solve (possible) some strange compile problems with explicit use GUID_LOPART(petitionguid) at some GCC versions (wrong code optimization in compiler?)
uint32 petitionGuidLow = GUID_LOPART(petitionguid);
Petition const* petition = sPetitionMgr->GetPetition(petitionGuidLow);
if (!petition)
return;
Petition const* petition = sPetitionMgr->GetPetition(petitionGuidLow);
if (!petition)
return;
uint32 type = petition->petitionType;
uint32 type = petition->petitionType;
// if guild petition and has guild => error, return;
if (type == GUILD_CHARTER_TYPE && _player->GetGuildId())
return;
Signatures const* signatures = sPetitionMgr->GetSignature(petitionGuidLow);
uint8 signs = signatures ? signatures->signatureMap.size() : 0;
Signatures const* signatures = sPetitionMgr->GetSignature(petitionGuidLow);
uint8 signs = signatures ? signatures->signatureMap.size() : 0;
;//sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_PETITION_SHOW_SIGNATURES petition entry: '%u'", petitionGuidLow);
@@ -271,12 +271,12 @@ void WorldSession::HandlePetitionShowSignOpcode(WorldPacket& recvData)
data << uint32(petitionGuidLow); // guild guid
data << uint8(signs); // sign's count
if (signs)
for (SignatureMap::const_iterator itr = signatures->signatureMap.begin(); itr != signatures->signatureMap.begin(); ++itr)
{
data << uint64(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER)); // Player GUID
data << uint32(0); // there 0 ...
}
if (signs)
for (SignatureMap::const_iterator itr = signatures->signatureMap.begin(); itr != signatures->signatureMap.begin(); ++itr)
{
data << uint64(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER)); // Player GUID
data << uint32(0); // there 0 ...
}
SendPacket(&data);
}
@@ -296,20 +296,20 @@ void WorldSession::HandlePetitionQueryOpcode(WorldPacket & recvData)
void WorldSession::SendPetitionQueryOpcode(uint64 petitionguid)
{
Petition const* petition = sPetitionMgr->GetPetition(GUID_LOPART(petitionguid));
if (!petition)
{
Petition const* petition = sPetitionMgr->GetPetition(GUID_LOPART(petitionguid));
if (!petition)
{
;//sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_PETITION_QUERY failed for petition (GUID: %u)", GUID_LOPART(petitionguid));
return;
}
uint8 type = petition->petitionType;
uint8 type = petition->petitionType;
WorldPacket data(SMSG_PETITION_QUERY_RESPONSE, (4+8+petition->petitionName.size()+1+1+4*12+2+10));
data << uint32(GUID_LOPART(petitionguid)); // guild/team guid (in Trinity always same as GUID_LOPART(petition guid)
data << MAKE_NEW_GUID(petition->ownerGuid, 0, HIGHGUID_PLAYER); // charter owner guid
data << petition->petitionName; // name (guild/arena team)
data << petition->petitionName; // name (guild/arena team)
data << uint8(0); // some string
if (type == GUILD_CHARTER_TYPE)
if (type == GUILD_CHARTER_TYPE)
{
uint32 needed = sWorld->getIntConfig(CONFIG_MIN_PETITION_SIGNS);
data << uint32(needed);
@@ -355,14 +355,14 @@ void WorldSession::HandlePetitionRenameOpcode(WorldPacket & recvData)
if (!item)
return;
Petition const* petition = sPetitionMgr->GetPetition(GUID_LOPART(petitionGuid));
if (!petition)
{
Petition const* petition = sPetitionMgr->GetPetition(GUID_LOPART(petitionGuid));
if (!petition)
{
;//sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_PETITION_QUERY failed for petition (GUID: %u)", GUID_LOPART(petitionGuid));
return;
}
if (petition->petitionType == GUILD_CHARTER_TYPE)
if (petition->petitionType == GUILD_CHARTER_TYPE)
{
if (sGuildMgr->GetGuildByName(newName))
{
@@ -396,8 +396,8 @@ void WorldSession::HandlePetitionRenameOpcode(WorldPacket & recvData)
CharacterDatabase.Execute(stmt);
// xinef: update petition container
const_cast<Petition*>(petition)->petitionName = newName;
// xinef: update petition container
const_cast<Petition*>(petition)->petitionName = newName;
;//sLog->outDebug(LOG_FILTER_NETWORKIO, "Petition (GUID: %u) renamed to '%s'", GUID_LOPART(petitionGuid), newName.c_str());
WorldPacket data(MSG_PETITION_RENAME, (8+newName.size()+1));
@@ -416,26 +416,26 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recvData)
recvData >> unk;
Petition const* petition = sPetitionMgr->GetPetition(GUID_LOPART(petitionGuid));
if (!petition)
Petition const* petition = sPetitionMgr->GetPetition(GUID_LOPART(petitionGuid));
if (!petition)
{
sLog->outError("Petition %u is not found for player %u %s", GUID_LOPART(petitionGuid), GetPlayer()->GetGUIDLow(), GetPlayer()->GetName().c_str());
return;
}
uint64 ownerGuid = MAKE_NEW_GUID(petition->ownerGuid, 0, HIGHGUID_PLAYER);
uint8 type = petition->petitionType;
uint64 ownerGuid = MAKE_NEW_GUID(petition->ownerGuid, 0, HIGHGUID_PLAYER);
uint8 type = petition->petitionType;
uint32 playerGuid = _player->GetGUIDLow();
if (petition->ownerGuid == playerGuid)
return;
Signatures const* signatures = sPetitionMgr->GetSignature(GUID_LOPART(petitionGuid));
if (!signatures)
return;
Signatures const* signatures = sPetitionMgr->GetSignature(GUID_LOPART(petitionGuid));
if (!signatures)
return;
// not let enemies sign guild charter
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && GetPlayer()->GetTeamId() != sObjectMgr->GetPlayerTeamIdByGUID(ownerGuid))
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && GetPlayer()->GetTeamId() != sObjectMgr->GetPlayerTeamIdByGUID(ownerGuid))
{
if (type != GUILD_CHARTER_TYPE)
SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", "", ERR_ARENA_TEAM_NOT_ALLIED);
@@ -482,7 +482,7 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recvData)
}
}
uint32 signs = signatures->signatureMap.size();
if (++signs > type) // client signs maximum
return;
@@ -490,15 +490,15 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recvData)
// Client doesn't allow to sign petition two times by one character, but not check sign by another character from same account
// not allow sign another player from already sign player account
bool found = false;
for (SignatureMap::const_iterator itr = signatures->signatureMap.begin(); itr != signatures->signatureMap.end(); ++itr)
if (itr->second == GetAccountId())
{
found = true;
break;
}
bool found = false;
for (SignatureMap::const_iterator itr = signatures->signatureMap.begin(); itr != signatures->signatureMap.end(); ++itr)
if (itr->second == GetAccountId())
{
found = true;
break;
}
if (found)
if (found)
{
WorldPacket data(SMSG_PETITION_SIGN_RESULTS, (8+8+4));
data << uint64(petitionGuid);
@@ -523,8 +523,8 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recvData)
CharacterDatabase.Execute(stmt);
// xinef: fill petition store
sPetitionMgr->AddSignature(GUID_LOPART(petitionGuid), GetAccountId(), playerGuid);
// xinef: fill petition store
sPetitionMgr->AddSignature(GUID_LOPART(petitionGuid), GetAccountId(), playerGuid);
;//sLog->outDebug(LOG_FILTER_NETWORKIO, "PETITION SIGN: GUID %u by player: %s (GUID: %u Account: %u)", GUID_LOPART(petitionGuid), _player->GetName().c_str(), playerGuid, GetAccountId());
@@ -555,11 +555,11 @@ void WorldSession::HandlePetitionDeclineOpcode(WorldPacket & recvData)
recvData >> petitionguid; // petition guid
;//sLog->outDebug(LOG_FILTER_NETWORKIO, "Petition %u declined by %u", GUID_LOPART(petitionguid), _player->GetGUIDLow());
Petition const* petition = sPetitionMgr->GetPetition(GUID_LOPART(petitionguid));
if (!petition)
return;
Petition const* petition = sPetitionMgr->GetPetition(GUID_LOPART(petitionguid));
if (!petition)
return;
ownerguid = MAKE_NEW_GUID(petition->ownerGuid, 0, HIGHGUID_PLAYER);
ownerguid = MAKE_NEW_GUID(petition->ownerGuid, 0, HIGHGUID_PLAYER);
if (Player* owner = ObjectAccessor::FindPlayerInOrOutOfWorld(ownerguid)) // petition owner online
{
WorldPacket data(MSG_PETITION_DECLINE, 8);
@@ -583,13 +583,13 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket & recvData)
if (!player)
return;
Petition const* petition = sPetitionMgr->GetPetition(GUID_LOPART(petitionguid));
if (!petition)
return;
Petition const* petition = sPetitionMgr->GetPetition(GUID_LOPART(petitionguid));
if (!petition)
return;
if (GetPlayer()->GetTeamId() != player->GetTeamId())
{
if (petition->petitionType != GUILD_CHARTER_TYPE)
if (petition->petitionType != GUILD_CHARTER_TYPE)
SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", "", ERR_ARENA_TEAM_NOT_ALLIED);
else
Guild::SendCommandResult(this, GUILD_COMMAND_CREATE, ERR_GUILD_NOT_ALLIED);
@@ -637,8 +637,8 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket & recvData)
}
}
Signatures const* signatures = sPetitionMgr->GetSignature(GUID_LOPART(petitionguid));
uint8 signs = signatures ? signatures->signatureMap.size() : 0;
Signatures const* signatures = sPetitionMgr->GetSignature(GUID_LOPART(petitionguid));
uint8 signs = signatures ? signatures->signatureMap.size() : 0;
WorldPacket data(SMSG_PETITION_SHOW_SIGNATURES, (8+8+4+signs+signs*12));
data << uint64(petitionguid); // petition guid
@@ -646,12 +646,12 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket & recvData)
data << uint32(GUID_LOPART(petitionguid)); // guild guid
data << uint8(signs); // sign's count
if (signs)
for (SignatureMap::const_iterator itr = signatures->signatureMap.begin(); itr != signatures->signatureMap.end(); ++itr)
{
data << uint64(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER)); // Player GUID
data << uint32(0); // there 0 ...
}
if (signs)
for (SignatureMap::const_iterator itr = signatures->signatureMap.begin(); itr != signatures->signatureMap.end(); ++itr)
{
data << uint64(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER)); // Player GUID
data << uint32(0); // there 0 ...
}
player->GetSession()->SendPacket(&data);
}
@@ -673,16 +673,16 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recvData)
;//sLog->outDebug(LOG_FILTER_NETWORKIO, "Petition %u turned in by %u", GUID_LOPART(petitionGuid), _player->GetGUIDLow());
Petition const* petition = sPetitionMgr->GetPetition(GUID_LOPART(petitionGuid));
if (!petition)
{
Petition const* petition = sPetitionMgr->GetPetition(GUID_LOPART(petitionGuid));
if (!petition)
{
sLog->outError("Player %s (guid: %u) tried to turn in petition (guid: %u) that is not present in the database", _player->GetName().c_str(), _player->GetGUIDLow(), GUID_LOPART(petitionGuid));
return;
}
uint32 ownerguidlo = petition->ownerGuid;
uint8 type = petition->petitionType;
std::string name = petition->petitionName;
uint32 ownerguidlo = petition->ownerGuid;
uint8 type = petition->petitionType;
std::string name = petition->petitionName;
// Only the petition owner can turn in the petition
if (_player->GetGUIDLow() != ownerguidlo)
@@ -730,11 +730,11 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recvData)
}
// Get petition signatures from db
Signatures const* signatures = sPetitionMgr->GetSignature(GUID_LOPART(petitionGuid));
uint8 signs = signatures ? signatures->signatureMap.size() : 0;
SignatureMap signatureCopy;
if (signs)
signatureCopy = signatures->signatureMap;
Signatures const* signatures = sPetitionMgr->GetSignature(GUID_LOPART(petitionGuid));
uint8 signs = signatures ? signatures->signatureMap.size() : 0;
SignatureMap signatureCopy;
if (signs)
signatureCopy = signatures->signatureMap;
uint32 requiredSignatures;
if (type == GUILD_CHARTER_TYPE)
@@ -773,9 +773,9 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recvData)
Guild::SendCommandResult(this, GUILD_COMMAND_CREATE, ERR_GUILD_COMMAND_SUCCESS, name);
// Add members from signatures
if (signs)
for (SignatureMap::const_iterator itr = signatureCopy.begin(); itr != signatureCopy.end(); ++itr)
guild->AddMember(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER));
if (signs)
for (SignatureMap::const_iterator itr = signatureCopy.begin(); itr != signatureCopy.end(); ++itr)
guild->AddMember(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER));
}
else
{
@@ -797,12 +797,12 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recvData)
;//sLog->outDebug(LOG_FILTER_NETWORKIO, "PetitonsHandler: Arena team (guid: %u) added to ObjectMgr", arenaTeam->GetId());
// Add members
if (signs)
for (SignatureMap::const_iterator itr = signatureCopy.begin(); itr != signatureCopy.end(); ++itr)
{
;//sLog->outDebug(LOG_FILTER_NETWORKIO, "PetitionsHandler: Adding arena team (guid: %u) member %u", arenaTeam->GetId(), memberGUID);
arenaTeam->AddMember(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER));
}
if (signs)
for (SignatureMap::const_iterator itr = signatureCopy.begin(); itr != signatureCopy.end(); ++itr)
{
;//sLog->outDebug(LOG_FILTER_NETWORKIO, "PetitionsHandler: Adding arena team (guid: %u) member %u", arenaTeam->GetId(), memberGUID);
arenaTeam->AddMember(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER));
}
}
SQLTransaction trans = CharacterDatabase.BeginTransaction();
@@ -817,8 +817,8 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recvData)
CharacterDatabase.CommitTransaction(trans);
// xinef: clear petition store (petition and signatures)
sPetitionMgr->RemovePetition(GUID_LOPART(petitionGuid));
// xinef: clear petition store (petition and signatures)
sPetitionMgr->RemovePetition(GUID_LOPART(petitionGuid));
// created
;//sLog->outDebug(LOG_FILTER_NETWORKIO, "TURN IN PETITION GUID %u", GUID_LOPART(petitionGuid));

View File

@@ -33,7 +33,7 @@
void WorldSession::SendNameQueryOpcode(uint64 guid)
{
GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(GUID_LOPART(guid));
GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(GUID_LOPART(guid));
WorldPacket data(SMSG_NAME_QUERY_RESPONSE, (8+1+1+1+1+1+10));
data.appendPackGUID(guid);
@@ -324,14 +324,14 @@ void WorldSession::HandleQuestPOIQuery(WorldPacket& recvData)
}
// Read quest ids and add the in a unordered_set so we don't send POIs for the same quest multiple times
UNORDERED_SET<uint32> questIds;
UNORDERED_SET<uint32> questIds;
for (uint32 i = 0; i < count; ++i)
questIds.insert(recvData.read<uint32>()); // quest id
WorldPacket data(SMSG_QUEST_POI_QUERY_RESPONSE, 4 + (4 + 4)*questIds.size());
data << uint32(questIds.size()); // count
for (UNORDERED_SET<uint32>::const_iterator itr = questIds.begin(); itr != questIds.end(); ++itr)
for (UNORDERED_SET<uint32>::const_iterator itr = questIds.begin(); itr != questIds.end(); ++itr)
{
uint32 questId = *itr;
bool questOk = false;

View File

@@ -89,8 +89,8 @@ void WorldSession::HandleQuestgiverHelloOpcode(WorldPacket & recvData)
if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
// Stop the npc if moving
//if (!creature->GetTransport()) // pussywizard: reverted with new spline (old: without this check, npc would stay in place and the transport would continue moving, so the npc falls off. NPCs on transports don't have waypoints, so stopmoving is not needed)
creature->StopMoving();
//if (!creature->GetTransport()) // pussywizard: reverted with new spline (old: without this check, npc would stay in place and the transport would continue moving, so the npc falls off. NPCs on transports don't have waypoints, so stopmoving is not needed)
creature->StopMoving();
if (sScriptMgr->OnGossipHello(_player, creature))
return;
@@ -127,12 +127,12 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket & recvData)
if (Quest const* quest = sObjectMgr->GetQuestTemplate(questId))
{
// pussywizard: exploit fix, can't share quests that give items to be sold
if (object->GetTypeId() == TYPEID_PLAYER)
if (uint32 itemId = quest->GetSrcItemId())
if (const ItemTemplate* srcItem = sObjectMgr->GetItemTemplate(itemId))
if (srcItem->SellPrice > 0)
return;
// pussywizard: exploit fix, can't share quests that give items to be sold
if (object->GetTypeId() == TYPEID_PLAYER)
if (uint32 itemId = quest->GetSrcItemId())
if (const ItemTemplate* srcItem = sObjectMgr->GetItemTemplate(itemId))
if (srcItem->SellPrice > 0)
return;
// prevent cheating
if (!GetPlayer()->CanTakeQuest(quest, true))
@@ -276,7 +276,7 @@ void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPacket & recvData)
switch (object->GetTypeId())
{
case TYPEID_UNIT:
{
{
Creature* questgiver = object->ToCreature();
if (!sScriptMgr->OnQuestReward(_player, questgiver, quest, reward))
{
@@ -284,17 +284,17 @@ void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPacket & recvData)
if (Quest const* nextQuest = _player->GetNextQuest(guid, quest))
{
if (_player->CanAddQuest(nextQuest, false) && _player->CanTakeQuest(nextQuest, false))
{
if (nextQuest->IsAutoAccept())
_player->AddQuestAndCheckCompletion(nextQuest, object);
_player->PlayerTalkClass->SendQuestGiverQuestDetails(nextQuest, guid, true);
}
{
if (nextQuest->IsAutoAccept())
_player->AddQuestAndCheckCompletion(nextQuest, object);
_player->PlayerTalkClass->SendQuestGiverQuestDetails(nextQuest, guid, true);
}
}
questgiver->AI()->sQuestReward(_player, quest, reward);
}
break;
}
}
case TYPEID_GAMEOBJECT:
{
GameObject* questGiver = object->ToGameObject();
@@ -304,17 +304,17 @@ void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPacket & recvData)
if (Quest const* nextQuest = _player->GetNextQuest(guid, quest))
{
if (_player->CanAddQuest(nextQuest, false) && _player->CanTakeQuest(quest, false))
{
if (nextQuest->IsAutoAccept())
_player->AddQuestAndCheckCompletion(nextQuest, object);
_player->PlayerTalkClass->SendQuestGiverQuestDetails(nextQuest, guid, true);
}
{
if (nextQuest->IsAutoAccept())
_player->AddQuestAndCheckCompletion(nextQuest, object);
_player->PlayerTalkClass->SendQuestGiverQuestDetails(nextQuest, guid, true);
}
}
questGiver->AI()->QuestReward(_player, quest, reward);
}
break;
}
}
default:
break;
}
@@ -431,11 +431,11 @@ void WorldSession::HandleQuestConfirmAccept(WorldPacket& recvData)
if (!_player->CanTakeQuest(quest, true) || _player->HasPendingBind())
return;
// pussywizard: exploit fix, can't share quests that give items to be sold
if (uint32 itemId = quest->GetSrcItemId())
if (const ItemTemplate* srcItem = sObjectMgr->GetItemTemplate(itemId))
if (srcItem->SellPrice > 0)
return;
// pussywizard: exploit fix, can't share quests that give items to be sold
if (uint32 itemId = quest->GetSrcItemId())
if (const ItemTemplate* srcItem = sObjectMgr->GetItemTemplate(itemId))
if (srcItem->SellPrice > 0)
return;
if (_player->CanAddQuest(quest, true))
_player->AddQuestAndCheckCompletion(quest, NULL); // NULL, this prevent DB script from duplicate running
@@ -550,7 +550,7 @@ void WorldSession::HandlePushQuestToParty(WorldPacket& recvPacket)
_player->SendPushToPartyResponse(player, QUEST_PARTY_MSG_SHARING_QUEST);
if (quest->IsAutoAccept() && player->CanAddQuest(quest, true) && player->CanTakeQuest(quest, true))
player->AddQuestAndCheckCompletion(quest, _player);
player->AddQuestAndCheckCompletion(quest, _player);
if ((quest->IsAutoComplete() && quest->IsRepeatable() && !quest->IsDailyOrWeekly()) || quest->HasFlag(QUEST_FLAGS_AUTOCOMPLETE))
player->PlayerTalkClass->SendQuestGiverRequestItems(quest, _player->GetGUID(), player->CanCompleteRepeatableQuest(quest), true);

View File

@@ -240,12 +240,12 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket)
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_GIFT_BY_ITEM);
stmt->setUInt32(0, item->GetGUIDLow());
stmt->setUInt32(0, item->GetGUIDLow());
_openWrappedItemCallback.SetFirstParam(bagIndex);
_openWrappedItemCallback.SetSecondParam(slot);
_openWrappedItemCallback.SetThirdParam(item->GetGUIDLow());
_openWrappedItemCallback.SetFutureResult(CharacterDatabase.AsyncQuery(stmt));
_openWrappedItemCallback.SetFirstParam(bagIndex);
_openWrappedItemCallback.SetSecondParam(slot);
_openWrappedItemCallback.SetThirdParam(item->GetGUIDLow());
_openWrappedItemCallback.SetFutureResult(CharacterDatabase.AsyncQuery(stmt));
}
else
pUser->SendLoot(item->GetGUID(), LOOT_CORPSE);
@@ -256,14 +256,14 @@ void WorldSession::HandleOpenWrappedItemCallback(PreparedQueryResult result, uin
if (!GetPlayer())
return;
Item* item = GetPlayer()->GetItemByPos(bagIndex, slot);
if (!item)
return;
Item* item = GetPlayer()->GetItemByPos(bagIndex, slot);
if (!item)
return;
if (item->GetGUIDLow() != itemLowGUID || !item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_WRAPPED)) // during getting result, gift was swapped with another item
return;
if (item->GetGUIDLow() != itemLowGUID || !item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_WRAPPED)) // during getting result, gift was swapped with another item
return;
if (!result)
{
sLog->outError("Wrapped item %u don't have record in character_gifts table and will deleted", item->GetGUIDLow());
@@ -280,16 +280,16 @@ void WorldSession::HandleOpenWrappedItemCallback(PreparedQueryResult result, uin
item->SetUInt64Value(ITEM_FIELD_GIFTCREATOR, 0);
item->SetEntry(entry);
item->SetUInt32Value(ITEM_FIELD_FLAGS, flags);
item->SetUInt32Value(ITEM_FIELD_MAXDURABILITY, item->GetTemplate()->MaxDurability);
item->SetUInt32Value(ITEM_FIELD_MAXDURABILITY, item->GetTemplate()->MaxDurability);
item->SetState(ITEM_CHANGED, GetPlayer());
GetPlayer()->SaveInventoryAndGoldToDB(trans);
GetPlayer()->SaveInventoryAndGoldToDB(trans);
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GIFT);
stmt->setUInt32(0, item->GetGUIDLow());
trans->Append(stmt);
trans->Append(stmt);
CharacterDatabase.CommitTransaction(trans);
CharacterDatabase.CommitTransaction(trans);
}
void WorldSession::HandleGameObjectUseOpcode(WorldPacket & recvData)
@@ -374,24 +374,24 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket)
}
else
{
// pussywizard: casting player's spells from vehicle when seat allows it
// if ANYTHING CHANGES in this function, INFORM ME BEFORE applying!!!
if (Vehicle* veh = mover->GetVehicleKit())
if (const VehicleSeatEntry* seat = veh->GetSeatForPassenger(_player))
if (seat->m_flags & VEHICLE_SEAT_FLAG_CAN_ATTACK || spellInfo->Effects[EFFECT_0].Effect == SPELL_EFFECT_OPEN_LOCK /*allow looting from vehicle, but only if player has required spell (all necessary opening spells are in playercreateinfo_spell)*/)
if ((mover->GetTypeId() == TYPEID_UNIT && !mover->ToCreature()->HasSpell(spellId)) || spellInfo->IsPassive()) // the creature can't cast that spell, check player instead
{
if( !(spellInfo->Targets & TARGET_FLAG_GAMEOBJECT_ITEM) && (!_player->HasActiveSpell (spellId) || spellInfo->IsPassive()) )
{
//cheater? kick? ban?
recvPacket.rfinish(); // prevent spam at ignore packet
return;
}
// pussywizard: casting player's spells from vehicle when seat allows it
// if ANYTHING CHANGES in this function, INFORM ME BEFORE applying!!!
if (Vehicle* veh = mover->GetVehicleKit())
if (const VehicleSeatEntry* seat = veh->GetSeatForPassenger(_player))
if (seat->m_flags & VEHICLE_SEAT_FLAG_CAN_ATTACK || spellInfo->Effects[EFFECT_0].Effect == SPELL_EFFECT_OPEN_LOCK /*allow looting from vehicle, but only if player has required spell (all necessary opening spells are in playercreateinfo_spell)*/)
if ((mover->GetTypeId() == TYPEID_UNIT && !mover->ToCreature()->HasSpell(spellId)) || spellInfo->IsPassive()) // the creature can't cast that spell, check player instead
{
if( !(spellInfo->Targets & TARGET_FLAG_GAMEOBJECT_ITEM) && (!_player->HasActiveSpell (spellId) || spellInfo->IsPassive()) )
{
//cheater? kick? ban?
recvPacket.rfinish(); // prevent spam at ignore packet
return;
}
// at this point, player is a valid caster
// swapping the mover will stop the check below at == TYPEID_UNIT, so everything works fine
mover = _player;
}
// at this point, player is a valid caster
// swapping the mover will stop the check below at == TYPEID_UNIT, so everything works fine
mover = _player;
}
// not have spell in spellbook or spell passive and not casted by client
if ((mover->GetTypeId() == TYPEID_UNIT && !mover->ToCreature()->HasSpell(spellId)) || spellInfo->IsPassive())
@@ -452,7 +452,7 @@ void WorldSession::HandleCancelCastOpcode(WorldPacket& recvPacket)
recvPacket.read_skip<uint8>(); // counter, increments with every CANCEL packet, don't use for now
recvPacket >> spellId;
_player->InterruptSpell(CURRENT_MELEE_SPELL);
_player->InterruptSpell(CURRENT_MELEE_SPELL);
if (_player->IsNonMeleeSpellCast(false))
_player->InterruptNonMeleeSpells(false, spellId, false, true);
}
@@ -467,7 +467,7 @@ void WorldSession::HandleCancelAuraOpcode(WorldPacket& recvPacket)
return;
// not allow remove non positive spells and spells with attr SPELL_ATTR0_CANT_CANCEL
if ((!spellInfo->IsPositive() || spellInfo->HasAttribute(SPELL_ATTR0_CANT_CANCEL) || spellInfo->IsPassive()) && spellId != 605)
if ((!spellInfo->IsPositive() || spellInfo->HasAttribute(SPELL_ATTR0_CANT_CANCEL) || spellInfo->IsPassive()) && spellId != 605)
return;
// channeled spell case (it currently casted then)
@@ -580,10 +580,10 @@ void WorldSession::HandleSelfResOpcode(WorldPacket & /*recvData*/)
{
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(_player->GetUInt32Value(PLAYER_SELF_RES_SPELL));
if (spellInfo)
{
{
_player->CastSpell(_player, spellInfo, true, 0);
_player->AddSpellAndCategoryCooldowns(spellInfo, 0);
}
_player->AddSpellAndCategoryCooldowns(spellInfo, 0);
}
_player->SetUInt32Value(PLAYER_SELF_RES_SPELL, 0);
}

View File

@@ -210,7 +210,7 @@ void WorldSession::HandleMoveSplineDoneOpcode(WorldPacket& recvData)
recvData.readPackGUID(guid);
MovementInfo movementInfo; // used only for proper packet read
movementInfo.guid = guid;
movementInfo.guid = guid;
ReadMovementInfo(recvData, &movementInfo);
recvData.read_skip<uint32>(); // spline id

View File

@@ -458,14 +458,14 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& /*recvPacket*/)
// execute trade: 2. store
moveItems(myItems, hisItems);
if( my_trade->GetMoney() >= 10*GOLD )
{
CharacterDatabase.PExecute("INSERT INTO log_money VALUES(%u, %u, \"%s\", \"%s\", %u, \"%s\", %u, \"<TRADE>\", NOW())", GetAccountId(), _player->GetGUIDLow(), _player->GetName().c_str(), GetRemoteAddress().c_str(), trader->GetSession()->GetAccountId(), trader->GetName().c_str(), my_trade->GetMoney());
}
if( his_trade->GetMoney() >= 10*GOLD )
{
CharacterDatabase.PExecute("INSERT INTO log_money VALUES(%u, %u, \"%s\", \"%s\", %u, \"%s\", %u, \"<TRADE>\", NOW())", trader->GetSession()->GetAccountId(), trader->GetGUIDLow(), trader->GetName().c_str(), trader->GetSession()->GetRemoteAddress().c_str(), GetAccountId(), _player->GetName().c_str(), his_trade->GetMoney());
}
if( my_trade->GetMoney() >= 10*GOLD )
{
CharacterDatabase.PExecute("INSERT INTO log_money VALUES(%u, %u, \"%s\", \"%s\", %u, \"%s\", %u, \"<TRADE>\", NOW())", GetAccountId(), _player->GetGUIDLow(), _player->GetName().c_str(), GetRemoteAddress().c_str(), trader->GetSession()->GetAccountId(), trader->GetName().c_str(), my_trade->GetMoney());
}
if( his_trade->GetMoney() >= 10*GOLD )
{
CharacterDatabase.PExecute("INSERT INTO log_money VALUES(%u, %u, \"%s\", \"%s\", %u, \"%s\", %u, \"<TRADE>\", NOW())", trader->GetSession()->GetAccountId(), trader->GetGUIDLow(), trader->GetName().c_str(), trader->GetSession()->GetRemoteAddress().c_str(), GetAccountId(), _player->GetName().c_str(), his_trade->GetMoney());
}
// update money
_player->ModifyMoney(-int32(my_trade->GetMoney()));
@@ -571,8 +571,8 @@ void WorldSession::HandleInitiateTradeOpcode(WorldPacket& recvPacket)
return;
}
if (GetPlayer()->IsSpectator())
return;
if (GetPlayer()->IsSpectator())
return;
Player* pOther = ObjectAccessor::FindPlayer(ID);
@@ -618,11 +618,11 @@ void WorldSession::HandleInitiateTradeOpcode(WorldPacket& recvPacket)
return;
}
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_TRADE) && pOther->GetTeamId() != _player->GetTeamId())
{
SendTradeStatus(TRADE_STATUS_WRONG_FACTION);
return;
}
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_TRADE) && pOther->GetTeamId() != _player->GetTeamId())
{
SendTradeStatus(TRADE_STATUS_WRONG_FACTION);
return;
}
if (!pOther->IsWithinDistInMap(_player, 10.0f, false))
{

View File

@@ -39,13 +39,13 @@ void WorldSession::HandleDismissControlledVehicle(WorldPacket &recvData)
recvData.readPackGUID(guid);
// pussywizard: typical check for incomming movement packets
if (!_player->m_mover || !_player->m_mover->IsInWorld() || _player->m_mover->IsDuringRemoveFromWorld() || guid != _player->m_mover->GetGUID())
{
recvData.rfinish(); // prevent warnings spam
_player->ExitVehicle();
return;
}
// pussywizard: typical check for incomming movement packets
if (!_player->m_mover || !_player->m_mover->IsInWorld() || _player->m_mover->IsDuringRemoveFromWorld() || guid != _player->m_mover->GetGUID())
{
recvData.rfinish(); // prevent warnings spam
_player->ExitVehicle();
return;
}
MovementInfo mi;
mi.guid = guid;
@@ -89,12 +89,12 @@ void WorldSession::HandleChangeSeatsOnControlledVehicle(WorldPacket &recvData)
uint64 guid; // current vehicle guid
recvData.readPackGUID(guid);
// pussywizard:
if (vehicle_base->GetGUID() != guid)
{
recvData.rfinish(); // prevent warnings spam
return;
}
// pussywizard:
if (vehicle_base->GetGUID() != guid)
{
recvData.rfinish(); // prevent warnings spam
return;
}
MovementInfo movementInfo;
movementInfo.guid = guid;
@@ -152,9 +152,9 @@ void WorldSession::HandleEnterPlayerVehicle(WorldPacket &data)
return;
if (!player->IsWithinDistInMap(_player, INTERACTION_DISTANCE))
return;
// Xinef:
if (!_player->FindMap() || _player->FindMap()->IsBattleArena())
return;
// Xinef:
if (!_player->FindMap() || _player->FindMap()->IsBattleArena())
return;
_player->EnterVehicle(player);
}