Read the world database; hand out guids from the top of the range
The core gives `.npc add` and temporary creatures guids above MAX(creature.guid), so allocating upward put the server's own spawns in the guids a project takes next. Counting down from the top makes the range's last guid that maximum after the first export. With EDITOR_WORLD_DB set, `check` and `export` compare the server's rows in the range with the project and refuse on a conflict, and the editor takes the brush's display and name from creature_template. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Generated
+435
-1
@@ -249,6 +249,15 @@ version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2ad8689a486416c401ea15715a4694de30054248ec627edbf31f49cb64ee4086"
|
||||
|
||||
[[package]]
|
||||
name = "arc-swap"
|
||||
version = "1.9.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c049c0be4daef0b145cb3555416b3b8ef5b7888a38aea1a3a155801fe7b0810b"
|
||||
dependencies = [
|
||||
"rustversion",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "arrayref"
|
||||
version = "0.3.9"
|
||||
@@ -442,6 +451,12 @@ version = "0.22.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.23.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5"
|
||||
|
||||
[[package]]
|
||||
name = "benilla-adt"
|
||||
version = "0.2.0"
|
||||
@@ -1020,7 +1035,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5f37fb52655d0439656ca0a1db027d46926e463c81d893d4b1639668e5d7f1c1"
|
||||
dependencies = [
|
||||
"async-lock",
|
||||
"base64",
|
||||
"base64 0.22.1",
|
||||
"bevy_animation",
|
||||
"bevy_app",
|
||||
"bevy_asset",
|
||||
@@ -1979,6 +1994,21 @@ dependencies = [
|
||||
"piper",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "btoi"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b5ab9db53bcda568284df0fd39f6eac24ad6f7ba7ff1168b9e76eba6576b976"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bufstream"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "40e38929add23cdf8a366df9b0e088953150724bcbe5fc330b0d8eb3b328eec8"
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.20.3"
|
||||
@@ -2590,6 +2620,17 @@ dependencies = [
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive_utils"
|
||||
version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc05a5d33db20c784f873e84934ad94bb209a090987ac5f62fede2c178234f23"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 3.0.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.10.7"
|
||||
@@ -2618,6 +2659,17 @@ dependencies = [
|
||||
"objc2 0.6.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "displaydoc"
|
||||
version = "0.2.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 3.0.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "disqualified"
|
||||
version = "1.1.0"
|
||||
@@ -2672,6 +2724,7 @@ dependencies = [
|
||||
"bevy",
|
||||
"clap",
|
||||
"editor-project",
|
||||
"editor-vmangos",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2699,6 +2752,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"editor-project",
|
||||
"mysql",
|
||||
"sha2",
|
||||
]
|
||||
|
||||
@@ -2928,6 +2982,15 @@ version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b"
|
||||
|
||||
[[package]]
|
||||
name = "form_urlencoded"
|
||||
version = "1.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf"
|
||||
dependencies = [
|
||||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-channel"
|
||||
version = "0.3.34"
|
||||
@@ -3367,6 +3430,110 @@ version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df"
|
||||
|
||||
[[package]]
|
||||
name = "icu_collections"
|
||||
version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa68d21081c4a05d5a901a1c62add574c77048b6a1c67be3b50ce0b60d4ca513"
|
||||
dependencies = [
|
||||
"displaydoc",
|
||||
"potential_utf",
|
||||
"utf8_iter",
|
||||
"yoke",
|
||||
"zerofrom",
|
||||
"zerovec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "icu_locale_core"
|
||||
version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d56e28588da92eee5c3201a6eff33fabdd49b62269c8938d4ff050ce4d900deb"
|
||||
dependencies = [
|
||||
"displaydoc",
|
||||
"litemap",
|
||||
"tinystr",
|
||||
"writeable",
|
||||
"zerovec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "icu_normalizer"
|
||||
version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "12f9cf5f235641ed274641dd81c3f28d870e276763d0797aeeab72317b1c646f"
|
||||
dependencies = [
|
||||
"icu_collections",
|
||||
"icu_normalizer_data",
|
||||
"icu_properties",
|
||||
"icu_provider",
|
||||
"smallvec",
|
||||
"zerovec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "icu_normalizer_data"
|
||||
version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1563da1ed3e0b3bf3d74c9b85917ac9c56464d2f57242270c09c9e752f8021a0"
|
||||
|
||||
[[package]]
|
||||
name = "icu_properties"
|
||||
version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7e7ca276ad3145661a65914e6daf131ca5120cd3dcee8f8f3214b8875184a148"
|
||||
dependencies = [
|
||||
"displaydoc",
|
||||
"icu_collections",
|
||||
"icu_locale_core",
|
||||
"icu_properties_data",
|
||||
"icu_provider",
|
||||
"zerotrie",
|
||||
"zerovec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "icu_properties_data"
|
||||
version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e590f038c1464a96894fd6d10127e90a8be4509f56ff7ecef851b15cee0b7caa"
|
||||
|
||||
[[package]]
|
||||
name = "icu_provider"
|
||||
version = "2.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d27bbb9d3abbefac45d55f647c9de1d44aafcd1186eb91879afef17c396c3e73"
|
||||
dependencies = [
|
||||
"displaydoc",
|
||||
"icu_locale_core",
|
||||
"writeable",
|
||||
"yoke",
|
||||
"zerofrom",
|
||||
"zerotrie",
|
||||
"zerovec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "idna"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de"
|
||||
dependencies = [
|
||||
"idna_adapter",
|
||||
"smallvec",
|
||||
"utf8_iter",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "idna_adapter"
|
||||
version = "1.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714"
|
||||
dependencies = [
|
||||
"icu_normalizer",
|
||||
"icu_properties",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "image"
|
||||
version = "0.25.10"
|
||||
@@ -3427,6 +3594,15 @@ dependencies = [
|
||||
"rustversion",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "io-enum"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f859dc81e05e585e93cfc84dffa4fd068d0651ca229c51bca6101c056b63b93a"
|
||||
dependencies = [
|
||||
"derive_utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "is-terminal"
|
||||
version = "0.4.17"
|
||||
@@ -3666,6 +3842,12 @@ version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53"
|
||||
|
||||
[[package]]
|
||||
name = "litemap"
|
||||
version = "0.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae"
|
||||
|
||||
[[package]]
|
||||
name = "litrs"
|
||||
version = "1.0.1"
|
||||
@@ -3687,6 +3869,12 @@ version = "0.4.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6"
|
||||
|
||||
[[package]]
|
||||
name = "lru"
|
||||
version = "0.18.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ef9ac18847474e638e3702b76c65d4eb93428471a74778ef0f1be711717f89b5"
|
||||
|
||||
[[package]]
|
||||
name = "mach2"
|
||||
version = "0.4.3"
|
||||
@@ -3780,6 +3968,56 @@ dependencies = [
|
||||
"pxfm",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mysql"
|
||||
version = "28.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca3de8a73b7c70f76dbcdd4b6abc9b53bbb6c4f7bd6c79d8e8a7ea2157c02487"
|
||||
dependencies = [
|
||||
"arc-swap",
|
||||
"bufstream",
|
||||
"bytes",
|
||||
"crossbeam-queue",
|
||||
"crossbeam-utils",
|
||||
"flate2",
|
||||
"io-enum",
|
||||
"libc",
|
||||
"lru",
|
||||
"mysql_common",
|
||||
"named_pipe",
|
||||
"pem",
|
||||
"percent-encoding",
|
||||
"socket2",
|
||||
"twox-hash",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mysql_common"
|
||||
version = "0.37.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0f27695f286b461da077b8c2f72f47feaa04ce3c3f9c0976257410e90e21208a"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"bitflags 2.13.2",
|
||||
"btoi",
|
||||
"byteorder",
|
||||
"bytes",
|
||||
"crc32fast",
|
||||
"flate2",
|
||||
"getrandom 0.3.4",
|
||||
"num-bigint",
|
||||
"num-traits",
|
||||
"regex",
|
||||
"saturating",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha1",
|
||||
"sha2",
|
||||
"thiserror 2.0.21",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "naga"
|
||||
version = "27.0.3"
|
||||
@@ -3824,6 +4062,15 @@ dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "named_pipe"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ad9c443cce91fc3e12f017290db75dde490d685cdaaf508d7159d7cf41f0eb2b"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nanorand"
|
||||
version = "0.6.1"
|
||||
@@ -3929,6 +4176,16 @@ dependencies = [
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-bigint"
|
||||
version = "0.4.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c89e69e7e0f03bea5ef08013795c25018e101932225a656383bd384495ecc367"
|
||||
dependencies = [
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-complex"
|
||||
version = "0.4.6"
|
||||
@@ -3949,6 +4206,15 @@ dependencies = [
|
||||
"syn 2.0.119",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-integer"
|
||||
version = "0.1.47"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ce2d95d4b3734dc35aa2f45e1aa22cd416814592a4f9d9205e11affd5b8e10b"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.19"
|
||||
@@ -4413,6 +4679,16 @@ version = "1.0.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
|
||||
|
||||
[[package]]
|
||||
name = "pem"
|
||||
version = "4.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d354a98a3d1251555de99e8fdd8afda05573c31b82f59063a7b0a29b5527f120"
|
||||
dependencies = [
|
||||
"base64 0.23.1",
|
||||
"serde_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "percent-encoding"
|
||||
version = "2.3.2"
|
||||
@@ -4551,6 +4827,15 @@ dependencies = [
|
||||
"portable-atomic",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "potential_utf"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661"
|
||||
dependencies = [
|
||||
"zerovec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pp-rs"
|
||||
version = "0.2.1"
|
||||
@@ -4970,6 +5255,12 @@ dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "saturating"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ece8e78b2f38ec51c51f5d475df0a7187ba5111b2a28bdc761ee05b075d40a71"
|
||||
|
||||
[[package]]
|
||||
name = "scoped-tls"
|
||||
version = "1.0.1"
|
||||
@@ -5056,6 +5347,17 @@ dependencies = [
|
||||
"zmij",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha1"
|
||||
version = "0.10.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a978451301f4db1d02937a4ab3ccce137717b81826e79b7d49ffe3244a13c3b8"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cpufeatures 0.2.17",
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha2"
|
||||
version = "0.10.9"
|
||||
@@ -5198,6 +5500,16 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "socket2"
|
||||
version = "0.6.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spade"
|
||||
version = "2.15.1"
|
||||
@@ -5300,6 +5612,17 @@ dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "synstructure"
|
||||
version = "0.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 3.0.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sys-locale"
|
||||
version = "0.3.2"
|
||||
@@ -5447,6 +5770,16 @@ dependencies = [
|
||||
"strict-num",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinystr"
|
||||
version = "0.8.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b1e27c91459209c2986af3dcf603a5a74a4368754ce37414f59acc971167f643"
|
||||
dependencies = [
|
||||
"displaydoc",
|
||||
"zerovec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinytemplate"
|
||||
version = "1.2.1"
|
||||
@@ -5682,6 +6015,24 @@ version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"
|
||||
|
||||
[[package]]
|
||||
name = "url"
|
||||
version = "2.5.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed"
|
||||
dependencies = [
|
||||
"form_urlencoded",
|
||||
"idna",
|
||||
"percent-encoding",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "utf8_iter"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
|
||||
|
||||
[[package]]
|
||||
name = "utf8parse"
|
||||
version = "0.2.2"
|
||||
@@ -6657,6 +7008,12 @@ version = "0.57.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e"
|
||||
|
||||
[[package]]
|
||||
name = "writeable"
|
||||
version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc"
|
||||
|
||||
[[package]]
|
||||
name = "x11-dl"
|
||||
version = "2.21.0"
|
||||
@@ -6726,6 +7083,29 @@ version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e01738255b5a16e78bbb83e7fbba0a1e7dd506905cfc53f4622d89015a03fbb5"
|
||||
|
||||
[[package]]
|
||||
name = "yoke"
|
||||
version = "0.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "709fe23a0424b6a435d82152b1bd3fdfb0833487d5fa90d05d42762a9891fef5"
|
||||
dependencies = [
|
||||
"stable_deref_trait",
|
||||
"yoke-derive",
|
||||
"zerofrom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "yoke-derive"
|
||||
version = "0.8.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 3.0.9",
|
||||
"synstructure",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zeno"
|
||||
version = "0.3.3"
|
||||
@@ -6752,6 +7132,60 @@ dependencies = [
|
||||
"syn 2.0.119",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerofrom"
|
||||
version = "0.1.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272"
|
||||
dependencies = [
|
||||
"zerofrom-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerofrom-derive"
|
||||
version = "0.1.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f75b4683f6c7f45248d4d64056a24298c6281e0993356d7d1b4a1a962ef10d4a"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 3.0.9",
|
||||
"synstructure",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerotrie"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f"
|
||||
dependencies = [
|
||||
"displaydoc",
|
||||
"yoke",
|
||||
"zerofrom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerovec"
|
||||
version = "0.11.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bb0464e17806c1d976d5cba29399c7f08e516e279e2ba493f63123b5fca67dd8"
|
||||
dependencies = [
|
||||
"yoke",
|
||||
"zerofrom",
|
||||
"zerovec-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerovec-derive"
|
||||
version = "0.11.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34df6fc39dbd26ddc9c10e6a2984476e13acce22e64e4487636ef494369225da"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 3.0.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zlib-rs"
|
||||
version = "0.6.8"
|
||||
|
||||
@@ -19,6 +19,8 @@ serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
clap = { version = "4.6.1", features = ["derive"] }
|
||||
sha2 = "0.10"
|
||||
# Pure-Rust compression: no zlib to build on Windows. No TLS: the world database is local.
|
||||
mysql = { version = "28.0.4", default-features = false, features = ["minimal-rust"] }
|
||||
# benilla's feature set, plus `default_font` for the editor's status text.
|
||||
bevy = { version = "0.18.1", default-features = false, features = [
|
||||
"default_app",
|
||||
|
||||
@@ -9,7 +9,7 @@ migrations. Nothing from the install is ever committed or written to.
|
||||
| Crate | What |
|
||||
| --- | --- |
|
||||
| `editor-project` | The project model: targets, reserved id ranges, spawns, the last-export baseline. No Bevy. |
|
||||
| `editor-vmangos` | Pending changes to one vMaNGOS world migration, in the core's own template. No Bevy. |
|
||||
| `editor-vmangos` | Pending changes to one vMaNGOS world migration, in the core's own template; the world database read back (`world_db`). No Bevy. |
|
||||
| `editor-cli` | `benilla-editor-cli new / check / export`, for CI and the release pipeline. |
|
||||
| `editor-app` | `benilla-editor`, the window: benilla's `WorldPlugins`, a free camera, placement, preview. |
|
||||
|
||||
@@ -24,14 +24,29 @@ own (`BENILLA_PIN_ANY=1` builds anyway, to try one).
|
||||
cargo run -p editor-cli -- new camp.json --vmangos-rev <core commit> \
|
||||
--guid-first 9000000 --guid-last 9000999
|
||||
|
||||
# Place spawns: entry is creature_template.entry, display a CreatureDisplayInfo id to preview.
|
||||
WOW_DATA=<path to WoW/Data> cargo run -p editor-app -- camp.json --entry 197 --display 1430
|
||||
# Optional, read only: the world database the export targets. An environment variable, so the
|
||||
# password stays out of shell history.
|
||||
export EDITOR_WORLD_DB=mysql://vmangos:<password>@127.0.0.1:13306/mangos
|
||||
|
||||
# Place spawns: entry is creature_template.entry. With EDITOR_WORLD_DB the preview display and the
|
||||
# name come from the template; without it, pass --display <CreatureDisplayInfo id>.
|
||||
WOW_DATA=<path to WoW/Data> cargo run -p editor-app -- camp.json --entry 69
|
||||
|
||||
# What would be exported, then write the migration into the server repository.
|
||||
cargo run -p editor-cli -- check camp.json
|
||||
cargo run -p editor-cli -- export camp.json --out ../core/sql/migrations
|
||||
cargo run -p editor-cli -- export camp.json --out <core>/sql/content/migrations
|
||||
```
|
||||
|
||||
Guids are handed out from the top of the range down and never reused. The core gives `.npc add`
|
||||
and temporary creatures guids above `MAX(creature.guid)`; once the range's last guid is that
|
||||
maximum, the server's own allocations land above the range instead of where the project places
|
||||
next.
|
||||
|
||||
With `EDITOR_WORLD_DB` set, `check` and `export` compare the server with the project first, and
|
||||
`export` refuses on a conflict: a row in the range the project never held, a guid it adds that is
|
||||
taken, a template missing at the spawn's `patch_min`, or (once every export is applied) a row that
|
||||
no longer matches the last export. The migration's own guards check the same at apply time.
|
||||
|
||||
An export writes only what changed since the last one, records the migration and its SHA-256 in
|
||||
the project, and refuses to overwrite a migration file. Re-exporting an unchanged project writes
|
||||
nothing.
|
||||
@@ -51,8 +66,8 @@ The run that closes R0: a spawn appears on the server at the spot and facing the
|
||||
1. `new`, then in the editor place one spawn with a plain creature display (not a humanoid NPC)
|
||||
on terrain, one on a WMO floor (a bridge or an upper storey), turn each to a distinct facing,
|
||||
`Ctrl+S`.
|
||||
2. `export` into a test server's `sql/migrations`, apply it, restart or `.reload` as the core
|
||||
needs.
|
||||
2. `export` into the core's `sql/content/migrations`, apply it (`deploy/local/apply-content.sh`),
|
||||
restart `mangosd`.
|
||||
3. In the client: `.go xyz` with the line the editor's status shows for each spawn. The creature
|
||||
stands at the editor's position and faces the editor's arrow. Record `.gps` next to the
|
||||
editor's numbers.
|
||||
@@ -62,5 +77,5 @@ The run that closes R0: a spawn appears on the server at the spot and facing the
|
||||
## Not yet
|
||||
|
||||
Humanoid NPC preview (`CreatureDisplayInfoExtra`: the character geoset and equipment pipeline is
|
||||
private to `benilla-app`), reading the world database (entry and display come from the command
|
||||
line for now), animation, and everything after R1.
|
||||
private to `benilla-app`), the server's existing spawns shown in the world, a project content
|
||||
patch (the brush previews the patch-10 template), animation, and everything after R1.
|
||||
|
||||
@@ -21,3 +21,4 @@ benilla-world.workspace = true
|
||||
bevy.workspace = true
|
||||
clap.workspace = true
|
||||
editor-project = { path = "../editor-project" }
|
||||
editor-vmangos = { path = "../editor-vmangos" }
|
||||
|
||||
@@ -16,6 +16,8 @@ use crate::preview::{Dressed, Preview, Previews};
|
||||
pub struct Brush {
|
||||
pub entry: u32,
|
||||
pub display: Option<u32>,
|
||||
/// The template's name, when read from the world database.
|
||||
pub name: Option<String>,
|
||||
}
|
||||
|
||||
/// The open project and the edit session over it.
|
||||
@@ -401,9 +403,15 @@ fn update_status(
|
||||
),
|
||||
None => "-".into(),
|
||||
};
|
||||
let name = ed
|
||||
.brush
|
||||
.name
|
||||
.as_ref()
|
||||
.map(|n| format!(" \"{n}\""))
|
||||
.unwrap_or_default();
|
||||
let brush = match ed.brush.display {
|
||||
Some(d) => format!("entry {} display {d}", ed.brush.entry),
|
||||
None => format!("entry {} (no preview display)", ed.brush.entry),
|
||||
Some(d) => format!("entry {}{name} display {d}", ed.brush.entry),
|
||||
None => format!("entry {}{name} (no preview display)", ed.brush.entry),
|
||||
};
|
||||
**text = format!(
|
||||
"map {} cursor {cursor}\nbrush {brush}{}\nselected {selected}\n\
|
||||
|
||||
@@ -25,7 +25,8 @@ struct Args {
|
||||
/// `creature_template.entry` new spawns get.
|
||||
#[arg(long, default_value_t = 0)]
|
||||
entry: u32,
|
||||
/// `CreatureDisplayInfo` id new spawns preview with.
|
||||
/// `CreatureDisplayInfo` id new spawns preview with; with `EDITOR_WORLD_DB` set, defaults to
|
||||
/// the template's first display.
|
||||
#[arg(long)]
|
||||
display: Option<u32>,
|
||||
/// Map id; defaults to the first spawn's, else 0 (Eastern Kingdoms).
|
||||
@@ -48,6 +49,7 @@ fn main() -> anyhow::Result<()> {
|
||||
env!("BENILLA_REV")
|
||||
);
|
||||
}
|
||||
let brush = brush(args.entry, args.display)?;
|
||||
let map = args
|
||||
.map
|
||||
.or_else(|| project.creatures.values().next().map(|c| c.map))
|
||||
@@ -95,14 +97,7 @@ fn main() -> anyhow::Result<()> {
|
||||
.add_plugins(benilla_world::world_plugins::WorldPlugins)
|
||||
// What the engine needs told: there is a world. The streamer follows the camera on its own.
|
||||
.insert_resource(benilla_world::schedule::WorldLive(true))
|
||||
.insert_resource(edit::Editor::new(
|
||||
project,
|
||||
args.project,
|
||||
edit::Brush {
|
||||
entry: args.entry,
|
||||
display: args.display,
|
||||
},
|
||||
))
|
||||
.insert_resource(edit::Editor::new(project, args.project, brush))
|
||||
.insert_resource(camera::Start { map, at: start })
|
||||
.add_plugins((camera::plugin, preview::plugin, edit::plugin));
|
||||
|
||||
@@ -120,6 +115,37 @@ fn main() -> anyhow::Result<()> {
|
||||
}
|
||||
}
|
||||
|
||||
/// The brush for `--entry`: its name and default display from the world database when
|
||||
/// `EDITOR_WORLD_DB` is set. An entry the database does not have is refused, as the server would
|
||||
/// not load the spawn.
|
||||
fn brush(entry: u32, display: Option<u32>) -> anyhow::Result<edit::Brush> {
|
||||
let mut brush = edit::Brush {
|
||||
entry,
|
||||
display,
|
||||
name: None,
|
||||
};
|
||||
if entry == 0 {
|
||||
return Ok(brush);
|
||||
}
|
||||
let Some(mut db) = editor_vmangos::world_db::WorldDb::from_env()? else {
|
||||
return Ok(brush);
|
||||
};
|
||||
// New spawns load from patch 0 to 10; the template a patch-10 server shows.
|
||||
let template = db
|
||||
.creature_template(entry, 10)?
|
||||
.with_context(|| format!("creature_template {entry} is not in the world database"))?;
|
||||
brush.display = brush.display.or(template.displays.first().copied());
|
||||
brush.name = Some(template.display_name().to_string());
|
||||
eprintln!(
|
||||
"brush: entry {entry} \"{}\" (template patch {}), displays {:?}, previewing {:?}",
|
||||
template.display_name(),
|
||||
template.patch,
|
||||
template.displays,
|
||||
brush.display
|
||||
);
|
||||
Ok(brush)
|
||||
}
|
||||
|
||||
/// Logs the run's state, writes the frame, and exits two seconds later: the write is
|
||||
/// asynchronous, and an immediate exit loses the PNG.
|
||||
fn shoot_and_exit(
|
||||
|
||||
@@ -6,6 +6,7 @@ use std::path::{Path, PathBuf};
|
||||
use anyhow::{bail, Context, Result};
|
||||
use clap::{Parser, Subcommand};
|
||||
use editor_project::{ExportRecord, IdRange, Project, Target};
|
||||
use editor_vmangos::world_db::{self, WorldDb};
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(
|
||||
@@ -31,10 +32,12 @@ enum Command {
|
||||
#[arg(long)]
|
||||
guid_last: u32,
|
||||
},
|
||||
/// Validate a project and list what the next export would write.
|
||||
/// Validate a project and list what the next export would write. With `EDITOR_WORLD_DB`
|
||||
/// set, also check the server's rows in the project's range and the spawns' templates.
|
||||
Check { project: PathBuf },
|
||||
/// Write the pending changes as one vMaNGOS world migration into `--out` (the server
|
||||
/// repository's `sql/migrations`), then record it in the project as the new baseline.
|
||||
/// repository's `sql/content/migrations`), then record it in the project as the new
|
||||
/// baseline. With `EDITOR_WORLD_DB` set, refuses while the server conflicts with the project.
|
||||
Export {
|
||||
project: PathBuf,
|
||||
#[arg(long)]
|
||||
@@ -83,6 +86,9 @@ fn main() -> Result<()> {
|
||||
c.changed.len(),
|
||||
c.removed.len()
|
||||
);
|
||||
if server_check(&p)? == Some(true) {
|
||||
bail!("the server does not match the project");
|
||||
}
|
||||
}
|
||||
Command::Export { project, out, id } => export(&project, &out, id)?,
|
||||
}
|
||||
@@ -92,6 +98,9 @@ fn main() -> Result<()> {
|
||||
fn export(path: &Path, out: &Path, id: Option<String>) -> Result<()> {
|
||||
let mut p = Project::load(path)?;
|
||||
pin_warning(&p);
|
||||
if server_check(&p)? == Some(true) {
|
||||
bail!("not exporting: the server does not match the project");
|
||||
}
|
||||
let id = id.unwrap_or_else(utc_migration_id);
|
||||
let Some(m) = editor_vmangos::creature_migration(&p, &id)? else {
|
||||
println!("nothing to export: the project matches its last export");
|
||||
@@ -118,6 +127,55 @@ fn export(path: &Path, out: &Path, id: Option<String>) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// With `EDITOR_WORLD_DB` set, prints how the server compares with the project and returns whether
|
||||
/// that blocks an export; `None` without a database.
|
||||
fn server_check(p: &Project) -> Result<Option<bool>> {
|
||||
let Some(mut db) = WorldDb::from_env()? else {
|
||||
return Ok(None);
|
||||
};
|
||||
let range = p.ranges.creature_guid;
|
||||
let rows = db.creature_rows(range)?;
|
||||
let applied = db.applied_migrations()?;
|
||||
let audit = world_db::audit(p, &rows, &applied);
|
||||
let max = db.max_creature_guid()?;
|
||||
|
||||
let mut missing_templates = Vec::new();
|
||||
let pending = p.pending();
|
||||
for guid in pending.added.iter().chain(&pending.changed) {
|
||||
let c = &p.creatures[guid];
|
||||
if db.creature_template(c.entry, c.patch_min)?.is_none() {
|
||||
missing_templates.push(format!(
|
||||
"guid {guid}: entry {} has no creature_template at patch {} or below",
|
||||
c.entry, c.patch_min
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
println!(
|
||||
"server: {} row(s) in {}..={}, MAX(creature.guid) {max}{}",
|
||||
rows.len(),
|
||||
range.first,
|
||||
range.last,
|
||||
if (range.first..range.last).contains(&max) {
|
||||
" (inside the range: the server's own spawns would take the project's next guids)"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
);
|
||||
for id in &audit.unapplied {
|
||||
println!(" not applied yet: {id}_world.sql");
|
||||
}
|
||||
for line in audit
|
||||
.conflicts
|
||||
.iter()
|
||||
.chain(&audit.drift)
|
||||
.chain(&missing_templates)
|
||||
{
|
||||
println!(" problem: {line}");
|
||||
}
|
||||
Ok(Some(audit.blocks_export() || !missing_templates.is_empty()))
|
||||
}
|
||||
|
||||
/// The project was made against another benilla commit; coordinates and display ids still hold,
|
||||
/// but a preview may differ.
|
||||
fn pin_warning(p: &Project) {
|
||||
|
||||
@@ -180,28 +180,33 @@ impl Project {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The next free guid: above every guid this project has ever held, so a deleted spawn's guid
|
||||
/// The next free guid: below every guid this project has ever held, so a deleted spawn's guid
|
||||
/// is never handed to a new one (the server may still hold rows that reference it).
|
||||
///
|
||||
/// Counting down from the top of the range: the core hands `.npc add` and temporary creatures
|
||||
/// guids above `MAX(creature.guid)` (`ObjectMgr::SetHighestGuids`). The first export makes the
|
||||
/// range's last guid that maximum, so the server's own allocations land above the range rather
|
||||
/// than in the guids this project would take next.
|
||||
pub fn next_creature_guid(&self) -> Result<u32> {
|
||||
let range = self.ranges.creature_guid;
|
||||
let high = self
|
||||
let low = self
|
||||
.creatures
|
||||
.keys()
|
||||
.chain(self.exported.keys())
|
||||
.max()
|
||||
.min()
|
||||
.copied();
|
||||
let next = match high {
|
||||
Some(g) => g.checked_add(1).context("guid overflow")?,
|
||||
None => range.first,
|
||||
let next = match low {
|
||||
Some(g) => g.checked_sub(1),
|
||||
None => Some(range.last),
|
||||
};
|
||||
if !range.contains(next) {
|
||||
if !next.is_some_and(|g| range.contains(g)) {
|
||||
bail!(
|
||||
"creature guid range {}..={} is exhausted",
|
||||
range.first,
|
||||
range.last
|
||||
);
|
||||
}
|
||||
Ok(next)
|
||||
Ok(next.unwrap_or_default())
|
||||
}
|
||||
|
||||
/// Adds a spawn under a fresh guid and returns it.
|
||||
@@ -297,7 +302,7 @@ mod tests {
|
||||
p.exported = p.creatures.clone();
|
||||
p.creatures.remove(&a);
|
||||
let b = p.add_creature(spawn(2)).unwrap();
|
||||
assert_eq!((a, b), (9_000_000, 9_000_001));
|
||||
assert_eq!((a, b), (9_000_002, 9_000_001));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -314,7 +319,8 @@ mod tests {
|
||||
let mut p = project();
|
||||
let a = p.add_creature(spawn(1)).unwrap();
|
||||
let b = p.add_creature(spawn(2)).unwrap();
|
||||
assert_eq!(p.pending().added, vec![a, b]);
|
||||
// In guid order: guids count down, so the later spawn comes first.
|
||||
assert_eq!(p.pending().added, vec![b, a]);
|
||||
p.exported = p.creatures.clone();
|
||||
assert!(p.pending().is_empty());
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "editor-vmangos"
|
||||
description = "The vMaNGOS adapter: turns a project's pending changes into a world-database migration"
|
||||
description = "The vMaNGOS adapter: a project's pending changes as a world-database migration, and the world database read back"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
@@ -11,4 +11,5 @@ workspace = true
|
||||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
editor-project = { path = "../editor-project" }
|
||||
mysql.workspace = true
|
||||
sha2.workspace = true
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
//! every guard runs ahead of the `migrations` row and the first write, and a failed guard
|
||||
//! `SIGNAL`s out with the database untouched.
|
||||
|
||||
pub mod world_db;
|
||||
|
||||
use std::fmt::Write as _;
|
||||
|
||||
use anyhow::{ensure, Result};
|
||||
@@ -288,7 +290,7 @@ mod tests {
|
||||
`position_x`, `position_y`, `position_z`, `orientation`, `spawntimesecsmin`, \
|
||||
`spawntimesecsmax`, `wander_distance`, `health_percent`, `mana_percent`, \
|
||||
`movement_type`, `spawn_flags`, `visibility_mod`, `patch_min`, `patch_max`) VALUES \
|
||||
(9000000, 197, 0, 0, 0, 0, 0, -8949.95, -132.49, 83.5, 1.5, 300, 300, 0.0, 100, 100, \
|
||||
(9000999, 197, 0, 0, 0, 0, 0, -8949.95, -132.49, 83.5, 1.5, 300, 300, 0.0, 100, 100, \
|
||||
0, 0, 0, 0, 10);"
|
||||
));
|
||||
// Guards come before the migrations row, which comes before the first write.
|
||||
|
||||
@@ -0,0 +1,329 @@
|
||||
//! Reading a vMaNGOS world database: templates for the brush, and the rows in a project's range to
|
||||
//! check the server against the project before an export.
|
||||
//!
|
||||
//! Read only: the editor writes the server through migrations, never through this connection.
|
||||
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use editor_project::{IdRange, Project};
|
||||
use mysql::prelude::Queryable;
|
||||
|
||||
/// The environment variable holding the connection URL,
|
||||
/// `mysql://user:password@host:port/database`. An environment variable and not a flag, so the
|
||||
/// password stays out of shell history and process lists.
|
||||
pub const URL_VAR: &str = "EDITOR_WORLD_DB";
|
||||
|
||||
/// The `creature_template` row the server loads for an entry at a content patch.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct CreatureTemplate {
|
||||
pub entry: u32,
|
||||
/// The row's `patch`: the highest at or below the patch asked for.
|
||||
pub patch: u8,
|
||||
pub name: String,
|
||||
/// `locales_creature.name_loc8` (ruRU), when the database has one.
|
||||
pub name_ru: Option<String>,
|
||||
/// The non-zero `display_id1..4`.
|
||||
pub displays: Vec<u32>,
|
||||
}
|
||||
|
||||
impl CreatureTemplate {
|
||||
/// The name to show: the Russian one when present.
|
||||
pub fn display_name(&self) -> &str {
|
||||
self.name_ru.as_deref().unwrap_or(&self.name)
|
||||
}
|
||||
}
|
||||
|
||||
/// One `creature` row by the columns that identify it.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub struct CreatureRow {
|
||||
pub guid: u32,
|
||||
pub entry: u32,
|
||||
pub map: u32,
|
||||
}
|
||||
|
||||
/// A read-only connection to the world database.
|
||||
pub struct WorldDb {
|
||||
conn: mysql::Conn,
|
||||
}
|
||||
|
||||
impl WorldDb {
|
||||
/// Connects to `url`. Errors never echo the URL, which carries the password.
|
||||
pub fn connect(url: &str) -> Result<Self> {
|
||||
let opts = mysql::Opts::from_url(url).map_err(|_| {
|
||||
anyhow::anyhow!("{URL_VAR} is not a mysql://user:pass@host:port/db URL")
|
||||
})?;
|
||||
let conn = mysql::Conn::new(opts).context("connecting to the world database")?;
|
||||
Ok(Self { conn })
|
||||
}
|
||||
|
||||
/// Connects to [`URL_VAR`] if it is set.
|
||||
pub fn from_env() -> Result<Option<Self>> {
|
||||
match std::env::var(URL_VAR) {
|
||||
Ok(url) if !url.is_empty() => Self::connect(&url).map(Some),
|
||||
_ => Ok(None),
|
||||
}
|
||||
}
|
||||
|
||||
/// The template the server loads for `entry` at content patch `patch`: the row with the highest
|
||||
/// `patch` at or below it, as `ObjectMgr::LoadCreatureTemplates` keeps.
|
||||
pub fn creature_template(&mut self, entry: u32, patch: u8) -> Result<Option<CreatureTemplate>> {
|
||||
type Row = (u32, u8, String, u32, u32, u32, u32, Option<String>);
|
||||
let row: Option<Row> = self
|
||||
.conn
|
||||
.exec_first(
|
||||
"SELECT t.`entry`, t.`patch`, t.`name`, t.`display_id1`, t.`display_id2`, \
|
||||
t.`display_id3`, t.`display_id4`, l.`name_loc8` \
|
||||
FROM `creature_template` t \
|
||||
LEFT JOIN `locales_creature` l ON l.`entry` = t.`entry` \
|
||||
WHERE t.`entry` = ? AND t.`patch` <= ? ORDER BY t.`patch` DESC LIMIT 1",
|
||||
(entry, patch),
|
||||
)
|
||||
.with_context(|| format!("reading creature_template {entry}"))?;
|
||||
Ok(row.map(
|
||||
|(entry, patch, name, d1, d2, d3, d4, name_ru)| CreatureTemplate {
|
||||
entry,
|
||||
patch,
|
||||
name,
|
||||
name_ru: name_ru.filter(|n| !n.is_empty()),
|
||||
displays: [d1, d2, d3, d4].into_iter().filter(|d| *d != 0).collect(),
|
||||
},
|
||||
))
|
||||
}
|
||||
|
||||
/// Every `creature` row whose guid is in `range`.
|
||||
pub fn creature_rows(&mut self, range: IdRange) -> Result<Vec<CreatureRow>> {
|
||||
let rows: Vec<(u32, u32, u32)> = self
|
||||
.conn
|
||||
.exec(
|
||||
"SELECT `guid`, `id`, `map` FROM `creature` WHERE `guid` BETWEEN ? AND ? \
|
||||
ORDER BY `guid`",
|
||||
(range.first, range.last),
|
||||
)
|
||||
.context("reading creature rows in the project's range")?;
|
||||
Ok(rows
|
||||
.into_iter()
|
||||
.map(|(guid, entry, map)| CreatureRow { guid, entry, map })
|
||||
.collect())
|
||||
}
|
||||
|
||||
/// `MAX(creature.guid)`: the core's static and temporary creature guids start above it.
|
||||
pub fn max_creature_guid(&mut self) -> Result<u32> {
|
||||
let max: Option<Option<u32>> = self
|
||||
.conn
|
||||
.query_first("SELECT MAX(`guid`) FROM `creature`")
|
||||
.context("reading MAX(creature.guid)")?;
|
||||
Ok(max.flatten().unwrap_or(0))
|
||||
}
|
||||
|
||||
/// The ids in the `migrations` table.
|
||||
pub fn applied_migrations(&mut self) -> Result<BTreeSet<String>> {
|
||||
let ids: Vec<String> = self
|
||||
.conn
|
||||
.query("SELECT `id` FROM `migrations`")
|
||||
.context("reading the migrations table")?;
|
||||
Ok(ids.into_iter().collect())
|
||||
}
|
||||
}
|
||||
|
||||
/// How the server's rows in a project's range compare with the project.
|
||||
#[derive(Debug, Default, PartialEq)]
|
||||
pub struct Audit {
|
||||
/// Rows the next export or the next placements would collide with. An export is refused.
|
||||
pub conflicts: Vec<String>,
|
||||
/// The project's exports the server has not applied, oldest first.
|
||||
pub unapplied: Vec<String>,
|
||||
/// With every export applied, rows that no longer match the last export: something else
|
||||
/// changed the server. An export is refused; its guards would fail on the server anyway.
|
||||
pub drift: Vec<String>,
|
||||
}
|
||||
|
||||
impl Audit {
|
||||
pub fn blocks_export(&self) -> bool {
|
||||
!self.conflicts.is_empty() || !self.drift.is_empty()
|
||||
}
|
||||
}
|
||||
|
||||
/// Compares the server's `rows` in the project's range, and its applied migration ids, with the
|
||||
/// project. Pure, so it tests without a database.
|
||||
///
|
||||
/// Guids are handed out downward and never reused ([`Project::next_creature_guid`]), so every guid
|
||||
/// from the lowest one the project holds up to the top of its range has been the project's. A row
|
||||
/// below that is someone else's, sitting where the next placement goes.
|
||||
pub fn audit(project: &Project, rows: &[CreatureRow], applied: &BTreeSet<String>) -> Audit {
|
||||
let mut out = Audit {
|
||||
unapplied: project
|
||||
.exports
|
||||
.iter()
|
||||
.filter(|e| !applied.contains(&e.migration))
|
||||
.map(|e| e.migration.clone())
|
||||
.collect(),
|
||||
..Audit::default()
|
||||
};
|
||||
let lowest_held = project
|
||||
.creatures
|
||||
.keys()
|
||||
.chain(project.exported.keys())
|
||||
.min()
|
||||
.copied();
|
||||
let pending = project.pending();
|
||||
let all_applied = out.unapplied.is_empty();
|
||||
|
||||
for row in rows {
|
||||
let held = lowest_held.is_some_and(|low| row.guid >= low);
|
||||
if !held {
|
||||
out.conflicts.push(format!(
|
||||
"guid {} (entry {}, map {}) is in the project's range but not the project's: \
|
||||
new placements would take it",
|
||||
row.guid, row.entry, row.map
|
||||
));
|
||||
} else if pending.added.contains(&row.guid) {
|
||||
out.conflicts.push(format!(
|
||||
"guid {} is already on the server (entry {}, map {}); the project adds it",
|
||||
row.guid, row.entry, row.map
|
||||
));
|
||||
} else if all_applied {
|
||||
match project.exported.get(&row.guid) {
|
||||
Some(c) if c.entry == row.entry && c.map == row.map => {}
|
||||
Some(c) => out.drift.push(format!(
|
||||
"guid {} is entry {} map {} on the server, entry {} map {} in the last export",
|
||||
row.guid, row.entry, row.map, c.entry, c.map
|
||||
)),
|
||||
None => out.drift.push(format!(
|
||||
"guid {} (entry {}) is still on the server; the project removed it",
|
||||
row.guid, row.entry
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
if all_applied {
|
||||
for guid in project.exported.keys() {
|
||||
if !rows.iter().any(|r| r.guid == *guid) {
|
||||
out.drift.push(format!(
|
||||
"guid {guid} is missing on the server; the last export has it"
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use editor_project::{CreatureSpawn, ExportRecord, Target};
|
||||
|
||||
fn project() -> Project {
|
||||
Project::new(
|
||||
Target {
|
||||
client_version: "1.12.1".into(),
|
||||
client_build: 5875,
|
||||
benilla_rev: "b".into(),
|
||||
vmangos_rev: "v".into(),
|
||||
},
|
||||
IdRange {
|
||||
first: 100,
|
||||
last: 199,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
fn spawn(entry: u32) -> CreatureSpawn {
|
||||
CreatureSpawn {
|
||||
entry,
|
||||
map: 0,
|
||||
position: [0.0; 3],
|
||||
orientation: 0.0,
|
||||
spawn_secs_min: 300,
|
||||
spawn_secs_max: 300,
|
||||
wander_distance: 0.0,
|
||||
movement_type: 0,
|
||||
patch_min: 0,
|
||||
patch_max: 10,
|
||||
preview_display: None,
|
||||
}
|
||||
}
|
||||
|
||||
fn row(guid: u32, entry: u32) -> CreatureRow {
|
||||
CreatureRow {
|
||||
guid,
|
||||
entry,
|
||||
map: 0,
|
||||
}
|
||||
}
|
||||
|
||||
/// A project with spawns 199 and 198 exported as `1`, then 198 removed and 197 added.
|
||||
fn exported_project() -> Project {
|
||||
let mut p = project();
|
||||
p.add_creature(spawn(1)).unwrap();
|
||||
p.add_creature(spawn(2)).unwrap();
|
||||
p.exported = p.creatures.clone();
|
||||
p.exports.push(ExportRecord {
|
||||
migration: "1".into(),
|
||||
sha256: String::new(),
|
||||
});
|
||||
p.creatures.remove(&198);
|
||||
p.add_creature(spawn(3)).unwrap();
|
||||
p
|
||||
}
|
||||
|
||||
fn applied(ids: &[&str]) -> BTreeSet<String> {
|
||||
ids.iter().map(|s| s.to_string()).collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn matching_server_is_clean() {
|
||||
let p = exported_project();
|
||||
let a = audit(&p, &[row(198, 2), row(199, 1)], &applied(&["1"]));
|
||||
assert_eq!(a, Audit::default());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_foreign_row_below_the_project_conflicts() {
|
||||
let p = exported_project();
|
||||
let a = audit(
|
||||
&p,
|
||||
&[row(150, 7), row(198, 2), row(199, 1)],
|
||||
&applied(&["1"]),
|
||||
);
|
||||
assert_eq!(a.conflicts.len(), 1);
|
||||
assert!(a.conflicts[0].contains("guid 150"));
|
||||
assert!(a.blocks_export());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_taken_added_guid_conflicts() {
|
||||
let p = exported_project();
|
||||
let a = audit(
|
||||
&p,
|
||||
&[row(197, 7), row(198, 2), row(199, 1)],
|
||||
&applied(&["1"]),
|
||||
);
|
||||
assert_eq!(a.conflicts.len(), 1);
|
||||
assert!(a.conflicts[0].contains("guid 197"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn drift_from_the_last_export_is_reported() {
|
||||
let p = exported_project();
|
||||
// 199 changed entry, 198 gone.
|
||||
let a = audit(&p, &[row(199, 9)], &applied(&["1"]));
|
||||
assert!(a.conflicts.is_empty());
|
||||
assert_eq!(a.drift.len(), 2, "{:?}", a.drift);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_unapplied_export_skips_drift() {
|
||||
let p = exported_project();
|
||||
let a = audit(&p, &[], &applied(&[]));
|
||||
assert_eq!(a.unapplied, vec!["1".to_string()]);
|
||||
assert!(a.drift.is_empty());
|
||||
assert!(!a.blocks_export());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_empty_project_owns_nothing_yet() {
|
||||
let a = audit(&project(), &[row(199, 1)], &applied(&[]));
|
||||
assert_eq!(a.conflicts.len(), 1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user