240{
241 {
243
244 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");
245 if (!result)
246 {
248 LOG_WARN(
"server.loading",
">> Loaded 0 game events. DB table `game_event` is empty.");
250 return;
251 }
252
254 do
255 {
256 Field* fields = result->Fetch();
257
259 if (event_id == 0)
260 {
261 LOG_ERROR(
"sql.sql",
"`game_event` game event entry 0 is reserved and can't be used.");
262 continue;
263 }
264
268 pGameEvent.
start = time_t(starttime);
270 if (fields[2].IsNull())
272 pGameEvent.
end = time_t(endtime);
276
282
283 ++count;
284
286 {
287 LOG_ERROR(
"sql.sql",
"`game_event` game event id ({}) isn't a world event and has length = 0, thus it can't be used.", event_id);
288 continue;
289 }
290
292 {
294 {
295 LOG_ERROR(
"sql.sql",
"`game_event` game event id ({}) have not existed holiday id {}.", event_id, pGameEvent.
holiday_id);
297 }
298
300 }
301 } while (result->NextRow());
302
305 }
306
307 LOG_INFO(
"server.loading",
"Loading Game Event Saves Data...");
308 {
310
311
313
314 if (!result)
315 {
316 LOG_WARN(
"server.loading",
">> Loaded 0 Game Event Saves In Game Events. DB Table `game_event_save` Is Empty.");
318 }
319 else
320 {
322 do
323 {
324 Field* fields = result->Fetch();
325
327
329 {
330 LOG_ERROR(
"sql.sql",
"`game_event_save` game event entry ({}) is out of range compared to max event entry in `game_event`", event_id);
331 continue;
332 }
333
335 {
337 mGameEvent[event_id].nextstart = time_t(fields[2].Get<uint32>());
338 }
339 else
340 {
341 LOG_ERROR(
"sql.sql",
"game_event_save includes event save for non-worldevent id {}", event_id);
342 continue;
343 }
344
345 ++count;
346 } while (result->NextRow());
347
350 }
351 }
352
353 LOG_INFO(
"server.loading",
"Loading Game Event Prerequisite Data...");
354 {
356
357
359 if (!result)
360 {
361 LOG_WARN(
"server.loading",
">> Loaded 0 Game Rvent Prerequisites in Game Events. DB Table `game_event_prerequisite` Is Empty.");
363 }
364 else
365 {
367 do
368 {
369 Field* fields = result->Fetch();
370
372
374 {
375 LOG_ERROR(
"sql.sql",
"`game_event_prerequisite` game event id ({}) is out of range compared to max event id in `game_event`", event_id);
376 continue;
377 }
378
380 {
383 {
384 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);
385 continue;
386 }
387 mGameEvent[event_id].prerequisite_events.insert(prerequisite_event);
388 }
389 else
390 {
391 LOG_ERROR(
"sql.sql",
"game_event_prerequisiste includes event entry for non-worldevent id {}", event_id);
392 continue;
393 }
394
395 ++count;
396 } while (result->NextRow());
397
398 LOG_INFO(
"server.loading",
">> Loaded {} game event prerequisites in Game Events in {} ms", count,
GetMSTimeDiffToNow(oldMSTime));
400 }
401 }
402
403 LOG_INFO(
"server.loading",
"Loading Game Event Creature Data...");
404 {
406
407
409
410 if (!result)
411 {
412 LOG_WARN(
"server.loading",
">> Loaded 0 creatures in game events. DB table `game_event_creature` is empty");
414 }
415 else
416 {
418 do
419 {
420 Field* fields = result->Fetch();
421
424
426 if (!data)
427 {
428 LOG_ERROR(
"sql.sql",
"`game_event_creature` contains creature (GUID: {}) not found in `creature` table.", guid);
429 continue;
430 }
431
433
435 {
436 LOG_ERROR(
"sql.sql",
"`game_event_creature` game event id ({}) is out of range compared to max event id in `game_event`", event_id);
437 continue;
438 }
439
441 crelist.push_back(guid);
442
443 ++count;
444 } while (result->NextRow());
445
448 }
449 }
450
451 LOG_INFO(
"server.loading",
"Loading Game Event GO Data...");
452 {
454
455
457
458 if (!result)
459 {
460 LOG_WARN(
"server.loading",
">> Loaded 0 gameobjects in game events. DB table `game_event_gameobject` is empty.");
462 }
463 else
464 {
466 do
467 {
468 Field* fields = result->Fetch();
469
472
474
476 if (!data)
477 {
478 LOG_ERROR(
"sql.sql",
"`game_event_gameobject` contains gameobject (GUID: {}) not found in `gameobject` table.", guid);
479 continue;
480 }
481
483 {
484 LOG_ERROR(
"sql.sql",
"`game_event_gameobject` game event id ({}) is out of range compared to max event id in `game_event`", event_id);
485 continue;
486 }
487
489 golist.push_back(guid);
490
491 ++count;
492 } while (result->NextRow());
493
496 }
497 }
498
499 LOG_INFO(
"server.loading",
"Loading Game Event Model/Equipment Change Data...");
500 {
502
503
504 QueryResult result =
WorldDatabase.Query(
"SELECT creature.guid, creature.id1, creature.id2, creature.id3, game_event_model_equip.eventEntry, game_event_model_equip.modelid, game_event_model_equip.equipment_id "
505 "FROM creature JOIN game_event_model_equip ON creature.guid=game_event_model_equip.guid");
506
507 if (!result)
508 {
509 LOG_WARN(
"server.loading",
">> Loaded 0 Model/Equipment Changes In Game Events. DB Table `game_event_model_equip` Is Empty.");
511 }
512 else
513 {
515 do
516 {
517 Field* fields = result->Fetch();
518
524
526 {
527 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);
528 continue;
529 }
530
537
539 {
541 if ((!
sObjectMgr->GetEquipmentInfo(entry, equipId)) || (entry2 && !
sObjectMgr->GetEquipmentInfo(entry2, equipId)) || (entry3 && !
sObjectMgr->GetEquipmentInfo(entry3, equipId)))
542 {
543 LOG_ERROR(
"sql.sql",
"Table `game_event_model_equip` have creature (Guid: {}) with equipment_id {} not found in table `creature_equip_template`, set to no equipment.",
545 continue;
546 }
547 }
548
549 equiplist.push_back(std::pair<ObjectGuid::LowType, ModelEquip>(guid, newModelEquipSet));
550
551 ++count;
552 } while (result->NextRow());
553
554 LOG_INFO(
"server.loading",
">> Loaded {} Model/Equipment Changes In Game Events in {} ms", count,
GetMSTimeDiffToNow(oldMSTime));
556 }
557 }
558
559 LOG_INFO(
"server.loading",
"Loading Game Event Quest Data...");
560 {
562
563
565
566 if (!result)
567 {
568 LOG_WARN(
"server.loading",
">> Loaded 0 Quests Additions In Game Events. DB Table `game_event_creature_quest` Is Empty.");
570 }
571 else
572 {
574 do
575 {
576 Field* fields = result->Fetch();
577
581
583 {
584 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);
585 continue;
586 }
587
590
591 ++count;
592 } while (result->NextRow());
593
596 }
597 }
598
599 LOG_INFO(
"server.loading",
"Loading Game Event GO Quest Data...");
600 {
602
603
605
606 if (!result)
607 {
608 LOG_WARN(
"server.loading",
">> Loaded 0 go Quests Additions In Game Events. DB Table `game_event_gameobject_quest` Is Empty.");
610 }
611 else
612 {
614 do
615 {
616 Field* fields = result->Fetch();
617
621
623 {
624 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);
625 continue;
626 }
627
630
631 ++count;
632 } while (result->NextRow());
633
636 }
637 }
638
639 LOG_INFO(
"server.loading",
"Loading Game Event Quest Condition Data...");
640 {
642
643
644 QueryResult result =
WorldDatabase.Query(
"SELECT quest, eventEntry, condition_id, num FROM game_event_quest_condition");
645
646 if (!result)
647 {
648 LOG_WARN(
"server.loading",
">> Loaded 0 quest event Conditions In Game Events. DB Table `game_event_quest_condition` Is Empty.");
650 }
651 else
652 {
654 do
655 {
656 Field* fields = result->Fetch();
657
661 float num = fields[3].
Get<
float>();
662
664 {
665 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);
666 continue;
667 }
668
672
673 ++count;
674 } while (result->NextRow());
675
676 LOG_INFO(
"server.loading",
">> Loaded {} quest event conditions in Game Events in {} ms", count,
GetMSTimeDiffToNow(oldMSTime));
678 }
679 }
680
681 LOG_INFO(
"server.loading",
"Loading Game Event Condition Data...");
682 {
684
685
686 QueryResult result =
WorldDatabase.Query(
"SELECT eventEntry, condition_id, req_num, max_world_state_field, done_world_state_field FROM game_event_condition");
687
688 if (!result)
689 {
690 LOG_WARN(
"server.loading",
">> Loaded 0 Conditions In Game Events. DB table `game_event_condition` Is Empty.");
692 }
693 else
694 {
696 do
697 {
698 Field* fields = result->Fetch();
699
702
704 {
705 LOG_ERROR(
"sql.sql",
"`game_event_condition` game event id ({}) is out of range compared to max event id in `game_event`", event_id);
706 continue;
707 }
708
709 mGameEvent[event_id].conditions[condition].reqNum = fields[2].
Get<
float>();
710 mGameEvent[event_id].conditions[condition].done = 0;
713
714 ++count;
715 } while (result->NextRow());
716
719 }
720 }
721
722 LOG_INFO(
"server.loading",
"Loading Game Event Condition Save Data...");
723 {
725
726
728
729 if (!result)
730 {
731 LOG_WARN(
"server.loading",
">> Loaded 0 Condition Saves In Game Events. DB Table `game_event_condition_save` Is Empty.");
733 }
734 else
735 {
737 do
738 {
739 Field* fields = result->Fetch();
740
743
745 {
746 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);
747 continue;
748 }
749
750 GameEventConditionMap::iterator itr =
mGameEvent[event_id].conditions.find(condition);
751 if (itr !=
mGameEvent[event_id].conditions.end())
752 {
753 itr->second.done = fields[2].
Get<
float>();
754 }
755 else
756 {
757 LOG_ERROR(
"sql.sql",
"game_event_condition_save contains not present condition evt id {} cond id {}", event_id, condition);
758 continue;
759 }
760
761 ++count;
762 } while (result->NextRow());
763
766 }
767 }
768
769 LOG_INFO(
"server.loading",
"Loading Game Event NPCflag Data...");
770 {
772
773
775
776 if (!result)
777 {
778 LOG_WARN(
"server.loading",
">> Loaded 0 Npcflags In Game Events. DB Table `game_event_npcflag` Is Empty.");
780 }
781 else
782 {
784 do
785 {
786 Field* fields = result->Fetch();
787
791
793 {
794 LOG_ERROR(
"sql.sql",
"`game_event_npcflag` game event id ({}) is out of range compared to max event id in `game_event`", event_id);
795 continue;
796 }
797
799
800 ++count;
801 } while (result->NextRow());
802
805 }
806 }
807
808 LOG_INFO(
"server.loading",
"Loading Game Event Seasonal Quest Relations...");
809 {
811
812
814
815 if (!result)
816 {
817 LOG_WARN(
"server.loading",
">> Loaded 0 Seasonal Quests Additions In Game Events. DB Table `game_event_seasonal_questrelation` Is Empty.");
819 }
820 else
821 {
823 do
824 {
825 Field* fields = result->Fetch();
826
829
831
832 if (!questTemplate)
833 {
834 LOG_ERROR(
"sql.sql",
"`game_event_seasonal_questrelation` quest id ({}) does not exist in `quest_template`", questId);
835 continue;
836 }
837
839 {
840 LOG_ERROR(
"sql.sql",
"`game_event_seasonal_questrelation` event id ({}) is out of range compared to max event in `game_event`", eventEntry);
841 continue;
842 }
843
844 questTemplate->SetEventIdForQuest((
uint16)eventEntry);
846 ++count;
847 } while (result->NextRow());
848
851 }
852 }
853
854 LOG_INFO(
"server.loading",
"Loading Game Event Vendor Additions Data...");
855 {
857
858
859 QueryResult result =
WorldDatabase.Query(
"SELECT eventEntry, guid, item, maxcount, incrtime, ExtendedCost FROM game_event_npc_vendor ORDER BY guid, slot ASC");
860
861 if (!result)
862 {
863 LOG_WARN(
"server.loading",
">> Loaded 0 Vendor Additions In Game Events. DB Table `game_event_npc_vendor` Is Empty.");
865 }
866 else
867 {
869 do
870 {
871 Field* fields = result->Fetch();
872
874
876 {
877 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);
878 continue;
879 }
880
888
889 uint32 event_npc_flag = 0;
891 for (NPCFlagList::const_iterator itr = flist.begin(); itr != flist.end(); ++itr)
892 {
893 if (itr->first == guid)
894 {
895 event_npc_flag = itr->second;
896 break;
897 }
898 }
899
901
903 newEntry.
entry = data->id1;
904
905
907 continue;
908
909 vendors.push_back(newEntry);
910
911 ++count;
912 } while (result->NextRow());
913
916 }
917 }
918
919 LOG_INFO(
"server.loading",
"Loading Game Event Battleground Data...");
920 {
922
923
925
926 if (!result)
927 {
928 LOG_WARN(
"server.loading",
">> Loaded 0 Battleground Holidays In Game Events. DB table `game_event_battleground_holiday` is empty.");
930 }
931 else
932 {
934 do
935 {
936 Field* fields = result->Fetch();
937
939
941 {
942 LOG_ERROR(
"sql.sql",
"`game_event_battleground_holiday` game event id ({}) is out of range compared to max event id in `game_event`", event_id);
943 continue;
944 }
945
947
948 ++count;
949 } while (result->NextRow());
950
951 LOG_INFO(
"server.loading",
">> Loaded {} Battleground Holidays In Game Events in {} ms", count,
GetMSTimeDiffToNow(oldMSTime));
953 }
954 }
955
956 LOG_INFO(
"server.loading",
"Loading Game Event Pool Data...");
957 {
959
960
961 QueryResult result =
WorldDatabase.Query(
"SELECT pool_template.entry, game_event_pool.eventEntry FROM pool_template"
962 " JOIN game_event_pool ON pool_template.entry = game_event_pool.pool_entry");
963
964 if (!result)
965 {
966 LOG_WARN(
"server.loading",
">> Loaded 0 Pools For Game Events. DB Table `game_event_pool` Is Empty.");
968 }
969 else
970 {
972 do
973 {
974 Field* fields = result->Fetch();
975
978
980
982 {
983 LOG_ERROR(
"sql.sql",
"`game_event_pool` game event id ({}) is out of range compared to max event id in `game_event`", event_id);
984 continue;
985 }
986
988 {
989 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);
990 continue;
991 }
992
994 poollist.push_back(entry);
995
996 ++count;
997 } while (result->NextRow());
998
1001 }
1002 }
1003}
#define LOG_INFO(filterType__,...)
Definition: Log.h:165
#define LOG_WARN(filterType__,...)
Definition: Log.h:161
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition: Timer.h:131
uint32 getMSTime()
Definition: Timer.h:103
std::int8_t int8
Definition: Define.h:105
std::uint64_t uint64
Definition: Define.h:106
HolidayIds
Definition: SharedDefines.h:2741
@ HOLIDAY_NONE
Definition: SharedDefines.h:2742
GameEventState
Definition: GameEventMgr.h:30
DBCStorage< HolidaysEntry > sHolidaysStore(Holidaysfmt)
Definition: GameEventMgr.h:57
uint32 occurence
Definition: GameEventMgr.h:63
time_t end
Definition: GameEventMgr.h:61
uint8 holidayStage
Definition: GameEventMgr.h:66
GameEventState state
Definition: GameEventMgr.h:67
uint8 announce
Definition: GameEventMgr.h:71
uint32 eventId
Definition: GameEventMgr.h:59
HolidayIds holiday_id
Definition: GameEventMgr.h:65
uint32 length
Definition: GameEventMgr.h:64
time_t start
Definition: GameEventMgr.h:60
time_t nextstart
Definition: GameEventMgr.h:62
std::string description
Definition: GameEventMgr.h:70
Definition: GameEventMgr.h:77
uint32 modelid
Definition: GameEventMgr.h:78
uint8 equipement_id_prev
Definition: GameEventMgr.h:81
uint32 modelid_prev
Definition: GameEventMgr.h:79
uint8 equipment_id
Definition: GameEventMgr.h:80
Definition: GameEventMgr.h:85
int32 maxcount
Definition: GameEventMgr.h:88
uint32 item
Definition: GameEventMgr.h:87
uint32 entry
Definition: GameEventMgr.h:86
uint32 incrtime
Definition: GameEventMgr.h:89
uint32 ExtendedCost
Definition: GameEventMgr.h:90
std::list< ObjectGuid::LowType > GuidLowList
Definition: GameEventMgr.h:148
std::list< ModelEquipPair > ModelEquipList
Definition: GameEventMgr.h:153
GameEventSeasonalQuestsMap _gameEventSeasonalQuestsMap
Definition: GameEventMgr.h:179
std::list< GuidNPCFlagPair > NPCFlagList
Definition: GameEventMgr.h:162
std::list< uint32 > IdList
Definition: GameEventMgr.h:149
void SetHolidayEventTime(GameEventData &event)
Definition: GameEventMgr.cpp:1799
std::list< QuestRelation > QuestRelList
Definition: GameEventMgr.h:156
std::list< NPCVendorEntry > NPCVendorList
Definition: GameEventMgr.h:158
std::pair< uint32, uint32 > QuestRelation
Definition: GameEventMgr.h:155
std::pair< ObjectGuid::LowType, uint32 > GuidNPCFlagPair
Definition: GameEventMgr.h:161
Definition: QuestDef.h:210