Isle
Loading...
Searching...
No Matches
mxutilities.h File Reference
#include "mxtypes.h"
#include <string.h>
Include dependency graph for mxutilities.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<class T >
Abs (T p_t)
 Returns the absolute value of a value. More...
 
template<class T >
Min (T p_t1, T p_t2)
 Returns the minimum of two values. More...
 
template<class T >
Max (T p_t1, T p_t2)
 Returns the maximum of two values. More...
 
template<class T >
void GetScalar (MxU8 *&p_source, T &p_dest)
 Reads a value of type T from a memory buffer and advances the pointer. More...
 
template<class T >
GetScalar (T *&p_source)
 Reads a single value from a pointer and advances the pointer. More...
 
template<class T >
void GetDouble (MxU8 *&p_source, T &p_dest)
 Reads a double-precision value from memory and advances the pointer. More...
 
template<class T >
void GetString (MxU8 *&p_source, char *&p_dest, T *p_obj, void(T::*p_setter)(const char *))
 Extracts a string from a buffer and assigns it using a setter function on an object. More...
 
MxBool GetRectIntersection (MxS32 p_rect1Width, MxS32 p_rect1Height, MxS32 p_rect2Width, MxS32 p_rect2Height, MxS32 *p_rect1Left, MxS32 *p_rect1Top, MxS32 *p_rect2Left, MxS32 *p_rect2Top, MxS32 *p_width, MxS32 *p_height)
 Computes intersection of two rectangles and modifies their positions and dimensions to the intersection area. More...
 
void MakeSourceName (char *, const char *)
 Parses an SI source filename and normalizes it for use in the engine. More...
 
void OmniError (const char *p_message, MxS32 p_status)
 Displays or logs an error message using the current user message handler, or aborts on error status if none is set. More...
 
void SetOmniUserMessage (void(*p_omniUserMessage)(const char *, MxS32))
 Sets the callback to handle user messages, such as errors or logs, for the OMNI engine. More...
 
MxBool ContainsPresenter (MxCompositePresenterList &p_presenterList, MxPresenter *p_presenter)
 Determines if a presenter exists within a composite presenter hierarchy. More...
 
void FUN_100b7220 (MxDSAction *p_action, MxU32 p_newFlags, MxBool p_setFlags)
 Recursively sets or clears flags for an MxDSAction and all sub-actions if applicable. More...
 
MxBool KeyValueStringParse (char *, const char *, const char *)
 Searches p_string for a key command and copies its associated value to p_output. More...
 

Function Documentation

◆ Abs()

template<class T >
T Abs ( p_t)
inline

Returns the absolute value of a value.

[AI]

[AI] Templated utility function to compute the absolute value for any arithmetic type.

Template Parameters
T[AI] Any type supporting comparison and negation.
Parameters
p_t[AI] Value to compute the absolute value of.
Returns
Absolute value of p_t. [AI]

Definition at line 22 of file mxutilities.h.

◆ ContainsPresenter()

MxBool ContainsPresenter ( MxCompositePresenterList p_presenterList,
MxPresenter p_presenter 
)

Determines if a presenter exists within a composite presenter hierarchy.

[AI]

[AI] Searches recursively within all composite presenters for an exact pointer match or type match.

Parameters
p_presenterList[AI] Reference to list of composite presenters.
p_presenter[AI] Presenter to look for.
Returns
TRUE if found, FALSE otherwise. [AI]

Definition at line 122 of file mxutilities.cpp.

◆ FUN_100b7220()

void FUN_100b7220 ( MxDSAction p_action,
MxU32  p_newFlags,
MxBool  p_setFlags 
)

Recursively sets or clears flags for an MxDSAction and all sub-actions if applicable.

[AI]

[AI] If the object is a MxDSMultiAction, recurses into its action list, updating flags for all contained actions.

Parameters
p_action[AI] The root action to update.
p_newFlags[AI] Flags to set or clear.
p_setFlags[AI] TRUE to set bits, FALSE to clear bits in the action's flags. [AI_SUGGESTED_NAME: SetActionFlagsRecursive]

Definition at line 153 of file mxutilities.cpp.

◆ GetDouble()

template<class T >
void GetDouble ( MxU8 *&  p_source,
T &  p_dest 
)
inline

Reads a double-precision value from memory and advances the pointer.

[AI]

[AI] Specialized for double reads, as some SI chunks may pack doubles specially.

Template Parameters
T[AI] Target type to store the double into (usually double).
Parameters
p_source[AI] Reference to pointer in buffer, will be incremented by sizeof(double).
p_dest[AI] Destination to store the value.

Definition at line 92 of file mxutilities.h.

◆ GetRectIntersection()

MxBool GetRectIntersection ( MxS32  p_rect1Width,
MxS32  p_rect1Height,
MxS32  p_rect2Width,
MxS32  p_rect2Height,
MxS32 p_rect1Left,
MxS32 p_rect1Top,
MxS32 p_rect2Left,
MxS32 p_rect2Top,
MxS32 p_width,
MxS32 p_height 
)

Computes intersection of two rectangles and modifies their positions and dimensions to the intersection area.

[AI]

[AI] Used to find overlapping portions when rendering or handling collision/visibility in 2D screen/UI contexts. Modifies parameters in-place.

Parameters
p_rect1Width[AI] Width of first rectangle.
p_rect1Height[AI] Height of first rectangle.
p_rect2Width[AI] Width of second rectangle.
p_rect2Height[AI] Height of second rectangle.
p_rect1Left[AI] Pointer to X of top-left of first rectangle (modified to intersection).
p_rect1Top[AI] Pointer to Y of top-left of first rectangle (modified to intersection).
p_rect2Left[AI] Pointer to X of top-left of second rectangle (modified to intersection).
p_rect2Top[AI] Pointer to Y of top-left of second rectangle (modified to intersection).
p_width[AI] Pointer to width of the intersection area.
p_height[AI] Pointer to height of the intersection area.
Returns
TRUE if the rectangles intersect, FALSE otherwise. [AI]

Definition at line 19 of file mxutilities.cpp.

◆ GetScalar() [1/2]

template<class T >
void GetScalar ( MxU8 *&  p_source,
T &  p_dest 
)
inline

Reads a value of type T from a memory buffer and advances the pointer.

[AI]

[AI] Used for deserialization from a byte buffer, e.g. for loading chunked SI data.

Template Parameters
T[AI] Type to extract.
Parameters
p_source[AI] Reference to pointer in buffer to read from. Will be incremented by sizeof(T).
p_dest[AI] Destination to store the extracted value.

Definition at line 63 of file mxutilities.h.

◆ GetScalar() [2/2]

template<class T >
T GetScalar ( T *&  p_source)
inline

Reads a single value from a pointer and advances the pointer.

[AI]

[AI] Convenience version for types already aligned in memory.

Template Parameters
T[AI] Type to extract.
Parameters
p_source[AI] Reference to pointer to T to read from. Increments pointer by one element.
Returns
The extracted value. [AI]

Definition at line 77 of file mxutilities.h.

◆ GetString()

template<class T >
void GetString ( MxU8 *&  p_source,
char *&  p_dest,
T *  p_obj,
void(T::*)(const char *)  p_setter 
)
inline

Extracts a string from a buffer and assigns it using a setter function on an object.

[AI]

[AI] Reads a NUL-terminated string, uses p_setter member function to consume it, then advances buffer pointer past string.

Template Parameters
T[AI] Type of the object with the setter member function.
Parameters
p_source[AI] Reference to buffer pointer, advanced past the string.
p_dest[AI] The string pointer assigned by the setter.
p_obj[AI] Object to call member function on.
p_setter[AI] Member function accepting a const char* as parameter. Typically sets a property on the object.

Definition at line 108 of file mxutilities.h.

◆ KeyValueStringParse()

MxBool KeyValueStringParse ( char *  p_output,
const char *  p_command,
const char *  p_string 
)

Searches p_string for a key command and copies its associated value to p_output.

[AI]

[AI] For commands like "foo:123, bar:456", if p_command is "bar" then p_output becomes "456". Used in config or SI parsing.

Parameters
p_output[AI] Buffer for found value.
p_command[AI] Key to search for.
p_string[AI] String to search in.
Returns
TRUE if key is found, FALSE otherwise. [AI]

Definition at line 85 of file mxutilities.cpp.

◆ MakeSourceName()

void MakeSourceName ( char *  p_output,
const char *  p_input 
)

Parses an SI source filename and normalizes it for use in the engine.

[AI]

[AI] Removes any disk designator (e.g., 'C:') and ".si" extension, and makes string lowercase.

Parameters
p_output[AI] Output buffer for source name.
p_input[AI] Input filename (may include drive, extension, etc.).

Definition at line 66 of file mxutilities.cpp.

◆ Max()

template<class T >
T Max ( p_t1,
p_t2 
)
inline

Returns the maximum of two values.

[AI]

[AI] Templated utility function to select the greater of two values.

Template Parameters
T[AI] Any type supporting comparison.
Parameters
p_t1[AI] First value.
p_t2[AI] Second value.
Returns
Largest of p_t1 and p_t2. [AI]

Definition at line 50 of file mxutilities.h.

◆ Min()

template<class T >
T Min ( p_t1,
p_t2 
)
inline

Returns the minimum of two values.

[AI]

[AI] Templated utility function to select the smaller of two values.

Template Parameters
T[AI] Any type supporting comparison.
Parameters
p_t1[AI] First value.
p_t2[AI] Second value.
Returns
Smallest of p_t1 and p_t2. [AI]

Definition at line 36 of file mxutilities.h.

◆ OmniError()

void OmniError ( const char *  p_message,
MxS32  p_status 
)

Displays or logs an error message using the current user message handler, or aborts on error status if none is set.

[AI]

[AI] If the callback is not set and status is non-zero, aborts process. Otherwise, invokes callback.

Parameters
p_message[AI] Null-terminated error message.
p_status[AI] Status code or severity.

Definition at line 135 of file mxutilities.cpp.

◆ SetOmniUserMessage()

void SetOmniUserMessage ( void(*)(const char *, MxS32 p_omniUserMessage)

Sets the callback to handle user messages, such as errors or logs, for the OMNI engine.

[AI]

[AI] The callback is a function pointer invoked by OmniError.

Parameters
p_omniUserMessage[AI] Callback function accepting a string message and status integer.

Definition at line 146 of file mxutilities.cpp.