MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / CmdMoveSign

Function CmdMoveSign

src/signs_cmd.cpp:106–126  ·  view source on GitHub ↗

* Move a sign to the given coordinates. Ownership of signs * has no meaning/effect whatsoever except for eyecandy. * @param flags type of operation * @param sign_id index of the sign to be moved * @param tile tile to place the sign at * @return the cost of this operation or an error */

Source from the content-addressed store, hash-verified

104 * @return the cost of this operation or an error
105 */
106CommandCost CmdMoveSign(DoCommandFlags flags, SignID sign_id, TileIndex tile)
107{
108 Sign *si = Sign::GetIfValid(sign_id);
109 if (si == nullptr) return CMD_ERROR;
110 if (!CompanyCanEditSign(si)) return CMD_ERROR;
111
112 /* Move the sign */
113 if (flags.Test(DoCommandFlag::Execute)) {
114 int x = TileX(tile) * TILE_SIZE;
115 int y = TileY(tile) * TILE_SIZE;
116
117 si->x = x;
118 si->y = y;
119 si->z = GetSlopePixelZ(x, y);
120 if (_game_mode != GM_EDITOR) si->owner = _current_company;
121
122 si->UpdateVirtCoord();
123 }
124
125 return CommandCost();
126}
127
128/**
129 * Callback function that is called after a sign is placed

Callers

nothing calls this directly

Calls 7

CompanyCanEditSignFunction · 0.85
TileXFunction · 0.85
TileYFunction · 0.85
GetSlopePixelZFunction · 0.85
CommandCostClass · 0.85
TestMethod · 0.80
UpdateVirtCoordMethod · 0.45

Tested by

no test coverage detected