summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2011-12-11 15:52:18 +0000
committeryexo <yexo@openttd.org>2011-12-11 15:52:18 +0000
commit8f36e70e354c7af1f82d27f406d02a0bf9528b45 (patch)
tree277b89cb8c983019c171eabe3b325d2bba58d9f3 /src
parent686297c2c6517419e2f9c80d255b5d9c07fa32d9 (diff)
downloadopenttd-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')
-rw-r--r--src/3rdparty/squirrel/squirrel/sqvm.cpp11
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{