Index: TODO ================================================================== --- TODO +++ TODO @@ -35,7 +35,6 @@ * Command-line switch for batch import/export levels * SQL * Implement the GROUP column in the CLASSES table * Allow multiple SQL statements in one binding * Large fonts (width 8 or 16, height 8-32) -* Remember solved levels (store solved version in USERSTATE column) Index: game.c ================================================================== --- game.c +++ game.c @@ -29,10 +29,11 @@ static int inputs_size,inputs_count; static Uint8 side_mode=255; static Uint8 should_record_solution; static Uint8 replay_speed; static Uint8 replay_time; +static Uint8 solved; static void record_solution(void); static void setup_game(void) { const char*v; @@ -70,11 +71,11 @@ x=y=0; SDL_GetMouseState(&x,&y); SDL_LockSurface(screen); if(left_margin>=88) { snprintf(buf,32,"%5d/%5d",level_ord,level_nindex); - draw_text(0,0,buf,0xF0,0xFC); + draw_text(0,0,buf,0xF0,solved?0xFA:0xFC); snprintf(buf,32,"%5d",level_id); draw_text(0,8,"ID",0xF0,0xF7); draw_text(48,8,buf,0xF0,0xFF); snprintf(buf,32,"%5d",level_version); draw_text(0,16,"VER",0xF0,0xF7); @@ -82,11 +83,11 @@ snprintf(buf,32,"%5d",level_code); draw_text(0,24,"CODE",0xF0,0xF7); draw_text(48,24,buf,0xF0,0xFF); } else { snprintf(buf,32,"%5d",level_ord); - draw_text(16,0,buf,0xF0,0xFC); + draw_text(16,0,buf,0xF0,solved?0xFA:0xFC); snprintf(buf,32,"%5d",level_id); draw_text(0,8,"I",0xF0,0xF7); draw_text(16,8,buf,0xF0,0xFF); snprintf(buf,32,"%5d",level_version); draw_text(0,16,"V",0xF0,0xF7); @@ -241,18 +242,21 @@ } static void save_replay(void) { long sz=replay_size; if(solution_replay || !replay_list) return; - if(sz0xFFFF?0xFFFF:sz); } - sz=replay_count+4; - replay_list[sz-4]=replay_mark>>8; - replay_list[sz-3]=replay_mark; + if(gameover==1) solved=1; + sz=replay_count+6; + replay_list[sz-6]=replay_mark>>8; + replay_list[sz-5]=replay_mark; + replay_list[sz-4]=(level_version+solved-1)>>8; + replay_list[sz-3]=level_version+solved-1; replay_list[sz-2]=replay_count>>8; replay_list[sz-1]=replay_count; write_userstate(FIL_LEVEL,level_id,sz,replay_list); } @@ -283,10 +287,14 @@ replay_list=read_userstate(FIL_LEVEL,level_id,&sz); if(sz>=2) { replay_size=(sz>0xFFFF?0xFFFF:sz); replay_count=(replay_list[sz-2]<<8)|replay_list[sz-1]; if(sz-replay_count>=4) replay_mark=(replay_list[replay_count]<<8)|replay_list[replay_count+1]; else replay_mark=0; + if(sz-replay_count>=6) { + i=(replay_list[replay_count+2]<<8)|replay_list[replay_count+3]; + if(i==level_version) solved=1; + } } else { notfound: replay_count=replay_mark=replay_size=0; free(replay_list); replay_list=0; @@ -298,10 +306,11 @@ const char*t; replay_time=0; if(replay_count) save_replay(); inputs_count=0; replay_pos=0; + solved=0; t=load_level(id)?:init_level(); load_replay(); if(t) { gameover=-1; screen_message(t);