summaryrefslogtreecommitdiff
path: root/ai
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2005-12-01 09:34:40 +0000
committertruelight <truelight@openttd.org>2005-12-01 09:34:40 +0000
commit5e4a1a4dc1038b2195201c4ad1ee1210cdbb5ab6 (patch)
tree5a82cec627725880b7864a11cf31556ee3e256cf /ai
parenta518f81093a704396b73a4b54fcae2b9b7cd120a (diff)
downloadopenttd-5e4a1a4dc1038b2195201c4ad1ee1210cdbb5ab6.tar.xz
(svn r3251) -Fix: report errors from GPMI in a more detailed way (Igor2Code)
Diffstat (limited to 'ai')
-rw-r--r--ai/ai.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/ai/ai.c b/ai/ai.c
index c186d8051..df457f662 100644
--- a/ai/ai.c
+++ b/ai/ai.c
@@ -243,6 +243,15 @@ void AI_LoadAIControl(void)
ottd_SetAIParam(_ai.gpmi_param);
}
+
+/**
+ * Dump an entry of the GPMI error stack (callback routine). This helps the user to trace errors back to their roots.
+ */
+void AI_PrintErrorStack(gpmi_err_stack_t *entry, char *string)
+{
+ DEBUG(ai, 0)(string);
+}
+
#endif /* GPMI */
/**
@@ -262,6 +271,7 @@ void AI_StartNewAI(PlayerID player)
char *params = NULL;
ottd_GetNextAIData(&library, &params);
+ gpmi_error_stack_enable = 1;
if (library != NULL) {
_ai_player[player].module = gpmi_mod_load(library, params);
@@ -271,9 +281,12 @@ void AI_StartNewAI(PlayerID player)
free(params);
if (_ai_player[player].module == NULL) {
- DEBUG(ai, 0)("[AI] Failed to load AI, aborting..");
+ DEBUG(ai, 0)("[AI] Failed to load AI, aborting. GPMI error stack:");
+ gpmi_err_stack_process_str(AI_PrintErrorStack);
return;
}
+ gpmi_error_stack_enable = 0;
+
}
#endif /* GPMI */