Browse Source

Remove DisableLighting from release builds

pull/6005/head
Anders Jenbo 3 years ago
parent
commit
382212b98c
  1. 7
      Source/levels/gendung.cpp
  2. 43
      Source/lighting.cpp
  3. 2
      Source/lighting.h
  4. 39
      Source/objects.cpp

7
Source/levels/gendung.cpp

@ -338,7 +338,12 @@ void InitGlobals()
memset(dItem, 0, sizeof(dItem));
memset(dObject, 0, sizeof(dObject));
memset(dSpecial, 0, sizeof(dSpecial));
memset(dLight, DisableLighting || leveltype == DTYPE_TOWN ? 0 : 15, sizeof(dLight));
uint8_t defaultLight = leveltype == DTYPE_TOWN ? 0 : 15;
#ifdef _DEBUG
if (DisableLighting)
defaultLight = 0;
#endif
memset(dLight, defaultLight, sizeof(dLight));
DRLG_InitTrans();

43
Source/lighting.cpp

@ -25,7 +25,9 @@ std::array<std::array<uint8_t, 256>, NumLightingLevels> LightTables;
std::array<uint8_t, 256> InfravisionTable;
std::array<uint8_t, 256> StoneTable;
std::array<uint8_t, 256> PauseTable;
#ifdef _DEBUG
bool DisableLighting;
#endif
bool UpdateLighting;
namespace {
@ -463,7 +465,9 @@ void InitLighting()
UpdateVision = false;
VisionCount = 0;
VisionId = 1;
#ifdef _DEBUG
DisableLighting = false;
#endif
for (int i = 0; i < MAXLIGHTS; i++) {
ActiveLights[i] = i;
@ -476,8 +480,10 @@ void InitLighting()
int AddLight(Point position, uint8_t radius)
{
#ifdef _DEBUG
if (DisableLighting)
return NO_LIGHT;
#endif
if (ActiveLightCount >= MAXLIGHTS)
return NO_LIGHT;
@ -496,9 +502,12 @@ int AddLight(Point position, uint8_t radius)
void AddUnLight(int i)
{
if (DisableLighting || i == NO_LIGHT) {
#ifdef _DEBUG
if (DisableLighting)
return;
#endif
if (i == NO_LIGHT)
return;
}
Lights[i].isInvalid = true;
@ -507,9 +516,12 @@ void AddUnLight(int i)
void ChangeLightRadius(int i, uint8_t radius)
{
if (DisableLighting || i == NO_LIGHT) {
#ifdef _DEBUG
if (DisableLighting)
return;
#endif
if (i == NO_LIGHT)
return;
}
Light &light = Lights[i];
light.hasChanged = true;
@ -522,9 +534,12 @@ void ChangeLightRadius(int i, uint8_t radius)
void ChangeLightXY(int i, Point position)
{
if (DisableLighting || i == NO_LIGHT) {
#ifdef _DEBUG
if (DisableLighting)
return;
#endif
if (i == NO_LIGHT)
return;
}
Light &light = Lights[i];
light.hasChanged = true;
@ -537,9 +552,12 @@ void ChangeLightXY(int i, Point position)
void ChangeLightOffset(int i, Displacement offset)
{
if (DisableLighting || i == NO_LIGHT) {
#ifdef _DEBUG
if (DisableLighting)
return;
#endif
if (i == NO_LIGHT)
return;
}
Light &light = Lights[i];
light.hasChanged = true;
@ -552,9 +570,12 @@ void ChangeLightOffset(int i, Displacement offset)
void ChangeLight(int i, Point position, uint8_t radius)
{
if (DisableLighting || i == NO_LIGHT) {
#ifdef _DEBUG
if (DisableLighting)
return;
#endif
if (i == NO_LIGHT)
return;
}
Light &light = Lights[i];
light.hasChanged = true;
@ -568,8 +589,10 @@ void ChangeLight(int i, Point position, uint8_t radius)
void ProcessLightList()
{
#ifdef _DEBUG
if (DisableLighting)
return;
#endif
if (!UpdateLighting)
return;
for (int i = 0; i < ActiveLightCount; i++) {

2
Source/lighting.h

@ -54,7 +54,9 @@ extern std::array<std::array<uint8_t, 256>, NumLightingLevels> LightTables;
extern std::array<uint8_t, 256> InfravisionTable;
extern std::array<uint8_t, 256> StoneTable;
extern std::array<uint8_t, 256> PauseTable;
#ifdef _DEBUG
extern bool DisableLighting;
#endif
extern bool UpdateLighting;
void DoLighting(Point position, uint8_t radius, int Lnum);

39
Source/objects.cpp

@ -1529,28 +1529,35 @@ void AddMushPatch()
}
}
void UpdateObjectLight(Object &light, int lightRadius)
bool IsLightVisible(Object &light, int lightRadius)
{
if (light._oVar1 == -1) {
return;
}
#ifdef _DEBUG
if (!DisableLighting)
return false;
#endif
bool turnon = false;
if (!DisableLighting) {
for (const Player &player : Players) {
if (!player.plractive)
continue;
for (const Player &player : Players) {
if (!player.plractive)
continue;
if (!player.isOnActiveLevel())
continue;
if (!player.isOnActiveLevel())
continue;
if (player.position.tile.WalkingDistance(light.position) < lightRadius + 10) {
turnon = true;
break;
}
if (player.position.tile.WalkingDistance(light.position) < lightRadius + 10) {
return true;
}
}
if (turnon) {
return false;
}
void UpdateObjectLight(Object &light, int lightRadius)
{
if (light._oVar1 == -1) {
return;
}
if (IsLightVisible(light, lightRadius)) {
if (light._oVar1 == 0)
light._olid = AddLight(light.position, lightRadius);
light._oVar1 = 1;

Loading…
Cancel
Save