mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-02-10 03:59:05 +01:00
* Remove Player::SetSession (obsolete and dangerous function).
* Speed up map script searches (avoid redundant loops). * Fix linking errors for ScriptObject::RegisterSelf. --HG-- branch : trunk extra : rebase_source : 2ba48fdab4e119c6de7fe64e47c5b8115fdac1b5
This commit is contained in:
@@ -1812,7 +1812,6 @@ class Player : public Unit, public GridObject<Player>
|
||||
void RemovedInsignia(Player* looterPlr);
|
||||
|
||||
WorldSession* GetSession() const { return m_session; }
|
||||
void SetSession(WorldSession *s) { m_session = s; }
|
||||
|
||||
void BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target) const;
|
||||
void DestroyForPlayer(Player *target, bool anim = false) const;
|
||||
|
||||
@@ -301,7 +301,7 @@ void ScriptMgr::CreateSpellScripts(uint32 spell_id, std::list<SpellScript *> & s
|
||||
|
||||
if (!script)
|
||||
{
|
||||
sLog.outError("Spell script %s for spell %u returned a NULL SpellScript pointer!", tmpscript->ToString(), spell_id);
|
||||
sLog.outError("Spell script %s for spell %u returned a NULL SpellScript pointer!", tmpscript->GetName().c_str(), spell_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -324,7 +324,7 @@ void ScriptMgr::CreateSpellScripts(uint32 spell_id, std::vector<std::pair<SpellS
|
||||
|
||||
if (!script)
|
||||
{
|
||||
sLog.outError("Spell script %s for spell %u returned a NULL SpellScript pointer!", tmpscript->ToString(), spell_id);
|
||||
sLog.outError("Spell script %s for spell %u returned a NULL SpellScript pointer!", tmpscript->GetName().c_str(), spell_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -462,7 +462,7 @@ void ScriptMgr::OnGroupRateCalculation(float& rate, uint32 count, bool isRaid)
|
||||
{
|
||||
|
||||
#define SCR_MAP_END \
|
||||
break; \
|
||||
return; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
@@ -1188,7 +1188,7 @@ void ScriptMgr::ScriptRegistry<TScript>::AddScript(TScript* const script)
|
||||
if (it->second == script)
|
||||
{
|
||||
sLog.outError("Script '%s' forgot to allocate memory, so this script and/or the script before that can't work.",
|
||||
script->ToString());
|
||||
script->GetName().c_str());
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -1198,7 +1198,7 @@ void ScriptMgr::ScriptRegistry<TScript>::AddScript(TScript* const script)
|
||||
{
|
||||
// Get an ID for the script. An ID only exists if it's a script that is assigned in the database
|
||||
// through a script name (or similar).
|
||||
uint32 id = GetScriptId(script->ToString());
|
||||
uint32 id = GetScriptId(script->GetName().c_str());
|
||||
if (id)
|
||||
{
|
||||
// Try to find an existing script.
|
||||
@@ -1224,7 +1224,7 @@ void ScriptMgr::ScriptRegistry<TScript>::AddScript(TScript* const script)
|
||||
{
|
||||
// If the script is already assigned -> delete it!
|
||||
sLog.outError("Script '%s' already assigned with the same script name, so the script can't work.",
|
||||
script->ToString());
|
||||
script->GetName().c_str());
|
||||
|
||||
delete script;
|
||||
}
|
||||
@@ -1234,7 +1234,7 @@ void ScriptMgr::ScriptRegistry<TScript>::AddScript(TScript* const script)
|
||||
// The script uses a script name from database, but isn't assigned to anything.
|
||||
if (script->GetName().find("example") == std::string::npos)
|
||||
sLog.outErrorDb("Script named '%s' does not have a script name assigned in database.",
|
||||
script->ToString());
|
||||
script->GetName().c_str());
|
||||
|
||||
delete script;
|
||||
}
|
||||
|
||||
@@ -82,13 +82,17 @@ void DoScriptText(int32 textEntry, WorldObject* pSource, Unit *pTarget = NULL);
|
||||
{
|
||||
uint32 _someId;
|
||||
|
||||
private:
|
||||
|
||||
void RegisterSelf();
|
||||
|
||||
protected:
|
||||
|
||||
MyScriptType(const char* name, uint32 someId)
|
||||
: ScriptObject(name), _someId(someId)
|
||||
{ }
|
||||
|
||||
void RegisterSelf();
|
||||
{
|
||||
RegisterSelf();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -162,8 +166,6 @@ class ScriptObject
|
||||
|
||||
const std::string& GetName() const { return _name; }
|
||||
|
||||
const char* ToString() const { return _name.c_str(); }
|
||||
|
||||
protected:
|
||||
|
||||
// Call this to register the script with ScriptMgr.
|
||||
@@ -174,9 +176,6 @@ class ScriptObject
|
||||
{
|
||||
// Allow the script to do startup routines.
|
||||
OnInitialize();
|
||||
|
||||
// Register with ScriptMgr.
|
||||
RegisterSelf();
|
||||
}
|
||||
|
||||
virtual ~ScriptObject()
|
||||
@@ -205,13 +204,17 @@ template<class TObject> class UpdatableScript
|
||||
|
||||
class SpellHandlerScript : public ScriptObject
|
||||
{
|
||||
private:
|
||||
|
||||
void RegisterSelf();
|
||||
|
||||
protected:
|
||||
|
||||
SpellHandlerScript(const char* name)
|
||||
: ScriptObject(name)
|
||||
{ }
|
||||
|
||||
void RegisterSelf();
|
||||
{
|
||||
RegisterSelf();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -223,13 +226,17 @@ class SpellHandlerScript : public ScriptObject
|
||||
|
||||
class AuraHandlerScript : public ScriptObject
|
||||
{
|
||||
private:
|
||||
|
||||
void RegisterSelf();
|
||||
|
||||
protected:
|
||||
|
||||
AuraHandlerScript(const char* name)
|
||||
: ScriptObject(name)
|
||||
{ }
|
||||
|
||||
void RegisterSelf();
|
||||
{
|
||||
RegisterSelf();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -241,13 +248,17 @@ class AuraHandlerScript : public ScriptObject
|
||||
|
||||
class ServerScript : public ScriptObject
|
||||
{
|
||||
private:
|
||||
|
||||
void RegisterSelf();
|
||||
|
||||
protected:
|
||||
|
||||
ServerScript(const char* name)
|
||||
: ScriptObject(name)
|
||||
{ }
|
||||
|
||||
void RegisterSelf();
|
||||
{
|
||||
RegisterSelf();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -279,13 +290,17 @@ class ServerScript : public ScriptObject
|
||||
|
||||
class WorldScript : public ScriptObject, public UpdatableScript<void>
|
||||
{
|
||||
private:
|
||||
|
||||
void RegisterSelf();
|
||||
|
||||
protected:
|
||||
|
||||
WorldScript(const char* name)
|
||||
: ScriptObject(name)
|
||||
{ }
|
||||
|
||||
void RegisterSelf();
|
||||
{
|
||||
RegisterSelf();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -316,13 +331,17 @@ class WorldScript : public ScriptObject, public UpdatableScript<void>
|
||||
|
||||
class FormulaScript : public ScriptObject
|
||||
{
|
||||
private:
|
||||
|
||||
void RegisterSelf();
|
||||
|
||||
protected:
|
||||
|
||||
FormulaScript(const char* name)
|
||||
: ScriptObject(name)
|
||||
{ }
|
||||
|
||||
void RegisterSelf();
|
||||
{
|
||||
RegisterSelf();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -347,6 +366,7 @@ class FormulaScript : public ScriptObject
|
||||
// Called after calculating experience gain.
|
||||
virtual void OnGainCalculation(uint32& gain, Player* player, Unit* unit) { }
|
||||
|
||||
// Called when calculating the experience rate for group experience.
|
||||
virtual void OnGroupRateCalculation(float& rate, uint32 count, bool isRaid) { }
|
||||
};
|
||||
|
||||
@@ -392,6 +412,10 @@ template<class TMap> class MapScript : public UpdatableScript<TMap>
|
||||
|
||||
class WorldMapScript : public ScriptObject, public MapScript<Map>
|
||||
{
|
||||
private:
|
||||
|
||||
void RegisterSelf();
|
||||
|
||||
protected:
|
||||
|
||||
WorldMapScript(const char* name, uint32 mapId)
|
||||
@@ -399,13 +423,17 @@ class WorldMapScript : public ScriptObject, public MapScript<Map>
|
||||
{
|
||||
if (GetEntry() && !GetEntry()->IsContinent())
|
||||
sLog.outError("WorldMapScript for map %u is invalid.", mapId);
|
||||
else
|
||||
RegisterSelf();
|
||||
}
|
||||
|
||||
void RegisterSelf();
|
||||
};
|
||||
|
||||
class InstanceMapScript : public ScriptObject, public MapScript<InstanceMap>
|
||||
{
|
||||
private:
|
||||
|
||||
void RegisterSelf();
|
||||
|
||||
protected:
|
||||
|
||||
InstanceMapScript(const char* name, uint32 mapId = 0)
|
||||
@@ -413,10 +441,10 @@ class InstanceMapScript : public ScriptObject, public MapScript<InstanceMap>
|
||||
{
|
||||
if (GetEntry() && !GetEntry()->IsDungeon())
|
||||
sLog.outError("InstanceMapScript for map %u is invalid.", mapId);
|
||||
else
|
||||
RegisterSelf();
|
||||
}
|
||||
|
||||
void RegisterSelf();
|
||||
|
||||
public:
|
||||
|
||||
bool IsDatabaseBound() const { return true; }
|
||||
@@ -434,6 +462,8 @@ class BattlegroundMapScript : public ScriptObject, public MapScript<Battleground
|
||||
{
|
||||
if (GetEntry() && !GetEntry()->IsBattleground())
|
||||
sLog.outError("BattlegroundMapScript for map %u is invalid.", mapId);
|
||||
else
|
||||
RegisterSelf();
|
||||
}
|
||||
|
||||
void RegisterSelf();
|
||||
@@ -441,13 +471,17 @@ class BattlegroundMapScript : public ScriptObject, public MapScript<Battleground
|
||||
|
||||
class ItemScript : public ScriptObject
|
||||
{
|
||||
private:
|
||||
|
||||
void RegisterSelf();
|
||||
|
||||
protected:
|
||||
|
||||
ItemScript(const char* name)
|
||||
: ScriptObject(name)
|
||||
{ }
|
||||
|
||||
void RegisterSelf();
|
||||
{
|
||||
RegisterSelf();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -468,13 +502,17 @@ class ItemScript : public ScriptObject
|
||||
|
||||
class CreatureScript : public ScriptObject, public UpdatableScript<Creature>
|
||||
{
|
||||
private:
|
||||
|
||||
void RegisterSelf();
|
||||
|
||||
protected:
|
||||
|
||||
CreatureScript(const char* name)
|
||||
: ScriptObject(name)
|
||||
{ }
|
||||
|
||||
void RegisterSelf();
|
||||
{
|
||||
RegisterSelf();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -513,13 +551,17 @@ class CreatureScript : public ScriptObject, public UpdatableScript<Creature>
|
||||
|
||||
class GameObjectScript : public ScriptObject, public UpdatableScript<GameObject>
|
||||
{
|
||||
private:
|
||||
|
||||
void RegisterSelf();
|
||||
|
||||
protected:
|
||||
|
||||
GameObjectScript(const char* name)
|
||||
: ScriptObject(name)
|
||||
{ }
|
||||
|
||||
void RegisterSelf();
|
||||
{
|
||||
RegisterSelf();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -552,13 +594,17 @@ class GameObjectScript : public ScriptObject, public UpdatableScript<GameObject>
|
||||
|
||||
class AreaTriggerScript : public ScriptObject
|
||||
{
|
||||
private:
|
||||
|
||||
void RegisterSelf();
|
||||
|
||||
protected:
|
||||
|
||||
AreaTriggerScript(const char* name)
|
||||
: ScriptObject(name)
|
||||
{ }
|
||||
|
||||
void RegisterSelf();
|
||||
{
|
||||
RegisterSelf();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -570,13 +616,17 @@ class AreaTriggerScript : public ScriptObject
|
||||
|
||||
class BattlegroundScript : public ScriptObject
|
||||
{
|
||||
private:
|
||||
|
||||
void RegisterSelf();
|
||||
|
||||
protected:
|
||||
|
||||
BattlegroundScript(const char* name)
|
||||
: ScriptObject(name)
|
||||
{ }
|
||||
|
||||
void RegisterSelf();
|
||||
{
|
||||
RegisterSelf();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -588,13 +638,17 @@ class BattlegroundScript : public ScriptObject
|
||||
|
||||
class OutdoorPvPScript : public ScriptObject
|
||||
{
|
||||
private:
|
||||
|
||||
void RegisterSelf();
|
||||
|
||||
protected:
|
||||
|
||||
OutdoorPvPScript(const char* name)
|
||||
: ScriptObject(name)
|
||||
{ }
|
||||
|
||||
void RegisterSelf();
|
||||
{
|
||||
RegisterSelf();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -606,13 +660,17 @@ class OutdoorPvPScript : public ScriptObject
|
||||
|
||||
class CommandScript : public ScriptObject
|
||||
{
|
||||
private:
|
||||
|
||||
void RegisterSelf();
|
||||
|
||||
protected:
|
||||
|
||||
CommandScript(const char* name)
|
||||
: ScriptObject(name)
|
||||
{ }
|
||||
|
||||
void RegisterSelf();
|
||||
{
|
||||
RegisterSelf();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -622,13 +680,17 @@ class CommandScript : public ScriptObject
|
||||
|
||||
class WeatherScript : public ScriptObject, public UpdatableScript<Weather>
|
||||
{
|
||||
private:
|
||||
|
||||
void RegisterSelf();
|
||||
|
||||
protected:
|
||||
|
||||
WeatherScript(const char* name)
|
||||
: ScriptObject(name)
|
||||
{ }
|
||||
|
||||
void RegisterSelf();
|
||||
{
|
||||
RegisterSelf();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -640,13 +702,17 @@ class WeatherScript : public ScriptObject, public UpdatableScript<Weather>
|
||||
|
||||
class AuctionHouseScript : public ScriptObject
|
||||
{
|
||||
private:
|
||||
|
||||
void RegisterSelf();
|
||||
|
||||
protected:
|
||||
|
||||
AuctionHouseScript(const char* name)
|
||||
: ScriptObject(name)
|
||||
{ }
|
||||
|
||||
void RegisterSelf();
|
||||
{
|
||||
RegisterSelf();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -665,13 +731,17 @@ class AuctionHouseScript : public ScriptObject
|
||||
|
||||
class ConditionScript : public ScriptObject
|
||||
{
|
||||
private:
|
||||
|
||||
void RegisterSelf();
|
||||
|
||||
protected:
|
||||
|
||||
ConditionScript(const char* name)
|
||||
: ScriptObject(name)
|
||||
{ }
|
||||
|
||||
void RegisterSelf();
|
||||
{
|
||||
RegisterSelf();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -683,13 +753,17 @@ class ConditionScript : public ScriptObject
|
||||
|
||||
class VehicleScript : public ScriptObject
|
||||
{
|
||||
private:
|
||||
|
||||
void RegisterSelf();
|
||||
|
||||
protected:
|
||||
|
||||
VehicleScript(const char* name)
|
||||
: ScriptObject(name)
|
||||
{ }
|
||||
|
||||
void RegisterSelf();
|
||||
{
|
||||
RegisterSelf();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -717,26 +791,33 @@ class VehicleScript : public ScriptObject
|
||||
|
||||
class DynamicObjectScript : public ScriptObject, public UpdatableScript<DynamicObject>
|
||||
{
|
||||
private:
|
||||
|
||||
void RegisterSelf();
|
||||
|
||||
protected:
|
||||
|
||||
DynamicObjectScript(const char* name)
|
||||
: ScriptObject(name)
|
||||
{ }
|
||||
|
||||
void RegisterSelf();
|
||||
{
|
||||
RegisterSelf();
|
||||
}
|
||||
};
|
||||
|
||||
class TransportScript : public ScriptObject, public UpdatableScript<Transport>
|
||||
{
|
||||
private:
|
||||
|
||||
void RegisterSelf();
|
||||
|
||||
protected:
|
||||
|
||||
TransportScript(const char* name)
|
||||
: ScriptObject(name)
|
||||
{
|
||||
RegisterSelf();
|
||||
}
|
||||
|
||||
void RegisterSelf();
|
||||
|
||||
public:
|
||||
|
||||
bool IsDatabaseBound() const { return true; }
|
||||
@@ -756,15 +837,18 @@ class TransportScript : public ScriptObject, public UpdatableScript<Transport>
|
||||
|
||||
class AchievementCriteriaScript : public ScriptObject
|
||||
{
|
||||
private:
|
||||
|
||||
void RegisterSelf();
|
||||
|
||||
protected:
|
||||
|
||||
AchievementCriteriaScript(const char* name)
|
||||
: ScriptObject(name)
|
||||
{
|
||||
RegisterSelf();
|
||||
}
|
||||
|
||||
void RegisterSelf();
|
||||
|
||||
public:
|
||||
|
||||
bool IsDatabaseBound() const { return true; }
|
||||
|
||||
Reference in New Issue
Block a user