From d67e7f0f80e43e2464f026c846eeb71ad90030cb Mon Sep 17 00:00:00 2001 From: Cloudwalk Date: Tue, 22 Sep 2020 00:13:12 -0400 Subject: [PATCH] Fix compatibility with DP's own server with NEHAHRABJP2 and 3 protocols. Actually adhere to the protocols with regards to modelindex and soundindex widths. --- cl_parse.c | 2 +- cl_protocol_basenq.h | 4 ++-- sv_main.c | 6 +++--- svvm_cmds.c | 17 ++++++++++------- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/cl_parse.c b/cl_parse.c index c70a3391..b89027ee 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -2170,7 +2170,7 @@ void CL_ParseStaticSound (int large) int sound_num, vol, atten; cls.protocol->ReadVector(&cl_message, org); - if (large || cls.protocol == &protocol_nehahrabjp2) + if (large) sound_num = (unsigned short) MSG_ReadShort(&cl_message); else sound_num = MSG_ReadByte(&cl_message); diff --git a/cl_protocol_basenq.h b/cl_protocol_basenq.h index f969245b..7d2b473f 100644 --- a/cl_protocol_basenq.h +++ b/cl_protocol_basenq.h @@ -59,7 +59,7 @@ static void Netmsg_svc_setview (protocol_t *protocol) // [short] entity number static void Netmsg_svc_sound (protocol_t *protocol) // { - CL_ParseStartSoundPacket(false); + CL_ParseStartSoundPacket(protocol == &protocol_nehahrabjp2 || protocol == &protocol_nehahrabjp3 ? true : false); } static void Netmsg_svc_time (protocol_t *protocol) // [float] server time @@ -255,7 +255,7 @@ static void Netmsg_svc_foundsecret (protocol_t *protocol) static void Netmsg_svc_spawnstaticsound (protocol_t *protocol) { - CL_ParseStaticSound (false); + CL_ParseStaticSound (protocol == &protocol_nehahrabjp2 || protocol == &protocol_nehahrabjp3 ? true : false); } static void Netmsg_svc_intermission (protocol_t *protocol) diff --git a/sv_main.c b/sv_main.c index 75b2f1b4..34a72b24 100644 --- a/sv_main.c +++ b/sv_main.c @@ -794,7 +794,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); @@ -3015,7 +3015,7 @@ SV_ModelIndex */ int SV_ModelIndex(const char *s, int precachemode) { - int i, limit = ((sv.protocol == &protocol_netquake || 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_netquake || sv.protocol == &protocol_quakedp || sv.protocol == &protocol_nehahramovie) ? 256 : MAX_MODELS); char filename[MAX_QPATH]; if (!s || !*s) return 0; @@ -3078,7 +3078,7 @@ SV_SoundIndex */ int SV_SoundIndex(const char *s, int precachemode) { - int i, limit = ((sv.protocol == &protocol_netquake || 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_netquake || 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/svvm_cmds.c b/svvm_cmds.c index ffb9af8e..57c1c802 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) sv.protocol->WriteVector(&sv.signon, pos); - 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 { -- 2.39.2