Worldstate functions

class WorldstateFunctions

Public Static Functions

static void ReadReceivedWorldstate() noexcept

Use the last worldstate received by the server as the one being read.

Returns

void

static void CopyReceivedWorldstateToStore() noexcept

Take the contents of the read-only worldstate last received by the server from a player and move its contents to the stored worldstate that can be sent by the server.

Returns

void

static void ClearKillChanges() noexcept

Clear the kill count changes for the write-only worldstate.

This is used to initialize the sending of new WorldKillCount packets.

Returns

void

static void ClearMapChanges() noexcept

Clear the map changes for the write-only worldstate.

This is used to initialize the sending of new WorldMap packets.

Returns

void

static void ClearClientGlobals() noexcept

Clear the client globals for the write-only worldstate.

This is used to initialize the sending of new ClientScriptGlobal packets.

Returns

void

static unsigned int GetKillChangesSize() noexcept

Get the number of indexes in the read worldstate’s kill changes.

Returns

The number of indexes.

static unsigned int GetMapChangesSize() noexcept

Get the number of indexes in the read worldstate’s map changes.

Returns

The number of indexes.

static unsigned int GetClientGlobalsSize() noexcept

Get the number of indexes in the read worldstate’s client globals.

Returns

The number of indexes.

static const char *GetKillRefId(unsigned int index) noexcept

Get the refId at a certain index in the read worldstate’s kill count changes.

Parameters

index – The index of the kill count.

Returns

The refId.

static int GetKillNumber(unsigned int index) noexcept

Get the number of kills at a certain index in the read worldstate’s kill count changes.

Parameters

index – The index of the kill count.

Returns

The number of kills.

static const char *GetWeatherRegion() noexcept

Get the weather region in the read worldstate.

Returns

The weather region.

static int GetWeatherCurrent() noexcept

Get the current weather in the read worldstate.

Returns

The current weather.

static int GetWeatherNext() noexcept

Get the next weather in the read worldstate.

Returns

The next weather.

static int GetWeatherQueued() noexcept

Get the queued weather in the read worldstate.

Returns

The queued weather.

static double GetWeatherTransitionFactor() noexcept

Get the transition factor of the weather in the read worldstate.

Returns

The transition factor of the weather.

static int GetMapTileCellX(unsigned int index) noexcept

Get the X coordinate of the cell corresponding to the map tile at a certain index in the read worldstate’s map tiles.

Parameters

index – The index of the map tile.

Returns

The X coordinate of the cell.

static int GetMapTileCellY(unsigned int index) noexcept

Get the Y coordinate of the cell corresponding to the map tile at a certain index in the read worldstate’s map tiles.

Parameters

index – The index of the map tile.

Returns

The Y coordinate of the cell.

static const char *GetClientGlobalId(unsigned int index) noexcept

Get the id of the global variable at a certain index in the read worldstate’s client globals.

Parameters

index – The index of the client global.

Returns

The id.

static unsigned short GetClientGlobalVariableType(unsigned int index) noexcept

Get the type of the global variable at a certain index in the read worldstate’s client globals.

Parameters

index – The index of the client global.

Returns

The variable type (0 for INTEGER, 1 for LONG, 2 for FLOAT).

static int GetClientGlobalIntValue(unsigned int index) noexcept

Get the integer value of the global variable at a certain index in the read worldstate’s client globals.

Parameters

index – The index of the client global.

Returns

The integer value.

static double GetClientGlobalFloatValue(unsigned int index) noexcept

Get the float value of the global variable at a certain index in the read worldstate’s client globals.

Parameters

index – The index of the client global.

Returns

The float value.

static void SetAuthorityRegion(const char *authorityRegion) noexcept

Set the region affected by the next WorldRegionAuthority packet sent.

Parameters

authorityRegion – The region.

Returns

void

static void SetWeatherRegion(const char *region) noexcept

Set the weather region in the write-only worldstate stored on the server.

Parameters

region – The region.

Returns

void

static void SetWeatherForceState(bool forceState) noexcept

Set the weather forcing state in the write-only worldstate stored on the server.

Players who receive a packet with forced weather will switch to that weather immediately.

Parameters

forceState – The weather forcing state.

Returns

void

static void SetWeatherCurrent(int currentWeather) noexcept

Set the current weather in the write-only worldstate stored on the server.

Parameters

currentWeather – The current weather.

Returns

void

static void SetWeatherNext(int nextWeather) noexcept

Set the next weather in the write-only worldstate stored on the server.

Parameters

nextWeather – The next weather.

Returns

void

static void SetWeatherQueued(int queuedWeather) noexcept

Set the queued weather in the write-only worldstate stored on the server.

Parameters

queuedWeather – The queued weather.

Returns

void

static void SetWeatherTransitionFactor(double transitionFactor) noexcept

Set the transition factor for the weather in the write-only worldstate stored on the server.

Parameters

transitionFactor – The transition factor.

Returns

void

static void SetHour(double hour) noexcept

Set the world’s hour in the write-only worldstate stored on the server.

Parameters

hour – The hour.

Returns

void

static void SetDay(int day) noexcept

Set the world’s day in the write-only worldstate stored on the server.

Parameters

day – The day.

Returns

void

static void SetMonth(int month) noexcept

Set the world’s month in the write-only worldstate stored on the server.

Parameters

month – The month.

Returns

void

static void SetYear(int year) noexcept

Set the world’s year in the write-only worldstate stored on the server.

Parameters

year – The year.

Returns

void

static void SetDaysPassed(int daysPassed) noexcept

Set the world’s days passed in the write-only worldstate stored on the server.

Parameters

daysPassed – The days passed.

Returns

void

static void SetTimeScale(double timeScale) noexcept

Set the world’s time scale in the write-only worldstate stored on the server.

Parameters

timeScale – The time scale.

Returns

void

static void SetPlayerCollisionState(bool state) noexcept

Set the collision state for other players in the write-only worldstate stored on the server.

Parameters

state – The collision state.

Returns

void

static void SetActorCollisionState(bool state) noexcept

Set the collision state for actors in the write-only worldstate stored on the server.

Parameters

state – The collision state.

Returns

void

static void SetPlacedObjectCollisionState(bool state) noexcept

Set the collision state for placed objects in the write-only worldstate stored on the server.

Parameters

state – The collision state.

Returns

void

static void UseActorCollisionForPlacedObjects(bool useActorCollision) noexcept

Whether placed objects with collision turned on should use actor collision, i.e. whether they should be slippery and prevent players from standing on them.

Parameters

useActorCollision – Whether to use actor collision.

Returns

void

static void AddKill(const char *refId, int number) noexcept

Add a new kill count to the kill count changes.

Parameters
  • refId – The refId of the kill count.

  • number – The number of kills in the kill count.

Returns

void

static void AddClientGlobalInteger(const char *id, int intValue, unsigned int variableType = 0) noexcept

Add a new client global integer to the client globals.

Parameters
  • id – The id of the client global.

  • variableType – The variable type (0 for SHORT, 1 for LONG).

  • intValue – The integer value of the client global.

Returns

void

static void AddClientGlobalFloat(const char *id, double floatValue) noexcept

Add a new client global float to the client globals.

Parameters
  • id – The id of the client global.

  • floatValue – The float value of the client global.

Returns

void

static void AddSynchronizedClientScriptId(const char *scriptId) noexcept

Add an ID to the list of script IDs whose variable changes should be sent to the the server by clients.

Parameters

scriptId – The ID.

Returns

void

static void AddSynchronizedClientGlobalId(const char *globalId) noexcept

Add an ID to the list of global IDs whose value changes should be sent to the server by clients.

Parameters

globalId – The ID.

Returns

void

static void AddEnforcedCollisionRefId(const char *refId) noexcept

Add a refId to the list of refIds for which collision should be enforced irrespective of other settings.

Parameters

refId – The refId.

Returns

void

static void AddCellToReset(const char *cellDescription) noexcept

Add a cell with given cellDescription to the list of cells that should be reset on the client.

Returns

void

static void AddDestinationOverride(const char *oldCellDescription, const char *newCellDescription) noexcept

Add a destination override containing the cell description for the old cell and the new cell.

Parameters
  • oldCellDescription – The old cell description.

  • newCellDescription – The new cell description.

Returns

void

static void ClearSynchronizedClientScriptIds() noexcept

Clear the list of script IDs whose variable changes should be sent to the the server by clients.

Returns

void

static void ClearSynchronizedClientGlobalIds() noexcept

Clear the list of global IDs whose value changes should be sent to the the server by clients.

Returns

void

static void ClearEnforcedCollisionRefIds() noexcept

Clear the list of refIds for which collision should be enforced irrespective of other settings.

Returns

void

static void ClearCellsToReset() noexcept

Clear the list of cells which should be reset on the client.

Returns

void

static void ClearDestinationOverrides() noexcept

Clear the list of destination overrides.

Returns

void

static void SaveMapTileImageFile(unsigned int index, const char *filePath) noexcept

Save the .png image data of the map tile at a certain index in the read worldstate’s map changes.

Parameters
  • index – The index of the map tile.

  • filePath – The file path of the resulting file.

Returns

void

static void LoadMapTileImageFile(int cellX, int cellY, const char *filePath) noexcept

Load a .png file as the image data for a map tile and add it to the write-only worldstate stored on the server.

Parameters
  • cellX – The X coordinate of the cell corresponding to the map tile.

  • cellY – The Y coordinate of the cell corresponding to the map tile.

  • filePath – The file path of the loaded file.

Returns

void

static void SendClientScriptGlobal(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept

Send a ClientScriptGlobal packet with the current client script globals in the write-only worldstate.

Parameters
  • pid – The player ID attached to the packet.

  • sendToOtherPlayers – Whether this packet should be sent to players other than the player attached to the packet (false by default).

  • skipAttachedPlayer – Whether the packet should skip being sent to the player attached to the packet (false by default).

Returns

void

static void SendClientScriptSettings(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept

Send a ClientScriptSettings packet with the current client script settings in the write-only worldstate.

Parameters
  • pid – The player ID attached to the packet.

  • sendToOtherPlayers – Whether this packet should be sent to players other than the player attached to the packet (false by default).

  • skipAttachedPlayer – Whether the packet should skip being sent to the player attached to the packet (false by default).

Returns

void

static void SendWorldKillCount(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept

Send a WorldKillCount packet with the current set of kill count changes in the write-only worldstate.

Parameters
  • pid – The player ID attached to the packet.

  • sendToOtherPlayers – Whether this packet should be sent to players other than the player attached to the packet (false by default).

  • skipAttachedPlayer – Whether the packet should skip being sent to the player attached to the packet (false by default).

Returns

void

static void SendWorldRegionAuthority(unsigned short pid) noexcept

Send a WorldRegionAuthority packet establishing a certain player as the only one who should process certain region-specific events (such as weather changes).

It is always sent to all players.

Parameters

pid – The player ID attached to the packet.

Returns

void

static void SendWorldMap(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept

Send a WorldMap packet with the current set of map changes in the write-only worldstate.

Parameters
  • pid – The player ID attached to the packet.

  • sendToOtherPlayers – Whether this packet should be sent to players other than the player attached to the packet (false by default).

  • skipAttachedPlayer – Whether the packet should skip being sent to the player attached to the packet (false by default).

Returns

void

static void SendWorldTime(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept

Send a WorldTime packet with the current time and time scale in the write-only worldstate.

Parameters
  • pid – The player ID attached to the packet.

  • sendToOtherPlayers – Whether this packet should be sent to players other than the player attached to the packet (false by default).

  • skipAttachedPlayer – Whether the packet should skip being sent to the player attached to the packet (false by default).

Returns

void

static void SendWorldWeather(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept

Send a WorldWeather packet with the current weather in the write-only worldstate.

Parameters
  • pid – The player ID attached to the packet.

  • sendToOtherPlayers – Whether this packet should be sent to players other than the player attached to the packet (false by default).

  • skipAttachedPlayer – Whether the packet should skip being sent to the player attached to the packet (false by default).

Returns

void

static void SendWorldCollisionOverride(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept

Send a WorldCollisionOverride packet with the current collision overrides in the write-only worldstate.

Parameters
  • pid – The player ID attached to the packet.

  • sendToOtherPlayers – Whether this packet should be sent to players other than the player attached to the packet (false by default).

  • skipAttachedPlayer – Whether the packet should skip being sent to the player attached to the packet (false by default).

Returns

void

static void SendCellReset(unsigned short pid, bool sendToOtherPlayers) noexcept

Send a CellReset packet with a list of cells,.

Parameters

pid – The player ID attached to the packet.

Returns

void

static void SendWorldDestinationOverride(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept

Send a WorldDestinationOverride packet with the current destination overrides in the write-only worldstate.

Parameters
  • pid – The player ID attached to the packet.

  • sendToOtherPlayers – Whether this packet should be sent to players other than the player attached to the packet (false by default).

  • skipAttachedPlayer – Whether the packet should skip being sent to the player attached to the packet (false by default).

Returns

void