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; static bool steamclient_has_ipv6_functions_flag;
bool steamclient_has_ipv6_functions() 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) 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(); return self->GetServerReputation();
} }
STEAMAPI_API SteamIPAddress_t SteamAPI_ISteamGameServer_GetPublicIP( ISteamGameServer* self ) STEAMAPI_API void *SteamAPI_ISteamGameServer_GetPublicIP( intptr_t instancePtr, void *instancePtr_possible )
{ {
return self->GetPublicIP(); //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 ) 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) static void kill_tcp_socket(struct TCP_Socket &socket)
{ {
kill_socket(socket.sock); kill_socket(socket.sock);
socket = TCP_Socket(); socket = TCP_Socket();
} }
static bool initialed;
static void run_at_startup() static void run_at_startup()
{ {
static bool initialed = false; static bool initialed = false;
@ -1271,7 +1271,6 @@ bool Networking::isAlive()
return alive; return alive;
} }
void Networking::startQuery(IP_PORT ip_port) void Networking::startQuery(IP_PORT ip_port)
{ {
if (ip_port.port <= 1024) if (ip_port.port <= 1024)
@ -1341,4 +1340,4 @@ void Networking::shutDownQuery()
bool Networking::isQueryAlive() bool Networking::isQueryAlive()
{ {
return query_alive; return query_alive;
} }

View File

@ -86,8 +86,8 @@ struct Connection {
class Networking { class Networking {
bool enabled = false; bool enabled = false;
bool query_alive;
bool alive; bool alive;
bool query_alive;
std::chrono::high_resolution_clock::time_point last_run; std::chrono::high_resolution_clock::time_point last_run;
sock_t query_socket, udp_socket, tcp_socket; sock_t query_socket, udp_socket, tcp_socket;
uint16 udp_port, tcp_port; uint16 udp_port, tcp_port;
@ -137,7 +137,7 @@ public:
void shutDown(); void shutDown();
bool isAlive(); bool isAlive();
void startQuery(IP_PORT ip_port); void startQuery(IP_PORT ip_port);
void shutDownQuery(); void shutDownQuery();
bool isQueryAlive(); 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_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); 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; last_cb_run = 0;
PRINT_DEBUG("client init end\n"); PRINT_DEBUG("client init end\n");
} }
@ -303,8 +305,10 @@ ISteamGameServer *Steam_Client::GetISteamGameServer( HSteamUser hSteamUser, HSte
} else if (strcmp(pchVersion, "SteamGameServer012") == 0) { } else if (strcmp(pchVersion, "SteamGameServer012") == 0) {
return (ISteamGameServer *)(void *)(ISteamGameServer012 *)steam_gameserver; return (ISteamGameServer *)(void *)(ISteamGameServer012 *)steam_gameserver;
} else if (strcmp(pchVersion, STEAMGAMESERVER_INTERFACE_VERSION) == 0) { } else if (strcmp(pchVersion, STEAMGAMESERVER_INTERFACE_VERSION) == 0) {
gameserver_has_ipv6_functions = true;
return (ISteamGameServer *)(void *)(ISteamGameServer *)steam_gameserver; return (ISteamGameServer *)(void *)(ISteamGameServer *)steam_gameserver;
} else { } else {
gameserver_has_ipv6_functions = true;
return (ISteamGameServer *)(void *)(ISteamGameServer *)steam_gameserver; return (ISteamGameServer *)(void *)(ISteamGameServer *)steam_gameserver;
} }

View File

@ -139,6 +139,8 @@ public:
unsigned steam_pipe_counter = 1; unsigned steam_pipe_counter = 1;
std::map<HSteamPipe, enum Steam_Pipe> steam_pipes; std::map<HSteamPipe, enum Steam_Pipe> steam_pipes;
bool gameserver_has_ipv6_functions;
Steam_Client(); Steam_Client();
~Steam_Client(); ~Steam_Client();
// Creates a communication pipe to the 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_ip(unIP);
server_data.set_port(usGamePort); server_data.set_port(usGamePort);
server_data.set_query_port(usQueryPort); server_data.set_query_port(usQueryPort);
server_data.set_offline(false); server_data.set_offline(false);
if (!settings->disable_source_query) if (!settings->disable_source_query)
network->startQuery({ unIP, usQueryPort }); network->startQuery({ unIP, usQueryPort });
@ -81,7 +81,7 @@ void Steam_GameServer::SetProduct( const char *pszProduct )
{ {
PRINT_DEBUG("SetProduct\n"); PRINT_DEBUG("SetProduct\n");
std::lock_guard<std::recursive_mutex> lock(global_mutex); 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"); PRINT_DEBUG("SendUserDisconnect\n");
std::lock_guard<std::recursive_mutex> lock(global_mutex); 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) auto player_it = std::find_if(players.begin(), players.end(), [&steamIDUser](std::pair<CSteamID, Gameserver_Player_Info_t>& player)
{ {
return player.first == steamIDUser; return player.first == steamIDUser;
@ -617,6 +617,12 @@ SteamIPAddress_t Steam_GameServer::GetPublicIP()
return ip; 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 // 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 // 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 // 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.set_allocated_gameserver(new Gameserver(server_data));
msg.mutable_gameserver()->set_offline(true); msg.mutable_gameserver()->set_offline(true);
network->sendToAllIndividuals(&msg, true); network->sendToAllIndividuals(&msg, true);
// Shutdown Source Query // Shutdown Source Query
network->shutDownQuery(); network->shutDownQuery();
// And empty the queue if needed // And empty the queue if needed
outgoing_packets.clear(); outgoing_packets.clear();

View File

@ -69,7 +69,7 @@ public:
Steam_GameServer(class Settings *settings, class Networking *network, class SteamCallBacks *callbacks); Steam_GameServer(class Settings *settings, class Networking *network, class SteamCallBacks *callbacks);
~Steam_GameServer(); ~Steam_GameServer();
std::vector<std::pair<CSteamID, Gameserver_Player_Info_t>>* get_players(); std::vector<std::pair<CSteamID, Gameserver_Player_Info_t>>* get_players();
// //
@ -291,6 +291,7 @@ public:
// connect to // connect to
uint32 GetPublicIP_old(); uint32 GetPublicIP_old();
SteamIPAddress_t GetPublicIP(); SteamIPAddress_t GetPublicIP();
void GetPublicIP_fix(SteamIPAddress_t *out);
// These are in GameSocketShare mode, where instead of ISteamGameServer creating its own // 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 // 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 { try {
auto it = defined_achievements_find(pchName); auto it = defined_achievements_find(pchName);
if (it == defined_achievements.end()) return false;
std::string pch_name = it->value("name", std::string()); std::string pch_name = it->value("name", std::string());
auto ach = user_achievements.find(pch_name); auto ach = user_achievements.find(pch_name);
@ -261,6 +262,7 @@ bool SetAchievement( const char *pchName )
try { try {
auto it = defined_achievements_find(pchName); auto it = defined_achievements_find(pchName);
if (it == defined_achievements.end()) return false;
std::string pch_name = it->value("name", std::string()); std::string pch_name = it->value("name", std::string());
if (it != defined_achievements.end()) { if (it != defined_achievements.end()) {
@ -288,6 +290,7 @@ bool ClearAchievement( const char *pchName )
try { try {
auto it = defined_achievements_find(pchName); auto it = defined_achievements_find(pchName);
if (it == defined_achievements.end()) return false;
std::string pch_name = it->value("name", std::string()); std::string pch_name = it->value("name", std::string());
if (it != defined_achievements.end()) { if (it != defined_achievements.end()) {
@ -313,6 +316,7 @@ bool GetAchievementAndUnlockTime( const char *pchName, bool *pbAchieved, uint32
try { try {
auto it = defined_achievements_find(pchName); auto it = defined_achievements_find(pchName);
if (it == defined_achievements.end()) return false;
std::string pch_name = it->value("name", std::string()); std::string pch_name = it->value("name", std::string());
auto ach = user_achievements.find(pch_name); auto ach = user_achievements.find(pch_name);
@ -417,6 +421,8 @@ bool IndicateAchievementProgress( const char *pchName, uint32 nCurProgress, uint
try { try {
auto it = defined_achievements_find(pchName); auto it = defined_achievements_find(pchName);
if (it == defined_achievements.end()) return false;
std::string pch_name = it->value("name", std::string()); std::string pch_name = it->value("name", std::string());
auto ach = user_achievements.find(pch_name); 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 // behind NAT and you want to advertise its IP in a lobby for other clients to directly
// connect to // connect to
virtual uint32 GetPublicIP_old() = 0; virtual uint32 GetPublicIP_old() = 0;
virtual SteamIPAddress_t GetPublicIP() = 0;
// These are in GameSocketShare mode, where instead of ISteamGameServer creating its own // 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 // 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 bool SteamAPI_ISteamGameServer_RequestUserGroupStatus( ISteamGameServer* self, uint64_steamid steamIDUser, uint64_steamid steamIDGroup );
STEAMAPI_API void SteamAPI_ISteamGameServer_GetGameplayStats( ISteamGameServer* self ); STEAMAPI_API void SteamAPI_ISteamGameServer_GetGameplayStats( ISteamGameServer* self );
STEAMAPI_API SteamAPICall_t SteamAPI_ISteamGameServer_GetServerReputation( 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 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 int SteamAPI_ISteamGameServer_GetNextOutgoingPacket( ISteamGameServer* self, void * pOut, int cbMaxOut, uint32 * pNetAdr, uint16 * pPort );
STEAMAPI_API void SteamAPI_ISteamGameServer_EnableHeartbeats( ISteamGameServer* self, bool bActive ); 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.