Index: class.c ================================================================== --- class.c +++ class.c @@ -1326,11 +1326,11 @@ ParseError("Expected ( or ) or number\n"); } } } -static void class_definition(int cla) { +static void class_definition(int cla,sqlite3_stmt*vst) { Hash*hash=calloc(LOCAL_HASH_SIZE,sizeof(Hash)); Class*cl=classes[cla]; int ptr=0; int compat=0; int i; @@ -1461,11 +1461,20 @@ if(!cl->nimages) cl->oflags|=OF_INVISIBLE; if(main_options['C']) dump_class(cla,ptr,hash); if(main_options['H']) { for(i=0;i=0x2000 && hash[i].id<0x2800) { + sqlite3_reset(vst); + sqlite3_bind_int(vst,1,(hash[i].id&0x07FF)|(cla<<16)); + sqlite3_bind_text(vst,2,hash[i].txt,-1,free); + while(sqlite3_step(vst)==SQLITE_ROW); + } else { + free(hash[i].txt); + } + } free(hash); } static void load_class_numbers(void) { int i,n; @@ -1502,10 +1511,11 @@ void load_classes(void) { int i; int gloptr=0; Hash*glolocalhash; char*nam=sqlite3_mprintf("%s.class",basefilename); + sqlite3_stmt*vst=0; fprintf(stderr,"Loading class definitions...\n"); if(!nam) fatal("Allocation failed\n"); classfp=fopen(nam,"r"); sqlite3_free(nam); if(!classfp) fatal("Cannot open class file '%s': %m\n",nam); @@ -1545,10 +1555,11 @@ classes[0]->name=classes[0]->edithelp=classes[0]->gamehelp=0; classes[0]->codes=classes[0]->messages=classes[0]->images=0; classes[0]->nmsg=0; memset(functions,-1,sizeof(functions)); load_class_numbers(); + if(userdb && (i=sqlite3_prepare_v2(userdb,"INSERT INTO `VARIABLES`(`ID`,`NAME`) VALUES(?1,?2);",-1,&vst,0))) fatal("SQL error (%d): %s\n",i,sqlite3_errmsg(userdb)); for(;;) { nxttok(); if(tokent==TF_EOF) goto done; if(tokent!=TF_OPEN) ParseError("Expected open parenthesis\n"); nxttok(); @@ -1558,11 +1569,11 @@ gloptr=parse_instructions(0,gloptr,glolocalhash,0); end_label_stack(classes[0]->codes,glolocalhash); } else if(Tokenf(TF_NAME)) { switch(tokenv) { case 0x4000 ... 0x7FFF: // Class definition - class_definition(tokenv-0x4000); + class_definition(tokenv-0x4000,vst); break; case 0x0200 ... 0x02FF: case 0xC000 ... 0xFFFF: // Default message handler begin_label_stack(); set_message_ptr(0,tokenv&0x8000?(tokenv&0x3FFF)+256:tokenv-0x0200,gloptr); gloptr=parse_instructions(0,gloptr,glolocalhash,0); @@ -1618,12 +1629,22 @@ for(i=0;i=0x2800 && glohash[i].id<0x3000) { + sqlite3_reset(vst); + sqlite3_bind_int(vst,1,glohash[i].id&0x07FF); + sqlite3_bind_text(vst,2,glohash[i].txt,-1,free); + while(sqlite3_step(vst)==SQLITE_ROW); + } else { + free(glohash[i].txt); + } + } + if(vst) sqlite3_finalize(vst); free(glohash); for(i=1;icflags&CF_NOCLASS1)) fatal("Class $%s mentioned but not defined\n",classes[i]->name); if(macros) for(i=0;i