26#include "table/strings.h"
50 case LoanCommand::Interval:
53 case LoanCommand::Max:
56 case LoanCommand::Amount:
58 if (loan < LOAN_INTERVAL || c->current_loan + loan > max_loan || loan %
LOAN_INTERVAL != 0)
return CMD_ERROR;
94 case LoanCommand::Interval:
97 case LoanCommand::Max:
101 case LoanCommand::Amount:
128 if (amount != COMPANY_MAX_LOAN_DEFAULT) {
137 if (amount != COMPANY_MAX_LOAN_DEFAULT) amount -= (int64_t)amount %
LOAN_INTERVAL;
Class for backupping variables and making sure they are restored later.
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
constexpr Timpl & Set()
Set all bits.
constexpr Timpl & Reset(Tvalue_type value)
Reset the value-th bit.
Common return value for all commands.
CommandCost CommandCostWithParam(StringID str, uint64_t value)
Return an error status, with string and parameter.
Functions related to commands.
static const CommandCost CMD_ERROR
Define a default return value for a failed command.
@ Execute
execute the given command
Definition of stuff that is very close to a company, like the company struct itself.
void InvalidateCompanyWindows(const Company *company)
Refresh all windows owned by a company.
Money GetAvailableMoneyForCommand()
This functions returns the money which can be used to execute a command.
void SubtractMoneyFromCompany(const CommandCost &cost)
Subtract money from the _current_company, if the company is valid.
CompanyID _current_company
Company currently doing an action.
Functions related to companies.
GUI Functions related to companies.
static constexpr Owner OWNER_DEITY
The object is owned by a superuser / goal script.
Functions related to the economy.
static const int64_t MAX_LOAN_LIMIT
The max amount possible to configure for a max loan of a company.
ExpensesType
Types of expenses.
@ EXPENSES_END
Number of expense types.
@ EXPENSES_OTHER
Other expenses.
static const int LOAN_INTERVAL
The "steps" in loan size, in British Pounds!
PauseModes _pause_mode
The current pause mode.
static debug_inline uint TileY(TileIndex tile)
Get the Y component of a tile.
static debug_inline uint TileX(TileIndex tile)
Get the X component of a tile.
CommandCost CmdChangeBankBalance(DoCommandFlags flags, TileIndex tile, Money delta, CompanyID company, ExpensesType expenses_type)
Change the bank bank balance of a company by inserting or removing money without affecting the loan.
CommandCost CmdDecreaseLoan(DoCommandFlags flags, LoanCommand cmd, Money amount)
Decrease the loan of your company.
CommandCost CmdIncreaseLoan(DoCommandFlags flags, LoanCommand cmd, Money amount)
Increase the loan of your company.
CommandCost CmdMoneyCheat(DoCommandFlags, Money amount)
Change the financial flow of your company.
CommandCost CmdPause(DoCommandFlags flags, PauseMode mode, bool pause)
Pause/Unpause the game (server-only).
CommandCost CmdSetCompanyMaxLoan(DoCommandFlags flags, CompanyID company, Money amount)
Sets the max loan amount of your company.
static void AskUnsafeUnpauseCallback(Window *, bool confirmed)
In case of an unsafe unpause, we want the user to confirm that it might crash.
Miscellaneous command definitions.
void ShowQuery(EncodedString &&caption, EncodedString &&message, Window *parent, QueryCallbackProc *callback, bool focus)
Show a confirmation window with standard 'yes' and 'no' buttons The window is aligned to the centre o...
void ShowCostOrIncomeAnimation(int x, int y, int z, Money cost)
Display animated income or costs on the map.
void NetworkHandlePauseChange(PauseModes prev_mode, PauseMode changed_mode)
Handle the pause mode change so we send the right messages to the chat.
bool _networking
are we in networking mode?
Basic functions/variables used all over the place.
Network functions used by other parts of OpenTTD.
PauseMode
Modes of pausing we've got.
@ LinkGraph
A game paused due to the link graph schedule lagging.
@ Error
A game paused because a (critical) error.
@ GameScript
A game paused by a game script.
@ ActiveClients
A game paused for 'min_active_clients'.
@ Normal
A game normally paused.
@ Join
A game paused for 'pause_on_join'.
@ CommandDuringPause
A game paused, and a command executed during the pause; resets on autosave.
@ SaveLoad
A game paused for saving/loading.
A number of safeguards to prevent using unsafe methods.
Definition of base types and functions in a cross-platform compatible way.
EncodedString GetEncodedString(StringID str)
Encode a string with no parameters into an encoded string.
Functions related to OTTD's strings.
Class to backup a specific variable and restore it later.
void Restore()
Restore the variable.
Money current_loan
Amount of money borrowed from the bank.
Money max_loan
Max allowed amount of the loan or COMPANY_MAX_LOAN_DEFAULT.
Money money
Money owned by the company.
Money GetMaxLoan() const
Calculate the max allowed loan for this company.
static Titem * Get(auto index)
Returns Titem with given index.
static bool IsValidID(auto index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
static Titem * GetIfValid(auto index)
Returns Titem with given index.
Data structure for an opened window.
Stuff related to the text buffer GUI.
Functions related to text effects.
Map writing/reading functions for tiles.
int GetTilePixelZ(TileIndex tile)
Get bottom height of the tile.
static const uint TILE_SIZE
Tile size in world coordinates.
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
Window functions not directly related to making/drawing windows.
@ WC_STATUS_BAR
Statusbar (at the bottom of your screen); Window numbers:
@ WC_MAIN_TOOLBAR
Main toolbar (the long bar at the top); Window numbers: