[nexuiz-commits] r8684 - in trunk/data: qcsrc/client qcsrc/common qcsrc/server qcsrc/server/bot/havocbot scripts

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sun Feb 28 14:42:05 EST 2010


Author: div0
Date: 2010-02-28 14:42:05 -0500 (Sun, 28 Feb 2010)
New Revision: 8684

Modified:
   trunk/data/qcsrc/client/Main.qc
   trunk/data/qcsrc/client/View.qc
   trunk/data/qcsrc/client/particles.qc
   trunk/data/qcsrc/common/constants.qh
   trunk/data/qcsrc/common/util.qc
   trunk/data/qcsrc/common/util.qh
   trunk/data/qcsrc/server/bot/havocbot/havocbot.qc
   trunk/data/qcsrc/server/miscfunctions.qc
   trunk/data/qcsrc/server/t_teleporters.qc
   trunk/data/scripts/common.shader
Log:
warpzones: properly account for lag - predict them in CSQC

Conflicts:

	data/qcsrc/client/View.qc

Modified: trunk/data/qcsrc/client/Main.qc
===================================================================
--- trunk/data/qcsrc/client/Main.qc	2010-02-28 19:33:07 UTC (rev 8683)
+++ trunk/data/qcsrc/client/Main.qc	2010-02-28 19:42:05 UTC (rev 8684)
@@ -839,6 +839,51 @@
 	psrandom(s);
 }
 
+float FL_CAMERA = 8192;
+.vector warpzone_transform;
+void Ent_WarpZone(float isnew)
+{
+	if not(self.enemy)
+	{
+		self.enemy = spawn();
+		self.enemy.classname = "warpzone_from";
+	}
+	self.classname = "warpzone_to";
+	self.origin_x = ReadCoord();
+	self.origin_y = ReadCoord();
+	self.origin_z = ReadCoord();
+	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.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();
+
+	self.avelocity = AnglesTransform_TurnDirection(self.avelocity);
+	self.warpzone_transform = AnglesTransform_Divide(self.avelocity, self.enemy.avelocity);
+
+	self.flags = FL_CAMERA;
+	self.drawmask = MASK_NORMAL;
+
+	// link me
+	//setmodel(self, self.model);
+	setorigin(self, self.origin);
+	setsize(self, self.mins, self.maxs);
+}
+
 // 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();
@@ -896,6 +941,7 @@
 		case ENT_CLIENT_WALL: Ent_Wall(); break;
 		case ENT_CLIENT_MODELEFFECT: Ent_ModelEffect(bIsNewEntity); break;
 		case ENT_CLIENT_TUBANOTE: Ent_TubaNote(bIsNewEntity); break;
+		case ENT_CLIENT_WARPZONE: Ent_WarpZone(bIsNewEntity); break;
 		default:
 			error(strcat("unknown entity type in CSQC_Ent_Update: ", ftos(self.enttype), "\n"));
 			break;

Modified: trunk/data/qcsrc/client/View.qc
===================================================================
--- trunk/data/qcsrc/client/View.qc	2010-02-28 19:33:07 UTC (rev 8683)
+++ trunk/data/qcsrc/client/View.qc	2010-02-28 19:42:05 UTC (rev 8684)
@@ -346,7 +346,7 @@
 	entity e;
 	float fov;
 	float f, i, j;
-	vector v;
+	vector v, vo;
 
 	WaypointSprite_Load();
 
@@ -356,11 +356,29 @@
 		myteam = GetPlayerColor(player_localentnum - 1);
 
 	ticrate = getstatf(STAT_MOVEVARS_TICRATE) * getstatf(STAT_MOVEVARS_TIMESCALE);
+	vo = '0 0 1' * getstati(STAT_VIEWHEIGHT);
 
+	// if view origin is INSIDE a warpzone, we are screwed and must
+	// temporarily move the origin to the other side of the warp
+	pmove_org = pmove_org + vo;
+	for(e = world; (e = find(e, classname, "warpzone_to")); )
+	{
+		//print(sprintf("does %s (%s to %s) touch %s?\n", e.model, vtos(e.absmin), vtos(e.absmax), vtos(pmove_org)));
+		if(BoxTouchesBrush(pmove_org, pmove_org, e, world))
+		{
+			pmove_org = AnglesTransform_Apply(e.warpzone_transform, pmove_org - e.enemy.oldorigin) + e.oldorigin;
+			input_angles = AnglesTransform_Multiply(e.warpzone_transform, input_angles);
+			R_SetView(VF_ORIGIN, pmove_org);
+			R_SetView(VF_ANGLES, input_angles);
+			break;
+		}
+	}
+	pmove_org = pmove_org - vo;
+
 	// Render the Scene
 	if(!intermission || !view_set)
 	{
-		view_origin = pmove_org + '0 0 1' * getstati(STAT_VIEWHEIGHT);
+		view_origin = pmove_org + vo;
 		view_angles = input_angles;
 		makevectors(view_angles);
 		view_forward = v_forward;

Modified: trunk/data/qcsrc/client/particles.qc
===================================================================
--- trunk/data/qcsrc/client/particles.qc	2010-02-28 19:33:07 UTC (rev 8683)
+++ trunk/data/qcsrc/client/particles.qc	2010-02-28 19:42:05 UTC (rev 8684)
@@ -1,43 +1,5 @@
-vector PointInBrush_vec;
-entity PointInBrush_brush;
 .float dphitcontentsmask;
-float PointInBrush_Recurse()
-{
-	float s;
-	entity se;
-	float f;
 
-	traceline(PointInBrush_vec, PointInBrush_vec, 0, world);
-	if not(trace_ent)
-		return 0;
-	if(trace_ent == PointInBrush_brush)
-		return 1;
-
-	se = trace_ent;
-	s = se.solid;
-	se.solid = SOLID_NOT;
-	f = PointInBrush_Recurse();
-	se.solid = s;
-
-	return f;
-}
-float PointInBrush(entity brush, vector point)
-{
-	float f, s;
-
-	if not(brush.modelindex)
-		return 1;
-
-	s = brush.solid;
-	brush.solid = SOLID_BSP;
-	PointInBrush_vec = point;
-	PointInBrush_brush = brush;
-	f = PointInBrush_Recurse();
-	brush.solid = s;
-
-	return f;
-}
-
 .float cnt; // effect number
 .vector velocity; // particle velocity
 .float waterlevel; // direction jitter
@@ -81,7 +43,7 @@
 		p_x += random() * sz_x;
 		p_y += random() * sz_y;
 		p_z += random() * sz_z;
-		if(PointInBrush(self, p))
+		if(BoxTouchesBrush(p, p, self, world))
 		{
 			if(self.movedir != '0 0 0')
 			{

Modified: trunk/data/qcsrc/common/constants.qh
===================================================================
--- trunk/data/qcsrc/common/constants.qh	2010-02-28 19:33:07 UTC (rev 8683)
+++ trunk/data/qcsrc/common/constants.qh	2010-02-28 19:42:05 UTC (rev 8684)
@@ -96,6 +96,7 @@
 const float ENT_CLIENT_SPIDERBOT = 21;
 const float ENT_CLIENT_MODELEFFECT = 22;
 const float ENT_CLIENT_TUBANOTE = 23;
+const float ENT_CLIENT_WARPZONE = 24;
 
 const float ENT_CLIENT_TURRET = 40;
 

Modified: trunk/data/qcsrc/common/util.qc
===================================================================
--- trunk/data/qcsrc/common/util.qc	2010-02-28 19:33:07 UTC (rev 8683)
+++ trunk/data/qcsrc/common/util.qc	2010-02-28 19:42:05 UTC (rev 8684)
@@ -1916,3 +1916,60 @@
 {
 	return strcasecmp(substring(haystack, 0, strlen(needle)), needle) == 0;
 }
+
+#ifndef MENUQC
+vector BoxTouchesBrush_mins;
+vector BoxTouchesBrush_maxs;
+entity BoxTouchesBrush_ent;
+entity BoxTouchesBrush_ignore;
+float BoxTouchesBrush_Recurse()
+{
+	float s;
+	entity se;
+	float f;
+
+	tracebox('0 0 0', BoxTouchesBrush_mins, BoxTouchesBrush_maxs, '0 0 0', MOVE_NOMONSTERS, BoxTouchesBrush_ignore);
+#ifdef CSQC
+	if (trace_networkentity)
+	{
+		dprint("hit a network ent, cannot continue BoxTouchesBrush\n");
+		// we cannot continue, as a player blocks us...
+		// so, abort
+		return 0;
+	}
+#endif
+	if not(trace_ent)
+		return 0;
+	if (trace_ent == BoxTouchesBrush_ent)
+		return 1;
+
+	
+
+	se = trace_ent;
+	s = se.solid;
+	se.solid = SOLID_NOT;
+	f = BoxTouchesBrush_Recurse();
+	se.solid = s;
+
+	return f;
+}
+
+float BoxTouchesBrush(vector mi, vector ma, entity e, entity ig)
+{
+    float f, s;
+
+    if not(e.modelindex)
+        return 1;
+
+    s = e.solid;
+    e.solid = SOLID_BSP;
+    BoxTouchesBrush_mins = mi;
+    BoxTouchesBrush_maxs = ma;
+    BoxTouchesBrush_ent = e;
+    BoxTouchesBrush_ignore = ig;
+    f = BoxTouchesBrush_Recurse();
+    e.solid = s;
+
+    return f;
+}
+#endif

Modified: trunk/data/qcsrc/common/util.qh
===================================================================
--- trunk/data/qcsrc/common/util.qh	2010-02-28 19:33:07 UTC (rev 8683)
+++ trunk/data/qcsrc/common/util.qh	2010-02-28 19:42:05 UTC (rev 8684)
@@ -211,3 +211,7 @@
 float matchacl(string acl, string str); // matches str against ACL acl (with entries +foo*, +foo, +*foo, +*foo*, and same with - for forbidding)
 float startsWith(string haystack, string needle);
 float startsWithNocase(string haystack, string needle);
+
+#ifndef MENUQC
+float BoxTouchesBrush(vector mi, vector ma, entity e, entity ig);
+#endif

Modified: trunk/data/qcsrc/server/bot/havocbot/havocbot.qc
===================================================================
--- trunk/data/qcsrc/server/bot/havocbot/havocbot.qc	2010-02-28 19:33:07 UTC (rev 8683)
+++ trunk/data/qcsrc/server/bot/havocbot/havocbot.qc	2010-02-28 19:42:05 UTC (rev 8684)
@@ -1285,22 +1285,11 @@
 	entity head;
 	for(head = world; (head = find(head, classname, "trigger_teleport")); )
 	{
-		entity s, o;
-		s = self;
-		o = other;
-		self = head;
-		other = spawn();
-		other.absmin = pos;
-		other.absmax = pos;
-		other.dphitcontentsmask = self.dphitcontentsmask;
-		if(ExactTriggerHit())
+		if(BoxTouchesBrush(pos, pos, head, world))
 		{
 			wp.wpflags |= WAYPOINTFLAG_TELEPORT;
-			s.lastteleporttime = 0;
+			self.lastteleporttime = 0;
 		}
-		remove(other);
-		self = s;
-		other = o;
 	}
 
 /*

Modified: trunk/data/qcsrc/server/miscfunctions.qc
===================================================================
--- trunk/data/qcsrc/server/miscfunctions.qc	2010-02-28 19:33:07 UTC (rev 8683)
+++ trunk/data/qcsrc/server/miscfunctions.qc	2010-02-28 19:42:05 UTC (rev 8684)
@@ -1751,48 +1751,8 @@
 #define WRITESPECTATABLE_MSG_ONE(statement) WRITESPECTATABLE_MSG_ONE_VARNAME(oldmsg_entity, statement)
 #define WRITESPECTATABLE(msg,statement) if(msg == MSG_ONE) { WRITESPECTATABLE_MSG_ONE(statement); } else statement float WRITESPECTATABLE_workaround = 0
 
-vector ExactTriggerHit_mins;
-vector ExactTriggerHit_maxs;
-float ExactTriggerHit_Recurse()
-{
-    float s;
-    entity se;
-    float f;
-
-    tracebox('0 0 0', ExactTriggerHit_mins, ExactTriggerHit_maxs, '0 0 0', MOVE_NORMAL, other);
-    if not(trace_ent)
-        return 0;
-    if (trace_ent == self)
-        return 1;
-
-    se = trace_ent;
-    s = se.solid;
-    se.solid = SOLID_NOT;
-    f = ExactTriggerHit_Recurse();
-    se.solid = s;
-
-    return f;
-}
-
-float ExactTriggerHit()
-{
-    float f, s;
-
-    if not(self.modelindex)
-        return 1;
-
-    s = self.solid;
-    self.solid = SOLID_BSP;
-    ExactTriggerHit_mins = other.absmin;
-    ExactTriggerHit_maxs = other.absmax;
-    f = ExactTriggerHit_Recurse();
-    self.solid = s;
-
-    return f;
-}
-
 // WARNING: this kills the trace globals
-#define EXACTTRIGGER_TOUCH if not(ExactTriggerHit()) return
+#define EXACTTRIGGER_TOUCH if not(BoxTouchesBrush(other.absmin, other.absmax, self, other)) return
 #define EXACTTRIGGER_INIT  InitSolidBSPTrigger(); self.solid = SOLID_TRIGGER
 
 #define INITPRIO_FIRST              0

Modified: trunk/data/qcsrc/server/t_teleporters.qc
===================================================================
--- trunk/data/qcsrc/server/t_teleporters.qc	2010-02-28 19:33:07 UTC (rev 8683)
+++ trunk/data/qcsrc/server/t_teleporters.qc	2010-02-28 19:42:05 UTC (rev 8684)
@@ -325,7 +325,7 @@
 {
 	vector o0, a0, v0, o1, a1, v1;
 
-	o0 = player.origin;
+	o0 = player.origin + player.view_ofs;
 	v0 = player.velocity;
 	a0 = player.angles;
 
@@ -343,7 +343,7 @@
 		a1 = AnglesTransform_Multiply(self.warpzone_transform, a0);
 
 	// put him inside solid
-	tracebox(o1, player.mins, player.maxs, o1, MOVE_NOMONSTERS, player);
+	tracebox(o1 - player.view_ofs, player.mins, player.maxs, o1 - player.view_ofs, MOVE_NOMONSTERS, player);
 	if(trace_startsolid)
 	{
 		print("in solid\n");
@@ -359,7 +359,7 @@
 	//print(sprintf("warpzone: %f %f %f -> %f %f %f\n", o0_x, o0_y, o0_z, o1_x, o1_y, o1_z));
 
 	//o1 = trace_endpos;
-	TeleportPlayer(self, other, o1, a1, v1, '0 0 0', '0 0 0', TELEPORT_FLAGS_WARPZONE);
+	TeleportPlayer(self, other, o1 - player.view_ofs, a1, v1, '0 0 0', '0 0 0', TELEPORT_FLAGS_WARPZONE);
 
 	return 1;
 }
@@ -425,6 +425,40 @@
 	self.touch = warpzone_touch;
 }
 
+float warpzone_send(entity to, float sendflags)
+{
+	WriteByte(MSG_ENTITY, ENT_CLIENT_WARPZONE);
+
+	// we need THESE to render the warpzone (and cull properly)...
+	WriteCoord(MSG_ENTITY, self.origin_x);
+	WriteCoord(MSG_ENTITY, self.origin_y);
+	WriteCoord(MSG_ENTITY, self.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);
+
+	// 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.enemy.warpzone_origin_x);
+	WriteCoord(MSG_ENTITY, self.enemy.warpzone_origin_y);
+	WriteCoord(MSG_ENTITY, self.enemy.warpzone_origin_z);
+	WriteCoord(MSG_ENTITY, self.enemy.warpzone_angles_x);
+	WriteCoord(MSG_ENTITY, self.enemy.warpzone_angles_y);
+	WriteCoord(MSG_ENTITY, self.enemy.warpzone_angles_z);
+
+	return TRUE;
+}
+
 void spawnfunc_trigger_warpzone(void)
 {
 	// warp zone entities must have:
@@ -435,9 +469,13 @@
 	//              the map, with another killtarget to designate its
 	//              orientation
 	
+	string m;
+	m = self.model;
 	EXACTTRIGGER_INIT;
+	setmodel(self, m);
 
 	self.use = trigger_teleport_use; // set team
 	InitializeEntity(self, warpzone_findtarget, INITPRIO_FINDTARGET);
 	InitializeEntity(self, warpzone_updatetransform, INITPRIO_LAST);
+	Net_LinkEntity(self, FALSE, 0, warpzone_send);
 }

Modified: trunk/data/scripts/common.shader
===================================================================
--- trunk/data/scripts/common.shader	2010-02-28 19:33:07 UTC (rev 8683)
+++ trunk/data/scripts/common.shader	2010-02-28 19:42:05 UTC (rev 8684)
@@ -348,3 +348,16 @@
 	surfaceparm lightgrid
 }
 
+
+textures/common/warpzone
+{
+	surfaceparm nolightmap
+	surfaceparm nonsolid
+	surfaceparm trans
+	surfaceparm nomarks
+	{
+		map textures/common/mirror1.tga // fully transparent
+		blendfunc blend
+	}
+	dp_refract 1 1 1 1
+}



More information about the nexuiz-commits mailing list