You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openmw-tes3mp/apps/openmw-mp/Script/Functions/Miscellaneous.hpp

54 lines
1.8 KiB
C++

#ifndef OPENMW_MISCELLANEOUSAPI_HPP
#define OPENMW_MISCELLANEOUSAPI_HPP
#include "../Types.hpp"
#define MISCELLANEOUSAPI \
{"GetLastPlayerId", MiscellaneousFunctions::GetLastPlayerId},\
\
{"GetCurrentMpNum", MiscellaneousFunctions::GetCurrentMpNum},\
{"SetCurrentMpNum", MiscellaneousFunctions::SetCurrentMpNum}
class MiscellaneousFunctions
{
public:
/**
* \brief Get the last player ID currently connected to the server.
*
* Every player receives a unique numerical index known as their player ID upon joining the
* server.
*
* \return The player ID.
*/
static unsigned int GetLastPlayerId() noexcept;
/**
* \brief Get the current (latest) mpNum generated by the server.
*
* Every object that did not exist in an .ESM or .ESP data file and has instead been placed or
* spawned through a server-sent packet has a numerical index known as its mpNum.
*
* When ObjectPlace and ObjectSpawn packets are received from players, their objects lack mpNums,
* so the server assigns them some based on incrementing the server's current mpNum, with the
* operation's final mpNum becoming the server's new current mpNum.
*
* \return The mpNum.
*/
static int GetCurrentMpNum() noexcept;
/**
* \brief Set the current (latest) mpNum generated by the server.
*
* When restarting a server, it is important to revert to the previous current (latest) mpNum
* as stored in the server's data, so as to avoid starting over from 0 and ending up assigning
* duplicate mpNums to objects.
*
* \param mpNum The number that should be used as the new current mpNum.
* \return void
*/
static void SetCurrentMpNum(int mpNum) noexcept;
};
#endif //OPENMW_MISCELLANEOUSAPI_HPP