author | truelight |
Sat, 26 Nov 2005 16:18:15 +0000 | |
changeset 2696 | 309dedc426e5 |
parent 2690 | 2f810b43cb7f |
child 2700 | 555506b02195 |
permissions | -rw-r--r-- |
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
1 |
/* $Id$ */ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
2 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
3 |
#include "../stdafx.h" |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
4 |
#include "../openttd.h" |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
5 |
#include "../variables.h" |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
6 |
#include "../command.h" |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
7 |
#include "../network.h" |
2687
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
8 |
#include "../debug.h" |
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
9 |
#include "ai.h" |
2447
47f2b670fb22
(svn r2973) Move a function declaration somewhere where it belongs
tron
parents:
2446
diff
changeset
|
10 |
#include "default/default.h" |
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
11 |
|
2690
2f810b43cb7f
(svn r3232) -Add: implemented the event-system for AIs
truelight
parents:
2687
diff
changeset
|
12 |
/* Here we define the events */ |
2f810b43cb7f
(svn r3232) -Add: implemented the event-system for AIs
truelight
parents:
2687
diff
changeset
|
13 |
#define DEF_EVENTS |
2f810b43cb7f
(svn r3232) -Add: implemented the event-system for AIs
truelight
parents:
2687
diff
changeset
|
14 |
#include "ai_event.h" |
2f810b43cb7f
(svn r3232) -Add: implemented the event-system for AIs
truelight
parents:
2687
diff
changeset
|
15 |
#undef DEF_EVENTS |
2f810b43cb7f
(svn r3232) -Add: implemented the event-system for AIs
truelight
parents:
2687
diff
changeset
|
16 |
|
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
17 |
/** |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
18 |
* Dequeues commands put in the queue via AI_PutCommandInQueue. |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
19 |
*/ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
20 |
void AI_DequeueCommands(byte player) |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
21 |
{ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
22 |
AICommand *com, *entry_com; |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
23 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
24 |
entry_com = _ai_player[player].queue; |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
25 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
26 |
/* It happens that DoCommandP issues a new DoCommandAI which adds a new command |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
27 |
* to this very same queue (don't argue about this, if it currently doesn't |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
28 |
* happen I can tell you it will happen with AIScript -- TrueLight). If we |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
29 |
* do not make the queue NULL, that commands will be dequeued immediatly. |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
30 |
* Therefor we safe the entry-point to entry_com, and make the queue NULL, so |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
31 |
* the new queue can be safely built up. */ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
32 |
_ai_player[player].queue = NULL; |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
33 |
_ai_player[player].queue_tail = NULL; |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
34 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
35 |
/* Dequeue all commands */ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
36 |
while ((com = entry_com) != NULL) { |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
37 |
_current_player = player; |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
38 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
39 |
/* Copy the DP back in place */ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
40 |
memcpy(_decode_parameters, com->dp, sizeof(com->dp)); |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
41 |
DoCommandP(com->tile, com->p1, com->p2, NULL, com->procc); |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
42 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
43 |
/* Free item */ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
44 |
entry_com = com->next; |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
45 |
free(com); |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
46 |
} |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
47 |
} |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
48 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
49 |
/** |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
50 |
* Needed for SP; we need to delay DoCommand with 1 tick, because else events |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
51 |
* will make infinite loops (AIScript). |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
52 |
*/ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
53 |
void AI_PutCommandInQueue(byte player, uint tile, uint32 p1, uint32 p2, uint procc) |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
54 |
{ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
55 |
AICommand *com; |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
56 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
57 |
if (_ai_player[player].queue_tail == NULL) { |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
58 |
/* There is no item in the queue yet, create the queue */ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
59 |
_ai_player[player].queue = malloc(sizeof(AICommand)); |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
60 |
_ai_player[player].queue_tail = _ai_player[player].queue; |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
61 |
} else { |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
62 |
/* Add an item at the end */ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
63 |
_ai_player[player].queue_tail->next = malloc(sizeof(AICommand)); |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
64 |
_ai_player[player].queue_tail = _ai_player[player].queue_tail->next; |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
65 |
} |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
66 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
67 |
/* This is our new item */ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
68 |
com = _ai_player[player].queue_tail; |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
69 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
70 |
/* Assign the info */ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
71 |
com->tile = tile; |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
72 |
com->p1 = p1; |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
73 |
com->p2 = p2; |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
74 |
com->procc = procc; |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
75 |
com->next = NULL; |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
76 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
77 |
/* Copy the decode_parameters */ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
78 |
memcpy(com->dp, _decode_parameters, sizeof(com->dp)); |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
79 |
} |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
80 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
81 |
/** |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
82 |
* Executes a raw DoCommand for the AI. |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
83 |
*/ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
84 |
int32 AI_DoCommand(uint tile, uint32 p1, uint32 p2, uint32 flags, uint procc) |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
85 |
{ |
2551
436aaaa22ba5
(svn r3080) byte -> PlayerID, int -> EngineID, -1 -> INVALID_ENGINE
tron
parents:
2548
diff
changeset
|
86 |
PlayerID old_lp; |
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
87 |
int32 res = 0; |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
88 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
89 |
/* If you enable DC_EXEC with DC_QUERY_COST you are a really strange |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
90 |
* person.. should we check for those funny jokes? |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
91 |
*/ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
92 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
93 |
/* First, do a test-run to see if we can do this */ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
94 |
res = DoCommandByTile(tile, p1, p2, flags & ~DC_EXEC, procc); |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
95 |
/* The command failed, or you didn't want to execute, or you are quering, return */ |
2684
8aba54c245cc
(svn r3226) -Fix: GPMI implementation had minor glitches
truelight
parents:
2682
diff
changeset
|
96 |
if ((CmdFailed(res)) || !(flags & DC_EXEC) || (flags & DC_QUERY_COST)) |
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
97 |
return res; |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
98 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
99 |
/* If we did a DC_EXEC, and the command did not return an error, execute it |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
100 |
over the network */ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
101 |
if (flags & DC_AUTO) procc |= CMD_AUTO; |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
102 |
if (flags & DC_NO_WATER) procc |= CMD_NO_WATER; |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
103 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
104 |
/* NetworkSend_Command needs _local_player to be set correctly, so |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
105 |
adjust it, and put it back right after the function */ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
106 |
old_lp = _local_player; |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
107 |
_local_player = _current_player; |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
108 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
109 |
/* Send the command */ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
110 |
if (_networking) |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
111 |
/* Network is easy, send it to his handler */ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
112 |
NetworkSend_Command(tile, p1, p2, procc, NULL); |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
113 |
else |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
114 |
/* If we execute BuildCommands directly in SP, we have a big problem with events |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
115 |
* so we need to delay is for 1 tick */ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
116 |
AI_PutCommandInQueue(_current_player, tile, p1, p2, procc); |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
117 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
118 |
/* Set _local_player back */ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
119 |
_local_player = old_lp; |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
120 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
121 |
return res; |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
122 |
} |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
123 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
124 |
/** |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
125 |
* Run 1 tick of the AI. Don't overdo it, keep it realistic. |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
126 |
*/ |
2551
436aaaa22ba5
(svn r3080) byte -> PlayerID, int -> EngineID, -1 -> INVALID_ENGINE
tron
parents:
2548
diff
changeset
|
127 |
static void AI_RunTick(PlayerID player) |
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
128 |
{ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
129 |
_current_player = player; |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
130 |
|
2687
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
131 |
#ifdef GPMI |
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
132 |
if (_ai.gpmi) { |
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
133 |
gpmi_call_RunTick(_ai_player[player].module, _frame_counter); |
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
134 |
return; |
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
135 |
} |
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
136 |
#endif /* GPMI */ |
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
137 |
|
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
138 |
{ |
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
139 |
extern void AiNewDoGameLoop(Player *p); |
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
140 |
|
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
141 |
Player *p = GetPlayer(player); |
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
142 |
|
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
143 |
if (_patches.ainew_active) { |
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
144 |
AiNewDoGameLoop(p); |
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
145 |
} else { |
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
146 |
/* Enable all kind of cheats the old AI needs in order to operate correctly... */ |
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
147 |
_is_old_ai_player = true; |
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
148 |
AiDoGameLoop(p); |
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
149 |
_is_old_ai_player = false; |
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
150 |
} |
2422
914a12dee832
(svn r2948) -Fix: the old AI needs a special flag that triggers all kind of special
truelight
parents:
2395
diff
changeset
|
151 |
} |
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
152 |
} |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
153 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
154 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
155 |
/** |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
156 |
* The gameloop for AIs. |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
157 |
* Handles one tick for all the AIs. |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
158 |
*/ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
159 |
void AI_RunGameLoop(void) |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
160 |
{ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
161 |
/* Don't do anything if ai is disabled */ |
2639 | 162 |
if (!_ai.enabled) return; |
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
163 |
|
2682
94ca0b4dc53f
(svn r3224) -Add: Allow the NewAI to work in Multiplayer Games (switchable via patch
truelight
parents:
2639
diff
changeset
|
164 |
/* Don't do anything if we are a network-client |
94ca0b4dc53f
(svn r3224) -Add: Allow the NewAI to work in Multiplayer Games (switchable via patch
truelight
parents:
2639
diff
changeset
|
165 |
* (too bad when a client joins, he thinks the AIs are real, so it wants to control |
94ca0b4dc53f
(svn r3224) -Add: Allow the NewAI to work in Multiplayer Games (switchable via patch
truelight
parents:
2639
diff
changeset
|
166 |
* them.. this avoids that, while loading a network game in singleplayer, does make |
94ca0b4dc53f
(svn r3224) -Add: Allow the NewAI to work in Multiplayer Games (switchable via patch
truelight
parents:
2639
diff
changeset
|
167 |
* the AIs to continue ;)) |
94ca0b4dc53f
(svn r3224) -Add: Allow the NewAI to work in Multiplayer Games (switchable via patch
truelight
parents:
2639
diff
changeset
|
168 |
*/ |
94ca0b4dc53f
(svn r3224) -Add: Allow the NewAI to work in Multiplayer Games (switchable via patch
truelight
parents:
2639
diff
changeset
|
169 |
if (_networking && !_network_server && !_ai.network_client) |
94ca0b4dc53f
(svn r3224) -Add: Allow the NewAI to work in Multiplayer Games (switchable via patch
truelight
parents:
2639
diff
changeset
|
170 |
return; |
94ca0b4dc53f
(svn r3224) -Add: Allow the NewAI to work in Multiplayer Games (switchable via patch
truelight
parents:
2639
diff
changeset
|
171 |
|
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
172 |
/* New tick */ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
173 |
_ai.tick++; |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
174 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
175 |
/* Make sure the AI follows the difficulty rule.. */ |
2446 | 176 |
assert(_opt.diff.competitor_speed <= 4); |
177 |
if ((_ai.tick & ((1 << (4 - _opt.diff.competitor_speed)) - 1)) != 0) |
|
178 |
return; |
|
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
179 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
180 |
/* Check for AI-client (so joining a network with an AI) */ |
2684
8aba54c245cc
(svn r3226) -Fix: GPMI implementation had minor glitches
truelight
parents:
2682
diff
changeset
|
181 |
if (_ai.network_client && _ai_player[_ai.network_playas].active) { |
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
182 |
/* Run the script */ |
2684
8aba54c245cc
(svn r3226) -Fix: GPMI implementation had minor glitches
truelight
parents:
2682
diff
changeset
|
183 |
AI_DequeueCommands(_ai.network_playas); |
8aba54c245cc
(svn r3226) -Fix: GPMI implementation had minor glitches
truelight
parents:
2682
diff
changeset
|
184 |
AI_RunTick(_ai.network_playas); |
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
185 |
} else if (!_networking || _network_server) { |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
186 |
/* Check if we want to run AIs (server or SP only) */ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
187 |
Player *p; |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
188 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
189 |
FOR_ALL_PLAYERS(p) { |
2687
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
190 |
if (p->is_active && p->is_ai && _ai_player[p->index].active) { |
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
191 |
/* Run the script */ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
192 |
AI_DequeueCommands(p->index); |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
193 |
AI_RunTick(p->index); |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
194 |
} |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
195 |
} |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
196 |
} |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
197 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
198 |
_current_player = OWNER_NONE; |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
199 |
} |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
200 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
201 |
/** |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
202 |
* A new AI sees the day of light. You can do here what ever you think is needed. |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
203 |
*/ |
2551
436aaaa22ba5
(svn r3080) byte -> PlayerID, int -> EngineID, -1 -> INVALID_ENGINE
tron
parents:
2548
diff
changeset
|
204 |
void AI_StartNewAI(PlayerID player) |
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
205 |
{ |
2687
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
206 |
#ifdef GPMI |
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
207 |
char library[80]; |
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
208 |
char params[80]; |
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
209 |
|
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
210 |
/* XXX -- Todo, make a nice assign for library and params from a nice GUI :) */ |
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
211 |
snprintf(library, sizeof(library), "php"); |
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
212 |
snprintf(params, sizeof(params), "daeb"); |
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
213 |
|
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
214 |
_ai_player[player].module = gpmi_mod_load(library, params); |
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
215 |
if (_ai_player[player].module == NULL) { |
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
216 |
DEBUG(ai, 0)("[AI] Failed to load AI, aborting.."); |
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
217 |
return; |
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
218 |
} |
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
219 |
#endif /* GPMI */ |
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
220 |
|
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
221 |
/* Called if a new AI is booted */ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
222 |
_ai_player[player].active = true; |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
223 |
} |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
224 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
225 |
/** |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
226 |
* This AI player died. Give it some chance to make a final puf. |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
227 |
*/ |
2551
436aaaa22ba5
(svn r3080) byte -> PlayerID, int -> EngineID, -1 -> INVALID_ENGINE
tron
parents:
2548
diff
changeset
|
228 |
void AI_PlayerDied(PlayerID player) |
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
229 |
{ |
2684
8aba54c245cc
(svn r3226) -Fix: GPMI implementation had minor glitches
truelight
parents:
2682
diff
changeset
|
230 |
if (_ai.network_client && _ai.network_playas == player) |
8aba54c245cc
(svn r3226) -Fix: GPMI implementation had minor glitches
truelight
parents:
2682
diff
changeset
|
231 |
_ai.network_playas = OWNER_SPECTATOR; |
8aba54c245cc
(svn r3226) -Fix: GPMI implementation had minor glitches
truelight
parents:
2682
diff
changeset
|
232 |
|
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
233 |
/* Called if this AI died */ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
234 |
_ai_player[player].active = false; |
2687
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
235 |
|
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
236 |
#ifdef GPMI |
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
237 |
gpmi_mod_unload(_ai_player[player].module); |
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
238 |
#endif /* GPMI */ |
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
239 |
} |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
240 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
241 |
/** |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
242 |
* Initialize some AI-related stuff. |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
243 |
*/ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
244 |
void AI_Initialize(void) |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
245 |
{ |
2687
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
246 |
bool tmp_ai_network_client = _ai.network_client; |
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
247 |
bool tmp_ai_gpmi = _ai.gpmi; |
2684
8aba54c245cc
(svn r3226) -Fix: GPMI implementation had minor glitches
truelight
parents:
2682
diff
changeset
|
248 |
|
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
249 |
memset(&_ai, 0, sizeof(_ai)); |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
250 |
memset(&_ai_player, 0, sizeof(_ai_player)); |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
251 |
|
2687
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
252 |
_ai.network_client = tmp_ai_network_client; |
2684
8aba54c245cc
(svn r3226) -Fix: GPMI implementation had minor glitches
truelight
parents:
2682
diff
changeset
|
253 |
_ai.network_playas = OWNER_SPECTATOR; |
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
254 |
_ai.enabled = true; |
2687
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
255 |
_ai.gpmi = tmp_ai_gpmi; |
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
256 |
} |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
257 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
258 |
/** |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
259 |
* Deinitializer for AI-related stuff. |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
260 |
*/ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
261 |
void AI_Uninitialize(void) |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
262 |
{ |
2639 | 263 |
Player* p; |
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
264 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
265 |
FOR_ALL_PLAYERS(p) { |
2687
eb2443a14a74
(svn r3229) -Add: add more GPMI support. Now GPMI-based AIs can be loaded (doesn't change a thing if you didn't enable GPMI)
truelight
parents:
2684
diff
changeset
|
266 |
if (p->is_active && p->is_ai && _ai_player[p->index].active) AI_PlayerDied(p->index); |
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
267 |
} |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
268 |
} |