updated on Thu Jan 26 12:02:26 UTC 2012
[aur-mirror.git] / gtkmagnetic / gargoyle.patch
blob81344b22f9553b3c428dd1a8e9640919d76ea340
1 diff -aur Generic/defs.h Generic.garg/defs.h
2 --- Generic/defs.h 2008-08-12 19:56:48.000000000 +0200
3 +++ Generic.garg/defs.h 2011-10-20 05:38:40.000000000 +0200
4 @@ -21,7 +21,7 @@
6 * You should have received a copy of the GNU General Public License
7 * along with this program; if not, write to the Free Software
8 -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
9 +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
11 \****************************************************************************/
13 @@ -35,12 +35,34 @@
14 * correct number of bits on your system !!!
15 \*****************************************************************************/
17 -typedef unsigned char type8;
18 -typedef signed char type8s;
19 -typedef unsigned short type16;
20 -typedef signed short type16s;
21 -typedef unsigned long type32;
22 -typedef signed long type32s;
23 +#include <limits.h>
25 +#if UCHAR_MAX==0xff
26 +typedef unsigned char type8;
27 +typedef signed char type8s;
28 +#else
29 +#error "Can't find an 8-bit integer type"
30 +#endif
32 +#if SHRT_MAX==0x7fff
33 +typedef unsigned short type16;
34 +typedef signed short type16s;
35 +#elif INT_MAX==0x7fff
36 +typedef unsigned int type16;
37 +typedef signed int type16s;
38 +#else
39 +#error "Can't find a 16-bit integer type"
40 +#endif
42 +#if INT_MAX==0x7fffffff
43 +typedef unsigned int type32;
44 +typedef signed int type32s;
45 +#elif LONG_MAX==0x7fffffff
46 +typedef unsigned long type32;
47 +typedef signed long type32s;
48 +#else
49 +#error "Can't find a 32-bit integer type"
50 +#endif
52 /****************************************************************************\
53 * Compile time switches
54 diff -aur Generic/emu.c Generic.garg/emu.c
55 --- Generic/emu.c 2008-08-21 07:10:40.000000000 +0200
56 +++ Generic.garg/emu.c 2011-10-04 11:35:14.000000000 +0200
57 @@ -21,7 +21,7 @@
59 * You should have received a copy of the GNU General Public License
60 * along with this program; if not, write to the Free Software
61 -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
62 +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
64 * History:
66 @@ -824,7 +824,7 @@
67 if ((hints != 0) && (hint_contents != 0))
69 /* Read number of blocks */
70 - fread(&buf, 1, 2, hnt_fp);
71 + if (fread(&buf, 1, 2, hnt_fp) != 2 && !feof(hnt_fp)) return 0;
72 blkcnt = read_w2(buf);
73 #ifdef LOGHNT
74 out2("Blocks: %d\n",blkcnt);
75 @@ -836,7 +836,7 @@
76 out2("\nBlock No. %d\n",i);
77 #endif
78 /* Read number of elements */
79 - fread(&buf, 1, 2, hnt_fp);
80 + if (fread(&buf, 1, 2, hnt_fp) != 2 && !feof(hnt_fp)) return 0;
81 elcnt = read_w2(buf);
82 #ifdef LOGHNT
83 out2("Elements: %d\n",elcnt);
84 @@ -844,7 +844,7 @@
85 hints[i].elcount = elcnt;
87 /* Read node type */
88 - fread(&buf, 1, 2, hnt_fp);
89 + if (fread(&buf, 1, 2, hnt_fp) != 2 && !feof(hnt_fp)) return 0;
90 ntype = read_w2(buf);
91 #ifdef LOGHNT
92 if (ntype == 1)
93 @@ -859,9 +859,9 @@
94 #endif
95 for (j = 0; j < elcnt; j++)
97 - fread(&buf, 1, 2, hnt_fp);
98 + if (fread(&buf, 1, 2, hnt_fp) != 2 && !feof(hnt_fp)) return 0;
99 elsize = read_w2(buf);
100 - fread(hint_contents+conidx, 1, elsize, hnt_fp);
101 + if (fread(hint_contents+conidx, 1, elsize, hnt_fp) != elsize && !feof(hnt_fp)) return 0;
102 hint_contents[conidx+elsize-1] = '\0';
103 #ifdef LOGHNT
104 out2("%s\n",hint_contents+conidx);
105 @@ -877,7 +877,7 @@
106 #endif
107 for (j = 0; j < elcnt; j++)
109 - fread(&buf, 1, 2, hnt_fp);
110 + if (fread(&buf, 1, 2, hnt_fp) != 2 && !feof(hnt_fp)) return 0;
111 hints[i].links[j] = read_w2(buf);
112 #ifdef LOGHNT
113 out2("%d\n",hints[i].links[j]);
114 @@ -886,7 +886,7 @@
117 /* Read the parent block */
118 - fread(&buf, 1, 2, hnt_fp);
119 + if (fread(&buf, 1, 2, hnt_fp) != 2 && !feof(hnt_fp)) return 0;
120 hints[i].parent = read_w2(buf);
121 #ifdef LOGHNT
122 out2("Parent: %d\n",hints[i].parent);
123 diff -aur Generic/gfxlink2.c Generic.garg/gfxlink2.c
124 --- Generic/gfxlink2.c 2010-10-25 17:32:11.000000000 +0200
125 +++ Generic.garg/gfxlink2.c 2011-06-07 22:21:27.000000000 +0200
126 @@ -6,7 +6,6 @@
127 Written by David Kinder.
130 -#include <ctype.h>
131 #include <stdio.h>
132 #include <stdlib.h>
133 #include <string.h>
134 diff -aur Generic/gfxlink.c Generic.garg/gfxlink.c
135 --- Generic/gfxlink.c 1998-01-09 21:35:42.000000000 +0100
136 +++ Generic.garg/gfxlink.c 2011-06-07 22:21:27.000000000 +0200
137 @@ -61,9 +61,29 @@
138 #define DIRSEP "/"
139 #endif
141 -typedef unsigned char type8;
142 -typedef unsigned short type16;
143 -typedef unsigned long int type32;
144 +#include <limits.h>
146 +#if UCHAR_MAX==0xff
147 +typedef unsigned char type8;
148 +#else
149 +#error "Can't find an 8-bit integer type"
150 +#endif
152 +#if SHRT_MAX==0x7fff
153 +typedef unsigned short type16;
154 +#elif INT_MAX==0x7fff
155 +typedef unsigned int type16;
156 +#else
157 +#error "Can't find a 16-bit integer type"
158 +#endif
160 +#if INT_MAX==0x7fffffff
161 +typedef unsigned int type32;
162 +#elif LONG_MAX==0x7fffffff
163 +typedef unsigned long type32;
164 +#else
165 +#error "Can't find a 32-bit integer type"
166 +#endif
168 int fdi, fdo_temp, fdo_gfx;
169 char infilemask[FILENAMELENGTH];
170 diff -aur Generic/main.c Generic.garg/main.c
171 --- Generic/main.c 2010-10-25 17:32:25.000000000 +0200
172 +++ Generic.garg/main.c 2011-10-04 11:35:14.000000000 +0200
173 @@ -21,7 +21,7 @@
175 * You should have received a copy of the GNU General Public License
176 * along with this program; if not, write to the Free Software
177 -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
178 +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
180 * Simple ANSI interface main.c
182 @@ -36,7 +36,7 @@
183 #define WIDTH 78
185 type8 buffer[80], xpos = 0, bufpos = 0, log_on = 0, ms_gfx_enabled, filename[256];
186 -FILE *logfile1 = 0, *logfile2 = 0;
187 +FILE *log1 = 0, *log2 = 0;
189 type8 ms_load_file(type8s *name, type8 *ptr, type16 size)
191 @@ -88,23 +88,23 @@
193 void script_write(type8 c)
195 - if (log_on == 2 && fputc(c,logfile1) == EOF)
196 + if (log_on == 2 && fputc(c,log1) == EOF)
198 printf("[Problem with script file - closing]\n");
199 - fclose(logfile1);
200 + fclose(log1);
201 log_on = 0;
205 void transcript_write(type8 c)
207 - if (logfile2 && c == 0x08 && ftell(logfile2) > 0)
208 - fseek(logfile2,-1,SEEK_CUR);
209 - else if (logfile2 && fputc(c,logfile2) == EOF)
210 + if (log2 && c == 0x08 && ftell(log2) > 0)
211 + fseek(log2,-1,SEEK_CUR);
212 + else if (log2 && fputc(c,log2) == EOF)
214 printf("[Problem with transcript file - closing]\n");
215 - fclose(logfile2);
216 - logfile2 = 0;
217 + fclose(log2);
218 + log2 = 0;
222 @@ -187,11 +187,11 @@
223 if (log_on == 1)
225 /* Reading from logfile */
226 - if ((c = fgetc(logfile1)) == EOF)
227 + if ((c = fgetc(log1)) == EOF)
229 /* End of log? - turn off */
230 log_on = 0;
231 - fclose(logfile1);
232 + fclose(log1);
233 c = getchar();
235 else printf("%c",c); /* print the char as well */
236 @@ -211,7 +211,7 @@
238 printf("[Closing script file]\n");
239 log_on = 0;
240 - fclose(logfile1);
241 + fclose(log1);
243 else if (!strcmp(buf,"undo"))
244 c = 0;
245 @@ -311,17 +311,17 @@
246 slimit = 655360;
247 break;
248 case 't':
249 - if (!(logfile2 = fopen(&argv[i][2],"w")))
250 + if (!(log2 = fopen(&argv[i][2],"w")))
251 printf("Failed to open \"%s\" for writing.\n",&argv[i][2]);
252 break;
253 case 'r':
254 - if (logfile1 = fopen(&argv[i][2],"r"))
255 + if (log1 = fopen(&argv[i][2],"r"))
256 log_on = 1;
257 else
258 printf("Failed to open \"%s\" for reading.\n",&argv[i][2]);
259 break;
260 case 'w':
261 - if (logfile1 = fopen(&argv[i][2],"w"))
262 + if (log1 = fopen(&argv[i][2],"w"))
263 log_on = 2;
264 else
265 printf("Failed to open \"%s\" for writing.\n",&argv[i][2]);
266 @@ -374,9 +374,9 @@
268 ms_freemem();
269 if (log_on)
270 - fclose(logfile1);
271 - if (logfile2)
272 - fclose(logfile2);
273 + fclose(log1);
274 + if (log2)
275 + fclose(log2);
276 printf("\nExiting.\n");
277 return 0;
279 diff -aur Generic/passwd.c Generic.garg/passwd.c
280 --- Generic/passwd.c 2000-12-06 23:33:06.000000000 +0100
281 +++ Generic.garg/passwd.c 2011-06-07 22:21:27.000000000 +0200
282 @@ -1,61 +1,73 @@
283 -#include <stdio.h>
284 -#include <stdlib.h>
285 -#include <string.h>
286 -#include <ctype.h>
288 -typedef unsigned char type8;
289 -typedef unsigned long type32;
291 -type8 obfuscate(type8 c) {
292 - static type8 state;
293 - type8 i;
295 - if (!c) state=0;
296 - else {
297 - state^=c;
298 - for (i=0;i<13;i++) {
299 - if ((state & 1) ^ ((state>>1) & 1)) state|=0x80;
300 - else state&=0x7f;
301 - state>>=1;
304 - return state;
307 -int main(int argc, char **argv) {
309 - type8 tmp,name[128],result[128],pad[]="MAGNETICSCR";
310 - type32 i,j;
312 - if (argc!=2) {
313 - printf("Usage: %s string\n",argv[0]);
314 - exit(1);
317 - for (i=j=0;i<strlen(argv[1]);i++) {
318 - if (argv[1][i]!=0x20) name[j++]=toupper(argv[1][i]);
320 - name[j]=0;
322 - tmp=name[strlen(name)-1];
323 - if ((tmp=='#') || (tmp==']')) name[strlen(name)-1]=0;
325 - if (strlen(name)<12) {
326 - for (i=strlen(name),j=0;i<12;i++,j++) name[i]=pad[j];
327 - name[i]=0;
330 - obfuscate(0);
331 - i=j=0;
332 - while (name[i]) {
333 - tmp=obfuscate(name[i++]);
334 - if (name[i]) tmp+=obfuscate(name[i++]);
335 - tmp&=0x1f;
336 - if (tmp<26) tmp+='A';
337 - else tmp+=0x16;
338 - result[j++]=tmp;
340 - result[j]=0;
341 +#include <stdio.h>
342 +#include <stdlib.h>
343 +#include <string.h>
344 +#include <ctype.h>
345 +#include <limits.h>
347 +#if UCHAR_MAX==0xff
348 +typedef unsigned char type8;
349 +#else
350 +#error "Can't find an 8-bit integer type"
351 +#endif
353 +#if INT_MAX==0x7fffffff
354 +typedef unsigned int type32;
355 +#elif LONG_MAX==0x7fffffff
356 +typedef unsigned long type32;
357 +#else
358 +#error "Can't find a 32-bit integer type"
359 +#endif
361 +type8 obfuscate(type8 c) {
362 + static type8 state;
363 + type8 i;
365 + if (!c) state=0;
366 + else {
367 + state^=c;
368 + for (i=0;i<13;i++) {
369 + if ((state & 1) ^ ((state>>1) & 1)) state|=0x80;
370 + else state&=0x7f;
371 + state>>=1;
374 + return state;
377 +int main(int argc, char **argv) {
379 + type8 tmp,name[128],result[128],pad[]="MAGNETICSCR";
380 + type32 i,j;
382 + if (argc!=2) {
383 + printf("Usage: %s string\n",argv[0]);
384 + exit(1);
387 + for (i=j=0;i<strlen(argv[1]);i++) {
388 + if (argv[1][i]!=0x20) name[j++]=toupper(argv[1][i]);
390 + name[j]=0;
392 + tmp=name[strlen(name)-1];
393 + if ((tmp=='#') || (tmp==']')) name[strlen(name)-1]=0;
395 + if (strlen(name)<12) {
396 + for (i=strlen(name),j=0;i<12;i++,j++) name[i]=pad[j];
397 + name[i]=0;
400 + obfuscate(0);
401 + i=j=0;
402 + while (name[i]) {
403 + tmp=obfuscate(name[i++]);
404 + if (name[i]) tmp+=obfuscate(name[i++]);
405 + tmp&=0x1f;
406 + if (tmp<26) tmp+='A';
407 + else tmp+=0x16;
408 + result[j++]=tmp;
410 + result[j]=0;
411 printf("The password for \"%s\" is: %s\n",argv[1],result);
412 - return 0;
414 + return 0;
416 diff -aur Generic/sndlink.c Generic.garg/sndlink.c
417 --- Generic/sndlink.c 2009-06-06 18:22:59.000000000 +0200
418 +++ Generic.garg/sndlink.c 2011-06-07 22:21:27.000000000 +0200
419 @@ -7,7 +7,6 @@
421 v1.1 added option for tempo patching
422 v1.2 fixed tempo patching
423 - v1.3 remove garbage bytes at end of original data
426 #include <stdio.h>
427 @@ -39,7 +38,6 @@
428 FILE* OutputFile = NULL;
429 unsigned long OutOffset = 0;
430 int tempopatch=0;
431 -int garbagefix=0;
433 void WriteLong(unsigned char* p, unsigned long v)
435 @@ -204,7 +202,7 @@
437 void WriteSndFile(int Index)
439 - unsigned long offset, length, j = 0;
440 + unsigned long offset, length;
441 unsigned short tsize;
442 int game = -1;
444 @@ -214,21 +212,6 @@
445 length = BUFFER_SIZE;
446 ReadFile(Buffer1,&offset,length);
448 - // Remove garbage bytes if present
449 - if (garbagefix)
451 - while ((j <= length-1) && !(Buffer1[j]==0xFF && Buffer1[j+1]==0x2F && Buffer1[j+2]==0x00))
453 - j++;
455 - if (j+3 != length)
457 - SndFiles[Index].Length = j+3;
458 - length=j+3;
463 // Tempo patching
464 if (tempopatch)
466 @@ -356,25 +339,14 @@
468 int main(int argc, char** argv)
470 - if (argc == 2 ||
471 - ((argc == 3 && ((strcmp(argv[1],"-p")==0) || strcmp(argv[1],"-r")==0))) ||
472 - ((argc == 4 && ((strcmp(argv[1],"-p")==0) && strcmp(argv[2],"-r")==0))))
473 + if (argc == 2 || (argc == 3 && strcmp(argv[1],"-p")==0))
475 if (argc==2)
476 OpenFile(argv[1]);
477 - else if (argc==2)
479 - if (strcmp(argv[1],"-p")==0)
480 - tempopatch = 1;
481 - if (strcmp(argv[1],"-r")==0)
482 - garbagefix = 1;
483 - OpenFile(argv[2]);
485 else
487 tempopatch = 1;
488 - garbagefix = 1;
489 - OpenFile(argv[3]);
490 + OpenFile(argv[2]);
492 FindResourceNames();
493 WriteSndHeader1();
494 @@ -385,18 +357,17 @@
496 else
498 - printf("SndLink v1.3 by Stefan Meier.\n\n"
499 + printf("SndLink v1.2 by Stefan Meier.\n\n"
500 "Extractor for the music scores in Magnetic Scrolls' Wonderland\n"
501 "Amiga, Atari ST, PC versions.\n\n"
502 - "Usage: SndLink [-p] [-r] all.rsc\n\n"
503 + "Usage: SndLink [-p] all.rsc\n\n"
504 "\"all.rsc\" is taken from an installed game. Depending on your\n"
505 "game version, the resource file might be split into several files\n"
506 "named e.g. all.1, all.2,... or TWO,THREE,FOUR...\n"
507 "Before running the extractor, you need to merge these parts into\n"
508 "one file, e.g. with the DOS command copy /B ONE+TWO+THREE+... all.rsc\n"
509 "If the extraction is successfull, the file wonder.snd is created\n\n"
510 - "The optional -p switch adds tempo data to the music score\n"
511 - "The optional -r switch removes garbage bytes from the PC versions");
512 + "The optional -p switch adds tempo data to the music score");
514 return 0;
516 diff -aur Generic/xtract64.c Generic.garg/xtract64.c
517 --- Generic/xtract64.c 2000-05-06 16:30:00.000000000 +0200
518 +++ Generic.garg/xtract64.c 2011-06-07 22:21:27.000000000 +0200
519 @@ -2,12 +2,25 @@
520 #include <stdio.h>
521 #include <stdlib.h>
522 #include <string.h>
523 +#include <limits.h>
525 #define size_d64 ((type32)(174848))
526 #define NL ((type32) -1)
528 -typedef unsigned char type8;
529 -typedef unsigned long type32;
530 +#if UCHAR_MAX==0xff
531 +typedef unsigned char type8;
532 +#else
533 +#error "Can't find an 8-bit integer type"
534 +#endif
536 +#if INT_MAX==0x7fffffff
537 +typedef unsigned int type32;
538 +#elif LONG_MAX==0x7fffffff
539 +typedef unsigned long type32;
540 +#else
541 +#error "Can't find a 32-bit integer type"
542 +#endif
544 #ifdef __MSDOS__
545 typedef unsigned char huge * type8ptr;
546 #include <alloc.h>
547 diff -aur Generic/xtractpc.c Generic.garg/xtractpc.c
548 --- Generic/xtractpc.c 2010-10-25 17:32:32.000000000 +0200
549 +++ Generic.garg/xtractpc.c 2011-06-07 22:21:27.000000000 +0200
550 @@ -7,7 +7,6 @@
551 Written by Niclas Karlsson and David Kinder.
554 -#include <ctype.h>
555 #include <stdio.h>
556 #include <stdlib.h>
557 #include <string.h>