mirror of
https://gitea.sffempire.ru/Kolyah35/minecraft-pe-0.6.1.git
synced 2026-03-20 15:03:32 +00:00
Added a dummy cheats toggle to the world creation screen.
This commit is contained in:
@@ -14,13 +14,14 @@ namespace GameType {
|
||||
class LevelSettings
|
||||
{
|
||||
public:
|
||||
LevelSettings(long seed, int gameType)
|
||||
LevelSettings(long seed, int gameType, bool allowCheats = false)
|
||||
: seed(seed),
|
||||
gameType(gameType)
|
||||
gameType(gameType),
|
||||
allowCheats(allowCheats)
|
||||
{
|
||||
}
|
||||
static LevelSettings None() {
|
||||
return LevelSettings(-1,-1);
|
||||
return LevelSettings(-1,-1,false);
|
||||
}
|
||||
|
||||
long getSeed() const {
|
||||
@@ -31,6 +32,10 @@ public:
|
||||
return gameType;
|
||||
}
|
||||
|
||||
bool getAllowCheats() const {
|
||||
return allowCheats;
|
||||
}
|
||||
|
||||
//
|
||||
// Those two should actually not be here
|
||||
// @todo: Move out when we add LevelSettings.cpp :p
|
||||
@@ -53,6 +58,7 @@ public:
|
||||
private:
|
||||
const long seed;
|
||||
const int gameType;
|
||||
const bool allowCheats;
|
||||
};
|
||||
|
||||
#endif /*NET_MINECRAFT_WORLD_LEVEL__LevelSettings_H__*/
|
||||
|
||||
@@ -12,8 +12,8 @@ LevelData::LevelData()
|
||||
dimension(Dimension::NORMAL),
|
||||
playerDataVersion(-1),
|
||||
storageVersion(0),
|
||||
gameType(GameType::Default),
|
||||
loadedPlayerTag(NULL)
|
||||
gameType(GameType::Default), spawnMobs(false),
|
||||
allowCheats(false), loadedPlayerTag(NULL)
|
||||
{
|
||||
//LOGI("ctor 1: %p\n", this);
|
||||
spawnMobs = (gameType == GameType::Survival);
|
||||
@@ -21,8 +21,7 @@ LevelData::LevelData()
|
||||
|
||||
LevelData::LevelData( const LevelSettings& settings, const std::string& levelName, int generatorVersion /*= -1*/ )
|
||||
: seed(settings.getSeed()),
|
||||
gameType(settings.getGameType()),
|
||||
levelName(levelName),
|
||||
gameType(settings.getGameType()), allowCheats(settings.getAllowCheats()), levelName(levelName),
|
||||
xSpawn(128),
|
||||
ySpawn(64),
|
||||
zSpawn(128),
|
||||
@@ -62,6 +61,7 @@ LevelData::LevelData( const LevelData& rhs )
|
||||
playerDataVersion(rhs.playerDataVersion),
|
||||
generatorVersion(rhs.generatorVersion),
|
||||
spawnMobs(rhs.spawnMobs),
|
||||
allowCheats(rhs.allowCheats),
|
||||
loadedPlayerTag(NULL),
|
||||
playerData(rhs.playerData)
|
||||
{
|
||||
@@ -84,6 +84,7 @@ LevelData& LevelData::operator=( const LevelData& rhs )
|
||||
time = rhs.time;
|
||||
dimension = rhs.dimension;
|
||||
spawnMobs = rhs.spawnMobs;
|
||||
allowCheats = rhs.allowCheats;
|
||||
playerData = rhs.playerData;
|
||||
playerDataVersion = rhs.playerDataVersion;
|
||||
generatorVersion = rhs.generatorVersion;
|
||||
@@ -161,6 +162,7 @@ void LevelData::setTagData( CompoundTag* tag, CompoundTag* playerTag )
|
||||
if (!tag) return;
|
||||
tag->putLong("RandomSeed", seed);
|
||||
tag->putInt("GameType", gameType);
|
||||
tag->putBoolean("AllowCommands", allowCheats);
|
||||
tag->putInt("SpawnX", xSpawn);
|
||||
tag->putInt("SpawnY", ySpawn);
|
||||
tag->putInt("SpawnZ", zSpawn);
|
||||
@@ -181,6 +183,7 @@ void LevelData::getTagData( const CompoundTag* tag )
|
||||
if (!tag) return;
|
||||
seed = (long)tag->getLong("RandomSeed");
|
||||
gameType = tag->getInt("GameType");
|
||||
allowCheats = tag->getBoolean("AllowCommands");
|
||||
xSpawn = tag->getInt("SpawnX");
|
||||
ySpawn = tag->getInt("SpawnY");
|
||||
zSpawn = tag->getInt("SpawnZ");
|
||||
@@ -362,3 +365,13 @@ void LevelData::setSpawnMobs( bool doSpawn )
|
||||
{
|
||||
spawnMobs = doSpawn;
|
||||
}
|
||||
|
||||
bool LevelData::getAllowCheats() const
|
||||
{
|
||||
return allowCheats;
|
||||
}
|
||||
|
||||
void LevelData::setAllowCheats( bool allow )
|
||||
{
|
||||
allowCheats = allow;
|
||||
}
|
||||
|
||||
@@ -72,6 +72,9 @@ public:
|
||||
bool getSpawnMobs() const;
|
||||
void setSpawnMobs(bool doSpawn);
|
||||
|
||||
bool getAllowCheats() const;
|
||||
void setAllowCheats(bool allow);
|
||||
|
||||
public:
|
||||
PlayerData playerData;
|
||||
int playerDataVersion;
|
||||
@@ -89,6 +92,7 @@ private:
|
||||
int gameType;
|
||||
int storageVersion;
|
||||
bool spawnMobs;
|
||||
bool allowCheats;
|
||||
//@note: This version is never written or loaded to disk. The only purpose
|
||||
// is to use it in the level generator on server and clients.
|
||||
int generatorVersion;
|
||||
|
||||
Reference in New Issue
Block a user