Index: class.c ================================================================== --- class.c +++ class.c @@ -1502,11 +1502,11 @@ } static void load_class_numbers(void) { int i,n; long size=0; - unsigned char*data=read_lump(FIL_LEVEL,LUMP_CLASS_DEF,&size,0); + unsigned char*data=read_lump(FIL_LEVEL,LUMP_CLASS_DEF,&size); unsigned char*p; if(!data) return; for(i=0;i65536) 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=0?read_lump(FIL_LEVEL,lvl,&sz,0):0; + unsigned char*buf=lvl>=0?read_lump(FIL_LEVEL,lvl,&sz):0; unsigned char*p=buf; unsigned char*end=buf+sz; unsigned char*q; int i,n,x,y,z; Uint16 lo=0; @@ -206,11 +220,11 @@ Uint32 o; Uint32 mru[2]; if(lvl<0 && level_index && -lvl<=level_nindex) { lo=-lvl; lvl=level_index[~lvl]; - p=buf=read_lump(FIL_LEVEL,lvl,&sz,0); + p=buf=read_lump(FIL_LEVEL,lvl,&sz); end=buf+sz; } if(lvl<0) return "Invalid level ID"; if(!buf) return "Cannot find level"; free(level_title); @@ -495,11 +509,12 @@ if(fst.st_mtime>t1 || fst.st_ctime>t1) leveluc=reset_usercache(levelfp,nam2,&fst,".LVL"); if(stat(nam3,&fst)) fatal("Unable to stat '%s': %m\n",nam3); if(fst.st_mtime>t2 || fst.st_ctime>t2) solutionuc=reset_usercache(solutionfp,nam3,&fst,".SOL"); free(nam2); free(nam3); - if(z=sqlite3_prepare_v3(userdb,"SELECT * FROM `USERCACHEDATA` WHERE `FILE` = ?1 AND `LEVEL` = ?2;",-1,SQLITE_PREPARE_PERSISTENT,&readusercachest,0)) { + if(z=sqlite3_prepare_v3(userdb,"SELECT `OFFSET`, CASE WHEN ?3 THEN `DATA` ELSE `USERSTATE` END " + "FROM `USERCACHEDATA` WHERE `FILE` = ?1 AND `LEVEL` = ?2;",-1,SQLITE_PREPARE_PERSISTENT,&readusercachest,0)) { fatal("SQL error (%d): %s\n",z,sqlite3_errmsg(userdb)); } if(z=sqlite3_exec(userdb,"COMMIT;",0,0,0)) fatal("SQL error (%d): %s\n",z,sqlite3_errmsg(userdb)); fprintf(stderr,"Done\n"); }