Mercurial > hg > openttd
changeset 18649:9d5d9d24be00 draft
(svn r23496) -Fix: [Squirrel] Provide a proper error message when the _cmp meta-function doesn't return an integer
author | yexo <yexo@openttd.org> |
---|---|
date | Sun, 11 Dec 2011 15:52:18 +0000 |
parents | f68b9653f952 |
children | 7e084b7495c6 |
files | src/3rdparty/squirrel/squirrel/sqvm.cpp |
diffstat | 1 files changed, 8 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/3rdparty/squirrel/squirrel/sqvm.cpp +++ b/src/3rdparty/squirrel/squirrel/sqvm.cpp @@ -195,14 +195,19 @@ 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{