mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-09-27 21:21:02 +00:00
Merge pull request #71 from 4jcraft/refactor/no-std-wildcard
refactor: remove `using namespace std`
This commit is contained in:
@@ -21,7 +21,7 @@ int ChunkPos::hashCode()
|
||||
return h1 ^ h2;
|
||||
}
|
||||
|
||||
double ChunkPos::distanceToSqr(shared_ptr<Entity> e)
|
||||
double ChunkPos::distanceToSqr(std::shared_ptr<Entity> e)
|
||||
{
|
||||
double xPos = x * 16 + 8;
|
||||
double zPos = z * 16 + 8;
|
||||
@@ -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"]";
|
||||
}
|
||||
|
||||
@@ -13,14 +13,14 @@ public:
|
||||
static __int64 hashCode(int x, int z);
|
||||
int hashCode();
|
||||
|
||||
double distanceToSqr(shared_ptr<Entity> e);
|
||||
double distanceToSqr(std::shared_ptr<Entity> e);
|
||||
double distanceToSqr(double px, double pz); // 4J added
|
||||
|
||||
int getMiddleBlockX();
|
||||
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);
|
||||
|
||||
@@ -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 std::vector<Biome::MobSpawnerData *> *getMobsAt(MobCategory *mobCategory, int x, int y, int z) = 0;
|
||||
virtual TilePos *findNearestMapFeature(Level *level, const std::wstring& featureName, int x, int y, int z) = 0;
|
||||
};
|
||||
|
||||
@@ -20,13 +20,13 @@ 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
|
||||
string path = "GameRules\\heightmap.bin";
|
||||
std::string path = "GameRules\\heightmap.bin";
|
||||
#else
|
||||
string path = "GAME:\\GameRules\\heightmap.bin";
|
||||
std::string path = "GAME:\\GameRules\\heightmap.bin";
|
||||
#endif
|
||||
#endif
|
||||
HANDLE file = CreateFile(path.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
@@ -62,13 +62,13 @@ 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
|
||||
string waterHeightPath = "GameRules\\waterheight.bin";
|
||||
std::string waterHeightPath = "GameRules\\waterheight.bin";
|
||||
#else
|
||||
string waterHeightPath = "GAME:\\GameRules\\waterheight.bin";
|
||||
std::string waterHeightPath = "GAME:\\GameRules\\waterheight.bin";
|
||||
#endif
|
||||
#endif
|
||||
file = CreateFile(waterHeightPath.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
@@ -609,12 +609,12 @@ bool CustomLevelSource::shouldSave()
|
||||
return true;
|
||||
}
|
||||
|
||||
wstring CustomLevelSource::gatherStats()
|
||||
std::wstring CustomLevelSource::gatherStats()
|
||||
{
|
||||
return L"CustomLevelSource";
|
||||
}
|
||||
|
||||
vector<Biome::MobSpawnerData *> *CustomLevelSource::getMobsAt(MobCategory *mobCategory, int x, int y, int z)
|
||||
std::vector<Biome::MobSpawnerData *> *CustomLevelSource::getMobsAt(MobCategory *mobCategory, int x, int y, int z)
|
||||
{
|
||||
#ifdef _OVERRIDE_HEIGHTMAP
|
||||
Biome *biome = level->getBiome(x, z);
|
||||
@@ -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)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
using namespace std;
|
||||
|
||||
|
||||
#include "ChunkSource.h"
|
||||
|
||||
@@ -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 std::vector<Biome::MobSpawnerData *> *getMobsAt(MobCategory *mobCategory, 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 @@ CompoundTag *DerivedLevelData::createTag()
|
||||
return wrapped->createTag();
|
||||
}
|
||||
|
||||
CompoundTag *DerivedLevelData::createTag(vector<shared_ptr<Player> > *players)
|
||||
CompoundTag *DerivedLevelData::createTag(std::vector<std::shared_ptr<Player> > *players)
|
||||
{
|
||||
return wrapped->createTag(players);
|
||||
}
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ protected:
|
||||
|
||||
public:
|
||||
CompoundTag *createTag();
|
||||
CompoundTag *createTag(vector<shared_ptr<Player> > *players);
|
||||
CompoundTag *createTag(std::vector<std::shared_ptr<Player> > *players);
|
||||
__int64 getSeed();
|
||||
int getXSpawn();
|
||||
int getYSpawn();
|
||||
@@ -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);
|
||||
|
||||
@@ -94,15 +94,15 @@ int EmptyLevelChunk::getRawBrightness(int x, int y, int z, int skyDampen)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void EmptyLevelChunk::addEntity(shared_ptr<Entity> e)
|
||||
void EmptyLevelChunk::addEntity(std::shared_ptr<Entity> e)
|
||||
{
|
||||
}
|
||||
|
||||
void EmptyLevelChunk::removeEntity(shared_ptr<Entity> e)
|
||||
void EmptyLevelChunk::removeEntity(std::shared_ptr<Entity> e)
|
||||
{
|
||||
}
|
||||
|
||||
void EmptyLevelChunk::removeEntity(shared_ptr<Entity> e, int yc)
|
||||
void EmptyLevelChunk::removeEntity(std::shared_ptr<Entity> e, int yc)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -115,16 +115,16 @@ void EmptyLevelChunk::skyBrightnessChanged()
|
||||
{
|
||||
}
|
||||
|
||||
shared_ptr<TileEntity> EmptyLevelChunk::getTileEntity(int x, int y, int z)
|
||||
std::shared_ptr<TileEntity> EmptyLevelChunk::getTileEntity(int x, int y, int z)
|
||||
{
|
||||
return shared_ptr<TileEntity>();
|
||||
return std::shared_ptr<TileEntity>();
|
||||
}
|
||||
|
||||
void EmptyLevelChunk::addTileEntity(shared_ptr<TileEntity> te)
|
||||
void EmptyLevelChunk::addTileEntity(std::shared_ptr<TileEntity> te)
|
||||
{
|
||||
}
|
||||
|
||||
void EmptyLevelChunk::setTileEntity(int x, int y, int z, shared_ptr<TileEntity> tileEntity)
|
||||
void EmptyLevelChunk::setTileEntity(int x, int y, int z, std::shared_ptr<TileEntity> tileEntity)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -144,11 +144,11 @@ void EmptyLevelChunk::markUnsaved()
|
||||
{
|
||||
}
|
||||
|
||||
void EmptyLevelChunk::getEntities(shared_ptr<Entity> except, AABB bb, vector<shared_ptr<Entity> > &es)
|
||||
void EmptyLevelChunk::getEntities(std::shared_ptr<Entity> except, AABB bb, std::vector<std::shared_ptr<Entity> > &es)
|
||||
{
|
||||
}
|
||||
|
||||
void EmptyLevelChunk::getEntitiesOfClass(const type_info& ec, AABB bb, vector<shared_ptr<Entity> > &es)
|
||||
void EmptyLevelChunk::getEntitiesOfClass(const std::type_info& ec, AABB bb, std::vector<std::shared_ptr<Entity> > &es)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -28,20 +28,20 @@ public:
|
||||
void getNeighbourBrightnesses(int *brightnesses, LightLayer::variety layer, int x, int y, int z); // 4J added
|
||||
void setBrightness(LightLayer::variety layer, int x, int y, int z, int brightness);
|
||||
int getRawBrightness(int x, int y, int z, int skyDampen);
|
||||
void addEntity(shared_ptr<Entity> e);
|
||||
void removeEntity(shared_ptr<Entity> e);
|
||||
void removeEntity(shared_ptr<Entity> e, int yc);
|
||||
void addEntity(std::shared_ptr<Entity> e);
|
||||
void removeEntity(std::shared_ptr<Entity> e);
|
||||
void removeEntity(std::shared_ptr<Entity> e, int yc);
|
||||
bool isSkyLit(int x, int y, int z);
|
||||
void skyBrightnessChanged();
|
||||
shared_ptr<TileEntity> getTileEntity(int x, int y, int z);
|
||||
void addTileEntity(shared_ptr<TileEntity> te);
|
||||
void setTileEntity(int x, int y, int z, shared_ptr<TileEntity> tileEntity);
|
||||
std::shared_ptr<TileEntity> getTileEntity(int x, int y, int z);
|
||||
void addTileEntity(std::shared_ptr<TileEntity> te);
|
||||
void setTileEntity(int x, int y, int z, std::shared_ptr<TileEntity> tileEntity);
|
||||
void removeTileEntity(int x, int y, int z);
|
||||
void load();
|
||||
void unload(bool unloadTileEntities) ; // 4J - added parameter
|
||||
void markUnsaved();
|
||||
void getEntities(shared_ptr<Entity> except, AABB bb, vector<shared_ptr<Entity> > &es);
|
||||
void getEntitiesOfClass(const type_info& ec, AABB bb, vector<shared_ptr<Entity> > &es);
|
||||
void getEntities(std::shared_ptr<Entity> except, AABB bb, std::vector<std::shared_ptr<Entity> > &es);
|
||||
void getEntitiesOfClass(const std::type_info& ec, AABB bb, std::vector<std::shared_ptr<Entity> > &es);
|
||||
int countEntities();
|
||||
bool shouldSave(bool force);
|
||||
void setBlocks(byteArray newBlocks, int sub);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
using namespace std;
|
||||
|
||||
|
||||
class TileEntity;
|
||||
#include "../../Player/Player.h"
|
||||
@@ -16,25 +16,25 @@ 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(shared_ptr<Entity> entity,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
|
||||
|
||||
virtual void entityAdded(shared_ptr<Entity> entity) = 0;
|
||||
virtual void entityAdded(std::shared_ptr<Entity> entity) = 0;
|
||||
|
||||
virtual void entityRemoved(shared_ptr<Entity> entity) = 0;
|
||||
virtual void entityRemoved(std::shared_ptr<Entity> entity) = 0;
|
||||
|
||||
virtual void playerRemoved(shared_ptr<Entity> entity) = 0; // 4J added - for when a player is removed from the level's player array, not just the entity storage
|
||||
virtual void playerRemoved(std::shared_ptr<Entity> entity) = 0; // 4J added - for when a player is removed from the level's player array, not just the entity storage
|
||||
|
||||
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(shared_ptr<Player> source, int type, int x, int y, int z, int data) = 0;
|
||||
virtual void levelEvent(std::shared_ptr<Player> source, int type, int x, int y, int z, int data) = 0;
|
||||
|
||||
virtual void destroyTileProgress(int id, int x, int y, int z, int progress) = 0;
|
||||
};
|
||||
@@ -11,7 +11,7 @@ VillageSiege::VillageSiege(Level *level)
|
||||
siegeState = SIEGE_NOT_INITED;
|
||||
siegeCount = 0;
|
||||
nextSpawnTime = 0;
|
||||
village = weak_ptr<Village>();
|
||||
village = std::weak_ptr<Village>();
|
||||
spawnX = spawnY = spawnZ = 0;
|
||||
|
||||
this->level = level;
|
||||
@@ -77,12 +77,12 @@ void VillageSiege::tick()
|
||||
|
||||
bool VillageSiege::tryToSetupSiege()
|
||||
{
|
||||
vector<shared_ptr<Player> > *players = &level->players;
|
||||
std::vector<std::shared_ptr<Player> > *players = &level->players;
|
||||
//for (Player player : players)
|
||||
for(AUTO_VAR(it, players->begin()); it != players->end(); ++it)
|
||||
{
|
||||
shared_ptr<Player> player = *it;
|
||||
shared_ptr<Village> _village = level->villages->getClosestVillage((int) player->x, (int) player->y, (int) player->z, 1);
|
||||
std::shared_ptr<Player> player = *it;
|
||||
std::shared_ptr<Village> _village = level->villages->getClosestVillage((int) player->x, (int) player->y, (int) player->z, 1);
|
||||
village = _village;
|
||||
|
||||
if (_village == NULL) continue;
|
||||
@@ -101,11 +101,11 @@ bool VillageSiege::tryToSetupSiege()
|
||||
spawnY = center->y;
|
||||
spawnZ = center->z + (int) (Mth::sin(level->random->nextFloat() * PI * 2.f) * radius * 0.9);
|
||||
overlaps = false;
|
||||
vector<shared_ptr<Village> > *villages = level->villages->getVillages();
|
||||
std::vector<std::shared_ptr<Village> > *villages = level->villages->getVillages();
|
||||
//for (Village v : level.villages.getVillages())
|
||||
for(AUTO_VAR(itV, villages->begin()); itV != villages->end(); ++itV)
|
||||
{
|
||||
shared_ptr<Village>v = *itV;
|
||||
std::shared_ptr<Village>v = *itV;
|
||||
if (v == _village) continue;
|
||||
if (v->isInside(spawnX, spawnY, spawnZ))
|
||||
{
|
||||
@@ -131,10 +131,10 @@ bool VillageSiege::trySpawn()
|
||||
{
|
||||
Vec3 *spawnPos = findRandomSpawnPos(spawnX, spawnY, spawnZ);
|
||||
if (spawnPos == NULL) return false;
|
||||
shared_ptr<Zombie> mob;
|
||||
std::shared_ptr<Zombie> mob;
|
||||
//try
|
||||
{
|
||||
mob = shared_ptr<Zombie>( new Zombie(level) );
|
||||
mob = std::shared_ptr<Zombie>( new Zombie(level) );
|
||||
mob->finalizeMobSpawn();
|
||||
mob->setVillager(false);
|
||||
}
|
||||
@@ -144,7 +144,7 @@ bool VillageSiege::trySpawn()
|
||||
//}
|
||||
mob->moveTo(spawnPos->x, spawnPos->y, spawnPos->z, level->random->nextFloat() * 360, 0);
|
||||
level->addEntity(mob);
|
||||
shared_ptr<Village> _village = village.lock();
|
||||
std::shared_ptr<Village> _village = village.lock();
|
||||
if( _village == NULL ) return false;
|
||||
|
||||
Pos *center = _village->getCenter();
|
||||
@@ -154,7 +154,7 @@ bool VillageSiege::trySpawn()
|
||||
|
||||
Vec3 *VillageSiege::findRandomSpawnPos(int x, int y, int z)
|
||||
{
|
||||
shared_ptr<Village> _village = village.lock();
|
||||
std::shared_ptr<Village> _village = village.lock();
|
||||
if( _village == NULL ) return NULL;
|
||||
|
||||
for (int i = 0; i < 10; ++i)
|
||||
|
||||
@@ -8,7 +8,7 @@ private:
|
||||
int siegeState;
|
||||
int siegeCount;
|
||||
int nextSpawnTime;
|
||||
weak_ptr<Village> village;
|
||||
std::weak_ptr<Village> village;
|
||||
int spawnX, spawnY, spawnZ;
|
||||
|
||||
static const int SIEGE_NOT_INITED = -1;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "Explosion.h"
|
||||
#include "../Util/SoundTypes.h"
|
||||
|
||||
Explosion::Explosion(Level *level, shared_ptr<Entity> source, double x, double y, double z, float r)
|
||||
Explosion::Explosion(Level *level, std::shared_ptr<Entity> source, double x, double y, double z, float r)
|
||||
{
|
||||
fire = false;
|
||||
random = new Random();
|
||||
@@ -97,14 +97,14 @@ void Explosion::explode()
|
||||
// Fix for 360 #123866 - [CRASH] TU13: Code: Compliance: Placing the TNT next to Ender Crystals will crash the title after a certain amount of time.
|
||||
// If we explode something next to an EnderCrystal then it creates a new explosion that overwrites the shared vector in the level
|
||||
// So copy it here instead of directly using the shared one
|
||||
vector<shared_ptr<Entity> > *levelEntities = level->getEntities(source, AABB::newTemp(x0, y0, z0, x1, y1, z1));
|
||||
vector<shared_ptr<Entity> > entities(levelEntities->begin(), levelEntities->end() );
|
||||
std::vector<std::shared_ptr<Entity> > *levelEntities = level->getEntities(source, AABB::newTemp(x0, y0, z0, x1, y1, z1));
|
||||
std::vector<std::shared_ptr<Entity> > entities(levelEntities->begin(), levelEntities->end() );
|
||||
Vec3 *center = Vec3::newTemp(x, y, z);
|
||||
|
||||
AUTO_VAR(itEnd, entities.end());
|
||||
for (AUTO_VAR(it, entities.begin()); it != itEnd; it++)
|
||||
{
|
||||
shared_ptr<Entity> e = *it; //entities->at(i);
|
||||
std::shared_ptr<Entity> e = *it; //entities->at(i);
|
||||
|
||||
// 4J Stu - If the entity is not in a block that would be blown up, then they should not be damaged
|
||||
// Fix for #46606 - TU5: Content: Gameplay: The player can be damaged and killed by explosions behind obsidian walls
|
||||
@@ -149,7 +149,7 @@ void Explosion::explode()
|
||||
e->yd += ya * push;
|
||||
e->zd += za * push;
|
||||
|
||||
shared_ptr<Player> player = dynamic_pointer_cast<Player>(e);
|
||||
std::shared_ptr<Player> player = std::dynamic_pointer_cast<Player>(e);
|
||||
if (player != NULL)
|
||||
{
|
||||
//app.DebugPrintf("Adding player knockback (%f,%f,%f)\n", xa * pow, ya * pow, za * pow);
|
||||
@@ -161,13 +161,13 @@ void Explosion::explode()
|
||||
}
|
||||
|
||||
|
||||
void Explosion::finalizeExplosion(bool generateParticles, vector<TilePos> *toBlowDirect/*=NULL*/) // 4J - added toBlowDirect parameter
|
||||
void Explosion::finalizeExplosion(bool generateParticles, std::vector<TilePos> *toBlowDirect/*=NULL*/) // 4J - added toBlowDirect parameter
|
||||
{
|
||||
level->playSound(x, y, z, eSoundType_RANDOM_EXPLODE, 4, (1 + (level->random->nextFloat() - level->random->nextFloat()) * 0.2f) * 0.7f);
|
||||
level->addParticle(eParticleType_hugeexplosion, x, y, z, 0, 0, 0);
|
||||
|
||||
// 4J - use pointer to vector directly passed in if this is available - used to speed up calling this from an incoming packet
|
||||
vector<TilePos> *toBlowArray = toBlowDirect ? toBlowDirect : new vector<TilePos>( toBlow.begin(), toBlow.end() );
|
||||
std::vector<TilePos> *toBlowArray = toBlowDirect ? toBlowDirect : new std::vector<TilePos>( toBlow.begin(), toBlow.end() );
|
||||
//toBlowArray.addAll(toBlow);
|
||||
// TODO 4J Stu - Reverse iterator
|
||||
PIXBeginNamedEvent(0,"Finalizing explosion size %d",toBlow.size());
|
||||
@@ -255,7 +255,7 @@ Explosion::playerVec3Map *Explosion::getHitPlayers()
|
||||
return &hitPlayers;
|
||||
}
|
||||
|
||||
Vec3 *Explosion::getHitPlayerKnockback( shared_ptr<Player> player )
|
||||
Vec3 *Explosion::getHitPlayerKnockback( std::shared_ptr<Player> player )
|
||||
{
|
||||
AUTO_VAR(it, hitPlayers.find(player));
|
||||
|
||||
|
||||
@@ -19,24 +19,24 @@ private:
|
||||
|
||||
public:
|
||||
double x, y, z;
|
||||
shared_ptr<Entity> source;
|
||||
std::shared_ptr<Entity> source;
|
||||
float r;
|
||||
|
||||
unordered_set<TilePos, TilePosKeyHash, TilePosKeyEq> toBlow;
|
||||
std::unordered_set<TilePos, TilePosKeyHash, TilePosKeyEq> toBlow;
|
||||
|
||||
private:
|
||||
typedef unordered_map<shared_ptr<Player>, Vec3 * , PlayerKeyHash, PlayerKeyEq> playerVec3Map;
|
||||
typedef std::unordered_map<std::shared_ptr<Player>, Vec3 * , PlayerKeyHash, PlayerKeyEq> playerVec3Map;
|
||||
playerVec3Map hitPlayers;
|
||||
|
||||
public:
|
||||
Explosion(Level *level, shared_ptr<Entity> source, double x, double y, double z, float r);
|
||||
Explosion(Level *level, std::shared_ptr<Entity> source, double x, double y, double z, float r);
|
||||
~Explosion();
|
||||
|
||||
public:
|
||||
void explode();
|
||||
|
||||
public:
|
||||
void finalizeExplosion(bool generateParticles, vector<TilePos> *toBlowDirect = NULL); // 4J - added toBlow parameter
|
||||
void finalizeExplosion(bool generateParticles, std::vector<TilePos> *toBlowDirect = NULL); // 4J - added toBlow parameter
|
||||
playerVec3Map *getHitPlayers();
|
||||
Vec3 *getHitPlayerKnockback( shared_ptr<Player> player );
|
||||
Vec3 *getHitPlayerKnockback( std::shared_ptr<Player> player );
|
||||
};
|
||||
+120
-120
@@ -558,20 +558,20 @@ BiomeSource *Level::getBiomeSource()
|
||||
return dimension->biomeSource;
|
||||
}
|
||||
|
||||
Level::Level(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();
|
||||
this->levelStorage = levelStorage;//shared_ptr<LevelStorage>(levelStorage);
|
||||
this->levelStorage = levelStorage;//std::shared_ptr<LevelStorage>(levelStorage);
|
||||
this->dimension = dimension;
|
||||
this->levelData = new LevelData(levelSettings, name);
|
||||
if( !this->levelData->useNewSeaLevel() ) seaLevel = Level::genDepth / 2; // 4J added - sea level is one unit lower since 1.8.2, maintain older height for old levels
|
||||
this->savedDataStorage = new SavedDataStorage(levelStorage.get());
|
||||
|
||||
shared_ptr<Villages> savedVillages = dynamic_pointer_cast<Villages>(savedDataStorage->get(typeid(Villages), Villages::VILLAGE_FILE_ID));
|
||||
std::shared_ptr<Villages> savedVillages = std::dynamic_pointer_cast<Villages>(savedDataStorage->get(typeid(Villages), Villages::VILLAGE_FILE_ID));
|
||||
if (savedVillages == NULL)
|
||||
{
|
||||
villages = shared_ptr<Villages>(new Villages(this));
|
||||
villages = std::shared_ptr<Villages>(new Villages(this));
|
||||
savedDataStorage->set(Villages::VILLAGE_FILE_ID, villages);
|
||||
}
|
||||
else
|
||||
@@ -597,10 +597,10 @@ Level::Level(Level *level, Dimension *dimension)
|
||||
if( !this->levelData->useNewSeaLevel() ) seaLevel = Level::genDepth / 2; // 4J added - sea level is one unit lower since 1.8.2, maintain older height for old levels
|
||||
this->savedDataStorage = new SavedDataStorage( levelStorage.get() );
|
||||
|
||||
shared_ptr<Villages> savedVillages = dynamic_pointer_cast<Villages>(savedDataStorage->get(typeid(Villages), Villages::VILLAGE_FILE_ID));
|
||||
std::shared_ptr<Villages> savedVillages = std::dynamic_pointer_cast<Villages>(savedDataStorage->get(typeid(Villages), Villages::VILLAGE_FILE_ID));
|
||||
if (savedVillages == NULL)
|
||||
{
|
||||
villages = shared_ptr<Villages>(new Villages(this));
|
||||
villages = std::shared_ptr<Villages>(new Villages(this));
|
||||
savedDataStorage->set(Villages::VILLAGE_FILE_ID, villages);
|
||||
}
|
||||
else
|
||||
@@ -617,29 +617,29 @@ Level::Level(Level *level, Dimension *dimension)
|
||||
}
|
||||
|
||||
|
||||
Level::Level(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(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(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;//shared_ptr<LevelStorage>(levelStorage);
|
||||
this->levelStorage = levelStorage;//std::shared_ptr<LevelStorage>(levelStorage);
|
||||
this->savedDataStorage = new SavedDataStorage(levelStorage.get());
|
||||
|
||||
shared_ptr<Villages> savedVillages = dynamic_pointer_cast<Villages>(savedDataStorage->get(typeid(Villages), Villages::VILLAGE_FILE_ID));
|
||||
std::shared_ptr<Villages> savedVillages = std::dynamic_pointer_cast<Villages>(savedDataStorage->get(typeid(Villages), Villages::VILLAGE_FILE_ID));
|
||||
if (savedVillages == NULL)
|
||||
{
|
||||
villages = shared_ptr<Villages>(new Villages(this));
|
||||
villages = std::shared_ptr<Villages>(new Villages(this));
|
||||
savedDataStorage->set(Villages::VILLAGE_FILE_ID, villages);
|
||||
}
|
||||
else
|
||||
@@ -1581,7 +1581,7 @@ HitResult *Level::clip(Vec3 *a, Vec3 *b, bool liquid, bool solidOnly)
|
||||
}
|
||||
|
||||
|
||||
void Level::playSound(shared_ptr<Entity> entity, int iSound, float volume, float pitch)
|
||||
void Level::playSound(std::shared_ptr<Entity> entity, int iSound, float volume, float pitch)
|
||||
{
|
||||
if(entity == NULL) return;
|
||||
AUTO_VAR(itEnd, listeners.end());
|
||||
@@ -1602,7 +1602,7 @@ void Level::playSound(shared_ptr<Entity> entity, int iSound, float volume, float
|
||||
}
|
||||
|
||||
|
||||
//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++)
|
||||
@@ -1648,7 +1648,7 @@ void Level::addParticle(ePARTICLE_TYPE id, double x, double y, double z, double
|
||||
(*it)->addParticle(id, x, y, z, xd, yd, zd);
|
||||
}
|
||||
|
||||
bool Level::addGlobalEntity(shared_ptr<Entity> e)
|
||||
bool Level::addGlobalEntity(std::shared_ptr<Entity> e)
|
||||
{
|
||||
globalEntities.push_back(e);
|
||||
return true;
|
||||
@@ -1656,7 +1656,7 @@ bool Level::addGlobalEntity(shared_ptr<Entity> e)
|
||||
|
||||
#pragma optimize( "", off )
|
||||
|
||||
bool Level::addEntity(shared_ptr<Entity> e)
|
||||
bool Level::addEntity(std::shared_ptr<Entity> e)
|
||||
{
|
||||
int xc = Mth::floor(e->x / 16);
|
||||
int zc = Mth::floor(e->z / 16);
|
||||
@@ -1667,16 +1667,16 @@ bool Level::addEntity(shared_ptr<Entity> e)
|
||||
}
|
||||
|
||||
bool forced = false;
|
||||
if (dynamic_pointer_cast<Player>( e ) != NULL)
|
||||
if (std::dynamic_pointer_cast<Player>( e ) != NULL)
|
||||
{
|
||||
forced = true;
|
||||
}
|
||||
|
||||
if (forced || hasChunk(xc, zc))
|
||||
{
|
||||
if (dynamic_pointer_cast<Player>( e ) != NULL)
|
||||
if (std::dynamic_pointer_cast<Player>( e ) != NULL)
|
||||
{
|
||||
shared_ptr<Player> player = dynamic_pointer_cast<Player>(e);
|
||||
std::shared_ptr<Player> player = std::dynamic_pointer_cast<Player>(e);
|
||||
|
||||
// 4J Stu - Added so we don't continually add the player to the players list while they are dead
|
||||
if( find( players.begin(), players.end(), e ) == players.end() )
|
||||
@@ -1704,7 +1704,7 @@ bool Level::addEntity(shared_ptr<Entity> e)
|
||||
|
||||
#pragma optimize( "", on )
|
||||
|
||||
void Level::entityAdded(shared_ptr<Entity> e)
|
||||
void Level::entityAdded(std::shared_ptr<Entity> e)
|
||||
{
|
||||
AUTO_VAR(itEnd, listeners.end());
|
||||
for (AUTO_VAR(it, listeners.begin()); it != itEnd; it++)
|
||||
@@ -1714,7 +1714,7 @@ void Level::entityAdded(shared_ptr<Entity> e)
|
||||
}
|
||||
|
||||
|
||||
void Level::entityRemoved(shared_ptr<Entity> e)
|
||||
void Level::entityRemoved(std::shared_ptr<Entity> e)
|
||||
{
|
||||
AUTO_VAR(itEnd, listeners.end());
|
||||
for (AUTO_VAR(it, listeners.begin()); it != itEnd; it++)
|
||||
@@ -1724,7 +1724,7 @@ void Level::entityRemoved(shared_ptr<Entity> e)
|
||||
}
|
||||
|
||||
// 4J added
|
||||
void Level::playerRemoved(shared_ptr<Entity> e)
|
||||
void Level::playerRemoved(std::shared_ptr<Entity> e)
|
||||
{
|
||||
AUTO_VAR(itEnd, listeners.end());
|
||||
for (AUTO_VAR(it, listeners.begin()); it != itEnd; it++)
|
||||
@@ -1733,7 +1733,7 @@ void Level::playerRemoved(shared_ptr<Entity> e)
|
||||
}
|
||||
}
|
||||
|
||||
void Level::removeEntity(shared_ptr<Entity> e)
|
||||
void Level::removeEntity(std::shared_ptr<Entity> e)
|
||||
{
|
||||
if (e->rider.lock() != NULL)
|
||||
{
|
||||
@@ -1744,11 +1744,11 @@ void Level::removeEntity(shared_ptr<Entity> e)
|
||||
e->ride(nullptr);
|
||||
}
|
||||
e->remove();
|
||||
if (dynamic_pointer_cast<Player>( e ) != NULL)
|
||||
if (std::dynamic_pointer_cast<Player>( e ) != NULL)
|
||||
{
|
||||
vector<shared_ptr<Player> >::iterator it = players.begin();
|
||||
vector<shared_ptr<Player> >::iterator itEnd = players.end();
|
||||
while( it != itEnd && *it != dynamic_pointer_cast<Player>(e) )
|
||||
std::vector<std::shared_ptr<Player> >::iterator it = players.begin();
|
||||
std::vector<std::shared_ptr<Player> >::iterator itEnd = players.end();
|
||||
while( it != itEnd && *it != std::dynamic_pointer_cast<Player>(e) )
|
||||
it++;
|
||||
|
||||
if( it != itEnd )
|
||||
@@ -1762,15 +1762,15 @@ void Level::removeEntity(shared_ptr<Entity> e)
|
||||
}
|
||||
|
||||
|
||||
void Level::removeEntityImmediately(shared_ptr<Entity> e)
|
||||
void Level::removeEntityImmediately(std::shared_ptr<Entity> e)
|
||||
{
|
||||
e->remove();
|
||||
|
||||
if (dynamic_pointer_cast<Player>( e ) != NULL)
|
||||
if (std::dynamic_pointer_cast<Player>( e ) != NULL)
|
||||
{
|
||||
vector<shared_ptr<Player> >::iterator it = players.begin();
|
||||
vector<shared_ptr<Player> >::iterator itEnd = players.end();
|
||||
while( it != itEnd && *it != dynamic_pointer_cast<Player>(e) )
|
||||
std::vector<std::shared_ptr<Player> >::iterator it = players.begin();
|
||||
std::vector<std::shared_ptr<Player> >::iterator itEnd = players.end();
|
||||
while( it != itEnd && *it != std::dynamic_pointer_cast<Player>(e) )
|
||||
it++;
|
||||
|
||||
if( it != itEnd )
|
||||
@@ -1790,8 +1790,8 @@ void Level::removeEntityImmediately(shared_ptr<Entity> e)
|
||||
}
|
||||
|
||||
EnterCriticalSection(&m_entitiesCS);
|
||||
vector<shared_ptr<Entity> >::iterator it = entities.begin();
|
||||
vector<shared_ptr<Entity> >::iterator endIt = entities.end();
|
||||
std::vector<std::shared_ptr<Entity> >::iterator it = entities.begin();
|
||||
std::vector<std::shared_ptr<Entity> >::iterator endIt = entities.end();
|
||||
while( it != endIt && *it != e)
|
||||
it++;
|
||||
|
||||
@@ -1812,8 +1812,8 @@ void Level::addListener(LevelListener *listener)
|
||||
|
||||
void Level::removeListener(LevelListener *listener)
|
||||
{
|
||||
vector<LevelListener *>::iterator it = listeners.begin();
|
||||
vector<LevelListener *>::iterator itEnd = listeners.end();
|
||||
std::vector<LevelListener *>::iterator it = listeners.begin();
|
||||
std::vector<LevelListener *>::iterator itEnd = listeners.end();
|
||||
while( it != itEnd && *it != listener )
|
||||
it++;
|
||||
|
||||
@@ -1823,7 +1823,7 @@ void Level::removeListener(LevelListener *listener)
|
||||
|
||||
|
||||
// 4J - added noEntities and blockAtEdge parameter
|
||||
AABBList *Level::getCubes(shared_ptr<Entity> source, AABB *box, bool noEntities, bool blockAtEdge)
|
||||
AABBList *Level::getCubes(std::shared_ptr<Entity> source, AABB *box, bool noEntities, bool blockAtEdge)
|
||||
{
|
||||
boxes.clear();
|
||||
int x0 = Mth::floor(box->x0);
|
||||
@@ -1895,8 +1895,8 @@ AABBList *Level::getCubes(shared_ptr<Entity> source, AABB *box, bool noEntities,
|
||||
if( noEntities ) return &boxes;
|
||||
|
||||
double r = 0.25;
|
||||
vector<shared_ptr<Entity> > *ee = getEntities(source, box->grow(r, r, r));
|
||||
vector<shared_ptr<Entity> >::iterator itEnd = ee->end();
|
||||
std::vector<std::shared_ptr<Entity> > *ee = getEntities(source, box->grow(r, r, r));
|
||||
std::vector<std::shared_ptr<Entity> >::iterator itEnd = ee->end();
|
||||
for (AUTO_VAR(it, ee->begin()); it != itEnd; it++)
|
||||
{
|
||||
AABB *collideBox = (*it)->getCollideBox();
|
||||
@@ -1986,7 +1986,7 @@ float Level::getSkyDarken(float a)
|
||||
|
||||
|
||||
|
||||
Vec3 *Level::getSkyColor(shared_ptr<Entity> source, float a)
|
||||
Vec3 *Level::getSkyColor(std::shared_ptr<Entity> source, float a)
|
||||
{
|
||||
float td = getTimeOfDay(a);
|
||||
|
||||
@@ -2197,10 +2197,10 @@ void Level::forceAddTileTick(int x, int y, int z, int tileId, int tickDelay)
|
||||
void Level::tickEntities()
|
||||
{
|
||||
//for (int i = 0; i < globalEntities.size(); i++)
|
||||
vector<shared_ptr<Entity> >::iterator itGE = globalEntities.begin();
|
||||
std::vector<std::shared_ptr<Entity> >::iterator itGE = globalEntities.begin();
|
||||
while( itGE != globalEntities.end() )
|
||||
{
|
||||
shared_ptr<Entity> e = *itGE;//globalEntities.at(i);
|
||||
std::shared_ptr<Entity> e = *itGE;//globalEntities.at(i);
|
||||
e->tick();
|
||||
if (e->removed)
|
||||
{
|
||||
@@ -2241,7 +2241,7 @@ void Level::tickEntities()
|
||||
AUTO_VAR(itETREnd, entitiesToRemove.end());
|
||||
for (AUTO_VAR(it, entitiesToRemove.begin()); it != itETREnd; it++)
|
||||
{
|
||||
shared_ptr<Entity> e = *it;//entitiesToRemove.at(j);
|
||||
std::shared_ptr<Entity> e = *it;//entitiesToRemove.at(j);
|
||||
int xc = e->xChunk;
|
||||
int zc = e->zChunk;
|
||||
if (e->inChunk && hasChunk(xc, zc))
|
||||
@@ -2267,13 +2267,13 @@ void Level::tickEntities()
|
||||
|
||||
for (unsigned int i = 0; i < entities.size(); )
|
||||
{
|
||||
shared_ptr<Entity> e = entities.at(i);
|
||||
std::shared_ptr<Entity> e = entities.at(i);
|
||||
|
||||
if (e->riding != NULL)
|
||||
{
|
||||
if (e->riding->removed || e->riding->rider.lock() != e)
|
||||
{
|
||||
e->riding->rider = weak_ptr<Entity>();
|
||||
e->riding->rider = std::weak_ptr<Entity>();
|
||||
e->riding = nullptr;
|
||||
}
|
||||
else
|
||||
@@ -2286,7 +2286,7 @@ void Level::tickEntities()
|
||||
if (!e->removed)
|
||||
{
|
||||
#ifndef _FINAL_BUILD
|
||||
if(!( app.DebugSettingsOn() && app.GetMobsDontTickEnabled() && (dynamic_pointer_cast<Mob>(e) != NULL) && (dynamic_pointer_cast<Player>(e) == NULL)))
|
||||
if(!( app.DebugSettingsOn() && app.GetMobsDontTickEnabled() && (std::dynamic_pointer_cast<Mob>(e) != NULL) && (std::dynamic_pointer_cast<Player>(e) == NULL)))
|
||||
#endif
|
||||
{
|
||||
tick(e);
|
||||
@@ -2326,7 +2326,7 @@ void Level::tickEntities()
|
||||
updatingTileEntities = true;
|
||||
for (AUTO_VAR(it, tileEntityList.begin()); it != tileEntityList.end();)
|
||||
{
|
||||
shared_ptr<TileEntity> te = *it;//tilevector<shared_ptr<Entity> >.at(i);
|
||||
std::shared_ptr<TileEntity> te = *it;//tilestd::vector<std::shared_ptr<Entity> >.at(i);
|
||||
if( !te->isRemoved() && te->hasLevel() )
|
||||
{
|
||||
if (hasChunkAt(te->x, te->y, te->z))
|
||||
@@ -2394,7 +2394,7 @@ void Level::tickEntities()
|
||||
{
|
||||
for( AUTO_VAR(it, pendingTileEntities.begin()); it != pendingTileEntities.end(); it++ )
|
||||
{
|
||||
shared_ptr<TileEntity> e = *it;
|
||||
std::shared_ptr<TileEntity> e = *it;
|
||||
if( !e->isRemoved() )
|
||||
{
|
||||
if( find(tileEntityList.begin(),tileEntityList.end(),e) == tileEntityList.end() )
|
||||
@@ -2415,7 +2415,7 @@ void Level::tickEntities()
|
||||
LeaveCriticalSection(&m_tileEntityListCS);
|
||||
}
|
||||
|
||||
void Level::addAllPendingTileEntities(vector< shared_ptr<TileEntity> >& entities)
|
||||
void Level::addAllPendingTileEntities(std::vector< std::shared_ptr<TileEntity> >& entities)
|
||||
{
|
||||
EnterCriticalSection(&m_tileEntityListCS);
|
||||
if( updatingTileEntities )
|
||||
@@ -2435,13 +2435,13 @@ void Level::addAllPendingTileEntities(vector< shared_ptr<TileEntity> >& entities
|
||||
LeaveCriticalSection(&m_tileEntityListCS);
|
||||
}
|
||||
|
||||
void Level::tick(shared_ptr<Entity> e)
|
||||
void Level::tick(std::shared_ptr<Entity> e)
|
||||
{
|
||||
tick(e, true);
|
||||
}
|
||||
|
||||
|
||||
void Level::tick(shared_ptr<Entity> e, bool actual)
|
||||
void Level::tick(std::shared_ptr<Entity> e, bool actual)
|
||||
{
|
||||
int xc = Mth::floor(e->x);
|
||||
int zc = Mth::floor(e->z);
|
||||
@@ -2521,7 +2521,7 @@ void Level::tick(shared_ptr<Entity> e, bool actual)
|
||||
if (e->rider.lock()->removed || e->rider.lock()->riding != e)
|
||||
{
|
||||
e->rider.lock()->riding = nullptr;
|
||||
e->rider = weak_ptr<Entity>();
|
||||
e->rider = std::weak_ptr<Entity>();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2537,13 +2537,13 @@ bool Level::isUnobstructed(AABB *aabb)
|
||||
return isUnobstructed(aabb, nullptr);
|
||||
}
|
||||
|
||||
bool Level::isUnobstructed(AABB *aabb, shared_ptr<Entity> ignore)
|
||||
bool Level::isUnobstructed(AABB *aabb, std::shared_ptr<Entity> ignore)
|
||||
{
|
||||
vector<shared_ptr<Entity> > *ents = getEntities(nullptr, aabb);
|
||||
std::vector<std::shared_ptr<Entity> > *ents = getEntities(nullptr, aabb);
|
||||
AUTO_VAR(itEnd, ents->end());
|
||||
for (AUTO_VAR(it, ents->begin()); it != itEnd; it++)
|
||||
{
|
||||
shared_ptr<Entity> e = *it;
|
||||
std::shared_ptr<Entity> e = *it;
|
||||
if (!e->removed && e->blocksBuilding && e != ignore) return false;
|
||||
}
|
||||
return true;
|
||||
@@ -2658,7 +2658,7 @@ bool Level::containsFireTile(AABB *box)
|
||||
}
|
||||
|
||||
|
||||
bool Level::checkAndHandleWater(AABB *box, Material *material, shared_ptr<Entity> e)
|
||||
bool Level::checkAndHandleWater(AABB *box, Material *material, std::shared_ptr<Entity> e)
|
||||
{
|
||||
int x0 = Mth::floor(box->x0);
|
||||
int x1 = Mth::floor(box->x1 + 1);
|
||||
@@ -2758,15 +2758,15 @@ bool Level::containsLiquid(AABB *box, Material *material)
|
||||
}
|
||||
|
||||
|
||||
shared_ptr<Explosion> Level::explode(shared_ptr<Entity> source, double x, double y, double z, float r, bool destroyBlocks)
|
||||
std::shared_ptr<Explosion> Level::explode(std::shared_ptr<Entity> source, double x, double y, double z, float r, bool destroyBlocks)
|
||||
{
|
||||
return explode(source, x, y, z, r, false, destroyBlocks);
|
||||
}
|
||||
|
||||
|
||||
shared_ptr<Explosion> Level::explode(shared_ptr<Entity> source, double x, double y, double z, float r, bool fire, bool destroyBlocks)
|
||||
std::shared_ptr<Explosion> Level::explode(std::shared_ptr<Entity> source, double x, double y, double z, float r, bool fire, bool destroyBlocks)
|
||||
{
|
||||
shared_ptr<Explosion> explosion = shared_ptr<Explosion>( new Explosion(this, source, x, y, z, r) );
|
||||
std::shared_ptr<Explosion> explosion = std::shared_ptr<Explosion>( new Explosion(this, source, x, y, z, r) );
|
||||
explosion->fire = fire;
|
||||
explosion->destroyBlocks = destroyBlocks;
|
||||
explosion->explode();
|
||||
@@ -2799,7 +2799,7 @@ float Level::getSeenPercent(Vec3 *center, AABB *bb)
|
||||
}
|
||||
|
||||
|
||||
bool Level::extinguishFire(shared_ptr<Player> player, int x, int y, int z, int face)
|
||||
bool Level::extinguishFire(std::shared_ptr<Player> player, int x, int y, int z, int face)
|
||||
{
|
||||
if (face == 0) y--;
|
||||
if (face == 1) y++;
|
||||
@@ -2818,30 +2818,30 @@ bool Level::extinguishFire(shared_ptr<Player> player, int x, int y, int z, int f
|
||||
}
|
||||
|
||||
/*
|
||||
shared_ptr<Entity> Level::findSubclassOf(Entity::Class *entityClass)
|
||||
std::shared_ptr<Entity> Level::findSubclassOf(Entity::Class *entityClass)
|
||||
{
|
||||
return shared_ptr<Entity>();
|
||||
return std::shared_ptr<Entity>();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
shared_ptr<TileEntity> Level::getTileEntity(int x, int y, int z)
|
||||
std::shared_ptr<TileEntity> Level::getTileEntity(int x, int y, int z)
|
||||
{
|
||||
if (y >= Level::maxBuildHeight)
|
||||
{
|
||||
@@ -2852,14 +2852,14 @@ shared_ptr<TileEntity> Level::getTileEntity(int x, int y, int z)
|
||||
|
||||
if (lc != NULL)
|
||||
{
|
||||
shared_ptr<TileEntity> tileEntity = lc->getTileEntity(x & 15, y, z & 15);
|
||||
std::shared_ptr<TileEntity> tileEntity = lc->getTileEntity(x & 15, y, z & 15);
|
||||
|
||||
if (tileEntity == NULL)
|
||||
{
|
||||
EnterCriticalSection(&m_tileEntityListCS);
|
||||
for( AUTO_VAR(it, pendingTileEntities.begin()); it != pendingTileEntities.end(); it++ )
|
||||
{
|
||||
shared_ptr<TileEntity> e = *it;
|
||||
std::shared_ptr<TileEntity> e = *it;
|
||||
|
||||
if (!e->isRemoved() && e->x == x && e->y == y && e->z == z)
|
||||
{
|
||||
@@ -2876,7 +2876,7 @@ shared_ptr<TileEntity> Level::getTileEntity(int x, int y, int z)
|
||||
}
|
||||
|
||||
|
||||
void Level::setTileEntity(int x, int y, int z, shared_ptr<TileEntity> tileEntity)
|
||||
void Level::setTileEntity(int x, int y, int z, std::shared_ptr<TileEntity> tileEntity)
|
||||
{
|
||||
if (tileEntity != NULL && !tileEntity->isRemoved())
|
||||
{
|
||||
@@ -2905,7 +2905,7 @@ void Level::setTileEntity(int x, int y, int z, shared_ptr<TileEntity> tileEntity
|
||||
void Level::removeTileEntity(int x, int y, int z)
|
||||
{
|
||||
EnterCriticalSection(&m_tileEntityListCS);
|
||||
shared_ptr<TileEntity> te = getTileEntity(x, y, z);
|
||||
std::shared_ptr<TileEntity> te = getTileEntity(x, y, z);
|
||||
if (te != NULL && updatingTileEntities)
|
||||
{
|
||||
te->setRemoved();
|
||||
@@ -2936,7 +2936,7 @@ void Level::removeTileEntity(int x, int y, int z)
|
||||
LeaveCriticalSection(&m_tileEntityListCS);
|
||||
}
|
||||
|
||||
void Level::markForRemoval(shared_ptr<TileEntity> entity)
|
||||
void Level::markForRemoval(std::shared_ptr<TileEntity> entity)
|
||||
{
|
||||
tileEntitiesToUnload.push_back(entity);
|
||||
}
|
||||
@@ -3163,7 +3163,7 @@ void Level::buildAndPrepareChunksToPoll()
|
||||
AUTO_VAR(itEnd, players.end());
|
||||
for (AUTO_VAR(it, players.begin()); it != itEnd; it++)
|
||||
{
|
||||
shared_ptr<Player> player = *it;
|
||||
std::shared_ptr<Player> player = *it;
|
||||
int xx = Mth::floor(player->x / 16);
|
||||
int zz = Mth::floor(player->z / 16);
|
||||
|
||||
@@ -3183,7 +3183,7 @@ void Level::buildAndPrepareChunksToPoll()
|
||||
int *zz = new int[playerCount];
|
||||
for (int i = 0; i < playerCount; i++)
|
||||
{
|
||||
shared_ptr<Player> player = players[i];
|
||||
std::shared_ptr<Player> player = players[i];
|
||||
xx[i] = Mth::floor(player->x / 16);
|
||||
zz[i] = Mth::floor(player->z / 16);
|
||||
chunksToPoll.insert(ChunkPos(xx[i], zz[i] ));
|
||||
@@ -3239,7 +3239,7 @@ void Level::tickClientSideTiles(int xo, int zo, LevelChunk *lc)
|
||||
z += zo;
|
||||
if (id == 0 && this->getDaytimeRawBrightness(x, y, z) <= random->nextInt(8) && getBrightness(LightLayer::Sky, x, y, z) <= 0)
|
||||
{
|
||||
shared_ptr<Player> player = getNearestPlayer(x + 0.5, y + 0.5, z + 0.5, 8);
|
||||
std::shared_ptr<Player> player = getNearestPlayer(x + 0.5, y + 0.5, z + 0.5, 8);
|
||||
if (player != NULL && player->distanceToSqr(x + 0.5, y + 0.5, z + 0.5) > 2 * 2)
|
||||
{
|
||||
// 4J-PB - Fixed issue with cave audio event having 2 sounds at 192k
|
||||
@@ -3722,13 +3722,13 @@ bool Level::tickPendingTicks(bool force)
|
||||
return false;
|
||||
}
|
||||
|
||||
vector<TickNextTickData> *Level::fetchTicksInChunk(LevelChunk *chunk, bool remove)
|
||||
std::vector<TickNextTickData> *Level::fetchTicksInChunk(LevelChunk *chunk, bool remove)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
vector<shared_ptr<Entity> > *Level::getEntities(shared_ptr<Entity> except, AABB *bb)
|
||||
std::vector<std::shared_ptr<Entity> > *Level::getEntities(std::shared_ptr<Entity> except, AABB *bb)
|
||||
{
|
||||
MemSect(40);
|
||||
es.clear();
|
||||
@@ -3768,13 +3768,13 @@ vector<shared_ptr<Entity> > *Level::getEntities(shared_ptr<Entity> except, AABB
|
||||
}
|
||||
|
||||
|
||||
vector<shared_ptr<Entity> > *Level::getEntitiesOfClass(const type_info& baseClass, AABB *bb)
|
||||
std::vector<std::shared_ptr<Entity> > *Level::getEntitiesOfClass(const std::type_info& baseClass, AABB *bb)
|
||||
{
|
||||
int xc0 = Mth::floor((bb->x0 - 2) / 16);
|
||||
int xc1 = Mth::floor((bb->x1 + 2) / 16);
|
||||
int zc0 = Mth::floor((bb->z0 - 2) / 16);
|
||||
int zc1 = Mth::floor((bb->z1 + 2) / 16);
|
||||
vector<shared_ptr<Entity> > *es = new vector<shared_ptr<Entity> >();
|
||||
std::vector<std::shared_ptr<Entity> > *es = new std::vector<std::shared_ptr<Entity> >();
|
||||
|
||||
#ifdef __PSVITA__
|
||||
#ifdef _ENTITIES_RW_SECTION
|
||||
@@ -3805,15 +3805,15 @@ vector<shared_ptr<Entity> > *Level::getEntitiesOfClass(const type_info& baseClas
|
||||
return es;
|
||||
}
|
||||
|
||||
shared_ptr<Entity> Level::getClosestEntityOfClass(const type_info& baseClass, AABB *bb, shared_ptr<Entity> source)
|
||||
std::shared_ptr<Entity> Level::getClosestEntityOfClass(const std::type_info& baseClass, AABB *bb, std::shared_ptr<Entity> source)
|
||||
{
|
||||
vector<shared_ptr<Entity> > *entities = getEntitiesOfClass(baseClass, bb);
|
||||
shared_ptr<Entity> closest = nullptr;
|
||||
std::vector<std::shared_ptr<Entity> > *entities = getEntitiesOfClass(baseClass, bb);
|
||||
std::shared_ptr<Entity> closest = nullptr;
|
||||
double closestDistSqr = Double::MAX_VALUE;
|
||||
//for (Entity entity : entities)
|
||||
for(AUTO_VAR(it, entities->begin()); it != entities->end(); ++it)
|
||||
{
|
||||
shared_ptr<Entity> entity = *it;
|
||||
std::shared_ptr<Entity> entity = *it;
|
||||
if (entity == source) continue;
|
||||
double distSqr = source->distanceToSqr(entity);
|
||||
if (distSqr > closestDistSqr) continue;
|
||||
@@ -3824,16 +3824,16 @@ shared_ptr<Entity> Level::getClosestEntityOfClass(const type_info& baseClass, AA
|
||||
return closest;
|
||||
}
|
||||
|
||||
vector<shared_ptr<Entity> > Level::getAllEntities()
|
||||
std::vector<std::shared_ptr<Entity> > Level::getAllEntities()
|
||||
{
|
||||
EnterCriticalSection(&m_entitiesCS);
|
||||
vector<shared_ptr<Entity> > retVec = entities;
|
||||
std::vector<std::shared_ptr<Entity> > retVec = entities;
|
||||
LeaveCriticalSection(&m_entitiesCS);
|
||||
return retVec;
|
||||
}
|
||||
|
||||
|
||||
void Level::tileEntityChanged(int x, int y, int z, shared_ptr<TileEntity> te)
|
||||
void Level::tileEntityChanged(int x, int y, int z, std::shared_ptr<TileEntity> te)
|
||||
{
|
||||
if (this->hasChunkAt(x, y, z))
|
||||
{
|
||||
@@ -3849,7 +3849,7 @@ unsigned int Level::countInstanceOf(BaseObject::Class *clas)
|
||||
AUTO_VAR(itEnd, entities.end());
|
||||
for (AUTO_VAR(it, entities.begin()); it != itEnd; it++)
|
||||
{
|
||||
shared_ptr<Entity> e = *it;//entities.at(i);
|
||||
std::shared_ptr<Entity> e = *it;//entities.at(i);
|
||||
if (clas->isAssignableFrom(e->getClass())) count++;
|
||||
}
|
||||
LeaveCriticalSection(&m_entitiesCS);
|
||||
@@ -3869,7 +3869,7 @@ unsigned int Level::countInstanceOf(eINSTANCEOF clas, bool singleType, unsigned
|
||||
AUTO_VAR(itEnd, entities.end());
|
||||
for (AUTO_VAR(it, entities.begin()); it != itEnd; it++)
|
||||
{
|
||||
shared_ptr<Entity> e = *it;//entities.at(i);
|
||||
std::shared_ptr<Entity> e = *it;//entities.at(i);
|
||||
if( singleType )
|
||||
{
|
||||
if (e->GetType() == clas)
|
||||
@@ -3904,7 +3904,7 @@ unsigned int Level::countInstanceOfInRange(eINSTANCEOF clas, bool singleType, in
|
||||
AUTO_VAR(itEnd, entities.end());
|
||||
for (AUTO_VAR(it, entities.begin()); it != itEnd; it++)
|
||||
{
|
||||
shared_ptr<Entity> e = *it;//entities.at(i);
|
||||
std::shared_ptr<Entity> e = *it;//entities.at(i);
|
||||
|
||||
float sd = e->distanceTo(x,y,z);
|
||||
if (sd * sd > range * range)
|
||||
@@ -3932,7 +3932,7 @@ unsigned int Level::countInstanceOfInRange(eINSTANCEOF clas, bool singleType, in
|
||||
return count;
|
||||
}
|
||||
|
||||
void Level::addEntities(vector<shared_ptr<Entity> > *list)
|
||||
void Level::addEntities(std::vector<std::shared_ptr<Entity> > *list)
|
||||
{
|
||||
//entities.addAll(list);
|
||||
EnterCriticalSection(&m_entitiesCS);
|
||||
@@ -3973,13 +3973,13 @@ void Level::addEntities(vector<shared_ptr<Entity> > *list)
|
||||
}
|
||||
|
||||
|
||||
void Level::removeEntities(vector<shared_ptr<Entity> > *list)
|
||||
void Level::removeEntities(std::vector<std::shared_ptr<Entity> > *list)
|
||||
{
|
||||
//entitiesToRemove.addAll(list);
|
||||
entitiesToRemove.insert(entitiesToRemove.end(), list->begin(), list->end());
|
||||
}
|
||||
|
||||
bool Level::mayPlace(int tileId, int x, int y, int z, bool ignoreEntities, int face, shared_ptr<Entity> ignoreEntity)
|
||||
bool Level::mayPlace(int tileId, int x, int y, int z, bool ignoreEntities, int face, std::shared_ptr<Entity> ignoreEntity)
|
||||
{
|
||||
int targetType = getTile(x, y, z);
|
||||
Tile *targetTile = Tile::tiles[targetType];
|
||||
@@ -4010,7 +4010,7 @@ int Level::getSeaLevel()
|
||||
}
|
||||
|
||||
|
||||
Path *Level::findPath(shared_ptr<Entity> from, shared_ptr<Entity> to, float maxDist, bool canPassDoors, bool canOpenDoors, bool avoidWater, bool canFloat)
|
||||
Path *Level::findPath(std::shared_ptr<Entity> from, std::shared_ptr<Entity> to, float maxDist, bool canPassDoors, bool canOpenDoors, bool avoidWater, bool canFloat)
|
||||
{
|
||||
int x = Mth::floor(from->x);
|
||||
int y = Mth::floor(from->y + 1);
|
||||
@@ -4029,7 +4029,7 @@ Path *Level::findPath(shared_ptr<Entity> from, shared_ptr<Entity> to, float maxD
|
||||
}
|
||||
|
||||
|
||||
Path *Level::findPath(shared_ptr<Entity> from, int xBest, int yBest, int zBest, float maxDist, bool canPassDoors, bool canOpenDoors, bool avoidWater, bool canFloat)
|
||||
Path *Level::findPath(std::shared_ptr<Entity> from, int xBest, int yBest, int zBest, float maxDist, bool canPassDoors, bool canOpenDoors, bool avoidWater, bool canFloat)
|
||||
{
|
||||
int x = Mth::floor(from->x);
|
||||
int y = Mth::floor(from->y);
|
||||
@@ -4092,21 +4092,21 @@ bool Level::hasNeighborSignal(int x, int y, int z)
|
||||
}
|
||||
|
||||
// 4J Stu - Added maxYDist param
|
||||
shared_ptr<Player> Level::getNearestPlayer(shared_ptr<Entity> source, double maxDist, double maxYDist /*= -1*/)
|
||||
std::shared_ptr<Player> Level::getNearestPlayer(std::shared_ptr<Entity> source, double maxDist, double maxYDist /*= -1*/)
|
||||
{
|
||||
return getNearestPlayer(source->x, source->y, source->z, maxDist, maxYDist);
|
||||
}
|
||||
|
||||
// 4J Stu - Added maxYDist param
|
||||
shared_ptr<Player> Level::getNearestPlayer(double x, double y, double z, double maxDist, double maxYDist /*= -1*/)
|
||||
std::shared_ptr<Player> Level::getNearestPlayer(double x, double y, double z, double maxDist, double maxYDist /*= -1*/)
|
||||
{
|
||||
MemSect(21);
|
||||
double best = -1;
|
||||
shared_ptr<Player> result = nullptr;
|
||||
std::shared_ptr<Player> result = nullptr;
|
||||
AUTO_VAR(itEnd, players.end());
|
||||
for (AUTO_VAR(it, players.begin()); it != itEnd; it++)
|
||||
{
|
||||
shared_ptr<Player> p = *it;//players.at(i);
|
||||
std::shared_ptr<Player> p = *it;//players.at(i);
|
||||
double dist = p->distanceToSqr(x, y, z);
|
||||
|
||||
// Allow specifying shorter distances in the vertical
|
||||
@@ -4123,14 +4123,14 @@ shared_ptr<Player> Level::getNearestPlayer(double x, double y, double z, double
|
||||
return result;
|
||||
}
|
||||
|
||||
shared_ptr<Player> Level::getNearestPlayer(double x, double z, double maxDist)
|
||||
std::shared_ptr<Player> Level::getNearestPlayer(double x, double z, double maxDist)
|
||||
{
|
||||
double best = -1;
|
||||
shared_ptr<Player> result = nullptr;
|
||||
std::shared_ptr<Player> result = nullptr;
|
||||
AUTO_VAR(itEnd, players.end());
|
||||
for (AUTO_VAR(it, players.begin()); it != itEnd; it++)
|
||||
{
|
||||
shared_ptr<Player> p = *it;
|
||||
std::shared_ptr<Player> p = *it;
|
||||
double dist = p->distanceToSqr(x, p->y, z);
|
||||
if ((maxDist < 0 || dist < maxDist * maxDist) && (best == -1 || dist < best))
|
||||
{
|
||||
@@ -4141,20 +4141,20 @@ shared_ptr<Player> Level::getNearestPlayer(double x, double z, double maxDist)
|
||||
return result;
|
||||
}
|
||||
|
||||
shared_ptr<Player> Level::getNearestAttackablePlayer(shared_ptr<Entity> source, double maxDist)
|
||||
std::shared_ptr<Player> Level::getNearestAttackablePlayer(std::shared_ptr<Entity> source, double maxDist)
|
||||
{
|
||||
return getNearestAttackablePlayer(source->x, source->y, source->z, maxDist);
|
||||
}
|
||||
|
||||
shared_ptr<Player> Level::getNearestAttackablePlayer(double x, double y, double z, double maxDist)
|
||||
std::shared_ptr<Player> Level::getNearestAttackablePlayer(double x, double y, double z, double maxDist)
|
||||
{
|
||||
double best = -1;
|
||||
|
||||
shared_ptr<Player> result = nullptr;
|
||||
std::shared_ptr<Player> result = nullptr;
|
||||
AUTO_VAR(itEnd, players.end());
|
||||
for (AUTO_VAR(it, players.begin()); it != itEnd; it++)
|
||||
{
|
||||
shared_ptr<Player> p = *it;
|
||||
std::shared_ptr<Player> p = *it;
|
||||
|
||||
if (p->abilities.invulnerable)
|
||||
{
|
||||
@@ -4190,7 +4190,7 @@ shared_ptr<Player> Level::getNearestAttackablePlayer(double x, double y, double
|
||||
return result;
|
||||
}
|
||||
|
||||
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++)
|
||||
@@ -4200,10 +4200,10 @@ shared_ptr<Player> Level::getPlayerByName(const wstring& name)
|
||||
return *it; //players.at(i);
|
||||
}
|
||||
}
|
||||
return shared_ptr<Player>();
|
||||
return std::shared_ptr<Player>();
|
||||
}
|
||||
|
||||
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++)
|
||||
@@ -4213,7 +4213,7 @@ shared_ptr<Player> Level::getPlayerByUUID(const wstring& name)
|
||||
return *it; //players.at(i);
|
||||
}
|
||||
}
|
||||
return shared_ptr<Player>();
|
||||
return std::shared_ptr<Player>();
|
||||
}
|
||||
|
||||
// 4J Stu - Removed in 1.2.3 ?
|
||||
@@ -4353,7 +4353,7 @@ void Level::setTime(__int64 time)
|
||||
if ( timeDiff > 0 && levelData->getTime() != -1 )
|
||||
{
|
||||
AUTO_VAR(itEnd, players.end());
|
||||
for (vector<shared_ptr<Player> >::iterator it = players.begin(); it != itEnd; it++)
|
||||
for (std::vector<std::shared_ptr<Player> >::iterator it = players.begin(); it != itEnd; it++)
|
||||
{
|
||||
(*it)->awardStat( GenericStats::timePlayed(), GenericStats::param_time(timeDiff) );
|
||||
}
|
||||
@@ -4396,7 +4396,7 @@ void Level::setSpawnPos(Pos *spawnPos)
|
||||
}
|
||||
|
||||
|
||||
void Level::ensureAdded(shared_ptr<Entity> entity)
|
||||
void Level::ensureAdded(std::shared_ptr<Entity> entity)
|
||||
{
|
||||
int xc = Mth::floor(entity->x / 16);
|
||||
int zc = Mth::floor(entity->z / 16);
|
||||
@@ -4419,13 +4419,13 @@ void Level::ensureAdded(shared_ptr<Entity> entity)
|
||||
}
|
||||
|
||||
|
||||
bool Level::mayInteract(shared_ptr<Player> player, int xt, int yt, int zt, int content)
|
||||
bool Level::mayInteract(std::shared_ptr<Player> player, int xt, int yt, int zt, int content)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Level::broadcastEntityEvent(shared_ptr<Entity> e, uint8_t event)
|
||||
void Level::broadcastEntityEvent(std::shared_ptr<Entity> e, uint8_t event)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -4506,19 +4506,19 @@ bool Level::isHumidAt(int x, int y, int z)
|
||||
}
|
||||
|
||||
|
||||
void Level::setSavedData(const wstring& id, shared_ptr<SavedData> data)
|
||||
void Level::setSavedData(const std::wstring& id, std::shared_ptr<SavedData> data)
|
||||
{
|
||||
savedDataStorage->set(id, data);
|
||||
}
|
||||
|
||||
|
||||
shared_ptr<SavedData> Level::getSavedData(const type_info& clazz, const wstring& id)
|
||||
std::shared_ptr<SavedData> Level::getSavedData(const std::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);
|
||||
}
|
||||
@@ -4544,7 +4544,7 @@ void Level::levelEvent(int type, int x, int y, int z, int data)
|
||||
}
|
||||
|
||||
|
||||
void Level::levelEvent(shared_ptr<Player> source, int type, int x, int y, int z, int data)
|
||||
void Level::levelEvent(std::shared_ptr<Player> source, int type, int x, int y, int z, int data)
|
||||
{
|
||||
AUTO_VAR(itEnd, listeners.end());
|
||||
for (AUTO_VAR(it, listeners.begin()); it != itEnd; it++)
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
using namespace std;
|
||||
|
||||
#include "Storage/LevelSource.h"
|
||||
#include "../Util/LightLayer.h"
|
||||
#include "ChunkPos.h"
|
||||
@@ -92,22 +92,22 @@ public:
|
||||
public:
|
||||
CRITICAL_SECTION m_entitiesCS; // 4J added
|
||||
|
||||
vector<shared_ptr<Entity> > entities;
|
||||
std::vector<std::shared_ptr<Entity> > entities;
|
||||
|
||||
protected:
|
||||
vector<shared_ptr<Entity> > entitiesToRemove;
|
||||
std::vector<std::shared_ptr<Entity> > entitiesToRemove;
|
||||
public:
|
||||
bool hasEntitiesToRemove(); // 4J added
|
||||
bool m_bDisableAddNewTileEntities; // 4J Added
|
||||
CRITICAL_SECTION m_tileEntityListCS; // 4J added
|
||||
vector<shared_ptr<TileEntity> > tileEntityList;
|
||||
std::vector<std::shared_ptr<TileEntity> > tileEntityList;
|
||||
private:
|
||||
vector<shared_ptr<TileEntity> > pendingTileEntities;
|
||||
vector<shared_ptr<TileEntity> > tileEntitiesToUnload;
|
||||
std::vector<std::shared_ptr<TileEntity> > pendingTileEntities;
|
||||
std::vector<std::shared_ptr<TileEntity> > tileEntitiesToUnload;
|
||||
bool updatingTileEntities;
|
||||
public:
|
||||
vector<shared_ptr<Player> > players;
|
||||
vector<shared_ptr<Entity> > globalEntities;
|
||||
std::vector<std::shared_ptr<Player> > players;
|
||||
std::vector<std::shared_ptr<Entity> > globalEntities;
|
||||
|
||||
private:
|
||||
int cloudColor;
|
||||
@@ -135,21 +135,21 @@ public:
|
||||
Dimension *dimension;
|
||||
|
||||
protected:
|
||||
vector<LevelListener *> listeners;
|
||||
std::vector<LevelListener *> listeners;
|
||||
|
||||
public:
|
||||
ChunkSource *chunkSource; // 4J - changed to public
|
||||
protected:
|
||||
// This is the only shared_ptr ref to levelStorage - we need to keep this as long as at least one Level references it,
|
||||
// This is the only std::shared_ptr ref to levelStorage - we need to keep this as long as at least one Level references it,
|
||||
// to be able to cope with moving from dimension to dimension where the Level(Level *level, Dimension *dimension) ctor is used
|
||||
shared_ptr<LevelStorage> levelStorage;
|
||||
std::shared_ptr<LevelStorage> levelStorage;
|
||||
|
||||
LevelData *levelData;
|
||||
|
||||
public:
|
||||
bool isFindingSpawn;
|
||||
SavedDataStorage *savedDataStorage;
|
||||
shared_ptr<Villages> villages;
|
||||
std::shared_ptr<Villages> villages;
|
||||
VillageSiege *villageSiege;
|
||||
|
||||
public:
|
||||
@@ -160,13 +160,13 @@ private:
|
||||
|
||||
// 4J Stu - Added these ctors to handle init of member variables
|
||||
void _init();
|
||||
void _init(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(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(shared_ptr<LevelStorage>levelStorage, const wstring& levelName, LevelSettings *levelSettings);
|
||||
Level(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();
|
||||
|
||||
@@ -278,26 +278,26 @@ public:
|
||||
HitResult *clip(Vec3 *a, Vec3 *b, bool liquid);
|
||||
HitResult *clip(Vec3 *a, Vec3 *b, bool liquid, bool solidOnly);
|
||||
|
||||
virtual void playSound(shared_ptr<Entity> entity, int iSound, float volume, float pitch);
|
||||
virtual void playSound(std::shared_ptr<Entity> entity, int iSound, float volume, float pitch);
|
||||
virtual void playSound(double x, double y, double z, int iSound, float volume, float pitch, float fClipSoundDist=16.0f);
|
||||
|
||||
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(shared_ptr<Entity> e);
|
||||
virtual bool addEntity(shared_ptr<Entity> e);
|
||||
virtual bool addGlobalEntity(std::shared_ptr<Entity> e);
|
||||
virtual bool addEntity(std::shared_ptr<Entity> e);
|
||||
|
||||
protected:
|
||||
virtual void entityAdded(shared_ptr<Entity> e);
|
||||
virtual void entityRemoved(shared_ptr<Entity> e);
|
||||
virtual void playerRemoved(shared_ptr<Entity> e); // 4J added
|
||||
virtual void entityAdded(std::shared_ptr<Entity> e);
|
||||
virtual void entityRemoved(std::shared_ptr<Entity> e);
|
||||
virtual void playerRemoved(std::shared_ptr<Entity> e); // 4J added
|
||||
|
||||
public:
|
||||
virtual void removeEntity(shared_ptr<Entity> e);
|
||||
void removeEntityImmediately(shared_ptr<Entity> e);
|
||||
virtual void removeEntity(std::shared_ptr<Entity> e);
|
||||
void removeEntityImmediately(std::shared_ptr<Entity> e);
|
||||
void addListener(LevelListener *listener);
|
||||
void removeListener(LevelListener *listener);
|
||||
|
||||
@@ -305,11 +305,11 @@ private:
|
||||
AABBList boxes;
|
||||
|
||||
public:
|
||||
AABBList *getCubes(shared_ptr<Entity> source, AABB *box, bool noEntities=false, bool blockAtEdge=false); // 4J - added noEntities & blockAtEdge parameters
|
||||
AABBList *getCubes(std::shared_ptr<Entity> source, AABB *box, bool noEntities=false, bool blockAtEdge=false); // 4J - added noEntities & blockAtEdge parameters
|
||||
AABBList *getTileCubes(AABB *box, bool blockAtEdge); // 4J Stu - Brought forward from 12w36 to fix #46282 - TU5: Gameplay: Exiting the minecart in a tight corridor damages the player
|
||||
int getOldSkyDarken(float a); // 4J - change brought forward from 1.8.2
|
||||
float getSkyDarken(float a); // 4J - change brought forward from 1.8.2
|
||||
Vec3 *getSkyColor(shared_ptr<Entity> source, float a);
|
||||
Vec3 *getSkyColor(std::shared_ptr<Entity> source, float a);
|
||||
float getTimeOfDay(float a);
|
||||
int getMoonPhase(float a);
|
||||
float getSunAngle(float a);
|
||||
@@ -324,29 +324,29 @@ public:
|
||||
virtual void addToTickNextTick(int x, int y, int z, int tileId, int tickDelay);
|
||||
virtual void forceAddTileTick(int x, int y, int z, int tileId, int tickDelay);
|
||||
virtual void tickEntities();
|
||||
void addAllPendingTileEntities(vector< shared_ptr<TileEntity> >& entities);
|
||||
void tick(shared_ptr<Entity> e);
|
||||
virtual void tick(shared_ptr<Entity> e, bool actual);
|
||||
void addAllPendingTileEntities(std::vector< std::shared_ptr<TileEntity> >& entities);
|
||||
void tick(std::shared_ptr<Entity> e);
|
||||
virtual void tick(std::shared_ptr<Entity> e, bool actual);
|
||||
bool isUnobstructed(AABB *aabb);
|
||||
bool isUnobstructed(AABB *aabb, shared_ptr<Entity> ignore);
|
||||
bool isUnobstructed(AABB *aabb, std::shared_ptr<Entity> ignore);
|
||||
bool containsAnyBlocks(AABB *box);
|
||||
bool containsAnyLiquid(AABB *box);
|
||||
bool containsAnyLiquid_NoLoad(AABB *box); // 4J added
|
||||
bool containsFireTile(AABB *box);
|
||||
bool checkAndHandleWater(AABB *box, Material *material, shared_ptr<Entity> e);
|
||||
bool checkAndHandleWater(AABB *box, Material *material, std::shared_ptr<Entity> e);
|
||||
bool containsMaterial(AABB *box, Material *material);
|
||||
bool containsLiquid(AABB *box, Material *material);
|
||||
// 4J Stu - destroyBlocks param brought forward as part of fix for tnt cannons
|
||||
shared_ptr<Explosion> explode(shared_ptr<Entity> source, double x, double y, double z, float r, bool destroyBlocks);
|
||||
virtual shared_ptr<Explosion> explode(shared_ptr<Entity> source, double x, double y, double z, float r, bool fire, bool destroyBlocks);
|
||||
std::shared_ptr<Explosion> explode(std::shared_ptr<Entity> source, double x, double y, double z, float r, bool destroyBlocks);
|
||||
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(shared_ptr<Player> player, int x, int y, int z, int face);
|
||||
wstring gatherStats();
|
||||
wstring gatherChunkSourceStats();
|
||||
virtual shared_ptr<TileEntity> getTileEntity(int x, int y, int z);
|
||||
void setTileEntity(int x, int y, int z, shared_ptr<TileEntity> tileEntity);
|
||||
bool extinguishFire(std::shared_ptr<Player> player, int x, int y, int z, int face);
|
||||
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);
|
||||
void markForRemoval(shared_ptr<TileEntity> entity);
|
||||
void markForRemoval(std::shared_ptr<TileEntity> entity);
|
||||
virtual bool isSolidRenderTile(int x, int y, int z);
|
||||
virtual bool isSolidBlockingTile(int x, int y, int z);
|
||||
bool isSolidBlockingTileInLoadedChunk(int x, int y, int z, bool valueIfNotLoaded);
|
||||
@@ -380,7 +380,7 @@ protected:
|
||||
// AP - See CustomSet.h for an explanation of this
|
||||
CustomSet chunksToPoll;
|
||||
#else
|
||||
unordered_set<ChunkPos,ChunkPosKeyHash,ChunkPosKeyEq> chunksToPoll;
|
||||
std::unordered_set<ChunkPos,ChunkPosKeyHash,ChunkPosKeyEq> chunksToPoll;
|
||||
#endif
|
||||
|
||||
private:
|
||||
@@ -410,41 +410,41 @@ public:
|
||||
|
||||
public:
|
||||
virtual bool tickPendingTicks(bool force);
|
||||
virtual vector<TickNextTickData> *fetchTicksInChunk(LevelChunk *chunk, bool remove);
|
||||
virtual std::vector<TickNextTickData> *fetchTicksInChunk(LevelChunk *chunk, bool remove);
|
||||
|
||||
private:
|
||||
vector<shared_ptr<Entity> > es;
|
||||
std::vector<std::shared_ptr<Entity> > es;
|
||||
|
||||
public:
|
||||
bool isClientSide;
|
||||
|
||||
vector<shared_ptr<Entity> > *getEntities(shared_ptr<Entity> except, AABB *bb);
|
||||
vector<shared_ptr<Entity> > *getEntitiesOfClass(const type_info& baseClass, AABB *bb);
|
||||
shared_ptr<Entity> getClosestEntityOfClass(const type_info& baseClass, AABB *bb, shared_ptr<Entity> source);
|
||||
vector<shared_ptr<Entity> > getAllEntities();
|
||||
void tileEntityChanged(int x, int y, int z, shared_ptr<TileEntity> te);
|
||||
std::vector<std::shared_ptr<Entity> > *getEntities(std::shared_ptr<Entity> except, AABB *bb);
|
||||
std::vector<std::shared_ptr<Entity> > *getEntitiesOfClass(const std::type_info& baseClass, AABB *bb);
|
||||
std::shared_ptr<Entity> getClosestEntityOfClass(const std::type_info& baseClass, AABB *bb, std::shared_ptr<Entity> source);
|
||||
std::vector<std::shared_ptr<Entity> > getAllEntities();
|
||||
void tileEntityChanged(int x, int y, int z, std::shared_ptr<TileEntity> te);
|
||||
// unsigned int countInstanceOf(BaseObject::Class *clas);
|
||||
unsigned int countInstanceOf(eINSTANCEOF clas, bool singleType, unsigned int *protectedCount = NULL, unsigned int *couldWanderCount = NULL); // 4J added
|
||||
unsigned int countInstanceOfInRange(eINSTANCEOF clas, bool singleType, int range, int x, int y, int z); // 4J Added
|
||||
void addEntities(vector<shared_ptr<Entity> > *list);
|
||||
virtual void removeEntities(vector<shared_ptr<Entity> > *list);
|
||||
bool mayPlace(int tileId, int x, int y, int z, bool ignoreEntities, int face, shared_ptr<Entity> ignoreEntity);
|
||||
void addEntities(std::vector<std::shared_ptr<Entity> > *list);
|
||||
virtual void removeEntities(std::vector<std::shared_ptr<Entity> > *list);
|
||||
bool mayPlace(int tileId, int x, int y, int z, bool ignoreEntities, int face, std::shared_ptr<Entity> ignoreEntity);
|
||||
int getSeaLevel();
|
||||
Path *findPath(shared_ptr<Entity> from, shared_ptr<Entity> to, float maxDist, bool canPassDoors, bool canOpenDoors, bool avoidWater, bool canFloat);
|
||||
Path *findPath(shared_ptr<Entity> from, int xBest, int yBest, int zBest, float maxDist, bool canPassDoors, bool canOpenDoors, bool avoidWater, bool canFloat);
|
||||
Path *findPath(std::shared_ptr<Entity> from, std::shared_ptr<Entity> to, float maxDist, bool canPassDoors, bool canOpenDoors, bool avoidWater, bool canFloat);
|
||||
Path *findPath(std::shared_ptr<Entity> from, int xBest, int yBest, int zBest, float maxDist, bool canPassDoors, bool canOpenDoors, bool avoidWater, bool canFloat);
|
||||
bool getDirectSignal(int x, int y, int z, int dir);
|
||||
bool hasDirectSignal(int x, int y, int z);
|
||||
bool getSignal(int x, int y, int z, int dir);
|
||||
bool hasNeighborSignal(int x, int y, int z);
|
||||
// 4J Added maxYDist param
|
||||
shared_ptr<Player> getNearestPlayer(shared_ptr<Entity> source, double maxDist, double maxYDist = -1);
|
||||
shared_ptr<Player> getNearestPlayer(double x, double y, double z, double maxDist, double maxYDist = -1);
|
||||
shared_ptr<Player> getNearestPlayer(double x, double z, double maxDist);
|
||||
shared_ptr<Player> getNearestAttackablePlayer(shared_ptr<Entity> source, double maxDist);
|
||||
shared_ptr<Player> getNearestAttackablePlayer(double x, double y, double z, double maxDist);
|
||||
std::shared_ptr<Player> getNearestPlayer(std::shared_ptr<Entity> source, double maxDist, double maxYDist = -1);
|
||||
std::shared_ptr<Player> getNearestPlayer(double x, double y, double z, double maxDist, double maxYDist = -1);
|
||||
std::shared_ptr<Player> getNearestPlayer(double x, double z, double maxDist);
|
||||
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);
|
||||
|
||||
shared_ptr<Player> getPlayerByName(const wstring& name);
|
||||
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);
|
||||
@@ -456,9 +456,9 @@ public:
|
||||
Pos *getSharedSpawnPos();
|
||||
void setSpawnPos(int x, int y, int z);
|
||||
void setSpawnPos(Pos *spawnPos);
|
||||
void ensureAdded(shared_ptr<Entity> entity);
|
||||
virtual bool mayInteract(shared_ptr<Player> player, int xt, int yt, int zt, int content);
|
||||
virtual void broadcastEntityEvent(shared_ptr<Entity> e, uint8_t event);
|
||||
void ensureAdded(std::shared_ptr<Entity> entity);
|
||||
virtual bool mayInteract(std::shared_ptr<Player> player, int xt, int yt, int zt, int content);
|
||||
virtual void broadcastEntityEvent(std::shared_ptr<Entity> e, uint8_t event);
|
||||
ChunkSource *getChunkSource();
|
||||
virtual void tileEvent(int x, int y, int z, int tile, int b0, int b1);
|
||||
LevelStorage *getLevelStorage();
|
||||
@@ -476,11 +476,11 @@ public:
|
||||
bool isRaining();
|
||||
bool isRainingAt(int x, int y, int z);
|
||||
bool isHumidAt(int x, int y, int z);
|
||||
void setSavedData(const wstring& id, shared_ptr<SavedData> data);
|
||||
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 std::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(shared_ptr<Player> source, 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();
|
||||
int getHeight();
|
||||
Random *getRandomFor(int x, int z, int blend);
|
||||
@@ -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);
|
||||
|
||||
@@ -58,7 +58,7 @@ void LevelChunk::init(Level *level, int x, int z)
|
||||
#else
|
||||
EnterCriticalSection(&m_csEntities);
|
||||
#endif
|
||||
entityBlocks = new vector<shared_ptr<Entity> > *[ENTITY_BLOCKS_LENGTH];
|
||||
entityBlocks = new std::vector<std::shared_ptr<Entity> > *[ENTITY_BLOCKS_LENGTH];
|
||||
#ifdef _ENTITIES_RW_SECTION
|
||||
LeaveCriticalRWSection(&m_csEntities, true);
|
||||
#else
|
||||
@@ -90,7 +90,7 @@ void LevelChunk::init(Level *level, int x, int z)
|
||||
#endif
|
||||
for (int i = 0; i < ENTITY_BLOCKS_LENGTH; i++)
|
||||
{
|
||||
entityBlocks[i] = new vector<shared_ptr<Entity> >();
|
||||
entityBlocks[i] = new std::vector<std::shared_ptr<Entity> >();
|
||||
}
|
||||
#ifdef _ENTITIES_RW_SECTION
|
||||
LeaveCriticalRWSection(&m_csEntities, true);
|
||||
@@ -1016,7 +1016,7 @@ bool LevelChunk::setTileAndData(int x, int y, int z, int _tile, int _data)
|
||||
// if (_tile > 0 && dynamic_cast<EntityTile *>(Tile::tiles[_tile]) != NULL)
|
||||
if (_tile > 0 && Tile::tiles[_tile] != NULL && Tile::tiles[_tile]->isEntityTile())
|
||||
{
|
||||
shared_ptr<TileEntity> te = getTileEntity(x, y, z);
|
||||
std::shared_ptr<TileEntity> te = getTileEntity(x, y, z);
|
||||
if (te == NULL)
|
||||
{
|
||||
te = ((EntityTile *) Tile::tiles[_tile])->newTileEntity(level);
|
||||
@@ -1034,7 +1034,7 @@ bool LevelChunk::setTileAndData(int x, int y, int z, int _tile, int _data)
|
||||
// else if (old > 0 && dynamic_cast<EntityTile *>(Tile::tiles[old]) != NULL)
|
||||
else if (old > 0 && Tile::tiles[_tile] != NULL && Tile::tiles[_tile]->isEntityTile())
|
||||
{
|
||||
shared_ptr<TileEntity> te = getTileEntity(x, y, z);
|
||||
std::shared_ptr<TileEntity> te = getTileEntity(x, y, z);
|
||||
if (te != NULL)
|
||||
{
|
||||
te->clearCache();
|
||||
@@ -1074,7 +1074,7 @@ bool LevelChunk::setData(int x, int y, int z, int val, int mask, bool *maskedBit
|
||||
int _tile = getTile(x, y, z);
|
||||
if (_tile > 0 && dynamic_cast<EntityTile *>( Tile::tiles[_tile] ) != NULL)
|
||||
{
|
||||
shared_ptr<TileEntity> te = getTileEntity(x, y, z);
|
||||
std::shared_ptr<TileEntity> te = getTileEntity(x, y, z);
|
||||
if (te != NULL)
|
||||
{
|
||||
te->clearCache();
|
||||
@@ -1166,7 +1166,7 @@ int LevelChunk::getRawBrightness(int x, int y, int z, int skyDampen)
|
||||
return light;
|
||||
}
|
||||
|
||||
void LevelChunk::addEntity(shared_ptr<Entity> e)
|
||||
void LevelChunk::addEntity(std::shared_ptr<Entity> e)
|
||||
{
|
||||
lastSaveHadEntities = true;
|
||||
|
||||
@@ -1200,12 +1200,12 @@ void LevelChunk::addEntity(shared_ptr<Entity> e)
|
||||
}
|
||||
|
||||
|
||||
void LevelChunk::removeEntity(shared_ptr<Entity> e)
|
||||
void LevelChunk::removeEntity(std::shared_ptr<Entity> e)
|
||||
{
|
||||
removeEntity(e, e->yChunk);
|
||||
}
|
||||
|
||||
void LevelChunk::removeEntity(shared_ptr<Entity> e, int yc)
|
||||
void LevelChunk::removeEntity(std::shared_ptr<Entity> e, int yc)
|
||||
{
|
||||
if (yc < 0) yc = 0;
|
||||
if (yc >= ENTITY_BLOCKS_LENGTH) yc = ENTITY_BLOCKS_LENGTH - 1;
|
||||
@@ -1261,14 +1261,14 @@ void LevelChunk::skyBrightnessChanged()
|
||||
level->setTilesDirty(x0, y0, z0, x1, y1, z1);
|
||||
}
|
||||
|
||||
shared_ptr<TileEntity> LevelChunk::getTileEntity(int x, int y, int z)
|
||||
std::shared_ptr<TileEntity> LevelChunk::getTileEntity(int x, int y, int z)
|
||||
{
|
||||
TilePos pos(x, y, z);
|
||||
|
||||
// 4J Stu - Changed as we should not be using the [] accessor (causes an insert when we don't want one)
|
||||
//shared_ptr<TileEntity> tileEntity = tileEntities[pos];
|
||||
//std::shared_ptr<TileEntity> tileEntity = tileEntities[pos];
|
||||
EnterCriticalSection(&m_csTileEntities);
|
||||
shared_ptr<TileEntity> tileEntity = nullptr;
|
||||
std::shared_ptr<TileEntity> tileEntity = nullptr;
|
||||
AUTO_VAR(it, tileEntities.find(pos));
|
||||
|
||||
if (it == tileEntities.end())
|
||||
@@ -1320,7 +1320,7 @@ shared_ptr<TileEntity> LevelChunk::getTileEntity(int x, int y, int z)
|
||||
return tileEntity;
|
||||
}
|
||||
|
||||
void LevelChunk::addTileEntity(shared_ptr<TileEntity> te)
|
||||
void LevelChunk::addTileEntity(std::shared_ptr<TileEntity> te)
|
||||
{
|
||||
int xx = (int)(te->x - this->x * 16);
|
||||
int yy = (int)te->y;
|
||||
@@ -1334,7 +1334,7 @@ void LevelChunk::addTileEntity(shared_ptr<TileEntity> te)
|
||||
}
|
||||
}
|
||||
|
||||
void LevelChunk::setTileEntity(int x, int y, int z, shared_ptr<TileEntity> tileEntity)
|
||||
void LevelChunk::setTileEntity(int x, int y, int z, std::shared_ptr<TileEntity> tileEntity)
|
||||
{
|
||||
TilePos pos(x, y, z);
|
||||
|
||||
@@ -1371,7 +1371,7 @@ void LevelChunk::removeTileEntity(int x, int y, int z)
|
||||
AUTO_VAR(it, tileEntities.find(pos));
|
||||
if( it != tileEntities.end() )
|
||||
{
|
||||
shared_ptr<TileEntity> te = tileEntities[pos];
|
||||
std::shared_ptr<TileEntity> te = tileEntities[pos];
|
||||
tileEntities.erase(pos);
|
||||
if( te != NULL )
|
||||
{
|
||||
@@ -1401,7 +1401,7 @@ void LevelChunk::load()
|
||||
for (int i = 0; i < entityTags->size(); i++)
|
||||
{
|
||||
CompoundTag *teTag = entityTags->get(i);
|
||||
shared_ptr<Entity> te = EntityIO::loadStatic(teTag, level);
|
||||
std::shared_ptr<Entity> te = EntityIO::loadStatic(teTag, level);
|
||||
if (te != NULL)
|
||||
{
|
||||
addEntity(te);
|
||||
@@ -1415,7 +1415,7 @@ void LevelChunk::load()
|
||||
for (int i = 0; i < tileEntityTags->size(); i++)
|
||||
{
|
||||
CompoundTag *teTag = tileEntityTags->get(i);
|
||||
shared_ptr<TileEntity> te = TileEntity::loadStatic(teTag);
|
||||
std::shared_ptr<TileEntity> te = TileEntity::loadStatic(teTag);
|
||||
if (te != NULL)
|
||||
{
|
||||
addTileEntity(te);
|
||||
@@ -1428,7 +1428,7 @@ void LevelChunk::load()
|
||||
}
|
||||
#endif
|
||||
|
||||
vector< shared_ptr<TileEntity> > values;
|
||||
std::vector< std::shared_ptr<TileEntity> > values;
|
||||
EnterCriticalSection(&m_csTileEntities);
|
||||
for( AUTO_VAR(it, tileEntities.begin()); it != tileEntities.end(); it++ )
|
||||
{
|
||||
@@ -1506,9 +1506,9 @@ void LevelChunk::unload(bool unloadTileEntities) // 4J - added parameter
|
||||
for (int i = 0; i < ENTITY_BLOCKS_LENGTH; i++)
|
||||
{
|
||||
AUTO_VAR(itEnd, entityBlocks[i]->end());
|
||||
for( vector<shared_ptr<Entity> >::iterator it = entityBlocks[i]->begin(); it != itEnd; it++ )
|
||||
for( std::vector<std::shared_ptr<Entity> >::iterator it = entityBlocks[i]->begin(); it != itEnd; it++ )
|
||||
{
|
||||
shared_ptr<Entity> e = *it;
|
||||
std::shared_ptr<Entity> e = *it;
|
||||
CompoundTag *teTag = new CompoundTag();
|
||||
if (e->save(teTag))
|
||||
{
|
||||
@@ -1529,10 +1529,10 @@ void LevelChunk::unload(bool unloadTileEntities) // 4J - added parameter
|
||||
ListTag<CompoundTag> *tileEntityTags = new ListTag<CompoundTag>();
|
||||
|
||||
AUTO_VAR(itEnd,tileEntities.end());
|
||||
for( unordered_map<TilePos, shared_ptr<TileEntity>, TilePosKeyHash, TilePosKeyEq>::iterator it = tileEntities.begin();
|
||||
for( std::unordered_map<TilePos, std::shared_ptr<TileEntity>, TilePosKeyHash, TilePosKeyEq>::iterator it = tileEntities.begin();
|
||||
it != itEnd; it++)
|
||||
{
|
||||
shared_ptr<TileEntity> te = it->second;
|
||||
std::shared_ptr<TileEntity> te = it->second;
|
||||
CompoundTag *teTag = new CompoundTag();
|
||||
te->save(teTag);
|
||||
tileEntityTags->add(teTag);
|
||||
@@ -1560,7 +1560,7 @@ void LevelChunk::markUnsaved()
|
||||
}
|
||||
|
||||
|
||||
void LevelChunk::getEntities(shared_ptr<Entity> except, AABB *bb, vector<shared_ptr<Entity> > &es)
|
||||
void LevelChunk::getEntities(std::shared_ptr<Entity> except, AABB *bb, std::vector<std::shared_ptr<Entity> > &es)
|
||||
{
|
||||
int yc0 = Mth::floor((bb->y0 - 2) / 16);
|
||||
int yc1 = Mth::floor((bb->y1 + 2) / 16);
|
||||
@@ -1573,16 +1573,16 @@ void LevelChunk::getEntities(shared_ptr<Entity> except, AABB *bb, vector<shared_
|
||||
#endif
|
||||
for (int yc = yc0; yc <= yc1; yc++)
|
||||
{
|
||||
vector<shared_ptr<Entity> > *entities = entityBlocks[yc];
|
||||
std::vector<std::shared_ptr<Entity> > *entities = entityBlocks[yc];
|
||||
|
||||
AUTO_VAR(itEnd, entities->end());
|
||||
for (AUTO_VAR(it, entities->begin()); it != itEnd; it++)
|
||||
{
|
||||
shared_ptr<Entity> e = *it; //entities->at(i);
|
||||
std::shared_ptr<Entity> e = *it; //entities->at(i);
|
||||
if (e != except && e->bb->intersects(bb))
|
||||
{
|
||||
es.push_back(e);
|
||||
vector<shared_ptr<Entity> > *subs = e->getSubEntities();
|
||||
std::vector<std::shared_ptr<Entity> > *subs = e->getSubEntities();
|
||||
if (subs != NULL)
|
||||
{
|
||||
for (int j = 0; j < subs->size(); j++)
|
||||
@@ -1602,7 +1602,7 @@ void LevelChunk::getEntities(shared_ptr<Entity> except, AABB *bb, vector<shared_
|
||||
#endif
|
||||
}
|
||||
|
||||
void LevelChunk::getEntitiesOfClass(const type_info& ec, AABB *bb, vector<shared_ptr<Entity> > &es)
|
||||
void LevelChunk::getEntitiesOfClass(const std::type_info& ec, AABB *bb, std::vector<std::shared_ptr<Entity> > &es)
|
||||
{
|
||||
int yc0 = Mth::floor((bb->y0 - 2) / 16);
|
||||
int yc1 = Mth::floor((bb->y1 + 2) / 16);
|
||||
@@ -1630,19 +1630,19 @@ void LevelChunk::getEntitiesOfClass(const type_info& ec, AABB *bb, vector<shared
|
||||
#endif
|
||||
for (int yc = yc0; yc <= yc1; yc++)
|
||||
{
|
||||
vector<shared_ptr<Entity> > *entities = entityBlocks[yc];
|
||||
std::vector<std::shared_ptr<Entity> > *entities = entityBlocks[yc];
|
||||
|
||||
AUTO_VAR(itEnd, entities->end());
|
||||
for (AUTO_VAR(it, entities->begin()); it != itEnd; it++)
|
||||
{
|
||||
shared_ptr<Entity> e = *it; //entities->at(i);
|
||||
std::shared_ptr<Entity> e = *it; //entities->at(i);
|
||||
|
||||
bool isAssignableFrom = false;
|
||||
// Some special cases where the base class is a general type that our class may be derived from, otherwise do a direct comparison of type_info
|
||||
if( ec == typeid(Player) ) { if( dynamic_pointer_cast<Player>(e) != NULL ) isAssignableFrom = true; }
|
||||
else if ( ec == typeid(Mob) ) { if( dynamic_pointer_cast<Mob>(e) != NULL ) isAssignableFrom = true; }
|
||||
else if ( ec == typeid(Monster) ) { if( dynamic_pointer_cast<Monster>(e) != NULL ) isAssignableFrom = true; }
|
||||
else if ( ec == typeid(Zombie) ) { if( dynamic_pointer_cast<Zombie>(e) != NULL ) isAssignableFrom = true; }
|
||||
// Some special cases where the base class is a general type that our class may be derived from, otherwise do a direct comparison of std::type_info
|
||||
if( ec == typeid(Player) ) { if( std::dynamic_pointer_cast<Player>(e) != NULL ) isAssignableFrom = true; }
|
||||
else if ( ec == typeid(Mob) ) { if( std::dynamic_pointer_cast<Mob>(e) != NULL ) isAssignableFrom = true; }
|
||||
else if ( ec == typeid(Monster) ) { if( std::dynamic_pointer_cast<Monster>(e) != NULL ) isAssignableFrom = true; }
|
||||
else if ( ec == typeid(Zombie) ) { if( std::dynamic_pointer_cast<Zombie>(e) != NULL ) isAssignableFrom = true; }
|
||||
else if(e != NULL && ec == typeid(*(e.get())) ) isAssignableFrom = true;
|
||||
if (isAssignableFrom && e->bb->intersects(bb)) es.push_back(e);
|
||||
// 4J - note needs to be equivalent to baseClass.isAssignableFrom(e.getClass())
|
||||
@@ -1696,21 +1696,21 @@ int LevelChunk::getBlocksAndData(byteArray *data, int x0, int y0, int z0, int x1
|
||||
int compressedHeight = Level::COMPRESSED_CHUNK_SECTION_HEIGHT;
|
||||
|
||||
// 4J - replaced block storage as now using CompressedTileStorage
|
||||
if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerBlocks->getDataRegion( *data, x0, y0, z0, x1, min(compressedHeight, y1), z1, p );
|
||||
if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperBlocks->getDataRegion( *data, x0, max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p );
|
||||
if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerBlocks->getDataRegion( *data, x0, y0, z0, x1, std::min(compressedHeight, y1), z1, p );
|
||||
if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperBlocks->getDataRegion( *data, x0, std::max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p );
|
||||
|
||||
// 4J - replaced data storage as now using SparseDataStorage
|
||||
if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerData->getDataRegion( *data, x0, y0, z0, x1, min(compressedHeight, y1), z1, p );
|
||||
if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperData->getDataRegion( *data, x0, max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p );
|
||||
if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerData->getDataRegion( *data, x0, y0, z0, x1, std::min(compressedHeight, y1), z1, p );
|
||||
if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperData->getDataRegion( *data, x0, std::max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p );
|
||||
|
||||
if( includeLighting )
|
||||
{
|
||||
// 4J - replaced block and skylight storage as these now use our SparseLightStorage
|
||||
if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerBlockLight->getDataRegion( *data, x0, y0, z0, x1, min(compressedHeight, y1), z1, p );
|
||||
if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperBlockLight->getDataRegion( *data, x0, max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p );
|
||||
if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerBlockLight->getDataRegion( *data, x0, y0, z0, x1, std::min(compressedHeight, y1), z1, p );
|
||||
if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperBlockLight->getDataRegion( *data, x0, std::max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p );
|
||||
|
||||
if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerSkyLight->getDataRegion( *data, x0, y0, z0, x1, min(compressedHeight, y1), z1, p );
|
||||
if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperSkyLight->getDataRegion( *data, x0, max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p );
|
||||
if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerSkyLight->getDataRegion( *data, x0, y0, z0, x1, std::min(compressedHeight, y1), z1, p );
|
||||
if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperSkyLight->getDataRegion( *data, x0, std::max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1744,8 +1744,8 @@ bool LevelChunk::testSetBlocksAndData(byteArray data, int x0, int y0, int z0, in
|
||||
// 4J Stu - Added this because some "min" functions don't let us use our constants :(
|
||||
int compressedHeight = Level::COMPRESSED_CHUNK_SECTION_HEIGHT;
|
||||
|
||||
if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) changed = lowerBlocks->testSetDataRegion(data, x0, y0, z0, x1, min(compressedHeight, y1), z1, p);
|
||||
if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) changed = changed || upperBlocks->testSetDataRegion(data, x0, max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p);
|
||||
if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) changed = lowerBlocks->testSetDataRegion(data, x0, y0, z0, x1, std::min(compressedHeight, y1), z1, p);
|
||||
if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) changed = changed || upperBlocks->testSetDataRegion(data, x0, std::max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p);
|
||||
|
||||
return changed;
|
||||
}
|
||||
@@ -1788,8 +1788,8 @@ int LevelChunk::setBlocksAndData(byteArray data, int x0, int y0, int z0, int x1,
|
||||
int compressedHeight = Level::COMPRESSED_CHUNK_SECTION_HEIGHT;
|
||||
|
||||
// 4J - replaced block storage as now uses CompressedTileStorage
|
||||
if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerBlocks->setDataRegion( data, x0, y0, z0, x1, min(compressedHeight, y1), z1, p, includeLighting ? NULL : tileUpdatedCallback, this, 0 );
|
||||
if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperBlocks->setDataRegion( data, x0, max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p, includeLighting ? NULL : tileUpdatedCallback, this, Level::COMPRESSED_CHUNK_SECTION_HEIGHT );
|
||||
if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerBlocks->setDataRegion( data, x0, y0, z0, x1, std::min(compressedHeight, y1), z1, p, includeLighting ? NULL : tileUpdatedCallback, this, 0 );
|
||||
if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperBlocks->setDataRegion( data, x0, std::max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p, includeLighting ? NULL : tileUpdatedCallback, this, Level::COMPRESSED_CHUNK_SECTION_HEIGHT );
|
||||
/*
|
||||
for (int x = x0; x < x1; x++)
|
||||
for (int z = z0; z < z1; z++)
|
||||
@@ -1803,17 +1803,17 @@ int LevelChunk::setBlocksAndData(byteArray data, int x0, int y0, int z0, int x1,
|
||||
recalcHeightmapOnly();
|
||||
|
||||
// 4J - replaced data storage as now uses SparseDataStorage
|
||||
if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerData->setDataRegion( data, x0, y0, z0, x1, min(compressedHeight, y1), z1, p, includeLighting ? NULL : tileUpdatedCallback, this, 0 );
|
||||
if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperData->setDataRegion( data, x0, max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p, includeLighting ? NULL : tileUpdatedCallback, this, Level::COMPRESSED_CHUNK_SECTION_HEIGHT );
|
||||
if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerData->setDataRegion( data, x0, y0, z0, x1, std::min(compressedHeight, y1), z1, p, includeLighting ? NULL : tileUpdatedCallback, this, 0 );
|
||||
if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperData->setDataRegion( data, x0, std::max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p, includeLighting ? NULL : tileUpdatedCallback, this, Level::COMPRESSED_CHUNK_SECTION_HEIGHT );
|
||||
|
||||
if( includeLighting )
|
||||
{
|
||||
// 4J - replaced block and skylight storage as these now use our SparseLightStorage
|
||||
if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerBlockLight->setDataRegion( data, x0, y0, z0, x1, min(compressedHeight, y1), z1, p );
|
||||
if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperBlockLight->setDataRegion( data, x0, max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p );
|
||||
if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerBlockLight->setDataRegion( data, x0, y0, z0, x1, std::min(compressedHeight, y1), z1, p );
|
||||
if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperBlockLight->setDataRegion( data, x0, std::max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p );
|
||||
|
||||
if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerSkyLight->setDataRegion( data, x0, y0, z0, x1, min(compressedHeight, y1), z1, p );
|
||||
if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperSkyLight->setDataRegion( data, x0, max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p );
|
||||
if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerSkyLight->setDataRegion( data, x0, y0, z0, x1, std::min(compressedHeight, y1), z1, p );
|
||||
if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperSkyLight->setDataRegion( data, x0, std::max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p );
|
||||
|
||||
memcpy(biomes.data, &data.data[p],biomes.length);
|
||||
p += biomes.length;
|
||||
@@ -2324,7 +2324,7 @@ byteArray LevelChunk::getReorderedBlocksAndData(int x0, int y0, int z0, int xs,
|
||||
{
|
||||
int highestNonEmpty = getHighestNonEmptyY();
|
||||
|
||||
ys = min(highestNonEmpty - y0, ys);
|
||||
ys = std::min(highestNonEmpty - y0, ys);
|
||||
if(ys < 0 ) ys = 0;
|
||||
|
||||
int x1 = x0 + xs;
|
||||
@@ -2354,15 +2354,15 @@ byteArray LevelChunk::getReorderedBlocksAndData(int x0, int y0, int z0, int xs,
|
||||
int compressedHeight = Level::COMPRESSED_CHUNK_SECTION_HEIGHT;
|
||||
|
||||
// 4J - replaced data storage as now using SparseDataStorage
|
||||
if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerData->getDataRegion( data, x0, y0, z0, x1, min(compressedHeight, y1), z1, p );
|
||||
if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperData->getDataRegion( data, x0, max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p );
|
||||
if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerData->getDataRegion( data, x0, y0, z0, x1, std::min(compressedHeight, y1), z1, p );
|
||||
if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperData->getDataRegion( data, x0, std::max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p );
|
||||
|
||||
// 4J - replaced block and skylight storage as these now use our SparseLightStorage
|
||||
if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerBlockLight->getDataRegion( data, x0, y0, z0, x1, min(compressedHeight, y1), z1, p );
|
||||
if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperBlockLight->getDataRegion( data, x0, max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p );
|
||||
if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerBlockLight->getDataRegion( data, x0, y0, z0, x1, std::min(compressedHeight, y1), z1, p );
|
||||
if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperBlockLight->getDataRegion( data, x0, std::max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p );
|
||||
|
||||
if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerSkyLight->getDataRegion( data, x0, y0, z0, x1, min(compressedHeight, y1), z1, p );
|
||||
if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperSkyLight->getDataRegion( data, x0, max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p );
|
||||
if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerSkyLight->getDataRegion( data, x0, y0, z0, x1, std::min(compressedHeight, y1), z1, p );
|
||||
if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperSkyLight->getDataRegion( data, x0, std::max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p );
|
||||
|
||||
memcpy(&data.data[p],biomes.data,biomes.length);
|
||||
|
||||
@@ -2402,7 +2402,7 @@ void LevelChunk::reorderBlocksAndDataToXZY(int y0, int xs, int ys, int zs, byteA
|
||||
unsigned int halfTileCount = tileCount/2;
|
||||
|
||||
int sectionHeight = Level::COMPRESSED_CHUNK_SECTION_HEIGHT;
|
||||
int lowerYSpan = min(y1, sectionHeight) - y0;
|
||||
int lowerYSpan = std::min(y1, sectionHeight) - y0;
|
||||
int upperYSpan = ys - lowerYSpan;
|
||||
int upperSlotOffset = xs * zs * lowerYSpan;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
using namespace std;
|
||||
|
||||
|
||||
class DataLayer;
|
||||
class TileEntity;
|
||||
@@ -100,8 +100,8 @@ private:
|
||||
bool hasGapsToCheck;
|
||||
public:
|
||||
|
||||
unordered_map<TilePos, shared_ptr<TileEntity>, TilePosKeyHash, TilePosKeyEq> tileEntities;
|
||||
vector<shared_ptr<Entity> > **entityBlocks;
|
||||
std::unordered_map<TilePos, std::shared_ptr<TileEntity>, TilePosKeyHash, TilePosKeyEq> tileEntities;
|
||||
std::vector<std::shared_ptr<Entity> > **entityBlocks;
|
||||
|
||||
static const int sTerrainPopulatedFromHere = 2;
|
||||
static const int sTerrainPopulatedFromW = 4;
|
||||
@@ -188,14 +188,14 @@ public:
|
||||
virtual void getNeighbourBrightnesses(int *brightnesses, LightLayer::variety layer, int x, int y, int z); // 4J added
|
||||
virtual void setBrightness(LightLayer::variety layer, int x, int y, int z, int brightness);
|
||||
virtual int getRawBrightness(int x, int y, int z, int skyDampen);
|
||||
virtual void addEntity(shared_ptr<Entity> e);
|
||||
virtual void removeEntity(shared_ptr<Entity> e);
|
||||
virtual void removeEntity(shared_ptr<Entity> e, int yc);
|
||||
virtual void addEntity(std::shared_ptr<Entity> e);
|
||||
virtual void removeEntity(std::shared_ptr<Entity> e);
|
||||
virtual void removeEntity(std::shared_ptr<Entity> e, int yc);
|
||||
virtual bool isSkyLit(int x, int y, int z);
|
||||
virtual void skyBrightnessChanged();
|
||||
virtual shared_ptr<TileEntity> getTileEntity(int x, int y, int z);
|
||||
virtual void addTileEntity(shared_ptr<TileEntity> te);
|
||||
virtual void setTileEntity(int x, int y, int z, shared_ptr<TileEntity> tileEntity);
|
||||
virtual std::shared_ptr<TileEntity> getTileEntity(int x, int y, int z);
|
||||
virtual void addTileEntity(std::shared_ptr<TileEntity> te);
|
||||
virtual void setTileEntity(int x, int y, int z, std::shared_ptr<TileEntity> tileEntity);
|
||||
virtual void removeTileEntity(int x, int y, int z);
|
||||
virtual void load();
|
||||
virtual void unload(bool unloadTileEntities) ; // 4J - added parameter
|
||||
@@ -203,8 +203,8 @@ public:
|
||||
virtual bool isUnloaded();
|
||||
#endif
|
||||
virtual void markUnsaved();
|
||||
virtual void getEntities(shared_ptr<Entity> except, AABB *bb, vector<shared_ptr<Entity> > &es);
|
||||
virtual void getEntitiesOfClass(const type_info& ec, AABB *bb, vector<shared_ptr<Entity> > &es);
|
||||
virtual void getEntities(std::shared_ptr<Entity> except, AABB *bb, std::vector<std::shared_ptr<Entity> > &es);
|
||||
virtual void getEntitiesOfClass(const std::type_info& ec, AABB *bb, std::vector<std::shared_ptr<Entity> > &es);
|
||||
virtual int countEntities();
|
||||
virtual bool shouldSave(bool force);
|
||||
virtual int getBlocksAndData(byteArray *data, int x0, int y0, int z0, int x1, int y1, int z1, int p, bool includeLighting = true); // 4J - added includeLighting parameter
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
using namespace std;
|
||||
|
||||
|
||||
#include "../Util/Exceptions.h"
|
||||
|
||||
@@ -9,5 +9,5 @@ private:
|
||||
static const __int32 serialVersionUID = 1L;
|
||||
|
||||
public:
|
||||
LevelConflictException(const wstring& msg);
|
||||
LevelConflictException(const std::wstring& msg);
|
||||
};
|
||||
@@ -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)
|
||||
{
|
||||
@@ -112,11 +112,11 @@ LevelData::LevelData(CompoundTag *tag)
|
||||
m_xzSize = tag->getInt(L"XZSize");
|
||||
m_hellScale = tag->getInt(L"HellScale");
|
||||
|
||||
m_xzSize = min(m_xzSize,LEVEL_MAX_WIDTH);
|
||||
m_xzSize = max(m_xzSize,LEVEL_MIN_WIDTH);
|
||||
m_xzSize = std::min(m_xzSize,LEVEL_MAX_WIDTH);
|
||||
m_xzSize = std::max(m_xzSize,LEVEL_MIN_WIDTH);
|
||||
|
||||
m_hellScale = min(m_hellScale,HELL_LEVEL_MAX_SCALE);
|
||||
m_hellScale = max(m_hellScale,HELL_LEVEL_MIN_SCALE);
|
||||
m_hellScale = std::min(m_hellScale,HELL_LEVEL_MAX_SCALE);
|
||||
m_hellScale = std::max(m_hellScale,HELL_LEVEL_MIN_SCALE);
|
||||
|
||||
int hellXZSize = m_xzSize / m_hellScale;
|
||||
while(hellXZSize > HELL_LEVEL_MAX_WIDTH && m_hellScale < HELL_LEVEL_MAX_SCALE)
|
||||
@@ -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();
|
||||
@@ -180,11 +180,11 @@ LevelData::LevelData(LevelSettings *levelSettings, const wstring& levelName)
|
||||
m_xzSize = levelSettings->getXZSize();
|
||||
m_hellScale = levelSettings->getHellScale();
|
||||
|
||||
m_xzSize = min(m_xzSize,LEVEL_MAX_WIDTH);
|
||||
m_xzSize = max(m_xzSize,LEVEL_MIN_WIDTH);
|
||||
m_xzSize = std::min(m_xzSize,LEVEL_MAX_WIDTH);
|
||||
m_xzSize = std::max(m_xzSize,LEVEL_MIN_WIDTH);
|
||||
|
||||
m_hellScale = min(m_hellScale,HELL_LEVEL_MAX_SCALE);
|
||||
m_hellScale = max(m_hellScale,HELL_LEVEL_MIN_SCALE);
|
||||
m_hellScale = std::min(m_hellScale,HELL_LEVEL_MAX_SCALE);
|
||||
m_hellScale = std::max(m_hellScale,HELL_LEVEL_MIN_SCALE);
|
||||
|
||||
int hellXZSize = m_xzSize / m_hellScale;
|
||||
while(hellXZSize > HELL_LEVEL_MAX_WIDTH && m_hellScale < HELL_LEVEL_MAX_SCALE)
|
||||
@@ -243,7 +243,7 @@ CompoundTag *LevelData::createTag()
|
||||
return tag;
|
||||
}
|
||||
|
||||
CompoundTag *LevelData::createTag(vector<shared_ptr<Player> > *players)
|
||||
CompoundTag *LevelData::createTag(std::vector<std::shared_ptr<Player> > *players)
|
||||
{
|
||||
// 4J - removed all code for storing tags for players
|
||||
return createTag();
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
using namespace std;
|
||||
|
||||
|
||||
class Player;
|
||||
class CompoundTag;
|
||||
@@ -21,7 +21,7 @@ private:
|
||||
__int64 sizeOnDisk;
|
||||
// CompoundTag *loadedPlayerTag; // 4J removed
|
||||
int dimension;
|
||||
wstring levelName;
|
||||
std::wstring levelName;
|
||||
int version;
|
||||
|
||||
bool raining;
|
||||
@@ -55,10 +55,10 @@ 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<shared_ptr<Player> > *players);
|
||||
CompoundTag *createTag(std::vector<std::shared_ptr<Player> > *players);
|
||||
|
||||
enum
|
||||
{
|
||||
@@ -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();
|
||||
|
||||
@@ -755,12 +755,12 @@ bool RandomLevelSource::shouldSave()
|
||||
return true;
|
||||
}
|
||||
|
||||
wstring RandomLevelSource::gatherStats()
|
||||
std::wstring RandomLevelSource::gatherStats()
|
||||
{
|
||||
return L"RandomLevelSource";
|
||||
}
|
||||
|
||||
vector<Biome::MobSpawnerData *> *RandomLevelSource::getMobsAt(MobCategory *mobCategory, int x, int y, int z)
|
||||
std::vector<Biome::MobSpawnerData *> *RandomLevelSource::getMobsAt(MobCategory *mobCategory, int x, int y, int z)
|
||||
{
|
||||
Biome *biome = level->getBiome(x, z);
|
||||
if (biome == NULL)
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
using namespace std;
|
||||
|
||||
|
||||
#include "ChunkSource.h"
|
||||
|
||||
@@ -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 std::vector<Biome::MobSpawnerData *> *getMobsAt(MobCategory *mobCategory, 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 ) )
|
||||
{
|
||||
@@ -351,7 +351,7 @@ LevelData *DirectoryLevelStorage::prepareLevel()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void DirectoryLevelStorage::saveLevelData(LevelData *levelData, vector<shared_ptr<Player> > *players)
|
||||
void DirectoryLevelStorage::saveLevelData(LevelData *levelData, std::vector<std::shared_ptr<Player> > *players)
|
||||
{
|
||||
// 4J Jev, removed try/catch
|
||||
|
||||
@@ -360,7 +360,7 @@ void DirectoryLevelStorage::saveLevelData(LevelData *levelData, vector<shared_pt
|
||||
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);
|
||||
@@ -385,7 +385,7 @@ void DirectoryLevelStorage::saveLevelData(LevelData *levelData)
|
||||
delete root;
|
||||
}
|
||||
|
||||
void DirectoryLevelStorage::save(shared_ptr<Player> player)
|
||||
void DirectoryLevelStorage::save(std::shared_ptr<Player> player)
|
||||
{
|
||||
// 4J Jev, removed try/catch.
|
||||
PlayerUID playerXuid = player->getXuid();
|
||||
@@ -433,7 +433,7 @@ void DirectoryLevelStorage::save(shared_ptr<Player> player)
|
||||
}
|
||||
|
||||
// 4J Changed return val to bool to check if new player or loaded player
|
||||
bool DirectoryLevelStorage::load(shared_ptr<Player> player)
|
||||
bool DirectoryLevelStorage::load(std::shared_ptr<Player> player)
|
||||
{
|
||||
bool newPlayer = true;
|
||||
CompoundTag *tag = loadPlayerDataTag( player->getXuid() );
|
||||
@@ -480,9 +480,9 @@ void DirectoryLevelStorage::clearOldPlayerFiles()
|
||||
if(StorageManager.GetSaveDisabled() ) return;
|
||||
|
||||
#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__)
|
||||
vector<FileEntry *> *playerFiles = m_saveFile->getValidPlayerDatFiles();
|
||||
std::vector<FileEntry *> *playerFiles = m_saveFile->getValidPlayerDatFiles();
|
||||
#else
|
||||
vector<FileEntry *> *playerFiles = m_saveFile->getFilesWithPrefix( playerDir.getName() );
|
||||
std::vector<FileEntry *> *playerFiles = m_saveFile->getFilesWithPrefix( playerDir.getName() );
|
||||
#endif
|
||||
|
||||
if( playerFiles != NULL )
|
||||
@@ -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;
|
||||
}
|
||||
@@ -569,9 +569,9 @@ void DirectoryLevelStorage::resetNetherPlayerPositions()
|
||||
if(app.GetResetNether())
|
||||
{
|
||||
#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__)
|
||||
vector<FileEntry *> *playerFiles = m_saveFile->getValidPlayerDatFiles();
|
||||
std::vector<FileEntry *> *playerFiles = m_saveFile->getValidPlayerDatFiles();
|
||||
#else
|
||||
vector<FileEntry *> *playerFiles = m_saveFile->getFilesWithPrefix( playerDir.getName() );
|
||||
std::vector<FileEntry *> *playerFiles = m_saveFile->getFilesWithPrefix( playerDir.getName() );
|
||||
#endif
|
||||
|
||||
if( playerFiles != NULL )
|
||||
@@ -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) )
|
||||
@@ -746,7 +746,7 @@ void DirectoryLevelStorage::dontSaveMapMappingForPlayer(PlayerUID xuid)
|
||||
#endif
|
||||
}
|
||||
|
||||
void DirectoryLevelStorage::deleteMapFilesForPlayer(shared_ptr<Player> player)
|
||||
void DirectoryLevelStorage::deleteMapFilesForPlayer(std::shared_ptr<Player> player)
|
||||
{
|
||||
PlayerUID playerXuid = player->getXuid();
|
||||
if(playerXuid != INVALID_XUID) deleteMapFilesForPlayer(playerXuid);
|
||||
@@ -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) )
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
using namespace std;
|
||||
|
||||
|
||||
#ifdef _LARGE_WORLDS
|
||||
// 51 maps per player (7x7 overworld, 1 nether, 1 end) * 100 players rounded up to power of 2
|
||||
@@ -66,16 +66,16 @@ 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
|
||||
{
|
||||
friend class DirectoryLevelStorage;
|
||||
private:
|
||||
unordered_map<__int64, short> m_mappings;
|
||||
std::unordered_map<__int64, short> m_mappings;
|
||||
|
||||
public:
|
||||
void addMapping(int id, int centreX, int centreZ, int dimension, int scale);
|
||||
@@ -84,9 +84,9 @@ private:
|
||||
void readMappings(DataInputStream *dis);
|
||||
};
|
||||
#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__) || defined(_DURANGO)
|
||||
unordered_map<PlayerUID, PlayerMappings, PlayerUID::Hash> m_playerMappings;
|
||||
std::unordered_map<PlayerUID, PlayerMappings, PlayerUID::Hash> m_playerMappings;
|
||||
#else
|
||||
unordered_map<PlayerUID, PlayerMappings> m_playerMappings;
|
||||
std::unordered_map<PlayerUID, PlayerMappings> m_playerMappings;
|
||||
#endif
|
||||
byteArray m_usedMappings;
|
||||
#else
|
||||
@@ -95,8 +95,8 @@ private:
|
||||
#endif
|
||||
bool m_bHasLoadedMapDataMappings;
|
||||
|
||||
unordered_map<wstring, ByteArrayOutputStream *> m_cachedSaveData;
|
||||
vector<short> m_mapFilesToDelete; // Temp list of files that couldn't be deleted immediately due to saving being disabled
|
||||
std::unordered_map<std::wstring, ByteArrayOutputStream *> m_cachedSaveData;
|
||||
std::vector<short> m_mapFilesToDelete; // Temp list of files that couldn't be deleted immediately due to saving being disabled
|
||||
|
||||
protected:
|
||||
ConsoleSaveFile *m_saveFile;
|
||||
@@ -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:
|
||||
@@ -119,24 +119,24 @@ public:
|
||||
void checkSession();
|
||||
virtual ChunkStorage *createChunkStorage(Dimension *dimension);
|
||||
LevelData *prepareLevel();
|
||||
virtual void saveLevelData(LevelData *levelData, vector<shared_ptr<Player> > *players);
|
||||
virtual void saveLevelData(LevelData *levelData, std::vector<std::shared_ptr<Player> > *players);
|
||||
virtual void saveLevelData(LevelData *levelData);
|
||||
virtual void save(shared_ptr<Player> player);
|
||||
virtual bool load(shared_ptr<Player> player); // 4J Changed return val to bool to check if new player or loaded player
|
||||
virtual void save(std::shared_ptr<Player> player);
|
||||
virtual bool load(std::shared_ptr<Player> player); // 4J Changed return val to bool to check if new player or loaded player
|
||||
virtual CompoundTag *loadPlayerDataTag(PlayerUID xuid);
|
||||
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);
|
||||
virtual void saveMapIdLookup();
|
||||
virtual void deleteMapFilesForPlayer(shared_ptr<Player> player);
|
||||
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,19 +17,19 @@ DirectoryLevelStorageSource::DirectoryLevelStorageSource(const File dir) : baseD
|
||||
//this->baseDir = dir;
|
||||
}
|
||||
|
||||
wstring DirectoryLevelStorageSource::getName()
|
||||
std::wstring DirectoryLevelStorageSource::getName()
|
||||
{
|
||||
return L"Old Format";
|
||||
}
|
||||
|
||||
vector<LevelSummary *> *DirectoryLevelStorageSource::getLevelList()
|
||||
std::vector<LevelSummary *> *DirectoryLevelStorageSource::getLevelList()
|
||||
{
|
||||
// 4J Stu - We don't use directory list with the Xbox save locations
|
||||
vector<LevelSummary *> *levels = new vector<LevelSummary *>;
|
||||
std::vector<LevelSummary *> *levels = new std::vector<LevelSummary *>;
|
||||
#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;
|
||||
@@ -104,7 +104,7 @@ void DirectoryLevelStorageSource::deleteLevel(const wstring& levelId)
|
||||
dir._delete();
|
||||
}
|
||||
|
||||
void DirectoryLevelStorageSource::deleteRecursive(vector<File *> *files)
|
||||
void DirectoryLevelStorageSource::deleteRecursive(std::vector<File *> *files)
|
||||
{
|
||||
AUTO_VAR(itEnd, files->end());
|
||||
for (AUTO_VAR(it, files->begin()); it != itEnd; it++)
|
||||
@@ -118,22 +118,22 @@ void DirectoryLevelStorageSource::deleteRecursive(vector<File *> *files)
|
||||
}
|
||||
}
|
||||
|
||||
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 shared_ptr<LevelStorage> (new DirectoryLevelStorage(saveFile, baseDir, levelId, 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;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
using namespace std;
|
||||
|
||||
|
||||
#include "LevelStorageSource.h"
|
||||
#include "../../IO/Files/File.h"
|
||||
@@ -15,20 +15,20 @@ protected:
|
||||
|
||||
public:
|
||||
DirectoryLevelStorageSource(const File dir);
|
||||
virtual wstring getName();
|
||||
virtual vector<LevelSummary *> *getLevelList();
|
||||
virtual std::wstring getName();
|
||||
virtual std::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);
|
||||
static void deleteRecursive(std::vector<File *> *files);
|
||||
|
||||
public:
|
||||
virtual 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);
|
||||
};
|
||||
@@ -14,29 +14,29 @@
|
||||
#include "../../Headers/com.mojang.nbt.h"
|
||||
#include "EntityIO.h"
|
||||
|
||||
unordered_map<wstring, entityCreateFn> *EntityIO::idCreateMap = new unordered_map<wstring, entityCreateFn>;
|
||||
unordered_map<eINSTANCEOF, wstring, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq> *EntityIO::classIdMap = new unordered_map<eINSTANCEOF, wstring, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq>;
|
||||
unordered_map<int, entityCreateFn> *EntityIO::numCreateMap = new unordered_map<int, entityCreateFn>;
|
||||
unordered_map<int, eINSTANCEOF> *EntityIO::numClassMap = new unordered_map<int, eINSTANCEOF>;
|
||||
unordered_map<eINSTANCEOF, int, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq> *EntityIO::classNumMap = new unordered_map<eINSTANCEOF, int, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq>;
|
||||
unordered_map<wstring, int> *EntityIO::idNumMap = new unordered_map<wstring, int>;
|
||||
unordered_map<int, EntityIO::SpawnableMobInfo *> EntityIO::idsSpawnableInCreative;
|
||||
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<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( unordered_map<wstring, entityCreateFn>::value_type(id, createFn) );
|
||||
classIdMap->insert( unordered_map<eINSTANCEOF, wstring, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq>::value_type(clas,id ) );
|
||||
numCreateMap->insert( unordered_map<int, entityCreateFn>::value_type(idNum, createFn) );
|
||||
numClassMap->insert( unordered_map<int, eINSTANCEOF>::value_type(idNum, clas) );
|
||||
classNumMap->insert( unordered_map<eINSTANCEOF, int, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq>::value_type(clas, idNum) );
|
||||
idNumMap->insert( unordered_map<wstring, int>::value_type(id, idNum) );
|
||||
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<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);
|
||||
|
||||
idsSpawnableInCreative.insert( unordered_map<int, SpawnableMobInfo *>::value_type( idNum, new SpawnableMobInfo(idNum, color1, color2, nameId) ) );
|
||||
idsSpawnableInCreative.insert( std::unordered_map<int, SpawnableMobInfo *>::value_type( idNum, new SpawnableMobInfo(idNum, color1, color2, nameId) ) );
|
||||
}
|
||||
|
||||
void EntityIO::staticCtor()
|
||||
@@ -98,29 +98,29 @@ void EntityIO::staticCtor()
|
||||
setId(DragonFireball::create, eTYPE_DRAGON_FIREBALL, L"DragonFireball", 1000);
|
||||
}
|
||||
|
||||
shared_ptr<Entity> EntityIO::newEntity(const wstring& id, Level *level)
|
||||
std::shared_ptr<Entity> EntityIO::newEntity(const std::wstring& id, Level *level)
|
||||
{
|
||||
shared_ptr<Entity> entity;
|
||||
std::shared_ptr<Entity> entity;
|
||||
|
||||
AUTO_VAR(it, idCreateMap->find(id));
|
||||
if(it != idCreateMap->end() )
|
||||
{
|
||||
entityCreateFn create = it->second;
|
||||
if (create != NULL) entity = shared_ptr<Entity>(create(level));
|
||||
if (create != NULL) entity = std::shared_ptr<Entity>(create(level));
|
||||
}
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
shared_ptr<Entity> EntityIO::loadStatic(CompoundTag *tag, Level *level)
|
||||
std::shared_ptr<Entity> EntityIO::loadStatic(CompoundTag *tag, Level *level)
|
||||
{
|
||||
shared_ptr<Entity> entity;
|
||||
std::shared_ptr<Entity> entity;
|
||||
|
||||
AUTO_VAR(it, idCreateMap->find(tag->getString(L"id")));
|
||||
if(it != idCreateMap->end() )
|
||||
{
|
||||
entityCreateFn create = it->second;
|
||||
if (create != NULL) entity = shared_ptr<Entity>(create(level));
|
||||
if (create != NULL) entity = std::shared_ptr<Entity>(create(level));
|
||||
}
|
||||
|
||||
if (entity != NULL)
|
||||
@@ -136,15 +136,15 @@ shared_ptr<Entity> EntityIO::loadStatic(CompoundTag *tag, Level *level)
|
||||
return entity;
|
||||
}
|
||||
|
||||
shared_ptr<Entity> EntityIO::newById(int id, Level *level)
|
||||
std::shared_ptr<Entity> EntityIO::newById(int id, Level *level)
|
||||
{
|
||||
shared_ptr<Entity> entity;
|
||||
std::shared_ptr<Entity> entity;
|
||||
|
||||
AUTO_VAR(it, numCreateMap->find(id));
|
||||
if(it != numCreateMap->end() )
|
||||
{
|
||||
entityCreateFn create = it->second;
|
||||
if (create != NULL) entity = shared_ptr<Entity>(create(level));
|
||||
if (create != NULL) entity = std::shared_ptr<Entity>(create(level));
|
||||
}
|
||||
|
||||
if (entity != NULL)
|
||||
@@ -157,40 +157,40 @@ shared_ptr<Entity> EntityIO::newById(int id, Level *level)
|
||||
return entity;
|
||||
}
|
||||
|
||||
shared_ptr<Entity> EntityIO::newByEnumType(eINSTANCEOF eType, Level *level)
|
||||
std::shared_ptr<Entity> EntityIO::newByEnumType(eINSTANCEOF eType, Level *level)
|
||||
{
|
||||
shared_ptr<Entity> entity;
|
||||
std::shared_ptr<Entity> entity;
|
||||
|
||||
unordered_map<eINSTANCEOF, int, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq>::iterator it = classNumMap->find( eType );
|
||||
std::unordered_map<eINSTANCEOF, int, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq>::iterator it = classNumMap->find( eType );
|
||||
if( it != classNumMap->end() )
|
||||
{
|
||||
AUTO_VAR(it2, numCreateMap->find(it->second));
|
||||
if(it2 != numCreateMap->end() )
|
||||
{
|
||||
entityCreateFn create = it2->second;
|
||||
if (create != NULL) entity = shared_ptr<Entity>(create(level));
|
||||
if (create != NULL) entity = std::shared_ptr<Entity>(create(level));
|
||||
}
|
||||
}
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
int EntityIO::getId(shared_ptr<Entity> entity)
|
||||
int EntityIO::getId(std::shared_ptr<Entity> entity)
|
||||
{
|
||||
unordered_map<eINSTANCEOF, int, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq>::iterator it = classNumMap->find( entity->GetType() );
|
||||
std::unordered_map<eINSTANCEOF, int, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq>::iterator it = classNumMap->find( entity->GetType() );
|
||||
return (*it).second;
|
||||
}
|
||||
|
||||
wstring EntityIO::getEncodeId(shared_ptr<Entity> entity)
|
||||
std::wstring EntityIO::getEncodeId(std::shared_ptr<Entity> entity)
|
||||
{
|
||||
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() )
|
||||
{
|
||||
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() )
|
||||
@@ -257,7 +257,7 @@ eINSTANCEOF EntityIO::getClass(int id)
|
||||
|
||||
int EntityIO::eTypeToIoid(eINSTANCEOF eType)
|
||||
{
|
||||
unordered_map<eINSTANCEOF, int, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq>::iterator it = classNumMap->find( eType );
|
||||
std::unordered_map<eINSTANCEOF, int, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq>::iterator it = classNumMap->find( eType );
|
||||
if( it != classNumMap->end() )
|
||||
return it->second;
|
||||
return -1;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
using namespace std;
|
||||
|
||||
|
||||
#include "../../Entities/Entity.h"
|
||||
#include "../../Util/JavaIntHash.h"
|
||||
@@ -28,32 +28,32 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
static unordered_map<wstring, entityCreateFn> *idCreateMap;
|
||||
static unordered_map<eINSTANCEOF, wstring, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq> *classIdMap;
|
||||
static unordered_map<int, entityCreateFn> *numCreateMap;
|
||||
static unordered_map<int, eINSTANCEOF> *numClassMap;
|
||||
static unordered_map<eINSTANCEOF, int, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq> *classNumMap;
|
||||
static unordered_map<wstring, int> *idNumMap;
|
||||
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<std::wstring, int> *idNumMap;
|
||||
|
||||
public:
|
||||
static unordered_map<int, SpawnableMobInfo *> idsSpawnableInCreative;
|
||||
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 shared_ptr<Entity> newEntity(const wstring& id, Level *level);
|
||||
static shared_ptr<Entity> loadStatic(CompoundTag *tag, Level *level);
|
||||
static shared_ptr<Entity> newById(int id, Level *level);
|
||||
static shared_ptr<Entity> newByEnumType(eINSTANCEOF eType, Level *level);
|
||||
static int getId(shared_ptr<Entity> entity);
|
||||
static wstring getEncodeId(shared_ptr<Entity> entity);
|
||||
static int getId(const wstring &encodeId);
|
||||
static wstring getEncodeId(int entityIoValue);
|
||||
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 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
|
||||
|
||||
@@ -10,7 +10,7 @@ class LevelSource
|
||||
{
|
||||
public:
|
||||
virtual int getTile(int x, int y, int z) = 0;
|
||||
virtual shared_ptr<TileEntity> getTileEntity(int x, int y, int z) = 0;
|
||||
virtual std::shared_ptr<TileEntity> getTileEntity(int x, int y, int z) = 0;
|
||||
virtual int getLightColor(int x, int y, int z, int emitt, int tileId = -1) = 0; // 4J - brought forward from 1.8.2, added tileId
|
||||
virtual float getBrightness(int x, int y, int z, int emitt) = 0;
|
||||
virtual float getBrightness(int x, int y, int z) = 0;
|
||||
|
||||
@@ -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/";
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
using namespace std;
|
||||
|
||||
|
||||
#include "../../IO/Files/ConsoleSavePath.h"
|
||||
|
||||
@@ -15,18 +15,18 @@ 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;
|
||||
virtual ChunkStorage *createChunkStorage(Dimension *dimension) = 0;
|
||||
virtual void saveLevelData(LevelData *levelData, vector<shared_ptr<Player> > *players) = 0;
|
||||
virtual void saveLevelData(LevelData *levelData, std::vector<std::shared_ptr<Player> > *players) = 0;
|
||||
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; }
|
||||
|
||||
@@ -26,7 +26,7 @@ ChunkStorage *LevelStorageProfilerDecorator::createChunkStorage(Dimension *dimen
|
||||
return new ChunkStorageProfilerDecorator(capsulated->createChunkStorage(dimension));
|
||||
}
|
||||
|
||||
void LevelStorageProfilerDecorator::saveLevelData(LevelData *levelData, vector<shared_ptr<Player> > *players)
|
||||
void LevelStorageProfilerDecorator::saveLevelData(LevelData *levelData, std::vector<std::shared_ptr<Player> > *players)
|
||||
{
|
||||
capsulated->saveLevelData(levelData, players);
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
using namespace std;
|
||||
|
||||
|
||||
#include "LevelStorage.h"
|
||||
|
||||
@@ -18,10 +18,10 @@ public:
|
||||
LevelData *prepareLevel();
|
||||
void checkSession();
|
||||
ChunkStorage *createChunkStorage(Dimension *dimension);
|
||||
void saveLevelData(LevelData *levelData, vector<shared_ptr<Player> > *players);
|
||||
void saveLevelData(LevelData *levelData, std::vector<std::shared_ptr<Player> > *players);
|
||||
void saveLevelData(LevelData *levelData);
|
||||
PlayerIO *getPlayerIO();
|
||||
void closeAll();
|
||||
ConsoleSavePath getDataFile(const wstring& id);
|
||||
wstring getLevelId();
|
||||
ConsoleSavePath getDataFile(const std::wstring& id);
|
||||
std::wstring getLevelId();
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
using namespace std;
|
||||
|
||||
|
||||
#include "../../Build/stdafx.h"
|
||||
|
||||
@@ -12,11 +12,11 @@ class ConsoleSaveFile;
|
||||
class LevelStorageSource
|
||||
{
|
||||
public:
|
||||
virtual wstring getName() = 0;
|
||||
virtual shared_ptr<LevelStorage> selectLevel(ConsoleSaveFile *saveFile, const wstring& levelId, bool createPlayerDir) = 0;
|
||||
virtual vector<LevelSummary *> *getLevelList() = 0;
|
||||
virtual std::wstring getName() = 0;
|
||||
virtual std::shared_ptr<LevelStorage> selectLevel(ConsoleSaveFile *saveFile, const std::wstring& levelId, bool createPlayerDir) = 0;
|
||||
virtual std::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;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#pragma once
|
||||
using namespace std;
|
||||
|
||||
|
||||
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();
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
using namespace std;
|
||||
|
||||
#include "../../Headers/net.minecraft.world.level.h"
|
||||
|
||||
class LevelType
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
@@ -23,7 +23,7 @@ MapItemSavedData::MapDecoration::MapDecoration(char img, char x, char y, char ro
|
||||
this->visible = visible;
|
||||
}
|
||||
|
||||
MapItemSavedData::HoldingPlayer::HoldingPlayer(shared_ptr<Player> player, const MapItemSavedData *parent) : parent( parent ), player( player )
|
||||
MapItemSavedData::HoldingPlayer::HoldingPlayer(std::shared_ptr<Player> player, const MapItemSavedData *parent) : parent( parent ), player( player )
|
||||
{
|
||||
// inited outside of ctor
|
||||
rowsDirtyMin = intArray(MapItem::IMAGE_WIDTH);
|
||||
@@ -48,7 +48,7 @@ MapItemSavedData::HoldingPlayer::~HoldingPlayer()
|
||||
delete lastSentDecorations.data;
|
||||
}
|
||||
|
||||
charArray MapItemSavedData::HoldingPlayer::nextUpdatePacket(shared_ptr<ItemInstance> itemInstance)
|
||||
charArray MapItemSavedData::HoldingPlayer::nextUpdatePacket(std::shared_ptr<ItemInstance> itemInstance)
|
||||
{
|
||||
if (--sendPosTick < 0)
|
||||
{
|
||||
@@ -125,7 +125,7 @@ charArray MapItemSavedData::HoldingPlayer::nextUpdatePacket(shared_ptr<ItemInsta
|
||||
}
|
||||
delete data.data;
|
||||
}
|
||||
shared_ptr<ServerPlayer> servPlayer = dynamic_pointer_cast<ServerPlayer>(player);
|
||||
std::shared_ptr<ServerPlayer> servPlayer = std::dynamic_pointer_cast<ServerPlayer>(player);
|
||||
for (int d = 0; d < 10; d++)
|
||||
{
|
||||
int column = (tick * 11) % (MapItem::IMAGE_WIDTH);
|
||||
@@ -153,7 +153,7 @@ charArray MapItemSavedData::HoldingPlayer::nextUpdatePacket(shared_ptr<ItemInsta
|
||||
}
|
||||
|
||||
|
||||
MapItemSavedData::MapItemSavedData(const wstring& id) : SavedData( id )
|
||||
MapItemSavedData::MapItemSavedData(const std::wstring& id) : SavedData( id )
|
||||
{
|
||||
x = z = 0;
|
||||
dimension = 0;
|
||||
@@ -223,11 +223,11 @@ void MapItemSavedData::save(CompoundTag *tag)
|
||||
tag->putByteArray(L"colors", colors);
|
||||
}
|
||||
|
||||
void MapItemSavedData::tickCarriedBy(shared_ptr<Player> player, shared_ptr<ItemInstance> item)
|
||||
void MapItemSavedData::tickCarriedBy(std::shared_ptr<Player> player, std::shared_ptr<ItemInstance> item)
|
||||
{
|
||||
if (carriedByPlayers.find(player) == carriedByPlayers.end())
|
||||
{
|
||||
shared_ptr<HoldingPlayer> hp = shared_ptr<HoldingPlayer>( new HoldingPlayer(player, this ) );
|
||||
std::shared_ptr<HoldingPlayer> hp = std::shared_ptr<HoldingPlayer>( new HoldingPlayer(player, this ) );
|
||||
carriedByPlayers.insert( playerHoldingPlayerMapType::value_type(player, hp) );
|
||||
carriedBy.push_back(hp);
|
||||
}
|
||||
@@ -245,12 +245,12 @@ void MapItemSavedData::tickCarriedBy(shared_ptr<Player> player, shared_ptr<ItemI
|
||||
bool addedPlayers = false;
|
||||
for (AUTO_VAR(it, carriedBy.begin()); it != carriedBy.end(); )
|
||||
{
|
||||
shared_ptr<HoldingPlayer> hp = *it;
|
||||
std::shared_ptr<HoldingPlayer> hp = *it;
|
||||
|
||||
// 4J Stu - Players in the same dimension as an item frame with a map need to be sent this data, so don't remove them
|
||||
if (hp->player->removed ) //|| (!hp->player->inventory->contains(item) && !item->isFramed() ))
|
||||
{
|
||||
AUTO_VAR(it2, carriedByPlayers.find( (shared_ptr<Player> ) hp->player ));
|
||||
AUTO_VAR(it2, carriedByPlayers.find( (std::shared_ptr<Player> ) hp->player ));
|
||||
if( it2 != carriedByPlayers.end() )
|
||||
{
|
||||
carriedByPlayers.erase( it2 );
|
||||
@@ -268,7 +268,7 @@ void MapItemSavedData::tickCarriedBy(shared_ptr<Player> player, shared_ptr<ItemI
|
||||
PlayerList *players = MinecraftServer::getInstance()->getPlayerList();
|
||||
for(AUTO_VAR(it3, players->players.begin()); it3 != players->players.end(); ++it3)
|
||||
{
|
||||
shared_ptr<ServerPlayer> serverPlayer = *it3;
|
||||
std::shared_ptr<ServerPlayer> serverPlayer = *it3;
|
||||
if(serverPlayer->dimension == 1)
|
||||
{
|
||||
atLeastOnePlayerInTheEnd = true;
|
||||
@@ -309,7 +309,7 @@ void MapItemSavedData::tickCarriedBy(shared_ptr<Player> player, shared_ptr<ItemI
|
||||
}
|
||||
#endif
|
||||
//decorations.push_back(new MapDecoration(4, x, y, 0));
|
||||
nonPlayerDecorations.insert( unordered_map<int, MapDecoration *>::value_type( END_PORTAL_DECORATION_KEY, new MapDecoration(4, x, y, 0, END_PORTAL_DECORATION_KEY, true) ) );
|
||||
nonPlayerDecorations.insert( std::unordered_map<int, MapDecoration *>::value_type( END_PORTAL_DECORATION_KEY, new MapDecoration(4, x, y, 0, END_PORTAL_DECORATION_KEY, true) ) );
|
||||
}
|
||||
else if ( currentPortalDecoration != nonPlayerDecorations.end() && !atLeastOnePlayerInTheEnd )
|
||||
{
|
||||
@@ -346,7 +346,7 @@ void MapItemSavedData::tickCarriedBy(shared_ptr<Player> player, shared_ptr<ItemI
|
||||
}
|
||||
#endif
|
||||
//decorations.push_back(new MapDecoration(7, x, y, 0));
|
||||
nonPlayerDecorations.insert( unordered_map<int, MapDecoration *>::value_type( item->getFrame()->entityId, new MapDecoration(12, x, y, rot, item->getFrame()->entityId, true) ) );
|
||||
nonPlayerDecorations.insert( std::unordered_map<int, MapDecoration *>::value_type( item->getFrame()->entityId, new MapDecoration(12, x, y, rot, item->getFrame()->entityId, true) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,7 +354,7 @@ void MapItemSavedData::tickCarriedBy(shared_ptr<Player> player, shared_ptr<ItemI
|
||||
#if 0
|
||||
for(AUTO_VAR(it,playerLevel->entities.begin()); it != playerLevel->entities.end(); ++it)
|
||||
{
|
||||
shared_ptr<Entity> ent = *it;
|
||||
std::shared_ptr<Entity> ent = *it;
|
||||
|
||||
if((ent->GetType() & eTYPE_ENEMY) == 0) continue;
|
||||
|
||||
@@ -380,7 +380,7 @@ void MapItemSavedData::tickCarriedBy(shared_ptr<Player> player, shared_ptr<ItemI
|
||||
}
|
||||
#endif
|
||||
//decorations.push_back(new MapDecoration(7, x, y, 0));
|
||||
nonPlayerDecorations.insert( unordered_map<int, MapDecoration *>::value_type( ent->entityId, new MapDecoration(4, x, y, rot, ent->entityId, true) ) );
|
||||
nonPlayerDecorations.insert( std::unordered_map<int, MapDecoration *>::value_type( ent->entityId, new MapDecoration(4, x, y, rot, ent->entityId, true) ) );
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -393,7 +393,7 @@ void MapItemSavedData::tickCarriedBy(shared_ptr<Player> player, shared_ptr<ItemI
|
||||
PlayerList *players = MinecraftServer::getInstance()->getPlayerList();
|
||||
for(AUTO_VAR(it3, players->players.begin()); it3 != players->players.end(); ++it3)
|
||||
{
|
||||
shared_ptr<ServerPlayer> decorationPlayer = *it3;
|
||||
std::shared_ptr<ServerPlayer> decorationPlayer = *it3;
|
||||
if(decorationPlayer!=NULL && decorationPlayer->dimension == this->dimension)
|
||||
{
|
||||
float xd = (float) (decorationPlayer->x - x) / (1 << scale);
|
||||
@@ -470,12 +470,12 @@ void MapItemSavedData::tickCarriedBy(shared_ptr<Player> player, shared_ptr<ItemI
|
||||
}
|
||||
}
|
||||
|
||||
charArray MapItemSavedData::getUpdatePacket(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player)
|
||||
charArray MapItemSavedData::getUpdatePacket(std::shared_ptr<ItemInstance> itemInstance, Level *level, std::shared_ptr<Player> player)
|
||||
{
|
||||
AUTO_VAR(it, carriedByPlayers.find(player));
|
||||
if (it == carriedByPlayers.end() ) return charArray();
|
||||
|
||||
shared_ptr<HoldingPlayer> hp = it->second;
|
||||
std::shared_ptr<HoldingPlayer> hp = it->second;
|
||||
return hp->nextUpdatePacket(itemInstance);
|
||||
}
|
||||
|
||||
@@ -486,7 +486,7 @@ void MapItemSavedData::setDirty(int x, int y0, int y1)
|
||||
AUTO_VAR(itEnd, carriedBy.end());
|
||||
for (AUTO_VAR(it, carriedBy.begin()); it != itEnd; it++)
|
||||
{
|
||||
shared_ptr<HoldingPlayer> hp = *it; //carriedBy.at(i);
|
||||
std::shared_ptr<HoldingPlayer> hp = *it; //carriedBy.at(i);
|
||||
if (hp->rowsDirtyMin[x] < 0 || hp->rowsDirtyMin[x] > y0) hp->rowsDirtyMin[x] = y0;
|
||||
if (hp->rowsDirtyMax[x] < 0 || hp->rowsDirtyMax[x] < y1) hp->rowsDirtyMax[x] = y1;
|
||||
}
|
||||
@@ -534,7 +534,7 @@ void MapItemSavedData::handleComplexItemData(charArray &data)
|
||||
// 4J Added
|
||||
// We only have one map per player per dimension, so if they pickup someone elses map we merge their map data with ours
|
||||
// so that we can see everything that they discovered but still only have one map data ourself
|
||||
void MapItemSavedData::mergeInMapData(shared_ptr<MapItemSavedData> dataToAdd)
|
||||
void MapItemSavedData::mergeInMapData(std::shared_ptr<MapItemSavedData> dataToAdd)
|
||||
{
|
||||
int w = MapItem::IMAGE_WIDTH;
|
||||
int h = MapItem::IMAGE_HEIGHT;
|
||||
@@ -562,7 +562,7 @@ void MapItemSavedData::mergeInMapData(shared_ptr<MapItemSavedData> dataToAdd)
|
||||
}
|
||||
}
|
||||
|
||||
void MapItemSavedData::removeItemFrameDecoration(shared_ptr<ItemInstance> item)
|
||||
void MapItemSavedData::removeItemFrameDecoration(std::shared_ptr<ItemInstance> item)
|
||||
{
|
||||
AUTO_VAR(frameDecoration, nonPlayerDecorations.find( item->getFrame()->entityId ) );
|
||||
if ( frameDecoration != nonPlayerDecorations.end() )
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
class HoldingPlayer
|
||||
{
|
||||
public:
|
||||
const shared_ptr<Player> player;
|
||||
const std::shared_ptr<Player> player;
|
||||
intArray rowsDirtyMin;
|
||||
intArray rowsDirtyMax;
|
||||
|
||||
@@ -42,9 +42,9 @@ public:
|
||||
|
||||
public:
|
||||
// 4J Stu - Had to add a reference to the MapItemSavedData object that created us as we try to access it's member variables
|
||||
HoldingPlayer(shared_ptr<Player> player, const MapItemSavedData *parent);
|
||||
HoldingPlayer(std::shared_ptr<Player> player, const MapItemSavedData *parent);
|
||||
~HoldingPlayer();
|
||||
charArray nextUpdatePacket(shared_ptr<ItemInstance> itemInstance);
|
||||
charArray nextUpdatePacket(std::shared_ptr<ItemInstance> itemInstance);
|
||||
};
|
||||
|
||||
public:
|
||||
@@ -53,37 +53,37 @@ public:
|
||||
uint8_t scale;
|
||||
byteArray colors;
|
||||
int step;
|
||||
vector<shared_ptr<HoldingPlayer> > carriedBy;
|
||||
std::vector<std::shared_ptr<HoldingPlayer> > carriedBy;
|
||||
|
||||
private:
|
||||
typedef unordered_map<shared_ptr<Player> , shared_ptr<HoldingPlayer> , PlayerKeyHash, PlayerKeyEq> playerHoldingPlayerMapType;
|
||||
typedef std::unordered_map<std::shared_ptr<Player> , std::shared_ptr<HoldingPlayer> , PlayerKeyHash, PlayerKeyEq> playerHoldingPlayerMapType;
|
||||
playerHoldingPlayerMapType carriedByPlayers;
|
||||
|
||||
public:
|
||||
vector<MapDecoration *> decorations;
|
||||
std::vector<MapDecoration *> decorations;
|
||||
|
||||
private:
|
||||
// 4J Stu added
|
||||
unordered_map<int, MapDecoration *> nonPlayerDecorations;
|
||||
std::unordered_map<int, MapDecoration *> nonPlayerDecorations;
|
||||
static const int END_PORTAL_DECORATION_KEY;
|
||||
|
||||
|
||||
public:
|
||||
MapItemSavedData(const wstring& id);
|
||||
MapItemSavedData(const std::wstring& id);
|
||||
~MapItemSavedData();
|
||||
|
||||
virtual void load(CompoundTag *tag);
|
||||
virtual void save(CompoundTag *tag);
|
||||
|
||||
void tickCarriedBy(shared_ptr<Player> player, shared_ptr<ItemInstance> item);
|
||||
void tickCarriedBy(std::shared_ptr<Player> player, std::shared_ptr<ItemInstance> item);
|
||||
|
||||
charArray getUpdatePacket(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player);
|
||||
charArray getUpdatePacket(std::shared_ptr<ItemInstance> itemInstance, Level *level, std::shared_ptr<Player> player);
|
||||
|
||||
using SavedData::setDirty;
|
||||
void setDirty(int x, int y0, int y1);
|
||||
void handleComplexItemData(charArray &data);
|
||||
|
||||
// 4J Stu Added
|
||||
void mergeInMapData(shared_ptr<MapItemSavedData> dataToAdd);
|
||||
void removeItemFrameDecoration(shared_ptr<ItemInstance> item);
|
||||
void mergeInMapData(std::shared_ptr<MapItemSavedData> dataToAdd);
|
||||
void removeItemFrameDecoration(std::shared_ptr<ItemInstance> item);
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
using namespace std;
|
||||
|
||||
|
||||
#include "ChunkStorage.h"
|
||||
#include "../LevelChunk.h"
|
||||
@@ -12,18 +12,18 @@ class ConsoleSaveFile;
|
||||
class McRegionChunkStorage : public ChunkStorage
|
||||
{
|
||||
private:
|
||||
const wstring m_prefix;
|
||||
const std::wstring m_prefix;
|
||||
ConsoleSaveFile *m_saveFile;
|
||||
static CRITICAL_SECTION cs_memory;
|
||||
|
||||
unordered_map<__int64, byteArray> m_entityData;
|
||||
std::unordered_map<__int64, byteArray> m_entityData;
|
||||
|
||||
static std::deque<DataOutputStream *> s_chunkDataQueue;
|
||||
static int s_runningThreadCount;
|
||||
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();
|
||||
@@ -30,7 +30,7 @@ ChunkStorage *McRegionLevelStorage::createChunkStorage(Dimension *dimension)
|
||||
if(app.GetResetNether())
|
||||
{
|
||||
#ifdef SPLIT_SAVES
|
||||
vector<FileEntry *> *netherFiles = m_saveFile->getRegionFilesByDimension(1);
|
||||
std::vector<FileEntry *> *netherFiles = m_saveFile->getRegionFilesByDimension(1);
|
||||
if(netherFiles!=NULL)
|
||||
{
|
||||
DWORD bytesWritten = 0;
|
||||
@@ -41,7 +41,7 @@ ChunkStorage *McRegionLevelStorage::createChunkStorage(Dimension *dimension)
|
||||
delete netherFiles;
|
||||
}
|
||||
#else
|
||||
vector<FileEntry *> *netherFiles = m_saveFile->getFilesWithPrefix(LevelStorage::NETHER_FOLDER);
|
||||
std::vector<FileEntry *> *netherFiles = m_saveFile->getFilesWithPrefix(LevelStorage::NETHER_FOLDER);
|
||||
if(netherFiles!=NULL)
|
||||
{
|
||||
for(AUTO_VAR(it, netherFiles->begin()); it != netherFiles->end(); ++it)
|
||||
@@ -71,7 +71,7 @@ ChunkStorage *McRegionLevelStorage::createChunkStorage(Dimension *dimension)
|
||||
// For versions before TU9 (TU7 and 8) we generate a part of The End, but we want to scrap it if it exists so that it is replaced with the TU9+ version
|
||||
app.DebugPrintf("Loaded save version number is: %d, required to keep The End is: %d\n",m_saveFile->getSaveVersion(), SAVE_FILE_VERSION_NEW_END);
|
||||
|
||||
vector<FileEntry *> *endFiles = m_saveFile->getFilesWithPrefix(LevelStorage::ENDER_FOLDER);
|
||||
std::vector<FileEntry *> *endFiles = m_saveFile->getFilesWithPrefix(LevelStorage::ENDER_FOLDER);
|
||||
|
||||
// 4J-PB - There will be no End in early saves
|
||||
if(endFiles!=NULL)
|
||||
@@ -89,7 +89,7 @@ ChunkStorage *McRegionLevelStorage::createChunkStorage(Dimension *dimension)
|
||||
return new McRegionChunkStorage(m_saveFile, L"");
|
||||
}
|
||||
|
||||
void McRegionLevelStorage::saveLevelData(LevelData *levelData, vector<shared_ptr<Player> > *players)
|
||||
void McRegionLevelStorage::saveLevelData(LevelData *levelData, std::vector<std::shared_ptr<Player> > *players)
|
||||
{
|
||||
levelData->setVersion(MCREGION_VERSION_ID);
|
||||
MemSect(38);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
using namespace std;
|
||||
|
||||
|
||||
#include "DirectoryLevelStorage.h"
|
||||
|
||||
@@ -13,10 +13,10 @@ 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);
|
||||
virtual void saveLevelData(LevelData *levelData, vector<shared_ptr<Player> > *players);
|
||||
virtual void saveLevelData(LevelData *levelData, std::vector<std::shared_ptr<Player> > *players);
|
||||
virtual void closeAll();
|
||||
};
|
||||
@@ -27,17 +27,17 @@ McRegionLevelStorageSource::McRegionLevelStorageSource(File dir) : DirectoryLeve
|
||||
{
|
||||
}
|
||||
|
||||
wstring McRegionLevelStorageSource::getName()
|
||||
std::wstring McRegionLevelStorageSource::getName()
|
||||
{
|
||||
return L"Scaevolus' McRegion";
|
||||
}
|
||||
|
||||
vector<LevelSummary *> *McRegionLevelStorageSource::getLevelList()
|
||||
std::vector<LevelSummary *> *McRegionLevelStorageSource::getLevelList()
|
||||
{
|
||||
// 4J Stu - We don't need to do directory lookups with the xbox save files
|
||||
vector<LevelSummary *> *levels = new vector<LevelSummary *>;
|
||||
std::vector<LevelSummary *> *levels = new std::vector<LevelSummary *>;
|
||||
#if 0
|
||||
vector<File *> *subFolders = baseDir.listFiles();
|
||||
std::vector<File *> *subFolders = baseDir.listFiles();
|
||||
File *file;
|
||||
AUTO_VAR(itEnd, subFolders->end());
|
||||
for (AUTO_VAR(it, subFolders->begin()); it != itEnd; it++)
|
||||
@@ -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()
|
||||
{
|
||||
}
|
||||
|
||||
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 shared_ptr<LevelStorage>(new McRegionLevelStorage(saveFile, 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
|
||||
@@ -117,10 +117,10 @@ bool McRegionLevelStorageSource::convertLevel(ConsoleSaveFile *saveFile, const w
|
||||
#if 0
|
||||
progress->progressStagePercentage(0);
|
||||
|
||||
vector<ChunkFile *> *normalRegions = new vector<ChunkFile *>;
|
||||
vector<File *> *normalBaseFolders = new vector<File *>;
|
||||
vector<ChunkFile *> *netherRegions = new vector<ChunkFile *>;
|
||||
vector<File *> *netherBaseFolders = new vector<File *>;
|
||||
std::vector<ChunkFile *> *normalRegions = new std::vector<ChunkFile *>;
|
||||
std::vector<File *> *normalBaseFolders = new std::vector<File *>;
|
||||
std::vector<ChunkFile *> *netherRegions = new std::vector<ChunkFile *>;
|
||||
std::vector<File *> *netherBaseFolders = new std::vector<File *>;
|
||||
ArrayList<ChunkFile> enderRegions = new ArrayList<ChunkFile>();
|
||||
ArrayList<File> enderBaseFolders = new ArrayList<File>();
|
||||
|
||||
@@ -173,13 +173,13 @@ bool McRegionLevelStorageSource::convertLevel(ConsoleSaveFile *saveFile, const w
|
||||
|
||||
#if 0
|
||||
// 4J - not required anymore
|
||||
void McRegionLevelStorageSource::addRegions(File &baseFolder, vector<ChunkFile *> *dest, vector<File *> *firstLevelFolders)
|
||||
void McRegionLevelStorageSource::addRegions(File &baseFolder, std::vector<ChunkFile *> *dest, std::vector<File *> *firstLevelFolders)
|
||||
{
|
||||
FolderFilter folderFilter;
|
||||
ChunkFilter chunkFilter;
|
||||
|
||||
File *folder1;
|
||||
vector<File *> *folderLevel1 = baseFolder.listFiles((FileFilter *) &folderFilter);
|
||||
std::vector<File *> *folderLevel1 = baseFolder.listFiles((FileFilter *) &folderFilter);
|
||||
AUTO_VAR(itEnd, folderLevel1->end());
|
||||
for (AUTO_VAR(it, folderLevel1->begin()); it != itEnd; it++)
|
||||
{
|
||||
@@ -189,13 +189,13 @@ void McRegionLevelStorageSource::addRegions(File &baseFolder, vector<ChunkFile *
|
||||
firstLevelFolders->push_back(folder1);
|
||||
|
||||
File *folder2;
|
||||
vector<File *> *folderLevel2 = folder1->listFiles(&folderFilter);
|
||||
std::vector<File *> *folderLevel2 = folder1->listFiles(&folderFilter);
|
||||
AUTO_VAR(itEnd2, folderLevel2->end());
|
||||
for (AUTO_VAR(it2, folderLevel2->begin()); it2 != itEnd; it2++)
|
||||
{
|
||||
folder2 = *it2; //folderLevel2->at(i2);
|
||||
|
||||
vector<File *> *chunkFiles = folder2->listFiles((FileFilter *) &chunkFilter);
|
||||
std::vector<File *> *chunkFiles = folder2->listFiles((FileFilter *) &chunkFilter);
|
||||
|
||||
File *chunk;
|
||||
AUTO_VAR(itEndFile, chunkFiles->end());
|
||||
@@ -210,7 +210,7 @@ void McRegionLevelStorageSource::addRegions(File &baseFolder, vector<ChunkFile *
|
||||
}
|
||||
#endif
|
||||
|
||||
void McRegionLevelStorageSource::convertRegions(File &baseFolder, vector<ChunkFile *> *chunkFiles, int currentCount, int totalCount, ProgressListener *progress)
|
||||
void McRegionLevelStorageSource::convertRegions(File &baseFolder, std::vector<ChunkFile *> *chunkFiles, int currentCount, int totalCount, ProgressListener *progress)
|
||||
{
|
||||
assert( false );
|
||||
|
||||
@@ -269,7 +269,7 @@ void McRegionLevelStorageSource::convertRegions(File &baseFolder, vector<ChunkFi
|
||||
|
||||
}
|
||||
|
||||
void McRegionLevelStorageSource::eraseFolders(vector<File *> *folders, int currentCount, int totalCount, ProgressListener *progress)
|
||||
void McRegionLevelStorageSource::eraseFolders(std::vector<File *> *folders, int currentCount, int totalCount, ProgressListener *progress)
|
||||
{
|
||||
File *folder;
|
||||
AUTO_VAR(itEnd, folders->end());
|
||||
@@ -277,7 +277,7 @@ void McRegionLevelStorageSource::eraseFolders(vector<File *> *folders, int curre
|
||||
{
|
||||
folder = *it; //folders->at(i);
|
||||
|
||||
vector<File *> *files = folder->listFiles();
|
||||
std::vector<File *> *files = folder->listFiles();
|
||||
deleteRecursive(files);
|
||||
folder->_delete();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
using namespace std;
|
||||
|
||||
|
||||
#include "DirectoryLevelStorageSource.h"
|
||||
#include "../../IO/Files/FileFilter.h"
|
||||
@@ -14,21 +14,21 @@ public:
|
||||
class ChunkFile;
|
||||
|
||||
McRegionLevelStorageSource(File dir);
|
||||
virtual wstring getName();
|
||||
virtual vector<LevelSummary *> *getLevelList();
|
||||
virtual std::wstring getName();
|
||||
virtual std::vector<LevelSummary *> *getLevelList();
|
||||
virtual void clearAll();
|
||||
virtual 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
|
||||
// 4J - not required anymore
|
||||
void addRegions(File &baseFolder, vector<ChunkFile *> *dest, vector<File *> *firstLevelFolders);
|
||||
void addRegions(File &baseFolder, std::vector<ChunkFile *> *dest, std::vector<File *> *firstLevelFolders);
|
||||
#endif
|
||||
void convertRegions(File &baseFolder, vector<ChunkFile *> *chunkFiles, int currentCount, int totalCount, ProgressListener *progress);
|
||||
void eraseFolders(vector<File *> *folders, int currentCount, int totalCount, ProgressListener *progress);
|
||||
void convertRegions(File &baseFolder, std::vector<ChunkFile *> *chunkFiles, int currentCount, int totalCount, ProgressListener *progress);
|
||||
void eraseFolders(std::vector<File *> *folders, int currentCount, int totalCount, ProgressListener *progress);
|
||||
|
||||
public:
|
||||
#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>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
using namespace std;
|
||||
|
||||
|
||||
#include "../ChunkSource.h"
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ ChunkStorage *MemoryLevelStorage::createChunkStorage(Dimension *dimension)
|
||||
return new MemoryChunkStorage();
|
||||
}
|
||||
|
||||
void MemoryLevelStorage::saveLevelData(LevelData *levelData, vector<shared_ptr<Player> > *players)
|
||||
void MemoryLevelStorage::saveLevelData(LevelData *levelData, std::vector<std::shared_ptr<Player> > *players)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -43,21 +43,21 @@ void MemoryLevelStorage::closeAll()
|
||||
{
|
||||
}
|
||||
|
||||
void MemoryLevelStorage::save(shared_ptr<Player> player)
|
||||
void MemoryLevelStorage::save(std::shared_ptr<Player> player)
|
||||
{
|
||||
}
|
||||
|
||||
bool MemoryLevelStorage::load(shared_ptr<Player> player)
|
||||
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""));
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
using namespace std;
|
||||
|
||||
|
||||
#include "LevelStorage.h"
|
||||
#include "PlayerIO.h"
|
||||
@@ -20,12 +20,12 @@ public:
|
||||
virtual LevelData *prepareLevel();
|
||||
virtual void checkSession();
|
||||
virtual ChunkStorage *createChunkStorage(Dimension *dimension);
|
||||
virtual void saveLevelData(LevelData *levelData, vector<shared_ptr<Player> > *players);
|
||||
virtual void saveLevelData(LevelData *levelData, std::vector<std::shared_ptr<Player> > *players);
|
||||
virtual void saveLevelData(LevelData *levelData);
|
||||
virtual PlayerIO *getPlayerIO();
|
||||
virtual void closeAll();
|
||||
virtual void save(shared_ptr<Player> player);
|
||||
virtual bool load(shared_ptr<Player> player);
|
||||
virtual CompoundTag *loadPlayerDataTag(const wstring& playerName);
|
||||
virtual ConsoleSavePath getDataFile(const wstring& id);
|
||||
virtual void save(std::shared_ptr<Player> player);
|
||||
virtual bool load(std::shared_ptr<Player> player);
|
||||
virtual CompoundTag *loadPlayerDataTag(const std::wstring& playerName);
|
||||
virtual ConsoleSavePath getDataFile(const std::wstring& id);
|
||||
};
|
||||
@@ -8,54 +8,54 @@ MemoryLevelStorageSource::MemoryLevelStorageSource()
|
||||
{
|
||||
}
|
||||
|
||||
wstring MemoryLevelStorageSource::getName()
|
||||
std::wstring MemoryLevelStorageSource::getName()
|
||||
{
|
||||
return L"Memory Storage";
|
||||
}
|
||||
|
||||
shared_ptr<LevelStorage> MemoryLevelStorageSource::selectLevel(const wstring& levelId, bool createPlayerDir)
|
||||
std::shared_ptr<LevelStorage> MemoryLevelStorageSource::selectLevel(const std::wstring& levelId, bool createPlayerDir)
|
||||
{
|
||||
return shared_ptr<LevelStorage> () new MemoryLevelStorage());
|
||||
return std::shared_ptr<LevelStorage> () new MemoryLevelStorage());
|
||||
}
|
||||
|
||||
vector<LevelSummary *> *MemoryLevelStorageSource::getLevelList()
|
||||
std::vector<LevelSummary *> *MemoryLevelStorageSource::getLevelList()
|
||||
{
|
||||
return new vector<LevelSummary *>;
|
||||
return new std::vector<LevelSummary *>;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
using namespace std;
|
||||
|
||||
|
||||
#include "LevelStorageSource.h"
|
||||
|
||||
@@ -7,15 +7,15 @@ class MemoryLevelStorageSource : public LevelStorageSource
|
||||
{
|
||||
public:
|
||||
MemoryLevelStorageSource();
|
||||
wstring getName();
|
||||
shared_ptr<LevelStorage> selectLevel(const wstring& levelId, bool createPlayerDir);
|
||||
vector<LevelSummary *> *getLevelList();
|
||||
std::wstring getName();
|
||||
std::shared_ptr<LevelStorage> selectLevel(const std::wstring& levelId, bool createPlayerDir);
|
||||
std::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);
|
||||
};
|
||||
@@ -21,7 +21,7 @@ ChunkStorage *MockedLevelStorage::createChunkStorage(Dimension *dimension)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void MockedLevelStorage::saveLevelData(LevelData *levelData, vector<shared_ptr<Player> > *players)
|
||||
void MockedLevelStorage::saveLevelData(LevelData *levelData, std::vector<std::shared_ptr<Player> > *players)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
using namespace std;
|
||||
|
||||
|
||||
#include "LevelStorage.h"
|
||||
|
||||
@@ -11,12 +11,12 @@ public:
|
||||
virtual LevelData *prepareLevel();
|
||||
virtual void checkSession();
|
||||
virtual ChunkStorage *createChunkStorage(Dimension *dimension);
|
||||
virtual void saveLevelData(LevelData *levelData, vector<shared_ptr<Player> > *players);
|
||||
virtual void saveLevelData(LevelData *levelData, std::vector<std::shared_ptr<Player> > *players);
|
||||
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)
|
||||
@@ -211,9 +211,9 @@ bool OldChunkStorage::saveEntities(LevelChunk *lc, Level *level, CompoundTag *ta
|
||||
for (int i = 0; i < lc->ENTITY_BLOCKS_LENGTH; i++)
|
||||
{
|
||||
AUTO_VAR(itEnd, lc->entityBlocks[i]->end());
|
||||
for( vector<shared_ptr<Entity> >::iterator it = lc->entityBlocks[i]->begin(); it != itEnd; it++ )
|
||||
for( std::vector<std::shared_ptr<Entity> >::iterator it = lc->entityBlocks[i]->begin(); it != itEnd; it++ )
|
||||
{
|
||||
shared_ptr<Entity> e = *it;
|
||||
std::shared_ptr<Entity> e = *it;
|
||||
lc->lastSaveHadEntities = true;
|
||||
CompoundTag *teTag = new CompoundTag();
|
||||
if (e->save(teTag))
|
||||
@@ -268,10 +268,10 @@ void OldChunkStorage::save(LevelChunk *lc, Level *level, DataOutputStream *dos)
|
||||
ListTag<CompoundTag> *tileEntityTags = new ListTag<CompoundTag>();
|
||||
|
||||
AUTO_VAR(itEnd, lc->tileEntities.end());
|
||||
for( unordered_map<TilePos, shared_ptr<TileEntity>, TilePosKeyHash, TilePosKeyEq>::iterator it = lc->tileEntities.begin();
|
||||
for( std::unordered_map<TilePos, std::shared_ptr<TileEntity>, TilePosKeyHash, TilePosKeyEq>::iterator it = lc->tileEntities.begin();
|
||||
it != itEnd; it++)
|
||||
{
|
||||
shared_ptr<TileEntity> te = it->second;
|
||||
std::shared_ptr<TileEntity> te = it->second;
|
||||
CompoundTag *teTag = new CompoundTag();
|
||||
te->save(teTag);
|
||||
tileEntityTags->add(teTag);
|
||||
@@ -280,7 +280,7 @@ void OldChunkStorage::save(LevelChunk *lc, Level *level, DataOutputStream *dos)
|
||||
PIXEndNamedEvent();
|
||||
|
||||
PIXBeginNamedEvent(0,"Saving tile tick data");
|
||||
vector<TickNextTickData > *ticksInChunk = level->fetchTicksInChunk(lc, false);
|
||||
std::vector<TickNextTickData > *ticksInChunk = level->fetchTicksInChunk(lc, false);
|
||||
if (ticksInChunk != NULL)
|
||||
{
|
||||
__int64 levelTime = level->getTime();
|
||||
@@ -357,10 +357,10 @@ void OldChunkStorage::save(LevelChunk *lc, Level *level, CompoundTag *tag)
|
||||
ListTag<CompoundTag> *tileEntityTags = new ListTag<CompoundTag>();
|
||||
|
||||
AUTO_VAR(itEnd, lc->tileEntities.end());
|
||||
for( unordered_map<TilePos, shared_ptr<TileEntity>, TilePosKeyHash, TilePosKeyEq>::iterator it = lc->tileEntities.begin();
|
||||
for( std::unordered_map<TilePos, std::shared_ptr<TileEntity>, TilePosKeyHash, TilePosKeyEq>::iterator it = lc->tileEntities.begin();
|
||||
it != itEnd; it++)
|
||||
{
|
||||
shared_ptr<TileEntity> te = it->second;
|
||||
std::shared_ptr<TileEntity> te = it->second;
|
||||
CompoundTag *teTag = new CompoundTag();
|
||||
te->save(teTag);
|
||||
tileEntityTags->add(teTag);
|
||||
@@ -369,7 +369,7 @@ void OldChunkStorage::save(LevelChunk *lc, Level *level, CompoundTag *tag)
|
||||
PIXEndNamedEvent();
|
||||
|
||||
PIXBeginNamedEvent(0,"Saving tile tick data");
|
||||
vector<TickNextTickData > *ticksInChunk = level->fetchTicksInChunk(lc, false);
|
||||
std::vector<TickNextTickData > *ticksInChunk = level->fetchTicksInChunk(lc, false);
|
||||
if (ticksInChunk != NULL)
|
||||
{
|
||||
__int64 levelTime = level->getTime();
|
||||
@@ -402,7 +402,7 @@ void OldChunkStorage::loadEntities(LevelChunk *lc, Level *level, CompoundTag *ta
|
||||
for (int i = 0; i < entityTags->size(); i++)
|
||||
{
|
||||
CompoundTag *teTag = entityTags->get(i);
|
||||
shared_ptr<Entity> te = EntityIO::loadStatic(teTag, level);
|
||||
std::shared_ptr<Entity> te = EntityIO::loadStatic(teTag, level);
|
||||
lc->lastSaveHadEntities = true;
|
||||
if (te != NULL)
|
||||
{
|
||||
@@ -417,7 +417,7 @@ void OldChunkStorage::loadEntities(LevelChunk *lc, Level *level, CompoundTag *ta
|
||||
for (int i = 0; i < tileEntityTags->size(); i++)
|
||||
{
|
||||
CompoundTag *teTag = tileEntityTags->get(i);
|
||||
shared_ptr<TileEntity> te = TileEntity::loadStatic(teTag);
|
||||
std::shared_ptr<TileEntity> te = TileEntity::loadStatic(teTag);
|
||||
if (te != NULL)
|
||||
{
|
||||
lc->addTileEntity(te);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
using namespace std;
|
||||
|
||||
|
||||
// If we have more than MAX_PLAYER_DATA_SAVES player.dat's then we delete the oldest ones
|
||||
// This value can be no higher than MAXIMUM_MAP_SAVE_DATA/3 (3 being the number of dimensions in future versions)
|
||||
@@ -10,13 +10,13 @@ class Player;
|
||||
class PlayerIO
|
||||
{
|
||||
public:
|
||||
virtual void save(shared_ptr<Player> player) = 0;
|
||||
virtual bool load(shared_ptr<Player> player) = 0; // 4J Changed return val to bool to check if new player or loaded player
|
||||
virtual void save(std::shared_ptr<Player> player) = 0;
|
||||
virtual bool load(std::shared_ptr<Player> player) = 0; // 4J Changed return val to bool to check if new player or loaded player
|
||||
virtual CompoundTag *loadPlayerDataTag(PlayerUID xuid) = 0; // 4J Changed from string name to xuid
|
||||
|
||||
// 4J Added
|
||||
virtual void clearOldPlayerFiles() = 0;
|
||||
virtual void saveMapIdLookup() = 0;
|
||||
virtual void deleteMapFilesForPlayer(shared_ptr<Player> player) = 0;
|
||||
virtual void deleteMapFilesForPlayer(std::shared_ptr<Player> player) = 0;
|
||||
virtual void saveAllCachedData() = 0;
|
||||
};
|
||||
@@ -11,7 +11,7 @@ PortalForcer::PortalForcer()
|
||||
}
|
||||
|
||||
|
||||
void PortalForcer::force(Level *level, shared_ptr<Entity> e)
|
||||
void PortalForcer::force(Level *level, std::shared_ptr<Entity> e)
|
||||
{
|
||||
if (level->dimension->id == 1)
|
||||
{
|
||||
@@ -54,7 +54,7 @@ void PortalForcer::force(Level *level, shared_ptr<Entity> e)
|
||||
}
|
||||
|
||||
|
||||
bool PortalForcer::findPortal(Level *level, shared_ptr<Entity> e)
|
||||
bool PortalForcer::findPortal(Level *level, std::shared_ptr<Entity> e)
|
||||
{
|
||||
// 4J Stu - Decrease the range at which we search for a portal in the nether given our smaller nether
|
||||
int r = 16;//* 8;
|
||||
@@ -133,7 +133,7 @@ bool PortalForcer::findPortal(Level *level, shared_ptr<Entity> e)
|
||||
}
|
||||
|
||||
|
||||
bool PortalForcer::createPortal(Level *level, shared_ptr<Entity> e)
|
||||
bool PortalForcer::createPortal(Level *level, std::shared_ptr<Entity> e)
|
||||
{
|
||||
// 4J Stu - Increase the range at which we try and create a portal to stop creating them floating in mid air over lava
|
||||
int r = 16 * 3;
|
||||
|
||||
@@ -11,11 +11,11 @@ public:
|
||||
// 4J Stu Added - Java has no ctor, but we need to initialise random
|
||||
PortalForcer();
|
||||
|
||||
void force(Level *level, shared_ptr<Entity> e);
|
||||
void force(Level *level, std::shared_ptr<Entity> e);
|
||||
|
||||
public:
|
||||
bool findPortal(Level *level, shared_ptr<Entity> e);
|
||||
bool findPortal(Level *level, std::shared_ptr<Entity> e);
|
||||
|
||||
public:
|
||||
bool createPortal(Level *level, shared_ptr<Entity> e);
|
||||
bool createPortal(Level *level, std::shared_ptr<Entity> e);
|
||||
};
|
||||
@@ -84,17 +84,17 @@ bool ReadOnlyChunkCache::shouldSave()
|
||||
return false;
|
||||
}
|
||||
|
||||
wstring ReadOnlyChunkCache::gatherStats()
|
||||
std::wstring ReadOnlyChunkCache::gatherStats()
|
||||
{
|
||||
return L"ReadOnlyChunkCache";
|
||||
}
|
||||
|
||||
vector<Biome::MobSpawnerData *> *ReadOnlyChunkCache::getMobsAt(MobCategory *mobCategory, int x, int y, int z)
|
||||
std::vector<Biome::MobSpawnerData *> *ReadOnlyChunkCache::getMobsAt(MobCategory *mobCategory, int x, int y, int z)
|
||||
{
|
||||
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 std::vector<Biome::MobSpawnerData *> *getMobsAt(MobCategory *mobCategory, int x, int y, int z);
|
||||
virtual TilePos *findNearestMapFeature(Level *level, const std::wstring& featureName, int x, int y, int z);
|
||||
};
|
||||
|
||||
@@ -137,7 +137,7 @@ LevelChunk* Region::getLevelChunk(int x, int y, int z)
|
||||
|
||||
|
||||
|
||||
shared_ptr<TileEntity> Region::getTileEntity(int x, int y, int z)
|
||||
std::shared_ptr<TileEntity> Region::getTileEntity(int x, int y, int z)
|
||||
{
|
||||
int xc = (x >> 4) - xc1;
|
||||
int zc = (z >> 4) - zc1;
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
virtual ~Region();
|
||||
bool isAllEmpty();
|
||||
int getTile(int x, int y, int z);
|
||||
shared_ptr<TileEntity> getTileEntity(int x, int y, int z);
|
||||
std::shared_ptr<TileEntity> getTileEntity(int x, int y, int z);
|
||||
float getBrightness(int x, int y, int z, int emitt);
|
||||
float getBrightness(int x, int y, int z);
|
||||
int getLightColor(int x, int y, int z, int emitt, int tileId = -1); // 4J - change brought forward from 1.8.2
|
||||
|
||||
@@ -80,7 +80,7 @@ RegionFile::RegionFile(ConsoleSaveFile *saveFile, File *path)
|
||||
{
|
||||
nSectors = (int) fileEntry->getFileSize() / SECTOR_BYTES;
|
||||
}
|
||||
sectorFree = new vector<bool>;
|
||||
sectorFree = new std::vector<bool>;
|
||||
sectorFree->reserve(nSectors);
|
||||
|
||||
for (int i = 0; i < nSectors; ++i)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "../../IO/Streams/Compression.h"
|
||||
#include "../../IO/Streams/InputOutputStream.h"
|
||||
using namespace std;
|
||||
|
||||
|
||||
class FileEntry;
|
||||
class ConsoleSaveFile;
|
||||
@@ -29,7 +29,7 @@ private:
|
||||
|
||||
int *offsets;
|
||||
int *chunkTimestamps;
|
||||
vector<bool> *sectorFree;
|
||||
std::vector<bool> *sectorFree;
|
||||
int sizeDelta;
|
||||
__int64 _lastModified;
|
||||
bool m_bIsEmpty; // 4J added
|
||||
|
||||
@@ -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()))
|
||||
|
||||
@@ -9,7 +9,7 @@ class RegionFileCache
|
||||
private:
|
||||
static const int MAX_CACHE_SIZE = 256;
|
||||
|
||||
unordered_map<File, RegionFile *, FileKeyHash, FileKeyEq> cache;
|
||||
std::unordered_map<File, RegionFile *, FileKeyHash, FileKeyEq> cache;
|
||||
|
||||
static RegionFileCache s_defaultCache;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
|
||||
|
||||
SavedData::SavedData(const wstring& id) : id( id )
|
||||
SavedData::SavedData(const std::wstring& id) : id( id )
|
||||
{
|
||||
dirty = false;
|
||||
}
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
#pragma once
|
||||
using namespace std;
|
||||
|
||||
|
||||
#include "../../Util/Class.h"
|
||||
|
||||
class CompoundTag;
|
||||
|
||||
class SavedData : public enable_shared_from_this<SavedData>
|
||||
class SavedData : public std::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,37 +11,37 @@
|
||||
SavedDataStorage::SavedDataStorage(LevelStorage *levelStorage)
|
||||
{
|
||||
/*
|
||||
cache = new unordered_map<wstring, shared_ptr<SavedData> >;
|
||||
savedDatas = new vector<shared_ptr<SavedData> >;
|
||||
usedAuxIds = new unordered_map<wstring, short*>;
|
||||
cache = new std::unordered_map<std::wstring, std::shared_ptr<SavedData> >;
|
||||
savedDatas = new std::vector<std::shared_ptr<SavedData> >;
|
||||
usedAuxIds = new std::unordered_map<std::wstring, short*>;
|
||||
*/
|
||||
|
||||
this->levelStorage = levelStorage;
|
||||
loadAuxValues();
|
||||
}
|
||||
|
||||
shared_ptr<SavedData> SavedDataStorage::get(const type_info& clazz, const wstring& id)
|
||||
std::shared_ptr<SavedData> SavedDataStorage::get(const std::type_info& clazz, const std::wstring& id)
|
||||
{
|
||||
AUTO_VAR(it, cache.find( id ));
|
||||
if (it != cache.end()) return (*it).second;
|
||||
|
||||
shared_ptr<SavedData> data = nullptr;
|
||||
std::shared_ptr<SavedData> data = nullptr;
|
||||
if (levelStorage != NULL)
|
||||
{
|
||||
//File file = levelStorage->getDataFile(id);
|
||||
ConsoleSavePath file = levelStorage->getDataFile(id);
|
||||
if (!file.getName().empty() && levelStorage->getSaveFile()->doesFileExist( file ) )
|
||||
{
|
||||
// mob = dynamic_pointer_cast<Mob>(Mob::_class->newInstance( level ));
|
||||
// mob = std::dynamic_pointer_cast<Mob>(Mob::_class->newInstance( level ));
|
||||
//data = clazz.getConstructor(String.class).newInstance(id);
|
||||
|
||||
if( clazz == typeid(MapItemSavedData) )
|
||||
{
|
||||
data = dynamic_pointer_cast<SavedData>( shared_ptr<MapItemSavedData>(new MapItemSavedData(id)) );
|
||||
data = std::dynamic_pointer_cast<SavedData>( std::shared_ptr<MapItemSavedData>(new MapItemSavedData(id)) );
|
||||
}
|
||||
else if( clazz == typeid(Villages) )
|
||||
{
|
||||
data = dynamic_pointer_cast<SavedData>( shared_ptr<Villages>(new Villages(id) ) );
|
||||
data = std::dynamic_pointer_cast<SavedData>( std::shared_ptr<Villages>(new Villages(id) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -59,13 +59,13 @@ shared_ptr<SavedData> SavedDataStorage::get(const type_info& clazz, const wstrin
|
||||
|
||||
if (data != NULL)
|
||||
{
|
||||
cache.insert( unordered_map<wstring, 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, shared_ptr<SavedData> data)
|
||||
void SavedDataStorage::set(const std::wstring& id, std::shared_ptr<SavedData> data)
|
||||
{
|
||||
if (data == NULL)
|
||||
{
|
||||
@@ -91,7 +91,7 @@ void SavedDataStorage::save()
|
||||
AUTO_VAR(itEnd, savedDatas.end());
|
||||
for (AUTO_VAR(it, savedDatas.begin()); it != itEnd; it++)
|
||||
{
|
||||
shared_ptr<SavedData> data = *it; //savedDatas->at(i);
|
||||
std::shared_ptr<SavedData> data = *it; //savedDatas->at(i);
|
||||
if (data->isDirty())
|
||||
{
|
||||
save(data);
|
||||
@@ -100,7 +100,7 @@ void SavedDataStorage::save()
|
||||
}
|
||||
}
|
||||
|
||||
void SavedDataStorage::save(shared_ptr<SavedData> data)
|
||||
void SavedDataStorage::save(std::shared_ptr<SavedData> data)
|
||||
{
|
||||
if (levelStorage == NULL) return;
|
||||
//File file = levelStorage->getDataFile(data->id);
|
||||
@@ -136,7 +136,7 @@ void SavedDataStorage::loadAuxValues()
|
||||
dis.close();
|
||||
|
||||
Tag *tag;
|
||||
vector<Tag *> *allTags = tags->getAllTags();
|
||||
std::vector<Tag *> *allTags = tags->getAllTags();
|
||||
AUTO_VAR(itEnd, allTags->end());
|
||||
for (AUTO_VAR(it, allTags->begin()); it != itEnd; it++)
|
||||
{
|
||||
@@ -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;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
using namespace std;
|
||||
|
||||
|
||||
class ConsoleSaveFile;
|
||||
#include "SavedData.h"
|
||||
@@ -9,26 +9,26 @@ class SavedDataStorage
|
||||
private:
|
||||
LevelStorage *levelStorage;
|
||||
|
||||
typedef unordered_map<wstring, shared_ptr<SavedData> > cacheMapType;
|
||||
typedef std::unordered_map<std::wstring, std::shared_ptr<SavedData> > cacheMapType;
|
||||
cacheMapType cache;
|
||||
|
||||
vector<shared_ptr<SavedData> > savedDatas;
|
||||
std::vector<std::shared_ptr<SavedData> > savedDatas;
|
||||
|
||||
typedef unordered_map<wstring, short> uaiMapType;
|
||||
typedef std::unordered_map<std::wstring, short> uaiMapType;
|
||||
uaiMapType usedAuxIds;
|
||||
|
||||
public:
|
||||
SavedDataStorage(LevelStorage *);
|
||||
shared_ptr<SavedData> get(const type_info& clazz, const wstring& id);
|
||||
void set(const wstring& id, shared_ptr<SavedData> data);
|
||||
std::shared_ptr<SavedData> get(const std::type_info& clazz, const std::wstring& id);
|
||||
void set(const std::wstring& id, std::shared_ptr<SavedData> data);
|
||||
void save();
|
||||
|
||||
private:
|
||||
void save(shared_ptr<SavedData> data);
|
||||
void save(std::shared_ptr<SavedData> data);
|
||||
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);
|
||||
}
|
||||
@@ -147,10 +147,10 @@ void ZonedChunkStorage::tick()
|
||||
tickCount++;
|
||||
if (tickCount % (20 * 10) == 4)
|
||||
{
|
||||
vector<__int64> toClose;
|
||||
std::vector<__int64> toClose;
|
||||
|
||||
AUTO_VAR(itEndZF, zoneFiles.end());
|
||||
for( unordered_map<__int64, ZoneFile *>::iterator it = zoneFiles.begin(); it != itEndZF; it++ )
|
||||
for( std::unordered_map<__int64, ZoneFile *>::iterator it = zoneFiles.begin(); it != itEndZF; it++ )
|
||||
{
|
||||
ZoneFile *zoneFile = it->second;
|
||||
if (tickCount - zoneFile->lastUse > 20 * 60)
|
||||
@@ -181,7 +181,7 @@ void ZonedChunkStorage::tick()
|
||||
void ZonedChunkStorage::flush()
|
||||
{
|
||||
AUTO_VAR(itEnd, zoneFiles.end());
|
||||
for( unordered_map<__int64, ZoneFile *>::iterator it = zoneFiles.begin(); it != itEnd; it++ )
|
||||
for( std::unordered_map<__int64, ZoneFile *>::iterator it = zoneFiles.begin(); it != itEnd; it++ )
|
||||
{
|
||||
ZoneFile *zoneFile = it->second;
|
||||
// 4J - removed try/catch
|
||||
@@ -198,7 +198,7 @@ void ZonedChunkStorage::loadEntities(Level *level, LevelChunk *lc)
|
||||
{
|
||||
int slot = getSlot(lc->x, lc->z);
|
||||
ZoneFile *zoneFile = getZoneFile(lc->x, lc->z, true);
|
||||
vector<CompoundTag *> *tags = zoneFile->entityFile->readAll(slot);
|
||||
std::vector<CompoundTag *> *tags = zoneFile->entityFile->readAll(slot);
|
||||
|
||||
AUTO_VAR(itEnd, tags->end());
|
||||
for (AUTO_VAR(it, tags->begin()); it != itEnd; it++)
|
||||
@@ -207,12 +207,12 @@ void ZonedChunkStorage::loadEntities(Level *level, LevelChunk *lc)
|
||||
int type = tag->getInt(L"_TYPE");
|
||||
if (type == 0)
|
||||
{
|
||||
shared_ptr<Entity> e = EntityIO::loadStatic(tag, level);
|
||||
std::shared_ptr<Entity> e = EntityIO::loadStatic(tag, level);
|
||||
if (e != NULL) lc->addEntity(e);
|
||||
}
|
||||
else if (type == 1)
|
||||
{
|
||||
shared_ptr<TileEntity> te = TileEntity::loadStatic(tag);
|
||||
std::shared_ptr<TileEntity> te = TileEntity::loadStatic(tag);
|
||||
if (te != NULL) lc->addTileEntity(te);
|
||||
}
|
||||
}
|
||||
@@ -223,7 +223,7 @@ void ZonedChunkStorage::saveEntities(Level *level, LevelChunk *lc)
|
||||
int slot = getSlot(lc->x, lc->z);
|
||||
ZoneFile *zoneFile = getZoneFile(lc->x, lc->z, true);
|
||||
|
||||
vector<CompoundTag *> tags;
|
||||
std::vector<CompoundTag *> tags;
|
||||
|
||||
#ifdef _ENTITIES_RW_SECTION
|
||||
EnterCriticalRWSection(&lc->m_csEntities, true);
|
||||
@@ -232,12 +232,12 @@ void ZonedChunkStorage::saveEntities(Level *level, LevelChunk *lc)
|
||||
#endif
|
||||
for (int i = 0; i < LevelChunk::ENTITY_BLOCKS_LENGTH; i++)
|
||||
{
|
||||
vector<shared_ptr<Entity> > *entities = lc->entityBlocks[i];
|
||||
std::vector<std::shared_ptr<Entity> > *entities = lc->entityBlocks[i];
|
||||
|
||||
AUTO_VAR(itEndTags, entities->end());
|
||||
for (AUTO_VAR(it, entities->begin()); it != itEndTags; it++)
|
||||
{
|
||||
shared_ptr<Entity> e = *it; //entities->at(j);
|
||||
std::shared_ptr<Entity> e = *it; //entities->at(j);
|
||||
CompoundTag *cp = new CompoundTag();
|
||||
cp->putInt(L"_TYPE", 0);
|
||||
e->save(cp);
|
||||
@@ -250,10 +250,10 @@ void ZonedChunkStorage::saveEntities(Level *level, LevelChunk *lc)
|
||||
LeaveCriticalSection(&lc->m_csEntities);
|
||||
#endif
|
||||
|
||||
for( unordered_map<TilePos, shared_ptr<TileEntity> , TilePosKeyHash, TilePosKeyEq>::iterator it = lc->tileEntities.begin();
|
||||
for( std::unordered_map<TilePos, std::shared_ptr<TileEntity> , TilePosKeyHash, TilePosKeyEq>::iterator it = lc->tileEntities.begin();
|
||||
it != lc->tileEntities.end(); it++)
|
||||
{
|
||||
shared_ptr<TileEntity> te = it->second;
|
||||
std::shared_ptr<TileEntity> te = it->second;
|
||||
CompoundTag *cp = new CompoundTag();
|
||||
cp->putInt(L"_TYPE", 1);
|
||||
te->save(cp);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
// 4J Stu - There are changes to this class for 1.8.2, but since we never use it anyway lets not worry about it
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
class ZoneFile;
|
||||
class ZoneIo;
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
File dir;
|
||||
|
||||
private:
|
||||
unordered_map<__int64, ZoneFile *> zoneFiles;
|
||||
std::unordered_map<__int64, ZoneFile *> zoneFiles;
|
||||
__int64 tickCount;
|
||||
|
||||
public:
|
||||
|
||||
@@ -53,15 +53,15 @@ void WaterLevelChunk::setBrightness(LightLayer::variety layer, int x, int y, int
|
||||
{
|
||||
}
|
||||
|
||||
void WaterLevelChunk::addEntity(shared_ptr<Entity> e)
|
||||
void WaterLevelChunk::addEntity(std::shared_ptr<Entity> e)
|
||||
{
|
||||
}
|
||||
|
||||
void WaterLevelChunk::removeEntity(shared_ptr<Entity> e)
|
||||
void WaterLevelChunk::removeEntity(std::shared_ptr<Entity> e)
|
||||
{
|
||||
}
|
||||
|
||||
void WaterLevelChunk::removeEntity(shared_ptr<Entity> e, int yc)
|
||||
void WaterLevelChunk::removeEntity(std::shared_ptr<Entity> e, int yc)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -69,16 +69,16 @@ void WaterLevelChunk::skyBrightnessChanged()
|
||||
{
|
||||
}
|
||||
|
||||
shared_ptr<TileEntity> WaterLevelChunk::getTileEntity(int x, int y, int z)
|
||||
std::shared_ptr<TileEntity> WaterLevelChunk::getTileEntity(int x, int y, int z)
|
||||
{
|
||||
return shared_ptr<TileEntity>();
|
||||
return std::shared_ptr<TileEntity>();
|
||||
}
|
||||
|
||||
void WaterLevelChunk::addTileEntity(shared_ptr<TileEntity> te)
|
||||
void WaterLevelChunk::addTileEntity(std::shared_ptr<TileEntity> te)
|
||||
{
|
||||
}
|
||||
|
||||
void WaterLevelChunk::setTileEntity(int x, int y, int z, shared_ptr<TileEntity> tileEntity)
|
||||
void WaterLevelChunk::setTileEntity(int x, int y, int z, std::shared_ptr<TileEntity> tileEntity)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -98,11 +98,11 @@ void WaterLevelChunk::markUnsaved()
|
||||
{
|
||||
}
|
||||
|
||||
void WaterLevelChunk::getEntities(shared_ptr<Entity> except, AABB bb, vector<shared_ptr<Entity> > &es)
|
||||
void WaterLevelChunk::getEntities(std::shared_ptr<Entity> except, AABB bb, std::vector<std::shared_ptr<Entity> > &es)
|
||||
{
|
||||
}
|
||||
|
||||
void WaterLevelChunk::getEntitiesOfClass(const type_info& ec, AABB bb, vector<shared_ptr<Entity> > &es)
|
||||
void WaterLevelChunk::getEntitiesOfClass(const std::type_info& ec, AABB bb, std::vector<std::shared_ptr<Entity> > &es)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -21,19 +21,19 @@ public:
|
||||
bool setData(int x, int y, int z, int val, int mask, bool *maskedBitsChanged); // 4J added mask
|
||||
void setBrightness(LightLayer::variety layer, int x, int y, int z, int brightness);
|
||||
void setLevelChunkBrightness(LightLayer::variety layer, int x, int y, int z, int brightness); // 4J added - calls the setBrightness method of the parent class
|
||||
void addEntity(shared_ptr<Entity> e);
|
||||
void removeEntity(shared_ptr<Entity> e);
|
||||
void removeEntity(shared_ptr<Entity> e, int yc);
|
||||
void addEntity(std::shared_ptr<Entity> e);
|
||||
void removeEntity(std::shared_ptr<Entity> e);
|
||||
void removeEntity(std::shared_ptr<Entity> e, int yc);
|
||||
void skyBrightnessChanged();
|
||||
shared_ptr<TileEntity> getTileEntity(int x, int y, int z);
|
||||
void addTileEntity(shared_ptr<TileEntity> te);
|
||||
void setTileEntity(int x, int y, int z, shared_ptr<TileEntity> tileEntity);
|
||||
std::shared_ptr<TileEntity> getTileEntity(int x, int y, int z);
|
||||
void addTileEntity(std::shared_ptr<TileEntity> te);
|
||||
void setTileEntity(int x, int y, int z, std::shared_ptr<TileEntity> tileEntity);
|
||||
void removeTileEntity(int x, int y, int z);
|
||||
void load();
|
||||
void unload(bool unloadTileEntities) ; // 4J - added parameter
|
||||
void markUnsaved();
|
||||
void getEntities(shared_ptr<Entity> except, AABB bb, vector<shared_ptr<Entity> > &es);
|
||||
void getEntitiesOfClass(const type_info& ec, AABB bb, vector<shared_ptr<Entity> > &es);
|
||||
void getEntities(std::shared_ptr<Entity> except, AABB bb, std::vector<std::shared_ptr<Entity> > &es);
|
||||
void getEntitiesOfClass(const std::type_info& ec, AABB bb, std::vector<std::shared_ptr<Entity> > &es);
|
||||
int countEntities();
|
||||
bool shouldSave(bool force);
|
||||
void setBlocks(byteArray newBlocks, int sub);
|
||||
|
||||
Reference in New Issue
Block a user