Codechange: Un-bitstuff goal and story page commands.

pull/353/head
Michael Lutz 3 years ago
parent 1a42a8a5d5
commit e6e69d5289

@ -36,49 +36,44 @@ INSTANTIATE_POOL_METHODS(Goal)
/** /**
* Create a new goal. * Create a new goal.
* @param flags type of operation * @param flags type of operation
* @param tile unused. * @param company Company for which this goal is.
* @param p1 various bitstuffed elements * @param type GoalType of destination.
* - p1 = (bit 0 - 7) - GoalType of destination. * @param dest GoalTypeID of destination.
* - p1 = (bit 8 - 15) - Company for which this goal is.
* @param p2 GoalTypeID of destination.
* @param text Text of the goal. * @param text Text of the goal.
* @return the cost of this operation or an error * @return the cost of this operation or an error
*/ */
CommandCost CmdCreateGoal(DoCommandFlag flags, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) CommandCost CmdCreateGoal(DoCommandFlag flags, CompanyID company, GoalType type, GoalTypeID dest, const std::string &text)
{ {
if (!Goal::CanAllocateItem()) return CMD_ERROR; if (!Goal::CanAllocateItem()) return CMD_ERROR;
GoalType type = (GoalType)GB(p1, 0, 8);
CompanyID company = (CompanyID)GB(p1, 8, 8);
if (_current_company != OWNER_DEITY) return CMD_ERROR; if (_current_company != OWNER_DEITY) return CMD_ERROR;
if (text.empty()) return CMD_ERROR; if (text.empty()) return CMD_ERROR;
if (company != INVALID_COMPANY && !Company::IsValidID(company)) return CMD_ERROR; if (company != INVALID_COMPANY && !Company::IsValidID(company)) return CMD_ERROR;
switch (type) { switch (type) {
case GT_NONE: case GT_NONE:
if (p2 != 0) return CMD_ERROR; if (dest != 0) return CMD_ERROR;
break; break;
case GT_TILE: case GT_TILE:
if (!IsValidTile(p2)) return CMD_ERROR; if (!IsValidTile(dest)) return CMD_ERROR;
break; break;
case GT_INDUSTRY: case GT_INDUSTRY:
if (!Industry::IsValidID(p2)) return CMD_ERROR; if (!Industry::IsValidID(dest)) return CMD_ERROR;
break; break;
case GT_TOWN: case GT_TOWN:
if (!Town::IsValidID(p2)) return CMD_ERROR; if (!Town::IsValidID(dest)) return CMD_ERROR;
break; break;
case GT_COMPANY: case GT_COMPANY:
if (!Company::IsValidID(p2)) return CMD_ERROR; if (!Company::IsValidID(dest)) return CMD_ERROR;
break; break;
case GT_STORY_PAGE: { case GT_STORY_PAGE: {
if (!StoryPage::IsValidID(p2)) return CMD_ERROR; if (!StoryPage::IsValidID(dest)) return CMD_ERROR;
CompanyID story_company = StoryPage::Get(p2)->company; CompanyID story_company = StoryPage::Get(dest)->company;
if (company == INVALID_COMPANY ? story_company != INVALID_COMPANY : story_company != INVALID_COMPANY && story_company != company) return CMD_ERROR; if (company == INVALID_COMPANY ? story_company != INVALID_COMPANY : story_company != INVALID_COMPANY && story_company != company) return CMD_ERROR;
break; break;
} }
@ -89,7 +84,7 @@ CommandCost CmdCreateGoal(DoCommandFlag flags, TileIndex tile, uint32 p1, uint32
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
Goal *g = new Goal(); Goal *g = new Goal();
g->type = type; g->type = type;
g->dst = p2; g->dst = dest;
g->company = company; g->company = company;
g->text = stredup(text.c_str()); g->text = stredup(text.c_str());
g->progress = nullptr; g->progress = nullptr;
@ -111,19 +106,16 @@ CommandCost CmdCreateGoal(DoCommandFlag flags, TileIndex tile, uint32 p1, uint32
/** /**
* Remove a goal. * Remove a goal.
* @param flags type of operation * @param flags type of operation
* @param tile unused. * @param goal GoalID to remove.
* @param p1 GoalID to remove.
* @param p2 unused.
* @param text unused.
* @return the cost of this operation or an error * @return the cost of this operation or an error
*/ */
CommandCost CmdRemoveGoal(DoCommandFlag flags, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) CommandCost CmdRemoveGoal(DoCommandFlag flags, GoalID goal)
{ {
if (_current_company != OWNER_DEITY) return CMD_ERROR; if (_current_company != OWNER_DEITY) return CMD_ERROR;
if (!Goal::IsValidID(p1)) return CMD_ERROR; if (!Goal::IsValidID(goal)) return CMD_ERROR;
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
Goal *g = Goal::Get(p1); Goal *g = Goal::Get(goal);
CompanyID c = g->company; CompanyID c = g->company;
delete g; delete g;
@ -141,20 +133,18 @@ CommandCost CmdRemoveGoal(DoCommandFlag flags, TileIndex tile, uint32 p1, uint32
/** /**
* Update goal text of a goal. * Update goal text of a goal.
* @param flags type of operation * @param flags type of operation
* @param tile unused. * @param goal GoalID to update.
* @param p1 GoalID to update.
* @param p2 unused
* @param text Text of the goal. * @param text Text of the goal.
* @return the cost of this operation or an error * @return the cost of this operation or an error
*/ */
CommandCost CmdSetGoalText(DoCommandFlag flags, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) CommandCost CmdSetGoalText(DoCommandFlag flags, GoalID goal, const std::string &text)
{ {
if (_current_company != OWNER_DEITY) return CMD_ERROR; if (_current_company != OWNER_DEITY) return CMD_ERROR;
if (!Goal::IsValidID(p1)) return CMD_ERROR; if (!Goal::IsValidID(goal)) return CMD_ERROR;
if (text.empty()) return CMD_ERROR; if (text.empty()) return CMD_ERROR;
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
Goal *g = Goal::Get(p1); Goal *g = Goal::Get(goal);
free(g->text); free(g->text);
g->text = stredup(text.c_str()); g->text = stredup(text.c_str());
@ -171,19 +161,17 @@ CommandCost CmdSetGoalText(DoCommandFlag flags, TileIndex tile, uint32 p1, uint3
/** /**
* Update progress text of a goal. * Update progress text of a goal.
* @param flags type of operation * @param flags type of operation
* @param tile unused. * @param goal GoalID to update.
* @param p1 GoalID to update.
* @param p2 unused
* @param text Progress text of the goal. * @param text Progress text of the goal.
* @return the cost of this operation or an error * @return the cost of this operation or an error
*/ */
CommandCost CmdSetGoalProgress(DoCommandFlag flags, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) CommandCost CmdSetGoalProgress(DoCommandFlag flags, GoalID goal, const std::string &text)
{ {
if (_current_company != OWNER_DEITY) return CMD_ERROR; if (_current_company != OWNER_DEITY) return CMD_ERROR;
if (!Goal::IsValidID(p1)) return CMD_ERROR; if (!Goal::IsValidID(goal)) return CMD_ERROR;
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
Goal *g = Goal::Get(p1); Goal *g = Goal::Get(goal);
free(g->progress); free(g->progress);
if (text.empty()) { if (text.empty()) {
g->progress = nullptr; g->progress = nullptr;
@ -204,20 +192,18 @@ CommandCost CmdSetGoalProgress(DoCommandFlag flags, TileIndex tile, uint32 p1, u
/** /**
* Update completed state of a goal. * Update completed state of a goal.
* @param flags type of operation * @param flags type of operation
* @param tile unused. * @param goal GoalID to update.
* @param p1 GoalID to update. * @param completed completed state of goal.
* @param p2 completed state. If goal is completed, set to 1, otherwise 0.
* @param text unused
* @return the cost of this operation or an error * @return the cost of this operation or an error
*/ */
CommandCost CmdSetGoalCompleted(DoCommandFlag flags, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) CommandCost CmdSetGoalCompleted(DoCommandFlag flags, GoalID goal, bool completed)
{ {
if (_current_company != OWNER_DEITY) return CMD_ERROR; if (_current_company != OWNER_DEITY) return CMD_ERROR;
if (!Goal::IsValidID(p1)) return CMD_ERROR; if (!Goal::IsValidID(goal)) return CMD_ERROR;
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
Goal *g = Goal::Get(p1); Goal *g = Goal::Get(goal);
g->completed = p2 == 1; g->completed = completed;
if (g->company == INVALID_COMPANY) { if (g->company == INVALID_COMPANY) {
InvalidateWindowClassesData(WC_GOALS_LIST); InvalidateWindowClassesData(WC_GOALS_LIST);
@ -232,27 +218,21 @@ CommandCost CmdSetGoalCompleted(DoCommandFlag flags, TileIndex tile, uint32 p1,
/** /**
* Ask a goal related question * Ask a goal related question
* @param flags type of operation * @param flags type of operation
* @param tile unused. * @param uniqueid Unique ID to use for this question.
* @param p1 various bitstuffed elements * @param target Company or client for which this question is.
* - p1 = (bit 0 - 15) - Unique ID to use for this question. * @param is_client Question target: false - company, true - client.
* - p1 = (bit 16 - 31) - Company or client for which this question is. * @param button_mask Buttons of the question.
* @param p2 various bitstuffed elements * @param type Question type.
* - p2 = (bit 0 - 17) - Buttons of the question.
* - p2 = (bit 29 - 30) - Question type.
* - p2 = (bit 31) - Question target: 0 - company, 1 - client.
* @param text Text of the question. * @param text Text of the question.
* @return the cost of this operation or an error * @return the cost of this operation or an error
*/ */
CommandCost CmdGoalQuestion(DoCommandFlag flags, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) CommandCost CmdGoalQuestion(DoCommandFlag flags, uint16 uniqueid, uint16 target, bool is_client, uint32 button_mask, GoalQuestionType type, const std::string &text)
{ {
uint16 uniqueid = (uint16)GB(p1, 0, 16); CompanyID company = (CompanyID)target;
CompanyID company = (CompanyID)GB(p1, 16, 8); ClientID client = (ClientID)target;
ClientID client = (ClientID)GB(p1, 16, 16);
static_assert(GOAL_QUESTION_BUTTON_COUNT < 29); static_assert(GOAL_QUESTION_BUTTON_COUNT < 29);
uint32 button_mask = GB(p2, 0, GOAL_QUESTION_BUTTON_COUNT); button_mask &= (1U << GOAL_QUESTION_BUTTON_COUNT) - 1;
byte type = GB(p2, 29, 2);
bool is_client = HasBit(p2, 31);
if (_current_company != OWNER_DEITY) return CMD_ERROR; if (_current_company != OWNER_DEITY) return CMD_ERROR;
if (text.empty()) return CMD_ERROR; if (text.empty()) return CMD_ERROR;
@ -284,31 +264,28 @@ CommandCost CmdGoalQuestion(DoCommandFlag flags, TileIndex tile, uint32 p1, uint
/** /**
* Reply to a goal question. * Reply to a goal question.
* @param flags type of operation * @param flags type of operation
* @param tile unused. * @param uniqueid Unique ID to use for this question.
* @param p1 Unique ID to use for this question. * @param button Button the company pressed
* @param p2 Button the company pressed
* @param text Text of the question.
* @return the cost of this operation or an error * @return the cost of this operation or an error
*/ */
CommandCost CmdGoalQuestionAnswer(DoCommandFlag flags, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) CommandCost CmdGoalQuestionAnswer(DoCommandFlag flags, uint16 uniqueid, uint8 button)
{ {
if (p1 > UINT16_MAX) return CMD_ERROR; if (button >= GOAL_QUESTION_BUTTON_COUNT) return CMD_ERROR;
if (p2 >= GOAL_QUESTION_BUTTON_COUNT) return CMD_ERROR;
if (_current_company == OWNER_DEITY) { if (_current_company == OWNER_DEITY) {
/* It has been requested to close this specific question on all clients */ /* It has been requested to close this specific question on all clients */
if (flags & DC_EXEC) CloseWindowById(WC_GOAL_QUESTION, p1); if (flags & DC_EXEC) CloseWindowById(WC_GOAL_QUESTION, uniqueid);
return CommandCost(); return CommandCost();
} }
if (_networking && _local_company == _current_company) { if (_networking && _local_company == _current_company) {
/* Somebody in the same company answered the question. Close the window */ /* Somebody in the same company answered the question. Close the window */
if (flags & DC_EXEC) CloseWindowById(WC_GOAL_QUESTION, p1); if (flags & DC_EXEC) CloseWindowById(WC_GOAL_QUESTION, uniqueid);
if (!_network_server) return CommandCost(); if (!_network_server) return CommandCost();
} }
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
Game::NewEvent(new ScriptEventGoalQuestionAnswer(p1, (ScriptCompany::CompanyID)(byte)_current_company, (ScriptGoal::QuestionButton)(1 << p2))); Game::NewEvent(new ScriptEventGoalQuestionAnswer(uniqueid, (ScriptCompany::CompanyID)(byte)_current_company, (ScriptGoal::QuestionButton)(1 << button)));
} }
return CommandCost(); return CommandCost();

@ -11,14 +11,16 @@
#define GOAL_CMD_H #define GOAL_CMD_H
#include "command_type.h" #include "command_type.h"
#include "command_type.h"
#include "goal_type.h"
CommandProc CmdCreateGoal; CommandCost CmdCreateGoal(DoCommandFlag flags, CompanyID company, GoalType type, GoalTypeID dest, const std::string &text);
CommandProc CmdRemoveGoal; CommandCost CmdRemoveGoal(DoCommandFlag flags, GoalID goal);
CommandProc CmdSetGoalText; CommandCost CmdSetGoalText(DoCommandFlag flags, GoalID goal, const std::string &text);
CommandProc CmdSetGoalProgress; CommandCost CmdSetGoalProgress(DoCommandFlag flags, GoalID goal, const std::string &text);
CommandProc CmdSetGoalCompleted; CommandCost CmdSetGoalCompleted(DoCommandFlag flags, GoalID goal, bool completed);
CommandProc CmdGoalQuestion; CommandCost CmdGoalQuestion(DoCommandFlag flags, uint16 uniqueid, uint16 target, bool is_client, uint32 button_mask, GoalQuestionType type, const std::string &text);
CommandProc CmdGoalQuestionAnswer; CommandCost CmdGoalQuestionAnswer(DoCommandFlag flags, uint16 uniqueid, uint8 button);
DEF_CMD_TRAIT(CMD_CREATE_GOAL, CmdCreateGoal, CMD_DEITY | CMD_STR_CTRL, CMDT_OTHER_MANAGEMENT) DEF_CMD_TRAIT(CMD_CREATE_GOAL, CmdCreateGoal, CMD_DEITY | CMD_STR_CTRL, CMDT_OTHER_MANAGEMENT)
DEF_CMD_TRAIT(CMD_REMOVE_GOAL, CmdRemoveGoal, CMD_DEITY, CMDT_OTHER_MANAGEMENT) DEF_CMD_TRAIT(CMD_REMOVE_GOAL, CmdRemoveGoal, CMD_DEITY, CMDT_OTHER_MANAGEMENT)

@ -383,17 +383,17 @@ struct GoalQuestionWindow : public Window {
{ {
switch (widget) { switch (widget) {
case WID_GQ_BUTTON_1: case WID_GQ_BUTTON_1:
Command<CMD_GOAL_QUESTION_ANSWER>::Post(0, this->window_number, this->button[0], {}); Command<CMD_GOAL_QUESTION_ANSWER>::Post(this->window_number, this->button[0]);
this->Close(); this->Close();
break; break;
case WID_GQ_BUTTON_2: case WID_GQ_BUTTON_2:
Command<CMD_GOAL_QUESTION_ANSWER>::Post(0, this->window_number, this->button[1], {}); Command<CMD_GOAL_QUESTION_ANSWER>::Post(this->window_number, this->button[1]);
this->Close(); this->Close();
break; break;
case WID_GQ_BUTTON_3: case WID_GQ_BUTTON_3:
Command<CMD_GOAL_QUESTION_ANSWER>::Post(0, this->window_number, this->button[2], {}); Command<CMD_GOAL_QUESTION_ANSWER>::Post(this->window_number, this->button[2]);
this->Close(); this->Close();
break; break;
} }

@ -38,7 +38,7 @@
EnforcePreconditionEncodedText(GOAL_INVALID, text); EnforcePreconditionEncodedText(GOAL_INVALID, text);
EnforcePrecondition(GOAL_INVALID, company == ScriptCompany::COMPANY_INVALID || ScriptCompany::ResolveCompanyID(company) != ScriptCompany::COMPANY_INVALID); EnforcePrecondition(GOAL_INVALID, company == ScriptCompany::COMPANY_INVALID || ScriptCompany::ResolveCompanyID(company) != ScriptCompany::COMPANY_INVALID);
uint8 c = company; CompanyID c = (::CompanyID)company;
if (company == ScriptCompany::COMPANY_INVALID) c = INVALID_COMPANY; if (company == ScriptCompany::COMPANY_INVALID) c = INVALID_COMPANY;
StoryPage *story_page = nullptr; StoryPage *story_page = nullptr;
if (type == GT_STORY_PAGE && ScriptStoryPage::IsValidStoryPage((ScriptStoryPage::StoryPageID)destination)) story_page = ::StoryPage::Get((ScriptStoryPage::StoryPageID)destination); if (type == GT_STORY_PAGE && ScriptStoryPage::IsValidStoryPage((ScriptStoryPage::StoryPageID)destination)) story_page = ::StoryPage::Get((ScriptStoryPage::StoryPageID)destination);
@ -50,7 +50,7 @@
(type == GT_COMPANY && ScriptCompany::ResolveCompanyID((ScriptCompany::CompanyID)destination) != ScriptCompany::COMPANY_INVALID) || (type == GT_COMPANY && ScriptCompany::ResolveCompanyID((ScriptCompany::CompanyID)destination) != ScriptCompany::COMPANY_INVALID) ||
(type == GT_STORY_PAGE && story_page != nullptr && (c == INVALID_COMPANY ? story_page->company == INVALID_COMPANY : story_page->company == INVALID_COMPANY || story_page->company == c))); (type == GT_STORY_PAGE && story_page != nullptr && (c == INVALID_COMPANY ? story_page->company == INVALID_COMPANY : story_page->company == INVALID_COMPANY || story_page->company == c)));
if (!ScriptObject::Command<CMD_CREATE_GOAL>::Do(&ScriptInstance::DoCommandReturnGoalID, 0, type | (c << 8), destination, text)) return GOAL_INVALID; if (!ScriptObject::Command<CMD_CREATE_GOAL>::Do(&ScriptInstance::DoCommandReturnGoalID, c, (::GoalType)type, destination, text)) return GOAL_INVALID;
/* In case of test-mode, we return GoalID 0 */ /* In case of test-mode, we return GoalID 0 */
return (ScriptGoal::GoalID)0; return (ScriptGoal::GoalID)0;
@ -61,7 +61,7 @@
EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY); EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY);
EnforcePrecondition(false, IsValidGoal(goal_id)); EnforcePrecondition(false, IsValidGoal(goal_id));
return ScriptObject::Command<CMD_REMOVE_GOAL>::Do(0, goal_id, 0, {}); return ScriptObject::Command<CMD_REMOVE_GOAL>::Do(goal_id);
} }
/* static */ bool ScriptGoal::SetText(GoalID goal_id, Text *goal) /* static */ bool ScriptGoal::SetText(GoalID goal_id, Text *goal)
@ -73,7 +73,7 @@
EnforcePrecondition(false, goal != nullptr); EnforcePrecondition(false, goal != nullptr);
EnforcePrecondition(false, !StrEmpty(goal->GetEncodedText())); EnforcePrecondition(false, !StrEmpty(goal->GetEncodedText()));
return ScriptObject::Command<CMD_SET_GOAL_TEXT>::Do(0, goal_id, 0, goal->GetEncodedText()); return ScriptObject::Command<CMD_SET_GOAL_TEXT>::Do(goal_id, goal->GetEncodedText());
} }
/* static */ bool ScriptGoal::SetProgress(GoalID goal_id, Text *progress) /* static */ bool ScriptGoal::SetProgress(GoalID goal_id, Text *progress)
@ -88,7 +88,7 @@
progress = nullptr; progress = nullptr;
} }
return ScriptObject::Command<CMD_SET_GOAL_PROGRESS>::Do(0, goal_id, 0, progress != nullptr ? std::string{ progress->GetEncodedText() } : std::string{}); return ScriptObject::Command<CMD_SET_GOAL_PROGRESS>::Do(goal_id, progress != nullptr ? std::string{ progress->GetEncodedText() } : std::string{});
} }
/* static */ bool ScriptGoal::SetCompleted(GoalID goal_id, bool completed) /* static */ bool ScriptGoal::SetCompleted(GoalID goal_id, bool completed)
@ -96,7 +96,7 @@
EnforcePrecondition(false, IsValidGoal(goal_id)); EnforcePrecondition(false, IsValidGoal(goal_id));
EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY); EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY);
return ScriptObject::Command<CMD_SET_GOAL_COMPLETED>::Do(0, goal_id, completed ? 1 : 0, {}); return ScriptObject::Command<CMD_SET_GOAL_COMPLETED>::Do(goal_id, completed);
} }
/* static */ bool ScriptGoal::IsCompleted(GoalID goal_id) /* static */ bool ScriptGoal::IsCompleted(GoalID goal_id)
@ -121,7 +121,7 @@
EnforcePrecondition(false, buttons < (1 << ::GOAL_QUESTION_BUTTON_COUNT)); EnforcePrecondition(false, buttons < (1 << ::GOAL_QUESTION_BUTTON_COUNT));
EnforcePrecondition(false, (int)type < ::GQT_END); EnforcePrecondition(false, (int)type < ::GQT_END);
return ScriptObject::Command<CMD_GOAL_QUESTION>::Do(0, uniqueid | (target << 16), buttons | (type << 29) | (is_client ? (1 << 31) : 0), text); return ScriptObject::Command<CMD_GOAL_QUESTION>::Do(uniqueid, target, is_client, buttons, (::GoalQuestionType)type, text);
} }
/* static */ bool ScriptGoal::Question(uint16 uniqueid, ScriptCompany::CompanyID company, Text *question, QuestionType type, int buttons) /* static */ bool ScriptGoal::Question(uint16 uniqueid, ScriptCompany::CompanyID company, Text *question, QuestionType type, int buttons)
@ -146,5 +146,5 @@
{ {
EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY); EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY);
return ScriptObject::Command<CMD_GOAL_QUESTION_ANSWER>::Do(0, uniqueid, 0, {}); return ScriptObject::Command<CMD_GOAL_QUESTION_ANSWER>::Do(uniqueid, 0);
} }

@ -49,10 +49,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type)
if (company == ScriptCompany::COMPANY_INVALID) c = INVALID_COMPANY; if (company == ScriptCompany::COMPANY_INVALID) c = INVALID_COMPANY;
if (!ScriptObject::Command<CMD_CREATE_STORY_PAGE>::Do(&ScriptInstance::DoCommandReturnStoryPageID, if (!ScriptObject::Command<CMD_CREATE_STORY_PAGE>::Do(&ScriptInstance::DoCommandReturnStoryPageID,
0, (::CompanyID)c, title != nullptr ? std::string{ title->GetEncodedText() } : std::string{})) return STORY_PAGE_INVALID;
c,
0,
title != nullptr ? std::string{ title->GetEncodedText() } : std::string{})) return STORY_PAGE_INVALID;
/* In case of test-mode, we return StoryPageID 0 */ /* In case of test-mode, we return StoryPageID 0 */
return (ScriptStoryPage::StoryPageID)0; return (ScriptStoryPage::StoryPageID)0;
@ -91,7 +88,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type)
if (!ScriptObject::Command<CMD_CREATE_STORY_PAGE_ELEMENT>::Do(&ScriptInstance::DoCommandReturnStoryPageElementID, if (!ScriptObject::Command<CMD_CREATE_STORY_PAGE_ELEMENT>::Do(&ScriptInstance::DoCommandReturnStoryPageElementID,
reftile, reftile,
story_page_id + (type << 16), (::StoryPageID)story_page_id, (::StoryPageElementType)type,
refid, refid,
StoryPageElementTypeRequiresText(btype) ? std::string{ text->GetEncodedText() } : std::string{})) return STORY_PAGE_ELEMENT_INVALID; StoryPageElementTypeRequiresText(btype) ? std::string{ text->GetEncodedText() } : std::string{})) return STORY_PAGE_ELEMENT_INVALID;
@ -160,7 +157,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type)
EnforcePrecondition(false, IsValidStoryPage(story_page_id)); EnforcePrecondition(false, IsValidStoryPage(story_page_id));
EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY); EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY);
return ScriptObject::Command<CMD_SET_STORY_PAGE_TITLE>::Do(0, story_page_id, 0, title != nullptr ? std::string{ title->GetEncodedText() } : std::string{}); return ScriptObject::Command<CMD_SET_STORY_PAGE_TITLE>::Do(story_page_id, title != nullptr ? std::string{ title->GetEncodedText() } : std::string{});
} }
/* static */ ScriptCompany::CompanyID ScriptStoryPage::GetCompany(StoryPageID story_page_id) /* static */ ScriptCompany::CompanyID ScriptStoryPage::GetCompany(StoryPageID story_page_id)
@ -186,7 +183,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type)
EnforcePrecondition(false, IsValidStoryPage(story_page_id)); EnforcePrecondition(false, IsValidStoryPage(story_page_id));
EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY); EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY);
return ScriptObject::Command<CMD_SET_STORY_PAGE_DATE>::Do(0, story_page_id, date, {}); return ScriptObject::Command<CMD_SET_STORY_PAGE_DATE>::Do(story_page_id, date);
} }
@ -195,7 +192,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type)
EnforcePrecondition(false, IsValidStoryPage(story_page_id)); EnforcePrecondition(false, IsValidStoryPage(story_page_id));
EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY); EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY);
return ScriptObject::Command<CMD_SHOW_STORY_PAGE>::Do(0, story_page_id, 0, {}); return ScriptObject::Command<CMD_SHOW_STORY_PAGE>::Do(story_page_id);
} }
/* static */ bool ScriptStoryPage::Remove(StoryPageID story_page_id) /* static */ bool ScriptStoryPage::Remove(StoryPageID story_page_id)
@ -203,7 +200,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type)
EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY); EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY);
EnforcePrecondition(false, IsValidStoryPage(story_page_id)); EnforcePrecondition(false, IsValidStoryPage(story_page_id));
return ScriptObject::Command<CMD_REMOVE_STORY_PAGE>::Do(0, story_page_id, 0, {}); return ScriptObject::Command<CMD_REMOVE_STORY_PAGE>::Do(story_page_id);
} }
/* static */ bool ScriptStoryPage::RemoveElement(StoryPageElementID story_page_element_id) /* static */ bool ScriptStoryPage::RemoveElement(StoryPageElementID story_page_element_id)
@ -211,7 +208,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type)
EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY); EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY);
EnforcePrecondition(false, IsValidStoryPageElement(story_page_element_id)); EnforcePrecondition(false, IsValidStoryPageElement(story_page_element_id));
return ScriptObject::Command<CMD_REMOVE_STORY_PAGE_ELEMENT>::Do(0, story_page_element_id, 0, {}); return ScriptObject::Command<CMD_REMOVE_STORY_PAGE_ELEMENT>::Do(story_page_element_id);
} }
/* static */ ScriptStoryPage::StoryPageButtonFormatting ScriptStoryPage::MakePushButtonReference(StoryPageButtonColour colour, StoryPageButtonFlags flags) /* static */ ScriptStoryPage::StoryPageButtonFormatting ScriptStoryPage::MakePushButtonReference(StoryPageButtonColour colour, StoryPageButtonFlags flags)

@ -198,19 +198,14 @@ bool StoryPageButtonData::ValidateVehicleType() const
/** /**
* Create a new story page. * Create a new story page.
* @param flags type of operation * @param flags type of operation
* @param tile unused. * @param company Company for which this story page belongs to.
* @param p1 various bitstuffed elements
* - p1 = (bit 0 - 7) - Company for which this story page belongs to.
* @param p2 unused.
* @param text Title of the story page. Null is allowed in which case a generic page title is provided by OpenTTD. * @param text Title of the story page. Null is allowed in which case a generic page title is provided by OpenTTD.
* @return the cost of this operation or an error * @return the cost of this operation or an error
*/ */
CommandCost CmdCreateStoryPage(DoCommandFlag flags, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) CommandCost CmdCreateStoryPage(DoCommandFlag flags, CompanyID company, const std::string &text)
{ {
if (!StoryPage::CanAllocateItem()) return CMD_ERROR; if (!StoryPage::CanAllocateItem()) return CMD_ERROR;
CompanyID company = (CompanyID)GB(p1, 0, 8);
if (_current_company != OWNER_DEITY) return CMD_ERROR; if (_current_company != OWNER_DEITY) return CMD_ERROR;
if (company != INVALID_COMPANY && !Company::IsValidID(company)) return CMD_ERROR; if (company != INVALID_COMPANY && !Company::IsValidID(company)) return CMD_ERROR;
@ -244,20 +239,16 @@ CommandCost CmdCreateStoryPage(DoCommandFlag flags, TileIndex tile, uint32 p1, u
* Create a new story page element. * Create a new story page element.
* @param flags type of operation * @param flags type of operation
* @param tile Tile location if it is a location page element, otherwise unused. * @param tile Tile location if it is a location page element, otherwise unused.
* @param p1 various bitstuffed elements * @param page_id The page which the element belongs to.
* - p1 = (bit 0 - 15) - The page which the element belongs to. * @param type Page element type
* (bit 16 - 23) - Page element type * @param reference Id of referenced object
* @param p2 Id of referenced object
* @param text Text content in case it is a text or location page element * @param text Text content in case it is a text or location page element
* @return the cost of this operation or an error * @return the cost of this operation or an error
*/ */
CommandCost CmdCreateStoryPageElement(DoCommandFlag flags, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) CommandCost CmdCreateStoryPageElement(DoCommandFlag flags, TileIndex tile, StoryPageID page_id, StoryPageElementType type, uint32 reference, const std::string &text)
{ {
if (!StoryPageElement::CanAllocateItem()) return CMD_ERROR; if (!StoryPageElement::CanAllocateItem()) return CMD_ERROR;
StoryPageID page_id = (StoryPageID)GB(p1, 0, 16);
StoryPageElementType type = Extract<StoryPageElementType, 16, 8>(p1);
/* Allow at most 128 elements per page. */ /* Allow at most 128 elements per page. */
uint16 element_count = 0; uint16 element_count = 0;
for (StoryPageElement *iter : StoryPageElement::Iterate()) { for (StoryPageElement *iter : StoryPageElement::Iterate()) {
@ -267,7 +258,7 @@ CommandCost CmdCreateStoryPageElement(DoCommandFlag flags, TileIndex tile, uint3
if (_current_company != OWNER_DEITY) return CMD_ERROR; if (_current_company != OWNER_DEITY) return CMD_ERROR;
if (!StoryPage::IsValidID(page_id)) return CMD_ERROR; if (!StoryPage::IsValidID(page_id)) return CMD_ERROR;
if (!VerifyElementContentParameters(page_id, type, tile, p2, text.c_str())) return CMD_ERROR; if (!VerifyElementContentParameters(page_id, type, tile, reference, text.c_str())) return CMD_ERROR;
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
if (_story_page_element_pool.items == 0) { if (_story_page_element_pool.items == 0) {
@ -279,7 +270,7 @@ CommandCost CmdCreateStoryPageElement(DoCommandFlag flags, TileIndex tile, uint3
pe->sort_value = _story_page_element_next_sort_value; pe->sort_value = _story_page_element_next_sort_value;
pe->type = type; pe->type = type;
pe->page = page_id; pe->page = page_id;
UpdateElement(*pe, tile, p2, text.c_str()); UpdateElement(*pe, tile, reference, text.c_str());
InvalidateWindowClassesData(WC_STORY_BOOK, page_id); InvalidateWindowClassesData(WC_STORY_BOOK, page_id);
@ -294,17 +285,13 @@ CommandCost CmdCreateStoryPageElement(DoCommandFlag flags, TileIndex tile, uint3
* Update a new story page element. * Update a new story page element.
* @param flags type of operation * @param flags type of operation
* @param tile Tile location if it is a location page element, otherwise unused. * @param tile Tile location if it is a location page element, otherwise unused.
* @param p1 various bitstuffed elements * @param page_element_id The page element to update.
* - p1 = (bit 0 - 15) - The page element to update. * @param reference Id of referenced object
* (bit 16 - 31) - unused
* @param p2 Id of referenced object
* @param text Text content in case it is a text or location page element * @param text Text content in case it is a text or location page element
* @return the cost of this operation or an error * @return the cost of this operation or an error
*/ */
CommandCost CmdUpdateStoryPageElement(DoCommandFlag flags, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) CommandCost CmdUpdateStoryPageElement(DoCommandFlag flags, TileIndex tile, StoryPageElementID page_element_id, uint32 reference, const std::string &text)
{ {
StoryPageElementID page_element_id = (StoryPageElementID)GB(p1, 0, 16);
if (_current_company != OWNER_DEITY) return CMD_ERROR; if (_current_company != OWNER_DEITY) return CMD_ERROR;
if (!StoryPageElement::IsValidID(page_element_id)) return CMD_ERROR; if (!StoryPageElement::IsValidID(page_element_id)) return CMD_ERROR;
@ -312,10 +299,10 @@ CommandCost CmdUpdateStoryPageElement(DoCommandFlag flags, TileIndex tile, uint3
StoryPageID page_id = pe->page; StoryPageID page_id = pe->page;
StoryPageElementType type = pe->type; StoryPageElementType type = pe->type;
if (!VerifyElementContentParameters(page_id, type, tile, p2, text.c_str())) return CMD_ERROR; if (!VerifyElementContentParameters(page_id, type, tile, reference, text.c_str())) return CMD_ERROR;
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
UpdateElement(*pe, tile, p2, text.c_str()); UpdateElement(*pe, tile, reference, text.c_str());
InvalidateWindowClassesData(WC_STORY_BOOK, pe->page); InvalidateWindowClassesData(WC_STORY_BOOK, pe->page);
} }
@ -325,16 +312,13 @@ CommandCost CmdUpdateStoryPageElement(DoCommandFlag flags, TileIndex tile, uint3
/** /**
* Update title of a story page. * Update title of a story page.
* @param flags type of operation * @param flags type of operation
* @param tile unused. * @param page_id StoryPageID to update.
* @param p1 = (bit 0 - 15) - StoryPageID to update.
* @param p2 unused
* @param text title text of the story page. * @param text title text of the story page.
* @return the cost of this operation or an error * @return the cost of this operation or an error
*/ */
CommandCost CmdSetStoryPageTitle(DoCommandFlag flags, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) CommandCost CmdSetStoryPageTitle(DoCommandFlag flags, StoryPageID page_id, const std::string &text)
{ {
if (_current_company != OWNER_DEITY) return CMD_ERROR; if (_current_company != OWNER_DEITY) return CMD_ERROR;
StoryPageID page_id = (StoryPageID)GB(p1, 0, 16);
if (!StoryPage::IsValidID(page_id)) return CMD_ERROR; if (!StoryPage::IsValidID(page_id)) return CMD_ERROR;
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
@ -355,18 +339,14 @@ CommandCost CmdSetStoryPageTitle(DoCommandFlag flags, TileIndex tile, uint32 p1,
/** /**
* Update date of a story page. * Update date of a story page.
* @param flags type of operation * @param flags type of operation
* @param tile unused. * @param page_id StoryPageID to update.
* @param p1 = (bit 0 - 15) - StoryPageID to update. * @param date date
* @param p2 = (bit 0 - 31) - date
* @param text unused
* @return the cost of this operation or an error * @return the cost of this operation or an error
*/ */
CommandCost CmdSetStoryPageDate(DoCommandFlag flags, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) CommandCost CmdSetStoryPageDate(DoCommandFlag flags, StoryPageID page_id, Date date)
{ {
if (_current_company != OWNER_DEITY) return CMD_ERROR; if (_current_company != OWNER_DEITY) return CMD_ERROR;
StoryPageID page_id = (StoryPageID)GB(p1, 0, 16);
if (!StoryPage::IsValidID(page_id)) return CMD_ERROR; if (!StoryPage::IsValidID(page_id)) return CMD_ERROR;
Date date = (Date)p2;
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
StoryPage *p = StoryPage::Get(page_id); StoryPage *p = StoryPage::Get(page_id);
@ -382,16 +362,12 @@ CommandCost CmdSetStoryPageDate(DoCommandFlag flags, TileIndex tile, uint32 p1,
* Display a story page for all clients that are allowed to * Display a story page for all clients that are allowed to
* view the story page. * view the story page.
* @param flags type of operation * @param flags type of operation
* @param tile unused. * @param page_id StoryPageID to show.
* @param p1 = (bit 0 - 15) - StoryPageID to show.
* @param p2 unused
* @param text unused
* @return the cost of this operation or an error * @return the cost of this operation or an error
*/ */
CommandCost CmdShowStoryPage(DoCommandFlag flags, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) CommandCost CmdShowStoryPage(DoCommandFlag flags, StoryPageID page_id)
{ {
if (_current_company != OWNER_DEITY) return CMD_ERROR; if (_current_company != OWNER_DEITY) return CMD_ERROR;
StoryPageID page_id = (StoryPageID)GB(p1, 0, 16);
if (!StoryPage::IsValidID(page_id)) return CMD_ERROR; if (!StoryPage::IsValidID(page_id)) return CMD_ERROR;
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
@ -404,16 +380,12 @@ CommandCost CmdShowStoryPage(DoCommandFlag flags, TileIndex tile, uint32 p1, uin
/** /**
* Remove a story page and associated story page elements. * Remove a story page and associated story page elements.
* @param flags type of operation * @param flags type of operation
* @param tile unused. * @param page_id StoryPageID to remove.
* @param p1 = (bit 0 - 15) - StoryPageID to remove.
* @param p2 unused.
* @param text unused.
* @return the cost of this operation or an error * @return the cost of this operation or an error
*/ */
CommandCost CmdRemoveStoryPage(DoCommandFlag flags, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) CommandCost CmdRemoveStoryPage(DoCommandFlag flags, StoryPageID page_id)
{ {
if (_current_company != OWNER_DEITY) return CMD_ERROR; if (_current_company != OWNER_DEITY) return CMD_ERROR;
StoryPageID page_id = (StoryPageID)p1;
if (!StoryPage::IsValidID(page_id)) return CMD_ERROR; if (!StoryPage::IsValidID(page_id)) return CMD_ERROR;
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
@ -437,16 +409,12 @@ CommandCost CmdRemoveStoryPage(DoCommandFlag flags, TileIndex tile, uint32 p1, u
/** /**
* Remove a story page element * Remove a story page element
* @param flags type of operation * @param flags type of operation
* @param tile unused. * @param page_element_id StoryPageElementID to remove.
* @param p1 = (bit 0 - 15) - StoryPageElementID to remove.
* @param p2 unused.
* @param text unused.
* @return the cost of this operation or an error * @return the cost of this operation or an error
*/ */
CommandCost CmdRemoveStoryPageElement(DoCommandFlag flags, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) CommandCost CmdRemoveStoryPageElement(DoCommandFlag flags, StoryPageElementID page_element_id)
{ {
if (_current_company != OWNER_DEITY) return CMD_ERROR; if (_current_company != OWNER_DEITY) return CMD_ERROR;
StoryPageElementID page_element_id = (StoryPageElementID)p1;
if (!StoryPageElement::IsValidID(page_element_id)) return CMD_ERROR; if (!StoryPageElement::IsValidID(page_element_id)) return CMD_ERROR;
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
@ -465,15 +433,12 @@ CommandCost CmdRemoveStoryPageElement(DoCommandFlag flags, TileIndex tile, uint3
* Clicked/used a button on a story page. * Clicked/used a button on a story page.
* @param flags Type of operation. * @param flags Type of operation.
* @param tile Tile selected, for tile selection buttons, otherwise unused. * @param tile Tile selected, for tile selection buttons, otherwise unused.
* @param p1 Bit 0..15 = story page element id of button. * @param page_element_id story page element id of button.
* @param p2 ID of selected item for buttons that select an item (e.g. vehicle), otherwise unused. * @param reference ID of selected item for buttons that select an item (e.g. vehicle), otherwise unused.
* @param text Unused.
* @return The cost of the operation, or an error. * @return The cost of the operation, or an error.
*/ */
CommandCost CmdStoryPageButton(DoCommandFlag flags, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) CommandCost CmdStoryPageButton(DoCommandFlag flags, TileIndex tile, StoryPageElementID page_element_id, VehicleID reference)
{ {
StoryPageElementID page_element_id = (StoryPageElementID)GB(p1, 0, 16);
if (!StoryPageElement::IsValidID(page_element_id)) return CMD_ERROR; if (!StoryPageElement::IsValidID(page_element_id)) return CMD_ERROR;
const StoryPageElement *const pe = StoryPageElement::Get(page_element_id); const StoryPageElement *const pe = StoryPageElement::Get(page_element_id);
@ -491,8 +456,8 @@ CommandCost CmdStoryPageButton(DoCommandFlag flags, TileIndex tile, uint32 p1, u
if (flags & DC_EXEC) Game::NewEvent(new ScriptEventStoryPageTileSelect(_current_company, pe->page, page_element_id, tile)); if (flags & DC_EXEC) Game::NewEvent(new ScriptEventStoryPageTileSelect(_current_company, pe->page, page_element_id, tile));
break; break;
case SPET_BUTTON_VEHICLE: case SPET_BUTTON_VEHICLE:
if (!Vehicle::IsValidID(p2)) return CMD_ERROR; if (!Vehicle::IsValidID(reference)) return CMD_ERROR;
if (flags & DC_EXEC) Game::NewEvent(new ScriptEventStoryPageVehicleSelect(_current_company, pe->page, page_element_id, (VehicleID)p2)); if (flags & DC_EXEC) Game::NewEvent(new ScriptEventStoryPageVehicleSelect(_current_company, pe->page, page_element_id, reference));
break; break;
default: default:
/* Invalid page element type, not a button. */ /* Invalid page element type, not a button. */

@ -11,16 +11,20 @@
#define STORY_CMD_H #define STORY_CMD_H
#include "command_type.h" #include "command_type.h"
#include "company_type.h"
#include "date_type.h"
#include "story_type.h"
#include "vehicle_type.h"
CommandProc CmdCreateStoryPage; CommandCost CmdCreateStoryPage(DoCommandFlag flags, CompanyID company, const std::string &text);
CommandProc CmdCreateStoryPageElement; CommandCost CmdCreateStoryPageElement(DoCommandFlag flags, TileIndex tile, StoryPageID page_id, StoryPageElementType type, uint32 reference, const std::string &text);
CommandProc CmdUpdateStoryPageElement; CommandCost CmdUpdateStoryPageElement(DoCommandFlag flags, TileIndex tile, StoryPageElementID page_element_id, uint32 reference, const std::string &text);
CommandProc CmdSetStoryPageTitle; CommandCost CmdSetStoryPageTitle(DoCommandFlag flags, StoryPageID page_id, const std::string &text);
CommandProc CmdSetStoryPageDate; CommandCost CmdSetStoryPageDate(DoCommandFlag flags, StoryPageID page_id, Date date);
CommandProc CmdShowStoryPage; CommandCost CmdShowStoryPage(DoCommandFlag flags, StoryPageID page_id);
CommandProc CmdRemoveStoryPage; CommandCost CmdRemoveStoryPage(DoCommandFlag flags, StoryPageID page_id);
CommandProc CmdRemoveStoryPageElement; CommandCost CmdRemoveStoryPageElement(DoCommandFlag flags, StoryPageElementID page_element_id);
CommandProc CmdStoryPageButton; CommandCost CmdStoryPageButton(DoCommandFlag flags, TileIndex tile, StoryPageElementID page_element_id, VehicleID reference);
DEF_CMD_TRAIT(CMD_CREATE_STORY_PAGE, CmdCreateStoryPage, CMD_DEITY | CMD_STR_CTRL, CMDT_OTHER_MANAGEMENT) DEF_CMD_TRAIT(CMD_CREATE_STORY_PAGE, CmdCreateStoryPage, CMD_DEITY | CMD_STR_CTRL, CMDT_OTHER_MANAGEMENT)
DEF_CMD_TRAIT(CMD_CREATE_STORY_PAGE_ELEMENT, CmdCreateStoryPageElement, CMD_DEITY | CMD_STR_CTRL, CMDT_OTHER_MANAGEMENT) DEF_CMD_TRAIT(CMD_CREATE_STORY_PAGE_ELEMENT, CmdCreateStoryPageElement, CMD_DEITY | CMD_STR_CTRL, CMDT_OTHER_MANAGEMENT)

@ -567,7 +567,7 @@ protected:
this->SetTimeout(); this->SetTimeout();
this->SetWidgetDirty(WID_SB_PAGE_PANEL); this->SetWidgetDirty(WID_SB_PAGE_PANEL);
Command<CMD_STORY_PAGE_BUTTON>::Post(0, pe.index, 0, {}); Command<CMD_STORY_PAGE_BUTTON>::Post(0, pe.index, 0);
break; break;
case SPET_BUTTON_TILE: case SPET_BUTTON_TILE:
@ -922,7 +922,7 @@ public:
return; return;
} }
Command<CMD_STORY_PAGE_BUTTON>::Post(tile, pe->index, 0, {}); Command<CMD_STORY_PAGE_BUTTON>::Post(tile, pe->index, 0);
ResetObjectToPlace(); ResetObjectToPlace();
} }
@ -941,7 +941,7 @@ public:
VehicleType wanted_vehtype = data.GetVehicleType(); VehicleType wanted_vehtype = data.GetVehicleType();
if (wanted_vehtype != VEH_INVALID && wanted_vehtype != v->type) return false; if (wanted_vehtype != VEH_INVALID && wanted_vehtype != v->type) return false;
Command<CMD_STORY_PAGE_BUTTON>::Post(0, pe->index, v->index, {}); Command<CMD_STORY_PAGE_BUTTON>::Post(0, pe->index, v->index);
ResetObjectToPlace(); ResetObjectToPlace();
return true; return true;
} }

@ -16,6 +16,7 @@ typedef uint16 StoryPageElementID; ///< ID of a story page element
typedef uint16 StoryPageID; ///< ID of a story page typedef uint16 StoryPageID; ///< ID of a story page
struct StoryPageElement; struct StoryPageElement;
struct StoryPage; struct StoryPage;
enum StoryPageElementType : byte;
extern StoryPageElementID _new_story_page_element_id; extern StoryPageElementID _new_story_page_element_id;
extern StoryPageID _new_story_page_id; extern StoryPageID _new_story_page_id;

Loading…
Cancel
Save