Skip to content

Clans: Emulator and server implementation - #17835

Merged
Megamouse merged 47 commits into
RPCS3:masterfrom
ZephyrCodesStuff:feat/clans
Dec 20, 2025
Merged

Megamouse merged 47 commits into
RPCS3:masterfrom
ZephyrCodesStuff:feat/clans

Conversation

@ZephyrCodesStuff

@ZephyrCodesStuff ZephyrCodesStuff commented Dec 7, 2025 •

Copy link
Copy Markdown
Contributor

This PR implements the Sony Clans subsystem for the RPCS3 emulator.

Used in:

  • PlayStation Home [NPIA00005]
  • Killzone: 2
  • Ratchet: Deadlocked
  • ?

Addresses and closes #16464.


The source code for the server is available here and is licensed AGPLv3.

  • It's written in Rust, with my best efforts in readability and documentation.
  • Every feature not-pertaining to RPCS3 has been feature-gated at compile-time.
  • Fully Dockerized deployment
  • Ticket signature verification

NOTE: The server is fully compatible with the PS3 console as well, as it follows the PS3 Clans Library specification.


The emulator code tries its best to follow on the steps of the RPCN client code wherever possible; both in the Client as well as the Settings and Config components.

Features:

  • Clans client implementation in clans_client.[h,cpp]
  • Syscalls implementation in sceNpClans.[h,cpp]
    • A couple of missing structs and/or enum members have been added in sceNp.h
  • Qt GUI for selecting the desired Clans server to use (default: [HTTPS] clans.rpcs3.net)
    • Implemented in clans_settings_dialog.[h,cpp]
    • Prevents modifying during emulator usage
  • clans.yml config file for persistence
    • Implemented in clans_config.[h,cpp]

- Needs GUI implementation to pick the server host
- Needs code to select the server host from config

Signed-off-by: zeph <[email protected]>
- Enabled SSL host verification

Signed-off-by: zeph <[email protected]>

@RipleyTom RipleyTom left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also need to add the files to msvc projects.

Comment thread rpcs3/Emu/Cell/Modules/sceNpClans.h Resolved
Comment thread rpcs3/Emu/Cell/Modules/sceNpClans.cpp Resolved
Comment thread rpcs3/Emu/Cell/Modules/sceNpClans.cpp Resolved
Comment thread rpcs3/Emu/Cell/Modules/sceNpClans.cpp Resolved
Comment thread rpcs3/Emu/Cell/Modules/sceNpClans.cpp Resolved
Comment thread rpcs3/Emu/NP/clans_client.cpp Resolved
Comment thread rpcs3/Emu/NP/clans_client.cpp Resolved
Comment thread rpcs3/Emu/NP/clans_client.cpp Resolved
Comment thread rpcs3/Emu/NP/clans_client.cpp Resolved
Comment thread rpcs3/Emu/NP/clans_client.h Resolved
Apparently, when paging is null we're supposed to return the total count from the server. The game will only access `pageResult->total`.
@ZephyrCodesStuff

ZephyrCodesStuff commented Dec 8, 2025 •

Copy link
Copy Markdown
Contributor Author

Addressed a good chunk of the suggestions.

Current to-do list of what's left:

  • CURL per-request
  • Actual request instance spawning and handle tracking with a generator
    • CURL ptr could go in here (?)
  • Ticket callback handling instead of busy loop
    • Handling case when ticket requesting fails

Comment thread rpcs3/rpcs3qt/clans_settings_dialog.h Resolved
Comment thread rpcs3/Emu/NP/clans_config.cpp Resolved
Comment thread rpcs3/Emu/NP/clans_config.cpp Resolved
Comment thread rpcs3/Emu/NP/clans_client.cpp Resolved
ZephyrCodesStuff and others added 4 commits December 8, 2025 13:10
@ZephyrCodesStuff

Copy link
Copy Markdown
Contributor Author

I've implemented an IDM for request handling and tested in-game -- everything seems fine and working. Clan search, membership status, sanity checks (don't join a clan you already are in, etc...). Ticket request failure is also now handled, meaning the game will display "Service Unavailable." if a ticket fails to be fetched.

Next step is now improving ticket requesting via callbacks!

Using proper atomic synchronisation primitives, instead of a busy loop

Signed-off-by: zeph <[email protected]>
@ZephyrCodesStuff

Copy link
Copy Markdown
Contributor Author

Everything has been handled. Please let me know if there's anything left to fix!

Comment thread rpcs3/Emu/NP/clans_config.cpp Resolved
@ZephyrCodesStuff

Copy link
Copy Markdown
Contributor Author

Switched to fmt::split_sv

@RipleyTom RipleyTom left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to remove those sscanf too, you can just use the std::string directly with string_to_npid

Comment thread rpcs3/Emu/Cell/Modules/sceNpClans.cpp Resolved
Comment thread rpcs3/Emu/Cell/Modules/sceNpClans.cpp Resolved
Comment thread rpcs3/Emu/NP/clans_client.cpp Resolved
Comment thread rpcs3/Emu/NP/clans_client.cpp Resolved
Comment thread rpcs3/Emu/NP/clans_client.cpp Resolved
Comment thread rpcs3/Emu/NP/clans_client.cpp Resolved
Comment thread rpcs3/Emu/NP/clans_client.cpp Resolved
Comment thread rpcs3/Emu/Cell/Modules/sceNpClans.cpp Resolved
ZephyrCodesStuff and others added 7 commits December 10, 2025 20:42
- Replaced `sscanf` with `np::string_to_npid`
- Reinstated log messages on level `warning` for implemented functions

Signed-off-by: zeph <[email protected]>

@RipleyTom RipleyTom left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR also lacks a mechanism to handle sceNpClans request when the game is not configured as Connected/RPCN. I don't know if that is an actual issues in games but if it does happen it will result in RPCN required assert.

clans_client::getClanTicket is probably a good place to return "" if nph.get_psn_status() != SCE_NP_MANAGER_STATUS_ONLINE, returning an empty ticket which leads most of your code to return SCE_NP_CLANS_ERROR_SERVICE_UNAVAILABLE.

Comment thread rpcs3/Emu/Cell/Modules/sceNpClans.cpp Resolved
Comment thread rpcs3/Emu/NP/np_requests.cpp Resolved
Comment thread rpcs3/Emu/NP/clans_client.cpp Resolved
ZephyrCodesStuff and others added 4 commits December 12, 2025 01:35
- Removed usage of raw pointers with `new`
- `clans_client::getClanTicket` now _actually_ uses the cached ticket if available.
- Avoid setting `current_ticket` and instead hijack it if it's the Clans ticket
- Refusing to get a ticket if emulator is not connected to RPCN

Signed-off-by: zeph <[email protected]>
…ical error

- Implemented clan creation syscall
- Implemented clan disbanding syscall
- Fixed an issue where the ticket would only actually be fetched once and never again, causing `service unavailable` every time after the 1st one

Signed-off-by: zeph <[email protected]>
Comment thread rpcs3/Emu/NP/clans_client.h Resolved
Comment thread rpcs3/rpcs3qt/settings_dialog.cpp Resolved
Comment thread rpcs3/Emu/NP/clans_client.cpp Resolved
@ZephyrCodesStuff

Copy link
Copy Markdown
Contributor Author

I've updated the Checkbox to reflect the behavior of the UPnP one: disabled when connection is toggled off, but still keeping its checked/unchecked state.

@Megamouse
Megamouse merged commit f946054 into RPCS3:master Dec 20, 2025
@19Aidan

19Aidan commented Dec 20, 2025 •

Copy link
Copy Markdown

Killzone 2 and Ratchet: Deadlocked uses clans too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature request] Clans Support

4 participants