From d309df4ce4d8ad0ed995a8e1c4267412a7782021 Mon Sep 17 00:00:00 2001 From: xolatile Date: Mon, 4 Aug 2025 22:53:42 +0200 Subject: Bunch of small changes... --- src/shared/iengine.h | 318 +++++++++++++++++++++++++-------------------------- 1 file changed, 157 insertions(+), 161 deletions(-) (limited to 'src/shared/iengine.h') 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=0 && o.y=0 && o.z=0 && o.x=0 && o.y=0 && o.z