edit game_undo + struct game_redo + copy hist
This commit is contained in:
1 parent
52458140cc
commit
87e5ebe741
3 files changed
+26
-8
No files matched your search
@@ -56,7 +56,7 @@ game game_copy(cgame g1) {
|
||||
for (int j = 0; j < g2->width; j++) {
|
||||
g2->tab_cell[i][j] = g1->tab_cell[i][j];
|
||||
}
|
||||
// g2->hist = history_copy(g1);
|
||||
g2->hist = history_copy(g1->hist);
|
||||
}
|
||||
return g2;
|
||||
}
|
||||
@@ -164,9 +164,9 @@ bool game_check_move(cgame g, uint i, uint j, square s) {
|
||||
void game_play_move(game g, uint i, uint j, square s) {
|
||||
if (g->hist == NULL) {
|
||||
g->hist = history_create_empty();
|
||||
g->hist = history_insert_first(g->hist, game_get_square(g, i, j), i, j);
|
||||
g->hist = history_insert_first(g->hist, game_get_state(g, i, j), i, j);
|
||||
} else {
|
||||
g->hist = history_next(history_insert_after(g->hist, g->hist, game_get_square(g, i, j), i, j));
|
||||
g->hist = history_next(history_insert_after(g->hist, g->hist, game_get_state(g, i, j), i, j));
|
||||
g->hist = history_delete_all_after(g->hist, g->hist);
|
||||
}
|
||||
game_set_square(g, i, j, s);
|
||||
|
||||
Reference in new issue
Block a user