From 7d03876a3e11aedff0201a8330bfdb2b5523fc5e Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 29 Jan 2014 19:22:03 +0000 Subject: Added LOGREPLACELINE for line replacement --- src/World.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/World.cpp') diff --git a/src/World.cpp b/src/World.cpp index 88bbf5f8a..bac529d4a 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -100,13 +100,13 @@ protected: { for (;;) { - LOG("%d chunks to load, %d chunks to generate", + LOGREPLACELINE("%d chunks to load, %d chunks to generate", m_World->GetStorage().GetLoadQueueLength(), m_World->GetGenerator().GetQueueLength() ); - // Wait for 2 sec, but be "reasonably wakeable" when the thread is to finish - for (int i = 0; i < 20; i++) + // Wait for 0.5 sec, but be "reasonably wakeable" when the thread is to finish + for (int i = 0; i < 5; i++) { cSleep::MilliSleep(100); if (m_ShouldTerminate) @@ -152,10 +152,10 @@ protected: { for (;;) { - LOG("%d chunks remaining to light", m_Lighting->GetQueueLength() + LOGREPLACELINE("%d chunks remaining to light", m_Lighting->GetQueueLength() ); - // Wait for 2 sec, but be "reasonably wakeable" when the thread is to finish + // Wait for 0.5 sec, but be "reasonably wakeable" when the thread is to finish for (int i = 0; i < 20; i++) { cSleep::MilliSleep(100); -- cgit v1.2.3 From d8aa0b0ec7a2ebea2fc157c623ae8cd7d0b6ba1c Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 31 Jan 2014 00:04:57 +0000 Subject: Improved code * Fixed some issues * Fixed standard violation --- src/World.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/World.cpp') diff --git a/src/World.cpp b/src/World.cpp index bac529d4a..f2981bf84 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -111,6 +111,7 @@ protected: cSleep::MilliSleep(100); if (m_ShouldTerminate) { + LOGREPLACELINE("World successfully loaded!"); return; } } @@ -161,6 +162,7 @@ protected: cSleep::MilliSleep(100); if (m_ShouldTerminate) { + LOGREPLACELINE("Lighting successful!"); return; } } -- cgit v1.2.3 From e26dc5cc0aaeb81ee7c6419ea91f8eef7d072ef3 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 1 Feb 2014 21:40:50 +0000 Subject: Added checks for ice into IsBlockWater() * This fixes players spawning in vast oceans of ice, as opposed to the previous water --- src/World.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/World.cpp') diff --git a/src/World.cpp b/src/World.cpp index f2981bf84..2571a6782 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -635,7 +635,7 @@ void cWorld::GenerateRandomSpawn(void) { LOGD("Generating random spawnpoint..."); - while (IsBlockWater(GetBlock((int)m_SpawnX, GetHeight((int)m_SpawnX, (int)m_SpawnZ), (int)m_SpawnZ))) + while (IsBlockWater(GetBlock((int)m_SpawnX, GetHeight((int)m_SpawnX, (int)m_SpawnZ), (int)m_SpawnZ), true)) { if ((GetTickRandomNumber(4) % 2) == 0) // Randomise whether to increment X or Z coords { -- cgit v1.2.3 From 55cfb232db9d7bf15dfa0d2e0816b4651331e2fd Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 2 Feb 2014 19:10:22 +0000 Subject: Possibly fixed #618 --- src/World.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/World.cpp') diff --git a/src/World.cpp b/src/World.cpp index 2571a6782..acfcf8e48 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -1639,7 +1639,7 @@ void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_FlyAwaySpeed /= 100; // Pre-divide, so that we don't have to divide each time inside the loop for (cItems::const_iterator itr = a_Pickups.begin(); itr != a_Pickups.end(); ++itr) { - if (!IsValidItem(itr->m_ItemType)) + if (!IsValidItem(itr->m_ItemType) || itr->m_ItemType == E_BLOCK_AIR) { // Don't spawn pickup if item isn't even valid; should prevent client crashing too continue; @@ -1665,7 +1665,7 @@ void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double { for (cItems::const_iterator itr = a_Pickups.begin(); itr != a_Pickups.end(); ++itr) { - if (!IsValidItem(itr->m_ItemType)) + if (!IsValidItem(itr->m_ItemType) || itr->m_ItemType == E_BLOCK_AIR) { continue; } -- cgit v1.2.3 From 6ef5c057aa2a36dbd54f56780e5700e753b37bcf Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 2 Feb 2014 20:10:23 +0000 Subject: Revert "Improved code" This reverts commit d8aa0b0ec7a2ebea2fc157c623ae8cd7d0b6ba1c. --- src/World.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/World.cpp') diff --git a/src/World.cpp b/src/World.cpp index acfcf8e48..5cd3e1478 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -111,7 +111,6 @@ protected: cSleep::MilliSleep(100); if (m_ShouldTerminate) { - LOGREPLACELINE("World successfully loaded!"); return; } } @@ -162,7 +161,6 @@ protected: cSleep::MilliSleep(100); if (m_ShouldTerminate) { - LOGREPLACELINE("Lighting successful!"); return; } } -- cgit v1.2.3 From d9a9052de733d88e49a2df9f455632c64f2c5b5d Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 2 Feb 2014 20:10:31 +0000 Subject: Revert "Added LOGREPLACELINE for line replacement" This reverts commit 7d03876a3e11aedff0201a8330bfdb2b5523fc5e. --- src/World.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/World.cpp') diff --git a/src/World.cpp b/src/World.cpp index 5cd3e1478..f598874ea 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -100,13 +100,13 @@ protected: { for (;;) { - LOGREPLACELINE("%d chunks to load, %d chunks to generate", + LOG("%d chunks to load, %d chunks to generate", m_World->GetStorage().GetLoadQueueLength(), m_World->GetGenerator().GetQueueLength() ); - // Wait for 0.5 sec, but be "reasonably wakeable" when the thread is to finish - for (int i = 0; i < 5; i++) + // Wait for 2 sec, but be "reasonably wakeable" when the thread is to finish + for (int i = 0; i < 20; i++) { cSleep::MilliSleep(100); if (m_ShouldTerminate) @@ -152,10 +152,10 @@ protected: { for (;;) { - LOGREPLACELINE("%d chunks remaining to light", m_Lighting->GetQueueLength() + LOG("%d chunks remaining to light", m_Lighting->GetQueueLength() ); - // Wait for 0.5 sec, but be "reasonably wakeable" when the thread is to finish + // Wait for 2 sec, but be "reasonably wakeable" when the thread is to finish for (int i = 0; i < 20; i++) { cSleep::MilliSleep(100); -- cgit v1.2.3 From 0f67f80c6e60b2696bf94ee91330cdc0cefde3fa Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 2 Feb 2014 21:48:21 +0000 Subject: Added IsBlockWaterOrIce() --- src/World.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/World.cpp') diff --git a/src/World.cpp b/src/World.cpp index f598874ea..d8850e78a 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -633,7 +633,7 @@ void cWorld::GenerateRandomSpawn(void) { LOGD("Generating random spawnpoint..."); - while (IsBlockWater(GetBlock((int)m_SpawnX, GetHeight((int)m_SpawnX, (int)m_SpawnZ), (int)m_SpawnZ), true)) + while (IsBlockWaterOrIce(GetBlock((int)m_SpawnX, GetHeight((int)m_SpawnX, (int)m_SpawnZ), (int)m_SpawnZ))) { if ((GetTickRandomNumber(4) % 2) == 0) // Randomise whether to increment X or Z coords { -- cgit v1.2.3