From: H.G. Muller Date: Mon, 7 Oct 2013 17:29:57 +0000 (+0200) Subject: Implement roaring of Lion X-Git-Url: http://winboard.nl/cgi-bin?p=xboard.git;a=commitdiff_plain;h=da8802ac4d06115296e0f8ba955ecf5570741d08 Implement roaring of Lion When a Lion double-move is animated, the roaring sound is played. It can be selected through the new -soundRoar persistent option. A wav file with a suitable roar is added, and configured for use. --- diff --git a/Makefile.am b/Makefile.am index bf941e3..e9d8ca8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -191,7 +191,7 @@ dist_png_DATA = png/hatch.png png/wood_d.png png/wood_l.png png/xqboard.png soundsdir = $(gamedatadir)/sounds dist_sounds_DATA = \ sounds/cymbal.wav sounds/pop2.wav sounds/slap.wav sounds/ding1.wav sounds/laser.wav \ - sounds/woodthunk.wav sounds/gong.wav sounds/penalty.wav sounds/honkhonk.wav sounds/phone.wav + sounds/woodthunk.wav sounds/gong.wav sounds/penalty.wav sounds/honkhonk.wav sounds/phone.wav sounds/roar.wav ### set correct dir in xboard.conf diff --git a/args.h b/args.h index 01dc439..03a7f43 100644 --- a/args.h +++ b/args.h @@ -468,6 +468,7 @@ ArgDescriptor argDescriptors[] = { { "soundSeek", ArgFilename, (void *) &appData.soundSeek, TRUE, (ArgIniType) "" }, { "soundMove", ArgFilename, (void *) &appData.soundMove, TRUE, (ArgIniType) "" }, { "soundBell", ArgFilename, (void *) &appData.soundBell, TRUE, (ArgIniType) SOUND_BELL }, + { "soundRoar", ArgFilename, (void *) &appData.soundRoar, TRUE, (ArgIniType) "" }, { "soundIcsWin", ArgFilename, (void *) &appData.soundIcsWin, TRUE, (ArgIniType) "" }, { "soundIcsLoss", ArgFilename, (void *) &appData.soundIcsLoss, TRUE, (ArgIniType) "" }, { "soundIcsDraw", ArgFilename, (void *) &appData.soundIcsDraw, TRUE, (ArgIniType) "" }, diff --git a/backend.c b/backend.c index 11ce0e6..fac9abd 100644 --- a/backend.c +++ b/backend.c @@ -8288,7 +8288,7 @@ HandleMachineMove (char *message, ChessProgramState *cps) char realname[MSG_SIZ]; int fromX, fromY, toX, toY; ChessMove moveType; - char promoChar; + char promoChar, roar; char *p, *pv=buf1; int machineWhite, oldError; char *bookHit; @@ -8604,10 +8604,12 @@ if(appData.debugMode) fprintf(debugFP, "nodes = %d, %lld\n", (int) programStats. cps->other->maybeThinking = TRUE; } + roar = (killX >= 0 && IS_LION(boards[forwardMostMove][toY][toX])); + ShowMove(fromX, fromY, toX, toY); /*updates currentMove*/ if (!pausing && appData.ringBellAfterMoves) { - RingBell(); + if(!roar) RingBell(); } /* diff --git a/board.c b/board.c index 8df780b..ab3985e 100644 --- a/board.c +++ b/board.c @@ -604,6 +604,8 @@ AnimateMove (Board board, int fromX, int fromY, int toX, int toY) Pnt frames[kFactor * 2 + 1]; int nFrames, startColor, endColor; + if(killX >= 0 && IS_LION(board[fromY][fromX])) Roar(); + /* Are we animating? */ if (!appData.animate || appData.blindfold) return; diff --git a/common.h b/common.h index d5adda1..2bd7653 100644 --- a/common.h +++ b/common.h @@ -274,6 +274,7 @@ typedef enum { #define SHOGI (int)EmptySquare + (int) #define CHUPROMOTED ((int)WhitePDragon - (int)WhiteDragon)*(gameInfo.variant == VariantChu) + PROMOTED #define IS_SHOGI(V) ((V) == VariantShogi || (V) == VariantChu) +#define IS_LION(V) ((V) == WhiteLion || (V) == BlackLion) typedef ChessSquare Board[BOARD_RANKS][BOARD_FILES]; @@ -538,6 +539,7 @@ typedef struct { char *soundSeek; char *soundMove; // [HGM] IMPORTANT: order must be as in SoundClass char *soundBell; + char *soundRoar; char *soundIcsAlarm; char *soundIcsWin; char *soundIcsLoss; diff --git a/dialogs.c b/dialogs.c index 0f95000..5bcbc0b 100644 --- a/dialogs.c +++ b/dialogs.c @@ -724,6 +724,7 @@ static char *soundNames[] = { N_("Penalty"), N_("Phone"), N_("Pop"), + N_("Roar"), N_("Slap"), N_("Wood Thunk"), NULL, @@ -742,6 +743,7 @@ static char *soundFiles[] = { // sound files corresponding to above names "penalty.wav", "phone.wav", "pop2.wav", + "roar.wav", "slap.wav", "woodthunk.wav", NULL, @@ -769,6 +771,7 @@ static Option soundOptions[] = { { 0, 0, 0, NULL, (void*) &appData.soundTell, (char*) soundFiles, soundNames, ComboBox, N_("Tell:") }, { 0, 0, 0, NULL, (void*) &appData.soundKibitz, (char*) soundFiles, soundNames, ComboBox, N_("Kibitz:") }, { 0, 0, 0, NULL, (void*) &appData.soundRequest, (char*) soundFiles, soundNames, ComboBox, N_("Request:") }, +{ 0, 0, 0, NULL, (void*) &appData.soundRoar, (char*) soundFiles, soundNames, ComboBox, N_("Lion roar:") }, { 0, 0, 0, NULL, (void*) &appData.soundSeek, (char*) soundFiles, soundNames, ComboBox, N_("Seek:") }, { 0, SAME_ROW, 0, NULL, NULL, "", NULL, EndMark , "" } }; diff --git a/frontend.h b/frontend.h index 5ac3cf8..e4b8684 100644 --- a/frontend.h +++ b/frontend.h @@ -93,13 +93,14 @@ void DrawSeekDot P((int x, int y, int color)); void PopUpMoveDialog P((char first)); void RingBell P((void)); +int Roar P((void)); void PlayIcsWinSound P((void)); void PlayIcsLossSound P((void)); void PlayIcsDrawSound P((void)); void PlayIcsUnfinishedSound P((void)); void PlayAlarmSound P((void)); void PlayTellSound P((void)); -void PlaySoundFile P((char *name)); +int PlaySoundFile P((char *name)); void PlaySoundByColor P((void)); void EchoOn P((void)); void EchoOff P((void)); diff --git a/sounds/roar.wav b/sounds/roar.wav new file mode 100644 index 0000000..16b0af7 Binary files /dev/null and b/sounds/roar.wav differ diff --git a/usounds.c b/usounds.c index 67afdb0..31a0cda 100644 --- a/usounds.c +++ b/usounds.c @@ -76,21 +76,22 @@ extern char *getenv(); #include "frontend.h" -void +int PlaySoundFile (char *name) { if (*name == NULLCHAR) { - return; + return 0; } else if (strcmp(name, "$") == 0) { putc(BELLCHAR, stderr); } else { char buf[2048]; char *prefix = "", *sep = ""; - if(appData.soundProgram[0] == NULLCHAR) return; + if(appData.soundProgram[0] == NULLCHAR) return 1; if(!strchr(name, '/')) { prefix = appData.soundDirectory; sep = "/"; } snprintf(buf, sizeof(buf), "%s '%s%s%s' &", appData.soundProgram, prefix, sep, name); system(buf); } + return 1; } void @@ -135,6 +136,12 @@ PlayTellSound () PlaySoundFile(appData.soundTell); } +int +Roar () +{ + return PlaySoundFile(appData.soundRoar); +} + void PlaySoundForColor (ColorClass cc) { diff --git a/xboard.conf.in b/xboard.conf.in index 38186c2..4d312f4 100644 --- a/xboard.conf.in +++ b/xboard.conf.in @@ -43,6 +43,7 @@ -soundTell phone.wav -soundChallenge gong.wav -soundMove woodthunk.wav +-soundRoar roar.wav -soundIcsAlarm penalty.wav -pasteSelection false -keepLineBreaksICS false