src/ai/NoAI/NoAI.hpp
author truelight
Fri, 16 Mar 2007 17:03:49 +0000
branchnoai
changeset 9441 03da911c8d5f
child 9444 fd27df7ca2a0
permissions -rw-r--r--
(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 */