From: Mario Date: Sat, 26 Mar 2016 14:53:36 +0000 (+1000) Subject: Purge self from most of the warpzone lib X-Git-Tag: xonotic-v0.8.2~1007 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7223a5e197781dd6d780c2623ec9483dd407dcc0;p=xonotic%2Fxonotic-data.pk3dir.git Purge self from most of the warpzone lib --- diff --git a/qcsrc/common/physics/player.qc b/qcsrc/common/physics/player.qc index 1ddb70799..0ecfa180f 100644 --- a/qcsrc/common/physics/player.qc +++ b/qcsrc/common/physics/player.qc @@ -1326,7 +1326,7 @@ void PM_Main(entity this) #ifdef SVQC - WarpZone_PlayerPhysics_FixVAngle(); + WarpZone_PlayerPhysics_FixVAngle(this); #endif float maxspeed_mod = 1; maxspeed_mod *= PHYS_HIGHSPEED(this); diff --git a/qcsrc/lib/warpzone/client.qc b/qcsrc/lib/warpzone/client.qc index 89f6b84af..6467dad35 100644 --- a/qcsrc/lib/warpzone/client.qc +++ b/qcsrc/lib/warpzone/client.qc @@ -29,139 +29,139 @@ void WarpZone_Touch (); NET_HANDLE(ENT_CLIENT_WARPZONE, bool isnew) { warpzone_warpzones_exist = 1; - if (!self.enemy) + if (!this.enemy) { - self.enemy = new(warpzone_from); + this.enemy = new(warpzone_from); } - self.classname = "trigger_warpzone"; + this.classname = "trigger_warpzone"; int f = ReadByte(); - self.warpzone_isboxy = (f & 1); + this.warpzone_isboxy = (f & 1); if(f & 4) { - self.origin_x = ReadCoord(); - self.origin_y = ReadCoord(); - self.origin_z = ReadCoord(); + this.origin_x = ReadCoord(); + this.origin_y = ReadCoord(); + this.origin_z = ReadCoord(); } else - self.origin = '0 0 0'; - self.modelindex = ReadShort(); - self.mins_x = ReadCoord(); - self.mins_y = ReadCoord(); - self.mins_z = ReadCoord(); - self.maxs_x = ReadCoord(); - self.maxs_y = ReadCoord(); - self.maxs_z = ReadCoord(); - self.scale = ReadByte() / 16; - self.enemy.oldorigin_x = ReadCoord(); - self.enemy.oldorigin_y = ReadCoord(); - self.enemy.oldorigin_z = ReadCoord(); - self.enemy.avelocity_x = ReadCoord(); - self.enemy.avelocity_y = ReadCoord(); - self.enemy.avelocity_z = ReadCoord(); - self.oldorigin_x = ReadCoord(); - self.oldorigin_y = ReadCoord(); - self.oldorigin_z = ReadCoord(); - self.avelocity_x = ReadCoord(); - self.avelocity_y = ReadCoord(); - self.avelocity_z = ReadCoord(); + this.origin = '0 0 0'; + this.modelindex = ReadShort(); + this.mins_x = ReadCoord(); + this.mins_y = ReadCoord(); + this.mins_z = ReadCoord(); + this.maxs_x = ReadCoord(); + this.maxs_y = ReadCoord(); + this.maxs_z = ReadCoord(); + this.scale = ReadByte() / 16; + this.enemy.oldorigin_x = ReadCoord(); + this.enemy.oldorigin_y = ReadCoord(); + this.enemy.oldorigin_z = ReadCoord(); + this.enemy.avelocity_x = ReadCoord(); + this.enemy.avelocity_y = ReadCoord(); + this.enemy.avelocity_z = ReadCoord(); + this.oldorigin_x = ReadCoord(); + this.oldorigin_y = ReadCoord(); + this.oldorigin_z = ReadCoord(); + this.avelocity_x = ReadCoord(); + this.avelocity_y = ReadCoord(); + this.avelocity_z = ReadCoord(); if(f & 2) { - self.warpzone_fadestart = ReadShort(); - self.warpzone_fadeend = max(self.warpzone_fadestart + 1, ReadShort()); + this.warpzone_fadestart = ReadShort(); + this.warpzone_fadeend = max(this.warpzone_fadestart + 1, ReadShort()); } else { - self.warpzone_fadestart = 0; - self.warpzone_fadeend = 0; + this.warpzone_fadestart = 0; + this.warpzone_fadeend = 0; } // common stuff - WarpZone_SetUp(self, self.enemy.oldorigin, self.enemy.avelocity, self.oldorigin, self.avelocity); + WarpZone_SetUp(this, this.enemy.oldorigin, this.enemy.avelocity, this.oldorigin, this.avelocity); // link me - //setmodel(self, self.model); - setorigin(self, self.origin); - setsize(self, self.mins, self.maxs); + //setmodel(this, this.model); + setorigin(this, this.origin); + setsize(this, this.mins, this.maxs); // how to draw // engine currently wants this - setpredraw(self, WarpZone_Fade_PreDraw); + setpredraw(this, WarpZone_Fade_PreDraw); - //self.move_touch = WarpZone_Touch; + //this.move_touch = WarpZone_Touch; return true; } NET_HANDLE(ENT_CLIENT_WARPZONE_CAMERA, bool isnew) { warpzone_cameras_exist = 1; - self.classname = "func_warpzone_camera"; + this.classname = "func_warpzone_camera"; int f = ReadByte(); if(f & 4) { - self.origin_x = ReadCoord(); - self.origin_y = ReadCoord(); - self.origin_z = ReadCoord(); + this.origin_x = ReadCoord(); + this.origin_y = ReadCoord(); + this.origin_z = ReadCoord(); } else - self.origin = '0 0 0'; - self.modelindex = ReadShort(); - self.mins_x = ReadCoord(); - self.mins_y = ReadCoord(); - self.mins_z = ReadCoord(); - self.maxs_x = ReadCoord(); - self.maxs_y = ReadCoord(); - self.maxs_z = ReadCoord(); - self.scale = ReadByte() / 16; - self.oldorigin_x = ReadCoord(); - self.oldorigin_y = ReadCoord(); - self.oldorigin_z = ReadCoord(); - self.avelocity_x = ReadCoord(); - self.avelocity_y = ReadCoord(); - self.avelocity_z = ReadCoord(); + this.origin = '0 0 0'; + this.modelindex = ReadShort(); + this.mins_x = ReadCoord(); + this.mins_y = ReadCoord(); + this.mins_z = ReadCoord(); + this.maxs_x = ReadCoord(); + this.maxs_y = ReadCoord(); + this.maxs_z = ReadCoord(); + this.scale = ReadByte() / 16; + this.oldorigin_x = ReadCoord(); + this.oldorigin_y = ReadCoord(); + this.oldorigin_z = ReadCoord(); + this.avelocity_x = ReadCoord(); + this.avelocity_y = ReadCoord(); + this.avelocity_z = ReadCoord(); if(f & 2) { - self.warpzone_fadestart = ReadShort(); - self.warpzone_fadeend = max(self.warpzone_fadestart + 1, ReadShort()); + this.warpzone_fadestart = ReadShort(); + this.warpzone_fadeend = max(this.warpzone_fadestart + 1, ReadShort()); } else { - self.warpzone_fadestart = 0; - self.warpzone_fadeend = 0; + this.warpzone_fadestart = 0; + this.warpzone_fadeend = 0; } // common stuff - WarpZone_Camera_SetUp(self, self.oldorigin, self.avelocity); + WarpZone_Camera_SetUp(this, this.oldorigin, this.avelocity); // engine currently wants this - self.drawmask = MASK_NORMAL; + this.drawmask = MASK_NORMAL; // link me - //setmodel(self, self.model); - setorigin(self, self.origin); - setsize(self, self.mins, self.maxs); + //setmodel(this, this.model); + setorigin(this, this.origin); + setsize(this, this.mins, this.maxs); // how to draw // engine currently wants this - setpredraw(self, WarpZone_Fade_PreDraw); + setpredraw(this, WarpZone_Fade_PreDraw); return true; } void CL_RotateMoves(vector ang) = #638; NET_HANDLE(ENT_CLIENT_WARPZONE_TELEPORTED, bool isnew) { - self.classname = "warpzone_teleported"; + this.classname = "warpzone_teleported"; vector v; v.x = ReadCoord(); v.y = ReadCoord(); v.z = ReadCoord(); return = true; if (!isnew) return; - self.warpzone_transform = v; - setproperty(VF_CL_VIEWANGLES, WarpZone_TransformVAngles(self, getpropertyvec(VF_CL_VIEWANGLES))); + this.warpzone_transform = v; + setproperty(VF_CL_VIEWANGLES, WarpZone_TransformVAngles(this, getpropertyvec(VF_CL_VIEWANGLES))); if(checkextension("DP_CSQC_ROTATEMOVES")) CL_RotateMoves(v); //CL_RotateMoves('0 90 0'); @@ -226,8 +226,7 @@ vector WarpZone_FixNearClip(vector o, vector c0, vector c1, vector c2, vector c3 void WarpZone_FixPMove() { - entity e; - e = WarpZone_Find(pmove_org, pmove_org); + entity e = WarpZone_Find(pmove_org, pmove_org); if(e) { pmove_org = WarpZone_TransformOrigin(e, pmove_org); diff --git a/qcsrc/lib/warpzone/common.qc b/qcsrc/lib/warpzone/common.qc index 7309ff79b..130e1b2d1 100644 --- a/qcsrc/lib/warpzone/common.qc +++ b/qcsrc/lib/warpzone/common.qc @@ -42,22 +42,22 @@ float autocvar_cl_warpzone_usetrace = 1; vector WarpZone_camera_transform(vector org, vector ang) {SELFPARAM(); vector vf, vr, vu; - if(self.warpzone_fadestart) - if(vdist(org - self.origin - 0.5 * (self.mins + self.maxs), >, self.warpzone_fadeend + 400)) + if(this.warpzone_fadestart) + if(vdist(org - this.origin - 0.5 * (this.mins + this.maxs), >, this.warpzone_fadeend + 400)) return org; // don't transform if zone faded out (plus 400qu safety margin for typical speeds and latencies) // unneeded on client, on server this helps a lot vf = v_forward; vr = v_right; vu = v_up; - org = WarpZone_TransformOrigin(self, org); - vf = WarpZone_TransformVelocity(self, vf); - vr = WarpZone_TransformVelocity(self, vr); - vu = WarpZone_TransformVelocity(self, vu); + org = WarpZone_TransformOrigin(this, org); + vf = WarpZone_TransformVelocity(this, vf); + vr = WarpZone_TransformVelocity(this, vr); + vu = WarpZone_TransformVelocity(this, vu); if(autocvar_cl_warpzone_usetrace) - traceline(self.warpzone_targetorigin, org, MOVE_NOMONSTERS, world); + traceline(this.warpzone_targetorigin, org, MOVE_NOMONSTERS, world); else - trace_endpos = self.warpzone_targetorigin; + trace_endpos = this.warpzone_targetorigin; v_forward = vf; v_right = vr; v_up = vu; @@ -80,14 +80,14 @@ void WarpZone_SetUp(entity e, vector my_org, vector my_ang, vector other_org, ve vector WarpZone_Camera_camera_transform(vector org, vector ang) {SELFPARAM(); // a fixed camera view - if(self.warpzone_fadestart) - if(vdist(org - self.origin - 0.5 * (self.mins + self.maxs), >, self.warpzone_fadeend + 400)) + if(this.warpzone_fadestart) + if(vdist(org - this.origin - 0.5 * (this.mins + this.maxs), >, this.warpzone_fadeend + 400)) return org; // don't transform if zone faded out (plus 400qu safety margin for typical speeds and latencies) // unneeded on client, on server this helps a lot - trace_endpos = self.warpzone_origin; - makevectors(self.warpzone_angles); - return self.warpzone_origin; + trace_endpos = this.warpzone_origin; + makevectors(this.warpzone_angles); + return this.warpzone_origin; } void WarpZone_Camera_SetUp(entity e, vector my_org, vector my_ang) // we assume that e.oldorigin and e.avelocity point to view origin and direction @@ -670,9 +670,9 @@ entity WarpZone_FindRadius(vector org, float rad, bool needlineofsight) void WarpZone_RefSys_GC() {SELFPARAM(); // garbage collect unused reference systems - self.nextthink = time + 1; - if(self.owner.WarpZone_refsys != self) - remove(self); + this.nextthink = time + 1; + if(this.owner.WarpZone_refsys != this) + remove(this); } void WarpZone_RefSys_CheckCreate(entity me) { @@ -788,7 +788,7 @@ entity WarpZone_RefSys_SpawnSameRefSys(entity me) float WarpZoneLib_ExactTrigger_Touch() {SELFPARAM(); - return !WarpZoneLib_BoxTouchesBrush(other.absmin, other.absmax, self, other); + return !WarpZoneLib_BoxTouchesBrush(other.absmin, other.absmax, this, other); } diff --git a/qcsrc/lib/warpzone/server.qc b/qcsrc/lib/warpzone/server.qc index 7444a5ded..2f8471180 100644 --- a/qcsrc/lib/warpzone/server.qc +++ b/qcsrc/lib/warpzone/server.qc @@ -71,12 +71,12 @@ void WarpZone_TeleportPlayer(entity teleporter, entity player, vector to, vector } #ifdef SVQC -bool WarpZone_Teleported_Send(entity to, int sf) -{SELFPARAM(); +bool WarpZone_Teleported_Send(entity this, entity to, int sf) +{ WriteHeader(MSG_ENTITY, ENT_CLIENT_WARPZONE_TELEPORTED); - WriteCoord(MSG_ENTITY, self.angles.x); - WriteCoord(MSG_ENTITY, self.angles.y); - WriteCoord(MSG_ENTITY, self.angles.z); + WriteCoord(MSG_ENTITY, this.angles.x); + WriteCoord(MSG_ENTITY, this.angles.y); + WriteCoord(MSG_ENTITY, this.angles.z); return true; } #endif @@ -169,7 +169,8 @@ float WarpZone_Teleport(entity wz, entity player, float f0, float f1) entity ts = new(warpzone_teleported); setmodel(ts, MDL_Null); - ts.SendEntity = WarpZone_Teleported_Send; + ts.SendEntity = SendEntity_self; + ts.SendEntity3 = WarpZone_Teleported_Send; ts.SendFlags = 0xFFFFFF; ts.drawonlytoclient = player; ts.think = SUB_Remove_self; @@ -209,9 +210,9 @@ void WarpZone_Touch () return; #ifdef SVQC - if(WarpZone_PlaneDist(self, other.origin + other.view_ofs) >= 0) // wrong side of the trigger_warpzone (don't teleport yet) + if(WarpZone_PlaneDist(this, other.origin + other.view_ofs) >= 0) // wrong side of the trigger_warpzone (don't teleport yet) #elif defined(CSQC) - if(WarpZone_PlaneDist(self, other.move_origin + other.view_ofs) >= 0) // wrong side of the trigger_warpzone (don't teleport yet) + if(WarpZone_PlaneDist(this, other.move_origin + other.view_ofs) >= 0) // wrong side of the trigger_warpzone (don't teleport yet) #endif return; @@ -236,24 +237,24 @@ void WarpZone_Touch () #endif else f = -1; - if(WarpZone_Teleport(self, other, f, 0)) + if(WarpZone_Teleport(this, other, f, 0)) { #ifdef SVQC string save1, save2; activator = other; - save1 = self.target; self.target = string_null; - save2 = self.target3; self.target3 = string_null; + save1 = this.target; this.target = string_null; + save2 = this.target3; this.target3 = string_null; SUB_UseTargets(); - if (!self.target) self.target = save1; - if (!self.target3) self.target3 = save2; + if (!this.target) this.target = save1; + if (!this.target3) this.target3 = save2; - setself(self.enemy); - save1 = self.target; self.target = string_null; - save2 = self.target2; self.target2 = string_null; + setself(this.enemy); + save1 = this.target; this.target = string_null; + save2 = this.target2; this.target2 = string_null; SUB_UseTargets(); - if (!self.target) self.target = save1; - if (!self.target2) self.target2 = save2; + if (!this.target) this.target = save1; + if (!this.target2) this.target2 = save2; setself(this); #endif } @@ -264,100 +265,100 @@ void WarpZone_Touch () } #ifdef SVQC -bool WarpZone_Send(entity to, int sendflags) -{SELFPARAM(); +bool WarpZone_Send(entity this, entity to, int sendflags) +{ WriteHeader(MSG_ENTITY, ENT_CLIENT_WARPZONE); // we must send this flag for clientside to match properly too int f = 0; - if(self.warpzone_isboxy) + if(this.warpzone_isboxy) BITSET_ASSIGN(f, 1); - if(self.warpzone_fadestart) + if(this.warpzone_fadestart) BITSET_ASSIGN(f, 2); - if(self.origin != '0 0 0') + if(this.origin != '0 0 0') BITSET_ASSIGN(f, 4); WriteByte(MSG_ENTITY, f); // we need THESE to render the warpzone (and cull properly)... if(f & 4) { - WriteCoord(MSG_ENTITY, self.origin.x); - WriteCoord(MSG_ENTITY, self.origin.y); - WriteCoord(MSG_ENTITY, self.origin.z); + WriteCoord(MSG_ENTITY, this.origin.x); + WriteCoord(MSG_ENTITY, this.origin.y); + WriteCoord(MSG_ENTITY, this.origin.z); } - WriteShort(MSG_ENTITY, self.modelindex); - WriteCoord(MSG_ENTITY, self.mins.x); - WriteCoord(MSG_ENTITY, self.mins.y); - WriteCoord(MSG_ENTITY, self.mins.z); - WriteCoord(MSG_ENTITY, self.maxs.x); - WriteCoord(MSG_ENTITY, self.maxs.y); - WriteCoord(MSG_ENTITY, self.maxs.z); - WriteByte(MSG_ENTITY, bound(1, self.scale * 16, 255)); + WriteShort(MSG_ENTITY, this.modelindex); + WriteCoord(MSG_ENTITY, this.mins.x); + WriteCoord(MSG_ENTITY, this.mins.y); + WriteCoord(MSG_ENTITY, this.mins.z); + WriteCoord(MSG_ENTITY, this.maxs.x); + WriteCoord(MSG_ENTITY, this.maxs.y); + WriteCoord(MSG_ENTITY, this.maxs.z); + WriteByte(MSG_ENTITY, bound(1, this.scale * 16, 255)); // we need THESE to calculate the proper transform - WriteCoord(MSG_ENTITY, self.warpzone_origin.x); - WriteCoord(MSG_ENTITY, self.warpzone_origin.y); - WriteCoord(MSG_ENTITY, self.warpzone_origin.z); - WriteCoord(MSG_ENTITY, self.warpzone_angles.x); - WriteCoord(MSG_ENTITY, self.warpzone_angles.y); - WriteCoord(MSG_ENTITY, self.warpzone_angles.z); - WriteCoord(MSG_ENTITY, self.warpzone_targetorigin.x); - WriteCoord(MSG_ENTITY, self.warpzone_targetorigin.y); - WriteCoord(MSG_ENTITY, self.warpzone_targetorigin.z); - WriteCoord(MSG_ENTITY, self.warpzone_targetangles.x); - WriteCoord(MSG_ENTITY, self.warpzone_targetangles.y); - WriteCoord(MSG_ENTITY, self.warpzone_targetangles.z); + WriteCoord(MSG_ENTITY, this.warpzone_origin.x); + WriteCoord(MSG_ENTITY, this.warpzone_origin.y); + WriteCoord(MSG_ENTITY, this.warpzone_origin.z); + WriteCoord(MSG_ENTITY, this.warpzone_angles.x); + WriteCoord(MSG_ENTITY, this.warpzone_angles.y); + WriteCoord(MSG_ENTITY, this.warpzone_angles.z); + WriteCoord(MSG_ENTITY, this.warpzone_targetorigin.x); + WriteCoord(MSG_ENTITY, this.warpzone_targetorigin.y); + WriteCoord(MSG_ENTITY, this.warpzone_targetorigin.z); + WriteCoord(MSG_ENTITY, this.warpzone_targetangles.x); + WriteCoord(MSG_ENTITY, this.warpzone_targetangles.y); + WriteCoord(MSG_ENTITY, this.warpzone_targetangles.z); if(f & 2) { - WriteShort(MSG_ENTITY, self.warpzone_fadestart); - WriteShort(MSG_ENTITY, self.warpzone_fadeend); + WriteShort(MSG_ENTITY, this.warpzone_fadestart); + WriteShort(MSG_ENTITY, this.warpzone_fadeend); } return true; } -bool WarpZone_Camera_Send(entity to, int sendflags) -{SELFPARAM(); +bool WarpZone_Camera_Send(entity this, entity to, int sendflags) +{ int f = 0; WriteHeader(MSG_ENTITY, ENT_CLIENT_WARPZONE_CAMERA); - if(self.warpzone_fadestart) + if(this.warpzone_fadestart) BITSET_ASSIGN(f, 2); - if(self.origin != '0 0 0') + if(this.origin != '0 0 0') BITSET_ASSIGN(f, 4); WriteByte(MSG_ENTITY, f); // we need THESE to render the warpzone (and cull properly)... if(f & 4) { - WriteCoord(MSG_ENTITY, self.origin.x); - WriteCoord(MSG_ENTITY, self.origin.y); - WriteCoord(MSG_ENTITY, self.origin.z); + WriteCoord(MSG_ENTITY, this.origin.x); + WriteCoord(MSG_ENTITY, this.origin.y); + WriteCoord(MSG_ENTITY, this.origin.z); } - WriteShort(MSG_ENTITY, self.modelindex); - WriteCoord(MSG_ENTITY, self.mins.x); - WriteCoord(MSG_ENTITY, self.mins.y); - WriteCoord(MSG_ENTITY, self.mins.z); - WriteCoord(MSG_ENTITY, self.maxs.x); - WriteCoord(MSG_ENTITY, self.maxs.y); - WriteCoord(MSG_ENTITY, self.maxs.z); - WriteByte(MSG_ENTITY, bound(1, self.scale * 16, 255)); + WriteShort(MSG_ENTITY, this.modelindex); + WriteCoord(MSG_ENTITY, this.mins.x); + WriteCoord(MSG_ENTITY, this.mins.y); + WriteCoord(MSG_ENTITY, this.mins.z); + WriteCoord(MSG_ENTITY, this.maxs.x); + WriteCoord(MSG_ENTITY, this.maxs.y); + WriteCoord(MSG_ENTITY, this.maxs.z); + WriteByte(MSG_ENTITY, bound(1, this.scale * 16, 255)); // we need THESE to calculate the proper transform - WriteCoord(MSG_ENTITY, self.enemy.origin.x); - WriteCoord(MSG_ENTITY, self.enemy.origin.y); - WriteCoord(MSG_ENTITY, self.enemy.origin.z); - WriteCoord(MSG_ENTITY, self.enemy.angles.x); - WriteCoord(MSG_ENTITY, self.enemy.angles.y); - WriteCoord(MSG_ENTITY, self.enemy.angles.z); + WriteCoord(MSG_ENTITY, this.enemy.origin.x); + WriteCoord(MSG_ENTITY, this.enemy.origin.y); + WriteCoord(MSG_ENTITY, this.enemy.origin.z); + WriteCoord(MSG_ENTITY, this.enemy.angles.x); + WriteCoord(MSG_ENTITY, this.enemy.angles.y); + WriteCoord(MSG_ENTITY, this.enemy.angles.z); if(f & 2) { - WriteShort(MSG_ENTITY, self.warpzone_fadestart); - WriteShort(MSG_ENTITY, self.warpzone_fadeend); + WriteShort(MSG_ENTITY, this.warpzone_fadestart); + WriteShort(MSG_ENTITY, this.warpzone_fadeend); } return true; @@ -456,7 +457,7 @@ float WarpZone_Projectile_Touch() // engine now aborts moves on teleport, so this SHOULD not happen any more // but if this is called from TouchAreaGrid of the projectile moving, // then this won't do - if(time == self.warpzone_teleport_time) + if(time == this.warpzone_teleport_time) return true; #ifdef SVQC @@ -490,7 +491,7 @@ float WarpZone_Projectile_Touch() save_inopen = trace_inopen; save_inwater = trace_inwater; float f; - if((f = WarpZone_CheckProjectileImpact(self)) != 0) + if((f = WarpZone_CheckProjectileImpact(this)) != 0) return (f > 0); trace_dpstartcontents = save_dpstartcontents; trace_dphitcontents = save_dphitcontents; @@ -519,84 +520,84 @@ float WarpZone_Projectile_Touch() void WarpZone_InitStep_FindOriginTarget() {SELFPARAM(); - if(self.killtarget != "") + if(this.killtarget != "") { - self.aiment = find(world, targetname, self.killtarget); - if(self.aiment == world) + this.aiment = find(world, targetname, this.killtarget); + if(this.aiment == world) { error("Warp zone with nonexisting killtarget"); return; } - self.killtarget = string_null; + this.killtarget = string_null; } } void WarpZonePosition_InitStep_FindTarget() {SELFPARAM(); - if(self.target == "") + if(this.target == "") { error("Warp zone position with no target"); return; } - self.enemy = find(world, targetname, self.target); - if(self.enemy == world) + this.enemy = find(world, targetname, this.target); + if(this.enemy == world) { error("Warp zone position with nonexisting target"); return; } - if(self.enemy.aiment) + if(this.enemy.aiment) { // already is positioned error("Warp zone position targeting already oriented warpzone"); return; } - self.enemy.aiment = self; + this.enemy.aiment = this; } void WarpZoneCamera_Think() {SELFPARAM(); - if(self.warpzone_save_origin != self.origin - || self.warpzone_save_angles != self.angles - || self.warpzone_save_eorigin != self.enemy.origin - || self.warpzone_save_eangles != self.enemy.angles) + if(this.warpzone_save_origin != this.origin + || this.warpzone_save_angles != this.angles + || this.warpzone_save_eorigin != this.enemy.origin + || this.warpzone_save_eangles != this.enemy.angles) { - WarpZone_Camera_SetUp(self, self.enemy.origin, self.enemy.angles); - self.warpzone_save_origin = self.origin; - self.warpzone_save_angles = self.angles; - self.warpzone_save_eorigin = self.enemy.origin; - self.warpzone_save_eangles = self.enemy.angles; + WarpZone_Camera_SetUp(this, this.enemy.origin, this.enemy.angles); + this.warpzone_save_origin = this.origin; + this.warpzone_save_angles = this.angles; + this.warpzone_save_eorigin = this.enemy.origin; + this.warpzone_save_eangles = this.enemy.angles; } - self.nextthink = time; + this.nextthink = time; } void WarpZoneCamera_InitStep_FindTarget() {SELFPARAM(); entity e; float i; - if(self.target == "") + if(this.target == "") { error("Camera with no target"); return; } - self.enemy = world; - for(e = world, i = 0; (e = find(e, targetname, self.target)); ) + this.enemy = world; + for(e = world, i = 0; (e = find(e, targetname, this.target)); ) if(random() * ++i < 1) - self.enemy = e; - if(self.enemy == world) + this.enemy = e; + if(this.enemy == world) { error("Camera with nonexisting target"); return; } warpzone_cameras_exist = 1; - WarpZone_Camera_SetUp(self, self.enemy.origin, self.enemy.angles); - self.SendFlags = 0xFFFFFF; - if(self.spawnflags & 1) + WarpZone_Camera_SetUp(this, this.enemy.origin, this.enemy.angles); + this.SendFlags = 0xFFFFFF; + if(this.spawnflags & 1) { - self.think = WarpZoneCamera_Think; - self.nextthink = time; + this.think = WarpZoneCamera_Think; + this.nextthink = time; } else - self.nextthink = 0; + this.nextthink = 0; } void WarpZone_InitStep_UpdateTransform() @@ -607,26 +608,26 @@ void WarpZone_InitStep_UpdateTransform() float i_s, i_t, n_t; string tex; - org = self.origin; + org = this.origin; if(org == '0 0 0') - org = 0.5 * (self.mins + self.maxs); + org = 0.5 * (this.mins + this.maxs); norm = point = '0 0 0'; area = 0; for(i_s = 0; ; ++i_s) { - tex = getsurfacetexture(self, i_s); + tex = getsurfacetexture(this, i_s); if (!tex) break; // this is beyond the last one if(tex == "textures/common/trigger" || tex == "trigger") continue; - n_t = getsurfacenumtriangles(self, i_s); + n_t = getsurfacenumtriangles(this, i_s); for(i_t = 0; i_t < n_t; ++i_t) { - tri = getsurfacetriangle(self, i_s, i_t); - a = getsurfacepoint(self, i_s, tri.x); - b = getsurfacepoint(self, i_s, tri.y); - c = getsurfacepoint(self, i_s, tri.z); + tri = getsurfacetriangle(this, i_s, i_t); + a = getsurfacepoint(this, i_s, tri.x); + b = getsurfacepoint(this, i_s, tri.y); + c = getsurfacepoint(this, i_s, tri.z); n = cross(c - a, b - a); area = area + vlen(n); norm = norm + n; @@ -639,32 +640,32 @@ void WarpZone_InitStep_UpdateTransform() point = point * (1 / (3 * area)); if(vdist(norm, <, 0.99)) { - LOG_INFO("trigger_warpzone near ", vtos(self.aiment.origin), " is nonplanar. BEWARE.\n"); + LOG_INFO("trigger_warpzone near ", vtos(this.aiment.origin), " is nonplanar. BEWARE.\n"); area = 0; // no autofixing in this case } norm = normalize(norm); } ang = '0 0 0'; - if(self.aiment) + if(this.aiment) { - org = self.aiment.origin; - ang = self.aiment.angles; + org = this.aiment.origin; + ang = this.aiment.angles; if(area > 0) { org = org - ((org - point) * norm) * norm; // project to plane makevectors(ang); if(norm * v_forward < 0) { - LOG_INFO("Position target of trigger_warpzone near ", vtos(self.aiment.origin), " points into trigger_warpzone. BEWARE.\n"); + LOG_INFO("Position target of trigger_warpzone near ", vtos(this.aiment.origin), " points into trigger_warpzone. BEWARE.\n"); norm = -1 * norm; } ang = vectoangles2(norm, v_up); // keep rotation, but turn exactly against plane ang.x = -ang.x; if(norm * v_forward < 0.99) - LOG_INFO("trigger_warpzone near ", vtos(self.aiment.origin), " has been turned to match plane orientation (", vtos(self.aiment.angles), " -> ", vtos(ang), "\n"); - if(vdist(org - self.aiment.origin, >, 0.5)) - LOG_INFO("trigger_warpzone near ", vtos(self.aiment.origin), " has been moved to match the plane (", vtos(self.aiment.origin), " -> ", vtos(org), ").\n"); + LOG_INFO("trigger_warpzone near ", vtos(this.aiment.origin), " has been turned to match plane orientation (", vtos(this.aiment.angles), " -> ", vtos(ang), "\n"); + if(vdist(org - this.aiment.origin, >, 0.5)) + LOG_INFO("trigger_warpzone near ", vtos(this.aiment.origin), " has been moved to match the plane (", vtos(this.aiment.origin), " -> ", vtos(org), ").\n"); } } else if(area > 0) @@ -676,15 +677,15 @@ void WarpZone_InitStep_UpdateTransform() else error("cannot infer origin/angles for this warpzone, please use a killtarget or a trigger_warpzone_position"); - self.warpzone_origin = org; - self.warpzone_angles = ang; + this.warpzone_origin = org; + this.warpzone_angles = ang; } void WarpZone_InitStep_ClearTarget() {SELFPARAM(); - if(self.enemy) - self.enemy.enemy = world; - self.enemy = world; + if(this.enemy) + this.enemy.enemy = world; + this.enemy = world; } entity warpzone_first; .entity warpzone_next; @@ -693,51 +694,51 @@ void WarpZone_InitStep_FindTarget() float i; entity e, e2; - if(self.enemy) + if(this.enemy) return; // this way only one of the two ents needs to target - if(self.target != "") + if(this.target != "") { - self.enemy = self; // so the if(!e.enemy) check also skips self, saves one IF + this.enemy = this; // so the if(!e.enemy) check also skips this, saves one IF e2 = world; - for(e = world, i = 0; (e = find(e, targetname, self.target)); ) + for(e = world, i = 0; (e = find(e, targetname, this.target)); ) if(!e.enemy) - if(e.classname == self.classname) // possibly non-warpzones may use the same targetname! + if(e.classname == this.classname) // possibly non-warpzones may use the same targetname! if(random() * ++i < 1) e2 = e; if(!e2) { - self.enemy = world; + this.enemy = world; error("Warpzone with non-existing target"); return; } - self.enemy = e2; - e2.enemy = self; + this.enemy = e2; + e2.enemy = this; } } void WarpZone_Think(); void WarpZone_InitStep_FinalizeTransform() {SELFPARAM(); - if(!self.enemy || self.enemy.enemy != self) + if(!this.enemy || this.enemy.enemy != this) { error("Invalid warp zone detected. Killed."); return; } warpzone_warpzones_exist = 1; - WarpZone_SetUp(self, self.warpzone_origin, self.warpzone_angles, self.enemy.warpzone_origin, self.enemy.warpzone_angles); - self.touch = WarpZone_Touch; - self.SendFlags = 0xFFFFFF; - if(self.spawnflags & 1) + WarpZone_SetUp(this, this.warpzone_origin, this.warpzone_angles, this.enemy.warpzone_origin, this.enemy.warpzone_angles); + this.touch = WarpZone_Touch; + this.SendFlags = 0xFFFFFF; + if(this.spawnflags & 1) { - self.think = WarpZone_Think; - self.nextthink = time; + this.think = WarpZone_Think; + this.nextthink = time; } else - self.nextthink = 0; + this.nextthink = 0; } float warpzone_initialized; @@ -748,8 +749,8 @@ entity warpzone_camera_first; spawnfunc(misc_warpzone_position) { // "target", "angles", "origin" - self.warpzone_next = warpzone_position_first; - warpzone_position_first = self; + this.warpzone_next = warpzone_position_first; + warpzone_position_first = this; } spawnfunc(trigger_warpzone_position) { @@ -765,53 +766,55 @@ spawnfunc(trigger_warpzone) // the map, with another killtarget to designate its // orientation - if(!self.scale) - self.scale = self.modelscale; - if(!self.scale) - self.scale = 1; + if(!this.scale) + this.scale = this.modelscale; + if(!this.scale) + this.scale = 1; string m; - m = self.model; + m = this.model; WarpZoneLib_ExactTrigger_Init(); if(m != "") { precache_model(m); - _setmodel(self, m); // no precision needed + _setmodel(this, m); // no precision needed } - setorigin(self, self.origin); - if(self.scale) - setsize(self, self.mins * self.scale, self.maxs * self.scale); + setorigin(this, this.origin); + if(this.scale) + setsize(this, this.mins * this.scale, this.maxs * this.scale); else - setsize(self, self.mins, self.maxs); - self.SendEntity = WarpZone_Send; - self.SendFlags = 0xFFFFFF; - BITSET_ASSIGN(self.effects, EF_NODEPTHTEST); - self.warpzone_next = warpzone_first; - warpzone_first = self; + setsize(this, this.mins, this.maxs); + this.SendEntity = SendEntity_self; + this.SendEntity3 = WarpZone_Send; + this.SendFlags = 0xFFFFFF; + BITSET_ASSIGN(this.effects, EF_NODEPTHTEST); + this.warpzone_next = warpzone_first; + warpzone_first = this; } spawnfunc(func_camera) { - if(!self.scale) - self.scale = self.modelscale; - if(!self.scale) - self.scale = 1; - if(self.model != "") + if(!this.scale) + this.scale = this.modelscale; + if(!this.scale) + this.scale = 1; + if(this.model != "") { - precache_model(self.model); - _setmodel(self, self.model); // no precision needed + precache_model(this.model); + _setmodel(this, this.model); // no precision needed } - setorigin(self, self.origin); - if(self.scale) - setsize(self, self.mins * self.scale, self.maxs * self.scale); + setorigin(this, this.origin); + if(this.scale) + setsize(this, this.mins * this.scale, this.maxs * this.scale); else - setsize(self, self.mins, self.maxs); - if(!self.solid) - self.solid = SOLID_BSP; - else if(self.solid < 0) - self.solid = SOLID_NOT; - self.SendEntity = WarpZone_Camera_Send; - self.SendFlags = 0xFFFFFF; - self.warpzone_next = warpzone_camera_first; - warpzone_camera_first = self; + setsize(this, this.mins, this.maxs); + if(!this.solid) + this.solid = SOLID_BSP; + else if(this.solid < 0) + this.solid = SOLID_NOT; + this.SendEntity = SendEntity_self; + this.SendEntity3 = WarpZone_Camera_Send; + this.SendFlags = 0xFFFFFF; + this.warpzone_next = warpzone_camera_first; + warpzone_camera_first = this; } void WarpZones_Reconnect() {SELFPARAM(); @@ -936,7 +939,7 @@ void trigger_warpzone_reconnect_use() spawnfunc(trigger_warpzone_reconnect) { - self.use = trigger_warpzone_reconnect_use; + this.use = trigger_warpzone_reconnect_use; } spawnfunc(target_warpzone_reconnect) @@ -944,15 +947,15 @@ spawnfunc(target_warpzone_reconnect) spawnfunc_trigger_warpzone_reconnect(this); // both names make sense here :( } -void WarpZone_PlayerPhysics_FixVAngle() -{SELFPARAM(); +void WarpZone_PlayerPhysics_FixVAngle(entity this) +{ #ifndef WARPZONE_DONT_FIX_VANGLE - if(IS_REAL_CLIENT(self)) - if(self.v_angle.z <= 360) // if not already adjusted - if(time - self.ping * 0.001 < self.warpzone_teleport_time) + if(IS_REAL_CLIENT(this)) + if(this.v_angle.z <= 360) // if not already adjusted + if(time - this.ping * 0.001 < this.warpzone_teleport_time) { - self.v_angle = WarpZone_TransformVAngles(self.warpzone_teleport_zone, self.v_angle); - self.v_angle_z += 720; // mark as adjusted + this.v_angle = WarpZone_TransformVAngles(this.warpzone_teleport_zone, this.v_angle); + this.v_angle_z += 720; // mark as adjusted } #endif } diff --git a/qcsrc/lib/warpzone/server.qh b/qcsrc/lib/warpzone/server.qh index 0e0594a1b..db0ba59cc 100644 --- a/qcsrc/lib/warpzone/server.qh +++ b/qcsrc/lib/warpzone/server.qh @@ -13,7 +13,7 @@ float WarpZone_Projectile_Touch_ImpactFilter_Callback(); //const float ENT_CLIENT_WARPZONE; //const float ENT_CLIENT_WARPZONE_CAMERA; -void WarpZone_PlayerPhysics_FixVAngle(); +void WarpZone_PlayerPhysics_FixVAngle(entity this); void WarpZone_PostInitialize_Callback(); #endif diff --git a/qcsrc/lib/warpzone/util_server.qc b/qcsrc/lib/warpzone/util_server.qc index 92c347a15..be232a281 100644 --- a/qcsrc/lib/warpzone/util_server.qc +++ b/qcsrc/lib/warpzone/util_server.qc @@ -12,38 +12,38 @@ void WarpZoneLib_ExactTrigger_Init() {SELFPARAM(); vector mi, ma; - if (self.movedir == '0 0 0') - if (self.angles != '0 0 0') + if (this.movedir == '0 0 0') + if (this.angles != '0 0 0') { - makevectors (self.angles); - self.movedir = v_forward; + makevectors (this.angles); + this.movedir = v_forward; } - if(self.model == "") + if(this.model == "") { // It's a box! No need to match with exacttriggers. - self.warpzone_isboxy = 1; + this.warpzone_isboxy = 1; } else { - mi = self.mins; - ma = self.maxs; - precache_model(self.model); - _setmodel(self, self.model); + mi = this.mins; + ma = this.maxs; + precache_model(this.model); + _setmodel(this, this.model); // let mapper-set mins/maxs override the model's bounds if set if(mi != '0 0 0' || ma != '0 0 0') { // It's a box! No need to match with exacttriggers. - self.mins = mi; - self.maxs = ma; - self.warpzone_isboxy = 1; + this.mins = mi; + this.maxs = ma; + this.warpzone_isboxy = 1; } } - setorigin(self, self.origin); - if(self.scale) - setsize(self, self.mins * self.scale, self.maxs * self.scale); + setorigin(this, this.origin); + if(this.scale) + setsize(this, this.mins * this.scale, this.maxs * this.scale); else - setsize(self, self.mins, self.maxs); - self.movetype = MOVETYPE_NONE; - self.solid = SOLID_TRIGGER; - self.model = ""; + setsize(this, this.mins, this.maxs); + this.movetype = MOVETYPE_NONE; + this.solid = SOLID_TRIGGER; + this.model = ""; } diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 8a6eefe86..5d739ac7b 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -2050,7 +2050,7 @@ void() nexball_setstatus; .int items_added; void PlayerPreThink () {SELFPARAM(); - WarpZone_PlayerPhysics_FixVAngle(); + WarpZone_PlayerPhysics_FixVAngle(self); self.stat_game_starttime = game_starttime; self.stat_round_starttime = round_starttime;