summaryrefslogtreecommitdiffstats
path: root/src/Protocol/Protocol_1_8.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Protocol/Protocol_1_8.cpp130
1 files changed, 119 insertions, 11 deletions
diff --git a/src/Protocol/Protocol_1_8.cpp b/src/Protocol/Protocol_1_8.cpp
index e865725ea..3474ed718 100644
--- a/src/Protocol/Protocol_1_8.cpp
+++ b/src/Protocol/Protocol_1_8.cpp
@@ -19,7 +19,6 @@ Implements the 1.8 protocol classes:
#include "../EffectID.h"
#include "../StringCompression.h"
#include "../CompositeChat.h"
-#include "../Statistics.h"
#include "../UUID.h"
#include "../World.h"
#include "../JsonUtils.h"
@@ -1421,18 +1420,26 @@ void cProtocol_1_8_0::SendStatistics(const cStatManager & a_Manager)
{
ASSERT(m_State == 3); // In game mode?
+ UInt32 Size = 0;
+ a_Manager.ForEachStatisticType([&Size](const auto & Store)
+ {
+ Size += static_cast<UInt32>(Store.size());
+ });
+
+ // No need to check Size != 0
+ // Assume that the vast majority of the time there's at least one statistic to send
+
cPacketizer Pkt(*this, pktStatistics);
- Pkt.WriteVarInt32(statCount); // TODO 2014-05-11 xdot: Optimization: Send "dirty" statistics only
+ Pkt.WriteVarInt32(Size);
- size_t Count = static_cast<size_t>(statCount);
- for (size_t i = 0; i < Count; ++i)
+ a_Manager.ForEachStatisticType([&Pkt](const cStatManager::CustomStore & Store)
{
- StatValue Value = a_Manager.GetValue(static_cast<eStatistic>(i));
- const AString & StatName = cStatInfo::GetName(static_cast<eStatistic>(i));
-
- Pkt.WriteString(StatName);
- Pkt.WriteVarInt32(static_cast<UInt32>(Value));
- }
+ for (const auto & Item : Store)
+ {
+ Pkt.WriteString(GetProtocolStatisticName(Item.first));
+ Pkt.WriteVarInt32(static_cast<UInt32>(Item.second));
+ }
+ });
}
@@ -2565,7 +2572,7 @@ void cProtocol_1_8_0::HandlePacketClientStatus(cByteBuffer & a_ByteBuffer)
case 2:
{
// Open Inventory achievement
- m_Client->GetPlayer()->AwardAchievement(achOpenInv);
+ m_Client->GetPlayer()->AwardAchievement(Statistic::AchOpenInventory);
break;
}
}
@@ -3968,3 +3975,104 @@ UInt8 cProtocol_1_8_0::GetProtocolEntityType(const cEntity & a_Entity)
}
UNREACHABLE("Unhandled entity kind");
}
+
+
+
+
+
+const char * cProtocol_1_8_0::GetProtocolStatisticName(Statistic a_Statistic)
+{
+ switch (a_Statistic)
+ {
+ // V1.8 Achievements
+ case Statistic::AchOpenInventory: return "achievement.openInventory";
+ case Statistic::AchMineWood: return "achievement.mineWood";
+ case Statistic::AchBuildWorkBench: return "achievement.buildWorkBench";
+ case Statistic::AchBuildPickaxe: return "achievement.buildPickaxe";
+ case Statistic::AchBuildFurnace: return "achievement.buildFurnace";
+ case Statistic::AchAcquireIron: return "achievement.acquireIron";
+ case Statistic::AchBuildHoe: return "achievement.buildHoe";
+ case Statistic::AchMakeBread: return "achievement.makeBread";
+ case Statistic::AchBakeCake: return "achievement.bakeCake";
+ case Statistic::AchBuildBetterPickaxe: return "achievement.buildBetterPickaxe";
+ case Statistic::AchCookFish: return "achievement.cookFish";
+ case Statistic::AchOnARail: return "achievement.onARail";
+ case Statistic::AchBuildSword: return "achievement.buildSword";
+ case Statistic::AchKillEnemy: return "achievement.killEnemy";
+ case Statistic::AchKillCow: return "achievement.killCow";
+ case Statistic::AchFlyPig: return "achievement.flyPig";
+ case Statistic::AchSnipeSkeleton: return "achievement.snipeSkeleton";
+ case Statistic::AchDiamonds: return "achievement.diamonds";
+ case Statistic::AchPortal: return "achievement.portal";
+ case Statistic::AchGhast: return "achievement.ghast";
+ case Statistic::AchBlazeRod: return "achievement.blazeRod";
+ case Statistic::AchPotion: return "achievement.potion";
+ case Statistic::AchTheEnd: return "achievement.theEnd";
+ case Statistic::AchTheEnd2: return "achievement.theEnd2";
+ case Statistic::AchEnchantments: return "achievement.enchantments";
+ case Statistic::AchOverkill: return "achievement.overkill";
+ case Statistic::AchBookcase: return "achievement.bookcase";
+ case Statistic::AchExploreAllBiomes: return "achievement.exploreAllBiomes";
+ case Statistic::AchSpawnWither: return "achievement.spawnWither";
+ case Statistic::AchKillWither: return "achievement.killWither";
+ case Statistic::AchFullBeacon: return "achievement.fullBeacon";
+ case Statistic::AchBreedCow: return "achievement.breedCow";
+ case Statistic::AchDiamondsToYou: return "achievement.diamondsToYou";
+
+ // V1.8 stats
+ case Statistic::AnimalsBred: return "stat.animalsBred";
+ case Statistic::BoatOneCm: return "stat.boatOneCm";
+ case Statistic::ClimbOneCm: return "stat.climbOneCm";
+ case Statistic::CrouchOneCm: return "stat.crouchOneCm";
+ case Statistic::DamageDealt: return "stat.damageDealt";
+ case Statistic::DamageTaken: return "stat.damageTaken";
+ case Statistic::Deaths: return "stat.deaths";
+ case Statistic::Drop: return "stat.drop";
+ case Statistic::FallOneCm: return "stat.fallOneCm";
+ case Statistic::FishCaught: return "stat.fishCaught";
+ case Statistic::FlyOneCm: return "stat.flyOneCm";
+ case Statistic::HorseOneCm: return "stat.horseOneCm";
+ case Statistic::Jump: return "stat.jump";
+ case Statistic::LeaveGame: return "stat.leaveGame";
+ case Statistic::MinecartOneCm: return "stat.minecartOneCm";
+ case Statistic::MobKills: return "stat.mobKills";
+ case Statistic::PigOneCm: return "stat.pigOneCm";
+ case Statistic::PlayerKills: return "stat.playerKills";
+ case Statistic::PlayOneMinute: return "stat.playOneMinute";
+ case Statistic::SprintOneCm: return "stat.sprintOneCm";
+ case Statistic::SwimOneCm: return "stat.swimOneCm";
+ case Statistic::TalkedToVillager: return "stat.talkedToVillager";
+ case Statistic::TimeSinceDeath: return "stat.timeSinceDeath";
+ case Statistic::TradedWithVillager: return "stat.tradedWithVillager";
+ case Statistic::WalkOneCm: return "stat.walkOneCm";
+ case Statistic::WalkUnderWaterOneCm: return "stat.diveOneCm";
+
+ // V1.8.2 stats
+ case Statistic::CleanArmor: return "stat.armorCleaned";
+ case Statistic::CleanBanner: return "stat.bannerCleaned";
+ case Statistic::EatCakeSlice: return "stat.cakeSlicesEaten";
+ case Statistic::EnchantItem: return "stat.itemEnchanted";
+ case Statistic::FillCauldron: return "stat.cauldronFilled";
+ case Statistic::InspectDispenser: return "stat.dispenserInspected";
+ case Statistic::InspectDropper: return "stat.dropperInspected";
+ case Statistic::InspectHopper: return "stat.hopperInspected";
+ case Statistic::InteractWithBeacon: return "stat.beaconInteraction";
+ case Statistic::InteractWithBrewingstand: return "stat.brewingstandInteraction";
+ case Statistic::InteractWithCraftingTable: return "stat.craftingTableInteraction";
+ case Statistic::InteractWithFurnace: return "stat.furnaceInteraction";
+ case Statistic::OpenChest: return "stat.chestOpened";
+ case Statistic::OpenEnderchest: return "stat.enderchestOpened";
+ case Statistic::PlayNoteblock: return "stat.noteblockPlayed";
+ case Statistic::PlayRecord: return "stat.recordPlayed";
+ case Statistic::PotFlower: return "stat.flowerPotted";
+ case Statistic::TriggerTrappedChest: return "stat.trappedChestTriggered";
+ case Statistic::TuneNoteblock: return "stat.noteblockTuned";
+ case Statistic::UseCauldron: return "stat.cauldronUsed";
+
+ // V1.9 stats
+ case Statistic::AviateOneCm: return "stat.aviateOneCm";
+ case Statistic::SleepInBed: return "stat.sleepInBed";
+ case Statistic::SneakTime: return "stat.sneakTime";
+ default: return "";
+ }
+}