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
330 .void(entity) predraw_qc;
334 self.predraw_qc(self);
337 void setpredraw(entity this, void(entity) pdfunc)
339 this.predraw = PreDraw_self;
340 this.predraw_qc = pdfunc;
343 void Ent_Remove(entity this);
345 void Ent_RemovePlayerScore(entity this)
348 SetTeam(this.owner, -1);
349 this.owner.gotscores = 0;
350 for(int i = 0; i < MAX_SCORE; ++i) {
351 this.owner.(scores[i]) = 0; // clear all scores
356 NET_HANDLE(ENT_CLIENT_SCORES, bool isnew)
363 // damnit -.- don't want to go change every single .sv_entnum in hud.qc AGAIN
364 // (no I've never heard of M-x replace-string, sed, or anything like that)
365 isNew = !this.owner; // workaround for DP bug
368 #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
369 if(!isNew && n != this.sv_entnum)
371 //print("A CSQC entity changed its owner!\n");
372 LOG_INFOF("A CSQC entity changed its owner! (edict: %d, classname: %s)\n", etof(this), this.classname);
380 o = playerslots[this.sv_entnum];
383 o = playerslots[this.sv_entnum] = new(playerslot);
387 o.sv_entnum = this.sv_entnum;
391 // RegisterPlayer(o);
392 //playerchecker will do this for us later, if it has not already done so
403 for(i = 0, p = 1; i < MAX_SCORE; ++i, p *= 2)
407 o.(scores[i]) = ReadInt24_t();
409 o.(scores[i]) = ReadChar();
415 HUD_UpdatePlayerPos(o); // if not registered, we cannot do this yet!
417 this.entremove = Ent_RemovePlayerScore;
420 NET_HANDLE(ENT_CLIENT_TEAMSCORES, bool isnew)
426 this.team = ReadByte();
427 o = this.owner = GetTeam(this.team, true); // these team numbers can always be trusted
430 #if MAX_TEAMSCORE <= 8
438 for(i = 0, p = 1; i < MAX_TEAMSCORE; ++i, p *= 2)
442 o.(teamscores[i]) = ReadInt24_t();
444 o.(teamscores[i]) = ReadChar();
449 HUD_UpdateTeamPos(o);
452 NET_HANDLE(ENT_CLIENT_CLIENTDATA, bool isnew)
455 float newspectatee_status;
459 scoreboard_showscores_force = (f & 1);
463 newspectatee_status = ReadByte();
464 if(newspectatee_status == player_localnum + 1)
465 newspectatee_status = -1; // observing
468 newspectatee_status = 0;
470 spectatorbutton_zoom = (f & 4);
474 angles_held_status = 1;
475 angles_held.x = ReadAngle();
476 angles_held.y = ReadAngle();
480 angles_held_status = 0;
484 if(newspectatee_status != spectatee_status)
488 race_checkpointtime = 0;
490 if (autocvar_hud_panel_healtharmor_progressbar_gfx)
492 if ( (spectatee_status == -1 && newspectatee_status > 0) //before observing, now spectating
493 || (spectatee_status > 0 && newspectatee_status > 0 && spectatee_status != newspectatee_status) //changed spectated player
496 else if(spectatee_status && !newspectatee_status) //before observing/spectating, now playing
499 spectatee_status = newspectatee_status;
501 // we could get rid of spectatee_status, and derive it from player_localentnum and player_localnum
504 NET_HANDLE(ENT_CLIENT_NAGGER, bool isnew)
509 int nags = ReadByte(); // NAGS NAGS NAGS NAGS NAGS NAGS NADZ NAGS NAGS NAGS
514 strunzone(vote_called_vote);
515 vote_called_vote = string_null;
525 vote_yescount = ReadByte();
526 vote_nocount = ReadByte();
527 vote_needed = ReadByte();
528 vote_highlighted = ReadChar();
534 strunzone(vote_called_vote);
535 vote_called_vote = strzone(ColorTranslateRGB(ReadString()));
540 for(j = 0; j < maxclients; ++j)
542 playerslots[j].ready = 1;
543 for(i = 1; i <= maxclients; i += 8)
546 for(j = i-1, b = 1; b < 256; b *= 2, ++j)
549 playerslots[j].ready = 0;
555 ready_waiting = (nags & BIT(0));
556 ready_waiting_for_me = (nags & BIT(1));
557 vote_waiting = (nags & BIT(2));
558 vote_waiting_for_me = (nags & BIT(3));
559 warmup_stage = (nags & BIT(4));
562 NET_HANDLE(ENT_CLIENT_ELIMINATEDPLAYERS, bool isnew)
570 for(j = 0; j < maxclients; ++j)
572 playerslots[j].eliminated = 1;
573 for(i = 1; i <= maxclients; i += 8)
576 for(j = i-1, b = 1; b < 256; b *= 2, ++j)
579 playerslots[j].eliminated = 0;
585 NET_HANDLE(ENT_CLIENT_RANDOMSEED, bool isnew)
589 float s = ReadShort();
594 NET_HANDLE(ENT_CLIENT_ACCURACY, bool isnew)
597 int sf = ReadInt24_t();
599 for (int w = 0; w <= WEP_LAST - WEP_FIRST; ++w)
600 weapon_accuracy[w] = -1;
605 for (int w = 0; w <= WEP_LAST - WEP_FIRST; ++w) {
609 weapon_accuracy[w] = -1;
611 weapon_accuracy[w] = 1.0; // no better error handling yet, sorry
613 weapon_accuracy[w] = (b - 1.0) / 100.0;
615 f = (f == 0x800000) ? 1 : f * 2;
620 void Spawn_Draw(entity this)
622 __pointparticles(this.cnt, this.origin + '0 0 28', '0 0 2', bound(0, frametime, 0.1));
625 NET_HANDLE(ENT_CLIENT_SPAWNPOINT, bool is_new)
627 float teamnum = (ReadByte() - 1);
629 spn_origin.x = ReadShort();
630 spn_origin.y = ReadShort();
631 spn_origin.z = ReadShort();
635 this.origin = spn_origin;
636 setsize(this, PL_MIN_CONST, PL_MAX_CONST);
639 /*if(autocvar_cl_spawn_point_model) // needs a model first
641 this.mdl = "models/spawnpoint.md3";
642 this.colormod = Team_ColorRGB(teamnum);
643 precache_model(this.mdl);
644 setmodel(this, this.mdl);
645 this.drawmask = MASK_NORMAL;
646 //this.movetype = MOVETYPE_NOCLIP;
647 //this.draw = Spawn_Draw;
649 if(autocvar_cl_spawn_point_particles)
651 if((serverflags & SERVERFLAG_TEAMPLAY))
655 case NUM_TEAM_1: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_RED); break;
656 case NUM_TEAM_2: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_BLUE); break;
657 case NUM_TEAM_3: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_YELLOW); break;
658 case NUM_TEAM_4: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_PINK); break;
659 default: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_NEUTRAL); break;
662 else { this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_NEUTRAL); }
664 this.draw = Spawn_Draw;
668 //printf("Ent_ReadSpawnPoint(is_new = %d); origin = %s, team = %d, effect = %d\n", is_new, vtos(this.origin), teamnum, this.cnt);
672 NET_HANDLE(ENT_CLIENT_SPAWNEVENT, bool is_new)
674 // If entnum is 0, ONLY do the local spawn actions
675 // this way the server can disable the sending of
676 // spawn origin or such to clients if wanted.
677 float entnum = ReadByte();
681 this.origin_x = ReadShort();
682 this.origin_y = ReadShort();
683 this.origin_z = ReadShort();
687 float teamnum = entcs_GetTeam(entnum - 1);
689 if(autocvar_cl_spawn_event_particles)
693 case NUM_TEAM_1: pointparticles(EFFECT_SPAWN_RED, this.origin, '0 0 0', 1); break;
694 case NUM_TEAM_2: pointparticles(EFFECT_SPAWN_BLUE, this.origin, '0 0 0', 1); break;
695 case NUM_TEAM_3: pointparticles(EFFECT_SPAWN_YELLOW, this.origin, '0 0 0', 1); break;
696 case NUM_TEAM_4: pointparticles(EFFECT_SPAWN_PINK, this.origin, '0 0 0', 1); break;
697 default: pointparticles(EFFECT_SPAWN_NEUTRAL, this.origin, '0 0 0', 1); break;
700 if(autocvar_cl_spawn_event_sound)
702 sound(this, CH_TRIGGER, SND_SPAWN, VOL_BASE, ATTEN_NORM);
708 // local spawn actions
709 if(is_new && (!entnum || (entnum == player_localentnum)))
712 current_viewzoom = (1 / bound(1, autocvar_cl_spawnzoom_factor, 16));
714 if(autocvar_cl_unpress_zoom_on_spawn)
720 HUD_Radar_Hide_Maximized();
721 //printf("Ent_ReadSpawnEvent(is_new = %d); origin = %s, entnum = %d, localentnum = %d\n", is_new, vtos(this.origin), entnum, player_localentnum);
724 // CSQC_Ent_Update : Called every frame that the server has indicated an update to the SSQC / CSQC entity has occured.
725 // The only parameter reflects if the entity is "new" to the client, meaning it just came into the client's PVS.
726 void CSQC_Ent_Update(bool isnew)
729 this.sourceLoc = __FILE__ ":" STR(__LINE__);
732 // set up the "time" global for received entities to be correct for interpolation purposes
733 float savetime = time;
740 serverprevtime = time;
741 serverdeltatime = STAT(MOVEVARS_TICRATE) * STAT(MOVEVARS_TIMESCALE);
742 time = serverprevtime + serverdeltatime;
745 #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
748 if (t != this.enttype || isnew)
750 LOG_INFOF("A CSQC entity changed its type! (edict: %d, server: %d, type: %d -> %d)\n", etof(this), this.entnum, this.enttype, t);
760 LOG_INFOF("A CSQC entity appeared out of nowhere! (edict: %d, server: %d, type: %d)\n", etof(this), this.entnum, t);
767 FOREACH(LinkedEntities, it.m_id == t, LAMBDA(
768 if (isnew) this.classname = it.netname;
769 if (autocvar_developer_csqcentities)
770 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);
771 done = it.m_read(this, NULL, isnew);
777 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);
781 // Destructor, but does NOT deallocate the entity by calling remove(). Also
782 // used when an entity changes its type. For an entity that someone interacts
783 // with others, make sure it can no longer do so.
784 void Ent_Remove(entity this)
786 if(this.entremove) this.entremove(this);
788 if(this.skeletonindex)
790 skel_delete(this.skeletonindex);
791 this.skeletonindex = 0;
794 if(this.snd_looping > 0)
796 sound(this, this.snd_looping, SND_Null, VOL_BASE, autocvar_g_jetpack_attenuation);
797 this.snd_looping = 0;
802 this.draw = func_null;
803 this.entremove = func_null;
804 // TODO possibly set more stuff to defaults
806 // CSQC_Ent_Remove : Called when the server requests a SSQC / CSQC entity to be removed. Essentially call remove(this) as well.
807 void CSQC_Ent_Remove()
810 if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Ent_Remove() with this=%i {.entnum=%d, .enttype=%d}\n", this, this.entnum, this.enttype);
813 LOG_WARNING("CSQC_Ent_Remove called for already removed entity. Packet loss?\n");
816 if (this.enttype) Ent_Remove(this);
824 if(!(calledhooks & HOOK_START))
825 localcmd("\n_cl_hook_gamestart ", MapInfo_Type_ToString(gametype), "\n");
826 calledhooks |= HOOK_START;
829 // 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.
830 void CSQC_Parse_StuffCmd(string strMessage)
832 if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Parse_StuffCmd(\"%s\")\n", strMessage);
833 localcmd(strMessage);
835 // 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.
836 void CSQC_Parse_Print(string strMessage)
838 if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Parse_Print(\"%s\")\n", strMessage);
839 print(ColorTranslateRGB(strMessage));
842 // CSQC_Parse_CenterPrint : Provides the centerprint_hud string in the first parameter that the server provided.
843 void CSQC_Parse_CenterPrint(string strMessage)
845 if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Parse_CenterPrint(\"%s\")\n", strMessage);
846 centerprint_hud(strMessage);
849 // CSQC_Parse_TempEntity : Handles all temporary entity network data in the CSQC layer.
850 // You must ALWAYS first acquire the temporary ID, which is sent as a byte.
851 // Return value should be 1 if CSQC handled the temporary entity, otherwise return 0 to have the engine process the event.
852 bool CSQC_Parse_TempEntity()
855 int nTEID = ReadByte();
857 FOREACH(TempEntities, it.m_id == nTEID, LAMBDA(
858 if (autocvar_developer_csqcentities)
859 LOG_INFOF("CSQC_Parse_TempEntity() nTEID=%s (%d)\n", it.netname, nTEID);
860 return it.m_read(NULL, NULL, true);
863 if (autocvar_developer_csqcentities)
864 LOG_INFOF("CSQC_Parse_TempEntity() with nTEID=%d\n", nTEID);
866 // No special logic for this temporary entity; return 0 so the engine can handle it
870 /** TODO somehow thwart prvm_globalset client ... */
874 if (autocvar_cl_orthoview && autocvar_cl_orthoview_nofog)
875 localcmd("\nr_drawfog 0\n");
876 else if (forcefog != "")
877 localcmd(sprintf("\nfog %s\nr_fog_exp2 0\nr_drawfog 1\n", forcefog));
880 void Gamemode_Init();
881 NET_HANDLE(ENT_CLIENT_SCORES_INFO, bool isnew)
884 gametype = ReadInt24_t();
885 HUD_ModIcons_SetFunc();
886 for (int i = 0; i < MAX_SCORE; ++i)
888 if (scores_label[i]) strunzone(scores_label[i]);
889 scores_label[i] = strzone(ReadString());
890 scores_flags[i] = ReadByte();
892 for (int i = 0; i < MAX_TEAMSCORE; ++i)
894 if (teamscores_label[i]) strunzone(teamscores_label[i]);
895 teamscores_label[i] = strzone(ReadString());
896 teamscores_flags[i] = ReadByte();
903 NET_HANDLE(ENT_CLIENT_INIT, bool isnew)
905 nb_pb_period = ReadByte() / 32; //Accuracy of 1/32th
907 hook_shotorigin[0] = decompressShotOrigin(ReadInt24_t());
908 hook_shotorigin[1] = decompressShotOrigin(ReadInt24_t());
909 hook_shotorigin[2] = decompressShotOrigin(ReadInt24_t());
910 hook_shotorigin[3] = decompressShotOrigin(ReadInt24_t());
911 arc_shotorigin[0] = decompressShotOrigin(ReadInt24_t());
912 arc_shotorigin[1] = decompressShotOrigin(ReadInt24_t());
913 arc_shotorigin[2] = decompressShotOrigin(ReadInt24_t());
914 arc_shotorigin[3] = decompressShotOrigin(ReadInt24_t());
916 if (forcefog) strunzone(forcefog);
917 forcefog = strzone(ReadString());
919 armorblockpercent = ReadByte() / 255.0;
921 serverflags = ReadByte();
923 g_trueaim_minrange = ReadCoord();
927 MUTATOR_CALLHOOK(Ent_Init);
929 if (!postinit) PostInit();
932 NET_HANDLE(TE_CSQC_RACE, bool isNew)
938 case RACE_NET_CHECKPOINT_HIT_QUALIFYING:
939 race_checkpoint = ReadByte();
940 race_time = ReadInt24_t();
941 race_previousbesttime = ReadInt24_t();
942 if(race_previousbestname)
943 strunzone(race_previousbestname);
944 race_previousbestname = strzone(ColorTranslateRGB(ReadString()));
946 race_checkpointtime = time;
948 if(race_checkpoint == 0 || race_checkpoint == 254)
950 race_penaltyaccumulator = 0;
951 race_laptime = time; // valid
956 case RACE_NET_CHECKPOINT_CLEAR:
958 race_checkpointtime = 0;
961 case RACE_NET_CHECKPOINT_NEXT_SPEC_QUALIFYING:
962 race_laptime = ReadCoord();
963 race_checkpointtime = -99999;
965 case RACE_NET_CHECKPOINT_NEXT_QUALIFYING:
966 race_nextcheckpoint = ReadByte();
968 race_nextbesttime = ReadInt24_t();
969 if(race_nextbestname)
970 strunzone(race_nextbestname);
971 race_nextbestname = strzone(ColorTranslateRGB(ReadString()));
974 case RACE_NET_CHECKPOINT_HIT_RACE:
975 race_mycheckpoint = ReadByte();
976 race_mycheckpointtime = time;
977 race_mycheckpointdelta = ReadInt24_t();
978 race_mycheckpointlapsdelta = ReadByte();
979 if(race_mycheckpointlapsdelta >= 128)
980 race_mycheckpointlapsdelta -= 256;
981 if(race_mycheckpointenemy)
982 strunzone(race_mycheckpointenemy);
983 race_mycheckpointenemy = strzone(ColorTranslateRGB(ReadString()));
986 case RACE_NET_CHECKPOINT_HIT_RACE_BY_OPPONENT:
987 race_othercheckpoint = ReadByte();
988 race_othercheckpointtime = time;
989 race_othercheckpointdelta = ReadInt24_t();
990 race_othercheckpointlapsdelta = ReadByte();
991 if(race_othercheckpointlapsdelta >= 128)
992 race_othercheckpointlapsdelta -= 256;
993 if(race_othercheckpointenemy)
994 strunzone(race_othercheckpointenemy);
995 race_othercheckpointenemy = strzone(ColorTranslateRGB(ReadString()));
998 case RACE_NET_PENALTY_RACE:
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_PENALTY_QUALIFYING:
1008 race_penaltyeventtime = time;
1009 race_penaltytime = ReadShort();
1010 race_penaltyaccumulator += race_penaltytime;
1011 if(race_penaltyreason)
1012 strunzone(race_penaltyreason);
1013 race_penaltyreason = strzone(ReadString());
1016 case RACE_NET_SERVER_RECORD:
1017 race_server_record = ReadInt24_t();
1019 case RACE_NET_SPEED_AWARD:
1020 race_speedaward = ReadInt24_t();
1021 if(race_speedaward_holder)
1022 strunzone(race_speedaward_holder);
1023 race_speedaward_holder = strzone(ReadString());
1025 case RACE_NET_SPEED_AWARD_BEST:
1026 race_speedaward_alltimebest = ReadInt24_t();
1027 if(race_speedaward_alltimebest_holder)
1028 strunzone(race_speedaward_alltimebest_holder);
1029 race_speedaward_alltimebest_holder = strzone(ReadString());
1031 case RACE_NET_SERVER_RANKINGS:
1033 int pos = ReadShort();
1034 prevpos = ReadShort();
1037 // move other rankings out of the way
1040 for (i=prevpos-1;i>pos-1;--i) {
1041 grecordtime[i] = grecordtime[i-1];
1042 if(grecordholder[i])
1043 strunzone(grecordholder[i]);
1044 grecordholder[i] = strzone(grecordholder[i-1]);
1046 } else if (del) { // a record has been deleted by the admin
1047 for (i=pos-1; i<= RANKINGS_CNT-1; ++i) {
1048 if (i == RANKINGS_CNT-1) { // clear out last record
1050 if (grecordholder[i])
1051 strunzone(grecordholder[i]);
1052 grecordholder[i] = string_null;
1055 grecordtime[i] = grecordtime[i+1];
1056 if (grecordholder[i])
1057 strunzone(grecordholder[i]);
1058 grecordholder[i] = strzone(grecordholder[i+1]);
1061 } else { // player has no ranked record yet
1062 for (i=RANKINGS_CNT-1;i>pos-1;--i) {
1063 grecordtime[i] = grecordtime[i-1];
1064 if(grecordholder[i])
1065 strunzone(grecordholder[i]);
1066 grecordholder[i] = strzone(grecordholder[i-1]);
1070 // store new ranking
1071 if(grecordholder[pos-1] != "")
1072 strunzone(grecordholder[pos-1]);
1073 grecordholder[pos-1] = strzone(ReadString());
1074 grecordtime[pos-1] = ReadInt24_t();
1075 if(grecordholder[pos-1] == entcs_GetName(player_localnum))
1078 case RACE_NET_SERVER_STATUS:
1079 race_status = ReadShort();
1080 if(race_status_name)
1081 strunzone(race_status_name);
1082 race_status_name = strzone(ReadString());
1087 NET_HANDLE(TE_CSQC_TEAMNAGGER, bool isNew)
1093 NET_HANDLE(TE_CSQC_PINGPLREPORT, bool isNew)
1096 int pi = ReadShort();
1097 int pl = ReadByte();
1098 int ml = ReadByte();
1100 entity e = playerslots[i];
1103 e.ping_packetloss = pl / 255.0;
1104 e.ping_movementloss = ml / 255.0;
1107 NET_HANDLE(TE_CSQC_WEAPONCOMPLAIN, bool isNew)
1109 complain_weapon = ReadByte();
1110 complain_weapon_type = ReadByte();
1113 complain_weapon_time = time;
1114 weapontime = time; // ping the weapon panel
1116 switch(complain_weapon_type)
1118 case 0: Local_Notification(MSG_MULTI, ITEM_WEAPON_NOAMMO, complain_weapon); break;
1119 case 1: Local_Notification(MSG_MULTI, ITEM_WEAPON_DONTHAVE, complain_weapon); break;
1120 default: Local_Notification(MSG_MULTI, ITEM_WEAPON_UNAVAILABLE, complain_weapon); break;
1124 string getcommandkey(string text, string command)
1127 float n, j, k, l = 0;
1129 if (!autocvar_hud_showbinds)
1132 keys = db_get(binddb, command);
1135 n = tokenize(findkeysforcommand(command, 0)); // uses '...' strings
1136 for(j = 0; j < n; ++j)
1142 keys = keynumtostring(k);
1144 keys = strcat(keys, ", ", keynumtostring(k));
1147 if (autocvar_hud_showbinds_limit > 0 && autocvar_hud_showbinds_limit <= l)
1154 db_put(binddb, command, keys);
1157 if (keys == "NO_KEY") {
1158 if (autocvar_hud_showbinds > 1)
1159 return sprintf(_("%s (not bound)"), text);
1163 else if (autocvar_hud_showbinds > 1)
1164 return sprintf("%s (%s)", text, keys);