1 | /* |
---|
2 | * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> |
---|
3 | * |
---|
4 | * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> |
---|
5 | * |
---|
6 | * This program is free software; you can redistribute it and/or modify |
---|
7 | * it under the terms of the GNU General Public License as published by |
---|
8 | * the Free Software Foundation; either version 2 of the License, or |
---|
9 | * (at your option) any later version. |
---|
10 | * |
---|
11 | * This program is distributed in the hope that it will be useful, |
---|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | * GNU General Public License for more details. |
---|
15 | * |
---|
16 | * You should have received a copy of the GNU General Public License |
---|
17 | * along with this program; if not, write to the Free Software |
---|
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
19 | */ |
---|
20 | |
---|
21 | #include "Common.h" |
---|
22 | #include "Language.h" |
---|
23 | #include "Database/DatabaseEnv.h" |
---|
24 | #include "Database/DatabaseImpl.h" |
---|
25 | #include "WorldPacket.h" |
---|
26 | #include "Opcodes.h" |
---|
27 | #include "Log.h" |
---|
28 | #include "Player.h" |
---|
29 | #include "World.h" |
---|
30 | #include "ObjectMgr.h" |
---|
31 | #include "WorldSession.h" |
---|
32 | #include "Auth/BigNumber.h" |
---|
33 | #include "Auth/Sha1.h" |
---|
34 | #include "UpdateData.h" |
---|
35 | #include "LootMgr.h" |
---|
36 | #include "Chat.h" |
---|
37 | #include "ScriptCalls.h" |
---|
38 | #include <zlib/zlib.h> |
---|
39 | #include "MapManager.h" |
---|
40 | #include "ObjectAccessor.h" |
---|
41 | #include "Object.h" |
---|
42 | #include "BattleGround.h" |
---|
43 | #include "OutdoorPvP.h" |
---|
44 | #include "SpellAuras.h" |
---|
45 | #include "Pet.h" |
---|
46 | #include "SocialMgr.h" |
---|
47 | #include "CellImpl.h" |
---|
48 | |
---|
49 | void WorldSession::HandleRepopRequestOpcode( WorldPacket & /*recv_data*/ ) |
---|
50 | { |
---|
51 | sLog.outDebug( "WORLD: Recvd CMSG_REPOP_REQUEST Message" ); |
---|
52 | |
---|
53 | if(GetPlayer()->isAlive()||GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) |
---|
54 | return; |
---|
55 | |
---|
56 | // the world update order is sessions, players, creatures |
---|
57 | // the netcode runs in parallel with all of these |
---|
58 | // creatures can kill players |
---|
59 | // so if the server is lagging enough the player can |
---|
60 | // release spirit after he's killed but before he is updated |
---|
61 | if(GetPlayer()->getDeathState() == JUST_DIED) |
---|
62 | { |
---|
63 | sLog.outDebug("HandleRepopRequestOpcode: got request after player %s(%d) was killed and before he was updated", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow()); |
---|
64 | GetPlayer()->KillPlayer(); |
---|
65 | } |
---|
66 | |
---|
67 | //this is spirit release confirm? |
---|
68 | GetPlayer()->RemovePet(NULL,PET_SAVE_NOT_IN_SLOT, true); |
---|
69 | GetPlayer()->BuildPlayerRepop(); |
---|
70 | GetPlayer()->RepopAtGraveyard(); |
---|
71 | } |
---|
72 | |
---|
73 | void WorldSession::HandleWhoOpcode( WorldPacket & recv_data ) |
---|
74 | { |
---|
75 | CHECK_PACKET_SIZE(recv_data,4+4+1+1+4+4+4+4); |
---|
76 | |
---|
77 | sLog.outDebug( "WORLD: Recvd CMSG_WHO Message" ); |
---|
78 | //recv_data.hexlike(); |
---|
79 | |
---|
80 | uint32 clientcount = 0; |
---|
81 | |
---|
82 | uint32 level_min, level_max, racemask, classmask, zones_count, str_count; |
---|
83 | uint32 zoneids[10]; // 10 is client limit |
---|
84 | std::string player_name, guild_name; |
---|
85 | |
---|
86 | recv_data >> level_min; // maximal player level, default 0 |
---|
87 | recv_data >> level_max; // minimal player level, default 100 |
---|
88 | recv_data >> player_name; // player name, case sensitive... |
---|
89 | |
---|
90 | // recheck |
---|
91 | CHECK_PACKET_SIZE(recv_data,4+4+(player_name.size()+1)+1+4+4+4+4); |
---|
92 | |
---|
93 | recv_data >> guild_name; // guild name, case sensitive... |
---|
94 | |
---|
95 | // recheck |
---|
96 | CHECK_PACKET_SIZE(recv_data,4+4+(player_name.size()+1)+(guild_name.size()+1)+4+4+4+4); |
---|
97 | |
---|
98 | recv_data >> racemask; // race mask |
---|
99 | recv_data >> classmask; // class mask |
---|
100 | recv_data >> zones_count; // zones count, client limit=10 (2.0.10) |
---|
101 | |
---|
102 | if(zones_count > 10) |
---|
103 | return; // can't be received from real client or broken packet |
---|
104 | |
---|
105 | // recheck |
---|
106 | CHECK_PACKET_SIZE(recv_data,4+4+(player_name.size()+1)+(guild_name.size()+1)+4+4+4+(4*zones_count)+4); |
---|
107 | |
---|
108 | for(uint32 i = 0; i < zones_count; i++) |
---|
109 | { |
---|
110 | uint32 temp; |
---|
111 | recv_data >> temp; // zone id, 0 if zone is unknown... |
---|
112 | zoneids[i] = temp; |
---|
113 | sLog.outDebug("Zone %u: %u", i, zoneids[i]); |
---|
114 | } |
---|
115 | |
---|
116 | recv_data >> str_count; // user entered strings count, client limit=4 (checked on 2.0.10) |
---|
117 | |
---|
118 | if(str_count > 4) |
---|
119 | return; // can't be received from real client or broken packet |
---|
120 | |
---|
121 | // recheck |
---|
122 | 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)); |
---|
123 | |
---|
124 | 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); |
---|
125 | |
---|
126 | std::wstring str[4]; // 4 is client limit |
---|
127 | for(uint32 i = 0; i < str_count; i++) |
---|
128 | { |
---|
129 | // recheck (have one more byte) |
---|
130 | CHECK_PACKET_SIZE(recv_data,recv_data.rpos()); |
---|
131 | |
---|
132 | std::string temp; |
---|
133 | recv_data >> temp; // user entered string, it used as universal search pattern(guild+player name)? |
---|
134 | |
---|
135 | if(!Utf8toWStr(temp,str[i])) |
---|
136 | continue; |
---|
137 | |
---|
138 | wstrToLower(str[i]); |
---|
139 | |
---|
140 | sLog.outDebug("String %u: %s", i, temp.c_str()); |
---|
141 | } |
---|
142 | |
---|
143 | std::wstring wplayer_name; |
---|
144 | std::wstring wguild_name; |
---|
145 | if(!(Utf8toWStr(player_name, wplayer_name) && Utf8toWStr(guild_name, wguild_name))) |
---|
146 | return; |
---|
147 | wstrToLower(wplayer_name); |
---|
148 | wstrToLower(wguild_name); |
---|
149 | |
---|
150 | // client send in case not set max level value 100 but mangos support 255 max level, |
---|
151 | // update it to show GMs with characters after 100 level |
---|
152 | if(level_max >= 100) |
---|
153 | level_max = 255; |
---|
154 | |
---|
155 | uint32 team = _player->GetTeam(); |
---|
156 | uint32 security = GetSecurity(); |
---|
157 | bool allowTwoSideWhoList = sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_WHO_LIST); |
---|
158 | bool gmInWhoList = sWorld.getConfig(CONFIG_GM_IN_WHO_LIST); |
---|
159 | |
---|
160 | WorldPacket data( SMSG_WHO, 50 ); // guess size |
---|
161 | data << clientcount; // clientcount place holder |
---|
162 | data << clientcount; // clientcount place holder |
---|
163 | |
---|
164 | //TODO: Guard Player map |
---|
165 | HashMapHolder<Player>::MapType& m = ObjectAccessor::Instance().GetPlayers(); |
---|
166 | for(HashMapHolder<Player>::MapType::iterator itr = m.begin(); itr != m.end(); ++itr) |
---|
167 | { |
---|
168 | if (security == SEC_PLAYER) |
---|
169 | { |
---|
170 | // player can see member of other team only if CONFIG_ALLOW_TWO_SIDE_WHO_LIST |
---|
171 | if (itr->second->GetTeam() != team && !allowTwoSideWhoList ) |
---|
172 | continue; |
---|
173 | |
---|
174 | // player can see MODERATOR, GAME MASTER, ADMINISTRATOR only if CONFIG_GM_IN_WHO_LIST |
---|
175 | if ((itr->second->GetSession()->GetSecurity() > SEC_PLAYER && !gmInWhoList)) |
---|
176 | continue; |
---|
177 | } |
---|
178 | |
---|
179 | // check if target is globally visible for player |
---|
180 | if (!(itr->second->IsVisibleGloballyFor(_player))) |
---|
181 | continue; |
---|
182 | |
---|
183 | // check if target's level is in level range |
---|
184 | uint32 lvl = itr->second->getLevel(); |
---|
185 | if (lvl < level_min || lvl > level_max) |
---|
186 | continue; |
---|
187 | |
---|
188 | // check if class matches classmask |
---|
189 | uint32 class_ = itr->second->getClass(); |
---|
190 | if (!(classmask & (1 << class_))) |
---|
191 | continue; |
---|
192 | |
---|
193 | // check if race matches racemask |
---|
194 | uint32 race = itr->second->getRace(); |
---|
195 | if (!(racemask & (1 << race))) |
---|
196 | continue; |
---|
197 | |
---|
198 | uint32 pzoneid = itr->second->GetZoneId(); |
---|
199 | |
---|
200 | bool z_show = true; |
---|
201 | for(uint32 i = 0; i < zones_count; i++) |
---|
202 | { |
---|
203 | if(zoneids[i] == pzoneid) |
---|
204 | { |
---|
205 | z_show = true; |
---|
206 | break; |
---|
207 | } |
---|
208 | |
---|
209 | z_show = false; |
---|
210 | } |
---|
211 | if (!z_show) |
---|
212 | continue; |
---|
213 | |
---|
214 | std::string pname = itr->second->GetName(); |
---|
215 | std::wstring wpname; |
---|
216 | if(!Utf8toWStr(pname,wpname)) |
---|
217 | continue; |
---|
218 | wstrToLower(wpname); |
---|
219 | |
---|
220 | if (!(wplayer_name.empty() || wpname.find(wplayer_name) != std::wstring::npos)) |
---|
221 | continue; |
---|
222 | |
---|
223 | std::string gname = objmgr.GetGuildNameById(itr->second->GetGuildId()); |
---|
224 | std::wstring wgname; |
---|
225 | if(!Utf8toWStr(gname,wgname)) |
---|
226 | continue; |
---|
227 | wstrToLower(wgname); |
---|
228 | |
---|
229 | if (!(wguild_name.empty() || wgname.find(wguild_name) != std::wstring::npos)) |
---|
230 | continue; |
---|
231 | |
---|
232 | std::string aname; |
---|
233 | if(AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(itr->second->GetZoneId())) |
---|
234 | aname = areaEntry->area_name[GetSessionDbcLocale()]; |
---|
235 | |
---|
236 | bool s_show = true; |
---|
237 | for(uint32 i = 0; i < str_count; i++) |
---|
238 | { |
---|
239 | if (!str[i].empty()) |
---|
240 | { |
---|
241 | if (wgname.find(str[i]) != std::wstring::npos || |
---|
242 | wpname.find(str[i]) != std::wstring::npos || |
---|
243 | Utf8FitTo(aname, str[i]) ) |
---|
244 | { |
---|
245 | s_show = true; |
---|
246 | break; |
---|
247 | } |
---|
248 | s_show = false; |
---|
249 | } |
---|
250 | } |
---|
251 | if (!s_show) |
---|
252 | continue; |
---|
253 | |
---|
254 | data << pname; // player name |
---|
255 | data << gname; // guild name |
---|
256 | data << uint32( lvl ); // player level |
---|
257 | data << uint32( class_ ); // player class |
---|
258 | data << uint32( race ); // player race |
---|
259 | data << uint8(0); // new 2.4.0 |
---|
260 | data << uint32( pzoneid ); // player zone id |
---|
261 | |
---|
262 | // 49 is maximum player count sent to client - can be overridden |
---|
263 | // through config, but is unstable |
---|
264 | if ((++clientcount) == sWorld.getConfig(CONFIG_MAX_WHO)) |
---|
265 | break; |
---|
266 | } |
---|
267 | |
---|
268 | data.put( 0, clientcount ); //insert right count |
---|
269 | data.put( sizeof(uint32), clientcount ); //insert right count |
---|
270 | |
---|
271 | SendPacket(&data); |
---|
272 | sLog.outDebug( "WORLD: Send SMSG_WHO Message" ); |
---|
273 | } |
---|
274 | |
---|
275 | void WorldSession::HandleLogoutRequestOpcode( WorldPacket & /*recv_data*/ ) |
---|
276 | { |
---|
277 | sLog.outDebug( "WORLD: Recvd CMSG_LOGOUT_REQUEST Message, security - %u", GetSecurity() ); |
---|
278 | |
---|
279 | if (uint64 lguid = GetPlayer()->GetLootGUID()) |
---|
280 | DoLootRelease(lguid); |
---|
281 | |
---|
282 | //instant logout for admins, gm's, mod's |
---|
283 | if( GetSecurity() > SEC_PLAYER ) |
---|
284 | { |
---|
285 | LogoutPlayer(true); |
---|
286 | return; |
---|
287 | } |
---|
288 | |
---|
289 | //Can not logout if... |
---|
290 | if( GetPlayer()->isInCombat() || //...is in combat |
---|
291 | GetPlayer()->duel || //...is in Duel |
---|
292 | GetPlayer()->HasAura(9454,0) || //...is frozen by GM via freeze command |
---|
293 | //...is jumping ...is falling |
---|
294 | GetPlayer()->HasUnitMovementFlag(MOVEMENTFLAG_JUMPING | MOVEMENTFLAG_FALLING)) |
---|
295 | { |
---|
296 | WorldPacket data( SMSG_LOGOUT_RESPONSE, (2+4) ) ; |
---|
297 | data << (uint8)0xC; |
---|
298 | data << uint32(0); |
---|
299 | data << uint8(0); |
---|
300 | SendPacket( &data ); |
---|
301 | LogoutRequest(0); |
---|
302 | return; |
---|
303 | } |
---|
304 | |
---|
305 | //instant logout in taverns/cities or on taxi or if its enabled in Trinityd.conf |
---|
306 | if(GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) || GetPlayer()->isInFlight() || sWorld.getConfig(CONFIG_INSTANT_LOGOUT)) |
---|
307 | { |
---|
308 | LogoutPlayer(true); |
---|
309 | return; |
---|
310 | } |
---|
311 | |
---|
312 | // not set flags if player can't free move to prevent lost state at logout cancel |
---|
313 | if(GetPlayer()->CanFreeMove()) |
---|
314 | { |
---|
315 | GetPlayer()->SetStandState(PLAYER_STATE_SIT); |
---|
316 | |
---|
317 | WorldPacket data( SMSG_FORCE_MOVE_ROOT, (8+4) ); // guess size |
---|
318 | data.append(GetPlayer()->GetPackGUID()); |
---|
319 | data << (uint32)2; |
---|
320 | SendPacket( &data ); |
---|
321 | GetPlayer()->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_ROTATE); |
---|
322 | } |
---|
323 | |
---|
324 | WorldPacket data( SMSG_LOGOUT_RESPONSE, 5 ); |
---|
325 | data << uint32(0); |
---|
326 | data << uint8(0); |
---|
327 | SendPacket( &data ); |
---|
328 | LogoutRequest(time(NULL)); |
---|
329 | } |
---|
330 | |
---|
331 | void WorldSession::HandlePlayerLogoutOpcode( WorldPacket & /*recv_data*/ ) |
---|
332 | { |
---|
333 | sLog.outDebug( "WORLD: Recvd CMSG_PLAYER_LOGOUT Message" ); |
---|
334 | } |
---|
335 | |
---|
336 | void WorldSession::HandleLogoutCancelOpcode( WorldPacket & /*recv_data*/ ) |
---|
337 | { |
---|
338 | sLog.outDebug( "WORLD: Recvd CMSG_LOGOUT_CANCEL Message" ); |
---|
339 | |
---|
340 | LogoutRequest(0); |
---|
341 | |
---|
342 | WorldPacket data( SMSG_LOGOUT_CANCEL_ACK, 0 ); |
---|
343 | SendPacket( &data ); |
---|
344 | |
---|
345 | // not remove flags if can't free move - its not set in Logout request code. |
---|
346 | if(GetPlayer()->CanFreeMove()) |
---|
347 | { |
---|
348 | //!we can move again |
---|
349 | data.Initialize( SMSG_FORCE_MOVE_UNROOT, 8 ); // guess size |
---|
350 | data.append(GetPlayer()->GetPackGUID()); |
---|
351 | data << uint32(0); |
---|
352 | SendPacket( &data ); |
---|
353 | |
---|
354 | //! Stand Up |
---|
355 | GetPlayer()->SetStandState(PLAYER_STATE_NONE); |
---|
356 | |
---|
357 | //! DISABLE_ROTATE |
---|
358 | GetPlayer()->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_ROTATE); |
---|
359 | } |
---|
360 | |
---|
361 | sLog.outDebug( "WORLD: sent SMSG_LOGOUT_CANCEL_ACK Message" ); |
---|
362 | } |
---|
363 | |
---|
364 | void WorldSession::HandleTogglePvP( WorldPacket & recv_data ) |
---|
365 | { |
---|
366 | // this opcode can be used in two ways: Either set explicit new status or toggle old status |
---|
367 | if(recv_data.size() == 1) |
---|
368 | { |
---|
369 | bool newPvPStatus; |
---|
370 | recv_data >> newPvPStatus; |
---|
371 | GetPlayer()->ApplyModFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP, newPvPStatus); |
---|
372 | } |
---|
373 | else |
---|
374 | { |
---|
375 | GetPlayer()->ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP); |
---|
376 | } |
---|
377 | |
---|
378 | if(GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP)) |
---|
379 | { |
---|
380 | if(!GetPlayer()->IsPvP() || GetPlayer()->pvpInfo.endTimer != 0) |
---|
381 | GetPlayer()->UpdatePvP(true, true); |
---|
382 | } |
---|
383 | else |
---|
384 | { |
---|
385 | if(!GetPlayer()->pvpInfo.inHostileArea && GetPlayer()->IsPvP()) |
---|
386 | GetPlayer()->pvpInfo.endTimer = time(NULL); // start toggle-off |
---|
387 | } |
---|
388 | |
---|
389 | if(OutdoorPvP * pvp = _player->GetOutdoorPvP()) |
---|
390 | { |
---|
391 | pvp->HandlePlayerActivityChanged(_player); |
---|
392 | } |
---|
393 | } |
---|
394 | |
---|
395 | void WorldSession::HandleZoneUpdateOpcode( WorldPacket & recv_data ) |
---|
396 | { |
---|
397 | CHECK_PACKET_SIZE(recv_data,4); |
---|
398 | |
---|
399 | uint32 newZone; |
---|
400 | recv_data >> newZone; |
---|
401 | |
---|
402 | sLog.outDetail("WORLD: Recvd ZONE_UPDATE: %u", newZone); |
---|
403 | |
---|
404 | GetPlayer()->UpdateZone(newZone); |
---|
405 | |
---|
406 | GetPlayer()->SendInitWorldStates(true,newZone); |
---|
407 | } |
---|
408 | |
---|
409 | void WorldSession::HandleSetTargetOpcode( WorldPacket & recv_data ) |
---|
410 | { |
---|
411 | // When this packet send? |
---|
412 | CHECK_PACKET_SIZE(recv_data,8); |
---|
413 | |
---|
414 | uint64 guid ; |
---|
415 | recv_data >> guid; |
---|
416 | |
---|
417 | _player->SetUInt32Value(UNIT_FIELD_TARGET,guid); |
---|
418 | |
---|
419 | // update reputation list if need |
---|
420 | Unit* unit = ObjectAccessor::GetUnit(*_player, guid ); |
---|
421 | if(!unit) |
---|
422 | return; |
---|
423 | |
---|
424 | _player->SetFactionVisibleForFactionTemplateId(unit->getFaction()); |
---|
425 | } |
---|
426 | |
---|
427 | void WorldSession::HandleSetSelectionOpcode( WorldPacket & recv_data ) |
---|
428 | { |
---|
429 | CHECK_PACKET_SIZE(recv_data,8); |
---|
430 | |
---|
431 | uint64 guid; |
---|
432 | recv_data >> guid; |
---|
433 | |
---|
434 | _player->SetSelection(guid); |
---|
435 | |
---|
436 | // update reputation list if need |
---|
437 | Unit* unit = ObjectAccessor::GetUnit(*_player, guid ); |
---|
438 | if(!unit) |
---|
439 | return; |
---|
440 | |
---|
441 | _player->SetFactionVisibleForFactionTemplateId(unit->getFaction()); |
---|
442 | } |
---|
443 | |
---|
444 | void WorldSession::HandleStandStateChangeOpcode( WorldPacket & recv_data ) |
---|
445 | { |
---|
446 | CHECK_PACKET_SIZE(recv_data,1); |
---|
447 | |
---|
448 | sLog.outDebug( "WORLD: Received CMSG_STAND_STATE_CHANGE" ); |
---|
449 | uint8 animstate; |
---|
450 | recv_data >> animstate; |
---|
451 | |
---|
452 | _player->SetStandState(animstate); |
---|
453 | } |
---|
454 | |
---|
455 | void WorldSession::HandleFriendListOpcode( WorldPacket & recv_data ) |
---|
456 | { |
---|
457 | CHECK_PACKET_SIZE(recv_data, 4); |
---|
458 | sLog.outDebug( "WORLD: Received CMSG_CONTACT_LIST" ); |
---|
459 | uint32 unk; |
---|
460 | recv_data >> unk; |
---|
461 | sLog.outDebug("unk value is %u", unk); |
---|
462 | _player->GetSocial()->SendSocialList(); |
---|
463 | } |
---|
464 | |
---|
465 | void WorldSession::HandleAddFriendOpcode( WorldPacket & recv_data ) |
---|
466 | { |
---|
467 | CHECK_PACKET_SIZE(recv_data, 1+1); |
---|
468 | |
---|
469 | sLog.outDebug( "WORLD: Received CMSG_ADD_FRIEND" ); |
---|
470 | |
---|
471 | std::string friendName = GetTrinityString(LANG_FRIEND_IGNORE_UNKNOWN); |
---|
472 | std::string friendNote; |
---|
473 | |
---|
474 | recv_data >> friendName; |
---|
475 | |
---|
476 | // recheck |
---|
477 | CHECK_PACKET_SIZE(recv_data, (friendName.size()+1)+1); |
---|
478 | |
---|
479 | recv_data >> friendNote; |
---|
480 | |
---|
481 | if(!normalizePlayerName(friendName)) |
---|
482 | return; |
---|
483 | |
---|
484 | CharacterDatabase.escape_string(friendName); // prevent SQL injection - normal name don't must changed by this call |
---|
485 | |
---|
486 | sLog.outDebug( "WORLD: %s asked to add friend : '%s'", |
---|
487 | GetPlayer()->GetName(), friendName.c_str() ); |
---|
488 | |
---|
489 | CharacterDatabase.AsyncPQuery(&WorldSession::HandleAddFriendOpcodeCallBack, GetAccountId(), friendNote, "SELECT guid, race FROM characters WHERE name = '%s'", friendName.c_str()); |
---|
490 | } |
---|
491 | |
---|
492 | void WorldSession::HandleAddFriendOpcodeCallBack(QueryResult *result, uint32 accountId, std::string friendNote) |
---|
493 | { |
---|
494 | if(!result) |
---|
495 | return; |
---|
496 | |
---|
497 | uint64 friendGuid = MAKE_NEW_GUID((*result)[0].GetUInt32(), 0, HIGHGUID_PLAYER); |
---|
498 | uint32 team = Player::TeamForRace((*result)[1].GetUInt8()); |
---|
499 | |
---|
500 | delete result; |
---|
501 | |
---|
502 | WorldSession * session = sWorld.FindSession(accountId); |
---|
503 | if(!session || !session->GetPlayer()) |
---|
504 | return; |
---|
505 | |
---|
506 | FriendsResult friendResult = FRIEND_NOT_FOUND; |
---|
507 | if(friendGuid) |
---|
508 | { |
---|
509 | if(friendGuid==session->GetPlayer()->GetGUID()) |
---|
510 | friendResult = FRIEND_SELF; |
---|
511 | else if(session->GetPlayer()->GetTeam() != team && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND) && session->GetSecurity() < SEC_MODERATOR) |
---|
512 | friendResult = FRIEND_ENEMY; |
---|
513 | else if(session->GetPlayer()->GetSocial()->HasFriend(GUID_LOPART(friendGuid))) |
---|
514 | friendResult = FRIEND_ALREADY; |
---|
515 | else |
---|
516 | { |
---|
517 | Player* pFriend = ObjectAccessor::FindPlayer(friendGuid); |
---|
518 | if( pFriend && pFriend->IsInWorld() && pFriend->IsVisibleGloballyFor(session->GetPlayer())) |
---|
519 | friendResult = FRIEND_ADDED_ONLINE; |
---|
520 | else |
---|
521 | friendResult = FRIEND_ADDED_OFFLINE; |
---|
522 | |
---|
523 | if(!session->GetPlayer()->GetSocial()->AddToSocialList(GUID_LOPART(friendGuid), false)) |
---|
524 | { |
---|
525 | friendResult = FRIEND_LIST_FULL; |
---|
526 | sLog.outDebug( "WORLD: %s's friend list is full.", session->GetPlayer()->GetName()); |
---|
527 | } |
---|
528 | |
---|
529 | session->GetPlayer()->GetSocial()->SetFriendNote(GUID_LOPART(friendGuid), friendNote); |
---|
530 | } |
---|
531 | } |
---|
532 | |
---|
533 | sSocialMgr.SendFriendStatus(session->GetPlayer(), friendResult, GUID_LOPART(friendGuid), false); |
---|
534 | |
---|
535 | sLog.outDebug( "WORLD: Sent (SMSG_FRIEND_STATUS)" ); |
---|
536 | } |
---|
537 | |
---|
538 | void WorldSession::HandleDelFriendOpcode( WorldPacket & recv_data ) |
---|
539 | { |
---|
540 | CHECK_PACKET_SIZE(recv_data, 8); |
---|
541 | |
---|
542 | uint64 FriendGUID; |
---|
543 | |
---|
544 | sLog.outDebug( "WORLD: Received CMSG_DEL_FRIEND" ); |
---|
545 | |
---|
546 | recv_data >> FriendGUID; |
---|
547 | |
---|
548 | _player->GetSocial()->RemoveFromSocialList(GUID_LOPART(FriendGUID), false); |
---|
549 | |
---|
550 | sSocialMgr.SendFriendStatus(GetPlayer(), FRIEND_REMOVED, GUID_LOPART(FriendGUID), false); |
---|
551 | |
---|
552 | sLog.outDebug( "WORLD: Sent motd (SMSG_FRIEND_STATUS)" ); |
---|
553 | } |
---|
554 | |
---|
555 | void WorldSession::HandleAddIgnoreOpcode( WorldPacket & recv_data ) |
---|
556 | { |
---|
557 | CHECK_PACKET_SIZE(recv_data,1); |
---|
558 | |
---|
559 | sLog.outDebug( "WORLD: Received CMSG_ADD_IGNORE" ); |
---|
560 | |
---|
561 | std::string IgnoreName = GetTrinityString(LANG_FRIEND_IGNORE_UNKNOWN); |
---|
562 | |
---|
563 | recv_data >> IgnoreName; |
---|
564 | |
---|
565 | if(!normalizePlayerName(IgnoreName)) |
---|
566 | return; |
---|
567 | |
---|
568 | CharacterDatabase.escape_string(IgnoreName); // prevent SQL injection - normal name don't must changed by this call |
---|
569 | |
---|
570 | sLog.outDebug( "WORLD: %s asked to Ignore: '%s'", |
---|
571 | GetPlayer()->GetName(), IgnoreName.c_str() ); |
---|
572 | |
---|
573 | CharacterDatabase.AsyncPQuery(&WorldSession::HandleAddIgnoreOpcodeCallBack, GetAccountId(), "SELECT guid FROM characters WHERE name = '%s'", IgnoreName.c_str()); |
---|
574 | } |
---|
575 | |
---|
576 | void WorldSession::HandleAddIgnoreOpcodeCallBack(QueryResult *result, uint32 accountId) |
---|
577 | { |
---|
578 | if(!result) |
---|
579 | return; |
---|
580 | |
---|
581 | uint64 IgnoreGuid = MAKE_NEW_GUID((*result)[0].GetUInt32(), 0, HIGHGUID_PLAYER); |
---|
582 | |
---|
583 | delete result; |
---|
584 | |
---|
585 | WorldSession * session = sWorld.FindSession(accountId); |
---|
586 | if(!session || !session->GetPlayer()) |
---|
587 | return; |
---|
588 | |
---|
589 | FriendsResult ignoreResult = FRIEND_IGNORE_NOT_FOUND; |
---|
590 | if(IgnoreGuid) |
---|
591 | { |
---|
592 | if(IgnoreGuid==session->GetPlayer()->GetGUID()) //not add yourself |
---|
593 | ignoreResult = FRIEND_IGNORE_SELF; |
---|
594 | else if( session->GetPlayer()->GetSocial()->HasIgnore(GUID_LOPART(IgnoreGuid)) ) |
---|
595 | ignoreResult = FRIEND_IGNORE_ALREADY; |
---|
596 | else |
---|
597 | { |
---|
598 | ignoreResult = FRIEND_IGNORE_ADDED; |
---|
599 | |
---|
600 | // ignore list full |
---|
601 | if(!session->GetPlayer()->GetSocial()->AddToSocialList(GUID_LOPART(IgnoreGuid), true)) |
---|
602 | ignoreResult = FRIEND_IGNORE_FULL; |
---|
603 | } |
---|
604 | } |
---|
605 | |
---|
606 | sSocialMgr.SendFriendStatus(session->GetPlayer(), ignoreResult, GUID_LOPART(IgnoreGuid), false); |
---|
607 | |
---|
608 | sLog.outDebug( "WORLD: Sent (SMSG_FRIEND_STATUS)" ); |
---|
609 | } |
---|
610 | |
---|
611 | void WorldSession::HandleDelIgnoreOpcode( WorldPacket & recv_data ) |
---|
612 | { |
---|
613 | CHECK_PACKET_SIZE(recv_data, 8); |
---|
614 | |
---|
615 | uint64 IgnoreGUID; |
---|
616 | |
---|
617 | sLog.outDebug( "WORLD: Received CMSG_DEL_IGNORE" ); |
---|
618 | |
---|
619 | recv_data >> IgnoreGUID; |
---|
620 | |
---|
621 | _player->GetSocial()->RemoveFromSocialList(GUID_LOPART(IgnoreGUID), true); |
---|
622 | |
---|
623 | sSocialMgr.SendFriendStatus(GetPlayer(), FRIEND_IGNORE_REMOVED, GUID_LOPART(IgnoreGUID), false); |
---|
624 | |
---|
625 | sLog.outDebug( "WORLD: Sent motd (SMSG_FRIEND_STATUS)" ); |
---|
626 | } |
---|
627 | |
---|
628 | void WorldSession::HandleSetFriendNoteOpcode( WorldPacket & recv_data ) |
---|
629 | { |
---|
630 | CHECK_PACKET_SIZE(recv_data, 8+1); |
---|
631 | uint64 guid; |
---|
632 | std::string note; |
---|
633 | recv_data >> guid >> note; |
---|
634 | _player->GetSocial()->SetFriendNote(guid, note); |
---|
635 | } |
---|
636 | |
---|
637 | void WorldSession::HandleBugOpcode( WorldPacket & recv_data ) |
---|
638 | { |
---|
639 | CHECK_PACKET_SIZE(recv_data,4+4+1+4+1); |
---|
640 | |
---|
641 | uint32 suggestion, contentlen; |
---|
642 | std::string content; |
---|
643 | uint32 typelen; |
---|
644 | std::string type; |
---|
645 | |
---|
646 | recv_data >> suggestion >> contentlen >> content; |
---|
647 | |
---|
648 | //recheck |
---|
649 | CHECK_PACKET_SIZE(recv_data,4+4+(content.size()+1)+4+1); |
---|
650 | |
---|
651 | recv_data >> typelen >> type; |
---|
652 | |
---|
653 | if( suggestion == 0 ) |
---|
654 | sLog.outDebug( "WORLD: Received CMSG_BUG [Bug Report]" ); |
---|
655 | else |
---|
656 | sLog.outDebug( "WORLD: Received CMSG_BUG [Suggestion]" ); |
---|
657 | |
---|
658 | sLog.outDebug( type.c_str( ) ); |
---|
659 | sLog.outDebug( content.c_str( ) ); |
---|
660 | |
---|
661 | CharacterDatabase.escape_string(type); |
---|
662 | CharacterDatabase.escape_string(content); |
---|
663 | CharacterDatabase.PExecute ("INSERT INTO bugreport (type,content) VALUES('%s', '%s')", type.c_str( ), content.c_str( )); |
---|
664 | } |
---|
665 | |
---|
666 | void WorldSession::HandleCorpseReclaimOpcode(WorldPacket &recv_data) |
---|
667 | { |
---|
668 | CHECK_PACKET_SIZE(recv_data,8); |
---|
669 | |
---|
670 | sLog.outDetail("WORLD: Received CMSG_RECLAIM_CORPSE"); |
---|
671 | if (GetPlayer()->isAlive()) |
---|
672 | return; |
---|
673 | |
---|
674 | if (BattleGround * bg = _player->GetBattleGround()) |
---|
675 | if(bg->isArena()) |
---|
676 | return; |
---|
677 | |
---|
678 | // body not released yet |
---|
679 | if(!GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) |
---|
680 | return; |
---|
681 | |
---|
682 | Corpse *corpse = GetPlayer()->GetCorpse(); |
---|
683 | |
---|
684 | if (!corpse ) |
---|
685 | return; |
---|
686 | |
---|
687 | // prevent resurrect before 30-sec delay after body release not finished |
---|
688 | if(corpse->GetGhostTime() + GetPlayer()->GetCorpseReclaimDelay(corpse->GetType()==CORPSE_RESURRECTABLE_PVP) > time(NULL)) |
---|
689 | return; |
---|
690 | |
---|
691 | float dist = corpse->GetDistance2d(GetPlayer()); |
---|
692 | sLog.outDebug("Corpse 2D Distance: \t%f",dist); |
---|
693 | if (dist > CORPSE_RECLAIM_RADIUS) |
---|
694 | return; |
---|
695 | |
---|
696 | uint64 guid; |
---|
697 | recv_data >> guid; |
---|
698 | |
---|
699 | // resurrect |
---|
700 | GetPlayer()->ResurrectPlayer(GetPlayer()->InBattleGround() ? 1.0f : 0.5f); |
---|
701 | |
---|
702 | // spawn bones |
---|
703 | GetPlayer()->SpawnCorpseBones(); |
---|
704 | |
---|
705 | GetPlayer()->SaveToDB(); |
---|
706 | } |
---|
707 | |
---|
708 | void WorldSession::HandleResurrectResponseOpcode(WorldPacket & recv_data) |
---|
709 | { |
---|
710 | CHECK_PACKET_SIZE(recv_data,8+1); |
---|
711 | |
---|
712 | sLog.outDetail("WORLD: Received CMSG_RESURRECT_RESPONSE"); |
---|
713 | |
---|
714 | if(GetPlayer()->isAlive()) |
---|
715 | return; |
---|
716 | |
---|
717 | uint64 guid; |
---|
718 | uint8 status; |
---|
719 | recv_data >> guid; |
---|
720 | recv_data >> status; |
---|
721 | |
---|
722 | if(status == 0) |
---|
723 | { |
---|
724 | GetPlayer()->clearResurrectRequestData(); // reject |
---|
725 | return; |
---|
726 | } |
---|
727 | |
---|
728 | if(!GetPlayer()->isRessurectRequestedBy(guid)) |
---|
729 | return; |
---|
730 | |
---|
731 | GetPlayer()->ResurectUsingRequestData(); |
---|
732 | GetPlayer()->SaveToDB(); |
---|
733 | } |
---|
734 | |
---|
735 | void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data) |
---|
736 | { |
---|
737 | CHECK_PACKET_SIZE(recv_data,4); |
---|
738 | |
---|
739 | sLog.outDebug("WORLD: Received CMSG_AREATRIGGER"); |
---|
740 | |
---|
741 | uint32 Trigger_ID; |
---|
742 | |
---|
743 | recv_data >> Trigger_ID; |
---|
744 | sLog.outDebug("Trigger ID:%u",Trigger_ID); |
---|
745 | |
---|
746 | if(GetPlayer()->isInFlight()) |
---|
747 | { |
---|
748 | sLog.outDebug("Player '%s' (GUID: %u) in flight, ignore Area Trigger ID:%u",GetPlayer()->GetName(),GetPlayer()->GetGUIDLow(), Trigger_ID); |
---|
749 | return; |
---|
750 | } |
---|
751 | |
---|
752 | AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(Trigger_ID); |
---|
753 | if(!atEntry) |
---|
754 | { |
---|
755 | sLog.outDebug("Player '%s' (GUID: %u) send unknown (by DBC) Area Trigger ID:%u",GetPlayer()->GetName(),GetPlayer()->GetGUIDLow(), Trigger_ID); |
---|
756 | return; |
---|
757 | } |
---|
758 | |
---|
759 | if (GetPlayer()->GetMapId()!=atEntry->mapid) |
---|
760 | { |
---|
761 | 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); |
---|
762 | return; |
---|
763 | } |
---|
764 | |
---|
765 | // delta is safe radius |
---|
766 | const float delta = 5.0f; |
---|
767 | // check if player in the range of areatrigger |
---|
768 | Player* pl = GetPlayer(); |
---|
769 | |
---|
770 | if (atEntry->radius > 0) |
---|
771 | { |
---|
772 | // if we have radius check it |
---|
773 | float dist = pl->GetDistance(atEntry->x,atEntry->y,atEntry->z); |
---|
774 | if(dist > atEntry->radius + delta) |
---|
775 | { |
---|
776 | sLog.outDebug("Player '%s' (GUID: %u) too far (radius: %f distance: %f), ignore Area Trigger ID: %u", |
---|
777 | pl->GetName(), pl->GetGUIDLow(), atEntry->radius, dist, Trigger_ID); |
---|
778 | return; |
---|
779 | } |
---|
780 | } |
---|
781 | else |
---|
782 | { |
---|
783 | // we have only extent |
---|
784 | float dx = pl->GetPositionX() - atEntry->x; |
---|
785 | float dy = pl->GetPositionY() - atEntry->y; |
---|
786 | float dz = pl->GetPositionZ() - atEntry->z; |
---|
787 | double es = sin(atEntry->box_orientation); |
---|
788 | double ec = cos(atEntry->box_orientation); |
---|
789 | // calc rotated vector based on extent axis |
---|
790 | double rotateDx = dx*ec - dy*es; |
---|
791 | double rotateDy = dx*es + dy*ec; |
---|
792 | |
---|
793 | if( (fabs(rotateDx) > atEntry->box_x/2 + delta) || |
---|
794 | (fabs(rotateDy) > atEntry->box_y/2 + delta) || |
---|
795 | (fabs(dz) > atEntry->box_z/2 + delta) ) |
---|
796 | { |
---|
797 | 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", |
---|
798 | pl->GetName(), pl->GetGUIDLow(), atEntry->box_x/2, atEntry->box_y/2, atEntry->box_z/2, rotateDx, rotateDy, dz, Trigger_ID); |
---|
799 | return; |
---|
800 | } |
---|
801 | } |
---|
802 | |
---|
803 | if(Script->scriptAreaTrigger(GetPlayer(), atEntry)) |
---|
804 | return; |
---|
805 | |
---|
806 | uint32 quest_id = objmgr.GetQuestForAreaTrigger( Trigger_ID ); |
---|
807 | if( quest_id && GetPlayer()->isAlive() && GetPlayer()->IsActiveQuest(quest_id) ) |
---|
808 | { |
---|
809 | Quest const* pQuest = objmgr.GetQuestTemplate(quest_id); |
---|
810 | if( pQuest ) |
---|
811 | { |
---|
812 | if(GetPlayer()->GetQuestStatus(quest_id) == QUEST_STATUS_INCOMPLETE) |
---|
813 | GetPlayer()->AreaExploredOrEventHappens( quest_id ); |
---|
814 | } |
---|
815 | } |
---|
816 | |
---|
817 | if(objmgr.IsTavernAreaTrigger(Trigger_ID)) |
---|
818 | { |
---|
819 | // set resting flag we are in the inn |
---|
820 | GetPlayer()->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING); |
---|
821 | GetPlayer()->InnEnter(time(NULL), atEntry->mapid, atEntry->x, atEntry->y, atEntry->z); |
---|
822 | GetPlayer()->SetRestType(REST_TYPE_IN_TAVERN); |
---|
823 | |
---|
824 | if(sWorld.IsFFAPvPRealm()) |
---|
825 | GetPlayer()->RemoveFlag(PLAYER_FLAGS,PLAYER_FLAGS_FFA_PVP); |
---|
826 | |
---|
827 | return; |
---|
828 | } |
---|
829 | |
---|
830 | if(GetPlayer()->InBattleGround()) |
---|
831 | { |
---|
832 | BattleGround* bg = GetPlayer()->GetBattleGround(); |
---|
833 | if(bg) |
---|
834 | if(bg->GetStatus() == STATUS_IN_PROGRESS) |
---|
835 | bg->HandleAreaTrigger(GetPlayer(), Trigger_ID); |
---|
836 | |
---|
837 | return; |
---|
838 | } |
---|
839 | |
---|
840 | if(OutdoorPvP * pvp = GetPlayer()->GetOutdoorPvP()) |
---|
841 | { |
---|
842 | if(pvp->HandleAreaTrigger(_player, Trigger_ID)) |
---|
843 | return; |
---|
844 | } |
---|
845 | |
---|
846 | // NULL if all values default (non teleport trigger) |
---|
847 | AreaTrigger const* at = objmgr.GetAreaTrigger(Trigger_ID); |
---|
848 | if(!at) |
---|
849 | return; |
---|
850 | |
---|
851 | if(!GetPlayer()->isGameMaster()) |
---|
852 | { |
---|
853 | uint32 missingLevel = 0; |
---|
854 | if(GetPlayer()->getLevel() < at->requiredLevel && !sWorld.getConfig(CONFIG_INSTANCE_IGNORE_LEVEL)) |
---|
855 | missingLevel = at->requiredLevel; |
---|
856 | |
---|
857 | // must have one or the other, report the first one that's missing |
---|
858 | uint32 missingItem = 0; |
---|
859 | if(at->requiredItem) |
---|
860 | { |
---|
861 | if(!GetPlayer()->HasItemCount(at->requiredItem, 1) && |
---|
862 | (!at->requiredItem2 || !GetPlayer()->HasItemCount(at->requiredItem2, 1))) |
---|
863 | missingItem = at->requiredItem; |
---|
864 | } |
---|
865 | else if(at->requiredItem2 && !GetPlayer()->HasItemCount(at->requiredItem2, 1)) |
---|
866 | missingItem = at->requiredItem2; |
---|
867 | |
---|
868 | uint32 missingKey = 0; |
---|
869 | if(GetPlayer()->GetDifficulty() == DIFFICULTY_HEROIC) |
---|
870 | { |
---|
871 | if(at->heroicKey) |
---|
872 | { |
---|
873 | if(!GetPlayer()->HasItemCount(at->heroicKey, 1) && |
---|
874 | (!at->heroicKey2 || !GetPlayer()->HasItemCount(at->heroicKey2, 1))) |
---|
875 | missingKey = at->heroicKey; |
---|
876 | } |
---|
877 | else if(at->heroicKey2 && !GetPlayer()->HasItemCount(at->heroicKey2, 1)) |
---|
878 | missingKey = at->heroicKey2; |
---|
879 | } |
---|
880 | |
---|
881 | uint32 missingQuest = 0; |
---|
882 | if(at->requiredQuest && !GetPlayer()->GetQuestRewardStatus(at->requiredQuest)) |
---|
883 | missingQuest = at->requiredQuest; |
---|
884 | |
---|
885 | if(missingLevel || missingItem || missingKey || missingQuest) |
---|
886 | { |
---|
887 | // TODO: all this is probably wrong |
---|
888 | if(missingItem) |
---|
889 | SendAreaTriggerMessage(GetTrinityString(LANG_LEVEL_MINREQUIRED_AND_ITEM), at->requiredLevel, objmgr.GetItemPrototype(missingItem)->Name1); |
---|
890 | else if(missingKey) |
---|
891 | GetPlayer()->SendTransferAborted(at->target_mapId, TRANSFER_ABORT_DIFFICULTY2); |
---|
892 | else if(missingQuest) |
---|
893 | SendAreaTriggerMessage(at->requiredFailedText.c_str()); |
---|
894 | else if(missingLevel) |
---|
895 | SendAreaTriggerMessage(GetTrinityString(LANG_LEVEL_MINREQUIRED), missingLevel); |
---|
896 | return; |
---|
897 | } |
---|
898 | } |
---|
899 | |
---|
900 | GetPlayer()->TeleportTo(at->target_mapId,at->target_X,at->target_Y,at->target_Z,at->target_Orientation,TELE_TO_NOT_LEAVE_TRANSPORT); |
---|
901 | } |
---|
902 | |
---|
903 | void WorldSession::HandleUpdateAccountData(WorldPacket &/*recv_data*/) |
---|
904 | { |
---|
905 | sLog.outDetail("WORLD: Received CMSG_UPDATE_ACCOUNT_DATA"); |
---|
906 | //recv_data.hexlike(); |
---|
907 | } |
---|
908 | |
---|
909 | void WorldSession::HandleRequestAccountData(WorldPacket& /*recv_data*/) |
---|
910 | { |
---|
911 | sLog.outDetail("WORLD: Received CMSG_REQUEST_ACCOUNT_DATA"); |
---|
912 | //recv_data.hexlike(); |
---|
913 | } |
---|
914 | |
---|
915 | void WorldSession::HandleSetActionButtonOpcode(WorldPacket& recv_data) |
---|
916 | { |
---|
917 | CHECK_PACKET_SIZE(recv_data,1+2+1+1); |
---|
918 | |
---|
919 | sLog.outDebug( "WORLD: Received CMSG_SET_ACTION_BUTTON" ); |
---|
920 | uint8 button, misc, type; |
---|
921 | uint16 action; |
---|
922 | recv_data >> button >> action >> misc >> type; |
---|
923 | sLog.outDetail( "BUTTON: %u ACTION: %u TYPE: %u MISC: %u", button, action, type, misc ); |
---|
924 | if(action==0) |
---|
925 | { |
---|
926 | sLog.outDetail( "MISC: Remove action from button %u", button ); |
---|
927 | |
---|
928 | GetPlayer()->removeActionButton(button); |
---|
929 | } |
---|
930 | else |
---|
931 | { |
---|
932 | if(type==ACTION_BUTTON_MACRO || type==ACTION_BUTTON_CMACRO) |
---|
933 | { |
---|
934 | sLog.outDetail( "MISC: Added Macro %u into button %u", action, button ); |
---|
935 | GetPlayer()->addActionButton(button,action,type,misc); |
---|
936 | } |
---|
937 | else if(type==ACTION_BUTTON_SPELL) |
---|
938 | { |
---|
939 | sLog.outDetail( "MISC: Added Action %u into button %u", action, button ); |
---|
940 | GetPlayer()->addActionButton(button,action,type,misc); |
---|
941 | } |
---|
942 | else if(type==ACTION_BUTTON_ITEM) |
---|
943 | { |
---|
944 | sLog.outDetail( "MISC: Added Item %u into button %u", action, button ); |
---|
945 | GetPlayer()->addActionButton(button,action,type,misc); |
---|
946 | } |
---|
947 | else |
---|
948 | sLog.outError( "MISC: Unknown action button type %u for action %u into button %u", type, action, button ); |
---|
949 | } |
---|
950 | } |
---|
951 | |
---|
952 | void WorldSession::HandleCompleteCinema( WorldPacket & /*recv_data*/ ) |
---|
953 | { |
---|
954 | DEBUG_LOG( "WORLD: Player is watching cinema" ); |
---|
955 | } |
---|
956 | |
---|
957 | void WorldSession::HandleNextCinematicCamera( WorldPacket & /*recv_data*/ ) |
---|
958 | { |
---|
959 | DEBUG_LOG( "WORLD: Which movie to play" ); |
---|
960 | } |
---|
961 | |
---|
962 | void WorldSession::HandleMoveTimeSkippedOpcode( WorldPacket & /*recv_data*/ ) |
---|
963 | { |
---|
964 | /* WorldSession::Update( getMSTime() );*/ |
---|
965 | DEBUG_LOG( "WORLD: Time Lag/Synchronization Resent/Update" ); |
---|
966 | |
---|
967 | /* |
---|
968 | CHECK_PACKET_SIZE(recv_data,8+4); |
---|
969 | uint64 guid; |
---|
970 | uint32 time_skipped; |
---|
971 | recv_data >> guid; |
---|
972 | recv_data >> time_skipped; |
---|
973 | sLog.outDebug( "WORLD: CMSG_MOVE_TIME_SKIPPED" ); |
---|
974 | |
---|
975 | /// TODO |
---|
976 | must be need use in Trinity |
---|
977 | We substract server Lags to move time ( AntiLags ) |
---|
978 | for exmaple |
---|
979 | GetPlayer()->ModifyLastMoveTime( -int32(time_skipped) ); |
---|
980 | */ |
---|
981 | } |
---|
982 | |
---|
983 | void WorldSession::HandleFeatherFallAck(WorldPacket &/*recv_data*/) |
---|
984 | { |
---|
985 | DEBUG_LOG("WORLD: CMSG_MOVE_FEATHER_FALL_ACK"); |
---|
986 | } |
---|
987 | |
---|
988 | void WorldSession::HandleMoveUnRootAck(WorldPacket&/* recv_data*/) |
---|
989 | { |
---|
990 | /* |
---|
991 | CHECK_PACKET_SIZE(recv_data,8+8+4+4+4+4+4); |
---|
992 | |
---|
993 | sLog.outDebug( "WORLD: CMSG_FORCE_MOVE_UNROOT_ACK" ); |
---|
994 | recv_data.hexlike(); |
---|
995 | uint64 guid; |
---|
996 | uint64 unknown1; |
---|
997 | uint32 unknown2; |
---|
998 | float PositionX; |
---|
999 | float PositionY; |
---|
1000 | float PositionZ; |
---|
1001 | float Orientation; |
---|
1002 | |
---|
1003 | recv_data >> guid; |
---|
1004 | recv_data >> unknown1; |
---|
1005 | recv_data >> unknown2; |
---|
1006 | recv_data >> PositionX; |
---|
1007 | recv_data >> PositionY; |
---|
1008 | recv_data >> PositionZ; |
---|
1009 | recv_data >> Orientation; |
---|
1010 | |
---|
1011 | // TODO for later may be we can use for anticheat |
---|
1012 | DEBUG_LOG("Guid " I64FMTD,guid); |
---|
1013 | DEBUG_LOG("unknown1 " I64FMTD,unknown1); |
---|
1014 | DEBUG_LOG("unknown2 %u",unknown2); |
---|
1015 | DEBUG_LOG("X %f",PositionX); |
---|
1016 | DEBUG_LOG("Y %f",PositionY); |
---|
1017 | DEBUG_LOG("Z %f",PositionZ); |
---|
1018 | DEBUG_LOG("O %f",Orientation); |
---|
1019 | */ |
---|
1020 | } |
---|
1021 | |
---|
1022 | void WorldSession::HandleMoveRootAck(WorldPacket&/* recv_data*/) |
---|
1023 | { |
---|
1024 | /* |
---|
1025 | CHECK_PACKET_SIZE(recv_data,8+8+4+4+4+4+4); |
---|
1026 | |
---|
1027 | sLog.outDebug( "WORLD: CMSG_FORCE_MOVE_ROOT_ACK" ); |
---|
1028 | recv_data.hexlike(); |
---|
1029 | uint64 guid; |
---|
1030 | uint64 unknown1; |
---|
1031 | uint32 unknown2; |
---|
1032 | float PositionX; |
---|
1033 | float PositionY; |
---|
1034 | float PositionZ; |
---|
1035 | float Orientation; |
---|
1036 | |
---|
1037 | recv_data >> guid; |
---|
1038 | recv_data >> unknown1; |
---|
1039 | recv_data >> unknown2; |
---|
1040 | recv_data >> PositionX; |
---|
1041 | recv_data >> PositionY; |
---|
1042 | recv_data >> PositionZ; |
---|
1043 | recv_data >> Orientation; |
---|
1044 | |
---|
1045 | // for later may be we can use for anticheat |
---|
1046 | DEBUG_LOG("Guid " I64FMTD,guid); |
---|
1047 | DEBUG_LOG("unknown1 " I64FMTD,unknown1); |
---|
1048 | DEBUG_LOG("unknown1 %u",unknown2); |
---|
1049 | DEBUG_LOG("X %f",PositionX); |
---|
1050 | DEBUG_LOG("Y %f",PositionY); |
---|
1051 | DEBUG_LOG("Z %f",PositionZ); |
---|
1052 | DEBUG_LOG("O %f",Orientation); |
---|
1053 | */ |
---|
1054 | } |
---|
1055 | |
---|
1056 | void WorldSession::HandleMoveTeleportAck(WorldPacket&/* recv_data*/) |
---|
1057 | { |
---|
1058 | /* |
---|
1059 | CHECK_PACKET_SIZE(recv_data,8+4); |
---|
1060 | |
---|
1061 | sLog.outDebug("MSG_MOVE_TELEPORT_ACK"); |
---|
1062 | uint64 guid; |
---|
1063 | uint32 flags, time; |
---|
1064 | |
---|
1065 | recv_data >> guid; |
---|
1066 | recv_data >> flags >> time; |
---|
1067 | DEBUG_LOG("Guid " I64FMTD,guid); |
---|
1068 | DEBUG_LOG("Flags %u, time %u",flags, time/1000); |
---|
1069 | */ |
---|
1070 | } |
---|
1071 | |
---|
1072 | void WorldSession::HandleSetActionBar(WorldPacket& recv_data) |
---|
1073 | { |
---|
1074 | CHECK_PACKET_SIZE(recv_data,1); |
---|
1075 | |
---|
1076 | uint8 ActionBar; |
---|
1077 | |
---|
1078 | recv_data >> ActionBar; |
---|
1079 | |
---|
1080 | if(!GetPlayer()) // ignore until not logged (check needed because STATUS_AUTHED) |
---|
1081 | { |
---|
1082 | if(ActionBar!=0) |
---|
1083 | sLog.outError("WorldSession::HandleSetActionBar in not logged state with value: %u, ignored",uint32(ActionBar)); |
---|
1084 | return; |
---|
1085 | } |
---|
1086 | |
---|
1087 | GetPlayer()->SetByteValue(PLAYER_FIELD_BYTES, 2, ActionBar); |
---|
1088 | } |
---|
1089 | |
---|
1090 | void WorldSession::HandleWardenDataOpcode(WorldPacket& /*recv_data*/) |
---|
1091 | { |
---|
1092 | /* |
---|
1093 | CHECK_PACKET_SIZE(recv_data,1); |
---|
1094 | |
---|
1095 | uint8 tmp; |
---|
1096 | recv_data >> tmp; |
---|
1097 | sLog.outDebug("Received opcode CMSG_WARDEN_DATA, not resolve.uint8 = %u",tmp); |
---|
1098 | */ |
---|
1099 | } |
---|
1100 | |
---|
1101 | void WorldSession::HandlePlayedTime(WorldPacket& /*recv_data*/) |
---|
1102 | { |
---|
1103 | uint32 TotalTimePlayed = GetPlayer()->GetTotalPlayedTime(); |
---|
1104 | uint32 LevelPlayedTime = GetPlayer()->GetLevelPlayedTime(); |
---|
1105 | |
---|
1106 | WorldPacket data(SMSG_PLAYED_TIME, 8); |
---|
1107 | data << TotalTimePlayed; |
---|
1108 | data << LevelPlayedTime; |
---|
1109 | SendPacket(&data); |
---|
1110 | } |
---|
1111 | |
---|
1112 | void WorldSession::HandleInspectOpcode(WorldPacket& recv_data) |
---|
1113 | { |
---|
1114 | CHECK_PACKET_SIZE(recv_data, 8); |
---|
1115 | |
---|
1116 | uint64 guid; |
---|
1117 | recv_data >> guid; |
---|
1118 | DEBUG_LOG("Inspected guid is " I64FMTD, guid); |
---|
1119 | |
---|
1120 | _player->SetSelection(guid); |
---|
1121 | |
---|
1122 | Player *plr = objmgr.GetPlayer(guid); |
---|
1123 | if(!plr) // wrong player |
---|
1124 | return; |
---|
1125 | |
---|
1126 | uint32 talent_points = 0x3D; |
---|
1127 | uint32 guid_size = plr->GetPackGUID().size(); |
---|
1128 | WorldPacket data(SMSG_INSPECT_TALENT, 4+talent_points); |
---|
1129 | data.append(plr->GetPackGUID()); |
---|
1130 | data << uint32(talent_points); |
---|
1131 | |
---|
1132 | // fill by 0 talents array |
---|
1133 | for(uint32 i = 0; i < talent_points; ++i) |
---|
1134 | data << uint8(0); |
---|
1135 | |
---|
1136 | if(sWorld.getConfig(CONFIG_TALENTS_INSPECTING) || _player->isGameMaster()) |
---|
1137 | { |
---|
1138 | // find class talent tabs (all players have 3 talent tabs) |
---|
1139 | uint32 const* talentTabIds = GetTalentTabPages(plr->getClass()); |
---|
1140 | |
---|
1141 | uint32 talentTabPos = 0; // pos of first talent rank in tab including all prev tabs |
---|
1142 | for(uint32 i = 0; i < 3; ++i) |
---|
1143 | { |
---|
1144 | uint32 talentTabId = talentTabIds[i]; |
---|
1145 | |
---|
1146 | // fill by real data |
---|
1147 | for(uint32 talentId = 0; talentId < sTalentStore.GetNumRows(); ++talentId) |
---|
1148 | { |
---|
1149 | TalentEntry const* talentInfo = sTalentStore.LookupEntry(talentId); |
---|
1150 | if(!talentInfo) |
---|
1151 | continue; |
---|
1152 | |
---|
1153 | // skip another tab talents |
---|
1154 | if(talentInfo->TalentTab != talentTabId) |
---|
1155 | continue; |
---|
1156 | |
---|
1157 | // find talent rank |
---|
1158 | uint32 curtalent_maxrank = 0; |
---|
1159 | for(uint32 k = 5; k > 0; --k) |
---|
1160 | { |
---|
1161 | if(talentInfo->RankID[k-1] && plr->HasSpell(talentInfo->RankID[k-1])) |
---|
1162 | { |
---|
1163 | curtalent_maxrank = k; |
---|
1164 | break; |
---|
1165 | } |
---|
1166 | } |
---|
1167 | |
---|
1168 | // not learned talent |
---|
1169 | if(!curtalent_maxrank) |
---|
1170 | continue; |
---|
1171 | |
---|
1172 | // 1 rank talent bit index |
---|
1173 | uint32 curtalent_index = talentTabPos + GetTalentInspectBitPosInTab(talentId); |
---|
1174 | |
---|
1175 | uint32 curtalent_rank_index = curtalent_index+curtalent_maxrank-1; |
---|
1176 | |
---|
1177 | // slot/offset in 7-bit bytes |
---|
1178 | uint32 curtalent_rank_slot7 = curtalent_rank_index / 7; |
---|
1179 | uint32 curtalent_rank_offset7 = curtalent_rank_index % 7; |
---|
1180 | |
---|
1181 | // rank pos with skipped 8 bit |
---|
1182 | uint32 curtalent_rank_index2 = curtalent_rank_slot7 * 8 + curtalent_rank_offset7; |
---|
1183 | |
---|
1184 | // slot/offset in 8-bit bytes with skipped high bit |
---|
1185 | uint32 curtalent_rank_slot = curtalent_rank_index2 / 8; |
---|
1186 | uint32 curtalent_rank_offset = curtalent_rank_index2 % 8; |
---|
1187 | |
---|
1188 | // apply mask |
---|
1189 | uint32 val = data.read<uint8>(guid_size + 4 + curtalent_rank_slot); |
---|
1190 | val |= (1 << curtalent_rank_offset); |
---|
1191 | data.put<uint8>(guid_size + 4 + curtalent_rank_slot, val & 0xFF); |
---|
1192 | } |
---|
1193 | |
---|
1194 | talentTabPos += GetTalentTabInspectBitSize(talentTabId); |
---|
1195 | } |
---|
1196 | } |
---|
1197 | |
---|
1198 | SendPacket(&data); |
---|
1199 | } |
---|
1200 | |
---|
1201 | void WorldSession::HandleInspectHonorStatsOpcode(WorldPacket& recv_data) |
---|
1202 | { |
---|
1203 | CHECK_PACKET_SIZE(recv_data, 8); |
---|
1204 | |
---|
1205 | uint64 guid; |
---|
1206 | recv_data >> guid; |
---|
1207 | |
---|
1208 | Player *player = objmgr.GetPlayer(guid); |
---|
1209 | |
---|
1210 | if(!player) |
---|
1211 | { |
---|
1212 | sLog.outError("InspectHonorStats: WTF, player not found..."); |
---|
1213 | return; |
---|
1214 | } |
---|
1215 | |
---|
1216 | WorldPacket data(MSG_INSPECT_HONOR_STATS, 8+1+4*4); |
---|
1217 | data << uint64(player->GetGUID()); |
---|
1218 | data << uint8(player->GetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY)); |
---|
1219 | data << uint32(player->GetUInt32Value(PLAYER_FIELD_KILLS)); |
---|
1220 | data << uint32(player->GetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION)); |
---|
1221 | data << uint32(player->GetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION)); |
---|
1222 | data << uint32(player->GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORBALE_KILLS)); |
---|
1223 | SendPacket(&data); |
---|
1224 | } |
---|
1225 | |
---|
1226 | void WorldSession::HandleWorldTeleportOpcode(WorldPacket& recv_data) |
---|
1227 | { |
---|
1228 | CHECK_PACKET_SIZE(recv_data,4+4+4+4+4+4); |
---|
1229 | |
---|
1230 | // write in client console: worldport 469 452 6454 2536 180 or /console worldport 469 452 6454 2536 180 |
---|
1231 | // Received opcode CMSG_WORLD_TELEPORT |
---|
1232 | // Time is ***, map=469, x=452.000000, y=6454.000000, z=2536.000000, orient=3.141593 |
---|
1233 | |
---|
1234 | //sLog.outDebug("Received opcode CMSG_WORLD_TELEPORT"); |
---|
1235 | |
---|
1236 | if(GetPlayer()->isInFlight()) |
---|
1237 | { |
---|
1238 | sLog.outDebug("Player '%s' (GUID: %u) in flight, ignore worldport command.",GetPlayer()->GetName(),GetPlayer()->GetGUIDLow()); |
---|
1239 | return; |
---|
1240 | } |
---|
1241 | |
---|
1242 | uint32 time; |
---|
1243 | uint32 mapid; |
---|
1244 | float PositionX; |
---|
1245 | float PositionY; |
---|
1246 | float PositionZ; |
---|
1247 | float Orientation; |
---|
1248 | |
---|
1249 | recv_data >> time; // time in m.sec. |
---|
1250 | recv_data >> mapid; |
---|
1251 | recv_data >> PositionX; |
---|
1252 | recv_data >> PositionY; |
---|
1253 | recv_data >> PositionZ; |
---|
1254 | recv_data >> Orientation; // o (3.141593 = 180 degrees) |
---|
1255 | DEBUG_LOG("Time %u sec, map=%u, x=%f, y=%f, z=%f, orient=%f", time/1000, mapid, PositionX, PositionY, PositionZ, Orientation); |
---|
1256 | |
---|
1257 | if (GetSecurity() >= SEC_ADMINISTRATOR) |
---|
1258 | GetPlayer()->TeleportTo(mapid,PositionX,PositionY,PositionZ,Orientation); |
---|
1259 | else |
---|
1260 | SendNotification(LANG_YOU_NOT_HAVE_PERMISSION); |
---|
1261 | sLog.outDebug("Received worldport command from player %s", GetPlayer()->GetName()); |
---|
1262 | } |
---|
1263 | |
---|
1264 | void WorldSession::HandleWhoisOpcode(WorldPacket& recv_data) |
---|
1265 | { |
---|
1266 | CHECK_PACKET_SIZE(recv_data, 1); |
---|
1267 | |
---|
1268 | sLog.outDebug("Received opcode CMSG_WHOIS"); |
---|
1269 | std::string charname; |
---|
1270 | recv_data >> charname; |
---|
1271 | |
---|
1272 | if (GetSecurity() < SEC_ADMINISTRATOR) |
---|
1273 | { |
---|
1274 | SendNotification(LANG_YOU_NOT_HAVE_PERMISSION); |
---|
1275 | return; |
---|
1276 | } |
---|
1277 | |
---|
1278 | if(charname.empty()) |
---|
1279 | { |
---|
1280 | SendNotification(LANG_NEED_CHARACTER_NAME); |
---|
1281 | return; |
---|
1282 | } |
---|
1283 | |
---|
1284 | normalizePlayerName (charname); |
---|
1285 | |
---|
1286 | Player *plr = objmgr.GetPlayer(charname.c_str()); |
---|
1287 | |
---|
1288 | if(!plr) |
---|
1289 | { |
---|
1290 | SendNotification(LANG_PLAYER_NOT_EXIST_OR_OFFLINE, charname.c_str()); |
---|
1291 | return; |
---|
1292 | } |
---|
1293 | |
---|
1294 | uint32 accid = plr->GetSession()->GetAccountId(); |
---|
1295 | |
---|
1296 | QueryResult *result = loginDatabase.PQuery("SELECT username,email,last_ip FROM account WHERE id=%u", accid); |
---|
1297 | if(!result) |
---|
1298 | { |
---|
1299 | SendNotification(LANG_ACCOUNT_FOR_PLAYER_NOT_FOUND, charname.c_str()); |
---|
1300 | return; |
---|
1301 | } |
---|
1302 | |
---|
1303 | Field *fields = result->Fetch(); |
---|
1304 | std::string acc = fields[0].GetCppString(); |
---|
1305 | if(acc.empty()) |
---|
1306 | acc = "Unknown"; |
---|
1307 | std::string email = fields[1].GetCppString(); |
---|
1308 | if(email.empty()) |
---|
1309 | email = "Unknown"; |
---|
1310 | std::string lastip = fields[2].GetCppString(); |
---|
1311 | if(lastip.empty()) |
---|
1312 | lastip = "Unknown"; |
---|
1313 | |
---|
1314 | std::string msg = charname + "'s " + "account is " + acc + ", e-mail: " + email + ", last ip: " + lastip; |
---|
1315 | |
---|
1316 | WorldPacket data(SMSG_WHOIS, msg.size()+1); |
---|
1317 | data << msg; |
---|
1318 | _player->GetSession()->SendPacket(&data); |
---|
1319 | |
---|
1320 | delete result; |
---|
1321 | |
---|
1322 | sLog.outDebug("Received whois command from player %s for character %s", GetPlayer()->GetName(), charname.c_str()); |
---|
1323 | } |
---|
1324 | |
---|
1325 | void WorldSession::HandleReportSpamOpcode( WorldPacket & recv_data ) |
---|
1326 | { |
---|
1327 | CHECK_PACKET_SIZE(recv_data, 1+8); |
---|
1328 | sLog.outDebug("WORLD: CMSG_REPORT_SPAM"); |
---|
1329 | recv_data.hexlike(); |
---|
1330 | |
---|
1331 | uint8 spam_type; // 0 - mail, 1 - chat |
---|
1332 | uint64 spammer_guid; |
---|
1333 | uint32 unk1, unk2, unk3, unk4 = 0; |
---|
1334 | std::string description = ""; |
---|
1335 | recv_data >> spam_type; // unk 0x01 const, may be spam type (mail/chat) |
---|
1336 | recv_data >> spammer_guid; // player guid |
---|
1337 | switch(spam_type) |
---|
1338 | { |
---|
1339 | case 0: |
---|
1340 | CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+4+4+4); |
---|
1341 | recv_data >> unk1; // const 0 |
---|
1342 | recv_data >> unk2; // probably mail id |
---|
1343 | recv_data >> unk3; // const 0 |
---|
1344 | break; |
---|
1345 | case 1: |
---|
1346 | CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+4+4+4+4+1); |
---|
1347 | recv_data >> unk1; // probably language |
---|
1348 | recv_data >> unk2; // message type? |
---|
1349 | recv_data >> unk3; // probably channel id |
---|
1350 | recv_data >> unk4; // unk random value |
---|
1351 | recv_data >> description; // spam description string (messagetype, channel name, player name, message) |
---|
1352 | break; |
---|
1353 | } |
---|
1354 | |
---|
1355 | // NOTE: all chat messages from this spammer automatically ignored by spam reporter until logout in case chat spam. |
---|
1356 | // if it's mail spam - ALL mails from this spammer automatically removed by client |
---|
1357 | |
---|
1358 | // Complaint Received message |
---|
1359 | WorldPacket data(SMSG_COMPLAIN_RESULT, 1); |
---|
1360 | data << uint8(0); |
---|
1361 | SendPacket(&data); |
---|
1362 | |
---|
1363 | 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()); |
---|
1364 | } |
---|
1365 | |
---|
1366 | void WorldSession::HandleRealmStateRequestOpcode( WorldPacket & recv_data ) |
---|
1367 | { |
---|
1368 | CHECK_PACKET_SIZE(recv_data, 4); |
---|
1369 | |
---|
1370 | sLog.outDebug("CMSG_REALM_SPLIT"); |
---|
1371 | |
---|
1372 | uint32 unk; |
---|
1373 | std::string split_date = "01/01/01"; |
---|
1374 | recv_data >> unk; |
---|
1375 | |
---|
1376 | WorldPacket data(SMSG_REALM_SPLIT, 4+4+split_date.size()+1); |
---|
1377 | data << unk; |
---|
1378 | data << uint32(0x00000000); // realm split state |
---|
1379 | // split states: |
---|
1380 | // 0x0 realm normal |
---|
1381 | // 0x1 realm split |
---|
1382 | // 0x2 realm split pending |
---|
1383 | data << split_date; |
---|
1384 | SendPacket(&data); |
---|
1385 | //sLog.outDebug("response sent %u", unk); |
---|
1386 | } |
---|
1387 | |
---|
1388 | void WorldSession::HandleFarSightOpcode( WorldPacket & recv_data ) |
---|
1389 | { |
---|
1390 | CHECK_PACKET_SIZE(recv_data, 1); |
---|
1391 | |
---|
1392 | sLog.outDebug("WORLD: CMSG_FAR_SIGHT"); |
---|
1393 | //recv_data.hexlike(); |
---|
1394 | |
---|
1395 | uint8 apply; |
---|
1396 | recv_data >> apply; |
---|
1397 | |
---|
1398 | CellPair pair; |
---|
1399 | |
---|
1400 | switch(apply) |
---|
1401 | { |
---|
1402 | case 0: |
---|
1403 | _player->SetFarsightVision(false); |
---|
1404 | pair = Trinity::ComputeCellPair(_player->GetPositionX(), _player->GetPositionY()); |
---|
1405 | sLog.outDebug("Player %u set vision to himself", _player->GetGUIDLow()); |
---|
1406 | break; |
---|
1407 | case 1: |
---|
1408 | _player->SetFarsightVision(true); |
---|
1409 | if (WorldObject* obj = _player->GetFarsightTarget()) |
---|
1410 | pair = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); |
---|
1411 | else |
---|
1412 | return; |
---|
1413 | sLog.outDebug("Player %u set vision to farsight target " I64FMTD ".", _player->GetGUIDLow(), _player->GetUInt64Value(PLAYER_FARSIGHT)); |
---|
1414 | break; |
---|
1415 | default: |
---|
1416 | sLog.outDebug("Unhandled mode in CMSG_FAR_SIGHT: %u", apply); |
---|
1417 | return; |
---|
1418 | } |
---|
1419 | // Update visibility after vision change |
---|
1420 | Cell cell(pair); |
---|
1421 | GetPlayer()->GetMap()->UpdateObjectsVisibilityFor(_player, cell, pair); |
---|
1422 | } |
---|
1423 | |
---|
1424 | void WorldSession::HandleChooseTitleOpcode( WorldPacket & recv_data ) |
---|
1425 | { |
---|
1426 | CHECK_PACKET_SIZE(recv_data, 4); |
---|
1427 | |
---|
1428 | sLog.outDebug("CMSG_SET_TITLE"); |
---|
1429 | |
---|
1430 | int32 title; |
---|
1431 | recv_data >> title; |
---|
1432 | |
---|
1433 | // -1 at none |
---|
1434 | if(title > 0 && title < 64) |
---|
1435 | { |
---|
1436 | if(!GetPlayer()->HasFlag64(PLAYER__FIELD_KNOWN_TITLES,uint64(1) << title)) |
---|
1437 | return; |
---|
1438 | } |
---|
1439 | else |
---|
1440 | title = 0; |
---|
1441 | |
---|
1442 | GetPlayer()->SetUInt32Value(PLAYER_CHOSEN_TITLE, title); |
---|
1443 | } |
---|
1444 | |
---|
1445 | void WorldSession::HandleAllowMoveAckOpcode( WorldPacket & recv_data ) |
---|
1446 | { |
---|
1447 | CHECK_PACKET_SIZE(recv_data, 4+4); |
---|
1448 | |
---|
1449 | sLog.outDebug("CMSG_ALLOW_MOVE_ACK"); |
---|
1450 | |
---|
1451 | uint32 counter, time_; |
---|
1452 | recv_data >> counter >> time_; |
---|
1453 | |
---|
1454 | // time_ seems always more than getMSTime() |
---|
1455 | uint32 diff = getMSTimeDiff(getMSTime(),time_); |
---|
1456 | |
---|
1457 | sLog.outDebug("response sent: counter %u, time %u (HEX: %X), ms. time %u, diff %u", counter, time_, time_, getMSTime(), diff); |
---|
1458 | } |
---|
1459 | |
---|
1460 | void WorldSession::HandleResetInstancesOpcode( WorldPacket & /*recv_data*/ ) |
---|
1461 | { |
---|
1462 | sLog.outDebug("WORLD: CMSG_RESET_INSTANCES"); |
---|
1463 | Group *pGroup = _player->GetGroup(); |
---|
1464 | if(pGroup) |
---|
1465 | { |
---|
1466 | if(pGroup->IsLeader(_player->GetGUID())) |
---|
1467 | pGroup->ResetInstances(INSTANCE_RESET_ALL, _player); |
---|
1468 | } |
---|
1469 | else |
---|
1470 | _player->ResetInstances(INSTANCE_RESET_ALL); |
---|
1471 | } |
---|
1472 | |
---|
1473 | void WorldSession::HandleDungeonDifficultyOpcode( WorldPacket & recv_data ) |
---|
1474 | { |
---|
1475 | CHECK_PACKET_SIZE(recv_data, 4); |
---|
1476 | |
---|
1477 | sLog.outDebug("MSG_SET_DUNGEON_DIFFICULTY"); |
---|
1478 | |
---|
1479 | uint32 mode; |
---|
1480 | recv_data >> mode; |
---|
1481 | |
---|
1482 | if(mode == _player->GetDifficulty()) |
---|
1483 | return; |
---|
1484 | |
---|
1485 | if(mode > DIFFICULTY_HEROIC) |
---|
1486 | { |
---|
1487 | sLog.outError("WorldSession::HandleDungeonDifficultyOpcode: player %d sent an invalid instance mode %d!", _player->GetGUIDLow(), mode); |
---|
1488 | return; |
---|
1489 | } |
---|
1490 | |
---|
1491 | // cannot reset while in an instance |
---|
1492 | Map *map = _player->GetMap(); |
---|
1493 | if(map && map->IsDungeon()) |
---|
1494 | { |
---|
1495 | sLog.outError("WorldSession::HandleDungeonDifficultyOpcode: player %d tried to reset the instance while inside!", _player->GetGUIDLow()); |
---|
1496 | return; |
---|
1497 | } |
---|
1498 | |
---|
1499 | if(_player->getLevel() < LEVELREQUIREMENT_HEROIC) |
---|
1500 | return; |
---|
1501 | Group *pGroup = _player->GetGroup(); |
---|
1502 | if(pGroup) |
---|
1503 | { |
---|
1504 | if(pGroup->IsLeader(_player->GetGUID())) |
---|
1505 | { |
---|
1506 | // the difficulty is set even if the instances can't be reset |
---|
1507 | //_player->SendDungeonDifficulty(true); |
---|
1508 | pGroup->ResetInstances(INSTANCE_RESET_CHANGE_DIFFICULTY, _player); |
---|
1509 | pGroup->SetDifficulty(mode); |
---|
1510 | } |
---|
1511 | } |
---|
1512 | else |
---|
1513 | { |
---|
1514 | _player->ResetInstances(INSTANCE_RESET_CHANGE_DIFFICULTY); |
---|
1515 | _player->SetDifficulty(mode); |
---|
1516 | } |
---|
1517 | } |
---|
1518 | |
---|
1519 | void WorldSession::HandleNewUnknownOpcode( WorldPacket & recv_data ) |
---|
1520 | { |
---|
1521 | sLog.outDebug("New Unknown Opcode %u", recv_data.GetOpcode()); |
---|
1522 | recv_data.hexlike(); |
---|
1523 | /* |
---|
1524 | New Unknown Opcode 837 |
---|
1525 | STORAGE_SIZE: 60 |
---|
1526 | 02 00 00 00 00 00 00 00 | 00 00 00 00 01 20 00 00 |
---|
1527 | 89 EB 33 01 71 5C 24 C4 | 15 03 35 45 74 47 8B 42 |
---|
1528 | BA B8 1B 40 00 00 00 00 | 00 00 00 00 77 66 42 BF |
---|
1529 | 23 91 26 3F 00 00 60 41 | 00 00 00 00 |
---|
1530 | |
---|
1531 | New Unknown Opcode 837 |
---|
1532 | STORAGE_SIZE: 44 |
---|
1533 | 02 00 00 00 00 00 00 00 | 00 00 00 00 00 00 80 00 |
---|
1534 | 7B 80 34 01 84 EA 2B C4 | 5F A1 36 45 C9 39 1C 42 |
---|
1535 | BA B8 1B 40 CE 06 00 00 | 00 00 80 3F |
---|
1536 | */ |
---|
1537 | } |
---|
1538 | |
---|
1539 | void WorldSession::HandleDismountOpcode( WorldPacket & /*recv_data*/ ) |
---|
1540 | { |
---|
1541 | sLog.outDebug("WORLD: CMSG_CANCEL_MOUNT_AURA"); |
---|
1542 | //recv_data.hexlike(); |
---|
1543 | |
---|
1544 | //If player is not mounted, so go out :) |
---|
1545 | if (!_player->IsMounted()) // not blizz like; no any messages on blizz |
---|
1546 | { |
---|
1547 | ChatHandler(this).SendSysMessage(LANG_CHAR_NON_MOUNTED); |
---|
1548 | return; |
---|
1549 | } |
---|
1550 | |
---|
1551 | if(_player->isInFlight()) // not blizz like; no any messages on blizz |
---|
1552 | { |
---|
1553 | ChatHandler(this).SendSysMessage(LANG_YOU_IN_FLIGHT); |
---|
1554 | return; |
---|
1555 | } |
---|
1556 | |
---|
1557 | _player->Unmount(); |
---|
1558 | _player->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED); |
---|
1559 | } |
---|
1560 | |
---|
1561 | void WorldSession::HandleMoveFlyModeChangeAckOpcode( WorldPacket & recv_data ) |
---|
1562 | { |
---|
1563 | CHECK_PACKET_SIZE(recv_data, 8+4+4); |
---|
1564 | |
---|
1565 | // fly mode on/off |
---|
1566 | sLog.outDebug("WORLD: CMSG_MOVE_SET_CAN_FLY_ACK"); |
---|
1567 | //recv_data.hexlike(); |
---|
1568 | |
---|
1569 | uint64 guid; |
---|
1570 | uint32 unk; |
---|
1571 | uint32 flags; |
---|
1572 | |
---|
1573 | recv_data >> guid >> unk >> flags; |
---|
1574 | |
---|
1575 | _player->SetUnitMovementFlags(flags); |
---|
1576 | /* |
---|
1577 | on: |
---|
1578 | 25 00 00 00 00 00 00 00 | 00 00 00 00 00 00 80 00 |
---|
1579 | 85 4E A9 01 19 BA 7A C3 | 42 0D 70 44 44 B0 A8 42 |
---|
1580 | 78 15 94 40 39 03 00 00 | 00 00 80 3F |
---|
1581 | off: |
---|
1582 | 25 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |
---|
1583 | 10 FD A9 01 19 BA 7A C3 | 42 0D 70 44 44 B0 A8 42 |
---|
1584 | 78 15 94 40 39 03 00 00 | 00 00 00 00 |
---|
1585 | */ |
---|
1586 | } |
---|
1587 | |
---|
1588 | void WorldSession::HandleRequestPetInfoOpcode( WorldPacket & /*recv_data */) |
---|
1589 | { |
---|
1590 | /* |
---|
1591 | sLog.outDebug("WORLD: CMSG_REQUEST_PET_INFO"); |
---|
1592 | recv_data.hexlike(); |
---|
1593 | */ |
---|
1594 | } |
---|
1595 | |
---|
1596 | void WorldSession::HandleSetTaxiBenchmarkOpcode( WorldPacket & recv_data ) |
---|
1597 | { |
---|
1598 | CHECK_PACKET_SIZE(recv_data, 1); |
---|
1599 | |
---|
1600 | uint8 mode; |
---|
1601 | recv_data >> mode; |
---|
1602 | |
---|
1603 | sLog.outDebug("Client used \"/timetest %d\" command", mode); |
---|
1604 | } |
---|