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 r_draweffects = {0, "r_draweffects", "1"};
53 cvar_t cl_explosions = {CVAR_SAVE, "cl_explosions", "1"};
54 cvar_t cl_stainmaps = {CVAR_SAVE, "cl_stainmaps", "1"};
56 mempool_t *cl_scores_mempool;
57 mempool_t *cl_refdef_mempool;
61 // FIXME: put these on hunk?
62 entity_t cl_entities[MAX_EDICTS];
63 entity_t cl_static_entities[MAX_STATIC_ENTITIES];
64 lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES];
66 typedef struct effect_s
75 // these are for interpolation
82 #define MAX_EFFECTS 256
84 static cl_effect_t cl_effect[MAX_EFFECTS];
93 void CL_ClearState (void)
100 Mem_EmptyPool(cl_scores_mempool);
102 // wipe the entire cl structure
103 memset (&cl, 0, sizeof(cl));
105 SZ_Clear (&cls.message);
107 // clear other arrays
108 memset(cl_entities, 0, sizeof(cl_entities));
109 memset(cl_lightstyle, 0, sizeof(cl_lightstyle));
110 memset(cl_temp_entities, 0, sizeof(cl_temp_entities));
111 memset(cl_beams, 0, sizeof(cl_beams));
112 memset(cl_dlights, 0, sizeof(cl_dlights));
113 memset(cl_effect, 0, sizeof(cl_effect));
115 CL_Particles_Clear();
116 // LordHavoc: have to set up the baseline info for alpha and other stuff
117 for (i = 0;i < MAX_EDICTS;i++)
119 ClearStateToDefault(&cl_entities[i].state_baseline);
120 ClearStateToDefault(&cl_entities[i].state_previous);
121 ClearStateToDefault(&cl_entities[i].state_current);
127 void CL_LerpUpdate(entity_t *e)
129 entity_persistent_t *p;
134 if (p->modelindex != e->state_current.modelindex)
136 // reset all interpolation information
137 p->modelindex = e->state_current.modelindex;
138 p->frame1 = p->frame2 = e->state_current.frame;
139 p->frame1time = p->frame2time = cl.time;
142 else if (p->frame2 != e->state_current.frame)
144 // transition to new frame
145 p->frame1 = p->frame2;
146 p->frame1time = p->frame2time;
147 p->frame2 = e->state_current.frame;
148 p->frame2time = cl.time;
154 p->framelerp = (cl.time - p->frame2time) * 10;
155 p->framelerp = bound(0, p->framelerp, 1);
158 r->model = cl.model_precache[e->state_current.modelindex];
159 Mod_CheckLoaded(r->model);
160 r->frame = e->state_current.frame;
161 r->frame1 = p->frame1;
162 r->frame2 = p->frame2;
163 r->framelerp = p->framelerp;
164 r->frame1time = p->frame1time;
165 r->frame2time = p->frame2time;
169 =====================
172 Sends a disconnect message to the server
173 This is also called on Host_Error, so it shouldn't cause any errors
174 =====================
176 void CL_Disconnect (void)
178 if (cls.state == ca_dedicated)
181 // stop sounds (especially looping!)
182 S_StopAllSounds (true);
184 // clear contents blends
185 cl.cshifts[0].percent = 0;
186 cl.cshifts[1].percent = 0;
187 cl.cshifts[2].percent = 0;
188 cl.cshifts[3].percent = 0;
190 cl.worldmodel = NULL;
192 if (cls.demoplayback)
194 else if (cls.state == ca_connected)
196 if (cls.demorecording)
199 Con_DPrintf ("Sending clc_disconnect\n");
200 SZ_Clear (&cls.message);
201 MSG_WriteByte (&cls.message, clc_disconnect);
202 NET_SendUnreliableMessage (cls.netcon, &cls.message);
203 SZ_Clear (&cls.message);
204 NET_Close (cls.netcon);
205 cls.state = ca_disconnected; // prevent this code from executing again during Host_ShutdownServer
206 // if running a local server, shut it down
208 Host_ShutdownServer(false);
210 cls.state = ca_disconnected;
212 cls.demoplayback = cls.timedemo = false;
216 void CL_Disconnect_f (void)
220 Host_ShutdownServer (false);
227 =====================
228 CL_EstablishConnection
230 Host should be either "local" or a net address to be passed on
231 =====================
233 void CL_EstablishConnection (char *host)
235 if (cls.state == ca_dedicated)
238 if (cls.demoplayback)
243 cls.netcon = NET_Connect (host);
245 Host_Error ("CL_Connect: connect failed\n");
246 Con_DPrintf ("CL_EstablishConnection: connected to %s\n", host);
248 cls.demonum = -1; // not in the demo loop now
249 cls.state = ca_connected;
250 cls.signon = 0; // need all the signon messages before playing
260 static void CL_PrintEntities_f (void)
266 for (i = 0, ent = cl_entities;i < MAX_EDICTS /*cl.num_entities*/;i++, ent++)
268 if (!ent->state_current.active)
270 if (!ent->render.model)
273 Con_Printf ("%3i:", i);
274 if (!ent->render.model)
276 Con_Printf ("EMPTY\n");
279 strncpy(name, ent->render.model->name, 25);
281 for (j = strlen(name);j < 25;j++)
283 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);
292 Determines the fraction between the last two messages that the objects
296 static float CL_LerpPoint (void)
300 // dropped packet, or start of demo
301 if (cl.mtime[1] < cl.mtime[0] - 0.1)
302 cl.mtime[1] = cl.mtime[0] - 0.1;
304 cl.time = bound(cl.mtime[1], cl.time, cl.mtime[0]);
306 // LordHavoc: lerp in listen games as the server is being capped below the client (usually)
307 f = cl.mtime[0] - cl.mtime[1];
308 if (!f || cl_nolerp.integer || cls.timedemo || (sv.active && svs.maxclients == 1))
310 cl.time = cl.mtime[0];
314 f = (cl.time - cl.mtime[1]) / f;
315 return bound(0, f, 1);
318 static void CL_RelinkStaticEntities(void)
321 for (i = 0;i < cl.num_statics && r_refdef.numentities < MAX_VISEDICTS;i++)
323 Mod_CheckLoaded(cl_static_entities[i].render.model);
324 r_refdef.entities[r_refdef.numentities++] = &cl_static_entities[i].render;
333 static void CL_RelinkNetworkEntities()
336 int i, glowcolor, effects;
337 float f, d, bobjrotate, bobjoffset, dlightradius, glowsize, lerp;
338 vec3_t oldorg, neworg, delta, dlightcolor;
340 bobjrotate = ANGLEMOD(100*cl.time);
341 if (cl_itembobheight.value)
342 bobjoffset = (cos(cl.time * cl_itembobspeed.value * (2.0 * M_PI)) + 1.0) * 0.5 * cl_itembobheight.value;
346 // start on the entity after the world
347 for (i = 1, ent = cl_entities + 1;i < MAX_EDICTS /*cl.num_entities*/;i++, ent++)
349 // if the object wasn't included in the latest packet, remove it
350 if (!ent->state_current.active)
353 VectorCopy(ent->persistent.trail_origin, oldorg);
355 if (!ent->state_previous.active)
357 // only one state available
359 VectorCopy (ent->state_current.origin, oldorg); // skip trails
360 VectorCopy (ent->state_current.origin, neworg);
361 VectorCopy (ent->state_current.angles, ent->render.angles);
365 // if the delta is large, assume a teleport and don't lerp
366 VectorSubtract(ent->state_current.origin, ent->state_previous.origin, delta);
367 // LordHavoc: increased tolerance from 100 to 200, and now to 1000
368 if ((sv.active && svs.maxclients == 1 && !(ent->state_current.flags & RENDER_STEP)) || cls.timedemo || DotProduct(delta, delta) > 1000*1000 || cl_nolerp.integer)
372 f = ent->state_current.time - ent->state_previous.time;
374 lerp = (cl.time - ent->state_previous.time) / f;
381 VectorCopy (ent->state_current.origin, neworg);
382 VectorCopy (ent->state_current.angles, ent->render.angles);
386 // interpolate the origin and angles
387 VectorMA(ent->state_previous.origin, lerp, delta, neworg);
388 VectorSubtract(ent->state_current.angles, ent->state_previous.angles, delta);
389 if (delta[0] < -180) delta[0] += 360;else if (delta[0] >= 180) delta[0] -= 360;
390 if (delta[1] < -180) delta[1] += 360;else if (delta[1] >= 180) delta[1] -= 360;
391 if (delta[2] < -180) delta[2] += 360;else if (delta[2] >= 180) delta[2] -= 360;
392 VectorMA(ent->state_previous.angles, lerp, delta, ent->render.angles);
396 VectorCopy (neworg, ent->persistent.trail_origin);
397 // persistent.modelindex will be updated by CL_LerpUpdate
398 if (ent->state_current.modelindex != ent->persistent.modelindex)
399 VectorCopy(neworg, oldorg);
401 VectorCopy (neworg, ent->render.origin);
402 ent->render.flags = ent->state_current.flags;
403 ent->render.effects = effects = ent->state_current.effects;
404 if (cl.scores == NULL || !ent->state_current.colormap)
405 ent->render.colormap = -1; // no special coloring
407 ent->render.colormap = cl.scores[ent->state_current.colormap - 1].colors; // color it
408 ent->render.skinnum = ent->state_current.skin;
409 ent->render.alpha = ent->state_current.alpha * (1.0f / 255.0f); // FIXME: interpolate?
410 ent->render.scale = ent->state_current.scale * (1.0f / 16.0f); // FIXME: interpolate?
412 // update interpolation info
415 // handle effects now...
421 // LordHavoc: if the entity has no effects, don't check each
424 if (effects & EF_BRIGHTFIELD)
425 CL_EntityParticles (ent);
426 if (effects & EF_MUZZLEFLASH)
427 ent->persistent.muzzleflash = 100.0f;
428 if (effects & EF_DIMLIGHT)
430 dlightcolor[0] += 200.0f;
431 dlightcolor[1] += 200.0f;
432 dlightcolor[2] += 200.0f;
434 if (effects & EF_BRIGHTLIGHT)
436 dlightcolor[0] += 400.0f;
437 dlightcolor[1] += 400.0f;
438 dlightcolor[2] += 400.0f;
440 // LordHavoc: added EF_RED and EF_BLUE
441 if (effects & EF_RED) // red
443 dlightcolor[0] += 200.0f;
444 dlightcolor[1] += 20.0f;
445 dlightcolor[2] += 20.0f;
447 if (effects & EF_BLUE) // blue
449 dlightcolor[0] += 20.0f;
450 dlightcolor[1] += 20.0f;
451 dlightcolor[2] += 200.0f;
453 if (effects & EF_FLAME)
455 if (ent->render.model)
459 mins[0] = neworg[0] - 16.0f;
460 mins[1] = neworg[1] - 16.0f;
461 mins[2] = neworg[2] - 16.0f;
462 maxs[0] = neworg[0] + 16.0f;
463 maxs[1] = neworg[1] + 16.0f;
464 maxs[2] = neworg[2] + 16.0f;
465 // how many flames to make
466 temp = (int) (cl.time * 300) - (int) (cl.oldtime * 300);
467 CL_FlameCube(mins, maxs, temp);
469 d = lhrandom(200, 250);
470 dlightcolor[0] += d * 1.0f;
471 dlightcolor[1] += d * 0.7f;
472 dlightcolor[2] += d * 0.3f;
474 if (effects & EF_STARDUST)
476 if (ent->render.model)
480 mins[0] = neworg[0] - 16.0f;
481 mins[1] = neworg[1] - 16.0f;
482 mins[2] = neworg[2] - 16.0f;
483 maxs[0] = neworg[0] + 16.0f;
484 maxs[1] = neworg[1] + 16.0f;
485 maxs[2] = neworg[2] + 16.0f;
486 // how many particles to make
487 temp = (int) (cl.time * 200) - (int) (cl.oldtime * 200);
488 CL_Stardust(mins, maxs, temp);
491 dlightcolor[0] += d * 1.0f;
492 dlightcolor[1] += d * 0.7f;
493 dlightcolor[2] += d * 0.3f;
497 if (ent->persistent.muzzleflash > 0)
501 AngleVectors (ent->render.angles, v, NULL, NULL);
503 v2[0] = v[0] * 18 + neworg[0];
504 v2[1] = v[1] * 18 + neworg[1];
505 v2[2] = v[2] * 18 + neworg[2] + 16;
506 CL_TraceLine(neworg, v2, v, NULL, 0, true);
508 CL_AllocDlight (NULL, v, ent->persistent.muzzleflash, 1, 1, 1, 0, 0);
509 ent->persistent.muzzleflash -= cl.frametime * 1000;
512 // LordHavoc: if the model has no flags, don't check each
513 if (ent->render.model && ent->render.model->flags)
515 if (ent->render.model->flags & EF_ROTATE)
517 ent->render.angles[1] = bobjrotate;
518 ent->render.origin[2] += bobjoffset;
520 // only do trails if present in the previous frame as well
521 if (ent->state_previous.active)
523 if (ent->render.model->flags & EF_GIB)
524 CL_RocketTrail (oldorg, neworg, 2, ent);
525 else if (ent->render.model->flags & EF_ZOMGIB)
526 CL_RocketTrail (oldorg, neworg, 4, ent);
527 else if (ent->render.model->flags & EF_TRACER)
529 CL_RocketTrail (oldorg, neworg, 3, ent);
530 dlightcolor[0] += 0x10;
531 dlightcolor[1] += 0x40;
532 dlightcolor[2] += 0x10;
534 else if (ent->render.model->flags & EF_TRACER2)
536 CL_RocketTrail (oldorg, neworg, 5, ent);
537 dlightcolor[0] += 0x50;
538 dlightcolor[1] += 0x30;
539 dlightcolor[2] += 0x10;
541 else if (ent->render.model->flags & EF_ROCKET)
543 CL_RocketTrail (oldorg, ent->render.origin, 0, ent);
544 dlightcolor[0] += 200.0f;
545 dlightcolor[1] += 160.0f;
546 dlightcolor[2] += 80.0f;
548 else if (ent->render.model->flags & EF_GRENADE)
550 if (ent->render.alpha == -1) // LordHavoc: Nehahra dem compatibility
551 CL_RocketTrail (oldorg, neworg, 7, ent);
553 CL_RocketTrail (oldorg, neworg, 1, ent);
555 else if (ent->render.model->flags & EF_TRACER3)
557 CL_RocketTrail (oldorg, neworg, 6, ent);
558 dlightcolor[0] += 0x50;
559 dlightcolor[1] += 0x20;
560 dlightcolor[2] += 0x40;
564 // LordHavoc: customizable glow
565 glowsize = ent->state_current.glowsize; // FIXME: interpolate?
566 glowcolor = ent->state_current.glowcolor;
569 qbyte *tempcolor = (qbyte *)&d_8to24table[glowcolor];
570 // * 4 for the expansion from 0-255 to 0-1023 range,
571 // / 255 to scale down byte colors
572 glowsize *= (4.0f / 255.0f);
573 VectorMA(dlightcolor, glowsize, tempcolor, dlightcolor);
575 // LordHavoc: customizable trail
576 if (ent->render.flags & RENDER_GLOWTRAIL)
577 CL_RocketTrail2 (oldorg, neworg, glowcolor, ent);
579 if (dlightcolor[0] || dlightcolor[1] || dlightcolor[2])
582 VectorCopy(neworg, vec);
583 // hack to make glowing player light shine on their gun
584 if (i == cl.viewentity && !chase_active.integer)
586 CL_AllocDlight (NULL, vec, 1, dlightcolor[0], dlightcolor[1], dlightcolor[2], 0, 0);
589 if (chase_active.integer)
591 if (ent->render.flags & RENDER_VIEWMODEL)
596 if (i == cl.viewentity || (ent->render.flags & RENDER_EXTERIORMODEL))
600 if (ent->render.model == NULL)
602 if (effects & EF_NODRAW)
604 if (r_refdef.numentities < MAX_VISEDICTS)
605 r_refdef.entities[r_refdef.numentities++] = &ent->render;
609 void CL_LerpPlayer(float frac)
614 if (cl.entitydatabase.numframes)
616 cl.viewentorigin[0] = cl.viewentoriginold[0] + frac * (cl.viewentoriginnew[0] - cl.viewentoriginold[0]);
617 cl.viewentorigin[1] = cl.viewentoriginold[1] + frac * (cl.viewentoriginnew[1] - cl.viewentoriginold[1]);
618 cl.viewentorigin[2] = cl.viewentoriginold[2] + frac * (cl.viewentoriginnew[2] - cl.viewentoriginold[2]);
621 VectorCopy (cl_entities[cl.viewentity].render.origin, cl.viewentorigin);
623 cl.viewzoom = cl.viewzoomold + frac * (cl.viewzoomnew - cl.viewzoomold);
625 for (i = 0;i < 3;i++)
626 cl.velocity[i] = cl.mvelocity[1][i] + frac * (cl.mvelocity[0][i] - cl.mvelocity[1][i]);
628 if (cls.demoplayback)
630 // interpolate the angles
631 for (i = 0;i < 3;i++)
633 d = cl.mviewangles[0][i] - cl.mviewangles[1][i];
638 cl.viewangles[i] = cl.mviewangles[1][i] + frac*d;
643 void CL_Effect(vec3_t org, int modelindex, int startframe, int framecount, float framerate)
647 if (!modelindex) // sanity check
649 for (i = 0, e = cl_effect;i < MAX_EFFECTS;i++, e++)
654 VectorCopy(org, e->origin);
655 e->modelindex = modelindex;
656 e->starttime = cl.time;
657 e->startframe = startframe;
658 e->endframe = startframe + framecount;
659 e->framerate = framerate;
662 e->frame1time = cl.time;
663 e->frame2time = cl.time;
668 static void CL_RelinkEffects()
675 for (i = 0, e = cl_effect;i < MAX_EFFECTS;i++, e++)
679 frame = (cl.time - e->starttime) * e->framerate + e->startframe;
681 if (intframe < 0 || intframe >= e->endframe)
684 memset(e, 0, sizeof(*e));
688 if (intframe != e->frame)
691 e->frame1time = e->frame2time;
692 e->frame2time = cl.time;
695 if (r_draweffects.integer && (vis = CL_NewTempEntity()))
697 // interpolation stuff
698 vis->render.frame1 = intframe;
699 vis->render.frame2 = intframe + 1;
700 if (vis->render.frame2 >= e->endframe)
701 vis->render.frame2 = -1; // disappear
702 vis->render.framelerp = frame - intframe;
703 vis->render.frame1time = e->frame1time;
704 vis->render.frame2time = e->frame2time;
707 VectorCopy(e->origin, vis->render.origin);
708 vis->render.model = cl.model_precache[e->modelindex];
709 vis->render.frame = vis->render.frame2;
710 vis->render.colormap = -1; // no special coloring
711 vis->render.scale = 1;
712 vis->render.alpha = 1;
718 void CL_RelinkEntities (void)
722 // fraction from previous network update to current
723 frac = CL_LerpPoint ();
726 CL_RelinkStaticEntities();
727 CL_RelinkNetworkEntities();
728 CL_TraceLine_ScanForBModels();
741 Read all incoming data from the server
744 int CL_ReadFromServer (void)
748 cl.oldtime = cl.time;
749 cl.time += cl.frametime;
754 ret = CL_GetMessage ();
756 Host_Error ("CL_ReadFromServer: lost server connection");
760 cl.last_received_message = realtime;
762 if (cl_shownet.integer)
765 CL_ParseServerMessage ();
767 while (ret && cls.state == ca_connected);
772 r_refdef.numentities = 0;
773 if (cls.state == ca_connected && cl.worldmodel)
775 CL_RelinkEntities ();
777 // run cgame code (which can add more entities)
782 // bring the links up to date
792 void CL_SendCmd (void)
796 if (cls.state != ca_connected)
799 if (cls.signon == SIGNONS)
801 // get basic movement from keyboard
804 IN_PreMove(); // OS independent code
806 // allow mice or other external controllers to add to the move
809 IN_PostMove(); // OS independent code
811 // send the unreliable message
817 // LordHavoc: fix for NAT routing of netquake:
818 // bounce back a clc_nop message to the newly allocated server port,
819 // to establish a routing connection for incoming frames,
820 // the server waits for this before sending anything
821 if (realtime > cl.sendnoptime)
823 Con_DPrintf("sending clc_nop to get server's attention\n");
824 cl.sendnoptime = realtime + 3;
825 MSG_WriteByte(&cls.message, clc_nop);
830 if (cls.demoplayback)
832 SZ_Clear (&cls.message);
836 // send the reliable message
837 if (!cls.message.cursize)
838 return; // no message at all
840 if (!NET_CanSendMessage (cls.netcon))
842 Con_DPrintf ("CL_WriteToServer: can't send\n");
846 if (NET_SendMessage (cls.netcon, &cls.message) == -1)
847 Host_Error ("CL_WriteToServer: lost server connection");
849 SZ_Clear (&cls.message);
852 // LordHavoc: pausedemo command
853 static void CL_PauseDemo_f (void)
855 cls.demopaused = !cls.demopaused;
857 Con_Printf("Demo paused\n");
859 Con_Printf("Demo unpaused\n");
863 ======================
865 LordHavoc: Intended for Nehahra, I personally think this is dumb, but Mindcrime won't listen.
866 ======================
868 static void CL_PModel_f (void)
873 if (Cmd_Argc () == 1)
875 Con_Printf ("\"pmodel\" is \"%s\"\n", cl_pmodel.string);
878 i = atoi(Cmd_Argv(1));
880 if (cmd_source == src_command)
882 if (cl_pmodel.integer == i)
884 Cvar_SetValue ("_cl_pmodel", i);
885 if (cls.state == ca_connected)
886 Cmd_ForwardToServer ();
890 host_client->pmodel = i;
891 if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_pmodel)))
896 ======================
898 ======================
900 static void CL_Fog_f (void)
902 if (Cmd_Argc () == 1)
904 Con_Printf ("\"fog\" is \"%f %f %f %f\"\n", fog_density, fog_red, fog_green, fog_blue);
907 fog_density = atof(Cmd_Argv(1));
908 fog_red = atof(Cmd_Argv(2));
909 fog_green = atof(Cmd_Argv(3));
910 fog_blue = atof(Cmd_Argv(4));
920 cl_scores_mempool = Mem_AllocPool("client player info");
922 cl_refdef_mempool = Mem_AllocPool("refdef");
923 memset(&r_refdef, 0, sizeof(r_refdef));
924 r_refdef.entities = Mem_Alloc(cl_refdef_mempool, sizeof(entity_render_t *) * MAX_VISEDICTS);
926 SZ_Alloc (&cls.message, 1024, "cls.message");
932 // register our commands
934 Cvar_RegisterVariable (&cl_name);
935 Cvar_RegisterVariable (&cl_color);
936 if (gamemode == GAME_NEHAHRA)
937 Cvar_RegisterVariable (&cl_pmodel);
938 Cvar_RegisterVariable (&cl_upspeed);
939 Cvar_RegisterVariable (&cl_forwardspeed);
940 Cvar_RegisterVariable (&cl_backspeed);
941 Cvar_RegisterVariable (&cl_sidespeed);
942 Cvar_RegisterVariable (&cl_movespeedkey);
943 Cvar_RegisterVariable (&cl_yawspeed);
944 Cvar_RegisterVariable (&cl_pitchspeed);
945 Cvar_RegisterVariable (&cl_anglespeedkey);
946 Cvar_RegisterVariable (&cl_shownet);
947 Cvar_RegisterVariable (&cl_nolerp);
948 Cvar_RegisterVariable (&lookspring);
949 Cvar_RegisterVariable (&lookstrafe);
950 Cvar_RegisterVariable (&sensitivity);
951 Cvar_RegisterVariable (&freelook);
953 Cvar_RegisterVariable (&m_pitch);
954 Cvar_RegisterVariable (&m_yaw);
955 Cvar_RegisterVariable (&m_forward);
956 Cvar_RegisterVariable (&m_side);
958 Cvar_RegisterVariable (&cl_itembobspeed);
959 Cvar_RegisterVariable (&cl_itembobheight);
961 Cmd_AddCommand ("entities", CL_PrintEntities_f);
962 Cmd_AddCommand ("bitprofile", CL_BitProfile_f);
963 Cmd_AddCommand ("disconnect", CL_Disconnect_f);
964 Cmd_AddCommand ("record", CL_Record_f);
965 Cmd_AddCommand ("stop", CL_Stop_f);
966 Cmd_AddCommand ("playdemo", CL_PlayDemo_f);
967 Cmd_AddCommand ("timedemo", CL_TimeDemo_f);
969 Cmd_AddCommand ("fog", CL_Fog_f);
971 // LordHavoc: added pausedemo
972 Cmd_AddCommand ("pausedemo", CL_PauseDemo_f);
973 if (gamemode == GAME_NEHAHRA)
974 Cmd_AddCommand ("pmodel", CL_PModel_f);
976 Cvar_RegisterVariable(&r_draweffects);
977 Cvar_RegisterVariable(&cl_explosions);
978 Cvar_RegisterVariable(&cl_stainmaps);