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