From e6329c3be134afd76d8b6a140d3dd0b287a477b1 Mon Sep 17 00:00:00 2001 From: oers Date: Tue, 19 Nov 2024 11:32:31 +0100 Subject: [PATCH] Undo Stack can be larger than 64 --- project/src/main/jni/droidzebra-jni.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/project/src/main/jni/droidzebra-jni.c b/project/src/main/jni/droidzebra-jni.c index c2a0b00..f4af9b0 100644 --- a/project/src/main/jni/droidzebra-jni.c +++ b/project/src/main/jni/droidzebra-jni.c @@ -71,7 +71,7 @@ static int s_practice_mode = FALSE; static const char* s_forced_opening_seq = NULL; static int s_use_book = TRUE; static int s_enable_msg = TRUE; -static int s_undo_stack[64]; +static int s_undo_stack[128]; static int s_undo_stack_pointer = 0; // -- @@ -1023,8 +1023,12 @@ void _droidzebra_undo_all(int* side_to_move) if(score_sheet_row==0 && *side_to_move==BLACKSQ) return; do { + droidzebra_message_debug("undoall Before: %d", s_undo_stack_pointer); + _droidzebra_undo_stack_push(disks_played); - *side_to_move = OPP(*side_to_move); + droidzebra_message_debug("undoall After: %d", s_undo_stack_pointer); + + *side_to_move = OPP(*side_to_move); if ( *side_to_move == WHITESQ ) score_sheet_row--; @@ -1123,6 +1127,7 @@ void _droidzebra_throw_engine_error(JNIEnv* env, const char* msg) void _droidzebra_undo_stack_push(int val) { + assert(s_undo_stack_pointer< 128); s_undo_stack[s_undo_stack_pointer++] = val; }