Index: class.doc ================================================================== --- class.doc +++ class.doc @@ -1554,11 +1554,11 @@ HitMe ( dir -- bool ) ** Checks hardness/sharpness and shoving like is done by Move, subject to From and Arg3. The direction is a direction relative to From, not to Self. The result is 1 if shoving or sharpness is successful, or 0 - otherwise. This will update Arg3,including at least setting the low + otherwise. This will update Arg3, including at least setting the low three bits; the new value of Arg3 may then be used as the return value from HITBY. It is intended that this instruction is used inside of a HITBY block, in case you want to do some of your own processing. The Compatible and VisualOnly flags of this object are not checked. Index: game.c ================================================================== --- game.c +++ game.c @@ -18,11 +18,12 @@ #include "quarks.h" #include "cursorshapes.h" #include "names.h" MoveItem*replay_list; -Uint16 replay_size,replay_count,replay_pos,replay_mark; +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; @@ -57,24 +58,22 @@ int decode_move_list(FILE*fp) { // Decodes a move list from the file, and stores it in replay_list and replay_count. // Returns the number of moves (replay_count). MoveItem v; - size_t s=0; free(replay_list); replay_list=0; + replay_size=0; replay_count=0; - FILE*o=open_memstream((char**)&replay_list,&s); + FILE*o=open_memstream((char**)&replay_list,&replay_size); if(!o) fatal("Allocation failed\n"); while(replay_count<0xFFFD && (v=decode_move(fp))) { fwrite(&v,1,sizeof(MoveItem),o); replay_count++; } fclose(o); if(replay_count && !replay_list) fatal("Allocation failed\n"); - s/=sizeof(MoveItem); - replay_size=(s>0xFFFF?0xFFFF:s); return replay_count; } static void record_solution(void); @@ -295,11 +294,11 @@ long sz=replay_size; if(solution_replay || !replay_list) return; if(sz0xFFFF?0xFFFF:sz); + replay_size=sz; } if(gameover==1) solved=1; sz=replay_count+6; replay_list[sz-6]=replay_mark>>8; replay_list[sz-5]=replay_mark; @@ -325,20 +324,20 @@ while(i=sz || sz-i>0xFFFF) goto notfound; - replay_size=(sz>0xFFFF?0xFFFF:sz); + replay_size=sz; memmove(replay_list,replay_list+i,replay_count=sz-i); replay_mark=0; } else { goto notfound; } } else { replay_list=read_userstate(FIL_LEVEL,level_id,&sz); if(sz>=2) { - replay_size=(sz>0xFFFF?0xFFFF:sz); + replay_size=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; @@ -711,17 +710,12 @@ 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; + decode_move_list(fp); pclose(fp); } static void do_export_moves(const char*arg) { FILE*fp; @@ -730,11 +724,11 @@ 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); + encode_move_list(fp); pclose(fp); } static void do_load_moves(sqlite3_stmt*st) { int i=sqlite3_column_bytes(st,1); Index: heromesh.h ================================================================== --- heromesh.h +++ heromesh.h @@ -321,11 +321,12 @@ // == game == typedef Uint8 MoveItem; extern MoveItem*replay_list; -extern Uint16 replay_size,replay_count,replay_pos,replay_mark; +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);