diff options
author | Shauren <shauren.trinity@gmail.com> | 2018-09-11 21:48:16 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2018-09-16 16:57:48 +0200 |
commit | ccbe4404f1806f047c009d14ed1dea9806dd5736 (patch) | |
tree | c12d6c8f199c161a0f3342f5897fab033739035d /src | |
parent | d8d874c47b01eb9b9b604476d02493295c874782 (diff) |
Tools: Updated db2 structures
Diffstat (limited to 'src')
-rw-r--r-- | src/common/DataStores/DB2FileLoader.cpp | 5 | ||||
-rw-r--r-- | src/common/DataStores/DB2FileLoader.h | 2 | ||||
-rw-r--r-- | src/common/DataStores/DB2FileSystemSource.cpp | 4 | ||||
-rw-r--r-- | src/common/DataStores/DB2FileSystemSource.h | 2 | ||||
-rw-r--r-- | src/tools/extractor_common/CascHandles.cpp | 7 | ||||
-rw-r--r-- | src/tools/extractor_common/CascHandles.h | 1 | ||||
-rw-r--r-- | src/tools/extractor_common/DB2CascFileSource.cpp | 5 | ||||
-rw-r--r-- | src/tools/extractor_common/DB2CascFileSource.h | 1 | ||||
-rw-r--r-- | src/tools/extractor_common/ExtractorDB2LoadInfo.h | 183 |
9 files changed, 148 insertions, 62 deletions
diff --git a/src/common/DataStores/DB2FileLoader.cpp b/src/common/DataStores/DB2FileLoader.cpp index d429195445b..d6138fa492e 100644 --- a/src/common/DataStores/DB2FileLoader.cpp +++ b/src/common/DataStores/DB2FileLoader.cpp @@ -1657,7 +1657,8 @@ bool DB2FileLoader::Load(DB2FileSource* source, DB2FileLoadInfo const* loadInfo) { DB2SectionHeader const& section = _impl->GetSection(i); - source->SetPosition(section.FileOffset); + if (!source->SetPosition(section.FileOffset)) + return false; if (!_impl->LoadTableData(source, i)) return false; @@ -1710,7 +1711,7 @@ bool DB2FileLoader::Load(DB2FileSource* source, DB2FileLoadInfo const* loadInfo) ASSERT(!loadInfo->Fields[0].IsSigned, "ID must be unsigned"); ++fieldIndex; } - for (uint32 f = 0; f < loadInfo->FieldCount; ++f) + for (uint32 f = 0; f < loadInfo->Meta->FieldCount; ++f) { ASSERT(loadInfo->Fields[fieldIndex].IsSigned == _impl->IsSignedField(f), "Mismatched field signedness for field %u (%s)", f, loadInfo->Fields[fieldIndex].Name); fieldIndex += loadInfo->Meta->Fields[f].ArraySize; diff --git a/src/common/DataStores/DB2FileLoader.h b/src/common/DataStores/DB2FileLoader.h index b1d42a2c954..7be5dc1aa39 100644 --- a/src/common/DataStores/DB2FileLoader.h +++ b/src/common/DataStores/DB2FileLoader.h @@ -88,7 +88,7 @@ struct TC_COMMON_API DB2FileSource // Returns current read position in file virtual std::size_t GetPosition() const = 0; - virtual void SetPosition(std::size_t position) = 0; + virtual bool SetPosition(std::size_t position) = 0; virtual std::size_t GetFileSize() const = 0; diff --git a/src/common/DataStores/DB2FileSystemSource.cpp b/src/common/DataStores/DB2FileSystemSource.cpp index b8a4e4258b6..9b929a8f5c9 100644 --- a/src/common/DataStores/DB2FileSystemSource.cpp +++ b/src/common/DataStores/DB2FileSystemSource.cpp @@ -45,9 +45,9 @@ std::size_t DB2FileSystemSource::GetPosition() const return ftell(_file); } -void DB2FileSystemSource::SetPosition(std::size_t position) +bool DB2FileSystemSource::SetPosition(std::size_t position) { - fseek(_file, position, SEEK_SET); + return fseek(_file, position, SEEK_SET) == 0; } std::size_t DB2FileSystemSource::GetFileSize() const diff --git a/src/common/DataStores/DB2FileSystemSource.h b/src/common/DataStores/DB2FileSystemSource.h index 94e4d3287b5..107aa2705fb 100644 --- a/src/common/DataStores/DB2FileSystemSource.h +++ b/src/common/DataStores/DB2FileSystemSource.h @@ -28,7 +28,7 @@ struct TC_COMMON_API DB2FileSystemSource : public DB2FileSource bool IsOpen() const override; bool Read(void* buffer, std::size_t numBytes) override; std::size_t GetPosition() const override; - void SetPosition(std::size_t position) override; + bool SetPosition(std::size_t position) override; std::size_t GetFileSize() const override; char const* GetFileName() const override; diff --git a/src/tools/extractor_common/CascHandles.cpp b/src/tools/extractor_common/CascHandles.cpp index 575f9fe3405..930d8eea420 100644 --- a/src/tools/extractor_common/CascHandles.cpp +++ b/src/tools/extractor_common/CascHandles.cpp @@ -127,6 +127,13 @@ DWORD CASC::GetFilePointer(FileHandle const& file) return ::CascSetFilePointer(file.get(), 0, nullptr, FILE_CURRENT); } +bool CASC::SetFilePointer(FileHandle const& file, LONGLONG position) +{ + LONG parts[2]; + memcpy(parts, &position, sizeof(parts)); + return ::CascSetFilePointer(file.get(), parts[0], &parts[1], FILE_BEGIN) != CASC_INVALID_POS; +} + bool CASC::ReadFile(FileHandle const& file, void* buffer, DWORD bytes, PDWORD bytesRead) { return ::CascReadFile(file.get(), buffer, bytes, bytesRead); diff --git a/src/tools/extractor_common/CascHandles.h b/src/tools/extractor_common/CascHandles.h index 0a8a1dd359c..a412976ce10 100644 --- a/src/tools/extractor_common/CascHandles.h +++ b/src/tools/extractor_common/CascHandles.h @@ -55,6 +55,7 @@ namespace CASC FileHandle OpenFile(StorageHandle const& storage, char const* fileName, DWORD localeMask, bool printErrors = false); DWORD GetFileSize(FileHandle const& file, PDWORD fileSizeHigh); DWORD GetFilePointer(FileHandle const& file); + bool SetFilePointer(FileHandle const& file, LONGLONG position); bool ReadFile(FileHandle const& file, void* buffer, DWORD bytes, PDWORD bytesRead); } diff --git a/src/tools/extractor_common/DB2CascFileSource.cpp b/src/tools/extractor_common/DB2CascFileSource.cpp index 5452c3e1518..b09f7f0b90e 100644 --- a/src/tools/extractor_common/DB2CascFileSource.cpp +++ b/src/tools/extractor_common/DB2CascFileSource.cpp @@ -40,6 +40,11 @@ std::size_t DB2CascFileSource::GetPosition() const return CASC::GetFilePointer(_fileHandle); } +bool DB2CascFileSource::SetPosition(std::size_t position) +{ + return CASC::SetFilePointer(_fileHandle, position); +} + std::size_t DB2CascFileSource::GetFileSize() const { DWORD sizeLow = 0; diff --git a/src/tools/extractor_common/DB2CascFileSource.h b/src/tools/extractor_common/DB2CascFileSource.h index 9708fcdcfe3..84376b6791d 100644 --- a/src/tools/extractor_common/DB2CascFileSource.h +++ b/src/tools/extractor_common/DB2CascFileSource.h @@ -28,6 +28,7 @@ struct DB2CascFileSource : public DB2FileSource bool IsOpen() const override; bool Read(void* buffer, std::size_t numBytes) override; std::size_t GetPosition() const override; + bool SetPosition(std::size_t position) override; std::size_t GetFileSize() const override; char const* GetFileName() const override; diff --git a/src/tools/extractor_common/ExtractorDB2LoadInfo.h b/src/tools/extractor_common/ExtractorDB2LoadInfo.h index fccfc924205..26c1fb860d7 100644 --- a/src/tools/extractor_common/ExtractorDB2LoadInfo.h +++ b/src/tools/extractor_common/ExtractorDB2LoadInfo.h @@ -26,20 +26,25 @@ struct CinematicCameraLoadInfo { static DB2FileLoadInfo const* Instance() { - static DB2FieldMeta const fields[] = + static DB2FieldMeta const loadedFields[] = { { false, FT_INT, "ID" }, - { false, FT_INT, "SoundID" }, { false, FT_FLOAT, "OriginX" }, { false, FT_FLOAT, "OriginY" }, { false, FT_FLOAT, "OriginZ" }, + { false, FT_INT, "SoundID" }, { false, FT_FLOAT, "OriginFacing" }, { false, FT_INT, "FileDataID" }, }; - static char const* types = "iffi"; - static uint8 const arraySizes[4] = { 1, 3, 1, 1 }; - static DB2Meta const meta(-1, 4, 0x0062B0F4, types, arraySizes, -1); - static DB2FileLoadInfo const loadInfo(&fields[0], std::extent<decltype(fields)>::value, &meta); + static DB2MetaField const fields[4] = + { + { FT_FLOAT, 3, true }, + { FT_INT, 1, false }, + { FT_FLOAT, 1, true }, + { FT_INT, 1, false }, + }; + static DB2Meta meta(-1, 4, 0x20C5E540, fields, -1); + static DB2FileLoadInfo const loadInfo(&loadedFields[0], std::extent<decltype(loadedFields)>::value, &meta); return &loadInfo; } }; @@ -48,24 +53,30 @@ struct GameobjectDisplayInfoLoadInfo { static DB2FileLoadInfo const* Instance() { - static DB2FieldMeta const fields[] = + static DB2FieldMeta const loadedFields[] = { { false, FT_INT, "ID" }, - { true, FT_INT, "FileDataID" }, { false, FT_FLOAT, "GeoBoxMinX" }, { false, FT_FLOAT, "GeoBoxMinY" }, { false, FT_FLOAT, "GeoBoxMinZ" }, { false, FT_FLOAT, "GeoBoxMaxX" }, { false, FT_FLOAT, "GeoBoxMaxY" }, { false, FT_FLOAT, "GeoBoxMaxZ" }, + { true, FT_INT, "FileDataID" }, + { true, FT_SHORT, "ObjectEffectPackageID" }, { false, FT_FLOAT, "OverrideLootEffectScale" }, { false, FT_FLOAT, "OverrideNameScale" }, - { true, FT_SHORT, "ObjectEffectPackageID" }, }; - static char const* types = "ifffh"; - static uint8 const arraySizes[5] = { 1, 6, 1, 1, 1 }; - static DB2Meta const meta(-1, 5, 0x9F2098D1, types, arraySizes, -1); - static DB2FileLoadInfo const loadInfo(&fields[0], std::extent<decltype(fields)>::value, &meta); + static DB2MetaField const fields[5] = + { + { FT_FLOAT, 6, true }, + { FT_INT, 1, true }, + { FT_SHORT, 1, true }, + { FT_FLOAT, 1, true }, + { FT_FLOAT, 1, true }, + }; + static DB2Meta meta(-1, 5, 0x7A816799, fields, -1); + static DB2FileLoadInfo const loadInfo(&loadedFields[0], std::extent<decltype(loadedFields)>::value, &meta); return &loadInfo; } }; @@ -74,16 +85,19 @@ struct LiquidMaterialLoadInfo { static DB2FileLoadInfo const* Instance() { - static DB2FieldMeta const fields[] = + static DB2FieldMeta const loadedFields[] = { { false, FT_INT, "ID" }, - { true, FT_BYTE, "LVF" }, { true, FT_BYTE, "Flags" }, + { true, FT_BYTE, "LVF" }, }; - static char const* types = "bb"; - static uint8 const arraySizes[2] = { 1, 1 }; - static DB2Meta meta(-1, 2, 0x62BE0340, types, arraySizes, -1); - static DB2FileLoadInfo const loadInfo(&fields[0], std::extent<decltype(fields)>::value, &meta); + static DB2MetaField const fields[2] = + { + { FT_BYTE, 1, true }, + { FT_BYTE, 1, true }, + }; + static DB2Meta meta(-1, 2, 0x6A7287A2, fields, -1); + static DB2FileLoadInfo const loadInfo(&loadedFields[0], std::extent<decltype(loadedFields)>::value, &meta); return &loadInfo; } }; @@ -92,7 +106,7 @@ struct LiquidObjectLoadInfo { static DB2FileLoadInfo const* Instance() { - static DB2FieldMeta const fields[] = + static DB2FieldMeta const loadedFields[] = { { false, FT_INT, "ID" }, { false, FT_FLOAT, "FlowDirection" }, @@ -101,10 +115,16 @@ struct LiquidObjectLoadInfo { false, FT_BYTE, "Fishable" }, { false, FT_BYTE, "Reflection" }, }; - static char const* types = "ffhbb"; - static uint8 const arraySizes[5] = { 1, 1, 1, 1, 1 }; - static DB2Meta meta(-1, 5, 0xACC168A6, types, arraySizes, -1); - static DB2FileLoadInfo const loadInfo(&fields[0], std::extent<decltype(fields)>::value, &meta); + static DB2MetaField const fields[5] = + { + { FT_FLOAT, 1, true }, + { FT_FLOAT, 1, true }, + { FT_SHORT, 1, true }, + { FT_BYTE, 1, false }, + { FT_BYTE, 1, false }, + }; + static DB2Meta meta(-1, 5, 0x7AF380AA, fields, -1); + static DB2FileLoadInfo const loadInfo(&loadedFields[0], std::extent<decltype(loadedFields)>::value, &meta); return &loadInfo; } }; @@ -113,7 +133,7 @@ struct LiquidTypeLoadInfo { static DB2FileLoadInfo const* Instance() { - static DB2FieldMeta const fields[] = + static DB2FieldMeta const loadedFields[] = { { false, FT_INT, "ID" }, { false, FT_STRING_NOT_LOCALIZED, "Name" }, @@ -123,12 +143,26 @@ struct LiquidTypeLoadInfo { false, FT_STRING_NOT_LOCALIZED, "Texture4" }, { false, FT_STRING_NOT_LOCALIZED, "Texture5" }, { false, FT_STRING_NOT_LOCALIZED, "Texture6" }, + { false, FT_SHORT, "Flags" }, + { false, FT_BYTE, "SoundBank" }, + { false, FT_INT, "SoundID" }, { false, FT_INT, "SpellID" }, { false, FT_FLOAT, "MaxDarkenDepth" }, { false, FT_FLOAT, "FogDarkenIntensity" }, { false, FT_FLOAT, "AmbDarkenIntensity" }, { false, FT_FLOAT, "DirDarkenIntensity" }, + { false, FT_SHORT, "LightID" }, { false, FT_FLOAT, "ParticleScale" }, + { false, FT_BYTE, "ParticleMovement" }, + { false, FT_BYTE, "ParticleTexSlots" }, + { false, FT_BYTE, "MaterialID" }, + { true, FT_INT, "MinimapStaticCol" }, + { false, FT_BYTE, "FrameCountTexture1" }, + { false, FT_BYTE, "FrameCountTexture2" }, + { false, FT_BYTE, "FrameCountTexture3" }, + { false, FT_BYTE, "FrameCountTexture4" }, + { false, FT_BYTE, "FrameCountTexture5" }, + { false, FT_BYTE, "FrameCountTexture6" }, { true, FT_INT, "Color1" }, { true, FT_INT, "Color2" }, { false, FT_FLOAT, "Float1" }, @@ -153,24 +187,37 @@ struct LiquidTypeLoadInfo { false, FT_INT, "Int2" }, { false, FT_INT, "Int3" }, { false, FT_INT, "Int4" }, - { false, FT_SHORT, "Flags" }, - { false, FT_SHORT, "LightID" }, - { false, FT_BYTE, "SoundBank" }, - { false, FT_BYTE, "ParticleMovement" }, - { false, FT_BYTE, "ParticleTexSlots" }, - { false, FT_BYTE, "MaterialID" }, - { false, FT_BYTE, "FrameCountTexture1" }, - { false, FT_BYTE, "FrameCountTexture2" }, - { false, FT_BYTE, "FrameCountTexture3" }, - { false, FT_BYTE, "FrameCountTexture4" }, - { false, FT_BYTE, "FrameCountTexture5" }, - { false, FT_BYTE, "FrameCountTexture6" }, - { false, FT_INT, "SoundID" }, + { false, FT_FLOAT, "Coefficient1" }, + { false, FT_FLOAT, "Coefficient2" }, + { false, FT_FLOAT, "Coefficient3" }, + { false, FT_FLOAT, "Coefficient4" }, + }; + static DB2MetaField const fields[21] = + { + { FT_STRING_NOT_LOCALIZED, 1, true }, + { FT_STRING_NOT_LOCALIZED, 6, true }, + { FT_SHORT, 1, false }, + { FT_BYTE, 1, false }, + { FT_INT, 1, false }, + { FT_INT, 1, false }, + { FT_FLOAT, 1, true }, + { FT_FLOAT, 1, true }, + { FT_FLOAT, 1, true }, + { FT_FLOAT, 1, true }, + { FT_SHORT, 1, false }, + { FT_FLOAT, 1, true }, + { FT_BYTE, 1, false }, + { FT_BYTE, 1, false }, + { FT_BYTE, 1, false }, + { FT_INT, 1, true }, + { FT_BYTE, 6, false }, + { FT_INT, 2, true }, + { FT_FLOAT, 18, true }, + { FT_INT, 4, false }, + { FT_FLOAT, 4, true }, }; - static char const* types = "ssifffffifihhbbbbbi"; - static uint8 const arraySizes[19] = { 1, 6, 1, 1, 1, 1, 1, 1, 2, 18, 4, 1, 1, 1, 1, 1, 1, 6, 1 }; - static DB2Meta const meta(-1, 19, 0x3313BBF3, types, arraySizes, -1); - static DB2FileLoadInfo const loadInfo(&fields[0], std::extent<decltype(fields)>::value, &meta); + static DB2Meta meta(-1, 21, 0x29F8C65E, fields, -1); + static DB2FileLoadInfo const loadInfo(&loadedFields[0], std::extent<decltype(loadedFields)>::value, &meta); return &loadInfo; } }; @@ -179,7 +226,7 @@ struct MapLoadInfo { static DB2FileLoadInfo const* Instance() { - static DB2FieldMeta const fields[] = + static DB2FieldMeta const loadedFields[] = { { false, FT_INT, "ID" }, { false, FT_STRING_NOT_LOCALIZED, "Directory" }, @@ -188,28 +235,52 @@ struct MapLoadInfo { false, FT_STRING, "MapDescription1" }, { false, FT_STRING, "PvpShortDescription" }, { false, FT_STRING, "PvpLongDescription" }, - { true, FT_INT, "Flags1" }, - { true, FT_INT, "Flags2" }, - { false, FT_FLOAT, "MinimapIconScale" }, { false, FT_FLOAT, "CorpseX" }, { false, FT_FLOAT, "CorpseY" }, + { false, FT_BYTE, "MapType" }, + { true, FT_BYTE, "InstanceType" }, + { false, FT_BYTE, "ExpansionID" }, { false, FT_SHORT, "AreaTableID" }, { true, FT_SHORT, "LoadingScreenID" }, - { true, FT_SHORT, "CorpseMapID" }, { true, FT_SHORT, "TimeOfDayOverride" }, { true, FT_SHORT, "ParentMapID" }, { true, FT_SHORT, "CosmeticParentMapID" }, - { true, FT_SHORT, "WindSettingsID" }, - { false, FT_BYTE, "InstanceType" }, - { false, FT_BYTE, "MapType" }, - { false, FT_BYTE, "ExpansionID" }, - { false, FT_BYTE, "MaxPlayers" }, { false, FT_BYTE, "TimeOffset" }, + { false, FT_FLOAT, "MinimapIconScale" }, + { true, FT_SHORT, "CorpseMapID" }, + { false, FT_BYTE, "MaxPlayers" }, + { true, FT_SHORT, "WindSettingsID" }, + { true, FT_INT, "ZmpFileDataID" }, + { true, FT_INT, "Flags1" }, + { true, FT_INT, "Flags2" }, + }; + static DB2MetaField const fields[22] = + { + { FT_STRING_NOT_LOCALIZED, 1, true }, + { FT_STRING, 1, true }, + { FT_STRING, 1, true }, + { FT_STRING, 1, true }, + { FT_STRING, 1, true }, + { FT_STRING, 1, true }, + { FT_FLOAT, 2, true }, + { FT_BYTE, 1, false }, + { FT_BYTE, 1, true }, + { FT_BYTE, 1, false }, + { FT_SHORT, 1, false }, + { FT_SHORT, 1, true }, + { FT_SHORT, 1, true }, + { FT_SHORT, 1, true }, + { FT_SHORT, 1, true }, + { FT_BYTE, 1, false }, + { FT_FLOAT, 1, true }, + { FT_SHORT, 1, true }, + { FT_BYTE, 1, false }, + { FT_SHORT, 1, true }, + { FT_INT, 1, true }, + { FT_INT, 2, true }, }; - static char const* types = "ssssssiffhhhhhhhbbbbb"; - static uint8 const arraySizes[21] = { 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; - static DB2Meta const meta(-1, 21, 0xF568DF12, types, arraySizes, -1); - static DB2FileLoadInfo const loadInfo(&fields[0], std::extent<decltype(fields)>::value, &meta); + static DB2Meta meta(-1, 22, 0x503A3E58, fields, -1); + static DB2FileLoadInfo const loadInfo(&loadedFields[0], std::extent<decltype(loadedFields)>::value, &meta); return &loadInfo; } }; |