feat(Core/Modules): Preparation to implement progression-system module. (#8837)

This commit is contained in:
UltraNix
2021-11-06 14:06:12 +01:00
committed by GitHub
parent 93bbff4cca
commit 70d8b88f3b
13 changed files with 253 additions and 97 deletions

View File

@@ -1453,7 +1453,20 @@ public:
bool IsDatabaseBound() const { return false; }
virtual void OnHandleDevCommand(Player* /*player*/, std::string& /*argstr*/) { }
virtual void OnHandleDevCommand(Player* /*player*/, std::string& /*argstr*/) { }
};
class DatabaseScript : public ScriptObject
{
protected:
DatabaseScript(const char* name);
public:
bool IsDatabaseBound() const { return false; }
virtual void OnAfterDatabasesLoaded(uint32 /*updateFlags*/) {}
};
// Manages registration, loading, and execution of scripts.
@@ -1938,6 +1951,10 @@ public: /* AchievementScript */
void OnHandleDevCommand(Player* player, std::string& argstr);
public: /* DatabaseScript */
void OnAfterDatabasesLoaded(uint32 updateFlags);
private:
uint32 _scriptCount;
@@ -2007,31 +2024,31 @@ public:
if (id)
{
// Try to find an existing script.
bool existing = false;
TScript const* oldScript = nullptr;
for (auto iterator = ScriptPointerList.begin(); iterator != ScriptPointerList.end(); ++iterator)
{
// If the script names match...
if (iterator->second->GetName() == script->GetName())
{
// ... It exists.
existing = true;
oldScript = iterator->second;
break;
}
}
// If the script isn't assigned -> assign it!
if (!existing)
// If the script is already assigned -> delete it!
if (oldScript)
{
ScriptPointerList[id] = script;
sScriptMgr->IncrementScriptCount();
delete oldScript;
}
else
{
// If the script is already assigned -> delete it!
LOG_ERROR("scripts", "Script named '%s' is already assigned (two or more scripts have the same name), so the script can't work, aborting...",
script->GetName().c_str());
ABORT(); // Error that should be fixed ASAP.
// Assign new script!
ScriptPointerList[id] = script;
// Increment script count only with new scripts
if (!oldScript)
{
sScriptMgr->IncrementScriptCount();
}
}
else