WIP: encore un peu de cosmétique (variables globales > locales)

This commit is contained in:
Jean Sirmai 2023-09-27 11:02:17 +02:00
parent 3f5d5eb6b7
commit fe8dccbe43
Signed by: jean
GPG Key ID: FB3115C340E057E3
1 changed files with 47 additions and 48 deletions

View File

@ -667,6 +667,53 @@ static bool erase_arrow (GLuint *arrows, int arrows_nb, int address, int site, i
return 1; 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) 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); 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, static void show_user_choices(GLuint *arrows, int arrows_nb,
int space_size_x, int space_size_y, int space_size_z, int space_size_x, int space_size_y, int space_size_z,
int prefer, int show_all) int prefer, int show_all)