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:
def __init__(self, filedata):
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
def show(self):
@ -99,7 +100,12 @@ class pyTextureBatchDescriptor:
self.cstruct = ctypes.pointer(TextureBatchDescriptor())
ptrofptr = ctypes.byref(self.cstruct)
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
def show(self):
@ -128,7 +134,12 @@ class pyTextureBatch:
self.cstruct.batch = ctypes.cast(
ctypes.create_string_buffer(memsize),
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
def gettextures(self):