Gentoo Archives: gentoo-commits

From: Sergei Trofimovich <slyfox@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: games-arcade/sdb/, games-arcade/sdb/files/
Date: Mon, 03 May 2021 16:18:18
Message-Id: 1620058691.f0369a777a35c2692b21c9f78d0673bb2983fa09.slyfox@gentoo
1 commit: f0369a777a35c2692b21c9f78d0673bb2983fa09
2 Author: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
3 AuthorDate: Mon May 3 16:17:47 2021 +0000
4 Commit: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
5 CommitDate: Mon May 3 16:18:11 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f0369a77
7
8 games-arcade/sdb: fix startup crash on gcc-8+
9
10 Crashes happen due to missing 'return' value in non-void functions.
11
12 Package-Manager: Portage-3.0.18, Repoman-3.0.3
13 Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>
14
15 games-arcade/sdb/files/sdb-1.0.2-return-type.patch | 56 ++++++++++++++++++++++
16 games-arcade/sdb/sdb-1.0.2-r2.ebuild | 55 +++++++++++++++++++++
17 2 files changed, 111 insertions(+)
18
19 diff --git a/games-arcade/sdb/files/sdb-1.0.2-return-type.patch b/games-arcade/sdb/files/sdb-1.0.2-return-type.patch
20 new file mode 100644
21 index 00000000000..9750eedb991
22 --- /dev/null
23 +++ b/games-arcade/sdb/files/sdb-1.0.2-return-type.patch
24 @@ -0,0 +1,56 @@
25 +Fix -Werror=return-type warnings to prevent gcc-8+ from
26 +corrupting caller's stack.
27 +
28 +Also detected by -fsanitize=undefined as:
29 +runtime error: execution reached the end of a value-returning
30 +function without returning a value
31 +--- a/src/input.cpp
32 ++++ b/src/input.cpp
33 +@@ -103,5 +103,6 @@ float InputHandler::bindingState(int key)
34 + }
35 + else
36 + return 0.0;
37 ++ return 0.0;
38 + }
39 +
40 +--- a/src/objects.h
41 ++++ b/src/objects.h
42 +@@ -545,12 +545,12 @@ class Object : public LevelObject
43 + bool Augmented() { return augmented; }
44 + void Augment() { model[1].set(MDL_PLAYER_TORSO2); augmented = true; }
45 +
46 +- virtual Weapon* Wpn() {}
47 +- virtual int CurrWeapon() {}
48 ++ virtual Weapon* Wpn() { return 0; }
49 ++ virtual int CurrWeapon() { return 0; }
50 + virtual void selectWeapon(int wp) {}
51 +- virtual char weaponState(int wp) {}
52 +- virtual char keyState(int wp) {}
53 +- virtual Vector2D* WeaponPoint() {}
54 ++ virtual char weaponState(int wp) { return 0; }
55 ++ virtual char keyState(int wp) { return 0; }
56 ++ virtual Vector2D* WeaponPoint() { return 0; }
57 +
58 + void giveKey(int key) { keys |= 1 << key-1; }
59 + virtual void givePowerup(int idx) {}
60 +--- a/src/sdb.h
61 ++++ b/src/sdb.h
62 +@@ -370,7 +370,7 @@ class Vector2D
63 + void set(float nx, float ny) { c[X] = nx; c[Y] = ny; c[Z] = 0; }
64 + void apply() { glVertex3fv(c); }
65 + void print() { printf("(%f, %f)\n", c[X], c[Y]); }
66 +- Vector2D operator = (Vector2D v) { c[X] = v.c[X]; c[Y] = v.c[Y]; }
67 ++ Vector2D operator = (Vector2D v) { c[X] = v.c[X]; c[Y] = v.c[Y]; return *this; }
68 + void operator += (Vector2D v) { c[X] += v.c[X]; c[Y] += v.c[Y]; }
69 + void operator -= (Vector2D v) { c[X] -= v.c[X]; c[Y] -= v.c[Y]; }
70 + void operator += (float s) { c[X] += s; c[Y] += s; }
71 +--- a/src/weapons.cpp
72 ++++ b/src/weapons.cpp
73 +@@ -135,6 +135,7 @@ bool Weapon::fire(float x, float y, float head, float h)
74 + }
75 + else
76 + return false;
77 ++ return false;
78 + }
79 +
80 + void Weapon::releaseTrigger(float x, float y, float head, float h)
81
82 diff --git a/games-arcade/sdb/sdb-1.0.2-r2.ebuild b/games-arcade/sdb/sdb-1.0.2-r2.ebuild
83 new file mode 100644
84 index 00000000000..842841e9cbd
85 --- /dev/null
86 +++ b/games-arcade/sdb/sdb-1.0.2-r2.ebuild
87 @@ -0,0 +1,55 @@
88 +# Copyright 1999-2021 Gentoo Authors
89 +# Distributed under the terms of the GNU General Public License v2
90 +
91 +EAPI=7
92 +inherit desktop toolchain-funcs
93 +
94 +DESCRIPTION="A 2D top-down action game; escape a facility full of walking death machines"
95 +HOMEPAGE="http://sdb.gamecreation.org/"
96 +SRC_URI="http://gcsociety.sp.cs.cmu.edu/~frenzy/${P}.tar.gz"
97 +
98 +LICENSE="GPL-2"
99 +SLOT="0"
100 +KEYWORDS="~amd64 ~x86"
101 +IUSE=""
102 +
103 +DEPEND="virtual/opengl
104 + media-libs/libsdl
105 + media-libs/sdl-image[png]
106 + media-libs/sdl-mixer"
107 +RDEPEND="${DEPEND}"
108 +
109 +PATCHES=(
110 + "${FILESDIR}"/${P}-endian.patch
111 + "${FILESDIR}"/${P}-gcc43.patch
112 + "${FILESDIR}"/${P}-ldflags.patch
113 + "${FILESDIR}"/${P}-gcc-11.patch
114 + "${FILESDIR}"/${P}-return-type.patch
115 +)
116 +
117 +src_prepare() {
118 + default
119 + sed -i \
120 + -e "s:models/:/usr/share/${PN}/models/:" \
121 + -e "s:snd/:/usr/share/${PN}/snd/:" \
122 + -e "s:sprites/:/usr/share/${PN}/sprites/:" \
123 + -e "s:levels/:/usr/share/${PN}/levels/:" \
124 + src/sdb.h src/game.cpp || die "setting game paths"
125 +}
126 +
127 +src_compile() {
128 + emake \
129 + -C src \
130 + CXXFLAGS="${CXXFLAGS} $(sdl-config --cflags)" \
131 + CC=$(tc-getCC) \
132 + CPP=$(tc-getCXX)
133 +}
134 +
135 +src_install() {
136 + dobin src/sdb
137 + insinto /usr/share/${PN}
138 + doins -r levels models snd sprites
139 + newicon sprites/barrel.png ${PN}.png
140 + make_desktop_entry sdb "Shotgun Debugger"
141 + einstalldocs
142 +}