From 3677f4c3696a5c6d70ba9f4ebde262ab84fcfecd Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Mon, 12 May 2025 13:19:04 -0500 Subject: [PATCH] fix OUT_FORCE_TOWN nodes --- src/game/boe.specials.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/game/boe.specials.cpp b/src/game/boe.specials.cpp index 9b9b648f..c86942f2 100644 --- a/src/game/boe.specials.cpp +++ b/src/game/boe.specials.cpp @@ -4547,9 +4547,16 @@ void outdoor_spec(const runtime_state& ctx){ *ctx.ret_a = 1; break; case eSpecType::OUT_FORCE_TOWN: { + short town = spec.ex1a; + if(town < 0 || town >= univ.scenario.towns.size()){ + showError("The scenario attempted to put the party in a nonexistent town: " + std::to_string(town)); + break; + } + size_t town_dim = univ.scenario.towns[town]->max_dim; l = {spec.ex2a, spec.ex2b}; + // town entry direction. 9 means forced position int i = 0; - if(l.x < 0 || l.y < 0 || l.x >= 64 || l.y >= 64) + if(l.x >= 0 && l.y >= 0 && l.x < town_dim && l.y < town_dim) i = 9; else if(spec.ex1b == 0) i = 2; else if(spec.ex1b == 4) i = 0;