From 83f14d3e5d695ac0c6df9abf5664bab28cf52fe5 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sat, 11 Oct 2008 22:46:31 +0200 Subject: [PATCH] rnd-20081011-1-src * fixed behaviour of player option "no centering when relocating" which was incorrect when disabled and relocation target inside visible area and "no scrolling when relocating" enabled at the same time --- ChangeLog | 20 ++++++++++- src/conftime.h | 2 +- src/game.c | 94 ++++++++++++++++++++++++-------------------------- 3 files changed, 66 insertions(+), 50 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8a72a75b..52445eae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,23 @@ +2008-10-11 + * fixed behaviour of player option "no centering when relocating" which + was incorrect when disabled and relocation target inside visible area + and "no scrolling when relocating" enabled at the same time + 2008-10-06 - * fixed problems with re-mapping players on playfield to input devices + * fixed problems with re-mapping players on playfield to input devices: + previously, players found on the level playfield were changed to the + players connected to input devices (for example, player 3 in the level + was changed to player 1 (using artwork of player 3, to be able to use + a player with a different color)); this had the disadvantage that CE + conditions using player elements did not work (because the players in + the level definition are different to those effectively used in-game); + the new system uses the same player elements as defined in the level + playfield and re-maps the input devices of connected players to the + corresponding player elements when playing the level (in the above + example, player 3 now really exists in the game and is moved using the + events from input device 1); level tapes still store the events from + input devices 1 to 4, which are then re-mapped to players accordingly + when re-playing the tape (just as it is done when playing the level) 2008-09-29 * fixed bug with player relocation while the player switches an element diff --git a/src/conftime.h b/src/conftime.h index 7ea76c58..6b56d4d8 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2008-10-07 00:52" +#define COMPILE_DATE_STRING "2008-10-11 22:44" diff --git a/src/game.c b/src/game.c index 717ea8d2..d4e4cf3f 100644 --- a/src/game.c +++ b/src/game.c @@ -4228,7 +4228,8 @@ void InitGame() #else for (i = 0; i < MAX_PLAYERS; i++) { - if (stored_player[i].active && !tape.player_participates[i]) + if (stored_player[i].active && + !tape.player_participates[i]) { struct PlayerInfo *player = &stored_player[i]; int jx = player->jx, jy = player->jy; @@ -5502,8 +5503,6 @@ void DrawRelocateScreen(int old_x, int old_y, int x, int y, int move_dir, if (quick_relocation) { - int offset = game.scroll_delay_value; - if (!IN_VIS_FIELD(SCREENX(x), SCREENY(y)) || center_screen) { if (!level.shifted_relocation || center_screen) @@ -5544,8 +5543,47 @@ void DrawRelocateScreen(int old_x, int old_y, int x, int y, int move_dir, } else { +#if 1 + if (!level.shifted_relocation || center_screen) + { + /* quick relocation (without scrolling), with centering of screen */ + + scroll_x = (x < SBX_Left + MIDPOSX ? SBX_Left : + x > SBX_Right + MIDPOSX ? SBX_Right : + x - MIDPOSX); + + scroll_y = (y < SBY_Upper + MIDPOSY ? SBY_Upper : + y > SBY_Lower + MIDPOSY ? SBY_Lower : + y - MIDPOSY); + } + else + { + /* quick relocation (without scrolling), but do not center screen */ + + int center_scroll_x = (old_x < SBX_Left + MIDPOSX ? SBX_Left : + old_x > SBX_Right + MIDPOSX ? SBX_Right : + old_x - MIDPOSX); + + int center_scroll_y = (old_y < SBY_Upper + MIDPOSY ? SBY_Upper : + old_y > SBY_Lower + MIDPOSY ? SBY_Lower : + old_y - MIDPOSY); + + int offset_x = x + (scroll_x - center_scroll_x); + int offset_y = y + (scroll_y - center_scroll_y); + + scroll_x = (offset_x < SBX_Left + MIDPOSX ? SBX_Left : + offset_x > SBX_Right + MIDPOSX ? SBX_Right : + offset_x - MIDPOSX); + + scroll_y = (offset_y < SBY_Upper + MIDPOSY ? SBY_Upper : + offset_y > SBY_Lower + MIDPOSY ? SBY_Lower : + offset_y - MIDPOSY); + } +#else /* quick relocation (without scrolling), inside visible screen area */ + int offset = game.scroll_delay_value; + if ((move_dir == MV_LEFT && scroll_x > x - MIDPOSX + offset) || (move_dir == MV_RIGHT && scroll_x < x - MIDPOSX - offset)) scroll_x = x - MIDPOSX + (scroll_x < x - MIDPOSX ? -offset : +offset); @@ -5561,6 +5599,7 @@ void DrawRelocateScreen(int old_x, int old_y, int x, int y, int move_dir, /* don't scroll over playfield boundaries */ if (scroll_y < SBY_Upper || scroll_y > SBY_Lower) scroll_y = (scroll_y < SBY_Upper ? SBY_Upper : SBY_Lower); +#endif } RedrawPlayfield(TRUE, 0,0,0,0); @@ -12246,15 +12285,6 @@ void GameActions() game.set_centered_player = TRUE; } -#if 0 /* USE_NEW_PLAYER_ASSIGNMENTS */ - for (i = 0; i < MAX_PLAYERS; i++) - { - summarized_player_action |= stored_player[i].mapped_action; - - if (!network_playing) - stored_player[i].effective_action = stored_player[i].mapped_action; - } -#else for (i = 0; i < MAX_PLAYERS; i++) { summarized_player_action |= stored_player[i].action; @@ -12262,7 +12292,6 @@ void GameActions() if (!network_playing) stored_player[i].effective_action = stored_player[i].action; } -#endif #if defined(NETWORK_AVALIABLE) if (network_playing) @@ -12279,25 +12308,13 @@ void GameActions() (i == game.centered_player_nr ? summarized_player_action : 0); } -#if 0 /* USE_NEW_PLAYER_ASSIGNMENTS */ if (recorded_player_action != NULL) for (i = 0; i < MAX_PLAYERS; i++) - stored_player[i].effective_action = - recorded_player_action[map_player_action[i]]; -#else - if (recorded_player_action != NULL) - for (i = 0; i < MAX_PLAYERS; i++) - stored_player[i].effective_action = - recorded_player_action[i]; -#endif + stored_player[i].effective_action = recorded_player_action[i]; for (i = 0; i < MAX_PLAYERS; i++) { -#if 0 /* USE_NEW_PLAYER_ASSIGNMENTS */ - tape_action[i] = stored_player[i].action; -#else tape_action[i] = stored_player[i].effective_action; -#endif /* (this can only happen in the R'n'D game engine) */ if (tape.recording && tape_action[i] && !tape.player_participates[i]) @@ -12310,33 +12327,14 @@ void GameActions() #if USE_NEW_PLAYER_ASSIGNMENTS { -#if 0 - - for (i = 0; i < MAX_PLAYERS; i++) - stored_player[i].mapped_action = stored_player[map_player_action[i]].action; - -#else - -#if 1 - byte unmapped_action[MAX_PLAYERS]; + byte mapped_action[MAX_PLAYERS]; for (i = 0; i < MAX_PLAYERS; i++) - unmapped_action[i] = stored_player[i].effective_action; + mapped_action[i] = stored_player[map_player_action[i]].effective_action; for (i = 0; i < MAX_PLAYERS; i++) - stored_player[i].effective_action = unmapped_action[map_player_action[i]]; -#endif - -#if 0 - for (i = 0; i < MAX_PLAYERS; i++) - printf("::: %d: %d [%d]\n", i, stored_player[i].effective_action, - map_player_action[i]); -#endif -#endif + stored_player[i].effective_action = mapped_action[i]; } -#else - for (i = 0; i < MAX_PLAYERS; i++) - stored_player[i].mapped_action = stored_player[i].action; #endif if (level.game_engine_type == GAME_ENGINE_TYPE_EM) -- 2.34.1