uox3/source/IDXMul.cpp
Xoduz 15e79871b9 0.99.4n
Fixed return value logic for onUseChecked/onUsedUnchecked JS events - was reversed by mistake!
Initiated start of revamped mul/uop handling, with some new files added to project: (punt)
	MultiMul.cpp/hpp, IDXMul.cpp/hpp and UOPData.cpp/hpp
Updated code for loading and seeking in multis (punt)
Added new files to VS project and project filter
Added new files to source/CMakeLists.txt
Updated version number in uox3.rc

Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2021-05-30 03:21:05 +08:00

55 lines
1.5 KiB
C++

//
// Created on: 4/28/21
#include "IDXMul.hpp"
#include <cstdint>
#include <iostream>
#include <stdexcept>
#include <fstream>
//+++++++++++++++++++++++++++++++++++++++++++++++++++
//
// Methods for IDXMul
//
//+++++++++++++++++++++++++++++++++++++++++++++++++++
//==========================================================================
IDXMul::IDXMul() {
}
//==========================================================================
IDXMul::IDXMul(const std::string &filepath) {
load(filepath);
}
//==========================================================================
void IDXMul::load(const std::string &filepath){
std::ifstream input(filepath,std::fstream::in | std::fstream::binary);
if (!input.is_open()) {
throw std::runtime_error(std::string("Unable to open: ")+filepath);
}
while(!input.eof()) {
entry value ;
input.read(reinterpret_cast<char*>(&value.offset),4);
if (input.gcount()!= 4) {
break;
}
input.read(reinterpret_cast<char*>(&value.length),4);
if (input.gcount()!= 4) {
break;
}
input.read(reinterpret_cast<char*>(&value.extra),4);
if (input.gcount()!= 4) {
break;
}
_entries.push_back(value);
}
}
//==========================================================================
std::size_t IDXMul::size() const {
return _entries.size();
}
//==========================================================================
const IDXMul::entry& IDXMul::operator[](std::size_t index) const {
return _entries[index];
}