OpenTTD Source: src/goal.cpp File Reference

OpenTTD Source 12.0-beta1

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 "safeguards.h"`

Go to the source code of this file.

## Functions
CommandCost | CmdCreateGoal (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
| Create a new goal. More...
CommandCost | CmdRemoveGoal (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
| Remove a goal. More...
CommandCost | CmdSetGoalText (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
| Update goal text of a goal. More...
CommandCost | CmdSetGoalProgress (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
| Update progress text of a goal. More...
CommandCost | CmdSetGoalCompleted (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
| Update completed state of a goal. More...
CommandCost | CmdGoalQuestion (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
| Ask a goal related question. More...
CommandCost | CmdGoalQuestionAnswer (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
| Reply to a goal question. More...

## Variables
GoalID | _new_goal_id
GoalPool | _goal_pool ("Goal")

## Detailed Description

Handling of goals.

Definition in file goal.cpp.

## Function Documentation

## ◆ CmdCreateGoal()

CommandCost CmdCreateGoal | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const std::string & | text
| ) |  |

Create a new goal.

Parameters

  tile | unused.
  flags | type of operation
  p1 | various bitstuffed elements p1 = (bit 0 - 7) - GoalType of destination. p1 = (bit 8 - 15) - Company for which this goal is.
  p2 | GoalTypeID of destination.
  text | Text of the goal.

Returns
  the cost of this operation or an error

Definition at line 46 of file goal.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_goal_pool >::CanAllocateItem(), CMD_ERROR, and GB().

## ◆ CmdGoalQuestion()

CommandCost CmdGoalQuestion | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const std::string & | text
| ) |  |

Ask a goal related question.

Parameters

  tile | unused.
  flags | type of operation
  p1 | various bitstuffed elements p1 = (bit 0 - 15) - Unique ID to use for this question. p1 = (bit 16 - 31) - Company or client for which this question is.
  p2 | various bitstuffed elements p2 = (bit 0 - 17) - Buttons of the question. p2 = (bit 29 - 30) - Question type. p2 = (bit 31) - Question target: 0 - company, 1 - client.
  text | Text of the question.

Returns
  the cost of this operation or an error

Definition at line 245 of file goal.cpp.

## ◆ CmdGoalQuestionAnswer()

CommandCost CmdGoalQuestionAnswer | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const std::string & | text
| ) |  |

Reply to a goal question.

Parameters

  tile | unused.
  flags | type of operation
  p1 | Unique ID to use for this question.
  p2 | Button the company pressed
  text | Text of the question.

Returns
  the cost of this operation or an error

Definition at line 292 of file goal.cpp.

## ◆ CmdRemoveGoal()

CommandCost CmdRemoveGoal | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const std::string & | text
| ) |  |

Remove a goal.

Parameters

  tile | unused.
  flags | type of operation
  p1 | GoalID to remove.
  p2 | unused.
  text | unused.

Returns
  the cost of this operation or an error

Definition at line 119 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 | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const std::string & | text
| ) |  |

Update completed state of a goal.

Parameters

  tile | unused.
  flags | type of operation
  p1 | GoalID to update.
  p2 | completed state. If goal is completed, set to 1, otherwise 0.
  text | unused

Returns
  the cost of this operation or an error

Definition at line 212 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.

## ◆ CmdSetGoalProgress()

CommandCost CmdSetGoalProgress | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const std::string & | text
| ) |  |

Update progress text of a goal.

Parameters

  tile | unused.
  flags | type of operation
  p1 | GoalID to update.
  p2 | unused
  text | Progress text of the goal.

Returns
  the cost of this operation or an error

Definition at line 179 of file goal.cpp.

References _current_company, CMD_ERROR, Goal::company, DC_EXEC, free(), 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, stredup(), and WC_GOALS_LIST.

## ◆ CmdSetGoalText()

CommandCost CmdSetGoalText | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const std::string & | text
| ) |  |

Update goal text of a goal.

Parameters

  tile | unused.
  flags | type of operation
  p1 | GoalID to update.
  p2 | unused
  text | Text of the goal.

Returns
  the cost of this operation or an error

Definition at line 149 of file goal.cpp.

References _current_company, CMD_ERROR, Goal::company, DC_EXEC, free(), 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, stredup(), Goal::text, and WC_GOALS_LIST.