mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-28 21:57:57 +03:00
Use functions that return master host information
This splits gamespy client-specific and server-specific code and add common gamespy code to provide more flexibility in the future
This commit is contained in:
parent
01367d0731
commit
a2bbf6cff8
12 changed files with 176 additions and 8 deletions
|
@ -7,6 +7,11 @@ add_subdirectory("../cgame" "./cgame")
|
|||
file(GLOB SOURCES_CLIENT "./*.c*")
|
||||
file(GLOB_RECURSE SOURCES_UILIB "../uilib/*.c*")
|
||||
|
||||
set(SOURCES_CLIENT ${SOURCES_CLIENT}
|
||||
# Gamespy
|
||||
"${CMAKE_SOURCE_DIR}/code/gamespy/cl_gamespy.c"
|
||||
)
|
||||
|
||||
# Made as an interface and not static, as static only links used methods
|
||||
add_library(omohclient INTERFACE)
|
||||
target_compile_definitions(omohclient INTERFACE APP_MODULE)
|
||||
|
|
36
code/gamespy/cl_gamespy.c
Normal file
36
code/gamespy/cl_gamespy.c
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
===========================================================================
|
||||
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
|
||||
|
||||
#include "cl_gamespy.h"
|
||||
#include "q_gamespy.h"
|
||||
|
||||
const char *ServerListGetHost()
|
||||
{
|
||||
return Com_GetMasterHost();
|
||||
}
|
||||
|
||||
int ServerListGetMsPort()
|
||||
{
|
||||
return Com_GetMasterQueryPort();
|
||||
}
|
25
code/gamespy/cl_gamespy.h
Normal file
25
code/gamespy/cl_gamespy.h
Normal file
|
@ -0,0 +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
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
// cl_gamespy.h -- Game-specific client GameSpy code
|
||||
|
||||
#pragma once
|
|
@ -48,8 +48,16 @@ Fax(714)549-0757
|
|||
// Added in 2.0
|
||||
#include "gcrypt.h"
|
||||
|
||||
#define MSHOST MASTER_SERVER_HOST
|
||||
#define MSPORT 28900
|
||||
/**
|
||||
* @brief Custom function used to return the master host, based on game settings
|
||||
*
|
||||
* @return const char* The master host
|
||||
*/
|
||||
extern const char *ServerListGetHost();
|
||||
extern int ServerGetMsPort();
|
||||
|
||||
#define MSHOST ServerListGetHost()
|
||||
#define MSPORT ServerListGetMsPort()
|
||||
#define SERVER_GROWBY 64
|
||||
#define LAN_SEARCH_TIME 3000 //3 sec
|
||||
#define LIST_NUMKEYBUCKETS 500
|
||||
|
|
40
code/gamespy/q_gamespy.c
Normal file
40
code/gamespy/q_gamespy.c
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
===========================================================================
|
||||
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
|
||||
|
||||
#include "q_gamespy.h"
|
||||
|
||||
const char *Com_GetMasterHost()
|
||||
{
|
||||
return "master.333networks.com";
|
||||
}
|
||||
|
||||
int Com_GetMasterQueryPort()
|
||||
{
|
||||
return 28900;
|
||||
}
|
||||
|
||||
int Com_GetMasterHeartbeatPort()
|
||||
{
|
||||
return 27900;
|
||||
}
|
29
code/gamespy/q_gamespy.h
Normal file
29
code/gamespy/q_gamespy.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
===========================================================================
|
||||
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
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
// q_gamespy.h -- Common game-specific GameSpy code shared between client and server
|
||||
|
||||
#pragma once
|
||||
|
||||
const char *Com_GetMasterHost();
|
||||
int Com_GetMasterQueryPort();
|
||||
int Com_GetMasterHeartbeatPort();
|
|
@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#include "../qcommon/q_version.h"
|
||||
#include "sv_gqueryreporting.h"
|
||||
#include "sv_gamespy.h"
|
||||
#include "q_gamespy.h"
|
||||
|
||||
#include "gcdkey/gcdkeys.h"
|
||||
#include "common/gsCommon.h"
|
||||
|
@ -501,3 +502,13 @@ void SV_GamespyAuthorize(netadr_t from, const char *response)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const char *qr_get_master_host()
|
||||
{
|
||||
return Com_GetMasterHost();
|
||||
}
|
||||
|
||||
int qr_get_master_port()
|
||||
{
|
||||
return Com_GetMasterHeartbeatPort();
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
===========================================================================
|
||||
*/
|
||||
|
||||
// sv_gamespy.h -- Game-specific server GameSpy code
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -161,7 +161,7 @@ static const char* queries[] = {"", "basic", "info", "rules", "players", "status
|
|||
static struct sockaddr_in hbaddr;
|
||||
struct qr_implementation_s static_rec = {INVALID_SOCKET, INVALID_SOCKET};
|
||||
static qr_t current_rec = &static_rec;
|
||||
char qr_hostname[64] = MASTER_ADDR;
|
||||
//char qr_hostname[64] = MASTER_ADDR;
|
||||
|
||||
static struct sockaddr_in MasterList[8];
|
||||
static char keyvalue[8192];
|
||||
|
|
|
@ -65,10 +65,9 @@ as the base port. Generally there is no reason to modify this value.
|
|||
/********
|
||||
DEFINES
|
||||
********/
|
||||
#define MASTER_SERVER_HOST "master.333networks.com"
|
||||
#define MASTER_PORT 27900
|
||||
#define MASTER_PORT qr_get_master_port()
|
||||
//#define MASTER_ADDR "master." GSI_DOMAIN_NAME
|
||||
#define MASTER_ADDR MASTER_SERVER_HOST
|
||||
#define MASTER_ADDR qr_get_master_host()
|
||||
#define FIRST_HB_TIME 30000 /* 30 sec */
|
||||
#define HB_TIME 300000 /* 5 minutes */
|
||||
#define MAX_FIRST_COUNT 10 /* 10 tries = 5 minutes */
|
||||
|
@ -82,6 +81,14 @@ IP can be stored here before calling
|
|||
qr_init */
|
||||
extern char qr_hostname[64];
|
||||
|
||||
/**
|
||||
* @brief Custom function used to return the master host, based on game settings
|
||||
*
|
||||
* @return const char* The full master server address
|
||||
*/
|
||||
extern const char *qr_get_master_host();
|
||||
extern int qr_get_master_port();
|
||||
|
||||
/********
|
||||
qr_querycallback_t
|
||||
-------------------
|
||||
|
|
|
@ -79,8 +79,7 @@ set(SOURCES_COMMON
|
|||
"${CMAKE_SOURCE_DIR}/code/qcommon/q_shared.c"
|
||||
"${CMAKE_SOURCE_DIR}/code/qcommon/unzip.c"
|
||||
# Gamespy
|
||||
"${CMAKE_SOURCE_DIR}/code/gamespy/sv_gamespy.c"
|
||||
"${CMAKE_SOURCE_DIR}/code/gamespy/sv_gqueryreporting.c"
|
||||
"${CMAKE_SOURCE_DIR}/code/gamespy/q_gamespy.c"
|
||||
)
|
||||
|
||||
add_subdirectory("../skeletor" "./skeletor")
|
||||
|
|
|
@ -6,6 +6,12 @@ add_subdirectory("../fgame" "./fgame")
|
|||
|
||||
file(GLOB_RECURSE SOURCES_SERVER "./*.c*")
|
||||
|
||||
set(SOURCES_SERVER ${SOURCES_SERVER}
|
||||
# Gamespy
|
||||
"${CMAKE_SOURCE_DIR}/code/gamespy/sv_gamespy.c"
|
||||
"${CMAKE_SOURCE_DIR}/code/gamespy/sv_gqueryreporting.c"
|
||||
)
|
||||
|
||||
add_library(omohserver INTERFACE)
|
||||
target_sources(omohserver INTERFACE ${SOURCES_SERVER})
|
||||
target_compile_features(omohserver INTERFACE cxx_nullptr)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue