509
510
511
512
513
514
515
516
517
518
519
520
521
522
|
while(n!=VOIDLINK && objects[n]->up!=VOIDLINK) n=objects[n]->up;
if(!classes[objects[n]->class]->gamehelp) return;
s=sqlite3_mprintf("\x0C\x0E%s:%d\\ %s\x0B\x0F%s",classes[objects[n]->class]->name,objects[n]->image,classes[objects[n]->class]->name,classes[objects[n]->class]->gamehelp);
if(!s) fatal("Allocation failed\n");
modal_draw_popup(s);
sqlite3_free(s);
}
static int game_command(int prev,int cmd,int number,int argc,sqlite3_stmt*args,void*aux) {
switch(cmd) {
case '\' ': // Play a move
if(solution_replay) {
screen_message("You cannot play your own moves during the solution replay");
return -3;
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
|
while(n!=VOIDLINK && objects[n]->up!=VOIDLINK) n=objects[n]->up;
if(!classes[objects[n]->class]->gamehelp) return;
s=sqlite3_mprintf("\x0C\x0E%s:%d\\ %s\x0B\x0F%s",classes[objects[n]->class]->name,objects[n]->image,classes[objects[n]->class]->name,classes[objects[n]->class]->gamehelp);
if(!s) fatal("Allocation failed\n");
modal_draw_popup(s);
sqlite3_free(s);
}
static void do_import_moves(const char*arg) {
FILE*fp;
int i;
if(!arg || !arg[strspn(arg," \t")]) return;
fp=popen(arg,"r");
if(!fp) {
screen_message("Unable to open pipe for reading");
return;
}
replay_list=realloc(replay_list,0x10000);
if(!replay_list) fatal("Allocation failed");
replay_mark=0;
replay_size=0xFFFF;
i=fread(replay_list,1,0xFFFD,fp);
if(i&~0xFFFF) i=0;
replay_count=i;
pclose(fp);
}
static void do_export_moves(const char*arg) {
FILE*fp;
int i;
if(!arg || !arg[strspn(arg," \t")]) return;
fp=popen(arg,"w");
if(!fp) {
screen_message("Unable to open pipe for writing");
return;
}
if(replay_count) fwrite(replay_list,1,replay_count,fp);
pclose(fp);
}
static void do_load_moves(sqlite3_stmt*st) {
int i=sqlite3_column_bytes(st,1);
if(i&~0xFFFF) return;
if(replay_size<i) replay_list=realloc(replay_list,replay_size=i);
if(!replay_list) fatal("Allocation failed");
replay_count=i;
if(i) memcpy(replay_list,sqlite3_column_blob(st,1),i);
}
static int game_command(int prev,int cmd,int number,int argc,sqlite3_stmt*args,void*aux) {
switch(cmd) {
case '\' ': // Play a move
if(solution_replay) {
screen_message("You cannot play your own moves during the solution replay");
return -3;
|
580
581
582
583
584
585
586
587
588
589
590
591
592
593
|
case '^s': // Toggle solution replay
solution_replay^=1;
if(replay_count) replay_count=0,begin_level(level_id); else load_replay();
return 1;
case 'go': // Select level
begin_level(number);
return 1;
default:
return prev;
}
}
static void set_caption(void) {
const char*r;
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
|
case '^s': // Toggle solution replay
solution_replay^=1;
if(replay_count) replay_count=0,begin_level(level_id); else load_replay();
return 1;
case 'go': // Select level
begin_level(number);
return 1;
case 'mi': // Move list import
if(argc<2 || solution_replay) break;
if(replay_pos) begin_level(level_id);
do_import_moves(sqlite3_column_text(args,1));
return 1;
case 'ml': // Move list load
if(argc<2 || solution_replay) break;
if(replay_pos) begin_level(level_id);
do_load_moves(args);
return 1;
case 'mx': // Move list export
if(argc<2) break;
do_export_moves(sqlite3_column_text(args,1));
return 0;
default:
return prev;
}
}
static void set_caption(void) {
const char*r;
|