Move Num_vertices into if(DXX_USE_EDITOR)

Non-editor builds only need Num_vertices as a local during mine loading.
This commit is contained in:
Kp 2020-12-26 21:17:29 +00:00
parent 90d43d6519
commit 70d55c010d
2 changed files with 15 additions and 7 deletions

View file

@ -397,7 +397,13 @@ namespace dcx {
#ifdef dsx
struct d_level_shared_vertex_state
{
#if DXX_USE_EDITOR
/* Number of elements in Vertex_active which have a nonzero value.
* This can be less than the index of the highest defined vertex if
* there are unused vertices.
*/
unsigned Num_vertices;
#endif
private:
vertex_array Vertices;
#if DXX_USE_EDITOR

View file

@ -442,11 +442,13 @@ int load_mine_data_compiled(PHYSFS_File *LoadFile, const char *const Gamesave_cu
(void)compiled_version;
DXX_POISON_VAR(Vertices, 0xfc);
if (New_file_format_load)
LevelSharedVertexState.Num_vertices = PHYSFSX_readShort(LoadFile);
else
LevelSharedVertexState.Num_vertices = PHYSFSX_readInt(LoadFile);
assert(LevelSharedVertexState.Num_vertices <= MAX_VERTICES);
const unsigned Num_vertices = New_file_format_load
? PHYSFSX_readShort(LoadFile)
: PHYSFSX_readInt(LoadFile);
assert(Num_vertices <= MAX_VERTICES);
#if DXX_USE_EDITOR
LevelSharedVertexState.Num_vertices = Num_vertices;
#endif
DXX_POISON_VAR(Segments, 0xfc);
if (New_file_format_load)
@ -455,7 +457,7 @@ int load_mine_data_compiled(PHYSFS_File *LoadFile, const char *const Gamesave_cu
LevelSharedSegmentState.Num_segments = PHYSFSX_readInt(LoadFile);
assert(LevelSharedSegmentState.Num_segments <= MAX_SEGMENTS);
range_for (auto &i, partial_range(Vertices, LevelSharedVertexState.Num_vertices))
range_for (auto &i, partial_range(Vertices, Num_vertices))
PHYSFSX_readVector(LoadFile, i);
const auto Num_segments = LevelSharedSegmentState.Num_segments;
@ -561,7 +563,7 @@ int load_mine_data_compiled(PHYSFS_File *LoadFile, const char *const Gamesave_cu
}
}
Vertices.set_count(LevelSharedVertexState.Num_vertices);
Vertices.set_count(Num_vertices);
Segments.set_count(Num_segments);
validate_segment_all(LevelSharedSegmentState); // Fill in side type and normals.