[2] | 1 | /* |
---|
[102] | 2 | * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> |
---|
| 3 | * |
---|
[44] | 4 | * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> |
---|
[2] | 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 |
---|
[44] | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
[2] | 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 |
---|
[44] | 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
[2] | 19 | */ |
---|
| 20 | |
---|
| 21 | #include "Common.h" |
---|
| 22 | #include "WorldPacket.h" |
---|
| 23 | #include "WorldSession.h" |
---|
| 24 | #include "Opcodes.h" |
---|
| 25 | #include "Log.h" |
---|
| 26 | #include "World.h" |
---|
| 27 | #include "Corpse.h" |
---|
| 28 | #include "Player.h" |
---|
| 29 | #include "MapManager.h" |
---|
| 30 | #include "Transports.h" |
---|
| 31 | #include "BattleGround.h" |
---|
| 32 | #include "WaypointMovementGenerator.h" |
---|
| 33 | #include "InstanceSaveMgr.h" |
---|
| 34 | |
---|
| 35 | void WorldSession::HandleMoveWorldportAckOpcode( WorldPacket & /*recv_data*/ ) |
---|
| 36 | { |
---|
| 37 | sLog.outDebug( "WORLD: got MSG_MOVE_WORLDPORT_ACK." ); |
---|
| 38 | HandleMoveWorldportAckOpcode(); |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | void WorldSession::HandleMoveWorldportAckOpcode() |
---|
| 42 | { |
---|
| 43 | // get the teleport destination |
---|
| 44 | WorldLocation &loc = GetPlayer()->GetTeleportDest(); |
---|
| 45 | |
---|
| 46 | // possible errors in the coordinate validity check |
---|
| 47 | if(!MapManager::IsValidMapCoord(loc.mapid,loc.x,loc.y,loc.z,loc.o)) |
---|
| 48 | { |
---|
| 49 | LogoutPlayer(false); |
---|
| 50 | return; |
---|
| 51 | } |
---|
| 52 | |
---|
[44] | 53 | if(!sWorld.IsAllowedMap(loc.mapid) && (GetSecurity() < SEC_GAMEMASTER)) |
---|
| 54 | { |
---|
| 55 | if(sWorld.IsAllowedMap(GetPlayer()->m_homebindMapId)) |
---|
| 56 | GetPlayer()->TeleportTo(GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation()); |
---|
| 57 | else |
---|
| 58 | LogoutPlayer(false); |
---|
| 59 | return; |
---|
| 60 | } |
---|
| 61 | |
---|
[2] | 62 | // get the destination map entry, not the current one, this will fix homebind and reset greeting |
---|
| 63 | MapEntry const* mEntry = sMapStore.LookupEntry(loc.mapid); |
---|
| 64 | InstanceTemplate const* mInstance = objmgr.GetInstanceTemplate(loc.mapid); |
---|
| 65 | |
---|
| 66 | // reset instance validity, except if going to an instance inside an instance |
---|
| 67 | if(GetPlayer()->m_InstanceValid == false && !mInstance) |
---|
| 68 | GetPlayer()->m_InstanceValid = true; |
---|
| 69 | |
---|
| 70 | GetPlayer()->SetSemaphoreTeleport(false); |
---|
| 71 | |
---|
| 72 | // relocate the player to the teleport destination |
---|
| 73 | GetPlayer()->SetMapId(loc.mapid); |
---|
| 74 | GetPlayer()->Relocate(loc.x, loc.y, loc.z, loc.o); |
---|
| 75 | |
---|
| 76 | // since the MapId is set before the GetInstance call, the InstanceId must be set to 0 |
---|
| 77 | // to let GetInstance() determine the proper InstanceId based on the player's binds |
---|
| 78 | GetPlayer()->SetInstanceId(0); |
---|
| 79 | |
---|
| 80 | // check this before Map::Add(player), because that will create the instance save! |
---|
| 81 | bool reset_notify = (GetPlayer()->GetBoundInstance(GetPlayer()->GetMapId(), GetPlayer()->GetDifficulty()) == NULL); |
---|
| 82 | |
---|
| 83 | GetPlayer()->SendInitialPacketsBeforeAddToMap(); |
---|
| 84 | // the CanEnter checks are done in TeleporTo but conditions may change |
---|
| 85 | // while the player is in transit, for example the map may get full |
---|
| 86 | if(!MapManager::Instance().GetMap(GetPlayer()->GetMapId(), GetPlayer())->Add(GetPlayer())) |
---|
| 87 | { |
---|
| 88 | sLog.outDebug("WORLD: teleport of player %s (%d) to location %d,%f,%f,%f,%f failed", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow(), loc.mapid, loc.x, loc.y, loc.z, loc.o); |
---|
| 89 | // teleport the player home |
---|
| 90 | GetPlayer()->SetDontMove(false); |
---|
| 91 | if(!GetPlayer()->TeleportTo(GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation())) |
---|
| 92 | { |
---|
| 93 | // the player must always be able to teleport home |
---|
| 94 | sLog.outError("WORLD: failed to teleport player %s (%d) to homebind location %d,%f,%f,%f,%f!", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow(), GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation()); |
---|
| 95 | assert(false); |
---|
| 96 | } |
---|
| 97 | return; |
---|
| 98 | } |
---|
| 99 | GetPlayer()->SendInitialPacketsAfterAddToMap(); |
---|
| 100 | |
---|
| 101 | // flight fast teleport case |
---|
| 102 | if(GetPlayer()->GetMotionMaster()->GetCurrentMovementGeneratorType()==FLIGHT_MOTION_TYPE) |
---|
| 103 | { |
---|
| 104 | if(!_player->InBattleGround()) |
---|
| 105 | { |
---|
| 106 | // short preparations to continue flight |
---|
| 107 | GetPlayer()->SetDontMove(false); |
---|
| 108 | FlightPathMovementGenerator* flight = (FlightPathMovementGenerator*)(GetPlayer()->GetMotionMaster()->top()); |
---|
| 109 | flight->Initialize(*GetPlayer()); |
---|
| 110 | return; |
---|
| 111 | } |
---|
| 112 | |
---|
| 113 | // battleground state prepare, stop flight |
---|
| 114 | GetPlayer()->GetMotionMaster()->MovementExpired(); |
---|
| 115 | GetPlayer()->m_taxi.ClearTaxiDestinations(); |
---|
| 116 | } |
---|
| 117 | |
---|
| 118 | // resurrect character at enter into instance where his corpse exist after add to map |
---|
| 119 | Corpse *corpse = GetPlayer()->GetCorpse(); |
---|
| 120 | if (corpse && corpse->GetType() != CORPSE_BONES && corpse->GetMapId() == GetPlayer()->GetMapId()) |
---|
| 121 | { |
---|
| 122 | if( mEntry->IsDungeon() ) |
---|
| 123 | { |
---|
| 124 | GetPlayer()->ResurrectPlayer(0.5f,false); |
---|
| 125 | GetPlayer()->SpawnCorpseBones(); |
---|
| 126 | GetPlayer()->SaveToDB(); |
---|
| 127 | } |
---|
| 128 | } |
---|
| 129 | |
---|
| 130 | if(mEntry->IsRaid() && mInstance) |
---|
| 131 | { |
---|
| 132 | if(reset_notify) |
---|
| 133 | { |
---|
| 134 | uint32 timeleft = sInstanceSaveManager.GetResetTimeFor(GetPlayer()->GetMapId()) - time(NULL); |
---|
| 135 | GetPlayer()->SendInstanceResetWarning(GetPlayer()->GetMapId(), timeleft); // greeting at the entrance of the resort raid instance |
---|
| 136 | } |
---|
| 137 | } |
---|
| 138 | |
---|
| 139 | // mount allow check |
---|
| 140 | if(!mEntry->IsMountAllowed()) |
---|
| 141 | _player->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED); |
---|
| 142 | |
---|
| 143 | // battleground state preper |
---|
[9] | 144 | // only add to bg group and object, if the player was invited (else he entered through command) |
---|
| 145 | if(_player->InBattleGround() && _player->IsInvitedForBattleGroundInstance(_player->GetBattleGroundId())) |
---|
[2] | 146 | { |
---|
| 147 | BattleGround *bg = _player->GetBattleGround(); |
---|
| 148 | if(bg) |
---|
| 149 | { |
---|
[9] | 150 | bg->AddPlayer(_player); |
---|
[2] | 151 | if(bg->GetMapId() == _player->GetMapId()) // we teleported to bg |
---|
| 152 | { |
---|
[9] | 153 | // get the team this way, because arenas might 'override' the teams. |
---|
| 154 | uint32 team = bg->GetPlayerTeam(_player->GetGUID()); |
---|
| 155 | if(!team) |
---|
| 156 | team = _player->GetTeam(); |
---|
| 157 | if(!bg->GetBgRaid(team)) // first player joined |
---|
[2] | 158 | { |
---|
| 159 | Group *group = new Group; |
---|
[9] | 160 | bg->SetBgRaid(team, group); |
---|
[2] | 161 | group->Create(_player->GetGUIDLow(), _player->GetName()); |
---|
| 162 | } |
---|
| 163 | else // raid already exist |
---|
| 164 | { |
---|
[9] | 165 | bg->GetBgRaid(team)->AddMember(_player->GetGUID(), _player->GetName()); |
---|
[2] | 166 | } |
---|
| 167 | } |
---|
| 168 | } |
---|
| 169 | } |
---|
| 170 | |
---|
| 171 | // honorless target |
---|
| 172 | if(GetPlayer()->pvpInfo.inHostileArea) |
---|
| 173 | GetPlayer()->CastSpell(GetPlayer(), 2479, true); |
---|
| 174 | |
---|
| 175 | // resummon pet |
---|
| 176 | if(GetPlayer()->m_temporaryUnsummonedPetNumber) |
---|
| 177 | { |
---|
| 178 | Pet* NewPet = new Pet; |
---|
| 179 | if(!NewPet->LoadPetFromDB(GetPlayer(), 0, GetPlayer()->m_temporaryUnsummonedPetNumber, true)) |
---|
| 180 | delete NewPet; |
---|
| 181 | |
---|
| 182 | GetPlayer()->m_temporaryUnsummonedPetNumber = 0; |
---|
| 183 | } |
---|
| 184 | |
---|
| 185 | GetPlayer()->SetDontMove(false); |
---|
| 186 | } |
---|
| 187 | |
---|
| 188 | void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data ) |
---|
| 189 | { |
---|
| 190 | CHECK_PACKET_SIZE(recv_data, 4+1+4+4+4+4+4); |
---|
| 191 | |
---|
| 192 | /* extract packet */ |
---|
| 193 | MovementInfo movementInfo; |
---|
| 194 | uint32 MovementFlags; |
---|
| 195 | |
---|
| 196 | recv_data >> MovementFlags; |
---|
| 197 | recv_data >> movementInfo.unk1; |
---|
| 198 | recv_data >> movementInfo.time; |
---|
| 199 | recv_data >> movementInfo.x; |
---|
| 200 | recv_data >> movementInfo.y; |
---|
| 201 | recv_data >> movementInfo.z; |
---|
| 202 | recv_data >> movementInfo.o; |
---|
| 203 | |
---|
| 204 | if(MovementFlags & MOVEMENTFLAG_ONTRANSPORT) |
---|
| 205 | { |
---|
| 206 | // recheck |
---|
| 207 | CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+8+4+4+4+4+4); |
---|
| 208 | |
---|
| 209 | recv_data >> movementInfo.t_guid; |
---|
| 210 | recv_data >> movementInfo.t_x; |
---|
| 211 | recv_data >> movementInfo.t_y; |
---|
| 212 | recv_data >> movementInfo.t_z; |
---|
| 213 | recv_data >> movementInfo.t_o; |
---|
| 214 | recv_data >> movementInfo.t_time; |
---|
| 215 | } |
---|
| 216 | |
---|
| 217 | if(MovementFlags & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING2)) |
---|
| 218 | { |
---|
| 219 | // recheck |
---|
| 220 | CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+4); |
---|
| 221 | |
---|
| 222 | recv_data >> movementInfo.s_pitch; // pitch, -1.55=looking down, 0=looking straight forward, +1.55=looking up |
---|
| 223 | } |
---|
| 224 | |
---|
| 225 | // recheck |
---|
| 226 | CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+4); |
---|
| 227 | |
---|
| 228 | recv_data >> movementInfo.fallTime; // duration of last jump (when in jump duration from jump begin to now) |
---|
| 229 | |
---|
| 230 | if(MovementFlags & MOVEMENTFLAG_JUMPING) |
---|
| 231 | { |
---|
| 232 | // recheck |
---|
| 233 | CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+4+4+4+4); |
---|
| 234 | |
---|
| 235 | recv_data >> movementInfo.j_unk; // constant, but different when jumping in water and on land? |
---|
| 236 | recv_data >> movementInfo.j_sinAngle; // sin of angle between orientation0 and players orientation |
---|
| 237 | recv_data >> movementInfo.j_cosAngle; // cos of angle between orientation0 and players orientation |
---|
| 238 | recv_data >> movementInfo.j_xyspeed; // speed of xy movement |
---|
| 239 | } |
---|
| 240 | |
---|
| 241 | if(MovementFlags & MOVEMENTFLAG_SPLINE) |
---|
| 242 | { |
---|
| 243 | // recheck |
---|
| 244 | CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+4); |
---|
| 245 | |
---|
| 246 | recv_data >> movementInfo.u_unk1; // unknown |
---|
| 247 | } |
---|
| 248 | /*----------------*/ |
---|
| 249 | |
---|
| 250 | if(recv_data.size() != recv_data.rpos()) |
---|
| 251 | { |
---|
| 252 | sLog.outError("MovementHandler: player %s (guid %d, account %u) sent a packet (opcode %u) that is %u bytes larger than it should be. Kicked as cheater.", _player->GetName(), _player->GetGUIDLow(), _player->GetSession()->GetAccountId(), recv_data.GetOpcode(), recv_data.size() - recv_data.rpos()); |
---|
| 253 | KickPlayer(); |
---|
| 254 | return; |
---|
| 255 | } |
---|
| 256 | |
---|
[44] | 257 | if (!Trinity::IsValidMapCoord(movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o)) |
---|
[2] | 258 | return; |
---|
| 259 | |
---|
[174] | 260 | // Handle possessed unit movement separately |
---|
| 261 | Unit* pos_unit = GetPlayer()->GetCharm(); |
---|
| 262 | if (pos_unit && pos_unit->isPossessed()) // can be charmed but not possessed |
---|
| 263 | { |
---|
| 264 | HandlePossessedMovement(recv_data, movementInfo, MovementFlags); |
---|
| 265 | return; |
---|
| 266 | } |
---|
| 267 | |
---|
| 268 | if (GetPlayer()->GetDontMove()) |
---|
| 269 | return; |
---|
| 270 | |
---|
| 271 | //Save movement flags |
---|
| 272 | GetPlayer()->SetUnitMovementFlags(MovementFlags); |
---|
| 273 | |
---|
[2] | 274 | /* handle special cases */ |
---|
| 275 | if (MovementFlags & MOVEMENTFLAG_ONTRANSPORT) |
---|
| 276 | { |
---|
| 277 | // transports size limited |
---|
| 278 | // (also received at zeppelin leave by some reason with t_* as absolute in continent coordinates, can be safely skipped) |
---|
| 279 | if( movementInfo.t_x > 50 || movementInfo.t_y > 50 || movementInfo.t_z > 50 ) |
---|
| 280 | return; |
---|
| 281 | |
---|
[44] | 282 | if( !Trinity::IsValidMapCoord(movementInfo.x+movementInfo.t_x, movementInfo.y+movementInfo.t_y, |
---|
[2] | 283 | movementInfo.z+movementInfo.t_z, movementInfo.o+movementInfo.t_o) ) |
---|
| 284 | return; |
---|
| 285 | |
---|
| 286 | // if we boarded a transport, add us to it |
---|
| 287 | if (!GetPlayer()->m_transport) |
---|
| 288 | { |
---|
| 289 | // elevators also cause the client to send MOVEMENTFLAG_ONTRANSPORT - just unmount if the guid can be found in the transport list |
---|
| 290 | for (MapManager::TransportSet::iterator iter = MapManager::Instance().m_Transports.begin(); iter != MapManager::Instance().m_Transports.end(); ++iter) |
---|
| 291 | { |
---|
| 292 | if ((*iter)->GetGUID() == movementInfo.t_guid) |
---|
| 293 | { |
---|
| 294 | // unmount before boarding |
---|
[174] | 295 | GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED); |
---|
[2] | 296 | |
---|
| 297 | GetPlayer()->m_transport = (*iter); |
---|
| 298 | (*iter)->AddPassenger(GetPlayer()); |
---|
| 299 | break; |
---|
| 300 | } |
---|
| 301 | } |
---|
| 302 | } |
---|
| 303 | } |
---|
| 304 | else if (GetPlayer()->m_transport) // if we were on a transport, leave |
---|
| 305 | { |
---|
| 306 | GetPlayer()->m_transport->RemovePassenger(GetPlayer()); |
---|
| 307 | GetPlayer()->m_transport = NULL; |
---|
| 308 | movementInfo.t_x = 0.0f; |
---|
| 309 | movementInfo.t_y = 0.0f; |
---|
| 310 | movementInfo.t_z = 0.0f; |
---|
| 311 | movementInfo.t_o = 0.0f; |
---|
| 312 | movementInfo.t_time = 0; |
---|
| 313 | } |
---|
| 314 | |
---|
[174] | 315 | // handle fall damage |
---|
| 316 | if (recv_data.GetOpcode() == MSG_MOVE_FALL_LAND) |
---|
| 317 | GetPlayer()->HandleFallDamage(movementInfo); |
---|
[2] | 318 | |
---|
| 319 | if(((MovementFlags & MOVEMENTFLAG_SWIMMING) != 0) != GetPlayer()->IsInWater()) |
---|
| 320 | { |
---|
| 321 | // now client not include swimming flag in case jumping under water |
---|
| 322 | GetPlayer()->SetInWater( !GetPlayer()->IsInWater() || GetPlayer()->GetBaseMap()->IsUnderWater(movementInfo.x, movementInfo.y, movementInfo.z) ); |
---|
| 323 | } |
---|
| 324 | |
---|
| 325 | /*----------------------*/ |
---|
| 326 | |
---|
| 327 | /* process position-change */ |
---|
| 328 | recv_data.put<uint32>(5, getMSTime()); // offset flags(4) + unk(1) |
---|
| 329 | WorldPacket data(recv_data.GetOpcode(), (GetPlayer()->GetPackGUID().size()+recv_data.size())); |
---|
| 330 | data.append(GetPlayer()->GetPackGUID()); |
---|
| 331 | data.append(recv_data.contents(), recv_data.size()); |
---|
| 332 | GetPlayer()->SendMessageToSet(&data, false); |
---|
| 333 | |
---|
| 334 | GetPlayer()->SetPosition(movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o); |
---|
| 335 | GetPlayer()->m_movementInfo = movementInfo; |
---|
| 336 | |
---|
| 337 | if(GetPlayer()->isMovingOrTurning()) |
---|
| 338 | GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); |
---|
| 339 | |
---|
| 340 | if(movementInfo.z < -500.0f) |
---|
[174] | 341 | GetPlayer()->HandleFallUnderMap(); |
---|
| 342 | } |
---|
| 343 | |
---|
| 344 | void WorldSession::HandlePossessedMovement(WorldPacket& recv_data, MovementInfo& movementInfo, uint32& MovementFlags) |
---|
| 345 | { |
---|
| 346 | // Whatever the client is controlling, it will send the GUID of the original player. |
---|
| 347 | // If current player is controlling, it must be handled like the controlled player sent these opcodes |
---|
| 348 | |
---|
| 349 | Unit* pos_unit = GetPlayer()->GetCharm(); |
---|
| 350 | |
---|
| 351 | if (pos_unit->GetTypeId() == TYPEID_PLAYER && ((Player*)pos_unit)->GetDontMove()) |
---|
| 352 | return; |
---|
| 353 | |
---|
| 354 | //Save movement flags |
---|
| 355 | pos_unit->SetUnitMovementFlags(MovementFlags); |
---|
| 356 | |
---|
| 357 | // Remove possession if possessed unit enters a transport |
---|
| 358 | if (MovementFlags & MOVEMENTFLAG_ONTRANSPORT) |
---|
[2] | 359 | { |
---|
[174] | 360 | GetPlayer()->RemovePossess(true); |
---|
| 361 | return; |
---|
| 362 | } |
---|
| 363 | |
---|
| 364 | recv_data.put<uint32>(5, getMSTime()); |
---|
| 365 | WorldPacket data(recv_data.GetOpcode(), pos_unit->GetPackGUID().size()+recv_data.size()); |
---|
| 366 | data.append(pos_unit->GetPackGUID()); |
---|
| 367 | data.append(recv_data.contents(), recv_data.size()); |
---|
| 368 | // Send the packet to self but not to the possessed player; for creatures the first bool is irrelevant |
---|
| 369 | pos_unit->SendMessageToSet(&data, true, false); |
---|
| 370 | |
---|
| 371 | // Possessed is a player |
---|
| 372 | if (pos_unit->GetTypeId() == TYPEID_PLAYER) |
---|
| 373 | { |
---|
| 374 | Player* plr = (Player*)pos_unit; |
---|
| 375 | |
---|
| 376 | if (recv_data.GetOpcode() == MSG_MOVE_FALL_LAND) |
---|
| 377 | plr->HandleFallDamage(movementInfo); |
---|
| 378 | |
---|
| 379 | if(((MovementFlags & MOVEMENTFLAG_SWIMMING) != 0) != plr->IsInWater()) |
---|
[2] | 380 | { |
---|
[174] | 381 | // Now client not include swimming flag in case jumping under water |
---|
| 382 | plr->SetInWater( !plr->IsInWater() || plr->GetBaseMap()->IsUnderWater(movementInfo.x, movementInfo.y, movementInfo.z) ); |
---|
[2] | 383 | } |
---|
[174] | 384 | |
---|
| 385 | plr->SetPosition(movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o, false); |
---|
| 386 | plr->m_movementInfo = movementInfo; |
---|
[2] | 387 | |
---|
[174] | 388 | if(plr->isMovingOrTurning()) |
---|
| 389 | plr->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); |
---|
| 390 | |
---|
| 391 | if(movementInfo.z < -500.0f) |
---|
| 392 | { |
---|
| 393 | GetPlayer()->RemovePossess(false); |
---|
| 394 | plr->HandleFallUnderMap(); |
---|
[9] | 395 | } |
---|
[174] | 396 | } |
---|
| 397 | else // Possessed unit is a creature |
---|
| 398 | { |
---|
| 399 | Map* map = MapManager::Instance().GetMap(pos_unit->GetMapId(), pos_unit); |
---|
| 400 | map->CreatureRelocation((Creature*)pos_unit, movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o); |
---|
[2] | 401 | } |
---|
| 402 | } |
---|
| 403 | |
---|
| 404 | void WorldSession::HandleForceSpeedChangeAck(WorldPacket &recv_data) |
---|
| 405 | { |
---|
| 406 | CHECK_PACKET_SIZE(recv_data, 8+4+4+1+4+4+4+4+4); |
---|
| 407 | |
---|
| 408 | /* extract packet */ |
---|
| 409 | uint64 guid; |
---|
| 410 | uint8 unkB; |
---|
| 411 | uint32 unk1, flags, time, fallTime; |
---|
| 412 | float x, y, z, orientation; |
---|
| 413 | |
---|
| 414 | uint64 t_GUID; |
---|
| 415 | float t_x, t_y, t_z, t_o; |
---|
| 416 | uint32 t_time; |
---|
| 417 | float s_pitch; |
---|
| 418 | float j_unk1, j_sinAngle, j_cosAngle, j_xyspeed; |
---|
| 419 | float u_unk1; |
---|
| 420 | float newspeed; |
---|
| 421 | |
---|
| 422 | recv_data >> guid; |
---|
| 423 | |
---|
| 424 | // now can skip not our packet |
---|
| 425 | if(_player->GetGUID() != guid) |
---|
| 426 | return; |
---|
| 427 | |
---|
| 428 | // continue parse packet |
---|
| 429 | |
---|
| 430 | recv_data >> unk1; |
---|
| 431 | recv_data >> flags >> unkB >> time; |
---|
| 432 | recv_data >> x >> y >> z >> orientation; |
---|
| 433 | if (flags & MOVEMENTFLAG_ONTRANSPORT) |
---|
| 434 | { |
---|
| 435 | // recheck |
---|
| 436 | CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+8+4+4+4+4+4); |
---|
| 437 | |
---|
| 438 | recv_data >> t_GUID; |
---|
| 439 | recv_data >> t_x >> t_y >> t_z >> t_o >> t_time; |
---|
| 440 | } |
---|
| 441 | if (flags & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING2)) |
---|
| 442 | { |
---|
| 443 | // recheck |
---|
| 444 | CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+4); |
---|
| 445 | |
---|
| 446 | recv_data >> s_pitch; // pitch, -1.55=looking down, 0=looking straight forward, +1.55=looking up |
---|
| 447 | } |
---|
| 448 | |
---|
| 449 | // recheck |
---|
| 450 | CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+4); |
---|
| 451 | |
---|
| 452 | recv_data >> fallTime; // duration of last jump (when in jump duration from jump begin to now) |
---|
| 453 | |
---|
| 454 | if ((flags & MOVEMENTFLAG_JUMPING) || (flags & MOVEMENTFLAG_FALLING)) |
---|
| 455 | { |
---|
| 456 | // recheck |
---|
| 457 | CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+4+4+4+4); |
---|
| 458 | |
---|
| 459 | recv_data >> j_unk1; // ?constant, but different when jumping in water and on land? |
---|
| 460 | recv_data >> j_sinAngle >> j_cosAngle; // sin + cos of angle between orientation0 and players orientation |
---|
| 461 | recv_data >> j_xyspeed; // speed of xy movement |
---|
| 462 | } |
---|
| 463 | |
---|
| 464 | if(flags & MOVEMENTFLAG_SPLINE) |
---|
| 465 | { |
---|
| 466 | // recheck |
---|
| 467 | CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+4); |
---|
| 468 | |
---|
| 469 | recv_data >> u_unk1; // unknown |
---|
| 470 | } |
---|
| 471 | |
---|
| 472 | // recheck |
---|
| 473 | CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+4); |
---|
| 474 | |
---|
| 475 | recv_data >> newspeed; |
---|
| 476 | /*----------------*/ |
---|
| 477 | |
---|
| 478 | // client ACK send one packet for mounted/run case and need skip all except last from its |
---|
| 479 | // in other cases anti-cheat check can be fail in false case |
---|
| 480 | UnitMoveType move_type; |
---|
| 481 | UnitMoveType force_move_type; |
---|
| 482 | |
---|
| 483 | static char const* move_type_name[MAX_MOVE_TYPE] = { "Walk", "Run", "Walkback", "Swim", "Swimback", "Turn", "Fly", "Flyback" }; |
---|
| 484 | |
---|
| 485 | uint16 opcode = recv_data.GetOpcode(); |
---|
| 486 | switch(opcode) |
---|
| 487 | { |
---|
| 488 | case CMSG_FORCE_WALK_SPEED_CHANGE_ACK: move_type = MOVE_WALK; force_move_type = MOVE_WALK; break; |
---|
| 489 | case CMSG_FORCE_RUN_SPEED_CHANGE_ACK: move_type = MOVE_RUN; force_move_type = MOVE_RUN; break; |
---|
| 490 | case CMSG_FORCE_RUN_BACK_SPEED_CHANGE_ACK: move_type = MOVE_WALKBACK; force_move_type = MOVE_WALKBACK; break; |
---|
| 491 | case CMSG_FORCE_SWIM_SPEED_CHANGE_ACK: move_type = MOVE_SWIM; force_move_type = MOVE_SWIM; break; |
---|
| 492 | case CMSG_FORCE_SWIM_BACK_SPEED_CHANGE_ACK: move_type = MOVE_SWIMBACK; force_move_type = MOVE_SWIMBACK; break; |
---|
| 493 | case CMSG_FORCE_TURN_RATE_CHANGE_ACK: move_type = MOVE_TURN; force_move_type = MOVE_TURN; break; |
---|
| 494 | case CMSG_FORCE_FLIGHT_SPEED_CHANGE_ACK: move_type = MOVE_FLY; force_move_type = MOVE_FLY; break; |
---|
| 495 | case CMSG_FORCE_FLIGHT_BACK_SPEED_CHANGE_ACK: move_type = MOVE_FLYBACK; force_move_type = MOVE_FLYBACK; break; |
---|
| 496 | default: |
---|
| 497 | sLog.outError("WorldSession::HandleForceSpeedChangeAck: Unknown move type opcode: %u", opcode); |
---|
| 498 | return; |
---|
| 499 | } |
---|
| 500 | |
---|
| 501 | // skip all forced speed changes except last and unexpected |
---|
| 502 | // in run/mounted case used one ACK and it must be skipped.m_forced_speed_changes[MOVE_RUN} store both. |
---|
| 503 | if(_player->m_forced_speed_changes[force_move_type] > 0) |
---|
| 504 | { |
---|
| 505 | --_player->m_forced_speed_changes[force_move_type]; |
---|
| 506 | if(_player->m_forced_speed_changes[force_move_type] > 0) |
---|
| 507 | return; |
---|
| 508 | } |
---|
| 509 | |
---|
| 510 | if (!_player->GetTransport() && fabs(_player->GetSpeed(move_type) - newspeed) > 0.01f) |
---|
| 511 | { |
---|
| 512 | if(_player->GetSpeed(move_type) > newspeed) // must be greater - just correct |
---|
| 513 | { |
---|
| 514 | sLog.outError("%sSpeedChange player %s is NOT correct (must be %f instead %f), force set to correct value", |
---|
| 515 | move_type_name[move_type], _player->GetName(), _player->GetSpeed(move_type), newspeed); |
---|
| 516 | _player->SetSpeed(move_type,_player->GetSpeedRate(move_type),true); |
---|
| 517 | } |
---|
| 518 | else // must be lesser - cheating |
---|
| 519 | { |
---|
| 520 | sLog.outBasic("Player %s from account id %u kicked for incorrect speed (must be %f instead %f)", |
---|
| 521 | _player->GetName(),_player->GetSession()->GetAccountId(),_player->GetSpeed(move_type), newspeed); |
---|
| 522 | _player->GetSession()->KickPlayer(); |
---|
| 523 | } |
---|
| 524 | } |
---|
| 525 | } |
---|
| 526 | |
---|
| 527 | void WorldSession::HandleSetActiveMoverOpcode(WorldPacket &recv_data) |
---|
| 528 | { |
---|
| 529 | sLog.outDebug("WORLD: Recvd CMSG_SET_ACTIVE_MOVER"); |
---|
| 530 | |
---|
| 531 | CHECK_PACKET_SIZE(recv_data,8); |
---|
| 532 | |
---|
| 533 | uint64 guid; |
---|
| 534 | recv_data >> guid; |
---|
| 535 | |
---|
| 536 | WorldPacket data(SMSG_TIME_SYNC_REQ, 4); // new 2.0.x, enable movement |
---|
| 537 | data << uint32(0x00000000); // on blizz it increments periodically |
---|
| 538 | SendPacket(&data); |
---|
| 539 | } |
---|
| 540 | |
---|
[189] | 541 | void WorldSession::HandleNotActiveMoverOpcode(WorldPacket& /*recv_data*/) |
---|
| 542 | { |
---|
| 543 | sLog.outDebug("WORLD: Recvd CMSG_MOVE_NOT_ACTIVE_MOVER"); |
---|
| 544 | } |
---|
| 545 | |
---|
[2] | 546 | void WorldSession::HandleMountSpecialAnimOpcode(WorldPacket& /*recvdata*/) |
---|
| 547 | { |
---|
| 548 | //sLog.outDebug("WORLD: Recvd CMSG_MOUNTSPECIAL_ANIM"); |
---|
| 549 | |
---|
| 550 | WorldPacket data(SMSG_MOUNTSPECIAL_ANIM, 8); |
---|
| 551 | data << uint64(GetPlayer()->GetGUID()); |
---|
| 552 | |
---|
| 553 | GetPlayer()->SendMessageToSet(&data, false); |
---|
| 554 | } |
---|
| 555 | |
---|
| 556 | void WorldSession::HandleMoveKnockBackAck( WorldPacket & /*recv_data*/ ) |
---|
| 557 | { |
---|
| 558 | // CHECK_PACKET_SIZE(recv_data,?); |
---|
| 559 | sLog.outDebug("CMSG_MOVE_KNOCK_BACK_ACK"); |
---|
| 560 | // Currently not used but maybe use later for recheck final player position |
---|
| 561 | // (must be at call same as into "recv_data >> x >> y >> z >> orientation;" |
---|
| 562 | |
---|
| 563 | /* |
---|
| 564 | uint32 flags, time; |
---|
| 565 | float x, y, z, orientation; |
---|
| 566 | uint64 guid; |
---|
| 567 | uint32 sequence; |
---|
| 568 | uint32 ukn1; |
---|
| 569 | float xdirection,ydirection,hspeed,vspeed; |
---|
| 570 | |
---|
| 571 | recv_data >> guid; |
---|
| 572 | recv_data >> sequence; |
---|
| 573 | recv_data >> flags >> time; |
---|
| 574 | recv_data >> x >> y >> z >> orientation; |
---|
| 575 | recv_data >> ukn1; //unknown |
---|
| 576 | recv_data >> vspeed >> xdirection >> ydirection >> hspeed; |
---|
| 577 | |
---|
| 578 | // skip not personal message; |
---|
| 579 | if(GetPlayer()->GetGUID()!=guid) |
---|
| 580 | return; |
---|
| 581 | |
---|
| 582 | // check code |
---|
| 583 | */ |
---|
| 584 | } |
---|
| 585 | |
---|
| 586 | void WorldSession::HandleMoveHoverAck( WorldPacket& /*recv_data*/ ) |
---|
| 587 | { |
---|
| 588 | sLog.outDebug("CMSG_MOVE_HOVER_ACK"); |
---|
| 589 | } |
---|
| 590 | |
---|
| 591 | void WorldSession::HandleMoveWaterWalkAck(WorldPacket& /*recv_data*/) |
---|
| 592 | { |
---|
| 593 | sLog.outDebug("CMSG_MOVE_WATER_WALK_ACK"); |
---|
| 594 | } |
---|
| 595 | |
---|
| 596 | void WorldSession::HandleSummonResponseOpcode(WorldPacket& recv_data) |
---|
| 597 | { |
---|
| 598 | CHECK_PACKET_SIZE(recv_data,8+1); |
---|
| 599 | |
---|
| 600 | if(!_player->isAlive() || _player->isInCombat() ) |
---|
| 601 | return; |
---|
| 602 | |
---|
| 603 | uint64 summoner_guid; |
---|
| 604 | bool agree; |
---|
| 605 | recv_data >> summoner_guid; |
---|
| 606 | recv_data >> agree; |
---|
| 607 | |
---|
| 608 | _player->SummonIfPossible(agree); |
---|
| 609 | } |
---|