Core/Vehicles: Removed hacky setting entry for multi-passenger mounts

Core/Pools: Fixed compile

--HG--
branch : trunk
This commit is contained in:
Shauren
2010-09-14 16:14:43 +02:00
parent 102e51d620
commit c2c3302d2f
6 changed files with 147 additions and 153 deletions

View File

@@ -11843,9 +11843,9 @@ void Unit::Mount(uint32 mount, uint32 VehicleId, uint32 creatureEntry)
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_MOUNT);
// unsummon pet
if (GetTypeId() == TYPEID_PLAYER)
if (Player* plr = ToPlayer())
{
Pet* pet = this->ToPlayer()->GetPet();
Pet* pet = plr->GetPet();
if (pet)
{
Battleground *bg = ToPlayer()->GetBattleground();
@@ -11853,31 +11853,26 @@ void Unit::Mount(uint32 mount, uint32 VehicleId, uint32 creatureEntry)
if (bg && bg->isArena())
pet->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
else
this->ToPlayer()->UnsummonPetTemporaryIfAny();
plr->UnsummonPetTemporaryIfAny();
}
if (VehicleId != 0)
if (VehicleId)
{
if (sVehicleStore.LookupEntry(VehicleId))
if (CreateVehicleKit(VehicleId))
{
GetVehicleKit()->Reset();
if (CreateVehicleKit(VehicleId))
{
GetVehicleKit()->Reset();
// mounts can also have accessories
GetVehicleKit()->InstallAllAccessories(creatureEntry);
// mounts can also have accessories
GetVehicleKit()->GetBase()->SetEntry(creatureEntry); // set creature entry so InstallAllAccessories() can read correct accessories
GetVehicleKit()->InstallAllAccessories();
// Send others that we now have a vehicle
WorldPacket data(SMSG_PLAYER_VEHICLE_DATA, GetPackGUID().size()+4);
data.appendPackGUID(GetGUID());
data << uint32(VehicleId);
SendMessageToSet(&data,true);
// Send others that we now have a vehicle
WorldPacket data(SMSG_PLAYER_VEHICLE_DATA, GetPackGUID().size()+4);
data.appendPackGUID(GetGUID());
data << uint32(VehicleId);
SendMessageToSet(&data,true);
data.Initialize(SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA, 0);
this->ToPlayer()->GetSession()->SendPacket(&data);
}
data.Initialize(SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA, 0);
plr->GetSession()->SendPacket(&data);
}
}
}
@@ -16668,21 +16663,20 @@ void Unit::EnterVehicle(Vehicle *vehicle, int8 seatId)
}
}
if (GetTypeId() == TYPEID_PLAYER)
if (Player* plr = ToPlayer())
{
if (vehicle->GetBase()->GetTypeId() == TYPEID_PLAYER && this->ToPlayer()->isInCombat())
if (vehicle->GetBase()->GetTypeId() == TYPEID_PLAYER && plr->isInCombat())
return;
this->ToPlayer()->InterruptNonMeleeSpells(false);
this->ToPlayer()->StopCastingCharm();
this->ToPlayer()->StopCastingBindSight();
this->ToPlayer()->Unmount();
this->ToPlayer()->RemoveAurasByType(SPELL_AURA_MOUNTED);
InterruptNonMeleeSpells(false);
plr->StopCastingCharm();
plr->StopCastingBindSight();
Unmount();
RemoveAurasByType(SPELL_AURA_MOUNTED);
// drop flag at invisible in bg
if (this->ToPlayer()->InBattleground())
if (Battleground *bg = this->ToPlayer()->GetBattleground())
bg->EventPlayerDroppedFlag(this->ToPlayer());
if (Battleground *bg = plr->GetBattleground())
bg->EventPlayerDroppedFlag(plr);
}
ASSERT(!m_vehicle);

View File

@@ -115,9 +115,9 @@ void Vehicle::Install()
sScriptMgr.OnInstall(this);
}
void Vehicle::InstallAllAccessories()
void Vehicle::InstallAllAccessories(uint32 entry)
{
VehicleAccessoryList const* mVehicleList = sObjectMgr.GetVehicleAccessoryList(me->GetEntry());
VehicleAccessoryList const* mVehicleList = sObjectMgr.GetVehicleAccessoryList(entry);
if (!mVehicleList)
return;
@@ -163,7 +163,7 @@ void Vehicle::Reset()
}
else
{
InstallAllAccessories();
InstallAllAccessories(me->GetEntry());
if (m_usableSeatNum)
me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
}

View File

@@ -71,7 +71,7 @@ class Vehicle
void Uninstall();
void Reset();
void Die();
void InstallAllAccessories();
void InstallAllAccessories(uint32 entry);
Unit *GetBase() const { return me; }
VehicleEntry const *GetVehicleInfo() { return m_vehicleInfo; }

View File

@@ -46,13 +46,6 @@ bool ActivePoolData::IsActiveObject<GameObject>(uint32 db_guid) const
return mSpawnedGameobjects.find(db_guid) != mSpawnedGameobjects.end();
}
// Method that tell if a quest can be started
template<>
bool ActivePoolData::IsActiveObject<Quest>(uint32 quest_id) const
{
return mActiveQuests.find(quest_id) != mActiveQuests.end();
}
// Method that tell if a pool is spawned currently
template<>
bool ActivePoolData::IsActiveObject<Pool>(uint32 sub_pool_id) const
@@ -60,6 +53,13 @@ bool ActivePoolData::IsActiveObject<Pool>(uint32 sub_pool_id) const
return mSpawnedPools.find(sub_pool_id) != mSpawnedPools.end();
}
// Method that tell if a quest can be started
template<>
bool ActivePoolData::IsActiveObject<Quest>(uint32 quest_id) const
{
return mActiveQuests.find(quest_id) != mActiveQuests.end();
}
template<>
void ActivePoolData::ActivateObject<Creature>(uint32 db_guid, uint32 pool_id)
{
@@ -75,16 +75,16 @@ void ActivePoolData::ActivateObject<GameObject>(uint32 db_guid, uint32 pool_id)
}
template<>
void ActivePoolData::ActivateObject<Quest>(uint32 quest_id, uint32 pool_id)
void ActivePoolData::ActivateObject<Pool>(uint32 sub_pool_id, uint32 pool_id)
{
mActiveQuests.insert(quest_id);
mSpawnedPools[sub_pool_id] = 0;
++mSpawnedPools[pool_id];
}
template<>
void ActivePoolData::ActivateObject<Pool>(uint32 sub_pool_id, uint32 pool_id)
void ActivePoolData::ActivateObject<Quest>(uint32 quest_id, uint32 pool_id)
{
mSpawnedPools[sub_pool_id] = 0;
mActiveQuests.insert(quest_id);
++mSpawnedPools[pool_id];
}
@@ -107,18 +107,18 @@ void ActivePoolData::RemoveObject<GameObject>(uint32 db_guid, uint32 pool_id)
}
template<>
void ActivePoolData::RemoveObject<Quest>(uint32 quest_id, uint32 pool_id)
void ActivePoolData::RemoveObject<Pool>(uint32 sub_pool_id, uint32 pool_id)
{
mActiveQuests.erase(quest_id);
mSpawnedPools.erase(sub_pool_id);
uint32& val = mSpawnedPools[pool_id];
if (val > 0)
--val;
}
template<>
void ActivePoolData::RemoveObject<Pool>(uint32 sub_pool_id, uint32 pool_id)
void ActivePoolData::RemoveObject<Quest>(uint32 quest_id, uint32 pool_id)
{
mSpawnedPools.erase(sub_pool_id);
mActiveQuests.erase(quest_id);
uint32& val = mSpawnedPools[pool_id];
if (val > 0)
--val;
@@ -239,6 +239,13 @@ void PoolGroup<GameObject>::Despawn1Object(uint32 guid)
}
}
// Same on one pool
template<>
void PoolGroup<Pool>::Despawn1Object(uint32 child_pool_id)
{
sPoolMgr.DespawnPool(child_pool_id);
}
// Same on one quest
template<>
void PoolGroup<Quest>::Despawn1Object(uint32 quest_id)
@@ -282,13 +289,6 @@ void PoolGroup<Quest>::Despawn1Object(uint32 quest_id)
}
}
// Same on one pool
template<>
void PoolGroup<Pool>::Despawn1Object(uint32 child_pool_id)
{
sPoolMgr.DespawnPool(child_pool_id);
}
// Method for a pool only to remove any found record causing a circular dependency loop
template<>
void PoolGroup<Pool>::RemoveOneRelation(uint32 child_pool_id)
@@ -351,73 +351,6 @@ void PoolGroup<T>::SpawnObject(ActivePoolData& spawns, uint32 limit, uint32 trig
}
}
template <>
void PoolGroup<Quest>::SpawnObject(ActivePoolData& spawns, uint32 limit, uint32 triggerFrom)
{
sLog.outDebug("PoolGroup<Quest>: Spawning pool %u", poolId);
// load state from db
if (!triggerFrom)
{
QueryResult result = CharacterDatabase.PQuery("SELECT quest_id FROM pool_quest_save WHERE pool_id = %u", poolId);
if (result)
{
do
{
uint32 questId = result->Fetch()[0].GetUInt32();
spawns.ActivateObject<Quest>(questId, poolId);
PoolObject tempObj(questId, 0.0f);
Spawn1Object(&tempObj);
--limit;
} while (result->NextRow() && limit);
return;
}
}
uint32 lastDespawned = 0;
ActivePoolObjects currentQuests = spawns.GetActiveQuests();
ActivePoolObjects newQuests;
// always try to select different quests
for (PoolObjectList::iterator itr = EqualChanced.begin(); itr != EqualChanced.end(); ++itr)
{
if (spawns.IsActiveObject<Quest>(itr->guid))
continue;
newQuests.insert(itr->guid);
}
// clear the pool
DespawnObject(spawns);
// recycle minimal amount of quests if possible count is lower than limit
if (limit > newQuests.size() && !currentQuests.empty())
{
do
{
ActivePoolObjects::iterator itr = currentQuests.begin();
std::advance(itr, urand(0, currentQuests.size()-1));
newQuests.insert(*itr);
} while (newQuests.size() < limit);
}
if (newQuests.empty())
return;
// activate <limit> random quests
do
{
ActivePoolObjects::iterator itr = newQuests.begin();
std::advance(itr, urand(0, newQuests.size()-1));
spawns.ActivateObject<Quest>(*itr, poolId);
PoolObject tempObj(*itr, 0.0f);
Spawn1Object(&tempObj);
newQuests.erase(itr);
--limit;
} while (limit && newQuests.size());
// if we are here it means the pool is initialized at startup and did not have previous saved state
if (!triggerFrom)
sPoolMgr.SaveQuestsToDB();
}
// Method that is actualy doing the spawn job on 1 creature
template <>
void PoolGroup<Creature>::Spawn1Object(PoolObject* obj)
@@ -473,6 +406,13 @@ void PoolGroup<GameObject>::Spawn1Object(PoolObject* obj)
}
}
// Same for 1 pool
template <>
void PoolGroup<Pool>::Spawn1Object(PoolObject* obj)
{
sPoolMgr.SpawnPool(obj->guid);
}
// Same for 1 quest
template<>
void PoolGroup<Quest>::Spawn1Object(PoolObject* obj)
@@ -496,11 +436,71 @@ void PoolGroup<Quest>::Spawn1Object(PoolObject* obj)
}
}
// Same for 1 pool
template <>
void PoolGroup<Pool>::Spawn1Object(PoolObject* obj)
void PoolGroup<Quest>::SpawnObject(ActivePoolData& spawns, uint32 limit, uint32 triggerFrom)
{
sPoolMgr.SpawnPool(obj->guid);
sLog.outDebug("PoolGroup<Quest>: Spawning pool %u", poolId);
// load state from db
if (!triggerFrom)
{
QueryResult result = CharacterDatabase.PQuery("SELECT quest_id FROM pool_quest_save WHERE pool_id = %u", poolId);
if (result)
{
do
{
uint32 questId = result->Fetch()[0].GetUInt32();
spawns.ActivateObject<Quest>(questId, poolId);
PoolObject tempObj(questId, 0.0f);
Spawn1Object(&tempObj);
--limit;
} while (result->NextRow() && limit);
return;
}
}
ActivePoolObjects currentQuests = spawns.GetActiveQuests();
ActivePoolObjects newQuests;
// always try to select different quests
for (PoolObjectList::iterator itr = EqualChanced.begin(); itr != EqualChanced.end(); ++itr)
{
if (spawns.IsActiveObject<Quest>(itr->guid))
continue;
newQuests.insert(itr->guid);
}
// clear the pool
DespawnObject(spawns);
// recycle minimal amount of quests if possible count is lower than limit
if (limit > newQuests.size() && !currentQuests.empty())
{
do
{
ActivePoolObjects::iterator itr = currentQuests.begin();
std::advance(itr, urand(0, currentQuests.size()-1));
newQuests.insert(*itr);
} while (newQuests.size() < limit);
}
if (newQuests.empty())
return;
// activate <limit> random quests
do
{
ActivePoolObjects::iterator itr = newQuests.begin();
std::advance(itr, urand(0, newQuests.size()-1));
spawns.ActivateObject<Quest>(*itr, poolId);
PoolObject tempObj(*itr, 0.0f);
Spawn1Object(&tempObj);
newQuests.erase(itr);
--limit;
} while (limit && newQuests.size());
// if we are here it means the pool is initialized at startup and did not have previous saved state
if (!triggerFrom)
sPoolMgr.SaveQuestsToDB();
}
// Method that does the respawn job on the specified creature
@@ -521,18 +521,18 @@ void PoolGroup<GameObject>::ReSpawn1Object(PoolObject* obj)
pGameobject->GetMap()->Add(pGameobject);
}
// Nothing to do for a quest
template <>
void PoolGroup<Quest>::ReSpawn1Object(PoolObject* /*obj*/)
{
}
// Nothing to do for a child Pool
template <>
void PoolGroup<Pool>::ReSpawn1Object(PoolObject* /*obj*/)
{
}
// Nothing to do for a quest
template <>
void PoolGroup<Quest>::ReSpawn1Object(PoolObject* /*obj*/)
{
}
////////////////////////////////////////////////////////////
// Methods of class PoolMgr
@@ -1032,14 +1032,6 @@ void PoolMgr::SpawnPool<GameObject>(uint32 pool_id, uint32 db_guid)
mPoolGameobjectGroups[pool_id].SpawnObject(mSpawnedData, mPoolTemplate[pool_id].MaxLimit, db_guid);
}
// Call to spawn a pool
template<>
void PoolMgr::SpawnPool<Quest>(uint32 pool_id, uint32 quest_id)
{
if (!mPoolQuestGroups[pool_id].isEmpty())
mPoolQuestGroups[pool_id].SpawnObject(mSpawnedData, mPoolTemplate[pool_id].MaxLimit, quest_id);
}
// Call to spawn a pool, if cache if true the method will spawn only if cached entry is different
// If it's same, the pool is respawned only
template<>
@@ -1049,6 +1041,14 @@ void PoolMgr::SpawnPool<Pool>(uint32 pool_id, uint32 sub_pool_id)
mPoolPoolGroups[pool_id].SpawnObject(mSpawnedData, mPoolTemplate[pool_id].MaxLimit, sub_pool_id);
}
// Call to spawn a pool
template<>
void PoolMgr::SpawnPool<Quest>(uint32 pool_id, uint32 quest_id)
{
if (!mPoolQuestGroups[pool_id].isEmpty())
mPoolQuestGroups[pool_id].SpawnObject(mSpawnedData, mPoolTemplate[pool_id].MaxLimit, quest_id);
}
void PoolMgr::SpawnPool(uint32 pool_id)
{
SpawnPool<Pool>(pool_id, 0);
@@ -1066,11 +1066,11 @@ void PoolMgr::DespawnPool(uint32 pool_id)
if (!mPoolGameobjectGroups[pool_id].isEmpty())
mPoolGameobjectGroups[pool_id].DespawnObject(mSpawnedData);
if (!mPoolQuestGroups[pool_id].isEmpty())
mPoolQuestGroups[pool_id].DespawnObject(mSpawnedData);
if (!mPoolPoolGroups[pool_id].isEmpty())
mPoolPoolGroups[pool_id].DespawnObject(mSpawnedData);
if (!mPoolQuestGroups[pool_id].isEmpty())
mPoolQuestGroups[pool_id].DespawnObject(mSpawnedData);
}
// Method that check chance integrity of the creatures and gameobjects in this pool
@@ -1079,8 +1079,8 @@ bool PoolMgr::CheckPool(uint32 pool_id) const
return pool_id <= max_pool_id &&
mPoolGameobjectGroups[pool_id].CheckPool() &&
mPoolCreatureGroups[pool_id].CheckPool() &&
mPoolQuestGroups[pool_id].CheckPool() &&
mPoolPoolGroups[pool_id].CheckPool();
mPoolPoolGroups[pool_id].CheckPool() &&
mPoolQuestGroups[pool_id].CheckPool();
}
// Call to update the pool when a gameobject/creature part of pool [pool_id] is ready to respawn

View File

@@ -139,19 +139,19 @@ class PoolMgr
void SpawnPool(uint32 pool_id, uint32 db_guid_or_pool_id);
uint32 max_pool_id;
typedef std::vector<PoolTemplateData> PoolTemplateDataMap;
typedef std::vector<PoolTemplateData> PoolTemplateDataMap;
typedef std::vector<PoolGroup<Creature> > PoolGroupCreatureMap;
typedef std::vector<PoolGroup<GameObject> > PoolGroupGameObjectMap;
typedef std::vector<PoolGroup<Pool> > PoolGroupPoolMap;
typedef std::vector<PoolGroup<Quest> > PoolGroupQuestMap;
typedef std::pair<uint32, uint32> SearchPair;
typedef std::map<uint32, uint32> SearchMap;
typedef std::pair<uint32, uint32> SearchPair;
typedef std::map<uint32, uint32> SearchMap;
PoolTemplateDataMap mPoolTemplate;
PoolGroupCreatureMap mPoolCreatureGroups;
PoolTemplateDataMap mPoolTemplate;
PoolGroupCreatureMap mPoolCreatureGroups;
PoolGroupGameObjectMap mPoolGameobjectGroups;
PoolGroupPoolMap mPoolPoolGroups;
PoolGroupQuestMap mPoolQuestGroups;
PoolGroupPoolMap mPoolPoolGroups;
PoolGroupQuestMap mPoolQuestGroups;
SearchMap mCreatureSearchMap;
SearchMap mGameobjectSearchMap;
SearchMap mPoolSearchMap;

View File

@@ -369,7 +369,7 @@ public:
void SpellHit(Unit* /*caster*/, const SpellEntry* pSpell)
{
if (pSpell->Id == SPELL_START_THE_ENGINE)
vehicle->InstallAllAccessories();
vehicle->InstallAllAccessories(me->GetEntry());
if (pSpell->Id == SPELL_ELECTROSHOCK)
me->InterruptSpell(CURRENT_CHANNELED_SPELL);