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 string cl_announcer_prev;
46 void WaypointSprite_Load();
51 __engine_check = checkextension("DP_SV_WRITEPICTURE");
54 print("^3Your engine build is outdated\n^3This Server uses a newer QC VM. Please update!\n");
55 localcmd("\ndisconnect\n");
61 check_unacceptable_compiler_bugs();
68 ClientProgsDB = db_load("client.db");
69 compressShortVector_init();
73 menu_show = menu_show_error;
74 menu_action = menu_sub_null;
76 for(i = 0; i < 255; ++i)
77 if(getplayerkey(i, "viewentity") == "")
82 // localcmd("alias order \"cmd order $*\""); enable if ctf-command thingy is used
83 //registercmd("ctf_menu");
84 registercmd("ons_map");
85 //registercmd("menu_action");
87 registercmd("+button3");
88 registercmd("-button3");
89 registercmd("+button4");
90 registercmd("-button4");
91 registercmd("+showaccuracy");registercmd("-showaccuracy");
97 registercmd("+forward");registercmd("-forward");
98 registercmd("+back");registercmd("-back");
99 registercmd("+moveup");registercmd("-moveup");
100 registercmd("+movedown");registercmd("-movedown");
101 registercmd("+moveright");registercmd("-moveright");
102 registercmd("+moveleft");registercmd("-moveleft");
103 registercmd("+roll_right");registercmd("-roll_right");
104 registercmd("+roll_left");registercmd("-roll_left");
108 registercvar("sbar_usecsqc", "1");
109 registercvar("sbar_columns", "default", CVAR_SAVE);
113 // sbar_fields uses strunzone on the titles!
114 for(i = 0; i < MAX_SBAR_FIELDS; ++i)
115 sbar_title[i] = strzone("(null)");
121 teams = Sort_Spawn();
122 players = Sort_Spawn();
124 GetTeam(COLOR_SPECTATOR, true); // add specs first
126 cvar_clientsettemp("_supports_weaponpriority", "1");
130 WaypointSprite_Load();
133 Projectile_Precache();
134 GibSplash_Precache();
136 DamageInfo_Precache();
137 if(cvar_string("cl_announcer") != cl_announcer_prev) {
138 Announcer_Precache();
139 if(cl_announcer_prev)
140 strunzone(cl_announcer_prev);
141 cl_announcer_prev = strzone(cvar_string("cl_announcer"));
149 registercvar("_cl_userid", "", CVAR_SAVE);
150 uid = cvar_string("_cl_userid");
154 for(i = 0; i < 4; ++i)
155 uid = strcat(uid, substring(ftos(floor(10000 + random() * 10000)), 1, -1));
157 cvar_set("_cl_userid", uid);
158 localcmd(strcat("\ncmd uid ", uid, "\n"));
162 get_mi_min_max_texcoords(1); // try the CLEVER way first
163 minimapname = strcat("gfx/", mi_shortname, "_radar.tga");
164 shortmapname = mi_shortname;
166 if(precache_pic(minimapname) == "")
168 // but maybe we have a non-clever minimap
169 minimapname = strcat("gfx/", mi_shortname, "_mini.tga");
170 if(precache_pic(minimapname) == "")
171 minimapname = ""; // FAIL
173 get_mi_min_max_texcoords(0); // load new texcoords
176 mi_center = (mi_min + mi_max) * 0.5;
177 mi_scale = mi_max - mi_min;
178 minimapname = strzone(minimapname);
181 // CSQC_Shutdown : Called every time the CSQC code is shutdown (changing maps, quitting, etc)
182 void CSQC_Shutdown(void)
195 db_save(ClientProgsDB, "client.db");
196 db_close(ClientProgsDB);
198 cvar_clientsettemp_restore();
201 cvar_set("chase_active",ftos(chase_active_backup));
205 if not(calledhooks & HOOK_START)
206 localcmd("\n_cl_hook_gamestart nop;");
207 if not(calledhooks & HOOK_END)
208 localcmd("\ncl_hook_gameend;");
213 float SetTeam(entity o, float Team)
227 if(GetTeam(Team, false) == NULL)
229 print("trying to switch to unsupported team ", ftos(Team), "\n");
230 Team = COLOR_SPECTATOR;
243 if(GetTeam(Team, false) == NULL)
245 print("trying to switch to unsupported team ", ftos(Team), "\n");
246 Team = COLOR_SPECTATOR;
251 if(Team == -1) // leave
255 //print("(DISCONNECT) leave team ", ftos(o.team), "\n");
256 tm = GetTeam(o.team, false);
266 //print("(CONNECT) enter team ", ftos(o.team), "\n");
268 tm = GetTeam(Team, true);
273 else if(Team != o.team)
275 //print("(CHANGE) leave team ", ftos(o.team), "\n");
276 tm = GetTeam(o.team, false);
279 //print("(CHANGE) enter team ", ftos(o.team), "\n");
280 tm = GetTeam(Team, true);
288 void Playerchecker_Think()
292 for(i = 0; i < maxclients; ++i)
295 if(GetPlayerName(i) == "")
299 //print("playerchecker: KILL KILL KILL\n");
300 // player disconnected
311 //print("playerchecker: SPAWN SPAWN SPAWN\n");
314 playerslots[i] = e = spawn();
317 e.ping_packetloss = 0;
318 e.ping_movementloss = 0;
319 //e.gotscores = 0; // we might already have the scores...
320 SetTeam(e, GetPlayerColor(i)); // will not hurt; later updates come with Sbar_UpdatePlayerTeams
322 Sbar_UpdatePlayerPos(e);
326 self.nextthink = time + 0.2;
333 print(strcat("PostInit\n maxclients = ", ftos(maxclients), "\n"));
334 localcmd(strcat("\nsbar_columns_set ", cvar_string("sbar_columns"), ";\n"));
336 entity playerchecker;
337 playerchecker = spawn();
338 playerchecker.think = Playerchecker_Think;
339 playerchecker.nextthink = time + 0.2;
347 // CSQC_ConsoleCommand : Used to parse commands in the console that have been registered with the "registercmd" function
348 // Return value should be 1 if CSQC handled the command, otherwise return 0 to have the engine handle it.
350 void Cmd_Sbar_SetFields(float);
351 void Cmd_Sbar_Help(float);
352 float CSQC_ConsoleCommand(string strMessage)
356 //argc = tokenize(strMessage);
357 argc = tokenize_console(strMessage);
363 if(strCmd == "+button4") { // zoom
364 // return false, because the message shall be sent to the server anyway (for demos/speccing)
372 } else if(strCmd == "-button4") { // zoom
373 if(ignore_minus_zoom)
380 } else if(strCmd == "+button3") { // secondary
383 } else if(strCmd == "-button3") { // secondary
386 } else if(strCmd == "+showscores") {
387 sb_showscores = true;
389 } else if(strCmd == "-showscores") {
390 sb_showscores = false;
392 } else if(strCmd == "+showaccuracy") {
393 sb_showaccuracy = true;
395 } else if(strCmd == "-showaccuracy") {
396 sb_showaccuracy = false;
401 if(strCmd == "+forward" || strCmd == "-back") {
402 ++camera_direction_x;
404 } else if(strCmd == "-forward" || strCmd == "+back") {
405 --camera_direction_x;
407 } else if(strCmd == "+moveright" || strCmd == "-moveleft") {
408 --camera_direction_y;
410 } else if(strCmd == "-moveright" || strCmd == "+moveleft") {
411 ++camera_direction_y;
413 } else if(strCmd == "+moveup" || strCmd == "-movedown") {
414 ++camera_direction_z;
416 } else if(strCmd == "-moveup" || strCmd == "+movedown") {
417 --camera_direction_z;
419 } else if(strCmd == "+roll_right" || strCmd == "-roll_left") {
422 } else if(strCmd == "+roll_left" || strCmd == "-roll_right") {
431 entity debug_shotorg;
434 self.origin = view_origin + view_forward * self.view_ofs_x + view_right * self.view_ofs_y + view_up * self.view_ofs_z;
435 self.angles = view_angles;
436 self.angles_x = -self.angles_x;
440 void ShotOrg_Draw2D()
442 vector coord2d_topleft, coord2d_topright, coord2d;
446 s = vtos(self.view_ofs);
447 s = substring(s, 1, strlen(s) - 2);
448 if(tokenize_console(s) == 3)
449 s = strcat(argv(0), " ", argv(1), " ", argv(2));
451 coord2d_topleft = project_3d_to_2d(self.origin + view_up * 4 - view_right * 4);
452 coord2d_topright = project_3d_to_2d(self.origin + view_up * 4 + view_right * 4);
454 fs = '1 1 0' * ((coord2d_topright_x - coord2d_topleft_x) / stringwidth(s, FALSE, '8 8 0'));
456 coord2d = coord2d_topleft;
459 coord2d_x += (coord2d_topright_x - coord2d_topleft_x) * (1 - 8 / fs_x) * 0.5;
464 drawstring(coord2d, s, fs, '1 1 1', 1, 0);
469 debug_shotorg = spawn();
470 debug_shotorg.draw = ShotOrg_Draw;
471 debug_shotorg.draw2d = ShotOrg_Draw2D;
472 debug_shotorg.renderflags = RF_VIEWMODEL;
473 debug_shotorg.effects = EF_FULLBRIGHT;
474 precache_model("models/shotorg_adjuster.md3");
475 setmodel(debug_shotorg, "models/shotorg_adjuster.md3");
476 debug_shotorg.scale = 2;
477 debug_shotorg.view_ofs = '25 8 -8';
480 void DrawDebugModel()
482 if(time - floor(time) > 0.5)
488 self.renderflags = 0;
493 void GameCommand(string msg)
498 argc = tokenize_console(msg);
500 if(argv(0) == "help" || argc == 0)
502 print("Usage: cl_cmd COMMAND..., where possible commands are:\n");
503 print(" settemp cvar value\n");
505 print(" sbar_columns_set ...\n");
506 print(" sbar_columns_help\n");
507 GameCommand_Generic("help");
511 if(GameCommand_Generic(msg))
516 if(cmd == "mv_download") {
517 Cmd_MapVote_MapDownload(argc);
519 else if(cmd == "settemp") {
520 cvar_clientsettemp(argv(1), argv(2));
522 else if(cmd == "radar") {
523 ons_showmap = !ons_showmap;
525 else if(cmd == "sbar_columns_set") {
526 Cmd_Sbar_SetFields(argc);
528 else if(cmd == "sbar_columns_help") {
532 else if(cmd == "blurtest") {
533 blurtest_time0 = time;
534 blurtest_time1 = time + stof(argv(1));
535 blurtest_radius = stof(argv(2));
536 blurtest_power = stof(argv(3));
539 else if(cmd == "shotorg_move") {
543 debug_shotorg.view_ofs = debug_shotorg.view_ofs + stov(argv(1));
544 localcmd("sv_cmd debug_shotorg \"", vtos(debug_shotorg.view_ofs), "\"\n");
546 else if(cmd == "shotorg_movez") {
550 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
551 localcmd("sv_cmd debug_shotorg \"", vtos(debug_shotorg.view_ofs), "\"\n");
553 else if(cmd == "shotorg_set") {
557 debug_shotorg.view_ofs = stov(argv(1));
558 localcmd("sv_cmd debug_shotorg \"", vtos(debug_shotorg.view_ofs), "\"\n");
560 else if(cmd == "shotorg_setz") {
564 debug_shotorg.view_ofs = debug_shotorg.view_ofs * (stof(argv(1)) / debug_shotorg.view_ofs_x); // closer/farther, same xy pos
565 localcmd("sv_cmd debug_shotorg \"", vtos(debug_shotorg.view_ofs), "\"\n");
567 else if(cmd == "shotorg_toggle_hide") {
570 debug_shotorg.cnt = !debug_shotorg.cnt;
573 else if(cmd == "shotorg_end") {
576 print(vtos(debug_shotorg.view_ofs), "\n");
577 remove(debug_shotorg);
578 debug_shotorg = world;
580 localcmd("sv_cmd debug_shotorg\n");
582 else if(cmd == "sendcvar") {
583 s = cvar_string(argv(1));
584 if(argv(1) == "cl_weaponpriority")
585 s = W_FixWeaponOrder(W_NumberWeaponOrder(s), 1);
586 else if(substring(argv(1), 0, 17) == "cl_weaponpriority" && strlen(argv(1)) == 18)
587 s = W_FixWeaponOrder(W_NumberWeaponOrder(s), 0);
588 localcmd("cmd sentcvar ", argv(1), " \"", s, "\"\n");
590 else if(cmd == "spawn") {
595 setorigin(e, view_origin);
596 e.angles = view_angles;
597 e.draw = DrawDebugModel;
598 e.classname = "debugmodel";
602 print("Invalid command. For a list of supported commands, try cl_cmd help.\n");
608 // CSQC_InputEvent : Used to perform actions based on any key pressed, key released and mouse on the client.
609 // Return value should be 1 if CSQC handled the input, otherwise return 0 to have the input passed to the engine.
610 // All keys are in ascii.
611 // bInputType = 0 is key pressed, 1 is key released, 2 is mouse input.
612 // In the case of keyboard input, nPrimary is the ascii code, and nSecondary is 0.
613 // In the case of mouse input, nPrimary is xdelta, nSecondary is ydelta.
614 float CSQC_InputEvent(float bInputType, float nPrimary, float nSecondary)
616 local float bSkipKey;
620 if(menu_action(bInputType, nPrimary, nSecondary))
625 // END REQUIRED CSQC FUNCTIONS
626 // --------------------------------------------------------------------------
628 // --------------------------------------------------------------------------
629 // BEGIN OPTIONAL CSQC FUNCTIONS
632 InterpolateOrigin_Undo();
634 self.classname = "entcs_receiver";
635 self.sv_entnum = ReadByte() - 1;
636 self.origin_x = ReadShort();
637 self.origin_y = ReadShort();
638 self.origin_z = ReadShort();
639 self.angles_y = ReadByte() * 360.0 / 256;
640 self.origin_z = self.angles_x = self.angles_z = 0;
642 InterpolateOrigin_Note();
647 void Ent_RemovePlayerScore()
653 SetTeam(self.owner, -1);
654 self.owner.gotscores = 0;
655 for(i = 0; i < MAX_SCORE; ++i)
656 self.owner.(scores[i]) = 0; // clear all scores
660 void Ent_ReadPlayerScore()
666 // damnit -.- don't want to go change every single .sv_entnum in sbar.qc AGAIN
667 // (no I've never heard of M-x replace-string, sed, or anything like that)
668 isNew = !self.owner; // workaround for DP bug
671 #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
672 if(!isNew && n != self.sv_entnum)
674 print("A CSQC entity changed its owner!\n");
677 self.enttype = ENT_CLIENT_SCORES;
683 if not(playerslots[self.sv_entnum])
684 playerslots[self.sv_entnum] = spawn();
685 o = self.owner = playerslots[self.sv_entnum];
686 o.sv_entnum = self.sv_entnum;
689 //if not(o.sort_prev)
690 // RegisterPlayer(o);
691 //playerchecker will do this for us later, if it has not already done so
702 for(i = 0, p = 1; i < MAX_SCORE; ++i, p *= 2)
706 o.(scores[i]) = ReadInt24_t();
708 o.(scores[i]) = ReadChar();
712 Sbar_UpdatePlayerPos(o); // if not registered, we cannot do this yet!
714 self.entremove = Ent_RemovePlayerScore;
717 void Ent_ReadTeamScore()
722 self.team = ReadByte();
723 o = self.owner = GetTeam(self.team, true); // these team numbers can always be trusted
726 #if MAX_TEAMSCORE <= 8
734 for(i = 0, p = 1; i < MAX_TEAMSCORE; ++i, p *= 2)
738 o.(teamscores[i]) = ReadInt24_t();
740 o.(teamscores[i]) = ReadChar();
743 Sbar_UpdateTeamPos(o);
750 void Ent_ClientData()
753 float newspectatee_status;
757 sb_showscores_force = (f & 1);
761 newspectatee_status = ReadByte();
762 if(newspectatee_status == player_localentnum)
763 newspectatee_status = -1; // observing
766 newspectatee_status = 0;
768 spectatorbutton_zoom = (f & 4);
772 angles_held_status = 1;
773 angles_held_x = ReadAngle();
774 angles_held_y = ReadAngle();
778 angles_held_status = 0;
780 if(newspectatee_status != spectatee_status)
783 // clear the weapon accuracy stats
784 for(i = WEP_FIRST; i <= WEP_LAST; ++i) {
791 race_checkpointtime = 0;
793 spectatee_status = newspectatee_status;
798 float nags, i, j, b, f;
805 strunzone(vote_called_vote);
806 vote_called_vote = strzone(ColorTranslateRGB(ReadString()));
811 for(j = 0; j < maxclients; ++j)
813 playerslots[j].ready = 1;
814 for(i = 1; i <= maxclients; i += 8)
817 for(j = i-1, b = 1; b < 256; b *= 2, ++j)
820 playerslots[j].ready = 0;
824 ready_waiting = (nags & 1);
825 ready_waiting_for_me = (nags & 2);
826 vote_waiting = (nags & 4);
827 vote_waiting_for_me = (nags & 8);
828 warmup_stage = (nags & 16);
831 void Ent_RandomSeed()
839 // CSQC_Ent_Update : Called every frame that the server has indicated an update to the SSQC / CSQC entity has occured.
840 // The only parameter reflects if the entity is "new" to the client, meaning it just came into the client's PVS.
841 void Ent_RadarLink();
843 void Ent_ScoresInfo();
844 void(float bIsNewEntity) CSQC_Ent_Update =
850 // set up the "time" global for received entities to be correct for interpolation purposes
858 serverprevtime = time;
859 serverdeltatime = getstatf(STAT_MOVEVARS_TICRATE) * getstatf(STAT_MOVEVARS_TIMESCALE);
860 time = serverprevtime + serverdeltatime;
863 #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
865 if(t != self.enttype)
867 print("A CSQC entity changed its type!\n");
875 case ENT_CLIENT_ENTCS: Ent_ReadEntCS(); break;
876 case ENT_CLIENT_SCORES: Ent_ReadPlayerScore(); break;
877 case ENT_CLIENT_TEAMSCORES: Ent_ReadTeamScore(); break;
878 case ENT_CLIENT_POINTPARTICLES: Ent_PointParticles(); break;
879 case ENT_CLIENT_RAINSNOW: Ent_RainOrSnow(); break;
880 case ENT_CLIENT_LASER: Ent_Laser(); break;
881 case ENT_CLIENT_NAGGER: Ent_Nagger(); break;
882 case ENT_CLIENT_WAYPOINT: Ent_WaypointSprite(); break;
883 case ENT_CLIENT_RADARLINK: Ent_RadarLink(); break;
884 case ENT_CLIENT_PROJECTILE: Ent_Projectile(); break;
885 case ENT_CLIENT_GIBSPLASH: Ent_GibSplash(bIsNewEntity); break;
886 case ENT_CLIENT_DAMAGEINFO: Ent_DamageInfo(bIsNewEntity); break;
887 case ENT_CLIENT_CASING: Ent_Casing(bIsNewEntity); break;
888 case ENT_CLIENT_INIT: Ent_Init(); break;
889 case ENT_CLIENT_SCORES_INFO: Ent_ScoresInfo(); break;
890 case ENT_CLIENT_MAPVOTE: Ent_MapVote(); break;
891 case ENT_CLIENT_CLIENTDATA: Ent_ClientData(); break;
892 case ENT_CLIENT_RANDOMSEED: Ent_RandomSeed(); break;
893 case ENT_CLIENT_WALL: Ent_Wall(); break;
894 case ENT_CLIENT_MODELEFFECT: Ent_ModelEffect(bIsNewEntity); break;
895 case ENT_CLIENT_TUBANOTE: Ent_TubaNote(bIsNewEntity); break;
897 error(strcat("unknown entity type in CSQC_Ent_Update: ", ftos(self.enttype), "\n"));
903 // Destructor, but does NOT deallocate the entity by calling remove(). Also
904 // used when an entity changes its type. For an entity that someone interacts
905 // with others, make sure it can no longer do so.
913 self.draw = menu_sub_null;
914 self.entremove = menu_sub_null;
915 // TODO possibly set more stuff to defaults
917 // CSQC_Ent_Remove : Called when the server requests a SSQC / CSQC entity to be removed. Essentially call remove(self) as well.
918 void CSQC_Ent_Remove()
927 if(gametype == GAME_ONSLAUGHT) {
928 print(strcat("Using ", minimapname, " as minimap.\n"));
929 precache_pic("gfx/ons-cp-neutral.tga");
930 precache_pic("gfx/ons-cp-red.tga");
931 precache_pic("gfx/ons-cp-blue.tga");
932 precache_pic("gfx/ons-frame.tga");
933 precache_pic("gfx/ons-frame-team.tga");
934 } else if(gametype == GAME_KEYHUNT) {
935 precache_pic("gfx/sb_key_carrying");
936 precache_pic("gfx/sb_key_carrying_outline");
941 localcmd("\n_cl_hook_gamestart ", GametypeNameFromType(gametype), ";");
942 calledhooks |= HOOK_START;
945 // 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.
946 void CSQC_Parse_StuffCmd(string strMessage)
948 localcmd(strMessage);
950 // 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.
951 void CSQC_Parse_Print(string strMessage)
953 print(ColorTranslateRGB(strMessage));
956 // CSQC_Parse_CenterPrint : Provides the centerprint string in the first parameter that the server provided.
957 void CSQC_Parse_CenterPrint(string strMessage)
959 centerprint(strMessage);
962 string notranslate_fogcmd1 = "\nfog ";
963 string notranslate_fogcmd2 = "\nr_fog_exp2 0\nr_drawfog 1\n";
966 // TODO somehow thwart prvm_globalset client ...
969 localcmd(strcat(notranslate_fogcmd1, forcefog, notranslate_fogcmd2));
972 void Gamemode_Init();
973 void Ent_ScoresInfo()
976 self.classname = "ent_client_scores_info";
977 gametype = ReadByte();
978 for(i = 0; i < MAX_SCORE; ++i)
980 scores_label[i] = strzone(ReadString());
981 scores_flags[i] = ReadByte();
983 for(i = 0; i < MAX_TEAMSCORE; ++i)
985 teamscores_label[i] = strzone(ReadString());
986 teamscores_flags[i] = ReadByte();
994 self.classname = "ent_client_init";
996 nb_pb_period = ReadByte() / 32; //Accuracy of 1/32th
998 hook_shotorigin_x = ReadCoord();
999 hook_shotorigin_y = ReadCoord();
1000 hook_shotorigin_z = ReadCoord();
1003 strunzone(forcefog);
1004 forcefog = strzone(ReadString());
1006 armorblockpercent = ReadByte() / 255.0;
1008 g_weaponswitchdelay = ReadByte() / 255.0;
1022 case RACE_NET_CHECKPOINT_HIT_QUALIFYING:
1023 race_checkpoint = ReadByte();
1024 race_time = ReadInt24_t();
1025 race_previousbesttime = ReadInt24_t();
1026 if(race_previousbestname)
1027 strunzone(race_previousbestname);
1028 race_previousbestname = strzone(ColorTranslateRGB(ReadString()));
1030 race_checkpointtime = time;
1032 if(race_checkpoint == 0 || race_checkpoint == 254)
1034 race_penaltyaccumulator = 0;
1035 race_laptime = time; // valid
1040 case RACE_NET_CHECKPOINT_CLEAR:
1042 race_checkpointtime = 0;
1045 case RACE_NET_CHECKPOINT_NEXT_SPEC_QUALIFYING:
1046 race_laptime = ReadCoord();
1047 race_checkpointtime = -99999;
1049 case RACE_NET_CHECKPOINT_NEXT_QUALIFYING:
1050 race_nextcheckpoint = ReadByte();
1052 race_nextbesttime = ReadInt24_t();
1053 if(race_nextbestname)
1054 strunzone(race_nextbestname);
1055 race_nextbestname = strzone(ColorTranslateRGB(ReadString()));
1058 case RACE_NET_CHECKPOINT_HIT_RACE:
1059 race_mycheckpoint = ReadByte();
1060 race_mycheckpointtime = time;
1061 race_mycheckpointdelta = ReadInt24_t();
1062 race_mycheckpointlapsdelta = ReadByte();
1063 if(race_mycheckpointlapsdelta >= 128)
1064 race_mycheckpointlapsdelta -= 256;
1065 if(race_mycheckpointenemy)
1066 strunzone(race_mycheckpointenemy);
1067 race_mycheckpointenemy = strzone(ColorTranslateRGB(ReadString()));
1070 case RACE_NET_CHECKPOINT_HIT_RACE_BY_OPPONENT:
1071 race_othercheckpoint = ReadByte();
1072 race_othercheckpointtime = time;
1073 race_othercheckpointdelta = ReadInt24_t();
1074 race_othercheckpointlapsdelta = ReadByte();
1075 if(race_othercheckpointlapsdelta >= 128)
1076 race_othercheckpointlapsdelta -= 256;
1077 if(race_othercheckpointenemy)
1078 strunzone(race_othercheckpointenemy);
1079 race_othercheckpointenemy = strzone(ColorTranslateRGB(ReadString()));
1082 case RACE_NET_PENALTY_RACE:
1083 race_penaltyeventtime = time;
1084 race_penaltytime = ReadShort();
1085 //race_penaltyaccumulator += race_penaltytime;
1086 if(race_penaltyreason)
1087 strunzone(race_penaltyreason);
1088 race_penaltyreason = strzone(ReadString());
1091 case RACE_NET_PENALTY_QUALIFYING:
1092 race_penaltyeventtime = time;
1093 race_penaltytime = ReadShort();
1094 race_penaltyaccumulator += race_penaltytime;
1095 if(race_penaltyreason)
1096 strunzone(race_penaltyreason);
1097 race_penaltyreason = strzone(ReadString());
1100 case RACE_NET_SERVER_RECORD:
1101 race_server_record = ReadInt24_t();
1103 case RACE_NET_SPEED_AWARD:
1104 race_speedaward = ReadInt24_t();
1105 if(race_speedaward_holder)
1106 strunzone(race_speedaward_holder);
1107 race_speedaward_holder = strzone(ReadString());
1109 case RACE_NET_SPEED_AWARD_BEST:
1110 race_speedaward_alltimebest = ReadInt24_t();
1111 if(race_speedaward_alltimebest_holder)
1112 strunzone(race_speedaward_alltimebest_holder);
1113 race_speedaward_alltimebest_holder = strzone(ReadString());
1115 case RACE_NET_SERVER_RANKINGS:
1116 float pos, prevpos, del;
1118 prevpos = ReadShort();
1121 // move other rankings out of the way
1124 for (i=prevpos-1;i>pos-1;--i) {
1125 grecordtime[i] = grecordtime[i-1];
1126 if(grecordholder[i])
1127 strunzone(grecordholder[i]);
1128 grecordholder[i] = strzone(grecordholder[i-1]);
1130 } else if (del) { // a record has been deleted by the admin
1131 for (i=pos-1; i<= RANKINGS_CNT-1; ++i) {
1132 if (i == RANKINGS_CNT-1) { // clear out last record
1134 if (grecordholder[i])
1135 strunzone(grecordholder[i]);
1136 grecordholder[i] = string_null;
1139 grecordtime[i] = grecordtime[i+1];
1140 if (grecordholder[i])
1141 strunzone(grecordholder[i]);
1142 grecordholder[i] = strzone(grecordholder[i+1]);
1145 } else { // player has no ranked record yet
1146 for (i=RANKINGS_CNT-1;i>pos-1;--i) {
1147 grecordtime[i] = grecordtime[i-1];
1148 if(grecordholder[i])
1149 strunzone(grecordholder[i]);
1150 grecordholder[i] = strzone(grecordholder[i-1]);
1154 // store new ranking
1155 if(grecordholder[pos-1] != "")
1156 strunzone(grecordholder[pos-1]);
1157 grecordholder[pos-1] = strzone(ReadString());
1158 grecordtime[pos-1] = ReadInt24_t();
1159 if(grecordholder[pos-1] == GetPlayerName(player_localentnum -1))
1162 case RACE_NET_SERVER_STATUS:
1163 race_status = ReadShort();
1164 if(race_status_name)
1165 strunzone(race_status_name);
1166 race_status_name = strzone(ReadString());
1170 void Net_ReadSpawn()
1173 current_viewzoom = 0.6;
1176 void Net_TeamNagger()
1181 void Net_ReadPingPLReport()
1183 float e, pi, pl, ml;
1188 if not(playerslots[e])
1190 playerslots[e].ping = pi;
1191 playerslots[e].ping_packetloss = pl / 255.0;
1192 playerslots[e].ping_movementloss = ml / 255.0;
1195 void Net_VoteDialog(float highlight) {
1197 vote_highlighted = ReadShort();
1201 vote_yescount = ReadShort();
1202 vote_nocount = ReadShort();
1203 vote_needed = ReadShort();
1207 void Net_VoteDialogReset() {
1211 // CSQC_Parse_TempEntity : Handles all temporary entity network data in the CSQC layer.
1212 // You must ALWAYS first acquire the temporary ID, which is sent as a byte.
1213 // Return value should be 1 if CSQC handled the temporary entity, otherwise return 0 to have the engine process the event.
1214 float CSQC_Parse_TempEntity()
1216 local float bHandled;
1222 // NOTE: Could just do return instead of break...
1225 case TE_CSQC_PICTURE:
1226 Net_MapVote_Picture();
1234 Net_GrapplingHook();
1241 case TE_CSQC_ZCURVEPARTICLES:
1242 Net_ReadZCurveParticles();
1245 case TE_CSQC_NEXGUNBEAMPARTICLE:
1246 Net_ReadNexgunBeamParticle();
1249 case TE_CSQC_TEAMNAGGER:
1254 Net_VoteDialog(ReadByte());
1257 case TE_CSQC_VOTERESET:
1258 Net_VoteDialogReset();
1261 case TE_CSQC_LIGHTNINGARC:
1262 Net_ReadLightningarc();
1265 case TE_CSQC_PINGPLREPORT:
1266 Net_ReadPingPLReport();
1269 case TE_CSQC_ANNOUNCE:
1270 announce_snd = strzone(ReadString());
1274 // No special logic for this temporary entity; return 0 so the engine can handle it
1282 string getcommandkey(string text, string command)
1287 if (!sbar_showbinds)
1290 keys = db_get(binddb, command);
1293 n = tokenize(findkeysforcommand(command)); // uses '...' strings
1294 for(j = 0; j < n; ++j)
1300 keys = keynumtostring(k);
1302 keys = strcat(keys, ", ", keynumtostring(k));
1305 if (sbar_showbinds_limit > 0 && sbar_showbinds_limit >= l) break;
1309 db_put(binddb, command, keys);
1313 if (sbar_showbinds > 1)
1314 return strcat(text, " (not bound)");
1318 else if (sbar_showbinds > 1)
1319 return strcat(text, " (", keys, ")");