Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import sys
- from omg import WAD, MapEditor, thinginfo # omgifol
- def thingToTuple(thing):
- pos = thing.x, thing.y
- try:
- if thing.type not in thinginfo.monsters:
- return None # Not interested in non-monster things
- name = thinginfo.all_num2desc[thing.type]
- except KeyError:
- # Seems omg doesn't recognize some things, esp. decorations
- # name = f"thing {thing.type}"
- return None
- tup = [name, pos]
- flags = []
- if thing.easy: flags.append('E')
- if thing.medium: flags.append('M')
- if thing.hard: flags.append('H')
- # if thing.deaf: flags.append('D')
- if thing.multiplayer: flags.append('U')
- tup.append(''.join(flags))
- angle = thing.angle
- # tup.append(angle)
- return tuple(tup)
- # Get list of all things in a specific map in g_type2def
- def mapGetThings(wad_name, map_id):
- print(f"Reading {wad_name}:{map_id}")
- wad = WAD(wad_name)
- edit = MapEditor(wad.maps[map_id])
- result = set()
- count = 0
- for thing in edit.things:
- thing = thingToTuple(thing)
- if thing is None: continue
- if thing in result:
- # We don't handle duplicate tihngs properly, so I'll at
- # least report them.
- print(f"Duplicate: {thing}")
- result.add(thing)
- count += 1
- if count != len(result):
- print("Count mismatch") # Duplicates?
- print(f"Found {count} things in {wad_name}:{map_id}")
- print()
- return result
- def main():
- if len(sys.argv) != 5:
- print("Usage: compare.py DOOM2.WAD MAP31 mymap.wad MAP01")
- exit(-1)
- wad_src, map_src = sys.argv[1:3]
- wad_new, map_new = sys.argv[3:5]
- things_src = mapGetThings(wad_src, map_src)
- things_new = mapGetThings(wad_new, map_new)
- extra, missing = [], []
- for thing in things_new:
- if thing not in things_src:
- extra.append(thing)
- for thing in things_src:
- if thing not in things_new:
- missing.append(thing)
- if len(extra) + len(missing) == 0:
- print("No mismatches found")
- else:
- print("Mismatches found")
- if len(extra) != 0:
- print(f"Extra things (in {wad_new}:{map_new} but " +
- f"missing from {wad_src}:{map_src}):")
- for thing in extra:
- print(f"- {thing}")
- if len(missing) != 0:
- print(f"Missing things (in {wad_src}:{map_src} but " +
- f"missing from {wad_new}:{map_new}):")
- for thing in missing:
- print(f"- {thing}")
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement