Core/Transport: Minor optimization in LoadTransports (And some cosmetic changes here and there in other files)

This commit is contained in:
Spp-
2011-08-03 08:18:24 +02:00
parent 43720b1e3a
commit fcdd4d784f
12 changed files with 33 additions and 31 deletions

View File

@@ -120,7 +120,7 @@ class UnitAI
virtual void DoAction(int32 const /*param*/) {}
virtual uint32 GetData(uint32 /*id = 0*/) { return 0; }
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; }
Unit* SelectTarget(SelectAggroTarget targetType, uint32 position = 0, float dist = 0.0f, bool playerOnly = false, int32 aura = 0);

View File

@@ -22,6 +22,9 @@
#include "World.h"
#include "SpellMgr.h"
#include "Vehicle.h"
#include "Log.h"
#include "MapReference.h"
#include "Player.h"
//Disable CreatureAI when charmed
void CreatureAI::OnCharmed(bool /*apply*/)

View File

@@ -68,7 +68,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Texts()
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))
{
sLog->outErrorDb("CreatureEventAI: Entry %i in table `creature_ai_texts` not found", i);

View File

@@ -25,10 +25,12 @@
class CreatureEventAIMgr
{
friend class ACE_Singleton<CreatureEventAIMgr, ACE_Null_Mutex>;
CreatureEventAIMgr(){};
public:
private:
CreatureEventAIMgr(){};
~CreatureEventAIMgr(){};
public:
void LoadCreatureEventAI_Texts();
void LoadCreatureEventAI_Summons();
void LoadCreatureEventAI_Scripts();

View File

@@ -157,7 +157,7 @@ class SmartAI : public CreatureAI
void SetData(uint32 id, uint32 value);
// 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
uint64 GetGUID(int32 id = 0);

View File

@@ -438,8 +438,7 @@ bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entr
need_save = true;
}
std::string enchants = fields[6].GetString();
_LoadIntoDataField(enchants.c_str(), ITEM_FIELD_ENCHANTMENT_1_1, MAX_ENCHANTMENT_SLOT * MAX_ENCHANTMENT_OFFSET);
_LoadIntoDataField(fields[6].GetCString(), ITEM_FIELD_ENCHANTMENT_1_1, MAX_ENCHANTMENT_SLOT * MAX_ENCHANTMENT_OFFSET);
SetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID, fields[7].GetInt16());
// recalculate suffix factor
if (GetItemRandomPropertyId() < 0)

View File

@@ -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
// 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?
if (GetUInt32Value(UNIT_CREATED_BY_SPELL))
if (summon_spell_id)
{
WorldPacket data(SMSG_SPELL_GO, (8+8+4+4+2));
data.append(owner->GetPackGUID());
data.append(owner->GetPackGUID());
data << uint8(0);
data << uint32(GetUInt32Value(UNIT_CREATED_BY_SPELL));
data << uint32(summon_spell_id);
data << uint32(256); // CAST_FLAG_UNKNOWN3
data << uint32(0);
owner->SendMessageToSet(&data, true);

View File

@@ -52,21 +52,17 @@ void MapManager::LoadTransports()
uint32 period = fields[3].GetUInt32();
uint32 scriptId = sObjectMgr->GetScriptId(fields[4].GetCString());
Transport *t = new Transport(period, scriptId);
const GameObjectTemplate *goinfo = sObjectMgr->GetGameObjectTemplate(entry);
if (!goinfo)
{
sLog->outErrorDb("Transport ID:%u, Name: %s, will not be loaded, gameobject_template missing", entry, name.c_str());
delete t;
continue;
}
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());
delete t;
continue;
}
@@ -74,6 +70,7 @@ void MapManager::LoadTransports()
std::set<uint32> mapsUsed;
Transport *t = new Transport(period, scriptId);
if (!t->GenerateWaypoints(goinfo->moTransport.taxiPathId, mapsUsed))
// skip transports with empty waypoints list
{
@@ -119,7 +116,7 @@ void MapManager::LoadTransports()
uint32 guid = fields[0].GetUInt32();
uint32 entry = fields[1].GetUInt32();
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());
}
@@ -173,10 +170,10 @@ void MapManager::LoadTransportNPCs()
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);
currenttguid = 0;
}
Transport::~Transport()

View File

@@ -187,13 +187,13 @@ void Vehicle::RemoveAllPassengers()
// 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 don't need to iterate over m_Seats
// We don't need to iterate over Seats
_me->RemoveAurasByType(SPELL_AURA_CONTROL_VEHICLE);
// Following the above logic, this assertion should NEVER fail.
// Even in 'hacky' cases, there should at least be VEHICLE_SPELL_RIDE_HARDCODED on us.
// 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);
}

View File

@@ -118,7 +118,7 @@ class Vehicle
Unit* GetBase() const { return _me; }
VehicleEntry const* GetVehicleInfo() const { return _vehicleInfo; }
uint32 const GetCreatureEntry() const { return _creatureEntry; }
uint32 GetCreatureEntry() const { return _creatureEntry; }
bool HasEmptySeat(int8 seatId) const;
Unit* GetPassenger(int8 seatId) const;

View File

@@ -1185,9 +1185,13 @@ void Spell::EffectDummy(SpellEffIndex effIndex)
if (unitTarget->GetEntry() != 29402)
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)
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);
return;
@@ -1394,7 +1398,7 @@ void Spell::EffectDummy(SpellEffIndex effIndex)
if (AuraEffect *dummy = owner->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_SHAMAN, 338, 1))
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;
}
// Mana Spring Totem
@@ -3706,9 +3710,8 @@ void Spell::EffectSummonPet(SpellEffIndex effIndex)
Player* owner = NULL;
if (m_originalCaster)
{
if (m_originalCaster->GetTypeId() == TYPEID_PLAYER)
owner = (Player*)m_originalCaster;
else if (m_originalCaster->ToCreature()->isTotem())
owner = m_originalCaster->ToPlayer();
if (!owner && m_originalCaster->ToCreature()->isTotem())
owner = m_originalCaster->GetCharmerOrOwnerPlayerOrPlayerItself();
}
@@ -3845,9 +3848,7 @@ void Spell::EffectWeaponDmg(SpellEffIndex /*effIndex*/)
void Spell::SpellDamageWeaponDmg(SpellEffIndex effIndex)
{
if (!unitTarget)
return;
if (!unitTarget->isAlive())
if (!unitTarget || !unitTarget->isAlive())
return;
// multiple weapon dmg effect workaround
@@ -6366,7 +6367,7 @@ void Spell::EffectTransmitted(SpellEffIndex effIndex)
if (m_caster->GetTypeId() == TYPEID_PLAYER)
{
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;
}
@@ -6961,7 +6962,7 @@ void Spell::EffectCastButtons(SpellEffIndex effIndex)
uint32 button_id = m_spellInfo->Effects[effIndex].MiscValue + 132;
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);
if (!ab || ab->GetType() != ACTION_BUTTON_SPELL)

View File

@@ -3345,4 +3345,4 @@ void SpellMgr::LoadDbcDataCorrections()
sLog->outString(">> Loading spell dbc data corrections in %u ms", GetMSTimeDiffToNow(oldMSTime));
sLog->outString();
}
}