From: bones_was_here <bones_was_here@xonotic.au>
Date: Thu, 15 Jun 2023 18:57:18 +0000 (+1000)
Subject: items: temp kludge to reduce visibility of prediction errors
X-Git-Tag: xonotic-v0.8.6~7^2
X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=ffacefe00ac83d2fd630268ff1e2d56854883876;p=xonotic%2Fxonotic-data.pk3dir.git

items: temp kludge to reduce visibility of prediction errors

FIXME PROPERLY: needs moar sv_legacy_bbox_expand 0
---

diff --git a/qcsrc/client/items/items.qc b/qcsrc/client/items/items.qc
index c1bcfe6e54..755f0f9cd4 100644
--- a/qcsrc/client/items/items.qc
+++ b/qcsrc/client/items/items.qc
@@ -315,6 +315,15 @@ NET_HANDLE(ENT_CLIENT_ITEM, bool isnew)
 		set_movetype(this, MOVETYPE_TOSS);
 		this.velocity = ReadVector();
 	}
+	else if (this.gravity) // caution: kludge FIXME (with sv_legacy_bbox_expand)
+	{
+		// workaround for prediction errors caused by bbox discrepancy between SVQC and CSQC
+		this.gravity = 0; // don't do this kludge again
+		this.pushable = false; // no fun allowed
+		set_movetype(this, MOVETYPE_NONE); // disable physics
+		this.velocity = '0 0 0'; // disable it more
+		SET_ONGROUND(this); // extra overkill
+	}
 
 	this.entremove = ItemRemove;
 
diff --git a/qcsrc/common/items/item.qh b/qcsrc/common/items/item.qh
index 2de498aaf4..0385667847 100644
--- a/qcsrc/common/items/item.qh
+++ b/qcsrc/common/items/item.qh
@@ -63,7 +63,8 @@ const int ITS_EXPIRING          = BIT(7);
 const float IT_DESPAWNFX_TIME = 1.5;
 
 // 2hz probably enough to correct a desync caused by serious lag
-const float IT_UPDATE_INTERVAL = 0.5;
+// FIXME but updating faster applies the kludge in Item_Think() sooner so it's less noticeable
+const float IT_UPDATE_INTERVAL = 0.0625;
 
 .float fade_start;
 .float fade_end;
diff --git a/qcsrc/server/items/items.qc b/qcsrc/server/items/items.qc
index 3aef870e00..46587b9c1d 100644
--- a/qcsrc/server/items/items.qc
+++ b/qcsrc/server/items/items.qc
@@ -205,6 +205,11 @@ void Item_Think(entity this)
 		if (this.itemdef.instanceOfPowerup)
 			powerups_DropItem_Think(this);
 
+		// caution: kludge FIXME (with sv_legacy_bbox_expand)
+		// this works around prediction errors caused by bbox discrepancy between SVQC and CSQC
+		if (this.velocity == '0 0 0' && IS_ONGROUND(this))
+			this.gravity = 0; // don't send ISF_DROP anymore
+
 		// send slow updates even if the item didn't move
 		// recovers prediction desyncs where server thinks item stopped, client thinks it didn't
 		ItemUpdate(this);