Merge branch 'main' of https://github.com/Grasscutters/Cultivation into Grasscutters-main

This commit is contained in:
Ffauzan 2022-07-19 11:03:51 +07:00
commit 6d9f1af134
10 changed files with 2661 additions and 2488 deletions

View File

@ -1,4 +1,4 @@
# Cient Patching Notice
# Client Patching Notice
For game versions 2.8 and above, Cultivation automatically makes a small patch to your game client when launching using Grasscutter, and restores it upon closing the game. In theory, you should still be totally safe, however it would be dishonest to not explicitly state that **modifying the game client could, theoretically, lead to a ban if you connect to official servers with it**. It is extremely unlikely AND there are no instances known of it happening, but the possibility exists.
# Cultivation
@ -12,8 +12,12 @@ Please do **NOT install, download, or use pre-compiled versions of Cultivation f
* [Developer Quick-start](#developer-quickstart)
* [Setup](#setup)
* [Building](#building)
* [Troubleshooting](#troubleshooting)
* [Code Formatting and Linting](#code-formatting-and-linting)
* [Generating Update Artifacts](#generating-update-artifacts)
* [Theming](#theming)
* [Screenshots](#screenshots)
* [Credits](#credits)
# Download
[Find release builds here!](https://github.com/Grasscutters/Cultivation/releases)
@ -24,28 +28,28 @@ Once downloaded, extract somewhere and open as administrator.
### Setup
* Install [NodeJS >12](https://nodejs.org/en/)
* Install [yarn](https://classic.yarnpkg.com/lang/en/docs/install/#debian-stable) (cry about it `npm` lovers)
* Install [Cargo](https://doc.rust-lang.org/cargo/getting-started/installation.html) & [Rust compiler](https://www.rust-lang.org/tools/install)
* Install [yarn](https://classic.yarnpkg.com/lang/en/docs/install) (cry about it `npm` lovers)
* Install [Rust](https://www.rust-lang.org/tools/install)
* `yarn install`
* `yarn start:dev`
### Building
`npm run build` or `yarn build`
For a release build,
- `yarn build`
Add `--release` or `--debug` depending on what release you are creating. This defaults to `--release`
For a debug build,
- `yarn build --debug`
### Code Formatting and Linting
- `yarn format`
- `yarn lint`
Format the code with `npm format` or `yarn format`. Run the lints with `npm lint` or `yarn lint`.
### Updating
### Generating Update Artifacts
* Add the `TAURI_PRIVATE_KEY` as an environment variable with a path to your private key.
* Add the `TAURI_KEY_PASSWORD` as an environment variable with the password for your private key.
* Run `npm run update` or `yarn build`
* The update will be in `src-tauri/target/(release|debug)/msi/Cultivation_X.X.X_x64_xx-XX.msi.zip`
* `yarn build`
# Troubleshooting
TODO. Collect common issues before updating.
The update will be at `src-tauri/target/(release|debug)/msi/Cultivation_X.X.X_x64_xx-XX.msi.zip`
# Theming

View File

@ -6,9 +6,9 @@
"@tauri-apps/api": "^1.0.0-rc.5",
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^13.0.0",
"@testing-library/user-event": "^13.2.1",
"@types/jest": "^27.0.1",
"@types/node": "^16.7.13",
"@testing-library/user-event": "^14.2.6",
"@types/jest": "^28.1.6",
"@types/node": "^18.0.6",
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"react": "^18.1.0",

148
src-tauri/Cargo.lock generated
View File

@ -506,9 +506,9 @@ dependencies = [
[[package]]
name = "concurrent-queue"
version = "1.2.2"
version = "1.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30ed07550be01594c6026cff2a1d7fe9c8f683caa798e12b68694ac9e88286a3"
checksum = "83827793632c72fa4f73c2edb31e7a997527dd8ffe7077344621fc62c5478157"
dependencies = [
"cache-padded",
]
@ -657,9 +657,9 @@ dependencies = [
[[package]]
name = "crypto-common"
version = "0.1.4"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5999502d32b9c48d492abe66392408144895020ec4709e549e840799f3bb74c0"
checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
dependencies = [
"generic-array",
"typenum",
@ -721,7 +721,7 @@ dependencies = [
"is_elevated",
"libloading",
"once_cell",
"open 2.1.3",
"open",
"rcgen",
"regex",
"registry",
@ -784,9 +784,9 @@ checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57"
[[package]]
name = "dbus"
version = "0.9.5"
version = "0.9.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de0a745c25b32caa56b82a3950f5fec7893a960f4c10ca3b02060b0c38d8c2ce"
checksum = "6f8bcdd56d2e5c4ed26a529c5a9029f5db8290d433497506f958eae3be148eb6"
dependencies = [
"libc",
"libdbus-sys",
@ -1239,15 +1239,15 @@ dependencies = [
[[package]]
name = "generator"
version = "0.7.0"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1d9279ca822891c1a4dae06d185612cf8fc6acfe5dff37781b41297811b12ee"
checksum = "cc184cace1cea8335047a471cc1da80f18acf8a76f3bab2028d499e328948ec7"
dependencies = [
"cc",
"libc",
"log",
"rustversion",
"winapi",
"windows 0.32.0",
]
[[package]]
@ -1463,9 +1463,9 @@ dependencies = [
[[package]]
name = "hashbrown"
version = "0.12.2"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "607c8a29735385251a339424dd462993c0fed8fa09d378f259377df08c126022"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
[[package]]
name = "heck"
@ -1948,9 +1948,9 @@ checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4"
[[package]]
name = "mac-notification-sys"
version = "0.5.2"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "042f74a606175d72ca483e14e0873fe0f6c003f7af45865b17b16fdaface7203"
checksum = "fff231a88fe2e9985f9d159a2f02986fe46daa0f6af976a0d934be4870cc9d02"
dependencies = [
"cc",
"dirs-next",
@ -2336,19 +2336,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
[[package]]
name = "open"
version = "2.1.3"
version = "3.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2423ffbf445b82e58c3b1543655968923dd06f85432f10be2bb4f1b7122f98c"
dependencies = [
"pathdiff",
"windows-sys",
]
[[package]]
name = "open"
version = "3.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "360bcc8316bf6363aa3954c3ccc4de8add167b087e0259190a043c9514f910fe"
checksum = "f23a407004a1033f53e93f9b45580d14de23928faad187384f891507c9b0c045"
dependencies = [
"pathdiff",
"windows-sys",
@ -2356,9 +2346,9 @@ dependencies = [
[[package]]
name = "openssl"
version = "0.10.40"
version = "0.10.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb81a6430ac911acb25fe5ac8f1d2af1b4ea8a4fdfda0f1ee4292af2e2d8eb0e"
checksum = "618febf65336490dfcf20b73f885f5651a0c89c64c2d4a8c3662585a70bf5bd0"
dependencies = [
"bitflags",
"cfg-if 1.0.0",
@ -2388,9 +2378,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
[[package]]
name = "openssl-sys"
version = "0.9.74"
version = "0.9.75"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "835363342df5fba8354c5b453325b110ffd54044e588c539cf2f20a8014e4cb1"
checksum = "e5f9bd0c2710541a3cda73d6f9ac4f1b240de4ae261065d309dbe73d9dceb42f"
dependencies = [
"autocfg",
"cc",
@ -2546,9 +2536,9 @@ dependencies = [
[[package]]
name = "pem"
version = "1.0.2"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e9a3b09a20e374558580a4914d3b7d89bd61b954a5a5e1dcbea98753addb1947"
checksum = "03c64931a1a212348ec4f3b4362585eca7159d0d09cbdf4a7f74f02173596fd4"
dependencies = [
"base64",
]
@ -2977,9 +2967,9 @@ dependencies = [
[[package]]
name = "rcgen"
version = "0.9.2"
version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7fa2d386df8533b02184941c76ae2e0d0c1d053f5d43339169d80f21275fc5e"
checksum = "6413f3de1edee53342e6138e75b56d32e7bc6e332b3bd62d497b1929d4cfbcdd"
dependencies = [
"pem",
"ring",
@ -3184,9 +3174,9 @@ dependencies = [
[[package]]
name = "rustversion"
version = "1.0.7"
version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0a5f7c728f5d284929a1cccb5bc19884422bfe6ef4d6c409da2c41838983fcf"
checksum = "24c8ad4f0c00e1eb5bc7614d236a7f1300e3dbd76b68cac8e06fb00b015ad8d8"
[[package]]
name = "ryu"
@ -3322,18 +3312,18 @@ dependencies = [
[[package]]
name = "serde"
version = "1.0.138"
version = "1.0.139"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1578c6245786b9d168c5447eeacfb96856573ca56c9d68fdcf394be134882a47"
checksum = "0171ebb889e45aa68b44aee0859b3eede84c6f5f5c228e6f140c0b2a0a46cad6"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.138"
version = "1.0.139"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "023e9b1467aef8a10fb88f25611870ada9800ef7e22afce356bb0d2387b6f27c"
checksum = "dc1d3230c1de7932af58ad8ffbe1d784bd55efd5a9d84ac24f69c72d83543dfb"
dependencies = [
"proc-macro2",
"quote",
@ -3789,9 +3779,9 @@ dependencies = [
[[package]]
name = "tauri"
version = "1.0.3"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d61fc211e0bd2c04c0aecd202d2cd72dd797a89da02989a39e1b9691462386d6"
checksum = "827f61bd3dd40276694be5c7ffc40d65b94ab00d9f8c1a4a4db07f2cdc306c83"
dependencies = [
"anyhow",
"attohttpc",
@ -3810,7 +3800,7 @@ dependencies = [
"notify-rust",
"objc",
"once_cell",
"open 3.0.1",
"open",
"os_info",
"os_pipe 1.0.1",
"percent-encoding",
@ -3842,9 +3832,9 @@ dependencies = [
[[package]]
name = "tauri-build"
version = "1.0.3"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f2b32e551ec810ba4ab2ad735de5e3576e54bf0322ab0f4b7ce41244bc65ecf"
checksum = "acafb1c515c5d14234a294461bd43c723639a84891a45f6a250fd3441ad2e8ed"
dependencies = [
"anyhow",
"cargo_toml",
@ -3858,9 +3848,9 @@ dependencies = [
[[package]]
name = "tauri-codegen"
version = "1.0.3"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6f1f7928dd040fc03c94207adfad506c0cf5b152982fd1dc0a621f7fd777e22"
checksum = "16d62a3c8790d6cba686cea6e3f7f569d12c662c3274c2d165a4fd33e3871b72"
dependencies = [
"base64",
"brotli",
@ -3884,9 +3874,9 @@ dependencies = [
[[package]]
name = "tauri-macros"
version = "1.0.3"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e50b9f52871c088857360319a37472d59f4644f1ed004489599d62831a1b6996"
checksum = "7296fa17996629f43081e1c66d554703900187ed900c5bf46f97f0bcfb069278"
dependencies = [
"heck 0.4.0",
"proc-macro2",
@ -4068,10 +4058,11 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]]
name = "tokio"
version = "1.19.2"
version = "1.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c51a52ed6686dd62c320f9b89299e9dfb46f730c7a48e635c19f21d116cb1439"
checksum = "57aec3cfa4c296db7255446efb4928a6be304b431a806216105542a67b6ca82e"
dependencies = [
"autocfg",
"bytes",
"libc",
"memchr",
@ -4107,9 +4098,9 @@ dependencies = [
[[package]]
name = "tokio-tungstenite"
version = "0.17.1"
version = "0.17.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06cda1232a49558c46f8a504d5b93101d42c0bf7f911f12a105ba48168f821ae"
checksum = "f714dd15bead90401d77e04243611caec13726c2408afd5b31901dfcdcb3b181"
dependencies = [
"futures-util",
"log",
@ -4236,9 +4227,9 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642"
[[package]]
name = "tungstenite"
version = "0.17.2"
version = "0.17.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d96a2dea40e7570482f28eb57afbe42d97551905da6a9400acc5c328d24004f5"
checksum = "e27992fd6a8c29ee7eef28fc78349aa244134e10ad447ce3b9f0ac0ed0fa4ce0"
dependencies = [
"base64",
"byteorder",
@ -4284,9 +4275,9 @@ checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992"
[[package]]
name = "unicode-ident"
version = "1.0.1"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c"
checksum = "15c61ba63f9235225a22310255a29b806b907c9b8c964bcbd0a2c70f3f2deea7"
[[package]]
name = "unicode-normalization"
@ -4690,6 +4681,19 @@ dependencies = [
"windows_x86_64_msvc 0.24.0",
]
[[package]]
name = "windows"
version = "0.32.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbedf6db9096bc2364adce0ae0aa636dcd89f3c3f2cd67947062aaf0ca2a10ec"
dependencies = [
"windows_aarch64_msvc 0.32.0",
"windows_i686_gnu 0.32.0",
"windows_i686_msvc 0.32.0",
"windows_x86_64_gnu 0.32.0",
"windows_x86_64_msvc 0.32.0",
]
[[package]]
name = "windows"
version = "0.37.0"
@ -4749,6 +4753,12 @@ version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3263d25f1170419995b78ff10c06b949e8a986c35c208dc24333c64753a87169"
[[package]]
name = "windows_aarch64_msvc"
version = "0.32.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8e92753b1c443191654ec532f14c199742964a061be25d77d7a96f09db20bf5"
[[package]]
name = "windows_aarch64_msvc"
version = "0.36.1"
@ -4767,6 +4777,12 @@ version = "0.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0866510a3eca9aed73a077490bbbf03e5eaac4e1fd70849d89539e5830501fd"
[[package]]
name = "windows_i686_gnu"
version = "0.32.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a711c68811799e017b6038e0922cb27a5e2f43a2ddb609fe0b6f3eeda9de615"
[[package]]
name = "windows_i686_gnu"
version = "0.36.1"
@ -4785,6 +4801,12 @@ version = "0.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf0ffed56b7e9369a29078d2ab3aaeceea48eb58999d2cff3aa2494a275b95c6"
[[package]]
name = "windows_i686_msvc"
version = "0.32.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "146c11bb1a02615db74680b32a68e2d61f553cc24c4eb5b4ca10311740e44172"
[[package]]
name = "windows_i686_msvc"
version = "0.36.1"
@ -4803,6 +4825,12 @@ version = "0.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "384a173630588044205a2993b6864a2f56e5a8c1e7668c07b93ec18cf4888dc4"
[[package]]
name = "windows_x86_64_gnu"
version = "0.32.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c912b12f7454c6620635bbff3450962753834be2a594819bd5e945af18ec64bc"
[[package]]
name = "windows_x86_64_gnu"
version = "0.36.1"
@ -4821,6 +4849,12 @@ version = "0.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9bd8f062d8ca5446358159d79a90be12c543b3a965c847c8f3eedf14b321d399"
[[package]]
name = "windows_x86_64_msvc"
version = "0.32.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "504a2476202769977a040c6364301a3f65d0cc9e3fb08600b2bda150a0488316"
[[package]]
name = "windows_x86_64_msvc"
version = "0.36.1"

View File

@ -37,7 +37,7 @@ zip = "0.6.2"
once_cell = "1.13.0"
# Program opener.
open = "2.1.2"
open = "3.0.2"
duct = "0.13.5"
# Serialization.

View File

@ -2,17 +2,14 @@ fn main() {
cc::Build::new()
.include("mhycrypto")
.cpp(true)
.file("mhycrypto/memecrypto.cpp")
.file("mhycrypto/metadata.cpp")
.file("mhycrypto/metadatastringdec.cpp")
.compile("mhycrypto");
cc::Build::new()
cc::Build::new()
.include("mhycrypto")
.file("mhycrypto/aes.c")
.compile("mhycrypto-aes");
tauri_build::build()

View File

@ -43,7 +43,7 @@ bool gen_global_metadata_key(uint8_t* src, size_t srcn) {
uint64_t* key = (uint64_t*)src;
for (int i = 0; i < srcn / sizeof(uint64_t); i++)
for (size_t i = 0; i < srcn / sizeof(uint64_t); i++)
key[i] = rand();
*(uint16_t *) (src + 0xc8) = 0xfc2e; // Magic

View File

@ -1,6 +1,6 @@
use std::fs;
use file_diff::diff;
use std::{io::{Read, Write}};
use std::fs;
use std::io::{Read, Write};
#[tauri::command]
pub fn rename(path: String, new_name: String) {
@ -142,7 +142,7 @@ pub fn write_file(path: String, contents: String) {
Ok(file) => file,
Err(e) => {
println!("Failed to open file: {}", e);
// attempt to create file. otherwise return
match fs::File::create(&path_buf) {
Ok(file) => file,
@ -159,7 +159,6 @@ pub fn write_file(path: String, contents: String) {
Ok(_) => (),
Err(e) => {
println!("Failed to write to file: {}", e);
return;
}
}
}

View File

@ -13,12 +13,12 @@ use sysinfo::{System, SystemExt};
mod downloader;
mod file_helpers;
mod lang;
mod metadata_patcher;
mod proxy;
mod structs;
mod system_helpers;
mod unzip;
mod web;
mod metadata_patcher;
static WATCH_GAME_PROCESS: Lazy<Mutex<String>> = Lazy::new(|| Mutex::new(String::new()));
@ -73,7 +73,7 @@ fn is_game_running() -> bool {
}
#[tauri::command]
fn enable_process_watcher(window: tauri::Window,process: String) {
fn enable_process_watcher(window: tauri::Window, process: String) {
*WATCH_GAME_PROCESS.lock().unwrap() = process;
window.listen("disable_process_watcher", |_e| {

View File

@ -4,19 +4,25 @@ use std::fs::OpenOptions;
use std::io::Read;
use std::io::Write;
extern {
fn decrypt_global_metadata(data : *mut u8, size : u64);
fn encrypt_global_metadata(data : *mut u8, size : u64);
extern "C" {
fn decrypt_global_metadata(data: *mut u8, size: u64);
fn encrypt_global_metadata(data: *mut u8, size: u64);
}
fn dll_decrypt_global_metadata(data : *mut u8, size : u64) -> Result<bool, Box<dyn std::error::Error>> {
fn dll_decrypt_global_metadata(
data: *mut u8,
size: u64,
) -> Result<bool, Box<dyn std::error::Error>> {
unsafe {
decrypt_global_metadata(data, size);
Ok(true)
}
}
fn dll_encrypt_global_metadata(data : *mut u8, size : u64) -> Result<bool, Box<dyn std::error::Error>> {
fn dll_encrypt_global_metadata(
data: *mut u8,
size: u64,
) -> Result<bool, Box<dyn std::error::Error>> {
unsafe {
encrypt_global_metadata(data, size);
Ok(true)
@ -46,7 +52,11 @@ pub fn patch_metadata(metadata_folder: &str) -> bool {
}
//write encrypted to file
let mut file = match OpenOptions::new().create(true).write(true).open(&(metadata_folder.to_owned() + "\\global-metadata-patched.dat")) {
let mut file = match OpenOptions::new()
.create(true)
.write(true)
.open(&(metadata_folder.to_owned() + "\\global-metadata-patched.dat"))
{
Ok(file) => file,
Err(e) => {
println!("Failed to open global-metadata: {}", e);
@ -55,7 +65,7 @@ pub fn patch_metadata(metadata_folder: &str) -> bool {
};
file.write_all(&encrypted).unwrap();
true
}
@ -82,13 +92,13 @@ fn decrypt_metadata(file_path: &str) -> Vec<u8> {
match dll_decrypt_global_metadata(data.as_mut_ptr(), data.len().try_into().unwrap()) {
Ok(_) => {
println!("Successfully decrypted global-metadata");
return data;
data
}
Err(e) => {
println!("Failed to decrypt global-metadata: {}", e);
return Vec::new();
Vec::new()
}
};
}
}
fn replace_keys(data: &[u8]) -> Vec<u8> {
@ -143,16 +153,16 @@ fn encrypt_metadata(old_data: &[u8]) -> Vec<u8> {
match dll_encrypt_global_metadata(data.as_mut_ptr(), data.len().try_into().unwrap()) {
Ok(_) => {
println!("Successfully encrypted global-metadata");
return data;
data
}
Err(e) => {
println!("Failed to encrypt global-metadata: {}", e);
return Vec::new();
Vec::new()
}
};
}
}
fn do_vecs_match<T: PartialEq>(a: &Vec<T>, b: &Vec<T>) -> bool {
let matching = a.iter().zip(b.iter()).filter(|&(a, b)| a == b).count();
matching == a.len() && matching == b.len()
}
}

4907
yarn.lock

File diff suppressed because it is too large Load Diff