diff --git a/sql/mangos.sql b/sql/mangos.sql index fbf2cd359..c258f33af 100644 --- a/sql/mangos.sql +++ b/sql/mangos.sql @@ -24,7 +24,7 @@ CREATE TABLE `db_version` ( `version` varchar(120) default NULL, `creature_ai_version` varchar(120) default NULL, `cache_id` int(10) default '0', - `required_11348_01_mangos_spell_bonus_data` bit(1) default NULL + `required_11385_01_mangos_creature_template` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; -- @@ -1260,6 +1260,7 @@ CREATE TABLE `creature_template` ( `questItem6` int(11) UNSIGNED DEFAULT '0' NOT NULL, `movementId` int(11) UNSIGNED DEFAULT '0' NOT NULL, `RegenHealth` tinyint(3) unsigned NOT NULL default '1', + `vehicle_id` mediumint(8) unsigned NOT NULL default '0', `equipment_id` mediumint(8) unsigned NOT NULL default '0', `trainer_id` mediumint(8) unsigned NOT NULL default '0', `vendor_id` mediumint(8) unsigned NOT NULL default '0', diff --git a/sql/updates/11385_01_mangos_creature_template.sql b/sql/updates/11385_01_mangos_creature_template.sql new file mode 100644 index 000000000..47956acb2 --- /dev/null +++ b/sql/updates/11385_01_mangos_creature_template.sql @@ -0,0 +1,4 @@ +ALTER TABLE db_version CHANGE COLUMN required_11348_01_mangos_spell_bonus_data required_11385_01_mangos_creature_template bit; + +ALTER TABLE creature_template + ADD COLUMN `vehicle_id` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0' AFTER `RegenHealth`; diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index 5f3a30153..685735a35 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -213,7 +213,6 @@ ChatCommand * ChatHandler::getCommandTable() { "spellcheck", SEC_CONSOLE, true, &ChatHandler::HandleDebugSpellCheckCommand, "", NULL }, { "spellcoefs", SEC_ADMINISTRATOR, true, &ChatHandler::HandleDebugSpellCoefsCommand, "", NULL }, { "spellmods", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSpellModsCommand, "", NULL }, - { "spawnvehicle", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSpawnVehicleCommand, "", NULL }, { "uws", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugUpdateWorldStateCommand, "", NULL }, { NULL, 0, false, NULL, "", NULL } }; diff --git a/src/game/Chat.h b/src/game/Chat.h index c9d4af774..5591607ef 100644 --- a/src/game/Chat.h +++ b/src/game/Chat.h @@ -187,7 +187,6 @@ class ChatHandler bool HandleDebugSetAuraStateCommand(char* args); bool HandleDebugSetItemValueCommand(char* args); bool HandleDebugSetValueCommand(char* args); - bool HandleDebugSpawnVehicleCommand(char* args); bool HandleDebugSpellCheckCommand(char* args); bool HandleDebugSpellCoefsCommand(char* args); bool HandleDebugSpellModsCommand(char* args); diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 918729287..ce713c911 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -190,7 +190,7 @@ Creature::~Creature() void Creature::AddToWorld() { ///- Register the creature for guid lookup - if(!IsInWorld() && GetObjectGuid().GetHigh() == HIGHGUID_UNIT) + if (!IsInWorld() && GetObjectGuid().IsCreatureOrVehicle()) GetMap()->GetObjectsStore().insert(GetGUID(), (Creature*)this); Unit::AddToWorld(); @@ -199,7 +199,7 @@ void Creature::AddToWorld() void Creature::RemoveFromWorld() { ///- Remove the creature from the accessor - if(IsInWorld() && GetObjectGuid().GetHigh() == HIGHGUID_UNIT) + if (IsInWorld() && GetObjectGuid().IsCreatureOrVehicle()) GetMap()->GetObjectsStore().erase(GetGUID(), (Creature*)NULL); Unit::RemoveFromWorld(); @@ -398,6 +398,8 @@ bool Creature::UpdateEntry(uint32 Entry, Team team, const CreatureData *data /*= for(int i = 0; i < CREATURE_MAX_SPELLS; ++i) m_spells[i] = GetCreatureInfo()->spells[i]; + SetVehicleId(GetCreatureInfo()->vehicleId); + // if eventData set then event active and need apply spell_start if (eventData) ApplyGameEventSpells(eventData, true); diff --git a/src/game/Creature.h b/src/game/Creature.h index 284dfbae7..4a6452410 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -132,6 +132,7 @@ struct CreatureInfo uint32 questItems[6]; uint32 movementId; bool RegenHealth; + uint32 vehicleId; uint32 equipmentId; uint32 trainerId; uint32 vendorId; @@ -140,10 +141,9 @@ struct CreatureInfo uint32 ScriptID; // helpers - // TODO: return HIGHGUID_UNIT/HIGHGUID_VEHICLE base at currently missing creature template data HighGuid GetHighGuid() const { - return HIGHGUID_UNIT; + return vehicleId ? HIGHGUID_VEHICLE : HIGHGUID_UNIT; } SkillType GetRequiredLootSkill() const @@ -423,7 +423,6 @@ enum CreatureSubtype CREATURE_SUBTYPE_GENERIC, // new Creature CREATURE_SUBTYPE_PET, // new Pet CREATURE_SUBTYPE_TOTEM, // new Totem - CREATURE_SUBTYPE_VEHICLE, // new Vehicle CREATURE_SUBTYPE_TEMPORARY_SUMMON, // new TemporarySummon }; @@ -465,7 +464,6 @@ class MANGOS_DLL_SPEC Creature : public Unit CreatureSubtype GetSubtype() const { return m_subtype; } bool IsPet() const { return m_subtype == CREATURE_SUBTYPE_PET; } - bool IsVehicle() const { return m_subtype == CREATURE_SUBTYPE_VEHICLE; } bool IsTotem() const { return m_subtype == CREATURE_SUBTYPE_TOTEM; } bool IsTemporarySummon() const { return m_subtype == CREATURE_SUBTYPE_TEMPORARY_SUMMON; } diff --git a/src/game/GridDefines.h b/src/game/GridDefines.h index 2eeca2637..d200a0d19 100644 --- a/src/game/GridDefines.h +++ b/src/game/GridDefines.h @@ -26,7 +26,6 @@ // Forward class definitions class Corpse; class Creature; -class Vehicle; class DynamicObject; class GameObject; class Pet; @@ -60,7 +59,7 @@ class Camera; // Cameras in world list just because linked with Player objects typedef TYPELIST_4(Player, Creature/*pets*/, Corpse/*resurrectable*/, Camera) AllWorldObjectTypes; typedef TYPELIST_4(GameObject, Creature/*except pets*/, DynamicObject, Corpse/*Bones*/) AllGridObjectTypes; -typedef TYPELIST_5(Creature, Pet, Vehicle, GameObject, DynamicObject) AllMapStoredObjectTypes; +typedef TYPELIST_4(Creature, Pet, GameObject, DynamicObject) AllMapStoredObjectTypes; typedef GridRefManager CameraMapType; typedef GridRefManager CorpseMapType; diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index cad8a3300..0e850ced8 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -26,7 +26,6 @@ #include "TemporarySummon.h" #include "Totem.h" #include "Pet.h" -#include "Vehicle.h" #include "GameObject.h" #include "Opcodes.h" #include "Chat.h" @@ -1563,8 +1562,7 @@ bool ChatHandler::HandleNpcAddCommand(char* args) return false; CreatureInfo const *cinfo = ObjectMgr::GetCreatureTemplate(id); - //FIXME: need vehicle support like GenerateStaticCreatureLowGuid when its will allowed static spawns - if (!cinfo || cinfo->GetHighGuid() != HIGHGUID_UNIT) + if (!cinfo) { PSendSysMessage(LANG_COMMAND_INVALIDCREATUREID, id); SetSentErrorMessage(true); @@ -1844,9 +1842,6 @@ bool ChatHandler::HandleNpcDeleteCommand(char* args) case CREATURE_SUBTYPE_TEMPORARY_SUMMON: ((TemporarySummon*)unit)->UnSummon(); break; - case CREATURE_SUBTYPE_VEHICLE: - ((Vehicle*)unit)->Dismiss(); - break; default: return false; } diff --git a/src/game/LootHandler.cpp b/src/game/LootHandler.cpp index 0d480d5cd..d1db97766 100644 --- a/src/game/LootHandler.cpp +++ b/src/game/LootHandler.cpp @@ -83,6 +83,7 @@ void WorldSession::HandleAutostoreLootItemOpcode( WorldPacket & recv_data ) break; } case HIGHGUID_UNIT: + case HIGHGUID_VEHICLE: { Creature* pCreature = GetPlayer()->GetMap()->GetCreature(lguid); @@ -216,6 +217,7 @@ void WorldSession::HandleLootMoneyOpcode( WorldPacket & /*recv_data*/ ) break; } case HIGHGUID_UNIT: + case HIGHGUID_VEHICLE: { Creature* pCreature = GetPlayer()->GetMap()->GetCreature(guid); @@ -460,6 +462,7 @@ void WorldSession::DoLootRelease(ObjectGuid lguid) return; // item can be looted only single player } case HIGHGUID_UNIT: + case HIGHGUID_VEHICLE: { Creature* pCreature = GetPlayer()->GetMap()->GetCreature(lguid); @@ -520,7 +523,7 @@ void WorldSession::HandleLootMasterGiveOpcode( WorldPacket & recv_data ) Loot *pLoot = NULL; - if(lootguid.IsCreature()) + if (lootguid.IsCreatureOrVehicle()) { Creature *pCreature = GetPlayer()->GetMap()->GetCreature(lootguid); if(!pCreature) diff --git a/src/game/Map.cpp b/src/game/Map.cpp index d18f8aff2..4984293df 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -19,7 +19,6 @@ #include "Map.h" #include "MapManager.h" #include "Player.h" -#include "Vehicle.h" #include "GridNotifiers.h" #include "Log.h" #include "GridStates.h" @@ -138,7 +137,7 @@ template<> void Map::AddToGrid(Creature* obj, NGridType *grid, Cell const& cell) { // add to world object registry in grid - if(obj->IsPet() || obj->IsVehicle()) + if (obj->IsPet()) { (*grid)(cell.CellX(), cell.CellY()).AddWorldObject(obj); obj->SetCurrentCell(cell); @@ -182,7 +181,7 @@ template<> void Map::RemoveFromGrid(Creature* obj, NGridType *grid, Cell const& cell) { // remove from world object registry in grid - if(obj->IsPet() || obj->IsVehicle()) + if (obj->IsPet()) { (*grid)(cell.CellX(), cell.CellY()).RemoveWorldObject(obj); } @@ -1687,14 +1686,12 @@ void Map::ScriptsProcess() break; } case HIGHGUID_UNIT: + case HIGHGUID_VEHICLE: source = GetCreature(step.sourceGuid); break; case HIGHGUID_PET: source = GetPet(step.sourceGuid); break; - case HIGHGUID_VEHICLE: - source = GetVehicle(step.sourceGuid); - break; case HIGHGUID_PLAYER: source = HashMapHolder::Find(step.sourceGuid); break; @@ -1720,14 +1717,12 @@ void Map::ScriptsProcess() switch(step.targetGuid.GetHigh()) { case HIGHGUID_UNIT: + case HIGHGUID_VEHICLE: target = GetCreature(step.targetGuid); break; case HIGHGUID_PET: target = GetPet(step.targetGuid); break; - case HIGHGUID_VEHICLE: - target = GetVehicle(step.targetGuid); - break; case HIGHGUID_PLAYER: target = HashMapHolder::Find(step.targetGuid); break; @@ -2901,25 +2896,15 @@ Player* Map::GetPlayer(ObjectGuid guid) } /** - * Function return creature (non-pet and then most summoned by spell creatures, and not vehicle) that in world at CURRENT map + * Function return creature (non-pet and then most summoned by spell creatures) that in world at CURRENT map * - * @param guid must be creature guid (HIGHGUID_UNIT) + * @param guid must be creature or vehicle guid (HIGHGUID_UNIT HIGHGUID_VEHICLE) */ Creature* Map::GetCreature(ObjectGuid guid) { return m_objectsStore.find(guid.GetRawValue(), (Creature*)NULL); } -/** - * Function return vehicle that in world at CURRENT map - * - * @param guid must be vehicle guid (HIGHGUID_VEHICLE) - */ -Vehicle* Map::GetVehicle(ObjectGuid guid) -{ - return m_objectsStore.find(guid.GetRawValue(), (Vehicle*)NULL); -} - /** * Function return pet that in world at CURRENT map * @@ -2952,9 +2937,9 @@ Creature* Map::GetAnyTypeCreature(ObjectGuid guid) { switch(guid.GetHigh()) { - case HIGHGUID_UNIT: return GetCreature(guid); + case HIGHGUID_UNIT: + case HIGHGUID_VEHICLE: return GetCreature(guid); case HIGHGUID_PET: return GetPet(guid); - case HIGHGUID_VEHICLE: return GetVehicle(guid); default: break; } @@ -3006,9 +2991,9 @@ WorldObject* Map::GetWorldObject(ObjectGuid guid) { case HIGHGUID_PLAYER: return GetPlayer(guid); case HIGHGUID_GAMEOBJECT: return GetGameObject(guid); - case HIGHGUID_UNIT: return GetCreature(guid); + case HIGHGUID_UNIT: + case HIGHGUID_VEHICLE: return GetCreature(guid); case HIGHGUID_PET: return GetPet(guid); - case HIGHGUID_VEHICLE: return GetVehicle(guid); case HIGHGUID_DYNAMICOBJECT:return GetDynamicObject(guid); case HIGHGUID_CORPSE: { diff --git a/src/game/Map.h b/src/game/Map.h index 9dd4af4d8..cddc8683c 100644 --- a/src/game/Map.h +++ b/src/game/Map.h @@ -222,7 +222,6 @@ class MANGOS_DLL_SPEC Map : public GridRefManager Player* GetPlayer(ObjectGuid guid); Creature* GetCreature(ObjectGuid guid); - Vehicle* GetVehicle(ObjectGuid guid); Pet* GetPet(ObjectGuid guid); Creature* GetAnyTypeCreature(ObjectGuid guid); // normal creature or pet or vehicle GameObject* GetGameObject(ObjectGuid guid); diff --git a/src/game/MovementHandler.cpp b/src/game/MovementHandler.cpp index f663c0d42..7ecd4bdbb 100644 --- a/src/game/MovementHandler.cpp +++ b/src/game/MovementHandler.cpp @@ -435,13 +435,6 @@ void WorldSession::HandleDismissControlledVehicle(WorldPacket &recv_data) return; _player->m_movementInfo = mi; - - // using charm guid, because we don't have vehicle guid... - if(Vehicle *vehicle = _player->GetMap()->GetVehicle(vehicleGUID)) - { - // Aura::HandleAuraControlVehicle will call Player::ExitVehicle - vehicle->RemoveSpellsCausingAura(SPELL_AURA_CONTROL_VEHICLE); - } } void WorldSession::HandleMountSpecialAnimOpcode(WorldPacket& /*recvdata*/) diff --git a/src/game/Object.cpp b/src/game/Object.cpp index 489cbbb01..7e2a761ce 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -230,10 +230,6 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const { uint16 moveFlags2 = (isType(TYPEMASK_UNIT) ? ((Unit*)this)->m_movementInfo.GetMovementFlags2() : MOVEFLAG2_NONE); - if(GetTypeId() == TYPEID_UNIT) - if(((Creature*)this)->IsVehicle()) - moveFlags2 |= MOVEFLAG2_ALLOW_PITCHING; // always allow pitch - *data << uint16(updateFlags); // update flags // 0x20 @@ -256,7 +252,7 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const // (ok) most seem to have this unit->m_movementInfo.AddMovementFlag(MOVEFLAG_LEVITATING); - if (!((Creature*)unit)->hasUnitState(UNIT_STAT_MOVING)) + if (!unit->hasUnitState(UNIT_STAT_ROOT)) { // (ok) possibly some "hover" mode unit->m_movementInfo.AddMovementFlag(MOVEFLAG_ROOT); @@ -506,9 +502,9 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const } // 0x80 - if(updateFlags & UPDATEFLAG_VEHICLE) // unused for now + if (updateFlags & UPDATEFLAG_VEHICLE) { - *data << uint32(((Vehicle*)this)->GetVehicleId()); // vehicle id + *data << uint32(((Unit*)this)->GetVehicleInfo()->GetEntry()->m_ID); // vehicle id *data << float(((WorldObject*)this)->GetOrientation()); } @@ -1664,7 +1660,7 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa if (x == 0.0f && y == 0.0f && z == 0.0f) pos = CreatureCreatePos(this, GetOrientation(), CONTACT_DISTANCE, ang); - if (!pCreature->Create(GetMap()->GenerateLocalLowGuid(HIGHGUID_UNIT), pos, cinfo, team)) + if (!pCreature->Create(GetMap()->GenerateLocalLowGuid(cinfo->GetHighGuid()), pos, cinfo, team)) { delete pCreature; return NULL; diff --git a/src/game/ObjectGridLoader.cpp b/src/game/ObjectGridLoader.cpp index bb782b5af..c4ba3d2dc 100644 --- a/src/game/ObjectGridLoader.cpp +++ b/src/game/ObjectGridLoader.cpp @@ -58,7 +58,7 @@ ObjectGridRespawnMover::Visit(CreatureMapType &m) Creature * c = iter->getSource(); - MANGOS_ASSERT((!c->IsPet() || !c->IsVehicle()) && "ObjectGridRespawnMover don't must be called for pets"); + MANGOS_ASSERT(!c->IsPet() && "ObjectGridRespawnMover don't must be called for pets"); Cell const& cur_cell = c->GetCurrentCell(); diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 62c576767..7dcd7d774 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -725,6 +725,12 @@ void ObjectMgr::LoadCreatureTemplates() const_cast(cInfo)->MovementType = IDLE_MOTION_TYPE; } + if (cInfo->vehicleId && !sVehicleStore.LookupEntry(cInfo->vehicleId)) + { + sLog.outErrorDb("Creature (Entry: %u) has non-existing vehicle_id (%u), set to 0.", cInfo->Entry, cInfo->vehicleId); + const_cast(cInfo)->vehicleId = 0; + } + if(cInfo->equipmentId > 0) // 0 no equipment { if(!GetEquipmentInfo(cInfo->equipmentId)) diff --git a/src/game/Opcodes.cpp b/src/game/Opcodes.cpp index 4c4c58f40..c19f21849 100644 --- a/src/game/Opcodes.cpp +++ b/src/game/Opcodes.cpp @@ -1217,8 +1217,8 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x4A4*/ { "CMSG_QUERY_VEHICLE_STATUS", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x4A5*/ { "UMSG_UNKNOWN_1189", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x4A6*/ { "SMSG_BATTLEGROUND_INFO_THROTTLED", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, - /*0x4A7*/ { "SMSG_PLAYER_VEHICLE_DATA", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, - /*0x4A8*/ { "CMSG_PLAYER_VEHICLE_ENTER", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, + /*0x4A7*/ { "SMSG_SET_VEHICLE_REC_ID", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, + /*0x4A8*/ { "CMSG_RIDE_VEHICLE_INTERACT", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x4A9*/ { "CMSG_EJECT_PASSENGER", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x4AA*/ { "SMSG_PET_GUIDS", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x4AB*/ { "SMSG_CLIENTCACHE_VERSION", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 79a3b6e59..8322c1119 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -26,7 +26,6 @@ #include "WorldPacket.h" #include "WorldSession.h" #include "UpdateMask.h" -#include "Vehicle.h" #include "SkillDiscovery.h" #include "QuestDef.h" #include "GossipDef.h" @@ -8087,6 +8086,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) break; } case HIGHGUID_UNIT: + case HIGHGUID_VEHICLE: { Creature *creature = GetMap()->GetCreature(guid); @@ -14725,7 +14725,7 @@ void Player::KilledMonsterCredit( uint32 entry, ObjectGuid guid ) void Player::CastedCreatureOrGO( uint32 entry, ObjectGuid guid, uint32 spell_id, bool original_caster ) { - bool isCreature = guid.IsCreature(); + bool isCreature = guid.IsCreatureOrVehicle(); uint32 addCastCount = 1; for(int i = 0; i < MAX_QUEST_LOG_SIZE; ++i) @@ -21323,98 +21323,6 @@ void Player::ApplyGlyphs(bool apply) ApplyGlyph(i,apply); } -void Player::EnterVehicle(Vehicle *vehicle) -{ - VehicleEntry const *ve = sVehicleStore.LookupEntry(vehicle->GetVehicleId()); - if(!ve) - return; - - VehicleSeatEntry const *veSeat = sVehicleSeatStore.LookupEntry(ve->m_seatID[0]); - if(!veSeat) - return; - - vehicle->SetCharmerGuid(GetObjectGuid()); - vehicle->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK); - vehicle->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); - vehicle->setFaction(getFaction()); - - SetCharm(vehicle); // charm - m_camera.SetView(vehicle); // set view - - SetClientControl(vehicle, 1); // redirect controls to vehicle - SetMover(vehicle); - - WorldPacket data(SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA, 0); - GetSession()->SendPacket(&data); - - data.Initialize(MSG_MOVE_TELEPORT_ACK, 30); - data << GetPackGUID(); - data << uint32(0); // counter? - data << uint32(MOVEFLAG_ONTRANSPORT); // transport - data << uint16(0); // special flags - data << uint32(WorldTimer::getMSTime()); // time - data << vehicle->GetPositionX(); // x - data << vehicle->GetPositionY(); // y - data << vehicle->GetPositionZ(); // z - data << vehicle->GetOrientation(); // o - // transport part, TODO: load/calculate seat offsets - data << vehicle->GetObjectGuid(); // transport guid - data << float(veSeat->m_attachmentOffsetX); // transport offsetX - data << float(veSeat->m_attachmentOffsetY); // transport offsetY - data << float(veSeat->m_attachmentOffsetZ); // transport offsetZ - data << float(0); // transport orientation - data << uint32(WorldTimer::getMSTime()); // transport time - data << uint8(0); // seat - // end of transport part - data << uint32(0); // fall time - GetSession()->SendPacket(&data); - - data.Initialize(SMSG_PET_SPELLS, 8+2+4+4+4*MAX_UNIT_ACTION_BAR_INDEX+1+1); - data << vehicle->GetObjectGuid(); - data << uint16(0); - data << uint32(0); - data << uint32(0x00000101); - - for(uint32 i = 0; i < 10; ++i) - data << uint16(0) << uint8(0) << uint8(i+8); - - data << uint8(0); - data << uint8(0); - GetSession()->SendPacket(&data); -} - -void Player::ExitVehicle(Vehicle *vehicle) -{ - vehicle->SetCharmerGuid(ObjectGuid()); - vehicle->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK); - vehicle->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); - vehicle->setFaction((GetTeam() == ALLIANCE) ? vehicle->GetCreatureInfo()->faction_A : vehicle->GetCreatureInfo()->faction_H); - - SetCharm(NULL); - m_camera.ResetView(); - - SetClientControl(vehicle, 0); - SetMover(NULL); - - WorldPacket data(MSG_MOVE_TELEPORT_ACK, 30); - data << GetPackGUID(); - data << uint32(0); // counter? - data << uint32(MOVEFLAG_ROOT); // fly unk - data << uint16(MOVEFLAG2_UNK4); // special flags - data << uint32(WorldTimer::getMSTime()); // time - data << vehicle->GetPositionX(); // x - data << vehicle->GetPositionY(); // y - data << vehicle->GetPositionZ(); // z - data << vehicle->GetOrientation(); // o - data << uint32(0); // fall time - GetSession()->SendPacket(&data); - - RemovePetActionBar(); - - // maybe called at dummy aura remove? - // CastSpell(this, 45472, true); // Parachute -} - bool Player::isTotalImmune() { AuraList const& immune = GetAurasByType(SPELL_AURA_SCHOOL_IMMUNITY); @@ -22795,6 +22703,7 @@ Object* Player::GetObjectByTypeMask(ObjectGuid guid, TypeMask typemask) return GetMap()->GetGameObject(guid); break; case HIGHGUID_UNIT: + case HIGHGUID_VEHICLE: if ((typemask & TYPEMASK_UNIT) && IsInWorld()) return GetMap()->GetCreature(guid); break; @@ -22802,10 +22711,6 @@ Object* Player::GetObjectByTypeMask(ObjectGuid guid, TypeMask typemask) if ((typemask & TYPEMASK_UNIT) && IsInWorld()) return GetMap()->GetPet(guid); break; - case HIGHGUID_VEHICLE: - if ((typemask & TYPEMASK_UNIT) && IsInWorld()) - return GetMap()->GetVehicle(guid); - break; case HIGHGUID_DYNAMICOBJECT: if ((typemask & TYPEMASK_DYNAMICOBJECT) && IsInWorld()) return GetMap()->GetDynamicObject(guid); diff --git a/src/game/Player.h b/src/game/Player.h index 2146b077f..9c203a3fc 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -51,7 +51,6 @@ class Transport; class UpdateMask; class SpellCastTargets; class PlayerSocial; -class Vehicle; class DungeonPersistentState; class Spell; class Item; @@ -2186,9 +2185,6 @@ class MANGOS_DLL_SPEC Player : public Unit Unit* GetMover() const { return m_mover; } bool IsSelfMover() const { return m_mover == this; }// normal case for player not controlling other unit - void EnterVehicle(Vehicle *vehicle); - void ExitVehicle(Vehicle *vehicle); - ObjectGuid const& GetFarSightGuid() const { return GetGuidValue(PLAYER_FARSIGHT); } // Transports diff --git a/src/game/PointMovementGenerator.cpp b/src/game/PointMovementGenerator.cpp index 2db1bae07..6dbd025f8 100644 --- a/src/game/PointMovementGenerator.cpp +++ b/src/game/PointMovementGenerator.cpp @@ -105,7 +105,7 @@ void PointMovementGenerator::MovementInform(Creature &unit) if (unit.IsTemporarySummon()) { TemporarySummon* pSummon = (TemporarySummon*)(&unit); - if (pSummon->GetSummonerGuid().IsCreature()) + if (pSummon->GetSummonerGuid().IsCreatureOrVehicle()) if(Creature* pSummoner = unit.GetMap()->GetCreature(pSummon->GetSummonerGuid())) if (pSummoner->AI()) pSummoner->AI()->SummonedMovementInform(&unit, POINT_MOTION_TYPE, id); diff --git a/src/game/QuestHandler.cpp b/src/game/QuestHandler.cpp index de4f661ee..6c8143646 100644 --- a/src/game/QuestHandler.cpp +++ b/src/game/QuestHandler.cpp @@ -636,7 +636,7 @@ void WorldSession::HandleQuestgiverStatusMultipleQuery(WorldPacket& /*recvPacket { uint8 dialogStatus = DIALOG_STATUS_NONE; - if (itr->IsCreatureOrPet()) + if (itr->IsAnyTypeCreature()) { // need also pet quests case support Creature *questgiver = GetPlayer()->GetMap()->GetAnyTypeCreature(*itr); diff --git a/src/game/SQLStorages.cpp b/src/game/SQLStorages.cpp index c1ae3991d..716f10cbc 100644 --- a/src/game/SQLStorages.cpp +++ b/src/game/SQLStorages.cpp @@ -21,8 +21,8 @@ #include "Database/SQLStorageImpl.h" #include "Database/DatabaseEnv.h" -const char CreatureInfosrcfmt[]="iiiiiiiiiisssiiiiiiiiiiifffiffiifiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiiffliiiiiiiliiiiis"; -const char CreatureInfodstfmt[]="iiiiiiiiiisssiiiiiiiiiiifffiffiifiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiiffliiiiiiiliiiiii"; +const char CreatureInfosrcfmt[]="iiiiiiiiiisssiiiiiiiiiiifffiffiifiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiiffliiiiiiiliiiiiis"; +const char CreatureInfodstfmt[]="iiiiiiiiiisssiiiiiiiiiiifffiffiifiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiiffliiiiiiiliiiiiii"; const char CreatureDataAddonInfofmt[]="iiibbiis"; const char CreatureModelfmt[]="iffbii"; const char CreatureInfoAddonInfofmt[]="iiibbiis"; diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 8df1f6850..ffd892e64 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -3385,7 +3385,7 @@ void Spell::update(uint32 difftime) for(TargetList::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) { TargetInfo const& target = *ihit; - if (!target.targetGUID.IsCreature()) + if (!target.targetGUID.IsCreatureOrVehicle()) continue; Unit* unit = m_caster->GetObjectGuid() == target.targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, target.targetGUID); diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 6727fae82..5a286cec1 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -7927,27 +7927,31 @@ void Aura::HandleAuraControlVehicle(bool apply, bool Real) return; Unit* target = GetTarget(); - if (target->GetTypeId() != TYPEID_UNIT || !((Creature*)target)->IsVehicle()) + if (!target->IsVehicle()) return; - Vehicle* vehicle = (Vehicle*)target; + + // TODO: Check for free seat Unit *caster = GetCaster(); - if (!caster || caster->GetTypeId() != TYPEID_PLAYER) + if (!caster) return; if (apply) { - ((Player*)caster)->RemovePet(PET_SAVE_AS_CURRENT); - ((Player*)caster)->EnterVehicle(vehicle); + if (caster->GetTypeId() == TYPEID_PLAYER) + ((Player*)caster)->RemovePet(PET_SAVE_AS_CURRENT); + + //caster->EnterVehicle(target); } else { - SpellEntry const *spell = GetSpellProto(); - // some SPELL_AURA_CONTROL_VEHICLE auras have a dummy effect on the player - remove them - caster->RemoveAurasDueToSpell(spell->Id); + caster->RemoveAurasDueToSpell(GetId()); - ((Player*)caster)->ExitVehicle(vehicle); + //caster->ExitVehicle(); + + if (caster->GetTypeId() == TYPEID_PLAYER) + ((Player*)caster)->ResummonPetTemporaryUnSummonedIfAny(); } } diff --git a/src/game/TemporarySummon.cpp b/src/game/TemporarySummon.cpp index a93c83634..3ce6324f6 100644 --- a/src/game/TemporarySummon.cpp +++ b/src/game/TemporarySummon.cpp @@ -163,7 +163,7 @@ void TemporarySummon::UnSummon() { CombatStop(); - if (GetSummonerGuid().IsCreature()) + if (GetSummonerGuid().IsCreatureOrVehicle()) if(Creature* sum = GetMap()->GetCreature(GetSummonerGuid())) if (sum->AI()) sum->AI()->SummonedCreatureDespawn(this); diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 9fec6ca1e..95478dd3f 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -39,6 +39,7 @@ #include "Pet.h" #include "Util.h" #include "Totem.h" +#include "Vehicle.h" #include "BattleGround.h" #include "InstanceData.h" #include "MapPersistentStateMgr.h" @@ -180,8 +181,10 @@ void GlobalCooldownMgr::CancelGlobalCooldown(SpellEntry const* spellInfo) //////////////////////////////////////////////////////////// // Methods of class Unit -Unit::Unit() -: WorldObject(), i_motionMaster(this), m_ThreatManager(this), m_HostileRefManager(this) +Unit::Unit() : + i_motionMaster(this), m_ThreatManager(this), m_HostileRefManager(this), + m_charmInfo(NULL), + m_vehicleInfo(NULL) { m_objectType |= TYPEMASK_UNIT; m_objectTypeId = TYPEID_UNIT; @@ -258,8 +261,6 @@ Unit::Unit() for (int i = 0; i < MAX_MOVE_TYPE; ++i) m_speed_rate[i] = 1.0f; - m_charmInfo = NULL; - // remove aurastates allowing special moves for(int i=0; i < MAX_REACTIVE; ++i) m_reactiveTimer[i] = 0; @@ -277,8 +278,8 @@ Unit::~Unit() } } - if (m_charmInfo) - delete m_charmInfo; + delete m_charmInfo; + delete m_vehicleInfo; // those should be already removed at "RemoveFromWorld()" call MANGOS_ASSERT(m_gameObj.size() == 0); @@ -848,7 +849,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa if (cVictim->IsTemporarySummon()) { TemporarySummon* pSummon = (TemporarySummon*)cVictim; - if (pSummon->GetSummonerGuid().IsCreature()) + if (pSummon->GetSummonerGuid().IsCreatureOrVehicle()) if(Creature* pSummoner = cVictim->GetMap()->GetCreature(pSummon->GetSummonerGuid())) if (pSummoner->AI()) pSummoner->AI()->SummonedCreatureJustDied(cVictim); @@ -8438,10 +8439,6 @@ bool Unit::CanHaveThreatList() const if (creature->IsTotem()) return false; - // vehicles can not have threat list - if (creature->IsVehicle()) - return false; - // pets can not have a threat list, unless they are controlled by a creature if (creature->IsPet() && creature->GetOwnerGuid().IsPlayer()) return false; @@ -10826,3 +10823,30 @@ void Unit::OnRelocated() } ScheduleAINotify(World::GetRelocationAINotifyDelay()); } + +void Unit::SetVehicleId(uint32 entry) +{ + delete m_vehicleInfo; + + if (entry) + { + VehicleEntry const* ventry = sVehicleStore.LookupEntry(entry); + MANGOS_ASSERT(ventry != NULL); + + m_vehicleInfo = new VehicleInfo(ventry); + m_updateFlag |= UPDATEFLAG_VEHICLE; + } + else + { + m_vehicleInfo = NULL; + m_updateFlag &= ~UPDATEFLAG_VEHICLE; + } + + if (GetTypeId() == TYPEID_PLAYER) + { + WorldPacket data(SMSG_SET_VEHICLE_REC_ID, 16); + data << GetPackGUID(); + data << uint32(entry); + SendMessageToSet(&data, true); + } +} diff --git a/src/game/Unit.h b/src/game/Unit.h index 7f9123e6e..2ecd7c75a 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -268,6 +268,7 @@ class Item; class Pet; class PetAura; class Totem; +class VehicleInfo; struct SpellImmune { @@ -1303,6 +1304,10 @@ class MANGOS_DLL_SPEC Unit : public WorldObject void Mount(uint32 mount, uint32 spellId = 0); void Unmount(bool from_aura = false); + VehicleInfo* GetVehicleInfo() { return m_vehicleInfo; } + bool IsVehicle() const { return m_vehicleInfo != NULL; } + void SetVehicleId(uint32 entry); + uint16 GetMaxSkillValueForLevel(Unit const* target = NULL) const { return (target ? GetLevelForTarget(target) : getLevel()) * 5; } void DealDamageMods(Unit *pVictim, uint32 &damage, uint32* absorb); uint32 DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDamage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask, SpellEntry const *spellProto, bool durabilityLoss); @@ -2003,6 +2008,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject uint32 m_regenTimer; uint32 m_lastManaUseTimer; + VehicleInfo* m_vehicleInfo; private: void CleanupDeletedAuras(); diff --git a/src/game/Vehicle.cpp b/src/game/Vehicle.cpp index 4207837c6..5002d795f 100644 --- a/src/game/Vehicle.cpp +++ b/src/game/Vehicle.cpp @@ -23,79 +23,7 @@ #include "Unit.h" #include "Util.h" -Vehicle::Vehicle() : Creature(CREATURE_SUBTYPE_VEHICLE), m_vehicleId(0) -{ - m_updateFlag = (UPDATEFLAG_LIVING | UPDATEFLAG_HAS_POSITION | UPDATEFLAG_VEHICLE); -} - -Vehicle::~Vehicle() +VehicleInfo::VehicleInfo(VehicleEntry const* entry) : + m_vehicleEntry(entry) { } - -void Vehicle::AddToWorld() -{ - ///- Register the vehicle for guid lookup - if(!IsInWorld()) - GetMap()->GetObjectsStore().insert(GetGUID(), (Vehicle*)this); - - Unit::AddToWorld(); -} - -void Vehicle::RemoveFromWorld() -{ - ///- Remove the vehicle from the accessor - if(IsInWorld()) - GetMap()->GetObjectsStore().erase(GetGUID(), (Vehicle*)NULL); - - ///- Don't call the function for Creature, normal mobs + totems go in a different storage - Unit::RemoveFromWorld(); -} - -void Vehicle::SetDeathState(DeathState s) // overwrite virtual Creature::SetDeathState and Unit::SetDeathState -{ - Creature::SetDeathState(s); -} - -void Vehicle::Update( uint32 update_diff, uint32 diff) -{ - Creature::Update(update_diff, diff); -} - -bool Vehicle::Create(uint32 guidlow, CreatureCreatePos& cPos, CreatureInfo const* cinfo, uint32 vehicleId, Team team) -{ - SetMap(cPos.GetMap()); - SetPhaseMask(cPos.GetPhaseMask(), false); - - Object::_Create(guidlow, cinfo->Entry, HIGHGUID_VEHICLE); - - if (!InitEntry(cinfo->Entry)) - return false; - - cPos.SelectFinalPoint(this); - - if (!cPos.Relocate(this)) - return false; - - m_defaultMovementType = IDLE_MOTION_TYPE; - - AIM_Initialize(); - - SetVehicleId(vehicleId); - - SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK); - SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 1.0f); - - CreatureInfo const *ci = GetCreatureInfo(); - setFaction(team == ALLIANCE ? ci->faction_A : ci->faction_H); - - SelectLevel(ci); - - return true; -} - -void Vehicle::Dismiss() -{ - SendObjectDeSpawnAnim(GetGUID()); - CombatStop(); - AddObjectToRemoveList(); -} diff --git a/src/game/Vehicle.h b/src/game/Vehicle.h index 8e642bf44..73ec3d631 100644 --- a/src/game/Vehicle.h +++ b/src/game/Vehicle.h @@ -25,36 +25,15 @@ #include "Unit.h" #include "SharedDefines.h" -class Vehicle : public Creature +struct VehicleEntry; + +class VehicleInfo { + VehicleEntry const* m_vehicleEntry; public: - explicit Vehicle(); - virtual ~Vehicle(); + explicit VehicleInfo(VehicleEntry const* entry); - void AddToWorld(); - void RemoveFromWorld(); - - bool Create(uint32 guidlow, CreatureCreatePos& cPos, CreatureInfo const* cinfo, uint32 vehicleId, Team team); - - void SetDeathState(DeathState s); // overwrite virtual Creature::SetDeathState and Unit::SetDeathState - void Update(uint32 update_diff, uint32 diff); // overwrite virtual Creature::Update and Unit::Update - - uint32 GetVehicleId() { return m_vehicleId; } - void SetVehicleId(uint32 vehicleid) { m_vehicleId = vehicleid; } - - void Dismiss(); - - protected: - uint32 m_vehicleId; - - private: - void SaveToDB(uint32, uint8, uint32) // overwrited of Creature::SaveToDB - don't must be called - { - MANGOS_ASSERT(false); - } - void DeleteFromDB() // overwrited of Creature::DeleteFromDB - don't must be called - { - MANGOS_ASSERT(false); - } + VehicleEntry const* GetEntry() const { return m_vehicleEntry; } }; + #endif diff --git a/src/game/World.cpp b/src/game/World.cpp index cef7969c8..5c7763554 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -31,7 +31,6 @@ #include "WorldPacket.h" #include "Weather.h" #include "Player.h" -#include "Vehicle.h" #include "SkillExtraItems.h" #include "SkillDiscovery.h" #include "AccountMgr.h" diff --git a/src/game/debugcmds.cpp b/src/game/debugcmds.cpp index d91d1ea5b..0f9c85284 100644 --- a/src/game/debugcmds.cpp +++ b/src/game/debugcmds.cpp @@ -19,7 +19,6 @@ #include "Common.h" #include "Database/DatabaseEnv.h" #include "WorldPacket.h" -#include "Vehicle.h" #include "Player.h" #include "Opcodes.h" #include "Chat.h" @@ -645,41 +644,6 @@ bool ChatHandler::HandleDebugArenaCommand(char* /*args*/) return true; } -bool ChatHandler::HandleDebugSpawnVehicleCommand(char* args) -{ - uint32 entry; - if (!ExtractUInt32(&args, entry)) - return false; - - uint32 id; - if (!ExtractUInt32(&args, id)) - return false; - - CreatureInfo const *ci = ObjectMgr::GetCreatureTemplate(entry); - if (!ci) - return false; - - VehicleEntry const *ve = sVehicleStore.LookupEntry(id); - if (!ve) - return false; - - Player* chr = m_session->GetPlayer(); - - Vehicle *v = new Vehicle; - - CreatureCreatePos pos(chr, chr->GetOrientation()); - - if (!v->Create(pos.GetMap()->GenerateLocalLowGuid(HIGHGUID_VEHICLE), pos, ci, id, chr->GetTeam())) - { - delete v; - return false; - } - - pos.GetMap()->Add((Creature*)v); - - return true; -} - bool ChatHandler::HandleDebugSpellCheckCommand(char* /*args*/) { sLog.outString( "Check expected in code spell properties base at table 'spell_check' content..."); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 2de66c486..0d09e3d85 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "11384" + #define REVISION_NR "11385" #endif // __REVISION_NR_H__ diff --git a/src/shared/revision_sql.h b/src/shared/revision_sql.h index 1fb5de4a3..cbbc64077 100644 --- a/src/shared/revision_sql.h +++ b/src/shared/revision_sql.h @@ -1,6 +1,6 @@ #ifndef __REVISION_SQL_H__ #define __REVISION_SQL_H__ #define REVISION_DB_CHARACTERS "required_11299_02_characters_pet_aura" - #define REVISION_DB_MANGOS "required_11348_01_mangos_spell_bonus_data" + #define REVISION_DB_MANGOS "required_11385_01_mangos_creature_template" #define REVISION_DB_REALMD "required_10008_01_realmd_realmd_db_version" #endif // __REVISION_SQL_H__