SkyPortal-plugin/Source/SkyPortal/Private/SkyPortalFigure.cpp
2024-09-26 15:11:24 +02:00

88 lines
1.8 KiB
C++

#pragma once
#include "SkyPortalFigure.h"
uint32 FigureData::GetFigureID()
{
if (ID == 0) {
int16_t OutFigureID = 0;
// The figure ID is stored in Block 1 of Sector 0 (i.e., data[1]), bytes 0 and 1 (16-bit integer, little-endian)
OutFigureID = data[1][0] | // Least significant byte
(data[1][1] << 8); // Most significant byte, shifted left by 8 bits
ID = OutFigureID;// Return the 16-bit figure ID
return OutFigureID;
}
else { return ID; }
/*
// Variant ID is stored in Block 0, bytes 4 to 5 (16-bit integer, little-endian)
OutVariantID = (DataBlock.blockdata[0][5] << 8) |
DataBlock.blockdata[0][4];
*/
};
/*
void FigureData::ReadData(uint8 index)
{
ClearData();
for (uint8 i = 0; i < 64; i++)
{
GEngine->GetEngineSubsystem<USkyPortalSubsystem>();
TArray<uint8> output = SkySubsystem->QueryBlock(index, i);
uint8[] blockData = new uint8[0x10];
Array.Copy(output, 3, blockData, 0, 16);
// block 1 is sometimes a duplicate of block 0
if (i == 1)
{
if (blockData.SequenceEqual(data[0]))
{
i -= 1;
continue;
}
}
Array.Copy(blockData, 0, data[i], 0, 16);
if (((i + 1) % 4 == 0) || i < 8)
{
Array.Copy(data[i], 0, decryptedData[i], 0, 16);
}
else
{
uint8[] hashIn = new byte[0x56];
data[0].CopyTo(hashIn, 0);
data[1].CopyTo(hashIn, 0x10);
hashIn[0x20] = i;
HASH_CONST.CopyTo(hashIn, 0x21);
uint8[] key = MD5.Create().ComputeHash(hashIn);
uint8[] decrypted = new byte[0x10];
using (Aes aesAlg = Aes.Create())
{
aesAlg.Key = key;
aesAlg.Mode = CipherMode.ECB;
aesAlg.Padding = PaddingMode.Zeros;
ICryptoTransform decryptor = aesAlg.CreateDecryptor();
decrypted = decryptor.TransformFinalBlock(data[i], 0, data[i].Length);
}
Array.Copy(decrypted, 0, decryptedData[i], 0, 16);
}
}
}
*/
void FigureData::ClearData()
{
}