~starkingdoms/starkingdoms

d434e6ce4f1651998f7dcaa2cfdc0d6f36bfc750 — core 1 year, 11 months ago b013511
make the game not melt servers
2 files changed, 19 insertions(+), 8 deletions(-)

M server/src/main.rs
M starkingdoms-client/src/hub.ts
M server/src/main.rs => server/src/main.rs +9 -2
@@ 23,7 23,9 @@ use crate::mathutil::rot2d;
use bevy::log::Level;
use bevy::log::LogPlugin;
use bevy::math::{vec2, vec3};
use bevy::{ecs::event::ManualEventReader, prelude::*};
use bevy::{
    app::ScheduleRunnerPlugin, ecs::event::ManualEventReader, prelude::*, time::TimePlugin,
};
use bevy_rapier2d::prelude::*;
use bevy_tungstenite_stk::{StkTungsteniteServerConfig, StkTungsteniteServerPlugin, WsEvent};
use component::Input;


@@ 34,6 36,7 @@ use starkingdoms_common::SaveModule;
use starkingdoms_common::{pack_savefile, unpack_savefile, SaveData};
use std::f32::consts::PI;
use std::str::FromStr;
use std::time::Duration;

pub mod component;
pub mod macros;


@@ 71,7 74,11 @@ fn main() {
            addr: IpAddr::from_str("0.0.0.0").unwrap(),
            port: 3000,
        })
        .add_plugins(MinimalPlugins)
        .add_plugins(TaskPoolPlugin::default())
        .add_plugins(TypeRegistrationPlugin)
        .add_plugins(FrameCountPlugin)
        .add_plugins(TimePlugin)
        .add_plugins(ScheduleRunnerPlugin::run_loop(Duration::from_millis(1)))
        .add_plugins(LogPlugin {
            level: Level::DEBUG,
            filter: "wgpu=error,bevy_render=info,bevy_ecs=trace".to_string(),

M starkingdoms-client/src/hub.ts => starkingdoms-client/src/hub.ts +10 -6
@@ 230,17 230,21 @@ export async function hub_connect(
            if (hud.next_poll <= 0) {
              velocity!.innerText = Math.round(
                Math.sqrt(
                  Math.pow(Math.abs(new_part.transform.x/10 - hud.x), 2) +
                    Math.pow(Math.abs(new_part.transform.y/10 - hud.y), 2),
                  Math.pow(Math.abs(new_part.transform.x / 10 - hud.x), 2) +
                    Math.pow(Math.abs(new_part.transform.y / 10 - hud.y), 2),
                ),
              ).toString();
              hud.next_poll = 30;

              hud.x = new_part.transform.x/10;
              hud.y = new_part.transform.y/10;
              hud.x = new_part.transform.x / 10;
              hud.y = new_part.transform.y / 10;

              x_pos!.innerText = Math.round(new_part.transform.x/10).toString();
              y_pos!.innerText = Math.round(new_part.transform.y/10).toString();
              x_pos!.innerText = Math.round(
                new_part.transform.x / 10,
              ).toString();
              y_pos!.innerText = Math.round(
                new_part.transform.y / 10,
              ).toString();
            }
            hud.next_poll--;
          }