A .dockerignore => .dockerignore +1 -0
@@ 0,0 1,1 @@
+target<
\ No newline at end of file
A server/Dockerfile => server/Dockerfile +6 -0
@@ 0,0 1,6 @@
+FROM rust:alpine
+
+WORKDIR /build
+COPY .. .
+
+RUN cargo build --profile release-ci<
\ No newline at end of file
M server/src/main.rs => server/src/main.rs +37 -36
@@ 318,42 318,43 @@ fn on_message(
} => {
// auth
// plz no remove
- /*if let Some(token) = jwt {
- let key: Hmac<Sha256> = Hmac::new_from_slice(&app_keys.app_key).unwrap();
- let claims: UserToken = match token.verify_with_key(&key) {
- Ok(c) => c,
- Err(e) => {
- event_queue.push(WsEvent::Send {
- to: *from,
- message: Packet::Message { message_type: MessageType::Error, actor: "SERVER".to_string(), content: format!("Token is invalid or verification failed: {e}. Please log in again, or contact StarKingdoms staff if the problem persists.") }.into(),
- });
- event_queue.push(WsEvent::Close { addr: *from });
- continue;
- }
- };
-
- if claims.permission_level < REQUIRED_PERM_LEVEL {
- event_queue.push(WsEvent::Send {
- to: *from,
- message: Packet::Message { message_type: MessageType::Error, actor: "SERVER".to_string(), content: format!("Permission level {} is too low, {REQUIRED_PERM_LEVEL} is required. If your permissions were just changed, you need to log out and log back in for the change to take effect. If you believe this is a mistake, contact StarKingdoms staff.", claims.permission_level) }.into(),
- });
- event_queue.push(WsEvent::Close { addr: *from });
- continue;
- }
-
- event_queue.push(WsEvent::Send {
- to: *from,
- message: Packet::Message { message_type: MessageType::Server, actor: "StarKingdoms Team".to_string(), content: "Thank you for participating in the StarKingdoms private alpha! Your feedback is essential to improving the game, so please give us any feedback you have in the Discord! <3".to_string() }.into(),
- });
- } else if REQUIRED_PERM_LEVEL != 0 {
- event_queue.push(WsEvent::Send {
- to: *from,
- message: Packet::Message { message_type: MessageType::Error, actor: "SERVER".to_string(), content: "Authentication is required to join this server at the moment. Log in and try again, or try again later.".to_string() }.into(),
- });
- event_queue.push(WsEvent::Close { addr: *from });
- continue;
- }*/
-
+ /*
+ if let Some(token) = jwt {
+ let key: Hmac<Sha256> = Hmac::new_from_slice(&app_keys.app_key).unwrap();
+ let claims: UserToken = match token.verify_with_key(&key) {
+ Ok(c) => c,
+ Err(e) => {
+ event_queue.push(WsEvent::Send {
+ to: *from,
+ message: Packet::Message { message_type: MessageType::Error, actor: "SERVER".to_string(), content: format!("Token is invalid or verification failed: {e}. Please log in again, or contact StarKingdoms staff if the problem persists.") }.into(),
+ });
+ event_queue.push(WsEvent::Close { addr: *from });
+ continue;
+ }
+ };
+
+ if claims.permission_level < REQUIRED_PERM_LEVEL {
+ event_queue.push(WsEvent::Send {
+ to: *from,
+ message: Packet::Message { message_type: MessageType::Error, actor: "SERVER".to_string(), content: format!("Permission level {} is too low, {REQUIRED_PERM_LEVEL} is required. If your permissions were just changed, you need to log out and log back in for the change to take effect. If you believe this is a mistake, contact StarKingdoms staff.", claims.permission_level) }.into(),
+ });
+ event_queue.push(WsEvent::Close { addr: *from });
+ continue;
+ }
+
+ event_queue.push(WsEvent::Send {
+ to: *from,
+ message: Packet::Message { message_type: MessageType::Server, actor: "StarKingdoms Team".to_string(), content: "Thank you for participating in the StarKingdoms private alpha! Your feedback is essential to improving the game, so please give us any feedback you have in the Discord! <3".to_string() }.into(),
+ });
+ } else if REQUIRED_PERM_LEVEL != 0 {
+ event_queue.push(WsEvent::Send {
+ to: *from,
+ message: Packet::Message { message_type: MessageType::Error, actor: "SERVER".to_string(), content: "Authentication is required to join this server at the moment. Log in and try again, or try again later.".to_string() }.into(),
+ });
+ event_queue.push(WsEvent::Close { addr: *from });
+ continue;
+ }
+ */
let angle: f32 = {
let mut rng = rand::thread_rng();
rng.gen::<f32>() * std::f32::consts::PI * 2.
M starkingdoms-client/src/components/ui/Button.svelte => starkingdoms-client/src/components/ui/Button.svelte +11 -0
@@ 15,6 15,7 @@
on:click
on:focus
{style}
+ class:btn-disabled={disabled}
class:btn-selected={selected}>
<slot />
</button>
@@ 54,4 55,14 @@
@extend %standard-hover;
background-color: var(--error-transparent);
}
+
+ .btn-disabled {
+ @extend %standard;
+ border: 2px solid gray;
+ color: rgba(205, 214, 244, 60);
+ }
+ .btn-disabled:hover {
+ background-color: transparent;
+ cursor: not-allowed;
+ }
</style>
M starkingdoms-client/src/config.json => starkingdoms-client/src/config.json +7 -23
@@ 1,6 1,8 @@
{
- "servers": {
- "stk-prod": {
+ "configSerial": 2024040503,
+ "backplaneBaseUrl": "https://backplane.starkingdoms.io",
+ "environments": [
+ {
"name": "StarKingdoms",
"clientHubUrl": "wss://starkingdoms.io/hub",
"apiBaseUrl": "https://api.starkingdoms.io",
@@ 8,30 10,12 @@
"isDevelopment": false,
"isPrimary": true
},
- "stk-beta": {
- "name": "StarKingdoms Beta",
- "clientHubUrl": "wss://beta.starkingdoms.io/hub",
- "apiBaseUrl": "https://api.beta.starkingdoms.io",
- "isProduction": false,
- "isDevelopment": false,
- "isPrimary": false
- },
- "stk-unstable": {
- "name": "StarKingdoms Unstable",
- "clientHubUrl": "wss://unstable.starkingdoms.io/hub",
- "apiBaseUrl": "https://api.unstable.starkingdoms.io",
- "isProduction": false,
- "isDevelopment": false,
- "isPrimary": false
- },
- "local-dev": {
+ {
"name": "Local (Development)",
"clientHubUrl": "ws://localhost:3000/hub",
"apiBaseUrl": "http://localhost:8080",
"isProduction": false,
- "isDevelopment": true,
- "isPrimary": false
+ "isDevelopment": true
}
- },
- "backplane": "https://backplane.starkingdoms.io"
+ ]
}
M starkingdoms-client/src/config.ts => starkingdoms-client/src/config.ts +5 -3
@@ 6,10 6,12 @@ const logger = createDebug("config");
const CONFIG_URL = "https://configuration.starkingdoms.io";
export interface Config {
- servers: { [id: string]: ConfigServer };
- backplane: string;
+ configSerial: number;
+ backplaneBaseUrl: string;
+ environments: Environment[];
}
-export interface ConfigServer {
+
+export interface Environment {
name: string;
clientHubUrl: string;
apiBaseUrl: string;
M starkingdoms-client/src/pages/Home.svelte => starkingdoms-client/src/pages/Home.svelte +11 -12
@@ 42,7 42,7 @@
let nonprod_warning: HTMLSpanElement;
- let server = "";
+ let server: number = 0;
let username = "";
function playGame() {
@@ 51,8 51,8 @@
function updateNonprodWarning() {
if (
- config.servers[server] !== undefined &&
- !config.servers[server].isProduction
+ config.environments[server] !== undefined &&
+ !config.environments[server].isProduction
) {
nonprod_warning.classList.remove("hidden");
} else {
@@ 64,8 64,8 @@
<Popup title="StarKingdoms" centered id="title-popup" style="max-width: 800px;">
<ColumnTable>
<Column>
- <h2></h2>
- test!
+ <h2>About</h2>
+ StarKingdoms is a browser game about floating through space.
</Column>
<VerticalRule />
<Column>
@@ 86,15 86,14 @@
on:change={updateNonprodWarning}
id="select"
class="select"
- autocomplete="off">
- <option disabled required selected value="">
+ autocomplete="off"
+ required>
+ <option disabled value="">
<em>Choose a server..</em>
</option>
- {#each Object.entries(config.servers) as [server_id, server]}
- {#if server.isDevelopment && !is_development}
- <!-- Ignore. Dev server and we arent dev -->
- {:else}
- <option value={server_id}>{server.name}</option>
+ {#each config.environments as env, i}
+ {#if !(env.isDevelopment && !is_development)}
+ <option value={i}>{env.name}</option>
{/if}
{/each}
</select>
M starkingdoms-client/src/pages/Play.svelte => starkingdoms-client/src/pages/Play.svelte +7 -5
@@ 83,10 83,10 @@
}, 5000);
return;
}
- let server_id = params.get("srv")!;
+ let server_id = Number.parseInt(params.get("srv")!);
let username = params.get("username")!;
- /*if (!Object.keys(config.servers).includes(server_id)) {
+ if (!config.environments[server_id]) {
chatbox.addMessage(
"server-error",
"The selected server is currently unavailable. Redirecting to main menu in 5 seconds.",
@@ 95,9 95,9 @@
window.location.href = "/";
}, 5000);
return;
- }*/
+ }
- let server = config.servers[server_id];
+ let server = config.environments[server_id];
await hub_connect(
server.clientHubUrl,
@@ 165,7 165,9 @@
<tbody>
<tr>
<td id="leave">
- <Button on:click={beam_out}>Beam out</Button>
+ <Button disabled={!global.saveEligible} on:click={beam_out}>
+ Beam out
+ </Button>
</td>
<td id="pos">
<span id="pos-val-x" bind:this={x_pos}>--</span>
M starkingdoms-client/src/pages/ShipEditor.svelte => starkingdoms-client/src/pages/ShipEditor.svelte +7 -1
@@ 209,7 209,13 @@
ctx.save();
ctx.translate(canvas_x + grid_size / 2, canvas_y + grid_size / 2);
ctx.rotate((rotation * Math.PI) / 2);
- ctx.drawImage(img, -grid_size/2, -grid_size/2, grid_size, grid_size);
+ ctx.drawImage(
+ img,
+ -grid_size / 2,
+ -grid_size / 2,
+ grid_size,
+ grid_size,
+ );
ctx.restore();
});
});