Core/ScriptMgr: Replace IsDatabaseBound() methods through traits.
(cherry picked from commit 12d1993994b11785174c7caa7d7f9b5aa87d8411)
This commit is contained in:
1 parent
987c1a3a53
commit
23153c8bf1
2 files changed
+55
-33
No files matched your search
@@ -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).
|
||||
|
||||
@@ -153,10 +153,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:
|
||||
@@ -198,8 +194,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; }
|
||||
|
||||
@@ -356,8 +350,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; }
|
||||
};
|
||||
@@ -377,8 +369,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; }
|
||||
|
||||
@@ -426,8 +416,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; }
|
||||
|
||||
@@ -464,8 +452,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; }
|
||||
|
||||
@@ -511,8 +497,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*/) { return false; }
|
||||
};
|
||||
@@ -525,8 +509,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;
|
||||
};
|
||||
@@ -539,8 +521,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;
|
||||
};
|
||||
@@ -565,8 +545,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*/) { }
|
||||
};
|
||||
@@ -600,8 +578,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; }
|
||||
};
|
||||
@@ -648,8 +624,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*/) { }
|
||||
|
||||
@@ -671,8 +645,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;
|
||||
};
|
||||
@@ -809,8 +781,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*/) { }
|
||||
|
||||
@@ -852,8 +822,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