OpenTTD Source 20241224-master-gf74b0cf984
signs_cmd.cpp File Reference

Handling of sign related commands. More...

#include "stdafx.h"
#include "landscape.h"
#include "company_func.h"
#include "signs_base.h"
#include "signs_func.h"
#include "command_func.h"
#include "tilehighlight_func.h"
#include "viewport_kdtree.h"
#include "window_func.h"
#include "string_func.h"
#include "signs_cmd.h"
#include "table/strings.h"
#include "safeguards.h"

Go to the source code of this file.

Functions

std::tuple< CommandCost, SignIDCmdPlaceSign (DoCommandFlag flags, TileIndex tile, const std::string &text)
 Place a sign at the given coordinates.
 
CommandCost CmdRenameSign (DoCommandFlag flags, SignID sign_id, const std::string &text)
 Rename a sign.
 
void CcPlaceSign (Commands, const CommandCost &result, SignID new_sign)
 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.
 

Detailed Description

Handling of sign related commands.

Definition in file signs_cmd.cpp.

Function Documentation

◆ CcPlaceSign()

void CcPlaceSign ( Commands  cmd,
const CommandCost result,
SignID  new_sign 
)

Callback function that is called after a sign is placed.

Parameters
resultof the operation
new_signID of the placed sign.

Definition at line 108 of file signs_cmd.cpp.

References CommandCost::Failed(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_sign_pool >::Get(), ResetObjectToPlace(), and ShowRenameSignWindow().

Referenced by PlaceProc_Sign().

◆ CmdPlaceSign()

std::tuple< CommandCost, SignID > CmdPlaceSign ( DoCommandFlag  flags,
TileIndex  tile,
const std::string &  text 
)

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
tiletile to place sign at
flagstype of operation
textcontents of the sign
Returns
the cost of this operation + the ID of the new sign or an error

Definition at line 35 of file signs_cmd.cpp.

References _current_company, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_sign_pool >::CanAllocateItem(), CMD_ERROR, DC_EXEC, GetSlopePixelZ(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_SIGN, InvalidateWindowData(), MAX_LENGTH_SIGN_NAME_CHARS, OWNER_DEITY, TILE_SIZE, TileX(), TileY(), Sign::UpdateVirtCoord(), Utf8StringLength(), and WC_SIGN_LIST.

◆ CmdRenameSign()

CommandCost CmdRenameSign ( DoCommandFlag  flags,
SignID  sign_id,
const std::string &  text 
)

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
flagstype of operation
sign_idindex of the sign to be renamed/removed
textthe new name or an empty string when resetting to the default
Returns
the cost of this operation or an error

Definition at line 72 of file signs_cmd.cpp.

References _current_company, CMD_ERROR, CompanyCanRenameSign(), DC_EXEC, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_sign_pool >::GetIfValid(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, InvalidateWindowData(), TrackedViewportSign::kdtree_valid, ViewportSign::MarkDirty(), MAX_LENGTH_SIGN_NAME_CHARS, Kdtree< T, TxyFunc, CoordT, DistT >::Remove(), Sign::UpdateVirtCoord(), Utf8StringLength(), and WC_SIGN_LIST.

◆ PlaceProc_Sign()

void PlaceProc_Sign ( TileIndex  tile)

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

Parameters
tileon which to place the sign

Definition at line 122 of file signs_cmd.cpp.

References CcPlaceSign().

Referenced by TerraformToolbarWindow::OnPlaceObject(), MainToolbarWindow::OnPlaceObject(), and ScenarioEditorToolbarWindow::OnPlaceObject().