Miscellaneous functions

class MiscellaneousFunctions

Public Static Functions

static const char *GenerateRandomString(unsigned int length) noexcept

Generate a random string of a particular length that only contains letters and numbers.

Parameters

length – The length of the generated string.

Returns

The generated string.

static const char *GetSHA256Hash(const char *inputString) noexcept

Get the SHA256 hash corresponding to an input string.

function is not reentrant due to a static variable

Parameters

inputString – The input string.

Returns

The SHA256 hash.

static unsigned int GetLastPlayerId() noexcept

Get the last player ID currently connected to the server.

function is not reentrant due to a static variable

Every player receives a unique numerical index known as their player ID upon joining the server.

Returns

The player ID.

static int GetCurrentMpNum() noexcept

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.

Returns

The mpNum.

static void SetCurrentMpNum(int mpNum) noexcept

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.

Parameters

mpNum – The number that should be used as the new current mpNum.

Returns

void