Index: function.c ================================================================== --- function.c +++ function.c @@ -163,10 +163,14 @@ a=sqlite3_value_int(*argv)&0xFFFF; if(!a || (a&~0x3FFF) || !classes[a] || (classes[a]->cflags&CF_NOCLASS2)) return; } found: sqlite3_result_int64(cxt,a|((sqlite3_int64)TY_CLASS<<32)); } + +static void fn_gameover(sqlite3_context*cxt,int argc,sqlite3_value**argv) { + sqlite3_result_int(cxt,gameover); +} static void fn_hash(sqlite3_context*cxt,int argc,sqlite3_value**argv) { const unsigned char*u=sqlite3_value_blob(*argv); int n=sqlite3_value_bytes(*argv); long long h=sqlite3_value_int64(argv[1]); @@ -1794,20 +1798,23 @@ sqlite3_create_function(userdb,"BEST_SCORE",0,SQLITE_UTF8,0,fn_best_score,0,0); sqlite3_create_function(userdb,"BYTE",-1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_byte,0,0); sqlite3_create_function(userdb,"CL",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_cl,0,0); sqlite3_create_function(userdb,"CLASS_DATA",2,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_class_data,0,0); sqlite3_create_function(userdb,"CVALUE",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_cvalue,0,0); + sqlite3_create_function(userdb,"GAMEOVER",0,SQLITE_UTF8,0,fn_gameover,0,0); sqlite3_create_function(userdb,"HASH",2,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_hash,0,0); sqlite3_create_function(userdb,"HAS_XY_INPUT",0,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_has_xy_input,0,0); sqlite3_create_function(userdb,"HEROMESH_ESCAPE",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_heromesh_escape,0,0); sqlite3_create_function(userdb,"HEROMESH_TYPE",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_heromesh_type,0,0); sqlite3_create_function(userdb,"HEROMESH_UNESCAPE",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_heromesh_unescape,0,0); sqlite3_create_function(userdb,"INRECT",2,SQLITE_UTF8,0,fn_inrect,0,0); sqlite3_create_function(userdb,"LEVEL",0,SQLITE_UTF8,&level_ord,fn_level,0,0); sqlite3_create_function(userdb,"LEVEL_CACHEID",0,SQLITE_UTF8|SQLITE_DETERMINISTIC,ptr0,fn_cacheid,0,0); + sqlite3_create_function(userdb,"LEVEL_CODE",0,SQLITE_UTF8,&level_code,fn_level,0,0); sqlite3_create_function(userdb,"LEVEL_ID",0,SQLITE_UTF8,&level_id,fn_level,0,0); sqlite3_create_function(userdb,"LEVEL_TITLE",0,SQLITE_UTF8,0,fn_level_title,0,0); + sqlite3_create_function(userdb,"LEVEL_VERSION",0,SQLITE_UTF8,&level_version,fn_level,0,0); sqlite3_create_function(userdb,"LOAD_LEVEL",1,SQLITE_UTF8,0,fn_load_level,0,0); sqlite3_create_function(userdb,"MAX_LEVEL",0,SQLITE_UTF8,0,fn_max_level,0,0); sqlite3_create_function(userdb,"MODSTATE",0,SQLITE_UTF8,0,fn_modstate,0,0); sqlite3_create_function(userdb,"MOVE_LIST",0,SQLITE_UTF8,0,fn_move_list,0,0); sqlite3_create_function(userdb,"MOVENUMBER",0,SQLITE_UTF8,0,fn_movenumber,0,0); Index: sql.doc ================================================================== --- sql.doc +++ sql.doc @@ -63,10 +63,14 @@ CVALUE(number) Makes a game value of type 'class', given the class number. You can also specify the class name instead of the number. +GAMEOVER() + Returns +1 if you win, -1 if you lose, or 0 otherwise. This value is not + meaningful in the editor. + HASH(data,algorithm) Make the hash of the data as a binary blob. See hash.h for a list of the valid numbers to use as the hash algorithm numbers. HAS_XY_INPUT() @@ -91,16 +95,22 @@ The one-based order number of the current level. LEVEL_CACHEID() The user cache ID of the level file. +LEVEL_CODE() + The level code number of the current level. + LEVEL_ID() The ID number of the current level. LEVEL_TITLE() The title of the current level, as a blob. +LEVEL_VERSION() + The version number of the current level. + LOAD_LEVEL(level_id) Only valid when Free Hero Mesh is invoked with the -x switch. Loads the level with the specified ID number. MAX_LEVEL()