Skip to content

Commit c3b7242

Browse files
committed
不知道写的什么鬼东西总之抄群主的逻辑
1 parent befe716 commit c3b7242

File tree

1 file changed

+81
-7
lines changed

1 file changed

+81
-7
lines changed

src/modder.rs

+81-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::{
22
base::BaseMessage,
3-
lq::{self, Character, PlayerGameView},
3+
lq::{self, Character, PlayerGameView, ResTitleList},
44
lq_config::ConfigTables,
55
parser::Parser,
66
settings::ModSettings,
@@ -255,12 +255,17 @@ impl Modder {
255255
".lq.FastTest.authGame" => {
256256
let mut msg = lq::ResAuthGame::decode(msg_block.data.as_ref())?;
257257
if MOD_SETTINGS.read().await.hint_on() {
258-
if let Some(r) = msg
259-
.game_config
260-
.as_mut()
261-
.and_then(|c| c.mode.as_mut()?.detail_rule.as_mut())
262-
{
263-
r.bianjietishi = true;
258+
if let Some(c) = msg.game_config.as_mut() {
259+
if let Some(r) = c.mode.as_mut().and_then(|m| m.detail_rule.as_mut()) {
260+
r.bianjietishi = true;
261+
}
262+
if let Some(ref mut id) = c.meta.as_mut().map(|m| m.mode_id) {
263+
match *id {
264+
a if (15..=16).contains(&a) => *id -= 4,
265+
b if (25..=26).contains(&b) => *id -= 2,
266+
_ => {}
267+
}
268+
}
264269
}
265270
}
266271
for p in &mut msg.players {
@@ -362,6 +367,10 @@ impl Modder {
362367
views.views.push(new_view);
363368
}
364369
}
370+
msg.title_list = Some(ResTitleList {
371+
title_list: self.titles.iter().map(|t| t.id).collect(),
372+
..Default::default()
373+
});
365374
modified_data = Some(msg.encode_to_vec());
366375
}
367376
".lq.Lobby.fetchServerSettings" => {
@@ -376,6 +385,30 @@ impl Modder {
376385
}
377386
}
378387
}
388+
".lq.Lobby.fetchGameRecord" => {
389+
let msg = lq::ResGameRecord::decode(msg_block.data.as_ref())?;
390+
if let Some(head) = msg.head.as_ref() {
391+
let uuid = head.uuid.as_str();
392+
const LOG_HEAD: &str = "发现读入牌谱!\n";
393+
const LOG_TAIL: &str = "注意:只有在同一服务器才能添加好友!";
394+
let mut logs = String::new();
395+
for acc in &head.accounts {
396+
if acc.account_id == SAFE.read().await.account_id {
397+
logs += "(自己)";
398+
}
399+
logs += &format!(
400+
"{}\n账号id: {}\t加好友id: {}\n主视角牌谱链接: {uuid}_a{}\n主视角牌谱链接(匿名): {}_a{}_2\n\n",
401+
add_zone_id(acc.account_id, &acc.nickname),
402+
acc.account_id,
403+
encode_account_id2(acc.account_id),
404+
encode_account_id(acc.account_id),
405+
encode_uuid(uuid),
406+
encode_account_id(acc.account_id),
407+
);
408+
}
409+
info!("{}{}{}", LOG_HEAD, logs, LOG_TAIL);
410+
}
411+
}
379412
_ => {}
380413
}
381414
if let Some(data) = modified_data {
@@ -725,6 +758,47 @@ fn add_zone_id(id: u32, name: &str) -> String {
725758
zone + name
726759
}
727760

761+
fn encode_uuid(uuid: &str) -> String {
762+
let mut buf = "".to_string();
763+
const CODE_0: u32 = '0' as u32;
764+
const CODE_A: u32 = 'a' as u32;
765+
for (i, c) in uuid.chars().enumerate() {
766+
let code = c as u32;
767+
let mut tmp = 0xFF;
768+
if (CODE_0..CODE_0 + 10).contains(&code) {
769+
tmp = code - CODE_0;
770+
} else if (CODE_A..CODE_A + 26).contains(&code) {
771+
tmp = code - CODE_A + 10;
772+
}
773+
if tmp != 0xFF {
774+
tmp = (tmp + 17 + i as u32) % 36;
775+
if tmp < 10 {
776+
buf.push((CODE_0 + tmp) as u8 as char);
777+
} else {
778+
buf.push((CODE_A + tmp - 10) as u8 as char);
779+
}
780+
} else {
781+
buf.push(c);
782+
}
783+
}
784+
buf
785+
}
786+
787+
fn encode_account_id(id: u32) -> u32 {
788+
((7 * id + 1117113) ^ 86216345) + 1358437
789+
}
790+
791+
fn encode_account_id2(id: u32) -> u32 {
792+
let p = 6139246 ^ id;
793+
const H: u32 = 67108863;
794+
let s = p & !H;
795+
let mut z = p & H;
796+
for _ in 0..5 {
797+
z = (511 & z) << 17 | z >> 9;
798+
}
799+
z + s + 1e7 as u32
800+
}
801+
728802
enum Block {
729803
_VarInt(u32, u64),
730804
String(u32, Bytes),

0 commit comments

Comments
 (0)