Public Types | Static Public Member Functions

ScriptSign Class Reference

Class that handles all sign related functions. More...

#include <script_sign.hpp>

Inheritance diagram for ScriptSign:
ScriptObject SimpleCountedObject

Public Types

enum  ErrorMessages { ERR_SIGN_BASE = ScriptError::ERR_CAT_SIGN << ScriptError::ERR_CAT_BIT_SIZE, ERR_SIGN_TOO_MANY_SIGNS }
 

All sign related error messages.

More...

Static Public Member Functions

static bool IsValidSign (SignID sign_id)
 Checks whether the given sign index is valid.
static bool SetName (SignID sign_id, const char *name)
 Set the name of a sign.
static char * GetName (SignID sign_id)
 Get the name of the sign.
static TileIndex GetLocation (SignID sign_id)
 Gets the location of the sign.
static SignID BuildSign (TileIndex location, const char *text)
 Builds a sign on the map.
static bool RemoveSign (SignID sign_id)
 Removes a sign from the map.

Detailed Description

Class that handles all sign related functions.

ai

Definition at line 21 of file script_sign.hpp.


Member Enumeration Documentation

All sign related error messages.

Enumerator:
ERR_SIGN_BASE 

Base for sign building related errors.

ERR_SIGN_TOO_MANY_SIGNS 

Too many signs have been placed.

Definition at line 26 of file script_sign.hpp.


Member Function Documentation

SignID ScriptSign::BuildSign ( TileIndex  location,
const char *  text 
) [static]

Builds a sign on the map.

Parameters:
location The place to build the sign.
text The text to place on the sign.
Precondition:
ScriptMap::IsValidTile(location).
'text' must have at least one character.
'text' must have at most 30 characters.
Exceptions:
ScriptSign::ERR_SIGN_TOO_MANY_SIGNS 
Returns:
The SignID of the build sign (use IsValidSign() to check for validity). In test-mode it returns 0 if successful, or any other value to indicate failure.

Definition at line 66 of file script_sign.cpp.

References CMD_PLACE_SIGN, ScriptObject::DoCommand(), ScriptInstance::DoCommandReturnSignID(), EnforcePrecondition, EnforcePreconditionCustomError, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG, INVALID_SIGN, IsValidTile(), MAX_LENGTH_SIGN_NAME_CHARS, StrEmpty(), and Utf8StringLength().

TileIndex ScriptSign::GetLocation ( SignID  sign_id  )  [static]

Gets the location of the sign.

Parameters:
sign_id The sign to get the location of.
Precondition:
IsValidSign(sign_id).
Returns:
The location of the sign.

Definition at line 52 of file script_sign.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_sign_pool >::Get(), INVALID_TILE, IsValidSign(), and TileVirtXY().

char * ScriptSign::GetName ( SignID  sign_id  )  [static]

Get the name of the sign.

Parameters:
sign_id The sign to get the name of.
Precondition:
IsValidSign(sign_id).
Returns:
The name of the sign.

Definition at line 39 of file script_sign.cpp.

References IsValidSign(), and SetDParam().

bool ScriptSign::IsValidSign ( SignID  sign_id  )  [static]

Checks whether the given sign index is valid.

Parameters:
sign_id The index to check.
Returns:
True if and only if the sign is valid.

Definition at line 24 of file script_sign.cpp.

References _current_company, and Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_sign_pool >::GetIfValid().

Referenced by GetLocation(), GetName(), RemoveSign(), and SetName().

bool ScriptSign::RemoveSign ( SignID  sign_id  )  [static]

Removes a sign from the map.

Parameters:
sign_id The sign to remove.
Precondition:
IsValidSign(sign_id).
Returns:
True if and only if the sign has been removed.

Definition at line 60 of file script_sign.cpp.

References CMD_RENAME_SIGN, ScriptObject::DoCommand(), EnforcePrecondition, and IsValidSign().

bool ScriptSign::SetName ( SignID  sign_id,
const char *  name 
) [static]

Set the name of a sign.

Parameters:
sign_id The sign to set the name for.
name The name for the sign.
Precondition:
IsValidSign(sign_id).
'name' must have at least one character.
'name' must have at most 30 characters.
Exceptions:
ScriptError::ERR_NAME_IS_NOT_UNIQUE 
Returns:
True if and only if the name was changed.

Definition at line 30 of file script_sign.cpp.

References CMD_RENAME_SIGN, ScriptObject::DoCommand(), EnforcePrecondition, EnforcePreconditionCustomError, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG, IsValidSign(), MAX_LENGTH_SIGN_NAME_CHARS, StrEmpty(), and Utf8StringLength().


The documentation for this class was generated from the following files: