Commit f8031f41 authored by Corentin Bocquillon's avatar Corentin Bocquillon

Bug fixing.

parent bf3a9aad
......@@ -158,12 +158,16 @@ Map::get_save ()
void
Map::set_surface_item (coordinates chunk_coordinates,
coordinates square_coordinates, int item_id,
int quantity)
coordinates square_coordinates, int item_id,
int quantity)
{
m_save.set_surface_item (chunk_coordinates, square_coordinates,
item_id, quantity);
update_chunk_vertices (get_chunk (chunk_coordinates));
coordinates coordinates = chunk_coordinates;
coordinates.y -= 1;
update_chunk_vertices (get_chunk (coordinates));
}
void
......@@ -319,7 +323,21 @@ Map::get_chunk_vertex_arrays (Chunk &chunk)
for (unsigned k = 0; k < m_item_max_height / Save::square_size; ++k)
{
int surface_id = save_chunk->get_square_item_id ({i, j + k});
int surface_id = -1;
if (j + k > Save::square_per_side - 1)
{
if (k > Save::square_per_side)
continue; // Cas non conforme.
coordinates chunk_coordinates = chunk.get_coordinates ();
chunk_coordinates.y += 1;
coordinates square_coordinates = {.x = (int) i,
.y = (int) j + (int) k - Save::square_per_side};
surface_id = m_save.get_surface_item (chunk_coordinates,
square_coordinates);
}
else
surface_id = save_chunk->get_square_item_id ({i, j + k});
set_vertices_position (surface_vertices[k],
square_number * 6, {i, j});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment