mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-04-01 11:06:41 +00:00
[Server] Add GetMaxPlayers, GetPort and HasPassword functions to API
This commit is contained in:
parent
3bd8aa82fe
commit
48f4792bc1
4 changed files with 45 additions and 0 deletions
|
@ -578,6 +578,11 @@ int Networking::getAvgPing(RakNet::AddressOrGUID addr) const
|
||||||
return peer->GetAveragePing(addr);
|
return peer->GetAveragePing(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned short Networking::getPort() const
|
||||||
|
{
|
||||||
|
return peer->GetMyBoundAddress().GetPort();
|
||||||
|
}
|
||||||
|
|
||||||
MasterClient *Networking::getMasterClient()
|
MasterClient *Networking::getMasterClient()
|
||||||
{
|
{
|
||||||
return mclient;
|
return mclient;
|
||||||
|
|
|
@ -34,6 +34,7 @@ namespace mwmp
|
||||||
unsigned short numberOfConnections() const;
|
unsigned short numberOfConnections() const;
|
||||||
unsigned int maxConnections() const;
|
unsigned int maxConnections() const;
|
||||||
int getAvgPing(RakNet::AddressOrGUID) const;
|
int getAvgPing(RakNet::AddressOrGUID) const;
|
||||||
|
unsigned short getPort() const;
|
||||||
|
|
||||||
int mainLoop();
|
int mainLoop();
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,21 @@ const char *ServerFunctions::GetIP(unsigned short pid) noexcept
|
||||||
return addr.ToString(false);
|
return addr.ToString(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned short ServerFunctions::GetPort() noexcept
|
||||||
|
{
|
||||||
|
return mwmp::Networking::get().getPort();
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int ServerFunctions::GetMaxPlayers() noexcept
|
||||||
|
{
|
||||||
|
return mwmp::Networking::get().maxConnections();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ServerFunctions::HasPassword() noexcept
|
||||||
|
{
|
||||||
|
return mwmp::Networking::get().isPassworded();
|
||||||
|
}
|
||||||
|
|
||||||
void ServerFunctions::SetGameMode(const char *gameMode) noexcept
|
void ServerFunctions::SetGameMode(const char *gameMode) noexcept
|
||||||
{
|
{
|
||||||
if (mwmp::Networking::getPtr()->getMasterClient())
|
if (mwmp::Networking::getPtr()->getMasterClient())
|
||||||
|
|
|
@ -14,6 +14,9 @@
|
||||||
{"GetProtocolVersion", ServerFunctions::GetProtocolVersion},\
|
{"GetProtocolVersion", ServerFunctions::GetProtocolVersion},\
|
||||||
{"GetAvgPing", ServerFunctions::GetAvgPing},\
|
{"GetAvgPing", ServerFunctions::GetAvgPing},\
|
||||||
{"GetIP", ServerFunctions::GetIP},\
|
{"GetIP", ServerFunctions::GetIP},\
|
||||||
|
{"GetMaxPlayers", ServerFunctions::GetMaxPlayers},\
|
||||||
|
{"GetPort", ServerFunctions::GetPort},\
|
||||||
|
{"HasPassword", ServerFunctions::HasPassword},\
|
||||||
\
|
\
|
||||||
{"SetGameMode", ServerFunctions::SetGameMode},\
|
{"SetGameMode", ServerFunctions::SetGameMode},\
|
||||||
{"SetHostname", ServerFunctions::SetHostname},\
|
{"SetHostname", ServerFunctions::SetHostname},\
|
||||||
|
@ -87,6 +90,27 @@ public:
|
||||||
*/
|
*/
|
||||||
static const char* GetIP(unsigned short pid) noexcept;
|
static const char* GetIP(unsigned short pid) noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Get the port used by the server.
|
||||||
|
*
|
||||||
|
* \return Port
|
||||||
|
*/
|
||||||
|
static unsigned short GetPort() noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Get the maximum number of players.
|
||||||
|
*
|
||||||
|
* \return Max players
|
||||||
|
*/
|
||||||
|
static unsigned int GetMaxPlayers() noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Checking if the server requires a password to connect.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
static bool HasPassword() noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set the game mode of the server, as displayed in the server browser.
|
* \brief Set the game mode of the server, as displayed in the server browser.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue