cargo fmt

This commit is contained in:
traffic95 2025-03-18 23:17:22 +01:00
parent 911149856e
commit 219b92f004
47 changed files with 15054 additions and 10593 deletions
crates
battle-server/src
dispatch-server/src
game-server/src
gate-server/src
hall-server/src
muip-server/src
trigger-codegen/src
trigger-cryptography/src
trigger-database/src
trigger-encoding/src
trigger-fileconfig/gen_flatbuffers
trigger-logic/src
trigger-protobuf
trigger-protocol/src
trigger-sv/src

View file

@ -10,7 +10,7 @@ use trigger_sv::{
net::ServerType,
};
use crate::{logic::GameState, session::BattleSession, AppState};
use crate::{AppState, logic::GameState, session::BattleSession};
pub async fn handle_message(state: &'static AppState, packet: trigger_sv::message::NetworkPacket) {
match packet.opcode {

View file

@ -1,5 +1,5 @@
use trigger_encoding::Decodeable;
use trigger_protocol::{util::ProtocolUnit, ClientCmdID, EndBattleCsReq};
use trigger_protocol::{ClientCmdID, EndBattleCsReq, util::ProtocolUnit};
use trigger_sv::message::GameStateCallback;
use super::BattleSession;

View file

@ -3,7 +3,7 @@ use std::{
sync::{LazyLock, OnceLock},
};
use axum::{routing::get, Router};
use axum::{Router, routing::get};
use config::DispatchConfig;
use tokio::net::TcpListener;
use tracing::error;

View file

@ -1,8 +1,8 @@
use axum::{extract::State, Json};
use axum::{Json, extract::State};
use crate::{
data::{QueryDispatchRsp, ServerListInfo},
AppState,
data::{QueryDispatchRsp, ServerListInfo},
};
pub const ROUTE_ENDPOINT: &str = "/query_dispatch";

View file

@ -1,20 +1,20 @@
use axum::{
Json,
extract::{Query, State},
response::IntoResponse,
Json,
};
use base64::{display::Base64Display, engine::general_purpose::STANDARD, Engine};
use base64::{Engine, display::Base64Display, engine::general_purpose::STANDARD};
use serde::{Deserialize, Serialize, Serializer};
use tracing::debug;
use trigger_cryptography::rsa;
use trigger_sv::config::RsaSetting;
use crate::{
AppState,
data::{
CdnConfExt, CdnDesignData, CdnGameRes, CdnSilenceData, RegionExtension, RegionSwitchFunc,
ServerDispatchData, ServerGateway,
},
AppState,
};
pub const ROUTE_ENDPOINT: &str = "/query_gateway";
@ -127,7 +127,10 @@ fn internal_process(
msg: String::with_capacity(0),
region_name: Borrowed(&server.name),
title: Borrowed(&server.title),
client_secret_key: Owned(base64::engine::general_purpose::STANDARD.encode(&state.environment.security.static_key.seed_buf)),
client_secret_key: Owned(
base64::engine::general_purpose::STANDARD
.encode(&state.environment.security.static_key.seed_buf),
),
cdn_check_url: String::with_capacity(0),
gateway: Some(ServerGateway {
ip: Borrowed(&server.addr),
@ -139,20 +142,32 @@ fn internal_process(
cdn_conf_ext: Some(CdnConfExt {
// TODO: unhardcode this
design_data: CdnDesignData {
base_url: Borrowed("https://autopatchcn.juequling.com/design_data/beta_live/output_7054632_323d17319c/client/"),
base_url: Borrowed(
"https://autopatchcn.juequling.com/design_data/beta_live/output_7054632_323d17319c/client/",
),
data_revision: Borrowed("7054632"),
md5_files: Borrowed(r#"[{"fileName": "data_version", "fileSize": 4503, "fileMD5": "419987357302147246"}]"#),
md5_files: Borrowed(
r#"[{"fileName": "data_version", "fileSize": 4503, "fileMD5": "419987357302147246"}]"#,
),
},
game_res: CdnGameRes {
audio_revision: Borrowed("7025371"),
base_url: Borrowed("https://autopatchcn.juequling.com/game_res/beta_live/output_7054632_323d17319c/client/"),
base_url: Borrowed(
"https://autopatchcn.juequling.com/game_res/beta_live/output_7054632_323d17319c/client/",
),
branch: Borrowed("beta_live"),
md5_files: Borrowed(r#"[{"fileName": "res_version", "fileSize": 2379030, "fileMD5": "15840336186912297231"}, {"fileName": "audio_version", "fileSize": 30435, "fileMD5": "15675397132378459243"}, {"fileName": "base_revision", "fileSize": 18, "fileMD5": "18079377284431001248"}]"#),
md5_files: Borrowed(
r#"[{"fileName": "res_version", "fileSize": 2379030, "fileMD5": "15840336186912297231"}, {"fileName": "audio_version", "fileSize": 30435, "fileMD5": "15675397132378459243"}, {"fileName": "base_revision", "fileSize": 18, "fileMD5": "18079377284431001248"}]"#,
),
res_revision: Borrowed("7054632"),
},
silence_data: CdnSilenceData {
base_url: Borrowed("https://autopatchcn.juequling.com/design_data/beta_live/output_7054632_323d17319c/client_silence/"),
md5_files: Borrowed(r#"[{"fileName": "silence_version", "fileSize": 647, "fileMD5": "15019531890587528788"}]"#),
base_url: Borrowed(
"https://autopatchcn.juequling.com/design_data/beta_live/output_7054632_323d17319c/client_silence/",
),
md5_files: Borrowed(
r#"[{"fileName": "silence_version", "fileSize": 647, "fileMD5": "15019531890587528788"}]"#,
),
silence_revision: Borrowed("7042559"),
},
pre_download: None,
@ -174,7 +189,7 @@ fn internal_process(
url_check_nap: String::new(),
url_check_sdk: String::new(),
}),
}
},
})
}

View file

@ -1,11 +1,11 @@
use tracing::{debug, warn};
use trigger_logic::quest::EQuestType;
use trigger_protocol::{util::ProtocolUnit, AvatarSync, CafeSync, ItemSync, PlayerSyncScNotify};
use trigger_protocol::{AvatarSync, CafeSync, ItemSync, PlayerSyncScNotify, util::ProtocolUnit};
use trigger_sv::gm_command::GMCommand;
use crate::AppState;
use super::{player::AvatarPropertyChanges, NapPlayer};
use super::{NapPlayer, player::AvatarPropertyChanges};
pub struct CommandContext<'player> {
pub player: &'player mut NapPlayer,

View file

@ -6,7 +6,7 @@ use quest::QuestModel;
use ramen::RamenModel;
use role::RoleModel;
use scene::SceneModel;
use trigger_database::{entity::*, prelude::*, DatabaseConnection};
use trigger_database::{DatabaseConnection, entity::*, prelude::*};
use trigger_fileconfig::NapFileCfg;
use trigger_logic::scene::ESceneType;
use trigger_protocol::PlayerBasicInfo;

View file

@ -1,6 +1,6 @@
use trigger_database::DatabaseConnection;
use trigger_database::entity::*;
use trigger_database::prelude::*;
use trigger_database::DatabaseConnection;
pub async fn load_player_basic_info(
db: &DatabaseConnection,

View file

@ -12,7 +12,7 @@ use tracing::{error, info};
use trigger_database::DatabaseConnection;
use trigger_fileconfig::NapFileCfg;
use trigger_sv::{
config::{load_json_config, ServerEnvironmentConfiguration, TomlConfig},
config::{ServerEnvironmentConfiguration, TomlConfig, load_json_config},
die, logging,
net::{ServerNetworkManager, ServerType},
print_banner,

View file

@ -1,9 +1,9 @@
use std::sync::Arc;
use crate::{
logic::{gm_util, NapPlayer},
session::GameSession,
AppState,
logic::{NapPlayer, gm_util},
session::GameSession,
};
use tokio::sync::Mutex;
use tracing::{debug, info, warn};

View file

@ -1,5 +1,5 @@
use trigger_encoding::Encodeable;
use trigger_protocol::{util::ProtocolUnit, ClientCmdID};
use trigger_protocol::{ClientCmdID, util::ProtocolUnit};
use super::GameSession;
use crate::AppState;

View file

@ -15,7 +15,7 @@ use trigger_sv::{
net::{ServerNetworkManager, ServerType},
};
use crate::logic::{scene_util, NapPlayer};
use crate::logic::{NapPlayer, scene_util};
pub mod message;

View file

@ -12,10 +12,10 @@ use trigger_sv::{
};
use crate::{
AppState,
net::{Connection, NetPacket},
session::SessionState,
util::BinExt,
AppState,
};
pub async fn handle_message(connection: &Connection, state: &'static AppState, packet: NetPacket) {
@ -41,20 +41,33 @@ pub async fn handle_message(connection: &Connection, state: &'static AppState, p
on_keep_alive(
connection,
state,
KeepAliveNotify::decode(&*packet.body).unwrap_or_default()
).await
KeepAliveNotify::decode(&*packet.body).unwrap_or_default(),
)
.await
}
cmd_id if connection.session.is_logged_in() => {
match trigger_protobuf::pb_to_common_protocol_unit(cmd_id, &packet.body) {
Ok(Some(unit)) => state.network_mgr.send_to(ServerType::GameServer, 0, ForwardClientProtocolMessage {
session_id: connection.session.id,
request_id: head.packet_id,
message: unit,
}).await,
Ok(Some(unit)) => {
state
.network_mgr
.send_to(
ServerType::GameServer,
0,
ForwardClientProtocolMessage {
session_id: connection.session.id,
request_id: head.packet_id,
message: unit,
},
)
.await
}
Ok(None) => warn!("ignoring message with unknown cmd_id: {cmd_id}"),
Err(err) => error!(
"failed to decode a message with cmd_id: {} from {} (player_uid: {}), error: {}",
cmd_id, connection.addr(), connection.session.player_uid(), err
cmd_id,
connection.addr(),
connection.session.player_uid(),
err
),
}
}

View file

@ -1,7 +1,7 @@
use tokio::sync::mpsc;
use tracing::warn;
use crate::{net::NetPacket, AppState};
use crate::{AppState, net::NetPacket};
#[derive(Clone)]
pub struct MessageHandler(mpsc::UnboundedSender<(u64, NetPacket)>);

View file

@ -2,8 +2,8 @@ use std::{
io,
net::SocketAddr,
sync::{
atomic::{AtomicU32, Ordering::SeqCst},
Arc, OnceLock,
atomic::{AtomicU32, Ordering::SeqCst},
},
time::Duration,
};

View file

@ -1,6 +1,6 @@
use std::io::{Cursor, Write};
use byteorder::{WriteBytesExt, BE};
use byteorder::{BE, WriteBytesExt};
use trigger_protobuf::PacketHead;
pub struct NetPacket {

View file

@ -3,7 +3,7 @@ use std::{io, net::SocketAddr};
use tokio::net::TcpListener;
use tracing::info;
use crate::{message_handler::MessageHandler, AppState};
use crate::{AppState, message_handler::MessageHandler};
pub async fn serve(
addr: SocketAddr,

View file

@ -1,6 +1,6 @@
use std::sync::{
atomic::{AtomicI64, Ordering::SeqCst},
OnceLock,
atomic::{AtomicI64, Ordering::SeqCst},
};
use atomic_enum::atomic_enum;

View file

@ -107,6 +107,6 @@ use trigger_protocol::{
};
use trigger_sv::message::GameStateCallback;
use crate::logic::{message::RunEventGraphEvent, GameStateListener};
use crate::logic::{GameStateListener, message::RunEventGraphEvent};
use super::scene_unit::{InteractContainer, SceneUnitTag};

View file

@ -1,6 +1,6 @@
use bevy_ecs::{prelude::*, query::QueryData};
use tracing::warn;
use trigger_fileconfig::{main_city_script::MainCityConfig, NapFileCfg};
use trigger_fileconfig::{NapFileCfg, main_city_script::MainCityConfig};
use crate::logic::save::HallSceneSaveData;

View file

@ -3,13 +3,13 @@ use tracing::{debug, warn};
use trigger_protocol::InteractWithUnitScRsp;
use trigger_sv::message::GameStateCallback;
use crate::logic::{message::InteractWithUnitEvent, GameStateListener};
use crate::logic::{GameStateListener, message::InteractWithUnitEvent};
use super::{
NapResources,
event_graph::{ActionChangeInteractCfgEvent, EventGraph, GraphEvent},
hall::MainCitySection,
scene_unit::{InteractContainer, SceneUnitTag},
NapResources,
};
pub fn tick_change_interact(

View file

@ -8,11 +8,11 @@ use scene::PlayerEnterScene;
use trigger_fileconfig::main_city_script::MainCityConfig;
use super::{
GameStateListener,
message::{
EnterSectionEvent, InteractWithUnitEvent, PlayerMoveEvent, RunEventGraphEvent,
SwitchRoleEvent,
},
GameStateListener,
};
pub mod event_graph;

View file

@ -1,8 +1,8 @@
use bevy_ecs::prelude::*;
use crate::logic::{
save::{HallSceneSaveData, MainCityPositionSave},
GameStateListener,
save::{HallSceneSaveData, MainCityPositionSave},
};
use super::{

View file

@ -1,6 +1,6 @@
use bevy_ecs::system::Resource;
use trigger_encoding::Encodeable;
use trigger_protocol::{util::ProtocolUnit, ClientCmdID};
use trigger_protocol::{ClientCmdID, util::ProtocolUnit};
use trigger_sv::{
message::{GameStateCallback, GameStateCallbackMessage},
net::{ServerNetworkManager, ServerType},

View file

@ -2,8 +2,8 @@ use bevy_ecs::event::Event;
use trigger_encoding::Decodeable;
use trigger_logic::scene::Transform;
use trigger_protocol::{
util::ProtocolUnit, ClientCmdID, EnterSectionCsReq, InteractWithUnitCsReq, RunEventGraphCsReq,
SavePosInMainCityCsReq, SwitchRoleCsReq,
ClientCmdID, EnterSectionCsReq, InteractWithUnitCsReq, RunEventGraphCsReq,
SavePosInMainCityCsReq, SwitchRoleCsReq, util::ProtocolUnit,
};
use super::ecs::NapEcs;

View file

@ -1,6 +1,6 @@
use std::{collections::HashMap, sync::mpsc, thread};
use ecs::{scene::PlayerEnterScene, NapEcs};
use ecs::{NapEcs, scene::PlayerEnterScene};
use message::ProtocolEventHandler;
use tracing::debug;
use trigger_protocol::util::ProtocolUnit;
@ -11,8 +11,8 @@ mod listener;
mod message;
pub mod save;
pub use ecs::hall::HallInitData;
pub use ecs::NapResources;
pub use ecs::hall::HallInitData;
pub use listener::GameStateListener;
#[derive(Clone)]

View file

@ -8,9 +8,9 @@ use dashmap::DashMap;
use logic::{GameRunner, NapResources};
use session::HallSession;
use tracing::{error, info};
use trigger_fileconfig::{main_city_script::MainCityConfig, NapFileCfg};
use trigger_fileconfig::{NapFileCfg, main_city_script::MainCityConfig};
use trigger_sv::{
config::{load_json_config, ServerEnvironmentConfiguration, TomlConfig},
config::{ServerEnvironmentConfiguration, TomlConfig, load_json_config},
die, logging,
net::{ServerNetworkManager, ServerType},
print_banner,

View file

@ -5,9 +5,9 @@ use trigger_sv::message::{
};
use crate::{
AppState,
logic::{GameStateListener, HallInitData},
session::HallSession,
AppState,
};
pub async fn handle_message(state: &'static AppState, packet: trigger_sv::message::NetworkPacket) {

View file

@ -1,9 +1,9 @@
use std::borrow::Cow;
use axum::{
Json, Router,
extract::{Query, State},
routing::get,
Json, Router,
};
use serde::{Deserialize, Serialize};
use tokio::net::TcpListener;
@ -64,7 +64,7 @@ async fn gm_api(
return Json(Response {
retcode: 2,
message: Some(Cow::Owned(format!("invalid command format: {err}"))),
})
});
}
};

View file

@ -1,8 +1,8 @@
use proc_macro2::TokenStream;
use quote::quote;
use syn::{
parse_macro_input, Data, DeriveInput, Field, Fields, GenericArgument, PathArguments, Type,
TypePath,
Data, DeriveInput, Field, Fields, GenericArgument, PathArguments, Type, TypePath,
parse_macro_input,
};
pub fn impl_gm_input(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
@ -114,7 +114,7 @@ pub fn impl_gm_input(input: proc_macro::TokenStream) -> proc_macro::TokenStream
fn from_str(input: &str) -> Result<Self, GMInputParseError> {
use GMInputParseError::*;
static CMD_TYPE_MAP: ::std::sync::LazyLock<::std::collections::HashMap<&'static str, #internal_enum_name>> =
static CMD_TYPE_MAP: ::std::sync::LazyLock<::std::collections::HashMap<&'static str, #internal_enum_name>> =
::std::sync::LazyLock::new(|| ::std::collections::HashMap::from([#internal_enum_mapping]));
let mut data = input.split(' ');
@ -165,4 +165,3 @@ fn get_field_sub_type(field: &Field) -> String {
_ => panic!("Unsupported field type"),
}
}

View file

@ -1,6 +1,6 @@
use proc_macro2::TokenStream;
use quote::quote;
use syn::{parse_macro_input, Data, DeriveInput, Fields, Ident};
use syn::{Data, DeriveInput, Fields, Ident, parse_macro_input};
pub fn impl_decodeable(item: proc_macro::TokenStream) -> proc_macro::TokenStream {
let input = parse_macro_input!(item as DeriveInput);

View file

@ -1,6 +1,6 @@
use proc_macro2::TokenStream;
use quote::quote;
use syn::{parse_macro_input, Data, DeriveInput, Fields, Ident};
use syn::{Data, DeriveInput, Fields, Ident, parse_macro_input};
pub fn impl_encodeable(item: proc_macro::TokenStream) -> proc_macro::TokenStream {
let input = parse_macro_input!(item as DeriveInput);

View file

@ -1,6 +1,6 @@
use proc_macro2::TokenStream;
use quote::{quote, ToTokens};
use syn::{parse_macro_input, FnArg, Item, ItemMod, ReturnType};
use quote::{ToTokens, quote};
use syn::{FnArg, Item, ItemMod, ReturnType, parse_macro_input};
pub fn imp(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
const INVALID_FUNCTION_SIGNATURE_MSG: &str = "functions in message handler module should have following signature: fn(&mut MessageContext<'_>, CsReq) -> ScRsp";

View file

@ -1,6 +1,6 @@
use proc_macro::TokenStream;
use quote::{quote, ToTokens};
use syn::{parse_macro_input, DeriveInput, Meta, MetaList};
use quote::{ToTokens, quote};
use syn::{DeriveInput, Meta, MetaList, parse_macro_input};
mod commands;
mod decodeable;

View file

@ -1,7 +1,7 @@
#![allow(unused)]
use super::tables::{
LOOKUP_G11, LOOKUP_G13, LOOKUP_G14, LOOKUP_G2, LOOKUP_G3, LOOKUP_G9, LOOKUP_RCON, LOOKUP_SBOX,
LOOKUP_G2, LOOKUP_G3, LOOKUP_G9, LOOKUP_G11, LOOKUP_G13, LOOKUP_G14, LOOKUP_RCON, LOOKUP_SBOX,
LOOKUP_SBOX_INV, SHIFT_ROWS_TABLE, SHIFT_ROWS_TABLE_INV,
};

View file

@ -1,6 +1,6 @@
use rsa::{
pkcs1v15::SigningKey, sha2::Sha256, signature::RandomizedSigner, Pkcs1v15Encrypt,
RsaPrivateKey, RsaPublicKey,
Pkcs1v15Encrypt, RsaPrivateKey, RsaPublicKey, pkcs1v15::SigningKey, sha2::Sha256,
signature::RandomizedSigner,
};
const RSA_CHUNK_SIZE: usize = 117;

View file

@ -10,10 +10,10 @@ pub use sea_orm::DbErr;
use tracing::error;
pub mod prelude {
pub use sea_orm::entity::prelude::*;
pub use sea_orm::entity::ActiveValue::*;
pub use sea_orm::query::Condition;
pub use sea_orm::TransactionTrait;
pub use sea_orm::entity::ActiveValue::*;
pub use sea_orm::entity::prelude::*;
pub use sea_orm::query::Condition;
}
#[derive(Debug, Deserialize)]

View file

@ -1,4 +1,4 @@
use byteorder::{ReadBytesExt, WriteBytesExt, BE};
use byteorder::{BE, ReadBytesExt, WriteBytesExt};
use std::collections::HashMap;
use std::io::{self, Read, Write};

File diff suppressed because it is too large Load diff

View file

@ -88,4 +88,4 @@ pub enum EPropertyType {
HpMaxAdvance = 9999_111_1,
AtkAdvance = 9999_121_1,
DefAdvance = 9999_131_1,
}
}

View file

@ -5,7 +5,7 @@ use std::{
path::Path,
};
use quote::{quote, ToTokens};
use quote::{ToTokens, quote};
use syn::{Field, GenericArgument, Item, PathArguments, Type, TypePath};
fn main() {

View file

@ -1793,4 +1793,4 @@ pub struct GetFlowerShopDataCsReq {}
#[id(7151)]
pub struct GetFlowerShopDataScRsp {
pub retcode: i32,
}
}

View file

@ -1,4 +1,4 @@
use serde::{de::DeserializeOwned, Deserialize, Deserializer};
use serde::{Deserialize, Deserializer, de::DeserializeOwned};
use std::net::SocketAddr;
use tracing::error;
use trigger_database::DatabaseSetting;

View file

@ -1,6 +1,6 @@
use crate::message::opcode;
use trigger_codegen::{Decodeable, Encodeable};
use trigger_protocol::{util::ProtocolUnit, DungeonEquipInfo};
use trigger_protocol::{DungeonEquipInfo, util::ProtocolUnit};
#[derive(Debug, Encodeable, Decodeable)]
pub struct BindClientSessionMessage {

View file

@ -4,7 +4,7 @@ use futures::future::BoxFuture;
use tokio::task::JoinHandle;
use tracing::warn;
use trigger_encoding::Decodeable;
use zeromq::{prelude::*, PullSocket, ZmqError};
use zeromq::{PullSocket, ZmqError, prelude::*};
use crate::message::NetworkPacket;

View file

@ -3,7 +3,7 @@ mod socket;
use std::{collections::HashMap, io::Cursor, net::SocketAddr};
pub use listener::{listen, RecvCallback};
pub use listener::{RecvCallback, listen};
use num_enum::{IntoPrimitive, TryFromPrimitive};
pub use socket::ServerSocket;

View file

@ -5,8 +5,8 @@ use std::time::Duration;
use tokio::sync::mpsc;
use tracing::warn;
use trigger_encoding::Encodeable;
use zeromq::prelude::*;
use zeromq::PushSocket;
use zeromq::prelude::*;
use crate::message::NetworkPacket;