Skip to content

Commit

Permalink
RPCN 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
RipleyTom committed Jan 14, 2024
1 parent ba02788 commit 27fc83d
Show file tree
Hide file tree
Showing 15 changed files with 644 additions and 130 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,27 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.0] - 2024-01-14

### Added

- Implemented SetUserInfo
- Implemented GetRoomMemberBinAttr
- Added proper public/private slot values
- Added a cleanup mechanism for accounts that have never been logged on and are older than a month

### Fixed

- Added FOREIGN_KEY constraints to TUS tables to ensure sanity
- Added a mechanism to ensure cleanup is done properly before letting the user back in the server

### Misc

- Updated dependencies
- Migrated all score tables into one unified table
- Added indexes for faster lookup to the SQL tables


## [0.9.2] - 2024-01-09

### Fixed
Expand Down
63 changes: 30 additions & 33 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rpcn"
version = "0.9.1"
version = "1.0.0"
authors = ["RipleyTom <[email protected]>"]
edition = "2021"

Expand Down
4 changes: 3 additions & 1 deletion servers.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,6 @@ NPWR00432|1|65542|
NPWR00432|1|65543|
NPWR00432|1|65544|
NPWR00432|1|65545|
NPWR00432|1|65546|
NPWR00432|1|65546|
#Metal Slug 3
NPWR08648|1|65537|
11 changes: 8 additions & 3 deletions src/server.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::collections::HashMap;
use std::collections::{HashMap, HashSet};
use std::fs::File;
use std::io::{self, BufReader};
use std::net::ToSocketAddrs;
Expand Down Expand Up @@ -34,7 +34,7 @@ use crate::Config;
#[allow(non_snake_case, dead_code)]
mod stream_extractor;

const PROTOCOL_VERSION: u32 = 21;
const PROTOCOL_VERSION: u32 = 22;

pub struct Server {
config: Arc<RwLock<Config>>,
Expand All @@ -43,6 +43,7 @@ pub struct Server {
client_infos: Arc<RwLock<HashMap<i64, ClientSharedInfo>>>,
score_cache: Arc<ScoresCache>,
game_tracker: Arc<GameTracker>,
cleanup_duty: Arc<RwLock<HashSet<i64>>>,
}

impl Server {
Expand All @@ -53,12 +54,15 @@ impl Server {
let score_cache = Server::initialize_score(db_pool.get().map_err(|e| format!("Failed to get a database connection: {}", e))?)?;
Server::initialize_tus_data_handler()?;

Server::cleanup_database(db_pool.get().map_err(|e| format!("Failed to get a database connection: {}", e))?)?;

Server::clean_score_data(db_pool.get().map_err(|e| format!("Failed to get a database connection: {}", e))?)?;
Server::clean_tus_data(db_pool.get().map_err(|e| format!("Failed to get a database connection: {}", e))?)?;

let room_manager = Arc::new(RwLock::new(RoomManager::new()));
let client_infos = Arc::new(RwLock::new(HashMap::new()));
let game_tracker = Arc::new(GameTracker::new());
let cleanup_duty = Arc::new(RwLock::new(HashSet::new()));

Ok(Server {
config,
Expand All @@ -67,6 +71,7 @@ impl Server {
client_infos,
score_cache,
game_tracker,
cleanup_duty,
})
}

Expand Down Expand Up @@ -163,7 +168,7 @@ impl Server {
let acceptor = acceptor.clone();
let config = self.config.clone();
let db_pool = self.db_pool.clone();
let shared = SharedData::new(self.room_manager.clone(), self.client_infos.clone(), self.score_cache.clone(), self.game_tracker.clone());
let shared = SharedData::new(self.room_manager.clone(), self.client_infos.clone(), self.score_cache.clone(), self.game_tracker.clone(), self.cleanup_duty.clone());
let servinfo_vec = servinfo_vec.clone();
let term_watch = term_watch.clone();
let fut_client = async move {
Expand Down
Loading

0 comments on commit 27fc83d

Please sign in to comment.