42 void AI_RunGameLoop(void); |
43 void AI_RunGameLoop(void); |
43 void AI_Initialize(void); |
44 void AI_Initialize(void); |
44 void AI_Uninitialize(void); |
45 void AI_Uninitialize(void); |
45 int32 AI_DoCommand(uint tile, uint32 p1, uint32 p2, uint32 flags, uint procc); |
46 int32 AI_DoCommand(uint tile, uint32 p1, uint32 p2, uint32 flags, uint procc); |
46 |
47 |
|
48 /** Is it allowed to start a new AI. |
|
49 * This function checks some boundries to see if we should launch a new AI. |
|
50 * @return True if we can start a new AI. |
|
51 */ |
|
52 static inline bool AI_AllowNewAI(void) |
|
53 { |
|
54 /* If disabled, no AI */ |
|
55 if (!_ai.enabled) |
|
56 return false; |
|
57 |
|
58 /* If in network, but no server, no AI */ |
|
59 if (_networking && !_network_server) |
|
60 return false; |
|
61 |
|
62 /* If in network, and server, possible AI */ |
|
63 if (_networking && _network_server) { |
|
64 /* Do we want AIs in multiplayer? */ |
|
65 if (!_patches.ai_in_multiplayer) |
|
66 return false; |
|
67 |
|
68 /* Only the NewAI is allowed... sadly enough the old AI just doesn't support this |
|
69 * system, because all commands are delayed by at least 1 tick, which causes |
|
70 * a big problem, because it uses variables that are only set AFTER the command |
|
71 * is really executed... */ |
|
72 if (!_patches.ainew_active) |
|
73 return false; |
|
74 } |
|
75 |
|
76 return true; |
|
77 } |
|
78 |
47 #define AI_CHANCE16(a,b) ((uint16) AI_Random() <= (uint16)((65536 * a) / b)) |
79 #define AI_CHANCE16(a,b) ((uint16) AI_Random() <= (uint16)((65536 * a) / b)) |
48 #define AI_CHANCE16R(a,b,r) ((uint16)(r = AI_Random()) <= (uint16)((65536 * a) / b)) |
80 #define AI_CHANCE16R(a,b,r) ((uint16)(r = AI_Random()) <= (uint16)((65536 * a) / b)) |
49 |
81 |
50 /** |
82 /** |
51 * The random-function that should be used by ALL AIs. |
83 * The random-function that should be used by ALL AIs. |