check tile flags

This commit is contained in:
Edgar 2023-09-15 15:06:35 +02:00
parent 762d0bee16
commit eb31e9b66d
No known key found for this signature in database
GPG key ID: 70ADAE8F35904387
3 changed files with 12 additions and 4 deletions

2
Cargo.lock generated
View file

@ -259,7 +259,7 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
[[package]] [[package]]
name = "ddnet-map-diff" name = "ddnet-map-diff"
version = "0.1.0" version = "0.1.1"
dependencies = [ dependencies = [
"clap", "clap",
"color-eyre", "color-eyre",

View file

@ -2,7 +2,7 @@
name = "ddnet-map-diff" name = "ddnet-map-diff"
authors = ["Edgar <git@edgarluque.com>"] authors = ["Edgar <git@edgarluque.com>"]
description = "A DDraceNetwork map diff tool." description = "A DDraceNetwork map diff tool."
version = "0.1.0" version = "0.1.1"
edition = "2021" edition = "2021"
license = "AGPL-3.0-only" license = "AGPL-3.0-only"
repository = "https://github.com/edg-l/ddnet-map-diff" repository = "https://github.com/edg-l/ddnet-map-diff"

View file

@ -136,8 +136,10 @@ where
for x in 0..width { for x in 0..width {
for y in 0..height { for y in 0..height {
let index_old = tiles_old[(y, x)].id(); let old_tile = &tiles_old[(y, x)];
let index_new = tiles_new[(y, x)].id(); let new_tile = &tiles_new[(y, x)];
let index_old = old_tile.id();
let index_new = new_tile.id();
if index_old == 0 && index_new != 0 { if index_old == 0 && index_new != 0 {
tiles_add[(y, x)].id = 1; tiles_add[(y, x)].id = 1;
@ -148,6 +150,12 @@ where
} else if index_old != index_new { } else if index_old != index_new {
tiles_mod[(y, x)].id = 1; tiles_mod[(y, x)].id = 1;
modifications += 1; modifications += 1;
} else {
// check if a tile state changed, like rotation
if old_tile.flags() != new_tile.flags() {
tiles_mod[(y, x)].id = 1;
modifications += 1;
}
} }
} }
} }