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::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()->HasUnitMovementFlag(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 _player
->SetFactionVisibleForFactionTemplateId(unit
->getFaction());
411 void WorldSession::HandleSetSelectionOpcode( WorldPacket
& recv_data
)
413 CHECK_PACKET_SIZE(recv_data
,8);
418 _player
->SetSelection(guid
);
420 // update reputation list if need
421 Unit
* unit
= ObjectAccessor::GetUnit(*_player
, guid
);
425 _player
->SetFactionVisibleForFactionTemplateId(unit
->getFaction());
428 void WorldSession::HandleStandStateChangeOpcode( WorldPacket
& recv_data
)
430 CHECK_PACKET_SIZE(recv_data
,1);
432 sLog
.outDebug( "WORLD: Received CMSG_STAND_STATE_CHANGE" );
434 recv_data
>> animstate
;
436 _player
->SetStandState(animstate
);
439 void WorldSession::HandleFriendListOpcode( WorldPacket
& recv_data
)
441 CHECK_PACKET_SIZE(recv_data
, 4);
442 sLog
.outDebug( "WORLD: Received CMSG_CONTACT_LIST" );
445 sLog
.outDebug("unk value is %u", unk
);
446 _player
->GetSocial()->SendSocialList();
449 void WorldSession::HandleAddFriendOpcode( WorldPacket
& recv_data
)
451 CHECK_PACKET_SIZE(recv_data
, 1+1);
453 sLog
.outDebug( "WORLD: Received CMSG_ADD_FRIEND" );
455 std::string friendName
= GetMangosString(LANG_FRIEND_IGNORE_UNKNOWN
);
456 std::string friendNote
;
458 recv_data
>> friendName
;
461 CHECK_PACKET_SIZE(recv_data
, (friendName
.size()+1)+1);
463 recv_data
>> friendNote
;
465 if(!normalizePlayerName(friendName
))
468 CharacterDatabase
.escape_string(friendName
); // prevent SQL injection - normal name don't must changed by this call
470 sLog
.outDebug( "WORLD: %s asked to add friend : '%s'",
471 GetPlayer()->GetName(), friendName
.c_str() );
473 CharacterDatabase
.AsyncPQuery(&WorldSession::HandleAddFriendOpcodeCallBack
, GetAccountId(), friendNote
, "SELECT guid, race FROM characters WHERE name = '%s'", friendName
.c_str());
476 void WorldSession::HandleAddFriendOpcodeCallBack(QueryResult
*result
, uint32 accountId
, std::string friendNote
)
481 uint64 friendGuid
= MAKE_NEW_GUID((*result
)[0].GetUInt32(), 0, HIGHGUID_PLAYER
);
482 uint32 team
= Player::TeamForRace((*result
)[1].GetUInt8());
486 WorldSession
* session
= sWorld
.FindSession(accountId
);
487 if(!session
|| !session
->GetPlayer())
490 FriendsResult friendResult
= FRIEND_NOT_FOUND
;
493 if(friendGuid
==session
->GetPlayer()->GetGUID())
494 friendResult
= FRIEND_SELF
;
495 else if(session
->GetPlayer()->GetTeam() != team
&& !sWorld
.getConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND
) && session
->GetSecurity() < SEC_MODERATOR
)
496 friendResult
= FRIEND_ENEMY
;
497 else if(session
->GetPlayer()->GetSocial()->HasFriend(GUID_LOPART(friendGuid
)))
498 friendResult
= FRIEND_ALREADY
;
501 Player
* pFriend
= ObjectAccessor::FindPlayer(friendGuid
);
502 if( pFriend
&& pFriend
->IsInWorld() && pFriend
->IsVisibleGloballyFor(session
->GetPlayer()))
503 friendResult
= FRIEND_ADDED_ONLINE
;
505 friendResult
= FRIEND_ADDED_OFFLINE
;
507 if(!session
->GetPlayer()->GetSocial()->AddToSocialList(GUID_LOPART(friendGuid
), false))
509 friendResult
= FRIEND_LIST_FULL
;
510 sLog
.outDebug( "WORLD: %s's friend list is full.", session
->GetPlayer()->GetName());
513 session
->GetPlayer()->GetSocial()->SetFriendNote(GUID_LOPART(friendGuid
), friendNote
);
517 sSocialMgr
.SendFriendStatus(session
->GetPlayer(), friendResult
, GUID_LOPART(friendGuid
), false);
519 sLog
.outDebug( "WORLD: Sent (SMSG_FRIEND_STATUS)" );
522 void WorldSession::HandleDelFriendOpcode( WorldPacket
& recv_data
)
524 CHECK_PACKET_SIZE(recv_data
, 8);
528 sLog
.outDebug( "WORLD: Received CMSG_DEL_FRIEND" );
530 recv_data
>> FriendGUID
;
532 _player
->GetSocial()->RemoveFromSocialList(GUID_LOPART(FriendGUID
), false);
534 sSocialMgr
.SendFriendStatus(GetPlayer(), FRIEND_REMOVED
, GUID_LOPART(FriendGUID
), false);
536 sLog
.outDebug( "WORLD: Sent motd (SMSG_FRIEND_STATUS)" );
539 void WorldSession::HandleAddIgnoreOpcode( WorldPacket
& recv_data
)
541 CHECK_PACKET_SIZE(recv_data
,1);
543 sLog
.outDebug( "WORLD: Received CMSG_ADD_IGNORE" );
545 std::string IgnoreName
= GetMangosString(LANG_FRIEND_IGNORE_UNKNOWN
);
547 recv_data
>> IgnoreName
;
549 if(!normalizePlayerName(IgnoreName
))
552 CharacterDatabase
.escape_string(IgnoreName
); // prevent SQL injection - normal name don't must changed by this call
554 sLog
.outDebug( "WORLD: %s asked to Ignore: '%s'",
555 GetPlayer()->GetName(), IgnoreName
.c_str() );
557 CharacterDatabase
.AsyncPQuery(&WorldSession::HandleAddIgnoreOpcodeCallBack
, GetAccountId(), "SELECT guid FROM characters WHERE name = '%s'", IgnoreName
.c_str());
560 void WorldSession::HandleAddIgnoreOpcodeCallBack(QueryResult
*result
, uint32 accountId
)
565 uint64 IgnoreGuid
= MAKE_NEW_GUID((*result
)[0].GetUInt32(), 0, HIGHGUID_PLAYER
);
569 WorldSession
* session
= sWorld
.FindSession(accountId
);
570 if(!session
|| !session
->GetPlayer())
573 FriendsResult ignoreResult
= FRIEND_IGNORE_NOT_FOUND
;
576 if(IgnoreGuid
==session
->GetPlayer()->GetGUID()) //not add yourself
577 ignoreResult
= FRIEND_IGNORE_SELF
;
578 else if( session
->GetPlayer()->GetSocial()->HasIgnore(GUID_LOPART(IgnoreGuid
)) )
579 ignoreResult
= FRIEND_IGNORE_ALREADY
;
582 ignoreResult
= FRIEND_IGNORE_ADDED
;
585 if(!session
->GetPlayer()->GetSocial()->AddToSocialList(GUID_LOPART(IgnoreGuid
), true))
586 ignoreResult
= FRIEND_IGNORE_FULL
;
590 sSocialMgr
.SendFriendStatus(session
->GetPlayer(), ignoreResult
, GUID_LOPART(IgnoreGuid
), false);
592 sLog
.outDebug( "WORLD: Sent (SMSG_FRIEND_STATUS)" );
595 void WorldSession::HandleDelIgnoreOpcode( WorldPacket
& recv_data
)
597 CHECK_PACKET_SIZE(recv_data
, 8);
601 sLog
.outDebug( "WORLD: Received CMSG_DEL_IGNORE" );
603 recv_data
>> IgnoreGUID
;
605 _player
->GetSocial()->RemoveFromSocialList(GUID_LOPART(IgnoreGUID
), true);
607 sSocialMgr
.SendFriendStatus(GetPlayer(), FRIEND_IGNORE_REMOVED
, GUID_LOPART(IgnoreGUID
), false);
609 sLog
.outDebug( "WORLD: Sent motd (SMSG_FRIEND_STATUS)" );
612 void WorldSession::HandleSetFriendNoteOpcode( WorldPacket
& recv_data
)
614 CHECK_PACKET_SIZE(recv_data
, 8+1);
617 recv_data
>> guid
>> note
;
618 _player
->GetSocial()->SetFriendNote(guid
, note
);
621 void WorldSession::HandleBugOpcode( WorldPacket
& recv_data
)
623 CHECK_PACKET_SIZE(recv_data
,4+4+1+4+1);
625 uint32 suggestion
, contentlen
;
630 recv_data
>> suggestion
>> contentlen
>> content
;
633 CHECK_PACKET_SIZE(recv_data
,4+4+(content
.size()+1)+4+1);
635 recv_data
>> typelen
>> type
;
637 if( suggestion
== 0 )
638 sLog
.outDebug( "WORLD: Received CMSG_BUG [Bug Report]" );
640 sLog
.outDebug( "WORLD: Received CMSG_BUG [Suggestion]" );
642 sLog
.outDebug( type
.c_str( ) );
643 sLog
.outDebug( content
.c_str( ) );
645 CharacterDatabase
.escape_string(type
);
646 CharacterDatabase
.escape_string(content
);
647 CharacterDatabase
.PExecute ("INSERT INTO bugreport (type,content) VALUES('%s', '%s')", type
.c_str( ), content
.c_str( ));
650 void WorldSession::HandleCorpseReclaimOpcode(WorldPacket
&recv_data
)
652 CHECK_PACKET_SIZE(recv_data
,8);
654 sLog
.outDetail("WORLD: Received CMSG_RECLAIM_CORPSE");
655 if (GetPlayer()->isAlive())
658 // do not allow corpse reclaim in arena
659 if (GetPlayer()->InArena())
662 // body not released yet
663 if(!GetPlayer()->HasFlag(PLAYER_FLAGS
, PLAYER_FLAGS_GHOST
))
666 Corpse
*corpse
= GetPlayer()->GetCorpse();
671 // prevent resurrect before 30-sec delay after body release not finished
672 if(corpse
->GetGhostTime() + GetPlayer()->GetCorpseReclaimDelay(corpse
->GetType()==CORPSE_RESURRECTABLE_PVP
) > time(NULL
))
675 float dist
= corpse
->GetDistance2d(GetPlayer());
676 sLog
.outDebug("Corpse 2D Distance: \t%f",dist
);
677 if (dist
> CORPSE_RECLAIM_RADIUS
)
684 GetPlayer()->ResurrectPlayer(GetPlayer()->InBattleGround() ? 1.0f
: 0.5f
);
687 GetPlayer()->SpawnCorpseBones();
689 GetPlayer()->SaveToDB();
692 void WorldSession::HandleResurrectResponseOpcode(WorldPacket
& recv_data
)
694 CHECK_PACKET_SIZE(recv_data
,8+1);
696 sLog
.outDetail("WORLD: Received CMSG_RESURRECT_RESPONSE");
698 if(GetPlayer()->isAlive())
708 GetPlayer()->clearResurrectRequestData(); // reject
712 if(!GetPlayer()->isRessurectRequestedBy(guid
))
715 GetPlayer()->ResurectUsingRequestData();
716 GetPlayer()->SaveToDB();
719 void WorldSession::HandleAreaTriggerOpcode(WorldPacket
& recv_data
)
721 CHECK_PACKET_SIZE(recv_data
,4);
723 sLog
.outDebug("WORLD: Received CMSG_AREATRIGGER");
727 recv_data
>> Trigger_ID
;
728 sLog
.outDebug("Trigger ID:%u",Trigger_ID
);
730 if(GetPlayer()->isInFlight())
732 sLog
.outDebug("Player '%s' (GUID: %u) in flight, ignore Area Trigger ID:%u",GetPlayer()->GetName(),GetPlayer()->GetGUIDLow(), Trigger_ID
);
736 AreaTriggerEntry
const* atEntry
= sAreaTriggerStore
.LookupEntry(Trigger_ID
);
739 sLog
.outDebug("Player '%s' (GUID: %u) send unknown (by DBC) Area Trigger ID:%u",GetPlayer()->GetName(),GetPlayer()->GetGUIDLow(), Trigger_ID
);
743 if (GetPlayer()->GetMapId()!=atEntry
->mapid
)
745 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
);
749 // delta is safe radius
750 const float delta
= 5.0f
;
751 // check if player in the range of areatrigger
752 Player
* pl
= GetPlayer();
754 if (atEntry
->radius
> 0)
756 // if we have radius check it
757 float dist
= pl
->GetDistance(atEntry
->x
,atEntry
->y
,atEntry
->z
);
758 if(dist
> atEntry
->radius
+ delta
)
760 sLog
.outDebug("Player '%s' (GUID: %u) too far (radius: %f distance: %f), ignore Area Trigger ID: %u",
761 pl
->GetName(), pl
->GetGUIDLow(), atEntry
->radius
, dist
, Trigger_ID
);
767 // we have only extent
768 float dx
= pl
->GetPositionX() - atEntry
->x
;
769 float dy
= pl
->GetPositionY() - atEntry
->y
;
770 float dz
= pl
->GetPositionZ() - atEntry
->z
;
771 double es
= sin(atEntry
->box_orientation
);
772 double ec
= cos(atEntry
->box_orientation
);
773 // calc rotated vector based on extent axis
774 double rotateDx
= dx
*ec
- dy
*es
;
775 double rotateDy
= dx
*es
+ dy
*ec
;
777 if( (fabs(rotateDx
) > atEntry
->box_x
/2 + delta
) ||
778 (fabs(rotateDy
) > atEntry
->box_y
/2 + delta
) ||
779 (fabs(dz
) > atEntry
->box_z
/2 + delta
) )
781 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",
782 pl
->GetName(), pl
->GetGUIDLow(), atEntry
->box_x
/2, atEntry
->box_y
/2, atEntry
->box_z
/2, rotateDx
, rotateDy
, dz
, Trigger_ID
);
787 if(Script
->scriptAreaTrigger(GetPlayer(), atEntry
))
790 uint32 quest_id
= objmgr
.GetQuestForAreaTrigger( Trigger_ID
);
791 if( quest_id
&& GetPlayer()->isAlive() && GetPlayer()->IsActiveQuest(quest_id
) )
793 Quest
const* pQuest
= objmgr
.GetQuestTemplate(quest_id
);
796 if(GetPlayer()->GetQuestStatus(quest_id
) == QUEST_STATUS_INCOMPLETE
)
797 GetPlayer()->AreaExploredOrEventHappens( quest_id
);
801 if(objmgr
.IsTavernAreaTrigger(Trigger_ID
))
803 // set resting flag we are in the inn
804 GetPlayer()->SetFlag(PLAYER_FLAGS
, PLAYER_FLAGS_RESTING
);
805 GetPlayer()->InnEnter(time(NULL
), atEntry
->mapid
, atEntry
->x
, atEntry
->y
, atEntry
->z
);
806 GetPlayer()->SetRestType(REST_TYPE_IN_TAVERN
);
808 if(sWorld
.IsFFAPvPRealm())
809 GetPlayer()->RemoveByteFlag(UNIT_FIELD_BYTES_2
, 1, UNIT_BYTE2_FLAG_FFA_PVP
);
814 if(GetPlayer()->InBattleGround())
816 BattleGround
* bg
= GetPlayer()->GetBattleGround();
818 if(bg
->GetStatus() == STATUS_IN_PROGRESS
)
819 bg
->HandleAreaTrigger(GetPlayer(), Trigger_ID
);
824 // NULL if all values default (non teleport trigger)
825 AreaTrigger
const* at
= objmgr
.GetAreaTrigger(Trigger_ID
);
829 if(!GetPlayer()->isGameMaster())
831 uint32 missingLevel
= 0;
832 if(GetPlayer()->getLevel() < at
->requiredLevel
&& !sWorld
.getConfig(CONFIG_INSTANCE_IGNORE_LEVEL
))
833 missingLevel
= at
->requiredLevel
;
835 // must have one or the other, report the first one that's missing
836 uint32 missingItem
= 0;
839 if(!GetPlayer()->HasItemCount(at
->requiredItem
, 1) &&
840 (!at
->requiredItem2
|| !GetPlayer()->HasItemCount(at
->requiredItem2
, 1)))
841 missingItem
= at
->requiredItem
;
843 else if(at
->requiredItem2
&& !GetPlayer()->HasItemCount(at
->requiredItem2
, 1))
844 missingItem
= at
->requiredItem2
;
846 uint32 missingKey
= 0;
847 if(GetPlayer()->GetDifficulty() == DIFFICULTY_HEROIC
)
851 if(!GetPlayer()->HasItemCount(at
->heroicKey
, 1) &&
852 (!at
->heroicKey2
|| !GetPlayer()->HasItemCount(at
->heroicKey2
, 1)))
853 missingKey
= at
->heroicKey
;
855 else if(at
->heroicKey2
&& !GetPlayer()->HasItemCount(at
->heroicKey2
, 1))
856 missingKey
= at
->heroicKey2
;
859 uint32 missingQuest
= 0;
860 if(GetPlayer()->GetDifficulty() == DIFFICULTY_HEROIC
)
862 if (at
->requiredQuestHeroic
&& !GetPlayer()->GetQuestRewardStatus(at
->requiredQuestHeroic
))
863 missingQuest
= at
->requiredQuestHeroic
;
867 if(at
->requiredQuest
&& !GetPlayer()->GetQuestRewardStatus(at
->requiredQuest
))
868 missingQuest
= at
->requiredQuest
;
871 if(missingLevel
|| missingItem
|| missingKey
|| missingQuest
)
873 // TODO: all this is probably wrong
875 SendAreaTriggerMessage(GetMangosString(LANG_LEVEL_MINREQUIRED_AND_ITEM
), at
->requiredLevel
, objmgr
.GetItemPrototype(missingItem
)->Name1
);
877 GetPlayer()->SendTransferAborted(at
->target_mapId
, TRANSFER_ABORT_DIFFICULTY
, DIFFICULTY_HEROIC
);
878 else if(missingQuest
)
879 SendAreaTriggerMessage(at
->requiredFailedText
.c_str());
880 else if(missingLevel
)
881 SendAreaTriggerMessage(GetMangosString(LANG_LEVEL_MINREQUIRED
), missingLevel
);
886 GetPlayer()->TeleportTo(at
->target_mapId
,at
->target_X
,at
->target_Y
,at
->target_Z
,at
->target_Orientation
,TELE_TO_NOT_LEAVE_TRANSPORT
);
889 void WorldSession::HandleUpdateAccountData(WorldPacket
&recv_data
)
891 sLog
.outDetail("WORLD: Received CMSG_UPDATE_ACCOUNT_DATA");
893 CHECK_PACKET_SIZE(recv_data
, 4+4+4);
895 uint32 type
, timestamp
, decompressedSize
;
896 recv_data
>> type
>> timestamp
>> decompressedSize
;
898 sLog
.outDebug("UAD: type %u, time %u, decompressedSize %u", type
, timestamp
, decompressedSize
);
900 if(type
> NUM_ACCOUNT_DATA_TYPES
)
903 if(decompressedSize
== 0) // erase
905 SetAccountData(type
, timestamp
, "");
907 WorldPacket
data(SMSG_UPDATE_ACCOUNT_DATA_COMPLETE
, 4+4);
908 data
<< uint32(type
);
915 if(decompressedSize
> 0xFFFF)
917 sLog
.outError("UAD: Account data packet too big, size %u", decompressedSize
);
922 dest
.resize(decompressedSize
);
924 uLongf realSize
= decompressedSize
;
925 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
)
927 sLog
.outError("UAD: Failed to decompress account data");
934 SetAccountData(type
, timestamp
, adata
);
936 WorldPacket
data(SMSG_UPDATE_ACCOUNT_DATA_COMPLETE
, 4+4);
937 data
<< uint32(type
);
942 void WorldSession::HandleRequestAccountData(WorldPacket
& recv_data
)
944 sLog
.outDetail("WORLD: Received CMSG_REQUEST_ACCOUNT_DATA");
946 CHECK_PACKET_SIZE(recv_data
, 4);
951 sLog
.outDebug("RAD: type %u", type
);
953 if(type
> NUM_ACCOUNT_DATA_TYPES
)
956 AccountData
*adata
= GetAccountData(type
);
958 uint32 size
= adata
->Data
.size();
963 uLongf destSize
= size
;
964 if(size
&& compress(const_cast<uint8
*>(dest
.contents()), &destSize
, (uint8
*)adata
->Data
.c_str(), size
) != Z_OK
)
966 sLog
.outDebug("RAD: Failed to compress account data");
970 dest
.resize(destSize
);
972 WorldPacket
data (SMSG_UPDATE_ACCOUNT_DATA
, 8+4+4+4+destSize
);
973 data
<< uint64(_player
->GetGUID()); // player guid
974 data
<< uint32(type
); // type (0-7)
975 data
<< uint32(adata
->Time
); // unix time
976 data
<< uint32(size
); // decompressed length
977 data
.append(dest
); // compressed data
981 void WorldSession::HandleSetActionButtonOpcode(WorldPacket
& recv_data
)
983 CHECK_PACKET_SIZE(recv_data
,1+2+1+1);
985 sLog
.outDebug( "WORLD: Received CMSG_SET_ACTION_BUTTON" );
986 uint8 button
, misc
, type
;
988 recv_data
>> button
>> action
>> misc
>> type
;
989 sLog
.outDetail( "BUTTON: %u ACTION: %u TYPE: %u MISC: %u", button
, action
, type
, misc
);
992 sLog
.outDetail( "MISC: Remove action from button %u", button
);
994 GetPlayer()->removeActionButton(button
);
998 if(type
==ACTION_BUTTON_MACRO
|| type
==ACTION_BUTTON_CMACRO
)
1000 sLog
.outDetail( "MISC: Added Macro %u into button %u", action
, button
);
1001 GetPlayer()->addActionButton(button
,action
,type
,misc
);
1003 else if(type
==ACTION_BUTTON_SPELL
)
1005 sLog
.outDetail( "MISC: Added Action %u into button %u", action
, button
);
1006 GetPlayer()->addActionButton(button
,action
,type
,misc
);
1008 else if(type
==ACTION_BUTTON_ITEM
)
1010 sLog
.outDetail( "MISC: Added Item %u into button %u", action
, button
);
1011 GetPlayer()->addActionButton(button
,action
,type
,misc
);
1014 sLog
.outError( "MISC: Unknown action button type %u for action %u into button %u", type
, action
, button
);
1018 void WorldSession::HandleCompleteCinema( WorldPacket
& /*recv_data*/ )
1020 DEBUG_LOG( "WORLD: Player is watching cinema" );
1023 void WorldSession::HandleNextCinematicCamera( WorldPacket
& /*recv_data*/ )
1025 DEBUG_LOG( "WORLD: Which movie to play" );
1028 void WorldSession::HandleMoveTimeSkippedOpcode( WorldPacket
& /*recv_data*/ )
1030 /* WorldSession::Update( getMSTime() );*/
1031 DEBUG_LOG( "WORLD: Time Lag/Synchronization Resent/Update" );
1034 CHECK_PACKET_SIZE(recv_data,8+4);
1036 uint32 time_skipped;
1038 recv_data >> time_skipped;
1039 sLog.outDebug( "WORLD: CMSG_MOVE_TIME_SKIPPED" );
1042 must be need use in mangos
1043 We substract server Lags to move time ( AntiLags )
1045 GetPlayer()->ModifyLastMoveTime( -int32(time_skipped) );
1049 void WorldSession::HandleFeatherFallAck(WorldPacket
&/*recv_data*/)
1051 DEBUG_LOG("WORLD: CMSG_MOVE_FEATHER_FALL_ACK");
1054 void WorldSession::HandleMoveUnRootAck(WorldPacket
&/* recv_data*/)
1057 CHECK_PACKET_SIZE(recv_data,8+8+4+4+4+4+4);
1059 sLog.outDebug( "WORLD: CMSG_FORCE_MOVE_UNROOT_ACK" );
1060 recv_data.hexlike();
1070 recv_data >> unknown1;
1071 recv_data >> unknown2;
1072 recv_data >> PositionX;
1073 recv_data >> PositionY;
1074 recv_data >> PositionZ;
1075 recv_data >> Orientation;
1077 // TODO for later may be we can use for anticheat
1078 DEBUG_LOG("Guid " I64FMTD,guid);
1079 DEBUG_LOG("unknown1 " I64FMTD,unknown1);
1080 DEBUG_LOG("unknown2 %u",unknown2);
1081 DEBUG_LOG("X %f",PositionX);
1082 DEBUG_LOG("Y %f",PositionY);
1083 DEBUG_LOG("Z %f",PositionZ);
1084 DEBUG_LOG("O %f",Orientation);
1088 void WorldSession::HandleMoveRootAck(WorldPacket
&/* recv_data*/)
1091 CHECK_PACKET_SIZE(recv_data,8+8+4+4+4+4+4);
1093 sLog.outDebug( "WORLD: CMSG_FORCE_MOVE_ROOT_ACK" );
1094 recv_data.hexlike();
1104 recv_data >> unknown1;
1105 recv_data >> unknown2;
1106 recv_data >> PositionX;
1107 recv_data >> PositionY;
1108 recv_data >> PositionZ;
1109 recv_data >> Orientation;
1111 // for later may be we can use for anticheat
1112 DEBUG_LOG("Guid " I64FMTD,guid);
1113 DEBUG_LOG("unknown1 " I64FMTD,unknown1);
1114 DEBUG_LOG("unknown1 %u",unknown2);
1115 DEBUG_LOG("X %f",PositionX);
1116 DEBUG_LOG("Y %f",PositionY);
1117 DEBUG_LOG("Z %f",PositionZ);
1118 DEBUG_LOG("O %f",Orientation);
1122 void WorldSession::HandleMoveTeleportAck(WorldPacket
&/* recv_data*/)
1125 CHECK_PACKET_SIZE(recv_data,8+4);
1127 sLog.outDebug("MSG_MOVE_TELEPORT_ACK");
1132 recv_data >> flags >> time;
1133 DEBUG_LOG("Guid " I64FMTD,guid);
1134 DEBUG_LOG("Flags %u, time %u",flags, time/IN_MILISECONDS);
1138 void WorldSession::HandleSetActionBar(WorldPacket
& recv_data
)
1140 CHECK_PACKET_SIZE(recv_data
,1);
1144 recv_data
>> ActionBar
;
1146 if(!GetPlayer()) // ignore until not logged (check needed because STATUS_AUTHED)
1149 sLog
.outError("WorldSession::HandleSetActionBar in not logged state with value: %u, ignored",uint32(ActionBar
));
1153 GetPlayer()->SetByteValue(PLAYER_FIELD_BYTES
, 2, ActionBar
);
1156 void WorldSession::HandleWardenDataOpcode(WorldPacket
& /*recv_data*/)
1159 CHECK_PACKET_SIZE(recv_data,1);
1163 sLog.outDebug("Received opcode CMSG_WARDEN_DATA, not resolve.uint8 = %u",tmp);
1167 void WorldSession::HandlePlayedTime(WorldPacket
& /*recv_data*/)
1169 uint32 TotalTimePlayed
= GetPlayer()->GetTotalPlayedTime();
1170 uint32 LevelPlayedTime
= GetPlayer()->GetLevelPlayedTime();
1172 WorldPacket
data(SMSG_PLAYED_TIME
, 8);
1173 data
<< TotalTimePlayed
;
1174 data
<< LevelPlayedTime
;
1178 void WorldSession::HandleInspectOpcode(WorldPacket
& recv_data
)
1180 CHECK_PACKET_SIZE(recv_data
, 8);
1184 DEBUG_LOG("Inspected guid is " I64FMTD
, guid
);
1186 _player
->SetSelection(guid
);
1188 Player
*plr
= objmgr
.GetPlayer(guid
);
1189 if(!plr
) // wrong player
1192 uint32 talent_points
= 0x3D;
1193 uint32 guid_size
= plr
->GetPackGUID().size();
1194 WorldPacket
data(SMSG_INSPECT_TALENT
, 4+talent_points
);
1195 data
.append(plr
->GetPackGUID());
1196 data
<< uint32(talent_points
);
1198 // fill by 0 talents array
1199 for(uint32 i
= 0; i
< talent_points
; ++i
)
1202 if(sWorld
.getConfig(CONFIG_TALENTS_INSPECTING
) || _player
->isGameMaster())
1204 // find class talent tabs (all players have 3 talent tabs)
1205 uint32
const* talentTabIds
= GetTalentTabPages(plr
->getClass());
1207 uint32 talentTabPos
= 0; // pos of first talent rank in tab including all prev tabs
1208 for(uint32 i
= 0; i
< 3; ++i
)
1210 uint32 talentTabId
= talentTabIds
[i
];
1212 // fill by real data
1213 for(uint32 talentId
= 0; talentId
< sTalentStore
.GetNumRows(); ++talentId
)
1215 TalentEntry
const* talentInfo
= sTalentStore
.LookupEntry(talentId
);
1219 // skip another tab talents
1220 if(talentInfo
->TalentTab
!= talentTabId
)
1224 uint32 curtalent_maxrank
= 0;
1225 for(uint32 k
= 5; k
> 0; --k
)
1227 if(talentInfo
->RankID
[k
-1] && plr
->HasSpell(talentInfo
->RankID
[k
-1]))
1229 curtalent_maxrank
= k
;
1234 // not learned talent
1235 if(!curtalent_maxrank
)
1238 // 1 rank talent bit index
1239 uint32 curtalent_index
= talentTabPos
+ GetTalentInspectBitPosInTab(talentId
);
1241 uint32 curtalent_rank_index
= curtalent_index
+curtalent_maxrank
-1;
1243 // slot/offset in 7-bit bytes
1244 uint32 curtalent_rank_slot7
= curtalent_rank_index
/ 7;
1245 uint32 curtalent_rank_offset7
= curtalent_rank_index
% 7;
1247 // rank pos with skipped 8 bit
1248 uint32 curtalent_rank_index2
= curtalent_rank_slot7
* 8 + curtalent_rank_offset7
;
1250 // slot/offset in 8-bit bytes with skipped high bit
1251 uint32 curtalent_rank_slot
= curtalent_rank_index2
/ 8;
1252 uint32 curtalent_rank_offset
= curtalent_rank_index2
% 8;
1255 uint32 val
= data
.read
<uint8
>(guid_size
+ 4 + curtalent_rank_slot
);
1256 val
|= (1 << curtalent_rank_offset
);
1257 data
.put
<uint8
>(guid_size
+ 4 + curtalent_rank_slot
, val
& 0xFF);
1260 talentTabPos
+= GetTalentTabInspectBitSize(talentTabId
);
1267 void WorldSession::HandleInspectHonorStatsOpcode(WorldPacket
& recv_data
)
1269 CHECK_PACKET_SIZE(recv_data
, 8);
1274 Player
*player
= objmgr
.GetPlayer(guid
);
1278 sLog
.outError("InspectHonorStats: WTF, player not found...");
1282 WorldPacket
data(MSG_INSPECT_HONOR_STATS
, 8+1+4*4);
1283 data
<< uint64(player
->GetGUID());
1284 data
<< uint8(player
->GetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY
));
1285 data
<< uint32(player
->GetUInt32Value(PLAYER_FIELD_KILLS
));
1286 data
<< uint32(player
->GetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION
));
1287 data
<< uint32(player
->GetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION
));
1288 data
<< uint32(player
->GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORBALE_KILLS
));
1292 void WorldSession::HandleWorldTeleportOpcode(WorldPacket
& recv_data
)
1294 CHECK_PACKET_SIZE(recv_data
,4+4+4+4+4+4);
1296 // write in client console: worldport 469 452 6454 2536 180 or /console worldport 469 452 6454 2536 180
1297 // Received opcode CMSG_WORLD_TELEPORT
1298 // Time is ***, map=469, x=452.000000, y=6454.000000, z=2536.000000, orient=3.141593
1300 //sLog.outDebug("Received opcode CMSG_WORLD_TELEPORT");
1302 if(GetPlayer()->isInFlight())
1304 sLog
.outDebug("Player '%s' (GUID: %u) in flight, ignore worldport command.",GetPlayer()->GetName(),GetPlayer()->GetGUIDLow());
1315 recv_data
>> time
; // time in m.sec.
1317 recv_data
>> PositionX
;
1318 recv_data
>> PositionY
;
1319 recv_data
>> PositionZ
;
1320 recv_data
>> Orientation
; // o (3.141593 = 180 degrees)
1321 DEBUG_LOG("Time %u sec, map=%u, x=%f, y=%f, z=%f, orient=%f", time
/1000, mapid
, PositionX
, PositionY
, PositionZ
, Orientation
);
1323 if (GetSecurity() >= SEC_ADMINISTRATOR
)
1324 GetPlayer()->TeleportTo(mapid
,PositionX
,PositionY
,PositionZ
,Orientation
);
1326 SendNotification(LANG_YOU_NOT_HAVE_PERMISSION
);
1327 sLog
.outDebug("Received worldport command from player %s", GetPlayer()->GetName());
1330 void WorldSession::HandleWhoisOpcode(WorldPacket
& recv_data
)
1332 CHECK_PACKET_SIZE(recv_data
, 1);
1334 sLog
.outDebug("Received opcode CMSG_WHOIS");
1335 std::string charname
;
1336 recv_data
>> charname
;
1338 if (GetSecurity() < SEC_ADMINISTRATOR
)
1340 SendNotification(LANG_YOU_NOT_HAVE_PERMISSION
);
1344 if(charname
.empty() || !normalizePlayerName (charname
))
1346 SendNotification(LANG_NEED_CHARACTER_NAME
);
1350 Player
*plr
= objmgr
.GetPlayer(charname
.c_str());
1354 SendNotification(LANG_PLAYER_NOT_EXIST_OR_OFFLINE
, charname
.c_str());
1358 uint32 accid
= plr
->GetSession()->GetAccountId();
1360 QueryResult
*result
= loginDatabase
.PQuery("SELECT username,email,last_ip FROM account WHERE id=%u", accid
);
1363 SendNotification(LANG_ACCOUNT_FOR_PLAYER_NOT_FOUND
, charname
.c_str());
1367 Field
*fields
= result
->Fetch();
1368 std::string acc
= fields
[0].GetCppString();
1371 std::string email
= fields
[1].GetCppString();
1374 std::string lastip
= fields
[2].GetCppString();
1378 std::string msg
= charname
+ "'s " + "account is " + acc
+ ", e-mail: " + email
+ ", last ip: " + lastip
;
1380 WorldPacket
data(SMSG_WHOIS
, msg
.size()+1);
1382 _player
->GetSession()->SendPacket(&data
);
1386 sLog
.outDebug("Received whois command from player %s for character %s", GetPlayer()->GetName(), charname
.c_str());
1389 void WorldSession::HandleReportSpamOpcode( WorldPacket
& recv_data
)
1391 CHECK_PACKET_SIZE(recv_data
, 1+8);
1392 sLog
.outDebug("WORLD: CMSG_REPORT_SPAM");
1393 recv_data
.hexlike();
1395 uint8 spam_type
; // 0 - mail, 1 - chat
1396 uint64 spammer_guid
;
1397 uint32 unk1
, unk2
, unk3
, unk4
= 0;
1398 std::string description
= "";
1399 recv_data
>> spam_type
; // unk 0x01 const, may be spam type (mail/chat)
1400 recv_data
>> spammer_guid
; // player guid
1404 CHECK_PACKET_SIZE(recv_data
, recv_data
.rpos()+4+4+4);
1405 recv_data
>> unk1
; // const 0
1406 recv_data
>> unk2
; // probably mail id
1407 recv_data
>> unk3
; // const 0
1410 CHECK_PACKET_SIZE(recv_data
, recv_data
.rpos()+4+4+4+4+1);
1411 recv_data
>> unk1
; // probably language
1412 recv_data
>> unk2
; // message type?
1413 recv_data
>> unk3
; // probably channel id
1414 recv_data
>> unk4
; // unk random value
1415 recv_data
>> description
; // spam description string (messagetype, channel name, player name, message)
1419 // NOTE: all chat messages from this spammer automatically ignored by spam reporter until logout in case chat spam.
1420 // if it's mail spam - ALL mails from this spammer automatically removed by client
1422 // Complaint Received message
1423 WorldPacket
data(SMSG_COMPLAIN_RESULT
, 1);
1427 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());
1430 void WorldSession::HandleRealmStateRequestOpcode( WorldPacket
& recv_data
)
1432 CHECK_PACKET_SIZE(recv_data
, 4);
1434 sLog
.outDebug("CMSG_REALM_SPLIT");
1437 std::string split_date
= "01/01/01";
1440 WorldPacket
data(SMSG_REALM_SPLIT
, 4+4+split_date
.size()+1);
1442 data
<< uint32(0x00000000); // realm split state
1446 // 0x2 realm split pending
1449 //sLog.outDebug("response sent %u", unk);
1452 void WorldSession::HandleFarSightOpcode( WorldPacket
& recv_data
)
1454 CHECK_PACKET_SIZE(recv_data
, 1);
1456 sLog
.outDebug("WORLD: CMSG_FAR_SIGHT");
1457 //recv_data.hexlike();
1465 //WorldPacket data(SMSG_CLEAR_FAR_SIGHT_IMMEDIATE, 0)
1466 //SendPacket(&data);
1467 //_player->SetUInt64Value(PLAYER_FARSIGHT, 0);
1468 sLog
.outDebug("Removed FarSight from player %u", _player
->GetGUIDLow());
1471 sLog
.outDebug("Added FarSight " I64FMT
" to player %u", _player
->GetFarSight(), _player
->GetGUIDLow());
1476 void WorldSession::HandleChooseTitleOpcode( WorldPacket
& recv_data
)
1478 CHECK_PACKET_SIZE(recv_data
, 4);
1480 sLog
.outDebug("CMSG_SET_TITLE");
1486 if(title
> 0 && title
< 128)
1488 if(!GetPlayer()->HasTitle(title
))
1494 GetPlayer()->SetUInt32Value(PLAYER_CHOSEN_TITLE
, title
);
1497 void WorldSession::HandleTimeSyncResp( WorldPacket
& recv_data
)
1499 CHECK_PACKET_SIZE(recv_data
, 4+4);
1501 sLog
.outDebug("CMSG_TIME_SYNC_RESP");
1503 uint32 counter
, time_
;
1504 recv_data
>> counter
>> time_
;
1506 // time_ seems always more than getMSTime()
1507 uint32 diff
= getMSTimeDiff(getMSTime(),time_
);
1509 sLog
.outDebug("response sent: counter %u, time %u (HEX: %X), ms. time %u, diff %u", counter
, time_
, time_
, getMSTime(), diff
);
1512 void WorldSession::HandleResetInstancesOpcode( WorldPacket
& /*recv_data*/ )
1514 sLog
.outDebug("WORLD: CMSG_RESET_INSTANCES");
1515 Group
*pGroup
= _player
->GetGroup();
1518 if(pGroup
->IsLeader(_player
->GetGUID()))
1519 pGroup
->ResetInstances(INSTANCE_RESET_ALL
, _player
);
1522 _player
->ResetInstances(INSTANCE_RESET_ALL
);
1525 void WorldSession::HandleDungeonDifficultyOpcode( WorldPacket
& recv_data
)
1527 CHECK_PACKET_SIZE(recv_data
, 4);
1529 sLog
.outDebug("MSG_SET_DUNGEON_DIFFICULTY");
1534 if(mode
== _player
->GetDifficulty())
1537 if(mode
> DIFFICULTY_HEROIC
)
1539 sLog
.outError("WorldSession::HandleDungeonDifficultyOpcode: player %d sent an invalid instance mode %d!", _player
->GetGUIDLow(), mode
);
1543 // cannot reset while in an instance
1544 Map
*map
= _player
->GetMap();
1545 if(map
&& map
->IsDungeon())
1547 sLog
.outError("WorldSession::HandleDungeonDifficultyOpcode: player %d tried to reset the instance while inside!", _player
->GetGUIDLow());
1551 if(_player
->getLevel() < LEVELREQUIREMENT_HEROIC
)
1553 Group
*pGroup
= _player
->GetGroup();
1556 if(pGroup
->IsLeader(_player
->GetGUID()))
1558 // the difficulty is set even if the instances can't be reset
1559 //_player->SendDungeonDifficulty(true);
1560 pGroup
->ResetInstances(INSTANCE_RESET_CHANGE_DIFFICULTY
, _player
);
1561 pGroup
->SetDifficulty(mode
);
1566 _player
->ResetInstances(INSTANCE_RESET_CHANGE_DIFFICULTY
);
1567 _player
->SetDifficulty(mode
);
1571 void WorldSession::HandleDismountOpcode( WorldPacket
& /*recv_data*/ )
1573 sLog
.outDebug("WORLD: CMSG_CANCEL_MOUNT_AURA");
1574 //recv_data.hexlike();
1576 //If player is not mounted, so go out :)
1577 if (!_player
->IsMounted()) // not blizz like; no any messages on blizz
1579 ChatHandler(this).SendSysMessage(LANG_CHAR_NON_MOUNTED
);
1583 if(_player
->isInFlight()) // not blizz like; no any messages on blizz
1585 ChatHandler(this).SendSysMessage(LANG_YOU_IN_FLIGHT
);
1590 _player
->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED
);
1593 void WorldSession::HandleMoveFlyModeChangeAckOpcode( WorldPacket
& recv_data
)
1595 CHECK_PACKET_SIZE(recv_data
, 8+4+4);
1598 sLog
.outDebug("WORLD: CMSG_MOVE_SET_CAN_FLY_ACK");
1599 //recv_data.hexlike();
1605 recv_data
>> guid
>> unk
>> flags
;
1607 _player
->SetUnitMovementFlags(flags
);
1610 25 00 00 00 00 00 00 00 | 00 00 00 00 00 00 80 00
1611 85 4E A9 01 19 BA 7A C3 | 42 0D 70 44 44 B0 A8 42
1612 78 15 94 40 39 03 00 00 | 00 00 80 3F
1614 25 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00
1615 10 FD A9 01 19 BA 7A C3 | 42 0D 70 44 44 B0 A8 42
1616 78 15 94 40 39 03 00 00 | 00 00 00 00
1620 void WorldSession::HandleRequestPetInfoOpcode( WorldPacket
& /*recv_data */)
1623 sLog.outDebug("WORLD: CMSG_REQUEST_PET_INFO");
1624 recv_data.hexlike();
1628 void WorldSession::HandleSetTaxiBenchmarkOpcode( WorldPacket
& recv_data
)
1630 CHECK_PACKET_SIZE(recv_data
, 1);
1635 sLog
.outDebug("Client used \"/timetest %d\" command", mode
);
1638 void WorldSession::HandleSpellClick( WorldPacket
& recv_data
)
1640 CHECK_PACKET_SIZE(recv_data
, 8);
1645 Vehicle
*vehicle
= ObjectAccessor::GetVehicle(guid
);
1650 _player
->EnterVehicle(vehicle
);
1653 void WorldSession::HandleInspectAchievements( WorldPacket
& recv_data
)
1655 CHECK_PACKET_SIZE(recv_data
, 1);
1657 if(!recv_data
.readPackGUID(guid
))
1660 Player
*player
= objmgr
.GetPlayer(guid
);
1664 player
->GetAchievementMgr().SendRespondInspectAchievements(_player
);