From a014f99742b4ce9131bb4571e52be59a073d1871 Mon Sep 17 00:00:00 2001 From: TimePath Date: Thu, 5 Nov 2015 16:56:27 +1100 Subject: [PATCH] Cleanup --- qcsrc/client/damage.qc | 6 +- qcsrc/client/damage.qh | 2 - qcsrc/client/hook.qc | 7 +- qcsrc/client/hook.qh | 2 - qcsrc/client/laser.qc | 128 ---- qcsrc/client/laser.qh | 6 - qcsrc/client/main.qc | 708 +++++------------- qcsrc/client/main.qh | 7 - qcsrc/client/mapvoting.qc | 3 +- qcsrc/client/mapvoting.qh | 2 - qcsrc/client/modeleffects.qc | 6 +- qcsrc/client/modeleffects.qh | 1 - qcsrc/client/particles.qh | 2 - qcsrc/client/teamradar.qc | 6 +- qcsrc/client/teamradar.qh | 4 - qcsrc/client/tuba.qc | 7 +- qcsrc/client/tuba.qh | 2 - qcsrc/client/view.qc | 3 - qcsrc/client/wall.qc | 6 +- qcsrc/client/wall.qh | 1 - qcsrc/client/weapons/projectile.qc | 11 +- qcsrc/client/weapons/projectile.qh | 4 - qcsrc/common/items/inventory.qh | 9 +- qcsrc/common/minigames/cl_minigames.qc | 5 +- qcsrc/common/minigames/cl_minigames.qh | 3 - qcsrc/common/notifications.qc | 3 +- qcsrc/common/notifications.qh | 1 - qcsrc/common/triggers/func/conveyor.qc | 6 +- qcsrc/common/triggers/func/conveyor.qh | 3 - qcsrc/common/triggers/func/door.qc | 5 +- qcsrc/common/triggers/func/door.qh | 1 - qcsrc/common/triggers/func/include.qh | 4 - qcsrc/common/triggers/func/ladder.qc | 7 +- qcsrc/common/triggers/func/ladder.qh | 4 - qcsrc/common/triggers/func/plat.qc | 5 +- qcsrc/common/triggers/func/plat.qh | 3 - qcsrc/common/triggers/func/pointparticles.qc | 6 +- qcsrc/common/triggers/func/pointparticles.qh | 5 - qcsrc/common/triggers/func/rainsnow.qc | 6 +- qcsrc/common/triggers/func/rainsnow.qh | 3 - qcsrc/common/triggers/func/train.qc | 6 +- qcsrc/common/triggers/func/train.qh | 1 - qcsrc/common/triggers/include.qh | 3 - qcsrc/common/triggers/misc/corner.qc | 6 +- qcsrc/common/triggers/misc/corner.qh | 3 - qcsrc/common/triggers/misc/include.qc | 2 - qcsrc/common/triggers/misc/include.qh | 7 - qcsrc/common/triggers/misc/laser.qc | 7 +- qcsrc/common/triggers/misc/laser.qh | 3 - qcsrc/common/triggers/target/music.qc | 5 +- qcsrc/common/triggers/target/music.qh | 2 - qcsrc/common/triggers/trigger/impulse.qc | 6 +- qcsrc/common/triggers/trigger/impulse.qh | 4 - qcsrc/common/triggers/trigger/jumppads.qc | 12 +- qcsrc/common/triggers/trigger/jumppads.qh | 6 - qcsrc/common/triggers/trigger/keylock.qc | 6 +- qcsrc/common/triggers/trigger/keylock.qh | 1 - qcsrc/common/triggers/trigger/swamp.qc | 6 +- qcsrc/common/triggers/trigger/swamp.qh | 4 - qcsrc/common/triggers/trigger/viewloc.qc | 13 +- qcsrc/common/triggers/trigger/viewloc.qh | 3 - qcsrc/common/turrets/all.qc | 4 - qcsrc/common/turrets/cl_turrets.qc | 5 +- qcsrc/common/turrets/cl_turrets.qh | 6 - qcsrc/common/vehicles/cl_vehicles.qc | 11 +- qcsrc/common/vehicles/cl_vehicles.qh | 4 - qcsrc/common/vehicles/vehicle/bumblebee.qh | 1 - .../vehicles/vehicle/bumblebee_weapons.qc | 5 +- qcsrc/common/weapons/weapon/arc.qc | 6 +- qcsrc/lib/csqcmodel/cl_model.qc | 5 +- qcsrc/lib/csqcmodel/cl_model.qh | 2 - qcsrc/lib/oo.qh | 16 + qcsrc/lib/warpzone/client.qc | 22 +- qcsrc/lib/warpzone/client.qh | 5 - qcsrc/server/t_items.qc | 5 +- qcsrc/server/t_items.qh | 2 - 76 files changed, 357 insertions(+), 851 deletions(-) delete mode 100644 qcsrc/client/laser.qc delete mode 100644 qcsrc/client/laser.qh delete mode 100644 qcsrc/common/triggers/func/conveyor.qh delete mode 100644 qcsrc/common/triggers/func/plat.qh delete mode 100644 qcsrc/common/triggers/func/pointparticles.qh delete mode 100644 qcsrc/common/triggers/func/rainsnow.qh delete mode 100644 qcsrc/common/triggers/misc/corner.qh delete mode 100644 qcsrc/common/triggers/misc/include.qh delete mode 100644 qcsrc/common/triggers/misc/laser.qh delete mode 100644 qcsrc/common/turrets/cl_turrets.qh diff --git a/qcsrc/client/damage.qc b/qcsrc/client/damage.qc index 1151f2336..a0c169610 100644 --- a/qcsrc/client/damage.qc +++ b/qcsrc/client/damage.qc @@ -117,8 +117,8 @@ void DamageEffect(vector hitorg, float thedamage, int type, int specnum) self.total_damages += 1; } -void Ent_DamageInfo(float isNew) -{SELFPARAM(); +NET_HANDLE(ENT_CLIENT_DAMAGEINFO, bool isNew) +{ make_pure(this); float thedamage, rad, edge, thisdmg; bool hitplayer = false; @@ -139,6 +139,8 @@ void Ent_DamageInfo(float isNew) force = decompressShortVector(ReadShort()); species = ReadByte(); + return = true; + if (!isNew) return; diff --git a/qcsrc/client/damage.qh b/qcsrc/client/damage.qh index 3f11b9a49..8cbdf81e2 100644 --- a/qcsrc/client/damage.qh +++ b/qcsrc/client/damage.qh @@ -3,6 +3,4 @@ .float total_damages; // number of effects which currently are attached to a player -void Ent_DamageInfo(float isNew); - #endif diff --git a/qcsrc/client/hook.qc b/qcsrc/client/hook.qc index 452189a15..cee2a0cd8 100644 --- a/qcsrc/client/hook.qc +++ b/qcsrc/client/hook.qc @@ -162,9 +162,9 @@ void Remove_GrapplingHook() sound (self, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM); } -void Ent_ReadHook(float bIsNew, entity type) -{SELFPARAM(); - self.HookType = type; +NET_HANDLE(ENT_CLIENT_HOOK, bool bIsNew) +{ + self.HookType = NET_ENT_CLIENT_HOOK; int sf = ReadByte(); @@ -225,6 +225,7 @@ void Ent_ReadHook(float bIsNew, entity type) } self.teleport_time = time + 10; + return true; } // TODO: hook: temporarily transform self.origin for drawing the model along warpzones! diff --git a/qcsrc/client/hook.qh b/qcsrc/client/hook.qh index 29fd98304..36624255f 100644 --- a/qcsrc/client/hook.qh +++ b/qcsrc/client/hook.qh @@ -3,6 +3,4 @@ void Draw_CylindricLine(vector from, vector to, float thickness, string texture, float aspect, float shift, vector rgb, float theAlpha, float drawflag, vector vieworg); -void Ent_ReadHook(float bIsNew, entity type); - #endif diff --git a/qcsrc/client/laser.qc b/qcsrc/client/laser.qc deleted file mode 100644 index 1c63a0dc2..000000000 --- a/qcsrc/client/laser.qc +++ /dev/null @@ -1,128 +0,0 @@ -#include "laser.qh" - -#include "../lib/csqcmodel/interpolate.qh" - -// a laser goes from origin in direction angles -// it has color 'colormod' -// and stops when something is in the way -entityclass(Laser); -class(Laser) .int cnt; // end effect -class(Laser) .vector colormod; -class(Laser) .int state; // on-off -class(Laser) .int count; // flags for the laser -class(Laser) .vector velocity; -class(Laser) .float alpha; -class(Laser) .float scale; // scaling factor of the thickness -class(Laser) .float modelscale; // scaling factor of the dlight - -void Draw_Laser(entity this) -{ - if(!self.state) - return; - InterpolateOrigin_Do(); - if(self.count & 0x80) - { - if(self.count & 0x10) - { - trace_endpos = self.velocity; - trace_dphitq3surfaceflags = 0; - } - else - traceline(self.origin, self.velocity, 0, self); - } - else - { - if(self.count & 0x10) - { - makevectors(self.angles); - trace_endpos = self.origin + v_forward * 1048576; - trace_dphitq3surfaceflags = Q3SURFACEFLAG_SKY; - } - else - { - makevectors(self.angles); - traceline(self.origin, self.origin + v_forward * 32768, 0, self); - if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY) - trace_endpos = self.origin + v_forward * 1048576; - } - } - if(self.scale != 0) - { - if(self.alpha) - { - Draw_CylindricLine(self.origin, trace_endpos, self.scale, "particles/laserbeam", 0, time * 3, self.colormod, self.alpha, DRAWFLAG_NORMAL, view_origin); - } - else - { - Draw_CylindricLine(self.origin, trace_endpos, self.scale, "particles/laserbeam", 0, time * 3, self.colormod, 0.5, DRAWFLAG_ADDITIVE, view_origin); - } - } - if (!(trace_dphitq3surfaceflags & (Q3SURFACEFLAG_SKY | Q3SURFACEFLAG_NOIMPACT))) - { - if(self.cnt >= 0) - pointparticles(self.cnt, trace_endpos, trace_plane_normal, drawframetime * 1000); - if(self.colormod != '0 0 0' && self.modelscale != 0) - adddynamiclight(trace_endpos + trace_plane_normal * 1, self.modelscale, self.colormod * 5); - } -} - -void Ent_Laser() -{ - InterpolateOrigin_Undo(); - - // 30 bytes, or 13 bytes for just moving - int f = ReadByte(); - self.count = (f & 0xF0); - - if(self.count & 0x80) - self.iflags = IFLAG_VELOCITY | IFLAG_ORIGIN; - else - self.iflags = IFLAG_ANGLES | IFLAG_ORIGIN; - - if(f & 1) - { - self.origin_x = ReadCoord(); - self.origin_y = ReadCoord(); - self.origin_z = ReadCoord(); - setorigin(self, self.origin); - } - if(f & 8) - { - self.colormod_x = ReadByte() / 255.0; - self.colormod_y = ReadByte() / 255.0; - self.colormod_z = ReadByte() / 255.0; - if(f & 0x40) - self.alpha = ReadByte() / 255.0; - else - self.alpha = 0; - self.scale = 2; - self.modelscale = 50; - if(f & 0x20) - { - self.scale *= ReadByte() / 16.0; // beam radius - self.modelscale *= ReadByte() / 16.0; // dlight radius - } - if((f & 0x80) || !(f & 0x10)) - self.cnt = ReadShort() - 1; // effect number - else - self.cnt = 0; - } - if(f & 2) - { - if(f & 0x80) - { - self.velocity_x = ReadCoord(); - self.velocity_y = ReadCoord(); - self.velocity_z = ReadCoord(); - } - else - { - self.angles_x = ReadAngle(); - self.angles_y = ReadAngle(); - } - } - if(f & 4) - self.state = ReadByte(); - InterpolateOrigin_Note(); - self.draw = Draw_Laser; -} diff --git a/qcsrc/client/laser.qh b/qcsrc/client/laser.qh deleted file mode 100644 index 32c6cd81e..000000000 --- a/qcsrc/client/laser.qh +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef CLIENT_LASER_H -#define CLIENT_LASER_H - -void Ent_Laser(); - -#endif diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index 7980d518d..71765f5e0 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -5,7 +5,6 @@ #include "gibs.qh" #include "hook.qh" #include "hud/all.qh" -#include "laser.qh" #include "mapvoting.qh" #include "modeleffects.qh" #include "mutators/events.qh" @@ -24,7 +23,6 @@ #include "../common/minigames/cl_minigames_hud.qh" #include "../common/net_notice.qh" #include "../common/triggers/include.qh" -#include "../common/turrets/cl_turrets.qh" #include "../common/vehicles/all.qh" #include "../lib/csqcmodel/cl_model.qh" #include "../lib/csqcmodel/interpolate.qh" @@ -34,34 +32,11 @@ // BEGIN REQUIRED CSQC FUNCTIONS //include "main.qh" -entity clearentity_ent; -void clearentity(entity e) -{ - if (!clearentity_ent) - { - clearentity_ent = new(clearentity); - } - int n = e.entnum; - copyentity(clearentity_ent, e); - e.entnum = n; -} - #define DP_CSQC_ENTITY_REMOVE_IS_B0RKED -void menu_show_error() -{ - drawstring('0 200 0', _("ERROR - MENU IS VISIBLE BUT NO MENU WAS DEFINED!"), '8 8 0', '1 0 0', 1, 0); -} // CSQC_Init : Called every time the CSQC code is initialized (essentially at map load) // Useful for precaching things -void menu_sub_null() -{ -} - -void draw_null(entity this) { } - -string forcefog; void ConsoleCommand_macro_init(); void CSQC_Init() { @@ -71,22 +46,20 @@ void CSQC_Init() LOG_TRACEF("^4CSQC Build information: ^1%s\n", WATERMARK); #endif - int i; - binddb = db_create(); tempdb = db_create(); ClientProgsDB = db_load("client.db"); compressShortVector_init(); draw_endBoldFont(); - menu_visible = false; - menu_show = menu_show_error; - menu_action = func_null; - for(i = 0; i < 255; ++i) - if(getplayerkeyvalue(i, "viewentity") == "") - break; - maxclients = i; + { + int i = 0; + for ( ; i < 255; ++i) + if (getplayerkeyvalue(i, "viewentity") == "") + break; + maxclients = i; + } //registercommand("hud_configure"); //registercommand("hud_save"); @@ -110,7 +83,7 @@ void CSQC_Init() gametype = 0; // hud_fields uses strunzone on the titles! - for(i = 0; i < MAX_HUD_FIELDS; ++i) + for(int i = 0; i < MAX_HUD_FIELDS; ++i) hud_title[i] = strzone("(null)"); Cmd_HUD_SetFields(0); @@ -131,34 +104,31 @@ void CSQC_Init() // precaches - Projectile_Precache(); - Tuba_Precache(); - if(autocvar_cl_reticle) { precache_pic("gfx/reticle_normal"); // weapon reticles are precached in weapon files } - get_mi_min_max_texcoords(1); // try the CLEVER way first - minimapname = strcat("gfx/", mi_shortname, "_radar.tga"); - shortmapname = mi_shortname; - - if(precache_pic(minimapname) == "") { - // but maybe we have a non-clever minimap - minimapname = strcat("gfx/", mi_shortname, "_mini.tga"); - if(precache_pic(minimapname) == "") - minimapname = ""; // FAIL - else - get_mi_min_max_texcoords(0); // load new texcoords - } + get_mi_min_max_texcoords(1); // try the CLEVER way first + minimapname = strcat("gfx/", mi_shortname, "_radar.tga"); + shortmapname = mi_shortname; - mi_center = (mi_min + mi_max) * 0.5; - mi_scale = mi_max - mi_min; - minimapname = strzone(minimapname); + if (precache_pic(minimapname) == "") + { + // but maybe we have a non-clever minimap + minimapname = strcat("gfx/", mi_shortname, "_mini.tga"); + if (precache_pic(minimapname) == "") + minimapname = ""; // FAIL + else + get_mi_min_max_texcoords(0); // load new texcoords + } - WarpZone_Init(); + mi_center = (mi_min + mi_max) * 0.5; + mi_scale = mi_max - mi_min; + minimapname = strzone(minimapname); + } hud_skin_path = strzone(strcat("gfx/hud/", autocvar_hud_skin)); draw_currentSkin = strzone(strcat("gfx/menu/", cvar_string("menu_skin"))); @@ -271,7 +241,8 @@ float SetTeam(entity o, int Team) } void Playerchecker_Think() -{SELFPARAM(); +{ + SELFPARAM(); int i; entity e; for(i = 0; i < maxclients; ++i) @@ -309,7 +280,7 @@ void Playerchecker_Think() } } } - self.nextthink = time + 0.2; + this.nextthink = time + 0.2; } void Porto_Init(); @@ -336,16 +307,13 @@ void PostInit() // In the case of mouse input after a setcursormode(1) call, nPrimary is xpos, nSecondary is ypos. float CSQC_InputEvent(float bInputType, float nPrimary, float nSecondary) { - float bSkipKey; - bSkipKey = false; - if (HUD_Panel_InputEvent(bInputType, nPrimary, nSecondary)) return true; if (QuickMenu_InputEvent(bInputType, nPrimary, nSecondary)) return true; - if ( HUD_Radar_InputEvent(bInputType, nPrimary, nSecondary) ) + if (HUD_Radar_InputEvent(bInputType, nPrimary, nSecondary)) return true; if (MapVote_InputEvent(bInputType, nPrimary, nSecondary)) @@ -354,11 +322,7 @@ float CSQC_InputEvent(float bInputType, float nPrimary, float nSecondary) if (HUD_Minigame_InputEvent(bInputType, nPrimary, nSecondary)) return true; - if(menu_visible && menu_action) - if(menu_action(bInputType, nPrimary, nSecondary)) - return true; - - return bSkipKey; + return false; } // END REQUIRED CSQC FUNCTIONS @@ -368,38 +332,42 @@ float CSQC_InputEvent(float bInputType, float nPrimary, float nSecondary) // BEGIN OPTIONAL CSQC FUNCTIONS void Ent_RemoveEntCS() -{SELFPARAM(); - entcs_receiver[self.sv_entnum] = NULL; +{ + SELFPARAM(); + entcs_receiver[this.sv_entnum] = NULL; } -void Ent_ReadEntCS() -{SELFPARAM(); + +NET_HANDLE(ENT_CLIENT_ENTCS, bool isnew) +{ make_pure(this); this.classname = "entcs_receiver"; InterpolateOrigin_Undo(); int sf = ReadByte(); if(sf & BIT(0)) - self.sv_entnum = ReadByte(); + this.sv_entnum = ReadByte(); if (sf & BIT(1)) { - self.origin_x = ReadShort(); - self.origin_y = ReadShort(); - self.origin_z = ReadShort(); - setorigin(self, self.origin); + this.origin_x = ReadShort(); + this.origin_y = ReadShort(); + this.origin_z = ReadShort(); + setorigin(this, this.origin); } if (sf & BIT(2)) { - self.angles_y = ReadByte() * 360.0 / 256; - self.angles_x = self.angles_z = 0; + this.angles_y = ReadByte() * 360.0 / 256; + this.angles_x = this.angles_z = 0; } if (sf & BIT(3)) - self.healthvalue = ReadByte() * 10; + this.healthvalue = ReadByte() * 10; if (sf & BIT(4)) - self.armorvalue = ReadByte() * 10; + this.armorvalue = ReadByte() * 10; + + return = true; - entcs_receiver[self.sv_entnum] = self; - self.entremove = Ent_RemoveEntCS; - self.iflags |= IFLAG_ORIGIN; + entcs_receiver[this.sv_entnum] = this; + this.entremove = Ent_RemoveEntCS; + this.iflags |= IFLAG_ORIGIN; InterpolateOrigin_Note(); } @@ -407,18 +375,19 @@ void Ent_ReadEntCS() void Ent_Remove(); void Ent_RemovePlayerScore() -{SELFPARAM(); - if(self.owner) { - SetTeam(self.owner, -1); - self.owner.gotscores = 0; +{ + SELFPARAM(); + if(this.owner) { + SetTeam(this.owner, -1); + this.owner.gotscores = 0; for(int i = 0; i < MAX_SCORE; ++i) { - self.owner.(scores[i]) = 0; // clear all scores + this.owner.(scores[i]) = 0; // clear all scores } } } -void Ent_ReadPlayerScore() -{SELFPARAM(); +NET_HANDLE(ENT_CLIENT_SCORES, bool isnew) +{ make_pure(this); int i, n; bool isNew; @@ -426,29 +395,29 @@ void Ent_ReadPlayerScore() // damnit -.- don't want to go change every single .sv_entnum in hud.qc AGAIN // (no I've never heard of M-x replace-string, sed, or anything like that) - isNew = !self.owner; // workaround for DP bug + isNew = !this.owner; // workaround for DP bug n = ReadByte()-1; #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED - if(!isNew && n != self.sv_entnum) + if(!isNew && n != this.sv_entnum) { //print("A CSQC entity changed its owner!\n"); - LOG_INFOF("A CSQC entity changed its owner! (edict: %d, classname: %s)\n", num_for_edict(self), self.classname); + LOG_INFOF("A CSQC entity changed its owner! (edict: %d, classname: %s)\n", num_for_edict(this), this.classname); isNew = true; Ent_Remove(); } #endif - self.sv_entnum = n; + this.sv_entnum = n; - o = playerslots[self.sv_entnum]; + o = playerslots[this.sv_entnum]; if (!o) { - o = playerslots[self.sv_entnum] = new(playerslot); + o = playerslots[this.sv_entnum] = new(playerslot); make_pure(o); } - self.owner = o; - o.sv_entnum = self.sv_entnum; + this.owner = o; + o.sv_entnum = this.sv_entnum; o.gotscores = 1; //if (!o.sort_prev) @@ -473,20 +442,22 @@ void Ent_ReadPlayerScore() o.(scores[i]) = ReadChar(); } + return = true; + if(o.sort_prev) HUD_UpdatePlayerPos(o); // if not registered, we cannot do this yet! - self.entremove = Ent_RemovePlayerScore; + this.entremove = Ent_RemovePlayerScore; } -void Ent_ReadTeamScore() -{SELFPARAM(); +NET_HANDLE(ENT_CLIENT_TEAMSCORES, bool isnew) +{ make_pure(this); int i; entity o; - self.team = ReadByte(); - o = self.owner = GetTeam(self.team, true); // these team numbers can always be trusted + this.team = ReadByte(); + o = this.owner = GetTeam(this.team, true); // these team numbers can always be trusted int sf, lf; #if MAX_TEAMSCORE <= 8 @@ -506,12 +477,14 @@ void Ent_ReadTeamScore() o.(teamscores[i]) = ReadChar(); } + return = true; + HUD_UpdateTeamPos(o); } -void Ent_ClientData() +NET_HANDLE(ENT_CLIENT_CLIENTDATA, bool isnew) { - make_pure(self); + make_pure(this); float newspectatee_status; int f = ReadByte(); @@ -539,6 +512,8 @@ void Ent_ClientData() else angles_held_status = 0; + return = true; + if(newspectatee_status != spectatee_status) { // clear race stuff @@ -559,9 +534,9 @@ void Ent_ClientData() // we could get rid of spectatee_status, and derive it from player_localentnum and player_localnum } -void Ent_Nagger() +NET_HANDLE(ENT_CLIENT_NAGGER, bool isnew) { - make_pure(self); + make_pure(this); int i, j, b, f; int nags = ReadByte(); // NAGS NAGS NAGS NAGS NAGS NAGS NADZ NAGS NAGS NAGS @@ -608,6 +583,8 @@ void Ent_Nagger() } } + return = true; + ready_waiting = (nags & BIT(0)); ready_waiting_for_me = (nags & BIT(1)); vote_waiting = (nags & BIT(2)); @@ -615,9 +592,9 @@ void Ent_Nagger() warmup_stage = (nags & BIT(4)); } -void Ent_EliminatedPlayers() +NET_HANDLE(ENT_CLIENT_ELIMINATEDPLAYERS, bool isnew) { - make_pure(self); + make_pure(this); int i, j, b, f; int sf = ReadByte(); @@ -635,24 +612,26 @@ void Ent_EliminatedPlayers() playerslots[j].eliminated = 0; } } + return true; } -void Ent_RandomSeed() +NET_HANDLE(ENT_CLIENT_RANDOMSEED, bool isnew) { - make_pure(self); + make_pure(this); prandom_debug(); float s = ReadShort(); psrandom(s); + return true; } -void Ent_ReadAccuracy() +NET_HANDLE(ENT_CLIENT_ACCURACY, bool isnew) { - make_pure(self); + make_pure(this); int sf = ReadInt24_t(); if (sf == 0) { for (int w = 0; w <= WEP_LAST - WEP_FIRST; ++w) weapon_accuracy[w] = -1; - return; + return true; } int f = 1; @@ -668,6 +647,7 @@ void Ent_ReadAccuracy() } f = (f == 0x800000) ? 1 : f * 2; } + return true; } void Spawn_Draw(entity this) @@ -675,8 +655,8 @@ void Spawn_Draw(entity this) __pointparticles(this.cnt, this.origin + '0 0 28', '0 0 2', bound(0, frametime, 0.1)); } -void Ent_ReadSpawnPoint(float is_new) // entity for spawnpoint -{SELFPARAM(); +NET_HANDLE(ENT_CLIENT_SPAWNPOINT, bool is_new) +{ float teamnum = (ReadByte() - 1); vector spn_origin; spn_origin.x = ReadShort(); @@ -685,19 +665,19 @@ void Ent_ReadSpawnPoint(float is_new) // entity for spawnpoint //if(is_new) //{ - self.origin = spn_origin; - setsize(self, PL_MIN_CONST, PL_MAX_CONST); + this.origin = spn_origin; + setsize(this, PL_MIN_CONST, PL_MAX_CONST); //droptofloor(); /*if(autocvar_cl_spawn_point_model) // needs a model first { - self.mdl = "models/spawnpoint.md3"; - self.colormod = Team_ColorRGB(teamnum); - precache_model(self.mdl); - setmodel(self, self.mdl); - self.drawmask = MASK_NORMAL; - //self.movetype = MOVETYPE_NOCLIP; - //self.draw = Spawn_Draw; + this.mdl = "models/spawnpoint.md3"; + this.colormod = Team_ColorRGB(teamnum); + precache_model(this.mdl); + setmodel(this, this.mdl); + this.drawmask = MASK_NORMAL; + //this.movetype = MOVETYPE_NOCLIP; + //this.draw = Spawn_Draw; }*/ if(autocvar_cl_spawn_point_particles) { @@ -705,24 +685,25 @@ void Ent_ReadSpawnPoint(float is_new) // entity for spawnpoint { switch(teamnum) { - case NUM_TEAM_1: self.cnt = particleeffectnum(EFFECT_SPAWNPOINT_RED); break; - case NUM_TEAM_2: self.cnt = particleeffectnum(EFFECT_SPAWNPOINT_BLUE); break; - case NUM_TEAM_3: self.cnt = particleeffectnum(EFFECT_SPAWNPOINT_YELLOW); break; - case NUM_TEAM_4: self.cnt = particleeffectnum(EFFECT_SPAWNPOINT_PINK); break; - default: self.cnt = particleeffectnum(EFFECT_SPAWNPOINT_NEUTRAL); break; + case NUM_TEAM_1: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_RED); break; + case NUM_TEAM_2: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_BLUE); break; + case NUM_TEAM_3: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_YELLOW); break; + case NUM_TEAM_4: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_PINK); break; + default: this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_NEUTRAL); break; } } - else { self.cnt = particleeffectnum(EFFECT_SPAWNPOINT_NEUTRAL); } + else { this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_NEUTRAL); } - self.draw = Spawn_Draw; + this.draw = Spawn_Draw; } //} - //printf("Ent_ReadSpawnPoint(is_new = %d); origin = %s, team = %d, effect = %d\n", is_new, vtos(self.origin), teamnum, self.cnt); + //printf("Ent_ReadSpawnPoint(is_new = %d); origin = %s, team = %d, effect = %d\n", is_new, vtos(this.origin), teamnum, this.cnt); + return true; } -void Ent_ReadSpawnEvent(float is_new) -{SELFPARAM(); +NET_HANDLE(ENT_CLIENT_SPAWNEVENT, bool is_new) +{ // If entnum is 0, ONLY do the local spawn actions // this way the server can disable the sending of // spawn origin or such to clients if wanted. @@ -730,9 +711,9 @@ void Ent_ReadSpawnEvent(float is_new) if(entnum) { - self.origin_x = ReadShort(); - self.origin_y = ReadShort(); - self.origin_z = ReadShort(); + this.origin_x = ReadShort(); + this.origin_y = ReadShort(); + this.origin_z = ReadShort(); if(is_new) { @@ -742,19 +723,20 @@ void Ent_ReadSpawnEvent(float is_new) { switch(teamnum) { - case NUM_TEAM_1: pointparticles(EFFECT_SPAWN_RED, self.origin, '0 0 0', 1); break; - case NUM_TEAM_2: pointparticles(EFFECT_SPAWN_BLUE, self.origin, '0 0 0', 1); break; - case NUM_TEAM_3: pointparticles(EFFECT_SPAWN_YELLOW, self.origin, '0 0 0', 1); break; - case NUM_TEAM_4: pointparticles(EFFECT_SPAWN_PINK, self.origin, '0 0 0', 1); break; - default: pointparticles(EFFECT_SPAWN_NEUTRAL, self.origin, '0 0 0', 1); break; + case NUM_TEAM_1: pointparticles(EFFECT_SPAWN_RED, this.origin, '0 0 0', 1); break; + case NUM_TEAM_2: pointparticles(EFFECT_SPAWN_BLUE, this.origin, '0 0 0', 1); break; + case NUM_TEAM_3: pointparticles(EFFECT_SPAWN_YELLOW, this.origin, '0 0 0', 1); break; + case NUM_TEAM_4: pointparticles(EFFECT_SPAWN_PINK, this.origin, '0 0 0', 1); break; + default: pointparticles(EFFECT_SPAWN_NEUTRAL, this.origin, '0 0 0', 1); break; } } if(autocvar_cl_spawn_event_sound) { - sound(self, CH_TRIGGER, SND_SPAWN, VOL_BASE, ATTEN_NORM); + sound(this, CH_TRIGGER, SND_SPAWN, VOL_BASE, ATTEN_NORM); } } } + return = true; // local spawn actions if(is_new && (!entnum || (entnum == player_localentnum))) @@ -769,14 +751,11 @@ void Ent_ReadSpawnEvent(float is_new) } } HUD_Radar_Hide_Maximized(); - //printf("Ent_ReadSpawnEvent(is_new = %d); origin = %s, entnum = %d, localentnum = %d\n", is_new, vtos(self.origin), entnum, player_localentnum); + //printf("Ent_ReadSpawnEvent(is_new = %d); origin = %s, entnum = %d, localentnum = %d\n", is_new, vtos(this.origin), entnum, player_localentnum); } // CSQC_Ent_Update : Called every frame that the server has indicated an update to the SSQC / CSQC entity has occured. // The only parameter reflects if the entity is "new" to the client, meaning it just came into the client's PVS. -void Ent_RadarLink(); -void Ent_Init(); -void Ent_ScoresInfo(); void CSQC_Ent_Update(float bIsNewEntity) { SELFPARAM(); @@ -822,7 +801,7 @@ void CSQC_Ent_Update(float bIsNewEntity) FOREACH(LinkedEntities, it.m_id == t, LAMBDA( this.classname = it.netname; if (autocvar_developer_csqcentities) - 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); + LOG_INFOF("CSQC_Ent_Update(%d) with this=%i {.entnum=%d, .enttype=%d} t=%s (%d)\n", bIsNewEntity, this, this.entnum, this.enttype, it.netname, t); done = it.m_read(this, bIsNewEntity); break; )); @@ -833,292 +812,45 @@ void CSQC_Ent_Update(float bIsNewEntity) error(sprintf("Unknown entity type in CSQC_Ent_Update (enttype: %d, edict: %d, classname: %s)\n", this.enttype, num_for_edict(this), this.classname)); } } -NET_HANDLE(ENT_CLIENT_ENTCS, bool isnew) -{ - Ent_ReadEntCS(); - return true; -} -NET_HANDLE(ENT_CLIENT_SCORES, bool isnew) -{ - Ent_ReadPlayerScore(); - return true; -} -NET_HANDLE(ENT_CLIENT_TEAMSCORES, bool isnew) -{ - Ent_ReadTeamScore(); - return true; -} -NET_HANDLE(ENT_CLIENT_POINTPARTICLES, bool isnew) -{ - Ent_PointParticles(); - return true; -} -NET_HANDLE(ENT_CLIENT_RAINSNOW, bool isnew) -{ - Ent_RainOrSnow(); - return true; -} -NET_HANDLE(ENT_CLIENT_LASER, bool isnew) -{ - Ent_Laser(); - return true; -} -NET_HANDLE(ENT_CLIENT_NAGGER, bool isnew) -{ - Ent_Nagger(); - return true; -} -NET_HANDLE(ENT_CLIENT_ELIMINATEDPLAYERS, bool isnew) -{ - Ent_EliminatedPlayers(); - return true; -} -NET_HANDLE(ENT_CLIENT_RADARLINK, bool isnew) -{ - Ent_RadarLink(); - return true; -} -NET_HANDLE(ENT_CLIENT_PROJECTILE, bool isnew) -{ - Ent_Projectile(); - return true; -} -NET_HANDLE(ENT_CLIENT_DAMAGEINFO, bool isnew) -{ - Ent_DamageInfo(isnew); - return true; -} -NET_HANDLE(ENT_CLIENT_INIT, bool isnew) -{ - Ent_Init(); - return true; -} -NET_HANDLE(ENT_CLIENT_SCORES_INFO, bool isnew) -{ - Ent_ScoresInfo(); - return true; -} -NET_HANDLE(ENT_CLIENT_MAPVOTE, bool isnew) -{ - Ent_MapVote(); - return true; -} -NET_HANDLE(ENT_CLIENT_CLIENTDATA, bool isnew) -{ - Ent_ClientData(); - return true; -} -NET_HANDLE(ENT_CLIENT_RANDOMSEED, bool isnew) -{ - Ent_RandomSeed(); - return true; -} -NET_HANDLE(ENT_CLIENT_WALL, bool isnew) -{ - Ent_Wall(); - return true; -} -NET_HANDLE(ENT_CLIENT_MODELEFFECT, bool isnew) -{ - Ent_ModelEffect(isnew); - return true; -} -NET_HANDLE(ENT_CLIENT_TUBANOTE, bool isnew) -{ - Ent_TubaNote(isnew); - return true; -} -NET_HANDLE(ENT_CLIENT_WARPZONE, bool isnew) -{ - WarpZone_Read(isnew); - return true; -} -NET_HANDLE(ENT_CLIENT_WARPZONE_CAMERA, bool isnew) -{ - WarpZone_Camera_Read(isnew); - return true; -} -NET_HANDLE(ENT_CLIENT_WARPZONE_TELEPORTED, bool isnew) -{ - WarpZone_Teleported_Read(isnew); - return true; -} -NET_HANDLE(ENT_CLIENT_TRIGGER_MUSIC, bool isnew) -{ - Ent_ReadTriggerMusic(); - return true; -} -NET_HANDLE(ENT_CLIENT_HOOK, bool isnew) -{ - Ent_ReadHook(isnew, NET_ENT_CLIENT_HOOK); - return true; -} -NET_HANDLE(ENT_CLIENT_INVENTORY, bool isnew) -{ - Inventory_Read(this); - return true; -} -NET_HANDLE(ENT_CLIENT_ARC_BEAM, bool isnew) -{ - Ent_ReadArcBeam(isnew); - return true; -} -NET_HANDLE(ENT_CLIENT_ACCURACY, bool isnew) -{ - Ent_ReadAccuracy(); - return true; -} -NET_HANDLE(ENT_CLIENT_AUXILIARYXHAIR, bool isnew) -{ - Net_AuXair2(isnew); - return true; -} -NET_HANDLE(ENT_CLIENT_TURRET, bool isnew) -{ - ent_turret(); - return true; -} -NET_HANDLE(ENT_CLIENT_MODEL, bool isnew) -{ - CSQCModel_Read(isnew); - return true; -} -NET_HANDLE(ENT_CLIENT_ITEM, bool isnew) -{ - ItemRead(isnew); - return true; -} -NET_HANDLE(ENT_CLIENT_BUMBLE_RAYGUN, bool isnew) -{ - bumble_raygun_read(isnew); - return true; -} -NET_HANDLE(ENT_CLIENT_SPAWNPOINT, bool isnew) -{ - Ent_ReadSpawnPoint(isnew); - return true; -} -NET_HANDLE(ENT_CLIENT_SPAWNEVENT, bool isnew) -{ - Ent_ReadSpawnEvent(isnew); - return true; -} -NET_HANDLE(ENT_CLIENT_NOTIFICATION, bool isnew) -{ - Read_Notification(isnew); - return true; -} -NET_HANDLE(ENT_CLIENT_MINIGAME, bool isnew) -{ - ent_read_minigame(); - return true; -} -NET_HANDLE(ENT_CLIENT_VIEWLOC, bool isnew) -{ - ent_viewloc(); - return true; -} -NET_HANDLE(ENT_CLIENT_VIEWLOC_TRIGGER, bool isnew) -{ - ent_viewloc_trigger(); - return true; -} -NET_HANDLE(ENT_CLIENT_LADDER, bool isnew) -{ - ent_func_ladder(); - return true; -} -NET_HANDLE(ENT_CLIENT_TRIGGER_PUSH, bool isnew) -{ - ent_trigger_push(); - return true; -} -NET_HANDLE(ENT_CLIENT_TARGET_PUSH, bool isnew) -{ - ent_target_push(); - return true; -} -NET_HANDLE(ENT_CLIENT_CONVEYOR, bool isnew) -{ - ent_conveyor(); - return true; -} -NET_HANDLE(ENT_CLIENT_DOOR, bool isnew) -{ - ent_door(); - return true; -} -NET_HANDLE(ENT_CLIENT_PLAT, bool isnew) -{ - ent_plat(); - return true; -} -NET_HANDLE(ENT_CLIENT_SWAMP, bool isnew) -{ - ent_swamp(); - return true; -} -NET_HANDLE(ENT_CLIENT_CORNER, bool isnew) -{ - ent_corner(); - return true; -} -NET_HANDLE(ENT_CLIENT_KEYLOCK, bool isnew) -{ - ent_keylock(); - return true; -} -NET_HANDLE(ENT_CLIENT_TRAIN, bool isnew) -{ - ent_train(); - return true; -} -NET_HANDLE(ENT_CLIENT_TRIGGER_IMPULSE, bool isnew) -{ - ent_trigger_impulse(); - return true; -} // Destructor, but does NOT deallocate the entity by calling remove(). Also // used when an entity changes its type. For an entity that someone interacts // with others, make sure it can no longer do so. void Ent_Remove() -{SELFPARAM(); - if(self.entremove) - self.entremove(); +{ + SELFPARAM(); + if(this.entremove) this.entremove(); - if(self.skeletonindex) + if(this.skeletonindex) { - skel_delete(self.skeletonindex); - self.skeletonindex = 0; + skel_delete(this.skeletonindex); + this.skeletonindex = 0; } - if(self.snd_looping > 0) + if(this.snd_looping > 0) { - sound(self, self.snd_looping, SND_Null, VOL_BASE, autocvar_g_jetpack_attenuation); - self.snd_looping = 0; + sound(this, this.snd_looping, SND_Null, VOL_BASE, autocvar_g_jetpack_attenuation); + this.snd_looping = 0; } - self.enttype = 0; - self.classname = ""; - self.draw = draw_null; - self.entremove = menu_sub_null; + this.enttype = 0; + this.classname = ""; + this.draw = func_null; + this.entremove = func_null; // TODO possibly set more stuff to defaults } -// CSQC_Ent_Remove : Called when the server requests a SSQC / CSQC entity to be removed. Essentially call remove(self) as well. +// CSQC_Ent_Remove : Called when the server requests a SSQC / CSQC entity to be removed. Essentially call remove(this) as well. void CSQC_Ent_Remove() -{SELFPARAM(); - if(autocvar_developer_csqcentities) - LOG_INFOF("CSQC_Ent_Remove() with self=%i self.entnum=%d self.enttype=%d\n", self, self.entnum, self.enttype); - - if(wasfreed(self)) +{ + SELFPARAM(); + if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Ent_Remove() with this=%i {.entnum=%d, .enttype=%d}\n", this, this.entnum, this.enttype); + if (wasfreed(this)) { - LOG_INFO("WARNING: CSQC_Ent_Remove called for already removed entity. Packet loss?\n"); + LOG_WARNING("CSQC_Ent_Remove called for already removed entity. Packet loss?\n"); return; } - if(self.enttype) - Ent_Remove(); - remove(self); + if (this.enttype) Ent_Remove(); + remove(this); } void Gamemode_Init() @@ -1133,68 +865,79 @@ void Gamemode_Init() // 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. void CSQC_Parse_StuffCmd(string strMessage) { - if(autocvar_developer_csqcentities) - LOG_INFOF("CSQC_Parse_StuffCmd(\"%s\")\n", strMessage); - + if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Parse_StuffCmd(\"%s\")\n", strMessage); localcmd(strMessage); } // 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. void CSQC_Parse_Print(string strMessage) { - if(autocvar_developer_csqcentities) - LOG_INFOF("CSQC_Parse_Print(\"%s\")\n", strMessage); - + if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Parse_Print(\"%s\")\n", strMessage); print(ColorTranslateRGB(strMessage)); } // CSQC_Parse_CenterPrint : Provides the centerprint_hud string in the first parameter that the server provided. void CSQC_Parse_CenterPrint(string strMessage) { - if(autocvar_developer_csqcentities) - LOG_INFOF("CSQC_Parse_CenterPrint(\"%s\")\n", strMessage); - + if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Parse_CenterPrint(\"%s\")\n", strMessage); centerprint_hud(strMessage); } -string notranslate_fogcmd1 = "\nfog "; -string notranslate_fogcmd2 = "\nr_fog_exp2 0\nr_drawfog 1\n"; -void Fog_Force() +// CSQC_Parse_TempEntity : Handles all temporary entity network data in the CSQC layer. +// You must ALWAYS first acquire the temporary ID, which is sent as a byte. +// Return value should be 1 if CSQC handled the temporary entity, otherwise return 0 to have the engine process the event. +bool CSQC_Parse_TempEntity() { - // TODO somehow thwart prvm_globalset client ... + // Acquire TE ID + int nTEID = ReadByte(); - if(autocvar_cl_orthoview && autocvar_cl_orthoview_nofog) - { localcmd("\nr_drawfog 0\n"); } - else if(forcefog != "") - { localcmd(strcat(notranslate_fogcmd1, forcefog, notranslate_fogcmd2)); } + FOREACH(TempEntities, it.m_id == nTEID, LAMBDA( + if (autocvar_developer_csqcentities) + LOG_INFOF("CSQC_Parse_TempEntity() nTEID=%s (%d)\n", it.netname, nTEID); + return it.m_read(NULL, true); + )); + + if (autocvar_developer_csqcentities) + LOG_INFOF("CSQC_Parse_TempEntity() with nTEID=%d\n", nTEID); + + // No special logic for this temporary entity; return 0 so the engine can handle it + return false; +} + +/** TODO somehow thwart prvm_globalset client ... */ +string forcefog; +void Fog_Force() +{ + if (autocvar_cl_orthoview && autocvar_cl_orthoview_nofog) + localcmd("\nr_drawfog 0\n"); + else if (forcefog != "") + localcmd(sprintf("\nfog %s\nr_fog_exp2 0\nr_drawfog 1\n", forcefog)); } void Gamemode_Init(); -void Ent_ScoresInfo() -{SELFPARAM(); - int i; +NET_HANDLE(ENT_CLIENT_SCORES_INFO, bool isnew) +{ make_pure(this); gametype = ReadInt24_t(); HUD_ModIcons_SetFunc(); - for(i = 0; i < MAX_SCORE; ++i) + for (int i = 0; i < MAX_SCORE; ++i) { - if(scores_label[i]) - strunzone(scores_label[i]); + if (scores_label[i]) strunzone(scores_label[i]); scores_label[i] = strzone(ReadString()); scores_flags[i] = ReadByte(); } - for(i = 0; i < MAX_TEAMSCORE; ++i) + for (int i = 0; i < MAX_TEAMSCORE; ++i) { - if(teamscores_label[i]) - strunzone(teamscores_label[i]); + if (teamscores_label[i]) strunzone(teamscores_label[i]); teamscores_label[i] = strzone(ReadString()); teamscores_flags[i] = ReadByte(); } + return = true; HUD_InitScores(); Gamemode_Init(); } -void Ent_Init() -{SELFPARAM(); +NET_HANDLE(ENT_CLIENT_INIT, bool isnew) +{ make_pure(this); nb_pb_period = ReadByte() / 32; //Accuracy of 1/32th @@ -1208,8 +951,7 @@ void Ent_Init() arc_shotorigin[2] = decompressShotOrigin(ReadInt24_t()); arc_shotorigin[3] = decompressShotOrigin(ReadInt24_t()); - if(forcefog) - strunzone(forcefog); + if (forcefog) strunzone(forcefog); forcefog = strzone(ReadString()); armorblockpercent = ReadByte() / 255.0; @@ -1230,20 +972,18 @@ void Ent_Init() g_trueaim_minrange = ReadCoord(); g_balance_porto_secondary = ReadByte(); + return = true; MUTATOR_CALLHOOK(Ent_Init); - if(!postinit) - PostInit(); + if (!postinit) PostInit(); } -void Net_ReadRace() +NET_HANDLE(TE_CSQC_RACE, bool isNew) { - float b; + int b = ReadByte(); - b = ReadByte(); - - switch(b) + switch (b) { case RACE_NET_CHECKPOINT_HIT_QUALIFYING: race_checkpoint = ReadByte(); @@ -1391,11 +1131,6 @@ void Net_ReadRace() strunzone(race_status_name); race_status_name = strzone(ReadString()); } -} - -NET_HANDLE(TE_CSQC_RACE, bool isNew) -{ - Net_ReadRace(); return true; } @@ -1405,34 +1140,27 @@ NET_HANDLE(TE_CSQC_TEAMNAGGER, bool isNew) return true; } -void Net_ReadPingPLReport() -{ - int e, pi, pl, ml; - e = ReadByte(); - pi = ReadShort(); - pl = ReadByte(); - ml = ReadByte(); - if (!(playerslots[e])) - return; - playerslots[e].ping = pi; - playerslots[e].ping_packetloss = pl / 255.0; - playerslots[e].ping_movementloss = ml / 255.0; -} NET_HANDLE(TE_CSQC_PINGPLREPORT, bool isNew) { - Net_ReadPingPLReport(); - return true; + int i = ReadByte(); + int pi = ReadShort(); + int pl = ReadByte(); + int ml = ReadByte(); + return = true; + entity e = playerslots[i]; + if (!e) return; + e.ping = pi; + e.ping_packetloss = pl / 255.0; + e.ping_movementloss = ml / 255.0; } -void Net_WeaponComplain() +NET_HANDLE(TE_CSQC_WEAPONCOMPLAIN, bool isNew) { complain_weapon = ReadByte(); - - if(complain_weapon_name) - strunzone(complain_weapon_name); + if (complain_weapon_name) strunzone(complain_weapon_name); complain_weapon_name = strzone(WEP_NAME(complain_weapon)); - complain_weapon_type = ReadByte(); + return = true; complain_weapon_time = time; weapontime = time; // ping the weapon panel @@ -1444,32 +1172,6 @@ void Net_WeaponComplain() default: Local_Notification(MSG_MULTI, ITEM_WEAPON_UNAVAILABLE, complain_weapon); break; } } -NET_HANDLE(TE_CSQC_WEAPONCOMPLAIN, bool isNew) -{ - Net_WeaponComplain(); - return true; -} - -// CSQC_Parse_TempEntity : Handles all temporary entity network data in the CSQC layer. -// You must ALWAYS first acquire the temporary ID, which is sent as a byte. -// Return value should be 1 if CSQC handled the temporary entity, otherwise return 0 to have the engine process the event. -bool CSQC_Parse_TempEntity() -{ - // Acquire TE ID - int nTEID = ReadByte(); - - FOREACH(TempEntities, it.m_id == nTEID, LAMBDA( - if (autocvar_developer_csqcentities) - LOG_INFOF("CSQC_Parse_TempEntity() nTEID=%s (%d)\n", it.netname, nTEID); - return it.m_read(NULL, true); - )); - - if (autocvar_developer_csqcentities) - LOG_INFOF("CSQC_Parse_TempEntity() with nTEID=%d\n", nTEID); - - // No special logic for this temporary entity; return 0 so the engine can handle it - return false; -} string getcommandkey(string text, string command) { diff --git a/qcsrc/client/main.qh b/qcsrc/client/main.qh index 7b4bb636b..e020cbecd 100644 --- a/qcsrc/client/main.qh +++ b/qcsrc/client/main.qh @@ -13,13 +13,6 @@ const float DATABUF_PING = 0; #define DATABUF_NEXT (5*maxclients) -void() menu_show_error; -void() menu_sub_null; - -float menu_visible; -var void() menu_show; -var float(float bInputType, float nPrimary, float nSecondary) menu_action; - // -------------------------------------------------------------------------- // Onslaught diff --git a/qcsrc/client/mapvoting.qc b/qcsrc/client/mapvoting.qc index e528187f4..a134357aa 100644 --- a/qcsrc/client/mapvoting.qc +++ b/qcsrc/client/mapvoting.qc @@ -851,10 +851,11 @@ void MapVote_UpdateVotes() mv_ownvote = ReadByte()-1; } -void Ent_MapVote() +NET_HANDLE(ENT_CLIENT_MAPVOTE, bool isnew) { make_pure(self); int sf = ReadByte(); + return = true; if(sf & 1) MapVote_Init(); diff --git a/qcsrc/client/mapvoting.qh b/qcsrc/client/mapvoting.qh index c1c27ad5b..1c8441948 100644 --- a/qcsrc/client/mapvoting.qh +++ b/qcsrc/client/mapvoting.qh @@ -8,8 +8,6 @@ void Cmd_MapVote_MapDownload(float argc); float MapVote_InputEvent(float bInputType, float nPrimary, float nSecondary); -void Ent_MapVote(); - void Net_MapVote_Picture(); float mv_active; diff --git a/qcsrc/client/modeleffects.qc b/qcsrc/client/modeleffects.qc index c17940b94..3a848e41d 100644 --- a/qcsrc/client/modeleffects.qc +++ b/qcsrc/client/modeleffects.qc @@ -23,7 +23,7 @@ void ModelEffect_Draw(entity this) } } -void Ent_ModelEffect(bool isNew) +NET_HANDLE(ENT_CLIENT_MODELEFFECT, bool isnew) { make_pure(self); @@ -66,6 +66,6 @@ void Ent_ModelEffect(bool isNew) e.draw = ModelEffect_Draw; - if(!isNew) - remove(e); // yes, this IS stupid, but I don't need to duplicate all the read* stuff then + if (!isnew) remove(e); // yes, this IS stupid, but I don't need to duplicate all the read* stuff then + return true; } diff --git a/qcsrc/client/modeleffects.qh b/qcsrc/client/modeleffects.qh index 32641f394..9c8c77f9b 100644 --- a/qcsrc/client/modeleffects.qh +++ b/qcsrc/client/modeleffects.qh @@ -9,5 +9,4 @@ class(ModelEffect) .float scale1, scale2; void ModelEffect_Draw(entity this); -void Ent_ModelEffect(bool isNew); #endif diff --git a/qcsrc/client/particles.qh b/qcsrc/client/particles.qh index 3735641af..a35866c6b 100644 --- a/qcsrc/client/particles.qh +++ b/qcsrc/client/particles.qh @@ -18,8 +18,6 @@ void Draw_PointParticles(entity this); void Ent_PointParticles_Remove(); -void Ent_PointParticles(); - class(PointParticles) .float glow_color; // palette index void Net_ReadVortexBeamParticle(); diff --git a/qcsrc/client/teamradar.qc b/qcsrc/client/teamradar.qc index 1a6322d97..80f25fbb0 100644 --- a/qcsrc/client/teamradar.qc +++ b/qcsrc/client/teamradar.qc @@ -200,8 +200,8 @@ void teamradar_loadcvars() // radar links -void Ent_RadarLink() -{SELFPARAM(); +NET_HANDLE(ENT_CLIENT_RADARLINK, bool isnew) +{ int sendflags = ReadByte(); InterpolateOrigin_Undo(); @@ -229,5 +229,7 @@ void Ent_RadarLink() self.team = ReadByte(); } + return = true; + InterpolateOrigin_Note(); } diff --git a/qcsrc/client/teamradar.qh b/qcsrc/client/teamradar.qh index b882f39fb..0f51a2a0d 100644 --- a/qcsrc/client/teamradar.qh +++ b/qcsrc/client/teamradar.qh @@ -47,8 +47,4 @@ void draw_teamradar_link(vector start, vector end, int colors); void teamradar_loadcvars(); -// radar links - -void Ent_RadarLink(); - #endif diff --git a/qcsrc/client/tuba.qc b/qcsrc/client/tuba.qc index f6b1c9e53..8f8fc4db5 100644 --- a/qcsrc/client/tuba.qc +++ b/qcsrc/client/tuba.qc @@ -103,8 +103,8 @@ void Ent_TubaNote_StopSound() self.enemy = world; } -void Ent_TubaNote(bool isNew) -{SELFPARAM(); +NET_HANDLE(ENT_CLIENT_TUBANOTE, bool isNew) +{ bool upd = false; int f = ReadByte(); if (f & 1) { @@ -152,9 +152,10 @@ void Ent_TubaNote(bool isNew) if (upd) { Ent_TubaNote_UpdateSound(); } + return true; } -void Tuba_Precache() +PRECACHE(Tuba) { Tuba_PitchStep = autocvar_g_balance_tuba_pitchstep; if (Tuba_PitchStep) { diff --git a/qcsrc/client/tuba.qh b/qcsrc/client/tuba.qh index e936dcd6e..0a310c359 100644 --- a/qcsrc/client/tuba.qh +++ b/qcsrc/client/tuba.qh @@ -1,7 +1,5 @@ #ifndef CLIENT_TUBA_H #define CLIENT_TUBA_H -void Ent_TubaNote(bool isNew); -void Tuba_Precache(); entityclass(Tuba); diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index 8e11cf124..6f37f39e3 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -1821,9 +1821,6 @@ void CSQC_UpdateView(float w, float h) else if(cvar("r_glsl_postprocess") == 2) cvar_set("r_glsl_postprocess", "0"); - if(menu_visible) - menu_show(); - /*if(gametype == MAPINFO_TYPE_CTF) { ctf_view(); diff --git a/qcsrc/client/wall.qc b/qcsrc/client/wall.qc index 9da9bb5b6..2623470c1 100644 --- a/qcsrc/client/wall.qc +++ b/qcsrc/client/wall.qc @@ -114,8 +114,8 @@ void Ent_Wall_Remove() self.bgmscript = string_null; } -void Ent_Wall() -{SELFPARAM(); +NET_HANDLE(ENT_CLIENT_WALL, bool isnew) +{ int f; var .vector fld; @@ -222,6 +222,8 @@ void Ent_Wall() BGMScript_InitEntity(self); } + return = true; + InterpolateOrigin_Note(); self.saved = self.(fld); diff --git a/qcsrc/client/wall.qh b/qcsrc/client/wall.qh index e05bb615e..16f87fdd9 100644 --- a/qcsrc/client/wall.qh +++ b/qcsrc/client/wall.qh @@ -20,5 +20,4 @@ void Ent_Wall_Draw(entity this); void Ent_Wall_Remove(); -void Ent_Wall(); #endif diff --git a/qcsrc/client/weapons/projectile.qc b/qcsrc/client/weapons/projectile.qc index 9969a89f1..04a600cb6 100644 --- a/qcsrc/client/weapons/projectile.qc +++ b/qcsrc/client/weapons/projectile.qc @@ -183,11 +183,8 @@ void Ent_RemoveProjectile() } } -void Ent_Projectile() +NET_HANDLE(ENT_CLIENT_PROJECTILE, bool isnew) { - SELFPARAM(); - int f; - // projectile properties: // kind (interpolated, or clientside) // @@ -202,7 +199,7 @@ void Ent_Projectile() // // projectiles don't send angles, because they always follow the velocity - f = ReadByte(); + int f = ReadByte(); self.count = (f & 0x80); self.iflags = (self.iflags & IFLAG_INTERNALMASK) | IFLAG_AUTOANGLES | IFLAG_ANGLES | IFLAG_ORIGIN; self.solid = SOLID_TRIGGER; @@ -485,6 +482,8 @@ void Ent_Projectile() setsize(self, self.mins, self.maxs); } + return = true; + if (self.gravity) { if (self.move_movetype == MOVETYPE_FLY) @@ -508,7 +507,7 @@ void Ent_Projectile() self.entremove = Ent_RemoveProjectile; } -void Projectile_Precache() +PRECACHE(Projectiles) { MUTATOR_CALLHOOK(PrecacheProjectiles); } diff --git a/qcsrc/client/weapons/projectile.qh b/qcsrc/client/weapons/projectile.qh index 847f3db49..699f48938 100644 --- a/qcsrc/client/weapons/projectile.qh +++ b/qcsrc/client/weapons/projectile.qh @@ -29,8 +29,4 @@ void loopsound(entity e, int ch, string samp, float vol, float attn); void Ent_RemoveProjectile(); -void Ent_Projectile(); - -void Projectile_Precache(); - #endif diff --git a/qcsrc/common/items/inventory.qh b/qcsrc/common/items/inventory.qh index 307d60ec0..b4c7c787c 100644 --- a/qcsrc/common/items/inventory.qh +++ b/qcsrc/common/items/inventory.qh @@ -12,16 +12,17 @@ class(Inventory) .int inv_items[Items_MAX]; .Inventory inventory; #ifdef CSQC -void Inventory_Read(Inventory data) +NET_HANDLE(ENT_CLIENT_INVENTORY, bool isnew) { - make_pure(self); + make_pure(this); const int bits = ReadInt24_t(); FOREACH(Items, bits & BIT(it.m_id), LAMBDA( .int fld = inv_items[it.m_id]; - int prev = data.(fld); - int next = data.(fld) = ReadByte(); + int prev = this.(fld); + int next = this.(fld) = ReadByte(); LOG_TRACEF("%s: %.0f -> %.0f\n", it.m_name, prev, next); )); + return true; } #endif diff --git a/qcsrc/common/minigames/cl_minigames.qc b/qcsrc/common/minigames/cl_minigames.qc index 38614c7d4..769b70c33 100644 --- a/qcsrc/common/minigames/cl_minigames.qc +++ b/qcsrc/common/minigames/cl_minigames.qc @@ -178,8 +178,8 @@ void minigame_read_owner() if ( !self.owner ) LOG_TRACE("Got a minigame entity without a minigame!\n"); } -void ent_read_minigame() -{SELFPARAM(); +NET_HANDLE(ENT_CLIENT_MINIGAME, bool isnew) +{ float sf = ReadByte(); if ( sf & MINIG_SF_CREATE ) { @@ -241,6 +241,7 @@ void ent_read_minigame() " classname:",self.classname," enttype:",ftos(self.enttype) ); LOG_DEBUG(" sf:",ftos(sf)," netname:",self.netname,"\n\n"); } + return true; } #undef ReadString #undef FIELD diff --git a/qcsrc/common/minigames/cl_minigames.qh b/qcsrc/common/minigames/cl_minigames.qh index aacfc2309..ab5ffc7ea 100644 --- a/qcsrc/common/minigames/cl_minigames.qh +++ b/qcsrc/common/minigames/cl_minigames.qh @@ -95,9 +95,6 @@ float minigame_isactive() #define minigame_cmd(...) minigame_cmd_workaround(0,__VA_ARGS__) void minigame_cmd_workaround(float dummy, string...cmdargc); -// Read a minigame entity from the server -void ent_read_minigame(); - // Prompt the player to play in the current minigame // (ie: it's their turn and they should get back to the minigame) void minigame_prompt(); diff --git a/qcsrc/common/notifications.qc b/qcsrc/common/notifications.qc index da7001de2..6507669b6 100644 --- a/qcsrc/common/notifications.qc +++ b/qcsrc/common/notifications.qc @@ -1680,10 +1680,11 @@ void Local_Notification_WOVA( // ========================= #ifdef CSQC -void Read_Notification(float is_new) +NET_HANDLE(ENT_CLIENT_NOTIFICATION, bool is_new) { int net_type = ReadByte(); int net_name = ReadShort(); + return = true; entity notif; diff --git a/qcsrc/common/notifications.qh b/qcsrc/common/notifications.qh index 59e6a5022..18cb7ee7f 100644 --- a/qcsrc/common/notifications.qh +++ b/qcsrc/common/notifications.qh @@ -148,7 +148,6 @@ void Local_Notification_WOVA( float f1, float f2, float f3, float f4); #ifdef CSQC // CLIENT ONLY -void Read_Notification(float is_new); string prev_soundfile; float prev_soundtime; #endif diff --git a/qcsrc/common/triggers/func/conveyor.qc b/qcsrc/common/triggers/func/conveyor.qc index a8dfafc87..f0cc4d803 100644 --- a/qcsrc/common/triggers/func/conveyor.qc +++ b/qcsrc/common/triggers/func/conveyor.qc @@ -160,8 +160,8 @@ void conveyor_init() self.move_time = time; } -void ent_conveyor() -{SELFPARAM(); +NET_HANDLE(ENT_CLIENT_CONVEYOR, bool isnew) +{ float sf = ReadByte(); if(sf & 1) @@ -195,5 +195,7 @@ void ent_conveyor() if(sf & 2) self.state = ReadByte(); + + return true; } #endif diff --git a/qcsrc/common/triggers/func/conveyor.qh b/qcsrc/common/triggers/func/conveyor.qh deleted file mode 100644 index f27203025..000000000 --- a/qcsrc/common/triggers/func/conveyor.qh +++ /dev/null @@ -1,3 +0,0 @@ -#ifdef CSQC -void ent_conveyor(); -#endif diff --git a/qcsrc/common/triggers/func/door.qc b/qcsrc/common/triggers/func/door.qc index 6eaf2547b..20bedff30 100644 --- a/qcsrc/common/triggers/func/door.qc +++ b/qcsrc/common/triggers/func/door.qc @@ -804,8 +804,8 @@ void door_draw(entity this) trigger_draw_generic(this); } -void ent_door() -{SELFPARAM(); +NET_HANDLE(ENT_CLIENT_DOOR, bool isnew) +{ float sf = ReadByte(); if(sf & SF_TRIGGER_INIT) @@ -874,6 +874,7 @@ void ent_door() self.pos2_y = ReadCoord(); self.pos2_z = ReadCoord(); } + return true; } #endif diff --git a/qcsrc/common/triggers/func/door.qh b/qcsrc/common/triggers/func/door.qh index a765e2265..f7ed28c5b 100644 --- a/qcsrc/common/triggers/func/door.qh +++ b/qcsrc/common/triggers/func/door.qh @@ -12,7 +12,6 @@ const int SPAWNFLAGS_SILVER_KEY = 16; #ifdef CSQC // stuff for preload -void ent_door(); .float door_finished; #endif diff --git a/qcsrc/common/triggers/func/include.qh b/qcsrc/common/triggers/func/include.qh index 624c0b5c8..628355cb7 100644 --- a/qcsrc/common/triggers/func/include.qh +++ b/qcsrc/common/triggers/func/include.qh @@ -1,12 +1,8 @@ #ifndef TRIGGERS_FUNC_INCLUDE_H #define TRIGGERS_FUNC_INCLUDE_H -#include "conveyor.qh" #include "door.qh" #include "ladder.qh" -#include "plat.qh" -#include "rainsnow.qh" -#include "pointparticles.qh" #include "train.qh" #endif diff --git a/qcsrc/common/triggers/func/ladder.qc b/qcsrc/common/triggers/func/ladder.qc index b33de95f1..8c87c15ae 100644 --- a/qcsrc/common/triggers/func/ladder.qc +++ b/qcsrc/common/triggers/func/ladder.qc @@ -60,14 +60,17 @@ spawnfunc(func_water) #elif defined(CSQC) .float speed; -void ent_func_ladder() -{SELFPARAM(); +NET_HANDLE(ENT_CLIENT_LADDER, bool isnew) +{ self.classname = strzone(ReadString()); self.skin = ReadByte(); self.speed = ReadByte(); self.model = strzone(ReadString()); trigger_common_read(false); + + return = true; + self.mins = self.maxs = '0 0 0'; self.solid = SOLID_TRIGGER; diff --git a/qcsrc/common/triggers/func/ladder.qh b/qcsrc/common/triggers/func/ladder.qh index 11eeeda26..774e7cf40 100644 --- a/qcsrc/common/triggers/func/ladder.qh +++ b/qcsrc/common/triggers/func/ladder.qh @@ -1,6 +1,2 @@ .float ladder_time; .entity ladder_entity; - -#ifdef CSQC -void ent_func_ladder(); -#endif diff --git a/qcsrc/common/triggers/func/plat.qc b/qcsrc/common/triggers/func/plat.qc index 30d3d5681..3b3c8eefd 100644 --- a/qcsrc/common/triggers/func/plat.qc +++ b/qcsrc/common/triggers/func/plat.qc @@ -133,8 +133,8 @@ void plat_draw(entity this) //Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy); } -void ent_plat() -{SELFPARAM(); +NET_HANDLE(ENT_CLIENT_PLAT, bool isnew) +{ float sf = ReadByte(); if(sf & SF_TRIGGER_INIT) @@ -197,5 +197,6 @@ void ent_plat() self.move_angles = self.angles; self.move_time = time; } + return true; } #endif diff --git a/qcsrc/common/triggers/func/plat.qh b/qcsrc/common/triggers/func/plat.qh deleted file mode 100644 index e3562f4e8..000000000 --- a/qcsrc/common/triggers/func/plat.qh +++ /dev/null @@ -1,3 +0,0 @@ -#ifdef CSQC -void ent_plat(); -#endif diff --git a/qcsrc/common/triggers/func/pointparticles.qc b/qcsrc/common/triggers/func/pointparticles.qc index d82232d6d..5e8636729 100644 --- a/qcsrc/common/triggers/func/pointparticles.qc +++ b/qcsrc/common/triggers/func/pointparticles.qc @@ -253,8 +253,8 @@ void Ent_PointParticles_Remove() self.bgmscript = string_null; } -void Ent_PointParticles() -{SELFPARAM(); +NET_HANDLE(ENT_CLIENT_POINTPARTICLES, bool isnew) +{ float i; vector v; int f = ReadByte(); @@ -340,6 +340,8 @@ void Ent_PointParticles() BGMScript_InitEntity(self); } + return = true; + if(f & 2) { self.absolute = (self.impulse >= 0); diff --git a/qcsrc/common/triggers/func/pointparticles.qh b/qcsrc/common/triggers/func/pointparticles.qh deleted file mode 100644 index f08ea4875..000000000 --- a/qcsrc/common/triggers/func/pointparticles.qh +++ /dev/null @@ -1,5 +0,0 @@ -#ifdef CSQC - -void Ent_PointParticles(); - -#endif diff --git a/qcsrc/common/triggers/func/rainsnow.qc b/qcsrc/common/triggers/func/rainsnow.qc index 91dc8bad6..f1f320ee6 100644 --- a/qcsrc/common/triggers/func/rainsnow.qc +++ b/qcsrc/common/triggers/func/rainsnow.qc @@ -100,8 +100,8 @@ void Draw_Snow(entity this) te_particlesnow(self.origin + self.mins, self.origin + self.maxs, self.velocity, floor(self.count * drawframetime + random()), self.glow_color); } -void Ent_RainOrSnow() -{SELFPARAM(); +NET_HANDLE(ENT_CLIENT_RAINSNOW, bool isnew) +{ self.impulse = ReadByte(); // Rain, Snow, or Whatever self.origin_x = ReadCoord(); self.origin_y = ReadCoord(); @@ -113,6 +113,8 @@ void Ent_RainOrSnow() self.count = ReadShort() * 10; self.glow_color = ReadByte(); // color + return = true; + self.mins = -0.5 * self.maxs; self.maxs = 0.5 * self.maxs; self.origin = self.origin - self.mins; diff --git a/qcsrc/common/triggers/func/rainsnow.qh b/qcsrc/common/triggers/func/rainsnow.qh deleted file mode 100644 index 5d8d92350..000000000 --- a/qcsrc/common/triggers/func/rainsnow.qh +++ /dev/null @@ -1,3 +0,0 @@ -#ifdef CSQC -void Ent_RainOrSnow(); -#endif diff --git a/qcsrc/common/triggers/func/train.qc b/qcsrc/common/triggers/func/train.qc index 45480686a..d7a3666ff 100644 --- a/qcsrc/common/triggers/func/train.qc +++ b/qcsrc/common/triggers/func/train.qc @@ -245,8 +245,8 @@ void train_draw(entity this) Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy); } -void ent_train() -{SELFPARAM(); +NET_HANDLE(ENT_CLIENT_TRAIN, bool isnew) +{ float sf = ReadByte(); if(sf & SF_TRIGGER_INIT) @@ -321,6 +321,8 @@ void ent_train() { // TODO: make a reset function for trains } + + return true; } #endif diff --git a/qcsrc/common/triggers/func/train.qh b/qcsrc/common/triggers/func/train.qh index f69515f5a..d42d8a8a0 100644 --- a/qcsrc/common/triggers/func/train.qh +++ b/qcsrc/common/triggers/func/train.qh @@ -1,4 +1,3 @@ #ifdef CSQC .float dmgtime; -void ent_train(); #endif diff --git a/qcsrc/common/triggers/include.qh b/qcsrc/common/triggers/include.qh index 138d26786..f69a72b0a 100644 --- a/qcsrc/common/triggers/include.qh +++ b/qcsrc/common/triggers/include.qh @@ -13,9 +13,6 @@ // func #include "func/include.qh" -// misc -#include "misc/include.qh" - // target #include "target/include.qh" diff --git a/qcsrc/common/triggers/misc/corner.qc b/qcsrc/common/triggers/misc/corner.qc index 38dd8f586..1623ac4fc 100644 --- a/qcsrc/common/triggers/misc/corner.qc +++ b/qcsrc/common/triggers/misc/corner.qc @@ -57,8 +57,8 @@ void corner_remove() self.platmovetype = string_null; } -void ent_corner() -{SELFPARAM(); +NET_HANDLE(ENT_CLIENT_CORNER, bool isnew) +{ self.platmovetype = strzone(ReadString()); self.origin_x = ReadCoord(); @@ -75,6 +75,8 @@ void ent_corner() self.wait = ReadByte(); + return = true; + self.classname = "path_corner"; self.drawmask = MASK_NORMAL; self.entremove = corner_remove; diff --git a/qcsrc/common/triggers/misc/corner.qh b/qcsrc/common/triggers/misc/corner.qh deleted file mode 100644 index 62b3aaed7..000000000 --- a/qcsrc/common/triggers/misc/corner.qh +++ /dev/null @@ -1,3 +0,0 @@ -#ifdef CSQC -void ent_corner(); -#endif diff --git a/qcsrc/common/triggers/misc/include.qc b/qcsrc/common/triggers/misc/include.qc index c05f8c376..8965c6290 100644 --- a/qcsrc/common/triggers/misc/include.qc +++ b/qcsrc/common/triggers/misc/include.qc @@ -1,5 +1,3 @@ -#include "include.qh" - #include "corner.qc" #include "follow.qc" #include "laser.qc" diff --git a/qcsrc/common/triggers/misc/include.qh b/qcsrc/common/triggers/misc/include.qh deleted file mode 100644 index 71b220521..000000000 --- a/qcsrc/common/triggers/misc/include.qh +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef TRIGGERS_MISC_INCLUDE_H -#define TRIGGERS_MISC_INCLUDE_H - -#include "corner.qh" -#include "laser.qh" - -#endif diff --git a/qcsrc/common/triggers/misc/laser.qc b/qcsrc/common/triggers/misc/laser.qc index 29a185626..20a5b7229 100644 --- a/qcsrc/common/triggers/misc/laser.qc +++ b/qcsrc/common/triggers/misc/laser.qc @@ -322,8 +322,8 @@ void Draw_Laser(entity this) } } -void Ent_Laser() -{SELFPARAM(); +NET_HANDLE(ENT_CLIENT_LASER, bool isnew) +{ InterpolateOrigin_Undo(); // 30 bytes, or 13 bytes for just moving @@ -379,6 +379,9 @@ void Ent_Laser() } if(f & 4) self.state = ReadByte(); + + return = true; + InterpolateOrigin_Note(); self.draw = Draw_Laser; } diff --git a/qcsrc/common/triggers/misc/laser.qh b/qcsrc/common/triggers/misc/laser.qh deleted file mode 100644 index a77c4c58e..000000000 --- a/qcsrc/common/triggers/misc/laser.qh +++ /dev/null @@ -1,3 +0,0 @@ -#ifdef CSQC -void Ent_Laser(); -#endif diff --git a/qcsrc/common/triggers/target/music.qc b/qcsrc/common/triggers/target/music.qc index c2014bf95..a1ef4829d 100644 --- a/qcsrc/common/triggers/target/music.qc +++ b/qcsrc/common/triggers/target/music.qc @@ -286,8 +286,8 @@ void Ent_TriggerMusic_Remove() self.noise = string_null; } -void Ent_ReadTriggerMusic() -{SELFPARAM(); +NET_HANDLE(ENT_CLIENT_TRIGGER_MUSIC, bool isnew) +{ int f = ReadByte(); if(f & 4) { @@ -340,6 +340,7 @@ void Ent_ReadTriggerMusic() self.cnt = 1; self.think = Ent_TriggerMusic_Think; self.nextthink = time; + return true; } #endif diff --git a/qcsrc/common/triggers/target/music.qh b/qcsrc/common/triggers/target/music.qh index d46c46055..188487976 100644 --- a/qcsrc/common/triggers/target/music.qh +++ b/qcsrc/common/triggers/target/music.qh @@ -22,8 +22,6 @@ void Ent_TriggerMusic_Think(); void Ent_TriggerMusic_Remove(); -void Ent_ReadTriggerMusic(); - #elif defined(SVQC) void target_music_kill(); #endif diff --git a/qcsrc/common/triggers/trigger/impulse.qc b/qcsrc/common/triggers/trigger/impulse.qc index 977821d44..a9c68051b 100644 --- a/qcsrc/common/triggers/trigger/impulse.qc +++ b/qcsrc/common/triggers/trigger/impulse.qc @@ -180,15 +180,15 @@ spawnfunc(trigger_impulse) trigger_impulse_link(); } #elif defined(CSQC) -void ent_trigger_impulse() -{SELFPARAM(); +NET_HANDLE(ENT_CLIENT_TRIGGER_IMPULSE, bool isnew) +{ self.radius = ReadCoord(); self.strength = ReadCoord(); self.falloff = ReadByte(); self.active = ReadByte(); trigger_common_read(true); - + return = true; self.classname = "trigger_impulse"; self.solid = SOLID_TRIGGER; diff --git a/qcsrc/common/triggers/trigger/impulse.qh b/qcsrc/common/triggers/trigger/impulse.qh index a4c248dca..67d6361fb 100644 --- a/qcsrc/common/triggers/trigger/impulse.qh +++ b/qcsrc/common/triggers/trigger/impulse.qh @@ -7,8 +7,4 @@ .float strength; .float lastpushtime; -#ifdef CSQC -void ent_trigger_impulse(); -#endif - #endif diff --git a/qcsrc/common/triggers/trigger/jumppads.qc b/qcsrc/common/triggers/trigger/jumppads.qc index 817b50e46..7cbc86e96 100644 --- a/qcsrc/common/triggers/trigger/jumppads.qc +++ b/qcsrc/common/triggers/trigger/jumppads.qc @@ -413,8 +413,8 @@ spawnfunc(target_position) { make_pure(this); target_push_link(); } #ifdef CSQC -void ent_trigger_push() -{SELFPARAM(); +NET_HANDLE(ENT_CLIENT_TRIGGER_PUSH, bool isnew) +{ float sf = ReadByte(); if(sf & 1) @@ -441,6 +441,7 @@ void ent_trigger_push() self.team = ReadByte(); self.active = ReadByte(); } + return true; } void target_push_remove() @@ -454,14 +455,17 @@ void target_push_remove() self.targetname = string_null; } -void ent_target_push() -{SELFPARAM(); +NET_HANDLE(ENT_CLIENT_TARGET_PUSH, bool isnew) +{ self.classname = "push_target"; self.cnt = ReadByte(); self.targetname = strzone(ReadString()); self.origin_x = ReadCoord(); self.origin_y = ReadCoord(); self.origin_z = ReadCoord(); + + return = true; + setorigin(self, self.origin); self.drawmask = MASK_NORMAL; diff --git a/qcsrc/common/triggers/trigger/jumppads.qh b/qcsrc/common/triggers/trigger/jumppads.qh index efce0df62..0c4180849 100644 --- a/qcsrc/common/triggers/trigger/jumppads.qh +++ b/qcsrc/common/triggers/trigger/jumppads.qh @@ -19,12 +19,6 @@ void() SUB_UseTargets; void trigger_push_use(); #endif -#ifdef CSQC -void ent_trigger_push(); - -void ent_target_push(); -#endif - /* trigger_push_calculatevelocity diff --git a/qcsrc/common/triggers/trigger/keylock.qc b/qcsrc/common/triggers/trigger/keylock.qc index fe33e7906..d3ffd719d 100644 --- a/qcsrc/common/triggers/trigger/keylock.qc +++ b/qcsrc/common/triggers/trigger/keylock.qc @@ -195,13 +195,15 @@ void keylock_remove() self.targetname = string_null; } -void ent_keylock() -{SELFPARAM(); +NET_HANDLE(ENT_CLIENT_KEYLOCK, bool isnew) +{ self.itemkeys = ReadInt24_t(); self.height = ReadByte(); trigger_common_read(true); + return = true; + self.classname = "trigger_keylock"; self.drawmask = MASK_NORMAL; self.draw = trigger_draw_generic; diff --git a/qcsrc/common/triggers/trigger/keylock.qh b/qcsrc/common/triggers/trigger/keylock.qh index bbec0182f..a59cb3f69 100644 --- a/qcsrc/common/triggers/trigger/keylock.qh +++ b/qcsrc/common/triggers/trigger/keylock.qh @@ -1,5 +1,4 @@ #ifdef CSQC -void ent_keylock(); bool item_keys_usekey(entity l, entity p) { int valid = (l.itemkeys & p.itemkeys); diff --git a/qcsrc/common/triggers/trigger/swamp.qc b/qcsrc/common/triggers/trigger/swamp.qc index 7d58ef007..38e4e394a 100644 --- a/qcsrc/common/triggers/trigger/swamp.qc +++ b/qcsrc/common/triggers/trigger/swamp.qc @@ -134,14 +134,16 @@ spawnfunc(trigger_swamp) #elif defined(CSQC) -void ent_swamp() -{SELFPARAM(); +NET_HANDLE(ENT_CLIENT_SWAMP, bool isnew) +{ self.dmg = ReadByte(); self.swamp_slowdown = ReadByte(); self.swamp_interval = ReadByte(); trigger_common_read(false); + return = true; + self.classname = "trigger_swamp"; self.solid = SOLID_TRIGGER; self.draw = trigger_draw_generic; diff --git a/qcsrc/common/triggers/trigger/swamp.qh b/qcsrc/common/triggers/trigger/swamp.qh index 86b14315b..7ae50bac4 100644 --- a/qcsrc/common/triggers/trigger/swamp.qh +++ b/qcsrc/common/triggers/trigger/swamp.qh @@ -8,8 +8,4 @@ .float in_swamp; // bool .entity swampslug; // Uses this to release from swamp ("untouch" fix) -#ifdef CSQC -void ent_swamp(); -#endif - #endif diff --git a/qcsrc/common/triggers/trigger/viewloc.qc b/qcsrc/common/triggers/trigger/viewloc.qc index cd950a406..81b364cef 100644 --- a/qcsrc/common/triggers/trigger/viewloc.qc +++ b/qcsrc/common/triggers/trigger/viewloc.qc @@ -137,8 +137,8 @@ void trigger_viewloc_updatelink() self.goalentity = findfloat(world, entnum, self.count); } -void ent_viewloc_trigger() -{SELFPARAM(); +NET_HANDLE(ENT_CLIENT_VIEWLOC_TRIGGER, bool isnew) +{ float point1 = ReadShort(); float point2 = ReadShort(); @@ -148,6 +148,9 @@ void ent_viewloc_trigger() self.origin_x = ReadCoord(); self.origin_y = ReadCoord(); self.origin_z = ReadCoord(); + + return = true; + setorigin(self, self.origin); self.cnt = point1; @@ -160,8 +163,8 @@ void ent_viewloc_trigger() self.drawmask = MASK_NORMAL; // not so concerned, but better keep it alive } -void ent_viewloc() -{SELFPARAM(); +NET_HANDLE(ENT_CLIENT_VIEWLOC, bool isnew) +{ self.cnt = ReadByte(); self.origin_x = ReadCoord(); @@ -173,6 +176,8 @@ void ent_viewloc() self.movedir_y = ReadCoord(); self.movedir_z = ReadCoord(); + return = true; + self.classname = ((self.cnt == 2) ? "target_viewlocation_end" : "target_viewlocation_start"); self.drawmask = MASK_NORMAL; // don't cull it } diff --git a/qcsrc/common/triggers/trigger/viewloc.qh b/qcsrc/common/triggers/trigger/viewloc.qh index 6708a8e47..881197a3b 100644 --- a/qcsrc/common/triggers/trigger/viewloc.qh +++ b/qcsrc/common/triggers/trigger/viewloc.qh @@ -7,9 +7,6 @@ .entity goalentity; .entity enemy; .vector movedir; - -void ent_viewloc(); -void ent_viewloc_trigger(); #endif #endif diff --git a/qcsrc/common/turrets/all.qc b/qcsrc/common/turrets/all.qc index d996778e6..8fa4632f9 100644 --- a/qcsrc/common/turrets/all.qc +++ b/qcsrc/common/turrets/all.qc @@ -4,10 +4,6 @@ #include "sv_turrets.qh" #endif -#ifdef CSQC -#include "cl_turrets.qh" -#endif - #define IMPLEMENTATION #include "all.inc" #undef IMPLEMENTATION diff --git a/qcsrc/common/turrets/cl_turrets.qc b/qcsrc/common/turrets/cl_turrets.qc index 449dd1f3a..07378804f 100644 --- a/qcsrc/common/turrets/cl_turrets.qc +++ b/qcsrc/common/turrets/cl_turrets.qc @@ -354,8 +354,8 @@ void turret_die() setmodel(self.tur_head, MDL_Null); } -void ent_turret() -{SELFPARAM(); +NET_HANDLE(ENT_CLIENT_TURRET, bool isnew) +{ float sf; sf = ReadByte(); @@ -441,4 +441,5 @@ void ent_turret() self.health = _tmp; } //self.enemy.health = self.health / 255; + return true; } diff --git a/qcsrc/common/turrets/cl_turrets.qh b/qcsrc/common/turrets/cl_turrets.qh deleted file mode 100644 index 0f8ff9485..000000000 --- a/qcsrc/common/turrets/cl_turrets.qh +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef CL_TURRETS_H -#define CL_TURRETS_H - -void ent_turret(); - -#endif diff --git a/qcsrc/common/vehicles/cl_vehicles.qc b/qcsrc/common/vehicles/cl_vehicles.qc index ff8e7c58d..be615772a 100644 --- a/qcsrc/common/vehicles/cl_vehicles.qc +++ b/qcsrc/common/vehicles/cl_vehicles.qc @@ -45,7 +45,7 @@ void AuxiliaryXhair_Draw2D(entity this) self.draw2d = func_null; } -void Net_AuXair2(bool bIsNew) +NET_HANDLE(ENT_CLIENT_AUXILIARYXHAIR, bool isnew) { int axh_id = bound(0, ReadByte(), MAX_AXH); entity axh = AuxiliaryXhair[axh_id]; @@ -70,16 +70,13 @@ void Net_AuXair2(bool bIsNew) axh.colormod_z = ReadByte() / 255; axh.cnt = time; axh.draw2d = AuxiliaryXhair_Draw2D; + return true; } -NET_HANDLE(TE_CSQC_VEHICLESETUP, bool isNew) +NET_HANDLE(TE_CSQC_VEHICLESETUP, bool isnew) { - Net_VehicleSetup(); - return true; -} -void Net_VehicleSetup() -{SELFPARAM(); int hud_id = ReadByte(); + return = true; // hud_id == 0 means we exited a vehicle, so stop alarm sound/s if(hud_id == 0) diff --git a/qcsrc/common/vehicles/cl_vehicles.qh b/qcsrc/common/vehicles/cl_vehicles.qh index 87f0751af..fbaf88c6f 100644 --- a/qcsrc/common/vehicles/cl_vehicles.qh +++ b/qcsrc/common/vehicles/cl_vehicles.qh @@ -4,10 +4,6 @@ vector vehicleHud_Size; vector vehicleHud_Pos; -void Net_AuXair2(float bIsNew); - -void Net_VehicleSetup(); - void RaptorCBShellfragDraw(entity this); void RaptorCBShellfragToss(vector _org, vector _vel, vector _ang); diff --git a/qcsrc/common/vehicles/vehicle/bumblebee.qh b/qcsrc/common/vehicles/vehicle/bumblebee.qh index 7c387e448..b04303892 100644 --- a/qcsrc/common/vehicles/vehicle/bumblebee.qh +++ b/qcsrc/common/vehicles/vehicle/bumblebee.qh @@ -2,7 +2,6 @@ #define BUMBLEBEE_H #ifdef CSQC -void bumble_raygun_read(bool bIsNew); void CSQC_BUMBLE_GUN_HUD(); #endif diff --git a/qcsrc/common/vehicles/vehicle/bumblebee_weapons.qc b/qcsrc/common/vehicles/vehicle/bumblebee_weapons.qc index 944dc53a5..5be36a48a 100644 --- a/qcsrc/common/vehicles/vehicle/bumblebee_weapons.qc +++ b/qcsrc/common/vehicles/vehicle/bumblebee_weapons.qc @@ -63,8 +63,8 @@ bool bumble_raygun_send(entity this, entity to, float sf) void bumble_raygun_draw(entity this); -void bumble_raygun_read(bool bIsNew) -{SELFPARAM(); +NET_HANDLE(ENT_CLIENT_BUMBLE_RAYGUN, bool isnew) +{ int sf = ReadByte(); if(sf & BRG_SETUP) @@ -99,6 +99,7 @@ void bumble_raygun_read(bool bIsNew) self.move_origin_y = ReadCoord(); self.move_origin_z = ReadCoord(); } + return true; } void bumble_raygun_draw(entity this) diff --git a/qcsrc/common/weapons/weapon/arc.qc b/qcsrc/common/weapons/weapon/arc.qc index 1bb921982..218edb6a8 100644 --- a/qcsrc/common/weapons/weapon/arc.qc +++ b/qcsrc/common/weapons/weapon/arc.qc @@ -96,7 +96,6 @@ ARC_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP) .float arc_smoke_sound; #endif #ifdef CSQC -void Ent_ReadArcBeam(float isnew); .vector beam_color; .float beam_alpha; @@ -1149,8 +1148,8 @@ void Remove_ArcBeam() sound(self, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM); } -void Ent_ReadArcBeam(float isnew) -{SELFPARAM(); +NET_HANDLE(ENT_CLIENT_ARC_BEAM, bool isnew) +{ int sf = ReadByte(); entity flash; @@ -1495,6 +1494,7 @@ void Ent_ReadArcBeam(float isnew) { InterpolateOrigin_Note(); } + return true; } #endif diff --git a/qcsrc/lib/csqcmodel/cl_model.qc b/qcsrc/lib/csqcmodel/cl_model.qc index 8d3d4ab93..a656fb790 100644 --- a/qcsrc/lib/csqcmodel/cl_model.qc +++ b/qcsrc/lib/csqcmodel/cl_model.qc @@ -209,8 +209,8 @@ void CSQCModel_Draw() self.csqcmodel_teleported = 0; } -void CSQCModel_Read(bool isnew) -{SELFPARAM(); +NET_HANDLE(ENT_CLIENT_MODEL, bool isnew) +{ int sf = ReadInt24_t(); // some nice flags for CSQCMODEL_IF and the hooks @@ -279,6 +279,7 @@ void CSQCModel_Read(bool isnew) // draw it self.drawmask = MASK_NORMAL; self.predraw = CSQCModel_Draw; + return true; } entity CSQCModel_server2csqc(float pl) diff --git a/qcsrc/lib/csqcmodel/cl_model.qh b/qcsrc/lib/csqcmodel/cl_model.qh index 55401e4b4..179350f95 100644 --- a/qcsrc/lib/csqcmodel/cl_model.qh +++ b/qcsrc/lib/csqcmodel/cl_model.qh @@ -24,8 +24,6 @@ #include "common.qh" -void CSQCModel_Read(bool isnew); - #define CSQCMODEL_IF(cond) #define CSQCMODEL_ENDIF #define CSQCMODEL_PROPERTY(flag,t,r,w,f) \ diff --git a/qcsrc/lib/oo.qh b/qcsrc/lib/oo.qh index 558a87319..1b4b6bbba 100644 --- a/qcsrc/lib/oo.qh +++ b/qcsrc/lib/oo.qh @@ -49,6 +49,22 @@ entity __spawn(string _classname, string _sourceFile, int _sourceLine, bool pure #endif #define spawn() __spawn("entity", __FILE__, __LINE__, false) +entity _clearentity_ent; +STATIC_INIT(clearentity) +{ + _clearentity_ent = new(clearentity); +} +void clearentity(entity e) +{ +#ifdef CSQC + int n = e.entnum; +#endif + copyentity(_clearentity_ent, e); +#ifdef CSQC + e.entnum = n; +#endif +} + // Classes have a `spawn##cname(entity)` constructor // The parameter is used across [[accumulate]] functions diff --git a/qcsrc/lib/warpzone/client.qc b/qcsrc/lib/warpzone/client.qc index 49216057c..dd2b5cc9a 100644 --- a/qcsrc/lib/warpzone/client.qc +++ b/qcsrc/lib/warpzone/client.qc @@ -25,8 +25,8 @@ void WarpZone_Fade_PreDraw() self.drawmask = MASK_NORMAL; } -void WarpZone_Read(float isnew) -{SELFPARAM(); +NET_HANDLE(ENT_CLIENT_WARPZONE, bool isnew) +{ warpzone_warpzones_exist = 1; if (!self.enemy) { @@ -87,10 +87,11 @@ void WarpZone_Read(float isnew) // how to draw // engine currently wants this self.predraw = WarpZone_Fade_PreDraw; + return true; } -void WarpZone_Camera_Read(float isnew) -{SELFPARAM(); +NET_HANDLE(ENT_CLIENT_WARPZONE_CAMERA, bool isnew) +{ warpzone_cameras_exist = 1; self.classname = "func_warpzone_camera"; @@ -143,18 +144,19 @@ void WarpZone_Camera_Read(float isnew) // how to draw // engine currently wants this self.predraw = WarpZone_Fade_PreDraw; + return true; } void CL_RotateMoves(vector ang) = #638; -void WarpZone_Teleported_Read(float isnew) -{SELFPARAM(); +NET_HANDLE(ENT_CLIENT_WARPZONE_TELEPORTED, bool isnew) +{ self.classname = "warpzone_teleported"; vector v; v.x = ReadCoord(); v.y = ReadCoord(); v.z = ReadCoord(); - if(!isnew) - return; + return = true; + if (!isnew) return; self.warpzone_transform = v; setproperty(VF_CL_VIEWANGLES, WarpZone_TransformVAngles(self, getpropertyvec(VF_CL_VIEWANGLES))); if(checkextension("DP_CSQC_ROTATEMOVES")) @@ -278,10 +280,6 @@ void WarpZone_FixView() setproperty(VF_ORIGIN, org + o); } -void WarpZone_Init() -{ -} - void WarpZone_Shutdown() { WarpZone_View_Outside(); diff --git a/qcsrc/lib/warpzone/client.qh b/qcsrc/lib/warpzone/client.qh index 016ac5882..8f3e643b5 100644 --- a/qcsrc/lib/warpzone/client.qh +++ b/qcsrc/lib/warpzone/client.qh @@ -1,14 +1,9 @@ #ifndef LIB_WARPZONE_CLIENT_H #define LIB_WARPZONE_CLIENT_H -void WarpZone_Read(float bIsNewEntity); -void WarpZone_Camera_Read(float bIsNewEntity); -void WarpZone_Teleported_Read(float bIsNewEntity); - void WarpZone_FixPMove(); void WarpZone_FixView(); -void WarpZone_Init(); void WarpZone_Shutdown(); vector warpzone_save_view_origin; diff --git a/qcsrc/server/t_items.qc b/qcsrc/server/t_items.qc index 2a594c11f..cd06f2da8 100644 --- a/qcsrc/server/t_items.qc +++ b/qcsrc/server/t_items.qc @@ -94,8 +94,8 @@ void Item_PreDraw() self.drawmask = MASK_NORMAL; } -void ItemRead(float _IsNew) -{SELFPARAM(); +NET_HANDLE(ENT_CLIENT_ITEM, bool isnew) +{ int sf = ReadByte(); if(sf & ISF_LOCATION) @@ -240,6 +240,7 @@ void ItemRead(float _IsNew) if(self.ItemStatus & ITS_ANIMATE2) self.move_avelocity = '0 -90 0'; } + return true; } #endif diff --git a/qcsrc/server/t_items.qh b/qcsrc/server/t_items.qh index 125fca4db..35a176800 100644 --- a/qcsrc/server/t_items.qh +++ b/qcsrc/server/t_items.qh @@ -45,8 +45,6 @@ string autocvar_cl_simpleitems_postfix = "_simple"; void ItemDraw(entity this); void ItemDrawSimple(entity this); -void ItemRead(float _IsNew); - #endif #ifdef SVQC spawnfunc(item_strength); -- 2.39.2