bayaraa / d2gl

Diablo 2 LoD Glide/DDraw to OpenGL Wrapper
GNU General Public License v3.0
164 stars 30 forks source link

D2GL + Linux #123

Open Thorinori opened 7 months ago

Thorinori commented 7 months ago
          > there's a fix on forums, dunno why he didn't do a proper PR https://forum.median-xl.com/viewtopic.php?p=587663#p587663

Just tested it as well, yup that works! Yeah not sure why there isn't a PR, hopefully that gets done. 2 Side Notes about it though: The HD Text overrides custom fonts (which is fine to me at least), and d2gl doesn't work specifically with sigma-loader to get d2stats working properly on Linux still, but as I said before I am not sure which side it is broken for (Still a pretty niche problem too of course since it is on Linux vs Windows as was intended)

Originally posted by @Thorinori in https://github.com/bayaraa/d2gl/issues/13#issuecomment-1624912628

So I pulled my original comment on the MXL Compatibility issue for context. I am currently trying to figure out what is causing this, so I was hoping I could get any insights into what could be causing this. For some reason, D2Stats can't seem to access the D2 DLLs only when using d2gl via sigma-loader, however it can get them just fine when using cnc-ddraw with sigma-loader. I am not totally sure what could be causing that, since as far as I can tell it isn't trying to access ddraw.dll or glide3x.dll, which are the main ones that this seems to interact with. Any help would be appreciated!

bayaraa commented 6 months ago

Sorry i am not familier MXL so really dont understand issue :P Isn't https://github.com/Pooquer/d2gl-mxl Pooquer's fork not working?

Thorinori commented 6 months ago

Yes, that fork does work on its own. I am trying to understand more about what d2gl is doing specifically though, since when using it specifically in Linux, sigma-loader breaks which is what is needed to make d2stats work for item filtering. Like I said in the post, for some reason either sigma-loader or d2gl change something that is preventing it from being able to access the dlls properly, and only when using d2gl's versions of those dlls. Like I said, it is a Linux specific issue that I am trying to fix.

Thorinori commented 4 months ago

Alright so I have been working on this some and I am at a loss for what to do. As I have said before, d2gl does work fine by itself on Linux, this is about getting other utilities to work with it, but it seems like I need to know more about d2gl to continue. Currently I am stuck at other utilities (namely d2stats) having problems hooking into the Diablo 2 process to inject what it needs to when using d2gl, and I saw the newest version specifically had a new DLL loading feature, so I am assuming something d2gl does messes with how the D2 process is made? Would love to chat and get some info!

Thorinori commented 3 months ago

Hey bumping this again, would you be open to chatting via discord or something? Still been having issues like I mentioned in my last comment, and ideally would like to be able to ask some questions and get some better insight into what d2gl is doing since I am not as familiar with messing with processes directly. From my poking around, I am thinking that d2gl is doing something with the D2 process that is making it so D2Stats methods for getting the game process aren't working (Particularly trying to get the hWnd of d2 via [CLASS:Diablo II] to then get the PID), but I am not quite sure what so would love to get some input potentially.

EDIT: I forgot I had ruled out the hWnd part and narrowed it down further. I am running into an issue specifically with trying to call VirtualAllocEx with the handle to the D2 process while using d2gl. I THINK that this is part of what sigma-loader normally fixes (deprotecting the process so d2stats can inject properly), but I am thinking something with d2gl is making it so that can't happen which is then not allowing d2stats to inject and allocate what it needs.

EDIT 2: So I have managed to make it kind of work. It seems if I basically make d2stats take MUCH longer before trying to do anything, it sometimes works properly, so I think one of the windows api calls is happening too slowly for some reason. It is kind of strange honestly.

bayaraa commented 3 months ago

sure. discord: armin1889

Wuteva commented 2 months ago

I have the same problem, did you figure something else out? I made D2Stats loop for much longer as you suggested and it does works but only randomly, most of the time it does not.

Thorinori commented 2 months ago

I have the same problem, did you figure something else out? I made D2Stats loop for much longer as you suggested and it does works but only randomly, most of the time it does not.

Sadly I did not manage to make it work consistently. I did figure out more or less what was causing it, but I couldn't come up with an actual solution since as best as I could tell it came down to being an issue with the dll injection and wine combo.

Wuteva commented 1 month ago

After a bunch of testing, I managed to make it work so far 100% of the time. You have to :

Some of theses step are probably not needed. Not sure why it don't work well with fullscreen, seems like it can't find the window somehow. Hopefully that help.

Thorinori commented 1 month ago

Interesting, I'll give it a shot and see if it can be done without making the fail counter so large.

Thorinori commented 1 month ago

Wow yeah it does seem to actually be working, even with only updating the fail Counter to 100. Honestly, just keeping it in windowed mode and going with that might be enough. Just means you have to wait a moment for d2stats to actually work when you first launch though. @Wuteva seems to have found it! I'll prob go add a PR to D2stats to allow an option for the fail counter so people don't need to recompile it in the future.

Wuteva commented 1 month ago

Good to hear it work for you too!

Thorinori commented 1 month ago

After testing a bit more while making sure I don't break d2stats while also trying to verify what steps are actually needed, it seems like the main things are the update time so it doesn't exit immediately, and changing the windowed mode. Even with a long wait time, if I don't swap the mode between fullscreen and windowed regardless of starting mode, it seems to not want to work. Pretty much right after I toggle fullscreen on then back off it ends up working. So basically what I have found is:

1) Open d2stats 2) Open mxl and hop on a character (this is the order that d2launcher is also expecting to sigma-loader gets used) 3) ctrl + o and switch between fullscreen and windowed (either direction works, just switching it seems to be the key, can switch back after to preferred mode) 4) wait a moment then try to inject filter

This seems to work relatively consistently, at least enough it shouldn't be an issue