refactor: unglob std::wstring

This commit is contained in:
Tropical
2026-03-06 11:50:22 -06:00
parent 41db813a6d
commit cdc08700e4
581 changed files with 2156 additions and 2154 deletions
+1 -1
View File
@@ -58,7 +58,7 @@ TilePos ChunkPos::getMiddleBlockPosition(int y)
return TilePos(getMiddleBlockX(), y, getMiddleBlockZ());
}
wstring ChunkPos::toString()
std::wstring ChunkPos::toString()
{
return L"[" + _toString<int>(x) + L", " + _toString<int>(z) + L"]";
}
+1 -1
View File
@@ -20,7 +20,7 @@ public:
int getMiddleBlockZ();
TilePos getMiddleBlockPosition(int y);
wstring toString();
std::wstring toString();
static __int64 hash_fnct(const ChunkPos &k);
static bool eq_test(const ChunkPos &x, const ChunkPos &y);
+2 -2
View File
@@ -60,8 +60,8 @@ public:
/**
* Returns some stats that are rendered when the user holds F3.
*/
virtual wstring gatherStats() = 0;
virtual std::wstring gatherStats() = 0;
virtual vector<Biome::MobSpawnerData *> *getMobsAt(MobCategory *mobCategory, int x, int y, int z) = 0;
virtual TilePos *findNearestMapFeature(Level *level, const wstring& featureName, int x, int y, int z) = 0;
virtual TilePos *findNearestMapFeature(Level *level, const std::wstring& featureName, int x, int y, int z) = 0;
};
+4 -4
View File
@@ -20,7 +20,7 @@ CustomLevelSource::CustomLevelSource(Level *level, __int64 seed, bool generateSt
m_heightmapOverride = byteArray( (m_XZSize*16) * (m_XZSize*16) );
#ifdef _UNICODE
wstring path = L"GAME:\\GameRules\\heightmap.bin";
std::wstring path = L"GAME:\\GameRules\\heightmap.bin";
#else
#ifdef _WINDOWS64
@@ -62,7 +62,7 @@ CustomLevelSource::CustomLevelSource(Level *level, __int64 seed, bool generateSt
m_waterheightOverride = byteArray( (m_XZSize*16) * (m_XZSize*16) );
#ifdef _UNICODE
wstring waterHeightPath = L"GAME:\\GameRules\\waterheight.bin";
std::wstring waterHeightPath = L"GAME:\\GameRules\\waterheight.bin";
#else
#ifdef _WINDOWS64
@@ -609,7 +609,7 @@ bool CustomLevelSource::shouldSave()
return true;
}
wstring CustomLevelSource::gatherStats()
std::wstring CustomLevelSource::gatherStats()
{
return L"CustomLevelSource";
}
@@ -628,7 +628,7 @@ vector<Biome::MobSpawnerData *> *CustomLevelSource::getMobsAt(MobCategory *mobCa
#endif
}
TilePos *CustomLevelSource::findNearestMapFeature(Level *level, const wstring& featureName, int x, int y, int z)
TilePos *CustomLevelSource::findNearestMapFeature(Level *level, const std::wstring& featureName, int x, int y, int z)
{
#ifdef _OVERRIDE_HEIGHTMAP
if (LargeFeature::STRONGHOLD == featureName && strongholdFeature != NULL)
+2 -2
View File
@@ -71,9 +71,9 @@ public:
virtual bool save(bool force, ProgressListener *progressListener);
virtual bool tick();
virtual bool shouldSave();
virtual wstring gatherStats();
virtual std::wstring gatherStats();
public:
virtual vector<Biome::MobSpawnerData *> *getMobsAt(MobCategory *mobCategory, int x, int y, int z);
virtual TilePos *findNearestMapFeature(Level *level, const wstring& featureName, int x, int y, int z);
virtual TilePos *findNearestMapFeature(Level *level, const std::wstring& featureName, int x, int y, int z);
};
+2 -2
View File
@@ -58,7 +58,7 @@ CompoundTag *DerivedLevelData::getLoadedPlayerTag()
return wrapped->getLoadedPlayerTag();
}
wstring DerivedLevelData::getLevelName()
std::wstring DerivedLevelData::getLevelName()
{
return wrapped->getLevelName();
}
@@ -134,7 +134,7 @@ void DerivedLevelData::setSpawn(int xSpawn, int ySpawn, int zSpawn)
{
}
void DerivedLevelData::setLevelName(const wstring &levelName)
void DerivedLevelData::setLevelName(const std::wstring &levelName)
{
}
+2 -2
View File
@@ -23,7 +23,7 @@ public:
__int64 getTime();
__int64 getSizeOnDisk();
CompoundTag *getLoadedPlayerTag();
wstring getLevelName();
std::wstring getLevelName();
int getVersion();
__int64 getLastPlayed();
bool isThundering();
@@ -40,7 +40,7 @@ public:
void setLoadedPlayerTag(CompoundTag *loadedPlayerTag);
void setDimension(int dimension);
void setSpawn(int xSpawn, int ySpawn, int zSpawn);
void setLevelName(const wstring &levelName);
void setLevelName(const std::wstring &levelName);
void setVersion(int version);
void setThundering(bool thundering);
void setThunderTime(int thunderTime);
+3 -3
View File
@@ -16,11 +16,11 @@ public:
virtual void allChanged() = 0;
//virtual void playSound(const wstring& name, double x, double y, double z, float volume, float pitch) = 0;
//virtual void playSound(const std::wstring& name, double x, double y, double z, float volume, float pitch) = 0;
virtual void playSound(int iSound, double x, double y, double z, float volume, float pitch, float fSoundClipDist=16.0f) = 0;
virtual void playSound(std::shared_ptr<Entity> entity,int iSound, double x, double y, double z, float volume, float pitch, float fSoundClipDist=16.0f) = 0;
// 4J removed - virtual void addParticle(const wstring& name, double x, double y, double z, double xa, double ya, double za) = 0;
// 4J removed - virtual void addParticle(const std::wstring& name, double x, double y, double z, double xa, double ya, double za) = 0;
virtual void addParticle(ePARTICLE_TYPE name, double x, double y, double z, double xa, double ya, double za) = 0; // 4J added
@@ -32,7 +32,7 @@ public:
virtual void skyColorChanged() = 0;
virtual void playStreamingMusic(const wstring& name, int x, int y, int z) = 0;
virtual void playStreamingMusic(const std::wstring& name, int x, int y, int z) = 0;
virtual void levelEvent(std::shared_ptr<Player> source, int type, int x, int y, int z, int data) = 0;
+17 -17
View File
@@ -558,7 +558,7 @@ BiomeSource *Level::getBiomeSource()
return dimension->biomeSource;
}
Level::Level(std::shared_ptr<LevelStorage> levelStorage, const wstring& name, Dimension *dimension, LevelSettings *levelSettings, bool doCreateChunkSource)
Level::Level(std::shared_ptr<LevelStorage> levelStorage, const std::wstring& name, Dimension *dimension, LevelSettings *levelSettings, bool doCreateChunkSource)
: seaLevel(constSeaLevel)
{
_init();
@@ -617,20 +617,20 @@ Level::Level(Level *level, Dimension *dimension)
}
Level::Level(std::shared_ptr<LevelStorage>levelStorage, const wstring& levelName, LevelSettings *levelSettings)
Level::Level(std::shared_ptr<LevelStorage>levelStorage, const std::wstring& levelName, LevelSettings *levelSettings)
: seaLevel( constSeaLevel )
{
_init(levelStorage, levelName, levelSettings, NULL, true);
}
Level::Level(std::shared_ptr<LevelStorage>levelStorage, const wstring& levelName, LevelSettings *levelSettings, Dimension *fixedDimension, bool doCreateChunkSource)
Level::Level(std::shared_ptr<LevelStorage>levelStorage, const std::wstring& levelName, LevelSettings *levelSettings, Dimension *fixedDimension, bool doCreateChunkSource)
: seaLevel( constSeaLevel )
{
_init( levelStorage, levelName, levelSettings, fixedDimension, doCreateChunkSource );
}
void Level::_init(std::shared_ptr<LevelStorage>levelStorage, const wstring& levelName, LevelSettings *levelSettings, Dimension *fixedDimension, bool doCreateChunkSource)
void Level::_init(std::shared_ptr<LevelStorage>levelStorage, const std::wstring& levelName, LevelSettings *levelSettings, Dimension *fixedDimension, bool doCreateChunkSource)
{
_init();
this->levelStorage = levelStorage;//std::shared_ptr<LevelStorage>(levelStorage);
@@ -1602,7 +1602,7 @@ void Level::playSound(std::shared_ptr<Entity> entity, int iSound, float volume,
}
//void Level::playSound(double x, double y, double z, const wstring& name, float volume, float pitch)
//void Level::playSound(double x, double y, double z, const std::wstring& name, float volume, float pitch)
void Level::playSound(double x, double y, double z, int iSound, float volume, float pitch, float fClipSoundDist)
{
AUTO_VAR(itEnd, listeners.end());
@@ -1616,7 +1616,7 @@ void Level::playLocalSound(double x, double y, double z, int iSound, float volum
{
}
void Level::playStreamingMusic(const wstring& name, int x, int y, int z)
void Level::playStreamingMusic(const std::wstring& name, int x, int y, int z)
{
AUTO_VAR(itEnd, listeners.end());
for (AUTO_VAR(it, listeners.begin()); it != itEnd; it++)
@@ -1626,13 +1626,13 @@ void Level::playStreamingMusic(const wstring& name, int x, int y, int z)
}
void Level::playMusic(double x, double y, double z, const wstring& string, float volume)
void Level::playMusic(double x, double y, double z, const std::wstring& string, float volume)
{
}
// 4J removed -
/*
void Level::addParticle(const wstring& id, double x, double y, double z, double xd, double yd, double zd)
void Level::addParticle(const std::wstring& id, double x, double y, double z, double xd, double yd, double zd)
{
AUTO_VAR(itEnd, listeners.end());
for (AUTO_VAR(it, listeners.begin()); it != itEnd; it++)
@@ -2825,17 +2825,17 @@ std::shared_ptr<Entity> Level::findSubclassOf(Entity::Class *entityClass)
*/
wstring Level::gatherStats()
std::wstring Level::gatherStats()
{
wchar_t buf[64];
EnterCriticalSection(&m_entitiesCS);
swprintf(buf,64,L"All:%d",this->entities.size());
LeaveCriticalSection(&m_entitiesCS);
return wstring(buf);
return std::wstring(buf);
}
wstring Level::gatherChunkSourceStats()
std::wstring Level::gatherChunkSourceStats()
{
return chunkSource->gatherStats();
}
@@ -4190,7 +4190,7 @@ std::shared_ptr<Player> Level::getNearestAttackablePlayer(double x, double y, do
return result;
}
std::shared_ptr<Player> Level::getPlayerByName(const wstring& name)
std::shared_ptr<Player> Level::getPlayerByName(const std::wstring& name)
{
AUTO_VAR(itEnd, players.end());
for (AUTO_VAR(it, players.begin()); it != itEnd; it++)
@@ -4203,7 +4203,7 @@ std::shared_ptr<Player> Level::getPlayerByName(const wstring& name)
return std::shared_ptr<Player>();
}
std::shared_ptr<Player> Level::getPlayerByUUID(const wstring& name)
std::shared_ptr<Player> Level::getPlayerByUUID(const std::wstring& name)
{
AUTO_VAR(itEnd, players.end());
for (AUTO_VAR(it, players.begin()); it != itEnd; it++)
@@ -4506,19 +4506,19 @@ bool Level::isHumidAt(int x, int y, int z)
}
void Level::setSavedData(const wstring& id, std::shared_ptr<SavedData> data)
void Level::setSavedData(const std::wstring& id, std::shared_ptr<SavedData> data)
{
savedDataStorage->set(id, data);
}
std::shared_ptr<SavedData> Level::getSavedData(const type_info& clazz, const wstring& id)
std::shared_ptr<SavedData> Level::getSavedData(const type_info& clazz, const std::wstring& id)
{
return savedDataStorage->get(clazz, id);
}
int Level::getFreeAuxValueFor(const wstring& id)
int Level::getFreeAuxValueFor(const std::wstring& id)
{
return savedDataStorage->getFreeAuxValueFor(id);
}
@@ -4575,7 +4575,7 @@ bool Level::updateLights()
return false;
}
TilePos *Level::findNearestMapFeature(const wstring& featureName, int x, int y, int z)
TilePos *Level::findNearestMapFeature(const std::wstring& featureName, int x, int y, int z)
{
return getChunkSource()->findNearestMapFeature(this, featureName, x, y, z);
}
+15 -15
View File
@@ -160,13 +160,13 @@ private:
// 4J Stu - Added these ctors to handle init of member variables
void _init();
void _init(std::shared_ptr<LevelStorage>levelStorage, const wstring& levelName, LevelSettings *levelSettings, Dimension *fixedDimension, bool doCreateChunkSource = true);
void _init(std::shared_ptr<LevelStorage>levelStorage, const std::wstring& levelName, LevelSettings *levelSettings, Dimension *fixedDimension, bool doCreateChunkSource = true);
public:
Level(std::shared_ptr<LevelStorage>levelStorage, const wstring& name, Dimension *dimension, LevelSettings *levelSettings, bool doCreateChunkSource = true);
Level(std::shared_ptr<LevelStorage>levelStorage, const std::wstring& name, Dimension *dimension, LevelSettings *levelSettings, bool doCreateChunkSource = true);
Level(Level *level, Dimension *dimension);
Level(std::shared_ptr<LevelStorage>levelStorage, const wstring& levelName, LevelSettings *levelSettings);
Level(std::shared_ptr<LevelStorage>levelStorage, const wstring& levelName, LevelSettings *levelSettings, Dimension *fixedDimension, bool doCreateChunkSource = true);
Level(std::shared_ptr<LevelStorage>levelStorage, const std::wstring& levelName, LevelSettings *levelSettings);
Level(std::shared_ptr<LevelStorage>levelStorage, const std::wstring& levelName, LevelSettings *levelSettings, Dimension *fixedDimension, bool doCreateChunkSource = true);
virtual ~Level();
@@ -283,9 +283,9 @@ public:
virtual void playLocalSound(double x, double y, double z, int iSound, float volume, float pitch, float fClipSoundDist=16.0f);
void playStreamingMusic(const wstring& name, int x, int y, int z);
void playMusic(double x, double y, double z, const wstring& string, float volume);
// 4J removed - void addParticle(const wstring& id, double x, double y, double z, double xd, double yd, double zd);
void playStreamingMusic(const std::wstring& name, int x, int y, int z);
void playMusic(double x, double y, double z, const std::wstring& string, float volume);
// 4J removed - void addParticle(const std::wstring& id, double x, double y, double z, double xd, double yd, double zd);
void addParticle(ePARTICLE_TYPE id, double x, double y, double z, double xd, double yd, double zd); // 4J added
virtual bool addGlobalEntity(std::shared_ptr<Entity> e);
virtual bool addEntity(std::shared_ptr<Entity> e);
@@ -341,8 +341,8 @@ public:
virtual std::shared_ptr<Explosion> explode(std::shared_ptr<Entity> source, double x, double y, double z, float r, bool fire, bool destroyBlocks);
float getSeenPercent(Vec3 *center, AABB *bb);
bool extinguishFire(std::shared_ptr<Player> player, int x, int y, int z, int face);
wstring gatherStats();
wstring gatherChunkSourceStats();
std::wstring gatherStats();
std::wstring gatherChunkSourceStats();
virtual std::shared_ptr<TileEntity> getTileEntity(int x, int y, int z);
void setTileEntity(int x, int y, int z, std::shared_ptr<TileEntity> tileEntity);
void removeTileEntity(int x, int y, int z);
@@ -443,8 +443,8 @@ public:
std::shared_ptr<Player> getNearestAttackablePlayer(std::shared_ptr<Entity> source, double maxDist);
std::shared_ptr<Player> getNearestAttackablePlayer(double x, double y, double z, double maxDist);
std::shared_ptr<Player> getPlayerByName(const wstring& name);
std::shared_ptr<Player> getPlayerByUUID(const wstring& name); // 4J Added
std::shared_ptr<Player> getPlayerByName(const std::wstring& name);
std::shared_ptr<Player> getPlayerByUUID(const std::wstring& name); // 4J Added
byteArray getBlocksAndData(int x, int y, int z, int xs, int ys, int zs, bool includeLighting = true);
void setBlocksAndData(int x, int y, int z, int xs, int ys, int zs, byteArray data, bool includeLighting = true);
virtual void disconnect(bool sendDisconnect = true);
@@ -476,9 +476,9 @@ public:
bool isRaining();
bool isRainingAt(int x, int y, int z);
bool isHumidAt(int x, int y, int z);
void setSavedData(const wstring& id, std::shared_ptr<SavedData> data);
std::shared_ptr<SavedData> getSavedData(const type_info& clazz, const wstring& id);
int getFreeAuxValueFor(const wstring& id);
void setSavedData(const std::wstring& id, std::shared_ptr<SavedData> data);
std::shared_ptr<SavedData> getSavedData(const type_info& clazz, const std::wstring& id);
int getFreeAuxValueFor(const std::wstring& id);
void levelEvent(int type, int x, int y, int z, int data);
void levelEvent(std::shared_ptr<Player> source, int type, int x, int y, int z, int data);
int getMaxBuildHeight();
@@ -488,7 +488,7 @@ public:
virtual bool isAllEmpty();
double getHorizonHeight() ;
void destroyTileProgress(int id, int x, int y, int z, int progress);
TilePos *findNearestMapFeature(const wstring& featureName, int x, int y, int z);
TilePos *findNearestMapFeature(const std::wstring& featureName, int x, int y, int z);
// 4J Added
int getAuxValueForMap(PlayerUID xuid, int dimension, int centreXC, int centreZC, int scale);
@@ -1,6 +1,6 @@
#include "../Build/stdafx.h"
#include "LevelConflictException.h"
LevelConflictException::LevelConflictException(const wstring& msg) : RuntimeException(msg)
LevelConflictException::LevelConflictException(const std::wstring& msg) : RuntimeException(msg)
{
}
@@ -9,5 +9,5 @@ private:
static const __int32 serialVersionUID = 1L;
public:
LevelConflictException(const wstring& msg);
LevelConflictException(const std::wstring& msg);
};
+4 -4
View File
@@ -16,7 +16,7 @@ LevelData::LevelData(CompoundTag *tag)
m_pGenerator = LevelType::lvl_normal;
if (tag->contains(L"generatorName"))
{
wstring generatorName = tag->getString(L"generatorName");
std::wstring generatorName = tag->getString(L"generatorName");
m_pGenerator = LevelType::getLevelType(generatorName);
if (m_pGenerator == NULL)
{
@@ -139,7 +139,7 @@ LevelData::LevelData(CompoundTag *tag)
dimension = 0;
}
LevelData::LevelData(LevelSettings *levelSettings, const wstring& levelName)
LevelData::LevelData(LevelSettings *levelSettings, const std::wstring& levelName)
{
this->seed = levelSettings->getSeed();
this->gameType = levelSettings->getGameType();
@@ -440,12 +440,12 @@ void LevelData::setSpawn(int xSpawn, int ySpawn, int zSpawn)
this->zSpawn = zSpawn;
}
wstring LevelData::getLevelName()
std::wstring LevelData::getLevelName()
{
return levelName;
}
void LevelData::setLevelName(const wstring& levelName)
void LevelData::setLevelName(const std::wstring& levelName)
{
this->levelName = levelName;
}
+4 -4
View File
@@ -21,7 +21,7 @@ private:
__int64 sizeOnDisk;
// CompoundTag *loadedPlayerTag; // 4J removed
int dimension;
wstring levelName;
std::wstring levelName;
int version;
bool raining;
@@ -55,7 +55,7 @@ protected:
public:
LevelData(CompoundTag *tag);
LevelData(LevelSettings *levelSettings, const wstring& levelName);
LevelData(LevelSettings *levelSettings, const std::wstring& levelName);
LevelData(LevelData *copy);
CompoundTag *createTag();
CompoundTag *createTag(vector<std::shared_ptr<Player> > *players);
@@ -101,8 +101,8 @@ public:
virtual void setLoadedPlayerTag(CompoundTag *loadedPlayerTag);
//void setDimension(int dimension); // 4J Removed TU 9 as it's never used
virtual void setSpawn(int xSpawn, int ySpawn, int zSpawn);
virtual wstring getLevelName();
virtual void setLevelName(const wstring& levelName);
virtual std::wstring getLevelName();
virtual void setLevelName(const std::wstring& levelName);
virtual int getVersion();
virtual void setVersion(int version);
virtual __int64 getLastPlayed();
+2 -2
View File
@@ -755,7 +755,7 @@ bool RandomLevelSource::shouldSave()
return true;
}
wstring RandomLevelSource::gatherStats()
std::wstring RandomLevelSource::gatherStats()
{
return L"RandomLevelSource";
}
@@ -770,7 +770,7 @@ vector<Biome::MobSpawnerData *> *RandomLevelSource::getMobsAt(MobCategory *mobCa
return biome->getMobs(mobCategory);
}
TilePos *RandomLevelSource::findNearestMapFeature(Level *level, const wstring& featureName, int x, int y, int z)
TilePos *RandomLevelSource::findNearestMapFeature(Level *level, const std::wstring& featureName, int x, int y, int z)
{
if (LargeFeature::STRONGHOLD == featureName && strongholdFeature != NULL)
{
+2 -2
View File
@@ -84,9 +84,9 @@ public:
virtual bool save(bool force, ProgressListener *progressListener);
virtual bool tick();
virtual bool shouldSave();
virtual wstring gatherStats();
virtual std::wstring gatherStats();
public:
virtual vector<Biome::MobSpawnerData *> *getMobsAt(MobCategory *mobCategory, int x, int y, int z);
virtual TilePos *findNearestMapFeature(Level *level, const wstring& featureName, int x, int y, int z);
virtual TilePos *findNearestMapFeature(Level *level, const std::wstring& featureName, int x, int y, int z);
};
@@ -12,7 +12,7 @@
#include "DirectoryLevelStorage.h"
#include "../../IO/Files/ConsoleSaveFileIO.h"
const wstring DirectoryLevelStorage::sc_szPlayerDir(L"players/");
const std::wstring DirectoryLevelStorage::sc_szPlayerDir(L"players/");
_MapDataMappings::_MapDataMappings()
{
@@ -159,8 +159,8 @@ void DirectoryLevelStorage::PlayerMappings::readMappings(DataInputStream *dis)
}
#endif
DirectoryLevelStorage::DirectoryLevelStorage(ConsoleSaveFile *saveFile, const File dir, const wstring& levelId, bool createPlayerDir) : sessionId( System::currentTimeMillis() ),
dir( L"" ), playerDir( sc_szPlayerDir ), dataDir( wstring(L"data/") ), levelId(levelId)
DirectoryLevelStorage::DirectoryLevelStorage(ConsoleSaveFile *saveFile, const File dir, const std::wstring& levelId, bool createPlayerDir) : sessionId( System::currentTimeMillis() ),
dir( L"" ), playerDir( sc_szPlayerDir ), dataDir( std::wstring(L"data/") ), levelId(levelId)
{
m_saveFile = saveFile;
m_bHasLoadedMapDataMappings = false;
@@ -188,7 +188,7 @@ void DirectoryLevelStorage::initiateSession()
{
// 4J Jev, removed try/catch.
File dataFile = File( dir, wstring(L"session.lock") );
File dataFile = File( dir, std::wstring(L"session.lock") );
FileOutputStream fos = FileOutputStream(dataFile);
DataOutputStream dos = DataOutputStream(&fos);
dos.writeLong(sessionId);
@@ -206,7 +206,7 @@ void DirectoryLevelStorage::checkSession()
// 4J-PB - Not in the Xbox game
/*
File dataFile = File( dir, wstring(L"session.lock"));
File dataFile = File( dir, std::wstring(L"session.lock"));
FileInputStream fis = FileInputStream(dataFile);
DataInputStream dis = DataInputStream(&fis);
dis.close();
@@ -336,7 +336,7 @@ LevelData *DirectoryLevelStorage::prepareLevel()
// 4J Jev, removed try/catch
ConsoleSavePath dataFile = ConsoleSavePath( wstring( L"level.dat" ) );
ConsoleSavePath dataFile = ConsoleSavePath( std::wstring( L"level.dat" ) );
if ( m_saveFile->doesFileExist( dataFile ) )
{
@@ -360,7 +360,7 @@ void DirectoryLevelStorage::saveLevelData(LevelData *levelData, vector<std::shar
CompoundTag *root = new CompoundTag();
root->put(L"Data", dataTag);
ConsoleSavePath currentFile = ConsoleSavePath( wstring( L"level.dat" ) );
ConsoleSavePath currentFile = ConsoleSavePath( std::wstring( L"level.dat" ) );
ConsoleSaveFileOutputStream fos = ConsoleSaveFileOutputStream( m_saveFile, currentFile );
NbtIo::writeCompressed(root, &fos);
@@ -377,7 +377,7 @@ void DirectoryLevelStorage::saveLevelData(LevelData *levelData)
CompoundTag *root = new CompoundTag();
root->put(L"Data", dataTag);
ConsoleSavePath currentFile = ConsoleSavePath( wstring( L"level.dat" ) );
ConsoleSavePath currentFile = ConsoleSavePath( std::wstring( L"level.dat" ) );
ConsoleSaveFileOutputStream fos = ConsoleSaveFileOutputStream( m_saveFile, currentFile );
NbtIo::writeCompressed(root, &fos);
@@ -493,7 +493,7 @@ void DirectoryLevelStorage::clearOldPlayerFiles()
for(unsigned int i = 0; i < playerFiles->size(); ++i )
{
FileEntry *file = playerFiles->at(i);
wstring xuidStr = replaceAll( replaceAll(file->data.filename,playerDir.getName(),L""),L".dat",L"");
std::wstring xuidStr = replaceAll( replaceAll(file->data.filename,playerDir.getName(),L""),L".dat",L"");
#if defined(__PS3__) || defined(__ORBIS__) || defined(_DURANGO)
PlayerUID xuid(xuidStr);
#else
@@ -512,7 +512,7 @@ void DirectoryLevelStorage::clearOldPlayerFiles()
for(unsigned int i = MAX_PLAYER_DATA_SAVES; i < playerFiles->size(); ++i )
{
FileEntry *file = playerFiles->at(i);
wstring xuidStr = replaceAll( replaceAll(file->data.filename,playerDir.getName(),L""),L".dat",L"");
std::wstring xuidStr = replaceAll( replaceAll(file->data.filename,playerDir.getName(),L""),L".dat",L"");
#if defined(__PS3__) || defined(__ORBIS__) || defined(_DURANGO)
PlayerUID xuid(xuidStr);
#else
@@ -536,12 +536,12 @@ void DirectoryLevelStorage::closeAll()
{
}
ConsoleSavePath DirectoryLevelStorage::getDataFile(const wstring& id)
ConsoleSavePath DirectoryLevelStorage::getDataFile(const std::wstring& id)
{
return ConsoleSavePath( dataDir.getName() + id + L".dat" );
}
wstring DirectoryLevelStorage::getLevelId()
std::wstring DirectoryLevelStorage::getLevelId()
{
return levelId;
}
@@ -654,7 +654,7 @@ int DirectoryLevelStorage::getAuxValueForMap(PlayerUID xuid, int dimension, int
m_saveableMapDataMappings.setMapping(mapId, xuid, dimension);
// If we had an old map file for a mapping that is no longer valid, delete it
std::wstring id = wstring( L"map_" ) + _toString(mapId);
std::wstring id = std::wstring( L"map_" ) + _toString(mapId);
ConsoleSavePath file = getDataFile(id);
if(m_saveFile->doesFileExist(file) )
@@ -760,7 +760,7 @@ void DirectoryLevelStorage::deleteMapFilesForPlayer(PlayerUID xuid)
{
for(AUTO_VAR(itMap, it->second.m_mappings.begin()); itMap != it->second.m_mappings.end(); ++itMap)
{
std::wstring id = wstring( L"map_" ) + _toString(itMap->second);
std::wstring id = std::wstring( L"map_" ) + _toString(itMap->second);
ConsoleSavePath file = getDataFile(id);
if(m_saveFile->doesFileExist(file) )
@@ -784,7 +784,7 @@ void DirectoryLevelStorage::deleteMapFilesForPlayer(PlayerUID xuid)
{
changed = true;
std::wstring id = wstring( L"map_" ) + _toString(i);
std::wstring id = std::wstring( L"map_" ) + _toString(i);
ConsoleSavePath file = getDataFile(id);
if(m_saveFile->doesFileExist(file) )
@@ -821,7 +821,7 @@ void DirectoryLevelStorage::saveAllCachedData()
for(AUTO_VAR(it, m_mapFilesToDelete.begin()); it != m_mapFilesToDelete.end(); ++it)
{
std::wstring id = wstring( L"map_" ) + _toString(*it);
std::wstring id = std::wstring( L"map_" ) + _toString(*it);
ConsoleSavePath file = getDataFile(id);
if(m_saveFile->doesFileExist(file) )
{
@@ -66,9 +66,9 @@ private:
//const File dataDir;
const ConsoleSavePath dataDir;
const __int64 sessionId;
const wstring levelId;
const std::wstring levelId;
static const wstring sc_szPlayerDir;
static const std::wstring sc_szPlayerDir;
// 4J Added
#ifdef _LARGE_WORLDS
class PlayerMappings
@@ -95,7 +95,7 @@ private:
#endif
bool m_bHasLoadedMapDataMappings;
std::unordered_map<wstring, ByteArrayOutputStream *> m_cachedSaveData;
std::unordered_map<std::wstring, ByteArrayOutputStream *> m_cachedSaveData;
vector<short> m_mapFilesToDelete; // Temp list of files that couldn't be deleted immediately due to saving being disabled
protected:
@@ -106,7 +106,7 @@ public:
virtual void flushSaveFile(bool autosave);
public:
DirectoryLevelStorage(ConsoleSaveFile *saveFile, const File dir, const wstring& levelId, bool createPlayerDir);
DirectoryLevelStorage(ConsoleSaveFile *saveFile, const File dir, const std::wstring& levelId, bool createPlayerDir);
~DirectoryLevelStorage();
private:
@@ -127,8 +127,8 @@ public:
virtual void clearOldPlayerFiles(); // 4J Added
PlayerIO *getPlayerIO();
virtual void closeAll();
ConsoleSavePath getDataFile(const wstring& id);
wstring getLevelId();
ConsoleSavePath getDataFile(const std::wstring& id);
std::wstring getLevelId();
// 4J Added
virtual int getAuxValueForMap(PlayerUID xuid, int dimension, int centreXC, int centreZC, int scale);
@@ -136,7 +136,7 @@ public:
virtual void deleteMapFilesForPlayer(std::shared_ptr<Player> player);
virtual void saveAllCachedData();
void resetNetherPlayerPositions(); // 4J Added
static wstring getPlayerDir() { return sc_szPlayerDir; }
static std::wstring getPlayerDir() { return sc_szPlayerDir; }
private:
void dontSaveMapMappingForPlayer(PlayerUID xuid);
@@ -17,7 +17,7 @@ DirectoryLevelStorageSource::DirectoryLevelStorageSource(const File dir) : baseD
//this->baseDir = dir;
}
wstring DirectoryLevelStorageSource::getName()
std::wstring DirectoryLevelStorageSource::getName()
{
return L"Old Format";
}
@@ -29,7 +29,7 @@ vector<LevelSummary *> *DirectoryLevelStorageSource::getLevelList()
#if 0
for (int i = 0; i < 5; i++)
{
wstring levelId = wstring(L"World").append( _toString( (i+1) ) );
std::wstring levelId = std::wstring(L"World").append( _toString( (i+1) ) );
LevelData *levelData = getDataTagFor(saveFile, levelId);
if (levelData != NULL)
@@ -45,10 +45,10 @@ void DirectoryLevelStorageSource::clearAll()
{
}
LevelData *DirectoryLevelStorageSource::getDataTagFor(ConsoleSaveFile *saveFile, const wstring& levelId)
LevelData *DirectoryLevelStorageSource::getDataTagFor(ConsoleSaveFile *saveFile, const std::wstring& levelId)
{
//File dataFile(dir, L"level.dat");
ConsoleSavePath dataFile = ConsoleSavePath( wstring( L"level.dat" ) );
ConsoleSavePath dataFile = ConsoleSavePath( std::wstring( L"level.dat" ) );
if ( saveFile->doesFileExist( dataFile ) )
{
ConsoleSaveFileInputStream fis = ConsoleSaveFileInputStream(saveFile, dataFile);
@@ -62,12 +62,12 @@ LevelData *DirectoryLevelStorageSource::getDataTagFor(ConsoleSaveFile *saveFile,
return NULL;
}
void DirectoryLevelStorageSource::renameLevel(const wstring& levelId, const wstring& newLevelName)
void DirectoryLevelStorageSource::renameLevel(const std::wstring& levelId, const std::wstring& newLevelName)
{
ConsoleSaveFileOriginal tempSave(levelId);
//File dataFile = File(dir, L"level.dat");
ConsoleSavePath dataFile = ConsoleSavePath( wstring( L"level.dat" ) );
ConsoleSavePath dataFile = ConsoleSavePath( std::wstring( L"level.dat" ) );
if ( tempSave.doesFileExist( dataFile ) )
{
ConsoleSaveFileInputStream fis = ConsoleSaveFileInputStream(&tempSave, dataFile);
@@ -80,7 +80,7 @@ void DirectoryLevelStorageSource::renameLevel(const wstring& levelId, const wstr
}
}
bool DirectoryLevelStorageSource::isNewLevelIdAcceptable(const wstring& levelId)
bool DirectoryLevelStorageSource::isNewLevelIdAcceptable(const std::wstring& levelId)
{
// 4J Jev, removed try/catch.
@@ -95,7 +95,7 @@ bool DirectoryLevelStorageSource::isNewLevelIdAcceptable(const wstring& levelId)
return true;
}
void DirectoryLevelStorageSource::deleteLevel(const wstring& levelId)
void DirectoryLevelStorageSource::deleteLevel(const std::wstring& levelId)
{
File dir = File(baseDir, levelId);
if (!dir.exists()) return;
@@ -118,22 +118,22 @@ void DirectoryLevelStorageSource::deleteRecursive(vector<File *> *files)
}
}
std::shared_ptr<LevelStorage> DirectoryLevelStorageSource::selectLevel(ConsoleSaveFile *saveFile, const wstring& levelId, bool createPlayerDir)
std::shared_ptr<LevelStorage> DirectoryLevelStorageSource::selectLevel(ConsoleSaveFile *saveFile, const std::wstring& levelId, bool createPlayerDir)
{
return std::shared_ptr<LevelStorage> (new DirectoryLevelStorage(saveFile, baseDir, levelId, createPlayerDir));
}
bool DirectoryLevelStorageSource::isConvertible(ConsoleSaveFile *saveFile, const wstring& levelId)
bool DirectoryLevelStorageSource::isConvertible(ConsoleSaveFile *saveFile, const std::wstring& levelId)
{
return false;
}
bool DirectoryLevelStorageSource::requiresConversion(ConsoleSaveFile *saveFile, const wstring& levelId)
bool DirectoryLevelStorageSource::requiresConversion(ConsoleSaveFile *saveFile, const std::wstring& levelId)
{
return false;
}
bool DirectoryLevelStorageSource::convertLevel(ConsoleSaveFile *saveFile, const wstring& levelId, ProgressListener *progress)
bool DirectoryLevelStorageSource::convertLevel(ConsoleSaveFile *saveFile, const std::wstring& levelId, ProgressListener *progress)
{
return false;
}
@@ -15,20 +15,20 @@ protected:
public:
DirectoryLevelStorageSource(const File dir);
virtual wstring getName();
virtual std::wstring getName();
virtual vector<LevelSummary *> *getLevelList();
virtual void clearAll();
virtual LevelData *getDataTagFor(ConsoleSaveFile *saveFile, const wstring& levelId);
virtual void renameLevel(const wstring& levelId, const wstring& newLevelName);
virtual bool isNewLevelIdAcceptable(const wstring& levelId);
virtual void deleteLevel(const wstring& levelId);
virtual LevelData *getDataTagFor(ConsoleSaveFile *saveFile, const std::wstring& levelId);
virtual void renameLevel(const std::wstring& levelId, const std::wstring& newLevelName);
virtual bool isNewLevelIdAcceptable(const std::wstring& levelId);
virtual void deleteLevel(const std::wstring& levelId);
protected:
static void deleteRecursive(vector<File *> *files);
public:
virtual std::shared_ptr<LevelStorage> selectLevel(ConsoleSaveFile *saveFile, const wstring& levelId, bool createPlayerDir);
virtual bool isConvertible(ConsoleSaveFile *saveFile, const wstring& levelId);
virtual bool requiresConversion(ConsoleSaveFile *saveFile, const wstring& levelId);
virtual bool convertLevel(ConsoleSaveFile *saveFile, const wstring& levelId, ProgressListener *progress);
virtual std::shared_ptr<LevelStorage> selectLevel(ConsoleSaveFile *saveFile, const std::wstring& levelId, bool createPlayerDir);
virtual bool isConvertible(ConsoleSaveFile *saveFile, const std::wstring& levelId);
virtual bool requiresConversion(ConsoleSaveFile *saveFile, const std::wstring& levelId);
virtual bool convertLevel(ConsoleSaveFile *saveFile, const std::wstring& levelId, ProgressListener *progress);
};
+15 -15
View File
@@ -14,25 +14,25 @@
#include "../../Headers/com.mojang.nbt.h"
#include "EntityIO.h"
std::unordered_map<wstring, entityCreateFn> *EntityIO::idCreateMap = new std::unordered_map<wstring, entityCreateFn>;
std::unordered_map<eINSTANCEOF, wstring, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq> *EntityIO::classIdMap = new std::unordered_map<eINSTANCEOF, wstring, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq>;
std::unordered_map<std::wstring, entityCreateFn> *EntityIO::idCreateMap = new std::unordered_map<std::wstring, entityCreateFn>;
std::unordered_map<eINSTANCEOF, std::wstring, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq> *EntityIO::classIdMap = new std::unordered_map<eINSTANCEOF, std::wstring, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq>;
std::unordered_map<int, entityCreateFn> *EntityIO::numCreateMap = new std::unordered_map<int, entityCreateFn>;
std::unordered_map<int, eINSTANCEOF> *EntityIO::numClassMap = new std::unordered_map<int, eINSTANCEOF>;
std::unordered_map<eINSTANCEOF, int, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq> *EntityIO::classNumMap = new std::unordered_map<eINSTANCEOF, int, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq>;
std::unordered_map<wstring, int> *EntityIO::idNumMap = new std::unordered_map<wstring, int>;
std::unordered_map<std::wstring, int> *EntityIO::idNumMap = new std::unordered_map<std::wstring, int>;
std::unordered_map<int, EntityIO::SpawnableMobInfo *> EntityIO::idsSpawnableInCreative;
void EntityIO::setId(entityCreateFn createFn, eINSTANCEOF clas, const wstring &id, int idNum)
void EntityIO::setId(entityCreateFn createFn, eINSTANCEOF clas, const std::wstring &id, int idNum)
{
idCreateMap->insert( std::unordered_map<wstring, entityCreateFn>::value_type(id, createFn) );
classIdMap->insert( std::unordered_map<eINSTANCEOF, wstring, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq>::value_type(clas,id ) );
idCreateMap->insert( std::unordered_map<std::wstring, entityCreateFn>::value_type(id, createFn) );
classIdMap->insert( std::unordered_map<eINSTANCEOF, std::wstring, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq>::value_type(clas,id ) );
numCreateMap->insert( std::unordered_map<int, entityCreateFn>::value_type(idNum, createFn) );
numClassMap->insert( std::unordered_map<int, eINSTANCEOF>::value_type(idNum, clas) );
classNumMap->insert( std::unordered_map<eINSTANCEOF, int, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq>::value_type(clas, idNum) );
idNumMap->insert( std::unordered_map<wstring, int>::value_type(id, idNum) );
idNumMap->insert( std::unordered_map<std::wstring, int>::value_type(id, idNum) );
}
void EntityIO::setId(entityCreateFn createFn, eINSTANCEOF clas, const wstring &id, int idNum, eMinecraftColour color1, eMinecraftColour color2, int nameId)
void EntityIO::setId(entityCreateFn createFn, eINSTANCEOF clas, const std::wstring &id, int idNum, eMinecraftColour color1, eMinecraftColour color2, int nameId)
{
setId(createFn, clas, id, idNum);
@@ -98,7 +98,7 @@ void EntityIO::staticCtor()
setId(DragonFireball::create, eTYPE_DRAGON_FIREBALL, L"DragonFireball", 1000);
}
std::shared_ptr<Entity> EntityIO::newEntity(const wstring& id, Level *level)
std::shared_ptr<Entity> EntityIO::newEntity(const std::wstring& id, Level *level)
{
std::shared_ptr<Entity> entity;
@@ -181,16 +181,16 @@ int EntityIO::getId(std::shared_ptr<Entity> entity)
return (*it).second;
}
wstring EntityIO::getEncodeId(std::shared_ptr<Entity> entity)
std::wstring EntityIO::getEncodeId(std::shared_ptr<Entity> entity)
{
std::unordered_map<eINSTANCEOF, wstring, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq>::iterator it = classIdMap->find( entity->GetType() );
std::unordered_map<eINSTANCEOF, std::wstring, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq>::iterator it = classIdMap->find( entity->GetType() );
if( it != classIdMap->end() )
return (*it).second;
else
return L"";
}
int EntityIO::getId(const wstring &encodeId)
int EntityIO::getId(const std::wstring &encodeId)
{
AUTO_VAR(it, idNumMap->find(encodeId));
if (it == idNumMap->end())
@@ -201,7 +201,7 @@ int EntityIO::getId(const wstring &encodeId)
return it->second;
}
wstring EntityIO::getEncodeId(int entityIoValue)
std::wstring EntityIO::getEncodeId(int entityIoValue)
{
//Class<? extends Entity> class1 = numClassMap.get(entityIoValue);
//if (class1 != null)
@@ -212,7 +212,7 @@ wstring EntityIO::getEncodeId(int entityIoValue)
AUTO_VAR(it, numClassMap->find(entityIoValue));
if(it != numClassMap->end() )
{
std::unordered_map<eINSTANCEOF, wstring, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq>::iterator classIdIt = classIdMap->find( it->second );
std::unordered_map<eINSTANCEOF, std::wstring, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq>::iterator classIdIt = classIdMap->find( it->second );
if( classIdIt != classIdMap->end() )
return (*classIdIt).second;
else
@@ -235,7 +235,7 @@ int EntityIO::getNameId(int entityIoValue)
return id;
}
eINSTANCEOF EntityIO::getType(const wstring &idString)
eINSTANCEOF EntityIO::getType(const std::wstring &idString)
{
AUTO_VAR(it, numClassMap->find(getId(idString)));
if(it != numClassMap->end() )
+10 -10
View File
@@ -28,32 +28,32 @@ public:
};
private:
static std::unordered_map<wstring, entityCreateFn> *idCreateMap;
static std::unordered_map<eINSTANCEOF, wstring, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq> *classIdMap;
static std::unordered_map<std::wstring, entityCreateFn> *idCreateMap;
static std::unordered_map<eINSTANCEOF, std::wstring, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq> *classIdMap;
static std::unordered_map<int, entityCreateFn> *numCreateMap;
static std::unordered_map<int, eINSTANCEOF> *numClassMap;
static std::unordered_map<eINSTANCEOF, int, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq> *classNumMap;
static std::unordered_map<wstring, int> *idNumMap;
static std::unordered_map<std::wstring, int> *idNumMap;
public:
static std::unordered_map<int, SpawnableMobInfo *> idsSpawnableInCreative;
private:
static void setId(entityCreateFn createFn, eINSTANCEOF clas, const wstring &id, int idNum);
static void setId(entityCreateFn createFn, eINSTANCEOF clas, const wstring &id, int idNum, eMinecraftColour color1, eMinecraftColour color2, int nameId);
static void setId(entityCreateFn createFn, eINSTANCEOF clas, const std::wstring &id, int idNum);
static void setId(entityCreateFn createFn, eINSTANCEOF clas, const std::wstring &id, int idNum, eMinecraftColour color1, eMinecraftColour color2, int nameId);
public:
static void staticCtor();
static std::shared_ptr<Entity> newEntity(const wstring& id, Level *level);
static std::shared_ptr<Entity> newEntity(const std::wstring& id, Level *level);
static std::shared_ptr<Entity> loadStatic(CompoundTag *tag, Level *level);
static std::shared_ptr<Entity> newById(int id, Level *level);
static std::shared_ptr<Entity> newByEnumType(eINSTANCEOF eType, Level *level);
static int getId(std::shared_ptr<Entity> entity);
static wstring getEncodeId(std::shared_ptr<Entity> entity);
static int getId(const wstring &encodeId);
static wstring getEncodeId(int entityIoValue);
static std::wstring getEncodeId(std::shared_ptr<Entity> entity);
static int getId(const std::wstring &encodeId);
static std::wstring getEncodeId(int entityIoValue);
static int getNameId(int entityIoValue);
static eINSTANCEOF getType(const wstring &idString);
static eINSTANCEOF getType(const std::wstring &idString);
static eINSTANCEOF getClass(int id);
// 4J-JEV, added for enumerating mobs.
@@ -16,7 +16,7 @@ void GameType::staticCtor()
ADVENTURE = new GameType(2, L"adventure");
}
GameType::GameType(int id, const wstring &name)
GameType::GameType(int id, const std::wstring &name)
{
this->id = id;
this->name = name;
@@ -27,7 +27,7 @@ int GameType::getId()
return id;
}
wstring GameType::getName()
std::wstring GameType::getName()
{
return name;
}
@@ -75,7 +75,7 @@ GameType *GameType::byId(int id)
return SURVIVAL;
}
GameType *GameType::byName(const wstring &name)
GameType *GameType::byName(const std::wstring &name)
{
if(name.compare(NOT_SET->name) == 0) return NOT_SET;
else if(name.compare(SURVIVAL->name) == 0) return SURVIVAL;
@@ -17,19 +17,19 @@ public:
private:
int id;
wstring name;
std::wstring name;
GameType(int id, const wstring &name);
GameType(int id, const std::wstring &name);
public:
int getId();
wstring getName();
std::wstring getName();
void updatePlayerAbilities(Abilities *abilities);
bool isReadOnly();
bool isCreative();
bool isSurvival();
static GameType *byId(int id);
static GameType *byName(const wstring &name);
static GameType *byName(const std::wstring &name);
};
class LevelSettings
@@ -2,5 +2,5 @@
#include "LevelStorage.h"
const wstring LevelStorage::NETHER_FOLDER = L"DIM-1";
const wstring LevelStorage::ENDER_FOLDER = L"DIM1/";
const std::wstring LevelStorage::NETHER_FOLDER = L"DIM-1";
const std::wstring LevelStorage::ENDER_FOLDER = L"DIM1/";
+4 -4
View File
@@ -15,8 +15,8 @@ class ConsoleSaveFile;
class LevelStorage
{
public:
static const wstring NETHER_FOLDER;
static const wstring ENDER_FOLDER;
static const std::wstring NETHER_FOLDER;
static const std::wstring ENDER_FOLDER;
virtual LevelData *prepareLevel() = 0;
virtual void checkSession() = 0;
@@ -25,8 +25,8 @@ public:
virtual void saveLevelData(LevelData *levelData) = 0;
virtual PlayerIO *getPlayerIO() = 0;
virtual void closeAll() = 0;
virtual ConsoleSavePath getDataFile(const wstring& id) = 0;
virtual wstring getLevelId() = 0;
virtual ConsoleSavePath getDataFile(const std::wstring& id) = 0;
virtual std::wstring getLevelId() = 0;
public:
virtual ConsoleSaveFile *getSaveFile() { return NULL; }
@@ -46,12 +46,12 @@ void LevelStorageProfilerDecorator::closeAll()
capsulated->closeAll();
}
ConsoleSavePath LevelStorageProfilerDecorator::getDataFile(const wstring& id)
ConsoleSavePath LevelStorageProfilerDecorator::getDataFile(const std::wstring& id)
{
return capsulated->getDataFile(id);
}
wstring LevelStorageProfilerDecorator::getLevelId()
std::wstring LevelStorageProfilerDecorator::getLevelId()
{
return capsulated->getLevelId();
}
@@ -22,6 +22,6 @@ public:
void saveLevelData(LevelData *levelData);
PlayerIO *getPlayerIO();
void closeAll();
ConsoleSavePath getDataFile(const wstring& id);
wstring getLevelId();
ConsoleSavePath getDataFile(const std::wstring& id);
std::wstring getLevelId();
};
@@ -12,11 +12,11 @@ class ConsoleSaveFile;
class LevelStorageSource
{
public:
virtual wstring getName() = 0;
virtual std::shared_ptr<LevelStorage> selectLevel(ConsoleSaveFile *saveFile, const wstring& levelId, bool createPlayerDir) = 0;
virtual std::wstring getName() = 0;
virtual std::shared_ptr<LevelStorage> selectLevel(ConsoleSaveFile *saveFile, const std::wstring& levelId, bool createPlayerDir) = 0;
virtual vector<LevelSummary *> *getLevelList() = 0;
virtual void clearAll() = 0;
virtual LevelData *getDataTagFor(ConsoleSaveFile *saveFile, const wstring& levelId) = 0;
virtual LevelData *getDataTagFor(ConsoleSaveFile *saveFile, const std::wstring& levelId) = 0;
/**
* Tests if a levelId can be used to store a level. For example, a levelId
@@ -28,10 +28,10 @@ public:
* @param levelId
* @return
*/
virtual bool isNewLevelIdAcceptable(const wstring& levelId) = 0;
virtual void deleteLevel(const wstring& levelId) = 0;
virtual void renameLevel(const wstring& levelId, const wstring& newLevelName) = 0;
virtual bool isConvertible(ConsoleSaveFile *saveFile, const wstring& levelId) = 0;
virtual bool requiresConversion(ConsoleSaveFile *saveFile, const wstring& levelId) = 0;
virtual bool convertLevel(ConsoleSaveFile *saveFile, const wstring &levelId, ProgressListener *progress) = 0;
virtual bool isNewLevelIdAcceptable(const std::wstring& levelId) = 0;
virtual void deleteLevel(const std::wstring& levelId) = 0;
virtual void renameLevel(const std::wstring& levelId, const std::wstring& newLevelName) = 0;
virtual bool isConvertible(ConsoleSaveFile *saveFile, const std::wstring& levelId) = 0;
virtual bool requiresConversion(ConsoleSaveFile *saveFile, const std::wstring& levelId) = 0;
virtual bool convertLevel(ConsoleSaveFile *saveFile, const std::wstring &levelId, ProgressListener *progress) = 0;
};
@@ -1,7 +1,7 @@
#include "../../Build/stdafx.h"
#include "LevelSummary.h"
LevelSummary::LevelSummary(const wstring& levelId, const wstring& levelName, __int64 lastPlayed, __int64 sizeOnDisk, GameType *gameMode, bool requiresConversion, bool hardcore, bool hasCheats) :
LevelSummary::LevelSummary(const std::wstring& levelId, const std::wstring& levelName, __int64 lastPlayed, __int64 sizeOnDisk, GameType *gameMode, bool requiresConversion, bool hardcore, bool hasCheats) :
levelId( levelId ),
levelName( levelName ),
lastPlayed( lastPlayed ),
@@ -13,12 +13,12 @@ LevelSummary::LevelSummary(const wstring& levelId, const wstring& levelName, __i
{
}
wstring LevelSummary::getLevelId()
std::wstring LevelSummary::getLevelId()
{
return levelId;
}
wstring LevelSummary::getLevelName()
std::wstring LevelSummary::getLevelName()
{
return levelName;
}
+5 -5
View File
@@ -5,8 +5,8 @@ class GameType;
class LevelSummary
{
const wstring levelId;
const wstring levelName;
const std::wstring levelId;
const std::wstring levelName;
const __int64 lastPlayed;
const __int64 sizeOnDisk;
const bool requiresConversion;
@@ -15,9 +15,9 @@ class LevelSummary
const bool _hasCheats;
public:
LevelSummary(const wstring& levelId, const wstring& levelName, __int64 lastPlayed, __int64 sizeOnDisk, GameType *gameMode, bool requiresConversion, bool hardcore, bool hasCheats);
wstring getLevelId();
wstring getLevelName();
LevelSummary(const std::wstring& levelId, const std::wstring& levelName, __int64 lastPlayed, __int64 sizeOnDisk, GameType *gameMode, bool requiresConversion, bool hardcore, bool hasCheats);
std::wstring getLevelId();
std::wstring getLevelName();
__int64 getSizeOnDisk();
bool isRequiresConversion();
__int64 getLastPlayed();
+6 -6
View File
@@ -30,12 +30,12 @@ void LevelType::staticCtor()
lvl_normal_1_1->setSelectableByUser(false);
}
LevelType::LevelType(int id, wstring generatorName)
LevelType::LevelType(int id, std::wstring generatorName)
{
init(id, generatorName, 0);
}
LevelType::LevelType(int id, wstring generatorName, int version)
LevelType::LevelType(int id, std::wstring generatorName, int version)
{
m_generatorName = generatorName;
m_version = version;
@@ -44,7 +44,7 @@ LevelType::LevelType(int id, wstring generatorName, int version)
}
void LevelType::init(int id, wstring generatorName, int version)
void LevelType::init(int id, std::wstring generatorName, int version)
{
m_generatorName = generatorName;
m_version = version;
@@ -52,12 +52,12 @@ void LevelType::init(int id, wstring generatorName, int version)
levelTypes[id] = this;
}
wstring LevelType::getGeneratorName()
std::wstring LevelType::getGeneratorName()
{
return m_generatorName;
}
wstring LevelType::getDescriptionId()
std::wstring LevelType::getDescriptionId()
{
return L"generator." + m_generatorName;
}
@@ -98,7 +98,7 @@ bool LevelType::hasReplacement()
return m_replacement;
}
LevelType *LevelType::getLevelType(wstring name)
LevelType *LevelType::getLevelType(std::wstring name)
{
if(name.length()>0)
{
+7 -7
View File
@@ -14,17 +14,17 @@ public:
static void staticCtor();
private:
wstring m_generatorName;
std::wstring m_generatorName;
int m_version;
bool m_selectable;
bool m_replacement;
LevelType(int id, wstring generatorName);
LevelType(int id, wstring generatorName, int version);
void init(int id, wstring generatorName, int version);
LevelType(int id, std::wstring generatorName);
LevelType(int id, std::wstring generatorName, int version);
void init(int id, std::wstring generatorName, int version);
public:
wstring getGeneratorName();
wstring getDescriptionId();
std::wstring getGeneratorName();
std::wstring getDescriptionId();
int getVersion();
LevelType *getReplacementForVersion(int oldVersion);
private:
@@ -35,5 +35,5 @@ private:
LevelType *setHasReplacement();
public:
bool hasReplacement();
static LevelType *getLevelType(wstring name);
static LevelType *getLevelType(std::wstring name);
};
@@ -153,7 +153,7 @@ charArray MapItemSavedData::HoldingPlayer::nextUpdatePacket(std::shared_ptr<Item
}
MapItemSavedData::MapItemSavedData(const wstring& id) : SavedData( id )
MapItemSavedData::MapItemSavedData(const std::wstring& id) : SavedData( id )
{
x = z = 0;
dimension = 0;
@@ -69,7 +69,7 @@ private:
public:
MapItemSavedData(const wstring& id);
MapItemSavedData(const std::wstring& id);
~MapItemSavedData();
virtual void load(CompoundTag *tag);
@@ -11,7 +11,7 @@ int McRegionChunkStorage::s_runningThreadCount = 0;
C4JThread *McRegionChunkStorage::s_saveThreads[3];
McRegionChunkStorage::McRegionChunkStorage(ConsoleSaveFile *saveFile, const wstring &prefix) : m_prefix( prefix )
McRegionChunkStorage::McRegionChunkStorage(ConsoleSaveFile *saveFile, const std::wstring &prefix) : m_prefix( prefix )
{
m_saveFile = saveFile;
@@ -34,7 +34,7 @@ McRegionChunkStorage::McRegionChunkStorage(ConsoleSaveFile *saveFile, const wstr
#ifdef SPLIT_SAVES
ConsoleSavePath currentFile = ConsoleSavePath( m_prefix + wstring( L"entities.dat" ) );
ConsoleSavePath currentFile = ConsoleSavePath( m_prefix + std::wstring( L"entities.dat" ) );
if(m_saveFile->doesFileExist(currentFile))
{
@@ -293,7 +293,7 @@ void McRegionChunkStorage::flush()
{
#ifdef SPLIT_SAVES
PIXBeginNamedEvent(0, "Flushing entity data");
ConsoleSavePath currentFile = ConsoleSavePath( m_prefix + wstring( L"entities.dat" ) );
ConsoleSavePath currentFile = ConsoleSavePath( m_prefix + std::wstring( L"entities.dat" ) );
ConsoleSaveFileOutputStream fos = ConsoleSaveFileOutputStream( m_saveFile, currentFile );
BufferedOutputStream bos(&fos, 1024*1024);
DataOutputStream dos(&bos);
@@ -12,7 +12,7 @@ class ConsoleSaveFile;
class McRegionChunkStorage : public ChunkStorage
{
private:
const wstring m_prefix;
const std::wstring m_prefix;
ConsoleSaveFile *m_saveFile;
static CRITICAL_SECTION cs_memory;
@@ -23,7 +23,7 @@ private:
static C4JThread *s_saveThreads[3];
public:
McRegionChunkStorage(ConsoleSaveFile *saveFile, const wstring &prefix);
McRegionChunkStorage(ConsoleSaveFile *saveFile, const std::wstring &prefix);
~McRegionChunkStorage();
static void staticCtor();
@@ -7,7 +7,7 @@
#include "../../IO/Files/File.h"
#include "McRegionLevelStorage.h"
McRegionLevelStorage::McRegionLevelStorage(ConsoleSaveFile *saveFile, File dir, const wstring& levelName, bool createPlayerDir)
McRegionLevelStorage::McRegionLevelStorage(ConsoleSaveFile *saveFile, File dir, const std::wstring& levelName, bool createPlayerDir)
: DirectoryLevelStorage(saveFile, dir, levelName, createPlayerDir)
{
RegionFileCache::clear();
@@ -13,7 +13,7 @@ protected:
static const int MCREGION_VERSION_ID = 0x4abc;
public:
McRegionLevelStorage(ConsoleSaveFile *saveFile, File dir, const wstring& levelName, bool createPlayerDir);
McRegionLevelStorage(ConsoleSaveFile *saveFile, File dir, const std::wstring& levelName, bool createPlayerDir);
~McRegionLevelStorage();
virtual ChunkStorage *createChunkStorage(Dimension *dimension);
@@ -27,7 +27,7 @@ McRegionLevelStorageSource::McRegionLevelStorageSource(File dir) : DirectoryLeve
{
}
wstring McRegionLevelStorageSource::getName()
std::wstring McRegionLevelStorageSource::getName()
{
return L"Scaevolus' McRegion";
}
@@ -49,13 +49,13 @@ vector<LevelSummary *> *McRegionLevelStorageSource::getLevelList()
continue;
}
wstring levelId = file->getName();
std::wstring levelId = file->getName();
LevelData *levelData = getDataTagFor(levelId);
if (levelData != NULL)
{
bool requiresConversion = levelData->getVersion() != McRegionLevelStorage::MCREGION_VERSION_ID;
wstring levelName = levelData->getLevelName();
std::wstring levelName = levelData->getLevelName();
if (levelName.empty()) // 4J Jev TODO: levelName can't be NULL? if (levelName == NULL || isEmpty(levelName))
{
@@ -74,13 +74,13 @@ void McRegionLevelStorageSource::clearAll()
{
}
std::shared_ptr<LevelStorage> McRegionLevelStorageSource::selectLevel(ConsoleSaveFile *saveFile, const wstring& levelId, bool createPlayerDir)
std::shared_ptr<LevelStorage> McRegionLevelStorageSource::selectLevel(ConsoleSaveFile *saveFile, const std::wstring& levelId, bool createPlayerDir)
{
// return new LevelStorageProfilerDecorator(new McRegionLevelStorage(baseDir, levelId, createPlayerDir));
return std::shared_ptr<LevelStorage>(new McRegionLevelStorage(saveFile, baseDir, levelId, createPlayerDir));
}
bool McRegionLevelStorageSource::isConvertible(ConsoleSaveFile *saveFile, const wstring& levelId)
bool McRegionLevelStorageSource::isConvertible(ConsoleSaveFile *saveFile, const std::wstring& levelId)
{
// check if there is old file format level data
LevelData *levelData = getDataTagFor(saveFile, levelId);
@@ -94,7 +94,7 @@ bool McRegionLevelStorageSource::isConvertible(ConsoleSaveFile *saveFile, const
return true;
}
bool McRegionLevelStorageSource::requiresConversion(ConsoleSaveFile *saveFile, const wstring& levelId)
bool McRegionLevelStorageSource::requiresConversion(ConsoleSaveFile *saveFile, const std::wstring& levelId)
{
LevelData *levelData = getDataTagFor(saveFile, levelId);
if (levelData == NULL || levelData->getVersion() != 0)
@@ -107,7 +107,7 @@ bool McRegionLevelStorageSource::requiresConversion(ConsoleSaveFile *saveFile, c
return true;
}
bool McRegionLevelStorageSource::convertLevel(ConsoleSaveFile *saveFile, const wstring& levelId, ProgressListener *progress)
bool McRegionLevelStorageSource::convertLevel(ConsoleSaveFile *saveFile, const std::wstring& levelId, ProgressListener *progress)
{
assert(false);
// I removed this while updating the saves to use the single save file
@@ -300,7 +300,7 @@ bool McRegionLevelStorageSource::FolderFilter::accept(File *file)
}
bool McRegionLevelStorageSource::ChunkFilter::accept(File *dir, const wstring& name)
bool McRegionLevelStorageSource::ChunkFilter::accept(File *dir, const std::wstring& name)
{
Matcher matcher( chunkFilePattern, name );
return matcher.matches();
@@ -14,13 +14,13 @@ public:
class ChunkFile;
McRegionLevelStorageSource(File dir);
virtual wstring getName();
virtual std::wstring getName();
virtual vector<LevelSummary *> *getLevelList();
virtual void clearAll();
virtual std::shared_ptr<LevelStorage> selectLevel(ConsoleSaveFile *saveFile, const wstring& levelId, bool createPlayerDir);
virtual bool isConvertible(ConsoleSaveFile *saveFile, const wstring& levelId);
virtual bool requiresConversion(ConsoleSaveFile *saveFile, const wstring& levelId);
virtual bool convertLevel(ConsoleSaveFile *saveFile, const wstring& levelId, ProgressListener *progress);
virtual std::shared_ptr<LevelStorage> selectLevel(ConsoleSaveFile *saveFile, const std::wstring& levelId, bool createPlayerDir);
virtual bool isConvertible(ConsoleSaveFile *saveFile, const std::wstring& levelId);
virtual bool requiresConversion(ConsoleSaveFile *saveFile, const std::wstring& levelId);
virtual bool convertLevel(ConsoleSaveFile *saveFile, const std::wstring& levelId, ProgressListener *progress);
private:
#if 0
@@ -44,7 +44,7 @@ public:
{
public:
static const std::tr1::wregex chunkFilePattern; // was Pattern
bool accept(File *dir, const wstring& name);
bool accept(File *dir, const std::wstring& name);
};
static class ChunkFile // implements Comparable<ChunkFile>
@@ -52,12 +52,12 @@ bool MemoryLevelStorage::load(std::shared_ptr<Player> player)
return false;
}
CompoundTag *MemoryLevelStorage::loadPlayerDataTag(const wstring& playerName)
CompoundTag *MemoryLevelStorage::loadPlayerDataTag(const std::wstring& playerName)
{
return NULL;
}
ConsoleSavePath MemoryLevelStorage::getDataFile(const wstring& id)
ConsoleSavePath MemoryLevelStorage::getDataFile(const std::wstring& id)
{
return ConsoleSaveFile(wstring(L""));
return ConsoleSaveFile(std::wstring(L""));
}
@@ -26,6 +26,6 @@ public:
virtual void closeAll();
virtual void save(std::shared_ptr<Player> player);
virtual bool load(std::shared_ptr<Player> player);
virtual CompoundTag *loadPlayerDataTag(const wstring& playerName);
virtual ConsoleSavePath getDataFile(const wstring& id);
virtual CompoundTag *loadPlayerDataTag(const std::wstring& playerName);
virtual ConsoleSavePath getDataFile(const std::wstring& id);
};
@@ -8,12 +8,12 @@ MemoryLevelStorageSource::MemoryLevelStorageSource()
{
}
wstring MemoryLevelStorageSource::getName()
std::wstring MemoryLevelStorageSource::getName()
{
return L"Memory Storage";
}
std::shared_ptr<LevelStorage> MemoryLevelStorageSource::selectLevel(const wstring& levelId, bool createPlayerDir)
std::shared_ptr<LevelStorage> MemoryLevelStorageSource::selectLevel(const std::wstring& levelId, bool createPlayerDir)
{
return std::shared_ptr<LevelStorage> () new MemoryLevelStorage());
}
@@ -27,35 +27,35 @@ void MemoryLevelStorageSource::clearAll()
{
}
LevelData *MemoryLevelStorageSource::getDataTagFor(const wstring& levelId)
LevelData *MemoryLevelStorageSource::getDataTagFor(const std::wstring& levelId)
{
return NULL;
}
bool MemoryLevelStorageSource::isNewLevelIdAcceptable(const wstring& levelId)
bool MemoryLevelStorageSource::isNewLevelIdAcceptable(const std::wstring& levelId)
{
return true;
}
void MemoryLevelStorageSource::deleteLevel(const wstring& levelId)
void MemoryLevelStorageSource::deleteLevel(const std::wstring& levelId)
{
}
void MemoryLevelStorageSource::renameLevel(const wstring& levelId, const wstring& newLevelName)
void MemoryLevelStorageSource::renameLevel(const std::wstring& levelId, const std::wstring& newLevelName)
{
}
bool MemoryLevelStorageSource::isConvertible(const wstring& levelId)
bool MemoryLevelStorageSource::isConvertible(const std::wstring& levelId)
{
return false;
}
bool MemoryLevelStorageSource::requiresConversion(const wstring& levelId)
bool MemoryLevelStorageSource::requiresConversion(const std::wstring& levelId)
{
return false;
}
bool MemoryLevelStorageSource::convertLevel(const wstring& levelId, ProgressListener *progress)
bool MemoryLevelStorageSource::convertLevel(const std::wstring& levelId, ProgressListener *progress)
{
return false;
}
@@ -7,15 +7,15 @@ class MemoryLevelStorageSource : public LevelStorageSource
{
public:
MemoryLevelStorageSource();
wstring getName();
std::shared_ptr<LevelStorage> selectLevel(const wstring& levelId, bool createPlayerDir);
std::wstring getName();
std::shared_ptr<LevelStorage> selectLevel(const std::wstring& levelId, bool createPlayerDir);
vector<LevelSummary *> *getLevelList();
void clearAll();
LevelData *getDataTagFor(const wstring& levelId);
bool isNewLevelIdAcceptable(const wstring& levelId);
void deleteLevel(const wstring& levelId);
void renameLevel(const wstring& levelId, const wstring& newLevelName);
bool isConvertible(const wstring& levelId);
bool requiresConversion(const wstring& levelId);
bool convertLevel(const wstring& levelId, ProgressListener *progress);
LevelData *getDataTagFor(const std::wstring& levelId);
bool isNewLevelIdAcceptable(const std::wstring& levelId);
void deleteLevel(const std::wstring& levelId);
void renameLevel(const std::wstring& levelId, const std::wstring& newLevelName);
bool isConvertible(const std::wstring& levelId);
bool requiresConversion(const std::wstring& levelId);
bool convertLevel(const std::wstring& levelId, ProgressListener *progress);
};
@@ -38,12 +38,12 @@ void MockedLevelStorage::closeAll()
{
}
ConsoleSavePath MockedLevelStorage::getDataFile(const wstring& id)
ConsoleSavePath MockedLevelStorage::getDataFile(const std::wstring& id)
{
return ConsoleSavePath(wstring(L""));
return ConsoleSavePath(std::wstring(L""));
}
wstring MockedLevelStorage::getLevelId()
std::wstring MockedLevelStorage::getLevelId()
{
return L"none";
}
@@ -15,8 +15,8 @@ public:
virtual void saveLevelData(LevelData *levelData);
virtual PlayerIO *getPlayerIO();
virtual void closeAll();
virtual ConsoleSavePath getDataFile(const wstring& id);
virtual wstring getLevelId();
virtual ConsoleSavePath getDataFile(const std::wstring& id);
virtual std::wstring getLevelId();
public:
virtual ConsoleSaveFile *getSaveFile() { return NULL; }
};
@@ -75,7 +75,7 @@ File OldChunkStorage::getFile(int x, int z)
_itow(z & 63,path2,36);
#endif
//sprintf(file,"%s\\%s",dir,path1);
File file( dir, wstring( path1 ) );
File file( dir, std::wstring( path1 ) );
if( !file.exists() )
{
if(create) file.mkdir();
@@ -87,7 +87,7 @@ File OldChunkStorage::getFile(int x, int z)
//strcat(file,"\\");
//strcat(file,path2);
file = File( file, wstring( path2 ) );
file = File( file, std::wstring( path2 ) );
if( !file.exists() )
{
if(create) file.mkdir();
@@ -100,7 +100,7 @@ File OldChunkStorage::getFile(int x, int z)
//strcat(file,"\\");
//strcat(file,name);
//sprintf(file,"%s\\%s",file,name);
file = File( file, wstring( name ) );
file = File( file, std::wstring( name ) );
if ( !file.exists() )
{
if (!create)
@@ -84,7 +84,7 @@ bool ReadOnlyChunkCache::shouldSave()
return false;
}
wstring ReadOnlyChunkCache::gatherStats()
std::wstring ReadOnlyChunkCache::gatherStats()
{
return L"ReadOnlyChunkCache";
}
@@ -94,7 +94,7 @@ vector<Biome::MobSpawnerData *> *ReadOnlyChunkCache::getMobsAt(MobCategory *mobC
return NULL;
}
TilePos *ReadOnlyChunkCache::findNearestMapFeature(Level *level, const wstring& featureName, int x, int y, int z)
TilePos *ReadOnlyChunkCache::findNearestMapFeature(Level *level, const std::wstring& featureName, int x, int y, int z)
{
return NULL;
}
@@ -32,8 +32,8 @@ public:
virtual bool save(bool force, ProgressListener *progressListener);
virtual bool tick();
virtual bool shouldSave();
virtual wstring gatherStats();
virtual std::wstring gatherStats();
virtual vector<Biome::MobSpawnerData *> *getMobsAt(MobCategory *mobCategory, int x, int y, int z);
virtual TilePos *findNearestMapFeature(Level *level, const wstring& featureName, int x, int y, int z);
virtual TilePos *findNearestMapFeature(Level *level, const std::wstring& featureName, int x, int y, int z);
};
@@ -17,7 +17,7 @@ bool RegionFileCache::useSplitSaves(ESavePlatform platform)
};
}
RegionFile *RegionFileCache::_getRegionFile(ConsoleSaveFile *saveFile, const wstring &prefix, int chunkX, int chunkZ) // 4J - TODO was synchronized
RegionFile *RegionFileCache::_getRegionFile(ConsoleSaveFile *saveFile, const std::wstring &prefix, int chunkX, int chunkZ) // 4J - TODO was synchronized
{
// 4J Jev - changed back to use of the File class.
//char file[MAX_PATH_SIZE];
@@ -25,16 +25,16 @@ RegionFile *RegionFileCache::_getRegionFile(ConsoleSaveFile *saveFile, const wst
//File regionDir(basePath, L"region");
//File file(regionDir, wstring(L"r.") + _toString(chunkX>>5) + L"." + _toString(chunkZ>>5) + L".mcr" );
//File file(regionDir, std::wstring(L"r.") + _toString(chunkX>>5) + L"." + _toString(chunkZ>>5) + L".mcr" );
MemSect(31);
File file;
if(useSplitSaves(saveFile->getSavePlatform()))
{
file = File( prefix + wstring(L"r.") + _toString(chunkX>>4) + L"." + _toString(chunkZ>>4) + L".mcr" );
file = File( prefix + std::wstring(L"r.") + _toString(chunkX>>4) + L"." + _toString(chunkZ>>4) + L".mcr" );
}
else
{
file = File( prefix + wstring(L"r.") + _toString(chunkX>>5) + L"." + _toString(chunkZ>>5) + L".mcr" );
file = File( prefix + std::wstring(L"r.") + _toString(chunkX>>5) + L"." + _toString(chunkZ>>5) + L".mcr" );
}
MemSect(0);
@@ -87,13 +87,13 @@ void RegionFileCache::_clear() // 4J - TODO was synchronized
cache.clear();
}
int RegionFileCache::_getSizeDelta(ConsoleSaveFile *saveFile, const wstring &prefix, int chunkX, int chunkZ)
int RegionFileCache::_getSizeDelta(ConsoleSaveFile *saveFile, const std::wstring &prefix, int chunkX, int chunkZ)
{
RegionFile *r = _getRegionFile(saveFile, prefix, chunkX, chunkZ);
return r->getSizeDelta();
}
DataInputStream *RegionFileCache::_getChunkDataInputStream(ConsoleSaveFile *saveFile, const wstring &prefix, int chunkX, int chunkZ)
DataInputStream *RegionFileCache::_getChunkDataInputStream(ConsoleSaveFile *saveFile, const std::wstring &prefix, int chunkX, int chunkZ)
{
RegionFile* r = _getRegionFile(saveFile, prefix, chunkX, chunkZ);
if(useSplitSaves(saveFile->getSavePlatform()))
@@ -107,7 +107,7 @@ DataInputStream *RegionFileCache::_getChunkDataInputStream(ConsoleSaveFile *save
}
}
DataOutputStream *RegionFileCache::_getChunkDataOutputStream(ConsoleSaveFile *saveFile, const wstring &prefix, int chunkX, int chunkZ)
DataOutputStream *RegionFileCache::_getChunkDataOutputStream(ConsoleSaveFile *saveFile, const std::wstring &prefix, int chunkX, int chunkZ)
{
RegionFile* r = _getRegionFile(saveFile, prefix, chunkX, chunkZ);
if(useSplitSaves(saveFile->getSavePlatform()))
@@ -17,18 +17,18 @@ public:
// Made public and non-static so we can have a cache for input and output files
RegionFileCache() {}
RegionFile *_getRegionFile(ConsoleSaveFile *saveFile, const wstring &prefix, int chunkX, int chunkZ); // 4J - TODO was synchronized
RegionFile *_getRegionFile(ConsoleSaveFile *saveFile, const std::wstring &prefix, int chunkX, int chunkZ); // 4J - TODO was synchronized
void _clear(); // 4J - TODO was synchronized
int _getSizeDelta(ConsoleSaveFile *saveFile, const wstring &prefix, int chunkX, int chunkZ);
DataInputStream *_getChunkDataInputStream(ConsoleSaveFile *saveFile, const wstring &prefix, int chunkX, int chunkZ);
DataOutputStream *_getChunkDataOutputStream(ConsoleSaveFile *saveFile, const wstring &prefix, int chunkX, int chunkZ);
int _getSizeDelta(ConsoleSaveFile *saveFile, const std::wstring &prefix, int chunkX, int chunkZ);
DataInputStream *_getChunkDataInputStream(ConsoleSaveFile *saveFile, const std::wstring &prefix, int chunkX, int chunkZ);
DataOutputStream *_getChunkDataOutputStream(ConsoleSaveFile *saveFile, const std::wstring &prefix, int chunkX, int chunkZ);
// Keep static version for general game usage
static RegionFile *getRegionFile(ConsoleSaveFile *saveFile, const wstring &prefix, int chunkX, int chunkZ) { return s_defaultCache._getRegionFile(saveFile, prefix, chunkX, chunkZ); }
static RegionFile *getRegionFile(ConsoleSaveFile *saveFile, const std::wstring &prefix, int chunkX, int chunkZ) { return s_defaultCache._getRegionFile(saveFile, prefix, chunkX, chunkZ); }
static void clear() { s_defaultCache._clear(); }
static int getSizeDelta(ConsoleSaveFile *saveFile, const wstring &prefix, int chunkX, int chunkZ) { return s_defaultCache._getSizeDelta(saveFile, prefix, chunkX, chunkZ); }
static DataInputStream *getChunkDataInputStream(ConsoleSaveFile *saveFile, const wstring &prefix, int chunkX, int chunkZ) { return s_defaultCache._getChunkDataInputStream(saveFile, prefix, chunkX, chunkZ); }
static DataOutputStream *getChunkDataOutputStream(ConsoleSaveFile *saveFile, const wstring &prefix, int chunkX, int chunkZ) { return s_defaultCache._getChunkDataOutputStream(saveFile, prefix, chunkX, chunkZ); }
static int getSizeDelta(ConsoleSaveFile *saveFile, const std::wstring &prefix, int chunkX, int chunkZ) { return s_defaultCache._getSizeDelta(saveFile, prefix, chunkX, chunkZ); }
static DataInputStream *getChunkDataInputStream(ConsoleSaveFile *saveFile, const std::wstring &prefix, int chunkX, int chunkZ) { return s_defaultCache._getChunkDataInputStream(saveFile, prefix, chunkX, chunkZ); }
static DataOutputStream *getChunkDataOutputStream(ConsoleSaveFile *saveFile, const std::wstring &prefix, int chunkX, int chunkZ) { return s_defaultCache._getChunkDataOutputStream(saveFile, prefix, chunkX, chunkZ); }
private:
bool useSplitSaves(ESavePlatform platform);
+1 -1
View File
@@ -3,7 +3,7 @@
SavedData::SavedData(const wstring& id) : id( id )
SavedData::SavedData(const std::wstring& id) : id( id )
{
dirty = false;
}
+2 -2
View File
@@ -8,13 +8,13 @@ class CompoundTag;
class SavedData : public enable_shared_from_this<SavedData>
{
public:
const wstring id;
const std::wstring id;
private:
bool dirty;
public:
SavedData(const wstring& id);
SavedData(const std::wstring& id);
virtual void load(CompoundTag *tag) = 0;
virtual void save(CompoundTag *tag) = 0;
@@ -11,16 +11,16 @@
SavedDataStorage::SavedDataStorage(LevelStorage *levelStorage)
{
/*
cache = new std::unordered_map<wstring, std::shared_ptr<SavedData> >;
cache = new std::unordered_map<std::wstring, std::shared_ptr<SavedData> >;
savedDatas = new vector<std::shared_ptr<SavedData> >;
usedAuxIds = new std::unordered_map<wstring, short*>;
usedAuxIds = new std::unordered_map<std::wstring, short*>;
*/
this->levelStorage = levelStorage;
loadAuxValues();
}
std::shared_ptr<SavedData> SavedDataStorage::get(const type_info& clazz, const wstring& id)
std::shared_ptr<SavedData> SavedDataStorage::get(const type_info& clazz, const std::wstring& id)
{
AUTO_VAR(it, cache.find( id ));
if (it != cache.end()) return (*it).second;
@@ -59,13 +59,13 @@ std::shared_ptr<SavedData> SavedDataStorage::get(const type_info& clazz, const w
if (data != NULL)
{
cache.insert( std::unordered_map<wstring, std::shared_ptr<SavedData> >::value_type( id , data ) );
cache.insert( std::unordered_map<std::wstring, std::shared_ptr<SavedData> >::value_type( id , data ) );
savedDatas.push_back(data);
}
return data;
}
void SavedDataStorage::set(const wstring& id, std::shared_ptr<SavedData> data)
void SavedDataStorage::set(const std::wstring& id, std::shared_ptr<SavedData> data)
{
if (data == NULL)
{
@@ -145,7 +145,7 @@ void SavedDataStorage::loadAuxValues()
if (dynamic_cast<ShortTag *>(tag) != NULL)
{
ShortTag *sTag = (ShortTag *) tag;
wstring id = sTag->getName();
std::wstring id = sTag->getName();
short val = sTag->data;
usedAuxIds.insert( uaiMapType::value_type( id, val ) );
}
@@ -154,7 +154,7 @@ void SavedDataStorage::loadAuxValues()
}
}
int SavedDataStorage::getFreeAuxValueFor(const wstring& id)
int SavedDataStorage::getFreeAuxValueFor(const std::wstring& id)
{
AUTO_VAR(it, usedAuxIds.find( id ));
short val = 0;
@@ -9,18 +9,18 @@ class SavedDataStorage
private:
LevelStorage *levelStorage;
typedef std::unordered_map<wstring, std::shared_ptr<SavedData> > cacheMapType;
typedef std::unordered_map<std::wstring, std::shared_ptr<SavedData> > cacheMapType;
cacheMapType cache;
vector<std::shared_ptr<SavedData> > savedDatas;
typedef std::unordered_map<wstring, short> uaiMapType;
typedef std::unordered_map<std::wstring, short> uaiMapType;
uaiMapType usedAuxIds;
public:
SavedDataStorage(LevelStorage *);
std::shared_ptr<SavedData> get(const type_info& clazz, const wstring& id);
void set(const wstring& id, std::shared_ptr<SavedData> data);
std::shared_ptr<SavedData> get(const type_info& clazz, const std::wstring& id);
void set(const std::wstring& id, std::shared_ptr<SavedData> data);
void save();
private:
@@ -28,7 +28,7 @@ private:
void loadAuxValues();
public:
int getFreeAuxValueFor(const wstring& id);
int getFreeAuxValueFor(const std::wstring& id);
// 4J Added
int getAuxValueForMap(PlayerUID xuid, int dimension, int centreXC, int centreZC, int scale);
@@ -29,7 +29,7 @@ ZonedChunkStorage::ZonedChunkStorage(File dir)
tickCount = 0;
//this->dir = dir;
this->dir = File( dir, wstring( L"data" ) );
this->dir = File( dir, std::wstring( L"data" ) );
if( !this->dir.exists() ) this->dir.mkdirs();
}
@@ -58,7 +58,7 @@ ZoneFile *ZonedChunkStorage::getZoneFile(int x, int z, bool create)
wchar_t zRadix36[64];
_itow(x,xRadix36,36);
_itow(z,zRadix36,36);
File file = File(dir, wstring( L"zone_") + _toString( xRadix36 ) + L"_" + _toString( zRadix36 ) + L".dat" );
File file = File(dir, std::wstring( L"zone_") + _toString( xRadix36 ) + L"_" + _toString( zRadix36 ) + L".dat" );
if ( !file.exists() )
{
@@ -67,7 +67,7 @@ ZoneFile *ZonedChunkStorage::getZoneFile(int x, int z, bool create)
CloseHandle(ch);
}
File entityFile = File(dir, wstring( L"entities_") + _toString( xRadix36 ) + L"_" + _toString( zRadix36 ) + L".dat" );
File entityFile = File(dir, std::wstring( L"entities_") + _toString( xRadix36 ) + L"_" + _toString( zRadix36 ) + L".dat" );
zoneFiles[key] = new ZoneFile(key, file, entityFile);
}