Formatting

This commit is contained in:
smallmodel 2025-03-01 23:34:24 +01:00
parent 70f6ede7b8
commit d08027360f
No known key found for this signature in database
GPG key ID: 9F2D623CEDF08512
4 changed files with 101 additions and 55 deletions

View file

@ -1,6 +1,6 @@
/* /*
=========================================================================== ===========================================================================
Copyright (C) 2023 the OpenMoHAA team Copyright (C) 2025 the OpenMoHAA team
This file is part of OpenMoHAA source code. This file is part of OpenMoHAA source code.
@ -95,23 +95,28 @@ int qr_init(
void *userdata void *userdata
); );
const char* GS_GetGameKey(unsigned int index) { const char *GS_GetGameKey(unsigned int index)
{
return SECRET_GS_KEYS[index]; return SECRET_GS_KEYS[index];
} }
const char* GS_GetCurrentGameKey() { const char *GS_GetCurrentGameKey()
{
return GS_GetGameKey(com_target_game->integer); return GS_GetGameKey(com_target_game->integer);
} }
unsigned int GS_GetGameID(unsigned int index) { unsigned int GS_GetGameID(unsigned int index)
{
return GCD_GAME_IDS[index]; return GCD_GAME_IDS[index];
} }
unsigned int GS_GetCurrentGameID() { unsigned int GS_GetCurrentGameID()
{
return GS_GetGameID(com_target_game->integer); return GS_GetGameID(com_target_game->integer);
} }
const char* GS_GetGameName(unsigned int index) { const char *GS_GetGameName(unsigned int index)
{
if (!com_target_demo->integer) { if (!com_target_demo->integer) {
return GS_GAME_NAME[index]; return GS_GAME_NAME[index];
} else { } else {
@ -119,11 +124,13 @@ const char* GS_GetGameName(unsigned int index) {
} }
} }
const char* GS_GetCurrentGameName() { const char *GS_GetCurrentGameName()
{
return GS_GetGameName(com_target_game->integer); return GS_GetGameName(com_target_game->integer);
} }
const char* GS_GetGameVersion(unsigned int index) { const char *GS_GetGameVersion(unsigned int index)
{
if (!com_target_demo->integer) { if (!com_target_demo->integer) {
return GS_GAME_VERSION[index]; return GS_GAME_VERSION[index];
} else { } else {
@ -131,7 +138,8 @@ const char* GS_GetGameVersion(unsigned int index) {
} }
} }
const char* GS_GetCurrentGameVersion() { const char *GS_GetCurrentGameVersion()
{
return GS_GetGameVersion(com_target_game->integer); return GS_GetGameVersion(com_target_game->integer);
} }
@ -398,22 +406,27 @@ void AuthenticateCallback(int gameid, int localid, int authenticated, char* errm
} }
challenge = FindChallengeById(gameid); challenge = FindChallengeById(gameid);
if (valid) if (valid) {
{
challenge->cdkeyState = 2; challenge->cdkeyState = 2;
challenge->pingTime = svs.time; challenge->pingTime = svs.time;
SV_NET_OutOfBandPrint(&svs.netprofile, challenge->adr, "challengeResponse %i", challenge->challenge); SV_NET_OutOfBandPrint(&svs.netprofile, challenge->adr, "challengeResponse %i", challenge->challenge);
} } else {
else
{
char buf[32]; char buf[32];
if (!challenge) { if (!challenge) {
return; return;
} }
Com_sprintf(buf, sizeof(buf), "%d.%d.%d.%d", challenge->adr.ip[0], challenge->adr.ip[1], challenge->adr.ip[2], challenge->adr.ip[3]); Com_sprintf(
buf,
sizeof(buf),
"%d.%d.%d.%d",
challenge->adr.ip[0],
challenge->adr.ip[1],
challenge->adr.ip[2],
challenge->adr.ip[3]
);
Com_Printf("%s failed cdkey authorization\n", buf); Com_Printf("%s failed cdkey authorization\n", buf);
challenge->cdkeyState = 3; challenge->cdkeyState = 3;
// tell the client about the reason // tell the client about the reason
@ -421,9 +434,7 @@ void AuthenticateCallback(int gameid, int localid, int authenticated, char* errm
} }
} }
void RefreshAuthCallback(int gameid, int localid, int hint, char* challenge, void* instance) void RefreshAuthCallback(int gameid, int localid, int hint, char *challenge, void *instance) {}
{
}
void SV_GamespyAuthorize(netadr_t from, const char *response) void SV_GamespyAuthorize(netadr_t from, const char *response)
{ {
@ -433,8 +444,7 @@ void SV_GamespyAuthorize(netadr_t from, const char* response)
return; return;
} }
switch (challenge->cdkeyState) switch (challenge->cdkeyState) {
{
case CDKS_NONE: case CDKS_NONE:
challenge->cdkeyState = CDKS_AUTHENTICATING; challenge->cdkeyState = CDKS_AUTHENTICATING;
challenge->firstTime = svs.time; challenge->firstTime = svs.time;
@ -453,8 +463,7 @@ void SV_GamespyAuthorize(netadr_t from, const char* response)
case CDKS_AUTHENTICATING: case CDKS_AUTHENTICATING:
// the server can't reach the authentication server // the server can't reach the authentication server
// let the client connect // let the client connect
if (svs.time - challenge->firstTime > 5000) if (svs.time - challenge->firstTime > 5000) {
{
Com_DPrintf("authorize server timed out\n"); Com_DPrintf("authorize server timed out\n");
challenge->cdkeyState = CDKS_AUTHENTICATED; challenge->cdkeyState = CDKS_AUTHENTICATED;
challenge->pingTime = svs.time; challenge->pingTime = svs.time;
@ -466,7 +475,15 @@ void SV_GamespyAuthorize(netadr_t from, const char* response)
break; break;
case CDKS_FAILED: case CDKS_FAILED:
// authentication server told the cdkey was invalid // authentication server told the cdkey was invalid
Com_sprintf(buf, sizeof(buf), "%d.%d.%d.%d", challenge->adr.ip[0], challenge->adr.ip[1], challenge->adr.ip[2], challenge->adr.ip[3]); Com_sprintf(
buf,
sizeof(buf),
"%d.%d.%d.%d",
challenge->adr.ip[0],
challenge->adr.ip[1],
challenge->adr.ip[2],
challenge->adr.ip[3]
);
Com_Printf("%s failed cdkey authorization\n", buf); Com_Printf("%s failed cdkey authorization\n", buf);
// reject the client // reject the client
SV_NET_OutOfBandPrint(&svs.netprofile, from, "droperror\nServer rejected connection:\nInvalid CD Key"); SV_NET_OutOfBandPrint(&svs.netprofile, from, "droperror\nServer rejected connection:\nInvalid CD Key");

View file

@ -1,3 +1,25 @@
/*
===========================================================================
Copyright (C) 2025 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#pragma once #pragma once
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -1,6 +1,6 @@
/* /*
=========================================================================== ===========================================================================
Copyright (C) 2023 the OpenMoHAA team Copyright (C) 2025 the OpenMoHAA team
This file is part of OpenMoHAA source code. This file is part of OpenMoHAA source code.
@ -402,7 +402,14 @@ static void send_heartbeat(qr_t qrec, int statechanged)
sprintf(buf + strlen(buf), "\\statechanged\\%d", statechanged); sprintf(buf + strlen(buf), "\\statechanged\\%d", statechanged);
} }
sendto((SOCKET)qrec->hbsock, buf, (int)strlen(buf), 0, (const struct sockaddr *)&qrec->master_saddr, sizeof(qrec->master_saddr)); sendto(
(SOCKET)qrec->hbsock,
buf,
(int)strlen(buf),
0,
(const struct sockaddr *)&qrec->master_saddr,
sizeof(qrec->master_saddr)
);
qrec->lastheartbeat = current_time(); qrec->lastheartbeat = current_time();
} }

View file

@ -1,6 +1,6 @@
/* /*
=========================================================================== ===========================================================================
Copyright (C) 2023 the OpenMoHAA team Copyright (C) 2025 the OpenMoHAA team
This file is part of OpenMoHAA source code. This file is part of OpenMoHAA source code.