From de05ce656235c918f68ac274de9792bdaaaa00af Mon Sep 17 00:00:00 2001 From: ephphatha Date: Wed, 22 Jun 2022 12:06:42 +1000 Subject: [PATCH] Use theme room attributes directly instead of recalculating --- Source/engine/size.hpp | 11 +++++++++++ Source/gendung.cpp | 9 +++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Source/engine/size.hpp b/Source/engine/size.hpp index c2cdc9fcc..a53f23fca 100644 --- a/Source/engine/size.hpp +++ b/Source/engine/size.hpp @@ -41,6 +41,11 @@ struct Size { return *this; } + constexpr Size &operator-=(const int factor) + { + return *this += -factor; + } + constexpr Size &operator*=(const int factor) { width *= factor; @@ -68,6 +73,12 @@ struct Size { return a; } + constexpr friend Size operator-(Size a, const int factor) + { + a -= factor; + return a; + } + constexpr friend Size operator*(Size a, const int factor) { a *= factor; diff --git a/Source/gendung.cpp b/Source/gendung.cpp index 01a40fe28..4cff9c8dc 100644 --- a/Source/gendung.cpp +++ b/Source/gendung.cpp @@ -670,13 +670,14 @@ void DRLG_PlaceThemeRooms(int minSize, int maxSize, int floor, int freq, bool rn if (themeH < min || themeH > max) themeH = min; } - themeLoc[themeCount].room = { { i + 1, j + 1 }, { themeW, themeH } }; + THEME_LOC &theme = themeLoc[themeCount]; + theme.room = { Point { i, j } + Direction::South, Size { themeW, themeH } }; if (IsAnyOf(leveltype, DTYPE_CAVES, DTYPE_NEST)) { - DRLG_RectTrans({ Point(i + 2, j + 2).megaToWorld(), { themeW * 2 - 5, themeH * 2 - 5 } }); + DRLG_RectTrans({ (theme.room.position + Direction::South).megaToWorld(), theme.room.size * 2 - 5 }); } else { - DRLG_MRectTrans({ { i + 1, j + 1 }, { themeW - 1, themeH - 1 } }); + DRLG_MRectTrans({ theme.room.position, theme.room.size - 1 }); } - themeLoc[themeCount].ttval = TransVal - 1; + theme.ttval = TransVal - 1; CreateThemeRoom(themeCount); themeCount++; }