Added exceptions for textures objects

This commit is contained in:
_ 2018-05-17 11:35:43 -07:00
parent cef4720e42
commit 53ec9b0474

View File

@ -82,7 +82,8 @@ del libc
class pyTexturePack: class pyTexturePack:
def __init__(self, filedata): def __init__(self, filedata):
self.cstruct = ctypes.pointer(TexturePack()) self.cstruct = ctypes.pointer(TexturePack())
devil1tex.getheader(ctypes.byref(self.cstruct), filedata) if not devil1tex.getheader(ctypes.byref(self.cstruct), filedata):
raise RuntimeError("failed to get texture pack header")
return return
def show(self): def show(self):
@ -99,7 +100,12 @@ class pyTextureBatchDescriptor:
self.cstruct = ctypes.pointer(TextureBatchDescriptor()) self.cstruct = ctypes.pointer(TextureBatchDescriptor())
ptrofptr = ctypes.byref(self.cstruct) ptrofptr = ctypes.byref(self.cstruct)
if filedata: if filedata:
devil1tex.getbatchdesc(ptrofptr, i, filedata, len(filedata)) if not devil1tex.getbatchdesc(
ptrofptr,
i,
filedata,
len(filedata)):
raise RuntimeError("failed to get texturebatchdescriptor #" + str(i))
return return
def show(self): def show(self):
@ -128,7 +134,12 @@ class pyTextureBatch:
self.cstruct.batch = ctypes.cast( self.cstruct.batch = ctypes.cast(
ctypes.create_string_buffer(memsize), ctypes.create_string_buffer(memsize),
ctypes.POINTER(Texture)) ctypes.POINTER(Texture))
devil1tex.gettextures(self.cstruct.batch, i, filedata, len(filedata)) if not devil1tex.gettextures(
self.cstruct.batch,
i,
filedata,
len(filedata)):
raise RuntimeError("failed to get textures of batch #" + str(i))
return return
def gettextures(self): def gettextures(self):