PermMem
PermMem is a powerful package that allows classes (or instances) to be used permanently even after loading or restarting by saving them to the ASCII .ZEN
archive in the savegame directory. PermMem manages handles that are used to access instances, and provides various functions to manipulate these handles and instances.
Dependencies
Initialization
Initialize with LeGo_PermMem
flag.
Implementation
Functions
new
Creates a handle to a new instance of inst
.
var int inst
A valid instance. Used as "constructor"
Return value
The function returns a new, valid PermMem handle.
create
Similar to new
, but here a pointer is returned directly and not a handle. Caution! Not managed by PermMem!
var int inst
A valid instance. Used as "constructor"
Return value
The function returns a pointer to the new instance.
wrap
"Wraps" a handle "around" a pointer so that the pointer can be used with any function that expects handles. Only conditionally managed by PermMem.
var int inst
A valid instance. Determines the type of the handlevar int ptr
Pointer to wrap
Return value
The function returns a handle with ptr
as content.
clear
Cleans the handle. After that it is invalid.
var int hndl
Valid PermMem handle
release
Frees the handle. The reserved memory is not deleted, the handle becomes invalid.
var int hndl
Valid PermMem handle
delete
Cleans the handle just like clear
, only the destructor is also called.
var int hndl
Valid PermMem handle
free
Similar to delete
, only here a pointer is destroyed and not a handle. Caution! Not managed by PermMem!
var int ptr
The pointer to be cleanedvar int inst
Instance used increate
function.
get
Returns the instance of the handle.
var int hndl
Valid PermMem handle
getPtr
Returns a pointer to instance of handle.
var int hndl
Valid PermMem handle
setPtr
Sets the pointer of a handle.
var int hndl
Valid PermMem handlevar int ptr
New pointer for handle
getInst
Returns the instance used to create the given handle in new
function.
var int hndl
Valid PermMem handle
numHandles
Returns the number of handles managed by PermMem.
sizeof
Gets the size of the given instance's class.
var int inst
Any instance
Return value
The function returns the size of a given instance's class in bytes.
Hlp_IsValidHandle
Indicates whether the handle exists and is managed by PermMem.
var int hndl
PermMem's handle
Return value
The function returns TRUE
if the handle is valid (managed by PermMem), FALSE
is returned otherwise.
Example
The example function that use Hlp_IsValidHandle
is Bar_SetMax
form LeGo Bars package. The function first checks if the handle is valid, then gets the instance and changes its parameters.
foreachHndl
Executes a function for each handle of an instance.
var int inst
The function is called for this instancevar int inst
This function is called. The signature isfunction(int handle)
hasHndl
Checks if PermMem has a handle of this instance.
var int inst
Instance to be checked
Return value
The function returns TRUE
if the PermMem has a handle of this instance, FALSE
is returned otherwise.
MEM_ReadStringArray
Function moved to PermMem form Ikarus. Reads string from the array at the arrayAddress
.
var int arrayAddress
Memory address of arrayvar int offset
Array offset (array index)
Return value
The function returns string from the array if the address is correct.
PM_Exists
Checks if the specified field already exists in the archive. (used with archiver/unarchiver)
var string name
Name of the field
Return value
The function returns TRUE
if the field exists in the archive, FALSE
is returned otherwise.
Archiver
PM_SaveInt
Saves an integer to the archive.
var string name
Name of the field in saved archivevar int val
Value of the saved integer
PM_SaveFloat
Saves a daedalus float to the archive.
var string name
Name of the field in saved archivevar int flt
Value of the saved float
PM_SaveString
Saves a string to the archive.
var string name
Name of the field in saved archivevar string val
Saved string
PM_SaveFuncID
Saves a function ID to the archive.
var string name
Name of the field in saved archivevar int fnc
Saved function ID
PM_SaveFuncOffset
Saves a function offset to the archive.
var string name
Name of the field in saved archivevar int fnc
Saved function offset
PM_SaveFuncPtr
Saves a function pointer to the archive.
var string name
Name of the field in saved archivevar int fnc
Saved function pointer
PM_SaveClassPtr
Saves a pointer of a class to the archive.
var string name
Name of the field in saved archivevar int ptr
Saved pointervar string className
Name of the class of stored pointer
PM_SaveClass
Saves a class like PM_SaveClassPtr
.
var string name
Name of the field in saved archivevar int ptr
Saved class pointervar string className
Name of the class of stored pointer
PM_SaveIntArray
Saves an array of integers.
var string name
Name of the field in saved archivevar int ptr
Pointer to the arrayvar int elements
Number of elements in array
PM_SaveStringArray
Saves an array of integers.
var string name
Name of the field in saved archivevar int ptr
Pointer to the arrayvar int elements
Number of elements in array
Unarchiver
PM_Load
Universal function to load integers, floats, class pointers and int arrays.
var string name
Name of the loaded field
Return value The function returns the data existing in the archive at the given field.
PM_LoadInt
Returns an integer stored in the archive.
var string name
Name of the loaded field
PM_LoadFloat
Returns a daedalus float stored in the archive.
var string name
Name of the loaded field
PM_LoadString
Returns a string stored in the archive.
var string name
Name of the loaded field
PM_LoadFuncID
Returns a function ID stored in the archive.
var string name
Name of the loaded field
PM_LoadFuncOffset
Returns a function offset stored in the archive.
var string name
Name of the loaded field
PM_LoadFuncPtr
Returns a function pointer stored in the archive.
var string name
Name of the loaded field
PM_LoadClassPtr
Returns a class pointer stored in the archive.
var string name
Name of the loaded field
PM_LoadClass
Loads a pointer to the class from the archive to destPtr
.
var string name
Name of the loaded fieldvar int destPtr
Destination pointer, the address to where it will deserialize the saved data
PM_LoadArray
Returns a pointer to array stored in the archive.
var string name
Name of the loaded field
PM_LoadArrayToPtr
Loads a pointer to array from the archive to destPtr
.
var string name
Name of the loaded fieldvar int destPtr
Destination pointer, the address to where it will deserialize the saved data
PM_LoadToPtr
Universal function to load array or class pointer from the archive to destPtr
.
var string name
Name of the loaded fieldvar int destPtr
Destination pointer, the address to where it will deserialize the saved data