summaryrefslogtreecommitdiff
path: root/ai
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2005-11-29 15:53:15 +0000
committertruelight <truelight@openttd.org>2005-11-29 15:53:15 +0000
commitc963c59b672b18e1b67eb859b83d69eb17eac647 (patch)
treea71d1010bc421c8702c2fb37e41c0ae1e8fb6d5c /ai
parent2eb1c8a2151deef9155eb73a83873029d3b40f73 (diff)
downloadopenttd-c963c59b672b18e1b67eb859b83d69eb17eac647.tar.xz
(svn r3245) -Add: allow OpenTTD to give his GPMI-params to the GPMI modules
Diffstat (limited to 'ai')
-rw-r--r--ai/ai.c18
-rw-r--r--ai/ai.h1
2 files changed, 16 insertions, 3 deletions
diff --git a/ai/ai.c b/ai/ai.c
index 52950be25..42465914d 100644
--- a/ai/ai.c
+++ b/ai/ai.c
@@ -8,6 +8,7 @@
#include "../debug.h"
#include "ai.h"
#include "default/default.h"
+#include "../string.h"
/* Here we define the events */
#define DEF_EVENTS
@@ -200,8 +201,6 @@ void AI_RunGameLoop(void)
#ifdef GPMI
-void (*ottd_GetNextAIData)(char **library, char **param);
-
void AI_ShutdownAIControl(bool with_error)
{
if (_ai.gpmi_mod != NULL)
@@ -215,6 +214,9 @@ void AI_ShutdownAIControl(bool with_error)
}
}
+void (*ottd_GetNextAIData)(char **library, char **param);
+void (*ottd_SetAIParam)(char *param);
+
void AI_LoadAIControl(void)
{
/* Load module */
@@ -233,10 +235,13 @@ void AI_LoadAIControl(void)
/* Now link all the functions */
{
ottd_GetNextAIData = gpmi_pkg_resolve(_ai.gpmi_pkg, "ottd_GetNextAIData");
+ ottd_SetAIParam = gpmi_pkg_resolve(_ai.gpmi_pkg, "ottd_SetAIParam");
- if (ottd_GetNextAIData == NULL)
+ if (ottd_GetNextAIData == NULL || ottd_SetAIParam == NULL)
AI_ShutdownAIControl(true);
}
+
+ ottd_SetAIParam(_ai.gpmi_param);
}
#endif /* GPMI */
@@ -298,6 +303,9 @@ void AI_Initialize(void)
{
bool tmp_ai_network_client = _ai.network_client;
bool tmp_ai_gpmi = _ai.gpmi;
+#ifdef GPMI
+ char *tmp_ai_gpmi_param = strdup(_ai.gpmi_param);
+#endif /* GPMI */
memset(&_ai, 0, sizeof(_ai));
memset(&_ai_player, 0, sizeof(_ai_player));
@@ -306,6 +314,10 @@ void AI_Initialize(void)
_ai.network_playas = OWNER_SPECTATOR;
_ai.enabled = true;
_ai.gpmi = tmp_ai_gpmi;
+#ifdef GPMI
+ ttd_strlcpy(_ai.gpmi_param, tmp_ai_gpmi_param, sizeof(_ai.gpmi_param));
+ free(tmp_ai_gpmi_param);
+#endif /* GPMI */
}
/**
diff --git a/ai/ai.h b/ai/ai.h
index af55f6506..bb56ed27d 100644
--- a/ai/ai.h
+++ b/ai/ai.h
@@ -43,6 +43,7 @@ typedef struct AIStruct {
#ifdef GPMI
gpmi_module *gpmi_mod; //! The module controller for GPMI based AIs (Event-handling)
gpmi_package *gpmi_pkg; //! The package controller for GPMI based AIs (Functions)
+ char gpmi_param[128]; //! The params given to the gpmi_mod
#endif /* GPMI */
} AIStruct;