Free Hero Mesh

Check-in [42f95966ca]
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 autotest mode and add the config.doc file
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 42f95966ca0916ccd1e29f0fa60d0a4af36741f9
User & Date: user on 2021-01-10 03:23:24
Other Links: manifest | tags
Context
2021-01-10
23:58
Mention in the documentation about the autotest mode, regular expression to find errors check-in: 839e21c938 user: user tags: trunk
03:23
Implement autotest mode and add the config.doc file check-in: 42f95966ca user: user tags: trunk
2021-01-09
03:03
Fix a mistake in the solution replay and document that command. check-in: 8524828a0e user: user tags: trunk
Changes

Modified commandline.doc from [edc9378782] to [4a5551fa71].

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
-M
  Write details of macro expansion to stdout.

-T
  Mode for testing some internal functions of Free Hero Mesh and SDL. You
  probably do not need to use this mode yourself.

-a (not implemented yet)
  Autotest levels, ensuring that the provided solution is valid.

-c
  Only load classes and then terminate. This can be used to test that
  the class definition file does not contain syntax errors, or it can be
  used together with -C, -H, -L, -M to see how it is parsing it.








|







21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
-M
  Write details of macro expansion to stdout.

-T
  Mode for testing some internal functions of Free Hero Mesh and SDL. You
  probably do not need to use this mode yourself.

-a
  Autotest levels, ensuring that the provided solution is valid.

-c
  Only load classes and then terminate. This can be used to test that
  the class definition file does not contain syntax errors, or it can be
  used together with -C, -H, -L, -M to see how it is parsing it.

Added config.doc version [f70dddc30c].





















































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
Configuration can be set in two ways. There is the .heromeshrc file in
your home directory, which is a X resource manager file, and you can also
specify settings in command-line arguments after the puzzle set name, each
of which is a X resource manager string.

In the .heromeshrc file, the first component of each resource is the name
of the puzzle set (you can use ? for all puzzle sets); in command-line,
that is omitted, and the setting name is the first component.

Some settings are boolean. For boolean settings, anything that starts with
"0", "n", "N", "f", or "F" is false, and anything that starts with "1",
"y", "Y", "t", or "T" is true. If neither, the default setting is used.

See bindings.doc for key/mouse bindings.


=== Resources ===

.altImage
  If the puzzle set contains multiple pictures with the same name and size
  then this resource controls which of those pictures is selected. The
  default setting is zero.

.editTitle
  The window title to use in edit mode. A tilde is replaced by the name of
  the puzzle set.

.gameTitle
  The window title to use in game mode. A tilde is replaced by the name of
  the puzzle set.

.gamma
  Gamma setting. If this is set, colours are gamma corrected by the number
  specified here. The default setting is 1.0.

.imageSize
  The picture size to use, up to 255. If the puzzle set contains pictures
  of the requested size, it will use those, otherwise it will try to make
  the pictures it does have larger by integer scaling; if that also does
  not work, then it is an error.

.keyRepeat
  The keyboard repeat rate, which are two numbers, first the key repeating
  delay and then the key repeating interval.

.level
  Specifies the 1-based order number of the level to start at.

.margin
  The X coordinate of the left margin. To the left is the status area, and
  to the right of the margin is the playfield. This should be at least 64,
  or the picture size, whichever is greater.

.palette
  If defined, the file name of the palette to use (if not set, then the
  internal palette is used instead). The file format is hex rrggbb format
  separated by any kind of whitespaces.

.progress
  If nonzero, how many steps between dots in the progress report for the
  auto testing most.

.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
  Height of the window (not counting the border), in pixels.

.screenWidth
  Width of the window (not counting the border), in pixels.

.showInventory
  True means to show the inventory in the margin by default; false means
  to show the move list in the margin by default. Either way, it is
  possible to change the display at run time.

.sqlCoveringIndexScan
  Boolean controlling if SQLite will use covering index scans.

.sqlExtensions
  Names of SQLite extensions with spaces in between.

.sqlFile
  Name of the user cache database. If not set, then it will use the file
  called .heromeshsession in the home directory.

.sqlInit
  SQL codes to execute when Free Hero Mesh starts.

.sqlMemStatus
  Boolean controlling if SQL memory status is available.

.sqlSmallAllocations
  Boolean controlling if SQLite will try to make small allocations.

.stackProtection
  Controls protection from stack overflows; this only works if the C
  compiler supports this feature, otherwise there is no effect. If the
  first character is ? then the stack protection test mode will be
  activated; it will display the call stack usage. The first character
  may also be < or > for a stack growing down or up, followed by the
  maximum number of bytes to use (in decimal, or hexadecimal with "0x"
  at first). Note that not all C functions will check for the stack
  protection, so it will use a small amount more than specified here.

.traceAll
  If true, then all classes and messages are allowed for tracing. However,
  there is no effect unless tracing is enabled.

.traceObject
  If defined, and tracing is enabled, then it is an error for the
  specified object to be freed during the game; you can use this to
  debug errors with the use of a specific non-existent objects. You
  specify as the object ID number and generation number, separated by
  a colon. (This is how it is displayed in the examination screen.)

.tracePrefix
  If defined, trace output is prefixed by the specified text.

Modified game.c from [5f7adb0422] to [bcb10cb33f].

698
699
700
701
702
703
704


























































705
706
707
708
709
710
711
        break;
    }
  }
  quit:
  save_replay();
  exit(0);
}



























































void locate_me(int x,int y) {
  Uint8 c=7;
  SDL_Rect r,rh,rv;
  SDL_Event ev;
  if(!screen) return;
  redraw_game();







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







698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
        break;
    }
  }
  quit:
  save_replay();
  exit(0);
}

void run_auto_test(void) {
  Uint8 rc=0;
  int lvl,pro,i,n;
  const char*t;
  setbuf(stdout,0);
  solution_replay=1;
  optionquery[1]=Q_progress;
  t=xrm_get_resource(resourcedb,optionquery,optionquery,2);
  pro=t?strtol(t,0,10):0;
  optionquery[1]=Q_level;
  t=xrm_get_resource(resourcedb,optionquery,optionquery,2);
  if(n=lvl=t?strtol(t,0,10):0) goto start;
  for(n=1;n<=level_nindex;n++) {
    if(lvl) break;
    start:
    printf("Level %d",n);
    if(t=load_level(-n)) {
      printf(": Error during loading: %s\n",t);
      rc=1; continue;
    }
    load_replay();
    if(!replay_count) {
      printf(": Solution is absent, invalid, or for wrong version of this level\n");
      rc=1; continue;
    }
    if(t=init_level()) {
      printf(": Error during initialization: %s\n",t);
      rc=1; continue;
    }
    if(gameover==-1) {
      printf(": Lose during initialization\n");
      rc=1; continue;
    }
    for(i=0;i<replay_count;i++) {
      if(gameover) {
        printf(": Premature termination on move %d\n",i);
        rc=1; goto cont;
      }
      if(pro && !(i%pro)) putchar('.');
      if(t=execute_turn(replay_list[i])) {
        printf(": Error on move %d: %s\n",i+1,t);
        rc=1; goto cont;
      }
      if(gameover==-1) {
        printf(": Game loss on move %d\n",i+1);
        rc=1; goto cont;
      }
    }
    if(gameover<=0) {
      printf(": Game not terminated after %d moves\n",replay_count);
      rc=1; continue;
    }
    printf(": OK\n");
    cont: ;
  }
  exit(rc);
}

void locate_me(int x,int y) {
  Uint8 c=7;
  SDL_Rect r,rh,rv;
  SDL_Event ev;
  if(!screen) return;
  redraw_game();

Modified heromesh.h from [f7c90cf74d] to [e8f5d32ef9].

257
258
259
260
261
262
263

264
265
266
267
268
269
270
// == game ==

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

void run_game(void);

void locate_me(int x,int y);

// == edit ==

void run_editor(void);
void write_empty_level_set(FILE*);








>







257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
// == game ==

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

void run_game(void);
void run_auto_test(void);
void locate_me(int x,int y);

// == edit ==

void run_editor(void);
void write_empty_level_set(FILE*);

Modified main.c from [46407c4aee] to [e9e638bdea].

862
863
864
865
866
867
868

869
870
871
872
873
874
875
    globalclassname=strrchr(basefilename,'/');
    globalclassname=globalclassname?globalclassname+1:basefilename;
  }
  if(main_options['n']) {
    if(main_options['r']) fatal("Switches -r and -n are conflicting\n");
    main_options['x']=1;
  }

  if(!main_options['c']) load_options();
  if(argc>optind) read_options(argc-optind,argv+optind);
  *optionquery=xrm_make_quark(globalclassname,0)?:xrm_anyq;
#ifdef __GNUC__
  stack_protect_mark=__builtin_frame_address(0);
  set_stack_protection();
#endif







>







862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
    globalclassname=strrchr(basefilename,'/');
    globalclassname=globalclassname?globalclassname+1:basefilename;
  }
  if(main_options['n']) {
    if(main_options['r']) fatal("Switches -r and -n are conflicting\n");
    main_options['x']=1;
  }
  if(main_options['a']) main_options['r']=main_options['x']=1;
  if(!main_options['c']) load_options();
  if(argc>optind) read_options(argc-optind,argv+optind);
  *optionquery=xrm_make_quark(globalclassname,0)?:xrm_anyq;
#ifdef __GNUC__
  stack_protect_mark=__builtin_frame_address(0);
  set_stack_protection();
#endif
891
892
893
894
895
896
897

898
899
900
901
902
903
904
  load_level_index();
  optionquery[1]=Q_maxObjects;
  max_objects=strtoll(xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"",0,0)?:0xFFFF0000L;
  set_tracing();
  annihilate();
  optionquery[1]=Q_level;
  if(level_ord=strtol(xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"",0,10)) log_if_error(load_level(-level_ord));

  if(main_options['x']) {
    fprintf(stderr,"Ready for executing SQL statements.\n");
    do_sql_mode();
    return 0;
  }
  for(;;) { if(main_options['e']) run_editor(); else run_game(); }
}







>







892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
  load_level_index();
  optionquery[1]=Q_maxObjects;
  max_objects=strtoll(xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"",0,0)?:0xFFFF0000L;
  set_tracing();
  annihilate();
  optionquery[1]=Q_level;
  if(level_ord=strtol(xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"",0,10)) log_if_error(load_level(-level_ord));
  if(main_options['a']) run_auto_test();
  if(main_options['x']) {
    fprintf(stderr,"Ready for executing SQL statements.\n");
    do_sql_mode();
    return 0;
  }
  for(;;) { if(main_options['e']) run_editor(); else run_game(); }
}

Modified man6/heromesh.6 from [51d8cd5b88] to [b9875397f8].

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Dump all class data.
.IP -H
Dump the hash table.
.IP -L
Display all tokens being read from the class definition file.
.IP -a
Autotest levels, ensuring that the provided solution is valid.
(Not implemented yet)
.IP -c
Only load classes and then terminate.
This can be used to verify that the class definition file does not contain syntax errors.
You can also use it with some other options to display details.
.IP -e
Start the level editor.
.IP -n







<







19
20
21
22
23
24
25

26
27
28
29
30
31
32
Dump all class data.
.IP -H
Dump the hash table.
.IP -L
Display all tokens being read from the class definition file.
.IP -a
Autotest levels, ensuring that the provided solution is valid.

.IP -c
Only load classes and then terminate.
This can be used to verify that the class definition file does not contain syntax errors.
You can also use it with some other options to display details.
.IP -e
Start the level editor.
.IP -n

Modified quarks from [1be78c1f08] to [64ae3938b3].

212
213
214
215
216
217
218

219
level
tracePrefix
stackProtection
maxObjects
traceAll
traceObject
showInventory









>

212
213
214
215
216
217
218
219
220
level
tracePrefix
stackProtection
maxObjects
traceAll
traceObject
showInventory
progress

Modified quarks.h from [eb6ffb657a] to [600f40dc0a].

177
178
179
180
181
182
183

184
185
186
187
188
189
190
#define Q_level 178
#define Q_tracePrefix 179
#define Q_stackProtection 180
#define Q_maxObjects 181
#define Q_traceAll 182
#define Q_traceObject 183
#define Q_showInventory 184

static const char*const global_quarks[]={
  "screenWidth",
  "screenHeight",
  "margin",
  "palette",
  "popupColors",
  "imageSize",







>







177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#define Q_level 178
#define Q_tracePrefix 179
#define Q_stackProtection 180
#define Q_maxObjects 181
#define Q_traceAll 182
#define Q_traceObject 183
#define Q_showInventory 184
#define Q_progress 185
static const char*const global_quarks[]={
  "screenWidth",
  "screenHeight",
  "margin",
  "palette",
  "popupColors",
  "imageSize",
361
362
363
364
365
366
367

368
369
370
371
372
373
374
  "level",
  "tracePrefix",
  "stackProtection",
  "maxObjects",
  "traceAll",
  "traceObject",
  "showInventory",

0};
#ifdef HEROMESH_BINDINGS
static const SDLKey quark_to_key[Q_undo+1-Q_backspace]={
SDLK_BACKSPACE,
SDLK_TAB,
SDLK_CLEAR,
SDLK_RETURN,







>







362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
  "level",
  "tracePrefix",
  "stackProtection",
  "maxObjects",
  "traceAll",
  "traceObject",
  "showInventory",
  "progress",
0};
#ifdef HEROMESH_BINDINGS
static const SDLKey quark_to_key[Q_undo+1-Q_backspace]={
SDLK_BACKSPACE,
SDLK_TAB,
SDLK_CLEAR,
SDLK_RETURN,