In this GitHub - RyroNZ/UE4MasterServer: This is a plugin for Unreal Engine 4 that adds server registration, deregistration etc with a master server. Plugin is a function that uses zlib to compress and decompress Bytes which i would like to have aviable in Blueprint.
Here are the mentioned functions :
TArray<uint8> UMasterServerFunctions::FStringToBinaryArray(FString InString)
{
TArray<uint8> BinaryArray;
for (int32 i = 0; i < InString.Len(); i++)
{
BinaryArray.Add(InString[i]);
}
return BinaryArray;
}
FString UMasterServerFunctions::BinaryArrayToFString(TArray<uint8> InBinaryArray)
{
return FString(UTF8_TO_TCHAR(InBinaryArray.GetData()));
}
FString UMasterServerFunctions::DecompressBytes(TArray<uint8> CompressedBinaryArray)
{
TArray<uint8> UncompressedBinaryArray;
UncompressedBinaryArray.SetNum(CompressedBinaryArray.Num() * 1032);
//int ret;
z_stream strm;
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
strm.avail_in = CompressedBinaryArray.Num();
strm.next_in = (Bytef *)CompressedBinaryArray.GetData();
strm.avail_out = UncompressedBinaryArray.Num();
strm.next_out = (Bytef *)UncompressedBinaryArray.GetData();
// the actual DE-compression work.
inflateInit(&strm);
inflate(&strm, Z_FINISH);
inflateEnd(&strm);
return BinaryArrayToFString(UncompressedBinaryArray);
}
TArray<uint8> UMasterServerFunctions::CompressBytes(FString UncompressedString)
{
TArray<uint8> UncompressedBinaryArray = FStringToBinaryArray(UncompressedString);
TArray<uint8> CompressedBinaryArray;
CompressedBinaryArray.SetNum(UncompressedBinaryArray.Num() * 1023, true);
//int ret;
z_stream strm;
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
strm.avail_in = UncompressedBinaryArray.Num();
strm.next_in = (Bytef *)UncompressedBinaryArray.GetData();
strm.avail_out = CompressedBinaryArray.Num();
strm.next_out = (Bytef *)CompressedBinaryArray.GetData();
// the actual compression work.
deflateInit(&strm, Z_BEST_COMPRESSION);
deflate(&strm, Z_FINISH);
deflateEnd(&strm);
// Shrink the array to minimum size
CompressedBinaryArray.RemoveAt(strm.total_out, CompressedBinaryArray.Num() - strm.total_out, true);
return CompressedBinaryArray;
}
Ive got a MyPlugin template created from a while back where i have a couple functions blueprintcallable, and i thought i may be able to add theese aswell.
so i added the Zlib.h/inflate/deflate/zconf.h to my Plugin folder and copied the functions / includes
everything fine so far … i can compile but when i try to use one of the functions
http://i.imgur.com/mTiSSJP.png
All i tried so far resulted in either compilation error or the same target requirement ( compilation Error says that an illegal nonstatic memberfunction was called)
I know im doing something fundamentally wrong im unfortunatly unfamiliar with coding / c++ but still refuse to just not try in situations like this. Can someone help me in the right direction?