feat: Implement dvd watermark :xdskull:

This commit is contained in:
amizing25 2024-11-10 10:51:42 +07:00
parent a46f2307f8
commit d14f4a9d49
7 changed files with 129 additions and 42 deletions

View File

@ -71,8 +71,8 @@ impl Gateway {
}
async fn establish_kcp_session(&mut self, data: u32, addr: SocketAddr) -> Result<()> {
tracing::info!("New connection from {addr}");
let (conv_id, session_token) = self.next_conv_pair();
tracing::info!("New connection from addr: {addr} with conv_id: {conv_id}");
self.sessions.lock().await.insert(
conv_id,
@ -127,6 +127,13 @@ impl Gateway {
return;
};
// TODO: Temporary fix
if session.read().await.is_destroyed {
drop(session);
self.sessions.lock().await.remove(&conv_id);
return;
}
tokio::spawn(async move {
if let Err(err) = Box::pin(session.write().await.consume(&data)).await {
tracing::error!("An error occurred while processing session ({addr}): {err}");

View File

@ -190,38 +190,38 @@ async fn create_battle_info(caster_id: u32, skill_index: u32) -> SceneBattleInfo
battle_info.buff_list.push(buffs);
}
// pf score object
if player.battle_config.battle_type == BattleType::PF && battle_info.stage_id < 30309041 {
battle_info.battle_target_info.insert(
1,
BattleTargetList {
battle_target_list: vec![BattleTarget {
id: 10002,
progress: 0,
..Default::default()
}],
},
);
// pf score object
if player.battle_config.battle_type == BattleType::PF {
if battle_info.stage_id >= 30309011 {
battle_info.battle_target_info.insert(
1,
BattleTargetList {
battle_target_list: vec![BattleTarget {
id: 10003,
progress: 0,
..Default::default()
}],
},
);
} else {
battle_info.battle_target_info.insert(
1,
BattleTargetList {
battle_target_list: vec![BattleTarget {
id: 10002,
progress: 0,
..Default::default()
}],
},
);
}
}
else { // idk wtf im doing, someone pls optimal it, but atleast it work
battle_info.battle_target_info.insert(
1,
BattleTargetList {
battle_target_list: vec![BattleTarget {
id: 10003,
progress: 0,
..Default::default()
}],
},
);
}
for i in 2..=4 {
battle_info
.battle_target_info
.insert(i, BattleTargetList::default());
}
if player.battle_config.battle_type == BattleType::PF {
battle_info.battle_target_info.insert(
5,
BattleTargetList {
@ -239,7 +239,8 @@ if player.battle_config.battle_type == BattleType::PF {
],
},
);
}
}
// Apocalyptic Shadow
if player.battle_config.battle_type == BattleType::AS {
battle_info.battle_target_info.insert(

View File

@ -1,3 +1,5 @@
use std::sync::atomic::Ordering;
use crate::{
net::{
tools::{FreesrData, MultiPathAvatar},
@ -11,7 +13,8 @@ use super::*;
const SERVER_UID: u32 = 727;
const SERVER_HEAD_ICON: u32 = 201008;
const SERVER_CHAT_BUBBLE_ID: u32 = 220005;
const SERVER_CHAT_HISTORY: [&str; 4] = [
const SERVER_CHAT_HISTORY: [&str; 5] = [
"'dvd' render a dvd bouncing effect. you need to put the image into your game folder, with name \"image.png\"",
"'sync'",
"'mc {mc_id}' mc_id can be set from 8001 to 8006",
"'march {march_id}' march_id can be set 1001 or 1224",
@ -155,6 +158,23 @@ pub async fn on_send_msg_cs_req(
.await
.unwrap();
}
"dvd" => {
session.toggle_dvd().await;
session
.send(RevcMsgScNotify {
msg_type: body.msg_type,
text: format!(
"DVD toggled to {}",
session.dvd_running.load(Ordering::SeqCst)
),
emote: body.emote,
from_uid: SERVER_UID,
to_uid: 25,
chat_type: body.chat_type,
})
.await
.unwrap();
}
_ => {}
}
}

View File

@ -24,12 +24,12 @@ pub async fn on_player_heart_beat_cs_req(
) {
res.client_time_ms = body.client_time_ms;
res.server_time_ms = cur_timestamp_ms();
res.download_data = Some(ClientDownloadData {
version: 51,
time: res.server_time_ms as i64,
data: rbase64::decode("bG9jYWwgZnVuY3Rpb24gYmV0YV90ZXh0KG9iaikKICAgIGxvY2FsIGdhbWVPYmplY3QgPSBDUy5Vbml0eUVuZ2luZS5HYW1lT2JqZWN0LkZpbmQoIlVJUm9vdC9BYm92ZURpYWxvZy9CZXRhSGludERpYWxvZyhDbG9uZSkiKQoKICAgIGlmIGdhbWVPYmplY3QgdGhlbgogICAgICAgIGxvY2FsIHRleHRDb21wb25lbnQgPSBnYW1lT2JqZWN0OkdldENvbXBvbmVudEluQ2hpbGRyZW4odHlwZW9mKENTLlJQRy5DbGllbnQuTG9jYWxpemVkVGV4dCkpCgogICAgICAgIGlmIHRleHRDb21wb25lbnQgdGhlbgogICAgICAgICAgICB0ZXh0Q29tcG9uZW50LnRleHQgPSAiUm9iaW5TUiBpcyBhIGZyZWUgYW5kIG9wZW4gc291cmNlIHNvZnR3YXJlLiBkaXNjb3JkLmdnL3JldmVyc2Vkcm9vbXMiCiAgICAgICAgZW5kCiAgICBlbHNlCiAgICBlbmQKZW5kCgpiZXRhX3RleHQoKQ==").unwrap(),
njddjhapnbo: 0
});
// res.download_data = Some(ClientDownloadData {
// version: 51,
// time: res.server_time_ms as i64,
// data: rbase64::decode("bG9jYWwgZnVuY3Rpb24gYmV0YV90ZXh0KG9iaikKICAgIGxvY2FsIGdhbWVPYmplY3QgPSBDUy5Vbml0eUVuZ2luZS5HYW1lT2JqZWN0LkZpbmQoIlVJUm9vdC9BYm92ZURpYWxvZy9CZXRhSGludERpYWxvZyhDbG9uZSkiKQoKICAgIGlmIGdhbWVPYmplY3QgdGhlbgogICAgICAgIGxvY2FsIHRleHRDb21wb25lbnQgPSBnYW1lT2JqZWN0OkdldENvbXBvbmVudEluQ2hpbGRyZW4odHlwZW9mKENTLlJQRy5DbGllbnQuTG9jYWxpemVkVGV4dCkpCgogICAgICAgIGlmIHRleHRDb21wb25lbnQgdGhlbgogICAgICAgICAgICB0ZXh0Q29tcG9uZW50LnRleHQgPSAiUm9iaW5TUiBpcyBhIGZyZWUgYW5kIG9wZW4gc291cmNlIHNvZnR3YXJlLiBkaXNjb3JkLmdnL3JldmVyc2Vkcm9vbXMiCiAgICAgICAgZW5kCiAgICBlbHNlCiAgICBlbmQKZW5kCgpiZXRhX3RleHQoKQ==").unwrap(),
// njddjhapnbo: 0
// });
}
pub async fn on_player_login_finish_cs_req(
@ -53,7 +53,9 @@ pub async fn on_player_login_finish_cs_req(
..Default::default()
}),
})
.await
.await?;
Ok(())
}
pub async fn on_get_multi_path_avatar_info_cs_req(

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@ use std::{collections::HashMap, fs, sync::LazyLock};
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Vector {
pub x: i32, // or f32 depending on your needs
pub x: i32,
pub y: i32,
pub z: i32,
}

View File

@ -2897,6 +2897,15 @@ pub struct Cijjendfjlo {
#[prost(uint32, tag = "1")]
pub kklaobblgce: u32,
}
/// Obf: CIJNHLEPACK
#[derive(proto_derive::CmdID)]
#[cmdid(15)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ClientDownloadDataScNotify {
#[prost(message, optional, tag = "2")]
pub download_data: ::core::option::Option<ClientDownloadData>,
}
#[derive(proto_derive::CmdID)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]