summaryrefslogtreecommitdiff
path: root/src/qcommon
diff options
context:
space:
mode:
author/dev/humancontroller <devhc@example.com>2015-02-08 13:55:15 +0100
committer/dev/humancontroller <devhc@example.com>2017-03-09 13:51:18 +0100
commitb392b0d97f3ea048478059873ed6dec8afd9634b (patch)
treee3fb4a9ef70d89bfb70676fe33f9b493da7051ec /src/qcommon
parent65bcf419d4b612b7d626447924fa0fe2079c18c2 (diff)
implement part 1 of the multi-protocol functionality: protocols
this contains support for connecting via, and serving simultaneously via, any of the three protocols: latest, GPP and 1.1 alternate-1 means protocol 70 (GPP), alternate-2 means protocol 69 (1.1) relevant cvars: - net_alternateProtocols - net_alt{1|2}port[6] - sv_alt{1|2}master{1|...|5} - sv_clAltProto{0|..|63}
Diffstat (limited to 'src/qcommon')
-rw-r--r--src/qcommon/common.c2
-rw-r--r--src/qcommon/msg.c373
-rw-r--r--src/qcommon/net_chan.c22
-rw-r--r--src/qcommon/net_ip.c197
-rw-r--r--src/qcommon/q_shared.h1
-rw-r--r--src/qcommon/qcommon.h24
-rw-r--r--src/qcommon/vm.c4
7 files changed, 538 insertions, 85 deletions
diff --git a/src/qcommon/common.c b/src/qcommon/common.c
index cf8b4d83..2644a729 100644
--- a/src/qcommon/common.c
+++ b/src/qcommon/common.c
@@ -33,7 +33,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#endif
int demo_protocols[] =
-{ PROTOCOL_VERSION, 0 };
+{ PROTOCOL_VERSION, 70, 69, 0 };
#define MAX_NUM_ARGVS 50
diff --git a/src/qcommon/msg.c b/src/qcommon/msg.c
index 6e0b88c4..8258abdd 100644
--- a/src/qcommon/msg.c
+++ b/src/qcommon/msg.c
@@ -484,12 +484,12 @@ void MSG_ReadData( msg_t *msg, void *data, int len ) {
// a string hasher which gives the same hash value even if the
// string is later modified via the legacy MSG read/write code
-int MSG_HashKey(const char *string, int maxlen) {
+int MSG_HashKey(int alternateProtocol, const char *string, int maxlen) {
int hash, i;
hash = 0;
for (i = 0; i < maxlen && string[i] != '\0'; i++) {
- if (string[i] & 0x80)
+ if (string[i] & 0x80 || (alternateProtocol == 2 && string[i] == '%'))
hash += '.' * (119 + i);
else
hash += string[i] * (119 + i);
@@ -795,7 +795,7 @@ If force is not set, then nothing at all will be generated if the entity is
identical, under the assumption that the in-order delta code will catch it.
==================
*/
-void MSG_WriteDeltaEntity( msg_t *msg, struct entityState_s *from, struct entityState_s *to,
+void MSG_WriteDeltaEntity( int alternateProtocol, msg_t *msg, struct entityState_s *from, struct entityState_s *to,
qboolean force ) {
int i, lc;
int numFields;
@@ -829,6 +829,9 @@ void MSG_WriteDeltaEntity( msg_t *msg, struct entityState_s *from, struct entity
lc = 0;
// build the change vector as bytes so it is endien independent
for ( i = 0, field = entityStateFields ; i < numFields ; i++, field++ ) {
+ if ( alternateProtocol == 2 && i == 13 ) {
+ continue;
+ }
fromF = (int *)( (byte *)from + field->offset );
toF = (int *)( (byte *)to + field->offset );
if ( *fromF != *toF ) {
@@ -852,11 +855,19 @@ void MSG_WriteDeltaEntity( msg_t *msg, struct entityState_s *from, struct entity
MSG_WriteBits( msg, 0, 1 ); // not removed
MSG_WriteBits( msg, 1, 1 ); // we have a delta
- MSG_WriteByte( msg, lc ); // # of changes
+ if ( alternateProtocol == 2 && lc - 1 > 13 ) {
+ MSG_WriteByte( msg, lc - 1 ); // # of changes
+ } else {
+ MSG_WriteByte( msg, lc ); // # of changes
+ }
oldsize += numFields;
for ( i = 0, field = entityStateFields ; i < lc ; i++, field++ ) {
+ if ( alternateProtocol == 2 && i == 13 ) {
+ continue;
+ }
+
fromF = (int *)( (byte *)from + field->offset );
toF = (int *)( (byte *)to + field->offset );
@@ -894,7 +905,11 @@ void MSG_WriteDeltaEntity( msg_t *msg, struct entityState_s *from, struct entity
} else {
MSG_WriteBits( msg, 1, 1 );
// integer
- MSG_WriteBits( msg, *toF, field->bits );
+ if ( alternateProtocol == 2 && i == 33 ) {
+ MSG_WriteBits( msg, *toF, 8 );
+ } else {
+ MSG_WriteBits( msg, *toF, field->bits );
+ }
}
}
}
@@ -912,7 +927,7 @@ If the delta removes the entity, entityState_t->number will be set to MAX_GENTIT
Can go from either a baseline or a previous packet_entity
==================
*/
-void MSG_ReadDeltaEntity( msg_t *msg, entityState_t *from, entityState_t *to,
+void MSG_ReadDeltaEntity( int alternateProtocol, msg_t *msg, entityState_t *from, entityState_t *to,
int number) {
int i, lc;
int numFields;
@@ -951,6 +966,9 @@ void MSG_ReadDeltaEntity( msg_t *msg, entityState_t *from, entityState_t *to,
numFields = ARRAY_LEN( entityStateFields );
lc = MSG_ReadByte(msg);
+ if ( alternateProtocol == 2 && lc - 1 >= 13 ) {
+ ++lc;
+ }
if ( lc > numFields || lc < 0 ) {
Com_Error( ERR_DROP, "invalid entityState field count" );
@@ -970,6 +988,10 @@ void MSG_ReadDeltaEntity( msg_t *msg, entityState_t *from, entityState_t *to,
for ( i = 0, field = entityStateFields ; i < lc ; i++, field++ ) {
fromF = (int *)( (byte *)from + field->offset );
toF = (int *)( (byte *)to + field->offset );
+ if ( alternateProtocol == 2 && i == 13 ) {
+ *toF = 0;
+ continue;
+ }
if ( ! MSG_ReadBits( msg, 1 ) ) {
// no change
@@ -1002,7 +1024,11 @@ void MSG_ReadDeltaEntity( msg_t *msg, entityState_t *from, entityState_t *to,
*toF = 0;
} else {
// integer
- *toF = MSG_ReadBits( msg, field->bits );
+ if ( alternateProtocol == 2 && i == 33 ) {
+ *toF = MSG_ReadBits( msg, 8 );
+ } else {
+ *toF = MSG_ReadBits( msg, field->bits );
+ }
if ( print ) {
Com_Printf( "%s:%i ", field->name, *toF );
}
@@ -1096,17 +1122,143 @@ netField_t playerStateFields[] =
{ PSF(loopSound), 16 }
};
+typedef struct alternatePlayerState_s {
+ int commandTime; // cmd->serverTime of last executed command
+ int pm_type;
+ int bobCycle; // for view bobbing and footstep generation
+ int pm_flags; // ducked, jump_held, etc
+ int pm_time;
+
+ vec3_t origin;
+ vec3_t velocity;
+ int weaponTime;
+ int gravity;
+ int speed;
+ int delta_angles[3]; // add to command angles to get view direction
+ // changed by spawns, rotating objects, and teleporters
+
+ int groundEntityNum;// ENTITYNUM_NONE = in air
+
+ int legsTimer; // don't change low priority animations until this runs out
+ int legsAnim; // mask off ANIM_TOGGLEBIT
+
+ int torsoTimer; // don't change low priority animations until this runs out
+ int torsoAnim; // mask off ANIM_TOGGLEBIT
+
+ int movementDir; // a number 0 to 7 that represents the relative angle
+ // of movement to the view angle (axial and diagonals)
+ // when at rest, the value will remain unchanged
+ // used to twist the legs during strafing
+
+ vec3_t grapplePoint; // location of grapple to pull towards if PMF_GRAPPLE_PULL
+
+ int eFlags; // copied to entityState_t->eFlags
+
+ int eventSequence; // pmove generated events
+ int events[MAX_PS_EVENTS];
+ int eventParms[MAX_PS_EVENTS];
+
+ int externalEvent; // events set on player from another source
+ int externalEventParm;
+ int externalEventTime;
+
+ int clientNum; // ranges from 0 to MAX_CLIENTS-1
+ int weapon; // copied to entityState_t->weapon
+ int weaponstate;
+
+ vec3_t viewangles; // for fixed views
+ int viewheight;
+
+ // damage feedback
+ int damageEvent; // when it changes, latch the other parms
+ int damageYaw;
+ int damagePitch;
+ int damageCount;
+
+ int stats[MAX_STATS];
+ int persistant[MAX_PERSISTANT]; // stats that aren't cleared on death
+ int misc[MAX_MISC]; // misc data
+ int ammo[MAX_WEAPONS];
+
+ int generic1;
+ int loopSound;
+ int otherEntityNum;
+
+ // not communicated over the net at all
+ int ping; // server to game info for scoreboard
+ int pmove_framecount;
+ int jumppad_frame;
+ int entityEventSequence;
+} alternatePlayerState_t;
+
+#define APSF(x) #x,(size_t)&((alternatePlayerState_t*)0)->x
+
+netField_t alternatePlayerStateFields[] =
+{
+{ APSF(commandTime), 32 },
+{ APSF(origin[0]), 0 },
+{ APSF(origin[1]), 0 },
+{ APSF(bobCycle), 8 },
+{ APSF(velocity[0]), 0 },
+{ APSF(velocity[1]), 0 },
+{ APSF(viewangles[1]), 0 },
+{ APSF(viewangles[0]), 0 },
+{ APSF(weaponTime), -16 },
+{ APSF(origin[2]), 0 },
+{ APSF(velocity[2]), 0 },
+{ APSF(legsTimer), 8 },
+{ APSF(pm_time), -16 },
+{ APSF(eventSequence), 16 },
+{ APSF(torsoAnim), 8 },
+{ APSF(movementDir), 4 },
+{ APSF(events[0]), 8 },
+{ APSF(legsAnim), 8 },
+{ APSF(events[1]), 8 },
+{ APSF(pm_flags), 16 },
+{ APSF(groundEntityNum), GENTITYNUM_BITS },
+{ APSF(weaponstate), 4 },
+{ APSF(eFlags), 16 },
+{ APSF(externalEvent), 10 },
+{ APSF(gravity), -16 },
+{ APSF(speed), -16 },
+{ APSF(delta_angles[1]), 16 },
+{ APSF(externalEventParm), 8 },
+{ APSF(viewheight), -8 },
+{ APSF(damageEvent), 8 },
+{ APSF(damageYaw), 8 },
+{ APSF(damagePitch), 8 },
+{ APSF(damageCount), 8 },
+{ APSF(generic1), 8 },
+{ APSF(pm_type), 8 },
+{ APSF(delta_angles[0]), 16 },
+{ APSF(delta_angles[2]), 16 },
+{ APSF(torsoTimer), 12 },
+{ APSF(eventParms[0]), 8 },
+{ APSF(eventParms[1]), 8 },
+{ APSF(clientNum), 8 },
+{ APSF(weapon), 5 },
+{ APSF(viewangles[2]), 0 },
+{ APSF(grapplePoint[0]), 0 },
+{ APSF(grapplePoint[1]), 0 },
+{ APSF(grapplePoint[2]), 0 },
+{ APSF(otherEntityNum), GENTITYNUM_BITS },
+{ APSF(loopSound), 16 }
+};
+
/*
=============
MSG_WriteDeltaPlayerstate
=============
*/
-void MSG_WriteDeltaPlayerstate( msg_t *msg, struct playerState_s *from, struct playerState_s *to ) {
+void MSG_WriteDeltaPlayerstate( int alternateProtocol, msg_t *msg, struct playerState_s *from, struct playerState_s *to ) {
int i;
playerState_t dummy;
int statsbits;
int persistantbits;
+ int altFromAmmo[3];
+ int altToAmmo[3];
+ int ammobits;
int miscbits;
int numFields;
netField_t *field;
@@ -1123,6 +1275,9 @@ void MSG_WriteDeltaPlayerstate( msg_t *msg, struct playerState_s *from, struct p
lc = 0;
for ( i = 0, field = playerStateFields ; i < numFields ; i++, field++ ) {
+ if ( alternateProtocol == 2 && ( i == 15 || i == 34 || i == 35 || i == 41 ) ) {
+ continue;
+ }
fromF = (int *)( (byte *)from + field->offset );
toF = (int *)( (byte *)to + field->offset );
if ( *fromF != *toF ) {
@@ -1130,11 +1285,29 @@ void MSG_WriteDeltaPlayerstate( msg_t *msg, struct playerState_s *from, struct p
}
}
- MSG_WriteByte( msg, lc ); // # of changes
+ if ( alternateProtocol == 2 ) {
+ if ( lc - 1 > 41 ) {
+ MSG_WriteByte( msg, lc - 4 ); // # of changes
+ } else if ( lc - 1 > 35 ) {
+ MSG_WriteByte( msg, lc - 3 ); // # of changes
+ } else if ( lc - 1 > 34 ) {
+ MSG_WriteByte( msg, lc - 2 ); // # of changes
+ } else if ( lc - 1 > 15 ) {
+ MSG_WriteByte( msg, lc - 1 ); // # of changes
+ } else {
+ MSG_WriteByte( msg, lc ); // # of changes
+ }
+ } else {
+ MSG_WriteByte( msg, lc ); // # of changes
+ }
oldsize += numFields - lc;
for ( i = 0, field = playerStateFields ; i < lc ; i++, field++ ) {
+ if ( alternateProtocol == 2 && ( i == 15 || i == 34 || i == 35 || i == 41 ) ) {
+ continue;
+ }
+
fromF = (int *)( (byte *)from + field->offset );
toF = (int *)( (byte *)to + field->offset );
@@ -1163,7 +1336,17 @@ void MSG_WriteDeltaPlayerstate( msg_t *msg, struct playerState_s *from, struct p
}
} else {
// integer
- MSG_WriteBits( msg, *toF, field->bits );
+ if ( alternateProtocol == 2 ) {
+ if ( i == 20 ) {
+ MSG_WriteBits( msg, *toF, 16 );
+ } else if ( i == 36 ) {
+ MSG_WriteBits( msg, *toF, 8 );
+ } else {
+ MSG_WriteBits( msg, *toF, field->bits );
+ }
+ } else {
+ MSG_WriteBits( msg, *toF, field->bits );
+ }
}
}
@@ -1183,6 +1366,22 @@ void MSG_WriteDeltaPlayerstate( msg_t *msg, struct playerState_s *from, struct p
persistantbits |= 1<<i;
}
}
+ if ( alternateProtocol == 2 ) {
+ altFromAmmo[0] = ( from->weaponAnim & 0xFF ) | ( ( from->pm_flags >> 8 ) & 0xFF00 );
+ altFromAmmo[1] = ( from->ammo & 0xFFF ) | ( ( from->clips << 12 ) & 0xF000 );
+ altFromAmmo[2] = ( from->tauntTimer & 0xFFF ) | ( ( from->generic1 << 4 ) & 0x3000 );
+ altToAmmo[0] = ( to->weaponAnim & 0xFF ) | ( ( to->pm_flags >> 8 ) & 0xFF00 );
+ altToAmmo[1] = ( to->ammo & 0xFFF ) | ( ( to->clips << 12 ) & 0xF000 );
+ altToAmmo[2] = ( to->tauntTimer & 0xFFF ) | ( ( to->generic1 << 4 ) & 0x3000 );
+ ammobits = 0;
+ for (i=0 ; i<3 ; i++) {
+ if (altToAmmo[i] != altFromAmmo[i]) {
+ ammobits |= 1<<i;
+ }
+ }
+ } else {
+ ammobits = 0;
+ }
miscbits = 0;
for (i=0 ; i<MAX_MISC ; i++) {
if (to->misc[i] != from->misc[i]) {
@@ -1190,7 +1389,7 @@ void MSG_WriteDeltaPlayerstate( msg_t *msg, struct playerState_s *from, struct p
}
}
- if (!statsbits && !persistantbits && !miscbits) {
+ if (!statsbits && !persistantbits && !ammobits && !miscbits) {
MSG_WriteBits( msg, 0, 1 ); // no change
oldsize += 4;
return;
@@ -1219,6 +1418,19 @@ void MSG_WriteDeltaPlayerstate( msg_t *msg, struct playerState_s *from, struct p
}
+ if ( alternateProtocol == 2 ) {
+ if ( ammobits ) {
+ MSG_WriteBits( msg, 1, 1 ); // changed
+ MSG_WriteBits( msg, ammobits, 16 );
+ for (i=0 ; i<3 ; i++)
+ if (ammobits & (1<<i) )
+ MSG_WriteShort (msg, altToAmmo[i]);
+ } else {
+ MSG_WriteBits( msg, 0, 1 ); // no change
+ }
+ }
+
+
if ( miscbits ) {
MSG_WriteBits( msg, 1, 1 ); // changed
MSG_WriteBits( msg, miscbits, MAX_MISC );
@@ -1364,6 +1576,145 @@ void MSG_ReadDeltaPlayerstate (msg_t *msg, playerState_t *from, playerState_t *t
}
}
+void MSG_ReadDeltaAlternatePlayerstate (msg_t *msg, alternatePlayerState_t *from, alternatePlayerState_t *to ) {
+ int i, lc;
+ int bits;
+ netField_t *field;
+ int numFields;
+ int startBit, endBit;
+ int print;
+ int *fromF, *toF;
+ int trunc;
+ alternatePlayerState_t dummy;
+
+ if ( !from ) {
+ from = &dummy;
+ Com_Memset( &dummy, 0, sizeof( dummy ) );
+ }
+ *to = *from;
+
+ if ( msg->bit == 0 ) {
+ startBit = msg->readcount * 8 - GENTITYNUM_BITS;
+ } else {
+ startBit = ( msg->readcount - 1 ) * 8 + msg->bit - GENTITYNUM_BITS;
+ }
+
+ // shownet 2/3 will interleave with other printed info, -2 will
+ // just print the delta records
+ if ( cl_shownet && ( cl_shownet->integer >= 2 || cl_shownet->integer == -2 ) ) {
+ print = 1;
+ Com_Printf( "%3i: playerstate ", msg->readcount );
+ } else {
+ print = 0;
+ }
+
+ numFields = ARRAY_LEN( alternatePlayerStateFields );
+ lc = MSG_ReadByte(msg);
+
+ if ( lc > numFields || lc < 0 ) {
+ Com_Error( ERR_DROP, "invalid playerState field count" );
+ }
+
+ for ( i = 0, field = alternatePlayerStateFields ; i < lc ; i++, field++ ) {
+ fromF = (int *)( (byte *)from + field->offset );
+ toF = (int *)( (byte *)to + field->offset );
+
+ if ( ! MSG_ReadBits( msg, 1 ) ) {
+ // no change
+ *toF = *fromF;
+ } else {
+ if ( field->bits == 0 ) {
+ // float
+ if ( MSG_ReadBits( msg, 1 ) == 0 ) {
+ // integral float
+ trunc = MSG_ReadBits( msg, FLOAT_INT_BITS );
+ // bias to allow equal parts positive and negative
+ trunc -= FLOAT_INT_BIAS;
+ *(float *)toF = trunc;
+ if ( print ) {
+ Com_Printf( "%s:%i ", field->name, trunc );
+ }
+ } else {
+ // full floating point value
+ *toF = MSG_ReadBits( msg, 32 );
+ if ( print ) {
+ Com_Printf( "%s:%f ", field->name, *(float *)toF );
+ }
+ }
+ } else {
+ // integer
+ *toF = MSG_ReadBits( msg, field->bits );
+ if ( print ) {
+ Com_Printf( "%s:%i ", field->name, *toF );
+ }
+ }
+ }
+ }
+ for ( i=lc,field = &alternatePlayerStateFields[lc];i<numFields; i++, field++) {
+ fromF = (int *)( (byte *)from + field->offset );
+ toF = (int *)( (byte *)to + field->offset );
+ // no change
+ *toF = *fromF;
+ }
+
+
+ // read the arrays
+ if (MSG_ReadBits( msg, 1 ) ) {
+ // parse stats
+ if ( MSG_ReadBits( msg, 1 ) ) {
+ LOG("PS_STATS");
+ bits = MSG_ReadBits (msg, MAX_STATS);
+ for (i=0 ; i<MAX_STATS ; i++) {
+ if (bits & (1<<i) ) {
+ to->stats[i] = MSG_ReadShort(msg);
+ }
+ }
+ }
+
+ // parse persistant stats
+ if ( MSG_ReadBits( msg, 1 ) ) {
+ LOG("PS_PERSISTANT");
+ bits = MSG_ReadBits (msg, MAX_PERSISTANT);
+ for (i=0 ; i<MAX_PERSISTANT ; i++) {
+ if (bits & (1<<i) ) {
+ to->persistant[i] = MSG_ReadShort(msg);
+ }
+ }
+ }
+
+ // parse ammo
+ if ( MSG_ReadBits( msg, 1 ) ) {
+ LOG("PS_AMMO");
+ bits = MSG_ReadBits (msg, MAX_WEAPONS);
+ for (i=0 ; i<MAX_WEAPONS ; i++) {
+ if (bits & (1<<i) ) {
+ to->ammo[i] = MSG_ReadShort(msg);
+ }
+ }
+ }
+
+ // parse misc data
+ if ( MSG_ReadBits( msg, 1 ) ) {
+ LOG("PS_MISC");
+ bits = MSG_ReadBits (msg, MAX_MISC);
+ for (i=0 ; i<MAX_MISC ; i++) {
+ if (bits & (1<<i) ) {
+ to->misc[i] = MSG_ReadLong(msg);
+ }
+ }
+ }
+ }
+
+ if ( print ) {
+ if ( msg->bit == 0 ) {
+ endBit = msg->readcount * 8 - GENTITYNUM_BITS;
+ } else {
+ endBit = ( msg->readcount - 1 ) * 8 + msg->bit - GENTITYNUM_BITS;
+ }
+ Com_Printf( " (%i bits)\n", endBit - startBit );
+ }
+}
+
int msg_hData[256] = {
250315, // 0
41193, // 1
diff --git a/src/qcommon/net_chan.c b/src/qcommon/net_chan.c
index 58a45b50..422f64fc 100644
--- a/src/qcommon/net_chan.c
+++ b/src/qcommon/net_chan.c
@@ -84,7 +84,7 @@ Netchan_Setup
called to open a channel to a remote system
==============
*/
-void Netchan_Setup(netsrc_t sock, netchan_t *chan, netadr_t adr, int qport, int challenge)
+void Netchan_Setup(int alternateProtocol, netsrc_t sock, netchan_t *chan, netadr_t adr, int qport, int challenge)
{
Com_Memset (chan, 0, sizeof(*chan));
@@ -94,6 +94,7 @@ void Netchan_Setup(netsrc_t sock, netchan_t *chan, netadr_t adr, int qport, int
chan->incomingSequence = 0;
chan->outgoingSequence = 1;
chan->challenge = challenge;
+ chan->alternateProtocol = alternateProtocol;
}
/*
@@ -120,7 +121,8 @@ void Netchan_TransmitNextFragment( netchan_t *chan ) {
MSG_WriteShort( &send, qport->integer );
}
- MSG_WriteLong(&send, NETCHAN_GENCHECKSUM(chan->challenge, chan->outgoingSequence));
+ if ( chan->alternateProtocol == 0 )
+ MSG_WriteLong(&send, NETCHAN_GENCHECKSUM(chan->challenge, chan->outgoingSequence));
// copy the reliable message to the packet first
fragmentLength = FRAGMENT_SIZE;
@@ -198,7 +200,8 @@ void Netchan_Transmit( netchan_t *chan, int length, const byte *data ) {
if(chan->sock == NS_CLIENT)
MSG_WriteShort(&send, qport->integer);
- MSG_WriteLong(&send, NETCHAN_GENCHECKSUM(chan->challenge, chan->outgoingSequence));
+ if ( chan->alternateProtocol == 0 )
+ MSG_WriteLong(&send, NETCHAN_GENCHECKSUM(chan->challenge, chan->outgoingSequence));
chan->outgoingSequence++;
@@ -258,11 +261,14 @@ qboolean Netchan_Process( netchan_t *chan, msg_t *msg ) {
MSG_ReadShort( msg );
}
- checksum = MSG_ReadLong(msg);
+ if ( chan->alternateProtocol == 0 )
+ {
+ checksum = MSG_ReadLong(msg);
- // UDP spoofing protection
- if(NETCHAN_GENCHECKSUM(chan->challenge, sequence) != checksum)
- return qfalse;
+ // UDP spoofing protection
+ if(NETCHAN_GENCHECKSUM(chan->challenge, sequence) != checksum)
+ return qfalse;
+ }
// read the fragment information
if ( fragmented ) {
@@ -656,6 +662,8 @@ int NET_StringToAdr( const char *s, netadr_t *a, netadrtype_t family )
search = base;
}
+ a->alternateProtocol = 0;
+
if(!Sys_StringToAdr(search, a, family))
{
a->type = NA_BAD;
diff --git a/src/qcommon/net_ip.c b/src/qcommon/net_ip.c
index 882562e9..82a1ebe0 100644
--- a/src/qcommon/net_ip.c
+++ b/src/qcommon/net_ip.c
@@ -96,6 +96,7 @@ static qboolean usingSocks = qfalse;
static int networkingEnabled = 0;
static cvar_t *net_enabled;
+static cvar_t *net_alternateProtocols;
static cvar_t *net_socksEnabled;
static cvar_t *net_socksServer;
@@ -105,8 +106,8 @@ static cvar_t *net_socksPassword;
static cvar_t *net_ip;
static cvar_t *net_ip6;
-static cvar_t *net_port;
-static cvar_t *net_port6;
+static cvar_t *net_ports[3];
+static cvar_t *net_port6s[3];
static cvar_t *net_mcast6addr;
static cvar_t *net_mcast6iface;
@@ -114,10 +115,13 @@ static cvar_t *net_dropsim;
static struct sockaddr socksRelayAddr;
-static SOCKET ip_socket = INVALID_SOCKET;
-static SOCKET ip6_socket = INVALID_SOCKET;
+static SOCKET ip_sockets[3] = { INVALID_SOCKET, INVALID_SOCKET, INVALID_SOCKET };
+static SOCKET ip6_sockets[3] = { INVALID_SOCKET, INVALID_SOCKET, INVALID_SOCKET };
+/*
+TODO: accommodate
static SOCKET socks_socket = INVALID_SOCKET;
static SOCKET multicast6_socket = INVALID_SOCKET;
+*/
// Keep track of currently joined multicast group.
static struct ipv6_mreq curgroup;
@@ -253,6 +257,7 @@ static void SockadrToNetadr( struct sockaddr *s, netadr_t *a ) {
a->port = ((struct sockaddr_in6 *)s)->sin6_port;
a->scope_id = ((struct sockaddr_in6 *)s)->sin6_scope_id;
}
+ a->alternateProtocol = 0;
}
@@ -396,7 +401,10 @@ qboolean NET_CompareBaseAdrMask(netadr_t a, netadr_t b, int netmask)
{
byte cmpmask, *addra, *addrb;
int curbyte;
-
+
+ if (a.alternateProtocol != b.alternateProtocol)
+ return qfalse;
+
if (a.type != b.type)
return qfalse;
@@ -523,15 +531,19 @@ Receive one packet
*/
qboolean NET_GetPacket(netadr_t *net_from, msg_t *net_message, fd_set *fdr)
{
+ int a;
int ret;
struct sockaddr_storage from;
socklen_t fromlen;
int err;
- if(ip_socket != INVALID_SOCKET && FD_ISSET(ip_socket, fdr))
+ for(a = 0; a < 3; ++a)
+ {
+ // indent
+ if(ip_sockets[a] != INVALID_SOCKET && FD_ISSET(ip_sockets[a], fdr))
{
fromlen = sizeof(from);
- ret = recvfrom( ip_socket, (void *)net_message->data, net_message->maxsize, 0, (struct sockaddr *) &from, &fromlen );
+ ret = recvfrom( ip_sockets[a], (void *)net_message->data, net_message->maxsize, 0, (struct sockaddr *) &from, &fromlen );
if (ret == SOCKET_ERROR)
{
@@ -561,6 +573,8 @@ qboolean NET_GetPacket(netadr_t *net_from, msg_t *net_message, fd_set *fdr)
SockadrToNetadr( (struct sockaddr *) &from, net_from );
net_message->readcount = 0;
}
+
+ net_from->alternateProtocol = a;
if( ret >= net_message->maxsize ) {
Com_Printf( "Oversize packet from %s\n", NET_AdrToString (*net_from) );
@@ -572,10 +586,10 @@ qboolean NET_GetPacket(netadr_t *net_from, msg_t *net_message, fd_set *fdr)
}
}
- if(ip6_socket != INVALID_SOCKET && FD_ISSET(ip6_socket, fdr))
+ if(ip6_sockets[a] != INVALID_SOCKET && FD_ISSET(ip6_sockets[a], fdr))
{
fromlen = sizeof(from);
- ret = recvfrom(ip6_socket, (void *)net_message->data, net_message->maxsize, 0, (struct sockaddr *) &from, &fromlen);
+ ret = recvfrom(ip6_sockets[a], (void *)net_message->data, net_message->maxsize, 0, (struct sockaddr *) &from, &fromlen);
if (ret == SOCKET_ERROR)
{
@@ -589,6 +603,8 @@ qboolean NET_GetPacket(netadr_t *net_from, msg_t *net_message, fd_set *fdr)
SockadrToNetadr((struct sockaddr *) &from, net_from);
net_message->readcount = 0;
+ net_from->alternateProtocol = a;
+
if(ret >= net_message->maxsize)
{
Com_Printf( "Oversize packet from %s\n", NET_AdrToString (*net_from) );
@@ -600,6 +616,8 @@ qboolean NET_GetPacket(netadr_t *net_from, msg_t *net_message, fd_set *fdr)
}
}
+ /*
+ TODO: accommodate
if(multicast6_socket != INVALID_SOCKET && multicast6_socket != ip6_socket && FD_ISSET(multicast6_socket, fdr))
{
fromlen = sizeof(from);
@@ -627,6 +645,9 @@ qboolean NET_GetPacket(netadr_t *net_from, msg_t *net_message, fd_set *fdr)
return qtrue;
}
}
+ */
+ // outdent
+ }
return qfalse;
@@ -651,10 +672,10 @@ void Sys_SendPacket( int length, const void *data, netadr_t to ) {
return;
}
- if( (ip_socket == INVALID_SOCKET && to.type == NA_IP) ||
- (ip_socket == INVALID_SOCKET && to.type == NA_BROADCAST) ||
- (ip6_socket == INVALID_SOCKET && to.type == NA_IP6) ||
- (ip6_socket == INVALID_SOCKET && to.type == NA_MULTICAST6) )
+ if( (ip_sockets[to.alternateProtocol] == INVALID_SOCKET && to.type == NA_IP) ||
+ (ip_sockets[to.alternateProtocol] == INVALID_SOCKET && to.type == NA_BROADCAST) ||
+ (ip6_sockets[to.alternateProtocol] == INVALID_SOCKET && to.type == NA_IP6) ||
+ (/* TODO: accommodate ip6_socket == INVALID_SOCKET && */to.type == NA_MULTICAST6) )
return;
if(to.type == NA_MULTICAST6 && (net_enabled->integer & NET_DISABLEMCAST))
@@ -671,13 +692,13 @@ void Sys_SendPacket( int length, const void *data, netadr_t to ) {
*(int *)&socksBuf[4] = ((struct sockaddr_in *)&addr)->sin_addr.s_addr;
*(short *)&socksBuf[8] = ((struct sockaddr_in *)&addr)->sin_port;
memcpy( &socksBuf[10], data, length );
- ret = sendto( ip_socket, socksBuf, length+10, 0, &socksRelayAddr, sizeof(socksRelayAddr) );
+ ret = sendto( ip_sockets[to.alternateProtocol], socksBuf, length+10, 0, &socksRelayAddr, sizeof(socksRelayAddr) );
}
else {
if(addr.ss_family == AF_INET)
- ret = sendto( ip_socket, data, length, 0, (struct sockaddr *) &addr, sizeof(struct sockaddr_in) );
+ ret = sendto( ip_sockets[to.alternateProtocol], data, length, 0, (struct sockaddr *) &addr, sizeof(struct sockaddr_in) );
else if(addr.ss_family == AF_INET6)
- ret = sendto( ip6_socket, data, length, 0, (struct sockaddr *) &addr, sizeof(struct sockaddr_in6) );
+ ret = sendto( ip6_sockets[to.alternateProtocol], data, length, 0, (struct sockaddr *) &addr, sizeof(struct sockaddr_in6) );
}
if( ret == SOCKET_ERROR ) {
int err = socketError;
@@ -811,7 +832,7 @@ void Sys_ShowIP(void) {
NET_IPSocket
====================
*/
-SOCKET NET_IPSocket( char *net_interface, int port, int *err ) {
+SOCKET NET_IPSocket( int alternateProtocol, char *net_interface, int port, int *err ) {
SOCKET newsocket;
struct sockaddr_in address;
ioctlarg_t _true = 1;
@@ -820,10 +841,12 @@ SOCKET NET_IPSocket( char *net_interface, int port, int *err ) {
*err = 0;
if( net_interface ) {
- Com_Printf( "Opening IP socket: %s:%i\n", net_interface, port );
+ Com_Printf( "Opening%s IP socket: %s:%i\n",
+ ( alternateProtocol == 2 ? " alternate-2" : alternateProtocol == 1 ? " alternate-1" : "" ), net_interface, port );
}
else {
- Com_Printf( "Opening IP socket: 0.0.0.0:%i\n", port );
+ Com_Printf( "Opening%s IP socket: 0.0.0.0:%i\n",
+ ( alternateProtocol == 2 ? " alternate-2" : alternateProtocol == 1 ? " alternate-1" : "" ), port );
}
if( ( newsocket = socket( PF_INET, SOCK_DGRAM, IPPROTO_UDP ) ) == INVALID_SOCKET ) {
@@ -879,7 +902,7 @@ SOCKET NET_IPSocket( char *net_interface, int port, int *err ) {
NET_IP6Socket
====================
*/
-SOCKET NET_IP6Socket( char *net_interface, int port, struct sockaddr_in6 *bindto, int *err ) {
+SOCKET NET_IP6Socket( int alternateProtocol, char *net_interface, int port, struct sockaddr_in6 *bindto, int *err ) {
SOCKET newsocket;
struct sockaddr_in6 address;
ioctlarg_t _true = 1;
@@ -890,12 +913,15 @@ SOCKET NET_IP6Socket( char *net_interface, int port, struct sockaddr_in6 *bindto
{
// Print the name in brackets if there is a colon:
if(Q_CountChar(net_interface, ':'))
- Com_Printf( "Opening IP6 socket: [%s]:%i\n", net_interface, port );
+ Com_Printf( "Opening%s IP6 socket: [%s]:%i\n",
+ ( alternateProtocol == 2 ? " alternate-2" : alternateProtocol == 1 ? " alternate-1" : "" ), net_interface, port );
else
- Com_Printf( "Opening IP6 socket: %s:%i\n", net_interface, port );
+ Com_Printf( "Opening%s IP6 socket: %s:%i\n",
+ ( alternateProtocol == 2 ? " alternate-2" : alternateProtocol == 1 ? " alternate-1" : "" ), net_interface, port );
}
else
- Com_Printf( "Opening IP6 socket: [::]:%i\n", port );
+ Com_Printf( "Opening%s IP6 socket: [::]:%i\n",
+ ( alternateProtocol == 2 ? " alternate-2" : alternateProtocol == 1 ? " alternate-1" : "" ), port );
if( ( newsocket = socket( PF_INET6, SOCK_DGRAM, IPPROTO_UDP ) ) == INVALID_SOCKET ) {
*err = socketError;
@@ -999,6 +1025,8 @@ Join an ipv6 multicast group
*/
void NET_JoinMulticast6(void)
{
+ /*
+ TODO: accommodate
int err;
if(ip6_socket == INVALID_SOCKET || multicast6_socket != INVALID_SOCKET || (net_enabled->integer & NET_DISABLEMCAST))
@@ -1045,10 +1073,13 @@ void NET_JoinMulticast6(void)
return;
}
}
+ */
}
void NET_LeaveMulticast6()
{
+ /*
+ TODO: accommodate
if(multicast6_socket != INVALID_SOCKET)
{
if(multicast6_socket != ip6_socket)
@@ -1058,6 +1089,7 @@ void NET_LeaveMulticast6()
multicast6_socket = INVALID_SOCKET;
}
+ */
}
/*
@@ -1066,6 +1098,8 @@ NET_OpenSocks
====================
*/
void NET_OpenSocks( int port ) {
+ /*
+ TODO: accommodate
struct sockaddr_in address;
struct hostent *h;
int len;
@@ -1224,6 +1258,7 @@ void NET_OpenSocks( int port ) {
memset( ((struct sockaddr_in *)&socksRelayAddr)->sin_zero, 0, 8 );
usingSocks = qtrue;
+ */
}
@@ -1347,16 +1382,30 @@ NET_OpenIP
====================
*/
void NET_OpenIP( void ) {
+ int a;
int i;
int err;
- int port;
- int port6;
+ int ports[3];
+ int port6s[3];
- port = net_port->integer;
- port6 = net_port6->integer;
+ for( a = 0; a < 3; ++a )
+ {
+ ports[a] = net_ports[a]->integer;
+ port6s[a] = net_port6s[a]->integer;
+ }
NET_GetLocalAddress();
+ for( a = 0; a < 3; ++a )
+ {
+ // indent
+ if( a == 0 && ( net_alternateProtocols->integer & NET_DISABLEPRIMPROTO ) )
+ continue;
+ if( a == 1 && !( net_alternateProtocols->integer & NET_ENABLEALT1PROTO ) )
+ continue;
+ if( a == 2 && !( net_alternateProtocols->integer & NET_ENABLEALT2PROTO ) )
+ continue;
+
// automatically scan for a valid port, so multiple
// dedicated servers can be started without requiring
// a different net_port for each one
@@ -1365,10 +1414,10 @@ void NET_OpenIP( void ) {
{
for( i = 0 ; i < 10 ; i++ )
{
- ip6_socket = NET_IP6Socket(net_ip6->string, port6 + i, &boundto, &err);
- if (ip6_socket != INVALID_SOCKET)
+ ip6_sockets[a] = NET_IP6Socket( a, net_ip6->string, port6s[a] + i, &boundto, &err );
+ if (ip6_sockets[a] != INVALID_SOCKET)
{
- Cvar_SetValue( "net_port6", port6 + i );
+ Cvar_SetValue( ( a == 2 ? "net_alt2port6" : a == 1 ? "net_alt1port6" : "net_port6" ), port6s[a] + i );
break;
}
else
@@ -1377,19 +1426,20 @@ void NET_OpenIP( void ) {
break;
}
}
- if(ip6_socket == INVALID_SOCKET)
- Com_Printf( "WARNING: Couldn't bind to a v6 ip address.\n");
+ if(ip6_sockets[a] == INVALID_SOCKET)
+ Com_Printf( "WARNING: Couldn't bind to a%s v6 ip address.\n",
+ ( a == 2 ? "n alternate-2" : a == 1 ? "n alternate-1" : "" ) );
}
if(net_enabled->integer & NET_ENABLEV4)
{
for( i = 0 ; i < 10 ; i++ ) {
- ip_socket = NET_IPSocket( net_ip->string, port + i, &err );
- if (ip_socket != INVALID_SOCKET) {
- Cvar_SetValue( "net_port", port + i );
+ ip_sockets[a] = NET_IPSocket( a, net_ip->string, ports[a] + i, &err );
+ if (ip_sockets[a] != INVALID_SOCKET) {
+ Cvar_SetValue( ( a == 2 ? "net_alt2port" : a == 1 ? "net_alt1port" : "net_port" ), ports[a] + i );
if (net_socksEnabled->integer)
- NET_OpenSocks( port + i );
+ NET_OpenSocks( ports[a] + i );
break;
}
@@ -1400,8 +1450,11 @@ void NET_OpenIP( void ) {
}
}
- if(ip_socket == INVALID_SOCKET)
- Com_Printf( "WARNING: Couldn't bind to a v4 ip address.\n");
+ if(ip_sockets[a] == INVALID_SOCKET)
+ Com_Printf( "WARNING: Couldn't bind to a%s v4 ip address.\n",
+ ( a == 2 ? "n alternate-2" : a == 1 ? "n alternate-1" : "" ) );
+ }
+ // outdent
}
}
@@ -1416,6 +1469,7 @@ NET_GetCvars
*/
static qboolean NET_GetCvars( void ) {
int modified;
+ int a;
#ifdef DEDICATED
// I want server owners to explicitly turn on ipv6 support.
@@ -1428,6 +1482,10 @@ static qboolean NET_GetCvars( void ) {
modified = net_enabled->modified;
net_enabled->modified = qfalse;
+ net_alternateProtocols = Cvar_Get( "net_alternateProtocols", "3", CVAR_LATCH | CVAR_ARCHIVE );
+ modified += net_alternateProtocols->modified;
+ net_alternateProtocols->modified = qfalse;
+
net_ip = Cvar_Get( "net_ip", "0.0.0.0", CVAR_LATCH );
modified += net_ip->modified;
net_ip->modified = qfalse;
@@ -1436,13 +1494,18 @@ static qboolean NET_GetCvars( void ) {
modified += net_ip6->modified;
net_ip6->modified = qfalse;
- net_port = Cvar_Get( "net_port", va( "%i", PORT_SERVER ), CVAR_LATCH );
- modified += net_port->modified;
- net_port->modified = qfalse;
+ for( a = 0; a < 3; ++a )
+ {
+ net_ports[a] = Cvar_Get( ( a == 2 ? "net_alt2port" : a == 1 ? "net_alt1port" : "net_port" ),
+ ( a == 2 ? XSTRING( ALT2PORT_SERVER ) : a == 1 ? XSTRING( ALT1PORT_SERVER ) : XSTRING( PORT_SERVER ) ), CVAR_LATCH );
+ modified += net_ports[a]->modified;
+ net_ports[a]->modified = qfalse;
- net_port6 = Cvar_Get( "net_port6", va( "%i", PORT_SERVER ), CVAR_LATCH );
- modified += net_port6->modified;
- net_port6->modified = qfalse;
+ net_port6s[a] = Cvar_Get( ( a == 2 ? "net_alt2port6" : a == 1 ? "net_alt1port6" : "net_port6" ),
+ ( a == 2 ? XSTRING( ALT2PORT_SERVER ) : a == 1 ? XSTRING( ALT1PORT_SERVER ) : XSTRING( PORT_SERVER ) ), CVAR_LATCH );
+ modified += net_port6s[a]->modified;
+ net_port6s[a]->modified = qfalse;
+ }
// Some cvars for configuring multicast options which facilitates scanning for servers on local subnets.
net_mcast6addr = Cvar_Get( "net_mcast6addr", NET_MULTICAST_IP6, CVAR_LATCH | CVAR_ARCHIVE );
@@ -1492,6 +1555,7 @@ void NET_Config( qboolean enableNetworking ) {
qboolean modified;
qboolean stop;
qboolean start;
+ int a;
// get any latched changes to cvars
modified = NET_GetCvars();
@@ -1528,11 +1592,21 @@ void NET_Config( qboolean enableNetworking ) {
}
if( stop ) {
- if ( ip_socket != INVALID_SOCKET ) {
- closesocket( ip_socket );
- ip_socket = INVALID_SOCKET;
+ for( a = 0; a < 3; ++a )
+ {
+ if ( ip_sockets[a] != INVALID_SOCKET ) {
+ closesocket( ip_sockets[a] );
+ ip_sockets[a] = INVALID_SOCKET;
+ }
+
+ if ( ip6_sockets[a] != INVALID_SOCKET ) {
+ closesocket( ip6_sockets[a] );
+ ip6_sockets[a] = INVALID_SOCKET;
+ }
}
+ /*
+ TODO: accommodate
if(multicast6_socket != INVALID_SOCKET)
{
if(multicast6_socket != ip6_socket)
@@ -1541,15 +1615,11 @@ void NET_Config( qboolean enableNetworking ) {
multicast6_socket = INVALID_SOCKET;
}
- if ( ip6_socket != INVALID_SOCKET ) {
- closesocket( ip6_socket );
- ip6_socket = INVALID_SOCKET;
- }
-
if ( socks_socket != INVALID_SOCKET ) {
closesocket( socks_socket );
socks_socket = INVALID_SOCKET;
}
+ */
}
@@ -1656,6 +1726,7 @@ void NET_Sleep(int msec)
struct timeval timeout;
fd_set fdr;
int retval;
+ int a;
SOCKET highestfd = INVALID_SOCKET;
if(msec < 0)
@@ -1663,18 +1734,22 @@ void NET_Sleep(int msec)
FD_ZERO(&fdr);
- if(ip_socket != INVALID_SOCKET)
+ for(a = 0; a < 3; ++a)
{
- FD_SET(ip_socket, &fdr);
+ if(ip_sockets[a] != INVALID_SOCKET)
+ {
+ FD_SET(ip_sockets[a], &fdr);
- highestfd = ip_socket;
- }
- if(ip6_socket != INVALID_SOCKET)
- {
- FD_SET(ip6_socket, &fdr);
+ if(highestfd == INVALID_SOCKET || ip_sockets[a] > highestfd)
+ highestfd = ip_sockets[a];
+ }
+ if(ip6_sockets[a] != INVALID_SOCKET)
+ {
+ FD_SET(ip6_sockets[a], &fdr);
- if(highestfd == INVALID_SOCKET || ip6_socket > highestfd)
- highestfd = ip6_socket;
+ if(highestfd == INVALID_SOCKET || ip6_sockets[a] > highestfd)
+ highestfd = ip6_sockets[a];
+ }
}
#ifdef _WIN32
diff --git a/src/qcommon/q_shared.h b/src/qcommon/q_shared.h
index 331dcfcc..6d6aa461 100644
--- a/src/qcommon/q_shared.h
+++ b/src/qcommon/q_shared.h
@@ -1103,6 +1103,7 @@ typedef struct {
// if none of the catchers are active, bound key strings will be executed
#define KEYCATCH_CONSOLE 0x0001
#define KEYCATCH_UI 0x0002
+#define KEYCATCH_MESSAGE 0x0004
#define KEYCATCH_CGAME 0x0008
diff --git a/src/qcommon/qcommon.h b/src/qcommon/qcommon.h
index b494773b..895c01d4 100644
--- a/src/qcommon/qcommon.h
+++ b/src/qcommon/qcommon.h
@@ -75,7 +75,7 @@ void MSG_WriteFloat (msg_t *sb, float f);
void MSG_WriteString (msg_t *sb, const char *s);
void MSG_WriteBigString (msg_t *sb, const char *s);
void MSG_WriteAngle16 (msg_t *sb, float f);
-int MSG_HashKey(const char *string, int maxlen);
+int MSG_HashKey(int alternateProtocol, const char *string, int maxlen);
void MSG_BeginReading (msg_t *sb);
void MSG_BeginReadingOOB(msg_t *sb);
@@ -97,13 +97,15 @@ int MSG_LookaheadByte (msg_t *msg);
void MSG_WriteDeltaUsercmdKey( msg_t *msg, int key, usercmd_t *from, usercmd_t *to );
void MSG_ReadDeltaUsercmdKey( msg_t *msg, int key, usercmd_t *from, usercmd_t *to );
-void MSG_WriteDeltaEntity( msg_t *msg, struct entityState_s *from, struct entityState_s *to
+void MSG_WriteDeltaEntity( int alternateProtocol, msg_t *msg, struct entityState_s *from, struct entityState_s *to
, qboolean force );
-void MSG_ReadDeltaEntity( msg_t *msg, entityState_t *from, entityState_t *to,
+void MSG_ReadDeltaEntity( int alternateProtocol, msg_t *msg, entityState_t *from, entityState_t *to,
int number );
-void MSG_WriteDeltaPlayerstate( msg_t *msg, struct playerState_s *from, struct playerState_s *to );
+void MSG_WriteDeltaPlayerstate( int alternateProtocol, msg_t *msg, struct playerState_s *from, struct playerState_s *to );
void MSG_ReadDeltaPlayerstate( msg_t *msg, struct playerState_s *from, struct playerState_s *to );
+struct alternatePlayerState_s;
+void MSG_ReadDeltaAlternatePlayerstate( msg_t *msg, struct alternatePlayerState_s *from, struct alternatePlayerState_s *to );
void MSG_ReportChangeVectors_f( void );
@@ -125,6 +127,10 @@ NET
// disables ipv6 multicast support if set.
#define NET_DISABLEMCAST 0x08
+#define NET_ENABLEALT1PROTO 0x01
+#define NET_ENABLEALT2PROTO 0x02
+#define NET_DISABLEPRIMPROTO 0x04
+
#define PACKET_BACKUP 32 // number of old messages that must be kept on client and
// server for delta comrpession and ping estimation
@@ -162,6 +168,8 @@ typedef struct {
unsigned short port;
unsigned long scope_id; // Needed for IPv6 link-local addresses
+
+ int alternateProtocol;
} netadr_t;
void NET_Init( void );
@@ -204,6 +212,7 @@ typedef struct {
int dropped; // between last packet and previous
+ int alternateProtocol;
netadr_t remoteAddress;
int qport; // qport value to write when transmitting
@@ -229,7 +238,7 @@ typedef struct {
} netchan_t;
void Netchan_Init( int qport );
-void Netchan_Setup(netsrc_t sock, netchan_t *chan, netadr_t adr, int qport, int challenge);
+void Netchan_Setup(int alternateProtocol, netsrc_t sock, netchan_t *chan, netadr_t adr, int qport, int challenge);
void Netchan_Transmit( netchan_t *chan, int length, const byte *data );
void Netchan_TransmitNextFragment( netchan_t *chan );
@@ -258,6 +267,10 @@ extern int demo_protocols[];
#define PORT_MASTER 30700
#define PORT_SERVER 30720
+#define ALT1PORT_MASTER 30700
+#define ALT1PORT_SERVER 30721
+#define ALT2PORT_MASTER 30710
+#define ALT2PORT_SERVER 30722
#define NUM_SERVER_PORTS 4 // broadcast scan this many ports after
// PORT_SERVER so a single machine can
// run multiple servers
@@ -343,6 +356,7 @@ void VM_Free( vm_t *vm );
void VM_Clear(void);
void VM_Forced_Unload_Start(void);
void VM_Forced_Unload_Done(void);
+void VM_ClearCallLevel(vm_t *vm);
vm_t *VM_Restart(vm_t *vm, qboolean unpure);
intptr_t QDECL VM_Call( vm_t *vm, int callNum, ... );
diff --git a/src/qcommon/vm.c b/src/qcommon/vm.c
index 18be5331..aa77f605 100644
--- a/src/qcommon/vm.c
+++ b/src/qcommon/vm.c
@@ -744,6 +744,10 @@ void VM_Forced_Unload_Done(void) {
forced_unload = 0;
}
+void VM_ClearCallLevel(vm_t *vm) {
+ vm->callLevel = 0;
+}
+
void *VM_ArgPtr( intptr_t intValue ) {
if ( !intValue ) {
return NULL;