From 5c746f0fb23b83488f742ceba0ccf2ad6e6810aa Mon Sep 17 00:00:00 2001 From: Katherine Kiefer Date: Thu, 6 Jun 2024 22:35:32 +1000 Subject: [PATCH] some stuff --- .github/workflows/build.yml | 42 +-- .github/workflows/check.yml | 34 +- .github/workflows/release.yml | 130 +++---- Cargo.lock | 492 ++++++++++++++++++-------- Cargo.toml | 36 +- crates/auxcallback/Cargo.toml | 1 + src/gas/mixture.rs | 3 +- src/lib.rs | 14 +- src/reaction.rs | 23 +- src/reaction/{hooks.rs => citadel.rs} | 12 +- src/reaction/yogs.rs | 98 +++++ src/turfs.rs | 11 +- src/turfs/groups.rs | 2 + src/turfs/katmos.rs | 13 +- src/turfs/processing.rs | 25 +- 15 files changed, 628 insertions(+), 308 deletions(-) rename src/reaction/{hooks.rs => citadel.rs} (97%) create mode 100644 src/reaction/yogs.rs diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8f8b6beb..51d6ff99 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,25 +1,25 @@ name: Linux build on: - push: - branches: [master] + push: + branches: [master] jobs: - linux-build: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - target: i686-unknown-linux-gnu - override: true + linux-build: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: i686-unknown-linux-gnu + override: true - - name: Install g++-multilib - run: | - sudo apt update - sudo apt install g++-multilib -y - - name: Build auxmos - run: cargo build --target=i686-unknown-linux-gnu --release --features "all_reaction_hooks katmos" - - uses: actions/upload-artifact@v2 - with: - name: Linux compile - path: target/i686-unknown-linux-gnu/release/libauxmos.* + - name: Install g++-multilib + run: | + sudo apt update + sudo apt install g++-multilib -y + - name: Build auxmos + run: cargo build --target=i686-unknown-linux-gnu --release --features "citadel_reactions katmos" + - uses: actions/upload-artifact@v2 + with: + name: Linux compile + path: target/i686-unknown-linux-gnu/release/libauxmos.* diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 5a744eb9..6a5e757b 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -1,21 +1,21 @@ name: Check compile on: pull_request jobs: - linux-build: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - target: i686-unknown-linux-gnu - override: true + linux-build: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: i686-unknown-linux-gnu + override: true - - name: Install g++-multilib - run: | - sudo apt update - sudo apt install g++-multilib -y - - name: Check formatting - run: cargo fmt --all -- --check - - name: Check auxmos build - run: cargo check --target=i686-unknown-linux-gnu --release --features "all_reaction_hooks katmos" + - name: Install g++-multilib + run: | + sudo apt update + sudo apt install g++-multilib -y + - name: Check formatting + run: cargo fmt --all -- --check + - name: Check auxmos build + run: cargo check --target=i686-unknown-linux-gnu --release --features "citadel_reactions katmos" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3ab144e7..71851ea2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,77 +1,77 @@ name: Build Release on: - release: - types: [published] + release: + types: [published] jobs: - release: - name: Build and Release - runs-on: ${{ matrix.os }} - strategy: - matrix: - include: - - os: ubuntu-20.04 - target_name: i686-unknown-linux-gnu - artifact_name: libauxmos.so - - os: windows-latest - target_name: i686-pc-windows-msvc - artifact_name: auxmos.dll - debug_pdb_name: auxmos.pdb - steps: - - name: Checkout - uses: actions/checkout@v1 + release: + name: Build and Release + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - os: ubuntu-20.04 + target_name: i686-unknown-linux-gnu + artifact_name: libauxmos.so + - os: windows-latest + target_name: i686-pc-windows-msvc + artifact_name: auxmos.dll + debug_pdb_name: auxmos.pdb + steps: + - name: Checkout + uses: actions/checkout@v1 - - name: Setup Toolchains (Windows) - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - target: i686-pc-windows-msvc - if: matrix.os == 'windows-latest' + - name: Setup Toolchains (Windows) + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: i686-pc-windows-msvc + if: matrix.os == 'windows-latest' - - name: Install g++ multilib - run: | - sudo dpkg --add-architecture i386 - sudo apt-get update - sudo apt-get install build-essential g++-multilib libc6-i386 libstdc++6:i386 - if: matrix.os == 'ubuntu-20.04' + - name: Install g++ multilib + run: | + sudo dpkg --add-architecture i386 + sudo apt-get update + sudo apt-get install build-essential g++-multilib libc6-i386 libstdc++6:i386 + if: matrix.os == 'ubuntu-20.04' - - name: Setup Toolchains (Ubuntu) - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - target: i686-unknown-linux-gnu - if: matrix.os == 'ubuntu-20.04' + - name: Setup Toolchains (Ubuntu) + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: i686-unknown-linux-gnu + if: matrix.os == 'ubuntu-20.04' - - name: Build auxmos (Windows) - uses: actions-rs/cargo@v1 - with: - toolchain: stable - command: build - args: --target i686-pc-windows-msvc --release --features "all_reaction_hooks katmos" - if: matrix.os == 'windows-latest' + - name: Build auxmos (Windows) + uses: actions-rs/cargo@v1 + with: + toolchain: stable + command: build + args: --target i686-pc-windows-msvc --release --features "citadel_reactions katmos" + if: matrix.os == 'windows-latest' - - name: Build auxmos (Ubuntu) - uses: actions-rs/cargo@v1 - with: - toolchain: stable - command: build - args: --target i686-unknown-linux-gnu --release --features "generic_fire_hook katmos" - if: matrix.os == 'ubuntu-20.04' + - name: Build auxmos (Ubuntu) + uses: actions-rs/cargo@v1 + with: + toolchain: stable + command: build + args: --target i686-unknown-linux-gnu --release --features "citadel_reactions katmos" + if: matrix.os == 'ubuntu-20.04' - - name: Upload binary to release - uses: svenstaro/upload-release-action@v1-release - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: target/${{ matrix.target_name }}/release/${{ matrix.artifact_name }} - asset_name: ${{ matrix.artifact_name }} - tag: ${{ github.ref }} + - name: Upload binary to release + uses: svenstaro/upload-release-action@v1-release + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: target/${{ matrix.target_name }}/release/${{ matrix.artifact_name }} + asset_name: ${{ matrix.artifact_name }} + tag: ${{ github.ref }} - - name: Upload debug informations to release - uses: svenstaro/upload-release-action@v1-release - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: target/${{ matrix.target_name }}/release/${{ matrix.debug_pdb_name }} - asset_name: ${{ matrix.debug_pdb_name }} - tag: ${{ github.ref }} - if: matrix.os == 'windows-latest' + - name: Upload debug informations to release + uses: svenstaro/upload-release-action@v1-release + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: target/${{ matrix.target_name }}/release/${{ matrix.debug_pdb_name }} + asset_name: ${{ matrix.debug_pdb_name }} + tag: ${{ github.ref }} + if: matrix.os == 'windows-latest' diff --git a/Cargo.lock b/Cargo.lock index c0d0083c..0db0e657 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -26,21 +26,21 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.16" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "atomic_float" -version = "0.1.0" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62af46d040ba9df09edc6528dae9d8e49f5f3e82f55b7d2ec31a733c38dbc49d" +checksum = "3c4b08ed8a30ff7320117c190eb4d73d47f0ac0c930ab853b8224cef7cd9a5e7" [[package]] name = "autocfg" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "auxcallback" @@ -50,6 +50,7 @@ dependencies = [ "coarsetime", "eyre", "flume", + "tracing", ] [[package]] @@ -59,7 +60,7 @@ dependencies = [ "ahash", "atomic_float", "auxcallback", - "bitflags 2.5.0", + "bitflags", "byondapi", "coarsetime", "dashmap", @@ -69,7 +70,7 @@ dependencies = [ "fxhash", "hashbrown", "indexmap", - "itertools", + "itertools 0.13.0", "lazy_static", "mimalloc", "nom", @@ -78,6 +79,9 @@ dependencies = [ "rayon", "simple-eyre", "tinyvec", + "tracing", + "tracing-subscriber", + "tracing-tracy", ] [[package]] @@ -86,10 +90,10 @@ version = "0.69.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" dependencies = [ - "bitflags 2.5.0", + "bitflags", "cexpr", "clang-sys", - "itertools", + "itertools 0.12.1", "lazy_static", "lazycell", "log", @@ -103,12 +107,6 @@ dependencies = [ "which", ] -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bitflags" version = "2.5.0" @@ -117,15 +115,15 @@ checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" [[package]] name = "bumpalo" -version = "3.15.4" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "byondapi" -version = "0.4.4" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d402a985fc5cd33b538172b2c4e8a0ff06bf965040e1a82bf321231b7196e16d" +checksum = "5525b530bee0e5daeb7b658b6b734fea77f50e6327be59983abf6dcc42440337" dependencies = [ "byondapi-macros", "byondapi-sys", @@ -168,9 +166,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cc" -version = "1.0.90" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" +checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" [[package]] name = "cexpr" @@ -189,9 +187,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clang-sys" -version = "1.7.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67523a3b4be3ce1989d607a828d036249522dd9c1c8de7f4dd2dae43a37369d1" +checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" dependencies = [ "glob", "libc", @@ -230,9 +228,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" [[package]] name = "dashmap" @@ -259,9 +257,9 @@ dependencies = [ [[package]] name = "either" -version = "1.10.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" [[package]] name = "equivalent" @@ -271,9 +269,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", "windows-sys", @@ -334,11 +332,25 @@ dependencies = [ "byteorder", ] +[[package]] +name = "generator" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "186014d53bc231d0090ef8d6f03e0920c54d85a5ed22f4f2f74315ec56cf83fb" +dependencies = [ + "cc", + "cfg-if", + "libc", + "log", + "rustversion", + "windows", +] + [[package]] name = "getrandom" -version = "0.2.13" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06fddc2749e0528d2813f95e050e87e52c8cbbae56223b9babf73b3e53b0cc6" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "js-sys", @@ -355,9 +367,9 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ "ahash", "allocator-api2", @@ -404,6 +416,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + [[package]] name = "js-sys" version = "0.3.69" @@ -427,9 +448,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.153" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libloading" @@ -438,14 +459,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" dependencies = [ "cfg-if", - "windows-targets 0.52.4", + "windows-targets", ] [[package]] name = "libmimalloc-sys" -version = "0.1.35" +version = "0.1.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3979b5c37ece694f1f5e51e7ecc871fdb0f517ed04ee45f88d15d6d553cb9664" +checksum = "0e7bb23d733dfcc8af652a78b7bf232f0e967710d044732185e561e47c0336b6" dependencies = [ "cc", "libc", @@ -453,15 +474,15 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "lock_api" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", @@ -473,6 +494,28 @@ version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +[[package]] +name = "loom" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "419e0dc8046cb947daa77eb95ae174acfbddb7673b4151f56d1eed8e93fbfaca" +dependencies = [ + "cfg-if", + "generator", + "scoped-tls", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + [[package]] name = "memchr" version = "2.7.2" @@ -481,9 +524,9 @@ checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" [[package]] name = "mimalloc" -version = "0.1.39" +version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa01922b5ea280a911e323e4d2fd24b7fe5cc4042e0d2cda3c40775cdc4bdc9c" +checksum = "e9186d86b79b52f4a77af65604b51225e8db1d6ee7e3f41aec1e40829c71a176" dependencies = [ "libmimalloc-sys", ] @@ -513,6 +556,16 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + [[package]] name = "num_enum" version = "0.7.2" @@ -540,11 +593,17 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + [[package]] name = "parking_lot" -version = "0.12.1" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" dependencies = [ "lock_api", "parking_lot_core", @@ -552,22 +611,22 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.9" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-targets 0.48.5", + "windows-targets", ] [[package]] name = "petgraph" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" +checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", "indexmap", @@ -615,11 +674,17 @@ dependencies = [ "siphasher", ] +[[package]] +name = "pin-project-lite" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + [[package]] name = "prettyplease" -version = "0.2.17" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d3928fb5db768cb86f891ff014f0144589297e3c6a1aba6ed7cecfdace270c7" +checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" dependencies = [ "proc-macro2", "syn", @@ -636,18 +701,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.79" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -689,11 +754,11 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.4.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" dependencies = [ - "bitflags 1.3.2", + "bitflags", ] [[package]] @@ -704,8 +769,17 @@ checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" dependencies = [ "aho-corasick", "memchr", - "regex-automata", - "regex-syntax", + "regex-automata 0.4.6", + "regex-syntax 0.8.3", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", ] [[package]] @@ -716,9 +790,15 @@ checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-syntax 0.8.3", ] +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + [[package]] name = "regex-syntax" version = "0.8.3" @@ -742,17 +822,23 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.32" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags 2.5.0", + "bitflags", "errno", "libc", "linux-raw-sys", "windows-sys", ] +[[package]] +name = "rustversion" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" + [[package]] name = "same-file" version = "1.0.6" @@ -762,6 +848,12 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + [[package]] name = "scopeguard" version = "1.2.0" @@ -770,9 +862,18 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "semver" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] [[package]] name = "shlex" @@ -813,15 +914,25 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.58" +version = "2.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" +checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] +[[package]] +name = "thread_local" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +dependencies = [ + "cfg-if", + "once_cell", +] + [[package]] name = "tinyvec" version = "1.6.0" @@ -839,9 +950,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "toml_datetime" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" [[package]] name = "toml_edit" @@ -854,12 +965,110 @@ dependencies = [ "winnow", ] +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", +] + +[[package]] +name = "tracing-tracy" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6024d04f84a69fd0d1dc1eee3a2b070bd246530a0582f9982ae487cb6c703614" +dependencies = [ + "tracing-core", + "tracing-subscriber", + "tracy-client", +] + +[[package]] +name = "tracy-client" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59fb931a64ff88984f86d3e9bcd1ae8843aa7fe44dd0f8097527bc172351741d" +dependencies = [ + "loom", + "once_cell", + "tracy-client-sys", +] + +[[package]] +name = "tracy-client-sys" +version = "0.22.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d104d610dfa9dd154535102cc9c6164ae1fa37842bc2d9e83f9ac82b0ae0882" +dependencies = [ + "cc", +] + [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + [[package]] name = "version_check" version = "0.9.4" @@ -975,11 +1184,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.6" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" dependencies = [ - "winapi", + "windows-sys", ] [[package]] @@ -989,127 +1198,106 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] -name = "windows-sys" -version = "0.52.0" +name = "windows" +version = "0.54.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +checksum = "9252e5725dbed82865af151df558e754e4a3c2c30818359eb17465f1346a1b49" dependencies = [ - "windows-targets 0.52.4", + "windows-core", + "windows-targets", ] [[package]] -name = "windows-targets" -version = "0.48.5" +name = "windows-core" +version = "0.54.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +checksum = "12661b9c89351d684a50a8a643ce5f608e20243b9fb84687800163429f161d65" dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", + "windows-result", + "windows-targets", ] [[package]] -name = "windows-targets" -version = "0.52.4" +name = "windows-result" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" +checksum = "749f0da9cc72d82e600d8d2e44cadd0b9eedb9038f71a1c58556ac1c5791813b" dependencies = [ - "windows_aarch64_gnullvm 0.52.4", - "windows_aarch64_msvc 0.52.4", - "windows_i686_gnu 0.52.4", - "windows_i686_msvc 0.52.4", - "windows_x86_64_gnu 0.52.4", - "windows_x86_64_gnullvm 0.52.4", - "windows_x86_64_msvc 0.52.4", + "windows-targets", ] [[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" +name = "windows-sys" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] [[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.4" +name = "windows-targets" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] [[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" +name = "windows_aarch64_gnullvm" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" [[package]] name = "windows_aarch64_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" [[package]] name = "windows_i686_gnu" -version = "0.48.5" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" [[package]] -name = "windows_i686_gnu" -version = "0.52.4" +name = "windows_i686_gnullvm" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" [[package]] name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" [[package]] name = "windows_x86_64_gnu" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" [[package]] name = "windows_x86_64_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "winnow" @@ -1122,18 +1310,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.32" +version = "0.7.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.32" +version = "0.7.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 28622fe7..5b487748 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,10 +2,11 @@ members = ["crates/*"] [workspace.dependencies] -byondapi = "0.4.4" +byondapi = "0.4.7" coarsetime = "0.1.34" flume = "0.11.0" eyre = "0.6.12" +tracing = "0.1.40" [package] name = "auxmos" @@ -16,7 +17,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] -default = ["turf_processing"] +default = ["turf_processing", "yogs_reactions"] zas_hooks = [] turf_processing = [] superconductivity = ["turf_processing"] @@ -24,16 +25,11 @@ fastmos = ["turf_processing"] katmos = ["fastmos"] katmos_slow_decompression = ["fastmos"] reaction_hooks = [] -plasma_fire_hook = ["reaction_hooks"] -trit_fire_hook = ["reaction_hooks"] -fusion_hook = ["reaction_hooks"] -generic_fire_hook = ["reaction_hooks"] -all_reaction_hooks = [ - "fusion_hook", - "trit_fire_hook", - "plasma_fire_hook", - "generic_fire_hook", -] +citadel_reactions = ["reaction_hooks"] +yogs_reactions = ["reaction_hooks"] + +# Tracing will expose this application to a local port, use with care +tracy = ["dep:tracing-tracy", "dep:tracing-subscriber", "dep:tracing"] [lib] crate-type = ["cdylib"] @@ -44,23 +40,27 @@ flume = { workspace = true } coarsetime = { workspace = true } eyre = { workspace = true } auxcallback = { path = "./crates/auxcallback" } -itertools = "0.12.1" +itertools = "0.13.0" rayon = "1.10.0" float-ord = "0.3.2" -parking_lot = "0.12.1" +parking_lot = "0.12.3" fxhash = "0.2.1" ahash = "0.8.11" lazy_static = "1.4.0" indexmap = { version = "2.2.6", features = ["rayon"] } dashmap = { version = "5.5.3", features = ["rayon"] } -hashbrown = "0.14.3" -atomic_float = "0.1.0" -petgraph = "0.6.4" +hashbrown = "0.14.5" +atomic_float = "1.0.0" +petgraph = "0.6.5" bitflags = "2.5.0" nom = "7.1.3" -mimalloc = { version = "0.1.39", default-features = false } +mimalloc = { version = "0.1.42", default-features = false } simple-eyre = "0.3.1" +tracing = { version = "0.1.40", optional = true } +tracing-tracy = { version = "0.11.0", optional = true } +tracing-subscriber = { version = "0.3.18", optional = true } + [dependencies.tinyvec] version = "1.6.0" features = ["rustc_1_57", "alloc"] diff --git a/crates/auxcallback/Cargo.toml b/crates/auxcallback/Cargo.toml index b5a0ed80..1b5685b1 100644 --- a/crates/auxcallback/Cargo.toml +++ b/crates/auxcallback/Cargo.toml @@ -14,3 +14,4 @@ byondapi = { workspace = true } flume = { workspace = true } coarsetime = { workspace = true } eyre = { workspace = true } +tracing = { workspace = true } diff --git a/src/gas/mixture.rs b/src/gas/mixture.rs index ce07ffd8..58e61034 100644 --- a/src/gas/mixture.rs +++ b/src/gas/mixture.rs @@ -22,6 +22,7 @@ use eyre::Result; type SpecificFireInfo = (usize, f32, f32); +#[derive(Debug)] struct GasCache(AtomicF32); impl Clone for GasCache { @@ -71,7 +72,7 @@ pub fn visibility_step(gas_amt: f32) -> u32 { /// processing no longer requires sleeping turfs. Instead, we're using /// a proper, fully-simulated FDM system, much like LINDA but without /// sleeping turfs. -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct Mixture { temperature: f32, pub volume: f32, diff --git a/src/lib.rs b/src/lib.rs index cb35a7d5..3f6aa80b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,7 +7,7 @@ mod reaction; mod parser; -use byondapi::{map::byond_length, prelude::*}; +use byondapi::prelude::*; use gas::{ amt_gases, constants, gas_idx_from_string, gas_idx_from_value, gas_idx_to_id, tot_gases, types, @@ -25,11 +25,19 @@ static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; #[byondapi::init] pub fn init_eyre() { simple_eyre::install().unwrap(); + #[cfg(feature = "tracy")] + { + use tracing_subscriber::layer::SubscriberExt; + + tracing::subscriber::set_global_default( + tracing_subscriber::registry().with(tracing_tracy::TracyLayer::default()), + ) + .expect("setup tracy layer"); + } } /// Args: (ms). Runs callbacks until time limit is reached. If time limit is omitted, runs all callbacks. #[byondapi::bind("/proc/process_atmos_callbacks")] -#[tracing::instrument] fn atmos_callback_handle(remaining: ByondValue) { auxcallback::callback_processing_hook(remaining) } @@ -391,7 +399,7 @@ fn scrub_into_hook(src: ByondValue, into: ByondValue, ratio_v: ByondValue, gas_l if !gas_list.is_list() { return Err(eyre::eyre!("Non-list gas_list passed to scrub_into!")); } - if byond_length(&gas_list)?.get_number()? as u32 == 0 { + if gas_list.builtin_length()?.get_number()? as u32 == 0 { return Ok(false.into()); } let gas_scrub_vec = gas_list diff --git a/src/reaction.rs b/src/reaction.rs index 8b6bdbbc..066dc86c 100644 --- a/src/reaction.rs +++ b/src/reaction.rs @@ -1,5 +1,8 @@ -#[cfg(feature = "reaction_hooks")] -mod hooks; +#[cfg(feature = "citadel_reactions")] +mod citadel; + +#[cfg(feature = "yogs_reactions")] +mod yogs; use byondapi::prelude::*; @@ -15,6 +18,9 @@ pub type ReactionIdentifier = u64; use eyre::{Context, Result}; +use fxhash::FxBuildHasher; +use hashbrown::HashMap; + #[derive(Clone, Debug)] pub struct Reaction { id: ReactionIdentifier, @@ -26,12 +32,11 @@ pub struct Reaction { min_gas_reqs: Vec<(GasIDX, f32)>, } -use fxhash::FxBuildHasher; -use hashbrown::HashMap; +type ReactFunc = fn(ByondValue, ByondValue) -> Result; enum ReactionSide { ByondSide(ByondValue), - RustSide(fn(ByondValue, ByondValue) -> Result), + RustSide(ReactFunc), } thread_local! { @@ -73,9 +78,13 @@ impl Reaction { .read_string_id(byond_string!("id")) .map_err(|_| eyre::eyre!("Reaction id must be a string!"))?; let func = { - #[cfg(feature = "reaction_hooks")] + #[cfg(feature = "citadel_reactions")] + { + citadel::func_from_id(string_id.as_str()) + } + #[cfg(feature = "yogs_reactions")] { - hooks::func_from_id(string_id.as_str()) + yogs::func_from_id(string_id.as_str()) } #[cfg(not(feature = "reaction_hooks"))] { diff --git a/src/reaction/hooks.rs b/src/reaction/citadel.rs similarity index 97% rename from src/reaction/hooks.rs rename to src/reaction/citadel.rs index 85c997d1..f82e7ce5 100644 --- a/src/reaction/hooks.rs +++ b/src/reaction/citadel.rs @@ -9,23 +9,16 @@ use crate::gas::{ const SUPER_SATURATION_THRESHOLD: f32 = 96.0; #[must_use] -pub fn func_from_id(id: &str) -> Option { +pub fn func_from_id(id: &str) -> Option { match id { - #[cfg(feature = "plasma_fire_hook")] "plasmafire" => Some(plasma_fire), - #[cfg(feature = "trit_fire_hook")] "tritfire" => Some(tritium_fire), - #[cfg(feature = "fusion_hook")] "fusion" => Some(fusion), - #[cfg(feature = "generic_fire_hook")] "genericfire" => Some(generic_fire), _ => None, } } -type ReactFunc = fn(ByondValue, ByondValue) -> Result; - -#[cfg(feature = "plasma_fire_hook")] fn plasma_fire(byond_air: ByondValue, holder: ByondValue) -> Result { const PLASMA_UPPER_TEMPERATURE: f32 = 1390.0 + T0C; const OXYGEN_BURN_RATE_BASE: f32 = 1.4; @@ -101,7 +94,6 @@ fn plasma_fire(byond_air: ByondValue, holder: ByondValue) -> Result } } -#[cfg(feature = "trit_fire_hook")] fn tritium_fire(byond_air: ByondValue, holder: ByondValue) -> Result { const TRITIUM_BURN_OXY_FACTOR: f32 = 100.0; const TRITIUM_BURN_TRIT_FACTOR: f32 = 10.0; @@ -155,7 +147,6 @@ fn tritium_fire(byond_air: ByondValue, holder: ByondValue) -> Result Ok(true.into()) } -#[cfg(feature = "fusion_hook")] fn fusion(byond_air: ByondValue, holder: ByondValue) -> Result { const TOROID_CALCULATED_THRESHOLD: f32 = 5.96; // changing it by 0.1 generally doubles or halves fusion temps const INSTABILITY_GAS_POWER_FACTOR: f32 = 3.0; @@ -300,7 +291,6 @@ fn fusion(byond_air: ByondValue, holder: ByondValue) -> Result { } } -#[cfg(feature = "generic_fire_hook")] fn generic_fire(byond_air: ByondValue, holder: ByondValue) -> Result { use fxhash::FxBuildHasher; use hashbrown::HashMap; diff --git a/src/reaction/yogs.rs b/src/reaction/yogs.rs new file mode 100644 index 00000000..23cf52ef --- /dev/null +++ b/src/reaction/yogs.rs @@ -0,0 +1,98 @@ +use crate::gas::{constants::*, gas_idx_from_string, with_mix, with_mix_mut}; +use byondapi::prelude::*; +use eyre::Result; + +#[must_use] +pub fn func_from_id(id: &str) -> Option { + match id { + "plasmafire" => Some(plasma_fire), + //"tritfire" => Some(tritium_fire), + //"fusion" => Some(fusion), + _ => None, + } +} + +const SUPER_SATURATION_THRESHOLD: f32 = 96.0; +fn plasma_fire(byond_air: ByondValue, holder: ByondValue) -> Result { + const PLASMA_UPPER_TEMPERATURE: f32 = 1370.0 + T0C; + const OXYGEN_BURN_RATE_BASE: f32 = 1.4; + const PLASMA_OXYGEN_FULLBURN: f32 = 10.0; + const PLASMA_BURN_RATE_DELTA: f32 = 9.0; + const FIRE_PLASMA_ENERGY_RELEASED: f32 = 3_000_000.0; + let o2 = gas_idx_from_string(GAS_O2)?; + let plasma = gas_idx_from_string(GAS_PLASMA)?; + let co2 = gas_idx_from_string(GAS_CO2)?; + let tritium = gas_idx_from_string(GAS_TRITIUM)?; + let (oxygen_burn_rate, plasma_burn_rate, initial_oxy, initial_plasma, initial_energy) = + with_mix(&byond_air, |air| { + let temperature_scale = { + if air.get_temperature() > PLASMA_UPPER_TEMPERATURE { + 1.0 + } else { + (air.get_temperature() - PLASMA_MINIMUM_BURN_TEMPERATURE) + / (PLASMA_UPPER_TEMPERATURE - PLASMA_MINIMUM_BURN_TEMPERATURE) + } + }; + if temperature_scale > 0.0 { + let oxygen_burn_rate = OXYGEN_BURN_RATE_BASE - temperature_scale; + let oxy = air.get_moles(o2); + let plas = air.get_moles(plasma); + let plasma_burn_rate = { + if oxy > plas * PLASMA_OXYGEN_FULLBURN { + plas * temperature_scale / PLASMA_BURN_RATE_DELTA + } else { + (temperature_scale * (oxy / PLASMA_OXYGEN_FULLBURN)) + / PLASMA_BURN_RATE_DELTA + } + } + .min(plas) + .min(oxy / oxygen_burn_rate); + Ok(( + oxygen_burn_rate, + plasma_burn_rate, + oxy, + plas, + air.thermal_energy(), + )) + } else { + Ok((0.0, -1.0, 0.0, 0.0, 0.0)) + } + })?; + let fire_amount = plasma_burn_rate * (1.0 + oxygen_burn_rate); + if fire_amount > 0.0 { + let temperature = with_mix_mut(&byond_air, |air| { + air.set_moles(plasma, initial_plasma - plasma_burn_rate); + air.set_moles(o2, initial_oxy - (plasma_burn_rate * oxygen_burn_rate)); + if initial_oxy / initial_plasma > SUPER_SATURATION_THRESHOLD { + air.adjust_moles(tritium, plasma_burn_rate); + } else { + air.adjust_moles(co2, plasma_burn_rate); + } + let new_temp = (initial_energy + plasma_burn_rate * FIRE_PLASMA_ENERGY_RELEASED) + / air.heat_capacity(); + air.set_temperature(new_temp); + air.garbage_collect(); + Ok(new_temp) + })?; + let mut cached_results = byond_air.read_var_id(byond_string!("reaction_results"))?; + cached_results.write_list_index("fire", fire_amount)?; + if temperature > FIRE_MINIMUM_TEMPERATURE_TO_EXIST { + byondapi::global_call::call_global_id( + byond_string!("fire_expose"), + &[holder, byond_air, temperature.into()], + )?; + } + Ok(true.into()) + } else { + Ok(false.into()) + } +} +/* +fn tritium_fire(byond_air: ByondValue, holder: ByondValue) -> Result { + Ok(ByondValue::new()) +} + +fn fusion(byond_air: ByondValue, holder: ByondValue) -> Result { + Ok(ByondValue::new()) +} +*/ diff --git a/src/turfs.rs b/src/turfs.rs index e332526a..5b9c46b9 100644 --- a/src/turfs.rs +++ b/src/turfs.rs @@ -36,7 +36,7 @@ use std::{mem::drop, sync::atomic::AtomicU64}; use eyre::{Context, Result}; bitflags! { - #[derive(Default, Clone, Copy, PartialEq, Eq)] + #[derive(Default, Debug, Clone, Copy, PartialEq, Eq)] pub struct Directions: u8 { const NORTH = 0b1; const SOUTH = 0b10; @@ -48,19 +48,19 @@ bitflags! { const ALL_CARDINALS_MULTIZ = Self::NORTH.bits() | Self::SOUTH.bits() | Self::EAST.bits() | Self::WEST.bits() | Self::UP.bits() | Self::DOWN.bits(); } - #[derive(Default)] + #[derive(Default, Debug)] pub struct SimulationFlags: u8 { const SIMULATION_DIFFUSE = 0b1; const SIMULATION_ALL = 0b10; const SIMULATION_ANY = Self::SIMULATION_DIFFUSE.bits() | Self::SIMULATION_ALL.bits(); } - #[derive(Default)] + #[derive(Default, Debug)] pub struct AdjacentFlags: u8 { const ATMOS_ADJACENT_FIRELOCK = 0b10; } - #[derive(Default, Clone, Copy)] + #[derive(Default, Debug, Clone, Copy)] pub struct DirtyFlags: u8 { const DIRTY_MIX_REF = 0b1; const DIRTY_ADJACENT = 0b10; @@ -97,7 +97,7 @@ const fn idx_to_adj_flag(idx: u8) -> Directions { type TurfID = u32; // TurfMixture can be treated as "immutable" for all intents and purposes--put other data somewhere else -#[derive(Default)] +#[derive(Default, Debug)] struct TurfMixture { pub mix: usize, pub id: TurfID, @@ -223,6 +223,7 @@ impl TurfMixture { type TurfGraphMap = IndexMap; //adjacency/turf infos goes here +#[derive(Debug)] struct TurfGases { graph: StableDiGraph, map: TurfGraphMap, diff --git a/src/turfs/groups.rs b/src/turfs/groups.rs index 0efc3ac6..443b9866 100644 --- a/src/turfs/groups.rs +++ b/src/turfs/groups.rs @@ -21,6 +21,7 @@ pub fn send_to_groups(sent: BTreeSet) { } #[byondapi::bind("/datum/controller/subsystem/air/proc/process_excited_groups_auxtools")] +#[cfg_attr(feature = "tracy", tracing::instrument(skip_all))] fn groups_hook(mut src: ByondValue, remaining: ByondValue) { let group_pressure_goal = src .read_number_id(byond_string!("excited_group_pressure_goal")) @@ -55,6 +56,7 @@ fn groups_hook(mut src: ByondValue, remaining: ByondValue) { } // Finds small differences in turf pressures and equalizes them. +#[cfg_attr(feature = "tracy", tracing::instrument(skip_all))] fn excited_group_processing( pressure_goal: f32, low_pressure_turfs: BTreeSet, diff --git a/src/turfs/katmos.rs b/src/turfs/katmos.rs index f535620a..e1ba2568 100644 --- a/src/turfs/katmos.rs +++ b/src/turfs/katmos.rs @@ -40,7 +40,7 @@ pub fn send_to_equalize(sent: BTreeSet) { EQUALIZE_CHANNEL.try_lock().map(|mut opt| opt.replace(sent)); } -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Debug)] struct MonstermosInfo { mole_delta: f32, curr_transfer_amount: f32, @@ -59,7 +59,7 @@ impl Default for MonstermosInfo { } } -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Debug)] struct ReducedInfo { curr_transfer_amount: f32, curr_transfer_dir: Option, @@ -316,7 +316,7 @@ fn take_from_givers( } } } - +#[cfg_attr(feature = "tracy", tracing::instrument(skip_all))] fn explosively_depressurize(initial_index: TurfID, equalize_hard_turf_limit: usize) -> Result<()> { let Some(initial_index) = with_turf_gases_read(|arena| arena.get_id(initial_index)) else { return Ok(()); @@ -510,7 +510,7 @@ fn explosively_depressurize(initial_index: TurfID, equalize_hard_turf_limit: usi Ok(()) } - +#[cfg_attr(feature = "tracy", tracing::instrument(skip_all))] fn flood_fill_zones( (index_node, index_turf): (NodeIndex, TurfID), equalize_hard_turf_limit: usize, @@ -573,6 +573,7 @@ fn flood_fill_zones( (!ignore_zone).then_some((turf_graph, total_moles)) } +#[cfg_attr(feature = "tracy", tracing::instrument(skip_all))] fn planet_equalize(initial_index: TurfID, equalize_hard_turf_limit: usize) -> Result<()> { let Some(initial_index) = with_turf_gases_read(|arena| arena.get_id(initial_index)) else { return Ok(()); @@ -629,6 +630,7 @@ fn planet_equalize(initial_index: TurfID, equalize_hard_turf_limit: usize) -> Re Ok(()) } +#[cfg_attr(feature = "tracy", tracing::instrument(skip_all))] fn process_zone( graph: DiGraphMap>, average_moles: f32, @@ -688,6 +690,7 @@ fn process_zone( graph } +#[cfg_attr(feature = "tracy", tracing::instrument(skip_all))] fn finalize_eq_zone( arena: &TurfGases, graph: DiGraphMap>, @@ -719,6 +722,7 @@ fn send_pressure_differences( } #[byondapi::bind("/datum/controller/subsystem/air/proc/process_turf_equalize_auxtools")] +#[cfg_attr(feature = "tracy", tracing::instrument(skip_all))] fn equalize_hook(mut src: ByondValue, remaining: ByondValue) { let equalize_hard_turf_limit = src .read_number_id(byond_string!("equalize_hard_turf_limit")) @@ -750,6 +754,7 @@ fn equalize_hook(mut src: ByondValue, remaining: ByondValue) { Ok(is_cancelled.into()) } +#[cfg_attr(feature = "tracy", tracing::instrument(skip_all))] fn equalize( equalize_hard_turf_limit: usize, high_pressure_turfs: &BTreeSet, diff --git a/src/turfs/processing.rs b/src/turfs/processing.rs index 921e074e..0ab32cc1 100644 --- a/src/turfs/processing.rs +++ b/src/turfs/processing.rs @@ -21,11 +21,13 @@ fn thread_running_hook() { } #[byondapi::bind("/datum/controller/subsystem/air/proc/finish_turf_processing_auxtools")] +#[cfg_attr(feature = "tracy", tracing::instrument(skip_all))] fn finish_process_turfs(time_remaining: ByondValue) { Ok(process_callbacks_for_millis(time_remaining.get_number()? as u64).into()) } #[byondapi::bind("/datum/controller/subsystem/air/proc/process_turfs_auxtools")] +#[cfg_attr(feature = "tracy", tracing::instrument(skip_all))] fn process_turf_hook(src: ByondValue, remaining: ByondValue) { let remaining_time = Duration::from_millis(remaining.get_number().unwrap_or(50.0) as u64); let fdm_max_steps = src @@ -34,14 +36,26 @@ fn process_turf_hook(src: ByondValue, remaining: ByondValue) { let equalize_enabled = cfg!(feature = "fastmos") && src.read_number_id(byond_string!("equalize_enabled"))? != 0.0; - process_turf(remaining_time, fdm_max_steps, equalize_enabled, src)?; + let planet_share_ratio = src + .read_number_id(byond_string!("planet_share_ratio")) + .unwrap_or(GAS_DIFFUSION_CONSTANT); + + process_turf( + remaining_time, + fdm_max_steps, + equalize_enabled, + planet_share_ratio, + src, + )?; Ok(ByondValue::null()) } +#[cfg_attr(feature = "tracy", tracing::instrument(skip_all))] fn process_turf( remaining: Duration, fdm_max_steps: i32, equalize_enabled: bool, + planet_share_ratio: f32, mut ssair: ByondValue, ) -> Result<()> { //this will block until process_turfs is called @@ -71,7 +85,7 @@ fn process_turf( )?; } { - planet_process(); + planet_process(planet_share_ratio); } { super::groups::send_to_groups(low_pressure_turfs); @@ -85,7 +99,8 @@ fn process_turf( Ok(()) } -fn planet_process() { +#[cfg_attr(feature = "tracy", tracing::instrument(skip_all))] +fn planet_process(planet_share_ratio: f32) { with_turf_gases_read(|arena| { GasArena::with_all_mixtures(|all_mixtures| { with_planetary_atmos(|map| { @@ -114,7 +129,7 @@ fn planet_process() { .flatten() { if comparison > 0.1 || has_temp_difference { - gas.share_ratio(planet_atmos, GAS_DIFFUSION_CONSTANT); + gas.share_ratio(planet_atmos, planet_share_ratio); } else { gas.copy_from_mutable(planet_atmos); } @@ -213,6 +228,7 @@ fn process_cell( } // Solving the heat equation using a Finite Difference Method, an iterative stencil loop. +#[cfg_attr(feature = "tracy", tracing::instrument(skip_all))] fn fdm( (start_time, remaining_time): (&Instant, Duration), fdm_max_steps: i32, @@ -371,6 +387,7 @@ fn post_process_cell<'a>( // Goes through every turf, checks if it should reset to planet atmos, if it should // update visuals, if it should react, sends a callback if it should. +#[cfg_attr(feature = "tracy", tracing::instrument(skip_all))] fn post_process() { let vis = crate::gas::visibility_copies(); with_turf_gases_read(|arena| {