summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/BlockID.cpp5
-rw-r--r--src/ChunkMap.cpp6
-rw-r--r--src/ClientHandle.cpp126
-rw-r--r--src/ClientHandle.h5
-rw-r--r--src/Entities/Entity.cpp31
-rw-r--r--src/Entities/Entity.h3
-rw-r--r--src/Entities/FallingBlock.cpp4
-rw-r--r--src/LineBlockTracer.cpp1
-rw-r--r--src/MCLogger.cpp14
-rw-r--r--src/MCLogger.h1
-rw-r--r--src/Mobs/AggressiveMonster.cpp17
-rw-r--r--src/Mobs/AggressiveMonster.h4
-rw-r--r--src/Mobs/Monster.cpp22
-rw-r--r--src/Mobs/Monster.h3
-rw-r--r--src/OSSupport/File.cpp10
-rw-r--r--src/World.cpp80
-rw-r--r--src/World.h5
-rw-r--r--src/WorldStorage/NBTChunkSerializer.cpp8
-rw-r--r--src/WorldStorage/WSSCompact.cpp1
19 files changed, 172 insertions, 174 deletions
diff --git a/src/BlockID.cpp b/src/BlockID.cpp
index 79e122032..bf95d0798 100644
--- a/src/BlockID.cpp
+++ b/src/BlockID.cpp
@@ -324,7 +324,7 @@ eDimension StringToDimension(const AString & a_DimensionString)
{ dimOverworld, "Normal"},
{ dimOverworld, "World"},
{ dimNether, "Nether"},
- { dimNether, "Hell"}, // Alternate name for End
+ { dimNether, "Hell"}, // Alternate name for Nether
{ dimEnd, "End"},
{ dimEnd, "Sky"}, // Old name for End
} ;
@@ -337,7 +337,8 @@ eDimension StringToDimension(const AString & a_DimensionString)
} // for i - DimensionMap[]
// Not found
- return (eDimension)-1000;
+ LOGWARNING("Unknown dimension: \"%s\". Setting to Overworld", a_DimensionString.c_str());
+ return dimOverworld;
}
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index ed9103174..0fb6988b5 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -346,9 +346,8 @@ void cChunkMap::BroadcastAttachEntity(const cEntity & a_Entity, const cEntity *
void cChunkMap::BroadcastBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude)
{
cCSLock Lock(m_CSLayers);
- int x, y, z, ChunkX, ChunkZ;
+ int x, z, ChunkX, ChunkZ;
x = a_BlockX;
- y = a_BlockY;
z = a_BlockZ;
cChunkDef::BlockToChunk(x, z, ChunkX, ChunkZ);
cChunkPtr Chunk = GetChunkNoGen(ChunkX, ZERO_CHUNK_Y, ChunkZ);
@@ -1146,9 +1145,8 @@ BLOCKTYPE cChunkMap::GetBlock(int a_BlockX, int a_BlockY, int a_BlockZ)
// First check if it isn't queued in the m_FastSetBlockQueue:
{
int X = a_BlockX, Y = a_BlockY, Z = a_BlockZ;
- int ChunkX, ChunkY, ChunkZ;
+ int ChunkX, ChunkZ;
cChunkDef::AbsoluteToRelative(X, Y, Z, ChunkX, ChunkZ);
- ChunkY = 0;
cCSLock Lock(m_CSFastSetBlock);
for (sSetBlockList::iterator itr = m_FastSetBlockQueue.begin(); itr != m_FastSetBlockQueue.end(); ++itr)
{
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 63ae98be4..fc3f98aaf 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -186,6 +186,46 @@ void cClientHandle::GenerateOfflineUUID(void)
+AString cClientHandle::FormatChatPrefix(bool ShouldAppendChatPrefixes, AString a_ChatPrefixS, AString m_Color1, AString m_Color2)
+{
+ if (ShouldAppendChatPrefixes)
+ return Printf("%s[%s] %s", m_Color1.c_str(), a_ChatPrefixS.c_str(), m_Color2.c_str());
+ else
+ return Printf("%s", m_Color1.c_str());
+}
+
+
+
+
+
+AString cClientHandle::FormatMessageType(bool ShouldAppendChatPrefixes, eMessageType a_ChatPrefix, const AString &a_AdditionalData)
+{
+ switch (a_ChatPrefix)
+ {
+ case mtCustom: return AString();
+ case mtFailure: return FormatChatPrefix(ShouldAppendChatPrefixes, "INFO", cChatColor::Rose, cChatColor::White);
+ case mtInformation: return FormatChatPrefix(ShouldAppendChatPrefixes, "INFO", cChatColor::Yellow, cChatColor::White);
+ case mtSuccess: return FormatChatPrefix(ShouldAppendChatPrefixes, "INFO", cChatColor::Green, cChatColor::White);
+ case mtWarning: return FormatChatPrefix(ShouldAppendChatPrefixes, "WARN", cChatColor::Rose, cChatColor::White);
+ case mtFatal: return FormatChatPrefix(ShouldAppendChatPrefixes, "FATAL", cChatColor::Red, cChatColor::White);
+ case mtDeath: return FormatChatPrefix(ShouldAppendChatPrefixes, "DEATH", cChatColor::Gray, cChatColor::White);
+ case mtJoin: return FormatChatPrefix(ShouldAppendChatPrefixes, "JOIN", cChatColor::Yellow, cChatColor::White);
+ case mtLeave: return FormatChatPrefix(ShouldAppendChatPrefixes, "LEAVE", cChatColor::Yellow, cChatColor::White);
+ case mtPrivateMessage:
+ {
+ if (ShouldAppendChatPrefixes)
+ return Printf("%s[MSG: %s] %s%s", cChatColor::LightBlue.c_str(), a_AdditionalData.c_str(), cChatColor::White.c_str(), cChatColor::Italic.c_str());
+ else
+ return Printf("%s: %s", a_AdditionalData.c_str(), cChatColor::LightBlue.c_str());
+ }
+ }
+ ASSERT(!"Unhandled chat prefix type!");
+}
+
+
+
+
+
AString cClientHandle::GenerateOfflineUUID(const AString & a_Username)
{
// Proper format for a version 3 UUID is:
@@ -1849,7 +1889,7 @@ void cClientHandle::SendBlockChanges(int a_ChunkX, int a_ChunkZ, const sSetBlock
void cClientHandle::SendChat(const AString & a_Message, eMessageType a_ChatPrefix, const AString & a_AdditionalData)
{
bool ShouldAppendChatPrefixes = true;
-
+
if (GetPlayer()->GetWorld() == NULL)
{
cWorld * World = cRoot::Get()->GetWorld(GetPlayer()->GetLoadedWorldName());
@@ -1868,89 +1908,9 @@ void cClientHandle::SendChat(const AString & a_Message, eMessageType a_ChatPrefi
ShouldAppendChatPrefixes = false;
}
- AString Message;
-
- switch (a_ChatPrefix)
- {
- case mtCustom: break;
- case mtFailure:
- {
- if (ShouldAppendChatPrefixes)
- Message = Printf("%s[INFO] %s", cChatColor::Rose.c_str(), cChatColor::White.c_str());
- else
- Message = Printf("%s", cChatColor::Rose.c_str());
- break;
- }
- case mtInformation:
- {
- if (ShouldAppendChatPrefixes)
- Message = Printf("%s[INFO] %s", cChatColor::Yellow.c_str(), cChatColor::White.c_str());
- else
- Message = Printf("%s", cChatColor::Yellow.c_str());
- break;
- }
- case mtSuccess:
- {
- if (ShouldAppendChatPrefixes)
- Message = Printf("%s[INFO] %s", cChatColor::Green.c_str(), cChatColor::White.c_str());
- else
- Message = Printf("%s", cChatColor::Green.c_str());
- break;
- }
- case mtWarning:
- {
- if (ShouldAppendChatPrefixes)
- Message = Printf("%s[WARN] %s", cChatColor::Rose.c_str(), cChatColor::White.c_str());
- else
- Message = Printf("%s", cChatColor::Rose.c_str());
- break;
- }
- case mtFatal:
- {
- if (ShouldAppendChatPrefixes)
- Message = Printf("%s[FATAL] %s", cChatColor::Red.c_str(), cChatColor::White.c_str());
- else
- Message = Printf("%s", cChatColor::Red.c_str());
- break;
- }
- case mtDeath:
- {
- if (ShouldAppendChatPrefixes)
- Message = Printf("%s[DEATH] %s", cChatColor::Gray.c_str(), cChatColor::White.c_str());
- else
- Message = Printf("%s", cChatColor::Gray.c_str());
- break;
- }
- case mtPrivateMessage:
- {
- if (ShouldAppendChatPrefixes)
- Message = Printf("%s[MSG: %s] %s%s", cChatColor::LightBlue.c_str(), a_AdditionalData.c_str(), cChatColor::White.c_str(), cChatColor::Italic.c_str());
- else
- Message = Printf("%s: %s", a_AdditionalData.c_str(), cChatColor::LightBlue.c_str());
- break;
- }
- case mtJoin:
- {
- if (ShouldAppendChatPrefixes)
- Message = Printf("%s[JOIN] %s", cChatColor::Yellow.c_str(), cChatColor::White.c_str());
- else
- Message = Printf("%s", cChatColor::Yellow.c_str());
- break;
- }
- case mtLeave:
- {
- if (ShouldAppendChatPrefixes)
- Message = Printf("%s[LEAVE] %s", cChatColor::Yellow.c_str(), cChatColor::White.c_str());
- else
- Message = Printf("%s", cChatColor::Yellow.c_str());
- break;
- }
- default: ASSERT(!"Unhandled chat prefix type!"); return;
- }
-
- Message.append(a_Message);
+ AString Message = FormatMessageType(ShouldAppendChatPrefixes, a_ChatPrefix, a_AdditionalData);
- m_Protocol->SendChat(Message);
+ m_Protocol->SendChat(Message.append(a_Message));
}
diff --git a/src/ClientHandle.h b/src/ClientHandle.h
index 3d01d8034..9f8d44129 100644
--- a/src/ClientHandle.h
+++ b/src/ClientHandle.h
@@ -77,6 +77,11 @@ public:
This is used for the offline (non-auth) mode, when there's no UUID source.
Each username generates a unique and constant UUID, so that when the player reconnects with the same name, their UUID is the same. */
static AString GenerateOfflineUUID(const AString & a_Username); // tolua_export
+
+ /** Formats the type of message with the proper color and prefix for sending to the client. **/
+ AString FormatMessageType(bool ShouldAppendChatPrefixes, eMessageType a_ChatPrefix, const AString & a_AdditionalData);
+
+ AString FormatChatPrefix(bool ShouldAppendChatPrefixes, AString a_ChatPrefixS, AString m_Color1, AString m_Color2);
void Kick(const AString & a_Reason); // tolua_export
void Authenticate(const AString & a_Name, const AString & a_UUID); // Called by cAuthenticator when the user passes authentication
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index d0dd6fb50..7c8e18b51 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -410,11 +410,8 @@ int cEntity::GetRawDamageAgainst(const cEntity & a_Receiver)
-int cEntity::GetArmorCoverAgainst(const cEntity * a_Attacker, eDamageType a_DamageType, int a_Damage)
+bool cEntity::ArmorCoversAgainst(eDamageType a_DamageType)
{
- // Returns the hitpoints out of a_RawDamage that the currently equipped armor would cover
-
- // Filter out damage types that are not protected by armor:
// Ref.: http://www.minecraftwiki.net/wiki/Armor#Effects as of 2012_12_20
switch (a_DamageType)
{
@@ -429,9 +426,33 @@ int cEntity::GetArmorCoverAgainst(const cEntity * a_Attacker, eDamageType a_Dama
case dtLightning:
case dtPlugin:
{
- return 0;
+ return false;
+ }
+
+ case dtAttack:
+ case dtArrowAttack:
+ case dtCactusContact:
+ case dtLavaContact:
+ case dtFireContact:
+ case dtEnderPearl:
+ case dtExplosion:
+ {
+ return true;
}
}
+ ASSERT(!"Invalid damage type!");
+}
+
+
+
+
+
+int cEntity::GetArmorCoverAgainst(const cEntity * a_Attacker, eDamageType a_DamageType, int a_Damage)
+{
+ // Returns the hitpoints out of a_RawDamage that the currently equipped armor would cover
+
+ // Filter out damage types that are not protected by armor:
+ if (!ArmorCoversAgainst(a_DamageType)) return 0;
// Add up all armor points:
// Ref.: http://www.minecraftwiki.net/wiki/Armor#Defense_points as of 2012_12_20
diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h
index 86efc5a98..9b8011b55 100644
--- a/src/Entities/Entity.h
+++ b/src/Entities/Entity.h
@@ -270,6 +270,9 @@ public:
/// Returns the hitpoints that this pawn can deal to a_Receiver using its equipped items
virtual int GetRawDamageAgainst(const cEntity & a_Receiver);
+ /** Returns whether armor will protect against the passed damage type **/
+ virtual bool ArmorCoversAgainst(eDamageType a_DamageType);
+
/// Returns the hitpoints out of a_RawDamage that the currently equipped armor would cover
virtual int GetArmorCoverAgainst(const cEntity * a_Attacker, eDamageType a_DamageType, int a_RawDamage);
diff --git a/src/Entities/FallingBlock.cpp b/src/Entities/FallingBlock.cpp
index a66c7e4ae..bcdac0291 100644
--- a/src/Entities/FallingBlock.cpp
+++ b/src/Entities/FallingBlock.cpp
@@ -87,7 +87,9 @@ void cFallingBlock::Tick(float a_Dt, cChunk & a_Chunk)
AddSpeedY(MilliDt * -9.8f);
AddPosition(GetSpeed() * MilliDt);
- if ((GetSpeedX() != 0) || (GetSpeedZ() != 0))
+ // If not static (One billionth precision) broadcast movement.
+ static const float epsilon = 0.000000001;
+ if ((fabs(GetSpeedX()) > epsilon) || (fabs(GetSpeedZ()) > epsilon))
{
BroadcastMovementUpdate();
}
diff --git a/src/LineBlockTracer.cpp b/src/LineBlockTracer.cpp
index f4f29e833..b03652bab 100644
--- a/src/LineBlockTracer.cpp
+++ b/src/LineBlockTracer.cpp
@@ -171,7 +171,6 @@ bool cLineBlockTracer::MoveToNextBlock(void)
double CoeffZ = (DestZ - m_StartZ) / m_DiffZ;
if (CoeffZ < Coeff)
{
- Coeff = CoeffZ;
Direction = dirZ;
}
}
diff --git a/src/MCLogger.cpp b/src/MCLogger.cpp
index 80fa7b173..583438d65 100644
--- a/src/MCLogger.cpp
+++ b/src/MCLogger.cpp
@@ -9,7 +9,6 @@
cMCLogger * cMCLogger::s_MCLogger = NULL;
-bool g_ShouldColorOutput = false;
#ifdef _WIN32
#include <io.h> // Needed for _isatty(), not available on Linux
@@ -33,7 +32,8 @@ cMCLogger * cMCLogger::GetInstance(void)
-cMCLogger::cMCLogger(void)
+cMCLogger::cMCLogger(void):
+ m_ShouldColorOutput(false)
{
AString FileName;
Printf(FileName, "LOG_%d.txt", (int)time(NULL));
@@ -76,15 +76,15 @@ void cMCLogger::InitLog(const AString & a_FileName)
#ifdef _WIN32
// See whether we are writing to a console the default console attrib:
- g_ShouldColorOutput = (_isatty(_fileno(stdin)) != 0);
- if (g_ShouldColorOutput)
+ m_ShouldColorOutput = (_isatty(_fileno(stdin)) != 0);
+ if (m_ShouldColorOutput)
{
CONSOLE_SCREEN_BUFFER_INFO sbi;
GetConsoleScreenBufferInfo(g_Console, &sbi);
g_DefaultConsoleAttrib = sbi.wAttributes;
}
#elif defined (__linux) && !defined(ANDROID_NDK)
- g_ShouldColorOutput = isatty(fileno(stdout));
+ m_ShouldColorOutput = isatty(fileno(stdout));
// TODO: Check if the terminal supports colors, somehow?
#endif
}
@@ -178,7 +178,7 @@ void cMCLogger::Error(const char * a_Format, va_list a_ArgList)
void cMCLogger::SetColor(eColorScheme a_Scheme)
{
- if (!g_ShouldColorOutput)
+ if (!m_ShouldColorOutput)
{
return;
}
@@ -211,7 +211,7 @@ void cMCLogger::SetColor(eColorScheme a_Scheme)
void cMCLogger::ResetColor(void)
{
- if (!g_ShouldColorOutput)
+ if (!m_ShouldColorOutput)
{
return;
}
diff --git a/src/MCLogger.h b/src/MCLogger.h
index c0150c124..114210f63 100644
--- a/src/MCLogger.h
+++ b/src/MCLogger.h
@@ -52,6 +52,7 @@ private:
cCriticalSection m_CriticalSection;
cLog * m_Log;
static cMCLogger * s_MCLogger;
+ bool m_ShouldColorOutput;
/// Sets the specified color scheme in the terminal (TODO: if coloring available)
diff --git a/src/Mobs/AggressiveMonster.cpp b/src/Mobs/AggressiveMonster.cpp
index 0901f85a9..3e5f72dbf 100644
--- a/src/Mobs/AggressiveMonster.cpp
+++ b/src/Mobs/AggressiveMonster.cpp
@@ -37,7 +37,7 @@ void cAggressiveMonster::InStateChasing(float a_Dt)
}
}
- if (((float)m_FinalDestination.x != (float)m_Target->GetPosX()) || ((float)m_FinalDestination.z != (float)m_Target->GetPosZ()))
+ if (!IsMovingToTargetPosition())
{
MoveToPosition(m_Target->GetPosition());
}
@@ -106,3 +106,18 @@ void cAggressiveMonster::Attack(float a_Dt)
+bool cAggressiveMonster::IsMovingToTargetPosition()
+{
+ float epsilon = 0.000000000001;
+ // Difference between destination x and target x is negligible (to 10^-12 precision)
+ if (fabsf((float)m_FinalDestination.x - (float)m_Target->GetPosX()) < epsilon)
+ {
+ return false;
+ }
+ // Difference between destination z and target z is negligible (to 10^-12 precision)
+ else if (fabsf(m_FinalDestination.z - (float)m_Target->GetPosZ()) > epsilon)
+ {
+ return false;
+ }
+ return true;
+}
diff --git a/src/Mobs/AggressiveMonster.h b/src/Mobs/AggressiveMonster.h
index 152260f95..d70ff04a3 100644
--- a/src/Mobs/AggressiveMonster.h
+++ b/src/Mobs/AggressiveMonster.h
@@ -22,6 +22,10 @@ public:
virtual void EventSeePlayer(cEntity *) override;
virtual void Attack(float a_Dt);
+protected:
+ /** Whether this mob's destination is the same as its target's position. */
+ bool IsMovingToTargetPosition();
+
} ;
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index eb8480268..14d951393 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -761,8 +761,10 @@ cMonster::eFamily cMonster::FamilyFromType(eType a_Type)
case mtChicken: return mfPassive;
case mtCow: return mfPassive;
case mtCreeper: return mfHostile;
+ case mtEnderDragon: return mfNoSpawn;
case mtEnderman: return mfHostile;
case mtGhast: return mfHostile;
+ case mtGiant: return mfNoSpawn;
case mtHorse: return mfPassive;
case mtIronGolem: return mfPassive;
case mtMagmaCube: return mfHostile;
@@ -773,17 +775,20 @@ cMonster::eFamily cMonster::FamilyFromType(eType a_Type)
case mtSilverfish: return mfHostile;
case mtSkeleton: return mfHostile;
case mtSlime: return mfHostile;
+ case mtSnowGolem: return mfNoSpawn;
case mtSpider: return mfHostile;
case mtSquid: return mfWater;
case mtVillager: return mfPassive;
case mtWitch: return mfHostile;
- case mtWither: return mfHostile;
+ case mtWither: return mfNoSpawn;
case mtWolf: return mfHostile;
case mtZombie: return mfHostile;
case mtZombiePigman: return mfHostile;
- } ;
+
+ case mtInvalidType: break;
+ }
ASSERT(!"Unhandled mob type");
- return mfMaxplusone;
+ return mfUnhandled;
}
@@ -794,10 +799,12 @@ int cMonster::GetSpawnDelay(cMonster::eFamily a_MobFamily)
{
switch (a_MobFamily)
{
- case mfHostile: return 40;
- case mfPassive: return 40;
- case mfAmbient: return 40;
- case mfWater: return 400;
+ case mfHostile: return 40;
+ case mfPassive: return 40;
+ case mfAmbient: return 40;
+ case mfWater: return 400;
+ case mfNoSpawn: return -1;
+ case mfUnhandled: break;
}
ASSERT(!"Unhandled mob family");
return -1;
@@ -866,6 +873,7 @@ cMonster * cMonster::NewMonsterFromType(cMonster::eType a_MobType)
case mtEnderDragon: toReturn = new cEnderDragon(); break;
case mtEnderman: toReturn = new cEnderman(); break;
case mtGhast: toReturn = new cGhast(); break;
+ case mtGiant: toReturn = new cGiant(); break;
case mtIronGolem: toReturn = new cIronGolem(); break;
case mtMooshroom: toReturn = new cMooshroom(); break;
case mtOcelot: toReturn = new cOcelot(); break;
diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h
index 70b3783fc..6b9c4fab8 100644
--- a/src/Mobs/Monster.h
+++ b/src/Mobs/Monster.h
@@ -66,7 +66,8 @@ public:
mfAmbient = 2, // Bats
mfWater = 3, // Squid
- mfMaxplusone, // Nothing. Be sure this is the last and the others are in order
+ mfNoSpawn,
+ mfUnhandled, // Nothing. Be sure this is the last and the others are in order
} ;
// tolua_end
diff --git a/src/OSSupport/File.cpp b/src/OSSupport/File.cpp
index 7f0f0ad2f..f1b3bcf9e 100644
--- a/src/OSSupport/File.cpp
+++ b/src/OSSupport/File.cpp
@@ -67,11 +67,11 @@ bool cFile::Open(const AString & iFileName, eMode iMode)
case fmRead: Mode = "rb"; break;
case fmWrite: Mode = "wb"; break;
case fmReadWrite: Mode = "rb+"; break;
- default:
- {
- ASSERT(!"Unhandled file mode");
- return false;
- }
+ }
+ if (Mode == NULL)
+ {
+ ASSERT(!"Unhandled file mode");
+ return false;
}
#ifdef _WIN32
diff --git a/src/World.cpp b/src/World.cpp
index 25ac9b021..5ac8e0a6e 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -316,12 +316,9 @@ int cWorld::GetDefaultWeatherInterval(eWeather a_Weather)
{
return 2400 + (m_TickRand.randInt() % 4800); // 2 - 6 minutes
}
- default:
- {
- LOGWARNING("%s: Missing default weather interval for weather %d.", __FUNCTION__, a_Weather);
- return -1;
- }
- } // switch (Weather)
+ }
+ LOGWARNING("%s: Missing default weather interval for weather %d.", __FUNCTION__, a_Weather);
+ return -1;
}
@@ -521,21 +518,6 @@ void cWorld::Start(void)
}
AString Dimension = IniFile.GetValueSet("General", "Dimension", "Overworld");
m_Dimension = StringToDimension(Dimension);
- switch (m_Dimension)
- {
- case dimNether:
- case dimOverworld:
- case dimEnd:
- {
- break;
- }
- default:
- {
- LOGWARNING("Unknown dimension: \"%s\". Setting to Overworld", Dimension.c_str());
- m_Dimension = dimOverworld;
- break;
- }
- } // switch (m_Dimension)
// Try to find the "SpawnPosition" key and coord values in the world configuration, set the flag if found
int KeyNum = IniFile.FindKey("SpawnPosition");
@@ -592,12 +574,6 @@ void cWorld::Start(void)
case dimOverworld: DefaultMonsters = "bat, cavespider, chicken, cow, creeper, enderman, horse, mooshroom, ocelot, pig, sheep, silverfish, skeleton, slime, spider, squid, wolf, zombie"; break;
case dimNether: DefaultMonsters = "blaze, ghast, magmacube, skeleton, zombie, zombiepigman"; break;
case dimEnd: DefaultMonsters = "enderman"; break;
- default:
- {
- ASSERT(!"Unhandled world dimension");
- DefaultMonsters = "wither";
- break;
- }
}
m_bAnimals = IniFile.GetValueSetB("Monsters", "AnimalsOn", true);
AString AllMonsters = IniFile.GetValueSet("Monsters", "Types", DefaultMonsters);
@@ -687,6 +663,30 @@ void cWorld::GenerateRandomSpawn(void)
+eWeather cWorld::ChooseNewWeather()
+{
+ // Pick a new weather. Only reasonable transitions allowed:
+ switch (m_Weather)
+ {
+ case eWeather_Sunny:
+ case eWeather_ThunderStorm: return eWeather_Rain;
+
+ case eWeather_Rain:
+ {
+ // 1/8 chance of turning into a thunderstorm
+ return ((m_TickRand.randInt() % 256) < 32) ? eWeather_ThunderStorm : eWeather_Sunny;
+ }
+ }
+
+ LOGWARNING("Unknown current weather: %d. Setting sunny.", m_Weather);
+ ASSERT(!"Unknown weather");
+ return eWeather_Sunny;
+}
+
+
+
+
+
void cWorld::Stop(void)
{
// Delete the clients that have been in this world:
@@ -786,30 +786,8 @@ void cWorld::TickWeather(float a_Dt)
else
{
// Change weather:
-
- // Pick a new weather. Only reasonable transitions allowed:
- eWeather NewWeather = m_Weather;
- switch (m_Weather)
- {
- case eWeather_Sunny: NewWeather = eWeather_Rain; break;
- case eWeather_ThunderStorm: NewWeather = eWeather_Rain; break;
- case eWeather_Rain:
- {
- // 1/8 chance of turning into a thunderstorm
- NewWeather = ((m_TickRand.randInt() % 256) < 32) ? eWeather_ThunderStorm : eWeather_Sunny;
- break;
- }
-
- default:
- {
- LOGWARNING("Unknown current weather: %d. Setting sunny.", m_Weather);
- ASSERT(!"Unknown weather");
- NewWeather = eWeather_Sunny;
- }
- }
-
- SetWeather(NewWeather);
- } // else (m_WeatherInterval > 0)
+ SetWeather(ChooseNewWeather());
+ }
if (m_Weather == eWeather_ThunderStorm)
{
diff --git a/src/World.h b/src/World.h
index e2be4cd35..f789916df 100644
--- a/src/World.h
+++ b/src/World.h
@@ -938,7 +938,10 @@ private:
/** <summary>Generates a random spawnpoint on solid land by walking chunks and finding their biomes</summary> */
void GenerateRandomSpawn(void);
-
+
+ /** Chooses a reasonable transition from the current weather to a new weather **/
+ eWeather ChooseNewWeather(void);
+
/** Creates a new fluid simulator, loads its settings from the inifile (a_FluidName section) */
cFluidSimulator * InitializeFluidSimulator(cIniFile & a_IniFile, const char * a_FluidName, BLOCKTYPE a_SimulateBlock, BLOCKTYPE a_StationaryBlock);
diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp
index b6c14db9c..773954f73 100644
--- a/src/WorldStorage/NBTChunkSerializer.cpp
+++ b/src/WorldStorage/NBTChunkSerializer.cpp
@@ -621,10 +621,10 @@ void cNBTChunkSerializer::AddHangingEntity(cHangingEntity * a_Hanging)
m_Writer.AddInt("TileZ", a_Hanging->GetTileZ());
switch (a_Hanging->GetDirection())
{
- case 0: m_Writer.AddByte("Dir", (unsigned char)2); break;
- case 1: m_Writer.AddByte("Dir", (unsigned char)1); break;
- case 2: m_Writer.AddByte("Dir", (unsigned char)0); break;
- case 3: m_Writer.AddByte("Dir", (unsigned char)3); break;
+ case BLOCK_FACE_YM: m_Writer.AddByte("Dir", (unsigned char)2); break;
+ case BLOCK_FACE_YP: m_Writer.AddByte("Dir", (unsigned char)1); break;
+ case BLOCK_FACE_ZM: m_Writer.AddByte("Dir", (unsigned char)0); break;
+ case BLOCK_FACE_ZP: m_Writer.AddByte("Dir", (unsigned char)3); break;
}
}
diff --git a/src/WorldStorage/WSSCompact.cpp b/src/WorldStorage/WSSCompact.cpp
index 5435e6d5a..c07c9e96f 100644
--- a/src/WorldStorage/WSSCompact.cpp
+++ b/src/WorldStorage/WSSCompact.cpp
@@ -797,7 +797,6 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3()
++index2;
}
InChunkOffset += index2 / 2;
- index2 = 0;
AString Converted(ConvertedData, ExpectedSize);