Skip to content

Commit

Permalink
Make ignorehitpause block affect its nested blocks in ZSS
Browse files Browse the repository at this point in the history
ignorehitpause if playerno = 2 {
	if time > -1 {
		text{
			text: "This is a text";
			pos: 100,100
		}
	}
}

Running the code above, text will fail to draw during a hit pause due to 'if time > -1' subblock not inheriting the 'ignorehitpause' attribute from the main block in the compiler. This commit attempts to fix that assuming this behavior makes more sense.
  • Loading branch information
Lazin3ss committed Nov 24, 2022
1 parent bc42429 commit 55567f0
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4414,16 +4414,22 @@ func (c *Compiler) scanStateDef(line *string, constants map[string]float32) (int
return v, err
}
func (c *Compiler) subBlock(line *string, root bool,
sbc *StateBytecode, numVars *int32) (*StateBlock, error) {
sbc *StateBytecode, numVars *int32, ignorehitpause bool) (*StateBlock, error) {
bl := newStateBlock()
// Inherit ignorehitpause from partner block
if ignorehitpause {
bl.ignorehitpause, bl.ctrlsIgnorehitpause = -1, true
}
ihpRead := false
for {
switch c.token {
case "ignorehitpause":
if bl.ignorehitpause >= -1 {
if ihpRead {
return nil, c.yokisinaiToken()
}
bl.ignorehitpause, bl.ctrlsIgnorehitpause = -1, true
c.scan(line)
ihpRead = true
continue
case "persistent":
if sbc == nil {
Expand Down Expand Up @@ -4505,7 +4511,7 @@ func (c *Compiler) subBlock(line *string, root bool,
c.scan(line)
var err error
if bl.elseBlock, err = c.subBlock(line, root,
sbc, numVars); err != nil {
sbc, numVars, ignorehitpause); err != nil {
return nil, err
}
if bl.elseBlock.ignorehitpause >= -1 {
Expand Down Expand Up @@ -4609,7 +4615,8 @@ func (c *Compiler) stateBlock(line *string, bl *StateBlock, root bool,
}
return nil
case "if", "ignorehitpause", "persistent":
if sbl, err := c.subBlock(line, root, sbc, numVars); err != nil {
if sbl, err := c.subBlock(line, root, sbc, numVars,
bl != nil && bl.ignorehitpause >= -1); err != nil {
return err
} else {
if bl != nil && sbl.ignorehitpause >= -1 {
Expand Down

0 comments on commit 55567f0

Please sign in to comment.