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"
11 #include "../common/t_items.qh"
13 #include "weapons/projectile.qh"
14 #include "../common/deathtypes/all.qh"
15 #include "../common/items/all.qh"
16 #include "../common/mapinfo.qh"
17 #include "../common/minigames/cl_minigames.qh"
18 #include "../common/minigames/cl_minigames_hud.qh"
19 #include "../common/net_notice.qh"
20 #include "../common/triggers/include.qh"
21 #include "../common/vehicles/all.qh"
22 #include "../lib/csqcmodel/cl_model.qh"
23 #include "../lib/csqcmodel/interpolate.qh"
24 #include "../lib/warpzone/client.qh"
26 // --------------------------------------------------------------------------
27 // BEGIN REQUIRED CSQC FUNCTIONS
30 #define DP_CSQC_ENTITY_REMOVE_IS_B0RKED
32 // CSQC_Init : Called every time the CSQC code is initialized (essentially at map load)
33 // Useful for precaching things
35 void ConsoleCommand_macro_init();
38 prvm_language = strzone(cvar_string("prvm_language"));
41 LOG_INFOF("^4CSQC Build information: ^1%s\n", WATERMARK);
47 if (getplayerkeyvalue(i, "viewentity") == "")
52 // needs to be done so early because of the constants they create
55 static_init_precache();
59 ClientProgsDB = db_load("client.db");
60 compressShortVector_init();
64 //registercommand("hud_configure");
65 //registercommand("hud_save");
66 //registercommand("menu_action");
68 ConsoleCommand_macro_init();
70 registercvar("hud_usecsqc", "1");
71 registercvar("scoreboard_columns", "default");
73 registercvar("cl_nade_type", "3");
74 registercvar("cl_pokenade_type", "zombie");
76 registercvar("cl_jumpspeedcap_min", "");
77 registercvar("cl_jumpspeedcap_max", "");
79 registercvar("cl_multijump", "0");
81 registercvar("cl_spawn_near_teammate", "1");
85 // hud_fields uses strunzone on the titles!
86 for(int i = 0; i < MAX_HUD_FIELDS; ++i)
87 hud_title[i] = strzone("(null)");
96 players = Sort_Spawn();
98 GetTeam(NUM_SPECTATOR, true); // add specs first
102 if(autocvar_cl_reticle)
104 precache_pic("gfx/reticle_normal");
105 // weapon reticles are precached in weapon files
109 get_mi_min_max_texcoords(1); // try the CLEVER way first
110 minimapname = strcat("gfx/", mi_shortname, "_radar.tga");
111 shortmapname = mi_shortname;
113 if (precache_pic(minimapname) == "")
115 // but maybe we have a non-clever minimap
116 minimapname = strcat("gfx/", mi_shortname, "_mini.tga");
117 if (precache_pic(minimapname) == "")
118 minimapname = ""; // FAIL
120 get_mi_min_max_texcoords(0); // load new texcoords
123 mi_center = (mi_min + mi_max) * 0.5;
124 mi_scale = mi_max - mi_min;
125 minimapname = strzone(minimapname);
128 hud_skin_path = strzone(strcat("gfx/hud/", autocvar_hud_skin));
129 draw_currentSkin = strzone(strcat("gfx/menu/", cvar_string("menu_skin")));
132 // CSQC_Shutdown : Called every time the CSQC code is shutdown (changing maps, quitting, etc)
141 if(autocvar_cl_db_saveasdump)
142 db_dump(ClientProgsDB, "client.db");
144 db_save(ClientProgsDB, "client.db");
145 db_close(ClientProgsDB);
148 cvar_set("chase_active",ftos(chase_active_backup));
150 // unset the event chasecam's chase_active
151 if(autocvar_chase_active < 0)
152 cvar_set("chase_active", "0");
156 if (!(calledhooks & HOOK_START))
157 localcmd("\n_cl_hook_gamestart nop\n");
158 if (!(calledhooks & HOOK_END))
159 localcmd("\ncl_hook_gameend\n");
162 deactivate_minigame();
163 HUD_MinigameMenu_Close();
167 float SetTeam(entity o, int Team)
169 devassert_once(Team);
182 if(GetTeam(Team, false) == world)
184 LOG_TRACEF("trying to switch to unsupported team %d\n", Team);
185 Team = NUM_SPECTATOR;
198 if(GetTeam(Team, false) == world)
200 LOG_TRACEF("trying to switch to unsupported team %d\n", Team);
201 Team = NUM_SPECTATOR;
206 if(Team == -1) // leave
210 tm = GetTeam(o.team, false);
221 tm = GetTeam(Team, true);
226 else if(Team != o.team)
228 tm = GetTeam(o.team, false);
231 tm = GetTeam(Team, true);
239 void Playerchecker_Think()
244 for(i = 0; i < maxclients; ++i)
247 if(entcs_GetName(i) == "")
251 // player disconnected
265 playerslots[i] = e = new(playerslot);
270 e.ping_packetloss = 0;
271 e.ping_movementloss = 0;
272 //e.gotscores = 0; // we might already have the scores...
273 int t = entcs_GetScoreTeam(i);
274 if (t) SetTeam(e, t); // will not hurt; later updates come with HUD_UpdatePlayerTeams
276 HUD_UpdatePlayerPos(e);
280 this.nextthink = time + 0.2;
287 entity playerchecker = new(playerchecker);
288 make_pure(playerchecker);
289 playerchecker.think = Playerchecker_Think;
290 playerchecker.nextthink = time + 0.2;
298 // CSQC_InputEvent : Used to perform actions based on any key pressed, key released and mouse on the client.
299 // Return value should be 1 if CSQC handled the input, otherwise return 0 to have the input passed to the engine.
300 // All keys are in ascii.
301 // bInputType = 0 is key pressed, 1 is key released, 2 and 3 are mouse input.
302 // In the case of keyboard input, nPrimary is the ascii code, and nSecondary is 0.
303 // In the case of mouse input, nPrimary is xdelta, nSecondary is ydelta.
304 // In the case of mouse input after a setcursormode(1) call, nPrimary is xpos, nSecondary is ypos.
305 float CSQC_InputEvent(float bInputType, float nPrimary, float nSecondary)
307 if (HUD_Panel_InputEvent(bInputType, nPrimary, nSecondary))
310 if (QuickMenu_InputEvent(bInputType, nPrimary, nSecondary))
313 if (HUD_Radar_InputEvent(bInputType, nPrimary, nSecondary))
316 if (MapVote_InputEvent(bInputType, nPrimary, nSecondary))
319 if (HUD_Minigame_InputEvent(bInputType, nPrimary, nSecondary))
325 // END REQUIRED CSQC FUNCTIONS
326 // --------------------------------------------------------------------------
328 // --------------------------------------------------------------------------
329 // BEGIN OPTIONAL CSQC FUNCTIONS
333 void Ent_RemovePlayerScore()
337 SetTeam(this.owner, -1);
338 this.owner.gotscores = 0;
339 for(int i = 0; i < MAX_SCORE; ++i) {
340 this.owner.(scores[i]) = 0; // clear all scores
345 NET_HANDLE(ENT_CLIENT_SCORES, bool isnew)
352 // damnit -.- don't want to go change every single .sv_entnum in hud.qc AGAIN
353 // (no I've never heard of M-x replace-string, sed, or anything like that)
354 isNew = !this.owner; // workaround for DP bug
357 #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
358 if(!isNew && n != this.sv_entnum)
360 //print("A CSQC entity changed its owner!\n");
361 LOG_INFOF("A CSQC entity changed its owner! (edict: %d, classname: %s)\n", etof(this), this.classname);
369 o = playerslots[this.sv_entnum];
372 o = playerslots[this.sv_entnum] = new(playerslot);
376 o.sv_entnum = this.sv_entnum;
380 // RegisterPlayer(o);
381 //playerchecker will do this for us later, if it has not already done so
392 for(i = 0, p = 1; i < MAX_SCORE; ++i, p *= 2)
396 o.(scores[i]) = ReadInt24_t();
398 o.(scores[i]) = ReadChar();
404 HUD_UpdatePlayerPos(o); // if not registered, we cannot do this yet!
406 this.entremove = Ent_RemovePlayerScore;
409 NET_HANDLE(ENT_CLIENT_TEAMSCORES, bool isnew)
415 this.team = ReadByte();
416 o = this.owner = GetTeam(this.team, true); // these team numbers can always be trusted
419 #if MAX_TEAMSCORE <= 8
427 for(i = 0, p = 1; i < MAX_TEAMSCORE; ++i, p *= 2)
431 o.(teamscores[i]) = ReadInt24_t();
433 o.(teamscores[i]) = ReadChar();
438 HUD_UpdateTeamPos(o);
441 NET_HANDLE(ENT_CLIENT_CLIENTDATA, bool isnew)
444 float newspectatee_status;
448 scoreboard_showscores_force = (f & 1);
452 newspectatee_status = ReadByte();
453 if(newspectatee_status == player_localnum + 1)
454 newspectatee_status = -1; // observing
457 newspectatee_status = 0;
459 spectatorbutton_zoom = (f & 4);
463 angles_held_status = 1;
464 angles_held.x = ReadAngle();
465 angles_held.y = ReadAngle();
469 angles_held_status = 0;
473 if(newspectatee_status != spectatee_status)
477 race_checkpointtime = 0;
479 if (autocvar_hud_panel_healtharmor_progressbar_gfx)
481 if ( (spectatee_status == -1 && newspectatee_status > 0) //before observing, now spectating
482 || (spectatee_status > 0 && newspectatee_status > 0 && spectatee_status != newspectatee_status) //changed spectated player
485 else if(spectatee_status && !newspectatee_status) //before observing/spectating, now playing
488 spectatee_status = newspectatee_status;
490 // we could get rid of spectatee_status, and derive it from player_localentnum and player_localnum
493 NET_HANDLE(ENT_CLIENT_NAGGER, bool isnew)
498 int nags = ReadByte(); // NAGS NAGS NAGS NAGS NAGS NAGS NADZ NAGS NAGS NAGS
503 strunzone(vote_called_vote);
504 vote_called_vote = string_null;
514 vote_yescount = ReadByte();
515 vote_nocount = ReadByte();
516 vote_needed = ReadByte();
517 vote_highlighted = ReadChar();
523 strunzone(vote_called_vote);
524 vote_called_vote = strzone(ColorTranslateRGB(ReadString()));
529 for(j = 0; j < maxclients; ++j)
531 playerslots[j].ready = 1;
532 for(i = 1; i <= maxclients; i += 8)
535 for(j = i-1, b = 1; b < 256; b *= 2, ++j)
538 playerslots[j].ready = 0;
544 ready_waiting = (nags & BIT(0));
545 ready_waiting_for_me = (nags & BIT(1));
546 vote_waiting = (nags & BIT(2));
547 vote_waiting_for_me = (nags & BIT(3));
548 warmup_stage = (nags & BIT(4));
551 NET_HANDLE(ENT_CLIENT_ELIMINATEDPLAYERS, bool isnew)
559 for(j = 0; j < maxclients; ++j)
561 playerslots[j].eliminated = 1;
562 for(i = 1; i <= maxclients; i += 8)
565 for(j = i-1, b = 1; b < 256; b *= 2, ++j)
568 playerslots[j].eliminated = 0;
574 NET_HANDLE(ENT_CLIENT_RANDOMSEED, bool isnew)
578 float s = ReadShort();
583 NET_HANDLE(ENT_CLIENT_ACCURACY, bool isnew)
586 int sf = ReadInt24_t();
588 for (int w = 0; w <= WEP_LAST - WEP_FIRST; ++w)
589 weapon_accuracy[w] = -1;
594 for (int w = 0; w <= WEP_LAST - WEP_FIRST; ++w) {
598 weapon_accuracy[w] = -1;
600 weapon_accuracy[w] = 1.0; // no better error handling yet, sorry
602 weapon_accuracy[w] = (b - 1.0) / 100.0;
604 f = (f == 0x800000) ? 1 : f * 2;
609 void Spawn_Draw(entity this)
611 __pointparticles(this.cnt, this.origin + '0 0 28', '0 0 2', bound(0, frametime, 0.1));
614 NET_HANDLE(ENT_CLIENT_SPAWNPOINT, bool is_new)
616 float teamnum = (ReadByte() - 1);
618 spn_origin.x = ReadShort();
619 spn_origin.y = ReadShort();
620 spn_origin.z = ReadShort();
624 this.origin = spn_origin;
625 setsize(this, PL_MIN_CONST, PL_MAX_CONST);
628 /*if(autocvar_cl_spawn_point_model) // needs a model first
630 this.mdl = "models/spawnpoint.md3";
631 this.colormod = Team_ColorRGB(teamnum);
632 precache_model(this.mdl);
633 setmodel(this, this.mdl);
634 this.drawmask = MASK_NORMAL;
635 //this.movetype = MOVETYPE_NOCLIP;
636 //this.draw = Spawn_Draw;
638 if(autocvar_cl_spawn_point_particles)
640 if((serverflags & SERVERFLAG_TEAMPLAY))
644 case NUM_TEAM_1: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_RED); break;
645 case NUM_TEAM_2: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_BLUE); break;
646 case NUM_TEAM_3: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_YELLOW); break;
647 case NUM_TEAM_4: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_PINK); break;
648 default: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_NEUTRAL); break;
651 else { this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_NEUTRAL); }
653 this.draw = Spawn_Draw;
657 //printf("Ent_ReadSpawnPoint(is_new = %d); origin = %s, team = %d, effect = %d\n", is_new, vtos(this.origin), teamnum, this.cnt);
661 NET_HANDLE(ENT_CLIENT_SPAWNEVENT, bool is_new)
663 // If entnum is 0, ONLY do the local spawn actions
664 // this way the server can disable the sending of
665 // spawn origin or such to clients if wanted.
666 float entnum = ReadByte();
670 this.origin_x = ReadShort();
671 this.origin_y = ReadShort();
672 this.origin_z = ReadShort();
676 float teamnum = entcs_GetTeam(entnum - 1);
678 if(autocvar_cl_spawn_event_particles)
682 case NUM_TEAM_1: pointparticles(EFFECT_SPAWN_RED, this.origin, '0 0 0', 1); break;
683 case NUM_TEAM_2: pointparticles(EFFECT_SPAWN_BLUE, this.origin, '0 0 0', 1); break;
684 case NUM_TEAM_3: pointparticles(EFFECT_SPAWN_YELLOW, this.origin, '0 0 0', 1); break;
685 case NUM_TEAM_4: pointparticles(EFFECT_SPAWN_PINK, this.origin, '0 0 0', 1); break;
686 default: pointparticles(EFFECT_SPAWN_NEUTRAL, this.origin, '0 0 0', 1); break;
689 if(autocvar_cl_spawn_event_sound)
691 sound(this, CH_TRIGGER, SND_SPAWN, VOL_BASE, ATTEN_NORM);
697 // local spawn actions
698 if(is_new && (!entnum || (entnum == player_localentnum)))
701 current_viewzoom = (1 / bound(1, autocvar_cl_spawnzoom_factor, 16));
703 if(autocvar_cl_unpress_zoom_on_spawn)
709 HUD_Radar_Hide_Maximized();
710 //printf("Ent_ReadSpawnEvent(is_new = %d); origin = %s, entnum = %d, localentnum = %d\n", is_new, vtos(this.origin), entnum, player_localentnum);
713 // CSQC_Ent_Update : Called every frame that the server has indicated an update to the SSQC / CSQC entity has occured.
714 // The only parameter reflects if the entity is "new" to the client, meaning it just came into the client's PVS.
715 void CSQC_Ent_Update(bool isnew)
718 this.sourceLocLine = __LINE__;
719 this.sourceLocFile = __FILE__;
722 // set up the "time" global for received entities to be correct for interpolation purposes
723 float savetime = time;
730 serverprevtime = time;
731 serverdeltatime = STAT(MOVEVARS_TICRATE) * STAT(MOVEVARS_TIMESCALE);
732 time = serverprevtime + serverdeltatime;
735 #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
738 if (t != this.enttype || isnew)
740 LOG_INFOF("A CSQC entity changed its type! (edict: %d, server: %d, type: %d -> %d)\n", etof(this), this.entnum, this.enttype, t);
750 LOG_INFOF("A CSQC entity appeared out of nowhere! (edict: %d, server: %d, type: %d)\n", etof(this), this.entnum, t);
757 FOREACH(LinkedEntities, it.m_id == t, LAMBDA(
758 if (isnew) this.classname = it.netname;
759 if (autocvar_developer_csqcentities)
760 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);
761 done = it.m_read(this, NULL, isnew);
767 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);
771 // Destructor, but does NOT deallocate the entity by calling remove(). Also
772 // used when an entity changes its type. For an entity that someone interacts
773 // with others, make sure it can no longer do so.
777 if(this.entremove) this.entremove();
779 if(this.skeletonindex)
781 skel_delete(this.skeletonindex);
782 this.skeletonindex = 0;
785 if(this.snd_looping > 0)
787 sound(this, this.snd_looping, SND_Null, VOL_BASE, autocvar_g_jetpack_attenuation);
788 this.snd_looping = 0;
793 this.draw = func_null;
794 this.entremove = func_null;
795 // TODO possibly set more stuff to defaults
797 // CSQC_Ent_Remove : Called when the server requests a SSQC / CSQC entity to be removed. Essentially call remove(this) as well.
798 void CSQC_Ent_Remove()
801 if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Ent_Remove() with this=%i {.entnum=%d, .enttype=%d}\n", this, this.entnum, this.enttype);
804 LOG_WARNING("CSQC_Ent_Remove called for already removed entity. Packet loss?\n");
807 if (this.enttype) Ent_Remove();
815 if(!(calledhooks & HOOK_START))
816 localcmd("\n_cl_hook_gamestart ", MapInfo_Type_ToString(gametype), "\n");
817 calledhooks |= HOOK_START;
820 // 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.
821 void CSQC_Parse_StuffCmd(string strMessage)
823 if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Parse_StuffCmd(\"%s\")\n", strMessage);
824 localcmd(strMessage);
826 // 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.
827 void CSQC_Parse_Print(string strMessage)
829 if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Parse_Print(\"%s\")\n", strMessage);
830 print(ColorTranslateRGB(strMessage));
833 // CSQC_Parse_CenterPrint : Provides the centerprint_hud string in the first parameter that the server provided.
834 void CSQC_Parse_CenterPrint(string strMessage)
836 if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Parse_CenterPrint(\"%s\")\n", strMessage);
837 centerprint_hud(strMessage);
840 // CSQC_Parse_TempEntity : Handles all temporary entity network data in the CSQC layer.
841 // You must ALWAYS first acquire the temporary ID, which is sent as a byte.
842 // Return value should be 1 if CSQC handled the temporary entity, otherwise return 0 to have the engine process the event.
843 bool CSQC_Parse_TempEntity()
846 int nTEID = ReadByte();
848 FOREACH(TempEntities, it.m_id == nTEID, LAMBDA(
849 if (autocvar_developer_csqcentities)
850 LOG_INFOF("CSQC_Parse_TempEntity() nTEID=%s (%d)\n", it.netname, nTEID);
851 return it.m_read(NULL, NULL, true);
854 if (autocvar_developer_csqcentities)
855 LOG_INFOF("CSQC_Parse_TempEntity() with nTEID=%d\n", nTEID);
857 // No special logic for this temporary entity; return 0 so the engine can handle it
861 /** TODO somehow thwart prvm_globalset client ... */
865 if (autocvar_cl_orthoview && autocvar_cl_orthoview_nofog)
866 localcmd("\nr_drawfog 0\n");
867 else if (forcefog != "")
868 localcmd(sprintf("\nfog %s\nr_fog_exp2 0\nr_drawfog 1\n", forcefog));
871 void Gamemode_Init();
872 NET_HANDLE(ENT_CLIENT_SCORES_INFO, bool isnew)
875 gametype = ReadInt24_t();
876 HUD_ModIcons_SetFunc();
877 for (int i = 0; i < MAX_SCORE; ++i)
879 if (scores_label[i]) strunzone(scores_label[i]);
880 scores_label[i] = strzone(ReadString());
881 scores_flags[i] = ReadByte();
883 for (int i = 0; i < MAX_TEAMSCORE; ++i)
885 if (teamscores_label[i]) strunzone(teamscores_label[i]);
886 teamscores_label[i] = strzone(ReadString());
887 teamscores_flags[i] = ReadByte();
894 NET_HANDLE(ENT_CLIENT_INIT, bool isnew)
896 nb_pb_period = ReadByte() / 32; //Accuracy of 1/32th
898 hook_shotorigin[0] = decompressShotOrigin(ReadInt24_t());
899 hook_shotorigin[1] = decompressShotOrigin(ReadInt24_t());
900 hook_shotorigin[2] = decompressShotOrigin(ReadInt24_t());
901 hook_shotorigin[3] = decompressShotOrigin(ReadInt24_t());
902 arc_shotorigin[0] = decompressShotOrigin(ReadInt24_t());
903 arc_shotorigin[1] = decompressShotOrigin(ReadInt24_t());
904 arc_shotorigin[2] = decompressShotOrigin(ReadInt24_t());
905 arc_shotorigin[3] = decompressShotOrigin(ReadInt24_t());
907 if (forcefog) strunzone(forcefog);
908 forcefog = strzone(ReadString());
910 armorblockpercent = ReadByte() / 255.0;
912 serverflags = ReadByte();
914 g_trueaim_minrange = ReadCoord();
918 MUTATOR_CALLHOOK(Ent_Init);
920 if (!postinit) PostInit();
923 NET_HANDLE(TE_CSQC_RACE, bool isNew)
929 case RACE_NET_CHECKPOINT_HIT_QUALIFYING:
930 race_checkpoint = ReadByte();
931 race_time = ReadInt24_t();
932 race_previousbesttime = ReadInt24_t();
933 if(race_previousbestname)
934 strunzone(race_previousbestname);
935 race_previousbestname = strzone(ColorTranslateRGB(ReadString()));
937 race_checkpointtime = time;
939 if(race_checkpoint == 0 || race_checkpoint == 254)
941 race_penaltyaccumulator = 0;
942 race_laptime = time; // valid
947 case RACE_NET_CHECKPOINT_CLEAR:
949 race_checkpointtime = 0;
952 case RACE_NET_CHECKPOINT_NEXT_SPEC_QUALIFYING:
953 race_laptime = ReadCoord();
954 race_checkpointtime = -99999;
956 case RACE_NET_CHECKPOINT_NEXT_QUALIFYING:
957 race_nextcheckpoint = ReadByte();
959 race_nextbesttime = ReadInt24_t();
960 if(race_nextbestname)
961 strunzone(race_nextbestname);
962 race_nextbestname = strzone(ColorTranslateRGB(ReadString()));
965 case RACE_NET_CHECKPOINT_HIT_RACE:
966 race_mycheckpoint = ReadByte();
967 race_mycheckpointtime = time;
968 race_mycheckpointdelta = ReadInt24_t();
969 race_mycheckpointlapsdelta = ReadByte();
970 if(race_mycheckpointlapsdelta >= 128)
971 race_mycheckpointlapsdelta -= 256;
972 if(race_mycheckpointenemy)
973 strunzone(race_mycheckpointenemy);
974 race_mycheckpointenemy = strzone(ColorTranslateRGB(ReadString()));
977 case RACE_NET_CHECKPOINT_HIT_RACE_BY_OPPONENT:
978 race_othercheckpoint = ReadByte();
979 race_othercheckpointtime = time;
980 race_othercheckpointdelta = ReadInt24_t();
981 race_othercheckpointlapsdelta = ReadByte();
982 if(race_othercheckpointlapsdelta >= 128)
983 race_othercheckpointlapsdelta -= 256;
984 if(race_othercheckpointenemy)
985 strunzone(race_othercheckpointenemy);
986 race_othercheckpointenemy = strzone(ColorTranslateRGB(ReadString()));
989 case RACE_NET_PENALTY_RACE:
990 race_penaltyeventtime = time;
991 race_penaltytime = ReadShort();
992 //race_penaltyaccumulator += race_penaltytime;
993 if(race_penaltyreason)
994 strunzone(race_penaltyreason);
995 race_penaltyreason = strzone(ReadString());
998 case RACE_NET_PENALTY_QUALIFYING:
999 race_penaltyeventtime = time;
1000 race_penaltytime = ReadShort();
1001 race_penaltyaccumulator += race_penaltytime;
1002 if(race_penaltyreason)
1003 strunzone(race_penaltyreason);
1004 race_penaltyreason = strzone(ReadString());
1007 case RACE_NET_SERVER_RECORD:
1008 race_server_record = ReadInt24_t();
1010 case RACE_NET_SPEED_AWARD:
1011 race_speedaward = ReadInt24_t();
1012 if(race_speedaward_holder)
1013 strunzone(race_speedaward_holder);
1014 race_speedaward_holder = strzone(ReadString());
1016 case RACE_NET_SPEED_AWARD_BEST:
1017 race_speedaward_alltimebest = ReadInt24_t();
1018 if(race_speedaward_alltimebest_holder)
1019 strunzone(race_speedaward_alltimebest_holder);
1020 race_speedaward_alltimebest_holder = strzone(ReadString());
1022 case RACE_NET_SERVER_RANKINGS:
1024 int pos = ReadShort();
1025 prevpos = ReadShort();
1028 // move other rankings out of the way
1031 for (i=prevpos-1;i>pos-1;--i) {
1032 grecordtime[i] = grecordtime[i-1];
1033 if(grecordholder[i])
1034 strunzone(grecordholder[i]);
1035 grecordholder[i] = strzone(grecordholder[i-1]);
1037 } else if (del) { // a record has been deleted by the admin
1038 for (i=pos-1; i<= RANKINGS_CNT-1; ++i) {
1039 if (i == RANKINGS_CNT-1) { // clear out last record
1041 if (grecordholder[i])
1042 strunzone(grecordholder[i]);
1043 grecordholder[i] = string_null;
1046 grecordtime[i] = grecordtime[i+1];
1047 if (grecordholder[i])
1048 strunzone(grecordholder[i]);
1049 grecordholder[i] = strzone(grecordholder[i+1]);
1052 } else { // player has no ranked record yet
1053 for (i=RANKINGS_CNT-1;i>pos-1;--i) {
1054 grecordtime[i] = grecordtime[i-1];
1055 if(grecordholder[i])
1056 strunzone(grecordholder[i]);
1057 grecordholder[i] = strzone(grecordholder[i-1]);
1061 // store new ranking
1062 if(grecordholder[pos-1] != "")
1063 strunzone(grecordholder[pos-1]);
1064 grecordholder[pos-1] = strzone(ReadString());
1065 grecordtime[pos-1] = ReadInt24_t();
1066 if(grecordholder[pos-1] == entcs_GetName(player_localnum))
1069 case RACE_NET_SERVER_STATUS:
1070 race_status = ReadShort();
1071 if(race_status_name)
1072 strunzone(race_status_name);
1073 race_status_name = strzone(ReadString());
1078 NET_HANDLE(TE_CSQC_TEAMNAGGER, bool isNew)
1084 NET_HANDLE(TE_CSQC_PINGPLREPORT, bool isNew)
1087 int pi = ReadShort();
1088 int pl = ReadByte();
1089 int ml = ReadByte();
1091 entity e = playerslots[i];
1094 e.ping_packetloss = pl / 255.0;
1095 e.ping_movementloss = ml / 255.0;
1098 NET_HANDLE(TE_CSQC_WEAPONCOMPLAIN, bool isNew)
1100 complain_weapon = ReadByte();
1101 complain_weapon_type = ReadByte();
1104 complain_weapon_time = time;
1105 weapontime = time; // ping the weapon panel
1107 switch(complain_weapon_type)
1109 case 0: Local_Notification(MSG_MULTI, ITEM_WEAPON_NOAMMO, complain_weapon); break;
1110 case 1: Local_Notification(MSG_MULTI, ITEM_WEAPON_DONTHAVE, complain_weapon); break;
1111 default: Local_Notification(MSG_MULTI, ITEM_WEAPON_UNAVAILABLE, complain_weapon); break;
1115 string getcommandkey(string text, string command)
1118 float n, j, k, l = 0;
1120 if (!autocvar_hud_showbinds)
1123 keys = db_get(binddb, command);
1126 n = tokenize(findkeysforcommand(command, 0)); // uses '...' strings
1127 for(j = 0; j < n; ++j)
1133 keys = keynumtostring(k);
1135 keys = strcat(keys, ", ", keynumtostring(k));
1138 if (autocvar_hud_showbinds_limit > 0 && autocvar_hud_showbinds_limit <= l)
1145 db_put(binddb, command, keys);
1148 if (keys == "NO_KEY") {
1149 if (autocvar_hud_showbinds > 1)
1150 return sprintf(_("%s (not bound)"), text);
1154 else if (autocvar_hud_showbinds > 1)
1155 return sprintf("%s (%s)", text, keys);