From 6be805a9339ef506e991363056cd9de1cc06cc81 Mon Sep 17 00:00:00 2001 From: devinacker Date: Wed, 21 Feb 2018 00:03:09 -0500 Subject: [PATCH] handle wildcard tail lumps properly when saving fixes #28 --- omg/mapedit.py | 2 +- omg/util.py | 3 +-- omg/wad.py | 7 +++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/omg/mapedit.py b/omg/mapedit.py index f0ab597..0f3eeca 100644 --- a/omg/mapedit.py +++ b/omg/mapedit.py @@ -197,7 +197,7 @@ def from_lumps(self, lumpgroup): self.behavior = m["BEHAVIOR"] # optional script sources try: - self.scripts = m[m.find("SCRIPT*")[0]] + self.scripts = m[wcinlist(m, "SCRIPT*")[0]] except IndexError: self.scripts = Lump() else: diff --git a/omg/util.py b/omg/util.py index 7d68de9..98c6a70 100644 --- a/omg/util.py +++ b/omg/util.py @@ -4,7 +4,7 @@ """ from __future__ import print_function -from fnmatch import fnmatchcase as wccmp +from fnmatch import fnmatchcase as wccmp, filter as wcinlist from struct import pack, unpack, calcsize from copy import copy, deepcopy from collections import OrderedDict as od @@ -108,7 +108,6 @@ def all(set): def inwclist(elem, seq): return any(wccmp(elem, x) for x in seq) - #---------------------------------------------------------------------- # # Functions for processing lump names and other strings diff --git a/omg/wad.py b/omg/wad.py index 7d5ac68..a1fc9b4 100644 --- a/omg/wad.py +++ b/omg/wad.py @@ -152,8 +152,11 @@ def save_wadio(self, wadio, use_free=True): except KeyError: wadio.insert(h, bytes()) for t in self.tail: - if t in hs: - wadio.insert(t, hs[t].data, use_free=use_free) + try: + name = wcinlist(hs, t)[0] + wadio.insert(name, hs[name].data, use_free=use_free) + except IndexError: + pass class NameGroup(LumpGroup):