mirror of https://github.com/OpenTTD/OpenTTD
(svn r15090) -Add [NoAI] [API CHANGE]: info.nut/library.nut now requires a function GetShortName(), which should return a 4 (four) character string, unique throughout the world. This id is simular to a GRFid.
parent
606ef3c179
commit
d62a85f2ce
|
@ -3,6 +3,7 @@
|
||||||
class AyStar extends AILibrary {
|
class AyStar extends AILibrary {
|
||||||
function GetAuthor() { return "OpenTTD NoAI Developers Team"; }
|
function GetAuthor() { return "OpenTTD NoAI Developers Team"; }
|
||||||
function GetName() { return "AyStar"; }
|
function GetName() { return "AyStar"; }
|
||||||
|
function GetShortName() { return "GRA*"; }
|
||||||
function GetDescription() { return "An implementation of AyStar"; }
|
function GetDescription() { return "An implementation of AyStar"; }
|
||||||
function GetVersion() { return 4; }
|
function GetVersion() { return 4; }
|
||||||
function GetDate() { return "2008-06-11"; }
|
function GetDate() { return "2008-06-11"; }
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
class Rail extends AILibrary {
|
class Rail extends AILibrary {
|
||||||
function GetAuthor() { return "OpenTTD NoAI Developers Team"; }
|
function GetAuthor() { return "OpenTTD NoAI Developers Team"; }
|
||||||
function GetName() { return "Rail"; }
|
function GetName() { return "Rail"; }
|
||||||
|
function GetShortName() { return "PFRL"; }
|
||||||
function GetDescription() { return "An implementation of a rail pathfinder"; }
|
function GetDescription() { return "An implementation of a rail pathfinder"; }
|
||||||
function GetVersion() { return 1; }
|
function GetVersion() { return 1; }
|
||||||
function GetDate() { return "2008-09-22"; }
|
function GetDate() { return "2008-09-22"; }
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
class Road extends AILibrary {
|
class Road extends AILibrary {
|
||||||
function GetAuthor() { return "OpenTTD NoAI Developers Team"; }
|
function GetAuthor() { return "OpenTTD NoAI Developers Team"; }
|
||||||
function GetName() { return "Road"; }
|
function GetName() { return "Road"; }
|
||||||
|
function GetShortName() { return "PFRO"; }
|
||||||
function GetDescription() { return "An implementation of a road pathfinder"; }
|
function GetDescription() { return "An implementation of a road pathfinder"; }
|
||||||
function GetVersion() { return 3; }
|
function GetVersion() { return 3; }
|
||||||
function GetDate() { return "2008-06-18"; }
|
function GetDate() { return "2008-06-18"; }
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
class BinaryHeap extends AILibrary {
|
class BinaryHeap extends AILibrary {
|
||||||
function GetAuthor() { return "OpenTTD NoAI Developers Team"; }
|
function GetAuthor() { return "OpenTTD NoAI Developers Team"; }
|
||||||
function GetName() { return "Binary Heap"; }
|
function GetName() { return "Binary Heap"; }
|
||||||
|
function GetShortName() { return "QUBH"; }
|
||||||
function GetDescription() { return "An implementation of a Binary Heap"; }
|
function GetDescription() { return "An implementation of a Binary Heap"; }
|
||||||
function GetVersion() { return 1; }
|
function GetVersion() { return 1; }
|
||||||
function GetDate() { return "2008-06-10"; }
|
function GetDate() { return "2008-06-10"; }
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
class FibonacciHeap extends AILibrary {
|
class FibonacciHeap extends AILibrary {
|
||||||
function GetAuthor() { return "OpenTTD NoAI Developers Team"; }
|
function GetAuthor() { return "OpenTTD NoAI Developers Team"; }
|
||||||
function GetName() { return "Fibonacci Heap"; }
|
function GetName() { return "Fibonacci Heap"; }
|
||||||
|
function GetShortName() { return "QUFH"; }
|
||||||
function GetDescription() { return "An implementation of a Fibonacci Heap"; }
|
function GetDescription() { return "An implementation of a Fibonacci Heap"; }
|
||||||
function GetVersion() { return 1; }
|
function GetVersion() { return 1; }
|
||||||
function GetDate() { return "2008-08-22"; }
|
function GetDate() { return "2008-08-22"; }
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
class PriorityQueue extends AILibrary {
|
class PriorityQueue extends AILibrary {
|
||||||
function GetAuthor() { return "OpenTTD NoAI Developers Team"; }
|
function GetAuthor() { return "OpenTTD NoAI Developers Team"; }
|
||||||
function GetName() { return "Priority Queue"; }
|
function GetName() { return "Priority Queue"; }
|
||||||
|
function GetShortName() { return "QUPQ"; }
|
||||||
function GetDescription() { return "An implementation of a Priority Queue"; }
|
function GetDescription() { return "An implementation of a Priority Queue"; }
|
||||||
function GetVersion() { return 2; }
|
function GetVersion() { return 2; }
|
||||||
function GetDate() { return "2008-06-10"; }
|
function GetDate() { return "2008-06-10"; }
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
class Regression extends AIInfo {
|
class Regression extends AIInfo {
|
||||||
function GetAuthor() { return "OpenTTD NoAI Developers Team"; }
|
function GetAuthor() { return "OpenTTD NoAI Developers Team"; }
|
||||||
function GetName() { return "Regression"; }
|
function GetName() { return "Regression"; }
|
||||||
|
function GetShortName() { return "REGR"; }
|
||||||
function GetDescription() { return "This runs regression-tests on all commands. On the same map the result should always be the same."; }
|
function GetDescription() { return "This runs regression-tests on all commands. On the same map the result should always be the same."; }
|
||||||
function GetVersion() { return 1; }
|
function GetVersion() { return 1; }
|
||||||
function GetDate() { return "2007-03-18"; }
|
function GetDate() { return "2007-03-18"; }
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
class WrightAI extends AIInfo {
|
class WrightAI extends AIInfo {
|
||||||
function GetAuthor() { return "OpenTTD NoAI Developers Team"; }
|
function GetAuthor() { return "OpenTTD NoAI Developers Team"; }
|
||||||
function GetName() { return "WrightAI"; }
|
function GetName() { return "WrightAI"; }
|
||||||
|
function GetShortName() { return "WRAI"; }
|
||||||
function GetDescription() { return "A simple AI that tries to beat you with only aircrafts"; }
|
function GetDescription() { return "A simple AI that tries to beat you with only aircrafts"; }
|
||||||
function GetVersion() { return 2; }
|
function GetVersion() { return 2; }
|
||||||
function GetDate() { return "2008-02-24"; }
|
function GetDate() { return "2008-02-24"; }
|
||||||
|
|
|
@ -42,6 +42,12 @@ const char *AIFileInfo::GetName()
|
||||||
return this->name;
|
return this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *AIFileInfo::GetShortName()
|
||||||
|
{
|
||||||
|
if (this->short_name == NULL) this->short_name = this->engine->CallStringMethodStrdup(*this->SQ_instance, "GetShortName");
|
||||||
|
return this->short_name;
|
||||||
|
}
|
||||||
|
|
||||||
const char *AIFileInfo::GetDescription()
|
const char *AIFileInfo::GetDescription()
|
||||||
{
|
{
|
||||||
if (this->description == NULL) this->description = this->engine->CallStringMethodStrdup(*this->SQ_instance, "GetDescription");
|
if (this->description == NULL) this->description = this->engine->CallStringMethodStrdup(*this->SQ_instance, "GetDescription");
|
||||||
|
@ -106,7 +112,7 @@ void AIFileInfo::CheckMethods(SQInteger *res, const char *name)
|
||||||
{
|
{
|
||||||
if (!this->engine->MethodExists(*this->SQ_instance, name)) {
|
if (!this->engine->MethodExists(*this->SQ_instance, name)) {
|
||||||
char error[1024];
|
char error[1024];
|
||||||
snprintf(error, sizeof(error), "your AIFileInfo doesn't have the method '%s'", name);
|
snprintf(error, sizeof(error), "your info.nut/library.nut doesn't have the method '%s'", name);
|
||||||
this->engine->ThrowError(error);
|
this->engine->ThrowError(error);
|
||||||
*res = SQ_ERROR;
|
*res = SQ_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -127,6 +133,7 @@ void AIFileInfo::CheckMethods(SQInteger *res, const char *name)
|
||||||
/* Check if all needed fields are there */
|
/* Check if all needed fields are there */
|
||||||
info->CheckMethods(&res, "GetAuthor");
|
info->CheckMethods(&res, "GetAuthor");
|
||||||
info->CheckMethods(&res, "GetName");
|
info->CheckMethods(&res, "GetName");
|
||||||
|
info->CheckMethods(&res, "GetShortName");
|
||||||
info->CheckMethods(&res, "GetDescription");
|
info->CheckMethods(&res, "GetDescription");
|
||||||
info->CheckMethods(&res, "GetVersion");
|
info->CheckMethods(&res, "GetVersion");
|
||||||
info->CheckMethods(&res, "GetDate");
|
info->CheckMethods(&res, "GetDate");
|
||||||
|
|
|
@ -35,7 +35,7 @@ public:
|
||||||
friend class AIInfo;
|
friend class AIInfo;
|
||||||
friend class AILibrary;
|
friend class AILibrary;
|
||||||
|
|
||||||
AIFileInfo() : author(NULL), name(NULL), description(NULL), date(NULL), instance_name(NULL) {};
|
AIFileInfo() : author(NULL), name(NULL), short_name(NULL), description(NULL), date(NULL), instance_name(NULL) {};
|
||||||
~AIFileInfo();
|
~AIFileInfo();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,6 +48,11 @@ public:
|
||||||
*/
|
*/
|
||||||
const char *GetName();
|
const char *GetName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the 4 character long short name of the AI.
|
||||||
|
*/
|
||||||
|
const char *GetShortName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the description of the AI.
|
* Get the description of the AI.
|
||||||
*/
|
*/
|
||||||
|
@ -106,6 +111,7 @@ private:
|
||||||
class AIScanner *base;
|
class AIScanner *base;
|
||||||
const char *author;
|
const char *author;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
const char *short_name;
|
||||||
const char *description;
|
const char *description;
|
||||||
const char *date;
|
const char *date;
|
||||||
const char *instance_name;
|
const char *instance_name;
|
||||||
|
|
|
@ -16,6 +16,7 @@ const SQChar dummy_script_info[] = _SC("
|
||||||
class DummyAI extends AIInfo { \n\
|
class DummyAI extends AIInfo { \n\
|
||||||
function GetAuthor() { return \"OpenTTD NoAI Developers Team\"; } \n\
|
function GetAuthor() { return \"OpenTTD NoAI Developers Team\"; } \n\
|
||||||
function GetName() { return \"DummyAI\"; } \n\
|
function GetName() { return \"DummyAI\"; } \n\
|
||||||
|
function GetShortName() { return \"DUMM\"; } \n\
|
||||||
function GetDescription() { return \"A Dummy AI that is loaded when your ai/ dir is empty\"; }\n\
|
function GetDescription() { return \"A Dummy AI that is loaded when your ai/ dir is empty\"; }\n\
|
||||||
function GetVersion() { return 1; } \n\
|
function GetVersion() { return 1; } \n\
|
||||||
function GetDate() { return \"2008-07-26\"; } \n\
|
function GetDate() { return \"2008-07-26\"; } \n\
|
||||||
|
|
|
@ -308,6 +308,13 @@ void AIScanner::RegisterAI(AIInfo *info)
|
||||||
{
|
{
|
||||||
const char *ai_name = info->GetDirName();
|
const char *ai_name = info->GetDirName();
|
||||||
|
|
||||||
|
/* Check if GetShortName follows the rules */
|
||||||
|
if (strlen(info->GetShortName()) != 4) {
|
||||||
|
DEBUG(ai, 0, "The AI '%s' returned a string from GetShortName() which is not four characaters. Unable to load the AI.", info->GetDirName());
|
||||||
|
delete info;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Check if we register twice; than the first always wins */
|
/* Check if we register twice; than the first always wins */
|
||||||
if (this->info_list.find(ai_name) != this->info_list.end()) {
|
if (this->info_list.find(ai_name) != this->info_list.end()) {
|
||||||
/* In case they are not the same dir, give a warning */
|
/* In case they are not the same dir, give a warning */
|
||||||
|
|
Loading…
Reference in New Issue