From 9c7661f50f82fe265836f3279bf20b15aebba5b3 Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 30 Oct 2014 21:24:10 +0100 Subject: Added a MaxViewDistance option. --- src/World.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/World.cpp') diff --git a/src/World.cpp b/src/World.cpp index 2e079d447..4e6ca264f 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -283,6 +283,7 @@ cWorld::cWorld(const AString & a_WorldName, eDimension a_Dimension, const AStrin m_bCommandBlocksEnabled(true), m_bUseChatPrefixes(false), m_TNTShrapnelLevel(slNone), + m_MaxViewDistance(12), m_Scoreboard(this), m_MapManager(this), m_GeneratorCallbacks(*this), @@ -561,6 +562,8 @@ void cWorld::Start(void) m_BroadcastDeathMessages = IniFile.GetValueSetB("Broadcasting", "BroadcastDeathMessages", true); m_BroadcastAchievementMessages = IniFile.GetValueSetB("Broadcasting", "BroadcastAchievementMessages", true); + SetMaxViewDistance(IniFile.GetValueSetI("SpawnPosition", "MaxViewDistance", 12)); + // 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 = -- cgit v1.2.3 From 9f71a4e7aec04c4c7fa57ac4b82f27a21044f798 Mon Sep 17 00:00:00 2001 From: Lukas Pioch Date: Sun, 2 Nov 2014 21:01:23 +0100 Subject: Added FindAndDoWithUUID --- src/World.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/World.cpp') diff --git a/src/World.cpp b/src/World.cpp index 2e079d447..212566194 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -2729,6 +2729,28 @@ bool cWorld::FindAndDoWithPlayer(const AString & a_PlayerNameHint, cPlayerListCa +bool cWorld::FindAndDoWithUUID(const AString & a_PlayerUUID, cPlayerListCallback & a_Callback) +{ + cPlayer * FoundPlayer = nullptr; + cCSLock Lock(m_CSPlayers); + for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) + { + if ((*itr)->GetUUID() == a_PlayerUUID) { // Match found and exit + FoundPlayer = *itr; + break; + } + } + if (FoundPlayer != nullptr) + { + return a_Callback.Item (FoundPlayer); + } + return false; +} + + + + + // TODO: This interface is dangerous! cPlayer * cWorld::FindClosestPlayer(const Vector3d & a_Pos, float a_SightLimit, bool a_CheckLineOfSight) { -- cgit v1.2.3 From 269d76a208fcfc58c3c79d6e6a887b823d4f8f00 Mon Sep 17 00:00:00 2001 From: Lukas Pioch Date: Sun, 2 Nov 2014 21:38:17 +0100 Subject: Simplified FindAndDoWithUUID, formatted line --- src/World.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'src/World.cpp') diff --git a/src/World.cpp b/src/World.cpp index 212566194..1b4f4f171 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -2731,19 +2731,13 @@ bool cWorld::FindAndDoWithPlayer(const AString & a_PlayerNameHint, cPlayerListCa bool cWorld::FindAndDoWithUUID(const AString & a_PlayerUUID, cPlayerListCallback & a_Callback) { - cPlayer * FoundPlayer = nullptr; cCSLock Lock(m_CSPlayers); for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) { if ((*itr)->GetUUID() == a_PlayerUUID) { // Match found and exit - FoundPlayer = *itr; - break; + return a_Callback.Item (*itr); } } - if (FoundPlayer != nullptr) - { - return a_Callback.Item (FoundPlayer); - } return false; } -- cgit v1.2.3 From 13b20d6fe29ebccc60b6be0d3baa17e0353f4a06 Mon Sep 17 00:00:00 2001 From: Lukas Pioch Date: Wed, 5 Nov 2014 21:57:38 +0100 Subject: renamed FindAndDoWithUUID to DoWithPlayerByUUID, fixed style and comments, added description to APIDump --- src/World.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/World.cpp') diff --git a/src/World.cpp b/src/World.cpp index 1b4f4f171..1954854f3 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -2729,12 +2729,13 @@ bool cWorld::FindAndDoWithPlayer(const AString & a_PlayerNameHint, cPlayerListCa -bool cWorld::FindAndDoWithUUID(const AString & a_PlayerUUID, cPlayerListCallback & a_Callback) +bool cWorld::DoWithPlayerByUUID(const AString & a_PlayerUUID, cPlayerListCallback & a_Callback) { cCSLock Lock(m_CSPlayers); for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) { - if ((*itr)->GetUUID() == a_PlayerUUID) { // Match found and exit + if ((*itr)->GetUUID() == a_PlayerUUID) + { return a_Callback.Item (*itr); } } -- cgit v1.2.3 From 78fb7896313f2074fa814309901e30d4a4f218e2 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sat, 15 Nov 2014 15:16:52 +0100 Subject: Fixed a security problem with signs. --- src/World.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'src/World.cpp') diff --git a/src/World.cpp b/src/World.cpp index 68855e617..3178d41a6 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -2926,25 +2926,19 @@ bool cWorld::SetSignLines(int a_BlockX, int a_BlockY, int a_BlockZ, const AStrin AString Line2(a_Line2); AString Line3(a_Line3); AString Line4(a_Line4); + if (cRoot::Get()->GetPluginManager()->CallHookUpdatingSign(*this, a_BlockX, a_BlockY, a_BlockZ, Line1, Line2, Line3, Line4, a_Player)) { return false; } + if (m_ChunkMap->SetSignLines(a_BlockX, a_BlockY, a_BlockZ, Line1, Line2, Line3, Line4)) { cRoot::Get()->GetPluginManager()->CallHookUpdatedSign(*this, a_BlockX, a_BlockY, a_BlockZ, Line1, Line2, Line3, Line4, a_Player); return true; } - return false; -} - - - - -bool cWorld::UpdateSign(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player) -{ - return SetSignLines(a_BlockX, a_BlockY, a_BlockZ, a_Line1, a_Line2, a_Line3, a_Line4, a_Player); + return false; } -- cgit v1.2.3