fix x64 compile warning. delete CKBOOL. fix terminal color error
This commit is contained in:
parent
763c6e84f9
commit
2373dbee5b
|
@ -24,7 +24,7 @@ namespace LibCmo::CK2 {
|
||||||
CK_ID decided_id;
|
CK_ID decided_id;
|
||||||
if (this->m_ReturnedObjectIds.empty()) {
|
if (this->m_ReturnedObjectIds.empty()) {
|
||||||
// create new CK_ID.
|
// create new CK_ID.
|
||||||
decided_id = m_ObjectsList.size();
|
decided_id = static_cast<CK_ID>(m_ObjectsList.size());
|
||||||
m_ObjectsList.resize(decided_id + 1);
|
m_ObjectsList.resize(decided_id + 1);
|
||||||
} else {
|
} else {
|
||||||
// use returned CK_ID.
|
// use returned CK_ID.
|
||||||
|
|
|
@ -34,7 +34,7 @@ namespace LibCmo::CK2 {
|
||||||
//using CKClassDependenciesCountFct = std::function<CKINT(CKINT)>;
|
//using CKClassDependenciesCountFct = std::function<CKINT(CKINT)>;
|
||||||
|
|
||||||
struct CKClassDesc {
|
struct CKClassDesc {
|
||||||
CKBOOL Done;
|
bool Done;
|
||||||
// Initialized upon class registration
|
// Initialized upon class registration
|
||||||
CK_CLASSID Self;
|
CK_CLASSID Self;
|
||||||
CK_CLASSID Parent; // Class Identifier of parent class
|
CK_CLASSID Parent; // Class Identifier of parent class
|
||||||
|
@ -62,7 +62,7 @@ namespace LibCmo::CK2 {
|
||||||
//XContainer::XSArray<CK_CLASSID> ToNotify; // List of ClassID to notify when an object of this class is deleted (inverse of ToBeNotify)
|
//XContainer::XSArray<CK_CLASSID> ToNotify; // List of ClassID to notify when an object of this class is deleted (inverse of ToBeNotify)
|
||||||
|
|
||||||
CKClassDesc() :
|
CKClassDesc() :
|
||||||
Done(CKFALSE),
|
Done(false),
|
||||||
Self(CK_CLASSID::CKCID_OBJECT), Parent(CK_CLASSID::CKCID_OBJECT),
|
Self(CK_CLASSID::CKCID_OBJECT), Parent(CK_CLASSID::CKCID_OBJECT),
|
||||||
CreationFct(nullptr), ReleaseFct(nullptr), NameFct(nullptr),
|
CreationFct(nullptr), ReleaseFct(nullptr), NameFct(nullptr),
|
||||||
DerivationLevel(0),
|
DerivationLevel(0),
|
||||||
|
|
|
@ -23,8 +23,8 @@ namespace LibCmo::CK2 {
|
||||||
* @param rsize The size of buffer.
|
* @param rsize The size of buffer.
|
||||||
* @param need_manual_free True if provided buffer need freed by CKBufferParser automatically.
|
* @param need_manual_free True if provided buffer need freed by CKBufferParser automatically.
|
||||||
*/
|
*/
|
||||||
CKBufferParser(void* ptr, size_t rsize, bool need_manual_free) :
|
CKBufferParser(const void* ptr, size_t rsize, bool need_manual_free) :
|
||||||
m_MemBegin(static_cast<char*>(ptr)),
|
m_MemBegin(const_cast<char*>(static_cast<const char*>(ptr))),
|
||||||
m_MemPos(0u), m_MemSize(rsize),
|
m_MemPos(0u), m_MemSize(rsize),
|
||||||
m_NeedManualFree(need_manual_free)
|
m_NeedManualFree(need_manual_free)
|
||||||
{}
|
{}
|
||||||
|
@ -53,8 +53,8 @@ namespace LibCmo::CK2 {
|
||||||
this->m_MemPos += data_size;
|
this->m_MemPos += data_size;
|
||||||
}
|
}
|
||||||
void* GetBase(void) { return this->m_MemBegin; }
|
void* GetBase(void) { return this->m_MemBegin; }
|
||||||
size_t GetSize(void) { return this->m_MemSize; }
|
CKDWORD GetSize(void) { return static_cast<CKDWORD>(this->m_MemSize); }
|
||||||
size_t GetCursor(void) { return this->m_MemPos; }
|
CKDWORD GetCursor(void) { return static_cast<CKDWORD>(this->m_MemPos); }
|
||||||
void MoveCursor(ptrdiff_t off) { this->m_MemPos += off; }
|
void MoveCursor(ptrdiff_t off) { this->m_MemPos += off; }
|
||||||
void SetCursor(size_t off) { this->m_MemPos = off; }
|
void SetCursor(size_t off) { this->m_MemPos = off; }
|
||||||
};
|
};
|
||||||
|
@ -166,7 +166,7 @@ namespace LibCmo::CK2 {
|
||||||
|
|
||||||
const CKFileObject* GetFileObjectByIndex(size_t index);
|
const CKFileObject* GetFileObjectByIndex(size_t index);
|
||||||
protected:
|
protected:
|
||||||
CKBOOL m_IsReader;
|
bool m_IsReader;
|
||||||
CKFileReader* m_Reader;
|
CKFileReader* m_Reader;
|
||||||
CKFileWriter* m_Writer;
|
CKFileWriter* m_Writer;
|
||||||
CKContext* m_Ctx;
|
CKContext* m_Ctx;
|
||||||
|
@ -192,7 +192,7 @@ namespace LibCmo::CK2 {
|
||||||
const CKFileInfo GetFileInfo();
|
const CKFileInfo GetFileInfo();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CKBOOL m_Done;
|
bool m_Done;
|
||||||
CKINT m_SaveIDMax; /**< Maximum CK_ID found when saving or loading objects */
|
CKINT m_SaveIDMax; /**< Maximum CK_ID found when saving or loading objects */
|
||||||
XContainer::XArray<CKFileObject> m_FileObjects; /**< List of objects being saved / loaded */
|
XContainer::XArray<CKFileObject> m_FileObjects; /**< List of objects being saved / loaded */
|
||||||
XContainer::XArray<CKFileManagerData> m_ManagersData; /**< Manager Data loaded */
|
XContainer::XArray<CKFileManagerData> m_ManagersData; /**< Manager Data loaded */
|
||||||
|
@ -217,15 +217,15 @@ namespace LibCmo::CK2 {
|
||||||
LIBCMO_DISABLE_COPY_MOVE(CKFileWriter);
|
LIBCMO_DISABLE_COPY_MOVE(CKFileWriter);
|
||||||
|
|
||||||
// ========== Saving Preparing ==========
|
// ========== Saving Preparing ==========
|
||||||
CKBOOL AddSavedObject(ObjImpls::CKObject* obj, CKDWORD flags = CK_STATESAVE_ALL);
|
bool AddSavedObject(ObjImpls::CKObject* obj, CKDWORD flags = CK_STATESAVE_ALL);
|
||||||
CKBOOL AddSavedObjects(CKObjectArray* objarray, CKDWORD flags = CK_STATESAVE_ALL);
|
bool AddSavedObjects(CKObjectArray* objarray, CKDWORD flags = CK_STATESAVE_ALL);
|
||||||
CKBOOL AddSavedFile(CKSTRING u8FileName);
|
bool AddSavedFile(CKSTRING u8FileName);
|
||||||
|
|
||||||
// ========== Saving ==========
|
// ========== Saving ==========
|
||||||
CKERROR Save(CKSTRING u8_filename);
|
CKERROR Save(CKSTRING u8_filename);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CKBOOL m_Done;
|
bool m_Done;
|
||||||
/**
|
/**
|
||||||
* True if this writer is copy from reader.
|
* True if this writer is copy from reader.
|
||||||
* The data copied from reader mean that calling just only do some small modification.
|
* The data copied from reader mean that calling just only do some small modification.
|
||||||
|
@ -233,7 +233,7 @@ namespace LibCmo::CK2 {
|
||||||
* Just apply the data coming from reader.
|
* Just apply the data coming from reader.
|
||||||
* Also, Add object functions is not allowed when writer copying from reader.
|
* Also, Add object functions is not allowed when writer copying from reader.
|
||||||
*/
|
*/
|
||||||
CKBOOL m_IsCopyFromReader;
|
bool m_IsCopyFromReader;
|
||||||
|
|
||||||
CKINT m_SaveIDMax; /**< Maximum CK_ID found when saving or loading objects */
|
CKINT m_SaveIDMax; /**< Maximum CK_ID found when saving or loading objects */
|
||||||
XContainer::XArray<CKFileObject> m_FileObjects; /**< List of objects being saved / loaded */
|
XContainer::XArray<CKFileObject> m_FileObjects; /**< List of objects being saved / loaded */
|
||||||
|
|
|
@ -232,19 +232,19 @@ namespace LibCmo::CK2 {
|
||||||
|
|
||||||
CKFileWriter::~CKFileWriter() {}
|
CKFileWriter::~CKFileWriter() {}
|
||||||
|
|
||||||
CKBOOL CKFileWriter::AddSavedObject(ObjImpls::CKObject* obj, CKDWORD flags) {
|
bool CKFileWriter::AddSavedObject(ObjImpls::CKObject* obj, CKDWORD flags) {
|
||||||
if (m_Done || m_IsCopyFromReader) return CKFALSE;
|
if (m_Done || m_IsCopyFromReader) return false;
|
||||||
return CKFALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CKBOOL CKFileWriter::AddSavedObjects(CKObjectArray* objarray, CKDWORD flags) {
|
bool CKFileWriter::AddSavedObjects(CKObjectArray* objarray, CKDWORD flags) {
|
||||||
if (m_Done || m_IsCopyFromReader) return CKFALSE;
|
if (m_Done || m_IsCopyFromReader) return false;
|
||||||
return CKFALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CKBOOL CKFileWriter::AddSavedFile(CKSTRING u8FileName) {
|
bool CKFileWriter::AddSavedFile(CKSTRING u8FileName) {
|
||||||
if (m_Done || m_IsCopyFromReader) return CKFALSE;
|
if (m_Done || m_IsCopyFromReader) return false;
|
||||||
return CKFALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
@ -253,7 +253,7 @@ namespace LibCmo::CK2 {
|
||||||
#pragma region CKFileVisitor
|
#pragma region CKFileVisitor
|
||||||
|
|
||||||
CKFileVisitor::CKFileVisitor(CKFileReader* reader) :
|
CKFileVisitor::CKFileVisitor(CKFileReader* reader) :
|
||||||
m_IsReader(CKTRUE), m_Reader(reader), m_Writer(nullptr), m_Ctx(reader->m_Ctx) {
|
m_IsReader(true), m_Reader(reader), m_Writer(nullptr), m_Ctx(reader->m_Ctx) {
|
||||||
if (reader == nullptr) LIBPANIC("Reader is nullptr.");
|
if (reader == nullptr) LIBPANIC("Reader is nullptr.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace LibCmo::CK2 {
|
||||||
|
|
||||||
// ========== read header ==========
|
// ========== read header ==========
|
||||||
// check header size
|
// check header size
|
||||||
if (parser->GetSize() < sizeof(CKRawFileInfo)) return CKERROR::CKERR_INVALIDFILE;
|
if (parser->GetSize() < CKSizeof(CKRawFileInfo)) return CKERROR::CKERR_INVALIDFILE;
|
||||||
if (std::memcmp(parser->GetPtr(), CKNEMOFI, sizeof(CKRawFileInfo::NeMo))) return CKERROR::CKERR_INVALIDFILE;
|
if (std::memcmp(parser->GetPtr(), CKNEMOFI, sizeof(CKRawFileInfo::NeMo))) return CKERROR::CKERR_INVALIDFILE;
|
||||||
// read header
|
// read header
|
||||||
CKRawFileInfo rawHeader;
|
CKRawFileInfo rawHeader;
|
||||||
|
@ -85,7 +85,7 @@ namespace LibCmo::CK2 {
|
||||||
rawHeader.Crc = 0u;
|
rawHeader.Crc = 0u;
|
||||||
|
|
||||||
// compute crc
|
// compute crc
|
||||||
CKDWORD gotten_crc = CKComputeDataCRC(&rawHeader, sizeof(CKRawFileInfo), 0u);
|
CKDWORD gotten_crc = CKComputeDataCRC(&rawHeader, CKSizeof(CKRawFileInfo), 0u);
|
||||||
parser->SetCursor(sizeof(CKRawFileInfo));
|
parser->SetCursor(sizeof(CKRawFileInfo));
|
||||||
gotten_crc = CKComputeDataCRC(parser->GetPtr(), this->m_FileInfo.Hdr1PackSize, gotten_crc);
|
gotten_crc = CKComputeDataCRC(parser->GetPtr(), this->m_FileInfo.Hdr1PackSize, gotten_crc);
|
||||||
parser->MoveCursor(this->m_FileInfo.Hdr1PackSize);
|
parser->MoveCursor(this->m_FileInfo.Hdr1PackSize);
|
||||||
|
@ -170,7 +170,7 @@ namespace LibCmo::CK2 {
|
||||||
parser->Read(&includedFileCount, sizeof(CKDWORD));
|
parser->Read(&includedFileCount, sizeof(CKDWORD));
|
||||||
this->m_IncludedFiles.resize(includedFileCount);
|
this->m_IncludedFiles.resize(includedFileCount);
|
||||||
|
|
||||||
hasIncludedFile -= sizeof(CKDWORD);
|
hasIncludedFile -= static_cast<int32_t>(sizeof(CKDWORD));
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: backward pos
|
// MARK: backward pos
|
||||||
|
@ -314,8 +314,8 @@ namespace LibCmo::CK2 {
|
||||||
// read file body
|
// read file body
|
||||||
FILE* fp = m_Ctx->OpenTempFile(file.c_str(), "wb");
|
FILE* fp = m_Ctx->OpenTempFile(file.c_str(), "wb");
|
||||||
if (fp != nullptr) {
|
if (fp != nullptr) {
|
||||||
fwrite(parser->GetPtr(), sizeof(char), filebodylen, fp);
|
std::fwrite(parser->GetPtr(), sizeof(char), filebodylen, fp);
|
||||||
fclose(fp);
|
std::fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
// move to next
|
// move to next
|
||||||
|
|
|
@ -88,11 +88,11 @@ namespace LibCmo::CK2 {
|
||||||
sumHdrObjSize = 0;
|
sumHdrObjSize = 0;
|
||||||
for (auto& obj : m_FileObjects) {
|
for (auto& obj : m_FileObjects) {
|
||||||
// += 4DWORD(ObjId, ObjCid, FileIndex, NameLen)
|
// += 4DWORD(ObjId, ObjCid, FileIndex, NameLen)
|
||||||
sumHdrObjSize += 4 * sizeof(CKDWORD);
|
sumHdrObjSize += 4 * CKSizeof(CKDWORD);
|
||||||
if (obj.Name.c_str() != nullptr) {
|
if (obj.Name.c_str() != nullptr) {
|
||||||
// += Name size
|
// += Name size
|
||||||
m_Ctx->GetNativeString(obj.Name.string(), name_conv);
|
m_Ctx->GetNativeString(obj.Name.string(), name_conv);
|
||||||
sumHdrObjSize += name_conv.size();
|
sumHdrObjSize += static_cast<CKDWORD>(name_conv.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.Data == nullptr) {
|
if (obj.Data == nullptr) {
|
||||||
|
@ -101,7 +101,7 @@ namespace LibCmo::CK2 {
|
||||||
obj.PackSize = obj.Data->ConvertToBuffer(nullptr);
|
obj.PackSize = obj.Data->ConvertToBuffer(nullptr);
|
||||||
}
|
}
|
||||||
// += chunk size + chunk
|
// += chunk size + chunk
|
||||||
sumDataObjSize += obj.PackSize + sizeof(CKDWORD);
|
sumDataObjSize += obj.PackSize + CKSizeof(CKDWORD);
|
||||||
}
|
}
|
||||||
|
|
||||||
CKDWORD sumDataMgrSize = 0;
|
CKDWORD sumDataMgrSize = 0;
|
||||||
|
@ -113,17 +113,19 @@ namespace LibCmo::CK2 {
|
||||||
chunksize = mgr.Data->ConvertToBuffer(nullptr);
|
chunksize = mgr.Data->ConvertToBuffer(nullptr);
|
||||||
}
|
}
|
||||||
// += GUID(2 DWORD) + chunk size + chunk
|
// += GUID(2 DWORD) + chunk size + chunk
|
||||||
sumDataMgrSize += chunksize + 3 * sizeof(CKDWORD);
|
sumDataMgrSize += chunksize + 3 * CKSizeof(CKDWORD);
|
||||||
}
|
}
|
||||||
|
|
||||||
// += Plugin Dep list size
|
// += Plugin Dep list size
|
||||||
CKDWORD sumHdrPlgSize = sizeof(CKDWORD);
|
CKDWORD sumHdrPlgSize = CKSizeof(CKDWORD);
|
||||||
for (auto& plg : m_PluginsDep) {
|
for (auto& plg : m_PluginsDep) {
|
||||||
// += GUID list + (dep category + GUID list size)
|
// += GUID list + (dep category + GUID list size)
|
||||||
sumHdrPlgSize += sizeof(CKGUID) * plg.m_Guids.size() + 2 * sizeof(CKDWORD);
|
sumHdrPlgSize +=
|
||||||
|
CKSizeof(CKGUID) * static_cast<CKDWORD>(plg.m_Guids.size())
|
||||||
|
+ 2 * CKSizeof(CKDWORD);
|
||||||
}
|
}
|
||||||
|
|
||||||
CKDWORD sumHdrIncludedFiles = sizeof(int32_t) + sizeof(CKDWORD);
|
CKDWORD sumHdrIncludedFiles = CKSizeof(int32_t) + CKSizeof(CKDWORD);
|
||||||
|
|
||||||
// calc the whole size
|
// calc the whole size
|
||||||
CKDWORD sumHdrSize = sumHdrObjSize + sumHdrPlgSize + sumHdrIncludedFiles;
|
CKDWORD sumHdrSize = sumHdrObjSize + sumHdrPlgSize + sumHdrIncludedFiles;
|
||||||
|
@ -132,11 +134,11 @@ namespace LibCmo::CK2 {
|
||||||
// compute file index for all object
|
// compute file index for all object
|
||||||
if (!m_FileObjects.empty()) {
|
if (!m_FileObjects.empty()) {
|
||||||
// set base for first one
|
// set base for first one
|
||||||
m_FileObjects[0].FileIndex = sumHdrSize + sumDataMgrSize + sizeof(CKRawFileInfo);
|
m_FileObjects[0].FileIndex = sumHdrSize + sumDataMgrSize + CKSizeof(CKRawFileInfo);
|
||||||
// calc the remains
|
// calc the remains
|
||||||
for (size_t i = 1; i < m_FileObjects.size(); ++i) {
|
for (size_t i = 1; i < m_FileObjects.size(); ++i) {
|
||||||
// prev obj PackSize + prev obj FileIndex + prev obj chunk size
|
// prev obj PackSize + prev obj FileIndex + prev obj chunk size
|
||||||
m_FileObjects[i].FileIndex = m_FileObjects[i - 1].FileIndex + m_FileObjects[i - 1].PackSize + sizeof(CKDWORD);
|
m_FileObjects[i].FileIndex = m_FileObjects[i - 1].FileIndex + m_FileObjects[i - 1].PackSize + CKSizeof(CKDWORD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +201,7 @@ namespace LibCmo::CK2 {
|
||||||
|
|
||||||
// write included file
|
// write included file
|
||||||
{
|
{
|
||||||
CKDWORD cache = sizeof(CKDWORD);
|
CKDWORD cache = CKSizeof(CKDWORD);
|
||||||
hdrparser->Write(&cache, sizeof(CKDWORD));
|
hdrparser->Write(&cache, sizeof(CKDWORD));
|
||||||
|
|
||||||
cache = static_cast<CKDWORD>(m_IncludedFiles.size());
|
cache = static_cast<CKDWORD>(m_IncludedFiles.size());
|
||||||
|
@ -270,7 +272,7 @@ namespace LibCmo::CK2 {
|
||||||
|
|
||||||
// ========== Construct File Info ==========
|
// ========== Construct File Info ==========
|
||||||
// compute crc
|
// compute crc
|
||||||
CKDWORD computedcrc = CKComputeDataCRC(&rawHeader, sizeof(CKRawFileInfo), 0u);
|
CKDWORD computedcrc = CKComputeDataCRC(&rawHeader, CKSizeof(CKRawFileInfo), 0u);
|
||||||
computedcrc = CKComputeDataCRC(hdrparser->GetBase(), hdrparser->GetSize(), computedcrc);
|
computedcrc = CKComputeDataCRC(hdrparser->GetBase(), hdrparser->GetSize(), computedcrc);
|
||||||
computedcrc = CKComputeDataCRC(datparser->GetBase(), datparser->GetSize(), computedcrc);
|
computedcrc = CKComputeDataCRC(datparser->GetBase(), datparser->GetSize(), computedcrc);
|
||||||
|
|
||||||
|
@ -288,7 +290,7 @@ namespace LibCmo::CK2 {
|
||||||
this->m_FileInfo.ObjectCount = rawHeader.ObjectCount;
|
this->m_FileInfo.ObjectCount = rawHeader.ObjectCount;
|
||||||
this->m_FileInfo.MaxIDSaved = rawHeader.MaxIDSaved;
|
this->m_FileInfo.MaxIDSaved = rawHeader.MaxIDSaved;
|
||||||
// fill file size and crc
|
// fill file size and crc
|
||||||
this->m_FileInfo.FileSize = sizeof(CKRawFileInfo) + rawHeader.DataPackSize + rawHeader.Hdr1PackSize;
|
this->m_FileInfo.FileSize = CKSizeof(CKRawFileInfo) + rawHeader.DataPackSize + rawHeader.Hdr1PackSize;
|
||||||
this->m_FileInfo.Crc = computedcrc;
|
this->m_FileInfo.Crc = computedcrc;
|
||||||
rawHeader.Crc = computedcrc;
|
rawHeader.Crc = computedcrc;
|
||||||
|
|
||||||
|
@ -309,19 +311,19 @@ namespace LibCmo::CK2 {
|
||||||
// write filename
|
// write filename
|
||||||
m_Ctx->GetNativeString(fentry, name_conv);
|
m_Ctx->GetNativeString(fentry, name_conv);
|
||||||
CKDWORD filenamelen = static_cast<CKDWORD>(name_conv.size());
|
CKDWORD filenamelen = static_cast<CKDWORD>(name_conv.size());
|
||||||
fwrite(&filenamelen, sizeof(CKDWORD), 1, fs);
|
std::fwrite(&filenamelen, sizeof(CKDWORD), 1, fs);
|
||||||
fwrite(name_conv.data(), sizeof(char), filenamelen, fs);
|
std::fwrite(name_conv.data(), sizeof(char), filenamelen, fs);
|
||||||
|
|
||||||
// try mapping file.
|
// try mapping file.
|
||||||
std::unique_ptr<VxMath::VxMemoryMappedFile> mappedFile(new VxMath::VxMemoryMappedFile(fentry.c_str()));
|
std::unique_ptr<VxMath::VxMemoryMappedFile> mappedFile(new VxMath::VxMemoryMappedFile(fentry.c_str()));
|
||||||
|
|
||||||
// write file length
|
// write file length
|
||||||
CKDWORD filebodylen = static_cast<CKDWORD>(mappedFile->IsValid() ? mappedFile->GetFileSize() : 0);
|
CKDWORD filebodylen = static_cast<CKDWORD>(mappedFile->IsValid() ? mappedFile->GetFileSize() : 0);
|
||||||
fwrite(&filebodylen, sizeof(CKDWORD), 1, fs);
|
std::fwrite(&filebodylen, sizeof(CKDWORD), 1, fs);
|
||||||
|
|
||||||
// write file body
|
// write file body
|
||||||
if (mappedFile->IsValid()) {
|
if (mappedFile->IsValid()) {
|
||||||
fwrite(mappedFile->GetBase(), sizeof(char), filebodylen, fs);
|
std::fwrite(mappedFile->GetBase(), sizeof(char), filebodylen, fs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// release mapped file
|
// release mapped file
|
||||||
|
@ -330,7 +332,7 @@ namespace LibCmo::CK2 {
|
||||||
}
|
}
|
||||||
|
|
||||||
// close file
|
// close file
|
||||||
fclose(fs);
|
std::fclose(fs);
|
||||||
|
|
||||||
return CKERROR::CKERR_OK;
|
return CKERROR::CKERR_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ namespace LibCmo::CK2 {
|
||||||
return DestBuffer;
|
return DestBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
CKDWORD CKComputeDataCRC(const void* data, CKINT size, CKDWORD PreviousCRC) {
|
CKDWORD CKComputeDataCRC(const void* data, CKDWORD size, CKDWORD PreviousCRC) {
|
||||||
return static_cast<CKDWORD>(adler32(
|
return static_cast<CKDWORD>(adler32(
|
||||||
static_cast<uLong>(PreviousCRC),
|
static_cast<uLong>(PreviousCRC),
|
||||||
reinterpret_cast<const Bytef*>(data),
|
reinterpret_cast<const Bytef*>(data),
|
||||||
|
@ -89,13 +89,13 @@ namespace LibCmo::CK2 {
|
||||||
desc.DerivationLevel = parent.DerivationLevel + 1;
|
desc.DerivationLevel = parent.DerivationLevel + 1;
|
||||||
|
|
||||||
// set done
|
// set done
|
||||||
desc.Done = CKTRUE;
|
desc.Done = true;
|
||||||
}
|
}
|
||||||
static void CKBuildClassHierarchyTable() {
|
static void CKBuildClassHierarchyTable() {
|
||||||
// set Done to false and resize all XBitArray
|
// set Done to false and resize all XBitArray
|
||||||
size_t classCount = g_CKClassInfo.size();
|
size_t classCount = g_CKClassInfo.size();
|
||||||
for (auto& item : g_CKClassInfo) {
|
for (auto& item : g_CKClassInfo) {
|
||||||
item.Done = CKFALSE;
|
item.Done = false;
|
||||||
item.Parents.resize(classCount, false);
|
item.Parents.resize(classCount, false);
|
||||||
item.Children.resize(classCount, false);
|
item.Children.resize(classCount, false);
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ namespace LibCmo::CK2 {
|
||||||
#pragma region Class Hierarchy Management
|
#pragma region Class Hierarchy Management
|
||||||
|
|
||||||
CKINT CKGetClassCount() {
|
CKINT CKGetClassCount() {
|
||||||
return g_CKClassInfo.size();
|
return static_cast<CKINT>(g_CKClassInfo.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
const CKClassDesc* CKGetClassDesc(CK_CLASSID cid) {
|
const CKClassDesc* CKGetClassDesc(CK_CLASSID cid) {
|
||||||
|
@ -153,14 +153,14 @@ namespace LibCmo::CK2 {
|
||||||
return g_CKClassInfo[finder->second].NameFct();
|
return g_CKClassInfo[finder->second].NameFct();
|
||||||
}
|
}
|
||||||
|
|
||||||
CKBOOL CKIsChildClassOf(CK_CLASSID child, CK_CLASSID parent) {
|
bool CKIsChildClassOf(CK_CLASSID child, CK_CLASSID parent) {
|
||||||
// get corresponding index first
|
// get corresponding index first
|
||||||
// if we can't find it, return false anyway.
|
// if we can't find it, return false anyway.
|
||||||
auto finder = g_CKClassInfoId2Idx.find(child);
|
auto finder = g_CKClassInfoId2Idx.find(child);
|
||||||
if (finder == g_CKClassInfoId2Idx.end()) return CKFALSE;
|
if (finder == g_CKClassInfoId2Idx.end()) return false;
|
||||||
size_t child_idx = finder->second;
|
size_t child_idx = finder->second;
|
||||||
finder = g_CKClassInfoId2Idx.find(parent);
|
finder = g_CKClassInfoId2Idx.find(parent);
|
||||||
if (finder == g_CKClassInfoId2Idx.end()) return CKFALSE;
|
if (finder == g_CKClassInfoId2Idx.end()) return false;
|
||||||
size_t parent_idx = finder->second;
|
size_t parent_idx = finder->second;
|
||||||
|
|
||||||
return g_CKClassInfo[child_idx].Parents[parent_idx];
|
return g_CKClassInfo[child_idx].Parents[parent_idx];
|
||||||
|
|
|
@ -43,7 +43,14 @@ namespace LibCmo::CK2 {
|
||||||
* @return CRC of the buffer.
|
* @return CRC of the buffer.
|
||||||
* @see CKPackData, CKUnPackData
|
* @see CKPackData, CKUnPackData
|
||||||
*/
|
*/
|
||||||
CKDWORD CKComputeDataCRC(const void* data, CKINT size, CKDWORD PreviousCRC = 0);
|
CKDWORD CKComputeDataCRC(const void* data, CKDWORD size, CKDWORD PreviousCRC = 0);
|
||||||
|
|
||||||
|
// ========== Numberic Utilities ==========
|
||||||
|
|
||||||
|
/*
|
||||||
|
The convenient sizeof which return CKDWORD, not size_t.
|
||||||
|
*/
|
||||||
|
#define CKSizeof(_Ty) (static_cast<LibCmo::CK2::CKDWORD>(sizeof(_Ty)))
|
||||||
|
|
||||||
// ========== CKClass Registration ==========
|
// ========== CKClass Registration ==========
|
||||||
|
|
||||||
|
@ -56,7 +63,7 @@ namespace LibCmo::CK2 {
|
||||||
const CKClassDesc* CKGetClassDesc(CK_CLASSID cid);
|
const CKClassDesc* CKGetClassDesc(CK_CLASSID cid);
|
||||||
CKSTRING CKClassIDToString(CK_CLASSID cid);
|
CKSTRING CKClassIDToString(CK_CLASSID cid);
|
||||||
|
|
||||||
CKBOOL CKIsChildClassOf(CK_CLASSID child, CK_CLASSID parent);
|
bool CKIsChildClassOf(CK_CLASSID child, CK_CLASSID parent);
|
||||||
CK_CLASSID CKGetParentClassID(CK_CLASSID child);
|
CK_CLASSID CKGetParentClassID(CK_CLASSID child);
|
||||||
CK_CLASSID CKGetCommonParent(CK_CLASSID cid1, CK_CLASSID cid2);
|
CK_CLASSID CKGetCommonParent(CK_CLASSID cid1, CK_CLASSID cid2);
|
||||||
|
|
||||||
|
|
|
@ -152,7 +152,7 @@ namespace LibCmo::CK2 {
|
||||||
}
|
}
|
||||||
|
|
||||||
CKDWORD CKStateChunk::GetDataSize(void) {
|
CKDWORD CKStateChunk::GetDataSize(void) {
|
||||||
return sizeof(CKDWORD) * this->m_DataDwSize;
|
return CKSizeof(CKDWORD) * this->m_DataDwSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
CK_STATECHUNK_DATAVERSION CKStateChunk::GetDataVersion() {
|
CK_STATECHUNK_DATAVERSION CKStateChunk::GetDataVersion() {
|
||||||
|
@ -192,8 +192,8 @@ namespace LibCmo::CK2 {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
size_t CKStateChunk::GetCeilDwordSize(size_t char_size) {
|
CKDWORD CKStateChunk::GetCeilDwordSize(size_t char_size) {
|
||||||
return (char_size + 3) >> 2;
|
return static_cast<CKDWORD>((char_size + 3) >> 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CKStateChunk::ResizeBuffer(CKDWORD new_dwsize) {
|
bool CKStateChunk::ResizeBuffer(CKDWORD new_dwsize) {
|
||||||
|
@ -250,8 +250,8 @@ namespace LibCmo::CK2 {
|
||||||
|
|
||||||
#pragma region Buffer Related
|
#pragma region Buffer Related
|
||||||
|
|
||||||
CKBOOL CKStateChunk::ConvertFromBuffer(const void* buf) {
|
bool CKStateChunk::ConvertFromBuffer(const void* buf) {
|
||||||
if (buf == nullptr) return CKFALSE;
|
if (buf == nullptr) return false;
|
||||||
this->Clear();
|
this->Clear();
|
||||||
|
|
||||||
// read chunk ver and data ver first
|
// read chunk ver and data ver first
|
||||||
|
@ -374,28 +374,28 @@ namespace LibCmo::CK2 {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// too new. can not read, skip
|
// too new. can not read, skip
|
||||||
return CKTRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return CKTRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CKDWORD CKStateChunk::ConvertToBuffer(void* buf) {
|
CKDWORD CKStateChunk::ConvertToBuffer(void* buf) {
|
||||||
// calc size and setup options first
|
// calc size and setup options first
|
||||||
// size = buffer + buffer_size + header
|
// size = buffer + buffer_size + header
|
||||||
CKDWORD size = (m_DataDwSize * sizeof(CKDWORD)) + sizeof(CKDWORD) + sizeof(CKDWORD);
|
CKDWORD size = (m_DataDwSize * CKSizeof(CKDWORD)) + CKSizeof(CKDWORD) + CKSizeof(CKDWORD);
|
||||||
CK_STATECHUNK_CHUNKOPTIONS options = static_cast<CK_STATECHUNK_CHUNKOPTIONS>(0);
|
CK_STATECHUNK_CHUNKOPTIONS options = static_cast<CK_STATECHUNK_CHUNKOPTIONS>(0);
|
||||||
|
|
||||||
if (!m_ObjectList.empty()) {
|
if (!m_ObjectList.empty()) {
|
||||||
size += sizeof(CK_ID) * m_ObjectList.size() + sizeof(CKDWORD);
|
size += CKSizeof(CKDWORD) * static_cast<CKDWORD>(m_ObjectList.size()) + sizeof(CKDWORD);
|
||||||
EnumsHelper::Add(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_IDS);
|
EnumsHelper::Add(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_IDS);
|
||||||
}
|
}
|
||||||
if (!m_ChunkList.empty()) {
|
if (!m_ChunkList.empty()) {
|
||||||
size += sizeof(CK_ID) * m_ChunkList.size() + sizeof(CKDWORD);
|
size += CKSizeof(CKDWORD) * static_cast<CKDWORD>(m_ChunkList.size()) + sizeof(CKDWORD);
|
||||||
EnumsHelper::Add(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_CHN);
|
EnumsHelper::Add(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_CHN);
|
||||||
}
|
}
|
||||||
if (!m_ManagerList.empty()) {
|
if (!m_ManagerList.empty()) {
|
||||||
size += sizeof(CK_ID) * m_ManagerList.size() + sizeof(CKDWORD);
|
size += CKSizeof(CKDWORD) * static_cast<CKDWORD>(m_ManagerList.size()) + sizeof(CKDWORD);
|
||||||
EnumsHelper::Add(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_MAN);
|
EnumsHelper::Add(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_MAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,17 +422,17 @@ namespace LibCmo::CK2 {
|
||||||
// write list
|
// write list
|
||||||
if (!m_ObjectList.empty()) {
|
if (!m_ObjectList.empty()) {
|
||||||
dwbuf[bufpos] = static_cast<CKDWORD>(m_ObjectList.size());
|
dwbuf[bufpos] = static_cast<CKDWORD>(m_ObjectList.size());
|
||||||
std::memcpy(dwbuf + bufpos + 1, m_ObjectList.data(), m_ObjectList.size() * sizeof(CK_ID));
|
std::memcpy(dwbuf + bufpos + 1, m_ObjectList.data(), m_ObjectList.size() * sizeof(CKDWORD));
|
||||||
bufpos += m_ObjectList.size() + 1;
|
bufpos += m_ObjectList.size() + 1;
|
||||||
}
|
}
|
||||||
if (!m_ChunkList.empty()) {
|
if (!m_ChunkList.empty()) {
|
||||||
dwbuf[bufpos] = static_cast<CKDWORD>(m_ChunkList.size());
|
dwbuf[bufpos] = static_cast<CKDWORD>(m_ChunkList.size());
|
||||||
std::memcpy(dwbuf + bufpos + 1, m_ChunkList.data(), m_ChunkList.size() * sizeof(CK_ID));
|
std::memcpy(dwbuf + bufpos + 1, m_ChunkList.data(), m_ChunkList.size() * sizeof(CKDWORD));
|
||||||
bufpos += m_ChunkList.size() + 1;
|
bufpos += m_ChunkList.size() + 1;
|
||||||
}
|
}
|
||||||
if (!m_ManagerList.empty()) {
|
if (!m_ManagerList.empty()) {
|
||||||
dwbuf[bufpos] = static_cast<CKDWORD>(m_ManagerList.size());
|
dwbuf[bufpos] = static_cast<CKDWORD>(m_ManagerList.size());
|
||||||
std::memcpy(dwbuf + bufpos + 1, m_ManagerList.data(), m_ManagerList.size() * sizeof(CK_ID));
|
std::memcpy(dwbuf + bufpos + 1, m_ManagerList.data(), m_ManagerList.size() * sizeof(CKDWORD));
|
||||||
bufpos += m_ManagerList.size() + 1;
|
bufpos += m_ManagerList.size() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -460,7 +460,7 @@ namespace LibCmo::CK2 {
|
||||||
// // if no error, assign data
|
// // if no error, assign data
|
||||||
// if (err == Z_OK) {
|
// if (err == Z_OK) {
|
||||||
// // get dw size and copy it to remove useless blank data
|
// // get dw size and copy it to remove useless blank data
|
||||||
// this->m_DataDwSize = static_cast<CKDWORD>(destSize) / sizeof(CKDWORD);
|
// this->m_DataDwSize = static_cast<CKDWORD>(destSize) / CKSizeof(CKDWORD);
|
||||||
|
|
||||||
// delete[] this->m_pData;
|
// delete[] this->m_pData;
|
||||||
// this->m_pData = nullptr;
|
// this->m_pData = nullptr;
|
||||||
|
@ -521,7 +521,7 @@ namespace LibCmo::CK2 {
|
||||||
// the last identifier, use chunk size instead
|
// the last identifier, use chunk size instead
|
||||||
nextptr = this->m_DataDwSize;
|
nextptr = this->m_DataDwSize;
|
||||||
}
|
}
|
||||||
*out_size = sizeof(CKDWORD) * (nextptr - pos - 2u);
|
*out_size = CKSizeof(CKDWORD) * (nextptr - pos - 2u);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -542,7 +542,7 @@ namespace LibCmo::CK2 {
|
||||||
collection.emplace_back(IdentifierProfile{
|
collection.emplace_back(IdentifierProfile{
|
||||||
this->m_pData[pos],
|
this->m_pData[pos],
|
||||||
this->m_pData + pos + 2,
|
this->m_pData + pos + 2,
|
||||||
sizeof(CKDWORD) * (nextptr - pos - 2u)
|
CKSizeof(CKDWORD) * (nextptr - pos - 2u)
|
||||||
});
|
});
|
||||||
|
|
||||||
// move to next identifier or exit
|
// move to next identifier or exit
|
||||||
|
@ -693,26 +693,26 @@ namespace LibCmo::CK2 {
|
||||||
|
|
||||||
// core data
|
// core data
|
||||||
if (subchunk->m_DataDwSize != 0) {
|
if (subchunk->m_DataDwSize != 0) {
|
||||||
if (!this->ReadByteData(subchunk->m_pData, subchunk->m_DataDwSize * sizeof(CKDWORD))) goto subchunk_defer;
|
if (!this->ReadByteData(subchunk->m_pData, subchunk->m_DataDwSize * CKSizeof(CKDWORD))) goto subchunk_defer;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3 list data
|
// 3 list data
|
||||||
if (!subchunk->m_ObjectList.empty()) {
|
if (!subchunk->m_ObjectList.empty()) {
|
||||||
if (!this->ReadByteData(
|
if (!this->ReadByteData(
|
||||||
subchunk->m_ObjectList.data(),
|
subchunk->m_ObjectList.data(),
|
||||||
subchunk->m_ObjectList.size() * sizeof(CKDWORD)
|
static_cast<CKDWORD>(subchunk->m_ObjectList.size()) * CKSizeof(CKDWORD)
|
||||||
)) goto subchunk_defer;
|
)) goto subchunk_defer;
|
||||||
}
|
}
|
||||||
if (!subchunk->m_ChunkList.empty()) {
|
if (!subchunk->m_ChunkList.empty()) {
|
||||||
if (!this->ReadByteData(
|
if (!this->ReadByteData(
|
||||||
subchunk->m_ChunkList.data(),
|
subchunk->m_ChunkList.data(),
|
||||||
subchunk->m_ChunkList.size() * sizeof(CKDWORD)
|
static_cast<CKDWORD>(subchunk->m_ChunkList.size()) * CKSizeof(CKDWORD)
|
||||||
)) goto subchunk_defer;
|
)) goto subchunk_defer;
|
||||||
}
|
}
|
||||||
if (!subchunk->m_ManagerList.empty()) {
|
if (!subchunk->m_ManagerList.empty()) {
|
||||||
if (!this->ReadByteData(
|
if (!this->ReadByteData(
|
||||||
subchunk->m_ManagerList.data(),
|
subchunk->m_ManagerList.data(),
|
||||||
subchunk->m_ManagerList.size() * sizeof(CKDWORD)
|
static_cast<CKDWORD>(subchunk->m_ManagerList.size()) * CKSizeof(CKDWORD)
|
||||||
)) goto subchunk_defer;
|
)) goto subchunk_defer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -728,7 +728,7 @@ namespace LibCmo::CK2 {
|
||||||
this->Skip(1u);
|
this->Skip(1u);
|
||||||
|
|
||||||
// read core buf
|
// read core buf
|
||||||
if (!this->ReadByteData(subchunk->m_pData, subchunk->m_DataDwSize * sizeof(CKDWORD))) goto subchunk_defer;
|
if (!this->ReadByteData(subchunk->m_pData, subchunk->m_DataDwSize * CKSizeof(CKDWORD))) goto subchunk_defer;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,9 +55,9 @@ namespace LibCmo::CK2 {
|
||||||
|
|
||||||
ChunkParser m_Parser;
|
ChunkParser m_Parser;
|
||||||
|
|
||||||
std::vector<CKDWORD> m_ObjectList;
|
XContainer::XArray<CKDWORD> m_ObjectList;
|
||||||
std::vector<CKDWORD> m_ChunkList;
|
XContainer::XArray<CKDWORD> m_ChunkList;
|
||||||
std::vector<CKDWORD> m_ManagerList;
|
XContainer::XArray<CKDWORD> m_ManagerList;
|
||||||
|
|
||||||
CKFileVisitor* m_BindFile;
|
CKFileVisitor* m_BindFile;
|
||||||
CKContext* m_BindContext;
|
CKContext* m_BindContext;
|
||||||
|
@ -65,7 +65,7 @@ namespace LibCmo::CK2 {
|
||||||
#pragma region Buffer Related
|
#pragma region Buffer Related
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CKBOOL ConvertFromBuffer(const void* buf);
|
bool ConvertFromBuffer(const void* buf);
|
||||||
CKDWORD ConvertToBuffer(void* buf);
|
CKDWORD ConvertToBuffer(void* buf);
|
||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
@ -88,7 +88,7 @@ namespace LibCmo::CK2 {
|
||||||
bool Skip(CKDWORD DwordCount);
|
bool Skip(CKDWORD DwordCount);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
size_t GetCeilDwordSize(size_t char_size);
|
CKDWORD GetCeilDwordSize(size_t char_size);
|
||||||
bool ResizeBuffer(CKDWORD new_dwsize);
|
bool ResizeBuffer(CKDWORD new_dwsize);
|
||||||
bool EnsureWriteSpace(CKDWORD dwsize);
|
bool EnsureWriteSpace(CKDWORD dwsize);
|
||||||
bool EnsureReadSpace(CKDWORD dword_required);
|
bool EnsureReadSpace(CKDWORD dword_required);
|
||||||
|
@ -140,7 +140,7 @@ namespace LibCmo::CK2 {
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool ReadStruct(T* data) {
|
bool ReadStruct(T* data) {
|
||||||
return ReadByteData(data, static_cast<CKDWORD>(sizeof(T)));
|
return ReadByteData(data, CKSizeof(T));
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Read Struct
|
/// Read Struct
|
||||||
|
@ -152,7 +152,7 @@ namespace LibCmo::CK2 {
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline bool ReadStruct(T& data) {
|
inline bool ReadStruct(T& data) {
|
||||||
return ReadByteData(&data, static_cast<CKDWORD>(sizeof(T)));
|
return ReadByteData(&data, CKSizeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -167,14 +167,11 @@ namespace LibCmo::CK2 {
|
||||||
using CKSTRING = const char*;
|
using CKSTRING = const char*;
|
||||||
|
|
||||||
using CKCHAR = char;
|
using CKCHAR = char;
|
||||||
using CKBOOL = bool;
|
|
||||||
using CKBYTE = uint8_t;
|
using CKBYTE = uint8_t;
|
||||||
using CKDWORD = uint32_t;
|
using CKDWORD = uint32_t;
|
||||||
using CKWORD = uint16_t;
|
using CKWORD = uint16_t;
|
||||||
|
|
||||||
using CKINT = int32_t;
|
using CKINT = int32_t;
|
||||||
constexpr CKBOOL CKFALSE = false;
|
|
||||||
constexpr CKBOOL CKTRUE = true;
|
|
||||||
|
|
||||||
using CKParameterType = int32_t;
|
using CKParameterType = int32_t;
|
||||||
using CKOperationType = int32_t;
|
using CKOperationType = int32_t;
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace LibCmo::VxMath {
|
||||||
~VxMemoryMappedFile(void);
|
~VxMemoryMappedFile(void);
|
||||||
|
|
||||||
void* GetBase(void) { return this->m_pMemoryMappedFileBase; }
|
void* GetBase(void) { return this->m_pMemoryMappedFileBase; }
|
||||||
size_t GetFileSize(void) { return this->m_cbFile; }
|
CK2::CKDWORD GetFileSize(void) { return static_cast<CK2::CKDWORD>(this->m_cbFile); }
|
||||||
bool IsValid(void) { return this->m_bIsValid; }
|
bool IsValid(void) { return this->m_bIsValid; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ namespace Unvirt::StructFormatter {
|
||||||
|
|
||||||
fprintf(stdout, "0x%08" PRIxCKDWORD " (Rel: 0x%08" PRIxCKDWORD ")\t",
|
fprintf(stdout, "0x%08" PRIxCKDWORD " (Rel: 0x%08" PRIxCKDWORD ")\t",
|
||||||
obj.FileIndex,
|
obj.FileIndex,
|
||||||
obj.FileIndex - sizeof(LibCmo::CK2::CKRawFileInfo) - fileinfo.Hdr1UnPackSize);
|
obj.FileIndex - CKSizeof(LibCmo::CK2::CKRawFileInfo) - fileinfo.Hdr1UnPackSize);
|
||||||
fprintf(stdout, "0x%08" PRIxCKDWORD "\t", obj.PackSize);
|
fprintf(stdout, "0x%08" PRIxCKDWORD "\t", obj.PackSize);
|
||||||
|
|
||||||
fprintf(stdout, "#%" PRIuSIZET "\t", index);
|
fprintf(stdout, "#%" PRIuSIZET "\t", index);
|
||||||
|
@ -213,11 +213,11 @@ namespace Unvirt::StructFormatter {
|
||||||
fputs(UNVIRT_TERMCOL_LIGHT_YELLOW(("Identifiers\n")), stdout);
|
fputs(UNVIRT_TERMCOL_LIGHT_YELLOW(("Identifiers\n")), stdout);
|
||||||
fputs("Identifier\tData Pointer\tData Size\n", stdout);
|
fputs("Identifier\tData Pointer\tData Size\n", stdout);
|
||||||
for (const auto& ident : collection) {
|
for (const auto& ident : collection) {
|
||||||
fprintf(stdout, "0x%08" PRIxCKDWORD "\t", ident.m_AreaSize);
|
fprintf(stdout, "0x%08" PRIxCKDWORD "\t", ident.m_Identifier);
|
||||||
PrintPointer(ident.m_DataPtr);
|
PrintPointer(ident.m_DataPtr);
|
||||||
fputc('\t', stdout);
|
fputc('\t', stdout);
|
||||||
fprintf(stdout, "%" PRIuCKDWORD " (%" PRIuCKDWORD " DWORD + %" PRIuCKDWORD ")\n",
|
fprintf(stdout, "%" PRIuCKDWORD " (%" PRIuCKDWORD " DWORD + %" PRIuCKDWORD ")\n",
|
||||||
ident.m_AreaSize, ident.m_AreaSize / sizeof(LibCmo::CK2::CKDWORD), ident.m_AreaSize % sizeof(LibCmo::CK2::CKDWORD));
|
ident.m_AreaSize, ident.m_AreaSize / CKSizeof(LibCmo::CK2::CKDWORD), ident.m_AreaSize % CKSizeof(LibCmo::CK2::CKDWORD));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace Unvirt::TerminalHelper {
|
||||||
#define UNVIRT_TERMCOLHDR_LIGHT_CYAN "\033[96m"
|
#define UNVIRT_TERMCOLHDR_LIGHT_CYAN "\033[96m"
|
||||||
#define UNVIRT_TERMCOLHDR_LIGHT_WHITE "\033[97m"
|
#define UNVIRT_TERMCOLHDR_LIGHT_WHITE "\033[97m"
|
||||||
|
|
||||||
#define UNVIRT_TERMCOLTAIL "\033[97m"
|
#define UNVIRT_TERMCOLTAIL "\033[0m"
|
||||||
|
|
||||||
|
|
||||||
#define UNVIRT_TERMCOL_BLACK(T) "\033[30m" UNVIRT_REMOVE_PARENS(T) "\033[0m"
|
#define UNVIRT_TERMCOL_BLACK(T) "\033[30m" UNVIRT_REMOVE_PARENS(T) "\033[0m"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user