mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-07-10 01:34:42 -06:00
Matching2P9 (#4678)
getuserinfolist, getroommemberdataexternallist, getroomdataexternalist, setuserinfo
This commit is contained in:
parent
db43acc4f9
commit
8f4d05fe1b
@ -1626,7 +1626,7 @@ static u32 FillRankArrayFromProto(const shadnet::GetScoreResponse& resp,
|
||||
void NpHandler::OnAsyncReply(s32 user_id, ShadNet::CommandType cmd, u64 pkt_id,
|
||||
ShadNet::ErrorType error, const std::vector<u8>& body) {
|
||||
const auto cmd_val = static_cast<u16>(cmd);
|
||||
if (cmd_val >= 12 && cmd_val <= 24) {
|
||||
if (cmd_val >= 12 && cmd_val <= 26) {
|
||||
NpMatching2::OnMatchingReply(cmd, pkt_id, error, body);
|
||||
} else {
|
||||
OnScoreReply(user_id, cmd, pkt_id, error, body);
|
||||
|
||||
@ -441,8 +441,9 @@ int PS4_SYSV_ABI sceNpMatching2SetUserInfo(OrbisNpMatching2ContextId ctxId,
|
||||
}
|
||||
|
||||
StoreRequestCallback(ctx, requestOpt);
|
||||
*requestId = AllocRequestId();
|
||||
LOG_WARNING(Lib_NpMatching2, "not implemented");
|
||||
const OrbisNpMatching2RequestId reqId = AllocRequestId();
|
||||
*requestId = reqId;
|
||||
MmSetUserInfo(ctxId, reqId, *request);
|
||||
return ORBIS_OK;
|
||||
}
|
||||
|
||||
@ -756,8 +757,30 @@ int PS4_SYSV_ABI sceNpMatching2GetRoomDataInternal(
|
||||
return ORBIS_OK;
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI sceNpMatching2GetRoomMemberDataExternalList() {
|
||||
LOG_INFO(Lib_NpMatching2, "called");
|
||||
int PS4_SYSV_ABI sceNpMatching2GetRoomMemberDataExternalList(
|
||||
OrbisNpMatching2ContextId ctxId, OrbisNpMatching2GetRoomMemberDataExternalListRequest* request,
|
||||
OrbisNpMatching2RequestOptParam* requestOpt, OrbisNpMatching2RequestId* requestId) {
|
||||
LOG_INFO(Lib_NpMatching2, "called, ctxId = {}, requestOpt = {}", ctxId, fmt::ptr(requestOpt));
|
||||
|
||||
if (!IsInitialized()) {
|
||||
LOG_ERROR(Lib_NpMatching2, "not initialized");
|
||||
return ORBIS_NP_MATCHING2_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
if (!request || !requestId) {
|
||||
LOG_ERROR(Lib_NpMatching2, "request or requestId null");
|
||||
return ORBIS_NP_MATCHING2_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
ContextObject* ctx = ContextManager::Instance().Get(ctxId);
|
||||
if (!ctx) {
|
||||
LOG_ERROR(Lib_NpMatching2, "invalid context id");
|
||||
return ORBIS_NP_MATCHING2_ERROR_INVALID_CONTEXT_ID;
|
||||
}
|
||||
|
||||
StoreRequestCallback(ctx, requestOpt);
|
||||
const OrbisNpMatching2RequestId reqId = AllocRequestId();
|
||||
*requestId = reqId;
|
||||
MmGetRoomMemberDataExternalList(ctxId, reqId, *request, ctx->a_variant);
|
||||
return ORBIS_OK;
|
||||
}
|
||||
|
||||
@ -766,13 +789,59 @@ int PS4_SYSV_ABI sceNpMatching2GetRoomMemberDataInternal() {
|
||||
return ORBIS_OK;
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI sceNpMatching2GetUserInfoListA() {
|
||||
LOG_INFO(Lib_NpMatching2, "called");
|
||||
int PS4_SYSV_ABI sceNpMatching2GetUserInfoListA(OrbisNpMatching2ContextId ctxId,
|
||||
OrbisNpMatching2GetUserInfoListRequest* request,
|
||||
OrbisNpMatching2RequestOptParam* requestOpt,
|
||||
OrbisNpMatching2RequestId* requestId) {
|
||||
LOG_INFO(Lib_NpMatching2, "called, ctxId = {}, requestOpt = {}", ctxId, fmt::ptr(requestOpt));
|
||||
|
||||
if (!IsInitialized()) {
|
||||
LOG_ERROR(Lib_NpMatching2, "not initialized");
|
||||
return ORBIS_NP_MATCHING2_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
if (!request || !requestId) {
|
||||
LOG_ERROR(Lib_NpMatching2, "request or requestId null");
|
||||
return ORBIS_NP_MATCHING2_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
ContextObject* ctx = ContextManager::Instance().Get(ctxId);
|
||||
if (!ctx) {
|
||||
LOG_ERROR(Lib_NpMatching2, "invalid context id");
|
||||
return ORBIS_NP_MATCHING2_ERROR_INVALID_CONTEXT_ID;
|
||||
}
|
||||
|
||||
StoreRequestCallback(ctx, requestOpt);
|
||||
const OrbisNpMatching2RequestId reqId = AllocRequestId();
|
||||
*requestId = reqId;
|
||||
MmGetUserInfoList(ctxId, reqId, *request, true);
|
||||
return ORBIS_OK;
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI sceNpMatching2GetUserInfoList() {
|
||||
LOG_INFO(Lib_NpMatching2, "called");
|
||||
int PS4_SYSV_ABI sceNpMatching2GetUserInfoList(OrbisNpMatching2ContextId ctxId,
|
||||
OrbisNpMatching2GetUserInfoListRequest* request,
|
||||
OrbisNpMatching2RequestOptParam* requestOpt,
|
||||
OrbisNpMatching2RequestId* requestId) {
|
||||
LOG_INFO(Lib_NpMatching2, "called, ctxId = {}, requestOpt = {}", ctxId, fmt::ptr(requestOpt));
|
||||
|
||||
if (!IsInitialized()) {
|
||||
LOG_ERROR(Lib_NpMatching2, "not initialized");
|
||||
return ORBIS_NP_MATCHING2_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
if (!request || !requestId) {
|
||||
LOG_ERROR(Lib_NpMatching2, "request or requestId null");
|
||||
return ORBIS_NP_MATCHING2_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
ContextObject* ctx = ContextManager::Instance().Get(ctxId);
|
||||
if (!ctx) {
|
||||
LOG_ERROR(Lib_NpMatching2, "invalid context id");
|
||||
return ORBIS_NP_MATCHING2_ERROR_INVALID_CONTEXT_ID;
|
||||
}
|
||||
|
||||
StoreRequestCallback(ctx, requestOpt);
|
||||
const OrbisNpMatching2RequestId reqId = AllocRequestId();
|
||||
*requestId = reqId;
|
||||
MmGetUserInfoList(ctxId, reqId, *request, ctx->a_variant);
|
||||
return ORBIS_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -788,6 +788,168 @@ void* BuildGetRoomDataExternalListPayloadA(ContextObject& ctx,
|
||||
return p.request_data;
|
||||
}
|
||||
|
||||
void* BuildGetRoomMemberDataExternalListPayload(
|
||||
ContextObject& ctx, const shadnet::GetRoomMemberDataExternalListReply& resp) {
|
||||
CallbackPayload& p = ctx.request_payload;
|
||||
p.Reset();
|
||||
|
||||
const int member_count = resp.members_size();
|
||||
p.member_data_external.resize(member_count);
|
||||
for (int i = 0; i < member_count; ++i) {
|
||||
const auto& src = resp.members(i);
|
||||
auto& dst = p.member_data_external[i];
|
||||
dst = OrbisNpMatching2RoomMemberDataExternal{};
|
||||
dst.next = (i + 1 < member_count) ? &p.member_data_external[i + 1] : nullptr;
|
||||
std::strncpy(dst.npId.handle.data, src.npid().c_str(), sizeof(dst.npId.handle.data) - 1);
|
||||
dst.joinDate.tick = src.join_date();
|
||||
dst.role = static_cast<OrbisNpMatching2Role>(src.role());
|
||||
}
|
||||
|
||||
p.room_member_data_external_list_response =
|
||||
std::make_unique<OrbisNpMatching2GetRoomMemberDataExternalListResponse>();
|
||||
auto& out = *p.room_member_data_external_list_response;
|
||||
out = OrbisNpMatching2GetRoomMemberDataExternalListResponse{};
|
||||
out.roomMemberDataExternal =
|
||||
p.member_data_external.empty() ? nullptr : p.member_data_external.data();
|
||||
out.roomMemberDataExternalNum = static_cast<u64>(p.member_data_external.size());
|
||||
|
||||
p.request_data = p.room_member_data_external_list_response.get();
|
||||
return p.request_data;
|
||||
}
|
||||
|
||||
void* BuildGetRoomMemberDataExternalListPayloadA(
|
||||
ContextObject& ctx, const shadnet::GetRoomMemberDataExternalListReply& resp) {
|
||||
CallbackPayload& p = ctx.request_payload;
|
||||
p.Reset();
|
||||
|
||||
const int member_count = resp.members_size();
|
||||
p.member_data_external_a.resize(member_count);
|
||||
for (int i = 0; i < member_count; ++i) {
|
||||
const auto& src = resp.members(i);
|
||||
auto& dst = p.member_data_external_a[i];
|
||||
dst = OrbisNpMatching2RoomMemberDataExternalA{};
|
||||
dst.next = (i + 1 < member_count) ? &p.member_data_external_a[i + 1] : nullptr;
|
||||
dst.user.accountId = static_cast<Libraries::Np::OrbisNpAccountId>(src.account_id());
|
||||
dst.user.platform = static_cast<Libraries::Np::OrbisNpPlatformType>(src.platform());
|
||||
std::strncpy(dst.onlineId.data, src.npid().c_str(), sizeof(dst.onlineId.data) - 1);
|
||||
dst.joinDate.tick = src.join_date();
|
||||
dst.role = static_cast<OrbisNpMatching2Role>(src.role());
|
||||
}
|
||||
|
||||
p.room_member_data_external_list_response_a =
|
||||
std::make_unique<OrbisNpMatching2GetRoomMemberDataExternalListResponseA>();
|
||||
auto& out = *p.room_member_data_external_list_response_a;
|
||||
out = OrbisNpMatching2GetRoomMemberDataExternalListResponseA{};
|
||||
out.roomMemberDataExternal =
|
||||
p.member_data_external_a.empty() ? nullptr : p.member_data_external_a.data();
|
||||
out.roomMemberDataExternalNum = static_cast<u64>(p.member_data_external_a.size());
|
||||
|
||||
p.request_data = p.room_member_data_external_list_response_a.get();
|
||||
return p.request_data;
|
||||
}
|
||||
|
||||
void* BuildGetUserInfoListPayload(ContextObject& ctx, const shadnet::GetUserInfoListReply& resp) {
|
||||
CallbackPayload& p = ctx.request_payload;
|
||||
p.Reset();
|
||||
|
||||
size_t total_bin_attrs = 0;
|
||||
for (int i = 0; i < resp.users_size(); ++i) {
|
||||
total_bin_attrs += static_cast<size_t>(resp.users(i).user_bin_attrs_size());
|
||||
}
|
||||
p.user_bin_attrs.reserve(total_bin_attrs);
|
||||
p.bin_buffers.reserve(total_bin_attrs);
|
||||
|
||||
const int user_count = resp.users_size();
|
||||
p.user_info.resize(user_count);
|
||||
for (int i = 0; i < user_count; ++i) {
|
||||
const auto& u = resp.users(i);
|
||||
auto& dst = p.user_info[i];
|
||||
dst = OrbisNpMatching2UserInfo{};
|
||||
dst.next = (i + 1 < user_count) ? &p.user_info[i + 1] : nullptr;
|
||||
std::strncpy(dst.npId.handle.data, u.npid().c_str(), sizeof(dst.npId.handle.data) - 1);
|
||||
|
||||
if (u.user_bin_attrs_size() > 0) {
|
||||
OrbisNpMatching2BinAttr* first = nullptr;
|
||||
for (int a = 0; a < u.user_bin_attrs_size(); ++a) {
|
||||
const auto& src = u.user_bin_attrs(a);
|
||||
p.bin_buffers.emplace_back(src.data().begin(), src.data().end());
|
||||
auto& buf = p.bin_buffers.back();
|
||||
auto& ba = p.user_bin_attrs.emplace_back();
|
||||
ba = OrbisNpMatching2BinAttr{};
|
||||
ba.id = static_cast<OrbisNpMatching2AttributeId>(src.attr_id());
|
||||
ba.data = buf.empty() ? nullptr : buf.data();
|
||||
ba.dataSize = buf.size();
|
||||
if (!first) {
|
||||
first = &ba;
|
||||
}
|
||||
}
|
||||
dst.userBinAttr = first;
|
||||
dst.userBinAttrNum = static_cast<u64>(u.user_bin_attrs_size());
|
||||
}
|
||||
}
|
||||
|
||||
p.user_info_list_response = std::make_unique<OrbisNpMatching2GetUserInfoListResponse>();
|
||||
auto& out = *p.user_info_list_response;
|
||||
out = OrbisNpMatching2GetUserInfoListResponse{};
|
||||
out.userInfo = p.user_info.empty() ? nullptr : p.user_info.data();
|
||||
out.userInfoNum = static_cast<u64>(p.user_info.size());
|
||||
|
||||
p.request_data = p.user_info_list_response.get();
|
||||
return p.request_data;
|
||||
}
|
||||
|
||||
void* BuildGetUserInfoListPayloadA(ContextObject& ctx, const shadnet::GetUserInfoListReply& resp) {
|
||||
CallbackPayload& p = ctx.request_payload;
|
||||
p.Reset();
|
||||
|
||||
size_t total_bin_attrs = 0;
|
||||
for (int i = 0; i < resp.users_size(); ++i) {
|
||||
total_bin_attrs += static_cast<size_t>(resp.users(i).user_bin_attrs_size());
|
||||
}
|
||||
p.user_bin_attrs.reserve(total_bin_attrs);
|
||||
p.bin_buffers.reserve(total_bin_attrs);
|
||||
|
||||
const int user_count = resp.users_size();
|
||||
p.user_info_a.resize(user_count);
|
||||
for (int i = 0; i < user_count; ++i) {
|
||||
const auto& u = resp.users(i);
|
||||
auto& dst = p.user_info_a[i];
|
||||
dst = OrbisNpMatching2UserInfoA{};
|
||||
dst.next = (i + 1 < user_count) ? &p.user_info_a[i + 1] : nullptr;
|
||||
std::strncpy(dst.userOnlineId.data, u.npid().c_str(), sizeof(dst.userOnlineId.data) - 1);
|
||||
dst.user.accountId = static_cast<Libraries::Np::OrbisNpAccountId>(u.account_id());
|
||||
dst.user.platform = static_cast<Libraries::Np::OrbisNpPlatformType>(u.platform());
|
||||
|
||||
if (u.user_bin_attrs_size() > 0) {
|
||||
OrbisNpMatching2BinAttr* first = nullptr;
|
||||
for (int a = 0; a < u.user_bin_attrs_size(); ++a) {
|
||||
const auto& src = u.user_bin_attrs(a);
|
||||
p.bin_buffers.emplace_back(src.data().begin(), src.data().end());
|
||||
auto& buf = p.bin_buffers.back();
|
||||
auto& ba = p.user_bin_attrs.emplace_back();
|
||||
ba = OrbisNpMatching2BinAttr{};
|
||||
ba.id = static_cast<OrbisNpMatching2AttributeId>(src.attr_id());
|
||||
ba.data = buf.empty() ? nullptr : buf.data();
|
||||
ba.dataSize = buf.size();
|
||||
if (!first) {
|
||||
first = &ba;
|
||||
}
|
||||
}
|
||||
dst.userBinAttr = first;
|
||||
dst.userBinAttrNum = static_cast<u64>(u.user_bin_attrs_size());
|
||||
}
|
||||
}
|
||||
|
||||
p.user_info_list_response_a = std::make_unique<OrbisNpMatching2GetUserInfoListResponseA>();
|
||||
auto& out = *p.user_info_list_response_a;
|
||||
out = OrbisNpMatching2GetUserInfoListResponseA{};
|
||||
out.userInfo = p.user_info_a.empty() ? nullptr : p.user_info_a.data();
|
||||
out.userInfoNum = static_cast<u64>(p.user_info_a.size());
|
||||
|
||||
p.request_data = p.user_info_list_response_a.get();
|
||||
return p.request_data;
|
||||
}
|
||||
|
||||
void* BuildGetRoomDataInternalPayload(ContextObject& ctx, OrbisNpMatching2RoomId room_id) {
|
||||
const auto rc_it = ctx.room_cache.find(room_id);
|
||||
if (rc_it == ctx.room_cache.end()) {
|
||||
|
||||
@ -22,6 +22,8 @@ namespace shadnet {
|
||||
class CreateJoinRoomResponse;
|
||||
class GetWorldInfoListReply;
|
||||
class GetRoomDataExternalListReply;
|
||||
class GetRoomMemberDataExternalListReply;
|
||||
class GetUserInfoListReply;
|
||||
class LeaveRoomReply;
|
||||
class SearchRoomReply;
|
||||
} // namespace shadnet
|
||||
@ -100,11 +102,19 @@ struct CallbackPayload {
|
||||
room_data_external_list_response;
|
||||
std::unique_ptr<OrbisNpMatching2GetRoomDataExternalListResponseA>
|
||||
room_data_external_list_response_a;
|
||||
std::unique_ptr<OrbisNpMatching2GetRoomMemberDataExternalListResponse>
|
||||
room_member_data_external_list_response;
|
||||
std::unique_ptr<OrbisNpMatching2GetRoomMemberDataExternalListResponseA>
|
||||
room_member_data_external_list_response_a;
|
||||
std::unique_ptr<OrbisNpMatching2GetUserInfoListResponse> user_info_list_response;
|
||||
std::unique_ptr<OrbisNpMatching2GetUserInfoListResponseA> user_info_list_response_a;
|
||||
std::unique_ptr<OrbisNpMatching2GetWorldInfoListResponse> world_info_response;
|
||||
std::unique_ptr<OrbisNpMatching2SignalingGetPingInfoResponse> ping_info_response;
|
||||
std::vector<OrbisNpMatching2World> world_list;
|
||||
std::vector<OrbisNpMatching2RoomMemberDataInternal> member_data;
|
||||
std::vector<OrbisNpMatching2RoomMemberDataInternalA> member_data_a;
|
||||
std::vector<OrbisNpMatching2RoomMemberDataExternal> member_data_external;
|
||||
std::vector<OrbisNpMatching2RoomMemberDataExternalA> member_data_external_a;
|
||||
std::vector<OrbisNpMatching2RoomGroup> room_groups;
|
||||
std::vector<OrbisNpMatching2RoomGroup*> room_group_ptrs;
|
||||
std::vector<OrbisNpMatching2RoomBinAttrInternal> room_bin_attrs;
|
||||
@ -112,6 +122,9 @@ struct CallbackPayload {
|
||||
std::vector<OrbisNpMatching2RoomMemberBinAttrInternal> member_bin_attrs;
|
||||
std::vector<OrbisNpMatching2RoomDataExternal> room_data_external;
|
||||
std::vector<OrbisNpMatching2RoomDataExternalA> room_data_external_a;
|
||||
std::vector<OrbisNpMatching2UserInfo> user_info;
|
||||
std::vector<OrbisNpMatching2UserInfoA> user_info_a;
|
||||
std::vector<OrbisNpMatching2BinAttr> user_bin_attrs;
|
||||
std::vector<std::vector<u8>> bin_buffers;
|
||||
std::vector<OrbisNpMatching2IntAttr> ext_int_attrs;
|
||||
std::vector<OrbisNpMatching2BinAttr> ext_bin_attrs;
|
||||
@ -146,11 +159,17 @@ struct CallbackPayload {
|
||||
search_room_response_a.reset();
|
||||
room_data_external_list_response.reset();
|
||||
room_data_external_list_response_a.reset();
|
||||
room_member_data_external_list_response.reset();
|
||||
room_member_data_external_list_response_a.reset();
|
||||
user_info_list_response.reset();
|
||||
user_info_list_response_a.reset();
|
||||
world_info_response.reset();
|
||||
ping_info_response.reset();
|
||||
world_list.clear();
|
||||
member_data.clear();
|
||||
member_data_a.clear();
|
||||
member_data_external.clear();
|
||||
member_data_external_a.clear();
|
||||
room_groups.clear();
|
||||
room_group_ptrs.clear();
|
||||
room_bin_attrs.clear();
|
||||
@ -158,6 +177,9 @@ struct CallbackPayload {
|
||||
member_bin_attrs.clear();
|
||||
room_data_external.clear();
|
||||
room_data_external_a.clear();
|
||||
user_info.clear();
|
||||
user_info_a.clear();
|
||||
user_bin_attrs.clear();
|
||||
bin_buffers.clear();
|
||||
ext_int_attrs.clear();
|
||||
ext_bin_attrs.clear();
|
||||
@ -371,6 +393,12 @@ void* BuildGetRoomDataExternalListPayload(ContextObject& ctx,
|
||||
const shadnet::GetRoomDataExternalListReply& resp);
|
||||
void* BuildGetRoomDataExternalListPayloadA(ContextObject& ctx,
|
||||
const shadnet::GetRoomDataExternalListReply& resp);
|
||||
void* BuildGetRoomMemberDataExternalListPayload(
|
||||
ContextObject& ctx, const shadnet::GetRoomMemberDataExternalListReply& resp);
|
||||
void* BuildGetRoomMemberDataExternalListPayloadA(
|
||||
ContextObject& ctx, const shadnet::GetRoomMemberDataExternalListReply& resp);
|
||||
void* BuildGetUserInfoListPayload(ContextObject& ctx, const shadnet::GetUserInfoListReply& resp);
|
||||
void* BuildGetUserInfoListPayloadA(ContextObject& ctx, const shadnet::GetUserInfoListReply& resp);
|
||||
void* BuildGetRoomDataInternalPayload(ContextObject& ctx, OrbisNpMatching2RoomId room_id);
|
||||
|
||||
void InitEventDispatcher();
|
||||
|
||||
@ -204,6 +204,22 @@ void DispatchRequestComplete(const PendingRequest& pr, ShadNet::ErrorType error,
|
||||
request_data = pr.a_variant ? BuildGetRoomDataExternalListPayloadA(*ctx, reply)
|
||||
: BuildGetRoomDataExternalListPayload(*ctx, reply);
|
||||
}
|
||||
} else if (pr.req_event ==
|
||||
ORBIS_NP_MATCHING2_REQUEST_EVENT_GET_ROOM_MEMBER_DATA_EXTERNAL_LIST ||
|
||||
pr.req_event ==
|
||||
ORBIS_NP_MATCHING2_REQUEST_EVENT_GET_ROOM_MEMBER_DATA_EXTERNAL_LIST_A) {
|
||||
shadnet::GetRoomMemberDataExternalListReply reply;
|
||||
if (reply.ParseFromString(proto)) {
|
||||
request_data = pr.a_variant
|
||||
? BuildGetRoomMemberDataExternalListPayloadA(*ctx, reply)
|
||||
: BuildGetRoomMemberDataExternalListPayload(*ctx, reply);
|
||||
}
|
||||
} else if (pr.req_event == ORBIS_NP_MATCHING2_REQUEST_EVENT_GET_USER_INFO_LIST) {
|
||||
shadnet::GetUserInfoListReply reply;
|
||||
if (reply.ParseFromString(proto)) {
|
||||
request_data = pr.a_variant ? BuildGetUserInfoListPayloadA(*ctx, reply)
|
||||
: BuildGetUserInfoListPayload(*ctx, reply);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -222,7 +238,6 @@ void DispatchRequestComplete(const PendingRequest& pr, ShadNet::ErrorType error,
|
||||
if (error_code == 0 && (pr.req_event == ORBIS_NP_MATCHING2_REQUEST_EVENT_JOIN_ROOM ||
|
||||
pr.req_event == ORBIS_NP_MATCHING2_REQUEST_EVENT_JOIN_ROOM_A)) {
|
||||
StartMatching2SignalingForRoomPeers(*ctx, ctx->room_id);
|
||||
QueueMatching2EstablishedForRoomPeers(*ctx, ctx->room_id);
|
||||
} else if (error_code == 0 &&
|
||||
(pr.req_event == ORBIS_NP_MATCHING2_REQUEST_EVENT_CREATE_JOIN_ROOM ||
|
||||
pr.req_event == ORBIS_NP_MATCHING2_REQUEST_EVENT_CREATE_JOIN_ROOM_A)) {
|
||||
@ -534,7 +549,6 @@ void HandleRoomEvent(const ShadNet::NotifyRoomEvent& n) {
|
||||
|
||||
if (event == ORBIS_NP_MATCHING2_ROOM_EVENT_MEMBER_JOINED) {
|
||||
StartMatching2PeerHandshake(*ctx, room_id, member_id);
|
||||
QueueMatching2EstablishedForRoomPeers(*ctx, room_id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -900,6 +914,48 @@ s32 MmGetRoomDataExternalList(OrbisNpMatching2ContextId ctx_id, OrbisNpMatching2
|
||||
MmCommand::GetRoomDataExternalList, MakeProtoPayload(req), a_variant);
|
||||
}
|
||||
|
||||
s32 MmGetRoomMemberDataExternalList(
|
||||
OrbisNpMatching2ContextId ctx_id, OrbisNpMatching2RequestId req_id,
|
||||
const OrbisNpMatching2GetRoomMemberDataExternalListRequest& request, bool a_variant) {
|
||||
shadnet::GetRoomMemberDataExternalListRequest req;
|
||||
req.set_room_id(request.roomId);
|
||||
LOG_DEBUG(Lib_NpMatching2, "getRoomMemberDataExternalList room={}", request.roomId);
|
||||
return MmSubmitRequest(
|
||||
ctx_id, req_id,
|
||||
a_variant ? ORBIS_NP_MATCHING2_REQUEST_EVENT_GET_ROOM_MEMBER_DATA_EXTERNAL_LIST_A
|
||||
: ORBIS_NP_MATCHING2_REQUEST_EVENT_GET_ROOM_MEMBER_DATA_EXTERNAL_LIST,
|
||||
MmCommand::GetRoomMemberDataExternalList, MakeProtoPayload(req), a_variant);
|
||||
}
|
||||
|
||||
s32 MmGetUserInfoList(OrbisNpMatching2ContextId ctx_id, OrbisNpMatching2RequestId req_id,
|
||||
const OrbisNpMatching2GetUserInfoListRequest& request, bool a_variant) {
|
||||
shadnet::GetUserInfoListRequest req;
|
||||
for (u64 i = 0; i < request.npIdNum; ++i) {
|
||||
req.add_npids(request.npId[i].handle.data);
|
||||
}
|
||||
for (u64 i = 0; i < request.attrIdNum; ++i) {
|
||||
req.add_attr_ids(request.attrId[i]);
|
||||
}
|
||||
req.set_option(request.option);
|
||||
LOG_DEBUG(Lib_NpMatching2, "getUserInfoList npN={} attrN={}", request.npIdNum,
|
||||
request.attrIdNum);
|
||||
return MmSubmitRequest(ctx_id, req_id, ORBIS_NP_MATCHING2_REQUEST_EVENT_GET_USER_INFO_LIST,
|
||||
MmCommand::GetUserInfoList, MakeProtoPayload(req), a_variant);
|
||||
}
|
||||
|
||||
s32 MmSetUserInfo(OrbisNpMatching2ContextId ctx_id, OrbisNpMatching2RequestId req_id,
|
||||
const OrbisNpMatching2SetUserInfoRequest& request) {
|
||||
shadnet::SetUserInfoRequest req;
|
||||
req.set_server_id(request.serverId);
|
||||
for (u64 i = 0; request.userBinAttr && i < request.userBinAttrs; ++i) {
|
||||
AppendBinAttr(req.add_user_bin_attrs(), request.userBinAttr[i]);
|
||||
}
|
||||
LOG_DEBUG(Lib_NpMatching2, "setUserInfo server={} binAttrs={}", request.serverId,
|
||||
request.userBinAttrs);
|
||||
return MmSubmitRequest(ctx_id, req_id, ORBIS_NP_MATCHING2_REQUEST_EVENT_SET_USER_INFO,
|
||||
MmCommand::SetUserInfo, MakeProtoPayload(req));
|
||||
}
|
||||
|
||||
s32 MmSetRoomDataInternal(OrbisNpMatching2ContextId ctx_id, OrbisNpMatching2RequestId req_id,
|
||||
const OrbisNpMatching2SetRoomDataInternalRequest& request) {
|
||||
shadnet::SetRoomDataInternalRequest req;
|
||||
|
||||
@ -26,11 +26,14 @@ enum class MmCommand : u16 {
|
||||
SearchRoom = 16,
|
||||
RequestSignalingInfos = 17,
|
||||
ContextStop = 18,
|
||||
SetUserInfo = 19,
|
||||
SetRoomDataInternal = 20,
|
||||
SetRoomDataExternal = 21,
|
||||
KickoutRoomMember = 22,
|
||||
GetWorldInfoList = 23,
|
||||
GetRoomDataExternalList = 24,
|
||||
GetUserInfoList = 25,
|
||||
GetRoomMemberDataExternalList = 26,
|
||||
};
|
||||
|
||||
void SetMmShadNetClient(std::shared_ptr<ShadNet::ShadNetClient> client,
|
||||
@ -65,6 +68,14 @@ s32 MmSearchRoom(OrbisNpMatching2ContextId ctx_id, OrbisNpMatching2RequestId req
|
||||
s32 MmGetRoomDataExternalList(OrbisNpMatching2ContextId ctx_id, OrbisNpMatching2RequestId req_id,
|
||||
const OrbisNpMatching2GetRoomDataExternalListRequest& request,
|
||||
bool a_variant = false);
|
||||
s32 MmGetRoomMemberDataExternalList(
|
||||
OrbisNpMatching2ContextId ctx_id, OrbisNpMatching2RequestId req_id,
|
||||
const OrbisNpMatching2GetRoomMemberDataExternalListRequest& request, bool a_variant = false);
|
||||
s32 MmGetUserInfoList(OrbisNpMatching2ContextId ctx_id, OrbisNpMatching2RequestId req_id,
|
||||
const OrbisNpMatching2GetUserInfoListRequest& request,
|
||||
bool a_variant = false);
|
||||
s32 MmSetUserInfo(OrbisNpMatching2ContextId ctx_id, OrbisNpMatching2RequestId req_id,
|
||||
const OrbisNpMatching2SetUserInfoRequest& request);
|
||||
s32 MmSetRoomDataInternal(OrbisNpMatching2ContextId ctx_id, OrbisNpMatching2RequestId req_id,
|
||||
const OrbisNpMatching2SetRoomDataInternalRequest& request);
|
||||
s32 MmSetRoomDataExternal(OrbisNpMatching2ContextId ctx_id, OrbisNpMatching2RequestId req_id,
|
||||
|
||||
@ -416,20 +416,6 @@ void StartMatching2SignalingForRoomPeers(ContextObject& ctx, OrbisNpMatching2Roo
|
||||
}
|
||||
}
|
||||
|
||||
void QueueMatching2EstablishedForRoomPeers(ContextObject& ctx, OrbisNpMatching2RoomId room_id) {
|
||||
const auto room_it = ctx.room_cache.find(room_id);
|
||||
if (room_it == ctx.room_cache.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto& [member_id, member] : room_it->second.members) {
|
||||
if (member_id == 0 || member_id == ctx.my_member_id) {
|
||||
continue;
|
||||
}
|
||||
MarkMatching2PeerActive(ctx, room_id, member_id, member.addr, member.port);
|
||||
}
|
||||
}
|
||||
|
||||
void QueueMatching2DeadForRoomPeers(ContextObject& ctx, OrbisNpMatching2RoomId room_id,
|
||||
s32 error_code) {
|
||||
auto room_it = ctx.room_cache.find(room_id);
|
||||
|
||||
@ -18,7 +18,6 @@ bool SendMatching2StunPing(const ContextObject& ctx);
|
||||
void StartMatching2PeerHandshake(ContextObject& ctx, OrbisNpMatching2RoomId room_id,
|
||||
OrbisNpMatching2RoomMemberId member_id);
|
||||
void StartMatching2SignalingForRoomPeers(ContextObject& ctx, OrbisNpMatching2RoomId room_id);
|
||||
void QueueMatching2EstablishedForRoomPeers(ContextObject& ctx, OrbisNpMatching2RoomId room_id);
|
||||
void QueueMatching2DeadForRoomPeers(ContextObject& ctx, OrbisNpMatching2RoomId room_id,
|
||||
s32 error_code);
|
||||
void QueueMatching2SignalingEvent(ContextObject& ctx, OrbisNpMatching2RoomId room_id,
|
||||
|
||||
@ -36,6 +36,7 @@ using OrbisNpMatching2RoomId = u64;
|
||||
using OrbisNpMatching2RoomMemberId = u16;
|
||||
using OrbisNpMatching2RoomPasswordSlotMask = u64;
|
||||
using OrbisNpMatching2ServerId = u16;
|
||||
using OrbisNpMatching2SessionType = u8;
|
||||
using OrbisNpMatching2SignalingFlag = u8;
|
||||
using OrbisNpMatching2SignalingRequestId = u32;
|
||||
using OrbisNpMatching2TeamId = u8;
|
||||
@ -44,9 +45,11 @@ using OrbisNpMatching2WorldId = u32;
|
||||
// Event of request/room/signaling/context functions
|
||||
enum OrbisNpMatching2Event : u16 {
|
||||
ORBIS_NP_MATCHING2_REQUEST_EVENT_GET_WORLD_INFO_LIST = 0x0002,
|
||||
ORBIS_NP_MATCHING2_REQUEST_EVENT_GET_ROOM_MEMBER_DATA_EXTERNAL_LIST = 0x0003,
|
||||
ORBIS_NP_MATCHING2_REQUEST_EVENT_SET_ROOM_DATA_EXTERNAL = 0x0004,
|
||||
ORBIS_NP_MATCHING2_REQUEST_EVENT_GET_ROOM_DATA_EXTERNAL_LIST = 0x0005,
|
||||
ORBIS_NP_MATCHING2_REQUEST_EVENT_SET_USER_INFO = 0x0007,
|
||||
ORBIS_NP_MATCHING2_REQUEST_EVENT_GET_USER_INFO_LIST = 0x0008,
|
||||
ORBIS_NP_MATCHING2_REQUEST_EVENT_CREATE_JOIN_ROOM = 0x0101,
|
||||
ORBIS_NP_MATCHING2_REQUEST_EVENT_JOIN_ROOM = 0x0102,
|
||||
ORBIS_NP_MATCHING2_REQUEST_EVENT_LEAVE_ROOM = 0x0103,
|
||||
@ -74,6 +77,7 @@ enum OrbisNpMatching2Event : u16 {
|
||||
ORBIS_NP_MATCHING2_CONTEXT_EVENT_STOPPED = 0x6F03,
|
||||
ORBIS_NP_MATCHING2_REQUEST_EVENT_CREATE_JOIN_ROOM_A = 0x7101,
|
||||
ORBIS_NP_MATCHING2_REQUEST_EVENT_JOIN_ROOM_A = 0x7102,
|
||||
ORBIS_NP_MATCHING2_REQUEST_EVENT_GET_ROOM_MEMBER_DATA_EXTERNAL_LIST_A = 0x7003,
|
||||
ORBIS_NP_MATCHING2_REQUEST_EVENT_GET_ROOM_DATA_EXTERNAL_LIST_A = 0x7005,
|
||||
ORBIS_NP_MATCHING2_REQUEST_EVENT_SEARCH_ROOM_A = 0x7106,
|
||||
ORBIS_NP_MATCHING2_ROOM_EVENT_MEMBER_JOINED_A = 0x8101,
|
||||
@ -456,6 +460,25 @@ struct OrbisNpMatching2RoomMemberDataInternalListA {
|
||||
OrbisNpMatching2RoomMemberDataInternalA* owner;
|
||||
};
|
||||
|
||||
// Room-external room member information
|
||||
struct OrbisNpMatching2RoomMemberDataExternal {
|
||||
OrbisNpMatching2RoomMemberDataExternal* next;
|
||||
Libraries::Np::OrbisNpId npId;
|
||||
Libraries::Rtc::OrbisRtcTick joinDate;
|
||||
OrbisNpMatching2Role role;
|
||||
u8 padding[7];
|
||||
};
|
||||
|
||||
// Room-external room member information (account-id variant)
|
||||
struct OrbisNpMatching2RoomMemberDataExternalA {
|
||||
OrbisNpMatching2RoomMemberDataExternalA* next;
|
||||
Libraries::Np::OrbisNpPeerAddressA user;
|
||||
Libraries::Np::OrbisNpOnlineId onlineId;
|
||||
Libraries::Rtc::OrbisRtcTick joinDate;
|
||||
OrbisNpMatching2Role role;
|
||||
u8 padding[7];
|
||||
};
|
||||
|
||||
// Initialization parameter
|
||||
struct OrbisNpMatching2InitializeParameter {
|
||||
u64 poolSize;
|
||||
@ -689,6 +712,23 @@ struct OrbisNpMatching2GetRoomDataExternalListResponseA {
|
||||
u64 roomDataExternalNum;
|
||||
};
|
||||
|
||||
// GetRoomMemberDataExternalList request
|
||||
struct OrbisNpMatching2GetRoomMemberDataExternalListRequest {
|
||||
OrbisNpMatching2RoomId roomId;
|
||||
};
|
||||
|
||||
// GetRoomMemberDataExternalList response
|
||||
struct OrbisNpMatching2GetRoomMemberDataExternalListResponse {
|
||||
OrbisNpMatching2RoomMemberDataExternal* roomMemberDataExternal;
|
||||
u64 roomMemberDataExternalNum;
|
||||
};
|
||||
|
||||
// GetRoomMemberDataExternalList response (account-id variant)
|
||||
struct OrbisNpMatching2GetRoomMemberDataExternalListResponseA {
|
||||
OrbisNpMatching2RoomMemberDataExternalA* roomMemberDataExternal;
|
||||
u64 roomMemberDataExternalNum;
|
||||
};
|
||||
|
||||
// SetRoomDataExternal request
|
||||
struct OrbisNpMatching2SetRoomDataExternalRequest {
|
||||
OrbisNpMatching2RoomId roomId;
|
||||
@ -729,6 +769,61 @@ struct OrbisNpMatching2SetUserInfoRequest {
|
||||
u64 userBinAttrs;
|
||||
};
|
||||
|
||||
// Session a user is currently joined to
|
||||
struct OrbisNpMatching2JoinedSessionInfo {
|
||||
OrbisNpMatching2SessionType sessionType;
|
||||
u8 padding[1];
|
||||
OrbisNpMatching2ServerId serverId;
|
||||
OrbisNpMatching2WorldId worldId;
|
||||
OrbisNpMatching2LobbyId lobbyId;
|
||||
OrbisNpMatching2RoomId roomId;
|
||||
Libraries::Rtc::OrbisRtcTick joinDate;
|
||||
};
|
||||
|
||||
// User information
|
||||
struct OrbisNpMatching2UserInfo {
|
||||
OrbisNpMatching2UserInfo* next;
|
||||
Libraries::Np::OrbisNpId npId;
|
||||
OrbisNpMatching2BinAttr* userBinAttr;
|
||||
u64 userBinAttrNum;
|
||||
OrbisNpMatching2JoinedSessionInfo joinedSessionInfo;
|
||||
u64 joinedSessionInfoNum;
|
||||
};
|
||||
|
||||
// User information (account-id variant)
|
||||
struct OrbisNpMatching2UserInfoA {
|
||||
OrbisNpMatching2UserInfoA* next;
|
||||
Libraries::Np::OrbisNpPeerAddressA user;
|
||||
Libraries::Np::OrbisNpOnlineId userOnlineId;
|
||||
OrbisNpMatching2BinAttr* userBinAttr;
|
||||
u64 userBinAttrNum;
|
||||
OrbisNpMatching2JoinedSessionInfo joinedSessionInfo;
|
||||
u64 joinedSessionInfoNum;
|
||||
};
|
||||
|
||||
// GetUserInfoList request
|
||||
struct OrbisNpMatching2GetUserInfoListRequest {
|
||||
OrbisNpMatching2ServerId serverId;
|
||||
u8 padding[6];
|
||||
Libraries::Np::OrbisNpId* npId;
|
||||
u64 npIdNum;
|
||||
const OrbisNpMatching2AttributeId* attrId;
|
||||
u64 attrIdNum;
|
||||
s32 option;
|
||||
};
|
||||
|
||||
// GetUserInfoList response
|
||||
struct OrbisNpMatching2GetUserInfoListResponse {
|
||||
OrbisNpMatching2UserInfo* userInfo;
|
||||
u64 userInfoNum;
|
||||
};
|
||||
|
||||
// GetUserInfoList response (account-id variant)
|
||||
struct OrbisNpMatching2GetUserInfoListResponseA {
|
||||
OrbisNpMatching2UserInfoA* userInfo;
|
||||
u64 userInfoNum;
|
||||
};
|
||||
|
||||
// Room data internal update information
|
||||
struct OrbisNpMatching2RoomDataInternalUpdate {
|
||||
OrbisNpMatching2RoomDataInternal* chgRoomDataInternal;
|
||||
|
||||
@ -74,11 +74,14 @@ enum class CommandType : u16 {
|
||||
SearchRoom = 16,
|
||||
RequestSignalingInfos = 17,
|
||||
ContextStop = 18,
|
||||
SetUserInfo = 19,
|
||||
SetRoomDataInternal = 20,
|
||||
SetRoomDataExternal = 21,
|
||||
KickoutRoomMember = 22,
|
||||
GetWorldInfoList = 23,
|
||||
// 24-29 reserved for future matchmaking commands
|
||||
GetRoomDataExternalList = 24,
|
||||
GetUserInfoList = 25,
|
||||
GetRoomMemberDataExternalList = 26,
|
||||
GetBoardInfos = 30,
|
||||
RecordScore = 31,
|
||||
RecordScoreData = 32,
|
||||
|
||||
@ -260,6 +260,15 @@ message MatchingRoomMemberData {
|
||||
uint32 platform = 14;
|
||||
}
|
||||
|
||||
message MatchingRoomMemberDataExternal {
|
||||
string npid = 1;
|
||||
uint32 member_id = 2;
|
||||
uint64 account_id = 3;
|
||||
uint32 platform = 4;
|
||||
uint64 join_date = 5;
|
||||
uint32 role = 6;
|
||||
}
|
||||
|
||||
message MatchingRoomDataExternal {
|
||||
uint32 max_slot = 1;
|
||||
uint32 cur_members = 2;
|
||||
@ -444,6 +453,38 @@ message GetRoomDataExternalListReply {
|
||||
repeated MatchingRoomDataExternal rooms = 1;
|
||||
}
|
||||
|
||||
message GetRoomMemberDataExternalListRequest {
|
||||
uint64 room_id = 1;
|
||||
}
|
||||
|
||||
message GetRoomMemberDataExternalListReply {
|
||||
repeated MatchingRoomMemberDataExternal members = 1;
|
||||
}
|
||||
|
||||
message MatchingUserInfo {
|
||||
string npid = 1;
|
||||
uint64 account_id = 2;
|
||||
uint32 platform = 3;
|
||||
repeated MatchingBinAttr user_bin_attrs = 4;
|
||||
}
|
||||
|
||||
message SetUserInfoRequest {
|
||||
uint32 server_id = 1;
|
||||
repeated MatchingBinAttr user_bin_attrs = 2;
|
||||
}
|
||||
|
||||
message SetUserInfoReply {}
|
||||
|
||||
message GetUserInfoListRequest {
|
||||
repeated string npids = 1;
|
||||
repeated uint32 attr_ids = 2;
|
||||
int32 option = 3;
|
||||
}
|
||||
|
||||
message GetUserInfoListReply {
|
||||
repeated MatchingUserInfo users = 1;
|
||||
}
|
||||
|
||||
message MatchingWorld {
|
||||
uint32 world_id = 1;
|
||||
uint32 lobbies_num = 2;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user