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

Commit

Permalink
Warnings are no longer printed about orphaned records
Browse files Browse the repository at this point in the history
  Their formIDs are now saved, and may be retrieved with GetModNumOrphans / GetModOrphansFormIDs
  They are formIDs only, not RecordIDs. CBash does not keep the full record for orphans.
Ob::RACERecords now writes a race model's ICON chunk even if the MODL chunk is missing
Added ValidateList(Elements, Target) to cint
  Easily test whether all of the FormIDs/ActorValues/MGEFCodes in a list or tuple of values are valid for the target
ObModFile and FnvModFile now have GetNumEmptyGRUPs() and GetOrphanedFormIDs() for custom reporting of these errors
  • Loading branch information
waruddar committed Sep 11, 2011
1 parent afe658b commit 56d4f00
Show file tree
Hide file tree
Showing 11 changed files with 189 additions and 86 deletions.
Binary file modified CBash.suo
Binary file not shown.
27 changes: 26 additions & 1 deletion CBash/CBash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,32 @@ CPPDLLEXTERN SINT32 GetModNumOrphans(ModFile *ModID)
try
{
//ValidatePointer(ModID);
return ModID->FormIDHandler.OrphanedRecords;
return ModID->FormIDHandler.OrphanedRecords.size();
}
catch(std::exception &ex)
{
PRINT_EXCEPTION(ex);
}
catch(...)
{
PRINT_ERROR;
}
printer("\n\n");
if(RaiseCallback != NULL)
RaiseCallback();
return -1;
}

CPPDLLEXTERN SINT32 GetModOrphansFormIDs(ModFile *ModID, FORMIDARRAY FormIDs)
{
PROFILE_FUNC

try
{
//ValidatePointer(ModID);
for(UINT32 ListIndex = 0; ListIndex < ModID->FormIDHandler.OrphanedRecords.size(); ++ListIndex)
FormIDs[ListIndex] = ModID->FormIDHandler.OrphanedRecords[ListIndex];
return 0;
}
catch(std::exception &ex)
{
Expand Down
1 change: 1 addition & 0 deletions CBash/CBash.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ DLLEXTERN SINT32 GetModNumTypes(ModFile *ModID);
DLLEXTERN SINT32 GetModTypes(ModFile *ModID, UINT32ARRAY RecordTypes);
DLLEXTERN SINT32 GetModNumEmptyGRUPs(ModFile *ModID);
DLLEXTERN SINT32 GetModNumOrphans(ModFile *ModID);
DLLEXTERN SINT32 GetModOrphansFormIDs(ModFile *ModID, FORMIDARRAY FormIDs);
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
//FormID functions
Expand Down
3 changes: 1 addition & 2 deletions CBash/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,7 @@ FormIDHandlerClass::FormIDHandlerClass(std::vector<STRING> &_MAST, UINT32 &_Next
bMastersChanged(false),
FileStart(0),
FileEnd(0),
EmptyGRUPs(0),
OrphanedRecords(0)
EmptyGRUPs(0)
{
//
}
Expand Down
2 changes: 1 addition & 1 deletion CBash/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ class FormIDHandlerClass
bool IsEmpty;
bool bMastersChanged;
SINT32 EmptyGRUPs;
SINT32 OrphanedRecords;
std::vector<FORMID> OrphanedRecords;

FormIDHandlerClass(std::vector<STRING> &_MAST, UINT32 &_NextObject);
~FormIDHandlerClass();
Expand Down
160 changes: 80 additions & 80 deletions CBash/GRUPRecord.h

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CBash/GenericRecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class RecordProcessor
const ModFlags &Flags;
boost::unordered_set<UINT32> &UsedFormIDs;
SINT32 &EmptyGRUPs;
SINT32 &OrphanedRecords;
std::vector<FORMID> &OrphanedRecords;

bool IsSkipNewRecords;
bool IsTrackNewTypes;
Expand Down
2 changes: 1 addition & 1 deletion CBash/Oblivion/Records/RACERecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ void RACERecord::RACEMODEL::Write(FileWriter &writer)
WRITE(MODL);
WRITE(MODB);
WRITE(MODT);
WRITE(ICON);
}
WRITE(ICON);
}

bool RACERecord::RACEMODEL::operator ==(const RACEMODEL &other) const
Expand Down
Binary file modified release/CBash.dll
Binary file not shown.
39 changes: 39 additions & 0 deletions release/cint-template.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ def RaiseCB():
_CGetModNumEmptyGRUPs.errcheck = NegativeIsErrorCheck
_CGetModNumOrphans = CBash.GetModNumOrphans
_CGetModNumOrphans.errcheck = NegativeIsErrorCheck
_CGetModOrphansFormIDs = CBash.GetModOrphansFormIDs
_CGetModOrphansFormIDs.errcheck = NegativeIsErrorCheck

_CGetLongIDName = CBash.GetLongIDName
_CMakeShortFormID = CBash.MakeShortFormID
Expand Down Expand Up @@ -216,6 +218,7 @@ def RaiseCB():
_CGetModTypes.restype = c_long
_CGetModNumEmptyGRUPs.restype = c_long
_CGetModNumOrphans.restype = c_long
_CGetModOrphansFormIDs.restype = c_long
_CGetLongIDName.restype = c_char_p
_CMakeShortFormID.restype = c_ulong
_CCreateRecord.restype = c_ulong
Expand Down Expand Up @@ -1210,6 +1213,18 @@ def GetShortMGEFCode(self, target):
"""Resolves the various MGEFCode classes to a single 32-bit value used by CBash"""
return self.mgefCode.GetShortMGEFCode(target)

def ValidateList(Elements, Target):
"""Convenience function to ensure that a list of values is valid for the destination.
Returns true if all of the FormIDs/ActorValues/MGEFCodes in the list are valid."""
isValid = True
for element in Elements:
if not isValid: return isValid
if isinstance(element, (FormID, ActorValue, MGEFCode)):
isValid = element.Validate(Target)
elif isinstance(element, (tuple, list)):
isValid = ValidateList(element, Target)
return isValid

def getattr_deep(obj, attr):
return reduce(getattr, attr.split('.'), obj)

Expand Down Expand Up @@ -13260,6 +13275,18 @@ def GetNewRecordTypes(self):
return [cRecord.value for cRecord in cRecords if cRecord]
return []

def GetNumEmptyGRUPs(self):
return _CGetModNumEmptyGRUPs(self._ModID)

def GetOrphanedFormIDs(self):
numFormIDs = _CGetModNumOrphans(self._ModID)
if(numFormIDs > 0):
cFormIDs = (c_ulong * numFormIDs)()
_CGetModOrphansFormIDs(self._ModID, byref(cFormIDs))
RecordID = _CGetRecordID(self._ModID, 0, 0)
return [FormID(_CGetLongIDName(RecordID, cFormID, 0), cFormID) for cFormID in cFormIDs if cFormID]
return []

def UpdateReferences(self, Old_NewFormIDs):
Old_NewFormIDs = FormID.FilterValidDict(Old_NewFormIDs, self, True, True)
length = len(Old_NewFormIDs)
Expand Down Expand Up @@ -13476,6 +13503,18 @@ def GetNewRecordTypes(self):
return [cRecord.value for cRecord in cRecords if cRecord]
return []

def GetNumEmptyGRUPs(self):
return _CGetModNumEmptyGRUPs(self._ModID)

def GetOrphanedFormIDs(self):
numFormIDs = _CGetModNumOrphans(self._ModID)
if(numFormIDs > 0):
cFormIDs = (c_ulong * numFormIDs)()
_CGetModOrphansFormIDs(self._ModID, byref(cFormIDs))
RecordID = _CGetRecordID(self._ModID, 0, 0)
return [FormID(_CGetLongIDName(RecordID, cFormID, 0), cFormID) for cFormID in cFormIDs if cFormID]
return []

def UpdateReferences(self, Old_NewFormIDs):
Old_NewFormIDs = FormID.FilterValidDict(Old_NewFormIDs, self, True, True)
length = len(Old_NewFormIDs)
Expand Down
39 changes: 39 additions & 0 deletions release/cint.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ def RaiseCB():
_CGetModNumEmptyGRUPs.errcheck = NegativeIsErrorCheck
_CGetModNumOrphans = CBash.GetModNumOrphans
_CGetModNumOrphans.errcheck = NegativeIsErrorCheck
_CGetModOrphansFormIDs = CBash.GetModOrphansFormIDs
_CGetModOrphansFormIDs.errcheck = NegativeIsErrorCheck

_CGetLongIDName = CBash.GetLongIDName
_CMakeShortFormID = CBash.MakeShortFormID
Expand Down Expand Up @@ -216,6 +218,7 @@ def RaiseCB():
_CGetModTypes.restype = c_long
_CGetModNumEmptyGRUPs.restype = c_long
_CGetModNumOrphans.restype = c_long
_CGetModOrphansFormIDs.restype = c_long
_CGetLongIDName.restype = c_char_p
_CMakeShortFormID.restype = c_ulong
_CCreateRecord.restype = c_ulong
Expand Down Expand Up @@ -1210,6 +1213,18 @@ def GetShortMGEFCode(self, target):
"""Resolves the various MGEFCode classes to a single 32-bit value used by CBash"""
return self.mgefCode.GetShortMGEFCode(target)

def ValidateList(Elements, Target):
"""Convenience function to ensure that a list of values is valid for the destination.
Returns true if all of the FormIDs/ActorValues/MGEFCodes in the list are valid."""
isValid = True
for element in Elements:
if not isValid: return isValid
if isinstance(element, (FormID, ActorValue, MGEFCode)):
isValid = element.Validate(Target)
elif isinstance(element, (tuple, list)):
isValid = ValidateList(element, Target)
return isValid

def getattr_deep(obj, attr):
return reduce(getattr, attr.split('.'), obj)

Expand Down Expand Up @@ -14681,6 +14696,18 @@ def GetNewRecordTypes(self):
return [cRecord.value for cRecord in cRecords if cRecord]
return []

def GetNumEmptyGRUPs(self):
return _CGetModNumEmptyGRUPs(self._ModID)

def GetOrphanedFormIDs(self):
numFormIDs = _CGetModNumOrphans(self._ModID)
if(numFormIDs > 0):
cFormIDs = (c_ulong * numFormIDs)()
_CGetModOrphansFormIDs(self._ModID, byref(cFormIDs))
RecordID = _CGetRecordID(self._ModID, 0, 0)
return [FormID(_CGetLongIDName(RecordID, cFormID, 0), cFormID) for cFormID in cFormIDs if cFormID]
return []

def UpdateReferences(self, Old_NewFormIDs):
Old_NewFormIDs = FormID.FilterValidDict(Old_NewFormIDs, self, True, True)
length = len(Old_NewFormIDs)
Expand Down Expand Up @@ -15177,6 +15204,18 @@ def GetNewRecordTypes(self):
return [cRecord.value for cRecord in cRecords if cRecord]
return []

def GetNumEmptyGRUPs(self):
return _CGetModNumEmptyGRUPs(self._ModID)

def GetOrphanedFormIDs(self):
numFormIDs = _CGetModNumOrphans(self._ModID)
if(numFormIDs > 0):
cFormIDs = (c_ulong * numFormIDs)()
_CGetModOrphansFormIDs(self._ModID, byref(cFormIDs))
RecordID = _CGetRecordID(self._ModID, 0, 0)
return [FormID(_CGetLongIDName(RecordID, cFormID, 0), cFormID) for cFormID in cFormIDs if cFormID]
return []

def UpdateReferences(self, Old_NewFormIDs):
Old_NewFormIDs = FormID.FilterValidDict(Old_NewFormIDs, self, True, True)
length = len(Old_NewFormIDs)
Expand Down

0 comments on commit 56d4f00

Please sign in to comment.