summaryrefslogtreecommitdiffstats
path: root/src/World.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/World.cpp')
-rw-r--r--src/World.cpp100
1 files changed, 84 insertions, 16 deletions
diff --git a/src/World.cpp b/src/World.cpp
index 5b067b386..4c57b283f 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -66,6 +66,9 @@ const int TIME_NIGHT_END = 22812;
const int TIME_SUNRISE = 23999;
const int TIME_SPAWN_DIVISOR = 148;
+#define DEFAULT_NETHER_NAME GetName() + "_nether"
+#define DEFAULT_END_NAME GetName() + "_end"
+
@@ -229,8 +232,9 @@ void cWorld::cTickThread::Execute(void)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cWorld:
-cWorld::cWorld(const AString & a_WorldName) :
+cWorld::cWorld(const AString & a_WorldName, eDimension a_Dimension, const AString & a_OverworldName) :
m_WorldName(a_WorldName),
+ m_OverworldName(a_OverworldName),
m_IniFileName(m_WorldName + "/world.ini"),
m_StorageSchema("Default"),
#ifdef __arm__
@@ -238,6 +242,7 @@ cWorld::cWorld(const AString & a_WorldName) :
#else
m_StorageCompressionFactor(6),
#endif
+ m_Dimension(a_Dimension),
m_IsSpawnExplicitlySet(false),
m_WorldAgeSecs(0),
m_TimeOfDaySecs(0),
@@ -251,6 +256,7 @@ cWorld::cWorld(const AString & a_WorldName) :
m_MapManager(this),
m_GeneratorCallbacks(*this),
m_TickThread(*this)
+
{
LOGD("cWorld::cWorld(\"%s\")", a_WorldName.c_str());
@@ -508,7 +514,7 @@ void cWorld::InitializeSpawn(void)
-void cWorld::Start(void)
+void cWorld::Start(bool a_WasDimensionSet)
{
m_SpawnX = 0;
m_SpawnY = cChunkDef::Height;
@@ -520,8 +526,10 @@ void cWorld::Start(void)
{
LOGWARNING("Cannot read world settings from \"%s\", defaults will be used.", m_IniFileName.c_str());
}
- AString Dimension = IniFile.GetValueSet("General", "Dimension", "Overworld");
+
+ AString Dimension = IniFile.GetValueSet("General", "Dimension", a_WasDimensionSet ? DimensionToString(GetDimension()) : "Overworld");
m_Dimension = StringToDimension(Dimension);
+ m_OverworldName = IniFile.GetValue("General", "OverworldName", a_WasDimensionSet ? m_OverworldName : "");
// Try to find the "SpawnPosition" key and coord values in the world configuration, set the flag if found
int KeyNum = IniFile.FindKey("SpawnPosition");
@@ -566,10 +574,52 @@ void cWorld::Start(void)
m_bUseChatPrefixes = IniFile.GetValueSetB("Mechanics", "UseChatPrefixes", true);
m_VillagersShouldHarvestCrops = IniFile.GetValueSetB("Monsters", "VillagersShouldHarvestCrops", true);
int GameMode = IniFile.GetValueSetI("General", "Gamemode", (int)m_GameMode);
+ int Weather = IniFile.GetValueSetI("General", "Weather", (int)m_Weather);
+ m_TimeOfDay = IniFile.GetValueSetI("General", "TimeInTicks", m_TimeOfDay);
+
+ if ((GetDimension() != dimNether) && (GetDimension() != dimEnd))
+ {
+ m_bNetherPortalsEnabled = IniFile.GetValueSetB("General", "NetherPortalsEnabled", true);
+ m_NetherWorldName = IniFile.GetValueSet("General", "NetherWorldName", DEFAULT_NETHER_NAME);
+ m_bEndPortalsEnabled = IniFile.GetValueSetB("General", "EndPortalsEnabled", true);
+ m_EndWorldName = IniFile.GetValueSet("General", "EndWorldName", DEFAULT_END_NAME);
+ }
// Adjust the enum-backed variables into their respective bounds:
m_GameMode = (eGameMode) Clamp(GameMode, (int)gmSurvival, (int)gmAdventure);
m_TNTShrapnelLevel = (eShrapnelLevel)Clamp(TNTShrapnelLevel, (int)slNone, (int)slAll);
+ m_Weather = (eWeather) Clamp(Weather, (int)wSunny, (int)wStorm);
+
+ switch (GetDimension())
+ {
+ case dimEnd:
+ {
+ IniFile.GetValueSet("Generator", "BiomeGen", "Constant");
+ IniFile.GetValueSet("Generator", "ConstantBiome", "End");
+ IniFile.GetValueSet("Generator", "HeightGen", "Biomal");
+ IniFile.GetValueSet("Generator", "CompositionGen", "End");
+ break;
+ }
+ case dimOverworld:
+ {
+ IniFile.GetValueSet("Generator", "BiomeGen", "MultiStepMap");
+ IniFile.GetValueSet("Generator", "HeightGen", "DistortedHeightmap");
+ IniFile.GetValueSet("Generator", "CompositionGen", "DistortedHeightmap");
+ IniFile.GetValueSet("Generator", "Finishers", "Ravines, WormNestCaves, WaterLakes, WaterSprings, LavaLakes, LavaSprings, OreNests, Mineshafts, Trees, SprinkleFoliage, Ice, Snow, Lilypads, BottomLava, DeadBushes, PreSimulator");
+ break;
+ }
+ case dimNether:
+ {
+ IniFile.GetValueSet("Generator", "BiomeGen", "Constant");
+ IniFile.GetValueSet("Generator", "ConstantBiome", "Nether");
+ IniFile.GetValueSet("Generator", "HeightGen", "Flat");
+ IniFile.GetValueSet("Generator", "FlatHeight", "128");
+ IniFile.GetValueSet("Generator", "CompositionGen", "Nether");
+ IniFile.GetValueSet("Generator", "Finishers", "WormNestCaves, BottomLava, LavaSprings, NetherClumpFoliage, NetherForts, PreSimulator");
+ IniFile.GetValueSet("Generator", "BottomLavaHeight", "30");
+ break;
+ }
+ }
// Load allowed mobs:
const char * DefaultMonsters = "";
@@ -703,6 +753,27 @@ void cWorld::Stop(void)
} // for itr - m_Clients[]
m_Clients.clear();
}
+
+ // Write settings to file; these are all plugin changeable values - keep updated!
+ cIniFile IniFile;
+ IniFile.ReadFile(m_IniFileName);
+ if ((GetDimension() != dimNether) && (GetDimension() != dimEnd))
+ {
+ IniFile.SetValueB("General", "NetherPortalsEnabled", m_bNetherPortalsEnabled);
+ IniFile.SetValue("General", "NetherWorldName", m_NetherWorldName);
+ IniFile.SetValueB("General", "EndPortalsEnabled", m_bEndPortalsEnabled);
+ IniFile.SetValue("General", "EndWorldName", m_EndWorldName);
+ }
+ else
+ {
+ IniFile.SetValue("General", "OverworldName", m_OverworldName);
+ }
+ IniFile.SetValueI("Physics", "TNTShrapnelLevel", (int)m_TNTShrapnelLevel);
+ IniFile.SetValueB("Mechanics", "CommandBlocksEnabled", m_bCommandBlocksEnabled);
+ IniFile.SetValueB("Mechanics", "UseChatPrefixes", m_bUseChatPrefixes);
+ IniFile.SetValueI("General", "Weather", (int)m_Weather);
+ IniFile.SetValueI("General", "TimeInTicks", m_TimeOfDay);
+ IniFile.WriteFile(m_IniFileName);
m_TickThread.Stop();
m_Lighting.Stop();
@@ -2346,15 +2417,17 @@ void cWorld::AddPlayer(cPlayer * a_Player)
void cWorld::RemovePlayer(cPlayer * a_Player)
{
-
- m_ChunkMap->RemoveEntity(a_Player);
+ if (!a_Player->IsTravellingThroughPortal())
+ {
+ m_ChunkMap->RemoveEntity(a_Player);
+ }
{
cCSLock Lock(m_CSPlayersToAdd);
m_PlayersToAdd.remove(a_Player);
}
{
cCSLock Lock(m_CSPlayers);
- LOGD("Removing player \"%s\" from world \"%s\".", a_Player->GetName().c_str(), m_WorldName.c_str());
+ LOGD("Removing player %s from world \"%s\".", a_Player->GetName().c_str(), m_WorldName.c_str());
m_Players.remove(a_Player);
}
@@ -2849,15 +2922,6 @@ bool cWorld::HasEntity(int a_UniqueID)
-void cWorld::RemoveEntity(cEntity * a_Entity)
-{
- m_ChunkMap->RemoveEntity(a_Entity);
-}
-
-
-
-
-
/*
unsigned int cWorld::GetNumPlayers(void)
{
@@ -3146,7 +3210,8 @@ void cWorld::AddQueuedPlayers(void)
for (cPlayerList::iterator itr = PlayersToAdd.begin(), end = PlayersToAdd.end(); itr != end; ++itr)
{
ASSERT(std::find(m_Players.begin(), m_Players.end(), *itr) == m_Players.end()); // Is it already in the list? HOW?
-
+
+ LOGD("Adding player %s to world \"%s\".", (*itr)->GetName().c_str(), m_WorldName.c_str());
m_Players.push_back(*itr);
(*itr)->SetWorld(this);
@@ -3175,6 +3240,9 @@ void cWorld::AddQueuedPlayers(void)
if (Client != NULL)
{
Client->StreamChunks();
+ Client->SendPlayerMoveLook();
+ Client->SendHealth();
+ Client->SendWholeInventory(*(*itr)->GetWindow());
}
} // for itr - PlayersToAdd[]
}