mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2026-04-04 14:56:24 +00:00
V1.6
Rewrite
This commit is contained in:
@@ -1,59 +1,49 @@
|
||||
///
|
||||
/// Created by Anonymous275 on 4/23/2020
|
||||
/// Created by Anonymous275 on 7/15/2020
|
||||
///
|
||||
|
||||
#include <string>
|
||||
#include "Zlib/zlib.h"
|
||||
#include <iostream>
|
||||
#include "include/zlib.h"
|
||||
|
||||
|
||||
void Print(const std::string&MSG){
|
||||
//std::cout << MSG << std::endl;
|
||||
}
|
||||
|
||||
std::string Compress(const std::string&Data){
|
||||
std::string b;
|
||||
b.resize(Data.length());
|
||||
#define Biggest 30000
|
||||
std::string Comp(std::string Data){
|
||||
char*C = new char[Biggest];
|
||||
memset(C, 0, Biggest);
|
||||
z_stream defstream;
|
||||
defstream.zalloc = Z_NULL;
|
||||
defstream.zfree = Z_NULL;
|
||||
defstream.opaque = Z_NULL;
|
||||
defstream.avail_in = (uInt)Data.length()+1;
|
||||
defstream.avail_in = (uInt)Data.length();
|
||||
defstream.next_in = (Bytef *)&Data[0];
|
||||
defstream.avail_out = (uInt)b.size();
|
||||
defstream.next_out = (Bytef *)&b[0];
|
||||
defstream.avail_out = Biggest;
|
||||
defstream.next_out = reinterpret_cast<Bytef *>(C);
|
||||
deflateInit(&defstream, Z_BEST_COMPRESSION);
|
||||
deflate(&defstream, Z_SYNC_FLUSH);
|
||||
deflate(&defstream, Z_FINISH);
|
||||
deflateEnd(&defstream);
|
||||
for(int i = int(b.length())-1;i >= 0;i--){
|
||||
if(b.at(i) != '\0'){
|
||||
b.resize(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return b;
|
||||
int TO = defstream.total_out;
|
||||
std::string Ret(TO,0);
|
||||
memcpy_s(&Ret[0],TO,C,TO);
|
||||
delete [] C;
|
||||
return Ret;
|
||||
}
|
||||
|
||||
std::string Decompress(const std::string&Data)
|
||||
{
|
||||
std::string c;
|
||||
c.resize(Data.size()*5);
|
||||
std::string DeComp(std::string Compressed){
|
||||
char*C = new char[Biggest];
|
||||
memset(C, 0, Biggest);
|
||||
z_stream infstream;
|
||||
infstream.zalloc = Z_NULL;
|
||||
infstream.zfree = Z_NULL;
|
||||
infstream.opaque = Z_NULL;
|
||||
infstream.avail_in = (uInt)(Data.c_str());
|
||||
infstream.next_in = (Bytef *)&Data[0];
|
||||
infstream.avail_out = (uInt)c.size();
|
||||
infstream.next_out = (Bytef *)&c[0];
|
||||
infstream.avail_in = Biggest;
|
||||
infstream.next_in = (Bytef *)(&Compressed[0]);
|
||||
infstream.avail_out = Biggest;
|
||||
infstream.next_out = (Bytef *)(C);
|
||||
inflateInit(&infstream);
|
||||
inflate(&infstream, Z_NO_FLUSH);
|
||||
inflate(&infstream, Z_SYNC_FLUSH);
|
||||
inflate(&infstream, Z_FINISH);
|
||||
inflateEnd(&infstream);
|
||||
for(int i = int(c.length())-1;i >= 0;i--){
|
||||
if(c.at(i) != '\0'){
|
||||
c.resize(i+1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return c;
|
||||
int TO = infstream.total_out;
|
||||
std::string Ret(TO,0);
|
||||
memcpy_s(&Ret[0],TO,C,TO);
|
||||
delete [] C;
|
||||
return Ret;
|
||||
}
|
||||
Reference in New Issue
Block a user