summaryrefslogtreecommitdiff
path: root/src/script/script_info.cpp
diff options
context:
space:
mode:
authortruebrain <truebrain@openttd.org>2011-11-29 23:21:52 +0000
committertruebrain <truebrain@openttd.org>2011-11-29 23:21:52 +0000
commite37149a1def6a0e63dda8e0964abf1b82316761a (patch)
treed8f80cee8a3b1eb60feb883796e43300fb50cfb1 /src/script/script_info.cpp
parentae8540f5e080adebca3e54c69aa7cd85a87e550b (diff)
downloadopenttd-e37149a1def6a0e63dda8e0964abf1b82316761a.tar.xz
(svn r23362) -Codechange: refactor AIScanner, splitting it in AIScannerInfo and AIScannerLibrary
Diffstat (limited to 'src/script/script_info.cpp')
-rw-r--r--src/script/script_info.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/script/script_info.cpp b/src/script/script_info.cpp
index 8255bc04b..862907c8b 100644
--- a/src/script/script_info.cpp
+++ b/src/script/script_info.cpp
@@ -7,7 +7,7 @@
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
-/** @file script_info.cpp Implementation of ScriptFileInfo. */
+/** @file script_info.cpp Implementation of ScriptInfo. */
#include "../stdafx.h"
@@ -21,7 +21,7 @@ static const int MAX_GET_OPS = 1000;
/** Number of operations to create an instance of a script. */
static const int MAX_CREATEINSTANCE_OPS = 100000;
-ScriptFileInfo::~ScriptFileInfo()
+ScriptInfo::~ScriptInfo()
{
free(this->author);
free(this->name);
@@ -35,7 +35,7 @@ ScriptFileInfo::~ScriptFileInfo()
free(this->SQ_instance);
}
-bool ScriptFileInfo::CheckMethod(const char *name) const
+bool ScriptInfo::CheckMethod(const char *name) const
{
if (!this->engine->MethodExists(*this->SQ_instance, name)) {
char error[1024];
@@ -46,16 +46,18 @@ bool ScriptFileInfo::CheckMethod(const char *name) const
return true;
}
-/* static */ SQInteger ScriptFileInfo::Constructor(HSQUIRRELVM vm, ScriptFileInfo *info)
+/* static */ SQInteger ScriptInfo::Constructor(HSQUIRRELVM vm, ScriptInfo *info)
{
/* Set some basic info from the parent */
info->SQ_instance = MallocT<SQObject>(1);
Squirrel::GetInstance(vm, info->SQ_instance, 2);
/* Make sure the instance stays alive over time */
sq_addref(vm, info->SQ_instance);
- ScriptScanner *scanner = (ScriptScanner *)Squirrel::GetGlobalPointer(vm);
- info->engine = scanner->GetEngine();
+ info->scanner = (ScriptScanner *)Squirrel::GetGlobalPointer(vm);
+ info->engine = info->scanner->GetEngine();
+
+ /* Ensure the mandatory functions exist */
static const char * const required_functions[] = {
"GetAuthor",
"GetName",
@@ -69,8 +71,9 @@ bool ScriptFileInfo::CheckMethod(const char *name) const
if (!info->CheckMethod(required_functions[i])) return SQ_ERROR;
}
- info->main_script = strdup(scanner->GetMainScript());
- const char *tar_name = scanner->GetTarFile();
+ /* Get location information of the scanner */
+ info->main_script = strdup(info->scanner->GetMainScript());
+ const char *tar_name = info->scanner->GetTarFile();
if (tar_name != NULL) info->tar_file = strdup(tar_name);
/* Cache the data the info file gives us. */