mirror of
https://github.com/edg-l/ddnet-map-diff.git
synced 2024-11-09 17:48:21 +00:00
cleanup
This commit is contained in:
parent
4c67891254
commit
eb25c460a1
|
@ -7,6 +7,6 @@
|
||||||
[![Docs](https://docs.rs/ddnet-map-diff/badge.svg)](https://docs.rs/ddnet-map-diff)
|
[![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/)
|
[![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.
|
||||||
|
|
53
a.py
53
a.py
|
@ -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')
|
|
Loading…
Reference in a new issue