Add a help for quickmenu command
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / main.qc
1 #include "main.qh"
2 #include "_all.qh"
3
4 #include "controlpoint.qh"
5 #include "csqcmodel_hooks.qh"
6 #include "damage.qh"
7 #include "effects.qh"
8 #include "generator.qh"
9 #include "gibs.qh"
10 #include "hook.qh"
11 #include "hud.qh"
12 #include "hud_config.qh"
13 #include "laser.qh"
14 #include "mapvoting.qh"
15 #include "modeleffects.qh"
16 #include "particles.qh"
17 #include "scoreboard.qh"
18 #include "shownames.qh"
19 #include "tuba.qh"
20 #include "t_items.qh"
21 #include "wall.qh"
22
23 #include "../common/vehicles/all.qh"
24
25 #include "mutators/events.qh"
26
27 #include "weapons/projectile.qh"
28
29 #include "../common/buffs.qh"
30 #include "../common/deathtypes.qh"
31 #include "../common/effects.qh"
32 #include "../common/mapinfo.qh"
33 #include "../common/monsters/all.qh"
34 #include "../common/nades.qh"
35 #include "../common/net_notice.qh"
36 #include "../common/notifications.qh"
37 #include "../common/stats.qh"
38 #include "../common/teams.qh"
39
40 #include "../common/items/all.qh"
41
42 #include "../common/mutators/base.qh"
43
44 #include "../common/weapons/all.qh"
45
46 #include "../csqcmodellib/cl_model.qh"
47 #include "../csqcmodellib/interpolate.qh"
48
49 #include "../common/triggers/include.qh"
50
51 #include "../common/turrets/cl_turrets.qh"
52 #include "../common/turrets/turrets.qh"
53
54 #include "../warpzonelib/client.qh"
55
56 // --------------------------------------------------------------------------
57 // BEGIN REQUIRED CSQC FUNCTIONS
58 //include "main.qh"
59
60 entity clearentity_ent;
61 void clearentity(entity e)
62 {
63         if (!clearentity_ent)
64         {
65                 clearentity_ent = spawn();
66                 clearentity_ent.classname = "clearentity";
67         }
68         int n = e.entnum;
69         copyentity(clearentity_ent, e);
70         e.entnum = n;
71 }
72
73 #define DP_CSQC_ENTITY_REMOVE_IS_B0RKED
74 void menu_show_error()
75 {
76         drawstring('0 200 0', _("ERROR - MENU IS VISIBLE BUT NO MENU WAS DEFINED!"), '8 8 0', '1 0 0', 1, 0);
77 }
78
79 // CSQC_Init : Called every time the CSQC code is initialized (essentially at map load)
80 // Useful for precaching things
81
82 void menu_sub_null()
83 {
84 }
85
86 string forcefog;
87 void ConsoleCommand_macro_init();
88 void CSQC_Init(void)
89 {
90         prvm_language = strzone(cvar_string("prvm_language"));
91
92 #ifdef WATERMARK
93         dprintf("^4CSQC Build information: ^1%s\n", WATERMARK);
94 #endif
95
96         int i;
97
98         binddb = db_create();
99         tempdb = db_create();
100         ClientProgsDB = db_load("client.db");
101         compressShortVector_init();
102
103         draw_endBoldFont();
104         menu_visible = false;
105         menu_show = menu_show_error;
106         menu_action = func_null;
107
108         for(i = 0; i < 255; ++i)
109                 if(getplayerkeyvalue(i, "viewentity") == "")
110                         break;
111         maxclients = i;
112
113         //registercommand("hud_configure");
114         //registercommand("hud_save");
115         //registercommand("menu_action");
116
117         ConsoleCommand_macro_init();
118
119         registercvar("hud_usecsqc", "1");
120         registercvar("scoreboard_columns", "default");
121
122         registercvar("cl_nade_type", "3");
123         registercvar("cl_pokenade_type", "zombie");
124
125         registercvar("cl_jumpspeedcap_min", "");
126         registercvar("cl_jumpspeedcap_max", "");
127
128         gametype = 0;
129
130         // hud_fields uses strunzone on the titles!
131         for(i = 0; i < MAX_HUD_FIELDS; ++i)
132                 hud_title[i] = strzone("(null)");
133
134         Cmd_HUD_SetFields(0);
135
136         postinit = false;
137
138         calledhooks = 0;
139
140         teams = Sort_Spawn();
141         players = Sort_Spawn();
142
143         GetTeam(NUM_SPECTATOR, true); // add specs first
144
145         // needs to be done so early because of the constants they create
146         static_init();
147         CALL_ACCUMULATED_FUNCTION(RegisterTurrets);
148         CALL_ACCUMULATED_FUNCTION(RegisterNotifications);
149         CALL_ACCUMULATED_FUNCTION(RegisterDeathtypes);
150         CALL_ACCUMULATED_FUNCTION(RegisterHUD_Panels);
151         CALL_ACCUMULATED_FUNCTION(RegisterEffects);
152
153         initialize_minigames();
154
155         // precaches
156         precache_model("null");
157         precache_sound("misc/hit.wav");
158         precache_sound("misc/typehit.wav");
159
160         generator_precache();
161         Projectile_Precache();
162         Hook_Precache();
163         GibSplash_Precache();
164         Tuba_Precache();
165         CSQCPlayer_Precache();
166
167         if(autocvar_cl_reticle)
168         {
169                 precache_pic("gfx/reticle_normal");
170                 // weapon reticles are precached in weapon files
171         }
172
173         get_mi_min_max_texcoords(1); // try the CLEVER way first
174         minimapname = strcat("gfx/", mi_shortname, "_radar.tga");
175         shortmapname = mi_shortname;
176
177         if(precache_pic(minimapname) == "")
178         {
179                 // but maybe we have a non-clever minimap
180                 minimapname = strcat("gfx/", mi_shortname, "_mini.tga");
181                 if(precache_pic(minimapname) == "")
182                         minimapname = ""; // FAIL
183                 else
184                         get_mi_min_max_texcoords(0); // load new texcoords
185         }
186
187         mi_center = (mi_min + mi_max) * 0.5;
188         mi_scale = mi_max - mi_min;
189         minimapname = strzone(minimapname);
190
191         WarpZone_Init();
192
193         hud_skin_path = strzone(strcat("gfx/hud/", autocvar_hud_skin));
194         draw_currentSkin = strzone(strcat("gfx/menu/", cvar_string("menu_skin")));
195 }
196
197 // CSQC_Shutdown : Called every time the CSQC code is shutdown (changing maps, quitting, etc)
198 void Shutdown(void)
199 {
200         WarpZone_Shutdown();
201
202         remove(teams);
203         remove(players);
204         db_close(binddb);
205         db_close(tempdb);
206         if(autocvar_cl_db_saveasdump)
207                 db_dump(ClientProgsDB, "client.db");
208         else
209                 db_save(ClientProgsDB, "client.db");
210         db_close(ClientProgsDB);
211
212         if(camera_active)
213                 cvar_set("chase_active",ftos(chase_active_backup));
214
215         // unset the event chasecam's chase_active
216         if(autocvar_chase_active < 0)
217                 cvar_set("chase_active", "0");
218
219         if (!isdemo())
220         {
221                 if (!(calledhooks & HOOK_START))
222                         localcmd("\n_cl_hook_gamestart nop\n");
223                 if (!(calledhooks & HOOK_END))
224                         localcmd("\ncl_hook_gameend\n");
225         }
226
227         deactivate_minigame();
228         HUD_MinigameMenu_Close();
229 }
230
231 .float has_team;
232 float SetTeam(entity o, int Team)
233 {
234         entity tm;
235         if(teamplay)
236         {
237                 switch(Team)
238                 {
239                         case -1:
240                         case NUM_TEAM_1:
241                         case NUM_TEAM_2:
242                         case NUM_TEAM_3:
243                         case NUM_TEAM_4:
244                                 break;
245                         default:
246                                 if(GetTeam(Team, false) == world)
247                                 {
248                                         dprintf("trying to switch to unsupported team %d\n", Team);
249                                         Team = NUM_SPECTATOR;
250                                 }
251                                 break;
252                 }
253         }
254         else
255         {
256                 switch(Team)
257                 {
258                         case -1:
259                         case 0:
260                                 break;
261                         default:
262                                 if(GetTeam(Team, false) == world)
263                                 {
264                                         dprintf("trying to switch to unsupported team %d\n", Team);
265                                         Team = NUM_SPECTATOR;
266                                 }
267                                 break;
268                 }
269         }
270         if(Team == -1) // leave
271         {
272                 if(o.has_team)
273                 {
274                         tm = GetTeam(o.team, false);
275                         tm.team_size -= 1;
276                         o.has_team = 0;
277                         return true;
278                 }
279         }
280         else
281         {
282                 if (!o.has_team)
283                 {
284                         o.team = Team;
285                         tm = GetTeam(Team, true);
286                         tm.team_size += 1;
287                         o.has_team = 1;
288                         return true;
289                 }
290                 else if(Team != o.team)
291                 {
292                         tm = GetTeam(o.team, false);
293                         tm.team_size -= 1;
294                         o.team = Team;
295                         tm = GetTeam(Team, true);
296                         tm.team_size += 1;
297                         return true;
298                 }
299         }
300         return false;
301 }
302
303 void Playerchecker_Think()
304 {
305     int i;
306         entity e;
307         for(i = 0; i < maxclients; ++i)
308         {
309                 e = playerslots[i];
310                 if(GetPlayerName(i) == "")
311                 {
312                         if(e.sort_prev)
313                         {
314                                 // player disconnected
315                                 SetTeam(e, -1);
316                                 RemovePlayer(e);
317                                 e.sort_prev = world;
318                                 //e.gotscores = 0;
319                         }
320                 }
321                 else
322                 {
323                         if (!e.sort_prev)
324                         {
325                                 // player connected
326                                 if (!e)
327                                         playerslots[i] = e = spawn();
328                                 e.sv_entnum = i;
329                                 e.ping = 0;
330                                 e.ping_packetloss = 0;
331                                 e.ping_movementloss = 0;
332                                 //e.gotscores = 0; // we might already have the scores...
333                                 SetTeam(e, GetPlayerColor(i)); // will not hurt; later updates come with HUD_UpdatePlayerTeams
334                                 RegisterPlayer(e);
335                                 HUD_UpdatePlayerPos(e);
336                         }
337                 }
338         }
339         self.nextthink = time + 0.2;
340 }
341
342 void Porto_Init();
343 void TrueAim_Init();
344 void PostInit(void)
345 {
346         entity playerchecker;
347         playerchecker = spawn();
348         playerchecker.think = Playerchecker_Think;
349         playerchecker.nextthink = time + 0.2;
350
351         Porto_Init();
352         TrueAim_Init();
353
354         postinit = true;
355 }
356
357 // CSQC_InputEvent : Used to perform actions based on any key pressed, key released and mouse on the client.
358 // Return value should be 1 if CSQC handled the input, otherwise return 0 to have the input passed to the engine.
359 // All keys are in ascii.
360 // bInputType = 0 is key pressed, 1 is key released, 2 and 3 are mouse input.
361 // In the case of keyboard input, nPrimary is the ascii code, and nSecondary is 0.
362 // In the case of mouse input, nPrimary is xdelta, nSecondary is ydelta.
363 // In the case of mouse input after a setcursormode(1) call, nPrimary is xpos, nSecondary is ypos.
364 float CSQC_InputEvent(float bInputType, float nPrimary, float nSecondary)
365 {
366         float bSkipKey;
367         bSkipKey = false;
368
369         if (HUD_Panel_InputEvent(bInputType, nPrimary, nSecondary))
370                 return true;
371
372         if (QuickMenu_InputEvent(bInputType, nPrimary, nSecondary))
373                 return true;
374
375         if ( HUD_Radar_InputEvent(bInputType, nPrimary, nSecondary) )
376                 return true;
377
378         if (MapVote_InputEvent(bInputType, nPrimary, nSecondary))
379                 return true;
380
381         if (HUD_Minigame_InputEvent(bInputType, nPrimary, nSecondary))
382                 return true;
383
384         if(menu_visible && menu_action)
385                 if(menu_action(bInputType, nPrimary, nSecondary))
386                         return true;
387
388         return bSkipKey;
389 }
390
391 // END REQUIRED CSQC FUNCTIONS
392 // --------------------------------------------------------------------------
393
394 // --------------------------------------------------------------------------
395 // BEGIN OPTIONAL CSQC FUNCTIONS
396
397 void Ent_RemoveEntCS()
398 {
399         entcs_receiver[self.sv_entnum] = world;
400 }
401 void Ent_ReadEntCS()
402 {
403     int sf;
404         InterpolateOrigin_Undo();
405
406         self.classname = "entcs_receiver";
407         sf = ReadByte();
408
409         if(sf & 1)
410                 self.sv_entnum = ReadByte();
411         if(sf & 2)
412         {
413                 self.origin_x = ReadShort();
414                 self.origin_y = ReadShort();
415                 self.origin_z = ReadShort();
416                 setorigin(self, self.origin);
417         }
418         if(sf & 4)
419         {
420                 self.angles_y = ReadByte() * 360.0 / 256;
421                 self.angles_x = self.angles_z = 0;
422         }
423         if(sf & 8)
424                 self.healthvalue = ReadByte() * 10;
425         if(sf & 16)
426                 self.armorvalue = ReadByte() * 10;
427
428         entcs_receiver[self.sv_entnum] = self;
429         self.entremove = Ent_RemoveEntCS;
430         self.iflags |= IFLAG_ORIGIN;
431
432         InterpolateOrigin_Note();
433 }
434
435 void Ent_Remove();
436
437 void Ent_RemovePlayerScore()
438 {
439         if(self.owner) {
440                 SetTeam(self.owner, -1);
441                 self.owner.gotscores = 0;
442                 for(int i = 0; i < MAX_SCORE; ++i) {
443                         self.owner.(scores[i]) = 0; // clear all scores
444                 }
445         }
446 }
447
448 void Ent_ReadPlayerScore()
449 {
450         int i, n;
451         bool isNew;
452         entity o;
453
454         // damnit -.- don't want to go change every single .sv_entnum in hud.qc AGAIN
455         // (no I've never heard of M-x replace-string, sed, or anything like that)
456         isNew = !self.owner; // workaround for DP bug
457         n = ReadByte()-1;
458
459 #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
460         if(!isNew && n != self.sv_entnum)
461         {
462                 //print("A CSQC entity changed its owner!\n");
463                 printf("A CSQC entity changed its owner! (edict: %d, classname: %s)\n", num_for_edict(self), self.classname);
464                 isNew = true;
465                 Ent_Remove();
466                 self.enttype = ENT_CLIENT_SCORES;
467         }
468 #endif
469
470         self.sv_entnum = n;
471
472         if (!(playerslots[self.sv_entnum]))
473                 playerslots[self.sv_entnum] = spawn();
474         o = self.owner = playerslots[self.sv_entnum];
475         o.sv_entnum = self.sv_entnum;
476         o.gotscores = 1;
477
478         //if (!o.sort_prev)
479         //      RegisterPlayer(o);
480         //playerchecker will do this for us later, if it has not already done so
481
482     int sf, lf;
483 #if MAX_SCORE <= 8
484         sf = ReadByte();
485         lf = ReadByte();
486 #else
487         sf = ReadShort();
488         lf = ReadShort();
489 #endif
490     int p;
491         for(i = 0, p = 1; i < MAX_SCORE; ++i, p *= 2)
492                 if(sf & p)
493                 {
494                         if(lf & p)
495                                 o.(scores[i]) = ReadInt24_t();
496                         else
497                                 o.(scores[i]) = ReadChar();
498                 }
499
500         if(o.sort_prev)
501                 HUD_UpdatePlayerPos(o); // if not registered, we cannot do this yet!
502
503         self.entremove = Ent_RemovePlayerScore;
504 }
505
506 void Ent_ReadTeamScore()
507 {
508         int i;
509         entity o;
510
511         self.team = ReadByte();
512         o = self.owner = GetTeam(self.team, true); // these team numbers can always be trusted
513
514     int sf, lf;
515 #if MAX_TEAMSCORE <= 8
516         sf = ReadByte();
517         lf = ReadByte();
518 #else
519         sf = ReadShort();
520         lf = ReadShort();
521 #endif
522         int p;
523         for(i = 0, p = 1; i < MAX_TEAMSCORE; ++i, p *= 2)
524                 if(sf & p)
525                 {
526                         if(lf & p)
527                                 o.(teamscores[i]) = ReadInt24_t();
528                         else
529                                 o.(teamscores[i]) = ReadChar();
530                 }
531
532         HUD_UpdateTeamPos(o);
533 }
534
535 void Ent_ClientData()
536 {
537         float newspectatee_status;
538
539     int f = ReadByte();
540
541         scoreboard_showscores_force = (f & 1);
542
543         if(f & 2)
544         {
545                 newspectatee_status = ReadByte();
546                 if(newspectatee_status == player_localnum + 1)
547                         newspectatee_status = -1; // observing
548         }
549         else
550                 newspectatee_status = 0;
551
552         spectatorbutton_zoom = (f & 4);
553
554         if(f & 8)
555         {
556                 angles_held_status = 1;
557                 angles_held.x = ReadAngle();
558                 angles_held.y = ReadAngle();
559                 angles_held.z = 0;
560         }
561         else
562                 angles_held_status = 0;
563
564         if(newspectatee_status != spectatee_status)
565         {
566                 // clear race stuff
567                 race_laptime = 0;
568                 race_checkpointtime = 0;
569         }
570         if (autocvar_hud_panel_healtharmor_progressbar_gfx)
571         {
572                 if ( (spectatee_status == -1 && newspectatee_status > 0) //before observing, now spectating
573                   || (spectatee_status > 0 && newspectatee_status > 0 && spectatee_status != newspectatee_status) //changed spectated player
574                 )
575                         prev_p_health = -1;
576                 else if(spectatee_status && !newspectatee_status) //before observing/spectating, now playing
577                         prev_health = -1;
578         }
579         spectatee_status = newspectatee_status;
580
581         // we could get rid of spectatee_status, and derive it from player_localentnum and player_localnum
582 }
583
584 void Ent_Nagger()
585 {
586     int i, j, b, f;
587
588     int nags = ReadByte(); // NAGS NAGS NAGS NAGS NAGS NAGS NADZ NAGS NAGS NAGS
589
590         if(!(nags & 4))
591         {
592                 if(vote_called_vote)
593                         strunzone(vote_called_vote);
594                 vote_called_vote = string_null;
595                 vote_active = 0;
596         }
597         else
598         {
599                 vote_active = 1;
600         }
601
602         if(nags & 64)
603         {
604                 vote_yescount = ReadByte();
605                 vote_nocount = ReadByte();
606                 vote_needed = ReadByte();
607                 vote_highlighted = ReadChar();
608         }
609
610         if(nags & 128)
611         {
612                 if(vote_called_vote)
613                         strunzone(vote_called_vote);
614                 vote_called_vote = strzone(ColorTranslateRGB(ReadString()));
615         }
616
617         if(nags & 1)
618         {
619                 for(j = 0; j < maxclients; ++j)
620                         if(playerslots[j])
621                                 playerslots[j].ready = 1;
622                 for(i = 1; i <= maxclients; i += 8)
623                 {
624                         f = ReadByte();
625                         for(j = i-1, b = 1; b < 256; b *= 2, ++j)
626                                 if (!(f & b))
627                                         if(playerslots[j])
628                                                 playerslots[j].ready = 0;
629                 }
630         }
631
632         ready_waiting = (nags & 1);
633         ready_waiting_for_me = (nags & 2);
634         vote_waiting = (nags & 4);
635         vote_waiting_for_me = (nags & 8);
636         warmup_stage = (nags & 16);
637 }
638
639 void Ent_EliminatedPlayers()
640 {
641     int i, j, b, f;
642
643     int sf = ReadByte();
644         if(sf & 1)
645         {
646                 for(j = 0; j < maxclients; ++j)
647                         if(playerslots[j])
648                                 playerslots[j].eliminated = 1;
649                 for(i = 1; i <= maxclients; i += 8)
650                 {
651                         f = ReadByte();
652                         for(j = i-1, b = 1; b < 256; b *= 2, ++j)
653                                 if (!(f & b))
654                                         if(playerslots[j])
655                                                 playerslots[j].eliminated = 0;
656                 }
657         }
658 }
659
660 void Ent_RandomSeed()
661 {
662         float s;
663         prandom_debug();
664         s = ReadShort();
665         psrandom(s);
666 }
667
668 void Ent_ReadAccuracy(void)
669 {
670     int f, w;
671     int sf = ReadInt24_t();
672         if(sf == 0)
673         {
674                 for(w = 0; w <= WEP_LAST - WEP_FIRST; ++w)
675                         weapon_accuracy[w] = -1;
676                 return;
677         }
678
679         for(w = 0, f = 1; w <= WEP_LAST - WEP_FIRST; ++w)
680         {
681                 if(sf & f)
682                 {
683             int b = ReadByte();
684                         if(b == 0)
685                                 weapon_accuracy[w] = -1;
686                         else if(b == 255)
687                                 weapon_accuracy[w] = 1.0; // no better error handling yet, sorry
688                         else
689                                 weapon_accuracy[w] = (b - 1.0) / 100.0;
690                 }
691                 if(f == 0x800000)
692                         f = 1;
693                 else
694                         f *= 2;
695         }
696 }
697
698 void Spawn_Draw(void)
699 {
700         pointparticles(self.cnt, self.origin + '0 0 28', '0 0 2', bound(0, frametime, 0.1));
701 }
702
703 void Ent_ReadSpawnPoint(float is_new) // entity for spawnpoint
704 {
705         float teamnum = (ReadByte() - 1);
706         vector spn_origin;
707         spn_origin.x = ReadShort();
708         spn_origin.y = ReadShort();
709         spn_origin.z = ReadShort();
710
711         if(is_new)
712         {
713                 self.origin = spn_origin;
714                 setsize(self, PL_MIN_CONST, PL_MAX_CONST);
715                 droptofloor();
716
717                 /*if(autocvar_cl_spawn_point_model) // needs a model first
718                 {
719                         self.mdl = "models/spawnpoint.md3";
720                         self.colormod = Team_ColorRGB(teamnum);
721                         precache_model(self.mdl);
722                         setmodel(self, self.mdl);
723                         self.drawmask = MASK_NORMAL;
724                         //self.movetype = MOVETYPE_NOCLIP;
725                         //self.draw = Spawn_Draw;
726                 }*/
727                 if(autocvar_cl_spawn_point_particles)
728                 {
729                         if((serverflags & SERVERFLAG_TEAMPLAY))
730                         {
731                                 switch(teamnum)
732                                 {
733                                         case NUM_TEAM_1: self.cnt = particleeffectnum("spawn_point_red"); break;
734                                         case NUM_TEAM_2: self.cnt = particleeffectnum("spawn_point_blue"); break;
735                                         case NUM_TEAM_3: self.cnt = particleeffectnum("spawn_point_yellow"); break;
736                                         case NUM_TEAM_4: self.cnt = particleeffectnum("spawn_point_pink"); break;
737                                         default: self.cnt = particleeffectnum("spawn_point_neutral"); break;
738                                 }
739                         }
740                         else { self.cnt = particleeffectnum("spawn_point_neutral"); }
741
742                         self.draw = Spawn_Draw;
743                 }
744         }
745
746         //printf("Ent_ReadSpawnPoint(is_new = %d); origin = %s, team = %d, effect = %d\n", is_new, vtos(self.origin), teamnum, self.cnt);
747 }
748
749 void Ent_ReadSpawnEvent(float is_new)
750 {
751         // If entnum is 0, ONLY do the local spawn actions
752         // this way the server can disable the sending of
753         // spawn origin or such to clients if wanted.
754         float entnum = ReadByte();
755
756         if(entnum)
757         {
758                 self.origin_x = ReadShort();
759                 self.origin_y = ReadShort();
760                 self.origin_z = ReadShort();
761
762                 if(is_new)
763                 {
764                         float teamnum = GetPlayerColor(entnum - 1);
765
766                         if(autocvar_cl_spawn_event_particles)
767                         {
768                                 switch(teamnum)
769                                 {
770                                         case NUM_TEAM_1: pointparticles(particleeffectnum("spawn_event_red"), self.origin, '0 0 0', 1); break;
771                                         case NUM_TEAM_2: pointparticles(particleeffectnum("spawn_event_blue"), self.origin, '0 0 0', 1); break;
772                                         case NUM_TEAM_3: pointparticles(particleeffectnum("spawn_event_yellow"), self.origin, '0 0 0', 1); break;
773                                         case NUM_TEAM_4: pointparticles(particleeffectnum("spawn_event_pink"), self.origin, '0 0 0', 1); break;
774                                         default: pointparticles(particleeffectnum("spawn_event_neutral"), self.origin, '0 0 0', 1); break;
775                                 }
776                         }
777                         if(autocvar_cl_spawn_event_sound)
778                         {
779                                 sound(self, CH_TRIGGER, "misc/spawn.wav", VOL_BASE, ATTEN_NORM);
780                         }
781                 }
782         }
783
784         // local spawn actions
785         if(is_new && (!entnum || (entnum == player_localentnum)))
786         {
787                 zoomin_effect = 1;
788                 current_viewzoom = (1 / bound(1, autocvar_cl_spawnzoom_factor, 16));
789
790                 if(autocvar_cl_unpress_zoom_on_spawn)
791                 {
792                         localcmd("-zoom\n");
793                         button_zoom = false;
794                 }
795         }
796         HUD_Radar_Hide_Maximized();
797         //printf("Ent_ReadSpawnEvent(is_new = %d); origin = %s, entnum = %d, localentnum = %d\n", is_new, vtos(self.origin), entnum, player_localentnum);
798 }
799
800 // CSQC_Ent_Update : Called every frame that the server has indicated an update to the SSQC / CSQC entity has occured.
801 // The only parameter reflects if the entity is "new" to the client, meaning it just came into the client's PVS.
802 void Ent_RadarLink();
803 void Ent_Init();
804 void Ent_ScoresInfo();
805 void CSQC_Ent_Update(float bIsNewEntity)
806 {
807         float t;
808         float savetime;
809         t = ReadByte();
810
811         if(autocvar_developer_csqcentities)
812                 printf("CSQC_Ent_Update(%d) with self=%i self.entnum=%d self.enttype=%d t=%d\n", bIsNewEntity, self, self.entnum, self.enttype, t);
813
814         // set up the "time" global for received entities to be correct for interpolation purposes
815         savetime = time;
816         if(servertime)
817         {
818                 time = servertime;
819         }
820         else
821         {
822                 serverprevtime = time;
823                 serverdeltatime = getstatf(STAT_MOVEVARS_TICRATE) * getstatf(STAT_MOVEVARS_TIMESCALE);
824                 time = serverprevtime + serverdeltatime;
825         }
826
827 #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
828         if(self.enttype)
829         {
830                 if(t != self.enttype || bIsNewEntity)
831                 {
832                         //print("A CSQC entity changed its type!\n");
833                         printf("A CSQC entity changed its type! (edict: %d, server: %d, type: %d -> %d)\n", num_for_edict(self), self.entnum, self.enttype, t);
834                         Ent_Remove();
835                         clearentity(self);
836                         bIsNewEntity = 1;
837                 }
838         }
839         else
840         {
841                 if(!bIsNewEntity)
842                 {
843                         printf("A CSQC entity appeared out of nowhere! (edict: %d, server: %d, type: %d)\n", num_for_edict(self), self.entnum, t);
844                         bIsNewEntity = 1;
845                 }
846         }
847 #endif
848         self.enttype = t;
849         switch(t)
850         {
851                 case ENT_CLIENT_MUTATOR: {
852                         int mutID = ReadMutator();
853                         if (!MUTATOR_CALLHOOK(CSQC_Ent_Update, mutID, bIsNewEntity))
854                         error(sprintf("Unknown mutator type in CSQC_Ent_Update (mutID: %d, edict: %d, classname: %s)\n", mutID, num_for_edict(self), self.classname));
855                         break;
856                 }
857                 case ENT_CLIENT_ENTCS: Ent_ReadEntCS(); break;
858                 case ENT_CLIENT_SCORES: Ent_ReadPlayerScore(); break;
859                 case ENT_CLIENT_TEAMSCORES: Ent_ReadTeamScore(); break;
860                 case ENT_CLIENT_POINTPARTICLES: Ent_PointParticles(); break;
861                 case ENT_CLIENT_RAINSNOW: Ent_RainOrSnow(); break;
862                 case ENT_CLIENT_LASER: Ent_Laser(); break;
863                 case ENT_CLIENT_NAGGER: Ent_Nagger(); break;
864                 case ENT_CLIENT_ELIMINATEDPLAYERS: Ent_EliminatedPlayers(); break;
865                 case ENT_CLIENT_RADARLINK: Ent_RadarLink(); break;
866                 case ENT_CLIENT_PROJECTILE: Ent_Projectile(); break;
867                 case ENT_CLIENT_GIBSPLASH: Ent_GibSplash(bIsNewEntity); break;
868                 case ENT_CLIENT_DAMAGEINFO: Ent_DamageInfo(bIsNewEntity); break;
869                 case ENT_CLIENT_INIT: Ent_Init(); break;
870                 case ENT_CLIENT_SCORES_INFO: Ent_ScoresInfo(); break;
871                 case ENT_CLIENT_MAPVOTE: Ent_MapVote(); break;
872                 case ENT_CLIENT_CLIENTDATA: Ent_ClientData(); break;
873                 case ENT_CLIENT_RANDOMSEED: Ent_RandomSeed(); break;
874                 case ENT_CLIENT_WALL: Ent_Wall(); break;
875                 case ENT_CLIENT_MODELEFFECT: Ent_ModelEffect(bIsNewEntity); break;
876                 case ENT_CLIENT_TUBANOTE: Ent_TubaNote(bIsNewEntity); break;
877                 case ENT_CLIENT_WARPZONE: WarpZone_Read(bIsNewEntity); break;
878                 case ENT_CLIENT_WARPZONE_CAMERA: WarpZone_Camera_Read(bIsNewEntity); break;
879                 case ENT_CLIENT_WARPZONE_TELEPORTED: WarpZone_Teleported_Read(bIsNewEntity); break;
880                 case ENT_CLIENT_TRIGGER_MUSIC: Ent_ReadTriggerMusic(); break;
881                 case ENT_CLIENT_HOOK: Ent_ReadHook(bIsNewEntity, ENT_CLIENT_HOOK); break;
882                 case ENT_CLIENT_INVENTORY: Inventory_Read(self); break;
883                 case ENT_CLIENT_ARC_BEAM: Ent_ReadArcBeam(bIsNewEntity); break;
884                 case ENT_CLIENT_ACCURACY: Ent_ReadAccuracy(); break;
885                 case ENT_CLIENT_AUXILIARYXHAIR: Net_AuXair2(bIsNewEntity); break;
886                 case ENT_CLIENT_TURRET: ent_turret(); break;
887                 case ENT_CLIENT_GENERATOR: ent_generator(); break;
888                 case ENT_CLIENT_CONTROLPOINT_ICON: ent_cpicon(); break;
889                 case ENT_CLIENT_MODEL: CSQCModel_Read(bIsNewEntity); break;
890                 case ENT_CLIENT_ITEM: ItemRead(bIsNewEntity); break;
891                 case ENT_CLIENT_BUMBLE_RAYGUN: bumble_raygun_read(bIsNewEntity); break;
892                 case ENT_CLIENT_SPAWNPOINT: Ent_ReadSpawnPoint(bIsNewEntity); break;
893                 case ENT_CLIENT_SPAWNEVENT: Ent_ReadSpawnEvent(bIsNewEntity); break;
894                 case ENT_CLIENT_NOTIFICATION: Read_Notification(bIsNewEntity); break;
895                 case ENT_CLIENT_HEALING_ORB: ent_healer(); break;
896                 case ENT_CLIENT_MINIGAME: ent_read_minigame(); break;
897                 case ENT_CLIENT_VIEWLOC: ent_viewloc(); break;
898                 case ENT_CLIENT_VIEWLOC_TRIGGER: ent_viewloc_trigger(); break;
899                 case ENT_CLIENT_LADDER: ent_func_ladder(); break;
900                 case ENT_CLIENT_TRIGGER_PUSH: ent_trigger_push(); break;
901                 case ENT_CLIENT_TARGET_PUSH: ent_target_push(); break;
902                 case ENT_CLIENT_CONVEYOR: ent_conveyor(); break;
903                 case ENT_CLIENT_DOOR: ent_door(); break;
904                 case ENT_CLIENT_PLAT: ent_plat(); break;
905                 case ENT_CLIENT_SWAMP: ent_swamp(); break;
906                 case ENT_CLIENT_CORNER: ent_corner(); break;
907                 case ENT_CLIENT_KEYLOCK: ent_keylock(); break;
908                 case ENT_CLIENT_TRAIN: ent_train(); break;
909                 case ENT_CLIENT_TRIGGER_IMPULSE: ent_trigger_impulse(); break;
910                 case ENT_CLIENT_EFFECT: Read_Effect(bIsNewEntity); break;
911
912                 default:
913                         //error(strcat(_("unknown entity type in CSQC_Ent_Update: %d\n"), self.enttype));
914                         error(sprintf("Unknown entity type in CSQC_Ent_Update (enttype: %d, edict: %d, classname: %s)\n", self.enttype, num_for_edict(self), self.classname));
915                         break;
916         }
917
918         time = savetime;
919 }
920 // Destructor, but does NOT deallocate the entity by calling remove(). Also
921 // used when an entity changes its type. For an entity that someone interacts
922 // with others, make sure it can no longer do so.
923 void Ent_Remove()
924 {
925         if(self.entremove)
926                 self.entremove();
927
928         if(self.skeletonindex)
929         {
930                 skel_delete(self.skeletonindex);
931                 self.skeletonindex = 0;
932         }
933
934         if(self.snd_looping > 0)
935         {
936                 sound(self, self.snd_looping, "misc/null.wav", VOL_BASE, autocvar_g_jetpack_attenuation);
937                 self.snd_looping = 0;
938         }
939
940         self.enttype = 0;
941         self.classname = "";
942         self.draw = menu_sub_null;
943         self.entremove = menu_sub_null;
944         // TODO possibly set more stuff to defaults
945 }
946 // CSQC_Ent_Remove : Called when the server requests a SSQC / CSQC entity to be removed.  Essentially call remove(self) as well.
947 void CSQC_Ent_Remove()
948 {
949         if(autocvar_developer_csqcentities)
950                 printf("CSQC_Ent_Remove() with self=%i self.entnum=%d self.enttype=%d\n", self, self.entnum, self.enttype);
951
952         if(wasfreed(self))
953         {
954                 print("WARNING: CSQC_Ent_Remove called for already removed entity. Packet loss?\n");
955                 return;
956         }
957         if(self.enttype)
958                 Ent_Remove();
959         remove(self);
960 }
961
962 void Gamemode_Init()
963 {
964         if (!isdemo())
965         {
966                 if(!(calledhooks & HOOK_START))
967                         localcmd("\n_cl_hook_gamestart ", MapInfo_Type_ToString(gametype), "\n");
968                 calledhooks |= HOOK_START;
969         }
970 }
971 // CSQC_Parse_StuffCmd : Provides the stuffcmd string in the first parameter that the server provided.  To execute standard behavior, simply execute localcmd with the string.
972 void CSQC_Parse_StuffCmd(string strMessage)
973 {
974         if(autocvar_developer_csqcentities)
975                 printf("CSQC_Parse_StuffCmd(\"%s\")\n", strMessage);
976
977         localcmd(strMessage);
978 }
979 // CSQC_Parse_Print : Provides the print string in the first parameter that the server provided.  To execute standard behavior, simply execute print with the string.
980 void CSQC_Parse_Print(string strMessage)
981 {
982         if(autocvar_developer_csqcentities)
983                 printf("CSQC_Parse_Print(\"%s\")\n", strMessage);
984
985         print(ColorTranslateRGB(strMessage));
986 }
987
988 // CSQC_Parse_CenterPrint : Provides the centerprint_hud string in the first parameter that the server provided.
989 void CSQC_Parse_CenterPrint(string strMessage)
990 {
991         if(autocvar_developer_csqcentities)
992                 printf("CSQC_Parse_CenterPrint(\"%s\")\n", strMessage);
993
994         centerprint_hud(strMessage);
995 }
996
997 string notranslate_fogcmd1 = "\nfog ";
998 string notranslate_fogcmd2 = "\nr_fog_exp2 0\nr_drawfog 1\n";
999 void Fog_Force()
1000 {
1001         // TODO somehow thwart prvm_globalset client ...
1002
1003         if(autocvar_cl_orthoview && autocvar_cl_orthoview_nofog)
1004                 { localcmd("\nr_drawfog 0\n"); }
1005         else if(forcefog != "")
1006                 { localcmd(strcat(notranslate_fogcmd1, forcefog, notranslate_fogcmd2)); }
1007 }
1008
1009 void Gamemode_Init();
1010 void Ent_ScoresInfo()
1011 {
1012     int i;
1013         self.classname = "ent_client_scores_info";
1014         gametype = ReadInt24_t();
1015         HUD_ModIcons_SetFunc();
1016         for(i = 0; i < MAX_SCORE; ++i)
1017         {
1018                 if(scores_label[i])
1019                         strunzone(scores_label[i]);
1020                 scores_label[i] = strzone(ReadString());
1021                 scores_flags[i] = ReadByte();
1022         }
1023         for(i = 0; i < MAX_TEAMSCORE; ++i)
1024         {
1025                 if(teamscores_label[i])
1026                         strunzone(teamscores_label[i]);
1027                 teamscores_label[i] = strzone(ReadString());
1028                 teamscores_flags[i] = ReadByte();
1029         }
1030         HUD_InitScores();
1031         Gamemode_Init();
1032 }
1033
1034 void Ent_Init()
1035 {
1036         self.classname = "ent_client_init";
1037
1038         nb_pb_period = ReadByte() / 32; //Accuracy of 1/32th
1039
1040         hook_shotorigin[0] = decompressShotOrigin(ReadInt24_t());
1041         hook_shotorigin[1] = decompressShotOrigin(ReadInt24_t());
1042         hook_shotorigin[2] = decompressShotOrigin(ReadInt24_t());
1043         hook_shotorigin[3] = decompressShotOrigin(ReadInt24_t());
1044         arc_shotorigin[0] = decompressShotOrigin(ReadInt24_t());
1045         arc_shotorigin[1] = decompressShotOrigin(ReadInt24_t());
1046         arc_shotorigin[2] = decompressShotOrigin(ReadInt24_t());
1047         arc_shotorigin[3] = decompressShotOrigin(ReadInt24_t());
1048
1049         if(forcefog)
1050                 strunzone(forcefog);
1051         forcefog = strzone(ReadString());
1052
1053         armorblockpercent = ReadByte() / 255.0;
1054
1055         g_balance_mortar_bouncefactor = ReadCoord();
1056         g_balance_mortar_bouncestop = ReadCoord();
1057         g_balance_electro_secondary_bouncefactor = ReadCoord();
1058         g_balance_electro_secondary_bouncestop = ReadCoord();
1059
1060         vortex_scope = !ReadByte();
1061         rifle_scope = !ReadByte();
1062
1063         serverflags = ReadByte();
1064
1065         minelayer_maxmines = ReadByte();
1066
1067         hagar_maxrockets = ReadByte();
1068
1069         g_trueaim_minrange = ReadCoord();
1070         g_balance_porto_secondary = ReadByte();
1071
1072         if(!postinit)
1073                 PostInit();
1074 }
1075
1076 void Net_ReadRace()
1077 {
1078         float b;
1079
1080         b = ReadByte();
1081
1082         switch(b)
1083         {
1084                 case RACE_NET_CHECKPOINT_HIT_QUALIFYING:
1085                         race_checkpoint = ReadByte();
1086                         race_time = ReadInt24_t();
1087                         race_previousbesttime = ReadInt24_t();
1088                         if(race_previousbestname)
1089                                 strunzone(race_previousbestname);
1090                         race_previousbestname = strzone(ColorTranslateRGB(ReadString()));
1091
1092                         race_checkpointtime = time;
1093
1094                         if(race_checkpoint == 0 || race_checkpoint == 254)
1095                         {
1096                                 race_penaltyaccumulator = 0;
1097                                 race_laptime = time; // valid
1098                         }
1099
1100                         break;
1101
1102                 case RACE_NET_CHECKPOINT_CLEAR:
1103                         race_laptime = 0;
1104                         race_checkpointtime = 0;
1105                         break;
1106
1107                 case RACE_NET_CHECKPOINT_NEXT_SPEC_QUALIFYING:
1108                         race_laptime = ReadCoord();
1109                         race_checkpointtime = -99999;
1110                         // fall through
1111                 case RACE_NET_CHECKPOINT_NEXT_QUALIFYING:
1112                         race_nextcheckpoint = ReadByte();
1113
1114                         race_nextbesttime = ReadInt24_t();
1115                         if(race_nextbestname)
1116                                 strunzone(race_nextbestname);
1117                         race_nextbestname = strzone(ColorTranslateRGB(ReadString()));
1118                         break;
1119
1120                 case RACE_NET_CHECKPOINT_HIT_RACE:
1121                         race_mycheckpoint = ReadByte();
1122                         race_mycheckpointtime = time;
1123                         race_mycheckpointdelta = ReadInt24_t();
1124                         race_mycheckpointlapsdelta = ReadByte();
1125                         if(race_mycheckpointlapsdelta >= 128)
1126                                 race_mycheckpointlapsdelta -= 256;
1127                         if(race_mycheckpointenemy)
1128                                 strunzone(race_mycheckpointenemy);
1129                         race_mycheckpointenemy = strzone(ColorTranslateRGB(ReadString()));
1130                         break;
1131
1132                 case RACE_NET_CHECKPOINT_HIT_RACE_BY_OPPONENT:
1133                         race_othercheckpoint = ReadByte();
1134                         race_othercheckpointtime = time;
1135                         race_othercheckpointdelta = ReadInt24_t();
1136                         race_othercheckpointlapsdelta = ReadByte();
1137                         if(race_othercheckpointlapsdelta >= 128)
1138                                 race_othercheckpointlapsdelta -= 256;
1139                         if(race_othercheckpointenemy)
1140                                 strunzone(race_othercheckpointenemy);
1141                         race_othercheckpointenemy = strzone(ColorTranslateRGB(ReadString()));
1142                         break;
1143
1144                 case RACE_NET_PENALTY_RACE:
1145                         race_penaltyeventtime = time;
1146                         race_penaltytime = ReadShort();
1147                         //race_penaltyaccumulator += race_penaltytime;
1148                         if(race_penaltyreason)
1149                                 strunzone(race_penaltyreason);
1150                         race_penaltyreason = strzone(ReadString());
1151                         break;
1152
1153                 case RACE_NET_PENALTY_QUALIFYING:
1154                         race_penaltyeventtime = time;
1155                         race_penaltytime = ReadShort();
1156                         race_penaltyaccumulator += race_penaltytime;
1157                         if(race_penaltyreason)
1158                                 strunzone(race_penaltyreason);
1159                         race_penaltyreason = strzone(ReadString());
1160                         break;
1161
1162                 case RACE_NET_SERVER_RECORD:
1163                         race_server_record = ReadInt24_t();
1164                         break;
1165                 case RACE_NET_SPEED_AWARD:
1166                         race_speedaward = ReadInt24_t();
1167                         if(race_speedaward_holder)
1168                                 strunzone(race_speedaward_holder);
1169                         race_speedaward_holder = strzone(ReadString());
1170                         break;
1171                 case RACE_NET_SPEED_AWARD_BEST:
1172                         race_speedaward_alltimebest = ReadInt24_t();
1173                         if(race_speedaward_alltimebest_holder)
1174                                 strunzone(race_speedaward_alltimebest_holder);
1175                         race_speedaward_alltimebest_holder = strzone(ReadString());
1176                         break;
1177                 case RACE_NET_SERVER_RANKINGS:
1178                         float prevpos, del;
1179             int pos = ReadShort();
1180                         prevpos = ReadShort();
1181                         del = ReadShort();
1182
1183                         // move other rankings out of the way
1184             int i;
1185                         if (prevpos) {
1186                                 for (i=prevpos-1;i>pos-1;--i) {
1187                                         grecordtime[i] = grecordtime[i-1];
1188                                         if(grecordholder[i])
1189                                                 strunzone(grecordholder[i]);
1190                                         grecordholder[i] = strzone(grecordholder[i-1]);
1191                                 }
1192                         } else if (del) { // a record has been deleted by the admin
1193                                 for (i=pos-1; i<= RANKINGS_CNT-1; ++i) {
1194                                         if (i == RANKINGS_CNT-1) { // clear out last record
1195                                                 grecordtime[i] = 0;
1196                                                 if (grecordholder[i])
1197                                                         strunzone(grecordholder[i]);
1198                                                 grecordholder[i] = string_null;
1199                                         }
1200                                         else {
1201                                                 grecordtime[i] = grecordtime[i+1];
1202                                                 if (grecordholder[i])
1203                                                         strunzone(grecordholder[i]);
1204                                                 grecordholder[i] = strzone(grecordholder[i+1]);
1205                                         }
1206                                 }
1207                         } else { // player has no ranked record yet
1208                                 for (i=RANKINGS_CNT-1;i>pos-1;--i) {
1209                                         grecordtime[i] = grecordtime[i-1];
1210                                         if(grecordholder[i])
1211                                                 strunzone(grecordholder[i]);
1212                                         grecordholder[i] = strzone(grecordholder[i-1]);
1213                                 }
1214                         }
1215
1216                         // store new ranking
1217                         if(grecordholder[pos-1] != "")
1218                                 strunzone(grecordholder[pos-1]);
1219                         grecordholder[pos-1] = strzone(ReadString());
1220                         grecordtime[pos-1] = ReadInt24_t();
1221                         if(grecordholder[pos-1] == GetPlayerName(player_localnum))
1222                                 race_myrank = pos;
1223                         break;
1224                 case RACE_NET_SERVER_STATUS:
1225                         race_status = ReadShort();
1226                         if(race_status_name)
1227                                 strunzone(race_status_name);
1228                         race_status_name = strzone(ReadString());
1229         }
1230 }
1231
1232 void Net_TeamNagger()
1233 {
1234         teamnagger = 1;
1235 }
1236
1237 void Net_ReadPingPLReport()
1238 {
1239         int e, pi, pl, ml;
1240         e = ReadByte();
1241         pi = ReadShort();
1242         pl = ReadByte();
1243         ml = ReadByte();
1244         if (!(playerslots[e]))
1245                 return;
1246         playerslots[e].ping = pi;
1247         playerslots[e].ping_packetloss = pl / 255.0;
1248         playerslots[e].ping_movementloss = ml / 255.0;
1249 }
1250
1251 void Net_WeaponComplain()
1252 {
1253         complain_weapon = ReadByte();
1254
1255         if(complain_weapon_name)
1256                 strunzone(complain_weapon_name);
1257         complain_weapon_name = strzone(WEP_NAME(complain_weapon));
1258
1259         complain_weapon_type = ReadByte();
1260
1261         complain_weapon_time = time;
1262         weapontime = time; // ping the weapon panel
1263
1264         switch(complain_weapon_type)
1265         {
1266                 case 0: Local_Notification(MSG_MULTI, ITEM_WEAPON_NOAMMO, complain_weapon); break;
1267                 case 1: Local_Notification(MSG_MULTI, ITEM_WEAPON_DONTHAVE, complain_weapon); break;
1268                 default: Local_Notification(MSG_MULTI, ITEM_WEAPON_UNAVAILABLE, complain_weapon); break;
1269         }
1270 }
1271
1272 // CSQC_Parse_TempEntity : Handles all temporary entity network data in the CSQC layer.
1273 // You must ALWAYS first acquire the temporary ID, which is sent as a byte.
1274 // Return value should be 1 if CSQC handled the temporary entity, otherwise return 0 to have the engine process the event.
1275 float CSQC_Parse_TempEntity()
1276 {
1277         // Acquire TE ID
1278         int nTEID = ReadByte();
1279
1280         if (autocvar_developer_csqcentities)
1281                 printf("CSQC_Parse_TempEntity() with nTEID=%d\n", nTEID);
1282
1283         switch (nTEID)
1284         {
1285                 case TE_CSQC_MUTATOR:
1286                         int mutID = ReadMutator();
1287                         if (MUTATOR_CALLHOOK(CSQC_Parse_TempEntity, mutID))
1288                         return true;
1289                 case TE_CSQC_TARGET_MUSIC:
1290                         Net_TargetMusic();
1291                         return true;
1292                 case TE_CSQC_PICTURE:
1293                         Net_MapVote_Picture();
1294                         return true;
1295                 case TE_CSQC_RACE:
1296                         Net_ReadRace();
1297                         return true;
1298                 case TE_CSQC_VORTEXBEAMPARTICLE:
1299                         Net_ReadVortexBeamParticle();
1300                         return true;
1301                 case TE_CSQC_TEAMNAGGER:
1302                         Net_TeamNagger();
1303                         return true;
1304                 case TE_CSQC_ARC:
1305                         Net_ReadArc();
1306                         return true;
1307                 case TE_CSQC_PINGPLREPORT:
1308                         Net_ReadPingPLReport();
1309                         return true;
1310                 case TE_CSQC_WEAPONCOMPLAIN:
1311                         Net_WeaponComplain();
1312                         return true;
1313                 case TE_CSQC_VEHICLESETUP:
1314                         Net_VehicleSetup();
1315                         return true;
1316                 case TE_CSQC_SVNOTICE:
1317                         cl_notice_read();
1318                         return true;
1319                 case TE_CSQC_SHOCKWAVEPARTICLE:
1320                         Net_ReadShockwaveParticle();
1321                         return true;
1322                 default:
1323                         // No special logic for this temporary entity; return 0 so the engine can handle it
1324                         return false;
1325         }
1326 }
1327
1328 string getcommandkey(string text, string command)
1329 {
1330         string keys;
1331         float n, j, k, l = 0;
1332
1333         if (!autocvar_hud_showbinds)
1334                 return text;
1335
1336         keys = db_get(binddb, command);
1337         if (keys == "")
1338         {
1339                 n = tokenize(findkeysforcommand(command, 0)); // uses '...' strings
1340                 for(j = 0; j < n; ++j)
1341                 {
1342                         k = stof(argv(j));
1343                         if(k != -1)
1344                         {
1345                                 if ("" == keys)
1346                                         keys = keynumtostring(k);
1347                                 else
1348                                         keys = strcat(keys, ", ", keynumtostring(k));
1349
1350                                 ++l;
1351                                 if (autocvar_hud_showbinds_limit > 0 && autocvar_hud_showbinds_limit <= l)
1352                                         break;
1353                         }
1354
1355                 }
1356                 if (keys == "")
1357                         keys = "NO_KEY";
1358                 db_put(binddb, command, keys);
1359         }
1360
1361         if (keys == "NO_KEY") {
1362                 if (autocvar_hud_showbinds > 1)
1363                         return sprintf(_("%s (not bound)"), text);
1364                 else
1365                         return text;
1366         }
1367         else if (autocvar_hud_showbinds > 1)
1368                 return sprintf("%s (%s)", text, keys);
1369         else
1370                 return keys;
1371 }