Index: game.c ================================================================== --- game.c +++ game.c @@ -42,26 +42,38 @@ 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; + if(v>=8 && v<256) { + fputc(v,fp); + return 1; + } else { + fatal("Unencodable move (%u)\n",(int)v); + } } int encode_move_list(FILE*fp) { // Encodes the current replay list into the file; returns the number of bytes. // Does not write a null terminator. - fwrite(replay_list,1,replay_count,fp); - return replay_count; + int i; + int c=0; + for(i=0;i=8 && v<256) { + return v; + } else if(v==EOF || !v) { + return 0; + } else { + fatal("Undecodable move (%u)\n",v); + } } 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). Index: heromesh.h ================================================================== --- heromesh.h +++ heromesh.h @@ -318,11 +318,11 @@ const char*init_level(void); void swap_world(void); // == game == -typedef Uint8 MoveItem; +typedef Uint16 MoveItem; extern MoveItem*replay_list; extern size_t replay_size; extern Uint16 replay_count,replay_pos,replay_mark; extern Uint8 solution_replay;