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

Function CmdSetVehicleVisibility

src/engine.cpp:1018–1030  ·  view source on GitHub ↗

* Set the visibility of an engine. * @param flags Operation to perform. * @param engine_id Engine id.. * @param hide Set for hidden, unset for visible. * @return The cost of this operation or an error. */

Source from the content-addressed store, hash-verified

1016 * @return The cost of this operation or an error.
1017 */
1018CommandCost CmdSetVehicleVisibility(DoCommandFlags flags, EngineID engine_id, bool hide)
1019{
1020 Engine *e = Engine::GetIfValid(engine_id);
1021 if (e == nullptr || _current_company >= MAX_COMPANIES) return CMD_ERROR;
1022 if (!IsEngineBuildable(e->index, e->type, _current_company)) return CMD_ERROR;
1023
1024 if (flags.Test(DoCommandFlag::Execute)) {
1025 e->company_hidden.Set(_current_company, hide);
1026 AddRemoveEngineFromAutoreplaceAndBuildWindows(e->type);
1027 }
1028
1029 return CommandCost();
1030}
1031
1032/**
1033 * Accept an engine prototype. XXX - it is possible that the top-company

Callers

nothing calls this directly

Calls 5

IsEngineBuildableFunction · 0.85
CommandCostClass · 0.85
TestMethod · 0.80
SetMethod · 0.45

Tested by

no test coverage detected