Worldstate functions

class WorldstateFunctions

Public Static Functions

void ReadReceivedWorldstate()

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

Return
void

void CopyReceivedWorldstateToStore()

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.

Return
void

void ClearMapChanges()

Clear the map changes for the write-only worldstate.

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

Return
void

unsigned int GetMapChangesSize()

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

Return
The number of indexes.

const char *GetWeatherRegion()

Get the weather region in the read worldstate.

Return
The weather region.

int GetWeatherCurrent()

Get the current weather in the read worldstate.

Return
The current weather.

int GetWeatherNext()

Get the next weather in the read worldstate.

Return
The next weather.

int GetWeatherQueued()

Get the queued weather in the read worldstate.

Return
The queued weather.

double GetWeatherTransitionFactor()

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

Return
The transition factor of the weather.

int GetMapTileCellX(unsigned int index)

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

Return
The X coordinate of the cell.
Parameters
  • index: The index of the map tile.

int GetMapTileCellY(unsigned int index)

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

Return
The Y coordinate of the cell.
Parameters
  • index: The index of the map tile.

void SetAuthorityRegion(const char *authorityRegion)

Set the region affected by the next WorldRegionAuthority packet sent.

Return
void
Parameters
  • region: The region.

void SetWeatherRegion(const char *region)

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

Return
void
Parameters
  • region: The region.

void SetWeatherForceState(bool forceState)

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.

Return
void
Parameters
  • forceState: The weather forcing state.

void SetWeatherCurrent(int currentWeather)

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

Return
void
Parameters
  • currentWeather: The current weather.

void SetWeatherNext(int nextWeather)

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

Return
void
Parameters
  • nextWeather: The next weather.

void SetWeatherQueued(int queuedWeather)

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

Return
void
Parameters
  • queuedWeather: The queued weather.

void SetWeatherTransitionFactor(double transitionFactor)

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

Return
void
Parameters
  • transitionFactor: The transition factor.

void SetHour(double hour)

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

Return
void
Parameters
  • hour: The hour.

void SetDay(int day)

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

Return
void
Parameters
  • day: The day.

void SetMonth(int month)

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

Return
void
Parameters
  • month: The month.

void SetYear(int year)

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

Return
void
Parameters
  • year: The year.

void SetDaysPassed(int daysPassed)

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

Return
void
Parameters
  • daysPassed: The days passed.

void SetTimeScale(double timeScale)

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

Return
void
Parameters
  • pid: The player ID.
  • timeScale: The time scale.

void SetPlayerCollisionState(bool state)

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

Return
void
Parameters
  • state: The collision state.

void SetActorCollisionState(bool state)

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

Return
void
Parameters
  • state: The collision state.

void SetPlacedObjectCollisionState(bool state)

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

Return
void
Parameters
  • state: The collision state.

void UseActorCollisionForPlacedObjects(bool useActorCollision)

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.

Return
void
Parameters
  • useActorCollision: Whether to use actor collision.

void AddEnforcedCollisionRefId(const char *refId)

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

Return
void
Parameters
  • refId: The refId.

void ClearEnforcedCollisionRefIds()

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

Return
void

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

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

Return
void
Parameters
  • index: The index of the map tile.
  • filePath: The file path of the resulting file.

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

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

Return
void
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.

void SendWorldRegionAuthority(unsigned short pid)

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.

Return
void
Parameters
  • pid: The player ID attached to the packet.

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

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

Return
void
Parameters
  • pid: The player ID attached to the packet.
  • broadcast: Whether this packet should be sent only to the attached player or to all players on the server.

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

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

Return
void
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).

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

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

Return
void
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).

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

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

Return
void
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).