Overview
Comment: | Implement the INVENTORY virtual table. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
84ff96ae0ffcc8e153e4011ab4b73633 |
User & Date: | user on 2021-09-19 06:08:05 |
Other Links: | manifest | tags |
Context
2021-09-22
| ||
01:11 | Add missing documentation for MAX_LEVEL SQL function, and default key bindings for go to first/last level. check-in: f6ec7187a2 user: user tags: trunk | |
2021-09-19
| ||
06:08 | Implement the INVENTORY virtual table. check-in: 84ff96ae0f user: user tags: trunk | |
01:48 | Add function calls in pattern matching. check-in: c43bc33f91 user: user tags: trunk | |
Changes
Modified function.c from [d0c048fa84] to [2d1691d53b].
︙ | ︙ | |||
972 973 974 975 976 977 978 979 980 981 982 983 984 985 | Module(vt_objects, .xBestIndex=vt1_objects_index, .xColumn=vt1_objects_column, .xFilter=vt1_objects_filter, .xNext=vt1_objects_next, .xUpdate=vt1_objects_update, ); void init_sql_functions(sqlite3_int64*ptr0,sqlite3_int64*ptr1) { sqlite3_create_function(userdb,"BASENAME",0,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_basename,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,"HEROMESH_ESCAPE",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_heromesh_escape,0,0); | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 | Module(vt_objects, .xBestIndex=vt1_objects_index, .xColumn=vt1_objects_column, .xFilter=vt1_objects_filter, .xNext=vt1_objects_next, .xUpdate=vt1_objects_update, ); static int vt1_inventory_index(sqlite3_vtab*vt,sqlite3_index_info*info) { int i; info->estimatedCost=16.0; info->estimatedRows=16; for(i=0;i<info->nConstraint;i++) if(info->aConstraint[i].usable && info->aConstraint[i].op==SQLITE_INDEX_CONSTRAINT_EQ && !info->aConstraint[i].iColumn) { info->aConstraintUsage[i].omit=1; info->aConstraintUsage[i].argvIndex=1; info->idxFlags=SQLITE_INDEX_SCAN_UNIQUE; info->estimatedCost=1.0; info->estimatedRows=1; break; } return SQLITE_OK; } static int vt1_inventory_next(sqlite3_vtab_cursor*pcur) { Cursor*cur=(void*)pcur; ++cur->rowid; if(cur->unique || cur->rowid>=ninventory) cur->eof=1; return SQLITE_OK; } static int vt1_inventory_filter(sqlite3_vtab_cursor*pcur,int idxNum,const char*idxStr,int argc,sqlite3_value**argv) { Cursor*cur=(void*)pcur; if(argc) { if(sqlite3_value_type(*argv)==SQLITE_NULL) { eof: cur->eof=1; return SQLITE_OK; } cur->rowid=sqlite3_value_int(*argv); if(cur->rowid>=ninventory || cur->rowid<0) goto eof; cur->unique=1; cur->eof=0; return SQLITE_OK; } else { cur->rowid=-1; cur->unique=0; cur->eof=0; } return vt1_inventory_next(pcur); } static int vt1_inventory_column(sqlite3_vtab_cursor*pcur,sqlite3_context*cxt,int n) { Cursor*cur=(void*)pcur; switch(n) { case 0: sqlite3_result_int64(cxt,cur->rowid); break; case 1: sqlite3_result_int(cxt,inventory[cur->rowid].class); break; case 2: sqlite3_result_int(cxt,inventory[cur->rowid].image); break; case 3: sqlite3_result_int(cxt,inventory[cur->rowid].value); break; } return SQLITE_OK; } Module(vt_inventory, .xBestIndex=vt1_inventory_index, .xColumn=vt1_inventory_column, .xFilter=vt1_inventory_filter, .xNext=vt1_inventory_next, ); void init_sql_functions(sqlite3_int64*ptr0,sqlite3_int64*ptr1) { sqlite3_create_function(userdb,"BASENAME",0,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_basename,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,"HEROMESH_ESCAPE",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_heromesh_escape,0,0); |
︙ | ︙ | |||
1012 1013 1014 1015 1016 1017 1018 1019 | sqlite3_create_module(userdb,"CLASSES",&vt_classes,"CREATE TABLE `CLASSES`(`ID` INTEGER PRIMARY KEY, `NAME` TEXT, `EDITORHELP` TEXT, `HELP` TEXT," "`INPUT` INT, `QUIZ` INT, `TRACEIN` INT, `TRACEOUT` INT, `GROUP` TEXT, `PLAYER` INT);"); sqlite3_create_module(userdb,"MESSAGES",&vt_messages,"CREATE TABLE `MESSAGES`(`ID` INTEGER PRIMARY KEY, `NAME` TEXT, `TRACE` INT);"); sqlite3_create_module(userdb,"OBJECTS",&vt_objects,"CREATE TABLE `OBJECTS`(`ID` INTEGER PRIMARY KEY, `CLASS` INT, `MISC1` INT, `MISC2` INT, `MISC3` INT," "`IMAGE` INT, `DIR` INT, `X` INT, `Y` INT, `UP` INT, `DOWN` INT, `DENSITY` INT HIDDEN, `BIZARRO` INT HIDDEN);"); sqlite3_create_module(userdb,"BIZARRO_OBJECTS",&vt_objects,"CREATE TABLE `OBJECTS`(`ID` INTEGER PRIMARY KEY, `CLASS` INT, `MISC1` INT, `MISC2` INT, `MISC3` INT," "`IMAGE` INT, `DIR` INT, `X` INT, `Y` INT, `UP` INT, `DOWN` INT, `DENSITY` INT HIDDEN, `BIZARRO` INT HIDDEN);"); } | > | 1073 1074 1075 1076 1077 1078 1079 1080 1081 | sqlite3_create_module(userdb,"CLASSES",&vt_classes,"CREATE TABLE `CLASSES`(`ID` INTEGER PRIMARY KEY, `NAME` TEXT, `EDITORHELP` TEXT, `HELP` TEXT," "`INPUT` INT, `QUIZ` INT, `TRACEIN` INT, `TRACEOUT` INT, `GROUP` TEXT, `PLAYER` INT);"); sqlite3_create_module(userdb,"MESSAGES",&vt_messages,"CREATE TABLE `MESSAGES`(`ID` INTEGER PRIMARY KEY, `NAME` TEXT, `TRACE` INT);"); sqlite3_create_module(userdb,"OBJECTS",&vt_objects,"CREATE TABLE `OBJECTS`(`ID` INTEGER PRIMARY KEY, `CLASS` INT, `MISC1` INT, `MISC2` INT, `MISC3` INT," "`IMAGE` INT, `DIR` INT, `X` INT, `Y` INT, `UP` INT, `DOWN` INT, `DENSITY` INT HIDDEN, `BIZARRO` INT HIDDEN);"); sqlite3_create_module(userdb,"BIZARRO_OBJECTS",&vt_objects,"CREATE TABLE `OBJECTS`(`ID` INTEGER PRIMARY KEY, `CLASS` INT, `MISC1` INT, `MISC2` INT, `MISC3` INT," "`IMAGE` INT, `DIR` INT, `X` INT, `Y` INT, `UP` INT, `DOWN` INT, `DENSITY` INT HIDDEN, `BIZARRO` INT HIDDEN);"); sqlite3_create_module(userdb,"INVENTORY",&vt_inventory,"CREATE TABLE `INVENTORY`(`ID` INTEGER PRIMARY KEY, `CLASS` INT, `IMAGE` INT, `VALUE` INT);"); } |
Modified sql.doc from [0dad571720] to [33a3803519].
︙ | ︙ | |||
131 132 133 134 135 136 137 138 139 140 141 142 143 144 | TEXT, "HELP" TEXT, "INPUT" INT, "QUIZ" INT, "TRACEIN" INT, "TRACEOUT" INT, "GROUP" TEXT, "PLAYER" INT); * A list of classes in the current puzzle set; mostly read-only. Only QUIZ, TRACEIN, and TRACEOUT are writable. If TRACEIN is true then it will trace messages received by this class (if tracing is enabled). If TRACEOUT is true then it will trace messages sent by this class (if tracing is enabled). CREATE TABLE "MESSAGES"("ID" INTEGER PRIMARY KEY, "NAME" TEXT, "TRACE" INT); * The list of messages in the current puzzle set; mostly read-only. Only TRACE is writable; if true, this message will be traced. CREATE TABLE "OBJECTS"("ID" INTEGER PRIMARY KEY, "CLASS" INT, "MISC1" INT, | > > > > > | 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | TEXT, "HELP" TEXT, "INPUT" INT, "QUIZ" INT, "TRACEIN" INT, "TRACEOUT" INT, "GROUP" TEXT, "PLAYER" INT); * A list of classes in the current puzzle set; mostly read-only. Only QUIZ, TRACEIN, and TRACEOUT are writable. If TRACEIN is true then it will trace messages received by this class (if tracing is enabled). If TRACEOUT is true then it will trace messages sent by this class (if tracing is enabled). CREATE TABLE `INVENTORY`(`ID` INTEGER PRIMARY KEY, `CLASS` INT, `IMAGE` INT, `VALUE` INT);" * This table contains the current inventory, and is read-only. It is not meaningful in the editor. CREATE TABLE "MESSAGES"("ID" INTEGER PRIMARY KEY, "NAME" TEXT, "TRACE" INT); * The list of messages in the current puzzle set; mostly read-only. Only TRACE is writable; if true, this message will be traced. CREATE TABLE "OBJECTS"("ID" INTEGER PRIMARY KEY, "CLASS" INT, "MISC1" INT, |
︙ | ︙ |