diff --git a/polymer/eduke32/source/lunatic/map2text.lua b/polymer/eduke32/source/lunatic/map2text.lua new file mode 100755 index 000000000..a8e654d22 --- /dev/null +++ b/polymer/eduke32/source/lunatic/map2text.lua @@ -0,0 +1,83 @@ +#!/usr/bin/env luajit + +local B = require("build") +local string = require("string") + +local fn = arg[1] + +if (fn==nil) then + print("Usage: map2text ") + return 1 +end + +local function printf(fmt, ...) + print(string.format(fmt, ...)) +end + +local map, errmsg = B.loadboard(fn) +if (map == nil) then + printf("Couldn't load \"%s\": %s", fn, errmsg) + return 1 +end + + +printf("numsectors = %d", map.numsectors) +printf("numwalls = %d", map.numwalls) +printf("numsprites = %d", map.numsprites) + +printf("startpos = { %d, %d, %d }", map.start.x, map.start.y, map.start.z) +printf("startang = %d", map.start.ang) +printf("startsectnum = %d", map.start.sectnum) + +local sector_members = { + "wallptr", "wallnum", + "ceilingz", "floorz", + "ceilingstat", "floorstat", + "ceilingpicnum", "ceilingheinum", + "ceilingshade", + "ceilingpal", "ceilingxpanning", "ceilingypanning", + "floorpicnum", "floorheinum", + "floorshade", + "floorpal", "floorxpanning", "floorypanning", + "visibility", "filler", + "lotag", "hitag", "extra", +} + +local wall_members = { + "x", "y", + "point2", "nextwall", "nextsector", + "cstat", + "picnum", "overpicnum", + "shade", + "pal", "xrepeat", "yrepeat", "xpanning", "ypanning", + "lotag", "hitag", "extra", +} + +local sprite_members = { + "x", "y", "z", + "cstat", "picnum", + "shade", + "pal", "clipdist", "filler", + "xrepeat", "yrepeat", + "xoffset", "yoffset", + "sectnum", "statnum", + "ang", "owner", "xvel", "yvel", "zvel", + "lotag", "hitag", "extra", +} + +local function print_members(map, struct, members) + printf("%s = {", struct) + for i=0,map["num"..struct.."s"]-1 do + printf("[%d]={", i) + for j=1,#members do + local member = members[j] + printf("%s = %d", member, map[struct][i][member]) + end + print("}") + end + print("}") +end + +print_members(map, "sector", sector_members) +print_members(map, "wall", wall_members) +print_members(map, "sprite", sprite_members) diff --git a/polymer/eduke32/source/lunatic/mapdiff.sh b/polymer/eduke32/source/lunatic/mapdiff.sh new file mode 100755 index 000000000..0d1df26cf --- /dev/null +++ b/polymer/eduke32/source/lunatic/mapdiff.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +DIFF="git diff --no-index --color-words" +CMD="/usr/bin/env luajit ./map2text.lua" + +if [ `uname -s` != "Linux" ]; then + # I think 'tempfile' isn't in POSIX. Feel free to use 'mktemp' or something + # but absolutely test it before. + echo "This helper script is for Linux only." + return 1 +fi + +if [ -z "$1" -o -z "$2" ]; then + echo "Usage: ./mapdiff.sh " + exit 1 +fi + +tf1=`tempfile` +tf2=`tempfile` + +$CMD "$1" > "$tf1" +$CMD "$2" > "$tf2" + +$DIFF "$tf1" "$tf2" + +rm "$tf1" +rm "$tf2"