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 "ObjectDefines.h"
30 #include "WorldSession.h"
31 #include "Auth/BigNumber.h"
32 #include "Auth/Sha1.h"
33 #include "UpdateData.h"
36 #include "ScriptCalls.h"
37 #include <zlib/zlib.h>
38 #include "ObjectAccessor.h"
40 #include "BattleGround.h"
42 #include "SocialMgr.h"
45 void WorldSession::HandleRepopRequestOpcode( WorldPacket
& recv_data
)
47 sLog
.outDebug( "WORLD: Recvd CMSG_REPOP_REQUEST Message" );
49 recv_data
.read_skip
<uint8
>();
51 if(GetPlayer()->isAlive() || GetPlayer()->HasFlag(PLAYER_FLAGS
, PLAYER_FLAGS_GHOST
))
54 // the world update order is sessions, players, creatures
55 // the netcode runs in parallel with all of these
56 // creatures can kill players
57 // so if the server is lagging enough the player can
58 // release spirit after he's killed but before he is updated
59 if(GetPlayer()->getDeathState() == JUST_DIED
)
61 sLog
.outDebug("HandleRepopRequestOpcode: got request after player %s(%d) was killed and before he was updated", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow());
62 GetPlayer()->KillPlayer();
65 //this is spirit release confirm?
66 GetPlayer()->RemovePet(NULL
,PET_SAVE_NOT_IN_SLOT
, true);
67 GetPlayer()->BuildPlayerRepop();
68 GetPlayer()->RepopAtGraveyard();
71 void WorldSession::HandleWhoOpcode( WorldPacket
& recv_data
)
73 sLog
.outDebug( "WORLD: Recvd CMSG_WHO Message" );
74 //recv_data.hexlike();
76 uint32 clientcount
= 0;
78 uint32 level_min
, level_max
, racemask
, classmask
, zones_count
, str_count
;
79 uint32 zoneids
[10]; // 10 is client limit
80 std::string player_name
, guild_name
;
82 recv_data
>> level_min
; // maximal player level, default 0
83 recv_data
>> level_max
; // minimal player level, default 100 (MAX_LEVEL)
84 recv_data
>> player_name
; // player name, case sensitive...
86 recv_data
>> guild_name
; // guild name, case sensitive...
88 recv_data
>> racemask
; // race mask
89 recv_data
>> classmask
; // class mask
90 recv_data
>> zones_count
; // zones count, client limit=10 (2.0.10)
93 return; // can't be received from real client or broken packet
95 for(uint32 i
= 0; i
< zones_count
; ++i
)
98 recv_data
>> temp
; // zone id, 0 if zone is unknown...
100 sLog
.outDebug("Zone %u: %u", i
, zoneids
[i
]);
103 recv_data
>> str_count
; // user entered strings count, client limit=4 (checked on 2.0.10)
106 return; // can't be received from real client or broken packet
108 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
);
110 std::wstring str
[4]; // 4 is client limit
111 for(uint32 i
= 0; i
< str_count
; ++i
)
114 recv_data
>> temp
; // user entered string, it used as universal search pattern(guild+player name)?
116 if(!Utf8toWStr(temp
,str
[i
]))
121 sLog
.outDebug("String %u: %s", i
, temp
.c_str());
124 std::wstring wplayer_name
;
125 std::wstring wguild_name
;
126 if(!(Utf8toWStr(player_name
, wplayer_name
) && Utf8toWStr(guild_name
, wguild_name
)))
128 wstrToLower(wplayer_name
);
129 wstrToLower(wguild_name
);
131 // client send in case not set max level value 100 but mangos support 255 max level,
132 // update it to show GMs with characters after 100 level
133 if(level_max
>= MAX_LEVEL
)
134 level_max
= STRONG_MAX_LEVEL
;
136 uint32 team
= _player
->GetTeam();
137 uint32 security
= GetSecurity();
138 bool allowTwoSideWhoList
= sWorld
.getConfig(CONFIG_ALLOW_TWO_SIDE_WHO_LIST
);
139 AccountTypes gmLevelInWhoList
= (AccountTypes
)sWorld
.getConfig(CONFIG_GM_LEVEL_IN_WHO_LIST
);
141 WorldPacket
data( SMSG_WHO
, 50 ); // guess size
142 data
<< clientcount
; // clientcount place holder
143 data
<< clientcount
; // clientcount place holder
145 //TODO: Guard Player map
146 HashMapHolder
<Player
>::MapType
& m
= sObjectAccessor
.GetPlayers();
147 for(HashMapHolder
<Player
>::MapType::const_iterator itr
= m
.begin(); itr
!= m
.end(); ++itr
)
149 if (security
== SEC_PLAYER
)
151 // player can see member of other team only if CONFIG_ALLOW_TWO_SIDE_WHO_LIST
152 if (itr
->second
->GetTeam() != team
&& !allowTwoSideWhoList
)
155 // player can see MODERATOR, GAME MASTER, ADMINISTRATOR only if CONFIG_GM_IN_WHO_LIST
156 if (itr
->second
->GetSession()->GetSecurity() > gmLevelInWhoList
)
160 //do not process players which are not in world
161 if(!(itr
->second
->IsInWorld()))
164 // check if target is globally visible for player
165 if (!(itr
->second
->IsVisibleGloballyFor(_player
)))
168 // check if target's level is in level range
169 uint32 lvl
= itr
->second
->getLevel();
170 if (lvl
< level_min
|| lvl
> level_max
)
173 // check if class matches classmask
174 uint32 class_
= itr
->second
->getClass();
175 if (!(classmask
& (1 << class_
)))
178 // check if race matches racemask
179 uint32 race
= itr
->second
->getRace();
180 if (!(racemask
& (1 << race
)))
183 uint32 pzoneid
= itr
->second
->GetZoneId();
186 for(uint32 i
= 0; i
< zones_count
; ++i
)
188 if(zoneids
[i
] == pzoneid
)
199 std::string pname
= itr
->second
->GetName();
201 if(!Utf8toWStr(pname
,wpname
))
205 if (!(wplayer_name
.empty() || wpname
.find(wplayer_name
) != std::wstring::npos
))
208 std::string gname
= sObjectMgr
.GetGuildNameById(itr
->second
->GetGuildId());
210 if(!Utf8toWStr(gname
,wgname
))
214 if (!(wguild_name
.empty() || wgname
.find(wguild_name
) != std::wstring::npos
))
218 if(AreaTableEntry
const* areaEntry
= GetAreaEntryByAreaID(itr
->second
->GetZoneId()))
219 aname
= areaEntry
->area_name
[GetSessionDbcLocale()];
222 for(uint32 i
= 0; i
< str_count
; ++i
)
226 if (wgname
.find(str
[i
]) != std::wstring::npos
||
227 wpname
.find(str
[i
]) != std::wstring::npos
||
228 Utf8FitTo(aname
, str
[i
]) )
239 data
<< pname
; // player name
240 data
<< gname
; // guild name
241 data
<< uint32( lvl
); // player level
242 data
<< uint32( class_
); // player class
243 data
<< uint32( race
); // player race
244 data
<< uint8(0); // new 2.4.0
245 data
<< uint32( pzoneid
); // player zone id
247 // 49 is maximum player count sent to client
248 if ((++clientcount
) == 49)
252 data
.put( 0, clientcount
); // insert right count
253 data
.put( sizeof(uint32
), clientcount
); // insert right count
256 sLog
.outDebug( "WORLD: Send SMSG_WHO Message" );
259 void WorldSession::HandleLogoutRequestOpcode( WorldPacket
& /*recv_data*/ )
261 sLog
.outDebug( "WORLD: Recvd CMSG_LOGOUT_REQUEST Message, security - %u", GetSecurity() );
263 if (uint64 lguid
= GetPlayer()->GetLootGUID())
264 DoLootRelease(lguid
);
266 //Can not logout if...
267 if( GetPlayer()->isInCombat() || //...is in combat
268 GetPlayer()->duel
|| //...is in Duel
269 //...is jumping ...is falling
270 GetPlayer()->m_movementInfo
.HasMovementFlag(MovementFlags(MOVEMENTFLAG_JUMPING
| MOVEMENTFLAG_FALLING
)))
272 WorldPacket
data( SMSG_LOGOUT_RESPONSE
, (2+4) ) ;
281 //instant logout in taverns/cities or on taxi or for admins, gm's, mod's if its enabled in mangosd.conf
282 if (GetPlayer()->HasFlag(PLAYER_FLAGS
, PLAYER_FLAGS_RESTING
) || GetPlayer()->isInFlight() ||
283 GetSecurity() >= sWorld
.getConfig(CONFIG_INSTANT_LOGOUT
))
289 // not set flags if player can't free move to prevent lost state at logout cancel
290 if(GetPlayer()->CanFreeMove())
292 GetPlayer()->SetStandState(UNIT_STAND_STATE_SIT
);
294 WorldPacket
data( SMSG_FORCE_MOVE_ROOT
, (8+4) ); // guess size
295 data
.append(GetPlayer()->GetPackGUID());
298 GetPlayer()->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_STUNNED
);
301 WorldPacket
data( SMSG_LOGOUT_RESPONSE
, 5 );
305 LogoutRequest(time(NULL
));
308 void WorldSession::HandlePlayerLogoutOpcode( WorldPacket
& /*recv_data*/ )
310 sLog
.outDebug( "WORLD: Recvd CMSG_PLAYER_LOGOUT Message" );
313 void WorldSession::HandleLogoutCancelOpcode( WorldPacket
& /*recv_data*/ )
315 sLog
.outDebug( "WORLD: Recvd CMSG_LOGOUT_CANCEL Message" );
319 WorldPacket
data( SMSG_LOGOUT_CANCEL_ACK
, 0 );
322 // not remove flags if can't free move - its not set in Logout request code.
323 if(GetPlayer()->CanFreeMove())
326 data
.Initialize( SMSG_FORCE_MOVE_UNROOT
, 8 ); // guess size
327 data
.append(GetPlayer()->GetPackGUID());
332 GetPlayer()->SetStandState(UNIT_STAND_STATE_STAND
);
335 GetPlayer()->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_STUNNED
);
338 sLog
.outDebug( "WORLD: sent SMSG_LOGOUT_CANCEL_ACK Message" );
341 void WorldSession::HandleTogglePvP( WorldPacket
& recv_data
)
343 // this opcode can be used in two ways: Either set explicit new status or toggle old status
344 if(recv_data
.size() == 1)
347 recv_data
>> newPvPStatus
;
348 GetPlayer()->ApplyModFlag(PLAYER_FLAGS
, PLAYER_FLAGS_IN_PVP
, newPvPStatus
);
349 GetPlayer()->ApplyModFlag(PLAYER_FLAGS
, PLAYER_FLAGS_PVP_TIMER
, !newPvPStatus
);
353 GetPlayer()->ToggleFlag(PLAYER_FLAGS
, PLAYER_FLAGS_IN_PVP
);
354 GetPlayer()->ToggleFlag(PLAYER_FLAGS
, PLAYER_FLAGS_PVP_TIMER
);
357 if(GetPlayer()->HasFlag(PLAYER_FLAGS
, PLAYER_FLAGS_IN_PVP
))
359 if(!GetPlayer()->IsPvP() || GetPlayer()->pvpInfo
.endTimer
!= 0)
360 GetPlayer()->UpdatePvP(true, true);
364 if(!GetPlayer()->pvpInfo
.inHostileArea
&& GetPlayer()->IsPvP())
365 GetPlayer()->pvpInfo
.endTimer
= time(NULL
); // start toggle-off
369 void WorldSession::HandleZoneUpdateOpcode( WorldPacket
& recv_data
)
372 recv_data
>> newZone
;
374 sLog
.outDetail("WORLD: Recvd ZONE_UPDATE: %u", newZone
);
376 // use server size data
377 uint32 newzone
, newarea
;
378 GetPlayer()->GetZoneAndAreaId(newzone
, newarea
);
379 GetPlayer()->UpdateZone(newzone
, newarea
);
382 void WorldSession::HandleSetTargetOpcode( WorldPacket
& recv_data
)
384 // When this packet send?
388 _player
->SetTargetGUID(guid
);
390 // update reputation list if need
391 Unit
* unit
= ObjectAccessor::GetUnit(*_player
, guid
);
395 if(FactionTemplateEntry
const* factionTemplateEntry
= sFactionTemplateStore
.LookupEntry(unit
->getFaction()))
396 _player
->GetReputationMgr().SetVisible(factionTemplateEntry
);
399 void WorldSession::HandleSetSelectionOpcode( WorldPacket
& recv_data
)
404 _player
->SetSelection(guid
);
406 // update reputation list if need
407 Unit
* unit
= ObjectAccessor::GetUnit(*_player
, guid
);
411 if(FactionTemplateEntry
const* factionTemplateEntry
= sFactionTemplateStore
.LookupEntry(unit
->getFaction()))
412 _player
->GetReputationMgr().SetVisible(factionTemplateEntry
);
415 void WorldSession::HandleStandStateChangeOpcode( WorldPacket
& recv_data
)
417 // sLog.outDebug( "WORLD: Received CMSG_STANDSTATECHANGE" ); -- too many spam in log at lags/debug stop
419 recv_data
>> animstate
;
421 _player
->SetStandState(animstate
);
424 void WorldSession::HandleContactListOpcode( WorldPacket
& recv_data
)
426 sLog
.outDebug( "WORLD: Received CMSG_CONTACT_LIST" );
429 sLog
.outDebug("unk value is %u", unk
);
430 _player
->GetSocial()->SendSocialList();
433 void WorldSession::HandleAddFriendOpcode( WorldPacket
& recv_data
)
435 sLog
.outDebug( "WORLD: Received CMSG_ADD_FRIEND" );
437 std::string friendName
= GetMangosString(LANG_FRIEND_IGNORE_UNKNOWN
);
438 std::string friendNote
;
440 recv_data
>> friendName
;
442 recv_data
>> friendNote
;
444 if(!normalizePlayerName(friendName
))
447 CharacterDatabase
.escape_string(friendName
); // prevent SQL injection - normal name don't must changed by this call
449 sLog
.outDebug( "WORLD: %s asked to add friend : '%s'",
450 GetPlayer()->GetName(), friendName
.c_str() );
452 CharacterDatabase
.AsyncPQuery(&WorldSession::HandleAddFriendOpcodeCallBack
, GetAccountId(), friendNote
, "SELECT guid, race FROM characters WHERE name = '%s'", friendName
.c_str());
455 void WorldSession::HandleAddFriendOpcodeCallBack(QueryResult
*result
, uint32 accountId
, std::string friendNote
)
460 uint64 friendGuid
= MAKE_NEW_GUID((*result
)[0].GetUInt32(), 0, HIGHGUID_PLAYER
);
461 uint32 team
= Player::TeamForRace((*result
)[1].GetUInt8());
465 WorldSession
* session
= sWorld
.FindSession(accountId
);
466 if(!session
|| !session
->GetPlayer())
469 FriendsResult friendResult
= FRIEND_NOT_FOUND
;
472 if(friendGuid
==session
->GetPlayer()->GetGUID())
473 friendResult
= FRIEND_SELF
;
474 else if(session
->GetPlayer()->GetTeam() != team
&& !sWorld
.getConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND
) && session
->GetSecurity() < SEC_MODERATOR
)
475 friendResult
= FRIEND_ENEMY
;
476 else if(session
->GetPlayer()->GetSocial()->HasFriend(GUID_LOPART(friendGuid
)))
477 friendResult
= FRIEND_ALREADY
;
480 Player
* pFriend
= ObjectAccessor::FindPlayer(friendGuid
);
481 if( pFriend
&& pFriend
->IsInWorld() && pFriend
->IsVisibleGloballyFor(session
->GetPlayer()))
482 friendResult
= FRIEND_ADDED_ONLINE
;
484 friendResult
= FRIEND_ADDED_OFFLINE
;
486 if(!session
->GetPlayer()->GetSocial()->AddToSocialList(GUID_LOPART(friendGuid
), false))
488 friendResult
= FRIEND_LIST_FULL
;
489 sLog
.outDebug( "WORLD: %s's friend list is full.", session
->GetPlayer()->GetName());
492 session
->GetPlayer()->GetSocial()->SetFriendNote(GUID_LOPART(friendGuid
), friendNote
);
496 sSocialMgr
.SendFriendStatus(session
->GetPlayer(), friendResult
, GUID_LOPART(friendGuid
), false);
498 sLog
.outDebug( "WORLD: Sent (SMSG_FRIEND_STATUS)" );
501 void WorldSession::HandleDelFriendOpcode( WorldPacket
& recv_data
)
505 sLog
.outDebug( "WORLD: Received CMSG_DEL_FRIEND" );
507 recv_data
>> FriendGUID
;
509 _player
->GetSocial()->RemoveFromSocialList(GUID_LOPART(FriendGUID
), false);
511 sSocialMgr
.SendFriendStatus(GetPlayer(), FRIEND_REMOVED
, GUID_LOPART(FriendGUID
), false);
513 sLog
.outDebug( "WORLD: Sent motd (SMSG_FRIEND_STATUS)" );
516 void WorldSession::HandleAddIgnoreOpcode( WorldPacket
& recv_data
)
518 sLog
.outDebug( "WORLD: Received CMSG_ADD_IGNORE" );
520 std::string IgnoreName
= GetMangosString(LANG_FRIEND_IGNORE_UNKNOWN
);
522 recv_data
>> IgnoreName
;
524 if(!normalizePlayerName(IgnoreName
))
527 CharacterDatabase
.escape_string(IgnoreName
); // prevent SQL injection - normal name don't must changed by this call
529 sLog
.outDebug( "WORLD: %s asked to Ignore: '%s'",
530 GetPlayer()->GetName(), IgnoreName
.c_str() );
532 CharacterDatabase
.AsyncPQuery(&WorldSession::HandleAddIgnoreOpcodeCallBack
, GetAccountId(), "SELECT guid FROM characters WHERE name = '%s'", IgnoreName
.c_str());
535 void WorldSession::HandleAddIgnoreOpcodeCallBack(QueryResult
*result
, uint32 accountId
)
540 uint64 IgnoreGuid
= MAKE_NEW_GUID((*result
)[0].GetUInt32(), 0, HIGHGUID_PLAYER
);
544 WorldSession
* session
= sWorld
.FindSession(accountId
);
545 if(!session
|| !session
->GetPlayer())
548 FriendsResult ignoreResult
= FRIEND_IGNORE_NOT_FOUND
;
551 if(IgnoreGuid
== session
->GetPlayer()->GetGUID()) //not add yourself
552 ignoreResult
= FRIEND_IGNORE_SELF
;
553 else if( session
->GetPlayer()->GetSocial()->HasIgnore(GUID_LOPART(IgnoreGuid
)) )
554 ignoreResult
= FRIEND_IGNORE_ALREADY
;
557 ignoreResult
= FRIEND_IGNORE_ADDED
;
560 if(!session
->GetPlayer()->GetSocial()->AddToSocialList(GUID_LOPART(IgnoreGuid
), true))
561 ignoreResult
= FRIEND_IGNORE_FULL
;
565 sSocialMgr
.SendFriendStatus(session
->GetPlayer(), ignoreResult
, GUID_LOPART(IgnoreGuid
), false);
567 sLog
.outDebug( "WORLD: Sent (SMSG_FRIEND_STATUS)" );
570 void WorldSession::HandleDelIgnoreOpcode( WorldPacket
& recv_data
)
574 sLog
.outDebug( "WORLD: Received CMSG_DEL_IGNORE" );
576 recv_data
>> IgnoreGUID
;
578 _player
->GetSocial()->RemoveFromSocialList(GUID_LOPART(IgnoreGUID
), true);
580 sSocialMgr
.SendFriendStatus(GetPlayer(), FRIEND_IGNORE_REMOVED
, GUID_LOPART(IgnoreGUID
), false);
582 sLog
.outDebug( "WORLD: Sent motd (SMSG_FRIEND_STATUS)" );
585 void WorldSession::HandleSetContactNotesOpcode( WorldPacket
& recv_data
)
587 sLog
.outDebug("CMSG_SET_CONTACT_NOTES");
590 recv_data
>> guid
>> note
;
591 _player
->GetSocial()->SetFriendNote(guid
, note
);
594 void WorldSession::HandleBugOpcode( WorldPacket
& recv_data
)
596 uint32 suggestion
, contentlen
, typelen
;
597 std::string content
, type
;
599 recv_data
>> suggestion
>> contentlen
>> content
;
601 recv_data
>> typelen
>> type
;
603 if( suggestion
== 0 )
604 sLog
.outDebug( "WORLD: Received CMSG_BUG [Bug Report]" );
606 sLog
.outDebug( "WORLD: Received CMSG_BUG [Suggestion]" );
608 sLog
.outDebug("%s", type
.c_str() );
609 sLog
.outDebug("%s", content
.c_str() );
611 CharacterDatabase
.escape_string(type
);
612 CharacterDatabase
.escape_string(content
);
613 CharacterDatabase
.PExecute ("INSERT INTO bugreport (type,content) VALUES('%s', '%s')", type
.c_str( ), content
.c_str( ));
616 void WorldSession::HandleReclaimCorpseOpcode(WorldPacket
&recv_data
)
618 sLog
.outDetail("WORLD: Received CMSG_RECLAIM_CORPSE");
619 if (GetPlayer()->isAlive())
622 // do not allow corpse reclaim in arena
623 if (GetPlayer()->InArena())
626 // body not released yet
627 if(!GetPlayer()->HasFlag(PLAYER_FLAGS
, PLAYER_FLAGS_GHOST
))
630 Corpse
*corpse
= GetPlayer()->GetCorpse();
635 // prevent resurrect before 30-sec delay after body release not finished
636 if(corpse
->GetGhostTime() + GetPlayer()->GetCorpseReclaimDelay(corpse
->GetType()==CORPSE_RESURRECTABLE_PVP
) > time(NULL
))
639 if (!corpse
->IsWithinDistInMap(GetPlayer(), CORPSE_RECLAIM_RADIUS
, true))
646 GetPlayer()->ResurrectPlayer(GetPlayer()->InBattleGround() ? 1.0f
: 0.5f
);
649 GetPlayer()->SpawnCorpseBones();
652 void WorldSession::HandleResurrectResponseOpcode(WorldPacket
& recv_data
)
654 sLog
.outDetail("WORLD: Received CMSG_RESURRECT_RESPONSE");
656 if(GetPlayer()->isAlive())
666 GetPlayer()->clearResurrectRequestData(); // reject
670 if(!GetPlayer()->isRessurectRequestedBy(guid
))
673 GetPlayer()->ResurectUsingRequestData(); // will call spawncorpsebones
676 void WorldSession::HandleAreaTriggerOpcode(WorldPacket
& recv_data
)
678 sLog
.outDebug("WORLD: Received CMSG_AREATRIGGER");
682 recv_data
>> Trigger_ID
;
683 sLog
.outDebug("Trigger ID: %u", Trigger_ID
);
685 if(GetPlayer()->isInFlight())
687 sLog
.outDebug("Player '%s' (GUID: %u) in flight, ignore Area Trigger ID: %u", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow(), Trigger_ID
);
691 AreaTriggerEntry
const* atEntry
= sAreaTriggerStore
.LookupEntry(Trigger_ID
);
694 sLog
.outDebug("Player '%s' (GUID: %u) send unknown (by DBC) Area Trigger ID: %u", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow(), Trigger_ID
);
698 if (GetPlayer()->GetMapId() != atEntry
->mapid
)
700 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
);
704 // delta is safe radius
705 const float delta
= 5.0f
;
706 // check if player in the range of areatrigger
707 Player
* pl
= GetPlayer();
709 if (atEntry
->radius
> 0)
711 // if we have radius check it
712 float dist
= pl
->GetDistance(atEntry
->x
, atEntry
->y
, atEntry
->z
);
713 if(dist
> atEntry
->radius
+ delta
)
715 sLog
.outDebug("Player '%s' (GUID: %u) too far (radius: %f distance: %f), ignore Area Trigger ID: %u",
716 pl
->GetName(), pl
->GetGUIDLow(), atEntry
->radius
, dist
, Trigger_ID
);
722 // we have only extent
724 // rotate the players position instead of rotating the whole cube, that way we can make a simplified
725 // is-in-cube check and we have to calculate only one point instead of 4
727 // 2PI = 360°, keep in mind that ingame orientation is counter-clockwise
728 double rotation
= 2*M_PI
-atEntry
->box_orientation
;
729 double sinVal
= sin(rotation
);
730 double cosVal
= cos(rotation
);
732 float playerBoxDistX
= pl
->GetPositionX() - atEntry
->x
;
733 float playerBoxDistY
= pl
->GetPositionY() - atEntry
->y
;
735 float rotPlayerX
= atEntry
->x
+ playerBoxDistX
* cosVal
- playerBoxDistY
*sinVal
;
736 float rotPlayerY
= atEntry
->y
+ playerBoxDistY
* cosVal
+ playerBoxDistX
*sinVal
;
738 // box edges are parallel to coordiante axis, so we can treat every dimension independently :D
739 float dz
= pl
->GetPositionZ() - atEntry
->z
;
740 float dx
= rotPlayerX
- atEntry
->x
;
741 float dy
= rotPlayerY
- atEntry
->y
;
742 if( (fabs(dx
) > atEntry
->box_x
/2 + delta
) ||
743 (fabs(dy
) > atEntry
->box_y
/2 + delta
) ||
744 (fabs(dz
) > atEntry
->box_z
/2 + delta
) )
746 sLog
.outDebug("Player '%s' (GUID: %u) too far (1/2 box X: %f 1/2 box Y: %f 1/2 box Z: %f rotatedPlayerX: %f rotatedPlayerY: %f dZ:%f), ignore Area Trigger ID: %u",
747 pl
->GetName(), pl
->GetGUIDLow(), atEntry
->box_x
/2, atEntry
->box_y
/2, atEntry
->box_z
/2, rotPlayerX
, rotPlayerY
, dz
, Trigger_ID
);
752 if(Script
->scriptAreaTrigger(GetPlayer(), atEntry
))
755 uint32 quest_id
= sObjectMgr
.GetQuestForAreaTrigger( Trigger_ID
);
756 if( quest_id
&& GetPlayer()->isAlive() && GetPlayer()->IsActiveQuest(quest_id
) )
758 Quest
const* pQuest
= sObjectMgr
.GetQuestTemplate(quest_id
);
761 if(GetPlayer()->GetQuestStatus(quest_id
) == QUEST_STATUS_INCOMPLETE
)
762 GetPlayer()->AreaExploredOrEventHappens( quest_id
);
766 if(sObjectMgr
.IsTavernAreaTrigger(Trigger_ID
))
768 // set resting flag we are in the inn
769 GetPlayer()->SetFlag(PLAYER_FLAGS
, PLAYER_FLAGS_RESTING
);
770 GetPlayer()->InnEnter(time(NULL
), atEntry
->mapid
, atEntry
->x
, atEntry
->y
, atEntry
->z
);
771 GetPlayer()->SetRestType(REST_TYPE_IN_TAVERN
);
773 if(sWorld
.IsFFAPvPRealm())
774 GetPlayer()->RemoveByteFlag(UNIT_FIELD_BYTES_2
, 1, UNIT_BYTE2_FLAG_FFA_PVP
);
779 if(GetPlayer()->InBattleGround())
781 BattleGround
* bg
= GetPlayer()->GetBattleGround();
783 bg
->HandleAreaTrigger(GetPlayer(), Trigger_ID
);
787 // NULL if all values default (non teleport trigger)
788 AreaTrigger
const* at
= sObjectMgr
.GetAreaTrigger(Trigger_ID
);
792 if(!GetPlayer()->isGameMaster())
794 uint32 missingLevel
= 0;
795 if(GetPlayer()->getLevel() < at
->requiredLevel
&& !sWorld
.getConfig(CONFIG_INSTANCE_IGNORE_LEVEL
))
796 missingLevel
= at
->requiredLevel
;
798 // must have one or the other, report the first one that's missing
799 uint32 missingItem
= 0;
802 if(!GetPlayer()->HasItemCount(at
->requiredItem
, 1) &&
803 (!at
->requiredItem2
|| !GetPlayer()->HasItemCount(at
->requiredItem2
, 1)))
804 missingItem
= at
->requiredItem
;
806 else if(at
->requiredItem2
&& !GetPlayer()->HasItemCount(at
->requiredItem2
, 1))
807 missingItem
= at
->requiredItem2
;
809 MapEntry
const* mapEntry
= sMapStore
.LookupEntry(at
->target_mapId
);
813 bool isRegularTargetMap
= GetPlayer()->GetDifficulty(mapEntry
->IsRaid()) == REGULAR_DIFFICULTY
;
815 uint32 missingKey
= 0;
816 if (!isRegularTargetMap
)
820 if(!GetPlayer()->HasItemCount(at
->heroicKey
, 1) &&
821 (!at
->heroicKey2
|| !GetPlayer()->HasItemCount(at
->heroicKey2
, 1)))
822 missingKey
= at
->heroicKey
;
824 else if(at
->heroicKey2
&& !GetPlayer()->HasItemCount(at
->heroicKey2
, 1))
825 missingKey
= at
->heroicKey2
;
828 uint32 missingQuest
= 0;
829 if (!isRegularTargetMap
)
831 if (at
->requiredQuestHeroic
&& !GetPlayer()->GetQuestRewardStatus(at
->requiredQuestHeroic
))
832 missingQuest
= at
->requiredQuestHeroic
;
836 if(at
->requiredQuest
&& !GetPlayer()->GetQuestRewardStatus(at
->requiredQuest
))
837 missingQuest
= at
->requiredQuest
;
840 if(missingLevel
|| missingItem
|| missingKey
|| missingQuest
)
842 // TODO: all this is probably wrong
844 SendAreaTriggerMessage(GetMangosString(LANG_LEVEL_MINREQUIRED_AND_ITEM
), at
->requiredLevel
, ObjectMgr::GetItemPrototype(missingItem
)->Name1
);
846 GetPlayer()->SendTransferAborted(at
->target_mapId
, TRANSFER_ABORT_DIFFICULTY
, isRegularTargetMap
? DUNGEON_DIFFICULTY_NORMAL
: DUNGEON_DIFFICULTY_HEROIC
);
847 else if(missingQuest
)
848 SendAreaTriggerMessage(at
->requiredFailedText
.c_str());
849 else if(missingLevel
)
850 SendAreaTriggerMessage(GetMangosString(LANG_LEVEL_MINREQUIRED
), missingLevel
);
855 GetPlayer()->TeleportTo(at
->target_mapId
, at
->target_X
, at
->target_Y
, at
->target_Z
, at
->target_Orientation
, TELE_TO_NOT_LEAVE_TRANSPORT
);
858 void WorldSession::HandleUpdateAccountData(WorldPacket
&recv_data
)
860 sLog
.outDetail("WORLD: Received CMSG_UPDATE_ACCOUNT_DATA");
862 uint32 type
, timestamp
, decompressedSize
;
863 recv_data
>> type
>> timestamp
>> decompressedSize
;
865 sLog
.outDebug("UAD: type %u, time %u, decompressedSize %u", type
, timestamp
, decompressedSize
);
867 if(type
> NUM_ACCOUNT_DATA_TYPES
)
870 if(decompressedSize
== 0) // erase
872 SetAccountData(AccountDataType(type
), 0, "");
874 WorldPacket
data(SMSG_UPDATE_ACCOUNT_DATA_COMPLETE
, 4+4);
875 data
<< uint32(type
);
882 if(decompressedSize
> 0xFFFF)
884 recv_data
.rpos(recv_data
.wpos()); // unnneded warning spam in this case
885 sLog
.outError("UAD: Account data packet too big, size %u", decompressedSize
);
890 dest
.resize(decompressedSize
);
892 uLongf realSize
= decompressedSize
;
893 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
)
895 recv_data
.rpos(recv_data
.wpos()); // unneded warning spam in this case
896 sLog
.outError("UAD: Failed to decompress account data");
900 recv_data
.rpos(recv_data
.wpos()); // uncompress read (recv_data.size() - recv_data.rpos())
905 SetAccountData(AccountDataType(type
), timestamp
, adata
);
907 WorldPacket
data(SMSG_UPDATE_ACCOUNT_DATA_COMPLETE
, 4+4);
908 data
<< uint32(type
);
913 void WorldSession::HandleRequestAccountData(WorldPacket
& recv_data
)
915 sLog
.outDetail("WORLD: Received CMSG_REQUEST_ACCOUNT_DATA");
920 sLog
.outDebug("RAD: type %u", type
);
922 if(type
> NUM_ACCOUNT_DATA_TYPES
)
925 AccountData
*adata
= GetAccountData(AccountDataType(type
));
927 uint32 size
= adata
->Data
.size();
929 uLongf destSize
= compressBound(size
);
932 dest
.resize(destSize
);
934 if(size
&& compress(const_cast<uint8
*>(dest
.contents()), &destSize
, (uint8
*)adata
->Data
.c_str(), size
) != Z_OK
)
936 sLog
.outDebug("RAD: Failed to compress account data");
940 dest
.resize(destSize
);
942 WorldPacket
data(SMSG_UPDATE_ACCOUNT_DATA
, 8+4+4+4+destSize
);
943 data
<< uint64(_player
? _player
->GetGUID() : 0); // player guid
944 data
<< uint32(type
); // type (0-7)
945 data
<< uint32(adata
->Time
); // unix time
946 data
<< uint32(size
); // decompressed length
947 data
.append(dest
); // compressed data
951 void WorldSession::HandleSetActionButtonOpcode(WorldPacket
& recv_data
)
953 sLog
.outDebug( "WORLD: Received CMSG_SET_ACTION_BUTTON" );
956 recv_data
>> button
>> packetData
;
958 uint32 action
= ACTION_BUTTON_ACTION(packetData
);
959 uint8 type
= ACTION_BUTTON_TYPE(packetData
);
961 sLog
.outDetail( "BUTTON: %u ACTION: %u TYPE: %u", button
, action
, type
);
964 sLog
.outDetail( "MISC: Remove action from button %u", button
);
965 GetPlayer()->removeActionButton(button
);
971 case ACTION_BUTTON_MACRO
:
972 case ACTION_BUTTON_CMACRO
:
973 sLog
.outDetail( "MISC: Added Macro %u into button %u", action
, button
);
975 case ACTION_BUTTON_EQSET
:
976 sLog
.outDetail( "MISC: Added EquipmentSet %u into button %u", action
, button
);
978 case ACTION_BUTTON_SPELL
:
979 sLog
.outDetail( "MISC: Added Spell %u into button %u", action
, button
);
981 case ACTION_BUTTON_ITEM
:
982 sLog
.outDetail( "MISC: Added Item %u into button %u", action
, button
);
985 sLog
.outError( "MISC: Unknown action button type %u for action %u into button %u", type
, action
, button
);
988 GetPlayer()->addActionButton(button
, action
, type
);
992 void WorldSession::HandleCompleteCinematic( WorldPacket
& /*recv_data*/ )
994 DEBUG_LOG( "WORLD: Player is watching cinema" );
997 void WorldSession::HandleNextCinematicCamera( WorldPacket
& /*recv_data*/ )
999 DEBUG_LOG( "WORLD: Which movie to play" );
1002 void WorldSession::HandleMoveTimeSkippedOpcode( WorldPacket
& recv_data
)
1004 /* WorldSession::Update( getMSTime() );*/
1005 DEBUG_LOG( "WORLD: Time Lag/Synchronization Resent/Update" );
1008 if(!recv_data
.readPackGUID(guid
))
1010 recv_data
.rpos(recv_data
.wpos());
1013 recv_data
.read_skip
<uint32
>();
1016 uint32 time_skipped;
1018 recv_data >> time_skipped;
1019 sLog.outDebug( "WORLD: CMSG_MOVE_TIME_SKIPPED" );
1022 must be need use in mangos
1023 We substract server Lags to move time ( AntiLags )
1025 GetPlayer()->ModifyLastMoveTime( -int32(time_skipped) );
1029 void WorldSession::HandleFeatherFallAck(WorldPacket
&recv_data
)
1031 DEBUG_LOG("WORLD: CMSG_MOVE_FEATHER_FALL_ACK");
1034 recv_data
.rpos(recv_data
.wpos()); // prevent warnings spam
1037 void WorldSession::HandleMoveUnRootAck(WorldPacket
& recv_data
)
1040 recv_data
.rpos(recv_data
.wpos()); // prevent warnings spam
1045 // now can skip not our packet
1046 if(_player->GetGUID() != guid)
1048 recv_data.rpos(recv_data.wpos()); // prevent warnings spam
1052 sLog.outDebug( "WORLD: CMSG_FORCE_MOVE_UNROOT_ACK" );
1054 recv_data.read_skip<uint32>(); // unk
1056 MovementInfo movementInfo;
1057 ReadMovementInfo(recv_data, &movementInfo);
1061 void WorldSession::HandleMoveRootAck(WorldPacket
& recv_data
)
1064 recv_data
.rpos(recv_data
.wpos()); // prevent warnings spam
1069 // now can skip not our packet
1070 if(_player->GetGUID() != guid)
1072 recv_data.rpos(recv_data.wpos()); // prevent warnings spam
1076 sLog.outDebug( "WORLD: CMSG_FORCE_MOVE_ROOT_ACK" );
1078 recv_data.read_skip<uint32>(); // unk
1080 MovementInfo movementInfo;
1081 ReadMovementInfo(recv_data, &movementInfo);
1085 void WorldSession::HandleSetActionBarToggles(WorldPacket
& recv_data
)
1089 recv_data
>> ActionBar
;
1091 if(!GetPlayer()) // ignore until not logged (check needed because STATUS_AUTHED)
1094 sLog
.outError("WorldSession::HandleSetActionBarToggles in not logged state with value: %u, ignored", uint32(ActionBar
));
1098 GetPlayer()->SetByteValue(PLAYER_FIELD_BYTES
, 2, ActionBar
);
1101 void WorldSession::HandleWardenDataOpcode(WorldPacket
& recv_data
)
1103 recv_data
.read_skip
<uint8
>();
1107 sLog.outDebug("Received opcode CMSG_WARDEN_DATA, not resolve.uint8 = %u", tmp);
1111 void WorldSession::HandlePlayedTime(WorldPacket
& recv_data
)
1114 recv_data
>> unk1
; // 0 or 1 expected
1116 WorldPacket
data(SMSG_PLAYED_TIME
, 4 + 4 + 1);
1117 data
<< uint32(_player
->GetTotalPlayedTime());
1118 data
<< uint32(_player
->GetLevelPlayedTime());
1119 data
<< uint8(unk1
); // 0 - will not show in chat frame
1123 void WorldSession::HandleInspectOpcode(WorldPacket
& recv_data
)
1127 DEBUG_LOG("Inspected guid is (GUID: %u TypeId: %u)", GUID_LOPART(guid
), GuidHigh2TypeId(GUID_HIPART(guid
)));
1129 _player
->SetSelection(guid
);
1131 Player
*plr
= sObjectMgr
.GetPlayer(guid
);
1132 if(!plr
) // wrong player
1135 WorldPacket
data(SMSG_INSPECT_TALENT
, 50);
1136 data
.append(plr
->GetPackGUID());
1138 if(sWorld
.getConfig(CONFIG_TALENTS_INSPECTING
) || _player
->isGameMaster())
1140 plr
->BuildPlayerTalentsInfoData(&data
);
1141 plr
->BuildEnchantmentsInfoData(&data
);
1145 data
<< uint32(0); // unspentTalentPoints
1146 data
<< uint8(0); // talentGroupCount
1147 data
<< uint8(0); // talentGroupIndex
1148 data
<< uint32(0); // slotUsedMask
1154 void WorldSession::HandleInspectHonorStatsOpcode(WorldPacket
& recv_data
)
1159 Player
*player
= sObjectMgr
.GetPlayer(guid
);
1163 sLog
.outError("InspectHonorStats: WTF, player not found...");
1167 WorldPacket
data(MSG_INSPECT_HONOR_STATS
, 8+1+4*4);
1168 data
<< uint64(player
->GetGUID());
1169 data
<< uint8(player
->GetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY
));
1170 data
<< uint32(player
->GetUInt32Value(PLAYER_FIELD_KILLS
));
1171 data
<< uint32(player
->GetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION
));
1172 data
<< uint32(player
->GetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION
));
1173 data
<< uint32(player
->GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORBALE_KILLS
));
1177 void WorldSession::HandleWorldTeleportOpcode(WorldPacket
& recv_data
)
1179 // write in client console: worldport 469 452 6454 2536 180 or /console worldport 469 452 6454 2536 180
1180 // Received opcode CMSG_WORLD_TELEPORT
1181 // Time is ***, map=469, x=452.000000, y=6454.000000, z=2536.000000, orient=3.141593
1190 recv_data
>> time
; // time in m.sec.
1192 recv_data
>> PositionX
;
1193 recv_data
>> PositionY
;
1194 recv_data
>> PositionZ
;
1195 recv_data
>> Orientation
; // o (3.141593 = 180 degrees)
1197 //sLog.outDebug("Received opcode CMSG_WORLD_TELEPORT");
1199 if(GetPlayer()->isInFlight())
1201 sLog
.outDebug("Player '%s' (GUID: %u) in flight, ignore worldport command.",GetPlayer()->GetName(),GetPlayer()->GetGUIDLow());
1205 DEBUG_LOG("Time %u sec, map=%u, x=%f, y=%f, z=%f, orient=%f", time
/1000, mapid
, PositionX
, PositionY
, PositionZ
, Orientation
);
1207 if (GetSecurity() >= SEC_ADMINISTRATOR
)
1208 GetPlayer()->TeleportTo(mapid
, PositionX
, PositionY
, PositionZ
, Orientation
);
1210 SendNotification(LANG_YOU_NOT_HAVE_PERMISSION
);
1211 sLog
.outDebug("Received worldport command from player %s", GetPlayer()->GetName());
1214 void WorldSession::HandleWhoisOpcode(WorldPacket
& recv_data
)
1216 sLog
.outDebug("Received opcode CMSG_WHOIS");
1217 std::string charname
;
1218 recv_data
>> charname
;
1220 if (GetSecurity() < SEC_ADMINISTRATOR
)
1222 SendNotification(LANG_YOU_NOT_HAVE_PERMISSION
);
1226 if(charname
.empty() || !normalizePlayerName (charname
))
1228 SendNotification(LANG_NEED_CHARACTER_NAME
);
1232 Player
*plr
= sObjectMgr
.GetPlayer(charname
.c_str());
1236 SendNotification(LANG_PLAYER_NOT_EXIST_OR_OFFLINE
, charname
.c_str());
1240 uint32 accid
= plr
->GetSession()->GetAccountId();
1242 QueryResult
*result
= loginDatabase
.PQuery("SELECT username,email,last_ip FROM account WHERE id=%u", accid
);
1245 SendNotification(LANG_ACCOUNT_FOR_PLAYER_NOT_FOUND
, charname
.c_str());
1249 Field
*fields
= result
->Fetch();
1250 std::string acc
= fields
[0].GetCppString();
1253 std::string email
= fields
[1].GetCppString();
1256 std::string lastip
= fields
[2].GetCppString();
1260 std::string msg
= charname
+ "'s " + "account is " + acc
+ ", e-mail: " + email
+ ", last ip: " + lastip
;
1262 WorldPacket
data(SMSG_WHOIS
, msg
.size()+1);
1264 _player
->GetSession()->SendPacket(&data
);
1268 sLog
.outDebug("Received whois command from player %s for character %s", GetPlayer()->GetName(), charname
.c_str());
1271 void WorldSession::HandleComplainOpcode( WorldPacket
& recv_data
)
1273 sLog
.outDebug("WORLD: CMSG_COMPLAIN");
1274 recv_data
.hexlike();
1276 uint8 spam_type
; // 0 - mail, 1 - chat
1277 uint64 spammer_guid
;
1282 std::string description
= "";
1283 recv_data
>> spam_type
; // unk 0x01 const, may be spam type (mail/chat)
1284 recv_data
>> spammer_guid
; // player guid
1288 recv_data
>> unk1
; // const 0
1289 recv_data
>> unk2
; // probably mail id
1290 recv_data
>> unk3
; // const 0
1293 recv_data
>> unk1
; // probably language
1294 recv_data
>> unk2
; // message type?
1295 recv_data
>> unk3
; // probably channel id
1296 recv_data
>> unk4
; // unk random value
1297 recv_data
>> description
; // spam description string (messagetype, channel name, player name, message)
1301 // NOTE: all chat messages from this spammer automatically ignored by spam reporter until logout in case chat spam.
1302 // if it's mail spam - ALL mails from this spammer automatically removed by client
1304 // Complaint Received message
1305 WorldPacket
data(SMSG_COMPLAIN_RESULT
, 1);
1309 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());
1312 void WorldSession::HandleRealmSplitOpcode( WorldPacket
& recv_data
)
1314 sLog
.outDebug("CMSG_REALM_SPLIT");
1317 std::string split_date
= "01/01/01";
1320 WorldPacket
data(SMSG_REALM_SPLIT
, 4+4+split_date
.size()+1);
1322 data
<< uint32(0x00000000); // realm split state
1326 // 0x2 realm split pending
1329 //sLog.outDebug("response sent %u", unk);
1332 void WorldSession::HandleFarSightOpcode( WorldPacket
& recv_data
)
1334 sLog
.outDebug("WORLD: CMSG_FAR_SIGHT");
1335 //recv_data.hexlike();
1343 //WorldPacket data(SMSG_CLEAR_FAR_SIGHT_IMMEDIATE, 0)
1344 //SendPacket(&data);
1345 //_player->SetUInt64Value(PLAYER_FARSIGHT, 0);
1346 sLog
.outDebug("Removed FarSight from player %u", _player
->GetGUIDLow());
1349 sLog
.outDebug("Added FarSight (GUID:%u TypeId:%u) to player %u", GUID_LOPART(_player
->GetFarSight()), GuidHigh2TypeId(GUID_HIPART(_player
->GetFarSight())), _player
->GetGUIDLow());
1354 void WorldSession::HandleSetTitleOpcode( WorldPacket
& recv_data
)
1356 sLog
.outDebug("CMSG_SET_TITLE");
1362 if(title
> 0 && title
< MAX_TITLE_INDEX
)
1364 if(!GetPlayer()->HasTitle(title
))
1370 GetPlayer()->SetUInt32Value(PLAYER_CHOSEN_TITLE
, title
);
1373 void WorldSession::HandleTimeSyncResp( WorldPacket
& recv_data
)
1375 sLog
.outDebug("CMSG_TIME_SYNC_RESP");
1377 uint32 counter
, time_
;
1378 recv_data
>> counter
>> time_
;
1380 // time_ seems always more than getMSTime()
1381 uint32 diff
= getMSTimeDiff(getMSTime(), time_
);
1383 sLog
.outDebug("response sent: counter %u, time %u (HEX: %X), ms. time %u, diff %u", counter
, time_
, time_
, getMSTime(), diff
);
1386 void WorldSession::HandleResetInstancesOpcode( WorldPacket
& /*recv_data*/ )
1388 sLog
.outDebug("WORLD: CMSG_RESET_INSTANCES");
1390 if(Group
*pGroup
= _player
->GetGroup())
1392 if(pGroup
->IsLeader(_player
->GetGUID()))
1394 pGroup
->ResetInstances(INSTANCE_RESET_ALL
, false, _player
);
1395 pGroup
->ResetInstances(INSTANCE_RESET_ALL
, true,_player
);
1400 _player
->ResetInstances(INSTANCE_RESET_ALL
, false);
1401 _player
->ResetInstances(INSTANCE_RESET_ALL
, true);
1405 void WorldSession::HandleSetDungeonDifficultyOpcode( WorldPacket
& recv_data
)
1407 sLog
.outDebug("MSG_SET_DUNGEON_DIFFICULTY");
1412 if(mode
>= MAX_DUNGEON_DIFFICULTY
)
1414 sLog
.outError("WorldSession::HandleSetDungeonDifficultyOpcode: player %d sent an invalid instance mode %d!", _player
->GetGUIDLow(), mode
);
1418 if(Difficulty(mode
) == _player
->GetDungeonDifficulty())
1421 // cannot reset while in an instance
1422 Map
*map
= _player
->GetMap();
1423 if(map
&& map
->IsDungeon())
1425 sLog
.outError("WorldSession::HandleSetDungeonDifficultyOpcode: player %d tried to reset the instance while inside!", _player
->GetGUIDLow());
1429 if(_player
->getLevel() < LEVELREQUIREMENT_HEROIC
)
1432 if(Group
*pGroup
= _player
->GetGroup())
1434 if(pGroup
->IsLeader(_player
->GetGUID()))
1436 // the difficulty is set even if the instances can't be reset
1437 //_player->SendDungeonDifficulty(true);
1438 pGroup
->ResetInstances(INSTANCE_RESET_CHANGE_DIFFICULTY
, false, _player
);
1439 pGroup
->SetDungeonDifficulty(Difficulty(mode
));
1444 _player
->ResetInstances(INSTANCE_RESET_CHANGE_DIFFICULTY
, false);
1445 _player
->SetDungeonDifficulty(Difficulty(mode
));
1449 void WorldSession::HandleSetRaidDifficultyOpcode( WorldPacket
& recv_data
)
1451 sLog
.outDebug("MSG_SET_RAID_DIFFICULTY");
1456 if(mode
>= MAX_RAID_DIFFICULTY
)
1458 sLog
.outError("WorldSession::HandleSetRaidDifficultyOpcode: player %d sent an invalid instance mode %d!", _player
->GetGUIDLow(), mode
);
1462 if(Difficulty(mode
) == _player
->GetRaidDifficulty())
1465 // cannot reset while in an instance
1466 Map
*map
= _player
->GetMap();
1467 if(map
&& map
->IsDungeon())
1469 sLog
.outError("WorldSession::HandleSetRaidDifficultyOpcode: player %d tried to reset the instance while inside!", _player
->GetGUIDLow());
1473 if(_player
->getLevel() < LEVELREQUIREMENT_HEROIC
)
1476 if(Group
*pGroup
= _player
->GetGroup())
1478 if(pGroup
->IsLeader(_player
->GetGUID()))
1480 // the difficulty is set even if the instances can't be reset
1481 //_player->SendDungeonDifficulty(true);
1482 pGroup
->ResetInstances(INSTANCE_RESET_CHANGE_DIFFICULTY
, true, _player
);
1483 pGroup
->SetRaidDifficulty(Difficulty(mode
));
1488 _player
->ResetInstances(INSTANCE_RESET_CHANGE_DIFFICULTY
, true);
1489 _player
->SetRaidDifficulty(Difficulty(mode
));
1493 void WorldSession::HandleCancelMountAuraOpcode( WorldPacket
& /*recv_data*/ )
1495 sLog
.outDebug("WORLD: CMSG_CANCEL_MOUNT_AURA");
1497 //If player is not mounted, so go out :)
1498 if (!_player
->IsMounted()) // not blizz like; no any messages on blizz
1500 ChatHandler(this).SendSysMessage(LANG_CHAR_NON_MOUNTED
);
1504 if(_player
->isInFlight()) // not blizz like; no any messages on blizz
1506 ChatHandler(this).SendSysMessage(LANG_YOU_IN_FLIGHT
);
1511 _player
->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED
);
1514 void WorldSession::HandleMoveSetCanFlyAckOpcode( WorldPacket
& recv_data
)
1517 sLog
.outDebug("WORLD: CMSG_MOVE_SET_CAN_FLY_ACK");
1518 //recv_data.hexlike();
1520 uint64 guid
; // guid - unused
1521 if(!recv_data
.readPackGUID(guid
))
1524 recv_data
.read_skip
<uint32
>(); // unk
1526 MovementInfo movementInfo
;
1527 ReadMovementInfo(recv_data
, &movementInfo
);
1529 recv_data
.read_skip
<uint32
>(); // unk2
1531 _player
->m_movementInfo
.SetMovementFlags(movementInfo
.GetMovementFlags());
1534 void WorldSession::HandleRequestPetInfoOpcode( WorldPacket
& /*recv_data */)
1537 sLog.outDebug("WORLD: CMSG_REQUEST_PET_INFO");
1538 recv_data.hexlike();
1542 void WorldSession::HandleSetTaxiBenchmarkOpcode( WorldPacket
& recv_data
)
1547 sLog
.outDebug("Client used \"/timetest %d\" command", mode
);
1550 void WorldSession::HandleQueryInspectAchievements( WorldPacket
& recv_data
)
1553 if(!recv_data
.readPackGUID(guid
))
1556 if(Player
*player
= sObjectMgr
.GetPlayer(guid
))
1557 player
->GetAchievementMgr().SendRespondInspectAchievements(_player
);
1560 void WorldSession::HandleWorldStateUITimerUpdate(WorldPacket
& recv_data
)
1563 sLog
.outDebug("WORLD: CMSG_WORLD_STATE_UI_TIMER_UPDATE");
1565 WorldPacket
data(SMSG_WORLD_STATE_UI_TIMER_UPDATE
, 4);
1566 data
<< uint32(time(NULL
));