mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-28 21:57:57 +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.
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,7 +371,7 @@ qboolean SV_InitGamespy()
|
||||||
return qtrue;
|
return qtrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SV_CreateGamespyChallenge(char* challenge)
|
void SV_CreateGamespyChallenge(char *challenge)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -373,9 +381,9 @@ void SV_CreateGamespyChallenge(char* challenge)
|
||||||
challenge[i] = 0;
|
challenge[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
challenge_t* FindChallengeById(int gameid)
|
challenge_t *FindChallengeById(int gameid)
|
||||||
{
|
{
|
||||||
challenge_t* challenge;
|
challenge_t *challenge;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < MAX_CHALLENGES; i++) {
|
for (i = 0; i < MAX_CHALLENGES; i++) {
|
||||||
|
@ -388,9 +396,9 @@ challenge_t* FindChallengeById(int gameid)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AuthenticateCallback(int gameid, int localid, int authenticated, char* errmsg, void* instance)
|
void AuthenticateCallback(int gameid, int localid, int authenticated, char *errmsg, void *instance)
|
||||||
{
|
{
|
||||||
challenge_t* challenge;
|
challenge_t *challenge;
|
||||||
qboolean valid = qfalse;
|
qboolean valid = qfalse;
|
||||||
|
|
||||||
if (localid || !Q_stricmp(errmsg, "CD Key in use")) {
|
if (localid || !Q_stricmp(errmsg, "CD Key in use")) {
|
||||||
|
@ -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,20 +434,17 @@ 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)
|
||||||
{
|
{
|
||||||
char buf[64];
|
char buf[64];
|
||||||
challenge_t* challenge = FindChallenge(from, qtrue);
|
challenge_t *challenge = FindChallenge(from, qtrue);
|
||||||
if (!challenge) {
|
if (!challenge) {
|
||||||
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;
|
||||||
|
@ -442,7 +452,7 @@ void SV_GamespyAuthorize(netadr_t from, const char* response)
|
||||||
gcd_authenticate_user(
|
gcd_authenticate_user(
|
||||||
GS_GetCurrentGameID(),
|
GS_GetCurrentGameID(),
|
||||||
challenge->gamespyId,
|
challenge->gamespyId,
|
||||||
LittleLong(*(unsigned int*)from.ip),
|
LittleLong(*(unsigned int *)from.ip),
|
||||||
challenge->gsChallenge,
|
challenge->gsChallenge,
|
||||||
response,
|
response,
|
||||||
AuthenticateCallback,
|
AuthenticateCallback,
|
||||||
|
@ -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");
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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.
|
||||||
|
|
||||||
|
@ -306,7 +306,7 @@ static void send_final(qr_t qrec, struct sockaddr *sender, char *outbuf, char *v
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy((char*)encrypted_val, validation);
|
strcpy((char *)encrypted_val, validation);
|
||||||
|
|
||||||
gs_encrypt((uchar *)qrec->secret_key, (int)strlen(qrec->secret_key), encrypted_val, keylen);
|
gs_encrypt((uchar *)qrec->secret_key, (int)strlen(qrec->secret_key), encrypted_val, keylen);
|
||||||
gs_encode(encrypted_val, keylen, encoded_val);
|
gs_encode(encrypted_val, keylen, encoded_val);
|
||||||
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue