Files
azerothcore-wotlk/src/server/scripts/EasternKingdoms/Stratholme/stratholme.h
Hanabi a6a2ca8ef7 feat(Core/GameObjects): Instance gameobject save data implementation (#11113)
* fix(Core): Save gameobject state on instances

Currently, azerothcore doesn't save gameobject states on instances.
Whenever there's a re-start or crash, the instance's gameobjects and
their states aren't saved, producing un-wanted behaviours and blocking instances at times.

Implemented CRUD for new table `instance_saved_data` that holds the states of gameobjects.

- When worldserver launches and gameobjects are loaded, this will check
  if this object's state exists on the DB and sets the previous state.
- On instance deletion (reset) these states are also removed based on
  the instance ID.
- Whenever a gameobject state changes inside a dungeon or raid, we save
  on the database the set state.

* Select query to synchronous and used FindMap()

* loading gameobject states on create

* reseting instance saved data

* missing reset methods and on create state

* database structure

* Update src/server/game/Entities/GameObject/GameObject.cpp

Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>

* Update src/server/game/Entities/GameObject/GameObject.cpp

Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>

* Update src/server/game/Entities/GameObject/GameObject.cpp

Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>

* Update src/server/game/Entities/GameObject/GameObject.cpp

Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>

* Update src/server/game/Entities/Player/PlayerMisc.cpp

Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>

* Update src/server/game/Groups/Group.cpp

Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>

* codestyle

* table changes

* table style

* codestyle

* table changes for columns

* data sanitization

* todo:

- Finish loading db data into the containers
- Using containers to find data
- How to get data from ObjectMGR inside Gameobject?

* loading on start up and db changes

* Removing unused data structure

* Uninitialised integer

* Whitespace

* clean-up and hooks to save states on memory

* Codestyle MySQL deprecated backticks

* i dont understand codefactor

* build

* Update data/sql/updates/pending_db_world/rev_1643395587559675400.sql

Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>

* Update src/server/game/Globals/ObjectMgr.h

Co-authored-by: Kargatum <dowlandtop@yandex.com>

* review changes

* unecessary removal

* pushback instead of emplace

* wrong database update

* Update ObjectMgr.cpp

* missing check

* removing entry from the PR

* missing removals

* last delete

* build

* aha! Found the culprit for the sudden assert errors

* type safety, save only important gameobjects

* static cast to unsigned short

* Update data/sql/updates/pending_db_characters/rev_1643629468629316100.sql

Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>

* type changes

* queries fix

* fix build

* enabling which gameobjects to save on the database

* deadmines iron clad door

* Adjustment to gameobject onj create state and instances:

- Gnomeregan doors and Grubbis boss state
- Deadmines missing doors
- Stratholme gameobjects state saved

* forgot emi blastfuse change to despawn

* Leaving group logic

* codestyle

* fixing merge issues

* prevent bad behaviour

* brain meltdown

* Update data/sql/updates/pending_db_characters/rev_1643629468629316100.sql

* Update data/sql/updates/pending_db_world/rev_1649359139539727000.sql

Co-authored-by: Claudiodfc <54484196+claudiodfc@users.noreply.github.com>
Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>
Co-authored-by: Kargatum <dowlandtop@yandex.com>
Co-authored-by: Skjalf <47818697+Nyeriah@users.noreply.github.com>
2022-05-24 10:33:45 -03:00

116 lines
4.3 KiB
C++

/*
* 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 DEF_STRATHOLME_H
#define DEF_STRATHOLME_H
#include "SpellAuras.h"
#define StratholmeScriptName "instance_stratholme"
enum DataTypes
{
TYPE_BARON_RUN = 0,
TYPE_ZIGGURAT1 = 1,
TYPE_ZIGGURAT2 = 2,
TYPE_ZIGGURAT3 = 3,
TYPE_BARON_FIGHT = 4,
TYPE_MALLOW = 5,
DATA_BARON_RUN_NONE = 0,
DATA_BARON_RUN_GATE = 1,
DATA_JARIEN = 2,
DATA_SOTHOS = 3
};
enum CreatureIds
{
NPC_BARON_RIVENDARE = 10440,
NPC_BILE_SPEWER = 10416,
NPC_VENOM_BELCHER = 10417,
NPC_RAMSTEIN_THE_GORGER = 10439,
NPC_MINDLESS_UNDEAD = 11030,
NPC_BLACK_GUARD = 10394,
NPC_YSIDA = 16031,
NPC_PLAGUED_RAT = 10441,
NPC_PLAGUED_INSECT = 10461,
NPC_PLAGUED_MAGGOT = 10536,
NPC_JARIEN = 16101,
NPC_SOTHOS = 16102,
NPC_SPIRIT_OF_JARIEN = 16103,
NPC_SPIRIT_OF_SOTHOS = 16104
};
enum GameobjectIds
{
GO_CRUSADER_SQUARE_DOOR = 175967,
GO_HOARD_DOOR = 175968,
GO_HALL_OF_HIGH_COMMAND = 176194,
GO_GAUNTLET_DOOR_1 = 175357,
GO_GAUNTLET_DOOR_2 = 175356,
GO_ZIGGURAT_DOORS1 = 175380, // baroness
GO_ZIGGURAT_DOORS2 = 175379, // nerub'enkan
GO_ZIGGURAT_DOORS3 = 175381, // maleki
GO_ZIGGURAT_DOORS4 = 175405, // rammstein
GO_ZIGGURAT_DOORS5 = 175796, // baron
GO_GAUNTLET_GATE = 175374,
GO_SLAUGTHER_GATE = 175373,
GO_SLAUGHTER_GATE_SIDE = 175358,
GO_EXIT_GATE = 176424,
GO_PORT_TRAP_GATE_1 = 175351, // Portcullis used in the gate traps (rats trap)
GO_PORT_TRAP_GATE_2 = 175350, // Gate trap scarlet side
GO_PORT_TRAP_GATE_3 = 175355, // Gate trap undead side
GO_PORT_TRAP_GATE_4 = 175354,
GO_JARIEN_AND_SOTHOS_HEIRLOOMS = 181083
};
enum MiscIds
{
SAY_BLACK_GUARD_INIT = 0,
SAY_BARON_INIT_YELL = 0,
SAY_BRAON_ZIGGURAT_FALL_YELL = 1,
SAY_BARON_10M = 2,
SAY_BARON_5M = 3,
SAY_BARON_0M = 4,
SAY_BRAON_SUMMON_RAMSTEIN = 5,
SAY_BARON_GUARD_DEAD = 6,
EVENT_BARON_TIME = 1,
EVENT_SPAWN_MINDLESS = 2,
EVENT_FORCE_SLAUGHTER_EVENT = 3,
EVENT_SPAWN_BLACK_GUARD = 4,
EVENT_EXECUTE_PRISONER = 5,
EVENT_GATE1_TRAP = 6,
EVENT_GATE1_DELAY = 7,
EVENT_GATE1_CRITTER_DELAY = 8,
EVENT_GATE2_TRAP = 9,
EVENT_GATE2_DELAY = 10,
EVENT_GATE2_CRITTER_DELAY = 11,
SPELL_BARON_ULTIMATUM = 27861
};
template <class AI, class T>
inline AI* GetStratholmeAI(T* obj)
{
return GetInstanceAI<AI>(obj, StratholmeScriptName);
}
#define RegisterStratholmeCreatureAI(ai_name) RegisterCreatureAIWithFactory(ai_name, GetStratholmeAI)
#endif