maelstrom: initial add 3.0.6

Heavily inspired by [1]

[1] https://src.fedoraproject.org/cgit/rpms/Maelstrom.git/tree/

Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
This commit is contained in:
Andreas Müller
2019-02-12 19:52:29 +01:00
parent 3065caeaa5
commit 22b2b9098d
7 changed files with 418 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
From 6276f1388819e6f03e61133494e7c9d35c785e17 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20M=C3=BCller?= <schnitzeltony@gmail.com>
Date: Fri, 8 Feb 2019 19:11:19 +0100
Subject: [PATCH] Use pkg-config to find sdl
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Upstream-Status: Inappropriate [OE specific]
Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
---
configure.in | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/configure.in b/configure.in
index 0170f4b..a6f76ac 100644
--- a/configure.in
+++ b/configure.in
@@ -47,10 +47,7 @@ AC_SUBST(INETLIB)
dnl Check for SDL
SDL_VERSION=1.2.0
-AM_PATH_SDL($SDL_VERSION,
- :,
- AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
-)
+PKG_CHECK_MODULES([SDL], [sdl >= $SDL_VERSION], [HAVE_SDL=yes], [AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])])
CFLAGS="$CFLAGS $SDL_CFLAGS"
LIBS="$LIBS $SDL_LIBS"
--
2.20.1

View File

@@ -0,0 +1,87 @@
From 7d79950348bda1ad4c1282d3316bc25838047569 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20M=C3=BCller?= <schnitzeltony@gmail.com>
Date: Fri, 8 Feb 2019 19:25:04 +0100
Subject: [PATCH] buttonlist.h: Fix build with recent gcc's
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Stolen from [1]
[1] https://src.fedoraproject.org/cgit/rpms/Maelstrom.git/plain/Maelstrom-3.0.6-gcc34.patch
Upstream-Status: Pending
Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
---
buttonlist.h | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/buttonlist.h b/buttonlist.h
index 7bb37b3..39427f5 100644
--- a/buttonlist.h
+++ b/buttonlist.h
@@ -6,7 +6,17 @@
class ButtonList {
+
public:
+ typedef struct button {
+ /* Sensitive area */
+ Uint16 x1, y1;
+ Uint16 x2, y2;
+ void (*callback)(void);
+ struct button *next;
+ } button;
+ button button_list;
+
ButtonList() {
button_list.next = NULL;
}
@@ -16,7 +26,7 @@ public:
void Add_Button(Uint16 x, Uint16 y, Uint16 width, Uint16 height,
void (*callback)(void)) {
- struct button *belem;
+ button *belem;
for ( belem=&button_list; belem->next; belem=belem->next );
belem->next = new button;
@@ -30,7 +40,7 @@ public:
}
void Activate_Button(Uint16 x, Uint16 y) {
- struct button *belem;
+ button *belem;
for ( belem=button_list.next; belem; belem=belem->next ) {
if ( (x >= belem->x1) && (x <= belem->x2) &&
@@ -42,7 +52,7 @@ public:
}
void Delete_Buttons(void) {
- struct button *belem, *btemp;
+ button *belem, *btemp;
for ( belem=button_list.next; belem; ) {
btemp = belem;
@@ -51,14 +61,5 @@ public:
};
button_list.next = NULL;
}
-
-private:
- typedef struct button {
- /* Sensitive area */
- Uint16 x1, y1;
- Uint16 x2, y2;
- void (*callback)(void);
- struct button *next;
- } button;
- button button_list;
+
};
--
2.20.1

View File

@@ -0,0 +1,44 @@
From b051343fcac17227369bc4c7e0b0b00811500e24 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20M=C3=BCller?= <schnitzeltony@gmail.com>
Date: Tue, 12 Feb 2019 15:06:01 +0100
Subject: [PATCH] Fix install dir
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Upstream-Status: Inappropriate [Configuration]
Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
---
Makefile.am | 2 +-
configure.in | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/Makefile.am b/Makefile.am
index 4a9e949..a3194fc 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -65,7 +65,7 @@ DIST_SUBDIRS = $(SUBDIRS) Images Docs
# Special install rule for the game
install:
- make install_gamedata target=@GAME_INSTALLDIR@
+ make install_gamedata target=$(DESTDIR)@GAME_INSTALLDIR@
install_gamedata:
sh mkinstalldirs $(target)/
diff --git a/configure.in b/configure.in
index a6f76ac..e158dd2 100644
--- a/configure.in
+++ b/configure.in
@@ -105,6 +105,7 @@ case "$target" in
GAME_INSTALLDIR="\$(prefix)/games/$PACKAGE"
;;
esac
+GAME_INSTALLDIR="\$(datadir)/$PACKAGE"
AC_SUBST(GAME_INSTALLDIR)
CFLAGS="$CFLAGS -DLIBDIR=\\\"$GAME_INSTALLDIR\\\""
--
2.20.1

View File

@@ -0,0 +1,201 @@
From 94ac23023f12b540fb36d2a96a424387cf35339c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20M=C3=BCller?= <schnitzeltony@gmail.com>
Date: Wed, 13 Feb 2019 15:59:36 +0100
Subject: [PATCH] Rework score file handling
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Stolen from [1]
Upstream-Status: Pending
[1] https://src.fedoraproject.org/cgit/rpms/Maelstrom.git/tree/Maelstrom-3.0.6-setgid.patch
Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
---
main.cpp | 8 +++++
scores.cpp | 87 ++++++++++++++++++++++++++++++++++--------------------
scores.h | 1 +
3 files changed, 64 insertions(+), 32 deletions(-)
diff --git a/main.cpp b/main.cpp
index 7728c0b..851cf01 100644
--- a/main.cpp
+++ b/main.cpp
@@ -170,12 +170,20 @@ int main(int argc, char *argv[])
/* Command line flags */
int doprinthigh = 0;
int speedtest = 0;
+ gid_t gid;
Uint32 video_flags = SDL_SWSURFACE;
/* Normal variables */
SDL_Event event;
LibPath::SetExePath(argv[0]);
+ GetScoreFile();
+ gid = getgid();
+ if (setresgid(-1,gid,gid) != 0) {
+ error("Could not drop privleges. -- Exiting.\n");
+ exit(1);
+ }
+
#ifndef __WIN95__
/* The first thing we do is calculate our checksum */
(void) checksum();
diff --git a/scores.cpp b/scores.cpp
index 1633e8f..c8b53b5 100644
--- a/scores.cpp
+++ b/scores.cpp
@@ -4,6 +4,8 @@
*/
#ifdef unix
+#include <arpa/inet.h>
+#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#endif
@@ -15,11 +17,11 @@
#include "load.h"
#include "dialog.h"
-#define MAELSTROM_SCORES "Maelstrom-Scores"
+#define MAELSTROM_SCORES "/var/lib/games/Maelstrom-Scores"
#define NUM_SCORES 10 // Do not change this!
/* Everyone can write to scores file if defined to 0 */
-#define SCORES_PERMMASK 0
+#define SCORES_PERMMASK 002
#define CLR_DIALOG_WIDTH 281
#define CLR_DIALOG_HEIGHT 111
@@ -27,10 +29,31 @@
Bool gNetScores = 0;
Scores hScores[NUM_SCORES];
+int gScoreFile = -1;
+
+void GetScoreFile(void)
+{
+#ifdef unix
+ int omask;
+#endif
+ int f;
+
+#ifdef unix
+ omask=umask(SCORES_PERMMASK);
+#endif
+ f = open(MAELSTROM_SCORES,O_RDWR|O_CREAT);
+ if (f == -1)
+ f = open(MAELSTROM_SCORES,O_RDONLY);
+ if (f == -1)
+ error("Couldn't open score file %s.\n",MAELSTROM_SCORES);
+ gScoreFile = f;
+#ifdef unix
+ umask(omask);
+#endif
+}
+
void LoadScores(void)
{
- LibPath path;
- SDL_RWops *scores_src;
int i;
/* Try to load network scores, if we can */
@@ -44,50 +67,50 @@ void LoadScores(void)
}
memset(&hScores, 0, sizeof(hScores));
- scores_src = SDL_RWFromFile(path.Path(MAELSTROM_SCORES), "rb");
- if ( scores_src != NULL ) {
+ if (gScoreFile != -1) {
+ lseek(gScoreFile,0,SEEK_SET);
for ( i=0; i<NUM_SCORES; ++i ) {
- SDL_RWread(scores_src, hScores[i].name,
- sizeof(hScores[i].name), 1);
- hScores[i].wave = SDL_ReadBE32(scores_src);
- hScores[i].score = SDL_ReadBE32(scores_src);
+ Uint32 tmp;
+
+ if (read(gScoreFile,hScores[i].name,sizeof(hScores[i].name)) != sizeof(hScores[i].name))
+ break;
+ if (read(gScoreFile,&tmp,sizeof(Uint32)) != sizeof(Uint32))
+ break;
+ hScores[i].wave = ntohl(tmp);
+ if (read(gScoreFile,&tmp,sizeof(Uint32)) != sizeof(Uint32))
+ break;
+ hScores[i].score = ntohl(tmp);
}
- SDL_RWclose(scores_src);
}
}
void SaveScores(void)
{
- LibPath path;
- SDL_RWops *scores_src;
int i;
-#ifdef unix
- int omask;
-#endif
/* Don't save network scores */
if ( gNetScores )
return;
-#ifdef unix
- omask=umask(SCORES_PERMMASK);
-#endif
- scores_src = SDL_RWFromFile(path.Path(MAELSTROM_SCORES), "wb");
- if ( scores_src != NULL ) {
+ if (gScoreFile != -1) {
+ lseek(gScoreFile,0,SEEK_SET);
for ( i=0; i<NUM_SCORES; ++i ) {
- SDL_RWwrite(scores_src, hScores[i].name,
- sizeof(hScores[i].name), 1);
- SDL_WriteBE32(scores_src, hScores[i].wave);
- SDL_WriteBE32(scores_src, hScores[i].score);
+ Uint32 tmp;
+
+ if (write(gScoreFile, hScores[i].name, sizeof(hScores[i].name)) != sizeof(hScores[i].name))
+ goto out_err;
+ tmp = htonl(hScores[i].wave);
+ if (write(gScoreFile, &tmp,sizeof(Uint32)) != sizeof(Uint32))
+ goto out_err;
+ tmp = htonl(hScores[i].score);
+ if (write(gScoreFile, &tmp,sizeof(Uint32)) != sizeof(Uint32))
+ goto out_err;
}
- SDL_RWclose(scores_src);
- } else {
- error("Warning: Couldn't save scores to %s\n",
- path.Path(MAELSTROM_SCORES));
+ fsync(gScoreFile);
+ return;
}
-#ifdef unix
- umask(omask);
-#endif
+out_err:
+ error("Warning: Couldn't save scores to %s\n", MAELSTROM_SCORES);
}
/* Just show the high scores */
diff --git a/scores.h b/scores.h
index 4126260..4716751 100644
--- a/scores.h
+++ b/scores.h
@@ -2,6 +2,7 @@
// Functions from scores.cc
extern void LoadScores(void);
extern void SaveScores(void);
+extern void GetScoreFile(void);
extern int ZapHighScores(void);
extern int GetStartLevel(void);
extern void PrintHighScores(void);
--
2.20.1

View File

@@ -0,0 +1,9 @@
[Desktop Entry]
Name=Maelstrom
Comment=Space combat game
Exec=Maelstrom -fullscreen
Icon=maelstrom.png
Terminal=false
Type=Application
Categories=Game;ArcadeGame;
Keywords=game;arcade;space;shooter;asteroids;

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -0,0 +1,43 @@
SUMMARY = "Maelstrom is a GPL'd port of the shareware game for the Macintosh"
LICENSE = "GPLv2 & CC-BY-3.0"
LIC_FILES_CHKSUM = "file://COPYING;md5=0642955deaee2fa53c36bc592dc1ef25"
HOMEPAGE = "https://www.libsdl.org/projects/Maelstrom/"
inherit autotools-brokensep pkgconfig gettext gtk-icon-cache
DEPENDS += " \
libsdl-net \
"
SRC_URI = " \
https://www.libsdl.org/projects/Maelstrom/src/Maelstrom-${PV}.tar.gz \
file://0001-Use-pkg-config-to-find-sdl.patch \
file://0002-buttonlist.h-Fix-build-with-recent-gcc-s.patch \
file://0003-Fix-install-dir.patch \
file://0004-Maelstrom-3.0.6-setgid.patch \
file://maelstrom.png \
file://Maelstrom.desktop \
"
SRC_URI[md5sum] = "96aa6359538a6bd60b4198a792de578b"
SRC_URI[sha256sum] = "e7983c2c7376cdcca1944db1706d92aedd529638cf13358c88a60df982ba7b46"
S = "${WORKDIR}/Maelstrom-${PV}"
do_configure_prepend() {
touch ${S}/NEWS ${S}/AUTHORS ${S}/ChangeLog
}
do_install() {
oe_runmake DESTDIR=${D} install install-am
install -d ${D}/${datadir}/applications
install -m 644 ${WORKDIR}/Maelstrom.desktop ${D}/${datadir}/applications
install -d ${D}/${datadir}/icons/hicolor/48x48/apps
install -m 644 ${WORKDIR}/maelstrom.png ${D}/${datadir}/icons/hicolor/48x48/apps
install -d ${D}/${localstatedir}/lib/games
mv ${D}${datadir}/Maelstrom/*Scores ${D}/${localstatedir}/lib/games
}
FILES_${PN} += "${datadir}/Maelstrom"