mirror of
https://codeberg.org/icewind/sourcenav.git
synced 2026-06-03 18:24:10 +02:00
finish binrw rework
This commit is contained in:
parent
3adbbe761c
commit
048a2e7dbe
7 changed files with 703 additions and 271 deletions
678
Cargo.lock
generated
678
Cargo.lock
generated
|
|
@ -1,5 +1,7 @@
|
||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
|
version = 4
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aabb-quadtree"
|
name = "aabb-quadtree"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
|
|
@ -11,6 +13,33 @@ dependencies = [
|
||||||
"smallvec",
|
"smallvec",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "aho-corasick"
|
||||||
|
version = "1.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "anes"
|
||||||
|
version = "0.1.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "anstyle"
|
||||||
|
version = "1.0.10"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "array-init"
|
||||||
|
version = "2.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3d62b7694a562cdf5a74227903507c56ab2cc8bdd1f781ed5cb4cf9c9f810bfc"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "autocfg"
|
name = "autocfg"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
|
|
@ -18,25 +47,169 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
|
checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "binread"
|
name = "binrw"
|
||||||
version = "1.0.1"
|
version = "0.15.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "26cf5bb84d4f4a83abea99e345181ee66ad0616609cc105a54663409ad4b773c"
|
checksum = "81419ff39e6ed10a92a7f125290859776ced35d9a08a665ae40b23e7ca702f30"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"binread_derive",
|
"array-init",
|
||||||
|
"binrw_derive",
|
||||||
|
"bytemuck",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "binread_derive"
|
name = "binrw_derive"
|
||||||
version = "1.0.2"
|
version = "0.15.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c030fc40c89f14be583794fd033b29263e8d3ff205ee5fefb3087774319cc013"
|
checksum = "376404e55ec40d0d6f8b4b7df3f87b87954bd987f0cf9a7207ea3b6ea5c9add4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 1.0.10",
|
"either",
|
||||||
"quote 1.0.3",
|
"owo-colors",
|
||||||
"syn 1.0.18",
|
"proc-macro2 1.0.95",
|
||||||
|
"quote 1.0.40",
|
||||||
|
"syn 2.0.101",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bumpalo"
|
||||||
|
version = "3.17.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bytemuck"
|
||||||
|
version = "1.23.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9134a6ef01ce4b366b50689c94f82c14bc72bc5d0386829828a2e2752ef7958c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cast"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg-if"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ciborium"
|
||||||
|
version = "0.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e"
|
||||||
|
dependencies = [
|
||||||
|
"ciborium-io",
|
||||||
|
"ciborium-ll",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ciborium-io"
|
||||||
|
version = "0.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ciborium-ll"
|
||||||
|
version = "0.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9"
|
||||||
|
dependencies = [
|
||||||
|
"ciborium-io",
|
||||||
|
"half",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap"
|
||||||
|
version = "4.5.39"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fd60e63e9be68e5fb56422e397cf9baddded06dae1d2e523401542383bc72a9f"
|
||||||
|
dependencies = [
|
||||||
|
"clap_builder",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap_builder"
|
||||||
|
version = "4.5.39"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "89cc6392a1f72bbeb820d71f32108f61fdaf18bc526e1d23954168a67759ef51"
|
||||||
|
dependencies = [
|
||||||
|
"anstyle",
|
||||||
|
"clap_lex",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap_lex"
|
||||||
|
version = "0.7.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "criterion"
|
||||||
|
version = "0.6.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3bf7af66b0989381bd0be551bd7cc91912a655a58c6918420c9527b1fd8b4679"
|
||||||
|
dependencies = [
|
||||||
|
"anes",
|
||||||
|
"cast",
|
||||||
|
"ciborium",
|
||||||
|
"clap",
|
||||||
|
"criterion-plot",
|
||||||
|
"itertools 0.13.0",
|
||||||
|
"num-traits",
|
||||||
|
"oorandom",
|
||||||
|
"plotters",
|
||||||
|
"rayon",
|
||||||
|
"regex",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"tinytemplate",
|
||||||
|
"walkdir",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "criterion-plot"
|
||||||
|
version = "0.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1"
|
||||||
|
dependencies = [
|
||||||
|
"cast",
|
||||||
|
"itertools 0.10.5",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crossbeam-deque"
|
||||||
|
version = "0.8.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51"
|
||||||
|
dependencies = [
|
||||||
|
"crossbeam-epoch",
|
||||||
|
"crossbeam-utils",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crossbeam-epoch"
|
||||||
|
version = "0.9.18"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e"
|
||||||
|
dependencies = [
|
||||||
|
"crossbeam-utils",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crossbeam-utils"
|
||||||
|
version = "0.8.21"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crunchy"
|
||||||
|
version = "0.2.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "doc-comment"
|
name = "doc-comment"
|
||||||
version = "0.3.3"
|
version = "0.3.3"
|
||||||
|
|
@ -44,18 +217,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"
|
checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "err-derive"
|
name = "either"
|
||||||
version = "0.2.4"
|
version = "1.15.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "22deed3a8124cff5fa835713fa105621e43bbdc46690c3a6b68328a012d350d4"
|
checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
|
||||||
dependencies = [
|
|
||||||
"proc-macro-error",
|
|
||||||
"proc-macro2 1.0.10",
|
|
||||||
"quote 1.0.3",
|
|
||||||
"rustversion",
|
|
||||||
"syn 1.0.18",
|
|
||||||
"synstructure",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "euclid"
|
name = "euclid"
|
||||||
|
|
@ -84,6 +249,56 @@ version = "1.0.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"
|
checksum = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "half"
|
||||||
|
version = "2.6.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "459196ed295495a68f7d7fe1d84f6c4b7ff0e21fe3017b2f283c6fac3ad803c9"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"crunchy",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "itertools"
|
||||||
|
version = "0.10.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
|
||||||
|
dependencies = [
|
||||||
|
"either",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "itertools"
|
||||||
|
version = "0.13.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
|
||||||
|
dependencies = [
|
||||||
|
"either",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "itoa"
|
||||||
|
version = "1.0.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "js-sys"
|
||||||
|
version = "0.3.77"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f"
|
||||||
|
dependencies = [
|
||||||
|
"once_cell",
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "log"
|
||||||
|
version = "0.4.27"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "maybe-uninit"
|
name = "maybe-uninit"
|
||||||
version = "2.0.0"
|
version = "2.0.0"
|
||||||
|
|
@ -91,38 +306,64 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
|
checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-traits"
|
name = "memchr"
|
||||||
version = "0.2.11"
|
version = "2.7.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096"
|
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-traits"
|
||||||
|
version = "0.2.19"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro-error"
|
name = "once_cell"
|
||||||
version = "1.0.2"
|
version = "1.21.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "98e9e4b82e0ef281812565ea4751049f1bdcdfccda7d3f459f2e138a40c08678"
|
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "oorandom"
|
||||||
|
version = "11.1.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "owo-colors"
|
||||||
|
version = "4.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "26995317201fa17f3656c36716aed4a7c81743a9634ac4c99c0eeda495db0cec"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "plotters"
|
||||||
|
version = "0.3.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro-error-attr",
|
"num-traits",
|
||||||
"proc-macro2 1.0.10",
|
"plotters-backend",
|
||||||
"quote 1.0.3",
|
"plotters-svg",
|
||||||
"syn 1.0.18",
|
"wasm-bindgen",
|
||||||
"version_check",
|
"web-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro-error-attr"
|
name = "plotters-backend"
|
||||||
version = "1.0.2"
|
version = "0.3.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4f5444ead4e9935abd7f27dc51f7e852a0569ac888096d5ec2499470794e2e53"
|
checksum = "df42e13c12958a16b3f7f4386b9ab1f3e7933914ecea48da7139435263a4172a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "plotters-svg"
|
||||||
|
version = "0.3.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "51bae2ac328883f7acdfea3d66a7c35751187f870bc81f94563733a154d7a670"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 1.0.10",
|
"plotters-backend",
|
||||||
"quote 1.0.3",
|
|
||||||
"syn 1.0.18",
|
|
||||||
"syn-mid",
|
|
||||||
"version_check",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -131,16 +372,16 @@ version = "0.4.30"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
|
checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-xid 0.1.0",
|
"unicode-xid",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.10"
|
version = "1.0.95"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "df246d292ff63439fea9bc8c0a270bed0e390d5ebd4db4ba15aba81111b5abe3"
|
checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-xid 0.2.0",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -154,22 +395,113 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.3"
|
version = "1.0.40"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f"
|
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 1.0.10",
|
"proc-macro2 1.0.95",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustversion"
|
name = "rayon"
|
||||||
version = "1.0.2"
|
version = "1.10.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b3bba175698996010c4f6dce5e7f173b6eb781fce25d2cfc45e27091ce0b79f6"
|
checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 1.0.10",
|
"either",
|
||||||
"quote 1.0.3",
|
"rayon-core",
|
||||||
"syn 1.0.18",
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rayon-core"
|
||||||
|
version = "1.12.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2"
|
||||||
|
dependencies = [
|
||||||
|
"crossbeam-deque",
|
||||||
|
"crossbeam-utils",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex"
|
||||||
|
version = "1.11.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
|
||||||
|
dependencies = [
|
||||||
|
"aho-corasick",
|
||||||
|
"memchr",
|
||||||
|
"regex-automata",
|
||||||
|
"regex-syntax",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex-automata"
|
||||||
|
version = "0.4.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
|
||||||
|
dependencies = [
|
||||||
|
"aho-corasick",
|
||||||
|
"memchr",
|
||||||
|
"regex-syntax",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex-syntax"
|
||||||
|
version = "0.8.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustversion"
|
||||||
|
version = "1.0.21"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ryu"
|
||||||
|
version = "1.0.20"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "same-file"
|
||||||
|
version = "1.0.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
|
||||||
|
dependencies = [
|
||||||
|
"winapi-util",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde"
|
||||||
|
version = "1.0.219"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
|
||||||
|
dependencies = [
|
||||||
|
"serde_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_derive"
|
||||||
|
version = "1.0.219"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2 1.0.95",
|
||||||
|
"quote 1.0.40",
|
||||||
|
"syn 2.0.101",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_json"
|
||||||
|
version = "1.0.140"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373"
|
||||||
|
dependencies = [
|
||||||
|
"itoa",
|
||||||
|
"memchr",
|
||||||
|
"ryu",
|
||||||
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -183,13 +515,14 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sourcenav"
|
name = "sourcenav"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aabb-quadtree",
|
"aabb-quadtree",
|
||||||
"binread",
|
"binrw",
|
||||||
|
"criterion",
|
||||||
"doc-comment",
|
"doc-comment",
|
||||||
"err-derive",
|
|
||||||
"euclid",
|
"euclid",
|
||||||
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -200,42 +533,55 @@ checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 0.4.30",
|
"proc-macro2 0.4.30",
|
||||||
"quote 0.6.13",
|
"quote 0.6.13",
|
||||||
"unicode-xid 0.1.0",
|
"unicode-xid",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
|
version = "2.0.101"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2 1.0.95",
|
||||||
|
"quote 1.0.40",
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "thiserror"
|
||||||
|
version = "2.0.12"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708"
|
||||||
|
dependencies = [
|
||||||
|
"thiserror-impl",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "thiserror-impl"
|
||||||
|
version = "2.0.12"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2 1.0.95",
|
||||||
|
"quote 1.0.40",
|
||||||
|
"syn 2.0.101",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tinytemplate"
|
||||||
|
version = "1.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-ident"
|
||||||
version = "1.0.18"
|
version = "1.0.18"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "410a7488c0a728c7ceb4ad59b9567eb4053d02e8cc7f5c0e0eeeb39518369213"
|
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
|
||||||
dependencies = [
|
|
||||||
"proc-macro2 1.0.10",
|
|
||||||
"quote 1.0.3",
|
|
||||||
"unicode-xid 0.2.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "syn-mid"
|
|
||||||
version = "0.5.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7be3539f6c128a931cf19dcee741c1af532c7fd387baa739c03dd2e96479338a"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2 1.0.10",
|
|
||||||
"quote 1.0.3",
|
|
||||||
"syn 1.0.18",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "synstructure"
|
|
||||||
version = "0.12.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2 1.0.10",
|
|
||||||
"quote 1.0.3",
|
|
||||||
"syn 1.0.18",
|
|
||||||
"unicode-xid 0.2.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-xid"
|
name = "unicode-xid"
|
||||||
|
|
@ -244,13 +590,161 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
|
checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-xid"
|
name = "walkdir"
|
||||||
version = "0.2.0"
|
version = "2.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
|
checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b"
|
||||||
|
dependencies = [
|
||||||
|
"same-file",
|
||||||
|
"winapi-util",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "version_check"
|
name = "wasm-bindgen"
|
||||||
version = "0.9.1"
|
version = "0.2.100"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce"
|
checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"once_cell",
|
||||||
|
"rustversion",
|
||||||
|
"wasm-bindgen-macro",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-backend"
|
||||||
|
version = "0.2.100"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6"
|
||||||
|
dependencies = [
|
||||||
|
"bumpalo",
|
||||||
|
"log",
|
||||||
|
"proc-macro2 1.0.95",
|
||||||
|
"quote 1.0.40",
|
||||||
|
"syn 2.0.101",
|
||||||
|
"wasm-bindgen-shared",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-macro"
|
||||||
|
version = "0.2.100"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407"
|
||||||
|
dependencies = [
|
||||||
|
"quote 1.0.40",
|
||||||
|
"wasm-bindgen-macro-support",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-macro-support"
|
||||||
|
version = "0.2.100"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2 1.0.95",
|
||||||
|
"quote 1.0.40",
|
||||||
|
"syn 2.0.101",
|
||||||
|
"wasm-bindgen-backend",
|
||||||
|
"wasm-bindgen-shared",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-shared"
|
||||||
|
version = "0.2.100"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "web-sys"
|
||||||
|
version = "0.3.77"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2"
|
||||||
|
dependencies = [
|
||||||
|
"js-sys",
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-util"
|
||||||
|
version = "0.1.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
||||||
|
dependencies = [
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-sys"
|
||||||
|
version = "0.59.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
|
||||||
|
dependencies = [
|
||||||
|
"windows-targets",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-targets"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
||||||
|
dependencies = [
|
||||||
|
"windows_aarch64_gnullvm",
|
||||||
|
"windows_aarch64_msvc",
|
||||||
|
"windows_i686_gnu",
|
||||||
|
"windows_i686_gnullvm",
|
||||||
|
"windows_i686_msvc",
|
||||||
|
"windows_x86_64_gnu",
|
||||||
|
"windows_x86_64_gnullvm",
|
||||||
|
"windows_x86_64_msvc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_aarch64_gnullvm"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_aarch64_msvc"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_gnu"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_gnullvm"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_msvc"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_gnu"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_gnullvm"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_msvc"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||||
|
|
|
||||||
13
Cargo.toml
13
Cargo.toml
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "sourcenav"
|
name = "sourcenav"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
authors = ["Robin Appelman <robin@icewind.nl>"]
|
authors = ["Robin Appelman <robin@icewind.nl>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
description = "parsing of SourceEngine .nav files"
|
description = "parsing of SourceEngine .nav files"
|
||||||
|
|
@ -10,10 +10,15 @@ documentation = "https://docs.rs/sourcenav"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
binread = "1.0.1"
|
binrw = "0.15.0"
|
||||||
err-derive = "0.2.4"
|
thiserror = "2.0.12"
|
||||||
aabb-quadtree = "0.2.0"
|
aabb-quadtree = "0.2.0"
|
||||||
euclid = "0.19"
|
euclid = "0.19"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
doc-comment = "0.3.3"
|
doc-comment = "0.3.3"
|
||||||
|
criterion = "0.6.0"
|
||||||
|
|
||||||
|
[[bench]]
|
||||||
|
name = "bench"
|
||||||
|
harness = false
|
||||||
|
|
@ -10,10 +10,11 @@ navigation areas are exposed.
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use sourcenav::get_quad_tree;
|
use sourcenav::get_quad_tree;
|
||||||
|
use std::io::Cursor;
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let file = std::fs::read("data/pl_badwater.nav")?;
|
let file = std::fs::read("data/pl_badwater.nav")?;
|
||||||
let tree = get_quad_tree(file)?;
|
let tree = get_quad_tree(&mut Cursor::new(file))?;
|
||||||
|
|
||||||
assert_eq!(220.83125, tree.find_best_height(320.0, -1030.0, 0.0));
|
assert_eq!(220.83125, tree.find_best_height(320.0, -1030.0, 0.0));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,39 @@
|
||||||
#![feature(test)]
|
use std::hint::black_box;
|
||||||
|
use criterion::{criterion_group, criterion_main, Criterion};
|
||||||
extern crate test;
|
|
||||||
|
|
||||||
use bitbuffer::{BitReadBuffer, BitReadStream, LittleEndian};
|
|
||||||
use sourcenav::{get_quad_tree, read_areas};
|
use sourcenav::{get_quad_tree, read_areas};
|
||||||
use std::fs::read;
|
use std::fs::read;
|
||||||
use test::Bencher;
|
use std::io::Cursor;
|
||||||
|
|
||||||
#[bench]
|
fn bench_badwater_areas(c: &mut Criterion) {
|
||||||
fn bench_badwater_areas(b: &mut Bencher) {
|
|
||||||
let file = read("data/pl_badwater.nav").unwrap();
|
let file = read("data/pl_badwater.nav").unwrap();
|
||||||
let data = BitReadStream::new(BitReadBuffer::new(file, LittleEndian));
|
|
||||||
|
|
||||||
b.iter(|| {
|
c.bench_function("badwater areas", |b| {
|
||||||
let _ = test::black_box(read_areas(data.clone()));
|
b.iter(|| {
|
||||||
})
|
let _ = black_box(read_areas(black_box(&mut Cursor::new(&file))));
|
||||||
|
})
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[bench]
|
fn bench_badwater_quads(c: &mut Criterion) {
|
||||||
fn bench_badwater_quads(b: &mut Bencher) {
|
|
||||||
let file = read("data/pl_badwater.nav").unwrap();
|
let file = read("data/pl_badwater.nav").unwrap();
|
||||||
let data = BitReadStream::new(BitReadBuffer::new(file, LittleEndian));
|
|
||||||
|
|
||||||
b.iter(|| {
|
c.bench_function("badwater areas", |b| {
|
||||||
let _ = test::black_box(get_quad_tree(data.clone()));
|
b.iter(|| {
|
||||||
})
|
let _ = black_box(get_quad_tree(black_box(&mut Cursor::new(&file))));
|
||||||
|
})
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[bench]
|
fn bench_tree_query(c: &mut Criterion) {
|
||||||
fn bench_tree_query(b: &mut Bencher) {
|
|
||||||
let file = read("data/pl_badwater.nav").unwrap();
|
let file = read("data/pl_badwater.nav").unwrap();
|
||||||
let tree = get_quad_tree(file).unwrap();
|
let tree = get_quad_tree(&mut Cursor::new(&file)).unwrap();
|
||||||
|
|
||||||
b.iter(|| {
|
c.bench_function("badwater areas", |b| {
|
||||||
test::black_box(tree.find_best_height(320.0, -1030.0, 0.0));
|
b.iter(|| {
|
||||||
})
|
let _ = black_box(tree.find_best_height(black_box(320.0), black_box(-1030.0), black_box(0.0)));
|
||||||
|
})
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
criterion_group!(benches, bench_badwater_areas, bench_badwater_quads, bench_tree_query);
|
||||||
|
criterion_main!(benches);
|
||||||
23
src/lib.rs
23
src/lib.rs
|
|
@ -3,10 +3,9 @@ pub use crate::navmesh::{
|
||||||
ApproachArea, Connections, EncounterPath, LadderConnections, LadderDirection, LightIntensity,
|
ApproachArea, Connections, EncounterPath, LadderConnections, LadderDirection, LightIntensity,
|
||||||
NavDirection, NavHidingSpot, NavQuad, Vector3, VisibleArea,
|
NavDirection, NavHidingSpot, NavQuad, Vector3, VisibleArea,
|
||||||
};
|
};
|
||||||
use crate::parser::read_quads;
|
|
||||||
pub use crate::parser::{read_areas, NavArea, ParseError};
|
pub use crate::parser::{read_areas, NavArea, ParseError};
|
||||||
use aabb_quadtree::{ItemId, QuadTree};
|
use aabb_quadtree::{ItemId, QuadTree};
|
||||||
use binread::io::{Read, Seek};
|
use binrw::io::{Read, Seek};
|
||||||
use euclid::{TypedPoint2D, TypedRect, TypedSize2D};
|
use euclid::{TypedPoint2D, TypedRect, TypedSize2D};
|
||||||
|
|
||||||
mod navmesh;
|
mod navmesh;
|
||||||
|
|
@ -23,17 +22,18 @@ pub struct NavQuadTree(QuadTree<NavQuad, HammerUnit, [(ItemId, Rect); 4]>);
|
||||||
///
|
///
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// use sourcenav::get_quad_tree;
|
/// use sourcenav::get_quad_tree;
|
||||||
|
/// use std::io::Cursor;
|
||||||
///
|
///
|
||||||
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
/// let file = std::fs::read("path/to/navfile.nav")?;
|
/// let file = std::fs::read("path/to/navfile.nav")?;
|
||||||
/// let tree = get_quad_tree(file)?;
|
/// let tree = get_quad_tree(&mut Cursor::new(file))?;
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn get_quad_tree<R: Read + Seek>(data: &mut R) -> Result<NavQuadTree, ParseError> {
|
pub fn get_quad_tree<R: Read + Seek>(data: &mut R) -> Result<NavQuadTree, ParseError> {
|
||||||
let areas = read_quads(data)?;
|
let areas = read_areas(data)?;
|
||||||
|
|
||||||
let (min_x, min_y, max_x, max_y) = areas.iter().fold(
|
let (min_x, min_y, max_x, max_y) = areas.iter().map(|area| &area.quad).fold(
|
||||||
(f32::MAX, f32::MAX, f32::MIN, f32::MIN),
|
(f32::MAX, f32::MAX, f32::MIN, f32::MIN),
|
||||||
|(min_x, min_y, max_x, max_y), area| {
|
|(min_x, min_y, max_x, max_y), area| {
|
||||||
(
|
(
|
||||||
|
|
@ -54,7 +54,7 @@ pub fn get_quad_tree<R: Read + Seek>(data: &mut R) -> Result<NavQuadTree, ParseE
|
||||||
);
|
);
|
||||||
|
|
||||||
for area in areas {
|
for area in areas {
|
||||||
tree.insert(area);
|
tree.insert(area.quad);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(NavQuadTree(tree))
|
Ok(NavQuadTree(tree))
|
||||||
|
|
@ -67,10 +67,11 @@ impl NavQuadTree {
|
||||||
///
|
///
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// use sourcenav::get_quad_tree;
|
/// use sourcenav::get_quad_tree;
|
||||||
|
/// use std::io::Cursor;
|
||||||
///
|
///
|
||||||
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
/// let file = std::fs::read("path/to/navfile.nav")?;
|
/// let file = std::fs::read("path/to/navfile.nav")?;
|
||||||
/// let tree = get_quad_tree(file)?;
|
/// let tree = get_quad_tree(&mut Cursor::new(file))?;
|
||||||
/// let areas = tree.query(150.0, -312.0);
|
/// let areas = tree.query(150.0, -312.0);
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
|
|
@ -89,15 +90,16 @@ impl NavQuadTree {
|
||||||
///
|
///
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// use sourcenav::get_quad_tree;
|
/// use sourcenav::get_quad_tree;
|
||||||
|
/// use std::io::Cursor;
|
||||||
///
|
///
|
||||||
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
/// let file = std::fs::read("path/to/navfile.nav")?;
|
/// let file = std::fs::read("path/to/navfile.nav")?;
|
||||||
/// let tree = get_quad_tree(file)?;
|
/// let tree = get_quad_tree(&mut Cursor::new(file))?;
|
||||||
/// let heights = tree.find_z_height(150.0, -312.0);
|
/// let heights = tree.find_z_height(150.0, -312.0);
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn find_z_height<'a>(&'a self, x: f32, y: f32) -> impl Iterator<Item = f32> + 'a {
|
pub fn find_z_height(&self, x: f32, y: f32) -> impl Iterator<Item = f32> + '_ {
|
||||||
self.query(x, y).map(move |area| area.get_z_height(x, y))
|
self.query(x, y).map(move |area| area.get_z_height(x, y))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -123,10 +125,11 @@ impl NavQuadTree {
|
||||||
///
|
///
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// use sourcenav::get_quad_tree;
|
/// use sourcenav::get_quad_tree;
|
||||||
|
/// use std::io::Cursor;
|
||||||
///
|
///
|
||||||
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
/// let file = std::fs::read("path/to/navfile.nav")?;
|
/// let file = std::fs::read("path/to/navfile.nav")?;
|
||||||
/// let tree = get_quad_tree(file)?;
|
/// let tree = get_quad_tree(&mut Cursor::new(file))?;
|
||||||
/// for quad in tree.quads() {
|
/// for quad in tree.quads() {
|
||||||
/// println!("area: {:?}", quad)
|
/// println!("area: {:?}", quad)
|
||||||
/// }
|
/// }
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
use crate::Rect;
|
use crate::Rect;
|
||||||
use aabb_quadtree::Spatial;
|
use aabb_quadtree::Spatial;
|
||||||
use binread::io::{Read, Seek};
|
use binrw::io::{Read, Seek};
|
||||||
use binread::{BinRead, BinReaderExt, BinResult, ReadOptions};
|
use binrw::{BinRead, BinReaderExt, BinResult, Endian};
|
||||||
use euclid::{TypedPoint2D, TypedSize2D};
|
use euclid::{TypedPoint2D, TypedSize2D};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::ops::Index;
|
use std::ops::Index;
|
||||||
|
use std::convert::TryFrom;
|
||||||
|
|
||||||
/// A 3 dimensional coordinate
|
/// A 3 dimensional coordinate
|
||||||
#[derive(Debug, BinRead)]
|
#[derive(Debug, BinRead)]
|
||||||
|
|
@ -21,12 +22,29 @@ impl fmt::Display for NavAreaId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy)]
|
||||||
|
pub struct NavAreaFlags(pub u32);
|
||||||
|
|
||||||
|
impl BinRead for NavAreaFlags {
|
||||||
|
type Args<'a> = (u32,);
|
||||||
|
|
||||||
|
fn read_options<R: Read + Seek>(reader: &mut R, endian: Endian, args: Self::Args<'static>) -> BinResult<Self> {
|
||||||
|
let flags = match args.0 {
|
||||||
|
0..=8 => reader.read_type::<u8>(endian)? as u32,
|
||||||
|
9..=12 => reader.read_type::<u16>(endian)? as u32,
|
||||||
|
13.. => reader.read_type::<u32>(endian)?,
|
||||||
|
};
|
||||||
|
Ok(NavAreaFlags(flags))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// A navigation area from the nav file
|
/// A navigation area from the nav file
|
||||||
#[derive(Debug, BinRead)]
|
#[derive(Debug, BinRead)]
|
||||||
#[br(import(major_version: u32))]
|
#[br(import(major_version: u32))]
|
||||||
pub struct NavArea {
|
pub struct NavArea {
|
||||||
pub id: NavAreaId,
|
pub id: NavAreaId,
|
||||||
pub flags: u32,
|
#[br(args(major_version))]
|
||||||
|
pub flags: NavAreaFlags,
|
||||||
pub quad: NavQuad,
|
pub quad: NavQuad,
|
||||||
pub connections: Connections,
|
pub connections: Connections,
|
||||||
pub hiding_spots_count: u8,
|
pub hiding_spots_count: u8,
|
||||||
|
|
@ -77,12 +95,12 @@ pub(crate) struct HammerUnit;
|
||||||
pub struct Connections([Vec<NavAreaId>; 4]);
|
pub struct Connections([Vec<NavAreaId>; 4]);
|
||||||
|
|
||||||
impl BinRead for Connections {
|
impl BinRead for Connections {
|
||||||
type Args = ();
|
type Args<'a> = ();
|
||||||
|
|
||||||
fn read_options<R: Read + Seek>(
|
fn read_options<R: Read + Seek>(
|
||||||
reader: &mut R,
|
reader: &mut R,
|
||||||
options: &ReadOptions,
|
_endian: Endian,
|
||||||
args: Self::Args,
|
_args: Self::Args<'static>,
|
||||||
) -> BinResult<Self> {
|
) -> BinResult<Self> {
|
||||||
let mut connections = [Vec::new(), Vec::new(), Vec::new(), Vec::new()];
|
let mut connections = [Vec::new(), Vec::new(), Vec::new(), Vec::new()];
|
||||||
|
|
||||||
|
|
@ -128,12 +146,12 @@ impl Index<NavDirection> for Connections {
|
||||||
pub struct LadderConnections([Vec<NavAreaId>; 2]);
|
pub struct LadderConnections([Vec<NavAreaId>; 2]);
|
||||||
|
|
||||||
impl BinRead for LadderConnections {
|
impl BinRead for LadderConnections {
|
||||||
type Args = ();
|
type Args<'a> = ();
|
||||||
|
|
||||||
fn read_options<R: Read + Seek>(
|
fn read_options<R: Read + Seek>(
|
||||||
reader: &mut R,
|
reader: &mut R,
|
||||||
options: &ReadOptions,
|
_endian: Endian,
|
||||||
args: Self::Args,
|
_args: Self::Args<'static>,
|
||||||
) -> BinResult<Self> {
|
) -> BinResult<Self> {
|
||||||
let mut connections = [Vec::new(), Vec::new()];
|
let mut connections = [Vec::new(), Vec::new()];
|
||||||
|
|
||||||
|
|
@ -160,6 +178,7 @@ impl Index<LadderDirection> for LadderConnections {
|
||||||
/// The directions in which two areas can be connected
|
/// The directions in which two areas can be connected
|
||||||
#[derive(Debug, BinRead)]
|
#[derive(Debug, BinRead)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
|
#[br(repr =u8)]
|
||||||
pub enum NavDirection {
|
pub enum NavDirection {
|
||||||
North,
|
North,
|
||||||
East,
|
East,
|
||||||
|
|
@ -170,6 +189,7 @@ pub enum NavDirection {
|
||||||
/// The directions in which two areas can be connected by ladder
|
/// The directions in which two areas can be connected by ladder
|
||||||
#[derive(Debug, BinRead)]
|
#[derive(Debug, BinRead)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
|
#[br(repr =u8)]
|
||||||
pub enum LadderDirection {
|
pub enum LadderDirection {
|
||||||
Up,
|
Up,
|
||||||
Down,
|
Down,
|
||||||
|
|
@ -178,37 +198,37 @@ pub enum LadderDirection {
|
||||||
/// A hiding spot within an area
|
/// A hiding spot within an area
|
||||||
#[derive(Debug, BinRead)]
|
#[derive(Debug, BinRead)]
|
||||||
pub struct NavHidingSpot {
|
pub struct NavHidingSpot {
|
||||||
id: u32,
|
pub id: u32,
|
||||||
location: Vector3,
|
pub location: Vector3,
|
||||||
flags: u8,
|
pub flags: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An area that can be used for approach, no longer used in newer nav files
|
/// An area that can be used for approach, no longer used in newer nav files
|
||||||
#[derive(Debug, BinRead)]
|
#[derive(Debug, BinRead)]
|
||||||
pub struct ApproachArea {
|
pub struct ApproachArea {
|
||||||
approach_here: u32,
|
pub approach_here: u32,
|
||||||
approach_pre: u32,
|
pub approach_pre: u32,
|
||||||
approach_type: u8,
|
pub approach_type: u8,
|
||||||
approach_next: u32,
|
pub approach_next: u32,
|
||||||
approach_how: u8,
|
pub approach_how: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A path that can be used to approach an area
|
/// A path that can be used to approach an area
|
||||||
#[derive(Debug, BinRead)]
|
#[derive(Debug, BinRead)]
|
||||||
pub struct EncounterPath {
|
pub struct EncounterPath {
|
||||||
from_area_id: NavAreaId,
|
pub from_area_id: NavAreaId,
|
||||||
from_direction: u8,
|
pub from_direction: u8,
|
||||||
to_area_id: NavAreaId,
|
pub to_area_id: NavAreaId,
|
||||||
to_direction: u8,
|
pub to_direction: u8,
|
||||||
spot_count: u8,
|
pub spot_count: u8,
|
||||||
#[br(count = spot_count)]
|
#[br(count = spot_count)]
|
||||||
spots: Vec<EncounterSpot>,
|
pub spots: Vec<EncounterSpot>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, BinRead)]
|
#[derive(Debug, BinRead)]
|
||||||
pub struct EncounterSpot {
|
pub struct EncounterSpot {
|
||||||
order: u32,
|
pub order: u32,
|
||||||
distance: u8, // divide by 255
|
pub distance: u8, // divide by 255
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The light intensity at the four corners of an area
|
/// The light intensity at the four corners of an area
|
||||||
|
|
@ -223,14 +243,15 @@ pub struct LightIntensity {
|
||||||
/// An area that is visible
|
/// An area that is visible
|
||||||
#[derive(Debug, BinRead)]
|
#[derive(Debug, BinRead)]
|
||||||
pub struct VisibleArea {
|
pub struct VisibleArea {
|
||||||
id: u32,
|
pub id: u32,
|
||||||
attributes: u8,
|
pub attributes: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
#[allow(dead_code)]
|
||||||
pub struct NavPlace {
|
pub struct NavPlace {
|
||||||
id: u32,
|
pub id: u32,
|
||||||
name: String,
|
pub name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A navigation area from the nav file
|
/// A navigation area from the nav file
|
||||||
|
|
@ -256,10 +277,11 @@ impl NavQuad {
|
||||||
///
|
///
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// use sourcenav::get_quad_tree;
|
/// use sourcenav::get_quad_tree;
|
||||||
|
/// use std::io::Cursor;
|
||||||
///
|
///
|
||||||
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
/// let file = std::fs::read("path/to/navfile.nav")?;
|
/// let file = std::fs::read("path/to/navfile.nav")?;
|
||||||
/// let tree = get_quad_tree(file)?;
|
/// let tree = get_quad_tree(&mut Cursor::new(file))?;
|
||||||
/// let area = tree.query(150.0, -312.0).next().unwrap();
|
/// let area = tree.query(150.0, -312.0).next().unwrap();
|
||||||
///
|
///
|
||||||
/// let height = area.get_z_height(150.0, -312.0);
|
/// let height = area.get_z_height(150.0, -312.0);
|
||||||
|
|
|
||||||
154
src/parser.rs
154
src/parser.rs
|
|
@ -1,28 +1,34 @@
|
||||||
pub use crate::navmesh::NavArea;
|
pub use crate::navmesh::NavArea;
|
||||||
use crate::navmesh::NavQuad;
|
use binrw::io::{Read, Seek};
|
||||||
use crate::{Connections, EncounterPath, LadderConnections, NavHidingSpot, VisibleArea};
|
use binrw::{BinRead, BinReaderExt};
|
||||||
use binread::io::{Read, Seek, SeekFrom};
|
use thiserror::Error;
|
||||||
use binread::{BinRead, BinReaderExt, ReadOptions};
|
use std::convert::TryFrom;
|
||||||
use err_derive::Error;
|
|
||||||
use std::mem::size_of;
|
|
||||||
|
|
||||||
/// Errors that can occur when parsing the binary nav file
|
/// Errors that can occur when parsing the binary nav file
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum ParseError {
|
pub enum ParseError {
|
||||||
/// An error ocured when reading from the source binary data
|
/// An error occurred when reading from the source binary data
|
||||||
#[error(display = "Error while reading from data: {}", _0)]
|
#[error("Error while reading from data: {0}")]
|
||||||
ReadError(#[error(source)] binread::Error),
|
Io(#[from] std::io::Error),
|
||||||
#[error(
|
/// An error occurred when reading from the source binary data
|
||||||
display = "Invalid magic number ({:#8X}), not a nav file or corrupted",
|
#[error("Error while reading from data: {0}")]
|
||||||
_0
|
ReadError(#[from] binrw::Error),
|
||||||
)]
|
|
||||||
/// The binary data contained an invalid magic number and is probably not a nav file
|
/// The binary data contained an invalid magic number and is probably not a nav file
|
||||||
|
#[error("Invalid magic number ({0:#8X}), not a nav file or corrupted")]
|
||||||
InvalidMagicNumber(u32),
|
InvalidMagicNumber(u32),
|
||||||
/// The version of the nav file is not supported by this parser
|
/// The version of the nav file is not supported by this parser
|
||||||
#[error(display = "The major version for this nav ({}), is not supported", _0)]
|
#[error("The major version for this nav ({0}), is not supported")]
|
||||||
UnsupportedVersion(u32),
|
UnsupportedVersion(u32),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(BinRead)]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
struct FixedString {
|
||||||
|
string_len: u16,
|
||||||
|
#[br(count = string_len)]
|
||||||
|
string: Vec<u8>,
|
||||||
|
}
|
||||||
|
|
||||||
/// Parse all navigation areas from a nav file
|
/// Parse all navigation areas from a nav file
|
||||||
///
|
///
|
||||||
/// ## Examples
|
/// ## Examples
|
||||||
|
|
@ -31,12 +37,14 @@ pub enum ParseError {
|
||||||
/// use sourcenav::read_areas;
|
/// use sourcenav::read_areas;
|
||||||
///
|
///
|
||||||
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
/// use std::io::Cursor;
|
||||||
/// let file = std::fs::read("path/to/navfile.nav")?;
|
/// let file = std::fs::read("path/to/navfile.nav")?;
|
||||||
/// let tree = read_areas(file)?;
|
/// let tree = read_areas(&mut Cursor::new(file))?;
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn read_areas<R: Read + Seek>(data: &mut R) -> Result<Vec<NavArea>, ParseError> {
|
pub fn read_areas<R: Read + Seek>(data: &mut R) -> Result<Vec<NavArea>, ParseError> {
|
||||||
|
|
||||||
let magic = data.read_le()?;
|
let magic = data.read_le()?;
|
||||||
if magic != 0xFEED_FACE {
|
if magic != 0xFEED_FACE {
|
||||||
return Err(ParseError::InvalidMagicNumber(magic));
|
return Err(ParseError::InvalidMagicNumber(magic));
|
||||||
|
|
@ -44,7 +52,7 @@ pub fn read_areas<R: Read + Seek>(data: &mut R) -> Result<Vec<NavArea>, ParseErr
|
||||||
|
|
||||||
let major_version: u32 = data.read_le()?;
|
let major_version: u32 = data.read_le()?;
|
||||||
|
|
||||||
if major_version < 6 || major_version > 16 {
|
if !(6..=16).contains(&major_version) {
|
||||||
return Err(ParseError::UnsupportedVersion(major_version));
|
return Err(ParseError::UnsupportedVersion(major_version));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -57,7 +65,7 @@ pub fn read_areas<R: Read + Seek>(data: &mut R) -> Result<Vec<NavArea>, ParseErr
|
||||||
let _size: u32 = data.read_le()?;
|
let _size: u32 = data.read_le()?;
|
||||||
|
|
||||||
let _is_analysed = if major_version >= 14 {
|
let _is_analysed = if major_version >= 14 {
|
||||||
data.read_le::<u8>(8)? == 1
|
data.read_le::<u8>()? == 1
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
};
|
};
|
||||||
|
|
@ -66,13 +74,12 @@ pub fn read_areas<R: Read + Seek>(data: &mut R) -> Result<Vec<NavArea>, ParseErr
|
||||||
|
|
||||||
// let places = Vec::with_capacity(place_count as usize);
|
// let places = Vec::with_capacity(place_count as usize);
|
||||||
for _id in 1..=place_count {
|
for _id in 1..=place_count {
|
||||||
let name_length: u16 = data.read_le()?;
|
let _name: FixedString = data.read_le()?;
|
||||||
let _name = data.read_string(Some(name_length as usize))?;
|
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
let _has_unnamed_areas = if major_version >= 12 {
|
let _has_unnamed_areas = if major_version >= 12 {
|
||||||
data.read_le::<u8>(8)? == 1
|
data.read_le::<u8>()? == 1
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
};
|
};
|
||||||
|
|
@ -82,117 +89,16 @@ pub fn read_areas<R: Read + Seek>(data: &mut R) -> Result<Vec<NavArea>, ParseErr
|
||||||
let mut areas = Vec::with_capacity(area_count as usize);
|
let mut areas = Vec::with_capacity(area_count as usize);
|
||||||
|
|
||||||
for _ in 0..area_count {
|
for _ in 0..area_count {
|
||||||
areas.push(data.read_le()?);
|
areas.push(data.read_le_args((major_version,))?);
|
||||||
}
|
}
|
||||||
|
|
||||||
debug_assert!(data.bits_left() <= 32);
|
|
||||||
|
|
||||||
Ok(areas)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn read_quads<R: Read + Seek>(data: &mut R) -> Result<Vec<NavQuad>, ParseError> {
|
|
||||||
let magic = data.read_le()?;
|
|
||||||
if magic != 0xFEED_FACE {
|
|
||||||
return Err(ParseError::InvalidMagicNumber(magic));
|
|
||||||
}
|
|
||||||
|
|
||||||
let major_version: u32 = data.read_le()?;
|
|
||||||
|
|
||||||
if major_version != 16 {
|
|
||||||
return Err(ParseError::UnsupportedVersion(major_version));
|
|
||||||
}
|
|
||||||
|
|
||||||
let _minor_version: u32 = if major_version >= 10 {
|
|
||||||
data.read_le()?
|
|
||||||
} else {
|
|
||||||
0
|
|
||||||
};
|
|
||||||
|
|
||||||
let _size: u32 = data.read_le()?;
|
|
||||||
|
|
||||||
let _is_analysed = if major_version >= 14 {
|
|
||||||
data.read_le::<u8>(8)? == 1
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
};
|
|
||||||
|
|
||||||
let place_count: u16 = data.read_le()?;
|
|
||||||
|
|
||||||
// let places = Vec::with_capacity(place_count as usize);
|
|
||||||
for _id in 1..=place_count {
|
|
||||||
let name_length: u16 = data.read_le()?;
|
|
||||||
let _name = data.read_string(Some(name_length as usize))?;
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
let _has_unnamed_areas = if major_version >= 12 {
|
|
||||||
data.read_le::<u8>(8)? == 1
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
};
|
|
||||||
|
|
||||||
let area_count: u32 = data.read_le()?;
|
|
||||||
|
|
||||||
let mut areas = Vec::with_capacity(area_count as usize);
|
|
||||||
|
|
||||||
for _ in 0..area_count {
|
|
||||||
data.seek(SeekFrom::Current(4 * 2))?; // id and flags
|
|
||||||
|
|
||||||
let north_west = data.read_le()?;
|
|
||||||
let south_east = data.read_le()?;
|
|
||||||
let north_east_z = data.read_le()?;
|
|
||||||
let south_west_z = data.read_le()?;
|
|
||||||
|
|
||||||
Connections::skip(&mut data)?;
|
|
||||||
|
|
||||||
let hiding_spots_count: u8 = data.read_le()?;
|
|
||||||
data.seek(SeekFrom::Current(
|
|
||||||
size_of::<NavHidingSpot>() as i64 * hiding_spots_count as i64,
|
|
||||||
))?;
|
|
||||||
|
|
||||||
let encounter_paths_count: u32 = data.read_le()?;
|
|
||||||
for _ in 0..encounter_paths_count {
|
|
||||||
EncounterPath::skip(&mut data)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
data.seek(SeekFrom::Current(2))?;
|
|
||||||
|
|
||||||
let _: LadderConnections = data.read_le()?;
|
|
||||||
|
|
||||||
data.seek(SeekFrom::Current((4 * 2) + (4 * 4)))?; // occupy time, light intensity
|
|
||||||
|
|
||||||
let visible_areas_count: u32 = data.read_le()?;
|
|
||||||
data.seek(SeekFrom::Current(
|
|
||||||
size_of::<VisibleArea>() as i64 * visible_areas_count as i64,
|
|
||||||
))?;
|
|
||||||
|
|
||||||
data.seek(SeekFrom::Current(4 * 2))?; // inherit visible, garbage
|
|
||||||
|
|
||||||
areas.push(NavQuad {
|
|
||||||
north_west,
|
|
||||||
south_east,
|
|
||||||
north_east_z,
|
|
||||||
south_west_z,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
debug_assert!(data.bits_left() <= 32);
|
|
||||||
|
|
||||||
Ok(areas)
|
Ok(areas)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test() {
|
fn test() {
|
||||||
|
use std::io::Cursor;
|
||||||
let file = std::fs::read("data/pl_badwater.nav").unwrap();
|
let file = std::fs::read("data/pl_badwater.nav").unwrap();
|
||||||
let data = BitReadStream::new(bitbuffer::BitReadBuffer::new(file, LittleEndian));
|
let areas = read_areas(&mut Cursor::new(file)).unwrap();
|
||||||
let areas = read_areas(data).unwrap();
|
|
||||||
assert_eq!(1930, areas.len());
|
assert_eq!(1930, areas.len());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_quads() {
|
|
||||||
let file = std::fs::read("data/pl_badwater.nav").unwrap();
|
|
||||||
let data = BitReadStream::new(bitbuffer::BitReadBuffer::new(file, LittleEndian));
|
|
||||||
let quads = read_quads(data).unwrap();
|
|
||||||
assert_eq!(1930, quads.len());
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue