TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
GameEventMgr Class Reference

#include <GameEventMgr.h>

Public Types

typedef std::set< uint16ActiveEvents
 
typedef std::vector
< GameEventData
GameEventDataMap
 

Public Member Functions

ActiveEvents constGetActiveEventList () const
 
GameEventDataMap constGetEventMap () const
 
bool CheckOneGameEvent (uint16 entry) const
 
uint32 NextCheck (uint16 entry) const
 
void LoadFromDB ()
 
uint32 Update ()
 
bool IsActiveEvent (uint16 event_id)
 
uint32 StartSystem ()
 
void Initialize ()
 
void StartArenaSeason ()
 
void StartInternalEvent (uint16 event_id)
 
bool StartEvent (uint16 event_id, bool overwrite=false)
 
void StopEvent (uint16 event_id, bool overwrite=false)
 
void HandleQuestComplete (uint32 quest_id)
 
void HandleWorldEventGossip (Player *player, Creature *c)
 
uint64 GetNPCFlag (Creature *cr)
 
uint32 GetNpcTextId (uint32 guid)
 
uint16 GetEventIdForQuest (Quest const *quest) const
 

Static Public Member Functions

static GameEventMgrinstance ()
 

Public Attributes

GameEventGuidMap mGameEventCreatureGuids
 
GameEventGuidMap mGameEventGameobjectGuids
 

Private Types

typedef std::list
< ObjectGuid::LowType
GuidList
 
typedef std::list< uint32IdList
 
typedef std::vector< GuidListGameEventGuidMap
 
typedef std::vector< IdListGameEventIdMap
 
typedef std::pair
< ObjectGuid::LowType,
ModelEquip
ModelEquipPair
 
typedef std::list< ModelEquipPairModelEquipList
 
typedef std::vector
< ModelEquipList
GameEventModelEquipMap
 
typedef std::pair< uint32, uint32QuestRelation
 
typedef std::list< QuestRelationQuestRelList
 
typedef std::vector< QuestRelListGameEventQuestMap
 
typedef std::list< NPCVendorEntryNPCVendorList
 
typedef std::vector
< NPCVendorList
GameEventNPCVendorMap
 
typedef std::map< uint32,
GameEventQuestToEventConditionNum
QuestIdToEventConditionMap
 
typedef std::pair
< ObjectGuid::LowType, uint64
GuidNPCFlagPair
 
typedef std::list
< GuidNPCFlagPair
NPCFlagList
 
typedef std::vector< NPCFlagListGameEventNPCFlagMap
 
typedef std::vector< uint32GameEventBitmask
 

Private Member Functions

 GameEventMgr ()
 
 ~GameEventMgr ()
 
void SendWorldStateUpdate (Player *player, uint16 event_id)
 
void AddActiveEvent (uint16 event_id)
 
void RemoveActiveEvent (uint16 event_id)
 
void ApplyNewEvent (uint16 event_id)
 
void UnApplyEvent (uint16 event_id)
 
void GameEventSpawn (int16 event_id)
 
void GameEventUnspawn (int16 event_id)
 
void ChangeEquipOrModel (int16 event_id, bool activate)
 
void UpdateEventQuests (uint16 event_id, bool activate)
 
void UpdateWorldStates (uint16 event_id, bool Activate)
 
void UpdateEventNPCFlags (uint16 event_id)
 
void UpdateEventNPCVendor (uint16 event_id, bool activate)
 
void UpdateBattlegroundSettings ()
 
void RunSmartAIScripts (uint16 event_id, bool activate)
 
bool CheckOneGameEventConditions (uint16 event_id)
 Runs SMART_EVENT_GAME_EVENT_START/_END SAI. More...
 
void SaveWorldEventStateToDB (uint16 event_id)
 
bool hasCreatureQuestActiveEventExcept (uint32 quest_id, uint16 event_id)
 
bool hasGameObjectQuestActiveEventExcept (uint32 quest_id, uint16 event_id)
 
bool hasCreatureActiveEventExcept (ObjectGuid::LowType creature_guid, uint16 event_id)
 
bool hasGameObjectActiveEventExcept (ObjectGuid::LowType go_guid, uint16 event_id)
 

Private Attributes

GameEventQuestMap mGameEventCreatureQuests
 
GameEventQuestMap mGameEventGameObjectQuests
 
GameEventNPCVendorMap mGameEventVendors
 
GameEventModelEquipMap mGameEventModelEquip
 
GameEventIdMap mGameEventPoolIds
 
GameEventDataMap mGameEvent
 
GameEventBitmask mGameEventBattlegroundHolidays
 
QuestIdToEventConditionMap mQuestToEventConditions
 
GameEventNPCFlagMap mGameEventNPCFlags
 
ActiveEvents m_ActiveEvents
 
std::unordered_map< uint32,
uint16
_questToEventLinks
 
bool isSystemInit
 

Member Typedef Documentation

typedef std::vector<uint32> GameEventMgr::GameEventBitmask
private
typedef std::vector<GuidList> GameEventMgr::GameEventGuidMap
private
typedef std::vector<IdList> GameEventMgr::GameEventIdMap
private
typedef std::vector<NPCFlagList> GameEventMgr::GameEventNPCFlagMap
private
typedef std::vector<NPCVendorList> GameEventMgr::GameEventNPCVendorMap
private
typedef std::vector<QuestRelList> GameEventMgr::GameEventQuestMap
private
typedef std::list<ObjectGuid::LowType> GameEventMgr::GuidList
private
typedef std::list<uint32> GameEventMgr::IdList
private
typedef std::list<ModelEquipPair> GameEventMgr::ModelEquipList
private
typedef std::list<GuidNPCFlagPair> GameEventMgr::NPCFlagList
private
typedef std::list<NPCVendorEntry> GameEventMgr::NPCVendorList
private
typedef std::pair<uint32, uint32> GameEventMgr::QuestRelation
private
typedef std::list<QuestRelation> GameEventMgr::QuestRelList
private

Constructor & Destructor Documentation

GameEventMgr::GameEventMgr ( )
private
1520 : isSystemInit(false) { }
bool isSystemInit
Definition: GameEventMgr.h:178
GameEventMgr::~GameEventMgr ( )
inlineprivate
101 { }

Member Function Documentation

void GameEventMgr::AddActiveEvent ( uint16  event_id)
inlineprivate
128 { m_ActiveEvents.insert(event_id); }
ActiveEvents m_ActiveEvents
Definition: GameEventMgr.h:176

+ Here is the caller graph for this function:

void GameEventMgr::ApplyNewEvent ( uint16  event_id)
private

Run SAI scripts with SMART_EVENT_GAME_EVENT_END

1093 {
1094  uint8 announce = mGameEvent[event_id].announce;
1095  if (announce == 1 || (announce == 2 && sWorld->getBoolConfig(CONFIG_EVENT_ANNOUNCE)))
1096  sWorld->SendWorldText(LANG_EVENTMESSAGE, mGameEvent[event_id].description.c_str());
1097 
1098  TC_LOG_INFO("gameevent", "GameEvent %u \"%s\" started.", event_id, mGameEvent[event_id].description.c_str());
1099 
1101  RunSmartAIScripts(event_id, true);
1102 
1103  // spawn positive event tagget objects
1104  GameEventSpawn(event_id);
1105  // un-spawn negative event tagged objects
1106  int16 event_nid = (-1) * event_id;
1107  GameEventUnspawn(event_nid);
1108  // Change equipement or model
1109  ChangeEquipOrModel(event_id, true);
1110  // Add quests that are events only to non event npc
1111  UpdateEventQuests(event_id, true);
1112  UpdateWorldStates(event_id, true);
1113  // update npcflags in this event
1114  UpdateEventNPCFlags(event_id);
1115  // add vendor items
1116  UpdateEventNPCVendor(event_id, true);
1117  // update bg holiday
1119  // check for seasonal quest reset.
1120  sWorld->ResetEventSeasonalQuests(event_id);
1121 }
GameEventDataMap mGameEvent
Definition: GameEventMgr.h:172
void UpdateEventNPCVendor(uint16 event_id, bool activate)
Definition: GameEventMgr.cpp:1164
void GameEventUnspawn(int16 event_id)
Definition: GameEventMgr.cpp:1250
void UpdateWorldStates(uint16 event_id, bool Activate)
Definition: GameEventMgr.cpp:1499
#define sWorld
Definition: World.h:887
void RunSmartAIScripts(uint16 event_id, bool activate)
Definition: GameEventMgr.cpp:1649
Definition: World.h:170
Definition: Language.h:37
void ChangeEquipOrModel(int16 event_id, bool activate)
Definition: GameEventMgr.cpp:1326
void GameEventSpawn(int16 event_id)
Definition: GameEventMgr.cpp:1175
void UpdateEventQuests(uint16 event_id, bool activate)
Definition: GameEventMgr.cpp:1444
uint8_t uint8
Definition: Define.h:152
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
void UpdateBattlegroundSettings()
Definition: GameEventMgr.cpp:1156
int16_t int16
Definition: Define.h:147
void UpdateEventNPCFlags(uint16 event_id)
Definition: GameEventMgr.cpp:1123

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameEventMgr::ChangeEquipOrModel ( int16  event_id,
bool  activate 
)
private
1327 {
1328  for (ModelEquipList::iterator itr = mGameEventModelEquip[event_id].begin(); itr != mGameEventModelEquip[event_id].end(); ++itr)
1329  {
1330  // Remove the creature from grid
1331  CreatureData const* data = sObjectMgr->GetCreatureData(itr->first);
1332  if (!data)
1333  continue;
1334 
1335  // Update if spawned
1336  sMapMgr->DoForAllMapsWithMapId(data->mapid, [&itr, activate](Map* map)
1337  {
1338  auto creatureBounds = map->GetCreatureBySpawnIdStore().equal_range(itr->first);
1339  for (auto itr2 = creatureBounds.first; itr2 != creatureBounds.second; ++itr2)
1340  {
1341  Creature* creature = itr2->second;
1342  if (activate)
1343  {
1344  itr->second.equipement_id_prev = creature->GetCurrentEquipmentId();
1345  itr->second.modelid_prev = creature->GetDisplayId();
1346  creature->LoadEquipment(itr->second.equipment_id, true);
1347  if (itr->second.modelid > 0 && itr->second.modelid_prev != itr->second.modelid &&
1348  sObjectMgr->GetCreatureModelInfo(itr->second.modelid))
1349  {
1350  creature->SetDisplayId(itr->second.modelid);
1351  creature->SetNativeDisplayId(itr->second.modelid);
1352  }
1353  }
1354  else
1355  {
1356  creature->LoadEquipment(itr->second.equipement_id_prev, true);
1357  if (itr->second.modelid_prev > 0 && itr->second.modelid_prev != itr->second.modelid &&
1358  sObjectMgr->GetCreatureModelInfo(itr->second.modelid_prev))
1359  {
1360  creature->SetDisplayId(itr->second.modelid_prev);
1361  creature->SetNativeDisplayId(itr->second.modelid_prev);
1362  }
1363  }
1364  }
1365  });
1366 
1367  // now last step: put in data
1368  CreatureData& data2 = sObjectMgr->NewOrExistCreatureData(itr->first);
1369  if (activate)
1370  {
1371  itr->second.modelid_prev = data2.displayid;
1372  itr->second.equipement_id_prev = data2.equipmentId;
1373  data2.displayid = itr->second.modelid;
1374  data2.equipmentId = itr->second.equipment_id;
1375  }
1376  else
1377  {
1378  data2.displayid = itr->second.modelid_prev;
1379  data2.equipmentId = itr->second.equipement_id_prev;
1380  }
1381  }
1382 }
Definition: Creature.h:287
uint32 displayid
Definition: Creature.h:296
#define sObjectMgr
Definition: ObjectMgr.h:1567
int8 equipmentId
Definition: Creature.h:297
Definition: Map.h:259
#define sMapMgr
Definition: MapManager.h:194
uint16 mapid
Definition: Creature.h:294
GameEventModelEquipMap mGameEventModelEquip
Definition: GameEventMgr.h:168

+ Here is the caller graph for this function:

bool GameEventMgr::CheckOneGameEvent ( uint16  entry) const
39 {
40  switch (mGameEvent[entry].state)
41  {
42  default:
43  case GAMEEVENT_NORMAL:
44  {
45  time_t currenttime = time(NULL);
46  // Get the event information
47  return mGameEvent[entry].start < currenttime
48  && currenttime < mGameEvent[entry].end
49  && (currenttime - mGameEvent[entry].start) % (mGameEvent[entry].occurence * MINUTE) < mGameEvent[entry].length * MINUTE;
50  }
51  // if the state is conditions or nextphase, then the event should be active
54  return true;
55  // finished world events are inactive
57  case GAMEEVENT_INTERNAL:
58  return false;
59  // if inactive world event, check the prerequisite events
61  {
62  time_t currenttime = time(NULL);
63  for (std::set<uint16>::const_iterator itr = mGameEvent[entry].prerequisite_events.begin(); itr != mGameEvent[entry].prerequisite_events.end(); ++itr)
64  {
65  if ((mGameEvent[*itr].state != GAMEEVENT_WORLD_NEXTPHASE && mGameEvent[*itr].state != GAMEEVENT_WORLD_FINISHED) || // if prereq not in nextphase or finished state, then can't start this one
66  mGameEvent[*itr].nextstart > currenttime) // if not in nextphase state for long enough, can't start this one
67  return false;
68  }
69  // all prerequisite events are met
70  // but if there are no prerequisites, this can be only activated through gm command
71  return !(mGameEvent[entry].prerequisite_events.empty());
72  }
73  }
74 }
Definition: GameEventMgr.h:36
GameEventDataMap mGameEvent
Definition: GameEventMgr.h:172
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: GameEventMgr.h:33
Definition: Common.h:97
Definition: GameEventMgr.h:35
Definition: GameEventMgr.h:31
Definition: GameEventMgr.h:34
Definition: GameEventMgr.h:32

+ Here is the caller graph for this function:

bool GameEventMgr::CheckOneGameEventConditions ( uint16  event_id)
private

Runs SMART_EVENT_GAME_EVENT_START/_END SAI.

1578 {
1579  for (GameEventConditionMap::const_iterator itr = mGameEvent[event_id].conditions.begin(); itr != mGameEvent[event_id].conditions.end(); ++itr)
1580  if (itr->second.done < itr->second.reqNum)
1581  // return false if a condition doesn't match
1582  return false;
1583  // set the phase
1584  mGameEvent[event_id].state = GAMEEVENT_WORLD_NEXTPHASE;
1585  // set the followup events' start time
1586  if (!mGameEvent[event_id].nextstart)
1587  {
1588  time_t currenttime = time(NULL);
1589  mGameEvent[event_id].nextstart = currenttime + mGameEvent[event_id].length * 60;
1590  }
1591  return true;
1592 }
GameEventDataMap mGameEvent
Definition: GameEventMgr.h:172
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: GameEventMgr.h:34

+ Here is the caller graph for this function:

void GameEventMgr::GameEventSpawn ( int16  event_id)
private
Todo:
find out when it is add to map
1176 {
1177  int32 internal_event_id = mGameEvent.size() + event_id - 1;
1178 
1179  if (internal_event_id < 0 || internal_event_id >= int32(mGameEventCreatureGuids.size()))
1180  {
1181  TC_LOG_ERROR("gameevent", "GameEventMgr::GameEventSpawn attempt access to out of range mGameEventCreatureGuids element %i (size: %zu)",
1182  internal_event_id, mGameEventCreatureGuids.size());
1183  return;
1184  }
1185 
1186  for (GuidList::iterator itr = mGameEventCreatureGuids[internal_event_id].begin(); itr != mGameEventCreatureGuids[internal_event_id].end(); ++itr)
1187  {
1188  // Add to correct cell
1189  if (CreatureData const* data = sObjectMgr->GetCreatureData(*itr))
1190  {
1191  sObjectMgr->AddCreatureToGrid(*itr, data);
1192 
1193  // Spawn if necessary (loaded grids only)
1194  Map* map = sMapMgr->CreateBaseMap(data->mapid);
1195  // We use spawn coords to spawn
1196  if (!map->Instanceable() && map->IsGridLoaded(data->posX, data->posY))
1197  {
1198  Creature* creature = new Creature();
1199  //TC_LOG_DEBUG("misc", "Spawning creature %u", *itr);
1200  if (!creature->LoadCreatureFromDB(*itr, map))
1201  delete creature;
1202  }
1203  }
1204  }
1205 
1206  if (internal_event_id < 0 || internal_event_id >= int32(mGameEventGameobjectGuids.size()))
1207  {
1208  TC_LOG_ERROR("gameevent", "GameEventMgr::GameEventSpawn attempt access to out of range mGameEventGameobjectGuids element %i (size: %zu)",
1209  internal_event_id, mGameEventGameobjectGuids.size());
1210  return;
1211  }
1212 
1213  for (GuidList::iterator itr = mGameEventGameobjectGuids[internal_event_id].begin(); itr != mGameEventGameobjectGuids[internal_event_id].end(); ++itr)
1214  {
1215  // Add to correct cell
1216  if (GameObjectData const* data = sObjectMgr->GetGOData(*itr))
1217  {
1218  sObjectMgr->AddGameobjectToGrid(*itr, data);
1219  // Spawn if necessary (loaded grids only)
1220  // this base map checked as non-instanced and then only existed
1221  Map* map = sMapMgr->CreateBaseMap(data->mapid);
1222  // We use current coords to unspawn, not spawn coords since creature can have changed grid
1223  if (!map->Instanceable() && map->IsGridLoaded(data->posX, data->posY))
1224  {
1225  GameObject* pGameobject = new GameObject;
1226  //TC_LOG_DEBUG("misc", "Spawning gameobject %u", *itr);
1228  if (!pGameobject->LoadGameObjectFromDB(*itr, map, false))
1229  delete pGameobject;
1230  else
1231  {
1232  if (pGameobject->isSpawnedByDefault())
1233  map->AddToMap(pGameobject);
1234  }
1235  }
1236  }
1237  }
1238 
1239  if (internal_event_id < 0 || internal_event_id >= int32(mGameEventPoolIds.size()))
1240  {
1241  TC_LOG_ERROR("gameevent", "GameEventMgr::GameEventSpawn attempt access to out of range mGameEventPoolIds element %u (size: %zu)",
1242  internal_event_id, mGameEventPoolIds.size());
1243  return;
1244  }
1245 
1246  for (IdList::iterator itr = mGameEventPoolIds[internal_event_id].begin(); itr != mGameEventPoolIds[internal_event_id].end(); ++itr)
1247  sPoolMgr->SpawnPool(*itr);
1248 }
Definition: Creature.h:287
GameEventIdMap mGameEventPoolIds
Definition: GameEventMgr.h:171
GameEventDataMap mGameEvent
Definition: GameEventMgr.h:172
GameEventGuidMap mGameEventCreatureGuids
Definition: GameEventMgr.h:180
GameEventGuidMap mGameEventGameobjectGuids
Definition: GameEventMgr.h:181
Definition: Creature.h:467
bool IsGridLoaded(float x, float y) const
Definition: Map.h:308
#define sObjectMgr
Definition: ObjectMgr.h:1567
#define sPoolMgr
Definition: PoolMgr.h:166
bool AddToMap(T *)
Definition: Map.cpp:566
int32_t int32
Definition: Define.h:146
bool LoadGameObjectFromDB(ObjectGuid::LowType spawnId, Map *map, bool addToMap=true)
Definition: GameObject.cpp:858
Definition: GameObject.h:880
Definition: Map.h:259
Definition: GameObject.h:833
#define sMapMgr
Definition: MapManager.h:194
int32_t int32
Definition: g3dmath.h:167
bool Instanceable() const
Definition: Map.h:394
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
bool isSpawnedByDefault() const
Definition: GameObject.h:957
bool LoadCreatureFromDB(ObjectGuid::LowType spawnId, Map *map, bool addToMap=true, bool allowDuplicate=false)
Definition: Creature.cpp:1327

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameEventMgr::GameEventUnspawn ( int16  event_id)
private
1251 {
1252  int32 internal_event_id = mGameEvent.size() + event_id - 1;
1253 
1254  if (internal_event_id < 0 || internal_event_id >= int32(mGameEventCreatureGuids.size()))
1255  {
1256  TC_LOG_ERROR("gameevent", "GameEventMgr::GameEventUnspawn attempt access to out of range mGameEventCreatureGuids element %i (size: %zu)",
1257  internal_event_id, mGameEventCreatureGuids.size());
1258  return;
1259  }
1260 
1261  for (GuidList::iterator itr = mGameEventCreatureGuids[internal_event_id].begin(); itr != mGameEventCreatureGuids[internal_event_id].end(); ++itr)
1262  {
1263  // check if it's needed by another event, if so, don't remove
1264  if (event_id > 0 && hasCreatureActiveEventExcept(*itr, event_id))
1265  continue;
1266  // Remove the creature from grid
1267  if (CreatureData const* data = sObjectMgr->GetCreatureData(*itr))
1268  {
1269  sObjectMgr->RemoveCreatureFromGrid(*itr, data);
1270 
1271  sMapMgr->DoForAllMapsWithMapId(data->mapid, [&itr](Map* map)
1272  {
1273  auto creatureBounds = map->GetCreatureBySpawnIdStore().equal_range(*itr);
1274  for (auto itr2 = creatureBounds.first; itr2 != creatureBounds.second;)
1275  {
1276  Creature* creature = itr2->second;
1277  ++itr2;
1278  creature->AddObjectToRemoveList();
1279  }
1280  });
1281  }
1282  }
1283 
1284  if (internal_event_id < 0 || internal_event_id >= int32(mGameEventGameobjectGuids.size()))
1285  {
1286  TC_LOG_ERROR("gameevent", "GameEventMgr::GameEventUnspawn attempt access to out of range mGameEventGameobjectGuids element %i (size: %zu)",
1287  internal_event_id, mGameEventGameobjectGuids.size());
1288  return;
1289  }
1290 
1291  for (GuidList::iterator itr = mGameEventGameobjectGuids[internal_event_id].begin(); itr != mGameEventGameobjectGuids[internal_event_id].end(); ++itr)
1292  {
1293  // check if it's needed by another event, if so, don't remove
1294  if (event_id >0 && hasGameObjectActiveEventExcept(*itr, event_id))
1295  continue;
1296  // Remove the gameobject from grid
1297  if (GameObjectData const* data = sObjectMgr->GetGOData(*itr))
1298  {
1299  sObjectMgr->RemoveGameobjectFromGrid(*itr, data);
1300 
1301  sMapMgr->DoForAllMapsWithMapId(data->mapid, [&itr](Map* map)
1302  {
1303  auto gameobjectBounds = map->GetGameObjectBySpawnIdStore().equal_range(*itr);
1304  for (auto itr2 = gameobjectBounds.first; itr2 != gameobjectBounds.second;)
1305  {
1306  GameObject* go = itr2->second;
1307  ++itr2;
1308  go->AddObjectToRemoveList();
1309  }
1310  });
1311  }
1312  }
1313 
1314  if (internal_event_id < 0 || internal_event_id >= int32(mGameEventPoolIds.size()))
1315  {
1316  TC_LOG_ERROR("gameevent", "GameEventMgr::GameEventUnspawn attempt access to out of range mGameEventPoolIds element %u (size: %zu)", internal_event_id, mGameEventPoolIds.size());
1317  return;
1318  }
1319 
1320  for (IdList::iterator itr = mGameEventPoolIds[internal_event_id].begin(); itr != mGameEventPoolIds[internal_event_id].end(); ++itr)
1321  {
1322  sPoolMgr->DespawnPool(*itr);
1323  }
1324 }
Definition: Creature.h:287
GameEventIdMap mGameEventPoolIds
Definition: GameEventMgr.h:171
GameEventDataMap mGameEvent
Definition: GameEventMgr.h:172
GameEventGuidMap mGameEventCreatureGuids
Definition: GameEventMgr.h:180
GameEventGuidMap mGameEventGameobjectGuids
Definition: GameEventMgr.h:181
#define sObjectMgr
Definition: ObjectMgr.h:1567
bool hasGameObjectActiveEventExcept(ObjectGuid::LowType go_guid, uint16 event_id)
Definition: GameEventMgr.cpp:1427
#define sPoolMgr
Definition: PoolMgr.h:166
int32_t int32
Definition: Define.h:146
Definition: Map.h:259
bool hasCreatureActiveEventExcept(ObjectGuid::LowType creature_guid, uint16 event_id)
Definition: GameEventMgr.cpp:1411
Definition: GameObject.h:833
#define sMapMgr
Definition: MapManager.h:194
int32_t int32
Definition: g3dmath.h:167
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ActiveEvents const& GameEventMgr::GetActiveEventList ( ) const
inline
108 { return m_ActiveEvents; }
ActiveEvents m_ActiveEvents
Definition: GameEventMgr.h:176
uint16 GameEventMgr::GetEventIdForQuest ( Quest const quest) const
1662 {
1663  if (!quest)
1664  return 0;
1665 
1666  std::unordered_map<uint32, uint16>::const_iterator itr = _questToEventLinks.find(quest->GetQuestId());
1667  if (itr == _questToEventLinks.end())
1668  return 0;
1669 
1670  return itr->second;
1671 }
std::unordered_map< uint32, uint16 > _questToEventLinks
Definition: GameEventMgr.h:177

+ Here is the call graph for this function:

GameEventDataMap const& GameEventMgr::GetEventMap ( ) const
inline
109 { return mGameEvent; }
GameEventDataMap mGameEvent
Definition: GameEventMgr.h:172
uint64 GameEventMgr::GetNPCFlag ( Creature cr)
925 {
926  uint64 mask = 0;
927  ObjectGuid::LowType guid = cr->GetSpawnId();
928 
929  for (ActiveEvents::iterator e_itr = m_ActiveEvents.begin(); e_itr != m_ActiveEvents.end(); ++e_itr)
930  {
931  for (NPCFlagList::iterator itr = mGameEventNPCFlags[*e_itr].begin();
932  itr != mGameEventNPCFlags[*e_itr].end();
933  ++ itr)
934  if (itr->first == guid)
935  mask |= itr->second;
936  }
937 
938  return mask;
939 }
GameEventNPCFlagMap mGameEventNPCFlags
Definition: GameEventMgr.h:175
ObjectGuid::LowType GetSpawnId() const
Definition: Creature.h:487
uint64 LowType
Definition: ObjectGuid.h:199
ActiveEvents m_ActiveEvents
Definition: GameEventMgr.h:176
uint64_t uint64
Definition: Define.h:149

+ Here is the call graph for this function:

uint32 GameEventMgr::GetNpcTextId ( uint32  guid)
void GameEventMgr::HandleQuestComplete ( uint32  quest_id)
1523 {
1524  // translate the quest to event and condition
1525  QuestIdToEventConditionMap::iterator itr = mQuestToEventConditions.find(quest_id);
1526  // quest is registered
1527  if (itr != mQuestToEventConditions.end())
1528  {
1529  uint16 event_id = itr->second.event_id;
1530  uint32 condition = itr->second.condition;
1531  float num = itr->second.num;
1532 
1533  // the event is not active, so return, don't increase condition finishes
1534  if (!IsActiveEvent(event_id))
1535  return;
1536  // not in correct phase, return
1537  if (mGameEvent[event_id].state != GAMEEVENT_WORLD_CONDITIONS)
1538  return;
1539  GameEventConditionMap::iterator citr = mGameEvent[event_id].conditions.find(condition);
1540  // condition is registered
1541  if (citr != mGameEvent[event_id].conditions.end())
1542  {
1543  // increase the done count, only if less then the req
1544  if (citr->second.done < citr->second.reqNum)
1545  {
1546  citr->second.done += num;
1547  // check max limit
1548  if (citr->second.done > citr->second.reqNum)
1549  citr->second.done = citr->second.reqNum;
1550  // save the change to db
1552 
1554  stmt->setUInt8(0, uint8(event_id));
1555  stmt->setUInt32(1, condition);
1556  trans->Append(stmt);
1557 
1559  stmt->setUInt8(0, uint8(event_id));
1560  stmt->setUInt32(1, condition);
1561  stmt->setFloat(2, citr->second.done);
1562  trans->Append(stmt);
1564  // check if all conditions are met, if so, update the event state
1565  if (CheckOneGameEventConditions(event_id))
1566  {
1567  // changed, save to DB the gameevent state
1568  SaveWorldEventStateToDB(event_id);
1569  // force update events to set timer
1570  sWorld->ForceGameEventUpdate();
1571  }
1572  }
1573  }
1574  }
1575 }
GameEventDataMap mGameEvent
Definition: GameEventMgr.h:172
bool IsActiveEvent(uint16 event_id)
Definition: GameEventMgr.h:114
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
#define sWorld
Definition: World.h:887
Definition: GameEventMgr.h:33
Definition: PreparedStatement.h:74
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
QuestIdToEventConditionMap mQuestToEventConditions
Definition: GameEventMgr.h:174
uint32_t uint32
Definition: Define.h:150
uint16_t uint16
Definition: Define.h:151
void SaveWorldEventStateToDB(uint16 event_id)
Definition: GameEventMgr.cpp:1594
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
uint8_t uint8
Definition: g3dmath.h:164
bool CheckOneGameEventConditions(uint16 event_id)
Runs SMART_EVENT_GAME_EVENT_START/_END SAI.
Definition: GameEventMgr.cpp:1577
void setFloat(const uint8 index, const float value)
Definition: PreparedStatement.cpp:169
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: CharacterDatabase.h:249
Definition: CharacterDatabase.h:248
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

void GameEventMgr::HandleWorldEventGossip ( Player player,
Creature c 
)
bool GameEventMgr::hasCreatureActiveEventExcept ( ObjectGuid::LowType  creature_guid,
uint16  event_id 
)
private
1412 {
1413  for (ActiveEvents::iterator e_itr = m_ActiveEvents.begin(); e_itr != m_ActiveEvents.end(); ++e_itr)
1414  {
1415  if ((*e_itr) != event_id)
1416  {
1417  int32 internal_event_id = mGameEvent.size() + (*e_itr) - 1;
1418  for (GuidList::iterator itr = mGameEventCreatureGuids[internal_event_id].begin();
1419  itr != mGameEventCreatureGuids[internal_event_id].end();
1420  ++ itr)
1421  if (*itr == creature_id)
1422  return true;
1423  }
1424  }
1425  return false;
1426 }
GameEventDataMap mGameEvent
Definition: GameEventMgr.h:172
GameEventGuidMap mGameEventCreatureGuids
Definition: GameEventMgr.h:180
ActiveEvents m_ActiveEvents
Definition: GameEventMgr.h:176
int32_t int32
Definition: Define.h:146

+ Here is the caller graph for this function:

bool GameEventMgr::hasCreatureQuestActiveEventExcept ( uint32  quest_id,
uint16  event_id 
)
private
1385 {
1386  for (ActiveEvents::iterator e_itr = m_ActiveEvents.begin(); e_itr != m_ActiveEvents.end(); ++e_itr)
1387  {
1388  if ((*e_itr) != event_id)
1389  for (QuestRelList::iterator itr = mGameEventCreatureQuests[*e_itr].begin();
1390  itr != mGameEventCreatureQuests[*e_itr].end();
1391  ++ itr)
1392  if (itr->second == quest_id)
1393  return true;
1394  }
1395  return false;
1396 }
ActiveEvents m_ActiveEvents
Definition: GameEventMgr.h:176
GameEventQuestMap mGameEventCreatureQuests
Definition: GameEventMgr.h:165

+ Here is the caller graph for this function:

bool GameEventMgr::hasGameObjectActiveEventExcept ( ObjectGuid::LowType  go_guid,
uint16  event_id 
)
private
1428 {
1429  for (ActiveEvents::iterator e_itr = m_ActiveEvents.begin(); e_itr != m_ActiveEvents.end(); ++e_itr)
1430  {
1431  if ((*e_itr) != event_id)
1432  {
1433  int32 internal_event_id = mGameEvent.size() + (*e_itr) - 1;
1434  for (GuidList::iterator itr = mGameEventGameobjectGuids[internal_event_id].begin();
1435  itr != mGameEventGameobjectGuids[internal_event_id].end();
1436  ++ itr)
1437  if (*itr == go_id)
1438  return true;
1439  }
1440  }
1441  return false;
1442 }
GameEventDataMap mGameEvent
Definition: GameEventMgr.h:172
GameEventGuidMap mGameEventGameobjectGuids
Definition: GameEventMgr.h:181
ActiveEvents m_ActiveEvents
Definition: GameEventMgr.h:176
int32_t int32
Definition: Define.h:146
bool GameEventMgr::hasGameObjectQuestActiveEventExcept ( uint32  quest_id,
uint16  event_id 
)
private
1399 {
1400  for (ActiveEvents::iterator e_itr = m_ActiveEvents.begin(); e_itr != m_ActiveEvents.end(); ++e_itr)
1401  {
1402  if ((*e_itr) != event_id)
1403  for (QuestRelList::iterator itr = mGameEventGameObjectQuests[*e_itr].begin();
1404  itr != mGameEventGameObjectQuests[*e_itr].end();
1405  ++ itr)
1406  if (itr->second == quest_id)
1407  return true;
1408  }
1409  return false;
1410 }
ActiveEvents m_ActiveEvents
Definition: GameEventMgr.h:176
GameEventQuestMap mGameEventGameObjectQuests
Definition: GameEventMgr.h:166

+ Here is the caller graph for this function:

void GameEventMgr::Initialize ( )
942 {
943  QueryResult result = WorldDatabase.Query("SELECT MAX(eventEntry) FROM game_event");
944  if (result)
945  {
946  Field* fields = result->Fetch();
947 
948  uint32 maxEventId = fields[0].GetUInt8();
949 
950  // Id starts with 1 and vector with 0, thus increment
951  maxEventId++;
952 
953  mGameEvent.resize(maxEventId);
954  mGameEventCreatureGuids.resize(maxEventId * 2 - 1);
955  mGameEventGameobjectGuids.resize(maxEventId * 2 - 1);
956  mGameEventCreatureQuests.resize(maxEventId);
957  mGameEventGameObjectQuests.resize(maxEventId);
958  mGameEventVendors.resize(maxEventId);
959  mGameEventBattlegroundHolidays.resize(maxEventId, 0);
960  mGameEventPoolIds.resize(maxEventId * 2 - 1);
961  mGameEventNPCFlags.resize(maxEventId);
962  mGameEventModelEquip.resize(maxEventId);
963  }
964 }
GameEventIdMap mGameEventPoolIds
Definition: GameEventMgr.h:171
GameEventDataMap mGameEvent
Definition: GameEventMgr.h:172
GameEventGuidMap mGameEventCreatureGuids
Definition: GameEventMgr.h:180
GameEventNPCFlagMap mGameEventNPCFlags
Definition: GameEventMgr.h:175
Class used to access individual fields of database query result.
Definition: Field.h:56
GameEventNPCVendorMap mGameEventVendors
Definition: GameEventMgr.h:167
GameEventGuidMap mGameEventGameobjectGuids
Definition: GameEventMgr.h:181
WorldDatabaseWorkerPool WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
uint8 GetUInt8() const
Definition: Field.h:70
uint32_t uint32
Definition: Define.h:150
std::shared_ptr< ResultSet > QueryResult
Definition: QueryResult.h:61
GameEventBitmask mGameEventBattlegroundHolidays
Definition: GameEventMgr.h:173
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
GameEventQuestMap mGameEventGameObjectQuests
Definition: GameEventMgr.h:166
GameEventQuestMap mGameEventCreatureQuests
Definition: GameEventMgr.h:165
GameEventModelEquipMap mGameEventModelEquip
Definition: GameEventMgr.h:168

+ Here is the call graph for this function:

GameEventMgr * GameEventMgr::instance ( )
static
33 {
34  static GameEventMgr instance;
35  return &instance;
36 }
Definition: GameEventMgr.h:97
static GameEventMgr * instance()
Definition: GameEventMgr.cpp:32
bool GameEventMgr::IsActiveEvent ( uint16  event_id)
inline
114 { return (m_ActiveEvents.find(event_id) != m_ActiveEvents.end()); }
ActiveEvents m_ActiveEvents
Definition: GameEventMgr.h:176

+ Here is the caller graph for this function:

void GameEventMgr::LoadFromDB ( )
Todo:
Change to uint8
210 {
211  {
212  uint32 oldMSTime = getMSTime();
213  // 0 1 2 3 4 5 6 7 8
214  QueryResult result = WorldDatabase.Query("SELECT eventEntry, UNIX_TIMESTAMP(start_time), UNIX_TIMESTAMP(end_time), occurence, length, holiday, description, world_event, announce FROM game_event");
215  if (!result)
216  {
217  mGameEvent.clear();
218  TC_LOG_ERROR("server.loading", ">> Loaded 0 game events. DB table `game_event` is empty.");
219  return;
220  }
221 
222  uint32 count = 0;
223  do
224  {
225  Field* fields = result->Fetch();
226 
227  uint8 event_id = fields[0].GetUInt8();
228  if (event_id == 0)
229  {
230  TC_LOG_ERROR("sql.sql", "`game_event` game event entry 0 is reserved and can't be used.");
231  continue;
232  }
233 
234  GameEventData& pGameEvent = mGameEvent[event_id];
235  uint64 starttime = fields[1].GetUInt64();
236  pGameEvent.start = time_t(starttime);
237  uint64 endtime = fields[2].GetUInt64();
238  pGameEvent.end = time_t(endtime);
239  pGameEvent.occurence = fields[3].GetUInt64();
240  pGameEvent.length = fields[4].GetUInt64();
241  pGameEvent.holiday_id = HolidayIds(fields[5].GetUInt32());
242 
243  pGameEvent.state = (GameEventState)(fields[7].GetUInt8());
244  pGameEvent.nextstart = 0;
245  pGameEvent.announce = fields[8].GetUInt8();
246 
247  if (pGameEvent.length == 0 && pGameEvent.state == GAMEEVENT_NORMAL) // length>0 is validity check
248  {
249  TC_LOG_ERROR("sql.sql", "`game_event` game event id (%i) isn't a world event and has length = 0, thus it can't be used.", event_id);
250  continue;
251  }
252 
253  if (pGameEvent.holiday_id != HOLIDAY_NONE)
254  {
255  if (!sHolidaysStore.LookupEntry(pGameEvent.holiday_id))
256  {
257  TC_LOG_ERROR("sql.sql", "`game_event` game event id (%i) have not existed holiday id %u.", event_id, pGameEvent.holiday_id);
258  pGameEvent.holiday_id = HOLIDAY_NONE;
259  }
260  }
261 
262  pGameEvent.description = fields[6].GetString();
263 
264  ++count;
265  }
266  while (result->NextRow());
267 
268  TC_LOG_INFO("server.loading", ">> Loaded %u game events in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
269 
270  }
271 
272  TC_LOG_INFO("server.loading", "Loading Game Event Saves Data...");
273  {
274  uint32 oldMSTime = getMSTime();
275 
276  // 0 1 2
277  QueryResult result = CharacterDatabase.Query("SELECT eventEntry, state, next_start FROM game_event_save");
278 
279  if (!result)
280  TC_LOG_INFO("server.loading", ">> Loaded 0 game event saves in game events. DB table `game_event_save` is empty.");
281  else
282  {
283  uint32 count = 0;
284  do
285  {
286  Field* fields = result->Fetch();
287 
288  uint8 event_id = fields[0].GetUInt8();
289 
290  if (event_id >= mGameEvent.size())
291  {
292  TC_LOG_ERROR("sql.sql", "`game_event_save` game event entry (%i) is out of range compared to max event entry in `game_event`", event_id);
293  continue;
294  }
295 
296  if (mGameEvent[event_id].state != GAMEEVENT_NORMAL && mGameEvent[event_id].state != GAMEEVENT_INTERNAL)
297  {
298  mGameEvent[event_id].state = (GameEventState)(fields[1].GetUInt8());
299  mGameEvent[event_id].nextstart = time_t(fields[2].GetUInt32());
300  }
301  else
302  {
303  TC_LOG_ERROR("sql.sql", "game_event_save includes event save for non-worldevent id %u", event_id);
304  continue;
305  }
306 
307  ++count;
308  }
309  while (result->NextRow());
310 
311  TC_LOG_INFO("server.loading", ">> Loaded %u game event saves in game events in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
312 
313  }
314  }
315 
316  TC_LOG_INFO("server.loading", "Loading Game Event Prerequisite Data...");
317  {
318  uint32 oldMSTime = getMSTime();
319 
320  // 0 1
321  QueryResult result = WorldDatabase.Query("SELECT eventEntry, prerequisite_event FROM game_event_prerequisite");
322  if (!result)
323  TC_LOG_INFO("server.loading", ">> Loaded 0 game event prerequisites in game events. DB table `game_event_prerequisite` is empty.");
324  else
325  {
326  uint32 count = 0;
327  do
328  {
329  Field* fields = result->Fetch();
330 
331  uint16 event_id = fields[0].GetUInt8();
332 
333  if (event_id >= mGameEvent.size())
334  {
335  TC_LOG_ERROR("sql.sql", "`game_event_prerequisite` game event id (%i) is out of range compared to max event id in `game_event`", event_id);
336  continue;
337  }
338 
339  if (mGameEvent[event_id].state != GAMEEVENT_NORMAL && mGameEvent[event_id].state != GAMEEVENT_INTERNAL)
340  {
341  uint16 prerequisite_event = fields[1].GetUInt32();
342  if (prerequisite_event >= mGameEvent.size())
343  {
344  TC_LOG_ERROR("sql.sql", "`game_event_prerequisite` game event prerequisite id (%i) is out of range compared to max event id in `game_event`", prerequisite_event);
345  continue;
346  }
347  mGameEvent[event_id].prerequisite_events.insert(prerequisite_event);
348  }
349  else
350  {
351  TC_LOG_ERROR("sql.sql", "game_event_prerequisiste includes event entry for non-worldevent id %u", event_id);
352  continue;
353  }
354 
355  ++count;
356  }
357  while (result->NextRow());
358 
359  TC_LOG_INFO("server.loading", ">> Loaded %u game event prerequisites in game events in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
360 
361  }
362  }
363 
364  TC_LOG_INFO("server.loading", "Loading Game Event Creature Data...");
365  {
366  uint32 oldMSTime = getMSTime();
367 
368  // 0 1
369  QueryResult result = WorldDatabase.Query("SELECT guid, eventEntry FROM game_event_creature");
370 
371  if (!result)
372  TC_LOG_INFO("server.loading", ">> Loaded 0 creatures in game events. DB table `game_event_creature` is empty");
373  else
374  {
375  uint32 count = 0;
376  do
377  {
378  Field* fields = result->Fetch();
379 
380  ObjectGuid::LowType guid = fields[0].GetUInt64();
381  int16 event_id = fields[1].GetInt8();
382 
383  int32 internal_event_id = mGameEvent.size() + event_id - 1;
384 
385  CreatureData const* data = sObjectMgr->GetCreatureData(guid);
386  if (!data)
387  {
388  TC_LOG_ERROR("sql.sql", "`game_event_creature` contains creature (GUID: " UI64FMTD ") not found in `creature` table.", guid);
389  continue;
390  }
391 
392  if (internal_event_id < 0 || internal_event_id >= int32(mGameEventCreatureGuids.size()))
393  {
394  TC_LOG_ERROR("sql.sql", "`game_event_creature` game event id (%i) is out of range compared to max event id in `game_event`", event_id);
395  continue;
396  }
397 
398  GuidList& crelist = mGameEventCreatureGuids[internal_event_id];
399  crelist.push_back(guid);
400 
401  ++count;
402  }
403  while (result->NextRow());
404 
405  TC_LOG_INFO("server.loading", ">> Loaded %u creatures in game events in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
406 
407  }
408  }
409 
410  TC_LOG_INFO("server.loading", "Loading Game Event GO Data...");
411  {
412  uint32 oldMSTime = getMSTime();
413 
414  // 0 1
415  QueryResult result = WorldDatabase.Query("SELECT guid, eventEntry FROM game_event_gameobject");
416 
417  if (!result)
418  TC_LOG_INFO("server.loading", ">> Loaded 0 gameobjects in game events. DB table `game_event_gameobject` is empty.");
419  else
420  {
421  uint32 count = 0;
422  do
423  {
424  Field* fields = result->Fetch();
425 
426  ObjectGuid::LowType guid = fields[0].GetUInt64();
427  int16 event_id = fields[1].GetInt8();
428 
429  int32 internal_event_id = mGameEvent.size() + event_id - 1;
430 
431  GameObjectData const* data = sObjectMgr->GetGOData(guid);
432  if (!data)
433  {
434  TC_LOG_ERROR("sql.sql", "`game_event_gameobject` contains gameobject (GUID: " UI64FMTD ") not found in `gameobject` table.", guid);
435  continue;
436  }
437 
438  if (internal_event_id < 0 || internal_event_id >= int32(mGameEventGameobjectGuids.size()))
439  {
440  TC_LOG_ERROR("sql.sql", "`game_event_gameobject` game event id (%i) is out of range compared to max event id in `game_event`", event_id);
441  continue;
442  }
443 
444  GuidList& golist = mGameEventGameobjectGuids[internal_event_id];
445  golist.push_back(guid);
446 
447  ++count;
448  }
449  while (result->NextRow());
450 
451  TC_LOG_INFO("server.loading", ">> Loaded %u gameobjects in game events in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
452  }
453  }
454 
455  TC_LOG_INFO("server.loading", "Loading Game Event Model/Equipment Change Data...");
456  {
457  uint32 oldMSTime = getMSTime();
458 
459  // 0 1 2 3 4
460  QueryResult result = WorldDatabase.Query("SELECT creature.guid, creature.id, game_event_model_equip.eventEntry, game_event_model_equip.modelid, game_event_model_equip.equipment_id "
461  "FROM creature JOIN game_event_model_equip ON creature.guid=game_event_model_equip.guid");
462 
463  if (!result)
464  TC_LOG_INFO("server.loading", ">> Loaded 0 model/equipment changes in game events. DB table `game_event_model_equip` is empty.");
465  else
466  {
467  uint32 count = 0;
468  do
469  {
470  Field* fields = result->Fetch();
471 
472  ObjectGuid::LowType guid = fields[0].GetUInt64();
473  uint32 entry = fields[1].GetUInt32();
474  uint16 event_id = fields[2].GetUInt8();
475 
476  if (event_id >= mGameEventModelEquip.size())
477  {
478  TC_LOG_ERROR("sql.sql", "`game_event_model_equip` game event id (%u) is out of range compared to max event id in `game_event`", event_id);
479  continue;
480  }
481 
482  ModelEquipList& equiplist = mGameEventModelEquip[event_id];
483  ModelEquip newModelEquipSet;
484  newModelEquipSet.modelid = fields[3].GetUInt32();
485  newModelEquipSet.equipment_id = fields[4].GetUInt8();
486  newModelEquipSet.equipement_id_prev = 0;
487  newModelEquipSet.modelid_prev = 0;
488 
489  if (newModelEquipSet.equipment_id > 0)
490  {
491  int8 equipId = static_cast<int8>(newModelEquipSet.equipment_id);
492  if (!sObjectMgr->GetEquipmentInfo(entry, equipId))
493  {
494  TC_LOG_ERROR("sql.sql", "Table `game_event_model_equip` have creature (Guid: " UI64FMTD ", entry: %u) with equipment_id %u not found in table `creature_equip_template`, set to no equipment.",
495  guid, entry, newModelEquipSet.equipment_id);
496  continue;
497  }
498  }
499 
500  equiplist.push_back(std::pair<ObjectGuid::LowType, ModelEquip>(guid, newModelEquipSet));
501 
502  ++count;
503  }
504  while (result->NextRow());
505 
506  TC_LOG_INFO("server.loading", ">> Loaded %u model/equipment changes in game events in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
507  }
508  }
509 
510  TC_LOG_INFO("server.loading", "Loading Game Event Quest Data...");
511  {
512  uint32 oldMSTime = getMSTime();
513 
514  // 0 1 2
515  QueryResult result = WorldDatabase.Query("SELECT id, quest, eventEntry FROM game_event_creature_quest");
516 
517  if (!result)
518  TC_LOG_INFO("server.loading", ">> Loaded 0 quests additions in game events. DB table `game_event_creature_quest` is empty.");
519  else
520  {
521  uint32 count = 0;
522  do
523  {
524  Field* fields = result->Fetch();
525 
526  uint32 id = fields[0].GetUInt32();
527  uint32 quest = fields[1].GetUInt32();
528  uint16 event_id = fields[2].GetUInt8();
529 
530  if (event_id >= mGameEventCreatureQuests.size())
531  {
532  TC_LOG_ERROR("sql.sql", "`game_event_creature_quest` game event id (%u) is out of range compared to max event id in `game_event`", event_id);
533  continue;
534  }
535 
536  QuestRelList& questlist = mGameEventCreatureQuests[event_id];
537  questlist.push_back(QuestRelation(id, quest));
538 
539  ++count;
540  }
541  while (result->NextRow());
542 
543  TC_LOG_INFO("server.loading", ">> Loaded %u quests additions in game events in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
544  }
545  }
546 
547  TC_LOG_INFO("server.loading", "Loading Game Event GO Quest Data...");
548  {
549  uint32 oldMSTime = getMSTime();
550 
551  // 0 1 2
552  QueryResult result = WorldDatabase.Query("SELECT id, quest, eventEntry FROM game_event_gameobject_quest");
553 
554  if (!result)
555  TC_LOG_INFO("server.loading", ">> Loaded 0 go quests additions in game events. DB table `game_event_gameobject_quest` is empty.");
556  else
557  {
558  uint32 count = 0;
559  do
560  {
561  Field* fields = result->Fetch();
562 
563  uint32 id = fields[0].GetUInt32();
564  uint32 quest = fields[1].GetUInt32();
565  uint16 event_id = fields[2].GetUInt8();
566 
567  if (event_id >= mGameEventGameObjectQuests.size())
568  {
569  TC_LOG_ERROR("sql.sql", "`game_event_gameobject_quest` game event id (%u) is out of range compared to max event id in `game_event`", event_id);
570  continue;
571  }
572 
573  QuestRelList& questlist = mGameEventGameObjectQuests[event_id];
574  questlist.push_back(QuestRelation(id, quest));
575 
576  ++count;
577  }
578  while (result->NextRow());
579 
580  TC_LOG_INFO("server.loading", ">> Loaded %u quests additions in game events in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
581  }
582  }
583 
584  TC_LOG_INFO("server.loading", "Loading Game Event Quest Condition Data...");
585  {
586  uint32 oldMSTime = getMSTime();
587 
588  // 0 1 2 3
589  QueryResult result = WorldDatabase.Query("SELECT quest, eventEntry, condition_id, num FROM game_event_quest_condition");
590 
591  if (!result)
592  TC_LOG_INFO("server.loading", ">> Loaded 0 quest event conditions in game events. DB table `game_event_quest_condition` is empty.");
593  else
594  {
595  uint32 count = 0;
596  do
597  {
598  Field* fields = result->Fetch();
599 
600  uint32 quest = fields[0].GetUInt32();
601  uint16 event_id = fields[1].GetUInt8();
602  uint32 condition = fields[2].GetUInt32();
603  float num = fields[3].GetFloat();
604 
605  if (event_id >= mGameEvent.size())
606  {
607  TC_LOG_ERROR("sql.sql", "`game_event_quest_condition` game event id (%u) is out of range compared to max event id in `game_event`", event_id);
608  continue;
609  }
610 
611  mQuestToEventConditions[quest].event_id = event_id;
612  mQuestToEventConditions[quest].condition = condition;
613  mQuestToEventConditions[quest].num = num;
614 
615  ++count;
616  }
617  while (result->NextRow());
618 
619  TC_LOG_INFO("server.loading", ">> Loaded %u quest event conditions in game events in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
620  }
621  }
622 
623  TC_LOG_INFO("server.loading", "Loading Game Event Condition Data...");
624  {
625  uint32 oldMSTime = getMSTime();
626 
627  // 0 1 2 3 4
628  QueryResult result = WorldDatabase.Query("SELECT eventEntry, condition_id, req_num, max_world_state_field, done_world_state_field FROM game_event_condition");
629 
630  if (!result)
631  TC_LOG_INFO("server.loading", ">> Loaded 0 conditions in game events. DB table `game_event_condition` is empty.");
632  else
633  {
634  uint32 count = 0;
635  do
636  {
637  Field* fields = result->Fetch();
638 
639  uint16 event_id = fields[0].GetUInt8();
640  uint32 condition = fields[1].GetUInt32();
641 
642  if (event_id >= mGameEvent.size())
643  {
644  TC_LOG_ERROR("sql.sql", "`game_event_condition` game event id (%u) is out of range compared to max event id in `game_event`", event_id);
645  continue;
646  }
647 
648  mGameEvent[event_id].conditions[condition].reqNum = fields[2].GetFloat();
649  mGameEvent[event_id].conditions[condition].done = 0;
650  mGameEvent[event_id].conditions[condition].max_world_state = fields[3].GetUInt16();
651  mGameEvent[event_id].conditions[condition].done_world_state = fields[4].GetUInt16();
652 
653  ++count;
654  }
655  while (result->NextRow());
656 
657  TC_LOG_INFO("server.loading", ">> Loaded %u conditions in game events in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
658  }
659  }
660 
661  TC_LOG_INFO("server.loading", "Loading Game Event Condition Save Data...");
662  {
663  uint32 oldMSTime = getMSTime();
664 
665  // 0 1 2
666  QueryResult result = CharacterDatabase.Query("SELECT eventEntry, condition_id, done FROM game_event_condition_save");
667 
668  if (!result)
669  TC_LOG_INFO("server.loading", ">> Loaded 0 condition saves in game events. DB table `game_event_condition_save` is empty.");
670  else
671  {
672  uint32 count = 0;
673  do
674  {
675  Field* fields = result->Fetch();
676 
677  uint16 event_id = fields[0].GetUInt8();
678  uint32 condition = fields[1].GetUInt32();
679 
680  if (event_id >= mGameEvent.size())
681  {
682  TC_LOG_ERROR("sql.sql", "`game_event_condition_save` game event id (%u) is out of range compared to max event id in `game_event`", event_id);
683  continue;
684  }
685 
686  GameEventConditionMap::iterator itr = mGameEvent[event_id].conditions.find(condition);
687  if (itr != mGameEvent[event_id].conditions.end())
688  {
689  itr->second.done = fields[2].GetFloat();
690  }
691  else
692  {
693  TC_LOG_ERROR("sql.sql", "game_event_condition_save contains not present condition evt id %u cond id %u", event_id, condition);
694  continue;
695  }
696 
697  ++count;
698  }
699  while (result->NextRow());
700 
701  TC_LOG_INFO("server.loading", ">> Loaded %u condition saves in game events in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
702  }
703  }
704 
705  TC_LOG_INFO("server.loading", "Loading Game Event NPCflag Data...");
706  {
707  uint32 oldMSTime = getMSTime();
708 
709  // 0 1 2
710  QueryResult result = WorldDatabase.Query("SELECT guid, eventEntry, npcflag FROM game_event_npcflag");
711 
712  if (!result)
713  TC_LOG_INFO("server.loading", ">> Loaded 0 npcflags in game events. DB table `game_event_npcflag` is empty.");
714  else
715  {
716  uint32 count = 0;
717  do
718  {
719  Field* fields = result->Fetch();
720 
721  ObjectGuid::LowType guid = fields[0].GetUInt64();
722  uint16 event_id = fields[1].GetUInt8();
723  uint64 npcflag = fields[2].GetUInt64();
724 
725  if (event_id >= mGameEvent.size())
726  {
727  TC_LOG_ERROR("sql.sql", "`game_event_npcflag` game event id (%u) is out of range compared to max event id in `game_event`", event_id);
728  continue;
729  }
730 
731  mGameEventNPCFlags[event_id].push_back(GuidNPCFlagPair(guid, npcflag));
732 
733  ++count;
734  }
735  while (result->NextRow());
736 
737  TC_LOG_INFO("server.loading", ">> Loaded %u npcflags in game events in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
738  }
739  }
740 
741  TC_LOG_INFO("server.loading", "Loading Game Event Seasonal Quest Relations...");
742  {
743  uint32 oldMSTime = getMSTime();
744 
745  // 0 1
746  QueryResult result = WorldDatabase.Query("SELECT questId, eventEntry FROM game_event_seasonal_questrelation");
747 
748  if (!result)
749  TC_LOG_INFO("server.loading", ">> Loaded 0 seasonal quests additions in game events. DB table `game_event_seasonal_questrelation` is empty.");
750  else
751  {
752  uint32 count = 0;
753  do
754  {
755  Field* fields = result->Fetch();
756 
757  uint32 questId = fields[0].GetUInt32();
758  uint32 eventEntry = fields[1].GetUInt32();
759 
760  if (!sObjectMgr->GetQuestTemplate(questId))
761  {
762  TC_LOG_ERROR("sql.sql", "`game_event_seasonal_questrelation` quest id (%u) does not exist in `quest_template`", questId);
763  continue;
764  }
765 
766  if (eventEntry >= mGameEvent.size())
767  {
768  TC_LOG_ERROR("sql.sql", "`game_event_seasonal_questrelation` event id (%u) is out of range compared to max event in `game_event`", eventEntry);
769  continue;
770  }
771 
772  _questToEventLinks[questId] = eventEntry;
773  ++count;
774  }
775  while (result->NextRow());
776 
777  TC_LOG_INFO("server.loading", ">> Loaded %u quests additions in game events in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
778  }
779  }
780 
781  TC_LOG_INFO("server.loading", "Loading Game Event Vendor Additions Data...");
782  {
783  uint32 oldMSTime = getMSTime();
784 
785  // 0 1 2 3 4 5 6
786  QueryResult result = WorldDatabase.Query("SELECT eventEntry, guid, item, maxcount, incrtime, ExtendedCost, type FROM game_event_npc_vendor ORDER BY guid, slot ASC");
787 
788  if (!result)
789  TC_LOG_INFO("server.loading", ">> Loaded 0 vendor additions in game events. DB table `game_event_npc_vendor` is empty.");
790  else
791  {
792  uint32 count = 0;
793  do
794  {
795  Field* fields = result->Fetch();
796 
797  uint8 event_id = fields[0].GetUInt8();
798 
799  if (event_id >= mGameEventVendors.size())
800  {
801  TC_LOG_ERROR("sql.sql", "`game_event_npc_vendor` game event id (%u) is out of range compared to max event id in `game_event`", event_id);
802  continue;
803  }
804 
805  NPCVendorList& vendors = mGameEventVendors[event_id];
806  NPCVendorEntry newEntry;
807  ObjectGuid::LowType guid = fields[1].GetUInt64();
808  newEntry.item = fields[2].GetUInt32();
809  newEntry.maxcount = fields[3].GetUInt32();
810  newEntry.incrtime = fields[4].GetUInt32();
811  newEntry.ExtendedCost = fields[5].GetUInt32();
812  newEntry.Type = fields[6].GetUInt8();
813  // get the event npc flag for checking if the npc will be vendor during the event or not
814  uint32 event_npc_flag = 0;
815  NPCFlagList& flist = mGameEventNPCFlags[event_id];
816  for (NPCFlagList::const_iterator itr = flist.begin(); itr != flist.end(); ++itr)
817  {
818  if (itr->first == guid)
819  {
820  event_npc_flag = itr->second;
821  break;
822  }
823  }
824  // get creature entry
825  newEntry.entry = 0;
826 
827  if (CreatureData const* data = sObjectMgr->GetCreatureData(guid))
828  newEntry.entry = data->id;
829 
830  // check validity with event's npcflag
831  if (!sObjectMgr->IsVendorItemValid(newEntry.entry, newEntry.item, newEntry.maxcount, newEntry.incrtime, newEntry.ExtendedCost, newEntry.Type, NULL, NULL, event_npc_flag))
832  continue;
833 
834  vendors.push_back(newEntry);
835 
836  ++count;
837  }
838  while (result->NextRow());
839 
840  TC_LOG_INFO("server.loading", ">> Loaded %u vendor additions in game events in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
841  }
842  }
843 
844  TC_LOG_INFO("server.loading", "Loading Game Event Battleground Data...");
845  {
846  uint32 oldMSTime = getMSTime();
847 
848  // 0 1
849  QueryResult result = WorldDatabase.Query("SELECT eventEntry, bgflag FROM game_event_battleground_holiday");
850 
851  if (!result)
852  TC_LOG_INFO("server.loading", ">> Loaded 0 battleground holidays in game events. DB table `game_event_battleground_holiday` is empty.");
853  else
854  {
855  uint32 count = 0;
856  do
857  {
858  Field* fields = result->Fetch();
859 
860  uint16 event_id = fields[0].GetUInt8();
861 
862  if (event_id >= mGameEvent.size())
863  {
864  TC_LOG_ERROR("sql.sql", "`game_event_battleground_holiday` game event id (%u) is out of range compared to max event id in `game_event`", event_id);
865  continue;
866  }
867 
868  mGameEventBattlegroundHolidays[event_id] = fields[1].GetUInt32();
869 
870  ++count;
871  }
872  while (result->NextRow());
873 
874  TC_LOG_INFO("server.loading", ">> Loaded %u battleground holidays in game events in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
875  }
876  }
877 
878  TC_LOG_INFO("server.loading", "Loading Game Event Pool Data...");
879  {
880  uint32 oldMSTime = getMSTime();
881 
882  // 0 1
883  QueryResult result = WorldDatabase.Query("SELECT pool_template.entry, game_event_pool.eventEntry FROM pool_template"
884  " JOIN game_event_pool ON pool_template.entry = game_event_pool.pool_entry");
885 
886  if (!result)
887  TC_LOG_INFO("server.loading", ">> Loaded 0 pools for game events. DB table `game_event_pool` is empty.");
888  else
889  {
890  uint32 count = 0;
891  do
892  {
893  Field* fields = result->Fetch();
894 
895  uint32 entry = fields[0].GetUInt32();
896  int16 event_id = fields[1].GetInt8();
897 
898  int32 internal_event_id = mGameEvent.size() + event_id - 1;
899 
900  if (internal_event_id < 0 || internal_event_id >= int32(mGameEventPoolIds.size()))
901  {
902  TC_LOG_ERROR("sql.sql", "`game_event_pool` game event id (%i) is out of range compared to max event id in `game_event`", event_id);
903  continue;
904  }
905 
906  if (!sPoolMgr->CheckPool(entry))
907  {
908  TC_LOG_ERROR("sql.sql", "Pool Id (%u) has all creatures or gameobjects with explicit chance sum <>100 and no equal chance defined. The pool system cannot pick one to spawn.", entry);
909  continue;
910  }
911 
912  IdList& poollist = mGameEventPoolIds[internal_event_id];
913  poollist.push_back(entry);
914 
915  ++count;
916  }
917  while (result->NextRow());
918 
919  TC_LOG_INFO("server.loading", ">> Loaded %u pools for game events in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
920  }
921  }
922 }
Definition: Creature.h:287
GameEventIdMap mGameEventPoolIds
Definition: GameEventMgr.h:171
Definition: GameEventMgr.h:36
GameEventDataMap mGameEvent
Definition: GameEventMgr.h:172
uint32 item
Definition: GameEventMgr.h:86
int8_t int8
Definition: Define.h:148
uint64 GetUInt64() const
Definition: Field.h:184
HolidayIds holiday_id
Definition: GameEventMgr.h:65
Definition: SharedDefines.h:3716
float GetFloat() const
Definition: Field.h:222
GameEventGuidMap mGameEventCreatureGuids
Definition: GameEventMgr.h:180
GameEventNPCFlagMap mGameEventNPCFlags
Definition: GameEventMgr.h:175
uint8 Type
Definition: GameEventMgr.h:90
Class used to access individual fields of database query result.
Definition: Field.h:56
GameEventNPCVendorMap mGameEventVendors
Definition: GameEventMgr.h:167
uint8 announce
Definition: GameEventMgr.h:70
GameEventGuidMap mGameEventGameobjectGuids
Definition: GameEventMgr.h:181
uint32 getMSTime()
Definition: Timer.h:24
GameEventState
Definition: GameEventMgr.h:29
uint32 entry
Definition: GameEventMgr.h:85
arena_t NULL
Definition: jemalloc_internal.h:624
std::unordered_map< uint32, uint16 > _questToEventLinks
Definition: GameEventMgr.h:177
WorldDatabaseWorkerPool WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
uint8 equipment_id
Definition: GameEventMgr.h:79
uint32 ExtendedCost
Definition: GameEventMgr.h:89
time_t end
Definition: GameEventMgr.h:61
uint64 LowType
Definition: ObjectGuid.h:199
#define sObjectMgr
Definition: ObjectMgr.h:1567
uint32 length
Definition: GameEventMgr.h:64
std::list< uint32 > IdList
Definition: GameEventMgr.h:149
std::list< ObjectGuid > GuidList
Definition: ObjectGuid.h:333
std::list< QuestRelation > QuestRelList
Definition: GameEventMgr.h:156
DB2Storage< HolidaysEntry > sHolidaysStore("Holidays.db2", HolidaysEntryFormat, HOTFIX_SEL_HOLIDAYS)
uint8 GetUInt8() const
Definition: Field.h:70
std::list< NPCVendorEntry > NPCVendorList
Definition: GameEventMgr.h:158
#define sPoolMgr
Definition: PoolMgr.h:166
uint32 modelid_prev
Definition: GameEventMgr.h:78
uint32 incrtime
Definition: GameEventMgr.h:88
QuestIdToEventConditionMap mQuestToEventConditions
Definition: GameEventMgr.h:174
#define UI64FMTD
Definition: Define.h:137
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
uint64_t uint64
Definition: Define.h:149
std::shared_ptr< ResultSet > QueryResult
Definition: QueryResult.h:61
uint32 id
Definition: GameObject.h:838
uint16_t uint16
Definition: Define.h:151
std::pair< ObjectGuid::LowType, uint64 > GuidNPCFlagPair
Definition: GameEventMgr.h:161
time_t nextstart
Definition: GameEventMgr.h:62
uint16 GetUInt16() const
Definition: Field.h:108
Definition: GameEventMgr.h:31
uint8 equipement_id_prev
Definition: GameEventMgr.h:80
GameEventState state
Definition: GameEventMgr.h:66
int32 maxcount
Definition: GameEventMgr.h:87
Definition: GameObject.h:833
uint32 occurence
Definition: GameEventMgr.h:63
Definition: GameEventMgr.h:75
Definition: GameEventMgr.h:83
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition: Timer.h:42
GameEventBitmask mGameEventBattlegroundHolidays
Definition: GameEventMgr.h:173
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
std::list< ModelEquipPair > ModelEquipList
Definition: GameEventMgr.h:153
uint32 modelid
Definition: GameEventMgr.h:77
uint32 GetUInt32() const
Definition: Field.h:146
GameEventQuestMap mGameEventGameObjectQuests
Definition: GameEventMgr.h:166
int32_t int32
Definition: g3dmath.h:167
uint8_t uint8
Definition: Define.h:152
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
GameEventQuestMap mGameEventCreatureQuests
Definition: GameEventMgr.h:165
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
int16_t int16
Definition: Define.h:147
std::list< GuidNPCFlagPair > NPCFlagList
Definition: GameEventMgr.h:162
int8 GetInt8() const
Definition: Field.h:89
std::pair< uint32, uint32 > QuestRelation
Definition: GameEventMgr.h:155
Definition: GameEventMgr.h:56
std::string GetString() const
Definition: Field.h:276
std::string description
Definition: GameEventMgr.h:69
HolidayIds
Definition: SharedDefines.h:3714
GameEventModelEquipMap mGameEventModelEquip
Definition: GameEventMgr.h:168
time_t start
Definition: GameEventMgr.h:60

+ Here is the call graph for this function:

uint32 GameEventMgr::NextCheck ( uint16  entry) const
77 {
78  time_t currenttime = time(NULL);
79 
80  // for NEXTPHASE state world events, return the delay to start the next event, so the followup event will be checked correctly
81  if ((mGameEvent[entry].state == GAMEEVENT_WORLD_NEXTPHASE || mGameEvent[entry].state == GAMEEVENT_WORLD_FINISHED) && mGameEvent[entry].nextstart >= currenttime)
82  return uint32(mGameEvent[entry].nextstart - currenttime);
83 
84  // for CONDITIONS state world events, return the length of the wait period, so if the conditions are met, this check will be called again to set the timer as NEXTPHASE event
85  if (mGameEvent[entry].state == GAMEEVENT_WORLD_CONDITIONS)
86  {
87  if (mGameEvent[entry].length)
88  return mGameEvent[entry].length * 60;
89  else
90  return max_ge_check_delay;
91  }
92 
93  // outdated event: we return max
94  if (currenttime > mGameEvent[entry].end)
95  return max_ge_check_delay;
96 
97  // never started event, we return delay before start
98  if (mGameEvent[entry].start > currenttime)
99  return uint32(mGameEvent[entry].start - currenttime);
100 
101  uint32 delay;
102  // in event, we return the end of it
103  if ((((currenttime - mGameEvent[entry].start) % (mGameEvent[entry].occurence * 60)) < (mGameEvent[entry].length * 60)))
104  // we return the delay before it ends
105  delay = (mGameEvent[entry].length * MINUTE) - ((currenttime - mGameEvent[entry].start) % (mGameEvent[entry].occurence * MINUTE));
106  else // not in window, we return the delay before next start
107  delay = (mGameEvent[entry].occurence * MINUTE) - ((currenttime - mGameEvent[entry].start) % (mGameEvent[entry].occurence * MINUTE));
108  // In case the end is before next check
109  if (mGameEvent[entry].end < time_t(currenttime + delay))
110  return uint32(mGameEvent[entry].end - currenttime);
111  else
112  return delay;
113 }
GameEventDataMap mGameEvent
Definition: GameEventMgr.h:172
#define max_ge_check_delay
Definition: GameEventMgr.h:27
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: GameEventMgr.h:33
Definition: Common.h:97
Definition: GameEventMgr.h:35
uint32_t uint32
Definition: Define.h:150
float length(float v)
Definition: vectorMath.h:208
Definition: GameEventMgr.h:34
uint32_t uint32
Definition: g3dmath.h:168

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameEventMgr::RemoveActiveEvent ( uint16  event_id)
inlineprivate
129 { m_ActiveEvents.erase(event_id); }
ActiveEvents m_ActiveEvents
Definition: GameEventMgr.h:176

+ Here is the caller graph for this function:

void GameEventMgr::RunSmartAIScripts ( uint16  event_id,
bool  activate 
)
private

Iterate over every supported source type (creature and gameobject) Not entirely sure how this will affect units in non-loaded grids.

1650 {
1653  sMapMgr->DoForAllMaps([event_id, activate](Map* map)
1654  {
1655  GameEventAIHookWorker worker(event_id, activate);
1657  visitor.Visit(map->GetObjectsStore());
1658  });
1659 }
Definition: TypeContainerVisitor.h:32
Definition: GameEventMgr.cpp:1622
MapStoredObjectTypesContainer & GetObjectsStore()
Definition: Map.h:466
Definition: Map.h:259
#define sMapMgr
Definition: MapManager.h:194

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameEventMgr::SaveWorldEventStateToDB ( uint16  event_id)
private
1595 {
1597 
1599  stmt->setUInt8(0, uint8(event_id));
1600  trans->Append(stmt);
1601 
1603  stmt->setUInt8(0, uint8(event_id));
1604  stmt->setUInt8(1, mGameEvent[event_id].state);
1605  stmt->setUInt32(2, mGameEvent[event_id].nextstart ? uint32(mGameEvent[event_id].nextstart) : 0);
1606  trans->Append(stmt);
1608 }
GameEventDataMap mGameEvent
Definition: GameEventMgr.h:172
Definition: CharacterDatabase.h:245
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
Definition: PreparedStatement.h:74
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
Definition: CharacterDatabase.h:244
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
uint8_t uint8
Definition: g3dmath.h:164
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
uint32_t uint32
Definition: g3dmath.h:168
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameEventMgr::SendWorldStateUpdate ( Player player,
uint16  event_id 
)
private
1611 {
1612  GameEventConditionMap::const_iterator itr;
1613  for (itr = mGameEvent[event_id].conditions.begin(); itr !=mGameEvent[event_id].conditions.end(); ++itr)
1614  {
1615  if (itr->second.done_world_state)
1616  player->SendUpdateWorldState(itr->second.done_world_state, (uint32)(itr->second.done));
1617  if (itr->second.max_world_state)
1618  player->SendUpdateWorldState(itr->second.max_world_state, (uint32)(itr->second.reqNum));
1619  }
1620 }
GameEventDataMap mGameEvent
Definition: GameEventMgr.h:172
uint32_t uint32
Definition: Define.h:150
void GameEventMgr::StartArenaSeason ( )
975 {
976  uint8 season = sWorld->getIntConfig(CONFIG_ARENA_SEASON_ID);
977  QueryResult result = WorldDatabase.PQuery("SELECT eventEntry FROM game_event_arena_seasons WHERE season = '%i'", season);
978 
979  if (!result)
980  {
981  TC_LOG_ERROR("gameevent", "ArenaSeason (%u) must be an existant Arena Season", season);
982  return;
983  }
984 
985  Field* fields = result->Fetch();
986  uint16 eventId = fields[0].GetUInt8();
987 
988  if (eventId >= mGameEvent.size())
989  {
990  TC_LOG_ERROR("gameevent", "EventEntry %u for ArenaSeason (%u) does not exists", eventId, season);
991  return;
992  }
993 
994  StartEvent(eventId, true);
995  TC_LOG_INFO("gameevent", "Arena Season %u started...", season);
996 
997 }
bool StartEvent(uint16 event_id, bool overwrite=false)
Definition: GameEventMgr.cpp:129
GameEventDataMap mGameEvent
Definition: GameEventMgr.h:172
QueryResult PQuery(Format &&sql, T *conn, Args &&...args)
Definition: DatabaseWorkerPool.h:165
Class used to access individual fields of database query result.
Definition: Field.h:56
WorldDatabaseWorkerPool WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
#define sWorld
Definition: World.h:887
uint8 GetUInt8() const
Definition: Field.h:70
Definition: World.h:309
std::shared_ptr< ResultSet > QueryResult
Definition: QueryResult.h:61
uint16_t uint16
Definition: Define.h:151
uint8_t uint8
Definition: Define.h:152
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the call graph for this function:

bool GameEventMgr::StartEvent ( uint16  event_id,
bool  overwrite = false 
)
130 {
131  GameEventData &data = mGameEvent[event_id];
132  if (data.state == GAMEEVENT_NORMAL || data.state == GAMEEVENT_INTERNAL)
133  {
134  AddActiveEvent(event_id);
135  ApplyNewEvent(event_id);
136  if (overwrite)
137  {
138  mGameEvent[event_id].start = time(NULL);
139  if (data.end <= data.start)
140  data.end = data.start + data.length;
141  }
142  return false;
143  }
144  else
145  {
146  if (data.state == GAMEEVENT_WORLD_INACTIVE)
147  // set to conditions phase
149 
150  // add to active events
151  AddActiveEvent(event_id);
152  // add spawns
153  ApplyNewEvent(event_id);
154 
155  // check if can go to next state
156  bool conditions_met = CheckOneGameEventConditions(event_id);
157  // save to db
158  SaveWorldEventStateToDB(event_id);
159  // force game event update to set the update timer if conditions were met from a command
160  // this update is needed to possibly start events dependent on the started one
161  // or to scedule another update where the next event will be started
162  if (overwrite && conditions_met)
163  sWorld->ForceGameEventUpdate();
164 
165  return conditions_met;
166  }
167 }
Definition: GameEventMgr.h:36
GameEventDataMap mGameEvent
Definition: GameEventMgr.h:172
arena_t NULL
Definition: jemalloc_internal.h:624
#define sWorld
Definition: World.h:887
Definition: GameEventMgr.h:33
time_t end
Definition: GameEventMgr.h:61
uint32 length
Definition: GameEventMgr.h:64
void SaveWorldEventStateToDB(uint16 event_id)
Definition: GameEventMgr.cpp:1594
Definition: GameEventMgr.h:31
void AddActiveEvent(uint16 event_id)
Definition: GameEventMgr.h:128
GameEventState state
Definition: GameEventMgr.h:66
bool CheckOneGameEventConditions(uint16 event_id)
Runs SMART_EVENT_GAME_EVENT_START/_END SAI.
Definition: GameEventMgr.cpp:1577
Definition: GameEventMgr.h:32
void ApplyNewEvent(uint16 event_id)
Definition: GameEventMgr.cpp:1092
Definition: GameEventMgr.h:56
time_t start
Definition: GameEventMgr.h:60

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameEventMgr::StartInternalEvent ( uint16  event_id)
116 {
117  if (event_id < 1 || event_id >= mGameEvent.size())
118  return;
119 
120  if (!mGameEvent[event_id].isValid())
121  return;
122 
123  if (m_ActiveEvents.find(event_id) != m_ActiveEvents.end())
124  return;
125 
126  StartEvent(event_id);
127 }
bool StartEvent(uint16 event_id, bool overwrite=false)
Definition: GameEventMgr.cpp:129
GameEventDataMap mGameEvent
Definition: GameEventMgr.h:172
ActiveEvents m_ActiveEvents
Definition: GameEventMgr.h:176

+ Here is the call graph for this function:

uint32 GameEventMgr::StartSystem ( )
967 {
968  m_ActiveEvents.clear();
969  uint32 delay = Update();
970  isSystemInit = true;
971  return delay;
972 }
ActiveEvents m_ActiveEvents
Definition: GameEventMgr.h:176
uint32_t uint32
Definition: Define.h:150
bool isSystemInit
Definition: GameEventMgr.h:178
uint32 Update()
Definition: GameEventMgr.cpp:999

+ Here is the call graph for this function:

void GameEventMgr::StopEvent ( uint16  event_id,
bool  overwrite = false 
)
170 {
171  GameEventData &data = mGameEvent[event_id];
172  bool serverwide_evt = data.state != GAMEEVENT_NORMAL && data.state != GAMEEVENT_INTERNAL;
173 
174  RemoveActiveEvent(event_id);
175  UnApplyEvent(event_id);
176 
177  if (overwrite && !serverwide_evt)
178  {
179  data.start = time(NULL) - data.length * MINUTE;
180  if (data.end <= data.start)
181  data.end = data.start + data.length;
182  }
183  else if (serverwide_evt)
184  {
185  // if finished world event, then only gm command can stop it
186  if (overwrite || data.state != GAMEEVENT_WORLD_FINISHED)
187  {
188  // reset conditions
189  data.nextstart = 0;
191  GameEventConditionMap::iterator itr;
192  for (itr = data.conditions.begin(); itr != data.conditions.end(); ++itr)
193  itr->second.done = 0;
194 
197  stmt->setUInt8(0, uint8(event_id));
198  trans->Append(stmt);
199 
201  stmt->setUInt8(0, uint8(event_id));
202  trans->Append(stmt);
203 
205  }
206  }
207 }
Definition: GameEventMgr.h:36
GameEventDataMap mGameEvent
Definition: GameEventMgr.h:172
Definition: CharacterDatabase.h:247
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
arena_t NULL
Definition: jemalloc_internal.h:624
GameEventConditionMap conditions
Definition: GameEventMgr.h:67
time_t end
Definition: GameEventMgr.h:61
uint32 length
Definition: GameEventMgr.h:64
Definition: PreparedStatement.h:74
Definition: Common.h:97
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
Definition: GameEventMgr.h:35
Definition: CharacterDatabase.h:244
time_t nextstart
Definition: GameEventMgr.h:62
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
Definition: GameEventMgr.h:31
GameEventState state
Definition: GameEventMgr.h:66
uint8_t uint8
Definition: g3dmath.h:164
Definition: GameEventMgr.h:32
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: GameEventMgr.h:56
void UnApplyEvent(uint16 event_id)
Definition: GameEventMgr.cpp:1069
void RemoveActiveEvent(uint16 event_id)
Definition: GameEventMgr.h:129
time_t start
Definition: GameEventMgr.h:60
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameEventMgr::UnApplyEvent ( uint16  event_id)
private

Run SAI scripts with SMART_EVENT_GAME_EVENT_END

1070 {
1071  TC_LOG_INFO("gameevent", "GameEvent %u \"%s\" removed.", event_id, mGameEvent[event_id].description.c_str());
1073  RunSmartAIScripts(event_id, false);
1074  // un-spawn positive event tagged objects
1075  GameEventUnspawn(event_id);
1076  // spawn negative event tagget objects
1077  int16 event_nid = (-1) * event_id;
1078  GameEventSpawn(event_nid);
1079  // restore equipment or model
1080  ChangeEquipOrModel(event_id, false);
1081  // Remove quests that are events only to non event npc
1082  UpdateEventQuests(event_id, false);
1083  UpdateWorldStates(event_id, false);
1084  // update npcflags in this event
1085  UpdateEventNPCFlags(event_id);
1086  // remove vendor items
1087  UpdateEventNPCVendor(event_id, false);
1088  // update bg holiday
1090 }
GameEventDataMap mGameEvent
Definition: GameEventMgr.h:172
void UpdateEventNPCVendor(uint16 event_id, bool activate)
Definition: GameEventMgr.cpp:1164
void GameEventUnspawn(int16 event_id)
Definition: GameEventMgr.cpp:1250
void UpdateWorldStates(uint16 event_id, bool Activate)
Definition: GameEventMgr.cpp:1499
void RunSmartAIScripts(uint16 event_id, bool activate)
Definition: GameEventMgr.cpp:1649
void ChangeEquipOrModel(int16 event_id, bool activate)
Definition: GameEventMgr.cpp:1326
void GameEventSpawn(int16 event_id)
Definition: GameEventMgr.cpp:1175
void UpdateEventQuests(uint16 event_id, bool activate)
Definition: GameEventMgr.cpp:1444
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
void UpdateBattlegroundSettings()
Definition: GameEventMgr.cpp:1156
int16_t int16
Definition: Define.h:147
void UpdateEventNPCFlags(uint16 event_id)
Definition: GameEventMgr.cpp:1123

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 GameEventMgr::Update ( )
1000 {
1001  time_t currenttime = time(NULL);
1002  uint32 nextEventDelay = max_ge_check_delay; // 1 day
1003  uint32 calcDelay;
1004  std::set<uint16> activate, deactivate;
1005  for (uint16 itr = 1; itr < mGameEvent.size(); ++itr)
1006  {
1007  // must do the activating first, and after that the deactivating
1008  // so first queue it
1009  //TC_LOG_ERROR("sql.sql", "Checking event %u", itr);
1010  if (CheckOneGameEvent(itr))
1011  {
1012  // if the world event is in NEXTPHASE state, and the time has passed to finish this event, then do so
1013  if (mGameEvent[itr].state == GAMEEVENT_WORLD_NEXTPHASE && mGameEvent[itr].nextstart <= currenttime)
1014  {
1015  // set this event to finished, null the nextstart time
1016  mGameEvent[itr].state = GAMEEVENT_WORLD_FINISHED;
1017  mGameEvent[itr].nextstart = 0;
1018  // save the state of this gameevent
1020  // queue for deactivation
1021  if (IsActiveEvent(itr))
1022  deactivate.insert(itr);
1023  // go to next event, this no longer needs an event update timer
1024  continue;
1025  }
1026  else if (mGameEvent[itr].state == GAMEEVENT_WORLD_CONDITIONS && CheckOneGameEventConditions(itr))
1027  // changed, save to DB the gameevent state, will be updated in next update cycle
1029 
1030  //TC_LOG_DEBUG("misc", "GameEvent %u is active", itr->first);
1031  // queue for activation
1032  if (!IsActiveEvent(itr))
1033  activate.insert(itr);
1034  }
1035  else
1036  {
1037  //TC_LOG_DEBUG("misc", "GameEvent %u is not active", itr->first);
1038  if (IsActiveEvent(itr))
1039  deactivate.insert(itr);
1040  else
1041  {
1042  if (!isSystemInit)
1043  {
1044  int16 event_nid = (-1) * (itr);
1045  // spawn all negative ones for this event
1046  GameEventSpawn(event_nid);
1047  }
1048  }
1049  }
1050  calcDelay = NextCheck(itr);
1051  if (calcDelay < nextEventDelay)
1052  nextEventDelay = calcDelay;
1053  }
1054  // now activate the queue
1055  // a now activated event can contain a spawn of a to-be-deactivated one
1056  // following the activate - deactivate order, deactivating the first event later will leave the spawn in (wont disappear then reappear clientside)
1057  for (std::set<uint16>::iterator itr = activate.begin(); itr != activate.end(); ++itr)
1058  // start the event
1059  // returns true the started event completed
1060  // in that case, initiate next update in 1 second
1061  if (StartEvent(*itr))
1062  nextEventDelay = 0;
1063  for (std::set<uint16>::iterator itr = deactivate.begin(); itr != deactivate.end(); ++itr)
1064  StopEvent(*itr);
1065  TC_LOG_INFO("gameevent", "Next game event check in %u seconds.", nextEventDelay + 1);
1066  return (nextEventDelay + 1) * IN_MILLISECONDS; // Add 1 second to be sure event has started/stopped at next call
1067 }
bool StartEvent(uint16 event_id, bool overwrite=false)
Definition: GameEventMgr.cpp:129
bool CheckOneGameEvent(uint16 entry) const
Definition: GameEventMgr.cpp:38
uint32 NextCheck(uint16 entry) const
Definition: GameEventMgr.cpp:76
GameEventDataMap mGameEvent
Definition: GameEventMgr.h:172
#define max_ge_check_delay
Definition: GameEventMgr.h:27
bool IsActiveEvent(uint16 event_id)
Definition: GameEventMgr.h:114
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: GameEventMgr.h:33
void StopEvent(uint16 event_id, bool overwrite=false)
Definition: GameEventMgr.cpp:169
Definition: GameEventMgr.h:35
uint32_t uint32
Definition: Define.h:150
uint16_t uint16
Definition: Define.h:151
void SaveWorldEventStateToDB(uint16 event_id)
Definition: GameEventMgr.cpp:1594
bool isSystemInit
Definition: GameEventMgr.h:178
Definition: GameEventMgr.h:34
void GameEventSpawn(int16 event_id)
Definition: GameEventMgr.cpp:1175
Definition: Common.h:103
bool CheckOneGameEventConditions(uint16 event_id)
Runs SMART_EVENT_GAME_EVENT_START/_END SAI.
Definition: GameEventMgr.cpp:1577
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
int16_t int16
Definition: Define.h:147

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameEventMgr::UpdateBattlegroundSettings ( )
private
1157 {
1158  uint32 mask = 0;
1159  for (ActiveEvents::const_iterator itr = m_ActiveEvents.begin(); itr != m_ActiveEvents.end(); ++itr)
1160  mask |= mGameEventBattlegroundHolidays[*itr];
1161  sBattlegroundMgr->SetHolidayWeekends(mask);
1162 }
ActiveEvents m_ActiveEvents
Definition: GameEventMgr.h:176
uint32_t uint32
Definition: Define.h:150
GameEventBitmask mGameEventBattlegroundHolidays
Definition: GameEventMgr.h:173
#define sBattlegroundMgr
Definition: BattlegroundMgr.h:181

+ Here is the caller graph for this function:

void GameEventMgr::UpdateEventNPCFlags ( uint16  event_id)
private
1124 {
1125  std::unordered_map<uint32, std::unordered_set<ObjectGuid::LowType>> creaturesByMap;
1126 
1127  // go through the creatures whose npcflags are changed in the event
1128  for (NPCFlagList::iterator itr = mGameEventNPCFlags[event_id].begin(); itr != mGameEventNPCFlags[event_id].end(); ++itr)
1129  // get the creature data from the low guid to get the entry, to be able to find out the whole guid
1130  if (CreatureData const* data = sObjectMgr->GetCreatureData(itr->first))
1131  creaturesByMap[data->mapid].insert(itr->first);
1132 
1133  for (auto const& p : creaturesByMap)
1134  {
1135  sMapMgr->DoForAllMapsWithMapId(p.first, [this, &p](Map* map)
1136  {
1137  for (auto& spawnId : p.second)
1138  {
1139  auto creatureBounds = map->GetCreatureBySpawnIdStore().equal_range(spawnId);
1140  for (auto itr = creatureBounds.first; itr != creatureBounds.second; ++itr)
1141  {
1142  Creature* creature = itr->second;
1143  uint32 npcflag = GetNPCFlag(creature);
1144  if (CreatureTemplate const* creatureTemplate = creature->GetCreatureTemplate())
1145  npcflag |= creatureTemplate->npcflag;
1146 
1147  creature->SetUInt64Value(UNIT_NPC_FLAGS, npcflag);
1148  // reset gossip options, since the flag change might have added / removed some
1149  //cr->ResetGossipOptions();
1150  }
1151  }
1152  });
1153  }
1154 }
Definition: Creature.h:287
GameEventNPCFlagMap mGameEventNPCFlags
Definition: GameEventMgr.h:175
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: Map.h:259
#define sMapMgr
Definition: MapManager.h:194

+ Here is the caller graph for this function:

void GameEventMgr::UpdateEventNPCVendor ( uint16  event_id,
bool  activate 
)
private
1165 {
1166  for (NPCVendorList::iterator itr = mGameEventVendors[event_id].begin(); itr != mGameEventVendors[event_id].end(); ++itr)
1167  {
1168  if (activate)
1169  sObjectMgr->AddVendorItem(itr->entry, itr->item, itr->maxcount, itr->incrtime, itr->ExtendedCost, itr->Type, false);
1170  else
1171  sObjectMgr->RemoveVendorItem(itr->entry, itr->item, itr->Type, false);
1172  }
1173 }
GameEventNPCVendorMap mGameEventVendors
Definition: GameEventMgr.h:167
#define sObjectMgr
Definition: ObjectMgr.h:1567

+ Here is the caller graph for this function:

void GameEventMgr::UpdateEventQuests ( uint16  event_id,
bool  activate 
)
private
1445 {
1446  QuestRelList::iterator itr;
1447  for (itr = mGameEventCreatureQuests[event_id].begin(); itr != mGameEventCreatureQuests[event_id].end(); ++itr)
1448  {
1449  QuestRelations* CreatureQuestMap = sObjectMgr->GetCreatureQuestRelationMap();
1450  if (activate) // Add the pair(id, quest) to the multimap
1451  CreatureQuestMap->insert(QuestRelations::value_type(itr->first, itr->second));
1452  else
1453  {
1454  if (!hasCreatureQuestActiveEventExcept(itr->second, event_id))
1455  {
1456  // Remove the pair(id, quest) from the multimap
1457  QuestRelations::iterator qitr = CreatureQuestMap->find(itr->first);
1458  if (qitr == CreatureQuestMap->end())
1459  continue;
1460  QuestRelations::iterator lastElement = CreatureQuestMap->upper_bound(itr->first);
1461  for (; qitr != lastElement; ++qitr)
1462  {
1463  if (qitr->second == itr->second)
1464  {
1465  CreatureQuestMap->erase(qitr); // iterator is now no more valid
1466  break; // but we can exit loop since the element is found
1467  }
1468  }
1469  }
1470  }
1471  }
1472  for (itr = mGameEventGameObjectQuests[event_id].begin(); itr != mGameEventGameObjectQuests[event_id].end(); ++itr)
1473  {
1474  QuestRelations* GameObjectQuestMap = sObjectMgr->GetGOQuestRelationMap();
1475  if (activate) // Add the pair(id, quest) to the multimap
1476  GameObjectQuestMap->insert(QuestRelations::value_type(itr->first, itr->second));
1477  else
1478  {
1479  if (!hasGameObjectQuestActiveEventExcept(itr->second, event_id))
1480  {
1481  // Remove the pair(id, quest) from the multimap
1482  QuestRelations::iterator qitr = GameObjectQuestMap->find(itr->first);
1483  if (qitr == GameObjectQuestMap->end())
1484  continue;
1485  QuestRelations::iterator lastElement = GameObjectQuestMap->upper_bound(itr->first);
1486  for (; qitr != lastElement; ++qitr)
1487  {
1488  if (qitr->second == itr->second)
1489  {
1490  GameObjectQuestMap->erase(qitr); // iterator is now no more valid
1491  break; // but we can exit loop since the element is found
1492  }
1493  }
1494  }
1495  }
1496  }
1497 }
bool hasCreatureQuestActiveEventExcept(uint32 quest_id, uint16 event_id)
Definition: GameEventMgr.cpp:1384
#define sObjectMgr
Definition: ObjectMgr.h:1567
std::multimap< uint32, uint32 > QuestRelations
Definition: ObjectMgr.h:440
bool hasGameObjectQuestActiveEventExcept(uint32 quest_id, uint16 event_id)
Definition: GameEventMgr.cpp:1398
GameEventQuestMap mGameEventGameObjectQuests
Definition: GameEventMgr.h:166
GameEventQuestMap mGameEventCreatureQuests
Definition: GameEventMgr.h:165

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameEventMgr::UpdateWorldStates ( uint16  event_id,
bool  Activate 
)
private
1500 {
1501  GameEventData const& event = mGameEvent[event_id];
1502  if (event.holiday_id != HOLIDAY_NONE)
1503  {
1505  if (bgTypeId != BATTLEGROUND_TYPE_NONE)
1506  {
1507  BattlemasterListEntry const* bl = sBattlemasterListStore.LookupEntry(bgTypeId);
1508  if (bl && bl->HolidayWorldState)
1509  {
1511  worldstate.VariableID = bl->HolidayWorldState;
1512  worldstate.Value = Activate;
1513  //worldstate.Hidden = false;
1514  sWorld->SendGlobalMessage(worldstate.Write());
1515  }
1516  }
1517  }
1518 }
uint32 VariableID
Definition: WorldStatePackets.h:59
Definition: WorldStatePackets.h:50
GameEventDataMap mGameEvent
Definition: GameEventMgr.h:172
BattlegroundTypeId
Definition: SharedDefines.h:4558
Definition: SharedDefines.h:3716
DBCStorage< BattlemasterListEntry > sBattlemasterListStore(BattlemasterListfmt)
#define sWorld
Definition: World.h:887
int32 Value
Definition: WorldStatePackets.h:57
uint32 HolidayWorldState
Definition: DBCStructure.h:122
static BattlegroundTypeId WeekendHolidayIdToBGType(HolidayIds holiday)
Definition: BattlegroundMgr.cpp:840
Definition: SharedDefines.h:4560
Definition: GameEventMgr.h:56
WorldPacket const * Write() override
Definition: WorldStatePackets.cpp:44
Definition: DBCStructure.h:114

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

std::unordered_map<uint32, uint16> GameEventMgr::_questToEventLinks
private
bool GameEventMgr::isSystemInit
private
ActiveEvents GameEventMgr::m_ActiveEvents
private
GameEventDataMap GameEventMgr::mGameEvent
private
GameEventBitmask GameEventMgr::mGameEventBattlegroundHolidays
private
GameEventGuidMap GameEventMgr::mGameEventCreatureGuids
GameEventQuestMap GameEventMgr::mGameEventCreatureQuests
private
GameEventGuidMap GameEventMgr::mGameEventGameobjectGuids
GameEventQuestMap GameEventMgr::mGameEventGameObjectQuests
private
GameEventModelEquipMap GameEventMgr::mGameEventModelEquip
private
GameEventNPCFlagMap GameEventMgr::mGameEventNPCFlags
private
GameEventIdMap GameEventMgr::mGameEventPoolIds
private
GameEventNPCVendorMap GameEventMgr::mGameEventVendors
private
QuestIdToEventConditionMap GameEventMgr::mQuestToEventConditions
private

The documentation for this class was generated from the following files: