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

Ridge Racer 2 adhoc not working due to channel mismatch, includes workaround #10698

Closed
DarkArchonMind opened this issue Mar 8, 2018 · 7 comments

Comments

@DarkArchonMind
Copy link

What happens?

Ridge Racer 2 adhoc doesn't work because of channel mismatch
After calling sceUtilityGetSystemParamInt, since default value in ppsspp.ini is 0, RR2 decides to set the channel to 11 and caches it in memory

Later, when executing sceNetAdhocctlGetScanInfo, after getting the group result, the game looks in the groups for ones which are on the same channel, which fails, since all the group channels are set to 1 here

buf[discovered].channel = 1;

Change both ppsspp config files ppsspp.ini to set WlanAdhocChannel = 1 fixes this, but I'm wondering if there could be a way to detect and patch this, Or, maybe set WlanAdhocChannel = 1 by default instead of 0, especially since so much of the networking code tries to force things into channel 1.

What should happen?

Should connect and work correctly.

What hardware and operating system are you running PPSSPP on? GPU might matter if it's a graphical issue.

Windows

@nugarp
Copy link

nugarp commented May 28, 2018

Does this actually fix networking for Ridge Racer 2? I tested this and while I can host OK on the instance running the adhoc server, the client instance either says "communication error" or "no games found." It also sometimes gets stuck at "searching for a race open for entries." If I try to host a game with a client instance, it just says communication error. Tested on v1.6 with EUR RR2.

@adenovan
Copy link
Contributor

adenovan commented Jan 9, 2019

does the game call this hle function ?

https://github.com/hrydgard/ppsspp/blob/master/Core/HLE/sceUtility.cpp#L675 ?

double check on host and client.

if yes maybe we should emulate it properly by implementing the actual channel instead of force it to 1 , on SceUtilitySetParamInt And SceUtilityGetParamInt , its already has commented line on link to the ini file , try to uncomment that and make the options in networking settings.

there is 4 adhoc channel in psp , actually 3 because automatic will choose 1 of the 3 channel from psp sdk depend on the game call like this issue.

#define PSP_SYSTEMPARAM_ADHOC_CHANNEL_AUTOMATIC 0
#define PSP_SYSTEMPARAM_ADHOC_CHANNEL_1 1
#define PSP_SYSTEMPARAM_ADHOC_CHANNEL_6 6
#define PSP_SYSTEMPARAM_ADHOC_CHANNEL_11 11

it will mess the proadhocserver grouping info so the later call on SceNetAdhocctlScan can return invalid peer result and group info. we should also emulate that properly by implementing channel on group array inside of proadhocserver code.

if the game later call SceUtilitySetParamInt on established connection with proadhocserver we should tell the proadhocserver also the user is belong to the channel provided by the game , move the user to the correct group and the correct channel so the call for SceNetAdhocctlScan return an valid peer for other user. that is an workaround the fastest one is always set the channel to the 1 on client and host. but not sure if all game accept it . need to trace it on actuall psp how most of game behave on channel switching

@anr2me
Copy link
Collaborator

anr2me commented Mar 2, 2020

Actually, the game doesn't try to change the channel (never use sceUtilitySetParamInt), it only compares the channel value.

The only solution i can think of is, to make sure sceUtilityGetSystemParamInt returns a valid channel number (non-zero) when connected to a network (ie. using the channel data from parameter.channel variable) for Ridge Racer 2 to works with Auto channel, because it's comparing the channel value taken from sceUtilityGetSystemParamInt with the channel from sceNetAdhocctlGetScanInfo, if they don't matched the game room is ignored, and if it's 0 (Auto) the game room is also ignored.

But i'm not sure if this is also happened on real PSP or not tho.

@adenovan
Copy link
Contributor

adenovan commented Jul 3, 2020

test on automatic channel its return 0 either connected or not

[x] Load Module all net module test
[r] sceUtilityLoadNetModule common: 00000000
[r] sceUtilityLoadNetModule adhoc: 00000000
[r] sceUtilityLoadNetModule inet: 00000000
[r] sceNetInit : 00000000
[r] sceNetAdhocInit: 00000000
[r] sceNetAdhocctlInit: 00000000
[r] Pad CROSS to get peer List
[r] Pad TRIANGLE to exit the test and send all buffer to host
[r] Pad SQUARE get util param int
[r] Pad L_TRIGGER join control as creator maybe (host)
[r] Pad R_TRIGGER join control as connector maybe (client)
[r] Pad UP to Start Scan
[r] Pad DOWN to Stop Scan
[r] Starting User PAD Input Loop
[x] Result of User Pad
[r] sceNetAdhocctlConnect: 00000000 groupname R01
[r] Joining as Connector
[x] sceUtilityGetSystemParamInt : 00000000 0
[r] sceUtilityGetSystemParamInt : 00000000 0
[r] sceUtilityGetSystemParamInt : 00000000 0
[x] sceNetAdhocctlTerm: 00000000
[r] sceNetAdhocTerm : 00000000
[r] sceNetTerm : 00000000
[r] sceUtilityUnloadModule: 00000000
[r] sceUtilityUnloadModule: 00000000
[r] sceUtilityUnloadModule: 00000000

test with adhoc channel 1 its return 1

[x] Load Module all net module test
[r] sceUtilityLoadNetModule common: 00000000
[r] sceUtilityLoadNetModule adhoc: 00000000
[r] sceUtilityLoadNetModule inet: 00000000
[r] sceNetInit : 00000000
[r] sceNetAdhocInit: 00000000
[r] sceNetAdhocctlInit: 00000000
[r] Pad CROSS to get peer List
[r] Pad TRIANGLE to exit the test and send all buffer to host
[r] Pad SQUARE get util param int
[r] Pad L_TRIGGER join control as creator maybe (host)
[r] Pad R_TRIGGER join control as connector maybe (client)
[r] Pad UP to Start Scan
[r] Pad DOWN to Stop Scan
[r] Starting User PAD Input Loop
[x] Result of User Pad
[r] sceUtilityGetSystemParamInt : 00000000 1
[r] sceUtilityGetSystemParamInt : 00000000 1
[r] sceNetAdhocctlConnect: 00000000 groupname R01
[r] Joining as Connector
[x] sceUtilityGetSystemParamInt : 00000000 1
[r] sceUtilityGetSystemParamInt : 00000000 1
[r] sceUtilityGetSystemParamInt : 00000000 1
[r] calling get peer info with buffsize 2584
[r] SceNetAdhocctlGetPeerList : 00000000
[r] Buffsize after call 0
[r] Peer info Next 0x0
[r] Peer Info nickname
[r] Peer Info mac 00:00:00:00:00:00
[r] Peer Info unknown 00:00:00:00:00:00
[r] Peer info timestamp 0l
[x] sceNetAdhocctlTerm: 00000000
[r] sceNetAdhocTerm : 00000000
[r] sceNetTerm : 00000000
[r] sceUtilityUnloadModule: 00000000
[r] sceUtilityUnloadModule: 00000000
[r] sceUtilityUnloadModule: 00000000

the test code

if((prev_buttons & PSP_CTRL_SQUARE) == 0 && (curr_buttons & PSP_CTRL_SQUARE) != 0) {
            int paramresult;
            int util = sceUtilityGetSystemParamInt(PSP_SYSTEMPARAM_ID_INT_ADHOC_CHANNEL,&paramresult);
            checkpoint("sceUtilityGetSystemParamInt : %08x %d",util,paramresult);
        }

@adenovan
Copy link
Contributor

adenovan commented Jul 3, 2020

this will clear some confusion but scan return 11

[x] Load Module all net module test
[r] sceUtilityLoadNetModule common: 00000000
[r] sceUtilityLoadNetModule adhoc: 00000000
[r] sceUtilityLoadNetModule inet: 00000000
[r] sceNetInit : 00000000
[r] sceNetAdhocInit: 00000000
[r] sceNetAdhocctlInit: 00000000
[r] Pad CROSS to get peer List
[r] Pad TRIANGLE to exit the test and send all buffer to host
[r] Pad SQUARE get util param int
[r] Pad L_TRIGGER join control as creator maybe (host)
[r] Pad R_TRIGGER join control as connector maybe (client)
[r] Pad UP to Start Scan
[r] Pad DOWN to Stop Scan
[r] Starting User PAD Input Loop
[x] Result of User Pad
[r] SceNetAdhocctlScan : 00000000
[x] sceUtilityGetSystemParamInt : 00000000 0
[r] sceNetAdhocctlGetScanInfo : 00000000
[r] scan buffer name R01
[r] scan Buffer channel 11
[x] sceUtilityGetSystemParamInt : 00000000 0
[r] sceUtilityGetSystemParamInt : 00000000 0
[r] calling get peer info with buffsize 2584
[r] SceNetAdhocctlGetPeerList : 80410682

@adenovan
Copy link
Contributor

adenovan commented Jul 3, 2020

the conclusion
when set automatic on both console settings the automatic use channel 11 by default on getscaninfo and return 0 on sceUtilityGetSystemParamInt

we can force both to return channel 1 for a quick fix
return sceUtilityGetSystemParamInt with 1 too and keep the discovered on 1 in scaninfo

@anr2me
Copy link
Collaborator

anr2me commented Dec 27, 2020

This should already been fixed by now, Ridge Racer 2 (and Warriors Orochi 2, who had similar issue) can use any channel (including auto) without issue.

@hrydgard hrydgard modified the milestones: v1.12.0, v1.11.0 Dec 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants