8 #include "mapvoting.qh"
9 #include "modeleffects.qh"
10 #include "mutators/events.qh"
11 #include "quickmenu.qh"
12 #include "scoreboard.qh"
13 #include "shownames.qh"
17 #include "weapons/projectile.qh"
18 #include "../common/deathtypes/all.qh"
19 #include "../common/items/all.qh"
20 #include "../common/mapinfo.qh"
21 #include "../common/minigames/cl_minigames.qh"
22 #include "../common/minigames/cl_minigames_hud.qh"
23 #include "../common/net_notice.qh"
24 #include "../common/triggers/include.qh"
25 #include "../common/vehicles/all.qh"
26 #include "../lib/csqcmodel/cl_model.qh"
27 #include "../lib/csqcmodel/interpolate.qh"
28 #include "../lib/warpzone/client.qh"
30 // --------------------------------------------------------------------------
31 // BEGIN REQUIRED CSQC FUNCTIONS
34 #define DP_CSQC_ENTITY_REMOVE_IS_B0RKED
36 // CSQC_Init : Called every time the CSQC code is initialized (essentially at map load)
37 // Useful for precaching things
39 void ConsoleCommand_macro_init();
42 prvm_language = strzone(cvar_string("prvm_language"));
45 LOG_TRACEF("^4CSQC Build information: ^1%s\n", WATERMARK);
50 ClientProgsDB = db_load("client.db");
51 compressShortVector_init();
58 if (getplayerkeyvalue(i, "viewentity") == "")
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
99 // needs to be done so early because of the constants they create
102 static_init_precache();
106 if(autocvar_cl_reticle)
108 precache_pic("gfx/reticle_normal");
109 // weapon reticles are precached in weapon files
113 get_mi_min_max_texcoords(1); // try the CLEVER way first
114 minimapname = strcat("gfx/", mi_shortname, "_radar.tga");
115 shortmapname = mi_shortname;
117 if (precache_pic(minimapname) == "")
119 // but maybe we have a non-clever minimap
120 minimapname = strcat("gfx/", mi_shortname, "_mini.tga");
121 if (precache_pic(minimapname) == "")
122 minimapname = ""; // FAIL
124 get_mi_min_max_texcoords(0); // load new texcoords
127 mi_center = (mi_min + mi_max) * 0.5;
128 mi_scale = mi_max - mi_min;
129 minimapname = strzone(minimapname);
132 hud_skin_path = strzone(strcat("gfx/hud/", autocvar_hud_skin));
133 draw_currentSkin = strzone(strcat("gfx/menu/", cvar_string("menu_skin")));
136 // CSQC_Shutdown : Called every time the CSQC code is shutdown (changing maps, quitting, etc)
145 if(autocvar_cl_db_saveasdump)
146 db_dump(ClientProgsDB, "client.db");
148 db_save(ClientProgsDB, "client.db");
149 db_close(ClientProgsDB);
152 cvar_set("chase_active",ftos(chase_active_backup));
154 // unset the event chasecam's chase_active
155 if(autocvar_chase_active < 0)
156 cvar_set("chase_active", "0");
160 if (!(calledhooks & HOOK_START))
161 localcmd("\n_cl_hook_gamestart nop\n");
162 if (!(calledhooks & HOOK_END))
163 localcmd("\ncl_hook_gameend\n");
166 deactivate_minigame();
167 HUD_MinigameMenu_Close();
171 float SetTeam(entity o, int Team)
185 if(GetTeam(Team, false) == world)
187 LOG_TRACEF("trying to switch to unsupported team %d\n", Team);
188 Team = NUM_SPECTATOR;
201 if(GetTeam(Team, false) == world)
203 LOG_TRACEF("trying to switch to unsupported team %d\n", Team);
204 Team = NUM_SPECTATOR;
209 if(Team == -1) // leave
213 tm = GetTeam(o.team, false);
224 tm = GetTeam(Team, true);
229 else if(Team != o.team)
231 tm = GetTeam(o.team, false);
234 tm = GetTeam(Team, true);
242 void Playerchecker_Think()
247 for(i = 0; i < maxclients; ++i)
250 if(GetPlayerName(i) == "")
254 // player disconnected
268 playerslots[i] = e = new(playerslot);
273 e.ping_packetloss = 0;
274 e.ping_movementloss = 0;
275 //e.gotscores = 0; // we might already have the scores...
276 SetTeam(e, GetPlayerColor(i)); // will not hurt; later updates come with HUD_UpdatePlayerTeams
278 HUD_UpdatePlayerPos(e);
282 this.nextthink = time + 0.2;
289 entity playerchecker = new(playerchecker);
290 make_pure(playerchecker);
291 playerchecker.think = Playerchecker_Think;
292 playerchecker.nextthink = time + 0.2;
300 // CSQC_InputEvent : Used to perform actions based on any key pressed, key released and mouse on the client.
301 // Return value should be 1 if CSQC handled the input, otherwise return 0 to have the input passed to the engine.
302 // All keys are in ascii.
303 // bInputType = 0 is key pressed, 1 is key released, 2 and 3 are mouse input.
304 // In the case of keyboard input, nPrimary is the ascii code, and nSecondary is 0.
305 // In the case of mouse input, nPrimary is xdelta, nSecondary is ydelta.
306 // In the case of mouse input after a setcursormode(1) call, nPrimary is xpos, nSecondary is ypos.
307 float CSQC_InputEvent(float bInputType, float nPrimary, float nSecondary)
309 if (HUD_Panel_InputEvent(bInputType, nPrimary, nSecondary))
312 if (QuickMenu_InputEvent(bInputType, nPrimary, nSecondary))
315 if (HUD_Radar_InputEvent(bInputType, nPrimary, nSecondary))
318 if (MapVote_InputEvent(bInputType, nPrimary, nSecondary))
321 if (HUD_Minigame_InputEvent(bInputType, nPrimary, nSecondary))
327 // END REQUIRED CSQC FUNCTIONS
328 // --------------------------------------------------------------------------
330 // --------------------------------------------------------------------------
331 // BEGIN OPTIONAL CSQC FUNCTIONS
333 void Ent_RemoveEntCS()
336 entcs_receiver[this.sv_entnum] = NULL;
339 NET_HANDLE(ENT_CLIENT_ENTCS, bool isnew)
342 this.classname = "entcs_receiver";
343 InterpolateOrigin_Undo();
347 this.sv_entnum = ReadByte();
350 this.origin_x = ReadShort();
351 this.origin_y = ReadShort();
352 this.origin_z = ReadShort();
353 setorigin(this, this.origin);
357 this.angles_y = ReadByte() * 360.0 / 256;
358 this.angles_x = this.angles_z = 0;
361 this.healthvalue = ReadByte() * 10;
363 this.armorvalue = ReadByte() * 10;
367 entcs_receiver[this.sv_entnum] = this;
368 this.entremove = Ent_RemoveEntCS;
369 this.iflags |= IFLAG_ORIGIN;
371 InterpolateOrigin_Note();
376 void Ent_RemovePlayerScore()
380 SetTeam(this.owner, -1);
381 this.owner.gotscores = 0;
382 for(int i = 0; i < MAX_SCORE; ++i) {
383 this.owner.(scores[i]) = 0; // clear all scores
388 NET_HANDLE(ENT_CLIENT_SCORES, bool isnew)
395 // damnit -.- don't want to go change every single .sv_entnum in hud.qc AGAIN
396 // (no I've never heard of M-x replace-string, sed, or anything like that)
397 isNew = !this.owner; // workaround for DP bug
400 #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
401 if(!isNew && n != this.sv_entnum)
403 //print("A CSQC entity changed its owner!\n");
404 LOG_INFOF("A CSQC entity changed its owner! (edict: %d, classname: %s)\n", num_for_edict(this), this.classname);
412 o = playerslots[this.sv_entnum];
415 o = playerslots[this.sv_entnum] = new(playerslot);
419 o.sv_entnum = this.sv_entnum;
423 // RegisterPlayer(o);
424 //playerchecker will do this for us later, if it has not already done so
435 for(i = 0, p = 1; i < MAX_SCORE; ++i, p *= 2)
439 o.(scores[i]) = ReadInt24_t();
441 o.(scores[i]) = ReadChar();
447 HUD_UpdatePlayerPos(o); // if not registered, we cannot do this yet!
449 this.entremove = Ent_RemovePlayerScore;
452 NET_HANDLE(ENT_CLIENT_TEAMSCORES, bool isnew)
458 this.team = ReadByte();
459 o = this.owner = GetTeam(this.team, true); // these team numbers can always be trusted
462 #if MAX_TEAMSCORE <= 8
470 for(i = 0, p = 1; i < MAX_TEAMSCORE; ++i, p *= 2)
474 o.(teamscores[i]) = ReadInt24_t();
476 o.(teamscores[i]) = ReadChar();
481 HUD_UpdateTeamPos(o);
484 NET_HANDLE(ENT_CLIENT_CLIENTDATA, bool isnew)
487 float newspectatee_status;
491 scoreboard_showscores_force = (f & 1);
495 newspectatee_status = ReadByte();
496 if(newspectatee_status == player_localnum + 1)
497 newspectatee_status = -1; // observing
500 newspectatee_status = 0;
502 spectatorbutton_zoom = (f & 4);
506 angles_held_status = 1;
507 angles_held.x = ReadAngle();
508 angles_held.y = ReadAngle();
512 angles_held_status = 0;
516 if(newspectatee_status != spectatee_status)
520 race_checkpointtime = 0;
522 if (autocvar_hud_panel_healtharmor_progressbar_gfx)
524 if ( (spectatee_status == -1 && newspectatee_status > 0) //before observing, now spectating
525 || (spectatee_status > 0 && newspectatee_status > 0 && spectatee_status != newspectatee_status) //changed spectated player
528 else if(spectatee_status && !newspectatee_status) //before observing/spectating, now playing
531 spectatee_status = newspectatee_status;
533 // we could get rid of spectatee_status, and derive it from player_localentnum and player_localnum
536 NET_HANDLE(ENT_CLIENT_NAGGER, bool isnew)
541 int nags = ReadByte(); // NAGS NAGS NAGS NAGS NAGS NAGS NADZ NAGS NAGS NAGS
546 strunzone(vote_called_vote);
547 vote_called_vote = string_null;
557 vote_yescount = ReadByte();
558 vote_nocount = ReadByte();
559 vote_needed = ReadByte();
560 vote_highlighted = ReadChar();
566 strunzone(vote_called_vote);
567 vote_called_vote = strzone(ColorTranslateRGB(ReadString()));
572 for(j = 0; j < maxclients; ++j)
574 playerslots[j].ready = 1;
575 for(i = 1; i <= maxclients; i += 8)
578 for(j = i-1, b = 1; b < 256; b *= 2, ++j)
581 playerslots[j].ready = 0;
587 ready_waiting = (nags & BIT(0));
588 ready_waiting_for_me = (nags & BIT(1));
589 vote_waiting = (nags & BIT(2));
590 vote_waiting_for_me = (nags & BIT(3));
591 warmup_stage = (nags & BIT(4));
594 NET_HANDLE(ENT_CLIENT_ELIMINATEDPLAYERS, bool isnew)
602 for(j = 0; j < maxclients; ++j)
604 playerslots[j].eliminated = 1;
605 for(i = 1; i <= maxclients; i += 8)
608 for(j = i-1, b = 1; b < 256; b *= 2, ++j)
611 playerslots[j].eliminated = 0;
617 NET_HANDLE(ENT_CLIENT_RANDOMSEED, bool isnew)
621 float s = ReadShort();
626 NET_HANDLE(ENT_CLIENT_ACCURACY, bool isnew)
629 int sf = ReadInt24_t();
631 for (int w = 0; w <= WEP_LAST - WEP_FIRST; ++w)
632 weapon_accuracy[w] = -1;
637 for (int w = 0; w <= WEP_LAST - WEP_FIRST; ++w) {
641 weapon_accuracy[w] = -1;
643 weapon_accuracy[w] = 1.0; // no better error handling yet, sorry
645 weapon_accuracy[w] = (b - 1.0) / 100.0;
647 f = (f == 0x800000) ? 1 : f * 2;
652 void Spawn_Draw(entity this)
654 __pointparticles(this.cnt, this.origin + '0 0 28', '0 0 2', bound(0, frametime, 0.1));
657 NET_HANDLE(ENT_CLIENT_SPAWNPOINT, bool is_new)
659 float teamnum = (ReadByte() - 1);
661 spn_origin.x = ReadShort();
662 spn_origin.y = ReadShort();
663 spn_origin.z = ReadShort();
667 this.origin = spn_origin;
668 setsize(this, PL_MIN_CONST, PL_MAX_CONST);
671 /*if(autocvar_cl_spawn_point_model) // needs a model first
673 this.mdl = "models/spawnpoint.md3";
674 this.colormod = Team_ColorRGB(teamnum);
675 precache_model(this.mdl);
676 setmodel(this, this.mdl);
677 this.drawmask = MASK_NORMAL;
678 //this.movetype = MOVETYPE_NOCLIP;
679 //this.draw = Spawn_Draw;
681 if(autocvar_cl_spawn_point_particles)
683 if((serverflags & SERVERFLAG_TEAMPLAY))
687 case NUM_TEAM_1: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_RED); break;
688 case NUM_TEAM_2: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_BLUE); break;
689 case NUM_TEAM_3: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_YELLOW); break;
690 case NUM_TEAM_4: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_PINK); break;
691 default: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_NEUTRAL); break;
694 else { this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_NEUTRAL); }
696 this.draw = Spawn_Draw;
700 //printf("Ent_ReadSpawnPoint(is_new = %d); origin = %s, team = %d, effect = %d\n", is_new, vtos(this.origin), teamnum, this.cnt);
704 NET_HANDLE(ENT_CLIENT_SPAWNEVENT, bool is_new)
706 // If entnum is 0, ONLY do the local spawn actions
707 // this way the server can disable the sending of
708 // spawn origin or such to clients if wanted.
709 float entnum = ReadByte();
713 this.origin_x = ReadShort();
714 this.origin_y = ReadShort();
715 this.origin_z = ReadShort();
719 float teamnum = GetPlayerColor(entnum - 1);
721 if(autocvar_cl_spawn_event_particles)
725 case NUM_TEAM_1: pointparticles(EFFECT_SPAWN_RED, this.origin, '0 0 0', 1); break;
726 case NUM_TEAM_2: pointparticles(EFFECT_SPAWN_BLUE, this.origin, '0 0 0', 1); break;
727 case NUM_TEAM_3: pointparticles(EFFECT_SPAWN_YELLOW, this.origin, '0 0 0', 1); break;
728 case NUM_TEAM_4: pointparticles(EFFECT_SPAWN_PINK, this.origin, '0 0 0', 1); break;
729 default: pointparticles(EFFECT_SPAWN_NEUTRAL, this.origin, '0 0 0', 1); break;
732 if(autocvar_cl_spawn_event_sound)
734 sound(this, CH_TRIGGER, SND_SPAWN, VOL_BASE, ATTEN_NORM);
740 // local spawn actions
741 if(is_new && (!entnum || (entnum == player_localentnum)))
744 current_viewzoom = (1 / bound(1, autocvar_cl_spawnzoom_factor, 16));
746 if(autocvar_cl_unpress_zoom_on_spawn)
752 HUD_Radar_Hide_Maximized();
753 //printf("Ent_ReadSpawnEvent(is_new = %d); origin = %s, entnum = %d, localentnum = %d\n", is_new, vtos(this.origin), entnum, player_localentnum);
756 // CSQC_Ent_Update : Called every frame that the server has indicated an update to the SSQC / CSQC entity has occured.
757 // The only parameter reflects if the entity is "new" to the client, meaning it just came into the client's PVS.
758 void CSQC_Ent_Update(float bIsNewEntity)
761 this.sourceLocLine = __LINE__;
762 this.sourceLocFile = __FILE__;
765 // set up the "time" global for received entities to be correct for interpolation purposes
766 float savetime = time;
773 serverprevtime = time;
774 serverdeltatime = getstatf(STAT_MOVEVARS_TICRATE) * getstatf(STAT_MOVEVARS_TIMESCALE);
775 time = serverprevtime + serverdeltatime;
778 #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
781 if(t != this.enttype || bIsNewEntity)
783 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);
793 LOG_INFOF("A CSQC entity appeared out of nowhere! (edict: %d, server: %d, type: %d)\n", num_for_edict(this), this.entnum, t);
800 FOREACH(LinkedEntities, it.m_id == t, LAMBDA(
801 this.classname = it.netname;
802 if (autocvar_developer_csqcentities)
803 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);
804 done = it.m_read(this, bIsNewEntity);
810 //error(strcat(_("unknown entity type in CSQC_Ent_Update: %d\n"), this.enttype));
811 error(sprintf("Unknown entity type in CSQC_Ent_Update (enttype: %d, edict: %d, classname: %s)\n", this.enttype, num_for_edict(this), this.classname));
815 // Destructor, but does NOT deallocate the entity by calling remove(). Also
816 // used when an entity changes its type. For an entity that someone interacts
817 // with others, make sure it can no longer do so.
821 if(this.entremove) this.entremove();
823 if(this.skeletonindex)
825 skel_delete(this.skeletonindex);
826 this.skeletonindex = 0;
829 if(this.snd_looping > 0)
831 sound(this, this.snd_looping, SND_Null, VOL_BASE, autocvar_g_jetpack_attenuation);
832 this.snd_looping = 0;
837 this.draw = func_null;
838 this.entremove = func_null;
839 // TODO possibly set more stuff to defaults
841 // CSQC_Ent_Remove : Called when the server requests a SSQC / CSQC entity to be removed. Essentially call remove(this) as well.
842 void CSQC_Ent_Remove()
845 if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Ent_Remove() with this=%i {.entnum=%d, .enttype=%d}\n", this, this.entnum, this.enttype);
848 LOG_WARNING("CSQC_Ent_Remove called for already removed entity. Packet loss?\n");
851 if (this.enttype) Ent_Remove();
859 if(!(calledhooks & HOOK_START))
860 localcmd("\n_cl_hook_gamestart ", MapInfo_Type_ToString(gametype), "\n");
861 calledhooks |= HOOK_START;
864 // 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.
865 void CSQC_Parse_StuffCmd(string strMessage)
867 if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Parse_StuffCmd(\"%s\")\n", strMessage);
868 localcmd(strMessage);
870 // 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.
871 void CSQC_Parse_Print(string strMessage)
873 if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Parse_Print(\"%s\")\n", strMessage);
874 print(ColorTranslateRGB(strMessage));
877 // CSQC_Parse_CenterPrint : Provides the centerprint_hud string in the first parameter that the server provided.
878 void CSQC_Parse_CenterPrint(string strMessage)
880 if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Parse_CenterPrint(\"%s\")\n", strMessage);
881 centerprint_hud(strMessage);
884 // CSQC_Parse_TempEntity : Handles all temporary entity network data in the CSQC layer.
885 // You must ALWAYS first acquire the temporary ID, which is sent as a byte.
886 // Return value should be 1 if CSQC handled the temporary entity, otherwise return 0 to have the engine process the event.
887 bool CSQC_Parse_TempEntity()
890 int nTEID = ReadByte();
892 FOREACH(TempEntities, it.m_id == nTEID, LAMBDA(
893 if (autocvar_developer_csqcentities)
894 LOG_INFOF("CSQC_Parse_TempEntity() nTEID=%s (%d)\n", it.netname, nTEID);
895 return it.m_read(NULL, true);
898 if (autocvar_developer_csqcentities)
899 LOG_INFOF("CSQC_Parse_TempEntity() with nTEID=%d\n", nTEID);
901 // No special logic for this temporary entity; return 0 so the engine can handle it
905 /** TODO somehow thwart prvm_globalset client ... */
909 if (autocvar_cl_orthoview && autocvar_cl_orthoview_nofog)
910 localcmd("\nr_drawfog 0\n");
911 else if (forcefog != "")
912 localcmd(sprintf("\nfog %s\nr_fog_exp2 0\nr_drawfog 1\n", forcefog));
915 void Gamemode_Init();
916 NET_HANDLE(ENT_CLIENT_SCORES_INFO, bool isnew)
919 gametype = ReadInt24_t();
920 HUD_ModIcons_SetFunc();
921 for (int i = 0; i < MAX_SCORE; ++i)
923 if (scores_label[i]) strunzone(scores_label[i]);
924 scores_label[i] = strzone(ReadString());
925 scores_flags[i] = ReadByte();
927 for (int i = 0; i < MAX_TEAMSCORE; ++i)
929 if (teamscores_label[i]) strunzone(teamscores_label[i]);
930 teamscores_label[i] = strzone(ReadString());
931 teamscores_flags[i] = ReadByte();
938 NET_HANDLE(ENT_CLIENT_INIT, bool isnew)
942 nb_pb_period = ReadByte() / 32; //Accuracy of 1/32th
944 hook_shotorigin[0] = decompressShotOrigin(ReadInt24_t());
945 hook_shotorigin[1] = decompressShotOrigin(ReadInt24_t());
946 hook_shotorigin[2] = decompressShotOrigin(ReadInt24_t());
947 hook_shotorigin[3] = decompressShotOrigin(ReadInt24_t());
948 arc_shotorigin[0] = decompressShotOrigin(ReadInt24_t());
949 arc_shotorigin[1] = decompressShotOrigin(ReadInt24_t());
950 arc_shotorigin[2] = decompressShotOrigin(ReadInt24_t());
951 arc_shotorigin[3] = decompressShotOrigin(ReadInt24_t());
953 if (forcefog) strunzone(forcefog);
954 forcefog = strzone(ReadString());
956 armorblockpercent = ReadByte() / 255.0;
958 g_balance_mortar_bouncefactor = ReadCoord();
959 g_balance_mortar_bouncestop = ReadCoord();
960 g_balance_electro_secondary_bouncefactor = ReadCoord();
961 g_balance_electro_secondary_bouncestop = ReadCoord();
963 vortex_scope = !ReadByte();
964 rifle_scope = !ReadByte();
966 serverflags = ReadByte();
968 minelayer_maxmines = ReadByte();
970 hagar_maxrockets = ReadByte();
972 g_trueaim_minrange = ReadCoord();
973 g_balance_porto_secondary = ReadByte();
976 MUTATOR_CALLHOOK(Ent_Init);
978 if (!postinit) PostInit();
981 NET_HANDLE(TE_CSQC_RACE, bool isNew)
987 case RACE_NET_CHECKPOINT_HIT_QUALIFYING:
988 race_checkpoint = ReadByte();
989 race_time = ReadInt24_t();
990 race_previousbesttime = ReadInt24_t();
991 if(race_previousbestname)
992 strunzone(race_previousbestname);
993 race_previousbestname = strzone(ColorTranslateRGB(ReadString()));
995 race_checkpointtime = time;
997 if(race_checkpoint == 0 || race_checkpoint == 254)
999 race_penaltyaccumulator = 0;
1000 race_laptime = time; // valid
1005 case RACE_NET_CHECKPOINT_CLEAR:
1007 race_checkpointtime = 0;
1010 case RACE_NET_CHECKPOINT_NEXT_SPEC_QUALIFYING:
1011 race_laptime = ReadCoord();
1012 race_checkpointtime = -99999;
1014 case RACE_NET_CHECKPOINT_NEXT_QUALIFYING:
1015 race_nextcheckpoint = ReadByte();
1017 race_nextbesttime = ReadInt24_t();
1018 if(race_nextbestname)
1019 strunzone(race_nextbestname);
1020 race_nextbestname = strzone(ColorTranslateRGB(ReadString()));
1023 case RACE_NET_CHECKPOINT_HIT_RACE:
1024 race_mycheckpoint = ReadByte();
1025 race_mycheckpointtime = time;
1026 race_mycheckpointdelta = ReadInt24_t();
1027 race_mycheckpointlapsdelta = ReadByte();
1028 if(race_mycheckpointlapsdelta >= 128)
1029 race_mycheckpointlapsdelta -= 256;
1030 if(race_mycheckpointenemy)
1031 strunzone(race_mycheckpointenemy);
1032 race_mycheckpointenemy = strzone(ColorTranslateRGB(ReadString()));
1035 case RACE_NET_CHECKPOINT_HIT_RACE_BY_OPPONENT:
1036 race_othercheckpoint = ReadByte();
1037 race_othercheckpointtime = time;
1038 race_othercheckpointdelta = ReadInt24_t();
1039 race_othercheckpointlapsdelta = ReadByte();
1040 if(race_othercheckpointlapsdelta >= 128)
1041 race_othercheckpointlapsdelta -= 256;
1042 if(race_othercheckpointenemy)
1043 strunzone(race_othercheckpointenemy);
1044 race_othercheckpointenemy = strzone(ColorTranslateRGB(ReadString()));
1047 case RACE_NET_PENALTY_RACE:
1048 race_penaltyeventtime = time;
1049 race_penaltytime = ReadShort();
1050 //race_penaltyaccumulator += race_penaltytime;
1051 if(race_penaltyreason)
1052 strunzone(race_penaltyreason);
1053 race_penaltyreason = strzone(ReadString());
1056 case RACE_NET_PENALTY_QUALIFYING:
1057 race_penaltyeventtime = time;
1058 race_penaltytime = ReadShort();
1059 race_penaltyaccumulator += race_penaltytime;
1060 if(race_penaltyreason)
1061 strunzone(race_penaltyreason);
1062 race_penaltyreason = strzone(ReadString());
1065 case RACE_NET_SERVER_RECORD:
1066 race_server_record = ReadInt24_t();
1068 case RACE_NET_SPEED_AWARD:
1069 race_speedaward = ReadInt24_t();
1070 if(race_speedaward_holder)
1071 strunzone(race_speedaward_holder);
1072 race_speedaward_holder = strzone(ReadString());
1074 case RACE_NET_SPEED_AWARD_BEST:
1075 race_speedaward_alltimebest = ReadInt24_t();
1076 if(race_speedaward_alltimebest_holder)
1077 strunzone(race_speedaward_alltimebest_holder);
1078 race_speedaward_alltimebest_holder = strzone(ReadString());
1080 case RACE_NET_SERVER_RANKINGS:
1082 int pos = ReadShort();
1083 prevpos = ReadShort();
1086 // move other rankings out of the way
1089 for (i=prevpos-1;i>pos-1;--i) {
1090 grecordtime[i] = grecordtime[i-1];
1091 if(grecordholder[i])
1092 strunzone(grecordholder[i]);
1093 grecordholder[i] = strzone(grecordholder[i-1]);
1095 } else if (del) { // a record has been deleted by the admin
1096 for (i=pos-1; i<= RANKINGS_CNT-1; ++i) {
1097 if (i == RANKINGS_CNT-1) { // clear out last record
1099 if (grecordholder[i])
1100 strunzone(grecordholder[i]);
1101 grecordholder[i] = string_null;
1104 grecordtime[i] = grecordtime[i+1];
1105 if (grecordholder[i])
1106 strunzone(grecordholder[i]);
1107 grecordholder[i] = strzone(grecordholder[i+1]);
1110 } else { // player has no ranked record yet
1111 for (i=RANKINGS_CNT-1;i>pos-1;--i) {
1112 grecordtime[i] = grecordtime[i-1];
1113 if(grecordholder[i])
1114 strunzone(grecordholder[i]);
1115 grecordholder[i] = strzone(grecordholder[i-1]);
1119 // store new ranking
1120 if(grecordholder[pos-1] != "")
1121 strunzone(grecordholder[pos-1]);
1122 grecordholder[pos-1] = strzone(ReadString());
1123 grecordtime[pos-1] = ReadInt24_t();
1124 if(grecordholder[pos-1] == GetPlayerName(player_localnum))
1127 case RACE_NET_SERVER_STATUS:
1128 race_status = ReadShort();
1129 if(race_status_name)
1130 strunzone(race_status_name);
1131 race_status_name = strzone(ReadString());
1136 NET_HANDLE(TE_CSQC_TEAMNAGGER, bool isNew)
1142 NET_HANDLE(TE_CSQC_PINGPLREPORT, bool isNew)
1145 int pi = ReadShort();
1146 int pl = ReadByte();
1147 int ml = ReadByte();
1149 entity e = playerslots[i];
1152 e.ping_packetloss = pl / 255.0;
1153 e.ping_movementloss = ml / 255.0;
1156 NET_HANDLE(TE_CSQC_WEAPONCOMPLAIN, bool isNew)
1158 complain_weapon = ReadByte();
1159 if (complain_weapon_name) strunzone(complain_weapon_name);
1160 complain_weapon_name = strzone(WEP_NAME(complain_weapon));
1161 complain_weapon_type = ReadByte();
1164 complain_weapon_time = time;
1165 weapontime = time; // ping the weapon panel
1167 switch(complain_weapon_type)
1169 case 0: Local_Notification(MSG_MULTI, ITEM_WEAPON_NOAMMO, complain_weapon); break;
1170 case 1: Local_Notification(MSG_MULTI, ITEM_WEAPON_DONTHAVE, complain_weapon); break;
1171 default: Local_Notification(MSG_MULTI, ITEM_WEAPON_UNAVAILABLE, complain_weapon); break;
1175 string getcommandkey(string text, string command)
1178 float n, j, k, l = 0;
1180 if (!autocvar_hud_showbinds)
1183 keys = db_get(binddb, command);
1186 n = tokenize(findkeysforcommand(command, 0)); // uses '...' strings
1187 for(j = 0; j < n; ++j)
1193 keys = keynumtostring(k);
1195 keys = strcat(keys, ", ", keynumtostring(k));
1198 if (autocvar_hud_showbinds_limit > 0 && autocvar_hud_showbinds_limit <= l)
1205 db_put(binddb, command, keys);
1208 if (keys == "NO_KEY") {
1209 if (autocvar_hud_showbinds > 1)
1210 return sprintf(_("%s (not bound)"), text);
1214 else if (autocvar_hud_showbinds > 1)
1215 return sprintf("%s (%s)", text, keys);