truelight@2690: #ifndef AI_EVENT truelight@2690: #define AI_EVENT truelight@2690: truelight@2690: /* Make the ai_event macro set correctly */ truelight@2690: #ifdef GPMI truelight@2690: # include truelight@2690: # include "ai.h" truelight@2690: truelight@2690: /* This is how we call events (with safety-check) to GPMI */ truelight@2721: /* XXX -- This macro works only for some compilers (all GCCs for example). truelight@2721: * Some compilers on the other hand (MSCV!!) doesn't support variadic macros truelight@2721: * causing this to fail. There is no known solution. If you know any, please truelight@2721: * tell us ASAP! */ truelight@2718: # define ai_event(player, event, ...) \ truelight@2718: if ((player) < MAX_PLAYERS && _ai_player[(player)].module != NULL) \ truelight@2718: gpmi_event(_ai_player[(player)].module, (event), ##__VA_ARGS__) truelight@2690: truelight@2718: #else /* GPMI */ truelight@2690: truelight@2721: /* XXX -- Some compilers (like MSVC :() doesn't support variadic macros, truelight@2721: * which means we have to go to a lot of trouble to get the ai_event() ignored truelight@2721: * in case GPMI is disabled... KILL KILL KILL! truelight@2721: */ truelight@2720: # ifdef DEF_EVENTS truelight@2720: void CDECL empty_function(PlayerID player, int event, ...) {} truelight@2720: # else truelight@2720: extern void CDECL empty_function(PlayerID player, int event, ...); truelight@2720: # endif truelight@2720: # define ai_event empty_function truelight@2690: #endif /* GPMI */ truelight@2690: truelight@2690: /* To make our life a bit easier; you now only have to define new truelight@2690: * events here, and automaticly they work in OpenTTD without including truelight@2690: * the ottd_event package. Just because of some lovely macro-shit ;) */ truelight@2690: #ifdef DEF_EVENTS truelight@2690: # define DEF_EVENTS truelight@2690: # define INITIAL_SET = -1 truelight@2690: #else truelight@2690: # define DEF_EVENTS extern truelight@2690: # define INITIAL_SET truelight@2690: #endif /* DEF_EVENTS */ truelight@2690: truelight@2690: /* ------------ All available events -------------- */ truelight@2715: DEF_EVENTS int ottd_Event_CommandFailed INITIAL_SET; // (tile, unique_id) truelight@2715: DEF_EVENTS int ottd_Event_CommandSucceeded INITIAL_SET; // (tile, unique_id) truelight@2715: truelight@2690: DEF_EVENTS int ottd_Event_BuildStation INITIAL_SET; // (station_index, station_tile) truelight@2690: DEF_EVENTS int ottd_Event_BuildRoadStation INITIAL_SET; // (station_index, station_tile) truelight@2690: truelight@2690: DEF_EVENTS int ottd_Event_BuildDepot INITIAL_SET; // (depot_index, depot_tile) truelight@2690: DEF_EVENTS int ottd_Event_BuildRoadDepot INITIAL_SET; // (depot_index, depot_tile) truelight@2690: truelight@2690: DEF_EVENTS int ottd_Event_BuildVehicle INITIAL_SET; // (vehicle_index, depot_tile) truelight@2690: DEF_EVENTS int ottd_Event_BuildRoadVehicle INITIAL_SET; // (vehicle_index, depot_tile) truelight@2690: truelight@2690: DEF_EVENTS int ottd_Event_VehicleEnterDepot INITIAL_SET; // (vehicle_index, depot_tile) truelight@2690: DEF_EVENTS int ottd_Event_RoadVehicleEnterDepot INITIAL_SET; // (vehicle_index, depot_tile) truelight@2690: truelight@2690: DEF_EVENTS int ottd_Event_GiveOrder INITIAL_SET; // (vehicle_index) truelight@2709: truelight@2709: DEF_EVENTS int ottd_Event_BuildRoad INITIAL_SET; // (road_tile, road_pieces) truelight@2690: /* ----------------- End of list ------------------ */ truelight@2690: truelight@2690: #endif /* AI_EVENT */