This commit is contained in:
gulag 2024-03-20 08:05:35 -04:00
parent 7bc1ad2240
commit d76277add3
No known key found for this signature in database
GPG key ID: E67890ADC4227273
9 changed files with 18 additions and 36 deletions

View file

@ -1,28 +1,21 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "PascalCase")]
pub struct MainCityObjectTemplate { pub struct MainCityObjectTemplate {
#[serde(rename = "TagID")] #[serde(rename = "TagID")]
pub tag_id: i32, pub tag_id: i32,
#[serde(rename = "NPCID")] #[serde(rename = "NPCID")]
pub npc_id: i32, pub npc_id: i32,
#[serde(rename = "CreatePosition")]
pub create_position: String, pub create_position: String,
#[serde(rename = "CreateType")]
pub create_type: i32, pub create_type: i32,
#[serde(rename = "DefaultInteractIDs")] #[serde(rename = "DefaultInteractIDs")]
pub default_interact_ids: Vec<i32>, pub default_interact_ids: Vec<i32>,
#[serde(rename = "InteractName")]
pub interact_name: Option<String>, pub interact_name: Option<String>,
#[serde(rename = "InteractShape")]
pub interact_shape: i32, pub interact_shape: i32,
#[serde(rename = "InteractScale")]
pub interact_scale: String, pub interact_scale: String,
#[serde(rename = "FanInteractParam")]
pub fan_interact_param: Option<String>, pub fan_interact_param: Option<String>,
#[serde(rename = "FocusInteractScale")]
pub focus_interact_scale: f64, pub focus_interact_scale: f64,
#[serde(rename = "IgnoreCollider")]
pub ignore_collider: bool, pub ignore_collider: bool,
#[serde(rename = "LookIK")] #[serde(rename = "LookIK")]
pub look_ik: bool, pub look_ik: bool,
@ -30,28 +23,19 @@ pub struct MainCityObjectTemplate {
pub npc_look_ik: bool, pub npc_look_ik: bool,
#[serde(rename = "SceneSoundID")] #[serde(rename = "SceneSoundID")]
pub scene_sound_id: i32, pub scene_sound_id: i32,
#[serde(rename = "PlayerRotate")]
pub player_rotate: bool, pub player_rotate: bool,
#[serde(rename = "NPCRotate")] #[serde(rename = "NPCRotate")]
pub npc_rotate: bool, pub npc_rotate: bool,
#[serde(rename = "SceneObjectName")]
pub scene_object_name: Option<String>, pub scene_object_name: Option<String>,
#[serde(rename = "CameraStoryKey")]
pub camera_story_key: Option<String>, pub camera_story_key: Option<String>,
#[serde(rename = "ActionState")]
pub action_state: i32, pub action_state: i32,
#[serde(rename = "ColliderState")]
pub collider_state: Option<String>, pub collider_state: Option<String>,
#[serde(rename = "ItemState")]
pub item_state: Option<String>, pub item_state: Option<String>,
#[serde(rename = "ObjectIDs")] #[serde(rename = "ObjectIDs")]
pub object_ids: Vec<i32>, pub object_ids: Vec<i32>,
#[serde(rename = "CreateInterval")]
pub create_interval: i32, pub create_interval: i32,
#[serde(rename = "CreateDelay")]
pub create_delay: i32, pub create_delay: i32,
#[serde(rename = "NPCIcon")] #[serde(rename = "NPCIcon")]
pub npc_icon: Option<String>, pub npc_icon: Option<String>,
#[serde(rename = "ActionSwitch")]
pub action_switch: Option<String>, pub action_switch: Option<String>,
} }

View file

@ -103,7 +103,7 @@ impl HollowGridManager {
let actions = event_config["Events"]["OnEnd"]["Actions"] let actions = event_config["Events"]["OnEnd"]["Actions"]
.as_array() .as_array()
.unwrap(); .unwrap();
if let Some(action) = actions.get(0) { if let Some(action) = actions.first() {
hollow_finished = action["$type"].as_str().unwrap() == "Share.CConfigFinishHollow"; hollow_finished = action["$type"].as_str().unwrap() == "Share.CConfigFinishHollow";
} }
@ -247,7 +247,7 @@ impl HollowGridManager {
let mut action_move_path = move_path; let mut action_move_path = move_path;
let last_client_action = *action_move_path.iter().last().unwrap(); let last_client_action = *action_move_path.last().unwrap();
let actions = if last_client_action / 1000 == 1 { let actions = if last_client_action / 1000 == 1 {
event_config["Events"]["OnStart"]["Actions"] event_config["Events"]["OnStart"]["Actions"]
.as_array() .as_array()
@ -277,7 +277,7 @@ impl HollowGridManager {
event_graph_id: info.grid.event_graph_info.hollow_event_template_id, event_graph_id: info.grid.event_graph_info.hollow_event_template_id,
updated_event: EventInfo { updated_event: EventInfo {
id: 1000, id: 1000,
cur_action_id: *action_move_path.iter().last().unwrap(), cur_action_id: *action_move_path.last().unwrap(),
action_move_path, action_move_path,
state, state,
prev_state: EventState::Running, prev_state: EventState::Running,

View file

@ -43,8 +43,7 @@ impl SceneUnitManager {
} }
pub fn get(&self, uid: u64) -> SceneUnitProtocolInfo { pub fn get(&self, uid: u64) -> SceneUnitProtocolInfo {
let units = self.units.borrow(); self.units.borrow().get(&uid).unwrap().clone()
units.get(&uid).unwrap().clone()
} }
pub fn sync(&self, scene_uid: u64, section_id: i32) -> PtcSyncSceneUnitArg { pub fn sync(&self, scene_uid: u64, section_id: i32) -> PtcSyncSceneUnitArg {
@ -57,7 +56,7 @@ impl SceneUnitManager {
.units .units
.borrow() .borrow()
.iter() .iter()
.map(|(_uid, unit)| unit.clone()) .map(|(_, unit)| unit.clone())
.collect(), .collect(),
} }
} }

View file

@ -6,7 +6,6 @@ pub async fn on_rpc_battle_report_arg(
) -> Result<()> { ) -> Result<()> {
let need_index = arg let need_index = arg
.battle_reports .battle_reports
.iter()
.last() .last()
.map_or(0, |report| report.index + 1); .map_or(0, |report| report.index + 1);

View file

@ -9,7 +9,7 @@ pub async fn on_rpc_hollow_move_arg(
) -> Result<()> { ) -> Result<()> {
tracing::info!("Hollow movement {:?}", &arg); tracing::info!("Hollow movement {:?}", &arg);
let destination_pos = *arg.positions.iter().last().unwrap(); let destination_pos = *arg.positions.last().unwrap();
let scene_uid = session.get_player().scene_uid.unwrap(); let scene_uid = session.get_player().scene_uid.unwrap();
let hollow_grid_manager = session.context.hollow_grid_manager.borrow(); let hollow_grid_manager = session.context.hollow_grid_manager.borrow();
@ -32,7 +32,7 @@ pub async fn on_rpc_hollow_move_arg(
session session
.send_rpc_ret(RpcHollowMoveRet::new( .send_rpc_ret(RpcHollowMoveRet::new(
arg.hollow_level, arg.hollow_level,
*arg.positions.iter().last().unwrap(), *arg.positions.last().unwrap(),
)) ))
.await .await
} }
@ -224,7 +224,11 @@ pub async fn on_rpc_start_hollow_quest_arg(
let dungeon_manager = session.context.dungeon_manager.borrow(); let dungeon_manager = session.context.dungeon_manager.borrow();
let avatars: Vec<u64> = arg.avatar_map.iter().map(|(_idx, uid)| *uid).collect(); let avatars = arg
.avatar_map
.iter()
.map(|(_idx, uid)| *uid)
.collect::<Vec<_>>();
let (dungeon_uid, scene_uid) = *dungeon_manager let (dungeon_uid, scene_uid) = *dungeon_manager
.create_hollow(10001, 10010001, &avatars) .create_hollow(10001, 10010001, &avatars)
.send_changes(session) .send_changes(session)

View file

@ -1,6 +1,5 @@
use super::*; use super::*;
#[tracing::instrument(skip(session))]
pub async fn on_rpc_mod_nick_name_arg( pub async fn on_rpc_mod_nick_name_arg(
session: &NetworkSession, session: &NetworkSession,
arg: &RpcModNickNameArg, arg: &RpcModNickNameArg,

View file

@ -17,7 +17,6 @@ static UNLOCK_FEATURES: [i32; 35] = [
10014, 10015, 10017, 10018, 10019, 10014, 10015, 10017, 10018, 10019,
]; ];
#[tracing::instrument(skip(session))]
pub async fn on_rpc_run_event_graph_arg( pub async fn on_rpc_run_event_graph_arg(
session: &NetworkSession, session: &NetworkSession,
arg: &RpcRunEventGraphArg, arg: &RpcRunEventGraphArg,
@ -37,7 +36,7 @@ pub async fn on_rpc_run_event_graph_arg(
}; };
ptc_sync_event_info.updated_events.insert( ptc_sync_event_info.updated_events.insert(
*main_city_object.default_interact_ids.iter().next().unwrap(), *main_city_object.default_interact_ids.first().unwrap(),
100, 100,
EventInfo { EventInfo {
id: 100, id: 100,
@ -56,7 +55,6 @@ pub async fn on_rpc_run_event_graph_arg(
session.send_rpc_ret(RpcRunEventGraphRet::new()).await session.send_rpc_ret(RpcRunEventGraphRet::new()).await
} }
#[tracing::instrument(skip(session))]
pub async fn on_rpc_finish_event_graph_perform_show_arg( pub async fn on_rpc_finish_event_graph_perform_show_arg(
session: &NetworkSession, session: &NetworkSession,
arg: &RpcFinishEventGraphPerformShowArg, arg: &RpcFinishEventGraphPerformShowArg,
@ -91,7 +89,6 @@ pub async fn on_rpc_finish_event_graph_perform_show_arg(
.await .await
} }
#[tracing::instrument(skip(session))]
pub async fn on_rpc_interact_with_unit_arg( pub async fn on_rpc_interact_with_unit_arg(
session: &NetworkSession, session: &NetworkSession,
arg: &RpcInteractWithUnitArg, arg: &RpcInteractWithUnitArg,
@ -111,7 +108,7 @@ pub async fn on_rpc_interact_with_unit_arg(
}; };
ptc_sync_event_info.updated_events.insert( ptc_sync_event_info.updated_events.insert(
*main_city_object.default_interact_ids.iter().next().unwrap(), *main_city_object.default_interact_ids.first().unwrap(),
100, 100,
EventInfo { EventInfo {
id: 100, id: 100,
@ -145,7 +142,6 @@ pub async fn on_ptc_player_operation_arg(
session.send_rpc_ret(PtcPlayerOperationRet::new()).await session.send_rpc_ret(PtcPlayerOperationRet::new()).await
} }
#[tracing::instrument(skip(session))]
pub async fn on_rpc_save_pos_in_main_city_arg( pub async fn on_rpc_save_pos_in_main_city_arg(
session: &NetworkSession, session: &NetworkSession,
arg: &RpcSavePosInMainCityArg, arg: &RpcSavePosInMainCityArg,
@ -212,7 +208,7 @@ pub async fn on_rpc_enter_world_arg(
) -> Result<()> { ) -> Result<()> {
let account = session.get_account(); let account = session.get_account();
let id = *account.players.as_ref().unwrap().iter().next().unwrap(); // get first id from list let id = *account.players.as_ref().unwrap().first().unwrap(); // get first id from list
*session.get_player_mut() = create_player(id); *session.get_player_mut() = create_player(id);
let item_manager = session.context.item_manager.borrow(); let item_manager = session.context.item_manager.borrow();

View file

@ -90,6 +90,7 @@ macro_rules! trait_handler {
pub trait PacketHandler { pub trait PacketHandler {
$( $(
paste! { paste! {
#[tracing::instrument(skip(session))]
async fn [<on_$name:snake>](session: &mut NetworkSession, arg: &$name) -> Result<()> { async fn [<on_$name:snake>](session: &mut NetworkSession, arg: &$name) -> Result<()> {
[<on_$name:snake>](session, arg).await [<on_$name:snake>](session, arg).await
} }

View file

@ -53,7 +53,7 @@ macro_rules! ret {
}; };
} }
#[derive(OctData)] #[derive(OctData, Debug)]
pub struct RpcLoginArg { pub struct RpcLoginArg {
pub account_name: String, pub account_name: String,
pub token: String, pub token: String,