-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master' into B-A-Legion
- Loading branch information
Showing
104 changed files
with
1,078 additions
and
1,447 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
function gadget:GetInfo() | ||
return { | ||
name = "Test Environment Helper", | ||
desc = "Helper to setup test environment conditions", | ||
license = "GNU GPL, v2 or later", | ||
layer = 9999, | ||
handler = true, | ||
enabled = true, | ||
} | ||
end | ||
|
||
local ENABLED_RULES_PARAM = 'isTestEnvironmentHelperEnabled' | ||
|
||
if not Spring.Utilities.IsDevMode() or not Spring.Utilities.Gametype.IsSinglePlayer() then | ||
return | ||
end | ||
|
||
if gadgetHandler:IsSyncedCode() then | ||
|
||
local removeGadgets = {'Team Com Ends', 'Game End'} | ||
|
||
Spring.SetGameRulesParam(ENABLED_RULES_PARAM, true) | ||
|
||
local function SetTestEndConditionsCmd(cmd, line, words, playerID) | ||
if not Spring.IsCheatingEnabled() then | ||
return | ||
end | ||
for _, gadgetName in pairs(removeGadgets) do | ||
local g = gadgetHandler:FindGadget(gadgetName) | ||
gadgetHandler:RemoveGadget(g) | ||
end | ||
|
||
Spring.SetGameRulesParam("testEndConditionsOverride", true) | ||
end | ||
|
||
local function SetTestReadyPlayersCmd(cmd, line, words, playerID) | ||
if not Spring.IsCheatingEnabled() then | ||
return | ||
end | ||
local playerList = Spring.GetPlayerList() | ||
for _, playerID in pairs(playerList) do | ||
Spring.SetGameRulesParam("player_" .. playerID .. "_readyState", 1) | ||
end | ||
end | ||
|
||
function gadget:Initialize() | ||
gadgetHandler.actionHandler.AddChatAction(gadget, 'setTestEndConditions', SetTestEndConditionsCmd) | ||
gadgetHandler.actionHandler.AddChatAction(gadget, 'setTestReadyPlayers', SetTestReadyPlayersCmd) | ||
if Spring.GetGameRulesParam("testEndConditionsOverride") then | ||
SetTestEndConditionsCmd() | ||
end | ||
end | ||
|
||
function gadget:Shutdown() | ||
gadgetHandler.actionHandler.RemoveChatAction(gadget, 'setTestEndConditions') | ||
gadgetHandler.actionHandler.RemoveChatAction(gadget, 'setTestReadyPlayers') | ||
Spring.SetGameRulesParam(ENABLED_RULES_PARAM, false) | ||
end | ||
|
||
function gadget:RecvLuaMsg(msg, playerID) | ||
if msg == 'testEnvironmentStarting' then | ||
Spring.SetGameRulesParam('testEnvironmentStarting', true) | ||
gadgetHandler:RemoveGadgetCallIn('RecvLuaMsg', self) | ||
end | ||
end | ||
else | ||
-- taken from gui_pregameui.lua, check there for more information | ||
local NETMSG_STARTPLAYING = 4 | ||
local SYSTEM_ID = -1 | ||
|
||
function gadget:Update(n) | ||
if (Spring.GetPlayerTraffic(SYSTEM_ID, NETMSG_STARTPLAYING) or 0) > 0 then | ||
Spring.SendLuaRulesMsg('testEnvironmentStarting') | ||
gadgetHandler:RemoveGadget(self) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.