Skip to content
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
2 changes: 1 addition & 1 deletion client/src/BattleRoom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ end
function BattleRoom:onMatchEnded(match)
self.matchesPlayed = self.matchesPlayed + 1

if not match.aborted then
if not match.engine.aborted then
local winners = match:getWinners()
-- apply wins and possibly statistical data up for collection
if #winners == 1 then
Expand Down
2 changes: 1 addition & 1 deletion client/src/ChallengeMode.lua
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ function ChallengeMode:onMatchEnded(match)
GAME.netClient:reportLocalGameResult(winners)
end

if match.aborted then
if match.engine.aborted then
-- in challenge mode, an abort is always a manual pause and leave by the local player
-- match:deinit is the responsibility of the one switching out of the game scene
GAME.navigationStack:pop(nil, function() match:deinit() end)
Expand Down
1 change: 0 additions & 1 deletion client/src/ClientMatch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ function ClientMatch:setStage(stageId)
end

function ClientMatch:abort()
self.aborted = true
self.engine:abort()
self:handleMatchEnd()
end
Expand Down
3 changes: 2 additions & 1 deletion client/src/MatchParticipant.lua
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ function MatchParticipant:setAttackEngineSettings(attackEngineSettings)
end

-- a callback that runs whenever a match ended
function MatchParticipant:onMatchEnded()
---@param match ClientMatch
function MatchParticipant:onMatchEnded(match)
-- to prevent the game from instantly restarting, unready all players
if self.human then
self:setWantsReady(false)
Expand Down
1 change: 1 addition & 0 deletions client/src/scenes/EndlessGame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function EndlessGame:customLoad()
self.match:connectSignal("matchEnded", self, self.onMatchEnded)
end

---@param match ClientMatch
function EndlessGame:onMatchEnded(match)
if match.players[1].settings.style == GameModes.Styles.CLASSIC then
GAME.scores:saveEndlessScoreForLevel(match.players[1].stack.engine.score, match.players[1].stack.difficulty)
Expand Down
1 change: 1 addition & 0 deletions client/src/scenes/Game1pChallenge.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ function Game1pChallenge:startNextScene()
end
end

---@param match ClientMatch
function Game1pChallenge:pauseChanged(match)
if match.isPaused then
self.timeSplitElement.isVisible = false
Expand Down
1 change: 1 addition & 0 deletions client/src/scenes/GameBase.lua
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ function GameBase:drawEndGameText()
end
end

---@param match ClientMatch
function GameBase:genericOnMatchEnded(match)
self:setupGameOver()
-- matches always sort players to have locals in front so if 1 isn't local, none is
Expand Down
2 changes: 1 addition & 1 deletion client/src/scenes/PuzzleGame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ function PuzzleGame:customGameOverSetup()
end
else -- puzzle failed or manually reset
self.text = loc("pl_you_lose")
if (self.match.aborted == nil or self.match.aborted == false) then
if (self.match.engine.aborted == false) then
self:savePuzzleRecordResult(false)
end
end
Expand Down
3 changes: 2 additions & 1 deletion client/src/scenes/ReplayGame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,13 @@ function ReplayGame:drawHUD()
end
end

---@param match ClientMatch
function ReplayGame:genericOnMatchEnded(match)
-- Call parent implementation first
GameBase.genericOnMatchEnded(self, match)

-- Add win count increment logic like BattleRoom does
if not match.aborted then
if not match.engine.aborted then
local winners = match:getWinners()
if #winners == 1 then
winners[1].stack.character:playWinSfx()
Expand Down
1 change: 1 addition & 0 deletions client/src/scenes/TimeAttackGame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function TimeAttackGame:customLoad()
self.match:connectSignal("matchEnded", self, self.onMatchEnded)
end

---@param match ClientMatch
function TimeAttackGame:onMatchEnded(match)
if match.players[1].settings.style == GameModes.Styles.CLASSIC then
GAME.scores:saveTimeAttack1PScoreForLevel(match.players[1].stack.engine.score, match.players[1].stack.difficulty)
Expand Down
1 change: 1 addition & 0 deletions client/src/scenes/VsSelfGame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function VsSelfGame:customLoad()
self.match:connectSignal("matchEnded", self, self.onMatchEnded)
end

---@param match ClientMatch
function VsSelfGame:onMatchEnded(match)
local P1 = match.players[1].stack
GAME.scores:saveVsSelfScoreForLevel(P1.analytic.data.sent_garbage_lines, P1.level)
Expand Down
3 changes: 3 additions & 0 deletions common/engine/Match.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ local MatchRules = require("common.data.MatchRules")
---@field clock integer
---@field ended boolean
---@field gameOverClock integer?
---@field aborted boolean the game stopped in the middle because of crash, desync, game leave, online player left, etc.
---@field desyncError boolean? the match stopped because the other stack became too out of sync

-- A match is a particular instance of the game, for example 1 time attack round, or 1 vs match
---@class Match
Expand Down Expand Up @@ -61,6 +63,7 @@ function(self, panelSource, matchRules)
self.startTimestamp = os.time(os.date("*t"))
self.clock = 0
self.ended = false
self.aborted = false
end
)

Expand Down
4 changes: 4 additions & 0 deletions common/lib/signal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ function Signal.createSignal(t, signalName)
t.signalSubscriptions[signalName] = util.getWeaklyKeyedTable()
end

-- emits a signal, calling all connected callbacks with the subscriber and any additional arguments
---@param emitter Signal the emitter that is emitting the signal
---@param signalName string the name of the signal to emit
---@param ... any additional arguments to pass to the callbacks
function Signal.emitSignal(emitter, signalName, ...)
if not emitter.signalSubscriptions[signalName] then
error("Trying to emit unknown signal " .. signalName)
Expand Down
2 changes: 1 addition & 1 deletion main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ function love.errorhandler(msg)
if GAME.battleRoom and GAME.battleRoom.match then
pcall(function()
local match = GAME.battleRoom.match
match.aborted = true
match.engine.aborted = true
ReplayV3.finalizeReplay(match.engine, match.replay)
logger.info("Replay of match during crash:\n" .. json.encode(match.replay))
end)
Expand Down