1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-28 10:09:40 +00:00

[Server] Implement GetIP API function

This commit is contained in:
Koncord 2017-07-04 15:57:16 +08:00
parent 1f3cbb46e2
commit 940ae5c2fb
4 changed files with 16 additions and 0 deletions

View file

@ -376,6 +376,11 @@ Networking *Networking::getPtr()
return sThis;
}
RakNet::SystemAddress Networking::getSystemAddress(RakNet::RakNetGUID guid)
{
return peer->GetSystemAddressFromGuid(guid);
}
PacketPreInit::PluginContainer Networking::getPluginListSample()
{
PacketPreInit::PluginContainer pls;

View file

@ -23,6 +23,7 @@ namespace mwmp
void newPlayer(RakNet::RakNetGUID guid);
void disconnectPlayer(RakNet::RakNetGUID guid);
void kickPlayer(RakNet::RakNetGUID guid);
RakNet::SystemAddress getSystemAddress(RakNet::RakNetGUID guid);
void processPlayerPacket(RakNet::Packet *packet);
void processActorPacket(RakNet::Packet *packet);

View file

@ -154,3 +154,11 @@ void ScriptFunctions::SetRuleValue(const char *key, double value) noexcept
if (mc)
mc->SetRuleValue(key, value);
}
const char *ScriptFunctions::GetIP(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, "");
RakNet::SystemAddress addr = mwmp::Networking::getPtr()->getSystemAddress(player->guid);
return addr.ToString(false);
}

View file

@ -69,6 +69,7 @@ public:
static void FreeTimer(int timerId) noexcept;
static bool IsTimerElapsed(int timerId) noexcept;
static const char* GetIP(unsigned short pid) noexcept;
static void Kick(unsigned short pid) noexcept;
static const char *GetServerVersion() noexcept;
static const char *GetProtocolVersion() noexcept;
@ -105,6 +106,7 @@ public:
{"SetRuleValue", ScriptFunctions::SetRuleValue},
{"CleanChatByPid", ScriptFunctions::CleanChatByPid},
{"CleanChat", ScriptFunctions::CleanChat},
{"GetIP", ScriptFunctions::GetIP},
ACTORAPI,
BOOKAPI,