Skip to content

Commit

Permalink
Updated patcher view.
Browse files Browse the repository at this point in the history
  • Loading branch information
nokka committed Jul 22, 2020
1 parent 73d1f91 commit c006f8e
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 18 deletions.
3 changes: 1 addition & 2 deletions clients/slashdiablo/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ type Client struct {

// GetFile will the file by the given path in the repository set on the service.
func (c *Client) GetFile(filePath string) (io.ReadCloser, error) {
// TODO: Fix back to slashdiablo-patches.
resp, err := http.Get(fmt.Sprintf("%s/debug/%s", c.address, filePath))
resp, err := http.Get(fmt.Sprintf("%s/slashdiablo-patches/%s", c.address, filePath))
if err != nil {
return nil, err
}
Expand Down
9 changes: 3 additions & 6 deletions d2/diablo_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"os"
"os/exec"
"strings"
"syscall"
"unicode/utf8"

"golang.org/x/sys/windows/registry"
Expand Down Expand Up @@ -97,11 +96,9 @@ func launch(path string, flags []string, done chan execState) (*int, error) {
// Wait on separate thread.
go func() {
if err := cmd.Wait(); err != nil {
if exiterr, ok := err.(*exec.ExitError); ok {
// The program has exited with an exit code != 0
if status, ok := exiterr.Sys().(syscall.WaitStatus); ok {
done <- execState{pid: &cmd.Process.Pid, err: fmt.Errorf("Exit status: %d : %s", status.ExitStatus(), stderr.String())}
}
if _, ok := err.(*exec.ExitError); ok {
// The program has exited unsuccessfully most probably they just 'X'ed the window, no need to log it.
done <- execState{pid: &cmd.Process.Pid, err: nil}
} else {
// Was some other wait error such as permissions, return the err.
done <- execState{pid: &cmd.Process.Pid, err: fmt.Errorf("cmd.Wait: %d : %s", err, stderr.String())}
Expand Down
32 changes: 25 additions & 7 deletions d2/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ func (s *service) ValidateGameVersions() (bool, error) {
return false, err
}

// Get current slash patch and compare.
version113cManifest, err := s.getManifest("1.13c/manifest.json")
if err != nil {
return false, err
}

// Get current slash patch and compare.
slashManifest, err := s.getManifest("current/manifest.json")
if err != nil {
Expand All @@ -166,7 +172,14 @@ func (s *service) ValidateGameVersions() (bool, error) {

// Game wasn't 1.13c, needs to be updated.
if !valid {
return false, nil
upToDate = false
// Get files that aren't up to date and add them to the file model.
version113cFiles, _, err := s.getFilesToPatch(version113cManifest.Files, game.Location, nil)
if err != nil {
return false, err
}

s.addFilesToModel(version113cFiles)
}

// Check if the current game install is up to date with the slash patch.
Expand Down Expand Up @@ -502,6 +515,8 @@ func (s *service) listenForGameStates() {
}

func (s *service) validateMaphackVersion(game *storage.Game, versions []string) (bool, error) {
isValid := true

for _, v := range versions {
manifest, err := s.getManifest(fmt.Sprintf("maphack_%s/manifest.json", v))
if err != nil {
Expand All @@ -526,7 +541,7 @@ func (s *service) validateMaphackVersion(game *storage.Game, versions []string)
// Maphack patch isn't up to date.
if len(missingMaphackFiles) > 0 {
s.addFilesToModel(missingMaphackFiles)
return false, nil
isValid = false
}
} else {
installed, err := isModInstalled(game.Location, ModMaphackIdentifier, manifest)
Expand All @@ -542,15 +557,17 @@ func (s *service) validateMaphackVersion(game *storage.Game, versions []string)
return false, err
}

return false, nil
isValid = false
}
}
}

return true, nil
return isValid, nil
}

func (s *service) validateHDVersion(game *storage.Game, versions []string) (bool, error) {
isValid := true

for _, v := range versions {
manifest, err := s.getManifest(fmt.Sprintf("hd_%s/manifest.json", v))
if err != nil {
Expand All @@ -568,7 +585,7 @@ func (s *service) validateHDVersion(game *storage.Game, versions []string) (bool
// HD mod isn't up to date.
if len(missingFiles) > 0 {
s.addFilesToModel(missingFiles)
return false, nil
isValid = false
}
} else {
installed, err := isModInstalled(game.Location, ModHDIdentifier, manifest)
Expand All @@ -583,12 +600,13 @@ func (s *service) validateHDVersion(game *storage.Game, versions []string) (bool
if err != nil {
return false, err
}
return false, nil

isValid = false
}
}
}

return true, nil
return isValid, nil
}

func (s *service) apply113c(path string, state chan PatchState, progress chan float32) error {
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func main() {
// Environment variables set when building.
var (
debugMode = envBool("DEBUG_MODE", false)
environment = envString("ENVIRONMENT", "development")
environment = envString("ENVIRONMENT", "production")
buildVersion = envString("BUILD_VERSION", "v1.1.0")
)

Expand Down
2 changes: 1 addition & 1 deletion qml/GameSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ Item {
}

SText {
text: "Run if this install has troubles with crashing - requires reboot after"
text: "Run if this install gets Access Violation (C0000005) error - requires reboot"
font.pixelSize: 11
topPadding: 5
color: "#676767"
Expand Down
1 change: 1 addition & 0 deletions qml/LoadingScreen.qml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ Rectangle {
height: 40
anchors.bottom: parent.bottom
anchors.right: parent.right
anchors.rightMargin: 8

Title {
text: settings.buildVersion
Expand Down
7 changes: 6 additions & 1 deletion qml/Patcher.qml
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,12 @@ Item {
anchors.right: patchChanges.left
anchors.rightMargin: 10

onClicked: diablo.applyPatches()
onClicked: {
// Clear any files that has been set to be patched before patching.
diablo.patchFiles.clear()

diablo.applyPatches()
}
}

Image {
Expand Down

0 comments on commit c006f8e

Please sign in to comment.