mirror of
https://git.neonteam.dev/amizing/robinsr.git
synced 2025-03-12 03:28:30 -04:00
Implement Sync Inventory
This commit is contained in:
parent
1e8e6f04c3
commit
1e0cfa6f12
@ -308,7 +308,7 @@ pub async fn on_mpemgbdkigg(session: &mut PlayerSession, request: &Mpemgbdkigg)
|
||||
let targets = request
|
||||
.jpieajikioh
|
||||
.iter()
|
||||
.filter(|id| **id > 20_000 || **id < 10)
|
||||
.filter(|id| **id > 30_000 || **id < 1_000)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
if targets.is_empty() {
|
||||
|
||||
220
gameserver/src/net/handlers/chat.rs
Normal file
220
gameserver/src/net/handlers/chat.rs
Normal file
@ -0,0 +1,220 @@
|
||||
use crate::{
|
||||
net::{
|
||||
tools::{JsonData, MainCharacter},
|
||||
PlayerSession,
|
||||
},
|
||||
util::cur_timestamp_ms,
|
||||
};
|
||||
|
||||
use super::*;
|
||||
|
||||
pub async fn on_nhfajfplkep(session: &mut PlayerSession, _: &Nhfajfplkep) -> Result<()> {
|
||||
session
|
||||
.send(
|
||||
CMD_GET_FRIEND_LIST_INFO_SC_RSP,
|
||||
Pbfkjlnnnim {
|
||||
amgpdgdnlgd: vec![Leldmbjfheh {
|
||||
gpgdedmpjla: PlayingState::None.into(),
|
||||
cfmiklhjmle: Some(Alcoeanikil::default()),
|
||||
hiljemhhhnk: String::from("RobinSR"),
|
||||
kmclngophda: Some(Hcdpijbnijp {
|
||||
uid: 727,
|
||||
mbdjcknimop: 3,
|
||||
igmaomgegaj: 1,
|
||||
gjlfhjlijon: 201008,
|
||||
jpajpffgnbi: 220005,
|
||||
level: 70,
|
||||
nickname: String::from("Server"),
|
||||
plmbeaaegak: vec![AssistSimpleInfo {
|
||||
avatar_id: 1008,
|
||||
level: 70,
|
||||
..Default::default()
|
||||
}],
|
||||
..Default::default()
|
||||
}),
|
||||
gjdiplfecfa: true,
|
||||
}],
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn on_komknbijgpi(session: &mut PlayerSession, _: &Komknbijgpi) -> Result<()> {
|
||||
session
|
||||
.send(
|
||||
CMD_GET_PRIVATE_CHAT_HISTORY_SC_RSP,
|
||||
Ooibcglpnac {
|
||||
pgofeopnpbm: vec![Bpifmdladdn {
|
||||
bdjoneohhpj: MsgType::CustomText.into(),
|
||||
phhhfhobhmk: cur_timestamp_ms(),
|
||||
fbelgjfhbkh: ":motorized_wheelchair:".to_string(),
|
||||
nokipdbhglc: 727,
|
||||
..Default::default()
|
||||
}],
|
||||
fjbkleaflam: 727,
|
||||
oligkfnjkma: 1337,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
// RecvMsgCsReq
|
||||
pub async fn on_bgfjcbbfiek(session: &mut PlayerSession, body: &Bgfjcbbfiek) -> Result<()> {
|
||||
let mut json = JsonData::load().await;
|
||||
if let Some((cmd, args)) = parse_command(&body.moiplammfad) {
|
||||
match cmd {
|
||||
"sync" => {
|
||||
sync_player(session, json).await?;
|
||||
session
|
||||
.send(
|
||||
CMD_REVC_MSG_SC_NOTIFY,
|
||||
Kifdjbodlcc {
|
||||
pofomobijdg: body.pofomobijdg,
|
||||
kjdhmhgjdmc: body.kjdhmhgjdmc,
|
||||
moiplammfad: String::from("Inventory Synced"),
|
||||
bdjoneohhpj: body.bdjoneohhpj,
|
||||
aljhmlmnmhp: 727,
|
||||
djefnoaonkc: 1337,
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
"mc" => {
|
||||
let mc = MainCharacter::from(
|
||||
args.first()
|
||||
.unwrap_or(&"")
|
||||
.parse::<u32>()
|
||||
.unwrap_or(json.main_character as u32),
|
||||
);
|
||||
|
||||
json.main_character = mc;
|
||||
json.save().await;
|
||||
|
||||
session
|
||||
.send(
|
||||
CMD_GET_HERO_BASIC_TYPE_INFO_SC_RSP,
|
||||
GetHeroBasicTypeInfoScRsp {
|
||||
retcode: 0,
|
||||
gender: mc.get_gender().into(),
|
||||
cur_basic_type: mc.get_type().into(),
|
||||
basic_type_info_list: vec![HeroBasicTypeInfo {
|
||||
basic_type: mc.get_type().into(),
|
||||
..Default::default()
|
||||
}],
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
|
||||
sync_player(session, json).await?;
|
||||
|
||||
session
|
||||
.send(
|
||||
CMD_REVC_MSG_SC_NOTIFY,
|
||||
Kifdjbodlcc {
|
||||
pofomobijdg: body.pofomobijdg,
|
||||
kjdhmhgjdmc: body.kjdhmhgjdmc,
|
||||
moiplammfad: format!("Set MC to: {mc:#?}"),
|
||||
bdjoneohhpj: body.bdjoneohhpj,
|
||||
aljhmlmnmhp: 727,
|
||||
djefnoaonkc: 1337,
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
session
|
||||
.send(
|
||||
CMD_SEND_MSG_SC_RSP,
|
||||
Jhickbdnnii {
|
||||
retcode: 0,
|
||||
end_time: 0,
|
||||
},
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
fn parse_command(command: &str) -> Option<(&str, Vec<&str>)> {
|
||||
let parts: Vec<&str> = command.split_whitespace().collect();
|
||||
|
||||
if parts.is_empty() {
|
||||
return Option::None;
|
||||
}
|
||||
|
||||
Some((parts[0], parts[1..].to_vec()))
|
||||
}
|
||||
|
||||
async fn sync_player(session: &mut PlayerSession, json: JsonData) -> Result<()> {
|
||||
session
|
||||
.send(
|
||||
CMD_PLAYER_SYNC_SC_NOTIFY,
|
||||
Eckkajafean {
|
||||
lminpcphbfp: (2000..3500).collect(),
|
||||
oglioehgbal: (1..2000).collect(),
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
|
||||
session
|
||||
.send(
|
||||
CMD_PLAYER_SYNC_SC_NOTIFY,
|
||||
Eckkajafean {
|
||||
fihplpphfme: Some(Abcekhjbnmp {
|
||||
avatar_list: json
|
||||
.avatars
|
||||
.values()
|
||||
.map(|avatar| avatar.to_avatar_proto(Option::None, vec![]))
|
||||
.collect::<Vec<_>>(),
|
||||
}),
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
|
||||
session
|
||||
.send(
|
||||
CMD_PLAYER_SYNC_SC_NOTIFY,
|
||||
Eckkajafean {
|
||||
relic_list: json.relics.iter().map(|v| v.to_relic_proto()).collect(),
|
||||
equipment_list: json
|
||||
.lightcones
|
||||
.iter()
|
||||
.map(|v| v.to_equipment_proto())
|
||||
.collect(),
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
|
||||
session
|
||||
.send(
|
||||
CMD_PLAYER_SYNC_SC_NOTIFY,
|
||||
Eckkajafean {
|
||||
fihplpphfme: Some(Abcekhjbnmp {
|
||||
avatar_list: json
|
||||
.avatars
|
||||
.values()
|
||||
.map(|avatar| {
|
||||
avatar.to_avatar_proto(
|
||||
json.lightcones
|
||||
.iter()
|
||||
.find(|v| v.equip_avatar == avatar.avatar_id),
|
||||
json.relics
|
||||
.iter()
|
||||
.filter(|v| v.equip_avatar == avatar.avatar_id)
|
||||
.collect(),
|
||||
)
|
||||
})
|
||||
.collect(),
|
||||
}),
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.await
|
||||
}
|
||||
@ -155,6 +155,38 @@ async fn refresh_lineup(sess: &mut PlayerSession, player: &JsonData) -> Result<(
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
sess.send(
|
||||
CMD_SCENE_GROUP_REFRESH_SC_NOTIFY,
|
||||
Ljihfeagpcl {
|
||||
kpfomkdmoce: vec![Jnofbbanolk {
|
||||
group_id: 0,
|
||||
state: 0,
|
||||
kppckepfpce: 0,
|
||||
fiiciciambe: player
|
||||
.lineups
|
||||
.iter()
|
||||
.map(|(idx, v)| Gffbkjofnad {
|
||||
fimallpbobk: 0,
|
||||
mggfjbdchjh: 0,
|
||||
glalelmdamm: Some(SceneEntityInfo {
|
||||
actor: Some(SceneActorInfo {
|
||||
avatar_type: AvatarType::AvatarFormalType.into(),
|
||||
base_avatar_id: *v,
|
||||
map_layer: 0,
|
||||
uid: 1337,
|
||||
}),
|
||||
entity_id: idx + 1,
|
||||
group_id: 0,
|
||||
inst_id: 0,
|
||||
..Default::default()
|
||||
}),
|
||||
})
|
||||
.collect(),
|
||||
}],
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
|
||||
sess.send(
|
||||
CMD_SYNC_LINEUP_NOTIFY,
|
||||
SyncLineupNotify {
|
||||
|
||||
@ -7,6 +7,7 @@ mod player;
|
||||
mod scene;
|
||||
mod tutorial;
|
||||
mod inventory;
|
||||
mod chat;
|
||||
|
||||
use anyhow::Result;
|
||||
use paste::paste;
|
||||
@ -25,6 +26,7 @@ pub use player::*;
|
||||
pub use scene::*;
|
||||
pub use tutorial::*;
|
||||
pub use inventory::*;
|
||||
pub use chat::*;
|
||||
|
||||
use proto::{
|
||||
Aaihejacdpk::*, Achkcddkkkj::*, Bancodieeof::*, CmdActivityType::*, CmdBattleType::*,
|
||||
@ -80,7 +82,7 @@ dummy! {
|
||||
QueryProductInfo,
|
||||
GetQuestData,
|
||||
GetQuestRecord,
|
||||
GetFriendListInfo,
|
||||
// GetFriendListInfo,
|
||||
GetFriendApplyListInfo,
|
||||
GetCurAssist,
|
||||
GetRogueHandbookData,
|
||||
|
||||
@ -300,9 +300,9 @@ async fn load_scene(
|
||||
};
|
||||
|
||||
let mut loaded_npc: Vec<u32> = vec![];
|
||||
let mut prop_entity_id = 10;
|
||||
let mut npc_entity_id = 10_000;
|
||||
let mut monster_entity_id = 20_000;
|
||||
let mut prop_entity_id = 1_000;
|
||||
let mut npc_entity_id = 20_000;
|
||||
let mut monster_entity_id = 30_000;
|
||||
|
||||
for (group_id, group) in &group_config.group_items {
|
||||
let mut group_info = Dhkacjhaoid {
|
||||
|
||||
@ -280,9 +280,9 @@ trait_handler! {
|
||||
// StartChallengeScRsp 1788;
|
||||
// GetChallengeCsReq 1734;
|
||||
// BatchMarkChatEmojiScRsp 3906;
|
||||
// SendMsgCsReq 3934;
|
||||
Bgfjcbbfiek 3934;// SendMsgCsReq 3934;
|
||||
// GetPrivateChatHistoryScRsp 3909;
|
||||
// GetPrivateChatHistoryCsReq 3902;
|
||||
Komknbijgpi 3902; // GetPrivateChatHistoryCsReq 3902;
|
||||
// GetChatEmojiListScRsp 3929;
|
||||
// PrivateMsgOfflineUsersScNotify 3988;
|
||||
// MarkChatEmojiCsReq 3945;
|
||||
@ -493,7 +493,7 @@ trait_handler! {
|
||||
// GetAssistListCsReq 2961;
|
||||
// GetFriendRecommendListInfoScRsp 2939;
|
||||
// GetPlatformPlayerInfoCsReq 2965;
|
||||
// GetFriendListInfoCsReq 2934;
|
||||
Nhfajfplkep 2934;// GetFriendListInfoCsReq 2934;
|
||||
// SetAssistScRsp 2997;
|
||||
// SetForbidOtherApplyFriendCsReq 2992;
|
||||
// GetCurAssistCsReq 2924;
|
||||
|
||||
@ -535,20 +535,21 @@ pub enum MainCharacter {
|
||||
FemaleHarmony = 8006,
|
||||
}
|
||||
|
||||
impl From<u32> for MainCharacter {
|
||||
fn from(value: u32) -> Self {
|
||||
match value {
|
||||
8001 => Self::MalePyhsical,
|
||||
8002 => Self::FemalePhysical,
|
||||
8003 => Self::MalePreservation,
|
||||
8004 => Self::FemalePreservation,
|
||||
8005 => Self::MaleHarmony,
|
||||
8006 => Self::FemaleHarmony,
|
||||
_ => Self::FemaleHarmony,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl MainCharacter {
|
||||
// pub fn to_vec() -> Vec<MainCharacter> {
|
||||
// return vec![
|
||||
// MainCharacter::MalePyhsical,
|
||||
// MainCharacter::FemalePhysical,
|
||||
|
||||
// MainCharacter::MalePreservation,
|
||||
// MainCharacter::FemalePreservation,
|
||||
|
||||
// MainCharacter::MaleHarmony,
|
||||
// MainCharacter::FemaleHarmony
|
||||
// ]
|
||||
// }
|
||||
|
||||
pub fn get_gender(&self) -> Gender {
|
||||
if *self as u32 % 2 == 1 {
|
||||
Gender::Man
|
||||
@ -579,9 +580,11 @@ impl JsonData {
|
||||
pub async fn load() -> Self {
|
||||
let mut json: JsonData = tokio::fs::read_to_string("freesr-data.json")
|
||||
.await
|
||||
.map(|v| serde_json::from_str(&v))
|
||||
.expect("freesr-data.json is broken, pls redownload")
|
||||
.expect("freesr-data.json is broken, pls redownload");
|
||||
.map(|v| {
|
||||
serde_json::from_str::<JsonData>(&v)
|
||||
.expect("freesr-data.json is broken, pls redownload")
|
||||
})
|
||||
.expect("failed to read freesr-data.json");
|
||||
|
||||
let json2: JsonData2 = serde_json::from_str(
|
||||
&tokio::fs::read_to_string("persistent")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user