(svn r13563) [NoAI] -Fix: added some asserts to ensure sanity of AI*Modes. noai
authortruebrain
Wed, 18 Jun 2008 10:58:16 +0000
branchnoai
changeset 11007 d57c2e53679b
parent 11002 3a11ba88eb7c
child 11010 69532778abab
(svn r13563) [NoAI] -Fix: added some asserts to ensure sanity of AI*Modes.
-Note: it has to be said that currently 'scoping' is broken, and it is possible to cause an assert. But it is better to have an assert, than to build stuff for real in TestMode ;)
src/ai/api/ai_execmode.cpp
src/ai/api/ai_testmode.cpp
src/ai/api/ai_transactionmode.cpp
--- a/src/ai/api/ai_execmode.cpp	Tue Jun 17 23:16:33 2008 +0000
+++ b/src/ai/api/ai_execmode.cpp	Wed Jun 18 10:58:16 2008 +0000
@@ -21,5 +21,6 @@
 
 AIExecMode::~AIExecMode()
 {
+	assert(this->GetDoCommandModeInstance() == this);
 	this->SetDoCommandMode(this->last_mode, this->last_instance);
 }
--- a/src/ai/api/ai_testmode.cpp	Tue Jun 17 23:16:33 2008 +0000
+++ b/src/ai/api/ai_testmode.cpp	Wed Jun 18 10:58:16 2008 +0000
@@ -21,5 +21,6 @@
 
 AITestMode::~AITestMode()
 {
+	assert(this->GetDoCommandModeInstance() == this);
 	this->SetDoCommandMode(this->last_mode, this->last_instance);
 }
--- a/src/ai/api/ai_transactionmode.cpp	Tue Jun 17 23:16:33 2008 +0000
+++ b/src/ai/api/ai_transactionmode.cpp	Wed Jun 18 10:58:16 2008 +0000
@@ -39,6 +39,7 @@
 
 AITransactionMode::~AITransactionMode()
 {
+	assert(this->GetDoCommandModeInstance() == this);
 	this->SetDoCommandMode(this->last_mode, this->last_instance);
 
 	/* Clean up the command_stack nicely (as in: free the cmd_text) */