From 06225bd35a6e2f954bccb9da55199803e329391a Mon Sep 17 00:00:00 2001 From: Ishaan Bhardwaj Date: Thu, 9 Dec 2021 22:21:48 -0500 Subject: [PATCH] Fixed an issue where replays played in the menu could save a duplicate copy --- scene/replay.lua | 3 ++- tetris/modes/gamemode.lua | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/scene/replay.lua b/scene/replay.lua index 6b6aa0d..e1f54a1 100644 --- a/scene/replay.lua +++ b/scene/replay.lua @@ -13,8 +13,9 @@ function ReplayScene:new(replay, game_mode, ruleset, inputs) self.retry_ruleset = ruleset self.secret_inputs = inputs self.game = game_mode(self.secret_inputs) + self.game.save_replay = false self.ruleset = ruleset(self.game) - self.game:initialize(self.ruleset, true) + self.game:initialize(self.ruleset) self.inputs = { left=false, right=false, diff --git a/tetris/modes/gamemode.lua b/tetris/modes/gamemode.lua index 1f41a5f..ad7c7dd 100644 --- a/tetris/modes/gamemode.lua +++ b/tetris/modes/gamemode.lua @@ -21,6 +21,7 @@ function GameMode:new(secret_inputs) self.random_low, self.random_high = love.math.getRandomSeed() self.random_state = love.math.getRandomState() self.secret_inputs = secret_inputs + self.save_replay = config.gamesettings.save_replay == 1 self.grid = Grid(10, 24) self.randomizer = Randomizer() @@ -103,7 +104,7 @@ function GameMode:getSkin() return "2tie" end -function GameMode:initialize(ruleset, replay) +function GameMode:initialize(ruleset) -- generate next queue self.used_randomizer = ( table.equalvalues( @@ -113,11 +114,10 @@ function GameMode:initialize(ruleset, replay) self.randomizer or BagRandomizer(table.keys(ruleset.colourscheme)) ) self.ruleset = ruleset - self.save_replay = not replay and (config.gamesettings.save_replay == 1) for i = 1, math.max(self.next_queue_length, 1) do table.insert(self.next_queue, self:getNextPiece(ruleset)) end - self.lock_on_soft_drop = ({ruleset.softdrop_lock, self.instant_soft_drop, false, true})[config.gamesettings.manlock] + self.lock_on_soft_drop = ({ruleset.softdrop_lock, self.instant_soft_drop, false, true })[config.gamesettings.manlock] self.lock_on_hard_drop = ({ruleset.harddrop_lock, self.instant_hard_drop, true, false})[config.gamesettings.manlock] end