~ubuntu-branches/debian/squeeze/openttd/squeeze

« back to all changes in this revision

Viewing changes to src/ai/ai.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Jordi Mallach, Matthijs Kooijman, Jordi Mallach
  • Date: 2009-04-15 18:22:10 UTC
  • mfrom: (1.1.6 upstream) (2.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090415182210-22ktb8kdbp2tf3bm
[ Matthijs Kooijman ]
* New upstream release.
* Remove Debian specific desktop file, upstream provides one now. 
* Add debian/watch file.

[ Jordi Mallach ]
* Bump Standards-Version to 3.8.1, with no changes required.
* Move to debhelper compat 7. Bump Build-Depends accordingly.
* Use dh_prep.
* Add "set -e" to config script.
* Remove a few extra doc files that get installed by upstream Makefile.
* Add more complete copyright information.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: ai.hpp 15324 2009-02-03 18:08:07Z smatz $ */
 
2
 
 
3
/** @file ai.hpp Base functions for all AIs. */
 
4
 
 
5
#ifndef AI_HPP
 
6
#define AI_HPP
 
7
 
 
8
#include "api/ai_event_types.hpp"
 
9
#include "../date_type.h"
 
10
#include "../core/string_compare_type.hpp"
 
11
 
 
12
typedef std::map<const char *, class AIInfo *, StringCompare> AIInfoList;
 
13
 
 
14
 
 
15
void CcAI(bool success, TileIndex tile, uint32 p1, uint32 p2);
 
16
 
 
17
class AI {
 
18
public:
 
19
        /**
 
20
         * The default months AIs start after eachother.
 
21
         */
 
22
        enum StartNext {
 
23
                START_NEXT_EASY   = DAYS_IN_YEAR * 2,
 
24
                START_NEXT_MEDIUM = DAYS_IN_YEAR,
 
25
                START_NEXT_HARD   = DAYS_IN_YEAR / 2,
 
26
                START_NEXT_MIN    = 1,
 
27
                START_NEXT_MAX    = 3600,
 
28
                START_NEXT_DEVIATION = 60,
 
29
        };
 
30
 
 
31
        /**
 
32
         * Is it possible to start a new AI company?
 
33
         * @return True if a new AI company can be started.
 
34
         */
 
35
        static bool CanStartNew();
 
36
 
 
37
        /**
 
38
         * Start a new AI company.
 
39
         * @param company At which slot the AI company should start.
 
40
         */
 
41
        static void StartNew(CompanyID company);
 
42
 
 
43
        /**
 
44
         * Called every game-tick to let AIs do something.
 
45
         */
 
46
        static void GameLoop();
 
47
 
 
48
        /**
 
49
         * Get the current AI tick.
 
50
         */
 
51
        static uint GetTick();
 
52
 
 
53
        /**
 
54
         * Stop a company to be controlled by an AI.
 
55
         * @param company The company from which the AI needs to detach.
 
56
         * @pre !IsHumanCompany(company).
 
57
         */
 
58
        static void Stop(CompanyID company);
 
59
 
 
60
        /**
 
61
         * Kill any and all AIs we manage.
 
62
         */
 
63
        static void KillAll();
 
64
 
 
65
        /**
 
66
         * Initialize the AI system.
 
67
         */
 
68
        static void Initialize();
 
69
 
 
70
        /**
 
71
         * Uninitialize the AI system
 
72
         * @param keepConfig Should we keep AIConfigs, or can we free that memory?
 
73
         */
 
74
        static void Uninitialize(bool keepConfig);
 
75
 
 
76
        /**
 
77
         * Reset all AIConfigs, and make them reload their AIInfo.
 
78
         * If the AIInfo could no longer be found, an error is reported to the user.
 
79
         */
 
80
        static void ResetConfig();
 
81
 
 
82
        /**
 
83
         * Queue a new event for an AI.
 
84
         */
 
85
        static void NewEvent(CompanyID company, AIEvent *event);
 
86
 
 
87
        /**
 
88
         * Broadcast a new event to all active AIs.
 
89
         */
 
90
        static void BroadcastNewEvent(AIEvent *event, CompanyID skip_company = MAX_COMPANIES);
 
91
 
 
92
        /**
 
93
         * Save data from an AI to a savegame.
 
94
         */
 
95
        static void Save(CompanyID company);
 
96
 
 
97
        /**
 
98
         * Load data for an AI from a savegame.
 
99
         */
 
100
        static void Load(CompanyID company, int version);
 
101
 
 
102
        /**
 
103
         * Get the number of days before the next AI should start.
 
104
         */
 
105
        static int GetStartNextTime();
 
106
 
 
107
        static char *GetConsoleList(char *p, const char *last);
 
108
        static const AIInfoList *GetInfoList();
 
109
        static const AIInfoList *GetUniqueInfoList();
 
110
        static AIInfo *FindInfo(const char *name, int version);
 
111
        static bool ImportLibrary(const char *library, const char *class_name, int version, HSQUIRRELVM vm);
 
112
        static void Rescan();
 
113
#if defined(ENABLE_NETWORK)
 
114
        static bool HasAI(const struct ContentInfo *ci, bool md5sum);
 
115
#endif
 
116
private:
 
117
        static uint frame_counter;
 
118
        static class AIScanner *ai_scanner;
 
119
};
 
120
 
 
121
#endif /* AI_HPP */