(svn r9255) [NoAI] -Add: each AI now runs in a seperate thread. The main thread is suspended if any AI thread is running, only one AI thread runs at the time.
-Note: the threading is pretty poor right now, with slow CSleep(1) in them. Code is required to make this better, but it is a start.
-Change: entry point in AI is now Start(). If you return from that, your AI dies.
-Change: if you now run a DoCommand, you won't get a result till one tick later, or worse in MP.
/* $Id$ */
/** @file NoAI.hpp declarations of the class for a simple C++ AI that will never be an AI */
#ifndef NOAI_HPP
#define NOAI_HPP
#include "../ai_factory.hpp"
#include "../api/ai_controller.hpp"
#include "../api/ai_base.hpp"
#include "../api/ai_cargo.hpp"
#include "../api/ai_company.hpp"
#include "../api/ai_industry.hpp"
#include "../api/ai_map.hpp"
#include "../api/ai_town.hpp"
class NoAI: public AIController {
private:
AIBase base;
AICargo cargo;
AICompany company;
AIIndustry industry;
AIMap map;
AITown town;
public:
/* virtual */ void Start();
};
class FNoAI: public AIFactory<FNoAI> {
public:
/* virtual */ const char *GetAuthor() { return "OpenTTD Dev Team"; }
/* virtual */ const char *GetName() { return "NoAI"; }
/* virtual */ const char *GetDescription() { return "Rather simple AI that tests all the functions of the AI layer."; }
/* virtual */ int GetVersion() { return 1; }
/* virtual */ const char *GetDate() { return "2007-03-14"; }
/* virtual */ AIController *CreateInstance() { return new NoAI(); }
};
#endif /* NOAI_HPP */