OpenTTD Source: src/story.cpp Source File

OpenTTD Source 12.0-beta1

story.cpp
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 <http://www.gnu.org/licenses/>.
6 */
7
10 #include "stdafx.h"
11 #include "story_base.h"
12 #include "core/pool_func.hpp"
13 #include "cmd_helper.h"
14 #include "command_func.h"
15 #include "company_base.h"
16 #include "company_func.h"
17 #include "string_func.h"
18 #include "date_func.h"
19 #include "tile_map.h"
20 #include "goal_type.h"
21 #include "goal_base.h"
22 #include "window_func.h"
23 #include "gui.h"
24 #include "vehicle_base.h"
25 #include "game/game.hpp"
26 #include "script/api/script_story_page.hpp"
27 #include "script/api/script_event_types.hpp"
28
29 #include "safeguards.h"
30
31
32 StoryPageElementID _new_story_page_element_id;
33 StoryPageID _new_story_page_id;
34 uint32 _story_page_element_next_sort_value;
35 uint32 _story_page_next_sort_value;
36
37 StoryPageElementPool _story_page_element_pool("StoryPageElement");
38 StoryPagePool _story_page_pool("StoryPage");
39 INSTANTIATE_POOL_METHODS(StoryPageElement)
40 INSTANTIATE_POOL_METHODS(StoryPage)
41
42
52 static bool VerifyElementContentParameters(StoryPageID page_id, StoryPageElementType type, TileIndex tile, uint32 reference, const char *text)
53 {
54 StoryPageButtonData button_data{ reference };
55
56 switch (type) {
57 case SPET_TEXT:
58 if (StrEmpty(text)) return false;
59 break;
60 case SPET_LOCATION:
61 if (StrEmpty(text)) return false;
62 if (!IsValidTile(tile)) return false;
63 break;
64 case SPET_GOAL:
65 if (!Goal::IsValidID((GoalID)reference)) return false;
66 /* Reject company specific goals on global pages */
67 if (StoryPage::Get(page_id)->company == INVALID_COMPANY && Goal::Get((GoalID)reference)->company != INVALID_COMPANY) return false;
68 break;
69 case SPET_BUTTON_PUSH:
70 if (!button_data.ValidateColour()) return false;
71 return true;
72 case SPET_BUTTON_TILE:
73 if (!button_data.ValidateColour()) return false;
74 if (!button_data.ValidateCursor()) return false;
75 return true;
76 case SPET_BUTTON_VEHICLE:
77 if (!button_data.ValidateColour()) return false;
78 if (!button_data.ValidateCursor()) return false;
79 if (!button_data.ValidateVehicleType()) return false;
80 return true;
81 default:
82 return false;
83 }
84
85 return true;
86 }
87
96 static void UpdateElement(StoryPageElement &pe, TileIndex tile, uint32 reference, const char *text)
97 {
98 switch (pe.type) {
99 case SPET_TEXT:
100 pe.text = stredup(text);
101 break;
102 case SPET_LOCATION:
103 pe.text = stredup(text);
104 pe.referenced_id = tile;
105 break;
106 case SPET_GOAL:
107 pe.referenced_id = (GoalID)reference;
108 break;
109 case SPET_BUTTON_PUSH:
110 case SPET_BUTTON_TILE:
111 case SPET_BUTTON_VEHICLE:
112 pe.text = stredup(text);
113 pe.referenced_id = reference;
114 break;
115 default: NOT_REACHED();
116 }
117 }
118
120 void StoryPageButtonData::SetColour(Colours button_colour)
121 {
122 assert(button_colour < COLOUR_END);
123 SB(this->referenced_id, 0, 8, button_colour);
124 }
125
126 void StoryPageButtonData::SetFlags(StoryPageButtonFlags flags)
127 {
128 SB(this->referenced_id, 24, 8, flags);
129 }
130
132 void StoryPageButtonData::SetCursor(StoryPageButtonCursor cursor)
133 {
134 assert(cursor < SPBC_END);
135 SB(this->referenced_id, 8, 8, cursor);
136 }
137
139 void StoryPageButtonData::SetVehicleType(VehicleType vehtype)
140 {
141 assert(vehtype == VEH_INVALID || vehtype < VEH_COMPANY_END);
142 SB(this->referenced_id, 16, 8, vehtype);
143 }
144
146 Colours StoryPageButtonData::GetColour() const
147 {
148 return Extract<Colours, 0, 8>(this->referenced_id);
149 }
150
151 StoryPageButtonFlags StoryPageButtonData::GetFlags() const
152 {
153 return (StoryPageButtonFlags)GB(this->referenced_id, 24, 8);
154 }
155
157 StoryPageButtonCursor StoryPageButtonData::GetCursor() const
158 {
159 return Extract<StoryPageButtonCursor, 8, 8>(this->referenced_id);
160 }
161
163 VehicleType StoryPageButtonData::GetVehicleType() const
164 {
165 return (VehicleType)GB(this->referenced_id, 16, 8);
166 }
167
169 bool StoryPageButtonData::ValidateColour() const
170 {
171 return GB(this->referenced_id, 0, 8) < COLOUR_END;
172 }
173
174 bool StoryPageButtonData::ValidateFlags() const
175 {
176 byte flags = GB(this->referenced_id, 24, 8);
177 /* Don't allow float left and right together */
178 if ((flags & SPBF_FLOAT_LEFT) && (flags & SPBF_FLOAT_RIGHT)) return false;
179 /* Don't allow undefined flags */
180 if (flags & ~(SPBF_FLOAT_LEFT | SPBF_FLOAT_RIGHT)) return false;
181 return true;
182 }
183
185 bool StoryPageButtonData::ValidateCursor() const
186 {
187 return GB(this->referenced_id, 8, 8) < SPBC_END;
188 }
189
191 bool StoryPageButtonData::ValidateVehicleType() const
192 {
193 byte vehtype = GB(this->referenced_id, 16, 8);
194 return vehtype == VEH_INVALID || vehtype < VEH_COMPANY_END;
195 }
196
207 CommandCost CmdCreateStoryPage(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
208 {
209 if (!StoryPage::CanAllocateItem()) return CMD_ERROR;
210
211 CompanyID company = (CompanyID)GB(p1, 0, 8);
212
213 if (_current_company != OWNER_DEITY) return CMD_ERROR;
214 if (company != INVALID_COMPANY && !Company::IsValidID(company)) return CMD_ERROR;
215
216 if (flags & DC_EXEC) {
217 if (_story_page_pool.items == 0) {
218 /* Initialize the next sort value variable. */
219 _story_page_next_sort_value = 0;
220 }
221
222 StoryPage *s = new StoryPage();
223 s->sort_value = _story_page_next_sort_value;
224 s->date = _date;
225 s->company = company;
226 if (text.empty()) {
227 s->title = nullptr;
228 } else {
229 s->title = stredup(text.c_str());
230 }
231
232 InvalidateWindowClassesData(WC_STORY_BOOK, -1);
233 if (StoryPage::GetNumItems() == 1) InvalidateWindowData(WC_MAIN_TOOLBAR, 0);
234
235 _new_story_page_id = s->index;
236 _story_page_next_sort_value++;
237 }
238
239 return CommandCost();
240 }
241
253 CommandCost CmdCreateStoryPageElement(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
254 {
255 if (!StoryPageElement::CanAllocateItem()) return CMD_ERROR;
256
257 StoryPageID page_id = (StoryPageID)GB(p1, 0, 16);
258 StoryPageElementType type = Extract<StoryPageElementType, 16, 8>(p1);
259
260 /* Allow at most 128 elements per page. */
261 uint16 element_count = 0;
262 for (StoryPageElement *iter : StoryPageElement::Iterate()) {
263 if (iter->page == page_id) element_count++;
264 }
265 if (element_count >= 128) return CMD_ERROR;
266
267 if (_current_company != OWNER_DEITY) return CMD_ERROR;
268 if (!StoryPage::IsValidID(page_id)) return CMD_ERROR;
269 if (!VerifyElementContentParameters(page_id, type, tile, p2, text.c_str())) return CMD_ERROR;
270
271 if (flags & DC_EXEC) {
272 if (_story_page_element_pool.items == 0) {
273 /* Initialize the next sort value variable. */
274 _story_page_element_next_sort_value = 0;
275 }
276
277 StoryPageElement *pe = new StoryPageElement();
278 pe->sort_value = _story_page_element_next_sort_value;
279 pe->type = type;
280 pe->page = page_id;
281 UpdateElement(*pe, tile, p2, text.c_str());
282
283 InvalidateWindowClassesData(WC_STORY_BOOK, page_id);
284
285 _new_story_page_element_id = pe->index;
286 _story_page_element_next_sort_value++;
287 }
288
289 return CommandCost();
290 }
291
303 CommandCost CmdUpdateStoryPageElement(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
304 {
305 StoryPageElementID page_element_id = (StoryPageElementID)GB(p1, 0, 16);
306
307 if (_current_company != OWNER_DEITY) return CMD_ERROR;
308 if (!StoryPageElement::IsValidID(page_element_id)) return CMD_ERROR;
309
310 StoryPageElement *pe = StoryPageElement::Get(page_element_id);
311 StoryPageID page_id = pe->page;
312 StoryPageElementType type = pe->type;
313
314 if (!VerifyElementContentParameters(page_id, type, tile, p2, text.c_str())) return CMD_ERROR;
315
316 if (flags & DC_EXEC) {
317 UpdateElement(*pe, tile, p2, text.c_str());
318 InvalidateWindowClassesData(WC_STORY_BOOK, pe->page);
319 }
320
321 return CommandCost();
322 }
323
333 CommandCost CmdSetStoryPageTitle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
334 {
335 if (_current_company != OWNER_DEITY) return CMD_ERROR;
336 StoryPageID page_id = (StoryPageID)GB(p1, 0, 16);
337 if (!StoryPage::IsValidID(page_id)) return CMD_ERROR;
338
339 if (flags & DC_EXEC) {
340 StoryPage *p = StoryPage::Get(page_id);
341 free(p->title);
342 if (text.empty()) {
343 p->title = nullptr;
344 } else {
345 p->title = stredup(text.c_str());
346 }
347
348 InvalidateWindowClassesData(WC_STORY_BOOK, page_id);
349 }
350
351 return CommandCost();
352 }
353
363 CommandCost CmdSetStoryPageDate(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
364 {
365 if (_current_company != OWNER_DEITY) return CMD_ERROR;
366 StoryPageID page_id = (StoryPageID)GB(p1, 0, 16);
367 if (!StoryPage::IsValidID(page_id)) return CMD_ERROR;
368 Date date = (Date)p2;
369
370 if (flags & DC_EXEC) {
371 StoryPage *p = StoryPage::Get(page_id);
372 p->date = date;
373
374 InvalidateWindowClassesData(WC_STORY_BOOK, page_id);
375 }
376
377 return CommandCost();
378 }
379
390 CommandCost CmdShowStoryPage(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
391 {
392 if (_current_company != OWNER_DEITY) return CMD_ERROR;
393 StoryPageID page_id = (StoryPageID)GB(p1, 0, 16);
394 if (!StoryPage::IsValidID(page_id)) return CMD_ERROR;
395
396 if (flags & DC_EXEC) {
397 StoryPage *g = StoryPage::Get(page_id);
398 if ((g->company != INVALID_COMPANY && g->company == _local_company) || (g->company == INVALID_COMPANY && Company::IsValidID(_local_company))) ShowStoryBook(_local_company, page_id);
399 }
400
401 return CommandCost();
402 }
412 CommandCost CmdRemoveStoryPage(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
413 {
414 if (_current_company != OWNER_DEITY) return CMD_ERROR;
415 StoryPageID page_id = (StoryPageID)p1;
416 if (!StoryPage::IsValidID(page_id)) return CMD_ERROR;
417
418 if (flags & DC_EXEC) {
419 StoryPage *p = StoryPage::Get(page_id);
420
421 for (StoryPageElement *pe : StoryPageElement::Iterate()) {
422 if (pe->page == p->index) {
423 delete pe;
424 }
425 }
426
427 delete p;
428
429 InvalidateWindowClassesData(WC_STORY_BOOK, -1);
430 if (StoryPage::GetNumItems() == 0) InvalidateWindowData(WC_MAIN_TOOLBAR, 0);
431 }
432
433 return CommandCost();
434 }
435
445 CommandCost CmdRemoveStoryPageElement(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
446 {
447 if (_current_company != OWNER_DEITY) return CMD_ERROR;
448 StoryPageElementID page_element_id = (StoryPageElementID)p1;
449 if (!StoryPageElement::IsValidID(page_element_id)) return CMD_ERROR;
450
451 if (flags & DC_EXEC) {
452 StoryPageElement *pe = StoryPageElement::Get(page_element_id);
453 StoryPageID page_id = pe->page;
454
455 delete pe;
456
457 InvalidateWindowClassesData(WC_STORY_BOOK, page_id);
458 }
459
460 return CommandCost();
461 }
462
472 CommandCost CmdStoryPageButton(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
473 {
474 StoryPageElementID page_element_id = (StoryPageElementID)GB(p1, 0, 16);
475
476 if (!StoryPageElement::IsValidID(page_element_id)) return CMD_ERROR;
477 const StoryPageElement *const pe = StoryPageElement::Get(page_element_id);
478
479 /* Check the player belongs to the company that owns the page. */
480 const StoryPage *const sp = StoryPage::Get(pe->page);
481 if (sp->company != INVALID_COMPANY && sp->company != _current_company) return CMD_ERROR;
482
483 switch (pe->type) {
484 case SPET_BUTTON_PUSH:
485 /* No validation required */
486 if (flags & DC_EXEC) Game::NewEvent(new ScriptEventStoryPageButtonClick(_current_company, pe->page, page_element_id));
487 break;
488 case SPET_BUTTON_TILE:
489 if (!IsValidTile(tile)) return CMD_ERROR;
490 if (flags & DC_EXEC) Game::NewEvent(new ScriptEventStoryPageTileSelect(_current_company, pe->page, page_element_id, tile));
491 break;
492 case SPET_BUTTON_VEHICLE:
493 if (!Vehicle::IsValidID(p2)) return CMD_ERROR;
494 if (flags & DC_EXEC) Game::NewEvent(new ScriptEventStoryPageVehicleSelect(_current_company, pe->page, page_element_id, (VehicleID)p2));
495 break;
496 default:
497 /* Invalid page element type, not a button. */
498 return CMD_ERROR;
499 }
500
501 return CommandCost();
502 }
503
game.hpp
StoryPageElement::sort_value
uint32 sort_value
A number that increases for every created story page element. Used for sorting. The id of a story pag...
Definition: story_base.h:140
SPET_TEXT
@ SPET_TEXT
A text element.
Definition: story_base.h:31
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:83
InvalidateWindowData
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-...
Definition: window.cpp:3218
Pool::PoolItem<&_story_page_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:337
GB
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
Definition: bitmath_func.hpp:32
command_func.h
CMD_ERROR
static const CommandCost CMD_ERROR
Define a default return value for a failed command.
Definition: command_func.h:23
StoryPageButtonData::GetCursor
StoryPageButtonCursor GetCursor() const
Get the mouse cursor used while waiting for input for the button.
Definition: story.cpp:157
ShowStoryBook
void ShowStoryBook(CompanyID company, uint16 page_id=INVALID_STORY_PAGE)
Raise or create the story book window for company, at page page_id.
Definition: story_gui.cpp:1062
company_base.h
StoryPageButtonFlags
StoryPageButtonFlags
Flags available for buttons.
Definition: story_base.h:45
StoryPageElementType
StoryPageElementType
Definition: story_base.h:30
StoryPageButtonData::SetCursor
void SetCursor(StoryPageButtonCursor cursor)
Set the mouse cursor used while waiting for input for the button.
Definition: story.cpp:132
goal_type.h
Pool::PoolItem::index
Tindex index
Index of this pool item.
Definition: pool_type.hpp:235
SPET_BUTTON_PUSH
@ SPET_BUTTON_PUSH
A push button that triggers an immediate event.
Definition: story_base.h:34
vehicle_base.h
goal_base.h
CmdCreateStoryPageElement
CommandCost CmdCreateStoryPageElement(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Create a new story page element.
Definition: story.cpp:253
SPET_GOAL
@ SPET_GOAL
An element that references a goal.
Definition: story_base.h:33
StoryPage::sort_value
uint32 sort_value
A number that increases for every created story page. Used for sorting. The id of a story page is the...
Definition: story_base.h:160
CmdStoryPageButton
CommandCost CmdStoryPageButton(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Clicked/used a button on a story page.
Definition: story.cpp:472
StoryPageButtonData::SetColour
void SetColour(Colours button_colour)
Set the button background colour.
Definition: story.cpp:120
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:18
DC_EXEC
@ DC_EXEC
execute the given command
Definition: command_type.h:348
DoCommandFlag
DoCommandFlag
List of flags for a command.
Definition: command_type.h:346
StoryPageElement::referenced_id
uint32 referenced_id
Id of referenced object (location, goal etc.)
Definition: story_base.h:144
StoryPageButtonData::ValidateVehicleType
bool ValidateVehicleType() const
Verity that the data stored a valid VehicleType value.
Definition: story.cpp:191
SPET_BUTTON_VEHICLE
@ SPET_BUTTON_VEHICLE
A button that allows the player to select a vehicle, and triggers an event wih the vehicle.
Definition: story_base.h:36
StoryPageButtonData::ValidateCursor
bool ValidateCursor() const
Verify that the data stores a valid StoryPageButtonCursor value.
Definition: story.cpp:185
WC_STORY_BOOK
@ WC_STORY_BOOK
Story book; Window numbers:
Definition: window_type.h:288
tile_map.h
SPET_BUTTON_TILE
@ SPET_BUTTON_TILE
A button that allows the player to select a tile, and triggers an event with the tile.
Definition: story_base.h:35
StoryPageElement::type
StoryPageElementType type
Type of page element.
Definition: story_base.h:142
CommandCost
Common return value for all commands.
Definition: command_type.h:23
cmd_helper.h
_date
Date _date
Current date in days (day counter)
Definition: date.cpp:28
VEH_COMPANY_END
@ VEH_COMPANY_END
Last company-ownable type.
Definition: vehicle_type.h:29
Pool::items
size_t items
Number of used indexes (non-nullptr)
Definition: pool_type.hpp:92
StoryPageID
uint16 StoryPageID
ID of a story page.
Definition: story_type.h:16
StoryPageButtonData::GetVehicleType
VehicleType GetVehicleType() const
Get the type of vehicles that are accepted by the button.
Definition: story.cpp:163
SB
static T SB(T &x, const uint8 s, const uint8 n, const U d)
Set n bits in x starting at bit s to d.
Definition: bitmath_func.hpp:58
Date
int32 Date
The type to store our dates in.
Definition: date_type.h:14
StoryPage
Struct about stories, current and completed.
Definition: story_base.h:159
Game::NewEvent
static void NewEvent(class ScriptEvent *event)
Queue a new event for a Game Script.
Definition: game_core.cpp:141
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:46
safeguards.h
VEH_INVALID
@ VEH_INVALID
Non-existing type of vehicle.
Definition: vehicle_type.h:35
IsValidTile
static bool IsValidTile(TileIndex tile)
Checks if a tile is valid.
Definition: tile_map.h:161
CmdCreateStoryPage
CommandCost CmdCreateStoryPage(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Create a new story page.
Definition: story.cpp:207
StrEmpty
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
Definition: string_func.h:64
SPET_LOCATION
@ SPET_LOCATION
An element that references a tile along with a one-line text.
Definition: story_base.h:32
StoryPageButtonCursor
StoryPageButtonCursor
Mouse cursors usable by story page buttons.
Definition: story_base.h:53
date_func.h
stdafx.h
VehicleType
VehicleType
Available vehicle types.
Definition: vehicle_type.h:21
StoryPage::title
char * title
Title of story page.
Definition: story_base.h:164
CmdShowStoryPage
CommandCost CmdShowStoryPage(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Display a story page for all clients that are allowed to view the story page.
Definition: story.cpp:390
CmdSetStoryPageTitle
CommandCost CmdSetStoryPageTitle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Update title of a story page.
Definition: story.cpp:333
StoryPageButtonData::SetVehicleType
void SetVehicleType(VehicleType vehtype)
Set the type of vehicles that are accepted by the button.
Definition: story.cpp:139
VerifyElementContentParameters
static bool VerifyElementContentParameters(StoryPageID page_id, StoryPageElementType type, TileIndex tile, uint32 reference, const char *text)
This helper for Create/Update PageElement Cmd procedure verifies if the page element parameters are c...
Definition: story.cpp:52
string_func.h
_current_company
CompanyID _current_company
Company currently doing an action.
Definition: company_cmd.cpp:47
Pool::PoolItem<&_story_page_element_pool >::Iterate
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
Definition: pool_type.hpp:386
Pool
Base class for all pools.
Definition: pool_type.hpp:81
Pool::PoolItem<&_story_page_pool >::GetNumItems
static size_t GetNumItems()
Returns number of valid items in the pool.
Definition: pool_type.hpp:367
CmdRemoveStoryPageElement
CommandCost CmdRemoveStoryPageElement(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Remove a story page element.
Definition: story.cpp:445
InvalidateWindowClassesData
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...
Definition: window.cpp:3235
StoryPageElementID
uint16 StoryPageElementID
ID of a story page element.
Definition: story_type.h:15
StoryPageButtonData::GetColour
Colours GetColour() const
Get the button background colour.
Definition: story.cpp:146
Pool::PoolItem<&_story_page_pool >::CanAllocateItem
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
Definition: pool_type.hpp:307
StoryPageElement
Struct about story page elements.
Definition: story_base.h:139
UpdateElement
static void UpdateElement(StoryPageElement &pe, TileIndex tile, uint32 reference, const char *text)
This helper for Create/Update PageElement Cmd procedure updates a page element with new content data.
Definition: story.cpp:96
OWNER_DEITY
@ OWNER_DEITY
The object is owned by a superuser / goal script.
Definition: company_type.h:27
company_func.h
INSTANTIATE_POOL_METHODS
#define INSTANTIATE_POOL_METHODS(name)
Force instantiation of pool methods so we don't get linker errors.
Definition: pool_func.hpp:224
stredup
char * stredup(const char *s, const char *last)
Create a duplicate of the given string.
Definition: string.cpp:137
VehicleID
uint32 VehicleID
The type all our vehicle IDs have.
Definition: vehicle_type.h:16
window_func.h
INVALID_COMPANY
@ INVALID_COMPANY
An invalid company.
Definition: company_type.h:30
StoryPageElement::text
char * text
Static content text of page element.
Definition: story_base.h:145
gui.h
StoryPageButtonData
Helper to construct packed "id" values for button-type StoryPageElement.
Definition: story_base.h:117
CmdUpdateStoryPageElement
CommandCost CmdUpdateStoryPageElement(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Update a new story page element.
Definition: story.cpp:303
Pool::PoolItem<&_goal_pool >::IsValidID
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Definition: pool_type.hpp:326
StoryPageButtonData::ValidateColour
bool ValidateColour() const
Verify that the data stored a valid Colour value.
Definition: story.cpp:169
pool_func.hpp
free
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
Definition: stdafx.h:460
story_base.h
GoalID
uint16 GoalID
ID of a goal.
Definition: goal_type.h:38
WC_MAIN_TOOLBAR
@ WC_MAIN_TOOLBAR
Main toolbar (the long bar at the top); Window numbers:
Definition: window_type.h:50
StoryPage::date
Date date
Date when the page was created.
Definition: story_base.h:161
StoryPage::company
CompanyID company
StoryPage is for a specific company; INVALID_COMPANY if it is global.
Definition: story_base.h:162
CmdRemoveStoryPage
CommandCost CmdRemoveStoryPage(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Remove a story page and associated story page elements.
Definition: story.cpp:412
CmdSetStoryPageDate
CommandCost CmdSetStoryPageDate(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Update date of a story page.
Definition: story.cpp:363
StoryPageElement::page
StoryPageID page
Id of the page which the page element belongs to.
Definition: story_base.h:141