def __del__(self): ''' Calls the destructor and frees the memory. ''' spe.call('RecipientFilterDest', self) spe.dealloc(self)
def getViewCoords(userid, mask=0xFFFFFFFF, collisiongroup=0): player = playerlib.getPlayer(userid) startvec = player.getEyeLocation() # Create start and end vector pointers pStart = createVector(*startvec) pEnd = createVector(*list(Vector(startvec) + Vector(player.viewvector) \ * MAX_COORD_RANGE)) # Allocate space for the CGameTrace object ptr = spe.alloc(SIZE_TRACE_T) # Call UTIL_TraceLine() spe.call('TraceLine', pStart, pEnd, mask, spe.getPlayer(int(userid)), collisiongroup, ptr) # Wrap the end vector... x = spe.makeObject('Vector', ptr + 12) # ... and save the result result = x.x, x.y, x.z # Deallocate reserved space spe.dealloc(pStart) spe.dealloc(pEnd) spe.dealloc(ptr) # Finally, return the result return result
def __del__(self): ''' Frees the memory. ''' spe.dealloc(self)