summaryrefslogtreecommitdiffstats
path: root/src/Protocol/Protocol_1_13.cpp
diff options
context:
space:
mode:
authornshah25 <68348722+nshah25@users.noreply.github.com>2021-05-03 22:07:09 +0200
committerGitHub <noreply@github.com>2021-05-03 22:07:09 +0200
commit8be1dd54bb17b3ba3e20960aa3c3f696d09facf7 (patch)
tree334cf9a2c9f781816f8278c933d66a71bf5c7d88 /src/Protocol/Protocol_1_13.cpp
parentStyle: specify include relativity (#5217) (diff)
downloadcuberite-8be1dd54bb17b3ba3e20960aa3c3f696d09facf7.tar
cuberite-8be1dd54bb17b3ba3e20960aa3c3f696d09facf7.tar.gz
cuberite-8be1dd54bb17b3ba3e20960aa3c3f696d09facf7.tar.bz2
cuberite-8be1dd54bb17b3ba3e20960aa3c3f696d09facf7.tar.lz
cuberite-8be1dd54bb17b3ba3e20960aa3c3f696d09facf7.tar.xz
cuberite-8be1dd54bb17b3ba3e20960aa3c3f696d09facf7.tar.zst
cuberite-8be1dd54bb17b3ba3e20960aa3c3f696d09facf7.zip
Diffstat (limited to '')
-rw-r--r--src/Protocol/Protocol_1_13.cpp47
1 files changed, 21 insertions, 26 deletions
diff --git a/src/Protocol/Protocol_1_13.cpp b/src/Protocol/Protocol_1_13.cpp
index 44a011c76..336f3c339 100644
--- a/src/Protocol/Protocol_1_13.cpp
+++ b/src/Protocol/Protocol_1_13.cpp
@@ -142,24 +142,22 @@ void cProtocol_1_13::SendScoreboardObjective(const AString & a_Name, const AStri
-void cProtocol_1_13::SendStatistics(const cStatManager & a_Manager)
+void cProtocol_1_13::SendStatistics(const StatisticsManager & a_Manager)
{
ASSERT(m_State == 3); // In game mode?
UInt32 Size = 0;
- a_Manager.ForEachStatisticType([this, &Size](const auto & Store)
+
+ for (const auto & [Statistic, Value] : a_Manager.Custom)
{
- for (const auto & Item : Store)
- {
- // Client balks at out-of-range values so there is no good default value
- // We're forced to not send the statistics this protocol version doesn't support
+ // Client balks at out-of-range values so there is no good default value.
+ // We're forced to not send the statistics this protocol version doesn't support.
- if (GetProtocolStatisticType(Item.first) != static_cast<UInt32>(-1))
- {
- Size++;
- }
+ if (GetProtocolStatisticType(Statistic) != static_cast<UInt32>(-1))
+ {
+ Size++;
}
- });
+ }
// No need to check Size != 0
// Assume that the vast majority of the time there's at least one statistic to send
@@ -167,22 +165,19 @@ void cProtocol_1_13::SendStatistics(const cStatManager & a_Manager)
cPacketizer Pkt(*this, pktStatistics);
Pkt.WriteVarInt32(Size);
- a_Manager.ForEachStatisticType([this, &Pkt](const cStatManager::CustomStore & Store)
+ for (const auto & [Statistic, Value] : a_Manager.Custom)
{
- for (const auto & Item : Store)
+ const auto ID = GetProtocolStatisticType(Statistic);
+ if (ID == static_cast<UInt32>(-1))
{
- const auto ID = GetProtocolStatisticType(Item.first);
- if (ID == static_cast<UInt32>(-1))
- {
- // Unsupported, don't send:
- continue;
- }
-
- Pkt.WriteVarInt32(8); // "Custom" category
- Pkt.WriteVarInt32(ID);
- Pkt.WriteVarInt32(static_cast<UInt32>(Item.second));
+ // Unsupported, don't send:
+ continue;
}
- });
+
+ Pkt.WriteVarInt32(8); // "Custom" category.
+ Pkt.WriteVarInt32(ID);
+ Pkt.WriteVarInt32(static_cast<UInt32>(Value));
+ }
}
@@ -588,7 +583,7 @@ UInt32 cProtocol_1_13::GetProtocolMobType(eMonsterType a_MobType) const
-UInt32 cProtocol_1_13::GetProtocolStatisticType(Statistic a_Statistic) const
+UInt32 cProtocol_1_13::GetProtocolStatisticType(const CustomStatistic a_Statistic) const
{
return Palette_1_13::From(a_Statistic);
}
@@ -1480,7 +1475,7 @@ UInt32 cProtocol_1_13_1::GetProtocolItemType(short a_ItemID, short a_ItemDamage)
-UInt32 cProtocol_1_13_1::GetProtocolStatisticType(Statistic a_Statistic) const
+UInt32 cProtocol_1_13_1::GetProtocolStatisticType(const CustomStatistic a_Statistic) const
{
return Palette_1_13_1::From(a_Statistic);
}