From: cloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Date: Fri, 16 Oct 2020 22:46:06 +0000 (+0000)
Subject: Fix compatibility with DP's own server with NEHAHRABJP2 and 3 protocols.
X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=4ca9cdd79f030a5cae2b073c9b5c8c740ed2c2bd;p=xonotic%2Fdarkplaces.git

Fix compatibility with DP's own server with NEHAHRABJP2 and 3 protocols.

Actually adhere to the protocols with regards to modelindex and
soundindex widths.

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@13021 d7cf8633-e32d-0410-b094-e92efae38249
---

diff --git a/cl_parse.c b/cl_parse.c
index 4f1a07e2..30b2d3cc 100644
--- a/cl_parse.c
+++ b/cl_parse.c
@@ -2300,7 +2300,7 @@ static void CL_ParseStaticSound (int large)
 	int			sound_num, vol, atten;
 
 	MSG_ReadVector(&cl_message, org, cls.protocol);
-	if (large || cls.protocol == PROTOCOL_NEHAHRABJP2)
+	if (large)
 		sound_num = (unsigned short) MSG_ReadShort(&cl_message);
 	else
 		sound_num = MSG_ReadByte(&cl_message);
@@ -3976,7 +3976,7 @@ void CL_ParseServerMessage(void)
 				break;
 
 			case svc_sound:
-				CL_ParseStartSoundPacket(false);
+				CL_ParseStartSoundPacket(cls.protocol == PROTOCOL_NEHAHRABJP2 || cls.protocol == PROTOCOL_NEHAHRABJP3 ? true : false);
 				break;
 
 			case svc_precache:
@@ -4125,7 +4125,7 @@ void CL_ParseServerMessage(void)
 				break;
 
 			case svc_spawnstaticsound:
-				CL_ParseStaticSound (false);
+				CL_ParseStaticSound (cls.protocol == PROTOCOL_NEHAHRABJP2 || cls.protocol == PROTOCOL_NEHAHRABJP3 ? true : false);
 				break;
 
 			case svc_spawnstaticsound2:
diff --git a/sv_main.c b/sv_main.c
index 05134680..d60e98e6 100644
--- a/sv_main.c
+++ b/sv_main.c
@@ -1377,7 +1377,7 @@ SV_ModelIndex
 */
 int SV_ModelIndex(const char *s, int precachemode)
 {
-	int i, limit = ((sv.protocol == PROTOCOL_QUAKE || sv.protocol == PROTOCOL_QUAKEDP || sv.protocol == PROTOCOL_NEHAHRAMOVIE || sv.protocol == PROTOCOL_NEHAHRABJP || sv.protocol == PROTOCOL_NEHAHRABJP2 || sv.protocol == PROTOCOL_NEHAHRABJP3) ? 256 : MAX_MODELS);
+	int i, limit = ((sv.protocol == PROTOCOL_QUAKE || sv.protocol == PROTOCOL_QUAKEDP || sv.protocol == PROTOCOL_NEHAHRAMOVIE) ? 256 : MAX_MODELS);
 	char filename[MAX_QPATH];
 	if (!s || !*s)
 		return 0;
@@ -1440,7 +1440,7 @@ SV_SoundIndex
 */
 int SV_SoundIndex(const char *s, int precachemode)
 {
-	int i, limit = ((sv.protocol == PROTOCOL_QUAKE || sv.protocol == PROTOCOL_QUAKEDP || sv.protocol == PROTOCOL_NEHAHRAMOVIE || sv.protocol == PROTOCOL_NEHAHRABJP || sv.protocol == PROTOCOL_NEHAHRABJP2 || sv.protocol == PROTOCOL_NEHAHRABJP3) ? 256 : MAX_SOUNDS);
+	int i, limit = ((sv.protocol == PROTOCOL_QUAKE || sv.protocol == PROTOCOL_QUAKEDP || sv.protocol == PROTOCOL_NEHAHRAMOVIE || sv.protocol == PROTOCOL_NEHAHRABJP) ? 256 : MAX_SOUNDS);
 	char filename[MAX_QPATH];
 	if (!s || !*s)
 		return 0;
diff --git a/sv_send.c b/sv_send.c
index a9aec2b9..984f9635 100644
--- a/sv_send.c
+++ b/sv_send.c
@@ -291,7 +291,7 @@ void SV_StartSound (prvm_edict_t *entity, int channel, const char *sample, int n
 	}
 	else
 		MSG_WriteShort (dest, (ent<<3) | channel);
-	if ((field_mask & SND_LARGESOUND) || sv.protocol == PROTOCOL_NEHAHRABJP2)
+	if ((field_mask & SND_LARGESOUND) || sv.protocol == PROTOCOL_NEHAHRABJP2 || sv.protocol == PROTOCOL_NEHAHRABJP3)
 		MSG_WriteShort (dest, sound_num);
 	else
 		MSG_WriteByte (dest, sound_num);
diff --git a/svvm_cmds.c b/svvm_cmds.c
index ac391a3e..d2ad2d81 100644
--- a/svvm_cmds.c
+++ b/svvm_cmds.c
@@ -488,6 +488,9 @@ static void VM_SV_ambientsound(prvm_prog_t *prog)
 	if (soundnum >= 256)
 		large = true;
 
+	if(sv.protocol == PROTOCOL_NEHAHRABJP)
+		large = false;
+
 	// add an svc_spawnambient command to the level signon packet
 
 	if (large)
@@ -497,7 +500,7 @@ static void VM_SV_ambientsound(prvm_prog_t *prog)
 
 	MSG_WriteVector(&sv.signon, pos, sv.protocol);
 
-	if (large || sv.protocol == PROTOCOL_NEHAHRABJP || sv.protocol == PROTOCOL_NEHAHRABJP2 || sv.protocol == PROTOCOL_NEHAHRABJP3)
+	if (large || sv.protocol == PROTOCOL_NEHAHRABJP2 || sv.protocol == PROTOCOL_NEHAHRABJP3)
 		MSG_WriteShort (&sv.signon, soundnum);
 	else
 		MSG_WriteByte (&sv.signon, soundnum);
@@ -1542,17 +1545,17 @@ static void VM_SV_makestatic(prvm_prog_t *prog)
 	if (PRVM_serveredictfloat(ent, modelindex) >= 256 || PRVM_serveredictfloat(ent, frame) >= 256)
 		large = true;
 
-	if (large)
+	if (sv.protocol == PROTOCOL_NEHAHRABJP || sv.protocol == PROTOCOL_NEHAHRABJP2 || sv.protocol == PROTOCOL_NEHAHRABJP3)
 	{
-		MSG_WriteByte (&sv.signon,svc_spawnstatic2);
+		MSG_WriteByte (&sv.signon,svc_spawnstatic);
 		MSG_WriteShort (&sv.signon, (int)PRVM_serveredictfloat(ent, modelindex));
-		MSG_WriteShort (&sv.signon, (int)PRVM_serveredictfloat(ent, frame));
+		MSG_WriteByte (&sv.signon, (int)PRVM_serveredictfloat(ent, frame));
 	}
-	else if (sv.protocol == PROTOCOL_NEHAHRABJP || sv.protocol == PROTOCOL_NEHAHRABJP2 || sv.protocol == PROTOCOL_NEHAHRABJP3)
+	else if (large)
 	{
-		MSG_WriteByte (&sv.signon,svc_spawnstatic);
+		MSG_WriteByte (&sv.signon,svc_spawnstatic2);
 		MSG_WriteShort (&sv.signon, (int)PRVM_serveredictfloat(ent, modelindex));
-		MSG_WriteByte (&sv.signon, (int)PRVM_serveredictfloat(ent, frame));
+		MSG_WriteShort (&sv.signon, (int)PRVM_serveredictfloat(ent, frame));
 	}
 	else
 	{