Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit e09f57f

Browse files
committed
reduce conditional statement complexity in:
for (int star = 0; star < starCount; ++star) of: bool PlayIntroTitle()
1 parent 3f28910 commit e09f57f

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

Main.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -438,14 +438,25 @@ bool PlayIntroTitle() {
438438
StarSize size;
439439

440440
for (int star = 0; star < starCount; ++star) {
441-
aStars[star].m_Size = size = PosRand() < 0.95 ? StarSmall : (PosRand() < 0.85 ? StarLarge : StarHuge);
442-
aStars[star].m_pBitmap = size == StarSmall ? apStarSmallBitmaps[SelectRand(0, starSmallBitmapCount - 1)] :
443-
(size == StarLarge ? apStarLargeBitmaps[SelectRand(0, starLargeBitmapCount - 1)] : apStarHugeBitmaps[SelectRand(0, starLargeBitmapCount - 1)]);
441+
if (PosRand() < 0.95) {
442+
aStars[star].m_Size = StarSmall;
443+
aStars[star].m_pBitmap = apStarSmallBitmaps[SelectRand(0, starSmallBitmapCount - 1)];
444+
aStars[star].m_Intensity = RangeRand(0.001, 0.5);
445+
}
446+
else if (PosRand() < 0.85) {
447+
aStars[star].m_Size = StarLarge;
448+
aStars[star].m_pBitmap = apStarLargeBitmaps[SelectRand(0, starLargeBitmapCount - 1)];
449+
aStars[star].m_Intensity = RangeRand(0.6, 1.0);
450+
}
451+
else {
452+
aStars[star].m_Size = StarHuge;
453+
aStars[star].m_pBitmap = apStarHugeBitmaps[SelectRand(0, starLargeBitmapCount - 1)];
454+
aStars[star].m_Intensity = RangeRand(0.9, 1.0);
455+
}
444456
aStars[star].m_Pos.SetXY(resX * PosRand(), pBackdrop->GetBitmap()->h * PosRand());//resY * PosRand());
445457
aStars[star].m_Pos.Floor();
446458
// To match the nebula scroll
447459
aStars[star].m_ScrollRatio = backdropScrollRatio;
448-
aStars[star].m_Intensity = size == StarSmall ? RangeRand(0.001, 0.5) : (size == StarLarge ? RangeRand(0.6, 1.0) : RangeRand(0.9, 1.0));
449460
}
450461

451462
// Font stuff

0 commit comments

Comments
 (0)