1 // --------------------------------------------------------------------------
2 // BEGIN REQUIRED CSQC FUNCTIONS
5 #define DP_CSQC_ENTITY_REMOVE_IS_B0RKED
9 drawstring('0 200 0', _("ERROR - MENU IS VISIBLE BUT NO MENU WAS DEFINED!"), '8 8 0', '1 0 0', 1, 0);
12 // CSQC_Init : Called every time the CSQC code is initialized (essentially at map load)
13 // Useful for precaching things
23 void precache_playermodel(string m)
27 if(substring(m, -9,5) == "_lod1")
29 if(substring(m, -9,5) == "_lod2")
32 f = strcat(substring(m, 0, -5), "_lod1", substring(m, -4, -1));
35 f = strcat(substring(m, 0, -5), "_lod2", substring(m, -4, -1));
40 float globhandle, i, n;
41 globhandle = search_begin(strcat(m, "_*.sounds"), TRUE, FALSE);
44 n = search_getsize(globhandle);
45 for (i = 0; i < n; ++i)
47 //print(search_getfilename(globhandle, i), "\n");
48 f = search_getfilename(globhandle, i);
49 PrecachePlayerSounds(f);
51 search_end(globhandle);
54 void precache_all_playermodels(string pattern)
56 float globhandle, i, n;
59 globhandle = search_begin(pattern, TRUE, FALSE);
62 n = search_getsize(globhandle);
63 for (i = 0; i < n; ++i)
65 //print(search_getfilename(globhandle, i), "\n");
66 f = search_getfilename(globhandle, i);
67 precache_playermodel(f);
69 search_end(globhandle);
73 void WaypointSprite_Load();
76 prvm_language = cvar_string("prvm_language");
80 __engine_check = checkextension("DP_SV_WRITEPICTURE");
83 print(_("^3Your engine build is outdated\n^3This Server uses a newer QC VM. Please update!\n"));
84 localcmd("\ndisconnect\n");
90 check_unacceptable_compiler_bugs();
93 print(sprintf(_("^4CSQC Build information: ^1%s\n"), WATERMARK()));
98 #ifdef COMPAT_XON050_ENGINE
99 // old engine lacks implementation of player_localnum
100 player_localnum = player_localentnum - 1;
103 binddb = db_create();
104 tempdb = db_create();
105 ClientProgsDB = db_load("client.db");
106 compressShortVector_init();
108 drawfont = FONT_USER+1;
109 menu_visible = FALSE;
110 menu_show = menu_show_error;
111 menu_action = menu_sub_null;
113 for(i = 0; i < 255; ++i)
114 if(getplayerkeyvalue(i, "viewentity") == "")
118 registercommand("hud_configure");
119 registercommand("hud_save");
120 //registercommand("menu_action");
122 registercommand("+showscores");registercommand("-showscores");
123 registercommand("+showaccuracy");registercommand("-showaccuracy");
129 registercommand("+forward");registercommand("-forward");
130 registercommand("+back");registercommand("-back");
131 registercommand("+moveup");registercommand("-moveup");
132 registercommand("+movedown");registercommand("-movedown");
133 registercommand("+moveright");registercommand("-moveright");
134 registercommand("+moveleft");registercommand("-moveleft");
135 registercommand("+roll_right");registercommand("-roll_right");
136 registercommand("+roll_left");registercommand("-roll_left");
140 registercvar("hud_usecsqc", "1");
141 registercvar("scoreboard_columns", "default");
145 // hud_fields uses strunzone on the titles!
146 for(i = 0; i < MAX_HUD_FIELDS; ++i)
147 hud_title[i] = strzone("(null)");
153 teams = Sort_Spawn();
154 players = Sort_Spawn();
156 GetTeam(COLOR_SPECTATOR, true); // add specs first
160 WaypointSprite_Load();
163 precache_model("null");
164 precache_sound("misc/hit.wav");
165 precache_sound("misc/typehit.wav");
166 if (autocvar_cl_precacheplayermodels)
168 precache_all_playermodels("models/player/*.zym");
169 precache_all_playermodels("models/player/*.dpm");
170 precache_all_playermodels("models/player/*.md3");
171 precache_all_playermodels("models/player/*.psk");
172 precache_all_playermodels("models/player/*.iqm");
175 Projectile_Precache();
177 GibSplash_Precache();
179 DamageInfo_Precache();
182 Announcer_Precache();
185 if(autocvar_cl_reticle)
187 if(autocvar_cl_reticle_item_normal) { precache_pic("gfx/reticle_normal"); }
188 if(autocvar_cl_reticle_item_nex) { precache_pic("gfx/reticle_nex"); }
191 get_mi_min_max_texcoords(1); // try the CLEVER way first
192 minimapname = strcat("gfx/", mi_shortname, "_radar.tga");
193 shortmapname = mi_shortname;
195 if(precache_pic(minimapname) == "")
197 // but maybe we have a non-clever minimap
198 minimapname = strcat("gfx/", mi_shortname, "_mini.tga");
199 if(precache_pic(minimapname) == "")
200 minimapname = ""; // FAIL
202 get_mi_min_max_texcoords(0); // load new texcoords
205 mi_center = (mi_min + mi_max) * 0.5;
206 mi_scale = mi_max - mi_min;
207 minimapname = strzone(minimapname);
211 hud_configure_prev = -1;
215 // CSQC_Shutdown : Called every time the CSQC code is shutdown (changing maps, quitting, etc)
231 if(autocvar_cl_db_saveasdump)
232 db_dump(ClientProgsDB, "client.db");
234 db_save(ClientProgsDB, "client.db");
235 db_close(ClientProgsDB);
238 cvar_set("chase_active",ftos(chase_active_backup));
240 // unset the event chasecam's chase_active
241 if(autocvar_chase_active < 0)
242 cvar_set("chase_active", "0");
246 if not(calledhooks & HOOK_START)
247 localcmd("\n_cl_hook_gamestart nop\n");
248 if not(calledhooks & HOOK_END)
249 localcmd("\ncl_hook_gameend\n");
254 float SetTeam(entity o, float Team)
268 if(GetTeam(Team, false) == world)
270 print(sprintf(_("trying to switch to unsupported team %d\n"), Team));
271 Team = COLOR_SPECTATOR;
284 if(GetTeam(Team, false) == world)
286 print(sprintf(_("trying to switch to unsupported team %d\n"), Team));
287 Team = COLOR_SPECTATOR;
292 if(Team == -1) // leave
296 tm = GetTeam(o.team, false);
307 tm = GetTeam(Team, true);
312 else if(Team != o.team)
314 tm = GetTeam(o.team, false);
317 tm = GetTeam(Team, true);
325 void Playerchecker_Think()
329 for(i = 0; i < maxclients; ++i)
332 if(GetPlayerName(i) == "")
336 // player disconnected
349 playerslots[i] = e = spawn();
352 e.ping_packetloss = 0;
353 e.ping_movementloss = 0;
354 //e.gotscores = 0; // we might already have the scores...
355 SetTeam(e, GetPlayerColor(i)); // will not hurt; later updates come with HUD_UpdatePlayerTeams
357 HUD_UpdatePlayerPos(e);
361 self.nextthink = time + 0.2;
368 localcmd(strcat("\nscoreboard_columns_set ", autocvar_scoreboard_columns, ";\n"));
370 entity playerchecker;
371 playerchecker = spawn();
372 playerchecker.think = Playerchecker_Think;
373 playerchecker.nextthink = time + 0.2;
381 // CSQC_ConsoleCommand : Used to parse commands in the console that have been registered with the "registercommand" function
382 // Return value should be 1 if CSQC handled the command, otherwise return 0 to have the engine handle it.
384 void Cmd_HUD_SetFields(float);
385 void Cmd_HUD_Help(float);
386 float CSQC_ConsoleCommand(string strMessage)
390 argc = tokenize_console(strMessage);
396 if(strCmd == "hud_configure") { // config hud
397 cvar_set("_hud_configure", ftos(!autocvar__hud_configure));
399 } else if(strCmd == "hud_save") { // save hud config
400 if(argv(1) == "" || argv(2)) {
401 print(_("Usage:\n"));
402 print(_("hud_save configname (saves to hud_skinname_configname.cfg)\n"));
405 HUD_Panel_ExportCfg(argv(1));
407 } else if(strCmd == "+showscores") {
408 scoreboard_showscores = true;
410 } else if(strCmd == "-showscores") {
411 scoreboard_showscores = false;
413 } else if(strCmd == "+showaccuracy") {
414 scoreboard_showaccuracy = true;
416 } else if(strCmd == "-showaccuracy") {
417 scoreboard_showaccuracy = false;
422 if(strCmd == "+forward" || strCmd == "-back") {
423 ++camera_direction_x;
425 } else if(strCmd == "-forward" || strCmd == "+back") {
426 --camera_direction_x;
428 } else if(strCmd == "+moveright" || strCmd == "-moveleft") {
429 --camera_direction_y;
431 } else if(strCmd == "-moveright" || strCmd == "+moveleft") {
432 ++camera_direction_y;
434 } else if(strCmd == "+moveup" || strCmd == "-movedown") {
435 ++camera_direction_z;
437 } else if(strCmd == "-moveup" || strCmd == "+movedown") {
438 --camera_direction_z;
440 } else if(strCmd == "+roll_right" || strCmd == "-roll_left") {
443 } else if(strCmd == "+roll_left" || strCmd == "-roll_right") {
452 entity debug_shotorg;
455 self.origin = view_origin + view_forward * self.view_ofs_x + view_right * self.view_ofs_y + view_up * self.view_ofs_z;
456 self.angles = view_angles;
457 self.angles_x = -self.angles_x;
459 self.drawmask = MASK_NORMAL;
463 void ShotOrg_Draw2D()
465 vector coord2d_topleft, coord2d_topright, coord2d;
469 s = vtos(self.view_ofs);
470 s = substring(s, 1, strlen(s) - 2);
471 if(tokenize_console(s) == 3)
472 s = strcat(argv(0), " ", argv(1), " ", argv(2));
474 coord2d_topleft = project_3d_to_2d(self.origin + view_up * 4 - view_right * 4);
475 coord2d_topright = project_3d_to_2d(self.origin + view_up * 4 + view_right * 4);
477 fs = '1 1 0' * ((coord2d_topright_x - coord2d_topleft_x) / stringwidth(s, FALSE, '8 8 0'));
479 coord2d = coord2d_topleft;
482 coord2d_x += (coord2d_topright_x - coord2d_topleft_x) * (1 - 8 / fs_x) * 0.5;
487 drawstring(coord2d, s, fs, '1 1 1', 1, 0);
492 debug_shotorg = spawn();
493 debug_shotorg.draw = ShotOrg_Draw;
494 debug_shotorg.draw2d = ShotOrg_Draw2D;
495 debug_shotorg.renderflags = RF_VIEWMODEL;
496 debug_shotorg.effects = EF_FULLBRIGHT;
497 precache_model("models/shotorg_adjuster.md3");
498 setmodel(debug_shotorg, "models/shotorg_adjuster.md3");
499 debug_shotorg.scale = 2;
500 debug_shotorg.view_ofs = '25 8 -8';
503 void DrawDebugModel()
505 if(time - floor(time) > 0.5)
512 self.renderflags = 0;
513 self.drawmask = MASK_NORMAL;
517 void GameCommand(string msg)
522 argc = tokenize_console(msg);
524 if(argv(0) == "help" || argc == 0)
526 print(_("Usage: cl_cmd COMMAND..., where possible commands are:\n"));
527 print(_(" scoreboard_columns_set ...\n"));
528 print(_(" scoreboard_columns_help\n"));
529 GameCommand_Generic("help");
533 if(GameCommand_Generic(msg))
538 if(cmd == "mv_download") {
539 Cmd_MapVote_MapDownload(argc);
541 else if(cmd == "hud_panel_radar_maximized")
544 hud_panel_radar_maximized = !hud_panel_radar_maximized;
546 hud_panel_radar_maximized = (stof(argv(1)) != 0);
548 else if(cmd == "scoreboard_columns_set") {
549 Cmd_HUD_SetFields(argc);
551 else if(cmd == "scoreboard_columns_help") {
555 else if(cmd == "blurtest") {
556 blurtest_time0 = time;
557 blurtest_time1 = time + stof(argv(1));
558 blurtest_radius = stof(argv(2));
559 blurtest_power = stof(argv(3));
562 else if(cmd == "shotorg_move") {
566 debug_shotorg.view_ofs = debug_shotorg.view_ofs + stov(argv(1));
567 localcmd("sv_cmd debug_shotorg \"", vtos(debug_shotorg.view_ofs), "\"\n");
569 else if(cmd == "shotorg_movez") {
573 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
574 localcmd("sv_cmd debug_shotorg \"", vtos(debug_shotorg.view_ofs), "\"\n");
576 else if(cmd == "shotorg_set") {
580 debug_shotorg.view_ofs = stov(argv(1));
581 localcmd("sv_cmd debug_shotorg \"", vtos(debug_shotorg.view_ofs), "\"\n");
583 else if(cmd == "shotorg_setz") {
587 debug_shotorg.view_ofs = debug_shotorg.view_ofs * (stof(argv(1)) / debug_shotorg.view_ofs_x); // closer/farther, same xy pos
588 localcmd("sv_cmd debug_shotorg \"", vtos(debug_shotorg.view_ofs), "\"\n");
590 else if(cmd == "shotorg_toggle_hide") {
593 debug_shotorg.cnt = !debug_shotorg.cnt;
596 else if(cmd == "shotorg_end") {
599 print(vtos(debug_shotorg.view_ofs), "\n");
600 remove(debug_shotorg);
601 debug_shotorg = world;
603 localcmd("sv_cmd debug_shotorg\n");
605 else if(cmd == "sendcvar") {
606 // W_FixWeaponOrder will trash argv, so save what we need.
608 thiscvar = strzone(argv(1));
609 s = cvar_string(thiscvar);
610 if(thiscvar == "cl_weaponpriority")
611 s = W_FixWeaponOrder(W_NumberWeaponOrder(s), 1);
612 else if(substring(thiscvar, 0, 17) == "cl_weaponpriority" && strlen(thiscvar) == 18)
613 s = W_FixWeaponOrder(W_NumberWeaponOrder(s), 0);
614 localcmd("cmd sentcvar ", thiscvar, " \"", s, "\"\n");
617 else if(cmd == "spawn") {
622 setorigin(e, view_origin);
623 e.angles = view_angles;
624 e.draw = DrawDebugModel;
625 e.classname = "debugmodel";
627 else if(cmd == "vyes")
631 vote_active = 0; // force the panel to disappear right as we have selected the value (to prevent it from fading out in the normal vote panel pos)
633 localcmd("setreport cl_allow_uid2name 1\n");
639 localcmd("cmd vote yes\n");
642 else if(cmd == "vno")
648 localcmd("setreport cl_allow_uid2name 0\n");
654 localcmd("cmd vote no\n");
660 print("Invalid command. For a list of supported commands, try cl_cmd help.\n");
666 // CSQC_InputEvent : Used to perform actions based on any key pressed, key released and mouse on the client.
667 // Return value should be 1 if CSQC handled the input, otherwise return 0 to have the input passed to the engine.
668 // All keys are in ascii.
669 // bInputType = 0 is key pressed, 1 is key released, 2 is mouse input.
670 // In the case of keyboard input, nPrimary is the ascii code, and nSecondary is 0.
671 // In the case of mouse input, nPrimary is xdelta, nSecondary is ydelta.
672 float CSQC_InputEvent(float bInputType, float nPrimary, float nSecondary)
677 if (HUD_Panel_InputEvent(bInputType, nPrimary, nSecondary))
680 if (MapVote_InputEvent(bInputType, nPrimary, nSecondary))
684 if(menu_action(bInputType, nPrimary, nSecondary))
690 // END REQUIRED CSQC FUNCTIONS
691 // --------------------------------------------------------------------------
693 // --------------------------------------------------------------------------
694 // BEGIN OPTIONAL CSQC FUNCTIONS
695 void Ent_RemoveEntCS()
697 entcs_receiver[self.sv_entnum] = world;
702 InterpolateOrigin_Undo();
704 self.classname = "entcs_receiver";
708 self.sv_entnum = ReadByte();
711 self.origin_x = ReadShort();
712 self.origin_y = ReadShort();
713 self.origin_z = ReadShort();
717 self.angles_y = ReadByte() * 360.0 / 256;
718 self.angles_x = self.angles_z = 0;
721 self.healthvalue = ReadByte() * 10;
723 self.armorvalue = ReadByte() * 10;
725 entcs_receiver[self.sv_entnum] = self;
726 self.entremove = Ent_RemoveEntCS;
728 InterpolateOrigin_Note();
733 void Ent_RemovePlayerScore()
739 SetTeam(self.owner, -1);
740 self.owner.gotscores = 0;
741 for(i = 0; i < MAX_SCORE; ++i)
742 self.owner.(scores[i]) = 0; // clear all scores
746 void Ent_ReadPlayerScore()
752 // damnit -.- don't want to go change every single .sv_entnum in hud.qc AGAIN
753 // (no I've never heard of M-x replace-string, sed, or anything like that)
754 isNew = !self.owner; // workaround for DP bug
757 #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
758 if(!isNew && n != self.sv_entnum)
760 //print(_("A CSQC entity changed its owner!\n"));
761 print(sprintf(_("A CSQC entity changed its owner! (edict: %d, classname: %s)\n"), num_for_edict(self), self.classname));
764 self.enttype = ENT_CLIENT_SCORES;
770 if not(playerslots[self.sv_entnum])
771 playerslots[self.sv_entnum] = spawn();
772 o = self.owner = playerslots[self.sv_entnum];
773 o.sv_entnum = self.sv_entnum;
776 //if not(o.sort_prev)
777 // RegisterPlayer(o);
778 //playerchecker will do this for us later, if it has not already done so
789 for(i = 0, p = 1; i < MAX_SCORE; ++i, p *= 2)
793 o.(scores[i]) = ReadInt24_t();
795 o.(scores[i]) = ReadChar();
799 HUD_UpdatePlayerPos(o); // if not registered, we cannot do this yet!
801 self.entremove = Ent_RemovePlayerScore;
804 void Ent_ReadTeamScore()
809 self.team = ReadByte();
810 o = self.owner = GetTeam(self.team, true); // these team numbers can always be trusted
813 #if MAX_TEAMSCORE <= 8
821 for(i = 0, p = 1; i < MAX_TEAMSCORE; ++i, p *= 2)
825 o.(teamscores[i]) = ReadInt24_t();
827 o.(teamscores[i]) = ReadChar();
830 HUD_UpdateTeamPos(o);
833 void Ent_ClientData()
836 float newspectatee_status;
840 scoreboard_showscores_force = (f & 1);
844 newspectatee_status = ReadByte();
845 if(newspectatee_status == player_localnum + 1)
846 newspectatee_status = -1; // observing
849 newspectatee_status = 0;
851 spectatorbutton_zoom = (f & 4);
855 angles_held_status = 1;
856 angles_held_x = ReadAngle();
857 angles_held_y = ReadAngle();
861 angles_held_status = 0;
863 if(newspectatee_status != spectatee_status)
867 race_checkpointtime = 0;
869 if (autocvar_hud_panel_healtharmor_progressbar_gfx)
871 if ( (spectatee_status == -1 && newspectatee_status > 0) //before observing, now spectating
872 || (spectatee_status > 0 && newspectatee_status > 0 && spectatee_status != newspectatee_status) //changed spectated player
875 else if(spectatee_status && !newspectatee_status) //before observing/spectating, now playing
878 spectatee_status = newspectatee_status;
880 // non-COMPAT_XON050_ENGINE: we could get rid of spectatee_status, and derive it from player_localentnum and player_localnum
885 float nags, i, j, b, f;
887 nags = ReadByte(); // NAGS NAGS NAGS NAGS NAGS NAGS NADZ NAGS NAGS NAGS
892 strunzone(vote_called_vote);
893 vote_called_vote = string_null;
903 vote_yescount = ReadByte();
904 vote_nocount = ReadByte();
905 vote_needed = ReadByte();
906 vote_highlighted = ReadChar();
912 strunzone(vote_called_vote);
913 vote_called_vote = strzone(ColorTranslateRGB(ReadString()));
918 for(j = 0; j < maxclients; ++j)
920 playerslots[j].ready = 1;
921 for(i = 1; i <= maxclients; i += 8)
924 for(j = i-1, b = 1; b < 256; b *= 2, ++j)
927 playerslots[j].ready = 0;
931 ready_waiting = (nags & 1);
932 ready_waiting_for_me = (nags & 2);
933 vote_waiting = (nags & 4);
934 vote_waiting_for_me = (nags & 8);
935 warmup_stage = (nags & 16);
938 void Ent_RandomSeed()
946 void Ent_ReadAccuracy(void)
952 for(w = 0; w <= WEP_LAST - WEP_FIRST; ++w)
953 weapon_accuracy[w] = -1;
957 for(w = 0, f = 1; w <= WEP_LAST - WEP_FIRST; ++w, f *= 2)
963 weapon_accuracy[w] = -1;
965 weapon_accuracy[w] = 1.0; // no better error handling yet, sorry
967 weapon_accuracy[w] = (b - 1.0) / 100.0;
972 // CSQC_Ent_Update : Called every frame that the server has indicated an update to the SSQC / CSQC entity has occured.
973 // The only parameter reflects if the entity is "new" to the client, meaning it just came into the client's PVS.
974 void Ent_RadarLink();
976 void Ent_ScoresInfo();
977 void CSQC_Ent_Update(float bIsNewEntity)
983 // set up the "time" global for received entities to be correct for interpolation purposes
991 serverprevtime = time;
992 serverdeltatime = getstatf(STAT_MOVEVARS_TICRATE) * getstatf(STAT_MOVEVARS_TIMESCALE);
993 time = serverprevtime + serverdeltatime;
996 #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
999 if(t != self.enttype || bIsNewEntity)
1001 //print(_("A CSQC entity changed its type!\n"));
1002 print(sprintf(_("A CSQC entity changed its type! (edict: %d, server: %d, type: %d -> %d)\n"), num_for_edict(self), self.entnum, self.enttype, t));
1011 print(sprintf(_("A CSQC entity appeared out of nowhere! (edict: %d, server: %d, type: %d)\n"), num_for_edict(self), self.entnum, t));
1019 case ENT_CLIENT_ENTCS: Ent_ReadEntCS(); break;
1020 case ENT_CLIENT_SCORES: Ent_ReadPlayerScore(); break;
1021 case ENT_CLIENT_TEAMSCORES: Ent_ReadTeamScore(); break;
1022 case ENT_CLIENT_POINTPARTICLES: Ent_PointParticles(); break;
1023 case ENT_CLIENT_RAINSNOW: Ent_RainOrSnow(); break;
1024 case ENT_CLIENT_LASER: Ent_Laser(); break;
1025 case ENT_CLIENT_NAGGER: Ent_Nagger(); break;
1026 case ENT_CLIENT_WAYPOINT: Ent_WaypointSprite(); break;
1027 case ENT_CLIENT_RADARLINK: Ent_RadarLink(); break;
1028 case ENT_CLIENT_PROJECTILE: Ent_Projectile(); break;
1029 case ENT_CLIENT_GIBSPLASH: Ent_GibSplash(bIsNewEntity); break;
1030 case ENT_CLIENT_DAMAGEINFO: Ent_DamageInfo(bIsNewEntity); break;
1031 case ENT_CLIENT_CASING: Ent_Casing(bIsNewEntity); break;
1032 case ENT_CLIENT_INIT: Ent_Init(); break;
1033 case ENT_CLIENT_SCORES_INFO: Ent_ScoresInfo(); break;
1034 case ENT_CLIENT_MAPVOTE: Ent_MapVote(); break;
1035 case ENT_CLIENT_CLIENTDATA: Ent_ClientData(); break;
1036 case ENT_CLIENT_RANDOMSEED: Ent_RandomSeed(); break;
1037 case ENT_CLIENT_WALL: Ent_Wall(); break;
1038 case ENT_CLIENT_MODELEFFECT: Ent_ModelEffect(bIsNewEntity); break;
1039 case ENT_CLIENT_TUBANOTE: Ent_TubaNote(bIsNewEntity); break;
1040 case ENT_CLIENT_WARPZONE: WarpZone_Read(bIsNewEntity); break;
1041 case ENT_CLIENT_WARPZONE_CAMERA: WarpZone_Camera_Read(bIsNewEntity); break;
1042 case ENT_CLIENT_WARPZONE_TELEPORTED: WarpZone_Teleported_Read(bIsNewEntity); break;
1043 case ENT_CLIENT_TRIGGER_MUSIC: Ent_ReadTriggerMusic(); break;
1044 case ENT_CLIENT_HOOK: Ent_ReadHook(bIsNewEntity, ENT_CLIENT_HOOK); break;
1045 case ENT_CLIENT_LGBEAM: Ent_ReadHook(bIsNewEntity, ENT_CLIENT_LGBEAM); break;
1046 case ENT_CLIENT_GAUNTLET: Ent_ReadHook(bIsNewEntity, ENT_CLIENT_GAUNTLET); break;
1047 case ENT_CLIENT_ACCURACY: Ent_ReadAccuracy(); break;
1048 case ENT_CLIENT_AUXILIARYXHAIR: Net_AuXair2(bIsNewEntity); break;
1049 case ENT_CLIENT_TURRET: ent_turret(); break;
1050 case ENT_CLIENT_MODEL: CSQCModel_Read(); break;
1052 //error(strcat(_("unknown entity type in CSQC_Ent_Update: %d\n"), self.enttype));
1053 error(sprintf(_("Unknown entity type in CSQC_Ent_Update (enttype: %d, edict: %d, classname: %s)\n"), self.enttype, num_for_edict(self), self.classname));
1059 // Destructor, but does NOT deallocate the entity by calling remove(). Also
1060 // used when an entity changes its type. For an entity that someone interacts
1061 // with others, make sure it can no longer do so.
1068 self.classname = "";
1069 self.draw = menu_sub_null;
1070 self.entremove = menu_sub_null;
1071 // TODO possibly set more stuff to defaults
1073 // CSQC_Ent_Remove : Called when the server requests a SSQC / CSQC entity to be removed. Essentially call remove(self) as well.
1074 void CSQC_Ent_Remove()
1081 void Gamemode_Init()
1085 localcmd("\n_cl_hook_gamestart ", GametypeNameFromType(gametype), "\n");
1086 calledhooks |= HOOK_START;
1089 // 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.
1090 void CSQC_Parse_StuffCmd(string strMessage)
1092 localcmd(strMessage);
1094 // 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.
1095 void CSQC_Parse_Print(string strMessage)
1097 print(ColorTranslateRGB(strMessage));
1100 // CSQC_Parse_CenterPrint : Provides the centerprint_hud string in the first parameter that the server provided.
1101 void CSQC_Parse_CenterPrint(string strMessage)
1103 centerprint_hud(strMessage);
1106 string notranslate_fogcmd1 = "\nfog ";
1107 string notranslate_fogcmd2 = "\nr_fog_exp2 0\nr_drawfog 1\n";
1110 // TODO somehow thwart prvm_globalset client ...
1113 localcmd(strcat(notranslate_fogcmd1, forcefog, notranslate_fogcmd2));
1116 void Gamemode_Init();
1117 void Ent_ScoresInfo()
1120 self.classname = "ent_client_scores_info";
1121 gametype = ReadByte();
1122 for(i = 0; i < MAX_SCORE; ++i)
1124 scores_label[i] = strzone(ReadString());
1125 scores_flags[i] = ReadByte();
1127 for(i = 0; i < MAX_TEAMSCORE; ++i)
1129 teamscores_label[i] = strzone(ReadString());
1130 teamscores_flags[i] = ReadByte();
1138 self.classname = "ent_client_init";
1140 nb_pb_period = ReadByte() / 32; //Accuracy of 1/32th
1142 hook_shotorigin[0] = decompressShotOrigin(ReadInt24_t());
1143 hook_shotorigin[1] = decompressShotOrigin(ReadInt24_t());
1144 hook_shotorigin[2] = decompressShotOrigin(ReadInt24_t());
1145 hook_shotorigin[3] = decompressShotOrigin(ReadInt24_t());
1146 electro_shotorigin[0] = decompressShotOrigin(ReadInt24_t());
1147 electro_shotorigin[1] = decompressShotOrigin(ReadInt24_t());
1148 electro_shotorigin[2] = decompressShotOrigin(ReadInt24_t());
1149 electro_shotorigin[3] = decompressShotOrigin(ReadInt24_t());
1150 gauntlet_shotorigin[0] = decompressShotOrigin(ReadInt24_t());
1151 gauntlet_shotorigin[1] = decompressShotOrigin(ReadInt24_t());
1152 gauntlet_shotorigin[2] = decompressShotOrigin(ReadInt24_t());
1153 gauntlet_shotorigin[3] = decompressShotOrigin(ReadInt24_t());
1156 strunzone(forcefog);
1157 forcefog = strzone(ReadString());
1159 armorblockpercent = ReadByte() / 255.0;
1161 g_weaponswitchdelay = ReadByte() / 255.0;
1163 g_balance_grenadelauncher_bouncefactor = ReadCoord();
1164 g_balance_grenadelauncher_bouncestop = ReadCoord();
1165 g_balance_electro_secondary_bouncefactor = ReadCoord();
1166 g_balance_electro_secondary_bouncestop = ReadCoord();
1168 nex_scope = !ReadByte();
1169 rifle_scope = !ReadByte();
1171 serverflags = ReadByte();
1173 minelayer_maxmines = ReadByte();
1175 hagar_maxrockets = ReadByte();
1177 g_trueaim_minrange = ReadCoord();
1191 case RACE_NET_CHECKPOINT_HIT_QUALIFYING:
1192 race_checkpoint = ReadByte();
1193 race_time = ReadInt24_t();
1194 race_previousbesttime = ReadInt24_t();
1195 if(race_previousbestname)
1196 strunzone(race_previousbestname);
1197 race_previousbestname = strzone(ColorTranslateRGB(ReadString()));
1199 race_checkpointtime = time;
1201 if(race_checkpoint == 0 || race_checkpoint == 254)
1203 race_penaltyaccumulator = 0;
1204 race_laptime = time; // valid
1209 case RACE_NET_CHECKPOINT_CLEAR:
1211 race_checkpointtime = 0;
1214 case RACE_NET_CHECKPOINT_NEXT_SPEC_QUALIFYING:
1215 race_laptime = ReadCoord();
1216 race_checkpointtime = -99999;
1218 case RACE_NET_CHECKPOINT_NEXT_QUALIFYING:
1219 race_nextcheckpoint = ReadByte();
1221 race_nextbesttime = ReadInt24_t();
1222 if(race_nextbestname)
1223 strunzone(race_nextbestname);
1224 race_nextbestname = strzone(ColorTranslateRGB(ReadString()));
1227 case RACE_NET_CHECKPOINT_HIT_RACE:
1228 race_mycheckpoint = ReadByte();
1229 race_mycheckpointtime = time;
1230 race_mycheckpointdelta = ReadInt24_t();
1231 race_mycheckpointlapsdelta = ReadByte();
1232 if(race_mycheckpointlapsdelta >= 128)
1233 race_mycheckpointlapsdelta -= 256;
1234 if(race_mycheckpointenemy)
1235 strunzone(race_mycheckpointenemy);
1236 race_mycheckpointenemy = strzone(ColorTranslateRGB(ReadString()));
1239 case RACE_NET_CHECKPOINT_HIT_RACE_BY_OPPONENT:
1240 race_othercheckpoint = ReadByte();
1241 race_othercheckpointtime = time;
1242 race_othercheckpointdelta = ReadInt24_t();
1243 race_othercheckpointlapsdelta = ReadByte();
1244 if(race_othercheckpointlapsdelta >= 128)
1245 race_othercheckpointlapsdelta -= 256;
1246 if(race_othercheckpointenemy)
1247 strunzone(race_othercheckpointenemy);
1248 race_othercheckpointenemy = strzone(ColorTranslateRGB(ReadString()));
1251 case RACE_NET_PENALTY_RACE:
1252 race_penaltyeventtime = time;
1253 race_penaltytime = ReadShort();
1254 //race_penaltyaccumulator += race_penaltytime;
1255 if(race_penaltyreason)
1256 strunzone(race_penaltyreason);
1257 race_penaltyreason = strzone(ReadString());
1260 case RACE_NET_PENALTY_QUALIFYING:
1261 race_penaltyeventtime = time;
1262 race_penaltytime = ReadShort();
1263 race_penaltyaccumulator += race_penaltytime;
1264 if(race_penaltyreason)
1265 strunzone(race_penaltyreason);
1266 race_penaltyreason = strzone(ReadString());
1269 case RACE_NET_SERVER_RECORD:
1270 race_server_record = ReadInt24_t();
1272 case RACE_NET_SPEED_AWARD:
1273 race_speedaward = ReadInt24_t();
1274 if(race_speedaward_holder)
1275 strunzone(race_speedaward_holder);
1276 race_speedaward_holder = strzone(ReadString());
1278 case RACE_NET_SPEED_AWARD_BEST:
1279 race_speedaward_alltimebest = ReadInt24_t();
1280 if(race_speedaward_alltimebest_holder)
1281 strunzone(race_speedaward_alltimebest_holder);
1282 race_speedaward_alltimebest_holder = strzone(ReadString());
1284 case RACE_NET_SERVER_RANKINGS:
1285 float pos, prevpos, del;
1287 prevpos = ReadShort();
1290 // move other rankings out of the way
1293 for (i=prevpos-1;i>pos-1;--i) {
1294 grecordtime[i] = grecordtime[i-1];
1295 if(grecordholder[i])
1296 strunzone(grecordholder[i]);
1297 grecordholder[i] = strzone(grecordholder[i-1]);
1299 } else if (del) { // a record has been deleted by the admin
1300 for (i=pos-1; i<= RANKINGS_CNT-1; ++i) {
1301 if (i == RANKINGS_CNT-1) { // clear out last record
1303 if (grecordholder[i])
1304 strunzone(grecordholder[i]);
1305 grecordholder[i] = string_null;
1308 grecordtime[i] = grecordtime[i+1];
1309 if (grecordholder[i])
1310 strunzone(grecordholder[i]);
1311 grecordholder[i] = strzone(grecordholder[i+1]);
1314 } else { // player has no ranked record yet
1315 for (i=RANKINGS_CNT-1;i>pos-1;--i) {
1316 grecordtime[i] = grecordtime[i-1];
1317 if(grecordholder[i])
1318 strunzone(grecordholder[i]);
1319 grecordholder[i] = strzone(grecordholder[i-1]);
1323 // store new ranking
1324 if(grecordholder[pos-1] != "")
1325 strunzone(grecordholder[pos-1]);
1326 grecordholder[pos-1] = strzone(ReadString());
1327 grecordtime[pos-1] = ReadInt24_t();
1328 if(grecordholder[pos-1] == GetPlayerName(player_localnum))
1331 case RACE_NET_SERVER_STATUS:
1332 race_status = ReadShort();
1333 if(race_status_name)
1334 strunzone(race_status_name);
1335 race_status_name = strzone(ReadString());
1339 void Net_ReadSpawn()
1342 current_viewzoom = 0.6;
1345 void Net_TeamNagger()
1350 void Net_ReadPingPLReport()
1352 float e, pi, pl, ml;
1357 if not(playerslots[e])
1359 playerslots[e].ping = pi;
1360 playerslots[e].ping_packetloss = pl / 255.0;
1361 playerslots[e].ping_movementloss = ml / 255.0;
1364 void Net_WeaponComplain() {
1365 complain_weapon = ReadByte();
1367 if(complain_weapon_name)
1368 strunzone(complain_weapon_name);
1369 complain_weapon_name = strzone(ReadString());
1371 complain_weapon_type = ReadByte();
1373 complain_weapon_time = time;
1374 weapontime = time; // ping the weapon panel
1377 // CSQC_Parse_TempEntity : Handles all temporary entity network data in the CSQC layer.
1378 // You must ALWAYS first acquire the temporary ID, which is sent as a byte.
1379 // Return value should be 1 if CSQC handled the temporary entity, otherwise return 0 to have the engine process the event.
1380 float CSQC_Parse_TempEntity()
1388 // NOTE: Could just do return instead of break...
1391 case TE_CSQC_TARGET_MUSIC:
1395 case TE_CSQC_PICTURE:
1396 Net_MapVote_Picture();
1407 case TE_CSQC_ZCURVEPARTICLES:
1408 Net_ReadZCurveParticles();
1411 case TE_CSQC_NEXGUNBEAMPARTICLE:
1412 Net_ReadNexgunBeamParticle();
1415 case TE_CSQC_TEAMNAGGER:
1419 case TE_CSQC_LIGHTNINGARC:
1420 Net_ReadLightningarc();
1423 case TE_CSQC_PINGPLREPORT:
1424 Net_ReadPingPLReport();
1427 case TE_CSQC_ANNOUNCE:
1428 Announcer_Play(ReadString());
1431 case TE_CSQC_KILLNOTIFY:
1432 HUD_KillNotify(ReadString(), ReadString(), ReadString(), ReadShort(), ReadByte());
1435 case TE_CSQC_KILLCENTERPRINT:
1436 HUD_KillCenterprint(ReadString(), ReadString(), ReadShort(), ReadByte());
1439 case TE_CSQC_CENTERPRINT_GENERIC:
1444 if (id != 0 && s != "")
1445 centerprint_generic(id, s, ReadByte(), ReadByte());
1447 centerprint_generic(id, s, 0, 0);
1450 case TE_CSQC_WEAPONCOMPLAIN:
1451 Net_WeaponComplain();
1454 case TE_CSQC_VEHICLESETUP:
1459 // No special logic for this temporary entity; return 0 so the engine can handle it
1467 string getcommandkey(string text, string command)
1472 if (!autocvar_hud_showbinds)
1475 keys = db_get(binddb, command);
1478 n = tokenize(findkeysforcommand(command, 0)); // uses '...' strings
1479 for(j = 0; j < n; ++j)
1485 keys = keynumtostring(k);
1487 keys = strcat(keys, ", ", keynumtostring(k));
1490 if (autocvar_hud_showbinds_limit > 0 && autocvar_hud_showbinds_limit >= l) break;
1494 db_put(binddb, command, keys);
1498 if (autocvar_hud_showbinds > 1)
1499 return sprintf(_("%s (not bound)"), text);
1503 else if (autocvar_hud_showbinds > 1)
1504 return sprintf(_("%s (%s)"), text, keys);