FeatherMC/src/world/RegionFile.cpp

32 lines
670 B
C++
Raw Normal View History

2020-08-07 05:48:54 +01:00
#include "RegionFile.h"
#include "util/ByteUtil.h"
#include <fstream>
using std::string;
namespace Feather
{
RegionFile::RegionFile(string path)
{
2020-08-08 03:45:04 +01:00
std::ifstream stream(path, std::ifstream::binary);
2020-08-07 05:48:54 +01:00
stream.read(m_header, 8KB);
// Populate m_offsets
2020-08-08 03:45:04 +01:00
for (int i = 0; i < 1024; i++)
2020-08-07 05:48:54 +01:00
{
int32_t readInt = 0;
std::memcpy(&readInt, &m_header[i * 4], sizeof(int32_t));
// Read big endian ints.
readInt = ReverseBytes(readInt);
m_offsets[i] = readInt;
if (readInt == 0) continue;
//int sector = GetSectorNumber(readInt);
//int sectorCount = GetSectorCount(readInt);
// We can record which sectors are used by this region here
}
}
}