--HG--
branch : trunk
This commit is contained in:
click
2010-08-09 23:17:02 +02:00
2 changed files with 4 additions and 16 deletions
+3 -2
View File
@@ -136,6 +136,7 @@ void DoScriptText(int32 iTextEntry, WorldObject* pSource, Unit* pTarget)
} }
ScriptMgr::ScriptMgr() ScriptMgr::ScriptMgr()
: _scriptCount(0)
{ {
} }
@@ -1106,7 +1107,7 @@ WorldMapScript::WorldMapScript(const char* name, uint32 mapId)
} }
InstanceMapScript::InstanceMapScript(const char* name, uint32 mapId) InstanceMapScript::InstanceMapScript(const char* name, uint32 mapId)
: ScriptObject(name), MapScript<InstanceMap>(0) : ScriptObject(name), MapScript<InstanceMap>(mapId)
{ {
if (GetEntry() && !GetEntry()->IsDungeon()) if (GetEntry() && !GetEntry()->IsDungeon())
sLog.outError("InstanceMapScript for map %u is invalid.", mapId); sLog.outError("InstanceMapScript for map %u is invalid.", mapId);
@@ -1209,7 +1210,7 @@ AchievementCriteriaScript::AchievementCriteriaScript(const char* name)
// Instantiate static members of ScriptMgr::ScriptRegistry. // Instantiate static members of ScriptMgr::ScriptRegistry.
template<class TScript> std::map<uint32, TScript*> ScriptMgr::ScriptRegistry<TScript>::ScriptPointerList; template<class TScript> std::map<uint32, TScript*> ScriptMgr::ScriptRegistry<TScript>::ScriptPointerList;
template<class TScript> uint32 ScriptMgr::ScriptRegistry<TScript>::_scriptIdCounter; template<class TScript> uint32 ScriptMgr::ScriptRegistry<TScript>::_scriptIdCounter = 0;
// Specialize for each script type class like so: // Specialize for each script type class like so:
template class ScriptMgr::ScriptRegistry<SpellHandlerScript>; template class ScriptMgr::ScriptRegistry<SpellHandlerScript>;
+1 -14
View File
@@ -145,13 +145,6 @@ class ScriptObject
public: public:
// Called when the script is initialized. Use it to initialize any properties of the script. Do not use
// the constructor for this.
virtual void OnInitialize() { }
// Called when the script is deleted. Use it to free memory, etc. Do not use the destructor for this.
virtual void OnTeardown() { }
// Do not override this in scripts; it should be overridden by the various script type classes. It indicates // 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. // whether or not this script type must be assigned in the database.
virtual bool IsDatabaseBound() const { return false; } virtual bool IsDatabaseBound() const { return false; }
@@ -163,14 +156,10 @@ class ScriptObject
ScriptObject(const char* name) ScriptObject(const char* name)
: _name(std::string(name)) : _name(std::string(name))
{ {
// Allow the script to do startup routines.
OnInitialize();
} }
virtual ~ScriptObject() virtual ~ScriptObject()
{ {
// Allow the script to do cleanup routines.
OnTeardown();
} }
private: private:
@@ -902,7 +891,7 @@ class ScriptMgr
sLog.outError("Script '%s' already assigned with the same script name, so the script can't work.", sLog.outError("Script '%s' already assigned with the same script name, so the script can't work.",
script->GetName().c_str()); script->GetName().c_str());
delete script; ASSERT(false); // Error that should be fixed ASAP.
} }
} }
else else
@@ -911,8 +900,6 @@ class ScriptMgr
if (script->GetName().find("example") == std::string::npos) if (script->GetName().find("example") == std::string::npos)
sLog.outErrorDb("Script named '%s' does not have a script name assigned in database.", sLog.outErrorDb("Script named '%s' does not have a script name assigned in database.",
script->GetName().c_str()); script->GetName().c_str());
delete script;
} }
} }
else else