OpenTTD Source: src/goal.cpp File Reference

OpenTTD Source 14.0-RC3

Functions | Variables
goal.cpp File Reference
`#include "stdafx.h"`
`#include "company_func.h"`
`#include "industry.h"`
`#include "town.h"`
`#include "window_func.h"`
`#include "goal_base.h"`
`#include "core/pool_func.hpp"`
`#include "game/game.hpp"`
`#include "command_func.h"`
`#include "company_base.h"`
`#include "story_base.h"`
`#include "string_func.h"`
`#include "gui.h"`
`#include "network/network.h"`
`#include "network/network_base.h"`
`#include "network/network_func.h"`
`#include "goal_cmd.h"`
`#include "safeguards.h"`

Go to the source code of this file.

## Functions
std::tuple< CommandCost, GoalID > | CmdCreateGoal (DoCommandFlag flags, CompanyID company, GoalType type, GoalTypeID dest, const std::string &text)
| Create a new goal. More...
CommandCost | CmdRemoveGoal (DoCommandFlag flags, GoalID goal)
| Remove a goal. More...
CommandCost | CmdSetGoalDestination (DoCommandFlag flags, GoalID goal, GoalType type, GoalTypeID dest)
| Update goal destination of a goal. More...
CommandCost | CmdSetGoalText (DoCommandFlag flags, GoalID goal, const std::string &text)
| Update goal text of a goal. More...
CommandCost | CmdSetGoalProgress (DoCommandFlag flags, GoalID goal, const std::string &text)
| Update progress text of a goal. More...
CommandCost | CmdSetGoalCompleted (DoCommandFlag flags, GoalID goal, bool completed)
| Update completed state of a goal. More...
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. More...
CommandCost | CmdGoalQuestionAnswer (DoCommandFlag flags, uint16_t uniqueid, uint8_t button)
| Reply to a goal question. More...

## Variables
GoalPool | _goal_pool ("Goal")

## Detailed Description

Handling of goals.

Definition in file goal.cpp.

## Function Documentation

## ◆ CmdCreateGoal()

std::tuple<CommandCost, GoalID> CmdCreateGoal | ( | DoCommandFlag | flags,
|  | CompanyID | company,
|  | GoalType | type,
|  | GoalTypeID | dest,
|  | const std::string & | text
| ) |  |

Create a new goal.

Parameters

  flags | type of operation
  company | Company for which this goal is.
  type | GoalType of destination.
  dest | GoalTypeID of destination.
  text | Text of the goal.

Returns
  the cost of this operation or an error

Definition at line 78 of file goal.cpp.

References _current_company, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_goal_pool >::CanAllocateItem(), CMD_ERROR, Goal::company, Goal::completed, DC_EXEC, Goal::dst, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_goal_pool >::GetNumItems(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_COMPANY, INVALID_GOAL, InvalidateWindowClassesData(), InvalidateWindowData(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), OWNER_DEITY, Goal::text, Goal::type, WC_GOALS_LIST, and WC_MAIN_TOOLBAR.

## ◆ CmdGoalQuestion()

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.

Parameters

  flags | type of operation
  uniqueid | Unique ID to use for this question.
  target | Company or client for which this question is.
  is_client | Question target: false - company, true - client.
  button_mask | Buttons of the question.
  type | Question type.
  text | Text of the question.

Returns
  the cost of this operation or an error

Definition at line 248 of file goal.cpp.

## ◆ CmdGoalQuestionAnswer()

CommandCost CmdGoalQuestionAnswer | ( | DoCommandFlag | flags,
|  | uint16_t | uniqueid,
|  | uint8_t | button
| ) |  |

Reply to a goal question.

Parameters

  flags | type of operation
  uniqueid | Unique ID to use for this question.
  button | Button the company pressed

Returns
  the cost of this operation or an error

Definition at line 292 of file goal.cpp.

## ◆ CmdRemoveGoal()

CommandCost CmdRemoveGoal | ( | DoCommandFlag | flags,
|  | GoalID | goal
| ) |  |

Remove a goal.

Parameters

  flags | type of operation
  goal | GoalID to remove.

Returns
  the cost of this operation or an error

Definition at line 114 of file goal.cpp.

References _current_company, CMD_ERROR, Goal::company, DC_EXEC, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_goal_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_goal_pool >::GetNumItems(), INVALID_COMPANY, InvalidateWindowClassesData(), InvalidateWindowData(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_goal_pool >::IsValidID(), OWNER_DEITY, WC_GOALS_LIST, and WC_MAIN_TOOLBAR.

## ◆ CmdSetGoalCompleted()

CommandCost CmdSetGoalCompleted | ( | DoCommandFlag | flags,
|  | GoalID | goal,
|  | bool | completed
| ) |  |

Update completed state of a goal.

Parameters

  flags | type of operation
  goal | GoalID to update.
  completed | completed state of goal.

Returns
  the cost of this operation or an error

Definition at line 218 of file goal.cpp.

References _current_company, CMD_ERROR, Goal::company, Goal::completed, DC_EXEC, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_goal_pool >::Get(), INVALID_COMPANY, InvalidateWindowClassesData(), InvalidateWindowData(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_goal_pool >::IsValidID(), OWNER_DEITY, and WC_GOALS_LIST.

## ◆ CmdSetGoalDestination()

CommandCost CmdSetGoalDestination | ( | DoCommandFlag | flags,
|  | GoalID | goal,
|  | GoalType | type,
|  | GoalTypeID | dest
| ) |  |

Update goal destination of a goal.

Parameters

  flags | type of operation
  goal | GoalID to update.
  type | GoalType of destination.
  dest | GoalTypeID of destination.

Returns
  the cost of this operation or an error

Definition at line 143 of file goal.cpp.

References _current_company, CMD_ERROR, Goal::company, DC_EXEC, Goal::dst, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_goal_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_goal_pool >::IsValidID(), OWNER_DEITY, and Goal::type.

## ◆ CmdSetGoalProgress()

CommandCost CmdSetGoalProgress | ( | DoCommandFlag | flags,
|  | GoalID | goal,
|  | const std::string & | text
| ) |  |

Update progress text of a goal.

Parameters

  flags | type of operation
  goal | GoalID to update.
  text | Progress text of the goal.

Returns
  the cost of this operation or an error

Definition at line 192 of file goal.cpp.

References _current_company, CMD_ERROR, Goal::company, DC_EXEC, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_goal_pool >::Get(), INVALID_COMPANY, InvalidateWindowClassesData(), InvalidateWindowData(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_goal_pool >::IsValidID(), OWNER_DEITY, Goal::progress, and WC_GOALS_LIST.

## ◆ CmdSetGoalText()

CommandCost CmdSetGoalText | ( | DoCommandFlag | flags,
|  | GoalID | goal,
|  | const std::string & | text
| ) |  |

Update goal text of a goal.

Parameters

  flags | type of operation
  goal | GoalID to update.
  text | Text of the goal.

Returns
  the cost of this operation or an error

Definition at line 165 of file goal.cpp.

References _current_company, CMD_ERROR, Goal::company, DC_EXEC, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_goal_pool >::Get(), INVALID_COMPANY, InvalidateWindowClassesData(), InvalidateWindowData(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_goal_pool >::IsValidID(), OWNER_DEITY, Goal::text, and WC_GOALS_LIST.