From 16d6f8e322311eff51b23425218b2d6c383170d6 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Thu, 15 Sep 2022 08:31:43 +0100 Subject: The order of elements on a set is undefined This could lead to change in order, for example, when changing version of Python. This change ensures the colours are always in the same order. --- tools/png2sprites.py | 2 +- tools/png2tiles.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/png2sprites.py b/tools/png2sprites.py index 7528fae..95e6492 100755 --- a/tools/png2sprites.py +++ b/tools/png2sprites.py @@ -109,7 +109,7 @@ def main(): tile = [ data[x + i + ((y + j) * w)] for j in range(DEF_H) for i in range(DEF_W) ] - cols = set([c for c in tile if c != TRANS]) + cols = sorted(set([c for c in tile if c != TRANS])) if not cols: continue diff --git a/tools/png2tiles.py b/tools/png2tiles.py index 43eb1e0..55e7c53 100755 --- a/tools/png2tiles.py +++ b/tools/png2tiles.py @@ -97,7 +97,7 @@ def read_image(image_name, out, color): # get the attibutes of the tile # FIXME: this may not be right for i in range(0, len(tile), DEF_W): - cols = list(set(tile[i : i + DEF_W])) + cols = list(sorted(set(tile[i : i + DEF_W]))) if len(cols) > 2: raise Exception( -- cgit v1.2.3