From adbdaa38ab4f5ef5370e43162a00240c2637944d Mon Sep 17 00:00:00 2001 From: xeon Date: Sat, 30 Mar 2024 00:16:06 +0300 Subject: [PATCH] Add uid field in PlayerInfo --- gameserver/src/game/player_info.rs | 2 ++ gameserver/src/net/handlers/authentication.rs | 2 +- gameserver/src/net/handlers/scene.rs | 2 +- gameserver/src/net/session.rs | 4 ++++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gameserver/src/game/player_info.rs b/gameserver/src/game/player_info.rs index a9a5051..63d6742 100644 --- a/gameserver/src/game/player_info.rs +++ b/gameserver/src/game/player_info.rs @@ -5,12 +5,14 @@ use anyhow::Result; use proto::*; pub struct PlayerInfo { + pub uid: u32, pub lineup: LineupInfo, } impl PlayerInfo { pub fn new() -> Self { Self { + uid: 1337, lineup: default_lineup(), } } diff --git a/gameserver/src/net/handlers/authentication.rs b/gameserver/src/net/handlers/authentication.rs index af50496..75bf17c 100644 --- a/gameserver/src/net/handlers/authentication.rs +++ b/gameserver/src/net/handlers/authentication.rs @@ -13,7 +13,7 @@ pub async fn on_player_get_token_cs_req( PlayerGetTokenScRsp { retcode: 0, msg: String::from("OK"), - uid: 1337, + uid: session.player_uid(), ..Default::default() }, ) diff --git a/gameserver/src/net/handlers/scene.rs b/gameserver/src/net/handlers/scene.rs index 1bdf321..f8d4ab9 100644 --- a/gameserver/src/net/handlers/scene.rs +++ b/gameserver/src/net/handlers/scene.rs @@ -26,7 +26,7 @@ pub async fn on_get_cur_scene_info_cs_req( avatar_type: 3, base_avatar_id: 1309, map_layer: 2, - uid: 1337, + uid: session.player_uid(), }), motion: Some(MotionInfo { aomilajjmii: Some(Vector { diff --git a/gameserver/src/net/session.rs b/gameserver/src/net/session.rs index c726787..fe24812 100644 --- a/gameserver/src/net/session.rs +++ b/gameserver/src/net/session.rs @@ -51,6 +51,10 @@ impl PlayerSession { self.client_socket.lock().await } + pub fn player_uid(&self) -> u32 { + self.player_info().uid + } + pub fn player_info(&self) -> AtomicRef { self.player_info.borrow() }