M api/src/routes/beamin.rs => api/src/routes/beamin.rs +3 -2
@@ 76,6 76,7 @@ pub async fn beam_in(data: Json<BeaminRequest>, state: Data<AppState>) -> HttpRe
.order_by_desc(starkingdoms_api_entities::entity::user_savefile::Column::Timestamp).all(&state.conn).await {
Ok(sf) => sf,
Err(e) => {
+ error!("database error: {}", e);
return HttpResponse::InternalServerError().json(APIErrorsResponse {
errors: vec![
APIError {
@@ 98,12 99,12 @@ pub async fn beam_in(data: Json<BeaminRequest>, state: Data<AppState>) -> HttpRe
],
});
}
-
+
let save = &user_savefile[0];
let save_id = &save.id;
let save_data_str = &save.data;
let save_data: APISavedPlayerData = toml::from_str(save_data_str).expect("database contained corrupted player save data");
-
+
HttpResponse::Ok().json(BeaminResponse {
save_id: save_id.clone(),
save: save_data
M api/src/routes/beamout.rs => api/src/routes/beamout.rs +1 -1
@@ 6,7 6,7 @@ use hmac::digest::KeyInit;
use hmac::Hmac;
use jwt::VerifyWithKey;
use log::error;
-use sea_orm::{ActiveModelTrait, ColumnTrait, EntityTrait, IntoActiveModel, QueryFilter, QueryOrder};
+use sea_orm::{ActiveModelTrait, IntoActiveModel};
use serde::{Deserialize, Serialize};
use sha2::Sha256;
use ulid::Ulid;
M api/src/routes/select_realm.rs => api/src/routes/select_realm.rs +2 -2
@@ 1,8 1,8 @@
use std::collections::HashMap;
use actix_web::{get, HttpResponse};
-use actix_web::web::{Data, Query};
+use actix_web::web::{Data};
use log::error;
-use serde::{Deserialize, Serialize};
+use serde::{Serialize};
use tera::Context;
use crate::AppState;
use crate::config::{CONFIG, StarkingdomsApiConfigRealm};
M api/starkingdoms_api_migration/src/m20230420_144333_create_table_user_data.rs => api/starkingdoms_api_migration/src/m20230420_144333_create_table_user_data.rs +0 -1
@@ 1,5 1,4 @@
use sea_orm_migration::prelude::*;
-use crate::m20230417_162824_create_table_users::User;
use crate::m20230417_164240_create_table_user_auth_realms::UserAuthRealm;
#[derive(DeriveMigrationName)]
M server/src/entity.rs => server/src/entity.rs +5 -4
@@ 15,6 15,7 @@ pub fn get_entity_id() -> EntityId {
id
}
+#[derive(Default)]
pub struct EntityHandler {
pub entities: Entities,
}
@@ 41,7 42,7 @@ impl EntityHandler {
planets.remove(i);
}
}
- if planets.len() == 0 {
+ if planets.is_empty() {
return None;
}
Some(planets[0].clone())
@@ 73,7 74,7 @@ impl EntityHandler {
players.remove(i);
}
}
- if players.len() == 0 {
+ if players.is_empty() {
return None;
}
Some(players[0].clone().1)
@@ 82,7 83,7 @@ impl EntityHandler {
pub fn gravity(&self, position: (f64, f64), mass: f64) -> (f64, f64) {
let mut direction = Vector2::zeros();
let planets = self.get_planets();
- for planet in planets.clone() {
+ for planet in planets {
let planet_grav = planet.gravity(position, mass);
direction.x += planet_grav.0;
direction.y += planet_grav.1;
@@ 93,7 94,7 @@ impl EntityHandler {
pub fn to_protocol(&self) -> ClientHandlerMessage {
let mut planets = vec![];
- for planet in self.get_planets().clone() {
+ for planet in self.get_planets() {
// TODO: Adjust codegen to use f64
planets.push(starkingdoms_protocol::planet::Planet {
planet_type: planet.planet_type.into(),
M server/src/handler.rs => server/src/handler.rs +0 -1
@@ 20,7 20,6 @@ use crate::{send, recv, SCALE};
use async_std::{sync::RwLock, channel::Receiver};
use async_std::net::TcpStream;
use async_tungstenite::WebSocketStream;
-use starkingdoms_protocol::api::APISavedPlayerData;
use crate::api::{load_player_data_from_api, save_player_data_to_api};
pub async fn handle_client(mgr: ClientManager, entities: Arc<RwLock<EntityHandler>>, data: Arc<RwLock<PhysicsData>>,
M server/src/main.rs => server/src/main.rs +1 -2
@@ 3,10 3,9 @@ use std::net::SocketAddr;
use async_std::io::WriteExt;
use async_std::sync::Arc;
use async_std::net::{TcpListener, TcpStream};
-use entity::{Entities, EntityHandler};
+use entity::{EntityHandler};
use manager::PhysicsData;
use nalgebra::vector;
-use planet::Planets;
use rapier2d_f64::prelude::{MultibodyJointSet, ImpulseJointSet, ColliderSet, RigidBodySet, NarrowPhase, BroadPhase, IslandManager, CCDSolver, IntegrationParameters};
use lazy_static::lazy_static;
use log::{error, info, Level, warn};
M server/src/manager.rs => server/src/manager.rs +2 -1
@@ 27,7 27,8 @@ impl Player {
APISavedPlayerData {}
}
- pub fn load_api_data(&mut self, data: &APISavedPlayerData) {
+ pub fn load_api_data(&mut self, _data: &APISavedPlayerData) {
+
}
}
M server/src/orbit/mod.rs => server/src/orbit/mod.rs +1 -0
@@ 1,4 1,5 @@
pub mod constants;
+#[allow(clippy::module_inception)]
pub mod orbit;
pub mod newtonian;
pub mod kepler;
M server/src/orbit/orbit.rs => server/src/orbit/orbit.rs +2 -4
@@ 1,15 1,13 @@
// Mostly stolen from SebLague's plane game
// thanks
-use log::debug;
use nalgebra::{vector, Vector2};
use crate::orbit::newtonian::solve_kepler_with_newtonian;
-use crate::orbit::vis_viva::vis_viva;
-use crate::planet::GRAVITY;
+#[allow(clippy::too_many_arguments)]
pub fn calculate_vector_of_orbit(periapsis: f64, apoapsis: f64, t: f64, current_x: f64, current_y: f64, orbiting_x: f64, orbiting_y: f64, mass: f64, step: f64) -> Vector2<f64> {
let semi_major_length = (apoapsis + periapsis) / 2.0;
- let linear_eccentricity = semi_major_length - periapsis; // distance between center and focus
+ let _linear_eccentricity = semi_major_length - periapsis; // distance between center and focus
let target = calculate_world_position_of_orbit(calculate_point_on_orbit(periapsis, apoapsis, t), vector![orbiting_x, orbiting_y]);
let target_x = target[0];
M server/src/planet.rs => server/src/planet.rs +4 -6
@@ 1,11 1,9 @@
use std::collections::HashMap;
-use std::sync::Arc;
-use async_std::sync::RwLock;
use nalgebra::{Vector2, vector};
use rapier2d_f64::prelude::{RigidBodyHandle, RigidBodySet, ColliderBuilder, RigidBodyBuilder, ColliderSet};
use starkingdoms_protocol::planet::PlanetType;
-use crate::entity::{Entities, get_entity_id, Entity, EntityId, EntityHandler};
+use crate::entity::{Entities, get_entity_id, Entity, EntityId};
use crate::{SCALE, manager::ClientHandlerMessage};
use crate::orbit::constants::{EARTH_MASS, EARTH_RADIUS, MOON_APOAPSIS, MOON_MASS, MOON_PERIAPSIS, MOON_RADIUS};
use crate::orbit::orbit::{calculate_point_on_orbit, calculate_world_position_of_orbit};
@@ 46,7 44,7 @@ impl Planets {
self.planets.get_mut(planet_id)
}
- pub async fn make_planet(planet_id: &str,
+ pub async fn make_planet(_planet_id: &str,
planet_type: PlanetType, mass: f64, radius: f64,
position: (f64, f64), rigid_body_set: &mut RigidBodySet, collider_set: &mut ColliderSet
) -> (EntityId, Entity) {
@@ 70,8 68,8 @@ impl Planets {
}))
}
- pub async fn new(rigid_body_set: &mut RigidBodySet, collider_set: &mut ColliderSet,
- entities: &mut Entities) -> Vec<EntityId> {
+ pub async fn create_planets(rigid_body_set: &mut RigidBodySet, collider_set: &mut ColliderSet,
+ entities: &mut Entities) -> Vec<EntityId> {
let mut planet_ids: Vec<EntityId> = Vec::new();
let (earth_id, entity) = Planets::make_planet(
"earth",
M server/src/timer.rs => server/src/timer.rs +9 -9
@@ 1,13 1,14 @@
use std::{time::Duration, sync::Arc};
-use log::{debug, warn};
+use log::{warn};
use nalgebra::{vector, point};
use rapier2d_f64::prelude::{PhysicsPipeline};
use async_std::sync::RwLock;
use async_std::task::sleep;
use starkingdoms_protocol::{player::Player, planet::PlanetType};
-use crate::{manager::{ClientHandlerMessage, ClientManager, PhysicsData}, SCALE, planet::{Planets, Planet}, entity::{Entities, Entity, EntityHandler}};
-use crate::orbit::constants::{EARTH_MASS, GAME_ORBITS_ENABLED, MOON_APOAPSIS, MOON_MASS, MOON_ORBIT_TIME, MOON_PERIAPSIS};
-use crate::orbit::orbit::{calculate_point_on_orbit, calculate_vector_of_orbit, calculate_world_position_of_orbit};
+use crate::{manager::{ClientHandlerMessage, ClientManager, PhysicsData}, SCALE, planet::{Planets, Planet}};
+use crate::entity::EntityHandler;
+use crate::orbit::constants::{GAME_ORBITS_ENABLED, MOON_APOAPSIS, MOON_ORBIT_TIME, MOON_PERIAPSIS};
+use crate::orbit::orbit::{calculate_point_on_orbit, calculate_world_position_of_orbit};
pub const ROTATIONAL_FORCE: f64 = 100.0;
pub const LATERAL_FORCE: f64 = 100.0;
@@ 16,7 17,7 @@ pub async fn timer_main(mgr: ClientManager, physics_data: Arc<RwLock<PhysicsData
let mut pipeline = PhysicsPipeline::new();
let mut time = 0.0;
- let planet_ids;
+ let _planet_ids;
{
let mut data_handle = physics_data.write().await;
@@ 24,7 25,7 @@ pub async fn timer_main(mgr: ClientManager, physics_data: Arc<RwLock<PhysicsData
let mut rigid_body_set = data_handle.rigid_body_set.clone();
let mut collider_set = data_handle.collider_set.clone();
- planet_ids = Planets::new(&mut rigid_body_set, &mut collider_set, &mut entities.write().await.entities).await;
+ _planet_ids = Planets::create_planets(&mut rigid_body_set, &mut collider_set, &mut entities.write().await.entities).await;
data_handle.rigid_body_set = rigid_body_set;
data_handle.collider_set = collider_set;
@@ 41,12 42,11 @@ pub async fn timer_main(mgr: ClientManager, physics_data: Arc<RwLock<PhysicsData
// IT MAY ALWAYS BE TRUE
// THATS FINE
if GAME_ORBITS_ENABLED {
- let mut planets = entities.write().await;
+ let planets = entities.write().await;
// update earth (nothing changes, yet)
- let new_earth_position;
let earth = planets.get_planet(PlanetType::Earth).unwrap();
- new_earth_position = vector![earth.position.0, earth.position.1];
+ let new_earth_position = vector![earth.position.0, earth.position.1];
// update moon
let moon: &mut Planet = &mut planets.get_planet(PlanetType::Moon).unwrap();
M spacetime => spacetime +4 -4
@@ 28,10 28,10 @@ sub_help() {
echo " build_server - Compile the game server" # done
echo " run_server_prod - Compile and run the game server with optimizations enabled" # done
echo " build_server_prod - Compile the game server with optimizations enabled" # done
- echo " run_api - Compile and run the API server"
- echo " build_api - Compile the API server"
- echo " run_api_prod - Compile and run the API server with optimizations enabled"
- echo " build_api_prod - Compile the API server with optimizations enabled"
+ echo " run_api - Compile and run the API server" # done
+ echo " build_api - Compile the API server" # done
+ echo " run_api_prod - Compile and run the API server with optimizations enabled" # done
+ echo " build_api_prod - Compile the API server with optimizations enabled" # done
echo " install_tooling - Install the compilation utilities required for compiling StarKingdoms" # done
echo " build_assets - Compile spritesheets in all three texture sizes for textures-fast" # done
echo " build_assets_full - Compile spritesheets in full size for textures-fast" # done