summaryrefslogtreecommitdiff
path: root/apps/plugins/sdl/progs/quake/server.h
diff options
context:
space:
mode:
authorFranklin Wei <git@fwei.tk>2018-02-11 15:34:30 -0500
committerFranklin Wei <git@fwei.tk>2019-07-19 22:37:40 -0400
commit5d05b9d3e920a6aa5fcb553758e98ed0da8c91e4 (patch)
tree84406e21639529a185556a33e5de7f43cffc277b /apps/plugins/sdl/progs/quake/server.h
parentb70fecf21ddc21877ec1ae7888d9c18a979e37ad (diff)
downloadrockbox-5d05b9d3e920a6aa5fcb553758e98ed0da8c91e4.tar.gz
rockbox-5d05b9d3e920a6aa5fcb553758e98ed0da8c91e4.zip
Quake!
This ports id Software's Quake to run on the SDL plugin runtime. The source code originated from id under the GPLv2 license. I used https://github.com/ahefner/sdlquake as the base of my port. Performance is, unsurprisingly, not on par with what you're probably used to on PC. I average about 10FPS on ipod6g, but it's still playable. Sound works well enough, but in-game music is not supported. I've written ARM assembly routines for the inner sound loop. Make sure you turn the "brightness" all the way down, or colors will look funky. To run, extract Quake's data files to /.rockbox/quake. Have fun! Change-Id: I4285036e967d7f0722802d43cf2096c808ca5799
Diffstat (limited to 'apps/plugins/sdl/progs/quake/server.h')
-rw-r--r--apps/plugins/sdl/progs/quake/server.h258
1 files changed, 258 insertions, 0 deletions
diff --git a/apps/plugins/sdl/progs/quake/server.h b/apps/plugins/sdl/progs/quake/server.h
new file mode 100644
index 0000000000..5fe33deca0
--- /dev/null
+++ b/apps/plugins/sdl/progs/quake/server.h
@@ -0,0 +1,258 @@
1/*
2Copyright (C) 1996-1997 Id Software, Inc.
3
4This program is free software; you can redistribute it and/or
5modify it under the terms of the GNU General Public License
6as published by the Free Software Foundation; either version 2
7of the License, or (at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13See the GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19*/
20// server.h
21
22typedef struct
23{
24 int maxclients;
25 int maxclientslimit;
26 struct client_s *clients; // [maxclients]
27 int serverflags; // episode completion information
28 qboolean changelevel_issued; // cleared when at SV_SpawnServer
29} server_static_t;
30
31//=============================================================================
32
33typedef int server_state_t;
34enum {ss_loading, ss_active};
35
36typedef struct
37{
38 qboolean active; // false if only a net client
39
40 qboolean paused;
41 qboolean loadgame; // handle connections specially
42
43 double time;
44
45 int lastcheck; // used by PF_checkclient
46 double lastchecktime;
47
48 char name[64]; // map name
49#ifdef QUAKE2
50 char startspot[64];
51#endif
52 char modelname[64]; // maps/<name>.bsp, for model_precache[0]
53 struct model_s *worldmodel;
54 char *model_precache[MAX_MODELS]; // NULL terminated
55 struct model_s *models[MAX_MODELS];
56 char *sound_precache[MAX_SOUNDS]; // NULL terminated
57 char *lightstyles[MAX_LIGHTSTYLES];
58 int num_edicts;
59 int max_edicts;
60 edict_t *edicts; // can NOT be array indexed, because
61 // edict_t is variable sized, but can
62 // be used to reference the world ent
63 server_state_t state; // some actions are only valid during load
64
65 sizebuf_t datagram;
66 byte datagram_buf[MAX_DATAGRAM];
67
68 sizebuf_t reliable_datagram; // copied to all clients at end of frame
69 byte reliable_datagram_buf[MAX_DATAGRAM];
70
71 sizebuf_t signon;
72 byte signon_buf[8192];
73} server_t;
74
75
76#define NUM_PING_TIMES 16
77#define NUM_SPAWN_PARMS 16
78
79typedef struct client_s
80{
81 qboolean active; // false = client is free
82 qboolean spawned; // false = don't send datagrams
83 qboolean dropasap; // has been told to go to another level
84 qboolean privileged; // can execute any host command
85 qboolean sendsignon; // only valid before spawned
86
87 double last_message; // reliable messages must be sent
88 // periodically
89
90 struct qsocket_s *netconnection; // communications handle
91
92 usercmd_t cmd; // movement
93 vec3_t wishdir; // intended motion calced from cmd
94
95 sizebuf_t message; // can be added to at any time,
96 // copied and clear once per frame
97 byte msgbuf[MAX_MSGLEN];
98 edict_t *edict; // EDICT_NUM(clientnum+1)
99 char name[32]; // for printing to other people
100 int colors;
101
102 float ping_times[NUM_PING_TIMES];
103 int num_pings; // ping_times[num_pings%NUM_PING_TIMES]
104
105// spawn parms are carried from level to level
106 float spawn_parms[NUM_SPAWN_PARMS];
107
108// client known data for deltas
109 int old_frags;
110} client_t;
111
112
113//=============================================================================
114
115// edict->movetype values
116#define MOVETYPE_NONE 0 // never moves
117#define MOVETYPE_ANGLENOCLIP 1
118#define MOVETYPE_ANGLECLIP 2
119#define MOVETYPE_WALK 3 // gravity
120#define MOVETYPE_STEP 4 // gravity, special edge handling
121#define MOVETYPE_FLY 5
122#define MOVETYPE_TOSS 6 // gravity
123#define MOVETYPE_PUSH 7 // no clip to world, push and crush
124#define MOVETYPE_NOCLIP 8
125#define MOVETYPE_FLYMISSILE 9 // extra size to monsters
126#define MOVETYPE_BOUNCE 10
127#ifdef QUAKE2
128#define MOVETYPE_BOUNCEMISSILE 11 // bounce w/o gravity
129#define MOVETYPE_FOLLOW 12 // track movement of aiment
130#endif
131
132// edict->solid values
133#define SOLID_NOT 0 // no interaction with other objects
134#define SOLID_TRIGGER 1 // touch on edge, but not blocking
135#define SOLID_BBOX 2 // touch on edge, block
136#define SOLID_SLIDEBOX 3 // touch on edge, but not an onground
137#define SOLID_BSP 4 // bsp clip, touch on edge, block
138
139// edict->deadflag values
140#define DEAD_NO 0
141#define DEAD_DYING 1
142#define DEAD_DEAD 2
143
144#define DAMAGE_NO 0
145#define DAMAGE_YES 1
146#define DAMAGE_AIM 2
147
148// edict->flags
149#define FL_FLY 1
150#define FL_SWIM 2
151//#define FL_GLIMPSE 4
152#define FL_CONVEYOR 4
153#define FL_CLIENT 8
154#define FL_INWATER 16
155#define FL_MONSTER 32
156#define FL_GODMODE 64
157#define FL_NOTARGET 128
158#define FL_ITEM 256
159#define FL_ONGROUND 512
160#define FL_PARTIALGROUND 1024 // not all corners are valid
161#define FL_WATERJUMP 2048 // player jumping out of water
162#define FL_JUMPRELEASED 4096 // for jump debouncing
163#ifdef QUAKE2
164#define FL_FLASHLIGHT 8192
165#define FL_ARCHIVE_OVERRIDE 1048576
166#endif
167
168// entity effects
169
170#define EF_BRIGHTFIELD 1
171#define EF_MUZZLEFLASH 2
172#define EF_BRIGHTLIGHT 4
173#define EF_DIMLIGHT 8
174#ifdef QUAKE2
175#define EF_DARKLIGHT 16
176#define EF_DARKFIELD 32
177#define EF_LIGHT 64
178#define EF_NODRAW 128
179#endif
180
181#define SPAWNFLAG_NOT_EASY 256
182#define SPAWNFLAG_NOT_MEDIUM 512
183#define SPAWNFLAG_NOT_HARD 1024
184#define SPAWNFLAG_NOT_DEATHMATCH 2048
185
186#ifdef QUAKE2
187// server flags
188#define SFL_EPISODE_1 1
189#define SFL_EPISODE_2 2
190#define SFL_EPISODE_3 4
191#define SFL_EPISODE_4 8
192#define SFL_NEW_UNIT 16
193#define SFL_NEW_EPISODE 32
194#define SFL_CROSS_TRIGGERS 65280
195#endif
196
197//============================================================================
198
199extern cvar_t teamplay;
200extern cvar_t skill;
201extern cvar_t deathmatch;
202extern cvar_t coop;
203extern cvar_t fraglimit;
204extern cvar_t timelimit;
205
206extern server_static_t svs; // persistant server info
207extern server_t sv; // local server
208
209extern client_t *host_client;
210
211extern jmp_buf host_abortserver;
212
213extern double host_time;
214
215extern edict_t *sv_player;
216
217//===========================================================
218
219void SV_Init (void);
220
221void SV_StartParticle (vec3_t org, vec3_t dir, int color, int count);
222void SV_StartSound (edict_t *entity, int channel, char *sample, int volume,
223 float attenuation);
224
225void SV_DropClient (qboolean crash);
226
227void SV_SendClientMessages (void);
228void SV_ClearDatagram (void);
229
230int SV_ModelIndex (char *name);
231
232void SV_SetIdealPitch (void);
233
234void SV_AddUpdates (void);
235
236void SV_ClientThink (void);
237void SV_AddClientToServer (struct qsocket_s *ret);
238
239void SV_ClientPrintf (char *fmt, ...);
240void SV_BroadcastPrintf (char *fmt, ...);
241
242void SV_Physics (void);
243
244qboolean SV_CheckBottom (edict_t *ent);
245qboolean SV_movestep (edict_t *ent, vec3_t move, qboolean relink);
246
247void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg);
248
249void SV_MoveToGoal (void);
250
251void SV_CheckForNewClients (void);
252void SV_RunClients (void);
253void SV_SaveSpawnparms ();
254#ifdef QUAKE2
255void SV_SpawnServer (char *server, char *startspot);
256#else
257void SV_SpawnServer (char *server);
258#endif