32 uint32 _story_page_element_next_sort_value;
33 uint32 _story_page_next_sort_value;
93 default: NOT_REACHED();
117 if (_story_page_pool.
items == 0) {
119 _story_page_next_sort_value = 0;
135 _new_story_page_id = s->
index;
136 _story_page_next_sort_value++;
161 uint16 element_count = 0;
163 FOR_ALL_STORY_PAGE_ELEMENTS(iter) {
164 if (iter->
page == page_id) element_count++;
166 if (element_count >= 128)
return CMD_ERROR;
173 if (_story_page_element_pool.
items == 0) {
175 _story_page_element_next_sort_value = 0;
179 pe->
sort_value = _story_page_element_next_sort_value;
186 _new_story_page_element_id = pe->
index;
187 _story_page_element_next_sort_value++;
323 FOR_ALL_STORY_PAGE_ELEMENTS(pe) {
Definition of stuff that is very close to a company, like the company struct itself.
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.
CompanyByte _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.
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.
size_t items
Number of used indexes (non-NULL)
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...
CompanyByte company
StoryPage is for a specific company; INVALID_COMPANY if it is global.
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.
#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 bool StrEmpty(const char *s)
Check if a string buffer is empty.
CompanyByte _current_company
Company currently doing an action.
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() ...
An element that references a goal.
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:
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-NULL) 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.
An element that references a tile along with a one-line text.
char * text
Static content text of page element.
StoryPageElementTypeByte type
Type of page element.
Map writing/reading functions for tiles.
Owner
Enum for all companies/owners.
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.
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-...