summaryrefslogtreecommitdiff
path: root/src/script/api
diff options
context:
space:
mode:
authordP <dp@dpointer.org>2021-02-02 19:14:26 +0300
committerLoïc Guilloux <glx22@users.noreply.github.com>2021-02-14 23:21:43 +0100
commit91cc414588548e7752fb707b4547f63db597aca1 (patch)
tree22d5f6e1e66286a6e26bd93302bc4fe2f0be0501 /src/script/api
parent751f595bb674192f22d6d091bf68ad263b120c35 (diff)
downloadopenttd-91cc414588548e7752fb707b4547f63db597aca1.tar.xz
Feature: [GS] Allow non-question type windows to have no buttons
Diffstat (limited to 'src/script/api')
-rw-r--r--src/script/api/game_changelog.hpp1
-rw-r--r--src/script/api/script_goal.cpp5
2 files changed, 4 insertions, 2 deletions
diff --git a/src/script/api/game_changelog.hpp b/src/script/api/game_changelog.hpp
index edc588407..737adc7fc 100644
--- a/src/script/api/game_changelog.hpp
+++ b/src/script/api/game_changelog.hpp
@@ -38,6 +38,7 @@
*
* Other changes:
* \li GSCompany::ChangeBankBalance takes one extra parameter to refer to a location to show text effect on
+ * \li GSGoal::Question and GSGoal::QuestionClient no longer require to have any buttons except for the window type GSGoal.QT_QUESTION
*
* \b 1.10.0
*
diff --git a/src/script/api/script_goal.cpp b/src/script/api/script_goal.cpp
index ca2b16574..f1b75b032 100644
--- a/src/script/api/script_goal.cpp
+++ b/src/script/api/script_goal.cpp
@@ -115,9 +115,10 @@
EnforcePrecondition(false, question != nullptr);
const char *text = question->GetEncodedText();
EnforcePreconditionEncodedText(false, text);
- EnforcePrecondition(false, CountBits(buttons) >= 1 && CountBits(buttons) <= 3);
+ uint min_buttons = (type == QT_QUESTION ? 1 : 0);
+ EnforcePrecondition(false, CountBits(buttons) >= min_buttons && CountBits(buttons) <= 3);
EnforcePrecondition(false, buttons < (1 << ::GOAL_QUESTION_BUTTON_COUNT));
- EnforcePrecondition(false, (int)type < ::GOAL_QUESTION_TYPE_COUNT);
+ EnforcePrecondition(false, (int)type < ::GQT_END);
return ScriptObject::DoCommand(0, uniqueid | (target << 16), buttons | (type << 29) | (is_client ? (1 << 31) : 0), CMD_GOAL_QUESTION, text);
}