Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify the setup for moderator events #6002

Merged
merged 3 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions engine/User.lua
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,10 @@ end
function EntityCategoryFilterOut(category, units)
end

--- Executes some Lua code in the sim
--- Executes some Lua code in the sim. Requires cheats to be enabled
---@param func function
---@param ... any this may actually be a comma-separated string of args instead of a vararg
---@return any
function ExecLuaInSim(func, ...)
---@param value any
function ExecLuaInSim(func, value)
end

--- Requests that the application shut down
Expand Down
16 changes: 16 additions & 0 deletions lua/SimCallbacks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1247,3 +1247,19 @@ Callbacks.AIPlatoonSimpleStructureBehavior = function(data, units)
end

--#endregion

-------------------------------------------------------------------------------
--#region Moderator related functionality

---@class CallbackModeratorEventData
---@field From number
---@field Message string

---@param data CallbackModeratorEventData
Callbacks.ModeratorEvent = function(data)
-- show up in the game logs
local brain = GetArmyBrain(GetCurrentCommandSource())
SPEW(string.format("Moderator event for %s: %s", tostring(brain.Nickname), repru(data, 10000)))
end

--#endregion
1 change: 0 additions & 1 deletion lua/SimPing.lua
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ end

function OnArmyChange()
Sync.MaxPingMarkers = MaxPingMarkers
LOG('syncing max ping markers: ', MaxPingMarkers)
--Flush all of the current markers on the UI side
if not Sync.Ping then Sync.Ping = {} end
table.insert(Sync.Ping, {Action = 'flush'})
Expand Down
2 changes: 0 additions & 2 deletions lua/SimSync.lua
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ function OnPostLoad()
end

function NoteFocusArmyChanged(new, old)
LOG("NoteFocusArmyChanged", new, old)
--LOG('NoteFocusArmyChanged(new=' .. repr(new) .. ', old=' .. repr(old) .. ')')
import("/lua/simping.lua").OnArmyChange()
import("/lua/sim/recall.lua").OnArmyChange()
for entityID, data in UnitData do
Expand Down
23 changes: 4 additions & 19 deletions lua/UserSync.lua
Original file line number Diff line number Diff line change
Expand Up @@ -111,32 +111,17 @@ function OnSync()

-- Informs moderators that the focus army has changed for the local player
if Sync.FocusArmyChanged then
local clients = GetSessionClients()
local localClient = nil
for k = 1, table.getn(clients) do
if clients[k]["local"] then
localClient = clients[k]
break
end
end

-- try to inform moderators
SimCallback(
{
Func="GiveResourcesToPlayer",
Func="ModeratorEvent",
Args= {
From=Sync.FocusArmyChanged.old,
To=Sync.FocusArmyChanged.old,
Mass=0,
Energy=0,
Sender=localClient.name,
Msg={ to='moderators', text = string.format("Switched focus army from %s to %s!", tostring(Sync.FocusArmyChanged.old), tostring(Sync.FocusArmyChanged.new)) }
From = Sync.FocusArmyChanged.old,
Message = string.format("Switched focus army from %s to %s!", tostring(Sync.FocusArmyChanged.old), tostring(Sync.FocusArmyChanged.new)),
},
},
true
}
)
end

end

-- old sync callbacks
Expand Down
4 changes: 0 additions & 4 deletions lua/keymap/misckeyactions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,3 @@ SelectAllResourceConsumers = function(onscreen)

SelectUnits(units)
end

TogglePerformanceMetricsWindow = function()
local instance = import("/lua/ui/lobby/sim-performance-popup.lua").OpenWindow()
end
Loading