summaryrefslogtreecommitdiffstats
path: root/src/World.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-01-22 15:05:17 +0100
committerMattes D <github@xoft.cz>2014-01-22 15:05:17 +0100
commit26586fdb92c7924e47debf6946fbdbe06775ae19 (patch)
tree093a0fa1ad5de0cc2e7dd90f49a3a3ab6429ac5b /src/World.cpp
parentInfoDump: Can dump a single plugin without LFS. (diff)
parentcWorld now saves/loads the scoreboard (diff)
downloadcuberite-26586fdb92c7924e47debf6946fbdbe06775ae19.tar
cuberite-26586fdb92c7924e47debf6946fbdbe06775ae19.tar.gz
cuberite-26586fdb92c7924e47debf6946fbdbe06775ae19.tar.bz2
cuberite-26586fdb92c7924e47debf6946fbdbe06775ae19.tar.lz
cuberite-26586fdb92c7924e47debf6946fbdbe06775ae19.tar.xz
cuberite-26586fdb92c7924e47debf6946fbdbe06775ae19.tar.zst
cuberite-26586fdb92c7924e47debf6946fbdbe06775ae19.zip
Diffstat (limited to '')
-rw-r--r--src/World.cpp66
1 files changed, 65 insertions, 1 deletions
diff --git a/src/World.cpp b/src/World.cpp
index 5e9f4a38a..49d42f08e 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -12,6 +12,7 @@
#include "ChunkMap.h"
#include "Generating/ChunkDesc.h"
#include "OSSupport/Timer.h"
+#include "WorldStorage/ScoreboardSerializer.h"
// Entities (except mobs):
#include "Entities/ExpOrb.h"
@@ -242,11 +243,16 @@ cWorld::cWorld(const AString & a_WorldName) :
m_Weather(eWeather_Sunny),
m_WeatherInterval(24000), // Guaranteed 1 day of sunshine at server start :)
m_GeneratorCallbacks(*this),
- m_TickThread(*this)
+ m_TickThread(*this),
+ m_Scoreboard(this)
{
LOGD("cWorld::cWorld(\"%s\")", a_WorldName.c_str());
cFile::CreateFolder(FILE_IO_PREFIX + m_WorldName);
+
+ // Load the scoreboard
+ cScoreboardSerializer Serializer(m_WorldName, &m_Scoreboard);
+ Serializer.Load();
}
@@ -266,6 +272,10 @@ cWorld::~cWorld()
m_Storage.WaitForFinish();
+ // Unload the scoreboard
+ cScoreboardSerializer Serializer(m_WorldName, &m_Scoreboard);
+ Serializer.Save();
+
delete m_ChunkMap;
}
@@ -1981,6 +1991,60 @@ void cWorld::BroadcastRemoveEntityEffect(const cEntity & a_Entity, int a_EffectI
+void cWorld::BroadcastScoreboardObjective(const AString & a_Name, const AString & a_DisplayName, Byte a_Mode)
+{
+ cCSLock Lock(m_CSPlayers);
+ for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
+ {
+ cClientHandle * ch = (*itr)->GetClientHandle();
+ if ((ch == NULL) || !ch->IsLoggedIn() || ch->IsDestroyed())
+ {
+ continue;
+ }
+ ch->SendScoreboardObjective(a_Name, a_DisplayName, a_Mode);
+ }
+}
+
+
+
+
+
+void cWorld::BroadcastScoreUpdate(const AString & a_Objective, const AString & a_Player, cObjective::Score a_Score, Byte a_Mode)
+{
+ cCSLock Lock(m_CSPlayers);
+ for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
+ {
+ cClientHandle * ch = (*itr)->GetClientHandle();
+ if ((ch == NULL) || !ch->IsLoggedIn() || ch->IsDestroyed())
+ {
+ continue;
+ }
+ ch->SendScoreUpdate(a_Objective, a_Player, a_Score, a_Mode);
+ }
+}
+
+
+
+
+
+void cWorld::BroadcastDisplayObjective(const AString & a_Objective, cScoreboard::eDisplaySlot a_Display)
+{
+ cCSLock Lock(m_CSPlayers);
+ for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
+ {
+ cClientHandle * ch = (*itr)->GetClientHandle();
+ if ((ch == NULL) || !ch->IsLoggedIn() || ch->IsDestroyed())
+ {
+ continue;
+ }
+ ch->SendDisplayObjective(a_Objective, a_Display);
+ }
+}
+
+
+
+
+
void cWorld::BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude)
{
m_ChunkMap->BroadcastSoundEffect(a_SoundName, a_SrcX, a_SrcY, a_SrcZ, a_Volume, a_Pitch, a_Exclude);