Compare commits

...

5 Commits

Author SHA1 Message Date
adrido d8e2635c9e
Create main.yml (#5)
* Create main.yml

* Fix osx build

* Add package contact
2020-04-17 15:36:50 +02:00
Unknown 38f664fcf6 Print the vendor in version string 2019-03-29 13:50:37 +01:00
Unknown 35b8324099 Fix Bug where scaled maps where not drawn correctly
fix #4
2019-03-29 04:25:20 +01:00
Unknown 665e0339a3 Use correct install dir on Linux 2019-03-24 14:37:41 +01:00
Unknown 9a8e5be8ee Fix filesystem on gcc < 9.0 2019-03-23 10:02:44 +01:00
8 changed files with 119 additions and 60 deletions

69
.github/workflows/main.yml vendored Normal file
View File

@ -0,0 +1,69 @@
# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
Build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
branch: [x86, x64]
type: [portable, installer]
include:
- os: windows-latest
vcpkg_cmd: zlib libpng sqlite3 libgd[core,png] --triplet x64-windows
cpack_install_generator: -G WIX
- os: ubuntu-latest
vcpkg_cmd: zlib libpng sqlite3 libgd[core,png] --triplet x64-linux
cpack_install_generator: -G DEB
- os: macos-latest
vcpkg_cmd: zlib libpng sqlite3 libgd[core,png] --triplet x64-osx
exclude:
- branch: x86
# TODO: make x86 work
# TODO: generate the triplet of branch and os
steps:
- name: 🐞 Remove chocolately
run: Remove-Item -Path $env:ChocolateyInstall\\bin\\cpack.exe -Force
shell: pwsh
if: "contains(matrix.os, 'windows')"
- name: Checkout
uses: actions/checkout@v1
- name: Run vcpkg
run: vcpkg install ${{matrix.vcpkg_cmd}}
- name: CMake
run: |
echo -DBUILD_PORTABLE=$PORTABLE
cmake -DCMAKE_TOOLCHAIN_FILE="$VCPKG_INSTALLATION_ROOT\scripts\buildsystems\vcpkg.cmake" -DCMAKE_BUILD_TYPE=Release . -DBUILD_PORTABLE=$PORTABLE
shell: bash
env:
PORTABLE: ${{contains(matrix.type, 'portable')}}
- name: Build
run: cmake --build . --config Release
- name: Package Install
run: cpack ${{matrix.cpack_install_generator}}
if: "!contains(matrix.type, 'portable')"
- name: Package Portable
run: cpack -G ZIP
if: "contains(matrix.type, 'portable')"
- uses: actions/upload-artifact@v2-preview
with:
name: Package
path: ./_CPack_Packages

View File

@ -1,3 +1,4 @@
dist: xenial
language: cpp
compiler:
- gcc

View File

@ -80,11 +80,10 @@ target_include_directories(Minetestmapper PRIVATE ${LIBGD_INCLUDE_DIR})
if(UNIX)
find_package(PNG REQUIRED)
find_package(Threads REQUIRED)
find_library(fs_LIBRARY NAMES stdc++fs)
if(fs_LIBRARY)
target_link_libraries(Minetestmapper fs_LIBRARY)
endif()
target_link_libraries(Minetestmapper PNG::PNG Threads::Threads ${CMAKE_DL_LIBS})
target_link_libraries(Minetestmapper $<$<AND:$<CXX_COMPILER_ID:GNU>,$<VERSION_LESS:$<CXX_COMPILER_VERSION>,9.0>>:stdc++fs>)
endif()
# Optional Libraries
@ -112,36 +111,42 @@ endif()
# Installation
###############################################################################
set(INSTALL_RUNTIME_DIR "bin")
if(WIN32)
set(INSTALL_RUNTIME_DIR ".")
endif()
set (CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION ".")
set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION ${INSTALL_RUNTIME_DIR})
include (InstallRequiredSystemLibraries)
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(CPACK_PACKAGE_INSTALL_DIRECTORY ${PROJECT_NAME})
set(CPACK_PACKAGE_VENDOR "Adrido")
set(CPACK_PACKAGE_CONTACT "https://github.com/adrido/")
set(CPACK_GENERATOR "ZIP")
include(CPack)
install(TARGETS Minetestmapper RUNTIME DESTINATION ".")
install(TARGETS Minetestmapper RUNTIME DESTINATION ${INSTALL_RUNTIME_DIR})
if(WIN32)
#copy required dlls to install dir
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Release/
DESTINATION .
DESTINATION ${INSTALL_RUNTIME_DIR}
CONFIGURATIONS Release
FILES_MATCHING PATTERN "*.dll")
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Debug/
DESTINATION .
DESTINATION ${INSTALL_RUNTIME_DIR}
CONFIGURATIONS Debug
FILES_MATCHING PATTERN "*.dll")
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo/
DESTINATION .
DESTINATION ${INSTALL_RUNTIME_DIR}
CONFIGURATIONS RelWithDebInfo
FILES_MATCHING PATTERN "*.dll")
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/MinSizeRel/
DESTINATION .
DESTINATION ${INSTALL_RUNTIME_DIR}
CONFIGURATIONS RelWithDebInfo
FILES_MATCHING PATTERN "*.dll")
endif(WIN32)
install(DIRECTORY "${PROJECT_SOURCE_DIR}/colors/" DESTINATION "colors/"
install(DIRECTORY "${PROJECT_SOURCE_DIR}/colors/" DESTINATION "${INSTALL_RUNTIME_DIR}/colors/"
FILES_MATCHING PATTERN "*.txt")

View File

@ -152,7 +152,7 @@ int Mapper::start(int argc, char *argv[]) {
return 0;
break;
case 'V':
cout << "Minetestmapper - Version-ID: " << PROJECT_VERSION_MAJOR << "." << PROJECT_VERSION_MINOR << std::endl;
cout << "Minetestmapper - Version-ID: " << PROJECT_VERSION << "("<<PACKAGE_VENDOR<<")" << std::endl;
return 0;
break;
case 'i':

View File

@ -8,11 +8,13 @@
*/
#include "PixelAttributes.h"
#include <cstring> // memcpy
using namespace std;
PixelAttribute::AlphaMixingMode PixelAttribute::m_mixMode = PixelAttribute::AlphaMixCumulative;
void PixelAttributes::setParameters(int width, int lines, int nextY, int scale, bool defaultEmpty)
{
freeAttributes();
@ -28,20 +30,13 @@ void PixelAttributes::setParameters(int width, int lines, int nextY, int scale,
m_firstUnshadedY = 0;
m_scale = scale;
PixelAttribute pa;
pa.m_a = 0;
pa.nextEmpty = false;
m_pixelAttributes = vector<vector<PixelAttribute>>(m_lineCount, vector<PixelAttribute>(m_width, PixelAttribute()));
m_pixelAttributes = vector<vector<PixelAttribute>>(m_lineCount, vector<PixelAttribute>(m_width, pa));
if (defaultEmpty) {
int emptyColumns = (16 / scale);
for (int i = 0; i < m_lineCount; i++) {
for (int j = 0; j < m_width; j += emptyColumns) {
m_pixelAttributes[i][j + 1].nextEmpty = true;
if (defaultEmpty)
for (int i = 0; i < m_lineCount; i++)
for (int j = 0; j < m_width; j++) {
m_pixelAttributes[i][j].nextEmpty = (j - 1) % (16 / scale) == 0;
}
}
}
}
void PixelAttributes::scroll(int keepY)
@ -50,19 +45,20 @@ void PixelAttributes::scroll(int keepY)
if (scroll > 0) {
int i;
for (i = m_previousLine; i + scroll <= m_lastLine; i++) {
auto tmp = m_pixelAttributes[i];
m_pixelAttributes[i] = m_pixelAttributes[i + scroll];
m_pixelAttributes[i + scroll] = tmp;
m_pixelAttributes[i].swap(m_pixelAttributes[i + scroll]);
}
size_t lineLength = m_width * sizeof(PixelAttribute);
for (; i <= m_lastLine; ++i) {
m_pixelAttributes[i] = m_pixelAttributes[m_emptyLine];
// TODO: get rid of memcpy. This seems non-trivial.
memcpy(m_pixelAttributes[i].data(), m_pixelAttributes[m_emptyLine].data(), lineLength);
}
m_firstY += scroll;
m_nextY = m_firstY;
m_firstUnshadedY -= scroll;
if (m_firstUnshadedY < m_firstY) m_firstUnshadedY = m_firstY;
if (m_firstUnshadedY < m_firstY)
m_firstUnshadedY = m_firstY;
}
}
@ -115,14 +111,14 @@ void PixelAttributes::renderShading(double emphasis, bool drawAlpha)
d = 3;
}
d = d * 12 / 255 * emphasis;
#define pixel (m_pixelAttributes[y][x])
#define pixel (m_pixelAttributes[y][x])
//PixelAttribute &pixel = m_pixelAttributes[y][x];
if (drawAlpha)
d = d * (1 - pixel.m_t);
pixel.m_r = colorSafeBounds(pixel.m_r + d);
pixel.m_g = colorSafeBounds(pixel.m_g + d);
pixel.m_b = colorSafeBounds(pixel.m_b + d);
#undef pixel
#undef pixel
}
}
m_firstUnshadedY = y - yCoord2Line(0);
@ -234,7 +230,7 @@ void PixelAttribute::mixUnder(const PixelAttribute &p)
m_h = p.m_h;
}
else if (m_a == 1)
; // Nothing to do: pixel is already fully opaque.
; // Nothing to do: pixel is already fully opaque.
else if ((m_mixMode & AlphaMixCumulative) == AlphaMixCumulative || (m_mixMode == AlphaMixAverage && p.m_a == 1)) {
PixelAttribute pp(p);
#ifdef DEBUG
@ -287,16 +283,3 @@ void PixelAttribute::mixUnder(const PixelAttribute &p)
}
#endif
}
bool PixelAttribute::operator==(const PixelAttribute & p)
{
return m_n == p.m_n &&
m_h == p.m_h &&
m_t == p.m_t &&
m_a == p.m_a &&
m_r == p.m_r &&
m_g == p.m_g &&
m_b == p.m_b &&
nextEmpty == p.nextEmpty;
}

View File

@ -17,7 +17,8 @@
#include <stdexcept>
#include <vector>
class PixelAttribute {
class PixelAttribute
{
public:
enum AlphaMixingMode {
AlphaMixDarkenBit = 0x01,
@ -27,10 +28,10 @@ public:
};
static void setMixMode(AlphaMixingMode mode);
PixelAttribute() = default;
// PixelAttribute(const PixelAttribute &p);
// PixelAttribute(const PixelAttribute &p);
PixelAttribute(const Color &color, double height);
PixelAttribute(const ColorEntry &entry, double height);
bool nextEmpty{true};
bool nextEmpty{false};
double h() const { return m_h / (m_n ? m_n : 1); }
double t() const { return m_t / (m_n ? m_n : 1); }
double a() const { return m_a / (m_n ? m_n : 1); }
@ -51,19 +52,18 @@ public:
void normalize(double count = 0, Color defaultColor = Color(127, 127, 127));
void add(const PixelAttribute &p);
void mixUnder(const PixelAttribute &p);
bool operator==(const PixelAttribute &p);
bool operator!=(const PixelAttribute &p) { return !(*this == p); };
private:
static AlphaMixingMode m_mixMode;
double m_n{0};
double m_h{ std::numeric_limits<double>::quiet_NaN() };
double m_h{std::numeric_limits<double>::quiet_NaN()};
double m_t{0};
double m_a{0};
double m_r{0};
double m_g{0};
double m_b{0};
friend class PixelAttributes;
friend class PixelAttributes;
};
class PixelAttributes
@ -134,15 +134,15 @@ inline PixelAttribute &PixelAttributes::attribute(int y, int x)
// operator=(p);
//}
inline PixelAttribute::PixelAttribute(const Color &color, double height) :
nextEmpty(false), m_n(0), m_h(height), m_t(0), m_a(color.a/255.0),
m_r(color.r/255.0), m_g(color.g/255.0), m_b(color.b/255.0)
inline PixelAttribute::PixelAttribute(const Color &color, double height)
: nextEmpty(false), m_n(0), m_h(height), m_t(0), m_a(color.a / 255.0),
m_r(color.r / 255.0), m_g(color.g / 255.0), m_b(color.b / 255.0)
{
}
inline PixelAttribute::PixelAttribute(const ColorEntry &entry, double height) :
nextEmpty(false), m_n(0), m_h(height), m_t(entry.t/255.0), m_a(entry.a/255.0),
m_r(entry.r/255.0), m_g(entry.g/255.0), m_b(entry.b/255.0)
inline PixelAttribute::PixelAttribute(const ColorEntry &entry, double height)
: nextEmpty(false), m_n(0), m_h(height), m_t(entry.t / 255.0), m_a(entry.a / 255.0),
m_r(entry.r / 255.0), m_g(entry.g / 255.0), m_b(entry.b / 255.0)
{
}
@ -157,4 +157,3 @@ inline PixelAttribute &PixelAttribute::operator=(const PixelAttribute &p)
m_b = p.m_b;
return *this;
}

View File

@ -15,6 +15,7 @@ namespace fs = std::filesystem;
#include <sstream>
#include <stdexcept>
#include <iostream>
#include <ostream>
#include "PlayerAttributes.h"
using namespace std;
@ -28,7 +29,7 @@ PlayerAttributes::PlayerAttributes(const std::string &sourceDirectory)
if (!extractPlayersSqlite(playersPath)) {
#ifdef HAVE_FILESYSTEM
for (const auto &dirEntry : fs::directory_iterator(playersPath)) {
cout << dirEntry << std::endl;
cout << dirEntry.path().string() << std::endl;
//dirEntry.path().filename();
extractPlayer(dirEntry.path().string());

View File

@ -27,6 +27,7 @@
#define SPECIALBUILD @SPECIALBUILD@
#define BUILD_BRANCH "@BUILD_BRANCH@"
#define PRERELEASE @PRERELEASE@
#define PACKAGE_VENDOR "@CPACK_PACKAGE_VENDOR@"
/* Copyright string */
#cmakedefine PROJECT_COPYRIGHT "@PROJECT_COPYRIGHT@"