# signs.cpp File Reference

`#include "stdafx.h"`
`#include "openttd.h"`
`#include "landscape.h"`
`#include "player_func.h"`
`#include "signs.h"`
`#include "saveload.h"`
`#include "command_func.h"`
`#include "variables.h"`
`#include "strings_func.h"`
`#include "viewport_func.h"`
`#include "zoom_func.h"`
`#include "functions.h"`
`#include "window_func.h"`
`#include "map_func.h"`
`#include "string_func.h"`
`#include "table/strings.h"`

Go to the source code of this file.

## Functions

static void | UpdateSignVirtCoords (Sign *si)
| Update the coordinate of one sign.
void | UpdateAllSignVirtCoords ()
| Update the coordinates of all signs.
static void | MarkSignDirty (Sign *si)
| Marks the region of a sign as dirty.
CommandCost | CmdPlaceSign (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Place a sign at the given coordinates.
CommandCost | CmdRenameSign (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Rename a sign.
void | CcPlaceSign (bool success, TileIndex tile, uint32 p1, uint32 p2)
| Callback function that is called after a sign is placed.
void | PlaceProc_Sign (TileIndex tile)
| PlaceProc function, called when someone pressed the button if the sign-tool is selected.
void | InitializeSigns ()
| Initialize the signs.
static void | Save_SIGN ()
| Save all signs.
static void | Load_SIGN ()
| Load all signs.

## Variables

SignID | _new_sign_id
uint | _total_signs
bool | _sign_sort_dirty
static const SaveLoad | _sign_desc []
const ChunkHandler | _sign_chunk_handlers []

## Detailed Description

Definition in file signs.cpp.

## Function Documentation

void CcPlaceSign | ( | bool | success,
|  | TileIndex | tile,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Callback function that is called after a sign is placed.

Parameters:

  | success | of the operation
  | tile | unused
  | p1 | unused
  | p2 | unused

Definition at line 180 of file signs.cpp.

Referenced by PlaceProc_Sign().

CommandCost CmdPlaceSign | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Place a sign at the given coordinates.

Ownership of sign has no effect whatsoever except for the colour the sign gets for easy recognition, but everybody is able to rename/remove it.

Parameters:

  | tile | tile to place sign at
  | flags | type of operation
  | p1 | unused
  | p2 | unused

Definition at line 100 of file signs.cpp.

References DC_EXEC, MarkSignDirty(), return_cmd_error, TILE_SIZE, TileX(), TileY(), and UpdateSignVirtCoords().

CommandCost CmdRenameSign | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Rename a sign.

If the new name of the sign is empty, we assume the user wanted to delete it. So delete it. Ownership of signs has no meaning/effect whatsoever except for eyecandy

Parameters:

  | tile | unused
  | flags | type of operation
  | p1 | index of the sign to be renamed/removed
  | p2 | unused

Returns:
  0 if succesfull, otherwise CMD_ERROR

Definition at line 134 of file signs.cpp.

References _cmd_text, CMD_ERROR, DC_EXEC, MarkSignDirty(), and UpdateSignVirtCoords().

void InitializeSigns | ( |  | ) |

Initialize the signs.

Definition at line 204 of file signs.cpp.

static void Load_SIGN | ( |  | ) | `[static]`

Load all signs.

Definition at line 243 of file signs.cpp.

References SlIterateArray(), and SlObject().

void PlaceProc_Sign | ( | TileIndex | tile | ) |

PlaceProc function, called when someone pressed the button if the sign-tool is selected.

Parameters:

  | tile | on which to place the sign

Definition at line 194 of file signs.cpp.

References CcPlaceSign(), CMD_MSG, CMD_PLACE_SIGN, and DoCommandP().

static void Save_SIGN | ( |  | ) | `[static]`

Save all signs.

Definition at line 228 of file signs.cpp.

References SlObject().

void UpdateAllSignVirtCoords | ( |  | ) |

Update the coordinates of all signs.

Definition at line 63 of file signs.cpp.

References UpdateSignVirtCoords().

Referenced by InitializeWindowsAndCaches().

static void UpdateSignVirtCoords | ( | Sign * | si | ) | `[static]`

Update the coordinate of one sign.

Parameters:

  | si | Pointer to the Sign

Definition at line 51 of file signs.cpp.

Referenced by CmdPlaceSign(), CmdRenameSign(), and UpdateAllSignVirtCoords().

## Variable Documentation

const ChunkHandler _sign_chunk_handlers[]

Initial value:

     {
      { 'SIGN', Save_SIGN, Load_SIGN, CH_ARRAY | CH_LAST},
    }

const SaveLoad _sign_desc[]`[static]`

Initial value:

     {
      SLE_CONDVAR(Sign, name,  SLE_NAME,                   0, 83),
      SLE_CONDSTR(Sign, name,  SLE_STR, 0,                84, SL_MAX_VERSION),
      SLE_CONDVAR(Sign, x,     SLE_FILE_I16 | SLE_VAR_I32, 0, 4),
      SLE_CONDVAR(Sign, y,     SLE_FILE_I16 | SLE_VAR_I32, 0, 4),
      SLE_CONDVAR(Sign, x,     SLE_INT32,                  5, SL_MAX_VERSION),
      SLE_CONDVAR(Sign, y,     SLE_INT32,                  5, SL_MAX_VERSION),
      SLE_CONDVAR(Sign, owner, SLE_UINT8,                  6, SL_MAX_VERSION),
          SLE_VAR(Sign, z,     SLE_UINT8),

    }

Definition at line 211 of file signs.cpp.