Skip to content

Commit

Permalink
Scripts: Fix linux compilation of previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
killerwife committed Feb 19, 2023
1 parent 729a2bb commit 82eb575
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 28 deletions.
18 changes: 9 additions & 9 deletions src/game/DBScripts/ScriptMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ void ScriptMgr::LoadScriptMap(ScriptMapType scriptType, bool reload)
{
auto questEndScripts = GetScriptMap(scriptType);
// check ids
for (ScriptMapMap::const_iterator itr = questEndScripts->second.begin(); itr != questEndScripts->second.end(); ++itr)
for (auto itr = questEndScripts->second.begin(); itr != questEndScripts->second.end(); ++itr)
{
if (!sObjectMgr.GetQuestTemplate(itr->first))
sLog.outErrorDb("Table `dbscripts_on_quest_end` has not existing quest (Id: %u) as script id", itr->first);
Expand All @@ -963,7 +963,7 @@ void ScriptMgr::LoadScriptMap(ScriptMapType scriptType, bool reload)
{
auto questStartScripts = GetScriptMap(scriptType);
// check ids
for (ScriptMapMap::const_iterator itr = questStartScripts->second.begin(); itr != questStartScripts->second.end(); ++itr)
for (auto itr = questStartScripts->second.begin(); itr != questStartScripts->second.end(); ++itr)
{
if (!sObjectMgr.GetQuestTemplate(itr->first))
sLog.outErrorDb("Table `dbscripts_on_quest_start` has not existing quest (Id: %u) as script id", itr->first);
Expand All @@ -974,7 +974,7 @@ void ScriptMgr::LoadScriptMap(ScriptMapType scriptType, bool reload)
{
auto spellScripts = GetScriptMap(scriptType);
// check ids
for (ScriptMapMap::const_iterator itr = spellScripts->second.begin(); itr != spellScripts->second.end(); ++itr)
for (auto itr = spellScripts->second.begin(); itr != spellScripts->second.end(); ++itr)
{
SpellEntry const* spellInfo = sSpellTemplate.LookupEntry<SpellEntry>(itr->first);
if (!spellInfo)
Expand Down Expand Up @@ -1003,7 +1003,7 @@ void ScriptMgr::LoadScriptMap(ScriptMapType scriptType, bool reload)
{
auto goScripts = GetScriptMap(scriptType);
// check ids
for (ScriptMapMap::const_iterator itr = goScripts->second.begin(); itr != goScripts->second.end(); ++itr)
for (auto itr = goScripts->second.begin(); itr != goScripts->second.end(); ++itr)
{
if (!sObjectMgr.GetGOData(itr->first))
sLog.outErrorDb("Table `dbscripts_on_go_use` has not existing gameobject (GUID: %u) as script id", itr->first);
Expand All @@ -1014,7 +1014,7 @@ void ScriptMgr::LoadScriptMap(ScriptMapType scriptType, bool reload)
{
auto goTemplateScripts = GetScriptMap(scriptType);
// check ids
for (ScriptMapMap::const_iterator itr = goTemplateScripts->second.begin(); itr != goTemplateScripts->second.end(); ++itr)
for (auto itr = goTemplateScripts->second.begin(); itr != goTemplateScripts->second.end(); ++itr)
{
if (!sObjectMgr.GetGameObjectInfo(itr->first))
sLog.outErrorDb("Table `dbscripts_on_go_template_use` has not existing gameobject (Entry: %u) as script id", itr->first);
Expand All @@ -1029,7 +1029,7 @@ void ScriptMgr::LoadScriptMap(ScriptMapType scriptType, bool reload)
auto eventScripts = GetScriptMap(scriptType);

// Then check if all scripts are in above list of possible script entries
for (ScriptMapMap::const_iterator itr = eventScripts->second.begin(); itr != eventScripts->second.end(); ++itr)
for (auto itr = eventScripts->second.begin(); itr != eventScripts->second.end(); ++itr)
{
std::set<uint32>::const_iterator itr2 = eventIds.find(itr->first);
if (itr2 == eventIds.end())
Expand All @@ -1046,7 +1046,7 @@ void ScriptMgr::LoadScriptMap(ScriptMapType scriptType, bool reload)
{
// check ids
auto deathScripts = GetScriptMap(scriptType);
for (ScriptMapMap::const_iterator itr = deathScripts->second.begin(); itr != deathScripts->second.end(); ++itr)
for (auto itr = deathScripts->second.begin(); itr != deathScripts->second.end(); ++itr)
{
if (!sObjectMgr.GetCreatureTemplate(itr->first))
sLog.outErrorDb("Table `dbscripts_on_creature_death` has not existing creature (Entry: %u) as script id", itr->first);
Expand All @@ -1061,7 +1061,7 @@ void ScriptMgr::LoadScriptMap(ScriptMapType scriptType, bool reload)
{
// check ids
auto relayScripts = GetScriptMap(scriptType);
for (ScriptMapMap::const_iterator itr = relayScripts->second.begin(); itr != relayScripts->second.end(); ++itr)
for (auto itr = relayScripts->second.begin(); itr != relayScripts->second.end(); ++itr)
{
for (auto& data : itr->second) // need to check after load is complete, because of nesting
{
Expand Down Expand Up @@ -1167,7 +1167,7 @@ void ScriptMgr::CheckRandomRelayTemplates()
void ScriptMgr::CheckScriptTexts(ScriptMapType scriptType)
{
ScriptMapMapName const& scripts = *GetScriptMap(scriptType).get();
for (ScriptMapMap::const_iterator itrMM = scripts.second.begin(); itrMM != scripts.second.end(); ++itrMM)
for (auto itrMM = scripts.second.begin(); itrMM != scripts.second.end(); ++itrMM)
{
for (ScriptMap::const_iterator itrM = itrMM->second.begin(); itrM != itrMM->second.end(); ++itrM)
{
Expand Down
19 changes: 2 additions & 17 deletions src/game/DBScripts/ScriptMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
#include "Common.h"
#include "Entities/ObjectGuid.h"
#include "Server/DBCEnums.h"
#include "DBScripts/ScriptMgrDefines.h"

#include <atomic>
#include <memory>

class Map;
class Object;
Expand Down Expand Up @@ -584,22 +585,6 @@ struct ScriptInfo
}
};

enum ScriptMapType
{
SCRIPT_TYPE_QUEST_END = 0,
SCRIPT_TYPE_QUEST_START = 1,
SCRIPT_TYPE_SPELL = 2,
SCRIPT_TYPE_GAMEOBJECT = 3,
SCRIPT_TYPE_GAMEOBJECT_TEMPLATE = 4,
SCRIPT_TYPE_EVENT = 5,
SCRIPT_TYPE_GOSSIP = 6,
SCRIPT_TYPE_CREATURE_DEATH = 7,
SCRIPT_TYPE_CREATURE_MOVEMENT = 8,
SCRIPT_TYPE_RELAY = 9,
SCRIPT_TYPE_INTERNAL = 10, // must be last
SCRIPT_TYPE_MAX
};

class ScriptAction
{
public:
Expand Down
38 changes: 38 additions & 0 deletions src/game/DBScripts/ScriptMgrDefines.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* This file is part of the CMaNGOS 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 General Public License as published by
* the Free Software Foundation; either version 2 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#ifndef _SCRIPTMGRDEF_H
#define _SCRIPTMGRDEF_H

enum ScriptMapType
{
SCRIPT_TYPE_QUEST_END = 0,
SCRIPT_TYPE_QUEST_START = 1,
SCRIPT_TYPE_SPELL = 2,
SCRIPT_TYPE_GAMEOBJECT = 3,
SCRIPT_TYPE_GAMEOBJECT_TEMPLATE = 4,
SCRIPT_TYPE_EVENT = 5,
SCRIPT_TYPE_GOSSIP = 6,
SCRIPT_TYPE_CREATURE_DEATH = 7,
SCRIPT_TYPE_CREATURE_MOVEMENT = 8,
SCRIPT_TYPE_RELAY = 9,
SCRIPT_TYPE_INTERNAL = 10, // must be last
SCRIPT_TYPE_MAX
};

#endif
2 changes: 1 addition & 1 deletion src/game/Globals/ObjectMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9725,7 +9725,7 @@ void ObjectMgr::LoadGossipMenus()
auto gossipScripts = sScriptMgr.GetScriptMap(SCRIPT_TYPE_GOSSIP);
// Check which script-ids in dbscripts_on_gossip are not used
std::set<uint32> gossipScriptSet;
for (ScriptMapMap::const_iterator itr = gossipScripts->second.begin(); itr != gossipScripts->second.end(); ++itr)
for (auto itr = gossipScripts->second.begin(); itr != gossipScripts->second.end(); ++itr)
gossipScriptSet.insert(itr->first);

// Load gossip_menu and gossip_menu_option data
Expand Down
1 change: 1 addition & 0 deletions src/game/Maps/MapDataContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "Globals/ObjectMgr.h"
#include "AI/EventAI/CreatureEventAI.h"
#include "AI/EventAI/CreatureEventAIMgr.h"
#include "DBScripts/ScriptMgr.h"

MapDataContainer::MapDataContainer() : m_spellListContainer(sObjectMgr.GetCreatureSpellListContainer()),
m_spawnGroupContainer(sObjectMgr.GetSpawnGroupContainer()), m_CreatureEventAIEventEntryMap(sEventAIMgr.GetCreatureEventEntryAIMap()),
Expand Down
7 changes: 7 additions & 0 deletions src/game/Maps/MapDataContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define MAP_DATA_CONTAINER_H

#include "Platform/Define.h"
#include "DBScripts/ScriptMgrDefines.h"
#include <memory>
#include <vector>
#include <unordered_map>
Expand All @@ -30,12 +31,18 @@ struct SpawnGroupEntry;
struct SpawnGroupEntryContainer;
struct CreatureEventAI_Event;
struct CreatureEventAI_EventComputedData;
struct ScriptInfo;

// Event_Map
typedef std::vector<CreatureEventAI_Event> CreatureEventAI_Event_Vec;
typedef std::unordered_map<uint32, CreatureEventAI_Event_Vec> CreatureEventAI_Event_Map;
typedef std::unordered_map<uint32, CreatureEventAI_EventComputedData> CreatureEventAI_EventComputedData_Map;

// Scripts
typedef std::multimap < uint32 /*delay*/, std::shared_ptr<ScriptInfo>> ScriptMap;
typedef std::map < uint32 /*id*/, ScriptMap > ScriptMapMap;
typedef std::pair<const char*, ScriptMapMap> ScriptMapMapName;

class MapDataContainer
{
public:
Expand Down
2 changes: 1 addition & 1 deletion src/game/MotionGenerators/WaypointManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void WaypointManager::Load()
std::set<uint32> movementScriptSet;

auto creatureMovementScripts = sScriptMgr.GetScriptMap(SCRIPT_TYPE_CREATURE_MOVEMENT);
for (ScriptMapMap::const_iterator itr = creatureMovementScripts->second.begin(); itr != creatureMovementScripts->second.end(); ++itr)
for (auto itr = creatureMovementScripts->second.begin(); itr != creatureMovementScripts->second.end(); ++itr)
movementScriptSet.insert(itr->first);

// /////////////////////////////////////////////////////
Expand Down

0 comments on commit 82eb575

Please sign in to comment.