From eb25c460a1fc88d1f00e6e858598ea7e387da141 Mon Sep 17 00:00:00 2001 From: Edgar Luque Date: Thu, 14 Sep 2023 12:16:07 +0200 Subject: [PATCH] cleanup --- README.md | 4 ++-- a.py | 53 ----------------------------------------------------- 2 files changed, 2 insertions(+), 55 deletions(-) delete mode 100644 a.py diff --git a/README.md b/README.md index c761b41..cf0957b 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,6 @@ [![Docs](https://docs.rs/ddnet-map-diff/badge.svg)](https://docs.rs/ddnet-map-diff) [![crev reviews](https://web.crev.dev/rust-reviews/badge/crev_count/ddnet-map-diff.svg)](https://web.crev.dev/rust-reviews/crate/ddnet-map-diff/) -A map diff made in Rust using [twmap](https://docs.rs/twmap). +A DDNet map diff tool made in Rust using [twmap](https://docs.rs/twmap). -Inspired by Ravie's python script. +Inspired by the original Ravie's python script. diff --git a/a.py b/a.py deleted file mode 100644 index 85a97fe..0000000 --- a/a.py +++ /dev/null @@ -1,53 +0,0 @@ -# MIT License -# Copyright Ravie 2023 - -import twmap -import sys - -map_old = twmap.Map(sys.argv[1]) -map_new = twmap.Map(sys.argv[2]) - -tiles_old = map_old.game_layer().tiles -tiles_new = map_new.game_layer().tiles - -shape_old = tiles_old.shape -shape_new = tiles_new.shape - -w = min(shape_old[1], shape_new[1]) -h = min(shape_old[0], shape_new[0]) - -diff_group = map_new.groups.py_new() -diff_group.name = 'Difference' - -layer_add = diff_group.layers.new_tiles(w, h) -layer_add.color = (0, 255, 0, 64) -layer_add.name = 'Added' -tiles_add = layer_add.tiles - -layer_del = diff_group.layers.new_tiles(w, h) -layer_del.color = (255, 0, 0, 64) -layer_del.name = 'Deleted' -tiles_del = layer_del.tiles - -layer_mod = diff_group.layers.new_tiles(w, h) -layer_mod.color = (255, 255, 0, 64) -layer_mod.name = 'Modified' -tiles_mod = layer_mod.tiles - -for x in range(w): - for y in range(h): - index_old = tiles_old[y, x, 0] - index_new = tiles_new[y, x, 0] - - if index_old == 0 and index_new != 0: - tiles_add[y, x, 0] = True - elif index_old != 0 and index_new == 0: - tiles_del[y, x, 0] = True - elif index_old != index_new: - tiles_mod[y, x, 0] = True - -layer_add.tiles = tiles_add -layer_del.tiles = tiles_del -layer_mod.tiles = tiles_mod - -map_new.save('difference.map')