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;
619 if (MapVote_InputEvent(bInputType, nPrimary, nSecondary))
623 if(menu_action(bInputType, nPrimary, nSecondary))
628 // END REQUIRED CSQC FUNCTIONS
629 // --------------------------------------------------------------------------
631 // --------------------------------------------------------------------------
632 // BEGIN OPTIONAL CSQC FUNCTIONS
635 InterpolateOrigin_Undo();
637 self.classname = "entcs_receiver";
638 self.sv_entnum = ReadByte() - 1;
639 self.origin_x = ReadShort();
640 self.origin_y = ReadShort();
641 self.origin_z = ReadShort();
642 self.angles_y = ReadByte() * 360.0 / 256;
643 self.origin_z = self.angles_x = self.angles_z = 0;
645 InterpolateOrigin_Note();
650 void Ent_RemovePlayerScore()
656 SetTeam(self.owner, -1);
657 self.owner.gotscores = 0;
658 for(i = 0; i < MAX_SCORE; ++i)
659 self.owner.(scores[i]) = 0; // clear all scores
663 void Ent_ReadPlayerScore()
669 // damnit -.- don't want to go change every single .sv_entnum in sbar.qc AGAIN
670 // (no I've never heard of M-x replace-string, sed, or anything like that)
671 isNew = !self.owner; // workaround for DP bug
674 #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
675 if(!isNew && n != self.sv_entnum)
677 print("A CSQC entity changed its owner!\n");
680 self.enttype = ENT_CLIENT_SCORES;
686 if not(playerslots[self.sv_entnum])
687 playerslots[self.sv_entnum] = spawn();
688 o = self.owner = playerslots[self.sv_entnum];
689 o.sv_entnum = self.sv_entnum;
692 //if not(o.sort_prev)
693 // RegisterPlayer(o);
694 //playerchecker will do this for us later, if it has not already done so
705 for(i = 0, p = 1; i < MAX_SCORE; ++i, p *= 2)
709 o.(scores[i]) = ReadInt24_t();
711 o.(scores[i]) = ReadChar();
715 Sbar_UpdatePlayerPos(o); // if not registered, we cannot do this yet!
717 self.entremove = Ent_RemovePlayerScore;
720 void Ent_ReadTeamScore()
725 self.team = ReadByte();
726 o = self.owner = GetTeam(self.team, true); // these team numbers can always be trusted
729 #if MAX_TEAMSCORE <= 8
737 for(i = 0, p = 1; i < MAX_TEAMSCORE; ++i, p *= 2)
741 o.(teamscores[i]) = ReadInt24_t();
743 o.(teamscores[i]) = ReadChar();
746 Sbar_UpdateTeamPos(o);
753 void Ent_ClientData()
756 float newspectatee_status;
760 sb_showscores_force = (f & 1);
764 newspectatee_status = ReadByte();
765 if(newspectatee_status == player_localentnum)
766 newspectatee_status = -1; // observing
769 newspectatee_status = 0;
771 spectatorbutton_zoom = (f & 4);
775 angles_held_status = 1;
776 angles_held_x = ReadAngle();
777 angles_held_y = ReadAngle();
781 angles_held_status = 0;
783 if(newspectatee_status != spectatee_status)
786 // clear the weapon accuracy stats
787 for(i = WEP_FIRST; i <= WEP_LAST; ++i) {
794 race_checkpointtime = 0;
796 spectatee_status = newspectatee_status;
801 float nags, i, j, b, f;
808 strunzone(vote_called_vote);
809 vote_called_vote = strzone(ColorTranslateRGB(ReadString()));
814 for(j = 0; j < maxclients; ++j)
816 playerslots[j].ready = 1;
817 for(i = 1; i <= maxclients; i += 8)
820 for(j = i-1, b = 1; b < 256; b *= 2, ++j)
823 playerslots[j].ready = 0;
827 ready_waiting = (nags & 1);
828 ready_waiting_for_me = (nags & 2);
829 vote_waiting = (nags & 4);
830 vote_waiting_for_me = (nags & 8);
831 warmup_stage = (nags & 16);
834 void Ent_RandomSeed()
842 float FL_CAMERA = 8192;
843 .vector warpzone_transform;
844 void Ent_WarpZone(float isnew)
848 self.enemy = spawn();
849 self.enemy.classname = "warpzone_from";
851 self.classname = "warpzone_to";
852 self.origin_x = ReadCoord();
853 self.origin_y = ReadCoord();
854 self.origin_z = ReadCoord();
855 self.modelindex = ReadShort();
856 self.mins_x = ReadCoord();
857 self.mins_y = ReadCoord();
858 self.mins_z = ReadCoord();
859 self.maxs_x = ReadCoord();
860 self.maxs_y = ReadCoord();
861 self.maxs_z = ReadCoord();
862 self.enemy.oldorigin_x = ReadCoord();
863 self.enemy.oldorigin_y = ReadCoord();
864 self.enemy.oldorigin_z = ReadCoord();
865 self.enemy.avelocity_x = ReadCoord();
866 self.enemy.avelocity_y = ReadCoord();
867 self.enemy.avelocity_z = ReadCoord();
868 self.oldorigin_x = ReadCoord();
869 self.oldorigin_y = ReadCoord();
870 self.oldorigin_z = ReadCoord();
871 self.avelocity_x = ReadCoord();
872 self.avelocity_y = ReadCoord();
873 self.avelocity_z = ReadCoord();
875 self.avelocity = AnglesTransform_TurnDirection(self.avelocity);
876 self.warpzone_transform = AnglesTransform_Divide(self.avelocity, self.enemy.avelocity);
878 self.flags = FL_CAMERA;
879 self.drawmask = MASK_NORMAL;
882 //setmodel(self, self.model);
883 setorigin(self, self.origin);
884 setsize(self, self.mins, self.maxs);
887 // CSQC_Ent_Update : Called every frame that the server has indicated an update to the SSQC / CSQC entity has occured.
888 // The only parameter reflects if the entity is "new" to the client, meaning it just came into the client's PVS.
889 void Ent_RadarLink();
891 void Ent_ScoresInfo();
892 void(float bIsNewEntity) CSQC_Ent_Update =
898 // set up the "time" global for received entities to be correct for interpolation purposes
906 serverprevtime = time;
907 serverdeltatime = getstatf(STAT_MOVEVARS_TICRATE) * getstatf(STAT_MOVEVARS_TIMESCALE);
908 time = serverprevtime + serverdeltatime;
911 #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
913 if(t != self.enttype)
915 print("A CSQC entity changed its type!\n");
923 case ENT_CLIENT_ENTCS: Ent_ReadEntCS(); break;
924 case ENT_CLIENT_SCORES: Ent_ReadPlayerScore(); break;
925 case ENT_CLIENT_TEAMSCORES: Ent_ReadTeamScore(); break;
926 case ENT_CLIENT_POINTPARTICLES: Ent_PointParticles(); break;
927 case ENT_CLIENT_RAINSNOW: Ent_RainOrSnow(); break;
928 case ENT_CLIENT_LASER: Ent_Laser(); break;
929 case ENT_CLIENT_NAGGER: Ent_Nagger(); break;
930 case ENT_CLIENT_WAYPOINT: Ent_WaypointSprite(); break;
931 case ENT_CLIENT_RADARLINK: Ent_RadarLink(); break;
932 case ENT_CLIENT_PROJECTILE: Ent_Projectile(); break;
933 case ENT_CLIENT_GIBSPLASH: Ent_GibSplash(bIsNewEntity); break;
934 case ENT_CLIENT_DAMAGEINFO: Ent_DamageInfo(bIsNewEntity); break;
935 case ENT_CLIENT_CASING: Ent_Casing(bIsNewEntity); break;
936 case ENT_CLIENT_INIT: Ent_Init(); break;
937 case ENT_CLIENT_SCORES_INFO: Ent_ScoresInfo(); break;
938 case ENT_CLIENT_MAPVOTE: Ent_MapVote(); break;
939 case ENT_CLIENT_CLIENTDATA: Ent_ClientData(); break;
940 case ENT_CLIENT_RANDOMSEED: Ent_RandomSeed(); break;
941 case ENT_CLIENT_WALL: Ent_Wall(); break;
942 case ENT_CLIENT_MODELEFFECT: Ent_ModelEffect(bIsNewEntity); break;
943 case ENT_CLIENT_TUBANOTE: Ent_TubaNote(bIsNewEntity); break;
944 case ENT_CLIENT_WARPZONE: Ent_WarpZone(bIsNewEntity); break;
946 error(strcat("unknown entity type in CSQC_Ent_Update: ", ftos(self.enttype), "\n"));
952 // Destructor, but does NOT deallocate the entity by calling remove(). Also
953 // used when an entity changes its type. For an entity that someone interacts
954 // with others, make sure it can no longer do so.
962 self.draw = menu_sub_null;
963 self.entremove = menu_sub_null;
964 // TODO possibly set more stuff to defaults
966 // CSQC_Ent_Remove : Called when the server requests a SSQC / CSQC entity to be removed. Essentially call remove(self) as well.
967 void CSQC_Ent_Remove()
976 if(gametype == GAME_ONSLAUGHT) {
977 print(strcat("Using ", minimapname, " as minimap.\n"));
978 precache_pic("gfx/ons-cp-neutral.tga");
979 precache_pic("gfx/ons-cp-red.tga");
980 precache_pic("gfx/ons-cp-blue.tga");
981 precache_pic("gfx/ons-frame.tga");
982 precache_pic("gfx/ons-frame-team.tga");
983 } else if(gametype == GAME_KEYHUNT) {
984 precache_pic("gfx/sb_key_carrying");
985 precache_pic("gfx/sb_key_carrying_outline");
990 localcmd("\n_cl_hook_gamestart ", GametypeNameFromType(gametype), ";");
991 calledhooks |= HOOK_START;
994 // 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.
995 void CSQC_Parse_StuffCmd(string strMessage)
997 localcmd(strMessage);
999 // 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.
1000 void CSQC_Parse_Print(string strMessage)
1002 print(ColorTranslateRGB(strMessage));
1005 // CSQC_Parse_CenterPrint : Provides the centerprint string in the first parameter that the server provided.
1006 void CSQC_Parse_CenterPrint(string strMessage)
1008 centerprint(strMessage);
1011 string notranslate_fogcmd1 = "\nfog ";
1012 string notranslate_fogcmd2 = "\nr_fog_exp2 0\nr_drawfog 1\n";
1015 // TODO somehow thwart prvm_globalset client ...
1018 localcmd(strcat(notranslate_fogcmd1, forcefog, notranslate_fogcmd2));
1021 void Gamemode_Init();
1022 void Ent_ScoresInfo()
1025 self.classname = "ent_client_scores_info";
1026 gametype = ReadByte();
1027 for(i = 0; i < MAX_SCORE; ++i)
1029 scores_label[i] = strzone(ReadString());
1030 scores_flags[i] = ReadByte();
1032 for(i = 0; i < MAX_TEAMSCORE; ++i)
1034 teamscores_label[i] = strzone(ReadString());
1035 teamscores_flags[i] = ReadByte();
1043 self.classname = "ent_client_init";
1045 nb_pb_period = ReadByte() / 32; //Accuracy of 1/32th
1047 hook_shotorigin_x = ReadCoord();
1048 hook_shotorigin_y = ReadCoord();
1049 hook_shotorigin_z = ReadCoord();
1052 strunzone(forcefog);
1053 forcefog = strzone(ReadString());
1055 armorblockpercent = ReadByte() / 255.0;
1057 g_weaponswitchdelay = ReadByte() / 255.0;
1071 case RACE_NET_CHECKPOINT_HIT_QUALIFYING:
1072 race_checkpoint = ReadByte();
1073 race_time = ReadInt24_t();
1074 race_previousbesttime = ReadInt24_t();
1075 if(race_previousbestname)
1076 strunzone(race_previousbestname);
1077 race_previousbestname = strzone(ColorTranslateRGB(ReadString()));
1079 race_checkpointtime = time;
1081 if(race_checkpoint == 0 || race_checkpoint == 254)
1083 race_penaltyaccumulator = 0;
1084 race_laptime = time; // valid
1089 case RACE_NET_CHECKPOINT_CLEAR:
1091 race_checkpointtime = 0;
1094 case RACE_NET_CHECKPOINT_NEXT_SPEC_QUALIFYING:
1095 race_laptime = ReadCoord();
1096 race_checkpointtime = -99999;
1098 case RACE_NET_CHECKPOINT_NEXT_QUALIFYING:
1099 race_nextcheckpoint = ReadByte();
1101 race_nextbesttime = ReadInt24_t();
1102 if(race_nextbestname)
1103 strunzone(race_nextbestname);
1104 race_nextbestname = strzone(ColorTranslateRGB(ReadString()));
1107 case RACE_NET_CHECKPOINT_HIT_RACE:
1108 race_mycheckpoint = ReadByte();
1109 race_mycheckpointtime = time;
1110 race_mycheckpointdelta = ReadInt24_t();
1111 race_mycheckpointlapsdelta = ReadByte();
1112 if(race_mycheckpointlapsdelta >= 128)
1113 race_mycheckpointlapsdelta -= 256;
1114 if(race_mycheckpointenemy)
1115 strunzone(race_mycheckpointenemy);
1116 race_mycheckpointenemy = strzone(ColorTranslateRGB(ReadString()));
1119 case RACE_NET_CHECKPOINT_HIT_RACE_BY_OPPONENT:
1120 race_othercheckpoint = ReadByte();
1121 race_othercheckpointtime = time;
1122 race_othercheckpointdelta = ReadInt24_t();
1123 race_othercheckpointlapsdelta = ReadByte();
1124 if(race_othercheckpointlapsdelta >= 128)
1125 race_othercheckpointlapsdelta -= 256;
1126 if(race_othercheckpointenemy)
1127 strunzone(race_othercheckpointenemy);
1128 race_othercheckpointenemy = strzone(ColorTranslateRGB(ReadString()));
1131 case RACE_NET_PENALTY_RACE:
1132 race_penaltyeventtime = time;
1133 race_penaltytime = ReadShort();
1134 //race_penaltyaccumulator += race_penaltytime;
1135 if(race_penaltyreason)
1136 strunzone(race_penaltyreason);
1137 race_penaltyreason = strzone(ReadString());
1140 case RACE_NET_PENALTY_QUALIFYING:
1141 race_penaltyeventtime = time;
1142 race_penaltytime = ReadShort();
1143 race_penaltyaccumulator += race_penaltytime;
1144 if(race_penaltyreason)
1145 strunzone(race_penaltyreason);
1146 race_penaltyreason = strzone(ReadString());
1149 case RACE_NET_SERVER_RECORD:
1150 race_server_record = ReadInt24_t();
1152 case RACE_NET_SPEED_AWARD:
1153 race_speedaward = ReadInt24_t();
1154 if(race_speedaward_holder)
1155 strunzone(race_speedaward_holder);
1156 race_speedaward_holder = strzone(ReadString());
1158 case RACE_NET_SPEED_AWARD_BEST:
1159 race_speedaward_alltimebest = ReadInt24_t();
1160 if(race_speedaward_alltimebest_holder)
1161 strunzone(race_speedaward_alltimebest_holder);
1162 race_speedaward_alltimebest_holder = strzone(ReadString());
1164 case RACE_NET_SERVER_RANKINGS:
1165 float pos, prevpos, del;
1167 prevpos = ReadShort();
1170 // move other rankings out of the way
1173 for (i=prevpos-1;i>pos-1;--i) {
1174 grecordtime[i] = grecordtime[i-1];
1175 if(grecordholder[i])
1176 strunzone(grecordholder[i]);
1177 grecordholder[i] = strzone(grecordholder[i-1]);
1179 } else if (del) { // a record has been deleted by the admin
1180 for (i=pos-1; i<= RANKINGS_CNT-1; ++i) {
1181 if (i == RANKINGS_CNT-1) { // clear out last record
1183 if (grecordholder[i])
1184 strunzone(grecordholder[i]);
1185 grecordholder[i] = string_null;
1188 grecordtime[i] = grecordtime[i+1];
1189 if (grecordholder[i])
1190 strunzone(grecordholder[i]);
1191 grecordholder[i] = strzone(grecordholder[i+1]);
1194 } else { // player has no ranked record yet
1195 for (i=RANKINGS_CNT-1;i>pos-1;--i) {
1196 grecordtime[i] = grecordtime[i-1];
1197 if(grecordholder[i])
1198 strunzone(grecordholder[i]);
1199 grecordholder[i] = strzone(grecordholder[i-1]);
1203 // store new ranking
1204 if(grecordholder[pos-1] != "")
1205 strunzone(grecordholder[pos-1]);
1206 grecordholder[pos-1] = strzone(ReadString());
1207 grecordtime[pos-1] = ReadInt24_t();
1208 if(grecordholder[pos-1] == GetPlayerName(player_localentnum -1))
1211 case RACE_NET_SERVER_STATUS:
1212 race_status = ReadShort();
1213 if(race_status_name)
1214 strunzone(race_status_name);
1215 race_status_name = strzone(ReadString());
1219 void Net_ReadSpawn()
1222 current_viewzoom = 0.6;
1225 void Net_TeamNagger()
1230 void Net_ReadPingPLReport()
1232 float e, pi, pl, ml;
1237 if not(playerslots[e])
1239 playerslots[e].ping = pi;
1240 playerslots[e].ping_packetloss = pl / 255.0;
1241 playerslots[e].ping_movementloss = ml / 255.0;
1244 void Net_VoteDialog(float highlight) {
1246 vote_highlighted = ReadShort();
1250 vote_yescount = ReadShort();
1251 vote_nocount = ReadShort();
1252 vote_needed = ReadShort();
1256 void Net_VoteDialogReset() {
1260 // CSQC_Parse_TempEntity : Handles all temporary entity network data in the CSQC layer.
1261 // You must ALWAYS first acquire the temporary ID, which is sent as a byte.
1262 // Return value should be 1 if CSQC handled the temporary entity, otherwise return 0 to have the engine process the event.
1263 float CSQC_Parse_TempEntity()
1265 local float bHandled;
1271 // NOTE: Could just do return instead of break...
1274 case TE_CSQC_PICTURE:
1275 Net_MapVote_Picture();
1283 Net_GrapplingHook();
1290 case TE_CSQC_ZCURVEPARTICLES:
1291 Net_ReadZCurveParticles();
1294 case TE_CSQC_NEXGUNBEAMPARTICLE:
1295 Net_ReadNexgunBeamParticle();
1298 case TE_CSQC_TEAMNAGGER:
1303 Net_VoteDialog(ReadByte());
1306 case TE_CSQC_VOTERESET:
1307 Net_VoteDialogReset();
1310 case TE_CSQC_LIGHTNINGARC:
1311 Net_ReadLightningarc();
1314 case TE_CSQC_PINGPLREPORT:
1315 Net_ReadPingPLReport();
1318 case TE_CSQC_ANNOUNCE:
1319 announce_snd = strzone(ReadString());
1323 // No special logic for this temporary entity; return 0 so the engine can handle it
1331 string getcommandkey(string text, string command)
1336 if (!sbar_showbinds)
1339 keys = db_get(binddb, command);
1342 n = tokenize(findkeysforcommand(command)); // uses '...' strings
1343 for(j = 0; j < n; ++j)
1349 keys = keynumtostring(k);
1351 keys = strcat(keys, ", ", keynumtostring(k));
1354 if (sbar_showbinds_limit > 0 && sbar_showbinds_limit >= l) break;
1358 db_put(binddb, command, keys);
1362 if (sbar_showbinds > 1)
1363 return strcat(text, " (not bound)");
1367 else if (sbar_showbinds > 1)
1368 return strcat(text, " (", keys, ")");