diff --git a/sql/updates/7981_world_season_linked_event.sql b/sql/updates/7981_world_season_linked_event.sql new file mode 100644 index 0000000000..94e47e9152 --- /dev/null +++ b/sql/updates/7981_world_season_linked_event.sql @@ -0,0 +1,7 @@ +DROP TABLE IF EXISTS `season_linked_event`; +CREATE TABLE `season_linked_event` ( + `season` int(3) UNSIGNED NOT NULL default '0', + `event` int(8) UNSIGNED NOT NULL default '0', + PRIMARY KEY (`season`), + UNIQUE (`season`,`event`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/sql/world.sql b/sql/world.sql index ea0074b0fc..1129e9596e 100644 --- a/sql/world.sql +++ b/sql/world.sql @@ -4641,6 +4641,30 @@ LOCK TABLES `script_waypoint` WRITE; /*!40000 ALTER TABLE `script_waypoint` ENABLE KEYS */; UNLOCK TABLES; +-- +-- Table structure for table `season_linked_event` +-- + +DROP TABLE IF EXISTS `season_linked_event`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `season_linked_event` ( + `season` int(3) UNSIGNED NOT NULL default '0', + `event` int(8) UNSIGNED NOT NULL default '0', + PRIMARY KEY (`season`), + UNIQUE (`season`,`event`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `season_linked_event` +-- + +LOCK TABLES `season_linked_event` WRITE; +/*!40000 ALTER TABLE `season_linked_event` DISABLE KEYS */; +/*!40000 ALTER TABLE `season_linked_event` ENABLE KEYS */; +UNLOCK TABLES; + -- -- Table structure for table `skill_discovery_template` -- diff --git a/src/game/GameEventMgr.cpp b/src/game/GameEventMgr.cpp index e66c1a6e27..965651ae2f 100644 --- a/src/game/GameEventMgr.cpp +++ b/src/game/GameEventMgr.cpp @@ -1068,6 +1068,24 @@ uint32 GameEventMgr::Initialize() // return the next e return delay; } +void GameEventMgr::StartArenaSeason() +{ + QueryResult_AutoPtr result = WorldDatabase.PQuery("SELECT event FROM season_linked_event WHERE season = '%i'",sWorld.getConfig(CONFIG_ARENA_SEASON_ID)); + + if (!result) + { + sLog.outError("ArenaSeason (%i) must be an existant Arena Season",sWorld.getConfig(CONFIG_ARENA_SEASON_ID)); + return; + } + + Field *fields = result->Fetch(); + + uint16 eventId = fields[0].GetUInt16(); + + StartEvent(eventId,true); + sLog.outString("Arena Season %i started...",sWorld.getConfig(CONFIG_ARENA_SEASON_ID)); +} + uint32 GameEventMgr::Update() // return the next event delay in ms { time_t currenttime = time(NULL); diff --git a/src/game/GameEventMgr.h b/src/game/GameEventMgr.h index a1b65596ec..7c673c92e6 100644 --- a/src/game/GameEventMgr.h +++ b/src/game/GameEventMgr.h @@ -105,6 +105,7 @@ class GameEventMgr uint32 Update(); bool IsActiveEvent(uint16 event_id) { return (m_ActiveEvents.find(event_id) != m_ActiveEvents.end()); } uint32 Initialize(); + void StartArenaSeason(); void StartInternalEvent(uint16 event_id); bool StartEvent(uint16 event_id, bool overwrite = false); void StopEvent(uint16 event_id, bool overwrite = false); diff --git a/src/game/World.cpp b/src/game/World.cpp index b231558d62..aa290b7e06 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -1656,6 +1656,9 @@ void World::SetInitialWorldSettings() uint32 nextGameEvent = gameeventmgr.Initialize(); m_timers[WUPDATE_EVENTS].SetInterval(nextGameEvent); //depend on next event + sLog.outString("Starting Arena Season..."); + gameeventmgr.StartArenaSeason(); + sLog.outString("Loading World States..."); // must be loaded before battleground and outdoor PvP LoadWorldStates();