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

Commit

Permalink
Setting Record::IsCompressed flag internally no longer requires speci…
Browse files Browse the repository at this point in the history
…al treatment

  Previously, it required code to prevent it from being out of sync with later reads
    Otherwise, CBash could attempt to decompress a non-compressed record or fail to decompress a compressed record
  Now reading explicitly checks the original flags, and Record::IsCompressed is only used on writing
Records may now be undeleted!
  Simply toggle the Record::IsDeleted flag
  Deleted records are automatically filled in with the last known good record data from that mod's history when read
Fixed potential future bug in writing records if a record's flags was changed internally and the record was not marked as changed
  These conditions were never satisified in the previous code, but might in the future due to the change in IsCompressed and IsDeleted. 
  Now it checks to see if the flags have changed, and if so, fully writes the record rather than copying it from the original buffer
Simplified Collection::NextFreeExpandedFormID
Added virtual Record::SetEditorIDKey to match GetEditorIDKey
Simplified FileReader
FileReader::peek_around now takes an optional position arg (defaults to current pos)
FormIDHandlerClass::NextExpandedFormID should work with objectID 0x00FFFFFF now
Documented FormIDHandlerClass in depth (likely too well...)
Support in progress for FNV::BPDT, and FNV::PERK records
FNVRecordProcessor no longer inherits from RecordProcessor
Simplified GRUP record processing
  Moved several error checks out of the main loop, so it should load somewhat faster
Added and exported RedirectMessages(SINT32 (*_LoggingCallback)(const STRING)) function
  CBash now prints its error messages to Python's stdout by default whenever cint is used
  Removed remnants of old logging experiment
cint now checks the error return codes of several functions
  CBashError is raised if an error is returned
  Checked functions include CreateCollection, DeleteCollection, LoadCollection, etc
  High use functions like GetField, GetFieldAttribute, SetField, etc are NOT checked to avoid performance hits
Variety of minor type mismatches fixed
Aborted attempt to replace std::map indexing
  Custom indexing used ~2x as much memory (~55 bytes per record vs ~23 bytes per record)
  Left much of it in place, commented out, for future work
Added debugging macro CBASH_CHUNK_DEBUG to all records
  • Loading branch information
waruddar committed May 31, 2011
1 parent 11fea48 commit 210f9ef
Show file tree
Hide file tree
Showing 174 changed files with 3,950 additions and 3,289 deletions.
Binary file modified CBash.suo
Binary file not shown.
618 changes: 222 additions & 396 deletions CBash/CBash.cpp

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions CBash/CBash.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ EXPORT_FUNC UINT32 GetVersionRevision();
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
//Logging action functions
#ifdef CBASH_USE_LOGGING
EXPORT_FUNC SINT32 SetLogging(Collection *CollectionID, SINT32 (*_LoggingCallback)(const STRING), UINT32 LoggingLevel, UINT32 LoggingFlags);
#endif
EXPORT_FUNC void RedirectMessages(SINT32 (*_LoggingCallback)(const STRING));
EXPORT_FUNC void AllowRaising(void (*_RaiseCallback)());
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
//Collection action functions
Expand Down Expand Up @@ -71,7 +70,7 @@ EXPORT_FUNC STRING GetLongIDName(Collection *CollectionID, ModFile *ModID, const
//EXPORT_FUNC SINT32 GetShortIDIndex(Collection *CollectionID, const SINT32 ModID, STRING const ModName);
EXPORT_FUNC UINT32 IsModEmpty(Collection *CollectionID, ModFile *ModID);
EXPORT_FUNC SINT32 GetModNumTypes(Collection *CollectionID, ModFile *ModID);
EXPORT_FUNC void GetModTypes(Collection *CollectionID, ModFile *ModID, UINT32ARRAY RecordTypes);
EXPORT_FUNC SINT32 GetModTypes(Collection *CollectionID, ModFile *ModID, UINT32ARRAY RecordTypes);
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
//Record action functions
Expand Down
376 changes: 300 additions & 76 deletions CBash/Collection.cpp

Large diffs are not rendered by default.

62 changes: 61 additions & 1 deletion CBash/Collection.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,31 @@ GPL License and Copyright Notice ============================================
#include <map>
#include "Visitors.h"

//class SortedRecords
// {
// public:
// UINT32 size;
// ModFile ** mods;
// Record ** records;
//
// SortedRecords();
// ~SortedRecords();
//
// void push_back(ModFile *&mod, Record *&record);
// void erase(UINT32 &index);
// };

//struct IndexedRecords
// {
// SortedRecords loadordered, extended;
// };

//typedef std::map<UINT32, SortedRecords> FormID_Map;
//typedef std::map<STRING, SortedRecords, sameStr> EditorID_Map;
//
//typedef FormID_Map::iterator FormID_Iterator;
//typedef EditorID_Map::iterator EditorID_Iterator;

class Collection
{
private:
Expand All @@ -42,6 +67,7 @@ class Collection

EditorID_Map EditorID_ModFile_Record;
FormID_Map FormID_ModFile_Record;

EditorID_Map ExtendedEditorID_ModFile_Record;
FormID_Map ExtendedFormID_ModFile_Record;

Expand Down Expand Up @@ -69,4 +95,38 @@ class Collection
SINT32 DeleteRecord(ModFile *&curModFile, Record *&curRecord, Record *&ParentRecord);

SINT32 SetRecordIDs(ModFile *&curModFile, Record *&RecordID, FORMID FormID, STRING const &EditorID);
};
};

//class RecordDeleter : public RecordOp
// {
// private:
// EditorID_Map &EditorID_ModFile_Record;
// FormID_Map &FormID_ModFile_Record;
// Record *RecordToDelete;
// //bool IsExtended;
//
// public:
// RecordDeleter(Record *_RecordToDelete, /*bool IsExtended,*/ EditorID_Map &_EditorID_ModFile_Record, FormID_Map &_FormID_ModFile_Record);
// ~RecordDeleter();
//
// bool Accept(Record *&curRecord);
// };
//
//class RecordIndexer : public RecordOp
// {
// private:
// EditorID_Map &EditorID_ModFile_Record;
// FormID_Map &FormID_ModFile_Record;
// ModFile *curModFile;
// //bool IsExtended;
//
// public:
// RecordIndexer(ModFile *_curModFile, EditorID_Map &_EditorID_Map, FormID_Map &_FormID_Map);
// RecordIndexer(EditorID_Map &_EditorID_Map, FormID_Map &_FormID_Map);
// ~RecordIndexer();
//
// bool Accept(Record *&curRecord);
//
// void SetModFile(ModFile *_curModFile);
// //void SetIsExtended(bool UseExtended);
// };
Loading

0 comments on commit 210f9ef

Please sign in to comment.