Merged branch 'howaner/Options'.
This commit is contained in:
commit
f095e770b8
|
@ -124,44 +124,58 @@ void cPluginManager::ReloadPluginsNow(cIniFile & a_SettingsIni)
|
||||||
// Check if the Plugins section exists.
|
// Check if the Plugins section exists.
|
||||||
int KeyNum = a_SettingsIni.FindKey("Plugins");
|
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)
|
if (KeyNum == -1)
|
||||||
{
|
{
|
||||||
InsertDefaultPlugins(a_SettingsIni);
|
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);
|
AString PluginFile = a_SettingsIni.GetValue(KeyNum, i);
|
||||||
if (ValueName.compare("Plugin") == 0)
|
if (!PluginFile.empty())
|
||||||
{
|
{
|
||||||
AString PluginFile = a_SettingsIni.GetValue(KeyNum, i);
|
if (m_Plugins.find(PluginFile) != m_Plugins.end())
|
||||||
if (!PluginFile.empty())
|
|
||||||
{
|
{
|
||||||
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();
|
size_t NumLoadedPlugins = GetNumPlugins();
|
||||||
if (NumLoadedPlugins == 0)
|
if (NumLoadedPlugins == 0)
|
||||||
{
|
{
|
||||||
LOG("-- No Plugins Loaded --");
|
LOG("-- No Plugins Loaded --");
|
||||||
}
|
}
|
||||||
else if (NumLoadedPlugins > 1)
|
else if (NumLoadedPlugins == 1)
|
||||||
{
|
{
|
||||||
LOG("-- Loaded %i Plugins --", (int)NumLoadedPlugins);
|
LOG("-- Loaded 1 Plugin --");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOG("-- Loaded 1 Plugin --");
|
LOG("-- Loaded %i Plugins --", (int)NumLoadedPlugins);
|
||||||
}
|
}
|
||||||
CallHookPluginsLoaded();
|
CallHookPluginsLoaded();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
void cClientHandle::SendChat(const AString & a_Message, eMessageType a_ChatPrefix, const AString & a_AdditionalData)
|
||||||
{
|
{
|
||||||
bool ShouldAppendChatPrefixes = true;
|
cWorld * World = GetPlayer()->GetWorld();
|
||||||
|
if (World == NULL)
|
||||||
if (GetPlayer()->GetWorld() == NULL)
|
|
||||||
{
|
{
|
||||||
cWorld * World = cRoot::Get()->GetWorld(GetPlayer()->GetLoadedWorldName());
|
World = cRoot::Get()->GetWorld(GetPlayer()->GetLoadedWorldName());
|
||||||
if (World == NULL)
|
if (World == NULL)
|
||||||
{
|
{
|
||||||
World = cRoot::Get()->GetDefaultWorld();
|
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));
|
m_Protocol->SendChat(Message.append(a_Message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -882,7 +882,7 @@ void cPlayer::KilledBy(TakeDamageInfo & a_TDI)
|
||||||
m_World->SpawnItemPickups(Pickups, GetPosX(), GetPosY(), GetPosZ(), 10);
|
m_World->SpawnItemPickups(Pickups, GetPosX(), GetPosY(), GetPosZ(), 10);
|
||||||
SaveToDisk(); // Save it, yeah the world is a tough place !
|
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;
|
AString DamageText;
|
||||||
switch (a_TDI.DamageType)
|
switch (a_TDI.DamageType)
|
||||||
|
@ -1200,11 +1200,13 @@ unsigned int cPlayer::AwardAchievement(const eStatistic a_Ach)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// First time, announce it
|
if (m_World->ShouldBroadcastAchievementMessages())
|
||||||
cCompositeChat Msg;
|
{
|
||||||
Msg.SetMessageType(mtSuccess);
|
cCompositeChat Msg;
|
||||||
Msg.AddShowAchievementPart(GetName(), cStatInfo::GetName(a_Ach));
|
Msg.SetMessageType(mtSuccess);
|
||||||
m_World->BroadcastChat(Msg);
|
Msg.AddShowAchievementPart(GetName(), cStatInfo::GetName(a_Ach));
|
||||||
|
m_World->BroadcastChat(Msg);
|
||||||
|
}
|
||||||
|
|
||||||
// Increment the statistic
|
// Increment the statistic
|
||||||
StatValue New = m_Stats.AddValue(a_Ach);
|
StatValue New = m_Stats.AddValue(a_Ach);
|
||||||
|
|
|
@ -153,7 +153,7 @@ bool cGroupManager::LoadGroups()
|
||||||
AString Color = IniFile.GetValue(KeyName, "Color", "-");
|
AString Color = IniFile.GetValue(KeyName, "Color", "-");
|
||||||
if ((Color != "-") && (Color.length() >= 1))
|
if ((Color != "-") && (Color.length() >= 1))
|
||||||
{
|
{
|
||||||
Group->SetColor(cChatColor::Delimiter + Color[0]);
|
Group->SetColor(AString(cChatColor::Delimiter) + Color[0]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -269,12 +269,12 @@ void cRoot::LoadWorlds(cIniFile & IniFile)
|
||||||
{
|
{
|
||||||
// First get the default world
|
// First get the default world
|
||||||
AString DefaultWorldName = IniFile.GetValueSet("Worlds", "DefaultWorld", "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;
|
m_WorldsByName[ DefaultWorldName ] = m_pDefaultWorld;
|
||||||
|
|
||||||
// Then load the other worlds
|
// Then load the other worlds
|
||||||
unsigned int KeyNum = IniFile.FindKey("Worlds");
|
unsigned int KeyNum = IniFile.FindKey("Worlds");
|
||||||
unsigned int NumWorlds = IniFile.GetNumValues( KeyNum);
|
unsigned int NumWorlds = IniFile.GetNumValues(KeyNum);
|
||||||
if (NumWorlds <= 0)
|
if (NumWorlds <= 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -63,12 +63,12 @@ public: // tolua_export
|
||||||
const AString & GetDescription(void) const {return m_Description; }
|
const AString & GetDescription(void) const {return m_Description; }
|
||||||
|
|
||||||
// Player counts:
|
// Player counts:
|
||||||
int GetMaxPlayers(void) const {return m_MaxPlayers; }
|
int GetMaxPlayers(void) const { return m_MaxPlayers; }
|
||||||
int GetNumPlayers(void) const;
|
int GetNumPlayers(void) const;
|
||||||
void SetMaxPlayers(int a_MaxPlayers) { m_MaxPlayers = a_MaxPlayers; }
|
void SetMaxPlayers(int a_MaxPlayers) { m_MaxPlayers = a_MaxPlayers; }
|
||||||
|
|
||||||
// Hardcore mode or not:
|
// Hardcore mode or not:
|
||||||
bool IsHardcore(void) const {return m_bIsHardcore; }
|
bool IsHardcore(void) const { return m_bIsHardcore; }
|
||||||
|
|
||||||
// tolua_end
|
// tolua_end
|
||||||
|
|
||||||
|
|
|
@ -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
|
// 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_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
|
// Try to find the "SpawnPosition" key and coord values in the world configuration, set the flag if found
|
||||||
int KeyNum = IniFile.FindKey("SpawnPosition");
|
int KeyNum = IniFile.FindKey("SpawnPosition");
|
||||||
m_IsSpawnExplicitlySet =
|
m_IsSpawnExplicitlySet =
|
||||||
|
|
|
@ -621,6 +621,10 @@ public:
|
||||||
bool ShouldUseChatPrefixes(void) const { return m_bUseChatPrefixes; }
|
bool ShouldUseChatPrefixes(void) const { return m_bUseChatPrefixes; }
|
||||||
void SetShouldUseChatPrefixes(bool a_Flag) { m_bUseChatPrefixes = a_Flag; }
|
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; }
|
AString GetNetherWorldName(void) const { return m_NetherWorldName; }
|
||||||
void SetNetherWorldName(const AString & a_Name) { m_NetherWorldName = a_Name; }
|
void SetNetherWorldName(const AString & a_Name) { m_NetherWorldName = a_Name; }
|
||||||
|
|
||||||
|
@ -856,6 +860,9 @@ private:
|
||||||
double m_SpawnY;
|
double m_SpawnY;
|
||||||
double m_SpawnZ;
|
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_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.
|
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
|
Int64 m_WorldAge; // World age in ticks, calculated off of m_WorldAgeSecs
|
||||||
|
|
Loading…
Reference in New Issue
Block a user