69 for (std::set<uint16>::const_iterator itr =
mGameEvent[entry].prerequisite_events.begin(); itr !=
mGameEvent[entry].prerequisite_events.end(); ++itr)
77 return !(
mGameEvent[entry].prerequisite_events.empty());
115 if (
mGameEvent[entry].end < time_t(currenttime + delay))
123 if (event_id < 1 || event_id >=
mGameEvent.size())
168 if (overwrite && conditions_met)
169 sWorld->ForceGameEventUpdate();
171 return conditions_met;
183 if (overwrite && !serverwide_evt)
189 else if (serverwide_evt)
197 GameEventConditionMap::iterator itr;
199 itr->second.done = 0;
220 QueryResult result =
WorldDatabase.Query(
"SELECT eventEntry, UNIX_TIMESTAMP(start_time), UNIX_TIMESTAMP(end_time), occurence, length, holiday, holidayStage, description, world_event, announce FROM game_event");
224 TC_LOG_INFO(
"server.loading",
">> Loaded 0 game events. DB table `game_event` is empty.");
231 Field* fields = result->Fetch();
236 TC_LOG_ERROR(
"sql.sql",
"`game_event`: game event entry 0 is reserved and can't be used.");
242 pGameEvent.
start = time_t(starttime);
244 pGameEvent.
end = time_t(endtime);
258 TC_LOG_ERROR(
"sql.sql",
"`game_event`: game event id ({}) is not a world event and has length = 0, thus cannot be used.", event_id);
266 TC_LOG_ERROR(
"sql.sql",
"`game_event`: game event id ({}) contains nonexisting holiday id {}.", event_id, pGameEvent.
holiday_id);
272 TC_LOG_ERROR(
"sql.sql",
"`game_event` game event id ({}) has out of range holidayStage {}.", event_id, pGameEvent.
holidayStage);
281 while (result->NextRow());
287 TC_LOG_INFO(
"server.loading",
"Loading Game Event Saves Data...");
295 TC_LOG_INFO(
"server.loading",
">> Loaded 0 game event saves in game events. DB table `game_event_save` is empty.");
301 Field* fields = result->Fetch();
307 TC_LOG_ERROR(
"sql.sql",
"`game_event_save`: game event entry ({}) is out of range compared to max event entry in `game_event`.", event_id);
314 mGameEvent[event_id].nextstart = time_t(fields[2].GetUInt32());
318 TC_LOG_ERROR(
"sql.sql",
"game_event_save includes event save for non-worldevent id {}.", event_id);
324 while (result->NextRow());
331 TC_LOG_INFO(
"server.loading",
"Loading Game Event Prerequisite Data...");
338 TC_LOG_INFO(
"server.loading",
">> Loaded 0 game event prerequisites in game events. DB table `game_event_prerequisite` is empty.");
344 Field* fields = result->Fetch();
350 TC_LOG_ERROR(
"sql.sql",
"`game_event_prerequisite`: game event id ({}) is out of range compared to max event id in `game_event`.", event_id);
359 TC_LOG_ERROR(
"sql.sql",
"`game_event_prerequisite`: game event prerequisite id ({}) is out of range compared to max event id in `game_event`.", prerequisite_event);
362 mGameEvent[event_id].prerequisite_events.insert(prerequisite_event);
366 TC_LOG_ERROR(
"sql.sql",
"game_event_prerequisiste includes event entry for non-worldevent id {}.", event_id);
372 while (result->NextRow());
379 TC_LOG_INFO(
"server.loading",
"Loading Game Event Creature Data...");
387 TC_LOG_INFO(
"server.loading",
">> Loaded 0 creatures in game events. DB table `game_event_creature` is empty.");
393 Field* fields = result->Fetch();
403 TC_LOG_ERROR(
"sql.sql",
"`game_event_creature` contains creature (GUID: {}) not found in `creature` table.", guid);
409 TC_LOG_ERROR(
"sql.sql",
"`game_event_creature`: game event id ({}) is out of range compared to max event id in `game_event`.", event_id);
415 TC_LOG_ERROR(
"sql.sql",
"`game_event_creature`: game event id ({}) contains creature ({}) which is part of a pool ({}). This should be spawned in game_event_pool", event_id, guid, data->
poolId);
418 crelist.push_back(guid);
422 while (result->NextRow());
429 TC_LOG_INFO(
"server.loading",
"Loading Game Event GO Data...");
437 TC_LOG_INFO(
"server.loading",
">> Loaded 0 gameobjects in game events. DB table `game_event_gameobject` is empty.");
443 Field* fields = result->Fetch();
453 TC_LOG_ERROR(
"sql.sql",
"`game_event_gameobject` contains gameobject (GUID: {}) not found in `gameobject` table.", guid);
459 TC_LOG_ERROR(
"sql.sql",
"`game_event_gameobject`: game event id ({}) is out of range compared to max event id in `game_event`.", event_id);
465 TC_LOG_ERROR(
"sql.sql",
"`game_event_gameobject`: game event id ({}) contains game object ({}) which is part of a pool ({}). This should be spawned in game_event_pool", event_id, guid, data->
poolId);
468 golist.push_back(guid);
472 while (result->NextRow());
478 TC_LOG_INFO(
"server.loading",
"Loading Game Event Model/Equipment Change Data...");
483 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 "
484 "FROM creature JOIN game_event_model_equip ON creature.guid = game_event_model_equip.guid");
487 TC_LOG_INFO(
"server.loading",
">> Loaded 0 model/equipment changes in game events. DB table `game_event_model_equip` is empty.");
493 Field* fields = result->Fetch();
501 TC_LOG_ERROR(
"sql.sql",
"`game_event_model_equip`: game event id ({}) is out of range compared to max event id in `game_event`.", event_id);
515 if (!
sObjectMgr->GetEquipmentInfo(entry, equipId))
517 TC_LOG_ERROR(
"sql.sql",
"Table `game_event_model_equip` contains creature (Guid: {}, entry: {}) with equipment_id {} not found in table `creature_equip_template`. Setting entry to no equipment.",
523 equiplist.push_back(std::pair<ObjectGuid::LowType, ModelEquip>(guid, newModelEquipSet));
527 while (result->NextRow());
533 TC_LOG_INFO(
"server.loading",
"Loading Game Event Quest Data...");
541 TC_LOG_INFO(
"server.loading",
">> Loaded 0 quests additions in game events. DB table `game_event_creature_quest` is empty.");
547 Field* fields = result->Fetch();
555 TC_LOG_ERROR(
"sql.sql",
"`game_event_creature_quest`: game event id ({}) is out of range compared to max event id in `game_event`.", event_id);
564 while (result->NextRow());
570 TC_LOG_INFO(
"server.loading",
"Loading Game Event GO Quest Data...");
578 TC_LOG_INFO(
"server.loading",
">> Loaded 0 go quests additions in game events. DB table `game_event_gameobject_quest` is empty.");
584 Field* fields = result->Fetch();
592 TC_LOG_ERROR(
"sql.sql",
"`game_event_gameobject_quest`: game event id ({}) is out of range compared to max event id in `game_event`.", event_id);
601 while (result->NextRow());
607 TC_LOG_INFO(
"server.loading",
"Loading Game Event Quest Condition Data...");
612 QueryResult result =
WorldDatabase.Query(
"SELECT quest, eventEntry, condition_id, num FROM game_event_quest_condition");
615 TC_LOG_INFO(
"server.loading",
">> Loaded 0 quest event conditions in game events. DB table `game_event_quest_condition` is empty.");
621 Field* fields = result->Fetch();
630 TC_LOG_ERROR(
"sql.sql",
"`game_event_quest_condition`: game event id ({}) is out of range compared to max event id in `game_event`.", event_id);
640 while (result->NextRow());
646 TC_LOG_INFO(
"server.loading",
"Loading Game Event Condition Data...");
651 QueryResult result =
WorldDatabase.Query(
"SELECT eventEntry, condition_id, req_num, max_world_state_field, done_world_state_field FROM game_event_condition");
654 TC_LOG_INFO(
"server.loading",
">> Loaded 0 conditions in game events. DB table `game_event_condition` is empty.");
660 Field* fields = result->Fetch();
667 TC_LOG_ERROR(
"sql.sql",
"`game_event_condition`: game event id ({}) is out of range compared to max event id in `game_event`.", event_id);
672 mGameEvent[event_id].conditions[condition].done = 0;
678 while (result->NextRow());
684 TC_LOG_INFO(
"server.loading",
"Loading Game Event Condition Save Data...");
692 TC_LOG_INFO(
"server.loading",
">> Loaded 0 condition saves in game events. DB table `game_event_condition_save` is empty.");
698 Field* fields = result->Fetch();
705 TC_LOG_ERROR(
"sql.sql",
"`game_event_condition_save`: game event id ({}) is out of range compared to max event id in `game_event`.", event_id);
709 GameEventConditionMap::iterator itr =
mGameEvent[event_id].conditions.find(condition);
710 if (itr !=
mGameEvent[event_id].conditions.end())
712 itr->second.done = fields[2].
GetFloat();
716 TC_LOG_ERROR(
"sql.sql",
"game_event_condition_save contains not present condition event id {} condition id {}.", event_id, condition);
722 while (result->NextRow());
728 TC_LOG_INFO(
"server.loading",
"Loading Game Event NPCflag Data...");
736 TC_LOG_INFO(
"server.loading",
">> Loaded 0 npcflags in game events. DB table `game_event_npcflag` is empty.");
742 Field* fields = result->Fetch();
750 TC_LOG_ERROR(
"sql.sql",
"`game_event_npcflag`: game event id ({}) is out of range compared to max event id in `game_event`.", event_id);
758 while (result->NextRow());
764 TC_LOG_INFO(
"server.loading",
"Loading Game Event Seasonal Quest Relations...");
772 TC_LOG_INFO(
"server.loading",
">> Loaded 0 seasonal quests additions in game events. DB table `game_event_seasonal_questrelation` is empty.");
778 Field* fields = result->Fetch();
786 TC_LOG_ERROR(
"sql.sql",
"`game_event_seasonal_questrelation`: quest id ({}) does not exist in `quest_template`.", questId);
792 TC_LOG_ERROR(
"sql.sql",
"`game_event_seasonal_questrelation`: event id ({}) is out of range compared to max event in `game_event`.", eventEntry);
799 while (result->NextRow());
805 TC_LOG_INFO(
"server.loading",
"Loading Game Event Vendor Additions Data...");
810 QueryResult result =
WorldDatabase.Query(
"SELECT eventEntry, guid, item, maxcount, incrtime, ExtendedCost, type, BonusListIDs, PlayerConditionId, IgnoreFiltering FROM game_event_npc_vendor ORDER BY guid, slot ASC");
813 TC_LOG_INFO(
"server.loading",
">> Loaded 0 vendor additions in game events. DB table `game_event_npc_vendor` is empty.");
819 Field* fields = result->Fetch();
826 TC_LOG_ERROR(
"sql.sql",
"`game_event_npc_vendor`: game event id ({}) is out of range compared to max event id in `game_event`.", event_id);
831 uint32 event_npc_flag = 0;
833 for (NPCFlagList::const_iterator itr = flist.begin(); itr != flist.end(); ++itr)
835 if (itr->first == guid)
837 event_npc_flag = itr->second;
855 for (std::string_view token :
Trinity::Tokenize(fields[7].GetStringView(),
' ',
false))
860 if (!
sObjectMgr->IsVendorItemValid(entry, vItem,
nullptr,
nullptr, event_npc_flag))
864 vendors[entry].emplace_back(std::move(vItem));
868 while (result->NextRow());
874 TC_LOG_INFO(
"server.loading",
"Loading Game Event Pool Data...");
879 QueryResult result =
WorldDatabase.Query(
"SELECT pool_template.entry, game_event_pool.eventEntry FROM pool_template"
880 " JOIN game_event_pool ON pool_template.entry = game_event_pool.pool_entry");
883 TC_LOG_INFO(
"server.loading",
">> Loaded 0 pools for game events. DB table `game_event_pool` is empty.");
889 Field* fields = result->Fetch();
898 TC_LOG_ERROR(
"sql.sql",
"`game_event_pool`: game event id ({}) is out of range compared to max event id in `game_event`.", event_id);
904 TC_LOG_ERROR(
"sql.sql",
"Pool Id ({}) 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 poollist.push_back(entry);
913 while (result->NextRow());
930 if (itr->first == guid)
942 Field* fields = result->Fetch();
972 QueryResult result =
WorldDatabase.PQuery(
"SELECT eventEntry FROM game_event_arena_seasons WHERE season = '{}'", season);
976 TC_LOG_ERROR(
"gameevent",
"ArenaSeason ({}) must be an existing Arena Season.", season);
980 Field* fields = result->Fetch();
985 TC_LOG_ERROR(
"gameevent",
"EventEntry {} for ArenaSeason ({}) does not exist.", eventId, season);
990 TC_LOG_INFO(
"gameevent",
"Arena Season {} started...", season);
999 std::set<uint16> activate, deactivate;
1017 deactivate.insert(itr);
1028 activate.insert(itr);
1034 deactivate.insert(itr);
1039 int16 event_nid = (-1) * (itr);
1046 if (calcDelay < nextEventDelay)
1047 nextEventDelay = calcDelay;
1052 for (std::set<uint16>::iterator itr = activate.begin(); itr != activate.end(); ++itr)
1058 for (std::set<uint16>::iterator itr = deactivate.begin(); itr != deactivate.end(); ++itr)
1060 TC_LOG_INFO(
"gameevent",
"Next game event check in {} seconds.", nextEventDelay + 1);
1066 TC_LOG_INFO(
"gameevent",
"GameEvent {} \"{}\" removed.", event_id,
mGameEvent[event_id].description);
1072 int16 event_nid = (-1) * event_id;
1091 TC_LOG_INFO(
"gameevent",
"GameEvent {} \"{}\" started.", event_id,
mGameEvent[event_id].description);
1096 int16 event_nid = (-1) * event_id;
1117 std::unordered_map<uint32, std::unordered_set<ObjectGuid::LowType>> creaturesByMap;
1123 creaturesByMap[data->mapId].insert(itr->first);
1125 for (
auto const& p : creaturesByMap)
1127 sMapMgr->DoForAllMapsWithMapId(p.first, [
this, &p](
Map* map)
1129 for (auto& spawnId : p.second)
1131 auto creatureBounds = map->GetCreatureBySpawnIdStore().equal_range(spawnId);
1132 for (auto itr = creatureBounds.first; itr != creatureBounds.second; ++itr)
1134 Creature* creature = itr->second;
1135 uint64 npcflag = GetNPCFlag(creature);
1136 if (CreatureTemplate const* creatureTemplate = creature->GetCreatureTemplate())
1137 npcflag |= creatureTemplate->npcflag;
1139 creature->ReplaceAllNpcFlags(NPCFlags(npcflag & 0xFFFFFFFF));
1140 creature->ReplaceAllNpcFlags2(NPCFlags2(npcflag >> 32));
1156 sObjectMgr->AddVendorItem(itr->first, vItem,
false);
1169 TC_LOG_ERROR(
"gameevent",
"GameEventMgr::GameEventSpawn attempted access to out of range mGameEventCreatureGuids element {} (size: {}).",
1182 sMapMgr->DoForAllMapsWithMapId(data->mapId, [&itr, data](
Map* map)
1184 map->RemoveRespawnTime(SPAWN_TYPE_CREATURE, *itr);
1186 if (map->IsGridLoaded(data->spawnPoint))
1187 Creature::CreateCreatureFromDB(*itr, map);
1194 TC_LOG_ERROR(
"gameevent",
"GameEventMgr::GameEventSpawn attempted access to out of range mGameEventGameobjectGuids element {} (size: {}).",
1207 sMapMgr->DoForAllMapsWithMapId(data->mapId, [&itr, data](
Map* map)
1209 map->RemoveRespawnTime(SPAWN_TYPE_GAMEOBJECT, *itr);
1211 if (map->IsGridLoaded(data->spawnPoint))
1213 if (GameObject* go = GameObject::CreateGameObjectFromDB(*itr, map, false))
1216 if (go->isSpawnedByDefault())
1218 if (!map->AddToMap(go))
1227 if (internal_event_id >=
int32(mGameEventPoolIds.size()))
1229 TC_LOG_ERROR(
"gameevent",
"GameEventMgr::GameEventSpawn attempted access to out of range mGameEventPoolIds element {} (size: {}).",
1230 internal_event_id, mGameEventPoolIds.size());
1234 for (IdList::iterator itr = mGameEventPoolIds[internal_event_id].begin(); itr != mGameEventPoolIds[internal_event_id].end(); ++itr)
1238 sMapMgr->DoForAllMapsWithMapId(poolTemplate->MapId, [&itr](
Map* map)
1240 sPoolMgr->SpawnPool(map->GetPoolData(), *itr);
1252 TC_LOG_ERROR(
"gameevent",
"GameEventMgr::GameEventUnspawn attempted access to out of range mGameEventCreatureGuids element {} (size: {}).",
1267 sMapMgr->DoForAllMapsWithMapId(data->mapId, [&itr](
Map* map)
1269 map->RemoveRespawnTime(SPAWN_TYPE_CREATURE, *itr);
1270 auto creatureBounds = map->GetCreatureBySpawnIdStore().equal_range(*itr);
1271 for (auto itr2 = creatureBounds.first; itr2 != creatureBounds.second;)
1273 Creature* creature = itr2->second;
1275 creature->AddObjectToRemoveList();
1281 if (internal_event_id < 0 || internal_event_id >=
int32(mGameEventGameobjectGuids.size()))
1283 TC_LOG_ERROR(
"gameevent",
"GameEventMgr::GameEventUnspawn attempted access to out of range mGameEventGameobjectGuids element {} (size: {}).",
1284 internal_event_id, mGameEventGameobjectGuids.size());
1288 for (GuidList::iterator itr = mGameEventGameobjectGuids[internal_event_id].begin(); itr != mGameEventGameobjectGuids[internal_event_id].end(); ++itr)
1291 if (event_id >0 && hasGameObjectActiveEventExcept(*itr, event_id))
1298 sMapMgr->DoForAllMapsWithMapId(data->mapId, [&itr](
Map* map)
1300 map->RemoveRespawnTime(SPAWN_TYPE_GAMEOBJECT, *itr);
1301 auto gameobjectBounds = map->GetGameObjectBySpawnIdStore().equal_range(*itr);
1302 for (auto itr2 = gameobjectBounds.first; itr2 != gameobjectBounds.second;)
1304 GameObject* go = itr2->second;
1306 go->AddObjectToRemoveList();
1312 if (internal_event_id < 0 || internal_event_id >=
int32(mGameEventPoolIds.size()))
1314 TC_LOG_ERROR(
"gameevent",
"GameEventMgr::GameEventUnspawn attempted access to out of range mGameEventPoolIds element {} (size: {}).", internal_event_id, mGameEventPoolIds.size());
1318 for (IdList::iterator itr = mGameEventPoolIds[internal_event_id].begin(); itr != mGameEventPoolIds[internal_event_id].end(); ++itr)
1322 sMapMgr->DoForAllMapsWithMapId(poolTemplate->MapId, [&itr](
Map* map)
1324 sPoolMgr->DespawnPool(map->GetPoolData(), *itr, true);
1340 sMapMgr->DoForAllMapsWithMapId(data->
mapId, [&itr, activate](
Map* map)
1342 auto creatureBounds = map->GetCreatureBySpawnIdStore().equal_range(itr->first);
1343 for (auto itr2 = creatureBounds.first; itr2 != creatureBounds.second; ++itr2)
1345 Creature* creature = itr2->second;
1348 itr->second.equipement_id_prev = creature->GetCurrentEquipmentId();
1349 itr->second.modelid_prev = creature->GetDisplayId();
1350 creature->LoadEquipment(itr->second.equipment_id, true);
1351 if (itr->second.modelid > 0 && itr->second.modelid_prev != itr->second.modelid && sObjectMgr->GetCreatureModelInfo(itr->second.modelid))
1352 creature->SetDisplayId(itr->second.modelid, true);
1356 creature->LoadEquipment(itr->second.equipement_id_prev, true);
1357 if (itr->second.modelid_prev > 0 && itr->second.modelid_prev != itr->second.modelid && sObjectMgr->GetCreatureModelInfo(itr->second.modelid_prev))
1358 creature->SetDisplayId(itr->second.modelid_prev, true);
1367 itr->second.modelid_prev = data2.
display ? data2.
display->CreatureDisplayID : 0;
1368 itr->second.equipement_id_prev = data2.
equipmentId;
1369 if (itr->second.modelid)
1377 if (itr->second.modelid_prev)
1381 data2.
equipmentId = itr->second.equipement_id_prev;
1390 if ((*e_itr) != event_id)
1394 if (itr->second == quest_id)
1404 if ((*e_itr) != event_id)
1408 if (itr->second == quest_id)
1417 if ((*e_itr) != event_id)
1423 if (*itr == creature_id)
1433 if ((*e_itr) != event_id)
1448 QuestRelList::iterator itr;
1453 CreatureQuestMap->insert(QuestRelations::value_type(itr->first, itr->second));
1459 QuestRelations::iterator qitr = CreatureQuestMap->find(itr->first);
1460 if (qitr == CreatureQuestMap->end())
1462 QuestRelations::iterator lastElement = CreatureQuestMap->upper_bound(itr->first);
1463 for (; qitr != lastElement; ++qitr)
1465 if (qitr->second == itr->second)
1467 CreatureQuestMap->erase(qitr);
1478 GameObjectQuestMap->insert(QuestRelations::value_type(itr->first, itr->second));
1484 QuestRelations::iterator qitr = GameObjectQuestMap->find(itr->first);
1485 if (qitr == GameObjectQuestMap->end())
1487 QuestRelations::iterator lastElement = GameObjectQuestMap->upper_bound(itr->first);
1488 for (; qitr != lastElement; ++qitr)
1490 if (qitr->second == itr->second)
1492 GameObjectQuestMap->erase(qitr);
1506 if (bl->HolidayWorldState)
1507 sWorldStateMgr->SetValue(bl->HolidayWorldState, Activate ? 1 : 0,
false,
nullptr);
1525 uint16 event_id = itr->second.event_id;
1526 uint32 condition = itr->second.condition;
1527 float num = itr->second.num;
1535 GameEventConditionMap::iterator citr =
mGameEvent[event_id].conditions.find(condition);
1537 if (citr !=
mGameEvent[event_id].conditions.end())
1540 if (citr->second.done < citr->second.reqNum)
1542 citr->second.done += num;
1544 if (citr->second.done > citr->second.reqNum)
1545 citr->second.done = citr->second.reqNum;
1552 trans->Append(stmt);
1557 stmt->
setFloat(2, citr->second.done);
1558 trans->Append(stmt);
1566 sWorld->ForceGameEventUpdate();
1575 for (GameEventConditionMap::const_iterator itr =
mGameEvent[event_id].conditions.begin(); itr !=
mGameEvent[event_id].conditions.end(); ++itr)
1576 if (itr->second.done < itr->second.reqNum)
1596 trans->Append(stmt);
1602 trans->Append(stmt);
1608 GameEventConditionMap::const_iterator itr;
1609 for (itr =
mGameEvent[event_id].conditions.begin(); itr !=
mGameEvent[event_id].conditions.end(); ++itr)
1611 if (itr->second.done_world_state)
1613 if (itr->second.max_world_state)
1623 void Visit(std::unordered_map<ObjectGuid, Creature*>& creatureMap)
1625 for (
auto const& p : creatureMap)
1626 if (p.second->IsInWorld() && p.second->IsAIEnabled())
1630 void Visit(std::unordered_map<ObjectGuid, GameObject*>& gameObjectMap)
1632 for (
auto const& p : gameObjectMap)
1633 if (p.second->IsInWorld())
1638 void Visit(std::unordered_map<ObjectGuid, T*>&) { }
1649 sMapMgr->DoForAllMaps([event_id, activate](
Map* map)
1669 uint8 stageIndex =
event.holidayStage - 1;
1672 time_t stageOffset = 0;
1673 for (
uint8 i = 0; i < stageIndex; ++i)
1692 event.occurence = 0;
1697 bool singleDate = ((holiday->
Date[0] >> 24) & 0x1F) == 31;
1707 localtime_r(&curTime, &timeInfo);
1708 timeInfo.tm_year -= 1;
1711 timeInfo.tm_year = ((date >> 24) & 0x1F) + 100;
1713 timeInfo.tm_mon = (date >> 20) & 0xF;
1714 timeInfo.tm_mday = ((date >> 14) & 0x3F) + 1;
1715 timeInfo.tm_hour = (date >> 6) & 0x1F;
1716 timeInfo.tm_min = date & 0x3F;
1717 timeInfo.tm_sec = 0;
1718 timeInfo.tm_wday = 0;
1719 timeInfo.tm_yday = 0;
1720 timeInfo.tm_isdst = -1;
1723 time_t startTime = mktime(&timeInfo);
1726 event.start = startTime + stageOffset;
1729 else if (singleDate)
1732 localtime_r(&curTime, &tmCopy);
1733 int year = tmCopy.tm_year;
1735 tmCopy.tm_year = year;
1737 event.start = mktime(&tmCopy) + stageOffset;
1759 SystemTimePoint::duration durationSinceLastStart = (now - eventInitialStart) % occurence;
1760 return std::chrono::system_clock::to_time_t(now - durationSinceLastStart);
1771 for (GameEventMgr::ActiveEvents::const_iterator itr = ae.begin(); itr != ae.end(); ++itr)
1772 if (events[*itr].holiday_id ==
id)
1781 return ae.find(eventId) != ae.end();
@ CHAR_DEL_GAME_EVENT_SAVE
@ CHAR_DEL_ALL_GAME_EVENT_CONDITION_SAVE
@ CHAR_INS_GAME_EVENT_SAVE
@ CHAR_DEL_GAME_EVENT_CONDITION_SAVE
@ CHAR_INS_GAME_EVENT_CONDITION_SAVE
DB2Storage< BattlemasterListEntry > sBattlemasterListStore("BattlemasterList.db2", &BattlemasterListLoadInfo::Instance)
DB2Storage< HolidaysEntry > sHolidaysStore("Holidays.db2", &HolidaysLoadInfo::Instance)
#define MAX_HOLIDAY_DURATIONS
#define MAX_HOLIDAY_DATES
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
std::shared_ptr< ResultSet > QueryResult
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
std::chrono::system_clock::time_point SystemTimePoint
std::chrono::minutes Minutes
Minutes shorthand typedef.
bool IsHolidayActive(HolidayIds id)
bool IsEventActive(uint16 eventId)
#define max_ge_check_delay
@ GAMEEVENT_WORLD_FINISHED
@ GAMEEVENT_WORLD_CONDITIONS
@ GAMEEVENT_WORLD_NEXTPHASE
@ GAMEEVENT_WORLD_INACTIVE
#define TC_LOG_ERROR(filterType__,...)
#define TC_LOG_INFO(filterType__,...)
#define DEFAULT_PLAYER_DISPLAY_SCALE
std::multimap< uint32, uint32 > QuestRelations
std::optional< T > Optional
Optional helper class to wrap optional values within.
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
static BattlegroundTypeId WeekendHolidayIdToBGType(HolidayIds holiday)
ObjectGuid::LowType GetSpawnId() const
Class used to access individual fields of database query result.
std::string GetString() const
void Visit(std::unordered_map< ObjectGuid, T * > &)
void Visit(std::unordered_map< ObjectGuid, Creature * > &creatureMap)
void Visit(std::unordered_map< ObjectGuid, GameObject * > &gameObjectMap)
GameEventAIHookWorker(uint16 eventId, bool activate)
static GameEventMgr * instance()
uint32 NextCheck(uint16 entry) const
void HandleQuestComplete(uint32 quest_id)
ActiveEvents m_ActiveEvents
bool StartEvent(uint16 event_id, bool overwrite=false)
GameEventDataMap mGameEvent
GameEventNPCFlagMap mGameEventNPCFlags
bool IsActiveEvent(uint16 event_id)
GameEventIdMap mGameEventPoolIds
std::vector< GameEventData > GameEventDataMap
void GameEventSpawn(int16 event_id)
void GameEventUnspawn(int16 event_id)
GameEventGuidMap mGameEventCreatureGuids
void RemoveActiveEvent(uint16 event_id)
void UnApplyEvent(uint16 event_id)
void UpdateEventQuests(uint16 event_id, bool activate)
void UpdateEventNPCVendor(uint16 event_id, bool activate)
void UpdateWorldStates(uint16 event_id, bool Activate)
bool hasCreatureActiveEventExcept(ObjectGuid::LowType creature_guid, uint16 event_id)
time_t GetLastStartTime(uint16 event_id) const
void AddActiveEvent(uint16 event_id)
void StartInternalEvent(uint16 event_id)
std::list< ObjectGuid::LowType > GuidList
void ApplyNewEvent(uint16 event_id)
std::pair< ObjectGuid::LowType, uint64 > GuidNPCFlagPair
GameEventModelEquipMap mGameEventModelEquip
std::list< ModelEquipPair > ModelEquipList
GameEventNPCVendorMap mGameEventVendors
GameEventQuestMap mGameEventCreatureQuests
GameEventGuidMap mGameEventGameobjectGuids
void SaveWorldEventStateToDB(uint16 event_id)
void UpdateEventNPCFlags(uint16 event_id)
bool CheckOneGameEventConditions(uint16 event_id)
void ChangeEquipOrModel(int16 event_id, bool activate)
void RunSmartAIScripts(uint16 event_id, bool activate)
Runs SMART_EVENT_GAME_EVENT_START/_END SAI.
std::set< uint16 > ActiveEvents
QuestIdToEventConditionMap mQuestToEventConditions
bool hasCreatureQuestActiveEventExcept(uint32 quest_id, uint16 event_id)
std::list< GuidNPCFlagPair > NPCFlagList
std::list< uint32 > IdList
GameEventQuestMap mGameEventGameObjectQuests
void SetHolidayEventTime(GameEventData &event)
std::list< QuestRelation > QuestRelList
void SendWorldStateUpdate(Player *player, uint16 event_id)
bool hasGameObjectActiveEventExcept(ObjectGuid::LowType go_guid, uint16 event_id)
std::unordered_map< uint32, std::vector< VendorItem > > NPCVendorMap
bool CheckOneGameEvent(uint16 entry) const
void StopEvent(uint16 event_id, bool overwrite=false)
bool hasGameObjectQuestActiveEventExcept(uint32 quest_id, uint16 event_id)
std::pair< uint32, uint32 > QuestRelation
uint64 GetNPCFlag(Creature *cr)
MapStoredObjectTypesContainer & GetObjectsStore()
void SendUpdateWorldState(uint32 variable, uint32 value, bool hidden=false) const
void setFloat(const uint8 index, const float value)
void setUInt8(const uint8 index, const uint8 value)
void setInt64(const uint8 index, const int64 value)
void setUInt32(const uint8 index, const uint32 value)
void SetEventIdForQuest(uint16 eventId)
void Visit(TYPE_CONTAINER &c)
SystemTimePoint GetSystemTime()
Current chrono system_clock time point.
TC_COMMON_API std::vector< std::string_view > Tokenize(std::string_view str, char sep, bool keepEmpty)
Optional< CreatureModel > display
GameEventConditionMap conditions
std::array< uint32, MAX_HOLIDAY_DATES > Date
std::array< uint16, MAX_HOLIDAY_DURATIONS > Duration
std::vector< int32 > BonusListIDs