From 97b946d6c591c23046d79c46460a1bdb8805f9da Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Wed, 25 Oct 2023 19:13:12 +0200 Subject: [PATCH] =?UTF-8?q?WIP:=20un=20premier=20succ=C3=A8s=20(fragile)?= =?UTF-8?q?=20pour=20'erase=5Farrow()'=20(voir=20le=20cas=20liste=20vide)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/graphics/graphics.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/graphics/graphics.c b/src/graphics/graphics.c index 6be89ca..d7a305c 100644 --- a/src/graphics/graphics.c +++ b/src/graphics/graphics.c @@ -616,6 +616,11 @@ static inline int erase_arrow (int arrows_nb, int address, int site, int x, int arrows_ptr[address].y = arrows_ptr[arrows_nb].y; arrows_ptr[address].z = arrows_ptr[arrows_nb].z; + for (int i = 0 + address; i < 6 + address; i++) + buffer_vertex_origin [(long) buffer_vertex_0_arrow + i] = buffer_vertex_origin[(long) buffer_vertex_size - 6 + i]; + + for (int j = 0 + address; j < 4 + address; j++) + buffer_lines_origin [(long) buffer_lines_0_arrow + j] = buffer_lines_origin[(long) buffer_lines_size - 4 + j]; if (arrows_nb > 0) { @@ -623,12 +628,17 @@ static inline int erase_arrow (int arrows_nb, int address, int site, int x, int if (new_arrows_list_ptr) arrows_ptr = new_arrows_list_ptr; else perror("In erase arrow, can't re_allocate for arrow list.\n"); - printf("buffer_vertex_0_arrow = %d arrows_nb * 3 = %d <<<<\n", buffer_vertex_0_arrow, arrows_nb * 3); + /* long unit = 24 * 3 * sizeof(GLfloat); // 4 * 3 * 4 = 48 sizeof(GLfloat) = 3 * 8 bits */ + /* printf(" - erase_arrow() invoked with address = %d buffer_vertex_size - buffer_vertex_0_arrow = %d (for %d arrows)\n",\ */ + /* address, (long) buffer_vertex_size - buffer_vertex_0_arrow, arrows_nb + 1); */ + /* for (int i = 24; i < 36; i ++) printf(" %5.2f", buffer_vertex_origin[i]); printf("\n"); */ + + if (0) printf("buffer_vertex_0_arrow = %d arrows_nb * 3 = %d <<<<\n", buffer_vertex_0_arrow, arrows_nb * 3); void *new_arrows_vertex_ptr = g_realloc(buffer_vertex_origin, buffer_vertex_0_arrow + 9 * 3 * sizeof(GLfloat)); if (new_arrows_vertex_ptr) buffer_vertex_origin = new_arrows_vertex_ptr; else perror("In erase arrow, can't re_allocate for arrow vertex buffer.\n"); - printf("buffer_lines_0_arrow = %d arrows_nb * 2 = %d <<<<\n", buffer_lines_0_arrow, arrows_nb * 2); + if (0) printf("buffer_lines_0_arrow = %d arrows_nb * 2 = %d <<<<\n", buffer_lines_0_arrow, arrows_nb * 2); void *new_arrows_lines_ptr = g_realloc(buffer_lines_origin, buffer_lines_0_arrow + 9 * 2 * sizeof(GLfloat)); if (new_arrows_lines_ptr) buffer_lines_origin = new_arrows_lines_ptr; else perror("In erase arrow, can't re_allocate for arrow lines buffer.\n"); @@ -669,7 +679,7 @@ static inline int set_arrow (struct arrow_t *arrows_ptr, int arrows_nb, } } } - if (requested_weight == 0) printf("[%d]set_arrow() invoked with requested weight = %2d\n", arrows_nb, requested_weight); + if (requested_weight == 0) printf(" - set_arrow() invoked with requested weight = %2d\n", requested_weight); if (TEST) show_user_action(arrows_ptr, arrows_nb, address, requested_weight, current_weight, site, x, y, z);