8 #include "mapvoting.qh"
9 #include "modeleffects.qh"
10 #include "mutators/events.qh"
11 #include "particles.qh"
12 #include "quickmenu.qh"
13 #include "scoreboard.qh"
14 #include "shownames.qh"
18 #include "weapons/projectile.qh"
19 #include "../common/deathtypes/all.qh"
20 #include "../common/items/all.qh"
21 #include "../common/mapinfo.qh"
22 #include "../common/minigames/cl_minigames.qh"
23 #include "../common/minigames/cl_minigames_hud.qh"
24 #include "../common/net_notice.qh"
25 #include "../common/triggers/include.qh"
26 #include "../common/vehicles/all.qh"
27 #include "../lib/csqcmodel/cl_model.qh"
28 #include "../lib/csqcmodel/interpolate.qh"
29 #include "../lib/warpzone/client.qh"
31 // --------------------------------------------------------------------------
32 // BEGIN REQUIRED CSQC FUNCTIONS
35 #define DP_CSQC_ENTITY_REMOVE_IS_B0RKED
37 // CSQC_Init : Called every time the CSQC code is initialized (essentially at map load)
38 // Useful for precaching things
40 void ConsoleCommand_macro_init();
43 prvm_language = strzone(cvar_string("prvm_language"));
46 LOG_TRACEF("^4CSQC Build information: ^1%s\n", WATERMARK);
51 ClientProgsDB = db_load("client.db");
52 compressShortVector_init();
59 if (getplayerkeyvalue(i, "viewentity") == "")
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
100 // needs to be done so early because of the constants they create
103 static_init_precache();
107 if(autocvar_cl_reticle)
109 precache_pic("gfx/reticle_normal");
110 // weapon reticles are precached in weapon files
114 get_mi_min_max_texcoords(1); // try the CLEVER way first
115 minimapname = strcat("gfx/", mi_shortname, "_radar.tga");
116 shortmapname = mi_shortname;
118 if (precache_pic(minimapname) == "")
120 // but maybe we have a non-clever minimap
121 minimapname = strcat("gfx/", mi_shortname, "_mini.tga");
122 if (precache_pic(minimapname) == "")
123 minimapname = ""; // FAIL
125 get_mi_min_max_texcoords(0); // load new texcoords
128 mi_center = (mi_min + mi_max) * 0.5;
129 mi_scale = mi_max - mi_min;
130 minimapname = strzone(minimapname);
133 hud_skin_path = strzone(strcat("gfx/hud/", autocvar_hud_skin));
134 draw_currentSkin = strzone(strcat("gfx/menu/", cvar_string("menu_skin")));
137 // CSQC_Shutdown : Called every time the CSQC code is shutdown (changing maps, quitting, etc)
146 if(autocvar_cl_db_saveasdump)
147 db_dump(ClientProgsDB, "client.db");
149 db_save(ClientProgsDB, "client.db");
150 db_close(ClientProgsDB);
153 cvar_set("chase_active",ftos(chase_active_backup));
155 // unset the event chasecam's chase_active
156 if(autocvar_chase_active < 0)
157 cvar_set("chase_active", "0");
161 if (!(calledhooks & HOOK_START))
162 localcmd("\n_cl_hook_gamestart nop\n");
163 if (!(calledhooks & HOOK_END))
164 localcmd("\ncl_hook_gameend\n");
167 deactivate_minigame();
168 HUD_MinigameMenu_Close();
172 float SetTeam(entity o, int Team)
186 if(GetTeam(Team, false) == world)
188 LOG_TRACEF("trying to switch to unsupported team %d\n", Team);
189 Team = NUM_SPECTATOR;
202 if(GetTeam(Team, false) == world)
204 LOG_TRACEF("trying to switch to unsupported team %d\n", Team);
205 Team = NUM_SPECTATOR;
210 if(Team == -1) // leave
214 tm = GetTeam(o.team, false);
225 tm = GetTeam(Team, true);
230 else if(Team != o.team)
232 tm = GetTeam(o.team, false);
235 tm = GetTeam(Team, true);
243 void Playerchecker_Think()
248 for(i = 0; i < maxclients; ++i)
251 if(GetPlayerName(i) == "")
255 // player disconnected
269 playerslots[i] = e = new(playerslot);
274 e.ping_packetloss = 0;
275 e.ping_movementloss = 0;
276 //e.gotscores = 0; // we might already have the scores...
277 SetTeam(e, GetPlayerColor(i)); // will not hurt; later updates come with HUD_UpdatePlayerTeams
279 HUD_UpdatePlayerPos(e);
283 this.nextthink = time + 0.2;
290 entity playerchecker = new(playerchecker);
291 make_pure(playerchecker);
292 playerchecker.think = Playerchecker_Think;
293 playerchecker.nextthink = time + 0.2;
301 // CSQC_InputEvent : Used to perform actions based on any key pressed, key released and mouse on the client.
302 // Return value should be 1 if CSQC handled the input, otherwise return 0 to have the input passed to the engine.
303 // All keys are in ascii.
304 // bInputType = 0 is key pressed, 1 is key released, 2 and 3 are mouse input.
305 // In the case of keyboard input, nPrimary is the ascii code, and nSecondary is 0.
306 // In the case of mouse input, nPrimary is xdelta, nSecondary is ydelta.
307 // In the case of mouse input after a setcursormode(1) call, nPrimary is xpos, nSecondary is ypos.
308 float CSQC_InputEvent(float bInputType, float nPrimary, float nSecondary)
310 if (HUD_Panel_InputEvent(bInputType, nPrimary, nSecondary))
313 if (QuickMenu_InputEvent(bInputType, nPrimary, nSecondary))
316 if (HUD_Radar_InputEvent(bInputType, nPrimary, nSecondary))
319 if (MapVote_InputEvent(bInputType, nPrimary, nSecondary))
322 if (HUD_Minigame_InputEvent(bInputType, nPrimary, nSecondary))
328 // END REQUIRED CSQC FUNCTIONS
329 // --------------------------------------------------------------------------
331 // --------------------------------------------------------------------------
332 // BEGIN OPTIONAL CSQC FUNCTIONS
334 void Ent_RemoveEntCS()
337 entcs_receiver[this.sv_entnum] = NULL;
340 NET_HANDLE(ENT_CLIENT_ENTCS, bool isnew)
343 this.classname = "entcs_receiver";
344 InterpolateOrigin_Undo();
348 this.sv_entnum = ReadByte();
351 this.origin_x = ReadShort();
352 this.origin_y = ReadShort();
353 this.origin_z = ReadShort();
354 setorigin(this, this.origin);
358 this.angles_y = ReadByte() * 360.0 / 256;
359 this.angles_x = this.angles_z = 0;
362 this.healthvalue = ReadByte() * 10;
364 this.armorvalue = ReadByte() * 10;
368 entcs_receiver[this.sv_entnum] = this;
369 this.entremove = Ent_RemoveEntCS;
370 this.iflags |= IFLAG_ORIGIN;
372 InterpolateOrigin_Note();
377 void Ent_RemovePlayerScore()
381 SetTeam(this.owner, -1);
382 this.owner.gotscores = 0;
383 for(int i = 0; i < MAX_SCORE; ++i) {
384 this.owner.(scores[i]) = 0; // clear all scores
389 NET_HANDLE(ENT_CLIENT_SCORES, bool isnew)
396 // damnit -.- don't want to go change every single .sv_entnum in hud.qc AGAIN
397 // (no I've never heard of M-x replace-string, sed, or anything like that)
398 isNew = !this.owner; // workaround for DP bug
401 #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
402 if(!isNew && n != this.sv_entnum)
404 //print("A CSQC entity changed its owner!\n");
405 LOG_INFOF("A CSQC entity changed its owner! (edict: %d, classname: %s)\n", num_for_edict(this), this.classname);
413 o = playerslots[this.sv_entnum];
416 o = playerslots[this.sv_entnum] = new(playerslot);
420 o.sv_entnum = this.sv_entnum;
424 // RegisterPlayer(o);
425 //playerchecker will do this for us later, if it has not already done so
436 for(i = 0, p = 1; i < MAX_SCORE; ++i, p *= 2)
440 o.(scores[i]) = ReadInt24_t();
442 o.(scores[i]) = ReadChar();
448 HUD_UpdatePlayerPos(o); // if not registered, we cannot do this yet!
450 this.entremove = Ent_RemovePlayerScore;
453 NET_HANDLE(ENT_CLIENT_TEAMSCORES, bool isnew)
459 this.team = ReadByte();
460 o = this.owner = GetTeam(this.team, true); // these team numbers can always be trusted
463 #if MAX_TEAMSCORE <= 8
471 for(i = 0, p = 1; i < MAX_TEAMSCORE; ++i, p *= 2)
475 o.(teamscores[i]) = ReadInt24_t();
477 o.(teamscores[i]) = ReadChar();
482 HUD_UpdateTeamPos(o);
485 NET_HANDLE(ENT_CLIENT_CLIENTDATA, bool isnew)
488 float newspectatee_status;
492 scoreboard_showscores_force = (f & 1);
496 newspectatee_status = ReadByte();
497 if(newspectatee_status == player_localnum + 1)
498 newspectatee_status = -1; // observing
501 newspectatee_status = 0;
503 spectatorbutton_zoom = (f & 4);
507 angles_held_status = 1;
508 angles_held.x = ReadAngle();
509 angles_held.y = ReadAngle();
513 angles_held_status = 0;
517 if(newspectatee_status != spectatee_status)
521 race_checkpointtime = 0;
523 if (autocvar_hud_panel_healtharmor_progressbar_gfx)
525 if ( (spectatee_status == -1 && newspectatee_status > 0) //before observing, now spectating
526 || (spectatee_status > 0 && newspectatee_status > 0 && spectatee_status != newspectatee_status) //changed spectated player
529 else if(spectatee_status && !newspectatee_status) //before observing/spectating, now playing
532 spectatee_status = newspectatee_status;
534 // we could get rid of spectatee_status, and derive it from player_localentnum and player_localnum
537 NET_HANDLE(ENT_CLIENT_NAGGER, bool isnew)
542 int nags = ReadByte(); // NAGS NAGS NAGS NAGS NAGS NAGS NADZ NAGS NAGS NAGS
547 strunzone(vote_called_vote);
548 vote_called_vote = string_null;
558 vote_yescount = ReadByte();
559 vote_nocount = ReadByte();
560 vote_needed = ReadByte();
561 vote_highlighted = ReadChar();
567 strunzone(vote_called_vote);
568 vote_called_vote = strzone(ColorTranslateRGB(ReadString()));
573 for(j = 0; j < maxclients; ++j)
575 playerslots[j].ready = 1;
576 for(i = 1; i <= maxclients; i += 8)
579 for(j = i-1, b = 1; b < 256; b *= 2, ++j)
582 playerslots[j].ready = 0;
588 ready_waiting = (nags & BIT(0));
589 ready_waiting_for_me = (nags & BIT(1));
590 vote_waiting = (nags & BIT(2));
591 vote_waiting_for_me = (nags & BIT(3));
592 warmup_stage = (nags & BIT(4));
595 NET_HANDLE(ENT_CLIENT_ELIMINATEDPLAYERS, bool isnew)
603 for(j = 0; j < maxclients; ++j)
605 playerslots[j].eliminated = 1;
606 for(i = 1; i <= maxclients; i += 8)
609 for(j = i-1, b = 1; b < 256; b *= 2, ++j)
612 playerslots[j].eliminated = 0;
618 NET_HANDLE(ENT_CLIENT_RANDOMSEED, bool isnew)
622 float s = ReadShort();
627 NET_HANDLE(ENT_CLIENT_ACCURACY, bool isnew)
630 int sf = ReadInt24_t();
632 for (int w = 0; w <= WEP_LAST - WEP_FIRST; ++w)
633 weapon_accuracy[w] = -1;
638 for (int w = 0; w <= WEP_LAST - WEP_FIRST; ++w) {
642 weapon_accuracy[w] = -1;
644 weapon_accuracy[w] = 1.0; // no better error handling yet, sorry
646 weapon_accuracy[w] = (b - 1.0) / 100.0;
648 f = (f == 0x800000) ? 1 : f * 2;
653 void Spawn_Draw(entity this)
655 __pointparticles(this.cnt, this.origin + '0 0 28', '0 0 2', bound(0, frametime, 0.1));
658 NET_HANDLE(ENT_CLIENT_SPAWNPOINT, bool is_new)
660 float teamnum = (ReadByte() - 1);
662 spn_origin.x = ReadShort();
663 spn_origin.y = ReadShort();
664 spn_origin.z = ReadShort();
668 this.origin = spn_origin;
669 setsize(this, PL_MIN_CONST, PL_MAX_CONST);
672 /*if(autocvar_cl_spawn_point_model) // needs a model first
674 this.mdl = "models/spawnpoint.md3";
675 this.colormod = Team_ColorRGB(teamnum);
676 precache_model(this.mdl);
677 setmodel(this, this.mdl);
678 this.drawmask = MASK_NORMAL;
679 //this.movetype = MOVETYPE_NOCLIP;
680 //this.draw = Spawn_Draw;
682 if(autocvar_cl_spawn_point_particles)
684 if((serverflags & SERVERFLAG_TEAMPLAY))
688 case NUM_TEAM_1: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_RED); break;
689 case NUM_TEAM_2: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_BLUE); break;
690 case NUM_TEAM_3: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_YELLOW); break;
691 case NUM_TEAM_4: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_PINK); break;
692 default: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_NEUTRAL); break;
695 else { this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_NEUTRAL); }
697 this.draw = Spawn_Draw;
701 //printf("Ent_ReadSpawnPoint(is_new = %d); origin = %s, team = %d, effect = %d\n", is_new, vtos(this.origin), teamnum, this.cnt);
705 NET_HANDLE(ENT_CLIENT_SPAWNEVENT, bool is_new)
707 // If entnum is 0, ONLY do the local spawn actions
708 // this way the server can disable the sending of
709 // spawn origin or such to clients if wanted.
710 float entnum = ReadByte();
714 this.origin_x = ReadShort();
715 this.origin_y = ReadShort();
716 this.origin_z = ReadShort();
720 float teamnum = GetPlayerColor(entnum - 1);
722 if(autocvar_cl_spawn_event_particles)
726 case NUM_TEAM_1: pointparticles(EFFECT_SPAWN_RED, this.origin, '0 0 0', 1); break;
727 case NUM_TEAM_2: pointparticles(EFFECT_SPAWN_BLUE, this.origin, '0 0 0', 1); break;
728 case NUM_TEAM_3: pointparticles(EFFECT_SPAWN_YELLOW, this.origin, '0 0 0', 1); break;
729 case NUM_TEAM_4: pointparticles(EFFECT_SPAWN_PINK, this.origin, '0 0 0', 1); break;
730 default: pointparticles(EFFECT_SPAWN_NEUTRAL, this.origin, '0 0 0', 1); break;
733 if(autocvar_cl_spawn_event_sound)
735 sound(this, CH_TRIGGER, SND_SPAWN, VOL_BASE, ATTEN_NORM);
741 // local spawn actions
742 if(is_new && (!entnum || (entnum == player_localentnum)))
745 current_viewzoom = (1 / bound(1, autocvar_cl_spawnzoom_factor, 16));
747 if(autocvar_cl_unpress_zoom_on_spawn)
753 HUD_Radar_Hide_Maximized();
754 //printf("Ent_ReadSpawnEvent(is_new = %d); origin = %s, entnum = %d, localentnum = %d\n", is_new, vtos(this.origin), entnum, player_localentnum);
757 // CSQC_Ent_Update : Called every frame that the server has indicated an update to the SSQC / CSQC entity has occured.
758 // The only parameter reflects if the entity is "new" to the client, meaning it just came into the client's PVS.
759 void CSQC_Ent_Update(float bIsNewEntity)
762 this.sourceLocLine = __LINE__;
763 this.sourceLocFile = __FILE__;
766 // set up the "time" global for received entities to be correct for interpolation purposes
767 float savetime = time;
774 serverprevtime = time;
775 serverdeltatime = getstatf(STAT_MOVEVARS_TICRATE) * getstatf(STAT_MOVEVARS_TIMESCALE);
776 time = serverprevtime + serverdeltatime;
779 #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
782 if(t != this.enttype || bIsNewEntity)
784 LOG_INFOF("A CSQC entity changed its type! (edict: %d, server: %d, type: %d -> %d)\n", num_for_edict(this), this.entnum, this.enttype, t);
794 LOG_INFOF("A CSQC entity appeared out of nowhere! (edict: %d, server: %d, type: %d)\n", num_for_edict(this), this.entnum, t);
801 FOREACH(LinkedEntities, it.m_id == t, LAMBDA(
802 this.classname = it.netname;
803 if (autocvar_developer_csqcentities)
804 LOG_INFOF("CSQC_Ent_Update(%d) with this=%i {.entnum=%d, .enttype=%d} t=%s (%d)\n", bIsNewEntity, this, this.entnum, this.enttype, it.netname, t);
805 done = it.m_read(this, bIsNewEntity);
811 //error(strcat(_("unknown entity type in CSQC_Ent_Update: %d\n"), this.enttype));
812 error(sprintf("Unknown entity type in CSQC_Ent_Update (enttype: %d, edict: %d, classname: %s)\n", this.enttype, num_for_edict(this), this.classname));
816 // Destructor, but does NOT deallocate the entity by calling remove(). Also
817 // used when an entity changes its type. For an entity that someone interacts
818 // with others, make sure it can no longer do so.
822 if(this.entremove) this.entremove();
824 if(this.skeletonindex)
826 skel_delete(this.skeletonindex);
827 this.skeletonindex = 0;
830 if(this.snd_looping > 0)
832 sound(this, this.snd_looping, SND_Null, VOL_BASE, autocvar_g_jetpack_attenuation);
833 this.snd_looping = 0;
838 this.draw = func_null;
839 this.entremove = func_null;
840 // TODO possibly set more stuff to defaults
842 // CSQC_Ent_Remove : Called when the server requests a SSQC / CSQC entity to be removed. Essentially call remove(this) as well.
843 void CSQC_Ent_Remove()
846 if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Ent_Remove() with this=%i {.entnum=%d, .enttype=%d}\n", this, this.entnum, this.enttype);
849 LOG_WARNING("CSQC_Ent_Remove called for already removed entity. Packet loss?\n");
852 if (this.enttype) Ent_Remove();
860 if(!(calledhooks & HOOK_START))
861 localcmd("\n_cl_hook_gamestart ", MapInfo_Type_ToString(gametype), "\n");
862 calledhooks |= HOOK_START;
865 // 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.
866 void CSQC_Parse_StuffCmd(string strMessage)
868 if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Parse_StuffCmd(\"%s\")\n", strMessage);
869 localcmd(strMessage);
871 // 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.
872 void CSQC_Parse_Print(string strMessage)
874 if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Parse_Print(\"%s\")\n", strMessage);
875 print(ColorTranslateRGB(strMessage));
878 // CSQC_Parse_CenterPrint : Provides the centerprint_hud string in the first parameter that the server provided.
879 void CSQC_Parse_CenterPrint(string strMessage)
881 if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Parse_CenterPrint(\"%s\")\n", strMessage);
882 centerprint_hud(strMessage);
885 // CSQC_Parse_TempEntity : Handles all temporary entity network data in the CSQC layer.
886 // You must ALWAYS first acquire the temporary ID, which is sent as a byte.
887 // Return value should be 1 if CSQC handled the temporary entity, otherwise return 0 to have the engine process the event.
888 bool CSQC_Parse_TempEntity()
891 int nTEID = ReadByte();
893 FOREACH(TempEntities, it.m_id == nTEID, LAMBDA(
894 if (autocvar_developer_csqcentities)
895 LOG_INFOF("CSQC_Parse_TempEntity() nTEID=%s (%d)\n", it.netname, nTEID);
896 return it.m_read(NULL, true);
899 if (autocvar_developer_csqcentities)
900 LOG_INFOF("CSQC_Parse_TempEntity() with nTEID=%d\n", nTEID);
902 // No special logic for this temporary entity; return 0 so the engine can handle it
906 /** TODO somehow thwart prvm_globalset client ... */
910 if (autocvar_cl_orthoview && autocvar_cl_orthoview_nofog)
911 localcmd("\nr_drawfog 0\n");
912 else if (forcefog != "")
913 localcmd(sprintf("\nfog %s\nr_fog_exp2 0\nr_drawfog 1\n", forcefog));
916 void Gamemode_Init();
917 NET_HANDLE(ENT_CLIENT_SCORES_INFO, bool isnew)
920 gametype = ReadInt24_t();
921 HUD_ModIcons_SetFunc();
922 for (int i = 0; i < MAX_SCORE; ++i)
924 if (scores_label[i]) strunzone(scores_label[i]);
925 scores_label[i] = strzone(ReadString());
926 scores_flags[i] = ReadByte();
928 for (int i = 0; i < MAX_TEAMSCORE; ++i)
930 if (teamscores_label[i]) strunzone(teamscores_label[i]);
931 teamscores_label[i] = strzone(ReadString());
932 teamscores_flags[i] = ReadByte();
939 NET_HANDLE(ENT_CLIENT_INIT, bool isnew)
943 nb_pb_period = ReadByte() / 32; //Accuracy of 1/32th
945 hook_shotorigin[0] = decompressShotOrigin(ReadInt24_t());
946 hook_shotorigin[1] = decompressShotOrigin(ReadInt24_t());
947 hook_shotorigin[2] = decompressShotOrigin(ReadInt24_t());
948 hook_shotorigin[3] = decompressShotOrigin(ReadInt24_t());
949 arc_shotorigin[0] = decompressShotOrigin(ReadInt24_t());
950 arc_shotorigin[1] = decompressShotOrigin(ReadInt24_t());
951 arc_shotorigin[2] = decompressShotOrigin(ReadInt24_t());
952 arc_shotorigin[3] = decompressShotOrigin(ReadInt24_t());
954 if (forcefog) strunzone(forcefog);
955 forcefog = strzone(ReadString());
957 armorblockpercent = ReadByte() / 255.0;
959 g_balance_mortar_bouncefactor = ReadCoord();
960 g_balance_mortar_bouncestop = ReadCoord();
961 g_balance_electro_secondary_bouncefactor = ReadCoord();
962 g_balance_electro_secondary_bouncestop = ReadCoord();
964 vortex_scope = !ReadByte();
965 rifle_scope = !ReadByte();
967 serverflags = ReadByte();
969 minelayer_maxmines = ReadByte();
971 hagar_maxrockets = ReadByte();
973 g_trueaim_minrange = ReadCoord();
974 g_balance_porto_secondary = ReadByte();
977 MUTATOR_CALLHOOK(Ent_Init);
979 if (!postinit) PostInit();
982 NET_HANDLE(TE_CSQC_RACE, bool isNew)
988 case RACE_NET_CHECKPOINT_HIT_QUALIFYING:
989 race_checkpoint = ReadByte();
990 race_time = ReadInt24_t();
991 race_previousbesttime = ReadInt24_t();
992 if(race_previousbestname)
993 strunzone(race_previousbestname);
994 race_previousbestname = strzone(ColorTranslateRGB(ReadString()));
996 race_checkpointtime = time;
998 if(race_checkpoint == 0 || race_checkpoint == 254)
1000 race_penaltyaccumulator = 0;
1001 race_laptime = time; // valid
1006 case RACE_NET_CHECKPOINT_CLEAR:
1008 race_checkpointtime = 0;
1011 case RACE_NET_CHECKPOINT_NEXT_SPEC_QUALIFYING:
1012 race_laptime = ReadCoord();
1013 race_checkpointtime = -99999;
1015 case RACE_NET_CHECKPOINT_NEXT_QUALIFYING:
1016 race_nextcheckpoint = ReadByte();
1018 race_nextbesttime = ReadInt24_t();
1019 if(race_nextbestname)
1020 strunzone(race_nextbestname);
1021 race_nextbestname = strzone(ColorTranslateRGB(ReadString()));
1024 case RACE_NET_CHECKPOINT_HIT_RACE:
1025 race_mycheckpoint = ReadByte();
1026 race_mycheckpointtime = time;
1027 race_mycheckpointdelta = ReadInt24_t();
1028 race_mycheckpointlapsdelta = ReadByte();
1029 if(race_mycheckpointlapsdelta >= 128)
1030 race_mycheckpointlapsdelta -= 256;
1031 if(race_mycheckpointenemy)
1032 strunzone(race_mycheckpointenemy);
1033 race_mycheckpointenemy = strzone(ColorTranslateRGB(ReadString()));
1036 case RACE_NET_CHECKPOINT_HIT_RACE_BY_OPPONENT:
1037 race_othercheckpoint = ReadByte();
1038 race_othercheckpointtime = time;
1039 race_othercheckpointdelta = ReadInt24_t();
1040 race_othercheckpointlapsdelta = ReadByte();
1041 if(race_othercheckpointlapsdelta >= 128)
1042 race_othercheckpointlapsdelta -= 256;
1043 if(race_othercheckpointenemy)
1044 strunzone(race_othercheckpointenemy);
1045 race_othercheckpointenemy = strzone(ColorTranslateRGB(ReadString()));
1048 case RACE_NET_PENALTY_RACE:
1049 race_penaltyeventtime = time;
1050 race_penaltytime = ReadShort();
1051 //race_penaltyaccumulator += race_penaltytime;
1052 if(race_penaltyreason)
1053 strunzone(race_penaltyreason);
1054 race_penaltyreason = strzone(ReadString());
1057 case RACE_NET_PENALTY_QUALIFYING:
1058 race_penaltyeventtime = time;
1059 race_penaltytime = ReadShort();
1060 race_penaltyaccumulator += race_penaltytime;
1061 if(race_penaltyreason)
1062 strunzone(race_penaltyreason);
1063 race_penaltyreason = strzone(ReadString());
1066 case RACE_NET_SERVER_RECORD:
1067 race_server_record = ReadInt24_t();
1069 case RACE_NET_SPEED_AWARD:
1070 race_speedaward = ReadInt24_t();
1071 if(race_speedaward_holder)
1072 strunzone(race_speedaward_holder);
1073 race_speedaward_holder = strzone(ReadString());
1075 case RACE_NET_SPEED_AWARD_BEST:
1076 race_speedaward_alltimebest = ReadInt24_t();
1077 if(race_speedaward_alltimebest_holder)
1078 strunzone(race_speedaward_alltimebest_holder);
1079 race_speedaward_alltimebest_holder = strzone(ReadString());
1081 case RACE_NET_SERVER_RANKINGS:
1083 int pos = ReadShort();
1084 prevpos = ReadShort();
1087 // move other rankings out of the way
1090 for (i=prevpos-1;i>pos-1;--i) {
1091 grecordtime[i] = grecordtime[i-1];
1092 if(grecordholder[i])
1093 strunzone(grecordholder[i]);
1094 grecordholder[i] = strzone(grecordholder[i-1]);
1096 } else if (del) { // a record has been deleted by the admin
1097 for (i=pos-1; i<= RANKINGS_CNT-1; ++i) {
1098 if (i == RANKINGS_CNT-1) { // clear out last record
1100 if (grecordholder[i])
1101 strunzone(grecordholder[i]);
1102 grecordholder[i] = string_null;
1105 grecordtime[i] = grecordtime[i+1];
1106 if (grecordholder[i])
1107 strunzone(grecordholder[i]);
1108 grecordholder[i] = strzone(grecordholder[i+1]);
1111 } else { // player has no ranked record yet
1112 for (i=RANKINGS_CNT-1;i>pos-1;--i) {
1113 grecordtime[i] = grecordtime[i-1];
1114 if(grecordholder[i])
1115 strunzone(grecordholder[i]);
1116 grecordholder[i] = strzone(grecordholder[i-1]);
1120 // store new ranking
1121 if(grecordholder[pos-1] != "")
1122 strunzone(grecordholder[pos-1]);
1123 grecordholder[pos-1] = strzone(ReadString());
1124 grecordtime[pos-1] = ReadInt24_t();
1125 if(grecordholder[pos-1] == GetPlayerName(player_localnum))
1128 case RACE_NET_SERVER_STATUS:
1129 race_status = ReadShort();
1130 if(race_status_name)
1131 strunzone(race_status_name);
1132 race_status_name = strzone(ReadString());
1137 NET_HANDLE(TE_CSQC_TEAMNAGGER, bool isNew)
1143 NET_HANDLE(TE_CSQC_PINGPLREPORT, bool isNew)
1146 int pi = ReadShort();
1147 int pl = ReadByte();
1148 int ml = ReadByte();
1150 entity e = playerslots[i];
1153 e.ping_packetloss = pl / 255.0;
1154 e.ping_movementloss = ml / 255.0;
1157 NET_HANDLE(TE_CSQC_WEAPONCOMPLAIN, bool isNew)
1159 complain_weapon = ReadByte();
1160 if (complain_weapon_name) strunzone(complain_weapon_name);
1161 complain_weapon_name = strzone(WEP_NAME(complain_weapon));
1162 complain_weapon_type = ReadByte();
1165 complain_weapon_time = time;
1166 weapontime = time; // ping the weapon panel
1168 switch(complain_weapon_type)
1170 case 0: Local_Notification(MSG_MULTI, ITEM_WEAPON_NOAMMO, complain_weapon); break;
1171 case 1: Local_Notification(MSG_MULTI, ITEM_WEAPON_DONTHAVE, complain_weapon); break;
1172 default: Local_Notification(MSG_MULTI, ITEM_WEAPON_UNAVAILABLE, complain_weapon); break;
1176 string getcommandkey(string text, string command)
1179 float n, j, k, l = 0;
1181 if (!autocvar_hud_showbinds)
1184 keys = db_get(binddb, command);
1187 n = tokenize(findkeysforcommand(command, 0)); // uses '...' strings
1188 for(j = 0; j < n; ++j)
1194 keys = keynumtostring(k);
1196 keys = strcat(keys, ", ", keynumtostring(k));
1199 if (autocvar_hud_showbinds_limit > 0 && autocvar_hud_showbinds_limit <= l)
1206 db_put(binddb, command, keys);
1209 if (keys == "NO_KEY") {
1210 if (autocvar_hud_showbinds > 1)
1211 return sprintf(_("%s (not bound)"), text);
1215 else if (autocvar_hud_showbinds > 1)
1216 return sprintf("%s (%s)", text, keys);