toppler: unbreak and refactor (#387132)

Changed files
+176 -66
pkgs
by-name
games
toppler
top-level
+85
pkgs/by-name/to/toppler/gcc14.patch
···
+
diff --git a/Makefile b/Makefile
+
index a6a140f..fb9a8b9 100644
+
--- a/Makefile
+
+++ b/Makefile
+
@@ -518,7 +518,7 @@ src/po/%.po: _build/toppler.pot
+
# TODO dist and windist..
+
+
.PHONY: install
+
-install: toppler.dat toppler $(TRANSLATIONFILES_INST)
+
+install: toppler $(TRANSLATIONFILES_INST)
+
$(INSTALL) -m755 -d $(DESTDIR)$(PKGDATADIR)
+
$(INSTALL) -m755 -d $(DESTDIR)$(BINDIR)
+
$(INSTALL) -m755 -d $(DESTDIR)$(MANDIR)/man6
+
diff --git a/src/decl.cc b/src/decl.cc
+
index f80f83e..8a7bbd9 100644
+
--- a/src/decl.cc
+
+++ b/src/decl.cc
+
@@ -22,6 +22,7 @@
+
#include <SDL.h>
+
+
#include <cstdlib>
+
+#include <algorithm>
+
#include <cstring>
+
#include <sys/stat.h>
+
#include <unistd.h>
+
diff --git a/src/keyb.cc b/src/keyb.cc
+
index c3c13df..7d37847 100644
+
--- a/src/keyb.cc
+
+++ b/src/keyb.cc
+
@@ -156,7 +156,7 @@ static void handleEvents(void) {
+
mouse_button = e.button.button;
+
break;
+
case SDL_QUIT:
+
- fprintf(stderr, _("Wheee!!\n").c_str());
+
+ fprintf(stderr, "%s", _("Wheee!!\n").c_str());
+
exit(0);
+
break;
+
+
diff --git a/src/level.cc b/src/level.cc
+
index e1e2bb8..ac2faf3 100644
+
--- a/src/level.cc
+
+++ b/src/level.cc
+
@@ -27,6 +27,7 @@
+
#endif
+
+
#include "decl.h"
+
+#include <algorithm>
+
+
#ifdef _WIN32
+
#include <direct.h>
+
diff --git a/src/main.cc b/src/main.cc
+
index 522d041..ffc8e40 100644
+
--- a/src/main.cc
+
+++ b/src/main.cc
+
@@ -46,7 +46,7 @@ static bool parse_arguments(int argc, char *argv[]) {
+
if (parm >= '0' && parm <= '9') {
+
printf(_("Debug level is now %c.\n").c_str(), parm);
+
config.debug_level(parm - '0');
+
- } else printf(_("Illegal debug level value, using default.\n").c_str());
+
+ } else printf("%s", _("Illegal debug level value, using default.\n").c_str());
+
} else {
+
printhelp();
+
return false;
+
@@ -110,7 +110,7 @@ int main(int argc, char *argv[]) {
+
atexit(QuitFunction);
+
srand(time(0));
+
startgame();
+
- printf(_("Thanks for playing!\n").c_str());
+
+ printf("%s", _("Thanks for playing!\n").c_str());
+
SDL_ShowCursor(mouse);
+
SDL_Quit();
+
}
+
diff --git a/src/screen.cc b/src/screen.cc
+
index eb18543..ce23571 100644
+
--- a/src/screen.cc
+
+++ b/src/screen.cc
+
@@ -30,6 +30,8 @@
+
#include "keyb.h"
+
#include "configuration.h"
+
+
+#include <algorithm>
+
+
+
static SDL_Surface *display = nullptr;
+
static SDL_Window *sdlWindow = nullptr;
+
static SDL_Renderer *sdlRenderer = nullptr;
+91
pkgs/by-name/to/toppler/package.nix
···
+
{
+
lib,
+
stdenv,
+
fetchFromGitLab,
+
nix-update-script,
+
writableTmpDirAsHomeHook,
+
+
buildPackages,
+
pkg-config,
+
gettext,
+
povray,
+
imagemagick,
+
gimp,
+
+
sdl2-compat,
+
SDL2_mixer,
+
SDL2_image,
+
libpng,
+
zlib,
+
}:
+
+
stdenv.mkDerivation (finalAttrs: {
+
pname = "toppler";
+
version = "1.3";
+
+
src = fetchFromGitLab {
+
owner = "roever";
+
repo = "toppler";
+
rev = "v${finalAttrs.version}";
+
hash = "sha256-ecEaELu52Nmov/BD9VzcUw6wyWeHJcsKQkEzTnaW330=";
+
};
+
+
strictDeps = true;
+
enableParallelBuilding = true;
+
+
depsBuildBuild = [
+
buildPackages.stdenv.cc
+
pkg-config
+
sdl2-compat
+
SDL2_image
+
libpng
+
zlib
+
];
+
+
nativeBuildInputs = [
+
pkg-config
+
gettext
+
povray
+
imagemagick
+
gimp
+
# GIMP needs a writable home
+
writableTmpDirAsHomeHook
+
];
+
+
buildInputs = [
+
sdl2-compat
+
SDL2_mixer
+
zlib
+
];
+
+
patches = [
+
# Based on https://gitlab.com/roever/toppler/-/merge_requests/3
+
./gcc14.patch
+
];
+
+
makeFlags = [
+
"CXX_NATIVE=$(CXX_FOR_BUILD)"
+
"PKG_CONFIG_NATIVE=$(PKG_CONFIG_FOR_BUILD)"
+
"PREFIX=${placeholder "out"}"
+
];
+
+
preBuild = ''
+
# The `$` is escaped in `makeFlags` so using it for these parameters results in infinite recursion
+
makeFlagsArray+=(CXX=$CXX PKG_CONFIG=$PKG_CONFIG);
+
'';
+
+
passthru.updateScript = nix-update-script { };
+
+
meta = {
+
description = "Jump and run game, reimplementation of Tower Toppler/Nebulus";
+
homepage = "https://gitlab.com/roever/toppler";
+
license = with lib.licenses; [
+
gpl2Plus
+
# Makefile
+
gpl3Plus
+
];
+
maintainers = with lib.maintainers; [ fgaz ];
+
platforms = lib.platforms.all;
+
mainProgram = "toppler";
+
};
+
})
-62
pkgs/games/toppler/default.nix
···
-
{
-
lib,
-
stdenv,
-
fetchFromGitLab,
-
-
pkg-config,
-
gettext,
-
povray,
-
imagemagick,
-
gimp,
-
-
SDL2,
-
SDL2_mixer,
-
SDL2_image,
-
libpng,
-
zlib,
-
}:
-
-
stdenv.mkDerivation (finalAttrs: {
-
pname = "toppler";
-
version = "1.3";
-
-
src = fetchFromGitLab {
-
owner = "roever";
-
repo = "toppler";
-
rev = "v${finalAttrs.version}";
-
hash = "sha256-ecEaELu52Nmov/BD9VzcUw6wyWeHJcsKQkEzTnaW330=";
-
};
-
-
nativeBuildInputs = [
-
pkg-config
-
gettext
-
povray
-
imagemagick
-
gimp
-
];
-
-
buildInputs = [
-
SDL2
-
SDL2_mixer
-
SDL2_image
-
libpng
-
zlib
-
];
-
-
# GIMP needs a writable home
-
preBuild = ''
-
export HOME=$(mktemp -d)
-
'';
-
-
makeFlags = [ "PREFIX=$(out)" ];
-
-
hardeningDisable = [ "format" ];
-
-
meta = with lib; {
-
description = "Jump and run game, reimplementation of Tower Toppler/Nebulus";
-
homepage = "https://gitlab.com/roever/toppler";
-
license = licenses.gpl2Plus;
-
maintainers = with maintainers; [ fgaz ];
-
platforms = platforms.all;
-
};
-
})
-4
pkgs/top-level/all-packages.nix
···
tibia = pkgsi686Linux.callPackage ../games/tibia { };
-
toppler = callPackage ../games/toppler {
-
SDL2_image = SDL2_image_2_0;
-
};
-
speed_dreams = callPackage ../games/speed-dreams {
# Torcs wants to make shared libraries linked with plib libraries (it provides static).
# i686 is the only platform I know than can do that linking without plib built with -fPIC