summaryrefslogtreecommitdiff
path: root/src/ai
diff options
context:
space:
mode:
authortruebrain <truebrain@openttd.org>2011-11-29 23:21:13 +0000
committertruebrain <truebrain@openttd.org>2011-11-29 23:21:13 +0000
commitbbd9facb44dc09ded5500918319b770c63c0a981 (patch)
treee0aec49e211484cb1235fcbf1689de5b86dd2dda /src/ai
parent99cb93ef6faf7e89720ca0caf5536bb488be990e (diff)
downloadopenttd-bbd9facb44dc09ded5500918319b770c63c0a981.tar.xz
(svn r23358) -Codechange: move AI_FatalError to Script_FatalError (and to its own file)
Diffstat (limited to 'src/ai')
-rw-r--r--src/ai/ai_instance.cpp11
-rw-r--r--src/ai/ai_instance.hpp23
2 files changed, 6 insertions, 28 deletions
diff --git a/src/ai/ai_instance.cpp b/src/ai/ai_instance.cpp
index 729344fce..324242957 100644
--- a/src/ai/ai_instance.cpp
+++ b/src/ai/ai_instance.cpp
@@ -18,6 +18,7 @@
#include "ai_config.hpp"
#include "ai_gui.hpp"
+#include "../script/script_fatalerror.hpp"
#include "../script/script_storage.hpp"
#include "ai_instance.hpp"
@@ -154,7 +155,7 @@ void AIInstance::Initialize(AIInfo *info)
return;
}
ScriptObject::SetAllowDoCommand(true);
- } catch (AI_FatalError e) {
+ } catch (Script_FatalError e) {
this->is_dead = true;
this->engine->ThrowError(e.GetErrorMessage());
this->engine->ResumeError();
@@ -375,7 +376,7 @@ void AIInstance::GameLoop()
} catch (AI_VMSuspend e) {
this->suspend = e.GetSuspendTime();
this->callback = e.GetSuspendCallback();
- } catch (AI_FatalError e) {
+ } catch (Script_FatalError e) {
this->is_dead = true;
this->engine->ThrowError(e.GetErrorMessage());
this->engine->ResumeError();
@@ -396,7 +397,7 @@ void AIInstance::GameLoop()
} catch (AI_VMSuspend e) {
this->suspend = e.GetSuspendTime();
this->callback = e.GetSuspendCallback();
- } catch (AI_FatalError e) {
+ } catch (Script_FatalError e) {
this->is_dead = true;
this->engine->ThrowError(e.GetErrorMessage());
this->engine->ResumeError();
@@ -640,9 +641,9 @@ void AIInstance::Save()
this->engine->CrashOccurred();
return;
}
- } catch (AI_FatalError e) {
+ } catch (Script_FatalError e) {
/* If we don't mark the AI as dead here cleaning up the squirrel
- * stack could throw AI_FatalError again. */
+ * stack could throw Script_FatalError again. */
this->is_dead = true;
this->engine->ThrowError(e.GetErrorMessage());
this->engine->ResumeError();
diff --git a/src/ai/ai_instance.hpp b/src/ai/ai_instance.hpp
index 3f120a385..63da6f967 100644
--- a/src/ai/ai_instance.hpp
+++ b/src/ai/ai_instance.hpp
@@ -51,29 +51,6 @@ private:
AISuspendCallbackProc *callback; ///< Callback function to call when the AI can run again.
};
-/**
- * A throw-class that is given when the AI made a fatal error.
- */
-class AI_FatalError {
-public:
- /**
- * Creates a "fatal error" exception.
- * @param msg The message describing the cause of the fatal error.
- */
- AI_FatalError(const char *msg) :
- msg(msg)
- {}
-
- /**
- * The error message associated with the fatal error.
- * @return The error message.
- */
- const char *GetErrorMessage() { return msg; }
-
-private:
- const char *msg; ///< The error message.
-};
-
/** Runtime information about an AI like a pointer to the squirrel vm and the current state. */
class AIInstance {
public: