Hellgate and Tyrael's portal to Harrogath can't be clicked: objects not selectable in their start mode get no hover name

Open
#684 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
28/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
cpp
Domain
game-dev

Research direction

Start in components/game/gamedata/gamedata.cpp at add_object, where the hover name is gated on Selectable0 or Selectable2, and in apps/d2d/ingame.cpp where the unselectable check lives. Objects 342 and 566 are the cases; components/game/world/quests/act4.cpp and world.hpp cover Tyrael's portal door mode. Done means both portals show their names under the cursor and a click on each enters its destination in the headless save test described in the issue. The issue reports the fix works locally, but the mode handling for 566 depends on game.exe's InitFn 78, so verify that before relying on it.

Written by the indexing model from the issue text.

Description

Version: v0.12.3 (macOS arm64). The code is the same in main at c5c3edda83 (2026-11-22).

What happens

Two quest portals can't be entered with the mouse. The cursor never highlights them, and clicking one makes the player walk to the floor under it:

  • the red portal to Act 4 in Durance of Hate level 3, after Mephisto dies (object 342, OperateFn 46);
  • Tyrael's portal to Harrogath in the Pandemonium Fortress, after Diablo dies (object 566, OperateFn 73).

The operate code works in both cases. For the hellgate, cmd interact <index> takes the player to Act 4. For 566, once the portal has a name, a click takes the player to Harrogath.

Cause

In objects.txt, both objects are not selectable in mode 0 but are selectable in later modes:

id description Selectable0..2 Lit2 InitFn
342 hellgate 0 0 1 19 44
566 last last portal 0 1 1 0 78

add_object (gamedata.cpp, if (objects.get(row, lit_mode ? "Selectable2" : "Selectable0") == "1")) gives an object a hover name only when it is selectable in its start mode, so neither portal ever gets a name.

There is a second problem with 566. game.exe's InitFn 78 (table at 0x731bc0, entry 78 = 0x5b5840) reads the a4q2 record (quest data 0x17). If its +0x40 is not 2, it sets it to 2 and puts the object in mode 1. Otherwise it puts the object in mode 2. d2d never sets a mode, so the portal stays in mode 0, the mode where it can't be selected.

Same trap, not fixed here

A scan of objects.txt for "Selectable0 = 0 and some later SelectableN = 1" finds 9 rows:

  • 59 and 60 (town portals) are fine, because Lit2 starts them ON.
  • 342, 366 and 386 (the last two are the sewer and Durance stairs, see the stairs issue) are covered by the patches.
  • 563 and 569 (Baal's portals, InitFn 75, mode from the a5q6 record +0x94) and 565 (the last portal, InitFn 77, +0x9c) are left. act5.cpp never sets their mode, so they will likely be unclickable too. I could not test them.

Fix that worked here

The diffs below are against v0.12.3:

  • name both objects when any later mode is selectable;
  • hide the hellgate's name while it is shut (ingame.cpp);
  • for 566, set the door mode as InitFn 78 does (1 for the first portal of the game, then 2), and switch 1 -> 2 after FrameCnt1 + 1 frames, as the hellgate does. That last step is my choice; I did not trace game.exe's 1 -> 2.

Checked headless on a real save (talk to Tyrael, move, then click on the portal):

  • the release build: the cursor shows "Tyrael", and the player stays in the Fortress (0 of 3);
  • patched: the cursor shows "Harrogath", and the player arrives in Harrogath (3 of 3).

For the hellgate: 0 of 10 before, 10 of 11 after.

hellgate diff
--- a/components/game/gamedata/gamedata.cpp
+++ b/components/game/gamedata/gamedata.cpp
@@ -673,6 +673,18 @@
         auto name_found = lookup_string(game_data, "stair");
         npc.name = name_found ? u16_to_latin1(*name_found) : "Stairs";
     }
+    // LOCAL PATCH (hellgate): the red portal to Act 4 (342, OperateFn 46) starts shut (mode 0, a3q6's InitFn 44) and is
+    // selectable only open, so it got no name and the cursor never took it: a click by it walked to the floor instead.
+    // Its own Name for then (ingame.cpp hides it while it is shut).
+    if (npc.name.empty() && npc.operate_fn == d2d::rules::operate_fn::kHellgate) {
+        bool selectable_later = false;
+        for (int mode = 1; mode < 8; ++mode) selectable_later |= objects.get(row, "Selectable" + std::to_string(mode)) == "1";
+        if (selectable_later) {
+            const std::string key(objects.get(row, "Name"));
+            auto name_found = lookup_string(game_data, key);
+            npc.name = name_found ? u16_to_latin1(*name_found) : key;
+        }
+    }
     // Where it blocks walking, by mode (stamp_footprints takes its start mode's).
     npc.object_id = oid;
     npc.name_offset = std::atoi(std::string(objects.get(row, "NameOffset")).c_str());
--- a/apps/d2d/ingame.cpp
+++ b/apps/d2d/ingame.cpp
@@ -195,7 +195,7 @@
             static const std::string none;
             // An object in a new mode keeps its name where it's Selectable in it (an open door).
             const bool unselectable = (state && !state->mode.empty() && npc.root == "objects" && !(npc.selectable >> game::mode_index(state->mode) & 1))
-                || ((npc.operate_fn == 44 || npc.operate_fn == 50) && npc.root == "objects" && (!state || state->mode.empty()) && !(npc.selectable >> game::mode_index(npc.mode) & 1));   // LOCAL PATCH (stairs): shut from the start
+                || ((npc.operate_fn == 44 || npc.operate_fn == 50 || npc.operate_fn == 46) && npc.root == "objects" && (!state || state->mode.empty()) && !(npc.selectable >> game::mode_index(npc.mode) & 1));   // LOCAL PATCH (stairs, hellgate): shut from the start
             units.push_back({ x, y, &anim, state ? state->dir : 0, unselectable ? &none : &npc.name, state ? state->mode_ms : 0, int(i) });
             if (state && state->alert) {
                 units.back().overlay = &scene.npc_alert;
Tyrael's portal diff (on top of the hellgate one)
--- a/components/game/gamedata/gamedata.cpp
+++ b/components/game/gamedata/gamedata.cpp
@@ -676,7 +676,9 @@
     // LOCAL PATCH (hellgate): the red portal to Act 4 (342, OperateFn 46) starts shut (mode 0, a3q6's InitFn 44) and is
     // selectable only open, so it got no name and the cursor never took it: a click by it walked to the floor instead.
     // Its own Name for then (ingame.cpp hides it while it is shut).
-    if (npc.name.empty() && npc.operate_fn == d2d::rules::operate_fn::kHellgate) {
+    // LOCAL PATCH (last portal): Tyrael's portal to Harrogath (566, OperateFn 73) the same: Selectable0 0, its InitFn 78
+    // (0x5b5840) puts it in mode 1 or 2 (act4.cpp sets that), so it shows as "Harrogath".
+    if (npc.name.empty() && (npc.operate_fn == d2d::rules::operate_fn::kHellgate || npc.operate_fn == 73)) {
         bool selectable_later = false;
         for (int mode = 1; mode < 8; ++mode) selectable_later |= objects.get(row, "Selectable" + std::to_string(mode)) == "1";
         if (selectable_later) {
--- a/components/game/world/quests/act4.cpp
+++ b/components/game/world/quests/act4.cpp
@@ -99,7 +99,7 @@
         gem_rounds = 0;
         forge_inited = false;
         seal_bosses.clear();
-        fortress_warp_done = end_movie = game_closed = false;
+        fortress_warp_done = end_movie = game_closed = last_portal_opened = false;   // last_portal_opened: LOCAL PATCH (last portal)
         act4_chain();
     }
 
@@ -152,6 +152,10 @@
                 auto rgn = d2d::rules::Rng{ fight.rng.next() };
                 add_object(*game_data, game_data->builder->objects, game_data->builder->obj_row, here, d2d::rules::object_ids::kLastPortal,
                            int(tyrael->x * 5) + 5, int(tyrael->y * 5), rgn);
+                // LOCAL PATCH (last portal): InitFn 78 (0x5b5840): the game's first one mode 1 (it opens), later ones
+                // mode 2; d2d left it in mode 0, where objects.txt has it unselectable (no hover, no click).
+                if (!here.npcs.empty() && here.npcs.back().object_id == d2d::rules::object_ids::kLastPortal)
+                    doors[{ level, int(here.npcs.size()) - 1 }] = Door{ std::exchange(last_portal_opened, true) ? 2 : 1, now };
                 d2d::log::info("Terror's End: Tyrael opens the way to Harrogath");
             }
         }
@@ -254,6 +258,13 @@
 
 auto World::act4_update(std::uint32_t now_ms) -> void {
         if (hosted_quests) return;
+        // LOCAL PATCH (last portal): Tyrael's portal opened (mode 1, FrameCnt1 frames, no loop), then its loop (mode 2),
+        // as the hellgate's (shared.cpp).
+        for (std::size_t i = 0; i < level->npcs.size(); ++i)
+            if (level->npcs[i].object_id == d2d::rules::object_ids::kLastPortal)
+                if (const auto state = doors.find({ level, int(i) }); state != doors.end() && state->second.mode == 1
+                    && now_ms - state->second.when >= std::uint32_t(level->npcs[i].op_frames + 1) * kTickMs)
+                    state->second = Door{ 2, now_ms };
         // Izual's first think (FUN_005b4390): the Fallen Angel's log sent again.
         for (auto& monster : fight.monsters)
             if (std::exchange(monster.greeted, false)) {
--- a/components/game/world.hpp
+++ b/components/game/world.hpp
@@ -548,6 +548,7 @@
     const Level* izual_level = nullptr;    // where he died: the ghost goes there (0x5b3eaf: Act 4's map, game +0xc8)
     std::uint32_t diablo_dead_at = 0;      // a4q2's +0x18, classic: the 90 / 95 s end (FUN_005b4be0)
     bool fortress_warp_done = false;       // a4q2's +5: the 90 s step
+    bool last_portal_opened = false;       // LOCAL PATCH (last portal): a4q2 record +0x40 == 2, InitFn 78 ran this game
     // S->C 0x61 (FUN_0053d940): the cinematic the client plays now (its
     // table 0x721d9c: 7 D2X_OUT), -1 none; after the game's save
     // (FUN_0052e2a0: every player).
Dominant language
C++
Stars
17
Forks
6
Avg merge
6h 14m
Merged PRs (30d)
570

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from psi29a/d2decomped

All issues in psi29a/d2decomped

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.