diff options
author | yexo <yexo@openttd.org> | 2009-02-13 17:17:34 +0000 |
---|---|---|
committer | yexo <yexo@openttd.org> | 2009-02-13 17:17:34 +0000 |
commit | 8e14d77d0509e3b2d2162d16c2f9696680b0b1a0 (patch) | |
tree | 569a356b10c209708942b4184b1d6f9b100e228b /src/ai/ai_info.cpp | |
parent | 15b9366f0687182d635bb3e4bdce9451534a82ad (diff) | |
download | openttd-8e14d77d0509e3b2d2162d16c2f9696680b0b1a0.tar.xz |
(svn r15467) -Fix [NoAI]: AIs with an error in their info.nut are no longer available in-game.
Diffstat (limited to 'src/ai/ai_info.cpp')
-rw-r--r-- | src/ai/ai_info.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/ai/ai_info.cpp b/src/ai/ai_info.cpp index de1a71bc9..d55c6e57c 100644 --- a/src/ai/ai_info.cpp +++ b/src/ai/ai_info.cpp @@ -45,9 +45,9 @@ AILibrary::~AILibrary() free((void *)this->category); } -void AIFileInfo::GetSettings() const +bool AIFileInfo::GetSettings() { - this->engine->CallMethod(*this->SQ_instance, "GetSettings", NULL, -1); + return this->engine->CallMethod(*this->SQ_instance, "GetSettings", NULL, -1); } bool AIFileInfo::CheckMethod(const char *name) const @@ -90,13 +90,13 @@ bool AIFileInfo::CheckMethod(const char *name) const info->main_script = strdup(info->base->GetMainScript()); /* Cache the data the info file gives us. */ - info->author = info->engine->CallStringMethodStrdup(*info->SQ_instance, "GetAuthor"); - info->name = info->engine->CallStringMethodStrdup(*info->SQ_instance, "GetName"); - info->short_name = info->engine->CallStringMethodStrdup(*info->SQ_instance, "GetShortName"); - info->description = info->engine->CallStringMethodStrdup(*info->SQ_instance, "GetDescription"); - info->date = info->engine->CallStringMethodStrdup(*info->SQ_instance, "GetDate"); - info->version = info->engine->CallIntegerMethod(*info->SQ_instance, "GetVersion"); - info->instance_name = info->engine->CallStringMethodStrdup(*info->SQ_instance, "CreateInstance"); + if (!info->engine->CallStringMethodStrdup(*info->SQ_instance, "GetAuthor", &info->author)) return SQ_ERROR; + if (!info->engine->CallStringMethodStrdup(*info->SQ_instance, "GetName", &info->name)) return SQ_ERROR; + if (!info->engine->CallStringMethodStrdup(*info->SQ_instance, "GetShortName", &info->short_name)) return SQ_ERROR; + if (!info->engine->CallStringMethodStrdup(*info->SQ_instance, "GetDescription", &info->description)) return SQ_ERROR; + if (!info->engine->CallStringMethodStrdup(*info->SQ_instance, "GetDate", &info->date)) return SQ_ERROR; + 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; return 0; } @@ -118,10 +118,10 @@ bool AIFileInfo::CheckMethod(const char *name) const /* Check if we have settings */ if (info->engine->MethodExists(*info->SQ_instance, "GetSettings")) { - info->GetSettings(); + if (!info->GetSettings()) return SQ_ERROR; } if (info->engine->MethodExists(*info->SQ_instance, "MinVersionToLoad")) { - info->min_loadable_version = info->engine->CallIntegerMethod(*info->SQ_instance, "MinVersionToLoad"); + if (!info->engine->CallIntegerMethod(*info->SQ_instance, "MinVersionToLoad", &info->min_loadable_version)) return SQ_ERROR; } else { info->min_loadable_version = info->GetVersion(); } @@ -367,7 +367,10 @@ int AIInfo::GetSettingDefaultValue(const char *name) const } /* Cache the category */ - library->category = library->engine->CallStringMethodStrdup(*library->SQ_instance, "GetCategory"); + if (!library->engine->CallStringMethodStrdup(*library->SQ_instance, "GetCategory", &library->category)) { + delete library; + return SQ_ERROR; + } /* Register the Library to the base system */ library->base->RegisterLibrary(library); |