mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-31 20:26:43 +00:00 
			
		
		
		
	Use std::size_t to iterate
This commit is contained in:
		
							parent
							
								
									903ce44634
								
							
						
					
					
						commit
						f4cfade14b
					
				
					 2 changed files with 9 additions and 9 deletions
				
			
		|  | @ -212,7 +212,7 @@ void NIFFile::parse(Files::IStreamPtr stream) | |||
|         userVer = nif.getUInt(); | ||||
| 
 | ||||
|     // Number of records
 | ||||
|     unsigned int recNum = nif.getUInt(); | ||||
|     const std::size_t recNum = nif.getUInt(); | ||||
|     records.resize(recNum); | ||||
| 
 | ||||
|     // Bethesda stream header
 | ||||
|  | @ -251,7 +251,7 @@ void NIFFile::parse(Files::IStreamPtr stream) | |||
|                     std::vector<unsigned int> recSizes; // Currently unused
 | ||||
|                     nif.getUInts(recSizes, recNum); | ||||
|                 } | ||||
|                 unsigned int stringNum = nif.getUInt(); | ||||
|                 const std::size_t stringNum = nif.getUInt(); | ||||
|                 nif.getUInt(); // Max string length
 | ||||
|                 if (stringNum) | ||||
|                     nif.getSizedStrings(strings, stringNum); | ||||
|  | @ -264,7 +264,7 @@ void NIFFile::parse(Files::IStreamPtr stream) | |||
|     } | ||||
| 
 | ||||
|     const bool hasRecordSeparators = ver >= NIFStream::generateVersion(10,0,0,0) && ver < NIFStream::generateVersion(10,2,0,0); | ||||
|     for (unsigned int i = 0; i < recNum; i++) | ||||
|     for (std::size_t i = 0; i < recNum; i++) | ||||
|     { | ||||
|         Record *r = nullptr; | ||||
| 
 | ||||
|  | @ -308,11 +308,11 @@ void NIFFile::parse(Files::IStreamPtr stream) | |||
|         r->read(&nif); | ||||
|     } | ||||
| 
 | ||||
|     unsigned int rootNum = nif.getUInt(); | ||||
|     const std::size_t rootNum = nif.getUInt(); | ||||
|     roots.resize(rootNum); | ||||
| 
 | ||||
|     //Determine which records are roots
 | ||||
|     for (unsigned int i = 0; i < rootNum; i++) | ||||
|     for (std::size_t i = 0; i < rootNum; i++) | ||||
|     { | ||||
|         int idx = nif.getInt(); | ||||
|         if (idx >= 0 && idx < int(records.size())) | ||||
|  |  | |||
|  | @ -25,22 +25,22 @@ class NIFFile; | |||
| /* 
 | ||||
|     readLittleEndianBufferOfType: This template should only be used with arithmetic types | ||||
| */ | ||||
| template <uint32_t numInstances, typename T> inline void readLittleEndianBufferOfType(Files::IStreamPtr &pIStream, T* dest) | ||||
| template <std::size_t numInstances, typename T> inline void readLittleEndianBufferOfType(Files::IStreamPtr &pIStream, T* dest) | ||||
| { | ||||
|     pIStream->read((char*)dest, numInstances * sizeof(T)); | ||||
|     if constexpr (Misc::IS_BIG_ENDIAN) | ||||
|         for (uint32_t i = 0; i < numInstances; i++) | ||||
|         for (std::size_t i = 0; i < numInstances; i++) | ||||
|             Misc::swapEndiannessInplace(dest[i]); | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|     readLittleEndianDynamicBufferOfType: This template should only be used with arithmetic types | ||||
| */ | ||||
| template <typename T> inline void readLittleEndianDynamicBufferOfType(Files::IStreamPtr &pIStream, T* dest, uint32_t numInstances) | ||||
| template <typename T> inline void readLittleEndianDynamicBufferOfType(Files::IStreamPtr &pIStream, T* dest, std::size_t numInstances) | ||||
| { | ||||
|     pIStream->read((char*)dest, numInstances * sizeof(T)); | ||||
|     if constexpr (Misc::IS_BIG_ENDIAN) | ||||
|         for (uint32_t i = 0; i < numInstances; i++) | ||||
|         for (std::size_t i = 0; i < numInstances; i++) | ||||
|             Misc::swapEndiannessInplace(dest[i]); | ||||
| } | ||||
| template<typename type> type inline readLittleEndianType(Files::IStreamPtr &pIStream) | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue