changed texture slots in use message (developer mode only) to not mention glquake
[xonotic/darkplaces.git] / cl_main.c
1 /*
2 Copyright (C) 1996-1997 Id Software, Inc.
3
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.
8
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.  
12
13 See the GNU General Public License for more details.
14
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.
18
19 */
20 // cl_main.c  -- client main loop
21
22 #include "quakedef.h"
23
24 // we need to declare some mouse variables here, because the menu system
25 // references them even when on a unix system.
26
27 // these two are not intended to be set directly
28 cvar_t  cl_name = {"_cl_name", "player", true};
29 cvar_t  cl_color = {"_cl_color", "0", true};
30 cvar_t  cl_pmodel = {"_cl_pmodel", "0", true};
31
32 cvar_t  cl_shownet = {"cl_shownet","0"};        // can be 0, 1, or 2
33 cvar_t  cl_nolerp = {"cl_nolerp","0"};
34
35 cvar_t  lookspring = {"lookspring","0", true};
36 cvar_t  lookstrafe = {"lookstrafe","0", true};
37 cvar_t  sensitivity = {"sensitivity","3", true};
38
39 cvar_t  m_pitch = {"m_pitch","0.022", true};
40 cvar_t  m_yaw = {"m_yaw","0.022", true};
41 cvar_t  m_forward = {"m_forward","1", true};
42 cvar_t  m_side = {"m_side","0.8", true};
43
44
45 client_static_t cls;
46 client_state_t  cl;
47 // FIXME: put these on hunk?
48 efrag_t                 cl_efrags[MAX_EFRAGS];
49 entity_t                cl_entities[MAX_EDICTS];
50 entity_t                cl_static_entities[MAX_STATIC_ENTITIES];
51 lightstyle_t    cl_lightstyle[MAX_LIGHTSTYLES];
52 dlight_t                cl_dlights[MAX_DLIGHTS];
53
54 int                             cl_numvisedicts;
55 entity_t                *cl_visedicts[MAX_VISEDICTS];
56
57 /*
58 =====================
59 CL_ClearState
60
61 =====================
62 */
63 void CL_ClearState (void)
64 {
65         int                     i;
66
67         if (!sv.active)
68                 Host_ClearMemory ();
69
70 // wipe the entire cl structure
71         memset (&cl, 0, sizeof(cl));
72
73         SZ_Clear (&cls.message);
74
75 // clear other arrays   
76         memset (cl_efrags, 0, sizeof(cl_efrags));
77         memset (cl_entities, 0, sizeof(cl_entities));
78         memset (cl_dlights, 0, sizeof(cl_dlights));
79         memset (cl_lightstyle, 0, sizeof(cl_lightstyle));
80         memset (cl_temp_entities, 0, sizeof(cl_temp_entities));
81         memset (cl_beams, 0, sizeof(cl_beams));
82         // LordHavoc: have to set up the baseline info for alpha and other stuff
83         for (i = 0;i < MAX_EDICTS;i++)
84         {
85                 cl_entities[i].baseline.alpha = 255;
86                 cl_entities[i].baseline.scale = 16;
87                 cl_entities[i].baseline.glowsize = 0;
88                 cl_entities[i].baseline.glowcolor = 254;
89                 cl_entities[i].baseline.colormod = 255;
90         }
91
92 //
93 // allocate the efrags and chain together into a free list
94 //
95         cl.free_efrags = cl_efrags;
96         for (i=0 ; i<MAX_EFRAGS-1 ; i++)
97                 cl.free_efrags[i].entnext = &cl.free_efrags[i+1];
98         cl.free_efrags[i].entnext = NULL;
99 }
100
101 /*
102 =====================
103 CL_Disconnect
104
105 Sends a disconnect message to the server
106 This is also called on Host_Error, so it shouldn't cause any errors
107 =====================
108 */
109 void CL_Disconnect (void)
110 {
111 // stop sounds (especially looping!)
112         S_StopAllSounds (true);
113         
114 // bring the console down and fade the colors back to normal
115 //      SCR_BringDownConsole ();
116
117 // if running a local server, shut it down
118         if (cls.demoplayback)
119                 CL_StopPlayback ();
120         else if (cls.state == ca_connected)
121         {
122                 if (cls.demorecording)
123                         CL_Stop_f ();
124
125                 Con_DPrintf ("Sending clc_disconnect\n");
126                 SZ_Clear (&cls.message);
127                 MSG_WriteByte (&cls.message, clc_disconnect);
128                 NET_SendUnreliableMessage (cls.netcon, &cls.message);
129                 SZ_Clear (&cls.message);
130                 NET_Close (cls.netcon);
131
132                 cls.state = ca_disconnected;
133                 if (sv.active)
134                         Host_ShutdownServer(false);
135         }
136
137         cls.demoplayback = cls.timedemo = false;
138         cls.signon = 0;
139 }
140
141 void CL_Disconnect_f (void)
142 {
143         CL_Disconnect ();
144         if (sv.active)
145                 Host_ShutdownServer (false);
146 }
147
148
149
150
151 /*
152 =====================
153 CL_EstablishConnection
154
155 Host should be either "local" or a net address to be passed on
156 =====================
157 */
158 void CL_EstablishConnection (char *host)
159 {
160         if (cls.state == ca_dedicated)
161                 return;
162
163         if (cls.demoplayback)
164                 return;
165
166         CL_Disconnect ();
167
168         cls.netcon = NET_Connect (host);
169         if (!cls.netcon)
170                 Host_Error ("CL_Connect: connect failed\n");
171         Con_DPrintf ("CL_EstablishConnection: connected to %s\n", host);
172         
173         cls.demonum = -1;                       // not in the demo loop now
174         cls.state = ca_connected;
175         cls.signon = 0;                         // need all the signon messages before playing
176 }
177
178 extern int numgltextures;
179 extern int texels;
180
181 /*
182 =====================
183 CL_SignonReply
184
185 An svc_signonnum has been received, perform a client side setup
186 =====================
187 */
188 void CL_SignonReply (void)
189 {
190         char    str[8192];
191
192 Con_DPrintf ("CL_SignonReply: %i\n", cls.signon);
193
194         switch (cls.signon)
195         {
196         case 1:
197                 MSG_WriteByte (&cls.message, clc_stringcmd);
198                 MSG_WriteString (&cls.message, "prespawn");
199                 break;
200                 
201         case 2:
202                 MSG_WriteByte (&cls.message, clc_stringcmd);
203                 MSG_WriteString (&cls.message, va("name \"%s\"\n", cl_name.string));
204
205                 MSG_WriteByte (&cls.message, clc_stringcmd);
206                 MSG_WriteString (&cls.message, va("color %i %i\n", ((int)cl_color.value)>>4, ((int)cl_color.value)&15));
207         
208                 if (cl_pmodel.value)
209                 {
210                         MSG_WriteByte (&cls.message, clc_stringcmd);
211                         MSG_WriteString (&cls.message, va("pmodel %f\n", cl_pmodel.value));
212                 }
213
214                 MSG_WriteByte (&cls.message, clc_stringcmd);
215                 sprintf (str, "spawn %s", cls.spawnparms);
216                 MSG_WriteString (&cls.message, str);
217                 break;
218                 
219         case 3: 
220                 MSG_WriteByte (&cls.message, clc_stringcmd);
221                 MSG_WriteString (&cls.message, "begin");
222                 Cache_Report ();                // print remaining memory
223                 break;
224                 
225         case 4:
226                 SCR_EndLoadingPlaque ();                // allow normal screen updates
227                 // LordHavoc: debugging purposes
228                 Con_DPrintf("Texture slots in use: %i : %i : %i texels\n", texture_extension_number, numgltextures, texels);
229                 break;
230         }
231 }
232
233 /*
234 =====================
235 CL_NextDemo
236
237 Called to play the next demo in the demo loop
238 =====================
239 */
240 void CL_NextDemo (void)
241 {
242         char    str[1024];
243
244         if (cls.demonum == -1)
245                 return;         // don't play demos
246
247         SCR_BeginLoadingPlaque ();
248
249         if (!cls.demos[cls.demonum][0] || cls.demonum == MAX_DEMOS)
250         {
251                 cls.demonum = 0;
252                 if (!cls.demos[cls.demonum][0])
253                 {
254                         Con_Printf ("No demos listed with startdemos\n");
255                         cls.demonum = -1;
256                         return;
257                 }
258         }
259
260         sprintf (str,"playdemo %s\n", cls.demos[cls.demonum]);
261         Cbuf_InsertText (str);
262         cls.demonum++;
263 }
264
265 /*
266 ==============
267 CL_PrintEntities_f
268 ==============
269 */
270 void CL_PrintEntities_f (void)
271 {
272         entity_t        *ent;
273         int                     i;
274         
275         for (i=0,ent=cl_entities ; i<cl.num_entities ; i++,ent++)
276         {
277                 Con_Printf ("%3i:",i);
278                 if (!ent->model)
279                 {
280                         Con_Printf ("EMPTY\n");
281                         continue;
282                 }
283                 Con_Printf ("%s:%2i  (%5.1f,%5.1f,%5.1f) [%5.1f %5.1f %5.1f]\n"
284                 ,ent->model->name,ent->frame, ent->origin[0], ent->origin[1], ent->origin[2], ent->angles[0], ent->angles[1], ent->angles[2]);
285         }
286 }
287
288
289 /*
290 ===============
291 CL_AllocDlight
292
293 ===============
294 */
295 dlight_t *CL_AllocDlight (int key)
296 {
297         int             i;
298         dlight_t        *dl;
299
300 // first look for an exact key match
301         if (key)
302         {
303                 dl = cl_dlights;
304                 for (i=0 ; i<MAX_DLIGHTS ; i++, dl++)
305                 {
306                         if (dl->key == key)
307                         {
308                                 memset (dl, 0, sizeof(*dl));
309                                 dl->key = key;
310                                 return dl;
311                         }
312                 }
313         }
314
315 // then look for anything else
316         dl = cl_dlights;
317         for (i=0 ; i<MAX_DLIGHTS ; i++, dl++)
318         {
319                 if (dl->die < cl.time)
320                 {
321                         memset (dl, 0, sizeof(*dl));
322                         dl->key = key;
323                         return dl;
324                 }
325         }
326
327         dl = &cl_dlights[0];
328         memset (dl, 0, sizeof(*dl));
329         dl->key = key;
330         return dl;
331 }
332
333
334 /*
335 ===============
336 CL_DecayLights
337
338 ===============
339 */
340 void CL_DecayLights (void)
341 {
342         int                     i;
343         dlight_t        *dl;
344         float           time;
345         
346         time = cl.time - cl.oldtime;
347
348         dl = cl_dlights;
349         for (i=0 ; i<MAX_DLIGHTS ; i++, dl++)
350         {
351                 if (dl->die < cl.time || !dl->radius)
352                         continue;
353                 
354                 dl->radius -= time*dl->decay;
355                 if (dl->radius < 0)
356                         dl->radius = 0;
357         }
358 }
359
360
361 /*
362 ===============
363 CL_LerpPoint
364
365 Determines the fraction between the last two messages that the objects
366 should be put at.
367 ===============
368 */
369 float   CL_LerpPoint (void)
370 {
371         float   f, frac;
372
373         f = cl.mtime[0] - cl.mtime[1];
374         
375         if (!f || cl_nolerp.value || cls.timedemo || sv.active)
376         {
377                 cl.time = cl.mtime[0];
378                 return 1;
379         }
380                 
381         if (f > 0.1)
382         {       // dropped packet, or start of demo
383                 cl.mtime[1] = cl.mtime[0] - 0.1;
384                 f = 0.1;
385         }
386         frac = (cl.time - cl.mtime[1]) / f;
387 //Con_Printf ("frac: %f\n",frac);
388         if (frac < 0)
389         {
390                 if (frac < -0.01)
391                 {
392                         cl.time = cl.mtime[1];
393 //                              Con_Printf ("low frac\n");
394                 }
395                 frac = 0;
396         }
397         else if (frac > 1)
398         {
399                 if (frac > 1.01)
400                 {
401                         cl.time = cl.mtime[0];
402 //                              Con_Printf ("high frac\n");
403                 }
404                 frac = 1;
405         }
406                 
407         return frac;
408 }
409
410
411 /*
412 ===============
413 CL_RelinkEntities
414 ===============
415 */
416 void R_RocketTrail2 (vec3_t start, vec3_t end, int color, entity_t *ent);
417 void CL_RelinkEntities (void)
418 {
419         entity_t        *ent;
420         int                     i, j;
421         float           frac, f, d;
422         vec3_t          delta;
423         float           bobjrotate;
424         vec3_t          oldorg;
425         dlight_t        *dl;
426         byte            *tempcolor;
427
428 // determine partial update time        
429         frac = CL_LerpPoint ();
430
431         cl_numvisedicts = 0;
432
433 //
434 // interpolate player info
435 //
436         for (i=0 ; i<3 ; i++)
437                 cl.velocity[i] = cl.mvelocity[1][i] + frac * (cl.mvelocity[0][i] - cl.mvelocity[1][i]);
438
439         if (cls.demoplayback)
440         {
441         // interpolate the angles       
442                 for (j=0 ; j<3 ; j++)
443                 {
444                         d = cl.mviewangles[0][j] - cl.mviewangles[1][j];
445                         if (d > 180)
446                                 d -= 360;
447                         else if (d < -180)
448                                 d += 360;
449                         cl.viewangles[j] = cl.mviewangles[1][j] + frac*d;
450                 }
451         }
452         
453         bobjrotate = anglemod(100*cl.time);
454         
455 // start on the entity after the world
456         for (i=1,ent=cl_entities+1 ; i<cl.num_entities ; i++,ent++)
457         {
458                 if (!ent->model)
459                 {       // empty slot
460                         if (ent->forcelink)
461                                 R_RemoveEfrags (ent);   // just became empty
462                         continue;
463                 }
464
465 // if the object wasn't included in the last packet, remove it
466                 if (ent->msgtime != cl.mtime[0])
467                 {
468                         ent->model = NULL;
469                         // LordHavoc: free on the same frame, not the next
470                         if (ent->forcelink)
471                                 R_RemoveEfrags (ent);   // just became empty
472                         continue;
473                 }
474
475                 // LordHavoc: animation interpolation, note: framegroups partially override this in the renderer
476                 /*
477                 if (ent->model != ent->lerp_model || ent->lerp_time > cl.time)
478                 {
479                         ent->lerp_frame1 = ent->lerp_frame2 = ent->frame;
480                         ent->lerp_time = cl.time;
481                         ent->lerp = 0;
482                 }
483                 else if (ent->frame != ent->lerp_frame2)
484                 {
485                         ent->lerp_frame1 = ent->lerpframe2;
486                         ent->lerp_frame2 = ent->frame;
487                         ent->lerp_time = cl.time;
488                         ent->lerp = 0;
489                 }
490                 else
491                         ent->lerp = bound(0, (cl.time - ent->lerp_time) * 10.0f, 1);
492                 */
493
494                 VectorCopy (ent->origin, oldorg);
495
496                 if (ent->forcelink)
497                 {       // the entity was not updated in the last message
498                         // so move to the final spot
499                         VectorCopy (ent->msg_origins[0], ent->origin);
500                         VectorCopy (ent->msg_angles[0], ent->angles);
501                 }
502                 else
503                 {       // if the delta is large, assume a teleport and don't lerp
504                         f = frac;
505                         for (j=0 ; j<3 ; j++)
506                         {
507                                 delta[j] = ent->msg_origins[0][j] - ent->msg_origins[1][j];
508                                 // LordHavoc: increased lerp tolerance from 100 to 200
509                                 if (delta[j] > 200 || delta[j] < -200)
510                                         f = 1;          // assume a teleportation, not a motion
511                         }
512
513                 // interpolate the origin and angles
514                         for (j=0 ; j<3 ; j++)
515                         {
516                                 ent->origin[j] = ent->msg_origins[1][j] + f*delta[j];
517
518                                 d = ent->msg_angles[0][j] - ent->msg_angles[1][j];
519                                 if (d > 180)
520                                         d -= 360;
521                                 else if (d < -180)
522                                         d += 360;
523                                 ent->angles[j] = ent->msg_angles[1][j] + f*d;
524                         }
525                         
526                 }
527
528                 if (ent->effects & EF_BRIGHTFIELD)
529                         R_EntityParticles (ent);
530                 if (ent->effects & EF_MUZZLEFLASH)
531                 {
532                         vec3_t          fv, rv, uv;
533
534                         dl = CL_AllocDlight (i);
535                         VectorCopy (ent->origin,  dl->origin);
536                         dl->origin[2] += 16;
537                         AngleVectors (ent->angles, fv, rv, uv);
538                          
539                         VectorMA (dl->origin, 18, fv, dl->origin);
540                         dl->radius = 200 + (rand()&31);
541                         dl->minlight = 32;
542                         dl->die = cl.time + 0.1;
543                         dl->color[0] = 1.0;dl->color[1] = 1.0;dl->color[2] = 1.0;
544                 }
545                 if (ent->effects & EF_BRIGHTLIGHT)
546                 {                       
547                         dl = CL_AllocDlight (i);
548                         VectorCopy (ent->origin,  dl->origin);
549                         dl->origin[2] += 16;
550                         dl->radius = 400 + (rand()&31);
551                         dl->die = cl.time + 0.001;
552                         dl->color[0] = 1.0;dl->color[1] = 1.0;dl->color[2] = 1.0;
553                 }
554                 if (ent->effects & EF_DIMLIGHT)
555                 {                       
556                         dl = CL_AllocDlight (i);
557                         VectorCopy (ent->origin,  dl->origin);
558                         dl->radius = 200 + (rand()&31);
559                         dl->die = cl.time + 0.001;
560                         dl->color[0] = 1.0;dl->color[1] = 1.0;dl->color[2] = 1.0;
561                 }
562                 // LordHavoc: added EF_RED and EF_BLUE
563                 if (ent->effects & EF_RED) // red
564                 {                       
565                         if (ent->effects & EF_BLUE) // magenta
566                         {
567                                 dl = CL_AllocDlight (i);
568                                 VectorCopy (ent->origin,  dl->origin);
569                                 dl->radius = 200 + (rand()&31);
570                                 dl->die = cl.time + 0.001;
571                                 dl->color[0] = 0.7;dl->color[1] = 0.07;dl->color[2] = 0.7;
572                         }
573                         else // red
574                         {
575                                 dl = CL_AllocDlight (i);
576                                 VectorCopy (ent->origin,  dl->origin);
577                                 dl->radius = 200 + (rand()&31);
578                                 dl->die = cl.time + 0.001;
579                                 dl->color[0] = 0.8;dl->color[1] = 0.05;dl->color[2] = 0.05;
580                         }
581                 }
582                 else if (ent->effects & EF_BLUE) // blue
583                 {
584                         dl = CL_AllocDlight (i);
585                         VectorCopy (ent->origin,  dl->origin);
586                         dl->radius = 200 + (rand()&31);
587                         dl->die = cl.time + 0.001;
588                         dl->color[0] = 0.05;dl->color[1] = 0.05;dl->color[2] = 0.8;
589                 }
590
591                 if (ent->model->flags) // LordHavoc: if the model has no flags, don't check each
592                 {
593                 // rotate binary objects locally
594                         if (ent->model->flags & EF_ROTATE)
595                                 ent->angles[1] = bobjrotate;
596                         if (ent->model->flags & EF_GIB)
597                                 R_RocketTrail (oldorg, ent->origin, 2, ent);
598                         else if (ent->model->flags & EF_ZOMGIB)
599                                 R_RocketTrail (oldorg, ent->origin, 4, ent);
600                         else if (ent->model->flags & EF_TRACER)
601                                 R_RocketTrail (oldorg, ent->origin, 3, ent);
602                         else if (ent->model->flags & EF_TRACER2)
603                                 R_RocketTrail (oldorg, ent->origin, 5, ent);
604                         else if (ent->model->flags & EF_ROCKET)
605                         {
606                                 R_RocketTrail (oldorg, ent->origin, 0, ent);
607                                 dl = CL_AllocDlight (i);
608                                 VectorCopy (ent->origin, dl->origin);
609                                 dl->radius = 200;
610                                 dl->die = cl.time + 0.001;
611                                 dl->color[0] = 1.0;dl->color[1] = 0.8;dl->color[2] = 0.4;
612                         }
613                         else if (ent->model->flags & EF_GRENADE)
614                         {
615                                 if (ent->alpha == -1) // LordHavoc: Nehahra dem compatibility
616                                         R_RocketTrail (oldorg, ent->origin, 7, ent);
617                                 else
618                                         R_RocketTrail (oldorg, ent->origin, 1, ent);
619                         }
620                         else if (ent->model->flags & EF_TRACER3)
621                                 R_RocketTrail (oldorg, ent->origin, 6, ent);
622                 }
623                 if (ent->glowsize) // LordHavoc: customizable glow
624                 {
625                         dl = CL_AllocDlight (i);
626                         VectorCopy (ent->origin, dl->origin);
627                         dl->radius = ent->glowsize;
628                         dl->die = cl.time + 0.001;
629                         tempcolor = (byte *)&d_8to24table[ent->glowcolor];
630                         dl->color[0] = tempcolor[0]*(1.0/255.0);dl->color[1] = tempcolor[1]*(1.0/255.0);dl->color[2] = tempcolor[2]*(1.0/255.0);
631                 }
632                 if (ent->glowtrail) // LordHavoc: customizable glow and trail
633                         R_RocketTrail2 (oldorg, ent->origin, ent->glowcolor, ent);
634
635                 ent->forcelink = false;
636
637                 if (i == cl.viewentity && !chase_active.value)
638                         continue;
639
640 // LordHavoc: enabled EF_NODRAW
641                 if (!ent->model || ent->effects & EF_NODRAW)
642                         continue;
643                 if (cl_numvisedicts < MAX_VISEDICTS)
644                 {
645                         cl_visedicts[cl_numvisedicts] = ent;
646                         cl_numvisedicts++;
647                 }
648         }
649
650 }
651
652
653 /*
654 ===============
655 CL_ReadFromServer
656
657 Read all incoming data from the server
658 ===============
659 */
660 int CL_ReadFromServer (void)
661 {
662         int             ret;
663
664         cl.oldtime = cl.time;
665         cl.time += host_frametime;
666         
667         do
668         {
669                 ret = CL_GetMessage ();
670                 if (ret == -1)
671                         Host_Error ("CL_ReadFromServer: lost server connection");
672                 if (!ret)
673                         break;
674                 
675                 cl.last_received_message = realtime;
676                 CL_ParseServerMessage ();
677         } while (ret && cls.state == ca_connected);
678         
679         if (cl_shownet.value)
680                 Con_Printf ("\n");
681
682         CL_RelinkEntities ();
683         CL_UpdateTEnts ();
684
685 //
686 // bring the links up to date
687 //
688         return 0;
689 }
690
691 /*
692 =================
693 CL_SendCmd
694 =================
695 */
696 void CL_SendCmd (void)
697 {
698         usercmd_t               cmd;
699
700         if (cls.state != ca_connected)
701                 return;
702
703         if (cls.signon == SIGNONS)
704         {
705         // get basic movement from keyboard
706                 CL_BaseMove (&cmd);
707         
708         // allow mice or other external controllers to add to the move
709                 IN_Move (&cmd);
710         
711         // send the unreliable message
712                 CL_SendMove (&cmd);
713         
714         }
715
716         if (cls.demoplayback)
717         {
718                 SZ_Clear (&cls.message);
719                 return;
720         }
721         
722 // send the reliable message
723         if (!cls.message.cursize)
724                 return;         // no message at all
725         
726         if (!NET_CanSendMessage (cls.netcon))
727         {
728                 Con_DPrintf ("CL_WriteToServer: can't send\n");
729                 return;
730         }
731
732         if (NET_SendMessage (cls.netcon, &cls.message) == -1)
733                 Host_Error ("CL_WriteToServer: lost server connection");
734
735         SZ_Clear (&cls.message);
736 }
737
738 // LordHavoc: pausedemo command
739 void CL_PauseDemo_f (void)
740 {
741         cls.demopaused = !cls.demopaused;
742         if (cls.demopaused)
743                 Con_Printf("Demo paused\n");
744         else
745                 Con_Printf("Demo unpaused\n");
746 }
747
748 /*
749 ======================
750 CL_PModel_f
751 LordHavoc: Intended for Nehahra, I personally think this is dumb, but Mindcrime won't listen.
752 ======================
753 */
754 void CL_PModel_f (void)
755 {
756         int i;
757         eval_t *val;
758
759         if (Cmd_Argc () == 1)
760         {
761                 Con_Printf ("\"pmodel\" is \"%s\"\n", cl_pmodel.string);
762                 return;
763         }
764         i = atoi(Cmd_Argv(1));
765
766         if (cmd_source == src_command)
767         {
768                 if (cl_pmodel.value == i)
769                         return;
770                 Cvar_SetValue ("_cl_pmodel", i);
771                 if (cls.state == ca_connected)
772                         Cmd_ForwardToServer ();
773                 return;
774         }
775
776         host_client->pmodel = i;
777         if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_pmodel)))
778                 val->_float = i;
779 }
780
781 /*
782 ======================
783 CL_Fog_f
784 ======================
785 */
786 extern float fog_density, fog_red, fog_green, fog_blue;
787 void CL_Fog_f (void)
788 {
789         if (Cmd_Argc () == 1)
790         {
791                 Con_Printf ("\"fog\" is \"%f %f %f %f\"\n", fog_density, fog_red, fog_green, fog_blue);
792                 return;
793         }
794         fog_density = atof(Cmd_Argv(1));
795         fog_red = atof(Cmd_Argv(2));
796         fog_green = atof(Cmd_Argv(3));
797         fog_blue = atof(Cmd_Argv(4));
798 }
799
800 cvar_t demo_nehahra = {"demo_nehahra", "0"};
801
802 /*
803 =================
804 CL_Init
805 =================
806 */
807 void CL_Init (void)
808 {       
809         SZ_Alloc (&cls.message, 1024);
810
811         CL_InitInput ();
812         CL_InitTEnts ();
813         
814 //
815 // register our commands
816 //
817         Cvar_RegisterVariable (&cl_name);
818         Cvar_RegisterVariable (&cl_color);
819         Cvar_RegisterVariable (&cl_pmodel);
820         Cvar_RegisterVariable (&cl_upspeed);
821         Cvar_RegisterVariable (&cl_forwardspeed);
822         Cvar_RegisterVariable (&cl_backspeed);
823         Cvar_RegisterVariable (&cl_sidespeed);
824         Cvar_RegisterVariable (&cl_movespeedkey);
825         Cvar_RegisterVariable (&cl_yawspeed);
826         Cvar_RegisterVariable (&cl_pitchspeed);
827         Cvar_RegisterVariable (&cl_anglespeedkey);
828         Cvar_RegisterVariable (&cl_shownet);
829         Cvar_RegisterVariable (&cl_nolerp);
830         Cvar_RegisterVariable (&lookspring);
831         Cvar_RegisterVariable (&lookstrafe);
832         Cvar_RegisterVariable (&sensitivity);
833
834         Cvar_RegisterVariable (&m_pitch);
835         Cvar_RegisterVariable (&m_yaw);
836         Cvar_RegisterVariable (&m_forward);
837         Cvar_RegisterVariable (&m_side);
838
839 //      Cvar_RegisterVariable (&cl_autofire);
840         
841         Cmd_AddCommand ("entities", CL_PrintEntities_f);
842         Cmd_AddCommand ("disconnect", CL_Disconnect_f);
843         Cmd_AddCommand ("record", CL_Record_f);
844         Cmd_AddCommand ("stop", CL_Stop_f);
845         Cmd_AddCommand ("playdemo", CL_PlayDemo_f);
846         Cmd_AddCommand ("timedemo", CL_TimeDemo_f);
847
848         Cmd_AddCommand ("fog", CL_Fog_f);
849
850         // LordHavoc: added pausedemo
851         Cmd_AddCommand ("pausedemo", CL_PauseDemo_f);
852         // LordHavoc: added pmodel command (like name, etc, only intended for Nehahra)
853         Cmd_AddCommand ("pmodel", CL_PModel_f);
854         // LordHavoc: added demo_nehahra cvar
855         Cvar_RegisterVariable (&demo_nehahra);
856         if (nehahra)
857                 Cvar_SetValue("demo_nehahra", 1);
858 }
859