Package: edgar / 1.23-1

fix-pak.diff 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
Description: Use the existence of PAK_FILE instead of DEV to use files.
Author: Zorian Medwid <misterhat144@gmail.com>
Forwarded: No
Last-Update: 2015-10-13
--- a/src/system/pak.c
+++ b/src/system/pak.c
@@ -31,7 +31,7 @@

 void initPakFile()
 {
-	#if DEV == 0
+        #ifdef PAK_FILE
 		int32_t offset;
 		FILE *fp;
 		int i;
@@ -88,14 +88,16 @@

 void verifyVersion()
 {
-	char version[5];
+        #ifdef PAK_FILE
+            char version[5];

-	snprintf(version, sizeof(version), "%0.2f", VERSION);
+            snprintf(version, sizeof(version), "%0.2f", VERSION);

-	if (existsInPak(version) == FALSE)
-	{
-		showErrorAndExit("Game and PAK file versions do not match. Please reinstall the game.");
-	}
+                if (existsInPak(version) == FALSE)
+                {
+                        showErrorAndExit("Game and PAK file versions do not match. Please reinstall the game.");
+                }
+        #endif
 }

 SDL_Surface *loadImageFromPak(char *name)
@@ -166,10 +168,13 @@
 {
 	Mix_Music *music;

-	#if DEV == 1
+	#ifndef PAK_FILE
+                char fullName[MAX_PATH_LENGTH] = INSTALL_PATH;
+                snprintf(fullName, sizeof(fullName), "%s%s", INSTALL_PATH, name);
+
 		FILE *fp;

-		fp = fopen(name, "rb");
+		fp = fopen(fullName, "rb");

 		if (fp == NULL)
 		{
@@ -178,7 +183,7 @@

 		fclose(fp);

-		music = Mix_LoadMUS(name);
+		music = Mix_LoadMUS(fullName);

 		return music;
 	#else
@@ -217,12 +222,15 @@
 {
 	unsigned char *source, *dest;
 	FILE *fp;
-	#if DEV != 1
+	#ifdef PAK_FILE
 		int i, index;
 	#endif

-	#if DEV == 1
-		fp = fopen(name, "rb");
+	#ifndef PAK_FILE
+                char fullName[MAX_PATH_LENGTH] = INSTALL_PATH;
+                snprintf(fullName, sizeof(fullName), "%s%s", INSTALL_PATH, name);
+
+		fp = fopen(fullName, "rb");

 		if (fp == NULL)
 		{
@@ -314,9 +322,6 @@
 	unsigned long size;
 	unsigned char *source, *dest;
 	FILE *fp;
-	#if DEV != 1
-		int i, index;
-	#endif

 	filename = NULL;

@@ -327,8 +332,11 @@
 		showErrorAndExit("Failed to allocate a whole %d bytes for filename", MAX_PATH_LENGTH);
 	}

-	#if DEV == 1
-		fp = fopen(name, "rb");
+        #ifndef PAK_FILE
+                char fullName[MAX_PATH_LENGTH] = INSTALL_PATH;
+                snprintf(fullName, sizeof(fullName), "%s%s", INSTALL_PATH, name);
+
+		fp = fopen(fullName, "rb");

 		if (fp == NULL)
 		{
@@ -355,7 +363,8 @@

 		source = NULL;
 	#else
-		index = -1;
+                int i;
+		int index = -1;

 		for (i=0;i<fileCount;i++)
 		{
@@ -455,14 +464,14 @@
 int existsInPak(char *name)
 {
 	int exists;
-	#if DEV == 1
+
+	#ifndef PAK_FILE
+                char fullName[MAX_PATH_LENGTH] = INSTALL_PATH;
+                snprintf(fullName, sizeof(fullName), "%s%s", INSTALL_PATH, name);
+
 		FILE *fp;
-	#else
-		int i;
-	#endif
+		fp = fopen(fullName, "rb");

-	#if DEV == 1
-		fp = fopen(name, "rb");

 		if (fp == NULL)
 		{
@@ -476,6 +485,7 @@
 			exists = TRUE;
 		}
 	#else
+                int i;
 		exists = FALSE;

 		for (i=0;i<fileCount;i++)
@@ -494,7 +504,7 @@

 void freePakFile()
 {
-	#if DEV == 0
+	#ifndef PAK_FILE
 		if (fileData != NULL)
 		{
 			free(fileData);