From 6410f687e7b3b98833547e264fff519dae421b86 Mon Sep 17 00:00:00 2001
From: divverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Date: Tue, 16 Aug 2011 12:10:18 +0000
Subject: [PATCH] MOVETYPE_FLY_WORLDONLY (movetype 33)

Can't explain here what it does, Captain Obvious would enjoy it too much.

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11281 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=386d8ad395308eb4977346110b348562f3eadfb8
---
 dpdefs/dpextensions.qc |  8 ++++++++
 server.h               |  1 +
 sv_phys.c              | 12 ++++++++++--
 svvm_cmds.c            |  1 +
 4 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/dpdefs/dpextensions.qc b/dpdefs/dpextensions.qc
index a0e5a36c..91f5ee23 100644
--- a/dpdefs/dpextensions.qc
+++ b/dpdefs/dpextensions.qc
@@ -520,6 +520,14 @@ void(entity e, entity tagentity, string tagname) setattachment = #443; // attach
 //description:
 //MOVETYPE_BOUNCE but without gravity, and with full reflection (no speed loss like grenades have), in other words - bouncing laser bolts.
 
+//DP_MOVETYPEFLYWORLDONLY
+//idea: Samual
+//darkplaces implementation: Samual
+//movetype definitions:
+float MOVETYPE_FLY_WORLDONLY = 33;
+//description:
+//like MOVETYPE_FLY, but does all traces with MOVE_WORLDONLY, and is ignored by MOVETYPE_PUSH. Should only be combined with SOLID_NOT and SOLID_TRIGGER.
+
 //DP_NULL_MODEL
 //idea: Chris
 //darkplaces implementation: divVerent
diff --git a/server.h b/server.h
index b8339b2e..ed552a14 100644
--- a/server.h
+++ b/server.h
@@ -317,6 +317,7 @@ typedef struct client_s
 #define MOVETYPE_FOLLOW			12		///< track movement of aiment
 #define MOVETYPE_FAKEPUSH		13		///< tenebrae's push that doesn't push
 #define MOVETYPE_PHYSICS		32		///< indicates this object is physics controlled
+#define MOVETYPE_FLY_WORLDONLY		33		///< like MOVETYPE_FLY, but uses MOVE_WORLDONLY for all its traces; objects of this movetype better be SOLID_NOT or SOLID_TRIGGER please, or else...
 
 // edict->solid values
 #define	SOLID_NOT				0		///< no interaction with other objects
diff --git a/sv_phys.c b/sv_phys.c
index 24276208..7b9d705a 100644
--- a/sv_phys.c
+++ b/sv_phys.c
@@ -919,7 +919,7 @@ static int SV_TestEntityPosition (prvm_edict_t *ent, vec3_t offset)
 	trace_t trace;
 	contents = SV_GenericHitSuperContentsMask(ent);
 	VectorAdd(PRVM_serveredictvector(ent, origin), offset, org);
-	trace = SV_TraceBox(org, PRVM_serveredictvector(ent, mins), PRVM_serveredictvector(ent, maxs), PRVM_serveredictvector(ent, origin), MOVE_NOMONSTERS, ent, contents);
+	trace = SV_TraceBox(org, PRVM_serveredictvector(ent, mins), PRVM_serveredictvector(ent, maxs), PRVM_serveredictvector(ent, origin), ((PRVM_serveredictfloat(ent, movetype) == MOVETYPE_FLY_WORLDONLY) ? MOVE_WORLDONLY : MOVE_NOMONSTERS), ent, contents);
 	if (trace.startsupercontents & contents)
 		return true;
 	else
@@ -987,7 +987,8 @@ void SV_CheckAllEnts (void)
 		if (PRVM_serveredictfloat(check, movetype) == MOVETYPE_PUSH
 		 || PRVM_serveredictfloat(check, movetype) == MOVETYPE_NONE
 		 || PRVM_serveredictfloat(check, movetype) == MOVETYPE_FOLLOW
-		 || PRVM_serveredictfloat(check, movetype) == MOVETYPE_NOCLIP)
+		 || PRVM_serveredictfloat(check, movetype) == MOVETYPE_NOCLIP
+		 || PRVM_serveredictfloat(check, movetype) == MOVETYPE_FLY_WORLDONLY)
 			continue;
 
 		if (SV_TestEntityPosition (check, vec3_origin))
@@ -1598,6 +1599,8 @@ static qboolean SV_PushEntity (trace_t *trace, prvm_edict_t *ent, vec3_t push, q
 
 	if (movetype == MOVETYPE_FLYMISSILE)
 		type = MOVE_MISSILE;
+	else if (movetype == MOVETYPE_FLY_WORLDONLY)
+		type = MOVE_WORLDONLY;
 	else if (solid == SOLID_TRIGGER || solid == SOLID_NOT)
 		type = MOVE_NOMONSTERS; // only clip against bmodels
 	else
@@ -1785,6 +1788,7 @@ void SV_PushMove (prvm_edict_t *pusher, float movetime)
 		case MOVETYPE_PUSH:
 		case MOVETYPE_FOLLOW:
 		case MOVETYPE_NOCLIP:
+		case MOVETYPE_FLY_WORLDONLY:
 			continue;
 		default:
 			break;
@@ -2286,6 +2290,8 @@ void SV_WalkMove (prvm_edict_t *ent)
 		VectorSet(downmove, PRVM_serveredictvector(ent, origin)[0], PRVM_serveredictvector(ent, origin)[1], PRVM_serveredictvector(ent, origin)[2] - 1);
 		if (PRVM_serveredictfloat(ent, movetype) == MOVETYPE_FLYMISSILE)
 			type = MOVE_MISSILE;
+		else if (PRVM_serveredictfloat(ent, movetype) == MOVETYPE_FLY_WORLDONLY)
+			type = MOVE_WORLDONLY;
 		else if (PRVM_serveredictfloat(ent, solid) == SOLID_TRIGGER || PRVM_serveredictfloat(ent, solid) == SOLID_NOT)
 			type = MOVE_NOMONSTERS; // only clip against bmodels
 		else
@@ -2826,6 +2832,7 @@ static void SV_Physics_Entity (prvm_edict_t *ent)
 	case MOVETYPE_BOUNCEMISSILE:
 	case MOVETYPE_FLYMISSILE:
 	case MOVETYPE_FLY:
+	case MOVETYPE_FLY_WORLDONLY:
 		// regular thinking
 		if (SV_RunThink (ent))
 			SV_Physics_Toss (ent);
@@ -2998,6 +3005,7 @@ static void SV_Physics_ClientEntity(prvm_edict_t *ent)
 		SV_Physics_Toss (ent);
 		break;
 	case MOVETYPE_FLY:
+	case MOVETYPE_FLY_WORLDONLY:
 		SV_RunThink (ent);
 		SV_WalkMove (ent);
 		break;
diff --git a/svvm_cmds.c b/svvm_cmds.c
index f252ade1..617d1e33 100644
--- a/svvm_cmds.c
+++ b/svvm_cmds.c
@@ -74,6 +74,7 @@ const char *vm_sv_extensions =
 "DP_LITSUPPORT "
 "DP_MONSTERWALK "
 "DP_MOVETYPEBOUNCEMISSILE "
+"DP_MOVETYPEFLYWORLDONLY "
 "DP_MOVETYPEFOLLOW "
 "DP_NULL_MODEL "
 "DP_QC_ASINACOSATANATAN2TAN "
-- 
2.39.5