Add routing for 3d costume deck thingy idk

This commit is contained in:
Ethan O'Brien
2026-07-17 10:25:12 -05:00
parent 2aa2c6f2eb
commit e51058a7e9
6 changed files with 88 additions and 4 deletions

View File

@@ -17,6 +17,7 @@ mod android;
mod ios;
use actix_web::{rt, App, HttpServer, web, dev::Service};
//use actix_cors::Cors;
use std::time::Duration;
pub use options::get_args;
use runtime::get_data_path;
@@ -33,6 +34,7 @@ pub async fn run_server(in_thread: bool) -> std::io::Result<()> {
}
let rv = HttpServer::new(|| App::new()
//.wrap(Cors::permissive())
.wrap_fn(|req, srv| {
println!("Request: {} {}", req.method(), req.path());

View File

@@ -17,9 +17,11 @@ struct AssetHashes {
version_android: &'static str,
version_ios: &'static str,
version_windows: &'static str,
version_webgl: &'static str,
android: &'static str,
ios: &'static str,
windows: &'static str,
webgl: &'static str,
}
static ASSET_TABLE: &[(&str, AssetHashes)] = &[
@@ -27,17 +29,21 @@ static ASSET_TABLE: &[(&str, AssetHashes)] = &[
version_android: "4c921d2443335e574a82e04ec9ea243c",
version_ios: "4c921d2443335e574a82e04ec9ea243c",
version_windows: "4c921d2443335e574a82e04ec9ea243c",
version_webgl: "4c921d2443335e574a82e04ec9ea243c",
android: "67f8f261c16b3cca63e520a25aad6c1c",
ios: "b8975be8300013a168d061d3fdcd4a16",
windows: "eb59fcba5ff6987eff1969dbd97eccde",
windows: "fcc15c3dc02250d49c4c492c3b9d58fc",
webgl: "e1ff7c74b20c8d216507972b6f24b9df",
}),
("GL", AssetHashes {
version_android: "5260ff15dff8ba0c00ad91400f515f55",
version_ios: "5260ff15dff8ba0c00ad91400f515f55",
version_ios: "5260ff15dff8ba0c00ad91400f515f55",
version_windows: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
version_webgl: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
android: "d210b28037885f3ef56b8f8aa45ac95b",
ios: "dd7175e4bcdab476f38c33c7f34b5e4d",
windows: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
webgl: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
}),
];
@@ -49,6 +55,7 @@ impl AssetHashes {
("JP", "Android") => (self.android, args.jp_android_asset_hash.as_str()),
("JP", "iOS") => (self.ios, args.jp_ios_asset_hash.as_str()),
("JP", "Windows") => (self.windows, args.windows_asset_hash.as_str()),
("JP", "WebGL") => (self.webgl, ""),
("GL", "Android") => (self.android, args.en_android_asset_hash.as_str()),
("GL", "iOS") => (self.ios, args.en_ios_asset_hash.as_str()),
_ => return None,
@@ -69,6 +76,7 @@ impl AssetHashes {
("JP", "Android") => (self.version_android, ""),
("JP", "iOS") => (self.version_ios, ""),
("JP", "Windows") => (self.version_windows, args.windows_asset_version.as_str()),
("JP", "WebGL") => (self.version_webgl, ""),
("GL", "Android") => (self.version_android, ""),
("GL", "iOS") => (self.version_ios, ""),
("GL", "Windows") => (self.version_windows, ""),
@@ -108,7 +116,8 @@ pub fn parse_platform(header: &str) -> &str {
"iphone" => "iOS",
"windows" => "Windows",
"windowsplayer" => "Windows",
_ => "Android",
"webglplayer" => "WebGL",
_ => panic!("Unknown platform: {header}"),
}
}

View File

@@ -22,6 +22,74 @@ pub fn routes(cfg: &mut web::ServiceConfig) {
.route("/continue", web::post().to(continuee))
.route("/reward", web::post().to(reward))
);
cfg.route("/live3dDeck", web::post().to(live3d_deck));
cfg.route("/live3dDeck/save", web::post().to(live3d_deck_save));
}
async fn live3d_deck(req: HttpRequest, body: String) -> impl Responder {
let key = global::get_login(req.headers(), &body);
let user = userdata::get_acc(&key);
let deck_list = if user["live_mv_deck_list"].is_array() {
user["live_mv_deck_list"].clone()
} else {
array![]
};
global::api(&req, Some(object!{
"deck_list": deck_list
}))
}
async fn live3d_deck_save(req: HttpRequest, body: String) -> impl Responder {
let key = global::get_login(req.headers(), &body);
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
let mut user = userdata::get_acc(&key);
if !user["live_mv_deck_list"].is_array() {
user["live_mv_deck_list"] = array![];
}
let music = body["master_music_id"].as_i64().unwrap_or(0);
let deck_type = body["deck_type"].as_i32().unwrap_or(0);
let clear = body["clear"].as_i32().unwrap_or(0) != 0;
let mut index = None;
for (i, record) in user["live_mv_deck_list"].members().enumerate() {
if record["master_music_id"].as_i64().unwrap_or(-1) == music
&& record["deck_type"].as_i32().unwrap_or(-1) == deck_type {
index = Some(i);
break;
}
}
if clear {
if let Some(i) = index {
user["live_mv_deck_list"].array_remove(i);
}
} else {
let active = body["active"].as_i32().unwrap_or(0);
if active != 0 {
for record in user["live_mv_deck_list"].members_mut() {
if record["master_music_id"].as_i64().unwrap_or(-1) == music {
record["active"] = 0.into();
}
}
}
let record = object!{
"master_music_id": music,
"deck_type": deck_type,
"active": active,
"slot_list": body["slot_list"].clone()
};
match index {
Some(i) => user["live_mv_deck_list"][i] = record,
None => { user["live_mv_deck_list"].push(record).unwrap(); }
}
}
let deck_list = user["live_mv_deck_list"].clone();
userdata::save_acc(&key, user);
global::api(&req, Some(object!{
"deck_list": deck_list
}))
}
async fn retire(req: HttpRequest, body: String) -> impl Responder {

View File

@@ -71,7 +71,7 @@ fn platform_guard(ctx: &guard::GuardContext) -> bool {
.split('/')
.nth(1)
.unwrap_or("");
matches!(platform, "Android" | "StandaloneWindows64" | "iOS")
matches!(platform, "Android" | "StandaloneWindows64" | "StandaloneLinux64" | "WebGL" | "iOS")
}
pub fn routes(cfg: &mut web::ServiceConfig) {