Free Hero Mesh

Check-in [1aadd6299e]
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:Change MoveItem to Uint16 and fix the encoders/decoders for future use (only numbers 8 to 255 are currently in use).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 1aadd6299e7fc906d92c9ec94f0e53e2e59f0167
User & Date: user on 2022-07-01 21:09:11
Other Links: manifest | tags
Context
2022-07-02
16:14
Implement -O switch to output private solutions on stdout. check-in: 169561bd42 user: user tags: trunk
2022-07-01
21:09
Change MoveItem to Uint16 and fix the encoders/decoders for future use (only numbers 8 to 255 are currently in use). check-in: 1aadd6299e user: user tags: trunk
2022-06-30
06:37
More improvements to PORTING file. check-in: 65b8239f8b user: user tags: trunk
Changes

Modified game.c from [740d5e2168] to [d17a145787].

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
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;



}

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;
}

MoveItem decode_move(FILE*fp) {
  // Decodes a single move from the file, and returns the move.
  // Returns zero if there is no more moves.
  int v=fgetc(fp);

  return (v==EOF?0: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).
  MoveItem v;
  FILE*o;







>
|
|
>
>
>





>
>
|
|






>
|
>
>
>
>
>







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
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.
  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.
  int i;
  int c=0;
  for(i=0;i<replay_count;i++) c+=encode_move(fp,replay_list[i]);
  return c;
}

MoveItem decode_move(FILE*fp) {
  // Decodes a single move from the file, and returns the move.
  // Returns zero if there is no more moves.
  int v=fgetc(fp);
  if(v>=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).
  MoveItem v;
  FILE*o;

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

316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
void annihilate(void);
const char*execute_turn(int key);
const char*init_level(void);
void swap_world(void);

// == game ==

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;







|







316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
void annihilate(void);
const char*execute_turn(int key);
const char*init_level(void);
void swap_world(void);

// == game ==

typedef Uint16 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;