gomule-d2r icon indicating copy to clipboard operation
gomule-d2r copied to clipboard

d2r holds saves when open

Open Pwntheon opened this issue 4 years ago • 7 comments

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?

Pwntheon avatar Sep 25 '21 06:09 Pwntheon

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

pairofdocs avatar Sep 25 '21 15:09 pairofdocs

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.

Pwntheon avatar Sep 27 '21 10:09 Pwntheon

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

m4ke

m4ke72 avatar Sep 27 '21 14:09 m4ke72

@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

pairofdocs avatar Sep 27 '21 17:09 pairofdocs

Please don't make this Win only software !

m4ke

m4ke72 avatar Sep 27 '21 17:09 m4ke72

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

pairofdocs avatar Sep 27 '21 22:09 pairofdocs

@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

pairofdocs avatar Sep 27 '21 23:09 pairofdocs