Add player tokens 'Pawn', 'Bicycle', 'Train', 'Boot', 'Dog', 'Tank', 'Cannon', 'Duck', and 'Wastebasket'; Add player teams; Add 'friendly_fire' flag to configurations; Add 'addr', 'name' and 'password' fields to configuration; Add base for network support; Reconfigure release profile;

This commit is contained in:
Gabriel Bjørnager Jensen 2025-04-05 15:10:50 +02:00
parent 30d23c0858
commit efa690180d
30 changed files with 496 additions and 142 deletions

View file

@ -3,6 +3,15 @@
This is the changelog of Bedrock.
See `README.md` for more information.
## 0.5.0-4
* Add player tokens `Pawn`, `Bicycle`, `Train`, `Boot`, `Dog`, `Tank`, `Cannon`, `Duck`, and `Wastebasket`
* Add player teams
* Add `friendly_fire` flag to configurations
* Add `addr`, `name` and `password` fields to configuration
* Add base for network support
* Reconfigure release profile
## 0.5.0-3
* Change default level back to `lava_lake`

213
Cargo.lock generated
View file

@ -108,9 +108,11 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
[[package]]
name = "bedrock"
version = "0.5.0-3"
version = "0.5.0-4"
dependencies = [
"conststr",
"ctrlc",
"oct",
"pollster",
"polywave",
"rand",
@ -119,7 +121,7 @@ dependencies = [
"toml",
"wgpu",
"winit",
"zerocopy 0.8.20",
"zerocopy 0.8.24",
]
[[package]]
@ -184,26 +186,20 @@ dependencies = [
[[package]]
name = "bytemuck_derive"
version = "1.8.1"
version = "1.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fa76293b4f7bb636ab88fd78228235b5248b4d05cc589aed610f954af5d7c7a"
checksum = "7ecc273b49b3205b83d648f0690daa588925572cc5063745bfe547fe7ec8e1a1"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "byteorder"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]]
name = "bytes"
version = "1.10.0"
version = "1.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f61dac84819c6588b558454b194026eb1f09c293b9036ae9b159e74e73ab6cf9"
checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a"
[[package]]
name = "calloop"
@ -233,9 +229,9 @@ dependencies = [
[[package]]
name = "cc"
version = "1.2.16"
version = "1.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be714c154be609ec7f5dad223a33bf1482fff90472de28f7362806e6d4832b8c"
checksum = "1fcb57c740ae1daf453ae85f16e37396f672b039e00d9d866e07ddb24e328e3a"
dependencies = [
"jobserver",
"libc",
@ -289,6 +285,16 @@ dependencies = [
"crossbeam-utils",
]
[[package]]
name = "conststr"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b02a51ffaca55ca1a5e02dc6f60179ac2e6afc4ad9254ecad49fd88368dcc02c"
dependencies = [
"oct",
"serde",
]
[[package]]
name = "core-foundation"
version = "0.9.4"
@ -395,9 +401,9 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
[[package]]
name = "errno"
version = "0.3.10"
version = "0.3.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
checksum = "976dd42dc7e85965fe702eb8164f21f450704bdde31faefd6471dba214cb594e"
dependencies = [
"libc",
"windows-sys 0.59.0",
@ -405,9 +411,9 @@ dependencies = [
[[package]]
name = "foldhash"
version = "0.1.4"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f"
checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
[[package]]
name = "foreign-types"
@ -459,14 +465,14 @@ dependencies = [
[[package]]
name = "getrandom"
version = "0.3.1"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8"
checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0"
dependencies = [
"cfg-if",
"libc",
"wasi 0.13.3+wasi-0.2.2",
"windows-targets 0.52.6",
"r-efi",
"wasi 0.14.2+wasi-0.2.4",
]
[[package]]
@ -581,9 +587,9 @@ checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df"
[[package]]
name = "indexmap"
version = "2.7.1"
version = "2.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652"
checksum = "3954d50fe15b02142bf25d3b8bdadb634ec3948f103d04ffe3031bc8fe9d7058"
dependencies = [
"equivalent",
"hashbrown",
@ -613,10 +619,11 @@ checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130"
[[package]]
name = "jobserver"
version = "0.1.32"
version = "0.1.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0"
checksum = "38f262f097c174adebe41eb73d66ae9c06b2844fb0da69969647bbddd9b0538a"
dependencies = [
"getrandom 0.3.2",
"libc",
]
@ -649,9 +656,9 @@ checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"
[[package]]
name = "libc"
version = "0.2.170"
version = "0.2.171"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828"
checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6"
[[package]]
name = "libloading"
@ -671,7 +678,7 @@ checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d"
dependencies = [
"bitflags 2.9.0",
"libc",
"redox_syscall 0.5.9",
"redox_syscall 0.5.10",
]
[[package]]
@ -698,9 +705,9 @@ dependencies = [
[[package]]
name = "log"
version = "0.4.26"
version = "0.4.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e"
checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
[[package]]
name = "malloc_buf"
@ -759,7 +766,7 @@ dependencies = [
"spirv",
"strum",
"termcolor",
"thiserror 2.0.11",
"thiserror 2.0.12",
"unicode-xid",
]
@ -1056,6 +1063,26 @@ dependencies = [
"objc2-foundation",
]
[[package]]
name = "oct"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c66317e183fb7a728d8730716b549d15e4481f6cba1bb518b5f027e51a59f0ff"
dependencies = [
"oct-macros",
]
[[package]]
name = "oct-macros"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ac7e988adbae84d9773c17842e3f1c451923415378bfac3f2387a52b1b5f064"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "once_cell"
version = "1.21.3"
@ -1107,7 +1134,7 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8"
dependencies = [
"cfg-if",
"libc",
"redox_syscall 0.5.9",
"redox_syscall 0.5.10",
"smallvec",
"windows-targets 0.52.6",
]
@ -1126,18 +1153,18 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
[[package]]
name = "pin-project"
version = "1.1.9"
version = "1.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfe2e71e1471fe07709406bf725f710b02927c9c54b2b5b2ec0e8087d97c327d"
checksum = "677f1add503faace112b9f1373e43e9e054bfdd22ff1a63c1bc485eaec6a6a8a"
dependencies = [
"pin-project-internal",
]
[[package]]
name = "pin-project-internal"
version = "1.1.9"
version = "1.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6e859e6e5bd50440ab63c47e3ebabc90f26251f7c73c3d3e837b74a1cc3fa67"
checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861"
dependencies = [
"proc-macro2",
"quote",
@ -1152,9 +1179,9 @@ checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b"
[[package]]
name = "pkg-config"
version = "0.3.31"
version = "0.3.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2"
checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c"
[[package]]
name = "polling"
@ -1179,20 +1206,20 @@ checksum = "2f3a9f18d041e6d0e102a0a46750538147e5e8992d3b4873aaafee2520b00ce3"
[[package]]
name = "polywave"
version = "0.8.0"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49cd618dd0f4223dabd6d18d99d6d5564714b3c271cb881ed57ce61239c9e238"
checksum = "9332f1f5e96afc2417745fd3b8245b5cceeb20beca403728ca79ac3aa09a5df3"
dependencies = [
"zerocopy 0.8.20",
"zerocopy 0.8.24",
]
[[package]]
name = "ppv-lite86"
version = "0.2.20"
version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04"
checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
dependencies = [
"zerocopy 0.7.35",
"zerocopy 0.8.24",
]
[[package]]
@ -1203,18 +1230,18 @@ checksum = "e8cf8e6a8aa66ce33f63993ffc4ea4271eb5b0530a9002db8455ea6050c77bfa"
[[package]]
name = "proc-macro-crate"
version = "3.2.0"
version = "3.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b"
checksum = "edce586971a4dfaa28950c6f18ed55e0406c1ab88bbce2c6f6293a7aaba73d35"
dependencies = [
"toml_edit",
]
[[package]]
name = "proc-macro2"
version = "1.0.93"
version = "1.0.94"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99"
checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84"
dependencies = [
"unicode-ident",
]
@ -1227,22 +1254,28 @@ checksum = "afbdc74edc00b6f6a218ca6a5364d6226a259d4b8ea1af4a0ea063f27e179f4d"
[[package]]
name = "quick-xml"
version = "0.37.2"
version = "0.37.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "165859e9e55f79d67b96c5d96f4e88b6f2695a1972849c15a6a3f5c59fc2c003"
checksum = "a4ce8c88de324ff838700f36fb6ab86c96df0e3c4ab6ef3a9b2044465cce1369"
dependencies = [
"memchr",
]
[[package]]
name = "quote"
version = "1.0.38"
version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc"
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
dependencies = [
"proc-macro2",
]
[[package]]
name = "r-efi"
version = "5.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5"
[[package]]
name = "rand"
version = "0.9.0"
@ -1251,7 +1284,7 @@ checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94"
dependencies = [
"rand_chacha",
"rand_core",
"zerocopy 0.8.20",
"zerocopy 0.8.24",
]
[[package]]
@ -1266,12 +1299,11 @@ dependencies = [
[[package]]
name = "rand_core"
version = "0.9.2"
version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a509b1a2ffbe92afab0e55c8fd99dea1c280e8171bd2d88682bb20bc41cbc2c"
checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
dependencies = [
"getrandom 0.3.1",
"zerocopy 0.8.20",
"getrandom 0.3.2",
]
[[package]]
@ -1297,9 +1329,9 @@ dependencies = [
[[package]]
name = "redox_syscall"
version = "0.5.9"
version = "0.5.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "82b568323e98e49e2a0899dcee453dd679fae22d69adf9b11dd508d1549b7e2f"
checksum = "0b8c0c260b63a8219631167be35e6a988e9554dbd323f8bd08439c8ed1302bd1"
dependencies = [
"bitflags 2.9.0",
]
@ -1331,9 +1363,9 @@ dependencies = [
[[package]]
name = "rustversion"
version = "1.0.19"
version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4"
checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2"
[[package]]
name = "same-file"
@ -1371,18 +1403,18 @@ dependencies = [
[[package]]
name = "serde"
version = "1.0.218"
version = "1.0.219"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60"
checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.218"
version = "1.0.219"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b"
checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
dependencies = [
"proc-macro2",
"quote",
@ -1507,9 +1539,9 @@ dependencies = [
[[package]]
name = "syn"
version = "2.0.98"
version = "2.0.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1"
checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0"
dependencies = [
"proc-macro2",
"quote",
@ -1536,11 +1568,11 @@ dependencies = [
[[package]]
name = "thiserror"
version = "2.0.11"
version = "2.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc"
checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708"
dependencies = [
"thiserror-impl 2.0.11",
"thiserror-impl 2.0.12",
]
[[package]]
@ -1556,9 +1588,9 @@ dependencies = [
[[package]]
name = "thiserror-impl"
version = "2.0.11"
version = "2.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2"
checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d"
dependencies = [
"proc-macro2",
"quote",
@ -1668,9 +1700,9 @@ checksum = "d2df906b07856748fa3f6e0ad0cbaa047052d4a7dd609e231c4f72cee8c36f31"
[[package]]
name = "unicode-ident"
version = "1.0.17"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00e2473a93778eb0bad35909dff6a10d28e63f792f16ed15e404fca9d5eeedbe"
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
[[package]]
name = "unicode-segmentation"
@ -1714,9 +1746,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wasi"
version = "0.13.3+wasi-0.2.2"
version = "0.14.2+wasi-0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2"
checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3"
dependencies = [
"wit-bindgen-rt",
]
@ -1967,16 +1999,16 @@ dependencies = [
"raw-window-handle",
"rustc-hash",
"smallvec",
"thiserror 2.0.11",
"thiserror 2.0.12",
"wgpu-hal",
"wgpu-types",
]
[[package]]
name = "wgpu-hal"
version = "24.0.2"
version = "24.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4317a17171dc20e6577bf606796794580accae0716a69edbc7388c86a3ec9f23"
checksum = "f112f464674ca69f3533248508ee30cb84c67cf06c25ff6800685f5e0294e259"
dependencies = [
"android_system_properties",
"arrayvec",
@ -2010,7 +2042,7 @@ dependencies = [
"renderdoc-sys",
"rustc-hash",
"smallvec",
"thiserror 2.0.11",
"thiserror 2.0.12",
"wasm-bindgen",
"web-sys",
"wgpu-types",
@ -2362,18 +2394,18 @@ dependencies = [
[[package]]
name = "winnow"
version = "0.7.3"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e7f4ea97f6f78012141bcdb6a216b2609f0979ada50b20ca5b52dde2eac2bb1"
checksum = "0e97b544156e9bebe1a0ffbc03484fc1ffe3100cbce3ffb17eac35f7cdd7ab36"
dependencies = [
"memchr",
]
[[package]]
name = "wit-bindgen-rt"
version = "0.33.0"
version = "0.39.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c"
checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1"
dependencies = [
"bitflags 2.9.0",
]
@ -2447,17 +2479,16 @@ version = "0.7.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0"
dependencies = [
"byteorder",
"zerocopy-derive 0.7.35",
]
[[package]]
name = "zerocopy"
version = "0.8.20"
version = "0.8.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dde3bb8c68a8f3f1ed4ac9221aad6b10cece3e60a8e2ea54a6a2dec806d0084c"
checksum = "2586fea28e186957ef732a5f8b3be2da217d65c5969d4b1e17f973ebbe876879"
dependencies = [
"zerocopy-derive 0.8.20",
"zerocopy-derive 0.8.24",
]
[[package]]
@ -2473,9 +2504,9 @@ dependencies = [
[[package]]
name = "zerocopy-derive"
version = "0.8.20"
version = "0.8.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eea57037071898bf96a6da35fd626f4f27e9cee3ead2a6c703cf09d472b2e700"
checksum = "a996a8f63c5c4448cd959ac1bab0aaa3306ccfd060472f85943ee0750f0169be"
dependencies = [
"proc-macro2",
"quote",

View file

@ -1,6 +1,6 @@
[package]
name = "bedrock"
version = "0.5.0-3"
version = "0.5.0-4"
authors = ["Achernar", "Gabriel Bjørnager Jensen"]
edition = "2024"
repository = "https://mandelbrot.dk/achernar/bedrock/"
@ -13,9 +13,11 @@ toml = "0.8"
wgpu = "24.0"
winit = "0.30"
conststr = { version = "0.3", features = ["oct"] }
oct = { version = "0.22", features = ["proc-macro"]}
polywave = { version = "0.8", features = ["zerocopy"] }
serde = { version = "1.0", features = ["derive"] }
zerocopy = { version = "0.8", features = ["derive", "float-nightly"] }
zerocopy = { version = "0.8", features = ["derive"] }
[target.'cfg(not(target_env = "msvc"))'.dependencies]
tikv-jemallocator = "0.6"
@ -172,10 +174,11 @@ wildcard_dependencies = "forbid"
zero_prefixed_literal = "allow"
[profile.release]
opt-level = 3
strip = "none"
lto = "fat"
panic = "abort"
codegen-units = 1
lto = "fat"
opt-level = 3
[workspace]
exclude = ["wgpu"]

View file

@ -64,7 +64,7 @@ impl ApplicationHandler<UserEvent> for App {
if Instant::now() >= self.next_tick {
cold_path();
self.next_tick = Instant::now() + Duration::from_nanos(1_000_000_000 / u64::from(self.config.tps));
self.next_tick = Instant::now() + Duration::from_nanos(1_000_000_000 / u64::from(self.preset.tps));
self.tick();

View file

@ -15,9 +15,13 @@ impl App {
event: KeyEvent,
_is_synthetic: bool,
) {
if event.repeat { return };
if event.repeat {
return;
}
if matches!(event.state, ElementState::Released) { return };
if matches!(event.state, ElementState::Released) {
return;
}
match event.physical_key {
PhysicalKey::Code(
@ -31,11 +35,11 @@ impl App {
_ => unreachable!(),
};
let tps = self.config.tps.saturating_add_signed(off).max(0x1);
let tps = self.preset.tps.saturating_add_signed(off).max(0x1);
log!(note, "new tps is clamped at `{tps}`");
self.config.tps = tps;
self.preset.tps = tps;
}
PhysicalKey::Code(KeyCode::Escape) => {

View file

@ -83,7 +83,7 @@ impl App {
log!(note, "new x pan is unclamped at `{pan}`");
let pan = pan.clamp(0x0, self.config.map_size.width() - 0x1);
let pan = pan.clamp(0x0, self.preset.map_size.width() - 0x1);
log!(note, "new x pan is clamped to `{pan}`");
@ -102,7 +102,7 @@ impl App {
log!(note, "new y pan is unclamped at `{pan}`");
let pan = pan.clamp(0x0, self.config.map_size.height() - 0x1);
let pan = pan.clamp(0x0, self.preset.map_size.height() - 0x1);
log!(note, "new y pan is clamped to `{pan}`");

View file

@ -17,7 +17,7 @@ impl App {
self.players.clear();
self.players.push(Default::default());
self.players.insert(Default::default());
self.regenerate_level();

View file

@ -11,12 +11,12 @@ mod respawn_players;
mod run;
mod tick;
use crate::app::UserEvent;
use crate::config::Config;
use crate::app::{Config, UserEvent};
use crate::graphics::GraphicsContext;
use crate::level::Level;
use crate::map::Map;
use crate::player::Player;
use crate::player::PlayerList;
use crate::preset::Preset;
use std::path::PathBuf;
use std::time::Instant;
@ -33,10 +33,11 @@ pub struct App {
data_dir: PathBuf,
config: Config,
preset: Preset,
level: Level,
map: Map,
players: Vec<Player>,
players: PlayerList,
raw_view_scale: f64,

View file

@ -99,14 +99,14 @@ impl App {
assert!(self.level.chunks.len() <= u8::MAX as usize);
self.map.resize(self.config.map_size);
self.map.resize(self.preset.map_size);
roll_seeds(&mut self.map);
generate_columns(
self.map.columns_mut(),
&self.level,
self.config.map_size,
self.preset.map_size,
);
fill_bedrock(&mut self.map);

View file

@ -57,6 +57,7 @@ impl App {
data_dir: Self::get_data_dir()?,
config: Default::default(),
preset: Default::default(),
level: Default::default(),
map: Default::default(),

12
src/app/config/mod.rs Normal file
View file

@ -0,0 +1,12 @@
// Copyright 2025 Gabriel Bjørnager Jensen.
use crate::message::{LobbyName, LobbyPassword};
use std::net::SocketAddr;
#[derive(Clone, Debug, Default)]
pub struct Config {
pub addr: Option<SocketAddr>,
pub name: LobbyName,
pub password: LobbyPassword,
}

View file

@ -1,8 +1,12 @@
// Copyright 2025 Gabriel Bjørnager Jensen.
mod app;
mod config;
mod user_event;
pub use app::App;
use config::Config;
use user_event::UserEvent;
pub const DEFAULT_PORT: u16 = 0x4274;

View file

@ -1,10 +0,0 @@
// Copyright 2025 Gabriel Bjørnager Jensen.
use crate::map::MapSize;
#[derive(Clone, Debug, Default)]
pub struct Config {
pub map_size: MapSize,
pub tps: u16 = 0x8,
}

View file

@ -0,0 +1,31 @@
// Copyright 2025 Gabriel Bjørnager Jensen.
use oct::error::GenericDecodeError;
use std::fmt::{self, Display, Formatter};
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct DecodeError(Box<str>);
impl DecodeError {
#[inline]
#[must_use]
pub fn new<S: Display>(message: S) -> Self {
Self(message.to_string().into())
}
}
impl Display for DecodeError {
#[inline]
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
write!(f, "decode error: {}", self.0)
}
}
impl std::error::Error for DecodeError { }
impl<T: Into<GenericDecodeError>> From<T> for DecodeError{
#[inline(always)]
fn from(value: T) -> Self {
Self::new(value.into())
}
}

View file

@ -1,7 +1,9 @@
// Copyright 2025 Gabriel Bjørnager Jensen.
mod decode_error;
mod error;
pub use decode_error::DecodeError;
pub use error::Error;
pub type Result<T> = std::result::Result<T, Error>;

View file

@ -3,6 +3,7 @@
#![allow(internal_features)]
#![feature(cold_path)]
#![feature(const_try)]
#![feature(default_field_values)]
#![feature(generic_arg_infer)]
#![feature(rustc_attrs)]
@ -12,13 +13,14 @@ extern crate self as bedrock;
const _: () = assert!(usize::BITS >= u32::BITS);
mod app;
mod config;
mod error;
mod graphics;
mod level;
mod map;
mod message;
mod log;
mod player;
mod preset;
mod version;
#[cfg(not(target_env = "msvc"))]

View file

@ -37,7 +37,9 @@ impl<'a> ColumnWindowsMut<'a> {
#[inline]
#[must_use]
pub fn next(&mut self) -> Option<[&'a mut Block; 0x2]> {
if self.is_empty() { return None };
if self.is_empty() {
return None;
}
// SAFETY: `ptr` is always within bounds if `len`
// is non-null.

View file

@ -1,9 +1,13 @@
// Copyright 2025 Gabriel Bjørnager Jensen.
use crate::error::DecodeError;
use oct::decode::{self, Decode};
use oct::encode::{Encode, SizedEncode};
use std::hint::assert_unchecked;
use std::num::NonZero;
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, Encode, SizedEncode)]
pub struct MapSize {
width: NonZero<u32>,
height: NonZero<u32>,
@ -13,15 +17,12 @@ impl MapSize {
#[inline(always)]
#[must_use]
pub const fn new(width: u32, height: u32) -> Option<Self> {
if width % 0x2 != 0x0 { return None };
if height % 0x2 != 0x0 { return None };
if width == 0x0 { return None };
if height == 0x0 { return None };
if width % 0x2 != 0x0 || width == 0x0 { return None };
if height % 0x2 != 0x0 || height == 0x0 { return None };
// FIXME(const-hacks): We cannot try in constant
// expressions.
if width.checked_mul(height).is_none() {
if height.checked_mul(width).is_none() {
return None;
}
@ -101,6 +102,18 @@ impl MapSize {
}
}
impl Decode for MapSize {
type Error = DecodeError;
fn decode(input: &mut decode::Input) -> Result<Self, Self::Error> {
let Ok(width) = u32::decode(input);
let Ok(height) = u32::decode(input);
Self::new(width, height)
.ok_or_else(|| DecodeError::new("unable to decode map size"))
}
}
impl Default for MapSize {
#[inline(always)]
fn default() -> Self {

View file

@ -0,0 +1,30 @@
// Copyright 2025 Gabriel Bjørnager Jensen.
use crate::error::DecodeError;
use crate::message::{ChatMessage, LobbyPassword, Username};
use crate::player::Team;
use crate::preset::Preset;
use oct::decode::Decode;
use oct::encode::{Encode, SizedEncode};
#[derive(Debug, Decode, Encode, SizedEncode)]
#[oct(decode_error = DecodeError)]
pub enum Message {
Join {
username: Username,
password: LobbyPassword,
},
Chat(ChatMessage),
UpdatePreset(Preset),
Quit,
Kick,
Start,
ChangeTeam(Team),
}

12
src/message/mod.rs Normal file
View file

@ -0,0 +1,12 @@
// Copyright 2025 Gabriel Bjørnager Jensen.
mod message;
pub use message::Message;
use conststr::String;
pub type LobbyName = String<0x10>;
pub type LobbyPassword = String<0x40>;
pub type Username = String<0x10>;
pub type ChatMessage = String<0x40>;

View file

@ -0,0 +1,17 @@
// Copyright 2025 Gabriel Bjørnager Jensen.
use crate::message::Message;
use oct::slot::Slot;
use std::net::TcpStream;
#[derive(Debug, Default)]
pub enum Connexion {
#[default]
Local,
Remote {
stream: TcpStream,
buf: Slot<Message>,
},
}

View file

@ -1,4 +0,0 @@
// Copyright 2025 Gabriel Bjørnager Jensen.
#[derive(Clone, Debug, Default)]
pub struct Controls;

View file

@ -1,7 +1,13 @@
// Copyright 2025 Gabriel Bjørnager Jensen.
mod controls;
mod connexion;
mod player;
mod player_list;
mod team;
mod token;
pub use controls::Controls;
pub use connexion::Connexion;
pub use player::Player;
pub use player_list::PlayerList;
pub use team::Team;
pub use token::Token;

View file

@ -1,12 +1,16 @@
// Copyright 2025 Gabriel Bjørnager Jensen.
use crate::player::Controls;
use crate::player::{Connexion, Team, Token};
use std::borrow::Cow;
#[derive(Clone, Debug, Default)]
#[derive(Debug, Default)]
pub struct Player {
pub name: Cow<'static, str> = Cow::Borrowed("epsiloneridani"),
pub name: Cow<'static, str> = Cow::Borrowed("epsiloneridani"),
pub token: Token,
pub team: Team,
pub controls: Controls,
pub is_admin: bool,
pub connexion: Connexion,
}

View file

@ -0,0 +1,115 @@
// Copyright 2025 Gabriel Bjørnager Jensen.
use crate::log::log;
use crate::message::Message;
use crate::player::{Connexion, Player};
use std::io::{self, Write};
use std::slice;
use std::vec;
#[derive(Debug, Default)]
pub struct PlayerList(Vec<Player>);
impl PlayerList {
#[inline(always)]
#[track_caller]
pub fn clear(&mut self) {
self.0.clear()
}
#[inline(always)]
#[track_caller]
pub fn insert(&mut self, player: Player) -> bool {
if self.iter().any(|p| p.name == player.name) {
return true;
}
self.0.push(player);
false
}
pub fn remove(&mut self, name: &str) -> Option<Player> {
let index = self.iter().position(|p| p.name == name)?;
let player = self.0.remove(index);
Some(player)
}
pub fn send_message_to_all(&mut self, message: &Message) -> io::Result<()> {
log!(debug, "sending message `{message:?}` to players");
for player in self {
if let Connexion::Remote { ref mut stream, ref mut buf } = player.connexion {
buf.write(message).unwrap();
if let Err(e) = stream.write(buf) {
let addr = stream.peer_addr().unwrap();
log!("unable to send message to `{addr}`: {e}");
}
}
}
Ok(())
}
#[allow(unused)]
#[inline(always)]
#[must_use]
pub const fn len(&self) -> usize {
self.0.len()
}
#[allow(unused)]
#[inline(always)]
#[must_use]
pub const fn is_empty(&self) -> bool {
self.0.is_empty()
}
#[allow(unused)]
#[inline(always)]
pub fn iter(&self) -> slice::Iter<Player> {
self.0.iter()
}
#[allow(unused)]
#[inline(always)]
pub fn iter_mut(&mut self) -> slice::IterMut<Player> {
self.0.iter_mut()
}
}
impl IntoIterator for PlayerList {
type Item = Player;
type IntoIter = vec::IntoIter<Player>;
#[inline(always)]
fn into_iter(self) -> Self::IntoIter {
self.0.into_iter()
}
}
impl<'a> IntoIterator for &'a PlayerList {
type Item = &'a Player;
type IntoIter = slice::Iter<'a, Player>;
#[inline(always)]
fn into_iter(self) -> Self::IntoIter {
self.iter()
}
}
impl<'a> IntoIterator for &'a mut PlayerList {
type Item = &'a mut Player;
type IntoIter = slice::IterMut<'a, Player>;
#[inline(always)]
fn into_iter(self) -> Self::IntoIter {
self.iter_mut()
}
}

19
src/player/team/mod.rs Normal file
View file

@ -0,0 +1,19 @@
// Copyright 2025 Gabriel Bjørnager Jensen.
use oct::decode::Decode;
use oct::encode::{Encode, SizedEncode};
#[repr(u8)]
#[derive(Clone, Copy, Debug, Decode, Default, Encode, Eq, PartialEq, SizedEncode)]
pub enum Team {
#[default]
None,
Red,
Blue,
Green,
Yellow,
White,
Black,
Purple,
}

20
src/player/token/mod.rs Normal file
View file

@ -0,0 +1,20 @@
// Copyright 2025 Gabriel Bjørnager Jensen.
use oct::decode::Decode;
use oct::encode::{Encode, SizedEncode};
#[repr(u8)]
#[derive(Clone, Copy, Debug, Decode, Default, Encode, Eq, PartialEq, SizedEncode)]
pub enum Token {
#[default]
Pawn,
Bicycle,
Train,
Boot,
Dog,
Tank,
Cannon,
Duck,
Wastebasket,
}

View file

@ -1,5 +1,5 @@
// Copyright 2025 Gabriel Bjørnager Jensen.
mod config;
mod preset;
pub use config::Config;
pub use preset::Preset;

30
src/preset/preset/mod.rs Normal file
View file

@ -0,0 +1,30 @@
// Copyright 2025 Gabriel Bjørnager Jensen.
use crate::error::DecodeError;
use crate::map::MapSize;
use oct::decode::Decode;
use oct::encode::{Encode, SizedEncode};
#[derive(Clone, Debug, Decode, Encode, SizedEncode)]
#[oct(decode_error = DecodeError)]
pub struct Preset {
pub map_size: MapSize,
pub tps: u16,
pub friendly_fire: bool,
}
// FIXME: `syn` does not parse default field val-
// ues.
impl Default for Preset {
#[inline(always)]
fn default() -> Self {
Self {
map_size: Default::default(),
tps: 0x8,
friendly_fire: true,
}
}
}

View file

@ -15,7 +15,7 @@ impl Version {
major: 0x0,
minor: 0x5,
patch: 0x0,
pre: Some(0x3),
pre: Some(0x4),
};
}