Browse Source

Rename lighting globals

pull/2319/head
Anders Jenbo 5 years ago
parent
commit
dce78dde62
  1. 2
      Source/control.cpp
  2. 2
      Source/diablo.cpp
  3. 2
      Source/drlg_l1.cpp
  4. 12
      Source/engine/render/cel_render.cpp
  5. 4
      Source/engine/render/cl2_render.cpp
  6. 2
      Source/engine/render/common_impl.h
  7. 14
      Source/engine/render/dun_render.cpp
  8. 2
      Source/engine/render/text_render.cpp
  9. 2
      Source/gmenu.cpp
  10. 2
      Source/inv.cpp
  11. 232
      Source/lighting.cpp
  12. 24
      Source/lighting.h
  13. 36
      Source/loadsave.cpp
  14. 6
      Source/missiles.cpp
  15. 4
      Source/monster.cpp
  16. 2
      Source/objects.cpp
  17. 2
      Source/player.cpp
  18. 24
      Source/scrollrt.cpp
  19. 2
      Source/scrollrt.h
  20. 4
      test/drlg_l1_test.cpp

2
Source/control.cpp

@ -1533,7 +1533,7 @@ void DrawDurIcon(const Surface &out)
void RedBack(const Surface &out) void RedBack(const Surface &out)
{ {
uint8_t *dst = out.begin(); uint8_t *dst = out.begin();
uint8_t *tbl = &pLightTbl[4608]; uint8_t *tbl = &LightTables[4608];
for (int h = gnViewportHeight; h != 0; h--, dst += out.pitch() - gnScreenWidth) { for (int h = gnViewportHeight; h != 0; h--, dst += out.pitch() - gnScreenWidth) {
for (int w = gnScreenWidth; w != 0; w--) { for (int w = gnScreenWidth; w != 0; w--) {
if (leveltype != DTYPE_HELL || *dst >= 32) if (leveltype != DTYPE_HELL || *dst >= 32)

2
Source/diablo.cpp

@ -1458,7 +1458,7 @@ static void UpdateMonsterLights()
continue; continue;
} }
LightListStruct *lid = &LightList[mon->mlid]; LightStruct *lid = &Lights[mon->mlid];
if (mon->position.tile != lid->position.tile) { if (mon->position.tile != lid->position.tile) {
ChangeLightXY(mon->mlid, mon->position.tile); ChangeLightXY(mon->mlid, mon->position.tile);
} }

2
Source/drlg_l1.cpp

@ -964,7 +964,7 @@ void DRLG_Init_Globals()
memset(dItem, 0, sizeof(dItem)); memset(dItem, 0, sizeof(dItem));
memset(dMissile, 0, sizeof(dMissile)); memset(dMissile, 0, sizeof(dMissile));
memset(dSpecial, 0, sizeof(dSpecial)); memset(dSpecial, 0, sizeof(dSpecial));
int8_t c = lightflag ? 0 : 15; int8_t c = DisableLighting ? 0 : 15;
memset(dLight, c, sizeof(dLight)); memset(dLight, c, sizeof(dLight));
} }

12
Source/engine/render/cel_render.cpp

@ -547,7 +547,7 @@ void CelBlitSafeTo(const Surface &out, Point position, const byte *pRLEBytes, in
void CelBlitLightTransSafeTo(const Surface &out, Point position, const byte *pRLEBytes, int nDataSize, int nWidth) void CelBlitLightTransSafeTo(const Surface &out, Point position, const byte *pRLEBytes, int nDataSize, int nWidth)
{ {
assert(pRLEBytes != nullptr); assert(pRLEBytes != nullptr);
const std::uint8_t *tbl = &pLightTbl[light_table_index * 256]; const std::uint8_t *tbl = &LightTables[LightTableIndex * 256];
bool shift = (reinterpret_cast<uintptr_t>(&out[position]) % 2 == 1); bool shift = (reinterpret_cast<uintptr_t>(&out[position]) % 2 == 1);
const bool pitchIsEven = (out.pitch() % 2 == 0); const bool pitchIsEven = (out.pitch() % 2 == 0);
RenderCel( RenderCel(
@ -575,7 +575,7 @@ void CelBlitLightBlendedSafeTo(const Surface &out, Point position, const byte *p
{ {
assert(pRLEBytes != nullptr); assert(pRLEBytes != nullptr);
if (tbl == nullptr) if (tbl == nullptr)
tbl = &pLightTbl[light_table_index * 256]; tbl = &LightTables[LightTableIndex * 256];
RenderCel( RenderCel(
out, position, pRLEBytes, nDataSize, nWidth, [tbl](std::uint8_t *dst, const uint8_t *src, std::size_t w) { out, position, pRLEBytes, nDataSize, nWidth, [tbl](std::uint8_t *dst, const uint8_t *src, std::size_t w) {
@ -599,7 +599,7 @@ void CelBlitLightSafeTo(const Surface &out, Point position, const byte *pRLEByte
{ {
assert(pRLEBytes != nullptr); assert(pRLEBytes != nullptr);
if (tbl == nullptr) if (tbl == nullptr)
tbl = &pLightTbl[light_table_index * 256]; tbl = &LightTables[LightTableIndex * 256];
RenderCelWithLightTable(out, position, pRLEBytes, nDataSize, nWidth, tbl); RenderCelWithLightTable(out, position, pRLEBytes, nDataSize, nWidth, tbl);
} }
@ -625,7 +625,7 @@ void CelDrawLightTo(const Surface &out, Point position, const CelSprite &cel, in
int nDataSize; int nDataSize;
const auto *pRLEBytes = CelGetFrame(cel.Data(), frame, &nDataSize); const auto *pRLEBytes = CelGetFrame(cel.Data(), frame, &nDataSize);
if (light_table_index != 0 || tbl != nullptr) if (LightTableIndex != 0 || tbl != nullptr)
CelBlitLightSafeTo(out, position, pRLEBytes, nDataSize, cel.Width(frame), tbl); CelBlitLightSafeTo(out, position, pRLEBytes, nDataSize, cel.Width(frame), tbl);
else else
CelBlitSafeTo(out, position, pRLEBytes, nDataSize, cel.Width(frame)); CelBlitSafeTo(out, position, pRLEBytes, nDataSize, cel.Width(frame));
@ -636,7 +636,7 @@ void CelClippedDrawLightTo(const Surface &out, Point position, const CelSprite &
int nDataSize; int nDataSize;
const auto *pRLEBytes = CelGetFrameClipped(cel.Data(), frame, &nDataSize); const auto *pRLEBytes = CelGetFrameClipped(cel.Data(), frame, &nDataSize);
if (light_table_index != 0) if (LightTableIndex != 0)
CelBlitLightSafeTo(out, position, pRLEBytes, nDataSize, cel.Width(frame), nullptr); CelBlitLightSafeTo(out, position, pRLEBytes, nDataSize, cel.Width(frame), nullptr);
else else
CelBlitSafeTo(out, position, pRLEBytes, nDataSize, cel.Width(frame)); CelBlitSafeTo(out, position, pRLEBytes, nDataSize, cel.Width(frame));
@ -676,7 +676,7 @@ void CelClippedBlitLightTransTo(const Surface &out, Point position, const CelSpr
CelBlitLightBlendedSafeTo(out, position, pRLEBytes, nDataSize, cel.Width(frame), nullptr); CelBlitLightBlendedSafeTo(out, position, pRLEBytes, nDataSize, cel.Width(frame), nullptr);
else else
CelBlitLightTransSafeTo(out, position, pRLEBytes, nDataSize, cel.Width(frame)); CelBlitLightTransSafeTo(out, position, pRLEBytes, nDataSize, cel.Width(frame));
} else if (light_table_index != 0) } else if (LightTableIndex != 0)
CelBlitLightSafeTo(out, position, pRLEBytes, nDataSize, cel.Width(frame), nullptr); CelBlitLightSafeTo(out, position, pRLEBytes, nDataSize, cel.Width(frame), nullptr);
else else
CelBlitSafeTo(out, position, pRLEBytes, nDataSize, cel.Width(frame)); CelBlitSafeTo(out, position, pRLEBytes, nDataSize, cel.Width(frame));

4
Source/engine/render/cl2_render.cpp

@ -799,8 +799,8 @@ void Cl2DrawLight(const Surface &out, int sx, int sy, const CelSprite &cel, int
int nDataSize; int nDataSize;
const byte *pRLEBytes = CelGetFrameClipped(cel.Data(), frame, &nDataSize); const byte *pRLEBytes = CelGetFrameClipped(cel.Data(), frame, &nDataSize);
if (light_table_index != 0) if (LightTableIndex != 0)
Cl2BlitLightSafe(out, sx, sy, pRLEBytes, nDataSize, cel.Width(frame), &pLightTbl[light_table_index * 256]); Cl2BlitLightSafe(out, sx, sy, pRLEBytes, nDataSize, cel.Width(frame), &LightTables[LightTableIndex * 256]);
else else
Cl2BlitSafe(out, sx, sy, pRLEBytes, nDataSize, cel.Width(frame)); Cl2BlitSafe(out, sx, sy, pRLEBytes, nDataSize, cel.Width(frame));
} }

2
Source/engine/render/common_impl.h

@ -20,7 +20,7 @@ inline std::uint8_t *GetLightTable(char light)
idx += 256; // gray colors idx += 256; // gray colors
if (light >= 4) if (light >= 4)
idx += (light - 1) << 8; idx += (light - 1) << 8;
return &pLightTbl[idx]; return &LightTables[idx];
} }
struct ClipX { struct ClipX {

14
Source/engine/render/dun_render.cpp

@ -1396,16 +1396,16 @@ void RenderTile(const Surface &out, int x, int y)
if (clip.width <= 0 || clip.height <= 0) if (clip.width <= 0 || clip.height <= 0)
return; return;
const std::uint8_t *tbl = &pLightTbl[256 * light_table_index]; const std::uint8_t *tbl = &LightTables[256 * LightTableIndex];
const auto *pFrameTable = reinterpret_cast<const std::uint32_t *>(pDungeonCels.get()); const auto *pFrameTable = reinterpret_cast<const std::uint32_t *>(pDungeonCels.get());
const auto *src = reinterpret_cast<const std::uint8_t *>(&pDungeonCels[SDL_SwapLE32(pFrameTable[level_cel_block & 0xFFF])]); const auto *src = reinterpret_cast<const std::uint8_t *>(&pDungeonCels[SDL_SwapLE32(pFrameTable[level_cel_block & 0xFFF])]);
std::uint8_t *dst = out.at(static_cast<int>(x + clip.left), static_cast<int>(y - clip.bottom)); std::uint8_t *dst = out.at(static_cast<int>(x + clip.left), static_cast<int>(y - clip.bottom));
const auto dstPitch = out.pitch(); const auto dstPitch = out.pitch();
if (mask == &SolidMask[TILE_HEIGHT - 1]) { if (mask == &SolidMask[TILE_HEIGHT - 1]) {
if (light_table_index == lightmax) { if (LightTableIndex == LightsMax) {
RenderTileType<TransparencyType::Solid, LightType::FullyDark>(tile, dst, dstPitch, src, mask, tbl, clip); RenderTileType<TransparencyType::Solid, LightType::FullyDark>(tile, dst, dstPitch, src, mask, tbl, clip);
} else if (light_table_index == 0) { } else if (LightTableIndex == 0) {
RenderTileType<TransparencyType::Solid, LightType::FullyLit>(tile, dst, dstPitch, src, mask, tbl, clip); RenderTileType<TransparencyType::Solid, LightType::FullyLit>(tile, dst, dstPitch, src, mask, tbl, clip);
} else { } else {
RenderTileType<TransparencyType::Solid, LightType::PartiallyLit>(tile, dst, dstPitch, src, mask, tbl, clip); RenderTileType<TransparencyType::Solid, LightType::PartiallyLit>(tile, dst, dstPitch, src, mask, tbl, clip);
@ -1413,17 +1413,17 @@ void RenderTile(const Surface &out, int x, int y)
} else { } else {
mask -= clip.bottom; mask -= clip.bottom;
if (sgOptions.Graphics.bBlendedTransparancy) { if (sgOptions.Graphics.bBlendedTransparancy) {
if (light_table_index == lightmax) { if (LightTableIndex == LightsMax) {
RenderTileType<TransparencyType::Blended, LightType::FullyDark>(tile, dst, dstPitch, src, mask, tbl, clip); RenderTileType<TransparencyType::Blended, LightType::FullyDark>(tile, dst, dstPitch, src, mask, tbl, clip);
} else if (light_table_index == 0) { } else if (LightTableIndex == 0) {
RenderTileType<TransparencyType::Blended, LightType::FullyLit>(tile, dst, dstPitch, src, mask, tbl, clip); RenderTileType<TransparencyType::Blended, LightType::FullyLit>(tile, dst, dstPitch, src, mask, tbl, clip);
} else { } else {
RenderTileType<TransparencyType::Blended, LightType::PartiallyLit>(tile, dst, dstPitch, src, mask, tbl, clip); RenderTileType<TransparencyType::Blended, LightType::PartiallyLit>(tile, dst, dstPitch, src, mask, tbl, clip);
} }
} else { } else {
if (light_table_index == lightmax) { if (LightTableIndex == LightsMax) {
RenderTileType<TransparencyType::Stippled, LightType::FullyDark>(tile, dst, dstPitch, src, mask, tbl, clip); RenderTileType<TransparencyType::Stippled, LightType::FullyDark>(tile, dst, dstPitch, src, mask, tbl, clip);
} else if (light_table_index == 0) { } else if (LightTableIndex == 0) {
RenderTileType<TransparencyType::Stippled, LightType::FullyLit>(tile, dst, dstPitch, src, mask, tbl, clip); RenderTileType<TransparencyType::Stippled, LightType::FullyLit>(tile, dst, dstPitch, src, mask, tbl, clip);
} else { } else {
RenderTileType<TransparencyType::Stippled, LightType::PartiallyLit>(tile, dst, dstPitch, src, mask, tbl, clip); RenderTileType<TransparencyType::Stippled, LightType::PartiallyLit>(tile, dst, dstPitch, src, mask, tbl, clip);

2
Source/engine/render/text_render.cpp

@ -153,7 +153,7 @@ void DrawChar(const Surface &out, Point position, GameFontTables size, int nCel,
CelDrawLightTo(out, position, *fonts[size], nCel, fontColorTableGold); CelDrawLightTo(out, position, *fonts[size], nCel, fontColorTableGold);
break; break;
case ColorBlack: case ColorBlack:
light_table_index = 15; LightTableIndex = 15;
CelDrawLightTo(out, position, *fonts[size], nCel, nullptr); CelDrawLightTo(out, position, *fonts[size], nCel, nullptr);
return; return;
} }

2
Source/gmenu.cpp

@ -39,7 +39,7 @@ void gmenu_draw_pause(const Surface &out)
if (currlevel != 0) if (currlevel != 0)
RedBack(out); RedBack(out);
if (sgpCurrentMenu == nullptr) { if (sgpCurrentMenu == nullptr) {
light_table_index = 0; LightTableIndex = 0;
DrawString(out, _("Pause"), Point { 0, PANEL_TOP / 2 }, UIS_HUGE | UIS_CENTER, 2); DrawString(out, _("Pause"), Point { 0, PANEL_TOP / 2 }, UIS_HUGE | UIS_CENTER, 2);
} }
} }

2
Source/inv.cpp

@ -247,7 +247,7 @@ void DrawInv(const Surface &out)
|| (myPlayer.InvBody[slot]._itype != ITYPE_SWORD || (myPlayer.InvBody[slot]._itype != ITYPE_SWORD
&& myPlayer.InvBody[slot]._itype != ITYPE_MACE)) { && myPlayer.InvBody[slot]._itype != ITYPE_MACE)) {
InvDrawSlotBack(out, { RIGHT_PANEL_X + slotPos[INVLOC_HAND_RIGHT].x, slotPos[INVLOC_HAND_RIGHT].y }, { slotSize[INVLOC_HAND_RIGHT].width * InventorySlotSizeInPixels.width, slotSize[INVLOC_HAND_RIGHT].height * InventorySlotSizeInPixels.height }); InvDrawSlotBack(out, { RIGHT_PANEL_X + slotPos[INVLOC_HAND_RIGHT].x, slotPos[INVLOC_HAND_RIGHT].y }, { slotSize[INVLOC_HAND_RIGHT].width * InventorySlotSizeInPixels.width, slotSize[INVLOC_HAND_RIGHT].height * InventorySlotSizeInPixels.height });
light_table_index = 0; LightTableIndex = 0;
cel_transparency_active = true; cel_transparency_active = true;
const int dstX = RIGHT_PANEL_X + slotPos[INVLOC_HAND_RIGHT].x + (frameSize.width == InventorySlotSizeInPixels.width ? INV_SLOT_HALF_SIZE_PX : 0) - 1; const int dstX = RIGHT_PANEL_X + slotPos[INVLOC_HAND_RIGHT].x + (frameSize.width == InventorySlotSizeInPixels.width ? INV_SLOT_HALF_SIZE_PX : 0) - 1;

232
Source/lighting.cpp

@ -12,19 +12,19 @@
namespace devilution { namespace devilution {
LightListStruct VisionList[MAXVISION]; LightStruct VisionList[MAXVISION];
uint8_t lightactive[MAXLIGHTS]; uint8_t ActiveLights[MAXLIGHTS];
LightListStruct LightList[MAXLIGHTS]; LightStruct Lights[MAXLIGHTS];
int numlights; int ActiveLightCount;
uint8_t lightradius[16][128]; uint8_t lightradius[16][128];
bool dovision; bool dovision;
int numvision; int VisionCount;
char lightmax; char LightsMax;
bool dolighting; bool UpdateLighting;
uint8_t lightblock[64][16][16]; uint8_t lightblock[64][16][16];
int visionid; int VisionId;
std::array<uint8_t, LIGHTSIZE> pLightTbl; std::array<uint8_t, LIGHTSIZE> LightTables;
bool lightflag; bool DisableLighting;
/** /**
* CrawlTable specifies X- and Y-coordinate deltas from a missile target coordinate. * CrawlTable specifies X- and Y-coordinate deltas from a missile target coordinate.
@ -416,10 +416,10 @@ const char CrawlTable[2749] = {
}; };
/* /*
* vCrawlTable specifies the X- Y-coordinate offsets of lighting visions. * VisionCrawlTable specifies the X- Y-coordinate offsets of lighting visions.
* The last entry-pair is only for alignment. * The last entry-pair is only for alignment.
*/ */
const BYTE vCrawlTable[23][30] = { const BYTE VisionCrawlTable[23][30] = {
// clang-format off // clang-format off
{ 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0 }, { 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0 },
{ 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 1 }, { 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 1 },
@ -447,7 +447,7 @@ const BYTE vCrawlTable[23][30] = {
// clang-format on // clang-format on
}; };
/** RadiusAdj maps from vCrawlTable index to lighting vision radius adjustment. */ /** RadiusAdj maps from VisionCrawlTable index to lighting vision radius adjustment. */
const BYTE RadiusAdj[23] = { 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 4, 3, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0 }; const BYTE RadiusAdj[23] = { 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 4, 3, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0 };
void RotateRadius(int *x, int *y, int *dx, int *dy, int *lx, int *ly, int *bx, int *by) void RotateRadius(int *x, int *y, int *dx, int *dy, int *lx, int *ly, int *bx, int *by)
@ -501,8 +501,8 @@ void DoLighting(Point position, int nRadius, int lnum)
int blockY = 0; int blockY = 0;
if (lnum >= 0) { if (lnum >= 0) {
xoff = LightList[lnum].position.offset.x; xoff = Lights[lnum].position.offset.x;
yoff = LightList[lnum].position.offset.y; yoff = Lights[lnum].position.offset.y;
if (xoff < 0) { if (xoff < 0) {
xoff += 8; xoff += 8;
position -= { 1, 0 }; position -= { 1, 0 };
@ -682,33 +682,33 @@ void DoVision(Point position, int nRadius, bool doautomap, bool visible)
int nCrawlY = 0; int nCrawlY = 0;
switch (v) { switch (v) {
case 0: case 0:
nCrawlX = position.x + vCrawlTable[j][k]; nCrawlX = position.x + VisionCrawlTable[j][k];
nCrawlY = position.y + vCrawlTable[j][k + 1]; nCrawlY = position.y + VisionCrawlTable[j][k + 1];
if (vCrawlTable[j][k] > 0 && vCrawlTable[j][k + 1] > 0) { if (VisionCrawlTable[j][k] > 0 && VisionCrawlTable[j][k + 1] > 0) {
x1adj = -1; x1adj = -1;
y2adj = -1; y2adj = -1;
} }
break; break;
case 1: case 1:
nCrawlX = position.x - vCrawlTable[j][k]; nCrawlX = position.x - VisionCrawlTable[j][k];
nCrawlY = position.y - vCrawlTable[j][k + 1]; nCrawlY = position.y - VisionCrawlTable[j][k + 1];
if (vCrawlTable[j][k] > 0 && vCrawlTable[j][k + 1] > 0) { if (VisionCrawlTable[j][k] > 0 && VisionCrawlTable[j][k + 1] > 0) {
y1adj = 1; y1adj = 1;
x2adj = 1; x2adj = 1;
} }
break; break;
case 2: case 2:
nCrawlX = position.x + vCrawlTable[j][k]; nCrawlX = position.x + VisionCrawlTable[j][k];
nCrawlY = position.y - vCrawlTable[j][k + 1]; nCrawlY = position.y - VisionCrawlTable[j][k + 1];
if (vCrawlTable[j][k] > 0 && vCrawlTable[j][k + 1] > 0) { if (VisionCrawlTable[j][k] > 0 && VisionCrawlTable[j][k + 1] > 0) {
x1adj = -1; x1adj = -1;
y2adj = 1; y2adj = 1;
} }
break; break;
case 3: case 3:
nCrawlX = position.x - vCrawlTable[j][k]; nCrawlX = position.x - VisionCrawlTable[j][k];
nCrawlY = position.y + vCrawlTable[j][k + 1]; nCrawlY = position.y + VisionCrawlTable[j][k + 1];
if (vCrawlTable[j][k] > 0 && vCrawlTable[j][k + 1] > 0) { if (VisionCrawlTable[j][k] > 0 && VisionCrawlTable[j][k + 1] > 0) {
y1adj = -1; y1adj = -1;
x2adj = 1; x2adj = 1;
} }
@ -745,7 +745,7 @@ void DoVision(Point position, int nRadius, bool doautomap, bool visible)
void MakeLightTable() void MakeLightTable()
{ {
uint8_t *tbl = pLightTbl.data(); uint8_t *tbl = LightTables.data();
int shade = 0; int shade = 0;
int lights = 15; int lights = 15;
@ -805,7 +805,7 @@ void MakeLightTable()
if (leveltype == DTYPE_HELL) { if (leveltype == DTYPE_HELL) {
BYTE blood[16]; BYTE blood[16];
tbl = pLightTbl.data(); tbl = LightTables.data();
for (int i = 0; i < lights; i++) { for (int i = 0; i < lights; i++) {
int l1 = lights - i; int l1 = lights - i;
int l2 = l1; int l2 = l1;
@ -845,7 +845,7 @@ void MakeLightTable()
tbl += 224; tbl += 224;
} }
if (currlevel >= 17) { if (currlevel >= 17) {
tbl = pLightTbl.data(); tbl = LightTables.data();
for (int i = 0; i < lights; i++) { for (int i = 0; i < lights; i++) {
*tbl++ = 0; *tbl++ = 0;
for (int j = 1; j < 16; j++) for (int j = 1; j < 16; j++)
@ -932,9 +932,9 @@ void MakeLightTable()
#ifdef _DEBUG #ifdef _DEBUG
void ToggleLighting() void ToggleLighting()
{ {
lightflag = !lightflag; DisableLighting = !DisableLighting;
if (lightflag) { if (DisableLighting) {
memset(dLight, 0, sizeof(dLight)); memset(dLight, 0, sizeof(dLight));
return; return;
} }
@ -950,17 +950,17 @@ void ToggleLighting()
void InitLightMax() void InitLightMax()
{ {
lightmax = 15; LightsMax = 15;
} }
void InitLighting() void InitLighting()
{ {
numlights = 0; ActiveLightCount = 0;
dolighting = false; UpdateLighting = false;
lightflag = false; DisableLighting = false;
for (int i = 0; i < MAXLIGHTS; i++) { for (int i = 0; i < MAXLIGHTS; i++) {
lightactive[i] = i; ActiveLights[i] = i;
} }
} }
@ -968,20 +968,20 @@ int AddLight(Point position, int r)
{ {
int lid; int lid;
if (lightflag) { if (DisableLighting) {
return NO_LIGHT; return NO_LIGHT;
} }
lid = NO_LIGHT; lid = NO_LIGHT;
if (numlights < MAXLIGHTS) { if (ActiveLightCount < MAXLIGHTS) {
lid = lightactive[numlights++]; lid = ActiveLights[ActiveLightCount++];
LightList[lid].position.tile = position; Lights[lid].position.tile = position;
LightList[lid]._lradius = r; Lights[lid]._lradius = r;
LightList[lid].position.offset = { 0, 0 }; Lights[lid].position.offset = { 0, 0 };
LightList[lid]._ldel = false; Lights[lid]._ldel = false;
LightList[lid]._lunflag = false; Lights[lid]._lunflag = false;
dolighting = true; UpdateLighting = true;
} }
return lid; return lid;
@ -989,104 +989,104 @@ int AddLight(Point position, int r)
void AddUnLight(int i) void AddUnLight(int i)
{ {
if (lightflag || i == NO_LIGHT) { if (DisableLighting || i == NO_LIGHT) {
return; return;
} }
LightList[i]._ldel = true; Lights[i]._ldel = true;
dolighting = true; UpdateLighting = true;
} }
void ChangeLightRadius(int i, int r) void ChangeLightRadius(int i, int r)
{ {
if (lightflag || i == NO_LIGHT) { if (DisableLighting || i == NO_LIGHT) {
return; return;
} }
LightList[i]._lunflag = true; Lights[i]._lunflag = true;
LightList[i].position.old = LightList[i].position.tile; Lights[i].position.old = Lights[i].position.tile;
LightList[i].oldRadius = LightList[i]._lradius; Lights[i].oldRadius = Lights[i]._lradius;
LightList[i]._lradius = r; Lights[i]._lradius = r;
dolighting = true; UpdateLighting = true;
} }
void ChangeLightXY(int i, Point position) void ChangeLightXY(int i, Point position)
{ {
if (lightflag || i == NO_LIGHT) { if (DisableLighting || i == NO_LIGHT) {
return; return;
} }
LightList[i]._lunflag = true; Lights[i]._lunflag = true;
LightList[i].position.old = LightList[i].position.tile; Lights[i].position.old = Lights[i].position.tile;
LightList[i].oldRadius = LightList[i]._lradius; Lights[i].oldRadius = Lights[i]._lradius;
LightList[i].position.tile = position; Lights[i].position.tile = position;
dolighting = true; UpdateLighting = true;
} }
void ChangeLightOff(int i, Point position) void ChangeLightOff(int i, Point position)
{ {
if (lightflag || i == NO_LIGHT) { if (DisableLighting || i == NO_LIGHT) {
return; return;
} }
LightList[i]._lunflag = true; Lights[i]._lunflag = true;
LightList[i].position.old = LightList[i].position.tile; Lights[i].position.old = Lights[i].position.tile;
LightList[i].oldRadius = LightList[i]._lradius; Lights[i].oldRadius = Lights[i]._lradius;
LightList[i].position.offset = position; Lights[i].position.offset = position;
dolighting = true; UpdateLighting = true;
} }
void ChangeLight(int i, Point position, int r) void ChangeLight(int i, Point position, int r)
{ {
if (lightflag || i == NO_LIGHT) { if (DisableLighting || i == NO_LIGHT) {
return; return;
} }
LightList[i]._lunflag = true; Lights[i]._lunflag = true;
LightList[i].position.old = LightList[i].position.tile; Lights[i].position.old = Lights[i].position.tile;
LightList[i].oldRadius = LightList[i]._lradius; Lights[i].oldRadius = Lights[i]._lradius;
LightList[i].position.tile = position; Lights[i].position.tile = position;
LightList[i]._lradius = r; Lights[i]._lradius = r;
dolighting = true; UpdateLighting = true;
} }
void ProcessLightList() void ProcessLightList()
{ {
if (lightflag) { if (DisableLighting) {
return; return;
} }
if (dolighting) { if (UpdateLighting) {
for (int i = 0; i < numlights; i++) { for (int i = 0; i < ActiveLightCount; i++) {
int j = lightactive[i]; int j = ActiveLights[i];
if (LightList[j]._ldel) { if (Lights[j]._ldel) {
DoUnLight(LightList[j].position.tile.x, LightList[j].position.tile.y, LightList[j]._lradius); DoUnLight(Lights[j].position.tile.x, Lights[j].position.tile.y, Lights[j]._lradius);
} }
if (LightList[j]._lunflag) { if (Lights[j]._lunflag) {
DoUnLight(LightList[j].position.old.x, LightList[j].position.old.y, LightList[j].oldRadius); DoUnLight(Lights[j].position.old.x, Lights[j].position.old.y, Lights[j].oldRadius);
LightList[j]._lunflag = false; Lights[j]._lunflag = false;
} }
} }
for (int i = 0; i < numlights; i++) { for (int i = 0; i < ActiveLightCount; i++) {
int j = lightactive[i]; int j = ActiveLights[i];
if (!LightList[j]._ldel) { if (!Lights[j]._ldel) {
DoLighting(LightList[j].position.tile, LightList[j]._lradius, j); DoLighting(Lights[j].position.tile, Lights[j]._lradius, j);
} }
} }
int i = 0; int i = 0;
while (i < numlights) { while (i < ActiveLightCount) {
if (LightList[lightactive[i]]._ldel) { if (Lights[ActiveLights[i]]._ldel) {
numlights--; ActiveLightCount--;
BYTE temp = lightactive[numlights]; BYTE temp = ActiveLights[ActiveLightCount];
lightactive[numlights] = lightactive[i]; ActiveLights[ActiveLightCount] = ActiveLights[i];
lightactive[i] = temp; ActiveLights[i] = temp;
} else { } else {
i++; i++;
} }
} }
} }
dolighting = false; UpdateLighting = false;
} }
void SavePreLighting() void SavePreLighting()
@ -1096,9 +1096,9 @@ void SavePreLighting()
void InitVision() void InitVision()
{ {
numvision = 0; VisionCount = 0;
dovision = false; dovision = false;
visionid = 1; VisionId = 1;
for (int i = 0; i < TransVal; i++) { for (int i = 0; i < TransVal; i++) {
TransList[i] = false; TransList[i] = false;
@ -1107,17 +1107,17 @@ void InitVision()
int AddVision(Point position, int r, bool mine) int AddVision(Point position, int r, bool mine)
{ {
int vid = -1; // BUGFIX: if numvision >= MAXVISION behavior is undefined (fixed) int vid = -1; // BUGFIX: if VisionCount >= MAXVISION behavior is undefined (fixed)
if (numvision < MAXVISION) { if (VisionCount < MAXVISION) {
VisionList[numvision].position.tile = position; VisionList[VisionCount].position.tile = position;
VisionList[numvision]._lradius = r; VisionList[VisionCount]._lradius = r;
vid = visionid++; vid = VisionId++;
VisionList[numvision]._lid = vid; VisionList[VisionCount]._lid = vid;
VisionList[numvision]._ldel = false; VisionList[VisionCount]._ldel = false;
VisionList[numvision]._lunflag = false; VisionList[VisionCount]._lunflag = false;
VisionList[numvision]._lflags = mine; VisionList[VisionCount]._lflags = mine;
numvision++; VisionCount++;
dovision = true; dovision = true;
} }
@ -1126,7 +1126,7 @@ int AddVision(Point position, int r, bool mine)
void ChangeVisionRadius(int id, int r) void ChangeVisionRadius(int id, int r)
{ {
for (int i = 0; i < numvision; i++) { for (int i = 0; i < VisionCount; i++) {
if (VisionList[i]._lid == id) { if (VisionList[i]._lid == id) {
VisionList[i]._lunflag = true; VisionList[i]._lunflag = true;
VisionList[i].position.old = VisionList[i].position.tile; VisionList[i].position.old = VisionList[i].position.tile;
@ -1139,7 +1139,7 @@ void ChangeVisionRadius(int id, int r)
void ChangeVisionXY(int id, Point position) void ChangeVisionXY(int id, Point position)
{ {
for (int i = 0; i < numvision; i++) { for (int i = 0; i < VisionCount; i++) {
if (VisionList[i]._lid == id) { if (VisionList[i]._lid == id) {
VisionList[i]._lunflag = true; VisionList[i]._lunflag = true;
VisionList[i].position.old = VisionList[i].position.tile; VisionList[i].position.old = VisionList[i].position.tile;
@ -1153,7 +1153,7 @@ void ChangeVisionXY(int id, Point position)
void ProcessVisionList() void ProcessVisionList()
{ {
if (dovision) { if (dovision) {
for (int i = 0; i < numvision; i++) { for (int i = 0; i < VisionCount; i++) {
if (VisionList[i]._ldel) { if (VisionList[i]._ldel) {
DoUnVision(VisionList[i].position.tile, VisionList[i]._lradius); DoUnVision(VisionList[i].position.tile, VisionList[i]._lradius);
} }
@ -1165,7 +1165,7 @@ void ProcessVisionList()
for (int i = 0; i < TransVal; i++) { for (int i = 0; i < TransVal; i++) {
TransList[i] = false; TransList[i] = false;
} }
for (int i = 0; i < numvision; i++) { for (int i = 0; i < VisionCount; i++) {
if (!VisionList[i]._ldel) { if (!VisionList[i]._ldel) {
DoVision( DoVision(
VisionList[i].position.tile, VisionList[i].position.tile,
@ -1177,11 +1177,11 @@ void ProcessVisionList()
bool delflag; bool delflag;
do { do {
delflag = false; delflag = false;
for (int i = 0; i < numvision; i++) { for (int i = 0; i < VisionCount; i++) {
if (VisionList[i]._ldel) { if (VisionList[i]._ldel) {
numvision--; VisionCount--;
if (numvision > 0 && i != numvision) { if (VisionCount > 0 && i != VisionCount) {
VisionList[i] = VisionList[numvision]; VisionList[i] = VisionList[VisionCount];
} }
delflag = true; delflag = true;
} }
@ -1198,7 +1198,7 @@ void lighting_color_cycling()
return; return;
} }
uint8_t *tbl = pLightTbl.data(); uint8_t *tbl = LightTables.data();
for (int j = 0; j < 16; j++) { for (int j = 0; j < 16; j++) {
tbl++; tbl++;

24
Source/lighting.h

@ -26,7 +26,7 @@ struct LightPosition {
Point old; Point old;
}; };
struct LightListStruct { struct LightStruct {
LightPosition position; LightPosition position;
int _lradius; int _lradius;
int _lid; int _lid;
@ -36,16 +36,16 @@ struct LightListStruct {
bool _lflags; bool _lflags;
}; };
extern LightListStruct VisionList[MAXVISION]; extern LightStruct VisionList[MAXVISION];
extern uint8_t lightactive[MAXLIGHTS]; extern int VisionCount;
extern LightListStruct LightList[MAXLIGHTS]; extern int VisionId;
extern int numlights; extern LightStruct Lights[MAXLIGHTS];
extern int numvision; extern uint8_t ActiveLights[MAXLIGHTS];
extern char lightmax; extern int ActiveLightCount;
extern bool dolighting; extern char LightsMax;
extern int visionid; extern std::array<BYTE, LIGHTSIZE> LightTables;
extern std::array<BYTE, LIGHTSIZE> pLightTbl; extern bool DisableLighting;
extern bool lightflag; extern bool UpdateLighting;
void DoLighting(Point position, int nRadius, int Lnum); void DoLighting(Point position, int nRadius, int Lnum);
void DoUnVision(Point position, int nRadius); void DoUnVision(Point position, int nRadius);
@ -74,6 +74,6 @@ void lighting_color_cycling();
/* rdata */ /* rdata */
extern const char CrawlTable[2749]; extern const char CrawlTable[2749];
extern const BYTE vCrawlTable[23][30]; extern const BYTE VisionCrawlTable[23][30];
} // namespace devilution } // namespace devilution

36
Source/loadsave.cpp

@ -788,7 +788,7 @@ static void LoadQuest(LoadHelper *file, int i)
file->Skip(sizeof(int32_t)); // Skip DoomQuestState file->Skip(sizeof(int32_t)); // Skip DoomQuestState
} }
static void LoadLighting(LoadHelper *file, LightListStruct *pLight) static void LoadLighting(LoadHelper *file, LightStruct *pLight)
{ {
pLight->position.tile.x = file->NextLE<int32_t>(); pLight->position.tile.x = file->NextLE<int32_t>();
pLight->position.tile.y = file->NextLE<int32_t>(); pLight->position.tile.y = file->NextLE<int32_t>();
@ -1181,17 +1181,17 @@ void LoadGame(bool firstflag)
for (int i = 0; i < nobjects; i++) for (int i = 0; i < nobjects; i++)
SyncObjectAnim(objectactive[i]); SyncObjectAnim(objectactive[i]);
numlights = file.NextBE<int32_t>(); ActiveLightCount = file.NextBE<int32_t>();
for (uint8_t &lightId : lightactive) for (uint8_t &lightId : ActiveLights)
lightId = file.NextLE<uint8_t>(); lightId = file.NextLE<uint8_t>();
for (int i = 0; i < numlights; i++) for (int i = 0; i < ActiveLightCount; i++)
LoadLighting(&file, &LightList[lightactive[i]]); LoadLighting(&file, &Lights[ActiveLights[i]]);
visionid = file.NextBE<int32_t>(); VisionId = file.NextBE<int32_t>();
numvision = file.NextBE<int32_t>(); VisionCount = file.NextBE<int32_t>();
for (int i = 0; i < numvision; i++) for (int i = 0; i < VisionCount; i++)
LoadLighting(&file, &VisionList[i]); LoadLighting(&file, &VisionList[i]);
} }
@ -1824,7 +1824,7 @@ static void SaveQuest(SaveHelper *file, int i)
file->Skip(sizeof(int32_t)); // Skip DoomQuestState file->Skip(sizeof(int32_t)); // Skip DoomQuestState
} }
static void SaveLighting(SaveHelper *file, LightListStruct *pLight) static void SaveLighting(SaveHelper *file, LightStruct *pLight)
{ {
file->WriteLE<int32_t>(pLight->position.tile.x); file->WriteLE<int32_t>(pLight->position.tile.x);
file->WriteLE<int32_t>(pLight->position.tile.y); file->WriteLE<int32_t>(pLight->position.tile.y);
@ -1943,17 +1943,17 @@ void SaveGameData()
for (int i = 0; i < nobjects; i++) for (int i = 0; i < nobjects; i++)
SaveObject(&file, objectactive[i]); SaveObject(&file, objectactive[i]);
file.WriteBE<int32_t>(numlights); file.WriteBE<int32_t>(ActiveLightCount);
for (uint8_t lightId : lightactive) for (uint8_t lightId : ActiveLights)
file.WriteLE<uint8_t>(lightId); file.WriteLE<uint8_t>(lightId);
for (int i = 0; i < numlights; i++) for (int i = 0; i < ActiveLightCount; i++)
SaveLighting(&file, &LightList[lightactive[i]]); SaveLighting(&file, &Lights[ActiveLights[i]]);
file.WriteBE<int32_t>(visionid); file.WriteBE<int32_t>(VisionId);
file.WriteBE<int32_t>(numvision); file.WriteBE<int32_t>(VisionCount);
for (int i = 0; i < numvision; i++) for (int i = 0; i < VisionCount; i++)
SaveLighting(&file, &VisionList[i]); SaveLighting(&file, &VisionList[i]);
} }
@ -2205,12 +2205,12 @@ void LoadLevel()
AutomapZoomReset(); AutomapZoomReset();
ResyncQuests(); ResyncQuests();
SyncPortals(); SyncPortals();
dolighting = true; UpdateLighting = true;
} }
for (auto &player : plr) { for (auto &player : plr) {
if (player.plractive && currlevel == player.plrlevel) if (player.plractive && currlevel == player.plrlevel)
LightList[player._plid]._lunflag = true; Lights[player._plid]._lunflag = true;
} }
} }

6
Source/missiles.cpp

@ -3710,7 +3710,7 @@ void MI_FireNova(int i)
dir = plr[id]._pdir; dir = plr[id]._pdir;
en = TARGET_MONSTERS; en = TARGET_MONSTERS;
} }
for (const auto &k : vCrawlTable) { for (const auto &k : VisionCrawlTable) {
if (sx1 != k[6] || sy1 != k[7]) { if (sx1 != k[6] || sy1 != k[7]) {
Displacement offsets[] = { { k[6], k[7] }, { -k[6], -k[7] }, { -k[6], +k[7] }, { +k[6], -k[7] } }; Displacement offsets[] = { { k[6], k[7] }, { -k[6], -k[7] }, { -k[6], +k[7] }, { +k[6], -k[7] } };
for (Displacement offset : offsets) for (Displacement offset : offsets)
@ -4042,7 +4042,7 @@ void MI_Guardian(int i)
int ex = 0; int ex = 0;
for (int j = 0; j < 23 && ex != -1; j++) { for (int j = 0; j < 23 && ex != -1; j++) {
for (int k = 10; k >= 0 && ex != -1; k -= 2) { for (int k = 10; k >= 0 && ex != -1; k -= 2) {
const Displacement offset { vCrawlTable[j][k], vCrawlTable[j][k + 1] }; const Displacement offset { VisionCrawlTable[j][k], VisionCrawlTable[j][k + 1] };
if (offset == Displacement { 0, 0 }) { if (offset == Displacement { 0, 0 }) {
break; break;
} }
@ -4465,7 +4465,7 @@ void MI_Nova(int i)
dir = plr[id]._pdir; dir = plr[id]._pdir;
en = TARGET_MONSTERS; en = TARGET_MONSTERS;
} }
for (const auto &k : vCrawlTable) { for (const auto &k : VisionCrawlTable) {
if (sx1 != k[6] || sy1 != k[7]) { if (sx1 != k[6] || sy1 != k[7]) {
AddMissile(src, src + Displacement { k[6], k[7] }, dir, MIS_LIGHTBALL, en, id, dam, missile[i]._mispllvl); AddMissile(src, src + Displacement { k[6], k[7] }, dir, MIS_LIGHTBALL, en, id, dam, missile[i]._mispllvl);
AddMissile(src, src + Displacement { -k[6], -k[7] }, dir, MIS_LIGHTBALL, en, id, dam, missile[i]._mispllvl); AddMissile(src, src + Displacement { -k[6], -k[7] }, dir, MIS_LIGHTBALL, en, id, dam, missile[i]._mispllvl);

4
Source/monster.cpp

@ -875,7 +875,7 @@ void PlaceUniqueMonst(int uniqindex, int miniontype, int bosspacksize)
char filestr[64]; char filestr[64];
sprintf(filestr, "Monsters\\Monsters\\%s.TRN", uniq->mTrnName); sprintf(filestr, "Monsters\\Monsters\\%s.TRN", uniq->mTrnName);
LoadFileInMem(filestr, &pLightTbl[256 * (uniquetrans + 19)], 256); LoadFileInMem(filestr, &LightTables[256 * (uniquetrans + 19)], 256);
monst->_uniqtrans = uniquetrans++; monst->_uniqtrans = uniquetrans++;
@ -3112,7 +3112,7 @@ void MAI_Sneak(int i)
} }
int mx = monst->position.tile.x; int mx = monst->position.tile.x;
int my = monst->position.tile.y; int my = monst->position.tile.y;
if (dLight[mx][my] == lightmax) { if (dLight[mx][my] == LightsMax) {
return; return;
} }
mx -= monst->enemyPosition.x; mx -= monst->enemyPosition.x;

2
Source/objects.cpp

@ -1853,7 +1853,7 @@ void Obj_Light(int i, int lr)
int ox = object[i].position.x; int ox = object[i].position.x;
int oy = object[i].position.y; int oy = object[i].position.y;
int tr = lr + 10; int tr = lr + 10;
if (!lightflag) { if (!DisableLighting) {
for (int p = 0; p < MAX_PLRS && !turnon; p++) { for (int p = 0; p < MAX_PLRS && !turnon; p++) {
if (plr[p].plractive) { if (plr[p].plractive) {
if (currlevel == plr[p].plrlevel) { if (currlevel == plr[p].plrlevel) {

2
Source/player.cpp

@ -46,7 +46,7 @@ void PmChangeLightOff(PlayerStruct &player)
if (player._plid == NO_LIGHT) if (player._plid == NO_LIGHT)
return; return;
const LightListStruct *l = &LightList[player._plid]; const LightStruct *l = &Lights[player._plid];
int x = 2 * player.position.offset.deltaY + player.position.offset.deltaX; int x = 2 * player.position.offset.deltaY + player.position.offset.deltaX;
int y = 2 * player.position.offset.deltaY - player.position.offset.deltaX; int y = 2 * player.position.offset.deltaY - player.position.offset.deltaX;

24
Source/scrollrt.cpp

@ -165,7 +165,7 @@ void UpdateMissilesRendererData()
/** /**
* Specifies the current light entry. * Specifies the current light entry.
*/ */
int light_table_index; int LightTableIndex;
uint32_t sgdwCursWdtOld; uint32_t sgdwCursWdtOld;
int sgdwCursX; int sgdwCursX;
int sgdwCursY; int sgdwCursY;
@ -458,7 +458,7 @@ static void DrawMonster(const Surface &out, int x, int y, int mx, int my, int m)
trans = Monsters[m]._uniqtrans + 4; trans = Monsters[m]._uniqtrans + 4;
if (Monsters[m]._mmode == MM_STONE) if (Monsters[m]._mmode == MM_STONE)
trans = 2; trans = 2;
if (plr[myplr]._pInfraFlag && light_table_index > 8) if (plr[myplr]._pInfraFlag && LightTableIndex > 8)
trans = 1; trans = 1;
if (trans != 0) if (trans != 0)
Cl2DrawLightTbl(out, mx, my, cel, nCel, trans); Cl2DrawLightTbl(out, mx, my, cel, nCel, trans);
@ -560,22 +560,22 @@ static void DrawPlayer(const Surface &out, int pnum, int x, int y, int px, int p
return; return;
} }
if ((dFlags[x][y] & BFLAG_LIT) == 0 || (plr[myplr]._pInfraFlag && light_table_index > 8)) { if ((dFlags[x][y] & BFLAG_LIT) == 0 || (plr[myplr]._pInfraFlag && LightTableIndex > 8)) {
Cl2DrawLightTbl(out, px, py, *pCelSprite, nCel, 1); Cl2DrawLightTbl(out, px, py, *pCelSprite, nCel, 1);
DrawPlayerIcons(out, pnum, px, py, true); DrawPlayerIcons(out, pnum, px, py, true);
return; return;
} }
int l = light_table_index; int l = LightTableIndex;
if (light_table_index < 5) if (LightTableIndex < 5)
light_table_index = 0; LightTableIndex = 0;
else else
light_table_index -= 5; LightTableIndex -= 5;
Cl2DrawLight(out, px, py, *pCelSprite, nCel); Cl2DrawLight(out, px, py, *pCelSprite, nCel);
DrawPlayerIcons(out, pnum, px, py, false); DrawPlayerIcons(out, pnum, px, py, false);
light_table_index = l; LightTableIndex = l;
} }
/** /**
@ -612,7 +612,7 @@ void DrawDeadPlayer(const Surface &out, int x, int y, int sx, int sy)
*/ */
static void DrawObject(const Surface &out, int x, int y, int ox, int oy, bool pre) static void DrawObject(const Surface &out, int x, int y, int ox, int oy, bool pre)
{ {
if (dObject[x][y] == 0 || light_table_index >= lightmax) if (dObject[x][y] == 0 || LightTableIndex >= LightsMax)
return; return;
Point objectPosition {}; Point objectPosition {};
@ -702,7 +702,7 @@ static void DrawCell(const Surface &out, int x, int y, int sx, int sy)
static void DrawFloor(const Surface &out, int x, int y, int sx, int sy) static void DrawFloor(const Surface &out, int x, int y, int sx, int sy)
{ {
cel_transparency_active = false; cel_transparency_active = false;
light_table_index = dLight[x][y]; LightTableIndex = dLight[x][y];
arch_draw_type = 1; // Left arch_draw_type = 1; // Left
level_cel_block = dpiece_defs_map_2[x][y].mt[0]; level_cel_block = dpiece_defs_map_2[x][y].mt[0];
@ -863,7 +863,7 @@ static void DrawDungeon(const Surface &out, int sx, int sy, int dx, int dy)
return; return;
dRendered[sx][sy] = true; dRendered[sx][sy] = true;
light_table_index = dLight[sx][sy]; LightTableIndex = dLight[sx][sy];
DrawCell(out, sx, sy, dx, dy); DrawCell(out, sx, sy, dx, dy);
@ -885,7 +885,7 @@ static void DrawDungeon(const Surface &out, int sx, int sy, int dx, int dy)
DrawMissile(out, sx, sy, dx, dy, true); DrawMissile(out, sx, sy, dx, dy, true);
} }
if (light_table_index < lightmax && bDead != 0) { if (LightTableIndex < LightsMax && bDead != 0) {
do { do {
DeadStruct *pDeadGuy = &Dead[(bDead & 0x1F) - 1]; DeadStruct *pDeadGuy = &Dead[(bDead & 0x1F) - 1];
auto dd = static_cast<Direction>((bDead >> 5) & 7); auto dd = static_cast<Direction>((bDead >> 5) & 7);

2
Source/scrollrt.h

@ -29,7 +29,7 @@ enum _scroll_direction : uint8_t {
extern bool sgbControllerActive; extern bool sgbControllerActive;
extern bool IsMovingMouseCursorWithController(); extern bool IsMovingMouseCursorWithController();
extern int light_table_index; extern int LightTableIndex;
extern uint32_t level_cel_block; extern uint32_t level_cel_block;
extern char arch_draw_type; extern char arch_draw_type;
extern bool cel_transparency_active; extern bool cel_transparency_active;

4
test/drlg_l1_test.cpp

@ -8,14 +8,14 @@ using namespace devilution;
TEST(Drlg_l1, DRLG_Init_Globals_noflag) TEST(Drlg_l1, DRLG_Init_Globals_noflag)
{ {
lightflag = false; DisableLighting = false;
DRLG_Init_Globals(); DRLG_Init_Globals();
EXPECT_EQ(dLight[0][0], 15); EXPECT_EQ(dLight[0][0], 15);
} }
TEST(Drlg_l1, DRLG_Init_Globals) TEST(Drlg_l1, DRLG_Init_Globals)
{ {
lightflag = true; DisableLighting = true;
DRLG_Init_Globals(); DRLG_Init_Globals();
EXPECT_EQ(dLight[0][0], 0); EXPECT_EQ(dLight[0][0], 0);
} }

Loading…
Cancel
Save