Skip to content

Commit

Permalink
light: warn rather than fatal error on invalid "delay" settings
Browse files Browse the repository at this point in the history
  • Loading branch information
ericwa committed Apr 1, 2024
1 parent 21b3b69 commit 28190f5
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
7 changes: 7 additions & 0 deletions light/entities.cc
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,13 @@ static void CheckEntityFields(const mbsp_t *bsp, const settings::worldspawn_keys
entity->falloff.set_value(0.0f, settings::source::MAP);
}

if (entity->getFormula() < 0 || entity->getFormula() >= LF_COUNT) {
logging::print("WARNING: unknown delay {} on {} at [{}]\n",
static_cast<int>(entity->getFormula()), entity->classname(), entity->origin.value());
entity->formula.set_value(LF_LINEAR, settings::source::MAP);
entity->light.set_value(0.0f, settings::source::MAP);
}

/* set up deviance and samples defaults */
if (entity->deviance.value() > 0 && entity->samples.value() == 0) {
entity->samples.set_value(16, settings::source::MAP);
Expand Down
75 changes: 75 additions & 0 deletions testmaps/q1_light_invalid_delay.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Game: Quake
// Format: Standard
// entity 0
{
"classname" "worldspawn"
"_tb_textures" "textures/e1u1"
"_bounce" "0"
"wad" "deprecated/free_wad.wad"
// brush 0
{
( 480 1088 928 ) ( 480 1089 928 ) ( 480 1088 929 ) bolt14 0 32 0 1 1
( 704 1088 928 ) ( 704 1088 929 ) ( 705 1088 928 ) bolt14 0 32 0 1 1
( 704 1088 928 ) ( 705 1088 928 ) ( 704 1089 928 ) bolt14 0 0 0 1 1
( 944 1472 944 ) ( 944 1473 944 ) ( 945 1472 944 ) bolt14 0 0 0 1 1
( 944 1488 944 ) ( 945 1488 944 ) ( 944 1488 945 ) bolt14 0 32 0 1 1
( 1056 1472 944 ) ( 1056 1472 945 ) ( 1056 1473 944 ) bolt14 0 32 0 1 1
}
// brush 1
{
( 480 1088 1232 ) ( 480 1089 1232 ) ( 480 1088 1233 ) bolt14 0 16 0 1 1
( 704 1072 1232 ) ( 704 1072 1233 ) ( 705 1072 1232 ) bolt14 0 16 0 1 1
( 704 1088 1232 ) ( 705 1088 1232 ) ( 704 1089 1232 ) bolt14 0 0 0 1 1
( 944 1472 1248 ) ( 944 1473 1248 ) ( 945 1472 1248 ) bolt14 0 0 0 1 1
( 944 1488 1248 ) ( 945 1488 1248 ) ( 944 1488 1249 ) bolt14 0 16 0 1 1
( 1056 1472 1248 ) ( 1056 1472 1249 ) ( 1056 1473 1248 ) bolt14 0 16 0 1 1
}
// brush 2
{
( 480 1072 928 ) ( 480 1073 928 ) ( 480 1072 929 ) bolt14 16 32 0 1 1
( 704 1072 928 ) ( 704 1072 929 ) ( 705 1072 928 ) bolt14 0 32 0 1 1
( 704 1072 928 ) ( 705 1072 928 ) ( 704 1073 928 ) bolt14 0 -16 0 1 1
( 944 1456 1248 ) ( 944 1457 1248 ) ( 945 1456 1248 ) bolt14 0 -16 0 1 1
( 944 1088 944 ) ( 945 1088 944 ) ( 944 1088 945 ) bolt14 0 32 0 1 1
( 1056 1456 944 ) ( 1056 1456 945 ) ( 1056 1457 944 ) bolt14 16 32 0 1 1
}
// brush 3
{
( 480 1392 928 ) ( 480 1393 928 ) ( 480 1392 929 ) bolt14 -48 32 0 1 1
( 832 1488 928 ) ( 832 1488 929 ) ( 833 1488 928 ) bolt14 -128 32 0 1 1
( 832 1392 928 ) ( 833 1392 928 ) ( 832 1393 928 ) bolt14 -128 48 0 1 1
( 1072 1776 1248 ) ( 1072 1777 1248 ) ( 1073 1776 1248 ) bolt14 -128 48 0 1 1
( 1072 1504 944 ) ( 1073 1504 944 ) ( 1072 1504 945 ) bolt14 -128 32 0 1 1
( 1056 1392 928 ) ( 1056 1392 929 ) ( 1056 1393 928 ) bolt14 -48 32 0 1 1
}
// brush 4
{
( 1056 1088 1056 ) ( 1056 1089 1056 ) ( 1056 1088 1057 ) bolt14 0 32 0 1 1
( 736 1088 1056 ) ( 736 1088 1057 ) ( 737 1088 1056 ) bolt14 -32 32 0 1 1
( 736 1088 928 ) ( 737 1088 928 ) ( 736 1089 928 ) bolt14 -32 0 0 1 1
( 976 1472 1248 ) ( 976 1473 1248 ) ( 977 1472 1248 ) bolt14 -32 0 0 1 1
( 976 1488 1072 ) ( 977 1488 1072 ) ( 976 1488 1073 ) bolt14 -32 32 0 1 1
( 1072 1472 1072 ) ( 1072 1472 1073 ) ( 1072 1473 1072 ) bolt14 0 32 0 1 1
}
// brush 5
{
( 464 1088 1056 ) ( 464 1089 1056 ) ( 464 1088 1057 ) bolt14 0 32 0 1 1
( 144 1072 1056 ) ( 144 1072 1057 ) ( 145 1072 1056 ) bolt14 48 32 0 1 1
( 144 1088 928 ) ( 145 1088 928 ) ( 144 1089 928 ) bolt14 48 0 0 1 1
( 384 1472 1248 ) ( 384 1473 1248 ) ( 385 1472 1248 ) bolt14 48 0 0 1 1
( 384 1488 1072 ) ( 385 1488 1072 ) ( 384 1488 1073 ) bolt14 48 32 0 1 1
( 480 1472 1072 ) ( 480 1472 1073 ) ( 480 1473 1072 ) bolt14 0 32 0 1 1
}
}
// entity 1
{
"classname" "info_player_start"
"origin" "976 1408 968"
"angle" "180"
}
// entity 2
{
"classname" "light"
"origin" "568 1288 1080"
"delay" "15"
}
11 changes: 11 additions & 0 deletions tests/test_ltface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,17 @@ TEST_CASE("q1_light_sun_artifact")
}
}

TEST_CASE("q1_light_invalid_delay")
{
INFO("invalid light formulas are ignored, not a fatal error");

auto [bsp, bspx, lit] = QbspVisLight_Q1("q1_light_invalid_delay.map", {"-lit"});

for (const auto &face : bsp.dfaces) {
CheckFaceLuxels(bsp, face, [](qvec3b sample) { CHECK(sample == qvec3b(0, 0, 0)); }, &lit);
}
}

TEST_CASE("q1_light_bounce_litwater without the water")
{
auto [bsp, bspx] = QbspVisLight_Common("q1_light_bounce_litwater.map", {"-omitdetail"}, {"-lit", "-bounce", "4"}, runvis_t::no);
Expand Down

0 comments on commit 28190f5

Please sign in to comment.