From d1b895d07747fc102a056b1f81895bbbeb0236ff Mon Sep 17 00:00:00 2001 From: Diego Roversi Date: Sat, 23 May 2020 09:51:48 +0200 Subject: binboards.py: fix loading of a level in binary format --- bubbob/binboards.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bubbob/binboards.py b/bubbob/binboards.py index 110d8ed..fe19484 100644 --- a/bubbob/binboards.py +++ b/bubbob/binboards.py @@ -1,3 +1,4 @@ +import sys import macbinary import boards import gamesrv @@ -57,7 +58,8 @@ def load(filename): mnstrlist = [Nasty, Monky, Ghosty, Flappy, Springy, Orcy, Gramy, Blitzy] - for key, lvl in list(Bin['LEVL'].items()): + for key, lvl in list(Bin[b'LEVL'].items()): + print(f"load: lvl={lvl} {dir(lvl)}",file=sys.stderr) d = lvl.getlevel(mnstrlist) class BinBoard(boards.Board): pass @@ -65,7 +67,7 @@ def load(filename): setattr(BinBoard, key1, value1) levels[key] = BinBoard - def loader(code, rsrc=Bin['ppat'], cache={}): + def loader(code, rsrc=Bin[b'ppat'], cache={}): try: return cache[code] except KeyError: @@ -104,7 +106,7 @@ def load(filename): keycol1 = KEYCOL if result is not None: w, h, data = macbinary.image2rgb(result) - ppmdata = "P6\n%d %d\n255\n%s" % (w, h, data) + ppmdata = b"P6\n%d %d\n255\n%s" % (w, h, data) result = gamesrv.newbitmap(ppmdata, keycol1), (0, 0, w, h) cache[code] = result return result -- cgit v1.2.3