author | truelight |
Thu, 15 Mar 2007 13:36:45 +0000 | |
branch | noai |
changeset 9404 | ef9e171617a3 |
parent 9400 | 6da42d57fda2 |
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 |
|
9360
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
3 |
/** @file ai.cpp handles the communication between the AI layer and the OpenTTD core */ |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
4 |
|
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
5 |
#include "../../stdafx.h" |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
6 |
#include "../../openttd.h" |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
7 |
#include "../../variables.h" |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
8 |
#include "../../command.h" |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
9 |
#include "../../network/network.h" |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
10 |
#include "../../helpers.hpp" |
9390
4042c17c8055
(svn r9182) [NoAI] -Add: added AIFactory template which all AIs must define, as this
truelight
parents:
9383
diff
changeset
|
11 |
#include "../../debug.h" |
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
12 |
#include "ai.h" |
9360
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
13 |
#include "ai_base.hpp" |
9390
4042c17c8055
(svn r9182) [NoAI] -Add: added AIFactory template which all AIs must define, as this
truelight
parents:
9383
diff
changeset
|
14 |
#include "ai_controller.hpp" |
4042c17c8055
(svn r9182) [NoAI] -Add: added AIFactory template which all AIs must define, as this
truelight
parents:
9383
diff
changeset
|
15 |
#include "ai_factory.hpp" |
9360
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
16 |
|
9361
7bb2bd22b16e
(svn r9144) [NoAI] -Change: moved command functions to AIObject, and made AIBase depend on AIObject
truelight
parents:
9360
diff
changeset
|
17 |
static AIController *_ai_player[MAX_PLAYERS]; |
9360
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
18 |
static uint _ai_frame_counter; |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
19 |
static bool _ai_enabled; |
2715
0ad451d9264b
(svn r3260) -Add: add events for AIs to check if a command execution failed or succeeded
truelight
parents:
2707
diff
changeset
|
20 |
|
2395
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 |
* 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
|
23 |
*/ |
2551
436aaaa22ba5
(svn r3080) byte -> PlayerID, int -> EngineID, -1 -> INVALID_ENGINE
tron
parents:
2548
diff
changeset
|
24 |
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
|
25 |
{ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
26 |
_current_player = player; |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
27 |
|
9390
4042c17c8055
(svn r9182) [NoAI] -Add: added AIFactory template which all AIs must define, as this
truelight
parents:
9383
diff
changeset
|
28 |
/* If this is NULL, it means we couldn't find an AI for this player */ |
4042c17c8055
(svn r9182) [NoAI] -Add: added AIFactory template which all AIs must define, as this
truelight
parents:
9383
diff
changeset
|
29 |
if (_ai_player[player] == NULL) return; |
4042c17c8055
(svn r9182) [NoAI] -Add: added AIFactory template which all AIs must define, as this
truelight
parents:
9383
diff
changeset
|
30 |
|
9361
7bb2bd22b16e
(svn r9144) [NoAI] -Change: moved command functions to AIObject, and made AIBase depend on AIObject
truelight
parents:
9360
diff
changeset
|
31 |
_ai_player[player]->IncreaseTick(); |
7bb2bd22b16e
(svn r9144) [NoAI] -Change: moved command functions to AIObject, and made AIBase depend on AIObject
truelight
parents:
9360
diff
changeset
|
32 |
_ai_player[player]->GameLoop(); |
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
33 |
} |
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 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
36 |
/** |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
37 |
* The gameloop for AIs. |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
38 |
* 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
|
39 |
*/ |
6573 | 40 |
void AI_RunGameLoop() |
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
41 |
{ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
42 |
/* Don't do anything if ai is disabled */ |
9360
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
43 |
if (!_ai_enabled) return; |
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
44 |
|
5332
ffb2e98b961e
(svn r7494) -Fix: Really disable AI's in Multiplayer if you tell it so. In loaded games with
Darkvater
parents:
4854
diff
changeset
|
45 |
/* Don't do anything if we are a network-client, or the AI has been disabled */ |
ffb2e98b961e
(svn r7494) -Fix: Really disable AI's in Multiplayer if you tell it so. In loaded games with
Darkvater
parents:
4854
diff
changeset
|
46 |
if (_networking && (!_network_server || !_patches.ai_in_multiplayer)) return; |
2682
94ca0b4dc53f
(svn r3224) -Add: Allow the NewAI to work in Multiplayer Games (switchable via patch
truelight
parents:
2639
diff
changeset
|
47 |
|
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
48 |
/* New tick */ |
9360
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
49 |
_ai_frame_counter++; |
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
50 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
51 |
/* Make sure the AI follows the difficulty rule.. */ |
2446 | 52 |
assert(_opt.diff.competitor_speed <= 4); |
9360
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
53 |
if ((_ai_frame_counter & ((1 << (4 - _opt.diff.competitor_speed)) - 1)) != 0) return; |
2395
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 |
/* Check for AI-client (so joining a network with an AI) */ |
4854
383ef523793f
(svn r6780) -Codechange: Remove GPMI leftovers (-b impersonisation of AI in MP).
Darkvater
parents:
4850
diff
changeset
|
56 |
if (!_networking || _network_server) { |
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
57 |
/* Check if we want to run AIs (server or SP only) */ |
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3950
diff
changeset
|
58 |
const Player* p; |
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
59 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
60 |
FOR_ALL_PLAYERS(p) { |
2767 | 61 |
if (p->is_active && p->is_ai) { |
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
62 |
/* Run the script */ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
63 |
AI_RunTick(p->index); |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
64 |
} |
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 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
68 |
_current_player = OWNER_NONE; |
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 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
71 |
/** |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
72 |
* 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
|
73 |
*/ |
2551
436aaaa22ba5
(svn r3080) byte -> PlayerID, int -> EngineID, -1 -> INVALID_ENGINE
tron
parents:
2548
diff
changeset
|
74 |
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
|
75 |
{ |
4850
b4e9be22945f
(svn r6776) -Codechange: Use IsValidPlayer() function to determine of a PlayerID is an
Darkvater
parents:
4848
diff
changeset
|
76 |
assert(IsValidPlayer(player)); |
9360
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
77 |
if (!_ai_enabled) return; |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
78 |
if (_networking && !_network_server) return; |
2702
e4663e88c530
(svn r3246) -Fix: small glitch in ai_network_client code (network_client.c)
truelight
parents:
2701
diff
changeset
|
79 |
|
9390
4042c17c8055
(svn r9182) [NoAI] -Add: added AIFactory template which all AIs must define, as this
truelight
parents:
9383
diff
changeset
|
80 |
_ai_player[player] = AIFactoryBase::SelectRandomAI(); |
4042c17c8055
(svn r9182) [NoAI] -Add: added AIFactory template which all AIs must define, as this
truelight
parents:
9383
diff
changeset
|
81 |
if (_ai_player[player] == NULL) { |
4042c17c8055
(svn r9182) [NoAI] -Add: added AIFactory template which all AIs must define, as this
truelight
parents:
9383
diff
changeset
|
82 |
DEBUG(ai, 0, "Couldn't find a suitable AI to start for company '%d'", player); |
4042c17c8055
(svn r9182) [NoAI] -Add: added AIFactory template which all AIs must define, as this
truelight
parents:
9383
diff
changeset
|
83 |
/* XXX -- We have no clean way to handle this yet! */ |
9383
817b07079052
(svn r9173) [NoAI] -Codechange: start both AIs when the game starts more than one.
rubidium
parents:
9365
diff
changeset
|
84 |
} |
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
85 |
} |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
86 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
87 |
/** |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
88 |
* 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
|
89 |
*/ |
2551
436aaaa22ba5
(svn r3080) byte -> PlayerID, int -> EngineID, -1 -> INVALID_ENGINE
tron
parents:
2548
diff
changeset
|
90 |
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
|
91 |
{ |
9360
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
92 |
if (!_ai_enabled) return; |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
93 |
|
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
94 |
/* Called if this AI died */ |
9361
7bb2bd22b16e
(svn r9144) [NoAI] -Change: moved command functions to AIObject, and made AIBase depend on AIObject
truelight
parents:
9360
diff
changeset
|
95 |
delete _ai_player[player]; |
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
96 |
} |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
97 |
|
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 |
* Initialize some AI-related stuff. |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
100 |
*/ |
6573 | 101 |
void AI_Initialize() |
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
102 |
{ |
2706
d31bd0aa0096
(svn r3250) -Fix: AIs weren't uninitialized when a new game was loaded
truelight
parents:
2702
diff
changeset
|
103 |
/* First, make sure all AIs are DEAD! */ |
d31bd0aa0096
(svn r3250) -Fix: AIs weren't uninitialized when a new game was loaded
truelight
parents:
2702
diff
changeset
|
104 |
AI_Uninitialize(); |
d31bd0aa0096
(svn r3250) -Fix: AIs weren't uninitialized when a new game was loaded
truelight
parents:
2702
diff
changeset
|
105 |
|
2767 | 106 |
memset(&_ai_player, 0, sizeof(_ai_player)); |
9360
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
107 |
_ai_frame_counter = 0; |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
108 |
_ai_enabled = true; |
9400
6da42d57fda2
(svn r9195) [NoAI] -Fix: move GetName to AIFactory template, as otherwise GetName()
truelight
parents:
9390
diff
changeset
|
109 |
|
6da42d57fda2
(svn r9195) [NoAI] -Fix: move GetName to AIFactory template, as otherwise GetName()
truelight
parents:
9390
diff
changeset
|
110 |
AIFactoryBase::RunInitializers(); |
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
111 |
} |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
112 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
113 |
/** |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
114 |
* Deinitializer for AI-related stuff. |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
115 |
*/ |
6573 | 116 |
void AI_Uninitialize() |
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
117 |
{ |
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3950
diff
changeset
|
118 |
const Player* p; |
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
119 |
|
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
diff
changeset
|
120 |
FOR_ALL_PLAYERS(p) { |
2767 | 121 |
if (p->is_active && p->is_ai) AI_PlayerDied(p->index); |
2395
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 |
} |
9360
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
124 |
|
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
125 |
/** |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
126 |
* Is it allowed to start a new AI. |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
127 |
* This function checks some boundries to see if we should launch a new AI. |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
128 |
* @return True if we can start a new AI. |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
129 |
*/ |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
130 |
bool AI_AllowNewAI() |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
131 |
{ |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
132 |
/* If disabled, no AI */ |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
133 |
if (!_ai_enabled) return false; |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
134 |
|
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
135 |
/* If in network, but no server, no AI */ |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
136 |
if (_networking && !_network_server) return false; |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
137 |
|
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
138 |
/* If in network, and server, possible AI */ |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
139 |
if (_networking && _network_server) { |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
140 |
/* Do we want AIs in multiplayer? */ |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
141 |
if (!_patches.ai_in_multiplayer) return false; |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
142 |
} |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
143 |
|
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
144 |
return true; |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
9359
diff
changeset
|
145 |
} |