38 if (dest != 0)
return false;
64 default:
return false;
148 if (!Goal::IsValidGoalDestination(g->
company, type, dest))
return CMD_ERROR;
250 static_assert(
sizeof(uint32_t) >=
sizeof(
CompanyID));
252 static_assert(
sizeof(uint32_t) >=
sizeof(
ClientID));
268 uint min_buttons = (type == GQT_QUESTION ? 1 : 0);
309 Game::NewEvent(
new ScriptEventGoalQuestionAnswer(uniqueid, (ScriptCompany::CompanyID)(uint8_t)
_current_company, (ScriptGoal::QuestionButton)(1 << button)));
constexpr uint CountBits(T value)
Counts the number of set bits in a variable.
Common return value for all commands.
static void NewEvent(class ScriptEvent *event)
Queue a new event for a Game Script.
Functions related to commands.
static const CommandCost CMD_ERROR
Define a default return value for a failed command.
DoCommandFlag
List of flags for a command.
@ DC_EXEC
execute the given command
Definition of stuff that is very close to a company, like the company struct itself.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
CompanyID _current_company
Company currently doing an action.
Functions related to companies.
Owner
Enum for all companies/owners.
@ INVALID_COMPANY
An invalid company.
@ OWNER_DEITY
The object is owned by a superuser / goal script.
Base functions for all Games.
CommandCost CmdSetGoalText(DoCommandFlag flags, GoalID goal, const std::string &text)
Update goal text of a goal.
CommandCost CmdRemoveGoal(DoCommandFlag flags, GoalID goal)
Remove a goal.
CommandCost CmdSetGoalDestination(DoCommandFlag flags, GoalID goal, GoalType type, GoalTypeID dest)
Update goal destination of a goal.
CommandCost CmdSetGoalProgress(DoCommandFlag flags, GoalID goal, const std::string &text)
Update progress text of a goal.
CommandCost CmdSetGoalCompleted(DoCommandFlag flags, GoalID goal, bool completed)
Update completed state of a goal.
CommandCost CmdGoalQuestionAnswer(DoCommandFlag flags, uint16_t uniqueid, uint8_t button)
Reply to a goal question.
CommandCost CmdGoalQuestion(DoCommandFlag flags, uint16_t uniqueid, uint32_t target, bool is_client, uint32_t button_mask, GoalQuestionType type, const std::string &text)
Ask a goal related question.
std::tuple< CommandCost, GoalID > CmdCreateGoal(DoCommandFlag flags, CompanyID company, GoalType type, GoalTypeID dest, const std::string &text)
Create a new goal.
Command definitions related to goals.
void ShowGoalQuestion(uint16_t id, uint8_t type, uint32_t button_mask, const std::string &question)
Display a goal question.
uint16_t GoalID
ID of a goal.
GoalType
Types of goal destinations.
@ GT_INDUSTRY
Destination is an industry.
@ GT_STORY_PAGE
Destination is a story page.
@ GT_COMPANY
Destination is a company.
@ GT_NONE
Destination is not linked.
@ GT_TILE
Destination is a tile.
@ GT_TOWN
Destination is a town.
uint32_t GoalTypeID
Contains either tile, industry ID, town ID, company ID, or story page ID.
static const GoalID INVALID_GOAL
Constant representing a non-existing goal.
static const uint32_t GOAL_QUESTION_BUTTON_COUNT
Amount of buttons available.
GUI functions that shouldn't be here.
bool _networking
are we in networking mode?
bool _network_server
network-server is active
ClientID _network_own_client_id
Our client identifier.
Basic functions/variables used all over the place.
Base core network types and some helper functions to access them.
Network functions used by other parts of OpenTTD.
ClientID
'Unique' identifier to be given to clients
Some methods of Pool are placed here in order to reduce compilation time and binary size.
#define INSTANTIATE_POOL_METHODS(name)
Force instantiation of pool methods so we don't get linker errors.
A number of safeguards to prevent using unsafe methods.
Definition of base types and functions in a cross-platform compatible way.
Functions related to low-level strings.
Struct about goals, current and completed.
bool completed
Is the goal completed or not?
GoalType type
Type of the goal.
GoalTypeID dst
Index of type.
std::string text
Text of the goal.
CompanyID company
Goal is for a specific company; INVALID_COMPANY if it is global.
std::string progress
Progress text of the goal.
static NetworkClientInfo * GetByClientID(ClientID client_id)
Return the CI given it's client-identifier.
Tindex index
Index of this pool item.
static size_t GetNumItems()
Returns number of valid items in the pool.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
static Titem * Get(size_t index)
Returns Titem with given index.
Base class for all pools.
bool IsValidTile(Tile tile)
Checks if a tile is valid.
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data, bool gui_scope)
Mark window data of the window of a given class and specific window number as invalid (in need of re-...
void InvalidateWindowClassesData(WindowClass cls, int data, bool gui_scope)
Mark window data of all windows of a given class as invalid (in need of re-computing) Note that by de...
Window functions not directly related to making/drawing windows.
@ WC_GOAL_QUESTION
Popup with a set of buttons, designed to ask the user a question from a GameScript.
@ WC_GOALS_LIST
Goals list; Window numbers:
@ WC_MAIN_TOOLBAR
Main toolbar (the long bar at the top); Window numbers: