Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

d2r holds saves when open #6

Open
Pwntheon opened this issue Sep 25, 2021 · 7 comments
Open

d2r holds saves when open #6

Pwntheon opened this issue Sep 25, 2021 · 7 comments

Comments

@Pwntheon
Copy link

Hi.

It appears you need to quit d2r completely to mule - you can't just leave the game. If you have the game open, this can lead to items disappearing (if you move from stash to char) or duping (char to stash).

In the long run it would be nice to add some checks to see if the file has actually been written to, but short term, maybe check if d2r is open and give a warning or something?

@pairofdocs
Copy link
Owner

pairofdocs commented Sep 25, 2021

Hey, good point

The main menu displays character's gear and D2R keeps the save file open. (EDIT: keeps the char data in memory)

I want to stay away from checking memory for open processes since Windows will give virus warnings for Gomule. I'll add a warning to the app to exit D2R when using Gomule and also to the Readme Doc)

I'll think about how to add a code check to prevent accidental saving when D2R is open. Maybe have a pop-up confirmation window but that could be annoying to click through every time saving happens

@Pwntheon
Copy link
Author

Pwntheon commented Sep 27, 2021

I do believe that a simple FileUtils.touch(savefile) (Apache Commons IO) will throw an IOException if the file is open (i.e. d2r is holding it).

Maybe check this before performing actions on a save file?

I agree in general that a modal window is annoying in general. However, since this is a potentially destructive action, it's justified in my view.

@m4ke72
Copy link
Collaborator

m4ke72 commented Sep 27, 2021

File cannot be open if you can save over it? I think D2R caches chars and saves them at exit.

m4ke

@pairofdocs
Copy link
Owner

pairofdocs commented Sep 27, 2021

@Pwntheon good idea

Trying this example from stack overflow https://stackoverflow.com/questions/1390592/check-if-file-is-already-open

  • Tested: D2R running and GoMule running
  • Result: the save file is not open and I can still do save in gomule

Like m4ke72 said D2R keeps the char data in memory and writes to the savefile once the game is closed

I think your first suggestion is the way to go-- checking for a running process Game.exe / D2R.exe.

                        String processName = "D2R.exe"; 
			ProcessBuilder processBuilder = new ProcessBuilder("tasklist.exe");
			try {
				Process process = processBuilder.start();
				Scanner scanner = new Scanner(process.getInputStream(), "UTF-8").useDelimiter("\\A");
				String strr = scanner.hasNext() ? scanner.next() : "";
				System.err.println("process scanner: " + strr);
				scanner.close();
				
                                // check if game is running
				System.err.println("strr.contains(processName);: " + strr.contains(processName));
			}catch(Exception e) {
				;
			}

this check from stack overflow is working, i'll see if Windows has any "potential unsafe software" warnings when opening the gomule.jar

@m4ke72
Copy link
Collaborator

m4ke72 commented Sep 27, 2021

Please don't make this Win only software !

m4ke

@pairofdocs
Copy link
Owner

@m4ke72
Good point, I realized that just now when testing

@pairofdocs
Copy link
Owner

@Pwntheon here's a build ready with a check for d2r.exe running before saving files
https://github.com/pairofdocs/gomule-d2r/archive/refs/heads/main.zip

I didn't get any annoying windows warning popups when launching gomule.jar

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

No branches or pull requests

3 participants