From 28c3721ecf56573541e4b56aaf1078fe133409f0 Mon Sep 17 00:00:00 2001 From: Christof Petig Date: Sun, 18 Jun 2023 17:23:31 +0200 Subject: [PATCH] upgrade wasmer, implement basic WASI, turn off login events for now --- .gitignore | 3 + .gitlab/scripts/plugin.sh | 2 + Cargo.lock | 560 +++++++++++++--------- common/Cargo.toml | 1 - common/src/combat.rs | 55 +-- common/src/comp/buff.rs | 11 - common/src/comp/fluid_dynamics.rs | 8 +- common/src/comp/health.rs | 17 +- common/src/comp/mod.rs | 57 +-- common/src/lib.rs | 104 ++-- common/src/resources.rs | 5 - common/src/uid.rs | 335 +++++++------ common/state/Cargo.toml | 3 +- common/state/src/plugin/errors.rs | 4 +- common/state/src/plugin/exports.rs | 125 +++++ common/state/src/plugin/memory_manager.rs | 181 +++---- common/state/src/plugin/mod.rs | 17 +- common/state/src/plugin/module.rs | 182 ++++--- common/state/src/plugin/wasm_env.rs | 114 +++-- common/state/src/state.rs | 2 +- server/src/lib.rs | 2 +- server/src/login_provider.rs | 57 +-- server/src/sys/msg/register.rs | 30 +- 23 files changed, 1079 insertions(+), 796 deletions(-) create mode 100755 .gitlab/scripts/plugin.sh create mode 100644 common/state/src/plugin/exports.rs diff --git a/.gitignore b/.gitignore index 3bc13c3292..8d269ace87 100644 --- a/.gitignore +++ b/.gitignore @@ -75,3 +75,6 @@ nix/result* # Bash .history + +# Plugins +/assets/plugins/* diff --git a/.gitlab/scripts/plugin.sh b/.gitlab/scripts/plugin.sh new file mode 100755 index 0000000000..f9fbf52e65 --- /dev/null +++ b/.gitlab/scripts/plugin.sh @@ -0,0 +1,2 @@ +#!/bin/bash +time cargo build --release --example=hello --target=wasm32-wasi diff --git a/Cargo.lock b/Cargo.lock index 81d68adace..cfcf297ab5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -400,7 +400,7 @@ dependencies = [ "cfg-if 1.0.0", "libc", "miniz_oxide 0.6.2", - "object 0.30.3", + "object", "rustc-demangle", ] @@ -767,7 +767,7 @@ version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9644cd56d6b87dbe899ef8b053e331c0637664e9e21a33dfcdc36093f5c5c4" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2 1.0.56", "quote 1.0.26", "syn 2.0.15", @@ -950,6 +950,12 @@ name = "conrod_winit" version = "0.63.0" source = "git+https://gitlab.com/veloren/conrod.git?branch=copypasta_0.7#59fddc617696e68d28a75c2137a08c2572efb986" +[[package]] +name = "const_fn" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbdcdcb6d86f71c5e97409ad45898af11cbc995b4ee8112d59095a28d376c935" + [[package]] name = "constant_time_eq" version = "0.1.5" @@ -1159,56 +1165,74 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.82.3" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38faa2a16616c8e78a18d37b4726b98bfd2de192f2fdc8a39ddf568a408a0f75" +checksum = "2a2ab4512dfd3a6f4be184403a195f76e81a8a9f9e6c898e19d2dc3ce20e0115" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.82.3" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26f192472a3ba23860afd07d2b0217dc628f21fcc72617aa1336d98e1671f33b" +checksum = "98b022ed2a5913a38839dfbafe6cf135342661293b08049843362df4301261dc" dependencies = [ + "arrayvec 0.7.2", + "bumpalo", "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", + "cranelift-egraph", "cranelift-entity", + "cranelift-isle", "gimli 0.26.2", "log", - "regalloc", + "regalloc2", "smallvec", "target-lexicon", ] [[package]] name = "cranelift-codegen-meta" -version = "0.82.3" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f32ddb89e9b89d3d9b36a5b7d7ea3261c98235a76ac95ba46826b8ec40b1a24" +checksum = "639307b45434ad112a98f8300c0f0ab085cbefcd767efcdef9ef19d4c0756e74" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.82.3" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01fd0d9f288cc1b42d9333b7a776b17e278fc888c28e6a0f09b5573d45a150bc" +checksum = "278e52e29c53fcf32431ef08406c295699a70306d05a0715c5b1bf50e33a9ab7" + +[[package]] +name = "cranelift-egraph" +version = "0.91.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624b54323b06e675293939311943ba82d323bb340468ce1889be5da7932c8d73" +dependencies = [ + "cranelift-entity", + "fxhash", + "hashbrown 0.12.3", + "indexmap", + "log", + "smallvec", +] [[package]] name = "cranelift-entity" -version = "0.82.3" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e3bfe172b83167604601faf9dc60453e0d0a93415b57a9c4d1a7ae6849185cf" +checksum = "9a59bcbca89c3f1b70b93ab3cbba5e5e0cbf3e63dadb23c7525cb142e21a9d4c" [[package]] name = "cranelift-frontend" -version = "0.82.3" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a006e3e32d80ce0e4ba7f1f9ddf66066d052a8c884a110b91d05404d6ce26dce" +checksum = "0d70abacb8cfef3dc8ff7e8836e9c1d70f7967dfdac824a4cd5e30223415aca6" dependencies = [ "cranelift-codegen", "log", @@ -1216,6 +1240,12 @@ dependencies = [ "target-lexicon", ] +[[package]] +name = "cranelift-isle" +version = "0.91.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "393bc73c451830ff8dbb3a07f61843d6cb41a084f9996319917c0b291ed785bb" + [[package]] name = "crc32fast" version = "1.3.2" @@ -1637,6 +1667,19 @@ dependencies = [ "syn 2.0.15", ] +[[package]] +name = "dashmap" +version = "5.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "907076dfda823b0b36d2a1bb5f90c96660a5bbcd7729e10727f07858f22c4edc" +dependencies = [ + "cfg-if 1.0.0", + "hashbrown 0.12.3", + "lock_api 0.4.9", + "once_cell", + "parking_lot_core 0.9.7", +] + [[package]] name = "deflate" version = "1.0.0" @@ -1646,6 +1689,17 @@ dependencies = [ "adler32", ] +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2 1.0.56", + "quote 1.0.26", + "syn 1.0.109", +] + [[package]] name = "deunicode" version = "1.3.3" @@ -1738,7 +1792,7 @@ dependencies = [ "serde_json", "serde_repr", "thiserror", - "time", + "time 0.3.20", "tokio", "tracing", "url", @@ -2735,15 +2789,6 @@ dependencies = [ "ahash 0.4.7", ] -[[package]] -name = "hashbrown" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" -dependencies = [ - "ahash 0.7.6", -] - [[package]] name = "hashbrown" version = "0.12.3" @@ -2786,6 +2831,15 @@ dependencies = [ "stable_deref_trait", ] +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "heck" version = "0.4.1" @@ -3009,6 +3063,12 @@ dependencies = [ "winit", ] +[[package]] +name = "id-arena" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" + [[package]] name = "ident_case" version = "1.0.1" @@ -3049,7 +3109,6 @@ dependencies = [ "autocfg", "hashbrown 0.12.3", "rayon", - "serde", ] [[package]] @@ -3469,27 +3528,6 @@ dependencies = [ "tracing-subscriber", ] -[[package]] -name = "loupe" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b6a72dfa44fe15b5e76b94307eeb2ff995a8c5b283b55008940c02e0c5b634d" -dependencies = [ - "indexmap", - "loupe-derive", - "rustversion", -] - -[[package]] -name = "loupe-derive" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0fbfc88337168279f2e9ae06e157cfed4efd3316e14dc96ed074d4f2e6c5952" -dependencies = [ - "quote 1.0.26", - "syn 1.0.109", -] - [[package]] name = "lz-fear" version = "0.1.1" @@ -4244,18 +4282,6 @@ dependencies = [ "objc", ] -[[package]] -name = "object" -version = "0.28.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e42c982f2d955fac81dd7e1d0e1426a7d702acd9c98d19ab01083a6a0328c424" -dependencies = [ - "crc32fast", - "hashbrown 0.11.2", - "indexmap", - "memchr", -] - [[package]] name = "object" version = "0.30.3" @@ -4730,7 +4756,7 @@ version = "0.4.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" dependencies = [ - "unicode-xid", + "unicode-xid 0.1.0", ] [[package]] @@ -4817,6 +4843,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "pulldown-cmark" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffade02495f22453cd593159ea2f59827aae7f53fa8323f756799b670881dcf8" +dependencies = [ + "bitflags 1.3.2", + "memchr", + "unicase", +] + [[package]] name = "quick-xml" version = "0.28.2" @@ -5063,7 +5100,7 @@ checksum = "ffbe84efe2f38dea12e9bfc1f65377fdf03e53a18cb3b995faedf7934c7e785b" dependencies = [ "pem", "ring", - "time", + "time 0.3.20", "yasna", ] @@ -5127,7 +5164,7 @@ dependencies = [ "serde", "siphasher", "thiserror", - "time", + "time 0.3.20", "toml 0.7.3", "url", "walkdir 2.3.3", @@ -5147,13 +5184,14 @@ dependencies = [ ] [[package]] -name = "regalloc" -version = "0.0.34" +name = "regalloc2" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62446b1d3ebf980bdc68837700af1d77b37bc430e524bf95319c6eada2a4cc02" +checksum = "300d4fbfb40c1c66a78ba3ddd41c1110247cf52f97b87d0f2fc9209bd49b030c" dependencies = [ + "fxhash", "log", - "rustc-hash", + "slice-group-by", "smallvec", ] @@ -5239,6 +5277,7 @@ checksum = "21499ed91807f07ae081880aabb2ccc0235e9d88011867d984525e9a4c3cfa3e" dependencies = [ "bytecheck", "hashbrown 0.12.3", + "indexmap", "ptr_meta", "rend", "rkyv_derive", @@ -5708,12 +5747,14 @@ dependencies = [ ] [[package]] -name = "serde_bytes" -version = "0.11.9" +name = "serde-wasm-bindgen" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "416bda436f9aab92e02c8e10d49a15ddd339cea90b6e340fe51ed97abb548294" +checksum = "e3b4c031cd0d9014307d82b8abf653c0290fbdaeb4c02d00c63cf52f728628bf" dependencies = [ + "js-sys", "serde", + "wasm-bindgen", ] [[package]] @@ -5943,6 +5984,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "slice-group-by" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" + [[package]] name = "slotmap" version = "0.4.3" @@ -6126,6 +6173,15 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "standback" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e113fb6f3de07a243d434a56ec6f186dfd51cb08448239fe7bcae73f87ff28ff" +dependencies = [ + "version_check", +] + [[package]] name = "static_assertions" version = "1.1.0" @@ -6238,7 +6294,7 @@ version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2 1.0.56", "quote 1.0.26", "rustversion", @@ -6265,7 +6321,7 @@ checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" dependencies = [ "proc-macro2 0.4.30", "quote 0.6.13", - "unicode-xid", + "unicode-xid 0.1.0", ] [[package]] @@ -6380,6 +6436,21 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f685624f172cd0bde6f3363412455e81c018f2379fdf5a218e0be003f1bba642" +[[package]] +name = "time" +version = "0.2.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4752a97f8eebd6854ff91f1c1824cd6160626ac4bd44287f7f4ea2035a02a242" +dependencies = [ + "const_fn", + "libc", + "standback", + "stdweb 0.4.20", + "time-macros 0.1.1", + "version_check", + "winapi 0.3.9", +] + [[package]] name = "time" version = "0.3.20" @@ -6389,7 +6460,7 @@ dependencies = [ "itoa", "serde", "time-core", - "time-macros", + "time-macros 0.2.8", ] [[package]] @@ -6398,6 +6469,16 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" +[[package]] +name = "time-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "957e9c6e26f12cb6d0dd7fc776bb67a706312e7299aed74c8dd5b17ebb27e2f1" +dependencies = [ + "proc-macro-hack", + "time-macros-impl", +] + [[package]] name = "time-macros" version = "0.2.8" @@ -6407,6 +6488,19 @@ dependencies = [ "time-core", ] +[[package]] +name = "time-macros-impl" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd3c141a1b43194f3f56a1411225df8646c55781d5f26db825b3d98507eb482f" +dependencies = [ + "proc-macro-hack", + "proc-macro2 1.0.56", + "quote 1.0.26", + "standback", + "syn 1.0.109", +] + [[package]] name = "timer-queue" version = "0.1.0" @@ -6571,7 +6665,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if 1.0.0", - "log", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -6584,7 +6677,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09d48f71a791638519505cefafe162606f706c25592e4bde4d97600c0195312e" dependencies = [ "crossbeam-channel", - "time", + "time 0.3.20", "tracing-subscriber", ] @@ -6633,7 +6726,7 @@ dependencies = [ "sharded-slab", "smallvec", "thread_local", - "time", + "time 0.3.20", "tracing", "tracing-core", "tracing-log", @@ -6722,7 +6815,7 @@ version = "1.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "rand 0.8.5", "static_assertions", ] @@ -6769,6 +6862,15 @@ dependencies = [ "tinystr", ] +[[package]] +name = "unicase" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" +dependencies = [ + "version_check", +] + [[package]] name = "unicode-bidi" version = "0.3.13" @@ -6808,6 +6910,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + [[package]] name = "untrusted" version = "0.7.1" @@ -7088,6 +7196,7 @@ dependencies = [ "veloren-common-net", "veloren-plugin-api", "wasmer", + "wasmer-wasix-types", ] [[package]] @@ -7488,6 +7597,72 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "wai-bindgen-gen-core" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aa3dc41b510811122b3088197234c27e08fcad63ef936306dd8e11e2803876c" +dependencies = [ + "anyhow", + "wai-parser", +] + +[[package]] +name = "wai-bindgen-gen-rust" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19bc05e8380515c4337c40ef03b2ff233e391315b178a320de8640703d522efe" +dependencies = [ + "heck 0.3.3", + "wai-bindgen-gen-core", +] + +[[package]] +name = "wai-bindgen-gen-rust-wasm" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6f35ce5e74086fac87f3a7bd50f643f00fe3559adb75c88521ecaa01c8a6199" +dependencies = [ + "heck 0.3.3", + "wai-bindgen-gen-core", + "wai-bindgen-gen-rust", +] + +[[package]] +name = "wai-bindgen-rust" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e5601c6f448c063e83a5e931b8fefcdf7e01ada424ad42372c948d2e3d67741" +dependencies = [ + "bitflags 1.3.2", + "wai-bindgen-rust-impl", +] + +[[package]] +name = "wai-bindgen-rust-impl" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdeeb5c1170246de8425a3e123e7ef260dc05ba2b522a1d369fe2315376efea4" +dependencies = [ + "proc-macro2 1.0.56", + "syn 1.0.109", + "wai-bindgen-gen-core", + "wai-bindgen-gen-rust-wasm", +] + +[[package]] +name = "wai-parser" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bd0acb6d70885ea0c343749019ba74f015f64a9d30542e66db69b49b7e28186" +dependencies = [ + "anyhow", + "id-arena", + "pulldown-cmark", + "unicode-normalization", + "unicode-xid 0.2.4", +] + [[package]] name = "walkdir" version = "0.1.8" @@ -7555,6 +7730,29 @@ dependencies = [ "wasm-bindgen-shared", ] +[[package]] +name = "wasm-bindgen-downcast" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dac026d43bcca6e7ce1c0956ba68f59edf6403e8e930a5d891be72c31a44340" +dependencies = [ + "js-sys", + "once_cell", + "wasm-bindgen", + "wasm-bindgen-downcast-macros", +] + +[[package]] +name = "wasm-bindgen-downcast-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5020cfa87c7cecefef118055d44e3c1fc122c7ec25701d528ee458a0b45f38f" +dependencies = [ + "proc-macro2 1.0.56", + "quote 1.0.26", + "syn 1.0.109", +] + [[package]] name = "wasm-bindgen-futures" version = "0.4.34" @@ -7607,73 +7805,65 @@ dependencies = [ [[package]] name = "wasmer" -version = "2.3.0" +version = "4.0.0-beta.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea8d8361c9d006ea3d7797de7bd6b1492ffd0f91a22430cfda6c1658ad57bedf" +checksum = "d924829e1d14ca3b0ab2562ef7c958fd61ec3fdc6401fd09f20becf59c1f1d17" dependencies = [ + "bytes", "cfg-if 1.0.0", + "derivative", "indexmap", "js-sys", - "loupe", "more-asserts", + "rustc-demangle", + "serde", + "serde-wasm-bindgen", "target-lexicon", "thiserror", "wasm-bindgen", - "wasmer-artifact", + "wasm-bindgen-downcast", "wasmer-compiler", "wasmer-compiler-cranelift", "wasmer-derive", - "wasmer-engine", - "wasmer-engine-dylib", - "wasmer-engine-universal", "wasmer-types", "wasmer-vm", "wat", "winapi 0.3.9", ] -[[package]] -name = "wasmer-artifact" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7aaf9428c29c1d8ad2ac0e45889ba8a568a835e33fd058964e5e500f2f7ce325" -dependencies = [ - "enumset", - "loupe", - "thiserror", - "wasmer-compiler", - "wasmer-types", -] - [[package]] name = "wasmer-compiler" -version = "2.3.0" +version = "4.0.0-beta.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e67a6cd866aed456656db2cfea96c18baabbd33f676578482b85c51e1ee19d2c" +checksum = "945e8cd172c68cf10fefcd40f9c97bd301ecc9bf0136972bf807474f1b5951de" dependencies = [ + "backtrace", + "cfg-if 1.0.0", + "enum-iterator 0.7.0", "enumset", - "loupe", - "rkyv", - "serde", - "serde_bytes", + "lazy_static", + "leb128", + "memmap2 0.5.10", + "more-asserts", + "region", "smallvec", - "target-lexicon", "thiserror", "wasmer-types", + "wasmer-vm", "wasmparser", + "winapi 0.3.9", ] [[package]] name = "wasmer-compiler-cranelift" -version = "2.3.0" +version = "4.0.0-beta.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48be2f9f6495f08649e4f8b946a2cbbe119faf5a654aa1457f9504a99d23dae0" +checksum = "cdce36e48ec8c70e34d150073d6214e52757474bb375c013f2ae0bac85800cce" dependencies = [ "cranelift-codegen", "cranelift-entity", "cranelift-frontend", "gimli 0.26.2", - "loupe", "more-asserts", "rayon", "smallvec", @@ -7685,9 +7875,9 @@ dependencies = [ [[package]] name = "wasmer-derive" -version = "2.3.0" +version = "4.0.0-beta.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00e50405cc2a2f74ff574584710a5f2c1d5c93744acce2ca0866084739284b51" +checksum = "90277df86705920fefed23c2724ed652fa974af788f0983ca0493b51691a76bd" dependencies = [ "proc-macro-error", "proc-macro2 1.0.56", @@ -7695,152 +7885,80 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "wasmer-engine" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f98f010978c244db431b392aeab0661df7ea0822343334f8f2a920763548e45" -dependencies = [ - "backtrace", - "enumset", - "lazy_static", - "loupe", - "memmap2 0.5.10", - "more-asserts", - "rustc-demangle", - "serde", - "serde_bytes", - "target-lexicon", - "thiserror", - "wasmer-artifact", - "wasmer-compiler", - "wasmer-types", - "wasmer-vm", -] - -[[package]] -name = "wasmer-engine-dylib" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0358af9c154724587731175553805648d9acb8f6657880d165e378672b7e53" -dependencies = [ - "cfg-if 1.0.0", - "enum-iterator 0.7.0", - "enumset", - "leb128", - "libloading 0.7.4", - "loupe", - "object 0.28.4", - "rkyv", - "serde", - "tempfile", - "tracing", - "wasmer-artifact", - "wasmer-compiler", - "wasmer-engine", - "wasmer-object", - "wasmer-types", - "wasmer-vm", - "which", -] - -[[package]] -name = "wasmer-engine-universal" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "440dc3d93c9ca47865a4f4edd037ea81bf983b5796b59b3d712d844b32dbef15" -dependencies = [ - "cfg-if 1.0.0", - "enumset", - "leb128", - "loupe", - "region", - "rkyv", - "wasmer-compiler", - "wasmer-engine", - "wasmer-engine-universal-artifact", - "wasmer-types", - "wasmer-vm", - "winapi 0.3.9", -] - -[[package]] -name = "wasmer-engine-universal-artifact" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f1db3f54152657eb6e86c44b66525ff7801dad8328fe677da48dd06af9ad41" -dependencies = [ - "enum-iterator 0.7.0", - "enumset", - "loupe", - "rkyv", - "thiserror", - "wasmer-artifact", - "wasmer-compiler", - "wasmer-types", -] - -[[package]] -name = "wasmer-object" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d831335ff3a44ecf451303f6f891175c642488036b92ceceb24ac8623a8fa8b" -dependencies = [ - "object 0.28.4", - "thiserror", - "wasmer-compiler", - "wasmer-types", -] - [[package]] name = "wasmer-types" -version = "2.3.0" +version = "4.0.0-beta.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39df01ea05dc0a9bab67e054c7cb01521e53b35a7bb90bd02eca564ed0b2667f" +checksum = "918344b93266cf4efe56e6cd23f35c7325275524f534678145f7ead4b2b8c762" dependencies = [ - "backtrace", + "bytecheck", "enum-iterator 0.7.0", + "enumset", "indexmap", - "loupe", "more-asserts", "rkyv", - "serde", + "target-lexicon", "thiserror", ] [[package]] name = "wasmer-vm" -version = "2.3.0" +version = "4.0.0-beta.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30d965fa61f4dc4cdb35a54daaf7ecec3563fbb94154a6c35433f879466247dd" +checksum = "4e36cba570e0b2662ff52d40fe9a48fd368f6eb35183a84ce43f79bc51b9fd15" dependencies = [ "backtrace", "cc", "cfg-if 1.0.0", "corosensei", + "dashmap", + "derivative", "enum-iterator 0.7.0", + "fnv", "indexmap", "lazy_static", "libc", - "loupe", "mach", - "memoffset 0.6.5", + "memoffset 0.8.0", "more-asserts", "region", - "rkyv", "scopeguard", - "serde", "thiserror", - "wasmer-artifact", "wasmer-types", "winapi 0.3.9", ] [[package]] -name = "wasmparser" -version = "0.83.0" +name = "wasmer-wasix-types" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "718ed7c55c2add6548cca3ddd6383d738cd73b892df400e96b9aa876f0141d7a" +checksum = "13597c9c4febf4a6b0f36a8c76d17f90a6be7f65bc4667472a50a93121a6f2c5" +dependencies = [ + "anyhow", + "bitflags 1.3.2", + "byteorder", + "cfg-if 1.0.0", + "num_enum", + "time 0.2.27", + "wai-bindgen-gen-core", + "wai-bindgen-gen-rust", + "wai-bindgen-gen-rust-wasm", + "wai-bindgen-rust", + "wai-parser", + "wasmer", + "wasmer-derive", + "wasmer-types", +] + +[[package]] +name = "wasmparser" +version = "0.95.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2ea896273ea99b15132414be1da01ab0d8836415083298ecaffbe308eaac87a" +dependencies = [ + "indexmap", + "url", +] [[package]] name = "wast" @@ -8652,5 +8770,5 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e17bb3549cc1321ae1296b9cdc2698e2b6cb1992adfa19a8c72e5b7a738f44cd" dependencies = [ - "time", + "time 0.3.20", ] diff --git a/common/Cargo.toml b/common/Cargo.toml index 58d4452d4b..8e424fbce5 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -38,7 +38,6 @@ sha2 = "0.10" # Strum strum = { workspace = true } -[target.'cfg(not(target_arch = "wasm32"))'.dependencies] approx = "0.4.0" crossbeam-utils = { workspace = true } crossbeam-channel = { workspace = true } diff --git a/common/src/combat.rs b/common/src/combat.rs index 5edcbd8bd4..f86d53c693 100644 --- a/common/src/combat.rs +++ b/common/src/combat.rs @@ -1,8 +1,7 @@ -use crate::comp::buff::{Buff, BuffChange, BuffData, BuffKind, BuffSource}; -#[cfg(not(target_arch = "wasm32"))] use crate::{ comp::{ ability::Capability, + buff::{Buff, BuffChange, BuffData, BuffKind, BuffSource}, inventory::{ item::{ armor::Protection, @@ -12,29 +11,22 @@ use crate::{ slot::EquipSlot, }, skillset::SkillGroupKind, - Alignment, Body, Buffs, CharacterState, Combo, Energy, Health, HealthChange, Inventory, - Ori, Player, Poise, PoiseChange, SkillSet, Stats, + Alignment, Body, Buffs, CharacterState, Combo, Energy, Group, Health, HealthChange, + Inventory, Ori, Player, Poise, PoiseChange, SkillSet, Stats, }, event::ServerEvent, outcome::Outcome, - resources::Secs, + resources::{Secs, Time}, states::utils::StageSection, uid::{IdMaps, Uid}, util::Dir, }; - +use rand::Rng; use serde::{Deserialize, Serialize}; +use specs::{Entity as EcsEntity, ReadStorage}; +use std::ops::{Mul, MulAssign}; +use vek::*; -use crate::{comp::Group, resources::Time}; -#[cfg(not(target_arch = "wasm32"))] -use { - rand::Rng, - specs::{Entity as EcsEntity, ReadStorage}, - std::ops::{Mul, MulAssign}, - vek::*, -}; - -#[cfg(not(target_arch = "wasm32"))] #[derive(Copy, Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] pub enum GroupTarget { InGroup, @@ -51,7 +43,6 @@ pub enum AttackSource { Explosion, } -#[cfg(not(target_arch = "wasm32"))] #[derive(Copy, Clone)] pub struct AttackerInfo<'a> { pub entity: EcsEntity, @@ -63,7 +54,6 @@ pub struct AttackerInfo<'a> { pub stats: Option<&'a Stats>, } -#[cfg(not(target_arch = "wasm32"))] pub struct TargetInfo<'a> { pub entity: EcsEntity, pub uid: Uid, @@ -84,7 +74,6 @@ pub struct AttackOptions { pub target_group: GroupTarget, } -#[cfg(not(target_arch = "wasm32"))] #[derive(Clone, Debug, Serialize, Deserialize)] // TODO: Yeet clone derive pub struct Attack { damages: Vec, @@ -93,7 +82,6 @@ pub struct Attack { crit_multiplier: f32, } -#[cfg(not(target_arch = "wasm32"))] impl Default for Attack { fn default() -> Self { Self { @@ -105,7 +93,6 @@ impl Default for Attack { } } -#[cfg(not(target_arch = "wasm32"))] impl Attack { #[must_use] pub fn with_damage(mut self, damage: AttackDamage) -> Self { @@ -752,7 +739,6 @@ pub fn may_harm( .map_or(true, |(a, t)| a.may_harm(t)) } -#[cfg(not(target_arch = "wasm32"))] #[derive(Clone, Debug, Serialize, Deserialize)] pub struct AttackDamage { damage: Damage, @@ -762,7 +748,6 @@ pub struct AttackDamage { instance: u64, } -#[cfg(not(target_arch = "wasm32"))] impl AttackDamage { pub fn new(damage: Damage, target: Option, instance: u64) -> Self { Self { @@ -780,7 +765,6 @@ impl AttackDamage { } } -#[cfg(not(target_arch = "wasm32"))] #[derive(Clone, Debug, Serialize, Deserialize)] pub struct AttackEffect { target: Option, @@ -788,7 +772,6 @@ pub struct AttackEffect { requirements: Vec, } -#[cfg(not(target_arch = "wasm32"))] impl AttackEffect { pub fn new(target: Option, effect: CombatEffect) -> Self { Self { @@ -807,7 +790,6 @@ impl AttackEffect { pub fn effect(&self) -> &CombatEffect { &self.effect } } -#[cfg(not(target_arch = "wasm32"))] #[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq)] pub enum CombatEffect { Heal(f32), @@ -882,7 +864,6 @@ impl CombatEffect { } } -#[cfg(not(target_arch = "wasm32"))] #[derive(Clone, Debug, Serialize, Deserialize)] pub enum CombatRequirement { AnyDamage, @@ -968,7 +949,6 @@ const PIERCING_PENETRATION_FRACTION: f32 = 1.5; const SLASHING_ENERGY_FRACTION: f32 = 0.5; const CRUSHING_POISE_FRACTION: f32 = 1.0; -#[cfg(not(target_arch = "wasm32"))] #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct Damage { pub source: DamageSource, @@ -976,7 +956,6 @@ pub struct Damage { pub value: f32, } -#[cfg(not(target_arch = "wasm32"))] impl Damage { /// Returns the total damage reduction provided by all equipped items pub fn compute_damage_reduction( @@ -1081,14 +1060,12 @@ impl Damage { } } -#[cfg(not(target_arch = "wasm32"))] #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct Knockback { pub direction: KnockbackDir, pub strength: f32, } -#[cfg(not(target_arch = "wasm32"))] #[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum KnockbackDir { Away, @@ -1097,7 +1074,6 @@ pub enum KnockbackDir { TowardsUp, } -#[cfg(not(target_arch = "wasm32"))] impl Knockback { pub fn calculate_impulse(self, dir: Dir, char_state: Option<&CharacterState>) -> Vec3 { let from_char = { @@ -1128,7 +1104,6 @@ impl Knockback { } } -#[cfg(not(target_arch = "wasm32"))] #[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq)] pub struct CombatBuff { pub kind: BuffKind, @@ -1137,14 +1112,12 @@ pub struct CombatBuff { pub chance: f32, } -#[cfg(not(target_arch = "wasm32"))] #[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq)] pub enum CombatBuffStrength { DamageFraction(f32), Value(f32), } -#[cfg(not(target_arch = "wasm32"))] impl CombatBuffStrength { fn to_strength(self, damage: f32, strength_modifier: f32) -> f32 { match self { @@ -1170,7 +1143,6 @@ impl Mul for CombatBuffStrength { } } -#[cfg(not(target_arch = "wasm32"))] impl CombatBuff { fn to_buff( self, @@ -1203,7 +1175,6 @@ impl CombatBuff { } } -#[cfg(not(target_arch = "wasm32"))] pub fn get_weapon_kinds(inv: &Inventory) -> (Option, Option) { ( inv.equipped(EquipSlot::ActiveMainhand).and_then(|i| { @@ -1223,7 +1194,6 @@ pub fn get_weapon_kinds(inv: &Inventory) -> (Option, Option) ) } -#[cfg(not(target_arch = "wasm32"))] // TODO: Either remove msm or use it as argument in fn kind fn weapon_rating(item: &T, _msm: &MaterialStatManifest) -> f32 { const POWER_WEIGHT: f32 = 2.0; @@ -1265,7 +1235,6 @@ fn weapon_rating(item: &T, _msm: &MaterialStatManifest) -> f32 { rating.max(0.0) } -#[cfg(not(target_arch = "wasm32"))] fn weapon_skills(inventory: &Inventory, skill_set: &SkillSet) -> f32 { let (mainhand, offhand) = get_weapon_kinds(inventory); let mainhand_skills = if let Some(tool) = mainhand { @@ -1281,7 +1250,6 @@ fn weapon_skills(inventory: &Inventory, skill_set: &SkillSet) -> f32 { mainhand_skills.max(offhand_skills) } -#[cfg(not(target_arch = "wasm32"))] fn get_weapon_rating(inventory: &Inventory, msm: &MaterialStatManifest) -> f32 { let mainhand_rating = if let Some(item) = inventory.equipped(EquipSlot::ActiveMainhand) { weapon_rating(item, msm) @@ -1298,7 +1266,6 @@ fn get_weapon_rating(inventory: &Inventory, msm: &MaterialStatManifest) -> f32 { mainhand_rating.max(offhand_rating) } -#[cfg(not(target_arch = "wasm32"))] pub fn combat_rating( inventory: &Inventory, health: &Health, @@ -1359,7 +1326,6 @@ pub fn combat_rating( combined_rating * body.combat_multiplier() } -#[cfg(not(target_arch = "wasm32"))] pub fn compute_crit_mult(inventory: Option<&Inventory>, msm: &MaterialStatManifest) -> f32 { // Starts with a value of 1.25 when summing the stats from each armor piece, and // defaults to a value of 1.25 if no inventory is equipped @@ -1379,7 +1345,6 @@ pub fn compute_crit_mult(inventory: Option<&Inventory>, msm: &MaterialStatManife } /// Computes the energy reward modifier from worn armor -#[cfg(not(target_arch = "wasm32"))] pub fn compute_energy_reward_mod(inventory: Option<&Inventory>, msm: &MaterialStatManifest) -> f32 { // Starts with a value of 1.0 when summing the stats from each armor piece, and // defaults to a value of 1.0 if no inventory is present @@ -1400,7 +1365,6 @@ pub fn compute_energy_reward_mod(inventory: Option<&Inventory>, msm: &MaterialSt /// Computes the additive modifier that should be applied to max energy from the /// currently equipped items -#[cfg(not(target_arch = "wasm32"))] pub fn compute_max_energy_mod(inventory: Option<&Inventory>, msm: &MaterialStatManifest) -> f32 { // Defaults to a value of 0 if no inventory is present inventory.map_or(0.0, |inv| { @@ -1420,7 +1384,6 @@ pub fn compute_max_energy_mod(inventory: Option<&Inventory>, msm: &MaterialStatM /// Returns a value to be included as a multiplicative factor in perception /// distance checks. -#[cfg(not(target_arch = "wasm32"))] pub fn perception_dist_multiplier_from_stealth( inventory: Option<&Inventory>, character_state: Option<&CharacterState>, @@ -1436,7 +1399,6 @@ pub fn perception_dist_multiplier_from_stealth( multiplier.clamp(0.0, 1.0) } -#[cfg(not(target_arch = "wasm32"))] pub fn stealth_multiplier_from_items( inventory: Option<&Inventory>, msm: &MaterialStatManifest, @@ -1459,7 +1421,6 @@ pub fn stealth_multiplier_from_items( /// Computes the total protection provided from armor. Is used to determine the /// damage reduction applied to damage received by an entity None indicates that /// the armor equipped makes the entity invulnerable -#[cfg(not(target_arch = "wasm32"))] pub fn compute_protection( inventory: Option<&Inventory>, msm: &MaterialStatManifest, diff --git a/common/src/comp/buff.rs b/common/src/comp/buff.rs index a138af295a..dec7d0050b 100644 --- a/common/src/comp/buff.rs +++ b/common/src/comp/buff.rs @@ -7,11 +7,9 @@ use crate::{ }; use core::cmp::Ordering; -#[cfg(not(target_arch = "wasm32"))] use hashbrown::HashMap; use itertools::Either; use serde::{Deserialize, Serialize}; -#[cfg(not(target_arch = "wasm32"))] use specs::{Component, DerefFlaggedStorage, VecStorage}; use strum::EnumIter; @@ -121,7 +119,6 @@ pub enum BuffKind { Lifesteal, } -#[cfg(not(target_arch = "wasm32"))] impl BuffKind { /// Checks if buff is buff or debuff. pub fn is_buff(self) -> bool { @@ -330,7 +327,6 @@ pub struct BuffData { pub delay: Option, } -#[cfg(not(target_arch = "wasm32"))] impl BuffData { pub fn new(strength: f32, duration: Option, delay: Option) -> Self { Self { @@ -456,7 +452,6 @@ pub enum BuffChange { Refresh(BuffKind), } -#[cfg(not(target_arch = "wasm32"))] impl Buff { /// Builder function for buffs pub fn new( @@ -493,7 +488,6 @@ impl Buff { pub fn elapsed(&self, time: Time) -> Secs { Secs(time.0 - self.start_time.0) } } -#[cfg(not(target_arch = "wasm32"))] impl PartialOrd for Buff { fn partial_cmp(&self, other: &Self) -> Option { if self == other { @@ -516,12 +510,10 @@ impl PartialOrd for Buff { } } -#[cfg(not(target_arch = "wasm32"))] fn compare_end_time(a: Option