9 #include "mapvoting.qh"
10 #include "modeleffects.qh"
11 #include "mutators/events.qh"
12 #include "particles.qh"
13 #include "quickmenu.qh"
14 #include "scoreboard.qh"
15 #include "shownames.qh"
19 #include "weapons/projectile.qh"
20 #include "../common/deathtypes/all.qh"
21 #include "../common/items/all.qh"
22 #include "../common/mapinfo.qh"
23 #include "../common/minigames/cl_minigames.qh"
24 #include "../common/minigames/cl_minigames_hud.qh"
25 #include "../common/net_notice.qh"
26 #include "../common/triggers/include.qh"
27 #include "../common/turrets/cl_turrets.qh"
28 #include "../common/vehicles/all.qh"
29 #include "../lib/csqcmodel/cl_model.qh"
30 #include "../lib/csqcmodel/interpolate.qh"
31 #include "../lib/warpzone/client.qh"
33 // --------------------------------------------------------------------------
34 // BEGIN REQUIRED CSQC FUNCTIONS
37 entity clearentity_ent;
38 void clearentity(entity e)
42 clearentity_ent = new(clearentity);
45 copyentity(clearentity_ent, e);
49 #define DP_CSQC_ENTITY_REMOVE_IS_B0RKED
50 void menu_show_error()
52 drawstring('0 200 0', _("ERROR - MENU IS VISIBLE BUT NO MENU WAS DEFINED!"), '8 8 0', '1 0 0', 1, 0);
55 // CSQC_Init : Called every time the CSQC code is initialized (essentially at map load)
56 // Useful for precaching things
62 void draw_null(entity this) { }
65 void ConsoleCommand_macro_init();
68 prvm_language = strzone(cvar_string("prvm_language"));
71 LOG_TRACEF("^4CSQC Build information: ^1%s\n", WATERMARK);
78 ClientProgsDB = db_load("client.db");
79 compressShortVector_init();
83 menu_show = menu_show_error;
84 menu_action = func_null;
86 for(i = 0; i < 255; ++i)
87 if(getplayerkeyvalue(i, "viewentity") == "")
91 //registercommand("hud_configure");
92 //registercommand("hud_save");
93 //registercommand("menu_action");
95 ConsoleCommand_macro_init();
97 registercvar("hud_usecsqc", "1");
98 registercvar("scoreboard_columns", "default");
100 registercvar("cl_nade_type", "3");
101 registercvar("cl_pokenade_type", "zombie");
103 registercvar("cl_jumpspeedcap_min", "");
104 registercvar("cl_jumpspeedcap_max", "");
106 registercvar("cl_multijump", "0");
108 registercvar("cl_spawn_near_teammate", "1");
112 // hud_fields uses strunzone on the titles!
113 for(i = 0; i < MAX_HUD_FIELDS; ++i)
114 hud_title[i] = strzone("(null)");
116 Cmd_HUD_SetFields(0);
122 teams = Sort_Spawn();
123 players = Sort_Spawn();
125 GetTeam(NUM_SPECTATOR, true); // add specs first
127 // needs to be done so early because of the constants they create
130 static_init_precache();
134 Projectile_Precache();
137 if(autocvar_cl_reticle)
139 precache_pic("gfx/reticle_normal");
140 // weapon reticles are precached in weapon files
143 get_mi_min_max_texcoords(1); // try the CLEVER way first
144 minimapname = strcat("gfx/", mi_shortname, "_radar.tga");
145 shortmapname = mi_shortname;
147 if(precache_pic(minimapname) == "")
149 // but maybe we have a non-clever minimap
150 minimapname = strcat("gfx/", mi_shortname, "_mini.tga");
151 if(precache_pic(minimapname) == "")
152 minimapname = ""; // FAIL
154 get_mi_min_max_texcoords(0); // load new texcoords
157 mi_center = (mi_min + mi_max) * 0.5;
158 mi_scale = mi_max - mi_min;
159 minimapname = strzone(minimapname);
163 hud_skin_path = strzone(strcat("gfx/hud/", autocvar_hud_skin));
164 draw_currentSkin = strzone(strcat("gfx/menu/", cvar_string("menu_skin")));
167 // CSQC_Shutdown : Called every time the CSQC code is shutdown (changing maps, quitting, etc)
176 if(autocvar_cl_db_saveasdump)
177 db_dump(ClientProgsDB, "client.db");
179 db_save(ClientProgsDB, "client.db");
180 db_close(ClientProgsDB);
183 cvar_set("chase_active",ftos(chase_active_backup));
185 // unset the event chasecam's chase_active
186 if(autocvar_chase_active < 0)
187 cvar_set("chase_active", "0");
191 if (!(calledhooks & HOOK_START))
192 localcmd("\n_cl_hook_gamestart nop\n");
193 if (!(calledhooks & HOOK_END))
194 localcmd("\ncl_hook_gameend\n");
197 deactivate_minigame();
198 HUD_MinigameMenu_Close();
202 float SetTeam(entity o, int Team)
216 if(GetTeam(Team, false) == world)
218 LOG_TRACEF("trying to switch to unsupported team %d\n", Team);
219 Team = NUM_SPECTATOR;
232 if(GetTeam(Team, false) == world)
234 LOG_TRACEF("trying to switch to unsupported team %d\n", Team);
235 Team = NUM_SPECTATOR;
240 if(Team == -1) // leave
244 tm = GetTeam(o.team, false);
255 tm = GetTeam(Team, true);
260 else if(Team != o.team)
262 tm = GetTeam(o.team, false);
265 tm = GetTeam(Team, true);
273 void Playerchecker_Think()
277 for(i = 0; i < maxclients; ++i)
280 if(GetPlayerName(i) == "")
284 // player disconnected
298 playerslots[i] = e = new(playerslot);
303 e.ping_packetloss = 0;
304 e.ping_movementloss = 0;
305 //e.gotscores = 0; // we might already have the scores...
306 SetTeam(e, GetPlayerColor(i)); // will not hurt; later updates come with HUD_UpdatePlayerTeams
308 HUD_UpdatePlayerPos(e);
312 self.nextthink = time + 0.2;
319 entity playerchecker = new(playerchecker);
320 make_pure(playerchecker);
321 playerchecker.think = Playerchecker_Think;
322 playerchecker.nextthink = time + 0.2;
330 // CSQC_InputEvent : Used to perform actions based on any key pressed, key released and mouse on the client.
331 // Return value should be 1 if CSQC handled the input, otherwise return 0 to have the input passed to the engine.
332 // All keys are in ascii.
333 // bInputType = 0 is key pressed, 1 is key released, 2 and 3 are mouse input.
334 // In the case of keyboard input, nPrimary is the ascii code, and nSecondary is 0.
335 // In the case of mouse input, nPrimary is xdelta, nSecondary is ydelta.
336 // In the case of mouse input after a setcursormode(1) call, nPrimary is xpos, nSecondary is ypos.
337 float CSQC_InputEvent(float bInputType, float nPrimary, float nSecondary)
342 if (HUD_Panel_InputEvent(bInputType, nPrimary, nSecondary))
345 if (QuickMenu_InputEvent(bInputType, nPrimary, nSecondary))
348 if ( HUD_Radar_InputEvent(bInputType, nPrimary, nSecondary) )
351 if (MapVote_InputEvent(bInputType, nPrimary, nSecondary))
354 if (HUD_Minigame_InputEvent(bInputType, nPrimary, nSecondary))
357 if(menu_visible && menu_action)
358 if(menu_action(bInputType, nPrimary, nSecondary))
364 // END REQUIRED CSQC FUNCTIONS
365 // --------------------------------------------------------------------------
367 // --------------------------------------------------------------------------
368 // BEGIN OPTIONAL CSQC FUNCTIONS
370 void Ent_RemoveEntCS()
372 entcs_receiver[self.sv_entnum] = NULL;
377 this.classname = "entcs_receiver";
378 InterpolateOrigin_Undo();
382 self.sv_entnum = ReadByte();
385 self.origin_x = ReadShort();
386 self.origin_y = ReadShort();
387 self.origin_z = ReadShort();
388 setorigin(self, self.origin);
392 self.angles_y = ReadByte() * 360.0 / 256;
393 self.angles_x = self.angles_z = 0;
396 self.healthvalue = ReadByte() * 10;
398 self.armorvalue = ReadByte() * 10;
400 entcs_receiver[self.sv_entnum] = self;
401 self.entremove = Ent_RemoveEntCS;
402 self.iflags |= IFLAG_ORIGIN;
404 InterpolateOrigin_Note();
409 void Ent_RemovePlayerScore()
412 SetTeam(self.owner, -1);
413 self.owner.gotscores = 0;
414 for(int i = 0; i < MAX_SCORE; ++i) {
415 self.owner.(scores[i]) = 0; // clear all scores
420 void Ent_ReadPlayerScore()
427 // damnit -.- don't want to go change every single .sv_entnum in hud.qc AGAIN
428 // (no I've never heard of M-x replace-string, sed, or anything like that)
429 isNew = !self.owner; // workaround for DP bug
432 #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
433 if(!isNew && n != self.sv_entnum)
435 //print("A CSQC entity changed its owner!\n");
436 LOG_INFOF("A CSQC entity changed its owner! (edict: %d, classname: %s)\n", num_for_edict(self), self.classname);
444 o = playerslots[self.sv_entnum];
447 o = playerslots[self.sv_entnum] = new(playerslot);
451 o.sv_entnum = self.sv_entnum;
455 // RegisterPlayer(o);
456 //playerchecker will do this for us later, if it has not already done so
467 for(i = 0, p = 1; i < MAX_SCORE; ++i, p *= 2)
471 o.(scores[i]) = ReadInt24_t();
473 o.(scores[i]) = ReadChar();
477 HUD_UpdatePlayerPos(o); // if not registered, we cannot do this yet!
479 self.entremove = Ent_RemovePlayerScore;
482 void Ent_ReadTeamScore()
488 self.team = ReadByte();
489 o = self.owner = GetTeam(self.team, true); // these team numbers can always be trusted
492 #if MAX_TEAMSCORE <= 8
500 for(i = 0, p = 1; i < MAX_TEAMSCORE; ++i, p *= 2)
504 o.(teamscores[i]) = ReadInt24_t();
506 o.(teamscores[i]) = ReadChar();
509 HUD_UpdateTeamPos(o);
512 void Ent_ClientData()
515 float newspectatee_status;
519 scoreboard_showscores_force = (f & 1);
523 newspectatee_status = ReadByte();
524 if(newspectatee_status == player_localnum + 1)
525 newspectatee_status = -1; // observing
528 newspectatee_status = 0;
530 spectatorbutton_zoom = (f & 4);
534 angles_held_status = 1;
535 angles_held.x = ReadAngle();
536 angles_held.y = ReadAngle();
540 angles_held_status = 0;
542 if(newspectatee_status != spectatee_status)
546 race_checkpointtime = 0;
548 if (autocvar_hud_panel_healtharmor_progressbar_gfx)
550 if ( (spectatee_status == -1 && newspectatee_status > 0) //before observing, now spectating
551 || (spectatee_status > 0 && newspectatee_status > 0 && spectatee_status != newspectatee_status) //changed spectated player
554 else if(spectatee_status && !newspectatee_status) //before observing/spectating, now playing
557 spectatee_status = newspectatee_status;
559 // we could get rid of spectatee_status, and derive it from player_localentnum and player_localnum
567 int nags = ReadByte(); // NAGS NAGS NAGS NAGS NAGS NAGS NADZ NAGS NAGS NAGS
572 strunzone(vote_called_vote);
573 vote_called_vote = string_null;
583 vote_yescount = ReadByte();
584 vote_nocount = ReadByte();
585 vote_needed = ReadByte();
586 vote_highlighted = ReadChar();
592 strunzone(vote_called_vote);
593 vote_called_vote = strzone(ColorTranslateRGB(ReadString()));
598 for(j = 0; j < maxclients; ++j)
600 playerslots[j].ready = 1;
601 for(i = 1; i <= maxclients; i += 8)
604 for(j = i-1, b = 1; b < 256; b *= 2, ++j)
607 playerslots[j].ready = 0;
611 ready_waiting = (nags & BIT(0));
612 ready_waiting_for_me = (nags & BIT(1));
613 vote_waiting = (nags & BIT(2));
614 vote_waiting_for_me = (nags & BIT(3));
615 warmup_stage = (nags & BIT(4));
618 void Ent_EliminatedPlayers()
626 for(j = 0; j < maxclients; ++j)
628 playerslots[j].eliminated = 1;
629 for(i = 1; i <= maxclients; i += 8)
632 for(j = i-1, b = 1; b < 256; b *= 2, ++j)
635 playerslots[j].eliminated = 0;
640 void Ent_RandomSeed()
644 float s = ReadShort();
648 void Ent_ReadAccuracy()
651 int sf = ReadInt24_t();
653 for (int w = 0; w <= WEP_LAST - WEP_FIRST; ++w)
654 weapon_accuracy[w] = -1;
659 for (int w = 0; w <= WEP_LAST - WEP_FIRST; ++w) {
663 weapon_accuracy[w] = -1;
665 weapon_accuracy[w] = 1.0; // no better error handling yet, sorry
667 weapon_accuracy[w] = (b - 1.0) / 100.0;
669 f = (f == 0x800000) ? 1 : f * 2;
673 void Spawn_Draw(entity this)
675 __pointparticles(this.cnt, this.origin + '0 0 28', '0 0 2', bound(0, frametime, 0.1));
678 void Ent_ReadSpawnPoint(float is_new) // entity for spawnpoint
680 float teamnum = (ReadByte() - 1);
682 spn_origin.x = ReadShort();
683 spn_origin.y = ReadShort();
684 spn_origin.z = ReadShort();
688 self.origin = spn_origin;
689 setsize(self, PL_MIN_CONST, PL_MAX_CONST);
692 /*if(autocvar_cl_spawn_point_model) // needs a model first
694 self.mdl = "models/spawnpoint.md3";
695 self.colormod = Team_ColorRGB(teamnum);
696 precache_model(self.mdl);
697 setmodel(self, self.mdl);
698 self.drawmask = MASK_NORMAL;
699 //self.movetype = MOVETYPE_NOCLIP;
700 //self.draw = Spawn_Draw;
702 if(autocvar_cl_spawn_point_particles)
704 if((serverflags & SERVERFLAG_TEAMPLAY))
708 case NUM_TEAM_1: self.cnt = particleeffectnum(EFFECT_SPAWNPOINT_RED); break;
709 case NUM_TEAM_2: self.cnt = particleeffectnum(EFFECT_SPAWNPOINT_BLUE); break;
710 case NUM_TEAM_3: self.cnt = particleeffectnum(EFFECT_SPAWNPOINT_YELLOW); break;
711 case NUM_TEAM_4: self.cnt = particleeffectnum(EFFECT_SPAWNPOINT_PINK); break;
712 default: self.cnt = particleeffectnum(EFFECT_SPAWNPOINT_NEUTRAL); break;
715 else { self.cnt = particleeffectnum(EFFECT_SPAWNPOINT_NEUTRAL); }
717 self.draw = Spawn_Draw;
721 //printf("Ent_ReadSpawnPoint(is_new = %d); origin = %s, team = %d, effect = %d\n", is_new, vtos(self.origin), teamnum, self.cnt);
724 void Ent_ReadSpawnEvent(float is_new)
726 // If entnum is 0, ONLY do the local spawn actions
727 // this way the server can disable the sending of
728 // spawn origin or such to clients if wanted.
729 float entnum = ReadByte();
733 self.origin_x = ReadShort();
734 self.origin_y = ReadShort();
735 self.origin_z = ReadShort();
739 float teamnum = GetPlayerColor(entnum - 1);
741 if(autocvar_cl_spawn_event_particles)
745 case NUM_TEAM_1: pointparticles(EFFECT_SPAWN_RED, self.origin, '0 0 0', 1); break;
746 case NUM_TEAM_2: pointparticles(EFFECT_SPAWN_BLUE, self.origin, '0 0 0', 1); break;
747 case NUM_TEAM_3: pointparticles(EFFECT_SPAWN_YELLOW, self.origin, '0 0 0', 1); break;
748 case NUM_TEAM_4: pointparticles(EFFECT_SPAWN_PINK, self.origin, '0 0 0', 1); break;
749 default: pointparticles(EFFECT_SPAWN_NEUTRAL, self.origin, '0 0 0', 1); break;
752 if(autocvar_cl_spawn_event_sound)
754 sound(self, CH_TRIGGER, SND_SPAWN, VOL_BASE, ATTEN_NORM);
759 // local spawn actions
760 if(is_new && (!entnum || (entnum == player_localentnum)))
763 current_viewzoom = (1 / bound(1, autocvar_cl_spawnzoom_factor, 16));
765 if(autocvar_cl_unpress_zoom_on_spawn)
771 HUD_Radar_Hide_Maximized();
772 //printf("Ent_ReadSpawnEvent(is_new = %d); origin = %s, entnum = %d, localentnum = %d\n", is_new, vtos(self.origin), entnum, player_localentnum);
775 // CSQC_Ent_Update : Called every frame that the server has indicated an update to the SSQC / CSQC entity has occured.
776 // The only parameter reflects if the entity is "new" to the client, meaning it just came into the client's PVS.
777 void Ent_RadarLink();
779 void Ent_ScoresInfo();
780 void CSQC_Ent_Update(float bIsNewEntity)
783 this.sourceLocLine = __LINE__;
784 this.sourceLocFile = __FILE__;
787 // set up the "time" global for received entities to be correct for interpolation purposes
788 float savetime = time;
795 serverprevtime = time;
796 serverdeltatime = getstatf(STAT_MOVEVARS_TICRATE) * getstatf(STAT_MOVEVARS_TIMESCALE);
797 time = serverprevtime + serverdeltatime;
800 #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
803 if(t != this.enttype || bIsNewEntity)
805 LOG_INFOF("A CSQC entity changed its type! (edict: %d, server: %d, type: %d -> %d)\n", num_for_edict(this), this.entnum, this.enttype, t);
815 LOG_INFOF("A CSQC entity appeared out of nowhere! (edict: %d, server: %d, type: %d)\n", num_for_edict(this), this.entnum, t);
822 FOREACH(LinkedEntities, it.m_id == t, LAMBDA(
823 this.classname = it.netname;
824 if (autocvar_developer_csqcentities)
825 LOG_INFOF("CSQC_Ent_Update(%d) with self=%i {.entnum=%d, .enttype=%d} t=%s (%d)\n", bIsNewEntity, this, this.entnum, this.enttype, it.netname, t);
826 done = it.m_read(this, bIsNewEntity);
832 //error(strcat(_("unknown entity type in CSQC_Ent_Update: %d\n"), this.enttype));
833 error(sprintf("Unknown entity type in CSQC_Ent_Update (enttype: %d, edict: %d, classname: %s)\n", this.enttype, num_for_edict(this), this.classname));
836 NET_HANDLE(ENT_CLIENT_ENTCS, bool isnew)
841 NET_HANDLE(ENT_CLIENT_SCORES, bool isnew)
843 Ent_ReadPlayerScore();
846 NET_HANDLE(ENT_CLIENT_TEAMSCORES, bool isnew)
851 NET_HANDLE(ENT_CLIENT_POINTPARTICLES, bool isnew)
853 Ent_PointParticles();
856 NET_HANDLE(ENT_CLIENT_RAINSNOW, bool isnew)
861 NET_HANDLE(ENT_CLIENT_LASER, bool isnew)
866 NET_HANDLE(ENT_CLIENT_NAGGER, bool isnew)
871 NET_HANDLE(ENT_CLIENT_ELIMINATEDPLAYERS, bool isnew)
873 Ent_EliminatedPlayers();
876 NET_HANDLE(ENT_CLIENT_RADARLINK, bool isnew)
881 NET_HANDLE(ENT_CLIENT_PROJECTILE, bool isnew)
886 NET_HANDLE(ENT_CLIENT_DAMAGEINFO, bool isnew)
888 Ent_DamageInfo(isnew);
891 NET_HANDLE(ENT_CLIENT_INIT, bool isnew)
896 NET_HANDLE(ENT_CLIENT_SCORES_INFO, bool isnew)
901 NET_HANDLE(ENT_CLIENT_MAPVOTE, bool isnew)
906 NET_HANDLE(ENT_CLIENT_CLIENTDATA, bool isnew)
911 NET_HANDLE(ENT_CLIENT_RANDOMSEED, bool isnew)
916 NET_HANDLE(ENT_CLIENT_WALL, bool isnew)
921 NET_HANDLE(ENT_CLIENT_MODELEFFECT, bool isnew)
923 Ent_ModelEffect(isnew);
926 NET_HANDLE(ENT_CLIENT_TUBANOTE, bool isnew)
931 NET_HANDLE(ENT_CLIENT_WARPZONE, bool isnew)
933 WarpZone_Read(isnew);
936 NET_HANDLE(ENT_CLIENT_WARPZONE_CAMERA, bool isnew)
938 WarpZone_Camera_Read(isnew);
941 NET_HANDLE(ENT_CLIENT_WARPZONE_TELEPORTED, bool isnew)
943 WarpZone_Teleported_Read(isnew);
946 NET_HANDLE(ENT_CLIENT_TRIGGER_MUSIC, bool isnew)
948 Ent_ReadTriggerMusic();
951 NET_HANDLE(ENT_CLIENT_HOOK, bool isnew)
953 Ent_ReadHook(isnew, NET_ENT_CLIENT_HOOK);
956 NET_HANDLE(ENT_CLIENT_INVENTORY, bool isnew)
958 Inventory_Read(this);
961 NET_HANDLE(ENT_CLIENT_ARC_BEAM, bool isnew)
963 Ent_ReadArcBeam(isnew);
966 NET_HANDLE(ENT_CLIENT_ACCURACY, bool isnew)
971 NET_HANDLE(ENT_CLIENT_AUXILIARYXHAIR, bool isnew)
976 NET_HANDLE(ENT_CLIENT_TURRET, bool isnew)
981 NET_HANDLE(ENT_CLIENT_MODEL, bool isnew)
983 CSQCModel_Read(isnew);
986 NET_HANDLE(ENT_CLIENT_ITEM, bool isnew)
991 NET_HANDLE(ENT_CLIENT_BUMBLE_RAYGUN, bool isnew)
993 bumble_raygun_read(isnew);
996 NET_HANDLE(ENT_CLIENT_SPAWNPOINT, bool isnew)
998 Ent_ReadSpawnPoint(isnew);
1001 NET_HANDLE(ENT_CLIENT_SPAWNEVENT, bool isnew)
1003 Ent_ReadSpawnEvent(isnew);
1006 NET_HANDLE(ENT_CLIENT_NOTIFICATION, bool isnew)
1008 Read_Notification(isnew);
1011 NET_HANDLE(ENT_CLIENT_MINIGAME, bool isnew)
1013 ent_read_minigame();
1016 NET_HANDLE(ENT_CLIENT_VIEWLOC, bool isnew)
1021 NET_HANDLE(ENT_CLIENT_VIEWLOC_TRIGGER, bool isnew)
1023 ent_viewloc_trigger();
1026 NET_HANDLE(ENT_CLIENT_LADDER, bool isnew)
1031 NET_HANDLE(ENT_CLIENT_TRIGGER_PUSH, bool isnew)
1036 NET_HANDLE(ENT_CLIENT_TARGET_PUSH, bool isnew)
1041 NET_HANDLE(ENT_CLIENT_CONVEYOR, bool isnew)
1046 NET_HANDLE(ENT_CLIENT_DOOR, bool isnew)
1051 NET_HANDLE(ENT_CLIENT_PLAT, bool isnew)
1056 NET_HANDLE(ENT_CLIENT_SWAMP, bool isnew)
1061 NET_HANDLE(ENT_CLIENT_CORNER, bool isnew)
1066 NET_HANDLE(ENT_CLIENT_KEYLOCK, bool isnew)
1071 NET_HANDLE(ENT_CLIENT_TRAIN, bool isnew)
1076 NET_HANDLE(ENT_CLIENT_TRIGGER_IMPULSE, bool isnew)
1078 ent_trigger_impulse();
1082 // Destructor, but does NOT deallocate the entity by calling remove(). Also
1083 // used when an entity changes its type. For an entity that someone interacts
1084 // with others, make sure it can no longer do so.
1090 if(self.skeletonindex)
1092 skel_delete(self.skeletonindex);
1093 self.skeletonindex = 0;
1096 if(self.snd_looping > 0)
1098 sound(self, self.snd_looping, SND_Null, VOL_BASE, autocvar_g_jetpack_attenuation);
1099 self.snd_looping = 0;
1103 self.classname = "";
1104 self.draw = draw_null;
1105 self.entremove = menu_sub_null;
1106 // TODO possibly set more stuff to defaults
1108 // CSQC_Ent_Remove : Called when the server requests a SSQC / CSQC entity to be removed. Essentially call remove(self) as well.
1109 void CSQC_Ent_Remove()
1111 if(autocvar_developer_csqcentities)
1112 LOG_INFOF("CSQC_Ent_Remove() with self=%i self.entnum=%d self.enttype=%d\n", self, self.entnum, self.enttype);
1116 LOG_INFO("WARNING: CSQC_Ent_Remove called for already removed entity. Packet loss?\n");
1124 void Gamemode_Init()
1128 if(!(calledhooks & HOOK_START))
1129 localcmd("\n_cl_hook_gamestart ", MapInfo_Type_ToString(gametype), "\n");
1130 calledhooks |= HOOK_START;
1133 // 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.
1134 void CSQC_Parse_StuffCmd(string strMessage)
1136 if(autocvar_developer_csqcentities)
1137 LOG_INFOF("CSQC_Parse_StuffCmd(\"%s\")\n", strMessage);
1139 localcmd(strMessage);
1141 // 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.
1142 void CSQC_Parse_Print(string strMessage)
1144 if(autocvar_developer_csqcentities)
1145 LOG_INFOF("CSQC_Parse_Print(\"%s\")\n", strMessage);
1147 print(ColorTranslateRGB(strMessage));
1150 // CSQC_Parse_CenterPrint : Provides the centerprint_hud string in the first parameter that the server provided.
1151 void CSQC_Parse_CenterPrint(string strMessage)
1153 if(autocvar_developer_csqcentities)
1154 LOG_INFOF("CSQC_Parse_CenterPrint(\"%s\")\n", strMessage);
1156 centerprint_hud(strMessage);
1159 string notranslate_fogcmd1 = "\nfog ";
1160 string notranslate_fogcmd2 = "\nr_fog_exp2 0\nr_drawfog 1\n";
1163 // TODO somehow thwart prvm_globalset client ...
1165 if(autocvar_cl_orthoview && autocvar_cl_orthoview_nofog)
1166 { localcmd("\nr_drawfog 0\n"); }
1167 else if(forcefog != "")
1168 { localcmd(strcat(notranslate_fogcmd1, forcefog, notranslate_fogcmd2)); }
1171 void Gamemode_Init();
1172 void Ent_ScoresInfo()
1176 gametype = ReadInt24_t();
1177 HUD_ModIcons_SetFunc();
1178 for(i = 0; i < MAX_SCORE; ++i)
1181 strunzone(scores_label[i]);
1182 scores_label[i] = strzone(ReadString());
1183 scores_flags[i] = ReadByte();
1185 for(i = 0; i < MAX_TEAMSCORE; ++i)
1187 if(teamscores_label[i])
1188 strunzone(teamscores_label[i]);
1189 teamscores_label[i] = strzone(ReadString());
1190 teamscores_flags[i] = ReadByte();
1200 nb_pb_period = ReadByte() / 32; //Accuracy of 1/32th
1202 hook_shotorigin[0] = decompressShotOrigin(ReadInt24_t());
1203 hook_shotorigin[1] = decompressShotOrigin(ReadInt24_t());
1204 hook_shotorigin[2] = decompressShotOrigin(ReadInt24_t());
1205 hook_shotorigin[3] = decompressShotOrigin(ReadInt24_t());
1206 arc_shotorigin[0] = decompressShotOrigin(ReadInt24_t());
1207 arc_shotorigin[1] = decompressShotOrigin(ReadInt24_t());
1208 arc_shotorigin[2] = decompressShotOrigin(ReadInt24_t());
1209 arc_shotorigin[3] = decompressShotOrigin(ReadInt24_t());
1212 strunzone(forcefog);
1213 forcefog = strzone(ReadString());
1215 armorblockpercent = ReadByte() / 255.0;
1217 g_balance_mortar_bouncefactor = ReadCoord();
1218 g_balance_mortar_bouncestop = ReadCoord();
1219 g_balance_electro_secondary_bouncefactor = ReadCoord();
1220 g_balance_electro_secondary_bouncestop = ReadCoord();
1222 vortex_scope = !ReadByte();
1223 rifle_scope = !ReadByte();
1225 serverflags = ReadByte();
1227 minelayer_maxmines = ReadByte();
1229 hagar_maxrockets = ReadByte();
1231 g_trueaim_minrange = ReadCoord();
1232 g_balance_porto_secondary = ReadByte();
1234 MUTATOR_CALLHOOK(Ent_Init);
1248 case RACE_NET_CHECKPOINT_HIT_QUALIFYING:
1249 race_checkpoint = ReadByte();
1250 race_time = ReadInt24_t();
1251 race_previousbesttime = ReadInt24_t();
1252 if(race_previousbestname)
1253 strunzone(race_previousbestname);
1254 race_previousbestname = strzone(ColorTranslateRGB(ReadString()));
1256 race_checkpointtime = time;
1258 if(race_checkpoint == 0 || race_checkpoint == 254)
1260 race_penaltyaccumulator = 0;
1261 race_laptime = time; // valid
1266 case RACE_NET_CHECKPOINT_CLEAR:
1268 race_checkpointtime = 0;
1271 case RACE_NET_CHECKPOINT_NEXT_SPEC_QUALIFYING:
1272 race_laptime = ReadCoord();
1273 race_checkpointtime = -99999;
1275 case RACE_NET_CHECKPOINT_NEXT_QUALIFYING:
1276 race_nextcheckpoint = ReadByte();
1278 race_nextbesttime = ReadInt24_t();
1279 if(race_nextbestname)
1280 strunzone(race_nextbestname);
1281 race_nextbestname = strzone(ColorTranslateRGB(ReadString()));
1284 case RACE_NET_CHECKPOINT_HIT_RACE:
1285 race_mycheckpoint = ReadByte();
1286 race_mycheckpointtime = time;
1287 race_mycheckpointdelta = ReadInt24_t();
1288 race_mycheckpointlapsdelta = ReadByte();
1289 if(race_mycheckpointlapsdelta >= 128)
1290 race_mycheckpointlapsdelta -= 256;
1291 if(race_mycheckpointenemy)
1292 strunzone(race_mycheckpointenemy);
1293 race_mycheckpointenemy = strzone(ColorTranslateRGB(ReadString()));
1296 case RACE_NET_CHECKPOINT_HIT_RACE_BY_OPPONENT:
1297 race_othercheckpoint = ReadByte();
1298 race_othercheckpointtime = time;
1299 race_othercheckpointdelta = ReadInt24_t();
1300 race_othercheckpointlapsdelta = ReadByte();
1301 if(race_othercheckpointlapsdelta >= 128)
1302 race_othercheckpointlapsdelta -= 256;
1303 if(race_othercheckpointenemy)
1304 strunzone(race_othercheckpointenemy);
1305 race_othercheckpointenemy = strzone(ColorTranslateRGB(ReadString()));
1308 case RACE_NET_PENALTY_RACE:
1309 race_penaltyeventtime = time;
1310 race_penaltytime = ReadShort();
1311 //race_penaltyaccumulator += race_penaltytime;
1312 if(race_penaltyreason)
1313 strunzone(race_penaltyreason);
1314 race_penaltyreason = strzone(ReadString());
1317 case RACE_NET_PENALTY_QUALIFYING:
1318 race_penaltyeventtime = time;
1319 race_penaltytime = ReadShort();
1320 race_penaltyaccumulator += race_penaltytime;
1321 if(race_penaltyreason)
1322 strunzone(race_penaltyreason);
1323 race_penaltyreason = strzone(ReadString());
1326 case RACE_NET_SERVER_RECORD:
1327 race_server_record = ReadInt24_t();
1329 case RACE_NET_SPEED_AWARD:
1330 race_speedaward = ReadInt24_t();
1331 if(race_speedaward_holder)
1332 strunzone(race_speedaward_holder);
1333 race_speedaward_holder = strzone(ReadString());
1335 case RACE_NET_SPEED_AWARD_BEST:
1336 race_speedaward_alltimebest = ReadInt24_t();
1337 if(race_speedaward_alltimebest_holder)
1338 strunzone(race_speedaward_alltimebest_holder);
1339 race_speedaward_alltimebest_holder = strzone(ReadString());
1341 case RACE_NET_SERVER_RANKINGS:
1343 int pos = ReadShort();
1344 prevpos = ReadShort();
1347 // move other rankings out of the way
1350 for (i=prevpos-1;i>pos-1;--i) {
1351 grecordtime[i] = grecordtime[i-1];
1352 if(grecordholder[i])
1353 strunzone(grecordholder[i]);
1354 grecordholder[i] = strzone(grecordholder[i-1]);
1356 } else if (del) { // a record has been deleted by the admin
1357 for (i=pos-1; i<= RANKINGS_CNT-1; ++i) {
1358 if (i == RANKINGS_CNT-1) { // clear out last record
1360 if (grecordholder[i])
1361 strunzone(grecordholder[i]);
1362 grecordholder[i] = string_null;
1365 grecordtime[i] = grecordtime[i+1];
1366 if (grecordholder[i])
1367 strunzone(grecordholder[i]);
1368 grecordholder[i] = strzone(grecordholder[i+1]);
1371 } else { // player has no ranked record yet
1372 for (i=RANKINGS_CNT-1;i>pos-1;--i) {
1373 grecordtime[i] = grecordtime[i-1];
1374 if(grecordholder[i])
1375 strunzone(grecordholder[i]);
1376 grecordholder[i] = strzone(grecordholder[i-1]);
1380 // store new ranking
1381 if(grecordholder[pos-1] != "")
1382 strunzone(grecordholder[pos-1]);
1383 grecordholder[pos-1] = strzone(ReadString());
1384 grecordtime[pos-1] = ReadInt24_t();
1385 if(grecordholder[pos-1] == GetPlayerName(player_localnum))
1388 case RACE_NET_SERVER_STATUS:
1389 race_status = ReadShort();
1390 if(race_status_name)
1391 strunzone(race_status_name);
1392 race_status_name = strzone(ReadString());
1396 NET_HANDLE(TE_CSQC_RACE, bool isNew)
1402 NET_HANDLE(TE_CSQC_TEAMNAGGER, bool isNew)
1408 void Net_ReadPingPLReport()
1415 if (!(playerslots[e]))
1417 playerslots[e].ping = pi;
1418 playerslots[e].ping_packetloss = pl / 255.0;
1419 playerslots[e].ping_movementloss = ml / 255.0;
1421 NET_HANDLE(TE_CSQC_PINGPLREPORT, bool isNew)
1423 Net_ReadPingPLReport();
1427 void Net_WeaponComplain()
1429 complain_weapon = ReadByte();
1431 if(complain_weapon_name)
1432 strunzone(complain_weapon_name);
1433 complain_weapon_name = strzone(WEP_NAME(complain_weapon));
1435 complain_weapon_type = ReadByte();
1437 complain_weapon_time = time;
1438 weapontime = time; // ping the weapon panel
1440 switch(complain_weapon_type)
1442 case 0: Local_Notification(MSG_MULTI, ITEM_WEAPON_NOAMMO, complain_weapon); break;
1443 case 1: Local_Notification(MSG_MULTI, ITEM_WEAPON_DONTHAVE, complain_weapon); break;
1444 default: Local_Notification(MSG_MULTI, ITEM_WEAPON_UNAVAILABLE, complain_weapon); break;
1447 NET_HANDLE(TE_CSQC_WEAPONCOMPLAIN, bool isNew)
1449 Net_WeaponComplain();
1453 // CSQC_Parse_TempEntity : Handles all temporary entity network data in the CSQC layer.
1454 // You must ALWAYS first acquire the temporary ID, which is sent as a byte.
1455 // Return value should be 1 if CSQC handled the temporary entity, otherwise return 0 to have the engine process the event.
1456 bool CSQC_Parse_TempEntity()
1459 int nTEID = ReadByte();
1461 FOREACH(TempEntities, it.m_id == nTEID, LAMBDA(
1462 if (autocvar_developer_csqcentities)
1463 LOG_INFOF("CSQC_Parse_TempEntity() nTEID=%s (%d)\n", it.netname, nTEID);
1464 return it.m_read(NULL, true);
1467 if (autocvar_developer_csqcentities)
1468 LOG_INFOF("CSQC_Parse_TempEntity() with nTEID=%d\n", nTEID);
1470 // No special logic for this temporary entity; return 0 so the engine can handle it
1474 string getcommandkey(string text, string command)
1477 float n, j, k, l = 0;
1479 if (!autocvar_hud_showbinds)
1482 keys = db_get(binddb, command);
1485 n = tokenize(findkeysforcommand(command, 0)); // uses '...' strings
1486 for(j = 0; j < n; ++j)
1492 keys = keynumtostring(k);
1494 keys = strcat(keys, ", ", keynumtostring(k));
1497 if (autocvar_hud_showbinds_limit > 0 && autocvar_hud_showbinds_limit <= l)
1504 db_put(binddb, command, keys);
1507 if (keys == "NO_KEY") {
1508 if (autocvar_hud_showbinds > 1)
1509 return sprintf(_("%s (not bound)"), text);
1513 else if (autocvar_hud_showbinds > 1)
1514 return sprintf("%s (%s)", text, keys);