@@ -937,11 +937,22 @@ end
937937-- ; COMMAND LINE QUICK VS
938938-- ;===========================================================
939939function main .f_commandLine ()
940+ local flags = getCommandLineFlags ()
941+ local loadMotif = flags [' -loadmotif' ] ~= nil
942+ if loadMotif then
943+ main .f_default ()
944+ end
945+ main .pauseMenu = loadMotif
940946 setGameMode (' quickvs' )
941- main .pauseMenu = getCommandLineValue (" -loadmotif" ) ~= nil
947+ if loadMotif then
948+ start .f_selectReset (true )
949+ end
942950 setCredits (- 1 )
943- -- No need for asynchronous loading when running from command line. Fixes race conditions with Turns teammate faces
944- modifyGameOption (' Config.BootLoadingMode' , 0 )
951+ -- No need for asynchronous loading when running from command line. Fixes race conditions with Turns teammate faces
952+ modifyGameOption (' Config.BootLoadingMode' , 0 )
953+ if not loadMotif then
954+ loadFightScreen ()
955+ end
945956 local ref = # main .t_selChars
946957 local t_teamMode = {0 , 0 }
947958 local t_numChars = {0 , 0 }
@@ -952,14 +963,10 @@ function main.f_commandLine()
952963 tag = {gameOption (' Options.Tag.Match.Wins' ), gameOption (' Options.Tag.Match.Wins' )},
953964 }
954965 local roundTime = gameOption (' Options.Time' )
955- if getCommandLineValue (" -loadmotif" ) == nil then
956- loadFightScreen ()
957- end
958966 setFightScreenElements ({guardbar = gameOption (' Options.GuardBreak' ), stunbar = gameOption (' Options.Dizzy' ), redlifebar = gameOption (' Options.RedLife' )})
959967 local frames = fightScreenVar (" time.framespercount" )
960968 local t = {}
961969 local t_assignedPals = {}
962- local flags = getCommandLineFlags ()
963970 for k , v in pairs (flags ) do
964971 if k :match (' ^-p[0-9]+$' ) then
965972 local num = tonumber (k :match (' ^-p([0-9]+)' ))
@@ -1033,6 +1040,10 @@ function main.f_commandLine()
10331040 if t_teamMode [side ] == 3 then -- Tag
10341041 t_framesMul [side ] = t_numChars [side ]
10351042 end
1043+ if loadMotif then
1044+ start .p [side ].teamMode = t_teamMode [side ]
1045+ start .p [side ].numChars = t_numChars [side ]
1046+ end
10361047 end
10371048 -- Rounds to win. Determined by enemy team mode
10381049 for side = 1 , 2 do
@@ -1060,47 +1071,57 @@ function main.f_commandLine()
10601071 end
10611072 end
10621073 end
1063- if main .t_stageDef [stage :lower ()] == nil then
1064- if addStage (stage ) == 0 then
1074+ local stageKey = stage :lower ()
1075+ local stageRef = main .t_stageDef [stageKey ]
1076+ if stageRef == nil then
1077+ if loadMotif then
1078+ stageRef = start .f_getStageRef (stage )
1079+ else
1080+ if addStage (stage ) == 0 then
1081+ panicError (" \n Unable to add stage: " .. stage .. " \n " )
1082+ end
1083+ stageRef = # main .t_selStages + 1
1084+ main .t_stageDef [stageKey ] = stageRef
1085+ end
1086+ if stageRef == nil then
10651087 panicError (" \n Unable to add stage: " .. stage .. " \n " )
10661088 end
1067- main .t_stageDef [stage :lower ()] = # main .t_selStages + 1
10681089 end
10691090 clearSelected ()
10701091 setMatchNo (1 )
1071- selectStage (main . t_stageDef [ stage : lower ()] )
1092+ selectStage (stageRef )
10721093 setTeamMode (1 , t_teamMode [1 ], t_numChars [1 ])
10731094 setTeamMode (2 , t_teamMode [2 ], t_numChars [2 ])
10741095 if gameOption (' Debug.DumpLuaTables' ) then main .f_printTable (t , ' debug/t_quickvs.txt' ) end
10751096 local t_params = {}
10761097 -- iterate over the table in -p order ascending
10771098 for _ , v in main .f_sortKeys (t , function (t , a , b ) return t [b ].num > t [a ].num end ) do
1078- if main .t_charDef [v .character :lower ()] == nil then
1079- if flags [' -loadmotif' ] ~= nil then
1080- main .f_addChar (v .character , true , true )
1099+ local charKey = v .character :lower ()
1100+ local charRef = main .t_charDef [charKey ]
1101+ if charRef == nil then
1102+ if loadMotif then
1103+ charRef = start .f_getCharRef (v .character )
10811104 else
10821105 addChar (v .character )
1083- main .t_charDef [v .character :lower ()] = ref
1106+ charRef = ref
1107+ main .t_charDef [charKey ] = charRef
10841108 ref = ref + 1
10851109 end
10861110 end
1087- if main . t_charDef [ v . character : lower ()] == nil then
1111+ if charRef == nil then
10881112 panicError (" \n Unable to add character. No such file or directory: " .. v .character .. " \n " )
10891113 end
1090- selectChar (v .player , main . t_charDef [ v . character : lower ()] , v .pal )
1114+ selectChar (v .player , charRef , v .pal )
10911115 setCom (v .num , v .ai )
10921116 remapInput (v .num , v .input )
10931117 -- fold overrides into loadStart() params (p1.<member>.<field>=...)
10941118 local member = math.ceil (v .num / 2 )
10951119 for k2 , v2 in pairs (v .override ) do
10961120 table.insert (t_params , ' p' .. v .player .. ' .' .. member .. ' .' .. k2 .. ' =' .. tostring (v2 ))
10971121 end
1098- if start ~= nil then
1099- if start .p [v .player ].t_selected == nil then
1100- start .p [v .player ].t_selected = {}
1101- end
1122+ if loadMotif then
11021123 table.insert (start .p [v .player ].t_selected , {
1103- ref = main . t_charDef [ v . character : lower ()] ,
1124+ ref = charRef ,
11041125 pal = v .pal ,
11051126 pn = start .f_getPlayerNo (v .player , # start .p [v .player ].t_selected + 1 )
11061127 })
@@ -1124,20 +1145,21 @@ function main.f_commandLine()
11241145 print (getSessionWarning ())
11251146 os.exit ()
11261147 end
1127- main .f_clearShuffleTables ()
1148+ if loadMotif then
1149+ main .f_clearShuffleTables ()
1150+ end
11281151 refresh ()
11291152 end
1130- table.insert (t_params , ' pausemenu=' .. tostring (main .pauseMenu ))
1131- local params = table.concat (t_params , " , " )
1132- if params == ' ' then
1133- loadStart ()
1153+ if loadMotif then
1154+ table.insert (t_params , 1 , start .f_buildLoadStartParams ())
11341155 else
1135- loadStart ( params )
1156+ table.insert ( t_params , ' pausemenu=false ' )
11361157 end
1158+ loadStart (table.concat (t_params , ' , ' ))
11371159 while loading () do
11381160 -- do nothing
11391161 end
1140- local winner = game ()
1162+ game ()
11411163 if flags [' -log' ] ~= nil then
11421164 main .f_printTable (getGameStats ().Matches [matchNo ()], flags [' -log' ])
11431165 end
@@ -4001,8 +4023,7 @@ main.f_start()
40014023menu .f_start ()
40024024options .f_start ()
40034025
4004- if getCommandLineValue (" -p1" ) ~= nil and getCommandLineValue (" -p2" ) ~= nil then
4005- main .f_default ()
4026+ if getCommandLineValue (" -p1" ) ~= nil and getCommandLineValue (" -p2" ) ~= nil and getCommandLineValue (" -loadmotif" ) ~= nil then
40064027 main .f_commandLine ()
40074028end
40084029
0 commit comments