mirror of
https://gitlab.com/Mr_Goldberg/goldberg_emulator
synced 2025-05-23 21:57:40 +08:00
Improve steam_masterserver_updater stub.
This creates a new "custom_master_server.txt" file that can be used to pre-seed a master server list. This also allows for steam apps to manipulate the master server list in memory. I.e. This implements: Steam_Masterserver_Updater::AddMasterServer() Steam_Masterserver_Updater::RemoveMasterServer() Steam_Masterserver_Updater::GetNumMasterServers() Steam_Masterserver_Updater::GetMasterServerAddress() Signed-off-by: redpolline <11156324-redpolline@users.noreply.gitlab.com>
This commit is contained in:
parent
8f212b82ca
commit
a2c9f9230f
@ -132,6 +132,9 @@ public:
|
||||
//custom broadcasts
|
||||
std::set<IP_PORT> custom_broadcasts;
|
||||
|
||||
//custom master server
|
||||
std::set<IP_PORT> custom_master_server;
|
||||
|
||||
//stats
|
||||
std::map<std::string, Stat_config> getStats() { return stats; }
|
||||
void setStatDefiniton(std::string name, struct Stat_config stat_config) {stats[ascii_to_lowercase(name)] = stat_config; }
|
||||
|
@ -211,6 +211,11 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s
|
||||
load_custom_broadcasts(local_storage->get_global_settings_path() + "custom_broadcasts.txt", custom_broadcasts);
|
||||
load_custom_broadcasts(Local_Storage::get_game_settings_path() + "custom_broadcasts.txt", custom_broadcasts);
|
||||
|
||||
// Custom master server
|
||||
std::set<IP_PORT> custom_master_server;
|
||||
load_custom_broadcasts(local_storage->get_global_settings_path() + "custom_master_server.txt", custom_master_server);
|
||||
load_custom_broadcasts(Local_Storage::get_game_settings_path() + "custom_master_server.txt", custom_master_server);
|
||||
|
||||
// Acount name
|
||||
char name[32] = {};
|
||||
if (local_storage->get_data_settings("account_name.txt", name, sizeof(name) - 1) <= 0) {
|
||||
@ -359,6 +364,8 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s
|
||||
settings_server->set_port(port);
|
||||
settings_client->custom_broadcasts = custom_broadcasts;
|
||||
settings_server->custom_broadcasts = custom_broadcasts;
|
||||
settings_client->custom_master_server = custom_master_server;
|
||||
settings_server->custom_master_server = custom_master_server;
|
||||
settings_client->disable_networking = disable_networking;
|
||||
settings_server->disable_networking = disable_networking;
|
||||
settings_client->disable_overlay = disable_overlay;
|
||||
|
@ -173,12 +173,64 @@ void ForceHeartbeat()
|
||||
bool AddMasterServer( const char *pServerAddress )
|
||||
{
|
||||
PRINT_DEBUG("Steam_Masterserver_Updater::AddMasterServer\n");
|
||||
|
||||
IP_PORT addr;
|
||||
|
||||
if (pServerAddress)
|
||||
{
|
||||
addr.ip = (uint32)*pServerAddress;
|
||||
if (pServerAddress[(sizeof(uint32))] != 0)
|
||||
{
|
||||
addr.port = (uint16)*(pServerAddress + sizeof(uint32));
|
||||
}
|
||||
else
|
||||
{
|
||||
addr.port = 27016;
|
||||
}
|
||||
PRINT_DEBUG("Steam_Masterserver_Updater::AddMasterServer pServerAddress IP: %d, PORT: %d", addr.ip, addr.port);
|
||||
this->settings->custom_master_server.insert(addr);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RemoveMasterServer( const char *pServerAddress )
|
||||
{
|
||||
PRINT_DEBUG("Steam_Masterserver_Updater::RemoveMasterServer\n");
|
||||
|
||||
std::set<IP_PORT>::iterator iter;
|
||||
IP_PORT addr;
|
||||
IP_PORT list;
|
||||
|
||||
if (pServerAddress)
|
||||
{
|
||||
addr.ip = (uint32)*pServerAddress;
|
||||
if (pServerAddress[(sizeof(uint32))] != 0)
|
||||
{
|
||||
addr.port = (uint16)*(pServerAddress + sizeof(uint32));
|
||||
}
|
||||
else
|
||||
{
|
||||
addr.port = 27016;
|
||||
}
|
||||
PRINT_DEBUG("Steam_Masterserver_Updater::RemoveMasterServer pServerAddress IP: %d, PORT: %d", addr.ip, addr.port);
|
||||
|
||||
iter = this->settings->custom_master_server.begin();
|
||||
while (iter != this->settings->custom_master_server.end())
|
||||
{
|
||||
list = (*iter);
|
||||
if (addr.ip == list.ip &&
|
||||
(addr.port == list.port || (list.port == 0 && addr.port == 27016)))
|
||||
{
|
||||
iter = this->settings->custom_master_server.erase(iter);
|
||||
}
|
||||
else
|
||||
{
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -186,7 +238,7 @@ bool RemoveMasterServer( const char *pServerAddress )
|
||||
int GetNumMasterServers()
|
||||
{
|
||||
PRINT_DEBUG("Steam_Masterserver_Updater::GetNumMasterServers\n");
|
||||
return 0;
|
||||
return this->settings->custom_master_server.size();
|
||||
}
|
||||
|
||||
|
||||
@ -194,7 +246,38 @@ int GetNumMasterServers()
|
||||
int GetMasterServerAddress( int iServer, char *pOut, int outBufferSize )
|
||||
{
|
||||
PRINT_DEBUG("Steam_Masterserver_Updater::GetMasterServerAddress\n");
|
||||
return 0;
|
||||
|
||||
size_t written_bytes = 0;
|
||||
char * byte_cpy = NULL;
|
||||
std::set<IP_PORT>::iterator iter;
|
||||
IP_PORT addr;
|
||||
|
||||
if (pOut && outBufferSize >= sizeof(uint32) && this->settings->custom_master_server.size() > 0)
|
||||
{
|
||||
iter = this->settings->custom_master_server.begin();
|
||||
while (written_bytes < outBufferSize && iter != this->settings->custom_master_server.end())
|
||||
{
|
||||
addr = (*iter);
|
||||
byte_cpy = (char*)&(addr.ip);
|
||||
for (size_t x = 0; x < sizeof(addr.ip) && written_bytes < outBufferSize; x++)
|
||||
{
|
||||
memcpy(pOut + x, byte_cpy + x, 1);
|
||||
written_bytes++;
|
||||
}
|
||||
if (addr.port != 0 && addr.port != 27016) // Default updater port.
|
||||
{
|
||||
byte_cpy = (char*)&(addr.port);
|
||||
for (size_t x = 0; x < sizeof(addr.port) && written_bytes < outBufferSize; x++)
|
||||
{
|
||||
memcpy(pOut + x, byte_cpy + x, 1);
|
||||
written_bytes++;
|
||||
}
|
||||
}
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
|
||||
return written_bytes;
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,2 @@
|
||||
192.168.7.99
|
||||
removethis.test.domain.com
|
Loading…
x
Reference in New Issue
Block a user