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

Commit

Permalink
Fixed regression: skipped records are now skipped correctly when load…
Browse files Browse the repository at this point in the history
…ing a mod

Tested record undeletion
  fixed undeletion of editorID keyed records
  commented out debug statements
EditorID keyed records no longer get a new formID on copy
  keeping its existing formID, even if it means extra masters are added to the mod
  allows record undeletion if later loaded in CBash
  should also make TES4Edit users happy
Removed cruft
GMST records no longer print an error message when a deleted GMST is written
Made UpdateReferences faster
  pass all reference pairs at one time
  Use Record::GetRecordUpdatedReferences to tell if a record had its formIDs updated
  Use Collection::ClearReferenceLog to clear the map used by Record::GetRecordUpdatedReferences
  Removed Record::GetNumReferences
Updated jEdit macros
Changing both the editorID and formID at the same time no longer allows you to set the formID to one already in use
EditorID keyed records are now also keyed by their formID to prevent FormID keyed records from accidentally being given their formID
Collection unloading is now a smidge faster
CopyAsNew/Override now take an additional option UseWinningParents
  If true, and the record requires an auto-copy of its parents, it will use the winning version of those parents instead
Rewrote CleanModMasters
  Should be more reliable
  Should, on average, be faster (linear vs polynomial)
Added CleanMasters flag to Record::save
  It is enabled by default, so it no longer requires a separate function call later
Record histories and conflicts should be a bit faster to get
Saving a mod, but not closing the collection, no longer results in:
  1) Pseudo-random crashing when accessing that mod's records
  2) Creation of various '*.new.*' files
  3) Unknown error messages about the inability to rename files
  Once a file is saved, you cannot use ResetRecord to undo changes.
FormIDs, ActorValues, and MGEFCodes are much better handled by cint
  Python can now directly test if a value is a FormID, ActorValue, or MGEFCode with isinstance
  WARNING! This breaks backwards compatibility to some degree.
    Instead of passing ('Oblivion.esm', 0xFF), change it to FormID('Oblivion.esm', 0xFF)
REGN::edgeFalloff is no longer erroneously treated as a FormID by cint.py
Creating a condition and first setting any field other than ifunc no longer results in pointless warnings being printed by CBash
Record::flags1 no longer shows any internal CBash flags
ObTest.py updated to new FormID/ActorValue/MGEFCode requirements, cleaned flags, UpdateReferences changes
Added GetModIDByRecordID, GetCollectionIDByRecordID, and MakeShortFormID to API
All records now contain a pointer to their parent record (or Mod)
All mods now contain a pointer to their parent collection
cint.py is became much simpler.
  All records used to contain their CollectionID, ModID, and RecordID.
  Now they just require the RecordID.
  So the python records should construct faster, and use less memory.
  All the fields should also be accessible / settable a bit faster since the CBash functions require fewer parameters.
  Added GetParentMod() and GetParentCollection() to records
  Records no longer have FileName, ModName, GName properties.
    Use the new GetParentMod() function, and access the ModFile.FileName property there
Added Collection::UnloadAllCollections, DeleteAllCollections as static methods
Removed Collection::LookupRecord
TES4 description field is now limited to 512 characters (including NULL terminator)
  • Loading branch information
waruddar committed Sep 8, 2011
1 parent b60d33b commit 2a35494
Show file tree
Hide file tree
Showing 92 changed files with 6,967 additions and 5,398 deletions.
Binary file modified CBash.suo
Binary file not shown.
57 changes: 16 additions & 41 deletions CBash/Allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ GPL License and Copyright Notice ============================================
*/
#pragma once
#include "Common.h"
#include "GenericRecord.h"
//#include "GenericRecord.h"
#include <vector>
#include <malloc.h>

Expand Down Expand Up @@ -59,7 +59,7 @@ class RecordPoolAllocator
MakeFreeSet(free_set);
for(UINT32 p = 0;p < buffers.size(); p++)
{
UINT32 buffer_size = _msize(buffers[p]);
UINT32 buffer_size = (UINT32)_msize(buffers[p]);
//in case malloc returned more than the requested amount
buffer_size -= buffer_size % sizeof(T);
unsigned char *end_of_buffer = buffers[p] + buffer_size;
Expand Down Expand Up @@ -98,41 +98,43 @@ class RecordPoolAllocator
buffers.push_back(buffer);
}

Record *construct(unsigned char *recData)
Record *construct(unsigned char *recData, void *Parent, bool IsMod)
{
//See if any memory is free
if(freed_position)
{
unsigned char *next_position = *(unsigned char **)freed_position;
Record * curRecord = new (freed_position) T(recData);
curRecord->SetParent(Parent, IsMod);
freed_position = next_position;
return curRecord;
}
//Otherwise, allocate more memory
else
{
reserve(AllocUnit);
return construct(recData);
return construct(recData, Parent, IsMod);
}
throw std::bad_alloc();
return NULL;
}

Record *construct(Record *SourceRecord)
Record *construct(Record *SourceRecord, void *Parent, bool IsMod)
{
//See if any memory is free
if(freed_position)
{
unsigned char *next_position = *(unsigned char **)freed_position;
Record * curRecord = new (freed_position) T((T *)SourceRecord);
curRecord->SetParent(Parent, IsMod);
freed_position = next_position;
return curRecord;
}
//Otherwise, allocate more memory
else
{
reserve(AllocUnit);
return construct(SourceRecord);
return construct(SourceRecord, Parent, IsMod);
}
throw std::bad_alloc();
return NULL;
Expand Down Expand Up @@ -160,7 +162,7 @@ class RecordPoolAllocator
UINT32 size = 0;
for(UINT32 p = 0;p < buffers.size(); p++)
{
UINT32 buffer_size = _msize(buffers[p]);
UINT32 buffer_size = (UINT32)_msize(buffers[p]);
//in case malloc returned more than the requested amount
buffer_size -= buffer_size % sizeof(T);
size += buffer_size / sizeof(T);
Expand Down Expand Up @@ -212,7 +214,7 @@ class RecordPoolAllocator
MakeFreeSet(free_set);
for(UINT32 p = 0;p < buffers.size(); p++)
{
UINT32 buffer_size = _msize(buffers[p]);
UINT32 buffer_size = (UINT32)_msize(buffers[p]);
//in case malloc returned more than the requested amount
buffer_size -= buffer_size % sizeof(T);
unsigned char *end_of_buffer = buffers[p] + buffer_size;
Expand Down Expand Up @@ -264,7 +266,7 @@ class RecordPoolAllocator
Records.reserve(object_capacity() - free_set.size());
for(UINT32 p = 0;p < buffers.size(); p++)
{
UINT32 buffer_size = _msize(buffers[p]);
UINT32 buffer_size = (UINT32)_msize(buffers[p]);
//in case malloc returned more than the requested amount
buffer_size -= buffer_size % sizeof(T);
unsigned char *end_of_buffer = buffers[p] + buffer_size;
Expand All @@ -283,7 +285,7 @@ class RecordPoolAllocator
UINT32 pos = 0;
for(UINT32 p = 0;p < buffers.size(); p++)
{
UINT32 buffer_size = _msize(buffers[p]);
UINT32 buffer_size = (UINT32)_msize(buffers[p]);
//in case malloc returned more than the requested amount
buffer_size -= buffer_size % sizeof(T);
unsigned char *end_of_buffer = buffers[p] + buffer_size;
Expand All @@ -295,33 +297,6 @@ class RecordPoolAllocator
}
}

template<class U>
void Take_Ownership(U &rhs)
{
if(this != &rhs)
{
//purge_with_destructors();
if(freed_position != NULL && rhs.freed_position != NULL)
{
//Add the rhs frees to the end of the current frees
unsigned char *next_position = *(unsigned char **)freed_position;
while(*(unsigned char **)next_position != NULL)
{
next_position = *(unsigned char **)next_position;
};
*(unsigned char **)next_position = rhs.freed_position;
}
else if(rhs.freed_position != NULL)
freed_position = rhs.freed_position;

for(UINT32 x = 0; x < rhs.buffers.size(); ++x)
buffers.push_back(rhs.buffers[x]);
rhs.freed_position = NULL;
rhs.buffers.clear();
}
return;
}

void add_buffer(unsigned char *buffer)
{
buffers.push_back(buffer);
Expand Down Expand Up @@ -411,7 +386,7 @@ class RecordPoolAllocator
// UINT32 size = 0;
// for(UINT32 p = 0;p < buffers.size(); p++)
// {
// UINT32 buffer_size = _msize(buffers[p]);
// UINT32 buffer_size = (UINT32)_msize(buffers[p]);
// //in case malloc returned more than the requested amount
// buffer_size -= buffer_size % sizeof(T);
// size += buffer_size / sizeof(T);
Expand Down Expand Up @@ -448,7 +423,7 @@ class RecordPoolAllocator
// UINT32 size = 0;
// for(UINT32 p = 0;p < buffers.size(); p++)
// {
// UINT32 buffer_size = _msize(buffers[p]);
// UINT32 buffer_size = (UINT32)_msize(buffers[p]);
// //in case malloc returned more than the requested amount
// buffer_size -= buffer_size % sizeof(T);
// size += buffer_size;
Expand Down Expand Up @@ -588,7 +563,7 @@ class RecordPoolAllocator
// UINT32 size = 0;
// for(UINT32 p = 0;p < buffers.size(); p++)
// {
// UINT32 buffer_size = _msize(buffers[p]);
// UINT32 buffer_size = (UINT32)_msize(buffers[p]);
// //in case malloc returned more than the requested amount
// buffer_size -= buffer_size % sizeof(T);
// size += buffer_size / sizeof(T);
Expand Down Expand Up @@ -625,7 +600,7 @@ class RecordPoolAllocator
// UINT32 size = 0;
// for(UINT32 p = 0;p < buffers.size(); p++)
// {
// UINT32 buffer_size = _msize(buffers[p]);
// UINT32 buffer_size = (UINT32)_msize(buffers[p]);
// //in case malloc returned more than the requested amount
// buffer_size -= buffer_size % sizeof(T);
// size += buffer_size;
Expand Down
Loading

0 comments on commit 2a35494

Please sign in to comment.