From 3e9bc6cee75c9afd8737bf5b3b20e22a720b65d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Janouch?= Date: Sun, 30 Nov 2014 17:24:35 +0100 Subject: Fix server-client communication Regression was introduced by 08a2d53eb448fe80f68929111b8f6e74a44ffd50. --- autistdraw.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/autistdraw.c b/autistdraw.c index 0a7ad62..8e85285 100644 --- a/autistdraw.c +++ b/autistdraw.c @@ -495,16 +495,8 @@ make_place_for_point (app_context_t *app, int x, int y) } static void -draw_point (app_context_t *app, int x, int y, uint8_t color) +draw_point_internal (app_context_t *app, int x, int y, uint8_t color) { - // We don't actually draw anything immediately in client mode, - // instead we wait for confirmation from the server - if (app->mode == NETWORK_MODE_CLIENT) - { - send_draw_point_request (app, x, y, color); - return; - } - make_place_for_point (app, x, y); BITMAP_PIXEL (app, x - app->bitmap_x, y - app->bitmap_y) = color; @@ -517,8 +509,22 @@ draw_point (app_context_t *app, int x, int y, uint8_t color) addch (app->palette[color]); refresh (); } +} - // Broadcast the clients about the event +static void +draw_point (app_context_t *app, int x, int y, uint8_t color) +{ + // We don't actually draw anything immediately in client mode, + // instead we wait for confirmation from the server + if (app->mode == NETWORK_MODE_CLIENT) + { + send_draw_point_request (app, x, y, color); + return; + } + + draw_point_internal (app, x, y, color); + + // Broadcast clients about the event if (app->mode == NETWORK_MODE_SERVER) for (client_t *iter = app->clients; iter; iter = iter->next) send_draw_point_response (iter, x, y, color); @@ -1119,7 +1125,9 @@ on_server_put_point (app_context_t *app, struct msg_unpacker *unpacker) || !msg_unpacker_u8 (unpacker, &color)) return false; // Not enough data - draw_point (app, x, y, color); + // Either a confirmation of our own request, or an event notification; + // let's just put the pixel in place without further ado + draw_point_internal (app, x, y, color); return true; } -- cgit v1.2.3