Compare commits
2 Commits
4d4463ca0b
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
| e1c6d2a0b7 | |||
| a5a10166d9 |
@@ -1,86 +1,7 @@
|
|||||||
local AIO = AIO or require("AIO")
|
-- Game-mode UI synchronization is client-native since MoonWellClient 2.0.
|
||||||
|
--
|
||||||
local ADDON_NAME = "MoonWellClient"
|
-- The authoritative mode still comes from the server in SMSG_CHAR_ENUM as
|
||||||
local HANDLER_NAME = "Init"
|
-- CHARACTER_FLAG_UNK31 (0x40000000). WarcraftXL retains that bit while WoW
|
||||||
local GAME_MODE_NORMAL = 0
|
-- switches from GlueXML to the in-world FrameXML Lua state. Keeping this file
|
||||||
local GAME_MODE_TRAITOR = 1
|
-- as a no-op avoids stale deployment scripts failing on a missing path while
|
||||||
local PLAYER_EVENT_ON_LOGIN = 3
|
-- removing the timing-sensitive AIO login event completely.
|
||||||
local AIO_INIT_SEND_DELAY_MS = 1000
|
|
||||||
|
|
||||||
local MoonWellAIO = rawget(_G, "MoonWellAIO") or {}
|
|
||||||
_G.MoonWellAIO = MoonWellAIO
|
|
||||||
local PendingSyncEvents = {}
|
|
||||||
|
|
||||||
local function GetPlayerGameMode(player)
|
|
||||||
if not player then
|
|
||||||
return GAME_MODE_NORMAL
|
|
||||||
end
|
|
||||||
|
|
||||||
local query = CharDBQuery(
|
|
||||||
"SELECT game_mode FROM mod_gamemodes_characters WHERE guid = " .. player:GetGUIDLow() .. " LIMIT 1"
|
|
||||||
)
|
|
||||||
|
|
||||||
if not query or query:IsNull(0) then
|
|
||||||
return GAME_MODE_NORMAL
|
|
||||||
end
|
|
||||||
|
|
||||||
local gameMode = query:GetUInt8(0)
|
|
||||||
if gameMode == GAME_MODE_TRAITOR then
|
|
||||||
return GAME_MODE_TRAITOR
|
|
||||||
end
|
|
||||||
|
|
||||||
return GAME_MODE_NORMAL
|
|
||||||
end
|
|
||||||
|
|
||||||
function MoonWellAIO.GetPlayerGameMode(player)
|
|
||||||
return GetPlayerGameMode(player)
|
|
||||||
end
|
|
||||||
|
|
||||||
function MoonWellAIO.SendPlayerGameMode(player)
|
|
||||||
if not player then
|
|
||||||
return GAME_MODE_NORMAL
|
|
||||||
end
|
|
||||||
|
|
||||||
local gameMode = GetPlayerGameMode(player)
|
|
||||||
AIO.Handle(player, ADDON_NAME, HANDLER_NAME, gameMode)
|
|
||||||
return gameMode
|
|
||||||
end
|
|
||||||
|
|
||||||
local function CancelPendingSync(playerGuidLow)
|
|
||||||
local eventId = PendingSyncEvents[playerGuidLow]
|
|
||||||
if eventId then
|
|
||||||
RemoveEventById(eventId)
|
|
||||||
PendingSyncEvents[playerGuidLow] = nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function MoonWellAIO.SchedulePlayerGameMode(player, delayMs)
|
|
||||||
if not player then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local playerGuidLow = player:GetGUIDLow()
|
|
||||||
local playerGuid = player:GetGUID()
|
|
||||||
|
|
||||||
CancelPendingSync(playerGuidLow)
|
|
||||||
|
|
||||||
PendingSyncEvents[playerGuidLow] = CreateLuaEvent(function()
|
|
||||||
PendingSyncEvents[playerGuidLow] = nil
|
|
||||||
|
|
||||||
local onlinePlayer = GetPlayerByGUID(playerGuid)
|
|
||||||
if onlinePlayer then
|
|
||||||
MoonWellAIO.SendPlayerGameMode(onlinePlayer)
|
|
||||||
end
|
|
||||||
end, delayMs or AIO_INIT_SEND_DELAY_MS, 1)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Do not append MoonWellClient blocks directly into the AIO init packet:
|
|
||||||
-- the client addon may register its handlers slightly later than AIO itself.
|
|
||||||
AIO.AddOnInit(function(msg, player)
|
|
||||||
MoonWellAIO.SchedulePlayerGameMode(player, AIO_INIT_SEND_DELAY_MS)
|
|
||||||
return msg
|
|
||||||
end)
|
|
||||||
|
|
||||||
RegisterPlayerEvent(PLAYER_EVENT_ON_LOGIN, function(_, player)
|
|
||||||
MoonWellAIO.SchedulePlayerGameMode(player, AIO_INIT_SEND_DELAY_MS)
|
|
||||||
end)
|
|
||||||
|
|||||||
@@ -5559,6 +5559,12 @@ bool Player::LoadFromDB(ObjectGuid playerGuid, CharacterDatabaseQueryHolder cons
|
|||||||
m_reputationMgr->LoadFromDB(holder.GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_REPUTATION));
|
m_reputationMgr->LoadFromDB(holder.GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_REPUTATION));
|
||||||
sScriptMgr->OnPlayerReputationLoadFromDB(this);
|
sScriptMgr->OnPlayerReputationLoadFromDB(this);
|
||||||
|
|
||||||
|
// Traitor game mode swaps the player's team without changing race, but the
|
||||||
|
// reputation list is always rebuilt from the native race. Re-apply the
|
||||||
|
// traitor reputation state here so the new faction's reputations stay
|
||||||
|
// visible/friendly and the native ones hidden/at-war on every login.
|
||||||
|
ApplyTraitorReputationState();
|
||||||
|
|
||||||
// xinef: load mails before inventory, so problematic items can be added to already loaded mails
|
// xinef: load mails before inventory, so problematic items can be added to already loaded mails
|
||||||
_LoadMail(holder.GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_MAILS), holder.GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_MAIL_ITEMS));
|
_LoadMail(holder.GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_MAILS), holder.GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_MAIL_ITEMS));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user