otavepto / gbe_fork

Fork of https://gitlab.com/Mr_Goldberg/goldberg_emulator
https://gitlab.com/Mr_Goldberg/goldberg_emulator
GNU Lesser General Public License v3.0
191 stars 55 forks source link

Allow choosing of Steam download server #87

Open Xorinaes opened 4 months ago

Xorinaes commented 4 months ago

I wanted to ask if there's perhaps a possibility to add an option of choosing steam download region? As the newest Granblue game seems to use it for matchmaking and that causes problems when trying to play multiplayer using the emu, so I thought that it might be because right now, there is no region assigned in the emu and that might be throwing the game for a loop?

Detanup01 commented 3 months ago

what? GB using US as default. but dont think it has anything to do with that, you can even override that

Xorinaes commented 3 months ago

Sorry, I'm not sure if I understand; on Steam version of the game, GBR uses the download region setting on Steam to matchmake. This is why so many people recommend changing it to Tokyo, as it's the most populated one. What does "it uses US as default" mean in this context? Like, is it a fallback or something? And how do you override it?

Detanup01 commented 3 months ago

Can you write the AppId down for that game?

Refernecing to this:

https://github.com/otavepto/gbe_fork/blob/2cbc7864305afb0838d317708b9f06a3dfcb6698/dll/dll/steam_utils.h#L83

https://github.com/otavepto/gbe_fork/blob/2cbc7864305afb0838d317708b9f06a3dfcb6698/post_build/README.release.md?plain=1#L468

Also no idea what you trying with the "download region" since Goldberg only have this as region and no stuff like "download region"

Xorinaes commented 3 months ago

AppID is 881020, and that's why I'm asking if it'd be possible to implement it; By the "Download Region" I mean the first option when you navigate to Steam -> Settings -> Download. maxresdefault

otavepto commented 3 months ago

Aren't these the locations of the download servers ? These are only used while downloading an app/update, not in game as far as I know. Online games usually have their own mechanism to determine the nearest server for you, separate from Steam.

If you change that server does it actually make a difference ? Can you no longer for example join a match ?

Xorinaes commented 3 months ago

Yeah, that's the weirdest thing; you're right about it being only the download server and I understand your confusion, but it is what Granblue Fantasy Relink uses to matchmake. It was the same in God Eater 3 at one point. There's lots of posts on Steam recommending people to change this setting to Tokyo - Japan to get matches. In the first version of the game, if there were two friends who had this set to different regions, they could not play together, even if they invited themselves to a private match.

otavepto commented 3 months ago

I'm not sure which API would that be (ISteamMatchmaking Interface might be relevant), keep it open until this is figured out.

Edit: If you have some time, use the latest debug build and try joining/searching for a match, maybe the logs will give us a hint.

Xorinaes commented 3 months ago

Maybe something with SetRegion in ISteamGameServer? I will check it out tomorrow when my friend's online and provide logs then.

Xorinaes commented 3 months ago

Here's the promised log, I launched the game, started the lobby and got my friend to try to join; then, my friend started the lobby and I tried to join. Hopefully it helps you guys. I tried to scrub it from personal data (like changing my actual ip to "my_ip" or my friend's ip to "my_friend_ip_1", stuff like that, but I could've missed something. STEAM_LOG.zip

otavepto commented 3 months ago

Some observations, this line indicates that either the game isn't using ISteamMatchmakingServers or the host data wasn't sent to you somehow.

Steam_Matchmaking_Servers::RunCallbacks requests count = 0, servers count = 0

Usually a game using the above mentioned interface (such as Special Forces X, appid 217860), would call one of these APIs https://github.com/otavepto/gbe_fork/blob/b7c986f47c7c9ca4fdaaf8c6127a2d1665633260/dll/steam_matchmaking_servers.cpp#L150-L160

Then it's up to the emu to send this data. But I didn't find anything like

Steam_Matchmaking_Servers::RequestLANServerList
Steam_Matchmaking_Servers::RequestFriendsServerList
Steam_Matchmaking_Servers::RequestInternetServerList
etc...

Actually there was a problem with that part of the emu not so long from your original post, and there was a workaround for that: https://github.com/otavepto/gbe_fork/releases/tag/release-2024_2_29 If you were using any release before the above one, try any of the newer ones. I doubt that would do anything honestly, but worth giving a test. Try the 2 new config files mentioned in that release on any of the newer ones.

Xorinaes commented 3 months ago

Unfortunately, I tried that release and every combo of those two config files (with neither one, with either one alone and with two of them at the same time) and it didn't work. Just to make sure, I also used the same file with another game that we are sure works properly (GTFO in this case) and it did work. I also tried release version, experimental version, steamclient with original steam_api and experimental version of steamclient, and no dice. Also tried with experimental disable_lan_only and without it. And using virtual LAN service (self-hosted SoftEther with me being the host) and well, nothing worked. I guess there's gotta be some obscure API or a weird way of doing things because it's only the second time that I recall that using download region as matchmaking server happened (with God Eater 3 being the first one), and I don't think Goldberg emu was around during that time.

Xorinaes commented 3 months ago

Hello, it's me again. The game got an update which was supposed to fix something regarding the matchmaking, so I gave it a shot again and no dice. I also used the newe st version of emu from 16.03. I am attaching a new log file; it might help some, as there might've been some changes.

STEAM_LOG.zip

Xorinaes commented 3 months ago

I also found this script which supposedly fixes region lock in Monster Hunter Rise, which apparently worked/works the same way as Granblue Relink, with the matchmaking being dependent on the download region.

region_lock_fix.txt

otavepto commented 3 months ago

This is the repo for the above script by the way: https://github.com/GreenComfyTea/MHR-Better-Matchmaking/tree/main/reframework/autorun/Better_Matchmaking

Thanks for pointing this one out.

Xorinaes commented 3 months ago

No problem, I also thought of one thing - perhaps allowing us to set value of pszRegion would work? I am not sure if it's even possible or valid, but it's my closest guess. Otherwise, I really have no idea, I will continue my search for maybe something that could help. It would seem that this way of doing things, i.e. matchmaking by download region, is actually kinda common for Japanese ports of their games. Also, for some reason, Duck Game did it as well before some update in, I think, 2020-ish.

otavepto commented 3 months ago

I assume this is the API you're talking about https://github.com/otavepto/gbe_fork/blob/5417e0e4c2251ac2dea3da1c6c1daae36ac9fd65/dll/steam_gameserver.cpp#L346-L348

This is never mentioned in the logs, the game never called it. From what I understood from the script/mod is that this is the effective function https://github.com/GreenComfyTea/MHR-Better-Matchmaking/blob/cccd0ab8a51452effb131aab77f9e7147b37e0f6/reframework/autorun/Better_Matchmaking/region_lock_fix.lua#L44-L59

It sets the region to whatever the user configured it for, or "Worldwide" by default. This will eventually call this function https://github.com/otavepto/gbe_fork/blob/5417e0e4c2251ac2dea3da1c6c1daae36ac9fd65/dll/dll/steam_matchmaking.h#L606-L613

And you can actually see it in the logs

[53985 ms, 53985939 us] [tid 3900] GetISteamMatchmaking SteamMatchMaking009
[53986 ms, 53986041 us] [tid 3900] Steam_MatchMaking::AddRequestLobbyListResultCountFilter 1
[53986 ms, 53986120 us] [tid 3900] Steam_MatchMaking::AddRequestLobbyListDistanceFilter 3

Distance filter 3 is "Worldwide", so the game was already searching for worldwide results I guess, also as shown above, the emu doesn't really care about that filter, the function is empty. Later the game detected the lobby and requested its data

[53997 ms, 53997395 us] [tid 3900] Steam_MatchMaking::GetLobbyByIndex 0
[53997 ms, 53997468 us] [tid 3900]   Lobby 109775242669193117
[53997 ms, 53997543 us] [tid 3900] Steam_MatchMaking::GetLobbyData 109775242669193117 lobby_name
[53997 ms, 53997624 us] [tid 3900] Steam_MatchMaking::GetLobbyData returned Ayane
[53997 ms, 53997713 us] [tid 3900] Steam_MatchMaking::GetLobbyData 109775242669193117 allow_spoiler
[53997 ms, 53997788 us] [tid 3900] Steam_MatchMaking::GetLobbyData returned 1
......
[53999 ms, 53999228 us] [tid 3900] Steam_MatchMaking::GetLobbyData 109775242669193117 network_version
[53999 ms, 53999345 us] [tid 3900] Steam_MatchMaking::GetLobbyData returned 110
[53999 ms, 53999422 us] [tid 3900] Steam_MatchMaking::GetLobbyData 109775242669193117 lobby_type
[53999 ms, 53999498 us] [tid 3900] Steam_MatchMaking::GetLobbyData returned 1

And finally it asked for lobby members count

[53999 ms, 53999733 us] [tid 3900] Steam_MatchMaking::GetNumLobbyMembers 109775242669193117
[53999 ms, 53999813 us] [tid 3900] Steam_MatchMaking::GetNumLobbyMembers Number: 1

What I suspect is that the game maybe using Steam_MatchMaking::SetLobbyData & Steam_MatchMaking::GetLobbyData to put the relevant info, you can see a lot of these calls, but this is just guessing.

If someone created a mod for this game or figured what should be changed it would help us a lot.

Xorinaes commented 3 months ago

I come with new findings - I have tested online-fixes emu for a bit, and it seems the game makes two connections that are not even attempted when using this emu. There is one for, what I presume, to be a news source. obraz This connection appeared every time I tried to access the "News" section in the game, and the news worked correctly. When using gbe, a simple "Network Error has occurred" is displayed, and no connection attempt seems to be made (at least I couldn't see one in logs and in TCP View). obraz

The other, more crucial connection is what I think is the actual matchmaking server (at least for my region, I haven't tried testing it with other download regions). This appeared every time I first connected to online mode during a given play session - obraz

The ports were different every time, but the IP was consistent in both cases.

Additionally, when connecting to online services using online-fix, the game makes a multitude of connections on a bunch of different ports - obraz - behaviour not observed when using gbe (refer to above screenshot where only 4 connections are made using gbe). I dunno it it'll help you guys in any way, but it might mean that it's simply not possible to get it working with gbe, as it would seem that the game also relies on some outside servers which, for some reason, gbe doesn't even attempt to connect to? I, of course, have the "disable_lan_only" option enabled, and "offline" and "disable_networking" options disabled. Or is there something I can do to force the emu to connect to those IPs?

otavepto commented 3 months ago

The emu won't interfere with networking if you created disable_lan_only.txt and made sure to remove disable_networking.txt (which just disables steam networking interface, not the actual internet connections). You already did both, so not sure we can anything else, I guess over time someone might figure it out.

Xorinaes commented 2 months ago

A test mod that might have something to do with the issue was just created: https://github.com/Nenkai/gbfr.fix.matchmaking

It seems to hook into ELobbyDistanceFilter. You guys might be able to get some more info from that.

cardinalsad commented 1 month ago

I also got the "Network Connection Error" issue when entering the lobby, and I also found that when the network is connected, if the host logs out, I can join successfully. I checked the logs and found a lot of the following operations in the logs: Steam_Matchmaking::GetLobbyData() 109775242370727322 'matching_mode' Steam_Matchmaking::GetLobbyData() return '0' And the host side found many Socket timeouts: socket_timeouts() TCP SOCKET HEARTBEAT TIMEOUT

Xorinaes commented 4 weeks ago

I also found that when the network is connected, if the host logs out, I can join successfully.

Not quite sure that I follow; were you ultimately able to play together?

cardinalsad commented 4 weeks ago

I also found that when the network is connected, if the host logs out, I can join successfully.

Not quite sure that I follow; were you ultimately able to play together?

No, because you have to exit one to enter the other. In my log, it seems that the room has been added, and then the host can also see in the game that there are currently two people.

cardinalsad commented 4 weeks ago

I also saw the multiple udp connections under online fix that I observed in previous comments. Those connections are suddenly created when the host creates a room.