Skip to content
This repository has been archived by the owner on Dec 16, 2019. It is now read-only.

Commit

Permalink
Stripped trailing whitespace / extra newline at end of files
Browse files Browse the repository at this point in the history
IgnoreExisting renamed to CreateNew
Cleaned up usage of CreateNew
Load order sorting slightly modified
  Previously, new, ignored, and non-existent esps sorted after existing esps
  Now, new esps sort after existings esps, and non-existent esps sort before existing esps
    Non-existent esps now retaining their relative load order
    Ignored esps are no longer specially sorted (they either exist or not)
Raw MGEFCode's now sanitize their input (specifically, ISTRINGs, such as MGEF eids, are now converted to a regular string)
FormIDs/ActorValues/MGEFCodes now sanitize their input (specifically, master strings are converted to GPaths)
FormIDs/ActorValues/MGEFCodes can now be used in truth testing (Empty and Invalid values test as False, rest as True)
Cleaned up Collection::Load
Temporarily silenced GetRecordHistory: Warning until I figure out the best way to handle/avoid the issue
Fixed IdenticalToMasterRetriever to compare against the latest version of the master's record rather than the earliest
Fixed equality testing of child records, records with AI Packages, and pathgrids
(Mostly) factored reading out of templated var types
Minor typo fixes in comments
Fixed tracking of new types / records
Debug prints no longer include the file
Added debug macros to print hex, decimal, and string vars
Fixed list setting regression
  • Loading branch information
waruddar committed Sep 28, 2011
1 parent b8724b5 commit 5a8ab18
Show file tree
Hide file tree
Showing 47 changed files with 617 additions and 725 deletions.
Binary file modified CBash.suo
Binary file not shown.
2 changes: 1 addition & 1 deletion CBash/CBash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,7 @@ CPPDLLEXTERN SINT32 DeleteRecord(Record *RecordID)
//Update the IsWinning flags for all related records
ModFile *WinningModfile = NULL;
Record *WinningRecord = NULL;

if(IsKeyedByEditorID)
CollectionID->LookupWinningRecord(EditorID, WinningModfile, WinningRecord, true);
else
Expand Down
118 changes: 63 additions & 55 deletions CBash/Collection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,33 +91,45 @@ bool sortMod(ModFile *lhs, ModFile *rhs)
//Non-existent esms sort before existing esps
//Non-existent esms retain their relative load order
//Existing esps sort by modified date
//Non-existent esps sort before existing esps
//Non-existent esps retain their relative load order
//New esps load last
#ifndef LHS_BEFORE_RHS
#define LHS_BEFORE_RHS true
#define LHS_AFTER_RHS false
#endif
if(lhs->TES4.IsESM())
{
if(rhs->TES4.IsESM())
{
if(lhs->ModTime == 0)
{
if(rhs->ModTime == 0)
return true;
return false;
return LHS_BEFORE_RHS;
return LHS_AFTER_RHS;
}
if(rhs->ModTime == 0)
return true;
return LHS_BEFORE_RHS;
return lhs->ModTime < rhs->ModTime;
}
return true;
return LHS_BEFORE_RHS;
}
if(rhs->TES4.IsESM())
return false;
if(lhs->Flags.IsIgnoreExisting || lhs->ModTime == 0)
return LHS_AFTER_RHS;

if(lhs->Flags.IsCreateNew)
{
if(rhs->Flags.IsIgnoreExisting || rhs->ModTime == 0)
return true;
return false;
if(rhs->Flags.IsCreateNew)
return LHS_BEFORE_RHS;
return LHS_AFTER_RHS;
}
if(rhs->Flags.IsIgnoreExisting || rhs->ModTime == 0)
return false;
if(rhs->Flags.IsCreateNew)
return LHS_BEFORE_RHS;

if(lhs->ModTime == 0)
return LHS_BEFORE_RHS;
if(rhs->ModTime == 0)
return LHS_AFTER_RHS;
return lhs->ModTime < rhs->ModTime;
}

Expand Down Expand Up @@ -268,7 +280,7 @@ SINT32 Collection::Load()
{
curModFile = ModFiles[p];
curModFile->LoadTES4();
if(curModFile->Flags.IsAddMasters)
if(!curModFile->Flags.IsCreateNew && curModFile->Flags.IsAddMasters)
{
//Any new mods loaded this way inherit their flags
ModFlags preloadFlags(curModFile->Flags.GetFlags());
Expand Down Expand Up @@ -320,37 +332,16 @@ SINT32 Collection::Load()
curModFile = ModFiles[p];
RecordReader read_parser(curModFile);
//Loads GRUP and Record Headers. Fully loads GMST records.
if(curModFile->Flags.IsInLoadOrder || curModFile->Flags.IsIgnoreAbsentMasters)
curModFile->FormIDHandler.SetLoadOrder(strLoadOrder255);
else
{
curModFile->FormIDHandler.SetLoadOrder(strAllLoadOrder[x]);
++x;
}
if(curModFile->Flags.IsSkipNewRecords)
curModFile->FormIDHandler.CreateFormIDLookup(0xFF);
else
{
if(curModFile->Flags.IsInLoadOrder)
{
curModFile->FormIDHandler.CreateFormIDLookup(expandedIndex);
++expandedIndex;
}
else
curModFile->FormIDHandler.CreateFormIDLookup((UINT8)curModFile->TES4.MAST.size());
}
curModFile->FormIDHandler.SetLoadOrder((curModFile->Flags.IsInLoadOrder || curModFile->Flags.IsIgnoreAbsentMasters) ? strLoadOrder255 : strAllLoadOrder[x++]);
//VHDPRINT(curModFile->Flags.IsSkipNewRecords ? 0xFF : curModFile->Flags.IsInLoadOrder ? expandedIndex : (UINT8)curModFile->TES4.MAST.size());
curModFile->FormIDHandler.CreateFormIDLookup(curModFile->Flags.IsSkipNewRecords ? 0xFF :
curModFile->Flags.IsInLoadOrder ? expandedIndex++ :
(UINT8)curModFile->TES4.MAST.size());
Expanders.push_back(new FormIDResolver(curModFile->FormIDHandler.ExpandTable, curModFile->FormIDHandler.FileStart, curModFile->FormIDHandler.FileEnd));
DeletedRecords.push_back(std::make_pair(curModFile, std::vector<Record *>()));
if(curModFile->Flags.IsExtendedConflicts)
{
extended_indexer.SetModFile(curModFile);
curModFile->Load(read_parser, extended_indexer, Expanders, DeletedRecords.back().second);
}
else
{
indexer.SetModFile(curModFile);
curModFile->Load(read_parser, indexer, Expanders, DeletedRecords.back().second);
}
RecordIndexer &used_indexer = curModFile->Flags.IsExtendedConflicts ? extended_indexer : indexer;
used_indexer.SetModFile(curModFile);
curModFile->Load(read_parser, used_indexer, Expanders, DeletedRecords.back().second);
}
//printer("Loaded\n");
strAllLoadOrder.clear();
Expand Down Expand Up @@ -672,7 +663,8 @@ SINT32 Collection::GetRecordHistory(Record *&curRecord, RECORDIDARRAY RecordIDs)
ModFile *curModFile = curRecord->GetParentMod();
if(curModFile->Flags.IsExtendedConflicts)
{
printer("GetRecordHistory: Warning - No history available. Mod \"%s\" uses extended conflicts.\n", curModFile->ModName);
//Temporarily silenced until I figure out the best way to handle/avoid the issue
//printer("GetRecordHistory: Warning - No history available. Mod \"%s\" uses extended conflicts.\n", curModFile->ModName);
return -1;
}

Expand Down Expand Up @@ -1144,7 +1136,6 @@ IdenticalToMasterRetriever::IdenticalToMasterRetriever(ModFile *ModID):
RecordOp(),
reader(ModID->FormIDHandler, ModID->Parent->Expanders),
MasterIndex(ModID->FormIDHandler.ExpandedIndex),
LoadOrder255(ModID->Parent->LoadOrder255),
identical_records(ModID->Parent->identical_records),
EditorID_ModFile_Record(ModID->Flags.IsExtendedConflicts ? ModID->Parent->ExtendedEditorID_ModFile_Record: ModID->Parent->EditorID_ModFile_Record),
FormID_ModFile_Record(ModID->Flags.IsExtendedConflicts ? ModID->Parent->ExtendedFormID_ModFile_Record: ModID->Parent->FormID_ModFile_Record),
Expand All @@ -1167,30 +1158,47 @@ bool IdenticalToMasterRetriever::Accept(Record *&curRecord)
return false;

Record *master_record = NULL;
ModFile *master_mod = LoadOrder255[ModIndex];
ModFile *master_mod = curRecord->GetParentMod();

const UINT8 &CollapsedIndex = master_mod->FormIDHandler.CollapsedIndex;
const UINT8 (&CollapseTable)[256] = master_mod->FormIDHandler.CollapseTable;
SINT32 ModID = -1;

if(curRecord->IsKeyedByEditorID() && curRecord->GetEditorIDKey() != NULL) //Should only be null on deleted records (they'll get indexed after being undeleted)
{
for(EditorID_Range range = EditorID_ModFile_Record.equal_range(curRecord->GetEditorIDKey()); range.first != range.second; ++range.first)
if(range.first->second->GetParentMod() == master_mod)
{
master_record = range.first->second;
break;
}
{
master_mod = range.first->second->GetParentMod();
if((SINT32)master_mod->ModID > ModID && (master_mod->Flags.IsInLoadOrder || master_mod->Flags.IsIgnoreAbsentMasters))
//If the CollapseTable at a given expanded index is set to something other than the mod's CollapsedIndex,
// that means the mod has that other mod as a master.
if(CollapseTable[master_mod->FormIDHandler.ExpandedIndex] != CollapsedIndex)
{
ModID = master_mod->ModID;
master_record = range.first->second;
}
}
}
else if(curRecord->formID != 0)
{
for(FormID_Range range = FormID_ModFile_Record.equal_range(curRecord->formID); range.first != range.second; ++range.first)
if(range.first->second->GetParentMod() == master_mod)
{
master_record = range.first->second;
break;
}
{
master_mod = range.first->second->GetParentMod();
if((SINT32)master_mod->ModID > ModID && (master_mod->Flags.IsInLoadOrder || master_mod->Flags.IsIgnoreAbsentMasters))
//If the CollapseTable at a given expanded index is set to something other than the mod's CollapsedIndex,
// that means the mod has that other mod as a master.
if(CollapseTable[master_mod->FormIDHandler.ExpandedIndex] != CollapsedIndex)
{
ModID = master_mod->ModID;
master_record = range.first->second;
}
}
}

if(master_record == NULL)
return false;

RecordReader read_other(master_mod->FormIDHandler, Expanders);
RecordReader read_other(master_record->GetParentMod()->FormIDHandler, Expanders);

if(curRecord->master_equality(master_record, reader, read_other, identical_records))
identical_records.insert(curRecord);
Expand Down
1 change: 0 additions & 1 deletion CBash/Collection.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ class IdenticalToMasterRetriever : public RecordOp
private:
EditorID_Map &EditorID_ModFile_Record;
FormID_Map &FormID_ModFile_Record;
const std::vector<ModFile *> &LoadOrder255;
const UINT8 &MasterIndex;
boost::unordered_set<Record *> &identical_records;
std::vector<FormIDResolver *> &Expanders;
Expand Down
44 changes: 39 additions & 5 deletions CBash/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ ModFlags::ModFlags():
IsTrackNewTypes(false),
IsIndexLANDs(false),
IsFixupPlaceables(false),
IsIgnoreExisting(false),
IsCreateNew(false),
IsIgnoreAbsentMasters(false),
LoadedGRUPs(false)
{
Expand All @@ -773,7 +773,7 @@ ModFlags::ModFlags(UINT32 _Flags):
IsTrackNewTypes((_Flags & fIsTrackNewTypes) != 0),
IsIndexLANDs((_Flags & fIsIndexLANDs) != 0),
IsFixupPlaceables((_Flags & fIsFixupPlaceables) != 0),
IsIgnoreExisting((_Flags & fIsIgnoreExisting) != 0),
IsCreateNew((_Flags & fIsCreateNew) != 0),
IsIgnoreAbsentMasters((_Flags & fIsIgnoreAbsentMasters) != 0),
LoadedGRUPs(false)
{
Expand Down Expand Up @@ -820,8 +820,8 @@ UINT32 ModFlags::GetFlags()
flags |= fIsIndexLANDs;
if(IsFixupPlaceables)
flags |= fIsFixupPlaceables;
if(IsIgnoreExisting)
flags |= fIsIgnoreExisting;
if(IsCreateNew)
flags |= fIsCreateNew;
if(IsIgnoreAbsentMasters)
{
flags &= ~fIsAddMasters;
Expand Down Expand Up @@ -1059,7 +1059,7 @@ UINT32 NonNullStringRecord::GetSize() const
STRING NonNullStringRecord::GetString()
{
if(DiskSize != 0)
{
{
//Have to sanitize the string before letting it be used
//The string needs a null terminator added, so load it from disk
STRING nvalue = new char[DiskSize + 1];
Expand Down Expand Up @@ -1469,6 +1469,40 @@ bool RawRecord::operator !=(const RawRecord &other) const
return !(*this == other);
}

bool ReadChunk(unsigned char *&buffer, const UINT32 &buffer_size, void *dest_buffer, const UINT32 &dest_buffer_size, const bool &skip_load)
{
if(skip_load)
{
buffer += buffer_size;
return false;
}
#ifdef CBASH_CHUNK_WARN
if(buffer_size > dest_buffer_size)
{
printer("ReadChunk: Warning - Unable to fully parse chunk (%c%c%c%c). "
"Size of chunk (%u) is larger than the size of the subrecord (%u) "
"and will be truncated.\n",
buffer[-6], buffer[-5], buffer[-4], buffer[-3],
buffer_size, dest_buffer_size);
CBASH_CHUNK_DEBUG
}
#ifdef CBASH_CHUNK_LCHECK
else if(buffer_size < dest_buffer_size)
{
printer("ReadChunk: Info - Unable to fully parse chunk (%c%c%c%c). Size "
"of chunk (%u) is less than the size of the subrecord (%u) and any "
"remaining fields have their default value.\n",
buffer[-6], buffer[-5], buffer[-4], buffer[-3],
buffer_size, dest_buffer_size);
CBASH_CHUNK_DEBUG
}
#endif
#endif
memcpy(dest_buffer, buffer, buffer_size > dest_buffer_size ? dest_buffer_size : buffer_size);
buffer += buffer_size;
return true;
}

const UINT32 VATSFunction_Argument[] =
{
eFORMID,
Expand Down
Loading

0 comments on commit 5a8ab18

Please sign in to comment.