Skip to content

Commit

Permalink
Remove conditional for OOB read that isn't hit on win32
Browse files Browse the repository at this point in the history
Not sure if this changes behaviour on other platforms that diablo supported (macos?)
  • Loading branch information
ephphatha committed Mar 9, 2024
1 parent 7c49053 commit 78ab138
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 1 addition & 4 deletions Source/quests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,7 @@ void InitialiseQuestPools(uint32_t seed, Quest quests[])
DiabloGenerator rng(seed);
quests[rng.pickRandomlyAmong({ Q_SKELKING, Q_PWATER })]._qactive = QUEST_NOTAVAIL;

int QuestGroup1[3] { Q_BUTCHER, Q_LTBANNER, Q_GARBUD };
int randomIndex = rng.generateRnd(sizeof(QuestGroup1) / sizeof(*QuestGroup1));
if (randomIndex >= 0)
quests[randomIndex]._qactive = QUEST_NOTAVAIL;
quests[rng.pickRandomlyAmong({ Q_BUTCHER, Q_LTBANNER, Q_GARBUD })]._qactive = QUEST_NOTAVAIL;

quests[rng.pickRandomlyAmong({ Q_BLIND, Q_ROCK, Q_BLOOD })]._qactive = QUEST_NOTAVAIL;

Expand Down
2 changes: 1 addition & 1 deletion test/quests_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ TEST(QuestTest, SinglePlayerBadPools)
// Given Diablo was released in 1996 and it's currently 2024 this will never have been naturally hit. It's not
// possible to hit this case on a win32 system but it may be possible on macos or win64?
InitialiseQuestPools(988045466, Quests);
EXPECT_THAT(GetActiveFlagsForSlice({ Q_BUTCHER, Q_LTBANNER, Q_GARBUD }), ::testing::Each(QUEST_INIT)) << "All quests in pool 2 remain active with 'bad' seed";
EXPECT_EQ(Quests[Q_BUTCHER]._qactive, QUEST_NOTAVAIL) << "The Butcher should be deactivated with 'bad' seed";
ResetQuests();

// This seed can only be reached by editing a save file or modifying the game
Expand Down

0 comments on commit 78ab138

Please sign in to comment.