2 * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "Database/DatabaseEnv.h"
22 #include "Database/DatabaseImpl.h"
23 #include "WorldPacket.h"
28 #include "ObjectMgr.h"
29 #include "WorldSession.h"
30 #include "Auth/BigNumber.h"
31 #include "Auth/Sha1.h"
32 #include "UpdateData.h"
35 #include "ScriptCalls.h"
36 #include <zlib/zlib.h>
37 #include "ObjectAccessor.h"
39 #include "BattleGround.h"
41 #include "SocialMgr.h"
43 void WorldSession::HandleRepopRequestOpcode( WorldPacket
& /*recv_data*/ )
45 sLog
.outDebug( "WORLD: Recvd CMSG_REPOP_REQUEST Message" );
47 if(GetPlayer()->isAlive()||GetPlayer()->HasFlag(PLAYER_FLAGS
, PLAYER_FLAGS_GHOST
))
50 // the world update order is sessions, players, creatures
51 // the netcode runs in parallel with all of these
52 // creatures can kill players
53 // so if the server is lagging enough the player can
54 // release spirit after he's killed but before he is updated
55 if(GetPlayer()->getDeathState() == JUST_DIED
)
57 sLog
.outDebug("HandleRepopRequestOpcode: got request after player %s(%d) was killed and before he was updated", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow());
58 GetPlayer()->KillPlayer();
61 //this is spirit release confirm?
62 GetPlayer()->RemovePet(NULL
,PET_SAVE_NOT_IN_SLOT
, true);
63 GetPlayer()->BuildPlayerRepop();
64 GetPlayer()->RepopAtGraveyard();
67 void WorldSession::HandleWhoOpcode( WorldPacket
& recv_data
)
69 CHECK_PACKET_SIZE(recv_data
,4+4+1+1+4+4+4+4);
71 sLog
.outDebug( "WORLD: Recvd CMSG_WHO Message" );
72 //recv_data.hexlike();
74 uint32 clientcount
= 0;
76 uint32 level_min
, level_max
, racemask
, classmask
, zones_count
, str_count
;
77 uint32 zoneids
[10]; // 10 is client limit
78 std::string player_name
, guild_name
;
80 recv_data
>> level_min
; // maximal player level, default 0
81 recv_data
>> level_max
; // minimal player level, default 100 (MAX_LEVEL)
82 recv_data
>> player_name
; // player name, case sensitive...
85 CHECK_PACKET_SIZE(recv_data
,4+4+(player_name
.size()+1)+1+4+4+4+4);
87 recv_data
>> guild_name
; // guild name, case sensitive...
90 CHECK_PACKET_SIZE(recv_data
,4+4+(player_name
.size()+1)+(guild_name
.size()+1)+4+4+4+4);
92 recv_data
>> racemask
; // race mask
93 recv_data
>> classmask
; // class mask
94 recv_data
>> zones_count
; // zones count, client limit=10 (2.0.10)
97 return; // can't be received from real client or broken packet
100 CHECK_PACKET_SIZE(recv_data
,4+4+(player_name
.size()+1)+(guild_name
.size()+1)+4+4+4+(4*zones_count
)+4);
102 for(uint32 i
= 0; i
< zones_count
; ++i
)
105 recv_data
>> temp
; // zone id, 0 if zone is unknown...
107 sLog
.outDebug("Zone %u: %u", i
, zoneids
[i
]);
110 recv_data
>> str_count
; // user entered strings count, client limit=4 (checked on 2.0.10)
113 return; // can't be received from real client or broken packet
116 CHECK_PACKET_SIZE(recv_data
,4+4+(player_name
.size()+1)+(guild_name
.size()+1)+4+4+4+(4*zones_count
)+4+(1*str_count
));
118 sLog
.outDebug("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
);
120 std::wstring str
[4]; // 4 is client limit
121 for(uint32 i
= 0; i
< str_count
; ++i
)
123 // recheck (have one more byte)
124 CHECK_PACKET_SIZE(recv_data
,recv_data
.rpos());
127 recv_data
>> temp
; // user entered string, it used as universal search pattern(guild+player name)?
129 if(!Utf8toWStr(temp
,str
[i
]))
134 sLog
.outDebug("String %u: %s", i
, temp
.c_str());
137 std::wstring wplayer_name
;
138 std::wstring wguild_name
;
139 if(!(Utf8toWStr(player_name
, wplayer_name
) && Utf8toWStr(guild_name
, wguild_name
)))
141 wstrToLower(wplayer_name
);
142 wstrToLower(wguild_name
);
144 // client send in case not set max level value 100 but mangos support 255 max level,
145 // update it to show GMs with characters after 100 level
146 if(level_max
>= MAX_LEVEL
)
147 level_max
= STRONG_MAX_LEVEL
;
149 uint32 team
= _player
->GetTeam();
150 uint32 security
= GetSecurity();
151 bool allowTwoSideWhoList
= sWorld
.getConfig(CONFIG_ALLOW_TWO_SIDE_WHO_LIST
);
152 bool gmInWhoList
= sWorld
.getConfig(CONFIG_GM_IN_WHO_LIST
);
154 WorldPacket
data( SMSG_WHO
, 50 ); // guess size
155 data
<< clientcount
; // clientcount place holder
156 data
<< clientcount
; // clientcount place holder
158 //TODO: Guard Player map
159 HashMapHolder
<Player
>::MapType
& m
= ObjectAccessor::Instance().GetPlayers();
160 for(HashMapHolder
<Player
>::MapType::const_iterator itr
= m
.begin(); itr
!= m
.end(); ++itr
)
162 if (security
== SEC_PLAYER
)
164 // player can see member of other team only if CONFIG_ALLOW_TWO_SIDE_WHO_LIST
165 if (itr
->second
->GetTeam() != team
&& !allowTwoSideWhoList
)
168 // player can see MODERATOR, GAME MASTER, ADMINISTRATOR only if CONFIG_GM_IN_WHO_LIST
169 if ((itr
->second
->GetSession()->GetSecurity() > SEC_PLAYER
&& !gmInWhoList
))
173 // check if target is globally visible for player
174 if (!(itr
->second
->IsVisibleGloballyFor(_player
)))
177 // check if target's level is in level range
178 uint32 lvl
= itr
->second
->getLevel();
179 if (lvl
< level_min
|| lvl
> level_max
)
182 // check if class matches classmask
183 uint32 class_
= itr
->second
->getClass();
184 if (!(classmask
& (1 << class_
)))
187 // check if race matches racemask
188 uint32 race
= itr
->second
->getRace();
189 if (!(racemask
& (1 << race
)))
192 uint32 pzoneid
= itr
->second
->GetZoneId();
195 for(uint32 i
= 0; i
< zones_count
; ++i
)
197 if(zoneids
[i
] == pzoneid
)
208 std::string pname
= itr
->second
->GetName();
210 if(!Utf8toWStr(pname
,wpname
))
214 if (!(wplayer_name
.empty() || wpname
.find(wplayer_name
) != std::wstring::npos
))
217 std::string gname
= objmgr
.GetGuildNameById(itr
->second
->GetGuildId());
219 if(!Utf8toWStr(gname
,wgname
))
223 if (!(wguild_name
.empty() || wgname
.find(wguild_name
) != std::wstring::npos
))
227 if(AreaTableEntry
const* areaEntry
= GetAreaEntryByAreaID(itr
->second
->GetZoneId()))
228 aname
= areaEntry
->area_name
[GetSessionDbcLocale()];
231 for(uint32 i
= 0; i
< str_count
; ++i
)
235 if (wgname
.find(str
[i
]) != std::wstring::npos
||
236 wpname
.find(str
[i
]) != std::wstring::npos
||
237 Utf8FitTo(aname
, str
[i
]) )
248 data
<< pname
; // player name
249 data
<< gname
; // guild name
250 data
<< uint32( lvl
); // player level
251 data
<< uint32( class_
); // player class
252 data
<< uint32( race
); // player race
253 data
<< uint8(0); // new 2.4.0
254 data
<< uint32( pzoneid
); // player zone id
256 // 49 is maximum player count sent to client
257 if ((++clientcount
) == 49)
261 data
.put( 0, clientcount
); //insert right count
262 data
.put( sizeof(uint32
), clientcount
); //insert right count
265 sLog
.outDebug( "WORLD: Send SMSG_WHO Message" );
268 void WorldSession::HandleLogoutRequestOpcode( WorldPacket
& /*recv_data*/ )
270 sLog
.outDebug( "WORLD: Recvd CMSG_LOGOUT_REQUEST Message, security - %u", GetSecurity() );
272 if (uint64 lguid
= GetPlayer()->GetLootGUID())
273 DoLootRelease(lguid
);
275 //Can not logout if...
276 if( GetPlayer()->isInCombat() || //...is in combat
277 GetPlayer()->duel
|| //...is in Duel
278 //...is jumping ...is falling
279 GetPlayer()->m_movementInfo
.HasMovementFlag(MOVEMENTFLAG_JUMPING
| MOVEMENTFLAG_FALLING
))
281 WorldPacket
data( SMSG_LOGOUT_RESPONSE
, (2+4) ) ;
290 //instant logout in taverns/cities or on taxi or for admins, gm's, mod's if its enabled in mangosd.conf
291 if (GetPlayer()->HasFlag(PLAYER_FLAGS
, PLAYER_FLAGS_RESTING
) || GetPlayer()->isInFlight() ||
292 GetSecurity() >= sWorld
.getConfig(CONFIG_INSTANT_LOGOUT
))
298 // not set flags if player can't free move to prevent lost state at logout cancel
299 if(GetPlayer()->CanFreeMove())
301 GetPlayer()->SetStandState(UNIT_STAND_STATE_SIT
);
303 WorldPacket
data( SMSG_FORCE_MOVE_ROOT
, (8+4) ); // guess size
304 data
.append(GetPlayer()->GetPackGUID());
307 GetPlayer()->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_STUNNED
);
310 WorldPacket
data( SMSG_LOGOUT_RESPONSE
, 5 );
314 LogoutRequest(time(NULL
));
317 void WorldSession::HandlePlayerLogoutOpcode( WorldPacket
& /*recv_data*/ )
319 sLog
.outDebug( "WORLD: Recvd CMSG_PLAYER_LOGOUT Message" );
322 void WorldSession::HandleLogoutCancelOpcode( WorldPacket
& /*recv_data*/ )
324 sLog
.outDebug( "WORLD: Recvd CMSG_LOGOUT_CANCEL Message" );
328 WorldPacket
data( SMSG_LOGOUT_CANCEL_ACK
, 0 );
331 // not remove flags if can't free move - its not set in Logout request code.
332 if(GetPlayer()->CanFreeMove())
335 data
.Initialize( SMSG_FORCE_MOVE_UNROOT
, 8 ); // guess size
336 data
.append(GetPlayer()->GetPackGUID());
341 GetPlayer()->SetStandState(UNIT_STAND_STATE_STAND
);
344 GetPlayer()->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_STUNNED
);
347 sLog
.outDebug( "WORLD: sent SMSG_LOGOUT_CANCEL_ACK Message" );
350 void WorldSession::HandleTogglePvP( WorldPacket
& recv_data
)
352 // this opcode can be used in two ways: Either set explicit new status or toggle old status
353 if(recv_data
.size() == 1)
356 recv_data
>> newPvPStatus
;
357 GetPlayer()->ApplyModFlag(PLAYER_FLAGS
, PLAYER_FLAGS_IN_PVP
, newPvPStatus
);
358 GetPlayer()->ApplyModFlag(PLAYER_FLAGS
, PLAYER_FLAGS_PVP_TIMER
, !newPvPStatus
);
362 GetPlayer()->ToggleFlag(PLAYER_FLAGS
, PLAYER_FLAGS_IN_PVP
);
363 GetPlayer()->ToggleFlag(PLAYER_FLAGS
, PLAYER_FLAGS_PVP_TIMER
);
366 if(GetPlayer()->HasFlag(PLAYER_FLAGS
, PLAYER_FLAGS_IN_PVP
))
368 if(!GetPlayer()->IsPvP() || GetPlayer()->pvpInfo
.endTimer
!= 0)
369 GetPlayer()->UpdatePvP(true, true);
373 if(!GetPlayer()->pvpInfo
.inHostileArea
&& GetPlayer()->IsPvP())
374 GetPlayer()->pvpInfo
.endTimer
= time(NULL
); // start toggle-off
378 void WorldSession::HandleZoneUpdateOpcode( WorldPacket
& recv_data
)
380 CHECK_PACKET_SIZE(recv_data
,4);
383 recv_data
>> newZone
;
385 sLog
.outDetail("WORLD: Recvd ZONE_UPDATE: %u", newZone
);
387 // use server size data
388 uint32 newzone
, newarea
;
389 GetPlayer()->GetZoneAndAreaId(newzone
,newarea
);
390 GetPlayer()->UpdateZone(newzone
,newarea
);
393 void WorldSession::HandleSetTargetOpcode( WorldPacket
& recv_data
)
395 // When this packet send?
396 CHECK_PACKET_SIZE(recv_data
,8);
401 _player
->SetUInt32Value(UNIT_FIELD_TARGET
,guid
);
403 // update reputation list if need
404 Unit
* unit
= ObjectAccessor::GetUnit(*_player
, guid
);
408 if(FactionTemplateEntry
const* factionTemplateEntry
= sFactionTemplateStore
.LookupEntry(unit
->getFaction()))
409 _player
->GetReputationMgr().SetVisible(factionTemplateEntry
);
412 void WorldSession::HandleSetSelectionOpcode( WorldPacket
& recv_data
)
414 CHECK_PACKET_SIZE(recv_data
,8);
419 _player
->SetSelection(guid
);
421 // update reputation list if need
422 Unit
* unit
= ObjectAccessor::GetUnit(*_player
, guid
);
426 if(FactionTemplateEntry
const* factionTemplateEntry
= sFactionTemplateStore
.LookupEntry(unit
->getFaction()))
427 _player
->GetReputationMgr().SetVisible(factionTemplateEntry
);
430 void WorldSession::HandleStandStateChangeOpcode( WorldPacket
& recv_data
)
432 CHECK_PACKET_SIZE(recv_data
,1);
434 sLog
.outDebug( "WORLD: Received CMSG_STAND_STATE_CHANGE" );
436 recv_data
>> animstate
;
438 _player
->SetStandState(animstate
);
441 void WorldSession::HandleContactListOpcode( WorldPacket
& recv_data
)
443 CHECK_PACKET_SIZE(recv_data
, 4);
444 sLog
.outDebug( "WORLD: Received CMSG_CONTACT_LIST" );
447 sLog
.outDebug("unk value is %u", unk
);
448 _player
->GetSocial()->SendSocialList();
451 void WorldSession::HandleAddFriendOpcode( WorldPacket
& recv_data
)
453 CHECK_PACKET_SIZE(recv_data
, 1+1);
455 sLog
.outDebug( "WORLD: Received CMSG_ADD_FRIEND" );
457 std::string friendName
= GetMangosString(LANG_FRIEND_IGNORE_UNKNOWN
);
458 std::string friendNote
;
460 recv_data
>> friendName
;
463 CHECK_PACKET_SIZE(recv_data
, (friendName
.size()+1)+1);
465 recv_data
>> friendNote
;
467 if(!normalizePlayerName(friendName
))
470 CharacterDatabase
.escape_string(friendName
); // prevent SQL injection - normal name don't must changed by this call
472 sLog
.outDebug( "WORLD: %s asked to add friend : '%s'",
473 GetPlayer()->GetName(), friendName
.c_str() );
475 CharacterDatabase
.AsyncPQuery(&WorldSession::HandleAddFriendOpcodeCallBack
, GetAccountId(), friendNote
, "SELECT guid, race FROM characters WHERE name = '%s'", friendName
.c_str());
478 void WorldSession::HandleAddFriendOpcodeCallBack(QueryResult
*result
, uint32 accountId
, std::string friendNote
)
483 uint64 friendGuid
= MAKE_NEW_GUID((*result
)[0].GetUInt32(), 0, HIGHGUID_PLAYER
);
484 uint32 team
= Player::TeamForRace((*result
)[1].GetUInt8());
488 WorldSession
* session
= sWorld
.FindSession(accountId
);
489 if(!session
|| !session
->GetPlayer())
492 FriendsResult friendResult
= FRIEND_NOT_FOUND
;
495 if(friendGuid
==session
->GetPlayer()->GetGUID())
496 friendResult
= FRIEND_SELF
;
497 else if(session
->GetPlayer()->GetTeam() != team
&& !sWorld
.getConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND
) && session
->GetSecurity() < SEC_MODERATOR
)
498 friendResult
= FRIEND_ENEMY
;
499 else if(session
->GetPlayer()->GetSocial()->HasFriend(GUID_LOPART(friendGuid
)))
500 friendResult
= FRIEND_ALREADY
;
503 Player
* pFriend
= ObjectAccessor::FindPlayer(friendGuid
);
504 if( pFriend
&& pFriend
->IsInWorld() && pFriend
->IsVisibleGloballyFor(session
->GetPlayer()))
505 friendResult
= FRIEND_ADDED_ONLINE
;
507 friendResult
= FRIEND_ADDED_OFFLINE
;
509 if(!session
->GetPlayer()->GetSocial()->AddToSocialList(GUID_LOPART(friendGuid
), false))
511 friendResult
= FRIEND_LIST_FULL
;
512 sLog
.outDebug( "WORLD: %s's friend list is full.", session
->GetPlayer()->GetName());
515 session
->GetPlayer()->GetSocial()->SetFriendNote(GUID_LOPART(friendGuid
), friendNote
);
519 sSocialMgr
.SendFriendStatus(session
->GetPlayer(), friendResult
, GUID_LOPART(friendGuid
), false);
521 sLog
.outDebug( "WORLD: Sent (SMSG_FRIEND_STATUS)" );
524 void WorldSession::HandleDelFriendOpcode( WorldPacket
& recv_data
)
526 CHECK_PACKET_SIZE(recv_data
, 8);
530 sLog
.outDebug( "WORLD: Received CMSG_DEL_FRIEND" );
532 recv_data
>> FriendGUID
;
534 _player
->GetSocial()->RemoveFromSocialList(GUID_LOPART(FriendGUID
), false);
536 sSocialMgr
.SendFriendStatus(GetPlayer(), FRIEND_REMOVED
, GUID_LOPART(FriendGUID
), false);
538 sLog
.outDebug( "WORLD: Sent motd (SMSG_FRIEND_STATUS)" );
541 void WorldSession::HandleAddIgnoreOpcode( WorldPacket
& recv_data
)
543 CHECK_PACKET_SIZE(recv_data
,1);
545 sLog
.outDebug( "WORLD: Received CMSG_ADD_IGNORE" );
547 std::string IgnoreName
= GetMangosString(LANG_FRIEND_IGNORE_UNKNOWN
);
549 recv_data
>> IgnoreName
;
551 if(!normalizePlayerName(IgnoreName
))
554 CharacterDatabase
.escape_string(IgnoreName
); // prevent SQL injection - normal name don't must changed by this call
556 sLog
.outDebug( "WORLD: %s asked to Ignore: '%s'",
557 GetPlayer()->GetName(), IgnoreName
.c_str() );
559 CharacterDatabase
.AsyncPQuery(&WorldSession::HandleAddIgnoreOpcodeCallBack
, GetAccountId(), "SELECT guid FROM characters WHERE name = '%s'", IgnoreName
.c_str());
562 void WorldSession::HandleAddIgnoreOpcodeCallBack(QueryResult
*result
, uint32 accountId
)
567 uint64 IgnoreGuid
= MAKE_NEW_GUID((*result
)[0].GetUInt32(), 0, HIGHGUID_PLAYER
);
571 WorldSession
* session
= sWorld
.FindSession(accountId
);
572 if(!session
|| !session
->GetPlayer())
575 FriendsResult ignoreResult
= FRIEND_IGNORE_NOT_FOUND
;
578 if(IgnoreGuid
==session
->GetPlayer()->GetGUID()) //not add yourself
579 ignoreResult
= FRIEND_IGNORE_SELF
;
580 else if( session
->GetPlayer()->GetSocial()->HasIgnore(GUID_LOPART(IgnoreGuid
)) )
581 ignoreResult
= FRIEND_IGNORE_ALREADY
;
584 ignoreResult
= FRIEND_IGNORE_ADDED
;
587 if(!session
->GetPlayer()->GetSocial()->AddToSocialList(GUID_LOPART(IgnoreGuid
), true))
588 ignoreResult
= FRIEND_IGNORE_FULL
;
592 sSocialMgr
.SendFriendStatus(session
->GetPlayer(), ignoreResult
, GUID_LOPART(IgnoreGuid
), false);
594 sLog
.outDebug( "WORLD: Sent (SMSG_FRIEND_STATUS)" );
597 void WorldSession::HandleDelIgnoreOpcode( WorldPacket
& recv_data
)
599 CHECK_PACKET_SIZE(recv_data
, 8);
603 sLog
.outDebug( "WORLD: Received CMSG_DEL_IGNORE" );
605 recv_data
>> IgnoreGUID
;
607 _player
->GetSocial()->RemoveFromSocialList(GUID_LOPART(IgnoreGUID
), true);
609 sSocialMgr
.SendFriendStatus(GetPlayer(), FRIEND_IGNORE_REMOVED
, GUID_LOPART(IgnoreGUID
), false);
611 sLog
.outDebug( "WORLD: Sent motd (SMSG_FRIEND_STATUS)" );
614 void WorldSession::HandleSetContactNotesOpcode( WorldPacket
& recv_data
)
616 CHECK_PACKET_SIZE(recv_data
, 8+1);
617 sLog
.outDebug("CMSG_SET_CONTACT_NOTES");
620 recv_data
>> guid
>> note
;
621 _player
->GetSocial()->SetFriendNote(guid
, note
);
624 void WorldSession::HandleBugOpcode( WorldPacket
& recv_data
)
626 CHECK_PACKET_SIZE(recv_data
,4+4+1+4+1);
628 uint32 suggestion
, contentlen
;
633 recv_data
>> suggestion
>> contentlen
>> content
;
636 CHECK_PACKET_SIZE(recv_data
,4+4+(content
.size()+1)+4+1);
638 recv_data
>> typelen
>> type
;
640 if( suggestion
== 0 )
641 sLog
.outDebug( "WORLD: Received CMSG_BUG [Bug Report]" );
643 sLog
.outDebug( "WORLD: Received CMSG_BUG [Suggestion]" );
645 sLog
.outDebug( type
.c_str( ) );
646 sLog
.outDebug( content
.c_str( ) );
648 CharacterDatabase
.escape_string(type
);
649 CharacterDatabase
.escape_string(content
);
650 CharacterDatabase
.PExecute ("INSERT INTO bugreport (type,content) VALUES('%s', '%s')", type
.c_str( ), content
.c_str( ));
653 void WorldSession::HandleReclaimCorpseOpcode(WorldPacket
&recv_data
)
655 CHECK_PACKET_SIZE(recv_data
,8);
657 sLog
.outDetail("WORLD: Received CMSG_RECLAIM_CORPSE");
658 if (GetPlayer()->isAlive())
661 // do not allow corpse reclaim in arena
662 if (GetPlayer()->InArena())
665 // body not released yet
666 if(!GetPlayer()->HasFlag(PLAYER_FLAGS
, PLAYER_FLAGS_GHOST
))
669 Corpse
*corpse
= GetPlayer()->GetCorpse();
674 // prevent resurrect before 30-sec delay after body release not finished
675 if(corpse
->GetGhostTime() + GetPlayer()->GetCorpseReclaimDelay(corpse
->GetType()==CORPSE_RESURRECTABLE_PVP
) > time(NULL
))
678 float dist
= corpse
->GetDistance2d(GetPlayer());
679 sLog
.outDebug("Corpse 2D Distance: \t%f",dist
);
680 if (dist
> CORPSE_RECLAIM_RADIUS
)
687 GetPlayer()->ResurrectPlayer(GetPlayer()->InBattleGround() ? 1.0f
: 0.5f
);
690 GetPlayer()->SpawnCorpseBones();
692 GetPlayer()->SaveToDB();
695 void WorldSession::HandleResurrectResponseOpcode(WorldPacket
& recv_data
)
697 CHECK_PACKET_SIZE(recv_data
,8+1);
699 sLog
.outDetail("WORLD: Received CMSG_RESURRECT_RESPONSE");
701 if(GetPlayer()->isAlive())
711 GetPlayer()->clearResurrectRequestData(); // reject
715 if(!GetPlayer()->isRessurectRequestedBy(guid
))
718 GetPlayer()->ResurectUsingRequestData();
719 GetPlayer()->SaveToDB();
722 void WorldSession::HandleAreaTriggerOpcode(WorldPacket
& recv_data
)
724 CHECK_PACKET_SIZE(recv_data
,4);
726 sLog
.outDebug("WORLD: Received CMSG_AREATRIGGER");
730 recv_data
>> Trigger_ID
;
731 sLog
.outDebug("Trigger ID:%u",Trigger_ID
);
733 if(GetPlayer()->isInFlight())
735 sLog
.outDebug("Player '%s' (GUID: %u) in flight, ignore Area Trigger ID:%u",GetPlayer()->GetName(),GetPlayer()->GetGUIDLow(), Trigger_ID
);
739 AreaTriggerEntry
const* atEntry
= sAreaTriggerStore
.LookupEntry(Trigger_ID
);
742 sLog
.outDebug("Player '%s' (GUID: %u) send unknown (by DBC) Area Trigger ID:%u",GetPlayer()->GetName(),GetPlayer()->GetGUIDLow(), Trigger_ID
);
746 if (GetPlayer()->GetMapId()!=atEntry
->mapid
)
748 sLog
.outDebug("Player '%s' (GUID: %u) too far (trigger map: %u player map: %u), ignore Area Trigger ID: %u", GetPlayer()->GetName(), atEntry
->mapid
, GetPlayer()->GetMapId(), GetPlayer()->GetGUIDLow(), Trigger_ID
);
752 // delta is safe radius
753 const float delta
= 5.0f
;
754 // check if player in the range of areatrigger
755 Player
* pl
= GetPlayer();
757 if (atEntry
->radius
> 0)
759 // if we have radius check it
760 float dist
= pl
->GetDistance(atEntry
->x
,atEntry
->y
,atEntry
->z
);
761 if(dist
> atEntry
->radius
+ delta
)
763 sLog
.outDebug("Player '%s' (GUID: %u) too far (radius: %f distance: %f), ignore Area Trigger ID: %u",
764 pl
->GetName(), pl
->GetGUIDLow(), atEntry
->radius
, dist
, Trigger_ID
);
770 // we have only extent
771 float dx
= pl
->GetPositionX() - atEntry
->x
;
772 float dy
= pl
->GetPositionY() - atEntry
->y
;
773 float dz
= pl
->GetPositionZ() - atEntry
->z
;
774 double es
= sin(atEntry
->box_orientation
);
775 double ec
= cos(atEntry
->box_orientation
);
776 // calc rotated vector based on extent axis
777 double rotateDx
= dx
*ec
- dy
*es
;
778 double rotateDy
= dx
*es
+ dy
*ec
;
780 if( (fabs(rotateDx
) > atEntry
->box_x
/2 + delta
) ||
781 (fabs(rotateDy
) > atEntry
->box_y
/2 + delta
) ||
782 (fabs(dz
) > atEntry
->box_z
/2 + delta
) )
784 sLog
.outDebug("Player '%s' (GUID: %u) too far (1/2 box X: %f 1/2 box Y: %f 1/2 box Z: %f rotate dX: %f rotate dY: %f dZ:%f), ignore Area Trigger ID: %u",
785 pl
->GetName(), pl
->GetGUIDLow(), atEntry
->box_x
/2, atEntry
->box_y
/2, atEntry
->box_z
/2, rotateDx
, rotateDy
, dz
, Trigger_ID
);
790 if(Script
->scriptAreaTrigger(GetPlayer(), atEntry
))
793 uint32 quest_id
= objmgr
.GetQuestForAreaTrigger( Trigger_ID
);
794 if( quest_id
&& GetPlayer()->isAlive() && GetPlayer()->IsActiveQuest(quest_id
) )
796 Quest
const* pQuest
= objmgr
.GetQuestTemplate(quest_id
);
799 if(GetPlayer()->GetQuestStatus(quest_id
) == QUEST_STATUS_INCOMPLETE
)
800 GetPlayer()->AreaExploredOrEventHappens( quest_id
);
804 if(objmgr
.IsTavernAreaTrigger(Trigger_ID
))
806 // set resting flag we are in the inn
807 GetPlayer()->SetFlag(PLAYER_FLAGS
, PLAYER_FLAGS_RESTING
);
808 GetPlayer()->InnEnter(time(NULL
), atEntry
->mapid
, atEntry
->x
, atEntry
->y
, atEntry
->z
);
809 GetPlayer()->SetRestType(REST_TYPE_IN_TAVERN
);
811 if(sWorld
.IsFFAPvPRealm())
812 GetPlayer()->RemoveByteFlag(UNIT_FIELD_BYTES_2
, 1, UNIT_BYTE2_FLAG_FFA_PVP
);
817 if(GetPlayer()->InBattleGround())
819 BattleGround
* bg
= GetPlayer()->GetBattleGround();
821 if(bg
->GetStatus() == STATUS_IN_PROGRESS
)
822 bg
->HandleAreaTrigger(GetPlayer(), Trigger_ID
);
827 // NULL if all values default (non teleport trigger)
828 AreaTrigger
const* at
= objmgr
.GetAreaTrigger(Trigger_ID
);
832 if(!GetPlayer()->isGameMaster())
834 uint32 missingLevel
= 0;
835 if(GetPlayer()->getLevel() < at
->requiredLevel
&& !sWorld
.getConfig(CONFIG_INSTANCE_IGNORE_LEVEL
))
836 missingLevel
= at
->requiredLevel
;
838 // must have one or the other, report the first one that's missing
839 uint32 missingItem
= 0;
842 if(!GetPlayer()->HasItemCount(at
->requiredItem
, 1) &&
843 (!at
->requiredItem2
|| !GetPlayer()->HasItemCount(at
->requiredItem2
, 1)))
844 missingItem
= at
->requiredItem
;
846 else if(at
->requiredItem2
&& !GetPlayer()->HasItemCount(at
->requiredItem2
, 1))
847 missingItem
= at
->requiredItem2
;
849 uint32 missingKey
= 0;
850 if(GetPlayer()->GetDifficulty() == DIFFICULTY_HEROIC
)
854 if(!GetPlayer()->HasItemCount(at
->heroicKey
, 1) &&
855 (!at
->heroicKey2
|| !GetPlayer()->HasItemCount(at
->heroicKey2
, 1)))
856 missingKey
= at
->heroicKey
;
858 else if(at
->heroicKey2
&& !GetPlayer()->HasItemCount(at
->heroicKey2
, 1))
859 missingKey
= at
->heroicKey2
;
862 uint32 missingQuest
= 0;
863 if(GetPlayer()->GetDifficulty() == DIFFICULTY_HEROIC
)
865 if (at
->requiredQuestHeroic
&& !GetPlayer()->GetQuestRewardStatus(at
->requiredQuestHeroic
))
866 missingQuest
= at
->requiredQuestHeroic
;
870 if(at
->requiredQuest
&& !GetPlayer()->GetQuestRewardStatus(at
->requiredQuest
))
871 missingQuest
= at
->requiredQuest
;
874 if(missingLevel
|| missingItem
|| missingKey
|| missingQuest
)
876 // TODO: all this is probably wrong
878 SendAreaTriggerMessage(GetMangosString(LANG_LEVEL_MINREQUIRED_AND_ITEM
), at
->requiredLevel
, objmgr
.GetItemPrototype(missingItem
)->Name1
);
880 GetPlayer()->SendTransferAborted(at
->target_mapId
, TRANSFER_ABORT_DIFFICULTY
, DIFFICULTY_HEROIC
);
881 else if(missingQuest
)
882 SendAreaTriggerMessage(at
->requiredFailedText
.c_str());
883 else if(missingLevel
)
884 SendAreaTriggerMessage(GetMangosString(LANG_LEVEL_MINREQUIRED
), missingLevel
);
889 GetPlayer()->TeleportTo(at
->target_mapId
,at
->target_X
,at
->target_Y
,at
->target_Z
,at
->target_Orientation
,TELE_TO_NOT_LEAVE_TRANSPORT
);
892 void WorldSession::HandleUpdateAccountData(WorldPacket
&recv_data
)
894 sLog
.outDetail("WORLD: Received CMSG_UPDATE_ACCOUNT_DATA");
896 CHECK_PACKET_SIZE(recv_data
, 4+4+4);
898 uint32 type
, timestamp
, decompressedSize
;
899 recv_data
>> type
>> timestamp
>> decompressedSize
;
901 sLog
.outDebug("UAD: type %u, time %u, decompressedSize %u", type
, timestamp
, decompressedSize
);
903 if(type
> NUM_ACCOUNT_DATA_TYPES
)
906 if(decompressedSize
== 0) // erase
908 SetAccountData(type
, 0, "");
910 WorldPacket
data(SMSG_UPDATE_ACCOUNT_DATA_COMPLETE
, 4+4);
911 data
<< uint32(type
);
918 if(decompressedSize
> 0xFFFF)
920 sLog
.outError("UAD: Account data packet too big, size %u", decompressedSize
);
925 dest
.resize(decompressedSize
);
927 uLongf realSize
= decompressedSize
;
928 if(uncompress(const_cast<uint8
*>(dest
.contents()), &realSize
, const_cast<uint8
*>(recv_data
.contents() + recv_data
.rpos()), recv_data
.size() - recv_data
.rpos()) != Z_OK
)
930 sLog
.outError("UAD: Failed to decompress account data");
937 SetAccountData(type
, timestamp
, adata
);
939 WorldPacket
data(SMSG_UPDATE_ACCOUNT_DATA_COMPLETE
, 4+4);
940 data
<< uint32(type
);
945 void WorldSession::HandleRequestAccountData(WorldPacket
& recv_data
)
947 sLog
.outDetail("WORLD: Received CMSG_REQUEST_ACCOUNT_DATA");
949 CHECK_PACKET_SIZE(recv_data
, 4);
954 sLog
.outDebug("RAD: type %u", type
);
956 if(type
> NUM_ACCOUNT_DATA_TYPES
)
959 AccountData
*adata
= GetAccountData(type
);
961 uint32 size
= adata
->Data
.size();
966 uLongf destSize
= size
;
967 if(size
&& compress(const_cast<uint8
*>(dest
.contents()), &destSize
, (uint8
*)adata
->Data
.c_str(), size
) != Z_OK
)
969 sLog
.outDebug("RAD: Failed to compress account data");
973 dest
.resize(destSize
);
975 WorldPacket
data (SMSG_UPDATE_ACCOUNT_DATA
, 8+4+4+4+destSize
);
976 data
<< uint64(_player
->GetGUID()); // player guid
977 data
<< uint32(type
); // type (0-7)
978 data
<< uint32(adata
->Time
); // unix time
979 data
<< uint32(size
); // decompressed length
980 data
.append(dest
); // compressed data
984 void WorldSession::HandleSetActionButtonOpcode(WorldPacket
& recv_data
)
986 CHECK_PACKET_SIZE(recv_data
,1+2+1+1);
988 sLog
.outDebug( "WORLD: Received CMSG_SET_ACTION_BUTTON" );
989 uint8 button
, misc
, type
;
991 recv_data
>> button
>> action
>> misc
>> type
;
992 sLog
.outDetail( "BUTTON: %u ACTION: %u TYPE: %u MISC: %u", button
, action
, type
, misc
);
995 sLog
.outDetail( "MISC: Remove action from button %u", button
);
997 GetPlayer()->removeActionButton(button
);
1001 if(type
==ACTION_BUTTON_MACRO
|| type
==ACTION_BUTTON_CMACRO
)
1003 sLog
.outDetail( "MISC: Added Macro %u into button %u", action
, button
);
1004 GetPlayer()->addActionButton(button
,action
,type
,misc
);
1006 else if(type
==ACTION_BUTTON_EQSET
)
1008 sLog
.outDetail( "MISC: Added EquipmentSet %u into button %u", action
, button
);
1009 GetPlayer()->addActionButton(button
,action
,type
,misc
);
1011 else if(type
==ACTION_BUTTON_SPELL
)
1013 sLog
.outDetail( "MISC: Added Spell %u into button %u", action
, button
);
1014 GetPlayer()->addActionButton(button
,action
,type
,misc
);
1016 else if(type
==ACTION_BUTTON_ITEM
)
1018 sLog
.outDetail( "MISC: Added Item %u into button %u", action
, button
);
1019 GetPlayer()->addActionButton(button
,action
,type
,misc
);
1022 sLog
.outError( "MISC: Unknown action button type %u for action %u into button %u", type
, action
, button
);
1026 void WorldSession::HandleCompleteCinematic( WorldPacket
& /*recv_data*/ )
1028 DEBUG_LOG( "WORLD: Player is watching cinema" );
1031 void WorldSession::HandleNextCinematicCamera( WorldPacket
& /*recv_data*/ )
1033 DEBUG_LOG( "WORLD: Which movie to play" );
1036 void WorldSession::HandleMoveTimeSkippedOpcode( WorldPacket
& /*recv_data*/ )
1038 /* WorldSession::Update( getMSTime() );*/
1039 DEBUG_LOG( "WORLD: Time Lag/Synchronization Resent/Update" );
1042 CHECK_PACKET_SIZE(recv_data,8+4);
1044 uint32 time_skipped;
1046 recv_data >> time_skipped;
1047 sLog.outDebug( "WORLD: CMSG_MOVE_TIME_SKIPPED" );
1050 must be need use in mangos
1051 We substract server Lags to move time ( AntiLags )
1053 GetPlayer()->ModifyLastMoveTime( -int32(time_skipped) );
1057 void WorldSession::HandleFeatherFallAck(WorldPacket
&/*recv_data*/)
1059 DEBUG_LOG("WORLD: CMSG_MOVE_FEATHER_FALL_ACK");
1062 void WorldSession::HandleMoveUnRootAck(WorldPacket
&/* recv_data*/)
1065 CHECK_PACKET_SIZE(recv_data,8+8+4+4+4+4+4);
1067 sLog.outDebug( "WORLD: CMSG_FORCE_MOVE_UNROOT_ACK" );
1068 recv_data.hexlike();
1078 recv_data >> unknown1;
1079 recv_data >> unknown2;
1080 recv_data >> PositionX;
1081 recv_data >> PositionY;
1082 recv_data >> PositionZ;
1083 recv_data >> Orientation;
1085 // TODO for later may be we can use for anticheat
1086 DEBUG_LOG("Guid " I64FMTD,guid);
1087 DEBUG_LOG("unknown1 " I64FMTD,unknown1);
1088 DEBUG_LOG("unknown2 %u",unknown2);
1089 DEBUG_LOG("X %f",PositionX);
1090 DEBUG_LOG("Y %f",PositionY);
1091 DEBUG_LOG("Z %f",PositionZ);
1092 DEBUG_LOG("O %f",Orientation);
1096 void WorldSession::HandleMoveRootAck(WorldPacket
&/* recv_data*/)
1099 CHECK_PACKET_SIZE(recv_data,8+8+4+4+4+4+4);
1101 sLog.outDebug( "WORLD: CMSG_FORCE_MOVE_ROOT_ACK" );
1102 recv_data.hexlike();
1112 recv_data >> unknown1;
1113 recv_data >> unknown2;
1114 recv_data >> PositionX;
1115 recv_data >> PositionY;
1116 recv_data >> PositionZ;
1117 recv_data >> Orientation;
1119 // for later may be we can use for anticheat
1120 DEBUG_LOG("Guid " I64FMTD,guid);
1121 DEBUG_LOG("unknown1 " I64FMTD,unknown1);
1122 DEBUG_LOG("unknown1 %u",unknown2);
1123 DEBUG_LOG("X %f",PositionX);
1124 DEBUG_LOG("Y %f",PositionY);
1125 DEBUG_LOG("Z %f",PositionZ);
1126 DEBUG_LOG("O %f",Orientation);
1130 void WorldSession::HandleSetActionBarToggles(WorldPacket
& recv_data
)
1132 CHECK_PACKET_SIZE(recv_data
,1);
1136 recv_data
>> ActionBar
;
1138 if(!GetPlayer()) // ignore until not logged (check needed because STATUS_AUTHED)
1141 sLog
.outError("WorldSession::HandleSetActionBarToggles in not logged state with value: %u, ignored",uint32(ActionBar
));
1145 GetPlayer()->SetByteValue(PLAYER_FIELD_BYTES
, 2, ActionBar
);
1148 void WorldSession::HandleWardenDataOpcode(WorldPacket
& /*recv_data*/)
1151 CHECK_PACKET_SIZE(recv_data,1);
1155 sLog.outDebug("Received opcode CMSG_WARDEN_DATA, not resolve.uint8 = %u",tmp);
1159 void WorldSession::HandlePlayedTime(WorldPacket
& /*recv_data*/)
1161 uint32 TotalTimePlayed
= GetPlayer()->GetTotalPlayedTime();
1162 uint32 LevelPlayedTime
= GetPlayer()->GetLevelPlayedTime();
1164 WorldPacket
data(SMSG_PLAYED_TIME
, 9);
1165 data
<< TotalTimePlayed
;
1166 data
<< LevelPlayedTime
;
1171 void WorldSession::HandleInspectOpcode(WorldPacket
& recv_data
)
1173 CHECK_PACKET_SIZE(recv_data
, 8);
1177 DEBUG_LOG("Inspected guid is " I64FMTD
, guid
);
1179 _player
->SetSelection(guid
);
1181 Player
*plr
= objmgr
.GetPlayer(guid
);
1182 if(!plr
) // wrong player
1185 WorldPacket
data(SMSG_INSPECT_TALENT
, 50);
1186 data
.append(plr
->GetPackGUID());
1188 if(sWorld
.getConfig(CONFIG_TALENTS_INSPECTING
) || _player
->isGameMaster())
1190 plr
->BuildPlayerTalentsInfoData(&data
);
1191 plr
->BuildEnchantmentsInfoData(&data
);
1195 data
<< uint32(0); // unspentTalentPoints
1196 data
<< uint8(0); // talentGroupCount
1197 data
<< uint8(0); // talentGroupIndex
1198 data
<< uint32(0); // slotUsedMask
1204 void WorldSession::HandleInspectHonorStatsOpcode(WorldPacket
& recv_data
)
1206 CHECK_PACKET_SIZE(recv_data
, 8);
1211 Player
*player
= objmgr
.GetPlayer(guid
);
1215 sLog
.outError("InspectHonorStats: WTF, player not found...");
1219 WorldPacket
data(MSG_INSPECT_HONOR_STATS
, 8+1+4*4);
1220 data
<< uint64(player
->GetGUID());
1221 data
<< uint8(player
->GetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY
));
1222 data
<< uint32(player
->GetUInt32Value(PLAYER_FIELD_KILLS
));
1223 data
<< uint32(player
->GetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION
));
1224 data
<< uint32(player
->GetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION
));
1225 data
<< uint32(player
->GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORBALE_KILLS
));
1229 void WorldSession::HandleWorldTeleportOpcode(WorldPacket
& recv_data
)
1231 CHECK_PACKET_SIZE(recv_data
,4+4+4+4+4+4);
1233 // write in client console: worldport 469 452 6454 2536 180 or /console worldport 469 452 6454 2536 180
1234 // Received opcode CMSG_WORLD_TELEPORT
1235 // Time is ***, map=469, x=452.000000, y=6454.000000, z=2536.000000, orient=3.141593
1237 //sLog.outDebug("Received opcode CMSG_WORLD_TELEPORT");
1239 if(GetPlayer()->isInFlight())
1241 sLog
.outDebug("Player '%s' (GUID: %u) in flight, ignore worldport command.",GetPlayer()->GetName(),GetPlayer()->GetGUIDLow());
1252 recv_data
>> time
; // time in m.sec.
1254 recv_data
>> PositionX
;
1255 recv_data
>> PositionY
;
1256 recv_data
>> PositionZ
;
1257 recv_data
>> Orientation
; // o (3.141593 = 180 degrees)
1258 DEBUG_LOG("Time %u sec, map=%u, x=%f, y=%f, z=%f, orient=%f", time
/1000, mapid
, PositionX
, PositionY
, PositionZ
, Orientation
);
1260 if (GetSecurity() >= SEC_ADMINISTRATOR
)
1261 GetPlayer()->TeleportTo(mapid
,PositionX
,PositionY
,PositionZ
,Orientation
);
1263 SendNotification(LANG_YOU_NOT_HAVE_PERMISSION
);
1264 sLog
.outDebug("Received worldport command from player %s", GetPlayer()->GetName());
1267 void WorldSession::HandleWhoisOpcode(WorldPacket
& recv_data
)
1269 CHECK_PACKET_SIZE(recv_data
, 1);
1271 sLog
.outDebug("Received opcode CMSG_WHOIS");
1272 std::string charname
;
1273 recv_data
>> charname
;
1275 if (GetSecurity() < SEC_ADMINISTRATOR
)
1277 SendNotification(LANG_YOU_NOT_HAVE_PERMISSION
);
1281 if(charname
.empty() || !normalizePlayerName (charname
))
1283 SendNotification(LANG_NEED_CHARACTER_NAME
);
1287 Player
*plr
= objmgr
.GetPlayer(charname
.c_str());
1291 SendNotification(LANG_PLAYER_NOT_EXIST_OR_OFFLINE
, charname
.c_str());
1295 uint32 accid
= plr
->GetSession()->GetAccountId();
1297 QueryResult
*result
= loginDatabase
.PQuery("SELECT username,email,last_ip FROM account WHERE id=%u", accid
);
1300 SendNotification(LANG_ACCOUNT_FOR_PLAYER_NOT_FOUND
, charname
.c_str());
1304 Field
*fields
= result
->Fetch();
1305 std::string acc
= fields
[0].GetCppString();
1308 std::string email
= fields
[1].GetCppString();
1311 std::string lastip
= fields
[2].GetCppString();
1315 std::string msg
= charname
+ "'s " + "account is " + acc
+ ", e-mail: " + email
+ ", last ip: " + lastip
;
1317 WorldPacket
data(SMSG_WHOIS
, msg
.size()+1);
1319 _player
->GetSession()->SendPacket(&data
);
1323 sLog
.outDebug("Received whois command from player %s for character %s", GetPlayer()->GetName(), charname
.c_str());
1326 void WorldSession::HandleComplainOpcode( WorldPacket
& recv_data
)
1328 CHECK_PACKET_SIZE(recv_data
, 1+8);
1329 sLog
.outDebug("WORLD: CMSG_COMPLAIN");
1330 recv_data
.hexlike();
1332 uint8 spam_type
; // 0 - mail, 1 - chat
1333 uint64 spammer_guid
;
1338 std::string description
= "";
1339 recv_data
>> spam_type
; // unk 0x01 const, may be spam type (mail/chat)
1340 recv_data
>> spammer_guid
; // player guid
1344 CHECK_PACKET_SIZE(recv_data
, recv_data
.rpos()+4+4+4);
1345 recv_data
>> unk1
; // const 0
1346 recv_data
>> unk2
; // probably mail id
1347 recv_data
>> unk3
; // const 0
1350 CHECK_PACKET_SIZE(recv_data
, recv_data
.rpos()+4+4+4+4+1);
1351 recv_data
>> unk1
; // probably language
1352 recv_data
>> unk2
; // message type?
1353 recv_data
>> unk3
; // probably channel id
1354 recv_data
>> unk4
; // unk random value
1355 recv_data
>> description
; // spam description string (messagetype, channel name, player name, message)
1359 // NOTE: all chat messages from this spammer automatically ignored by spam reporter until logout in case chat spam.
1360 // if it's mail spam - ALL mails from this spammer automatically removed by client
1362 // Complaint Received message
1363 WorldPacket
data(SMSG_COMPLAIN_RESULT
, 1);
1367 sLog
.outDebug("REPORT SPAM: type %u, guid %u, unk1 %u, unk2 %u, unk3 %u, unk4 %u, message %s", spam_type
, GUID_LOPART(spammer_guid
), unk1
, unk2
, unk3
, unk4
, description
.c_str());
1370 void WorldSession::HandleRealmSplitOpcode( WorldPacket
& recv_data
)
1372 CHECK_PACKET_SIZE(recv_data
, 4);
1374 sLog
.outDebug("CMSG_REALM_SPLIT");
1377 std::string split_date
= "01/01/01";
1380 WorldPacket
data(SMSG_REALM_SPLIT
, 4+4+split_date
.size()+1);
1382 data
<< uint32(0x00000000); // realm split state
1386 // 0x2 realm split pending
1389 //sLog.outDebug("response sent %u", unk);
1392 void WorldSession::HandleFarSightOpcode( WorldPacket
& recv_data
)
1394 CHECK_PACKET_SIZE(recv_data
, 1);
1396 sLog
.outDebug("WORLD: CMSG_FAR_SIGHT");
1397 //recv_data.hexlike();
1405 //WorldPacket data(SMSG_CLEAR_FAR_SIGHT_IMMEDIATE, 0)
1406 //SendPacket(&data);
1407 //_player->SetUInt64Value(PLAYER_FARSIGHT, 0);
1408 sLog
.outDebug("Removed FarSight from player %u", _player
->GetGUIDLow());
1411 sLog
.outDebug("Added FarSight " I64FMT
" to player %u", _player
->GetFarSight(), _player
->GetGUIDLow());
1416 void WorldSession::HandleSetTitleOpcode( WorldPacket
& recv_data
)
1418 CHECK_PACKET_SIZE(recv_data
, 4);
1420 sLog
.outDebug("CMSG_SET_TITLE");
1426 if(title
> 0 && title
< 192)
1428 if(!GetPlayer()->HasTitle(title
))
1434 GetPlayer()->SetUInt32Value(PLAYER_CHOSEN_TITLE
, title
);
1437 void WorldSession::HandleTimeSyncResp( WorldPacket
& recv_data
)
1439 CHECK_PACKET_SIZE(recv_data
, 4+4);
1441 sLog
.outDebug("CMSG_TIME_SYNC_RESP");
1443 uint32 counter
, time_
;
1444 recv_data
>> counter
>> time_
;
1446 // time_ seems always more than getMSTime()
1447 uint32 diff
= getMSTimeDiff(getMSTime(),time_
);
1449 sLog
.outDebug("response sent: counter %u, time %u (HEX: %X), ms. time %u, diff %u", counter
, time_
, time_
, getMSTime(), diff
);
1452 void WorldSession::HandleResetInstancesOpcode( WorldPacket
& /*recv_data*/ )
1454 sLog
.outDebug("WORLD: CMSG_RESET_INSTANCES");
1455 Group
*pGroup
= _player
->GetGroup();
1458 if(pGroup
->IsLeader(_player
->GetGUID()))
1459 pGroup
->ResetInstances(INSTANCE_RESET_ALL
, _player
);
1462 _player
->ResetInstances(INSTANCE_RESET_ALL
);
1465 void WorldSession::HandleSetDungeonDifficultyOpcode( WorldPacket
& recv_data
)
1467 CHECK_PACKET_SIZE(recv_data
, 4);
1469 sLog
.outDebug("MSG_SET_DUNGEON_DIFFICULTY");
1474 if(mode
== _player
->GetDifficulty())
1477 if(mode
> DIFFICULTY_HEROIC
)
1479 sLog
.outError("WorldSession::HandleSetDungeonDifficultyOpcode: player %d sent an invalid instance mode %d!", _player
->GetGUIDLow(), mode
);
1483 // cannot reset while in an instance
1484 Map
*map
= _player
->GetMap();
1485 if(map
&& map
->IsDungeon())
1487 sLog
.outError("WorldSession::HandleSetDungeonDifficultyOpcode: player %d tried to reset the instance while inside!", _player
->GetGUIDLow());
1491 if(_player
->getLevel() < LEVELREQUIREMENT_HEROIC
)
1493 Group
*pGroup
= _player
->GetGroup();
1496 if(pGroup
->IsLeader(_player
->GetGUID()))
1498 // the difficulty is set even if the instances can't be reset
1499 //_player->SendDungeonDifficulty(true);
1500 pGroup
->ResetInstances(INSTANCE_RESET_CHANGE_DIFFICULTY
, _player
);
1501 pGroup
->SetDifficulty(mode
);
1506 _player
->ResetInstances(INSTANCE_RESET_CHANGE_DIFFICULTY
);
1507 _player
->SetDifficulty(mode
);
1511 void WorldSession::HandleCancelMountAuraOpcode( WorldPacket
& /*recv_data*/ )
1513 sLog
.outDebug("WORLD: CMSG_CANCEL_MOUNT_AURA");
1514 //recv_data.hexlike();
1516 //If player is not mounted, so go out :)
1517 if (!_player
->IsMounted()) // not blizz like; no any messages on blizz
1519 ChatHandler(this).SendSysMessage(LANG_CHAR_NON_MOUNTED
);
1523 if(_player
->isInFlight()) // not blizz like; no any messages on blizz
1525 ChatHandler(this).SendSysMessage(LANG_YOU_IN_FLIGHT
);
1530 _player
->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED
);
1533 void WorldSession::HandleMoveSetCanFlyAckOpcode( WorldPacket
& recv_data
)
1535 CHECK_PACKET_SIZE(recv_data
, 8+4+4);
1538 sLog
.outDebug("WORLD: CMSG_MOVE_SET_CAN_FLY_ACK");
1539 //recv_data.hexlike();
1545 recv_data
>> guid
>> unk
>> flags
;
1547 _player
->m_movementInfo
.flags
= flags
;
1550 void WorldSession::HandleRequestPetInfoOpcode( WorldPacket
& /*recv_data */)
1553 sLog.outDebug("WORLD: CMSG_REQUEST_PET_INFO");
1554 recv_data.hexlike();
1558 void WorldSession::HandleSetTaxiBenchmarkOpcode( WorldPacket
& recv_data
)
1560 CHECK_PACKET_SIZE(recv_data
, 1);
1565 sLog
.outDebug("Client used \"/timetest %d\" command", mode
);
1568 void WorldSession::HandleQueryInspectAchievements( WorldPacket
& recv_data
)
1570 CHECK_PACKET_SIZE(recv_data
, 1);
1572 if(!recv_data
.readPackGUID(guid
))
1575 Player
*player
= objmgr
.GetPlayer(guid
);
1579 player
->GetAchievementMgr().SendRespondInspectAchievements(_player
);