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, '8 8 0'));
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 DrawDebugModel()
475 if(time - floor(time) > 0.5)
481 self.renderflags = 0;
486 void GameCommand(string msg)
491 argc = tokenize_console(msg);
493 if(argv(0) == "help" || argc == 0)
495 print("Usage: cl_cmd COMMAND..., where possible commands are:\n");
496 print(" settemp cvar value\n");
498 print(" sbar_columns_set ...\n");
499 print(" sbar_columns_help\n");
500 GameCommand_Generic("help");
504 if(GameCommand_Generic(msg))
509 if(cmd == "mv_download") {
510 Cmd_MapVote_MapDownload(argc);
512 else if(cmd == "settemp") {
513 cvar_clientsettemp(argv(1), argv(2));
515 else if(cmd == "radar") {
516 ons_showmap = !ons_showmap;
518 else if(cmd == "sbar_columns_set") {
519 Cmd_Sbar_SetFields(argc);
521 else if(cmd == "sbar_columns_help") {
525 else if(cmd == "blurtest") {
526 blurtest_time0 = time;
527 blurtest_time1 = time + stof(argv(1));
528 blurtest_radius = stof(argv(2));
529 blurtest_power = stof(argv(3));
532 else if(cmd == "shotorg_move") {
536 debug_shotorg.view_ofs = debug_shotorg.view_ofs + stov(argv(1));
537 localcmd("sv_cmd debug_shotorg \"", vtos(debug_shotorg.view_ofs), "\"\n");
539 else if(cmd == "shotorg_movez") {
543 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
544 localcmd("sv_cmd debug_shotorg \"", vtos(debug_shotorg.view_ofs), "\"\n");
546 else if(cmd == "shotorg_set") {
550 debug_shotorg.view_ofs = stov(argv(1));
551 localcmd("sv_cmd debug_shotorg \"", vtos(debug_shotorg.view_ofs), "\"\n");
553 else if(cmd == "shotorg_setz") {
557 debug_shotorg.view_ofs = debug_shotorg.view_ofs * (stof(argv(1)) / debug_shotorg.view_ofs_x); // closer/farther, same xy pos
558 localcmd("sv_cmd debug_shotorg \"", vtos(debug_shotorg.view_ofs), "\"\n");
560 else if(cmd == "shotorg_toggle_hide") {
563 debug_shotorg.cnt = !debug_shotorg.cnt;
566 else if(cmd == "shotorg_end") {
569 print(vtos(debug_shotorg.view_ofs), "\n");
570 remove(debug_shotorg);
571 debug_shotorg = world;
573 localcmd("sv_cmd debug_shotorg\n");
575 else if(cmd == "sendcvar") {
576 s = cvar_string(argv(1));
577 if(argv(1) == "cl_weaponpriority")
578 s = W_FixWeaponOrder(W_NumberWeaponOrder(s), 1);
579 else if(substring(argv(1), 0, 17) == "cl_weaponpriority" && strlen(argv(1)) == 18)
580 s = W_FixWeaponOrder(W_NumberWeaponOrder(s), 0);
581 localcmd("cmd sentcvar ", argv(1), " \"", s, "\"\n");
583 else if(cmd == "spawn") {
588 setorigin(e, view_origin);
589 e.angles = view_angles;
590 e.draw = DrawDebugModel;
591 e.classname = "debugmodel";
595 print("Invalid command. For a list of supported commands, try cl_cmd help.\n");
601 // CSQC_InputEvent : Used to perform actions based on any key pressed, key released and mouse on the client.
602 // Return value should be 1 if CSQC handled the input, otherwise return 0 to have the input passed to the engine.
603 // All keys are in ascii.
604 // bInputType = 0 is key pressed, 1 is key released, 2 is mouse input.
605 // In the case of keyboard input, nPrimary is the ascii code, and nSecondary is 0.
606 // In the case of mouse input, nPrimary is xdelta, nSecondary is ydelta.
607 float CSQC_InputEvent(float bInputType, float nPrimary, float nSecondary)
609 local float bSkipKey;
613 if(menu_action(bInputType, nPrimary, nSecondary))
618 // END REQUIRED CSQC FUNCTIONS
619 // --------------------------------------------------------------------------
621 // --------------------------------------------------------------------------
622 // BEGIN OPTIONAL CSQC FUNCTIONS
625 InterpolateOrigin_Undo();
627 self.classname = "entcs_receiver";
628 self.sv_entnum = ReadByte() - 1;
629 self.origin_x = ReadShort();
630 self.origin_y = ReadShort();
631 self.origin_z = ReadShort();
632 self.angles_y = ReadByte() * 360.0 / 256;
633 self.origin_z = self.angles_x = self.angles_z = 0;
635 InterpolateOrigin_Note();
640 void Ent_RemovePlayerScore()
646 SetTeam(self.owner, -1);
647 self.owner.gotscores = 0;
648 for(i = 0; i < MAX_SCORE; ++i)
649 self.owner.(scores[i]) = 0; // clear all scores
653 void Ent_ReadPlayerScore()
659 // damnit -.- don't want to go change every single .sv_entnum in sbar.qc AGAIN
660 // (no I've never heard of M-x replace-string, sed, or anything like that)
661 isNew = !self.owner; // workaround for DP bug
664 #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
665 if(!isNew && n != self.sv_entnum)
667 print("A CSQC entity changed its owner!\n");
670 self.enttype = ENT_CLIENT_SCORES;
676 if not(playerslots[self.sv_entnum])
677 playerslots[self.sv_entnum] = spawn();
678 o = self.owner = playerslots[self.sv_entnum];
679 o.sv_entnum = self.sv_entnum;
682 //if not(o.sort_prev)
683 // RegisterPlayer(o);
684 //playerchecker will do this for us later, if it has not already done so
695 for(i = 0, p = 1; i < MAX_SCORE; ++i, p *= 2)
699 o.(scores[i]) = ReadInt24_t();
701 o.(scores[i]) = ReadChar();
705 Sbar_UpdatePlayerPos(o); // if not registered, we cannot do this yet!
707 self.entremove = Ent_RemovePlayerScore;
710 void Ent_ReadTeamScore()
715 self.team = ReadByte();
716 o = self.owner = GetTeam(self.team, true); // these team numbers can always be trusted
719 #if MAX_TEAMSCORE <= 8
727 for(i = 0, p = 1; i < MAX_TEAMSCORE; ++i, p *= 2)
731 o.(teamscores[i]) = ReadInt24_t();
733 o.(teamscores[i]) = ReadChar();
736 Sbar_UpdateTeamPos(o);
743 void Ent_ClientData()
746 float newspectatee_status;
750 sb_showscores_force = (f & 1);
754 newspectatee_status = ReadByte();
755 if(newspectatee_status == player_localentnum)
756 newspectatee_status = -1; // observing
759 newspectatee_status = 0;
761 spectatorbutton_zoom = (f & 4);
765 angles_held_status = 1;
766 angles_held_x = ReadAngle();
767 angles_held_y = ReadAngle();
771 angles_held_status = 0;
773 if(newspectatee_status != spectatee_status)
776 // clear the weapon accuracy stats
777 for(i = WEP_FIRST; i <= WEP_LAST; ++i) {
784 race_checkpointtime = 0;
786 spectatee_status = newspectatee_status;
791 float nags, i, j, b, f;
798 strunzone(vote_called_vote);
799 vote_called_vote = strzone(ColorTranslateRGB(ReadString()));
804 for(j = 0; j < maxclients; ++j)
806 playerslots[j].ready = 1;
807 for(i = 1; i <= maxclients; i += 8)
810 for(j = i-1, b = 1; b < 256; b *= 2, ++j)
813 playerslots[j].ready = 0;
817 ready_waiting = (nags & 1);
818 ready_waiting_for_me = (nags & 2);
819 vote_waiting = (nags & 4);
820 vote_waiting_for_me = (nags & 8);
821 warmup_stage = (nags & 16);
824 void Ent_RandomSeed()
832 // CSQC_Ent_Update : Called every frame that the server has indicated an update to the SSQC / CSQC entity has occured.
833 // The only parameter reflects if the entity is "new" to the client, meaning it just came into the client's PVS.
834 void Ent_RadarLink();
836 void Ent_ScoresInfo();
837 void(float bIsNewEntity) CSQC_Ent_Update =
843 // set up the "time" global for received entities to be correct for interpolation purposes
851 serverprevtime = time;
852 serverdeltatime = getstatf(STAT_MOVEVARS_TICRATE) * getstatf(STAT_MOVEVARS_TIMESCALE);
853 time = serverprevtime + serverdeltatime;
856 #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
858 if(t != self.enttype)
860 print("A CSQC entity changed its type!\n");
868 case ENT_CLIENT_ENTCS: Ent_ReadEntCS(); break;
869 case ENT_CLIENT_SCORES: Ent_ReadPlayerScore(); break;
870 case ENT_CLIENT_TEAMSCORES: Ent_ReadTeamScore(); break;
871 case ENT_CLIENT_POINTPARTICLES: Ent_PointParticles(); break;
872 case ENT_CLIENT_RAINSNOW: Ent_RainOrSnow(); break;
873 case ENT_CLIENT_LASER: Ent_Laser(); break;
874 case ENT_CLIENT_NAGGER: Ent_Nagger(); break;
875 case ENT_CLIENT_WAYPOINT: Ent_WaypointSprite(); break;
876 case ENT_CLIENT_RADARLINK: Ent_RadarLink(); break;
877 case ENT_CLIENT_PROJECTILE: Ent_Projectile(); break;
878 case ENT_CLIENT_GIBSPLASH: Ent_GibSplash(bIsNewEntity); break;
879 case ENT_CLIENT_DAMAGEINFO: Ent_DamageInfo(bIsNewEntity); break;
880 case ENT_CLIENT_CASING: Ent_Casing(bIsNewEntity); break;
881 case ENT_CLIENT_INIT: Ent_Init(); break;
882 case ENT_CLIENT_SCORES_INFO: Ent_ScoresInfo(); break;
883 case ENT_CLIENT_MAPVOTE: Ent_MapVote(); break;
884 case ENT_CLIENT_CLIENTDATA: Ent_ClientData(); break;
885 case ENT_CLIENT_RANDOMSEED: Ent_RandomSeed(); break;
886 case ENT_CLIENT_WALL: Ent_Wall(); break;
887 case ENT_CLIENT_MODELEFFECT: Ent_ModelEffect(bIsNewEntity); break;
888 case ENT_CLIENT_TUBANOTE: Ent_TubaNote(bIsNewEntity); break;
890 error(strcat("unknown entity type in CSQC_Ent_Update: ", ftos(self.enttype), "\n"));
896 // Destructor, but does NOT deallocate the entity by calling remove(). Also
897 // used when an entity changes its type. For an entity that someone interacts
898 // with others, make sure it can no longer do so.
906 self.draw = menu_sub_null;
907 self.entremove = menu_sub_null;
908 // TODO possibly set more stuff to defaults
910 // CSQC_Ent_Remove : Called when the server requests a SSQC / CSQC entity to be removed. Essentially call remove(self) as well.
911 void CSQC_Ent_Remove()
920 if(gametype == GAME_ONSLAUGHT) {
921 print(strcat("Using ", minimapname, " as minimap.\n"));
922 precache_pic("gfx/ons-cp-neutral.tga");
923 precache_pic("gfx/ons-cp-red.tga");
924 precache_pic("gfx/ons-cp-blue.tga");
925 precache_pic("gfx/ons-frame.tga");
926 precache_pic("gfx/ons-frame-team.tga");
927 } else if(gametype == GAME_KEYHUNT) {
928 precache_pic("gfx/sb_key_carrying");
929 precache_pic("gfx/sb_key_carrying_outline");
934 localcmd("\n_cl_hook_gamestart ", GametypeNameFromType(gametype), ";");
935 calledhooks |= HOOK_START;
938 // 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.
939 void CSQC_Parse_StuffCmd(string strMessage)
941 localcmd(strMessage);
943 // 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.
944 void CSQC_Parse_Print(string strMessage)
946 print(ColorTranslateRGB(strMessage));
949 // CSQC_Parse_CenterPrint : Provides the centerprint string in the first parameter that the server provided.
950 void CSQC_Parse_CenterPrint(string strMessage)
952 centerprint(strMessage);
955 string notranslate_fogcmd1 = "\nfog ";
956 string notranslate_fogcmd2 = "\nr_fog_exp2 0\nr_drawfog 1\n";
959 // TODO somehow thwart prvm_globalset client ...
962 localcmd(strcat(notranslate_fogcmd1, forcefog, notranslate_fogcmd2));
965 void Gamemode_Init();
966 void Ent_ScoresInfo()
969 self.classname = "ent_client_scores_info";
970 gametype = ReadByte();
971 for(i = 0; i < MAX_SCORE; ++i)
973 scores_label[i] = strzone(ReadString());
974 scores_flags[i] = ReadByte();
976 for(i = 0; i < MAX_TEAMSCORE; ++i)
978 teamscores_label[i] = strzone(ReadString());
979 teamscores_flags[i] = ReadByte();
988 self.classname = "ent_client_init";
990 nb_pb_period = ReadByte() / 32; //Accuracy of 1/32th
992 for(i = 0; i < 24; ++i)
993 weaponimpulse[i] = ReadByte() - 1;
994 hook_shotorigin_x = ReadCoord();
995 hook_shotorigin_y = ReadCoord();
996 hook_shotorigin_z = ReadCoord();
1000 forcefog = strzone(ReadString());
1002 armorblockpercent = ReadByte() / 255.0;
1004 g_weaponswitchdelay = ReadByte() / 255.0;
1018 case RACE_NET_CHECKPOINT_HIT_QUALIFYING:
1019 race_checkpoint = ReadByte();
1020 race_time = ReadInt24_t();
1021 race_previousbesttime = ReadInt24_t();
1022 if(race_previousbestname)
1023 strunzone(race_previousbestname);
1024 race_previousbestname = strzone(ColorTranslateRGB(ReadString()));
1026 race_checkpointtime = time;
1028 if(race_checkpoint == 0 || race_checkpoint == 254)
1030 race_penaltyaccumulator = 0;
1031 race_laptime = time; // valid
1036 case RACE_NET_CHECKPOINT_CLEAR:
1038 race_checkpointtime = 0;
1041 case RACE_NET_CHECKPOINT_NEXT_SPEC_QUALIFYING:
1042 race_laptime = ReadCoord();
1043 race_checkpointtime = -99999;
1045 case RACE_NET_CHECKPOINT_NEXT_QUALIFYING:
1046 race_nextcheckpoint = ReadByte();
1048 race_nextbesttime = ReadInt24_t();
1049 if(race_nextbestname)
1050 strunzone(race_nextbestname);
1051 race_nextbestname = strzone(ColorTranslateRGB(ReadString()));
1054 case RACE_NET_CHECKPOINT_HIT_RACE:
1055 race_mycheckpoint = ReadByte();
1056 race_mycheckpointtime = time;
1057 race_mycheckpointdelta = ReadInt24_t();
1058 race_mycheckpointlapsdelta = ReadByte();
1059 if(race_mycheckpointlapsdelta >= 128)
1060 race_mycheckpointlapsdelta -= 256;
1061 if(race_mycheckpointenemy)
1062 strunzone(race_mycheckpointenemy);
1063 race_mycheckpointenemy = strzone(ColorTranslateRGB(ReadString()));
1066 case RACE_NET_CHECKPOINT_HIT_RACE_BY_OPPONENT:
1067 race_othercheckpoint = ReadByte();
1068 race_othercheckpointtime = time;
1069 race_othercheckpointdelta = ReadInt24_t();
1070 race_othercheckpointlapsdelta = ReadByte();
1071 if(race_othercheckpointlapsdelta >= 128)
1072 race_othercheckpointlapsdelta -= 256;
1073 if(race_othercheckpointenemy)
1074 strunzone(race_othercheckpointenemy);
1075 race_othercheckpointenemy = strzone(ColorTranslateRGB(ReadString()));
1078 case RACE_NET_PENALTY_RACE:
1079 race_penaltyeventtime = time;
1080 race_penaltytime = ReadShort();
1081 //race_penaltyaccumulator += race_penaltytime;
1082 if(race_penaltyreason)
1083 strunzone(race_penaltyreason);
1084 race_penaltyreason = strzone(ReadString());
1087 case RACE_NET_PENALTY_QUALIFYING:
1088 race_penaltyeventtime = time;
1089 race_penaltytime = ReadShort();
1090 race_penaltyaccumulator += race_penaltytime;
1091 if(race_penaltyreason)
1092 strunzone(race_penaltyreason);
1093 race_penaltyreason = strzone(ReadString());
1096 case RACE_NET_SERVER_RECORD:
1097 race_server_record = ReadInt24_t();
1099 case RACE_NET_SPEED_AWARD:
1100 race_speedaward = ReadShort();
1101 if(race_speedaward_holder)
1102 strunzone(race_speedaward_holder);
1103 race_speedaward_holder = strzone(ReadString());
1105 case RACE_NET_SPEED_AWARD_BEST:
1106 race_speedaward_alltimebest = ReadShort();
1107 if(race_speedaward_alltimebest_holder)
1108 strunzone(race_speedaward_alltimebest_holder);
1109 race_speedaward_alltimebest_holder = strzone(ReadString());
1111 case RACE_NET_SERVER_RANKINGS:
1112 float pos, prevpos, del;
1114 prevpos = ReadShort();
1117 // move other rankings out of the way
1120 for (i=prevpos-1;i>pos-1;--i) {
1121 grecordtime[i] = grecordtime[i-1];
1122 if(grecordholder[i])
1123 strunzone(grecordholder[i]);
1124 grecordholder[i] = strzone(grecordholder[i-1]);
1126 } else if (del) { // a record has been deleted by the admin
1127 for (i=pos-1; i<= RANKINGS_CNT-1; ++i) {
1128 if (i == RANKINGS_CNT-1) { // clear out last record
1130 if (grecordholder[i])
1131 strunzone(grecordholder[i]);
1132 grecordholder[i] = string_null;
1135 grecordtime[i] = grecordtime[i+1];
1136 if (grecordholder[i])
1137 strunzone(grecordholder[i]);
1138 grecordholder[i] = strzone(grecordholder[i+1]);
1141 } else { // player has no ranked record yet
1142 for (i=RANKINGS_CNT-1;i>pos-1;--i) {
1143 grecordtime[i] = grecordtime[i-1];
1144 if(grecordholder[i])
1145 strunzone(grecordholder[i]);
1146 grecordholder[i] = strzone(grecordholder[i-1]);
1150 // store new ranking
1151 if(grecordholder[pos-1] != "")
1152 strunzone(grecordholder[pos-1]);
1153 grecordholder[pos-1] = strzone(ReadString());
1154 grecordtime[pos-1] = ReadInt24_t();
1155 if(grecordholder[pos-1] == GetPlayerName(player_localentnum -1))
1158 case RACE_NET_SERVER_STATUS:
1159 race_status = ReadShort();
1160 if(race_status_name)
1161 strunzone(race_status_name);
1162 race_status_name = strzone(ReadString());
1166 void Net_ReadSpawn()
1169 current_viewzoom = 0.6;
1172 void Net_TeamNagger()
1177 void Net_ReadPingPLReport()
1179 float e, pi, pl, ml;
1184 if not(playerslots[e])
1186 playerslots[e].ping = pi;
1187 playerslots[e].ping_packetloss = pl / 255.0;
1188 playerslots[e].ping_movementloss = ml / 255.0;
1191 void Net_VoteDialog(float highlight) {
1193 vote_highlighted = ReadShort();
1197 vote_yescount = ReadShort();
1198 vote_nocount = ReadShort();
1199 vote_needed = ReadShort();
1203 void Net_VoteDialogReset() {
1207 // CSQC_Parse_TempEntity : Handles all temporary entity network data in the CSQC layer.
1208 // You must ALWAYS first acquire the temporary ID, which is sent as a byte.
1209 // Return value should be 1 if CSQC handled the temporary entity, otherwise return 0 to have the engine process the event.
1210 float CSQC_Parse_TempEntity()
1212 local float bHandled;
1218 // NOTE: Could just do return instead of break...
1221 case TE_CSQC_PICTURE:
1222 Net_MapVote_Picture();
1230 Net_GrapplingHook();
1237 case TE_CSQC_ZCURVEPARTICLES:
1238 Net_ReadZCurveParticles();
1241 case TE_CSQC_NEXGUNBEAMPARTICLE:
1242 Net_ReadNexgunBeamParticle();
1245 case TE_CSQC_TEAMNAGGER:
1250 Net_VoteDialog(ReadByte());
1253 case TE_CSQC_VOTERESET:
1254 Net_VoteDialogReset();
1257 case TE_CSQC_LIGHTNINGARC:
1258 Net_ReadLightningarc();
1261 case TE_CSQC_PINGPLREPORT:
1262 Net_ReadPingPLReport();
1266 // No special logic for this temporary entity; return 0 so the engine can handle it
1274 string getcommandkey(string text, string command)
1279 if (!sbar_showbinds)
1282 keys = db_get(binddb, command);
1285 n = tokenize(findkeysforcommand(command)); // uses '...' strings
1286 for(j = 0; j < n; ++j)
1292 keys = keynumtostring(k);
1294 keys = strcat(keys, ", ", keynumtostring(k));
1297 if (sbar_showbinds_limit > 0 && sbar_showbinds_limit >= l) break;
1301 db_put(binddb, command, keys);
1305 if (sbar_showbinds > 1)
1306 return strcat(text, " (not bound)");
1310 else if (sbar_showbinds > 1)
1311 return strcat(text, " (", keys, ")");