1 /********************************************************************** 2 Freeciv - Copyright (C) 2001 - R. Falke 3 This program is free software; you can redistribute it and/or modify 4 it under the terms of the GNU General Public License as published by 5 the Free Software Foundation; either version 2, or (at your option) 6 any later version. 7 8 This program is distributed in the hope that it will be useful, 9 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 GNU General Public License for more details. 12 ***********************************************************************/ 13 14 #ifndef FC__AGENTS_H 15 #define FC__AGENTS_H 16 17 #ifdef __cplusplus 18 extern "C" { 19 #endif /* __cplusplus */ 20 21 #include "support.h" /* bool type */ 22 23 #include "fc_types.h" 24 25 /* 26 * Besides callback for convenience client/agents/agents also 27 * implements a "flattening" of the call stack i.e. to ensure that 28 * every agent is only called once at any time. 29 */ 30 31 /* Don't use the very last level unless you know what you're doing */ 32 #define LAST_AGENT_LEVEL 99 33 34 #define MAX_AGENT_NAME_LEN 10 35 36 enum callback_type { 37 CB_NEW, CB_REMOVE, CB_CHANGE, CB_LAST 38 }; 39 40 struct agent { 41 char name[MAX_AGENT_NAME_LEN]; 42 int level; 43 44 void (*turn_start_notify) (void); 45 void (*city_callbacks[CB_LAST]) (int); 46 void (*unit_callbacks[CB_LAST]) (int); 47 void (*tile_callbacks[CB_LAST]) (struct tile *ptile); 48 }; 49 50 void agents_init(void); 51 void agents_free(void); 52 void register_agent(const struct agent *agent); 53 bool agents_busy(void); 54 55 /* called from client/packhand.c */ 56 void agents_disconnect(void); 57 void agents_processing_started(void); 58 void agents_processing_finished(void); 59 void agents_freeze_hint(void); 60 void agents_thaw_hint(void); 61 void agents_game_joined(void); 62 void agents_game_start(void); 63 void agents_before_new_turn(void); 64 void agents_start_turn(void); 65 void agents_new_turn(void); 66 67 void agents_unit_changed(struct unit *punit); 68 void agents_unit_new(struct unit *punit); 69 void agents_unit_remove(struct unit *punit); 70 71 void agents_city_changed(struct city *pcity); 72 void agents_city_new(struct city *pcity); 73 void agents_city_remove(struct city *pcity); 74 75 void agents_tile_changed(struct tile *ptile); 76 void agents_tile_new(struct tile *ptile); 77 void agents_tile_remove(struct tile *ptile); 78 79 /* called from agents */ 80 void cause_a_city_changed_for_agent(const char *name_of_calling_agent, 81 struct city *pcity); 82 void cause_a_unit_changed_for_agent(const char *name_of_calling_agent, 83 struct unit *punit); 84 void wait_for_requests(const char *agent_name, int first_request_id, 85 int last_request_id); 86 87 #ifdef __cplusplus 88 } 89 #endif /* __cplusplus */ 90 91 #endif /* FC__AGENTS_H */ 92