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

@ -3689,6 +3689,8 @@ void CL_ServerInfoPacket( netadr_t from, msg_t *msg ) {
char *infoString;
int prot;
char *gamename;
char *pszVersion;
char *pszServerType;
qboolean gameMismatch;
infoString = MSG_ReadString( msg );
@ -3717,12 +3719,44 @@ void CL_ServerInfoPacket( netadr_t from, msg_t *msg ) {
#ifdef LEGACY_PROTOCOL
&& prot != com_legacyprotocol->integer
#endif
&& (com_target_demo->integer || prot != protocol_version_demo)
)
{
Com_DPrintf( "Different protocol info packet: %s\n", infoString );
return;
}
if (!com_target_demo->integer && prot == protocol_version_demo) {
Com_DPrintf("Full version found compatible demo protocol version. %s\n", infoString);
}
pszVersion = Info_ValueForKey(infoString, "gamever");
pszServerType = Info_ValueForKey(infoString, "serverType");
if (!*pszVersion) {
return;
}
if (*pszVersion == 'd') {
pszVersion++;
}
if (com_target_game->integer >= target_game_e::TG_MOHTT) {
if (atoi(pszServerType) == target_game_e::TG_MOHTT) {
if (fabs(atof(pszVersion)) < 2.3f) {
return;
}
} else {
if (fabs(atof(pszVersion)) < 2.1f) {
return;
}
}
} else {
if (fabs(atof(pszVersion) - com_target_version->value) > 0.1f) {
return;
}
}
// iterate servers waiting for ping response
for (i=0; i<MAX_PINGREQUESTS; i++)
{