00001
00002
00003
00004
00005
00006
00007
00008
00021 namespace Xconq {
00022 namespace AI {
00023
00025
00026 enum OpRole_Type {
00028 OR_NONE = 0,
00030 OR_SHUTTLE,
00032 OR_CONSTRUCTOR,
00033
00034 OR_Total
00035 };
00036
00038
00039 enum OpRole_Outcome {
00041 ORO_INVALID = 0,
00043 ORO_FAILED,
00045 ORO_OK,
00047 ORO_HANDLED_TACTICAL
00048
00049 };
00050
00052
00053 struct OpRole {
00054
00056 int id;
00058 OpRole_Type type;
00059
00061 int dedication;
00063 int execs_this_turn;
00065 int fails_this_turn;
00066
00067
00069 OpRole *next;
00071 OpRole *next_by_type;
00073 Side *side;
00074 };
00075
00076
00077
00078
00079
00081
00082 struct AI_Side {
00083
00085 AI_SKAnalysis *sk_analyses;
00086
00088 OpRole *oproles;
00090 OpRole *oproles_free;
00092 OpRole **oprole_buckets;
00093
00095 Side *side;
00096 };
00097
00099 extern void create_side_ai(Side *side);
00101 extern AI_Side * get_side_ai(Side *side);
00102
00105
00106 #define OR_BLK_SZ 200
00107
00109
00110 #define for_all_oproles(side,oprole) \
00111 for ((oprole) = (get_side_ai(side) ? get_side_ai(side)->oproles : NULL); \
00112 (oprole); (oprole) = (oprole)->next)
00113
00115
00116 #define for_all_oproles_by_type(side,type,oprole) \
00117 for ((oprole) = (get_side_ai(side) ? \
00118 get_side_ai(side)->oprole_buckets[type] : NULL); \
00119 (oprole); (oprole) = (oprole)->next_by_type)
00120
00122 extern void allocate_oproles(Side *side, int nodesnum = OR_BLK_SZ);
00124 extern OpRole *acquire_oprole(Side *side, int id, OpRole_Type type);
00126 extern void release_oprole(OpRole *oprole);
00128 extern OpRole *find_oprole(Side *side, int id);
00129
00132
00133
00135 extern int choose_utype_to_construct(OpRole *oprole, int *uscore);
00137 extern Unit *choose_transport_to_construct_in(
00138 int u2, Side *side, UnitView *uview, int upchain = FALSE);
00140 extern Task *generate_construction_task(Unit *unit, int u2);
00142 extern int choose_construction_or_repair(OpRole *oprole);
00144 extern OpRole_Outcome handle_constructor_oprole(OpRole *oprole);
00145
00146
00147
00149 extern void handle_oprole(OpRole *oprole);
00151 extern void handle_oproles(Side *side);
00152
00153 }
00154 }