Further: """ offset = 0 if lumptype in self.lumpheaders: offset = self.lumpheaders[lumptype] """
try this instead: """ offset = self.lumpheaders.get (lumptype, 0) """ dict.get is very handy :D btw, I failed to read the documentation (which is in-code!) for gfx4bpp -- it is actually completely obsolete -- I'm removing it. also: """if get_str16(hero['name'])""" is always True, unless something Cthulonian happened. what you want may be """if len(get_str16(hero['name'])) > 0""" it's also looking like, for read-only analysis, I should support easy use of recarrays so 'item.equippable' et al work. I've just pushed some commits to gitorious which you may like to 'git pull --rebase' -- in particular I've added a good deal of instructions for a range of things*, made setuptools automatically download itself (which should prevent anyone else from needing to do manual setup), and added the gfx submodule (which, yeah, includes an unpacking function or two.. I'm not sure I understand yours properly yet. so it's not yet included. I'll probably combine the functionality of the different unpackers.) * yes, I know the git clone URI is incorrect; it will be fixed next time I push. Oh yeah! and I wrote a function for you -- you may like to include a copy of it until I work out how simplified dtypes will be placed in nohrio in general: (see attachment) It simplifies dtypes to the minimum unambiguous representation.
# Simplified dtypes # ================= # # TeeEmCee has raised the issue of field nesting being unnecessarily # convoluted. # # This is my attempt to address the issue; # In TMC's colouruse.py:RPGDir.lump(), calling simplify_dtype on the dtype # before passing it to mmap is all that is needed. def simplify_dtype (dtype): """Make things easier for TMC. Really, reduces the amount of dereferencing needed to access sufficiently simple dtypes. drawing an analogy to paths, we simplify the following: name/fields -> fields where name is the only top level field name/name/../field -> (dtype of field) where field is the only bottom level field. """ import numpy as np dtype = dtype.descr newdtype = [] if len (dtype) == 1 and type (dtype[0][1]) == list: newdtype.append (simplify_dtype (np.dtype(dtype[0][1]))) else: return dtype while type (newdtype[0]) == list: newdtype = newdtype[0] if len (newdtype) == 1: # single field newdtype = newdtype[0][1:] return newdtype
_______________________________________________ Ohrrpgce mailing list ohrrpgce@lists.motherhamster.org http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org