Skip to content

Commit

Permalink
Fix views
Browse files Browse the repository at this point in the history
  • Loading branch information
Xerxes-2 committed Apr 28, 2024
1 parent 9b69fb6 commit 93f1995
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "majsoul_max_rs"
version = "0.3.6"
version = "0.3.7"
edition = "2021"

[lib]
Expand Down
137 changes: 132 additions & 5 deletions liqi_config/settings.mod.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,142 @@
{
"character": 200001,
"characters": {},
"mainChar": 200001,
"charSkin": {
"200087": 408701,
"200040": 404001,
"200067": 406701,
"200090": 409001,
"200070": 407001,
"200052": 405201,
"200028": 402801,
"200079": 407901,
"200060": 406001,
"200016": 401601,
"200068": 406801,
"200051": 405101,
"200043": 404301,
"200019": 401901,
"200082": 408201,
"200005": 400501,
"200065": 406501,
"200085": 408501,
"200029": 402901,
"200012": 401201,
"200022": 402201,
"200042": 404201,
"200064": 406401,
"200001": 400101,
"200061": 406101,
"200071": 407101,
"200056": 405601,
"200084": 408401,
"200054": 405401,
"200006": 400601,
"200063": 406301,
"200041": 404101,
"200077": 407701,
"200013": 401301,
"200020": 402001,
"200046": 404601,
"200050": 405001,
"200023": 402301,
"200072": 407201,
"200017": 401701,
"200021": 402101,
"200011": 401101,
"200047": 404701,
"200044": 404401,
"200004": 400401,
"200010": 401001,
"200033": 403301,
"200002": 400201,
"200049": 404901,
"200037": 403701,
"200045": 404501,
"200038": 403801,
"200083": 408301,
"200088": 408801,
"200081": 408101,
"200034": 403401,
"200074": 407401,
"200026": 402601,
"200018": 401801,
"200032": 403201,
"200059": 405901,
"200014": 401401,
"200027": 402701,
"200057": 405701,
"200066": 406601,
"200025": 402501,
"200069": 406901,
"200003": 400301,
"200008": 400801,
"200007": 400701,
"200086": 408601,
"200055": 405501,
"200009": 400901,
"200078": 407801,
"200080": 408001,
"200073": 407301,
"200058": 405801,
"200076": 407601,
"200036": 403601,
"200024": 402401,
"200053": 405301,
"200075": 407501,
"200031": 403101,
"200048": 404801,
"200015": 401501,
"200030": 403001,
"200035": 403501,
"200062": 406201,
"200039": 403901,
"200089": 408901
},
"nickname": "",
"starCharacter": [],
"hintSwitch": 1,
"title": 0,
"loadingBg": [],
"emojiSwitch": 0,
"views": [[], [], [], [], [], [], [], [], [], []],
"view": 0,
"viewsPresets": [
[
{
"slot": 0,
"item_id": 305001,
"type": 0,
"item_id_list": []
},
{
"slot": 1,
"item_id": 305007,
"type": 0,
"item_id_list": []
},
{
"slot": 2,
"item_id": 305010,
"type": 0,
"item_id_list": []
},
{
"slot": 3,
"item_id": 305011,
"type": 0,
"item_id_list": []
}
],
[],
[],
[],
[],
[],
[],
[],
[],
[]
],
"presetIndex": 0,
"showServer": 1,
"autoUpdate": 1,
"version": "v0.11.39.w"
}
}
22 changes: 17 additions & 5 deletions src/modder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ impl Modder {
assert!(PARSER.read().await.respond_type.contains_key(&msg_id));
let method_name = PARSER.read().await.respond_type[&msg_id].0.clone();
let mut modified_data: Option<Vec<u8>> = None;
info!("Respond method: {}", method_name);
match method_name.as_ref() {
".lq.Lobby.fetchCharacterInfo" => {
let mut msg = lq::ResCharacterInfo::decode(msg_block.data.as_ref())?;
Expand Down Expand Up @@ -227,14 +226,18 @@ impl Modder {
".lq.FastTest.authGame" => {
let mut msg = lq::ResAuthGame::decode(msg_block.data.as_ref())?;
if MOD_SETTINGS.read().await.hint_on() {
msg.game_config
if let Some(r) = msg
.game_config
.as_mut()
.and_then(|c| c.mode.as_mut()?.detail_rule.as_mut())
.map(|r| r.bianjietishi = true);
{
r.bianjietishi = true;
}
}
for p in &mut msg.players {
self.change_player(p).await;
}
info!("Respond authGame: {:?}", msg);
modified_data = Some(msg.encode_to_vec());
}
".lq.Lobby.fetchTitleList" => {
Expand Down Expand Up @@ -334,6 +337,7 @@ impl Modder {
_ => {}
}
if let Some(data) = modified_data {
info!("Respond method: {}", method_name);
msg_block.data = data;
let mut buf = vec![buf[0], buf[1], buf[2]];
buf.extend(msg_block.encode_to_vec());
Expand Down Expand Up @@ -388,6 +392,12 @@ impl Modder {
p.nickname = MOD_SETTINGS.read().await.nickname.clone();
}
p.title = MOD_SETTINGS.read().await.title;
p.views.clear();
p.views.extend(
MOD_SETTINGS.read().await.views_presets
[MOD_SETTINGS.read().await.preset_index as usize]
.clone(),
);
}
}
if MOD_SETTINGS.read().await.show_server() {
Expand Down Expand Up @@ -417,7 +427,9 @@ impl Modder {
}
character.views.clear();
character.views.extend(
MOD_SETTINGS.read().await.views_presets[MOD_SETTINGS.read().await.preset_index as usize].clone(),
MOD_SETTINGS.read().await.views_presets
[MOD_SETTINGS.read().await.preset_index as usize]
.clone(),
);
character
}
Expand Down Expand Up @@ -504,7 +516,7 @@ impl Modder {
".lq.Lobby.saveCommonViews" => {
fake = true;
let msg = lq::ReqSaveCommonViews::decode(msg_block.data.as_ref())?;
MOD_SETTINGS.write().await.views_presets[msg.save_index as usize] = msg.views.clone();
MOD_SETTINGS.write().await.views_presets[msg.save_index as usize] = msg.views;
if msg.is_use == 1 {
MOD_SETTINGS.write().await.preset_index = msg.save_index;
}
Expand Down
8 changes: 4 additions & 4 deletions src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,9 @@ pub async fn get_lqbin_prefix(version: &str) -> Result<String> {

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ModSettings {
#[serde(default)]
#[serde(rename = "mainChar")]
pub main_char: u32,
#[serde(default)]
#[serde(rename = "charSkin")]
pub char_skin: HashMap<u32, u32>,
#[serde(default)]
pub nickname: String,
Expand All @@ -252,9 +252,9 @@ pub struct ModSettings {
pub loading_bg: Vec<u32>,
#[serde(rename = "emojiSwitch")]
emoji_switch: i32,
#[serde(default)]
#[serde(rename = "viewsPresets")]
pub views_presets: [Vec<ViewSlot>; 10],
#[serde(default)]
#[serde(rename = "presetIndex")]
pub preset_index: u32,
#[serde(rename = "showServer")]
show_server: i32,
Expand Down

0 comments on commit 93f1995

Please sign in to comment.