aboutsummaryrefslogtreecommitdiff
path: root/src/ctaklm.c
diff options
context:
space:
mode:
authortslil clingman <tslil@posteo.de>2021-01-31 15:33:30 -0500
committertslil <tslil@posteo.de>2026-08-28 19:37:41 +0100
commit399d90f1b94717aa0ca5abb1dc43bdb6f4160d13 (patch)
tree21c954622a23fa606dacfe85552df92f6f195903 /src/ctaklm.c
parent84ad2e3c12cb505e3c5e3dd29d05edb529b82174 (diff)
Fairly important bug fixes to lcdlib, LCD now echoes input!
Input polling without line-buffering is done using ncurses, so the buildroot configuration had to change accordingly to include that library. The Makefile changed to accommodate stand-alone building of ct1986 and to include -lcurses where appropriate. There were also some typos about copying ct1986 and ctaklm to the correct directories.
Diffstat (limited to 'src/ctaklm.c')
-rw-r--r--src/ctaklm.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/ctaklm.c b/src/ctaklm.c
index 681f29c..4d910c4 100644
--- a/src/ctaklm.c
+++ b/src/ctaklm.c
@@ -171,13 +171,16 @@ print_info(void) {
}
static int human;
-static char *gamelog = 0;
+static char *gamelog = NULL;
static uint8_t auto_board = 0xFF, auto_info = 0xFF;
-static void
+static int
append_to_gamelog(const char *line, const uint8_t win_line) {
// I _could_ dynamically compute the size but ... don't let
// `perfect' be the enemy of `good' ?
+
+ if (gamelog == NULL) return EXIT_FAILURE;
+
char prepend[8];
if (win_line) {
@@ -194,8 +197,11 @@ append_to_gamelog(const char *line, const uint8_t win_line) {
strlen(gamelog)
+ strlen(prepend)
+ strlen(line) + 1);
- strcat(gamelog,prepend);
- strcat(gamelog,line);
+ // TODO: trap errno
+ strcat(gamelog, prepend);
+ strcat(gamelog, line);
+
+ return EXIT_SUCCESS;
}
static void
@@ -438,13 +444,12 @@ int main(int argc, char **argv) {
puts(license);
- negamax_search_depth = 3;
+ negamax_search_depth = 5;
new_game(5);
negamax_init(5);
// Test harness
if (argc > 1) {
- negamax_search_depth = 5;
load_ptn("data/0.ptn");
negamax_turn();
return 0;