diff options
| author | iThorgrim <125808072+iThorgrim@users.noreply.github.com> | 2025-02-17 03:26:05 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-17 03:26:05 +0100 |
| commit | e28384b059f8b266ebea1da771df56f5ff36a277 (patch) | |
| tree | 236857a295f34946a6950369a25698c6759534f3 /src/server/game/Scripting/ScriptDefines | |
| parent | 0c099a75ec709f30308b4b2a07c9befd450e9134 (diff) | |
feat(Core/Scripting): Add new hooks for Ticket (#21238)
Diffstat (limited to 'src/server/game/Scripting/ScriptDefines')
3 files changed, 109 insertions, 0 deletions
diff --git a/src/server/game/Scripting/ScriptDefines/AllScriptsObjects.h b/src/server/game/Scripting/ScriptDefines/AllScriptsObjects.h index aad81c0700..9196c32845 100644 --- a/src/server/game/Scripting/ScriptDefines/AllScriptsObjects.h +++ b/src/server/game/Scripting/ScriptDefines/AllScriptsObjects.h @@ -58,6 +58,7 @@ #include "PlayerScript.h" #include "ServerScript.h" #include "SpellScriptLoader.h" +#include "TicketScript.h" #include "TransportScript.h" #include "UnitScript.h" #include "VehicleScript.h" diff --git a/src/server/game/Scripting/ScriptDefines/TicketScript.cpp b/src/server/game/Scripting/ScriptDefines/TicketScript.cpp new file mode 100644 index 0000000000..a7e72076fd --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/TicketScript.cpp @@ -0,0 +1,58 @@ +/* + * This file is part of the AzerothCore Project. See AUTHORS file for Copyright information + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by the + * Free Software Foundation; either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "TicketScript.h" +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" + +void ScriptMgr::OnTicketCreate(GmTicket* ticket) +{ + CALL_ENABLED_HOOKS(TicketScript, TICKETHOOK_ON_TICKET_CREATE, script->OnTicketCreate(ticket)); +} + +void ScriptMgr::OnTicketUpdateLastChange(GmTicket* ticket) +{ + CALL_ENABLED_HOOKS(TicketScript, TICKETHOOK_ON_TICKET_UPDATE_LAST_CHANGE, script->OnTicketUpdateLastChange(ticket)); +} + +void ScriptMgr::OnTicketClose(GmTicket* ticket) +{ + CALL_ENABLED_HOOKS(TicketScript, TICKETHOOK_ON_TICKET_CLOSE, script->OnTicketClose(ticket)); +} + +void ScriptMgr::OnTicketStatusUpdate(GmTicket* ticket) +{ + CALL_ENABLED_HOOKS(TicketScript, TICKETHOOK_ON_TICKET_STATUS_UPDATE, script->OnTicketStatusUpdate(ticket)); +} + +void ScriptMgr::OnTicketResolve(GmTicket* ticket) +{ + CALL_ENABLED_HOOKS(TicketScript, TICKETHOOK_ON_TICKET_RESOLVE, script->OnTicketResolve(ticket)); +} + +TicketScript::TicketScript(char const* name, std::vector<uint16> enabledHooks) +: ScriptObject(name, TICKETHOOK_END) +{ + // If empty - enable all available hooks. + if (enabledHooks.empty()) + for (uint16 i = 0; i < TICKETHOOK_END; ++i) + enabledHooks.emplace_back(i); + + ScriptRegistry<TicketScript>::AddScript(this, std::move(enabledHooks)); +} + +template class AC_GAME_API ScriptRegistry<TicketScript>; diff --git a/src/server/game/Scripting/ScriptDefines/TicketScript.h b/src/server/game/Scripting/ScriptDefines/TicketScript.h new file mode 100644 index 0000000000..43bf616aed --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/TicketScript.h @@ -0,0 +1,50 @@ +/* + * This file is part of the AzerothCore Project. See AUTHORS file for Copyright information + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by the + * Free Software Foundation; either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef SCRIPT_OBJECT_TICKET_SCRIPT_H_ +#define SCRIPT_OBJECT_TICKET_SCRIPT_H_ + +#include "ScriptObject.h" +#include "TicketMgr.h" +#include <vector> + +enum TicketHook +{ + TICKETHOOK_ON_TICKET_CREATE, + TICKETHOOK_ON_TICKET_UPDATE_LAST_CHANGE, + TICKETHOOK_ON_TICKET_CLOSE, + TICKETHOOK_ON_TICKET_STATUS_UPDATE, + TICKETHOOK_ON_TICKET_RESOLVE, + TICKETHOOK_END +}; + +class TicketScript : public ScriptObject +{ +protected: + TicketScript(char const* name, std::vector<uint16> enabledHooks = std::vector<uint16>()); + +public: + [[nodiscard]] bool IsDatabaseBound() const override { return false; } + + virtual void OnTicketCreate(GmTicket* /*ticket*/) { } + virtual void OnTicketUpdateLastChange(GmTicket* /*ticket*/) { } + virtual void OnTicketClose(GmTicket* /*ticket*/) { } + virtual void OnTicketStatusUpdate(GmTicket* /*ticket*/) { } + virtual void OnTicketResolve(GmTicket* /*ticket*/) { } +}; + +#endif |
