Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔥 Remove multiple game difficulties #17

Merged
merged 1 commit into from
Sep 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ set(libdevilutionx_SRCS
Source/DiabloUI/progress.cpp
Source/DiabloUI/scrollbar.cpp

Source/DiabloUI/selgame.cpp

Source/DiabloUI/selhero.cpp
Source/DiabloUI/selok.cpp
Source/DiabloUI/selyesno.cpp
Expand Down
3 changes: 1 addition & 2 deletions Source/DiabloUI/diabloui.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ struct _uiheroinfo {
char name[16];
uint8_t level;
HeroClass heroclass;
uint8_t herorank;
uint16_t strength;
uint16_t magic;
uint16_t dexterity;
Expand Down Expand Up @@ -83,7 +82,7 @@ inline SDL_Surface *DiabloUiSurface()
void UiDestroy();
void UiTitleDialog();
void UiInitialize();
void UiSelHeroSingDialog(bool (*fninfo)(bool (*fninfofunc)(_uiheroinfo *)), bool (*fncreate)(_uiheroinfo *), bool (*fnremove)(_uiheroinfo *), void (*fnstats)(unsigned int, _uidefaultstats *), _selhero_selections *dlgresult, uint32_t *saveNumber, _difficulty *difficulty);
void UiSelHeroSingDialog(bool (*fninfo)(bool (*fninfofunc)(_uiheroinfo *)), bool (*fncreate)(_uiheroinfo *), bool (*fnremove)(_uiheroinfo *), void (*fnstats)(unsigned int, _uidefaultstats *), _selhero_selections *dlgresult, uint32_t *saveNumber);
bool UiCreditsDialog();
bool UiSupportDialog();
bool UiMainMenuDialog(const char *name, _mainmenu_selections *pdwResult, void (*fnSound)(const char *file), int attractTimeOut);
Expand Down
162 changes: 0 additions & 162 deletions Source/DiabloUI/selgame.cpp

This file was deleted.

15 changes: 0 additions & 15 deletions Source/DiabloUI/selgame.h

This file was deleted.

18 changes: 2 additions & 16 deletions Source/DiabloUI/selhero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "DiabloUI/diabloui.h"
#include "DiabloUI/dialogs.h"
#include "DiabloUI/scrollbar.h"
#include "DiabloUI/selgame.h"
#include "DiabloUI/selok.h"
#include "DiabloUI/selyesno.h"
#include "control.h"
Expand Down Expand Up @@ -307,19 +306,8 @@ void SelheroLoadSelect(int value)
return;
}

// This is part of a dangerous hack to enable difficulty selection in single-player.
// FIXME: Dialogs should not refer to each other's variables.

// We disable `selhero_endMenu` and replace the background and art
// and the item list with the difficulty selection ones.
//
// This means selhero's render loop will render selgame's items,
// which happens to work because the render loops are similar.
selhero_endMenu = false;
SelheroFree();
LoadBackgroundArt("ui_art\\selgame.pcx");
selgame_GameSelection_Select();

selhero_endMenu = true;
selhero_result = SELHERO_NEW_DUNGEON;
}

Expand Down Expand Up @@ -472,11 +460,9 @@ void UiSelHeroSingDialog(
bool (*fnremove)(_uiheroinfo *),
void (*fnstats)(unsigned int, _uidefaultstats *),
_selhero_selections *dlgresult,
uint32_t *saveNumber,
_difficulty *difficulty)
uint32_t *saveNumber)
{
UiSelHeroDialog(fninfo, fncreate, fnstats, fnremove, dlgresult, saveNumber);
*difficulty = nDifficulty;
}

} // namespace devilution
9 changes: 2 additions & 7 deletions Source/diablo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1340,13 +1340,8 @@ void InitKeymapActions()
'V',
[] {
char pszStr[120];
const char *difficulties[3] = {
"Normal",
"Nightmare",
"Hell",
};
strcpy(pszStr, fmt::format("{:s}, version = {:s}, mode = {:s}",
gszProductName, PROJECT_VERSION, difficulties[sgGameInitInfo.nDifficulty])
strcpy(pszStr, fmt::format("{:s}, version = {:s}",
gszProductName, PROJECT_VERSION)
.c_str());
NetSendCmdString(1 << MyPlayerId, pszStr);
},
Expand Down
6 changes: 0 additions & 6 deletions Source/gendung.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,6 @@ enum {
// clang-format on
};

enum _difficulty : uint8_t {
DIFF_NORMAL,
DIFF_NIGHTMARE,
DIFF_HELL,
};

struct ScrollStruct {
/** @brief Tile offset of camera. */
Point tile;
Expand Down
13 changes: 1 addition & 12 deletions Source/items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3218,19 +3218,8 @@ void GetItemAttrs(Item &item, int itemData, int lvl)
if (item._itype != ItemType::Gold)
return;

int rndv;
int itemlevel = ItemsGetCurrlevel();
switch (sgGameInitInfo.nDifficulty) {
case DIFF_NORMAL:
rndv = 5 * itemlevel + GenerateRnd(10 * itemlevel);
break;
case DIFF_NIGHTMARE:
rndv = 5 * (itemlevel + 16) + GenerateRnd(10 * (itemlevel + 16));
break;
case DIFF_HELL:
rndv = 5 * (itemlevel + 32) + GenerateRnd(10 * (itemlevel + 32));
break;
}
int rndv = 5 * itemlevel + GenerateRnd(10 * itemlevel);
if (leveltype == DTYPE_HELL)
rndv += rndv / 8;

Expand Down
21 changes: 12 additions & 9 deletions Source/loadsave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,12 @@ void LoadPlayer(LoadHelper &file, Player &player)
player.wReflections = file.NextLE<uint16_t>();
file.Skip(14); // Available bytes

player.pDiabloKillLevel = file.NextLE<uint32_t>();
player.pDifficulty = static_cast<_difficulty>(file.NextLE<uint32_t>());
// Skip Diablo kill level
file.Skip<uint32_t>();

// Skip difficulty
file.Skip<uint32_t>();

player.pDamAcFlags = file.NextLE<uint32_t>();
file.Skip(20); // Available bytes
CalcPlrItemVals(player, false);
Expand Down Expand Up @@ -1195,8 +1199,12 @@ void SavePlayer(SaveHelper &file, const Player &player)
file.WriteLE<uint16_t>(player.wReflections);
file.Skip(14); // Available bytes

file.WriteLE<uint32_t>(player.pDiabloKillLevel);
file.WriteLE<uint32_t>(player.pDifficulty);
// Skip Diablo kill level
file.Skip<uint32_t>();

// Skip difficulty
file.Skip<uint32_t>();

file.WriteLE<uint32_t>(player.pDamAcFlags);
file.Skip(20); // Available bytes

Expand Down Expand Up @@ -1648,10 +1656,6 @@ void LoadGame(bool firstflag)

LoadPlayer(file, myPlayer);

sgGameInitInfo.nDifficulty = myPlayer.pDifficulty;
if (sgGameInitInfo.nDifficulty < DIFF_NORMAL || sgGameInitInfo.nDifficulty > DIFF_HELL)
sgGameInitInfo.nDifficulty = DIFF_NORMAL;

for (int i = 0; i < giNumberQuests; i++)
LoadQuest(&file, i);
for (int i = 0; i < MAXPORTAL; i++)
Expand Down Expand Up @@ -1861,7 +1865,6 @@ void SaveGameData()
}

auto &myPlayer = Players[MyPlayerId];
myPlayer.pDifficulty = sgGameInitInfo.nDifficulty;
SavePlayer(file, myPlayer);

for (int i = 0; i < giNumberQuests; i++)
Expand Down
3 changes: 1 addition & 2 deletions Source/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ bool mainmenu_select_hero_dialog(GameData *gameData)
pfile_delete_save,
pfile_ui_set_class_stats,
&dlgresult,
&gSaveNumber,
&gameData->nDifficulty);
&gSaveNumber);

gbLoadGame = (dlgresult == SELHERO_CONTINUE);

Expand Down
Loading