diff --git a/pkg/memory/game_reader.go b/pkg/memory/game_reader.go index 556c276..0e65efb 100644 --- a/pkg/memory/game_reader.go +++ b/pkg/memory/game_reader.go @@ -318,7 +318,7 @@ func (gd *GameReader) InCharacterSelectionScreen() bool { } func (gd *GameReader) GetSelectedCharacterName() string { - return gd.Process.ReadStringFromMemory(gd.Process.moduleBaseAddressPtr+0x1C3D694, 0) + return gd.Process.ReadStringFromMemory(gd.Process.moduleBaseAddressPtr+gd.offset.SelectedCharName, 0) } func (gd *GameReader) LegacyGraphics() bool { @@ -438,11 +438,11 @@ func (gd *GameReader) IsDismissableModalPresent() (bool, string) { } func (gd *GameReader) LastGameName() string { - return gd.ReadStringFromMemory(gd.moduleBaseAddressPtr+0x29FB450, 0) + return gd.ReadStringFromMemory(gd.moduleBaseAddressPtr+gd.offset.LastGameName, 0) } func (gd *GameReader) LastGamePass() string { - return gd.ReadStringFromMemory(gd.moduleBaseAddressPtr+0x29FB4A8, 0) + return gd.ReadStringFromMemory(gd.moduleBaseAddressPtr+gd.offset.LastGamePassword, 0) } func (gd *GameReader) FPS() int { diff --git a/pkg/memory/keybindings.go b/pkg/memory/keybindings.go index 1eaf9bf..ad0cdb5 100644 --- a/pkg/memory/keybindings.go +++ b/pkg/memory/keybindings.go @@ -8,8 +8,8 @@ import ( ) func (gd *GameReader) GetKeyBindings() data.KeyBindings { - blob := gd.ReadBytesFromMemory(gd.moduleBaseAddressPtr+0x18C2894, 0x500) - blobSkills := gd.ReadBytesFromMemory(gd.moduleBaseAddressPtr+0x1CE8510, 0x500) + blob := gd.ReadBytesFromMemory(gd.moduleBaseAddressPtr+gd.offset.KeyBindingsOffset, 0x500) + blobSkills := gd.ReadBytesFromMemory(gd.moduleBaseAddressPtr+gd.offset.KeyBindingsSkillsOffset, 0x500) skillsKB := [16]data.SkillBinding{} for i := 0; i < 7; i++ { diff --git a/pkg/memory/offset.go b/pkg/memory/offset.go index 2b9dbdc..6e24274 100644 --- a/pkg/memory/offset.go +++ b/pkg/memory/offset.go @@ -19,15 +19,12 @@ type Offset struct { Ping uintptr LegacyGraphics uintptr CharData uintptr + SelectedCharName uintptr + LastGameName uintptr + LastGamePassword uintptr } -func calculateOffsets(process *Process) Offset { - memory, err := process.getProcessMemory() - if err != nil || len(memory) == 0 { - // Return empty offsets - will be recalculated when game is ready - return Offset{} - } - +func calculateOffsets(_ *Process) Offset { // UnitTable unitTableOffset := uintptr(0x1D95AF0) @@ -55,17 +52,20 @@ func calculateOffsets(process *Process) Offset { // FPS fpsOffset := uintptr(0x1C46894) + // KeyBindings + keyBindingsOffset := uintptr(0x18C2894) + // KeyBindings Skills keyBindingsSkillsOffset := uintptr(0x1CE8510) // QuestInfo - questInfoOffset := uintptr(0) + questInfoOffset := uintptr(0x1DB23D8) // Terror Zones - tzOffset := uintptr(0x248D4C8) + tzOffset := uintptr(0x248D430) // Ping - pingOffset := uintptr(0) + pingOffset := uintptr(0x1CE78D0) // LegacyGraphics legacyGfxOffset := uintptr(0x1DB263E) @@ -73,6 +73,15 @@ func calculateOffsets(process *Process) Offset { // CharData charDataOffset := uintptr(0x1CED5E8) + // Selected Char Name + selectedCharNameOffset := uintptr(0x1C3D694) + + // Last Game Name + lastGameNameOffset := uintptr(0x24D5A90) + + // Last Game Password + lastGamePasswordOffset := uintptr(0x24D5AE8) + return Offset{ UnitTable: unitTableOffset, UI: uiOffsetPtr, @@ -83,11 +92,15 @@ func calculateOffsets(process *Process) Offset { WidgetStatesOffset: WidgetStatesOffset, WaypointTableOffset: WaypointTableOffset, FPS: fpsOffset, + KeyBindingsOffset: keyBindingsOffset, KeyBindingsSkillsOffset: keyBindingsSkillsOffset, QuestInfo: questInfoOffset, TZ: tzOffset, Ping: pingOffset, LegacyGraphics: legacyGfxOffset, CharData: charDataOffset, + SelectedCharName: selectedCharNameOffset, + LastGameName: lastGameNameOffset, + LastGamePassword: lastGamePasswordOffset, } }