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::ACHRRecord, FNV::ACRERecord, FNV::REFRRecord
Added htoca.py
  auto-writes the cpp and api files for a given record header
  not perfect, but does ~95% of the work
  • Loading branch information
waruddar committed May 15, 2011
1 parent 2839463 commit 38ee86b
Show file tree
Hide file tree
Showing 33 changed files with 8,838 additions and 3,949 deletions.
Binary file modified CBash.suo
Binary file not shown.
105 changes: 105 additions & 0 deletions CBash/CBash.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -1100,10 +1100,22 @@
<Filter
Name="Complex"
>
<File
RelativePath=".\FalloutNewVegas\Records\ACHRRecord.cpp"
>
</File>
<File
RelativePath=".\FalloutNewVegas\Records\ACRERecord.cpp"
>
</File>
<File
RelativePath=".\FalloutNewVegas\Records\CELLRecord.cpp"
>
</File>
<File
RelativePath=".\FalloutNewVegas\Records\REFRRecord.cpp"
>
</File>
</Filter>
<Filter
Name="Simple"
Expand Down Expand Up @@ -2288,6 +2300,68 @@
<Filter
Name="API"
>
<File
RelativePath=".\FalloutNewVegas\Records\API\ACHRRecordAPI.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\ACRERecordAPI.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\ACTIRecordAPI.cpp"
>
Expand Down Expand Up @@ -3231,6 +3305,37 @@
/>
</FileConfiguration>
</File>
<File
RelativePath=".\FalloutNewVegas\Records\API\REFRRecordAPI.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\REGNRecordAPI.cpp"
>
Expand Down
49 changes: 29 additions & 20 deletions CBash/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -957,10 +957,12 @@ struct OptSimpleSubRecord
{
//
}

~OptSimpleSubRecord()
{
Unload();
//
}

UINT32 GetSize() const
{
return sizeof(T);
Expand All @@ -970,10 +972,12 @@ struct OptSimpleSubRecord
{
return (value != defaultValue);
}

void Load()
{
//
}

void Unload()
{
value = defaultValue;
Expand All @@ -986,37 +990,40 @@ struct OptSimpleSubRecord
curPos += subSize;
return false;
}

if(subSize > sizeof(T))
{
#ifdef CBASH_CHUNK_WARN
printf("OptSimpleSubRecord: 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 + curPos)[-6], (buffer + curPos)[-5], (buffer + curPos)[-4], (buffer + curPos)[-3],
subSize, sizeof(T));
CBASH_CHUNK_DEBUG
#endif
#ifdef CBASH_CHUNK_WARN
printf("OptSimpleSubRecord: 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 + curPos)[-6], (buffer + curPos)[-5], (buffer + curPos)[-4], (buffer + curPos)[-3],
subSize, sizeof(T));
CBASH_CHUNK_DEBUG
#endif
memcpy(&value, buffer + curPos, sizeof(T));
}
#ifdef CBASH_CHUNK_LCHECK
else if(subSize < sizeof(T))
#ifdef CBASH_CHUNK_LCHECK
else if(subSize < sizeof(T))
{
#ifdef CBASH_CHUNK_WARN
printf("OptSimpleSubRecord: 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 + curPos)[-6], (buffer + curPos)[-5], (buffer + curPos)[-4], (buffer + curPos)[-3],
subSize, sizeof(T));
CBASH_CHUNK_DEBUG
#endif
#ifdef CBASH_CHUNK_WARN
printf("OptSimpleSubRecord: 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 + curPos)[-6], (buffer + curPos)[-5], (buffer + curPos)[-4], (buffer + curPos)[-3],
subSize, sizeof(T));
CBASH_CHUNK_DEBUG
#endif
memcpy(&value, buffer + curPos, subSize);
}
#endif
#endif
else
memcpy(&value, buffer + curPos, subSize);

curPos += subSize;
return true;
}

void Write(UINT32 _Type, FileWriter &writer)
{
if(value != defaultValue)
Expand All @@ -1029,10 +1036,12 @@ struct OptSimpleSubRecord
value = rhs.value;
return *this;
}

bool operator ==(const OptSimpleSubRecord<T, defaultValue> &other) const
{
return value == other.value;
}

bool operator !=(const OptSimpleSubRecord<T, defaultValue> &other) const
{
return value != other.value;
Expand Down
98 changes: 98 additions & 0 deletions CBash/FalloutNewVegas/FNVFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,20 @@ UINT32 FNVFile::GetNumRecords(const UINT32 &RecordType)
return (UINT32)NAVI.Records.size();
case REV32(CELL):
return (UINT32)CELL.Records.size();
///////////////////////////////////////////////
//SubRecords are counted via GetFieldAttribute API function
//Fallthroughs are intentional
case REV32(INFO):
case REV32(ACHR):
case REV32(ACRE):
case REV32(REFR):
case REV32(PGRE):
case REV32(PMIS):
case REV32(NAVM):
case REV32(LAND):
printf("FNVFile::GetNumRecords: Warning - Unable to count records (%c%c%c%c) in mod \"%s\". SubRecords are counted via GetFieldAttribute API function.\n", ((STRING)&RecordType)[0], ((STRING)&RecordType)[1], ((STRING)&RecordType)[2], ((STRING)&RecordType)[3], reader.getModName());
break;
///////////////////////////////////////////////
case REV32(WRLD):
//return (UINT32)WRLD.Records.size();
case REV32(DIAL):
Expand Down Expand Up @@ -1344,6 +1358,90 @@ Record * FNVFile::CreateRecord(const UINT32 &RecordType, STRING const &RecordEdi
//DIAL.Records.push_back(new FNV::DIALRecord((FNV::DIALRecord *)SourceRecord));
//newRecord = DIAL.Records.back();
//break;
case REV32(INFO):
//if(ParentRecord == NULL || ParentRecord->GetType() != REV32(DIAL))
// {
// printf("FNVFile::CreateRecord: Error - Unable to create INFO record in mod \"%s\". Parent record type (%s) is invalid, only DIAL records can be INFO parents.\n", reader.getModName(), ParentRecord->GetStrType());
// return NULL;
// }

//((DIALRecord *)ParentRecord)->INFO.push_back(new INFORecord((INFORecord *)SourceRecord));
//newRecord = ((DIALRecord *)ParentRecord)->INFO.back();
//break;
case REV32(ACHR):
if(ParentRecord == NULL || ParentRecord->GetType() != REV32(CELL))
{
printf("FNVFile::CreateRecord: Error - Unable to create ACHR record in mod \"%s\". Parent record type (%s) is invalid, only CELL records can be ACHR parents.\n", reader.getModName(), ParentRecord->GetStrType());
return NULL;
}

((FNV::CELLRecord *)ParentRecord)->ACHR.push_back(new FNV::ACHRRecord((FNV::ACHRRecord *)SourceRecord));
newRecord = ((FNV::CELLRecord *)ParentRecord)->ACHR.back();
break;
case REV32(ACRE):
if(ParentRecord == NULL || ParentRecord->GetType() != REV32(CELL))
{
printf("FNVFile::CreateRecord: Error - Unable to create ACRE record in mod \"%s\". Parent record type (%s) is invalid, only CELL records can be ACRE parents.\n", reader.getModName(), ParentRecord->GetStrType());
return NULL;
}

((FNV::CELLRecord *)ParentRecord)->ACRE.push_back(new FNV::ACRERecord((FNV::ACRERecord *)SourceRecord));
newRecord = ((FNV::CELLRecord *)ParentRecord)->ACRE.back();
break;
case REV32(REFR):
if(ParentRecord == NULL || ParentRecord->GetType() != REV32(CELL))
{
printf("FNVFile::CreateRecord: Error - Unable to create REFR record in mod \"%s\". Parent record type (%s) is invalid, only CELL records can be REFR parents.\n", reader.getModName(), ParentRecord->GetStrType());
return NULL;
}

((FNV::CELLRecord *)ParentRecord)->REFR.push_back(new FNV::REFRRecord((FNV::REFRRecord *)SourceRecord));
newRecord = ((FNV::CELLRecord *)ParentRecord)->REFR.back();
break;
case REV32(PGRE):
//if(ParentRecord == NULL || ParentRecord->GetType() != REV32(CELL))
// {
// printf("FNVFile::CreateRecord: Error - Unable to create REFR record in mod \"%s\". Parent record type (%s) is invalid, only CELL records can be REFR parents.\n", reader.getModName(), ParentRecord->GetStrType());
// return NULL;
// }

//((CELLRecord *)ParentRecord)->REFR.push_back(new REFRRecord((REFRRecord *)SourceRecord));
//newRecord = ((CELLRecord *)ParentRecord)->REFR.back();
//break;
case REV32(PMIS):
//if(ParentRecord == NULL || ParentRecord->GetType() != REV32(CELL))
// {
// printf("FNVFile::CreateRecord: Error - Unable to create REFR record in mod \"%s\". Parent record type (%s) is invalid, only CELL records can be REFR parents.\n", reader.getModName(), ParentRecord->GetStrType());
// return NULL;
// }

//((CELLRecord *)ParentRecord)->REFR.push_back(new REFRRecord((REFRRecord *)SourceRecord));
//newRecord = ((CELLRecord *)ParentRecord)->REFR.back();
//break;
case REV32(NAVM):
//if(ParentRecord == NULL || ParentRecord->GetType() != REV32(CELL))
// {
// printf("FNVFile::CreateRecord: Error - Unable to create REFR record in mod \"%s\". Parent record type (%s) is invalid, only CELL records can be REFR parents.\n", reader.getModName(), ParentRecord->GetStrType());
// return NULL;
// }

//((CELLRecord *)ParentRecord)->REFR.push_back(new REFRRecord((REFRRecord *)SourceRecord));
//newRecord = ((CELLRecord *)ParentRecord)->REFR.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 a cell land already exists, return it instead of making a new one
//if(((CELLRecord *)ParentRecord)->LAND != NULL)
// return ((CELLRecord *)ParentRecord)->LAND;

//((CELLRecord *)ParentRecord)->LAND = new LANDRecord((LANDRecord *)SourceRecord);
//newRecord = ((CELLRecord *)ParentRecord)->LAND;
//break;
case REV32(QUST):
//QUST.Records.push_back(new FNV::QUSTRecord((FNV::QUSTRecord *)SourceRecord));
//newRecord = QUST.Records.back();
Expand Down
Loading

0 comments on commit 38ee86b

Please sign in to comment.