FS2_Open
Open source remastering of the Freespace 2 engine
pstypes.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <string.h>
#include "globalincs/toolchain.h"
#include "windows_stub/config.h"
#include "osapi/outwnd.h"
#include "math/fix.h"
#include "math/floating.h"
#include "globalincs/fsmemory.h"
#include "globalincs/vmallocator.h"
#include "globalincs/safe_strings.h"

Go to the source code of this file.

Classes

struct  ccodes
 
struct  vec4
 
struct  vec3d
 
struct  vec2d
 
struct  angles
 
struct  matrix
 
struct  matrix4
 
struct  uv_pair
 
struct  screen3d
 
struct  vertex
 
struct  effect_vertex
 
struct  particle_pnt
 
struct  trail_shader_info
 
struct  flag_def_list
 
struct  wep_t
 
struct  coord2d
 
struct  lod_checker
 
class  monitor
 
struct  script_hook
 
class  camid
 

Macros

#define UNINITIALIZED   0x7f8e6d9c
 
#define MAX_PLAYERS   12
 
#define USE_INLINE_ASM   1
 
#define STRUCT_CMP(a, b)   memcmp((void *) &a, (void *) &b, sizeof(a))
 
#define LOCAL   static
 
#define DIR_SEPARATOR_CHAR   '/'
 
#define DIR_SEPARATOR_STR   "/"
 
#define HARDWARE_ONLY
 
#define mprintf(args)   outwnd_printf2 args
 
#define nprintf(args)   outwnd_printf args
 
#define LOCATION   __FILE__,__LINE__
 
#define Assert(expr)
 
#define Verify(x)   do { if (!(x)){ Error(LOCATION, "Verify failure: %s\n", #x); } ASSUME(x); } while(0)
 
#define VerifyEx(x, y, ...)   do { if (!(x)) { Error(LOCATION, "Verify failure: %s with help text " #y "\n", #x, ##__VA_ARGS__); } ASSUME(x); } while(0)
 
#define Int3()   debug_int3(__FILE__, __LINE__)
 
#define MIN(a, b)   (((a) < (b)) ? (a) : (b))
 
#define MAX(a, b)   (((a) > (b)) ? (a) : (b))
 
#define PI   3.141592654f
 
#define MAX_FILENAME_LEN   32
 
#define MAX_PATH_LEN   256
 
#define SWAPSHORT(x)
 
#define SWAPINT(x)
 
#define BYTE_ORDER   BIG_ENDIAN
 
#define __stwbrx(value, base, index)   __asm__ ( "stwbrx %0, %1, %2" : : "r" (value), "b%" (index), "r" (base) : "memory" )
 
#define INTEL_INT(x)   SWAPINT(x)
 
#define INTEL_SHORT(x)   SWAPSHORT(x)
 
#define INTEL_FLOAT(x)   SWAPFLOAT(x)
 
#define TRUE   1
 
#define FALSE   0
 
#define VALID_FNAME(x)   ( strlen((x)) && stricmp((x), "none") && stricmp((x), "<none>") )
 
#define MONITOR(function_name)   monitor mon_##function_name(#function_name);
 
#define MONITOR_INC(function_name, inc)   do { mon_##function_name.value+=(inc); } while(0)
 
#define NOX(s)   s
 
#define CLAMP(x, min, max)   do { if ( (x) < (min) ) (x) = (min); else if ((x) > (max)) (x) = (max); } while(0)
 
#define STAMP_STRING   "\001\001\001\001\002\002\002\002Read the Foundation Novels from Asimov. I liked them."
 
#define STAMP_STRING_LENGTH   80
 
#define DEFAULT_CHECKSUM_STRING   "\001\001\001\001"
 
#define DEFAULT_TIME_STRING   "\002\002\002\002"
 
#define CALCULATE_STAMP_CHECKSUM()
 
#define vm_malloc(size)   _vm_malloc((size),__FILE__,__LINE__,0)
 
#define vm_free(ptr)   _vm_free((ptr),__FILE__,__LINE__)
 
#define vm_strdup(ptr)   _vm_strdup((ptr),__FILE__,__LINE__)
 
#define vm_strndup(ptr, size)   _vm_strndup((ptr),(size),__FILE__,__LINE__)
 
#define vm_realloc(ptr, size)   _vm_realloc((ptr),(size),__FILE__,__LINE__,0)
 
#define vm_malloc_q(size)   _vm_malloc((size),__FILE__,__LINE__,1)
 
#define vm_realloc_q(ptr, size)   _vm_realloc((ptr),(size),__FILE__,__LINE__,1)
 

Typedefs

typedef long fix
 
typedef long _fs_time_t
 
typedef int ptr_s
 
typedef unsigned int ptr_u
 
typedef __int64 longlong
 
typedef unsigned __int64 ulonglong
 
typedef unsigned char ubyte
 
typedef unsigned short ushort
 
typedef unsigned int uint
 
typedef unsigned long ulong
 
typedef struct ccodes ccodes
 
typedef struct vec4 vec4
 
typedef struct vec3d vec3d
 
typedef struct vec2d vec2d
 
typedef struct angles angles_t
 
typedef struct matrix matrix
 
typedef struct matrix4 matrix4
 
typedef struct uv_pair uv_pair
 
typedef struct screen3d screen3d
 
typedef struct vertex vertex
 
typedef struct effect_vertex effect_vertex
 
typedef struct flag_def_list def_list
 
typedef struct wep_t wep_t
 
typedef struct coord2d coord2d
 
typedef struct lod_checker lod_checker
 
typedef struct script_hook script_hook
 

Functions

bool operator== (const vec3d &self, const vec3d &other)
 
bool operator== (const uv_pair &left, const uv_pair &right)
 
bool operator== (const screen3d &self, const screen3d &other)
 
void _cdecl WinAssert (char *text, char *filename, int line)
 
void _cdecl WinAssert (char *text, char *filename, int linenum, SCP_FORMAT_STRING const char *format,...) SCP_FORMAT_STRING_ARGS(4
 
void _cdecl void LuaError (struct lua_State *L, SCP_FORMAT_STRING const char *format=NULL,...) SCP_FORMAT_STRING_ARGS(2
 
void _cdecl void void _cdecl Error (const char *filename, int line, SCP_FORMAT_STRING const char *format,...) SCP_FORMAT_STRING_ARGS(3
 
void _cdecl void void _cdecl void _cdecl Warning (char *filename, int line, SCP_FORMAT_STRING const char *format,...) SCP_FORMAT_STRING_ARGS(3
 
void _cdecl void void _cdecl void _cdecl void _cdecl WarningEx (char *filename, int line, SCP_FORMAT_STRING const char *format,...) SCP_FORMAT_STRING_ARGS(3
 
void _cdecl void void _cdecl void _cdecl void _cdecl void _cdecl ReleaseWarning (char *filename, int line, SCP_FORMAT_STRING const char *format,...) SCP_FORMAT_STRING_ARGS(3
 
void gr_activate (int)
 
void debug_int3 (char *file, int line)
 
float SWAPFLOAT (float *x)
 
int myrand ()
 
int rand32 ()
 
int game_busy_callback (void(*callback)(int count), int delta_step=-1)
 
void game_busy (const char *filename=NULL)
 
void monitor_update ()
 
const char * XSTR (const char *str, int index)
 
template<class T >
void CAP (T &v, T mn, T mx)
 
int vm_init (int min_heap_size)
 
void vm_free_all ()
 
void_vm_malloc (int size, char *filename=NULL, int line=-1, int quiet=0)
 
char * _vm_strdup (const char *ptr, char *filename, int line)
 
char * _vm_strndup (const char *ptr, int size, char *filename, int line)
 
void _vm_free (void *ptr, char *filename=NULL, int line=-1)
 
void_vm_realloc (void *ptr, int size, char *filename=NULL, int line=-1, int quiet=0)
 
void script_hook_init (script_hook *hook)
 
bool script_hook_valid (script_hook *hook)
 

Variables

void _cdecl void void _cdecl void _cdecl void _cdecl void _cdecl int Global_warning_count
 
int Global_error_count
 
const float PI2 = (PI*2.0f)
 
const float PI_2 = (PI/2.0f)
 
const int RAND_MAX_2 = (RAND_MAX/2)
 
const float RAND_MAX_1f = (1.0f / RAND_MAX)
 
int Fred_running
 

Macro Definition Documentation

#define __stwbrx (   value,
  base,
  index 
)    __asm__ ( "stwbrx %0, %1, %2" : : "r" (value), "b%" (index), "r" (base) : "memory" )
#define Assert (   expr)
Value:
do {\
if (!(expr)) {\
WinAssert(#expr,__FILE__,__LINE__);\
}\
ASSUME( expr );\
} while (0)
if(aifft_max_checks<=0)
Definition: aiturret.cpp:1581
#define ASSUME(x)
Definition: clang.h:32
void _cdecl WinAssert(char *text, char *filename, int line)
Definition: windebug.cpp:911

Definition at line 262 of file pstypes.h.

#define BYTE_ORDER   BIG_ENDIAN

Definition at line 347 of file pstypes.h.

#define CALCULATE_STAMP_CHECKSUM ( )
Value:
do { \
int i, found; \
\
checksum = 0; \
for ( i = 0; i < (int)strlen(ptr); i++ ) { \
found = 0; \
checksum += ptr[i]; \
if ( checksum & 0x01 ) \
found = 1; \
checksum = checksum >> 1; \
if (found) \
checksum |= 0x80000000; \
} \
checksum |= 0x80000000; \
} while (0) ;
int i
Definition: multi_pxo.cpp:466
typedef int(SCP_EXT_CALLCONV *SCPDLL_PFVERSION)(SCPDLL_Version *)
for(int idx=0;idx< i;idx++)
Definition: multi_pxo.cpp:472
if(aifft_max_checks<=0)
Definition: aiturret.cpp:1581

Definition at line 502 of file pstypes.h.

#define CLAMP (   x,
  min,
  max 
)    do { if ( (x) < (min) ) (x) = (min); else if ((x) > (max)) (x) = (max); } while(0)

Definition at line 488 of file pstypes.h.

#define DEFAULT_CHECKSUM_STRING   "\001\001\001\001"

Definition at line 497 of file pstypes.h.

#define DEFAULT_TIME_STRING   "\002\002\002\002"

Definition at line 498 of file pstypes.h.

#define DIR_SEPARATOR_CHAR   '/'

Definition at line 43 of file pstypes.h.

#define DIR_SEPARATOR_STR   "/"

Definition at line 44 of file pstypes.h.

#define FALSE   0

Definition at line 400 of file pstypes.h.

#define HARDWARE_ONLY

Definition at line 67 of file pstypes.h.

#define Int3 ( )    debug_int3(__FILE__, __LINE__)

Definition at line 292 of file pstypes.h.

#define INTEL_FLOAT (   x)    SWAPFLOAT(x)

Definition at line 391 of file pstypes.h.

#define INTEL_INT (   x)    SWAPINT(x)

Definition at line 388 of file pstypes.h.

#define INTEL_SHORT (   x)    SWAPSHORT(x)

Definition at line 389 of file pstypes.h.

#define LOCAL   static

Definition at line 37 of file pstypes.h.

#define LOCATION   __FILE__,__LINE__

Definition at line 245 of file pstypes.h.

#define MAX (   a,
  b 
)    (((a) > (b)) ? (a) : (b))

Definition at line 299 of file pstypes.h.

#define MAX_FILENAME_LEN   32

Definition at line 324 of file pstypes.h.

#define MAX_PATH_LEN   256

Definition at line 325 of file pstypes.h.

#define MAX_PLAYERS   12

Definition at line 32 of file pstypes.h.

#define MIN (   a,
  b 
)    (((a) < (b)) ? (a) : (b))

Definition at line 296 of file pstypes.h.

#define MONITOR (   function_name)    monitor mon_##function_name(#function_name);

Definition at line 454 of file pstypes.h.

#define MONITOR_INC (   function_name,
  inc 
)    do { mon_##function_name.value+=(inc); } while(0)

Definition at line 457 of file pstypes.h.

#define mprintf (   args)    outwnd_printf2 args

Definition at line 238 of file pstypes.h.

#define NOX (   s)    s

Definition at line 473 of file pstypes.h.

#define nprintf (   args)    outwnd_printf args

Definition at line 239 of file pstypes.h.

#define PI   3.141592654f

Definition at line 303 of file pstypes.h.

#define STAMP_STRING   "\001\001\001\001\002\002\002\002Read the Foundation Novels from Asimov. I liked them."

Definition at line 495 of file pstypes.h.

#define STAMP_STRING_LENGTH   80

Definition at line 496 of file pstypes.h.

#define STRUCT_CMP (   a,
  b 
)    memcmp((void *) &a, (void *) &b, sizeof(a))

Definition at line 35 of file pstypes.h.

#define SWAPINT (   x)
Value:
( \
(x << 24) | \
(((ulong)x) >> 24) | \
((x & 0x0000ff00) << 8) | \
((x & 0x00ff0000) >> 8) \
)
unsigned long ulong
Definition: pstypes.h:65
GLint GLint GLint GLint GLint x
Definition: Glext.h:5182

Definition at line 334 of file pstypes.h.

#define SWAPSHORT (   x)
Value:
( \
((ubyte)x << 8) | \
(((ushort)x) >> 8) \
)
GLint GLint GLint GLint GLint x
Definition: Glext.h:5182
unsigned char ubyte
Definition: pstypes.h:62
unsigned short ushort
Definition: pstypes.h:63

Definition at line 329 of file pstypes.h.

#define TRUE   1

Definition at line 399 of file pstypes.h.

#define UNINITIALIZED   0x7f8e6d9c

Definition at line 30 of file pstypes.h.

#define USE_INLINE_ASM   1

Definition at line 34 of file pstypes.h.

#define VALID_FNAME (   x)    ( strlen((x)) && stricmp((x), "none") && stricmp((x), "<none>") )

Definition at line 418 of file pstypes.h.

#define Verify (   x)    do { if (!(x)){ Error(LOCATION, "Verify failure: %s\n", #x); } ASSUME(x); } while(0)

Definition at line 272 of file pstypes.h.

#define VerifyEx (   x,
  y,
  ... 
)    do { if (!(x)) { Error(LOCATION, "Verify failure: %s with help text " #y "\n", #x, ##__VA_ARGS__); } ASSUME(x); } while(0)

Definition at line 276 of file pstypes.h.

#define vm_free (   ptr)    _vm_free((ptr),__FILE__,__LINE__)

Definition at line 548 of file pstypes.h.

#define vm_malloc (   size)    _vm_malloc((size),__FILE__,__LINE__,0)

Definition at line 547 of file pstypes.h.

#define vm_malloc_q (   size)    _vm_malloc((size),__FILE__,__LINE__,1)

Definition at line 554 of file pstypes.h.

#define vm_realloc (   ptr,
  size 
)    _vm_realloc((ptr),(size),__FILE__,__LINE__,0)

Definition at line 551 of file pstypes.h.

#define vm_realloc_q (   ptr,
  size 
)    _vm_realloc((ptr),(size),__FILE__,__LINE__,1)

Definition at line 555 of file pstypes.h.

#define vm_strdup (   ptr)    _vm_strdup((ptr),__FILE__,__LINE__)

Definition at line 549 of file pstypes.h.

#define vm_strndup (   ptr,
  size 
)    _vm_strndup((ptr),(size),__FILE__,__LINE__)

Definition at line 550 of file pstypes.h.

Typedef Documentation

typedef long _fs_time_t

Definition at line 55 of file pstypes.h.

typedef struct angles angles_t
typedef struct ccodes ccodes
typedef struct coord2d coord2d
typedef struct flag_def_list def_list
typedef struct effect_vertex effect_vertex
typedef long fix

Definition at line 54 of file pstypes.h.

typedef struct lod_checker lod_checker
typedef __int64 longlong

Definition at line 60 of file pstypes.h.

typedef struct matrix matrix
typedef struct matrix4 matrix4
typedef int ptr_s

Definition at line 56 of file pstypes.h.

typedef unsigned int ptr_u

Definition at line 57 of file pstypes.h.

typedef struct screen3d screen3d

Represents a point in 3d screen space. 'w' is 1/z.

Like vec3d but for screens.

Note: this is a struct, not a class, so no member functions.

typedef struct script_hook script_hook
typedef unsigned char ubyte

Definition at line 62 of file pstypes.h.

typedef unsigned int uint

Definition at line 64 of file pstypes.h.

typedef unsigned long ulong

Definition at line 65 of file pstypes.h.

typedef unsigned __int64 ulonglong

Definition at line 61 of file pstypes.h.

typedef unsigned short ushort

Definition at line 63 of file pstypes.h.

typedef struct uv_pair uv_pair
typedef struct vec2d vec2d
typedef struct vec3d vec3d

Represents a point in 3d space.

Note: this is a struct, not a class, so no member functions.

typedef struct vec4 vec4
typedef struct vertex vertex

Used to store rotated points for mines. Has flag to indicate if projected.

Note: this is a struct, not a class, so no memeber functions.

typedef struct wep_t wep_t

Function Documentation

void _vm_free ( void ptr,
char *  filename = NULL,
int  line = -1 
)

Definition at line 1973 of file windebug.cpp.

void* _vm_malloc ( int  size,
char *  filename = NULL,
int  line = -1,
int  quiet = 0 
)

Definition at line 1906 of file windebug.cpp.

void* _vm_realloc ( void ptr,
int  size,
char *  filename = NULL,
int  line = -1,
int  quiet = 0 
)

Definition at line 2001 of file windebug.cpp.

char* _vm_strdup ( const char *  ptr,
char *  filename,
int  line 
)

Definition at line 1935 of file windebug.cpp.

char* _vm_strndup ( const char *  ptr,
int  size,
char *  filename,
int  line 
)

Definition at line 1953 of file windebug.cpp.

template<class T >
void CAP ( T &  v,
mn,
mx 
)

Definition at line 478 of file pstypes.h.

void debug_int3 ( char *  file,
int  line 
)

Definition at line 769 of file osapi.cpp.

void _cdecl void void _cdecl Error ( const char *  filename,
int  line,
SCP_FORMAT_STRING const char *  format,
  ... 
)
void game_busy ( const char *  filename = NULL)

Definition at line 173 of file systemvars.cpp.

int game_busy_callback ( void(*)(int count callback,
int  delta_step = -1 
)

Definition at line 144 of file systemvars.cpp.

void gr_activate ( int  )

Definition at line 1122 of file 2d.cpp.

void _cdecl void LuaError ( struct lua_State *  L,
SCP_FORMAT_STRING const char *  format = NULL,
  ... 
)
void monitor_update ( )

Definition at line 328 of file systemvars.cpp.

int myrand ( )

Definition at line 102 of file systemvars.cpp.

bool operator== ( const vec3d self,
const vec3d other 
)
inline

Compares two vec3ds

Definition at line 98 of file pstypes.h.

bool operator== ( const uv_pair left,
const uv_pair right 
)
inline

Compares two uv_pairs

Definition at line 139 of file pstypes.h.

bool operator== ( const screen3d self,
const screen3d other 
)
inline

Compares two screen3ds

Definition at line 160 of file pstypes.h.

int rand32 ( )

Definition at line 112 of file systemvars.cpp.

void _cdecl void void _cdecl void _cdecl void _cdecl void _cdecl ReleaseWarning ( char *  filename,
int  line,
SCP_FORMAT_STRING const char *  format,
  ... 
)
void script_hook_init ( script_hook hook)

Definition at line 97 of file scripting.cpp.

bool script_hook_valid ( script_hook hook)

Definition at line 107 of file scripting.cpp.

float SWAPFLOAT ( float x)
inline

Definition at line 360 of file pstypes.h.

void vm_free_all ( )

Definition at line 1996 of file windebug.cpp.

int vm_init ( int  min_heap_size)

Definition at line 1657 of file windebug.cpp.

void _cdecl void void _cdecl void _cdecl Warning ( char *  filename,
int  line,
SCP_FORMAT_STRING const char *  format,
  ... 
)
void _cdecl void void _cdecl void _cdecl void _cdecl WarningEx ( char *  filename,
int  line,
SCP_FORMAT_STRING const char *  format,
  ... 
)
void _cdecl WinAssert ( char *  text,
char *  filename,
int  line 
)

Definition at line 911 of file windebug.cpp.

void _cdecl WinAssert ( char *  text,
char *  filename,
int  linenum,
SCP_FORMAT_STRING const char *  format,
  ... 
)
const char* XSTR ( const char *  str,
int  index 
)

Definition at line 851 of file localize.cpp.

Variable Documentation

int Fred_running

Definition at line 44 of file fred.cpp.

int Global_error_count

Definition at line 47 of file windebug.cpp.

Definition at line 46 of file windebug.cpp.

const float PI2 = (PI*2.0f)

Definition at line 305 of file pstypes.h.

const float PI_2 = (PI/2.0f)

Definition at line 307 of file pstypes.h.

const float RAND_MAX_1f = (1.0f / RAND_MAX)

Definition at line 309 of file pstypes.h.

const int RAND_MAX_2 = (RAND_MAX/2)

Definition at line 308 of file pstypes.h.