(svn r12376) [NoAI] -Remove: from this day on, C++ is removed as supported language to write your NoAI in. The only language to use is Squirrel.
This commit is as preparation of the complete removal of this support.
For reasons why, please check http://wiki.openttd.org/index.php/AI:Why_No_C%2B%2B
--- a/projects/openttd_vs80.vcproj Mon Mar 03 16:15:24 2008 +0000
+++ b/projects/openttd_vs80.vcproj Mon Mar 17 15:58:28 2008 +0000
@@ -1913,18 +1913,6 @@
</File>
</Filter>
<Filter
- Name="AI C++"
- >
- <File
- RelativePath=".\..\src\ai\NoAI\NoAI.cpp"
- >
- </File>
- <File
- RelativePath=".\..\src\ai\NoAI\NoAI.hpp"
- >
- </File>
- </Filter>
- <Filter
Name="AI API"
>
<File
--- a/projects/openttd_vs90.vcproj Mon Mar 03 16:15:24 2008 +0000
+++ b/projects/openttd_vs90.vcproj Mon Mar 17 15:58:28 2008 +0000
@@ -1910,18 +1910,6 @@
</File>
</Filter>
<Filter
- Name="AI C++"
- >
- <File
- RelativePath=".\..\src\ai\NoAI\NoAI.cpp"
- >
- </File>
- <File
- RelativePath=".\..\src\ai\NoAI\NoAI.hpp"
- >
- </File>
- </Filter>
- <Filter
Name="AI API"
>
<File
--- a/source.list Mon Mar 03 16:15:24 2008 +0000
+++ b/source.list Mon Mar 17 15:58:28 2008 +0000
@@ -393,10 +393,6 @@
ai/ai_threads.cpp
ai/ai_threads.h
-# AI C++
-ai/NoAI/NoAI.cpp
-ai/NoAI/NoAI.hpp
-
# AI API
ai/api/ai_abstractlist.hpp
ai/api/ai_accounting.hpp
--- a/src/ai/NoAI/NoAI.cpp Mon Mar 03 16:15:24 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-/* $Id$ */
-
-/** @file NoAI.cpp a simple C++ AI that will never be an AI */
-
-#include "../../stdafx.h"
-#include "NoAI.hpp"
-
-static FNoAI iFNoAI; ///< Tell the AI-core that we have an AI with which we like to play.
-
-/* Define the GameLoop. This is called every tick. */
-void NoAI::GameLoop()
-{
- if (this->GetTick() == 1) {
- if (!this->company.SetCompanyName("NoAI")) {
- char name[32];
- snprintf(name, lengthof(name), "NoAI %d", this->base.Rand());
- this->company.SetCompanyName(name);
- }
- printf("Map size: %d by %d, %d tiles\n", this->map.GetMapSizeX(),
- this->map.GetMapSizeY(), this->map.GetMapSize());
- }
-
- if (this->GetTick() < 10) {
- char *cargo_label = this->cargo.GetCargoLabel(this->GetTick());
- printf("%s is %sfreight and the income is %d per 20 tiles in 10 days\n",
- cargo_label, this->cargo.IsFreight(this->GetTick()) ? "" : "not ",
- this->cargo.GetCargoIncome(20, 10, this->GetTick()));
- free(cargo_label);
- }
-
- if (this->GetTick() < this->industry.GetMaxIndustryID()) {
- if (this->industry.IsValidIndustry(this->GetTick())) {
- char *industry_name = this->industry.GetName(this->GetTick());
- TileIndex t = this->industry.GetLocation(this->GetTick());
-
- printf("Industry %s [%d of %d] at (%d, %d)\n",
- industry_name, this->GetTick(), this->industry.GetIndustryCount(),
- this->map.GetTileX(t), this->map.GetTileY(t));
- }
- }
-
- if (this->GetTick() % 10 == 0) {
- char *company_name = this->company.GetCompanyName(AICompany::MY_COMPANY);
- printf("%s has loaned %d\n", company_name, this->company.GetLoanAmount());
- free(company_name);
- }
-
- if (this->GetTick() % 14 == 0) {
- uint level = (this->company.GetMaxLoanAmount() / this->company.GetLoanInterval()) + 1;
- this->company.SetLoanAmount(this->base.RandRange(level) * this->company.GetLoanInterval());
- }
-
- if (this->GetTick() % 13 == 0) {
- TownID town_id = this->base.RandRange(this->town.GetMaxTownID());
- if (this->town.IsValidTown(town_id)) {
- char *town_name = this->town.GetName(town_id);
- TileIndex t = this->town.GetLocation(town_id);
-
- printf("Town %s [%d of %d] at (%d, %d) with %d inhabitants\n",
- town_name, town_id, this->town.GetTownCount(),
- this->map.GetTileX(t), this->map.GetTileY(t),
- this->town.GetPopulation(town_id));
- }
- }
-}
-
-/* virtual */ void NoAI::Start()
-{
- this->stop = false;
- while (!stop) {
- this->Sleep(1);
- this->GameLoop();
- }
-}
-
-/* virtual */ void NoAI::Stop()
-{
- this->stop = true;
-}
--- a/src/ai/NoAI/NoAI.hpp Mon Mar 03 16:15:24 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-/* $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;
- bool stop;
-
-public:
- /* virtual */ void Start();
- /* virtual */ void Stop();
- void GameLoop();
-};
-
-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 */