#pragma once #include #include #include "Utilities/mutex.h" #include "Emu/Cell/Modules/sceNp.h" #include "Emu/Cell/Modules/sceNp2.h" namespace np { struct userinfo_cache { SceNpId npId; std::optional onlineName; std::optional avatarUrl; }; struct memberbin_cache { memberbin_cache(SceNpMatching2RoomMemberBinAttrInternal* sce_memberbin); SceNpMatching2AttributeId id; CellRtcTick updateDate; std::vector data; }; struct member_cache { member_cache(const SceNpMatching2RoomMemberDataInternal* sce_member); userinfo_cache userInfo; CellRtcTick joinDate; SceNpMatching2RoomMemberId memberId; SceNpMatching2TeamId teamId; SceNpMatching2RoomGroupId group_id; SceNpMatching2NatType natType; SceNpMatching2FlagAttr flagAttr; std::map bins; }; struct password_info_cache { bool with_password = false; SceNpMatching2SessionPassword password{}; }; struct room_cache { void update(const SceNpMatching2RoomDataInternal* sce_roomdata); u32 num_slots = 0; SceNpMatching2RoomPasswordSlotMask mask_password = 0; std::optional password; std::map groups; std::map members; bool owner = false; }; class cache_manager { public: cache_manager() = default; void insert_room(const SceNpMatching2RoomDataInternal* sce_roomdata); void add_member(SceNpMatching2RoomId room_id, const SceNpMatching2RoomMemberDataInternal* sce_roommemberdata); void del_member(SceNpMatching2RoomId room_id, SceNpMatching2RoomMemberId member_id); void update_password(SceNpMatching2RoomId room_id, const std::optional& password); std::pair> get_slots(SceNpMatching2RoomId room_id); std::pair> get_memberids(u64 room_id, s32 sort_method); std::pair> get_password(SceNpMatching2RoomId room_id); error_code get_member_and_attrs(SceNpMatching2RoomId room_id, SceNpMatching2RoomMemberId member_id, const std::vector& binattrs_list, SceNpMatching2RoomMemberDataInternal* ptr_member, u32 addr_data, u32 size_data); private: shared_mutex mutex; std::map rooms; }; } // namespace np