(svn r16093) -Feature [FS#2808]: Add GetURL() as possible function to info.nut. If AIs implement it, that url is shown when the AI crashes and also in the AI selection window.

This commit is contained in:
yexo
2009-04-19 15:14:23 +00:00
parent 8b09058902
commit f96429a494
5 changed files with 27 additions and 1 deletions

View File

@@ -19,6 +19,7 @@ ScriptFileInfo::~ScriptFileInfo()
free((void *)this->description);
free((void *)this->date);
free((void *)this->instance_name);
free((void *)this->url);
free(this->main_script);
free(this->SQ_instance);
}
@@ -68,5 +69,10 @@ bool ScriptFileInfo::CheckMethod(const char *name) const
if (!info->engine->CallIntegerMethod(*info->SQ_instance, "GetVersion", &info->version)) return SQ_ERROR;
if (!info->engine->CallStringMethodStrdup(*info->SQ_instance, "CreateInstance", &info->instance_name)) return SQ_ERROR;
/* The GetURL function is optional. */
if (info->engine->MethodExists(*info->SQ_instance, "GetURL")) {
if (!info->engine->CallStringMethodStrdup(*info->SQ_instance, "GetURL", &info->url)) return SQ_ERROR;
}
return 0;
}

View File

@@ -17,7 +17,8 @@ public:
short_name(NULL),
description(NULL),
date(NULL),
instance_name(NULL)
instance_name(NULL),
url(NULL)
{}
~ScriptFileInfo();
@@ -56,6 +57,11 @@ public:
*/
const char *GetInstanceName() const { return this->instance_name; }
/**
* Get the website for this script.
*/
const char *GetURL() const { return this->url; }
/**
* Get the filename of the main.nut script.
*/
@@ -83,6 +89,7 @@ private:
const char *date;
const char *instance_name;
int version;
const char *url;
};
#endif /* SCRIPT_INFO */