WIP: un premier succès (fragile) pour 'erase_arrow()' (voir le cas liste vide)
This commit is contained in:
parent
df54fc5751
commit
97b946d6c5
|
@ -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].y = arrows_ptr[arrows_nb].y;
|
||||||
arrows_ptr[address].z = arrows_ptr[arrows_nb].z;
|
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) {
|
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;
|
if (new_arrows_list_ptr) arrows_ptr = new_arrows_list_ptr;
|
||||||
else perror("In erase arrow, can't re_allocate for arrow list.\n");
|
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));
|
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;
|
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");
|
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));
|
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;
|
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");
|
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);
|
if (TEST) show_user_action(arrows_ptr, arrows_nb, address, requested_weight, current_weight, site, x, y, z);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue