mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-28 13:47:58 +03:00
Formatting
This commit is contained in:
parent
70f6ede7b8
commit
d08027360f
4 changed files with 101 additions and 55 deletions
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2023 the OpenMoHAA team
|
||||
Copyright (C) 2025 the OpenMoHAA team
|
||||
|
||||
This file is part of OpenMoHAA source code.
|
||||
|
||||
|
@ -95,23 +95,28 @@ int qr_init(
|
|||
void *userdata
|
||||
);
|
||||
|
||||
const char* GS_GetGameKey(unsigned int index) {
|
||||
const char *GS_GetGameKey(unsigned int index)
|
||||
{
|
||||
return SECRET_GS_KEYS[index];
|
||||
}
|
||||
|
||||
const char* GS_GetCurrentGameKey() {
|
||||
const char *GS_GetCurrentGameKey()
|
||||
{
|
||||
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];
|
||||
}
|
||||
|
||||
unsigned int GS_GetCurrentGameID() {
|
||||
unsigned int GS_GetCurrentGameID()
|
||||
{
|
||||
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) {
|
||||
return GS_GAME_NAME[index];
|
||||
} 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);
|
||||
}
|
||||
|
||||
const char* GS_GetGameVersion(unsigned int index) {
|
||||
const char *GS_GetGameVersion(unsigned int index)
|
||||
{
|
||||
if (!com_target_demo->integer) {
|
||||
return GS_GAME_VERSION[index];
|
||||
} 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);
|
||||
}
|
||||
|
||||
|
@ -398,22 +406,27 @@ void AuthenticateCallback(int gameid, int localid, int authenticated, char* errm
|
|||
}
|
||||
|
||||
challenge = FindChallengeById(gameid);
|
||||
if (valid)
|
||||
{
|
||||
if (valid) {
|
||||
challenge->cdkeyState = 2;
|
||||
challenge->pingTime = svs.time;
|
||||
|
||||
SV_NET_OutOfBandPrint(&svs.netprofile, challenge->adr, "challengeResponse %i", challenge->challenge);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
char buf[32];
|
||||
|
||||
if (!challenge) {
|
||||
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);
|
||||
challenge->cdkeyState = 3;
|
||||
// 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)
|
||||
{
|
||||
|
@ -433,8 +444,7 @@ void SV_GamespyAuthorize(netadr_t from, const char* response)
|
|||
return;
|
||||
}
|
||||
|
||||
switch (challenge->cdkeyState)
|
||||
{
|
||||
switch (challenge->cdkeyState) {
|
||||
case CDKS_NONE:
|
||||
challenge->cdkeyState = CDKS_AUTHENTICATING;
|
||||
challenge->firstTime = svs.time;
|
||||
|
@ -453,8 +463,7 @@ void SV_GamespyAuthorize(netadr_t from, const char* response)
|
|||
case CDKS_AUTHENTICATING:
|
||||
// the server can't reach the authentication server
|
||||
// let the client connect
|
||||
if (svs.time - challenge->firstTime > 5000)
|
||||
{
|
||||
if (svs.time - challenge->firstTime > 5000) {
|
||||
Com_DPrintf("authorize server timed out\n");
|
||||
challenge->cdkeyState = CDKS_AUTHENTICATED;
|
||||
challenge->pingTime = svs.time;
|
||||
|
@ -466,7 +475,15 @@ void SV_GamespyAuthorize(netadr_t from, const char* response)
|
|||
break;
|
||||
case CDKS_FAILED:
|
||||
// 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);
|
||||
// reject the client
|
||||
SV_NET_OutOfBandPrint(&svs.netprofile, from, "droperror\nServer rejected connection:\nInvalid CD Key");
|
||||
|
|
|
@ -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
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2023 the OpenMoHAA team
|
||||
Copyright (C) 2025 the OpenMoHAA team
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2023 the OpenMoHAA team
|
||||
Copyright (C) 2025 the OpenMoHAA team
|
||||
|
||||
This file is part of OpenMoHAA source code.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue