diff --git a/apps/openmw-mp/CMakeLists.txt b/apps/openmw-mp/CMakeLists.txt index abb770efb..0651ba6e6 100644 --- a/apps/openmw-mp/CMakeLists.txt +++ b/apps/openmw-mp/CMakeLists.txt @@ -77,7 +77,7 @@ set(SERVER Script/Functions/CharClass.cpp Script/Functions/Chat.cpp Script/Functions/GUI.cpp Script/Functions/Items.cpp Script/Functions/Quests.cpp Script/Functions/Stats.cpp Script/Functions/Spells.cpp Script/Functions/Timer.cpp Script/Functions/Positions.cpp - Script/Functions/Cells.cpp Script/Functions/World.cpp + Script/Functions/Cells.cpp Script/Functions/World.cpp Script/Functions/Miscellaneous.cpp Script/API/TimerAPI.cpp Script/API/PublicFnAPI.cpp ${PawnScript_Sources} diff --git a/apps/openmw-mp/Player.cpp b/apps/openmw-mp/Player.cpp index db3e7b760..edf974873 100644 --- a/apps/openmw-mp/Player.cpp +++ b/apps/openmw-mp/Player.cpp @@ -64,6 +64,11 @@ TPlayers *Players::getPlayers() return &players; } +unsigned short Players::getLastPlayerId() +{ + return slots.rbegin()->first; +} + Player::Player(RakNet::RakNetGUID guid) : BasePlayer(guid) { handshakeState = false; diff --git a/apps/openmw-mp/Player.hpp b/apps/openmw-mp/Player.hpp index cf83b9688..208abc99b 100644 --- a/apps/openmw-mp/Player.hpp +++ b/apps/openmw-mp/Player.hpp @@ -32,6 +32,7 @@ public: static Player *getPlayer(RakNet::RakNetGUID guid); static Player *getPlayer(unsigned short id); static TPlayers *getPlayers(); + static unsigned short getLastPlayerId(); private: static TPlayers players; diff --git a/apps/openmw-mp/Script/Functions/Miscellaneous.cpp b/apps/openmw-mp/Script/Functions/Miscellaneous.cpp new file mode 100644 index 000000000..7dfcaf48d --- /dev/null +++ b/apps/openmw-mp/Script/Functions/Miscellaneous.cpp @@ -0,0 +1,11 @@ +#include "Miscellaneous.hpp" +#include +#include + +#include +using namespace std; + +unsigned int MiscellaneousFunctions::GetLastPlayerId() noexcept +{ + return Players::getLastPlayerId(); +} diff --git a/apps/openmw-mp/Script/Functions/Miscellaneous.hpp b/apps/openmw-mp/Script/Functions/Miscellaneous.hpp new file mode 100644 index 000000000..c9509713c --- /dev/null +++ b/apps/openmw-mp/Script/Functions/Miscellaneous.hpp @@ -0,0 +1,16 @@ +#ifndef OPENMW_MISCELLANEOUSAPI_HPP +#define OPENMW_MISCELLANEOUSAPI_HPP + +#include "../Types.hpp" + +#define MISCELLANEOUSAPI \ + {"GetLastPlayerId", MiscellaneousFunctions::GetLastPlayerId} + + +class MiscellaneousFunctions +{ +public: + static unsigned int GetLastPlayerId() noexcept; +}; + +#endif //OPENMW_MISCELLANEOUSAPI_HPP diff --git a/apps/openmw-mp/Script/ScriptFunctions.hpp b/apps/openmw-mp/Script/ScriptFunctions.hpp index 9d8817597..684612cda 100644 --- a/apps/openmw-mp/Script/ScriptFunctions.hpp +++ b/apps/openmw-mp/Script/ScriptFunctions.hpp @@ -14,6 +14,7 @@ #include