Skip to content

Commit 6af1527

Browse files
authored
Merge pull request #3744 from ikemen-engine/fix
fix: randomtest pause menu, bash path, storyboard not found within zip archive, dialogue sctrl wait token, netplay loading readiness reliability
2 parents cd558b9 + 6f8b7b4 commit 6af1527

14 files changed

Lines changed: 196 additions & 92 deletions

File tree

build/Ikemen_GO.command

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
cd "$(dirname "$0")"
33

44
case "$OSTYPE" in

build/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
# Exit in case of failure; print function-trap friendly errors
44
set -o errtrace

build/bundle_run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
# Get the directory of this script (MacOS directory)
44
SCRIPT_DIR="$(dirname "$0")"

external/script/main.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,7 @@ end
941941
--;===========================================================
942942
function main.f_commandLine()
943943
setGameMode('quickvs')
944+
main.pauseMenu = false
944945
setCredits(-1)
945946
-- No need for asynchronous loading when running from command line. Fixes race conditions with Turns teammate faces
946947
modifyGameOption('Config.BootLoadingMode', 0)
@@ -1129,6 +1130,7 @@ function main.f_commandLine()
11291130
main.f_clearShuffleTables()
11301131
refresh()
11311132
end
1133+
table.insert(t_params, 'pausemenu=' .. tostring(main.pauseMenu))
11321134
local params = table.concat(t_params, ", ")
11331135
if params == '' then
11341136
loadStart()
@@ -1885,6 +1887,7 @@ function main.f_default()
18851887
redlifebar = gameOption('Options.RedLife'),
18861888
}
18871889
main.luaPath = 'external/script/default.lua' --path to script executed by start.f_selectMode()
1890+
main.pauseMenu = true
18881891
main.makeRoster = false --if default roster for each match should be generated before first match
18891892
main.matchWins = { --amount of rounds to win for each team side and team mode
18901893
draw = {gameOption('Options.Match.MaxDrawGames'), gameOption('Options.Match.MaxDrawGames')},
@@ -2108,6 +2111,7 @@ main.t_itemname = {
21082111
main.matchWins.tag = {1, 1}
21092112
main.numSimul = {2, 2}
21102113
main.numTag = {2, 2}
2114+
main.pauseMenu = false
21112115
main.persistLife = true
21122116
main.persistMusic = true
21132117
main.persistRounds = true
@@ -2147,6 +2151,7 @@ main.t_itemname = {
21472151
main.motif.winscreen = true
21482152
main.numSimul = {2, 2}
21492153
main.numTag = {2, 2}
2154+
main.pauseMenu = false
21502155
main.resetScore = true
21512156
main.stageOrder = true
21522157
main.storyboard.credits = true
@@ -2174,6 +2179,7 @@ main.t_itemname = {
21742179
main.motif.victoryscreen = true
21752180
main.orderSelect[1] = true
21762181
main.orderSelect[2] = true
2182+
main.pauseMenu = false
21772183
main.selectMenu[2] = true
21782184
main.stageMenu = true
21792185
main.teamMenu[1].simul = true
@@ -2197,6 +2203,7 @@ main.t_itemname = {
21972203
end,
21982204
--RANDOMTEST
21992205
['randomtest'] = function(t, item)
2206+
main.pauseMenu = false
22002207
setGameMode('randomtest')
22012208
hook.run("main.t_itemname", t, item)
22022209
return main.f_randomtest
@@ -3445,6 +3452,7 @@ end
34453452

34463453
function main.f_demoStart()
34473454
main.f_default()
3455+
main.pauseMenu = false
34483456
local palState = {}
34493457
setFightScreenElements({bars = motif.demo_mode.fight.bars.display})
34503458
setGameMode('demo')
@@ -3461,7 +3469,7 @@ function main.f_demoStart()
34613469
end
34623470
hook.run("main.t_itemname", t, item)
34633471
--clearColor(motif[main.background].bgclearcolor[1], motif[main.background].bgclearcolor[2], motif[main.background].bgclearcolor[3])
3464-
loadStart()
3472+
loadStart(start.f_buildLoadStartParams())
34653473
game()
34663474
if not motif.attract_mode.enabled then
34673475
if introWaitCycles >= motif.demo_mode.intro.waitcycles then

external/script/start.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1777,7 +1777,7 @@ function start.f_selectMode()
17771777
--external script execution
17781778
local oldCustomArcadePath = start.customArcadePath
17791779
start.customArcadePath = customArcadePath
1780-
assert(loadfile(path))()
1780+
assert(loadFile(path))()
17811781
start.customArcadePath = oldCustomArcadePath
17821782
--infinite matches flag detected
17831783
if main.makeRoster and start.t_roster[matchNo()] ~= nil and start.t_roster[matchNo()][1] == -1 then
@@ -3778,6 +3778,7 @@ function start.f_buildLoadStartParams(arg, doSelectMissing, t_orderRemap)
37783778
addParam("charparam.time", main.charparam.time)
37793779
addParam("p1.turnsoffset", start.p[1].turnsOffset or 0)
37803780
addParam("p2.turnsoffset", start.p[2].turnsOffset or 0)
3781+
addParam("pausemenu", main.pauseMenu)
37813782
addParam("persistlife", main.persistLife)
37823783
addParam("persistmusic", main.persistMusic)
37833784
addParam("persistrounds", main.persistRounds)

src/common.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import (
1515
"unicode"
1616
"unicode/utf8"
1717

18+
"gopkg.in/ini.v1"
19+
1820
"golang.org/x/text/encoding/japanese"
1921
"golang.org/x/text/transform"
2022
)
@@ -409,6 +411,24 @@ func LoadText(filename string) (string, error) {
409411
return string(bytes), nil
410412
}
411413

414+
func LoadINIText(text string, opts ini.LoadOptions) (*ini.File, error) {
415+
return ini.LoadSources(opts, []byte(NormalizeNewlines(text)))
416+
}
417+
418+
func LoadINIBytes(data []byte, opts ini.LoadOptions) (*ini.File, error) {
419+
return LoadINIText(string(data), opts)
420+
}
421+
422+
func LoadINIFile(filename string, opts ini.LoadOptions) (*ini.File, string, error) {
423+
text, err := LoadText(filename)
424+
if err != nil {
425+
return nil, "", err
426+
}
427+
text = NormalizeNewlines(text)
428+
iniFile, err := LoadINIText(text, opts)
429+
return iniFile, text, err
430+
}
431+
412432
func decodeShiftJIS(input string) string {
413433
bytes := []byte(input)
414434

src/config.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -243,31 +243,32 @@ func loadConfig(def string) (*Config, error) {
243243
userOptions := baseOptions
244244
userOptions.AllowShadows = true
245245

246-
// Choose default config source: prefer physical file, else embedded bytes.
247-
var defaultSrc interface{}
246+
var err error
247+
248+
defaultText := string(defaultConfig)
248249
if fp := FileExist("resources/defaultConfig.ini"); len(fp) != 0 {
249-
defaultSrc = fp
250-
} else {
251-
defaultSrc = defaultConfig
250+
defaultText, err = LoadText(fp)
251+
if err != nil {
252+
return nil, fmt.Errorf("failed to load default config %s: %w", fp, err)
253+
}
252254
}
253255
// Load the INI file
254256
var iniFile *ini.File
255257
var defaultOnlyIni *ini.File
256258
var userIniFile *ini.File
257259

258-
var err error
259260
// Load defaults-only.
260-
defaultOnlyIni, err = ini.LoadSources(baseOptions, defaultSrc)
261+
defaultOnlyIni, err = LoadINIText(defaultText, baseOptions)
261262
if err != nil {
262263
return nil, fmt.Errorf("failed to read defaults-only data: %v", err)
263264
}
264265
// Start merged INI as defaults, then overlay user (first-wins for duplicates).
265-
iniFile, err = ini.LoadSources(baseOptions, defaultSrc)
266+
iniFile, err = LoadINIText(defaultText, baseOptions)
266267
if err != nil {
267268
return nil, fmt.Errorf("failed to read base data: %v", err)
268269
}
269270
if fp := FileExist(def); len(fp) != 0 {
270-
userIniFile, err = ini.LoadSources(userOptions, def)
271+
userIniFile, _, err = LoadINIFile(fp, userOptions)
271272
if err != nil {
272273
return nil, fmt.Errorf("failed to read user data: %v", err)
273274
}

src/motif.go

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,6 +1558,7 @@ func loadMotif(def string) (*Motif, error) {
15581558
var iniFile *ini.File
15591559
var userIniFile *ini.File
15601560
var defaultOnlyIni *ini.File
1561+
var motifText string
15611562

15621563
if err := LoadFile(&def, []string{def, "", "data/"}, "", func(filename string) error {
15631564
def = filename
@@ -1568,10 +1569,11 @@ func loadMotif(def string) (*Motif, error) {
15681569
return fmt.Errorf("Failed to discover external mod system.def files: %w", err)
15691570
}
15701571

1571-
inputBytes, err := LoadText(filename)
1572+
inputText, err := LoadText(filename)
15721573
if err != nil {
15731574
return fmt.Errorf("Failed to load text from %s: %w", filename, err)
15741575
}
1576+
motifText = NormalizeNewlines(inputText)
15751577

15761578
var modsConcat strings.Builder
15771579
for _, p := range modSystemDefs {
@@ -1588,7 +1590,7 @@ func loadMotif(def string) (*Motif, error) {
15881590

15891591
// Preprocess and load INI sources from memory.
15901592
// Motif file overrides mods
1591-
baseTxt := NormalizeNewlines(string(inputBytes))
1593+
baseTxt := motifText
15921594
modsTxt := modsConcat.String()
15931595
var combined string
15941596
if modsTxt != "" {
@@ -1599,22 +1601,22 @@ func loadMotif(def string) (*Motif, error) {
15991601
} else {
16001602
combined = baseTxt
16011603
}
1602-
normalizedInput := []byte(preprocessINIContent(combined))
1603-
normalizedDefault := []byte(preprocessINIContent(NormalizeNewlines(string(defaultMotif))))
1604+
normalizedInput := preprocessINIContent(combined)
1605+
normalizedDefault := preprocessINIContent(NormalizeNewlines(string(defaultMotif)))
16041606

16051607
// Defaults-only baseline
1606-
defaultOnlyIni, err = ini.LoadSources(baseOptions, normalizedDefault)
1608+
defaultOnlyIni, err = LoadINIText(normalizedDefault, baseOptions)
16071609
if err != nil {
16081610
return fmt.Errorf("Failed to load defaults-only INI from memory: %w", err)
16091611
}
16101612

16111613
// merged starts as defaults, then overlay user (first-wins for duplicates in user)
1612-
iniFile, err = ini.LoadSources(baseOptions, normalizedDefault)
1614+
iniFile, err = LoadINIText(normalizedDefault, baseOptions)
16131615
if err != nil {
16141616
return fmt.Errorf("Failed to load merged baseline INI from memory: %w", err)
16151617
}
16161618

1617-
userIniFile, err = ini.LoadSources(userOptions, normalizedInput)
1619+
userIniFile, err = LoadINIText(normalizedInput, userOptions)
16181620
if err != nil {
16191621
return fmt.Errorf("Failed to load user INI source from memory: %w", err)
16201622
}
@@ -1834,11 +1836,7 @@ func loadMotif(def string) (*Motif, error) {
18341836
m.loadFiles()
18351837
sys.keepAlive()
18361838

1837-
str, err := LoadText(def)
1838-
if err != nil {
1839-
return nil, err
1840-
}
1841-
lines, i := SplitAndTrim(str, "\n"), 0
1839+
lines, i := SplitAndTrim(motifText, "\n"), 0
18421840
m.AnimTable = ReadAnimationTable(m.Def, m.Sff, &m.Sff.palList, lines, &i, true)
18431841
i = 0
18441842

@@ -3362,10 +3360,15 @@ func (me *MotifMenu) init(m *Motif) {
33623360
}
33633361
openPressed := sys.esc || sys.uiRawInput(pm.Menu.Cancel.Key, -1)
33643362

3365-
if sys.escExit() || (sys.netplay() && openPressed) {
3366-
if sys.netplay() {
3363+
if !sys.sel.gameParams.PauseMenu {
3364+
if openPressed {
33673365
sys.esc = true
3366+
sys.endMatch = true
33683367
}
3368+
return
3369+
}
3370+
3371+
if sys.escExit() {
33693372
sys.endMatch = true
33703373
return
33713374
}
@@ -4823,7 +4826,7 @@ func (di *MotifDialogue) step(m *Motif) {
48234826
}
48244827

48254828
// If line is fully rendered, handle auto-switch after SwitchTime
4826-
if di.lineFullyRendered {
4829+
if di.lineFullyRendered && di.wait <= 0 {
48274830
di.switchCounter++
48284831
if di.switchCounter >= int(m.DialogueInfo.SwitchTime) {
48294832
di.advanceLine(m)

0 commit comments

Comments
 (0)