diff --git a/components/home.js b/components/home.js index 4b5321d..bab801a 100644 --- a/components/home.js +++ b/components/home.js @@ -1047,11 +1047,11 @@ setShowCountryButtons(false) }, [screen, inCrazyGames]) useEffect(() => { - if(multiplayerState?.connected && inCrazyGames) { + if(multiplayerState?.connected) { // check if joined via invite link try { - let code = window.CrazyGames.SDK.game.getInviteParam("code") + let code = inCrazyGames ? window.CrazyGames.SDK.game.getInviteParam("code") : window.location.search.includes("code=") ? window.location.search.split("code=")[1].split("&")[0] : null; let instantJoin = window.location.search.includes("instantJoin"); @@ -1068,6 +1068,7 @@ setShowCountryButtons(false) setOnboardingCompleted(true) setOnboarding(null) setLoading(false) + setOnboardingModalShown(false) setScreen("home") if(code) { diff --git a/components/playerList.js b/components/playerList.js index 3c744b5..0a51059 100644 --- a/components/playerList.js +++ b/components/playerList.js @@ -156,7 +156,7 @@ export default function PlayerList({ multiplayerState, playAgain, backBtn, start )} {(multiplayerState?.gameData?.rounds > (multiplayerState?.gameData?.generated)) && -
{text("generating")} ( {multiplayerState?.gameData?.generated||0} / {multiplayerState?.gameData?.rounds} )
} +{text("generating")}
} { waitingForStart && !host && (multiplayerState?.gameData?.rounds== multiplayerState?.gameData?.generated) && ({text("waitingForHostToStart")}...
diff --git a/ws/classes/Game.js b/ws/classes/Game.js index 52c4c4d..5eb91b1 100644 --- a/ws/classes/Game.js +++ b/ws/classes/Game.js @@ -474,44 +474,57 @@ export default class Game { } else { + if(this.location === "all") { for (let i = 0; i < this.rounds; i++) { let loc; - if(this.location === "all") { // get n random from the list console.log('All locations', allLocations.length); loc = allLocations[Math.floor(Math.random() * allLocations.length)]; this.maxDist = 20000; this.extent = null; - } else if(countries.includes(this.location)) { - try { - let data = await fetch('http://localhost:3001/countryLocations/'+this.location, { - headers: { - 'Content-Type': 'application/json' - }, - }); - data = await data.json(); - if(data.ready && data.locations) { - loc = data.locations[Math.floor(Math.random() * data.locations.length)]; - } else { - loc = await findLatLongRandom({ location: this.location }, getRandomPointInCountry, lookup); - - } - } catch (e) { - console.error('Error getting country locations', e); - } - } this.locations.push(loc); + + this.sendAllPlayers({ + type: 'generating', + generated: this.locations.length, + }) + } + } else { + + try { + let loc; this.maxDist = countryMaxDists[this.location] || 20000; this.extent = officialCountryMaps.find((c) => c.countryCode === this.location)?.extent || null; - // console.log('Extent', this.extent, this.location); + console.time('Country locations '+this.location); + let data = await fetch('http://localhost:3001/countryLocations/'+this.location, { + headers: { + 'Content-Type': 'application/json' + }, + }); + data = await data.json(); + console.timeEnd('Country locations '+this.location); + for(let i = 0; i < this.rounds; i++) { + if(data.ready && data.locations) { + loc = data.locations[Math.floor(Math.random() * data.locations.length)]; + data.locations = data.locations.filter((l) => l !== loc); + } else { + loc = await findLatLongRandom({ location: this.location }, getRandomPointInCountry, lookup); + } + + this.locations.push(loc); this.sendAllPlayers({ type: 'generating', generated: this.locations.length, }) } + } catch (e) { + console.error('Error getting country locations', e); + } + + } this.sendAllPlayers({ type: 'maxDist',