Differences From Artifact [bb06bdfd76]:
- File function.c — part of check-in [b9447d4488] at 2021-06-10 18:36:40 on branch trunk — Do not try to access levels past beginning or end when skipping levels (user: user, size: 37019) [annotate] [blame] [check-ins using]
To Artifact [d0c048fa84]:
- File function.c — part of check-in [9ded322f4f] at 2021-09-09 06:18:34 on branch trunk — Free Hero Mesh is starting to be bizarro. (user: user, size: 37805) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
13 14 15 16 17 18 19 20 21 22 23 24 25 26 | typedef struct { struct sqlite3_vtab_cursor; sqlite3_int64 rowid; char unique,eof; Uint16 arg[4]; } Cursor; static void find_first_usable_image(const Class*cl,sqlite3_context*cxt) { int i; if(cl->cflags&CF_GROUP) return; if(!cl->images) return; for(i=0;i<cl->nimages;i++) { if(cl->images[i]&0x8000) { | > > | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | typedef struct { struct sqlite3_vtab_cursor; sqlite3_int64 rowid; char unique,eof; Uint16 arg[4]; } Cursor; static void*bizarro_vtab; static void find_first_usable_image(const Class*cl,sqlite3_context*cxt) { int i; if(cl->cflags&CF_GROUP) return; if(!cl->images) return; for(i=0;i<cl->nimages;i++) { if(cl->images[i]&0x8000) { |
︙ | ︙ | |||
360 361 362 363 364 365 366 367 368 369 370 371 372 373 | sqlite3_free(cur); return SQLITE_OK; } static int vt0_connect(sqlite3*db,void*aux,int argc,const char*const*argv,sqlite3_vtab**vt,char**err) { sqlite3_declare_vtab(db,aux); *vt=sqlite3_malloc(sizeof(sqlite3_vtab)); return *vt?SQLITE_OK:SQLITE_NOMEM; } static int vt0_disconnect(sqlite3_vtab*vt) { sqlite3_free(vt); return SQLITE_OK; } | > | 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | sqlite3_free(cur); return SQLITE_OK; } static int vt0_connect(sqlite3*db,void*aux,int argc,const char*const*argv,sqlite3_vtab**vt,char**err) { sqlite3_declare_vtab(db,aux); *vt=sqlite3_malloc(sizeof(sqlite3_vtab)); if(*vt && argv[0][0]=='B') bizarro_vtab=*vt; return *vt?SQLITE_OK:SQLITE_NOMEM; } static int vt0_disconnect(sqlite3_vtab*vt) { sqlite3_free(vt); return SQLITE_OK; } |
︙ | ︙ | |||
631 632 633 634 635 636 637 638 639 640 641 642 643 644 | break; case 10: // DOWN if(objects[cur->rowid]->down!=VOIDLINK) sqlite3_result_int64(cxt,objects[cur->rowid]->down); break; case 11: // DENSITY sqlite3_result_int(cxt,objects[cur->rowid]->density); break; } return SQLITE_OK; } static int vt1_objects_next(sqlite3_vtab_cursor*pcur) { Cursor*cur=(void*)pcur; if(cur->unique) { | > > > | 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 | break; case 10: // DOWN if(objects[cur->rowid]->down!=VOIDLINK) sqlite3_result_int64(cxt,objects[cur->rowid]->down); break; case 11: // DENSITY sqlite3_result_int(cxt,objects[cur->rowid]->density); break; case 12: // BIZARRO sqlite3_result_int(cxt,objects[cur->rowid]->oflags&OF_BIZARRO?1:0); break; } return SQLITE_OK; } static int vt1_objects_next(sqlite3_vtab_cursor*pcur) { Cursor*cur=(void*)pcur; if(cur->unique) { |
︙ | ︙ | |||
659 660 661 662 663 664 665 | } } cur->arg[1]=1; } else if((cur->arg[0]&0x0066) && !cur->arg[1]) { // Find top/bottom at location cur->arg[1]=1; atxy: | | | 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 | } } cur->arg[1]=1; } else if((cur->arg[0]&0x0066) && !cur->arg[1]) { // Find top/bottom at location cur->arg[1]=1; atxy: cur->rowid=(cur->pVtab==bizarro_vtab?bizplayfield:playfield)[cur->arg[2]+cur->arg[3]*64-65]; if(cur->rowid==VOIDLINK) goto nextxy; if(cur->arg[0]&0x0020) { while(cur->rowid!=VOIDLINK && objects[cur->rowid]->up!=VOIDLINK) cur->rowid=objects[cur->rowid]->up; } } else if(cur->arg[0]&0x0020) { // Go down cur->rowid=objects[cur->rowid]->down; |
︙ | ︙ | |||
698 699 700 701 702 703 704 | } goto atxy; } } else { // This shouldn't happen return SQLITE_INTERNAL; } | > | > > | 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 | } goto atxy; } } else { // This shouldn't happen return SQLITE_INTERNAL; } if(!cur->eof) { if(!objects[cur->rowid]->generation) goto again; if((objects[cur->rowid]->oflags&OF_BIZARRO)!=(cur->pVtab==bizarro_vtab?OF_BIZARRO:0)) goto again; } return SQLITE_OK; } static int vt1_objects_filter(sqlite3_vtab_cursor*pcur,int idxNum,const char*idxStr,int argc,sqlite3_value**argv) { Cursor*cur=(void*)pcur; int i; Uint32 t; |
︙ | ︙ | |||
918 919 920 921 922 923 924 925 926 927 928 929 930 931 | y=sqlite3_value_int(argv[10]); if(x<1 || x>pfwidth || y<1 || y>pfheight) return SQLITE_CONSTRAINT_CHECK; z=sqlite3_value_int(argv[3]); if(z<=0 || z>=0x4000 || !classes[z]) return SQLITE_CONSTRAINT_FOREIGNKEY; if(sqlite3_value_int(argv[7])<0 || sqlite3_value_int(argv[7])>=classes[z]->nimages) return SQLITE_CONSTRAINT_CHECK; id=objalloc(z); if(id==VOIDLINK) return SQLITE_CONSTRAINT_VTAB; goto update; } else { // UPDATE id=sqlite3_value_int64(argv[0]); if(id!=sqlite3_value_int64(argv[1]) || id!=sqlite3_value_int64(argv[2])) return SQLITE_CONSTRAINT_VTAB; if(sqlite3_value_type(argv[3])==SQLITE_NULL) return SQLITE_CONSTRAINT_NOTNULL; if(sqlite3_value_type(argv[7])==SQLITE_NULL) return SQLITE_CONSTRAINT_NOTNULL; | > | 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 | y=sqlite3_value_int(argv[10]); if(x<1 || x>pfwidth || y<1 || y>pfheight) return SQLITE_CONSTRAINT_CHECK; z=sqlite3_value_int(argv[3]); if(z<=0 || z>=0x4000 || !classes[z]) return SQLITE_CONSTRAINT_FOREIGNKEY; if(sqlite3_value_int(argv[7])<0 || sqlite3_value_int(argv[7])>=classes[z]->nimages) return SQLITE_CONSTRAINT_CHECK; id=objalloc(z); if(id==VOIDLINK) return SQLITE_CONSTRAINT_VTAB; if(vt==bizarro_vtab) objects[id]->oflags|=OF_BIZARRO; else objects[id]->oflags&=~OF_BIZARRO; goto update; } else { // UPDATE id=sqlite3_value_int64(argv[0]); if(id!=sqlite3_value_int64(argv[1]) || id!=sqlite3_value_int64(argv[2])) return SQLITE_CONSTRAINT_VTAB; if(sqlite3_value_type(argv[3])==SQLITE_NULL) return SQLITE_CONSTRAINT_NOTNULL; if(sqlite3_value_type(argv[7])==SQLITE_NULL) return SQLITE_CONSTRAINT_NOTNULL; |
︙ | ︙ | |||
994 995 996 997 998 999 1000 1001 1002 1003 1004 | sqlite3_create_function(userdb,"RESOURCE",-1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_resource,0,0); sqlite3_create_function(userdb,"SIGN_EXTEND",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_sign_extend,0,0); sqlite3_create_function(userdb,"SOLUTION_CACHEID",0,SQLITE_UTF8|SQLITE_DETERMINISTIC,ptr1,fn_cacheid,0,0); sqlite3_create_function(userdb,"TRACE_OFF",0,SQLITE_UTF8,"",fn_trace_on,0,0); sqlite3_create_function(userdb,"TRACE_ON",0,SQLITE_UTF8,"\x01",fn_trace_on,0,0); sqlite3_create_function(userdb,"XY",2,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_xy,0,0); sqlite3_create_function(userdb,"ZERO_EXTEND",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_zero_extend,0,0); 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," | > | > > | 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 | sqlite3_create_function(userdb,"RESOURCE",-1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_resource,0,0); sqlite3_create_function(userdb,"SIGN_EXTEND",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_sign_extend,0,0); sqlite3_create_function(userdb,"SOLUTION_CACHEID",0,SQLITE_UTF8|SQLITE_DETERMINISTIC,ptr1,fn_cacheid,0,0); sqlite3_create_function(userdb,"TRACE_OFF",0,SQLITE_UTF8,"",fn_trace_on,0,0); sqlite3_create_function(userdb,"TRACE_ON",0,SQLITE_UTF8,"\x01",fn_trace_on,0,0); sqlite3_create_function(userdb,"XY",2,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_xy,0,0); sqlite3_create_function(userdb,"ZERO_EXTEND",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_zero_extend,0,0); bizarro_vtab=""; // ensure that it is not null 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);"); } |