mirror of
https://github.com/UOX3DevTeam/UOX3
synced 2026-08-13 12:27:04 -04:00
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>
55 lines
1.5 KiB
C++
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];
|
|
}
|