mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-12-19 06:22:26 +00:00
Merge branch 'commit-version' into 'master'
Compare git commit before joining netgames See merge request KartKrew/Kart!721
This commit is contained in:
commit
1300ec5d56
4 changed files with 72 additions and 0 deletions
|
|
@ -895,8 +895,15 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime)
|
||||||
netbuffer->packettype = PT_SERVERINFO;
|
netbuffer->packettype = PT_SERVERINFO;
|
||||||
netbuffer->u.serverinfo._255 = 255;
|
netbuffer->u.serverinfo._255 = 255;
|
||||||
netbuffer->u.serverinfo.packetversion = PACKETVERSION;
|
netbuffer->u.serverinfo.packetversion = PACKETVERSION;
|
||||||
|
|
||||||
netbuffer->u.serverinfo.version = VERSION;
|
netbuffer->u.serverinfo.version = VERSION;
|
||||||
netbuffer->u.serverinfo.subversion = SUBVERSION;
|
netbuffer->u.serverinfo.subversion = SUBVERSION;
|
||||||
|
|
||||||
|
#ifdef DEVELOP
|
||||||
|
memcpy(netbuffer->u.serverinfo.commit,
|
||||||
|
comprevision_abbrev_bin, GIT_SHA_ABBREV);
|
||||||
|
#endif
|
||||||
|
|
||||||
strncpy(netbuffer->u.serverinfo.application, SRB2APPLICATION,
|
strncpy(netbuffer->u.serverinfo.application, SRB2APPLICATION,
|
||||||
sizeof netbuffer->u.serverinfo.application);
|
sizeof netbuffer->u.serverinfo.application);
|
||||||
// return back the time value so client can compute their ping
|
// return back the time value so client can compute their ping
|
||||||
|
|
@ -1681,6 +1688,35 @@ static boolean CL_ServerConnectionSearchTicker(tic_t *asksent)
|
||||||
|
|
||||||
if (client)
|
if (client)
|
||||||
{
|
{
|
||||||
|
#ifdef DEVELOP
|
||||||
|
// Commits do not match? Do not connect!
|
||||||
|
if (memcmp(serverlist[i].info.commit,
|
||||||
|
comprevision_abbrev_bin,
|
||||||
|
GIT_SHA_ABBREV))
|
||||||
|
{
|
||||||
|
char theirs[GIT_SHA_ABBREV * 2 + 1];
|
||||||
|
UINT8 n;
|
||||||
|
|
||||||
|
for (n = 0; n < GIT_SHA_ABBREV; ++n)
|
||||||
|
{
|
||||||
|
sprintf(&theirs[n * 2], "%02hhx",
|
||||||
|
serverlist[i].info.commit[n]);
|
||||||
|
}
|
||||||
|
|
||||||
|
D_QuitNetGame();
|
||||||
|
CL_Reset();
|
||||||
|
D_StartTitle();
|
||||||
|
|
||||||
|
M_StartMessage(va(
|
||||||
|
"Your EXE differs from the server.\n"
|
||||||
|
" Yours: %.*s\n"
|
||||||
|
"Theirs: %s\n\n"
|
||||||
|
"Press ESC\n",
|
||||||
|
GIT_SHA_ABBREV * 2, comprevision, theirs), NULL, MM_NOTHING);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CURL
|
#ifdef HAVE_CURL
|
||||||
if (serverlist[i].info.httpsource[0])
|
if (serverlist[i].info.httpsource[0])
|
||||||
strncpy(http_source, serverlist[i].info.httpsource, MAX_MIRROR_LENGTH);
|
strncpy(http_source, serverlist[i].info.httpsource, MAX_MIRROR_LENGTH);
|
||||||
|
|
|
||||||
|
|
@ -268,6 +268,9 @@ typedef struct
|
||||||
char application[MAXAPPLICATION];
|
char application[MAXAPPLICATION];
|
||||||
UINT8 version;
|
UINT8 version;
|
||||||
UINT8 subversion;
|
UINT8 subversion;
|
||||||
|
#ifdef DEVELOP
|
||||||
|
UINT8 commit[GIT_SHA_ABBREV];
|
||||||
|
#endif
|
||||||
UINT8 numberofplayer;
|
UINT8 numberofplayer;
|
||||||
UINT8 maxplayer;
|
UINT8 maxplayer;
|
||||||
UINT8 refusereason; // 0: joinable, 1: joins disabled, 2: full
|
UINT8 refusereason; // 0: joinable, 1: joins disabled, 2: full
|
||||||
|
|
|
||||||
22
src/d_main.c
22
src/d_main.c
|
|
@ -96,6 +96,10 @@
|
||||||
int VERSION;
|
int VERSION;
|
||||||
int SUBVERSION;
|
int SUBVERSION;
|
||||||
|
|
||||||
|
#ifdef DEVELOP
|
||||||
|
UINT8 comprevision_abbrev_bin[GIT_SHA_ABBREV];
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_DISCORDRPC
|
#ifdef HAVE_DISCORDRPC
|
||||||
#include "discord.h"
|
#include "discord.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -1170,6 +1174,20 @@ static void IdentifyVersion(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEVELOP
|
||||||
|
static void
|
||||||
|
D_AbbrevCommit (void)
|
||||||
|
{
|
||||||
|
UINT8 i;
|
||||||
|
|
||||||
|
for (i = 0; i < GIT_SHA_ABBREV; ++i)
|
||||||
|
{
|
||||||
|
sscanf(&comprevision[i * 2], "%2hhx",
|
||||||
|
&comprevision_abbrev_bin[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
D_ConvertVersionNumbers (void)
|
D_ConvertVersionNumbers (void)
|
||||||
{
|
{
|
||||||
|
|
@ -1194,6 +1212,10 @@ void D_SRB2Main(void)
|
||||||
/* break the version string into version numbers, for netplay */
|
/* break the version string into version numbers, for netplay */
|
||||||
D_ConvertVersionNumbers();
|
D_ConvertVersionNumbers();
|
||||||
|
|
||||||
|
#ifdef DEVELOP
|
||||||
|
D_AbbrevCommit();
|
||||||
|
#endif
|
||||||
|
|
||||||
// Print GPL notice for our console users (Linux)
|
// Print GPL notice for our console users (Linux)
|
||||||
CONS_Printf(
|
CONS_Printf(
|
||||||
"\n\nDr. Robotnik's Ring Racers\n"
|
"\n\nDr. Robotnik's Ring Racers\n"
|
||||||
|
|
|
||||||
|
|
@ -516,6 +516,17 @@ char *sizeu5(size_t num);
|
||||||
// d_main.c
|
// d_main.c
|
||||||
extern int VERSION;
|
extern int VERSION;
|
||||||
extern int SUBVERSION;
|
extern int SUBVERSION;
|
||||||
|
|
||||||
|
#ifdef DEVELOP
|
||||||
|
// 4 bytes handles 8 characters of a git object SHA. At
|
||||||
|
// around 20k commits, we only need 6 characters for a unique
|
||||||
|
// abbreviation. Maybe in another 20k commits, more than 8
|
||||||
|
// characters will be required! =P
|
||||||
|
// P.S. 8 is also what comptime generates
|
||||||
|
#define GIT_SHA_ABBREV (4)
|
||||||
|
extern UINT8 comprevision_abbrev_bin[GIT_SHA_ABBREV];
|
||||||
|
#endif
|
||||||
|
|
||||||
extern boolean devparm; // development mode (-debug)
|
extern boolean devparm; // development mode (-debug)
|
||||||
|
|
||||||
// m_cheat.c
|
// m_cheat.c
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue