1 // the interface the game uses to access the engine
3 extern void lightent(extentity
&e
, float height
= 8.0f
);
4 extern void lightreaching(const vec
&target
, vec
&color
, vec
&dir
, extentity
*e
= 0, float ambient
= 0.4f
);
5 extern entity
*brightestlight(const vec
&target
, const vec
&dir
);
7 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 };
9 extern float raycube (const vec
&o
, const vec
&ray
, float radius
= 0, int mode
= RAY_CLIPMAT
, int size
= 0, extentity
*t
= 0);
10 extern float raycubepos(const vec
&o
, vec
&ray
, vec
&hit
, float radius
= 0, int mode
= RAY_CLIPMAT
, int size
= 0);
11 extern float rayfloor (const vec
&o
, vec
&floor
, int mode
= 0, float radius
= 0);
12 extern bool raycubelos(vec
&o
, vec
&dest
, vec
&hitpos
);
14 extern bool isthirdperson();
16 extern void settexture(const char *name
, bool clamp
= false);
20 enum { EDIT_FACE
= 0, EDIT_TEX
, EDIT_MAT
, EDIT_FLIP
, EDIT_COPY
, EDIT_PASTE
, EDIT_ROTATE
, EDIT_REPLACE
, EDIT_DELCUBE
, EDIT_REMIP
};
28 int size() const { return s
.x
*s
.y
*s
.z
; }
29 int us(int d
) const { return s
[d
]*grid
; }
30 bool operator==(const selinfo
&sel
) const { return o
==sel
.o
&& s
==sel
.s
&& grid
==sel
.grid
&& orient
==sel
.orient
; }
37 extern void freeeditinfo(editinfo
*&e
);
38 extern void cursorupdate();
39 extern void pruneundos(int maxremain
= 0);
40 extern bool noedit(bool view
= false);
41 extern void toggleedit();
42 extern void mpeditface(int dir
, int mode
, selinfo
&sel
, bool local
);
43 extern void mpedittex(int tex
, int allfaces
, selinfo
&sel
, bool local
);
44 extern void mpeditmat(int matid
, selinfo
&sel
, bool local
);
45 extern void mpflip(selinfo
&sel
, bool local
);
46 extern void mpcopy(editinfo
*&e
, selinfo
&sel
, bool local
);
47 extern void mppaste(editinfo
*&e
, selinfo
&sel
, bool local
);
48 extern void mprotate(int cw
, selinfo
&sel
, bool local
);
49 extern void mpreplacetex(int oldtex
, int newtex
, selinfo
&sel
, bool local
);
50 extern void mpdelcube(selinfo
&sel
, bool local
);
51 extern void mpremip(bool local
);
54 extern int variable(const char *name
, int min
, int cur
, int max
, int *storage
, void (*fun
)(), bool persist
);
55 extern void setvar(const char *name
, int i
, bool dofunc
= false);
56 extern int getvar(const char *name
);
57 extern int getvarmin(const char *name
);
58 extern int getvarmax(const char *name
);
59 extern bool identexists(const char *name
);
60 extern ident
*getident(const char *name
);
61 extern bool addcommand(const char *name
, void (*fun
)(), const char *narg
);
62 extern int execute(const char *p
);
63 extern char *executeret(const char *p
);
64 extern void exec(const char *cfgfile
);
65 extern bool execfile(const char *cfgfile
);
66 extern void alias(const char *name
, const char *action
);
67 extern const char *getalias(const char *name
);
70 extern void keypress(int code
, bool isdown
, int cooked
);
71 extern void rendercommand(int x
, int y
);
72 extern int renderconsole(int w
, int h
);
73 extern void conoutf(const char *s
, ...);
74 extern char *getcurcommand();
75 extern void resetcomplete();
76 extern void complete(char *s
);
79 extern vec
menuinfrontofplayer();
80 extern void newgui(char *name
, char *contents
);
81 extern void showgui(char *name
);
84 extern bool emptymap(int factor
, bool force
);
85 extern bool enlargemap(bool force
);
86 extern int findentity(int type
, int index
= 0);
87 extern void mpeditent(int i
, const vec
&o
, int type
, int attr1
, int attr2
, int attr3
, int attr4
, bool local
);
88 extern int getworldsize();
89 extern int getmapversion();
90 extern bool insideworld(const vec
&o
);
91 extern void resettriggers();
92 extern void checktriggers();
97 extern void fatal(const char *s
, ...);
98 extern void keyrepeat(bool on
);
99 extern void registergame(const char *name
, igame
*ig
);
101 #define REGISTERGAME(t, n, c, s) struct t : igame { t() { registergame(n, this); } igameclient *newclient() { return c; } igameserver *newserver() { return s; } } reg_##t
104 extern bool setfont(const char *name
);
105 extern void gettextres(int &w
, int &h
);
106 extern void draw_text(const char *str
, int left
, int top
, int r
= 255, int g
= 255, int b
= 255, int a
= 255);
107 extern void draw_textf(const char *fstr
, int left
, int top
, ...);
108 extern int char_width(int c
, int x
= 0);
109 extern int text_width(const char *str
, int limit
= -1);
110 extern int text_visible(const char *str
, int max
);
113 extern void adddynlight(const vec
&o
, float radius
, const vec
&color
, int fade
= 0, int peak
= 0);
114 extern void cleardynlights();
115 extern void dynlightreaching(const vec
&target
, vec
&color
, vec
&dir
);
118 extern vec worldpos
, camright
, camup
;
119 extern void damageblend(int n
);
122 extern void render_particles(int time
);
123 extern void regular_particle_splash(int type
, int num
, int fade
, const vec
&p
, int delay
= 0);
124 extern void particle_splash(int type
, int num
, int fade
, const vec
&p
);
125 extern void particle_trail(int type
, int fade
, const vec
&from
, const vec
&to
);
126 extern void particle_text(const vec
&s
, const char *t
, int type
, int fade
= 2000);
127 extern void particle_meter(const vec
&s
, float val
, int type
, int fade
= 1);
128 extern void particle_flare(const vec
&p
, const vec
&dest
, int fade
, int type
= 10, physent
*owner
= NULL
);
129 extern void particle_fireball(const vec
&dest
, float max
, int type
);
130 extern void removetrackedparticles(physent
*owner
= NULL
);
133 extern void load_world(const char *mname
, const char *cname
= NULL
);
134 extern void save_world(char *mname
, bool nolms
= false);
137 extern void moveplayer(physent
*pl
, int moveres
, bool local
);
138 extern bool moveplayer(physent
*pl
, int moveres
, bool local
, int curtime
);
139 extern bool collide(physent
*d
, const vec
&dir
= vec(0, 0, 0), float cutoff
= 0.0f
, bool playercol
= true);
140 extern bool bounce(physent
*d
, float secs
, float elasticity
= 0.8f
, float waterfric
= 3.0f
);
141 extern void avoidcollision(physent
*d
, const vec
&dir
, physent
*obstacle
, float space
);
142 extern void physicsframe();
143 extern void dropenttofloor(entity
*e
);
144 extern void vecfromyawpitch(float yaw
, float pitch
, int move
, int strafe
, vec
&m
);
145 extern void vectoyawpitch(const vec
&v
, float &yaw
, float &pitch
);
146 extern bool intersect(physent
*d
, vec
&from
, vec
&to
);
147 extern bool moveplatform(physent
*p
, const vec
&dir
);
148 extern void updatephysstate(physent
*d
);
149 extern void cleardynentcache();
150 extern bool entinmap(dynent
*d
, bool avoidplayers
= false);
151 extern void findplayerspawn(dynent
*d
, int forceent
= -1);
153 extern void playsound (int n
, const vec
*loc
= NULL
, extentity
*ent
= NULL
);
154 extern void playsoundname(const char *s
, const vec
*loc
= NULL
, int vol
= 0);
155 extern void initsound();
159 enum { MDL_CULL_VFC
= 1<<0, MDL_CULL_DIST
= 1<<1, MDL_CULL_OCCLUDED
= 1<<2, MDL_CULL_QUERY
= 1<<3, MDL_SHADOW
= 1<<4, MDL_DYNSHADOW
= 1<<5, MDL_TRANSLUCENT
= 1<<6 };
160 enum { MDL_ATTACH_VWEP
= 0, MDL_ATTACH_SHIELD
, MDL_ATTACH_POWERUP
};
166 int type
, anim
, basetime
;
170 extern void startmodelbatches();
171 extern void endmodelbatches();
172 extern void rendermodel(vec
&color
, vec
&dir
, const char *mdl
, int anim
, int varseed
, int tex
, const vec
&o
, float yaw
= 0, float pitch
= 0, float speed
= 0, int basetime
= 0, dynent
*d
= NULL
, int cull
= MDL_CULL_VFC
| MDL_CULL_DIST
| MDL_CULL_OCCLUDED
, modelattach
*a
= NULL
);
173 extern void abovemodel(vec
&o
, const char *mdl
);
174 extern void rendershadow(dynent
*d
);
175 extern void renderclient(dynent
*d
, const char *mdlname
, modelattach
*attachments
, int attack
, int attackdelay
, int lastaction
, int lastpain
, float sink
= 0);
176 extern void interpolateorientation(dynent
*d
, float &interpyaw
, float &interppitch
);
177 extern void setbbfrommodel(dynent
*d
, const char *mdl
);
178 extern const char *mapmodelname(int i
);
179 extern model
*loadmodel(const char *name
, int i
= -1, bool msg
= false);
182 #define MAXCLIENTS 256 // in a multiplayer game, can be arbitrarily changed
183 #define MAXTRANS 5000 // max amount of data to swallow in 1 go
185 extern int maxclients
;
187 enum { DISC_NONE
= 0, DISC_EOP
, DISC_CN
, DISC_KICK
, DISC_TAGT
, DISC_IPBAN
, DISC_PRIVATE
, DISC_MAXCLIENTS
, DISC_NUM
};
189 extern void *getinfo(int i
);
190 extern void sendf(int cn
, int chan
, const char *format
, ...);
191 extern void sendfile(int cn
, int chan
, FILE *file
, const char *format
= "", ...);
192 extern void sendpacket(int cn
, int chan
, ENetPacket
*packet
, int exclude
= -1);
193 extern int getnumclients();
194 extern uint
getclientip(int n
);
195 extern void putint(ucharbuf
&p
, int n
);
196 extern int getint(ucharbuf
&p
);
197 extern void putuint(ucharbuf
&p
, int n
);
198 extern int getuint(ucharbuf
&p
);
199 extern void sendstring(const char *t
, ucharbuf
&p
);
200 extern void getstring(char *t
, ucharbuf
&p
, int len
= MAXTRANS
);
201 extern void filtertext(char *dst
, const char *src
, bool whitespace
= true, int len
= sizeof(string
)-1);
202 extern void disconnect_client(int n
, int reason
);
203 extern bool hasnonlocalclients();
204 extern bool haslocalclients();
207 extern void c2sinfo(dynent
*d
, int rate
= 33);
208 extern void sendpackettoserv(ENetPacket
*packet
, int chan
);
209 extern void disconnect(int onlyclean
= 0, int async
= 0);
210 extern bool isconnected();
211 extern bool multiplayer(bool msg
= true);
212 extern void neterr(const char *s
);
213 extern void gets2c();
218 enum { G3D_DOWN
= 1, G3D_UP
= 2, G3D_PRESSED
= 4, G3D_ROLLOVER
= 8 };
222 virtual ~g3d_gui() {}
224 virtual void start(int starttime
, float basescale
, int *tab
= NULL
, bool allowinput
= true) = 0;
225 virtual void end() = 0;
227 virtual int text(const char *text
, int color
, const char *icon
= NULL
) = 0;
228 int textf(const char *fmt
, int color
, const char *icon
= NULL
, ...)
230 s_sprintfdlv(str
, icon
, fmt
);
231 return text(str
, color
, icon
);
233 virtual int button(const char *text
, int color
, const char *icon
= NULL
) = 0;
234 virtual void background(int color
, int parentw
= 0, int parenth
= 0) = 0;
236 virtual void pushlist() {}
237 virtual void poplist() {}
239 virtual void tab(const char *name
, int color
) = 0;
240 virtual int title(const char *text
, int color
, const char *icon
= NULL
) = 0;
241 virtual int image(Texture
*t
, float scale
, bool overlaid
= false) = 0;
242 virtual int texture(Texture
*t
, float scale
) = 0;
243 virtual void slider(int &val
, int vmin
, int vmax
, int color
, char *label
= NULL
) = 0;
244 virtual void separator() = 0;
245 virtual void progress(float percent
) = 0;
246 virtual void strut(int size
) = 0;
247 virtual void space(int size
) = 0;
248 virtual char *field(const char *name
, int color
, int length
, const char *initval
= "") = 0;
253 virtual ~g3d_callback() {}
255 int starttime() { extern int totalmillis
; return totalmillis
; }
257 virtual void gui(g3d_gui
&g
, bool firstpass
) = 0;
260 extern void g3d_addgui(g3d_callback
*cb
, vec
&origin
, bool follow
= false);
261 extern bool g3d_movecursor(int dx
, int dy
);
262 extern void g3d_cursorpos(float &x
, float &y
);
263 extern void g3d_resetcursor();