Differences From Artifact [775aabf4a7]:
- File game.c — part of check-in [1a2fee8a44] at 2021-05-23 02:22:04 on branch trunk — Implement a key binding command to record the solution even if auto recording solutions is not enabled. (user: user, size: 31131) [annotate] [blame] [check-ins using]
To Artifact [75daa49f6d]:
- File game.c — part of check-in [c20acae981] at 2021-06-10 18:51:26 on branch trunk — Remember which levels have been solved in the user cache database (user: user, size: 31459) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
27 28 29 30 31 32 33 34 35 36 37 38 39 40 | static int exam_scroll; static Uint8*inputs; 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 void record_solution(void); static void setup_game(void) { const char*v; optionquery[1]=Q_showInventory; v=xrm_get_resource(resourcedb,optionquery,optionquery,2)?:""; | > | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | static int exam_scroll; static Uint8*inputs; 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; optionquery[1]=Q_showInventory; v=xrm_get_resource(resourcedb,optionquery,optionquery,2)?:""; |
︙ | ︙ | |||
68 69 70 71 72 73 74 | SDL_FillRect(screen,&r,back_color); for(x=1;x<=pfwidth;x++) for(y=1;y<=pfheight;y++) draw_cell(x,y); x=y=0; SDL_GetMouseState(&x,&y); SDL_LockSurface(screen); if(left_margin>=88) { snprintf(buf,32,"%5d/%5d",level_ord,level_nindex); | | | | 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | SDL_FillRect(screen,&r,back_color); for(x=1;x<=pfwidth;x++) for(y=1;y<=pfheight;y++) draw_cell(x,y); 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,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); draw_text(48,16,buf,0xF0,0xFF); 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,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); draw_text(16,16,buf,0xF0,0xFF); snprintf(buf,32,"%5d",level_code); |
︙ | ︙ | |||
239 240 241 242 243 244 245 | SDL_UnlockSurface(screen); SDL_Flip(screen); } static void save_replay(void) { long sz=replay_size; if(solution_replay || !replay_list) return; | | | > | > > | | | 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | SDL_UnlockSurface(screen); SDL_Flip(screen); } static void save_replay(void) { long sz=replay_size; if(solution_replay || !replay_list) return; if(sz<replay_count+6) { replay_list=realloc(replay_list,sz=replay_count+6); if(!replay_list) fatal("Allocation failed\n"); replay_size=(sz>0xFFFF?0xFFFF:sz); } 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); } static void load_replay(void) { long sz; |
︙ | ︙ | |||
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | } } else { 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; } else { notfound: replay_count=replay_mark=replay_size=0; free(replay_list); replay_list=0; } } } static void begin_level(int id) { const char*t; replay_time=0; if(replay_count) save_replay(); inputs_count=0; replay_pos=0; t=load_level(id)?:init_level(); load_replay(); if(t) { gameover=-1; screen_message(t); } else { gameover=0; | > > > > > | 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | } } else { 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; } } } static void begin_level(int id) { 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); } else { gameover=0; |
︙ | ︙ |