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

Clean up: AddShrine() [Second attempt] #7094

Merged
merged 5 commits into from Apr 20, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 19 additions & 13 deletions Source/objects.cpp
Expand Up @@ -1288,27 +1288,33 @@ void AddBarrel(Object &barrel)
void AddShrine(Object &shrine)
{
shrine._oRndSeed = AdvanceRndSeed();
bool slist[NumberOfShrineTypes];

shrine._oPreFlag = true;

int shrines = gbIsHellfire ? NumberOfShrineTypes : 26;
int shrineCount = gbIsHellfire ? NumberOfShrineTypes : 26;
bool slist[NumberOfShrineTypes] = { false };
AJenbo marked this conversation as resolved.
Show resolved Hide resolved
AJenbo marked this conversation as resolved.
Show resolved Hide resolved

for (int i = 0; i < shrineCount; i++) {
bool isShrineAvailable = true;

for (int j = 0; j < shrines; j++) {
slist[j] = j != ShrineEnchanted || IsAnyOf(leveltype, DTYPE_CATHEDRAL, DTYPE_CATACOMBS);
if (gbIsMultiplayer && shrineavail[j] == ShrineTypeSingle) {
slist[j] = false;
} else if (!gbIsMultiplayer && shrineavail[j] == ShrineTypeMulti) {
slist[j] = false;
if (gbIsMultiplayer) {
isShrineAvailable = (shrineavail[i] != ShrineTypeSingle);
} else {
isShrineAvailable = (shrineavail[i] != ShrineTypeMulti);
}

bool isEnchantedShrine = (i == ShrineEnchanted);
bool isCorrectLevelType = IsAnyOf(leveltype, DTYPE_CATHEDRAL, DTYPE_CATACOMBS);

slist[i] = isShrineAvailable && (!isEnchantedShrine || isCorrectLevelType);
}

int val;
int selectedIndex;
do {
val = GenerateRnd(shrines);
} while (!slist[val]);
selectedIndex = GenerateRnd(shrineCount);
} while (!slist[selectedIndex]);

shrine._oVar1 = selectedIndex;

shrine._oVar1 = val;
if (!FlipCoin()) {
shrine._oAnimFrame = 12;
shrine._oAnimLen = 22;
Expand Down