summaryrefslogtreecommitdiffstats
path: root/src/WorldStorage
diff options
context:
space:
mode:
Diffstat (limited to 'src/WorldStorage')
-rw-r--r--src/WorldStorage/StatSerializer.cpp11
-rw-r--r--src/WorldStorage/StatSerializer.h3
-rwxr-xr-xsrc/WorldStorage/WSSAnvil.cpp10
3 files changed, 15 insertions, 9 deletions
diff --git a/src/WorldStorage/StatSerializer.cpp b/src/WorldStorage/StatSerializer.cpp
index 16128966b..c8a4c0951 100644
--- a/src/WorldStorage/StatSerializer.cpp
+++ b/src/WorldStorage/StatSerializer.cpp
@@ -11,7 +11,7 @@
-cStatSerializer::cStatSerializer(const AString & a_WorldName, const AString & a_PlayerName, cStatManager * a_Manager)
+cStatSerializer::cStatSerializer(const AString & a_WorldName, const AString & a_PlayerName, const AString & a_FileName, cStatManager * a_Manager)
: m_Manager(a_Manager)
{
// Even though stats are shared between worlds, they are (usually) saved
@@ -20,7 +20,8 @@ cStatSerializer::cStatSerializer(const AString & a_WorldName, const AString & a_
AString StatsPath;
Printf(StatsPath, "%s%cstats", a_WorldName.c_str(), cFile::PathSeparator);
- m_Path = StatsPath + "/" + a_PlayerName + ".json";
+ m_LegacyPath = StatsPath + "/" + a_PlayerName + ".json";
+ m_Path = StatsPath + "/" + a_FileName + ".json";
// Ensure that the directory exists.
cFile::CreateFolder(FILE_IO_PREFIX + StatsPath);
@@ -35,7 +36,11 @@ bool cStatSerializer::Load(void)
AString Data = cFile::ReadWholeFile(FILE_IO_PREFIX + m_Path);
if (Data.empty())
{
- return false;
+ Data = cFile::ReadWholeFile(FILE_IO_PREFIX + m_LegacyPath);
+ if (Data.empty())
+ {
+ return false;
+ }
}
Json::Value Root;
diff --git a/src/WorldStorage/StatSerializer.h b/src/WorldStorage/StatSerializer.h
index 6b7efddbb..8e8e4ffdb 100644
--- a/src/WorldStorage/StatSerializer.h
+++ b/src/WorldStorage/StatSerializer.h
@@ -25,7 +25,7 @@ class cStatSerializer
{
public:
- cStatSerializer(const AString & a_WorldName, const AString & a_PlayerName, cStatManager * a_Manager);
+ cStatSerializer(const AString & a_WorldName, const AString & a_PlayerName, const AString & a_FileName, cStatManager * a_Manager);
/* Try to load the player statistics. Returns whether the operation was successful or not. */
bool Load(void);
@@ -45,6 +45,7 @@ private:
cStatManager * m_Manager;
+ AString m_LegacyPath; // The old <username>.json path to try to read from if the uuid path doesn't exist on load
AString m_Path;
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index a3251481f..158f7a819 100755
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -85,7 +85,7 @@ cWSSAnvil::cWSSAnvil(cWorld * a_World, int a_CompressionFactor) :
{
// Create a level.dat file for mapping tools, if it doesn't already exist:
AString fnam;
- Printf(fnam, "%s%clevel.dat", a_World->GetName().c_str(), cFile::PathSeparator);
+ Printf(fnam, "%s%clevel.dat", a_World->GetDataPath().c_str(), cFile::PathSeparator);
if (!cFile::Exists(fnam))
{
cFastNBTWriter Writer;
@@ -180,7 +180,7 @@ void cWSSAnvil::ChunkLoadFailed(int a_ChunkX, int a_ChunkZ, const AString & a_Re
{
// Construct the filename for offloading:
AString OffloadFileName;
- Printf(OffloadFileName, "%s%cregion%cbadchunks", m_World->GetName().c_str(), cFile::PathSeparator, cFile::PathSeparator);
+ Printf(OffloadFileName, "%s%cregion%cbadchunks", m_World->GetDataPath().c_str(), cFile::PathSeparator, cFile::PathSeparator);
cFile::CreateFolder(FILE_IO_PREFIX + OffloadFileName);
auto t = time(nullptr);
struct tm stm;
@@ -286,7 +286,7 @@ cWSSAnvil::cMCAFile * cWSSAnvil::LoadMCAFile(const cChunkCoords & a_Chunk)
// Load it anew:
AString FileName;
- Printf(FileName, "%s%cregion", m_World->GetName().c_str(), cFile::PathSeparator);
+ Printf(FileName, "%s%cregion", m_World->GetDataPath().c_str(), cFile::PathSeparator);
cFile::CreateFolder(FILE_IO_PREFIX + FileName);
AppendPrintf(FileName, "/r.%d.%d.mca", RegionX, RegionZ);
cMCAFile * f = new cMCAFile(*this, FileName, RegionX, RegionZ);
@@ -1661,7 +1661,7 @@ void cWSSAnvil::LoadOldMinecartFromNBT(cEntityList & a_Entities, const cParsedNB
void cWSSAnvil::LoadBoatFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cBoat> Boat = cpp14::make_unique<cBoat>(0, 0, 0, cBoat::bmOak);
+ std::unique_ptr<cBoat> Boat = cpp14::make_unique<cBoat>(Vector3d(), cBoat::bmOak);
if (!LoadEntityBaseFromNBT(*Boat.get(), a_NBT, a_TagIdx))
{
return;
@@ -1851,7 +1851,7 @@ void cWSSAnvil::LoadPickupFromNBT(cEntityList & a_Entities, const cParsedNBT & a
void cWSSAnvil::LoadTNTFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cTNTEntity> TNT = cpp14::make_unique<cTNTEntity>(0.0, 0.0, 0.0, 0);
+ std::unique_ptr<cTNTEntity> TNT = cpp14::make_unique<cTNTEntity>(Vector3d(), 0);
if (!LoadEntityBaseFromNBT(*TNT.get(), a_NBT, a_TagIdx))
{
return;