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 entity cutplane; // user can prvm_edictset its fields
474 void DrawDebugModel()
477 t = mod(floor(time / 3), 3);
481 self.renderflags = 0;
488 PolyDrawModel_Cut(self, cutplane);
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 cutplane.origin = e.origin;
603 fixedmakevectors((cutplane.angles = '0 90 0'));
604 cutplane.movedir = v_forward;
605 cutplane.enemy = spawn();
606 cutplane.enemy.origin = e.origin + '16 0 8';
607 fixedmakevectors((cutplane.enemy.angles = '45 90 0'));
608 cutplane.enemy.movedir = v_forward;
609 cutplane.enemy.aiment = spawn();
610 cutplane.enemy.aiment.origin = '-64 0 -64';
611 cutplane.enemy.enemy = spawn();
612 cutplane.enemy.enemy.origin = '64 0 64';
613 cutplane.aiment = spawn();
614 cutplane.aiment.origin = e.origin + '-16 -12 0';
615 fixedmakevectors((cutplane.aiment.angles = '27 41 9'));
616 cutplane.aiment.movedir = v_forward;
617 cutplane.aiment.aiment = spawn();
618 cutplane.aiment.aiment.origin = '-64 0 64';
619 cutplane.aiment.enemy = spawn();
620 cutplane.aiment.enemy.origin = '64 0 -64';
624 print("Invalid command. For a list of supported commands, try cl_cmd help.\n");
630 // CSQC_InputEvent : Used to perform actions based on any key pressed, key released and mouse on the client.
631 // Return value should be 1 if CSQC handled the input, otherwise return 0 to have the input passed to the engine.
632 // All keys are in ascii.
633 // bInputType = 0 is key pressed, 1 is key released, 2 is mouse input.
634 // In the case of keyboard input, nPrimary is the ascii code, and nSecondary is 0.
635 // In the case of mouse input, nPrimary is xdelta, nSecondary is ydelta.
636 float CSQC_InputEvent(float bInputType, float nPrimary, float nSecondary)
638 local float bSkipKey;
642 if(menu_action(bInputType, nPrimary, nSecondary))
647 // END REQUIRED CSQC FUNCTIONS
648 // --------------------------------------------------------------------------
650 // --------------------------------------------------------------------------
651 // BEGIN OPTIONAL CSQC FUNCTIONS
654 InterpolateOrigin_Undo();
656 self.classname = "entcs_receiver";
657 self.sv_entnum = ReadByte() - 1;
658 self.origin_x = ReadShort();
659 self.origin_y = ReadShort();
660 self.origin_z = ReadShort();
661 self.angles_y = ReadByte() * 360.0 / 256;
662 self.origin_z = self.angles_x = self.angles_z = 0;
664 InterpolateOrigin_Note();
669 void Ent_RemovePlayerScore()
675 SetTeam(self.owner, -1);
676 self.owner.gotscores = 0;
677 for(i = 0; i < MAX_SCORE; ++i)
678 self.owner.(scores[i]) = 0; // clear all scores
682 void Ent_ReadPlayerScore()
688 // damnit -.- don't want to go change every single .sv_entnum in sbar.qc AGAIN
689 // (no I've never heard of M-x replace-string, sed, or anything like that)
690 isNew = !self.owner; // workaround for DP bug
693 #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
694 if(!isNew && n != self.sv_entnum)
696 print("A CSQC entity changed its owner!\n");
699 self.enttype = ENT_CLIENT_SCORES;
705 if not(playerslots[self.sv_entnum])
706 playerslots[self.sv_entnum] = spawn();
707 o = self.owner = playerslots[self.sv_entnum];
708 o.sv_entnum = self.sv_entnum;
711 //if not(o.sort_prev)
712 // RegisterPlayer(o);
713 //playerchecker will do this for us later, if it has not already done so
724 for(i = 0, p = 1; i < MAX_SCORE; ++i, p *= 2)
728 o.(scores[i]) = ReadInt24_t();
730 o.(scores[i]) = ReadChar();
734 Sbar_UpdatePlayerPos(o); // if not registered, we cannot do this yet!
736 self.entremove = Ent_RemovePlayerScore;
739 void Ent_ReadTeamScore()
744 self.team = ReadByte();
745 o = self.owner = GetTeam(self.team, true); // these team numbers can always be trusted
748 #if MAX_TEAMSCORE <= 8
756 for(i = 0, p = 1; i < MAX_TEAMSCORE; ++i, p *= 2)
760 o.(teamscores[i]) = ReadInt24_t();
762 o.(teamscores[i]) = ReadChar();
765 Sbar_UpdateTeamPos(o);
772 void Ent_ClientData()
775 float newspectatee_status;
779 sb_showscores_force = (f & 1);
783 newspectatee_status = ReadByte();
784 if(newspectatee_status == player_localentnum)
785 newspectatee_status = -1; // observing
788 newspectatee_status = 0;
790 spectatorbutton_zoom = (f & 4);
794 angles_held_status = 1;
795 angles_held_x = ReadAngle();
796 angles_held_y = ReadAngle();
800 angles_held_status = 0;
802 if(newspectatee_status != spectatee_status)
805 // clear the weapon accuracy stats
806 for(i = WEP_FIRST; i <= WEP_LAST; ++i) {
813 race_checkpointtime = 0;
815 spectatee_status = newspectatee_status;
820 float nags, i, j, b, f;
827 strunzone(vote_called_vote);
828 vote_called_vote = strzone(ColorTranslateRGB(ReadString()));
833 for(j = 0; j < maxclients; ++j)
835 playerslots[j].ready = 1;
836 for(i = 1; i <= maxclients; i += 8)
839 for(j = i-1, b = 1; b < 256; b *= 2, ++j)
842 playerslots[j].ready = 0;
846 ready_waiting = (nags & 1);
847 ready_waiting_for_me = (nags & 2);
848 vote_waiting = (nags & 4);
849 vote_waiting_for_me = (nags & 8);
850 warmup_stage = (nags & 16);
853 void Ent_RandomSeed()
861 // CSQC_Ent_Update : Called every frame that the server has indicated an update to the SSQC / CSQC entity has occured.
862 // The only parameter reflects if the entity is "new" to the client, meaning it just came into the client's PVS.
863 void Ent_RadarLink();
865 void Ent_ScoresInfo();
866 void(float bIsNewEntity) CSQC_Ent_Update =
872 // set up the "time" global for received entities to be correct for interpolation purposes
880 serverprevtime = time;
881 serverdeltatime = getstatf(STAT_MOVEVARS_TICRATE) * getstatf(STAT_MOVEVARS_TIMESCALE);
882 time = serverprevtime + serverdeltatime;
885 #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
887 if(t != self.enttype)
889 print("A CSQC entity changed its type!\n");
897 case ENT_CLIENT_ENTCS: Ent_ReadEntCS(); break;
898 case ENT_CLIENT_SCORES: Ent_ReadPlayerScore(); break;
899 case ENT_CLIENT_TEAMSCORES: Ent_ReadTeamScore(); break;
900 case ENT_CLIENT_POINTPARTICLES: Ent_PointParticles(); break;
901 case ENT_CLIENT_RAINSNOW: Ent_RainOrSnow(); break;
902 case ENT_CLIENT_LASER: Ent_Laser(); break;
903 case ENT_CLIENT_NAGGER: Ent_Nagger(); break;
904 case ENT_CLIENT_WAYPOINT: Ent_WaypointSprite(); break;
905 case ENT_CLIENT_RADARLINK: Ent_RadarLink(); break;
906 case ENT_CLIENT_PROJECTILE: Ent_Projectile(); break;
907 case ENT_CLIENT_GIBSPLASH: Ent_GibSplash(bIsNewEntity); break;
908 case ENT_CLIENT_DAMAGEINFO: Ent_DamageInfo(bIsNewEntity); break;
909 case ENT_CLIENT_CASING: Ent_Casing(bIsNewEntity); break;
910 case ENT_CLIENT_INIT: Ent_Init(); break;
911 case ENT_CLIENT_SCORES_INFO: Ent_ScoresInfo(); break;
912 case ENT_CLIENT_MAPVOTE: Ent_MapVote(); break;
913 case ENT_CLIENT_CLIENTDATA: Ent_ClientData(); break;
914 case ENT_CLIENT_RANDOMSEED: Ent_RandomSeed(); break;
915 case ENT_CLIENT_WALL: Ent_Wall(); break;
916 case ENT_CLIENT_MODELEFFECT: Ent_ModelEffect(bIsNewEntity); break;
917 case ENT_CLIENT_TUBANOTE: Ent_TubaNote(bIsNewEntity); break;
919 error(strcat("unknown entity type in CSQC_Ent_Update: ", ftos(self.enttype), "\n"));
925 // Destructor, but does NOT deallocate the entity by calling remove(). Also
926 // used when an entity changes its type. For an entity that someone interacts
927 // with others, make sure it can no longer do so.
935 self.draw = menu_sub_null;
936 self.entremove = menu_sub_null;
937 // TODO possibly set more stuff to defaults
939 // CSQC_Ent_Remove : Called when the server requests a SSQC / CSQC entity to be removed. Essentially call remove(self) as well.
940 void CSQC_Ent_Remove()
949 if(gametype == GAME_ONSLAUGHT) {
950 print(strcat("Using ", minimapname, " as minimap.\n"));
951 precache_pic("gfx/ons-cp-neutral.tga");
952 precache_pic("gfx/ons-cp-red.tga");
953 precache_pic("gfx/ons-cp-blue.tga");
954 precache_pic("gfx/ons-frame.tga");
955 precache_pic("gfx/ons-frame-team.tga");
956 } else if(gametype == GAME_KEYHUNT) {
957 precache_pic("gfx/sb_key_carrying");
958 precache_pic("gfx/sb_key_carrying_outline");
963 localcmd("\n_cl_hook_gamestart ", GametypeNameFromType(gametype), ";");
964 calledhooks |= HOOK_START;
967 // 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.
968 void CSQC_Parse_StuffCmd(string strMessage)
970 localcmd(strMessage);
972 // 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.
973 void CSQC_Parse_Print(string strMessage)
975 print(ColorTranslateRGB(strMessage));
978 // CSQC_Parse_CenterPrint : Provides the centerprint string in the first parameter that the server provided.
979 void CSQC_Parse_CenterPrint(string strMessage)
981 centerprint(strMessage);
984 string notranslate_fogcmd1 = "\nfog ";
985 string notranslate_fogcmd2 = "\nr_fog_exp2 0\nr_drawfog 1\n";
988 // TODO somehow thwart prvm_globalset client ...
991 localcmd(strcat(notranslate_fogcmd1, forcefog, notranslate_fogcmd2));
994 void Gamemode_Init();
995 void Ent_ScoresInfo()
998 self.classname = "ent_client_scores_info";
999 gametype = ReadByte();
1000 for(i = 0; i < MAX_SCORE; ++i)
1002 scores_label[i] = strzone(ReadString());
1003 scores_flags[i] = ReadByte();
1005 for(i = 0; i < MAX_TEAMSCORE; ++i)
1007 teamscores_label[i] = strzone(ReadString());
1008 teamscores_flags[i] = ReadByte();
1017 self.classname = "ent_client_init";
1019 nb_pb_period = ReadByte() / 32; //Accuracy of 1/32th
1021 for(i = 0; i < 24; ++i)
1022 weaponimpulse[i] = ReadByte() - 1;
1023 hook_shotorigin_x = ReadCoord();
1024 hook_shotorigin_y = ReadCoord();
1025 hook_shotorigin_z = ReadCoord();
1028 strunzone(forcefog);
1029 forcefog = strzone(ReadString());
1031 armorblockpercent = ReadByte() / 255.0;
1033 g_weaponswitchdelay = ReadByte() / 255.0;
1047 case RACE_NET_CHECKPOINT_HIT_QUALIFYING:
1048 race_checkpoint = ReadByte();
1049 race_time = ReadInt24_t();
1050 race_previousbesttime = ReadInt24_t();
1051 if(race_previousbestname)
1052 strunzone(race_previousbestname);
1053 race_previousbestname = strzone(ColorTranslateRGB(ReadString()));
1055 race_checkpointtime = time;
1057 if(race_checkpoint == 0 || race_checkpoint == 254)
1059 race_penaltyaccumulator = 0;
1060 race_laptime = time; // valid
1065 case RACE_NET_CHECKPOINT_CLEAR:
1067 race_checkpointtime = 0;
1070 case RACE_NET_CHECKPOINT_NEXT_SPEC_QUALIFYING:
1071 race_laptime = ReadCoord();
1072 race_checkpointtime = -99999;
1074 case RACE_NET_CHECKPOINT_NEXT_QUALIFYING:
1075 race_nextcheckpoint = ReadByte();
1077 race_nextbesttime = ReadInt24_t();
1078 if(race_nextbestname)
1079 strunzone(race_nextbestname);
1080 race_nextbestname = strzone(ColorTranslateRGB(ReadString()));
1083 case RACE_NET_CHECKPOINT_HIT_RACE:
1084 race_mycheckpoint = ReadByte();
1085 race_mycheckpointtime = time;
1086 race_mycheckpointdelta = ReadInt24_t();
1087 race_mycheckpointlapsdelta = ReadByte();
1088 if(race_mycheckpointlapsdelta >= 128)
1089 race_mycheckpointlapsdelta -= 256;
1090 if(race_mycheckpointenemy)
1091 strunzone(race_mycheckpointenemy);
1092 race_mycheckpointenemy = strzone(ColorTranslateRGB(ReadString()));
1095 case RACE_NET_CHECKPOINT_HIT_RACE_BY_OPPONENT:
1096 race_othercheckpoint = ReadByte();
1097 race_othercheckpointtime = time;
1098 race_othercheckpointdelta = ReadInt24_t();
1099 race_othercheckpointlapsdelta = ReadByte();
1100 if(race_othercheckpointlapsdelta >= 128)
1101 race_othercheckpointlapsdelta -= 256;
1102 if(race_othercheckpointenemy)
1103 strunzone(race_othercheckpointenemy);
1104 race_othercheckpointenemy = strzone(ColorTranslateRGB(ReadString()));
1107 case RACE_NET_PENALTY_RACE:
1108 race_penaltyeventtime = time;
1109 race_penaltytime = ReadShort();
1110 //race_penaltyaccumulator += race_penaltytime;
1111 if(race_penaltyreason)
1112 strunzone(race_penaltyreason);
1113 race_penaltyreason = strzone(ReadString());
1116 case RACE_NET_PENALTY_QUALIFYING:
1117 race_penaltyeventtime = time;
1118 race_penaltytime = ReadShort();
1119 race_penaltyaccumulator += race_penaltytime;
1120 if(race_penaltyreason)
1121 strunzone(race_penaltyreason);
1122 race_penaltyreason = strzone(ReadString());
1125 case RACE_NET_SERVER_RECORD:
1126 race_server_record = ReadInt24_t();
1128 case RACE_NET_SPEED_AWARD:
1129 race_speedaward = ReadShort();
1130 if(race_speedaward_holder)
1131 strunzone(race_speedaward_holder);
1132 race_speedaward_holder = strzone(ReadString());
1134 case RACE_NET_SPEED_AWARD_BEST:
1135 race_speedaward_alltimebest = ReadShort();
1136 if(race_speedaward_alltimebest_holder)
1137 strunzone(race_speedaward_alltimebest_holder);
1138 race_speedaward_alltimebest_holder = strzone(ReadString());
1140 case RACE_NET_SERVER_RANKINGS:
1141 float pos, prevpos, del;
1143 prevpos = ReadShort();
1146 // move other rankings out of the way
1149 for (i=prevpos-1;i>pos-1;--i) {
1150 grecordtime[i] = grecordtime[i-1];
1151 if(grecordholder[i])
1152 strunzone(grecordholder[i]);
1153 grecordholder[i] = strzone(grecordholder[i-1]);
1155 } else if (del) { // a record has been deleted by the admin
1156 for (i=pos-1; i<= RANKINGS_CNT-1; ++i) {
1157 if (i == RANKINGS_CNT-1) { // clear out last record
1159 if (grecordholder[i])
1160 strunzone(grecordholder[i]);
1161 grecordholder[i] = string_null;
1164 grecordtime[i] = grecordtime[i+1];
1165 if (grecordholder[i])
1166 strunzone(grecordholder[i]);
1167 grecordholder[i] = strzone(grecordholder[i+1]);
1170 } else { // player has no ranked record yet
1171 for (i=RANKINGS_CNT-1;i>pos-1;--i) {
1172 grecordtime[i] = grecordtime[i-1];
1173 if(grecordholder[i])
1174 strunzone(grecordholder[i]);
1175 grecordholder[i] = strzone(grecordholder[i-1]);
1179 // store new ranking
1180 if(grecordholder[pos-1] != "")
1181 strunzone(grecordholder[pos-1]);
1182 grecordholder[pos-1] = strzone(ReadString());
1183 grecordtime[pos-1] = ReadInt24_t();
1184 if(grecordholder[pos-1] == GetPlayerName(player_localentnum -1))
1187 case RACE_NET_SERVER_STATUS:
1188 race_status = ReadShort();
1189 if(race_status_name)
1190 strunzone(race_status_name);
1191 race_status_name = strzone(ReadString());
1195 void Net_ReadSpawn()
1198 current_viewzoom = 0.6;
1201 void Net_TeamNagger()
1206 void Net_ReadPingPLReport()
1208 float e, pi, pl, ml;
1213 if not(playerslots[e])
1215 playerslots[e].ping = pi;
1216 playerslots[e].ping_packetloss = pl / 255.0;
1217 playerslots[e].ping_movementloss = ml / 255.0;
1220 void Net_VoteDialog(float highlight) {
1222 vote_highlighted = ReadShort();
1226 vote_yescount = ReadShort();
1227 vote_nocount = ReadShort();
1228 vote_needed = ReadShort();
1232 void Net_VoteDialogReset() {
1236 // CSQC_Parse_TempEntity : Handles all temporary entity network data in the CSQC layer.
1237 // You must ALWAYS first acquire the temporary ID, which is sent as a byte.
1238 // Return value should be 1 if CSQC handled the temporary entity, otherwise return 0 to have the engine process the event.
1239 float CSQC_Parse_TempEntity()
1241 local float bHandled;
1247 // NOTE: Could just do return instead of break...
1250 case TE_CSQC_PICTURE:
1251 Net_MapVote_Picture();
1259 Net_GrapplingHook();
1266 case TE_CSQC_ZCURVEPARTICLES:
1267 Net_ReadZCurveParticles();
1270 case TE_CSQC_NEXGUNBEAMPARTICLE:
1271 Net_ReadNexgunBeamParticle();
1274 case TE_CSQC_TEAMNAGGER:
1279 Net_VoteDialog(ReadByte());
1282 case TE_CSQC_VOTERESET:
1283 Net_VoteDialogReset();
1286 case TE_CSQC_LIGHTNINGARC:
1287 Net_ReadLightningarc();
1290 case TE_CSQC_PINGPLREPORT:
1291 Net_ReadPingPLReport();
1295 // No special logic for this temporary entity; return 0 so the engine can handle it
1303 string getcommandkey(string text, string command)
1308 if (!sbar_showbinds)
1311 keys = db_get(binddb, command);
1314 n = tokenize(findkeysforcommand(command)); // uses '...' strings
1315 for(j = 0; j < n; ++j)
1321 keys = keynumtostring(k);
1323 keys = strcat(keys, ", ", keynumtostring(k));
1326 if (sbar_showbinds_limit > 0 && sbar_showbinds_limit >= l) break;
1330 db_put(binddb, command, keys);
1334 if (sbar_showbinds > 1)
1335 return strcat(text, " (not bound)");
1339 else if (sbar_showbinds > 1)
1340 return strcat(text, " (", keys, ")");