mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-17 08:00:48 +01:00
Core/ScriptMgr: Replace IsDatabaseBound() methods through traits.
This commit is contained in:
@@ -41,6 +41,60 @@
|
||||
UnusedScriptNamesContainer UnusedScriptNames;
|
||||
// }
|
||||
|
||||
// Trait which indicates whether this script type
|
||||
// must be assigned in the database.
|
||||
template<typename>
|
||||
struct is_script_database_bound
|
||||
: std::false_type { };
|
||||
|
||||
template<>
|
||||
struct is_script_database_bound<SpellScriptLoader>
|
||||
: std::true_type { };
|
||||
|
||||
template<>
|
||||
struct is_script_database_bound<InstanceMapScript>
|
||||
: std::true_type { };
|
||||
|
||||
template<>
|
||||
struct is_script_database_bound<ItemScript>
|
||||
: std::true_type { };
|
||||
|
||||
template<>
|
||||
struct is_script_database_bound<CreatureScript>
|
||||
: std::true_type { };
|
||||
|
||||
template<>
|
||||
struct is_script_database_bound<GameObjectScript>
|
||||
: std::true_type { };
|
||||
|
||||
template<>
|
||||
struct is_script_database_bound<AreaTriggerScript>
|
||||
: std::true_type { };
|
||||
|
||||
template<>
|
||||
struct is_script_database_bound<BattlegroundScript>
|
||||
: std::true_type { };
|
||||
|
||||
template<>
|
||||
struct is_script_database_bound<OutdoorPvPScript>
|
||||
: std::true_type { };
|
||||
|
||||
template<>
|
||||
struct is_script_database_bound<WeatherScript>
|
||||
: std::true_type { };
|
||||
|
||||
template<>
|
||||
struct is_script_database_bound<ConditionScript>
|
||||
: std::true_type { };
|
||||
|
||||
template<>
|
||||
struct is_script_database_bound<TransportScript>
|
||||
: std::true_type { };
|
||||
|
||||
template<>
|
||||
struct is_script_database_bound<AchievementCriteriaScript>
|
||||
: std::true_type { };
|
||||
|
||||
// This is the global static registry of scripts.
|
||||
template<class TScript>
|
||||
class ScriptRegistry
|
||||
@@ -71,7 +125,7 @@ class ScriptRegistry
|
||||
}
|
||||
}
|
||||
|
||||
if (script->IsDatabaseBound())
|
||||
if (is_script_database_bound<TScript>::value)
|
||||
{
|
||||
// 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).
|
||||
|
||||
@@ -152,10 +152,6 @@ class ScriptObject
|
||||
|
||||
public:
|
||||
|
||||
// Do not override this in scripts; it should be overridden by the various script type classes. It indicates
|
||||
// whether or not this script type must be assigned in the database.
|
||||
virtual bool IsDatabaseBound() const { return false; }
|
||||
|
||||
const std::string& GetName() const { return _name; }
|
||||
|
||||
protected:
|
||||
@@ -197,8 +193,6 @@ class SpellScriptLoader : public ScriptObject
|
||||
|
||||
public:
|
||||
|
||||
bool IsDatabaseBound() const final override { return true; }
|
||||
|
||||
// Should return a fully valid SpellScript pointer.
|
||||
virtual SpellScript* GetSpellScript() const { return NULL; }
|
||||
|
||||
@@ -355,8 +349,6 @@ class InstanceMapScript : public ScriptObject, public MapScript<InstanceMap>
|
||||
|
||||
public:
|
||||
|
||||
bool IsDatabaseBound() const final override { return true; }
|
||||
|
||||
// Gets an InstanceScript object for this instance.
|
||||
virtual InstanceScript* GetInstanceScript(InstanceMap* /*map*/) const { return NULL; }
|
||||
};
|
||||
@@ -376,8 +368,6 @@ class ItemScript : public ScriptObject
|
||||
|
||||
public:
|
||||
|
||||
bool IsDatabaseBound() const final override { return true; }
|
||||
|
||||
// Called when a dummy spell effect is triggered on the item.
|
||||
virtual bool OnDummyEffect(Unit* /*caster*/, uint32 /*spellId*/, SpellEffIndex /*effIndex*/, Item* /*target*/) { return false; }
|
||||
|
||||
@@ -425,8 +415,6 @@ class CreatureScript : public UnitScript, public UpdatableScript<Creature>
|
||||
|
||||
public:
|
||||
|
||||
bool IsDatabaseBound() const final override { return true; }
|
||||
|
||||
// Called when a dummy spell effect is triggered on the creature.
|
||||
virtual bool OnDummyEffect(Unit* /*caster*/, uint32 /*spellId*/, SpellEffIndex /*effIndex*/, Creature* /*target*/) { return false; }
|
||||
|
||||
@@ -463,8 +451,6 @@ class GameObjectScript : public ScriptObject, public UpdatableScript<GameObject>
|
||||
|
||||
public:
|
||||
|
||||
bool IsDatabaseBound() const final override { return true; }
|
||||
|
||||
// Called when a dummy spell effect is triggered on the gameobject.
|
||||
virtual bool OnDummyEffect(Unit* /*caster*/, uint32 /*spellId*/, SpellEffIndex /*effIndex*/, GameObject* /*target*/) { return false; }
|
||||
|
||||
@@ -510,8 +496,6 @@ class AreaTriggerScript : public ScriptObject
|
||||
|
||||
public:
|
||||
|
||||
bool IsDatabaseBound() const final override { return true; }
|
||||
|
||||
// Called when the area trigger is activated by a player.
|
||||
virtual bool OnTrigger(Player* /*player*/, AreaTriggerEntry const* /*trigger*/, bool /*entered*/) { return false; }
|
||||
};
|
||||
@@ -524,8 +508,6 @@ class BattlegroundScript : public ScriptObject
|
||||
|
||||
public:
|
||||
|
||||
bool IsDatabaseBound() const final override { return true; }
|
||||
|
||||
// Should return a fully valid Battleground object for the type ID.
|
||||
virtual Battleground* GetBattleground() const = 0;
|
||||
};
|
||||
@@ -538,8 +520,6 @@ class OutdoorPvPScript : public ScriptObject
|
||||
|
||||
public:
|
||||
|
||||
bool IsDatabaseBound() const final override { return true; }
|
||||
|
||||
// Should return a fully valid OutdoorPvP object for the type ID.
|
||||
virtual OutdoorPvP* GetOutdoorPvP() const = 0;
|
||||
};
|
||||
@@ -564,8 +544,6 @@ class WeatherScript : public ScriptObject, public UpdatableScript<Weather>
|
||||
|
||||
public:
|
||||
|
||||
bool IsDatabaseBound() const final override { return true; }
|
||||
|
||||
// Called when the weather changes in the zone this script is associated with.
|
||||
virtual void OnChange(Weather* /*weather*/, WeatherState /*state*/, float /*grade*/) { }
|
||||
};
|
||||
@@ -599,8 +577,6 @@ class ConditionScript : public ScriptObject
|
||||
|
||||
public:
|
||||
|
||||
bool IsDatabaseBound() const final override { return true; }
|
||||
|
||||
// Called when a single condition is checked for a player.
|
||||
virtual bool OnConditionCheck(Condition const* /*condition*/, ConditionSourceInfo& /*sourceInfo*/) { return true; }
|
||||
};
|
||||
@@ -647,8 +623,6 @@ class TransportScript : public ScriptObject, public UpdatableScript<Transport>
|
||||
|
||||
public:
|
||||
|
||||
bool IsDatabaseBound() const final override { return true; }
|
||||
|
||||
// Called when a player boards the transport.
|
||||
virtual void OnAddPassenger(Transport* /*transport*/, Player* /*player*/) { }
|
||||
|
||||
@@ -670,8 +644,6 @@ class AchievementCriteriaScript : public ScriptObject
|
||||
|
||||
public:
|
||||
|
||||
bool IsDatabaseBound() const final override { return true; }
|
||||
|
||||
// Called when an additional criteria is checked.
|
||||
virtual bool OnCheck(Player* source, Unit* target) = 0;
|
||||
};
|
||||
@@ -808,8 +780,6 @@ class GuildScript : public ScriptObject
|
||||
|
||||
public:
|
||||
|
||||
bool IsDatabaseBound() const final override { return false; }
|
||||
|
||||
// Called when a member is added to the guild.
|
||||
virtual void OnAddMember(Guild* /*guild*/, Player* /*player*/, uint8& /*plRank*/) { }
|
||||
|
||||
@@ -851,8 +821,6 @@ class GroupScript : public ScriptObject
|
||||
|
||||
public:
|
||||
|
||||
bool IsDatabaseBound() const final override { return false; }
|
||||
|
||||
// Called when a member is added to a group.
|
||||
virtual void OnAddMember(Group* /*group*/, ObjectGuid /*guid*/) { }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user