diff options
author | Michael Lutz <michi@icosahedron.de> | 2021-11-05 23:55:23 +0100 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2021-12-16 22:28:32 +0100 |
commit | 21675ec7e22bfe53f20300cc27b4d50c84aeb4dc (patch) | |
tree | bfc6a1ef650ac6def3b80f86ec8d1a424900f459 /src/engine.cpp | |
parent | 2637c06f88ed6f9dea55449883f42a62c30f19d8 (diff) | |
download | openttd-21675ec7e22bfe53f20300cc27b4d50c84aeb4dc.tar.xz |
Codechange: Un-bitstuff vehicle/engine commands.
Diffstat (limited to 'src/engine.cpp')
-rw-r--r-- | src/engine.cpp | 45 |
1 files changed, 16 insertions, 29 deletions
diff --git a/src/engine.cpp b/src/engine.cpp index e9bb6c494..6d0b25fcc 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -876,20 +876,18 @@ void ClearEnginesHiddenFlagOfCompany(CompanyID cid) /** * Set the visibility of an engine. * @param flags Operation to perform. - * @param tile Unused. - * @param p1 Unused. - * @param p2 Bit 31: 0=visible, 1=hidden, other bits for the #EngineID. - * @param text Unused. + * @param engine_id Engine id.. + * @param hide Set for hidden, unset for visible. * @return The cost of this operation or an error. */ -CommandCost CmdSetVehicleVisibility(DoCommandFlag flags, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) +CommandCost CmdSetVehicleVisibility(DoCommandFlag flags, EngineID engine_id, bool hide) { - Engine *e = Engine::GetIfValid(GB(p2, 0, 31)); + Engine *e = Engine::GetIfValid(engine_id); if (e == nullptr || _current_company >= MAX_COMPANIES) return CMD_ERROR; if (!IsEngineBuildable(e->index, e->type, _current_company)) return CMD_ERROR; if ((flags & DC_EXEC) != 0) { - SB(e->company_hidden, _current_company, 1, GB(p2, 31, 1)); + SB(e->company_hidden, _current_company, 1, hide ? 1 : 0); AddRemoveEngineFromAutoreplaceAndBuildWindows(e->type); } @@ -900,18 +898,15 @@ CommandCost CmdSetVehicleVisibility(DoCommandFlag flags, TileIndex tile, uint32 * Accept an engine prototype. XXX - it is possible that the top-company * changes while you are waiting to accept the offer? Then it becomes invalid * @param flags operation to perform - * @param tile unused - * @param p1 engine-prototype offered - * @param p2 unused - * @param text unused + * @param engine_id engine-prototype offered * @return the cost of this operation or an error */ -CommandCost CmdWantEnginePreview(DoCommandFlag flags, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) +CommandCost CmdWantEnginePreview(DoCommandFlag flags, EngineID engine_id) { - Engine *e = Engine::GetIfValid(p1); + Engine *e = Engine::GetIfValid(engine_id); if (e == nullptr || !(e->flags & ENGINE_EXCLUSIVE_PREVIEW) || e->preview_company != _current_company) return CMD_ERROR; - if (flags & DC_EXEC) AcceptEnginePreview(p1, _current_company); + if (flags & DC_EXEC) AcceptEnginePreview(engine_id, _current_company); return CommandCost(); } @@ -919,20 +914,14 @@ CommandCost CmdWantEnginePreview(DoCommandFlag flags, TileIndex tile, uint32 p1, /** * Allow or forbid a specific company to use an engine * @param flags operation to perform - * @param tile unused - * @param p1 engine id - * @param p2 various bitstuffed elements - * - p2 = (bit 0 - 7) - Company to allow/forbid the use of an engine. - * - p2 = (bit 31) - 0 to forbid, 1 to allow. - * @param text unused + * @param engine_id engine id + * @param company_id Company to allow/forbid the use of an engine. + * @param allow false to forbid, true to allow. * @return the cost of this operation or an error */ -CommandCost CmdEngineCtrl(DoCommandFlag flags, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) +CommandCost CmdEngineCtrl(DoCommandFlag flags, EngineID engine_id, CompanyID company_id, bool allow) { if (_current_company != OWNER_DEITY) return CMD_ERROR; - EngineID engine_id = (EngineID)p1; - CompanyID company_id = (CompanyID)GB(p2, 0, 8); - bool allow = HasBit(p2, 31); if (!Engine::IsValidID(engine_id) || !Company::IsValidID(company_id)) return CMD_ERROR; @@ -1073,15 +1062,13 @@ static bool IsUniqueEngineName(const std::string &name) /** * Rename an engine. * @param flags operation to perform - * @param tile unused - * @param p1 engine ID to rename - * @param p2 unused + * @param engine_id engine ID to rename * @param text the new name or an empty string when resetting to the default * @return the cost of this operation or an error */ -CommandCost CmdRenameEngine(DoCommandFlag flags, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) +CommandCost CmdRenameEngine(DoCommandFlag flags, EngineID engine_id, const std::string &text) { - Engine *e = Engine::GetIfValid(p1); + Engine *e = Engine::GetIfValid(engine_id); if (e == nullptr) return CMD_ERROR; bool reset = text.empty(); |