mirror of
https://git.ethanthesleepy.one/ethanaobrien/ew
synced 2026-01-12 08:12:36 +08:00
Add the (currently android) easter mode
This commit is contained in:
@@ -33,10 +33,10 @@ extern "C" fn Java_one_ethanthesleepy_androidew_BackgroundService_startServer<'l
|
||||
data_path: JString<'local>,
|
||||
easter: jboolean
|
||||
) -> jstring {
|
||||
//crate::runtime::set_easter_mode(easter != 0);
|
||||
crate::runtime::set_easter_mode(easter != 0);
|
||||
|
||||
let data_path: String = env.get_string(&data_path).unwrap().into();
|
||||
crate::runtime::update_data_path(data_path);
|
||||
crate::runtime::update_data_path(&data_path);
|
||||
|
||||
let output = env.new_string(String::from("Azunyannnn~")).unwrap();
|
||||
thread::spawn(|| {
|
||||
@@ -56,5 +56,5 @@ extern "C" fn Java_one_ethanthesleepy_androidew_BackgroundService_stopServer<'lo
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
extern "C" fn Java_one_ethanthesleepy_androidew_BackgroundService_setEasterMode<'local>(_env: JNIEnv<'local>, _class: JClass<'local>, easter: jboolean) {
|
||||
//crate::runtime::set_easter_mode(easter != 0);
|
||||
crate::runtime::set_easter_mode(easter != 0);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ pub static INITIALIZER: extern "C" fn() = main;
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn main() {
|
||||
let data_path = get_bundle_path().into_os_string().into_string().unwrap();
|
||||
crate::runtime::update_data_path(data_path);
|
||||
crate::runtime::update_data_path(&data_path);
|
||||
|
||||
std::thread::spawn(|| {
|
||||
crate::run_server(true).unwrap();
|
||||
|
||||
@@ -39,7 +39,12 @@ pub async fn run_server(in_thread: bool) -> std::io::Result<()> {
|
||||
|
||||
let rv = HttpServer::new(|| App::new()
|
||||
.wrap_fn(|req, srv| {
|
||||
println!("Request: {}", req.path());
|
||||
println!("Request: {} {}", req.method(), req.path());
|
||||
|
||||
#[cfg(feature = "library")]
|
||||
#[cfg(target_os = "android")]
|
||||
log_to_logcat!("ew", "Request: {} {}", req.method(), req.path());
|
||||
|
||||
srv.call(req)
|
||||
})
|
||||
.app_data(web::PayloadConfig::default().limit(1024 * 1024 * 25))
|
||||
|
||||
@@ -9,40 +9,54 @@ use uuid::Uuid;
|
||||
|
||||
use crate::encryption;
|
||||
use crate::router::{userdata, gree, items};
|
||||
use crate::runtime::get_easter_mode;
|
||||
|
||||
pub const ASSET_VERSION: &str = "5260ff15dff8ba0c00ad91400f515f55";
|
||||
pub const ASSET_HASH_ANDROID: &str = "d210b28037885f3ef56b8f8aa45ac95b";
|
||||
pub const ASSET_HASH_IOS: &str = "dd7175e4bcdab476f38c33c7f34b5e4d";
|
||||
pub const ASSET_VERSION_GL: &str = "5260ff15dff8ba0c00ad91400f515f55";
|
||||
pub const ASSET_HASH_ANDROID_GL: &str = "d210b28037885f3ef56b8f8aa45ac95b";
|
||||
pub const ASSET_HASH_IOS_GL: &str = "dd7175e4bcdab476f38c33c7f34b5e4d";
|
||||
|
||||
pub const ASSET_VERSION_JP: &str = "4c921d2443335e574a82e04ec9ea243c";
|
||||
pub const ASSET_HASH_ANDROID_JP: &str = "67f8f261c16b3cca63e520a25aad6c1c";
|
||||
pub const ASSET_HASH_IOS_JP: &str = "b8975be8300013a168d061d3fdcd4a16";
|
||||
pub const ASSET_VERSION_JP: &str = "4c921d2443335e574a82e04ec9ea243c";
|
||||
pub const ASSET_HASH_ANDROID_JP: &str = "67f8f261c16b3cca63e520a25aad6c1c";
|
||||
pub const ASSET_HASH_IOS_JP: &str = "b8975be8300013a168d061d3fdcd4a16";
|
||||
|
||||
pub const ASSET_HASH_ANDROID_EASTER_GL: &str = "da7ae831381c3f29337caa9891db7e6a";
|
||||
pub const ASSET_HASH_ANDROID_EASTER_JP: &str = "eac0cad61c82bf2e31fc596555747d11";
|
||||
|
||||
pub fn get_asset_hash(asset_version: String, android: bool) -> String {
|
||||
let args = crate::get_args();
|
||||
if asset_version == ASSET_VERSION_JP {
|
||||
if android {
|
||||
if android {
|
||||
if asset_version == ASSET_VERSION_JP {
|
||||
if args.jp_android_asset_hash != String::new() {
|
||||
args.jp_android_asset_hash
|
||||
&args.jp_android_asset_hash
|
||||
} else if get_easter_mode() {
|
||||
ASSET_HASH_ANDROID_EASTER_JP
|
||||
} else {
|
||||
ASSET_HASH_ANDROID_JP.to_string()
|
||||
ASSET_HASH_ANDROID_JP
|
||||
}
|
||||
} else if args.jp_ios_asset_hash != String::new() {
|
||||
args.jp_ios_asset_hash
|
||||
} else {
|
||||
ASSET_HASH_IOS_JP.to_string()
|
||||
if args.en_android_asset_hash != String::new() {
|
||||
&args.en_android_asset_hash
|
||||
} else if get_easter_mode() {
|
||||
ASSET_HASH_ANDROID_EASTER_GL
|
||||
} else {
|
||||
ASSET_HASH_ANDROID_GL
|
||||
}
|
||||
}
|
||||
} else if android {
|
||||
if args.en_android_asset_hash != String::new() {
|
||||
args.en_android_asset_hash
|
||||
} else {
|
||||
ASSET_HASH_ANDROID.to_string()
|
||||
}
|
||||
} else if args.en_ios_asset_hash != String::new() {
|
||||
args.en_ios_asset_hash
|
||||
} else {
|
||||
ASSET_HASH_IOS.to_string()
|
||||
}
|
||||
if asset_version == ASSET_VERSION_JP {
|
||||
if args.jp_ios_asset_hash != String::new() {
|
||||
&args.jp_ios_asset_hash
|
||||
} else {
|
||||
ASSET_HASH_IOS_JP
|
||||
}
|
||||
} else {
|
||||
if args.en_ios_asset_hash != String::new() {
|
||||
&args.en_ios_asset_hash
|
||||
} else {
|
||||
ASSET_HASH_IOS_GL
|
||||
}
|
||||
}
|
||||
}.to_string()
|
||||
}
|
||||
|
||||
pub fn create_token() -> String {
|
||||
|
||||
@@ -5,7 +5,7 @@ use crate::encryption;
|
||||
use crate::router::{userdata, global};
|
||||
|
||||
fn get_asset_hash(req: &HttpRequest, body: &JsonValue) -> String {
|
||||
if body["asset_version"] != global::ASSET_VERSION && body["asset_version"] != global::ASSET_VERSION_JP {
|
||||
if body["asset_version"] != global::ASSET_VERSION_GL && body["asset_version"] != global::ASSET_VERSION_JP {
|
||||
println!("Warning! Asset version is not what was expected. (Did the app update?)");
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ use std::fs;
|
||||
lazy_static! {
|
||||
static ref RUNNING: RwLock<bool> = RwLock::new(false);
|
||||
static ref DATAPATH: RwLock<String> = RwLock::new(String::new());
|
||||
static ref EASTER: RwLock<bool> = RwLock::new(false);
|
||||
}
|
||||
|
||||
pub fn set_running(running: bool) {
|
||||
@@ -31,3 +32,13 @@ pub fn update_data_path(path: &str) {
|
||||
let mut w = DATAPATH.write().unwrap();
|
||||
*w = path.to_string();
|
||||
}
|
||||
|
||||
// Only currently editable by the android so
|
||||
pub fn set_easter_mode(enabled: bool) {
|
||||
let mut w = EASTER.write().unwrap();
|
||||
*w = enabled;
|
||||
}
|
||||
|
||||
pub fn get_easter_mode() -> bool {
|
||||
*EASTER.read().unwrap()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user