256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
|
// The actual Hamster archive files will be updated when the program terminates.
sqlite3_stmt*st;
int e;
if(e=sqlite3_prepare_v2(userdb,"INSERT INTO `USERCACHEDATA`(`FILE`,`LEVEL`,`NAME`,`DATA`) VALUES(?1,?2,CASE WHEN ?2 < 0 THEN ?3 ELSE ?2 || ?3 END,?4)"
" ON CONFLICT(`FILE`,`LEVEL`) DO UPDATE SET `DATA` = ?4;",-1,&st,0)) fatal("SQL error (%d): %s\n",e,sqlite3_errmsg(userdb));
sqlite3_bind_int64(st,1,sol?solutionuc:leveluc);
sqlite3_bind_int(st,2,lvl);
sqlite3_bind_text(st,3,lvl==LUMP_CLASS_DEF?"CLASS.DEF":lvl==LUMP_LEVEL_IDX?"LEVEL.IDX":sol?".SOL":".LVL",-1,SQLITE_STATIC);
sqlite3_bind_blob64(st,4,data,sz,0);
while((e=sqlite3_step(st))==SQLITE_ROW);
if(e!=SQLITE_DONE) fatal("SQL error (%d): %s\n",e,sqlite3_errmsg(userdb));
sqlite3_finalize(st);
}
void write_userstate(int sol,int lvl,long sz,const unsigned char*data) {
|
|
|
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
|
// The actual Hamster archive files will be updated when the program terminates.
sqlite3_stmt*st;
int e;
if(e=sqlite3_prepare_v2(userdb,"INSERT INTO `USERCACHEDATA`(`FILE`,`LEVEL`,`NAME`,`DATA`) VALUES(?1,?2,CASE WHEN ?2 < 0 THEN ?3 ELSE ?2 || ?3 END,?4)"
" ON CONFLICT(`FILE`,`LEVEL`) DO UPDATE SET `DATA` = ?4;",-1,&st,0)) fatal("SQL error (%d): %s\n",e,sqlite3_errmsg(userdb));
sqlite3_bind_int64(st,1,sol?solutionuc:leveluc);
sqlite3_bind_int(st,2,lvl);
sqlite3_bind_text(st,3,lvl==LUMP_CLASS_DEF?"CLASS.DEF":lvl==LUMP_LEVEL_IDX?"LEVEL.IDX":lvl==LUMP_DIVISION_IDX?"DIVISION.IDX":sol?".SOL":".LVL",-1,SQLITE_STATIC);
sqlite3_bind_blob64(st,4,data,sz,0);
while((e=sqlite3_step(st))==SQLITE_ROW);
if(e!=SQLITE_DONE) fatal("SQL error (%d): %s\n",e,sqlite3_errmsg(userdb));
sqlite3_finalize(st);
}
void write_userstate(int sol,int lvl,long sz,const unsigned char*data) {
|