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

Commit

Permalink
Basic support (reads, is exposed, not set/write tested)
Browse files Browse the repository at this point in the history
  FNV::WRLDRecord, FNV::LANDRecord
Copying a land, pgrd, world cell, etc to a record that already has that subrecord no longer occasionally clobbers the formID of the existing record.
Added support for swapped impacts to FNV::CELLRecord
Improved support for FNV::LVLIRecord
  LVLG chunk wasn't being read / exposed / saved
  Removed erroneous support for models
Improved support for FNV::CREARecord, FNV::NPC_Record
  Wasn't reading item extra data
Improved support for FNV::NAVMRecord
  A struct needed packing to fix alignment on read / write
Improved support for FNV::REFRRecord
  XMBR chunk (used twice in FalloutNV.esm) wasn't being read / written
Fixed land indexing, placeable fixing options for FalloutNewVegas and Oblivion
  If min loading (the default) is used, the records weren't read as they need to be for these options
Added RecordChanger record visitor for testing
  Marks all records as changed to force them being fully read, copied, saved
Fixed some issues with using copyattrs on FNV and Ob LANDRecords
  • Loading branch information
waruddar committed May 16, 2011
1 parent ee56316 commit eb33d9a
Show file tree
Hide file tree
Showing 39 changed files with 6,417 additions and 1,628 deletions.
Binary file modified CBash.suo
Binary file not shown.
70 changes: 70 additions & 0 deletions CBash/CBash.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,10 @@
RelativePath=".\FalloutNewVegas\Records\CELLRecord.cpp"
>
</File>
<File
RelativePath=".\FalloutNewVegas\Records\LANDRecord.cpp"
>
</File>
<File
RelativePath=".\FalloutNewVegas\Records\NAVMRecord.cpp"
>
Expand Down Expand Up @@ -1148,6 +1152,10 @@
RelativePath=".\FalloutNewVegas\Records\REFRRecord.cpp"
>
</File>
<File
RelativePath=".\FalloutNewVegas\Records\WRLDRecord.cpp"
>
</File>
</Filter>
<Filter
Name="Simple"
Expand Down Expand Up @@ -3061,6 +3069,37 @@
/>
</FileConfiguration>
</File>
<File
RelativePath=".\FalloutNewVegas\Records\API\LANDRecordAPI.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\$(InputName)1.obj"
XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\$(InputName)1.obj"
XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
/>
</FileConfiguration>
<FileConfiguration
Name="FullDebug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\$(InputName)1.obj"
XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\FalloutNewVegas\Records\API\LIGHRecordAPI.cpp"
>
Expand Down Expand Up @@ -3617,6 +3656,37 @@
/>
</FileConfiguration>
</File>
<File
RelativePath=".\FalloutNewVegas\Records\API\WRLDRecordAPI.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\$(InputName)1.obj"
XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\$(InputName)1.obj"
XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
/>
</FileConfiguration>
<FileConfiguration
Name="FullDebug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\$(InputName)1.obj"
XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\FalloutNewVegas\Records\API\WTHRRecordAPI.cpp"
>
Expand Down
13 changes: 10 additions & 3 deletions CBash/Collection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ Record * Collection::CopyRecord(ModFile *&curModFile, Record *&curRecord, ModFil
}

//See if an existing record was returned instead of the requested copy
if(RecordCopy->formID != curRecord->formID)
if(options.ExistingReturned)
return RecordCopy;

//Give the record a new formID if it isn't an override record
Expand Down Expand Up @@ -887,8 +887,15 @@ SINT32 Collection::DeleteRecord(ModFile *&curModFile, Record *&curRecord, Record
RecordDeleter deleter(curRecord, curModFile->Flags.IsExtendedConflicts ? ExtendedEditorID_ModFile_Record: EditorID_ModFile_Record, curModFile->Flags.IsExtendedConflicts ? ExtendedFormID_ModFile_Record: FormID_ModFile_Record);

UINT32 RecordType = curRecord->GetType();
UINT32 TopType = ParentRecord != NULL ? (ParentRecord->GetParentType() ? ParentRecord->GetParentType() : ParentRecord->GetType()) : RecordType;

UINT32 TopType = ParentRecord != NULL ?
(ParentRecord->GetParentType() ?
ParentRecord->GetParentType() :
ParentRecord->GetType()) :
RecordType;
//if(ParentRecord != NULL)
// DPRINT("Deleting %08X (%s) under %08X (%s) vs (%c%c%c%c) under (%c%c%c%c)", curRecord->formID, curRecord->GetStrType(), ParentRecord->formID, ParentRecord->GetStrType(), ((STRING)&RecordType)[0], ((STRING)&RecordType)[1], ((STRING)&RecordType)[2], ((STRING)&RecordType)[3], ((STRING)&TopType)[0], ((STRING)&TopType)[1], ((STRING)&TopType)[2], ((STRING)&TopType)[3]);
//else
// DPRINT("Deleting %08X (%s) vs (%c%c%c%c)", curRecord->formID, curRecord->GetStrType(), ((STRING)&RecordType)[0], ((STRING)&RecordType)[1], ((STRING)&RecordType)[2], ((STRING)&RecordType)[3]);
curModFile->VisitRecords(TopType, RecordType, deleter, true);
return deleter.GetCount();
}
Expand Down
6 changes: 4 additions & 2 deletions CBash/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,15 +651,17 @@ bool FormIDHandlerClass::IsValid(const unsigned char *_SrcBuf)
CreateRecordOptions::CreateRecordOptions():
SetAsOverride(false),
SetAsWorldCell(false),
CopyWorldCellStatus(false)
CopyWorldCellStatus(false),
ExistingReturned(false)
{
//
}

CreateRecordOptions::CreateRecordOptions(UINT32 nFlags):
SetAsOverride((nFlags & fSetAsOverride) != 0),
SetAsWorldCell((nFlags & fSetAsWorldCell) != 0),
CopyWorldCellStatus((nFlags & fCopyWorldCellStatus) != 0)
CopyWorldCellStatus((nFlags & fCopyWorldCellStatus) != 0),
ExistingReturned(false)
{
//
}
Expand Down
7 changes: 7 additions & 0 deletions CBash/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,9 @@ class CreateRecordOptions
bool SetAsWorldCell;
bool CopyWorldCellStatus;

//Internal use
bool ExistingReturned;

UINT32 GetFlags();
};

Expand Down Expand Up @@ -742,6 +745,10 @@ struct SimpleFloatSubRecord
if(isLoaded && value != defaultValue)
writer.record_write_subrecord(_Type, &value, sizeof(FLOAT32));
}
void ReqWrite(UINT32 _Type, FileWriter &writer)
{
writer.record_write_subrecord(_Type, &value, sizeof(FLOAT32));
}

SimpleFloatSubRecord<defaultValue>& operator = (const SimpleFloatSubRecord<defaultValue> &rhs)
{
Expand Down
130 changes: 70 additions & 60 deletions CBash/FalloutNewVegas/FNVFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,10 @@ SINT32 FNVFile::Load(RecordOp &indexer, std::vector<FormIDResolver *> &Expanders
break;
//case eIgWRLD: //Same as normal
case REV32(WRLD):
//reader.read(&WRLD.stamp, 4);
//reader.read(&WRLD.unknown, 4);
//WRLD.Skim(reader, GRUPSize, processor, indexer);
//break;
reader.read(&WRLD.stamp, 4);
reader.read(&WRLD.unknown, 4);
WRLD.Skim(reader, GRUPSize, processor, indexer, fullReader);
break;
case eIgDIAL:
case REV32(DIAL):
//reader.read(&DIAL.stamp, 4);
Expand Down Expand Up @@ -845,6 +845,12 @@ SINT32 FNVFile::Load(RecordOp &indexer, std::vector<FormIDResolver *> &Expanders
break;
}
};
//Testing snippet
//if(Flags.IsFullLoad)
// {
// RecordChanger changer(FormIDHandler, Expanders);
// VisitAllRecords(changer);
// }
return 1;
}

Expand Down Expand Up @@ -976,7 +982,7 @@ UINT32 FNVFile::GetNumRecords(const UINT32 &RecordType)
break;
///////////////////////////////////////////////
case REV32(WRLD):
//return (UINT32)WRLD.Records.size();
return (UINT32)WRLD.Records.size();
case REV32(DIAL):
//return (UINT32)DIAL.Records.size();
case REV32(QUST):
Expand Down Expand Up @@ -1311,51 +1317,52 @@ Record * FNVFile::CreateRecord(const UINT32 &RecordType, STRING const &RecordEdi
newRecord = NAVI.Records.back();
break;
case REV32(CELL):
//if(ParentRecord == NULL)
// {
if(ParentRecord == NULL)
{
CELL.Records.push_back(new FNV::CELLRecord((FNV::CELLRecord *)SourceRecord));
newRecord = CELL.Records.back();

((FNV::CELLRecord *)newRecord)->IsInterior(true);
// }
//else
// {
// if(ParentRecord->GetType() != REV32(WRLD))
// {
// printf("FNVFile::CreateRecord: Error - Unable to create CELL record in mod \"%s\". Parent record type (%s) is invalid, only WRLD records can be CELL parents.\n", reader.getModName(), ParentRecord->GetStrType());
// return NULL;
// }

// if(options.CopyWorldCellStatus)
// {
// if(((FNV::WRLDRecord *)((FNV::CELLRecord *)SourceRecord)->Parent)->CELL->formID == SourceRecord->formID)
// options.SetAsWorldCell = true;
// else
// options.SetAsWorldCell = false;
// }

// if(options.SetAsWorldCell)
// {
// //If a world cell already exists, return it instead of making a new one
// if(((FNV::WRLDRecord *)ParentRecord)->CELL != NULL)
// return ((FNV::WRLDRecord *)ParentRecord)->CELL;

// ((FNV::WRLDRecord *)ParentRecord)->CELL = new FNV::CELLRecord((FNV::CELLRecord *)SourceRecord);
// newRecord = ((FNV::WRLDRecord *)ParentRecord)->CELL;
// }
// else
// {
// ((FNV::WRLDRecord *)ParentRecord)->CELLS.push_back(new FNV::CELLRecord((FNV::CELLRecord *)SourceRecord));
// newRecord = ((FNV::WRLDRecord *)ParentRecord)->CELLS.back();
// }

// ((FNV::CELLRecord *)newRecord)->IsInterior(false);
// ((FNV::CELLRecord *)newRecord)->Parent = ParentRecord;
// }
}
else
{
if(ParentRecord->GetType() != REV32(WRLD))
{
printf("FNVFile::CreateRecord: Error - Unable to create CELL record in mod \"%s\". Parent record type (%s) is invalid, only WRLD records can be CELL parents.\n", reader.getModName(), ParentRecord->GetStrType());
return NULL;
}

if(options.CopyWorldCellStatus)
{
if(((FNV::WRLDRecord *)((FNV::CELLRecord *)SourceRecord)->Parent)->CELL->formID == SourceRecord->formID)
options.SetAsWorldCell = true;
else
options.SetAsWorldCell = false;
}

if(options.SetAsWorldCell)
{
//If a world cell already exists, return it instead of making a new one
if(((FNV::WRLDRecord *)ParentRecord)->CELL != NULL)
{
options.ExistingReturned = true;
return ((FNV::WRLDRecord *)ParentRecord)->CELL;
}
newRecord = ((FNV::WRLDRecord *)ParentRecord)->CELL = new FNV::CELLRecord((FNV::CELLRecord *)SourceRecord);
}
else
{
((FNV::WRLDRecord *)ParentRecord)->CELLS.push_back(new FNV::CELLRecord((FNV::CELLRecord *)SourceRecord));
newRecord = ((FNV::WRLDRecord *)ParentRecord)->CELLS.back();
}

((FNV::CELLRecord *)newRecord)->IsInterior(false);
((FNV::CELLRecord *)newRecord)->Parent = ParentRecord;
}
break;
case REV32(WRLD):
//WRLD.Records.push_back(new FNV::WRLDRecord((FNV::WRLDRecord *)SourceRecord));
//newRecord = WRLD.Records.back();
WRLD.Records.push_back(new FNV::WRLDRecord((FNV::WRLDRecord *)SourceRecord));
newRecord = WRLD.Records.back();
break;
case REV32(DIAL):
//DIAL.Records.push_back(new FNV::DIALRecord((FNV::DIALRecord *)SourceRecord));
Expand Down Expand Up @@ -1462,19 +1469,22 @@ Record * FNVFile::CreateRecord(const UINT32 &RecordType, STRING const &RecordEdi
newRecord = ((FNV::CELLRecord *)ParentRecord)->NAVM.back();
break;
case REV32(LAND):
//if(ParentRecord == NULL || ParentRecord->GetType() != REV32(CELL))
// {
// printf("FNVFile::CreateRecord: Error - Unable to create LAND record in mod \"%s\". Parent record type (%s) is invalid, only CELL records can be LAND parents.\n", reader.getModName(), ParentRecord->GetStrType());
// return NULL;
// }
if(ParentRecord == NULL || ParentRecord->GetType() != REV32(CELL))
{
printf("FNVFile::CreateRecord: Error - Unable to create LAND record in mod \"%s\". Parent record type (%s) is invalid, only CELL records can be LAND parents.\n", reader.getModName(), ParentRecord->GetStrType());
return NULL;
}

////If a cell land already exists, return it instead of making a new one
//if(((CELLRecord *)ParentRecord)->LAND != NULL)
// return ((CELLRecord *)ParentRecord)->LAND;
//If a cell land already exists, return it instead of making a new one
if(((FNV::CELLRecord *)ParentRecord)->LAND != NULL)
{
options.ExistingReturned = true;
return ((FNV::CELLRecord *)ParentRecord)->LAND;
}

//((CELLRecord *)ParentRecord)->LAND = new LANDRecord((LANDRecord *)SourceRecord);
//newRecord = ((CELLRecord *)ParentRecord)->LAND;
//break;
((FNV::CELLRecord *)ParentRecord)->LAND = new FNV::LANDRecord((FNV::LANDRecord *)SourceRecord);
newRecord = ((FNV::CELLRecord *)ParentRecord)->LAND;
break;
case REV32(QUST):
//QUST.Records.push_back(new FNV::QUSTRecord((FNV::QUSTRecord *)SourceRecord));
//newRecord = QUST.Records.back();
Expand Down Expand Up @@ -1746,7 +1756,7 @@ SINT32 FNVFile::CleanMasters(std::vector<FormIDResolver *> &Expanders)
if(REGN.VisitRecords(NULL, checker, false)) continue;
if(NAVI.VisitRecords(NULL, checker, false)) continue;
if(CELL.VisitRecords(NULL, checker, true)) continue;
//if(WRLD.VisitRecords(NULL, checker, true)) continue;
if(WRLD.VisitRecords(NULL, checker, true)) continue;
//if(DIAL.VisitRecords(NULL, checker, true)) continue;
//if(QUST.VisitRecords(NULL, checker, false)) continue;
//if(IDLE.VisitRecords(NULL, checker, false)) continue;
Expand Down Expand Up @@ -1884,7 +1894,7 @@ SINT32 FNVFile::Save(STRING const &SaveName, std::vector<FormIDResolver *> &Expa
formCount += REGN.WriteGRUP(REV32(REGN), writer, Expanders, expander, collapser, bMastersChanged, CloseMod);
formCount += NAVI.WriteGRUP(REV32(NAVI), writer, Expanders, expander, collapser, bMastersChanged, CloseMod);
formCount += CELL.WriteGRUP(writer, Expanders, expander, collapser, bMastersChanged, CloseMod);
//formCount += WRLD.WriteGRUP(REV32(WRLD), writer, Expanders, expander, collapser, bMastersChanged, CloseMod);
formCount += WRLD.WriteGRUP(writer, FormIDHandler, Expanders, expander, collapser, bMastersChanged, CloseMod);
//formCount += DIAL.WriteGRUP(REV32(DIAL), writer, Expanders, expander, collapser, bMastersChanged, CloseMod);
//formCount += QUST.WriteGRUP(REV32(QUST), writer, Expanders, expander, collapser, bMastersChanged, CloseMod);
//formCount += IDLE.WriteGRUP(REV32(IDLE), writer, Expanders, expander, collapser, bMastersChanged, CloseMod);
Expand Down Expand Up @@ -2007,7 +2017,7 @@ void FNVFile::VisitAllRecords(RecordOp &op)
REGN.VisitRecords(NULL, op, true);
NAVI.VisitRecords(NULL, op, true);
CELL.VisitRecords(NULL, op, true);
//WRLD.VisitRecords(NULL, op, true);
WRLD.VisitRecords(NULL, op, true);
//DIAL.VisitRecords(NULL, op, true);
//QUST.VisitRecords(NULL, op, true);
//IDLE.VisitRecords(NULL, op, true);
Expand Down Expand Up @@ -2234,8 +2244,8 @@ void FNVFile::VisitRecords(const UINT32 &TopRecordType, const UINT32 &RecordType
CELL.VisitRecords(RecordType, op, DeepVisit);
break;
case REV32(WRLD):
//WRLD.VisitRecords(RecordType, op, DeepVisit);
//break;
WRLD.VisitRecords(RecordType, op, DeepVisit);
break;
case REV32(DIAL):
//DIAL.VisitRecords(RecordType, op, DeepVisit);
//break;
Expand Down
4 changes: 2 additions & 2 deletions CBash/FalloutNewVegas/FNVFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ GPL License and Copyright Notice ============================================
#include "Records/REGNRecord.h"
#include "Records/NAVIRecord.h"
#include "Records/CELLRecord.h"
//#include "Records/WRLDRecord.h"
#include "Records/WRLDRecord.h"
//#include "Records/DIALRecord.h"
//#include "Records/QUSTRecord.h"
//#include "Records/IDLERecord.h"
Expand Down Expand Up @@ -182,7 +182,7 @@ class FNVFile : public ModFile
FNVGRUPRecords<FNV::REGNRecord> REGN;
FNVGRUPRecords<FNV::NAVIRecord> NAVI;
FNVGRUPRecords<FNV::CELLRecord> CELL;
//FNVGRUPRecords<FNV::WRLDRecord> WRLD;
FNVGRUPRecords<FNV::WRLDRecord> WRLD;
//FNVGRUPRecords<FNV::DIALRecord> DIAL;
//FNVGRUPRecords<FNV::QUSTRecord> QUST;
//FNVGRUPRecords<FNV::IDLERecord> IDLE;
Expand Down
Loading

0 comments on commit eb33d9a

Please sign in to comment.