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 recv_data
.read_skip
<uint8
>();
49 if(GetPlayer()->isAlive()||GetPlayer()->HasFlag(PLAYER_FLAGS
, PLAYER_FLAGS_GHOST
))
52 // the world update order is sessions, players, creatures
53 // the netcode runs in parallel with all of these
54 // creatures can kill players
55 // so if the server is lagging enough the player can
56 // release spirit after he's killed but before he is updated
57 if(GetPlayer()->getDeathState() == JUST_DIED
)
59 sLog
.outDebug("HandleRepopRequestOpcode: got request after player %s(%d) was killed and before he was updated", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow());
60 GetPlayer()->KillPlayer();
63 //this is spirit release confirm?
64 GetPlayer()->RemovePet(NULL
,PET_SAVE_NOT_IN_SLOT
, true);
65 GetPlayer()->BuildPlayerRepop();
66 GetPlayer()->RepopAtGraveyard();
69 void WorldSession::HandleWhoOpcode( WorldPacket
& recv_data
)
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...
84 recv_data
>> guild_name
; // guild name, case sensitive...
86 recv_data
>> racemask
; // race mask
87 recv_data
>> classmask
; // class mask
88 recv_data
>> zones_count
; // zones count, client limit=10 (2.0.10)
91 return; // can't be received from real client or broken packet
93 for(uint32 i
= 0; i
< zones_count
; ++i
)
96 recv_data
>> temp
; // zone id, 0 if zone is unknown...
98 sLog
.outDebug("Zone %u: %u", i
, zoneids
[i
]);
101 recv_data
>> str_count
; // user entered strings count, client limit=4 (checked on 2.0.10)
104 return; // can't be received from real client or broken packet
106 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
);
108 std::wstring str
[4]; // 4 is client limit
109 for(uint32 i
= 0; i
< str_count
; ++i
)
112 recv_data
>> temp
; // user entered string, it used as universal search pattern(guild+player name)?
114 if(!Utf8toWStr(temp
,str
[i
]))
119 sLog
.outDebug("String %u: %s", i
, temp
.c_str());
122 std::wstring wplayer_name
;
123 std::wstring wguild_name
;
124 if(!(Utf8toWStr(player_name
, wplayer_name
) && Utf8toWStr(guild_name
, wguild_name
)))
126 wstrToLower(wplayer_name
);
127 wstrToLower(wguild_name
);
129 // client send in case not set max level value 100 but mangos support 255 max level,
130 // update it to show GMs with characters after 100 level
131 if(level_max
>= MAX_LEVEL
)
132 level_max
= STRONG_MAX_LEVEL
;
134 uint32 team
= _player
->GetTeam();
135 uint32 security
= GetSecurity();
136 bool allowTwoSideWhoList
= sWorld
.getConfig(CONFIG_ALLOW_TWO_SIDE_WHO_LIST
);
137 uint32 gmLevelInWhoList
= sWorld
.getConfig(CONFIG_GM_LEVEL_IN_WHO_LIST
);
139 WorldPacket
data( SMSG_WHO
, 50 ); // guess size
140 data
<< clientcount
; // clientcount place holder
141 data
<< clientcount
; // clientcount place holder
143 //TODO: Guard Player map
144 HashMapHolder
<Player
>::MapType
& m
= ObjectAccessor::Instance().GetPlayers();
145 for(HashMapHolder
<Player
>::MapType::const_iterator itr
= m
.begin(); itr
!= m
.end(); ++itr
)
147 if (security
== SEC_PLAYER
)
149 // player can see member of other team only if CONFIG_ALLOW_TWO_SIDE_WHO_LIST
150 if (itr
->second
->GetTeam() != team
&& !allowTwoSideWhoList
)
153 // player can see MODERATOR, GAME MASTER, ADMINISTRATOR only if CONFIG_GM_IN_WHO_LIST
154 if ((itr
->second
->GetSession()->GetSecurity() > gmLevelInWhoList
))
158 //do not process players which are not in world
159 if(!(itr
->second
->IsInWorld()))
162 // check if target is globally visible for player
163 if (!(itr
->second
->IsVisibleGloballyFor(_player
)))
166 // check if target's level is in level range
167 uint32 lvl
= itr
->second
->getLevel();
168 if (lvl
< level_min
|| lvl
> level_max
)
171 // check if class matches classmask
172 uint32 class_
= itr
->second
->getClass();
173 if (!(classmask
& (1 << class_
)))
176 // check if race matches racemask
177 uint32 race
= itr
->second
->getRace();
178 if (!(racemask
& (1 << race
)))
181 uint32 pzoneid
= itr
->second
->GetZoneId();
184 for(uint32 i
= 0; i
< zones_count
; ++i
)
186 if(zoneids
[i
] == pzoneid
)
197 std::string pname
= itr
->second
->GetName();
199 if(!Utf8toWStr(pname
,wpname
))
203 if (!(wplayer_name
.empty() || wpname
.find(wplayer_name
) != std::wstring::npos
))
206 std::string gname
= objmgr
.GetGuildNameById(itr
->second
->GetGuildId());
208 if(!Utf8toWStr(gname
,wgname
))
212 if (!(wguild_name
.empty() || wgname
.find(wguild_name
) != std::wstring::npos
))
216 if(AreaTableEntry
const* areaEntry
= GetAreaEntryByAreaID(itr
->second
->GetZoneId()))
217 aname
= areaEntry
->area_name
[GetSessionDbcLocale()];
220 for(uint32 i
= 0; i
< str_count
; ++i
)
224 if (wgname
.find(str
[i
]) != std::wstring::npos
||
225 wpname
.find(str
[i
]) != std::wstring::npos
||
226 Utf8FitTo(aname
, str
[i
]) )
237 data
<< pname
; // player name
238 data
<< gname
; // guild name
239 data
<< uint32( lvl
); // player level
240 data
<< uint32( class_
); // player class
241 data
<< uint32( race
); // player race
242 data
<< uint8(0); // new 2.4.0
243 data
<< uint32( pzoneid
); // player zone id
245 // 49 is maximum player count sent to client
246 if ((++clientcount
) == 49)
250 data
.put( 0, clientcount
); //insert right count
251 data
.put( sizeof(uint32
), clientcount
); //insert right count
254 sLog
.outDebug( "WORLD: Send SMSG_WHO Message" );
257 void WorldSession::HandleLogoutRequestOpcode( WorldPacket
& /*recv_data*/ )
259 sLog
.outDebug( "WORLD: Recvd CMSG_LOGOUT_REQUEST Message, security - %u", GetSecurity() );
261 if (uint64 lguid
= GetPlayer()->GetLootGUID())
262 DoLootRelease(lguid
);
264 //Can not logout if...
265 if( GetPlayer()->isInCombat() || //...is in combat
266 GetPlayer()->duel
|| //...is in Duel
267 //...is jumping ...is falling
268 GetPlayer()->m_movementInfo
.HasMovementFlag(MovementFlags(MOVEMENTFLAG_JUMPING
| MOVEMENTFLAG_FALLING
)))
270 WorldPacket
data( SMSG_LOGOUT_RESPONSE
, (2+4) ) ;
279 //instant logout in taverns/cities or on taxi or for admins, gm's, mod's if its enabled in mangosd.conf
280 if (GetPlayer()->HasFlag(PLAYER_FLAGS
, PLAYER_FLAGS_RESTING
) || GetPlayer()->isInFlight() ||
281 GetSecurity() >= sWorld
.getConfig(CONFIG_INSTANT_LOGOUT
))
287 // not set flags if player can't free move to prevent lost state at logout cancel
288 if(GetPlayer()->CanFreeMove())
290 GetPlayer()->SetStandState(UNIT_STAND_STATE_SIT
);
292 WorldPacket
data( SMSG_FORCE_MOVE_ROOT
, (8+4) ); // guess size
293 data
.append(GetPlayer()->GetPackGUID());
296 GetPlayer()->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_STUNNED
);
299 WorldPacket
data( SMSG_LOGOUT_RESPONSE
, 5 );
303 LogoutRequest(time(NULL
));
306 void WorldSession::HandlePlayerLogoutOpcode( WorldPacket
& /*recv_data*/ )
308 sLog
.outDebug( "WORLD: Recvd CMSG_PLAYER_LOGOUT Message" );
311 void WorldSession::HandleLogoutCancelOpcode( WorldPacket
& /*recv_data*/ )
313 sLog
.outDebug( "WORLD: Recvd CMSG_LOGOUT_CANCEL Message" );
317 WorldPacket
data( SMSG_LOGOUT_CANCEL_ACK
, 0 );
320 // not remove flags if can't free move - its not set in Logout request code.
321 if(GetPlayer()->CanFreeMove())
324 data
.Initialize( SMSG_FORCE_MOVE_UNROOT
, 8 ); // guess size
325 data
.append(GetPlayer()->GetPackGUID());
330 GetPlayer()->SetStandState(UNIT_STAND_STATE_STAND
);
333 GetPlayer()->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_STUNNED
);
336 sLog
.outDebug( "WORLD: sent SMSG_LOGOUT_CANCEL_ACK Message" );
339 void WorldSession::HandleTogglePvP( WorldPacket
& recv_data
)
341 // this opcode can be used in two ways: Either set explicit new status or toggle old status
342 if(recv_data
.size() == 1)
345 recv_data
>> newPvPStatus
;
346 GetPlayer()->ApplyModFlag(PLAYER_FLAGS
, PLAYER_FLAGS_IN_PVP
, newPvPStatus
);
347 GetPlayer()->ApplyModFlag(PLAYER_FLAGS
, PLAYER_FLAGS_PVP_TIMER
, !newPvPStatus
);
351 GetPlayer()->ToggleFlag(PLAYER_FLAGS
, PLAYER_FLAGS_IN_PVP
);
352 GetPlayer()->ToggleFlag(PLAYER_FLAGS
, PLAYER_FLAGS_PVP_TIMER
);
355 if(GetPlayer()->HasFlag(PLAYER_FLAGS
, PLAYER_FLAGS_IN_PVP
))
357 if(!GetPlayer()->IsPvP() || GetPlayer()->pvpInfo
.endTimer
!= 0)
358 GetPlayer()->UpdatePvP(true, true);
362 if(!GetPlayer()->pvpInfo
.inHostileArea
&& GetPlayer()->IsPvP())
363 GetPlayer()->pvpInfo
.endTimer
= time(NULL
); // start toggle-off
367 void WorldSession::HandleZoneUpdateOpcode( WorldPacket
& recv_data
)
370 recv_data
>> newZone
;
372 sLog
.outDetail("WORLD: Recvd ZONE_UPDATE: %u", newZone
);
374 // use server size data
375 uint32 newzone
, newarea
;
376 GetPlayer()->GetZoneAndAreaId(newzone
,newarea
);
377 GetPlayer()->UpdateZone(newzone
,newarea
);
380 void WorldSession::HandleSetTargetOpcode( WorldPacket
& recv_data
)
382 // When this packet send?
386 _player
->SetUInt32Value(UNIT_FIELD_TARGET
,guid
);
388 // update reputation list if need
389 Unit
* unit
= ObjectAccessor::GetUnit(*_player
, guid
);
393 if(FactionTemplateEntry
const* factionTemplateEntry
= sFactionTemplateStore
.LookupEntry(unit
->getFaction()))
394 _player
->GetReputationMgr().SetVisible(factionTemplateEntry
);
397 void WorldSession::HandleSetSelectionOpcode( WorldPacket
& recv_data
)
402 _player
->SetSelection(guid
);
404 // update reputation list if need
405 Unit
* unit
= ObjectAccessor::GetUnit(*_player
, guid
);
409 if(FactionTemplateEntry
const* factionTemplateEntry
= sFactionTemplateStore
.LookupEntry(unit
->getFaction()))
410 _player
->GetReputationMgr().SetVisible(factionTemplateEntry
);
413 void WorldSession::HandleStandStateChangeOpcode( WorldPacket
& recv_data
)
415 // sLog.outDebug( "WORLD: Received CMSG_STANDSTATECHANGE" ); -- too many spam in log at lags/debug stop
417 recv_data
>> animstate
;
419 _player
->SetStandState(animstate
);
422 void WorldSession::HandleContactListOpcode( WorldPacket
& recv_data
)
424 sLog
.outDebug( "WORLD: Received CMSG_CONTACT_LIST" );
427 sLog
.outDebug("unk value is %u", unk
);
428 _player
->GetSocial()->SendSocialList();
431 void WorldSession::HandleAddFriendOpcode( WorldPacket
& recv_data
)
433 sLog
.outDebug( "WORLD: Received CMSG_ADD_FRIEND" );
435 std::string friendName
= GetMangosString(LANG_FRIEND_IGNORE_UNKNOWN
);
436 std::string friendNote
;
438 recv_data
>> friendName
;
440 recv_data
>> friendNote
;
442 if(!normalizePlayerName(friendName
))
445 CharacterDatabase
.escape_string(friendName
); // prevent SQL injection - normal name don't must changed by this call
447 sLog
.outDebug( "WORLD: %s asked to add friend : '%s'",
448 GetPlayer()->GetName(), friendName
.c_str() );
450 CharacterDatabase
.AsyncPQuery(&WorldSession::HandleAddFriendOpcodeCallBack
, GetAccountId(), friendNote
, "SELECT guid, race FROM characters WHERE name = '%s'", friendName
.c_str());
453 void WorldSession::HandleAddFriendOpcodeCallBack(QueryResult
*result
, uint32 accountId
, std::string friendNote
)
458 uint64 friendGuid
= MAKE_NEW_GUID((*result
)[0].GetUInt32(), 0, HIGHGUID_PLAYER
);
459 uint32 team
= Player::TeamForRace((*result
)[1].GetUInt8());
463 WorldSession
* session
= sWorld
.FindSession(accountId
);
464 if(!session
|| !session
->GetPlayer())
467 FriendsResult friendResult
= FRIEND_NOT_FOUND
;
470 if(friendGuid
==session
->GetPlayer()->GetGUID())
471 friendResult
= FRIEND_SELF
;
472 else if(session
->GetPlayer()->GetTeam() != team
&& !sWorld
.getConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND
) && session
->GetSecurity() < SEC_MODERATOR
)
473 friendResult
= FRIEND_ENEMY
;
474 else if(session
->GetPlayer()->GetSocial()->HasFriend(GUID_LOPART(friendGuid
)))
475 friendResult
= FRIEND_ALREADY
;
478 Player
* pFriend
= ObjectAccessor::FindPlayer(friendGuid
);
479 if( pFriend
&& pFriend
->IsInWorld() && pFriend
->IsVisibleGloballyFor(session
->GetPlayer()))
480 friendResult
= FRIEND_ADDED_ONLINE
;
482 friendResult
= FRIEND_ADDED_OFFLINE
;
484 if(!session
->GetPlayer()->GetSocial()->AddToSocialList(GUID_LOPART(friendGuid
), false))
486 friendResult
= FRIEND_LIST_FULL
;
487 sLog
.outDebug( "WORLD: %s's friend list is full.", session
->GetPlayer()->GetName());
490 session
->GetPlayer()->GetSocial()->SetFriendNote(GUID_LOPART(friendGuid
), friendNote
);
494 sSocialMgr
.SendFriendStatus(session
->GetPlayer(), friendResult
, GUID_LOPART(friendGuid
), false);
496 sLog
.outDebug( "WORLD: Sent (SMSG_FRIEND_STATUS)" );
499 void WorldSession::HandleDelFriendOpcode( WorldPacket
& recv_data
)
503 sLog
.outDebug( "WORLD: Received CMSG_DEL_FRIEND" );
505 recv_data
>> FriendGUID
;
507 _player
->GetSocial()->RemoveFromSocialList(GUID_LOPART(FriendGUID
), false);
509 sSocialMgr
.SendFriendStatus(GetPlayer(), FRIEND_REMOVED
, GUID_LOPART(FriendGUID
), false);
511 sLog
.outDebug( "WORLD: Sent motd (SMSG_FRIEND_STATUS)" );
514 void WorldSession::HandleAddIgnoreOpcode( WorldPacket
& recv_data
)
516 sLog
.outDebug( "WORLD: Received CMSG_ADD_IGNORE" );
518 std::string IgnoreName
= GetMangosString(LANG_FRIEND_IGNORE_UNKNOWN
);
520 recv_data
>> IgnoreName
;
522 if(!normalizePlayerName(IgnoreName
))
525 CharacterDatabase
.escape_string(IgnoreName
); // prevent SQL injection - normal name don't must changed by this call
527 sLog
.outDebug( "WORLD: %s asked to Ignore: '%s'",
528 GetPlayer()->GetName(), IgnoreName
.c_str() );
530 CharacterDatabase
.AsyncPQuery(&WorldSession::HandleAddIgnoreOpcodeCallBack
, GetAccountId(), "SELECT guid FROM characters WHERE name = '%s'", IgnoreName
.c_str());
533 void WorldSession::HandleAddIgnoreOpcodeCallBack(QueryResult
*result
, uint32 accountId
)
538 uint64 IgnoreGuid
= MAKE_NEW_GUID((*result
)[0].GetUInt32(), 0, HIGHGUID_PLAYER
);
542 WorldSession
* session
= sWorld
.FindSession(accountId
);
543 if(!session
|| !session
->GetPlayer())
546 FriendsResult ignoreResult
= FRIEND_IGNORE_NOT_FOUND
;
549 if(IgnoreGuid
==session
->GetPlayer()->GetGUID()) //not add yourself
550 ignoreResult
= FRIEND_IGNORE_SELF
;
551 else if( session
->GetPlayer()->GetSocial()->HasIgnore(GUID_LOPART(IgnoreGuid
)) )
552 ignoreResult
= FRIEND_IGNORE_ALREADY
;
555 ignoreResult
= FRIEND_IGNORE_ADDED
;
558 if(!session
->GetPlayer()->GetSocial()->AddToSocialList(GUID_LOPART(IgnoreGuid
), true))
559 ignoreResult
= FRIEND_IGNORE_FULL
;
563 sSocialMgr
.SendFriendStatus(session
->GetPlayer(), ignoreResult
, GUID_LOPART(IgnoreGuid
), false);
565 sLog
.outDebug( "WORLD: Sent (SMSG_FRIEND_STATUS)" );
568 void WorldSession::HandleDelIgnoreOpcode( WorldPacket
& recv_data
)
572 sLog
.outDebug( "WORLD: Received CMSG_DEL_IGNORE" );
574 recv_data
>> IgnoreGUID
;
576 _player
->GetSocial()->RemoveFromSocialList(GUID_LOPART(IgnoreGUID
), true);
578 sSocialMgr
.SendFriendStatus(GetPlayer(), FRIEND_IGNORE_REMOVED
, GUID_LOPART(IgnoreGUID
), false);
580 sLog
.outDebug( "WORLD: Sent motd (SMSG_FRIEND_STATUS)" );
583 void WorldSession::HandleSetContactNotesOpcode( WorldPacket
& recv_data
)
585 sLog
.outDebug("CMSG_SET_CONTACT_NOTES");
588 recv_data
>> guid
>> note
;
589 _player
->GetSocial()->SetFriendNote(guid
, note
);
592 void WorldSession::HandleBugOpcode( WorldPacket
& recv_data
)
594 uint32 suggestion
, contentlen
;
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
->IsWithinDist(GetPlayer(), CORPSE_RECLAIM_RADIUS
, true))
646 GetPlayer()->ResurrectPlayer(GetPlayer()->InBattleGround() ? 1.0f
: 0.5f
);
649 GetPlayer()->SpawnCorpseBones();
651 GetPlayer()->SaveToDB();
654 void WorldSession::HandleResurrectResponseOpcode(WorldPacket
& recv_data
)
656 sLog
.outDetail("WORLD: Received CMSG_RESURRECT_RESPONSE");
658 if(GetPlayer()->isAlive())
668 GetPlayer()->clearResurrectRequestData(); // reject
672 if(!GetPlayer()->isRessurectRequestedBy(guid
))
675 GetPlayer()->ResurectUsingRequestData();
676 GetPlayer()->SaveToDB();
679 void WorldSession::HandleAreaTriggerOpcode(WorldPacket
& recv_data
)
681 sLog
.outDebug("WORLD: Received CMSG_AREATRIGGER");
685 recv_data
>> Trigger_ID
;
686 sLog
.outDebug("Trigger ID:%u",Trigger_ID
);
688 if(GetPlayer()->isInFlight())
690 sLog
.outDebug("Player '%s' (GUID: %u) in flight, ignore Area Trigger ID:%u",GetPlayer()->GetName(),GetPlayer()->GetGUIDLow(), Trigger_ID
);
694 AreaTriggerEntry
const* atEntry
= sAreaTriggerStore
.LookupEntry(Trigger_ID
);
697 sLog
.outDebug("Player '%s' (GUID: %u) send unknown (by DBC) Area Trigger ID:%u",GetPlayer()->GetName(),GetPlayer()->GetGUIDLow(), Trigger_ID
);
701 if (GetPlayer()->GetMapId()!=atEntry
->mapid
)
703 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
);
707 // delta is safe radius
708 const float delta
= 5.0f
;
709 // check if player in the range of areatrigger
710 Player
* pl
= GetPlayer();
712 if (atEntry
->radius
> 0)
714 // if we have radius check it
715 float dist
= pl
->GetDistance(atEntry
->x
,atEntry
->y
,atEntry
->z
);
716 if(dist
> atEntry
->radius
+ delta
)
718 sLog
.outDebug("Player '%s' (GUID: %u) too far (radius: %f distance: %f), ignore Area Trigger ID: %u",
719 pl
->GetName(), pl
->GetGUIDLow(), atEntry
->radius
, dist
, Trigger_ID
);
725 // we have only extent
727 // rotate the players position instead of rotating the whole cube, that way we can make a simplified
728 // is-in-cube check and we have to calculate only one point instead of 4
730 // 2PI = 360°, keep in mind that ingame orientation is counter-clockwise
731 double rotation
= 2*M_PI
-atEntry
->box_orientation
;
732 double sinVal
= sin(rotation
);
733 double cosVal
= cos(rotation
);
735 float playerBoxDistX
= pl
->GetPositionX() - atEntry
->x
;
736 float playerBoxDistY
= pl
->GetPositionY() - atEntry
->y
;
738 float rotPlayerX
= atEntry
->x
+ playerBoxDistX
* cosVal
- playerBoxDistY
*sinVal
;
739 float rotPlayerY
= atEntry
->y
+ playerBoxDistY
* cosVal
+ playerBoxDistX
*sinVal
;
741 // box edges are parallel to coordiante axis, so we can treat every dimension independently :D
742 float dz
= pl
->GetPositionZ() - atEntry
->z
;
743 float dx
= rotPlayerX
- atEntry
->x
;
744 float dy
= rotPlayerY
- atEntry
->y
;
745 if( (fabs(dx
) > atEntry
->box_x
/2 + delta
) ||
746 (fabs(dy
) > atEntry
->box_y
/2 + delta
) ||
747 (fabs(dz
) > atEntry
->box_z
/2 + delta
) )
749 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",
750 pl
->GetName(), pl
->GetGUIDLow(), atEntry
->box_x
/2, atEntry
->box_y
/2, atEntry
->box_z
/2, rotPlayerX
, rotPlayerY
, dz
, Trigger_ID
);
755 if(Script
->scriptAreaTrigger(GetPlayer(), atEntry
))
758 uint32 quest_id
= objmgr
.GetQuestForAreaTrigger( Trigger_ID
);
759 if( quest_id
&& GetPlayer()->isAlive() && GetPlayer()->IsActiveQuest(quest_id
) )
761 Quest
const* pQuest
= objmgr
.GetQuestTemplate(quest_id
);
764 if(GetPlayer()->GetQuestStatus(quest_id
) == QUEST_STATUS_INCOMPLETE
)
765 GetPlayer()->AreaExploredOrEventHappens( quest_id
);
769 if(objmgr
.IsTavernAreaTrigger(Trigger_ID
))
771 // set resting flag we are in the inn
772 GetPlayer()->SetFlag(PLAYER_FLAGS
, PLAYER_FLAGS_RESTING
);
773 GetPlayer()->InnEnter(time(NULL
), atEntry
->mapid
, atEntry
->x
, atEntry
->y
, atEntry
->z
);
774 GetPlayer()->SetRestType(REST_TYPE_IN_TAVERN
);
776 if(sWorld
.IsFFAPvPRealm())
777 GetPlayer()->RemoveByteFlag(UNIT_FIELD_BYTES_2
, 1, UNIT_BYTE2_FLAG_FFA_PVP
);
782 if(GetPlayer()->InBattleGround())
784 BattleGround
* bg
= GetPlayer()->GetBattleGround();
786 if(bg
->GetStatus() == STATUS_IN_PROGRESS
)
787 bg
->HandleAreaTrigger(GetPlayer(), Trigger_ID
);
792 // NULL if all values default (non teleport trigger)
793 AreaTrigger
const* at
= objmgr
.GetAreaTrigger(Trigger_ID
);
797 if(!GetPlayer()->isGameMaster())
799 uint32 missingLevel
= 0;
800 if(GetPlayer()->getLevel() < at
->requiredLevel
&& !sWorld
.getConfig(CONFIG_INSTANCE_IGNORE_LEVEL
))
801 missingLevel
= at
->requiredLevel
;
803 // must have one or the other, report the first one that's missing
804 uint32 missingItem
= 0;
807 if(!GetPlayer()->HasItemCount(at
->requiredItem
, 1) &&
808 (!at
->requiredItem2
|| !GetPlayer()->HasItemCount(at
->requiredItem2
, 1)))
809 missingItem
= at
->requiredItem
;
811 else if(at
->requiredItem2
&& !GetPlayer()->HasItemCount(at
->requiredItem2
, 1))
812 missingItem
= at
->requiredItem2
;
814 uint32 missingKey
= 0;
815 if(GetPlayer()->GetDifficulty() == DIFFICULTY_HEROIC
)
819 if(!GetPlayer()->HasItemCount(at
->heroicKey
, 1) &&
820 (!at
->heroicKey2
|| !GetPlayer()->HasItemCount(at
->heroicKey2
, 1)))
821 missingKey
= at
->heroicKey
;
823 else if(at
->heroicKey2
&& !GetPlayer()->HasItemCount(at
->heroicKey2
, 1))
824 missingKey
= at
->heroicKey2
;
827 uint32 missingQuest
= 0;
828 if(GetPlayer()->GetDifficulty() == DIFFICULTY_HEROIC
)
830 if (at
->requiredQuestHeroic
&& !GetPlayer()->GetQuestRewardStatus(at
->requiredQuestHeroic
))
831 missingQuest
= at
->requiredQuestHeroic
;
835 if(at
->requiredQuest
&& !GetPlayer()->GetQuestRewardStatus(at
->requiredQuest
))
836 missingQuest
= at
->requiredQuest
;
839 if(missingLevel
|| missingItem
|| missingKey
|| missingQuest
)
841 // TODO: all this is probably wrong
843 SendAreaTriggerMessage(GetMangosString(LANG_LEVEL_MINREQUIRED_AND_ITEM
), at
->requiredLevel
, objmgr
.GetItemPrototype(missingItem
)->Name1
);
845 GetPlayer()->SendTransferAborted(at
->target_mapId
, TRANSFER_ABORT_DIFFICULTY
, DIFFICULTY_HEROIC
);
846 else if(missingQuest
)
847 SendAreaTriggerMessage(at
->requiredFailedText
.c_str());
848 else if(missingLevel
)
849 SendAreaTriggerMessage(GetMangosString(LANG_LEVEL_MINREQUIRED
), missingLevel
);
854 GetPlayer()->TeleportTo(at
->target_mapId
,at
->target_X
,at
->target_Y
,at
->target_Z
,at
->target_Orientation
,TELE_TO_NOT_LEAVE_TRANSPORT
);
857 void WorldSession::HandleUpdateAccountData(WorldPacket
&recv_data
)
859 sLog
.outDetail("WORLD: Received CMSG_UPDATE_ACCOUNT_DATA");
861 uint32 type
, timestamp
, decompressedSize
;
862 recv_data
>> type
>> timestamp
>> decompressedSize
;
864 sLog
.outDebug("UAD: type %u, time %u, decompressedSize %u", type
, timestamp
, decompressedSize
);
866 if(type
> NUM_ACCOUNT_DATA_TYPES
)
869 if(decompressedSize
== 0) // erase
871 SetAccountData(AccountDataType(type
), 0, "");
873 WorldPacket
data(SMSG_UPDATE_ACCOUNT_DATA_COMPLETE
, 4+4);
874 data
<< uint32(type
);
881 if(decompressedSize
> 0xFFFF)
883 recv_data
.rpos(recv_data
.wpos()); // unnneded warning spam in this case
884 sLog
.outError("UAD: Account data packet too big, size %u", decompressedSize
);
889 dest
.resize(decompressedSize
);
891 uLongf realSize
= decompressedSize
;
892 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
)
894 recv_data
.rpos(recv_data
.wpos()); // unnneded warning spam in this case
895 sLog
.outError("UAD: Failed to decompress account data");
899 recv_data
.rpos(recv_data
.wpos()); // uncompress read (recv_data.size() - recv_data.rpos())
904 SetAccountData(AccountDataType(type
), timestamp
, adata
);
906 WorldPacket
data(SMSG_UPDATE_ACCOUNT_DATA_COMPLETE
, 4+4);
907 data
<< uint32(type
);
912 void WorldSession::HandleRequestAccountData(WorldPacket
& recv_data
)
914 sLog
.outDetail("WORLD: Received CMSG_REQUEST_ACCOUNT_DATA");
919 sLog
.outDebug("RAD: type %u", type
);
921 if(type
> NUM_ACCOUNT_DATA_TYPES
)
924 AccountData
*adata
= GetAccountData(AccountDataType(type
));
926 uint32 size
= adata
->Data
.size();
928 uLongf destSize
= compressBound(size
);
931 dest
.resize(destSize
);
933 if(size
&& compress(const_cast<uint8
*>(dest
.contents()), &destSize
, (uint8
*)adata
->Data
.c_str(), size
) != Z_OK
)
935 sLog
.outDebug("RAD: Failed to compress account data");
939 dest
.resize(destSize
);
941 WorldPacket
data (SMSG_UPDATE_ACCOUNT_DATA
, 8+4+4+4+destSize
);
942 data
<< uint64(_player
->GetGUID()); // player guid
943 data
<< uint32(type
); // type (0-7)
944 data
<< uint32(adata
->Time
); // unix time
945 data
<< uint32(size
); // decompressed length
946 data
.append(dest
); // compressed data
950 void WorldSession::HandleSetActionButtonOpcode(WorldPacket
& recv_data
)
952 sLog
.outDebug( "WORLD: Received CMSG_SET_ACTION_BUTTON" );
955 recv_data
>> button
>> packetData
;
957 uint32 action
= ACTION_BUTTON_ACTION(packetData
);
958 uint8 type
= ACTION_BUTTON_TYPE(packetData
);
960 sLog
.outDetail( "BUTTON: %u ACTION: %u TYPE: %u", button
, action
, type
);
963 sLog
.outDetail( "MISC: Remove action from button %u", button
);
964 GetPlayer()->removeActionButton(button
);
970 case ACTION_BUTTON_MACRO
:
971 case ACTION_BUTTON_CMACRO
:
972 sLog
.outDetail( "MISC: Added Macro %u into button %u", action
, button
);
974 case ACTION_BUTTON_EQSET
:
975 sLog
.outDetail( "MISC: Added EquipmentSet %u into button %u", action
, button
);
977 case ACTION_BUTTON_SPELL
:
978 sLog
.outDetail( "MISC: Added Spell %u into button %u", action
, button
);
980 case ACTION_BUTTON_ITEM
:
981 sLog
.outDetail( "MISC: Added Item %u into button %u", action
, button
);
984 sLog
.outError( "MISC: Unknown action button type %u for action %u into button %u", type
, action
, button
);
987 GetPlayer()->addActionButton(button
,action
,type
);
991 void WorldSession::HandleCompleteCinematic( WorldPacket
& /*recv_data*/ )
993 DEBUG_LOG( "WORLD: Player is watching cinema" );
996 void WorldSession::HandleNextCinematicCamera( WorldPacket
& /*recv_data*/ )
998 DEBUG_LOG( "WORLD: Which movie to play" );
1001 void WorldSession::HandleMoveTimeSkippedOpcode( WorldPacket
& recv_data
)
1003 /* WorldSession::Update( getMSTime() );*/
1004 DEBUG_LOG( "WORLD: Time Lag/Synchronization Resent/Update" );
1006 recv_data
.read_skip
<uint64
>();
1007 recv_data
.read_skip
<uint32
>();
1010 uint32 time_skipped;
1012 recv_data >> time_skipped;
1013 sLog.outDebug( "WORLD: CMSG_MOVE_TIME_SKIPPED" );
1016 must be need use in mangos
1017 We substract server Lags to move time ( AntiLags )
1019 GetPlayer()->ModifyLastMoveTime( -int32(time_skipped) );
1023 void WorldSession::HandleFeatherFallAck(WorldPacket
&/*recv_data*/)
1025 DEBUG_LOG("WORLD: CMSG_MOVE_FEATHER_FALL_ACK");
1028 void WorldSession::HandleMoveUnRootAck(WorldPacket
& recv_data
)
1031 recv_data
.rpos(recv_data
.wpos()); // prevent warnings spam
1036 // now can skip not our packet
1037 if(_player->GetGUID() != guid)
1039 recv_data.rpos(recv_data.wpos()); // prevent warnings spam
1043 sLog.outDebug( "WORLD: CMSG_FORCE_MOVE_UNROOT_ACK" );
1045 recv_data.read_skip<uint32>(); // unk
1047 MovementInfo movementInfo;
1048 ReadMovementInfo(recv_data, &movementInfo);
1052 void WorldSession::HandleMoveRootAck(WorldPacket
& recv_data
)
1055 recv_data
.rpos(recv_data
.wpos()); // prevent warnings spam
1060 // now can skip not our packet
1061 if(_player->GetGUID() != guid)
1063 recv_data.rpos(recv_data.wpos()); // prevent warnings spam
1067 sLog.outDebug( "WORLD: CMSG_FORCE_MOVE_ROOT_ACK" );
1069 recv_data.read_skip<uint32>(); // unk
1071 MovementInfo movementInfo;
1072 ReadMovementInfo(recv_data, &movementInfo);
1076 void WorldSession::HandleSetActionBarToggles(WorldPacket
& recv_data
)
1080 recv_data
>> ActionBar
;
1082 if(!GetPlayer()) // ignore until not logged (check needed because STATUS_AUTHED)
1085 sLog
.outError("WorldSession::HandleSetActionBarToggles in not logged state with value: %u, ignored",uint32(ActionBar
));
1089 GetPlayer()->SetByteValue(PLAYER_FIELD_BYTES
, 2, ActionBar
);
1092 void WorldSession::HandleWardenDataOpcode(WorldPacket
& recv_data
)
1094 recv_data
.read_skip
<uint8
>();
1098 sLog.outDebug("Received opcode CMSG_WARDEN_DATA, not resolve.uint8 = %u",tmp);
1102 void WorldSession::HandlePlayedTime(WorldPacket
& recv_data
)
1105 recv_data
>> unk1
; // 0 or 1 expected
1107 WorldPacket
data(SMSG_PLAYED_TIME
, 4 + 4 + 1);
1108 data
<< uint32(_player
->GetTotalPlayedTime());
1109 data
<< uint32(_player
->GetLevelPlayedTime());
1110 data
<< uint8(unk1
); // 0 - will not show in chat frame
1114 void WorldSession::HandleInspectOpcode(WorldPacket
& recv_data
)
1118 DEBUG_LOG("Inspected guid is (GUID: %u TypeId: %u)", GUID_LOPART(guid
), GuidHigh2TypeId(GUID_HIPART(guid
)));
1120 _player
->SetSelection(guid
);
1122 Player
*plr
= objmgr
.GetPlayer(guid
);
1123 if(!plr
) // wrong player
1126 WorldPacket
data(SMSG_INSPECT_TALENT
, 50);
1127 data
.append(plr
->GetPackGUID());
1129 if(sWorld
.getConfig(CONFIG_TALENTS_INSPECTING
) || _player
->isGameMaster())
1131 plr
->BuildPlayerTalentsInfoData(&data
);
1132 plr
->BuildEnchantmentsInfoData(&data
);
1136 data
<< uint32(0); // unspentTalentPoints
1137 data
<< uint8(0); // talentGroupCount
1138 data
<< uint8(0); // talentGroupIndex
1139 data
<< uint32(0); // slotUsedMask
1145 void WorldSession::HandleInspectHonorStatsOpcode(WorldPacket
& recv_data
)
1150 Player
*player
= objmgr
.GetPlayer(guid
);
1154 sLog
.outError("InspectHonorStats: WTF, player not found...");
1158 WorldPacket
data(MSG_INSPECT_HONOR_STATS
, 8+1+4*4);
1159 data
<< uint64(player
->GetGUID());
1160 data
<< uint8(player
->GetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY
));
1161 data
<< uint32(player
->GetUInt32Value(PLAYER_FIELD_KILLS
));
1162 data
<< uint32(player
->GetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION
));
1163 data
<< uint32(player
->GetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION
));
1164 data
<< uint32(player
->GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORBALE_KILLS
));
1168 void WorldSession::HandleWorldTeleportOpcode(WorldPacket
& recv_data
)
1170 // write in client console: worldport 469 452 6454 2536 180 or /console worldport 469 452 6454 2536 180
1171 // Received opcode CMSG_WORLD_TELEPORT
1172 // Time is ***, map=469, x=452.000000, y=6454.000000, z=2536.000000, orient=3.141593
1174 //sLog.outDebug("Received opcode CMSG_WORLD_TELEPORT");
1176 if(GetPlayer()->isInFlight())
1178 sLog
.outDebug("Player '%s' (GUID: %u) in flight, ignore worldport command.",GetPlayer()->GetName(),GetPlayer()->GetGUIDLow());
1189 recv_data
>> time
; // time in m.sec.
1191 recv_data
>> PositionX
;
1192 recv_data
>> PositionY
;
1193 recv_data
>> PositionZ
;
1194 recv_data
>> Orientation
; // o (3.141593 = 180 degrees)
1195 DEBUG_LOG("Time %u sec, map=%u, x=%f, y=%f, z=%f, orient=%f", time
/1000, mapid
, PositionX
, PositionY
, PositionZ
, Orientation
);
1197 if (GetSecurity() >= SEC_ADMINISTRATOR
)
1198 GetPlayer()->TeleportTo(mapid
,PositionX
,PositionY
,PositionZ
,Orientation
);
1200 SendNotification(LANG_YOU_NOT_HAVE_PERMISSION
);
1201 sLog
.outDebug("Received worldport command from player %s", GetPlayer()->GetName());
1204 void WorldSession::HandleWhoisOpcode(WorldPacket
& recv_data
)
1206 sLog
.outDebug("Received opcode CMSG_WHOIS");
1207 std::string charname
;
1208 recv_data
>> charname
;
1210 if (GetSecurity() < SEC_ADMINISTRATOR
)
1212 SendNotification(LANG_YOU_NOT_HAVE_PERMISSION
);
1216 if(charname
.empty() || !normalizePlayerName (charname
))
1218 SendNotification(LANG_NEED_CHARACTER_NAME
);
1222 Player
*plr
= objmgr
.GetPlayer(charname
.c_str());
1226 SendNotification(LANG_PLAYER_NOT_EXIST_OR_OFFLINE
, charname
.c_str());
1230 uint32 accid
= plr
->GetSession()->GetAccountId();
1232 QueryResult
*result
= loginDatabase
.PQuery("SELECT username,email,last_ip FROM account WHERE id=%u", accid
);
1235 SendNotification(LANG_ACCOUNT_FOR_PLAYER_NOT_FOUND
, charname
.c_str());
1239 Field
*fields
= result
->Fetch();
1240 std::string acc
= fields
[0].GetCppString();
1243 std::string email
= fields
[1].GetCppString();
1246 std::string lastip
= fields
[2].GetCppString();
1250 std::string msg
= charname
+ "'s " + "account is " + acc
+ ", e-mail: " + email
+ ", last ip: " + lastip
;
1252 WorldPacket
data(SMSG_WHOIS
, msg
.size()+1);
1254 _player
->GetSession()->SendPacket(&data
);
1258 sLog
.outDebug("Received whois command from player %s for character %s", GetPlayer()->GetName(), charname
.c_str());
1261 void WorldSession::HandleComplainOpcode( WorldPacket
& recv_data
)
1263 sLog
.outDebug("WORLD: CMSG_COMPLAIN");
1264 recv_data
.hexlike();
1266 uint8 spam_type
; // 0 - mail, 1 - chat
1267 uint64 spammer_guid
;
1272 std::string description
= "";
1273 recv_data
>> spam_type
; // unk 0x01 const, may be spam type (mail/chat)
1274 recv_data
>> spammer_guid
; // player guid
1278 recv_data
>> unk1
; // const 0
1279 recv_data
>> unk2
; // probably mail id
1280 recv_data
>> unk3
; // const 0
1283 recv_data
>> unk1
; // probably language
1284 recv_data
>> unk2
; // message type?
1285 recv_data
>> unk3
; // probably channel id
1286 recv_data
>> unk4
; // unk random value
1287 recv_data
>> description
; // spam description string (messagetype, channel name, player name, message)
1291 // NOTE: all chat messages from this spammer automatically ignored by spam reporter until logout in case chat spam.
1292 // if it's mail spam - ALL mails from this spammer automatically removed by client
1294 // Complaint Received message
1295 WorldPacket
data(SMSG_COMPLAIN_RESULT
, 1);
1299 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());
1302 void WorldSession::HandleRealmSplitOpcode( WorldPacket
& recv_data
)
1304 sLog
.outDebug("CMSG_REALM_SPLIT");
1307 std::string split_date
= "01/01/01";
1310 WorldPacket
data(SMSG_REALM_SPLIT
, 4+4+split_date
.size()+1);
1312 data
<< uint32(0x00000000); // realm split state
1316 // 0x2 realm split pending
1319 //sLog.outDebug("response sent %u", unk);
1322 void WorldSession::HandleFarSightOpcode( WorldPacket
& recv_data
)
1324 sLog
.outDebug("WORLD: CMSG_FAR_SIGHT");
1325 //recv_data.hexlike();
1333 //WorldPacket data(SMSG_CLEAR_FAR_SIGHT_IMMEDIATE, 0)
1334 //SendPacket(&data);
1335 //_player->SetUInt64Value(PLAYER_FARSIGHT, 0);
1336 sLog
.outDebug("Removed FarSight from player %u", _player
->GetGUIDLow());
1339 sLog
.outDebug("Added FarSight (GUID:%u TypeId:%u) to player %u", GUID_LOPART(_player
->GetFarSight()), GuidHigh2TypeId(GUID_HIPART(_player
->GetFarSight())), _player
->GetGUIDLow());
1344 void WorldSession::HandleSetTitleOpcode( WorldPacket
& recv_data
)
1346 sLog
.outDebug("CMSG_SET_TITLE");
1352 if(title
> 0 && title
< MAX_TITLE_INDEX
)
1354 if(!GetPlayer()->HasTitle(title
))
1360 GetPlayer()->SetUInt32Value(PLAYER_CHOSEN_TITLE
, title
);
1363 void WorldSession::HandleTimeSyncResp( WorldPacket
& recv_data
)
1365 sLog
.outDebug("CMSG_TIME_SYNC_RESP");
1367 uint32 counter
, time_
;
1368 recv_data
>> counter
>> time_
;
1370 // time_ seems always more than getMSTime()
1371 uint32 diff
= getMSTimeDiff(getMSTime(),time_
);
1373 sLog
.outDebug("response sent: counter %u, time %u (HEX: %X), ms. time %u, diff %u", counter
, time_
, time_
, getMSTime(), diff
);
1376 void WorldSession::HandleResetInstancesOpcode( WorldPacket
& /*recv_data*/ )
1378 sLog
.outDebug("WORLD: CMSG_RESET_INSTANCES");
1379 Group
*pGroup
= _player
->GetGroup();
1382 if(pGroup
->IsLeader(_player
->GetGUID()))
1383 pGroup
->ResetInstances(INSTANCE_RESET_ALL
, _player
);
1386 _player
->ResetInstances(INSTANCE_RESET_ALL
);
1389 void WorldSession::HandleSetDungeonDifficultyOpcode( WorldPacket
& recv_data
)
1391 sLog
.outDebug("MSG_SET_DUNGEON_DIFFICULTY");
1396 if(mode
== _player
->GetDifficulty())
1399 if(mode
> DIFFICULTY_HEROIC
)
1401 sLog
.outError("WorldSession::HandleSetDungeonDifficultyOpcode: player %d sent an invalid instance mode %d!", _player
->GetGUIDLow(), mode
);
1405 // cannot reset while in an instance
1406 Map
*map
= _player
->GetMap();
1407 if(map
&& map
->IsDungeon())
1409 sLog
.outError("WorldSession::HandleSetDungeonDifficultyOpcode: player %d tried to reset the instance while inside!", _player
->GetGUIDLow());
1413 if(_player
->getLevel() < LEVELREQUIREMENT_HEROIC
)
1415 Group
*pGroup
= _player
->GetGroup();
1418 if(pGroup
->IsLeader(_player
->GetGUID()))
1420 // the difficulty is set even if the instances can't be reset
1421 //_player->SendDungeonDifficulty(true);
1422 pGroup
->ResetInstances(INSTANCE_RESET_CHANGE_DIFFICULTY
, _player
);
1423 pGroup
->SetDifficulty(mode
);
1428 _player
->ResetInstances(INSTANCE_RESET_CHANGE_DIFFICULTY
);
1429 _player
->SetDifficulty(mode
);
1433 void WorldSession::HandleCancelMountAuraOpcode( WorldPacket
& /*recv_data*/ )
1435 sLog
.outDebug("WORLD: CMSG_CANCEL_MOUNT_AURA");
1436 //recv_data.hexlike();
1438 //If player is not mounted, so go out :)
1439 if (!_player
->IsMounted()) // not blizz like; no any messages on blizz
1441 ChatHandler(this).SendSysMessage(LANG_CHAR_NON_MOUNTED
);
1445 if(_player
->isInFlight()) // not blizz like; no any messages on blizz
1447 ChatHandler(this).SendSysMessage(LANG_YOU_IN_FLIGHT
);
1452 _player
->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED
);
1455 void WorldSession::HandleMoveSetCanFlyAckOpcode( WorldPacket
& recv_data
)
1458 sLog
.outDebug("WORLD: CMSG_MOVE_SET_CAN_FLY_ACK");
1459 //recv_data.hexlike();
1461 recv_data
.read_skip
<uint64
>(); // guid
1462 recv_data
.read_skip
<uint32
>(); // unk
1464 MovementInfo movementInfo
;
1465 ReadMovementInfo(recv_data
, &movementInfo
);
1467 recv_data
.read_skip
<uint32
>(); // unk2
1469 _player
->m_movementInfo
.SetMovementFlags(movementInfo
.GetMovementFlags());
1472 void WorldSession::HandleRequestPetInfoOpcode( WorldPacket
& /*recv_data */)
1475 sLog.outDebug("WORLD: CMSG_REQUEST_PET_INFO");
1476 recv_data.hexlike();
1480 void WorldSession::HandleSetTaxiBenchmarkOpcode( WorldPacket
& recv_data
)
1485 sLog
.outDebug("Client used \"/timetest %d\" command", mode
);
1488 void WorldSession::HandleQueryInspectAchievements( WorldPacket
& recv_data
)
1491 if(!recv_data
.readPackGUID(guid
))
1494 Player
*player
= objmgr
.GetPlayer(guid
);
1498 player
->GetAchievementMgr().SendRespondInspectAchievements(_player
);