2 Copyright (C) 1996-1997 Id Software, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 // cl_main.c -- client main loop
23 #include "cl_collision.h"
26 // we need to declare some mouse variables here, because the menu system
27 // references them even when on a unix system.
29 // these two are not intended to be set directly
30 cvar_t cl_name = {CVAR_SAVE, "_cl_name", "player"};
31 cvar_t cl_color = {CVAR_SAVE, "_cl_color", "0"};
32 cvar_t cl_pmodel = {CVAR_SAVE, "_cl_pmodel", "0"};
34 cvar_t cl_shownet = {0, "cl_shownet","0"};
35 cvar_t cl_nolerp = {0, "cl_nolerp", "0"};
37 cvar_t cl_itembobheight = {0, "cl_itembobheight", "8"};
38 cvar_t cl_itembobspeed = {0, "cl_itembobspeed", "0.5"};
40 cvar_t lookspring = {CVAR_SAVE, "lookspring","0"};
41 cvar_t lookstrafe = {CVAR_SAVE, "lookstrafe","0"};
42 cvar_t sensitivity = {CVAR_SAVE, "sensitivity","3", 1, 30};
44 cvar_t m_pitch = {CVAR_SAVE, "m_pitch","0.022"};
45 cvar_t m_yaw = {CVAR_SAVE, "m_yaw","0.022"};
46 cvar_t m_forward = {CVAR_SAVE, "m_forward","1"};
47 cvar_t m_side = {CVAR_SAVE, "m_side","0.8"};
49 cvar_t freelook = {CVAR_SAVE, "freelook", "1"};
51 cvar_t cl_draweffects = {0, "cl_draweffects", "1"};
53 mempool_t *cl_scores_mempool;
54 mempool_t *cl_refdef_mempool;
58 // FIXME: put these on hunk?
59 entity_t cl_entities[MAX_EDICTS];
60 entity_t cl_static_entities[MAX_STATIC_ENTITIES];
61 lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES];
63 typedef struct effect_s
72 // these are for interpolation
79 #define MAX_EFFECTS 256
81 static cl_effect_t cl_effect[MAX_EFFECTS];
90 void CL_ClearState (void)
97 Mem_EmptyPool(cl_scores_mempool);
99 // wipe the entire cl structure
100 memset (&cl, 0, sizeof(cl));
102 SZ_Clear (&cls.message);
104 // clear other arrays
105 memset(cl_entities, 0, sizeof(cl_entities));
106 memset(cl_lightstyle, 0, sizeof(cl_lightstyle));
107 memset(cl_temp_entities, 0, sizeof(cl_temp_entities));
108 memset(cl_beams, 0, sizeof(cl_beams));
109 memset(cl_dlights, 0, sizeof(cl_dlights));
110 memset(cl_effect, 0, sizeof(cl_effect));
112 CL_Particles_Clear();
113 // LordHavoc: have to set up the baseline info for alpha and other stuff
114 for (i = 0;i < MAX_EDICTS;i++)
116 ClearStateToDefault(&cl_entities[i].state_baseline);
117 ClearStateToDefault(&cl_entities[i].state_previous);
118 ClearStateToDefault(&cl_entities[i].state_current);
124 void CL_LerpUpdate(entity_t *e)
126 entity_persistent_t *p;
131 if (p->modelindex != e->state_current.modelindex)
133 // reset all interpolation information
134 p->modelindex = e->state_current.modelindex;
135 p->frame1 = p->frame2 = e->state_current.frame;
136 p->frame1time = p->frame2time = cl.time;
139 else if (p->frame2 != e->state_current.frame)
141 // transition to new frame
142 p->frame1 = p->frame2;
143 p->frame1time = p->frame2time;
144 p->frame2 = e->state_current.frame;
145 p->frame2time = cl.time;
151 p->framelerp = (cl.time - p->frame2time) * 10;
152 p->framelerp = bound(0, p->framelerp, 1);
155 r->model = cl.model_precache[e->state_current.modelindex];
156 Mod_CheckLoaded(r->model);
157 r->frame = e->state_current.frame;
158 r->frame1 = p->frame1;
159 r->frame2 = p->frame2;
160 r->framelerp = p->framelerp;
161 r->frame1time = p->frame1time;
162 r->frame2time = p->frame2time;
166 =====================
169 Sends a disconnect message to the server
170 This is also called on Host_Error, so it shouldn't cause any errors
171 =====================
173 void CL_Disconnect (void)
175 if (cls.state == ca_dedicated)
178 // stop sounds (especially looping!)
179 S_StopAllSounds (true);
181 // clear contents blends
182 cl.cshifts[0].percent = 0;
183 cl.cshifts[1].percent = 0;
184 cl.cshifts[2].percent = 0;
185 cl.cshifts[3].percent = 0;
187 cl.worldmodel = NULL;
189 if (cls.demoplayback)
191 else if (cls.state == ca_connected)
193 if (cls.demorecording)
196 Con_DPrintf ("Sending clc_disconnect\n");
197 SZ_Clear (&cls.message);
198 MSG_WriteByte (&cls.message, clc_disconnect);
199 NET_SendUnreliableMessage (cls.netcon, &cls.message);
200 SZ_Clear (&cls.message);
201 NET_Close (cls.netcon);
202 cls.state = ca_disconnected; // prevent this code from executing again during Host_ShutdownServer
203 // if running a local server, shut it down
205 Host_ShutdownServer(false);
207 cls.state = ca_disconnected;
209 cls.demoplayback = cls.timedemo = false;
213 void CL_Disconnect_f (void)
217 Host_ShutdownServer (false);
224 =====================
225 CL_EstablishConnection
227 Host should be either "local" or a net address to be passed on
228 =====================
230 void CL_EstablishConnection (char *host)
232 if (cls.state == ca_dedicated)
235 if (cls.demoplayback)
240 cls.netcon = NET_Connect (host);
242 Host_Error ("CL_Connect: connect failed\n");
243 Con_DPrintf ("CL_EstablishConnection: connected to %s\n", host);
245 cls.demonum = -1; // not in the demo loop now
246 cls.state = ca_connected;
247 cls.signon = 0; // need all the signon messages before playing
257 static void CL_PrintEntities_f (void)
263 for (i = 0, ent = cl_entities;i < MAX_EDICTS /*cl.num_entities*/;i++, ent++)
265 if (!ent->state_current.active)
267 if (!ent->render.model)
270 Con_Printf ("%3i:", i);
271 if (!ent->render.model)
273 Con_Printf ("EMPTY\n");
276 strncpy(name, ent->render.model->name, 25);
278 for (j = strlen(name);j < 25;j++)
280 Con_Printf ("%s:%04i (%5i %5i %5i) [%3i %3i %3i] %4.2f %5.3f\n", name, ent->render.frame, (int) ent->render.origin[0], (int) ent->render.origin[1], (int) ent->render.origin[2], (int) ent->render.angles[0] % 360, (int) ent->render.angles[1] % 360, (int) ent->render.angles[2] % 360, ent->render.scale, ent->render.alpha);
289 Determines the fraction between the last two messages that the objects
293 static float CL_LerpPoint (void)
297 // dropped packet, or start of demo
298 if (cl.mtime[1] < cl.mtime[0] - 0.1)
299 cl.mtime[1] = cl.mtime[0] - 0.1;
301 cl.time = bound(cl.mtime[1], cl.time, cl.mtime[0]);
303 // LordHavoc: lerp in listen games as the server is being capped below the client (usually)
304 f = cl.mtime[0] - cl.mtime[1];
305 if (!f || cl_nolerp.integer || cls.timedemo || (sv.active && svs.maxclients == 1))
307 cl.time = cl.mtime[0];
311 f = (cl.time - cl.mtime[1]) / f;
312 return bound(0, f, 1);
315 static void CL_RelinkStaticEntities(void)
318 for (i = 0;i < cl.num_statics && r_refdef.numentities < MAX_VISEDICTS;i++)
320 Mod_CheckLoaded(cl_static_entities[i].render.model);
321 r_refdef.entities[r_refdef.numentities++] = &cl_static_entities[i].render;
330 static void CL_RelinkNetworkEntities()
333 int i, glowcolor, effects;
334 float f, d, bobjrotate, bobjoffset, dlightradius, glowsize, lerp;
335 vec3_t oldorg, neworg, delta, dlightcolor;
337 bobjrotate = ANGLEMOD(100*cl.time);
338 if (cl_itembobheight.value)
339 bobjoffset = (cos(cl.time * cl_itembobspeed.value * (2.0 * M_PI)) + 1.0) * 0.5 * cl_itembobheight.value;
343 // start on the entity after the world
344 for (i = 1, ent = cl_entities + 1;i < MAX_EDICTS /*cl.num_entities*/;i++, ent++)
346 // if the object wasn't included in the latest packet, remove it
347 if (!ent->state_current.active)
350 VectorCopy(ent->persistent.trail_origin, oldorg);
352 if (!ent->state_previous.active)
354 // only one state available
356 VectorCopy (ent->state_current.origin, oldorg); // skip trails
357 VectorCopy (ent->state_current.origin, neworg);
358 VectorCopy (ent->state_current.angles, ent->render.angles);
362 // if the delta is large, assume a teleport and don't lerp
363 VectorSubtract(ent->state_current.origin, ent->state_previous.origin, delta);
364 // LordHavoc: increased tolerance from 100 to 200, and now to 1000
365 if ((sv.active && svs.maxclients == 1 && !(ent->state_current.flags & RENDER_STEP)) || cls.timedemo || DotProduct(delta, delta) > 1000*1000 || cl_nolerp.integer)
369 f = ent->state_current.time - ent->state_previous.time;
371 lerp = (cl.time - ent->state_previous.time) / f;
378 VectorCopy (ent->state_current.origin, neworg);
379 VectorCopy (ent->state_current.angles, ent->render.angles);
383 // interpolate the origin and angles
384 VectorMA(ent->state_previous.origin, lerp, delta, neworg);
385 VectorSubtract(ent->state_current.angles, ent->state_previous.angles, delta);
386 if (delta[0] < -180) delta[0] += 360;else if (delta[0] >= 180) delta[0] -= 360;
387 if (delta[1] < -180) delta[1] += 360;else if (delta[1] >= 180) delta[1] -= 360;
388 if (delta[2] < -180) delta[2] += 360;else if (delta[2] >= 180) delta[2] -= 360;
389 VectorMA(ent->state_previous.angles, lerp, delta, ent->render.angles);
393 VectorCopy (neworg, ent->persistent.trail_origin);
394 // persistent.modelindex will be updated by CL_LerpUpdate
395 if (ent->state_current.modelindex != ent->persistent.modelindex)
396 VectorCopy(neworg, oldorg);
398 VectorCopy (neworg, ent->render.origin);
399 ent->render.flags = ent->state_current.flags;
400 ent->render.effects = effects = ent->state_current.effects;
401 if (cl.scores == NULL || !ent->state_current.colormap)
402 ent->render.colormap = -1; // no special coloring
404 ent->render.colormap = cl.scores[ent->state_current.colormap - 1].colors; // color it
405 ent->render.skinnum = ent->state_current.skin;
406 ent->render.alpha = ent->state_current.alpha * (1.0f / 255.0f); // FIXME: interpolate?
407 ent->render.scale = ent->state_current.scale * (1.0f / 16.0f); // FIXME: interpolate?
409 // update interpolation info
412 // handle effects now...
418 // LordHavoc: if the entity has no effects, don't check each
421 if (effects & EF_BRIGHTFIELD)
422 CL_EntityParticles (ent);
423 if (effects & EF_MUZZLEFLASH)
424 ent->persistent.muzzleflash = 100.0f;
425 if (effects & EF_DIMLIGHT)
427 dlightcolor[0] += 200.0f;
428 dlightcolor[1] += 200.0f;
429 dlightcolor[2] += 200.0f;
431 if (effects & EF_BRIGHTLIGHT)
433 dlightcolor[0] += 400.0f;
434 dlightcolor[1] += 400.0f;
435 dlightcolor[2] += 400.0f;
437 // LordHavoc: added EF_RED and EF_BLUE
438 if (effects & EF_RED) // red
440 dlightcolor[0] += 200.0f;
441 dlightcolor[1] += 20.0f;
442 dlightcolor[2] += 20.0f;
444 if (effects & EF_BLUE) // blue
446 dlightcolor[0] += 20.0f;
447 dlightcolor[1] += 20.0f;
448 dlightcolor[2] += 200.0f;
450 if (effects & EF_FLAME)
452 if (ent->render.model)
456 mins[0] = neworg[0] - 16.0f;
457 mins[1] = neworg[1] - 16.0f;
458 mins[2] = neworg[2] - 16.0f;
459 maxs[0] = neworg[0] + 16.0f;
460 maxs[1] = neworg[1] + 16.0f;
461 maxs[2] = neworg[2] + 16.0f;
462 // how many flames to make
463 temp = (int) (cl.time * 300) - (int) (cl.oldtime * 300);
464 CL_FlameCube(mins, maxs, temp);
466 d = lhrandom(200, 250);
467 dlightcolor[0] += d * 1.0f;
468 dlightcolor[1] += d * 0.7f;
469 dlightcolor[2] += d * 0.3f;
471 if (effects & EF_STARDUST)
473 if (ent->render.model)
477 mins[0] = neworg[0] - 16.0f;
478 mins[1] = neworg[1] - 16.0f;
479 mins[2] = neworg[2] - 16.0f;
480 maxs[0] = neworg[0] + 16.0f;
481 maxs[1] = neworg[1] + 16.0f;
482 maxs[2] = neworg[2] + 16.0f;
483 // how many particles to make
484 temp = (int) (cl.time * 200) - (int) (cl.oldtime * 200);
485 CL_Stardust(mins, maxs, temp);
488 dlightcolor[0] += d * 1.0f;
489 dlightcolor[1] += d * 0.7f;
490 dlightcolor[2] += d * 0.3f;
494 if (ent->persistent.muzzleflash > 0)
498 AngleVectors (ent->render.angles, v, NULL, NULL);
500 v2[0] = v[0] * 18 + neworg[0];
501 v2[1] = v[1] * 18 + neworg[1];
502 v2[2] = v[2] * 18 + neworg[2] + 16;
503 CL_TraceLine(neworg, v2, v, NULL, 0, true);
505 CL_AllocDlight (NULL, v, ent->persistent.muzzleflash, 1, 1, 1, 0, 0);
506 ent->persistent.muzzleflash -= cl.frametime * 1000;
509 // LordHavoc: if the model has no flags, don't check each
510 if (ent->render.model && ent->render.model->flags)
512 if (ent->render.model->flags & EF_ROTATE)
514 ent->render.angles[1] = bobjrotate;
515 ent->render.origin[2] += bobjoffset;
517 // only do trails if present in the previous frame as well
518 if (ent->state_previous.active)
520 if (ent->render.model->flags & EF_GIB)
521 CL_RocketTrail (oldorg, neworg, 2, ent);
522 else if (ent->render.model->flags & EF_ZOMGIB)
523 CL_RocketTrail (oldorg, neworg, 4, ent);
524 else if (ent->render.model->flags & EF_TRACER)
526 CL_RocketTrail (oldorg, neworg, 3, ent);
527 dlightcolor[0] += 0x10;
528 dlightcolor[1] += 0x40;
529 dlightcolor[2] += 0x10;
531 else if (ent->render.model->flags & EF_TRACER2)
533 CL_RocketTrail (oldorg, neworg, 5, ent);
534 dlightcolor[0] += 0x50;
535 dlightcolor[1] += 0x30;
536 dlightcolor[2] += 0x10;
538 else if (ent->render.model->flags & EF_ROCKET)
540 CL_RocketTrail (oldorg, ent->render.origin, 0, ent);
541 dlightcolor[0] += 200.0f;
542 dlightcolor[1] += 160.0f;
543 dlightcolor[2] += 80.0f;
545 else if (ent->render.model->flags & EF_GRENADE)
547 if (ent->render.alpha == -1) // LordHavoc: Nehahra dem compatibility
548 CL_RocketTrail (oldorg, neworg, 7, ent);
550 CL_RocketTrail (oldorg, neworg, 1, ent);
552 else if (ent->render.model->flags & EF_TRACER3)
554 CL_RocketTrail (oldorg, neworg, 6, ent);
555 dlightcolor[0] += 0x50;
556 dlightcolor[1] += 0x20;
557 dlightcolor[2] += 0x40;
561 // LordHavoc: customizable glow
562 glowsize = ent->state_current.glowsize; // FIXME: interpolate?
563 glowcolor = ent->state_current.glowcolor;
566 qbyte *tempcolor = (qbyte *)&d_8to24table[glowcolor];
567 // * 4 for the expansion from 0-255 to 0-1023 range,
568 // / 255 to scale down byte colors
569 glowsize *= (4.0f / 255.0f);
570 VectorMA(dlightcolor, glowsize, tempcolor, dlightcolor);
572 // LordHavoc: customizable trail
573 if (ent->render.flags & RENDER_GLOWTRAIL)
574 CL_RocketTrail2 (oldorg, neworg, glowcolor, ent);
576 if (dlightcolor[0] || dlightcolor[1] || dlightcolor[2])
579 VectorCopy(neworg, vec);
580 // hack to make glowing player light shine on their gun
581 if (i == cl.viewentity && !chase_active.integer)
583 CL_AllocDlight (NULL, vec, 1, dlightcolor[0], dlightcolor[1], dlightcolor[2], 0, 0);
586 if (chase_active.integer)
588 if (ent->render.flags & RENDER_VIEWMODEL)
593 if (i == cl.viewentity || (ent->render.flags & RENDER_EXTERIORMODEL))
597 if (ent->render.model == NULL)
599 if (effects & EF_NODRAW)
601 if (r_refdef.numentities < MAX_VISEDICTS)
602 r_refdef.entities[r_refdef.numentities++] = &ent->render;
606 void CL_LerpPlayer(float frac)
611 if (cl.entitydatabase.numframes)
613 cl.viewentorigin[0] = cl.viewentoriginold[0] + frac * (cl.viewentoriginnew[0] - cl.viewentoriginold[0]);
614 cl.viewentorigin[1] = cl.viewentoriginold[1] + frac * (cl.viewentoriginnew[1] - cl.viewentoriginold[1]);
615 cl.viewentorigin[2] = cl.viewentoriginold[2] + frac * (cl.viewentoriginnew[2] - cl.viewentoriginold[2]);
618 VectorCopy (cl_entities[cl.viewentity].render.origin, cl.viewentorigin);
620 cl.viewzoom = cl.viewzoomold + frac * (cl.viewzoomnew - cl.viewzoomold);
622 for (i = 0;i < 3;i++)
623 cl.velocity[i] = cl.mvelocity[1][i] + frac * (cl.mvelocity[0][i] - cl.mvelocity[1][i]);
625 if (cls.demoplayback)
627 // interpolate the angles
628 for (i = 0;i < 3;i++)
630 d = cl.mviewangles[0][i] - cl.mviewangles[1][i];
635 cl.viewangles[i] = cl.mviewangles[1][i] + frac*d;
640 void CL_Effect(vec3_t org, int modelindex, int startframe, int framecount, float framerate)
644 if (!modelindex) // sanity check
646 for (i = 0, e = cl_effect;i < MAX_EFFECTS;i++, e++)
651 VectorCopy(org, e->origin);
652 e->modelindex = modelindex;
653 e->starttime = cl.time;
654 e->startframe = startframe;
655 e->endframe = startframe + framecount;
656 e->framerate = framerate;
659 e->frame1time = cl.time;
660 e->frame2time = cl.time;
665 static void CL_RelinkEffects()
672 for (i = 0, e = cl_effect;i < MAX_EFFECTS;i++, e++)
676 frame = (cl.time - e->starttime) * e->framerate + e->startframe;
678 if (intframe < 0 || intframe >= e->endframe)
681 memset(e, 0, sizeof(*e));
685 if (intframe != e->frame)
688 e->frame1time = e->frame2time;
689 e->frame2time = cl.time;
692 if ((vis = CL_NewTempEntity()))
694 // interpolation stuff
695 vis->render.frame1 = intframe;
696 vis->render.frame2 = intframe + 1;
697 if (vis->render.frame2 >= e->endframe)
698 vis->render.frame2 = -1; // disappear
699 vis->render.framelerp = frame - intframe;
700 vis->render.frame1time = e->frame1time;
701 vis->render.frame2time = e->frame2time;
704 VectorCopy(e->origin, vis->render.origin);
705 vis->render.model = cl.model_precache[e->modelindex];
706 vis->render.frame = vis->render.frame2;
707 vis->render.colormap = -1; // no special coloring
708 vis->render.scale = 1;
709 vis->render.alpha = 1;
715 void CL_RelinkEntities (void)
719 // fraction from previous network update to current
720 frac = CL_LerpPoint ();
723 CL_RelinkStaticEntities();
724 CL_RelinkNetworkEntities();
725 CL_TraceLine_ScanForBModels();
738 Read all incoming data from the server
741 int CL_ReadFromServer (void)
745 cl.oldtime = cl.time;
746 cl.time += cl.frametime;
751 ret = CL_GetMessage ();
753 Host_Error ("CL_ReadFromServer: lost server connection");
757 cl.last_received_message = realtime;
759 if (cl_shownet.integer)
762 CL_ParseServerMessage ();
764 while (ret && cls.state == ca_connected);
769 r_refdef.numentities = 0;
770 if (cls.state == ca_connected && cl.worldmodel)
772 CL_RelinkEntities ();
774 // run cgame code (which can add more entities)
779 // bring the links up to date
789 void CL_SendCmd (void)
793 if (cls.state != ca_connected)
796 if (cls.signon == SIGNONS)
798 // get basic movement from keyboard
801 IN_PreMove(); // OS independent code
803 // allow mice or other external controllers to add to the move
806 IN_PostMove(); // OS independent code
808 // send the unreliable message
814 // LordHavoc: fix for NAT routing of netquake:
815 // bounce back a clc_nop message to the newly allocated server port,
816 // to establish a routing connection for incoming frames,
817 // the server waits for this before sending anything
818 if (realtime > cl.sendnoptime)
820 Con_DPrintf("sending clc_nop to get server's attention\n");
821 cl.sendnoptime = realtime + 3;
822 MSG_WriteByte(&cls.message, clc_nop);
827 if (cls.demoplayback)
829 SZ_Clear (&cls.message);
833 // send the reliable message
834 if (!cls.message.cursize)
835 return; // no message at all
837 if (!NET_CanSendMessage (cls.netcon))
839 Con_DPrintf ("CL_WriteToServer: can't send\n");
843 if (NET_SendMessage (cls.netcon, &cls.message) == -1)
844 Host_Error ("CL_WriteToServer: lost server connection");
846 SZ_Clear (&cls.message);
849 // LordHavoc: pausedemo command
850 static void CL_PauseDemo_f (void)
852 cls.demopaused = !cls.demopaused;
854 Con_Printf("Demo paused\n");
856 Con_Printf("Demo unpaused\n");
860 ======================
862 LordHavoc: Intended for Nehahra, I personally think this is dumb, but Mindcrime won't listen.
863 ======================
865 static void CL_PModel_f (void)
870 if (Cmd_Argc () == 1)
872 Con_Printf ("\"pmodel\" is \"%s\"\n", cl_pmodel.string);
875 i = atoi(Cmd_Argv(1));
877 if (cmd_source == src_command)
879 if (cl_pmodel.integer == i)
881 Cvar_SetValue ("_cl_pmodel", i);
882 if (cls.state == ca_connected)
883 Cmd_ForwardToServer ();
887 host_client->pmodel = i;
888 if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_pmodel)))
893 ======================
895 ======================
897 static void CL_Fog_f (void)
899 if (Cmd_Argc () == 1)
901 Con_Printf ("\"fog\" is \"%f %f %f %f\"\n", fog_density, fog_red, fog_green, fog_blue);
904 fog_density = atof(Cmd_Argv(1));
905 fog_red = atof(Cmd_Argv(2));
906 fog_green = atof(Cmd_Argv(3));
907 fog_blue = atof(Cmd_Argv(4));
917 cl_scores_mempool = Mem_AllocPool("client player info");
919 cl_refdef_mempool = Mem_AllocPool("refdef");
920 memset(&r_refdef, 0, sizeof(r_refdef));
921 r_refdef.entities = Mem_Alloc(cl_refdef_mempool, sizeof(entity_render_t *) * MAX_VISEDICTS);
923 SZ_Alloc (&cls.message, 1024, "cls.message");
929 // register our commands
931 Cvar_RegisterVariable (&cl_name);
932 Cvar_RegisterVariable (&cl_color);
933 if (gamemode == GAME_NEHAHRA)
934 Cvar_RegisterVariable (&cl_pmodel);
935 Cvar_RegisterVariable (&cl_upspeed);
936 Cvar_RegisterVariable (&cl_forwardspeed);
937 Cvar_RegisterVariable (&cl_backspeed);
938 Cvar_RegisterVariable (&cl_sidespeed);
939 Cvar_RegisterVariable (&cl_movespeedkey);
940 Cvar_RegisterVariable (&cl_yawspeed);
941 Cvar_RegisterVariable (&cl_pitchspeed);
942 Cvar_RegisterVariable (&cl_anglespeedkey);
943 Cvar_RegisterVariable (&cl_shownet);
944 Cvar_RegisterVariable (&cl_nolerp);
945 Cvar_RegisterVariable (&lookspring);
946 Cvar_RegisterVariable (&lookstrafe);
947 Cvar_RegisterVariable (&sensitivity);
948 Cvar_RegisterVariable (&freelook);
950 Cvar_RegisterVariable (&m_pitch);
951 Cvar_RegisterVariable (&m_yaw);
952 Cvar_RegisterVariable (&m_forward);
953 Cvar_RegisterVariable (&m_side);
955 Cvar_RegisterVariable (&cl_itembobspeed);
956 Cvar_RegisterVariable (&cl_itembobheight);
958 Cmd_AddCommand ("entities", CL_PrintEntities_f);
959 Cmd_AddCommand ("bitprofile", CL_BitProfile_f);
960 Cmd_AddCommand ("disconnect", CL_Disconnect_f);
961 Cmd_AddCommand ("record", CL_Record_f);
962 Cmd_AddCommand ("stop", CL_Stop_f);
963 Cmd_AddCommand ("playdemo", CL_PlayDemo_f);
964 Cmd_AddCommand ("timedemo", CL_TimeDemo_f);
966 Cmd_AddCommand ("fog", CL_Fog_f);
968 // LordHavoc: added pausedemo
969 Cmd_AddCommand ("pausedemo", CL_PauseDemo_f);
970 if (gamemode == GAME_NEHAHRA)
971 Cmd_AddCommand ("pmodel", CL_PModel_f);
973 Cvar_RegisterVariable(&cl_draweffects);