diff options
Diffstat (limited to 'src/shared/iengine.h')
| -rw-r--r-- | src/shared/iengine.h | 318 |
1 files changed, 157 insertions, 161 deletions
diff --git a/src/shared/iengine.h b/src/shared/iengine.h index 80bc9c5..bc2f7a9 100644 --- a/src/shared/iengine.h +++ b/src/shared/iengine.h @@ -1,38 +1,38 @@ // the interface the game uses to access the engine -extern int curtime; // current frame time -extern int lastmillis; // last time -extern int elapsedtime; // elapsed frame time -extern int totalmillis; // total elapsed time +extern int curtime; // current frame time +extern int lastmillis; // last time +extern int elapsedtime; // elapsed frame time +extern int totalmillis; // total elapsed time extern uint totalsecs; extern int gamespeed, paused; enum { - MATF_INDEX_SHIFT = 0, - MATF_VOLUME_SHIFT = 2, - MATF_CLIP_SHIFT = 5, - MATF_FLAG_SHIFT = 8, - - MATF_INDEX = 3 << MATF_INDEX_SHIFT, - MATF_VOLUME = 7 << MATF_VOLUME_SHIFT, - MATF_CLIP = 7 << MATF_CLIP_SHIFT, - MATF_FLAGS = 0xFF << MATF_FLAG_SHIFT + MATF_INDEX_SHIFT = 0, + MATF_VOLUME_SHIFT = 2, + MATF_CLIP_SHIFT = 5, + MATF_FLAG_SHIFT = 8, + + MATF_INDEX = 3 << MATF_INDEX_SHIFT, + MATF_VOLUME = 7 << MATF_VOLUME_SHIFT, + MATF_CLIP = 7 << MATF_CLIP_SHIFT, + MATF_FLAGS = 0xFF << MATF_FLAG_SHIFT }; enum // cube empty-space materials { - MAT_AIR = 0, // the default, fill the empty space with air - MAT_WATER = 1 << MATF_VOLUME_SHIFT, // fill with water, showing waves at the surface - MAT_LAVA = 2 << MATF_VOLUME_SHIFT, // fill with lava - MAT_GLASS = 3 << MATF_VOLUME_SHIFT, // behaves like clip but is blended blueish + MAT_AIR = 0, // the default, fill the empty space with air + MAT_WATER = 1 << MATF_VOLUME_SHIFT, // fill with water, showing waves at the surface + MAT_LAVA = 2 << MATF_VOLUME_SHIFT, // fill with lava + MAT_GLASS = 3 << MATF_VOLUME_SHIFT, // behaves like clip but is blended blueish - MAT_NOCLIP = 1 << MATF_CLIP_SHIFT, // collisions always treat cube as empty - MAT_CLIP = 2 << MATF_CLIP_SHIFT, // collisions always treat cube as solid - MAT_GAMECLIP = 3 << MATF_CLIP_SHIFT, // game specific clip material + MAT_NOCLIP = 1 << MATF_CLIP_SHIFT, // collisions always treat cube as empty + MAT_CLIP = 2 << MATF_CLIP_SHIFT, // collisions always treat cube as solid + MAT_GAMECLIP = 3 << MATF_CLIP_SHIFT, // game specific clip material - MAT_DEATH = 1 << MATF_FLAG_SHIFT, // force player suicide - MAT_ALPHA = 4 << MATF_FLAG_SHIFT // alpha blended + MAT_DEATH = 1 << MATF_FLAG_SHIFT, // force player suicide + MAT_ALPHA = 4 << MATF_FLAG_SHIFT // alpha blended }; #define isliquid(mat) ((mat)==MAT_WATER || (mat)==MAT_LAVA) @@ -45,7 +45,7 @@ extern entity *brightestlight(const vec &target, const vec &dir); enum { RAY_BB = 1, RAY_POLY = 3, RAY_ALPHAPOLY = 7, RAY_ENTS = 9, RAY_CLIPMAT = 16, RAY_SKIPFIRST = 32, RAY_EDITMAT = 64, RAY_SHADOW = 128, RAY_PASS = 256, RAY_SKIPSKY = 512, RAY_SKYTEX = 1024 }; -extern float raycube (const vec &o, const vec &ray, float radius = 0, int mode = RAY_CLIPMAT, int size = 0, extentity *t = 0); +extern float raycube (const vec &o, const vec &ray, float radius = 0, int mode = RAY_CLIPMAT, int size = 0, extentity *t = 0); extern float raycubepos(const vec &o, const vec &ray, vec &hit, float radius = 0, int mode = RAY_CLIPMAT, int size = 0); extern float rayfloor (const vec &o, vec &floor, int mode = 0, float radius = 0); extern bool raycubelos(const vec &o, const vec &dest, vec &hitpos); @@ -61,27 +61,27 @@ enum { EDIT_FACE = 0, EDIT_TEX, EDIT_MAT, EDIT_FLIP, EDIT_COPY, EDIT_PASTE, EDIT struct selinfo { - int corner; - int cx, cxs, cy, cys; - ivec o, s; - int grid, orient; - selinfo() : corner(0), cx(0), cxs(0), cy(0), cys(0), o(0, 0, 0), s(0, 0, 0), grid(8), orient(0) {} - int size() const { return s.x*s.y*s.z; } - int us(int d) const { return s[d]*grid; } - bool operator==(const selinfo &sel) const { return o==sel.o && s==sel.s && grid==sel.grid && orient==sel.orient; } - bool validate() - { - extern int worldsize; - if(grid <= 0 || grid >= worldsize) return false; - if(o.x >= worldsize || o.y >= worldsize || o.z >= worldsize) return false; - if(o.x < 0) { s.x -= (grid - 1 - o.x)/grid; o.x = 0; } - if(o.y < 0) { s.y -= (grid - 1 - o.y)/grid; o.y = 0; } - if(o.z < 0) { s.z -= (grid - 1 - o.z)/grid; o.z = 0; } - s.x = clamp(s.x, 0, (worldsize - o.x)/grid); - s.y = clamp(s.y, 0, (worldsize - o.y)/grid); - s.z = clamp(s.z, 0, (worldsize - o.z)/grid); - return s.x > 0 && s.y > 0 && s.z > 0; - } + int corner; + int cx, cxs, cy, cys; + ivec o, s; + int grid, orient; + selinfo() : corner(0), cx(0), cxs(0), cy(0), cys(0), o(0, 0, 0), s(0, 0, 0), grid(8), orient(0) {} + int size() const { return s.x*s.y*s.z; } + int us(int d) const { return s[d]*grid; } + bool operator==(const selinfo &sel) const { return o==sel.o && s==sel.s && grid==sel.grid && orient==sel.orient; } + bool validate() + { + extern int worldsize; + if(grid <= 0 || grid >= worldsize) return false; + if(o.x >= worldsize || o.y >= worldsize || o.z >= worldsize) return false; + if(o.x < 0) { s.x -= (grid - 1 - o.x)/grid; o.x = 0; } + if(o.y < 0) { s.y -= (grid - 1 - o.y)/grid; o.y = 0; } + if(o.z < 0) { s.z -= (grid - 1 - o.z)/grid; o.z = 0; } + s.x = clamp(s.x, 0, (worldsize - o.x)/grid); + s.y = clamp(s.y, 0, (worldsize - o.y)/grid); + s.z = clamp(s.z, 0, (worldsize - o.z)/grid); + return s.x > 0 && s.y > 0 && s.z > 0; + } }; struct editinfo; @@ -187,16 +187,16 @@ static inline void loopiter(ident *id, identstack &stack, const char *s) { tagva enum { - CON_INFO = 1<<0, - CON_WARN = 1<<1, - CON_ERROR = 1<<2, - CON_DEBUG = 1<<3, - CON_INIT = 1<<4, - CON_ECHO = 1<<5, - - CON_FLAGS = 0xFFFF, - CON_TAG_SHIFT = 16, - CON_TAG_MASK = (0x7FFF << CON_TAG_SHIFT) + CON_INFO = 1<<0, + CON_WARN = 1<<1, + CON_ERROR = 1<<2, + CON_DEBUG = 1<<3, + CON_INIT = 1<<4, + CON_ECHO = 1<<5, + + CON_FLAGS = 0xFFFF, + CON_TAG_SHIFT = 16, + CON_TAG_MASK = (0x7FFF << CON_TAG_SHIFT) }; extern void conoutf(const char *s, ...) PRINTFARGS(1, 2); @@ -221,14 +221,14 @@ extern int lookupmaterial(const vec &o); static inline bool insideworld(const vec &o) { - extern int worldsize; - return o.x>=0 && o.x<worldsize && o.y>=0 && o.y<worldsize && o.z>=0 && o.z<worldsize; + extern int worldsize; + return o.x>=0 && o.x<worldsize && o.y>=0 && o.y<worldsize && o.z>=0 && o.z<worldsize; } static inline bool insideworld(const ivec &o) { - extern int worldsize; - return uint(o.x)<uint(worldsize) && uint(o.y)<uint(worldsize) && uint(o.z)<uint(worldsize); + extern int worldsize; + return uint(o.x)<uint(worldsize) && uint(o.y)<uint(worldsize) && uint(o.z)<uint(worldsize); } // world @@ -263,31 +263,31 @@ extern void text_posf(const char *str, int cursor, float &cx, float &cy, int max static inline int text_width(const char *str) { - return int(ceil(text_widthf(str))); + return int(ceil(text_widthf(str))); } static inline void text_bounds(const char *str, int &width, int &height, int maxwidth = -1) { - float widthf, heightf; - text_boundsf(str, widthf, heightf, maxwidth); - width = int(ceil(widthf)); - height = int(ceil(heightf)); + float widthf, heightf; + text_boundsf(str, widthf, heightf, maxwidth); + width = int(ceil(widthf)); + height = int(ceil(heightf)); } static inline void text_pos(const char *str, int cursor, int &cx, int &cy, int maxwidth) { - float cxf, cyf; - text_posf(str, cursor, cxf, cyf, maxwidth); - cx = int(cxf); - cy = int(cyf); + float cxf, cyf; + text_posf(str, cursor, cxf, cyf, maxwidth); + cx = int(cxf); + cy = int(cyf); } // renderva enum { - DL_SHRINK = 1<<0, - DL_EXPAND = 1<<1, - DL_FLASH = 1<<2 + DL_SHRINK = 1<<0, + DL_EXPAND = 1<<1, + DL_FLASH = 1<<2 }; extern void adddynlight(const vec &o, float radius, const vec &color, int fade = 0, int peak = 0, int flags = 0, float initradius = 0, const vec &initcolor = vec(0, 0, 0), physent *owner = NULL); @@ -303,9 +303,7 @@ extern void disablezoom(); extern vec calcavatarpos(const vec &pos, float dist); extern vec calcmodelpreviewpos(const vec &radius, float &yaw); -extern void damageblend(int n); extern void damagecompass(int n, const vec &loc); -extern void cleardamagescreen(); extern matrix4 hudmatrix; extern void resethudmatrix(); @@ -318,23 +316,23 @@ extern void pushhudtranslate(float tx, float ty, float sx = 0, float sy = 0); // renderparticles enum { - PART_BLOOD = 0, - PART_WATER, - PART_SMOKE, - PART_STEAM, - PART_FLAME, - PART_FIREBALL1, PART_FIREBALL2, PART_FIREBALL3, - PART_STREAK, PART_LIGHTNING, - PART_EXPLOSION, PART_EXPLOSION_BLUE, - PART_SPARK, PART_EDIT, - PART_SNOW, - PART_MUZZLE_FLASH1, PART_MUZZLE_FLASH2, PART_MUZZLE_FLASH3, - PART_HUD_ICON, - PART_HUD_ICON_GREY, - PART_TEXT, - PART_TEXT_ICON, - PART_METER, PART_METER_VS, - PART_LENS_FLARE + PART_BLOOD = 0, + PART_WATER, + PART_SMOKE, + PART_STEAM, + PART_FLAME, + PART_FIREBALL1, PART_FIREBALL2, PART_FIREBALL3, + PART_STREAK, PART_LIGHTNING, + PART_EXPLOSION, PART_EXPLOSION_BLUE, + PART_SPARK, PART_EDIT, + PART_SNOW, + PART_MUZZLE_FLASH1, PART_MUZZLE_FLASH2, PART_MUZZLE_FLASH3, + PART_HUD_ICON, + PART_HUD_ICON_GREY, + PART_TEXT, + PART_TEXT_ICON, + PART_METER, PART_METER_VS, + PART_LENS_FLARE }; extern bool canaddparticles(); @@ -354,9 +352,9 @@ extern void removetrackedparticles(physent *owner = NULL); // decal enum { - DECAL_SCORCH = 0, - DECAL_BLOOD, - DECAL_BULLET + DECAL_SCORCH = 0, + DECAL_BLOOD, + DECAL_BULLET }; extern void adddecal(int type, const vec ¢er, const vec &surface, float radius, const bvec &color = bvec(0xFF, 0xFF, 0xFF), int info = 0); @@ -385,11 +383,9 @@ extern bool overlapsdynent(const vec &o, float radius); extern bool movecamera(physent *pl, const vec &dir, float dist, float stepdist); extern void physicsframe(); extern void dropenttofloor(entity *e); -extern bool droptofloor(vec &o, float radius, float height); extern void vecfromyawpitch(float yaw, float pitch, int move, int strafe, vec &m); extern void vectoyawpitch(const vec &v, float &yaw, float &pitch); -extern bool moveplatform(physent *p, const vec &dir); extern void updatephysstate(physent *d); extern void cleardynentcache(); extern void updatedynentcache(physent *d); @@ -399,9 +395,9 @@ extern void findplayerspawn(dynent *d, int forceent = -1, int tag = 0); // sound enum { - SND_MAP = 1<<0, - SND_NO_ALT = 1<<1, - SND_USE_ALT = 1<<2 + SND_MAP = 1<<0, + SND_NO_ALT = 1<<1, + SND_USE_ALT = 1<<2 }; extern int playsound(int n, const vec *loc = NULL, extentity *ent = NULL, int flags = 0, int loops = 0, int fade = 0, int chanid = -1, int radius = 0, int expire = -1); @@ -418,14 +414,14 @@ enum { MDL_CULL_VFC = 1<<0, MDL_CULL_DIST = 1<<1, MDL_CULL_OCCLUDED = 1<<2, MDL_ struct model; struct modelattach { - const char *tag, *name; - int anim, basetime; - vec *pos; - model *m; - - modelattach() : tag(NULL), name(NULL), anim(-1), basetime(0), pos(NULL), m(NULL) {} - modelattach(const char *tag, const char *name, int anim = -1, int basetime = 0) : tag(tag), name(name), anim(anim), basetime(basetime), pos(NULL), m(NULL) {} - modelattach(const char *tag, vec *pos) : tag(tag), name(NULL), anim(-1), basetime(0), pos(pos), m(NULL) {} + const char *tag, *name; + int anim, basetime; + vec *pos; + model *m; + + modelattach() : tag(NULL), name(NULL), anim(-1), basetime(0), pos(NULL), m(NULL) {} + modelattach(const char *tag, const char *name, int anim = -1, int basetime = 0) : tag(tag), name(name), anim(anim), basetime(basetime), pos(NULL), m(NULL) {} + modelattach(const char *tag, vec *pos) : tag(tag), name(NULL), anim(-1), basetime(0), pos(pos), m(NULL) {} }; extern void startmodelbatches(); @@ -447,8 +443,8 @@ extern void moveragdoll(dynent *d); extern void cleanragdoll(dynent *d); // server -#define MAXCLIENTS 128 // DO NOT set this any higher -#define MAXTRANS 5000 // max amount of data to swallow in 1 go +#define MAXCLIENTS 128 // DO NOT set this any higher +#define MAXTRANS 5000 // max amount of data to swallow in 1 go extern int maxclients; @@ -506,70 +502,70 @@ enum { EDITORFOCUSED = 1, EDITORUSED, EDITORFOREVER }; struct g3d_gui { - virtual ~g3d_gui() {} - - virtual void start(int starttime, float basescale, int *tab = NULL, bool allowinput = true) = 0; - virtual void end() = 0; - - virtual int text(const char *text, int color, const char *icon = NULL) = 0; - int textf(const char *fmt, int color, const char *icon = NULL, ...) PRINTFARGS(2, 5) - { - defvformatstring(str, icon, fmt); - return text(str, color, icon); - } - virtual int button(const char *text, int color, const char *icon = NULL) = 0; - int buttonf(const char *fmt, int color, const char *icon = NULL, ...) PRINTFARGS(2, 5) - { - defvformatstring(str, icon, fmt); - return button(str, color, icon); - } - virtual int title(const char *text, int color, const char *icon = NULL) = 0; - int titlef(const char *fmt, int color, const char *icon = NULL, ...) PRINTFARGS(2, 5) - { - defvformatstring(str, icon, fmt); - return title(str, color, icon); - } - virtual void background(int color, int parentw = 0, int parenth = 0) = 0; - - virtual void pushlist() {} - virtual void poplist() {} - - virtual bool allowautotab(bool on) = 0; - virtual bool shouldtab() = 0; - virtual void tab(const char *name = NULL, int color = 0) = 0; - virtual int image(Texture *t, float scale, const char *overlaid = NULL) = 0; - virtual int texture(VSlot &vslot, float scale, bool overlaid = true) = 0; - virtual int playerpreview(int model, int team, int weap, float scale, const char *overlaid = NULL) = 0; - virtual int modelpreview(const char *name, int anim, float scale, const char *overlaid = NULL, bool throttle = false) = 0; - virtual int prefabpreview(const char *prefab, const vec &color, float scale, const char *overlaid = NULL, bool throttle = false) = 0; - virtual void slider(int &val, int vmin, int vmax, int color, const char *label = NULL) = 0; - virtual void separator() = 0; - virtual void progress(float percent) = 0; - virtual void strut(float size) = 0; - virtual void space(float size) = 0; - virtual void spring(int weight = 1) = 0; - virtual void column(int col) = 0; - virtual char *keyfield(const char *name, int color, int length, int height = 0, const char *initval = NULL, int initmode = EDITORFOCUSED) = 0; - virtual char *field(const char *name, int color, int length, int height = 0, const char *initval = NULL, int initmode = EDITORFOCUSED) = 0; - virtual void textbox(const char *text, int width, int height, int color = 0xFFFFFF) = 0; - virtual bool mergehits(bool on) = 0; + virtual ~g3d_gui() {} + + virtual void start(int starttime, float basescale, int *tab = NULL, bool allowinput = true) = 0; + virtual void end() = 0; + + virtual int text(const char *text, int color, const char *icon = NULL) = 0; + int textf(const char *fmt, int color, const char *icon = NULL, ...) PRINTFARGS(2, 5) + { + defvformatstring(str, icon, fmt); + return text(str, color, icon); + } + virtual int button(const char *text, int color, const char *icon = NULL) = 0; + int buttonf(const char *fmt, int color, const char *icon = NULL, ...) PRINTFARGS(2, 5) + { + defvformatstring(str, icon, fmt); + return button(str, color, icon); + } + virtual int title(const char *text, int color, const char *icon = NULL) = 0; + int titlef(const char *fmt, int color, const char *icon = NULL, ...) PRINTFARGS(2, 5) + { + defvformatstring(str, icon, fmt); + return title(str, color, icon); + } + virtual void background(int color, int parentw = 0, int parenth = 0) = 0; + + virtual void pushlist() {} + virtual void poplist() {} + + virtual bool allowautotab(bool on) = 0; + virtual bool shouldtab() = 0; + virtual void tab(const char *name = NULL, int color = 0) = 0; + virtual int image(Texture *t, float scale, const char *overlaid = NULL) = 0; + virtual int texture(VSlot &vslot, float scale, bool overlaid = true) = 0; + virtual int playerpreview(int model, int team, int weap, float scale, const char *overlaid = NULL) = 0; + virtual int modelpreview(const char *name, int anim, float scale, const char *overlaid = NULL, bool throttle = false) = 0; + virtual int prefabpreview(const char *prefab, const vec &color, float scale, const char *overlaid = NULL, bool throttle = false) = 0; + virtual void slider(int &val, int vmin, int vmax, int color, const char *label = NULL) = 0; + virtual void separator() = 0; + virtual void progress(float percent) = 0; + virtual void strut(float size) = 0; + virtual void space(float size) = 0; + virtual void spring(int weight = 1) = 0; + virtual void column(int col) = 0; + virtual char *keyfield(const char *name, int color, int length, int height = 0, const char *initval = NULL, int initmode = EDITORFOCUSED) = 0; + virtual char *field(const char *name, int color, int length, int height = 0, const char *initval = NULL, int initmode = EDITORFOCUSED) = 0; + virtual void textbox(const char *text, int width, int height, int color = 0xFFFFFF) = 0; + virtual bool mergehits(bool on) = 0; }; struct g3d_callback { - virtual ~g3d_callback() {} + virtual ~g3d_callback() {} - int starttime() { return totalmillis; } + int starttime() { return totalmillis; } - virtual void gui(g3d_gui &g, bool firstpass) = 0; + virtual void gui(g3d_gui &g, bool firstpass) = 0; }; enum { - GUI_2D = 1<<0, - GUI_FOLLOW = 1<<1, - GUI_FORCE_2D = 1<<2, - GUI_BOTTOM = 1<<3 + GUI_2D = 1<<0, + GUI_FOLLOW = 1<<1, + GUI_FORCE_2D = 1<<2, + GUI_BOTTOM = 1<<3 }; extern void g3d_addgui(g3d_callback *cb, vec &origin, int flags = 0); |
