From 7a6f5e19d992f987bb26778a79f32d0faa387973 Mon Sep 17 00:00:00 2001 From: Jeff Date: Sat, 27 Jul 2024 20:36:12 -0400 Subject: [PATCH] Clone from trade_bot; Remove trading features --- .gitignore | 2 +- Cargo.lock | 499 ++++++++++++++++++------------------- Cargo.toml | 1 + src/bot.rs | 664 ++++++++++++++++++++------------------------------ src/config.rs | 29 +++ src/main.rs | 90 ++++--- 6 files changed, 594 insertions(+), 691 deletions(-) create mode 100644 src/config.rs diff --git a/.gitignore b/.gitignore index bab85c2..6d62a10 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ target/ -config.toml +secrets.toml diff --git a/Cargo.lock b/Cargo.lock index a6e5a11..9bf7cf0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -68,9 +68,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.14" +version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" +checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" dependencies = [ "anstyle", "anstyle-parse", @@ -83,33 +83,33 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" +checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" [[package]] name = "anstyle-parse" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" +checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" +checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" dependencies = [ "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.3" +version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" +checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" dependencies = [ "anstyle", "windows-sys 0.52.0", @@ -126,9 +126,9 @@ dependencies = [ [[package]] name = "arrayref" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" +checksum = "9d151e35f61089500b617991b791fc8bfd237ae50cd5950803758a179b41e67a" [[package]] name = "arrayvec" @@ -164,13 +164,13 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.80" +version = "0.1.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" +checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -217,9 +217,9 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "backtrace" -version = "0.3.72" +version = "0.3.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17c6a35df3749d2e8bb1b7b21a976d82b15548788d2735b9d82f329268f71a11" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" dependencies = [ "addr2line", "cc", @@ -259,9 +259,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" dependencies = [ "serde", ] @@ -294,9 +294,9 @@ checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytemuck" -version = "1.16.0" +version = "1.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78834c15cb5d5efe3452d58b1e8ba890dd62d21907f867f383358198e56ebca5" +checksum = "b236fc92302c97ed75b38da1f4917b5cdda4984745740f153a5d3059e48d725e" [[package]] name = "byteorder" @@ -305,16 +305,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] -name = "bytes" -version = "1.6.0" +name = "byteorder-lite" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" +checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" + +[[package]] +name = "bytes" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952" [[package]] name = "cc" -version = "1.0.98" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" +checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" [[package]] name = "cesu8" @@ -340,14 +346,14 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] name = "chrono-tz" -version = "0.8.6" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59ae0466b83e838b81a54256c39d5d7c20b9d7daa10510a242d9b75abd5936e" +checksum = "93698b29de5e97ad0ae26447b344c482a7284c737d9ddc5f9e52b74a336671bb" dependencies = [ "chrono", "chrono-tz-build", @@ -357,26 +363,20 @@ dependencies = [ [[package]] name = "chrono-tz-build" -version = "0.2.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "433e39f13c9a060046954e0592a8d0a4bcb1040125cbf91cb8ee58964cfb350f" +checksum = "0c088aee841df9c3041febbb73934cfc39708749bf96dc827e3359cd39ef11b1" dependencies = [ "parse-zoneinfo", "phf", "phf_codegen", ] -[[package]] -name = "color_quant" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" - [[package]] name = "colorchoice" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" +checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" [[package]] name = "combine" @@ -507,7 +507,7 @@ checksum = "1234e1717066d3c71dcf89b75e7b586299e41204d361db56ec51e6ded5014279" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -561,9 +561,9 @@ dependencies = [ [[package]] name = "either" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "enum-as-inner" @@ -571,10 +571,10 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ffccbb6966c05b32ef8fbac435df276c4ae4d3dc55a8cd0eb9745e6c12f546a" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -595,14 +595,14 @@ checksum = "f282cfdfe92516eb26c2af8589c274c7c17681f5ecc03c18255fe741c6aa64eb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "env_filter" -version = "0.1.0" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" +checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab" dependencies = [ "log", "regex", @@ -610,9 +610,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.11.3" +version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9" +checksum = "e13fa619b91fb2381732789fc5de83b45675e882f66623b7d8cb4f643017018d" dependencies = [ "anstream", "anstyle", @@ -738,7 +738,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -818,6 +818,7 @@ dependencies = [ "serde", "tokio", "toml", + "vek", "veloren-client", "veloren-common", "veloren-common-net", @@ -832,17 +833,6 @@ dependencies = [ "ahash 0.4.8", ] -[[package]] -name = "hashbrown" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" -dependencies = [ - "ahash 0.8.11", - "rayon", - "serde", -] - [[package]] name = "hashbrown" version = "0.14.5" @@ -852,6 +842,8 @@ dependencies = [ "ahash 0.8.11", "allocator-api2", "equivalent", + "rayon", + "serde", ] [[package]] @@ -860,6 +852,12 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "hermit-abi" version = "0.3.9" @@ -950,9 +948,9 @@ dependencies = [ [[package]] name = "http-body" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", "http", @@ -960,12 +958,12 @@ dependencies = [ [[package]] name = "http-body-util" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0475f8b2ac86659c21b64320d5d653f9efe42acd2a4e560073ec61a155a34f1d" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ "bytes", - "futures-core", + "futures-util", "http", "http-body", "pin-project-lite", @@ -973,9 +971,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.8.0" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" [[package]] name = "humantime" @@ -985,9 +983,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "1.3.1" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe575dd17d0862a9a33781c8c4696a55c320909004a67a00fb286ba8b1bc496d" +checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" dependencies = [ "bytes", "futures-channel", @@ -1022,9 +1020,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b875924a60b96e5d7b9ae7b066540b1dd1cbd90d1828f54c92e02a283351c56" +checksum = "3ab92f4f49ee4fb4f997c784b7a2e0fa70050211e0b6a287f898c3c9785ca956" dependencies = [ "bytes", "futures-channel", @@ -1085,16 +1083,16 @@ dependencies = [ [[package]] name = "image" -version = "0.24.9" +version = "0.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5690139d2f55868e080017335e4b94cb7414274c74f1669c84fb5feba2c9f69d" +checksum = "99314c8a2152b8ddb211f924cdae532d8c5e4c8bb54728e12fff1b0cd5963a10" dependencies = [ "bytemuck", - "byteorder", - "color_quant", - "jpeg-decoder", + "byteorder-lite", "num-traits", "png", + "zune-core", + "zune-jpeg", ] [[package]] @@ -1128,15 +1126,15 @@ checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "is_terminal_polyfill" -version = "1.70.0" +version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "itertools" -version = "0.10.5" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" dependencies = [ "either", ] @@ -1167,12 +1165,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" -[[package]] -name = "jpeg-decoder" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5d4a7da358eff58addd2877a45865158f0d78c911d43a5784ceb7bbf52833b0" - [[package]] name = "js-sys" version = "0.3.69" @@ -1184,9 +1176,9 @@ dependencies = [ [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" @@ -1200,7 +1192,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "libc", ] @@ -1222,9 +1214,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.21" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "lru-cache" @@ -1241,7 +1233,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26a280471e5ff9dda51cf34863c338ffde7df78139210f9c819943b29cdb091d" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "byteorder", "culpa", "thiserror", @@ -1272,9 +1264,9 @@ checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" [[package]] name = "memchr" -version = "2.7.2" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "minimal-lexical" @@ -1284,9 +1276,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ "adler", "simd-adler32", @@ -1294,13 +1286,14 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.11" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4" dependencies = [ + "hermit-abi", "libc", "wasi", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -1350,9 +1343,9 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" dependencies = [ "num-integer", "num-traits", @@ -1375,7 +1368,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -1430,9 +1423,9 @@ dependencies = [ [[package]] name = "object" -version = "0.35.0" +version = "0.36.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8ec7ab813848ba4522158d5517a6093db1ded27575b070f4177b8d12b41db5e" +checksum = "3f203fa8daa7bb185f760ae12bd8e097f63d17041dcdcaf675ac54cdf863170e" dependencies = [ "memchr", ] @@ -1451,9 +1444,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "ordered-float" -version = "3.9.2" +version = "4.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1e1c390732d15f1d48471625cd92d154e66db2c56645e29a9cd26f4699f72dc" +checksum = "19ff2cf528c6c03d9ed653d6c4ce1dc0582dc4af309790ad92f07c1cd551b0be" dependencies = [ "num-traits", ] @@ -1484,7 +1477,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -1563,7 +1556,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -1599,9 +1592,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.85" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -1628,9 +1621,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quinn" -version = "0.11.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904e3d3ba178131798c6d9375db2b13b34337d489b089fc5ba0825a2ff1bee73" +checksum = "e4ceeeeabace7857413798eb1ffa1e9c905a9946a57d81fb69b4b71c4d8eb3ad" dependencies = [ "bytes", "pin-project-lite", @@ -1645,9 +1638,9 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e974563a4b1c2206bbc61191ca4da9c22e4308b4c455e8906751cc7828393f08" +checksum = "ddf517c03a109db8100448a4be38d498df8a210a99fe0e1b9eaf39e78c640efe" dependencies = [ "bytes", "rand", @@ -1663,9 +1656,9 @@ dependencies = [ [[package]] name = "quinn-udp" -version = "0.5.1" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4f0def2590301f4f667db5a77f9694fb004f82796dc1a8b1508fafa3d0e8b72" +checksum = "8bffec3605b73c6f1754535084a85229fa8a30f86014e6c81aeec4abb68b0285" dependencies = [ "libc", "once_cell", @@ -1735,11 +1728,11 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.1" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", ] [[package]] @@ -1755,9 +1748,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.4" +version = "1.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" dependencies = [ "aho-corasick", "memchr", @@ -1767,9 +1760,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" dependencies = [ "aho-corasick", "memchr", @@ -1778,9 +1771,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "resolv-conf" @@ -1814,7 +1807,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94" dependencies = [ "base64 0.21.7", - "bitflags 2.5.0", + "bitflags 2.6.0", "serde", "serde_derive", ] @@ -1859,9 +1852,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.9" +version = "0.23.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a218f0f6d05669de4eabfb24f31ce802035c952429d037507b4a4a39f0e60c5b" +checksum = "c58f8c84392efc0a126acce10fa59ff7b3d2ac06ab451a33f2741989b806b044" dependencies = [ "once_cell", "ring", @@ -1873,9 +1866,9 @@ dependencies = [ [[package]] name = "rustls-native-certs" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f1fb85efa936c42c6d5fc28d2629bb51e4b2f4b8a5211e297d599cc5a093792" +checksum = "a88d6d420651b496bdd98684116959239430022a115c1240e6c3993be0b15fba" dependencies = [ "openssl-probe", "rustls-pemfile", @@ -1902,9 +1895,9 @@ checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" [[package]] name = "rustls-platform-verifier" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5f0d26fa1ce3c790f9590868f0109289a044acb954525f933e2aa3b871c157d" +checksum = "3e3beb939bcd33c269f4bf946cc829fcd336370267c4a927ac0399c84a3151a1" dependencies = [ "core-foundation", "core-foundation-sys", @@ -1929,9 +1922,9 @@ checksum = "84e217e7fdc8466b5b35d30f8c0a30febd29173df4a3a0c2115d306b9c4117ad" [[package]] name = "rustls-webpki" -version = "0.102.4" +version = "0.102.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff448f7e92e913c4b7d4c6d8e4540a1724b319b4152b8aef6d4cf8339712b33e" +checksum = "8e6b52d4fda176fd835fdc55a835d4a89b8499cad995885a21149d5ad62f852e" dependencies = [ "ring", "rustls-pki-types", @@ -1976,11 +1969,11 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "security-framework" -version = "2.11.0" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "core-foundation", "core-foundation-sys", "libc", @@ -1990,9 +1983,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.11.0" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7" +checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" dependencies = [ "core-foundation-sys", "libc", @@ -2006,29 +1999,29 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.120" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" dependencies = [ "itoa", "ryu", @@ -2043,14 +2036,14 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "serde_spanned" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" +checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" dependencies = [ "serde", ] @@ -2196,31 +2189,31 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "strum" -version = "0.24.1" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" dependencies = [ "strum_macros", ] [[package]] name = "strum_macros" -version = "0.24.3" +version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" dependencies = [ - "heck", + "heck 0.5.0", "proc-macro2", "quote", "rustversion", - "syn 1.0.109", + "syn 2.0.72", ] [[package]] name = "subtle" -version = "2.5.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "sum_type" @@ -2241,9 +2234,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.66" +version = "2.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" dependencies = [ "proc-macro2", "quote", @@ -2252,22 +2245,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.61" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.61" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -2281,9 +2274,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.6.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" dependencies = [ "tinyvec_macros", ] @@ -2296,30 +2289,29 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.38.0" +version = "1.39.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" +checksum = "daa4fb1bc778bd6f04cbfc4bb2d06a7396a8f299dc33ea1900cedaa316f467b1" dependencies = [ "backtrace", "bytes", "libc", "mio", - "num_cpus", "pin-project-lite", "socket2", "tokio-macros", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "tokio-macros" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -2346,9 +2338,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.14" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f49eb2ab21d2f26bd6db7bf383edc527a7ebaee412d17af4d40fdccd442f335" +checksum = "81967dd0dd2c1ab0bc3468bd7caecc32b8a4aa47d0c8c695d8c2b2108168d62c" dependencies = [ "serde", "serde_spanned", @@ -2358,18 +2350,18 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" +checksum = "f8fb9f64314842840f1d940ac544da178732128f1c78c21772e876579e0da1db" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.22.14" +version = "0.22.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" +checksum = "8d9f8729f5aea9562aac1cc0441f5d6de3cff1ee0c5d67293eeca5eb36ee7c16" dependencies = [ "indexmap", "serde", @@ -2425,7 +2417,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -2503,9 +2495,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.0" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna 0.5.0", @@ -2520,9 +2512,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.8.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" +checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" dependencies = [ "getrandom", "serde", @@ -2544,11 +2536,11 @@ dependencies = [ [[package]] name = "veloren-client" version = "0.16.0" -source = "git+https://gitlab.com/veloren/veloren?tag=weekly#5c0299ef8223927796e6f6d3062a1a144803a3cf" +source = "git+https://gitlab.com/veloren/veloren?tag=weekly#127c0ce0aa8d58d23c3f22eaa762e1061342d6c6" dependencies = [ "authc", "byteorder", - "hashbrown 0.13.2", + "hashbrown 0.14.5", "hickory-resolver", "image", "num", @@ -2570,17 +2562,17 @@ dependencies = [ [[package]] name = "veloren-common" version = "0.10.0" -source = "git+https://gitlab.com/veloren/veloren?tag=weekly#5c0299ef8223927796e6f6d3062a1a144803a3cf" +source = "git+https://gitlab.com/veloren/veloren?tag=weekly#127c0ce0aa8d58d23c3f22eaa762e1061342d6c6" dependencies = [ "approx", - "bitflags 2.5.0", + "bitflags 2.6.0", "chrono", "chrono-tz", "crossbeam-utils", "dot_vox", "enum-map", "fxhash", - "hashbrown 0.13.2", + "hashbrown 0.14.5", "indexmap", "itertools", "lazy_static", @@ -2610,11 +2602,11 @@ dependencies = [ [[package]] name = "veloren-common-assets" version = "0.10.0" -source = "git+https://gitlab.com/veloren/veloren?tag=weekly#5c0299ef8223927796e6f6d3062a1a144803a3cf" +source = "git+https://gitlab.com/veloren/veloren?tag=weekly#127c0ce0aa8d58d23c3f22eaa762e1061342d6c6" dependencies = [ "assets_manager", "dot_vox", - "hashbrown 0.13.2", + "hashbrown 0.14.5", "image", "lazy_static", "ron", @@ -2625,7 +2617,7 @@ dependencies = [ [[package]] name = "veloren-common-base" version = "0.10.0" -source = "git+https://gitlab.com/veloren/veloren?tag=weekly#5c0299ef8223927796e6f6d3062a1a144803a3cf" +source = "git+https://gitlab.com/veloren/veloren?tag=weekly#127c0ce0aa8d58d23c3f22eaa762e1061342d6c6" dependencies = [ "directories-next", "tracing", @@ -2634,7 +2626,7 @@ dependencies = [ [[package]] name = "veloren-common-ecs" version = "0.10.0" -source = "git+https://gitlab.com/veloren/veloren?tag=weekly#5c0299ef8223927796e6f6d3062a1a144803a3cf" +source = "git+https://gitlab.com/veloren/veloren?tag=weekly#127c0ce0aa8d58d23c3f22eaa762e1061342d6c6" dependencies = [ "specs", "tracing", @@ -2644,9 +2636,9 @@ dependencies = [ [[package]] name = "veloren-common-i18n" version = "0.1.0" -source = "git+https://gitlab.com/veloren/veloren?tag=weekly#5c0299ef8223927796e6f6d3062a1a144803a3cf" +source = "git+https://gitlab.com/veloren/veloren?tag=weekly#127c0ce0aa8d58d23c3f22eaa762e1061342d6c6" dependencies = [ - "hashbrown 0.13.2", + "hashbrown 0.14.5", "rand", "serde", ] @@ -2654,11 +2646,11 @@ dependencies = [ [[package]] name = "veloren-common-net" version = "0.10.0" -source = "git+https://gitlab.com/veloren/veloren?tag=weekly#5c0299ef8223927796e6f6d3062a1a144803a3cf" +source = "git+https://gitlab.com/veloren/veloren?tag=weekly#127c0ce0aa8d58d23c3f22eaa762e1061342d6c6" dependencies = [ "bincode", "flate2", - "hashbrown 0.13.2", + "hashbrown 0.14.5", "image", "num-traits", "serde", @@ -2672,12 +2664,12 @@ dependencies = [ [[package]] name = "veloren-common-state" version = "0.10.0" -source = "git+https://gitlab.com/veloren/veloren?tag=weekly#5c0299ef8223927796e6f6d3062a1a144803a3cf" +source = "git+https://gitlab.com/veloren/veloren?tag=weekly#127c0ce0aa8d58d23c3f22eaa762e1061342d6c6" dependencies = [ "async-trait", "bytes", "futures", - "hashbrown 0.13.2", + "hashbrown 0.14.5", "num_cpus", "rayon", "scopeguard", @@ -2694,7 +2686,7 @@ dependencies = [ [[package]] name = "veloren-common-systems" version = "0.10.0" -source = "git+https://gitlab.com/veloren/veloren?tag=weekly#5c0299ef8223927796e6f6d3062a1a144803a3cf" +source = "git+https://gitlab.com/veloren/veloren?tag=weekly#127c0ce0aa8d58d23c3f22eaa762e1061342d6c6" dependencies = [ "itertools", "ordered-float", @@ -2712,7 +2704,7 @@ dependencies = [ [[package]] name = "veloren-network" version = "0.3.0" -source = "git+https://gitlab.com/veloren/veloren?tag=weekly#5c0299ef8223927796e6f6d3062a1a144803a3cf" +source = "git+https://gitlab.com/veloren/veloren?tag=weekly#127c0ce0aa8d58d23c3f22eaa762e1061342d6c6" dependencies = [ "async-channel", "async-trait", @@ -2720,7 +2712,7 @@ dependencies = [ "bytes", "crossbeam-channel", "futures-util", - "hashbrown 0.13.2", + "hashbrown 0.14.5", "lazy_static", "lz-fear", "quinn", @@ -2737,12 +2729,12 @@ dependencies = [ [[package]] name = "veloren-network-protocol" version = "0.6.1" -source = "git+https://gitlab.com/veloren/veloren?tag=weekly#5c0299ef8223927796e6f6d3062a1a144803a3cf" +source = "git+https://gitlab.com/veloren/veloren?tag=weekly#127c0ce0aa8d58d23c3f22eaa762e1061342d6c6" dependencies = [ "async-trait", - "bitflags 2.5.0", + "bitflags 2.6.0", "bytes", - "hashbrown 0.13.2", + "hashbrown 0.14.5", "prometheus", "rand", "tracing", @@ -2750,9 +2742,9 @@ dependencies = [ [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "walkdir" @@ -2800,7 +2792,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", "wasm-bindgen-shared", ] @@ -2822,7 +2814,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2844,9 +2836,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.26.2" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c452ad30530b54a4d8e71952716a212b08efd0f3562baa66c29a618b07da7c3" +checksum = "bd7c23921eeb1713a4e851530e9b9756e4fb0e89978582942612524cf09f01cd" dependencies = [ "rustls-pki-types", ] @@ -2894,7 +2886,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -2912,7 +2904,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -2932,18 +2924,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.5", - "windows_aarch64_msvc 0.52.5", - "windows_i686_gnu 0.52.5", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.5", - "windows_x86_64_gnu 0.52.5", - "windows_x86_64_gnullvm 0.52.5", - "windows_x86_64_msvc 0.52.5", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -2954,9 +2946,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" @@ -2966,9 +2958,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" @@ -2978,15 +2970,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" @@ -2996,9 +2988,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" @@ -3008,9 +3000,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" @@ -3020,9 +3012,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" @@ -3032,15 +3024,15 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.13" +version = "0.6.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1" +checksum = "b480ae9340fc261e6be3e95a1ba86d54ae3f9171132a73ce8d4bbaf68339507c" dependencies = [ "memchr", ] @@ -3057,22 +3049,22 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.34" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.34" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -3080,3 +3072,18 @@ name = "zeroize" version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" + +[[package]] +name = "zune-core" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f423a2c17029964870cfaabb1f13dfab7d092a62a29a89264f4d36990ca414a" + +[[package]] +name = "zune-jpeg" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16099418600b4d8f028622f73ff6e3deaabdff330fb9a2a131dea781ee8b0768" +dependencies = [ + "zune-core", +] diff --git a/Cargo.toml b/Cargo.toml index c456ffb..5771bed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,7 @@ env_logger = "0.11.3" log = "0.4.21" hashbrown = { version = "0.14.5", features = ["equivalent"] } rand = "0.8.5" +vek = "0.17.0" [patch.crates-io] specs = { git = "https://github.com/amethyst/specs.git", rev = "4e2da1df29ee840baa9b936593c45592b7c9ae27" } diff --git a/src/bot.rs b/src/bot.rs index fc70ae7..7bbf6db 100644 --- a/src/bot.rs +++ b/src/bot.rs @@ -1,477 +1,345 @@ -use std::{sync::Arc, time::Duration}; +/// A bot that buys, sells and trades with players. +/// +/// See [main.rs] for an example of how to run this bot. +use std::{ + sync::Arc, + time::{Duration, Instant}, +}; -use log::info; -use rand::{thread_rng, Rng}; +use log::{debug, info}; use tokio::runtime::Runtime; -use veloren_client::{addr::ConnectionArgs, Client, Event as VelorenEvent}; +use vek::{Quaternion, Vec3}; +use veloren_client::{addr::ConnectionArgs, Client, Event as VelorenEvent, WorldExt}; use veloren_common::{ clock::Clock, - comp::{chat::GenericChatMsg, invite::InviteKind, ChatType, ControllerInputs}, + comp::{ChatType, ControllerInputs, Ori, Pos}, + time::DayPeriod, uid::Uid, uuid::Uuid, ViewDistances, }; -use crate::Config; +const CLIENT_TPS: Duration = Duration::from_millis(33); +/// An active connection to the Veloren server that will attempt to run every time the `tick` +/// function is called. pub struct Bot { + username: String, + position: Pos, + orientation: Ori, + admins: Vec, + client: Client, clock: Clock, - admin_list: Vec, - ban_list: Vec, + + last_action: Instant, } impl Bot { + /// Connect to the official veloren server, select the specified character + /// and return a Bot instance ready to run. + #[allow(clippy::too_many_arguments)] pub fn new( - username: &str, + game_server: String, + auth_server: &str, + username: String, password: &str, - admin_list: Vec, - ban_list: Vec, + character: &str, + admins: Vec, + position: Option<[f32; 3]>, + orientation: Option, ) -> Result { info!("Connecting to veloren"); - let client = connect_to_veloren(username, password)?; - let clock = Clock::new(Duration::from_secs_f64(1.0 / 60.0)); + let mut client = connect_to_veloren(game_server, auth_server, &username, password)?; + let mut clock = Clock::new(CLIENT_TPS); + + client.load_character_list(); + + while client.character_list().loading { + client + .tick(ControllerInputs::default(), clock.dt()) + .map_err(|error| format!("{error:?}"))?; + clock.tick(); + } + + let character_id = client + .character_list() + .characters + .iter() + .find(|character_item| character_item.character.alias == character) + .ok_or_else(|| format!("No character named {character}"))? + .character + .id + .ok_or("Failed to get character ID")?; + + info!("Selecting a character"); + + // This loop waits and retries requesting the character in the case that the character has + // logged out too recently. + while client.position().is_none() { + client.request_character( + character_id, + ViewDistances { + terrain: 4, + entity: 4, + }, + ); + + client + .tick(ControllerInputs::default(), clock.dt()) + .map_err(|error| format!("{error:?}"))?; + clock.tick(); + } + + let position = if let Some(coords) = position { + Pos(coords.into()) + } else { + client.position().map(Pos).ok_or("Failed to get position")? + }; + let orientation = if let Some(orientation) = orientation { + Ori::new(Quaternion::rotation_z(orientation.to_radians())) + } else { + client.current::().ok_or("Failed to get orientation")? + }; Ok(Bot { + username, + position, + orientation, + admins, client, clock, - admin_list, - ban_list, + last_action: Instant::now(), }) } - pub fn select_character(&mut self) -> Result<(), String> { - info!("Selecting a character"); - - self.client.load_character_list(); - - while self.client.character_list().loading { - self.client - .tick(ControllerInputs::default(), self.clock.dt()) - .map_err(|error| format!("{error:?}"))?; - self.clock.tick(); - } - - let character_id = self - .client - .character_list() - .characters - .first() - .expect("No characters to select") - .character - .id - .expect("Failed to get character ID"); - - self.client.request_character( - character_id, - ViewDistances { - terrain: 0, - entity: 0, - }, - ); - - Ok(()) - } - - pub fn tick(&mut self) -> Result<(), String> { + /// Run the bot for a single tick. This should be called in a loop. Returns `true` if the loop + /// should continue running. + pub fn tick(&mut self) -> Result { let veloren_events = self .client .tick(ControllerInputs::default(), self.clock.dt()) .map_err(|error| format!("{error:?}"))?; - for veloren_event in veloren_events { - self.handle_veloren_event(veloren_event)?; + for event in veloren_events { + let should_continue = self.handle_veloren_event(event)?; + + if !should_continue { + return Ok(false); + } + } + + if self.last_action.elapsed() > Duration::from_millis(300) { + self.handle_lantern(); + self.handle_position_and_orientation()?; + + self.last_action = Instant::now(); } - self.client.cleanup(); self.clock.tick(); - Ok(()) + Ok(true) } - fn handle_veloren_event(&mut self, event: VelorenEvent) -> Result<(), String> { - if let VelorenEvent::Chat(message) = event { - self.handle_message(message)?; - } - - Ok(()) - } - - fn handle_message(&mut self, message: GenericChatMsg) -> Result<(), String> { - let sender_uid = match &message.chat_type { - ChatType::Tell(from, _) | ChatType::Group(from, _) | ChatType::Say(from) => from, - _ => return Ok(()), - }; - let content = message.content().as_plain().unwrap_or(""); - let sender_info = self - .client - .player_list() - .into_iter() - .find_map(|(uid, player_info)| { - if uid == sender_uid { - Some(player_info.clone()) + /// Consume and manage a client-side Veloren event. Returns a boolean indicating whether the + /// bot should continue processing events. + fn handle_veloren_event(&mut self, event: VelorenEvent) -> Result { + match event { + VelorenEvent::Chat(message) => { + let sender = if let ChatType::Tell(uid, _) = message.chat_type { + uid } else { - None - } - }) - .ok_or_else(|| format!("Failed to find info for uid {sender_uid}"))?; + return Ok(true); + }; + let content = message.content().as_plain().unwrap_or_default(); + let mut split_content = content.split(' '); + let command = split_content.next().unwrap_or_default(); + let price_correction_message = "Use the format 'price [search_term]'"; + let correction_message = match command { + "ori" => { + if self.is_user_admin(&sender)? { + if let Some(new_rotation) = split_content.next() { + let new_rotation = new_rotation + .parse::() + .map_err(|error| error.to_string())?; - if self.ban_list.contains(&sender_info.uuid) { - return Ok(()); - } + self.orientation = + Ori::new(Quaternion::rotation_z(new_rotation.to_radians())); - // Process commands with no arguments - - if content == "help" { - info!("Showing help for {}", sender_info.player_alias); - - let command_list = - format!("Commands: admin, ban, cheese, info, inv, inv_all, kick, roll, unban"); - let example = format!("Example: inv name1 name2 name3"); - let command_details = format!("Admin-only commands: admin, ban, inv_all, kick, unban"); - - match &message.chat_type { - ChatType::Tell(_, _) | ChatType::Group(_, _) => { - self.client.send_command( - "tell".to_string(), - vec![sender_info.player_alias.clone(), command_list], - ); - self.client.send_command( - "tell".to_string(), - vec![sender_info.player_alias.clone(), example], - ); - self.client.send_command( - "tell".to_string(), - vec![sender_info.player_alias, command_details], - ); - } - _ => {} - } - - return Ok(()); - } - - if content == "inv" { - info!("Inviting {}", sender_info.player_alias); - - self.client.send_invite(*sender_uid, InviteKind::Group); - - return Ok(()); - } - - if content == "inv_all" && self.admin_list.contains(&sender_info.uuid) { - info!("Inviting everyone..."); - - let player_list = self.client.player_list().clone(); - - for (uid, _) in player_list { - self.client.send_invite(uid, InviteKind::Group); - } - - return Ok(()); - } - - if content == "cheese" { - info!("{} loves cheese!", sender_info.player_alias); - - let content = format!("{} loves cheese!", sender_info.player_alias); - - match &message.chat_type { - ChatType::Tell(_, _) | ChatType::Say(_) => { - self.client.send_command("say".to_string(), vec![content]) - } - _ => self.client.send_command("group".to_string(), vec![content]), - } - - return Ok(()); - } - - if content == "info" { - info!("Printing info"); - - let mut members_message = "Members:".to_string(); - - for (uid, _) in self.client.group_members() { - let alias = self - .client - .player_list() - .get(uid) - .ok_or(format!("Failed to find player with uid {uid}."))? - .player_alias - .clone(); - - members_message.extend_one(' '); - members_message.extend(alias.chars().into_iter()); - } - - let mut admins_message = "Admins:".to_string(); - - for uuid in &self.admin_list { - for (_, info) in self.client.player_list() { - if &info.uuid == uuid { - admins_message.extend_one(' '); - admins_message.extend(info.player_alias.chars()); - - break; + None + } else { + Some("Use the format 'ori [0-360]'") + } + } else { + Some(price_correction_message) + } } - } - } + "pos" => { + if self.is_user_admin(&sender)? { + if let (Some(x), Some(y), Some(z)) = ( + split_content.next(), + split_content.next(), + split_content.next(), + ) { + self.position = Pos(Vec3::new( + x.parse::().map_err(|error| error.to_string())?, + y.parse::().map_err(|error| error.to_string())?, + z.parse::().map_err(|error| error.to_string())?, + )); - let mut banned_message = "Banned:".to_string(); - - for uuid in &self.ban_list { - for (_, info) in self.client.player_list() { - if &info.uuid == uuid { - banned_message.extend_one(' '); - banned_message.extend(info.player_alias.chars()); - - break; + None + } else { + Some("Use the format 'pos [x] [y] [z]'.") + } + } else { + Some(price_correction_message) + } } + _ => Some(price_correction_message), + }; + + if let Some(message) = correction_message { + let player_name = self + .find_player_alias(&sender) + .ok_or("Failed to find player name")? + .to_string(); + + self.client.send_command( + "tell".to_string(), + vec![player_name.clone(), message.to_string()], + ); } } - - match &message.chat_type { - ChatType::Tell(_, _) | ChatType::Group(_, _) => { - self.client.send_command( - "tell".to_string(), - vec![sender_info.player_alias.clone(), members_message], - ); - self.client.send_command( - "tell".to_string(), - vec![sender_info.player_alias.clone(), admins_message], - ); - self.client.send_command( - "tell".to_string(), - vec![sender_info.player_alias, banned_message], - ); - } - _ => {} + VelorenEvent::Disconnect => { + return Ok(false); } - - return Ok(()); + _ => (), } - // Process commands that use one or more arguments + Ok(true) + } - let mut words = content.split_whitespace(); - let command = if let Some(command) = words.next() { - command + /// Use the lantern at night and put it away during the day. + fn handle_lantern(&mut self) { + let day_period = self.client.state().get_day_period(); + + match day_period { + DayPeriod::Night => { + if !self.client.is_lantern_enabled() { + self.client.enable_lantern(); + } + } + DayPeriod::Morning | DayPeriod::Noon | DayPeriod::Evening => { + if self.client.is_lantern_enabled() { + self.client.disable_lantern(); + } + } + } + } + + /// Determines if the Uid belongs to an admin. + fn is_user_admin(&self, uid: &Uid) -> Result { + let sender_name = self.find_player_alias(uid).ok_or("Failed to find name")?; + + if self.admins.contains(sender_name) { + Ok(true) } else { - return Ok(()); - }; + let sender_uuid = self + .find_uuid(uid) + .ok_or("Failed to find uuid")? + .to_string(); - match command { - "admin" => { - if self.admin_list.contains(&sender_info.uuid) || self.admin_list.is_empty() { - for word in words { - info!("Adminifying {word}"); + Ok(self.admins.contains(&sender_uuid)) + } + } - self.adminify_player(word)?; - } - } + /// Moves the character to the configured position and orientation. + fn handle_position_and_orientation(&mut self) -> Result<(), String> { + if let Some(current_position) = self.client.current::() { + if current_position != self.position { + debug!( + "Updating position from {} to {}", + current_position.0, self.position.0 + ); + + let entity = self.client.entity(); + let ecs = self.client.state_mut().ecs(); + let mut position_state = ecs.write_storage::(); + + position_state + .insert(entity, self.position) + .map_err(|error| error.to_string())?; } - "ban" => { - if self.admin_list.contains(&sender_info.uuid) { - for word in words { - info!("Banning {word}"); + } - let uid = self.find_uid(word)?; + if let Some(current_orientation) = self.client.current::() { + if current_orientation != self.orientation { + debug!( + "Updating orientation from {:?} to {:?}", + current_orientation, self.orientation + ); - self.client.kick_from_group(uid); - self.ban_player(word)?; - } - } + let entity = self.client.entity(); + let ecs = self.client.state_mut().ecs(); + let mut orientation_state = ecs.write_storage::(); + + orientation_state + .insert(entity, self.orientation) + .map_err(|error| error.to_string())?; } - "inv" => { - for word in words { - info!("Inviting {word}"); - - let (uid, uuid) = self.find_ids(word)?; - - if !self.ban_list.contains(&uuid) { - self.client.send_invite(uid, InviteKind::Group); - } - } - } - "kick" => { - if self.admin_list.contains(&sender_info.uuid) { - for word in words { - info!("Kicking {word}"); - - let uid = self.find_uid(word)?; - - self.client.kick_from_group(uid); - } - } - } - "roll" => { - for word in words { - let max = word - .parse::() - .map_err(|error| format!("Failed to parse integer: {error}"))?; - - if max <= 1 { - return Err( - "Roll command did not receive an integer greater than 1".to_string() - ); - } - - info!("Rolling a die 1-{max}"); - - let random = thread_rng().gen_range(1..=max); - - match message.chat_type { - ChatType::Tell(_, _) => self.client.send_command( - "tell".to_string(), - vec![ - sender_info.player_alias.clone(), - format!("Rolled a die with {} sides and got {random}.", max), - ], - ), - ChatType::Say(_) => self.client.send_command( - "say".to_string(), - vec![format!("Rolled a die with {} sides and got {random}.", max)], - ), - ChatType::Group(_, _) => self.client.send_command( - "group".to_string(), - vec![format!("Rolled a die with {} sides and got {random}.", max)], - ), - _ => return Ok(()), - } - } - } - "unban" => { - if self.admin_list.contains(&sender_info.uuid) { - for word in words { - info!("Unbanning {word}"); - - self.unban_player(word)?; - } - } - } - _ => {} } Ok(()) } - fn adminify_player(&mut self, name: &str) -> Result<(), String> { - let uuid = self.find_uuid(name)?; + /// Finds the name of a player by their Uid. + fn find_player_alias<'a>(&'a self, uid: &Uid) -> Option<&'a String> { + self.client.player_list().iter().find_map(|(id, info)| { + if id == uid { + return Some(&info.player_alias); + } - if !self.admin_list.contains(&uuid) && !self.ban_list.contains(&uuid) { - self.admin_list.push(uuid); - } - - let old_config = Config::read()?; - let new_config = Config { - username: old_config.username, - password: old_config.password, - admin_list: self.admin_list.clone(), - ban_list: old_config.ban_list, - }; - - new_config.write()?; - - Ok(()) + None + }) } - fn ban_player(&mut self, name: &str) -> Result<(), String> { - let uuid = self.find_uuid(name)?; - - if !self.admin_list.contains(&uuid) && !self.ban_list.contains(&uuid) { - self.ban_list.push(uuid); - } - - let old_config = Config::read()?; - let new_config = Config { - username: old_config.username, - password: old_config.password, - admin_list: old_config.admin_list, - ban_list: self.ban_list.clone(), - }; - - new_config.write()?; - - Ok(()) + /// Finds the Uuid of a player by their Uid. + fn find_uuid(&self, target: &Uid) -> Option { + self.client.player_list().iter().find_map(|(uid, info)| { + if uid == target { + Some(info.uuid) + } else { + None + } + }) } - fn unban_player(&mut self, name: &str) -> Result<(), String> { - let uuid = self.find_uuid(name)?; - - if let Some(uuid) = self - .ban_list - .iter() - .enumerate() - .find_map(|(index, banned)| if &uuid == banned { Some(index) } else { None }) - { - self.ban_list.remove(uuid); - } - - let old_config = Config::read()?; - let new_config = Config { - username: old_config.username, - password: old_config.password, - admin_list: old_config.admin_list, - ban_list: self.ban_list.clone(), - }; - - new_config.write()?; - - Ok(()) - } - - fn find_uid(&self, name: &str) -> Result { - self.client - .player_list() - .iter() - .find_map(|(uid, info)| { - if info.player_alias == name { - Some(uid.clone()) - } else { - None - } - }) - .ok_or(format!("Failed to find uid for player {}", name)) - } - - fn find_uuid(&self, name: &str) -> Result { - self.client - .player_list() - .iter() - .find_map(|(_, info)| { - if info.player_alias == name { - Some(info.uuid) - } else { - None - } - }) - .ok_or(format!("Failed to find uuid for player {}", name)) - } - - fn find_ids(&self, name: &str) -> Result<(Uid, Uuid), String> { - self.client - .player_list() - .iter() - .find_map(|(uid, info)| { - if info.player_alias == name { - Some((*uid, info.uuid)) - } else { - None - } - }) - .ok_or(format!("Failed to find ids for player {}", name)) + /// Finds the Uid of a player by their name. + fn _find_uid<'a>(&'a self, name: &str) -> Option<&'a Uid> { + self.client.player_list().iter().find_map(|(id, info)| { + if info.player_alias == name { + Some(id) + } else { + None + } + }) } } -fn connect_to_veloren(username: &str, password: &str) -> Result { +fn connect_to_veloren( + game_server: String, + auth_server: &str, + username: &str, + password: &str, +) -> Result { let runtime = Arc::new(Runtime::new().unwrap()); let runtime2 = Arc::clone(&runtime); runtime .block_on(Client::new( ConnectionArgs::Tcp { - hostname: "server.veloren.net".to_string(), + hostname: game_server, prefer_ipv6: false, }, runtime2, @@ -479,7 +347,7 @@ fn connect_to_veloren(username: &str, password: &str) -> Result username, password, None, - |provider| provider == "https://auth.veloren.net", + |provider| provider == auth_server, &|_| {}, |_| {}, Default::default(), diff --git a/src/config.rs b/src/config.rs new file mode 100644 index 0000000..106827e --- /dev/null +++ b/src/config.rs @@ -0,0 +1,29 @@ +/// Configuration used to initiate the bot. +/// +/// The Config struct is used to store configuration values that are not sensitive. The Secrets +/// struct is used to store sensitive information that should not be shared. This should be read +/// from a separate file that is not checked into version control. In production, use a secure +/// means of storing this information, such as the secret manager for Podman. +use serde::Deserialize; + +#[derive(Default, Deserialize)] +/// Non-sensitive configuration values. +/// +/// See the [module-level documentation](index.html) for more information. +pub struct Config { + pub game_server: Option, + pub auth_server: Option, + pub position: Option<[f32; 3]>, + pub orientation: Option, +} + +#[derive(Deserialize)] +/// Sensitive configuration values. +/// +/// See the [module-level documentation](index.html) for more information. +pub struct Secrets { + pub username: String, + pub password: String, + pub character: String, + pub admins: Vec, +} diff --git a/src/main.rs b/src/main.rs index 0c49d8d..3ed18f8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,61 +1,59 @@ -#![feature(extend_one)] +#![feature(duration_constructors)] mod bot; +mod config; -use std::{ - env::var, - fs::{read_to_string, write}, -}; +use std::{env::var, fs::read_to_string}; use bot::Bot; -use log::{error, info}; -use serde::{Deserialize, Serialize}; -use veloren_common::uuid::Uuid; - -#[derive(Serialize, Deserialize)] -struct Config { - pub username: String, - pub password: String, - pub admin_list: Vec, - pub ban_list: Vec, -} - -impl Config { - fn read() -> Result { - info!("Reading config"); - - let config_path = var("CONFIG_PATH").map_err(|error| error.to_string())?; - let config_file_content = read_to_string(config_path).map_err(|error| error.to_string())?; - - toml::from_str::(&config_file_content).map_err(|error| error.to_string()) - } - - fn write(&self) -> Result<(), String> { - info!("Writing config"); - - let config_path = var("CONFIG_PATH").map_err(|error| error.to_string())?; - let config_string = toml::to_string(self).map_err(|error| error.to_string())?; - - write(config_path, config_string).map_err(|error| error.to_string()) - } -} +use config::{Config, Secrets}; +use env_logger::Env; +use log::error; fn main() { - env_logger::init(); + env_logger::Builder::from_env(Env::default().default_filter_or("debug")).init(); - let config = Config::read().unwrap(); + let secrets = { + let secrets_path = + var("SECRETS").expect("Provide a SECRETS variable specifying the secrets file"); + let file_content = read_to_string(secrets_path).expect("Failed to read secrets"); + + toml::from_str::(&file_content).expect("Failed to parse secrets") + }; + let config = { + if let Ok(config_path) = var("CONFIG") { + let file_content = read_to_string(config_path).expect("Failed to read config"); + + toml::from_str::(&file_content).expect("Failed to parse config") + } else { + Config::default() + } + }; + let game_server = config + .game_server + .unwrap_or_else(|| "server.veloren.net".to_string()); + let auth_server = config + .auth_server + .unwrap_or_else(|| "https://auth.veloren.net".to_string()); let mut bot = Bot::new( - &config.username, - &config.password, - config.admin_list, - config.ban_list, + game_server, + &auth_server, + secrets.username, + &secrets.password, + &secrets.character, + secrets.admins, + config.position, + config.orientation, ) .expect("Failed to create bot"); - bot.select_character().expect("Failed to select character"); - - #[allow(unused_must_use)] loop { - bot.tick().inspect_err(|e| error!("{e}")); + match bot.tick() { + Ok(true) => return, + Ok(false) => {} + Err(error) => { + error!("{error}"); + } + } } }