From c48ecd78dbbace9d743565a7658fe5db73e6d4a9 Mon Sep 17 00:00:00 2001 From: Shingo INADA Date: Mon, 31 Jul 2023 15:46:57 +0900 Subject: [PATCH 1/2] wait gcping result --- core/gdxsv/gdxsv.cpp | 101 ++--------------------------- core/gdxsv/gdxsv.h | 4 +- core/gdxsv/gdxsv_CustomTexture.cpp | 4 +- core/gdxsv/gdxsv_network.cpp | 85 ++++++++++++++++++++++++ core/gdxsv/gdxsv_network.h | 1 + 5 files changed, 96 insertions(+), 99 deletions(-) diff --git a/core/gdxsv/gdxsv.cpp b/core/gdxsv/gdxsv.cpp index 44d0bec14..e333f02a3 100644 --- a/core/gdxsv/gdxsv.cpp +++ b/core/gdxsv/gdxsv.cpp @@ -315,20 +315,19 @@ std::vector Gdxsv::GeneratePlatformInfoPacket() { ss << "machine_id=" << std::hex << digest << std::dec << "\n"; } - if (gcp_ping_test_mutex_.try_lock()) { - for (const auto &res : gcp_ping_test_result_) { + if (gcp_ping_test_result_.valid()) { + for (const auto &res : gcp_ping_test_result_.get()) { ss << res.first << "=" << res.second << "\n"; } - gcp_ping_test_mutex_.unlock(); } - if (future_is_ready(public_ipv4_)) { + if (public_ipv4_.valid()) { if (public_ipv4_.get().first) { ss << "public_ipv4=" << public_ipv4_.get().second << "\n"; } } - if (future_is_ready(public_ipv6_)) { + if (public_ipv6_.valid()) { if (public_ipv6_.get().first) { ss << "public_ipv6=" << public_ipv6_.get().second << "\n"; } @@ -506,6 +505,8 @@ void Gdxsv::HandleRPC() { gdxsv_WriteMem32(symbols_["is_online"], netmode_ != NetMode::Offline); } +void Gdxsv::StartPingTest() { gcp_ping_test_result_ = gcp_ping_test().share(); } + void Gdxsv::FetchPublicIP() { public_ipv4_ = get_public_ip_address(false).share(); public_ipv6_ = get_public_ip_address(true).share(); @@ -550,96 +551,6 @@ void Gdxsv::NotifyWanPort() const { udp.Close(); } -void Gdxsv::StartPingTest() { - std::thread([this]() { - std::this_thread::sleep_for(std::chrono::seconds(3)); - GcpPingTest(); - }).detach(); -} - -void Gdxsv::GcpPingTest() { - std::map test_result; - - // powered by https://github.com/GoogleCloudPlatform/gcping - static const std::string get_path = "/api/ping"; - static const std::map gcp_region_hosts = { - {"asia-east1", "asia-east1-5tkroniexa-de.a.run.app"}, - {"asia-east2", "asia-east2-5tkroniexa-df.a.run.app"}, - {"asia-northeast1", "asia-northeast1-5tkroniexa-an.a.run.app"}, - {"asia-northeast2", "asia-northeast2-5tkroniexa-dt.a.run.app"}, - {"asia-northeast3", "asia-northeast3-5tkroniexa-du.a.run.app"}, - {"asia-south1", "asia-south1-5tkroniexa-el.a.run.app"}, - {"asia-southeast1", "asia-southeast1-5tkroniexa-as.a.run.app"}, - {"australia-southeast1", "australia-southeast1-5tkroniexa-ts.a.run.app"}, - {"europe-north1", "europe-north1-5tkroniexa-lz.a.run.app"}, - {"europe-west1", "europe-west1-5tkroniexa-ew.a.run.app"}, - {"europe-west2", "europe-west2-5tkroniexa-nw.a.run.app"}, - {"europe-west3", "europe-west3-5tkroniexa-ey.a.run.app"}, - {"europe-west4", "europe-west4-5tkroniexa-ez.a.run.app"}, - {"europe-west6", "europe-west6-5tkroniexa-oa.a.run.app"}, - {"northamerica-northeast1", "northamerica-northeast1-5tkroniexa-nn.a.run.app"}, - {"southamerica-east1", "southamerica-east1-5tkroniexa-rj.a.run.app"}, - {"us-central1", "us-central1-5tkroniexa-uc.a.run.app"}, - {"us-east1", "us-east1-5tkroniexa-ue.a.run.app"}, - {"us-east4", "us-east4-5tkroniexa-uk.a.run.app"}, - {"us-west1", "us-west1-5tkroniexa-uw.a.run.app"}, - {"us-west2", "us-west2-5tkroniexa-wl.a.run.app"}, - {"us-west3", "us-west3-5tkroniexa-wm.a.run.app"}, - }; - - for (const auto ®ion_host : gcp_region_hosts) { - TcpClient client; - std::stringstream ss; - ss << "HEAD " << get_path << " HTTP/1.1" - << "\r\n"; - ss << "Host: " << region_host.second << "\r\n"; - ss << "User-Agent: flycast for gdxsv" - << "\r\n"; - ss << "Accept: */*" - << "\r\n"; - ss << "\r\n"; // end of header - - if (!client.Connect(region_host.second.c_str(), 80)) { - ERROR_LOG(COMMON, "connect failed : %s", region_host.first.c_str()); - continue; - } - - auto request_header = ss.str(); - auto t1 = std::chrono::high_resolution_clock::now(); - int n = client.Send(request_header.c_str(), request_header.size()); - if (n < request_header.size()) { - ERROR_LOG(COMMON, "send failed : %s", region_host.first.c_str()); - client.Close(); - continue; - } - - char buf[1024] = {0}; - n = client.Recv(buf, 1024); - if (n <= 0) { - ERROR_LOG(COMMON, "recv failed : %s", region_host.first.c_str()); - client.Close(); - continue; - } - - auto t2 = std::chrono::high_resolution_clock::now(); - int rtt = (int)std::chrono::duration_cast(t2 - t1).count(); - const std::string response_header(buf, n); - if (response_header.find("200 OK") == std::string::npos && response_header.find("302 Found") == std::string::npos) { - ERROR_LOG(COMMON, "error response : %s", response_header.c_str()); - } else { - test_result[region_host.first] = rtt; - char latency_str[256]; - snprintf(latency_str, 256, "%s : %d[ms]", region_host.first.c_str(), rtt); - NOTICE_LOG(COMMON, "%s", latency_str); - } - client.Close(); - } - - gcp_ping_test_mutex_.lock(); - gcp_ping_test_result_.swap(test_result); - gcp_ping_test_mutex_.unlock(); -} - void Gdxsv::AddPortMapping() { if (config::EnableUPnP) { int port = config::GdxLocalPort; diff --git a/core/gdxsv/gdxsv.h b/core/gdxsv/gdxsv.h index 973fdc3ef..9118e21dd 100644 --- a/core/gdxsv/gdxsv.h +++ b/core/gdxsv/gdxsv.h @@ -52,7 +52,6 @@ class Gdxsv { MiniUPnP& UPnP() { return upnp_; } private: - void GcpPingTest(); void AddPortMapping(); static std::string GenerateLoginKey(); std::vector GeneratePlatformInfoPacket(); @@ -71,10 +70,9 @@ class Gdxsv { std::string user_id_; std::map symbols_; proto::GamePatchList patch_list_; - std::map gcp_ping_test_result_; - std::mutex gcp_ping_test_mutex_; bool going_to_battle_ = false; + std::shared_future> gcp_ping_test_result_; std::shared_future> public_ipv4_, public_ipv6_; MiniUPnP upnp_; diff --git a/core/gdxsv/gdxsv_CustomTexture.cpp b/core/gdxsv/gdxsv_CustomTexture.cpp index d9070e2e4..6ca97e8ab 100644 --- a/core/gdxsv/gdxsv_CustomTexture.cpp +++ b/core/gdxsv/gdxsv_CustomTexture.cpp @@ -10,9 +10,11 @@ #endif #include "gdxsv_CustomTexture.h" -#include "gdxsv_translation.h" + #include +#include "gdxsv_translation.h" + #ifdef __APPLE__ #include diff --git a/core/gdxsv/gdxsv_network.cpp b/core/gdxsv/gdxsv_network.cpp index dadf39e0d..8d6be92d8 100644 --- a/core/gdxsv/gdxsv_network.cpp +++ b/core/gdxsv/gdxsv_network.cpp @@ -89,6 +89,91 @@ std::future test_udp_port_connectivity(int port, bool ipv6) { }); } +std::future> gcp_ping_test() { + auto fn = []() -> std::map { + std::map test_result; + + // powered by https://github.com/GoogleCloudPlatform/gcping + const std::string get_path = "/api/ping"; + const std::map gcp_region_hosts = { + {"asia-east1", "asia-east1-5tkroniexa-de.a.run.app"}, + {"asia-east2", "asia-east2-5tkroniexa-df.a.run.app"}, + {"asia-northeast1", "asia-northeast1-5tkroniexa-an.a.run.app"}, + {"asia-northeast2", "asia-northeast2-5tkroniexa-dt.a.run.app"}, + {"asia-northeast3", "asia-northeast3-5tkroniexa-du.a.run.app"}, + {"asia-south1", "asia-south1-5tkroniexa-el.a.run.app"}, + {"asia-southeast1", "asia-southeast1-5tkroniexa-as.a.run.app"}, + {"australia-southeast1", "australia-southeast1-5tkroniexa-ts.a.run.app"}, + {"europe-north1", "europe-north1-5tkroniexa-lz.a.run.app"}, + {"europe-west1", "europe-west1-5tkroniexa-ew.a.run.app"}, + {"europe-west2", "europe-west2-5tkroniexa-nw.a.run.app"}, + {"europe-west3", "europe-west3-5tkroniexa-ey.a.run.app"}, + {"europe-west4", "europe-west4-5tkroniexa-ez.a.run.app"}, + {"europe-west6", "europe-west6-5tkroniexa-oa.a.run.app"}, + {"northamerica-northeast1", "northamerica-northeast1-5tkroniexa-nn.a.run.app"}, + {"southamerica-east1", "southamerica-east1-5tkroniexa-rj.a.run.app"}, + {"us-central1", "us-central1-5tkroniexa-uc.a.run.app"}, + {"us-east1", "us-east1-5tkroniexa-ue.a.run.app"}, + {"us-east4", "us-east4-5tkroniexa-uk.a.run.app"}, + {"us-west1", "us-west1-5tkroniexa-uw.a.run.app"}, + {"us-west2", "us-west2-5tkroniexa-wl.a.run.app"}, + {"us-west3", "us-west3-5tkroniexa-wm.a.run.app"}, + }; + + for (const auto ®ion_host : gcp_region_hosts) { + TcpClient client; + std::stringstream ss; + ss << "HEAD " << get_path << " HTTP/1.1" + << "\r\n"; + ss << "Host: " << region_host.second << "\r\n"; + ss << "User-Agent: flycast for gdxsv" + << "\r\n"; + ss << "Accept: */*" + << "\r\n"; + ss << "\r\n"; // end of header + + if (!client.Connect(region_host.second.c_str(), 80)) { + ERROR_LOG(COMMON, "connect failed : %s", region_host.first.c_str()); + continue; + } + + auto request_header = ss.str(); + auto t1 = std::chrono::high_resolution_clock::now(); + int n = client.Send(request_header.c_str(), request_header.size()); + if (n < request_header.size()) { + ERROR_LOG(COMMON, "send failed : %s", region_host.first.c_str()); + client.Close(); + continue; + } + + char buf[1024] = {0}; + n = client.Recv(buf, 1024); + if (n <= 0) { + ERROR_LOG(COMMON, "recv failed : %s", region_host.first.c_str()); + client.Close(); + continue; + } + + auto t2 = std::chrono::high_resolution_clock::now(); + int rtt = (int)std::chrono::duration_cast(t2 - t1).count(); + const std::string response_header(buf, n); + if (response_header.find("200 OK") == std::string::npos && response_header.find("302 Found") == std::string::npos) { + ERROR_LOG(COMMON, "error response : %s", response_header.c_str()); + } else { + test_result[region_host.first] = rtt; + char latency_str[256]; + snprintf(latency_str, 256, "%s : %d[ms]", region_host.first.c_str(), rtt); + NOTICE_LOG(COMMON, "%s", latency_str); + } + client.Close(); + } + + return test_result; + }; + + return std::async(std::launch::async, fn); +} + int get_random_port_number() { std::random_device rd; std::mt19937 gen(rd()); diff --git a/core/gdxsv/gdxsv_network.h b/core/gdxsv/gdxsv_network.h index 1ada21f32..2d7addefd 100644 --- a/core/gdxsv/gdxsv_network.h +++ b/core/gdxsv/gdxsv_network.h @@ -10,6 +10,7 @@ std::future test_udp_port_connectivity(int port, bool ipv6); std::future> get_public_ip_address(bool ipv6); +std::future> gcp_ping_test(); int get_random_port_number(); std::string sockaddr_to_string(const sockaddr *addr); bool is_loopback_addr(const sockaddr *addr); From 0cd7bee15a49d6f314f72c65b542a82668262edb Mon Sep 17 00:00:00 2001 From: Shingo INADA Date: Mon, 31 Jul 2023 17:18:48 +0900 Subject: [PATCH 2/2] add fps_history, total_timesync, input_blocked_count and after_log to match report --- core/gdxsv/gdxsv.cpp | 2 +- core/gdxsv/gdxsv.pb.cc | 373 ++++++++++++++++++------- core/gdxsv/gdxsv.pb.h | 376 ++++++++++++++++++++++---- core/gdxsv/gdxsv_backend_rollback.cpp | 22 ++ core/network/ggpo.cpp | 30 +- core/network/ggpo.h | 2 + 6 files changed, 647 insertions(+), 158 deletions(-) diff --git a/core/gdxsv/gdxsv.cpp b/core/gdxsv/gdxsv.cpp index e333f02a3..710de18a9 100644 --- a/core/gdxsv/gdxsv.cpp +++ b/core/gdxsv/gdxsv.cpp @@ -368,7 +368,7 @@ std::vector Gdxsv::GenerateP2PMatchReportPacket() { for (const auto &line : lines) { ss << line; } - rbk_report.set_log(ss.str()); + rbk_report.set_after_log(ss.str()); std::string data; if (rbk_report.SerializeToString(&data)) { diff --git a/core/gdxsv/gdxsv.pb.cc b/core/gdxsv/gdxsv.pb.cc index fda81eec1..b324a1c01 100644 --- a/core/gdxsv/gdxsv.pb.cc +++ b/core/gdxsv/gdxsv.pb.cc @@ -326,7 +326,13 @@ const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_gdxsv_2eproto::offsets[] PROTO PROTOBUF_FIELD_OFFSET(::proto::P2PMatchingReport, close_reason_), PROTOBUF_FIELD_OFFSET(::proto::P2PMatchingReport, frame_count_), PROTOBUF_FIELD_OFFSET(::proto::P2PMatchingReport, disconnected_peer_id_), - PROTOBUF_FIELD_OFFSET(::proto::P2PMatchingReport, log_), + PROTOBUF_FIELD_OFFSET(::proto::P2PMatchingReport, after_log_), + PROTOBUF_FIELD_OFFSET(::proto::P2PMatchingReport, before_log_), + PROTOBUF_FIELD_OFFSET(::proto::P2PMatchingReport, fps_history_), + PROTOBUF_FIELD_OFFSET(::proto::P2PMatchingReport, total_timesync_), + PROTOBUF_FIELD_OFFSET(::proto::P2PMatchingReport, input_block_count_0_), + PROTOBUF_FIELD_OFFSET(::proto::P2PMatchingReport, input_block_count_1_), + PROTOBUF_FIELD_OFFSET(::proto::P2PMatchingReport, input_block_count_2_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::proto::P2PMatching, _internal_metadata_), ~0u, // no _extensions_ @@ -473,20 +479,20 @@ const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_gdxsv_2eproto::offsets[] PROTO }; static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { { 0, -1, sizeof(::proto::P2PMatchingReport)}, - { 13, -1, sizeof(::proto::P2PMatching)}, - { 27, -1, sizeof(::proto::PlayerAddress)}, - { 37, -1, sizeof(::proto::GamePatch)}, - { 46, -1, sizeof(::proto::GamePatchCode)}, - { 55, -1, sizeof(::proto::GamePatchList)}, - { 61, -1, sizeof(::proto::BattleLogUser)}, - { 78, -1, sizeof(::proto::BattleLogFile)}, - { 98, -1, sizeof(::proto::BattleMessage)}, - { 106, -1, sizeof(::proto::PingMessage)}, - { 113, -1, sizeof(::proto::PongMessage)}, - { 121, -1, sizeof(::proto::HelloServerMessage)}, - { 129, -1, sizeof(::proto::FinMessage)}, - { 135, -1, sizeof(::proto::HelloLbsMessage)}, - { 141, -1, sizeof(::proto::Packet)}, + { 19, -1, sizeof(::proto::P2PMatching)}, + { 33, -1, sizeof(::proto::PlayerAddress)}, + { 43, -1, sizeof(::proto::GamePatch)}, + { 52, -1, sizeof(::proto::GamePatchCode)}, + { 61, -1, sizeof(::proto::GamePatchList)}, + { 67, -1, sizeof(::proto::BattleLogUser)}, + { 84, -1, sizeof(::proto::BattleLogFile)}, + { 104, -1, sizeof(::proto::BattleMessage)}, + { 112, -1, sizeof(::proto::PingMessage)}, + { 119, -1, sizeof(::proto::PongMessage)}, + { 127, -1, sizeof(::proto::HelloServerMessage)}, + { 135, -1, sizeof(::proto::FinMessage)}, + { 141, -1, sizeof(::proto::HelloLbsMessage)}, + { 147, -1, sizeof(::proto::Packet)}, }; static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = { @@ -508,62 +514,66 @@ static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = }; const char descriptor_table_protodef_gdxsv_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = - "\n\013gdxsv.proto\022\005proto\"\271\001\n\021P2PMatchingRepo" + "\n\013gdxsv.proto\022\005proto\"\327\002\n\021P2PMatchingRepo" "rt\022\023\n\013battle_code\030\001 \001(\t\022\022\n\nsession_id\030\002 " "\001(\005\022\024\n\014player_count\030\003 \001(\005\022\017\n\007peer_id\030\004 \001" "(\005\022\024\n\014close_reason\030\005 \001(\t\022\023\n\013frame_count\030" - "\006 \001(\005\022\034\n\024disconnected_peer_id\030\007 \001(\005\022\013\n\003l" - "og\030\013 \001(\t\"\356\001\n\013P2PMatching\022\023\n\013battle_code\030" - "\001 \001(\t\022\022\n\nsession_id\030\002 \001(\005\022\024\n\014player_coun" - "t\030\003 \001(\005\022\017\n\007peer_id\030\004 \001(\005\022\026\n\016timeout_min_" - "ms\030\005 \001(\005\022\026\n\016timeout_max_ms\030\006 \001(\005\022\020\n\010rule" - "_bin\030\010 \001(\014\022#\n\005users\030\t \003(\0132\024.proto.Battle" - "LogUser\022(\n\ncandidates\030\n \003(\0132\024.proto.Play" - "erAddress\"Y\n\rPlayerAddress\022\017\n\007user_id\030\001 " - "\001(\t\022\017\n\007peer_id\030\002 \001(\005\022\n\n\002ip\030\003 \001(\t\022\014\n\004port" - "\030\004 \001(\005\022\014\n\004team\030\005 \001(\005\"e\n\tGamePatch\022\021\n\tgam" - "e_disk\030\001 \001(\t\022\014\n\004name\030\002 \001(\t\022\022\n\nwrite_once" - "\030\004 \001(\010\022#\n\005codes\030\n \003(\0132\024.proto.GamePatchC" - "ode\"Q\n\rGamePatchCode\022\014\n\004size\030\001 \001(\005\022\017\n\007ad" - "dress\030\002 \001(\r\022\020\n\010original\030\003 \001(\r\022\017\n\007changed" - "\030\004 \001(\r\"2\n\rGamePatchList\022!\n\007patches\030\001 \003(\013" - "2\020.proto.GamePatch\"\354\001\n\rBattleLogUser\022\017\n\007" - "user_id\030\001 \001(\t\022\021\n\tuser_name\030\002 \001(\t\022\022\n\npilo" - "t_name\030\003 \001(\t\022\022\n\ngame_param\030\004 \001(\014\022\024\n\014batt" - "le_count\030\005 \001(\005\022\021\n\twin_count\030\006 \001(\005\022\022\n\nlos" - "e_count\030\007 \001(\005\022\r\n\005grade\030\010 \001(\005\022\014\n\004team\030\t \001" - "(\005\022\020\n\010platform\030\n \001(\t\022\026\n\016user_name_sjis\030\013" - " \001(\014\022\013\n\003pos\030\014 \001(\005\"\225\003\n\rBattleLogFile\022\021\n\tg" - "ame_disk\030\005 \001(\t\022 \n\030gdxsv_version_deprecat" - "ed\030\002 \001(\t\022\023\n\013battle_code\030\003 \001(\t\022\030\n\020log_fil" - "e_version\030\004 \001(\005\022!\n\007patches\030\007 \003(\0132\020.proto" - ".GamePatch\022\020\n\010rule_bin\030\n \001(\014\022#\n\005users\030\013 " - "\003(\0132\024.proto.BattleLogUser\022)\n\013battle_data" - "\030\014 \003(\0132\024.proto.BattleMessage\022\016\n\006inputs\030\017" - " \003(\006\022\031\n\021start_msg_indexes\030\020 \003(\005\022\031\n\021start" - "_msg_randoms\030\021 \003(\004\022\020\n\010start_at\030\024 \001(\003\022\016\n\006" - "end_at\030\025 \001(\003\022\024\n\014close_reason\030\030 \001(\t\022\035\n\025di" - "sconnect_user_index\030\031 \001(\005\";\n\rBattleMessa" - "ge\022\017\n\007user_id\030\001 \001(\t\022\013\n\003seq\030\002 \001(\r\022\014\n\004body" - "\030\003 \001(\014\"1\n\013PingMessage\022\021\n\ttimestamp\030\001 \001(\003" - "\022\017\n\007user_id\030\002 \001(\t\"F\n\013PongMessage\022\021\n\ttime" - "stamp\030\001 \001(\003\022\017\n\007user_id\030\002 \001(\t\022\023\n\013public_a" - "ddr\030\003 \001(\t\"P\n\022HelloServerMessage\022\035\n\025sessi" - "on_id_deprecated\030\001 \001(\t\022\n\n\002ok\030\002 \001(\010\022\017\n\007us" - "er_id\030\003 \001(\t\"\034\n\nFinMessage\022\016\n\006detail\030\001 \001(" - "\t\"\"\n\017HelloLbsMessage\022\017\n\007user_id\030\001 \001(\t\"\334\002" - "\n\006Packet\022 \n\004type\030\001 \001(\0162\022.proto.MessageTy" - "pe\022\013\n\003seq\030\002 \001(\r\022\013\n\003ack\030\003 \001(\r\022\022\n\nsession_" - "id\030\005 \001(\t\0224\n\021hello_server_data\030\n \001(\0132\031.pr" - "oto.HelloServerMessage\022%\n\tping_data\030\013 \001(" - "\0132\022.proto.PingMessage\022%\n\tpong_data\030\014 \001(\013" - "2\022.proto.PongMessage\022)\n\013battle_data\030\r \003(" - "\0132\024.proto.BattleMessage\022#\n\010fin_data\030\016 \001(" - "\0132\021.proto.FinMessage\022.\n\016hello_lbs_data\030\017" - " \001(\0132\026.proto.HelloLbsMessage*_\n\013MessageT" - "ype\022\010\n\004None\020\000\022\017\n\013HelloServer\020\001\022\010\n\004Ping\020\002" - "\022\010\n\004Pong\020\003\022\n\n\006Battle\020\004\022\007\n\003Fin\020\005\022\014\n\010Hello" - "Lbs\020\nB\rZ\013gdxsv/protob\006proto3" + "\006 \001(\005\022\034\n\024disconnected_peer_id\030\007 \001(\005\022\021\n\ta" + "fter_log\030\013 \001(\t\022\022\n\nbefore_log\030\014 \001(\t\022\023\n\013fp" + "s_history\030\017 \003(\002\022\026\n\016total_timesync\030\020 \001(\005\022" + "\033\n\023input_block_count_0\030\021 \001(\005\022\033\n\023input_bl" + "ock_count_1\030\022 \001(\005\022\033\n\023input_block_count_2" + "\030\023 \001(\005\"\356\001\n\013P2PMatching\022\023\n\013battle_code\030\001 " + "\001(\t\022\022\n\nsession_id\030\002 \001(\005\022\024\n\014player_count\030" + "\003 \001(\005\022\017\n\007peer_id\030\004 \001(\005\022\026\n\016timeout_min_ms" + "\030\005 \001(\005\022\026\n\016timeout_max_ms\030\006 \001(\005\022\020\n\010rule_b" + "in\030\010 \001(\014\022#\n\005users\030\t \003(\0132\024.proto.BattleLo" + "gUser\022(\n\ncandidates\030\n \003(\0132\024.proto.Player" + "Address\"Y\n\rPlayerAddress\022\017\n\007user_id\030\001 \001(" + "\t\022\017\n\007peer_id\030\002 \001(\005\022\n\n\002ip\030\003 \001(\t\022\014\n\004port\030\004" + " \001(\005\022\014\n\004team\030\005 \001(\005\"e\n\tGamePatch\022\021\n\tgame_" + "disk\030\001 \001(\t\022\014\n\004name\030\002 \001(\t\022\022\n\nwrite_once\030\004" + " \001(\010\022#\n\005codes\030\n \003(\0132\024.proto.GamePatchCod" + "e\"Q\n\rGamePatchCode\022\014\n\004size\030\001 \001(\005\022\017\n\007addr" + "ess\030\002 \001(\r\022\020\n\010original\030\003 \001(\r\022\017\n\007changed\030\004" + " \001(\r\"2\n\rGamePatchList\022!\n\007patches\030\001 \003(\0132\020" + ".proto.GamePatch\"\354\001\n\rBattleLogUser\022\017\n\007us" + "er_id\030\001 \001(\t\022\021\n\tuser_name\030\002 \001(\t\022\022\n\npilot_" + "name\030\003 \001(\t\022\022\n\ngame_param\030\004 \001(\014\022\024\n\014battle" + "_count\030\005 \001(\005\022\021\n\twin_count\030\006 \001(\005\022\022\n\nlose_" + "count\030\007 \001(\005\022\r\n\005grade\030\010 \001(\005\022\014\n\004team\030\t \001(\005" + "\022\020\n\010platform\030\n \001(\t\022\026\n\016user_name_sjis\030\013 \001" + "(\014\022\013\n\003pos\030\014 \001(\005\"\225\003\n\rBattleLogFile\022\021\n\tgam" + "e_disk\030\005 \001(\t\022 \n\030gdxsv_version_deprecated" + "\030\002 \001(\t\022\023\n\013battle_code\030\003 \001(\t\022\030\n\020log_file_" + "version\030\004 \001(\005\022!\n\007patches\030\007 \003(\0132\020.proto.G" + "amePatch\022\020\n\010rule_bin\030\n \001(\014\022#\n\005users\030\013 \003(" + "\0132\024.proto.BattleLogUser\022)\n\013battle_data\030\014" + " \003(\0132\024.proto.BattleMessage\022\016\n\006inputs\030\017 \003" + "(\006\022\031\n\021start_msg_indexes\030\020 \003(\005\022\031\n\021start_m" + "sg_randoms\030\021 \003(\004\022\020\n\010start_at\030\024 \001(\003\022\016\n\006en" + "d_at\030\025 \001(\003\022\024\n\014close_reason\030\030 \001(\t\022\035\n\025disc" + "onnect_user_index\030\031 \001(\005\";\n\rBattleMessage" + "\022\017\n\007user_id\030\001 \001(\t\022\013\n\003seq\030\002 \001(\r\022\014\n\004body\030\003" + " \001(\014\"1\n\013PingMessage\022\021\n\ttimestamp\030\001 \001(\003\022\017" + "\n\007user_id\030\002 \001(\t\"F\n\013PongMessage\022\021\n\ttimest" + "amp\030\001 \001(\003\022\017\n\007user_id\030\002 \001(\t\022\023\n\013public_add" + "r\030\003 \001(\t\"P\n\022HelloServerMessage\022\035\n\025session" + "_id_deprecated\030\001 \001(\t\022\n\n\002ok\030\002 \001(\010\022\017\n\007user" + "_id\030\003 \001(\t\"\034\n\nFinMessage\022\016\n\006detail\030\001 \001(\t\"" + "\"\n\017HelloLbsMessage\022\017\n\007user_id\030\001 \001(\t\"\334\002\n\006" + "Packet\022 \n\004type\030\001 \001(\0162\022.proto.MessageType" + "\022\013\n\003seq\030\002 \001(\r\022\013\n\003ack\030\003 \001(\r\022\022\n\nsession_id" + "\030\005 \001(\t\0224\n\021hello_server_data\030\n \001(\0132\031.prot" + "o.HelloServerMessage\022%\n\tping_data\030\013 \001(\0132" + "\022.proto.PingMessage\022%\n\tpong_data\030\014 \001(\0132\022" + ".proto.PongMessage\022)\n\013battle_data\030\r \003(\0132" + "\024.proto.BattleMessage\022#\n\010fin_data\030\016 \001(\0132" + "\021.proto.FinMessage\022.\n\016hello_lbs_data\030\017 \001" + "(\0132\026.proto.HelloLbsMessage*_\n\013MessageTyp" + "e\022\010\n\004None\020\000\022\017\n\013HelloServer\020\001\022\010\n\004Ping\020\002\022\010" + "\n\004Pong\020\003\022\n\n\006Battle\020\004\022\007\n\003Fin\020\005\022\014\n\010HelloLb" + "s\020\nB\rZ\013gdxsv/protob\006proto3" ; static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_gdxsv_2eproto_deps[1] = { }; @@ -586,7 +596,7 @@ static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_gdx }; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_gdxsv_2eproto_once; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_gdxsv_2eproto = { - false, false, descriptor_table_protodef_gdxsv_2eproto, "gdxsv.proto", 2228, + false, false, descriptor_table_protodef_gdxsv_2eproto, "gdxsv.proto", 2386, &descriptor_table_gdxsv_2eproto_once, descriptor_table_gdxsv_2eproto_sccs, descriptor_table_gdxsv_2eproto_deps, 15, 0, schemas, file_default_instances, TableStruct_gdxsv_2eproto::offsets, file_level_metadata_gdxsv_2eproto, 15, file_level_enum_descriptors_gdxsv_2eproto, file_level_service_descriptors_gdxsv_2eproto, @@ -624,13 +634,15 @@ class P2PMatchingReport::_Internal { }; P2PMatchingReport::P2PMatchingReport(::PROTOBUF_NAMESPACE_ID::Arena* arena) - : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + : ::PROTOBUF_NAMESPACE_ID::Message(arena), + fps_history_(arena) { SharedCtor(); RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:proto.P2PMatchingReport) } P2PMatchingReport::P2PMatchingReport(const P2PMatchingReport& from) - : ::PROTOBUF_NAMESPACE_ID::Message() { + : ::PROTOBUF_NAMESPACE_ID::Message(), + fps_history_(from.fps_history_) { _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); battle_code_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (!from._internal_battle_code().empty()) { @@ -642,14 +654,19 @@ P2PMatchingReport::P2PMatchingReport(const P2PMatchingReport& from) close_reason_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_close_reason(), GetArena()); } - log_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (!from._internal_log().empty()) { - log_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_log(), + after_log_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + if (!from._internal_after_log().empty()) { + after_log_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_after_log(), + GetArena()); + } + before_log_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + if (!from._internal_before_log().empty()) { + before_log_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_before_log(), GetArena()); } ::memcpy(&session_id_, &from.session_id_, - static_cast(reinterpret_cast(&disconnected_peer_id_) - - reinterpret_cast(&session_id_)) + sizeof(disconnected_peer_id_)); + static_cast(reinterpret_cast(&input_block_count_1_) - + reinterpret_cast(&session_id_)) + sizeof(input_block_count_1_)); // @@protoc_insertion_point(copy_constructor:proto.P2PMatchingReport) } @@ -657,10 +674,11 @@ void P2PMatchingReport::SharedCtor() { ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_P2PMatchingReport_gdxsv_2eproto.base); battle_code_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); close_reason_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - log_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + after_log_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + before_log_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); ::memset(&session_id_, 0, static_cast( - reinterpret_cast(&disconnected_peer_id_) - - reinterpret_cast(&session_id_)) + sizeof(disconnected_peer_id_)); + reinterpret_cast(&input_block_count_1_) - + reinterpret_cast(&session_id_)) + sizeof(input_block_count_1_)); } P2PMatchingReport::~P2PMatchingReport() { @@ -673,7 +691,8 @@ void P2PMatchingReport::SharedDtor() { GOOGLE_DCHECK(GetArena() == nullptr); battle_code_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); close_reason_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - log_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + after_log_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + before_log_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } void P2PMatchingReport::ArenaDtor(void* object) { @@ -697,12 +716,14 @@ void P2PMatchingReport::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; + fps_history_.Clear(); battle_code_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); close_reason_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - log_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + after_log_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + before_log_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); ::memset(&session_id_, 0, static_cast( - reinterpret_cast(&disconnected_peer_id_) - - reinterpret_cast(&session_id_)) + sizeof(disconnected_peer_id_)); + reinterpret_cast(&input_block_count_1_) - + reinterpret_cast(&session_id_)) + sizeof(input_block_count_1_)); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } @@ -767,12 +788,59 @@ const char* P2PMatchingReport::_InternalParse(const char* ptr, ::PROTOBUF_NAMESP CHK_(ptr); } else goto handle_unusual; continue; - // string log = 11; + // string after_log = 11; case 11: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 90)) { - auto str = _internal_mutable_log(); + auto str = _internal_mutable_after_log(); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "proto.P2PMatchingReport.after_log")); + CHK_(ptr); + } else goto handle_unusual; + continue; + // string before_log = 12; + case 12: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 98)) { + auto str = _internal_mutable_before_log(); ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); - CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "proto.P2PMatchingReport.log")); + CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "proto.P2PMatchingReport.before_log")); + CHK_(ptr); + } else goto handle_unusual; + continue; + // repeated float fps_history = 15; + case 15: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 122)) { + ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedFloatParser(_internal_mutable_fps_history(), ptr, ctx); + CHK_(ptr); + } else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 125) { + _internal_add_fps_history(::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad(ptr)); + ptr += sizeof(float); + } else goto handle_unusual; + continue; + // int32 total_timesync = 16; + case 16: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 128)) { + total_timesync_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // int32 input_block_count_0 = 17; + case 17: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 136)) { + input_block_count_0_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // int32 input_block_count_1 = 18; + case 18: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 144)) { + input_block_count_1_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; + // int32 input_block_count_2 = 19; + case 19: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 152)) { + input_block_count_2_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; continue; @@ -854,14 +922,53 @@ ::PROTOBUF_NAMESPACE_ID::uint8* P2PMatchingReport::_InternalSerialize( target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(7, this->_internal_disconnected_peer_id(), target); } - // string log = 11; - if (this->log().size() > 0) { + // string after_log = 11; + if (this->after_log().size() > 0) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->_internal_log().data(), static_cast(this->_internal_log().length()), + this->_internal_after_log().data(), static_cast(this->_internal_after_log().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, - "proto.P2PMatchingReport.log"); + "proto.P2PMatchingReport.after_log"); target = stream->WriteStringMaybeAliased( - 11, this->_internal_log(), target); + 11, this->_internal_after_log(), target); + } + + // string before_log = 12; + if (this->before_log().size() > 0) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( + this->_internal_before_log().data(), static_cast(this->_internal_before_log().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "proto.P2PMatchingReport.before_log"); + target = stream->WriteStringMaybeAliased( + 12, this->_internal_before_log(), target); + } + + // repeated float fps_history = 15; + if (this->_internal_fps_history_size() > 0) { + target = stream->WriteFixedPacked(15, _internal_fps_history(), target); + } + + // int32 total_timesync = 16; + if (this->total_timesync() != 0) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(16, this->_internal_total_timesync(), target); + } + + // int32 input_block_count_0 = 17; + if (this->input_block_count_0() != 0) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(17, this->_internal_input_block_count_0(), target); + } + + // int32 input_block_count_1 = 18; + if (this->input_block_count_1() != 0) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(18, this->_internal_input_block_count_1(), target); + } + + // int32 input_block_count_2 = 19; + if (this->input_block_count_2() != 0) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(19, this->_internal_input_block_count_2(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { @@ -880,6 +987,21 @@ size_t P2PMatchingReport::ByteSizeLong() const { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; + // repeated float fps_history = 15; + { + unsigned int count = static_cast(this->_internal_fps_history_size()); + size_t data_size = 4UL * count; + if (data_size > 0) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + static_cast<::PROTOBUF_NAMESPACE_ID::int32>(data_size)); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(data_size); + _fps_history_cached_byte_size_.store(cached_size, + std::memory_order_relaxed); + total_size += data_size; + } + // string battle_code = 1; if (this->battle_code().size() > 0) { total_size += 1 + @@ -894,11 +1016,18 @@ size_t P2PMatchingReport::ByteSizeLong() const { this->_internal_close_reason()); } - // string log = 11; - if (this->log().size() > 0) { + // string after_log = 11; + if (this->after_log().size() > 0) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_after_log()); + } + + // string before_log = 12; + if (this->before_log().size() > 0) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_log()); + this->_internal_before_log()); } // int32 session_id = 2; @@ -936,6 +1065,34 @@ size_t P2PMatchingReport::ByteSizeLong() const { this->_internal_disconnected_peer_id()); } + // int32 total_timesync = 16; + if (this->total_timesync() != 0) { + total_size += 2 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_total_timesync()); + } + + // int32 input_block_count_2 = 19; + if (this->input_block_count_2() != 0) { + total_size += 2 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_input_block_count_2()); + } + + // int32 input_block_count_0 = 17; + if (this->input_block_count_0() != 0) { + total_size += 2 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_input_block_count_0()); + } + + // int32 input_block_count_1 = 18; + if (this->input_block_count_1() != 0) { + total_size += 2 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( + this->_internal_input_block_count_1()); + } + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( _internal_metadata_, total_size, &_cached_size_); @@ -967,14 +1124,18 @@ void P2PMatchingReport::MergeFrom(const P2PMatchingReport& from) { ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; + fps_history_.MergeFrom(from.fps_history_); if (from.battle_code().size() > 0) { _internal_set_battle_code(from._internal_battle_code()); } if (from.close_reason().size() > 0) { _internal_set_close_reason(from._internal_close_reason()); } - if (from.log().size() > 0) { - _internal_set_log(from._internal_log()); + if (from.after_log().size() > 0) { + _internal_set_after_log(from._internal_after_log()); + } + if (from.before_log().size() > 0) { + _internal_set_before_log(from._internal_before_log()); } if (from.session_id() != 0) { _internal_set_session_id(from._internal_session_id()); @@ -991,6 +1152,18 @@ void P2PMatchingReport::MergeFrom(const P2PMatchingReport& from) { if (from.disconnected_peer_id() != 0) { _internal_set_disconnected_peer_id(from._internal_disconnected_peer_id()); } + if (from.total_timesync() != 0) { + _internal_set_total_timesync(from._internal_total_timesync()); + } + if (from.input_block_count_2() != 0) { + _internal_set_input_block_count_2(from._internal_input_block_count_2()); + } + if (from.input_block_count_0() != 0) { + _internal_set_input_block_count_0(from._internal_input_block_count_0()); + } + if (from.input_block_count_1() != 0) { + _internal_set_input_block_count_1(from._internal_input_block_count_1()); + } } void P2PMatchingReport::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { @@ -1014,12 +1187,14 @@ bool P2PMatchingReport::IsInitialized() const { void P2PMatchingReport::InternalSwap(P2PMatchingReport* other) { using std::swap; _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + fps_history_.InternalSwap(&other->fps_history_); battle_code_.Swap(&other->battle_code_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); close_reason_.Swap(&other->close_reason_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); - log_.Swap(&other->log_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + after_log_.Swap(&other->after_log_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + before_log_.Swap(&other->before_log_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(P2PMatchingReport, disconnected_peer_id_) - + sizeof(P2PMatchingReport::disconnected_peer_id_) + PROTOBUF_FIELD_OFFSET(P2PMatchingReport, input_block_count_1_) + + sizeof(P2PMatchingReport::input_block_count_1_) - PROTOBUF_FIELD_OFFSET(P2PMatchingReport, session_id_)>( reinterpret_cast(&session_id_), reinterpret_cast(&other->session_id_)); diff --git a/core/gdxsv/gdxsv.pb.h b/core/gdxsv/gdxsv.pb.h index 758fbaf14..68fe5c000 100644 --- a/core/gdxsv/gdxsv.pb.h +++ b/core/gdxsv/gdxsv.pb.h @@ -266,15 +266,43 @@ class P2PMatchingReport PROTOBUF_FINAL : // accessors ------------------------------------------------------- enum : int { + kFpsHistoryFieldNumber = 15, kBattleCodeFieldNumber = 1, kCloseReasonFieldNumber = 5, - kLogFieldNumber = 11, + kAfterLogFieldNumber = 11, + kBeforeLogFieldNumber = 12, kSessionIdFieldNumber = 2, kPlayerCountFieldNumber = 3, kPeerIdFieldNumber = 4, kFrameCountFieldNumber = 6, kDisconnectedPeerIdFieldNumber = 7, + kTotalTimesyncFieldNumber = 16, + kInputBlockCount2FieldNumber = 19, + kInputBlockCount0FieldNumber = 17, + kInputBlockCount1FieldNumber = 18, }; + // repeated float fps_history = 15; + int fps_history_size() const; + private: + int _internal_fps_history_size() const; + public: + void clear_fps_history(); + private: + float _internal_fps_history(int index) const; + const ::PROTOBUF_NAMESPACE_ID::RepeatedField< float >& + _internal_fps_history() const; + void _internal_add_fps_history(float value); + ::PROTOBUF_NAMESPACE_ID::RepeatedField< float >* + _internal_mutable_fps_history(); + public: + float fps_history(int index) const; + void set_fps_history(int index, float value); + void add_fps_history(float value); + const ::PROTOBUF_NAMESPACE_ID::RepeatedField< float >& + fps_history() const; + ::PROTOBUF_NAMESPACE_ID::RepeatedField< float >* + mutable_fps_history(); + // string battle_code = 1; void clear_battle_code(); const std::string& battle_code() const; @@ -307,20 +335,36 @@ class P2PMatchingReport PROTOBUF_FINAL : std::string* _internal_mutable_close_reason(); public: - // string log = 11; - void clear_log(); - const std::string& log() const; - void set_log(const std::string& value); - void set_log(std::string&& value); - void set_log(const char* value); - void set_log(const char* value, size_t size); - std::string* mutable_log(); - std::string* release_log(); - void set_allocated_log(std::string* log); - private: - const std::string& _internal_log() const; - void _internal_set_log(const std::string& value); - std::string* _internal_mutable_log(); + // string after_log = 11; + void clear_after_log(); + const std::string& after_log() const; + void set_after_log(const std::string& value); + void set_after_log(std::string&& value); + void set_after_log(const char* value); + void set_after_log(const char* value, size_t size); + std::string* mutable_after_log(); + std::string* release_after_log(); + void set_allocated_after_log(std::string* after_log); + private: + const std::string& _internal_after_log() const; + void _internal_set_after_log(const std::string& value); + std::string* _internal_mutable_after_log(); + public: + + // string before_log = 12; + void clear_before_log(); + const std::string& before_log() const; + void set_before_log(const std::string& value); + void set_before_log(std::string&& value); + void set_before_log(const char* value); + void set_before_log(const char* value, size_t size); + std::string* mutable_before_log(); + std::string* release_before_log(); + void set_allocated_before_log(std::string* before_log); + private: + const std::string& _internal_before_log() const; + void _internal_set_before_log(const std::string& value); + std::string* _internal_mutable_before_log(); public: // int32 session_id = 2; @@ -368,6 +412,42 @@ class P2PMatchingReport PROTOBUF_FINAL : void _internal_set_disconnected_peer_id(::PROTOBUF_NAMESPACE_ID::int32 value); public: + // int32 total_timesync = 16; + void clear_total_timesync(); + ::PROTOBUF_NAMESPACE_ID::int32 total_timesync() const; + void set_total_timesync(::PROTOBUF_NAMESPACE_ID::int32 value); + private: + ::PROTOBUF_NAMESPACE_ID::int32 _internal_total_timesync() const; + void _internal_set_total_timesync(::PROTOBUF_NAMESPACE_ID::int32 value); + public: + + // int32 input_block_count_2 = 19; + void clear_input_block_count_2(); + ::PROTOBUF_NAMESPACE_ID::int32 input_block_count_2() const; + void set_input_block_count_2(::PROTOBUF_NAMESPACE_ID::int32 value); + private: + ::PROTOBUF_NAMESPACE_ID::int32 _internal_input_block_count_2() const; + void _internal_set_input_block_count_2(::PROTOBUF_NAMESPACE_ID::int32 value); + public: + + // int32 input_block_count_0 = 17; + void clear_input_block_count_0(); + ::PROTOBUF_NAMESPACE_ID::int32 input_block_count_0() const; + void set_input_block_count_0(::PROTOBUF_NAMESPACE_ID::int32 value); + private: + ::PROTOBUF_NAMESPACE_ID::int32 _internal_input_block_count_0() const; + void _internal_set_input_block_count_0(::PROTOBUF_NAMESPACE_ID::int32 value); + public: + + // int32 input_block_count_1 = 18; + void clear_input_block_count_1(); + ::PROTOBUF_NAMESPACE_ID::int32 input_block_count_1() const; + void set_input_block_count_1(::PROTOBUF_NAMESPACE_ID::int32 value); + private: + ::PROTOBUF_NAMESPACE_ID::int32 _internal_input_block_count_1() const; + void _internal_set_input_block_count_1(::PROTOBUF_NAMESPACE_ID::int32 value); + public: + // @@protoc_insertion_point(class_scope:proto.P2PMatchingReport) private: class _Internal; @@ -375,14 +455,21 @@ class P2PMatchingReport PROTOBUF_FINAL : template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::RepeatedField< float > fps_history_; + mutable std::atomic _fps_history_cached_byte_size_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr battle_code_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr close_reason_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr log_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr after_log_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr before_log_; ::PROTOBUF_NAMESPACE_ID::int32 session_id_; ::PROTOBUF_NAMESPACE_ID::int32 player_count_; ::PROTOBUF_NAMESPACE_ID::int32 peer_id_; ::PROTOBUF_NAMESPACE_ID::int32 frame_count_; ::PROTOBUF_NAMESPACE_ID::int32 disconnected_peer_id_; + ::PROTOBUF_NAMESPACE_ID::int32 total_timesync_; + ::PROTOBUF_NAMESPACE_ID::int32 input_block_count_2_; + ::PROTOBUF_NAMESPACE_ID::int32 input_block_count_0_; + ::PROTOBUF_NAMESPACE_ID::int32 input_block_count_1_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; friend struct ::TableStruct_gdxsv_2eproto; }; @@ -3536,66 +3623,255 @@ inline void P2PMatchingReport::set_disconnected_peer_id(::PROTOBUF_NAMESPACE_ID: // @@protoc_insertion_point(field_set:proto.P2PMatchingReport.disconnected_peer_id) } -// string log = 11; -inline void P2PMatchingReport::clear_log() { - log_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +// string after_log = 11; +inline void P2PMatchingReport::clear_after_log() { + after_log_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline const std::string& P2PMatchingReport::after_log() const { + // @@protoc_insertion_point(field_get:proto.P2PMatchingReport.after_log) + return _internal_after_log(); +} +inline void P2PMatchingReport::set_after_log(const std::string& value) { + _internal_set_after_log(value); + // @@protoc_insertion_point(field_set:proto.P2PMatchingReport.after_log) +} +inline std::string* P2PMatchingReport::mutable_after_log() { + // @@protoc_insertion_point(field_mutable:proto.P2PMatchingReport.after_log) + return _internal_mutable_after_log(); +} +inline const std::string& P2PMatchingReport::_internal_after_log() const { + return after_log_.Get(); +} +inline void P2PMatchingReport::_internal_set_after_log(const std::string& value) { + + after_log_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); +} +inline void P2PMatchingReport::set_after_log(std::string&& value) { + + after_log_.Set( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); + // @@protoc_insertion_point(field_set_rvalue:proto.P2PMatchingReport.after_log) +} +inline void P2PMatchingReport::set_after_log(const char* value) { + GOOGLE_DCHECK(value != nullptr); + + after_log_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArena()); + // @@protoc_insertion_point(field_set_char:proto.P2PMatchingReport.after_log) +} +inline void P2PMatchingReport::set_after_log(const char* value, + size_t size) { + + after_log_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArena()); + // @@protoc_insertion_point(field_set_pointer:proto.P2PMatchingReport.after_log) +} +inline std::string* P2PMatchingReport::_internal_mutable_after_log() { + + return after_log_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline std::string* P2PMatchingReport::release_after_log() { + // @@protoc_insertion_point(field_release:proto.P2PMatchingReport.after_log) + return after_log_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline void P2PMatchingReport::set_allocated_after_log(std::string* after_log) { + if (after_log != nullptr) { + + } else { + + } + after_log_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), after_log, + GetArena()); + // @@protoc_insertion_point(field_set_allocated:proto.P2PMatchingReport.after_log) +} + +// string before_log = 12; +inline void P2PMatchingReport::clear_before_log() { + before_log_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } -inline const std::string& P2PMatchingReport::log() const { - // @@protoc_insertion_point(field_get:proto.P2PMatchingReport.log) - return _internal_log(); +inline const std::string& P2PMatchingReport::before_log() const { + // @@protoc_insertion_point(field_get:proto.P2PMatchingReport.before_log) + return _internal_before_log(); } -inline void P2PMatchingReport::set_log(const std::string& value) { - _internal_set_log(value); - // @@protoc_insertion_point(field_set:proto.P2PMatchingReport.log) +inline void P2PMatchingReport::set_before_log(const std::string& value) { + _internal_set_before_log(value); + // @@protoc_insertion_point(field_set:proto.P2PMatchingReport.before_log) } -inline std::string* P2PMatchingReport::mutable_log() { - // @@protoc_insertion_point(field_mutable:proto.P2PMatchingReport.log) - return _internal_mutable_log(); +inline std::string* P2PMatchingReport::mutable_before_log() { + // @@protoc_insertion_point(field_mutable:proto.P2PMatchingReport.before_log) + return _internal_mutable_before_log(); } -inline const std::string& P2PMatchingReport::_internal_log() const { - return log_.Get(); +inline const std::string& P2PMatchingReport::_internal_before_log() const { + return before_log_.Get(); } -inline void P2PMatchingReport::_internal_set_log(const std::string& value) { +inline void P2PMatchingReport::_internal_set_before_log(const std::string& value) { - log_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); + before_log_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); } -inline void P2PMatchingReport::set_log(std::string&& value) { +inline void P2PMatchingReport::set_before_log(std::string&& value) { - log_.Set( + before_log_.Set( &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); - // @@protoc_insertion_point(field_set_rvalue:proto.P2PMatchingReport.log) + // @@protoc_insertion_point(field_set_rvalue:proto.P2PMatchingReport.before_log) } -inline void P2PMatchingReport::set_log(const char* value) { +inline void P2PMatchingReport::set_before_log(const char* value) { GOOGLE_DCHECK(value != nullptr); - log_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + before_log_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), GetArena()); - // @@protoc_insertion_point(field_set_char:proto.P2PMatchingReport.log) + // @@protoc_insertion_point(field_set_char:proto.P2PMatchingReport.before_log) } -inline void P2PMatchingReport::set_log(const char* value, +inline void P2PMatchingReport::set_before_log(const char* value, size_t size) { - log_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( + before_log_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( reinterpret_cast(value), size), GetArena()); - // @@protoc_insertion_point(field_set_pointer:proto.P2PMatchingReport.log) + // @@protoc_insertion_point(field_set_pointer:proto.P2PMatchingReport.before_log) } -inline std::string* P2PMatchingReport::_internal_mutable_log() { +inline std::string* P2PMatchingReport::_internal_mutable_before_log() { - return log_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + return before_log_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } -inline std::string* P2PMatchingReport::release_log() { - // @@protoc_insertion_point(field_release:proto.P2PMatchingReport.log) - return log_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +inline std::string* P2PMatchingReport::release_before_log() { + // @@protoc_insertion_point(field_release:proto.P2PMatchingReport.before_log) + return before_log_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); } -inline void P2PMatchingReport::set_allocated_log(std::string* log) { - if (log != nullptr) { +inline void P2PMatchingReport::set_allocated_before_log(std::string* before_log) { + if (before_log != nullptr) { } else { } - log_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), log, + before_log_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), before_log, GetArena()); - // @@protoc_insertion_point(field_set_allocated:proto.P2PMatchingReport.log) + // @@protoc_insertion_point(field_set_allocated:proto.P2PMatchingReport.before_log) +} + +// repeated float fps_history = 15; +inline int P2PMatchingReport::_internal_fps_history_size() const { + return fps_history_.size(); +} +inline int P2PMatchingReport::fps_history_size() const { + return _internal_fps_history_size(); +} +inline void P2PMatchingReport::clear_fps_history() { + fps_history_.Clear(); +} +inline float P2PMatchingReport::_internal_fps_history(int index) const { + return fps_history_.Get(index); +} +inline float P2PMatchingReport::fps_history(int index) const { + // @@protoc_insertion_point(field_get:proto.P2PMatchingReport.fps_history) + return _internal_fps_history(index); +} +inline void P2PMatchingReport::set_fps_history(int index, float value) { + fps_history_.Set(index, value); + // @@protoc_insertion_point(field_set:proto.P2PMatchingReport.fps_history) +} +inline void P2PMatchingReport::_internal_add_fps_history(float value) { + fps_history_.Add(value); +} +inline void P2PMatchingReport::add_fps_history(float value) { + _internal_add_fps_history(value); + // @@protoc_insertion_point(field_add:proto.P2PMatchingReport.fps_history) +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< float >& +P2PMatchingReport::_internal_fps_history() const { + return fps_history_; +} +inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< float >& +P2PMatchingReport::fps_history() const { + // @@protoc_insertion_point(field_list:proto.P2PMatchingReport.fps_history) + return _internal_fps_history(); +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< float >* +P2PMatchingReport::_internal_mutable_fps_history() { + return &fps_history_; +} +inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< float >* +P2PMatchingReport::mutable_fps_history() { + // @@protoc_insertion_point(field_mutable_list:proto.P2PMatchingReport.fps_history) + return _internal_mutable_fps_history(); +} + +// int32 total_timesync = 16; +inline void P2PMatchingReport::clear_total_timesync() { + total_timesync_ = 0; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 P2PMatchingReport::_internal_total_timesync() const { + return total_timesync_; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 P2PMatchingReport::total_timesync() const { + // @@protoc_insertion_point(field_get:proto.P2PMatchingReport.total_timesync) + return _internal_total_timesync(); +} +inline void P2PMatchingReport::_internal_set_total_timesync(::PROTOBUF_NAMESPACE_ID::int32 value) { + + total_timesync_ = value; +} +inline void P2PMatchingReport::set_total_timesync(::PROTOBUF_NAMESPACE_ID::int32 value) { + _internal_set_total_timesync(value); + // @@protoc_insertion_point(field_set:proto.P2PMatchingReport.total_timesync) +} + +// int32 input_block_count_0 = 17; +inline void P2PMatchingReport::clear_input_block_count_0() { + input_block_count_0_ = 0; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 P2PMatchingReport::_internal_input_block_count_0() const { + return input_block_count_0_; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 P2PMatchingReport::input_block_count_0() const { + // @@protoc_insertion_point(field_get:proto.P2PMatchingReport.input_block_count_0) + return _internal_input_block_count_0(); +} +inline void P2PMatchingReport::_internal_set_input_block_count_0(::PROTOBUF_NAMESPACE_ID::int32 value) { + + input_block_count_0_ = value; +} +inline void P2PMatchingReport::set_input_block_count_0(::PROTOBUF_NAMESPACE_ID::int32 value) { + _internal_set_input_block_count_0(value); + // @@protoc_insertion_point(field_set:proto.P2PMatchingReport.input_block_count_0) +} + +// int32 input_block_count_1 = 18; +inline void P2PMatchingReport::clear_input_block_count_1() { + input_block_count_1_ = 0; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 P2PMatchingReport::_internal_input_block_count_1() const { + return input_block_count_1_; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 P2PMatchingReport::input_block_count_1() const { + // @@protoc_insertion_point(field_get:proto.P2PMatchingReport.input_block_count_1) + return _internal_input_block_count_1(); +} +inline void P2PMatchingReport::_internal_set_input_block_count_1(::PROTOBUF_NAMESPACE_ID::int32 value) { + + input_block_count_1_ = value; +} +inline void P2PMatchingReport::set_input_block_count_1(::PROTOBUF_NAMESPACE_ID::int32 value) { + _internal_set_input_block_count_1(value); + // @@protoc_insertion_point(field_set:proto.P2PMatchingReport.input_block_count_1) +} + +// int32 input_block_count_2 = 19; +inline void P2PMatchingReport::clear_input_block_count_2() { + input_block_count_2_ = 0; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 P2PMatchingReport::_internal_input_block_count_2() const { + return input_block_count_2_; +} +inline ::PROTOBUF_NAMESPACE_ID::int32 P2PMatchingReport::input_block_count_2() const { + // @@protoc_insertion_point(field_get:proto.P2PMatchingReport.input_block_count_2) + return _internal_input_block_count_2(); +} +inline void P2PMatchingReport::_internal_set_input_block_count_2(::PROTOBUF_NAMESPACE_ID::int32 value) { + + input_block_count_2_ = value; +} +inline void P2PMatchingReport::set_input_block_count_2(::PROTOBUF_NAMESPACE_ID::int32 value) { + _internal_set_input_block_count_2(value); + // @@protoc_insertion_point(field_set:proto.P2PMatchingReport.input_block_count_2) } // ------------------------------------------------------------------- diff --git a/core/gdxsv/gdxsv_backend_rollback.cpp b/core/gdxsv/gdxsv_backend_rollback.cpp index 0567f0cc4..9f3f3b114 100644 --- a/core/gdxsv/gdxsv_backend_rollback.cpp +++ b/core/gdxsv/gdxsv_backend_rollback.cpp @@ -14,6 +14,7 @@ #include "imgui/imgui_internal.h" #include "input/gamepad_device.h" #include "libs.h" +#include "log/InMemoryListener.h" #include "network/ggpo.h" #include "network/net_platform.h" #include "rend/boxart/http_client.h" @@ -219,6 +220,14 @@ void GdxsvBackendRollback::OnMainUiLoop() { error_fast_return_ = true; emu.start(); } + { + std::ostringstream ss; + auto lines = InMemoryListener::getInstance()->getLog(); + for (const auto& line : lines) { + ss << line; + } + report_.set_before_log(ss.str()); + } } if (state_ == State::WaitGGPOSession) { @@ -597,6 +606,19 @@ u32 GdxsvBackendRollback::OnSockRead(u32 addr, u32 size) { if (!ggpo::rollbacking()) { report_.set_frame_count(frame); + + if (0 < frame && frame % 600 == 0) { + auto me = matching_.peer_id(); + ggpo::NetworkStats stats{}; + if (ggpo::active()) { + ggpo::getNetworkStats(me, &stats); + report_.add_fps_history(stats.extra.current_fps); + report_.set_total_timesync(stats.extra.total_timesync); + report_.set_input_block_count_0(stats.extra.input_block_count[0]); + report_.set_input_block_count_1(stats.extra.input_block_count[1]); + report_.set_input_block_count_2(stats.extra.input_block_count[2]); + } + } } verify(recv_buf_.size() <= size); diff --git a/core/network/ggpo.cpp b/core/network/ggpo.cpp index e8f9a95c6..a3b7a8a21 100644 --- a/core/network/ggpo.cpp +++ b/core/network/ggpo.cpp @@ -121,10 +121,12 @@ static GGPOPlayerHandle remotePlayer; static int disconnect_flags; static bool synchronized; static std::recursive_mutex ggpoMutex; -static std::array msPerFrame; -static int msPerFrameIndex; +static std::array usPerFrame; +static int usPerFrameIndex; static time_point lastFrameTime; -static int msPerFrameAvg; +static int usPerFrameAvg; +static float fpsAvg; +static std::array inputBlockCount; static bool _endOfFrame; static MiniUPnP miniupnp; static int analogAxes; @@ -510,6 +512,7 @@ void startSession(int localPort, int localPlayerNum) cb.log_game_state = log_game_state; cb.on_message = on_message; disconnect_flags = 0; + inputBlockCount.fill(0); #ifdef SYNC_TEST GGPOErrorCode result = ggpo_start_synctest(&ggpoSession, &cb, settings.content.gameId.c_str(), 2, sizeof(kcode[0]), 1); @@ -717,10 +720,11 @@ bool nextFrame() auto now = std::chrono::steady_clock::now(); if (lastFrameTime != time_point()) { - msPerFrame[msPerFrameIndex++] = duration_cast(now - lastFrameTime).count(); - if (msPerFrameIndex >= (int)msPerFrame.size()) - msPerFrameIndex = 0; - msPerFrameAvg = std::accumulate(msPerFrame.begin(), msPerFrame.end(), 0) / msPerFrame.size(); + usPerFrame[usPerFrameIndex++] = duration_cast(now - lastFrameTime).count(); + if (usPerFrameIndex >= (int)usPerFrame.size()) + usPerFrameIndex = 0; + usPerFrameAvg = std::accumulate(usPerFrame.begin(), usPerFrame.end(), 0) / usPerFrame.size(); + fpsAvg = static_cast(usPerFrame.size()) * 1000 * 1000 / std::accumulate(usPerFrame.begin(), usPerFrame.end(), 0); } lastFrameTime = now; @@ -802,6 +806,11 @@ bool nextFrame() error = ggpo_add_local_input(ggpoSession, localPlayer, &inputs, inputSize); if (error == GGPO_OK) { + if (0 < loop_count) { + if (loop_count * 5 <= 30) inputBlockCount[0]++; + else if (loop_count * 5 <= 500) inputBlockCount[1]++; + else inputBlockCount[2]++; + } if (2 < loop_count) NOTICE_LOG(NETWORK, "ggpo_add_local_input prediction barrier reached looped %dms", loop_count * 5); break; @@ -1052,6 +1061,10 @@ void getNetworkStats(int playerNum, NetworkStats* stats) stats->extra.total_rollbacked_frames = totalRollbackFrames; stats->extra.total_timesync = totalTimeSync; stats->extra.current_timesync = timeSyncFrames; + stats->extra.current_fps = fpsAvg; + stats->extra.input_block_count[0] = inputBlockCount[0]; + stats->extra.input_block_count[1] = inputBlockCount[1]; + stats->extra.input_block_count[2] = inputBlockCount[2]; ggpo_get_network_stats(ggpoSession, playerHandles[playerNum], (GGPONetworkStats*)stats); } @@ -1068,7 +1081,8 @@ void gdxsvStartSession(const char* sessionCode, int me, cb.log_game_state = log_game_state; cb.on_message = on_message; memset(playerHandles, 0, sizeof(playerHandles)); - + disconnect_flags = 0; + inputBlockCount.fill(0); useExInput = true; localExInput = 0; analogAxes = 2; diff --git a/core/network/ggpo.h b/core/network/ggpo.h index 6f62a1deb..f8b043b79 100644 --- a/core/network/ggpo.h +++ b/core/network/ggpo.h @@ -45,6 +45,8 @@ struct NetworkStats { int total_rollbacked_frames; int total_timesync; int current_timesync; + float current_fps; + int input_block_count[3]; } extra; };