summaryrefslogtreecommitdiffstats
path: root/src/WorldStorage
diff options
context:
space:
mode:
Diffstat (limited to 'src/WorldStorage')
-rw-r--r--src/WorldStorage/NamespaceSerializer.cpp232
-rw-r--r--src/WorldStorage/StatSerializer.cpp207
-rwxr-xr-xsrc/WorldStorage/WSSAnvil.cpp4
3 files changed, 228 insertions, 215 deletions
diff --git a/src/WorldStorage/NamespaceSerializer.cpp b/src/WorldStorage/NamespaceSerializer.cpp
index e717e7b3e..41023caea 100644
--- a/src/WorldStorage/NamespaceSerializer.cpp
+++ b/src/WorldStorage/NamespaceSerializer.cpp
@@ -131,125 +131,129 @@ namespace NamespaceSerializer
UNREACHABLE("Tried to save unhandled statistic");
}
- static const std::unordered_map<std::string_view, Statistic> CustomStatistics
- {
- { "animals_bred", Statistic::AnimalsBred },
- { "aviate_one_cm", Statistic::AviateOneCm },
- { "bell_ring", Statistic::BellRing },
- { "boat_one_cm", Statistic::BoatOneCm },
- { "clean_armor", Statistic::CleanArmor },
- { "clean_banner", Statistic::CleanBanner },
- { "clean_shulker_box", Statistic::CleanShulkerBox },
- { "climb_one_cm", Statistic::ClimbOneCm },
- { "crouch_one_cm", Statistic::CrouchOneCm },
- { "damage_absorbed", Statistic::DamageAbsorbed },
- { "damage_blocked_by_shield", Statistic::DamageBlockedByShield },
- { "damage_dealt", Statistic::DamageDealt },
- { "damage_dealt_absorbed", Statistic::DamageDealtAbsorbed },
- { "damage_dealt_resisted", Statistic::DamageDealtResisted },
- { "damage_resisted", Statistic::DamageResisted },
- { "damage_taken", Statistic::DamageTaken },
- { "deaths", Statistic::Deaths },
- { "drop", Statistic::Drop },
- { "eat_cake_slice", Statistic::EatCakeSlice },
- { "enchant_item", Statistic::EnchantItem },
- { "fall_one_cm", Statistic::FallOneCm },
- { "fill_cauldron", Statistic::FillCauldron },
- { "fish_caught", Statistic::FishCaught },
- { "fly_one_cm", Statistic::FlyOneCm },
- { "horse_one_cm", Statistic::HorseOneCm },
- { "inspect_dispenser", Statistic::InspectDispenser },
- { "inspect_dropper", Statistic::InspectDropper },
- { "inspect_hopper", Statistic::InspectHopper },
- { "interact_with_anvil", Statistic::InteractWithAnvil },
- { "interact_with_beacon", Statistic::InteractWithBeacon },
- { "interact_with_blast_furnace", Statistic::InteractWithBlastFurnace },
- { "interact_with_brewingstand", Statistic::InteractWithBrewingstand },
- { "interact_with_campfire", Statistic::InteractWithCampfire },
- { "interact_with_cartography_table", Statistic::InteractWithCartographyTable },
- { "interact_with_crafting_table", Statistic::InteractWithCraftingTable },
- { "interact_with_furnace", Statistic::InteractWithFurnace },
- { "interact_with_grindstone", Statistic::InteractWithGrindstone },
- { "interact_with_lectern", Statistic::InteractWithLectern },
- { "interact_with_loom", Statistic::InteractWithLoom },
- { "interact_with_smithing_table", Statistic::InteractWithSmithingTable },
- { "interact_with_smoker", Statistic::InteractWithSmoker },
- { "interact_with_stonecutter", Statistic::InteractWithStonecutter },
- { "jump", Statistic::Jump },
- { "leave_game", Statistic::LeaveGame },
- { "minecart_one_cm", Statistic::MinecartOneCm },
- { "mob_kills", Statistic::MobKills },
- { "open_barrel", Statistic::OpenBarrel },
- { "open_chest", Statistic::OpenChest },
- { "open_enderchest", Statistic::OpenEnderchest },
- { "open_shulker_box", Statistic::OpenShulkerBox },
- { "pig_one_cm", Statistic::PigOneCm },
- { "play_noteblock", Statistic::PlayNoteblock },
- { "play_one_minute", Statistic::PlayOneMinute },
- { "play_record", Statistic::PlayRecord },
- { "player_kills", Statistic::PlayerKills },
- { "pot_flower", Statistic::PotFlower },
- { "raid_trigger", Statistic::RaidTrigger },
- { "raid_win", Statistic::RaidWin },
- { "sleep_in_bed", Statistic::SleepInBed },
- { "sneak_time", Statistic::SneakTime },
- { "sprint_one_cm", Statistic::SprintOneCm },
- { "strider_one_cm", Statistic::StriderOneCm },
- { "swim_one_cm", Statistic::SwimOneCm },
- { "talked_to_villager", Statistic::TalkedToVillager },
- { "target_hit", Statistic::TargetHit },
- { "time_since_death", Statistic::TimeSinceDeath },
- { "time_since_rest", Statistic::TimeSinceRest },
- { "traded_with_villager", Statistic::TradedWithVillager },
- { "trigger_trapped_chest", Statistic::TriggerTrappedChest },
- { "tune_noteblock", Statistic::TuneNoteblock },
- { "use_cauldron", Statistic::UseCauldron },
- { "walk_on_water_one_cm", Statistic::WalkOnWaterOneCm },
- { "walk_one_cm", Statistic::WalkOneCm },
- { "walk_under_water_one_cm", Statistic::WalkUnderWaterOneCm },
- // Old ones just for compatibility
- { "junk_fished", Statistic::JunkFished },
- { "treasure_fished", Statistic::TreasureFished },
- // The old advancements
- { "cuberite:achievement.openInventory", Statistic::AchOpenInventory },
- { "cuberite:achievement.mineWood", Statistic::AchMineWood },
- { "cuberite:achievement.buildWorkBench", Statistic::AchBuildWorkBench },
- { "cuberite:achievement.buildPickaxe", Statistic::AchBuildPickaxe },
- { "cuberite:achievement.buildFurnace", Statistic::AchBuildFurnace },
- { "cuberite:achievement.acquireIron", Statistic::AchAcquireIron },
- { "cuberite:achievement.buildHoe", Statistic::AchBuildHoe },
- { "cuberite:achievement.makeBread", Statistic::AchMakeBread },
- { "cuberite:achievement.bakeCake", Statistic::AchBakeCake },
- { "cuberite:achievement.buildBetterPickaxe", Statistic::AchBuildBetterPickaxe },
- { "cuberite:achievement.cookFish", Statistic::AchCookFish },
- { "cuberite:achievement.onARail", Statistic::AchOnARail },
- { "cuberite:achievement.buildSword", Statistic::AchBuildSword },
- { "cuberite:achievement.killEnemy", Statistic::AchKillEnemy },
- { "cuberite:achievement.killCow", Statistic::AchKillCow },
- { "cuberite:achievement.flyPig", Statistic::AchFlyPig },
- { "cuberite:achievement.snipeSkeleton", Statistic::AchSnipeSkeleton },
- { "cuberite:achievement.diamonds", Statistic::AchDiamonds },
- { "cuberite:achievement.portal", Statistic::AchPortal },
- { "cuberite:achievement.ghast", Statistic::AchGhast },
- { "cuberite:achievement.blazeRod", Statistic::AchBlazeRod },
- { "cuberite:achievement.potion", Statistic::AchPotion },
- { "cuberite:achievement.theEnd", Statistic::AchTheEnd },
- { "cuberite:achievement.theEnd2", Statistic::AchTheEnd2 },
- { "cuberite:achievement.enchantments", Statistic::AchEnchantments },
- { "cuberite:achievement.overkill", Statistic::AchOverkill },
- { "cuberite:achievement.bookcase", Statistic::AchBookcase },
- { "cuberite:achievement.exploreAllBiomes", Statistic::AchExploreAllBiomes },
- { "cuberite:achievement.spawnWither", Statistic::AchSpawnWither },
- { "cuberite:achievement.killWither", Statistic::AchKillWither },
- { "cuberite:achievement.fullBeacon", Statistic::AchFullBeacon },
- { "cuberite:achievement.breedCow", Statistic::AchBreedCow },
- { "cuberite:achievement.diamondsToYou", Statistic::AchDiamondsToYou}
- };
+
Statistic ToCustomStatistic(const std::string_view ID)
{
+ static const std::unordered_map<std::string_view, Statistic> CustomStatistics
+ {
+ { "animals_bred", Statistic::AnimalsBred },
+ { "aviate_one_cm", Statistic::AviateOneCm },
+ { "bell_ring", Statistic::BellRing },
+ { "boat_one_cm", Statistic::BoatOneCm },
+ { "clean_armor", Statistic::CleanArmor },
+ { "clean_banner", Statistic::CleanBanner },
+ { "clean_shulker_box", Statistic::CleanShulkerBox },
+ { "climb_one_cm", Statistic::ClimbOneCm },
+ { "crouch_one_cm", Statistic::CrouchOneCm },
+ { "damage_absorbed", Statistic::DamageAbsorbed },
+ { "damage_blocked_by_shield", Statistic::DamageBlockedByShield },
+ { "damage_dealt", Statistic::DamageDealt },
+ { "damage_dealt_absorbed", Statistic::DamageDealtAbsorbed },
+ { "damage_dealt_resisted", Statistic::DamageDealtResisted },
+ { "damage_resisted", Statistic::DamageResisted },
+ { "damage_taken", Statistic::DamageTaken },
+ { "deaths", Statistic::Deaths },
+ { "drop", Statistic::Drop },
+ { "eat_cake_slice", Statistic::EatCakeSlice },
+ { "enchant_item", Statistic::EnchantItem },
+ { "fall_one_cm", Statistic::FallOneCm },
+ { "fill_cauldron", Statistic::FillCauldron },
+ { "fish_caught", Statistic::FishCaught },
+ { "fly_one_cm", Statistic::FlyOneCm },
+ { "horse_one_cm", Statistic::HorseOneCm },
+ { "inspect_dispenser", Statistic::InspectDispenser },
+ { "inspect_dropper", Statistic::InspectDropper },
+ { "inspect_hopper", Statistic::InspectHopper },
+ { "interact_with_anvil", Statistic::InteractWithAnvil },
+ { "interact_with_beacon", Statistic::InteractWithBeacon },
+ { "interact_with_blast_furnace", Statistic::InteractWithBlastFurnace },
+ { "interact_with_brewingstand", Statistic::InteractWithBrewingstand },
+ { "interact_with_campfire", Statistic::InteractWithCampfire },
+ { "interact_with_cartography_table", Statistic::InteractWithCartographyTable },
+ { "interact_with_crafting_table", Statistic::InteractWithCraftingTable },
+ { "interact_with_furnace", Statistic::InteractWithFurnace },
+ { "interact_with_grindstone", Statistic::InteractWithGrindstone },
+ { "interact_with_lectern", Statistic::InteractWithLectern },
+ { "interact_with_loom", Statistic::InteractWithLoom },
+ { "interact_with_smithing_table", Statistic::InteractWithSmithingTable },
+ { "interact_with_smoker", Statistic::InteractWithSmoker },
+ { "interact_with_stonecutter", Statistic::InteractWithStonecutter },
+ { "jump", Statistic::Jump },
+ { "leave_game", Statistic::LeaveGame },
+ { "minecart_one_cm", Statistic::MinecartOneCm },
+ { "mob_kills", Statistic::MobKills },
+ { "open_barrel", Statistic::OpenBarrel },
+ { "open_chest", Statistic::OpenChest },
+ { "open_enderchest", Statistic::OpenEnderchest },
+ { "open_shulker_box", Statistic::OpenShulkerBox },
+ { "pig_one_cm", Statistic::PigOneCm },
+ { "play_noteblock", Statistic::PlayNoteblock },
+ { "play_one_minute", Statistic::PlayOneMinute },
+ { "play_record", Statistic::PlayRecord },
+ { "player_kills", Statistic::PlayerKills },
+ { "pot_flower", Statistic::PotFlower },
+ { "raid_trigger", Statistic::RaidTrigger },
+ { "raid_win", Statistic::RaidWin },
+ { "sleep_in_bed", Statistic::SleepInBed },
+ { "sneak_time", Statistic::SneakTime },
+ { "sprint_one_cm", Statistic::SprintOneCm },
+ { "strider_one_cm", Statistic::StriderOneCm },
+ { "swim_one_cm", Statistic::SwimOneCm },
+ { "talked_to_villager", Statistic::TalkedToVillager },
+ { "target_hit", Statistic::TargetHit },
+ { "time_since_death", Statistic::TimeSinceDeath },
+ { "time_since_rest", Statistic::TimeSinceRest },
+ { "traded_with_villager", Statistic::TradedWithVillager },
+ { "trigger_trapped_chest", Statistic::TriggerTrappedChest },
+ { "tune_noteblock", Statistic::TuneNoteblock },
+ { "use_cauldron", Statistic::UseCauldron },
+ { "walk_on_water_one_cm", Statistic::WalkOnWaterOneCm },
+ { "walk_one_cm", Statistic::WalkOneCm },
+ { "walk_under_water_one_cm", Statistic::WalkUnderWaterOneCm },
+
+ // Old ones just for compatibility
+ { "junk_fished", Statistic::JunkFished },
+ { "treasure_fished", Statistic::TreasureFished },
+
+ // The old advancements
+ { "cuberite:achievement.openInventory", Statistic::AchOpenInventory },
+ { "cuberite:achievement.mineWood", Statistic::AchMineWood },
+ { "cuberite:achievement.buildWorkBench", Statistic::AchBuildWorkBench },
+ { "cuberite:achievement.buildPickaxe", Statistic::AchBuildPickaxe },
+ { "cuberite:achievement.buildFurnace", Statistic::AchBuildFurnace },
+ { "cuberite:achievement.acquireIron", Statistic::AchAcquireIron },
+ { "cuberite:achievement.buildHoe", Statistic::AchBuildHoe },
+ { "cuberite:achievement.makeBread", Statistic::AchMakeBread },
+ { "cuberite:achievement.bakeCake", Statistic::AchBakeCake },
+ { "cuberite:achievement.buildBetterPickaxe", Statistic::AchBuildBetterPickaxe },
+ { "cuberite:achievement.cookFish", Statistic::AchCookFish },
+ { "cuberite:achievement.onARail", Statistic::AchOnARail },
+ { "cuberite:achievement.buildSword", Statistic::AchBuildSword },
+ { "cuberite:achievement.killEnemy", Statistic::AchKillEnemy },
+ { "cuberite:achievement.killCow", Statistic::AchKillCow },
+ { "cuberite:achievement.flyPig", Statistic::AchFlyPig },
+ { "cuberite:achievement.snipeSkeleton", Statistic::AchSnipeSkeleton },
+ { "cuberite:achievement.diamonds", Statistic::AchDiamonds },
+ { "cuberite:achievement.portal", Statistic::AchPortal },
+ { "cuberite:achievement.ghast", Statistic::AchGhast },
+ { "cuberite:achievement.blazeRod", Statistic::AchBlazeRod },
+ { "cuberite:achievement.potion", Statistic::AchPotion },
+ { "cuberite:achievement.theEnd", Statistic::AchTheEnd },
+ { "cuberite:achievement.theEnd2", Statistic::AchTheEnd2 },
+ { "cuberite:achievement.enchantments", Statistic::AchEnchantments },
+ { "cuberite:achievement.overkill", Statistic::AchOverkill },
+ { "cuberite:achievement.bookcase", Statistic::AchBookcase },
+ { "cuberite:achievement.exploreAllBiomes", Statistic::AchExploreAllBiomes },
+ { "cuberite:achievement.spawnWither", Statistic::AchSpawnWither },
+ { "cuberite:achievement.killWither", Statistic::AchKillWither },
+ { "cuberite:achievement.fullBeacon", Statistic::AchFullBeacon },
+ { "cuberite:achievement.breedCow", Statistic::AchBreedCow },
+ { "cuberite:achievement.diamondsToYou", Statistic::AchDiamondsToYou}
+ };
+
return CustomStatistics.at(ID);
}
diff --git a/src/WorldStorage/StatSerializer.cpp b/src/WorldStorage/StatSerializer.cpp
index 95652a8d7..11b5ffbf9 100644
--- a/src/WorldStorage/StatSerializer.cpp
+++ b/src/WorldStorage/StatSerializer.cpp
@@ -4,6 +4,7 @@
#include "Globals.h"
#include "../Statistics.h"
+#include "StatSerializer.h"
#include "NamespaceSerializer.h"
#include <json/json.h>
@@ -12,100 +13,9 @@
-// Upgrade mapping from pre-1.13 names. TODO: remove on 2020-09-18
-static const std::unordered_map<std::string_view, Statistic> LegacyMapping
-{
- { "achievement.openInventory", Statistic::AchOpenInventory },
- { "achievement.mineWood", Statistic::AchMineWood },
- { "achievement.buildWorkBench", Statistic::AchBuildWorkBench },
- { "achievement.buildPickaxe", Statistic::AchBuildPickaxe },
- { "achievement.buildFurnace", Statistic::AchBuildFurnace },
- { "achievement.acquireIron", Statistic::AchAcquireIron },
- { "achievement.buildHoe", Statistic::AchBuildHoe },
- { "achievement.makeBread", Statistic::AchMakeBread },
- { "achievement.bakeCake", Statistic::AchBakeCake },
- { "achievement.buildBetterPickaxe", Statistic::AchBuildBetterPickaxe },
- { "achievement.cookFish", Statistic::AchCookFish },
- { "achievement.onARail", Statistic::AchOnARail },
- { "achievement.buildSword", Statistic::AchBuildSword },
- { "achievement.killEnemy", Statistic::AchKillEnemy },
- { "achievement.killCow", Statistic::AchKillCow },
- { "achievement.flyPig", Statistic::AchFlyPig },
- { "achievement.snipeSkeleton", Statistic::AchSnipeSkeleton },
- { "achievement.diamonds", Statistic::AchDiamonds },
- { "achievement.portal", Statistic::AchPortal },
- { "achievement.ghast", Statistic::AchGhast },
- { "achievement.blazeRod", Statistic::AchBlazeRod },
- { "achievement.potion", Statistic::AchPotion },
- { "achievement.theEnd", Statistic::AchTheEnd },
- { "achievement.theEnd2", Statistic::AchTheEnd2 },
- { "achievement.enchantments", Statistic::AchEnchantments },
- { "achievement.overkill", Statistic::AchOverkill },
- { "achievement.bookcase", Statistic::AchBookcase },
- { "achievement.exploreAllBiomes", Statistic::AchExploreAllBiomes },
- { "achievement.spawnWither", Statistic::AchSpawnWither },
- { "achievement.killWither", Statistic::AchKillWither },
- { "achievement.fullBeacon", Statistic::AchFullBeacon },
- { "achievement.breedCow", Statistic::AchBreedCow },
- { "achievement.diamondsToYou", Statistic::AchDiamondsToYou },
- { "stat.animalsBred", Statistic::AnimalsBred },
- { "stat.boatOneCm", Statistic::BoatOneCm },
- { "stat.climbOneCm", Statistic::ClimbOneCm },
- { "stat.crouchOneCm", Statistic::CrouchOneCm },
- { "stat.damageDealt", Statistic::DamageDealt },
- { "stat.damageTaken", Statistic::DamageTaken },
- { "stat.deaths", Statistic::Deaths },
- { "stat.drop", Statistic::Drop },
- { "stat.fallOneCm", Statistic::FallOneCm },
- { "stat.fishCaught", Statistic::FishCaught },
- { "stat.flyOneCm", Statistic::FlyOneCm },
- { "stat.horseOneCm", Statistic::HorseOneCm },
- { "stat.jump", Statistic::Jump },
- { "stat.leaveGame", Statistic::LeaveGame },
- { "stat.minecartOneCm", Statistic::MinecartOneCm },
- { "stat.mobKills", Statistic::MobKills },
- { "stat.pigOneCm", Statistic::PigOneCm },
- { "stat.playerKills", Statistic::PlayerKills },
- { "stat.playOneMinute", Statistic::PlayOneMinute },
- { "stat.sprintOneCm", Statistic::SprintOneCm },
- { "stat.swimOneCm", Statistic::SwimOneCm },
- { "stat.talkedToVillager", Statistic::TalkedToVillager },
- { "stat.timeSinceDeath", Statistic::TimeSinceDeath },
- { "stat.tradedWithVillager", Statistic::TradedWithVillager },
- { "stat.walkOneCm", Statistic::WalkOneCm },
- { "stat.diveOneCm", Statistic::WalkUnderWaterOneCm },
- { "stat.armorCleaned", Statistic::CleanArmor },
- { "stat.bannerCleaned", Statistic::CleanBanner },
- { "stat.cakeSlicesEaten", Statistic::EatCakeSlice },
- { "stat.itemEnchanted", Statistic::EnchantItem },
- { "stat.cauldronFilled", Statistic::FillCauldron },
- { "stat.dispenserInspected", Statistic::InspectDispenser },
- { "stat.dropperInspected", Statistic::InspectDropper },
- { "stat.hopperInspected", Statistic::InspectHopper },
- { "stat.beaconInteraction", Statistic::InteractWithBeacon },
- { "stat.brewingstandInteraction", Statistic::InteractWithBrewingstand },
- { "stat.craftingTableInteraction", Statistic::InteractWithCraftingTable },
- { "stat.furnaceInteraction", Statistic::InteractWithFurnace },
- { "stat.chestOpened", Statistic::OpenChest },
- { "stat.enderchestOpened", Statistic::OpenEnderchest },
- { "stat.noteblockPlayed", Statistic::PlayNoteblock },
- { "stat.recordPlayed", Statistic::PlayRecord },
- { "stat.flowerPotted", Statistic::PotFlower },
- { "stat.trappedChestTriggered", Statistic::TriggerTrappedChest },
- { "stat.noteblockTuned", Statistic::TuneNoteblock },
- { "stat.cauldronUsed", Statistic::UseCauldron },
- { "stat.aviateOneCm", Statistic::AviateOneCm },
- { "stat.sleepInBed", Statistic::SleepInBed },
- { "stat.sneakTime", Statistic::SneakTime }
-};
-
-
-
-
-
namespace StatSerializer
{
- auto MakeStatisticsDirectory(const std::string & WorldPath, std::string && FileName)
+ static auto MakeStatisticsDirectory(const std::string & WorldPath, std::string && FileName)
{
// Even though stats are shared between worlds, they are (usually) saved
// inside the folder of the default world.
@@ -123,7 +33,7 @@ namespace StatSerializer
- void SaveStatToJSON(const cStatManager & Manager, Json::Value & a_Out)
+ static void SaveStatToJSON(const cStatManager & Manager, Json::Value & a_Out)
{
Manager.ForEachStatisticType([&a_Out](const cStatManager::CustomStore & Store)
{
@@ -145,8 +55,95 @@ namespace StatSerializer
- void LoadLegacyFromJSON(cStatManager & Manager, const Json::Value & In)
+ static void LoadLegacyFromJSON(cStatManager & Manager, const Json::Value & In)
{
+ // Upgrade mapping from pre-1.13 names. TODO: remove on 2020-09-18
+ static const std::unordered_map<std::string_view, Statistic> LegacyMapping
+ {
+ { "achievement.openInventory", Statistic::AchOpenInventory },
+ { "achievement.mineWood", Statistic::AchMineWood },
+ { "achievement.buildWorkBench", Statistic::AchBuildWorkBench },
+ { "achievement.buildPickaxe", Statistic::AchBuildPickaxe },
+ { "achievement.buildFurnace", Statistic::AchBuildFurnace },
+ { "achievement.acquireIron", Statistic::AchAcquireIron },
+ { "achievement.buildHoe", Statistic::AchBuildHoe },
+ { "achievement.makeBread", Statistic::AchMakeBread },
+ { "achievement.bakeCake", Statistic::AchBakeCake },
+ { "achievement.buildBetterPickaxe", Statistic::AchBuildBetterPickaxe },
+ { "achievement.cookFish", Statistic::AchCookFish },
+ { "achievement.onARail", Statistic::AchOnARail },
+ { "achievement.buildSword", Statistic::AchBuildSword },
+ { "achievement.killEnemy", Statistic::AchKillEnemy },
+ { "achievement.killCow", Statistic::AchKillCow },
+ { "achievement.flyPig", Statistic::AchFlyPig },
+ { "achievement.snipeSkeleton", Statistic::AchSnipeSkeleton },
+ { "achievement.diamonds", Statistic::AchDiamonds },
+ { "achievement.portal", Statistic::AchPortal },
+ { "achievement.ghast", Statistic::AchGhast },
+ { "achievement.blazeRod", Statistic::AchBlazeRod },
+ { "achievement.potion", Statistic::AchPotion },
+ { "achievement.theEnd", Statistic::AchTheEnd },
+ { "achievement.theEnd2", Statistic::AchTheEnd2 },
+ { "achievement.enchantments", Statistic::AchEnchantments },
+ { "achievement.overkill", Statistic::AchOverkill },
+ { "achievement.bookcase", Statistic::AchBookcase },
+ { "achievement.exploreAllBiomes", Statistic::AchExploreAllBiomes },
+ { "achievement.spawnWither", Statistic::AchSpawnWither },
+ { "achievement.killWither", Statistic::AchKillWither },
+ { "achievement.fullBeacon", Statistic::AchFullBeacon },
+ { "achievement.breedCow", Statistic::AchBreedCow },
+ { "achievement.diamondsToYou", Statistic::AchDiamondsToYou },
+ { "stat.animalsBred", Statistic::AnimalsBred },
+ { "stat.boatOneCm", Statistic::BoatOneCm },
+ { "stat.climbOneCm", Statistic::ClimbOneCm },
+ { "stat.crouchOneCm", Statistic::CrouchOneCm },
+ { "stat.damageDealt", Statistic::DamageDealt },
+ { "stat.damageTaken", Statistic::DamageTaken },
+ { "stat.deaths", Statistic::Deaths },
+ { "stat.drop", Statistic::Drop },
+ { "stat.fallOneCm", Statistic::FallOneCm },
+ { "stat.fishCaught", Statistic::FishCaught },
+ { "stat.flyOneCm", Statistic::FlyOneCm },
+ { "stat.horseOneCm", Statistic::HorseOneCm },
+ { "stat.jump", Statistic::Jump },
+ { "stat.leaveGame", Statistic::LeaveGame },
+ { "stat.minecartOneCm", Statistic::MinecartOneCm },
+ { "stat.mobKills", Statistic::MobKills },
+ { "stat.pigOneCm", Statistic::PigOneCm },
+ { "stat.playerKills", Statistic::PlayerKills },
+ { "stat.playOneMinute", Statistic::PlayOneMinute },
+ { "stat.sprintOneCm", Statistic::SprintOneCm },
+ { "stat.swimOneCm", Statistic::SwimOneCm },
+ { "stat.talkedToVillager", Statistic::TalkedToVillager },
+ { "stat.timeSinceDeath", Statistic::TimeSinceDeath },
+ { "stat.tradedWithVillager", Statistic::TradedWithVillager },
+ { "stat.walkOneCm", Statistic::WalkOneCm },
+ { "stat.diveOneCm", Statistic::WalkUnderWaterOneCm },
+ { "stat.armorCleaned", Statistic::CleanArmor },
+ { "stat.bannerCleaned", Statistic::CleanBanner },
+ { "stat.cakeSlicesEaten", Statistic::EatCakeSlice },
+ { "stat.itemEnchanted", Statistic::EnchantItem },
+ { "stat.cauldronFilled", Statistic::FillCauldron },
+ { "stat.dispenserInspected", Statistic::InspectDispenser },
+ { "stat.dropperInspected", Statistic::InspectDropper },
+ { "stat.hopperInspected", Statistic::InspectHopper },
+ { "stat.beaconInteraction", Statistic::InteractWithBeacon },
+ { "stat.brewingstandInteraction", Statistic::InteractWithBrewingstand },
+ { "stat.craftingTableInteraction", Statistic::InteractWithCraftingTable },
+ { "stat.furnaceInteraction", Statistic::InteractWithFurnace },
+ { "stat.chestOpened", Statistic::OpenChest },
+ { "stat.enderchestOpened", Statistic::OpenEnderchest },
+ { "stat.noteblockPlayed", Statistic::PlayNoteblock },
+ { "stat.recordPlayed", Statistic::PlayRecord },
+ { "stat.flowerPotted", Statistic::PotFlower },
+ { "stat.trappedChestTriggered", Statistic::TriggerTrappedChest },
+ { "stat.noteblockTuned", Statistic::TuneNoteblock },
+ { "stat.cauldronUsed", Statistic::UseCauldron },
+ { "stat.aviateOneCm", Statistic::AviateOneCm },
+ { "stat.sleepInBed", Statistic::SleepInBed },
+ { "stat.sneakTime", Statistic::SneakTime }
+ };
+
for (auto Entry = In.begin(); Entry != In.end(); ++Entry)
{
const auto & Key = Entry.key().asString();
@@ -154,7 +151,13 @@ namespace StatSerializer
if ((FindResult != LegacyMapping.end()) && Entry->isInt())
{
- Manager.SetValue(FindResult->second, Entry->asInt());
+ auto Value = Entry->asInt();
+ if (Value < 0)
+ {
+ FLOGWARNING("Invalid stat value: {0} = {1}", Key, Value);
+ continue;
+ }
+ Manager.SetValue(FindResult->second, ToUnsigned(Value));
}
}
}
@@ -163,7 +166,7 @@ namespace StatSerializer
- void LoadCustomStatFromJSON(cStatManager & Manager, const Json::Value & a_In)
+ static void LoadCustomStatFromJSON(cStatManager & Manager, const Json::Value & a_In)
{
for (auto it = a_In.begin(); it != a_In.end(); ++it)
{
@@ -178,13 +181,19 @@ namespace StatSerializer
const auto & StatName = StatInfo.second;
try
{
- Manager.SetValue(NamespaceSerializer::ToCustomStatistic(StatName), it->asInt());
+ auto Value = it->asInt();
+ if (Value < 0)
+ {
+ FLOGWARNING("Invalid statistic value: {0} = {1}", Key, Value);
+ continue;
+ }
+ Manager.SetValue(NamespaceSerializer::ToCustomStatistic(StatName), ToUnsigned(Value));
}
- catch (const std::out_of_range & Oops)
+ catch (const std::out_of_range &)
{
FLOGWARNING("Invalid statistic type \"{}\"", StatName);
}
- catch (const Json::LogicError & Oops)
+ catch (const Json::LogicError &)
{
FLOGWARNING("Invalid statistic value for type \"{}\"", StatName);
}
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index 03decbea3..f822f9375 100755
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -1450,7 +1450,7 @@ OwnedBlockEntity cWSSAnvil::LoadNoteBlockFromNBT(const cParsedNBT & a_NBT, int a
int note = a_NBT.FindChildByName(a_TagIdx, "note");
if (note >= 0)
{
- NoteBlock->SetNote(static_cast<char>(a_NBT.GetByte(note)));
+ NoteBlock->SetNote(a_NBT.GetByte(note));
}
return NoteBlock;
}
@@ -1856,7 +1856,7 @@ void cWSSAnvil::LoadTNTFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NB
int FuseTicks = a_NBT.FindChildByName(a_TagIdx, "Fuse");
if (FuseTicks > 0)
{
- TNT->SetFuseTicks(static_cast<int>(a_NBT.GetByte(FuseTicks)));
+ TNT->SetFuseTicks(a_NBT.GetByte(FuseTicks));
}
a_Entities.emplace_back(std::move(TNT));