241{
242 {
244
245 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");
246 if (!result)
247 {
249 LOG_WARN(
"server.loading",
">> Loaded 0 game events. DB table `game_event` is empty.");
251 return;
252 }
253
255 do
256 {
257 Field* fields = result->Fetch();
258
260 if (event_id == 0)
261 {
262 LOG_ERROR(
"sql.sql",
"`game_event` game event entry 0 is reserved and can't be used.");
263 continue;
264 }
265
269 pGameEvent.
start = time_t(starttime);
271 if (fields[2].IsNull())
273 pGameEvent.
end = time_t(endtime);
277
283
284 ++count;
285
287 {
288 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);
289 continue;
290 }
291
293 {
295 {
296 LOG_ERROR(
"sql.sql",
"`game_event` game event id ({}) have not existed holiday id {}.", event_id, pGameEvent.
holiday_id);
298 }
299
301 }
302 } while (result->NextRow());
303
306 }
307
308 LOG_INFO(
"server.loading",
"Loading Game Event Saves Data...");
309 {
311
312
314
315 if (!result)
316 {
317 LOG_WARN(
"server.loading",
">> Loaded 0 Game Event Saves In Game Events. DB Table `game_event_save` Is Empty.");
319 }
320 else
321 {
323 do
324 {
325 Field* fields = result->Fetch();
326
328
330 {
331 LOG_ERROR(
"sql.sql",
"`game_event_save` game event entry ({}) is out of range compared to max event entry in `game_event`", event_id);
332 continue;
333 }
334
336 {
338 mGameEvent[event_id].nextstart = time_t(fields[2].Get<uint32>());
339 }
340 else
341 {
342 LOG_ERROR(
"sql.sql",
"game_event_save includes event save for non-worldevent id {}", event_id);
343 continue;
344 }
345
346 ++count;
347 } while (result->NextRow());
348
351 }
352 }
353
354 LOG_INFO(
"server.loading",
"Loading Game Event Prerequisite Data...");
355 {
357
358
360 if (!result)
361 {
362 LOG_WARN(
"server.loading",
">> Loaded 0 Game Rvent Prerequisites in Game Events. DB Table `game_event_prerequisite` Is Empty.");
364 }
365 else
366 {
368 do
369 {
370 Field* fields = result->Fetch();
371
373
375 {
376 LOG_ERROR(
"sql.sql",
"`game_event_prerequisite` game event id ({}) is out of range compared to max event id in `game_event`", event_id);
377 continue;
378 }
379
381 {
384 {
385 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);
386 continue;
387 }
388 mGameEvent[event_id].prerequisite_events.insert(prerequisite_event);
389 }
390 else
391 {
392 LOG_ERROR(
"sql.sql",
"game_event_prerequisiste includes event entry for non-worldevent id {}", event_id);
393 continue;
394 }
395
396 ++count;
397 } while (result->NextRow());
398
399 LOG_INFO(
"server.loading",
">> Loaded {} game event prerequisites in Game Events in {} ms", count,
GetMSTimeDiffToNow(oldMSTime));
401 }
402 }
403
404 LOG_INFO(
"server.loading",
"Loading Game Event Creature Data...");
405 {
407
408
410
411 if (!result)
412 {
413 LOG_WARN(
"server.loading",
">> Loaded 0 creatures in game events. DB table `game_event_creature` is empty");
415 }
416 else
417 {
419 do
420 {
421 Field* fields = result->Fetch();
422
425
427 if (!data)
428 {
429 LOG_ERROR(
"sql.sql",
"`game_event_creature` contains creature (GUID: {}) not found in `creature` table.", guid);
430 continue;
431 }
432
434
436 {
437 LOG_ERROR(
"sql.sql",
"`game_event_creature` game event id ({}) is out of range compared to max event id in `game_event`", event_id);
438 continue;
439 }
440
442 crelist.push_back(guid);
443
444 ++count;
445 } while (result->NextRow());
446
449 }
450 }
451
452 LOG_INFO(
"server.loading",
"Loading Game Event GO Data...");
453 {
455
456
458
459 if (!result)
460 {
461 LOG_WARN(
"server.loading",
">> Loaded 0 gameobjects in game events. DB table `game_event_gameobject` is empty.");
463 }
464 else
465 {
467 do
468 {
469 Field* fields = result->Fetch();
470
473
475
477 if (!data)
478 {
479 LOG_ERROR(
"sql.sql",
"`game_event_gameobject` contains gameobject (GUID: {}) not found in `gameobject` table.", guid);
480 continue;
481 }
482
484 {
485 LOG_ERROR(
"sql.sql",
"`game_event_gameobject` game event id ({}) is out of range compared to max event id in `game_event`", event_id);
486 continue;
487 }
488
490 golist.push_back(guid);
491
492 ++count;
493 } while (result->NextRow());
494
497 }
498 }
499
500 LOG_INFO(
"server.loading",
"Loading Game Event Model/Equipment Change Data...");
501 {
503
504
505 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 "
506 "FROM creature JOIN game_event_model_equip ON creature.guid=game_event_model_equip.guid");
507
508 if (!result)
509 {
510 LOG_WARN(
"server.loading",
">> Loaded 0 Model/Equipment Changes In Game Events. DB Table `game_event_model_equip` Is Empty.");
512 }
513 else
514 {
516 do
517 {
518 Field* fields = result->Fetch();
519
525
527 {
528 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);
529 continue;
530 }
531
538
540 {
542 if ((!
sObjectMgr->GetEquipmentInfo(entry, equipId)) || (entry2 && !
sObjectMgr->GetEquipmentInfo(entry2, equipId)) || (entry3 && !
sObjectMgr->GetEquipmentInfo(entry3, equipId)))
543 {
544 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.",
546 continue;
547 }
548 }
549
550 equiplist.push_back(std::pair<ObjectGuid::LowType, ModelEquip>(guid, newModelEquipSet));
551
552 ++count;
553 } while (result->NextRow());
554
555 LOG_INFO(
"server.loading",
">> Loaded {} Model/Equipment Changes In Game Events in {} ms", count,
GetMSTimeDiffToNow(oldMSTime));
557 }
558 }
559
560 LOG_INFO(
"server.loading",
"Loading Game Event Quest Data...");
561 {
563
564
566
567 if (!result)
568 {
569 LOG_WARN(
"server.loading",
">> Loaded 0 Quests Additions In Game Events. DB Table `game_event_creature_quest` Is Empty.");
571 }
572 else
573 {
575 do
576 {
577 Field* fields = result->Fetch();
578
582
584 {
585 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);
586 continue;
587 }
588
591
592 ++count;
593 } while (result->NextRow());
594
597 }
598 }
599
600 LOG_INFO(
"server.loading",
"Loading Game Event GO Quest Data...");
601 {
603
604
606
607 if (!result)
608 {
609 LOG_WARN(
"server.loading",
">> Loaded 0 go Quests Additions In Game Events. DB Table `game_event_gameobject_quest` Is Empty.");
611 }
612 else
613 {
615 do
616 {
617 Field* fields = result->Fetch();
618
622
624 {
625 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);
626 continue;
627 }
628
631
632 ++count;
633 } while (result->NextRow());
634
637 }
638 }
639
640 LOG_INFO(
"server.loading",
"Loading Game Event Quest Condition Data...");
641 {
643
644
645 QueryResult result =
WorldDatabase.Query(
"SELECT quest, eventEntry, condition_id, num FROM game_event_quest_condition");
646
647 if (!result)
648 {
649 LOG_WARN(
"server.loading",
">> Loaded 0 quest event Conditions In Game Events. DB Table `game_event_quest_condition` Is Empty.");
651 }
652 else
653 {
655 do
656 {
657 Field* fields = result->Fetch();
658
662 float num = fields[3].
Get<
float>();
663
665 {
666 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);
667 continue;
668 }
669
673
674 ++count;
675 } while (result->NextRow());
676
677 LOG_INFO(
"server.loading",
">> Loaded {} quest event conditions in Game Events in {} ms", count,
GetMSTimeDiffToNow(oldMSTime));
679 }
680 }
681
682 LOG_INFO(
"server.loading",
"Loading Game Event Condition Data...");
683 {
685
686
687 QueryResult result =
WorldDatabase.Query(
"SELECT eventEntry, condition_id, req_num, max_world_state_field, done_world_state_field FROM game_event_condition");
688
689 if (!result)
690 {
691 LOG_WARN(
"server.loading",
">> Loaded 0 Conditions In Game Events. DB table `game_event_condition` Is Empty.");
693 }
694 else
695 {
697 do
698 {
699 Field* fields = result->Fetch();
700
703
705 {
706 LOG_ERROR(
"sql.sql",
"`game_event_condition` game event id ({}) is out of range compared to max event id in `game_event`", event_id);
707 continue;
708 }
709
710 mGameEvent[event_id].conditions[condition].reqNum = fields[2].
Get<
float>();
711 mGameEvent[event_id].conditions[condition].done = 0;
714
715 ++count;
716 } while (result->NextRow());
717
720 }
721 }
722
723 LOG_INFO(
"server.loading",
"Loading Game Event Condition Save Data...");
724 {
726
727
729
730 if (!result)
731 {
732 LOG_WARN(
"server.loading",
">> Loaded 0 Condition Saves In Game Events. DB Table `game_event_condition_save` Is Empty.");
734 }
735 else
736 {
738 do
739 {
740 Field* fields = result->Fetch();
741
744
746 {
747 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);
748 continue;
749 }
750
751 GameEventConditionMap::iterator itr =
mGameEvent[event_id].conditions.find(condition);
752 if (itr !=
mGameEvent[event_id].conditions.end())
753 {
754 itr->second.done = fields[2].
Get<
float>();
755 }
756 else
757 {
758 LOG_ERROR(
"sql.sql",
"game_event_condition_save contains not present condition evt id {} cond id {}", event_id, condition);
759 continue;
760 }
761
762 ++count;
763 } while (result->NextRow());
764
767 }
768 }
769
770 LOG_INFO(
"server.loading",
"Loading Game Event NPCflag Data...");
771 {
773
774
776
777 if (!result)
778 {
779 LOG_WARN(
"server.loading",
">> Loaded 0 Npcflags In Game Events. DB Table `game_event_npcflag` Is Empty.");
781 }
782 else
783 {
785 do
786 {
787 Field* fields = result->Fetch();
788
792
794 {
795 LOG_ERROR(
"sql.sql",
"`game_event_npcflag` game event id ({}) is out of range compared to max event id in `game_event`", event_id);
796 continue;
797 }
798
800
801 ++count;
802 } while (result->NextRow());
803
806 }
807 }
808
809 LOG_INFO(
"server.loading",
"Loading Game Event Seasonal Quest Relations...");
810 {
812
813
815
816 if (!result)
817 {
818 LOG_WARN(
"server.loading",
">> Loaded 0 Seasonal Quests Additions In Game Events. DB Table `game_event_seasonal_questrelation` Is Empty.");
820 }
821 else
822 {
824 do
825 {
826 Field* fields = result->Fetch();
827
830
832
833 if (!questTemplate)
834 {
835 LOG_ERROR(
"sql.sql",
"`game_event_seasonal_questrelation` quest id ({}) does not exist in `quest_template`", questId);
836 continue;
837 }
838
840 {
841 LOG_ERROR(
"sql.sql",
"`game_event_seasonal_questrelation` event id ({}) is out of range compared to max event in `game_event`", eventEntry);
842 continue;
843 }
844
845 questTemplate->SetEventIdForQuest((
uint16)eventEntry);
847 ++count;
848 } while (result->NextRow());
849
852 }
853 }
854
855 LOG_INFO(
"server.loading",
"Loading Game Event Vendor Additions Data...");
856 {
858
859
860 QueryResult result =
WorldDatabase.Query(
"SELECT eventEntry, guid, item, maxcount, incrtime, ExtendedCost FROM game_event_npc_vendor ORDER BY guid, slot ASC");
861
862 if (!result)
863 {
864 LOG_WARN(
"server.loading",
">> Loaded 0 Vendor Additions In Game Events. DB Table `game_event_npc_vendor` Is Empty.");
866 }
867 else
868 {
870 do
871 {
872 Field* fields = result->Fetch();
873
875
877 {
878 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);
879 continue;
880 }
881
889
890 uint32 event_npc_flag = 0;
892 for (NPCFlagList::const_iterator itr = flist.begin(); itr != flist.end(); ++itr)
893 {
894 if (itr->first == guid)
895 {
896 event_npc_flag = itr->second;
897 break;
898 }
899 }
900
902
904 newEntry.
entry = data->id1;
905
906
908 continue;
909
910 vendors.push_back(newEntry);
911
912 ++count;
913 } while (result->NextRow());
914
917 }
918 }
919
920 LOG_INFO(
"server.loading",
"Loading Game Event Battleground Data...");
921 {
923
924
926
927 if (!result)
928 {
929 LOG_WARN(
"server.loading",
">> Loaded 0 Battleground Holidays In Game Events. DB table `game_event_battleground_holiday` is empty.");
931 }
932 else
933 {
935 do
936 {
937 Field* fields = result->Fetch();
938
940
942 {
943 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);
944 continue;
945 }
946
948
949 ++count;
950 } while (result->NextRow());
951
952 LOG_INFO(
"server.loading",
">> Loaded {} Battleground Holidays In Game Events in {} ms", count,
GetMSTimeDiffToNow(oldMSTime));
954 }
955 }
956
957 LOG_INFO(
"server.loading",
"Loading Game Event Pool Data...");
958 {
960
961
962 QueryResult result =
WorldDatabase.Query(
"SELECT pool_template.entry, game_event_pool.eventEntry FROM pool_template"
963 " JOIN game_event_pool ON pool_template.entry = game_event_pool.pool_entry");
964
965 if (!result)
966 {
967 LOG_WARN(
"server.loading",
">> Loaded 0 Pools For Game Events. DB Table `game_event_pool` Is Empty.");
969 }
970 else
971 {
973 do
974 {
975 Field* fields = result->Fetch();
976
979
981
983 {
984 LOG_ERROR(
"sql.sql",
"`game_event_pool` game event id ({}) is out of range compared to max event id in `game_event`", event_id);
985 continue;
986 }
987
989 {
990 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);
991 continue;
992 }
993
995 poollist.push_back(entry);
996
997 ++count;
998 } while (result->NextRow());
999
1002 }
1003 }
1004}
#define LOG_INFO(filterType__,...)
Definition: Log.h:164
#define LOG_WARN(filterType__,...)
Definition: Log.h:160
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
GameEventState
Definition: GameEventMgr.h:30
DBCStorage< HolidaysEntry > sHolidaysStore(Holidaysfmt)
HolidayIds
Definition: SharedDefines.h:2741
@ HOLIDAY_NONE
Definition: SharedDefines.h:2742
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:1800
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