Test minimum UQM version in Netplay.

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2572 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
meep-eep
2006-12-06 03:56:34 +00:00
parent 7958a9e87f
commit 14da945d5d
3 changed files with 44 additions and 1 deletions
+1
View File
@@ -1,4 +1,5 @@
Changes towards version 0.6:
- Validate UQM version of either side of a Netplay game - SvdB
- Better abort and disconnect handling for Netplay - SvdB
- Menu sounds in Setup track rest of game (#922), from Nic - Michael
- Shifted the Mouse Error to a Popup Window, moved the message to
+5 -1
View File
@@ -25,7 +25,11 @@
#define NETPLAY_FULL 2
#define NETPLAY_PROTOCOL_VERSION_MAJOR 0
#define NETPLAY_PROTOCOL_VERSION_MINOR 2
#define NETPLAY_PROTOCOL_VERSION_MINOR 3
#define NETPLAY_MIN_UQM_VERSION_MAJOR 0
#define NETPLAY_MIN_UQM_VERSION_MINOR 5
#define NETPLAY_MIN_UQM_VERSION_PATCH 4
#define NETPLAY_DEBUG
/* Extra debugging for netplay */
+38
View File
@@ -57,6 +57,27 @@ testNetState(bool condition, PacketType type) {
return condition;
}
static int
versionCompare(int major1, int minor1, int patch1,
int major2, int minor2, int patch2) {
if (major1 < major2)
return -1;
if (major1 > major2)
return 1;
if (minor1 < minor2)
return -1;
if (minor1 > minor2)
return 1;
if (patch1 < patch2)
return -1;
if (patch1 > patch2)
return 1;
return 0;
}
int
PacketHandler_Init(NetConnection *conn, const Packet_Init *packet) {
if (conn->stateFlags.reset.localReset)
@@ -72,12 +93,29 @@ PacketHandler_Init(NetConnection *conn, const Packet_Init *packet) {
if (packet->protoVersion.major != NETPLAY_PROTOCOL_VERSION_MAJOR ||
packet->protoVersion.minor != NETPLAY_PROTOCOL_VERSION_MINOR) {
sendAbort (conn, AbortReason_versionMismatch);
abortFeedback(conn->player, AbortReason_versionMismatch);
log_add(log_Error, "Protocol version %d.%d not supported.\n",
packet->protoVersion.major, packet->protoVersion.minor);
errno = ENOSYS;
return -1;
}
if (versionCompare(packet->uqmVersion.major, packet->uqmVersion.minor,
packet->uqmVersion.patch, NETPLAY_MIN_UQM_VERSION_MAJOR,
NETPLAY_MIN_UQM_VERSION_MINOR, NETPLAY_MIN_UQM_VERSION_PATCH)
< 0) {
sendAbort (conn, AbortReason_versionMismatch);
abortFeedback(conn->player, AbortReason_versionMismatch);
log_add(log_Error, "Remote side is running a version of UQM that "
"is too old (%d.%d.%d; %d.%d.%d is required).\n",
packet->uqmVersion.major, packet->uqmVersion.minor,
packet->uqmVersion.patch, NETPLAY_MIN_UQM_VERSION_MAJOR,
NETPLAY_MIN_UQM_VERSION_MINOR, NETPLAY_MIN_UQM_VERSION_PATCH);
errno = ENOSYS;
return -1;
}
Netplay_remoteReady(conn);
return 0;