diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 64b4877..14676f6 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,4 +1,4 @@ -name: Publish binaries +name: Publish builds on: push: @@ -7,7 +7,7 @@ on: jobs: publish: - name: Publish binaries for Windows + name: Publish build for Windows runs-on: windows-latest steps: @@ -21,7 +21,7 @@ jobs: - name: Build run: | cargo build --release --locked - tar.exe -c -a -f mapeditr-windows.zip target/release/mapeditr.exe LICENSE.txt README.md Manual.md + tar.exe -c -a -f mapeditr-windows.zip LICENSE.txt README.md Manual.md -C target/release mapeditr.exe - name: Upload artifacts to release uses: softprops/action-gh-release@v1 diff --git a/.gitignore b/.gitignore index 6ce87ef..5091756 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,21 @@ -/target +# Generated by Cargo +# will have compiled files and executables +debug/ +target/ + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html +# Cargo.lock + +# These are backup files generated by rustfmt **/*.rs.bk -# VSCode stuff -/.vscode -*.code_workspace +# MSVC Windows builds of rustc generate these, which store debugging information +*.pdb + +# VSCode files +.vscode/* +*.code-workspace + +# Local History for Visual Studio Code +.history/ diff --git a/Cargo.lock b/Cargo.lock index 59ffef4..6b89872 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,9 +2,9 @@ # It is not intended for manual editing. [[package]] name = "adler" -version = "0.2.3" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "ansi_term" @@ -17,9 +17,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.37" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee67c11feeac938fae061b232e38e0b6d94f97a9df10e6271319325ac4c56a86" +checksum = "28b2cd92db5cbd74e8e5028f7e27dd7aa3090e89e4f2a197cc7c8dfb69c7063b" [[package]] name = "atty" @@ -46,15 +46,15 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "byteorder" -version = "1.3.4" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "cc" -version = "1.0.66" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c0496836a84f8d0495758516b8621a622beb77c0fed418570e50764093ced48" +checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787" [[package]] name = "cfg-if" @@ -88,9 +88,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7411863d55df97a419aa64cb4d2f167103ea9d767e2c54a1868b7ac3f6b47129" +checksum = "cd3aec53de10fe96d7d8c565eb17f2c687bb5518a2ec453b5b1252964526abe0" dependencies = [ "cfg-if", "crc32fast", @@ -100,22 +100,22 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.1.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8" +checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" dependencies = [ "libc", ] [[package]] name = "libc" -version = "0.2.81" +version = "0.2.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb" +checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e" [[package]] name = "mapeditr" -version = "0.1.0" +version = "1.0.0" dependencies = [ "anyhow", "byteorder", @@ -134,9 +134,9 @@ checksum = "a64a92489e2744ce060c349162be1c5f33c6969234104dbd99ddb5feb08b8c15" [[package]] name = "miniz_oxide" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d" +checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" dependencies = [ "adler", "autocfg", @@ -150,27 +150,27 @@ checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" [[package]] name = "proc-macro2" -version = "1.0.24" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038" dependencies = [ "unicode-xid", ] [[package]] name = "quote" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "991431c3519a3f36861882da93630ce66b52918dcf1b8e2fd66b397fc96f28df" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" dependencies = [ "proc-macro2", ] [[package]] name = "sqlite" -version = "0.25.3" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35f759dc2e373e1edd0a27da87aa9136416360c5077a23643fcd6fcdc9cb9e31" +checksum = "3fb1a534c07ec276fbbe0e55a1c00814d8563da3a2f4d9d9d4c802bd1278db6a" dependencies = [ "libc", "sqlite3-sys", @@ -178,9 +178,9 @@ dependencies = [ [[package]] name = "sqlite3-src" -version = "0.2.12" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8bb25e66d026488228a97e0ad21e3d15ec5998dcd9ad73c97cc277c56a6b314" +checksum = "a260b07ce75a0644c6f5891f34f46db9869e731838e95293469ab17999abcfa3" dependencies = [ "cc", "pkg-config", @@ -188,9 +188,9 @@ dependencies = [ [[package]] name = "sqlite3-sys" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71fec807a1534bd13eeaaec396175d67c79bdc68df55e18a452726ec62a8fb08" +checksum = "04d2f028faeb14352df7934b4771806f60d61ce61be1928ec92396d7492e2e54" dependencies = [ "libc", "sqlite3-src", @@ -204,9 +204,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "syn" -version = "1.0.58" +version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc60a3d73ea6594cd712d830cc1f0390fd71542d8c8cd24e70cc54cdfd5e05d5" +checksum = "a1e8cdbefb79a9a5a65e0db8b47b723ee907b7c7f8496c76a1770b5c310bab82" dependencies = [ "proc-macro2", "quote", @@ -224,18 +224,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.23" +version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76cc616c6abf8c8928e2fdcc0dbfab37175edd8fb49a4641066ad1364fdab146" +checksum = "fa6f76457f59514c7eeb4e59d891395fab0b2fd1d40723ae737d64153392e9c6" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.23" +version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9be73a2caec27583d0046ef3796c3794f868a5bc813db689eed00c7631275cd1" +checksum = "8a36768c0fbf1bb15eca10defa29526bda730a2376c2ab4393ccfa16fb1a318d" dependencies = [ "proc-macro2", "quote", @@ -250,9 +250,9 @@ checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" [[package]] name = "unicode-xid" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" [[package]] name = "vec_map" diff --git a/Cargo.toml b/Cargo.toml index c8e60ac..1e219d2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,14 +1,14 @@ [package] name = "mapeditr" -version = "0.1.0" -authors = ["random-geek <35757396+random-geek@users.noreply.github.com>"] +version = "1.0.0" +authors = ["random-geek (github.com/random-geek)"] edition = "2018" [dependencies] - sqlite = "0.25" - flate2 = "1" - clap = "2" - byteorder = "1" - memmem = "0.1" anyhow = "1" + byteorder = "1" + clap = "2" + flate2 = "1" + memmem = "0.1" + sqlite = "0.26" thiserror = "1" diff --git a/LICENSE.txt b/LICENSE.txt index 0be03c2..edb3479 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,38 @@ -Copyright (c) 2021 random-geek +MapEditr copyright notice and MIT license terms +----------------------------------------------- + +Copyright (c) 2021 random-geek (github.com/random-geek) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +END OF MAPEDITR LICENSE TERMS + +The following dependencies are included in builds of MapEditr and are licensed +under the terms of the MIT license, reproduced below. + +anyhow +byteorder: Copyright (c) 2015 Andrew Gallant +clap: Copyright (c) 2015-2016 Kevin B. Knapp +flate2: Copyright (c) 2014 Alex Crichton +memmem: Copyright (c) 2014 The Rust Project Developers +sqlite: Copyright 2015–2021 The sqlite Developers +thiserror Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 5784e44..de4afb8 100644 --- a/README.md +++ b/README.md @@ -13,23 +13,40 @@ MapEditr was originally based on [MapEdit][2], except written in Rust rather than Python (hence the added "r"). Switching to a compiled language will make MapEditr more robust and easier to maintain in the future. -[1]: https://github.com/Uberi/Minetest-WorldEdit -[2]: https://github.com/random-geek/MapEdit - ## Compilation/Installation -TODO: Pre-built binaries +### Option 1: Pre-built releases -To compile from source, you must have Rust installed first, which can be -downloaded from [the Rust website][3]. Then, in the MapEditr directory, simply -run: +If you are using Windows and don't have Rust installed, you can download a +build of the latest release of MapEditr from the [Releases page][3]. Only +64-bit Windows builds are currently available. + +To run the `mapeditr` command from anywhere, the path to the executable file +must be included in your system's Path variable. [Here is one article][4] +explaining how to edit the Path variable on Windows. + +### Option 2: Install using Cargo + +This method works on any operating system. To use Cargo, you must have Rust +installed first, which can be downloaded from [the Rust website][5]. Then, +simply run: + +`cargo install --git https://github.com/random-geek/MapEditr.git` + +This will download MapEditr and install it to `$HOME/.cargo/bin`. After +installing, you should be able to run MapEditr from anywhere with the +`mapeditr` command. + +### Option 3: Build normally + +If you don't wish to install MapEditr, you can build it normally using Cargo. +In the MapEditr directory, run: `cargo build --release` The `--release` flag is important, as it produces an optimized executable which -runs much faster than the default, unoptimized version. - -[3]: https://www.rust-lang.org +runs much faster than the default, unoptimized version. The compiled executable +will be in the `target/release` directory. ## Usage @@ -53,15 +70,20 @@ project's readme or documentation. ## Acknowledgments -The [Minetest][4] project has been rather important for the making of +The [Minetest][6] project has been rather important for the making of MapEdit/MapEditr, for obvious reasons. Some parts of the original MapEdit code were adapted from AndrejIT's -[map_unexplore][5] project. All due credit goes to the author(s) of that +[map_unexplore][7] project. All due credit goes to the author(s) of that project. Thank you also to ExeterDad and the moderators of the late Hometown server, for partially inspiring MapEdit/MapEditr. -[4]: https://github.com/minetest/minetest -[5]: https://github.com/AndrejIT/map_unexplore +[1]: https://github.com/Uberi/Minetest-WorldEdit +[2]: https://github.com/random-geek/MapEdit +[3]: https://github.com/random-geek/MapEditr/releases +[4]: https://www.howtogeek.com/118594/how-to-edit-your-system-path-for-easy-command-line-access/ +[5]: https://www.rust-lang.org +[6]: https://github.com/minetest/minetest +[7]: https://github.com/AndrejIT/map_unexplore diff --git a/src/instance.rs b/src/instance.rs index 9d3599f..6a9e8e5 100644 --- a/src/instance.rs +++ b/src/instance.rs @@ -267,12 +267,10 @@ fn verify_args(args: &InstArgs) -> anyhow::Result<()> { let mod_name = &name[..delim]; let item_name = &name[delim + 1..]; - mod_name.find(|c: char| - !(c.is_ascii_lowercase() || c.is_ascii_digit() || c == '_')) - .is_none() - && item_name.find(|c: char| - !(c.is_ascii_alphanumeric() || c == '_')) - .is_none() + mod_name.chars().all(|c: char| + c.is_ascii_lowercase() || c.is_ascii_digit() || c == '_') + && item_name.chars().all(|c: char| + c.is_ascii_alphanumeric() || c == '_') } } diff --git a/src/map_block/map_block.rs b/src/map_block/map_block.rs index 662173f..f169d4a 100644 --- a/src/map_block/map_block.rs +++ b/src/map_block/map_block.rs @@ -136,7 +136,6 @@ impl MapBlock { mod tests { use super::*; use crate::spatial::Vec3; - // use crate::testing::debug_bytes; // TODO use std::path::Path; fn read_test_file(filename: &str) -> anyhow::Result> {