4 #include "../common/effects/qc/all.qh"
7 #include "mapvoting.qh"
8 #include "modeleffects.qh"
9 #include "mutators/events.qh"
10 #include "quickmenu.qh"
11 #include "scoreboard.qh"
12 #include "shownames.qh"
16 #include "weapons/projectile.qh"
17 #include "../common/deathtypes/all.qh"
18 #include "../common/items/all.qh"
19 #include "../common/mapinfo.qh"
20 #include "../common/minigames/cl_minigames.qh"
21 #include "../common/minigames/cl_minigames_hud.qh"
22 #include "../common/net_notice.qh"
23 #include "../common/triggers/include.qh"
24 #include "../common/vehicles/all.qh"
25 #include "../lib/csqcmodel/cl_model.qh"
26 #include "../lib/csqcmodel/interpolate.qh"
27 #include "../lib/warpzone/client.qh"
29 // --------------------------------------------------------------------------
30 // BEGIN REQUIRED CSQC FUNCTIONS
33 #define DP_CSQC_ENTITY_REMOVE_IS_B0RKED
35 // CSQC_Init : Called every time the CSQC code is initialized (essentially at map load)
36 // Useful for precaching things
38 void ConsoleCommand_macro_init();
41 prvm_language = strzone(cvar_string("prvm_language"));
44 LOG_TRACEF("^4CSQC Build information: ^1%s\n", WATERMARK);
49 ClientProgsDB = db_load("client.db");
50 compressShortVector_init();
57 if (getplayerkeyvalue(i, "viewentity") == "")
62 //registercommand("hud_configure");
63 //registercommand("hud_save");
64 //registercommand("menu_action");
66 ConsoleCommand_macro_init();
68 registercvar("hud_usecsqc", "1");
69 registercvar("scoreboard_columns", "default");
71 registercvar("cl_nade_type", "3");
72 registercvar("cl_pokenade_type", "zombie");
74 registercvar("cl_jumpspeedcap_min", "");
75 registercvar("cl_jumpspeedcap_max", "");
77 registercvar("cl_multijump", "0");
79 registercvar("cl_spawn_near_teammate", "1");
83 // hud_fields uses strunzone on the titles!
84 for(int i = 0; i < MAX_HUD_FIELDS; ++i)
85 hud_title[i] = strzone("(null)");
94 players = Sort_Spawn();
96 GetTeam(NUM_SPECTATOR, true); // add specs first
98 // needs to be done so early because of the constants they create
101 static_init_precache();
105 if(autocvar_cl_reticle)
107 precache_pic("gfx/reticle_normal");
108 // weapon reticles are precached in weapon files
112 get_mi_min_max_texcoords(1); // try the CLEVER way first
113 minimapname = strcat("gfx/", mi_shortname, "_radar.tga");
114 shortmapname = mi_shortname;
116 if (precache_pic(minimapname) == "")
118 // but maybe we have a non-clever minimap
119 minimapname = strcat("gfx/", mi_shortname, "_mini.tga");
120 if (precache_pic(minimapname) == "")
121 minimapname = ""; // FAIL
123 get_mi_min_max_texcoords(0); // load new texcoords
126 mi_center = (mi_min + mi_max) * 0.5;
127 mi_scale = mi_max - mi_min;
128 minimapname = strzone(minimapname);
131 hud_skin_path = strzone(strcat("gfx/hud/", autocvar_hud_skin));
132 draw_currentSkin = strzone(strcat("gfx/menu/", cvar_string("menu_skin")));
135 // CSQC_Shutdown : Called every time the CSQC code is shutdown (changing maps, quitting, etc)
144 if(autocvar_cl_db_saveasdump)
145 db_dump(ClientProgsDB, "client.db");
147 db_save(ClientProgsDB, "client.db");
148 db_close(ClientProgsDB);
151 cvar_set("chase_active",ftos(chase_active_backup));
153 // unset the event chasecam's chase_active
154 if(autocvar_chase_active < 0)
155 cvar_set("chase_active", "0");
159 if (!(calledhooks & HOOK_START))
160 localcmd("\n_cl_hook_gamestart nop\n");
161 if (!(calledhooks & HOOK_END))
162 localcmd("\ncl_hook_gameend\n");
165 deactivate_minigame();
166 HUD_MinigameMenu_Close();
170 float SetTeam(entity o, int Team)
184 if(GetTeam(Team, false) == world)
186 LOG_TRACEF("trying to switch to unsupported team %d\n", Team);
187 Team = NUM_SPECTATOR;
200 if(GetTeam(Team, false) == world)
202 LOG_TRACEF("trying to switch to unsupported team %d\n", Team);
203 Team = NUM_SPECTATOR;
208 if(Team == -1) // leave
212 tm = GetTeam(o.team, false);
223 tm = GetTeam(Team, true);
228 else if(Team != o.team)
230 tm = GetTeam(o.team, false);
233 tm = GetTeam(Team, true);
241 void Playerchecker_Think()
246 for(i = 0; i < maxclients; ++i)
249 if(GetPlayerName(i) == "")
253 // player disconnected
267 playerslots[i] = e = new(playerslot);
272 e.ping_packetloss = 0;
273 e.ping_movementloss = 0;
274 //e.gotscores = 0; // we might already have the scores...
275 SetTeam(e, GetPlayerColor(i)); // will not hurt; later updates come with HUD_UpdatePlayerTeams
277 HUD_UpdatePlayerPos(e);
281 this.nextthink = time + 0.2;
288 entity playerchecker = new(playerchecker);
289 make_pure(playerchecker);
290 playerchecker.think = Playerchecker_Think;
291 playerchecker.nextthink = time + 0.2;
299 // CSQC_InputEvent : Used to perform actions based on any key pressed, key released and mouse on the client.
300 // Return value should be 1 if CSQC handled the input, otherwise return 0 to have the input passed to the engine.
301 // All keys are in ascii.
302 // bInputType = 0 is key pressed, 1 is key released, 2 and 3 are mouse input.
303 // In the case of keyboard input, nPrimary is the ascii code, and nSecondary is 0.
304 // In the case of mouse input, nPrimary is xdelta, nSecondary is ydelta.
305 // In the case of mouse input after a setcursormode(1) call, nPrimary is xpos, nSecondary is ypos.
306 float CSQC_InputEvent(float bInputType, float nPrimary, float nSecondary)
308 if (HUD_Panel_InputEvent(bInputType, nPrimary, nSecondary))
311 if (QuickMenu_InputEvent(bInputType, nPrimary, nSecondary))
314 if (HUD_Radar_InputEvent(bInputType, nPrimary, nSecondary))
317 if (MapVote_InputEvent(bInputType, nPrimary, nSecondary))
320 if (HUD_Minigame_InputEvent(bInputType, nPrimary, nSecondary))
326 // END REQUIRED CSQC FUNCTIONS
327 // --------------------------------------------------------------------------
329 // --------------------------------------------------------------------------
330 // BEGIN OPTIONAL CSQC FUNCTIONS
332 void Ent_RemoveEntCS()
335 entcs_receiver[this.sv_entnum] = NULL;
338 NET_HANDLE(ENT_CLIENT_ENTCS, bool isnew)
341 this.classname = "entcs_receiver";
342 InterpolateOrigin_Undo();
346 this.sv_entnum = ReadByte();
349 this.origin_x = ReadShort();
350 this.origin_y = ReadShort();
351 this.origin_z = ReadShort();
352 setorigin(this, this.origin);
356 this.angles_y = ReadByte() * 360.0 / 256;
357 this.angles_x = this.angles_z = 0;
360 this.healthvalue = ReadByte() * 10;
362 this.armorvalue = ReadByte() * 10;
366 entcs_receiver[this.sv_entnum] = this;
367 this.entremove = Ent_RemoveEntCS;
368 this.iflags |= IFLAG_ORIGIN;
370 InterpolateOrigin_Note();
375 void Ent_RemovePlayerScore()
379 SetTeam(this.owner, -1);
380 this.owner.gotscores = 0;
381 for(int i = 0; i < MAX_SCORE; ++i) {
382 this.owner.(scores[i]) = 0; // clear all scores
387 NET_HANDLE(ENT_CLIENT_SCORES, bool isnew)
394 // damnit -.- don't want to go change every single .sv_entnum in hud.qc AGAIN
395 // (no I've never heard of M-x replace-string, sed, or anything like that)
396 isNew = !this.owner; // workaround for DP bug
399 #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
400 if(!isNew && n != this.sv_entnum)
402 //print("A CSQC entity changed its owner!\n");
403 LOG_INFOF("A CSQC entity changed its owner! (edict: %d, classname: %s)\n", num_for_edict(this), this.classname);
411 o = playerslots[this.sv_entnum];
414 o = playerslots[this.sv_entnum] = new(playerslot);
418 o.sv_entnum = this.sv_entnum;
422 // RegisterPlayer(o);
423 //playerchecker will do this for us later, if it has not already done so
434 for(i = 0, p = 1; i < MAX_SCORE; ++i, p *= 2)
438 o.(scores[i]) = ReadInt24_t();
440 o.(scores[i]) = ReadChar();
446 HUD_UpdatePlayerPos(o); // if not registered, we cannot do this yet!
448 this.entremove = Ent_RemovePlayerScore;
451 NET_HANDLE(ENT_CLIENT_TEAMSCORES, bool isnew)
457 this.team = ReadByte();
458 o = this.owner = GetTeam(this.team, true); // these team numbers can always be trusted
461 #if MAX_TEAMSCORE <= 8
469 for(i = 0, p = 1; i < MAX_TEAMSCORE; ++i, p *= 2)
473 o.(teamscores[i]) = ReadInt24_t();
475 o.(teamscores[i]) = ReadChar();
480 HUD_UpdateTeamPos(o);
483 NET_HANDLE(ENT_CLIENT_CLIENTDATA, bool isnew)
486 float newspectatee_status;
490 scoreboard_showscores_force = (f & 1);
494 newspectatee_status = ReadByte();
495 if(newspectatee_status == player_localnum + 1)
496 newspectatee_status = -1; // observing
499 newspectatee_status = 0;
501 spectatorbutton_zoom = (f & 4);
505 angles_held_status = 1;
506 angles_held.x = ReadAngle();
507 angles_held.y = ReadAngle();
511 angles_held_status = 0;
515 if(newspectatee_status != spectatee_status)
519 race_checkpointtime = 0;
521 if (autocvar_hud_panel_healtharmor_progressbar_gfx)
523 if ( (spectatee_status == -1 && newspectatee_status > 0) //before observing, now spectating
524 || (spectatee_status > 0 && newspectatee_status > 0 && spectatee_status != newspectatee_status) //changed spectated player
527 else if(spectatee_status && !newspectatee_status) //before observing/spectating, now playing
530 spectatee_status = newspectatee_status;
532 // we could get rid of spectatee_status, and derive it from player_localentnum and player_localnum
535 NET_HANDLE(ENT_CLIENT_NAGGER, bool isnew)
540 int nags = ReadByte(); // NAGS NAGS NAGS NAGS NAGS NAGS NADZ NAGS NAGS NAGS
545 strunzone(vote_called_vote);
546 vote_called_vote = string_null;
556 vote_yescount = ReadByte();
557 vote_nocount = ReadByte();
558 vote_needed = ReadByte();
559 vote_highlighted = ReadChar();
565 strunzone(vote_called_vote);
566 vote_called_vote = strzone(ColorTranslateRGB(ReadString()));
571 for(j = 0; j < maxclients; ++j)
573 playerslots[j].ready = 1;
574 for(i = 1; i <= maxclients; i += 8)
577 for(j = i-1, b = 1; b < 256; b *= 2, ++j)
580 playerslots[j].ready = 0;
586 ready_waiting = (nags & BIT(0));
587 ready_waiting_for_me = (nags & BIT(1));
588 vote_waiting = (nags & BIT(2));
589 vote_waiting_for_me = (nags & BIT(3));
590 warmup_stage = (nags & BIT(4));
593 NET_HANDLE(ENT_CLIENT_ELIMINATEDPLAYERS, bool isnew)
601 for(j = 0; j < maxclients; ++j)
603 playerslots[j].eliminated = 1;
604 for(i = 1; i <= maxclients; i += 8)
607 for(j = i-1, b = 1; b < 256; b *= 2, ++j)
610 playerslots[j].eliminated = 0;
616 NET_HANDLE(ENT_CLIENT_RANDOMSEED, bool isnew)
620 float s = ReadShort();
625 NET_HANDLE(ENT_CLIENT_ACCURACY, bool isnew)
628 int sf = ReadInt24_t();
630 for (int w = 0; w <= WEP_LAST - WEP_FIRST; ++w)
631 weapon_accuracy[w] = -1;
636 for (int w = 0; w <= WEP_LAST - WEP_FIRST; ++w) {
640 weapon_accuracy[w] = -1;
642 weapon_accuracy[w] = 1.0; // no better error handling yet, sorry
644 weapon_accuracy[w] = (b - 1.0) / 100.0;
646 f = (f == 0x800000) ? 1 : f * 2;
651 void Spawn_Draw(entity this)
653 __pointparticles(this.cnt, this.origin + '0 0 28', '0 0 2', bound(0, frametime, 0.1));
656 NET_HANDLE(ENT_CLIENT_SPAWNPOINT, bool is_new)
658 float teamnum = (ReadByte() - 1);
660 spn_origin.x = ReadShort();
661 spn_origin.y = ReadShort();
662 spn_origin.z = ReadShort();
666 this.origin = spn_origin;
667 setsize(this, PL_MIN_CONST, PL_MAX_CONST);
670 /*if(autocvar_cl_spawn_point_model) // needs a model first
672 this.mdl = "models/spawnpoint.md3";
673 this.colormod = Team_ColorRGB(teamnum);
674 precache_model(this.mdl);
675 setmodel(this, this.mdl);
676 this.drawmask = MASK_NORMAL;
677 //this.movetype = MOVETYPE_NOCLIP;
678 //this.draw = Spawn_Draw;
680 if(autocvar_cl_spawn_point_particles)
682 if((serverflags & SERVERFLAG_TEAMPLAY))
686 case NUM_TEAM_1: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_RED); break;
687 case NUM_TEAM_2: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_BLUE); break;
688 case NUM_TEAM_3: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_YELLOW); break;
689 case NUM_TEAM_4: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_PINK); break;
690 default: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_NEUTRAL); break;
693 else { this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_NEUTRAL); }
695 this.draw = Spawn_Draw;
699 //printf("Ent_ReadSpawnPoint(is_new = %d); origin = %s, team = %d, effect = %d\n", is_new, vtos(this.origin), teamnum, this.cnt);
703 NET_HANDLE(ENT_CLIENT_SPAWNEVENT, bool is_new)
705 // If entnum is 0, ONLY do the local spawn actions
706 // this way the server can disable the sending of
707 // spawn origin or such to clients if wanted.
708 float entnum = ReadByte();
712 this.origin_x = ReadShort();
713 this.origin_y = ReadShort();
714 this.origin_z = ReadShort();
718 float teamnum = GetPlayerColor(entnum - 1);
720 if(autocvar_cl_spawn_event_particles)
724 case NUM_TEAM_1: pointparticles(EFFECT_SPAWN_RED, this.origin, '0 0 0', 1); break;
725 case NUM_TEAM_2: pointparticles(EFFECT_SPAWN_BLUE, this.origin, '0 0 0', 1); break;
726 case NUM_TEAM_3: pointparticles(EFFECT_SPAWN_YELLOW, this.origin, '0 0 0', 1); break;
727 case NUM_TEAM_4: pointparticles(EFFECT_SPAWN_PINK, this.origin, '0 0 0', 1); break;
728 default: pointparticles(EFFECT_SPAWN_NEUTRAL, this.origin, '0 0 0', 1); break;
731 if(autocvar_cl_spawn_event_sound)
733 sound(this, CH_TRIGGER, SND_SPAWN, VOL_BASE, ATTEN_NORM);
739 // local spawn actions
740 if(is_new && (!entnum || (entnum == player_localentnum)))
743 current_viewzoom = (1 / bound(1, autocvar_cl_spawnzoom_factor, 16));
745 if(autocvar_cl_unpress_zoom_on_spawn)
751 HUD_Radar_Hide_Maximized();
752 //printf("Ent_ReadSpawnEvent(is_new = %d); origin = %s, entnum = %d, localentnum = %d\n", is_new, vtos(this.origin), entnum, player_localentnum);
755 // CSQC_Ent_Update : Called every frame that the server has indicated an update to the SSQC / CSQC entity has occured.
756 // The only parameter reflects if the entity is "new" to the client, meaning it just came into the client's PVS.
757 void CSQC_Ent_Update(float bIsNewEntity)
760 this.sourceLocLine = __LINE__;
761 this.sourceLocFile = __FILE__;
764 // set up the "time" global for received entities to be correct for interpolation purposes
765 float savetime = time;
772 serverprevtime = time;
773 serverdeltatime = getstatf(STAT_MOVEVARS_TICRATE) * getstatf(STAT_MOVEVARS_TIMESCALE);
774 time = serverprevtime + serverdeltatime;
777 #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
780 if(t != this.enttype || bIsNewEntity)
782 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);
792 LOG_INFOF("A CSQC entity appeared out of nowhere! (edict: %d, server: %d, type: %d)\n", num_for_edict(this), this.entnum, t);
799 FOREACH(LinkedEntities, it.m_id == t, LAMBDA(
800 this.classname = it.netname;
801 if (autocvar_developer_csqcentities)
802 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);
803 done = it.m_read(this, bIsNewEntity);
809 //error(strcat(_("unknown entity type in CSQC_Ent_Update: %d\n"), this.enttype));
810 error(sprintf("Unknown entity type in CSQC_Ent_Update (enttype: %d, edict: %d, classname: %s)\n", this.enttype, num_for_edict(this), this.classname));
814 // Destructor, but does NOT deallocate the entity by calling remove(). Also
815 // used when an entity changes its type. For an entity that someone interacts
816 // with others, make sure it can no longer do so.
820 if(this.entremove) this.entremove();
822 if(this.skeletonindex)
824 skel_delete(this.skeletonindex);
825 this.skeletonindex = 0;
828 if(this.snd_looping > 0)
830 sound(this, this.snd_looping, SND_Null, VOL_BASE, autocvar_g_jetpack_attenuation);
831 this.snd_looping = 0;
836 this.draw = func_null;
837 this.entremove = func_null;
838 // TODO possibly set more stuff to defaults
840 // CSQC_Ent_Remove : Called when the server requests a SSQC / CSQC entity to be removed. Essentially call remove(this) as well.
841 void CSQC_Ent_Remove()
844 if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Ent_Remove() with this=%i {.entnum=%d, .enttype=%d}\n", this, this.entnum, this.enttype);
847 LOG_WARNING("CSQC_Ent_Remove called for already removed entity. Packet loss?\n");
850 if (this.enttype) Ent_Remove();
858 if(!(calledhooks & HOOK_START))
859 localcmd("\n_cl_hook_gamestart ", MapInfo_Type_ToString(gametype), "\n");
860 calledhooks |= HOOK_START;
863 // 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.
864 void CSQC_Parse_StuffCmd(string strMessage)
866 if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Parse_StuffCmd(\"%s\")\n", strMessage);
867 localcmd(strMessage);
869 // 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.
870 void CSQC_Parse_Print(string strMessage)
872 if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Parse_Print(\"%s\")\n", strMessage);
873 print(ColorTranslateRGB(strMessage));
876 // CSQC_Parse_CenterPrint : Provides the centerprint_hud string in the first parameter that the server provided.
877 void CSQC_Parse_CenterPrint(string strMessage)
879 if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Parse_CenterPrint(\"%s\")\n", strMessage);
880 centerprint_hud(strMessage);
883 // CSQC_Parse_TempEntity : Handles all temporary entity network data in the CSQC layer.
884 // You must ALWAYS first acquire the temporary ID, which is sent as a byte.
885 // Return value should be 1 if CSQC handled the temporary entity, otherwise return 0 to have the engine process the event.
886 bool CSQC_Parse_TempEntity()
889 int nTEID = ReadByte();
891 FOREACH(TempEntities, it.m_id == nTEID, LAMBDA(
892 if (autocvar_developer_csqcentities)
893 LOG_INFOF("CSQC_Parse_TempEntity() nTEID=%s (%d)\n", it.netname, nTEID);
894 return it.m_read(NULL, true);
897 if (autocvar_developer_csqcentities)
898 LOG_INFOF("CSQC_Parse_TempEntity() with nTEID=%d\n", nTEID);
900 // No special logic for this temporary entity; return 0 so the engine can handle it
904 /** TODO somehow thwart prvm_globalset client ... */
908 if (autocvar_cl_orthoview && autocvar_cl_orthoview_nofog)
909 localcmd("\nr_drawfog 0\n");
910 else if (forcefog != "")
911 localcmd(sprintf("\nfog %s\nr_fog_exp2 0\nr_drawfog 1\n", forcefog));
914 void Gamemode_Init();
915 NET_HANDLE(ENT_CLIENT_SCORES_INFO, bool isnew)
918 gametype = ReadInt24_t();
919 HUD_ModIcons_SetFunc();
920 for (int i = 0; i < MAX_SCORE; ++i)
922 if (scores_label[i]) strunzone(scores_label[i]);
923 scores_label[i] = strzone(ReadString());
924 scores_flags[i] = ReadByte();
926 for (int i = 0; i < MAX_TEAMSCORE; ++i)
928 if (teamscores_label[i]) strunzone(teamscores_label[i]);
929 teamscores_label[i] = strzone(ReadString());
930 teamscores_flags[i] = ReadByte();
937 NET_HANDLE(ENT_CLIENT_INIT, bool isnew)
941 nb_pb_period = ReadByte() / 32; //Accuracy of 1/32th
943 hook_shotorigin[0] = decompressShotOrigin(ReadInt24_t());
944 hook_shotorigin[1] = decompressShotOrigin(ReadInt24_t());
945 hook_shotorigin[2] = decompressShotOrigin(ReadInt24_t());
946 hook_shotorigin[3] = decompressShotOrigin(ReadInt24_t());
947 arc_shotorigin[0] = decompressShotOrigin(ReadInt24_t());
948 arc_shotorigin[1] = decompressShotOrigin(ReadInt24_t());
949 arc_shotorigin[2] = decompressShotOrigin(ReadInt24_t());
950 arc_shotorigin[3] = decompressShotOrigin(ReadInt24_t());
952 if (forcefog) strunzone(forcefog);
953 forcefog = strzone(ReadString());
955 armorblockpercent = ReadByte() / 255.0;
957 g_balance_mortar_bouncefactor = ReadCoord();
958 g_balance_mortar_bouncestop = ReadCoord();
959 g_balance_electro_secondary_bouncefactor = ReadCoord();
960 g_balance_electro_secondary_bouncestop = ReadCoord();
962 vortex_scope = !ReadByte();
963 rifle_scope = !ReadByte();
965 serverflags = ReadByte();
967 minelayer_maxmines = ReadByte();
969 hagar_maxrockets = ReadByte();
971 g_trueaim_minrange = ReadCoord();
972 g_balance_porto_secondary = ReadByte();
975 MUTATOR_CALLHOOK(Ent_Init);
977 if (!postinit) PostInit();
980 NET_HANDLE(TE_CSQC_RACE, bool isNew)
986 case RACE_NET_CHECKPOINT_HIT_QUALIFYING:
987 race_checkpoint = ReadByte();
988 race_time = ReadInt24_t();
989 race_previousbesttime = ReadInt24_t();
990 if(race_previousbestname)
991 strunzone(race_previousbestname);
992 race_previousbestname = strzone(ColorTranslateRGB(ReadString()));
994 race_checkpointtime = time;
996 if(race_checkpoint == 0 || race_checkpoint == 254)
998 race_penaltyaccumulator = 0;
999 race_laptime = time; // valid
1004 case RACE_NET_CHECKPOINT_CLEAR:
1006 race_checkpointtime = 0;
1009 case RACE_NET_CHECKPOINT_NEXT_SPEC_QUALIFYING:
1010 race_laptime = ReadCoord();
1011 race_checkpointtime = -99999;
1013 case RACE_NET_CHECKPOINT_NEXT_QUALIFYING:
1014 race_nextcheckpoint = ReadByte();
1016 race_nextbesttime = ReadInt24_t();
1017 if(race_nextbestname)
1018 strunzone(race_nextbestname);
1019 race_nextbestname = strzone(ColorTranslateRGB(ReadString()));
1022 case RACE_NET_CHECKPOINT_HIT_RACE:
1023 race_mycheckpoint = ReadByte();
1024 race_mycheckpointtime = time;
1025 race_mycheckpointdelta = ReadInt24_t();
1026 race_mycheckpointlapsdelta = ReadByte();
1027 if(race_mycheckpointlapsdelta >= 128)
1028 race_mycheckpointlapsdelta -= 256;
1029 if(race_mycheckpointenemy)
1030 strunzone(race_mycheckpointenemy);
1031 race_mycheckpointenemy = strzone(ColorTranslateRGB(ReadString()));
1034 case RACE_NET_CHECKPOINT_HIT_RACE_BY_OPPONENT:
1035 race_othercheckpoint = ReadByte();
1036 race_othercheckpointtime = time;
1037 race_othercheckpointdelta = ReadInt24_t();
1038 race_othercheckpointlapsdelta = ReadByte();
1039 if(race_othercheckpointlapsdelta >= 128)
1040 race_othercheckpointlapsdelta -= 256;
1041 if(race_othercheckpointenemy)
1042 strunzone(race_othercheckpointenemy);
1043 race_othercheckpointenemy = strzone(ColorTranslateRGB(ReadString()));
1046 case RACE_NET_PENALTY_RACE:
1047 race_penaltyeventtime = time;
1048 race_penaltytime = ReadShort();
1049 //race_penaltyaccumulator += race_penaltytime;
1050 if(race_penaltyreason)
1051 strunzone(race_penaltyreason);
1052 race_penaltyreason = strzone(ReadString());
1055 case RACE_NET_PENALTY_QUALIFYING:
1056 race_penaltyeventtime = time;
1057 race_penaltytime = ReadShort();
1058 race_penaltyaccumulator += race_penaltytime;
1059 if(race_penaltyreason)
1060 strunzone(race_penaltyreason);
1061 race_penaltyreason = strzone(ReadString());
1064 case RACE_NET_SERVER_RECORD:
1065 race_server_record = ReadInt24_t();
1067 case RACE_NET_SPEED_AWARD:
1068 race_speedaward = ReadInt24_t();
1069 if(race_speedaward_holder)
1070 strunzone(race_speedaward_holder);
1071 race_speedaward_holder = strzone(ReadString());
1073 case RACE_NET_SPEED_AWARD_BEST:
1074 race_speedaward_alltimebest = ReadInt24_t();
1075 if(race_speedaward_alltimebest_holder)
1076 strunzone(race_speedaward_alltimebest_holder);
1077 race_speedaward_alltimebest_holder = strzone(ReadString());
1079 case RACE_NET_SERVER_RANKINGS:
1081 int pos = ReadShort();
1082 prevpos = ReadShort();
1085 // move other rankings out of the way
1088 for (i=prevpos-1;i>pos-1;--i) {
1089 grecordtime[i] = grecordtime[i-1];
1090 if(grecordholder[i])
1091 strunzone(grecordholder[i]);
1092 grecordholder[i] = strzone(grecordholder[i-1]);
1094 } else if (del) { // a record has been deleted by the admin
1095 for (i=pos-1; i<= RANKINGS_CNT-1; ++i) {
1096 if (i == RANKINGS_CNT-1) { // clear out last record
1098 if (grecordholder[i])
1099 strunzone(grecordholder[i]);
1100 grecordholder[i] = string_null;
1103 grecordtime[i] = grecordtime[i+1];
1104 if (grecordholder[i])
1105 strunzone(grecordholder[i]);
1106 grecordholder[i] = strzone(grecordholder[i+1]);
1109 } else { // player has no ranked record yet
1110 for (i=RANKINGS_CNT-1;i>pos-1;--i) {
1111 grecordtime[i] = grecordtime[i-1];
1112 if(grecordholder[i])
1113 strunzone(grecordholder[i]);
1114 grecordholder[i] = strzone(grecordholder[i-1]);
1118 // store new ranking
1119 if(grecordholder[pos-1] != "")
1120 strunzone(grecordholder[pos-1]);
1121 grecordholder[pos-1] = strzone(ReadString());
1122 grecordtime[pos-1] = ReadInt24_t();
1123 if(grecordholder[pos-1] == GetPlayerName(player_localnum))
1126 case RACE_NET_SERVER_STATUS:
1127 race_status = ReadShort();
1128 if(race_status_name)
1129 strunzone(race_status_name);
1130 race_status_name = strzone(ReadString());
1135 NET_HANDLE(TE_CSQC_TEAMNAGGER, bool isNew)
1141 NET_HANDLE(TE_CSQC_PINGPLREPORT, bool isNew)
1144 int pi = ReadShort();
1145 int pl = ReadByte();
1146 int ml = ReadByte();
1148 entity e = playerslots[i];
1151 e.ping_packetloss = pl / 255.0;
1152 e.ping_movementloss = ml / 255.0;
1155 NET_HANDLE(TE_CSQC_WEAPONCOMPLAIN, bool isNew)
1157 complain_weapon = ReadByte();
1158 if (complain_weapon_name) strunzone(complain_weapon_name);
1159 complain_weapon_name = strzone(WEP_NAME(complain_weapon));
1160 complain_weapon_type = ReadByte();
1163 complain_weapon_time = time;
1164 weapontime = time; // ping the weapon panel
1166 switch(complain_weapon_type)
1168 case 0: Local_Notification(MSG_MULTI, ITEM_WEAPON_NOAMMO, complain_weapon); break;
1169 case 1: Local_Notification(MSG_MULTI, ITEM_WEAPON_DONTHAVE, complain_weapon); break;
1170 default: Local_Notification(MSG_MULTI, ITEM_WEAPON_UNAVAILABLE, complain_weapon); break;
1174 string getcommandkey(string text, string command)
1177 float n, j, k, l = 0;
1179 if (!autocvar_hud_showbinds)
1182 keys = db_get(binddb, command);
1185 n = tokenize(findkeysforcommand(command, 0)); // uses '...' strings
1186 for(j = 0; j < n; ++j)
1192 keys = keynumtostring(k);
1194 keys = strcat(keys, ", ", keynumtostring(k));
1197 if (autocvar_hud_showbinds_limit > 0 && autocvar_hud_showbinds_limit <= l)
1204 db_put(binddb, command, keys);
1207 if (keys == "NO_KEY") {
1208 if (autocvar_hud_showbinds > 1)
1209 return sprintf(_("%s (not bound)"), text);
1213 else if (autocvar_hud_showbinds > 1)
1214 return sprintf("%s (%s)", text, keys);