diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0a28ab34..ff52e3bd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,7 @@ on: env: CARGO_TERM_COLOR: always - RUST_TOOLCHAIN: nightly-2024-10-15 + RUST_TOOLCHAIN: nightly-2024-11-03 jobs: machete: @@ -48,22 +48,6 @@ jobs: run: | cargo test --workspace --all-features - deny: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Install cargo-deny - uses: taiki-e/install-action@v2 - with: - tool: cargo-deny - - - name: Run cargo deny - run: | - cargo deny check -D warnings - fmt: runs-on: ubuntu-latest diff --git a/Cargo.lock b/Cargo.lock index 66e548d4..23b3b2e1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -78,9 +78,9 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] name = "anstream" -version = "0.6.17" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23a1e53f0f5d86382dafe1cf314783b2044280f406e7e1506368220ad11b1338" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" dependencies = [ "anstyle", "anstyle-parse", @@ -93,9 +93,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8365de52b16c035ff4fcafe0092ba9390540e3e352870ac09933bebcaa2c8c56" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" [[package]] name = "anstyle-parse" @@ -127,9 +127,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.91" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8" +checksum = "74f37166d7d48a0284b99dd824694c26119c700b53bf0d1540cdb147dbdaaf13" dependencies = [ "backtrace", ] @@ -169,7 +169,7 @@ dependencies = [ "async-task", "concurrent-queue", "fastrand 2.1.1", - "futures-lite 2.3.0", + "futures-lite 2.4.0", "slab", ] @@ -353,16 +353,14 @@ dependencies = [ [[package]] name = "bindgen" -version = "0.69.5" +version = "0.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088" +checksum = "f49d8fed880d473ea71efb9bf597651e77201bdd4893efe54c9e5d65ae04ce6f" dependencies = [ "bitflags 2.6.0", "cexpr", "clang-sys", - "itertools 0.12.1", - "lazy_static", - "lazycell", + "itertools 0.13.0", "log", "prettyplease", "proc-macro2", @@ -371,7 +369,6 @@ dependencies = [ "rustc-hash 1.1.0", "shlex", "syn", - "which", ] [[package]] @@ -542,9 +539,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.31" +version = "1.1.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f" +checksum = "67b9470d453346108f93a59222a9a1a5724db32d0a4727b7ab7ace4b4d822dc9" dependencies = [ "shlex", ] @@ -960,11 +957,22 @@ dependencies = [ "winapi", ] +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "divan" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0d567df2c9c2870a43f3f2bd65aaeb18dbce1c18f217c3e564b4fbaeb3ee56c" +checksum = "6e05d17bd4ff1c1e7998ed4623d2efd91f72f1e24141ac33aac9377974270e1f" dependencies = [ "cfg-if", "clap", @@ -976,9 +984,9 @@ dependencies = [ [[package]] name = "divan-macros" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27540baf49be0d484d8f0130d7d8da3011c32a44d4fc873368154f1510e574a2" +checksum = "1b4464d46ce68bfc7cb76389248c7c254def7baca8bece0693b02b83842c4c88" dependencies = [ "proc-macro2", "quote", @@ -1129,7 +1137,7 @@ dependencies = [ [[package]] name = "flecs_ecs" version = "0.1.3" -source = "git+https://github.com/Indra-db/Flecs-Rust#3a60b40f1f010c3de3cf169b8a716e2a208d10cc" +source = "git+https://github.com/Indra-db/Flecs-Rust#98b53fb037a4ebbf20e063f001df2d53770fb28a" dependencies = [ "bitflags 2.6.0", "compact_str", @@ -1141,7 +1149,7 @@ dependencies = [ [[package]] name = "flecs_ecs_derive" version = "0.1.0" -source = "git+https://github.com/Indra-db/Flecs-Rust#3a60b40f1f010c3de3cf169b8a716e2a208d10cc" +source = "git+https://github.com/Indra-db/Flecs-Rust#98b53fb037a4ebbf20e063f001df2d53770fb28a" dependencies = [ "proc-macro2", "quote", @@ -1151,7 +1159,7 @@ dependencies = [ [[package]] name = "flecs_ecs_sys" version = "0.1.2" -source = "git+https://github.com/Indra-db/Flecs-Rust#3a60b40f1f010c3de3cf169b8a716e2a208d10cc" +source = "git+https://github.com/Indra-db/Flecs-Rust#98b53fb037a4ebbf20e063f001df2d53770fb28a" dependencies = [ "bindgen", "cc", @@ -1239,9 +1247,9 @@ dependencies = [ [[package]] name = "futures-lite" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5" +checksum = "3f1fa2f9765705486b33fd2acf1577f8ec449c2ba1f318ae5447697b7c08d210" dependencies = [ "fastrand 2.1.1", "futures-core", @@ -1350,9 +1358,9 @@ checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "glam" -version = "0.29.0" +version = "0.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28091a37a5d09b555cb6628fd954da299b536433834f5b8e59eba78e0cbbf8a" +checksum = "480c9417a5dc586fc0c0cb67891170e59cc11e9dc79ba1c11ddd2c56ca3f3b90" dependencies = [ "serde", ] @@ -1431,9 +1439,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" +checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" dependencies = [ "allocator-api2", "equivalent", @@ -1518,15 +1526,6 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" -[[package]] -name = "home" -version = "0.5.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" -dependencies = [ - "windows-sys 0.52.0", -] - [[package]] name = "http" version = "1.1.0" @@ -1712,10 +1711,6 @@ dependencies = [ "valence_text", ] -[[package]] -name = "hyperion-circle-buf" -version = "0.1.0" - [[package]] name = "hyperion-crafting" version = "0.1.0" @@ -1846,6 +1841,124 @@ dependencies = [ "flecs_ecs", ] +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -1854,12 +1967,23 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.5.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" dependencies = [ - "unicode-bidi", - "unicode-normalization", + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +dependencies = [ + "icu_normalizer", + "icu_properties", ] [[package]] @@ -1883,7 +2007,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown 0.15.0", + "hashbrown 0.15.1", "serde", ] @@ -1992,12 +2116,6 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -[[package]] -name = "lazycell" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" - [[package]] name = "libc" version = "0.2.161" @@ -2059,6 +2177,12 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +[[package]] +name = "litemap" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" + [[package]] name = "lmdb-master-sys" version = "0.2.4" @@ -2105,7 +2229,7 @@ version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38" dependencies = [ - "hashbrown 0.15.0", + "hashbrown 0.15.1", ] [[package]] @@ -2398,9 +2522,9 @@ dependencies = [ [[package]] name = "ordered-float" -version = "4.4.0" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83e7ccb95e240b7c9506a3d544f10d935e142cc90b0a1d56954fb44d89ad6b97" +checksum = "c65ee1f9701bf938026630b455d5315f490640234259037edb259798b3bcf85e" dependencies = [ "num-traits", ] @@ -3465,9 +3589,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.85" +version = "2.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" dependencies = [ "proc-macro2", "quote", @@ -3492,6 +3616,17 @@ dependencies = [ "crossbeam-queue", ] +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "system-configuration" version = "0.6.1" @@ -3542,9 +3677,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tar" -version = "0.4.42" +version = "0.4.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ff6c40d3aedb5e06b57c6f669ad17ab063dd1e63d977c6a88e7f4dfa4f04020" +checksum = "c65998313f8e17d0d553d28f91a0df93e4dbbbf770279c7bc21ca0f09ea1a1f6" dependencies = [ "filetime", "libc", @@ -3591,18 +3726,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.65" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d11abd9594d9b38965ef50805c5e469ca9cc6f197f883f717e0269a3057b3d5" +checksum = "02dd99dc800bbb97186339685293e1cc5d9df1f8fae2d0aecd9ff1c77efea892" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.65" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602" +checksum = "a7c61ec9a6f64d2793d8a45faba21efbe3ced62a886d44c36a009b2b519b4c7e" dependencies = [ "proc-macro2", "quote", @@ -3670,6 +3805,16 @@ dependencies = [ "time-core", ] +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + [[package]] name = "tinytemplate" version = "1.2.1" @@ -3934,27 +4079,12 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" -[[package]] -name = "unicode-bidi" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" - [[package]] name = "unicode-ident" version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" -[[package]] -name = "unicode-normalization" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" -dependencies = [ - "tinyvec", -] - [[package]] name = "unicode-segmentation" version = "1.12.0" @@ -3975,9 +4105,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.2" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" +checksum = "8d157f1b96d14500ffdc1f10ba712e780825526c03d9a49b4d0324b0d9113ada" dependencies = [ "form_urlencoded", "idna", @@ -3985,6 +4115,18 @@ dependencies = [ "serde", ] +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "utf8parse" version = "0.2.2" @@ -4365,18 +4507,6 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082" -[[package]] -name = "which" -version = "4.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" -dependencies = [ - "either", - "home", - "once_cell", - "rustix", -] - [[package]] name = "winapi" version = "0.3.9" @@ -4706,6 +4836,18 @@ dependencies = [ "memchr", ] +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + [[package]] name = "wyz" version = "0.5.1" @@ -4732,6 +4874,30 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" +[[package]] +name = "yoke" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + [[package]] name = "zerocopy" version = "0.7.35" @@ -4753,8 +4919,51 @@ dependencies = [ "syn", ] +[[package]] +name = "zerofrom" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + [[package]] name = "zeroize" version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" + +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/Cargo.toml b/Cargo.toml index 8f598cd1..54fa8684 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,4 @@ + [profile] [profile.release-debug] @@ -28,7 +29,6 @@ members = [ 'crates/hyperion-text', 'crates/hyperion-utils', 'events/proof-of-concept', - 'crates/hyperion-circle-buf', 'crates/hyperion-permission' ] resolver = '2' @@ -115,9 +115,6 @@ git = 'https://github.com/Indra-db/Flecs-Rust' [workspace.dependencies.hyperion] path = 'crates/hyperion' -[workspace.dependencies.hyperion-circle-buf] -path = 'crates/hyperion-circle-buf' - [workspace.dependencies.hyperion-crafting] path = 'crates/hyperion-crafting' diff --git a/crates/bvh-region/Cargo.toml b/crates/bvh-region/Cargo.toml index 6b63e837..8ede5c7e 100644 --- a/crates/bvh-region/Cargo.toml +++ b/crates/bvh-region/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["edition2024"] + [[bench]] harness = false name = "sort" @@ -41,7 +43,7 @@ workspace = true [package] authors = ["Andrew Gazelka "] -edition = "2021" +edition = "2024" name = "bvh-region" publish = false readme = "README.md" diff --git a/crates/bvh-region/benches/bvh.rs b/crates/bvh-region/benches/bvh.rs index 657cdee0..46a45ca9 100644 --- a/crates/bvh-region/benches/bvh.rs +++ b/crates/bvh-region/benches/bvh.rs @@ -10,7 +10,7 @@ fn main() { divan::main(); } -use bvh_region::{create_random_elements_1, random_aabb, Bvh, Heuristic, TrivialHeuristic}; +use bvh_region::{Bvh, Heuristic, TrivialHeuristic, create_random_elements_1, random_aabb}; const ENTITY_COUNTS: &[usize] = &[100, 1_000, 10_000]; diff --git a/crates/bvh-region/benches/side_by_side.rs b/crates/bvh-region/benches/side_by_side.rs index 65d4ca32..a8a311e4 100644 --- a/crates/bvh-region/benches/side_by_side.rs +++ b/crates/bvh-region/benches/side_by_side.rs @@ -1,8 +1,8 @@ use std::hint::black_box; -use bvh_region::{aabb::Aabb, random_aabb, Bvh, TrivialHeuristic}; +use bvh_region::{Bvh, TrivialHeuristic, aabb::Aabb, random_aabb}; use rayon::iter::{IntoParallelIterator, ParallelIterator}; -use tango_bench::{benchmark_fn, tango_benchmarks, tango_main, IntoBenchmarks}; +use tango_bench::{IntoBenchmarks, benchmark_fn, tango_benchmarks, tango_main}; const COUNT: usize = 10_000; diff --git a/crates/bvh-region/benches/sort.rs b/crates/bvh-region/benches/sort.rs index 2b82c526..f411f960 100644 --- a/crates/bvh-region/benches/sort.rs +++ b/crates/bvh-region/benches/sort.rs @@ -1,6 +1,6 @@ use std::hint::black_box; -use criterion::{criterion_group, criterion_main, Bencher, Criterion}; +use criterion::{Bencher, Criterion, criterion_group, criterion_main}; use ordered_float::OrderedFloat; const LEN: usize = 100; diff --git a/crates/bvh-region/src/lib.rs b/crates/bvh-region/src/lib.rs index d38d34ac..367edb65 100644 --- a/crates/bvh-region/src/lib.rs +++ b/crates/bvh-region/src/lib.rs @@ -194,7 +194,7 @@ impl Bvh { (elem, dist2) }) - .min_by_key(|(_, dist)| dist.to_bits()) + .min_by_key(|(_, dist)| dist.to_bits()); } }; diff --git a/crates/bvh-region/src/plot.rs b/crates/bvh-region/src/plot.rs index b04df2bf..a73415b3 100644 --- a/crates/bvh-region/src/plot.rs +++ b/crates/bvh-region/src/plot.rs @@ -5,11 +5,11 @@ use plotters::{ drawing::IntoDrawingArea, element::Rectangle, prelude::Cartesian2d, - style::{Color, RGBColor, ShapeStyle, BLACK, RED}, + style::{BLACK, Color, RED, RGBColor, ShapeStyle}, }; use plotters_bitmap::BitMapBackend; -use crate::{aabb::Aabb, Bvh, HasAabb, Node}; +use crate::{Bvh, HasAabb, Node, aabb::Aabb}; impl Bvh { pub fn plot(&self, filename: &str) -> Result<(), Box> { diff --git a/crates/hyperion-circle-buf/.gitignore b/crates/hyperion-circle-buf/.gitignore deleted file mode 100644 index ea8c4bf7..00000000 --- a/crates/hyperion-circle-buf/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/target diff --git a/crates/hyperion-circle-buf/Cargo.toml b/crates/hyperion-circle-buf/Cargo.toml deleted file mode 100644 index a53d754a..00000000 --- a/crates/hyperion-circle-buf/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[dependencies] - -[lints] -workspace = true - -[package] -authors = ["Andrew Gazelka "] -edition = "2021" -name = "hyperion-circle-buf" -publish = false -readme = "README.md" -version = "0.1.0" diff --git a/crates/hyperion-circle-buf/README.md b/crates/hyperion-circle-buf/README.md deleted file mode 100644 index e3654ea5..00000000 --- a/crates/hyperion-circle-buf/README.md +++ /dev/null @@ -1 +0,0 @@ -# hyperion-circle-buf \ No newline at end of file diff --git a/crates/hyperion-circle-buf/src/lib.rs b/crates/hyperion-circle-buf/src/lib.rs deleted file mode 100644 index 7ddb199d..00000000 --- a/crates/hyperion-circle-buf/src/lib.rs +++ /dev/null @@ -1,288 +0,0 @@ -use std::{ - alloc::{self, Layout}, - ptr::NonNull, - sync::atomic::{AtomicUsize, Ordering}, -}; - -/// A lock-free SPSC (Single Producer Single Consumer) ring buffer optimized for HPC scenarios. -/// Specialized for u8 data to optimize for common byte stream use cases. -pub struct RingBuf { - buf: NonNull, - capacity: usize, - mask: usize, - // Position that has been committed/made visible to reader - committed: AtomicUsize, -} - -/// Writer handle for pushing data into the buffer -pub struct Producer { - inner: *const RingBuf, - // Local write position for batching writes - write_pos: usize, -} - -unsafe impl Send for Producer {} - -/// Reader handle for consuming data from the buffer -pub struct Consumer { - inner: *const RingBuf, - // Local read position - read_pos: usize, -} - -unsafe impl Send for Consumer {} - -// Safety: RingBuf can be sent between threads -unsafe impl Send for RingBuf {} -unsafe impl Sync for RingBuf {} - -#[must_use] -pub fn new_pair(capacity: usize) -> (Producer, Consumer) { - let ring = RingBuf::new(capacity); - RingBuf::split(Box::new(ring)) -} - -impl RingBuf { - /// Creates a new [`RingBuf`] with the specified capacity rounded up to the next power of 2 - #[must_use] - pub fn new(mut capacity: usize) -> Self { - // Round up to next power of 2 for efficient wrapping - capacity = capacity.next_power_of_two(); - let layout = Layout::array::(capacity).unwrap(); - let buf = unsafe { NonNull::new(alloc::alloc(layout)).expect("allocation failed") }; - - Self { - buf, - capacity, - mask: capacity - 1, - committed: AtomicUsize::new(0), - } - } - - /// Creates a producer-consumer pair for this buffer - #[must_use] - pub fn split(buffer: Box) -> (Producer, Consumer) { - let ptr = Box::into_raw(buffer); - ( - Producer { - inner: ptr, - write_pos: 0, - }, - Consumer { - inner: ptr, - read_pos: 0, - }, - ) - } -} - -impl Producer { - /// Returns two slices representing the available write space: - /// - First slice: from write position to end of buffer - /// - Second slice: from start of buffer to wrap point - #[inline] - #[must_use] - pub fn write_bufs(&self) -> [&mut [u8]; 2] { - let ring = unsafe { &*self.inner }; - let write_idx = self.write_pos & ring.mask; - - unsafe { - let ptr = ring.buf.as_ptr(); - - // First slice: from write_idx to end of buffer - let slice1 = - std::slice::from_raw_parts_mut(ptr.add(write_idx), ring.capacity - write_idx); - - // Second slice: from start to write_idx - let slice2 = std::slice::from_raw_parts_mut(ptr, write_idx); - - [slice1, slice2] - } - } - - /// Commits written data to be visible to the consumer - #[inline] - pub fn commit(&mut self, written: usize) { - let ring = unsafe { &*self.inner }; - self.write_pos = self.write_pos.wrapping_add(written); - ring.committed.store(self.write_pos, Ordering::Release); - } - - /// Write as much data as possible from the slice, returns number of bytes written - #[inline] - pub fn write(&mut self, src: &[u8]) -> usize { - if src.is_empty() { - return 0; - } - - let [buf1, buf2] = self.write_bufs(); - let mut written = 0; - - // Write to first buffer - let to_write1 = src.len().min(buf1.len()); - if to_write1 > 0 { - unsafe { - std::ptr::copy_nonoverlapping(src.as_ptr(), buf1.as_mut_ptr(), to_write1); - } - written += to_write1; - } - - // Write remaining data to second buffer if needed - let remaining = src.len() - written; - if remaining > 0 { - let to_write2 = remaining.min(buf2.len()); - if to_write2 > 0 { - unsafe { - std::ptr::copy_nonoverlapping( - src.as_ptr().add(written), - buf2.as_mut_ptr(), - to_write2, - ); - } - written += to_write2; - } - } - - // Commit the write - self.commit(written); - written - } - - #[inline] - #[must_use] - pub fn capacity(&self) -> usize { - unsafe { (*self.inner).capacity } - } -} - -impl Consumer { - /// Returns a slice containing available data to read - #[inline] - #[must_use] - pub fn read_buf(&self) -> &[u8] { - let ring = unsafe { &*self.inner }; - let read_idx = self.read_pos & ring.mask; - - // Get committed write position - let committed = ring.committed.load(Ordering::Acquire); - let available = committed.wrapping_sub(self.read_pos); - - if available == 0 { - return &[]; - } - - // Calculate contiguous readable bytes - let readable = available.min(ring.capacity - read_idx); - - unsafe { std::slice::from_raw_parts(ring.buf.as_ptr().add(read_idx), readable) } - } - - /// Advances the read position - #[inline] - pub fn commit(&mut self, amount: usize) { - self.read_pos = self.read_pos.wrapping_add(amount); - } - - /// Returns number of bytes available to read - #[inline] - #[must_use] - pub fn available(&self) -> usize { - let ring = unsafe { &*self.inner }; - let committed = ring.committed.load(Ordering::Acquire); - committed.wrapping_sub(self.read_pos) - } - - #[inline] - #[must_use] - pub fn is_empty(&self) -> bool { - self.available() == 0 - } -} - -impl Drop for RingBuf { - fn drop(&mut self) { - unsafe { - let layout = Layout::array::(self.capacity).unwrap(); - alloc::dealloc(self.buf.as_ptr(), layout); - } - } -} - -#[cfg(test)] -mod tests { - use std::thread; - - use super::*; - - #[test] - fn test_basic_operations() { - let buffer = Box::new(RingBuf::new(16)); - let (mut producer, mut consumer) = RingBuf::split(buffer); - - // Test writing - assert_eq!(producer.write(&[1, 2, 3, 4]), 4); - - // Test reading - let data = consumer.read_buf(); - assert_eq!(data, &[1, 2, 3, 4]); - - // Test consuming - consumer.commit(2); - let data = consumer.read_buf(); - assert_eq!(data, &[3, 4]); - } - - #[test] - fn test_wrap_around() { - let buffer = Box::new(RingBuf::new(4)); - let (mut producer, mut consumer) = RingBuf::split(buffer); - - // Fill buffer - assert_eq!(producer.write(&[1, 2, 3, 4]), 4); - - // Read part - assert_eq!(consumer.read_buf(), &[1, 2, 3, 4]); - consumer.commit(2); - - // Write more to trigger wrap - assert_eq!(producer.write(&[5, 6]), 2); - - // Verify data - assert_eq!(consumer.read_buf(), &[3, 4]); - consumer.commit(2); - assert_eq!(consumer.read_buf(), &[5, 6]); - } - - #[test] - fn test_concurrent_access() { - let buffer = Box::new(RingBuf::new(1024)); - let (mut producer, mut consumer) = RingBuf::split(buffer); - - let producer_thread = thread::spawn(move || { - let data: Vec = (0..100).collect(); - let mut written = 0; - while written < data.len() { - written += producer.write(&data[written..]); - } - }); - - let consumer_thread = thread::spawn(move || { - let mut total_read = 0; - while total_read < 100 { - let data = consumer.read_buf(); - if !data.is_empty() { - // Verify data - for (i, &byte) in data.iter().enumerate() { - assert_eq!(byte, u8::try_from(total_read + i).unwrap()); - } - let len = data.len(); - consumer.commit(data.len()); - total_read += len; - } - } - }); - - producer_thread.join().unwrap(); - consumer_thread.join().unwrap(); - } -} diff --git a/crates/hyperion-crafting/Cargo.toml b/crates/hyperion-crafting/Cargo.toml index 99900a82..49c9cbdf 100644 --- a/crates/hyperion-crafting/Cargo.toml +++ b/crates/hyperion-crafting/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["edition2024"] + [dependencies] anyhow.workspace = true derive-build.workspace = true @@ -10,7 +12,7 @@ workspace = true [package] authors = ["Andrew Gazelka "] -edition = "2021" +edition = "2024" name = "hyperion-crafting" publish = false readme = "README.md" diff --git a/crates/hyperion-crafting/src/lib.rs b/crates/hyperion-crafting/src/lib.rs index 7503f744..d789baba 100644 --- a/crates/hyperion-crafting/src/lib.rs +++ b/crates/hyperion-crafting/src/lib.rs @@ -2,7 +2,7 @@ use std::{collections::HashMap, io::Write}; use derive_build::Build; use flecs_ecs::macros::Component; -use slotmap::{new_key_type, SecondaryMap, SlotMap}; +use slotmap::{SecondaryMap, SlotMap, new_key_type}; use valence_protocol::{Encode, ItemKind, ItemStack, Packet}; /// Represents a packet sent from the server to the client to synchronize recipes. diff --git a/crates/hyperion-event-macros/Cargo.toml b/crates/hyperion-event-macros/Cargo.toml index 17b53f27..65d735e1 100644 --- a/crates/hyperion-event-macros/Cargo.toml +++ b/crates/hyperion-event-macros/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["edition2024"] + [dependencies] convert_case = "0.6.0" proc-macro2 = "1.0.88" @@ -16,7 +18,7 @@ workspace = true [package] authors = ["Andrew Gazelka "] -edition = "2021" +edition = "2024" name = "hyperion-event-macros" publish = false readme = "README.md" diff --git a/crates/hyperion-event-macros/src/lib.rs b/crates/hyperion-event-macros/src/lib.rs index 85f8f556..7d896ecc 100644 --- a/crates/hyperion-event-macros/src/lib.rs +++ b/crates/hyperion-event-macros/src/lib.rs @@ -2,11 +2,11 @@ use convert_case::{Case, Casing}; use proc_macro::TokenStream; use quote::{format_ident, quote}; use syn::{ + Lifetime, Token, Type, parse::{Parse, ParseStream, Result}, parse_macro_input, punctuated::Punctuated, spanned::Spanned, - Lifetime, Token, Type, }; /// Entry point for the procedural macro diff --git a/crates/hyperion-inventory/Cargo.toml b/crates/hyperion-inventory/Cargo.toml index cbc84ad3..64a0f34a 100644 --- a/crates/hyperion-inventory/Cargo.toml +++ b/crates/hyperion-inventory/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["edition2024"] + [dependencies] flecs_ecs.workspace = true hyperion-crafting.workspace = true @@ -10,7 +12,7 @@ workspace = true [package] authors = ["Andrew Gazelka "] -edition = "2021" +edition = "2024" name = "hyperion-inventory" publish = false readme = "README.md" diff --git a/crates/hyperion-inventory/src/action.rs b/crates/hyperion-inventory/src/action.rs index f534fdac..ba3e9faa 100644 --- a/crates/hyperion-inventory/src/action.rs +++ b/crates/hyperion-inventory/src/action.rs @@ -1,6 +1,6 @@ use valence_protocol::ItemStack; -use super::{slot_index_from_hand, PlayerInventory, OFFHAND_SLOT}; +use super::{OFFHAND_SLOT, PlayerInventory, slot_index_from_hand}; #[derive(Debug, PartialEq, Eq, Clone, Copy)] pub enum FullMouseButton { diff --git a/crates/hyperion-inventory/src/parser.rs b/crates/hyperion-inventory/src/parser.rs index fcc3058f..917278af 100644 --- a/crates/hyperion-inventory/src/parser.rs +++ b/crates/hyperion-inventory/src/parser.rs @@ -1,4 +1,4 @@ -use snafu::{ensure, ResultExt, Snafu}; +use snafu::{ResultExt, Snafu, ensure}; use super::action::{FullMouseButton, InventoryAction, MouseButton}; diff --git a/crates/hyperion-minecraft-proto/Cargo.toml b/crates/hyperion-minecraft-proto/Cargo.toml index a3803feb..29b11dc2 100644 --- a/crates/hyperion-minecraft-proto/Cargo.toml +++ b/crates/hyperion-minecraft-proto/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["edition2024"] + [dependencies] [lints] @@ -5,7 +7,7 @@ workspace = true [package] authors = ["Andrew Gazelka "] -edition = "2021" +edition = "2024" name = "hyperion-minecraft-proto" publish = false readme = "README.md" diff --git a/crates/hyperion-nerd-font/Cargo.toml b/crates/hyperion-nerd-font/Cargo.toml index 530ee739..1762bcf4 100644 --- a/crates/hyperion-nerd-font/Cargo.toml +++ b/crates/hyperion-nerd-font/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["edition2024"] + [dependencies] [lints] @@ -5,7 +7,7 @@ workspace = true [package] authors = ["Andrew Gazelka "] -edition = "2021" +edition = "2024" name = "hyperion-nerd-font" publish = false readme = "README.md" diff --git a/crates/hyperion-palette/Cargo.toml b/crates/hyperion-palette/Cargo.toml index b75d85f6..d4d7058d 100644 --- a/crates/hyperion-palette/Cargo.toml +++ b/crates/hyperion-palette/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["edition2024"] + [dependencies] anyhow.workspace = true roaring.workspace = true @@ -8,7 +10,7 @@ workspace = true [package] authors = ["Andrew Gazelka "] -edition = "2021" +edition = "2024" name = "hyperion-palette" publish = false readme = "README.md" diff --git a/crates/hyperion-palette/src/encode.rs b/crates/hyperion-palette/src/encode.rs index e779592e..fc4ab7b0 100644 --- a/crates/hyperion-palette/src/encode.rs +++ b/crates/hyperion-palette/src/encode.rs @@ -9,7 +9,7 @@ use std::io::Write; use valence_protocol::{Encode, VarInt}; -use crate::{Data, PalettedContainer, LEN}; +use crate::{Data, LEN, PalettedContainer}; const fn bit_width(n: usize) -> usize { (usize::BITS - n.leading_zeros()) as usize diff --git a/crates/hyperion-palette/src/indirect.rs b/crates/hyperion-palette/src/indirect.rs index 43e9628d..be06bae0 100644 --- a/crates/hyperion-palette/src/indirect.rs +++ b/crates/hyperion-palette/src/indirect.rs @@ -1,4 +1,4 @@ -use std::simd::{cmp::SimdPartialEq, Simd}; +use std::simd::{Simd, cmp::SimdPartialEq}; use crate::{Data, HALF_LEN, LEN}; diff --git a/crates/hyperion-permission/Cargo.toml b/crates/hyperion-permission/Cargo.toml index 2b1e0047..075de1b5 100644 --- a/crates/hyperion-permission/Cargo.toml +++ b/crates/hyperion-permission/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["edition2024"] + [dependencies] heed = "0.20.5" num-derive = "0.4.2" @@ -15,7 +17,7 @@ workspace = true [package] authors = ["Andrew Gazelka "] -edition = "2021" +edition = "2024" name = "hyperion-permission" publish = false readme = "README.md" diff --git a/crates/hyperion-permission/src/lib.rs b/crates/hyperion-permission/src/lib.rs index 657203b1..99893fbc 100644 --- a/crates/hyperion-permission/src/lib.rs +++ b/crates/hyperion-permission/src/lib.rs @@ -1,10 +1,10 @@ use flecs_ecs::{ core::{QueryBuilderImpl, SystemAPI, TermBuilderImpl, World, WorldGet}, - macros::{observer, Component}, - prelude::{flecs, Module}, + macros::{Component, observer}, + prelude::{Module, flecs}, }; use hyperion::{ - simulation::{command::cmd_with, Uuid}, + simulation::{Uuid, command::cmd_with}, storage::LocalDb, }; use num_derive::{FromPrimitive, ToPrimitive}; @@ -36,12 +36,12 @@ pub enum Group { } use nom::{ + IResult, Parser as NomParser, branch::alt, bytes::complete::{is_a, tag}, character::complete::space0, combinator::{map, value}, sequence::preceded, - IResult, Parser as NomParser, }; fn parse_group(input: &str) -> IResult<&str, Group> { diff --git a/crates/hyperion-permission/src/storage.rs b/crates/hyperion-permission/src/storage.rs index 0d7d5f28..22a30df8 100644 --- a/crates/hyperion-permission/src/storage.rs +++ b/crates/hyperion-permission/src/storage.rs @@ -1,5 +1,5 @@ use flecs_ecs::macros::Component; -use heed::{byteorder::NativeEndian, types, Database, Env}; +use heed::{Database, Env, byteorder::NativeEndian, types}; use hyperion::storage::LocalDb; use num_traits::{FromPrimitive, ToPrimitive}; diff --git a/crates/hyperion-proto/Cargo.toml b/crates/hyperion-proto/Cargo.toml index 4c980188..3529520d 100644 --- a/crates/hyperion-proto/Cargo.toml +++ b/crates/hyperion-proto/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["edition2024"] + [build-dependencies] [dependencies] @@ -8,7 +10,7 @@ workspace = true [package] authors = ["Andrew Gazelka "] -edition = "2021" +edition = "2024" name = "hyperion-proto" publish = false readme = "README.md" diff --git a/crates/hyperion-proto/rustfmt.toml b/crates/hyperion-proto/rustfmt.toml index 2531e139..c1c03c98 100644 --- a/crates/hyperion-proto/rustfmt.toml +++ b/crates/hyperion-proto/rustfmt.toml @@ -2,7 +2,7 @@ combine_control_expr = true comment_width = 100 # https://lkml.org/lkml/2020/5/29/1038 condense_wildcard_suffixes = true control_brace_style = "AlwaysSameLine" -edition = "2021" +edition = "2024" format_code_in_doc_comments = true format_macro_bodies = true format_macro_matchers = true diff --git a/crates/hyperion-proto/src/proxy_to_server.rs b/crates/hyperion-proto/src/proxy_to_server.rs index f1886f0e..07ed2fdf 100644 --- a/crates/hyperion-proto/src/proxy_to_server.rs +++ b/crates/hyperion-proto/src/proxy_to_server.rs @@ -1,4 +1,4 @@ -use rkyv::{with::InlineAsBox, Archive, Deserialize, Serialize}; +use rkyv::{Archive, Deserialize, Serialize, with::InlineAsBox}; #[derive(Archive, Deserialize, Serialize, Clone, PartialEq, Debug)] pub struct PlayerPackets<'a> { diff --git a/crates/hyperion-proto/src/server_to_proxy.rs b/crates/hyperion-proto/src/server_to_proxy.rs index e96434d8..05369b99 100644 --- a/crates/hyperion-proto/src/server_to_proxy.rs +++ b/crates/hyperion-proto/src/server_to_proxy.rs @@ -1,4 +1,4 @@ -use rkyv::{with::InlineAsBox, Archive, Deserialize, Serialize}; +use rkyv::{Archive, Deserialize, Serialize, with::InlineAsBox}; use crate::ChunkPosition; diff --git a/crates/hyperion-proxy/Cargo.toml b/crates/hyperion-proxy/Cargo.toml index 59727d94..29f69da5 100644 --- a/crates/hyperion-proxy/Cargo.toml +++ b/crates/hyperion-proxy/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["edition2024"] + [dependencies] colored = "2.1.0" kanal = "0.1.0-pre8" @@ -24,7 +26,7 @@ workspace = true [package] authors = ["Andrew Gazelka "] -edition = "2021" +edition = "2024" name = "hyperion-proxy" publish = false readme = "README.md" diff --git a/crates/hyperion-proxy/src/cache.rs b/crates/hyperion-proxy/src/cache.rs index 37aa86ab..b238a6ed 100644 --- a/crates/hyperion-proxy/src/cache.rs +++ b/crates/hyperion-proxy/src/cache.rs @@ -313,20 +313,17 @@ impl BufferedEgress { self.raw_local_broadcast_data.clear(); let egress = self.egress; - tokio::task::Builder::new() - .name("bvh") - .spawn(async move { - let bvh = bvh.into_bytes(); - - let instruction = BroadcastLocalInstruction { - order: 0, - bvh: Arc::new(bvh), - exclusions: Arc::new(exclusions), - }; - - egress.handle_broadcast_local(instruction); - }) - .unwrap(); + tokio::spawn(async move { + let bvh = bvh.into_bytes(); + + let instruction = BroadcastLocalInstruction { + order: 0, + bvh: Arc::new(bvh), + exclusions: Arc::new(exclusions), + }; + + egress.handle_broadcast_local(instruction); + }); } } } diff --git a/crates/hyperion-proxy/src/data.rs b/crates/hyperion-proxy/src/data.rs index bc57b7fd..0d73d677 100644 --- a/crates/hyperion-proxy/src/data.rs +++ b/crates/hyperion-proxy/src/data.rs @@ -1,8 +1,8 @@ -use std::sync::{atomic, atomic::AtomicBool, Arc}; +use std::sync::{Arc, atomic, atomic::AtomicBool}; use anyhow::bail; use bytes::Bytes; -use slotmap::{new_key_type, KeyData}; +use slotmap::{KeyData, new_key_type}; use crate::cache::ExclusionsManager; diff --git a/crates/hyperion-proxy/src/egress.rs b/crates/hyperion-proxy/src/egress.rs index f5badf77..8f604bf6 100644 --- a/crates/hyperion-proxy/src/egress.rs +++ b/crates/hyperion-proxy/src/egress.rs @@ -8,7 +8,7 @@ use hyperion_proto::{ ChunkPosition, }; use rustc_hash::FxBuildHasher; -use tracing::{debug, error, info_span, instrument, warn, Instrument}; +use tracing::{Instrument, debug, error, info_span, instrument, warn}; use crate::{ cache::ExclusionsManager, @@ -75,36 +75,30 @@ impl Egress { let data = pkt.data; let data = Bytes::copy_from_slice(data); - tokio::task::Builder::new() - .name("broadcast_global") - .spawn( - async move { - let exclusions = Arc::new(exclusions); - - // imo it makes sense to read once... it is a fast loop - #[allow(clippy::significant_drop_in_scrutinee)] - for (player_id, player) in &players { - if !player.can_receive_broadcasts() { - continue; - } + tokio::spawn( + async move { + let exclusions = Arc::new(exclusions); - let to_send = OrderedBytes::with_exclusions( - pkt.order, - data.clone(), - exclusions.clone(), - ); + // imo it makes sense to read once... it is a fast loop + #[allow(clippy::significant_drop_in_scrutinee)] + for (player_id, player) in &players { + if !player.can_receive_broadcasts() { + continue; + } - if let Err(e) = player.send(to_send) { - warn!("Failed to send data to player: {:?}", e); - if let Some(result) = players.remove(player_id) { - result.shutdown(); - } + let to_send = + OrderedBytes::with_exclusions(pkt.order, data.clone(), exclusions.clone()); + + if let Err(e) = player.send(to_send) { + warn!("Failed to send data to player: {:?}", e); + if let Some(result) = players.remove(player_id) { + result.shutdown(); } } } - .instrument(info_span!("broadcast_global_task")), - ) - .unwrap(); + } + .instrument(info_span!("broadcast_global_task")), + ); } #[instrument(skip_all)] @@ -135,60 +129,57 @@ impl Egress { let positions = self.positions.pin_owned(); // we are spawning because it is rather intensive to call get_in_slices on a bvh // #[allow(clippy::significant_drop_tightening)] - tokio::task::Builder::new() - .name("broadcast_local") - .spawn( - async move { - const RADIUS: i16 = 16; - - let players = self.player_registry.pin(); - - for (id, &position) in &positions { - let Some(player) = players.get(id) else { - // expected to still happen infrequently - debug!("Player not found for id {id:?}"); - continue; - }; + tokio::spawn( + async move { + const RADIUS: i16 = 16; - if !player.can_receive_broadcasts() { - continue; - } + let players = self.player_registry.pin(); - let position = I16Vec2::new(position.x, position.z); - let min = position - I16Vec2::splat(RADIUS); - let max = position + I16Vec2::splat(RADIUS); + for (id, &position) in &positions { + let Some(player) = players.get(id) else { + // expected to still happen infrequently + debug!("Player not found for id {id:?}"); + continue; + }; - let aabb = Aabb::new(min, max); + if !player.can_receive_broadcasts() { + continue; + } + + let position = I16Vec2::new(position.x, position.z); + let min = position - I16Vec2::splat(RADIUS); + let max = position + I16Vec2::splat(RADIUS); - let slices = bvh.get_in(aabb); + let aabb = Aabb::new(min, max); - for slice in slices { - let (_, data) = bvh.inner(); + let slices = bvh.get_in(aabb); - let start = slice.start as usize; - let end = slice.end as usize; + for slice in slices { + let (_, data) = bvh.inner(); - let data = data.slice(start..end); + let start = slice.start as usize; + let end = slice.end as usize; - let to_send = OrderedBytes { - order, - offset: slice.start, - data, - exclusions: Some(exclusions.clone()), - }; + let data = data.slice(start..end); - if let Err(e) = player.send(to_send) { - warn!("Failed to send data to player: {:?}", e); - if let Some(result) = players.remove(id) { - result.shutdown(); - } + let to_send = OrderedBytes { + order, + offset: slice.start, + data, + exclusions: Some(exclusions.clone()), + }; + + if let Err(e) = player.send(to_send) { + warn!("Failed to send data to player: {:?}", e); + if let Some(result) = players.remove(id) { + result.shutdown(); } } } } - .instrument(info_span!("broadcast_local_task")), - ) - .unwrap(); + } + .instrument(info_span!("broadcast_local_task")), + ); } #[instrument(skip_all)] diff --git a/crates/hyperion-proxy/src/lib.rs b/crates/hyperion-proxy/src/lib.rs index 57e4d2b5..44e37006 100644 --- a/crates/hyperion-proxy/src/lib.rs +++ b/crates/hyperion-proxy/src/lib.rs @@ -28,7 +28,7 @@ use tokio::{ net::{TcpStream, ToSocketAddrs}, }; use tokio_util::net::Listener; -use tracing::{debug, error, info, info_span, instrument, trace, warn, Instrument}; +use tracing::{Instrument, debug, error, info, info_span, instrument, trace, warn}; use crate::{ cache::BufferedEgress, data::PlayerHandle, egress::Egress, player::initiate_player_connection, @@ -74,17 +74,14 @@ pub async fn run_proxy( ) -> anyhow::Result<()> { let (shutdown_tx, shutdown_rx) = tokio::sync::watch::channel(None); - tokio::task::Builder::new() - .name("ctrl-c") - .spawn({ - let shutdown_tx = shutdown_tx.clone(); - async move { - tokio::signal::ctrl_c().await.unwrap(); - warn!("ctrl-c received, shutting down"); - shutdown_tx.send(Some(ShutdownType::Full)).unwrap(); - } - }) - .unwrap(); + tokio::spawn({ + let shutdown_tx = shutdown_tx.clone(); + async move { + tokio::signal::ctrl_c().await.unwrap(); + warn!("ctrl-c received, shutting down"); + shutdown_tx.send(Some(ShutdownType::Full)).unwrap(); + } + }); loop { let mut shutdown_rx2 = shutdown_rx.clone(); @@ -144,12 +141,10 @@ async fn connect_to_server_and_run_proxy( let mut handler = IngressHandler::new(BufReader::new(server_read), egress); - tokio::task::Builder::new() - .name("s2prox") - .spawn({ - let mut shutdown_rx = shutdown_rx.clone(); + tokio::spawn({ + let mut shutdown_rx = shutdown_rx.clone(); - async move { + async move { loop { tokio::select! { _ = shutdown_rx.wait_for(Option::is_some) => return, @@ -174,7 +169,7 @@ async fn connect_to_server_and_run_proxy( shutdown_tx.send(Some(ShutdownType::Reconnect)).unwrap(); } .instrument(info_span!("server_reader_loop")) - }).unwrap(); + }); // 0 is reserved for "None" value let mut player_id_on = 1; diff --git a/crates/hyperion-proxy/src/main.rs b/crates/hyperion-proxy/src/main.rs index cb25b331..df7c596c 100644 --- a/crates/hyperion-proxy/src/main.rs +++ b/crates/hyperion-proxy/src/main.rs @@ -96,25 +96,22 @@ async fn main() -> Result<(), Box> { let server_help = "~ The event server internal address".dimmed(); info!("👾 Internal server address: tcp://{server_addr} {server_help}"); - let handle = tokio::task::Builder::new() - .name("proxy") - .spawn(async move { - match &proxy_addr { - ProxyAddress::Tcp(addr) => { - let listener = TcpListener::bind(addr).await.unwrap(); - let socket = NoDelayTcpListener { listener }; - run_proxy(socket, server_addr).await.unwrap(); - } - #[cfg(unix)] - ProxyAddress::Unix(path) => { - // remove file if already exists - let _unused = tokio::fs::remove_file(path).await; - let listener = UnixListener::bind(path).unwrap(); - run_proxy(listener, server_addr).await.unwrap(); - } + let handle = tokio::spawn(async move { + match &proxy_addr { + ProxyAddress::Tcp(addr) => { + let listener = TcpListener::bind(addr).await.unwrap(); + let socket = NoDelayTcpListener { listener }; + run_proxy(socket, server_addr).await.unwrap(); } - }) - .unwrap(); + #[cfg(unix)] + ProxyAddress::Unix(path) => { + // remove file if already exists + let _unused = tokio::fs::remove_file(path).await; + let listener = UnixListener::bind(path).unwrap(); + run_proxy(listener, server_addr).await.unwrap(); + } + } + }); if let Err(e) = handle.await { error!("Proxy task failed: {:?}", e); diff --git a/crates/hyperion-proxy/src/player.rs b/crates/hyperion-proxy/src/player.rs index fa7569fd..3a92213a 100644 --- a/crates/hyperion-proxy/src/player.rs +++ b/crates/hyperion-proxy/src/player.rs @@ -15,11 +15,11 @@ use tokio::{ use tracing::{info, info_span, instrument, warn}; use crate::{ + ShutdownType, cache::ExclusionsManager, data::{OrderedBytes, PlayerHandle}, server_sender::ServerSender, util::AsyncWriteVectoredExt, - ShutdownType, }; /// Default buffer size for reading player packets, set to 8 KiB. @@ -52,149 +52,139 @@ pub fn initiate_player_connection( let socket_writer = Box::pin(socket_writer); // Task for handling incoming packets (player -> proxy) - let mut packet_reader_task = tokio::task::Builder::new() - .name("PL->PR") // player to proxy - .spawn({ - let server_sender = server_sender.clone(); - async move { - let mut read_buffer = Vec::new(); - let player_stream_id = player_id; - - let connect = rkyv::to_bytes::( - &ProxyToServerMessage::PlayerConnect(PlayerConnect { - stream: player_stream_id, - }), - ) - .unwrap(); - - if let Err(e) = server_sender.send(connect).await { - warn!("failed to send player connect to server: {e}"); - return; - } - - let mut arena = Arena::new(); + let mut packet_reader_task = tokio::spawn({ + let server_sender = server_sender.clone(); + async move { + let mut read_buffer = Vec::new(); + let player_stream_id = player_id; + + let connect = rkyv::to_bytes::( + &ProxyToServerMessage::PlayerConnect(PlayerConnect { + stream: player_stream_id, + }), + ) + .unwrap(); + + if let Err(e) = server_sender.send(connect).await { + warn!("failed to send player connect to server: {e}"); + return; + } - loop { - // Ensure the buffer has enough capacity - read_buffer.reserve(DEFAULT_READ_BUFFER_SIZE); + let mut arena = Arena::new(); - let bytes_read = match socket_reader.read_buf(&mut read_buffer).await { - Ok(n) => n, - Err(e) => { - warn!("Error reading from player: {e:?}"); - return; - } - }; + loop { + // Ensure the buffer has enough capacity + read_buffer.reserve(DEFAULT_READ_BUFFER_SIZE); - if bytes_read == 0 { - warn!("End of stream reached for player"); + let bytes_read = match socket_reader.read_buf(&mut read_buffer).await { + Ok(n) => n, + Err(e) => { + warn!("Error reading from player: {e:?}"); return; } + }; - let player_packets = ProxyToServerMessage::PlayerPackets(PlayerPackets { - stream: player_id, - data: &read_buffer, - }); + if bytes_read == 0 { + warn!("End of stream reached for player"); + return; + } + + let player_packets = ProxyToServerMessage::PlayerPackets(PlayerPackets { + stream: player_id, + data: &read_buffer, + }); - let aligned_vec = - rkyv::api::high::to_bytes_with_alloc::<_, rkyv::rancor::Error>( - &player_packets, - arena.acquire(), - ) - .unwrap(); + let aligned_vec = rkyv::api::high::to_bytes_with_alloc::<_, rkyv::rancor::Error>( + &player_packets, + arena.acquire(), + ) + .unwrap(); - read_buffer.clear(); + read_buffer.clear(); - if let Err(e) = server_sender.send(aligned_vec).await { - warn!("Error forwarding player packets to server: {e:?}"); - return; - } + if let Err(e) = server_sender.send(aligned_vec).await { + warn!("Error forwarding player packets to server: {e:?}"); + return; } } - }) - .unwrap(); + } + }); // Task for handling outgoing packets (proxy -> player) - let mut packet_writer_task = tokio::task::Builder::new() - .name("proxy2player") - .spawn(async move { - let mut packet_writer = PlayerPacketWriter::new(socket_writer, player_id); + let mut packet_writer_task = tokio::spawn(async move { + let mut packet_writer = PlayerPacketWriter::new(socket_writer, player_id); + + while let Ok(outgoing_packet) = incoming_packet_receiver.recv().await { + if outgoing_packet.is_shutdown() { + return; + } - while let Ok(outgoing_packet) = incoming_packet_receiver.recv().await { - if outgoing_packet.is_shutdown() { + if outgoing_packet.is_flush() { + let time_start = std::time::Instant::now(); + if let Err(e) = packet_writer.flush_pending_packets().await { + warn!("Error flushing packets to player: {e:?}"); return; } - - if outgoing_packet.is_flush() { - let time_start = std::time::Instant::now(); - if let Err(e) = packet_writer.flush_pending_packets().await { - warn!("Error flushing packets to player: {e:?}"); - return; - } - let duration = time_start.elapsed(); - if duration > std::time::Duration::from_millis(50) { - warn!("flushed packets to player in {duration:?}"); - } - } else { - packet_writer.enqueue_packet(outgoing_packet); + let duration = time_start.elapsed(); + if duration > std::time::Duration::from_millis(50) { + warn!("flushed packets to player in {duration:?}"); } + } else { + packet_writer.enqueue_packet(outgoing_packet); } - }) - .unwrap(); - - tokio::task::Builder::new() - .name("player_disconnect") - .spawn(async move { - let shutdown_received = async move { - shutdown_signal.wait_for(Option::is_some).await.unwrap(); - }; - - tokio::select! { - () = shutdown_received => { - info!("Shutting down player connection due to server shutdown"); - packet_reader_task.abort(); - packet_writer_task.abort(); - }, - _ = &mut packet_writer_task => { - info!("Player disconnected because writer task finished: {player_id:?}"); - packet_reader_task.abort(); - - let disconnect = rkyv::to_bytes::( - &ProxyToServerMessage::PlayerDisconnect(PlayerDisconnect { - stream: player_id, - reason: PlayerDisconnectReason::LostConnection, - }), - ).unwrap(); - - if let Err(e) = server_sender.send(disconnect).await { - warn!("failed to send player disconnect to server: {e}"); - } - }, - _ = &mut packet_reader_task => { - info!("Player disconnected because reader task finished: {player_id:?}"); - packet_writer_task.abort(); + } + }); + + tokio::task::spawn(async move { + let shutdown_received = async move { + shutdown_signal.wait_for(Option::is_some).await.unwrap(); + }; + + tokio::select! { + () = shutdown_received => { + info!("Shutting down player connection due to server shutdown"); + packet_reader_task.abort(); + packet_writer_task.abort(); + }, + _ = &mut packet_writer_task => { + info!("Player disconnected because writer task finished: {player_id:?}"); + packet_reader_task.abort(); + + let disconnect = rkyv::to_bytes::( + &ProxyToServerMessage::PlayerDisconnect(PlayerDisconnect { + stream: player_id, + reason: PlayerDisconnectReason::LostConnection, + }), + ).unwrap(); + if let Err(e) = server_sender.send(disconnect).await { + warn!("failed to send player disconnect to server: {e}"); + } + }, + _ = &mut packet_reader_task => { + info!("Player disconnected because reader task finished: {player_id:?}"); + packet_writer_task.abort(); - let disconnect = rkyv::to_bytes::( - &ProxyToServerMessage::PlayerDisconnect(PlayerDisconnect { - stream: player_id, - reason: PlayerDisconnectReason::LostConnection, - })).unwrap(); - if let Err(e) = server_sender.send(disconnect).await { - warn!("failed to send player disconnect to server: {e}"); - } + let disconnect = rkyv::to_bytes::( + &ProxyToServerMessage::PlayerDisconnect(PlayerDisconnect { + stream: player_id, + reason: PlayerDisconnectReason::LostConnection, + })).unwrap(); - let map_ref = player_registry.pin(); - map_ref.remove(&player_id); + if let Err(e) = server_sender.send(disconnect).await { + warn!("failed to send player disconnect to server: {e}"); + } - let map_ref = player_positions.pin(); - map_ref.remove(&player_id); + let map_ref = player_registry.pin(); + map_ref.remove(&player_id); + + let map_ref = player_positions.pin(); + map_ref.remove(&player_id); - } } - }) - .unwrap() + } + }) } /// Manages the writing of packets to a player's connection. diff --git a/crates/hyperion-proxy/src/server_sender.rs b/crates/hyperion-proxy/src/server_sender.rs index fad3a46f..581d14ba 100644 --- a/crates/hyperion-proxy/src/server_sender.rs +++ b/crates/hyperion-proxy/src/server_sender.rs @@ -1,7 +1,7 @@ use std::io::IoSlice; use rkyv::util::AlignedVec; -use tracing::{trace_span, warn, Instrument}; +use tracing::{Instrument, trace_span, warn}; use crate::util::AsyncWriteVectoredExt; @@ -12,55 +12,50 @@ pub type ServerSender = kanal::AsyncSender; pub fn launch_server_writer(mut write: tokio::net::tcp::OwnedWriteHalf) -> ServerSender { let (tx, rx) = kanal::bounded_async::(32_768); - tokio::task::Builder::new() - .name("server_writer") - .spawn( - async move { - let mut lengths: Vec<[u8; 8]> = Vec::new(); - let mut messages = Vec::new(); + tokio::spawn( + async move { + let mut lengths: Vec<[u8; 8]> = Vec::new(); + let mut messages = Vec::new(); - // todo: remove allocation is there an easy way to do this? - let mut io_slices = Vec::new(); + // todo: remove allocation is there an easy way to do this? + let mut io_slices = Vec::new(); - while let Ok(message) = rx.recv().await { - let len = message.len() as u64; + while let Ok(message) = rx.recv().await { + let len = message.len() as u64; + + lengths.push(len.to_be_bytes()); + messages.push(message); + while let Ok(Some(message)) = rx.try_recv() { + let len = message.len() as u64; lengths.push(len.to_be_bytes()); messages.push(message); + } - while let Ok(Some(message)) = rx.try_recv() { - let len = message.len() as u64; - lengths.push(len.to_be_bytes()); - messages.push(message); - } - - for (message, length) in messages.iter().zip(lengths.iter()) { - let len = IoSlice::new(length); - let msg = IoSlice::new(message); - - // todo: is there a way around this? - let len = - unsafe { core::mem::transmute::, IoSlice<'static>>(len) }; - let msg = - unsafe { core::mem::transmute::, IoSlice<'static>>(msg) }; + for (message, length) in messages.iter().zip(lengths.iter()) { + let len = IoSlice::new(length); + let msg = IoSlice::new(message); - io_slices.push(len); - io_slices.push(msg); - } + // todo: is there a way around this? + let len = unsafe { core::mem::transmute::, IoSlice<'static>>(len) }; + let msg = unsafe { core::mem::transmute::, IoSlice<'static>>(msg) }; - if let Err(e) = write.write_vectored_all(&mut io_slices).await { - warn!("failed to write to server: {e}"); - return; - } + io_slices.push(len); + io_slices.push(msg); + } - lengths.clear(); - messages.clear(); - io_slices.clear(); + if let Err(e) = write.write_vectored_all(&mut io_slices).await { + warn!("failed to write to server: {e}"); + return; } + + lengths.clear(); + messages.clear(); + io_slices.clear(); } - .instrument(trace_span!("server_writer_loop")), - ) - .unwrap(); + } + .instrument(trace_span!("server_writer_loop")), + ); tx } diff --git a/crates/hyperion-scheduled/Cargo.toml b/crates/hyperion-scheduled/Cargo.toml index 24daff0f..a9542918 100644 --- a/crates/hyperion-scheduled/Cargo.toml +++ b/crates/hyperion-scheduled/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["edition2024"] + [dependencies] [lints] @@ -5,7 +7,7 @@ workspace = true [package] authors = ["Andrew Gazelka "] -edition = "2021" +edition = "2024" name = "hyperion-scheduled" publish = false readme = "README.md" diff --git a/crates/hyperion-scheduled/src/lib.rs b/crates/hyperion-scheduled/src/lib.rs index 28576f81..ff75d0ab 100644 --- a/crates/hyperion-scheduled/src/lib.rs +++ b/crates/hyperion-scheduled/src/lib.rs @@ -1,7 +1,7 @@ use std::{ borrow::Borrow, cmp::{Ordering, Reverse}, - collections::{binary_heap::PeekMut, BinaryHeap}, + collections::{BinaryHeap, binary_heap::PeekMut}, }; struct KeyValue(K, V); diff --git a/crates/hyperion-stats/Cargo.toml b/crates/hyperion-stats/Cargo.toml index 6ffffb0f..738f56db 100644 --- a/crates/hyperion-stats/Cargo.toml +++ b/crates/hyperion-stats/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["edition2024"] + [[bench]] harness = false name = "parallel_stats" @@ -14,7 +16,7 @@ workspace = true [package] authors = ["Andrew Gazelka "] -edition = "2021" +edition = "2024" name = "hyperion-stats" publish = false readme = "README.md" diff --git a/crates/hyperion-stats/benches/parallel_stats.rs b/crates/hyperion-stats/benches/parallel_stats.rs index d56a66b3..78969ce1 100644 --- a/crates/hyperion-stats/benches/parallel_stats.rs +++ b/crates/hyperion-stats/benches/parallel_stats.rs @@ -1,4 +1,4 @@ -use divan::{black_box, Bencher}; +use divan::{Bencher, black_box}; use hyperion_stats::ParallelStats; use rand::Rng; diff --git a/crates/hyperion-text/Cargo.toml b/crates/hyperion-text/Cargo.toml index d4e9c55c..21c67880 100644 --- a/crates/hyperion-text/Cargo.toml +++ b/crates/hyperion-text/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["edition2024"] + [dependencies] serde = {version = "1.0.214", features = ["derive"]} serde_json = "1.0.128" @@ -10,7 +12,7 @@ workspace = true [package] authors = ["Andrew Gazelka "] -edition = "2021" +edition = "2024" name = "hyperion-text" publish = false readme = "README.md" diff --git a/crates/hyperion-text/src/color.rs b/crates/hyperion-text/src/color.rs index 2ced8209..b86dc74a 100644 --- a/crates/hyperion-text/src/color.rs +++ b/crates/hyperion-text/src/color.rs @@ -2,7 +2,7 @@ use std::{fmt, hash::Hash}; -use serde::{de::Visitor, Deserialize, Deserializer, Serialize, Serializer}; +use serde::{Deserialize, Deserializer, Serialize, Serializer, de::Visitor}; use thiserror::Error; /// Text color diff --git a/crates/hyperion-text/src/lib.rs b/crates/hyperion-text/src/lib.rs index fba8f783..0dafd942 100644 --- a/crates/hyperion-text/src/lib.rs +++ b/crates/hyperion-text/src/lib.rs @@ -1,7 +1,7 @@ use std::{borrow::Cow, io::Write}; use serde::{Deserialize, Serialize}; -use valence_protocol::{anyhow, anyhow::Context, Bounded, Encode}; +use valence_protocol::{Bounded, Encode, anyhow, anyhow::Context}; use crate::{ color::Color, diff --git a/crates/hyperion-utils/Cargo.toml b/crates/hyperion-utils/Cargo.toml index 9aa87a09..981348bb 100644 --- a/crates/hyperion-utils/Cargo.toml +++ b/crates/hyperion-utils/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["edition2024"] + [dependencies] flecs_ecs.workspace = true @@ -6,7 +8,7 @@ workspace = true [package] authors = ["Andrew Gazelka "] -edition = "2021" +edition = "2024" name = "hyperion-utils" publish = false readme = "README.md" diff --git a/crates/hyperion/Cargo.toml b/crates/hyperion/Cargo.toml index 7834ee6a..2017fdbc 100644 --- a/crates/hyperion/Cargo.toml +++ b/crates/hyperion/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["edition2024"] + [[bench]] harness = false name = "set" @@ -85,7 +87,7 @@ workspace = true [package] authors = ["Andrew Gazelka "] -edition = "2021" +edition = "2024" name = "hyperion" publish = false readme = "README.md" diff --git a/crates/hyperion/benches/atomic.rs b/crates/hyperion/benches/atomic.rs index eb9cf0f4..a46c7f0f 100644 --- a/crates/hyperion/benches/atomic.rs +++ b/crates/hyperion/benches/atomic.rs @@ -5,7 +5,7 @@ use std::hint::black_box; use divan::Bencher; use flecs_ecs::prelude::World; use hyperion::{ - storage::{raw::RawQueue, ThreadHeaplessVec, ThreadLocalSoaVec, ThreadLocalVec}, + storage::{ThreadHeaplessVec, ThreadLocalSoaVec, ThreadLocalVec, raw::RawQueue}, util::SendableRef, }; diff --git a/crates/hyperion/src/common/mod.rs b/crates/hyperion/src/common/mod.rs index c87bca35..38bbeded 100644 --- a/crates/hyperion/src/common/mod.rs +++ b/crates/hyperion/src/common/mod.rs @@ -1,6 +1,6 @@ //! Defined the [`Global`] struct which is used to store global data which defines a [`crate::Hyperion`] use std::{ - sync::{atomic::AtomicUsize, Arc}, + sync::{Arc, atomic::AtomicUsize}, time::Duration, }; diff --git a/crates/hyperion/src/common/util/mojang.rs b/crates/hyperion/src/common/util/mojang.rs index 02204989..f2bd1e00 100644 --- a/crates/hyperion/src/common/util/mojang.rs +++ b/crates/hyperion/src/common/util/mojang.rs @@ -2,12 +2,12 @@ use std::{sync::Arc, time::Duration}; -use anyhow::{bail, Context}; +use anyhow::{Context, bail}; use flecs_ecs::macros::Component; use serde_json::Value; use tokio::{ sync::Semaphore, - time::{interval, MissedTickBehavior}, + time::{MissedTickBehavior, interval}, }; use tracing::warn; use uuid::Uuid; @@ -73,31 +73,25 @@ impl MojangClient { let rate_limit = Arc::new(Semaphore::new(provider.max_requests())); let interval_duration = provider.interval(); - tokio::task::Builder::new() - .name("reset_rate_limit") - .spawn_on( - { - let rate_limit = Arc::downgrade(&rate_limit); - let max_requests = provider.max_requests(); - async move { - let mut interval = interval(interval_duration); - interval.set_missed_tick_behavior(MissedTickBehavior::Delay); - - loop { - interval.tick().await; - - let Some(rate_limit) = rate_limit.upgrade() else { - return; - }; - - let available = rate_limit.available_permits(); - rate_limit.add_permits(max_requests - available); - } - } - }, - tasks.handle(), - ) - .unwrap(); + tasks.spawn({ + let rate_limit = Arc::downgrade(&rate_limit); + let max_requests = provider.max_requests(); + async move { + let mut interval = interval(interval_duration); + interval.set_missed_tick_behavior(MissedTickBehavior::Delay); + + loop { + interval.tick().await; + + let Some(rate_limit) = rate_limit.upgrade() else { + return; + }; + + let available = rate_limit.available_permits(); + rate_limit.add_permits(max_requests - available); + } + } + }); Self { req: reqwest::Client::new(), diff --git a/crates/hyperion/src/common/util/tracing_ext.rs b/crates/hyperion/src/common/util/tracing_ext.rs index fbd2e121..22188d74 100644 --- a/crates/hyperion/src/common/util/tracing_ext.rs +++ b/crates/hyperion/src/common/util/tracing_ext.rs @@ -1,4 +1,4 @@ -use flecs_ecs::core::{builder, ComponentId, EntityView, QueryTuple, SystemAPI}; +use flecs_ecs::core::{ComponentId, EntityView, QueryTuple, SystemAPI, builder}; use tracing::Span; // SystemAPI<'a, P, T>: Builder<'a> + private::internal_SystemAPI<'a, P, T> // where diff --git a/crates/hyperion/src/egress/metadata.rs b/crates/hyperion/src/egress/metadata.rs index 328bfc13..5e302bea 100644 --- a/crates/hyperion/src/egress/metadata.rs +++ b/crates/hyperion/src/egress/metadata.rs @@ -1,7 +1,7 @@ //! Utilities for working with the Entity Metadata packet. use ouroboros::self_referencing; -use valence_protocol::{packets::play, Encode, RawBytes, VarInt}; +use valence_protocol::{Encode, RawBytes, VarInt, packets::play}; #[self_referencing] pub struct ShowAll { diff --git a/crates/hyperion/src/egress/mod.rs b/crates/hyperion/src/egress/mod.rs index c4d8ca91..1c0477ed 100644 --- a/crates/hyperion/src/egress/mod.rs +++ b/crates/hyperion/src/egress/mod.rs @@ -3,7 +3,7 @@ use flecs_ecs::prelude::*; use hyperion_proto::{Flush, ServerToProxyMessage, UpdatePlayerChunkPositions}; use rkyv::util::AlignedVec; use tracing::{error, info_span}; -use valence_protocol::{packets::play, VarInt}; +use valence_protocol::{VarInt, packets::play}; use crate::{net::Compose, simulation::EgressComm}; @@ -21,7 +21,7 @@ use sync_entity_state::EntityStateSyncModule; use crate::{ ingress::GametickSpan, net::NetworkStreamRef, - simulation::{blocks::Blocks, ChunkPosition}, + simulation::{ChunkPosition, blocks::Blocks}, system_registry::SystemId, }; diff --git a/crates/hyperion/src/egress/player_join/list.rs b/crates/hyperion/src/egress/player_join/list.rs index 40d8b3de..d6d087d6 100644 --- a/crates/hyperion/src/egress/player_join/list.rs +++ b/crates/hyperion/src/egress/player_join/list.rs @@ -2,7 +2,7 @@ use std::{borrow::Cow, io::Write}; use bitfield_struct::bitfield; use uuid::Uuid; -use valence_protocol::{profile::Property, Decode, Encode, GameMode, Packet, VarInt}; +use valence_protocol::{Decode, Encode, GameMode, Packet, VarInt, profile::Property}; use valence_text::Text; #[derive(Clone, Debug, Packet)] diff --git a/crates/hyperion/src/egress/player_join/mod.rs b/crates/hyperion/src/egress/player_join/mod.rs index 07649fc8..72fd4ae3 100644 --- a/crates/hyperion/src/egress/player_join/mod.rs +++ b/crates/hyperion/src/egress/player_join/mod.rs @@ -7,15 +7,14 @@ use hyperion_utils::EntityExt; use rayon::iter::{IntoParallelIterator, ParallelIterator}; use tracing::{info, instrument}; use valence_protocol::{ + ByteAngle, GameMode, Ident, PacketEncoder, RawBytes, VarInt, Velocity, game_mode::OptGameMode, ident, packets::play::{ - self, + self, GameJoinS2c, player_position_look_s2c::PlayerPositionLookFlags, team_s2c::{CollisionRule, Mode, NameTagVisibility, TeamColor, TeamFlags}, - GameJoinS2c, }, - ByteAngle, GameMode, Ident, PacketEncoder, RawBytes, VarInt, Velocity, }; use valence_registry::{BiomeRegistry, RegistryCodec}; use valence_server::entity::EntityKind; @@ -32,13 +31,13 @@ use crate::{ ingress::PendingRemove, net::{Compose, DataBundle, NetworkStreamRef}, simulation::{ - command::{get_command_packet, Command, ROOT_COMMAND}, + Comms, InGameName, Position, Uuid, Yaw, + command::{Command, ROOT_COMMAND, get_command_packet}, metadata::{EntityFlags, MetadataBuilder}, skin::PlayerSkin, util::registry_codec_raw, - Comms, InGameName, Position, Uuid, Yaw, }, - system_registry::{SystemId, PLAYER_JOINS}, + system_registry::{PLAYER_JOINS, SystemId}, util::{SendableQuery, SendableRef}, }; diff --git a/crates/hyperion/src/egress/stats.rs b/crates/hyperion/src/egress/stats.rs index 31a5e35e..bb307b91 100644 --- a/crates/hyperion/src/egress/stats.rs +++ b/crates/hyperion/src/egress/stats.rs @@ -3,7 +3,7 @@ use tracing::{error, info_span}; use crate::{ net::Compose, - simulation::{blocks::Blocks, PacketState}, + simulation::{PacketState, blocks::Blocks}, }; #[derive(Component)] diff --git a/crates/hyperion/src/egress/sync_chunks.rs b/crates/hyperion/src/egress/sync_chunks.rs index 82aed366..7e74e9ef 100644 --- a/crates/hyperion/src/egress/sync_chunks.rs +++ b/crates/hyperion/src/egress/sync_chunks.rs @@ -5,16 +5,16 @@ use flecs_ecs::prelude::*; use glam::IVec2; use tracing::{error, info_span}; use valence_protocol::{ - packets::play::{self}, ChunkPos, + packets::play::{self}, }; use crate::{ config::Config, net::{Compose, DataBundle, NetworkStreamRef}, simulation::{ - blocks::{Blocks, GetChunk}, ChunkPosition, PacketState, Position, + blocks::{Blocks, GetChunk}, }, system_registry::{GENERATE_CHUNK_CHANGES, SEND_FULL_LOADED_CHUNKS}, util::TracingExt, diff --git a/crates/hyperion/src/egress/sync_entity_state.rs b/crates/hyperion/src/egress/sync_entity_state.rs index c72dad7b..9a4fdebf 100644 --- a/crates/hyperion/src/egress/sync_entity_state.rs +++ b/crates/hyperion/src/egress/sync_entity_state.rs @@ -8,23 +8,23 @@ use hyperion_utils::EntityExt; use tracing::{error, info_span}; use valence_ident::ident; use valence_protocol::{ + ByteAngle, GameMode, RawBytes, VarInt, Velocity, game_mode::OptGameMode, packets::{play, play::entity_equipment_update_s2c::EquipmentEntry}, - ByteAngle, GameMode, RawBytes, VarInt, Velocity, }; use crate::{ + Prev, egress::metadata::show_all, - net::{agnostic, Compose, NetworkStreamRef}, + net::{Compose, NetworkStreamRef, agnostic}, simulation::{ + EntityReaction, Health, Pitch, Position, Yaw, animation::ActiveAnimation, metadata::{EntityFlags, MetadataBuilder, Pose}, - EntityReaction, Health, Pitch, Position, Yaw, }, storage::ThreadLocal, system_registry::SYNC_ENTITY_POSITION, util::TracingExt, - Prev, }; #[derive(Component)] diff --git a/crates/hyperion/src/ingress/mod.rs b/crates/hyperion/src/ingress/mod.rs index 12f46c3d..97157e2d 100644 --- a/crates/hyperion/src/ingress/mod.rs +++ b/crates/hyperion/src/ingress/mod.rs @@ -8,35 +8,34 @@ use serde_json::json; use sha2::Digest; use tracing::{error, info, info_span, span::EnteredSpan, trace, warn}; use valence_protocol::{ - packets, + Bounded, Packet, VarInt, packets, packets::{ handshaking::handshake_c2s::HandshakeNextState, login, login::LoginCompressionS2c, play, }, - Bounded, Packet, VarInt, }; use valence_text::IntoText; use crate::{ + Prev, egress::sync_chunks::ChunkSendQueue, net::{ - decoder::BorrowedPacketFrame, proxy::ReceiveState, Compose, NetworkStreamRef, - PacketDecoder, MINECRAFT_VERSION, PROTOCOL_VERSION, + Compose, MINECRAFT_VERSION, NetworkStreamRef, PROTOCOL_VERSION, PacketDecoder, + decoder::BorrowedPacketFrame, proxy::ReceiveState, }, runtime::AsyncRuntime, simulation::{ + AiTargetable, ChunkPosition, Comms, ConfirmBlockSequences, EntityReaction, EntitySize, + Health, IgnMap, ImmuneStatus, InGameName, PacketState, Pitch, Player, Position, + StreamLookup, Uuid, Yaw, animation::ActiveAnimation, blocks::Blocks, handlers::PacketSwitchQuery, metadata::{EntityFlags, Pose}, skin::PlayerSkin, - AiTargetable, ChunkPosition, Comms, ConfirmBlockSequences, EntityReaction, EntitySize, - Health, IgnMap, ImmuneStatus, InGameName, PacketState, Pitch, Player, Position, - StreamLookup, Uuid, Yaw, }, storage::{Events, GlobalEventHandlers, PlayerJoinServer, SkinHandler}, - system_registry::{SystemId, RECV_DATA, REMOVE_PLAYER_FROM_VISIBILITY}, - util::{mojang::MojangClient, SendableRef, TracingExt}, - Prev, + system_registry::{RECV_DATA, REMOVE_PLAYER_FROM_VISIBILITY, SystemId}, + util::{SendableRef, TracingExt, mojang::MojangClient}, }; #[derive(Component, Debug)] @@ -134,27 +133,21 @@ fn process_login( let skins = comms.skins_tx.clone(); let id = entity.id(); - tokio::task::Builder::new() - .name("player_join") - .spawn_on( - async move { - let skin = match PlayerSkin::from_uuid(uuid, &mojang, &skins_collection).await { - Ok(Some(skin)) => skin, - Err(e) => { - error!("failed to get skin {e}. Using empty skin"); - PlayerSkin::EMPTY - } - Ok(None) => { - error!("failed to get skin. Using empty skin"); - PlayerSkin::EMPTY - } - }; + tasks.spawn(async move { + let skin = match PlayerSkin::from_uuid(uuid, &mojang, &skins_collection).await { + Ok(Some(skin)) => skin, + Err(e) => { + error!("failed to get skin {e}. Using empty skin"); + PlayerSkin::EMPTY + } + Ok(None) => { + error!("failed to get skin. Using empty skin"); + PlayerSkin::EMPTY + } + }; - skins.send((id, skin)).unwrap(); - }, - tasks.handle(), - ) - .unwrap(); + skins.send((id, skin)).unwrap(); + }); let pkt = login::LoginSuccessS2c { uuid, diff --git a/crates/hyperion/src/lib.rs b/crates/hyperion/src/lib.rs index bb2ba89c..a9524ff3 100644 --- a/crates/hyperion/src/lib.rs +++ b/crates/hyperion/src/lib.rs @@ -19,7 +19,6 @@ #![feature(array_try_map)] #![feature(split_array)] #![feature(never_type)] -#![feature(f16)] #![feature(duration_constructors)] // todo: deny more and completely fix panics // #![deny( @@ -41,7 +40,7 @@ pub const CHUNK_HEIGHT_SPAN: u32 = 384; // 512; // usually 384 use std::{alloc::Allocator, cell::RefCell, fmt::Debug, io::Write, net::ToSocketAddrs, sync::Arc}; -use anyhow::{bail, Context}; +use anyhow::{Context, bail}; use derive_more::{Deref, DerefMut}; use egress::EgressModule; use flecs_ecs::prelude::*; @@ -49,9 +48,9 @@ pub use glam; use glam::IVec2; use ingress::IngressModule; #[cfg(unix)] -use libc::{getrlimit, setrlimit, RLIMIT_NOFILE}; +use libc::{RLIMIT_NOFILE, getrlimit, setrlimit}; use libdeflater::CompressionLvl; -use simulation::{blocks::Blocks, util::generate_biome_registry, Comms, SimModule, StreamLookup}; +use simulation::{Comms, SimModule, StreamLookup, blocks::Blocks, util::generate_biome_registry}; use storage::{Events, GlobalEventHandlers, LocalDb, SkinHandler, ThreadLocal}; use tracing::info; use util::mojang::MojangClient; @@ -59,14 +58,14 @@ pub use uuid; // todo: slowly move more and more things to arbitrary module // and then eventually do not re-export valence_protocol pub use valence_protocol; +use valence_protocol::{CompressionThreshold, Encode, Packet}; pub use valence_protocol::{ - block::{BlockKind, BlockState}, ItemKind, ItemStack, Particle, + block::{BlockKind, BlockState}, }; -use valence_protocol::{CompressionThreshold, Encode, Packet}; use crate::{ - net::{proxy::init_proxy_comms, Compose, Compressors, IoBuf, MAX_PACKET_SIZE}, + net::{Compose, Compressors, IoBuf, MAX_PACKET_SIZE, proxy::init_proxy_comms}, runtime::AsyncRuntime, simulation::{Pitch, Yaw}, }; @@ -79,10 +78,10 @@ pub use valence_ident; pub use crate::simulation::command::CommandScope; use crate::{ ingress::{GametickSpan, PendingRemove}, - net::{proxy::ReceiveState, NetworkStreamRef, PacketDecoder}, + net::{NetworkStreamRef, PacketDecoder, proxy::ReceiveState}, simulation::{ - metadata::{EntityFlags, Pose}, EgressComm, EntitySize, IgnMap, PacketState, Player, + metadata::{EntityFlags, Pose}, }, util::mojang::ApiProvider, }; diff --git a/crates/hyperion/src/net/agnostic.rs b/crates/hyperion/src/net/agnostic.rs index 456840b3..27aff989 100644 --- a/crates/hyperion/src/net/agnostic.rs +++ b/crates/hyperion/src/net/agnostic.rs @@ -1,7 +1,7 @@ //! Agnostic networking primitives. Translates to correct protocol version. mod chat; -pub use chat::{chat, Chat}; +pub use chat::{Chat, chat}; mod sound; -pub use sound::{sound, Sound, SoundBuilder}; +pub use sound::{Sound, SoundBuilder, sound}; diff --git a/crates/hyperion/src/net/decoder.rs b/crates/hyperion/src/net/decoder.rs index 2c073f59..6a947d88 100644 --- a/crates/hyperion/src/net/decoder.rs +++ b/crates/hyperion/src/net/decoder.rs @@ -3,11 +3,11 @@ use std::{ ops::{Index, RangeFull}, }; -use anyhow::{bail, ensure, Context}; +use anyhow::{Context, bail, ensure}; use bytes::Buf; use flecs_ecs::macros::Component; use valence_protocol::{ - var_int::VarIntDecodeError, CompressionThreshold, Decode, Packet, VarInt, MAX_PACKET_SIZE, + CompressionThreshold, Decode, MAX_PACKET_SIZE, Packet, VarInt, var_int::VarIntDecodeError, }; #[derive(Default)] diff --git a/crates/hyperion/src/net/encoder/mod.rs b/crates/hyperion/src/net/encoder/mod.rs index 96f49328..3b897fe7 100644 --- a/crates/hyperion/src/net/encoder/mod.rs +++ b/crates/hyperion/src/net/encoder/mod.rs @@ -16,7 +16,7 @@ use anyhow::ensure; use tracing::trace; use valence_protocol::{CompressionThreshold, Encode, VarInt}; -use crate::{net::MAX_PACKET_SIZE, storage::Buf, PacketBundle, ScratchBuffer}; +use crate::{PacketBundle, ScratchBuffer, net::MAX_PACKET_SIZE, storage::Buf}; mod util; diff --git a/crates/hyperion/src/net/encoder/util.rs b/crates/hyperion/src/net/encoder/util.rs index f36307f7..5db8955c 100644 --- a/crates/hyperion/src/net/encoder/util.rs +++ b/crates/hyperion/src/net/encoder/util.rs @@ -45,7 +45,7 @@ pub fn read_to_end( mod tests { use std::io::{Cursor, Read}; - use flate2::{read::ZlibEncoder, Compression}; + use flate2::{Compression, read::ZlibEncoder}; use crate::net::encoder::util::read_to_end; diff --git a/crates/hyperion/src/net/mod.rs b/crates/hyperion/src/net/mod.rs index aaf56001..fd26ab87 100644 --- a/crates/hyperion/src/net/mod.rs +++ b/crates/hyperion/src/net/mod.rs @@ -17,10 +17,10 @@ use libdeflater::CompressionLvl; use rkyv::util::AlignedVec; use crate::{ - net::encoder::{append_packet_without_compression, PacketEncoder}, + Global, PacketBundle, Scratch, Scratches, + net::encoder::{PacketEncoder, append_packet_without_compression}, storage::ThreadLocal, system_registry::SystemId, - Global, PacketBundle, Scratch, Scratches, }; pub mod agnostic; diff --git a/crates/hyperion/src/net/packets.rs b/crates/hyperion/src/net/packets.rs index 2e5102c7..cac3b010 100644 --- a/crates/hyperion/src/net/packets.rs +++ b/crates/hyperion/src/net/packets.rs @@ -2,11 +2,11 @@ use std::{borrow::Cow, io::Write}; use uuid::Uuid; use valence_protocol::{ + Decode, Encode, ItemStack, Packet, VarInt, packets::play::{ boss_bar_s2c::{BossBarColor, BossBarDivision, BossBarFlags}, entity_equipment_update_s2c::EquipmentEntry, }, - Decode, Encode, ItemStack, Packet, VarInt, }; #[derive(Clone, PartialEq, Debug, Packet)] diff --git a/crates/hyperion/src/net/proxy.rs b/crates/hyperion/src/net/proxy.rs index 7a9df7b6..71a9dc4a 100644 --- a/crates/hyperion/src/net/proxy.rs +++ b/crates/hyperion/src/net/proxy.rs @@ -73,95 +73,81 @@ async fn inner( Err(e) => panic!("Failed to bind to address {socket}: {e}"), }; - tokio::task::Builder::new() - .name("proxy_listener") - .spawn( - async move { - loop { - let (socket, _) = listener.accept().await.unwrap(); - socket.set_nodelay(true).unwrap(); - - let addr = socket.peer_addr().unwrap(); - - info!("Proxy connection established on {addr}"); - - let shared = shared.clone(); - - let (read, mut write) = socket.into_split(); - - let proxy_writer_task = tokio::task::Builder::new() - .name("proxy_writer") - .spawn(async move { - while let Some(bytes) = server_to_proxy.recv().await { - if write.write_all(&bytes).await.is_err() { - error!("error writing to proxy"); - return server_to_proxy; - } + tokio::spawn( + async move { + loop { + let (socket, _) = listener.accept().await.unwrap(); + socket.set_nodelay(true).unwrap(); + + let addr = socket.peer_addr().unwrap(); + + info!("Proxy connection established on {addr}"); + + let shared = shared.clone(); + + let (read, mut write) = socket.into_split(); + + let proxy_writer_task = tokio::spawn(async move { + while let Some(bytes) = server_to_proxy.recv().await { + if write.write_all(&bytes).await.is_err() { + error!("error writing to proxy"); + return server_to_proxy; + } + } + + warn!("proxy shut down"); + + server_to_proxy + }); + + tokio::spawn(async move { + let mut reader = ProxyReader::new(read); + + loop { + let buffer = match reader.next_server_packet_buffer().await { + Ok(message) => message, + Err(err) => { + error!("failed to process packet {err:?}"); + return; } + }; + + let result = unsafe { + rkyv::access_unchecked::>(&buffer) + }; - warn!("proxy shut down"); - - server_to_proxy - }) - .unwrap(); - - tokio::task::Builder::new() - .name("proxy_reader") - .spawn(async move { - let mut reader = ProxyReader::new(read); - - loop { - let buffer = match reader.next_server_packet_buffer().await { - Ok(message) => message, - Err(err) => { - error!("failed to process packet {err:?}"); - return; - } - }; - - let result = unsafe { - rkyv::access_unchecked::>( - &buffer, - ) - }; - - match result { - ArchivedProxyToServerMessage::PlayerConnect(message) => { - let Ok(stream) = - rkyv::deserialize::(&message.stream); - - shared.lock().player_connect.push(stream); - } - ArchivedProxyToServerMessage::PlayerDisconnect(message) => { - let Ok(stream) = - rkyv::deserialize::(&message.stream); - shared.lock().player_disconnect.push(stream); - } - ArchivedProxyToServerMessage::PlayerPackets(message) => { - let Ok(stream) = - rkyv::deserialize::(&message.stream); - - shared - .lock() - .packets - .entry(stream) - .or_default() - .extend_from_slice(&message.data); - } - } + match result { + ArchivedProxyToServerMessage::PlayerConnect(message) => { + let Ok(stream) = rkyv::deserialize::(&message.stream); + + shared.lock().player_connect.push(stream); } - }) - .unwrap(); - - // todo: handle player disconnects on proxy shut down - // Ideally, we should design for there being multiple proxies, - // and all proxies should store all the players on them. - // Then we can disconnect all those players related to that proxy. - server_to_proxy = proxy_writer_task.await.unwrap(); - } - }, // .instrument(info_span!("proxy reader")), - ) - .unwrap(); + ArchivedProxyToServerMessage::PlayerDisconnect(message) => { + let Ok(stream) = rkyv::deserialize::(&message.stream); + shared.lock().player_disconnect.push(stream); + } + ArchivedProxyToServerMessage::PlayerPackets(message) => { + let Ok(stream) = rkyv::deserialize::(&message.stream); + + shared + .lock() + .packets + .entry(stream) + .or_default() + .extend_from_slice(&message.data); + } + } + } + }); + + // todo: handle player disconnects on proxy shut down + // Ideally, we should design for there being multiple proxies, + // and all proxies should store all the players on them. + // Then we can disconnect all those players related to that proxy. + server_to_proxy = proxy_writer_task.await.unwrap(); + } + }, // .instrument(info_span!("proxy reader")), + ); } /// A wrapper around [`ReceiveStateInner`] diff --git a/crates/hyperion/src/simulation/animation.rs b/crates/hyperion/src/simulation/animation.rs index d2ad345b..42621cba 100644 --- a/crates/hyperion/src/simulation/animation.rs +++ b/crates/hyperion/src/simulation/animation.rs @@ -1,6 +1,6 @@ use enumset::{EnumSet, EnumSetType}; use flecs_ecs::prelude::Component; -use valence_protocol::{packets::play::EntityAnimationS2c, VarInt}; +use valence_protocol::{VarInt, packets::play::EntityAnimationS2c}; #[derive(EnumSetType)] #[repr(u8)] diff --git a/crates/hyperion/src/simulation/blocks/chunk/packet.rs b/crates/hyperion/src/simulation/blocks/chunk/packet.rs index f3fa72f4..ca5b517a 100644 --- a/crates/hyperion/src/simulation/blocks/chunk/packet.rs +++ b/crates/hyperion/src/simulation/blocks/chunk/packet.rs @@ -2,16 +2,16 @@ use std::io::Write; use glam::IVec2; use valence_protocol::{ - packets::play::{chunk_delta_update_s2c::ChunkDeltaUpdateEntry, ChunkDeltaUpdateS2c}, ChunkSectionPos, Encode, Packet, VarInt, + packets::play::{ChunkDeltaUpdateS2c, chunk_delta_update_s2c::ChunkDeltaUpdateEntry}, }; use crate::{ + PacketBundle, simulation::blocks::{ chunk::{Column, START_Y}, loader::parse::section::Section, }, - PacketBundle, }; #[derive(derive_more::Debug)] diff --git a/crates/hyperion/src/simulation/blocks/frame.rs b/crates/hyperion/src/simulation/blocks/frame.rs index a3c55285..3143edb4 100644 --- a/crates/hyperion/src/simulation/blocks/frame.rs +++ b/crates/hyperion/src/simulation/blocks/frame.rs @@ -3,7 +3,7 @@ use glam::{IVec2, IVec3}; use ndarray::ArrayView3; use valence_generated::block::BlockState; -use crate::simulation::blocks::{chunk::START_Y, Blocks}; +use crate::simulation::blocks::{Blocks, chunk::START_Y}; impl Blocks { #[deprecated = "this is called automatically"] diff --git a/crates/hyperion/src/simulation/blocks/loader/mod.rs b/crates/hyperion/src/simulation/blocks/loader/mod.rs index bb4c7462..366bc453 100644 --- a/crates/hyperion/src/simulation/blocks/loader/mod.rs +++ b/crates/hyperion/src/simulation/blocks/loader/mod.rs @@ -1,6 +1,6 @@ use std::{borrow::Cow, cell::RefCell, io::Write, sync::Arc}; -use anyhow::{bail, Context}; +use anyhow::{Context, bail}; use bytes::BytesMut; use glam::IVec2; use hyperion_nerd_font::NERD_ROCKET; @@ -10,20 +10,20 @@ use parse::ColumnData; use rustc_hash::FxHashSet; use tracing::{debug, warn}; use valence_generated::block::BlockState; -use valence_nbt::{compound, List}; -use valence_protocol::{packets::play, ChunkPos, CompressionThreshold, FixedArray}; +use valence_nbt::{List, compound}; +use valence_protocol::{ChunkPos, CompressionThreshold, FixedArray, packets::play}; use valence_registry::RegistryIdx; -use valence_server::layer::chunk::{bit_width, BiomeContainer, Chunk}; +use valence_server::layer::chunk::{BiomeContainer, Chunk, bit_width}; pub mod parse; use super::{chunk::Column, shared::WorldShared}; use crate::{ + CHUNK_HEIGHT_SPAN, Scratch, net::encoder::PacketEncoder, runtime::AsyncRuntime, simulation::{blocks::loader::parse::section::Section, util::heightmap}, storage::BitStorage, - Scratch, CHUNK_HEIGHT_SPAN, }; struct TasksState { @@ -73,25 +73,19 @@ impl ChunkLoaderHandle { pub fn launch_manager(shared: Arc, runtime: &AsyncRuntime) -> ChunkLoaderHandle { let (tx_load_chunk_requests, rx_load_chunk_requests) = tokio::sync::mpsc::unbounded_channel(); - tokio::task::Builder::new() - .name("launch_manager") - .spawn_on( - { - let runtime = runtime.clone(); - async move { - ChunkLoader { - rx_load_chunk_requests, - received_request: FxHashSet::default(), - shared, - runtime, - } - .run() - .await; - } - }, - runtime.handle(), - ) - .unwrap(); + runtime.spawn({ + let runtime = runtime.clone(); + async move { + ChunkLoader { + rx_load_chunk_requests, + received_request: FxHashSet::default(), + shared, + runtime, + } + .run() + .await; + } + }); ChunkLoaderHandle { tx_load_chunk_requests, diff --git a/crates/hyperion/src/simulation/blocks/loader/parse.rs b/crates/hyperion/src/simulation/blocks/loader/parse.rs index 507131cc..a25468d4 100644 --- a/crates/hyperion/src/simulation/blocks/loader/parse.rs +++ b/crates/hyperion/src/simulation/blocks/loader/parse.rs @@ -7,7 +7,7 @@ use valence_generated::block::{BlockKind, BlockState, PropName, PropValue}; use valence_nbt::{Compound, List, Value}; use valence_protocol::Ident; use valence_registry::biome::BiomeId; -use valence_server::layer::chunk::{check_biome_oob, check_block_oob, check_section_oob, Chunk}; +use valence_server::layer::chunk::{Chunk, check_biome_oob, check_block_oob, check_section_oob}; use crate::simulation::blocks::loader::parse::section::Section; diff --git a/crates/hyperion/src/simulation/blocks/manager.rs b/crates/hyperion/src/simulation/blocks/manager.rs index b68029e2..19173978 100644 --- a/crates/hyperion/src/simulation/blocks/manager.rs +++ b/crates/hyperion/src/simulation/blocks/manager.rs @@ -32,13 +32,7 @@ impl RegionManager { let root = save.join("region"); let (sender, receiver) = mpsc::channel(100); - tokio::task::Builder::new() - .name("region_manager") - .spawn_on( - RegionManagerTask::new(root.clone(), receiver).run(), - runtime.handle(), - ) - .unwrap(); + runtime.spawn(RegionManagerTask::new(root.clone(), receiver).run()); Ok(Self { root, sender }) } diff --git a/crates/hyperion/src/simulation/blocks/mod.rs b/crates/hyperion/src/simulation/blocks/mod.rs index 1cb3c6b2..19dd9cfa 100644 --- a/crates/hyperion/src/simulation/blocks/mod.rs +++ b/crates/hyperion/src/simulation/blocks/mod.rs @@ -7,7 +7,7 @@ use chunk::Column; use flecs_ecs::{core::Entity, macros::Component}; use glam::{IVec2, IVec3}; use indexmap::IndexMap; -use loader::{launch_manager, ChunkLoaderHandle}; +use loader::{ChunkLoaderHandle, launch_manager}; use roaring::RoaringBitmap; use rustc_hash::FxBuildHasher; use shared::WorldShared; @@ -16,7 +16,7 @@ use valence_generated::block::BlockState; use valence_registry::BiomeRegistry; use valence_server::layer::chunk::Chunk; -use crate::{runtime::AsyncRuntime, CHUNK_HEIGHT_SPAN}; +use crate::{CHUNK_HEIGHT_SPAN, runtime::AsyncRuntime}; pub mod chunk; diff --git a/crates/hyperion/src/simulation/blocks/shared.rs b/crates/hyperion/src/simulation/blocks/shared.rs index 63dbcfce..daf9426d 100644 --- a/crates/hyperion/src/simulation/blocks/shared.rs +++ b/crates/hyperion/src/simulation/blocks/shared.rs @@ -3,7 +3,7 @@ use std::collections::BTreeMap; use anyhow::Context; use tokio::runtime::Runtime; use valence_protocol::Ident; -use valence_registry::{biome::BiomeId, BiomeRegistry}; +use valence_registry::{BiomeRegistry, biome::BiomeId}; use super::manager::RegionManager; diff --git a/crates/hyperion/src/simulation/command.rs b/crates/hyperion/src/simulation/command.rs index c5396916..5e6636c5 100644 --- a/crates/hyperion/src/simulation/command.rs +++ b/crates/hyperion/src/simulation/command.rs @@ -6,8 +6,8 @@ use rustc_hash::FxHashMap; use tracing::warn; pub use valence_protocol::packets::play::command_tree_s2c::Parser; use valence_protocol::{ - packets::play::command_tree_s2c::{Node, NodeData}, VarInt, + packets::play::command_tree_s2c::{Node, NodeData}, }; #[derive(Component)] diff --git a/crates/hyperion/src/simulation/handlers.rs b/crates/hyperion/src/simulation/handlers.rs index b5a3f3fd..2dcfd955 100644 --- a/crates/hyperion/src/simulation/handlers.rs +++ b/crates/hyperion/src/simulation/handlers.rs @@ -2,7 +2,7 @@ use std::borrow::Cow; -use anyhow::{bail, Context}; +use anyhow::{Context, bail}; use bvh_region::aabb::Aabb; use flecs_ecs::core::{Entity, EntityView, World}; use glam::{IVec3, Vec3}; @@ -10,26 +10,25 @@ use hyperion_utils::EntityExt; use tracing::{info, instrument, trace, warn}; use valence_generated::block::{BlockKind, BlockState, PropName}; use valence_protocol::{ - nbt, + Decode, Hand, Packet, VarInt, nbt, packets::play::{ self, click_slot_c2s::SlotChange, client_command_c2s::ClientCommand, player_action_c2s::PlayerAction, player_interact_entity_c2s::EntityInteraction, player_position_look_s2c::PlayerPositionLookFlags, }, - Decode, Hand, Packet, VarInt, }; use valence_text::IntoText; use super::{ + ConfirmBlockSequences, EntitySize, Position, animation::{self, ActiveAnimation}, block_bounds, blocks::Blocks, metadata::Pose, - ConfirmBlockSequences, EntitySize, Position, }; use crate::{ - net::{decoder::BorrowedPacketFrame, Compose, NetworkStreamRef}, - simulation::{aabb, event, event::PluginMessage, Pitch, Yaw}, + net::{Compose, NetworkStreamRef, decoder::BorrowedPacketFrame}, + simulation::{Pitch, Yaw, aabb, event, event::PluginMessage}, storage::Events, system_registry::SystemId, }; @@ -50,8 +49,8 @@ fn full(query: &mut PacketSwitchQuery<'_>, mut data: &[u8]) -> anyhow::Result<() let position = position.as_vec3(); change_position_or_correct_client(query, position); - query.yaw.yaw = yaw as f16; - query.pitch.pitch = pitch as f16; + query.yaw.yaw = yaw; + query.pitch.pitch = pitch; Ok(()) } @@ -168,8 +167,8 @@ fn look_and_on_ground(mut data: &[u8], query: &mut PacketSwitchQuery<'_>) -> any let play::LookAndOnGroundC2s { yaw, pitch, .. } = pkt; - **query.yaw = yaw as f16; - **query.pitch = pitch as f16; + **query.yaw = yaw; + **query.pitch = pitch; Ok(()) } @@ -502,7 +501,7 @@ pub fn custom_payload( let event = PluginMessage { channel: borrow, - data: packet.data.0 .0, + data: packet.data.0.0, }; query.events.push(event, query.world); diff --git a/crates/hyperion/src/simulation/metadata/mod.rs b/crates/hyperion/src/simulation/metadata/mod.rs index 22bfa6b2..1eab11b0 100644 --- a/crates/hyperion/src/simulation/metadata/mod.rs +++ b/crates/hyperion/src/simulation/metadata/mod.rs @@ -186,13 +186,13 @@ impl Deref for MetadataView<'_> { type Target = [u8]; fn deref(&self) -> &Self::Target { - &self.0 .0[..] + &self.0.0[..] } } impl Drop for MetadataView<'_> { fn drop(&mut self) { - self.0 .0.clear(); + self.0.0.clear(); } } diff --git a/crates/hyperion/src/simulation/mod.rs b/crates/hyperion/src/simulation/mod.rs index 41a1e40f..000292b6 100644 --- a/crates/hyperion/src/simulation/mod.rs +++ b/crates/hyperion/src/simulation/mod.rs @@ -1,6 +1,6 @@ use std::{borrow::Borrow, collections::HashMap, hash::Hash, sync::Arc}; -use bvh_region::{aabb::Aabb, HasAabb}; +use bvh_region::{HasAabb, aabb::Aabb}; use derive_more::{Deref, DerefMut, Display, From}; use flecs_ecs::prelude::*; use glam::{IVec2, IVec3, Vec3}; @@ -10,9 +10,9 @@ use skin::PlayerSkin; use uuid; use crate::{ + Global, Prev, simulation::{command::Command, metadata::Metadata}, storage::ThreadLocalVec, - Global, Prev, }; pub mod animation; @@ -297,7 +297,7 @@ pub struct Position { #[derive(Component, Copy, Clone, Debug, Deref, DerefMut, Default)] pub struct Yaw { - yaw: f16, + yaw: f32, } impl Display for Yaw { @@ -316,17 +316,17 @@ impl Display for Pitch { #[derive(Component, Copy, Clone, Debug, Deref, DerefMut, Default)] pub struct Pitch { - pitch: f16, + pitch: f32, } -const PLAYER_WIDTH: f16 = 0.6; -const PLAYER_HEIGHT: f16 = 1.8; +const PLAYER_WIDTH: f32 = 0.6; +const PLAYER_HEIGHT: f32 = 1.8; #[derive(Component, Copy, Clone, Debug)] #[meta] pub struct EntitySize { - pub half_width: f16, - pub height: f16, + pub half_width: f32, + pub height: f32, } impl Display for EntitySize { diff --git a/crates/hyperion/src/simulation/skin.rs b/crates/hyperion/src/simulation/skin.rs index 319a23cc..8d10f4d5 100644 --- a/crates/hyperion/src/simulation/skin.rs +++ b/crates/hyperion/src/simulation/skin.rs @@ -1,6 +1,6 @@ //! Constructs for obtaining a player's skin. use anyhow::Context; -use base64::{engine::general_purpose, Engine as _}; +use base64::{Engine as _, engine::general_purpose}; use flecs_ecs::macros::Component; use rkyv::Archive; use tracing::info; diff --git a/crates/hyperion/src/simulation/util.rs b/crates/hyperion/src/simulation/util.rs index 91bc132b..f6f24bc0 100644 --- a/crates/hyperion/src/simulation/util.rs +++ b/crates/hyperion/src/simulation/util.rs @@ -1,14 +1,14 @@ use std::{path::PathBuf, sync::LazyLock}; -use anyhow::{bail, Context}; +use anyhow::{Context, bail}; use flate2::bufread::GzDecoder; use serde::Deserialize; use tar::Archive; use tracing::info; -use valence_nbt::{value::ValueRef, Compound, Value}; +use valence_nbt::{Compound, Value, value::ValueRef}; use valence_registry::{ - biome::{Biome, BiomeEffects}, BiomeRegistry, + biome::{Biome, BiomeEffects}, }; use valence_server::Ident; diff --git a/crates/hyperion/src/storage/db.rs b/crates/hyperion/src/storage/db.rs index ecc8eb2d..7e948cb5 100644 --- a/crates/hyperion/src/storage/db.rs +++ b/crates/hyperion/src/storage/db.rs @@ -5,7 +5,7 @@ use std::path::Path; use byteorder::NativeEndian; use derive_more::Deref; use flecs_ecs::macros::Component; -use heed::{types, Database, Env, EnvOpenOptions}; +use heed::{Database, Env, EnvOpenOptions, types}; use uuid::Uuid; use crate::simulation::skin::{ArchivedPlayerSkin, PlayerSkin}; diff --git a/crates/hyperion/src/storage/event/queue/mod.rs b/crates/hyperion/src/storage/event/queue/mod.rs index c6356a31..fcce6260 100644 --- a/crates/hyperion/src/storage/event/queue/mod.rs +++ b/crates/hyperion/src/storage/event/queue/mod.rs @@ -1,7 +1,7 @@ use std::marker::PhantomData; use flecs_ecs::{ - core::{flecs, ComponentId, ComponentType, DataComponent, Struct, World, WorldGet}, + core::{ComponentId, ComponentType, DataComponent, Struct, World, WorldGet, flecs}, macros::Component, }; diff --git a/events/proof-of-concept/Cargo.toml b/events/proof-of-concept/Cargo.toml index 68624d1a..b72aacab 100644 --- a/events/proof-of-concept/Cargo.toml +++ b/events/proof-of-concept/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["edition2024"] + [dependencies] # console-subscriber = "0.4.0" clap = {workspace = true, features = ["derive"]} @@ -30,7 +32,7 @@ workspace = true [package] authors = ["Andrew Gazelka "] -edition = "2021" +edition = "2024" name = "proof-of-concept" publish = false readme = "README.md" diff --git a/events/proof-of-concept/src/lib.rs b/events/proof-of-concept/src/lib.rs index a3d191bc..6041e237 100644 --- a/events/proof-of-concept/src/lib.rs +++ b/events/proof-of-concept/src/lib.rs @@ -9,7 +9,7 @@ use std::net::ToSocketAddrs; use flecs_ecs::prelude::*; -use hyperion::{simulation::Player, Hyperion}; +use hyperion::{Hyperion, simulation::Player}; use module::block::BlockModule; mod component; diff --git a/events/proof-of-concept/src/module/animation.rs b/events/proof-of-concept/src/module/animation.rs index 9c8ed3b0..f5509e61 100644 --- a/events/proof-of-concept/src/module/animation.rs +++ b/events/proof-of-concept/src/module/animation.rs @@ -1,9 +1,9 @@ use flecs_ecs::{ core::{QueryBuilderImpl, SystemAPI, TableIter, TermBuilderImpl, World}, - macros::{system, Component}, + macros::{Component, system}, prelude::Module, }; -use hyperion::{glam::IVec3, simulation::blocks::Blocks, BlockState}; +use hyperion::{BlockState, glam::IVec3, simulation::blocks::Blocks}; use ndarray::Array3; use tracing::trace_span; diff --git a/events/proof-of-concept/src/module/attack.rs b/events/proof-of-concept/src/module/attack.rs index 5dce0ca8..6f0b5838 100644 --- a/events/proof-of-concept/src/module/attack.rs +++ b/events/proof-of-concept/src/module/attack.rs @@ -3,25 +3,24 @@ use std::borrow::Cow; use compact_str::format_compact; use flecs_ecs::{ core::{ - flecs, EntityViewGet, QueryBuilderImpl, SystemAPI, TableIter, TermBuilderImpl, World, - WorldProvider, + EntityViewGet, QueryBuilderImpl, SystemAPI, TableIter, TermBuilderImpl, World, + WorldProvider, flecs, }, - macros::{system, Component}, + macros::{Component, system}, prelude::Module, }; use hyperion::{ net::{ - agnostic, + Compose, NetworkStreamRef, agnostic, packets::{BossBarAction, BossBarS2c}, - Compose, NetworkStreamRef, }, - simulation::{event, EntityReaction, Health, PacketState, Player, Position}, + simulation::{EntityReaction, Health, PacketState, Player, Position, event}, storage::EventQueue, system_registry::SystemId, util::TracingExt, uuid::Uuid, valence_protocol::{ - ident, + ItemKind, ItemStack, Particle, VarInt, ident, math::{DVec3, Vec3}, nbt, packets::{ @@ -31,7 +30,6 @@ use hyperion::{ entity_attributes_s2c::AttributeProperty, }, }, - ItemKind, ItemStack, Particle, VarInt, }, }; use hyperion_inventory::PlayerInventory; diff --git a/events/proof-of-concept/src/module/block.rs b/events/proof-of-concept/src/module/block.rs index 9a7b4c55..1e759527 100644 --- a/events/proof-of-concept/src/module/block.rs +++ b/events/proof-of-concept/src/module/block.rs @@ -5,11 +5,11 @@ use std::{ use flecs_ecs::{ core::{EntityViewGet, QueryBuilderImpl, SystemAPI, TableIter, TermBuilderImpl, World}, - macros::{system, Component}, + macros::{Component, system}, prelude::Module, }; use hyperion::{ - net::{agnostic, Compose, NetworkStreamRef}, + net::{Compose, NetworkStreamRef, agnostic}, simulation::{ blocks::{Blocks, EntityAndSequence}, event, @@ -17,12 +17,12 @@ use hyperion::{ storage::EventQueue, system_registry::SystemId, valence_protocol::{ + BlockPos, BlockState, ItemStack, Particle, VarInt, block::{PropName, PropValue}, ident, math::{DVec3, IVec3, Vec3}, packets::play, text::IntoText, - BlockPos, BlockState, ItemStack, Particle, VarInt, }, }; use hyperion_inventory::PlayerInventory; diff --git a/events/proof-of-concept/src/module/chat.rs b/events/proof-of-concept/src/module/chat.rs index 6dd5c591..424df05d 100644 --- a/events/proof-of-concept/src/module/chat.rs +++ b/events/proof-of-concept/src/module/chat.rs @@ -1,11 +1,11 @@ use flecs_ecs::{ - core::{flecs, EntityViewGet, QueryBuilderImpl, SystemAPI, TableIter, TermBuilderImpl, World}, - macros::{system, Component}, + core::{EntityViewGet, QueryBuilderImpl, SystemAPI, TableIter, TermBuilderImpl, World, flecs}, + macros::{Component, system}, prelude::Module, }; use hyperion::{ net::NetworkStreamRef, - simulation::{event, InGameName, Player, Position}, + simulation::{InGameName, Player, Position, event}, storage::EventQueue, system_registry::SystemId, valence_protocol::{packets::play, text::IntoText}, diff --git a/events/proof-of-concept/src/module/command.rs b/events/proof-of-concept/src/module/command.rs index f98502e1..2b186bb5 100644 --- a/events/proof-of-concept/src/module/command.rs +++ b/events/proof-of-concept/src/module/command.rs @@ -6,27 +6,27 @@ use hyperion::{ egress::player_join::{PlayerListActions, PlayerListEntry, PlayerListS2c}, net::{Compose, NetworkStreamRef}, simulation::{ + Health, IgnMap, InGameName, Position, Uuid, blocks::Blocks, - command::{add_command, cmd_with, get_root_command, Command, Parser}, + command::{Command, Parser, add_command, cmd_with, get_root_command}, event, metadata::EntityFlags, - Health, IgnMap, InGameName, Position, Uuid, }, storage::EventQueue, system_registry::SystemId, uuid, valence_ident::ident, valence_protocol::{ - self, + self, BlockState, GameMode, ItemKind, ItemStack, VarInt, game_mode::OptGameMode, math::IVec3, nbt, packets::play::{ - self, command_tree_s2c::StringArg, player_abilities_s2c::PlayerAbilitiesFlags, - player_position_look_s2c::PlayerPositionLookFlags, PlayerAbilitiesS2c, + self, PlayerAbilitiesS2c, command_tree_s2c::StringArg, + player_abilities_s2c::PlayerAbilitiesFlags, + player_position_look_s2c::PlayerPositionLookFlags, }, text::IntoText, - BlockState, GameMode, ItemKind, ItemStack, VarInt, }, }; use hyperion_inventory::PlayerInventory; diff --git a/events/proof-of-concept/src/module/command/parse.rs b/events/proof-of-concept/src/module/command/parse.rs index 9e0e8fee..c316511a 100644 --- a/events/proof-of-concept/src/module/command/parse.rs +++ b/events/proof-of-concept/src/module/command/parse.rs @@ -1,11 +1,11 @@ use nom::{ + IResult, Parser, branch::alt, bytes::complete::{tag, take_until, take_while1}, character::complete::space1, combinator::{map, map_res, opt}, number::complete::float, sequence::preceded, - IResult, Parser, }; #[derive(Debug, PartialEq, Eq, Copy, Clone)] diff --git a/events/proof-of-concept/src/module/level.rs b/events/proof-of-concept/src/module/level.rs index f74e93b8..468b3ebe 100644 --- a/events/proof-of-concept/src/module/level.rs +++ b/events/proof-of-concept/src/module/level.rs @@ -1,5 +1,5 @@ use flecs_ecs::{ - core::{flecs, World}, + core::{World, flecs}, macros::Component, prelude::Module, }; diff --git a/events/proof-of-concept/src/module/regeneration.rs b/events/proof-of-concept/src/module/regeneration.rs index 6df9d36d..d86cd15a 100644 --- a/events/proof-of-concept/src/module/regeneration.rs +++ b/events/proof-of-concept/src/module/regeneration.rs @@ -1,13 +1,13 @@ use flecs_ecs::{ - core::{flecs, QueryBuilderImpl, TermBuilderImpl, World}, - macros::{system, Component}, + core::{QueryBuilderImpl, TermBuilderImpl, World, flecs}, + macros::{Component, system}, prelude::Module, }; use hyperion::{ + Prev, net::Compose, simulation::{Health, Player}, util::TracingExt, - Prev, }; use tracing::info_span; diff --git a/events/proof-of-concept/src/module/spawn.rs b/events/proof-of-concept/src/module/spawn.rs index 373f13a3..c2861e40 100644 --- a/events/proof-of-concept/src/module/spawn.rs +++ b/events/proof-of-concept/src/module/spawn.rs @@ -1,16 +1,16 @@ use std::{cell::RefCell, rc::Rc}; use flecs_ecs::{ - core::{flecs, QueryBuilderImpl, SystemAPI, TermBuilderImpl, World}, - macros::{observer, Component}, + core::{QueryBuilderImpl, SystemAPI, TermBuilderImpl, World, flecs}, + macros::{Component, observer}, prelude::Module, }; use hyperion::{ runtime::AsyncRuntime, - simulation::{blocks::Blocks, Position, Uuid}, + simulation::{Position, Uuid, blocks::Blocks}, valence_protocol::{ - math::{IVec2, IVec3, Vec3}, BlockKind, + math::{IVec2, IVec3, Vec3}, }, }; use rustc_hash::FxHashMap; diff --git a/events/proof-of-concept/src/module/stats.rs b/events/proof-of-concept/src/module/stats.rs index 40d881bb..1e91b61c 100644 --- a/events/proof-of-concept/src/module/stats.rs +++ b/events/proof-of-concept/src/module/stats.rs @@ -1,6 +1,6 @@ use flecs_ecs::{ core::{QueryBuilderImpl, SystemAPI, TermBuilderImpl, World}, - macros::{system, Component}, + macros::{Component, system}, prelude::Module, }; use hyperion::{ diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 846fce20..feaacd24 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "nightly-2024-10-22" -components = ["rustfmt", "clippy"] +channel = "nightly-2024-11-03" +components = ["rustfmt", "clippy", "rustc-codegen-cranelift-preview"] profile = "minimal" diff --git a/rustfmt.toml b/rustfmt.toml index c833d770..01e4d0f2 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -2,7 +2,7 @@ combine_control_expr = true comment_width = 100 # https://lkml.org/lkml/2020/5/29/1038 condense_wildcard_suffixes = true control_brace_style = "AlwaysSameLine" -edition = "2021" +edition = "2024" format_code_in_doc_comments = true format_macro_bodies = true format_macro_matchers = true