summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2005-07-10 14:57:43 +0000
committertruelight <truelight@openttd.org>2005-07-10 14:57:43 +0000
commit48b3b8699d7db88ae9307e319535c8ec5b236824 (patch)
treed80479fbf61384ebe9e039f86a4290aefd69ff45
parent84faec4c4341a2310d9e97bc75170231ba5b1d43 (diff)
downloadopenttd-48b3b8699d7db88ae9307e319535c8ec5b236824.tar.xz
(svn r2542) -Add: [GPMI] Added GPMI (http://sourceforge.net/projects/libgpmi/)
support to OpenTTD in preperation of AIScripts (long term). It is OFF by default. Add GPMI:=1 to Makefile.config to enable.
-rw-r--r--Makefile9
-rw-r--r--debug.c13
-rw-r--r--debug.h7
-rw-r--r--makefiledir/Makefile.config_writer1
-rw-r--r--openttd.c17
5 files changed, 47 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index c1e20799c..00fbb13c2 100644
--- a/Makefile
+++ b/Makefile
@@ -386,6 +386,15 @@ endif
CFLAGS += $(BASECFLAGS)
+# See if we want to enable GPMI
+ifdef GPMI
+CFLAGS += -DGPMI
+GPMI_STATIC_PATH = `gpmi-config --static`
+LDFLAGS += -rdynamic `gpmi-config --libs`
+# Static link paths into the game
+LDFLAGS += $(GPMI_STATIC_PATH)/paths-static.o
+endif
+
ifdef UNIX
CDEFS += -DUNIX
endif
diff --git a/debug.c b/debug.c
index fe36348fc..089f77850 100644
--- a/debug.c
+++ b/debug.c
@@ -15,6 +15,9 @@ int _debug_net_level;
int _debug_spritecache_level;
int _debug_oldloader_level;
int _debug_pbs_level;
+#ifdef GPMI
+int _debug_gpmi_level;
+#endif /* GPMI */
int _debug_npf_level;
@@ -46,6 +49,9 @@ typedef struct DebugLevel {
DEBUG_LEVEL(spritecache),
DEBUG_LEVEL(oldloader),
DEBUG_LEVEL(pbs),
+#ifdef GPMI
+ DEBUG_LEVEL(gpmi),
+#endif
DEBUG_LEVEL(npf)
};
#undef DEBUG_LEVEL
@@ -120,3 +126,10 @@ const char *GetDebugString(void)
return dbgstr;
}
+
+#ifdef GPMI
+void gpmi_debug_openttd(int level, char *s)
+{
+ DEBUG(gpmi, level)("[GPMI] %s", s);
+}
+#endif /* GPMI */
diff --git a/debug.h b/debug.h
index 320e1d5de..1bfe990ba 100644
--- a/debug.h
+++ b/debug.h
@@ -15,6 +15,9 @@
extern int _debug_spritecache_level;
extern int _debug_oldloader_level;
extern int _debug_pbs_level;
+#ifdef GPMI
+ extern int _debug_gpmi_level;
+#endif /* GPMI */
extern int _debug_npf_level;
#endif
@@ -23,4 +26,8 @@ void CDECL debug(const char *s, ...);
void SetDebugString(const char *s);
const char *GetDebugString(void);
+#ifdef GPMI
+void gpmi_debug_openttd(int level, char *s);
+#endif /* GPMI */
+
#endif
diff --git a/makefiledir/Makefile.config_writer b/makefiledir/Makefile.config_writer
index 615517f98..caadb188b 100644
--- a/makefiledir/Makefile.config_writer
+++ b/makefiledir/Makefile.config_writer
@@ -29,6 +29,7 @@ $(MAKE_CONFIG):
$(call CONFIG_LINE,SUPRESS_LANG_ERRORS:=$(SUPRESS_LANG_ERRORS))
$(call CONFIG_LINE,WITH_NETWORK:=$(WITH_NETWORK))
$(call CONFIG_LINE,DEDICATED:=$(DEDICATED))
+ $(call CONFIG_LINE,GPMI:=$(GPMI))
$(call CONFIG_LINE,)
$(call CONFIG_LINE,\# Disable asserts. Leave them on for easier bug finding)
diff --git a/openttd.c b/openttd.c
index 04c24adbd..8ec907162 100644
--- a/openttd.c
+++ b/openttd.c
@@ -37,6 +37,11 @@
#include <stdarg.h>
+#ifdef GPMI
+#include <gpmi.h>
+#include <gpmi/packages/paths.h>
+#endif /* GPMI */
+
void GenerateWorld(int mode, uint log_x, uint log_y);
void CallLandscapeTick(void);
void IncreaseDate(void);
@@ -593,6 +598,18 @@ int ttd_main(int argc, char* argv[])
DeterminePaths();
CheckExternalFiles();
+#ifdef GPMI
+ /* Set the debug proc */
+ gpmi_debug_proc = &gpmi_debug_openttd;
+
+ /* Initialize GPMI */
+ gpmi_init();
+
+ /* Add our paths so we can find our own packages */
+ gpmi_path_append(&gpmi_path_modules, "gpmi/modules");
+ gpmi_path_append(&gpmi_path_packages, "gpmi/packages");
+#endif /* GPMI */
+
#ifdef UNIX
// We must fork here, or we'll end up without some resources we need (like sockets)
if (_dedicated_forks)