Skip to content
This repository was archived by the owner on Dec 21, 2022. It is now read-only.

Commit 30b0091

Browse files
committed
v1.1.1 minor improvments
1 parent c416404 commit 30b0091

File tree

5 files changed

+35
-17
lines changed

5 files changed

+35
-17
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [1.1.1] - 2021-11-02 - Minor improvements
6+
7+
- No longer exits sometimes when changing acts
8+
- Map will no longer show when at menu
9+
- Other minor optimisations
10+
511
## [1.1.0] - 2021-10-28 - Better map drawing
612

713
- Better map alias smoothing

src/d2r-map.ahk

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,36 +21,47 @@ IniRead, startingOffset, settings.ini, Memory, playerOffset
2121

2222
playerOffset:=startingOffset
2323

24-
SetTimer, UpdateCycle, 1000
24+
SetTimer, UpdateCycle, 1000 ; the 1000 here is priority, not sleep
2525
return
2626

2727
UpdateCycle:
2828
; scan for the player offset
2929
playerOffset := checkLastOffset(playerOffset)
3030
if (!playerOffset) {
31+
Sleep, 1000
3132
playerOffset := scanForPlayerOffset(startingOffset)
3233
}
3334
if (playerOffset) {
3435
pSeedAddress := getMapSeedAddress(playerOffset)
3536
if (pSeedAddress) {
3637
pLevelNoAddress := getLevelNoAddress(playerOffset)
37-
sMapUrl := getD2RMapUrl(baseUrl, pSeedAddress, pLevelNoAddress)
38-
if (InStr(lastMap, sMapUrl)) { ; if map not changed then don't update
39-
} else {
40-
WriteLog("Fetching map from " sMapUrl)
41-
lastMap := sMapUrl
42-
ShowMap(sMapUrl, width, height, leftMargin, topMargin, opacity)
38+
if (pLevelNoAddress) {
39+
sMapUrl := getD2RMapUrl(baseUrl, pSeedAddress, pLevelNoAddress)
40+
if (InStr(lastMap, sMapUrl)) { ; if map not changed then don't update
41+
} else {
42+
WriteLog("Fetching map from " sMapUrl)
43+
lastMap := sMapUrl
44+
ShowMap(sMapUrl, width, height, leftMargin, topMargin, opacity)
45+
}
4346
}
4447
} else {
4548
WriteLog("Found playerOffset" playerOffset ", but not map seed address")
46-
Sleep, 2000
49+
Gui, 1: Hide
50+
playerOffset := startingOffset ; reset the offset to default
51+
Sleep, 1000
4752
}
4853
} else {
49-
Sleep, 5000 ; sleep longer when no offset found, this means you're in menu
54+
playerOffset := startingOffset ; reset the offset to default
55+
Gui, 1: Hide
56+
Sleep, 3000 ; sleep longer when no offset found, you're likely in menu
5057
}
51-
Sleep, 1000
58+
Sleep, 1000 ; set a pacing of 1 second
5259
return
5360

54-
+F4::ExitApp ; shift+f4 to exit app
61+
+F10::
62+
{
63+
WriteLog("Pressed Shift+F10, exiting...")
64+
ExitApp
65+
}
5566

5667

src/include/getLevelNo.ahk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ getLevelNoAddress(playerOffset) {
3636
levelNo := d2r.read(dwLevelNo, "UInt")
3737
if (!levelNo) {
3838
WriteLog("Did not find level num at address " dwLevelNo " using player offset " playerOffset)
39-
ExitApp
4039
}
4140
;WriteLog("Found level num " levelNo " at address " dwLevelNo)
4241

src/include/getPlayerOffset.ahk

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ checkLastOffset(startingOffset) {
88
}
99

1010
scanForPlayerOffset(startingOffset) {
11-
return getPlayerOffset(startingOffset, 2000)
11+
;WriteLog("Scanning for new player offset address, starting default offset " startingOffset)
12+
return getPlayerOffset(startingOffset, 128)
1213
}
1314

1415

16+
1517
getPlayerOffset(startingOffset, loops) {
1618

1719
if (_ClassMemory.__Class != "_ClassMemory")
@@ -28,11 +30,9 @@ getPlayerOffset(startingOffset, loops) {
2830
ExitApp
2931
}
3032

31-
;WriteLog("Looking for player offset address, starting with offset " startingOffset)
32-
3333
loop, %loops%
3434
{
35-
newOffset := HexAdd(startingOffset, A_Index - 1)
35+
newOffset := HexAdd(startingOffset, (A_Index - 1) * 8)
3636
startingAddress := d2r.BaseAddress + newOffset
3737
playerUnit := d2r.read(startingAddress, "Int64")
3838
if (playerUnit) {
@@ -47,6 +47,8 @@ getPlayerOffset(startingOffset, loops) {
4747
}
4848
newOffset := newOffset + 0
4949
return newOffset
50+
} else {
51+
WriteLog("Found player unit: " playerUnit ", from " A_Index " attempts, but no mapSeed " mapSeed ", ignoring...")
5052
}
5153
}
5254
}

src/include/showMap.ahk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ShowMap(sMapUrl, width, height, leftMargin, topMargin, opacity) {
1515

1616
sFile=%a_scriptdir%\currentmap.png
1717
URLDownloadToFile, %sMapUrl%,%sFile%
18-
18+
1919
Gui, 1: -Caption +E0x20 +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
2020
Gui, 1: Show, NA
2121

0 commit comments

Comments
 (0)