mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
put the game version constants all together in one file. Closes #870
This commit is contained in:
parent
4073520214
commit
590dbac239
|
@ -36,6 +36,8 @@
|
|||
#include <engine/shared/ringbuffer.h>
|
||||
#include <engine/shared/snapshot.h>
|
||||
|
||||
#include <game/version.h>
|
||||
|
||||
#include <mastersrv/mastersrv.h>
|
||||
#include <versionsrv/versionsrv.h>
|
||||
|
||||
|
@ -859,23 +861,26 @@ void CClient::ProcessConnlessPacket(CNetChunk *pPacket)
|
|||
if(m_VersionInfo.m_State == CVersionInfo::STATE_READY && net_addr_comp(&pPacket->m_Address, &m_VersionInfo.m_VersionServeraddr.m_Addr) == 0)
|
||||
{
|
||||
// version info
|
||||
if(pPacket->m_DataSize == (int)(sizeof(VERSIONSRV_VERSION) + sizeof(VERSION_DATA)) &&
|
||||
if(pPacket->m_DataSize == (int)(sizeof(VERSIONSRV_VERSION) + sizeof(GAME_RELEASE_VERSION)) &&
|
||||
mem_comp(pPacket->m_pData, VERSIONSRV_VERSION, sizeof(VERSIONSRV_VERSION)) == 0)
|
||||
|
||||
{
|
||||
unsigned char *pVersionData = (unsigned char*)pPacket->m_pData + sizeof(VERSIONSRV_VERSION);
|
||||
int VersionMatch = !mem_comp(pVersionData, VERSION_DATA, sizeof(VERSION_DATA));
|
||||
char *pVersionData = (char*)pPacket->m_pData + sizeof(VERSIONSRV_VERSION);
|
||||
int VersionMatch = !mem_comp(pVersionData, GAME_RELEASE_VERSION, sizeof(GAME_RELEASE_VERSION));
|
||||
|
||||
char aVersion[sizeof(GAME_RELEASE_VERSION)];
|
||||
str_copy(aVersion, pVersionData, sizeof(aVersion));
|
||||
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "version does %s (%d.%d.%d)",
|
||||
str_format(aBuf, sizeof(aBuf), "version does %s (%s)",
|
||||
VersionMatch ? "match" : "NOT match",
|
||||
pVersionData[1], pVersionData[2], pVersionData[3]);
|
||||
aVersion);
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "client/version", aBuf);
|
||||
|
||||
// assume version is out of date when version-data doesn't match
|
||||
if (!VersionMatch)
|
||||
if(!VersionMatch)
|
||||
{
|
||||
str_format(m_aVersionStr, sizeof(m_aVersionStr), "%d.%d.%d", pVersionData[1], pVersionData[2], pVersionData[3]);
|
||||
str_copy(m_aVersionStr, aVersion, sizeof(m_aVersionStr));
|
||||
}
|
||||
|
||||
// request the map version list now
|
||||
|
|
|
@ -5,4 +5,5 @@
|
|||
#include "generated/nethash.cpp"
|
||||
#define GAME_VERSION "0.6 trunk"
|
||||
#define GAME_NETVERSION "0.6 " GAME_NETVERSION_HASH
|
||||
static const char GAME_RELEASE_VERSION[8] = {'0', '.', '6', '1', 0};
|
||||
#endif
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
#include <engine/shared/network.h>
|
||||
|
||||
#include <game/version.h>
|
||||
|
||||
#include "versionsrv.h"
|
||||
|
||||
enum {
|
||||
|
@ -57,10 +59,10 @@ void BuildPackets()
|
|||
void SendVer(NETADDR *pAddr)
|
||||
{
|
||||
CNetChunk p;
|
||||
unsigned char aData[sizeof(VERSIONSRV_VERSION) + sizeof(VERSION_DATA)];
|
||||
unsigned char aData[sizeof(VERSIONSRV_VERSION) + sizeof(GAME_RELEASE_VERSION)];
|
||||
|
||||
mem_copy(aData, VERSIONSRV_VERSION, sizeof(VERSIONSRV_VERSION));
|
||||
mem_copy(aData + sizeof(VERSIONSRV_VERSION), VERSION_DATA, sizeof(VERSION_DATA));
|
||||
mem_copy(aData + sizeof(VERSIONSRV_VERSION), GAME_RELEASE_VERSION, sizeof(GAME_RELEASE_VERSION));
|
||||
|
||||
p.m_ClientID = -1;
|
||||
p.m_Address = *pAddr;
|
||||
|
|
|
@ -28,8 +28,6 @@ static CMapVersion s_aMapVersionList[] = {
|
|||
};
|
||||
static const int s_NumMapVersionItems = sizeof(s_aMapVersionList)/sizeof(CMapVersion);
|
||||
|
||||
static const unsigned char VERSION_DATA[] = {0x00, 0, 6, 0};
|
||||
|
||||
static const unsigned char VERSIONSRV_GETVERSION[] = {255, 255, 255, 255, 'v', 'e', 'r', 'g'};
|
||||
static const unsigned char VERSIONSRV_VERSION[] = {255, 255, 255, 255, 'v', 'e', 'r', 's'};
|
||||
|
||||
|
|
Loading…
Reference in a new issue