Compare commits
9 Commits
a48c4dcd33
...
e87435dc0b
Author | SHA1 | Date |
---|---|---|
BodgeMaster | e87435dc0b | |
BodgeMaster | e0cb220d37 | |
BodgeMaster | b5bb2f45c1 | |
BodgeMaster | f35211689e | |
BodgeMaster | 248175e0e1 | |
BodgeMaster | f563f96e87 | |
BodgeMaster | f20ed8b123 | |
BodgeMaster | 487d8f1636 | |
BodgeMaster | 34e19486d6 |
|
@ -35,20 +35,10 @@ fi
|
||||||
# dynamically linked libraries.
|
# dynamically linked libraries.
|
||||||
echo ">>> Building libs..."
|
echo ">>> Building libs..."
|
||||||
create_directory bin/lib
|
create_directory bin/lib
|
||||||
COMPILE_COMMANDS=(
|
for lib in $(find ./src/lib -name "*.cpp"); do
|
||||||
"$CXX_WITH_FLAGS -I ./include -fPIC -shared -o ./bin/lib/net/client.so ./src/lib/net/client.cpp"
|
COMPILE_COMMAND="$CXX_WITH_FLAGS -I ./include -fPIC -shared -o $(sed -e 's/^.\/src/.\/bin/;s/cpp$/so/' <<< $lib) $lib"
|
||||||
"$CXX_WITH_FLAGS -I ./include -fPIC -shared -o ./bin/lib/net/server.so ./src/lib/net/server.cpp"
|
echo $COMPILE_COMMAND
|
||||||
"$CXX_WITH_FLAGS -I ./include -fPIC -shared -o ./bin/lib/cli.so ./src/lib/cli.cpp"
|
$COMPILE_COMMAND &
|
||||||
"$CXX_WITH_FLAGS -I ./include -fPIC -shared -o ./bin/lib/file.so ./src/lib/file.cpp"
|
|
||||||
"$CXX_WITH_FLAGS -I ./include -fPIC -shared -o ./bin/lib/game/block.so ./src/lib/game/block.cpp"
|
|
||||||
"$CXX_WITH_FLAGS -I ./include -fPIC -shared -o ./bin/lib/game/entity.so ./src/lib/game/entity.cpp"
|
|
||||||
"$CXX_WITH_FLAGS -I ./include -fPIC -shared -o ./bin/lib/nbt.so ./src/lib/nbt.cpp"
|
|
||||||
"$CXX_WITH_FLAGS -I ./include -fPIC -shared -o ./bin/lib/region.so ./src/lib/region.cpp"
|
|
||||||
"$CXX_WITH_FLAGS -I ./include -fPIC -shared -l:libz.so -o ./bin/lib/zlibutil.so ./src/lib/zlibutil.cpp"
|
|
||||||
)
|
|
||||||
for command in ${!COMPILE_COMMANDS[@]}; do
|
|
||||||
echo "${COMPILE_COMMANDS[command]}"
|
|
||||||
${COMPILE_COMMANDS[command]} &
|
|
||||||
$WAIT_ANYWAY
|
$WAIT_ANYWAY
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -72,7 +62,7 @@ COMPILE_COMMANDS=(
|
||||||
"$CXX_WITH_FLAGS src/tools/dumpnbt.cpp -I./include -Lbin/lib -l:nbt.so -l:cli.so -o bin/tools/dumpnbt"
|
"$CXX_WITH_FLAGS src/tools/dumpnbt.cpp -I./include -Lbin/lib -l:nbt.so -l:cli.so -o bin/tools/dumpnbt"
|
||||||
"$CXX_WITH_FLAGS src/tools/arraydump.cpp -I./include -Lbin/lib -l:file.so -l:cli.so -o bin/tools/arraydump"
|
"$CXX_WITH_FLAGS src/tools/arraydump.cpp -I./include -Lbin/lib -l:file.so -l:cli.so -o bin/tools/arraydump"
|
||||||
"$CXX_WITH_FLAGS src/tools/baseconvert.cpp -I./include -Lbin/lib -l:cli.so -o bin/tools/baseconvert"
|
"$CXX_WITH_FLAGS src/tools/baseconvert.cpp -I./include -Lbin/lib -l:cli.so -o bin/tools/baseconvert"
|
||||||
"$CXX_WITH_FLAGS src/tools/zlibutil.cpp -I./include -Lbin/lib -l:cli.so -l:file.so -l:zlibutil.so -l:libz.so -o bin/tools/zlibutil"
|
"$CXX_WITH_FLAGS src/tools/zlibutil.cpp -I./include -Lbin/lib -l:cli.so -l:libz.so -l:file.so -o bin/tools/zlibutil"
|
||||||
"$CXX_WITH_FLAGS -pthread src/tools/hexnet.cpp -I./include -Lbin/lib -l:cli.so -l:libsockpp.so -o bin/tools/hexnet"
|
"$CXX_WITH_FLAGS -pthread src/tools/hexnet.cpp -I./include -Lbin/lib -l:cli.so -l:libsockpp.so -o bin/tools/hexnet"
|
||||||
"$CXX_WITH_FLAGS -DFOSSVG_DEBUG src/fossvg.cpp -I./include -Lbin/lib -l:file.so -l:cli.so -lglfw -lvulkan -o bin/fossvg"
|
"$CXX_WITH_FLAGS -DFOSSVG_DEBUG src/fossvg.cpp -I./include -Lbin/lib -l:file.so -l:cli.so -lglfw -lvulkan -o bin/fossvg"
|
||||||
"$CXX_WITH_FLAGS src/fossvgd.cpp -I./include -Lbin/lib -l:cli.so -o bin/fossvgd"
|
"$CXX_WITH_FLAGS src/fossvgd.cpp -I./include -Lbin/lib -l:cli.so -o bin/fossvgd"
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
echo "================================================================================"
|
|
||||||
echo -n "Testing \`zlibutil\`... "
|
|
||||||
|
|
||||||
|
|
||||||
echo "abc" >> testfile
|
|
||||||
|
|
||||||
bin/tools/zlibutil -c testfile
|
|
||||||
|
|
||||||
if [ "$(bin/tools/arraydump --binary testfile.compressed)" = "{0b01111000, 0b10011100, 0b01001011, 0b01001100, 0b01001010, 0b11100110, 0b00000010, 0b00000000, 0b00000011, 0b01111110, 0b00000001, 0b00110001}" ]; then
|
|
||||||
echo -n "Compression Test: PASS... "
|
|
||||||
else
|
|
||||||
echo -n "Compression Test: FAILED... "
|
|
||||||
fi
|
|
||||||
|
|
||||||
bin/tools/zlibutil -d testfile.compressed
|
|
||||||
|
|
||||||
if [ "$(bin/tools/arraydump --binary testfile.compressed.uncompressed)" = "{0b01100001, 0b01100010, 0b01100011, 0b00001010}" ]; then
|
|
||||||
echo "Decompression Test: PASS"
|
|
||||||
else
|
|
||||||
echo "Decompression Test: FAILED"
|
|
||||||
fi
|
|
||||||
|
|
||||||
rm testfile testfile.compressed testfile.compressed.uncompressed
|
|
||||||
|
|
||||||
echo "================================================================================"
|
|
|
@ -1,107 +0,0 @@
|
||||||
// Copyright 2022, FOSS-VG Developers and Contributers
|
|
||||||
//
|
|
||||||
// Author(s):
|
|
||||||
// Jocadbz
|
|
||||||
//
|
|
||||||
// This program is free software: you can redistribute it and/or modify it
|
|
||||||
// under the terms of the GNU Affero General Public License as published
|
|
||||||
// by the Free Software Foundation, version 3.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied
|
|
||||||
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
// See the GNU Affero General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
|
||||||
// version 3 along with this program.
|
|
||||||
// If not, see https://www.gnu.org/licenses/agpl-3.0.en.html
|
|
||||||
|
|
||||||
#include "../lib/zlibutil.hpp"
|
|
||||||
|
|
||||||
#include <bitset>
|
|
||||||
#include <iomanip>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
#include <tinyutf8/tinyutf8.h>
|
|
||||||
#include <zlib/zlib.h>
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
#include "../lib/cli.hpp"
|
|
||||||
#include "../lib/file.hpp"
|
|
||||||
|
|
||||||
#define EXIT_SUCCESS 0
|
|
||||||
#define EXIT_RUNTIME 1
|
|
||||||
#define EXIT_USAGE 2
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <fstream>
|
|
||||||
#include <vector>
|
|
||||||
#include <zlib.h>
|
|
||||||
|
|
||||||
#define CHUNK_SIZE 16384 // Chunk size
|
|
||||||
|
|
||||||
|
|
||||||
std::vector<char> compressData(const char* data, int size) {
|
|
||||||
z_stream zs;
|
|
||||||
memset(&zs, 0, sizeof(zs));
|
|
||||||
|
|
||||||
if (deflateInit(&zs, Z_DEFAULT_COMPRESSION) != Z_OK)
|
|
||||||
throw(std::runtime_error("deflateInit failed while compressing."));
|
|
||||||
|
|
||||||
zs.next_in = reinterpret_cast<Bytef*>(const_cast<char*>(data));
|
|
||||||
zs.avail_in = size;
|
|
||||||
|
|
||||||
int ret;
|
|
||||||
char outbuffer[CHUNK_SIZE];
|
|
||||||
std::vector<char> compressedData;
|
|
||||||
|
|
||||||
do {
|
|
||||||
zs.next_out = reinterpret_cast<Bytef*>(outbuffer);
|
|
||||||
zs.avail_out = CHUNK_SIZE;
|
|
||||||
|
|
||||||
ret = deflate(&zs, Z_FINISH);
|
|
||||||
|
|
||||||
if (compressedData.size() < zs.total_out)
|
|
||||||
compressedData.insert(compressedData.end(), outbuffer, outbuffer + CHUNK_SIZE - zs.avail_out);
|
|
||||||
} while (ret == Z_OK);
|
|
||||||
|
|
||||||
deflateEnd(&zs);
|
|
||||||
|
|
||||||
if (ret != Z_STREAM_END)
|
|
||||||
throw(std::runtime_error("Error while compressing: " + std::to_string(ret)));
|
|
||||||
|
|
||||||
return compressedData;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::vector<char> decompressData(const char* data, int size) {
|
|
||||||
z_stream zs;
|
|
||||||
memset(&zs, 0, sizeof(zs));
|
|
||||||
|
|
||||||
if (inflateInit(&zs) != Z_OK)
|
|
||||||
throw(std::runtime_error("inflateInit failed while decompressing."));
|
|
||||||
|
|
||||||
zs.next_in = reinterpret_cast<Bytef*>(const_cast<char*>(data));
|
|
||||||
zs.avail_in = size;
|
|
||||||
|
|
||||||
int ret;
|
|
||||||
char outbuffer[CHUNK_SIZE];
|
|
||||||
std::vector<char> decompressedData;
|
|
||||||
|
|
||||||
do {
|
|
||||||
zs.next_out = reinterpret_cast<Bytef*>(outbuffer);
|
|
||||||
zs.avail_out = CHUNK_SIZE;
|
|
||||||
|
|
||||||
ret = inflate(&zs, 0);
|
|
||||||
|
|
||||||
if (decompressedData.size() < zs.total_out)
|
|
||||||
decompressedData.insert(decompressedData.end(), outbuffer, outbuffer + CHUNK_SIZE - zs.avail_out);
|
|
||||||
} while (ret == Z_OK);
|
|
||||||
|
|
||||||
inflateEnd(&zs);
|
|
||||||
|
|
||||||
if (ret != Z_STREAM_END)
|
|
||||||
throw(std::runtime_error("Error while decompressing: " + std::to_string(ret)));
|
|
||||||
|
|
||||||
return decompressedData;
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
// Copyright 2024, FOSS-VG Developers and Contributers
|
|
||||||
//
|
|
||||||
// Author(s):
|
|
||||||
// Jocadbz
|
|
||||||
//
|
|
||||||
// This program is free software: you can redistribute it and/or modify it
|
|
||||||
// under the terms of the GNU Affero General Public License as published
|
|
||||||
// by the Free Software Foundation, version 3.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied
|
|
||||||
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
// See the GNU Affero General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
|
||||||
// version 3 along with this program.
|
|
||||||
// If not, see https://www.gnu.org/licenses/agpl-3.0.en.html
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#ifndef ZLIBUTIL_H
|
|
||||||
#define ZLIBUTIL_H
|
|
||||||
|
|
||||||
std::vector<char> compressData(const char* data, int size);
|
|
||||||
std::vector<char> decompressData(const char* data, int size);
|
|
||||||
|
|
||||||
#endif // ZLIBUTIL_H
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2024, FOSS-VG Developers and Contributers
|
// Copyright 2022, FOSS-VG Developers and Contributers
|
||||||
//
|
//
|
||||||
// Author(s):
|
// Author(s):
|
||||||
// Jocadbz
|
// Jocadbz
|
||||||
|
@ -23,18 +23,87 @@
|
||||||
#include <tinyutf8/tinyutf8.h>
|
#include <tinyutf8/tinyutf8.h>
|
||||||
#include <zlib/zlib.h>
|
#include <zlib/zlib.h>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
#include "../lib/cli.hpp"
|
#include "../lib/cli.hpp"
|
||||||
#include "../lib/file.hpp"
|
#include "../lib/file.hpp"
|
||||||
#include "../lib/zlibutil.hpp"
|
|
||||||
|
|
||||||
#define EXIT_SUCCESS 0
|
#define EXIT_SUCCESS 0
|
||||||
#define EXIT_RUNTIME 1
|
#define EXIT_RUNTIME 1
|
||||||
#define EXIT_USAGE 2
|
#define EXIT_USAGE 2
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <vector>
|
||||||
|
#include <zlib.h>
|
||||||
|
|
||||||
#define CHUNK_SIZE 16384 // Chunk size
|
#define CHUNK_SIZE 16384 // Chunk size
|
||||||
|
|
||||||
|
|
||||||
|
std::vector<char> compressData(const char* data, int size) {
|
||||||
|
z_stream zs;
|
||||||
|
memset(&zs, 0, sizeof(zs));
|
||||||
|
|
||||||
|
if (deflateInit(&zs, Z_DEFAULT_COMPRESSION) != Z_OK)
|
||||||
|
throw(std::runtime_error("deflateInit failed while compressing."));
|
||||||
|
|
||||||
|
zs.next_in = reinterpret_cast<Bytef*>(const_cast<char*>(data));
|
||||||
|
zs.avail_in = size;
|
||||||
|
|
||||||
|
int ret;
|
||||||
|
char outbuffer[CHUNK_SIZE];
|
||||||
|
std::vector<char> compressedData;
|
||||||
|
|
||||||
|
do {
|
||||||
|
zs.next_out = reinterpret_cast<Bytef*>(outbuffer);
|
||||||
|
zs.avail_out = CHUNK_SIZE;
|
||||||
|
|
||||||
|
ret = deflate(&zs, Z_FINISH);
|
||||||
|
|
||||||
|
if (compressedData.size() < zs.total_out)
|
||||||
|
compressedData.insert(compressedData.end(), outbuffer, outbuffer + CHUNK_SIZE - zs.avail_out);
|
||||||
|
} while (ret == Z_OK);
|
||||||
|
|
||||||
|
deflateEnd(&zs);
|
||||||
|
|
||||||
|
if (ret != Z_STREAM_END)
|
||||||
|
throw(std::runtime_error("Error while compressing: " + std::to_string(ret)));
|
||||||
|
|
||||||
|
return compressedData;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::vector<char> decompressData(const char* data, int size) {
|
||||||
|
z_stream zs;
|
||||||
|
memset(&zs, 0, sizeof(zs));
|
||||||
|
|
||||||
|
if (inflateInit(&zs) != Z_OK)
|
||||||
|
throw(std::runtime_error("inflateInit failed while decompressing."));
|
||||||
|
|
||||||
|
zs.next_in = reinterpret_cast<Bytef*>(const_cast<char*>(data));
|
||||||
|
zs.avail_in = size;
|
||||||
|
|
||||||
|
int ret;
|
||||||
|
char outbuffer[CHUNK_SIZE];
|
||||||
|
std::vector<char> decompressedData;
|
||||||
|
|
||||||
|
do {
|
||||||
|
zs.next_out = reinterpret_cast<Bytef*>(outbuffer);
|
||||||
|
zs.avail_out = CHUNK_SIZE;
|
||||||
|
|
||||||
|
ret = inflate(&zs, 0);
|
||||||
|
|
||||||
|
if (decompressedData.size() < zs.total_out)
|
||||||
|
decompressedData.insert(decompressedData.end(), outbuffer, outbuffer + CHUNK_SIZE - zs.avail_out);
|
||||||
|
} while (ret == Z_OK);
|
||||||
|
|
||||||
|
inflateEnd(&zs);
|
||||||
|
|
||||||
|
if (ret != Z_STREAM_END)
|
||||||
|
throw(std::runtime_error("Error while decompressing: " + std::to_string(ret)));
|
||||||
|
|
||||||
|
return decompressedData;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Finally, the main file
|
Finally, the main file
|
||||||
⠀⠀⠀⠀⠀⠀⠀⢠⣤⣄⣀⣠⣤⣶⣿⣯⣿⣽⣾⣷⣶⣶⡦⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
⠀⠀⠀⠀⠀⠀⠀⢠⣤⣄⣀⣠⣤⣶⣿⣯⣿⣽⣾⣷⣶⣶⡦⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
||||||
|
|
Loading…
Reference in New Issue