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

View file

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

View file

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

View file

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

View file

@ -9,7 +9,7 @@ pub async fn on_rpc_hollow_move_arg(
) -> Result<()> {
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 hollow_grid_manager = session.context.hollow_grid_manager.borrow();
@ -32,7 +32,7 @@ pub async fn on_rpc_hollow_move_arg(
session
.send_rpc_ret(RpcHollowMoveRet::new(
arg.hollow_level,
*arg.positions.iter().last().unwrap(),
*arg.positions.last().unwrap(),
))
.await
}
@ -224,7 +224,11 @@ pub async fn on_rpc_start_hollow_quest_arg(
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
.create_hollow(10001, 10010001, &avatars)
.send_changes(session)

View file

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

View file

@ -17,7 +17,6 @@ static UNLOCK_FEATURES: [i32; 35] = [
10014, 10015, 10017, 10018, 10019,
];
#[tracing::instrument(skip(session))]
pub async fn on_rpc_run_event_graph_arg(
session: &NetworkSession,
arg: &RpcRunEventGraphArg,
@ -37,7 +36,7 @@ pub async fn on_rpc_run_event_graph_arg(
};
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,
EventInfo {
id: 100,
@ -56,7 +55,6 @@ pub async fn on_rpc_run_event_graph_arg(
session.send_rpc_ret(RpcRunEventGraphRet::new()).await
}
#[tracing::instrument(skip(session))]
pub async fn on_rpc_finish_event_graph_perform_show_arg(
session: &NetworkSession,
arg: &RpcFinishEventGraphPerformShowArg,
@ -91,7 +89,6 @@ pub async fn on_rpc_finish_event_graph_perform_show_arg(
.await
}
#[tracing::instrument(skip(session))]
pub async fn on_rpc_interact_with_unit_arg(
session: &NetworkSession,
arg: &RpcInteractWithUnitArg,
@ -111,7 +108,7 @@ pub async fn on_rpc_interact_with_unit_arg(
};
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,
EventInfo {
id: 100,
@ -145,7 +142,6 @@ pub async fn on_ptc_player_operation_arg(
session.send_rpc_ret(PtcPlayerOperationRet::new()).await
}
#[tracing::instrument(skip(session))]
pub async fn on_rpc_save_pos_in_main_city_arg(
session: &NetworkSession,
arg: &RpcSavePosInMainCityArg,
@ -212,7 +208,7 @@ pub async fn on_rpc_enter_world_arg(
) -> Result<()> {
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);
let item_manager = session.context.item_manager.borrow();

View file

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

View file

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