void WorldSession::HandleAttackSwingOpcode(WorldPacket & recv_data) { ObjectGuid guid; recv_data >> guid; DEBUG_LOG("WORLD: Recvd CMSG_ATTACKSWING Message %s", guid.GetString().c_str()); Unit *pEnemy = ObjectAccessor::GetUnit(*_player, guid.GetRawValue()); if (!pEnemy) { if (!guid.IsUnit()) sLog.outError("WORLD: %s isn't player, pet or creature", guid.GetString().c_str()); else sLog.outError("WORLD: Enemy %s not found", guid.GetString().c_str()); // stop attack state at client SendAttackStop(NULL); return; } if (!_player->canAttack(pEnemy)) { sLog.outError("WORLD: Enemy %s is friendly",guid.GetString().c_str()); // stop attack state at client SendAttackStop(pEnemy); return; } _player->Attack(pEnemy,true); }
void WorldSession::HandleAttackSwingOpcode(WorldPacket& recv_data) { ObjectGuid guid; recv_data >> guid; DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "WORLD: Received opcode CMSG_ATTACKSWING %s", guid.GetString().c_str()); if (!guid.IsUnit()) { sLog.outError("WORLD: %s isn't unit", guid.GetString().c_str()); return; } Unit* pEnemy = _player->GetMap()->GetUnit(guid); if (!pEnemy) { sLog.outError("WORLD: Enemy %s not found", guid.GetString().c_str()); // stop attack state at client SendAttackStop(NULL); return; } if (_player->IsFriendlyTo(pEnemy) || pEnemy->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE)) { sLog.outError("WORLD: Enemy %s is friendly", guid.GetString().c_str()); // stop attack state at client SendAttackStop(pEnemy); return; } if (!pEnemy->isAlive()) { // client can generate swing to known dead target if autoswitch between autoshot and autohit is enabled in client options // stop attack state at client SendAttackStop(pEnemy); return; } _player->Attack(pEnemy, true); }
void WorldSession::HandleAttackSwingOpcode( WorldPacket & recv_data ) { ObjectGuid guid; recv_data >> guid; DEBUG_LOG("WORLD: Recvd CMSG_ATTACKSWING Message %s", guid.GetString().c_str()); Unit *pEnemy = ObjectAccessor::GetUnit(*_player, guid); if(!pEnemy) { if(!guid.IsUnit()) sLog.outError("WORLD: %u isn't player, pet or creature", guid.GetString().c_str()); else sLog.outError( "WORLD: Enemy %s not found", guid.GetString().c_str()); // stop attack state at client SendAttackStop(NULL); return; } if(_player->IsFriendlyTo(pEnemy) || pEnemy->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE)) { sLog.outError( "WORLD: Enemy %s is friendly",guid.GetString().c_str()); // stop attack state at client SendAttackStop(pEnemy); return; } if(!pEnemy->isAlive()) { // client can generate swing to known dead target if autoswitch between autoshot and autohit is enabled in client options // stop attack state at client SendAttackStop(pEnemy); return; } _player->Attack(pEnemy,true); }
void WorldSession::HandleEjectPassenger(WorldPacket& data) { Vehicle* vehicle = _player->GetVehicleKit(); if (!vehicle) { data.rfinish(); // prevent warnings spam TC_LOG_ERROR("network", "HandleEjectPassenger: %s is not in a vehicle!", GetPlayer()->GetGUID().ToString().c_str()); return; } ObjectGuid guid; data >> guid; if (guid.IsUnit()) { Unit* unit = ObjectAccessor::GetUnit(*_player, guid); if (!unit) // creatures can be ejected too from player mounts { TC_LOG_ERROR("network", "%s tried to eject %s from vehicle, but the latter was not found in world!", GetPlayer()->GetGUID().ToString().c_str(), guid.ToString().c_str()); return; } if (!unit->IsOnVehicle(vehicle->GetBase())) { TC_LOG_ERROR("network", "%s tried to eject %s, but they are not in the same vehicle", GetPlayer()->GetGUID().ToString().c_str(), guid.ToString().c_str()); return; } VehicleSeatEntry const* seat = vehicle->GetSeatForPassenger(unit); ASSERT(seat); if (seat->IsEjectable()) unit->ExitVehicle(); else TC_LOG_ERROR("network", "Player %u attempted to eject %s from non-ejectable seat.", GetPlayer()->GetGUIDLow(), guid.ToString().c_str()); } else TC_LOG_ERROR("network", "HandleEjectPassenger: %s tried to eject invalid %s ", GetPlayer()->GetGUID().ToString().c_str(), guid.ToString().c_str()); }