Compare commits

...

2 Commits

Author SHA1 Message Date
julien bruel 4b83a7a3d5 put back source query 2021-04-09 21:32:11 +02:00
julien bruel 3ee66fb2de Revert change 2021-04-09 21:07:04 +02:00
13 changed files with 41 additions and 19 deletions

View File

@ -136,7 +136,7 @@ Steam_Client *get_steam_clientserver_old()
static bool steamclient_has_ipv6_functions_flag;
bool steamclient_has_ipv6_functions()
{
return steamclient_has_ipv6_functions_flag;
return steamclient_has_ipv6_functions_flag || get_steam_client()->gameserver_has_ipv6_functions;
}
static void *create_client_interface(const char *ver)

View File

@ -5843,9 +5843,15 @@ STEAMAPI_API SteamAPICall_t SteamAPI_ISteamGameServer_GetServerReputation( IStea
return self->GetServerReputation();
}
STEAMAPI_API SteamIPAddress_t SteamAPI_ISteamGameServer_GetPublicIP( ISteamGameServer* self )
{
return self->GetPublicIP();
STEAMAPI_API void *SteamAPI_ISteamGameServer_GetPublicIP( intptr_t instancePtr, void *instancePtr_possible )
{
//abuse call convention rules to get this working.
if (steamclient_has_ipv6_functions()) {
get_steam_client()->steam_gameserver->GetPublicIP_fix((SteamIPAddress_t *)instancePtr);
return (void *)instancePtr;
} else {
return (void *)((ISteamGameServer012 *)instancePtr)->GetPublicIP_old();
}
}
STEAMAPI_API bool SteamAPI_ISteamGameServer_HandleIncomingPacket( ISteamGameServer* self, const void * pData, int cbData, uint32 srcIP, uint16 srcPort )

View File

@ -230,12 +230,12 @@ static void kill_socket(sock_t sock)
}
static void kill_tcp_socket(struct TCP_Socket &socket)
{
{
kill_socket(socket.sock);
socket = TCP_Socket();
}
static bool initialed;
static void run_at_startup()
{
static bool initialed = false;
@ -1271,7 +1271,6 @@ bool Networking::isAlive()
return alive;
}
void Networking::startQuery(IP_PORT ip_port)
{
if (ip_port.port <= 1024)
@ -1341,4 +1340,4 @@ void Networking::shutDownQuery()
bool Networking::isQueryAlive()
{
return query_alive;
}
}

View File

@ -86,8 +86,8 @@ struct Connection {
class Networking {
bool enabled = false;
bool query_alive;
bool alive;
bool query_alive;
std::chrono::high_resolution_clock::time_point last_run;
sock_t query_socket, udp_socket, tcp_socket;
uint16 udp_port, tcp_port;
@ -137,7 +137,7 @@ public:
void shutDown();
bool isAlive();
void startQuery(IP_PORT ip_port);
void shutDownQuery();
bool isQueryAlive();

View File

@ -109,6 +109,8 @@ Steam_Client::Steam_Client()
steam_gameserver_game_coordinator = new Steam_Game_Coordinator(settings_server, network, callback_results_server, callbacks_server, run_every_runcb);
steam_masterserver_updater = new Steam_Masterserver_Updater(settings_server, network, callback_results_server, callbacks_server, run_every_runcb);
gameserver_has_ipv6_functions = false;
last_cb_run = 0;
PRINT_DEBUG("client init end\n");
}
@ -303,8 +305,10 @@ ISteamGameServer *Steam_Client::GetISteamGameServer( HSteamUser hSteamUser, HSte
} else if (strcmp(pchVersion, "SteamGameServer012") == 0) {
return (ISteamGameServer *)(void *)(ISteamGameServer012 *)steam_gameserver;
} else if (strcmp(pchVersion, STEAMGAMESERVER_INTERFACE_VERSION) == 0) {
gameserver_has_ipv6_functions = true;
return (ISteamGameServer *)(void *)(ISteamGameServer *)steam_gameserver;
} else {
gameserver_has_ipv6_functions = true;
return (ISteamGameServer *)(void *)(ISteamGameServer *)steam_gameserver;
}

View File

@ -139,6 +139,8 @@ public:
unsigned steam_pipe_counter = 1;
std::map<HSteamPipe, enum Steam_Pipe> steam_pipes;
bool gameserver_has_ipv6_functions;
Steam_Client();
~Steam_Client();
// Creates a communication pipe to the Steam client.

View File

@ -59,8 +59,8 @@ bool Steam_GameServer::InitGameServer( uint32 unIP, uint16 usGamePort, uint16 us
server_data.set_ip(unIP);
server_data.set_port(usGamePort);
server_data.set_query_port(usQueryPort);
server_data.set_offline(false);
server_data.set_offline(false);
if (!settings->disable_source_query)
network->startQuery({ unIP, usQueryPort });
@ -81,7 +81,7 @@ void Steam_GameServer::SetProduct( const char *pszProduct )
{
PRINT_DEBUG("SetProduct\n");
std::lock_guard<std::recursive_mutex> lock(global_mutex);
server_data.set_product(pszProduct);
server_data.set_product(pszProduct);// Set product to game name if this is empty
}
@ -402,7 +402,7 @@ void Steam_GameServer::SendUserDisconnect( CSteamID steamIDUser )
{
PRINT_DEBUG("SendUserDisconnect\n");
std::lock_guard<std::recursive_mutex> lock(global_mutex);
auto player_it = std::find_if(players.begin(), players.end(), [&steamIDUser](std::pair<CSteamID, Gameserver_Player_Info_t>& player)
{
return player.first == steamIDUser;
@ -617,6 +617,12 @@ SteamIPAddress_t Steam_GameServer::GetPublicIP()
return ip;
}
void Steam_GameServer::GetPublicIP_fix(SteamIPAddress_t *out)
{
PRINT_DEBUG("GetPublicIP_fix\n");
if (out) *out = GetPublicIP();
}
// These are in GameSocketShare mode, where instead of ISteamGameServer creating its own
// socket to talk to the master server on, it lets the game use its socket to forward messages
// back and forth. This prevents us from requiring server ops to open up yet another port
@ -761,7 +767,7 @@ void Steam_GameServer::RunCallbacks()
msg.set_allocated_gameserver(new Gameserver(server_data));
msg.mutable_gameserver()->set_offline(true);
network->sendToAllIndividuals(&msg, true);
// Shutdown Source Query
// Shutdown Source Query
network->shutDownQuery();
// And empty the queue if needed
outgoing_packets.clear();

View File

@ -69,7 +69,7 @@ public:
Steam_GameServer(class Settings *settings, class Networking *network, class SteamCallBacks *callbacks);
~Steam_GameServer();
std::vector<std::pair<CSteamID, Gameserver_Player_Info_t>>* get_players();
//
@ -291,6 +291,7 @@ public:
// connect to
uint32 GetPublicIP_old();
SteamIPAddress_t GetPublicIP();
void GetPublicIP_fix(SteamIPAddress_t *out);
// These are in GameSocketShare mode, where instead of ISteamGameServer creating its own
// socket to talk to the master server on, it lets the game use its socket to forward messages

View File

@ -239,6 +239,7 @@ bool GetAchievement( const char *pchName, bool *pbAchieved )
try {
auto it = defined_achievements_find(pchName);
if (it == defined_achievements.end()) return false;
std::string pch_name = it->value("name", std::string());
auto ach = user_achievements.find(pch_name);
@ -261,6 +262,7 @@ bool SetAchievement( const char *pchName )
try {
auto it = defined_achievements_find(pchName);
if (it == defined_achievements.end()) return false;
std::string pch_name = it->value("name", std::string());
if (it != defined_achievements.end()) {
@ -288,6 +290,7 @@ bool ClearAchievement( const char *pchName )
try {
auto it = defined_achievements_find(pchName);
if (it == defined_achievements.end()) return false;
std::string pch_name = it->value("name", std::string());
if (it != defined_achievements.end()) {
@ -313,6 +316,7 @@ bool GetAchievementAndUnlockTime( const char *pchName, bool *pbAchieved, uint32
try {
auto it = defined_achievements_find(pchName);
if (it == defined_achievements.end()) return false;
std::string pch_name = it->value("name", std::string());
auto ach = user_achievements.find(pch_name);
@ -417,6 +421,8 @@ bool IndicateAchievementProgress( const char *pchName, uint32 nCurProgress, uint
try {
auto it = defined_achievements_find(pchName);
if (it == defined_achievements.end()) return false;
std::string pch_name = it->value("name", std::string());
auto ach = user_achievements.find(pch_name);

View File

@ -189,8 +189,6 @@ public:
// behind NAT and you want to advertise its IP in a lobby for other clients to directly
// connect to
virtual uint32 GetPublicIP_old() = 0;
virtual SteamIPAddress_t GetPublicIP() = 0;
// These are in GameSocketShare mode, where instead of ISteamGameServer creating its own
// socket to talk to the master server on, it lets the game use its socket to forward messages

View File

@ -1011,7 +1011,7 @@ STEAMAPI_API EUserHasLicenseForAppResult SteamAPI_ISteamGameServer_UserHasLicens
STEAMAPI_API bool SteamAPI_ISteamGameServer_RequestUserGroupStatus( ISteamGameServer* self, uint64_steamid steamIDUser, uint64_steamid steamIDGroup );
STEAMAPI_API void SteamAPI_ISteamGameServer_GetGameplayStats( ISteamGameServer* self );
STEAMAPI_API SteamAPICall_t SteamAPI_ISteamGameServer_GetServerReputation( ISteamGameServer* self );
STEAMAPI_API SteamIPAddress_t SteamAPI_ISteamGameServer_GetPublicIP( ISteamGameServer* self );
//STEAMAPI_API SteamIPAddress_t SteamAPI_ISteamGameServer_GetPublicIP( ISteamGameServer* self );
STEAMAPI_API bool SteamAPI_ISteamGameServer_HandleIncomingPacket( ISteamGameServer* self, const void * pData, int cbData, uint32 srcIP, uint16 srcPort );
STEAMAPI_API int SteamAPI_ISteamGameServer_GetNextOutgoingPacket( ISteamGameServer* self, void * pOut, int cbMaxOut, uint32 * pNetAdr, uint16 * pPort );
STEAMAPI_API void SteamAPI_ISteamGameServer_EnableHeartbeats( ISteamGameServer* self, bool bActive );

BIN
steamclient.dll Normal file

Binary file not shown.

BIN
steamclient64.dll Normal file

Binary file not shown.