mirror of
https://github.com/electronicarts/CNC_TS_and_RA2_Mission_Editor.git
synced 2025-04-30 09:01:41 -04:00
Fix/overlay refactor mismatch (#101)
* fixed overlay encoding result differs from original . * some type adjustments to silence compile warning, UT case added . * escape Chinese comments . * added compile dependency of UT on MissionPackLib .
This commit is contained in:
parent
87d35212f7
commit
9b24232f2e
13 changed files with 214 additions and 76 deletions
82
3rdParty/xcc/misc/shp_decode.cpp
vendored
82
3rdParty/xcc/misc/shp_decode.cpp
vendored
|
@ -198,32 +198,32 @@ static void write_v80(byte v, int count, byte*& d)
|
|||
}
|
||||
}
|
||||
|
||||
void get_same(const byte* s, const byte* r, const byte* s_end, const byte*& p, int& cb_p)
|
||||
void get_same(const byte* src_start, const byte* src_pos, const byte* src_end, const byte*& p_same_content_beg, int& same_content_len)
|
||||
{
|
||||
// init
|
||||
p = nullptr;
|
||||
cb_p = 0;
|
||||
p_same_content_beg = nullptr;
|
||||
same_content_len = 0;
|
||||
|
||||
while (s++ < s_end) {
|
||||
while (src_start++ < src_end) {
|
||||
// reset round
|
||||
int counted = 0;
|
||||
// early safe check
|
||||
if (s >= r) {
|
||||
if (src_start >= src_pos) {
|
||||
break;
|
||||
}
|
||||
while (s[counted] == r[counted]) {
|
||||
while (src_start[counted] == src_pos[counted]) {
|
||||
// match begins, early safe check
|
||||
if (s + counted >= s_end) {
|
||||
if (src_start + counted >= src_end) {
|
||||
break;
|
||||
}
|
||||
if (r + counted >= s_end) {
|
||||
if (src_pos + counted >= src_end) {
|
||||
break;
|
||||
}
|
||||
counted++;
|
||||
}
|
||||
if (counted > cb_p) {
|
||||
cb_p = counted;
|
||||
p = s;
|
||||
if (counted >= same_content_len) {
|
||||
same_content_len = counted;
|
||||
p_same_content_beg = src_start;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -274,41 +274,47 @@ static void flush_c1(byte*& w, const byte* r, const byte*& copy_from)
|
|||
}
|
||||
}
|
||||
|
||||
int encode80(const byte* s, byte* d, int cb_s)
|
||||
int encode80(const byte* src, byte* dst, const size_t src_len)
|
||||
{
|
||||
//using std::cout;
|
||||
//using std::endl;
|
||||
// full compression
|
||||
const byte* s_end = s + cb_s;
|
||||
const byte* r = s;
|
||||
byte* w = d;
|
||||
const byte* src_end = src + src_len;
|
||||
const byte* src_pos = src;
|
||||
byte* w = dst;
|
||||
const byte* copy_from = NULL;
|
||||
while (r < s_end) {
|
||||
const byte* p;
|
||||
int cb_p;
|
||||
int t = get_run_length(r, s_end);
|
||||
get_same(s, r, s_end, p, cb_p);
|
||||
if (t < cb_p && cb_p > 2) {
|
||||
flush_c1(w, r, copy_from);
|
||||
if (cb_p - 3 < 8 && r - p < 0x1000)
|
||||
write80_c0(w, cb_p, r - p);
|
||||
else if (cb_p - 3 < 0x3e)
|
||||
write80_c2(w, cb_p, p - s);
|
||||
while (src_pos < src_end) {
|
||||
const byte* p_block_begin;
|
||||
int block_len;
|
||||
int same_data_len = get_run_length(src_pos, src_end);
|
||||
get_same(src, src_pos, src_end, p_block_begin, block_len);
|
||||
|
||||
//cout << "p_block_begin:" << std::showbase << std::hex << (std::uintptr_t)p_block_begin << ", block_len:" << block_len << endl;
|
||||
if (same_data_len < block_len && block_len > 2) {
|
||||
flush_c1(w, src_pos, copy_from);
|
||||
if (block_len - 3 < 8 && src_pos - p_block_begin < 0x1000)
|
||||
write80_c0(w, block_len, src_pos - p_block_begin);
|
||||
else if (block_len - 3 < 0x3e)
|
||||
write80_c2(w, block_len, p_block_begin - src);
|
||||
else
|
||||
write80_c4(w, cb_p, p - s);
|
||||
r += cb_p;
|
||||
} else {
|
||||
if (t < 3) {
|
||||
write80_c4(w, block_len, p_block_begin - src);
|
||||
src_pos += block_len;
|
||||
}
|
||||
else {
|
||||
if (same_data_len < 3) {
|
||||
if (!copy_from)
|
||||
copy_from = r;
|
||||
} else {
|
||||
flush_c1(w, r, copy_from);
|
||||
write80_c3(w, t, *r);
|
||||
copy_from = src_pos;
|
||||
}
|
||||
r += t;
|
||||
else {
|
||||
flush_c1(w, src_pos, copy_from);
|
||||
write80_c3(w, same_data_len, *src_pos);
|
||||
}
|
||||
src_pos += same_data_len;
|
||||
}
|
||||
}
|
||||
flush_c1(w, r, copy_from);
|
||||
flush_c1(w, src_pos, copy_from);
|
||||
write80_c1(w, 0, NULL);
|
||||
return w - d;
|
||||
return w - dst;
|
||||
}
|
||||
|
||||
int decode80(const byte source[], byte dest[])
|
||||
|
@ -683,7 +689,7 @@ int encode5(const byte* s, byte* d, int cb_s, int format)
|
|||
return w - d;
|
||||
}
|
||||
|
||||
int decode5(const byte* s, byte* d, int cb_s, int format)
|
||||
int decode5(const byte* s, byte* d, const size_t cb_s, int format)
|
||||
{
|
||||
const byte* r = s;
|
||||
const byte* r_end = s + cb_s;
|
||||
|
|
4
3rdParty/xcc/misc/shp_decode.h
vendored
4
3rdParty/xcc/misc/shp_decode.h
vendored
|
@ -21,12 +21,12 @@
|
|||
#include <virtual_binary.h>
|
||||
|
||||
int decode3(const byte* s, byte* d, int cx, int cy);
|
||||
int decode5(const byte* s, byte* d, int cb_s, int format);
|
||||
int decode5(const byte* s, byte* d, const size_t cb_s, int format);
|
||||
int encode5(const byte* s, byte* d, int cb_s, int format);
|
||||
int decode5s(const byte* s, byte* d, int cb_s);
|
||||
int encode5s(const byte* s, byte* d, int cb_s);
|
||||
Cvirtual_binary decode64(data_ref);
|
||||
Cvirtual_binary encode64(data_ref);
|
||||
int decode80(const byte image_in[], byte image_out[]);
|
||||
int encode80(const byte* s, byte* d, int cb_s);
|
||||
int encode80(const byte* s, byte* d, const size_t cb_s);
|
||||
int get_run_length(const byte* r, const byte* s_end);
|
||||
|
|
|
@ -17,6 +17,9 @@ EndProject
|
|||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XCC Library", "3rdParty\xcc\Library\XCC Library.vcxproj", "{5E445578-CB45-4D82-9A1C-FC7D3E8D866A}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UnitTest", "UnitTest\UnitTest.vcxproj", "{75E18879-7564-4A2C-8C00-393A5A17171F}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{DEB40EF0-E215-4C2F-A0AD-3742E2E01A8C} = {DEB40EF0-E215-4C2F-A0AD-3742E2E01A8C}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CncVxlRenderText", "3rdParty\CncVxlRender\CncVxlRenderText.vcxproj", "{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}"
|
||||
EndProject
|
||||
|
|
|
@ -898,8 +898,8 @@ void CMapData::Unpack()
|
|||
ovrl += val;
|
||||
}
|
||||
|
||||
//BYTE values[262144];
|
||||
const size_t VALUESIZE = 262144;
|
||||
//BYTE values[overlayDataCapacity];
|
||||
const size_t VALUESIZE = overlayDataCapacity;
|
||||
std::vector<BYTE> values(VALUESIZE, 0xFF);
|
||||
int hexlen;
|
||||
|
||||
|
@ -1068,7 +1068,7 @@ void CMapData::Pack(BOOL bCreatePreview, BOOL bCompression)
|
|||
}
|
||||
|
||||
|
||||
BYTE* values = new(BYTE[262144]);
|
||||
BYTE* values = new(BYTE[overlayDataCapacity]);
|
||||
BYTE* hexpacked = NULL; // must be freed!
|
||||
|
||||
|
||||
|
@ -1079,11 +1079,11 @@ void CMapData::Pack(BOOL bCreatePreview, BOOL bCompression)
|
|||
errstream << "Packing overlay" << endl;
|
||||
errstream.flush();
|
||||
|
||||
for (i = 0; i < 262144; i++) {
|
||||
for (i = 0; i < overlayDataCapacity; i++) {
|
||||
values[i] = m_Overlay[i];
|
||||
}
|
||||
|
||||
int hexpackedLen = FSunPackLib::EncodeF80(values, 262144, 32, &hexpacked);
|
||||
int hexpackedLen = FSunPackLib::EncodeF80(values, overlayDataCapacity, 32, &hexpacked);
|
||||
base64 = FSunPackLib::EncodeBase64(hexpacked, hexpackedLen);
|
||||
|
||||
|
||||
|
@ -1091,6 +1091,9 @@ void CMapData::Pack(BOOL bCreatePreview, BOOL bCompression)
|
|||
|
||||
i = 0;
|
||||
pos = 0;
|
||||
|
||||
auto const b64StrLen = strlen(reinterpret_cast<const char*>(base64));
|
||||
|
||||
while (TRUE) {
|
||||
i++;
|
||||
char cLine[50];
|
||||
|
@ -1098,8 +1101,8 @@ void CMapData::Pack(BOOL bCreatePreview, BOOL bCompression)
|
|||
char str[200];
|
||||
memset(str, 0, 200);
|
||||
WORD cpysize = 70;
|
||||
if (pos + cpysize > strlen((char*)base64)) {
|
||||
cpysize = strlen((char*)base64) - pos;
|
||||
if (pos + cpysize > b64StrLen) {
|
||||
cpysize = b64StrLen - pos;
|
||||
}
|
||||
memcpy(str, &base64[pos], cpysize);
|
||||
if (strlen(str) > 0) {
|
||||
|
@ -1121,16 +1124,14 @@ void CMapData::Pack(BOOL bCreatePreview, BOOL bCompression)
|
|||
errstream << "Pack overlaydata" << endl;
|
||||
errstream.flush();
|
||||
|
||||
for (i = 0; i < 262144; i++) {
|
||||
values[i] = m_OverlayData[i];
|
||||
}
|
||||
memcpy(values, m_OverlayData, overlayDataCapacity);
|
||||
|
||||
hexpacked = NULL;
|
||||
|
||||
errstream << "Format80" << endl;
|
||||
errstream.flush();
|
||||
|
||||
hexpackedLen = FSunPackLib::EncodeF80(values, 262144, 32, &hexpacked);
|
||||
hexpackedLen = FSunPackLib::EncodeF80(values, overlayDataCapacity, 32, &hexpacked);
|
||||
|
||||
|
||||
errstream << "Base64" << endl;
|
||||
|
@ -1148,15 +1149,16 @@ void CMapData::Pack(BOOL bCreatePreview, BOOL bCompression)
|
|||
i++;
|
||||
char cLine[50];
|
||||
itoa(i, cLine, 10);
|
||||
char str[200];
|
||||
memset(str, 0, 200);
|
||||
|
||||
WORD cpysize = 70;
|
||||
if (pos + cpysize > strlen((char*)base64)) {
|
||||
cpysize = strlen((char*)base64) - pos;
|
||||
}
|
||||
memcpy(str, &base64[pos], cpysize);
|
||||
if (strlen(str) > 0) {
|
||||
m_mapfile.SetString("OverlayDataPack", cLine, str);
|
||||
|
||||
CString str(reinterpret_cast<const char*>(base64 + pos), cpysize);
|
||||
|
||||
if (str.GetLength() > 0) {
|
||||
m_mapfile.SetString("OverlayDataPack", cLine, std::move(str));
|
||||
}
|
||||
if (cpysize < 70) {
|
||||
break;
|
||||
|
@ -1299,13 +1301,13 @@ void CMapData::Pack(BOOL bCreatePreview, BOOL bCompression)
|
|||
|
||||
void CMapData::ClearOverlayData()
|
||||
{
|
||||
memset(m_OverlayData, 0x0, 262144);
|
||||
memset(m_OverlayData, 0x0, overlayDataCapacity);
|
||||
// Pack();
|
||||
}
|
||||
|
||||
void CMapData::ClearOverlay()
|
||||
{
|
||||
memset(m_Overlay, 0xFF, 262144);
|
||||
memset(m_Overlay, 0xFF, overlayDataCapacity);
|
||||
// Pack();
|
||||
}
|
||||
|
||||
|
@ -1314,7 +1316,7 @@ void CMapData::SetOverlayAt(DWORD dwPos, BYTE bValue)
|
|||
int y = dwPos / m_IsoSize;
|
||||
int x = dwPos % m_IsoSize;
|
||||
|
||||
if (y + x * 512 > 262144 || dwPos > m_IsoSize * m_IsoSize) return;
|
||||
if (y + x * 512 > overlayDataCapacity || dwPos > m_IsoSize * m_IsoSize) return;
|
||||
|
||||
BYTE& ovrl = m_Overlay[y + x * 512];
|
||||
BYTE& ovrld = m_OverlayData[y + x * 512];
|
||||
|
@ -1360,7 +1362,7 @@ void CMapData::SetOverlayDataAt(DWORD dwPos, BYTE bValue)
|
|||
int y = dwPos / m_IsoSize;
|
||||
int x = dwPos % m_IsoSize;
|
||||
|
||||
if (y + x * 512 > 262144 || dwPos > m_IsoSize * m_IsoSize) return;
|
||||
if (y + x * 512 > overlayDataCapacity || dwPos > m_IsoSize * m_IsoSize) return;
|
||||
|
||||
BYTE& ovrl = m_Overlay[y + x * 512];
|
||||
BYTE& ovrld = m_OverlayData[y + x * 512];
|
||||
|
|
|
@ -484,8 +484,11 @@ private:
|
|||
#ifdef SMUDGE_SUPP
|
||||
map<CString, int> smudgeid;
|
||||
#endif
|
||||
BYTE m_Overlay[262144]; // overlay byte values (extracted)
|
||||
BYTE m_OverlayData[262144]; // overlay data byte values (extracted)
|
||||
|
||||
static constexpr size_t overlayDataCapacity = 262144;
|
||||
|
||||
BYTE m_Overlay[overlayDataCapacity]; // overlay byte values (extracted)
|
||||
BYTE m_OverlayData[overlayDataCapacity]; // overlay data byte values (extracted)
|
||||
BYTE* m_mfd; // map field data buffer
|
||||
DWORD dwIsoMapSize;
|
||||
CIniFile m_mapfile;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
<XccVcpkgDirTriplet>$(XccDir)\vcpkg_installed\$(Platform)-windows\$(Platform)-windows</XccVcpkgDirTriplet>
|
||||
<XccVcpkgDir>$(XccVcpkgDirTriplet)\debug</XccVcpkgDir>
|
||||
<VxlLibDir>$(SolutionDir)$(Platform)\Debug</VxlLibDir>
|
||||
<SchemaType>Debug</SchemaType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<DistributionFolder>$(MSBuildThisFileDirectory)\..\..\dist\$(DistributionName)</DistributionFolder>
|
||||
<OutDir>$(DistributionFolder)\</OutDir>
|
||||
<OutDir>$(DistributionFolder)\</OutDir>
|
||||
<TestOutDir>$(MSBuildThisFileDirectory)\..\..\$(Platform)\$(SchemaType)</TestOutDir>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<!--<XccVcpkgLic Include="$(XccVcpkgDirTriplet)\share\boost-config\copyright"><Dest>boost\license.txt</Dest></XccVcpkgLic>-->
|
||||
|
@ -30,6 +31,9 @@
|
|||
<Target Name="CopyDllFiles" AfterTargets="Build" BeforeTargets="BuildAndZipDistribution">
|
||||
<Copy SourceFiles="@(XccVcpkgBin)" DestinationFolder="$(OutDir)" />
|
||||
</Target>
|
||||
<Target Name="CopyDllFilesForUT" AfterTargets="Build" BeforeTargets="BuildAndZipDistribution">
|
||||
<Copy SourceFiles="@(XccVcpkgBin)" DestinationFolder="$(TestOutDir)" />
|
||||
</Target>
|
||||
<Target Name="CopyVxlLibDll" AfterTargets="Build" BeforeTargets="BuildAndZipDistribution">
|
||||
<Copy SourceFiles="@(VxlLibBin)" DestinationFolder="$(OutDir)" />
|
||||
</Target>
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
<XccVcpkgDirTriplet>$(XccDir)\vcpkg_installed\$(Platform)-windows\$(Platform)-windows</XccVcpkgDirTriplet>
|
||||
<XccVcpkgDir>$(XccVcpkgDirTriplet)</XccVcpkgDir>
|
||||
<VxlLibDir>$(SolutionDir)$(Platform)\Release</VxlLibDir>
|
||||
<SchemaType>Release</SchemaType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
|
|
|
@ -171,7 +171,7 @@ namespace FSunPackLib
|
|||
extern "C" int last_succeeded_operation = 0;
|
||||
|
||||
|
||||
BYTE* EncodeBase64(BYTE* sp, UINT len)
|
||||
BYTE* EncodeBase64(BYTE* sp, const size_t len)
|
||||
{
|
||||
auto encoded = encode64(data_ref(sp, std::size_t(len)));
|
||||
// for now make a copy, we might refactor this
|
||||
|
@ -189,13 +189,13 @@ namespace FSunPackLib
|
|||
|
||||
|
||||
|
||||
INT EncodeF80(BYTE* sp, UINT len, UINT nSections, BYTE** dest)
|
||||
size_t EncodeF80(BYTE* sp, size_t len, UINT nSections, BYTE** dest)
|
||||
{
|
||||
*dest = new(BYTE[len * 4]); // as large as sp, to make sure it works
|
||||
|
||||
BYTE* data = *dest;
|
||||
|
||||
int length = len / nSections;
|
||||
auto const length = len / nSections;
|
||||
// each section has this length
|
||||
|
||||
#ifdef DBG2
|
||||
|
@ -210,11 +210,11 @@ namespace FSunPackLib
|
|||
WriteFile(hOut, out.data(), out.size(), &dw, NULL);
|
||||
#endif
|
||||
|
||||
UINT i;
|
||||
UINT DP = 0;
|
||||
UINT SP = 0;
|
||||
size_t i;
|
||||
size_t DP = 0;
|
||||
size_t SP = 0;
|
||||
for (i = 0; i < nSections; i++) {
|
||||
UINT packLen = encode80(&sp[SP], &data[DP + 4], length); //ConvertToF80(&sp[SP], length, &data[DP+4]);
|
||||
const size_t packLen = encode80(&sp[SP], &data[DP + 4], length); //ConvertToF80(&sp[SP], length, &data[DP+4]);
|
||||
|
||||
memcpy(&data[DP], &packLen, 3);
|
||||
DP += 3;
|
||||
|
@ -255,7 +255,7 @@ namespace FSunPackLib
|
|||
return DP;
|
||||
}
|
||||
|
||||
bool DecodeF80(const BYTE* const sp, const UINT SourceLength, std::vector<BYTE>& dp, const std::size_t max_size)
|
||||
bool DecodeF80(const BYTE* const sp, const size_t SourceLength, std::vector<BYTE>& dp, const std::size_t max_size)
|
||||
{
|
||||
static_assert(4 == sizeof(t_pack_section_header));
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ namespace FSunPackLib
|
|||
len - length of hex data
|
||||
Returns a poINTer to the base64 data. Caller must free this memory.
|
||||
*/
|
||||
BYTE* EncodeBase64(BYTE* sp, UINT len);
|
||||
BYTE* EncodeBase64(BYTE* sp, const size_t len);
|
||||
/*
|
||||
Converts Base64 data to hex data.
|
||||
sp - source poINTer
|
||||
|
@ -135,7 +135,7 @@ namespace FSunPackLib
|
|||
dest - poINTer to dest poINTer. Function allocates memory, caller must free this memory.
|
||||
Returns the length of the packed data.
|
||||
*/
|
||||
INT EncodeF80(BYTE* sp, UINT len, UINT nSections, BYTE** dest);
|
||||
size_t EncodeF80(BYTE* sp, size_t len, UINT nSections, BYTE** dest);
|
||||
|
||||
/*
|
||||
Extracts a simple format 80 pack like the Overlay & OverlayData-Pack
|
||||
|
@ -146,7 +146,7 @@ namespace FSunPackLib
|
|||
dp - dest buffer
|
||||
max_size - maximum allowed destination size
|
||||
*/
|
||||
bool DecodeF80(const BYTE* sp, UINT SourceLength, std::vector<BYTE>& dp, std::size_t max_size);
|
||||
bool DecodeF80(const BYTE* sp, size_t SourceLength, std::vector<BYTE>& dp, std::size_t max_size);
|
||||
|
||||
// IsoMapPack5
|
||||
/*
|
||||
|
|
112
UnitTest/Serde_Test.cpp
Normal file
112
UnitTest/Serde_Test.cpp
Normal file
|
@ -0,0 +1,112 @@
|
|||
|
||||
#include "stdafx.h"
|
||||
#include "MissionEditorPackLib.h"
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
#if 0
|
||||
void printBin(const std::span<BYTE> input, const char* fileName)
|
||||
{
|
||||
std::ofstream file(fileName);
|
||||
std::ostringstream line_stream;
|
||||
size_t count = 0;
|
||||
|
||||
for (const auto& byte : input) {
|
||||
// to hex
|
||||
line_stream << std::setw(2) << std::setfill('0') << std::hex << static_cast<int>(byte) << " ";
|
||||
count++;
|
||||
|
||||
// switch line every 16 bytes
|
||||
if (count % 16 == 0) {
|
||||
file << line_stream.str() << std::endl;
|
||||
line_stream.str(""); // clear stream
|
||||
line_stream.clear(); // reset stream
|
||||
}
|
||||
}
|
||||
|
||||
// for the rest of bytes
|
||||
if (count % 16 != 0) {
|
||||
file << line_stream.str() << std::endl;
|
||||
}
|
||||
|
||||
file.close();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
TEST(SerdeTest, OverlayDataPackSerde)
|
||||
{
|
||||
static const char* rawInput[] = {
|
||||
R"(1=BQAAIP4AIACAeAAAIP5iDACBBP4EAAeBBv76AQCHBwsLCgoIB/75AQCHBgoLCgAKCv/6AW)",
|
||||
R"(2=cMgQgEAIMKCwj//AFpDP4DAAsGA//3AWkQMgAyA4EE//YBbw7+CQAL//UBaA6BCEP///gB)",
|
||||
R"(3=ZhLBYgyBCCwGgQv/+gFoEIEH/gQACv+SAW0YgIkAACD+WgAAgQP+DwAAgQj+BQALgQf+6A)",
|
||||
R"(4=EAhQQEAAIM/gwAAIEH/+4BawCBBv4DAACBBf/8AV4ChAgGAgnMXgSECggHBP/qAXEEzG4G)",
|
||||
R"(5=gwQHBxQU/ukBAIMHAAr/6QFwBNJFCIIKCv/9AV0KhAQICgj+/gEAggYGzVoA/usLAMtcAv)",
|
||||
R"(6=7zAQDKXQT+mQEAgFIAACD+VAAAgQT+BAAAggIJ/vkBAIEF/vsBAIEC/gMACv/6AVoA/v8F)",
|
||||
R"(7=AIMGCgz+/QEAgwUAAf//AVAM/v4BAP8AAk0QhAMKCgj+DwQAwlQA/5sHUg6AuwAAIP5UAg)",
|
||||
R"(8=CEBgoKDP78AQCBBSAD//QBYwAz+P/3AVQEEfQh+IQDCgoJ//wBWAb/+gFdAoEC//QBVwj+)",
|
||||
R"(9=CAAAgwEABP/mAWYE/gMAB4EG1jYK/+MBagT+AwALggoH0zcO/uMBAIEH/gUAC9M3Ev/qAU)",
|
||||
R"(10=4SUgH+BwAB//IBRxSCCwooBP4HAAL+EQAAgQL/2QFXAlIAgQvbORT/2QFNEIIECBoB/gMA)",
|
||||
R"(11=C4EI//YBPBqDAAAIyTQYziIcRgD/pwFPDIAVAQAg/icAAIMGCgzJHQD+BgALgQj+FAAAgQ)",
|
||||
R"(12=X+BAAAgQT+zwEAhAYJAAPIKQCBCP4GAAuCCgbUPgCEAgkGBv/PAVoAggAAyCkCggQINAKB)",
|
||||
R"(13=B/4TAACCAwoEF4UGCgoIB//JAVYAAf8B0YIKCMkpAP4FAAfWWwSBB9U5BP+4AXECJ9bJKQ)",
|
||||
R"(14=L+HgAAgQj+AwAK/8kBWgYR/CIA5isIBiCBAP/KAVkIa9YAB4EC4i4KggQHBAH/ywFaCoED)",
|
||||
R"(15=CdYIABYKgQHiAQ6CCAjUOgL/tAFwBv4GAAoD+YEG51sEwDQA0jwA/7cBdAqBAxAHggYJRg)",
|
||||
R"(16=biMxD/yQFaBGf7ggoKwSYE/vEBAFIA//UBLRTCTgT+BQAK//gBKhb+3wUAgAUAACD+ACAA)",
|
||||
R"(17=gAUAACD+ACAAgL4AACD+KAAAgQT+/QEAhAEGBwf+/gEAhggKCAYEAf76AQCHBwsKBwYHBv)",
|
||||
R"(18=/6AS8EhAgHBgoCBP73AQCDBAAIBAOCCwv/+AEuCIIEB/4DAASCCAoCAYEG//UBLQSBAxwF)",
|
||||
R"(19=gQACAIILCP/6AS0ECAEEAYEI//kBLgYSAP4EAAr/+gEzEIMICgoGBYMIAQH/+AEvAIEH/g)",
|
||||
R"(20=MACv/8ATAQggMHGAQMBv//ATcWgQf/+QEyDoIBCCIAHhH/+AE2EAoG/8kBNxqAGQAAIP4y)",
|
||||
R"(21=AACGAwAEAAgH/vwBAIQBAQQE/sgdAIAFAAAg/gAgAIAFAAAg/gAgAIAFAAAg/gAgAIAFAA)",
|
||||
R"(22=Ag/gAgAIAFAAAg/gAgAIAFAAAg/gAgAIAFAAAg/gAgAIAFAAAg/gAgAIAFAAAg/gAgAIAF)",
|
||||
R"(23=AAAg/gAgAIAFAAAg/gAgAIAFAAAg/gAgAIAFAAAg/gAgAIAFAAAg/gAgAIAFAAAg/gAgAI)",
|
||||
R"(24=AFAAAg/gAgAIAFAAAg/gAgAIAFAAAg/gAgAIAFAAAg/gAgAIAFAAAg/gAgAIAFAAAg/gAg)",
|
||||
R"(25=AIAFAAAg/gAgAIA=)"
|
||||
};
|
||||
|
||||
std::stringstream input;
|
||||
std::string line;
|
||||
|
||||
for (auto const& line : rawInput) {
|
||||
size_t pos = std::string_view(line).find('=');
|
||||
if (pos != std::string::npos) {
|
||||
input << std::string_view(line).substr(pos + 1);
|
||||
}
|
||||
}
|
||||
|
||||
const std::string b64Input = input.str();
|
||||
|
||||
const size_t VALUESIZE = 262144;
|
||||
std::vector<BYTE> values(VALUESIZE, 0xFF);
|
||||
|
||||
std::vector<BYTE> hex;
|
||||
auto const hexlen = FSunPackLib::DecodeBase64(b64Input.data(), hex);
|
||||
FSunPackLib::DecodeF80(hex.data(), hexlen, values, VALUESIZE);
|
||||
values.resize(VALUESIZE, 0xFF); // fill rest
|
||||
|
||||
|
||||
//printBin(values, "output_x64.txt");
|
||||
|
||||
auto const encoded = [&values]
|
||||
{
|
||||
BYTE* hexpacked = nullptr;
|
||||
const size_t hexpackedLen = FSunPackLib::EncodeF80(values.data(), values.size(), 32, &hexpacked);
|
||||
|
||||
//printBin({ hexpacked , hexpackedLen }, "encoded_bin_x64.txt");
|
||||
|
||||
|
||||
auto const base64 = FSunPackLib::EncodeBase64(hexpacked, hexpackedLen);
|
||||
cout << endl
|
||||
<< "encoded:"
|
||||
<< endl
|
||||
<< base64
|
||||
<< endl;
|
||||
|
||||
delete[] hexpacked;
|
||||
return std::unique_ptr<BYTE>(base64);
|
||||
} ();
|
||||
|
||||
ASSERT_EQ(b64Input.size(), strlen(reinterpret_cast<char*>(encoded.get())));
|
||||
ASSERT_TRUE(0 == memcmp(encoded.get(), b64Input.data(), b64Input.size()));
|
||||
}
|
|
@ -112,7 +112,8 @@
|
|||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>$(SolutionDir)googletest\x64\lib\$(Configuration)\*.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>$(SolutionDir)googletest\x64\lib\$(Configuration)\*.lib;$(SolutionDir)3rdParty\xcc\vcpkg_installed\x64-windows\x64-windows\lib\*.lib;XCC Library.lib;MissionEditorPackLibd.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)build\output\$(Configuration)-$(Platform)\lib;$(SolutionDir)build\output\$(Configuration)Minimal-$(Platform)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
|
@ -131,7 +132,8 @@
|
|||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>$(SolutionDir)googletest\x64\lib\$(Configuration)\*.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>$(SolutionDir)googletest\x64\lib\$(Configuration)\*.lib;$(SolutionDir)3rdParty\xcc\vcpkg_installed\x64-windows\x64-windows\lib\*.lib;XCC Library.lib;MissionEditorPackLib.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)build\output\$(Configuration)-$(Platform)\lib;$(SolutionDir)build\output\$(Configuration)Minimal-$(Platform)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
|
@ -139,6 +141,7 @@
|
|||
<ClCompile Include="..\MissionEditor\INIMeta.cpp" />
|
||||
<ClCompile Include="CIni_Meta_Test.cpp" />
|
||||
<ClCompile Include="CIni_Test.cpp" />
|
||||
<ClCompile Include="Serde_Test.cpp" />
|
||||
<ClCompile Include="UnitTest.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -30,6 +30,9 @@
|
|||
<ClCompile Include="..\MissionEditor\INIMeta.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Serde_Test.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="StdAfx.h">
|
||||
|
|
Loading…
Add table
Reference in a new issue