Add support for the demo version of the game

This allows the demo version of the game to be used, both for playing on demo servers, or for hosting a demo server
This commit is contained in:
smallmodel 2024-11-12 23:09:37 +01:00
parent b0a683c188
commit ab84a6ea58
No known key found for this signature in database
GPG key ID: 9F2D623CEDF08512
11 changed files with 198 additions and 35 deletions

View file

@ -284,6 +284,28 @@ challenge_t* FindChallenge(netadr_t from, qboolean connecting) {
return challenge;
}
/*
==================
SV_IsDemoClient
Returns whether or not the client is using the demo version of the game
==================
*/
qboolean SV_IsDemoClient(const char *userinfo)
{
int version;
if (protocol_version_demo == protocol_version_full) {
// Older versions don't check for network demo
return qfalse;
}
version = atoi(Info_ValueForKey(userinfo, "protocol"));
return version == protocol_version_demo;
}
/*
==================
SV_DirectConnect
@ -334,9 +356,20 @@ void SV_DirectConnect( netadr_t from ) {
Com_DPrintf(" rejected connect - only Breakthrough clients allowed.\n");
return;
}
}
}
version = atoi(Info_ValueForKey(userinfo, "protocol"));
version = atoi(Info_ValueForKey(userinfo, "protocol"));
if (!com_target_demo->integer && SV_IsDemoClient(userinfo)) {
SV_NET_OutOfBandPrint(&svs.netprofile, from, "print\nThe Multiplayer Demo can not connect to full version games.\n");
Com_DPrintf(" rejected connect from version %i\n", version);
return;
}
if (com_target_demo->integer && version == protocol_version_full) {
// Make sure to make the full game compatible with the demo game protocol
version = com_protocol->integer;
}
#ifdef LEGACY_PROTOCOL
if(version > 0 && com_legacyprotocol->integer == version)

View file

@ -615,8 +615,15 @@ void SVC_Info( netadr_t from ) {
Info_SetValueForKey( infostring, "game", gamedir );
}
Info_SetValueForKey(infostring, "gamever", com_target_version->string);
Info_SetValueForKey(infostring, "serverType", va("%i", com_target_game->integer));
if (!com_target_demo->integer || com_target_game->integer <= TG_MOH) {
Info_SetValueForKey(infostring, "gamever", com_target_version->string);
} else {
Info_SetValueForKey(infostring, "gamever", va("d%s", com_target_version->string));
}
if (com_target_game->integer >= TG_MOHTT) {
Info_SetValueForKey(infostring, "serverType", va("%i", com_target_game->integer));
}
SV_NET_OutOfBandPrint( &svs.netprofile, from, "infoResponse\n%s", infostring );
}