3 #include "../common/effects/qc/all.qh"
5 #include "mapvoting.qh"
6 #include "mutators/events.qh"
7 #include "quickmenu.qh"
8 #include "scoreboard.qh"
9 #include "shownames.qh"
10 #include "../common/t_items.qh"
12 #include "weapons/projectile.qh"
13 #include "../common/deathtypes/all.qh"
14 #include "../common/items/all.qh"
15 #include "../common/mapinfo.qh"
16 #include "../common/minigames/cl_minigames.qh"
17 #include "../common/minigames/cl_minigames_hud.qh"
18 #include "../common/net_notice.qh"
19 #include "../common/triggers/include.qh"
20 #include "../common/vehicles/all.qh"
21 #include "../lib/csqcmodel/cl_model.qh"
22 #include "../lib/csqcmodel/interpolate.qh"
23 #include "../lib/warpzone/client.qh"
25 // --------------------------------------------------------------------------
26 // BEGIN REQUIRED CSQC FUNCTIONS
29 #define DP_CSQC_ENTITY_REMOVE_IS_B0RKED
31 // CSQC_Init : Called every time the CSQC code is initialized (essentially at map load)
32 // Useful for precaching things
34 void ConsoleCommand_macro_init();
37 prvm_language = strzone(cvar_string("prvm_language"));
40 LOG_INFOF("^4CSQC Build information: ^1%s\n", WATERMARK);
46 if (getplayerkeyvalue(i, "viewentity") == "")
51 // needs to be done so early because of the constants they create
54 static_init_precache();
58 ClientProgsDB = db_load("client.db");
59 compressShortVector_init();
63 //registercommand("hud_configure");
64 //registercommand("hud_save");
65 //registercommand("menu_action");
67 ConsoleCommand_macro_init();
69 registercvar("hud_usecsqc", "1");
70 registercvar("scoreboard_columns", "default");
72 registercvar("cl_nade_type", "3");
73 registercvar("cl_pokenade_type", "zombie");
75 registercvar("cl_jumpspeedcap_min", "");
76 registercvar("cl_jumpspeedcap_max", "");
78 registercvar("cl_multijump", "0");
80 registercvar("cl_spawn_near_teammate", "1");
84 // hud_fields uses strunzone on the titles!
85 for(int i = 0; i < MAX_HUD_FIELDS; ++i)
86 hud_title[i] = strzone("(null)");
95 players = Sort_Spawn();
97 GetTeam(NUM_SPECTATOR, true); // add specs first
101 if(autocvar_cl_reticle)
103 precache_pic("gfx/reticle_normal");
104 // weapon reticles are precached in weapon files
108 get_mi_min_max_texcoords(1); // try the CLEVER way first
109 minimapname = strcat("gfx/", mi_shortname, "_radar.tga");
110 shortmapname = mi_shortname;
112 if (precache_pic(minimapname) == "")
114 // but maybe we have a non-clever minimap
115 minimapname = strcat("gfx/", mi_shortname, "_mini.tga");
116 if (precache_pic(minimapname) == "")
117 minimapname = ""; // FAIL
119 get_mi_min_max_texcoords(0); // load new texcoords
122 mi_center = (mi_min + mi_max) * 0.5;
123 mi_scale = mi_max - mi_min;
124 minimapname = strzone(minimapname);
127 hud_skin_path = strzone(strcat("gfx/hud/", autocvar_hud_skin));
128 draw_currentSkin = strzone(strcat("gfx/menu/", cvar_string("menu_skin")));
131 // CSQC_Shutdown : Called every time the CSQC code is shutdown (changing maps, quitting, etc)
140 if(autocvar_cl_db_saveasdump)
141 db_dump(ClientProgsDB, "client.db");
143 db_save(ClientProgsDB, "client.db");
144 db_close(ClientProgsDB);
147 cvar_set("chase_active",ftos(chase_active_backup));
149 // unset the event chasecam's chase_active
150 if(autocvar_chase_active < 0)
151 cvar_set("chase_active", "0");
155 if (!(calledhooks & HOOK_START))
156 localcmd("\n_cl_hook_gamestart nop\n");
157 if (!(calledhooks & HOOK_END))
158 localcmd("\ncl_hook_gameend\n");
161 deactivate_minigame();
162 HUD_MinigameMenu_Close();
166 float SetTeam(entity o, int Team)
168 devassert_once(Team);
181 if(GetTeam(Team, false) == world)
183 LOG_TRACEF("trying to switch to unsupported team %d\n", Team);
184 Team = NUM_SPECTATOR;
197 if(GetTeam(Team, false) == world)
199 LOG_TRACEF("trying to switch to unsupported team %d\n", Team);
200 Team = NUM_SPECTATOR;
205 if(Team == -1) // leave
209 tm = GetTeam(o.team, false);
220 tm = GetTeam(Team, true);
225 else if(Team != o.team)
227 tm = GetTeam(o.team, false);
230 tm = GetTeam(Team, true);
238 void Playerchecker_Think()
243 for(i = 0; i < maxclients; ++i)
246 if(entcs_GetName(i) == "")
250 // player disconnected
264 playerslots[i] = e = new(playerslot);
269 e.ping_packetloss = 0;
270 e.ping_movementloss = 0;
271 //e.gotscores = 0; // we might already have the scores...
272 int t = entcs_GetScoreTeam(i);
273 if (t) SetTeam(e, t); // will not hurt; later updates come with HUD_UpdatePlayerTeams
275 HUD_UpdatePlayerPos(e);
279 this.nextthink = time + 0.2;
286 entity playerchecker = new(playerchecker);
287 make_pure(playerchecker);
288 playerchecker.think = Playerchecker_Think;
289 playerchecker.nextthink = time + 0.2;
297 // CSQC_InputEvent : Used to perform actions based on any key pressed, key released and mouse on the client.
298 // Return value should be 1 if CSQC handled the input, otherwise return 0 to have the input passed to the engine.
299 // All keys are in ascii.
300 // bInputType = 0 is key pressed, 1 is key released, 2 and 3 are mouse input.
301 // In the case of keyboard input, nPrimary is the ascii code, and nSecondary is 0.
302 // In the case of mouse input, nPrimary is xdelta, nSecondary is ydelta.
303 // In the case of mouse input after a setcursormode(1) call, nPrimary is xpos, nSecondary is ypos.
304 float CSQC_InputEvent(float bInputType, float nPrimary, float nSecondary)
306 if (HUD_Panel_InputEvent(bInputType, nPrimary, nSecondary))
309 if (QuickMenu_InputEvent(bInputType, nPrimary, nSecondary))
312 if (HUD_Radar_InputEvent(bInputType, nPrimary, nSecondary))
315 if (MapVote_InputEvent(bInputType, nPrimary, nSecondary))
318 if (HUD_Minigame_InputEvent(bInputType, nPrimary, nSecondary))
324 // END REQUIRED CSQC FUNCTIONS
325 // --------------------------------------------------------------------------
327 // --------------------------------------------------------------------------
328 // BEGIN OPTIONAL CSQC FUNCTIONS
332 void Ent_RemovePlayerScore()
336 SetTeam(this.owner, -1);
337 this.owner.gotscores = 0;
338 for(int i = 0; i < MAX_SCORE; ++i) {
339 this.owner.(scores[i]) = 0; // clear all scores
344 NET_HANDLE(ENT_CLIENT_SCORES, bool isnew)
351 // damnit -.- don't want to go change every single .sv_entnum in hud.qc AGAIN
352 // (no I've never heard of M-x replace-string, sed, or anything like that)
353 isNew = !this.owner; // workaround for DP bug
356 #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
357 if(!isNew && n != this.sv_entnum)
359 //print("A CSQC entity changed its owner!\n");
360 LOG_INFOF("A CSQC entity changed its owner! (edict: %d, classname: %s)\n", etof(this), this.classname);
368 o = playerslots[this.sv_entnum];
371 o = playerslots[this.sv_entnum] = new(playerslot);
375 o.sv_entnum = this.sv_entnum;
379 // RegisterPlayer(o);
380 //playerchecker will do this for us later, if it has not already done so
391 for(i = 0, p = 1; i < MAX_SCORE; ++i, p *= 2)
395 o.(scores[i]) = ReadInt24_t();
397 o.(scores[i]) = ReadChar();
403 HUD_UpdatePlayerPos(o); // if not registered, we cannot do this yet!
405 this.entremove = Ent_RemovePlayerScore;
408 NET_HANDLE(ENT_CLIENT_TEAMSCORES, bool isnew)
414 this.team = ReadByte();
415 o = this.owner = GetTeam(this.team, true); // these team numbers can always be trusted
418 #if MAX_TEAMSCORE <= 8
426 for(i = 0, p = 1; i < MAX_TEAMSCORE; ++i, p *= 2)
430 o.(teamscores[i]) = ReadInt24_t();
432 o.(teamscores[i]) = ReadChar();
437 HUD_UpdateTeamPos(o);
440 NET_HANDLE(ENT_CLIENT_CLIENTDATA, bool isnew)
443 float newspectatee_status;
447 scoreboard_showscores_force = (f & 1);
451 newspectatee_status = ReadByte();
452 if(newspectatee_status == player_localnum + 1)
453 newspectatee_status = -1; // observing
456 newspectatee_status = 0;
458 spectatorbutton_zoom = (f & 4);
462 angles_held_status = 1;
463 angles_held.x = ReadAngle();
464 angles_held.y = ReadAngle();
468 angles_held_status = 0;
472 if(newspectatee_status != spectatee_status)
476 race_checkpointtime = 0;
478 if (autocvar_hud_panel_healtharmor_progressbar_gfx)
480 if ( (spectatee_status == -1 && newspectatee_status > 0) //before observing, now spectating
481 || (spectatee_status > 0 && newspectatee_status > 0 && spectatee_status != newspectatee_status) //changed spectated player
484 else if(spectatee_status && !newspectatee_status) //before observing/spectating, now playing
487 spectatee_status = newspectatee_status;
489 // we could get rid of spectatee_status, and derive it from player_localentnum and player_localnum
492 NET_HANDLE(ENT_CLIENT_NAGGER, bool isnew)
497 int nags = ReadByte(); // NAGS NAGS NAGS NAGS NAGS NAGS NADZ NAGS NAGS NAGS
502 strunzone(vote_called_vote);
503 vote_called_vote = string_null;
513 vote_yescount = ReadByte();
514 vote_nocount = ReadByte();
515 vote_needed = ReadByte();
516 vote_highlighted = ReadChar();
522 strunzone(vote_called_vote);
523 vote_called_vote = strzone(ColorTranslateRGB(ReadString()));
528 for(j = 0; j < maxclients; ++j)
530 playerslots[j].ready = 1;
531 for(i = 1; i <= maxclients; i += 8)
534 for(j = i-1, b = 1; b < 256; b *= 2, ++j)
537 playerslots[j].ready = 0;
543 ready_waiting = (nags & BIT(0));
544 ready_waiting_for_me = (nags & BIT(1));
545 vote_waiting = (nags & BIT(2));
546 vote_waiting_for_me = (nags & BIT(3));
547 warmup_stage = (nags & BIT(4));
550 NET_HANDLE(ENT_CLIENT_ELIMINATEDPLAYERS, bool isnew)
558 for(j = 0; j < maxclients; ++j)
560 playerslots[j].eliminated = 1;
561 for(i = 1; i <= maxclients; i += 8)
564 for(j = i-1, b = 1; b < 256; b *= 2, ++j)
567 playerslots[j].eliminated = 0;
573 NET_HANDLE(ENT_CLIENT_RANDOMSEED, bool isnew)
577 float s = ReadShort();
582 NET_HANDLE(ENT_CLIENT_ACCURACY, bool isnew)
585 int sf = ReadInt24_t();
587 for (int w = 0; w <= WEP_LAST - WEP_FIRST; ++w)
588 weapon_accuracy[w] = -1;
593 for (int w = 0; w <= WEP_LAST - WEP_FIRST; ++w) {
597 weapon_accuracy[w] = -1;
599 weapon_accuracy[w] = 1.0; // no better error handling yet, sorry
601 weapon_accuracy[w] = (b - 1.0) / 100.0;
603 f = (f == 0x800000) ? 1 : f * 2;
608 void Spawn_Draw(entity this)
610 __pointparticles(this.cnt, this.origin + '0 0 28', '0 0 2', bound(0, frametime, 0.1));
613 NET_HANDLE(ENT_CLIENT_SPAWNPOINT, bool is_new)
615 float teamnum = (ReadByte() - 1);
617 spn_origin.x = ReadShort();
618 spn_origin.y = ReadShort();
619 spn_origin.z = ReadShort();
623 this.origin = spn_origin;
624 setsize(this, PL_MIN_CONST, PL_MAX_CONST);
627 /*if(autocvar_cl_spawn_point_model) // needs a model first
629 this.mdl = "models/spawnpoint.md3";
630 this.colormod = Team_ColorRGB(teamnum);
631 precache_model(this.mdl);
632 setmodel(this, this.mdl);
633 this.drawmask = MASK_NORMAL;
634 //this.movetype = MOVETYPE_NOCLIP;
635 //this.draw = Spawn_Draw;
637 if(autocvar_cl_spawn_point_particles)
639 if((serverflags & SERVERFLAG_TEAMPLAY))
643 case NUM_TEAM_1: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_RED); break;
644 case NUM_TEAM_2: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_BLUE); break;
645 case NUM_TEAM_3: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_YELLOW); break;
646 case NUM_TEAM_4: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_PINK); break;
647 default: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_NEUTRAL); break;
650 else { this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_NEUTRAL); }
652 this.draw = Spawn_Draw;
656 //printf("Ent_ReadSpawnPoint(is_new = %d); origin = %s, team = %d, effect = %d\n", is_new, vtos(this.origin), teamnum, this.cnt);
660 NET_HANDLE(ENT_CLIENT_SPAWNEVENT, bool is_new)
662 // If entnum is 0, ONLY do the local spawn actions
663 // this way the server can disable the sending of
664 // spawn origin or such to clients if wanted.
665 float entnum = ReadByte();
669 this.origin_x = ReadShort();
670 this.origin_y = ReadShort();
671 this.origin_z = ReadShort();
675 float teamnum = entcs_GetTeam(entnum - 1);
677 if(autocvar_cl_spawn_event_particles)
681 case NUM_TEAM_1: pointparticles(EFFECT_SPAWN_RED, this.origin, '0 0 0', 1); break;
682 case NUM_TEAM_2: pointparticles(EFFECT_SPAWN_BLUE, this.origin, '0 0 0', 1); break;
683 case NUM_TEAM_3: pointparticles(EFFECT_SPAWN_YELLOW, this.origin, '0 0 0', 1); break;
684 case NUM_TEAM_4: pointparticles(EFFECT_SPAWN_PINK, this.origin, '0 0 0', 1); break;
685 default: pointparticles(EFFECT_SPAWN_NEUTRAL, this.origin, '0 0 0', 1); break;
688 if(autocvar_cl_spawn_event_sound)
690 sound(this, CH_TRIGGER, SND_SPAWN, VOL_BASE, ATTEN_NORM);
696 // local spawn actions
697 if(is_new && (!entnum || (entnum == player_localentnum)))
700 current_viewzoom = (1 / bound(1, autocvar_cl_spawnzoom_factor, 16));
702 if(autocvar_cl_unpress_zoom_on_spawn)
708 HUD_Radar_Hide_Maximized();
709 //printf("Ent_ReadSpawnEvent(is_new = %d); origin = %s, entnum = %d, localentnum = %d\n", is_new, vtos(this.origin), entnum, player_localentnum);
712 // CSQC_Ent_Update : Called every frame that the server has indicated an update to the SSQC / CSQC entity has occured.
713 // The only parameter reflects if the entity is "new" to the client, meaning it just came into the client's PVS.
714 void CSQC_Ent_Update(bool isnew)
717 this.sourceLocLine = __LINE__;
718 this.sourceLocFile = __FILE__;
721 // set up the "time" global for received entities to be correct for interpolation purposes
722 float savetime = time;
729 serverprevtime = time;
730 serverdeltatime = STAT(MOVEVARS_TICRATE) * STAT(MOVEVARS_TIMESCALE);
731 time = serverprevtime + serverdeltatime;
734 #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
737 if (t != this.enttype || isnew)
739 LOG_INFOF("A CSQC entity changed its type! (edict: %d, server: %d, type: %d -> %d)\n", etof(this), this.entnum, this.enttype, t);
749 LOG_INFOF("A CSQC entity appeared out of nowhere! (edict: %d, server: %d, type: %d)\n", etof(this), this.entnum, t);
756 FOREACH(LinkedEntities, it.m_id == t, LAMBDA(
757 if (isnew) this.classname = it.netname;
758 if (autocvar_developer_csqcentities)
759 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);
760 done = it.m_read(this, NULL, isnew);
766 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);
770 // Destructor, but does NOT deallocate the entity by calling remove(). Also
771 // used when an entity changes its type. For an entity that someone interacts
772 // with others, make sure it can no longer do so.
776 if(this.entremove) this.entremove();
778 if(this.skeletonindex)
780 skel_delete(this.skeletonindex);
781 this.skeletonindex = 0;
784 if(this.snd_looping > 0)
786 sound(this, this.snd_looping, SND_Null, VOL_BASE, autocvar_g_jetpack_attenuation);
787 this.snd_looping = 0;
792 this.draw = func_null;
793 this.entremove = func_null;
794 // TODO possibly set more stuff to defaults
796 // CSQC_Ent_Remove : Called when the server requests a SSQC / CSQC entity to be removed. Essentially call remove(this) as well.
797 void CSQC_Ent_Remove()
800 if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Ent_Remove() with this=%i {.entnum=%d, .enttype=%d}\n", this, this.entnum, this.enttype);
803 LOG_WARNING("CSQC_Ent_Remove called for already removed entity. Packet loss?\n");
806 if (this.enttype) Ent_Remove();
814 if(!(calledhooks & HOOK_START))
815 localcmd("\n_cl_hook_gamestart ", MapInfo_Type_ToString(gametype), "\n");
816 calledhooks |= HOOK_START;
819 // 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.
820 void CSQC_Parse_StuffCmd(string strMessage)
822 if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Parse_StuffCmd(\"%s\")\n", strMessage);
823 localcmd(strMessage);
825 // 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.
826 void CSQC_Parse_Print(string strMessage)
828 if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Parse_Print(\"%s\")\n", strMessage);
829 print(ColorTranslateRGB(strMessage));
832 // CSQC_Parse_CenterPrint : Provides the centerprint_hud string in the first parameter that the server provided.
833 void CSQC_Parse_CenterPrint(string strMessage)
835 if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Parse_CenterPrint(\"%s\")\n", strMessage);
836 centerprint_hud(strMessage);
839 // CSQC_Parse_TempEntity : Handles all temporary entity network data in the CSQC layer.
840 // You must ALWAYS first acquire the temporary ID, which is sent as a byte.
841 // Return value should be 1 if CSQC handled the temporary entity, otherwise return 0 to have the engine process the event.
842 bool CSQC_Parse_TempEntity()
845 int nTEID = ReadByte();
847 FOREACH(TempEntities, it.m_id == nTEID, LAMBDA(
848 if (autocvar_developer_csqcentities)
849 LOG_INFOF("CSQC_Parse_TempEntity() nTEID=%s (%d)\n", it.netname, nTEID);
850 return it.m_read(NULL, NULL, true);
853 if (autocvar_developer_csqcentities)
854 LOG_INFOF("CSQC_Parse_TempEntity() with nTEID=%d\n", nTEID);
856 // No special logic for this temporary entity; return 0 so the engine can handle it
860 /** TODO somehow thwart prvm_globalset client ... */
864 if (autocvar_cl_orthoview && autocvar_cl_orthoview_nofog)
865 localcmd("\nr_drawfog 0\n");
866 else if (forcefog != "")
867 localcmd(sprintf("\nfog %s\nr_fog_exp2 0\nr_drawfog 1\n", forcefog));
870 void Gamemode_Init();
871 NET_HANDLE(ENT_CLIENT_SCORES_INFO, bool isnew)
874 gametype = ReadInt24_t();
875 HUD_ModIcons_SetFunc();
876 for (int i = 0; i < MAX_SCORE; ++i)
878 if (scores_label[i]) strunzone(scores_label[i]);
879 scores_label[i] = strzone(ReadString());
880 scores_flags[i] = ReadByte();
882 for (int i = 0; i < MAX_TEAMSCORE; ++i)
884 if (teamscores_label[i]) strunzone(teamscores_label[i]);
885 teamscores_label[i] = strzone(ReadString());
886 teamscores_flags[i] = ReadByte();
893 NET_HANDLE(ENT_CLIENT_INIT, bool isnew)
895 nb_pb_period = ReadByte() / 32; //Accuracy of 1/32th
897 hook_shotorigin[0] = decompressShotOrigin(ReadInt24_t());
898 hook_shotorigin[1] = decompressShotOrigin(ReadInt24_t());
899 hook_shotorigin[2] = decompressShotOrigin(ReadInt24_t());
900 hook_shotorigin[3] = decompressShotOrigin(ReadInt24_t());
901 arc_shotorigin[0] = decompressShotOrigin(ReadInt24_t());
902 arc_shotorigin[1] = decompressShotOrigin(ReadInt24_t());
903 arc_shotorigin[2] = decompressShotOrigin(ReadInt24_t());
904 arc_shotorigin[3] = decompressShotOrigin(ReadInt24_t());
906 if (forcefog) strunzone(forcefog);
907 forcefog = strzone(ReadString());
909 armorblockpercent = ReadByte() / 255.0;
911 serverflags = ReadByte();
913 g_trueaim_minrange = ReadCoord();
917 MUTATOR_CALLHOOK(Ent_Init);
919 if (!postinit) PostInit();
922 NET_HANDLE(TE_CSQC_RACE, bool isNew)
928 case RACE_NET_CHECKPOINT_HIT_QUALIFYING:
929 race_checkpoint = ReadByte();
930 race_time = ReadInt24_t();
931 race_previousbesttime = ReadInt24_t();
932 if(race_previousbestname)
933 strunzone(race_previousbestname);
934 race_previousbestname = strzone(ColorTranslateRGB(ReadString()));
936 race_checkpointtime = time;
938 if(race_checkpoint == 0 || race_checkpoint == 254)
940 race_penaltyaccumulator = 0;
941 race_laptime = time; // valid
946 case RACE_NET_CHECKPOINT_CLEAR:
948 race_checkpointtime = 0;
951 case RACE_NET_CHECKPOINT_NEXT_SPEC_QUALIFYING:
952 race_laptime = ReadCoord();
953 race_checkpointtime = -99999;
955 case RACE_NET_CHECKPOINT_NEXT_QUALIFYING:
956 race_nextcheckpoint = ReadByte();
958 race_nextbesttime = ReadInt24_t();
959 if(race_nextbestname)
960 strunzone(race_nextbestname);
961 race_nextbestname = strzone(ColorTranslateRGB(ReadString()));
964 case RACE_NET_CHECKPOINT_HIT_RACE:
965 race_mycheckpoint = ReadByte();
966 race_mycheckpointtime = time;
967 race_mycheckpointdelta = ReadInt24_t();
968 race_mycheckpointlapsdelta = ReadByte();
969 if(race_mycheckpointlapsdelta >= 128)
970 race_mycheckpointlapsdelta -= 256;
971 if(race_mycheckpointenemy)
972 strunzone(race_mycheckpointenemy);
973 race_mycheckpointenemy = strzone(ColorTranslateRGB(ReadString()));
976 case RACE_NET_CHECKPOINT_HIT_RACE_BY_OPPONENT:
977 race_othercheckpoint = ReadByte();
978 race_othercheckpointtime = time;
979 race_othercheckpointdelta = ReadInt24_t();
980 race_othercheckpointlapsdelta = ReadByte();
981 if(race_othercheckpointlapsdelta >= 128)
982 race_othercheckpointlapsdelta -= 256;
983 if(race_othercheckpointenemy)
984 strunzone(race_othercheckpointenemy);
985 race_othercheckpointenemy = strzone(ColorTranslateRGB(ReadString()));
988 case RACE_NET_PENALTY_RACE:
989 race_penaltyeventtime = time;
990 race_penaltytime = ReadShort();
991 //race_penaltyaccumulator += race_penaltytime;
992 if(race_penaltyreason)
993 strunzone(race_penaltyreason);
994 race_penaltyreason = strzone(ReadString());
997 case RACE_NET_PENALTY_QUALIFYING:
998 race_penaltyeventtime = time;
999 race_penaltytime = ReadShort();
1000 race_penaltyaccumulator += race_penaltytime;
1001 if(race_penaltyreason)
1002 strunzone(race_penaltyreason);
1003 race_penaltyreason = strzone(ReadString());
1006 case RACE_NET_SERVER_RECORD:
1007 race_server_record = ReadInt24_t();
1009 case RACE_NET_SPEED_AWARD:
1010 race_speedaward = ReadInt24_t();
1011 if(race_speedaward_holder)
1012 strunzone(race_speedaward_holder);
1013 race_speedaward_holder = strzone(ReadString());
1015 case RACE_NET_SPEED_AWARD_BEST:
1016 race_speedaward_alltimebest = ReadInt24_t();
1017 if(race_speedaward_alltimebest_holder)
1018 strunzone(race_speedaward_alltimebest_holder);
1019 race_speedaward_alltimebest_holder = strzone(ReadString());
1021 case RACE_NET_SERVER_RANKINGS:
1023 int pos = ReadShort();
1024 prevpos = ReadShort();
1027 // move other rankings out of the way
1030 for (i=prevpos-1;i>pos-1;--i) {
1031 grecordtime[i] = grecordtime[i-1];
1032 if(grecordholder[i])
1033 strunzone(grecordholder[i]);
1034 grecordholder[i] = strzone(grecordholder[i-1]);
1036 } else if (del) { // a record has been deleted by the admin
1037 for (i=pos-1; i<= RANKINGS_CNT-1; ++i) {
1038 if (i == RANKINGS_CNT-1) { // clear out last record
1040 if (grecordholder[i])
1041 strunzone(grecordholder[i]);
1042 grecordholder[i] = string_null;
1045 grecordtime[i] = grecordtime[i+1];
1046 if (grecordholder[i])
1047 strunzone(grecordholder[i]);
1048 grecordholder[i] = strzone(grecordholder[i+1]);
1051 } else { // player has no ranked record yet
1052 for (i=RANKINGS_CNT-1;i>pos-1;--i) {
1053 grecordtime[i] = grecordtime[i-1];
1054 if(grecordholder[i])
1055 strunzone(grecordholder[i]);
1056 grecordholder[i] = strzone(grecordholder[i-1]);
1060 // store new ranking
1061 if(grecordholder[pos-1] != "")
1062 strunzone(grecordholder[pos-1]);
1063 grecordholder[pos-1] = strzone(ReadString());
1064 grecordtime[pos-1] = ReadInt24_t();
1065 if(grecordholder[pos-1] == entcs_GetName(player_localnum))
1068 case RACE_NET_SERVER_STATUS:
1069 race_status = ReadShort();
1070 if(race_status_name)
1071 strunzone(race_status_name);
1072 race_status_name = strzone(ReadString());
1077 NET_HANDLE(TE_CSQC_TEAMNAGGER, bool isNew)
1083 NET_HANDLE(TE_CSQC_PINGPLREPORT, bool isNew)
1086 int pi = ReadShort();
1087 int pl = ReadByte();
1088 int ml = ReadByte();
1090 entity e = playerslots[i];
1093 e.ping_packetloss = pl / 255.0;
1094 e.ping_movementloss = ml / 255.0;
1097 NET_HANDLE(TE_CSQC_WEAPONCOMPLAIN, bool isNew)
1099 complain_weapon = ReadByte();
1100 complain_weapon_type = ReadByte();
1103 complain_weapon_time = time;
1104 weapontime = time; // ping the weapon panel
1106 switch(complain_weapon_type)
1108 case 0: Local_Notification(MSG_MULTI, ITEM_WEAPON_NOAMMO, complain_weapon); break;
1109 case 1: Local_Notification(MSG_MULTI, ITEM_WEAPON_DONTHAVE, complain_weapon); break;
1110 default: Local_Notification(MSG_MULTI, ITEM_WEAPON_UNAVAILABLE, complain_weapon); break;
1114 string getcommandkey(string text, string command)
1117 float n, j, k, l = 0;
1119 if (!autocvar_hud_showbinds)
1122 keys = db_get(binddb, command);
1125 n = tokenize(findkeysforcommand(command, 0)); // uses '...' strings
1126 for(j = 0; j < n; ++j)
1132 keys = keynumtostring(k);
1134 keys = strcat(keys, ", ", keynumtostring(k));
1137 if (autocvar_hud_showbinds_limit > 0 && autocvar_hud_showbinds_limit <= l)
1144 db_put(binddb, command, keys);
1147 if (keys == "NO_KEY") {
1148 if (autocvar_hud_showbinds > 1)
1149 return sprintf(_("%s (not bound)"), text);
1153 else if (autocvar_hud_showbinds > 1)
1154 return sprintf("%s (%s)", text, keys);