summaryrefslogtreecommitdiff
path: root/src/engine.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine.c')
-rw-r--r--src/engine.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/engine.c b/src/engine.c
index 52aa83b..187be28 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -40,19 +40,20 @@ int main(void) {
get_moves(&moves, position);
send_queue(tx, "Sending", 8);
- char buf[128];
- for (int i = 0; i <= moves.length / 32; i++) {
- for (int ii = 0; ii < 32; ii++) {
- if (moves.length <= 4 * i + ii) continue;
- struct sqrstr from_str = sqr_to_str(moves.moves[4 * i + ii].from);
- struct sqrstr to_str = sqr_to_str(moves.moves[4 * i + ii].to);
- buf[4 * ii + 0] = from_str.data[0];
- buf[4 * ii + 1] = from_str.data[1];
- buf[4 * ii + 2] = to_str.data[0];
- buf[4 * ii + 3] = to_str.data[1];
- buf[4 * ii + 4] = 0;
+ char buf[65];
+ int k = 0;
+ for (int i = 0; i < moves.length; i++) {
+ struct sqrstr from_str = sqr_to_str(moves.moves[i].from);
+ struct sqrstr to_str = sqr_to_str(moves.moves[i].to);
+ buf[k++] = from_str.data[0];
+ buf[k++] = from_str.data[1];
+ buf[k++] = to_str.data[0];
+ buf[k++] = to_str.data[1];
+ if (k == 64) {
+ buf[k] = 0;
+ send_queue(tx, buf, sizeof(buf));
+ k = 0;
}
- send_queue(tx, buf, sizeof(buf));
}
}