Cleanup of items.cpp (#1967)

- Apply Point where applicable
- Deduplicate vendor logic
- Add comment about unhanded edge case in GetSuperItemLoc
- Initialize some variables at deceleration
This commit is contained in:
Vladimir Olteanu 2021-05-17 01:12:53 +03:00 committed by GitHub
commit 0c7c71d579
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 457 additions and 621 deletions

View file

@ -596,7 +596,7 @@ void Theme_MonstPit(int t)
}
}
}
CreateRndItem(ixp, iyp, true, false, true);
CreateRndItem({ixp, iyp}, true, false, true);
ItemNoFlippy();
PlaceThemeMonsts(t, monstrnd[leveltype - 1]);
}
@ -690,11 +690,11 @@ void Theme_Treasure(int t)
int rv = GenerateRnd(treasrnd[leveltype - 1]);
// BUGFIX: the `2*` in `2*GenerateRnd(treasrnd...) == 0` has no effect, should probably be `GenerateRnd(2*treasrnd...) == 0`
if ((2 * GenerateRnd(treasrnd[leveltype - 1])) == 0) {
CreateTypeItem(xp, yp, false, ITYPE_GOLD, IMISC_NONE, false, true);
CreateTypeItem({xp, yp}, false, ITYPE_GOLD, IMISC_NONE, false, true);
ItemNoFlippy();
}
if (rv == 0) {
CreateRndItem(xp, yp, false, false, true);
CreateRndItem({xp, yp}, false, false, true);
ItemNoFlippy();
}
if (rv == 0 || rv >= treasrnd[leveltype - 1] - 2) {