From 8a0f81ec121d06a820f0028dfc0d0c01daa7c7c3 Mon Sep 17 00:00:00 2001 From: ephphatha Date: Mon, 27 Dec 2021 14:08:51 +1100 Subject: [PATCH] Pass regionId to TFit_Obj3 to extract reference to themes global --- Source/themes.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Source/themes.cpp b/Source/themes.cpp index 5137d258c..0f68e4ae9 100644 --- a/Source/themes.cpp +++ b/Source/themes.cpp @@ -191,13 +191,13 @@ bool CheckThemeObj3(Point origin, int8_t regionId, int frequency) }); } -bool TFit_Obj3(int t) +bool TFit_Obj3(int8_t regionId) { char objrnd[4] = { 4, 4, 3, 5 }; for (int yp = 1; yp < MAXDUNY - 1; yp++) { for (int xp = 1; xp < MAXDUNX - 1; xp++) { - if (CheckThemeObj3({ xp, yp }, themes[t].ttval, objrnd[leveltype - 1])) { + if (CheckThemeObj3({ xp, yp }, regionId, objrnd[leveltype - 1])) { themex = xp; themey = yp; return true; @@ -328,7 +328,7 @@ static bool SpecialThemeFit(int i, theme_id t) case THEME_BRNCROSS: case THEME_WEAPONRACK: if (rv) { - rv = TFit_Obj3(i); + rv = TFit_Obj3(themes[i].ttval); } break; case THEME_TREASURE: @@ -814,7 +814,7 @@ void Theme_ArmorStand(int t) char monstrnd[4] = { 6, 7, 3, 9 }; if (armorFlag) { - TFit_Obj3(t); + TFit_Obj3(themes[t].ttval); AddObject(OBJ_ARMORSTAND, { themex, themey }); } for (int yp = 0; yp < MAXDUNY; yp++) { @@ -899,13 +899,14 @@ void Theme_TearFountain(int t) */ void Theme_BrnCross(int t) { + int8_t regionId = themes[t].ttval; char monstrnd[4] = { 6, 8, 3, 9 }; char bcrossrnd[4] = { 5, 7, 3, 8 }; for (int yp = 0; yp < MAXDUNY; yp++) { for (int xp = 0; xp < MAXDUNX; xp++) { - if (dTransVal[xp][yp] == themes[t].ttval && IsTileNotSolid({ xp, yp })) { - if (CheckThemeObj3({ xp, yp }, themes[t].ttval, -1)) { + if (dTransVal[xp][yp] == regionId && IsTileNotSolid({ xp, yp })) { + if (CheckThemeObj3({ xp, yp }, regionId, -1)) { if (GenerateRnd(bcrossrnd[leveltype - 1]) == 0) { AddObject(OBJ_TBCROSS, { xp, yp }); } @@ -923,17 +924,18 @@ void Theme_BrnCross(int t) */ void Theme_WeaponRack(int t) { + int8_t regionId = themes[t].ttval; char weaponrnd[4] = { 6, 8, 5, 8 }; char monstrnd[4] = { 6, 7, 3, 9 }; if (weaponFlag) { - TFit_Obj3(t); + TFit_Obj3(regionId); AddObject(OBJ_WEAPONRACK, { themex, themey }); } for (int yp = 0; yp < MAXDUNY; yp++) { for (int xp = 0; xp < MAXDUNX; xp++) { - if (dTransVal[xp][yp] == themes[t].ttval && IsTileNotSolid({ xp, yp })) { - if (CheckThemeObj3({ xp, yp }, themes[t].ttval, -1)) { + if (dTransVal[xp][yp] == regionId && IsTileNotSolid({ xp, yp })) { + if (CheckThemeObj3({ xp, yp }, regionId, -1)) { if (GenerateRnd(weaponrnd[leveltype - 1]) == 0) { AddObject(OBJ_WEAPONRACKN, { xp, yp }); }