Index: commandline.doc ================================================================== --- commandline.doc +++ commandline.doc @@ -19,10 +19,13 @@ Display all tokens being read from the class definition file. -M Write details of macro expansion to stdout. +-O + Write a solution Hamster archive with private solutions 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. -U Index: game.c ================================================================== --- game.c +++ game.c @@ -1683,10 +1683,50 @@ printf(": OK\n"); cont: ; } exit(rc); } + +void export_private_solutions(void) { + int rc=0; + const char*t; + int i0,i1,i2,i,j,n; + unsigned char*data; + long sz; + for(n=1;n<=level_nindex;n++) { + level_id=level_index[n-1]; + data=read_userstate(FIL_LEVEL,level_id,&sz); + if(!data) continue; + if(!sz || *data) { + free(data); + continue; + } + i0=i1=i2=0; + for(i=1;i>16); putchar(j>>24); putchar(j); putchar(j>>8); // lump data size + putchar(data[i1]); putchar(data[i1+1]); // level version + putchar(i2?0x80:0x00); // flag + if(i2) fwrite(data+i2,1,4,stdout); // score + fwrite(data+i0,1,i,stdout); // move list + } + free(data); + } + exit(rc); +} void locate_me(int x,int y) { Uint8 c=7; SDL_Rect r,rh,rv; SDL_Event ev; Index: heromesh.h ================================================================== --- heromesh.h +++ heromesh.h @@ -334,10 +334,11 @@ MoveItem decode_move(FILE*fp); int decode_move_list(FILE*fp); void run_game(void); void run_auto_test(void); +void export_private_solutions(void); void locate_me(int x,int y); // == edit == typedef struct { Index: main.c ================================================================== --- main.c +++ main.c @@ -5,11 +5,10 @@ /* This program is part of Free Hero Mesh and is public domain. */ -//#define _GNU_SOURCE #define HEROMESH_MAIN #include "SDL.h" #include #include #include @@ -1104,11 +1103,11 @@ if(main_options['n'] && main_options['i']) fatal("Switches -n and -i are conflicting\n"); if(main_options['n'] || main_options['i']) { if(main_options['r']) fatal("Switches -r and -%c are conflicting\n",main_options['i']?'i':'n'); main_options['x']=1; } - if(main_options['a']) main_options['r']=main_options['x']=1; + if(main_options['a'] || main_options['O']) main_options['r']=main_options['x']=1; if(main_options['p']) main_options['r']=1; if(main_options['f']) main_options['x']=1; if(!main_options['c']) { set_path(argv[0]); load_options(); @@ -1159,10 +1158,11 @@ log_if_error(load_level(-level_ord)); } optionquery[1]=Q_maxTrigger; max_trigger=strtol(xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"",0,10); if(main_options['a']) run_auto_test(); + if(main_options['O']) export_private_solutions(); if(main_options['x']) { if(main_options['i']) { batch_import(); if(main_options['f']) flush_usercache(); return 0; Index: man6/heromesh.6 ================================================================== --- man6/heromesh.6 +++ man6/heromesh.6 @@ -19,10 +19,12 @@ Dump all class data. .IP -H Dump the hash table. .IP -L Display all tokens being read from the class definition file. +.IP -O +Output a solution Hamster archive with private solutions to stdout and then terminate. .IP -U Enable experimental/unstable features. .IP -a Autotest levels, ensuring that the provided solution is valid. .IP -c