Skip to content
This repository has been archived by the owner on Sep 5, 2020. It is now read-only.

Commit

Permalink
(ref. #8) Change to RecordProcessor::Accept()
Browse files Browse the repository at this point in the history
Moved the implementation of RecordProcessor::Accept() from the header
to the cpp file.

Reason is that both GenericRecord.h and ModFile.h includes each other,
so in GenericRecord.h ModFile struct is not fully declared.  So any use
of its members triggers a compile error.
  • Loading branch information
leandor committed Oct 28, 2016
1 parent 234c682 commit 808ef45
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 50 deletions.
53 changes: 53 additions & 0 deletions src/GenericRecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

#include "Common.h"
#include "GenericRecord.h"
#include "ModFile.h"
#include "zlib.h"

RecordOp::RecordOp():
Expand Down Expand Up @@ -97,6 +98,58 @@ RecordProcessor::~RecordProcessor()
//
}

bool RecordProcessor::Accept(RecordHeader &header)
{

/* this assumes records are read serial (all records belonging
* to a specific worldspace are between this WRLD and the next WRLD)
*/
if (header.type == REV32(WRLD))
activewspace = header.formID;

/* only allow those in the set */
if (filter_inclusive) {
if (filter_records.count(header.type) == 0)
return false;
if (header.type != REV32(LTEX))
if (header.type != REV32(TXST))
if (header.type != REV32(MATT))
if (filter_wspaces.count(activewspace) == 0)
return false;
}
/* only allow those not in the set */
else {
if (filter_records.count(header.type) != 0)
return false;
if (header.type != REV32(LTEX))
if (header.type != REV32(TXST))
if (header.type != REV32(MATT))
if (filter_wspaces.count(activewspace) != 0)
return false;
}

expander.Accept(header.formID);

if ((IsTrackNewTypes || IsSkipNewRecords) && ((header.formID >> 24) == ExpandedIndex))
{
if (IsTrackNewTypes)
NewTypes.insert(header.type);
if (IsSkipNewRecords)
return false;
}

//Make sure the formID is unique within the mod
auto result = UsedFormIDs.insert(header.formID);
if (result.second == false)
{
if (IsAddMasters) //If not, can cause any new records to be given a duplicate ID
printer("RecordProcessor: Warning - Information lost. Record skipped with duplicate formID: %08X\n", header.formID);
return false;
}

return IsKeepRecords;
}

Record::Record(unsigned char *_recData):
flags(0),
formID(0),
Expand Down
51 changes: 1 addition & 50 deletions src/GenericRecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,56 +105,7 @@ class RecordProcessor
filter_wspaces = WorldSpaces;
}

bool Accept(RecordHeader &header)
{

/* this assumes records are read serial (all records belonging
* to a specific worldspace are between this WRLD and the next WRLD)
*/
if (header.type == REV32(WRLD))
activewspace = header.formID;

/* only allow those in the set */
if (filter_inclusive) {
if (filter_records.count(header.type) == 0)
return false;
if (header.type != REV32(LTEX))
if (header.type != REV32(TXST))
if (header.type != REV32(MATT))
if (filter_wspaces.count(activewspace) == 0)
return false;
}
/* only allow those not in the set */
else {
if (filter_records.count(header.type) != 0)
return false;
if (header.type != REV32(LTEX))
if (header.type != REV32(TXST))
if (header.type != REV32(MATT))
if (filter_wspaces.count(activewspace) != 0)
return false;
}

expander.Accept(header.formID);

if((IsTrackNewTypes || IsSkipNewRecords) && ((header.formID >> 24) == ExpandedIndex))
{
if(IsTrackNewTypes)
NewTypes.insert(header.type);
if(IsSkipNewRecords)
return false;
}

//Make sure the formID is unique within the mod
if(UsedFormIDs.insert(header.formID).second == false)
{
if(IsAddMasters) //If not, can cause any new records to be given a duplicate ID
printer("RecordProcessor: Warning - Information lost. Record skipped with duplicate formID: %08X\n", header.formID);
return false;
}

return IsKeepRecords;
}
bool Accept(RecordHeader &header);

//template<bool IsKeyedByEditorID, typename U>
//typename boost::enable_if_c<IsKeyedByEditorID,bool>::type Accept(U &header)
Expand Down

0 comments on commit 808ef45

Please sign in to comment.