summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2005-12-06 11:36:46 +0000
committertruelight <truelight@openttd.org>2005-12-06 11:36:46 +0000
commita3d142ed57aceed7db2a9c7c7ef9fc2d50b6a44a (patch)
tree12495b7a5ae255c52a14b8d11048a8d09e89dd35
parent1a93bcb5bb0bf733ad74d8e192478e9e4643ca7a (diff)
downloadopenttd-a3d142ed57aceed7db2a9c7c7ef9fc2d50b6a44a.tar.xz
(svn r3263) -Fix: use () around 'variables' in macros, gives less crashes ;)
-Fix: va-args in macros are supported via __VA_ARGS__ in C99, so changed to that; now GCC 2.95 likes it too :)
-rw-r--r--ai/ai_event.h23
1 files changed, 6 insertions, 17 deletions
diff --git a/ai/ai_event.h b/ai/ai_event.h
index 684ce54b5..33d5d170a 100644
--- a/ai/ai_event.h
+++ b/ai/ai_event.h
@@ -7,25 +7,14 @@
# include "ai.h"
/* This is how we call events (with safety-check) to GPMI */
-/* XXX -- This macro (vararg macro) isn't supported on old GCCs, but GPMI
- * is using them too, so it isn't a real problem, yet */
-# define ai_event(player, event, params...) \
- if (player < MAX_PLAYERS && _ai_player[player].module != NULL) \
- gpmi_event(_ai_player[player].module, event, params)
+# define ai_event(player, event, ...) \
+ if ((player) < MAX_PLAYERS && _ai_player[(player)].module != NULL) \
+ gpmi_event(_ai_player[(player)].module, (event), ##__VA_ARGS__)
-#else
-/* If GPMI isn't loaded, don't do a thing with the events (for now at least)
- * Because old GCCs don't support vararg macros, and OTTD does support those
- * GCCs, we need something tricky to ignore the events... and this is the solution :)
- * Ugly, I know, but it works! */
-
-# ifdef DEF_EVENTS
- void CDECL empty_function(PlayerID player, int event, ...) {}
-# else
- extern void CDECL empty_function(PlayerID player, int event, ...);
-# endif
-# define ai_event empty_function
+#else /* GPMI */
+/* If GPMI isn't loaded, don't do a thing with the events (for now at least) */
+# define ai_event(...)
#endif /* GPMI */
/* To make our life a bit easier; you now only have to define new