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