Skip to content

Commit 4ca3b9b

Browse files
authored
Merge pull request #1621 from Alistair-Afton/fix-questport-5894
questport, reveal-adv-map: fix for current viewscreen_adventure_logst
2 parents fb6812a + 71d7dc8 commit 4ca3b9b

4 files changed

Lines changed: 27 additions & 16 deletions

File tree

‎changelog.txt‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ Template for new versions:
4747
- `fix/loyaltycascade`: guard against citizens that are not historical figures and emit a warning.
4848
- `gui/settings-manager`: preserve built-in work details added after saved settings were created
4949
- `gui/siegemanager`: fix nil index if there are no siege engines on the map
50-
- `item`: the ``reachable``/``unreachable`` filters no longer count installed building parts, and now treat loose contents of unwalkable buildings (like bolts loaded in a bolt thrower) as reachable when a citizen can stand next to the building
5150
- `hide-tutorials`: also suppress the adventure mode start tutorial (defaults its checkbox to off and dismisses the popups)
51+
- `item`: the ``reachable``/``unreachable`` filters no longer count installed building parts, and now treat loose contents of unwalkable buildings (like bolts loaded in a bolt thrower) as reachable when a citizen can stand next to the building
52+
- `questport`: fix crash on current DF versions and make the teleport actually move the player in fast travel
53+
- `reveal-adv-map`: fix live quest log map update when revealing or hiding the map
5254

5355
## Misc Improvements
5456
- `caravan`: the ``Bring goods to depot``, ``Trade``, and ``Assign items for display`` overlays now allow searching for items with non-ASCII characters in their description

‎docs/questport.rst‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ questport
33

44
.. dfhack-tool::
55
:summary: Teleport to your quest log map cursor.
6-
:tags: unavailable
6+
:tags: adventure armok map
77

88
If you open the quest log map and move the cursor to your target location, you
99
can run this command to teleport straight there. This can be done both within
1010
and outside of fast travel mode, and it is possible to ``questport`` in
11-
situations where fast travel is normally prohibited.
11+
situations where fast travel is normally prohibited. The quest log map must be
12+
zoomed out to the world map when running this command.
1213

1314
It is not possible to ``questport`` into inaccessible locations like ocean and
1415
mountain tiles.

‎questport.lua‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ local function processTravelNoArmy(advmode, advScreen, target_x, target_y)
77
gui.simulateInput(advScreen.child, 'LEAVESCREEN') -- close map
88
gui.simulateInput(advScreen.child, 'LEAVESCREEN') -- close log
99
advmode.site_level_zoom = 1 -- zoom in to shrink the following travel movement, reducing the risk of failure
10-
gui.simulateInput(advScreen, 'CURSOR_DOWN') -- the player army is only created once the player moves in travel mode; ensure that this movement occurs as the player will otherwise find themselves at their original location if they end travel mode immediately
10+
gui.simulateInput(advScreen, 'A_MOVE_S') -- the player army is only created once the player moves in travel mode; ensure that this movement occurs as the player will otherwise find themselves at their original location if they end travel mode immediately
1111
-- note: the above movement may be blocked by an impassable tile (especially if trying to teleport into a mountain range); it would be more ideal to create and move the player army directly instead
1212
end
1313

@@ -20,9 +20,14 @@ local advScreen = dfhack.gui.getViewscreenByType(df.viewscreen_dungeonmodest, 0)
2020
local questMap = dfhack.gui.getViewscreenByType(df.viewscreen_adventure_logst, 0)
2121
or qerror("You must first select your destination on the quest log map!")
2222

23-
local target_x = questMap.cursor.x
24-
local target_y = questMap.cursor.y
25-
if questMap.player_region.x == target_x and questMap.player_region.y == target_y then
23+
local mapDisplay = questMap.map_display
24+
if mapDisplay.midmap ~= 0 or mapDisplay.localmap ~= 0 then
25+
qerror("Please zoom the quest log map out to the world map!")
26+
end
27+
28+
local target_x = mapDisplay.cursor.x
29+
local target_y = mapDisplay.cursor.y
30+
if mapDisplay.cur_loc.x == target_x and mapDisplay.cur_loc.y == target_y then
2631
qerror("You already seem to be at the target location!")
2732
end
2833

@@ -38,13 +43,15 @@ if advmode.menu == df.ui_advmode_menu.Default then
3843
processTravelNoArmy(advmode, advScreen, target_x, target_y)
3944

4045
elseif advmode.menu == df.ui_advmode_menu.Travel then
41-
if not advmode.travel_not_moved then -- player is already moving in fast travel mode; just relocate the player army
42-
local army = df.army.find(advmode.player_army_id)
46+
local army = df.army.find(advmode.player_army_id)
47+
if advmode.travel_not_moved == 0 and army then -- player is already moving in fast travel mode; just relocate the player army
4348
army.pos.x = target_x
4449
army.pos.y = target_y
4550
gui.simulateInput(advScreen.child, 'LEAVESCREEN') -- close map
4651
gui.simulateInput(advScreen.child, 'LEAVESCREEN') -- close log
4752
else -- player has opened travel mode but hasn't moved yet, so the player army hasn't been created
4853
processTravelNoArmy(advmode, advScreen, target_x, target_y)
4954
end
55+
else
56+
qerror("Please close the open menu before questporting!")
5057
end

‎reveal-adv-map.lua‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@ function revealAdvMap(hide)
1212
-- update the quest log configuration if it is already open (restricts map cursor movement):
1313
local view = dfhack.gui.getDFViewscreen(true)
1414
if view._type == df.viewscreen_adventure_logst then
15-
local player = view.player_region
15+
local mapDisplay = view.map_display
16+
local player = mapDisplay.cur_loc
1617
if hide then
17-
view.cursor.x = player.x
18-
view.cursor.y = player.y
18+
mapDisplay.cursor.x = player.x
19+
mapDisplay.cursor.y = player.y
1920
end
20-
view.min_discovered.x = (hide and player.x) or 0
21-
view.min_discovered.y = (hide and player.y) or 0
22-
view.max_discovered.x = (hide and player.x) or world.world_width - 1
23-
view.max_discovered.y = (hide and player.y) or world.world_height - 1
21+
mapDisplay.min.x = (hide and player.x) or 0
22+
mapDisplay.min.y = (hide and player.y) or 0
23+
mapDisplay.max.x = (hide and player.x) or world.world_width - 1
24+
mapDisplay.max.y = (hide and player.y) or world.world_height - 1
2425
end
2526
end
2627

0 commit comments

Comments
 (0)