mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 22:45:34 +00:00
clean up code; purge const_cast
This commit is contained in:
parent
7aca6d72e4
commit
8c2f3ff007
5 changed files with 12 additions and 9 deletions
|
@ -45,7 +45,7 @@ void ESMStore::load(ESM::ESMReader &esm, Loading::Listener* listener)
|
|||
const std::vector<ESM::Header::MasterData> &masters = esm.getGameFiles();
|
||||
std::vector<ESM::ESMReader> *allPlugins = esm.getGlobalReaderList();
|
||||
for (size_t j = 0; j < masters.size(); j++) {
|
||||
ESM::Header::MasterData &mast = const_cast<ESM::Header::MasterData&>(masters[j]);
|
||||
const ESM::Header::MasterData &mast = masters[j];
|
||||
std::string fname = mast.name;
|
||||
int index = ~0;
|
||||
for (int i = 0; i < esm.getIndex(); i++) {
|
||||
|
@ -63,7 +63,7 @@ void ESMStore::load(ESM::ESMReader &esm, Loading::Listener* listener)
|
|||
+ ", but it has not been loaded yet. Please check your load order.";
|
||||
esm.fail(fstring);
|
||||
}
|
||||
mast.index = index;
|
||||
esm.addParentFileIndex(index);
|
||||
}
|
||||
|
||||
// Loop through all records
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
@ -126,6 +127,7 @@ struct ESM_Context
|
|||
// actually contribute to a specific cell. Therefore, we need to store the index
|
||||
// of the file belonging to this contest. See CellStore::(list/load)refs for details.
|
||||
int index;
|
||||
std::vector<int> parentFileIndices;
|
||||
|
||||
// True if subName has been read but not used.
|
||||
bool subCached;
|
||||
|
|
|
@ -20,8 +20,7 @@ ESM_Context ESMReader::getContext()
|
|||
}
|
||||
|
||||
ESMReader::ESMReader()
|
||||
: mIdx(0)
|
||||
, mRecordFlags(0)
|
||||
: mRecordFlags(0)
|
||||
, mBuffer(50*1024)
|
||||
, mGlobalReaderList(nullptr)
|
||||
, mEncoder(nullptr)
|
||||
|
|
|
@ -79,13 +79,15 @@ public:
|
|||
// terrain palette, but ESMReader does not pass a reference to the correct plugin
|
||||
// to the individual load() methods. This hack allows to pass this reference
|
||||
// indirectly to the load() method.
|
||||
int mIdx;
|
||||
void setIndex(const int index) {mIdx = index; mCtx.index = index;}
|
||||
int getIndex() {return mIdx;}
|
||||
void setIndex(const int index) { mCtx.index = index;}
|
||||
int getIndex() {return mCtx.index;}
|
||||
|
||||
void setGlobalReaderList(std::vector<ESMReader> *list) {mGlobalReaderList = list;}
|
||||
std::vector<ESMReader> *getGlobalReaderList() {return mGlobalReaderList;}
|
||||
|
||||
void addParentFileIndex(int index) { mCtx.parentFileIndices.push_back(index); }
|
||||
const std::vector<int>& getParentFileIndices() const { return mCtx.parentFileIndices; }
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* Medium-level reading shortcuts
|
||||
|
|
|
@ -21,12 +21,12 @@ namespace
|
|||
|
||||
// If we have an index value that does not make sense, assume that it was an addition
|
||||
// by the present plugin (but a faulty one)
|
||||
if (local && local <= reader.getGameFiles().size())
|
||||
if (local && local <= reader.getParentFileIndices().size())
|
||||
{
|
||||
// If the most significant 8 bits are used, then this reference already exists.
|
||||
// In this case, do not spawn a new reference, but overwrite the old one.
|
||||
refNum.mIndex &= 0x00ffffff; // delete old plugin ID
|
||||
refNum.mContentFile = reader.getGameFiles()[local-1].index;
|
||||
refNum.mContentFile = reader.getParentFileIndices()[local-1];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue