Files
Gleb MazovetskiyandClaude Sonnet 4.6 53b91fd7a2 Untangle more dependencies
Split several monolithic files to reduce transitive dependencies and
enable the dun_render_benchmark to link without bringing in all of
DevilutionX:

- Extract dungeon tile globals and loading functions from `gendung` into
  `dun_tile_data.{hpp,cpp}`
- Extract light table data and MakeLightTable from lighting into
  `engine/light_tables.{hpp,cpp}`
- Move cursor_id and SelectionRegion to cursor_defs.hpp
- Extract quest log rendering to `panels/quest_log.{hpp,cpp}`
- Extract drlg quest setpiece logic to `levels/drlg_quests.{hpp,cpp}`
- Extract quest data loading to `tables/questdat.{hpp,cpp}`
- Move `GameData` and `gbIsMultiplayer` into `game_mode.{hpp,cpp}`
- Add `parse_sfx_id.{hpp,cpp}`
- Update CMake libraries accordingly

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
2026-08-23 06:08:15 +01:00

77 lines
2.1 KiB
C++

/**
* @file lighting.h
*
* Interface of light and vision.
*/
#pragma once
#include <array>
#include <cstdint>
#include <expected>
#include "automap.h"
#include "engine/displacement.hpp"
#include "engine/light_tables.hpp"
#include "engine/lighting_defs.hpp"
#include "engine/point.hpp"
#include "engine/world_tile.hpp"
#include "utils/attributes.h"
namespace devilution {
struct LightPosition {
WorldTilePosition tile;
/** Pixel offset from tile. */
DisplacementOf<int8_t> offset;
/** Previous position. */
WorldTilePosition old;
};
struct Light {
LightPosition position;
uint8_t radius;
uint8_t oldRadius;
bool isInvalid;
bool hasChanged;
};
extern Light VisionList[MAXVISION];
extern std::array<bool, MAXVISION> VisionActive;
extern Light Lights[MAXLIGHTS];
extern std::array<uint8_t, MAXLIGHTS> ActiveLights;
extern int ActiveLightCount;
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 DoUnLight(Point position, uint8_t radius);
void DoLighting(Point position, uint8_t radius, DisplacementOf<int8_t> offset);
void DoUnVision(Point position, uint8_t radius);
void DoVision(Point position, uint8_t radius, MapExplorationType doAutomap, bool visible);
std::expected<void, std::string> LoadTrns();
#ifdef _DEBUG
void ToggleLighting();
#endif
void InitLighting();
int AddLight(Point position, uint8_t radius);
void AddUnLight(int i);
void ChangeLightRadius(int i, uint8_t radius);
void ChangeLightXY(int i, Point position);
void ChangeLightOffset(int i, DisplacementOf<int8_t> offset);
void ChangeLight(int i, Point position, uint8_t radius);
void ProcessLightList();
void SavePreLighting();
void ActivateVision(Point position, int r, size_t id);
void ChangeVisionRadius(size_t id, int r);
void ChangeVisionXY(size_t id, Point position);
void ProcessVisionList();
void lighting_color_cycling();
constexpr int MaxCrawlRadius = 18;
} // namespace devilution