[11385] Add support for static vehicle spawns

Signed-off-by: zergtmn <zerg@myisp.com>
This commit is contained in:
zergtmn 2011-04-20 23:23:47 +06:00
parent 75e1e7c3a3
commit 2835aa5f20
32 changed files with 115 additions and 331 deletions

View file

@ -24,7 +24,7 @@ CREATE TABLE `db_version` (
`version` varchar(120) default NULL, `version` varchar(120) default NULL,
`creature_ai_version` varchar(120) default NULL, `creature_ai_version` varchar(120) default NULL,
`cache_id` int(10) default '0', `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'; ) 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, `questItem6` int(11) UNSIGNED DEFAULT '0' NOT NULL,
`movementId` int(11) UNSIGNED DEFAULT '0' NOT NULL, `movementId` int(11) UNSIGNED DEFAULT '0' NOT NULL,
`RegenHealth` tinyint(3) unsigned NOT NULL default '1', `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', `equipment_id` mediumint(8) unsigned NOT NULL default '0',
`trainer_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', `vendor_id` mediumint(8) unsigned NOT NULL default '0',

View file

@ -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`;

View file

@ -213,7 +213,6 @@ ChatCommand * ChatHandler::getCommandTable()
{ "spellcheck", SEC_CONSOLE, true, &ChatHandler::HandleDebugSpellCheckCommand, "", NULL }, { "spellcheck", SEC_CONSOLE, true, &ChatHandler::HandleDebugSpellCheckCommand, "", NULL },
{ "spellcoefs", SEC_ADMINISTRATOR, true, &ChatHandler::HandleDebugSpellCoefsCommand, "", NULL }, { "spellcoefs", SEC_ADMINISTRATOR, true, &ChatHandler::HandleDebugSpellCoefsCommand, "", NULL },
{ "spellmods", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSpellModsCommand, "", NULL }, { "spellmods", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSpellModsCommand, "", NULL },
{ "spawnvehicle", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSpawnVehicleCommand, "", NULL },
{ "uws", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugUpdateWorldStateCommand, "", NULL }, { "uws", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugUpdateWorldStateCommand, "", NULL },
{ NULL, 0, false, NULL, "", NULL } { NULL, 0, false, NULL, "", NULL }
}; };

View file

@ -187,7 +187,6 @@ class ChatHandler
bool HandleDebugSetAuraStateCommand(char* args); bool HandleDebugSetAuraStateCommand(char* args);
bool HandleDebugSetItemValueCommand(char* args); bool HandleDebugSetItemValueCommand(char* args);
bool HandleDebugSetValueCommand(char* args); bool HandleDebugSetValueCommand(char* args);
bool HandleDebugSpawnVehicleCommand(char* args);
bool HandleDebugSpellCheckCommand(char* args); bool HandleDebugSpellCheckCommand(char* args);
bool HandleDebugSpellCoefsCommand(char* args); bool HandleDebugSpellCoefsCommand(char* args);
bool HandleDebugSpellModsCommand(char* args); bool HandleDebugSpellModsCommand(char* args);

View file

@ -190,7 +190,7 @@ Creature::~Creature()
void Creature::AddToWorld() void Creature::AddToWorld()
{ {
///- Register the creature for guid lookup ///- Register the creature for guid lookup
if(!IsInWorld() && GetObjectGuid().GetHigh() == HIGHGUID_UNIT) if (!IsInWorld() && GetObjectGuid().IsCreatureOrVehicle())
GetMap()->GetObjectsStore().insert<Creature>(GetGUID(), (Creature*)this); GetMap()->GetObjectsStore().insert<Creature>(GetGUID(), (Creature*)this);
Unit::AddToWorld(); Unit::AddToWorld();
@ -199,7 +199,7 @@ void Creature::AddToWorld()
void Creature::RemoveFromWorld() void Creature::RemoveFromWorld()
{ {
///- Remove the creature from the accessor ///- Remove the creature from the accessor
if(IsInWorld() && GetObjectGuid().GetHigh() == HIGHGUID_UNIT) if (IsInWorld() && GetObjectGuid().IsCreatureOrVehicle())
GetMap()->GetObjectsStore().erase<Creature>(GetGUID(), (Creature*)NULL); GetMap()->GetObjectsStore().erase<Creature>(GetGUID(), (Creature*)NULL);
Unit::RemoveFromWorld(); 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) for(int i = 0; i < CREATURE_MAX_SPELLS; ++i)
m_spells[i] = GetCreatureInfo()->spells[i]; m_spells[i] = GetCreatureInfo()->spells[i];
SetVehicleId(GetCreatureInfo()->vehicleId);
// if eventData set then event active and need apply spell_start // if eventData set then event active and need apply spell_start
if (eventData) if (eventData)
ApplyGameEventSpells(eventData, true); ApplyGameEventSpells(eventData, true);

View file

@ -132,6 +132,7 @@ struct CreatureInfo
uint32 questItems[6]; uint32 questItems[6];
uint32 movementId; uint32 movementId;
bool RegenHealth; bool RegenHealth;
uint32 vehicleId;
uint32 equipmentId; uint32 equipmentId;
uint32 trainerId; uint32 trainerId;
uint32 vendorId; uint32 vendorId;
@ -140,10 +141,9 @@ struct CreatureInfo
uint32 ScriptID; uint32 ScriptID;
// helpers // helpers
// TODO: return HIGHGUID_UNIT/HIGHGUID_VEHICLE base at currently missing creature template data
HighGuid GetHighGuid() const HighGuid GetHighGuid() const
{ {
return HIGHGUID_UNIT; return vehicleId ? HIGHGUID_VEHICLE : HIGHGUID_UNIT;
} }
SkillType GetRequiredLootSkill() const SkillType GetRequiredLootSkill() const
@ -423,7 +423,6 @@ enum CreatureSubtype
CREATURE_SUBTYPE_GENERIC, // new Creature CREATURE_SUBTYPE_GENERIC, // new Creature
CREATURE_SUBTYPE_PET, // new Pet CREATURE_SUBTYPE_PET, // new Pet
CREATURE_SUBTYPE_TOTEM, // new Totem CREATURE_SUBTYPE_TOTEM, // new Totem
CREATURE_SUBTYPE_VEHICLE, // new Vehicle
CREATURE_SUBTYPE_TEMPORARY_SUMMON, // new TemporarySummon CREATURE_SUBTYPE_TEMPORARY_SUMMON, // new TemporarySummon
}; };
@ -465,7 +464,6 @@ class MANGOS_DLL_SPEC Creature : public Unit
CreatureSubtype GetSubtype() const { return m_subtype; } CreatureSubtype GetSubtype() const { return m_subtype; }
bool IsPet() const { return m_subtype == CREATURE_SUBTYPE_PET; } 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 IsTotem() const { return m_subtype == CREATURE_SUBTYPE_TOTEM; }
bool IsTemporarySummon() const { return m_subtype == CREATURE_SUBTYPE_TEMPORARY_SUMMON; } bool IsTemporarySummon() const { return m_subtype == CREATURE_SUBTYPE_TEMPORARY_SUMMON; }

View file

@ -26,7 +26,6 @@
// Forward class definitions // Forward class definitions
class Corpse; class Corpse;
class Creature; class Creature;
class Vehicle;
class DynamicObject; class DynamicObject;
class GameObject; class GameObject;
class Pet; class Pet;
@ -60,7 +59,7 @@ class Camera;
// Cameras in world list just because linked with Player objects // Cameras in world list just because linked with Player objects
typedef TYPELIST_4(Player, Creature/*pets*/, Corpse/*resurrectable*/, Camera) AllWorldObjectTypes; typedef TYPELIST_4(Player, Creature/*pets*/, Corpse/*resurrectable*/, Camera) AllWorldObjectTypes;
typedef TYPELIST_4(GameObject, Creature/*except pets*/, DynamicObject, Corpse/*Bones*/) AllGridObjectTypes; 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<Camera> CameraMapType; typedef GridRefManager<Camera> CameraMapType;
typedef GridRefManager<Corpse> CorpseMapType; typedef GridRefManager<Corpse> CorpseMapType;

View file

@ -26,7 +26,6 @@
#include "TemporarySummon.h" #include "TemporarySummon.h"
#include "Totem.h" #include "Totem.h"
#include "Pet.h" #include "Pet.h"
#include "Vehicle.h"
#include "GameObject.h" #include "GameObject.h"
#include "Opcodes.h" #include "Opcodes.h"
#include "Chat.h" #include "Chat.h"
@ -1563,8 +1562,7 @@ bool ChatHandler::HandleNpcAddCommand(char* args)
return false; return false;
CreatureInfo const *cinfo = ObjectMgr::GetCreatureTemplate(id); CreatureInfo const *cinfo = ObjectMgr::GetCreatureTemplate(id);
//FIXME: need vehicle support like GenerateStaticCreatureLowGuid when its will allowed static spawns if (!cinfo)
if (!cinfo || cinfo->GetHighGuid() != HIGHGUID_UNIT)
{ {
PSendSysMessage(LANG_COMMAND_INVALIDCREATUREID, id); PSendSysMessage(LANG_COMMAND_INVALIDCREATUREID, id);
SetSentErrorMessage(true); SetSentErrorMessage(true);
@ -1844,9 +1842,6 @@ bool ChatHandler::HandleNpcDeleteCommand(char* args)
case CREATURE_SUBTYPE_TEMPORARY_SUMMON: case CREATURE_SUBTYPE_TEMPORARY_SUMMON:
((TemporarySummon*)unit)->UnSummon(); ((TemporarySummon*)unit)->UnSummon();
break; break;
case CREATURE_SUBTYPE_VEHICLE:
((Vehicle*)unit)->Dismiss();
break;
default: default:
return false; return false;
} }

View file

@ -83,6 +83,7 @@ void WorldSession::HandleAutostoreLootItemOpcode( WorldPacket & recv_data )
break; break;
} }
case HIGHGUID_UNIT: case HIGHGUID_UNIT:
case HIGHGUID_VEHICLE:
{ {
Creature* pCreature = GetPlayer()->GetMap()->GetCreature(lguid); Creature* pCreature = GetPlayer()->GetMap()->GetCreature(lguid);
@ -216,6 +217,7 @@ void WorldSession::HandleLootMoneyOpcode( WorldPacket & /*recv_data*/ )
break; break;
} }
case HIGHGUID_UNIT: case HIGHGUID_UNIT:
case HIGHGUID_VEHICLE:
{ {
Creature* pCreature = GetPlayer()->GetMap()->GetCreature(guid); Creature* pCreature = GetPlayer()->GetMap()->GetCreature(guid);
@ -460,6 +462,7 @@ void WorldSession::DoLootRelease(ObjectGuid lguid)
return; // item can be looted only single player return; // item can be looted only single player
} }
case HIGHGUID_UNIT: case HIGHGUID_UNIT:
case HIGHGUID_VEHICLE:
{ {
Creature* pCreature = GetPlayer()->GetMap()->GetCreature(lguid); Creature* pCreature = GetPlayer()->GetMap()->GetCreature(lguid);
@ -520,7 +523,7 @@ void WorldSession::HandleLootMasterGiveOpcode( WorldPacket & recv_data )
Loot *pLoot = NULL; Loot *pLoot = NULL;
if(lootguid.IsCreature()) if (lootguid.IsCreatureOrVehicle())
{ {
Creature *pCreature = GetPlayer()->GetMap()->GetCreature(lootguid); Creature *pCreature = GetPlayer()->GetMap()->GetCreature(lootguid);
if(!pCreature) if(!pCreature)

View file

@ -19,7 +19,6 @@
#include "Map.h" #include "Map.h"
#include "MapManager.h" #include "MapManager.h"
#include "Player.h" #include "Player.h"
#include "Vehicle.h"
#include "GridNotifiers.h" #include "GridNotifiers.h"
#include "Log.h" #include "Log.h"
#include "GridStates.h" #include "GridStates.h"
@ -138,7 +137,7 @@ template<>
void Map::AddToGrid(Creature* obj, NGridType *grid, Cell const& cell) void Map::AddToGrid(Creature* obj, NGridType *grid, Cell const& cell)
{ {
// add to world object registry in grid // add to world object registry in grid
if(obj->IsPet() || obj->IsVehicle()) if (obj->IsPet())
{ {
(*grid)(cell.CellX(), cell.CellY()).AddWorldObject<Creature>(obj); (*grid)(cell.CellX(), cell.CellY()).AddWorldObject<Creature>(obj);
obj->SetCurrentCell(cell); obj->SetCurrentCell(cell);
@ -182,7 +181,7 @@ template<>
void Map::RemoveFromGrid(Creature* obj, NGridType *grid, Cell const& cell) void Map::RemoveFromGrid(Creature* obj, NGridType *grid, Cell const& cell)
{ {
// remove from world object registry in grid // remove from world object registry in grid
if(obj->IsPet() || obj->IsVehicle()) if (obj->IsPet())
{ {
(*grid)(cell.CellX(), cell.CellY()).RemoveWorldObject<Creature>(obj); (*grid)(cell.CellX(), cell.CellY()).RemoveWorldObject<Creature>(obj);
} }
@ -1687,14 +1686,12 @@ void Map::ScriptsProcess()
break; break;
} }
case HIGHGUID_UNIT: case HIGHGUID_UNIT:
case HIGHGUID_VEHICLE:
source = GetCreature(step.sourceGuid); source = GetCreature(step.sourceGuid);
break; break;
case HIGHGUID_PET: case HIGHGUID_PET:
source = GetPet(step.sourceGuid); source = GetPet(step.sourceGuid);
break; break;
case HIGHGUID_VEHICLE:
source = GetVehicle(step.sourceGuid);
break;
case HIGHGUID_PLAYER: case HIGHGUID_PLAYER:
source = HashMapHolder<Player>::Find(step.sourceGuid); source = HashMapHolder<Player>::Find(step.sourceGuid);
break; break;
@ -1720,14 +1717,12 @@ void Map::ScriptsProcess()
switch(step.targetGuid.GetHigh()) switch(step.targetGuid.GetHigh())
{ {
case HIGHGUID_UNIT: case HIGHGUID_UNIT:
case HIGHGUID_VEHICLE:
target = GetCreature(step.targetGuid); target = GetCreature(step.targetGuid);
break; break;
case HIGHGUID_PET: case HIGHGUID_PET:
target = GetPet(step.targetGuid); target = GetPet(step.targetGuid);
break; break;
case HIGHGUID_VEHICLE:
target = GetVehicle(step.targetGuid);
break;
case HIGHGUID_PLAYER: case HIGHGUID_PLAYER:
target = HashMapHolder<Player>::Find(step.targetGuid); target = HashMapHolder<Player>::Find(step.targetGuid);
break; 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) Creature* Map::GetCreature(ObjectGuid guid)
{ {
return m_objectsStore.find<Creature>(guid.GetRawValue(), (Creature*)NULL); return m_objectsStore.find<Creature>(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<Vehicle>(guid.GetRawValue(), (Vehicle*)NULL);
}
/** /**
* Function return pet that in world at CURRENT map * Function return pet that in world at CURRENT map
* *
@ -2952,9 +2937,9 @@ Creature* Map::GetAnyTypeCreature(ObjectGuid guid)
{ {
switch(guid.GetHigh()) 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_PET: return GetPet(guid);
case HIGHGUID_VEHICLE: return GetVehicle(guid);
default: break; default: break;
} }
@ -3006,9 +2991,9 @@ WorldObject* Map::GetWorldObject(ObjectGuid guid)
{ {
case HIGHGUID_PLAYER: return GetPlayer(guid); case HIGHGUID_PLAYER: return GetPlayer(guid);
case HIGHGUID_GAMEOBJECT: return GetGameObject(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_PET: return GetPet(guid);
case HIGHGUID_VEHICLE: return GetVehicle(guid);
case HIGHGUID_DYNAMICOBJECT:return GetDynamicObject(guid); case HIGHGUID_DYNAMICOBJECT:return GetDynamicObject(guid);
case HIGHGUID_CORPSE: case HIGHGUID_CORPSE:
{ {

View file

@ -222,7 +222,6 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>
Player* GetPlayer(ObjectGuid guid); Player* GetPlayer(ObjectGuid guid);
Creature* GetCreature(ObjectGuid guid); Creature* GetCreature(ObjectGuid guid);
Vehicle* GetVehicle(ObjectGuid guid);
Pet* GetPet(ObjectGuid guid); Pet* GetPet(ObjectGuid guid);
Creature* GetAnyTypeCreature(ObjectGuid guid); // normal creature or pet or vehicle Creature* GetAnyTypeCreature(ObjectGuid guid); // normal creature or pet or vehicle
GameObject* GetGameObject(ObjectGuid guid); GameObject* GetGameObject(ObjectGuid guid);

View file

@ -435,13 +435,6 @@ void WorldSession::HandleDismissControlledVehicle(WorldPacket &recv_data)
return; return;
_player->m_movementInfo = mi; _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*/) void WorldSession::HandleMountSpecialAnimOpcode(WorldPacket& /*recvdata*/)

View file

@ -230,10 +230,6 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const
{ {
uint16 moveFlags2 = (isType(TYPEMASK_UNIT) ? ((Unit*)this)->m_movementInfo.GetMovementFlags2() : MOVEFLAG2_NONE); 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 *data << uint16(updateFlags); // update flags
// 0x20 // 0x20
@ -256,7 +252,7 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const
// (ok) most seem to have this // (ok) most seem to have this
unit->m_movementInfo.AddMovementFlag(MOVEFLAG_LEVITATING); unit->m_movementInfo.AddMovementFlag(MOVEFLAG_LEVITATING);
if (!((Creature*)unit)->hasUnitState(UNIT_STAT_MOVING)) if (!unit->hasUnitState(UNIT_STAT_ROOT))
{ {
// (ok) possibly some "hover" mode // (ok) possibly some "hover" mode
unit->m_movementInfo.AddMovementFlag(MOVEFLAG_ROOT); unit->m_movementInfo.AddMovementFlag(MOVEFLAG_ROOT);
@ -506,9 +502,9 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const
} }
// 0x80 // 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()); *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) if (x == 0.0f && y == 0.0f && z == 0.0f)
pos = CreatureCreatePos(this, GetOrientation(), CONTACT_DISTANCE, ang); 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; delete pCreature;
return NULL; return NULL;

View file

@ -58,7 +58,7 @@ ObjectGridRespawnMover::Visit(CreatureMapType &m)
Creature * c = iter->getSource(); 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(); Cell const& cur_cell = c->GetCurrentCell();

View file

@ -725,6 +725,12 @@ void ObjectMgr::LoadCreatureTemplates()
const_cast<CreatureInfo*>(cInfo)->MovementType = IDLE_MOTION_TYPE; const_cast<CreatureInfo*>(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<CreatureInfo*>(cInfo)->vehicleId = 0;
}
if(cInfo->equipmentId > 0) // 0 no equipment if(cInfo->equipmentId > 0) // 0 no equipment
{ {
if(!GetEquipmentInfo(cInfo->equipmentId)) if(!GetEquipmentInfo(cInfo->equipmentId))

View file

@ -1217,8 +1217,8 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] =
/*0x4A4*/ { "CMSG_QUERY_VEHICLE_STATUS", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x4A4*/ { "CMSG_QUERY_VEHICLE_STATUS", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL },
/*0x4A5*/ { "UMSG_UNKNOWN_1189", 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 }, /*0x4A6*/ { "SMSG_BATTLEGROUND_INFO_THROTTLED", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide },
/*0x4A7*/ { "SMSG_PLAYER_VEHICLE_DATA", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x4A7*/ { "SMSG_SET_VEHICLE_REC_ID", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide },
/*0x4A8*/ { "CMSG_PLAYER_VEHICLE_ENTER", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x4A8*/ { "CMSG_RIDE_VEHICLE_INTERACT", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL },
/*0x4A9*/ { "CMSG_EJECT_PASSENGER", 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 }, /*0x4AA*/ { "SMSG_PET_GUIDS", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide },
/*0x4AB*/ { "SMSG_CLIENTCACHE_VERSION", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x4AB*/ { "SMSG_CLIENTCACHE_VERSION", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide },

View file

@ -26,7 +26,6 @@
#include "WorldPacket.h" #include "WorldPacket.h"
#include "WorldSession.h" #include "WorldSession.h"
#include "UpdateMask.h" #include "UpdateMask.h"
#include "Vehicle.h"
#include "SkillDiscovery.h" #include "SkillDiscovery.h"
#include "QuestDef.h" #include "QuestDef.h"
#include "GossipDef.h" #include "GossipDef.h"
@ -8087,6 +8086,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type)
break; break;
} }
case HIGHGUID_UNIT: case HIGHGUID_UNIT:
case HIGHGUID_VEHICLE:
{ {
Creature *creature = GetMap()->GetCreature(guid); 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 ) void Player::CastedCreatureOrGO( uint32 entry, ObjectGuid guid, uint32 spell_id, bool original_caster )
{ {
bool isCreature = guid.IsCreature(); bool isCreature = guid.IsCreatureOrVehicle();
uint32 addCastCount = 1; uint32 addCastCount = 1;
for(int i = 0; i < MAX_QUEST_LOG_SIZE; ++i) for(int i = 0; i < MAX_QUEST_LOG_SIZE; ++i)
@ -21323,98 +21323,6 @@ void Player::ApplyGlyphs(bool apply)
ApplyGlyph(i,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() bool Player::isTotalImmune()
{ {
AuraList const& immune = GetAurasByType(SPELL_AURA_SCHOOL_IMMUNITY); AuraList const& immune = GetAurasByType(SPELL_AURA_SCHOOL_IMMUNITY);
@ -22795,6 +22703,7 @@ Object* Player::GetObjectByTypeMask(ObjectGuid guid, TypeMask typemask)
return GetMap()->GetGameObject(guid); return GetMap()->GetGameObject(guid);
break; break;
case HIGHGUID_UNIT: case HIGHGUID_UNIT:
case HIGHGUID_VEHICLE:
if ((typemask & TYPEMASK_UNIT) && IsInWorld()) if ((typemask & TYPEMASK_UNIT) && IsInWorld())
return GetMap()->GetCreature(guid); return GetMap()->GetCreature(guid);
break; break;
@ -22802,10 +22711,6 @@ Object* Player::GetObjectByTypeMask(ObjectGuid guid, TypeMask typemask)
if ((typemask & TYPEMASK_UNIT) && IsInWorld()) if ((typemask & TYPEMASK_UNIT) && IsInWorld())
return GetMap()->GetPet(guid); return GetMap()->GetPet(guid);
break; break;
case HIGHGUID_VEHICLE:
if ((typemask & TYPEMASK_UNIT) && IsInWorld())
return GetMap()->GetVehicle(guid);
break;
case HIGHGUID_DYNAMICOBJECT: case HIGHGUID_DYNAMICOBJECT:
if ((typemask & TYPEMASK_DYNAMICOBJECT) && IsInWorld()) if ((typemask & TYPEMASK_DYNAMICOBJECT) && IsInWorld())
return GetMap()->GetDynamicObject(guid); return GetMap()->GetDynamicObject(guid);

View file

@ -51,7 +51,6 @@ class Transport;
class UpdateMask; class UpdateMask;
class SpellCastTargets; class SpellCastTargets;
class PlayerSocial; class PlayerSocial;
class Vehicle;
class DungeonPersistentState; class DungeonPersistentState;
class Spell; class Spell;
class Item; class Item;
@ -2186,9 +2185,6 @@ class MANGOS_DLL_SPEC Player : public Unit
Unit* GetMover() const { return m_mover; } Unit* GetMover() const { return m_mover; }
bool IsSelfMover() const { return m_mover == this; }// normal case for player not controlling other unit 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); } ObjectGuid const& GetFarSightGuid() const { return GetGuidValue(PLAYER_FARSIGHT); }
// Transports // Transports

View file

@ -105,7 +105,7 @@ void PointMovementGenerator<Creature>::MovementInform(Creature &unit)
if (unit.IsTemporarySummon()) if (unit.IsTemporarySummon())
{ {
TemporarySummon* pSummon = (TemporarySummon*)(&unit); TemporarySummon* pSummon = (TemporarySummon*)(&unit);
if (pSummon->GetSummonerGuid().IsCreature()) if (pSummon->GetSummonerGuid().IsCreatureOrVehicle())
if(Creature* pSummoner = unit.GetMap()->GetCreature(pSummon->GetSummonerGuid())) if(Creature* pSummoner = unit.GetMap()->GetCreature(pSummon->GetSummonerGuid()))
if (pSummoner->AI()) if (pSummoner->AI())
pSummoner->AI()->SummonedMovementInform(&unit, POINT_MOTION_TYPE, id); pSummoner->AI()->SummonedMovementInform(&unit, POINT_MOTION_TYPE, id);

View file

@ -636,7 +636,7 @@ void WorldSession::HandleQuestgiverStatusMultipleQuery(WorldPacket& /*recvPacket
{ {
uint8 dialogStatus = DIALOG_STATUS_NONE; uint8 dialogStatus = DIALOG_STATUS_NONE;
if (itr->IsCreatureOrPet()) if (itr->IsAnyTypeCreature())
{ {
// need also pet quests case support // need also pet quests case support
Creature *questgiver = GetPlayer()->GetMap()->GetAnyTypeCreature(*itr); Creature *questgiver = GetPlayer()->GetMap()->GetAnyTypeCreature(*itr);

View file

@ -21,8 +21,8 @@
#include "Database/SQLStorageImpl.h" #include "Database/SQLStorageImpl.h"
#include "Database/DatabaseEnv.h" #include "Database/DatabaseEnv.h"
const char CreatureInfosrcfmt[]="iiiiiiiiiisssiiiiiiiiiiifffiffiifiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiiffliiiiiiiliiiiis"; const char CreatureInfosrcfmt[]="iiiiiiiiiisssiiiiiiiiiiifffiffiifiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiiffliiiiiiiliiiiiis";
const char CreatureInfodstfmt[]="iiiiiiiiiisssiiiiiiiiiiifffiffiifiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiiffliiiiiiiliiiiii"; const char CreatureInfodstfmt[]="iiiiiiiiiisssiiiiiiiiiiifffiffiifiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiiffliiiiiiiliiiiiii";
const char CreatureDataAddonInfofmt[]="iiibbiis"; const char CreatureDataAddonInfofmt[]="iiibbiis";
const char CreatureModelfmt[]="iffbii"; const char CreatureModelfmt[]="iffbii";
const char CreatureInfoAddonInfofmt[]="iiibbiis"; const char CreatureInfoAddonInfofmt[]="iiibbiis";

View file

@ -3385,7 +3385,7 @@ void Spell::update(uint32 difftime)
for(TargetList::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) for(TargetList::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
{ {
TargetInfo const& target = *ihit; TargetInfo const& target = *ihit;
if (!target.targetGUID.IsCreature()) if (!target.targetGUID.IsCreatureOrVehicle())
continue; continue;
Unit* unit = m_caster->GetObjectGuid() == target.targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, target.targetGUID); Unit* unit = m_caster->GetObjectGuid() == target.targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, target.targetGUID);

View file

@ -7927,27 +7927,31 @@ void Aura::HandleAuraControlVehicle(bool apply, bool Real)
return; return;
Unit* target = GetTarget(); Unit* target = GetTarget();
if (target->GetTypeId() != TYPEID_UNIT || !((Creature*)target)->IsVehicle()) if (!target->IsVehicle())
return; return;
Vehicle* vehicle = (Vehicle*)target;
// TODO: Check for free seat
Unit *caster = GetCaster(); Unit *caster = GetCaster();
if (!caster || caster->GetTypeId() != TYPEID_PLAYER) if (!caster)
return; return;
if (apply) if (apply)
{ {
((Player*)caster)->RemovePet(PET_SAVE_AS_CURRENT); if (caster->GetTypeId() == TYPEID_PLAYER)
((Player*)caster)->EnterVehicle(vehicle); ((Player*)caster)->RemovePet(PET_SAVE_AS_CURRENT);
//caster->EnterVehicle(target);
} }
else else
{ {
SpellEntry const *spell = GetSpellProto();
// some SPELL_AURA_CONTROL_VEHICLE auras have a dummy effect on the player - remove them // 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();
} }
} }

View file

@ -163,7 +163,7 @@ void TemporarySummon::UnSummon()
{ {
CombatStop(); CombatStop();
if (GetSummonerGuid().IsCreature()) if (GetSummonerGuid().IsCreatureOrVehicle())
if(Creature* sum = GetMap()->GetCreature(GetSummonerGuid())) if(Creature* sum = GetMap()->GetCreature(GetSummonerGuid()))
if (sum->AI()) if (sum->AI())
sum->AI()->SummonedCreatureDespawn(this); sum->AI()->SummonedCreatureDespawn(this);

View file

@ -39,6 +39,7 @@
#include "Pet.h" #include "Pet.h"
#include "Util.h" #include "Util.h"
#include "Totem.h" #include "Totem.h"
#include "Vehicle.h"
#include "BattleGround.h" #include "BattleGround.h"
#include "InstanceData.h" #include "InstanceData.h"
#include "MapPersistentStateMgr.h" #include "MapPersistentStateMgr.h"
@ -180,8 +181,10 @@ void GlobalCooldownMgr::CancelGlobalCooldown(SpellEntry const* spellInfo)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Methods of class Unit // Methods of class Unit
Unit::Unit() Unit::Unit() :
: WorldObject(), i_motionMaster(this), m_ThreatManager(this), m_HostileRefManager(this) i_motionMaster(this), m_ThreatManager(this), m_HostileRefManager(this),
m_charmInfo(NULL),
m_vehicleInfo(NULL)
{ {
m_objectType |= TYPEMASK_UNIT; m_objectType |= TYPEMASK_UNIT;
m_objectTypeId = TYPEID_UNIT; m_objectTypeId = TYPEID_UNIT;
@ -258,8 +261,6 @@ Unit::Unit()
for (int i = 0; i < MAX_MOVE_TYPE; ++i) for (int i = 0; i < MAX_MOVE_TYPE; ++i)
m_speed_rate[i] = 1.0f; m_speed_rate[i] = 1.0f;
m_charmInfo = NULL;
// remove aurastates allowing special moves // remove aurastates allowing special moves
for(int i=0; i < MAX_REACTIVE; ++i) for(int i=0; i < MAX_REACTIVE; ++i)
m_reactiveTimer[i] = 0; 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 // those should be already removed at "RemoveFromWorld()" call
MANGOS_ASSERT(m_gameObj.size() == 0); MANGOS_ASSERT(m_gameObj.size() == 0);
@ -848,7 +849,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
if (cVictim->IsTemporarySummon()) if (cVictim->IsTemporarySummon())
{ {
TemporarySummon* pSummon = (TemporarySummon*)cVictim; TemporarySummon* pSummon = (TemporarySummon*)cVictim;
if (pSummon->GetSummonerGuid().IsCreature()) if (pSummon->GetSummonerGuid().IsCreatureOrVehicle())
if(Creature* pSummoner = cVictim->GetMap()->GetCreature(pSummon->GetSummonerGuid())) if(Creature* pSummoner = cVictim->GetMap()->GetCreature(pSummon->GetSummonerGuid()))
if (pSummoner->AI()) if (pSummoner->AI())
pSummoner->AI()->SummonedCreatureJustDied(cVictim); pSummoner->AI()->SummonedCreatureJustDied(cVictim);
@ -8438,10 +8439,6 @@ bool Unit::CanHaveThreatList() const
if (creature->IsTotem()) if (creature->IsTotem())
return false; 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 // pets can not have a threat list, unless they are controlled by a creature
if (creature->IsPet() && creature->GetOwnerGuid().IsPlayer()) if (creature->IsPet() && creature->GetOwnerGuid().IsPlayer())
return false; return false;
@ -10826,3 +10823,30 @@ void Unit::OnRelocated()
} }
ScheduleAINotify(World::GetRelocationAINotifyDelay()); 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);
}
}

View file

@ -268,6 +268,7 @@ class Item;
class Pet; class Pet;
class PetAura; class PetAura;
class Totem; class Totem;
class VehicleInfo;
struct SpellImmune struct SpellImmune
{ {
@ -1303,6 +1304,10 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
void Mount(uint32 mount, uint32 spellId = 0); void Mount(uint32 mount, uint32 spellId = 0);
void Unmount(bool from_aura = false); 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; } uint16 GetMaxSkillValueForLevel(Unit const* target = NULL) const { return (target ? GetLevelForTarget(target) : getLevel()) * 5; }
void DealDamageMods(Unit *pVictim, uint32 &damage, uint32* absorb); 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); 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_regenTimer;
uint32 m_lastManaUseTimer; uint32 m_lastManaUseTimer;
VehicleInfo* m_vehicleInfo;
private: private:
void CleanupDeletedAuras(); void CleanupDeletedAuras();

View file

@ -23,79 +23,7 @@
#include "Unit.h" #include "Unit.h"
#include "Util.h" #include "Util.h"
Vehicle::Vehicle() : Creature(CREATURE_SUBTYPE_VEHICLE), m_vehicleId(0) VehicleInfo::VehicleInfo(VehicleEntry const* entry) :
{ m_vehicleEntry(entry)
m_updateFlag = (UPDATEFLAG_LIVING | UPDATEFLAG_HAS_POSITION | UPDATEFLAG_VEHICLE);
}
Vehicle::~Vehicle()
{ {
} }
void Vehicle::AddToWorld()
{
///- Register the vehicle for guid lookup
if(!IsInWorld())
GetMap()->GetObjectsStore().insert<Vehicle>(GetGUID(), (Vehicle*)this);
Unit::AddToWorld();
}
void Vehicle::RemoveFromWorld()
{
///- Remove the vehicle from the accessor
if(IsInWorld())
GetMap()->GetObjectsStore().erase<Vehicle>(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();
}

View file

@ -25,36 +25,15 @@
#include "Unit.h" #include "Unit.h"
#include "SharedDefines.h" #include "SharedDefines.h"
class Vehicle : public Creature struct VehicleEntry;
class VehicleInfo
{ {
VehicleEntry const* m_vehicleEntry;
public: public:
explicit Vehicle(); explicit VehicleInfo(VehicleEntry const* entry);
virtual ~Vehicle();
void AddToWorld(); VehicleEntry const* GetEntry() const { return m_vehicleEntry; }
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);
}
}; };
#endif #endif

View file

@ -31,7 +31,6 @@
#include "WorldPacket.h" #include "WorldPacket.h"
#include "Weather.h" #include "Weather.h"
#include "Player.h" #include "Player.h"
#include "Vehicle.h"
#include "SkillExtraItems.h" #include "SkillExtraItems.h"
#include "SkillDiscovery.h" #include "SkillDiscovery.h"
#include "AccountMgr.h" #include "AccountMgr.h"

View file

@ -19,7 +19,6 @@
#include "Common.h" #include "Common.h"
#include "Database/DatabaseEnv.h" #include "Database/DatabaseEnv.h"
#include "WorldPacket.h" #include "WorldPacket.h"
#include "Vehicle.h"
#include "Player.h" #include "Player.h"
#include "Opcodes.h" #include "Opcodes.h"
#include "Chat.h" #include "Chat.h"
@ -645,41 +644,6 @@ bool ChatHandler::HandleDebugArenaCommand(char* /*args*/)
return true; 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*/) bool ChatHandler::HandleDebugSpellCheckCommand(char* /*args*/)
{ {
sLog.outString( "Check expected in code spell properties base at table 'spell_check' content..."); sLog.outString( "Check expected in code spell properties base at table 'spell_check' content...");

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "11384" #define REVISION_NR "11385"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__

View file

@ -1,6 +1,6 @@
#ifndef __REVISION_SQL_H__ #ifndef __REVISION_SQL_H__
#define __REVISION_SQL_H__ #define __REVISION_SQL_H__
#define REVISION_DB_CHARACTERS "required_11299_02_characters_pet_aura" #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" #define REVISION_DB_REALMD "required_10008_01_realmd_realmd_db_version"
#endif // __REVISION_SQL_H__ #endif // __REVISION_SQL_H__