3 #include "../common/effects/qc/all.qh"
6 #include "mapvoting.qh"
7 #include "mutators/events.qh"
8 #include "quickmenu.qh"
9 #include "scoreboard.qh"
10 #include "shownames.qh"
14 #include "weapons/projectile.qh"
15 #include "../common/deathtypes/all.qh"
16 #include "../common/items/all.qh"
17 #include "../common/mapinfo.qh"
18 #include "../common/minigames/cl_minigames.qh"
19 #include "../common/minigames/cl_minigames_hud.qh"
20 #include "../common/net_notice.qh"
21 #include "../common/triggers/include.qh"
22 #include "../common/vehicles/all.qh"
23 #include "../lib/csqcmodel/cl_model.qh"
24 #include "../lib/csqcmodel/interpolate.qh"
25 #include "../lib/warpzone/client.qh"
27 // --------------------------------------------------------------------------
28 // BEGIN REQUIRED CSQC FUNCTIONS
31 #define DP_CSQC_ENTITY_REMOVE_IS_B0RKED
33 // CSQC_Init : Called every time the CSQC code is initialized (essentially at map load)
34 // Useful for precaching things
36 void ConsoleCommand_macro_init();
39 prvm_language = strzone(cvar_string("prvm_language"));
42 LOG_INFOF("^4CSQC Build information: ^1%s\n", WATERMARK);
48 if (getplayerkeyvalue(i, "viewentity") == "")
53 // needs to be done so early because of the constants they create
56 static_init_precache();
60 ClientProgsDB = db_load("client.db");
61 compressShortVector_init();
65 //registercommand("hud_configure");
66 //registercommand("hud_save");
67 //registercommand("menu_action");
69 ConsoleCommand_macro_init();
71 registercvar("hud_usecsqc", "1");
72 registercvar("scoreboard_columns", "default");
74 registercvar("cl_nade_type", "3");
75 registercvar("cl_pokenade_type", "zombie");
77 registercvar("cl_jumpspeedcap_min", "");
78 registercvar("cl_jumpspeedcap_max", "");
80 registercvar("cl_multijump", "0");
82 registercvar("cl_spawn_near_teammate", "1");
86 // hud_fields uses strunzone on the titles!
87 for(int i = 0; i < MAX_HUD_FIELDS; ++i)
88 hud_title[i] = strzone("(null)");
97 players = Sort_Spawn();
99 GetTeam(NUM_SPECTATOR, true); // add specs first
103 if(autocvar_cl_reticle)
105 precache_pic("gfx/reticle_normal");
106 // weapon reticles are precached in weapon files
110 get_mi_min_max_texcoords(1); // try the CLEVER way first
111 minimapname = strcat("gfx/", mi_shortname, "_radar.tga");
112 shortmapname = mi_shortname;
114 if (precache_pic(minimapname) == "")
116 // but maybe we have a non-clever minimap
117 minimapname = strcat("gfx/", mi_shortname, "_mini.tga");
118 if (precache_pic(minimapname) == "")
119 minimapname = ""; // FAIL
121 get_mi_min_max_texcoords(0); // load new texcoords
124 mi_center = (mi_min + mi_max) * 0.5;
125 mi_scale = mi_max - mi_min;
126 minimapname = strzone(minimapname);
129 hud_skin_path = strzone(strcat("gfx/hud/", autocvar_hud_skin));
130 draw_currentSkin = strzone(strcat("gfx/menu/", cvar_string("menu_skin")));
133 // CSQC_Shutdown : Called every time the CSQC code is shutdown (changing maps, quitting, etc)
142 if(autocvar_cl_db_saveasdump)
143 db_dump(ClientProgsDB, "client.db");
145 db_save(ClientProgsDB, "client.db");
146 db_close(ClientProgsDB);
149 cvar_set("chase_active",ftos(chase_active_backup));
151 // unset the event chasecam's chase_active
152 if(autocvar_chase_active < 0)
153 cvar_set("chase_active", "0");
157 if (!(calledhooks & HOOK_START))
158 localcmd("\n_cl_hook_gamestart nop\n");
159 if (!(calledhooks & HOOK_END))
160 localcmd("\ncl_hook_gameend\n");
163 deactivate_minigame();
164 HUD_MinigameMenu_Close();
168 float SetTeam(entity o, int Team)
170 devassert_once(Team);
183 if(GetTeam(Team, false) == world)
185 LOG_TRACEF("trying to switch to unsupported team %d\n", Team);
186 Team = NUM_SPECTATOR;
199 if(GetTeam(Team, false) == world)
201 LOG_TRACEF("trying to switch to unsupported team %d\n", Team);
202 Team = NUM_SPECTATOR;
207 if(Team == -1) // leave
211 tm = GetTeam(o.team, false);
222 tm = GetTeam(Team, true);
227 else if(Team != o.team)
229 tm = GetTeam(o.team, false);
232 tm = GetTeam(Team, true);
240 void Playerchecker_Think()
245 for(i = 0; i < maxclients; ++i)
248 if(entcs_GetName(i) == "")
252 // player disconnected
266 playerslots[i] = e = new(playerslot);
271 e.ping_packetloss = 0;
272 e.ping_movementloss = 0;
273 //e.gotscores = 0; // we might already have the scores...
274 int t = entcs_GetScoreTeam(i);
275 if (t) SetTeam(e, t); // will not hurt; later updates come with HUD_UpdatePlayerTeams
277 HUD_UpdatePlayerPos(e);
281 this.nextthink = time + 0.2;
288 entity playerchecker = new(playerchecker);
289 make_pure(playerchecker);
290 playerchecker.think = Playerchecker_Think;
291 playerchecker.nextthink = time + 0.2;
299 // CSQC_InputEvent : Used to perform actions based on any key pressed, key released and mouse on the client.
300 // Return value should be 1 if CSQC handled the input, otherwise return 0 to have the input passed to the engine.
301 // All keys are in ascii.
302 // bInputType = 0 is key pressed, 1 is key released, 2 and 3 are mouse input.
303 // In the case of keyboard input, nPrimary is the ascii code, and nSecondary is 0.
304 // In the case of mouse input, nPrimary is xdelta, nSecondary is ydelta.
305 // In the case of mouse input after a setcursormode(1) call, nPrimary is xpos, nSecondary is ypos.
306 float CSQC_InputEvent(float bInputType, float nPrimary, float nSecondary)
308 if (HUD_Panel_InputEvent(bInputType, nPrimary, nSecondary))
311 if (QuickMenu_InputEvent(bInputType, nPrimary, nSecondary))
314 if (HUD_Radar_InputEvent(bInputType, nPrimary, nSecondary))
317 if (MapVote_InputEvent(bInputType, nPrimary, nSecondary))
320 if (HUD_Minigame_InputEvent(bInputType, nPrimary, nSecondary))
326 // END REQUIRED CSQC FUNCTIONS
327 // --------------------------------------------------------------------------
329 // --------------------------------------------------------------------------
330 // BEGIN OPTIONAL CSQC FUNCTIONS
334 void Ent_RemovePlayerScore()
338 SetTeam(this.owner, -1);
339 this.owner.gotscores = 0;
340 for(int i = 0; i < MAX_SCORE; ++i) {
341 this.owner.(scores[i]) = 0; // clear all scores
346 NET_HANDLE(ENT_CLIENT_SCORES, bool isnew)
353 // damnit -.- don't want to go change every single .sv_entnum in hud.qc AGAIN
354 // (no I've never heard of M-x replace-string, sed, or anything like that)
355 isNew = !this.owner; // workaround for DP bug
358 #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
359 if(!isNew && n != this.sv_entnum)
361 //print("A CSQC entity changed its owner!\n");
362 LOG_INFOF("A CSQC entity changed its owner! (edict: %d, classname: %s)\n", etof(this), this.classname);
370 o = playerslots[this.sv_entnum];
373 o = playerslots[this.sv_entnum] = new(playerslot);
377 o.sv_entnum = this.sv_entnum;
381 // RegisterPlayer(o);
382 //playerchecker will do this for us later, if it has not already done so
393 for(i = 0, p = 1; i < MAX_SCORE; ++i, p *= 2)
397 o.(scores[i]) = ReadInt24_t();
399 o.(scores[i]) = ReadChar();
405 HUD_UpdatePlayerPos(o); // if not registered, we cannot do this yet!
407 this.entremove = Ent_RemovePlayerScore;
410 NET_HANDLE(ENT_CLIENT_TEAMSCORES, bool isnew)
416 this.team = ReadByte();
417 o = this.owner = GetTeam(this.team, true); // these team numbers can always be trusted
420 #if MAX_TEAMSCORE <= 8
428 for(i = 0, p = 1; i < MAX_TEAMSCORE; ++i, p *= 2)
432 o.(teamscores[i]) = ReadInt24_t();
434 o.(teamscores[i]) = ReadChar();
439 HUD_UpdateTeamPos(o);
442 NET_HANDLE(ENT_CLIENT_CLIENTDATA, bool isnew)
445 float newspectatee_status;
449 scoreboard_showscores_force = (f & 1);
453 newspectatee_status = ReadByte();
454 if(newspectatee_status == player_localnum + 1)
455 newspectatee_status = -1; // observing
458 newspectatee_status = 0;
460 spectatorbutton_zoom = (f & 4);
464 angles_held_status = 1;
465 angles_held.x = ReadAngle();
466 angles_held.y = ReadAngle();
470 angles_held_status = 0;
474 if(newspectatee_status != spectatee_status)
478 race_checkpointtime = 0;
480 if (autocvar_hud_panel_healtharmor_progressbar_gfx)
482 if ( (spectatee_status == -1 && newspectatee_status > 0) //before observing, now spectating
483 || (spectatee_status > 0 && newspectatee_status > 0 && spectatee_status != newspectatee_status) //changed spectated player
486 else if(spectatee_status && !newspectatee_status) //before observing/spectating, now playing
489 spectatee_status = newspectatee_status;
491 // we could get rid of spectatee_status, and derive it from player_localentnum and player_localnum
494 NET_HANDLE(ENT_CLIENT_NAGGER, bool isnew)
499 int nags = ReadByte(); // NAGS NAGS NAGS NAGS NAGS NAGS NADZ NAGS NAGS NAGS
504 strunzone(vote_called_vote);
505 vote_called_vote = string_null;
515 vote_yescount = ReadByte();
516 vote_nocount = ReadByte();
517 vote_needed = ReadByte();
518 vote_highlighted = ReadChar();
524 strunzone(vote_called_vote);
525 vote_called_vote = strzone(ColorTranslateRGB(ReadString()));
530 for(j = 0; j < maxclients; ++j)
532 playerslots[j].ready = 1;
533 for(i = 1; i <= maxclients; i += 8)
536 for(j = i-1, b = 1; b < 256; b *= 2, ++j)
539 playerslots[j].ready = 0;
545 ready_waiting = (nags & BIT(0));
546 ready_waiting_for_me = (nags & BIT(1));
547 vote_waiting = (nags & BIT(2));
548 vote_waiting_for_me = (nags & BIT(3));
549 warmup_stage = (nags & BIT(4));
552 NET_HANDLE(ENT_CLIENT_ELIMINATEDPLAYERS, bool isnew)
560 for(j = 0; j < maxclients; ++j)
562 playerslots[j].eliminated = 1;
563 for(i = 1; i <= maxclients; i += 8)
566 for(j = i-1, b = 1; b < 256; b *= 2, ++j)
569 playerslots[j].eliminated = 0;
575 NET_HANDLE(ENT_CLIENT_RANDOMSEED, bool isnew)
579 float s = ReadShort();
584 NET_HANDLE(ENT_CLIENT_ACCURACY, bool isnew)
587 int sf = ReadInt24_t();
589 for (int w = 0; w <= WEP_LAST - WEP_FIRST; ++w)
590 weapon_accuracy[w] = -1;
595 for (int w = 0; w <= WEP_LAST - WEP_FIRST; ++w) {
599 weapon_accuracy[w] = -1;
601 weapon_accuracy[w] = 1.0; // no better error handling yet, sorry
603 weapon_accuracy[w] = (b - 1.0) / 100.0;
605 f = (f == 0x800000) ? 1 : f * 2;
610 void Spawn_Draw(entity this)
612 __pointparticles(this.cnt, this.origin + '0 0 28', '0 0 2', bound(0, frametime, 0.1));
615 NET_HANDLE(ENT_CLIENT_SPAWNPOINT, bool is_new)
617 float teamnum = (ReadByte() - 1);
619 spn_origin.x = ReadShort();
620 spn_origin.y = ReadShort();
621 spn_origin.z = ReadShort();
625 this.origin = spn_origin;
626 setsize(this, PL_MIN_CONST, PL_MAX_CONST);
629 /*if(autocvar_cl_spawn_point_model) // needs a model first
631 this.mdl = "models/spawnpoint.md3";
632 this.colormod = Team_ColorRGB(teamnum);
633 precache_model(this.mdl);
634 setmodel(this, this.mdl);
635 this.drawmask = MASK_NORMAL;
636 //this.movetype = MOVETYPE_NOCLIP;
637 //this.draw = Spawn_Draw;
639 if(autocvar_cl_spawn_point_particles)
641 if((serverflags & SERVERFLAG_TEAMPLAY))
645 case NUM_TEAM_1: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_RED); break;
646 case NUM_TEAM_2: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_BLUE); break;
647 case NUM_TEAM_3: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_YELLOW); break;
648 case NUM_TEAM_4: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_PINK); break;
649 default: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_NEUTRAL); break;
652 else { this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_NEUTRAL); }
654 this.draw = Spawn_Draw;
658 //printf("Ent_ReadSpawnPoint(is_new = %d); origin = %s, team = %d, effect = %d\n", is_new, vtos(this.origin), teamnum, this.cnt);
662 NET_HANDLE(ENT_CLIENT_SPAWNEVENT, bool is_new)
664 // If entnum is 0, ONLY do the local spawn actions
665 // this way the server can disable the sending of
666 // spawn origin or such to clients if wanted.
667 float entnum = ReadByte();
671 this.origin_x = ReadShort();
672 this.origin_y = ReadShort();
673 this.origin_z = ReadShort();
677 float teamnum = entcs_GetTeam(entnum - 1);
679 if(autocvar_cl_spawn_event_particles)
683 case NUM_TEAM_1: pointparticles(EFFECT_SPAWN_RED, this.origin, '0 0 0', 1); break;
684 case NUM_TEAM_2: pointparticles(EFFECT_SPAWN_BLUE, this.origin, '0 0 0', 1); break;
685 case NUM_TEAM_3: pointparticles(EFFECT_SPAWN_YELLOW, this.origin, '0 0 0', 1); break;
686 case NUM_TEAM_4: pointparticles(EFFECT_SPAWN_PINK, this.origin, '0 0 0', 1); break;
687 default: pointparticles(EFFECT_SPAWN_NEUTRAL, this.origin, '0 0 0', 1); break;
690 if(autocvar_cl_spawn_event_sound)
692 sound(this, CH_TRIGGER, SND_SPAWN, VOL_BASE, ATTEN_NORM);
698 // local spawn actions
699 if(is_new && (!entnum || (entnum == player_localentnum)))
702 current_viewzoom = (1 / bound(1, autocvar_cl_spawnzoom_factor, 16));
704 if(autocvar_cl_unpress_zoom_on_spawn)
710 HUD_Radar_Hide_Maximized();
711 //printf("Ent_ReadSpawnEvent(is_new = %d); origin = %s, entnum = %d, localentnum = %d\n", is_new, vtos(this.origin), entnum, player_localentnum);
714 // CSQC_Ent_Update : Called every frame that the server has indicated an update to the SSQC / CSQC entity has occured.
715 // The only parameter reflects if the entity is "new" to the client, meaning it just came into the client's PVS.
716 void CSQC_Ent_Update(bool isnew)
719 this.sourceLocLine = __LINE__;
720 this.sourceLocFile = __FILE__;
723 // set up the "time" global for received entities to be correct for interpolation purposes
724 float savetime = time;
731 serverprevtime = time;
732 serverdeltatime = STAT(MOVEVARS_TICRATE) * STAT(MOVEVARS_TIMESCALE);
733 time = serverprevtime + serverdeltatime;
736 #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
739 if (t != this.enttype || isnew)
741 LOG_INFOF("A CSQC entity changed its type! (edict: %d, server: %d, type: %d -> %d)\n", etof(this), this.entnum, this.enttype, t);
751 LOG_INFOF("A CSQC entity appeared out of nowhere! (edict: %d, server: %d, type: %d)\n", etof(this), this.entnum, t);
758 FOREACH(LinkedEntities, it.m_id == t, LAMBDA(
759 if (isnew) this.classname = it.netname;
760 if (autocvar_developer_csqcentities)
761 LOG_INFOF("CSQC_Ent_Update(%d) at %f with this=%i {.entnum=%d, .enttype=%d} t=%s (%d)\n", isnew, savetime, this, this.entnum, this.enttype, this.classname, t);
762 done = it.m_read(this, isnew);
768 LOG_FATALF("CSQC_Ent_Update(%d) at %f with this=%i {.entnum=%d, .enttype=%d} t=%s (%d)\n", isnew, savetime, this, this.entnum, this.enttype, this.classname, t);
772 // Destructor, but does NOT deallocate the entity by calling remove(). Also
773 // used when an entity changes its type. For an entity that someone interacts
774 // with others, make sure it can no longer do so.
778 if(this.entremove) this.entremove();
780 if(this.skeletonindex)
782 skel_delete(this.skeletonindex);
783 this.skeletonindex = 0;
786 if(this.snd_looping > 0)
788 sound(this, this.snd_looping, SND_Null, VOL_BASE, autocvar_g_jetpack_attenuation);
789 this.snd_looping = 0;
794 this.draw = func_null;
795 this.entremove = func_null;
796 // TODO possibly set more stuff to defaults
798 // CSQC_Ent_Remove : Called when the server requests a SSQC / CSQC entity to be removed. Essentially call remove(this) as well.
799 void CSQC_Ent_Remove()
802 if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Ent_Remove() with this=%i {.entnum=%d, .enttype=%d}\n", this, this.entnum, this.enttype);
805 LOG_WARNING("CSQC_Ent_Remove called for already removed entity. Packet loss?\n");
808 if (this.enttype) Ent_Remove();
816 if(!(calledhooks & HOOK_START))
817 localcmd("\n_cl_hook_gamestart ", MapInfo_Type_ToString(gametype), "\n");
818 calledhooks |= HOOK_START;
821 // 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.
822 void CSQC_Parse_StuffCmd(string strMessage)
824 if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Parse_StuffCmd(\"%s\")\n", strMessage);
825 localcmd(strMessage);
827 // 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.
828 void CSQC_Parse_Print(string strMessage)
830 if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Parse_Print(\"%s\")\n", strMessage);
831 print(ColorTranslateRGB(strMessage));
834 // CSQC_Parse_CenterPrint : Provides the centerprint_hud string in the first parameter that the server provided.
835 void CSQC_Parse_CenterPrint(string strMessage)
837 if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Parse_CenterPrint(\"%s\")\n", strMessage);
838 centerprint_hud(strMessage);
841 // CSQC_Parse_TempEntity : Handles all temporary entity network data in the CSQC layer.
842 // You must ALWAYS first acquire the temporary ID, which is sent as a byte.
843 // Return value should be 1 if CSQC handled the temporary entity, otherwise return 0 to have the engine process the event.
844 bool CSQC_Parse_TempEntity()
847 int nTEID = ReadByte();
849 FOREACH(TempEntities, it.m_id == nTEID, LAMBDA(
850 if (autocvar_developer_csqcentities)
851 LOG_INFOF("CSQC_Parse_TempEntity() nTEID=%s (%d)\n", it.netname, nTEID);
852 return it.m_read(NULL, true);
855 if (autocvar_developer_csqcentities)
856 LOG_INFOF("CSQC_Parse_TempEntity() with nTEID=%d\n", nTEID);
858 // No special logic for this temporary entity; return 0 so the engine can handle it
862 /** TODO somehow thwart prvm_globalset client ... */
866 if (autocvar_cl_orthoview && autocvar_cl_orthoview_nofog)
867 localcmd("\nr_drawfog 0\n");
868 else if (forcefog != "")
869 localcmd(sprintf("\nfog %s\nr_fog_exp2 0\nr_drawfog 1\n", forcefog));
872 void Gamemode_Init();
873 NET_HANDLE(ENT_CLIENT_SCORES_INFO, bool isnew)
876 gametype = ReadInt24_t();
877 HUD_ModIcons_SetFunc();
878 for (int i = 0; i < MAX_SCORE; ++i)
880 if (scores_label[i]) strunzone(scores_label[i]);
881 scores_label[i] = strzone(ReadString());
882 scores_flags[i] = ReadByte();
884 for (int i = 0; i < MAX_TEAMSCORE; ++i)
886 if (teamscores_label[i]) strunzone(teamscores_label[i]);
887 teamscores_label[i] = strzone(ReadString());
888 teamscores_flags[i] = ReadByte();
895 NET_HANDLE(ENT_CLIENT_INIT, bool isnew)
897 nb_pb_period = ReadByte() / 32; //Accuracy of 1/32th
899 hook_shotorigin[0] = decompressShotOrigin(ReadInt24_t());
900 hook_shotorigin[1] = decompressShotOrigin(ReadInt24_t());
901 hook_shotorigin[2] = decompressShotOrigin(ReadInt24_t());
902 hook_shotorigin[3] = decompressShotOrigin(ReadInt24_t());
903 arc_shotorigin[0] = decompressShotOrigin(ReadInt24_t());
904 arc_shotorigin[1] = decompressShotOrigin(ReadInt24_t());
905 arc_shotorigin[2] = decompressShotOrigin(ReadInt24_t());
906 arc_shotorigin[3] = decompressShotOrigin(ReadInt24_t());
908 if (forcefog) strunzone(forcefog);
909 forcefog = strzone(ReadString());
911 armorblockpercent = ReadByte() / 255.0;
913 serverflags = ReadByte();
915 g_trueaim_minrange = ReadCoord();
919 MUTATOR_CALLHOOK(Ent_Init);
921 if (!postinit) PostInit();
924 NET_HANDLE(TE_CSQC_RACE, bool isNew)
930 case RACE_NET_CHECKPOINT_HIT_QUALIFYING:
931 race_checkpoint = ReadByte();
932 race_time = ReadInt24_t();
933 race_previousbesttime = ReadInt24_t();
934 if(race_previousbestname)
935 strunzone(race_previousbestname);
936 race_previousbestname = strzone(ColorTranslateRGB(ReadString()));
938 race_checkpointtime = time;
940 if(race_checkpoint == 0 || race_checkpoint == 254)
942 race_penaltyaccumulator = 0;
943 race_laptime = time; // valid
948 case RACE_NET_CHECKPOINT_CLEAR:
950 race_checkpointtime = 0;
953 case RACE_NET_CHECKPOINT_NEXT_SPEC_QUALIFYING:
954 race_laptime = ReadCoord();
955 race_checkpointtime = -99999;
957 case RACE_NET_CHECKPOINT_NEXT_QUALIFYING:
958 race_nextcheckpoint = ReadByte();
960 race_nextbesttime = ReadInt24_t();
961 if(race_nextbestname)
962 strunzone(race_nextbestname);
963 race_nextbestname = strzone(ColorTranslateRGB(ReadString()));
966 case RACE_NET_CHECKPOINT_HIT_RACE:
967 race_mycheckpoint = ReadByte();
968 race_mycheckpointtime = time;
969 race_mycheckpointdelta = ReadInt24_t();
970 race_mycheckpointlapsdelta = ReadByte();
971 if(race_mycheckpointlapsdelta >= 128)
972 race_mycheckpointlapsdelta -= 256;
973 if(race_mycheckpointenemy)
974 strunzone(race_mycheckpointenemy);
975 race_mycheckpointenemy = strzone(ColorTranslateRGB(ReadString()));
978 case RACE_NET_CHECKPOINT_HIT_RACE_BY_OPPONENT:
979 race_othercheckpoint = ReadByte();
980 race_othercheckpointtime = time;
981 race_othercheckpointdelta = ReadInt24_t();
982 race_othercheckpointlapsdelta = ReadByte();
983 if(race_othercheckpointlapsdelta >= 128)
984 race_othercheckpointlapsdelta -= 256;
985 if(race_othercheckpointenemy)
986 strunzone(race_othercheckpointenemy);
987 race_othercheckpointenemy = strzone(ColorTranslateRGB(ReadString()));
990 case RACE_NET_PENALTY_RACE:
991 race_penaltyeventtime = time;
992 race_penaltytime = ReadShort();
993 //race_penaltyaccumulator += race_penaltytime;
994 if(race_penaltyreason)
995 strunzone(race_penaltyreason);
996 race_penaltyreason = strzone(ReadString());
999 case RACE_NET_PENALTY_QUALIFYING:
1000 race_penaltyeventtime = time;
1001 race_penaltytime = ReadShort();
1002 race_penaltyaccumulator += race_penaltytime;
1003 if(race_penaltyreason)
1004 strunzone(race_penaltyreason);
1005 race_penaltyreason = strzone(ReadString());
1008 case RACE_NET_SERVER_RECORD:
1009 race_server_record = ReadInt24_t();
1011 case RACE_NET_SPEED_AWARD:
1012 race_speedaward = ReadInt24_t();
1013 if(race_speedaward_holder)
1014 strunzone(race_speedaward_holder);
1015 race_speedaward_holder = strzone(ReadString());
1017 case RACE_NET_SPEED_AWARD_BEST:
1018 race_speedaward_alltimebest = ReadInt24_t();
1019 if(race_speedaward_alltimebest_holder)
1020 strunzone(race_speedaward_alltimebest_holder);
1021 race_speedaward_alltimebest_holder = strzone(ReadString());
1023 case RACE_NET_SERVER_RANKINGS:
1025 int pos = ReadShort();
1026 prevpos = ReadShort();
1029 // move other rankings out of the way
1032 for (i=prevpos-1;i>pos-1;--i) {
1033 grecordtime[i] = grecordtime[i-1];
1034 if(grecordholder[i])
1035 strunzone(grecordholder[i]);
1036 grecordholder[i] = strzone(grecordholder[i-1]);
1038 } else if (del) { // a record has been deleted by the admin
1039 for (i=pos-1; i<= RANKINGS_CNT-1; ++i) {
1040 if (i == RANKINGS_CNT-1) { // clear out last record
1042 if (grecordholder[i])
1043 strunzone(grecordholder[i]);
1044 grecordholder[i] = string_null;
1047 grecordtime[i] = grecordtime[i+1];
1048 if (grecordholder[i])
1049 strunzone(grecordholder[i]);
1050 grecordholder[i] = strzone(grecordholder[i+1]);
1053 } else { // player has no ranked record yet
1054 for (i=RANKINGS_CNT-1;i>pos-1;--i) {
1055 grecordtime[i] = grecordtime[i-1];
1056 if(grecordholder[i])
1057 strunzone(grecordholder[i]);
1058 grecordholder[i] = strzone(grecordholder[i-1]);
1062 // store new ranking
1063 if(grecordholder[pos-1] != "")
1064 strunzone(grecordholder[pos-1]);
1065 grecordholder[pos-1] = strzone(ReadString());
1066 grecordtime[pos-1] = ReadInt24_t();
1067 if(grecordholder[pos-1] == entcs_GetName(player_localnum))
1070 case RACE_NET_SERVER_STATUS:
1071 race_status = ReadShort();
1072 if(race_status_name)
1073 strunzone(race_status_name);
1074 race_status_name = strzone(ReadString());
1079 NET_HANDLE(TE_CSQC_TEAMNAGGER, bool isNew)
1085 NET_HANDLE(TE_CSQC_PINGPLREPORT, bool isNew)
1088 int pi = ReadShort();
1089 int pl = ReadByte();
1090 int ml = ReadByte();
1092 entity e = playerslots[i];
1095 e.ping_packetloss = pl / 255.0;
1096 e.ping_movementloss = ml / 255.0;
1099 NET_HANDLE(TE_CSQC_WEAPONCOMPLAIN, bool isNew)
1101 complain_weapon = ReadByte();
1102 if (complain_weapon_name) strunzone(complain_weapon_name);
1103 complain_weapon_name = strzone(Weapons_from(complain_weapon).m_name);
1104 complain_weapon_type = ReadByte();
1107 complain_weapon_time = time;
1108 weapontime = time; // ping the weapon panel
1110 switch(complain_weapon_type)
1112 case 0: Local_Notification(MSG_MULTI, ITEM_WEAPON_NOAMMO, complain_weapon); break;
1113 case 1: Local_Notification(MSG_MULTI, ITEM_WEAPON_DONTHAVE, complain_weapon); break;
1114 default: Local_Notification(MSG_MULTI, ITEM_WEAPON_UNAVAILABLE, complain_weapon); break;
1118 string getcommandkey(string text, string command)
1121 float n, j, k, l = 0;
1123 if (!autocvar_hud_showbinds)
1126 keys = db_get(binddb, command);
1129 n = tokenize(findkeysforcommand(command, 0)); // uses '...' strings
1130 for(j = 0; j < n; ++j)
1136 keys = keynumtostring(k);
1138 keys = strcat(keys, ", ", keynumtostring(k));
1141 if (autocvar_hud_showbinds_limit > 0 && autocvar_hud_showbinds_limit <= l)
1148 db_put(binddb, command, keys);
1151 if (keys == "NO_KEY") {
1152 if (autocvar_hud_showbinds > 1)
1153 return sprintf(_("%s (not bound)"), text);
1157 else if (autocvar_hud_showbinds > 1)
1158 return sprintf("%s (%s)", text, keys);