diff --git a/packet-service/src/handlers/character.rs b/packet-service/src/handlers/character.rs index 14d9a6c..5c565ca 100644 --- a/packet-service/src/handlers/character.rs +++ b/packet-service/src/handlers/character.rs @@ -304,10 +304,10 @@ pub(crate) async fn handle_select_char_req( // Build the character inventory list for item in items { if item.slot < MAX_VISIBLE_ITEMS as i32 { - let slot = convert_type_to_body_part(item.item_type) as isize - 2; + let slot = convert_type_to_body_part(item.header.unwrap().r#type) as isize - 2; if slot >= 0 { equipped_item_list[slot as usize] = EquippedItem { - id: item.item_id as u16, + id: item.header.unwrap().id as u16, gem_opt: item.gem_option as u16, socket: item.socket as i8, grade: item.grade as u8, @@ -317,9 +317,9 @@ pub(crate) async fn handle_select_char_req( inventory[item.slot as usize] = srv_inventory_data::Item { header: srv_inventory_data::Header { - type_: item.item_type as u8, - id: item.item_id as u16, - is_created: item.is_created as u8, + type_: item.header.unwrap().r#type as u8, + id: item.header.unwrap().id as u16, + is_created: item.header.unwrap().is_created as u8, }, data: srv_inventory_data::Data { gem_opt: item.gem_option as u16, diff --git a/packet-service/src/router.rs b/packet-service/src/router.rs index 525d451..082e433 100644 --- a/packet-service/src/router.rs +++ b/packet-service/src/router.rs @@ -8,6 +8,7 @@ use crate::packet::Packet; use crate::packet_type::PacketType; use std::error::Error; use std::sync::Arc; +use std::time::Instant; use tokio::io::{AsyncReadExt, ReadHalf}; use tokio::net::TcpStream; use tokio::sync::Mutex; @@ -42,8 +43,8 @@ impl PacketRouter { PACKETS_RECEIVED.inc(); - let timer = PACKET_PROCESSING_TIME.start_timer(); // Process the packet + let start = Instant::now(); match Packet::from_raw(&buffer[..packet_size]) { Ok(packet) => { debug!("Parsed Packet: {:?}", packet); @@ -51,7 +52,8 @@ impl PacketRouter { } Err(e) => warn!("Failed to parse packet: {}", e), } - timer.stop_and_record(); + let duration = start.elapsed(); + PACKET_PROCESSING_TIME.observe(duration.as_secs_f64()); pool.release(buffer).await; } diff --git a/proto/character_common.proto b/proto/character_common.proto index fe7175d..bf58e33 100644 --- a/proto/character_common.proto +++ b/proto/character_common.proto @@ -41,18 +41,22 @@ message EquippedItem { int32 slot = 5; } -message Item { - int32 item_id = 1; - int32 item_type = 2; +message ItemHeader { + int32 type_ = 1; + int32 id = 2; int32 is_created = 3; - int32 gem_option = 4; - float durability = 5; - float life = 6; - int32 socket = 7; - int32 is_appraised = 8; - int32 grade = 9; - int32 count = 10; - int32 slot = 11; +} + +message Item { + ItemHeader header = 1; + int32 gem_option = 2; + float durability = 3; + float life = 4; + int32 socket = 5; + int32 is_appraised = 6; + int32 grade = 7; + int32 count = 8; + int32 slot = 9; } message Location {