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:
@@ -1,4 +1,5 @@
|
|||||||
Changes towards version 0.6:
|
Changes towards version 0.6:
|
||||||
|
- Validate UQM version of either side of a Netplay game - SvdB
|
||||||
- Better abort and disconnect handling for Netplay - SvdB
|
- Better abort and disconnect handling for Netplay - SvdB
|
||||||
- Menu sounds in Setup track rest of game (#922), from Nic - Michael
|
- Menu sounds in Setup track rest of game (#922), from Nic - Michael
|
||||||
- Shifted the Mouse Error to a Popup Window, moved the message to
|
- Shifted the Mouse Error to a Popup Window, moved the message to
|
||||||
|
|||||||
@@ -25,7 +25,11 @@
|
|||||||
#define NETPLAY_FULL 2
|
#define NETPLAY_FULL 2
|
||||||
|
|
||||||
#define NETPLAY_PROTOCOL_VERSION_MAJOR 0
|
#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
|
#define NETPLAY_DEBUG
|
||||||
/* Extra debugging for netplay */
|
/* Extra debugging for netplay */
|
||||||
|
|||||||
@@ -57,6 +57,27 @@ testNetState(bool condition, PacketType type) {
|
|||||||
return condition;
|
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
|
int
|
||||||
PacketHandler_Init(NetConnection *conn, const Packet_Init *packet) {
|
PacketHandler_Init(NetConnection *conn, const Packet_Init *packet) {
|
||||||
if (conn->stateFlags.reset.localReset)
|
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 ||
|
if (packet->protoVersion.major != NETPLAY_PROTOCOL_VERSION_MAJOR ||
|
||||||
packet->protoVersion.minor != NETPLAY_PROTOCOL_VERSION_MINOR) {
|
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",
|
log_add(log_Error, "Protocol version %d.%d not supported.\n",
|
||||||
packet->protoVersion.major, packet->protoVersion.minor);
|
packet->protoVersion.major, packet->protoVersion.minor);
|
||||||
errno = ENOSYS;
|
errno = ENOSYS;
|
||||||
return -1;
|
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);
|
Netplay_remoteReady(conn);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user