83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
case 84: sqlite3_result_int(cxt,cl->shovable); break;
case 128: sqlite3_result_double(cxt,cl->volume/(double)max_volume); break;
case 129: sqlite3_result_int(cxt,cl->uservars); break;
case 130: sqlite3_result_int(cxt,cl->collisionLayers); break;
case 132: sqlite3_result_int(cxt,cl->cflags&CF_COMPATIBLE?1:0); break;
}
}
static void fn_modstate(sqlite3_context*cxt,int argc,sqlite3_value**argv) {
sqlite3_result_int(cxt,SDL_GetModState());
}
static void fn_picture_size(sqlite3_context*cxt,int argc,sqlite3_value**argv) {
sqlite3_result_int(cxt,picture_size);
}
static void fn_read_lump_at(sqlite3_context*cxt,int argc,sqlite3_value**argv) {
sqlite3_int64 of=sqlite3_value_int64(argv[0]);
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
case 84: sqlite3_result_int(cxt,cl->shovable); break;
case 128: sqlite3_result_double(cxt,cl->volume/(double)max_volume); break;
case 129: sqlite3_result_int(cxt,cl->uservars); break;
case 130: sqlite3_result_int(cxt,cl->collisionLayers); break;
case 132: sqlite3_result_int(cxt,cl->cflags&CF_COMPATIBLE?1:0); break;
}
}
static void fn_cvalue(sqlite3_context*cxt,int argc,sqlite3_value**argv) {
int a;
if(sqlite3_value_type(*argv)==SQLITE_NULL) return;
a=sqlite3_value_int(*argv)&0xFFFF;
sqlite3_result_int64(cxt,a|((sqlite3_int64)TY_CLASS<<32));
}
static void fn_modstate(sqlite3_context*cxt,int argc,sqlite3_value**argv) {
sqlite3_result_int(cxt,SDL_GetModState());
}
static void fn_mvalue(sqlite3_context*cxt,int argc,sqlite3_value**argv) {
int a;
if(sqlite3_value_type(*argv)==SQLITE_NULL) return;
a=sqlite3_value_int(*argv)&0xFFFF;
sqlite3_result_int64(cxt,a|((sqlite3_int64)TY_MESSAGE<<32LL));
}
static void fn_ovalue(sqlite3_context*cxt,int argc,sqlite3_value**argv) {
Uint32 a;
if(sqlite3_value_type(*argv)==SQLITE_NULL) {
sqlite3_result_int(cxt,0);
return;
}
a=sqlite3_value_int64(*argv)&0xFFFFFFFF;
if(a>=nobjects || !objects[a] || (objects[a]->dir&IOF_DEAD)) return; // result is null if object does not exist
sqlite3_result_int64(cxt,a|((sqlite3_int64)objects[a]->generation<<32));
}
static void fn_picture_size(sqlite3_context*cxt,int argc,sqlite3_value**argv) {
sqlite3_result_int(cxt,picture_size);
}
static void fn_read_lump_at(sqlite3_context*cxt,int argc,sqlite3_value**argv) {
sqlite3_int64 of=sqlite3_value_int64(argv[0]);
|
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
|
Module(vt_classes,
.xColumn=vt1_classes_column,
.xFilter=vt1_classes_filter,
.xNext=vt1_classes_next,
.xUpdate=vt1_classes_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,"CLASS_DATA",2,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_class_data,0,0);
sqlite3_create_function(userdb,"LEVEL_CACHEID",0,SQLITE_UTF8|SQLITE_DETERMINISTIC,ptr0,fn_cacheid,0,0);
sqlite3_create_function(userdb,"MODSTATE",0,SQLITE_UTF8,0,fn_modstate,0,0);
sqlite3_create_function(userdb,"PICTURE_SIZE",0,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_picture_size,0,0);
sqlite3_create_function(userdb,"READ_LUMP_AT",2,SQLITE_UTF8,0,fn_read_lump_at,0,0);
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_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);");
}
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
|
Module(vt_classes,
.xColumn=vt1_classes_column,
.xFilter=vt1_classes_filter,
.xNext=vt1_classes_next,
.xUpdate=vt1_classes_update,
);
static int vt1_objects_column(sqlite3_vtab_cursor*pcur,sqlite3_context*cxt,int n) {
return SQLITE_OK;
}
static int vt1_objects_filter(sqlite3_vtab_cursor*pcur,int idxNum,const char*idxStr,int argc,sqlite3_value**argv) {
return SQLITE_OK;
}
static int vt1_objects_index(sqlite3_vtab*vt,sqlite3_index_info*info) {
return SQLITE_OK;
}
static int vt1_objects_next(sqlite3_vtab_cursor*pcur) {
return SQLITE_OK;
}
static int vt1_objects_update(sqlite3_vtab*vt,int argc,sqlite3_value**argv,sqlite3_int64*rowid) {
if(!main_options['e']) return SQLITE_LOCKED;
return SQLITE_OK;
}
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,"CLASS_DATA",2,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_class_data,0,0);
sqlite3_create_function(userdb,"LEVEL_CACHEID",0,SQLITE_UTF8|SQLITE_DETERMINISTIC,ptr0,fn_cacheid,0,0);
sqlite3_create_function(userdb,"MODSTATE",0,SQLITE_UTF8,0,fn_modstate,0,0);
sqlite3_create_function(userdb,"CVALUE",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_cvalue,0,0);
sqlite3_create_function(userdb,"MVALUE",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_mvalue,0,0);
sqlite3_create_function(userdb,"NVALUE",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_zero_extend,0,0);
sqlite3_create_function(userdb,"OVALUE",1,SQLITE_UTF8,0,fn_ovalue,0,0);
sqlite3_create_function(userdb,"PICTURE_SIZE",0,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_picture_size,0,0);
sqlite3_create_function(userdb,"READ_LUMP_AT",2,SQLITE_UTF8,0,fn_read_lump_at,0,0);
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,"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,"
"`IMAGE` INT, `DIR` INT, `X` INT, `Y` INT, `UP` INT, `DOWN` INT, `DENSITY` INT HIDDEN);");
}
|