From b7fe72dcb4068a6d989231654382bd457209509c Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Thu, 30 Aug 2018 21:51:16 +0200 Subject: [PATCH] added using global levelset identifier and level number for network games This change/addition was required for correctly handling identifiers and level numbers when playing network games (for which the related levelset possibly does not exist locally, but was sent by the network server). This includes showing the correct level number for the level that is played over the network, and saving the resulting high scores for the correct level in the correct levelset score directory (again, even if this levelset or level number does not exist locally). --- src/files.c | 3 ++- src/game.c | 10 +++++----- src/libgame/setup.c | 4 +++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/files.c b/src/files.c index bb1ce497..efbc26f8 100644 --- a/src/files.c +++ b/src/files.c @@ -8281,7 +8281,8 @@ void SaveScore(int nr) char *filename = getScoreFilename(nr); FILE *file; - InitScoreDirectory(leveldir_current->subdir); + /* used instead of "leveldir_current->subdir" (for network games) */ + InitScoreDirectory(levelset.identifier); if (!(file = fopen(filename, MODE_WRITE))) { diff --git a/src/game.c b/src/game.c index a84acfb8..d63944fa 100644 --- a/src/game.c +++ b/src/game.c @@ -2224,8 +2224,8 @@ void UpdateGameControlValues() /* update game panel control values */ - /* use "level.file_info.nr" instead of "level_nr" (for network games) */ - game_panel_controls[GAME_PANEL_LEVEL_NUMBER].value = level.file_info.nr; + /* used instead of "level_nr" (for network games) */ + game_panel_controls[GAME_PANEL_LEVEL_NUMBER].value = levelset.level_nr; game_panel_controls[GAME_PANEL_GEMS].value = gems; game_panel_controls[GAME_PANEL_INVENTORY_COUNT].value = 0; @@ -4661,7 +4661,6 @@ void GameWon() void GameEnd() { int hi_pos; - int last_level_nr = level_nr; local_player->LevelSolved_GameEnd = TRUE; @@ -4717,13 +4716,14 @@ void GameEnd() } } - hi_pos = NewHiScore(last_level_nr); + /* used instead of last "level_nr" (for network games) */ + hi_pos = NewHiScore(levelset.level_nr); if (hi_pos >= 0 && !setup.skip_scores_after_game) { SetGameStatus(GAME_MODE_SCORES); - DrawHallOfFame(last_level_nr, hi_pos); + DrawHallOfFame(levelset.level_nr, hi_pos); } else if (setup.auto_play_next_level && setup.increment_levels && !network_playing) diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 802c673a..e9f28486 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -569,7 +569,9 @@ char *getScoreFilename(int nr) checked_free(filename); sprintf(basename, "%03d.%s", nr, SCOREFILE_EXTENSION); - filename = getPath2(getScoreDir(leveldir_current->subdir), basename); + + /* used instead of "leveldir_current->subdir" (for network games) */ + filename = getPath2(getScoreDir(levelset.identifier), basename); return filename; } -- 2.34.1