Index: main.c ================================================================== --- main.c +++ main.c @@ -38,10 +38,11 @@ "CREATE TABLE IF NOT EXISTS `USERCACHEDATA`(`ID` INTEGER PRIMARY KEY, `FILE` INT, `LEVEL` INT, `NAME` TEXT COLLATE NOCASE, `OFFSET` INT, `DATA` BLOB, `USERSTATE` BLOB);" "CREATE UNIQUE INDEX IF NOT EXISTS `USERCACHEDATA_I1` ON `USERCACHEDATA`(`FILE`, `LEVEL`);" "CREATE TRIGGER IF NOT EXISTS `USERCACHEINDEX_DELETION` AFTER DELETE ON `USERCACHEINDEX` BEGIN DELETE FROM `USERCACHEDATA` WHERE `FILE` = OLD.`ID`; END;" "CREATE TEMPORARY TABLE `PICTURES`(`ID` INTEGER PRIMARY KEY, `NAME` TEXT COLLATE NOCASE, `OFFSET` INT, `DEPENDENT` INT);" "CREATE TEMPORARY TABLE `VARIABLES`(`ID` INTEGER PRIMARY KEY, `NAME` TEXT);" + "CREATE TEMPORARY TABLE `DIVISIONS`(`HEADING` BLOB NOT NULL, `FIRST` INT NOT NULL);" "COMMIT;" ; sqlite3*userdb; xrm_db*resourcedb; @@ -197,10 +198,12 @@ sqlite3_bind_int(st,2,strtol(buf,0,10)); } else if(i==9 && suffix[1]=='L' && !sqlite3_stricmp(buf,"CLASS.DEF")) { sqlite3_bind_int(st,2,LUMP_CLASS_DEF); } else if(i==9 && suffix[1]=='L' && !sqlite3_stricmp(buf,"LEVEL.IDX")) { sqlite3_bind_int(st,2,LUMP_LEVEL_IDX); + } else if(i==12 && suffix[1]=='L' && !sqlite3_stricmp(buf,"DIVISION.IDX")) { + sqlite3_bind_int(st,2,LUMP_DIVISION_IDX); } else { nomatch: sqlite3_bind_null(st,2); } while((z=sqlite3_step(st))==SQLITE_ROW); if(z!=SQLITE_DONE) fatal("SQL error (%d): %s\n",z,sqlite3_errmsg(userdb)); @@ -277,18 +280,40 @@ sqlite3_finalize(st); } static void load_level_index(void) { long sz; + sqlite3_stmt*st; int i; unsigned char*data=read_lump(FIL_LEVEL,LUMP_LEVEL_IDX,&sz); + unsigned char*p; if(!data) return; if(sz>65536) fatal("Too many levels\n"); level_index=malloc((level_nindex=sz>>1)*sizeof(Uint16)); if(!level_index) fatal("Allocation failed\n"); for(i=0;i