1 // --------------------------------------------------------------------------
2 // BEGIN REQUIRED CSQC FUNCTIONS
5 #define DP_CSQC_ENTITY_REMOVE_IS_B0RKED
7 void cvar_clientsettemp(string cv, string val)
10 for(e = world; (e = find(e, classname, "saved_cvar_value")); )
14 e.classname = "saved_cvar_value";
15 e.netname = strzone(cv);
16 e.message = strzone(cvar_string(cv));
21 void cvar_clientsettemp_restore()
24 for(e = world; (e = find(e, classname, "saved_cvar_value")); )
25 cvar_set(e.netname, e.message);
28 void() menu_show_error =
30 drawstring('0 200 0', "ERROR - MENU IS VISIBLE BUT NO MENU WAS DEFINED!", '8 8 0', '1 0 0', 1, 0);
33 // CSQC_Init : Called every time the CSQC code is initialized (essentially at map load)
34 // Useful for precaching things
36 void() menu_sub_null =
45 void WaypointSprite_Load();
50 __engine_check = checkextension("DP_SV_WRITEPICTURE");
53 print("^3Your engine build is outdated\n^3This Server uses a newer QC VM. Please update!\n");
54 localcmd("\ndisconnect\n");
60 check_unacceptable_compiler_bugs();
67 ClientProgsDB = db_load("client.db");
68 compressShortVector_init();
72 menu_show = menu_show_error;
73 menu_action = menu_sub_null;
75 for(i = 0; i < 255; ++i)
76 if(getplayerkey(i, "viewentity") == "")
81 // localcmd("alias order \"cmd order $*\""); enable if ctf-command thingy is used
82 //registercmd("ctf_menu");
83 registercmd("ons_map");
84 //registercmd("menu_action");
86 registercmd("+button3");
87 registercmd("-button3");
88 registercmd("+button4");
89 registercmd("-button4");
90 registercmd("+showaccuracy");registercmd("-showaccuracy");
96 registercmd("+forward");registercmd("-forward");
97 registercmd("+back");registercmd("-back");
98 registercmd("+moveup");registercmd("-moveup");
99 registercmd("+movedown");registercmd("-movedown");
100 registercmd("+moveright");registercmd("-moveright");
101 registercmd("+moveleft");registercmd("-moveleft");
102 registercmd("+roll_right");registercmd("-roll_right");
103 registercmd("+roll_left");registercmd("-roll_left");
107 registercvar("sbar_usecsqc", "1");
108 registercvar("sbar_columns", "default", CVAR_SAVE);
112 // sbar_fields uses strunzone on the titles!
113 for(i = 0; i < MAX_SBAR_FIELDS; ++i)
114 sbar_title[i] = strzone("(null)");
120 teams = Sort_Spawn();
121 players = Sort_Spawn();
123 GetTeam(COLOR_SPECTATOR, true); // add specs first
125 cvar_clientsettemp("_supports_weaponpriority", "1");
129 WaypointSprite_Load();
131 Projectile_Precache();
132 GibSplash_Precache();
134 DamageInfo_Precache();
135 Announcer_Precache();
142 registercvar("_cl_userid", "", CVAR_SAVE);
143 uid = cvar_string("_cl_userid");
147 for(i = 0; i < 4; ++i)
148 uid = strcat(uid, substring(ftos(floor(10000 + random() * 10000)), 1, -1));
150 cvar_set("_cl_userid", uid);
151 localcmd(strcat("\ncmd uid ", uid, "\n"));
155 get_mi_min_max_texcoords(1); // try the CLEVER way first
156 minimapname = strcat("gfx/", mi_shortname, "_radar.tga");
157 shortmapname = mi_shortname;
159 if(precache_pic(minimapname) == "")
161 // but maybe we have a non-clever minimap
162 minimapname = strcat("gfx/", mi_shortname, "_mini.tga");
163 if(precache_pic(minimapname) == "")
164 minimapname = ""; // FAIL
166 get_mi_min_max_texcoords(0); // load new texcoords
169 mi_center = (mi_min + mi_max) * 0.5;
170 mi_scale = mi_max - mi_min;
171 minimapname = strzone(minimapname);
174 // CSQC_Shutdown : Called every time the CSQC code is shutdown (changing maps, quitting, etc)
175 void CSQC_Shutdown(void)
188 db_save(ClientProgsDB, "client.db");
189 db_close(ClientProgsDB);
191 cvar_clientsettemp_restore();
194 cvar_set("chase_active",ftos(chase_active_backup));
198 if not(calledhooks & HOOK_START)
199 localcmd("\n_cl_hook_gamestart nop;");
200 if not(calledhooks & HOOK_END)
201 localcmd("\ncl_hook_gameend;");
206 float SetTeam(entity o, float Team)
220 if(GetTeam(Team, false) == NULL)
222 print("trying to switch to unsupported team ", ftos(Team), "\n");
223 Team = COLOR_SPECTATOR;
236 if(GetTeam(Team, false) == NULL)
238 print("trying to switch to unsupported team ", ftos(Team), "\n");
239 Team = COLOR_SPECTATOR;
244 if(Team == -1) // leave
248 //print("(DISCONNECT) leave team ", ftos(o.team), "\n");
249 tm = GetTeam(o.team, false);
259 //print("(CONNECT) enter team ", ftos(o.team), "\n");
261 tm = GetTeam(Team, true);
266 else if(Team != o.team)
268 //print("(CHANGE) leave team ", ftos(o.team), "\n");
269 tm = GetTeam(o.team, false);
272 //print("(CHANGE) enter team ", ftos(o.team), "\n");
273 tm = GetTeam(Team, true);
281 void Playerchecker_Think()
285 for(i = 0; i < maxclients; ++i)
288 if(GetPlayerName(i) == "")
292 //print("playerchecker: KILL KILL KILL\n");
293 // player disconnected
304 //print("playerchecker: SPAWN SPAWN SPAWN\n");
307 playerslots[i] = e = spawn();
310 e.ping_packetloss = 0;
311 e.ping_movementloss = 0;
312 //e.gotscores = 0; // we might already have the scores...
313 SetTeam(e, GetPlayerColor(i)); // will not hurt; later updates come with Sbar_UpdatePlayerTeams
315 Sbar_UpdatePlayerPos(e);
319 self.nextthink = time + 0.2;
326 print(strcat("PostInit\n maxclients = ", ftos(maxclients), "\n"));
327 localcmd(strcat("\nsbar_columns_set ", cvar_string("sbar_columns"), ";\n"));
329 entity playerchecker;
330 playerchecker = spawn();
331 playerchecker.think = Playerchecker_Think;
332 playerchecker.nextthink = time + 0.2;
340 // CSQC_ConsoleCommand : Used to parse commands in the console that have been registered with the "registercmd" function
341 // Return value should be 1 if CSQC handled the command, otherwise return 0 to have the engine handle it.
343 void Cmd_Sbar_SetFields(float);
344 void Cmd_Sbar_Help(float);
345 float CSQC_ConsoleCommand(string strMessage)
349 //argc = tokenize(strMessage);
350 argc = tokenize_console(strMessage);
356 if(strCmd == "+button4") { // zoom
357 // return false, because the message shall be sent to the server anyway (for demos/speccing)
365 } else if(strCmd == "-button4") { // zoom
366 if(ignore_minus_zoom)
373 } else if(strCmd == "+button3") { // secondary
376 } else if(strCmd == "-button3") { // secondary
379 } else if(strCmd == "+showscores") {
380 sb_showscores = true;
382 } else if(strCmd == "-showscores") {
383 sb_showscores = false;
385 } else if(strCmd == "+showaccuracy") {
386 sb_showaccuracy = true;
388 } else if(strCmd == "-showaccuracy") {
389 sb_showaccuracy = false;
394 if(strCmd == "+forward" || strCmd == "-back") {
395 ++camera_direction_x;
397 } else if(strCmd == "-forward" || strCmd == "+back") {
398 --camera_direction_x;
400 } else if(strCmd == "+moveright" || strCmd == "-moveleft") {
401 --camera_direction_y;
403 } else if(strCmd == "-moveright" || strCmd == "+moveleft") {
404 ++camera_direction_y;
406 } else if(strCmd == "+moveup" || strCmd == "-movedown") {
407 ++camera_direction_z;
409 } else if(strCmd == "-moveup" || strCmd == "+movedown") {
410 --camera_direction_z;
412 } else if(strCmd == "+roll_right" || strCmd == "-roll_left") {
415 } else if(strCmd == "+roll_left" || strCmd == "-roll_right") {
424 entity debug_shotorg;
427 self.origin = view_origin + view_forward * self.view_ofs_x + view_right * self.view_ofs_y + view_up * self.view_ofs_z;
428 self.angles = view_angles;
429 self.angles_x = -self.angles_x;
433 void ShotOrg_Draw2D()
435 vector coord2d_topleft, coord2d_topright, coord2d;
439 s = vtos(self.view_ofs);
440 s = substring(s, 1, strlen(s) - 2);
441 if(tokenize_console(s) == 3)
442 s = strcat(argv(0), " ", argv(1), " ", argv(2));
444 coord2d_topleft = project_3d_to_2d(self.origin + view_up * 4 - view_right * 4);
445 coord2d_topright = project_3d_to_2d(self.origin + view_up * 4 + view_right * 4);
447 fs = '1 1 0' * ((coord2d_topright_x - coord2d_topleft_x) / stringwidth(s, FALSE));
449 coord2d = coord2d_topleft;
452 coord2d_x += (coord2d_topright_x - coord2d_topleft_x) * (1 - 8 / fs_x) * 0.5;
457 drawstring(coord2d, s, fs, '1 1 1', 1, 0);
462 debug_shotorg = spawn();
463 debug_shotorg.draw = ShotOrg_Draw;
464 debug_shotorg.draw2d = ShotOrg_Draw2D;
465 debug_shotorg.renderflags = RF_VIEWMODEL;
466 debug_shotorg.effects = EF_FULLBRIGHT;
467 precache_model("models/shotorg_adjuster.md3");
468 setmodel(debug_shotorg, "models/shotorg_adjuster.md3");
469 debug_shotorg.scale = 2;
470 debug_shotorg.view_ofs = '25 8 -8';
473 void GameCommand(string msg)
477 argc = tokenize_console(msg);
479 if(argv(0) == "help" || argc == 0)
481 print("Usage: cl_cmd COMMAND..., where possible commands are:\n");
482 print(" settemp cvar value\n");
484 print(" sbar_columns_set ...\n");
485 print(" sbar_columns_help\n");
486 GameCommand_Generic("help");
490 if(GameCommand_Generic(msg))
495 if(cmd == "mv_download") {
496 Cmd_MapVote_MapDownload(argc);
498 else if(cmd == "settemp") {
499 cvar_clientsettemp(argv(1), argv(2));
501 else if(cmd == "radar") {
502 ons_showmap = !ons_showmap;
504 else if(cmd == "sbar_columns_set") {
505 Cmd_Sbar_SetFields(argc);
507 else if(cmd == "sbar_columns_help") {
511 else if(cmd == "blurtest") {
512 blurtest_time0 = time;
513 blurtest_time1 = time + stof(argv(1));
514 blurtest_radius = stof(argv(2));
515 blurtest_power = stof(argv(3));
518 else if(cmd == "shotorg_move") {
522 debug_shotorg.view_ofs = debug_shotorg.view_ofs + stov(argv(1));
523 localcmd("sv_cmd debug_shotorg \"", vtos(debug_shotorg.view_ofs), "\"\n");
525 else if(cmd == "shotorg_movez") {
529 debug_shotorg.view_ofs = debug_shotorg.view_ofs + stof(argv(1)) * (debug_shotorg.view_ofs * (1 / debug_shotorg.view_ofs_x)); // closer/farther, same xy pos
530 localcmd("sv_cmd debug_shotorg \"", vtos(debug_shotorg.view_ofs), "\"\n");
532 else if(cmd == "shotorg_set") {
536 debug_shotorg.view_ofs = stov(argv(1));
537 localcmd("sv_cmd debug_shotorg \"", vtos(debug_shotorg.view_ofs), "\"\n");
539 else if(cmd == "shotorg_setz") {
543 debug_shotorg.view_ofs = debug_shotorg.view_ofs * (stof(argv(1)) / debug_shotorg.view_ofs_x); // closer/farther, same xy pos
544 localcmd("sv_cmd debug_shotorg \"", vtos(debug_shotorg.view_ofs), "\"\n");
546 else if(cmd == "shotorg_toggle_hide") {
549 debug_shotorg.cnt = !debug_shotorg.cnt;
552 else if(cmd == "shotorg_end") {
555 print(vtos(debug_shotorg.view_ofs), "\n");
556 remove(debug_shotorg);
557 debug_shotorg = world;
559 localcmd("sv_cmd debug_shotorg\n");
561 else if(cmd == "sendcvar") {
562 s = cvar_string(argv(1));
563 if(argv(1) == "cl_weaponpriority")
564 s = W_FixWeaponOrder(W_NumberWeaponOrder(s), 1);
565 else if(substring(argv(1), 0, 17) == "cl_weaponpriority" && strlen(argv(1)) == 18)
566 s = W_FixWeaponOrder(W_NumberWeaponOrder(s), 0);
567 localcmd("cmd sentcvar ", argv(1), " \"", s, "\"\n");
571 print("Invalid command. For a list of supported commands, try cl_cmd help.\n");
577 // CSQC_InputEvent : Used to perform actions based on any key pressed, key released and mouse on the client.
578 // Return value should be 1 if CSQC handled the input, otherwise return 0 to have the input passed to the engine.
579 // All keys are in ascii.
580 // bInputType = 0 is key pressed, 1 is key released, 2 is mouse input.
581 // In the case of keyboard input, nPrimary is the ascii code, and nSecondary is 0.
582 // In the case of mouse input, nPrimary is xdelta, nSecondary is ydelta.
583 float CSQC_InputEvent(float bInputType, float nPrimary, float nSecondary)
585 local float bSkipKey;
589 if(menu_action(bInputType, nPrimary, nSecondary))
594 // END REQUIRED CSQC FUNCTIONS
595 // --------------------------------------------------------------------------
597 // --------------------------------------------------------------------------
598 // BEGIN OPTIONAL CSQC FUNCTIONS
601 InterpolateOrigin_Undo();
603 self.classname = "entcs_receiver";
604 self.sv_entnum = ReadByte() - 1;
605 self.origin_x = ReadShort();
606 self.origin_y = ReadShort();
607 self.origin_z = ReadShort();
608 self.angles_y = ReadByte() * 360.0 / 256;
609 self.origin_z = self.angles_x = self.angles_z = 0;
611 InterpolateOrigin_Note();
616 void Ent_RemovePlayerScore()
622 SetTeam(self.owner, -1);
623 self.owner.gotscores = 0;
624 for(i = 0; i < MAX_SCORE; ++i)
625 self.owner.(scores[i]) = 0; // clear all scores
629 void Ent_ReadPlayerScore()
635 // damnit -.- don't want to go change every single .sv_entnum in sbar.qc AGAIN
636 // (no I've never heard of M-x replace-string, sed, or anything like that)
637 isNew = !self.owner; // workaround for DP bug
640 #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
641 if(!isNew && n != self.sv_entnum)
643 print("A CSQC entity changed its owner!\n");
646 self.enttype = ENT_CLIENT_SCORES;
652 if not(playerslots[self.sv_entnum])
653 playerslots[self.sv_entnum] = spawn();
654 o = self.owner = playerslots[self.sv_entnum];
655 o.sv_entnum = self.sv_entnum;
658 //if not(o.sort_prev)
659 // RegisterPlayer(o);
660 //playerchecker will do this for us later, if it has not already done so
671 for(i = 0, p = 1; i < MAX_SCORE; ++i, p *= 2)
675 o.(scores[i]) = ReadInt24_t();
677 o.(scores[i]) = ReadChar();
681 Sbar_UpdatePlayerPos(o); // if not registered, we cannot do this yet!
683 self.entremove = Ent_RemovePlayerScore;
686 void Ent_ReadTeamScore()
691 self.team = ReadByte();
692 o = self.owner = GetTeam(self.team, true); // these team numbers can always be trusted
695 #if MAX_TEAMSCORE <= 8
703 for(i = 0, p = 1; i < MAX_TEAMSCORE; ++i, p *= 2)
707 o.(teamscores[i]) = ReadInt24_t();
709 o.(teamscores[i]) = ReadChar();
712 Sbar_UpdateTeamPos(o);
719 void Ent_ClientData()
722 float newspectatee_status;
726 sb_showscores_force = (f & 1);
730 newspectatee_status = ReadByte();
731 if(newspectatee_status == player_localentnum)
732 newspectatee_status = -1; // observing
735 newspectatee_status = 0;
737 spectatorbutton_zoom = (f & 4);
741 angles_held_status = 1;
742 angles_held_x = ReadAngle();
743 angles_held_y = ReadAngle();
747 angles_held_status = 0;
749 if(newspectatee_status != spectatee_status)
752 // clear the weapon accuracy stats
753 for(i = WEP_FIRST; i <= WEP_LAST; ++i) {
760 race_checkpointtime = 0;
762 spectatee_status = newspectatee_status;
767 float nags, i, j, b, f;
774 strunzone(vote_called_vote);
775 vote_called_vote = strzone(ColorTranslateRGB(ReadString()));
780 for(j = 0; j < maxclients; ++j)
782 playerslots[j].ready = 1;
783 for(i = 1; i <= maxclients; i += 8)
786 for(j = i-1, b = 1; b < 256; b *= 2, ++j)
789 playerslots[j].ready = 0;
793 ready_waiting = (nags & 1);
794 ready_waiting_for_me = (nags & 2);
795 vote_waiting = (nags & 4);
796 vote_waiting_for_me = (nags & 8);
797 warmup_stage = (nags & 16);
800 void Ent_RandomSeed()
808 // CSQC_Ent_Update : Called every frame that the server has indicated an update to the SSQC / CSQC entity has occured.
809 // The only parameter reflects if the entity is "new" to the client, meaning it just came into the client's PVS.
810 void Ent_RadarLink();
812 void Ent_ScoresInfo();
813 void(float bIsNewEntity) CSQC_Ent_Update =
819 // set up the "time" global for received entities to be correct for interpolation purposes
827 serverprevtime = time;
828 serverdeltatime = getstatf(STAT_MOVEVARS_TICRATE) * getstatf(STAT_MOVEVARS_TIMESCALE);
829 time = serverprevtime + serverdeltatime;
832 #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
834 if(t != self.enttype)
836 print("A CSQC entity changed its type!\n");
844 case ENT_CLIENT_ENTCS: Ent_ReadEntCS(); break;
845 case ENT_CLIENT_SCORES: Ent_ReadPlayerScore(); break;
846 case ENT_CLIENT_TEAMSCORES: Ent_ReadTeamScore(); break;
847 case ENT_CLIENT_POINTPARTICLES: Ent_PointParticles(); break;
848 case ENT_CLIENT_RAINSNOW: Ent_RainOrSnow(); break;
849 case ENT_CLIENT_LASER: Ent_Laser(); break;
850 case ENT_CLIENT_NAGGER: Ent_Nagger(); break;
851 case ENT_CLIENT_WAYPOINT: Ent_WaypointSprite(); break;
852 case ENT_CLIENT_RADARLINK: Ent_RadarLink(); break;
853 case ENT_CLIENT_PROJECTILE: Ent_Projectile(); break;
854 case ENT_CLIENT_GIBSPLASH: Ent_GibSplash(bIsNewEntity); break;
855 case ENT_CLIENT_DAMAGEINFO: Ent_DamageInfo(bIsNewEntity); break;
856 case ENT_CLIENT_CASING: Ent_Casing(bIsNewEntity); break;
857 case ENT_CLIENT_INIT: Ent_Init(); break;
858 case ENT_CLIENT_SCORES_INFO: Ent_ScoresInfo(); break;
859 case ENT_CLIENT_MAPVOTE: Ent_MapVote(); break;
860 case ENT_CLIENT_CLIENTDATA: Ent_ClientData(); break;
861 case ENT_CLIENT_RANDOMSEED: Ent_RandomSeed(); break;
862 case ENT_CLIENT_WALL: Ent_Wall(); break;
863 case ENT_CLIENT_MODELEFFECT: Ent_ModelEffect(bIsNewEntity); break;
864 case ENT_CLIENT_TUBANOTE: Ent_TubaNote(bIsNewEntity); break;
866 error(strcat("unknown entity type in CSQC_Ent_Update: ", ftos(self.enttype), "\n"));
872 // Destructor, but does NOT deallocate the entity by calling remove(). Also
873 // used when an entity changes its type. For an entity that someone interacts
874 // with others, make sure it can no longer do so.
882 self.draw = menu_sub_null;
883 self.entremove = menu_sub_null;
884 // TODO possibly set more stuff to defaults
886 // CSQC_Ent_Remove : Called when the server requests a SSQC / CSQC entity to be removed. Essentially call remove(self) as well.
887 void CSQC_Ent_Remove()
896 if(gametype == GAME_ONSLAUGHT) {
897 print(strcat("Using ", minimapname, " as minimap.\n"));
898 precache_pic("gfx/ons-cp-neutral.tga");
899 precache_pic("gfx/ons-cp-red.tga");
900 precache_pic("gfx/ons-cp-blue.tga");
901 precache_pic("gfx/ons-frame.tga");
902 precache_pic("gfx/ons-frame-team.tga");
903 } else if(gametype == GAME_KEYHUNT) {
904 precache_pic("gfx/sb_key_carrying");
905 precache_pic("gfx/sb_key_carrying_outline");
910 localcmd("\n_cl_hook_gamestart ", GametypeNameFromType(gametype), ";");
911 calledhooks |= HOOK_START;
914 // 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.
915 void CSQC_Parse_StuffCmd(string strMessage)
917 localcmd(strMessage);
919 // 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.
920 void CSQC_Parse_Print(string strMessage)
922 print(ColorTranslateRGB(strMessage));
925 // CSQC_Parse_CenterPrint : Provides the centerprint string in the first parameter that the server provided.
926 void CSQC_Parse_CenterPrint(string strMessage)
928 centerprint(strMessage);
931 string notranslate_fogcmd1 = "\nfog ";
932 string notranslate_fogcmd2 = "\nr_fog_exp2 0\nr_drawfog 1\n";
935 // TODO somehow thwart prvm_globalset client ...
938 localcmd(strcat(notranslate_fogcmd1, forcefog, notranslate_fogcmd2));
941 void Gamemode_Init();
942 void Ent_ScoresInfo()
945 self.classname = "ent_client_scores_info";
946 gametype = ReadByte();
947 for(i = 0; i < MAX_SCORE; ++i)
949 scores_label[i] = strzone(ReadString());
950 scores_flags[i] = ReadByte();
952 for(i = 0; i < MAX_TEAMSCORE; ++i)
954 teamscores_label[i] = strzone(ReadString());
955 teamscores_flags[i] = ReadByte();
964 self.classname = "ent_client_init";
966 nb_pb_period = ReadByte() / 32; //Accuracy of 1/32th
968 for(i = 0; i < 24; ++i)
969 weaponimpulse[i] = ReadByte() - 1;
970 hook_shotorigin_x = ReadCoord();
971 hook_shotorigin_y = ReadCoord();
972 hook_shotorigin_z = ReadCoord();
976 forcefog = strzone(ReadString());
978 armorblockpercent = ReadByte() / 255.0;
980 g_weaponswitchdelay = ReadByte() / 255.0;
994 case RACE_NET_CHECKPOINT_HIT_QUALIFYING:
995 race_checkpoint = ReadByte();
996 race_time = ReadInt24_t();
997 race_previousbesttime = ReadInt24_t();
998 if(race_previousbestname)
999 strunzone(race_previousbestname);
1000 race_previousbestname = strzone(ColorTranslateRGB(ReadString()));
1002 race_checkpointtime = time;
1004 if(race_checkpoint == 0 || race_checkpoint == 254)
1006 race_penaltyaccumulator = 0;
1007 race_laptime = time; // valid
1012 case RACE_NET_CHECKPOINT_CLEAR:
1014 race_checkpointtime = 0;
1017 case RACE_NET_CHECKPOINT_NEXT_SPEC_QUALIFYING:
1018 race_laptime = ReadCoord();
1019 race_checkpointtime = -99999;
1021 case RACE_NET_CHECKPOINT_NEXT_QUALIFYING:
1022 race_nextcheckpoint = ReadByte();
1024 race_nextbesttime = ReadInt24_t();
1025 if(race_nextbestname)
1026 strunzone(race_nextbestname);
1027 race_nextbestname = strzone(ColorTranslateRGB(ReadString()));
1030 case RACE_NET_CHECKPOINT_HIT_RACE:
1031 race_mycheckpoint = ReadByte();
1032 race_mycheckpointtime = time;
1033 race_mycheckpointdelta = ReadInt24_t();
1034 race_mycheckpointlapsdelta = ReadByte();
1035 if(race_mycheckpointlapsdelta >= 128)
1036 race_mycheckpointlapsdelta -= 256;
1037 if(race_mycheckpointenemy)
1038 strunzone(race_mycheckpointenemy);
1039 race_mycheckpointenemy = strzone(ColorTranslateRGB(ReadString()));
1042 case RACE_NET_CHECKPOINT_HIT_RACE_BY_OPPONENT:
1043 race_othercheckpoint = ReadByte();
1044 race_othercheckpointtime = time;
1045 race_othercheckpointdelta = ReadInt24_t();
1046 race_othercheckpointlapsdelta = ReadByte();
1047 if(race_othercheckpointlapsdelta >= 128)
1048 race_othercheckpointlapsdelta -= 256;
1049 if(race_othercheckpointenemy)
1050 strunzone(race_othercheckpointenemy);
1051 race_othercheckpointenemy = strzone(ColorTranslateRGB(ReadString()));
1054 case RACE_NET_PENALTY_RACE:
1055 race_penaltyeventtime = time;
1056 race_penaltytime = ReadShort();
1057 //race_penaltyaccumulator += race_penaltytime;
1058 if(race_penaltyreason)
1059 strunzone(race_penaltyreason);
1060 race_penaltyreason = strzone(ReadString());
1063 case RACE_NET_PENALTY_QUALIFYING:
1064 race_penaltyeventtime = time;
1065 race_penaltytime = ReadShort();
1066 race_penaltyaccumulator += race_penaltytime;
1067 if(race_penaltyreason)
1068 strunzone(race_penaltyreason);
1069 race_penaltyreason = strzone(ReadString());
1072 case RACE_NET_SERVER_RECORD:
1073 race_server_record = ReadInt24_t();
1075 case RACE_NET_SPEED_AWARD:
1076 race_speedaward = ReadShort();
1077 if(race_speedaward_holder)
1078 strunzone(race_speedaward_holder);
1079 race_speedaward_holder = strzone(ReadString());
1081 case RACE_NET_SPEED_AWARD_BEST:
1082 race_speedaward_alltimebest = ReadShort();
1083 if(race_speedaward_alltimebest_holder)
1084 strunzone(race_speedaward_alltimebest_holder);
1085 race_speedaward_alltimebest_holder = strzone(ReadString());
1087 case RACE_NET_SERVER_RANKINGS:
1088 float pos, prevpos, del;
1090 prevpos = ReadShort();
1093 // move other rankings out of the way
1096 for (i=prevpos-1;i>pos-1;--i) {
1097 grecordtime[i] = grecordtime[i-1];
1098 if(grecordholder[i])
1099 strunzone(grecordholder[i]);
1100 grecordholder[i] = strzone(grecordholder[i-1]);
1102 } else if (del) { // a record has been deleted by the admin
1103 for (i=pos-1; i<= RANKINGS_CNT-1; ++i) {
1104 if (i == RANKINGS_CNT-1) { // clear out last record
1106 if (grecordholder[i])
1107 strunzone(grecordholder[i]);
1108 grecordholder[i] = string_null;
1111 grecordtime[i] = grecordtime[i+1];
1112 if (grecordholder[i])
1113 strunzone(grecordholder[i]);
1114 grecordholder[i] = strzone(grecordholder[i+1]);
1117 } else { // player has no ranked record yet
1118 for (i=RANKINGS_CNT-1;i>pos-1;--i) {
1119 grecordtime[i] = grecordtime[i-1];
1120 if(grecordholder[i])
1121 strunzone(grecordholder[i]);
1122 grecordholder[i] = strzone(grecordholder[i-1]);
1126 // store new ranking
1127 if(grecordholder[pos-1] != "")
1128 strunzone(grecordholder[pos-1]);
1129 grecordholder[pos-1] = strzone(ReadString());
1130 grecordtime[pos-1] = ReadInt24_t();
1132 myrank_old = race_CheckName(GetPlayerName(player_localentnum -1));
1137 case RACE_NET_SERVER_STATUS:
1138 race_status = ReadShort();
1139 if(race_status_name)
1140 strunzone(race_status_name);
1141 race_status_name = strzone(ReadString());
1145 void Net_ReadSpawn()
1148 current_viewzoom = 0.6;
1151 void Net_TeamNagger()
1156 void Net_ReadPingPLReport()
1158 float e, pi, pl, ml;
1163 if not(playerslots[e])
1165 playerslots[e].ping = pi;
1166 playerslots[e].ping_packetloss = pl / 255.0;
1167 playerslots[e].ping_movementloss = ml / 255.0;
1170 // CSQC_Parse_TempEntity : Handles all temporary entity network data in the CSQC layer.
1171 // You must ALWAYS first acquire the temporary ID, which is sent as a byte.
1172 // Return value should be 1 if CSQC handled the temporary entity, otherwise return 0 to have the engine process the event.
1173 float CSQC_Parse_TempEntity()
1175 local float bHandled;
1181 // NOTE: Could just do return instead of break...
1184 case TE_CSQC_PICTURE:
1185 Net_MapVote_Picture();
1193 Net_GrapplingHook();
1200 case TE_CSQC_ZCURVEPARTICLES:
1201 Net_ReadZCurveParticles();
1204 case TE_CSQC_NEXGUNBEAMPARTICLE:
1205 Net_ReadNexgunBeamParticle();
1208 case TE_CSQC_TEAMNAGGER:
1212 case TE_CSQC_LIGHTNINGARC:
1213 Net_ReadLightningarc();
1216 case TE_CSQC_PINGPLREPORT:
1217 Net_ReadPingPLReport();
1221 // No special logic for this temporary entity; return 0 so the engine can handle it
1229 string getcommandkey(string text, string command)
1234 if (!sbar_showbinds)
1237 keys = db_get(binddb, command);
1240 n = tokenize(findkeysforcommand(command)); // uses '...' strings
1241 for(j = 0; j < n; ++j)
1247 keys = keynumtostring(k);
1249 keys = strcat(keys, ", ", keynumtostring(k));
1252 if (sbar_showbinds_limit > 0 && sbar_showbinds_limit >= l) break;
1256 db_put(binddb, command, keys);
1260 if (sbar_showbinds > 1)
1261 return strcat(text, " (not bound)");
1265 else if (sbar_showbinds > 1)
1266 return strcat(text, " (", keys, ")");