ref: 6482e60caf7916c1f0085064eb8a17b55d9db117
parent: 69674e88a5393217a724b9390ff3c843bd0fc768
author: zamfofex <zamfofex@twdb.moe>
date: Fri Oct 20 18:06:44 EDT 2023
fix bug handling multiple games on Lichess at once
--- a/chess.c
+++ b/chess.c
@@ -3,7 +3,7 @@
#include "moonfish.h"
-static int moonfish_piece_scores[] = {100, 320, 330, 500, 900, 599900};+static int moonfish_piece_scores[] = {100, 320, 330, 500, 900, 0};static signed char moonfish_piece_square_scores[] =
{--- a/tools/lichess.c
+++ b/tools/lichess.c
@@ -685,13 +685,6 @@
struct moonfish_game *game;
pthread_t thread;
- game = malloc(sizeof *game);
- if (game == NULL)
- {- fprintf(stderr, "%s: could not allocate game\n", argv0);
- exit(1);
- }
-
root = NULL;
for (;;)
@@ -726,6 +719,13 @@
id = cJSON_GetObjectItem(challenge, "id");
if (!cJSON_IsString(id)) moonfish_json_error(argv0);
+
+ game = malloc(sizeof *game);
+ if (game == NULL)
+ {+ fprintf(stderr, "%s: could not allocate game\n", argv0);
+ exit(1);
+ }
if (strlen(id->valuestring) > sizeof game->id - 1)
{--
⑨