mirror of
https://github.com/araxiaonline/TrinityCore2.git
synced 2026-06-16 21:09:50 -04:00
Core/Transport: Minor optimization in LoadTransports (And some cosmetic changes here and there in other files)
This commit is contained in:
@@ -120,7 +120,7 @@ class UnitAI
|
|||||||
virtual void DoAction(int32 const /*param*/) {}
|
virtual void DoAction(int32 const /*param*/) {}
|
||||||
virtual uint32 GetData(uint32 /*id = 0*/) { return 0; }
|
virtual uint32 GetData(uint32 /*id = 0*/) { return 0; }
|
||||||
virtual void SetData(uint32 /*id*/, uint32 /*value*/) {}
|
virtual void SetData(uint32 /*id*/, uint32 /*value*/) {}
|
||||||
virtual void SetGUID(uint64 const/*guid*/, int32 /*id*/ = 0) {}
|
virtual void SetGUID(uint64 /*guid*/, int32 /*id*/ = 0) {}
|
||||||
virtual uint64 GetGUID(int32 /*id*/ = 0) { return 0; }
|
virtual uint64 GetGUID(int32 /*id*/ = 0) { return 0; }
|
||||||
|
|
||||||
Unit* SelectTarget(SelectAggroTarget targetType, uint32 position = 0, float dist = 0.0f, bool playerOnly = false, int32 aura = 0);
|
Unit* SelectTarget(SelectAggroTarget targetType, uint32 position = 0, float dist = 0.0f, bool playerOnly = false, int32 aura = 0);
|
||||||
|
|||||||
@@ -22,6 +22,9 @@
|
|||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include "SpellMgr.h"
|
#include "SpellMgr.h"
|
||||||
#include "Vehicle.h"
|
#include "Vehicle.h"
|
||||||
|
#include "Log.h"
|
||||||
|
#include "MapReference.h"
|
||||||
|
#include "Player.h"
|
||||||
|
|
||||||
//Disable CreatureAI when charmed
|
//Disable CreatureAI when charmed
|
||||||
void CreatureAI::OnCharmed(bool /*apply*/)
|
void CreatureAI::OnCharmed(bool /*apply*/)
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Texts()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// range negative (don't must be happen, loaded from same table)
|
// range negative (must not happen, loaded from same table)
|
||||||
if (!sObjectMgr->GetTrinityStringLocale(i))
|
if (!sObjectMgr->GetTrinityStringLocale(i))
|
||||||
{
|
{
|
||||||
sLog->outErrorDb("CreatureEventAI: Entry %i in table `creature_ai_texts` not found", i);
|
sLog->outErrorDb("CreatureEventAI: Entry %i in table `creature_ai_texts` not found", i);
|
||||||
|
|||||||
@@ -25,10 +25,12 @@
|
|||||||
class CreatureEventAIMgr
|
class CreatureEventAIMgr
|
||||||
{
|
{
|
||||||
friend class ACE_Singleton<CreatureEventAIMgr, ACE_Null_Mutex>;
|
friend class ACE_Singleton<CreatureEventAIMgr, ACE_Null_Mutex>;
|
||||||
CreatureEventAIMgr(){};
|
|
||||||
public:
|
private:
|
||||||
|
CreatureEventAIMgr(){};
|
||||||
~CreatureEventAIMgr(){};
|
~CreatureEventAIMgr(){};
|
||||||
|
|
||||||
|
public:
|
||||||
void LoadCreatureEventAI_Texts();
|
void LoadCreatureEventAI_Texts();
|
||||||
void LoadCreatureEventAI_Summons();
|
void LoadCreatureEventAI_Summons();
|
||||||
void LoadCreatureEventAI_Scripts();
|
void LoadCreatureEventAI_Scripts();
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ class SmartAI : public CreatureAI
|
|||||||
void SetData(uint32 id, uint32 value);
|
void SetData(uint32 id, uint32 value);
|
||||||
|
|
||||||
// Used in scripts to share variables
|
// Used in scripts to share variables
|
||||||
void SetGUID(const uint64 guid, int32 id = 0);
|
void SetGUID(uint64 guid, int32 id = 0);
|
||||||
|
|
||||||
// Used in scripts to share variables
|
// Used in scripts to share variables
|
||||||
uint64 GetGUID(int32 id = 0);
|
uint64 GetGUID(int32 id = 0);
|
||||||
|
|||||||
@@ -438,8 +438,7 @@ bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entr
|
|||||||
need_save = true;
|
need_save = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string enchants = fields[6].GetString();
|
_LoadIntoDataField(fields[6].GetCString(), ITEM_FIELD_ENCHANTMENT_1_1, MAX_ENCHANTMENT_SLOT * MAX_ENCHANTMENT_OFFSET);
|
||||||
_LoadIntoDataField(enchants.c_str(), ITEM_FIELD_ENCHANTMENT_1_1, MAX_ENCHANTMENT_SLOT * MAX_ENCHANTMENT_OFFSET);
|
|
||||||
SetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID, fields[7].GetInt16());
|
SetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID, fields[7].GetInt16());
|
||||||
// recalculate suffix factor
|
// recalculate suffix factor
|
||||||
if (GetItemRandomPropertyId() < 0)
|
if (GetItemRandomPropertyId() < 0)
|
||||||
|
|||||||
@@ -266,13 +266,13 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c
|
|||||||
// Send fake summon spell cast - this is needed for correct cooldown application for spells
|
// Send fake summon spell cast - this is needed for correct cooldown application for spells
|
||||||
// Example: 46584 - without this cooldown (which should be set always when pet is loaded) isn't set clientside
|
// Example: 46584 - without this cooldown (which should be set always when pet is loaded) isn't set clientside
|
||||||
// TODO: pets should be summoned from real cast instead of just faking it?
|
// TODO: pets should be summoned from real cast instead of just faking it?
|
||||||
if (GetUInt32Value(UNIT_CREATED_BY_SPELL))
|
if (summon_spell_id)
|
||||||
{
|
{
|
||||||
WorldPacket data(SMSG_SPELL_GO, (8+8+4+4+2));
|
WorldPacket data(SMSG_SPELL_GO, (8+8+4+4+2));
|
||||||
data.append(owner->GetPackGUID());
|
data.append(owner->GetPackGUID());
|
||||||
data.append(owner->GetPackGUID());
|
data.append(owner->GetPackGUID());
|
||||||
data << uint8(0);
|
data << uint8(0);
|
||||||
data << uint32(GetUInt32Value(UNIT_CREATED_BY_SPELL));
|
data << uint32(summon_spell_id);
|
||||||
data << uint32(256); // CAST_FLAG_UNKNOWN3
|
data << uint32(256); // CAST_FLAG_UNKNOWN3
|
||||||
data << uint32(0);
|
data << uint32(0);
|
||||||
owner->SendMessageToSet(&data, true);
|
owner->SendMessageToSet(&data, true);
|
||||||
|
|||||||
@@ -52,21 +52,17 @@ void MapManager::LoadTransports()
|
|||||||
uint32 period = fields[3].GetUInt32();
|
uint32 period = fields[3].GetUInt32();
|
||||||
uint32 scriptId = sObjectMgr->GetScriptId(fields[4].GetCString());
|
uint32 scriptId = sObjectMgr->GetScriptId(fields[4].GetCString());
|
||||||
|
|
||||||
Transport *t = new Transport(period, scriptId);
|
|
||||||
|
|
||||||
const GameObjectTemplate *goinfo = sObjectMgr->GetGameObjectTemplate(entry);
|
const GameObjectTemplate *goinfo = sObjectMgr->GetGameObjectTemplate(entry);
|
||||||
|
|
||||||
if (!goinfo)
|
if (!goinfo)
|
||||||
{
|
{
|
||||||
sLog->outErrorDb("Transport ID:%u, Name: %s, will not be loaded, gameobject_template missing", entry, name.c_str());
|
sLog->outErrorDb("Transport ID:%u, Name: %s, will not be loaded, gameobject_template missing", entry, name.c_str());
|
||||||
delete t;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (goinfo->type != GAMEOBJECT_TYPE_MO_TRANSPORT)
|
if (goinfo->type != GAMEOBJECT_TYPE_MO_TRANSPORT)
|
||||||
{
|
{
|
||||||
sLog->outErrorDb("Transport ID:%u, Name: %s, will not be loaded, gameobject_template type wrong", entry, name.c_str());
|
sLog->outErrorDb("Transport ID:%u, Name: %s, will not be loaded, gameobject_template type wrong", entry, name.c_str());
|
||||||
delete t;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,6 +70,7 @@ void MapManager::LoadTransports()
|
|||||||
|
|
||||||
std::set<uint32> mapsUsed;
|
std::set<uint32> mapsUsed;
|
||||||
|
|
||||||
|
Transport *t = new Transport(period, scriptId);
|
||||||
if (!t->GenerateWaypoints(goinfo->moTransport.taxiPathId, mapsUsed))
|
if (!t->GenerateWaypoints(goinfo->moTransport.taxiPathId, mapsUsed))
|
||||||
// skip transports with empty waypoints list
|
// skip transports with empty waypoints list
|
||||||
{
|
{
|
||||||
@@ -119,7 +116,7 @@ void MapManager::LoadTransports()
|
|||||||
uint32 guid = fields[0].GetUInt32();
|
uint32 guid = fields[0].GetUInt32();
|
||||||
uint32 entry = fields[1].GetUInt32();
|
uint32 entry = fields[1].GetUInt32();
|
||||||
std::string name = fields[2].GetString();
|
std::string name = fields[2].GetString();
|
||||||
sLog->outErrorDb("Transport %u '%s' have record (GUID: %u) in `gameobject`. Transports DON'T must have any records in `gameobject` or its behavior will be unpredictable/bugged.", entry, name.c_str(), guid);
|
sLog->outErrorDb("Transport %u '%s' have record (GUID: %u) in `gameobject`. Transports must not have any records in `gameobject` or its behavior will be unpredictable/bugged.",entry,name.c_str(),guid);
|
||||||
}
|
}
|
||||||
while (result->NextRow());
|
while (result->NextRow());
|
||||||
}
|
}
|
||||||
@@ -173,10 +170,10 @@ void MapManager::LoadTransportNPCs()
|
|||||||
sLog->outString();
|
sLog->outString();
|
||||||
}
|
}
|
||||||
|
|
||||||
Transport::Transport(uint32 period, uint32 script) : GameObject(), m_period(period), ScriptId(script)
|
Transport::Transport(uint32 period, uint32 script) : GameObject(), m_pathTime(0), m_timer(0),
|
||||||
|
currenttguid(0), m_period(period), ScriptId(script), m_nextNodeTime(0)
|
||||||
{
|
{
|
||||||
m_updateFlag = (UPDATEFLAG_TRANSPORT | UPDATEFLAG_HIGHGUID | UPDATEFLAG_HAS_POSITION | UPDATEFLAG_ROTATION);
|
m_updateFlag = (UPDATEFLAG_TRANSPORT | UPDATEFLAG_HIGHGUID | UPDATEFLAG_HAS_POSITION | UPDATEFLAG_ROTATION);
|
||||||
currenttguid = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Transport::~Transport()
|
Transport::~Transport()
|
||||||
|
|||||||
@@ -187,13 +187,13 @@ void Vehicle::RemoveAllPassengers()
|
|||||||
|
|
||||||
// Passengers always cast an aura with SPELL_AURA_CONTROL_VEHICLE on the vehicle
|
// Passengers always cast an aura with SPELL_AURA_CONTROL_VEHICLE on the vehicle
|
||||||
// We just remove the aura and the unapply handler will make the target leave the vehicle.
|
// We just remove the aura and the unapply handler will make the target leave the vehicle.
|
||||||
// We don't need to iterate over m_Seats
|
// We don't need to iterate over Seats
|
||||||
_me->RemoveAurasByType(SPELL_AURA_CONTROL_VEHICLE);
|
_me->RemoveAurasByType(SPELL_AURA_CONTROL_VEHICLE);
|
||||||
|
|
||||||
// Following the above logic, this assertion should NEVER fail.
|
// Following the above logic, this assertion should NEVER fail.
|
||||||
// Even in 'hacky' cases, there should at least be VEHICLE_SPELL_RIDE_HARDCODED on us.
|
// Even in 'hacky' cases, there should at least be VEHICLE_SPELL_RIDE_HARDCODED on us.
|
||||||
// SeatMap::const_iterator itr;
|
// SeatMap::const_iterator itr;
|
||||||
// for (itr = m_Seats.begin(); itr != m_Seats.end(); ++itr)
|
// for (itr = Seats.begin(); itr != Seats.end(); ++itr)
|
||||||
// ASSERT(!itr->second.passenger);
|
// ASSERT(!itr->second.passenger);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ class Vehicle
|
|||||||
|
|
||||||
Unit* GetBase() const { return _me; }
|
Unit* GetBase() const { return _me; }
|
||||||
VehicleEntry const* GetVehicleInfo() const { return _vehicleInfo; }
|
VehicleEntry const* GetVehicleInfo() const { return _vehicleInfo; }
|
||||||
uint32 const GetCreatureEntry() const { return _creatureEntry; }
|
uint32 GetCreatureEntry() const { return _creatureEntry; }
|
||||||
|
|
||||||
bool HasEmptySeat(int8 seatId) const;
|
bool HasEmptySeat(int8 seatId) const;
|
||||||
Unit* GetPassenger(int8 seatId) const;
|
Unit* GetPassenger(int8 seatId) const;
|
||||||
|
|||||||
@@ -1185,9 +1185,13 @@ void Spell::EffectDummy(SpellEffIndex effIndex)
|
|||||||
if (unitTarget->GetEntry() != 29402)
|
if (unitTarget->GetEntry() != 29402)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_caster->SummonGameObject(192693, unitTarget->GetPositionX(), unitTarget->GetPositionY(), unitTarget->GetPositionZ(), unitTarget->GetOrientation(), 0, 0, 0, 0, 100);
|
m_caster->SummonGameObject(192693, unitTarget->GetPositionX(), unitTarget->GetPositionY(),
|
||||||
|
unitTarget->GetPositionZ(), unitTarget->GetOrientation(), 0, 0, 0, 0, 100);
|
||||||
|
|
||||||
for (uint8 i = 0; i < 4; ++i)
|
for (uint8 i = 0; i < 4; ++i)
|
||||||
m_caster->SummonGameObject(191567, float(unitTarget->GetPositionX() + irand(-7, 7)), float(unitTarget->GetPositionY() + irand(-7, 7)), unitTarget->GetPositionZ(), unitTarget->GetOrientation(), 0, 0, 0, 0, 100);
|
m_caster->SummonGameObject(191567, float(unitTarget->GetPositionX() + irand(-7, 7)),
|
||||||
|
float(unitTarget->GetPositionY() + irand(-7, 7)), unitTarget->GetPositionZ(), unitTarget->GetOrientation(),
|
||||||
|
0, 0, 0, 0, 100);
|
||||||
|
|
||||||
unitTarget->Kill(unitTarget);
|
unitTarget->Kill(unitTarget);
|
||||||
return;
|
return;
|
||||||
@@ -1394,7 +1398,7 @@ void Spell::EffectDummy(SpellEffIndex effIndex)
|
|||||||
if (AuraEffect *dummy = owner->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_SHAMAN, 338, 1))
|
if (AuraEffect *dummy = owner->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_SHAMAN, 338, 1))
|
||||||
AddPctN(damage, dummy->GetAmount());
|
AddPctN(damage, dummy->GetAmount());
|
||||||
|
|
||||||
m_caster->CastCustomSpell(unitTarget, 52042, &damage, 0, 0, true, 0, 0, m_originalCasterGUID);
|
m_caster->CastCustomSpell(unitTarget, 52042, &damage, 0, 0, true, 0, 0, m_originalCasterGUID);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Mana Spring Totem
|
// Mana Spring Totem
|
||||||
@@ -3706,9 +3710,8 @@ void Spell::EffectSummonPet(SpellEffIndex effIndex)
|
|||||||
Player* owner = NULL;
|
Player* owner = NULL;
|
||||||
if (m_originalCaster)
|
if (m_originalCaster)
|
||||||
{
|
{
|
||||||
if (m_originalCaster->GetTypeId() == TYPEID_PLAYER)
|
owner = m_originalCaster->ToPlayer();
|
||||||
owner = (Player*)m_originalCaster;
|
if (!owner && m_originalCaster->ToCreature()->isTotem())
|
||||||
else if (m_originalCaster->ToCreature()->isTotem())
|
|
||||||
owner = m_originalCaster->GetCharmerOrOwnerPlayerOrPlayerItself();
|
owner = m_originalCaster->GetCharmerOrOwnerPlayerOrPlayerItself();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3845,9 +3848,7 @@ void Spell::EffectWeaponDmg(SpellEffIndex /*effIndex*/)
|
|||||||
|
|
||||||
void Spell::SpellDamageWeaponDmg(SpellEffIndex effIndex)
|
void Spell::SpellDamageWeaponDmg(SpellEffIndex effIndex)
|
||||||
{
|
{
|
||||||
if (!unitTarget)
|
if (!unitTarget || !unitTarget->isAlive())
|
||||||
return;
|
|
||||||
if (!unitTarget->isAlive())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// multiple weapon dmg effect workaround
|
// multiple weapon dmg effect workaround
|
||||||
@@ -6366,7 +6367,7 @@ void Spell::EffectTransmitted(SpellEffIndex effIndex)
|
|||||||
if (m_caster->GetTypeId() == TYPEID_PLAYER)
|
if (m_caster->GetTypeId() == TYPEID_PLAYER)
|
||||||
{
|
{
|
||||||
pGameObj->AddUniqueUse(m_caster->ToPlayer());
|
pGameObj->AddUniqueUse(m_caster->ToPlayer());
|
||||||
m_caster->AddGameObject(pGameObj); // will removed at spell cancel
|
m_caster->AddGameObject(pGameObj); // will be removed at spell cancel
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -6961,7 +6962,7 @@ void Spell::EffectCastButtons(SpellEffIndex effIndex)
|
|||||||
uint32 button_id = m_spellInfo->Effects[effIndex].MiscValue + 132;
|
uint32 button_id = m_spellInfo->Effects[effIndex].MiscValue + 132;
|
||||||
uint32 n_buttons = m_spellInfo->Effects[effIndex].MiscValueB;
|
uint32 n_buttons = m_spellInfo->Effects[effIndex].MiscValueB;
|
||||||
|
|
||||||
for (; n_buttons; n_buttons--, button_id++)
|
for (; n_buttons; --n_buttons, ++button_id)
|
||||||
{
|
{
|
||||||
ActionButton const* ab = p_caster->GetActionButton(button_id);
|
ActionButton const* ab = p_caster->GetActionButton(button_id);
|
||||||
if (!ab || ab->GetType() != ACTION_BUTTON_SPELL)
|
if (!ab || ab->GetType() != ACTION_BUTTON_SPELL)
|
||||||
|
|||||||
@@ -3345,4 +3345,4 @@ void SpellMgr::LoadDbcDataCorrections()
|
|||||||
|
|
||||||
sLog->outString(">> Loading spell dbc data corrections in %u ms", GetMSTimeDiffToNow(oldMSTime));
|
sLog->outString(">> Loading spell dbc data corrections in %u ms", GetMSTimeDiffToNow(oldMSTime));
|
||||||
sLog->outString();
|
sLog->outString();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user