// 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 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 }; 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_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_NOGI = 2 << MATF_FLAG_SHIFT, // disable global illumination MAT_ALPHA = 4 << MATF_FLAG_SHIFT // alpha blended }; #define isliquid(mat) ((mat)==MAT_WATER || (mat)==MAT_LAVA) #define isclipped(mat) ((mat)==MAT_GLASS) #define isdeadly(mat) ((mat)==MAT_LAVA) extern void lightent(extentity &e, float height = 8.0f); extern void lightreaching(const vec &target, vec &color, vec &dir, bool fast = false, extentity *e = 0, float minambient = 0.4f); 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 }; 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); extern int thirdperson; extern bool isthirdperson(); // octaedit enum { EDIT_FACE = 0, EDIT_TEX, EDIT_MAT, EDIT_FLIP, EDIT_COPY, EDIT_PASTE, EDIT_ROTATE, EDIT_REPLACE, EDIT_DELCUBE, EDIT_CALCLIGHT, EDIT_REMIP, EDIT_VSLOT, EDIT_UNDO, EDIT_REDO }; struct selinfo; struct editinfo; extern editinfo *localedit; extern bool editmode; extern int shouldpacktex(int index); extern bool packeditinfo(editinfo *e, int &inlen, uchar *&outbuf, int &outlen); extern bool unpackeditinfo(editinfo *&e, const uchar *inbuf, int inlen, int outlen); extern void freeeditinfo(editinfo *&e); extern void pruneundos(int maxremain = 0); extern bool packundo(int op, int &inlen, uchar *&outbuf, int &outlen); extern bool unpackundo(const uchar *inbuf, int inlen, int outlen); extern bool noedit(bool view = false, bool msg = true); extern void toggleedit(bool force = true); extern void mpeditface(int dir, int mode, selinfo &sel, bool local); extern void mpedittex(int tex, int allfaces, selinfo &sel, bool local); extern bool mpedittex(int tex, int allfaces, selinfo &sel, ucharbuf &buf); extern void mpeditmat(int matid, int filter, selinfo &sel, bool local); extern void mpflip(selinfo &sel, bool local); extern void mpcopy(editinfo *&e, selinfo &sel, bool local); extern void mppaste(editinfo *&e, selinfo &sel, bool local); extern void mprotate(int cw, selinfo &sel, bool local); extern void mpreplacetex(int oldtex, int newtex, bool insel, selinfo &sel, bool local); extern bool mpreplacetex(int oldtex, int newtex, bool insel, selinfo &sel, ucharbuf &buf); extern void mpdelcube(selinfo &sel, bool local); extern void mpremip(bool local); extern bool mpeditvslot(int delta, int allfaces, selinfo &sel, ucharbuf &buf); extern void mpcalclight(bool local); // command extern int variable(const char *name, int min, int cur, int max, int *storage, identfun fun, int flags); extern float fvariable(const char *name, float min, float cur, float max, float *storage, identfun fun, int flags); extern char *svariable(const char *name, const char *cur, char **storage, identfun fun, int flags); extern void setvar(const char *name, int i, bool dofunc = true, bool doclamp = true); extern void setfvar(const char *name, float f, bool dofunc = true, bool doclamp = true); extern void setsvar(const char *name, const char *str, bool dofunc = true); extern void setvarchecked(ident *id, int val); extern void setfvarchecked(ident *id, float val); extern void setsvarchecked(ident *id, const char *val); extern void touchvar(const char *name); extern int getvar(const char *name); extern int getvarmin(const char *name); extern int getvarmax(const char *name); extern bool identexists(const char *name); extern ident *getident(const char *name); extern ident *newident(const char *name, int flags = 0); extern ident *readident(const char *name); extern ident *writeident(const char *name, int flags = 0); extern bool addcommand(const char *name, identfun fun, const char *narg, int type = ID_COMMAND); extern uint *compilecode(const char *p); extern void keepcode(uint *p); extern void freecode(uint *p); extern void executeret(const uint *code, tagval &result = *commandret); extern void executeret(const char *p, tagval &result = *commandret); extern void executeret(ident *id, tagval *args, int numargs, bool lookup = false, tagval &result = *commandret); extern char *executestr(const uint *code); extern char *executestr(const char *p); extern char *executestr(ident *id, tagval *args, int numargs, bool lookup = false); extern char *execidentstr(const char *name, bool lookup = false); extern int execute(const uint *code); extern int execute(const char *p); extern int execute(ident *id, tagval *args, int numargs, bool lookup = false); extern int execident(const char *name, int noid = 0, bool lookup = false); extern float executefloat(const uint *code); extern float executefloat(const char *p); extern float executefloat(ident *id, tagval *args, int numargs, bool lookup = false); extern float execidentfloat(const char *name, float noid = 0, bool lookup = false); extern bool executebool(const uint *code); extern bool executebool(const char *p); extern bool executebool(ident *id, tagval *args, int numargs, bool lookup = false); extern bool execidentbool(const char *name, bool noid = false, bool lookup = false); extern bool execfile(const char *cfgfile, bool msg = true); extern void alias(const char *name, const char *action); extern void alias(const char *name, tagval &v); extern const char *getalias(const char *name); extern const char *escapestring(const char *s); extern const char *escapeid(const char *s); static inline const char *escapeid(ident &id) { return escapeid(id.name); } extern bool validateblock(const char *s); extern void explodelist(const char *s, vector &elems, int limit = -1); extern char *indexlist(const char *s, int pos); extern int listlen(const char *s); extern void printvar(ident *id); extern void printvar(ident *id, int i); extern void printfvar(ident *id, float f); extern void printsvar(ident *id, const char *s); extern int clampvar(ident *id, int i, int minval, int maxval); extern float clampfvar(ident *id, float f, float minval, float maxval); extern void loopiter(ident *id, identstack &stack, const tagval &v); extern void loopend(ident *id, identstack &stack); #define loopstart(id, stack) if((id)->type != ID_ALIAS) return; identstack stack; static inline void loopiter(ident *id, identstack &stack, int i) { tagval v; v.setint(i); loopiter(id, stack, v); } static inline void loopiter(ident *id, identstack &stack, float f) { tagval v; v.setfloat(f); loopiter(id, stack, v); } static inline void loopiter(ident *id, identstack &stack, const char *s) { tagval v; v.setstr(newstring(s)); loopiter(id, stack, v); } // console 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 }; extern void conoutf(const char *s, ...) PRINTFARGS(1, 2); extern void conoutf(int type, const char *s, ...) PRINTFARGS(2, 3); extern void conoutfv(int type, const char *fmt, va_list args); // octa 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