Core/GameEvents: Added holiday/event world state field
Port From (https://github.com/TrinityCore/TrinityCore/commit/c575b397c591e7051c325046204da61086a0dbb9)
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
using Framework.Collections;
|
using Framework.Collections;
|
||||||
using Framework.Constants;
|
using Framework.Constants;
|
||||||
using Framework.Database;
|
using Framework.Database;
|
||||||
|
using Game.BattleGrounds;
|
||||||
using Game.DataStorage;
|
using Game.DataStorage;
|
||||||
using Game.Entities;
|
using Game.Entities;
|
||||||
using Game.Maps;
|
using Game.Maps;
|
||||||
@@ -193,8 +194,8 @@ namespace Game
|
|||||||
{
|
{
|
||||||
{
|
{
|
||||||
uint oldMSTime = Time.GetMSTime();
|
uint oldMSTime = Time.GetMSTime();
|
||||||
// 0 1 2 3 4 5 6 7 8 9
|
// 0 1 2 3 4 5 6 7 8 9 10
|
||||||
SQLResult result = DB.World.Query("SELECT eventEntry, UNIX_TIMESTAMP(start_time), UNIX_TIMESTAMP(end_time), occurence, length, holiday, holidayStage, description, world_event, announce FROM game_event");
|
SQLResult result = DB.World.Query("SELECT eventEntry, UNIX_TIMESTAMP(start_time), UNIX_TIMESTAMP(end_time), occurence, length, holiday, holidayStage, WorldStateId, description, world_event, announce FROM game_event");
|
||||||
if (result.IsEmpty())
|
if (result.IsEmpty())
|
||||||
{
|
{
|
||||||
mGameEvent.Clear();
|
mGameEvent.Clear();
|
||||||
@@ -222,9 +223,10 @@ namespace Game
|
|||||||
pGameEvent.holiday_id = (HolidayIds)result.Read<uint>(5);
|
pGameEvent.holiday_id = (HolidayIds)result.Read<uint>(5);
|
||||||
|
|
||||||
pGameEvent.holidayStage = result.Read<byte>(6);
|
pGameEvent.holidayStage = result.Read<byte>(6);
|
||||||
pGameEvent.description = result.Read<string>(7);
|
pGameEvent.WorldStateId = result.Read<int>(7);
|
||||||
pGameEvent.state = (GameEventState)result.Read<byte>(8);
|
pGameEvent.description = result.Read<string>(8);
|
||||||
pGameEvent.announce = result.Read<byte>(9);
|
pGameEvent.state = (GameEventState)result.Read<byte>(9);
|
||||||
|
pGameEvent.announce = result.Read<byte>(10);
|
||||||
pGameEvent.nextstart = 0;
|
pGameEvent.nextstart = 0;
|
||||||
|
|
||||||
++count;
|
++count;
|
||||||
@@ -250,9 +252,23 @@ namespace Game
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var bl = CliDB.BattlemasterListStorage.LookupByKey(Global.BattlegroundMgr.WeekendHolidayIdToBGType(pGameEvent.holiday_id));
|
||||||
|
if (bl != null && bl.HolidayWorldState != 0)
|
||||||
|
{
|
||||||
|
if (pGameEvent.WorldStateId.HasValue && pGameEvent.WorldStateId != bl.HolidayWorldState)
|
||||||
|
Log.outError(LogFilter.Sql, $"`game_event` game event id ({event_id}) has world state id set, but holiday {pGameEvent.holiday_id} is linked to battleground, set to battlemaster world state id {bl.HolidayWorldState}");
|
||||||
|
pGameEvent.WorldStateId = bl.HolidayWorldState;
|
||||||
|
}
|
||||||
|
|
||||||
SetHolidayEventTime(pGameEvent);
|
SetHolidayEventTime(pGameEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pGameEvent.WorldStateId.HasValue && Global.WorldStateMgr.GetWorldStateTemplate(pGameEvent.WorldStateId.Value) == null)
|
||||||
|
{
|
||||||
|
Log.outError(LogFilter.Sql, $"`game_event` game event id ({event_id}) has an invalid world state Id {pGameEvent.WorldStateId}, set to 0.");
|
||||||
|
pGameEvent.WorldStateId = null;
|
||||||
|
}
|
||||||
|
|
||||||
mGameEvent[event_id] = pGameEvent;
|
mGameEvent[event_id] = pGameEvent;
|
||||||
}
|
}
|
||||||
while (result.NextRow());
|
while (result.NextRow());
|
||||||
@@ -1031,7 +1047,7 @@ namespace Game
|
|||||||
|
|
||||||
Log.outInfo(LogFilter.Gameevent, "GameEvent {0} \"{1}\" started.", event_id, mGameEvent[event_id].description);
|
Log.outInfo(LogFilter.Gameevent, "GameEvent {0} \"{1}\" started.", event_id, mGameEvent[event_id].description);
|
||||||
|
|
||||||
// spawn positive event tagget objects
|
// spawn positive event tagged objects
|
||||||
GameEventSpawn((short)event_id);
|
GameEventSpawn((short)event_id);
|
||||||
// un-spawn negative event tagged objects
|
// un-spawn negative event tagged objects
|
||||||
short event_nid = (short)(-1 * event_id);
|
short event_nid = (short)(-1 * event_id);
|
||||||
@@ -1411,18 +1427,9 @@ namespace Game
|
|||||||
|
|
||||||
void UpdateWorldStates(ushort event_id, bool Activate)
|
void UpdateWorldStates(ushort event_id, bool Activate)
|
||||||
{
|
{
|
||||||
GameEventData Event = mGameEvent[event_id];
|
var worldStateId = mGameEvent[event_id].WorldStateId;
|
||||||
if (Event.holiday_id != HolidayIds.None)
|
if (worldStateId.HasValue)
|
||||||
{
|
Global.WorldStateMgr.SetValue(worldStateId.Value, Activate ? 1 : 0, false, null);
|
||||||
BattlegroundTypeId bgTypeId = Global.BattlegroundMgr.WeekendHolidayIdToBGType(Event.holiday_id);
|
|
||||||
if (bgTypeId != BattlegroundTypeId.None)
|
|
||||||
{
|
|
||||||
var bl = CliDB.BattlemasterListStorage.LookupByKey(Global.BattlegroundMgr.WeekendHolidayIdToBGType(Event.holiday_id));
|
|
||||||
if (bl != null)
|
|
||||||
if (bl.HolidayWorldState != 0)
|
|
||||||
Global.WorldStateMgr.SetValue(bl.HolidayWorldState, Activate ? 1 : 0, false, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HandleQuestComplete(uint quest_id)
|
public void HandleQuestComplete(uint quest_id)
|
||||||
@@ -1691,6 +1698,7 @@ namespace Game
|
|||||||
public uint length; // length of the event (Time.Minutes) after finishing all conditions
|
public uint length; // length of the event (Time.Minutes) after finishing all conditions
|
||||||
public HolidayIds holiday_id;
|
public HolidayIds holiday_id;
|
||||||
public byte holidayStage;
|
public byte holidayStage;
|
||||||
|
public int? WorldStateId;
|
||||||
public GameEventState state; // state of the game event, these are saved into the game_event table on change!
|
public GameEventState state; // state of the game event, these are saved into the game_event table on change!
|
||||||
public Dictionary<uint, GameEventFinishCondition> conditions = new(); // conditions to finish
|
public Dictionary<uint, GameEventFinishCondition> conditions = new(); // conditions to finish
|
||||||
public List<ushort> prerequisite_events = new(); // events that must be completed before starting this event
|
public List<ushort> prerequisite_events = new(); // events that must be completed before starting this event
|
||||||
|
|||||||
@@ -702,6 +702,9 @@ namespace Game
|
|||||||
Log.outInfo(LogFilter.ServerLoading, "Loading Quest Pooling Data...");
|
Log.outInfo(LogFilter.ServerLoading, "Loading Quest Pooling Data...");
|
||||||
Global.QuestPoolMgr.LoadFromDB(); // must be after quest templates
|
Global.QuestPoolMgr.LoadFromDB(); // must be after quest templates
|
||||||
|
|
||||||
|
Log.outInfo(LogFilter.ServerLoading, "Loading World State templates...");
|
||||||
|
Global.WorldStateMgr.LoadFromDB(); // must be loaded before battleground, outdoor PvP, game events and conditions
|
||||||
|
|
||||||
Log.outInfo(LogFilter.ServerLoading, "Loading Game Event Data..."); // must be after loading pools fully
|
Log.outInfo(LogFilter.ServerLoading, "Loading Game Event Data..."); // must be after loading pools fully
|
||||||
Global.GameEventMgr.LoadFromDB();
|
Global.GameEventMgr.LoadFromDB();
|
||||||
|
|
||||||
@@ -890,7 +893,6 @@ namespace Game
|
|||||||
Log.outInfo(LogFilter.ServerLoading, "Loading Guilds...");
|
Log.outInfo(LogFilter.ServerLoading, "Loading Guilds...");
|
||||||
Global.GuildMgr.LoadGuilds();
|
Global.GuildMgr.LoadGuilds();
|
||||||
|
|
||||||
|
|
||||||
Log.outInfo(LogFilter.ServerLoading, "Loading ArenaTeams...");
|
Log.outInfo(LogFilter.ServerLoading, "Loading ArenaTeams...");
|
||||||
Global.ArenaTeamMgr.LoadArenaTeams();
|
Global.ArenaTeamMgr.LoadArenaTeams();
|
||||||
|
|
||||||
@@ -936,9 +938,6 @@ namespace Game
|
|||||||
Log.outInfo(LogFilter.ServerLoading, "Loading Creature Formations...");
|
Log.outInfo(LogFilter.ServerLoading, "Loading Creature Formations...");
|
||||||
FormationMgr.LoadCreatureFormations();
|
FormationMgr.LoadCreatureFormations();
|
||||||
|
|
||||||
Log.outInfo(LogFilter.ServerLoading, "Loading World State templates...");
|
|
||||||
Global.WorldStateMgr.LoadFromDB(); // must be loaded before battleground, outdoor PvP and conditions
|
|
||||||
|
|
||||||
Log.outInfo(LogFilter.ServerLoading, "Loading Persistend World Variables..."); // must be loaded before Battleground, outdoor PvP and conditions
|
Log.outInfo(LogFilter.ServerLoading, "Loading Persistend World Variables..."); // must be loaded before Battleground, outdoor PvP and conditions
|
||||||
LoadPersistentWorldVariables();
|
LoadPersistentWorldVariables();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user