summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Bindings/AllToLua.pkg1
-rw-r--r--src/Bindings/ManualBindings.cpp5
-rw-r--r--src/BlockEntities/JukeboxEntity.h5
-rw-r--r--src/Blocks/ChunkInterface.h31
-rw-r--r--src/Entities/Painting.cpp11
-rw-r--r--src/Entities/Painting.h2
-rw-r--r--src/Entities/Player.cpp39
-rw-r--r--src/Generating/Caves.cpp6
-rw-r--r--src/Generating/Caves.h16
-rw-r--r--src/Generating/ChunkDesc.cpp2
-rw-r--r--src/Generating/ComposableGenerator.cpp157
-rw-r--r--src/Generating/ComposableGenerator.h56
-rw-r--r--src/Generating/MineShafts.cpp2
-rw-r--r--src/Generating/MineShafts.h6
-rw-r--r--src/Generating/Ravines.cpp2
-rw-r--r--src/Generating/Ravines.h6
-rw-r--r--src/Generating/StructGen.cpp10
-rw-r--r--src/Generating/StructGen.h30
-rw-r--r--src/GroupManager.cpp21
-rw-r--r--src/GroupManager.h3
-rw-r--r--src/HTTPServer/HTTPServer.cpp4
-rw-r--r--src/Items/ItemHandler.cpp26
-rw-r--r--src/OSSupport/BlockingTCPLink.cpp4
-rw-r--r--src/Scoreboard.cpp135
-rw-r--r--src/Scoreboard.h131
-rw-r--r--src/UI/SlotArea.cpp30
-rw-r--r--src/UI/SlotArea.h6
-rw-r--r--src/WorldStorage/FastNBT.h52
-rw-r--r--src/WorldStorage/ScoreboardSerializer.cpp14
29 files changed, 510 insertions, 303 deletions
diff --git a/src/Bindings/AllToLua.pkg b/src/Bindings/AllToLua.pkg
index 6537437cd..1a2140771 100644
--- a/src/Bindings/AllToLua.pkg
+++ b/src/Bindings/AllToLua.pkg
@@ -75,6 +75,7 @@ $cfile "../Mobs/Monster.h"
$cfile "../CompositeChat.h"
$cfile "../Map.h"
$cfile "../MapManager.h"
+$cfile "../Scoreboard.h"
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp
index 461186d3b..fcdd728be 100644
--- a/src/Bindings/ManualBindings.cpp
+++ b/src/Bindings/ManualBindings.cpp
@@ -2583,6 +2583,11 @@ void ManualBindings::Bind(lua_State * tolua_S)
tolua_beginmodule(tolua_S, "cMapManager");
tolua_function(tolua_S, "DoWithMap", tolua_DoWithID<cMapManager, cMap, &cMapManager::DoWithMap>);
tolua_endmodule(tolua_S);
+
+ tolua_beginmodule(tolua_S, "cScoreboard");
+ tolua_function(tolua_S, "ForEachObjective", tolua_ForEach<cScoreboard, cObjective, &cScoreboard::ForEachObjective>);
+ tolua_function(tolua_S, "ForEachTeam", tolua_ForEach<cScoreboard, cTeam, &cScoreboard::ForEachTeam>);
+ tolua_endmodule(tolua_S);
tolua_beginmodule(tolua_S, "cPlugin");
tolua_function(tolua_S, "Call", tolua_cPlugin_Call);
diff --git a/src/BlockEntities/JukeboxEntity.h b/src/BlockEntities/JukeboxEntity.h
index 01ce52494..3d1d604f7 100644
--- a/src/BlockEntities/JukeboxEntity.h
+++ b/src/BlockEntities/JukeboxEntity.h
@@ -38,10 +38,11 @@ public:
int GetRecord(void);
void SetRecord(int a_Record);
- /** Play a Record. Return false, when a_Record isn't a Record */
+ /** Plays the specified Record. Return false if a_Record isn't a playable Record (E_ITEM_XXX_DISC).
+ If there is a record already playing, ejects it first. */
bool PlayRecord(int a_Record);
- /** Ejects the currently held record as a pickup. Return false when no record inserted. */
+ /** Ejects the currently held record as a pickup. Return false when no record had been inserted. */
bool EjectRecord(void);
/** Is in the Jukebox a Record? */
diff --git a/src/Blocks/ChunkInterface.h b/src/Blocks/ChunkInterface.h
index b30eff1e4..be7c2e0e5 100644
--- a/src/Blocks/ChunkInterface.h
+++ b/src/Blocks/ChunkInterface.h
@@ -5,31 +5,35 @@
#include "../ForEachChunkProvider.h"
#include "WorldInterface.h"
-class cBlockHandler;
-class cChunkInterface : public cForEachChunkProvider
+
+
+
+class cChunkInterface:
+ public cForEachChunkProvider
{
public:
cChunkInterface(cChunkMap * a_ChunkMap) : m_ChunkMap(a_ChunkMap) {}
- BLOCKTYPE GetBlock (int a_BlockX, int a_BlockY, int a_BlockZ)
+ BLOCKTYPE GetBlock(int a_BlockX, int a_BlockY, int a_BlockZ)
{
return m_ChunkMap->GetBlock(a_BlockX,a_BlockY,a_BlockZ);
}
- BLOCKTYPE GetBlock (const Vector3i & a_Pos )
+ BLOCKTYPE GetBlock(const Vector3i & a_Pos)
{
- return GetBlock( a_Pos.x, a_Pos.y, a_Pos.z );
+ return GetBlock(a_Pos.x, a_Pos.y, a_Pos.z);
}
- NIBBLETYPE GetBlockMeta (int a_BlockX, int a_BlockY, int a_BlockZ)
+ NIBBLETYPE GetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ)
{
return m_ChunkMap->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
}
- bool GetBlockTypeMeta (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta)
+ bool GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta)
{
return m_ChunkMap->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
}
+
/** Sets the block at the specified coords to the specified value.
Full processing, incl. updating neighbors, is performed.
*/
@@ -37,7 +41,8 @@ public:
{
m_ChunkMap->SetBlock(a_WorldInterface, a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
}
- void SetBlockMeta (int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_MetaData)
+
+ void SetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_MetaData)
{
m_ChunkMap->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, a_MetaData);
}
@@ -55,7 +60,11 @@ public:
{
m_ChunkMap->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
}
- void FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ) { FastSetBlock( a_Pos.x, a_Pos.y, a_Pos.z, a_BlockType, a_BlockMeta ); }
+
+ void FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta )
+ {
+ FastSetBlock( a_Pos.x, a_Pos.y, a_Pos.z, a_BlockType, a_BlockMeta );
+ }
void UseBlockEntity(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
{
@@ -77,3 +86,7 @@ public:
private:
cChunkMap * m_ChunkMap;
};
+
+
+
+
diff --git a/src/Entities/Painting.cpp b/src/Entities/Painting.cpp
index b98c1e67a..e217556c7 100644
--- a/src/Entities/Painting.cpp
+++ b/src/Entities/Painting.cpp
@@ -4,6 +4,7 @@
#include "Painting.h"
#include "ClientHandle.h"
#include "Player.h"
+#include "../Chunk.h"
@@ -30,6 +31,16 @@ void cPainting::SpawnOn(cClientHandle & a_Client)
+void cPainting::Tick(float a_Dt, cChunk & a_Chunk)
+{
+ UNUSED(a_Dt);
+ UNUSED(a_Chunk);
+}
+
+
+
+
+
void cPainting::GetDrops(cItems & a_Items, cEntity * a_Killer)
{
if ((a_Killer != NULL) && a_Killer->IsPlayer() && !((cPlayer *)a_Killer)->IsGameModeCreative())
diff --git a/src/Entities/Painting.h b/src/Entities/Painting.h
index 95afbed1e..c1024bd1b 100644
--- a/src/Entities/Painting.h
+++ b/src/Entities/Painting.h
@@ -24,7 +24,7 @@ public:
private:
virtual void SpawnOn(cClientHandle & a_Client) override;
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override {};
+ virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void GetDrops(cItems & a_Items, cEntity * a_Killer) override;
virtual void KilledBy(cEntity * a_Killer) override
{
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index e0f0b9222..8f94f1feb 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -858,6 +858,8 @@ void cPlayer::KilledBy(cEntity * a_Killer)
else if (a_Killer->IsPlayer())
{
GetWorld()->BroadcastChatDeath(Printf("%s was killed by %s", GetName().c_str(), ((cPlayer *)a_Killer)->GetName().c_str()));
+
+ m_World->GetScoreBoard().AddPlayerScore(((cPlayer *)a_Killer)->GetName(), cObjective::otPlayerKillCount, 1);
}
else
{
@@ -867,24 +869,7 @@ void cPlayer::KilledBy(cEntity * a_Killer)
GetWorld()->BroadcastChatDeath(Printf("%s was killed by a %s", GetName().c_str(), KillerClass.c_str()));
}
- class cIncrementCounterCB
- : public cObjectiveCallback
- {
- AString m_Name;
- public:
- cIncrementCounterCB(const AString & a_Name) : m_Name(a_Name) {}
-
- virtual bool Item(cObjective * a_Objective) override
- {
- a_Objective->AddScore(m_Name, 1);
- return true;
- }
- } IncrementCounter (GetName());
-
- cScoreboard & Scoreboard = m_World->GetScoreBoard();
-
- // Update scoreboard objectives
- Scoreboard.ForEachObjectiveWith(cObjective::E_TYPE_DEATH_COUNT, IncrementCounter);
+ m_World->GetScoreBoard().AddPlayerScore(GetName(), cObjective::otDeathCount, 1);
}
@@ -1529,14 +1514,14 @@ void cPlayer::LoadPermissionsFromDisk()
std::string Groups = IniFile.GetValue(m_PlayerName, "Groups", "");
if (!Groups.empty())
{
- AStringVector Split = StringSplit( Groups, "," );
- for( unsigned int i = 0; i < Split.size(); i++ )
+ AStringVector Split = StringSplitAndTrim(Groups, ",");
+ for (AStringVector::const_iterator itr = Split.begin(), end = Split.end(); itr != end; ++itr)
{
- if (!cRoot::Get()->GetGroupManager()->ExistsGroup(Split[i]))
+ if (!cRoot::Get()->GetGroupManager()->ExistsGroup(*itr))
{
- LOGWARNING("The group %s for player %s was not found!", Split[i].c_str(), m_PlayerName.c_str());
+ LOGWARNING("The group %s for player %s was not found!", itr->c_str(), m_PlayerName.c_str());
}
- AddToGroup(Split[i].c_str());
+ AddToGroup(*itr);
}
}
else
@@ -1544,11 +1529,15 @@ void cPlayer::LoadPermissionsFromDisk()
AddToGroup("Default");
}
- m_Color = IniFile.GetValue(m_PlayerName, "Color", "-")[0];
+ AString Color = IniFile.GetValue(m_PlayerName, "Color", "-");
+ if (!Color.empty())
+ {
+ m_Color = Color[0];
+ }
}
else
{
- cRoot::Get()->GetGroupManager()->CheckUsers();
+ cGroupManager::GenerateDefaultUsersIni(IniFile);
AddToGroup("Default");
}
ResolvePermissions();
diff --git a/src/Generating/Caves.cpp b/src/Generating/Caves.cpp
index 2571e6b77..98b7c8681 100644
--- a/src/Generating/Caves.cpp
+++ b/src/Generating/Caves.cpp
@@ -762,7 +762,7 @@ void cStructGenWormNestCaves::ClearCache(void)
-void cStructGenWormNestCaves::GenStructures(cChunkDesc & a_ChunkDesc)
+void cStructGenWormNestCaves::GenFinish(cChunkDesc & a_ChunkDesc)
{
int ChunkX = a_ChunkDesc.GetChunkX();
int ChunkZ = a_ChunkDesc.GetChunkZ();
@@ -902,7 +902,7 @@ static float GetMarbleNoise( float x, float y, float z, cNoise & a_Noise )
-void cStructGenMarbleCaves::GenStructures(cChunkDesc & a_ChunkDesc)
+void cStructGenMarbleCaves::GenFinish(cChunkDesc & a_ChunkDesc)
{
cNoise Noise(m_Seed);
for (int z = 0; z < cChunkDef::Width; z++)
@@ -938,7 +938,7 @@ void cStructGenMarbleCaves::GenStructures(cChunkDesc & a_ChunkDesc)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cStructGenDualRidgeCaves:
-void cStructGenDualRidgeCaves::GenStructures(cChunkDesc & a_ChunkDesc)
+void cStructGenDualRidgeCaves::GenFinish(cChunkDesc & a_ChunkDesc)
{
for (int z = 0; z < cChunkDef::Width; z++)
{
diff --git a/src/Generating/Caves.h b/src/Generating/Caves.h
index ea7f10bf4..7c45c056b 100644
--- a/src/Generating/Caves.h
+++ b/src/Generating/Caves.h
@@ -20,7 +20,7 @@
class cStructGenMarbleCaves :
- public cStructureGen
+ public cFinishGen
{
public:
cStructGenMarbleCaves(int a_Seed) : m_Seed(a_Seed) {}
@@ -29,8 +29,8 @@ protected:
int m_Seed;
- // cStructureGen override:
- virtual void GenStructures(cChunkDesc & a_ChunkDesc) override;
+ // cFinishGen override:
+ virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
} ;
@@ -38,7 +38,7 @@ protected:
class cStructGenDualRidgeCaves :
- public cStructureGen
+ public cFinishGen
{
public:
cStructGenDualRidgeCaves(int a_Seed, float a_Threshold) :
@@ -55,8 +55,8 @@ protected:
int m_Seed;
float m_Threshold;
- // cStructureGen override:
- virtual void GenStructures(cChunkDesc & a_ChunkDesc) override;
+ // cFinishGen override:
+ virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
} ;
@@ -64,7 +64,7 @@ protected:
class cStructGenWormNestCaves :
- public cStructureGen
+ public cFinishGen
{
public:
cStructGenWormNestCaves(int a_Seed, int a_Size = 64, int a_Grid = 96, int a_MaxOffset = 128) :
@@ -94,7 +94,7 @@ protected:
void GetCavesForChunk(int a_ChunkX, int a_ChunkZ, cCaveSystems & a_Caves);
// cStructGen override:
- virtual void GenStructures(cChunkDesc & a_ChunkDesc) override;
+ virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
} ;
diff --git a/src/Generating/ChunkDesc.cpp b/src/Generating/ChunkDesc.cpp
index d9529b4b0..308fbe423 100644
--- a/src/Generating/ChunkDesc.cpp
+++ b/src/Generating/ChunkDesc.cpp
@@ -209,6 +209,7 @@ bool cChunkDesc::IsUsingDefaultComposition(void) const
void cChunkDesc::SetUseDefaultStructures(bool a_bUseDefaultStructures)
{
+ LOGWARNING("%s: Structures are no longer accounted for, use Finishers instead", __FUNCTION__);
m_bUseDefaultStructures = a_bUseDefaultStructures;
}
@@ -218,6 +219,7 @@ void cChunkDesc::SetUseDefaultStructures(bool a_bUseDefaultStructures)
bool cChunkDesc::IsUsingDefaultStructures(void) const
{
+ LOGWARNING("%s: Structures are no longer accounted for, use Finishers instead", __FUNCTION__);
return m_bUseDefaultStructures;
}
diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp
index cfa7e9c6f..e96e9a645 100644
--- a/src/Generating/ComposableGenerator.cpp
+++ b/src/Generating/ComposableGenerator.cpp
@@ -133,11 +133,6 @@ cComposableGenerator::~cComposableGenerator()
delete *itr;
}
m_FinishGens.clear();
- for (cStructureGenList::const_iterator itr = m_StructureGens.begin(); itr != m_StructureGens.end(); ++itr)
- {
- delete *itr;
- }
- m_StructureGens.clear();
delete m_CompositionGen;
m_CompositionGen = NULL;
@@ -164,7 +159,6 @@ void cComposableGenerator::Initialize(cIniFile & a_IniFile)
InitBiomeGen(a_IniFile);
InitHeightGen(a_IniFile);
InitCompositionGen(a_IniFile);
- InitStructureGens(a_IniFile);
InitFinishGens(a_IniFile);
}
@@ -201,14 +195,6 @@ void cComposableGenerator::DoGenerate(int a_ChunkX, int a_ChunkZ, cChunkDesc & a
m_CompositionGen->ComposeTerrain(a_ChunkDesc);
}
- if (a_ChunkDesc.IsUsingDefaultStructures())
- {
- for (cStructureGenList::iterator itr = m_StructureGens.begin(); itr != m_StructureGens.end(); ++itr)
- {
- (*itr)->GenStructures(a_ChunkDesc);
- } // for itr - m_StructureGens[]
- }
-
if (a_ChunkDesc.IsUsingDefaultFinish())
{
for (cFinishGenList::iterator itr = m_FinishGens.begin(); itr != m_FinishGens.end(); ++itr)
@@ -290,35 +276,69 @@ void cComposableGenerator::InitCompositionGen(cIniFile & a_IniFile)
-void cComposableGenerator::InitStructureGens(cIniFile & a_IniFile)
+void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile)
{
- AString Structures = a_IniFile.GetValueSet("Generator", "Structures", "Ravines, WormNestCaves, WaterLakes, LavaLakes, OreNests, Trees");
-
int Seed = m_ChunkGenerator.GetSeed();
- AStringVector Str = StringSplitAndTrim(Structures, ",");
+ eDimension Dimension = StringToDimension(a_IniFile.GetValue("General", "Dimension", "Overworld"));
+
+ // Older configuration used "Structures" in addition to "Finishers"; we don't distinguish between the two anymore (#398)
+ // Therefore, we load Structures from the ini file for compatibility, but move its contents over to Finishers:
+ AString Structures = a_IniFile.GetValue("Generator", "Structures", "");
+ AString Finishers = a_IniFile.GetValueSet("Generator", "Finishers", "Ravines, WormNestCaves, WaterLakes, LavaLakes, OreNests, Trees, SprinkleFoliage, Ice, Snow, Lilypads, BottomLava, DeadBushes, PreSimulator");
+ if (!Structures.empty())
+ {
+ LOGINFO("[Generator].Structures is deprecated, moving the contents to [Generator].Finishers.");
+ // Structures used to generate before Finishers, so place them first:
+ Structures.append(", ");
+ Finishers = Structures + Finishers;
+ a_IniFile.SetValue("Generator", "Finishers", Finishers);
+ }
+ a_IniFile.DeleteValue("Generator", "Structures");
+
+ // Create all requested finishers:
+ AStringVector Str = StringSplitAndTrim(Finishers, ",");
for (AStringVector::const_iterator itr = Str.begin(); itr != Str.end(); ++itr)
{
- if (NoCaseCompare(*itr, "DualRidgeCaves") == 0)
+ // Finishers, alpha-sorted:
+ if (NoCaseCompare(*itr, "BottomLava") == 0)
{
- float Threshold = (float)a_IniFile.GetValueSetF("Generator", "DualRidgeCavesThreshold", 0.3);
- m_StructureGens.push_back(new cStructGenDualRidgeCaves(Seed, Threshold));
+ int DefaultBottomLavaLevel = (Dimension == dimNether) ? 30 : 10;
+ int BottomLavaLevel = a_IniFile.GetValueSetI("Generator", "BottomLavaLevel", DefaultBottomLavaLevel);
+ m_FinishGens.push_back(new cFinishGenBottomLava(BottomLavaLevel));
+ }
+ else if (NoCaseCompare(*itr, "DeadBushes") == 0)
+ {
+ m_FinishGens.push_back(new cFinishGenSingleBiomeSingleTopBlock(Seed, E_BLOCK_DEAD_BUSH, biDesert, 2, E_BLOCK_SAND, E_BLOCK_SAND));
}
else if (NoCaseCompare(*itr, "DirectOverhangs") == 0)
{
- m_StructureGens.push_back(new cStructGenDirectOverhangs(Seed));
+ m_FinishGens.push_back(new cStructGenDirectOverhangs(Seed));
}
else if (NoCaseCompare(*itr, "DistortedMembraneOverhangs") == 0)
{
- m_StructureGens.push_back(new cStructGenDistortedMembraneOverhangs(Seed));
+ m_FinishGens.push_back(new cStructGenDistortedMembraneOverhangs(Seed));
+ }
+ else if (NoCaseCompare(*itr, "DualRidgeCaves") == 0)
+ {
+ float Threshold = (float)a_IniFile.GetValueSetF("Generator", "DualRidgeCavesThreshold", 0.3);
+ m_FinishGens.push_back(new cStructGenDualRidgeCaves(Seed, Threshold));
+ }
+ else if (NoCaseCompare(*itr, "Ice") == 0)
+ {
+ m_FinishGens.push_back(new cFinishGenIce);
}
else if (NoCaseCompare(*itr, "LavaLakes") == 0)
{
int Probability = a_IniFile.GetValueSetI("Generator", "LavaLakesProbability", 10);
- m_StructureGens.push_back(new cStructGenLakes(Seed * 5 + 16873, E_BLOCK_STATIONARY_LAVA, *m_HeightGen, Probability));
+ m_FinishGens.push_back(new cStructGenLakes(Seed * 5 + 16873, E_BLOCK_STATIONARY_LAVA, *m_HeightGen, Probability));
+ }
+ else if (NoCaseCompare(*itr, "LavaSprings") == 0)
+ {
+ m_FinishGens.push_back(new cFinishGenFluidSprings(Seed, E_BLOCK_LAVA, a_IniFile, Dimension));
}
else if (NoCaseCompare(*itr, "MarbleCaves") == 0)
{
- m_StructureGens.push_back(new cStructGenMarbleCaves(Seed));
+ m_FinishGens.push_back(new cStructGenMarbleCaves(Seed));
}
else if (NoCaseCompare(*itr, "MineShafts") == 0)
{
@@ -327,71 +347,11 @@ void cComposableGenerator::InitStructureGens(cIniFile & a_IniFile)
int ChanceCorridor = a_IniFile.GetValueSetI("Generator", "MineShaftsChanceCorridor", 600);
int ChanceCrossing = a_IniFile.GetValueSetI("Generator", "MineShaftsChanceCrossing", 200);
int ChanceStaircase = a_IniFile.GetValueSetI("Generator", "MineShaftsChanceStaircase", 200);
- m_StructureGens.push_back(new cStructGenMineShafts(
+ m_FinishGens.push_back(new cStructGenMineShafts(
Seed, GridSize, MaxSystemSize,
ChanceCorridor, ChanceCrossing, ChanceStaircase
));
}
- else if (NoCaseCompare(*itr, "OreNests") == 0)
- {
- m_StructureGens.push_back(new cStructGenOreNests(Seed));
- }
- else if (NoCaseCompare(*itr, "Ravines") == 0)
- {
- m_StructureGens.push_back(new cStructGenRavines(Seed, 128));
- }
- else if (NoCaseCompare(*itr, "Trees") == 0)
- {
- m_StructureGens.push_back(new cStructGenTrees(Seed, m_BiomeGen, m_HeightGen, m_CompositionGen));
- }
- else if (NoCaseCompare(*itr, "WaterLakes") == 0)
- {
- int Probability = a_IniFile.GetValueSetI("Generator", "WaterLakesProbability", 25);
- m_StructureGens.push_back(new cStructGenLakes(Seed * 3 + 652, E_BLOCK_STATIONARY_WATER, *m_HeightGen, Probability));
- }
- else if (NoCaseCompare(*itr, "WormNestCaves") == 0)
- {
- m_StructureGens.push_back(new cStructGenWormNestCaves(Seed));
- }
- else
- {
- LOGWARNING("Unknown structure generator: \"%s\". Ignoring.", itr->c_str());
- }
- } // for itr - Str[]
-}
-
-
-
-
-
-void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile)
-{
- int Seed = m_ChunkGenerator.GetSeed();
- eDimension Dimension = StringToDimension(a_IniFile.GetValue("General", "Dimension", "Overworld"));
-
- AString Finishers = a_IniFile.GetValueSet("Generator", "Finishers", "SprinkleFoliage,Ice,Snow,Lilypads,BottomLava,DeadBushes,PreSimulator");
- AStringVector Str = StringSplitAndTrim(Finishers, ",");
- for (AStringVector::const_iterator itr = Str.begin(); itr != Str.end(); ++itr)
- {
- // Finishers, alpha-sorted:
- if (NoCaseCompare(*itr, "BottomLava") == 0)
- {
- int DefaultBottomLavaLevel = (Dimension == dimNether) ? 30 : 10;
- int BottomLavaLevel = a_IniFile.GetValueSetI("Generator", "BottomLavaLevel", DefaultBottomLavaLevel);
- m_FinishGens.push_back(new cFinishGenBottomLava(BottomLavaLevel));
- }
- else if (NoCaseCompare(*itr, "DeadBushes") == 0)
- {
- m_FinishGens.push_back(new cFinishGenSingleBiomeSingleTopBlock(Seed, E_BLOCK_DEAD_BUSH, biDesert, 2, E_BLOCK_SAND, E_BLOCK_SAND));
- }
- else if (NoCaseCompare(*itr, "Ice") == 0)
- {
- m_FinishGens.push_back(new cFinishGenIce);
- }
- else if (NoCaseCompare(*itr, "LavaSprings") == 0)
- {
- m_FinishGens.push_back(new cFinishGenFluidSprings(Seed, E_BLOCK_LAVA, a_IniFile, Dimension));
- }
else if (NoCaseCompare(*itr, "Lilypads") == 0)
{
m_FinishGens.push_back(new cFinishGenSingleBiomeSingleTopBlock(Seed, E_BLOCK_LILY_PAD, biSwampland, 4, E_BLOCK_WATER, E_BLOCK_STATIONARY_WATER));
@@ -400,10 +360,18 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile)
{
m_FinishGens.push_back(new cFinishGenNetherClumpFoliage(Seed));
}
+ else if (NoCaseCompare(*itr, "OreNests") == 0)
+ {
+ m_FinishGens.push_back(new cStructGenOreNests(Seed));
+ }
else if (NoCaseCompare(*itr, "PreSimulator") == 0)
{
m_FinishGens.push_back(new cFinishGenPreSimulator);
}
+ else if (NoCaseCompare(*itr, "Ravines") == 0)
+ {
+ m_FinishGens.push_back(new cStructGenRavines(Seed, 128));
+ }
else if (NoCaseCompare(*itr, "Snow") == 0)
{
m_FinishGens.push_back(new cFinishGenSnow);
@@ -412,10 +380,27 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile)
{
m_FinishGens.push_back(new cFinishGenSprinkleFoliage(Seed));
}
+ else if (NoCaseCompare(*itr, "Trees") == 0)
+ {
+ m_FinishGens.push_back(new cStructGenTrees(Seed, m_BiomeGen, m_HeightGen, m_CompositionGen));
+ }
+ else if (NoCaseCompare(*itr, "WaterLakes") == 0)
+ {
+ int Probability = a_IniFile.GetValueSetI("Generator", "WaterLakesProbability", 25);
+ m_FinishGens.push_back(new cStructGenLakes(Seed * 3 + 652, E_BLOCK_STATIONARY_WATER, *m_HeightGen, Probability));
+ }
else if (NoCaseCompare(*itr, "WaterSprings") == 0)
{
m_FinishGens.push_back(new cFinishGenFluidSprings(Seed, E_BLOCK_WATER, a_IniFile, Dimension));
}
+ else if (NoCaseCompare(*itr, "WormNestCaves") == 0)
+ {
+ m_FinishGens.push_back(new cStructGenWormNestCaves(Seed));
+ }
+ else
+ {
+ LOGWARNING("Unknown Finisher in the [Generator] section: \"%s\". Ignoring.", itr->c_str());
+ }
} // for itr - Str[]
}
diff --git a/src/Generating/ComposableGenerator.h b/src/Generating/ComposableGenerator.h
index 29add0636..6b7627d2e 100644
--- a/src/Generating/ComposableGenerator.h
+++ b/src/Generating/ComposableGenerator.h
@@ -43,16 +43,16 @@ class cBiomeGen
public:
virtual ~cBiomeGen() {} // Force a virtual destructor in descendants
- /// Generates biomes for the given chunk
+ /** Generates biomes for the given chunk */
virtual void GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) = 0;
- /// Reads parameters from the ini file, prepares generator for use.
+ /** Reads parameters from the ini file, prepares generator for use. */
virtual void InitializeBiomeGen(cIniFile & a_IniFile) {}
- /// Creates the correct BiomeGen descendant based on the ini file settings and the seed provided.
- /// a_CacheOffByDefault gets set to whether the cache should be disabled by default
- /// Used in BiomeVisualiser, too.
- /// Implemented in BioGen.cpp!
+ /** Creates the correct BiomeGen descendant based on the ini file settings and the seed provided.
+ a_CacheOffByDefault gets set to whether the cache should be disabled by default.
+ Used in BiomeVisualiser, too.
+ Implemented in BioGen.cpp! */
static cBiomeGen * CreateBiomeGen(cIniFile & a_IniFile, int a_Seed, bool & a_CacheOffByDefault);
} ;
@@ -72,10 +72,10 @@ class cTerrainHeightGen
public:
virtual ~cTerrainHeightGen() {} // Force a virtual destructor in descendants
- /// Generates heightmap for the given chunk
+ /** Generates heightmap for the given chunk */
virtual void GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) = 0;
- /// Reads parameters from the ini file, prepares generator for use.
+ /** Reads parameters from the ini file, prepares generator for use. */
virtual void InitializeHeightGen(cIniFile & a_IniFile) {}
/** Creates the correct TerrainHeightGen descendant based on the ini file settings and the seed provided.
@@ -102,7 +102,7 @@ public:
virtual void ComposeTerrain(cChunkDesc & a_ChunkDesc) = 0;
- /// Reads parameters from the ini file, prepares generator for use.
+ /** Reads parameters from the ini file, prepares generator for use. */
virtual void InitializeCompoGen(cIniFile & a_IniFile) {}
/** Creates the correct TerrainCompositionGen descendant based on the ini file settings and the seed provided.
@@ -116,28 +116,12 @@ public:
-/** The interface that a structure generator must implement
-Structures are generated after the terrain composition took place. It should modify the blocktype data to account
-for whatever structures the generator is generating.
-Note that ores are considered structures too, at least from the interface point of view.
-Also note that a worldgenerator may contain multiple structure generators, one for each type of structure
-*/
-class cStructureGen
-{
-public:
- virtual ~cStructureGen() {} // Force a virtual destructor in descendants
-
- virtual void GenStructures(cChunkDesc & a_ChunkDesc) = 0;
-} ;
-
-typedef std::list<cStructureGen *> cStructureGenList;
-
-
-
-
-
/** The interface that a finisher must implement
-Finisher implements small additions after all structures have been generated.
+Finisher implements changes to the chunk after the rough terrain has been generated.
+Examples of finishers are trees, snow, ore, lilypads and others.
+Note that a worldgenerator may contain multiple finishers.
+Also note that previously we used to distinguish between a structuregen and a finisher; this distinction is
+no longer relevant, all structure generators are considered finishers now (#398)
*/
class cFinishGen
{
@@ -171,7 +155,6 @@ protected:
cBiomeGen * m_BiomeGen;
cTerrainHeightGen * m_HeightGen;
cTerrainCompositionGen * m_CompositionGen;
- cStructureGenList m_StructureGens;
cFinishGenList m_FinishGens;
// Generators underlying the caches:
@@ -180,19 +163,16 @@ protected:
cTerrainCompositionGen * m_UnderlyingCompositionGen;
- /// Reads the biome gen settings from the ini and initializes m_BiomeGen accordingly
+ /** Reads the biome gen settings from the ini and initializes m_BiomeGen accordingly */
void InitBiomeGen(cIniFile & a_IniFile);
- /// Reads the HeightGen settings from the ini and initializes m_HeightGen accordingly
+ /** Reads the HeightGen settings from the ini and initializes m_HeightGen accordingly */
void InitHeightGen(cIniFile & a_IniFile);
- /// Reads the CompositionGen settings from the ini and initializes m_CompositionGen accordingly
+ /** Reads the CompositionGen settings from the ini and initializes m_CompositionGen accordingly */
void InitCompositionGen(cIniFile & a_IniFile);
- /// Reads the structures to generate from the ini and initializes m_StructureGens accordingly
- void InitStructureGens(cIniFile & a_IniFile);
-
- /// Reads the finishers from the ini and initializes m_FinishGens accordingly
+ /** Reads the finishers from the ini and initializes m_FinishGens accordingly */
void InitFinishGens(cIniFile & a_IniFile);
} ;
diff --git a/src/Generating/MineShafts.cpp b/src/Generating/MineShafts.cpp
index cc39cef7b..d9acc57bb 100644
--- a/src/Generating/MineShafts.cpp
+++ b/src/Generating/MineShafts.cpp
@@ -1407,7 +1407,7 @@ void cStructGenMineShafts::GetMineShaftSystemsForChunk(
-void cStructGenMineShafts::GenStructures(cChunkDesc & a_ChunkDesc)
+void cStructGenMineShafts::GenFinish(cChunkDesc & a_ChunkDesc)
{
int ChunkX = a_ChunkDesc.GetChunkX();
int ChunkZ = a_ChunkDesc.GetChunkZ();
diff --git a/src/Generating/MineShafts.h b/src/Generating/MineShafts.h
index c53d3bc53..ba32e75ad 100644
--- a/src/Generating/MineShafts.h
+++ b/src/Generating/MineShafts.h
@@ -17,7 +17,7 @@
class cStructGenMineShafts :
- public cStructureGen
+ public cFinishGen
{
public:
cStructGenMineShafts(
@@ -52,8 +52,8 @@ protected:
*/
void GetMineShaftSystemsForChunk(int a_ChunkX, int a_ChunkZ, cMineShaftSystems & a_MineShaftSystems);
- // cStructureGen overrides:
- virtual void GenStructures(cChunkDesc & a_ChunkDesc) override;
+ // cFinishGen overrides:
+ virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
} ;
diff --git a/src/Generating/Ravines.cpp b/src/Generating/Ravines.cpp
index cfda47e32..e64f55214 100644
--- a/src/Generating/Ravines.cpp
+++ b/src/Generating/Ravines.cpp
@@ -117,7 +117,7 @@ void cStructGenRavines::ClearCache(void)
-void cStructGenRavines::GenStructures(cChunkDesc & a_ChunkDesc)
+void cStructGenRavines::GenFinish(cChunkDesc & a_ChunkDesc)
{
int ChunkX = a_ChunkDesc.GetChunkX();
int ChunkZ = a_ChunkDesc.GetChunkZ();
diff --git a/src/Generating/Ravines.h b/src/Generating/Ravines.h
index 05164a5b2..c76b9f19f 100644
--- a/src/Generating/Ravines.h
+++ b/src/Generating/Ravines.h
@@ -17,7 +17,7 @@
class cStructGenRavines :
- public cStructureGen
+ public cFinishGen
{
public:
cStructGenRavines(int a_Seed, int a_Size);
@@ -37,8 +37,8 @@ protected:
/// Returns all ravines that *may* intersect the given chunk. All the ravines are valid until the next call to this function.
void GetRavinesForChunk(int a_ChunkX, int a_ChunkZ, cRavines & a_Ravines);
- // cStructureGen override:
- virtual void GenStructures(cChunkDesc & a_ChunkDesc) override;
+ // cFinishGen override:
+ virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
} ;
diff --git a/src/Generating/StructGen.cpp b/src/Generating/StructGen.cpp
index 47945cc2b..3cc8a09c3 100644
--- a/src/Generating/StructGen.cpp
+++ b/src/Generating/StructGen.cpp
@@ -54,7 +54,7 @@ const int NEST_SIZE_GRAVEL = 32;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cStructGenTrees:
-void cStructGenTrees::GenStructures(cChunkDesc & a_ChunkDesc)
+void cStructGenTrees::GenFinish(cChunkDesc & a_ChunkDesc)
{
int ChunkX = a_ChunkDesc.GetChunkX();
int ChunkZ = a_ChunkDesc.GetChunkZ();
@@ -306,7 +306,7 @@ int cStructGenTrees::GetNumTrees(
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cStructGenOreNests:
-void cStructGenOreNests::GenStructures(cChunkDesc & a_ChunkDesc)
+void cStructGenOreNests::GenFinish(cChunkDesc & a_ChunkDesc)
{
int ChunkX = a_ChunkDesc.GetChunkX();
int ChunkZ = a_ChunkDesc.GetChunkZ();
@@ -413,7 +413,7 @@ void cStructGenOreNests::GenerateOre(int a_ChunkX, int a_ChunkZ, BLOCKTYPE a_Ore
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cStructGenLakes:
-void cStructGenLakes::GenStructures(cChunkDesc & a_ChunkDesc)
+void cStructGenLakes::GenFinish(cChunkDesc & a_ChunkDesc)
{
int ChunkX = a_ChunkDesc.GetChunkX();
int ChunkZ = a_ChunkDesc.GetChunkZ();
@@ -545,7 +545,7 @@ cStructGenDirectOverhangs::cStructGenDirectOverhangs(int a_Seed) :
-void cStructGenDirectOverhangs::GenStructures(cChunkDesc & a_ChunkDesc)
+void cStructGenDirectOverhangs::GenFinish(cChunkDesc & a_ChunkDesc)
{
// If there is no column of the wanted biome, bail out:
if (!HasWantedBiome(a_ChunkDesc))
@@ -665,7 +665,7 @@ cStructGenDistortedMembraneOverhangs::cStructGenDistortedMembraneOverhangs(int a
-void cStructGenDistortedMembraneOverhangs::GenStructures(cChunkDesc & a_ChunkDesc)
+void cStructGenDistortedMembraneOverhangs::GenFinish(cChunkDesc & a_ChunkDesc)
{
const NOISE_DATATYPE Frequency = (NOISE_DATATYPE)16;
const NOISE_DATATYPE Amount = (NOISE_DATATYPE)1;
diff --git a/src/Generating/StructGen.h b/src/Generating/StructGen.h
index 853748bb8..9176bc192 100644
--- a/src/Generating/StructGen.h
+++ b/src/Generating/StructGen.h
@@ -21,7 +21,7 @@
class cStructGenTrees :
- public cStructureGen
+ public cFinishGen
{
public:
cStructGenTrees(int a_Seed, cBiomeGen * a_BiomeGen, cTerrainHeightGen * a_HeightGen, cTerrainCompositionGen * a_CompositionGen) :
@@ -64,8 +64,8 @@ protected:
const cChunkDef::BiomeMap & a_Biomes
);
- // cStructureGen override:
- virtual void GenStructures(cChunkDesc & a_ChunkDesc) override;
+ // cFinishGen override:
+ virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
} ;
@@ -73,7 +73,7 @@ protected:
class cStructGenOreNests :
- public cStructureGen
+ public cFinishGen
{
public:
cStructGenOreNests(int a_Seed) : m_Noise(a_Seed), m_Seed(a_Seed) {}
@@ -82,8 +82,8 @@ protected:
cNoise m_Noise;
int m_Seed;
- // cStructureGen override:
- virtual void GenStructures(cChunkDesc & a_ChunkDesc) override;
+ // cFinishGen override:
+ virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
void GenerateOre(int a_ChunkX, int a_ChunkZ, BLOCKTYPE a_OreType, int a_MaxHeight, int a_NumNests, int a_NestSize, cChunkDef::BlockTypes & a_BlockTypes, int a_Seq);
} ;
@@ -93,7 +93,7 @@ protected:
class cStructGenLakes :
- public cStructureGen
+ public cFinishGen
{
public:
cStructGenLakes(int a_Seed, BLOCKTYPE a_Fluid, cTerrainHeightGen & a_HeiGen, int a_Probability) :
@@ -112,8 +112,8 @@ protected:
cTerrainHeightGen & m_HeiGen;
int m_Probability; ///< Chance, 0 .. 100, of a chunk having the lake
- // cStructureGen override:
- virtual void GenStructures(cChunkDesc & a_ChunkDesc) override;
+ // cFinishGen override:
+ virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
/// Creates a lake image for the specified chunk into a_Lake
void CreateLakeImage(int a_ChunkX, int a_ChunkZ, cBlockArea & a_Lake);
@@ -125,7 +125,7 @@ protected:
class cStructGenDirectOverhangs :
- public cStructureGen
+ public cFinishGen
{
public:
cStructGenDirectOverhangs(int a_Seed);
@@ -134,8 +134,8 @@ protected:
cNoise m_Noise1;
cNoise m_Noise2;
- // cStructureGen override:
- virtual void GenStructures(cChunkDesc & a_ChunkDesc) override;
+ // cFinishGen override:
+ virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
bool HasWantedBiome(cChunkDesc & a_ChunkDesc) const;
} ;
@@ -145,7 +145,7 @@ protected:
class cStructGenDistortedMembraneOverhangs :
- public cStructureGen
+ public cFinishGen
{
public:
cStructGenDistortedMembraneOverhangs(int a_Seed);
@@ -156,8 +156,8 @@ protected:
cNoise m_NoiseZ;
cNoise m_NoiseH;
- // cStructureGen override:
- virtual void GenStructures(cChunkDesc & a_ChunkDesc) override;
+ // cFinishGen override:
+ virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
} ;
diff --git a/src/GroupManager.cpp b/src/GroupManager.cpp
index 5125e7586..33b601e82 100644
--- a/src/GroupManager.cpp
+++ b/src/GroupManager.cpp
@@ -55,16 +55,27 @@ cGroupManager::cGroupManager()
+void cGroupManager::GenerateDefaultUsersIni(cIniFile & a_IniFile)
+{
+ LOGWARN("Regenerating users.ini, all users will be reset");
+ a_IniFile.AddHeaderComment(" This file stores the players' groups.");
+ a_IniFile.AddHeaderComment(" The format is:");
+ a_IniFile.AddHeaderComment(" [PlayerName]");
+ a_IniFile.AddHeaderComment(" Groups = GroupName1, GroupName2, ...");
+
+ a_IniFile.WriteFile("users.ini");
+}
+
+
+
+
+
void cGroupManager::CheckUsers(void)
{
cIniFile IniFile;
if (!IniFile.ReadFile("users.ini"))
{
- LOGWARN("Regenerating users.ini, all users will be reset");
- IniFile.AddHeaderComment(" This is the file in which the group the player belongs to is stored");
- IniFile.AddHeaderComment(" The format is: [PlayerName] | Groups=GroupName");
-
- IniFile.WriteFile("users.ini");
+ GenerateDefaultUsersIni(IniFile);
return;
}
diff --git a/src/GroupManager.h b/src/GroupManager.h
index 377a54c98..9e1689a76 100644
--- a/src/GroupManager.h
+++ b/src/GroupManager.h
@@ -19,6 +19,9 @@ public:
void LoadGroups(void);
void CheckUsers(void);
+ /** Writes the default header to the specified ini file, and saves it as "users.ini". */
+ static void GenerateDefaultUsersIni(cIniFile & a_IniFile);
+
private:
friend class cRoot;
cGroupManager();
diff --git a/src/HTTPServer/HTTPServer.cpp b/src/HTTPServer/HTTPServer.cpp
index f6f5b0f8b..4e9195a00 100644
--- a/src/HTTPServer/HTTPServer.cpp
+++ b/src/HTTPServer/HTTPServer.cpp
@@ -29,6 +29,8 @@ class cDebugCallbacks :
{
virtual void OnRequestBegun(cHTTPConnection & a_Connection, cHTTPRequest & a_Request) override
{
+ UNUSED(a_Connection);
+
if (cHTTPFormParser::HasFormData(a_Request))
{
a_Request.SetUserData(new cHTTPFormParser(a_Request, *this));
@@ -38,6 +40,8 @@ class cDebugCallbacks :
virtual void OnRequestBody(cHTTPConnection & a_Connection, cHTTPRequest & a_Request, const char * a_Data, int a_Size) override
{
+ UNUSED(a_Connection);
+
cHTTPFormParser * FormParser = (cHTTPFormParser *)(a_Request.GetUserData());
if (FormParser != NULL)
{
diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp
index c10d13edc..507f7fa86 100644
--- a/src/Items/ItemHandler.cpp
+++ b/src/Items/ItemHandler.cpp
@@ -248,6 +248,14 @@ cItemHandler::cItemHandler(int a_ItemType)
bool cItemHandler::OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir)
{
+ UNUSED(a_World);
+ UNUSED(a_Player);
+ UNUSED(a_Item);
+ UNUSED(a_BlockX);
+ UNUSED(a_BlockY);
+ UNUSED(a_BlockZ);
+ UNUSED(a_Dir);
+
return false;
}
@@ -257,6 +265,14 @@ bool cItemHandler::OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem &
bool cItemHandler::OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir)
{
+ UNUSED(a_World);
+ UNUSED(a_Player);
+ UNUSED(a_Item);
+ UNUSED(a_BlockX);
+ UNUSED(a_BlockY);
+ UNUSED(a_BlockZ);
+ UNUSED(a_Dir);
+
return false;
}
@@ -266,6 +282,8 @@ bool cItemHandler::OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, const cI
void cItemHandler::OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ)
{
+ UNUSED(a_Item);
+
BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
cBlockHandler * Handler = cBlockHandler::GetBlockHandler(Block);
@@ -288,7 +306,9 @@ void cItemHandler::OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const
void cItemHandler::OnFoodEaten(cWorld * a_World, cPlayer * a_Player, cItem * a_Item)
{
-
+ UNUSED(a_World);
+ UNUSED(a_Player);
+ UNUSED(a_Item);
}
@@ -461,6 +481,8 @@ bool cItemHandler::IsPlaceable(void)
bool cItemHandler::CanHarvestBlock(BLOCKTYPE a_BlockType)
{
+ UNUSED(a_BlockType);
+
return false;
}
@@ -499,6 +521,8 @@ bool cItemHandler::GetPlacementBlockTypeMeta(
bool cItemHandler::EatItem(cPlayer * a_Player, cItem * a_Item)
{
+ UNUSED(a_Item);
+
FoodInfo Info = GetFoodInfo();
if ((Info.FoodLevel > 0) || (Info.Saturation > 0.f))
diff --git a/src/OSSupport/BlockingTCPLink.cpp b/src/OSSupport/BlockingTCPLink.cpp
index af50eda5d..e9c00d6d4 100644
--- a/src/OSSupport/BlockingTCPLink.cpp
+++ b/src/OSSupport/BlockingTCPLink.cpp
@@ -89,6 +89,8 @@ bool cBlockingTCPLink::Connect(const char * iAddress, unsigned int iPort)
int cBlockingTCPLink::Send(char * a_Data, unsigned int a_Size, int a_Flags /* = 0 */ )
{
+ UNUSED(a_Flags);
+
ASSERT(m_Socket.IsValid());
if (!m_Socket.IsValid())
{
@@ -104,6 +106,8 @@ int cBlockingTCPLink::Send(char * a_Data, unsigned int a_Size, int a_Flags /* =
int cBlockingTCPLink::SendMessage( const char* a_Message, int a_Flags /* = 0 */ )
{
+ UNUSED(a_Flags);
+
ASSERT(m_Socket.IsValid());
if (!m_Socket.IsValid())
{
diff --git a/src/Scoreboard.cpp b/src/Scoreboard.cpp
index 61ecac5b7..05fd0314d 100644
--- a/src/Scoreboard.cpp
+++ b/src/Scoreboard.cpp
@@ -17,19 +17,19 @@ AString cObjective::TypeToString(eType a_Type)
{
switch (a_Type)
{
- case E_TYPE_DUMMY: return "dummy";
- case E_TYPE_DEATH_COUNT: return "deathCount";
- case E_TYPE_PLAYER_KILL_COUNT: return "playerKillCount";
- case E_TYPE_TOTAL_KILL_COUNT: return "totalKillCount";
- case E_TYPE_HEALTH: return "health";
- case E_TYPE_ACHIEVEMENT: return "achievement";
- case E_TYPE_STAT: return "stat";
- case E_TYPE_STAT_ITEM_CRAFT: return "stat.craftItem";
- case E_TYPE_STAT_ITEM_USE: return "stat.useItem";
- case E_TYPE_STAT_ITEM_BREAK: return "stat.breakItem";
- case E_TYPE_STAT_BLOCK_MINE: return "stat.mineBlock";
- case E_TYPE_STAT_ENTITY_KILL: return "stat.killEntity";
- case E_TYPE_STAT_ENTITY_KILLED_BY: return "stat.entityKilledBy";
+ case otDummy: return "dummy";
+ case otDeathCount: return "deathCount";
+ case otPlayerKillCount: return "playerKillCount";
+ case otTotalKillCount: return "totalKillCount";
+ case otHealth: return "health";
+ case otAchievement: return "achievement";
+ case otStat: return "stat";
+ case otStatItemCraft: return "stat.craftItem";
+ case otStatItemUse: return "stat.useItem";
+ case otStatItemBreak: return "stat.breakItem";
+ case otStatBlockMine: return "stat.mineBlock";
+ case otStatEntityKill: return "stat.killEntity";
+ case otStatEntityKilledBy: return "stat.entityKilledBy";
default: return "";
}
@@ -46,19 +46,19 @@ cObjective::eType cObjective::StringToType(const AString & a_Name)
const char * m_String;
} TypeMap [] =
{
- {E_TYPE_DUMMY, "dummy"},
- {E_TYPE_DEATH_COUNT, "deathCount"},
- {E_TYPE_PLAYER_KILL_COUNT, "playerKillCount"},
- {E_TYPE_TOTAL_KILL_COUNT, "totalKillCount"},
- {E_TYPE_HEALTH, "health"},
- {E_TYPE_ACHIEVEMENT, "achievement"},
- {E_TYPE_STAT, "stat"},
- {E_TYPE_STAT_ITEM_CRAFT, "stat.craftItem"},
- {E_TYPE_STAT_ITEM_USE, "stat.useItem"},
- {E_TYPE_STAT_ITEM_BREAK, "stat.breakItem"},
- {E_TYPE_STAT_BLOCK_MINE, "stat.mineBlock"},
- {E_TYPE_STAT_ENTITY_KILL, "stat.killEntity"},
- {E_TYPE_STAT_ENTITY_KILLED_BY, "stat.entityKilledBy"}
+ {otDummy, "dummy" },
+ {otDeathCount, "deathCount" },
+ {otPlayerKillCount, "playerKillCount" },
+ {otTotalKillCount, "totalKillCount" },
+ {otHealth, "health" },
+ {otAchievement, "achievement" },
+ {otStat, "stat" },
+ {otStatItemCraft, "stat.craftItem" },
+ {otStatItemUse, "stat.useItem" },
+ {otStatItemBreak, "stat.breakItem" },
+ {otStatBlockMine, "stat.mineBlock" },
+ {otStatEntityKill, "stat.killEntity" },
+ {otStatEntityKilledBy, "stat.entityKilledBy"}
};
for (size_t i = 0; i < ARRAYCOUNT(TypeMap); i++)
{
@@ -67,7 +67,7 @@ cObjective::eType cObjective::StringToType(const AString & a_Name)
return TypeMap[i].m_Type;
}
} // for i - TypeMap[]
- return E_TYPE_DUMMY;
+ return otDummy;
}
@@ -246,6 +246,17 @@ void cTeam::Reset(void)
+void cTeam::SetDisplayName(const AString & a_Name)
+{
+ m_DisplayName = a_Name;
+
+ // TODO 2014-03-01 xdot: Update clients
+}
+
+
+
+
+
unsigned int cTeam::GetNumPlayers(void) const
{
return m_Players.size();
@@ -257,7 +268,7 @@ unsigned int cTeam::GetNumPlayers(void) const
cScoreboard::cScoreboard(cWorld * a_World) : m_World(a_World)
{
- for (int i = 0; i < (int) E_DISPLAY_SLOT_COUNT; ++i)
+ for (int i = 0; i < (int) dsCount; ++i)
{
m_Display[i] = NULL;
}
@@ -306,6 +317,8 @@ bool cScoreboard::RemoveObjective(const AString & a_Name)
ASSERT(m_World != NULL);
m_World->BroadcastScoreboardObjective(it->second.GetName(), it->second.GetDisplayName(), 1);
+ // TODO 2014-03-01 xdot: Remove objective from display slot
+
return true;
}
@@ -410,7 +423,7 @@ cTeam * cScoreboard::QueryPlayerTeam(const AString & a_Name)
void cScoreboard::SetDisplay(const AString & a_Objective, eDisplaySlot a_Slot)
{
- ASSERT(a_Slot < E_DISPLAY_SLOT_COUNT);
+ ASSERT(a_Slot < dsCount);
cObjective * Objective = GetObjective(a_Objective);
@@ -435,7 +448,7 @@ void cScoreboard::SetDisplay(cObjective * a_Objective, eDisplaySlot a_Slot)
cObjective * cScoreboard::GetObjectiveIn(eDisplaySlot a_Slot)
{
- ASSERT(a_Slot < E_DISPLAY_SLOT_COUNT);
+ ASSERT(a_Slot < dsCount);
return m_Display[a_Slot];
}
@@ -444,7 +457,7 @@ cObjective * cScoreboard::GetObjectiveIn(eDisplaySlot a_Slot)
-void cScoreboard::ForEachObjectiveWith(cObjective::eType a_Type, cObjectiveCallback& a_Callback)
+bool cScoreboard::ForEachObjectiveWith(cObjective::eType a_Type, cObjectiveCallback& a_Callback)
{
cCSLock Lock(m_CSObjectives);
@@ -455,10 +468,66 @@ void cScoreboard::ForEachObjectiveWith(cObjective::eType a_Type, cObjectiveCallb
// Call callback
if (a_Callback.Item(&it->second))
{
- return;
+ return false;
}
}
}
+ return true;
+}
+
+
+
+
+
+bool cScoreboard::ForEachObjective(cObjectiveCallback& a_Callback)
+{
+ cCSLock Lock(m_CSObjectives);
+
+ for (cObjectiveMap::iterator it = m_Objectives.begin(); it != m_Objectives.end(); ++it)
+ {
+ // Call callback
+ if (a_Callback.Item(&it->second))
+ {
+ return false;
+ }
+ }
+ return true;
+}
+
+
+
+
+
+bool cScoreboard::ForEachTeam(cTeamCallback& a_Callback)
+{
+ cCSLock Lock(m_CSObjectives);
+
+ for (cTeamMap::iterator it = m_Teams.begin(); it != m_Teams.end(); ++it)
+ {
+ // Call callback
+ if (a_Callback.Item(&it->second))
+ {
+ return false;
+ }
+ }
+ return true;
+}
+
+
+
+
+
+void cScoreboard::AddPlayerScore(const AString & a_Name, cObjective::eType a_Type, cObjective::Score a_Value)
+{
+ cCSLock Lock(m_CSObjectives);
+
+ for (cObjectiveMap::iterator it = m_Objectives.begin(); it != m_Objectives.end(); ++it)
+ {
+ if (it->second.GetType() == a_Type)
+ {
+ it->second.AddScore(a_Name, a_Value);
+ }
+ }
}
@@ -474,7 +543,7 @@ void cScoreboard::SendTo(cClientHandle & a_Client)
it->second.SendTo(a_Client);
}
- for (int i = 0; i < (int) E_DISPLAY_SLOT_COUNT; ++i)
+ for (int i = 0; i < (int) dsCount; ++i)
{
// Avoid race conditions
cObjective * Objective = m_Display[i];
diff --git a/src/Scoreboard.h b/src/Scoreboard.h
index f64ba2bce..e22ecaeb1 100644
--- a/src/Scoreboard.h
+++ b/src/Scoreboard.h
@@ -14,9 +14,11 @@
class cObjective;
+class cTeam;
class cWorld;
typedef cItemCallback<cObjective> cObjectiveCallback;
+typedef cItemCallback<cTeam> cTeamCallback;
@@ -31,23 +33,23 @@ public:
enum eType
{
- E_TYPE_DUMMY,
+ otDummy,
- E_TYPE_DEATH_COUNT,
- E_TYPE_PLAYER_KILL_COUNT,
- E_TYPE_TOTAL_KILL_COUNT,
- E_TYPE_HEALTH,
+ otDeathCount,
+ otPlayerKillCount,
+ otTotalKillCount,
+ otHealth,
- E_TYPE_ACHIEVEMENT,
+ otAchievement,
- E_TYPE_STAT,
- E_TYPE_STAT_ITEM_CRAFT,
- E_TYPE_STAT_ITEM_USE,
- E_TYPE_STAT_ITEM_BREAK,
+ otStat,
+ otStatItemCraft,
+ otStatItemUse,
+ otStatItemBreak,
- E_TYPE_STAT_BLOCK_MINE,
- E_TYPE_STAT_ENTITY_KILL,
- E_TYPE_STAT_ENTITY_KILLED_BY
+ otStatBlockMine,
+ otStatEntityKill,
+ otStatEntityKilledBy
};
// tolua_end
@@ -67,31 +69,37 @@ public:
const AString & GetName(void) const { return m_Name; }
const AString & GetDisplayName(void) const { return m_DisplayName; }
- /// Resets the objective
+ /** Resets the objective */
void Reset(void);
- /// Returns the score of the specified player
+ /** Returns the score of the specified player */
Score GetScore(const AString & a_Name) const;
- /// Sets the score of the specified player
+ /** Sets the score of the specified player */
void SetScore(const AString & a_Name, Score a_Score);
- /// Resets the score of the specified player
+ /** Resets the score of the specified player */
void ResetScore(const AString & a_Name);
- /// Adds a_Delta and returns the new score
+ /** Adds a_Delta and returns the new score */
Score AddScore(const AString & a_Name, Score a_Delta);
- /// Subtracts a_Delta and returns the new score
+ /** Subtracts a_Delta and returns the new score */
Score SubScore(const AString & a_Name, Score a_Delta);
void SetDisplayName(const AString & a_Name);
// tolua_end
- /// Send this objective to the specified client
+ /** Send this objective to the specified client */
void SendTo(cClientHandle & a_Client);
+ static const char * GetClassStatic(void) // Needed for ManualBindings's ForEach templates
+ {
+ return "cObjective";
+ }
+
+
private:
typedef std::pair<AString, Score> cTrackedPlayer;
@@ -109,7 +117,8 @@ private:
friend class cScoreboardSerializer;
-};
+
+}; // tolua_export
@@ -127,21 +136,21 @@ public:
const AString & a_Prefix, const AString & a_Suffix
);
- /// Adds a new player to the team
+ // tolua_begin
+
+ /** Adds a new player to the team */
bool AddPlayer(const AString & a_Name);
- /// Removes a player from the team
+ /** Removes a player from the team */
bool RemovePlayer(const AString & a_Name);
- /// Returns whether the specified player is in this team
+ /** Returns whether the specified player is in this team */
bool HasPlayer(const AString & a_Name) const;
- /// Removes all registered players
+ /** Removes all registered players */
void Reset(void);
- // tolua_begin
-
- /// Returns the number of registered players
+ /** Returns the number of registered players */
unsigned int GetNumPlayers(void) const;
bool AllowsFriendlyFire(void) const { return m_AllowsFriendlyFire; }
@@ -163,6 +172,11 @@ public:
// tolua_end
+ static const char * GetClassStatic(void) // Needed for ManualBindings's ForEach templates
+ {
+ return "cTeam";
+ }
+
private:
typedef std::set<AString> cPlayerNameSet;
@@ -180,7 +194,8 @@ private:
friend class cScoreboardSerializer;
-};
+
+}; // tolua_export
@@ -193,11 +208,11 @@ public:
enum eDisplaySlot
{
- E_DISPLAY_SLOT_LIST = 0,
- E_DISPLAY_SLOT_SIDEBAR,
- E_DISPLAY_SLOT_NAME,
+ dsList = 0,
+ dsSidebar,
+ dsName,
- E_DISPLAY_SLOT_COUNT
+ dsCount
};
// tolua_end
@@ -209,44 +224,61 @@ public:
// tolua_begin
- /// Registers a new scoreboard objective, returns the cObjective instance, NULL on name collision
+ /** Registers a new scoreboard objective, returns the cObjective instance, NULL on name collision */
cObjective * RegisterObjective(const AString & a_Name, const AString & a_DisplayName, cObjective::eType a_Type);
- /// Removes a registered objective, returns true if operation was successful
+ /** Removes a registered objective, returns true if operation was successful */
bool RemoveObjective(const AString & a_Name);
- /// Retrieves the objective with the specified name, NULL if not found
+ /** Retrieves the objective with the specified name, NULL if not found */
cObjective * GetObjective(const AString & a_Name);
- /// Registers a new team, returns the cTeam instance, NULL on name collision
+ /** Registers a new team, returns the cTeam instance, NULL on name collision */
cTeam * RegisterTeam(const AString & a_Name, const AString & a_DisplayName, const AString & a_Prefix, const AString & a_Suffix);
- /// Removes a registered team, returns true if operation was successful
+ /** Removes a registered team, returns true if operation was successful */
bool RemoveTeam(const AString & a_Name);
- /// Retrieves the team with the specified name, NULL if not found
+ /** Retrieves the team with the specified name, NULL if not found */
cTeam * GetTeam(const AString & a_Name);
- cTeam * QueryPlayerTeam(const AString & a_Name); // WARNING: O(n logn)
-
void SetDisplay(const AString & a_Objective, eDisplaySlot a_Slot);
- void SetDisplay(cObjective * a_Objective, eDisplaySlot a_Slot);
-
cObjective * GetObjectiveIn(eDisplaySlot a_Slot);
- /// Execute callback for each objective with the specified type
- void ForEachObjectiveWith(cObjective::eType a_Type, cObjectiveCallback& a_Callback);
-
unsigned int GetNumObjectives(void) const;
unsigned int GetNumTeams(void) const;
+ void AddPlayerScore(const AString & a_Name, cObjective::eType a_Type, cObjective::Score a_Value = 1);
+
// tolua_end
- /// Send this scoreboard to the specified client
+ /** Send this scoreboard to the specified client */
void SendTo(cClientHandle & a_Client);
+ cTeam * QueryPlayerTeam(const AString & a_Name); // WARNING: O(n logn)
+
+ /** Execute callback for each objective with the specified type
+ *
+ * Returns true if all objectives processed, false if the callback aborted by returning true.
+ */
+ bool ForEachObjectiveWith(cObjective::eType a_Type, cObjectiveCallback& a_Callback);
+
+ /** Execute callback for each objective.
+ *
+ * Returns true if all objectives have been processed, false if the callback aborted by returning true.
+ */
+ bool ForEachObjective(cObjectiveCallback& a_Callback); // Exported in ManualBindings.cpp
+
+ /** Execute callback for each team.
+ *
+ * Returns true if all teams have been processed, false if the callback aborted by returning true.
+ */
+ bool ForEachTeam(cTeamCallback& a_Callback); // Exported in ManualBindings.cpp
+
+ void SetDisplay(cObjective * a_Objective, eDisplaySlot a_Slot);
+
private:
@@ -265,11 +297,12 @@ private:
cWorld * m_World;
- cObjective* m_Display[E_DISPLAY_SLOT_COUNT];
+ cObjective * m_Display[dsCount];
friend class cScoreboardSerializer;
-} ;
+
+}; // tolua_export
diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp
index bfcad3d92..88977e005 100644
--- a/src/UI/SlotArea.cpp
+++ b/src/UI/SlotArea.cpp
@@ -224,6 +224,24 @@ void cSlotArea::DblClicked(cPlayer & a_Player, int a_SlotNum)
+void cSlotArea::OnPlayerAdded(cPlayer & a_Player)
+{
+ UNUSED(a_Player);
+}
+
+
+
+
+
+void cSlotArea::OnPlayerRemoved(cPlayer & a_Player)
+{
+ UNUSED(a_Player);
+}
+
+
+
+
+
void cSlotArea::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_Apply, bool a_KeepEmptySlots)
{
for (int i = 0; i < m_NumSlots; i++)
@@ -447,6 +465,18 @@ void cSlotAreaCrafting::OnPlayerRemoved(cPlayer & a_Player)
+
+void cSlotAreaCrafting::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots)
+{
+ UNUSED(a_ItemStack);
+ UNUSED(a_Player);
+ UNUSED(a_ShouldApply);
+ UNUSED(a_KeepEmptySlots);
+}
+
+
+
+
void cSlotAreaCrafting::ClickedResult(cPlayer & a_Player)
{
cItem & DraggingItem = a_Player.GetDraggingItem();
diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h
index d31c87e0c..25b367cff 100644
--- a/src/UI/SlotArea.h
+++ b/src/UI/SlotArea.h
@@ -48,10 +48,10 @@ public:
virtual void DblClicked(cPlayer & a_Player, int a_SlotNum);
/// Called when a new player opens the same parent window. The window already tracks the player. CS-locked.
- virtual void OnPlayerAdded(cPlayer & a_Player) {} ;
+ virtual void OnPlayerAdded(cPlayer & a_Player);
/// Called when one of the players closes the parent window. The window already doesn't track the player. CS-locked.
- virtual void OnPlayerRemoved(cPlayer & a_Player) {} ;
+ virtual void OnPlayerRemoved(cPlayer & a_Player);
/** Called to store as much of a_ItemStack in the area as possible. a_ItemStack is modified to reflect the change.
The default implementation searches each slot for available space and distributes the stack there.
@@ -226,7 +226,7 @@ public:
virtual void OnPlayerRemoved(cPlayer & a_Player) override;
// Distributing items into this area is completely disabled
- virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots) override {}
+ virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots) override;
protected:
/// Maps player's EntityID -> current recipe; not a std::map because cCraftingGrid needs proper constructor params
diff --git a/src/WorldStorage/FastNBT.h b/src/WorldStorage/FastNBT.h
index 49f97c458..01a9ad274 100644
--- a/src/WorldStorage/FastNBT.h
+++ b/src/WorldStorage/FastNBT.h
@@ -106,6 +106,10 @@ public:
/** Parses and contains the parsed data
Also implements data accessor functions for tree traversal and value getters
The data pointer passed in the constructor is assumed to be valid throughout the object's life. Care must be taken not to initialize from a temporary.
+The parser decomposes the input data into a tree of tags that is stored as an array of cFastNBTTag items,
+and accessing the tree is done by using the array indices for tags. Each tag stores the indices for its parent,
+first child, last child, prev sibling and next sibling, a value of -1 indicates that the indice is not valid.
+Each primitive tag also stores the length of the contained data, in bytes.
*/
class cParsedNBT
{
@@ -114,13 +118,32 @@ public:
bool IsValid(void) const {return m_IsValid; }
+ /** Returns the root tag of the hierarchy. */
int GetRoot(void) const {return 0; }
+
+ /** Returns the first child of the specified tag, or -1 if none / not applicable. */
int GetFirstChild (int a_Tag) const { return m_Tags[a_Tag].m_FirstChild; }
+
+ /** Returns the last child of the specified tag, or -1 if none / not applicable. */
int GetLastChild (int a_Tag) const { return m_Tags[a_Tag].m_LastChild; }
+
+ /** Returns the next sibling of the specified tag, or -1 if none. */
int GetNextSibling(int a_Tag) const { return m_Tags[a_Tag].m_NextSibling; }
+
+ /** Returns the previous sibling of the specified tag, or -1 if none. */
int GetPrevSibling(int a_Tag) const { return m_Tags[a_Tag].m_PrevSibling; }
- int GetDataLength (int a_Tag) const { return m_Tags[a_Tag].m_DataLength; }
+
+ /** Returns the length of the tag's data, in bytes.
+ Not valid for Compound or List tags! */
+ int GetDataLength (int a_Tag) const
+ {
+ ASSERT(m_Tags[a_Tag].m_Type != TAG_List);
+ ASSERT(m_Tags[a_Tag].m_Type != TAG_Compound);
+ return m_Tags[a_Tag].m_DataLength;
+ }
+ /** Returns the data stored in this tag.
+ Not valid for Compound or List tags! */
const char * GetData(int a_Tag) const
{
ASSERT(m_Tags[a_Tag].m_Type != TAG_List);
@@ -128,55 +151,64 @@ public:
return m_Data + m_Tags[a_Tag].m_DataStart;
}
+ /** Returns the direct child tag of the specified name, or -1 if no such tag. */
int FindChildByName(int a_Tag, const AString & a_Name) const
{
return FindChildByName(a_Tag, a_Name.c_str(), a_Name.length());
}
+ /** Returns the direct child tag of the specified name, or -1 if no such tag. */
int FindChildByName(int a_Tag, const char * a_Name, size_t a_NameLength = 0) const;
- int FindTagByPath (int a_Tag, const AString & a_Path) const;
+
+ /** Returns the child tag of the specified path (Name1\Name2\Name3...), or -1 if no such tag. */
+ int FindTagByPath(int a_Tag, const AString & a_Path) const;
eTagType GetType(int a_Tag) const { return m_Tags[a_Tag].m_Type; }
- /// Returns the children type for a list tag; undefined on other tags. If list empty, returns TAG_End
+ /** Returns the children type for a List tag; undefined on other tags. If list empty, returns TAG_End. */
eTagType GetChildrenType(int a_Tag) const
{
ASSERT(m_Tags[a_Tag].m_Type == TAG_List);
return (m_Tags[a_Tag].m_FirstChild < 0) ? TAG_End : m_Tags[m_Tags[a_Tag].m_FirstChild].m_Type;
}
+ /** Returns the value stored in a Byte tag. Not valid for any other tag type. */
inline unsigned char GetByte(int a_Tag) const
{
ASSERT(m_Tags[a_Tag].m_Type == TAG_Byte);
return (unsigned char)(m_Data[m_Tags[a_Tag].m_DataStart]);
}
+ /** Returns the value stored in a Short tag. Not valid for any other tag type. */
inline Int16 GetShort(int a_Tag) const
{
ASSERT(m_Tags[a_Tag].m_Type == TAG_Short);
return GetBEShort(m_Data + m_Tags[a_Tag].m_DataStart);
}
+ /** Returns the value stored in an Int tag. Not valid for any other tag type. */
inline Int32 GetInt(int a_Tag) const
{
ASSERT(m_Tags[a_Tag].m_Type == TAG_Int);
return GetBEInt(m_Data + m_Tags[a_Tag].m_DataStart);
}
+ /** Returns the value stored in a Long tag. Not valid for any other tag type. */
inline Int64 GetLong(int a_Tag) const
{
ASSERT(m_Tags[a_Tag].m_Type == TAG_Long);
return NetworkToHostLong8(m_Data + m_Tags[a_Tag].m_DataStart);
}
+ /** Returns the value stored in a Float tag. Not valid for any other tag type. */
inline float GetFloat(int a_Tag) const
{
ASSERT(m_Tags[a_Tag].m_Type == TAG_Float);
// Cause a compile-time error if sizeof(float) != 4
// If your platform produces a compiler error here, you'll need to add code that manually decodes 32-bit floats
- char Check1[5 - sizeof(float)]; // sizeof(float) <= 4
- char Check2[sizeof(float) - 3]; // sizeof(float) >= 4
+ char Check1[5 - sizeof(float)]; // Fails if sizeof(float) > 4
+ char Check2[sizeof(float) - 3]; // Fails if sizeof(float) < 4
UNUSED(Check1);
UNUSED(Check2);
@@ -186,12 +218,21 @@ public:
return f;
}
+ /** Returns the value stored in a Double tag. Not valid for any other tag type. */
inline double GetDouble(int a_Tag) const
{
+ // Cause a compile-time error if sizeof(double) != 8
+ // If your platform produces a compiler error here, you'll need to add code that manually decodes 64-bit doubles
+ char Check1[9 - sizeof(double)]; // Fails if sizeof(double) > 8
+ char Check2[sizeof(double) - 7]; // Fails if sizeof(double) < 8
+ UNUSED(Check1);
+ UNUSED(Check2);
+
ASSERT(m_Tags[a_Tag].m_Type == TAG_Double);
return NetworkToHostDouble8(m_Data + m_Tags[a_Tag].m_DataStart);
}
+ /** Returns the value stored in a String tag. Not valid for any other tag type. */
inline AString GetString(int a_Tag) const
{
ASSERT(m_Tags[a_Tag].m_Type == TAG_String);
@@ -200,6 +241,7 @@ public:
return res;
}
+ /** Returns the tag's name. For tags that are not named, returns an empty string. */
inline AString GetName(int a_Tag) const
{
AString res;
diff --git a/src/WorldStorage/ScoreboardSerializer.cpp b/src/WorldStorage/ScoreboardSerializer.cpp
index 9b8b661c4..6c885bb45 100644
--- a/src/WorldStorage/ScoreboardSerializer.cpp
+++ b/src/WorldStorage/ScoreboardSerializer.cpp
@@ -173,13 +173,13 @@ void cScoreboardSerializer::SaveScoreboardToNBT(cFastNBTWriter & a_Writer)
a_Writer.BeginCompound("DisplaySlots");
- cObjective * Objective = m_ScoreBoard->GetObjectiveIn(cScoreboard::E_DISPLAY_SLOT_LIST);
+ cObjective * Objective = m_ScoreBoard->GetObjectiveIn(cScoreboard::dsList);
a_Writer.AddString("slot_0", (Objective == NULL) ? "" : Objective->GetName());
- Objective = m_ScoreBoard->GetObjectiveIn(cScoreboard::E_DISPLAY_SLOT_SIDEBAR);
+ Objective = m_ScoreBoard->GetObjectiveIn(cScoreboard::dsSidebar);
a_Writer.AddString("slot_1", (Objective == NULL) ? "" : Objective->GetName());
- Objective = m_ScoreBoard->GetObjectiveIn(cScoreboard::E_DISPLAY_SLOT_NAME);
+ Objective = m_ScoreBoard->GetObjectiveIn(cScoreboard::dsName);
a_Writer.AddString("slot_2", (Objective == NULL) ? "" : Objective->GetName());
a_Writer.EndCompound(); // DisplaySlots
@@ -280,7 +280,7 @@ bool cScoreboardSerializer::LoadScoreboardFromNBT(const cParsedNBT & a_NBT)
{
AString Name, DisplayName, Prefix, Suffix;
- bool AllowsFriendlyFire = false, CanSeeFriendlyInvisible = false;
+ bool AllowsFriendlyFire = true, CanSeeFriendlyInvisible = false;
int CurrLine = a_NBT.FindChildByName(Child, "Name");
if (CurrLine >= 0)
@@ -346,7 +346,7 @@ bool cScoreboardSerializer::LoadScoreboardFromNBT(const cParsedNBT & a_NBT)
{
AString Name = a_NBT.GetString(CurrLine);
- m_ScoreBoard->SetDisplay(Name, cScoreboard::E_DISPLAY_SLOT_LIST);
+ m_ScoreBoard->SetDisplay(Name, cScoreboard::dsList);
}
CurrLine = a_NBT.FindChildByName(DisplaySlots, "slot_1");
@@ -354,7 +354,7 @@ bool cScoreboardSerializer::LoadScoreboardFromNBT(const cParsedNBT & a_NBT)
{
AString Name = a_NBT.GetString(CurrLine);
- m_ScoreBoard->SetDisplay(Name, cScoreboard::E_DISPLAY_SLOT_SIDEBAR);
+ m_ScoreBoard->SetDisplay(Name, cScoreboard::dsSidebar);
}
CurrLine = a_NBT.FindChildByName(DisplaySlots, "slot_2");
@@ -362,7 +362,7 @@ bool cScoreboardSerializer::LoadScoreboardFromNBT(const cParsedNBT & a_NBT)
{
AString Name = a_NBT.GetString(CurrLine);
- m_ScoreBoard->SetDisplay(Name, cScoreboard::E_DISPLAY_SLOT_NAME);
+ m_ScoreBoard->SetDisplay(Name, cScoreboard::dsName);
}
return true;