summaryrefslogtreecommitdiff
path: root/src/ai
diff options
context:
space:
mode:
authorglx22 <glx22@users.noreply.github.com>2019-09-07 18:37:01 +0200
committerCharles Pigott <charlespigott@googlemail.com>2019-09-07 17:37:01 +0100
commitb3fd7879596defeb6af78acb4ea45e4418821bdf (patch)
tree08b94b2cd65012e573b0e8c94196daab5aab12ba /src/ai
parent381c2a45875206afe43241d0c76619638cf613fc (diff)
downloadopenttd-b3fd7879596defeb6af78acb4ea45e4418821bdf.tar.xz
Fix #7188: check the validity of command callback for scripts (#7701)
Diffstat (limited to 'src/ai')
-rw-r--r--src/ai/ai_instance.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/ai/ai_instance.cpp b/src/ai/ai_instance.cpp
index edb7ebce0..18a549aa1 100644
--- a/src/ai/ai_instance.cpp
+++ b/src/ai/ai_instance.cpp
@@ -251,8 +251,9 @@ ScriptInfo *AIInstance::FindLibrary(const char *library, int version)
* @param tile The tile on which the command was executed.
* @param p1 p1 as given to DoCommandPInternal.
* @param p2 p2 as given to DoCommandPInternal.
+ * @param cmd cmd as given to DoCommandPInternal.
*/
-void CcAI(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
+void CcAI(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
{
/*
* The company might not exist anymore. Check for this.
@@ -263,8 +264,9 @@ void CcAI(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
const Company *c = Company::GetIfValid(_current_company);
if (c == nullptr || c->ai_instance == nullptr) return;
- c->ai_instance->DoCommandCallback(result, tile, p1, p2);
- c->ai_instance->Continue();
+ if (c->ai_instance->DoCommandCallback(result, tile, p1, p2, cmd)) {
+ c->ai_instance->Continue();
+ }
}
CommandCallback *AIInstance::GetDoCommandCallback()