From b68a403e41901198093866fcdcd352009bc5da3f Mon Sep 17 00:00:00 2001 From: Kp Date: Sat, 20 Dec 2014 04:36:11 +0000 Subject: [PATCH] Use partial_range to load textures --- common/main/gamemine.h | 2 +- similar/editor/group.cpp | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/common/main/gamemine.h b/common/main/gamemine.h index 2b74d0b9b..b455e1621 100644 --- a/common/main/gamemine.h +++ b/common/main/gamemine.h @@ -70,7 +70,7 @@ struct mfi { int vertex_howmany; int vertex_sizeof; int texture_offset; - int texture_howmany; + uint32_t texture_howmany; int texture_sizeof; int walls_offset; int walls_howmany; diff --git a/similar/editor/group.cpp b/similar/editor/group.cpp index d478d4ef9..2a325b25e 100644 --- a/similar/editor/group.cpp +++ b/similar/editor/group.cpp @@ -47,6 +47,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "dxxsconf.h" #include "compiler-range_for.h" #include "highest_valid.h" +#include "partial_range.h" #include "segiter.h" static void validate_selected_segments(void); @@ -70,7 +71,7 @@ struct group_fileinfo { int segment_howmany; int segment_sizeof; int texture_offset; - int texture_howmany; + uint32_t texture_howmany; int texture_sizeof; } group_fileinfo; @@ -1282,10 +1283,12 @@ static int med_load_group( const char *filename, group::vertex_array_type_t &ver if (PHYSFSX_fseek( LoadFile, group_fileinfo.texture_offset, SEEK_SET )) Error( "Error seeking to texture_offset in gamemine.c" ); - for (i=0; i< group_fileinfo.texture_howmany; i++ ) + range_for (auto &i, partial_range(old_tmap_list, group_fileinfo.texture_howmany)) { - if (PHYSFS_read( LoadFile, &old_tmap_list[i], group_fileinfo.texture_sizeof, 1 )!=1) + array a; + if (PHYSFS_read(LoadFile, a.data(), std::min(static_cast(group_fileinfo.texture_sizeof), a.size()), 1) != 1) Error( "Error reading old_tmap_list[i] in gamemine.c" ); + i.copy_if(a); } }