diff options
author | yexo <yexo@openttd.org> | 2011-12-11 15:52:18 +0000 |
---|---|---|
committer | yexo <yexo@openttd.org> | 2011-12-11 15:52:18 +0000 |
commit | 8f36e70e354c7af1f82d27f406d02a0bf9528b45 (patch) | |
tree | 277b89cb8c983019c171eabe3b325d2bba58d9f3 /src/3rdparty/squirrel | |
parent | 686297c2c6517419e2f9c80d255b5d9c07fa32d9 (diff) | |
download | openttd-8f36e70e354c7af1f82d27f406d02a0bf9528b45.tar.xz |
(svn r23496) -Fix: [Squirrel] Provide a proper error message when the _cmp meta-function doesn't return an integer
Diffstat (limited to 'src/3rdparty/squirrel')
-rw-r--r-- | src/3rdparty/squirrel/squirrel/sqvm.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/3rdparty/squirrel/squirrel/sqvm.cpp b/src/3rdparty/squirrel/squirrel/sqvm.cpp index b4ff85d95..dae5ff4a2 100644 --- a/src/3rdparty/squirrel/squirrel/sqvm.cpp +++ b/src/3rdparty/squirrel/squirrel/sqvm.cpp @@ -195,14 +195,19 @@ bool SQVM::ObjCmp(const SQObjectPtr &o1,const SQObjectPtr &o2,SQInteger &result) case OT_INSTANCE: if(_delegable(o1)->_delegate) { Push(o1);Push(o2); - if(CallMetaMethod(_delegable(o1),MT_CMP,2,res)) break; + if(CallMetaMethod(_delegable(o1),MT_CMP,2,res)) { + if(type(res) != OT_INTEGER) { + Raise_Error(_SC("_cmp must return an integer")); + return false; + } + _RET_SUCCEED(_integer(res)) + } } //continues through (no break needed) default: _RET_SUCCEED( _userpointer(o1) < _userpointer(o2)?-1:1 ); } - if(type(res)!=OT_INTEGER) { Raise_CompareError(o1,o2); return false; } - _RET_SUCCEED(_integer(res)); + assert(0); } else{ |