From fe8dccbe43eb88673c62c493e2dcb3afb672706e Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Wed, 27 Sep 2023 11:02:17 +0200 Subject: [PATCH] =?UTF-8?q?WIP:=20encore=20un=20peu=20de=20cosm=C3=A9tique?= =?UTF-8?q?=20(variables=20globales=20>=20locales)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/graphics/graphics.c | 95 ++++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 48 deletions(-) diff --git a/src/graphics/graphics.c b/src/graphics/graphics.c index a98dd84..4cf6e84 100644 --- a/src/graphics/graphics.c +++ b/src/graphics/graphics.c @@ -667,6 +667,53 @@ static bool erase_arrow (GLuint *arrows, int arrows_nb, int address, int site, i return 1; } + + + +static int set_arrow (GLuint *arrows, int arrows_nb, int weight, int site, int x, int y, int z) +{ + // assert pas de doublons flèche(s) + + int address = -1, current_weight = -1; + + if (arrows_nb > 0) + for (int i = 0; i < arrows_nb; i++) { + if ((site == *(arrows + i * 5 + 1)) + && (x == *(arrows + i * 5 + 2)) + && (y == *(arrows + i * 5 + 3)) + && (z == *(arrows + i * 5 + 4))) + { + address = i * 5; + current_weight = *(arrows + i * 5 + 0); + break; + } + } + + if (address == -1 && weight == 0) return 0; + if (address == -1 && weight > 0) return create_arrow (arrows, arrows_nb, weight, site, x, y, z); + if (address >= 0 && weight == 0) return erase_arrow (arrows, arrows_nb, address, site, x, y, z); + if (address >= 0 && current_weight != weight) return rewrite_arrow (arrows, arrows_nb, address, weight, site, x, y, z); + return 0; +} + + + + + + + + + + + + + + + + + + + static void show_arrows_array (GLuint *arrows, int arrows_nb, int address, int current_weigh, int weight, int site, int x, int y, int z) { printf("\nset_arrow (%d | %2d %2d %2d %2d) <> ", weight, site, x, y, z); @@ -701,54 +748,6 @@ static void show_arrows_array (GLuint *arrows, int arrows_nb, int address, int c } } - - - - - - - - - - - - - - - - - - - - -static int set_arrow (GLuint *arrows, int arrows_nb, int weight, int site, int x, int y, int z) -{ - // assert pas de doublons flèche(s) - - int address = -1, current_weight = -1; - - if (arrows_nb > 0) - for (int i = 0; i < arrows_nb; i++) { - if ((site == *(arrows + i * 5 + 1)) - && (x == *(arrows + i * 5 + 2)) - && (y == *(arrows + i * 5 + 3)) - && (z == *(arrows + i * 5 + 4))) - { - address = i * 5; - current_weight = *(arrows + i * 5 + 0); - break; - } - } - - if (address == -1 && weight == 0) return 0; - if (address == -1 && weight > 0) return create_arrow (arrows, arrows_nb, weight, site, x, y, z); - if (address >= 0 && weight == 0) return erase_arrow (arrows, arrows_nb, address, site, x, y, z); - if (address >= 0 && current_weight != weight) return rewrite_arrow (arrows, arrows_nb, address, weight, site, x, y, z); - return 0; -} - -/* -------------------------------------------------------------------------- */ - static void show_user_choices(GLuint *arrows, int arrows_nb, int space_size_x, int space_size_y, int space_size_z, int prefer, int show_all)