diff options
Diffstat (limited to 'src/engine.cpp')
-rw-r--r-- | src/engine.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/engine.cpp b/src/engine.cpp index 362bd014a..f8fc0ee6a 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -655,6 +655,7 @@ void StartupOneEngine(Engine *e, Date aging_date) e->age = 0; e->flags = 0; e->company_avail = 0; + e->company_hidden = 0; /* Don't randomise the start-date in the first two years after gamestart to ensure availability * of engines in early starting games. @@ -854,6 +855,41 @@ void EnginesDailyLoop() } /** + * Clear the 'hidden' flag for all engines of a new company. + * @param cid Company being created. + */ +void ClearEnginesHiddenFlagOfCompany(CompanyID cid) +{ + Engine *e; + FOR_ALL_ENGINES(e) { + SB(e->company_hidden, cid, 1, 0); + } +} + +/** + * Set the visibility of an engine. + * @param tile Unused. + * @param flags Operation to perform. + * @param p1 Unused. + * @param p2 Bit 31: 0=visible, 1=hidden, other bits for the #EngineID. + * @param text Unused. + * @return The cost of this operation or an error. + */ +CommandCost CmdSetVehicleVisibility(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +{ + Engine *e = Engine::GetIfValid(GB(p2, 0, 31)); + if (e == NULL || _current_company >= MAX_COMPANIES) return CMD_ERROR; + if ((e->flags & ENGINE_AVAILABLE) == 0 || !HasBit(e->company_avail, _current_company)) return CMD_ERROR; + + if ((flags & DC_EXEC) != 0) { + SB(e->company_hidden, _current_company, 1, GB(p2, 31, 1)); + AddRemoveEngineFromAutoreplaceAndBuildWindows(e->type); + } + + return CommandCost(); +} + +/** * 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 tile unused |