diff options
| author | Aargh Rai <aargh.rai+git@gmail.com> | 2026-06-01 12:18:28 +0530 |
|---|---|---|
| committer | Aargh Rai <aargh.rai+git@gmail.com> | 2026-06-01 12:18:28 +0530 |
| commit | 29822a5d0f63bf0c1b34da636ddf27ecf22ca3cb (patch) | |
| tree | 66234320292a113a7ac522117a8b9396ca31ee8b /src/engine.c | |
| parent | 97c2eacc290ef4ba298b6659ab8bba925203f125 (diff) | |
handling recv better & sending smaller packs so i don't need to handle more conditions
Diffstat (limited to 'src/engine.c')
| -rw-r--r-- | src/engine.c | 25 |
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)); } } |
