30 uint32 _story_page_element_next_sort_value;
31 uint32 _story_page_next_sort_value;
91 default: NOT_REACHED();
115 if (_story_page_pool.
items == 0) {
117 _story_page_next_sort_value = 0;
133 _new_story_page_id = s->
index;
134 _story_page_next_sort_value++;
159 uint16 element_count = 0;
161 if (iter->page == page_id) element_count++;
163 if (element_count >= 128)
return CMD_ERROR;
170 if (_story_page_element_pool.
items == 0) {
172 _story_page_element_next_sort_value = 0;
176 pe->
sort_value = _story_page_element_next_sort_value;
183 _new_story_page_element_id = pe->
index;
184 _story_page_element_next_sort_value++;
320 if (pe->page == p->
index) {
Owner
Enum for all companies/owners.
Definition of stuff that is very close to a company, like the company struct itself.
An element that references a tile along with a one-line text.
StoryPageID page
Id of the page which the page element belongs to.
static Titem * Get(size_t index)
Returns Titem with given index.
Functions related to dates.
uint16 GoalID
ID of a goal.
static const CommandCost CMD_ERROR
Define a default return value for a failed command.
uint32 sort_value
A number that increases for every created story page element. Used for sorting. The id of a story pag...
Date date
Date when the page was created.
CommandCost CmdUpdateStoryPageElement(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Update a new story page element.
Tindex index
Index of this pool item.
char * title
Title of story page.
Helper functions to extract data from command parameters.
Common return value for all commands.
Struct about story page elements.
static bool IsValidTile(TileIndex tile)
Checks if a tile is valid.
uint32 referenced_id
Id of referenced object (location, goal etc.)
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...
CommandCost CmdRemoveStoryPage(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Remove a story page and associated story page elements.
Struct about stories, current and completed.
Functions related to low-level strings.
Some methods of Pool are placed here in order to reduce compilation time and binary size...
CommandCost CmdRemoveStoryPageElement(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Remove a story page element.
DoCommandFlag
List of flags for a command.
uint16 StoryPageElementID
ID of a story page element.
Definition of base types and functions in a cross-platform compatible way.
A number of safeguards to prevent using unsafe methods.
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...
char * stredup(const char *s, const char *last)
Create a duplicate of the given string.
StoryPageElementType type
Type of page element.
size_t items
Number of used indexes (non-nullptr)
CommandCost CmdSetStoryPageTitle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Update title of a story page.
uint32 sort_value
A number that increases for every created story page. Used for sorting. The id of a story page is the...
basic types related to goals
CommandCost CmdCreateStoryPageElement(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Create a new story page element.
Base class for all pools.
CommandCost CmdSetStoryPageDate(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Update date of a story page.
An element that references a goal.
#define INSTANTIATE_POOL_METHODS(name)
Force instantiation of pool methods so we don't get linker errors.
execute the given command
Functions related to companies.
CommandCost CmdShowStoryPage(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Display a story page for all clients that are allowed to view the story page.
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...
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
uint32 TileIndex
The index/ID of a Tile.
static size_t GetNumItems()
Returns number of valid items in the pool.
Story book; Window numbers:
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
CommandCost CmdCreateStoryPage(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Create a new story page.
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function() ...
Functions related to commands.
void ShowStoryBook(CompanyID company, uint16 page_id=INVALID_STORY_PAGE)
Raise or create the story book window for company, at page page_id.
Main toolbar (the long bar at the top); Window numbers:
CompanyID _current_company
Company currently doing an action.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
int32 Date
The type to store our dates in.
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
char * text
Static content text of page element.
Map writing/reading functions for tiles.
Window functions not directly related to making/drawing windows.
GUI functions that shouldn't be here.
Date _date
Current date in days (day counter)
uint16 StoryPageID
ID of a story page.
CompanyID company
StoryPage is for a specific company; INVALID_COMPANY if it is global.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
The object is owned by a superuser / goal script.
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-...