aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autistdraw.c30
1 files 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;
}