- {room.players.length} / {room.maxPlayers} | {#if room.players.length > 4}
- {#each room.players.slice(0, 4) as player}
- {player.nickname}{#if player !== room.players[3]},{" "}
- {/if}
- {/each}
- and {room.players.length - 4}
- {room.players.length - 4 === 1 ? "other" : "others"}
- {:else}
- {#each room.players as player}
- {player.nickname}{#if player !== room.players[room.players.length - 1]},{" "}
- {/if}
- {/each}
- {/if} | {room.hasPassword ? "Private" : "Public"} | {room.address}:{room.port}
+
+
+
+ {#if room.game?.iconUrl}
+

+ {/if}
+
+
+ {room.name}
+ ({room.game?.name || "No preferred game"})
+
+
{room.description}
+
+ {room.players.length} / {room.maxPlayers} | {#if room.players.length > 4}
+ {#each room.players.slice(0, 4) as player}
+ {player.nickname}{#if player !== room.players[3]},{" "}
+ {/if}
+ {/each}
+ and {room.players.length - 4}
+ {room.players.length - 4 === 1 ? "other" : "others"}
+ {:else}
+ {#each room.players as player}
+ {player.nickname}{#if player !== room.players[room.players.length - 1]},{" "}
+ {/if}
+ {/each}
+ {/if} | {room.hasPassword ? "Private" : "Public"} | {room.address}:{room.port}
+
diff --git a/src/hooks.server.ts b/src/hooks.server.ts
index 04d86a3..5d61ec1 100644
--- a/src/hooks.server.ts
+++ b/src/hooks.server.ts
@@ -4,6 +4,7 @@ import { building } from "$app/environment";
import type { Handle } from "@sveltejs/kit";
import { WebSocketServer } from "ws";
import { userRepo } from "$lib/server/repo";
+import { globalData } from "$lib/server/other";
let server: WebSocketServer;
@@ -22,6 +23,20 @@ function initServer() {
} catch {}
}
+async function fetchGames() {
+ console.log("Fetching game data");
+ const res = await fetch("https://raw.githubusercontent.com/blawar/titledb/master/US.en.json");
+ let gamesText = await res.text();
+ gamesText = gamesText.replaceAll(/\\u[0-9a-fA-F]{4}/gm, "");
+ globalData.games = Object.values(JSON.parse(gamesText));
+ console.log("Fetched game data");
+}
+
+async function setupGames() {
+ await fetchGames();
+ setInterval(fetchGames, 1000 * 60 * 60 * 12);
+}
+
const runAllTheInitFunctions = async () => {
if (!db.isInitialized) await db.initialize();
// sigh.
@@ -34,6 +49,9 @@ const runAllTheInitFunctions = async () => {
} catch {
console.error("Could not initialize WebSocket server");
}
+ if (globalData.games.length === 0) {
+ await setupGames();
+ }
};
if (!building) {
diff --git a/src/lib/server/class/Room.ts b/src/lib/server/class/Room.ts
index 38d96a3..e2b8d59 100644
--- a/src/lib/server/class/Room.ts
+++ b/src/lib/server/class/Room.ts
@@ -1,4 +1,5 @@
import type { IRoom, IRoomConfig, RoomPlayer } from "$types/rooms";
+import { globalData, type SwitchGame } from "../other";
import type { SuyuUser } from "../schema";
import { v4 } from "uuid";
@@ -52,6 +53,9 @@ export class Room {
netVersion: 1,
owner: this.host.username,
port: parseInt(parsed[1]),
+ game: globalData.games.find(
+ (g) => g.name.toUpperCase().trim() === config.gameName.toUpperCase().trim(),
+ ),
};
}
diff --git a/src/lib/server/other/index.ts b/src/lib/server/other/index.ts
index f961d4b..c542a23 100644
--- a/src/lib/server/other/index.ts
+++ b/src/lib/server/other/index.ts
@@ -1,14 +1,14 @@
-interface SwitchGame {
+export interface SwitchGame {
bannerUrl: string;
category: string[];
description: string;
- developer: null;
- frontBoxArt: null;
+ // developer: null;
+ // frontBoxArt: null;
iconUrl: string;
id: string;
intro: null | string;
isDemo: boolean;
- key: null;
+ // key: null;
languages: string[];
name: string;
nsuId: number;
@@ -16,12 +16,12 @@ interface SwitchGame {
publisher: string;
rating: number;
ratingContent: string[];
- region: null;
+ // region: null;
releaseDate: number;
rightsId: string;
screenshots: string[];
size: number;
- version: null;
+ // version: null;
}
export const globalData: {
games: SwitchGame[];
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte
index ed84007..6ff716a 100644
--- a/src/routes/+layout.svelte
+++ b/src/routes/+layout.svelte
@@ -130,7 +130,7 @@
$: navItems = [
{
name: "Blog",
- href: "/blog",
+ href: "/coming-soon",
},
{
name: "Docs",
@@ -264,7 +264,7 @@
diff --git a/src/routes/+page.server.ts b/src/routes/+page.server.ts
index 66a07d6..2ce74a2 100644
--- a/src/routes/+page.server.ts
+++ b/src/routes/+page.server.ts
@@ -1,6 +1,5 @@
import { building } from "$app/environment";
import { DISCORD_USER_TOKEN, GITLAB_API_TOKEN } from "$env/static/private";
-import { globalData } from "$lib/server/other";
let memberCount = 0;
let starCount = 0;
@@ -41,19 +40,9 @@ async function fetchServerSideData() {
console.log("Stars count:", starCount);
}
-async function fetchSlowServerSideData() {
- console.log("Fetching game data");
- const res = await fetch("https://raw.githubusercontent.com/blawar/titledb/master/US.en.json");
- let gamesText = await res.text();
- gamesText = gamesText.replaceAll(/\\u[0-9a-fA-F]{4}/gm, "");
- globalData.games = Object.values(JSON.parse(gamesText));
- console.log("Fetched game data");
-}
-
if (!building) {
- await Promise.all([await fetchServerSideData(), await fetchSlowServerSideData()]);
+ await fetchServerSideData();
setInterval(fetchServerSideData, 1000 * 60 * 10);
- setInterval(fetchSlowServerSideData, 1000 * 60 * 60 * 12);
}
export async function load({ cookies }) {
diff --git a/src/routes/account/+layout.svelte b/src/routes/account/+layout.svelte
index 26d1646..1ae779a 100644
--- a/src/routes/account/+layout.svelte
+++ b/src/routes/account/+layout.svelte
@@ -168,13 +168,13 @@
{#key data.url}