Free Hero Mesh

Check-in [e71ea9875c]
Login
This is a mirror of the main repository for Free Hero Mesh. New tickets and changes will not be accepted at this mirror.
Overview
Comment:Implement the .saveSolutions.private option (and the SQL functions to work with it), and remove the unused .allowMouseWarp option.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e71ea9875c6545b3a743de4ebbc72e60f43b9915
User & Date: user on 2022-06-30 05:46:45
Other Links: manifest | tags
Context
2022-06-30
06:01
Add PORTING file (currently incomplete) check-in: 956eb13fee user: user tags: trunk
05:46
Implement the .saveSolutions.private option (and the SQL functions to work with it), and remove the unused .allowMouseWarp option. check-in: e71ea9875c user: user tags: trunk
02:50
Change some things in game.c to use sizeof(MoveItem) instead of assuming that each move item is one byte long. check-in: f4c84adc9c user: user tags: trunk
Changes

Modified config.doc from [67613eb1cc] to [b4646fa155].

136
137
138
139
140
141
142





143
144
145
146
147
148
149
  of centiseconds between turns from 1 to 255.

.saveSolutions
  If true, then solutions are saved if you solve a level in less moves
  than the currently recorded solution (or if no solution is already
  recorded). This has no effect in read-only mode.






.screenFlags
  SDL flags: d = double buffer, f = full screen, h = use hardware surface,
  n = no window frame, p = hardware palette, r = allow the window to be
  resized, y = asynchronous blit, z = no parachute. Some flags might not
  work if the window manager does not support them.

.screenHeight







>
>
>
>
>







136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
  of centiseconds between turns from 1 to 255.

.saveSolutions
  If true, then solutions are saved if you solve a level in less moves
  than the currently recorded solution (or if no solution is already
  recorded). This has no effect in read-only mode.

.saveSolutions.private
  If true, then solutions are saved like .saveSolutions but they are saved
  privately to the user cache database, instead of in the solution file.
  This works even in read-only mode.

.screenFlags
  SDL flags: d = double buffer, f = full screen, h = use hardware surface,
  n = no window frame, p = hardware palette, r = allow the window to be
  resized, y = asynchronous blit, z = no parachute. Some flags might not
  work if the window manager does not support them.

.screenHeight

Modified function.c from [9d360dcc17] to [0fcaf673c8].

60
61
62
63
64
65
66








67
68
69
70
71
72
73
  if(i=sqlite3_str_length(str)) {
    sqlite3_result_blob(cxt,sqlite3_str_finish(str),i,sqlite3_free);
  } else {
    sqlite3_free(sqlite3_str_finish(str));
    sqlite3_result_zeroblob(cxt,0);
  }
}









static void fn_byte(sqlite3_context*cxt,int argc,sqlite3_value**argv) {
  Uint8*s=malloc(argc+1);
  int i;
  if(!s) {
    sqlite3_result_error_nomem(cxt);
    return;







>
>
>
>
>
>
>
>







60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
  if(i=sqlite3_str_length(str)) {
    sqlite3_result_blob(cxt,sqlite3_str_finish(str),i,sqlite3_free);
  } else {
    sqlite3_free(sqlite3_str_finish(str));
    sqlite3_result_zeroblob(cxt,0);
  }
}

static void fn_best_move_list(sqlite3_context*cxt,int argc,sqlite3_value**argv) {
  if(best_list) sqlite3_result_blob(cxt,best_list,strlen(best_list),SQLITE_TRANSIENT);
}

static void fn_best_score(sqlite3_context*cxt,int argc,sqlite3_value**argv) {
  if(best_list && best_score!=NO_SCORE) sqlite3_result_int64(cxt,best_score);
}

static void fn_byte(sqlite3_context*cxt,int argc,sqlite3_value**argv) {
  Uint8*s=malloc(argc+1);
  int i;
  if(!s) {
    sqlite3_result_error_nomem(cxt);
    return;
1774
1775
1776
1777
1778
1779
1780


1781
1782
1783
1784
1785
1786
1787
  .xConnect=vt1_levels_connect,
  .xOpen=vt1_levels_open,
);

void init_sql_functions(sqlite3_int64*ptr0,sqlite3_int64*ptr1) {
  sqlite3_create_function(userdb,"BASENAME",0,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_basename,0,0);
  sqlite3_create_function(userdb,"BCAT",-1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_bcat,0,0);


  sqlite3_create_function(userdb,"BYTE",-1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_byte,0,0);
  sqlite3_create_function(userdb,"CL",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_cl,0,0);
  sqlite3_create_function(userdb,"CLASS_DATA",2,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_class_data,0,0);
  sqlite3_create_function(userdb,"CVALUE",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_cvalue,0,0);
  sqlite3_create_function(userdb,"HASH",2,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_hash,0,0);
  sqlite3_create_function(userdb,"HEROMESH_ESCAPE",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_heromesh_escape,0,0);
  sqlite3_create_function(userdb,"HEROMESH_TYPE",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_heromesh_type,0,0);







>
>







1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
  .xConnect=vt1_levels_connect,
  .xOpen=vt1_levels_open,
);

void init_sql_functions(sqlite3_int64*ptr0,sqlite3_int64*ptr1) {
  sqlite3_create_function(userdb,"BASENAME",0,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_basename,0,0);
  sqlite3_create_function(userdb,"BCAT",-1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_bcat,0,0);
  sqlite3_create_function(userdb,"BEST_MOVE_LIST",0,SQLITE_UTF8,0,fn_best_move_list,0,0);
  sqlite3_create_function(userdb,"BEST_SCORE",0,SQLITE_UTF8,0,fn_best_score,0,0);
  sqlite3_create_function(userdb,"BYTE",-1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_byte,0,0);
  sqlite3_create_function(userdb,"CL",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_cl,0,0);
  sqlite3_create_function(userdb,"CLASS_DATA",2,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_class_data,0,0);
  sqlite3_create_function(userdb,"CVALUE",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_cvalue,0,0);
  sqlite3_create_function(userdb,"HASH",2,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_hash,0,0);
  sqlite3_create_function(userdb,"HEROMESH_ESCAPE",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_heromesh_escape,0,0);
  sqlite3_create_function(userdb,"HEROMESH_TYPE",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_heromesh_type,0,0);

Modified game.c from [2346a86e7d] to [740d5e2168].

1
2
3
4
5
6
7
8
9
#if 0
gcc ${CFLAGS:--s -O2} -c -Wno-multichar -fwrapv game.c `sdl-config --cflags`
exit
#endif

/*
  This program is part of Free Hero Mesh and is public domain.
*/


|







1
2
3
4
5
6
7
8
9
#if 0
gcc ${CFLAGS:--s -O2} -c -Wno-unused-result -Wno-multichar -fwrapv game.c `sdl-config --cflags`
exit
#endif

/*
  This program is part of Free Hero Mesh and is public domain.
*/

19
20
21
22
23
24
25


26
27
28
29
30
31
32
33

34
35
36
37
38

39
40
41
42
43
44
45
#include "cursorshapes.h"
#include "names.h"

MoveItem*replay_list;
size_t replay_size;
Uint16 replay_count,replay_pos,replay_mark;
Uint8 solution_replay=255;



static volatile Uint8 timerflag;
static int exam_scroll;
static MoveItem*inputs;
static size_t inputs_size;
static int inputs_count;
static Uint8 side_mode=255;
static Uint8 should_record_solution;

static Uint8 replay_speed;
static Uint8 replay_time;
static Uint8 solved;
static Uint8 inserting,saved_inserting;
static sqlite3_stmt*autowin;


int encode_move(FILE*fp,MoveItem v) {
  // Encodes a single move and writes the encoded move to the file.
  // Returns the number of bytes of the encoded move.
  fputc(v,fp);
  return 1;
}







>
>








>





>







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "cursorshapes.h"
#include "names.h"

MoveItem*replay_list;
size_t replay_size;
Uint16 replay_count,replay_pos,replay_mark;
Uint8 solution_replay=255;
char*best_list;
Sint32 best_score=NO_SCORE;

static volatile Uint8 timerflag;
static int exam_scroll;
static MoveItem*inputs;
static size_t inputs_size;
static int inputs_count;
static Uint8 side_mode=255;
static Uint8 should_record_solution;
static Uint8 should_record_private_solution;
static Uint8 replay_speed;
static Uint8 replay_time;
static Uint8 solved;
static Uint8 inserting,saved_inserting;
static sqlite3_stmt*autowin;
static size_t dum_size; // not used by Free Hero Mesh, but needed by some C library functions.

int encode_move(FILE*fp,MoveItem v) {
  // Encodes a single move and writes the encoded move to the file.
  // Returns the number of bytes of the encoded move.
  fputc(v,fp);
  return 1;
}
88
89
90
91
92
93
94




95
96
97
98
99
100
101
102
103
104
105
  const char*v;
  optionquery[1]=Q_showInventory;
  v=xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"";
  side_mode=boolxrm(v,1);
  optionquery[1]=Q_replaySpeed;
  v=xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"";
  replay_speed=strtol(v,0,10)?:16;




  if(main_options['r']) {
    should_record_solution=0;
  } else {
    optionquery[1]=Q_saveSolutions;
    v=xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"";
    should_record_solution=boolxrm(v,0);
  }
  solution_replay=0;
  optionquery[1]=Q_autoWin;
  v=xrm_get_resource(resourcedb,optionquery,optionquery,2);
  if(v && *v) sqlite3_prepare_v3(userdb,v,-1,SQLITE_PREPARE_PERSISTENT,&autowin,0);







>
>
>
>



<







92
93
94
95
96
97
98
99
100
101
102
103
104
105

106
107
108
109
110
111
112
  const char*v;
  optionquery[1]=Q_showInventory;
  v=xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"";
  side_mode=boolxrm(v,1);
  optionquery[1]=Q_replaySpeed;
  v=xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"";
  replay_speed=strtol(v,0,10)?:16;
  optionquery[1]=Q_saveSolutions;
  optionquery[2]=Q_private;
  v=xrm_get_resource(resourcedb,optionquery,optionquery,3)?:"";
  should_record_private_solution=boolxrm(v,0);
  if(main_options['r']) {
    should_record_solution=0;
  } else {

    v=xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"";
    should_record_solution=boolxrm(v,0);
  }
  solution_replay=0;
  optionquery[1]=Q_autoWin;
  v=xrm_get_resource(resourcedb,optionquery,optionquery,2);
  if(v && *v) sqlite3_prepare_v3(userdb,v,-1,SQLITE_PREPARE_PERSISTENT,&autowin,0);
309
310
311
312
313
314
315









316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335


336
337
338
339
340
341
342
  fputc(0x01,fp);
  encode_move_list(fp);
  fputc(0x00,fp);
  if(solved) {
    fputc(0x41,fp);
    fputc(level_version,fp);
    fputc(level_version>>8,fp);









  }
  if(replay_mark) {
    fputc(0x42,fp);
    fputc(replay_mark,fp);
    fputc(replay_mark>>8,fp);
  }
  fclose(fp);
  if(!buf) fatal("Allocation failed\n");
  write_userstate(FIL_LEVEL,level_id,sz,buf);
  free(buf);
}

static void load_replay(void) {
  FILE*fp=0;
  unsigned char*buf=0;
  long sz;
  int i,j;
  free(replay_list);
  replay_list=0;
  replay_count=replay_mark=replay_size=0;


  if(solution_replay) {
    gameover_score=NO_SCORE;
    if(buf=read_lump(FIL_SOLUTION,level_id,&sz)) {
      fp=fmemopen(buf,sz,"r");
      if(!fp) fatal("Allocation failed\n");
      // Solution format: version (16-bits), flag (8-bits), score (32-bits), user name (null-terminated), timestamp (64-bits), move list
      if(sz>3) {







>
>
>
>
>
>
>
>
>




















>
>







316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
  fputc(0x01,fp);
  encode_move_list(fp);
  fputc(0x00,fp);
  if(solved) {
    fputc(0x41,fp);
    fputc(level_version,fp);
    fputc(level_version>>8,fp);
    if(best_list) {
      fputc(0x02,fp);
      fwrite(best_list,1,strlen(best_list)+1,fp);
      fputc(0x81,fp);
      fputc(best_score,fp);
      fputc(best_score>>8,fp);
      fputc(best_score>>16,fp);
      fputc(best_score>>24,fp);
    }
  }
  if(replay_mark) {
    fputc(0x42,fp);
    fputc(replay_mark,fp);
    fputc(replay_mark>>8,fp);
  }
  fclose(fp);
  if(!buf) fatal("Allocation failed\n");
  write_userstate(FIL_LEVEL,level_id,sz,buf);
  free(buf);
}

static void load_replay(void) {
  FILE*fp=0;
  unsigned char*buf=0;
  long sz;
  int i,j;
  free(replay_list);
  replay_list=0;
  replay_count=replay_mark=replay_size=0;
  free(best_list);
  best_list=0;
  if(solution_replay) {
    gameover_score=NO_SCORE;
    if(buf=read_lump(FIL_SOLUTION,level_id,&sz)) {
      fp=fmemopen(buf,sz,"r");
      if(!fp) fatal("Allocation failed\n");
      // Solution format: version (16-bits), flag (8-bits), score (32-bits), user name (null-terminated), timestamp (64-bits), move list
      if(sz>3) {
354
355
356
357
358
359
360

361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379





380
381
382
383
384
385
386
387






388
389
390
391
392
393
394
395
396
397





398
399
400
401
402
403
404
          decode_move_list(fp);
        }
      }
    }
  } else if(buf=read_userstate(FIL_LEVEL,level_id,&sz)) {
    fp=fmemopen(buf,sz,"r");
    if(!fp) fatal("Allocation failed\n");

    if(sz>2 && *buf) {
      // Old format
      replay_count=(buf[sz-2]<<8)|buf[sz-1];
      if(sz-replay_count>=4) replay_mark=(buf[replay_count]<<8)|buf[replay_count+1]; else replay_mark=0;
      if(sz-replay_count>=6) {
        i=(buf[replay_count+2]<<8)|buf[replay_count+3];
        if(i==level_version) solved=1;
      }
      replay_list=malloc(replay_size=sizeof(MoveItem)*replay_count+1);
      if(!replay_list) fatal("Allocation failed\n");
      for(i=0;i<replay_size;i++) replay_list[i]=buf[i];
    } else {
      // New format
      fgetc(fp); // skip first null byte
      while((i=fgetc(fp))!=EOF) switch(i) {
        case 0x01: // Replay list
          if(replay_list) goto skip;
          decode_move_list(fp);
          break;





        case 0x41: // Solved version
          i=fgetc(fp); i|=fgetc(fp)<<8;
          if(i==level_version) solved=1;
          break;
        case 0x42: // Mark
          replay_mark=fgetc(fp);
          replay_mark|=fgetc(fp)<<8;
          break;






        default: skip:
          if(i<0x40) {
            while(fgetc(fp)>0);
          } else if(i<0x80) {
            fgetc(fp); fgetc(fp);
          } else if(i<0xC0) {
            for(i=0;i<4;i++) fgetc(fp);
          } else {
            for(i=0;i<8;i++) fgetc(fp);
          }





      }
    }
  }
  if(fp) fclose(fp);
  free(buf);
}








>



















>
>
>
>
>








>
>
>
>
>
>










>
>
>
>
>







372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
          decode_move_list(fp);
        }
      }
    }
  } else if(buf=read_userstate(FIL_LEVEL,level_id,&sz)) {
    fp=fmemopen(buf,sz,"r");
    if(!fp) fatal("Allocation failed\n");
    best_score=NO_SCORE;
    if(sz>2 && *buf) {
      // Old format
      replay_count=(buf[sz-2]<<8)|buf[sz-1];
      if(sz-replay_count>=4) replay_mark=(buf[replay_count]<<8)|buf[replay_count+1]; else replay_mark=0;
      if(sz-replay_count>=6) {
        i=(buf[replay_count+2]<<8)|buf[replay_count+3];
        if(i==level_version) solved=1;
      }
      replay_list=malloc(replay_size=sizeof(MoveItem)*replay_count+1);
      if(!replay_list) fatal("Allocation failed\n");
      for(i=0;i<replay_size;i++) replay_list[i]=buf[i];
    } else {
      // New format
      fgetc(fp); // skip first null byte
      while((i=fgetc(fp))!=EOF) switch(i) {
        case 0x01: // Replay list
          if(replay_list) goto skip;
          decode_move_list(fp);
          break;
        case 0x02: // Best list
          if(best_list) goto skip;
          dum_size=0;
          getdelim(&best_list,&dum_size,0,fp);
          break;
        case 0x41: // Solved version
          i=fgetc(fp); i|=fgetc(fp)<<8;
          if(i==level_version) solved=1;
          break;
        case 0x42: // Mark
          replay_mark=fgetc(fp);
          replay_mark|=fgetc(fp)<<8;
          break;
        case 0x81: // Best score
          best_score=fgetc(fp);
          best_score|=fgetc(fp)<<8;
          best_score|=fgetc(fp)<<16;
          best_score|=fgetc(fp)<<24;
          break;
        default: skip:
          if(i<0x40) {
            while(fgetc(fp)>0);
          } else if(i<0x80) {
            fgetc(fp); fgetc(fp);
          } else if(i<0xC0) {
            for(i=0;i<4;i++) fgetc(fp);
          } else {
            for(i=0;i<8;i++) fgetc(fp);
          }
      }
      if(best_list && !solved) {
        free(best_list);
        best_list=0;
        best_score=NO_SCORE;
      }
    }
  }
  if(fp) fclose(fp);
  free(buf);
}

1463
1464
1465
1466
1467
1468
1469






















1470
1471
1472
1473
1474
1475
1476
  replay_count=n;
  fclose(fp);
  if(!buf) fatal("Allocation failed\n");
  write_lump(FIL_SOLUTION,level_id,sz,buf);
  free(buf);
  sqlite3_exec(userdb,"UPDATE `LEVELS` SET `SOLVABLE` = 1 WHERE `ID` = LEVEL_ID();",0,0,0);
}























void run_game(void) {
  int i;
  SDL_Event ev;
  set_caption();
  replay_count=0;
  replay_time=0;







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
  replay_count=n;
  fclose(fp);
  if(!buf) fatal("Allocation failed\n");
  write_lump(FIL_SOLUTION,level_id,sz,buf);
  free(buf);
  sqlite3_exec(userdb,"UPDATE `LEVELS` SET `SOLVABLE` = 1 WHERE `ID` = LEVEL_ID();",0,0,0);
}

static void record_private_solution(void) {
  FILE*fp;
  char*buf=0;
  int n;
  if(solution_replay) return;
  if(gameover_score==NO_SCORE) gameover_score=replay_pos;
  if(best_list && best_score!=NO_SCORE && gameover_score>best_score) return;
  dum_size=0;
  fp=open_memstream(&buf,&dum_size);
  if(!fp) fatal("Allocation failed\n");
  n=replay_count;
  replay_count=replay_pos;
  encode_move_list(fp);
  replay_count=n;
  fclose(fp);
  if(buf) {
    free(best_list);
    best_list=buf;
    best_score=gameover_score;
  }
}

void run_game(void) {
  int i;
  SDL_Event ev;
  set_caption();
  replay_count=0;
  replay_time=0;
1531
1532
1533
1534
1535
1536
1537

1538
1539
1540
1541
1542
1543
1544
        if(inputs_count) {
          for(i=0;i<inputs_count && !gameover;i++) if(inputs[i]) input_move(inputs[i]);
          inputs_count=0;
          if(saved_inserting) inserting=1,saved_inserting=0;
          no_dead_anim=0;
          if(gameover==1) {
            if(should_record_solution) record_solution();

            if(!solution_replay && !solved) sqlite3_exec(userdb,"UPDATE `LEVELS` SET `SOLVED` = 1 WHERE `ID` = LEVEL_ID();",0,0,0);
            if(autowin) do_autowin();
          }
        }
        redraw_game();
        timerflag=0; // ensure we have not missed a timer event
        break;







>







1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
        if(inputs_count) {
          for(i=0;i<inputs_count && !gameover;i++) if(inputs[i]) input_move(inputs[i]);
          inputs_count=0;
          if(saved_inserting) inserting=1,saved_inserting=0;
          no_dead_anim=0;
          if(gameover==1) {
            if(should_record_solution) record_solution();
            if(should_record_private_solution) record_private_solution();
            if(!solution_replay && !solved) sqlite3_exec(userdb,"UPDATE `LEVELS` SET `SOLVED` = 1 WHERE `ID` = LEVEL_ID();",0,0,0);
            if(autowin) do_autowin();
          }
        }
        redraw_game();
        timerflag=0; // ensure we have not missed a timer event
        break;

Modified heromesh.h from [e542ddb045] to [87e56863d6].

322
323
324
325
326
327
328


329
330
331
332
333
334
335

typedef Uint8 MoveItem;

extern MoveItem*replay_list;
extern size_t replay_size;
extern Uint16 replay_count,replay_pos,replay_mark;
extern Uint8 solution_replay;



int encode_move(FILE*fp,MoveItem v);
int encode_move_list(FILE*fp);
MoveItem decode_move(FILE*fp);
int decode_move_list(FILE*fp);

void run_game(void);







>
>







322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337

typedef Uint8 MoveItem;

extern MoveItem*replay_list;
extern size_t replay_size;
extern Uint16 replay_count,replay_pos,replay_mark;
extern Uint8 solution_replay;
extern char*best_list;
extern Sint32 best_score;

int encode_move(FILE*fp,MoveItem v);
int encode_move_list(FILE*fp);
MoveItem decode_move(FILE*fp);
int decode_move_list(FILE*fp);

void run_game(void);

Modified internals.doc from [72305d8afa] to [e7768cb272].

151
152
153
154
155
156
157


158
159
160
161


162
* 0xC1 to 0xFF = Eight more bytes

The new format is always small-endian.

Record types:

* 0x01 = Replay list



* 0x41 = Level version, if solved (omitted otherwise)

* 0x42 = Mark position










>
>




>
>

151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
* 0xC1 to 0xFF = Eight more bytes

The new format is always small-endian.

Record types:

* 0x01 = Replay list

* 0x02 = Best personal solution

* 0x41 = Level version, if solved (omitted otherwise)

* 0x42 = Mark position

* 0x81 = Best personal score

Modified quarks from [64da450c8f] to [f8b2d652ef].

183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202

203
204
205
206
207
208
209
alt
meta
numLock

! Mouse
editClick
gameClick
allowMouseWarp
middle
! (left and right are listed with keys)
! (the key modifiers are also valid here)

! Class
class
quiz

! Solutions
saveSolutions
solutionComment
solutionTimestamp


! Picture editor
picedit
macro

! SQL settings
sqlFile







<












>







183
184
185
186
187
188
189

190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
alt
meta
numLock

! Mouse
editClick
gameClick

middle
! (left and right are listed with keys)
! (the key modifiers are also valid here)

! Class
class
quiz

! Solutions
saveSolutions
solutionComment
solutionTimestamp
private

! Picture editor
picedit
macro

! SQL settings
sqlFile

Modified quarks.h from [ebbe12be54] to [bfbb2aaa34].

158
159
160
161
162
163
164
165
166
167
168
169
170
171

172
173
174
175
176
177
178
#define Q_shift 159
#define Q_ctrl 160
#define Q_alt 161
#define Q_meta 162
#define Q_numLock 163
#define Q_editClick 164
#define Q_gameClick 165
#define Q_allowMouseWarp 166
#define Q_middle 167
#define Q_class 168
#define Q_quiz 169
#define Q_saveSolutions 170
#define Q_solutionComment 171
#define Q_solutionTimestamp 172

#define Q_picedit 173
#define Q_macro 174
#define Q_sqlFile 175
#define Q_sqlInit 176
#define Q_sqlExtensions 177
#define Q_sqlMemStatus 178
#define Q_sqlSmallAllocations 179







<
|
|
|
|
|
|
>







158
159
160
161
162
163
164

165
166
167
168
169
170
171
172
173
174
175
176
177
178
#define Q_shift 159
#define Q_ctrl 160
#define Q_alt 161
#define Q_meta 162
#define Q_numLock 163
#define Q_editClick 164
#define Q_gameClick 165

#define Q_middle 166
#define Q_class 167
#define Q_quiz 168
#define Q_saveSolutions 169
#define Q_solutionComment 170
#define Q_solutionTimestamp 171
#define Q_private 172
#define Q_picedit 173
#define Q_macro 174
#define Q_sqlFile 175
#define Q_sqlInit 176
#define Q_sqlExtensions 177
#define Q_sqlMemStatus 178
#define Q_sqlSmallAllocations 179
355
356
357
358
359
360
361
362
363
364
365
366
367
368

369
370
371
372
373
374
375
  "shift",
  "ctrl",
  "alt",
  "meta",
  "numLock",
  "editClick",
  "gameClick",
  "allowMouseWarp",
  "middle",
  "class",
  "quiz",
  "saveSolutions",
  "solutionComment",
  "solutionTimestamp",

  "picedit",
  "macro",
  "sqlFile",
  "sqlInit",
  "sqlExtensions",
  "sqlMemStatus",
  "sqlSmallAllocations",







<






>







355
356
357
358
359
360
361

362
363
364
365
366
367
368
369
370
371
372
373
374
375
  "shift",
  "ctrl",
  "alt",
  "meta",
  "numLock",
  "editClick",
  "gameClick",

  "middle",
  "class",
  "quiz",
  "saveSolutions",
  "solutionComment",
  "solutionTimestamp",
  "private",
  "picedit",
  "macro",
  "sqlFile",
  "sqlInit",
  "sqlExtensions",
  "sqlMemStatus",
  "sqlSmallAllocations",

Modified sql.doc from [56d19caca8] to [e099c9daa4].

10
11
12
13
14
15
16










17
18
19
20
21
22
23
BASENAME()
  The base name, which is a copy of the first command-line argument (not
  counting the switches or the program name).

BCAT(...)
  Concatenate several blobs. Nulls are skipped, if any.











BYTE(...)
  Make a blob; each argument is a number, of which the low 8-bits are used
  to make the value of one byte in the blob, so the size of the blob will
  then be the same as the number of arguments.

CL(text)
  Returns the class number, given the class name. If there is no such







>
>
>
>
>
>
>
>
>
>







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
BASENAME()
  The base name, which is a copy of the first command-line argument (not
  counting the switches or the program name).

BCAT(...)
  Concatenate several blobs. Nulls are skipped, if any.

BEST_MOVE_LIST()
  Returns the best personal move list in the user cache file (only valid if
  .saveSolution.private is true), as a blob. If there isn't any saved, then
  this is null.

BEST_SCORE()
  Returns the best score from the best move list (if it has been saved).
  If no score has been explicitly specified, then this is equal to the
  number of moves. If no score has been stored, then it is null.

BYTE(...)
  Make a blob; each argument is a number, of which the low 8-bits are used
  to make the value of one byte in the blob, so the size of the blob will
  then be the same as the number of arguments.

CL(text)
  Returns the class number, given the class name. If there is no such