protocol: Add support for BJP version 1, 2 & 3 protocols

Now pull together all that previous work and enable the BJP
protocols. Each uses a different combination of bytes/shorts for
models, static and dymanic sounds.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
This commit is contained in:
Kevin Shanahan 2012-02-12 21:02:55 +10:30
parent 8088798681
commit 05ee56fc9c
4 changed files with 49 additions and 1 deletions

View File

@ -115,7 +115,11 @@ CL_ReadSoundNum()
{
switch (cl.protocol) {
case PROTOCOL_VERSION_NQ:
case PROTOCOL_VERSION_BJP:
return MSG_ReadByte();
case PROTOCOL_VERSION_BJP2:
case PROTOCOL_VERSION_BJP3:
return MSG_ReadShort();
default:
Host_Error("%s: Unknown protocol version (%d)\n", __func__,
cl.protocol);
@ -350,6 +354,10 @@ CL_ReadModelIndex(void)
switch (cl.protocol) {
case PROTOCOL_VERSION_NQ:
return MSG_ReadByte();
case PROTOCOL_VERSION_BJP:
case PROTOCOL_VERSION_BJP2:
case PROTOCOL_VERSION_BJP3:
return MSG_ReadShort();
default:
Host_Error("%s: Unknown protocol version (%d)\n", __func__,
cl.protocol);
@ -722,7 +730,11 @@ CL_ReadSoundNum_Static(void)
{
switch (cl.protocol) {
case PROTOCOL_VERSION_NQ:
case PROTOCOL_VERSION_BJP:
case PROTOCOL_VERSION_BJP3:
return MSG_ReadByte();
case PROTOCOL_VERSION_BJP2:
return MSG_ReadShort();
default:
Host_Error("%s: Unknown protocol version (%d)\n", __func__,
cl.protocol);

View File

@ -534,8 +534,13 @@ PF_WriteSoundNum_Static(sizebuf_t *sb, int c)
{
switch (sv.protocol) {
case PROTOCOL_VERSION_NQ:
case PROTOCOL_VERSION_BJP:
case PROTOCOL_VERSION_BJP3:
MSG_WriteByte(sb, c);
break;
case PROTOCOL_VERSION_BJP2:
MSG_WriteShort(sb, c);
break;
default:
Host_Error("%s: Unknown protocol version (%d)\n", __func__,
sv.protocol);

View File

@ -25,13 +25,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "qtypes.h"
#define PROTOCOL_VERSION_NQ 15
#define PROTOCOL_VERSION_NQ 15
#define PROTOCOL_VERSION_BJP 10000
#define PROTOCOL_VERSION_BJP2 10001
#define PROTOCOL_VERSION_BJP3 10002
static inline qboolean
Protocol_Known(int version)
{
switch (version) {
case PROTOCOL_VERSION_NQ:
case PROTOCOL_VERSION_BJP:
case PROTOCOL_VERSION_BJP2:
case PROTOCOL_VERSION_BJP3:
return true;
default:
return false;
@ -44,6 +50,10 @@ max_models(int protocol)
switch (protocol) {
case PROTOCOL_VERSION_NQ:
return qmin(256, MAX_MODELS);
case PROTOCOL_VERSION_BJP:
case PROTOCOL_VERSION_BJP2:
case PROTOCOL_VERSION_BJP3:
return qmin(65536, MAX_MODELS);
default:
return 0;
}
@ -54,7 +64,11 @@ max_sounds_static(int protocol)
{
switch (protocol) {
case PROTOCOL_VERSION_NQ:
case PROTOCOL_VERSION_BJP:
case PROTOCOL_VERSION_BJP3:
return qmin(256, MAX_SOUNDS);
case PROTOCOL_VERSION_BJP2:
return qmin(65536, MAX_SOUNDS);
default:
return 0;
}
@ -65,7 +79,11 @@ max_sounds_dynamic(int protocol)
{
switch (protocol) {
case PROTOCOL_VERSION_NQ:
case PROTOCOL_VERSION_BJP:
return qmin(256, MAX_SOUNDS);
case PROTOCOL_VERSION_BJP2:
case PROTOCOL_VERSION_BJP3:
return qmin(65536, MAX_SOUNDS);
default:
return 0;
}

View File

@ -56,6 +56,9 @@ typedef struct {
#define PROT(v, n, d) { .version = v, .name = n, .description = d }
static sv_protocol_t sv_protocols[] = {
PROT(PROTOCOL_VERSION_NQ, "NQ", "Standard NetQuake protocol"),
PROT(PROTOCOL_VERSION_BJP, "BJP", "BJP protocol (v1)"),
PROT(PROTOCOL_VERSION_BJP2, "BJP2", "BJP protocol (v2)"),
PROT(PROTOCOL_VERSION_BJP3, "BJP3", "BJP protocol (v3)")
};
static int sv_protocol = PROTOCOL_VERSION_NQ;
@ -197,8 +200,13 @@ SV_WriteSoundNum(sizebuf_t *sb, int c)
{
switch (sv.protocol) {
case PROTOCOL_VERSION_NQ:
case PROTOCOL_VERSION_BJP:
MSG_WriteByte(sb, c);
break;
case PROTOCOL_VERSION_BJP2:
case PROTOCOL_VERSION_BJP3:
MSG_WriteShort(sb, c);
break;
default:
Host_Error("%s: Unknown protocol version (%d)\n", __func__,
sv.protocol);
@ -526,6 +534,11 @@ SV_WriteModelIndex(sizebuf_t *sb, int c)
case PROTOCOL_VERSION_NQ:
MSG_WriteByte(sb, c);
break;
case PROTOCOL_VERSION_BJP:
case PROTOCOL_VERSION_BJP2:
case PROTOCOL_VERSION_BJP3:
MSG_WriteShort(sb, c);
break;
default:
Host_Error("%s: Unknown protocol version (%d)\n", __func__,
sv.protocol);