Skip to content

Commit

Permalink
Merge pull request #1457 from Lazin3ss/development
Browse files Browse the repository at this point in the history
fix: Refine anim no. handling from #1448, PlayBGM SCTRL leaking to the character select screen
  • Loading branch information
K4thos authored Oct 26, 2023
2 parents f924037 + 426962c commit 2d16dec
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 18 deletions.
2 changes: 1 addition & 1 deletion data/dizzy.zss
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ playSnd{value: F7, ($vely > const240p(5)) + ($vely > const240p(14))}
#===============================================================================
# StateDizzyBirdsHelper [helper]
#===============================================================================
[StateDef const(StateDizzyBirdsHelper); type: A; physics: N; anim: -1; velset: 0, 0; ctrl: 0;]
[StateDef const(StateDizzyBirdsHelper); type: A; physics: N; anim: -2; velset: 0, 0; ctrl: 0;]

# Destroy helper
# 32 ticks after conditions are met so that it may fade out the effects
Expand Down
4 changes: 2 additions & 2 deletions src/bytecode.go
Original file line number Diff line number Diff line change
Expand Up @@ -2487,7 +2487,7 @@ func (sc stateDef) Run(c *Char) {
}
}
case stateDef_anim:
c.changeAnim(exp[1].evalI(c), string(*(*[]byte)(unsafe.Pointer(&exp[0]))))
c.changeAnimEx(exp[1].evalI(c), c.playerNo, string(*(*[]byte)(unsafe.Pointer(&exp[0]))), false)
case stateDef_ctrl:
//in mugen fatal blow ignores statedef ctrl
if !c.ghv.fatal {
Expand Down Expand Up @@ -2961,7 +2961,7 @@ func (sc changeAnim) Run(c *Char, _ []int32) bool {
if r != -1 {
pn = r
}
crun.changeAnimEx(exp[1].evalI(c), pn, string(*(*[]byte)(unsafe.Pointer(&exp[0]))), false)
crun.changeAnim(exp[1].evalI(c), pn, string(*(*[]byte)(unsafe.Pointer(&exp[0]))))
if setelem {
crun.setAnimElem(elem)
}
Expand Down
33 changes: 20 additions & 13 deletions src/char.go
Original file line number Diff line number Diff line change
Expand Up @@ -2668,10 +2668,21 @@ func (c *Char) changeAnimEx(animNo int32, playerNo int, ffx string, alt bool) {
}
}
}
func (c *Char) changeAnim(animNo int32, ffx string) {
c.changeAnimEx(animNo, c.playerNo, ffx, false)
func (c *Char) changeAnim(animNo int32, playerNo int, ffx string) {
if animNo < 0 && animNo != -2 {
// MUGEN 1.1 exports a warning message when attempting to change anim to a negative value through ChangeAnim SCTRL,
// then sets the character animation to "0". Ikemen GO uses "-2" as a no-sprite/invisible anim, so we make
// an exception here
sys.appendToConsole(c.warn() + fmt.Sprintf("attempted change to negative anim (different from -2)"))
animNo = 0
}
c.changeAnimEx(animNo, playerNo, ffx, false)
}
func (c *Char) changeAnim2(animNo int32, ffx string) {
if animNo < 0 && animNo != -2 {
sys.appendToConsole(c.warn() + fmt.Sprintf("attempted change to negative anim (different from -2)"))
animNo = 0
}
c.changeAnimEx(animNo, c.ss.sb.playerNo, ffx, true)
}
func (c *Char) setAnimElem(e int32) {
Expand Down Expand Up @@ -3389,11 +3400,11 @@ func (c *Char) turn() {
switch c.ss.stateType {
case ST_S:
if c.animNo != 5 {
c.changeAnim(5, "")
c.changeAnimEx(5, c.playerNo, "", false)
}
case ST_C:
if c.animNo != 6 {
c.changeAnim(6, "")
c.changeAnimEx(6, c.playerNo, "", false)
}
}
c.setFacing(-c.facing)
Expand Down Expand Up @@ -3472,8 +3483,8 @@ func (c *Char) changeStateEx(no int32, pn int, anim, ctrl int32, ffx string) {
(c.ss.stateType == ST_S || c.ss.stateType == ST_C) && !c.sf(CSF_noautoturn) {
c.turn()
}
if anim >= 0 {
c.changeAnim(anim, ffx)
if anim != -1 {
c.changeAnim(anim, c.playerNo, ffx)
}
if ctrl >= 0 {
c.setCtrl(ctrl != 0)
Expand Down Expand Up @@ -3808,15 +3819,11 @@ func (c *Char) enemyExplodsRemove(en int) {
remove(&sys.underexplDrawlist[en], true)
}
func (c *Char) getAnim(n int32, ffx string, log bool) (a *Animation) {
if n == -1 {
if n == -2 {
return &Animation{}
}
if n < -1 {
// MUGEN 1.1 exports a warning message when attempting to change anim to a negative value, then sets
// the character animation to "0". Ikemen GO uses "-1" as a no-sprite/invisible anim, so we make
// an exception here
sys.appendToConsole(c.warn() + fmt.Sprintf("attempted change to negative anim (below -1)"))
n = 0
if n == -1 {
return nil
}
if ffx != "" && ffx != "s" {
if sys.ffx[ffx] != nil && sys.ffx[ffx].fat != nil {
Expand Down
4 changes: 2 additions & 2 deletions src/script.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ func systemScriptInit(l *lua.LState) {
if ffx {
preffix = "f"
}
c[0].changeAnim(an, preffix)
c[0].changeAnim(an, c[0].playerNo, preffix)
if l.GetTop() >= 3 {
c[0].setAnimElem(int32(numArg(l, 3)))
}
Expand Down Expand Up @@ -1089,7 +1089,7 @@ func systemScriptInit(l *lua.LState) {
l.Push(lua.LNumber(winp))
l.Push(tbl)
if sys.playBgmFlg {
sys.bgm = *newBgm()
sys.bgm.Open("", 1, 100, 0, 0, 0)
sys.playBgmFlg = false
}
sys.clearAllSound()
Expand Down

0 comments on commit 2d16dec

Please sign in to comment.