Skip to content
This repository has been archived by the owner on Dec 20, 2021. It is now read-only.

Windows - Detect Diablo 2 install directory if not installed in default directory #1048

Open
Alexbeav opened this issue Feb 6, 2021 · 2 comments

Comments

@Alexbeav
Copy link

Alexbeav commented Feb 6, 2021

Under Windows, the defaults.go file assumes that the game is installed in the default directory, 'C:\Program Files (x86)\Diablo II', with a hard coded MPQ location of:

(d2core\d2config\defaults.go, line 44)
config.MpqPath = "C:/Program Files/Diablo II"

If Diablo 2 is not installed in the above directory, the 'go run .' fails.

I believe the following solution could fix this:

`package main

import (
"fmt"
"log"

"golang.org/x/sys/windows/registry"

)

func main() {
k, err := registry.OpenKey(registry.LOCAL_MACHINE, SOFTWARE\WOW6432Node\Blizzard Entertainment\Diablo II, registry.QUERY_VALUE)
if err != nil {
log.Fatal(err)
}
s, _, err := k.GetStringValue("InstallPath")
if err != nil {
log.Fatal(err)
}
fmt.Printf("Diablo 2 is installed in: %q\n", s)
}`

I'm not a programmer, but I wrote this to return the D2 install directory by reading it from the appropriate registry file. I don't know how it could be formatted or implemented better, but that should take care of finding the location of the MPQ file.

I hope this is of use, thank you!

@willroberts
Copy link
Contributor

As an alternative, I would support a flag to specify MPQ directory manually.

@EndlessEden
Copy link

Personally i agree with @willroberts - non-standard locations or backups of installs is a better choice, and it could be done in a platform agnostic way.

Honestly, i think looking for d2data.mpq at runtime, displaying a non_error "config" menu that would alter the MpqPath variable, think would be better.
This would resolve the issue on all platforms and give a starting spot for enabling/editing load-order from runtime in the future.

One of the most difficult things with the current situation is, editing the configuration can only be done from a text editor, and this should be undesirable for the end user experience.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants