Package: opentyrian / 2.1.20130907+dfsg-3

gdp.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
From: Alexandre Detiste <alexandre.detiste@gmail.com>
Subject: Display an error message when data is missing
Date: Sat, 04 Mar 2017 20:59:30 +0100

A version of this patch has been forwarded upstream; this is a cut-down
version suitable for Debian stretch.

Bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=856728
Forwarded: https://bitbucket.org/opentyrian/opentyrian/pull-requests/6

--- a/src/varz.c
+++ b/src/varz.c
@@ -16,6 +16,10 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
+#ifdef TARGET_UNIX
+#include <unistd.h>
+#endif
+
 #include "config.h"
 #include "editship.h"
 #include "episodes.h"
@@ -498,6 +502,38 @@
 	}
 
 	SDL_Quit();
+
+#ifdef TARGET_UNIX
+#define MISSING_TEXT "One or more of the required Tyrian " TYRIAN_VERSION " data files could not be found.\n" \
+                     "These can be installed using game-data-packager.\n"
+	if (code == 1)
+	{
+		char* argv[6];
+		pid_t child_pid;
+		child_pid = fork();
+		if(child_pid == 0) {
+			argv[0] = "zenity";
+			argv[1] = "--error";
+			argv[2] = "--text=" MISSING_TEXT;
+			argv[3] = "--title=Tyrian";
+			argv[4] = NULL;
+			execvp(argv[0], argv);
+			argv[0] = "kdialog";
+			argv[2] = MISSING_TEXT;
+			execvp(argv[0], argv);
+			argv[0] = "xmessage";
+			argv[1] = "-center";
+			argv[3] = NULL;
+			execvp(argv[0], argv);
+			argv[0] = "notify-send";
+			argv[1] = "Tyrian";
+			argv[3] = "-i";
+			argv[4] = "dialog-error";
+			argv[5] = NULL;
+			execvp(argv[0], argv);
+		}
+	}
+#endif
 	exit(code);
 }
 
--- a/src/file.c
+++ b/src/file.c
@@ -18,6 +18,7 @@
  */
 #include "file.h"
 #include "opentyr.h"
+#include "varz.h"
 
 #include "SDL.h"
 #include <errno.h>
@@ -96,7 +97,7 @@
 		fprintf(stderr, "error: failed to open '%s': %s\n", file, strerror(errno));
 		fprintf(stderr, "error: One or more of the required Tyrian " TYRIAN_VERSION " data files could not be found.\n"
 		                "       Please read the README file.\n");
-		exit(1);
+		JE_tyrianHalt(1);
 	}
 	
 	return f;