@@ -214,15 +214,36 @@ DATA colorThemeMap() = $B4,$88, $84,$08, $22,$28, $04,$08,' NTSC
214214DATA = $A4 ,$78 , $74 ,$08 , $12 ,$18 , $04 ,$08 ' PAL
215215colorTheme =-1
216216
217- gameversion =1
218- serverEndpoint$=" N:https://fujillama.spysoft.nz"
219- ' serverEndpoint$="N:http://192.168.68.100:8080" ' Local server for testing
217+ gameversion =2
218+ serverEndpoint$=" "
219+ query$=" "
220+ ' Read server endpoint stored from Lobby
221+ @NReadAppKey AK_LOBBY_CREATOR_ID, AK_LOBBY_APP_ID , AK_LOBBY_KEY_SERVER , &serverEndpoint $
222+
223+ ' Parse endpoint url into server and query
224+ if serverEndpoint$<>" "
225+ for i =1 to len (serverEndpoint $)
226+ if serverEndpoint$[i,1 ]=" ?"
227+ query$=serverEndpoint $[i]
228+ serverEndpoint$=serverEndpoint $[1 ,i -2 ]
229+ exit
230+ endif
231+ next
232+ else
233+ ' Default to known server if not specified by lobby. Override for local testing
234+ serverEndpoint$=" N:https://fujillama.spysoft.nz"
235+ QUERY$=" " $9B
236+ ' serverEndpoint$="N:http://192.168.68.100:8080" ' Local server for testing
237+ endif
238+
239+ ' Write server endpoint back to app key so when game is relaunched without the lobby it uses the same server
240+ @NWriteAppKey AK_LOBBY_CREATOR_ID, AK_LOBBY_APP_ID , AK_LOBBY_KEY_SERVER , &serverEndpoint $
241+
220242
221243' Fuji-Net Setup Variblies
222244UNIT =1
223245JSON_MODE =1
224246URL$=" "
225- QUERY$=" " $9B
226247JSON$=" /tables"
227248dummy$=" "
228249
@@ -298,7 +319,17 @@ WaitTime=Time
298319' Loop until the player has successfully joined a table
299320DO
300321 Repeat
301- @tableSelection
322+ if QUERY$[1 ,1 ]<>" ?"
323+ @tableSelection
324+ else
325+ tablenumber =1
326+ for i =1 to len (QUERY $)
327+ if QUERY$[i,1 ]=" ="
328+ TableID$(TableNumber )=QUERY $[i +1 ,5 ]
329+ endif
330+ next i
331+ @JoinTable
332+ Endif
302333 @checkErrors
303334 UNTIL OK =1
304335
@@ -520,6 +551,10 @@ PROC TableSelection
520551 TableNumber =K -48 ' Convert ASCII to number
521552 UNTIL TableNumber >0 and TableNumber <8
522553 DEC TableNumber ' Convert to array index
554+ @JoinTable
555+ ENDPROC
556+
557+ Proc JoinTable
523558 JSON$=" /join?table="
524559 JSON$=+TableID $(TableNumber ) ' Join the table based on the number selected
525560 JSON$=+" &player="
@@ -529,7 +564,7 @@ PROC TableSelection
529564 @CallFujiNet ' Call the FujiNet API to join the table
530565 @NInputInit UNIT, &responseBuffer ' Initialize reading the api response
531566 @NInput &dummy $ ' Read the response from the FujiNet API
532- ENDPROC
567+ EndProc
533568
534569PROC ReadKeyPresses
535570 K =KEY ()
@@ -1488,6 +1523,7 @@ ENDPROC
14881523' --------------------------------------------------------------
14891524PROC CallFujiNet
14901525 dummy$=" "
1526+ QUERY$=" " $9B
14911527 URL$=serverEndpoint $
14921528 URL$=+JSON $
14931529 URL$=+" " $9B
0 commit comments