Changeset - r10887:cdbf4a546981
[Not reviewed]
master
0 1 0
Yexo - 15 years ago 2009-01-23 10:30:50
yexo@openttd.org
(svn r15222) -Fix: The squirrel stack was corrupted if an AI called any C++ function during Save().
1 file changed with 6 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/script/squirrel.cpp
Show inline comments
 
@@ -177,6 +177,10 @@ bool Squirrel::Resume(int suspend)
 

	
 
bool Squirrel::CallMethod(HSQOBJECT instance, const char *method_name, HSQOBJECT *ret, int suspend)
 
{
 
	/* Store the stack-location for the return value. We need to
 
	 * restore this after saving or the stack will be corrupted
 
	 * if we're in the middle of a DoCommand. */
 
	SQInteger last_target = this->vm->_suspended_target;
 
	/* Store the current top */
 
	int top = sq_gettop(this->vm);
 
	/* Go to the instance-root */
 
@@ -195,6 +199,8 @@ bool Squirrel::CallMethod(HSQOBJECT inst
 
	/* Reset the top, but don't do so for the AI main function, as we need
 
	 *  a correct stack when resuming. */
 
	if (suspend == -1) sq_settop(this->vm, top);
 
	/* Restore the return-value location. */
 
	this->vm->_suspended_target = last_target;
 

	
 
	return this->vm->_suspended != 0;
 
}
0 comments (0 inline, 0 general)