]> git.pld-linux.org Git - packages/crafty.git/blame - crafty-MDK.patch
- remove binary sources to distfiles
[packages/crafty.git] / crafty-MDK.patch
CommitLineData
e5eb4e43
PG
1--- annotate.c
2+++ annotate.c
3@@ -554,7 +554,7 @@
4
5 void AnnotatePositionHTML(TREE * RESTRICT tree, int wtm, FILE * annotate_out)
6 {
7- char filename[32], html_piece;
8+ char filename[64], html_piece;
9 char alt[32];
10 char xlate[15] =
11 { 'q', 'r', 'b', 0, 'k', 'n', 'p', 0, 'P', 'N', 'K', 0, 'B', 'R', 'Q' };
12@@ -566,7 +566,7 @@
13 for (rank = RANK8; rank >= RANK1; rank--) {
14 fprintf(annotate_out, "<TR>\n");
15 for (file = FILEA; file <= FILEH; file++) {
16- (void) strcpy(filename, "bitmaps/");
17+ (void) strcpy(filename, "/usr/share/crafty/bitmaps/");
18 if ((rank + file) % 2)
19 (void) strcat(filename, "w");
20 else
21@@ -665,7 +665,7 @@
22 fprintf(annotate_out, "\\usepackage{times}\n");
23 fprintf(annotate_out, "\\usepackage{a4wide}\n");
24 fprintf(annotate_out, "\\usepackage{chess}\n");
25- fprintf(annotate_out, "\\usepackage{bdfchess}\n");
26+ fprintf(annotate_out, "%% \\usepackage{bdfchess}\n");
27 fprintf(annotate_out, "\\usepackage[T1]{fontenc}\n");
28 fprintf(annotate_out, "\n");
29 fprintf(annotate_out, "\\setlength{\\columnsep}{7mm}\n");
30--- egtb.cpp
31+++ egtb.cpp
32@@ -4490,7 +4490,8 @@
33 #if defined (SMP)
34 static lock_t lockDecode;
35 #endif
36-extern "C" int TB_CRC_CHECK = 0;
37+extern "C" int TB_CRC_CHECK;
38+int TB_CRC_CHECK = 0;
39 static int cCompressed = 0;
40 static decode_block *rgpdbDecodeBlocks[CPUS];
41
42--- lock.h
43+++ lock.h
44@@ -64,7 +64,7 @@
45 *******************************************************************************
46 */
47
48-#if defined(ALPHA)
49+#if defined(__alpha__)
50
51 # include <machine/builtins.h>
52
53--- main.c
54+++ main.c
55@@ -1,6 +1,10 @@
56 #include <stdio.h>
57 #include <stdlib.h>
58 #include <string.h>
59+#include <sys/stat.h>
60+#include <sys/types.h>
61+#include <fcntl.h>
62+#include <unistd.h>
63 #include "chess.h"
64 #include "data.h"
65 #if defined(UNIX) || defined(AMIGA)
66@@ -3230,8 +3234,58 @@
67 #if !defined(UNIX)
68 char crafty_rc_file_spec[FILENAME_MAX];
69 #endif
70-/* Collect environmental variables */
71- char *directory_spec = getenv("CRAFTY_BOOK_PATH");
72+
73+ char *directory_spec;
74+
75+/*
76+ set log_path & rc_path to some reasonable value
77+ create default .craftyrc
78+*/
79+ {
80+ char l[128], *h = getenv("HOME");
81+ struct stat st;
82+ FILE *f;
83+
84+ if(!h || strlen(h) > 100) h = "/tmp";
85+ strcpy(rc_path, h);
86+ sprintf(log_path, "%s/%s", h, ".crafty");
87+
88+ if(stat(log_path, &st) || !S_ISDIR(st.st_mode)) {
89+ mkdir(log_path, 0755);
90+ }
91+
92+ sprintf(l, "%s/.craftyrc", rc_path);
93+ if(lstat(l, &st)) {
94+ if((f = fopen(l, "w"))) {
95+ fprintf(f, "egtb\n");
96+ fclose(f);
97+ }
98+ }
99+ }
100+
101+/*
102+ set book_path to some reasonable value
103+*/
104+ {
105+ char l[128], *h = getenv("HOME");
106+ struct stat st;
107+
108+ if(!h || strlen(h) > 100) h = "/tmp";
109+ sprintf(book_path, "%s/%s", h, ".crafty");
110+
111+ if(stat(book_path, &st) || !S_ISDIR(st.st_mode)) {
112+ mkdir(book_path, 0755);
113+ }
114+
115+ sprintf(l, "%s/book.bin", book_path);
116+ if(lstat(l, &st)) symlink("/usr/share/crafty/book.bin", l);
117+
118+ sprintf(l, "%s/books.bin", book_path);
119+ if(lstat(l, &st)) symlink("/usr/share/crafty/books.bin", l);
120+ }
121+
122+ /* Collect environmental variables */
123+ directory_spec=getenv("CRAFTY_BOOK_PATH");
124
125 #if defined(NUMA) && defined(LINUX)
126 if (numa_available() >= 0) {
127--- Makefile
128+++ Makefile
129@@ -72,8 +72,21 @@
130 # with the large egtb.cpp code/templates.
131 #
132
133+ARCH = $(shell uname -m | sed -e 's/^i./i3/')
134+
135+opt = -DCOMPACT_ATTACKS -DUSE_ATTACK_FUNCTIONS -DFAST -DDGT -DEGTB6
136+
137+# EGTB code seems to have problems with SMP
138+ifneq ($(findstring $(ARCH),i386),)
139+ opt += -O2 -DUSE_ASSEMBLY_A -DUSE_ASSEMBLY_B # -DSMP -DCPUS=4
140+ asm = X86-elf.o
141+else
142+ opt += -O # -DSMP -DCPUS=4 -DMUTEX
143+ asm =
144+endif
145+
146 default:
147- $(MAKE) -j linux-icc
148+ $(MAKE) linux-suse
149 help:
150 @echo "You must specify the system which you want to compile for:"
151 @echo ""
152@@ -173,6 +186,15 @@
153 LDFLAGS='$(LDFLAGS) +O3 +Onolimit $(CFLAGS)' \
154 crafty-make
155
156+linux-suse:
157+ $(MAKE) target=LINUX \
158+ CC=gcc CXX=g++ \
159+ CFLAGS='$(CFLAGS) -Wall -pipe -D_REENTRANT' \
160+ CXFLAGS='$(CFLAGS) \
161+ -fforce-mem -fomit-frame-pointer' \
162+ LDFLAGS='$(LDFLAGS) -lpthread' \
163+ crafty-make
164+
165 linux:
166 $(MAKE) target=LINUX \
167 CC=gcc CXX=g++ \
168--- option.c
169+++ option.c
170@@ -11,6 +11,8 @@
171 #endif
172 #include "epdglue.h"
173
174+#define safe_strcpy(dst, src) strncpy(dst, src, sizeof dst - 1)[sizeof dst - 1] = 0
175+
176 /* last modified 10/10/05 */
177 /*
178 *******************************************************************************
179@@ -843,7 +845,7 @@
180 char filename[256];
181 FILE *file;
182
183- strcpy(filename, args[2]);
184+ safe_strcpy(filename, args[2]);
185 strcat(filename, ".cpf");
186 file = fopen(filename, "w");
187 if (!file) {
188@@ -1129,7 +1131,7 @@
189 movenum = shared->move_number;
190 if (wtm)
191 movenum--;
192- strcpy(text, args[1]);
193+ safe_strcpy(text, args[1]);
194 sprintf(buffer, "reset %d", movenum);
195 wtm = Flip(wtm);
196 (void) Option(tree);
197@@ -1357,7 +1359,7 @@
198 char *readstat = (char *) -1;
199 int lines = 0;
200
201- helpfile = fopen("crafty.hlp", "r");
202+ helpfile = fopen("/usr/share/crafty/crafty.hlp", "r");
203 if (!helpfile) {
204 printf("ERROR. Unable to open \"crafty.hlp\" -- help unavailable\n");
205 return (1);
206@@ -1858,7 +1860,7 @@
207 printf("file does not exist.\n");
208 return (1);
209 }
210- strcpy(title, args[2]);
211+ safe_strcpy(title, args[2]);
212 while (!feof(prob_file)) {
213 readstat = fgets(buffer, 128, prob_file);
214 if (readstat) {
215@@ -2154,10 +2156,10 @@
216 return (1);
217 }
218 if (wtm) {
219- strcpy(pgn_white, args[1]);
220+ safe_strcpy(pgn_white, args[1]);
221 sprintf(pgn_black, "Crafty %s", version);
222 } else {
223- strcpy(pgn_black, args[1]);
224+ safe_strcpy(pgn_black, args[1]);
225 sprintf(pgn_white, "Crafty %s", version);
226 }
227 Print(128, "Crafty %s vs %s\n", version, args[1]);
228@@ -2368,14 +2370,14 @@
229 }
230 if (!strchr(args[1], '(')) {
231 if (strstr(args[0], "bookpath"))
232- strcpy(book_path, args[1]);
233+ safe_strcpy(book_path, args[1]);
234 else if (strstr(args[0], "perspath"))
235- strcpy(personality_path, args[1]);
236+ safe_strcpy(personality_path, args[1]);
237 else if (strstr(args[0], "logpath"))
238- strcpy(log_path, args[1]);
239+ safe_strcpy(log_path, args[1]);
240 #if !defined(NOEGTB)
241 else if (strstr(args[0], "tbpath")) {
242- strcpy(tb_path, args[1]);
243+ safe_strcpy(tb_path, args[1]);
244 EGTBlimit = IInitializeTb(tb_path);
245 Print(128, "%d piece tablebase files found\n", EGTBlimit);
246 if (0 != cbEGTBCompBytes)
247@@ -2398,12 +2400,12 @@
248 if (strchr(args[1], ')')) {
249 *strchr(args[1], ')') = 0;
250 if (strstr(args[0], "bookpath"))
251- strcpy(book_path, args[1] + 1);
252+ safe_strcpy(book_path, args[1] + 1);
253 else if (strstr(args[0], "logpath"))
254- strcpy(log_path, args[1] + 1);
255+ safe_strcpy(log_path, args[1] + 1);
256 #if !defined(NOEGTB)
257 else if (strstr(args[0], "tbpath")) {
258- strcpy(tb_path, args[1] + 1);
259+ safe_strcpy(tb_path, args[1] + 1);
260 EGTBlimit = IInitializeTb(tb_path);
261 Print(128, "%d piece tablebase files found\n", EGTBlimit);
262 if (0 != cbEGTBCompBytes)
263--- speak
264+++ speak
265@@ -4,13 +4,13 @@
266 #
267
268 # The program used for Sound Output
269-my $playprg = "/usr/bin/esdplay";
270+my $playprg = "/usr/bin/play";
271
272 # Where the sound files are located
273-my $soundpath = "/opt/chess/sound";
274+my $soundpath = "/usr/share/crafty/sound";
275 # Which language to use (each supported language is in a separate
276 # subdir of $soundpath)
277-my $language = "english";
278+my $language = "en";
279
280 # The move sent by crafty
281 my $move = $ARGV[0];
282@@ -18,11 +18,28 @@
283 # Set soundpath to the correct language
284 $soundpath = $soundpath . "/" . $language;
285
286+%piece = (
287+ 'B' => 'Bishop',
288+ 'K' => 'King',
289+ 'N' => 'Knight',
290+ 'Q' => 'Queen',
291+ 'R' => 'Rook'
292+);
293+
294+
295+%moves = (
296+ 'O-O' => '0-0',
297+ 'O-O-O' => '0-0-0',
298+ 'Stalemate' => 'Stalemate',
299+ 'Drawaccept' => 'Drawaccept',
300+ 'Drawoffer' => 'Drawoffer',
301+ 'Resign' => 'Resign'
302+);
303+
304 # First check some specials
305-if (($move =~ /O-O/) || ($move eq "Stalemate") ||
306- ($move eq "Drawaccept") || ($move eq "Drawoffer") ||
307- ($move eq "Resign") || ($move eq "Checkmate")) {
308- system("$playprg $soundpath/$move.wav");
309+
310+if($moves{$move}) {
311+ system("$playprg $soundpath/$moves{$move}.wav");
312 }
313 # Handle all normal moves. All that needs to be done is announce
314 # each character sent by crafty alone. Set some pause beteween each
315@@ -42,9 +59,14 @@
316 else {
317 for (my $i=0; $i<length($move); $i++) {
318 my $char = substr $move, $i, 1;
319+
320+ if($i == 0 && $char =~ /[a-h]/) {
321+ system("$playprg $soundpath/Pawn.wav");
322+ }
323+
324 if ($char =~ /[^=]/) {
325 if ($char =~ /x/) {
326- system("$playprg $soundpath/x.wav");
327+ system("$playprg $soundpath/takes.wav");
328 system("usleep 400000");
329 }
330 elsif ($char =~ /#/) {
331@@ -53,9 +75,21 @@
332 elsif ($char =~ /\+/) {
333 system("$playprg $soundpath/Check.wav");
334 }
335+ elsif ($char =~ /[1-8]/) {
336+ system("$playprg $soundpath/${char}from.wav");
337+ }
338+ elsif ($char =~ /[a-h]/) {
339+ system("$playprg $soundpath/\U${char}\Efrom.wav");
340+ }
341+ elsif ($char =~ /[QKNBR]/) {
342+ system("$playprg $soundpath/$piece{$char}.wav");
343+ }
344 else {
345 system("$playprg $soundpath/$char".".wav");
346 }
347 }
348 }
349+
350+ system("$playprg $soundpath/click.wav");
351+
352 }
353--- utility.c
354+++ utility.c
355@@ -133,10 +133,12 @@
356 float BookIn32f(unsigned char *ch)
357 {
358 int v1;
359- float *v2 = (float *) &v1;
360+ float v2;
361
362 v1 = (ch[3] << 24) | (ch[2] << 16) | (ch[1] << 8) | ch[0];
363- return (*v2);
364+ memcpy(&v2, &v1, sizeof v2);
365+
366+ return v2;
367 }
368
369 /*
370@@ -201,14 +203,15 @@
371 */
372 unsigned char *BookOut32f(float val)
373 {
374- float v1;
375- int *v2 = (int *) &v1;
376+ int v2;
377+
378+ memcpy(&v2, &val, sizeof v2);
379+
380+ convert_buff[3] = (v2 >> 24) & 0xff;
381+ convert_buff[2] = (v2 >> 16) & 0xff;
382+ convert_buff[1] = (v2 >> 8) & 0xff;
383+ convert_buff[0] = v2 & 0xff;
384
385- v1 = val;
386- convert_buff[3] = (*v2 >> 24) & 0xff;
387- convert_buff[2] = (*v2 >> 16) & 0xff;
388- convert_buff[1] = (*v2 >> 8) & 0xff;
389- convert_buff[0] = *v2 & 0xff;
390 return (convert_buff);
391 }
392
393@@ -1547,14 +1550,16 @@
394 if (vb & shared->display_options)
395 vprintf(fmt, ap);
396 fflush(stdout);
397+ va_end(ap);
398+
399 if (shared->time_limit > 99 || shared->tc_time_remaining > 6000 || vb == 4095) {
400 va_start(ap, fmt);
401 if (log_file)
402 vfprintf(log_file, fmt, ap);
403 if (log_file)
404 fflush(log_file);
405+ va_end(ap);
406 }
407- va_end(ap);
408 }
409
410 char *PrintKM(size_t val, int realK)
This page took 0.197666 seconds and 4 git commands to generate.