2007-06-27 22:00:00 +02:00
|
|
|
|
//=======================================================================
|
|
|
|
|
// Copyright XashXT Group 2007 <20>
|
|
|
|
|
// ref_system.h - generic shared interfaces
|
|
|
|
|
//=======================================================================
|
|
|
|
|
#ifndef REF_SYSTEM_H
|
|
|
|
|
#define REF_SYSTEM_H
|
|
|
|
|
|
2007-07-28 22:00:00 +02:00
|
|
|
|
#include "studio.h"
|
|
|
|
|
#include "sprite.h"
|
|
|
|
|
#include "bspmodel.h"
|
2007-08-13 22:00:00 +02:00
|
|
|
|
#include "version.h"
|
|
|
|
|
|
2007-07-28 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
#define RENDERER_API_VERSION 4
|
|
|
|
|
#define PLATFORM_API_VERSION 2
|
2007-08-13 22:00:00 +02:00
|
|
|
|
#define LAUNCHER_API_VERSION 2
|
|
|
|
|
|
2007-07-28 22:00:00 +02:00
|
|
|
|
|
2007-06-29 22:00:00 +02:00
|
|
|
|
//bsplib compile flags
|
|
|
|
|
#define BSP_ONLYENTS 0x01
|
|
|
|
|
#define BSP_ONLYVIS 0x02
|
|
|
|
|
#define BSP_ONLYRAD 0x04
|
|
|
|
|
#define BSP_FULLCOMPILE 0x08
|
|
|
|
|
|
2007-08-28 22:00:00 +02:00
|
|
|
|
//qcclib compile flags
|
|
|
|
|
#define QCC_PROGDEFS 0x01
|
|
|
|
|
#define QCC_OPT_LEVEL_0 0x02
|
|
|
|
|
#define QCC_OPT_LEVEL_1 0x04
|
|
|
|
|
#define QCC_OPT_LEVEL_2 0x08
|
|
|
|
|
#define QCC_OPT_LEVEL_3 0x10
|
|
|
|
|
|
2007-07-28 22:00:00 +02:00
|
|
|
|
#define MAX_DLIGHTS 32
|
|
|
|
|
#define MAX_ENTITIES 128
|
|
|
|
|
#define MAX_PARTICLES 4096
|
|
|
|
|
#define MAX_LIGHTSTYLES 256
|
|
|
|
|
|
|
|
|
|
#define ENTITY_FLAGS 68
|
|
|
|
|
#define POWERSUIT_SCALE 4.0F
|
|
|
|
|
|
|
|
|
|
#define SHELL_RED_COLOR 0xF2
|
|
|
|
|
#define SHELL_GREEN_COLOR 0xD0
|
|
|
|
|
#define SHELL_BLUE_COLOR 0xF3
|
|
|
|
|
|
|
|
|
|
#define SHELL_RG_COLOR 0xDC
|
|
|
|
|
#define SHELL_RB_COLOR 0x68
|
|
|
|
|
#define SHELL_BG_COLOR 0x78
|
|
|
|
|
#define SHELL_WHITE_COLOR 0xD7
|
|
|
|
|
|
2007-07-07 22:00:00 +02:00
|
|
|
|
enum comp_format
|
|
|
|
|
{
|
|
|
|
|
PF_UNKNOWN = 0,
|
|
|
|
|
PF_INDEXED_8, // pcx or wal images with transparent color in palette
|
|
|
|
|
PF_INDEXED_24, // studio model skins
|
|
|
|
|
PF_INDEXED_32, // sprite 32-bit palette
|
|
|
|
|
PF_RGBA_32, // already prepared ".bmp", ".tga" or ".jpg" image
|
|
|
|
|
PF_ARGB_32, // uncompressed dds image
|
|
|
|
|
PF_RGB_24, // uncompressed dds or another 24-bit image
|
|
|
|
|
PF_DXT1, // nvidia DXT5 format
|
|
|
|
|
PF_DXT2, // nvidia DXT5 format
|
|
|
|
|
PF_DXT3, // nvidia DXT5 format
|
|
|
|
|
PF_DXT4, // nvidia DXT5 format
|
|
|
|
|
PF_DXT5, // nvidia DXT5 format
|
2007-07-12 22:00:00 +02:00
|
|
|
|
PF_ATI1N, // ati 1N texture
|
|
|
|
|
PF_ATI2N, // ati 2N texture
|
2007-07-07 22:00:00 +02:00
|
|
|
|
PF_LUMINANCE, // b&w dds image
|
|
|
|
|
PF_LUMINANCE_16, // b&w hi-res image
|
|
|
|
|
PF_LUMINANCE_ALPHA, // b&w dds image with alpha channel
|
|
|
|
|
PF_RXGB, // doom3 normal maps
|
2007-07-12 22:00:00 +02:00
|
|
|
|
PF_ABGR_64, // uint image
|
|
|
|
|
PF_ABGR_128F, // float image
|
2007-07-07 22:00:00 +02:00
|
|
|
|
PF_PROCEDURE_TEX, // internal special texture
|
|
|
|
|
PF_TOTALCOUNT, // must be last
|
|
|
|
|
};
|
|
|
|
|
|
2007-07-21 22:00:00 +02:00
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
MSG_ONE,
|
|
|
|
|
MSG_ALL,
|
|
|
|
|
MSG_PHS,
|
|
|
|
|
MSG_PVS,
|
2007-08-19 22:00:00 +02:00
|
|
|
|
MSG_ONE_R, // reliable
|
|
|
|
|
MSG_ALL_R,
|
2007-07-21 22:00:00 +02:00
|
|
|
|
MSG_PHS_R,
|
|
|
|
|
MSG_PVS_R,
|
|
|
|
|
} msgtype_t;
|
|
|
|
|
|
2007-09-03 22:00:00 +02:00
|
|
|
|
enum dev_level
|
|
|
|
|
{
|
|
|
|
|
D_INFO = 1, // "-developer 1", shows various system messages
|
|
|
|
|
D_WARN, // "-developer 2", shows not critical system warnings, same as MsgWarn
|
|
|
|
|
D_ERROR, // "-developer 3", shows critical warnings
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// format info table
|
2007-07-07 22:00:00 +02:00
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
int format; // pixelformat
|
|
|
|
|
char name[8]; // used for debug
|
|
|
|
|
int bpp; // channels (e.g. rgb = 3, rgba = 4)
|
|
|
|
|
int bpc; // sizebytes (byte, short, float)
|
2007-07-10 22:00:00 +02:00
|
|
|
|
int block; // blocksize < 0 needs alternate calc
|
2007-07-07 22:00:00 +02:00
|
|
|
|
} bpc_desc_t;
|
|
|
|
|
|
|
|
|
|
static bpc_desc_t PixelFormatDescription[] =
|
|
|
|
|
{
|
|
|
|
|
{PF_INDEXED_8, "pal 8", 4, 1, 0 },
|
2007-07-12 22:00:00 +02:00
|
|
|
|
{PF_INDEXED_24, "pal 24", 3, 1, 0 },
|
|
|
|
|
{PF_INDEXED_32, "pal 32", 4, 1, 0 },
|
2007-07-07 22:00:00 +02:00
|
|
|
|
{PF_RGBA_32, "RGBA", 4, 1, -4 },
|
|
|
|
|
{PF_ARGB_32, "ARGB", 4, 1, -4 },
|
|
|
|
|
{PF_RGB_24, "RGB", 3, 1, -3 },
|
|
|
|
|
{PF_DXT1, "DXT1", 4, 1, 8 },
|
|
|
|
|
{PF_DXT2, "DXT2", 4, 1, 16 },
|
|
|
|
|
{PF_DXT3, "DXT3", 4, 1, 16 },
|
|
|
|
|
{PF_DXT4, "DXT4", 4, 1, 16 },
|
|
|
|
|
{PF_DXT5, "DXT5", 4, 1, 16 },
|
|
|
|
|
{PF_ATI1N, "ATI1N", 1, 1, 8 },
|
2007-07-12 22:00:00 +02:00
|
|
|
|
{PF_ATI2N, "3DC", 3, 1, 16 },
|
2007-07-07 22:00:00 +02:00
|
|
|
|
{PF_LUMINANCE, "LUM 8", 1, 1, -1 },
|
|
|
|
|
{PF_LUMINANCE_16, "LUM 16", 2, 2, -2 },
|
|
|
|
|
{PF_LUMINANCE_ALPHA,"LUM A", 2, 1, -2 },
|
|
|
|
|
{PF_RXGB, "RXGB", 3, 1, 16 },
|
|
|
|
|
{PF_ABGR_64, "ABGR", 4, 2, -8 },
|
|
|
|
|
{PF_ABGR_128F, "ABGR128",4, 4, -16},
|
|
|
|
|
{PF_PROCEDURE_TEX, "system", 4, 1, -32},
|
|
|
|
|
{PF_UNKNOWN, "", 0, 0, 0 },
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define IMAGE_CUBEMAP 0x00000001
|
|
|
|
|
#define IMAGE_HAS_ALPHA 0x00000002
|
|
|
|
|
#define IMAGE_PREMULT 0x00000004 // indices who need in additional premultiply
|
|
|
|
|
#define IMAGE_GEN_MIPS 0x00000008 // must generate mips
|
|
|
|
|
|
2007-07-12 22:00:00 +02:00
|
|
|
|
#define CUBEMAP_POSITIVEX 0x00000400L
|
|
|
|
|
#define CUBEMAP_NEGATIVEX 0x00000800L
|
|
|
|
|
#define CUBEMAP_POSITIVEY 0x00001000L
|
|
|
|
|
#define CUBEMAP_NEGATIVEY 0x00002000L
|
|
|
|
|
#define CUBEMAP_POSITIVEZ 0x00004000L
|
|
|
|
|
#define CUBEMAP_NEGATIVEZ 0x00008000L
|
|
|
|
|
|
2007-06-27 22:00:00 +02:00
|
|
|
|
typedef struct search_s
|
|
|
|
|
{
|
|
|
|
|
int numfilenames;
|
|
|
|
|
char **filenames;
|
|
|
|
|
char *filenamesbuffer;
|
2007-07-28 22:00:00 +02:00
|
|
|
|
|
2007-06-27 22:00:00 +02:00
|
|
|
|
} search_t;
|
|
|
|
|
|
|
|
|
|
typedef struct rgbdata_s
|
|
|
|
|
{
|
|
|
|
|
word width; // image width
|
|
|
|
|
word height; // image height
|
2007-07-07 22:00:00 +02:00
|
|
|
|
byte numLayers; // multi-layer volume
|
|
|
|
|
byte numMips; // mipmap count
|
2007-07-10 22:00:00 +02:00
|
|
|
|
byte bitsCount; // RGB bits count
|
2007-07-07 22:00:00 +02:00
|
|
|
|
uint type; // compression type
|
|
|
|
|
uint flags; // misc image flags
|
2007-06-27 22:00:00 +02:00
|
|
|
|
byte *palette; // palette if present
|
|
|
|
|
byte *buffer; // image buffer
|
2007-07-28 22:00:00 +02:00
|
|
|
|
|
2007-06-27 22:00:00 +02:00
|
|
|
|
} rgbdata_t;
|
|
|
|
|
|
2007-06-29 22:00:00 +02:00
|
|
|
|
typedef struct gameinfo_s
|
|
|
|
|
{
|
|
|
|
|
//filesystem info
|
|
|
|
|
char basedir[128];
|
|
|
|
|
char gamedir[128];
|
|
|
|
|
char title[128];
|
|
|
|
|
float version;
|
|
|
|
|
|
|
|
|
|
int viewmode;
|
|
|
|
|
int gamemode;
|
|
|
|
|
|
|
|
|
|
//system info
|
|
|
|
|
int cpunum;
|
|
|
|
|
float cpufreq;
|
|
|
|
|
|
|
|
|
|
char key[16];
|
2007-07-28 22:00:00 +02:00
|
|
|
|
|
2007-06-29 22:00:00 +02:00
|
|
|
|
} gameinfo_t;
|
|
|
|
|
|
2007-07-28 22:00:00 +02:00
|
|
|
|
#define CVAR_ARCHIVE 1 // set to cause it to be saved to vars.rc
|
|
|
|
|
#define CVAR_USERINFO 2 // added to userinfo when changed
|
|
|
|
|
#define CVAR_SERVERINFO 4 // added to serverinfo when changed
|
|
|
|
|
#define CVAR_NOSET 8 // don't allow change from console at all, but can be set from the command line
|
|
|
|
|
#define CVAR_LATCH 16 // save changes until server restart
|
|
|
|
|
|
|
|
|
|
#define CVAR_MAXFLAGSVAL 31 // maximum number of flags
|
|
|
|
|
|
|
|
|
|
typedef struct cvar_s
|
|
|
|
|
{
|
|
|
|
|
int flags;
|
|
|
|
|
char *name;
|
|
|
|
|
|
|
|
|
|
char *string;
|
|
|
|
|
char *description;
|
|
|
|
|
int integer;
|
|
|
|
|
float value;
|
|
|
|
|
float vector[3];
|
|
|
|
|
char *defstring;
|
|
|
|
|
|
|
|
|
|
struct cvar_s *next;
|
|
|
|
|
struct cvar_s *hash;
|
|
|
|
|
|
|
|
|
|
//FIXME: remove these old variables
|
|
|
|
|
char *latched_string; // for CVAR_LATCH vars
|
|
|
|
|
bool modified; // set each time the cvar is changed
|
|
|
|
|
} cvar_t;
|
|
|
|
|
|
|
|
|
|
typedef struct dlight_s
|
|
|
|
|
{
|
|
|
|
|
vec3_t origin;
|
|
|
|
|
vec3_t color;
|
|
|
|
|
float intensity;
|
|
|
|
|
|
|
|
|
|
} dlight_t;
|
|
|
|
|
|
|
|
|
|
typedef struct particle_s
|
|
|
|
|
{
|
|
|
|
|
vec3_t origin;
|
|
|
|
|
int color;
|
|
|
|
|
float alpha;
|
|
|
|
|
|
|
|
|
|
} particle_t;
|
|
|
|
|
|
|
|
|
|
typedef struct lightstyle_s
|
|
|
|
|
{
|
|
|
|
|
float rgb[3]; // 0.0 - 2.0
|
|
|
|
|
float white; // highest of rgb
|
|
|
|
|
|
|
|
|
|
} lightstyle_t;
|
|
|
|
|
|
|
|
|
|
typedef struct latchedvars_s
|
|
|
|
|
{
|
|
|
|
|
float animtime;
|
|
|
|
|
float sequencetime;
|
|
|
|
|
vec3_t origin;
|
|
|
|
|
vec3_t angles;
|
|
|
|
|
|
|
|
|
|
int sequence;
|
|
|
|
|
float frame;
|
|
|
|
|
|
|
|
|
|
byte blending[MAXSTUDIOBLENDS];
|
|
|
|
|
byte seqblending[MAXSTUDIOBLENDS];
|
|
|
|
|
byte controller[MAXSTUDIOCONTROLLERS];
|
|
|
|
|
|
|
|
|
|
} latchedvars_t;
|
|
|
|
|
|
|
|
|
|
typedef struct entity_s
|
|
|
|
|
{
|
2007-08-19 22:00:00 +02:00
|
|
|
|
model_t *model; // opaque type outside refresh
|
|
|
|
|
model_t *weaponmodel; // opaque type outside refresh
|
2007-07-28 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
latchedvars_t prev; //previous frame values for lerping
|
|
|
|
|
|
|
|
|
|
vec3_t angles;
|
|
|
|
|
vec3_t origin; // also used as RF_BEAM's "from"
|
|
|
|
|
float oldorigin[3]; // also used as RF_BEAM's "to"
|
|
|
|
|
|
|
|
|
|
float animtime;
|
|
|
|
|
float frame; // also used as RF_BEAM's diameter
|
|
|
|
|
float framerate;
|
|
|
|
|
|
|
|
|
|
int body;
|
|
|
|
|
int skin;
|
|
|
|
|
|
|
|
|
|
byte blending[MAXSTUDIOBLENDS];
|
|
|
|
|
byte controller[MAXSTUDIOCONTROLLERS];
|
|
|
|
|
byte mouth; //TODO: move to struct
|
|
|
|
|
|
|
|
|
|
int movetype; //entity moving type
|
|
|
|
|
int sequence;
|
|
|
|
|
float scale;
|
|
|
|
|
|
|
|
|
|
vec3_t attachment[MAXSTUDIOATTACHMENTS];
|
|
|
|
|
|
|
|
|
|
// misc
|
|
|
|
|
float backlerp; // 0.0 = current, 1.0 = old
|
|
|
|
|
int skinnum; // also used as RF_BEAM's palette index
|
|
|
|
|
|
|
|
|
|
int lightstyle; // for flashing entities
|
|
|
|
|
float alpha; // ignore if RF_TRANSLUCENT isn't set
|
|
|
|
|
|
2007-08-19 22:00:00 +02:00
|
|
|
|
image_t *image; // NULL for inline skin
|
2007-07-28 22:00:00 +02:00
|
|
|
|
int flags;
|
|
|
|
|
|
|
|
|
|
} entity_t;
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
int x, y, width, height;// in virtual screen coordinates
|
|
|
|
|
float fov_x, fov_y;
|
|
|
|
|
float vieworg[3];
|
|
|
|
|
float viewangles[3];
|
|
|
|
|
float blend[4]; // rgba 0-1 full screen blend
|
2007-09-06 22:00:00 +02:00
|
|
|
|
float time; // time is used to auto animate
|
2007-07-28 22:00:00 +02:00
|
|
|
|
int rdflags; // RDF_UNDERWATER, etc
|
|
|
|
|
|
|
|
|
|
byte *areabits; // if not NULL, only areas with set bits will be drawn
|
|
|
|
|
|
|
|
|
|
lightstyle_t *lightstyles; // [MAX_LIGHTSTYLES]
|
|
|
|
|
|
|
|
|
|
int num_entities;
|
|
|
|
|
entity_t *entities;
|
|
|
|
|
|
|
|
|
|
int num_dlights;
|
|
|
|
|
dlight_t *dlights;
|
|
|
|
|
|
|
|
|
|
int num_particles;
|
|
|
|
|
particle_t *particles;
|
|
|
|
|
|
|
|
|
|
} refdef_t;
|
|
|
|
|
|
2007-06-27 22:00:00 +02:00
|
|
|
|
/*
|
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
|
|
FILESYSTEM ENGINE INTERFACE
|
|
|
|
|
==============================================================================
|
|
|
|
|
*/
|
|
|
|
|
typedef struct filesystem_api_s
|
|
|
|
|
{
|
|
|
|
|
//interface validator
|
2007-06-29 22:00:00 +02:00
|
|
|
|
size_t api_size; // must matched with sizeof(filesystem_api_t)
|
2007-06-27 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
//base functions
|
|
|
|
|
void (*FileBase)(char *in, char *out); // get filename without path & ext
|
|
|
|
|
bool (*FileExists)(const char *filename); // return true if file exist
|
|
|
|
|
long (*FileSize)(const char *filename); // same as FileExists but return filesize
|
|
|
|
|
const char *(*FileExtension)(const char *in); // return extension of file
|
|
|
|
|
const char *(*FileWithoutPath)(const char *in); // return file without path
|
|
|
|
|
void (*StripExtension)(char *path); // remove extension if present
|
2007-06-29 22:00:00 +02:00
|
|
|
|
void (*StripFilePath)(const char* const src, char* dst); // get file path without filename.ext
|
2007-06-27 22:00:00 +02:00
|
|
|
|
void (*DefaultExtension)(char *path, const char *ext ); // append extension if not present
|
|
|
|
|
void (*ClearSearchPath)( void ); // delete all search pathes
|
|
|
|
|
|
|
|
|
|
//built-in search interface
|
|
|
|
|
search_t *(*Search)(const char *pattern, int casecmp ); // returned list of found files
|
|
|
|
|
void (*FreeSearch)( search_t *search ); // free search results
|
|
|
|
|
|
|
|
|
|
//file low-level operations
|
2007-07-21 22:00:00 +02:00
|
|
|
|
file_t *(*Open)(const char* path, const char* mode); // same as fopen
|
2007-06-27 22:00:00 +02:00
|
|
|
|
int (*Close)(file_t* file); // same as fclose
|
|
|
|
|
long (*Write)(file_t* file, const void* data, size_t datasize); // same as fwrite
|
|
|
|
|
long (*Read)(file_t* file, void* buffer, size_t buffersize); // same as fread, can see trough pakfile
|
|
|
|
|
int (*Print)(file_t* file, const char *msg); // printed message into file
|
|
|
|
|
int (*Printf)(file_t* file, const char* format, ...); // same as fprintf
|
|
|
|
|
int (*Gets)(file_t* file, byte *string, size_t bufsize ); // like a fgets, but can return EOF
|
|
|
|
|
int (*Seek)(file_t* file, fs_offset_t offset, int whence); // fseek, can seek in packfiles too
|
|
|
|
|
long (*Tell)(file_t* file); // like a ftell
|
|
|
|
|
|
|
|
|
|
//fs simply user interface
|
|
|
|
|
byte *(*LoadFile)(const char *path, long *filesize ); // load file into heap
|
|
|
|
|
bool (*WriteFile)(const char *filename, void *data, long len); // write file into disk
|
|
|
|
|
rgbdata_t *(*LoadImage)(const char *filename, char *data, int size ); // returned rgb data image
|
2007-06-29 22:00:00 +02:00
|
|
|
|
void (*FreeImage)( rgbdata_t *pack ); // release image buffer
|
2007-06-27 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
} filesystem_api_t;
|
|
|
|
|
|
2007-07-21 22:00:00 +02:00
|
|
|
|
typedef struct vfilesystem_api_s
|
|
|
|
|
{
|
|
|
|
|
//interface validator
|
|
|
|
|
size_t api_size; // must matched with sizeof(vfilesystem_api_t)
|
|
|
|
|
|
|
|
|
|
//file low-level operations
|
2007-07-22 22:00:00 +02:00
|
|
|
|
vfile_t *(*Create)(byte *buffer, size_t buffsize); // create virtual stream
|
2007-07-21 22:00:00 +02:00
|
|
|
|
vfile_t *(*Open)(file_t* file, const char* mode); // virtual fopen
|
|
|
|
|
int (*Close)(vfile_t* file); // free buffer or write dump
|
|
|
|
|
long (*Write)(vfile_t* file, const void* data, size_t datasize); // write into buffer
|
|
|
|
|
long (*Read)(vfile_t* file, void* buffer, size_t buffersize); // read from buffer
|
|
|
|
|
int (*Seek)(vfile_t* file, fs_offset_t offset, int whence); // fseek, can seek in packfiles too
|
|
|
|
|
long (*Tell)(vfile_t* file); // like a ftell
|
|
|
|
|
|
|
|
|
|
} vfilesystem_api_t;
|
2007-06-27 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
|
|
MEMORY MANAGER ENGINE INTERFACE
|
|
|
|
|
==============================================================================
|
|
|
|
|
*/
|
|
|
|
|
typedef struct memsystem_api_s
|
|
|
|
|
{
|
|
|
|
|
//interface validator
|
2007-06-29 22:00:00 +02:00
|
|
|
|
size_t api_size; // must matched with sizeof(memsystem_api_t)
|
2007-06-27 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
// memsystem base functions
|
|
|
|
|
byte *(*AllocPool)(const char *name, const char *file, int line); // alloc memory pool
|
|
|
|
|
void (*EmptyPool)(byte *poolptr, const char *file, int line); // drain memory pool
|
|
|
|
|
void (*FreePool)(byte **poolptr, const char *file, int line); // release memory pool
|
|
|
|
|
void (*CheckSentinelsGlobal)(const char *file, int line); // check memory sentinels
|
|
|
|
|
|
|
|
|
|
// user simply interface
|
|
|
|
|
void *(*Alloc)(byte *pool, size_t size, const char *file, int line); //same as malloc
|
|
|
|
|
void *(*Realloc)(byte *pool, void *mem, size_t size, const char *file, int line); //same as realloc
|
2007-06-29 22:00:00 +02:00
|
|
|
|
void (*Move)(void *dest, void *src, size_t size, const char *file, int line); //same as memmove
|
2007-06-27 22:00:00 +02:00
|
|
|
|
void (*Copy)(void *dest, void *src, size_t size, const char *file, int line); //same as memcpy
|
|
|
|
|
void (*Free)(void *data, const char *file, int line); //same as free
|
|
|
|
|
|
|
|
|
|
} memsystem_api_t;
|
|
|
|
|
|
2007-08-01 22:00:00 +02:00
|
|
|
|
/*
|
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
|
|
INFOSTRING MANAGER ENGINE INTERFACE
|
|
|
|
|
==============================================================================
|
|
|
|
|
*/
|
|
|
|
|
typedef struct infostring_api_s
|
|
|
|
|
{
|
|
|
|
|
//interface validator
|
|
|
|
|
size_t api_size; // must matched with sizeof(infostring_api_t)
|
|
|
|
|
|
|
|
|
|
void (*Print) (char *s);
|
|
|
|
|
bool (*Validate) (char *s);
|
|
|
|
|
void (*RemoveKey) (char *s, char *key);
|
|
|
|
|
char *(*ValueForKey) (char *s, char *key);
|
|
|
|
|
void (*SetValueForKey) (char *s, char *key, char *value);
|
|
|
|
|
|
|
|
|
|
} infostring_api_t;
|
|
|
|
|
|
|
|
|
|
|
2007-06-27 22:00:00 +02:00
|
|
|
|
/*
|
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
|
|
PARSE STUFF SYSTEM INTERFACE
|
|
|
|
|
==============================================================================
|
|
|
|
|
*/
|
|
|
|
|
typedef struct scriptsystem_api_s
|
|
|
|
|
{
|
|
|
|
|
//interface validator
|
2007-06-29 22:00:00 +02:00
|
|
|
|
size_t api_size; // must matched with sizeof(scriptsystem_api_t)
|
2007-06-27 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
//user interface
|
2007-06-29 22:00:00 +02:00
|
|
|
|
bool (*Load)( const char *name, char *buf, int size );// load script into stack from file or bufer
|
|
|
|
|
bool (*Include)( const char *name, char *buf, int size ); // include script from file or buffer
|
2007-06-27 22:00:00 +02:00
|
|
|
|
char *(*GetToken)( bool newline ); // get next token on a line or newline
|
|
|
|
|
char *(*Token)( void ); // just return current token
|
|
|
|
|
bool (*TryToken)( void ); // return 1 if have token on a line
|
|
|
|
|
void (*FreeToken)( void ); // free current token to may get it again
|
|
|
|
|
void (*SkipToken)( void ); // skip current token and jump into newline
|
|
|
|
|
bool (*MatchToken)( const char *match ); // compare current token with user keyword
|
2007-08-28 22:00:00 +02:00
|
|
|
|
char *(*ParseToken)(const char **data ); // parse token from char buffer
|
|
|
|
|
char *(*ParseWord)( const char **data ); // parse word from char buffer
|
2007-06-27 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
} scriptsystem_api_t;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
|
|
INTERNAL COMPILERS INTERFACE
|
|
|
|
|
==============================================================================
|
|
|
|
|
*/
|
2007-06-29 22:00:00 +02:00
|
|
|
|
typedef struct compilers_api_s
|
|
|
|
|
{
|
|
|
|
|
//interface validator
|
|
|
|
|
size_t api_size; // must matched with sizeof(compilers_api_t)
|
2007-06-27 22:00:00 +02:00
|
|
|
|
|
2007-06-29 22:00:00 +02:00
|
|
|
|
bool (*Studio)( byte *mempool, const char *name, byte parms ); // input name of qc-script
|
|
|
|
|
bool (*Sprite)( byte *mempool, const char *name, byte parms ); // input name of qc-script
|
|
|
|
|
bool (*PrepareBSP)( const char *dir, const char *name, byte params ); // compile map in gamedir
|
|
|
|
|
bool (*BSP)( void );
|
2007-08-28 22:00:00 +02:00
|
|
|
|
bool (*PrepareDAT)( const char *dir, const char *name, byte params ); // compile dat in gamedir
|
|
|
|
|
bool (*DAT)( void );
|
2007-06-29 22:00:00 +02:00
|
|
|
|
} compilers_api_t;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
|
|
STDIO SYSTEM INTERFACE
|
|
|
|
|
==============================================================================
|
|
|
|
|
*/
|
|
|
|
|
// that interface will never be expanded or extened. No need to check api_size anymore.
|
2007-07-28 22:00:00 +02:00
|
|
|
|
typedef struct stdinout_api_s
|
2007-06-27 22:00:00 +02:00
|
|
|
|
{
|
|
|
|
|
//interface validator
|
2007-09-03 22:00:00 +02:00
|
|
|
|
size_t api_size; // must matched with sizeof(stdinout_api_t)
|
2007-06-29 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
//base events
|
2007-09-03 22:00:00 +02:00
|
|
|
|
void (*print)( char *msg ); // basic text message
|
|
|
|
|
void (*printf)( char *msg, ... ); // normal text message
|
|
|
|
|
void (*dprintf)( int level, char *msg, ... ); // developer text message
|
|
|
|
|
void (*wprintf)( char *msg, ... ); // warning text message
|
|
|
|
|
void (*error)( char *msg, ... ); // abnormal termination with message
|
|
|
|
|
void (*exit)( void ); // normal silent termination
|
|
|
|
|
char *(*input)( void ); // system console input
|
2007-06-29 22:00:00 +02:00
|
|
|
|
|
2007-07-28 22:00:00 +02:00
|
|
|
|
} stdinout_api_t;
|
2007-06-29 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
|
|
CVAR SYSTEM INTERFACE
|
|
|
|
|
==============================================================================
|
|
|
|
|
*/
|
|
|
|
|
typedef struct cvar_api_s
|
|
|
|
|
{
|
|
|
|
|
//interface validator
|
|
|
|
|
size_t api_size; // must matched with sizeof(cvar_api_t)
|
|
|
|
|
|
|
|
|
|
//cvar_t *(*Register)(const char *name, const char *value, int flags, const char *description );
|
|
|
|
|
//cvar_t *(*SetString)(const char *name, char *value);
|
|
|
|
|
//void (*SetValue)(const char *name, float value);
|
|
|
|
|
|
|
|
|
|
} cvar_api_t;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
==============================================================================
|
|
|
|
|
|
2007-08-13 22:00:00 +02:00
|
|
|
|
LAUNCHER.DLL INTERFACE
|
|
|
|
|
==============================================================================
|
|
|
|
|
*/
|
|
|
|
|
typedef struct launcher_exp_s
|
|
|
|
|
{
|
|
|
|
|
//interface validator
|
|
|
|
|
int apiversion; // must matched with LAUNCHER_API_VERSION
|
|
|
|
|
size_t api_size; // must matched with sizeof(launcher_api_t)
|
|
|
|
|
|
|
|
|
|
void ( *Init ) ( char *funcname, int argc, char **argv ); // init host
|
|
|
|
|
void ( *Main ) ( void ); // host frame
|
|
|
|
|
void ( *Free ) ( void ); // close host
|
|
|
|
|
|
|
|
|
|
} launcher_exp_t;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
==============================================================================
|
|
|
|
|
|
2007-06-29 22:00:00 +02:00
|
|
|
|
PLATFORM.DLL INTERFACE
|
|
|
|
|
==============================================================================
|
|
|
|
|
*/
|
|
|
|
|
|
2007-07-28 22:00:00 +02:00
|
|
|
|
typedef struct platform_exp_s
|
2007-06-29 22:00:00 +02:00
|
|
|
|
{
|
|
|
|
|
//interface validator
|
|
|
|
|
int apiversion; // must matched with PLATFORM_API_VERSION
|
|
|
|
|
size_t api_size; // must matched with sizeof(platform_api_t)
|
2007-06-27 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
// initialize
|
2007-08-13 22:00:00 +02:00
|
|
|
|
bool (*Init)( int argc, char **argv ); // init all platform systems
|
2007-06-29 22:00:00 +02:00
|
|
|
|
void (*Shutdown)( void ); // shutdown all platform systems
|
2007-06-27 22:00:00 +02:00
|
|
|
|
|
2007-06-29 22:00:00 +02:00
|
|
|
|
//platform systems
|
|
|
|
|
filesystem_api_t Fs;
|
2007-07-21 22:00:00 +02:00
|
|
|
|
vfilesystem_api_t VFs;
|
2007-06-29 22:00:00 +02:00
|
|
|
|
memsystem_api_t Mem;
|
|
|
|
|
scriptsystem_api_t Script;
|
|
|
|
|
compilers_api_t Compile;
|
2007-08-01 22:00:00 +02:00
|
|
|
|
infostring_api_t Info;
|
2007-06-27 22:00:00 +02:00
|
|
|
|
|
2007-06-29 22:00:00 +02:00
|
|
|
|
// path initialization
|
|
|
|
|
void (*InitRootDir)( char *path ); // init custom rootdir
|
|
|
|
|
void (*LoadGameInfo)( const char *filename ); // gate game info from script file
|
|
|
|
|
void (*AddGameHierarchy)(const char *dir); // add base directory in search list
|
|
|
|
|
|
|
|
|
|
//misc utils
|
|
|
|
|
double (*DoubleTime)( void );
|
2007-08-17 22:00:00 +02:00
|
|
|
|
gameinfo_t (*GameInfo)( void );
|
2007-06-29 22:00:00 +02:00
|
|
|
|
|
2007-07-28 22:00:00 +02:00
|
|
|
|
} platform_exp_t;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
|
|
RENDERER.DLL INTERFACE
|
|
|
|
|
==============================================================================
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
typedef struct renderer_exp_s
|
|
|
|
|
{
|
|
|
|
|
//interface validator
|
2007-08-13 22:00:00 +02:00
|
|
|
|
int apiversion; // must matched with RENDERER_API_VERSION
|
|
|
|
|
size_t api_size; // must matched with sizeof(renderer_exp_t)
|
2007-07-28 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
// initialize
|
|
|
|
|
bool (*Init)( void *hInstance, void *WndProc ); // init all renderer systems
|
|
|
|
|
void (*Shutdown)( void ); // shutdown all renderer systems
|
|
|
|
|
|
|
|
|
|
void (*BeginRegistration) (char *map);
|
2007-08-19 22:00:00 +02:00
|
|
|
|
model_t *(*RegisterModel) (char *name);
|
|
|
|
|
image_t *(*RegisterSkin) (char *name);
|
|
|
|
|
image_t *(*RegisterPic) (char *name);
|
2007-07-28 22:00:00 +02:00
|
|
|
|
void (*SetSky) (char *name, float rotate, vec3_t axis);
|
|
|
|
|
void (*EndRegistration) (void);
|
|
|
|
|
|
|
|
|
|
void (*RenderFrame) (refdef_t *fd);
|
|
|
|
|
|
|
|
|
|
void (*DrawGetPicSize) (int *w, int *h, char *name); // will return 0 0 if not found
|
|
|
|
|
void (*DrawPic) (int x, int y, char *name);
|
|
|
|
|
void (*DrawStretchPic) (int x, int y, int w, int h, char *name);
|
2007-09-02 22:00:00 +02:00
|
|
|
|
void (*DrawChar) (float x, float y, int c);
|
2007-07-28 22:00:00 +02:00
|
|
|
|
void (*DrawString) (int x, int y, char *str);
|
|
|
|
|
void (*DrawTileClear) (int x, int y, int w, int h, char *name);
|
|
|
|
|
void (*DrawFill) (int x, int y, int w, int h, int c);
|
|
|
|
|
void (*DrawFadeScreen) (void);
|
|
|
|
|
|
|
|
|
|
// Draw images for cinematic rendering (which can have a different palette). Note that calls
|
|
|
|
|
void (*DrawStretchRaw) (int x, int y, int w, int h, int cols, int rows, byte *data);
|
|
|
|
|
|
|
|
|
|
// video mode and refresh state management entry points
|
|
|
|
|
void (*CinematicSetPalette)( const byte *palette); // NULL = game palette
|
|
|
|
|
void (*BeginFrame)( float camera_separation );
|
|
|
|
|
void (*EndFrame) (void);
|
|
|
|
|
|
|
|
|
|
void (*AppActivate)( bool activate ); // ??
|
|
|
|
|
|
|
|
|
|
} renderer_exp_t;
|
|
|
|
|
|
|
|
|
|
typedef struct renderer_imp_s
|
|
|
|
|
{
|
|
|
|
|
//shared xash systems
|
|
|
|
|
filesystem_api_t Fs;
|
|
|
|
|
vfilesystem_api_t VFs;
|
|
|
|
|
memsystem_api_t Mem;
|
|
|
|
|
scriptsystem_api_t Script;
|
|
|
|
|
compilers_api_t Compile;
|
|
|
|
|
stdinout_api_t Stdio;
|
|
|
|
|
|
|
|
|
|
void (*Cmd_AddCommand) (char *name, void(*cmd)(void));
|
|
|
|
|
void (*Cmd_RemoveCommand) (char *name);
|
|
|
|
|
int (*Cmd_Argc) (void);
|
|
|
|
|
char *(*Cmd_Argv) (int i);
|
|
|
|
|
void (*Cmd_ExecuteText) (int exec_when, char *text);
|
|
|
|
|
|
|
|
|
|
//client fundamental callbacks
|
|
|
|
|
void (*StudioEvent)( mstudioevent_t *event, entity_t *ent );
|
|
|
|
|
|
|
|
|
|
// gamedir will be the current directory that generated
|
|
|
|
|
// files should be stored to, ie: "f:\quake\id1"
|
|
|
|
|
char *(*gamedir) ( void );
|
|
|
|
|
char *(*title) ( void );
|
|
|
|
|
|
|
|
|
|
cvar_t *(*Cvar_Get) (char *name, char *value, int flags);
|
|
|
|
|
cvar_t *(*Cvar_Set)( char *name, char *value );
|
|
|
|
|
void (*Cvar_SetValue)( char *name, float value );
|
|
|
|
|
|
|
|
|
|
bool (*Vid_GetModeInfo)( int *width, int *height, int mode );
|
|
|
|
|
void (*Vid_MenuInit)( void );
|
|
|
|
|
void (*Vid_NewWindow)( int width, int height );
|
|
|
|
|
|
|
|
|
|
} renderer_imp_t;
|
|
|
|
|
|
2007-06-29 22:00:00 +02:00
|
|
|
|
|
2007-07-28 22:00:00 +02:00
|
|
|
|
// this is the only function actually exported at the linker level
|
2007-08-17 22:00:00 +02:00
|
|
|
|
typedef renderer_exp_t *(*renderer_t)( renderer_imp_t );
|
|
|
|
|
typedef platform_exp_t *(*platform_t)( stdinout_api_t );
|
|
|
|
|
typedef launcher_exp_t *(*launcher_t)( stdinout_api_t );
|
2007-06-27 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
#endif//REF_SYSTEM_H
|