From 1b1abc9792a141b93b14f3b587e21ab7bb7e1a06 Mon Sep 17 00:00:00 2001 From: Ishaan Bhardwaj Date: Tue, 20 Apr 2021 16:11:49 -0400 Subject: [PATCH] Fixed an issue with buffer lock inputs --- tetris/modes/gamemode.lua | 25 +++++++++++++++++-------- tetris/rulesets/ruleset.lua | 12 ++---------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/tetris/modes/gamemode.lua b/tetris/modes/gamemode.lua index 40f8fd1..4d578fe 100644 --- a/tetris/modes/gamemode.lua +++ b/tetris/modes/gamemode.lua @@ -529,16 +529,13 @@ function GameMode:initializeNextPiece(inputs, ruleset, piece_data, generate_next self.lock_drop, self.lock_hard_drop, self.big_mode, ( self.frames == 0 or (ruleset.are and self:getARE() ~= 0) - ) and self.irs or false, - self.buffer_hard_drop, self.buffer_soft_drop, - self.lock_on_hard_drop, self.lock_on_soft_drop + ) and self.irs or false ) - if self.piece:isDropBlocked(self.grid) and - self.grid:canPlacePiece(self.piece) then - playSE("bottom") - end if self.buffer_hard_drop then - self.buffer_hard_drop = false + if config.gamesettings.buffer_lock == 1 then + self.piece:dropToBottom(self.grid) + if self.lock_on_hard_drop then self.piece.locked = true end + end local above_field = ( (config.gamesettings.spawn_positions == 1 and ruleset.spawn_above_field) or @@ -552,10 +549,22 @@ function GameMode:initializeNextPiece(inputs, ruleset, piece_data, generate_next piece_data.shape, piece_data.orientation ) or 0) ) + self.buffer_hard_drop = false end if self.buffer_soft_drop then + if ( + self.lock_on_soft_drop and + self.piece:isDropBlocked(self.grid) and + config.gamesettings.buffer_lock == 1 + ) then + self.piece.locked = true + end self.buffer_soft_drop = false end + if self.piece:isDropBlocked(self.grid) and + self.grid:canPlacePiece(self.piece) then + playSE("bottom") + end if self.lock_drop or ( not ruleset.are or self:getARE() == 0 ) then diff --git a/tetris/rulesets/ruleset.lua b/tetris/rulesets/ruleset.lua index 5198833..abee732 100644 --- a/tetris/rulesets/ruleset.lua +++ b/tetris/rulesets/ruleset.lua @@ -210,9 +210,7 @@ end function Ruleset:initializePiece( inputs, data, grid, gravity, prev_inputs, move, lock_delay, drop_speed, - drop_locked, hard_drop_locked, big, irs, - buffer_hard_drop, buffer_soft_drop, - lock_on_hard_drop, lock_on_soft_drop + drop_locked, hard_drop_locked, big, irs ) local spawn_positions if big then @@ -265,13 +263,6 @@ function Ruleset:initializePiece( end end self:dropPiece(inputs, piece, grid, gravity, drop_speed, drop_locked, hard_drop_locked) - if (buffer_hard_drop and config.gamesettings.buffer_lock == 1) then - piece:dropToBottom(grid) - if lock_on_hard_drop then piece.locked = true end - end - if (buffer_soft_drop and lock_on_soft_drop and piece:isDropBlocked(grid) and config.gamesettings.buffer_lock == 1) then - piece.locked = true - end return piece end @@ -284,6 +275,7 @@ function Ruleset:processPiece( drop_locked, hard_drop_locked, hard_drop_enabled, additive_gravity, classic_lock ) + if piece.locked then return end local synchroes_allowed = ({not self.world, true, false})[config.gamesettings.synchroes_allowed]