OpenTTD Source 20260108-master-g8ba1860eaa
goal_base.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#ifndef GOAL_BASE_H
11#define GOAL_BASE_H
12
13#include "company_type.h"
14#include "goal_type.h"
15#include "core/pool_type.hpp"
16#include "strings_type.h"
17
19extern GoalPool _goal_pool;
20
22struct Goal : GoalPool::PoolItem<&_goal_pool> {
23 CompanyID company = CompanyID::Invalid();
28 bool completed = false;
29
30 Goal(GoalID index, GoalType type = GT_NONE, GoalTypeID dst = 0, CompanyID company = CompanyID::Invalid(), const EncodedString &text = {}) :
31 GoalPool::PoolItem<&_goal_pool>(index), company(company), type(type), dst(dst), text(text) {}
32
36 ~Goal() { }
37
38 static bool IsValidGoalDestination(CompanyID company, GoalType type, GoalTypeID dest);
39};
40
41#endif /* GOAL_BASE_H */
Container for an encoded string, created by GetEncodedString.
Types related to companies.
Basic types related to goals.
GoalType
Types of goal destinations.
Definition goal_type.h:26
@ GT_NONE
Destination is not linked.
Definition goal_type.h:27
uint32_t GoalTypeID
Contains either tile, industry ID, town ID, company ID, or story page ID.
Definition goal_type.h:35
Definition of Pool, structure used to access PoolItems, and PoolItem, base structure for Vehicle,...
Types related to strings.
Struct about goals, current and completed.
Definition goal_base.h:22
~Goal()
(Empty) destructor has to be defined else operator delete might be called with nullptr parameter
Definition goal_base.h:36
EncodedString progress
Progress text of the goal.
Definition goal_base.h:27
EncodedString text
Text of the goal.
Definition goal_base.h:26
bool completed
Is the goal completed or not?
Definition goal_base.h:28
GoalType type
Type of the goal.
Definition goal_base.h:24
GoalTypeID dst
Index of type.
Definition goal_base.h:25
CompanyID company
Goal is for a specific company; CompanyID::Invalid() if it is global.
Definition goal_base.h:23
Base class for all PoolItems.
PoolItem(Tindex index)
Construct the item.
const Tindex index
Index of this pool item.
Base class for all pools.