X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Fgame.c;h=89e0c110a1e0255bbd22f5d55040666ff66ea1ff;hp=de245df51c6b571301d58eca00d70e43fce5135d;hb=6746a99c1d7348748c06d457f8496b4253bb7c84;hpb=6da19745f8b8aa6f8cc02b59da507082fe509c5b diff --git a/src/game.c b/src/game.c index de245df5..89e0c110 100644 --- a/src/game.c +++ b/src/game.c @@ -827,6 +827,14 @@ static struct GamePanelControlInfo game_panel_controls[] = #define DOUBLE_PLAYER_SPEED(p) (HALVE_MOVE_DELAY( (p)->move_delay_value)) #define HALVE_PLAYER_SPEED(p) (DOUBLE_MOVE_DELAY((p)->move_delay_value)) +/* values for scroll positions */ +#define SCROLL_POSITION_X(x) ((x) < SBX_Left + MIDPOSX ? SBX_Left : \ + (x) > SBX_Right + MIDPOSX ? SBX_Right :\ + (x) - MIDPOSX) +#define SCROLL_POSITION_Y(y) ((y) < SBY_Upper + MIDPOSY ? SBY_Upper :\ + (y) > SBY_Lower + MIDPOSY ? SBY_Lower :\ + (y) - MIDPOSY) + /* values for other actions */ #define MOVE_STEPSIZE_NORMAL (TILEX / MOVE_DELAY_NORMAL_SPEED) #define MOVE_STEPSIZE_MIN (1) @@ -1611,7 +1619,6 @@ void GetPlayerConfig() setup.sound = (setup.sound_simple || setup.sound_loops || setup.sound_music); SetAudioMode(setup.sound); - InitJoysticks(); } int GetElementFromGroupElement(int element) @@ -3896,23 +3903,13 @@ void InitGame() } } - scroll_x = (start_x < SBX_Left + MIDPOSX ? SBX_Left : - start_x > SBX_Right + MIDPOSX ? SBX_Right : - start_x - MIDPOSX); - - scroll_y = (start_y < SBY_Upper + MIDPOSY ? SBY_Upper : - start_y > SBY_Lower + MIDPOSY ? SBY_Lower : - start_y - MIDPOSY); + scroll_x = SCROLL_POSITION_X(start_x); + scroll_y = SCROLL_POSITION_Y(start_y); } else { - scroll_x = (local_player->jx < SBX_Left + MIDPOSX ? SBX_Left : - local_player->jx > SBX_Right + MIDPOSX ? SBX_Right : - local_player->jx - MIDPOSX); - - scroll_y = (local_player->jy < SBY_Upper + MIDPOSY ? SBY_Upper : - local_player->jy > SBY_Lower + MIDPOSY ? SBY_Lower : - local_player->jy - MIDPOSY); + scroll_x = SCROLL_POSITION_X(local_player->jx); + scroll_y = SCROLL_POSITION_Y(local_player->jy); } /* !!! FIX THIS (START) !!! */ @@ -4463,7 +4460,8 @@ void GameEnd() SaveLevelSetup_SeriesInfo(); } - if (level_nr < leveldir_current->last_level) + if (setup.increment_levels && + level_nr < leveldir_current->last_level) raise_level = TRUE; /* advance to next level */ if ((hi_pos = NewHiScore()) >= 0) @@ -4496,6 +4494,7 @@ int NewHiScore() { int k, l; int position = -1; + boolean one_score_entry_per_name = !program.many_scores_per_name; LoadScore(level_nr); @@ -4513,13 +4512,15 @@ int NewHiScore() { int m = MAX_SCORE_ENTRIES - 1; -#ifdef ONE_PER_NAME - for (l = k; l < MAX_SCORE_ENTRIES; l++) - if (strEqual(setup.player_name, highscore[l].Name)) - m = l; - if (m == k) /* player's new highscore overwrites his old one */ - goto put_into_list; -#endif + if (one_score_entry_per_name) + { + for (l = k; l < MAX_SCORE_ENTRIES; l++) + if (strEqual(setup.player_name, highscore[l].Name)) + m = l; + + if (m == k) /* player's new highscore overwrites his old one */ + goto put_into_list; + } for (l = m; l > k; l--) { @@ -4528,22 +4529,19 @@ int NewHiScore() } } -#ifdef ONE_PER_NAME put_into_list: -#endif + strncpy(highscore[k].Name, setup.player_name, MAX_PLAYER_NAME_LEN); highscore[k].Name[MAX_PLAYER_NAME_LEN] = '\0'; highscore[k].Score = local_player->score_final; position = k; + break; } - -#ifdef ONE_PER_NAME - else if (!strncmp(setup.player_name, highscore[k].Name, + else if (one_score_entry_per_name && + !strncmp(setup.player_name, highscore[k].Name, MAX_PLAYER_NAME_LEN)) break; /* player already there with a higher score */ -#endif - } if (position >= 0) @@ -4924,36 +4922,21 @@ void DrawRelocateScreen(int old_x, int old_y, int x, int y, int move_dir, { /* relocation _with_ centering of screen */ - new_scroll_x = (x < SBX_Left + MIDPOSX ? SBX_Left : - x > SBX_Right + MIDPOSX ? SBX_Right : - x - MIDPOSX); - - new_scroll_y = (y < SBY_Upper + MIDPOSY ? SBY_Upper : - y > SBY_Lower + MIDPOSY ? SBY_Lower : - y - MIDPOSY); + new_scroll_x = SCROLL_POSITION_X(x); + new_scroll_y = SCROLL_POSITION_Y(y); } else { /* relocation _without_ centering of 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 center_scroll_x = SCROLL_POSITION_X(old_x); + int center_scroll_y = SCROLL_POSITION_Y(old_y); int offset_x = x + (scroll_x - center_scroll_x); int offset_y = y + (scroll_y - center_scroll_y); - new_scroll_x = (offset_x < SBX_Left + MIDPOSX ? SBX_Left : - offset_x > SBX_Right + MIDPOSX ? SBX_Right : - offset_x - MIDPOSX); - - new_scroll_y = (offset_y < SBY_Upper + MIDPOSY ? SBY_Upper : - offset_y > SBY_Lower + MIDPOSY ? SBY_Lower : - offset_y - MIDPOSY); + /* for new screen position, apply previous offset to center position */ + new_scroll_x = SCROLL_POSITION_X(offset_x); + new_scroll_y = SCROLL_POSITION_Y(offset_y); } if (quick_relocation)