Skip to content
This repository has been archived by the owner on Feb 25, 2025. It is now read-only.

Commit

Permalink
group cfgs, add scene cfg, edit readme
Browse files Browse the repository at this point in the history
  • Loading branch information
yuvlian committed Dec 23, 2024
1 parent 7bf3c17 commit 3cb0f93
Show file tree
Hide file tree
Showing 26 changed files with 232 additions and 92 deletions.
37 changes: 35 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
# sr
# QingqueSR

epic gamer code
Ever wanted a private server that is quick to update when the game updates, but doesn't sacrifice too much features?

A server that's modular enough and feature complete-ish for battle simulation?

You're in the right place!

## Tutorial

This tutorial assumes you have basic knowledge of a terminal and traffic redirection with a proxy.

Also, if config files are missing, the server will fallback to default config. This means you can delete all files in `_config` folder.

You only have to worry about `config.json` because that's the config file for battle. It's obtainable from https://srtools.pages.dev/

### From Prebuilt (Windows only)

1. Download the prebuilt that matches your SR version in https://github.com/f2pqingque/sr/releases
2. Extract the zip
5. Edit config files in `_config` if necessary (check the README in that folder)
4. Run `net-game.exe` and `net-sdk.exe`

### From Source

1. Install Rust
2. Clone this repository
3. `cd` into `main`
4. Put your proto & cmdid file in `net-msg`
5. Edit config files in `_config` if necessary (check the README in that folder)
6. `cargo run --release --bin net-game`
7. `cargo run --release --bin net-sdk`

## Credits
- Yulian: QingqueSR Developer
- amizing25: SrTools Author
8 changes: 4 additions & 4 deletions main/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ strip = true
lto = true
opt-level = 3
codegen-units = 1
# set this shit to "abort"
# if you want it to always crash
# when theres a panic
panic = "unwind"
# set this shit to "unwind"
# if you dont want it to always crash
# when it panics
panic = "abort"

[profile.release.build-override]
strip = true
Expand Down
11 changes: 11 additions & 0 deletions main/_config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
`avatar.toml` -> configuration for lineup, march/trailblazer path, and owned avatar

`config.json` -> configuration for battle, obtainable from https://srtools.pages.dev/

`hotfix.json` -> configuration for hotfix links.

hotfix is not needed if you play on production client, as you can obtain the update by logging into the official server.

`scene.toml` -> configuration for player position, calyx position, and map.

`server.toml` -> configuration for where the servers should bind to.
5 changes: 5 additions & 0 deletions main/avatar.toml → main/_config/avatar.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ trailblazer_gender = "Woman"
trailblazer_element = "Imaginary"
march_element = "Imaginary"

# You don't need to update owned_avatars for battle to work.
# Only need to update for lineup.
# If you don't change the lineup, no need to update.

# Last updated: Fugue
owned_avatars = [
1001,
1002,
Expand Down
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions main/_config/scene.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[scene_config]
plane_id = 20101

[scene_config.player]
x = 4480
y = 19364
z = -550
# i'm not sure if base_avatar_id actually does anything
base_avatar_id = 1201
map_layer = 2

[scene_config.calyx]
x = 4480
y = 18354
z = -570
group_id = 19
inst_id = 300001
entity_id = 228
prop_id = 808
File renamed without changes.
8 changes: 4 additions & 4 deletions main/cfg-server/src/hotfix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::collections::HashMap;
use std::fs;

#[derive(Deserialize, Clone, Default)]
pub struct Hotfix {
pub struct HotfixConfig {
pub asset_bundle_url: String,
pub ex_resource_url: String,
pub lua_url: String,
Expand All @@ -13,7 +13,7 @@ pub struct Hotfix {
#[derive(Deserialize, Default)]
pub struct GameVersion {
#[serde(flatten)]
pub versions: HashMap<String, Hotfix>,
pub versions: HashMap<String, HotfixConfig>,
}

impl GameVersion {
Expand All @@ -25,10 +25,10 @@ impl GameVersion {
}
}

pub fn get_hotfix_for_version(&self, version: &Option<String>) -> Hotfix {
pub fn get_hotfix_for_version(&self, version: &Option<String>) -> HotfixConfig {
match version {
Some(v) => self.versions.get(v).cloned().unwrap_or_default(),
None => Hotfix::default(),
None => HotfixConfig::default(),
}
}
}
1 change: 1 addition & 0 deletions main/cfg-server/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod address;
pub mod avatar;
pub mod hotfix;
pub mod scene;
pub mod srtools;
127 changes: 127 additions & 0 deletions main/cfg-server/src/scene/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
use net_msg::pb::scene_entity_info::EntityCase::{Actor, Prop};
use net_msg::pb::{
AvatarType, MotionInfo, SceneActorInfo, SceneEntityGroupInfo, SceneEntityInfo, SceneInfo,
ScenePropInfo, Vector,
};
use serde::Deserialize;
use std::fs;

#[derive(Deserialize)]
pub struct SceneConfig {
pub plane_id: u32,
pub player: PlayerScene,
pub calyx: CalyxScene,
}

impl Default for SceneConfig {
fn default() -> Self {
Self {
plane_id: 20101,
player: PlayerScene {
x: 4480,
y: 19364,
z: -550,
base_avatar_id: 1201,
map_layer: 2,
},
calyx: CalyxScene {
x: 4480,
y: 18354,
z: -570,
group_id: 19,
inst_id: 300001,
entity_id: 228,
prop_id: 808,
},
}
}
}

impl SceneConfig {
pub fn from_file(file_path: &str) -> Self {
let scene_toml_data = fs::read_to_string(file_path);
match scene_toml_data {
Ok(data) => toml::from_str(&data).unwrap_or_default(),
Err(_) => Self::default(),
}
}

pub fn get_scene_info(&self) -> SceneInfo {
SceneInfo {
plane_id: self.plane_id,
floor_id: (self.plane_id * 1000) + 1,
entry_id: (self.plane_id * 100) + 1,
game_mode_type: 2,
entity_group_list: vec![
SceneEntityGroupInfo {
state: 1,
group_id: 0,
entity_list: vec![SceneEntityInfo {
group_id: 0,
inst_id: 0,
entity_id: 0,
entity_case: Some(Actor(SceneActorInfo {
avatar_type: AvatarType::AvatarFormalType.into(),
base_avatar_id: self.player.base_avatar_id,
map_layer: self.player.map_layer,
uid: 1,
})),
motion: Some(MotionInfo {
pos: Some(Vector {
x: self.player.x,
y: self.player.y,
z: self.player.z,
}),
rot: Some(Vector { x: 0, y: 0, z: 0 }),
}),
}],
..Default::default()
},
SceneEntityGroupInfo {
state: 1,
group_id: self.calyx.group_id,
entity_list: vec![SceneEntityInfo {
group_id: self.calyx.group_id,
inst_id: self.calyx.inst_id,
entity_id: self.calyx.entity_id,
entity_case: Some(Prop(ScenePropInfo {
prop_id: self.calyx.prop_id,
prop_state: 1,
..Default::default()
})),
motion: Some(MotionInfo {
pos: Some(Vector {
x: self.calyx.x,
y: self.calyx.y,
z: self.calyx.z,
}),
rot: Some(Vector { x: 0, y: 0, z: 0 }),
}),
}],
..Default::default()
},
],
..Default::default()
}
}
}

#[derive(Deserialize)]
pub struct PlayerScene {
pub x: i32,
pub y: i32,
pub z: i32,
pub base_avatar_id: u32,
pub map_layer: u32,
}

#[derive(Deserialize)]
pub struct CalyxScene {
pub x: i32,
pub y: i32,
pub z: i32,
pub group_id: u32,
pub inst_id: u32,
pub entity_id: u32,
pub prop_id: u32,
}
4 changes: 2 additions & 2 deletions main/net-game/src/handlers/avatar/get_avatar_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use cfg_server::avatar::AvatarConfig;
use net_msg::pb::GetAvatarDataScRsp;
use net_msg::Trait;

pub async fn handle(_req: &[u8]) -> Vec<u8> {
let cfg = AvatarConfig::from_file("avatar.toml");
pub async fn handle(_: &[u8]) -> Vec<u8> {
let cfg = AvatarConfig::from_file("_config/avatar.toml");

GetAvatarDataScRsp {
is_get_all: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use net_msg::pb::GetMultiPathAvatarInfoScRsp;
use net_msg::Trait;
use std::collections::HashMap;

pub async fn handle(_req: &[u8]) -> Vec<u8> {
let cfg = AvatarConfig::from_file("avatar.toml");
pub async fn handle(_: &[u8]) -> Vec<u8> {
let cfg = AvatarConfig::from_file("_config/avatar.toml");

let gender = cfg.get_trailblazer_gender();
let (march, trailblazer) = cfg.get_multipath_data(gender);
Expand Down
2 changes: 1 addition & 1 deletion main/net-game/src/handlers/battle/start_cocoon_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use net_msg::pb::{SceneBattleInfo, StartCocoonStageCsReq, StartCocoonStageScRsp}
use net_msg::{dec, Trait};

pub async fn handle(req: &[u8]) -> Vec<u8> {
let cfg = SrToolsConfig::from_file("config.json");
let cfg = SrToolsConfig::from_file("_config/config.json");
let req = dec!(StartCocoonStageCsReq, req);

let battle_info = SceneBattleInfo {
Expand Down
2 changes: 1 addition & 1 deletion main/net-game/src/handlers/item/get_bag.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pub async fn handle(_req: &[u8]) -> Vec<u8> {
pub async fn handle(_: &[u8]) -> Vec<u8> {
Vec::with_capacity(0)
}
4 changes: 2 additions & 2 deletions main/net-game/src/handlers/lineup/get_all_lineup_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use cfg_server::avatar::AvatarConfig;
use net_msg::pb::GetAllLineupDataScRsp;
use net_msg::Trait;

pub async fn handle(_req: &[u8]) -> Vec<u8> {
let cfg = AvatarConfig::from_file("avatar.toml");
pub async fn handle(_: &[u8]) -> Vec<u8> {
let cfg = AvatarConfig::from_file("_config/avatar.toml");

GetAllLineupDataScRsp {
lineup_list: vec![cfg.get_cur_lineup()],
Expand Down
4 changes: 2 additions & 2 deletions main/net-game/src/handlers/lineup/get_cur_lineup_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use cfg_server::avatar::AvatarConfig;
use net_msg::pb::GetCurLineupDataScRsp;
use net_msg::Trait;

pub async fn handle(_req: &[u8]) -> Vec<u8> {
let cfg = AvatarConfig::from_file("avatar.toml");
pub async fn handle(_: &[u8]) -> Vec<u8> {
let cfg = AvatarConfig::from_file("_config/avatar.toml");

GetCurLineupDataScRsp {
retcode: 0,
Expand Down
2 changes: 1 addition & 1 deletion main/net-game/src/handlers/login/player_get_token.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use net_msg::pb::PlayerGetTokenScRsp;
use net_msg::Trait;

pub async fn handle(_req: &[u8]) -> Vec<u8> {
pub async fn handle(_: &[u8]) -> Vec<u8> {
PlayerGetTokenScRsp {
msg: String::from("OK"),
retcode: 0,
Expand Down
2 changes: 1 addition & 1 deletion main/net-game/src/handlers/login/player_login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::utils::time;
use net_msg::pb::{PlayerBasicInfo, PlayerLoginScRsp};
use net_msg::Trait;

pub async fn handle(_req: &[u8]) -> Vec<u8> {
pub async fn handle(_: &[u8]) -> Vec<u8> {
PlayerLoginScRsp {
basic_info: Some(PlayerBasicInfo {
nickname: String::from("smol"),
Expand Down
2 changes: 1 addition & 1 deletion main/net-game/src/handlers/login/player_login_finish.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use net_msg::pb::PlayerLoginFinishScRsp;
use net_msg::Trait;

pub async fn handle(_req: &[u8]) -> Vec<u8> {
pub async fn handle(_: &[u8]) -> Vec<u8> {
PlayerLoginFinishScRsp { retcode: 0 }.encode_to_vec()
}
4 changes: 2 additions & 2 deletions main/net-game/src/handlers/player/get_basic_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use cfg_server::avatar::AvatarConfig;
use net_msg::pb::GetBasicInfoScRsp;
use net_msg::Trait;

pub async fn handle(_req: &[u8]) -> Vec<u8> {
let cfg = AvatarConfig::from_file("avatar.toml");
pub async fn handle(_: &[u8]) -> Vec<u8> {
let cfg = AvatarConfig::from_file("_config/avatar.toml");
let gender = cfg.get_trailblazer_gender() as u32;

GetBasicInfoScRsp {
Expand Down
Loading

0 comments on commit 3cb0f93

Please sign in to comment.