1 // --------------------------------------------------------------------------
2 // BEGIN REQUIRED CSQC FUNCTIONS
5 #define DP_CSQC_ENTITY_REMOVE_IS_B0RKED
8 drawstring('0 200 0', _("ERROR - MENU IS VISIBLE BUT NO MENU WAS DEFINED!"), '8 8 0', '1 0 0', 1, 0);
11 // CSQC_Init : Called every time the CSQC code is initialized (essentially at map load)
12 // Useful for precaching things
22 void precache_playermodel(string m)
26 if(substring(m, -9,5) == "_lod1")
28 if(substring(m, -9,5) == "_lod2")
31 f = strcat(substring(m, 0, -5), "_lod1", substring(m, -4, -1));
34 f = strcat(substring(m, 0, -5), "_lod2", substring(m, -4, -1));
39 float globhandle, i, n;
40 globhandle = search_begin(strcat(m, "_*.sounds"), TRUE, FALSE);
43 n = search_getsize(globhandle);
44 for (i = 0; i < n; ++i)
46 //print(search_getfilename(globhandle, i), "\n");
47 f = search_getfilename(globhandle, i);
48 PrecachePlayerSounds(f);
50 search_end(globhandle);
53 void precache_all_playermodels(string pattern)
55 float globhandle, i, n;
58 globhandle = search_begin(pattern, TRUE, FALSE);
61 n = search_getsize(globhandle);
62 for (i = 0; i < n; ++i)
64 //print(search_getfilename(globhandle, i), "\n");
65 f = search_getfilename(globhandle, i);
66 precache_playermodel(f);
68 search_end(globhandle);
72 void WaypointSprite_Load();
73 void ConsoleCommand_macro_init();
76 prvm_language = cvar_string("prvm_language");
80 __engine_check = checkextension("DP_SV_WRITEPICTURE");
83 print(_("^3Your engine build is outdated\n^3This Server uses a newer QC VM. Please update!\n"));
84 localcmd("\ndisconnect\n");
90 check_unacceptable_compiler_bugs();
93 print(sprintf(_("^4CSQC Build information: ^1%s\n"), WATERMARK()));
98 #ifdef COMPAT_XON050_ENGINE
99 // old engine lacks implementation of player_localnum
100 player_localnum = player_localentnum - 1;
103 binddb = db_create();
104 tempdb = db_create();
105 ClientProgsDB = db_load("client.db");
106 compressShortVector_init();
108 drawfont = FONT_USER+1;
109 menu_visible = FALSE;
110 menu_show = menu_show_error;
111 menu_action = menu_sub_null;
113 for(i = 0; i < 255; ++i)
114 if(getplayerkeyvalue(i, "viewentity") == "")
118 //registercommand("hud_configure");
119 //registercommand("hud_save");
120 //registercommand("menu_action");
122 ConsoleCommand_macro_init();
124 registercvar("hud_usecsqc", "1");
125 registercvar("scoreboard_columns", "default");
129 // hud_fields uses strunzone on the titles!
130 for(i = 0; i < MAX_HUD_FIELDS; ++i)
131 hud_title[i] = strzone("(null)");
137 teams = Sort_Spawn();
138 players = Sort_Spawn();
140 GetTeam(COLOR_SPECTATOR, true); // add specs first
142 // needs to be done so early because of the constants they create
146 WaypointSprite_Load();
149 precache_model("null");
150 precache_sound("misc/hit.wav");
151 precache_sound("misc/typehit.wav");
152 if (autocvar_cl_precacheplayermodels)
154 precache_all_playermodels("models/player/*.zym");
155 precache_all_playermodels("models/player/*.dpm");
156 precache_all_playermodels("models/player/*.md3");
157 precache_all_playermodels("models/player/*.psk");
158 precache_all_playermodels("models/player/*.iqm");
161 Projectile_Precache();
163 GibSplash_Precache();
165 DamageInfo_Precache();
168 Announcer_Precache();
171 if(autocvar_cl_reticle)
173 if(autocvar_cl_reticle_item_normal) { precache_pic("gfx/reticle_normal"); }
174 if(autocvar_cl_reticle_item_nex) { precache_pic("gfx/reticle_nex"); }
177 get_mi_min_max_texcoords(1); // try the CLEVER way first
178 minimapname = strcat("gfx/", mi_shortname, "_radar.tga");
179 shortmapname = mi_shortname;
181 if(precache_pic(minimapname) == "")
183 // but maybe we have a non-clever minimap
184 minimapname = strcat("gfx/", mi_shortname, "_mini.tga");
185 if(precache_pic(minimapname) == "")
186 minimapname = ""; // FAIL
188 get_mi_min_max_texcoords(0); // load new texcoords
191 mi_center = (mi_min + mi_max) * 0.5;
192 mi_scale = mi_max - mi_min;
193 minimapname = strzone(minimapname);
197 hud_configure_prev = -1;
200 draw_currentSkin = strzone(strcat("gfx/menu/", cvar_string("menu_skin")));
203 // CSQC_Shutdown : Called every time the CSQC code is shutdown (changing maps, quitting, etc)
219 if(autocvar_cl_db_saveasdump)
220 db_dump(ClientProgsDB, "client.db");
222 db_save(ClientProgsDB, "client.db");
223 db_close(ClientProgsDB);
226 cvar_set("chase_active",ftos(chase_active_backup));
228 // unset the event chasecam's chase_active
229 if(autocvar_chase_active < 0)
230 cvar_set("chase_active", "0");
234 if not(calledhooks & HOOK_START)
235 localcmd("\n_cl_hook_gamestart nop\n");
236 if not(calledhooks & HOOK_END)
237 localcmd("\ncl_hook_gameend\n");
242 float SetTeam(entity o, float Team)
256 if(GetTeam(Team, false) == world)
258 print(sprintf(_("trying to switch to unsupported team %d\n"), Team));
259 Team = COLOR_SPECTATOR;
272 if(GetTeam(Team, false) == world)
274 print(sprintf(_("trying to switch to unsupported team %d\n"), Team));
275 Team = COLOR_SPECTATOR;
280 if(Team == -1) // leave
284 tm = GetTeam(o.team, false);
295 tm = GetTeam(Team, true);
300 else if(Team != o.team)
302 tm = GetTeam(o.team, false);
305 tm = GetTeam(Team, true);
313 void Playerchecker_Think()
317 for(i = 0; i < maxclients; ++i)
320 if(GetPlayerName(i) == "")
324 // player disconnected
337 playerslots[i] = e = spawn();
340 e.ping_packetloss = 0;
341 e.ping_movementloss = 0;
342 //e.gotscores = 0; // we might already have the scores...
343 SetTeam(e, GetPlayerColor(i)); // will not hurt; later updates come with HUD_UpdatePlayerTeams
345 HUD_UpdatePlayerPos(e);
349 self.nextthink = time + 0.2;
356 localcmd(strcat("\nscoreboard_columns_set ", autocvar_scoreboard_columns, ";\n"));
358 entity playerchecker;
359 playerchecker = spawn();
360 playerchecker.think = Playerchecker_Think;
361 playerchecker.nextthink = time + 0.2;
371 // CSQC_InputEvent : Used to perform actions based on any key pressed, key released and mouse on the client.
372 // Return value should be 1 if CSQC handled the input, otherwise return 0 to have the input passed to the engine.
373 // All keys are in ascii.
374 // bInputType = 0 is key pressed, 1 is key released, 2 is mouse input.
375 // In the case of keyboard input, nPrimary is the ascii code, and nSecondary is 0.
376 // In the case of mouse input, nPrimary is xdelta, nSecondary is ydelta.
377 float CSQC_InputEvent(float bInputType, float nPrimary, float nSecondary)
382 if (HUD_Panel_InputEvent(bInputType, nPrimary, nSecondary))
385 if (MapVote_InputEvent(bInputType, nPrimary, nSecondary))
389 if(menu_action(bInputType, nPrimary, nSecondary))
395 // END REQUIRED CSQC FUNCTIONS
396 // --------------------------------------------------------------------------
398 // --------------------------------------------------------------------------
399 // BEGIN OPTIONAL CSQC FUNCTIONS
400 void Ent_RemoveEntCS()
402 entcs_receiver[self.sv_entnum] = world;
407 InterpolateOrigin_Undo();
409 self.classname = "entcs_receiver";
413 self.sv_entnum = ReadByte();
416 self.origin_x = ReadShort();
417 self.origin_y = ReadShort();
418 self.origin_z = ReadShort();
422 self.angles_y = ReadByte() * 360.0 / 256;
423 self.angles_x = self.angles_z = 0;
426 self.healthvalue = ReadByte() * 10;
428 self.armorvalue = ReadByte() * 10;
430 entcs_receiver[self.sv_entnum] = self;
431 self.entremove = Ent_RemoveEntCS;
433 InterpolateOrigin_Note();
438 void Ent_RemovePlayerScore()
444 SetTeam(self.owner, -1);
445 self.owner.gotscores = 0;
446 for(i = 0; i < MAX_SCORE; ++i)
447 self.owner.(scores[i]) = 0; // clear all scores
451 void Ent_ReadPlayerScore()
457 // damnit -.- don't want to go change every single .sv_entnum in hud.qc AGAIN
458 // (no I've never heard of M-x replace-string, sed, or anything like that)
459 isNew = !self.owner; // workaround for DP bug
462 #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
463 if(!isNew && n != self.sv_entnum)
465 //print(_("A CSQC entity changed its owner!\n"));
466 print(sprintf(_("A CSQC entity changed its owner! (edict: %d, classname: %s)\n"), num_for_edict(self), self.classname));
469 self.enttype = ENT_CLIENT_SCORES;
475 if not(playerslots[self.sv_entnum])
476 playerslots[self.sv_entnum] = spawn();
477 o = self.owner = playerslots[self.sv_entnum];
478 o.sv_entnum = self.sv_entnum;
481 //if not(o.sort_prev)
482 // RegisterPlayer(o);
483 //playerchecker will do this for us later, if it has not already done so
494 for(i = 0, p = 1; i < MAX_SCORE; ++i, p *= 2)
498 o.(scores[i]) = ReadInt24_t();
500 o.(scores[i]) = ReadChar();
504 HUD_UpdatePlayerPos(o); // if not registered, we cannot do this yet!
506 self.entremove = Ent_RemovePlayerScore;
509 void Ent_ReadTeamScore()
514 self.team = ReadByte();
515 o = self.owner = GetTeam(self.team, true); // these team numbers can always be trusted
518 #if MAX_TEAMSCORE <= 8
526 for(i = 0, p = 1; i < MAX_TEAMSCORE; ++i, p *= 2)
530 o.(teamscores[i]) = ReadInt24_t();
532 o.(teamscores[i]) = ReadChar();
535 HUD_UpdateTeamPos(o);
538 void Ent_ClientData()
541 float newspectatee_status;
545 scoreboard_showscores_force = (f & 1);
549 newspectatee_status = ReadByte();
550 if(newspectatee_status == player_localnum + 1)
551 newspectatee_status = -1; // observing
554 newspectatee_status = 0;
556 spectatorbutton_zoom = (f & 4);
560 angles_held_status = 1;
561 angles_held_x = ReadAngle();
562 angles_held_y = ReadAngle();
566 angles_held_status = 0;
568 if(newspectatee_status != spectatee_status)
572 race_checkpointtime = 0;
574 if (autocvar_hud_panel_healtharmor_progressbar_gfx)
576 if ( (spectatee_status == -1 && newspectatee_status > 0) //before observing, now spectating
577 || (spectatee_status > 0 && newspectatee_status > 0 && spectatee_status != newspectatee_status) //changed spectated player
580 else if(spectatee_status && !newspectatee_status) //before observing/spectating, now playing
583 spectatee_status = newspectatee_status;
585 // non-COMPAT_XON050_ENGINE: we could get rid of spectatee_status, and derive it from player_localentnum and player_localnum
590 float nags, i, j, b, f;
592 nags = ReadByte(); // NAGS NAGS NAGS NAGS NAGS NAGS NADZ NAGS NAGS NAGS
597 strunzone(vote_called_vote);
598 vote_called_vote = string_null;
608 vote_yescount = ReadByte();
609 vote_nocount = ReadByte();
610 vote_needed = ReadByte();
611 vote_highlighted = ReadChar();
617 strunzone(vote_called_vote);
618 vote_called_vote = strzone(ColorTranslateRGB(ReadString()));
623 for(j = 0; j < maxclients; ++j)
625 playerslots[j].ready = 1;
626 for(i = 1; i <= maxclients; i += 8)
629 for(j = i-1, b = 1; b < 256; b *= 2, ++j)
632 playerslots[j].ready = 0;
636 ready_waiting = (nags & 1);
637 ready_waiting_for_me = (nags & 2);
638 vote_waiting = (nags & 4);
639 vote_waiting_for_me = (nags & 8);
640 warmup_stage = (nags & 16);
643 void Ent_RandomSeed()
651 void Ent_ReadAccuracy(void)
657 for(w = 0; w <= WEP_LAST - WEP_FIRST; ++w)
658 weapon_accuracy[w] = -1;
662 for(w = 0, f = 1; w <= WEP_LAST - WEP_FIRST; ++w, f *= 2)
668 weapon_accuracy[w] = -1;
670 weapon_accuracy[w] = 1.0; // no better error handling yet, sorry
672 weapon_accuracy[w] = (b - 1.0) / 100.0;
677 // CSQC_Ent_Update : Called every frame that the server has indicated an update to the SSQC / CSQC entity has occured.
678 // The only parameter reflects if the entity is "new" to the client, meaning it just came into the client's PVS.
679 void Ent_RadarLink();
681 void Ent_ScoresInfo();
682 void CSQC_Ent_Update(float bIsNewEntity)
688 // set up the "time" global for received entities to be correct for interpolation purposes
696 serverprevtime = time;
697 serverdeltatime = getstatf(STAT_MOVEVARS_TICRATE) * getstatf(STAT_MOVEVARS_TIMESCALE);
698 time = serverprevtime + serverdeltatime;
701 #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
704 if(t != self.enttype || bIsNewEntity)
706 //print(_("A CSQC entity changed its type!\n"));
707 print(sprintf(_("A CSQC entity changed its type! (edict: %d, server: %d, type: %d -> %d)\n"), num_for_edict(self), self.entnum, self.enttype, t));
716 print(sprintf(_("A CSQC entity appeared out of nowhere! (edict: %d, server: %d, type: %d)\n"), num_for_edict(self), self.entnum, t));
724 case ENT_CLIENT_ENTCS: Ent_ReadEntCS(); break;
725 case ENT_CLIENT_SCORES: Ent_ReadPlayerScore(); break;
726 case ENT_CLIENT_TEAMSCORES: Ent_ReadTeamScore(); break;
727 case ENT_CLIENT_POINTPARTICLES: Ent_PointParticles(); break;
728 case ENT_CLIENT_RAINSNOW: Ent_RainOrSnow(); break;
729 case ENT_CLIENT_LASER: Ent_Laser(); break;
730 case ENT_CLIENT_NAGGER: Ent_Nagger(); break;
731 case ENT_CLIENT_WAYPOINT: Ent_WaypointSprite(); break;
732 case ENT_CLIENT_RADARLINK: Ent_RadarLink(); break;
733 case ENT_CLIENT_PROJECTILE: Ent_Projectile(); break;
734 case ENT_CLIENT_GIBSPLASH: Ent_GibSplash(bIsNewEntity); break;
735 case ENT_CLIENT_DAMAGEINFO: Ent_DamageInfo(bIsNewEntity); break;
736 case ENT_CLIENT_CASING: Ent_Casing(bIsNewEntity); break;
737 case ENT_CLIENT_INIT: Ent_Init(); break;
738 case ENT_CLIENT_SCORES_INFO: Ent_ScoresInfo(); break;
739 case ENT_CLIENT_MAPVOTE: Ent_MapVote(); break;
740 case ENT_CLIENT_CLIENTDATA: Ent_ClientData(); break;
741 case ENT_CLIENT_RANDOMSEED: Ent_RandomSeed(); break;
742 case ENT_CLIENT_WALL: Ent_Wall(); break;
743 case ENT_CLIENT_MODELEFFECT: Ent_ModelEffect(bIsNewEntity); break;
744 case ENT_CLIENT_TUBANOTE: Ent_TubaNote(bIsNewEntity); break;
745 case ENT_CLIENT_WARPZONE: WarpZone_Read(bIsNewEntity); break;
746 case ENT_CLIENT_WARPZONE_CAMERA: WarpZone_Camera_Read(bIsNewEntity); break;
747 case ENT_CLIENT_WARPZONE_TELEPORTED: WarpZone_Teleported_Read(bIsNewEntity); break;
748 case ENT_CLIENT_TRIGGER_MUSIC: Ent_ReadTriggerMusic(); break;
749 case ENT_CLIENT_HOOK: Ent_ReadHook(bIsNewEntity, ENT_CLIENT_HOOK); break;
750 case ENT_CLIENT_LGBEAM: Ent_ReadHook(bIsNewEntity, ENT_CLIENT_LGBEAM); break;
751 case ENT_CLIENT_GAUNTLET: Ent_ReadHook(bIsNewEntity, ENT_CLIENT_GAUNTLET); break;
752 case ENT_CLIENT_ACCURACY: Ent_ReadAccuracy(); break;
753 case ENT_CLIENT_AUXILIARYXHAIR: Net_AuXair2(bIsNewEntity); break;
754 case ENT_CLIENT_TURRET: ent_turret(); break;
755 case ENT_CLIENT_MODEL: CSQCModel_Read(bIsNewEntity); break;
757 //error(strcat(_("unknown entity type in CSQC_Ent_Update: %d\n"), self.enttype));
758 error(sprintf(_("Unknown entity type in CSQC_Ent_Update (enttype: %d, edict: %d, classname: %s)\n"), self.enttype, num_for_edict(self), self.classname));
764 // Destructor, but does NOT deallocate the entity by calling remove(). Also
765 // used when an entity changes its type. For an entity that someone interacts
766 // with others, make sure it can no longer do so.
774 self.draw = menu_sub_null;
775 self.entremove = menu_sub_null;
776 // TODO possibly set more stuff to defaults
778 // CSQC_Ent_Remove : Called when the server requests a SSQC / CSQC entity to be removed. Essentially call remove(self) as well.
779 void CSQC_Ent_Remove()
783 print("WARNING: CSQC_Ent_Remove called for already removed entity. Packet loss?\n");
795 if(!(calledhooks & HOOK_START))
796 localcmd("\n_cl_hook_gamestart ", MapInfo_Type_ToString(gametype), "\n");
797 calledhooks |= HOOK_START;
800 // 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.
801 void CSQC_Parse_StuffCmd(string strMessage)
803 localcmd(strMessage);
805 // 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.
806 void CSQC_Parse_Print(string strMessage)
808 print(ColorTranslateRGB(strMessage));
811 // CSQC_Parse_CenterPrint : Provides the centerprint_hud string in the first parameter that the server provided.
812 void CSQC_Parse_CenterPrint(string strMessage)
814 centerprint_hud(strMessage);
817 string notranslate_fogcmd1 = "\nfog ";
818 string notranslate_fogcmd2 = "\nr_fog_exp2 0\nr_drawfog 1\n";
821 // TODO somehow thwart prvm_globalset client ...
824 localcmd(strcat(notranslate_fogcmd1, forcefog, notranslate_fogcmd2));
827 void Gamemode_Init();
828 void Ent_ScoresInfo()
831 self.classname = "ent_client_scores_info";
832 gametype = ReadInt24_t();
833 for(i = 0; i < MAX_SCORE; ++i)
835 scores_label[i] = strzone(ReadString());
836 scores_flags[i] = ReadByte();
838 for(i = 0; i < MAX_TEAMSCORE; ++i)
840 teamscores_label[i] = strzone(ReadString());
841 teamscores_flags[i] = ReadByte();
849 self.classname = "ent_client_init";
851 nb_pb_period = ReadByte() / 32; //Accuracy of 1/32th
853 hook_shotorigin[0] = decompressShotOrigin(ReadInt24_t());
854 hook_shotorigin[1] = decompressShotOrigin(ReadInt24_t());
855 hook_shotorigin[2] = decompressShotOrigin(ReadInt24_t());
856 hook_shotorigin[3] = decompressShotOrigin(ReadInt24_t());
857 electro_shotorigin[0] = decompressShotOrigin(ReadInt24_t());
858 electro_shotorigin[1] = decompressShotOrigin(ReadInt24_t());
859 electro_shotorigin[2] = decompressShotOrigin(ReadInt24_t());
860 electro_shotorigin[3] = decompressShotOrigin(ReadInt24_t());
861 gauntlet_shotorigin[0] = decompressShotOrigin(ReadInt24_t());
862 gauntlet_shotorigin[1] = decompressShotOrigin(ReadInt24_t());
863 gauntlet_shotorigin[2] = decompressShotOrigin(ReadInt24_t());
864 gauntlet_shotorigin[3] = decompressShotOrigin(ReadInt24_t());
868 forcefog = strzone(ReadString());
870 armorblockpercent = ReadByte() / 255.0;
872 g_weaponswitchdelay = ReadByte() / 255.0;
874 g_balance_grenadelauncher_bouncefactor = ReadCoord();
875 g_balance_grenadelauncher_bouncestop = ReadCoord();
876 g_balance_electro_secondary_bouncefactor = ReadCoord();
877 g_balance_electro_secondary_bouncestop = ReadCoord();
879 nex_scope = !ReadByte();
880 rifle_scope = !ReadByte();
882 serverflags = ReadByte();
884 minelayer_maxmines = ReadByte();
886 hagar_maxrockets = ReadByte();
888 g_trueaim_minrange = ReadCoord();
889 g_balance_porto_secondary = ReadByte();
903 case RACE_NET_CHECKPOINT_HIT_QUALIFYING:
904 race_checkpoint = ReadByte();
905 race_time = ReadInt24_t();
906 race_previousbesttime = ReadInt24_t();
907 if(race_previousbestname)
908 strunzone(race_previousbestname);
909 race_previousbestname = strzone(ColorTranslateRGB(ReadString()));
911 race_checkpointtime = time;
913 if(race_checkpoint == 0 || race_checkpoint == 254)
915 race_penaltyaccumulator = 0;
916 race_laptime = time; // valid
921 case RACE_NET_CHECKPOINT_CLEAR:
923 race_checkpointtime = 0;
926 case RACE_NET_CHECKPOINT_NEXT_SPEC_QUALIFYING:
927 race_laptime = ReadCoord();
928 race_checkpointtime = -99999;
930 case RACE_NET_CHECKPOINT_NEXT_QUALIFYING:
931 race_nextcheckpoint = ReadByte();
933 race_nextbesttime = ReadInt24_t();
934 if(race_nextbestname)
935 strunzone(race_nextbestname);
936 race_nextbestname = strzone(ColorTranslateRGB(ReadString()));
939 case RACE_NET_CHECKPOINT_HIT_RACE:
940 race_mycheckpoint = ReadByte();
941 race_mycheckpointtime = time;
942 race_mycheckpointdelta = ReadInt24_t();
943 race_mycheckpointlapsdelta = ReadByte();
944 if(race_mycheckpointlapsdelta >= 128)
945 race_mycheckpointlapsdelta -= 256;
946 if(race_mycheckpointenemy)
947 strunzone(race_mycheckpointenemy);
948 race_mycheckpointenemy = strzone(ColorTranslateRGB(ReadString()));
951 case RACE_NET_CHECKPOINT_HIT_RACE_BY_OPPONENT:
952 race_othercheckpoint = ReadByte();
953 race_othercheckpointtime = time;
954 race_othercheckpointdelta = ReadInt24_t();
955 race_othercheckpointlapsdelta = ReadByte();
956 if(race_othercheckpointlapsdelta >= 128)
957 race_othercheckpointlapsdelta -= 256;
958 if(race_othercheckpointenemy)
959 strunzone(race_othercheckpointenemy);
960 race_othercheckpointenemy = strzone(ColorTranslateRGB(ReadString()));
963 case RACE_NET_PENALTY_RACE:
964 race_penaltyeventtime = time;
965 race_penaltytime = ReadShort();
966 //race_penaltyaccumulator += race_penaltytime;
967 if(race_penaltyreason)
968 strunzone(race_penaltyreason);
969 race_penaltyreason = strzone(ReadString());
972 case RACE_NET_PENALTY_QUALIFYING:
973 race_penaltyeventtime = time;
974 race_penaltytime = ReadShort();
975 race_penaltyaccumulator += race_penaltytime;
976 if(race_penaltyreason)
977 strunzone(race_penaltyreason);
978 race_penaltyreason = strzone(ReadString());
981 case RACE_NET_SERVER_RECORD:
982 race_server_record = ReadInt24_t();
984 case RACE_NET_SPEED_AWARD:
985 race_speedaward = ReadInt24_t();
986 if(race_speedaward_holder)
987 strunzone(race_speedaward_holder);
988 race_speedaward_holder = strzone(ReadString());
990 case RACE_NET_SPEED_AWARD_BEST:
991 race_speedaward_alltimebest = ReadInt24_t();
992 if(race_speedaward_alltimebest_holder)
993 strunzone(race_speedaward_alltimebest_holder);
994 race_speedaward_alltimebest_holder = strzone(ReadString());
996 case RACE_NET_SERVER_RANKINGS:
997 float pos, prevpos, del;
999 prevpos = ReadShort();
1002 // move other rankings out of the way
1005 for (i=prevpos-1;i>pos-1;--i) {
1006 grecordtime[i] = grecordtime[i-1];
1007 if(grecordholder[i])
1008 strunzone(grecordholder[i]);
1009 grecordholder[i] = strzone(grecordholder[i-1]);
1011 } else if (del) { // a record has been deleted by the admin
1012 for (i=pos-1; i<= RANKINGS_CNT-1; ++i) {
1013 if (i == RANKINGS_CNT-1) { // clear out last record
1015 if (grecordholder[i])
1016 strunzone(grecordholder[i]);
1017 grecordholder[i] = string_null;
1020 grecordtime[i] = grecordtime[i+1];
1021 if (grecordholder[i])
1022 strunzone(grecordholder[i]);
1023 grecordholder[i] = strzone(grecordholder[i+1]);
1026 } else { // player has no ranked record yet
1027 for (i=RANKINGS_CNT-1;i>pos-1;--i) {
1028 grecordtime[i] = grecordtime[i-1];
1029 if(grecordholder[i])
1030 strunzone(grecordholder[i]);
1031 grecordholder[i] = strzone(grecordholder[i-1]);
1035 // store new ranking
1036 if(grecordholder[pos-1] != "")
1037 strunzone(grecordholder[pos-1]);
1038 grecordholder[pos-1] = strzone(ReadString());
1039 grecordtime[pos-1] = ReadInt24_t();
1040 if(grecordholder[pos-1] == GetPlayerName(player_localnum))
1043 case RACE_NET_SERVER_STATUS:
1044 race_status = ReadShort();
1045 if(race_status_name)
1046 strunzone(race_status_name);
1047 race_status_name = strzone(ReadString());
1051 void Net_ReadSpawn()
1054 current_viewzoom = 0.6;
1057 void Net_TeamNagger()
1062 void Net_ReadPingPLReport()
1064 float e, pi, pl, ml;
1069 if not(playerslots[e])
1071 playerslots[e].ping = pi;
1072 playerslots[e].ping_packetloss = pl / 255.0;
1073 playerslots[e].ping_movementloss = ml / 255.0;
1076 void Net_WeaponComplain() {
1077 complain_weapon = ReadByte();
1079 if(complain_weapon_name)
1080 strunzone(complain_weapon_name);
1081 complain_weapon_name = strzone(ReadString());
1083 complain_weapon_type = ReadByte();
1085 complain_weapon_time = time;
1086 weapontime = time; // ping the weapon panel
1089 // CSQC_Parse_TempEntity : Handles all temporary entity network data in the CSQC layer.
1090 // You must ALWAYS first acquire the temporary ID, which is sent as a byte.
1091 // Return value should be 1 if CSQC handled the temporary entity, otherwise return 0 to have the engine process the event.
1092 float CSQC_Parse_TempEntity()
1100 // NOTE: Could just do return instead of break...
1103 case TE_CSQC_TARGET_MUSIC:
1107 case TE_CSQC_PICTURE:
1108 Net_MapVote_Picture();
1119 case TE_CSQC_ZCURVEPARTICLES:
1120 Net_ReadZCurveParticles();
1123 case TE_CSQC_NEXGUNBEAMPARTICLE:
1124 Net_ReadNexgunBeamParticle();
1127 case TE_CSQC_TEAMNAGGER:
1131 case TE_CSQC_LIGHTNINGARC:
1132 Net_ReadLightningarc();
1135 case TE_CSQC_PINGPLREPORT:
1136 Net_ReadPingPLReport();
1139 case TE_CSQC_ANNOUNCE:
1140 Announcer_Play(ReadString());
1143 case TE_CSQC_KILLNOTIFY:
1144 HUD_KillNotify(ReadString(), ReadString(), ReadString(), ReadShort(), ReadByte());
1147 case TE_CSQC_KILLCENTERPRINT:
1148 HUD_KillCenterprint(ReadString(), ReadString(), ReadShort(), ReadByte());
1151 case TE_CSQC_CENTERPRINT_GENERIC:
1156 if (id != 0 && s != "")
1157 centerprint_generic(id, s, ReadByte(), ReadByte());
1159 centerprint_generic(id, s, 0, 0);
1162 case TE_CSQC_WEAPONCOMPLAIN:
1163 Net_WeaponComplain();
1166 case TE_CSQC_VEHICLESETUP:
1170 case TE_CSQC_SVNOTICE:
1175 // No special logic for this temporary entity; return 0 so the engine can handle it
1183 string getcommandkey(string text, string command)
1188 if (!autocvar_hud_showbinds)
1191 keys = db_get(binddb, command);
1194 n = tokenize(findkeysforcommand(command, 0)); // uses '...' strings
1195 for(j = 0; j < n; ++j)
1201 keys = keynumtostring(k);
1203 keys = strcat(keys, ", ", keynumtostring(k));
1206 if (autocvar_hud_showbinds_limit > 0 && autocvar_hud_showbinds_limit >= l) break;
1210 db_put(binddb, command, keys);
1214 if (autocvar_hud_showbinds > 1)
1215 return sprintf(_("%s (not bound)"), text);
1219 else if (autocvar_hud_showbinds > 1)
1220 return sprintf(_("%s (%s)"), text, keys);