From: Holger Schemel Date: Sun, 24 Jul 2005 21:37:09 +0000 (+0200) Subject: rnd-20050724-1-src X-Git-Tag: 3.1.1^2~4 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=bafa61706833e7bfe942c388471058749c20c79e;p=rocksndiamonds.git rnd-20050724-1-src * added recognition of "trigger element" for "change digged element to" (this is not really what the "trigger element" was made for, but its use may seem obvious for leaving back digged elements unchanged) * fixed multiple warnings about failed joystick device initialization --- diff --git a/ChangeLog b/ChangeLog index bbc96b9d..6ea090be 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2005-07-24 + * added recognition of "trigger element" for "change digged element to" + (this is not really what the "trigger element" was made for, but its + use may seem obvious for leaving back digged elements unchanged) + +2005-07-23 + * fixed multiple warnings about failed joystick device initialization + 2005-06-27 * fixed bug with dynamite dropped on top of just dropped custom element (collect dynamite, collect CE, drop CE => dynamite was also dropped); diff --git a/src/conftime.h b/src/conftime.h index cee54f4d..0cedaf28 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2005-06-30 00:18]" +#define COMPILE_DATE_STRING "[2005-07-24 14:45]" diff --git a/src/game.c b/src/game.c index 34a57f74..ba4c8f9d 100644 --- a/src/game.c +++ b/src/game.c @@ -56,6 +56,8 @@ #define USE_DROP_BUGFIX (TRUE * USE_NEW_STUFF * 1) +#define USE_CHANGE_TO_TRIGGERED (TRUE * USE_NEW_STUFF * 1) + /* for DigField() */ #define DF_NO_PUSH 0 @@ -6219,7 +6221,16 @@ void StartMoving(int x, int y) #if 1 Store[newx][newy] = EL_EMPTY; if (IS_EQUAL_OR_IN_GROUP(new_element, MOVE_ENTER_EL(element))) + { +#if USE_CHANGE_TO_TRIGGERED + int move_leave_element = element_info[element].move_leave_element; + + Store[newx][newy] = (move_leave_element == EL_TRIGGER_ELEMENT ? + new_element : move_leave_element); +#else Store[newx][newy] = element_info[element].move_leave_element; +#endif + } #else Store[newx][newy] = EL_EMPTY; if (IS_EQUAL_OR_IN_GROUP(new_element, MOVE_ENTER_EL(element)) || @@ -6629,6 +6640,12 @@ void ContinueMoving(int x, int y) { int move_leave_element = ei->move_leave_element; +#if USE_CHANGE_TO_TRIGGERED + if (ei->move_leave_type == LEAVE_TYPE_LIMITED && + ei->move_leave_element == EL_TRIGGER_ELEMENT) + move_leave_element = stored; +#endif + Feld[x][y] = move_leave_element; #if USE_PREVIOUS_MOVE_DIR diff --git a/src/libgame/joystick.c b/src/libgame/joystick.c index d9cad128..c2d0c192 100644 --- a/src/libgame/joystick.c +++ b/src/libgame/joystick.c @@ -26,6 +26,8 @@ #if defined(PLATFORM_UNIX) && !defined(TARGET_SDL) void UnixInitJoysticks() { + static boolean unix_joystick_subsystem_initialized = FALSE; + boolean print_warning = !unix_joystick_subsystem_initialized; int i; for (i = 0; i < MAX_PLAYERS; i++) @@ -44,18 +46,24 @@ void UnixInitJoysticks() if (access(device_name, R_OK) != 0) { - Error(ERR_WARN, "cannot access joystick device '%s'", device_name); + if (print_warning) + Error(ERR_WARN, "cannot access joystick device '%s'", device_name); + continue; } if ((joystick.fd[i] = open(device_name, O_RDONLY)) < 0) { - Error(ERR_WARN, "cannot open joystick device '%s'", device_name); + if (print_warning) + Error(ERR_WARN, "cannot open joystick device '%s'", device_name); + continue; } joystick.status = JOYSTICK_ACTIVATED; } + + unix_joystick_subsystem_initialized = TRUE; } boolean UnixReadJoystick(int fd, int *x, int *y, boolean *b1, boolean *b2) diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index 1bc222a9..b127c784 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -1440,6 +1440,7 @@ void HandleJoystickEvent(Event *event) void SDLInitJoysticks() { static boolean sdl_joystick_subsystem_initialized = FALSE; + boolean print_warning = !sdl_joystick_subsystem_initialized; int i; if (!sdl_joystick_subsystem_initialized) @@ -1459,11 +1460,19 @@ void SDLInitJoysticks() int joystick_nr = getJoystickNrFromDeviceName(device_name); if (joystick_nr >= SDL_NumJoysticks()) + { + if (setup.input[i].use_joystick && print_warning) + Error(ERR_WARN, "cannot find joystick %d", joystick_nr); + joystick_nr = -1; + } /* misuse joystick file descriptor variable to store joystick number */ joystick.fd[i] = joystick_nr; + if (joystick_nr == -1) + continue; + /* this allows subsequent calls to 'InitJoysticks' for re-initialization */ if (SDLCheckJoystickOpened(joystick_nr)) SDLCloseJoystick(joystick_nr); @@ -1473,7 +1482,9 @@ void SDLInitJoysticks() if (!SDLOpenJoystick(joystick_nr)) { - Error(ERR_WARN, "cannot open joystick %d", joystick_nr); + if (print_warning) + Error(ERR_WARN, "cannot open joystick %d", joystick_nr); + continue; }