summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-07-30 10:06:18 +0200
committermadmaxoft <github@xoft.cz>2014-07-30 10:06:18 +0200
commitf095e770b84178ad45cbf3ba484b6ee18a239cb7 (patch)
tree70cbfedf25e0abc83655471a8ce44fee99b878f6
parentFixed "Dependency" typos (diff)
parentChange Group->SetColor() again. (diff)
downloadcuberite-f095e770b84178ad45cbf3ba484b6ee18a239cb7.tar
cuberite-f095e770b84178ad45cbf3ba484b6ee18a239cb7.tar.gz
cuberite-f095e770b84178ad45cbf3ba484b6ee18a239cb7.tar.bz2
cuberite-f095e770b84178ad45cbf3ba484b6ee18a239cb7.tar.lz
cuberite-f095e770b84178ad45cbf3ba484b6ee18a239cb7.tar.xz
cuberite-f095e770b84178ad45cbf3ba484b6ee18a239cb7.tar.zst
cuberite-f095e770b84178ad45cbf3ba484b6ee18a239cb7.zip
Diffstat (limited to '')
-rw-r--r--src/Bindings/PluginManager.cpp46
-rw-r--r--src/ClientHandle.cpp19
-rw-r--r--src/Entities/Player.cpp14
-rw-r--r--src/GroupManager.cpp2
-rw-r--r--src/Root.cpp4
-rw-r--r--src/Server.h4
-rw-r--r--src/World.cpp3
-rw-r--r--src/World.h7
8 files changed, 57 insertions, 42 deletions
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp
index 3560b8660..89bfe3566 100644
--- a/src/Bindings/PluginManager.cpp
+++ b/src/Bindings/PluginManager.cpp
@@ -124,44 +124,58 @@ void cPluginManager::ReloadPluginsNow(cIniFile & a_SettingsIni)
// Check if the Plugins section exists.
int KeyNum = a_SettingsIni.FindKey("Plugins");
- // If it does, how many plugins are there?
- int NumPlugins = ((KeyNum != -1) ? (a_SettingsIni.GetNumValues(KeyNum)) : 0);
-
if (KeyNum == -1)
{
InsertDefaultPlugins(a_SettingsIni);
+ KeyNum = a_SettingsIni.FindKey("Plugins");
}
- else if (NumPlugins > 0)
+
+ // How many plugins are there?
+ int NumPlugins = a_SettingsIni.GetNumValues(KeyNum);
+
+ for (int i = 0; i < NumPlugins; i++)
{
- for (int i = 0; i < NumPlugins; i++)
+ AString ValueName = a_SettingsIni.GetValueName(KeyNum, i);
+ if (ValueName.compare("Plugin") == 0)
{
- AString ValueName = a_SettingsIni.GetValueName(KeyNum, i);
- if (ValueName.compare("Plugin") == 0)
+ AString PluginFile = a_SettingsIni.GetValue(KeyNum, i);
+ if (!PluginFile.empty())
{
- AString PluginFile = a_SettingsIni.GetValue(KeyNum, i);
- if (!PluginFile.empty())
+ if (m_Plugins.find(PluginFile) != m_Plugins.end())
{
- if (m_Plugins.find(PluginFile) != m_Plugins.end())
- {
- LoadPlugin(PluginFile);
- }
+ LoadPlugin(PluginFile);
}
}
}
}
+
+ // Remove invalid plugins from the PluginMap.
+ for (PluginMap::iterator itr = m_Plugins.begin(); itr != m_Plugins.end();)
+ {
+ if (itr->second == NULL)
+ {
+ PluginMap::iterator thiz = itr;
+ ++thiz;
+ m_Plugins.erase(itr);
+ itr = thiz;
+ continue;
+ }
+ ++itr;
+ }
+
size_t NumLoadedPlugins = GetNumPlugins();
if (NumLoadedPlugins == 0)
{
LOG("-- No Plugins Loaded --");
}
- else if (NumLoadedPlugins > 1)
+ else if (NumLoadedPlugins == 1)
{
- LOG("-- Loaded %i Plugins --", (int)NumLoadedPlugins);
+ LOG("-- Loaded 1 Plugin --");
}
else
{
- LOG("-- Loaded 1 Plugin --");
+ LOG("-- Loaded %i Plugins --", (int)NumLoadedPlugins);
}
CallHookPluginsLoaded();
}
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index b390bf2d6..30ec737be 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -1972,28 +1972,17 @@ 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 = GetPlayer()->GetWorld();
+ if (World == NULL)
{
- cWorld * World = cRoot::Get()->GetWorld(GetPlayer()->GetLoadedWorldName());
+ World = cRoot::Get()->GetWorld(GetPlayer()->GetLoadedWorldName());
if (World == NULL)
{
World = cRoot::Get()->GetDefaultWorld();
}
-
- if (!World->ShouldUseChatPrefixes())
- {
- ShouldAppendChatPrefixes = false;
- }
- }
- else if (!GetPlayer()->GetWorld()->ShouldUseChatPrefixes())
- {
- ShouldAppendChatPrefixes = false;
}
- AString Message = FormatMessageType(ShouldAppendChatPrefixes, a_ChatPrefix, a_AdditionalData);
-
+ AString Message = FormatMessageType(World->ShouldUseChatPrefixes(), a_ChatPrefix, a_AdditionalData);
m_Protocol->SendChat(Message.append(a_Message));
}
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index cf3322968..603fc7937 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -882,7 +882,7 @@ void cPlayer::KilledBy(TakeDamageInfo & a_TDI)
m_World->SpawnItemPickups(Pickups, GetPosX(), GetPosY(), GetPosZ(), 10);
SaveToDisk(); // Save it, yeah the world is a tough place !
- if (a_TDI.Attacker == NULL)
+ if ((a_TDI.Attacker == NULL) && m_World->ShouldBroadcastDeathMessages())
{
AString DamageText;
switch (a_TDI.DamageType)
@@ -1200,11 +1200,13 @@ unsigned int cPlayer::AwardAchievement(const eStatistic a_Ach)
}
else
{
- // First time, announce it
- cCompositeChat Msg;
- Msg.SetMessageType(mtSuccess);
- Msg.AddShowAchievementPart(GetName(), cStatInfo::GetName(a_Ach));
- m_World->BroadcastChat(Msg);
+ if (m_World->ShouldBroadcastAchievementMessages())
+ {
+ cCompositeChat Msg;
+ Msg.SetMessageType(mtSuccess);
+ Msg.AddShowAchievementPart(GetName(), cStatInfo::GetName(a_Ach));
+ m_World->BroadcastChat(Msg);
+ }
// Increment the statistic
StatValue New = m_Stats.AddValue(a_Ach);
diff --git a/src/GroupManager.cpp b/src/GroupManager.cpp
index 32c2f1c97..4c3dfc6f0 100644
--- a/src/GroupManager.cpp
+++ b/src/GroupManager.cpp
@@ -153,7 +153,7 @@ bool cGroupManager::LoadGroups()
AString Color = IniFile.GetValue(KeyName, "Color", "-");
if ((Color != "-") && (Color.length() >= 1))
{
- Group->SetColor(cChatColor::Delimiter + Color[0]);
+ Group->SetColor(AString(cChatColor::Delimiter) + Color[0]);
}
else
{
diff --git a/src/Root.cpp b/src/Root.cpp
index b65e9b067..af6aa5efb 100644
--- a/src/Root.cpp
+++ b/src/Root.cpp
@@ -269,12 +269,12 @@ void cRoot::LoadWorlds(cIniFile & IniFile)
{
// First get the default world
AString DefaultWorldName = IniFile.GetValueSet("Worlds", "DefaultWorld", "world");
- m_pDefaultWorld = new cWorld( DefaultWorldName.c_str());
+ m_pDefaultWorld = new cWorld(DefaultWorldName.c_str());
m_WorldsByName[ DefaultWorldName ] = m_pDefaultWorld;
// Then load the other worlds
unsigned int KeyNum = IniFile.FindKey("Worlds");
- unsigned int NumWorlds = IniFile.GetNumValues( KeyNum);
+ unsigned int NumWorlds = IniFile.GetNumValues(KeyNum);
if (NumWorlds <= 0)
{
return;
diff --git a/src/Server.h b/src/Server.h
index b03359f03..c1640b388 100644
--- a/src/Server.h
+++ b/src/Server.h
@@ -63,12 +63,12 @@ public: // tolua_export
const AString & GetDescription(void) const {return m_Description; }
// Player counts:
- int GetMaxPlayers(void) const {return m_MaxPlayers; }
+ int GetMaxPlayers(void) const { return m_MaxPlayers; }
int GetNumPlayers(void) const;
void SetMaxPlayers(int a_MaxPlayers) { m_MaxPlayers = a_MaxPlayers; }
// Hardcore mode or not:
- bool IsHardcore(void) const {return m_bIsHardcore; }
+ bool IsHardcore(void) const { return m_bIsHardcore; }
// tolua_end
diff --git a/src/World.cpp b/src/World.cpp
index 84c0f2b93..348498693 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -530,6 +530,9 @@ void cWorld::Start(void)
// If no configuration value is found, GetDimension() is written to file and the variable is written to again to ensure that cosmic rays haven't sneakily changed its value
m_Dimension = StringToDimension(IniFile.GetValueSet("General", "Dimension", DimensionToString(GetDimension())));
+ m_BroadcastDeathMessages = IniFile.GetValueSetB("Broadcasting", "BroadcastDeathMessages", true);
+ m_BroadcastAchievementMessages = IniFile.GetValueSetB("Broadcasting", "BroadcastAchievementMessages", true);
+
// Try to find the "SpawnPosition" key and coord values in the world configuration, set the flag if found
int KeyNum = IniFile.FindKey("SpawnPosition");
m_IsSpawnExplicitlySet =
diff --git a/src/World.h b/src/World.h
index 6649c4163..4d0ccf2dd 100644
--- a/src/World.h
+++ b/src/World.h
@@ -621,6 +621,10 @@ public:
bool ShouldUseChatPrefixes(void) const { return m_bUseChatPrefixes; }
void SetShouldUseChatPrefixes(bool a_Flag) { m_bUseChatPrefixes = a_Flag; }
+ bool ShouldBroadcastDeathMessages(void) const { return m_BroadcastDeathMessages; }
+ bool ShouldBroadcastAchievementMessages(void) const { return m_BroadcastAchievementMessages; }
+
+
AString GetNetherWorldName(void) const { return m_NetherWorldName; }
void SetNetherWorldName(const AString & a_Name) { m_NetherWorldName = a_Name; }
@@ -856,6 +860,9 @@ private:
double m_SpawnY;
double m_SpawnZ;
+ bool m_BroadcastDeathMessages;
+ bool m_BroadcastAchievementMessages;
+
double m_WorldAgeSecs; // World age, in seconds. Is only incremented, cannot be set by plugins.
double m_TimeOfDaySecs; // Time of day in seconds. Can be adjusted. Is wrapped to zero each day.
Int64 m_WorldAge; // World age in ticks, calculated off of m_WorldAgeSecs