From 9692f20a99e32a7859e4e8522393d116f11517ba Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Wed, 13 Nov 2013 19:36:04 +0000 Subject: Fixed link error with clang on x86_64. --- GNUmakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GNUmakefile b/GNUmakefile index 338470592..e056a61ec 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -103,7 +103,7 @@ endif UNAME := $(shell uname -s) ifeq ($(UNAME),Linux) - LNK_LIBS = -lstdc++ -ldl + LNK_LIBS = -lstdc++ -ldl -lm else LNK_LIBS = -lstdc++ -lltdl endif -- cgit v1.2.3 From 26ac6881cd5985eefe08fc7307f4d09442b68fd1 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Wed, 13 Nov 2013 19:41:05 +0000 Subject: Fixed some of the comments in the makefile. --- GNUmakefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index e056a61ec..de1da1455 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -46,6 +46,7 @@ ifeq ($(release),1) ################ # release build - fastest run-time, no gdb support ################ + CC_OPTIONS = -s -g -O3 -DNDEBUG CXX_OPTIONS = -s -g -O3 -DNDEBUG LNK_OPTIONS = -pthread -O3 @@ -56,6 +57,7 @@ ifeq ($(profile),1) ################ # profile build - a release build with symbols and profiling engine built in ################ + CC_OPTIONS = -s -g -ggdb -O3 -pg -DNDEBUG CXX_OPTIONS = -s -g -ggdb -O3 -pg -DNDEBUG LNK_OPTIONS = -pthread -ggdb -O3 -pg @@ -66,6 +68,7 @@ ifeq ($(pedantic),1) ################ # pedantic build - basically a debug build with lots of warnings ################ + CC_OPTIONS = -s -g -ggdb -D_DEBUG -Wall -Wextra -pedantic -ansi -Wno-long-long CXX_OPTIONS = -s -g -ggdb -D_DEBUG -Wall -Wextra -pedantic -ansi -Wno-long-long LNK_OPTIONS = -pthread -ggdb @@ -76,6 +79,7 @@ else # debug build - fully traceable by gdb in C++ code, slowest # Since C code is used only for supporting libraries (zlib, lua), it is still O3-optimized ################ + CC_OPTIONS = -s -ggdb -g -D_DEBUG -O3 CXX_OPTIONS = -s -ggdb -g -D_DEBUG LNK_OPTIONS = -pthread -g -ggdb @@ -140,7 +144,6 @@ endif ################################################### # INCLUDE directories for MCServer -# INCLUDE = -I.\ -Isource\ @@ -162,9 +165,6 @@ INCLUDE = -I.\ ################################################### # Build MCServer -# - -# 2012_11_08 _X: Removed: squirrel_3_0_1_stable SOURCES := $(shell find CryptoPP lua-5.1.4 jsoncpp-src-0.5.0 zlib-1.2.7 source tolua++-1.0.93 iniFile expat '(' -name '*.cpp' -o -name '*.c' ')') SOURCES := $(filter-out %minigzip.c %lua.c %tolua.c %toluabind.c %LeakFinder.cpp %StackWalker.cpp %example.c,$(SOURCES)) -- cgit v1.2.3 From cd8894fca680eb315110ad481bf6d54090792a99 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Wed, 13 Nov 2013 19:53:39 +0000 Subject: Got rid of warnings caused by the -s option on Clang, and it doesn't seem to do anything anyway. --- GNUmakefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index de1da1455..e40748bef 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -47,8 +47,8 @@ ifeq ($(release),1) # release build - fastest run-time, no gdb support ################ -CC_OPTIONS = -s -g -O3 -DNDEBUG -CXX_OPTIONS = -s -g -O3 -DNDEBUG +CC_OPTIONS = -g -O3 -DNDEBUG +CXX_OPTIONS = -g -O3 -DNDEBUG LNK_OPTIONS = -pthread -O3 BUILDDIR = build/release/ -- cgit v1.2.3 From 3ea3da8b3f1800e6d13919f6ee2bd6d088c1906e Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Wed, 13 Nov 2013 20:09:24 +0000 Subject: Removed unnecessary format data. --- source/Log.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Log.cpp b/source/Log.cpp index fc19595db..a0de4531b 100644 --- a/source/Log.cpp +++ b/source/Log.cpp @@ -124,7 +124,7 @@ void cLog::Log(const char * a_Format, va_list argList) #endif if (m_File) { - fprintf(m_File, "%s\n", Line.c_str(), m_File); + fprintf(m_File, "%s\n", Line.c_str()); fflush(m_File); } -- cgit v1.2.3 From 56c23305d53e4113cfbd41f39252a19ab67c1f23 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Wed, 13 Nov 2013 20:13:35 +0000 Subject: Added the last bit of the enum, and alpha-sorted the switch. --- source/BlockID.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/source/BlockID.cpp b/source/BlockID.cpp index f8949577e..4467d7e82 100644 --- a/source/BlockID.cpp +++ b/source/BlockID.cpp @@ -461,23 +461,26 @@ eDimension StringToDimension(const AString & a_DimensionString) /// Translates damage type constant to a string representation (built-in). AString DamageTypeToString(eDamageType a_DamageType) { + // Make sure to keep this alpha-sorted. switch (a_DamageType) { + case dtAdmin: return "dtAdmin"; case dtAttack: return "dtAttack"; - case dtRangedAttack: return "dtRangedAttack"; - case dtLightning: return "dtLightning"; - case dtFalling: return "dtFalling"; - case dtDrowning: return "dtDrowning"; - case dtSuffocating: return "dtSuffocation"; - case dtStarving: return "dtStarving"; case dtCactusContact: return "dtCactusContact"; - case dtLavaContact: return "dtLavaContact"; - case dtPoisoning: return "dtPoisoning"; - case dtOnFire: return "dtOnFire"; + case dtDrowning: return "dtDrowning"; + case dtEnderPearl: return "dtEnderPearl"; + case dtFalling: return "dtFalling"; case dtFireContact: return "dtFireContact"; case dtInVoid: return "dtInVoid"; + case dtLavaContact: return "dtLavaContact"; + case dtLightning: return "dtLightning"; + case dtOnFire: return "dtOnFire"; + case dtPoisoning: return "dtPoisoning"; case dtPotionOfHarming: return "dtPotionOfHarming"; - case dtAdmin: return "dtAdmin"; + case dtRangedAttack: return "dtRangedAttack"; + case dtStarving: return "dtStarving"; + case dtSuffocating: return "dtSuffocation"; + } // Unknown damage type: -- cgit v1.2.3 From dc94b927534f6216a0ace7690ba250b69c014407 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Thu, 14 Nov 2013 07:38:59 +0000 Subject: Silenced another warning. --- source/Generating/StructGen.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/source/Generating/StructGen.cpp b/source/Generating/StructGen.cpp index 2180261aa..bd8f5d581 100644 --- a/source/Generating/StructGen.cpp +++ b/source/Generating/StructGen.cpp @@ -274,6 +274,7 @@ int cStructGenTrees::GetNumTrees( case biExtremeHillsEdge: Add = 5; break; case biJungle: Add = 120; break; case biJungleHills: Add = 90; break; + default: Add = 0; break; } NumTrees += Add; } -- cgit v1.2.3 From 444e6e4fa74e987880133bb52433b047ff3981b2 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Thu, 14 Nov 2013 07:42:03 +0000 Subject: Silenced yet another not completed enum warning. --- source/Generating/StructGen.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/source/Generating/StructGen.cpp b/source/Generating/StructGen.cpp index bd8f5d581..d9859aab5 100644 --- a/source/Generating/StructGen.cpp +++ b/source/Generating/StructGen.cpp @@ -595,6 +595,7 @@ void cStructGenDirectOverhangs::GenStructures(cChunkDesc & a_ChunkDesc) } // for y break; } + default: break; } // switch (biome) } // for z, x -- cgit v1.2.3 From 3328c80aec768cf0e64e48eb40e50bf02bfff59c Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Thu, 14 Nov 2013 07:42:54 +0000 Subject: Fixed another one. --- source/Generating/StructGen.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/source/Generating/StructGen.cpp b/source/Generating/StructGen.cpp index d9859aab5..c18783304 100644 --- a/source/Generating/StructGen.cpp +++ b/source/Generating/StructGen.cpp @@ -620,6 +620,7 @@ bool cStructGenDirectOverhangs::HasWantedBiome(cChunkDesc & a_ChunkDesc) const { return true; } + default: break; } } // for i return false; -- cgit v1.2.3 From eca23ed0b3558d5c6bca960a599924b888fd2468 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sat, 16 Nov 2013 17:49:14 +0000 Subject: Always warn about everything! This should help me in my efforts. --- GNUmakefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/GNUmakefile b/GNUmakefile index e40748bef..d8afc0525 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -88,6 +88,10 @@ endif endif endif +################################################## +# Always be warning. + +CXX_OPTIONS += -Wall ################################################### # Fix Crypto++ warnings in clang -- cgit v1.2.3 From 2f2fe8ab0c73bdc1e5b10cf815595757328b61d2 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sat, 16 Nov 2013 17:53:27 +0000 Subject: Revert "Fixed another one." This reverts commit 3328c80aec768cf0e64e48eb40e50bf02bfff59c. --- source/Generating/StructGen.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/source/Generating/StructGen.cpp b/source/Generating/StructGen.cpp index c18783304..d9859aab5 100644 --- a/source/Generating/StructGen.cpp +++ b/source/Generating/StructGen.cpp @@ -620,7 +620,6 @@ bool cStructGenDirectOverhangs::HasWantedBiome(cChunkDesc & a_ChunkDesc) const { return true; } - default: break; } } // for i return false; -- cgit v1.2.3 From 33e1439c809b8791e14e7946ab77cb3d6f9a3093 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sat, 16 Nov 2013 17:53:55 +0000 Subject: Revert "Silenced yet another not completed enum warning." This reverts commit 444e6e4fa74e987880133bb52433b047ff3981b2. --- source/Generating/StructGen.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/source/Generating/StructGen.cpp b/source/Generating/StructGen.cpp index d9859aab5..bd8f5d581 100644 --- a/source/Generating/StructGen.cpp +++ b/source/Generating/StructGen.cpp @@ -595,7 +595,6 @@ void cStructGenDirectOverhangs::GenStructures(cChunkDesc & a_ChunkDesc) } // for y break; } - default: break; } // switch (biome) } // for z, x -- cgit v1.2.3 From ab676060fa72e82773db4f0fbe53012483518f16 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sat, 16 Nov 2013 17:54:18 +0000 Subject: Revert "Silenced another warning." This reverts commit dc94b927534f6216a0ace7690ba250b69c014407. --- source/Generating/StructGen.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/source/Generating/StructGen.cpp b/source/Generating/StructGen.cpp index bd8f5d581..2180261aa 100644 --- a/source/Generating/StructGen.cpp +++ b/source/Generating/StructGen.cpp @@ -274,7 +274,6 @@ int cStructGenTrees::GetNumTrees( case biExtremeHillsEdge: Add = 5; break; case biJungle: Add = 120; break; case biJungleHills: Add = 90; break; - default: Add = 0; break; } NumTrees += Add; } -- cgit v1.2.3 From 9060fbf4b59c5e44de463b391eb6e5d1532ca9ef Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sat, 16 Nov 2013 18:15:12 +0000 Subject: Fixed a warning about unsigned int comparison - probably was a real issue. --- source/PluginManager.cpp | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/source/PluginManager.cpp b/source/PluginManager.cpp index 3ac2366ca..b384383e5 100644 --- a/source/PluginManager.cpp +++ b/source/PluginManager.cpp @@ -113,9 +113,13 @@ void cPluginManager::ReloadPluginsNow(cIniFile & a_SettingsIni) FindPlugins(); cServer::BindBuiltInConsoleCommands(); - - unsigned int KeyNum = a_SettingsIni.FindKey("Plugins"); + + // Check if the Plugins section exists. + int KeyNum = a_SettingsIni.FindKey("Plugins"); + + // If it does, how many plugins are there? unsigned int NumPlugins = ((KeyNum != -1) ? (a_SettingsIni.GetNumValues(KeyNum)) : 0); + if (KeyNum == -1) { InsertDefaultPlugins(a_SettingsIni); @@ -202,7 +206,7 @@ void cPluginManager::Tick(float a_Dt) bool cPluginManager::CallHookBlockToPickups( cWorld * a_World, cEntity * a_Digger, - int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, + int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cItems & a_Pickups ) { @@ -247,7 +251,7 @@ bool cPluginManager::CallHookChat(cPlayer * a_Player, AString & a_Message) { return false; } - + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { if ((*itr)->OnChat(a_Player, a_Message)) @@ -255,7 +259,7 @@ bool cPluginManager::CallHookChat(cPlayer * a_Player, AString & a_Message) return true; } } - + return false; } @@ -1230,27 +1234,27 @@ bool cPluginManager::CallHookWorldTick(cWorld & a_World, float a_Dt) bool cPluginManager::HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions) { ASSERT(a_Player != NULL); - + AStringVector Split(StringSplit(a_Command, " ")); if (Split.empty()) { return false; } - + CommandMap::iterator cmd = m_Commands.find(Split[0]); if (cmd == m_Commands.end()) { // Command not found return false; } - + // Ask plugins first if a command is okay to execute the command: if (CallHookExecuteCommand(a_Player, Split)) { LOGINFO("Player \"%s\" tried executing command \"%s\" that was stopped by the HOOK_EXECUTE_COMMAND hook", a_Player->GetName().c_str(), Split[0].c_str()); return false; } - + if ( a_ShouldCheckPermissions && !cmd->second.m_Permission.empty() && @@ -1262,8 +1266,8 @@ bool cPluginManager::HandleCommand(cPlayer * a_Player, const AString & a_Command } ASSERT(cmd->second.m_Plugin != NULL); - - return cmd->second.m_Plugin->HandleCommand(Split, a_Player); + + return cmd->second.m_Plugin->HandleCommand(Split, a_Player); } @@ -1320,7 +1324,7 @@ bool cPluginManager::DisablePlugin(const AString & a_PluginName) { return false; } - + if (itr->first.compare(a_PluginName) == 0) // _X 2013_02_01: wtf? Isn't this supposed to be what find() does? { m_DisablePluginList.push_back(itr->second); @@ -1365,7 +1369,7 @@ void cPluginManager::RemovePlugin(cPlugin * a_Plugin) break; } } - + RemovePluginCommands(a_Plugin); RemovePluginConsoleCommands(a_Plugin); RemoveHooks(a_Plugin); @@ -1386,7 +1390,7 @@ void cPluginManager::RemovePluginCommands(cPlugin * a_Plugin) { a_Plugin->ClearCommands(); } - + for (CommandMap::iterator itr = m_Commands.begin(); itr != m_Commands.end();) { if (itr->second.m_Plugin == a_Plugin) @@ -1414,7 +1418,7 @@ bool cPluginManager::BindCommand(const AString & a_Command, cPlugin * a_Plugin, LOGWARNING("Command \"%s\" is already bound to plugin \"%s\".", a_Command.c_str(), cmd->second.m_Plugin->GetName().c_str()); return false; } - + m_Commands[a_Command].m_Plugin = a_Plugin; m_Commands[a_Command].m_Permission = a_Permission; m_Commands[a_Command].m_HelpString = a_HelpString; @@ -1484,7 +1488,7 @@ void cPluginManager::RemovePluginConsoleCommands(cPlugin * a_Plugin) { a_Plugin->ClearConsoleCommands(); } - + for (CommandMap::iterator itr = m_ConsoleCommands.begin(); itr != m_ConsoleCommands.end();) { if (itr->second.m_Plugin == a_Plugin) @@ -1519,7 +1523,7 @@ bool cPluginManager::BindConsoleCommand(const AString & a_Command, cPlugin * a_P } return false; } - + m_ConsoleCommands[a_Command].m_Plugin = a_Plugin; m_ConsoleCommands[a_Command].m_Permission = ""; m_ConsoleCommands[a_Command].m_HelpString = a_HelpString; @@ -1561,20 +1565,20 @@ bool cPluginManager::ExecuteConsoleCommand(const AStringVector & a_Split, cComma { return false; } - + CommandMap::iterator cmd = m_ConsoleCommands.find(a_Split[0]); if (cmd == m_ConsoleCommands.end()) { // Command not found return false; } - + if (cmd->second.m_Plugin == NULL) { // This is a built-in command return false; } - + // Ask plugins first if a command is okay to execute the console command: if (CallHookExecuteCommand(NULL, a_Split)) { @@ -1582,7 +1586,7 @@ bool cPluginManager::ExecuteConsoleCommand(const AStringVector & a_Split, cComma return false; } - return cmd->second.m_Plugin->HandleConsoleCommand(a_Split, a_Output); + return cmd->second.m_Plugin->HandleConsoleCommand(a_Split, a_Output); } @@ -1656,7 +1660,7 @@ void cPluginManager::AddHook(cPlugin * a_Plugin, int a_Hook) unsigned int cPluginManager::GetNumPlugins() const { - return m_Plugins.size(); + return m_Plugins.size(); } -- cgit v1.2.3 From 5337fee8e084e787151b2c460d0130cffcdbccfa Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sat, 16 Nov 2013 18:26:46 +0000 Subject: Fixed a warning about brackets. Is this the right way round? This is how C++ interprets it, so it should be changed if this is the wrong way round. --- source/Generating/MineShafts.cpp | 116 +++++++++++++++++++-------------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/source/Generating/MineShafts.cpp b/source/Generating/MineShafts.cpp index 3131b5429..e7884f243 100644 --- a/source/Generating/MineShafts.cpp +++ b/source/Generating/MineShafts.cpp @@ -41,8 +41,8 @@ public: mskCrossing, mskStaircase, } ; - - + + enum eDirection { dirXP, @@ -50,8 +50,8 @@ public: dirXM, dirZM, } ; - - + + cStructGenMineShafts::cMineShaftSystem & m_ParentSystem; eKind m_Kind; cCuboid m_BoundingBox; @@ -62,25 +62,25 @@ public: m_Kind(a_Kind) { } - + cMineShaft(cStructGenMineShafts::cMineShaftSystem & a_ParentSystem, eKind a_Kind, const cCuboid & a_BoundingBox) : m_ParentSystem(a_ParentSystem), m_Kind(a_Kind), m_BoundingBox(a_BoundingBox) { } - + /// Returns true if this mineshaft intersects the specified cuboid bool DoesIntersect(const cCuboid & a_Other) { return m_BoundingBox.DoesIntersect(a_Other); } - + /** If recursion level is not too large, appends more branches to the parent system, using exit points specific to this class. */ virtual void AppendBranches(int a_RecursionLevel, cNoise & a_Noise) = 0; - + /// Imprints this shape into the specified chunk's data virtual void ProcessChunk(cChunkDesc & a_ChunkDesc) = 0; } ; @@ -95,10 +95,10 @@ class cMineShaftDirtRoom : public cMineShaft { typedef cMineShaft super; - + public: cMineShaftDirtRoom(cStructGenMineShafts::cMineShaftSystem & a_Parent, cNoise & a_Noise); - + // cMineShaft overrides: virtual void AppendBranches(int a_RecursionLevel, cNoise & a_Noise) override; virtual void ProcessChunk(cChunkDesc & a_ChunkDesc) override; @@ -112,7 +112,7 @@ class cMineShaftCorridor : public cMineShaft { typedef cMineShaft super; - + public: /** Creates a new Corridor attached to the specified pivot point and direction. Checks all ParentSystem's objects and disallows intersecting. Initializes the new object to fit. @@ -123,36 +123,36 @@ public: int a_PivotX, int a_PivotY, int a_PivotZ, eDirection a_Direction, cNoise & a_Noise ); - + protected: static const int MAX_SEGMENTS = 5; - + int m_NumSegments; eDirection m_Direction; bool m_HasFullBeam[MAX_SEGMENTS]; ///< If true, segment at that index has a full beam support (planks in the top center block) int m_ChestPosition; ///< If <0, no chest; otherwise an offset from m_BoundingBox's p1.x or p1.z, depenging on m_Direction int m_SpawnerPosition; ///< If <0, no spawner; otherwise an offset from m_BoundingBox's p1.x or p1.z, depenging on m_Direction bool m_HasTracks; ///< If true, random tracks will be placed on the floor - + cMineShaftCorridor( cStructGenMineShafts::cMineShaftSystem & a_ParentSystem, const cCuboid & a_BoundingBox, int a_NumSegments, eDirection a_Direction, cNoise & a_Noise ); - + // cMineShaft overrides: virtual void AppendBranches(int a_RecursionLevel, cNoise & a_Noise) override; virtual void ProcessChunk(cChunkDesc & a_ChunkDesc) override; /// Places a chest, if the corridor has one void PlaceChest(cChunkDesc & a_ChunkDesc); - + /// If this corridor has tracks, places them randomly void PlaceTracks(cChunkDesc & a_ChunkDesc); - + /// If this corridor has a spawner, places the spawner void PlaceSpawner(cChunkDesc & a_ChunkDesc); - + /// Randomly places torches around the central beam block void PlaceTorches(cChunkDesc & a_ChunkDesc); } ; @@ -165,7 +165,7 @@ class cMineShaftCrossing : public cMineShaft { typedef cMineShaft super; - + public: /** Creates a new Crossing attached to the specified pivot point and direction. Checks all ParentSystem's objects and disallows intersecting. Initializes the new object to fit. @@ -176,10 +176,10 @@ public: int a_PivotX, int a_PivotY, int a_PivotZ, eDirection a_Direction, cNoise & a_Noise ); - + protected: cMineShaftCrossing(cStructGenMineShafts::cMineShaftSystem & a_ParentSystem, const cCuboid & a_BoundingBox); - + // cMineShaft overrides: virtual void AppendBranches(int a_RecursionLevel, cNoise & a_Noise) override; virtual void ProcessChunk(cChunkDesc & a_ChunkDesc) override; @@ -193,14 +193,14 @@ class cMineShaftStaircase : public cMineShaft { typedef cMineShaft super; - + public: enum eSlope { sUp, sDown, } ; - + /** Creates a new Staircase attached to the specified pivot point and direction. Checks all ParentSystem's objects and disallows intersecting. Initializes the new object to fit. May return NULL if cannot fit. @@ -210,12 +210,12 @@ public: int a_PivotX, int a_PivotY, int a_PivotZ, eDirection a_Direction, cNoise & a_Noise ); - + protected: eDirection m_Direction; eSlope m_Slope; - - + + cMineShaftStaircase( cStructGenMineShafts::cMineShaftSystem & a_ParentSystem, const cCuboid & a_BoundingBox, @@ -257,7 +257,7 @@ public: /// Carves the system into the chunk data void ProcessChunk(cChunkDesc & a_Chunk); - + /** Creates new cMineShaft descendant connected at the specified point, heading the specified direction, if it fits, appends it to the list and calls its AppendBranches() */ @@ -266,7 +266,7 @@ public: cMineShaft::eDirection a_Direction, cNoise & a_Noise, int a_RecursionLevel ); - + /// Returns true if none of the objects in m_MineShafts intersect with the specified bounding box and the bounding box is valid bool CanAppend(const cCuboid & a_BoundingBox); } ; @@ -294,7 +294,7 @@ cStructGenMineShafts::cMineShaftSystem::cMineShaftSystem( m_ChanceTorch(1000) // TODO: settable { m_MineShafts.reserve(100); - + cMineShaft * Start = new cMineShaftDirtRoom(*this, a_Noise); m_MineShafts.push_back(Start); @@ -302,9 +302,9 @@ cStructGenMineShafts::cMineShaftSystem::cMineShaftSystem( Start->m_BoundingBox.p1.x - a_MaxSystemSize / 2, 2, Start->m_BoundingBox.p1.z - a_MaxSystemSize / 2, Start->m_BoundingBox.p2.x + a_MaxSystemSize / 2, 50, Start->m_BoundingBox.p2.z + a_MaxSystemSize / 2 ); - + Start->AppendBranches(0, a_Noise); - + for (cMineShafts::const_iterator itr = m_MineShafts.begin(), end = m_MineShafts.end(); itr != end; ++itr) { ASSERT((*itr)->m_BoundingBox.IsSorted()); @@ -341,7 +341,7 @@ void cStructGenMineShafts::cMineShaftSystem::ProcessChunk(cChunkDesc & a_Chunk) void cStructGenMineShafts::cMineShaftSystem::AppendBranch( - int a_PivotX, int a_PivotY, int a_PivotZ, + int a_PivotX, int a_PivotY, int a_PivotZ, cMineShaft::eDirection a_Direction, cNoise & a_Noise, int a_RecursionLevel ) @@ -350,7 +350,7 @@ void cStructGenMineShafts::cMineShaftSystem::AppendBranch( { return; } - + cMineShaft * Next = NULL; int rnd = (a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + a_RecursionLevel * 16, a_PivotZ) / 13) % m_ProbLevelStaircase; if (rnd < m_ProbLevelCorridor) @@ -384,7 +384,7 @@ bool cStructGenMineShafts::cMineShaftSystem::CanAppend(const cCuboid & a_Boundin // Too far away, or too low / too high return false; } - + // Check intersections: for (cMineShafts::const_iterator itr = m_MineShafts.begin(), end = m_MineShafts.end(); itr != end; ++itr) { @@ -436,7 +436,7 @@ void cMineShaftDirtRoom::AppendBranches(int a_RecursionLevel, cNoise & a_Noise) rnd >>= 4; m_ParentSystem.AppendBranch(x, m_BoundingBox.p1.y + (rnd % Height), m_BoundingBox.p2.z + 1, dirZP, a_Noise, a_RecursionLevel); } - + for (int z = m_BoundingBox.p1.z + 1; z < m_BoundingBox.p2.z; z += 4) { int rnd = a_Noise.IntNoise3DInt(m_BoundingBox.p1.x, a_RecursionLevel, z) / 13; @@ -464,13 +464,13 @@ void cMineShaftDirtRoom::ProcessChunk(cChunkDesc & a_ChunkDesc) // Early bailout - cannot intersect this chunk return; } - + // Chunk-relative coords of the boundaries: int MinX = std::max(BlockX, m_BoundingBox.p1.x) - BlockX; int MaxX = std::min(BlockX + cChunkDef::Width, m_BoundingBox.p2.x + 1) - BlockX; int MinZ = std::max(BlockZ, m_BoundingBox.p1.z) - BlockZ; int MaxZ = std::min(BlockZ + cChunkDef::Width, m_BoundingBox.p2.z + 1) - BlockZ; - + // Carve the room out: for (int z = MinZ; z < MaxZ; z++) { @@ -513,7 +513,7 @@ cMineShaftCorridor::cMineShaftCorridor( rnd >>= 2; } m_HasTracks = ((rnd % 4) < 2); // 50 % chance of tracks - + rnd = a_Noise.IntNoise3DInt(a_BoundingBox.p1.z, a_BoundingBox.p1.x, a_BoundingBox.p1.y) / 7; int ChestCheck = rnd % 250; rnd >>= 8; @@ -597,7 +597,7 @@ void cMineShaftCorridor::AppendBranches(int a_RecursionLevel, cNoise & a_Noise) } break; } - + case dirZM: { m_ParentSystem.AppendBranch(m_BoundingBox.p1.x + 1, Height, m_BoundingBox.p1.z - 1, dirZM, a_Noise, a_RecursionLevel); @@ -646,14 +646,14 @@ void cMineShaftCorridor::ProcessChunk(cChunkDesc & a_ChunkDesc) Top.p2.y += 1; Top.p1.y = Top.p2.y; a_ChunkDesc.FillRelCuboid(RelBoundingBox, E_BLOCK_AIR, 0); - a_ChunkDesc.RandomFillRelCuboid(Top, E_BLOCK_AIR, 0, BlockX ^ BlockZ + BlockX, 8000); + a_ChunkDesc.RandomFillRelCuboid(Top, E_BLOCK_AIR, 0, (BlockX ^ (BlockZ + BlockX)), 8000); if (m_SpawnerPosition >= 0) { // Cobwebs around the spider spawner - a_ChunkDesc.RandomFillRelCuboid(RelBoundingBox, E_BLOCK_COBWEB, 0, BlockX ^ BlockZ + BlockZ, 8000); - a_ChunkDesc.RandomFillRelCuboid(Top, E_BLOCK_COBWEB, 0, BlockX ^ BlockZ + BlockX, 5000); + a_ChunkDesc.RandomFillRelCuboid(RelBoundingBox, E_BLOCK_COBWEB, 0, (BlockX ^ (BlockZ + BlockZ)), 8000); + a_ChunkDesc.RandomFillRelCuboid(Top, E_BLOCK_COBWEB, 0, (BlockX ^ (BlockZ + BlockX)), 5000); } - a_ChunkDesc.RandomFillRelCuboid(Top, E_BLOCK_COBWEB, 0, BlockX ^ BlockZ + BlockX + 10, 500); + a_ChunkDesc.RandomFillRelCuboid(Top, E_BLOCK_COBWEB, 0, (BlockX ^ (BlockZ + BlockX + 10)), 500); RelBoundingBox.p1.y = m_BoundingBox.p1.y; RelBoundingBox.p2.y = m_BoundingBox.p1.y; a_ChunkDesc.FloorRelCuboid(RelBoundingBox, E_BLOCK_PLANKS, 0); @@ -693,7 +693,7 @@ void cMineShaftCorridor::ProcessChunk(cChunkDesc & a_ChunkDesc) } // for i - NumSegments break; } - + case dirZM: case dirZP: { @@ -729,7 +729,7 @@ void cMineShaftCorridor::ProcessChunk(cChunkDesc & a_ChunkDesc) break; } // case dirZ? } // for i - + PlaceChest(a_ChunkDesc); PlaceTracks(a_ChunkDesc); PlaceSpawner(a_ChunkDesc); // (must be after Tracks!) @@ -762,7 +762,7 @@ void cMineShaftCorridor::PlaceChest(cChunkDesc & a_ChunkDesc) { return; } - + int BlockX = a_ChunkDesc.GetChunkX() * cChunkDef::Width; int BlockZ = a_ChunkDesc.GetChunkZ() * cChunkDef::Width; int x, z; @@ -777,7 +777,7 @@ void cMineShaftCorridor::PlaceChest(cChunkDesc & a_ChunkDesc) Meta = E_META_CHEST_FACING_ZP; break; } - + case dirZM: case dirZP: { @@ -829,7 +829,7 @@ void cMineShaftCorridor::PlaceTracks(cChunkDesc & a_ChunkDesc) Meta = E_META_TRACKS_X; break; } - + case dirZM: case dirZP: { @@ -921,7 +921,7 @@ void cMineShaftCorridor::PlaceTorches(cChunkDesc & a_ChunkDesc) } // for i break; } - + case dirZM: case dirZP: { @@ -1041,7 +1041,7 @@ void cMineShaftCrossing::AppendBranches(int a_RecursionLevel, cNoise & a_Noise) // This exit is not available (two-level exit on a one-level crossing) continue; } - + int Height = m_BoundingBox.p1.y + Exits[i].y; m_ParentSystem.AppendBranch(m_BoundingBox.p1.x + Exits[i].x, Height, m_BoundingBox.p1.z + Exits[i].z, Exits[i].dir, a_Noise, a_RecursionLevel); } // for i @@ -1089,7 +1089,7 @@ void cMineShaftCrossing::ProcessChunk(cChunkDesc & a_ChunkDesc) a_ChunkDesc.FillRelCuboid(box.p1.x + 1, box.p2.x - 1, Mid, Ceil, box.p1.z, box.p1.z, E_BLOCK_AIR, 0); a_ChunkDesc.FillRelCuboid(box.p1.x + 1, box.p2.x - 1, Mid, Ceil, box.p2.z, box.p2.z, E_BLOCK_AIR, 0); } - + // The floor, if needed: box.p2.y = box.p1.y; a_ChunkDesc.FloorRelCuboid(box, E_BLOCK_PLANKS, 0); @@ -1198,7 +1198,7 @@ void cMineShaftStaircase::ProcessChunk(cChunkDesc & a_ChunkDesc) // No intersection between this staircase and this chunk return; } - + int SFloor = RelB.p1.y + ((m_Slope == sDown) ? 5 : 1); int DFloor = RelB.p1.y + ((m_Slope == sDown) ? 1 : 5); int Add = (m_Slope == sDown) ? -1 : 1; @@ -1221,7 +1221,7 @@ void cMineShaftStaircase::ProcessChunk(cChunkDesc & a_ChunkDesc) } break; } - + case dirXP: { a_ChunkDesc.FillRelCuboid (RelB.p1.x, RelB.p1.x + 1, SFloor, SFloor + 2, RelB.p1.z, RelB.p2.z, E_BLOCK_AIR, 0); @@ -1253,7 +1253,7 @@ void cMineShaftStaircase::ProcessChunk(cChunkDesc & a_ChunkDesc) } break; } - + case dirZP: { a_ChunkDesc.FillRelCuboid (RelB.p1.x, RelB.p2.x, SFloor, SFloor + 2, RelB.p1.z, RelB.p1.z + 1, E_BLOCK_AIR, 0); @@ -1269,7 +1269,7 @@ void cMineShaftStaircase::ProcessChunk(cChunkDesc & a_ChunkDesc) } break; } - + } // switch (m_Direction) } @@ -1359,7 +1359,7 @@ void cStructGenMineShafts::GetMineShaftSystemsForChunk( ++itr; } } // for itr - m_Cache[] - + for (int x = 0; x < NEIGHBORHOOD_SIZE; x++) { int RealX = (BaseX + x) * m_GridSize; @@ -1381,11 +1381,11 @@ void cStructGenMineShafts::GetMineShaftSystemsForChunk( } } // for z } // for x - + // Copy a_MineShafts into m_Cache to the beginning: cMineShaftSystems MineShaftsCopy(a_MineShafts); m_Cache.splice(m_Cache.begin(), MineShaftsCopy, MineShaftsCopy.begin(), MineShaftsCopy.end()); - + // Trim the cache if it's too long: if (m_Cache.size() > 100) { -- cgit v1.2.3 From 574e8f1419e9da7472bcd5b0813cc1d0e33fcf17 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sat, 16 Nov 2013 18:27:30 +0000 Subject: Fixed unsigned integer comparison. --- source/Generating/MineShafts.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Generating/MineShafts.cpp b/source/Generating/MineShafts.cpp index e7884f243..bd8da6515 100644 --- a/source/Generating/MineShafts.cpp +++ b/source/Generating/MineShafts.cpp @@ -1034,7 +1034,7 @@ void cMineShaftCrossing::AppendBranches(int a_RecursionLevel, cNoise & a_Noise) { 5, 5, 2, dirXP}, { 2, 5, 5, dirZP}, } ; - for (int i = 0; i < ARRAYCOUNT(Exits); i++) + for (unsigned int i = 0; i < ARRAYCOUNT(Exits); i++) { if (m_BoundingBox.p1.y + Exits[i].y >= m_BoundingBox.p2.y) { -- cgit v1.2.3 From f217981de99037e8e8e37222992886235f64b05b Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sat, 16 Nov 2013 18:34:54 +0000 Subject: Fixed another unsigned integer comparison. --- source/Generating/DistortedHeightmap.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/source/Generating/DistortedHeightmap.cpp b/source/Generating/DistortedHeightmap.cpp index 98eab31b5..7e46c251e 100644 --- a/source/Generating/DistortedHeightmap.cpp +++ b/source/Generating/DistortedHeightmap.cpp @@ -30,7 +30,7 @@ const cDistortedHeightmap::sGenParam cDistortedHeightmap::m_GenParam[biNumBiomes /* biExtremeHills */ {16.0f, 16.0f}, /* biForest */ { 3.0f, 3.0f}, /* biTaiga */ { 1.5f, 1.5f}, - + /* biSwampland */ { 0.0f, 0.0f}, /* biRiver */ { 0.0f, 0.0f}, /* biNether */ { 0.0f, 0.0f}, // Unused, but must be here due to indexing @@ -81,7 +81,7 @@ void cDistortedHeightmap::Initialize(cIniFile & a_IniFile) { return; } - + // Read the params from the INI file: m_SeaLevel = a_IniFile.GetValueSetI("Generator", "DistortedHeightmapSeaLevel", 62); m_FrequencyX = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "DistortedHeightmapFrequencyX", 10); @@ -103,8 +103,8 @@ void cDistortedHeightmap::PrepareState(int a_ChunkX, int a_ChunkZ) } m_CurChunkX = a_ChunkX; m_CurChunkZ = a_ChunkZ; - - + + m_HeightGen.GenHeightMap(a_ChunkX, a_ChunkZ, m_CurChunkHeights); UpdateDistortAmps(); GenerateHeightArray(); @@ -126,13 +126,13 @@ void cDistortedHeightmap::GenerateHeightArray(void) NOISE_DATATYPE EndY = ((NOISE_DATATYPE)(257)) / m_FrequencyY; NOISE_DATATYPE StartZ = ((NOISE_DATATYPE)(m_CurChunkZ * cChunkDef::Width)) / m_FrequencyZ; NOISE_DATATYPE EndZ = ((NOISE_DATATYPE)((m_CurChunkZ + 1) * cChunkDef::Width - 1)) / m_FrequencyZ; - + m_NoiseDistortX.Generate3D(DistortNoiseX, DIM_X, DIM_Y, DIM_Z, StartX, EndX, StartY, EndY, StartZ, EndZ, Workspace); m_NoiseDistortZ.Generate3D(DistortNoiseZ, DIM_X, DIM_Y, DIM_Z, StartX, EndX, StartY, EndY, StartZ, EndZ, Workspace); // The distorted heightmap, before linear upscaling NOISE_DATATYPE DistHei[DIM_X * DIM_Y * DIM_Z]; - + // Distort the heightmap using the distortion: for (int z = 0; z < DIM_Z; z++) { @@ -151,7 +151,7 @@ void cDistortedHeightmap::GenerateHeightArray(void) } } } - + // Upscale the distorted heightmap into full dimensions: LinearUpscale3DArray( DistHei, DIM_X, DIM_Y, DIM_Z, @@ -208,7 +208,7 @@ void cDistortedHeightmap::ComposeTerrain(cChunkDesc & a_ChunkDesc) // Prepare the internal state for generating this chunk: PrepareState(a_ChunkDesc.GetChunkX(), a_ChunkDesc.GetChunkZ()); - + // Compose: a_ChunkDesc.FillBlocks(E_BLOCK_AIR, 0); for (int z = 0; z < cChunkDef::Width; z++) @@ -348,7 +348,7 @@ int cDistortedHeightmap::GetHeightmapAt(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Z) { return cChunkDef::GetHeight(m_CurChunkHeights, RelX, RelZ); } - + // Ask the cache: HEIGHTTYPE res = 0; if (m_HeightGen.GetHeightAt(ChunkX, ChunkZ, RelX, RelZ, res)) @@ -356,7 +356,7 @@ int cDistortedHeightmap::GetHeightmapAt(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Z) // The height was in the cache return res; } - + // The height is not in the cache, generate full heightmap and get it there: cChunkDef::HeightMap Heightmap; m_HeightGen.GenHeightMap(ChunkX, ChunkZ, Heightmap); @@ -385,7 +385,7 @@ void cDistortedHeightmap::UpdateDistortAmps(void) GetDistortAmpsAt(Biomes, x * INTERPOL_X, z * INTERPOL_Z, m_DistortAmpX[x + DIM_X * z], m_DistortAmpZ[x + DIM_X * z]); } } -} +} @@ -430,7 +430,7 @@ void cDistortedHeightmap::GetDistortAmpsAt(BiomeNeighbors & a_Neighbors, int a_R // For each biome type that has a nonzero count, calc its amps and add it: NOISE_DATATYPE AmpX = 0; NOISE_DATATYPE AmpZ = 0; - for (int i = 0; i < ARRAYCOUNT(BiomeCounts); i++) + for (unsigned int i = 0; i < ARRAYCOUNT(BiomeCounts); i++) { AmpX += BiomeCounts[i] * m_GenParam[i].m_DistortAmpX; AmpZ += BiomeCounts[i] * m_GenParam[i].m_DistortAmpZ; -- cgit v1.2.3 From d3360051b160cb67115fa0f1d6a9be9424489529 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sat, 16 Nov 2013 18:37:43 +0000 Subject: Fixed typo causing buggy code. --- source/LinearUpscale.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/source/LinearUpscale.h b/source/LinearUpscale.h index b7ac84c6a..b337b3219 100644 --- a/source/LinearUpscale.h +++ b/source/LinearUpscale.h @@ -31,7 +31,7 @@ Linearly interpolates values in the array between the equidistant anchor points Works in-place (input is already present at the correct output coords) */ template void LinearUpscale2DArrayInPlace( - TYPE * a_Array, + TYPE * a_Array, int a_SizeX, int a_SizeY, // Dimensions of the array int a_AnchorStepX, int a_AnchorStepY // Distances between the anchor points in each direction ) @@ -53,7 +53,7 @@ template void LinearUpscale2DArrayInPlace( Idx += a_AnchorStepX; } // for x } // for y - + // Now interpolate in rows, each row has values in the anchor columns int LastXCell = a_SizeX - a_AnchorStepX; for (int y = 0; y < a_SizeY; y++) @@ -92,7 +92,7 @@ template void LinearUpscale2DArray( // Feel free to enlarge them if needed, but keep in mind that they're on the stack const int MAX_UPSCALE_X = 128; const int MAX_UPSCALE_Y = 128; - + ASSERT(a_Src != NULL); ASSERT(a_Dst != NULL); ASSERT(a_SrcSizeX > 0); @@ -101,7 +101,7 @@ template void LinearUpscale2DArray( ASSERT(a_UpscaleY > 0); ASSERT(a_UpscaleX <= MAX_UPSCALE_X); ASSERT(a_UpscaleY <= MAX_UPSCALE_Y); - + // Pre-calculate the upscaling ratios: TYPE RatioX[MAX_UPSCALE_X]; TYPE RatioY[MAX_UPSCALE_Y]; @@ -113,7 +113,7 @@ template void LinearUpscale2DArray( { RatioY[y] = (TYPE)y / a_UpscaleY; } - + // Interpolate each XY cell: int DstSizeX = (a_SrcSizeX - 1) * a_UpscaleX + 1; int DstSizeY = (a_SrcSizeY - 1) * a_UpscaleY + 1; @@ -163,7 +163,7 @@ template void LinearUpscale3DArray( const int MAX_UPSCALE_X = 128; const int MAX_UPSCALE_Y = 128; const int MAX_UPSCALE_Z = 128; - + ASSERT(a_Src != NULL); ASSERT(a_Dst != NULL); ASSERT(a_SrcSizeX > 0); @@ -175,11 +175,11 @@ template void LinearUpscale3DArray( ASSERT(a_UpscaleX <= MAX_UPSCALE_X); ASSERT(a_UpscaleY <= MAX_UPSCALE_Y); ASSERT(a_UpscaleZ <= MAX_UPSCALE_Z); - + // Pre-calculate the upscaling ratios: TYPE RatioX[MAX_UPSCALE_X]; TYPE RatioY[MAX_UPSCALE_Y]; - TYPE RatioZ[MAX_UPSCALE_Y]; + TYPE RatioZ[MAX_UPSCALE_Z]; for (int x = 0; x <= a_UpscaleX; x++) { RatioX[x] = (TYPE)x / a_UpscaleX; @@ -192,7 +192,7 @@ template void LinearUpscale3DArray( { RatioZ[z] = (TYPE)z / a_UpscaleZ; } - + // Interpolate each XYZ cell: int DstSizeX = (a_SrcSizeX - 1) * a_UpscaleX + 1; int DstSizeY = (a_SrcSizeY - 1) * a_UpscaleY + 1; -- cgit v1.2.3 From a319973e50e06de7e2fae96058aafdb1daceab1a Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sat, 16 Nov 2013 18:43:40 +0000 Subject: Fixed yet another unsigned integer comparison. --- source/Generating/Noise3DGenerator.cpp | 52 +++++++++++++++++----------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/source/Generating/Noise3DGenerator.cpp b/source/Generating/Noise3DGenerator.cpp index f47c64430..c47b3f8a2 100644 --- a/source/Generating/Noise3DGenerator.cpp +++ b/source/Generating/Noise3DGenerator.cpp @@ -25,8 +25,8 @@ public: DoTest1(); DoTest2(); } - - + + void DoTest1(void) { float In[3 * 3 * 3]; @@ -39,8 +39,8 @@ public: LinearUpscale3DArray(In, 3, 3, 3, Out, 8, 16, 17); Debug3DNoise(Out, 17, 33, 35, "Upscale3D test"); } - - + + void DoTest2(void) { float In[3 * 3]; @@ -53,7 +53,7 @@ public: LinearUpscale2DArray(In, 3, 3, Out, 8, 16); Debug2DNoise(Out, 17, 33, "Upscale2D test"); } - + } gTest; //*/ @@ -72,7 +72,7 @@ cNoise3DGenerator::cNoise3DGenerator(cChunkGenerator & a_ChunkGenerator) : m_Perlin.AddOctave(1, (NOISE_DATATYPE)0.5); m_Perlin.AddOctave((NOISE_DATATYPE)0.5, 1); m_Perlin.AddOctave((NOISE_DATATYPE)0.5, 2); - + #if 0 // DEBUG: Test the noise generation: // NOTE: In order to be able to run MCS with this code, you need to increase the default thread stack size @@ -84,7 +84,7 @@ cNoise3DGenerator::cNoise3DGenerator(cChunkGenerator & a_ChunkGenerator) : m_FrequencyY = 4; m_FrequencyZ = 4; m_AirThreshold = 0.5; - + const int NumChunks = 4; NOISE_DATATYPE Noise[NumChunks][cChunkDef::Width * cChunkDef::Width * cChunkDef::Height]; for (int x = 0; x < NumChunks; x++) @@ -153,7 +153,7 @@ cNoise3DGenerator::~cNoise3DGenerator() void cNoise3DGenerator::Initialize(cWorld * a_World, cIniFile & a_IniFile) { m_World = a_World; - + // Params: m_SeaLevel = a_IniFile.GetValueSetI("Generator", "Noise3DSeaLevel", 62); m_HeightAmplification = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DHeightAmplification", 0); @@ -170,7 +170,7 @@ void cNoise3DGenerator::Initialize(cWorld * a_World, cIniFile & a_IniFile) void cNoise3DGenerator::GenerateBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) { - for (int i = 0; i < ARRAYCOUNT(a_BiomeMap); i++) + for (unsigned int i = 0; i < ARRAYCOUNT(a_BiomeMap); i++) { a_BiomeMap[i] = biExtremeHills; } @@ -184,7 +184,7 @@ void cNoise3DGenerator::DoGenerate(int a_ChunkX, int a_ChunkZ, cChunkDesc & a_Ch { NOISE_DATATYPE Noise[17 * 257 * 17]; GenerateNoiseArray(a_ChunkX, a_ChunkZ, Noise); - + // Output noise into chunk: for (int z = 0; z < cChunkDef::Width; z++) { @@ -207,7 +207,7 @@ void cNoise3DGenerator::DoGenerate(int a_ChunkX, int a_ChunkZ, cChunkDesc & a_Ch } } } - + UpdateHeightmap(a_ChunkDesc); ComposeTerrain (a_ChunkDesc); } @@ -228,11 +228,11 @@ void cNoise3DGenerator::GenerateNoiseArray(int a_ChunkX, int a_ChunkZ, NOISE_DAT NOISE_DATATYPE EndZ = ((NOISE_DATATYPE)((a_ChunkZ + 1) * cChunkDef::Width) - 1) / m_FrequencyZ; NOISE_DATATYPE StartY = 0; NOISE_DATATYPE EndY = ((NOISE_DATATYPE)256) / m_FrequencyY; - + m_Perlin.Generate3D(NoiseO, DIM_X, DIM_Y, DIM_Z, StartX, EndX, StartY, EndY, StartZ, EndZ, NoiseW); - + // DEBUG: Debug3DNoise(NoiseO, DIM_X, DIM_Y, DIM_Z, Printf("Chunk_%d_%d_orig", a_ChunkX, a_ChunkZ)); - + // Precalculate a "height" array: NOISE_DATATYPE Height[DIM_X * DIM_Z]; // Output for the cubic noise heightmap ("source") m_Cubic.Generate2D(Height, DIM_X, DIM_Z, StartX / 25, EndX / 25, StartZ / 25, EndZ / 25); @@ -240,7 +240,7 @@ void cNoise3DGenerator::GenerateNoiseArray(int a_ChunkX, int a_ChunkZ, NOISE_DAT { Height[i] = abs(Height[i]) * m_HeightAmplification + 1; } - + // Modify the noise by height data: for (int y = 0; y < DIM_Y; y++) { @@ -257,13 +257,13 @@ void cNoise3DGenerator::GenerateNoiseArray(int a_ChunkX, int a_ChunkZ, NOISE_DAT } // DEBUG: Debug3DNoise(NoiseO, DIM_X, DIM_Y, DIM_Z, Printf("Chunk_%d_%d_hei", a_ChunkX, a_ChunkZ)); - + // Upscale the Perlin noise into full-blown chunk dimensions: LinearUpscale3DArray( NoiseO, DIM_X, DIM_Y, DIM_Z, a_OutNoise, UPSCALE_X, UPSCALE_Y, UPSCALE_Z ); - + // DEBUG: Debug3DNoise(a_OutNoise, 17, 257, 17, Printf("Chunk_%d_%d_lerp", a_ChunkX, a_ChunkZ)); } @@ -383,12 +383,12 @@ void cNoise3DComposable::GenerateNoiseArrayIfNeeded(int a_ChunkX, int a_ChunkZ) } m_LastChunkX = a_ChunkX; m_LastChunkZ = a_ChunkZ; - + // Upscaling parameters: const int UPSCALE_X = 8; const int UPSCALE_Y = 4; const int UPSCALE_Z = 8; - + const int DIM_X = 1 + cChunkDef::Width / UPSCALE_X; const int DIM_Y = 1 + cChunkDef::Height / UPSCALE_Y; const int DIM_Z = 1 + cChunkDef::Width / UPSCALE_Z; @@ -405,7 +405,7 @@ void cNoise3DComposable::GenerateNoiseArrayIfNeeded(int a_ChunkX, int a_ChunkZ) Height[x + 17 * z] = val * val * val; } } - + int idx = 0; for (int y = 0; y < 257; y += UPSCALE_Y) { @@ -419,7 +419,7 @@ void cNoise3DComposable::GenerateNoiseArrayIfNeeded(int a_ChunkX, int a_ChunkZ) for (int x = 0; x < 17; x += UPSCALE_X) { NOISE_DATATYPE NoiseX = ((NOISE_DATATYPE)(a_ChunkX * cChunkDef::Width + x)) / m_FrequencyX; - CurFloor[x + 17 * z] = + CurFloor[x + 17 * z] = m_Noise1.CubicNoise3D(NoiseX, NoiseY, NoiseZ) * (NOISE_DATATYPE)0.5 + m_Noise2.CubicNoise3D(NoiseX / 2, NoiseY / 2, NoiseZ / 2) + m_Noise3.CubicNoise3D(NoiseX / 4, NoiseY / 4, NoiseZ / 4) * 2 + @@ -429,7 +429,7 @@ void cNoise3DComposable::GenerateNoiseArrayIfNeeded(int a_ChunkX, int a_ChunkZ) // Linear-interpolate this XZ floor: LinearUpscale2DArrayInPlace(CurFloor, 17, 17, UPSCALE_X, UPSCALE_Z); } - + // Finish the 3D linear interpolation by interpolating between each XZ-floors on the Y axis for (int y = 1; y < cChunkDef::Height; y++) { @@ -455,7 +455,7 @@ void cNoise3DComposable::GenerateNoiseArrayIfNeeded(int a_ChunkX, int a_ChunkZ) idx += 1; // Skipping one X column } } - + // The noise array is now fully interpolated /* // DEBUG: Output two images of the array, sliced by XY and XZ: @@ -504,7 +504,7 @@ void cNoise3DComposable::GenerateNoiseArrayIfNeeded(int a_ChunkX, int a_ChunkZ) void cNoise3DComposable::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) { GenerateNoiseArrayIfNeeded(a_ChunkX, a_ChunkZ); - + for (int z = 0; z < cChunkDef::Width; z++) { for (int x = 0; x < cChunkDef::Width; x++) @@ -529,9 +529,9 @@ void cNoise3DComposable::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::Hei void cNoise3DComposable::ComposeTerrain(cChunkDesc & a_ChunkDesc) { GenerateNoiseArrayIfNeeded(a_ChunkDesc.GetChunkX(), a_ChunkDesc.GetChunkZ()); - + a_ChunkDesc.FillBlocks(E_BLOCK_AIR, 0); - + // Make basic terrain composition: for (int z = 0; z < cChunkDef::Width; z++) { -- cgit v1.2.3 From 5687ca7bad4c83be16dd932c7f598fb699057a3e Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sat, 16 Nov 2013 18:44:19 +0000 Subject: Fixed another one... --- source/Generating/Noise3DGenerator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Generating/Noise3DGenerator.cpp b/source/Generating/Noise3DGenerator.cpp index c47b3f8a2..e44f5f135 100644 --- a/source/Generating/Noise3DGenerator.cpp +++ b/source/Generating/Noise3DGenerator.cpp @@ -236,7 +236,7 @@ void cNoise3DGenerator::GenerateNoiseArray(int a_ChunkX, int a_ChunkZ, NOISE_DAT // Precalculate a "height" array: NOISE_DATATYPE Height[DIM_X * DIM_Z]; // Output for the cubic noise heightmap ("source") m_Cubic.Generate2D(Height, DIM_X, DIM_Z, StartX / 25, EndX / 25, StartZ / 25, EndZ / 25); - for (int i = 0; i < ARRAYCOUNT(Height); i++) + for (unsigned int i = 0; i < ARRAYCOUNT(Height); i++) { Height[i] = abs(Height[i]) * m_HeightAmplification + 1; } -- cgit v1.2.3 From eb77bfc1b340ddc218fcf073918e998e25c722e5 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sat, 16 Nov 2013 18:46:06 +0000 Subject: Those variables weren't used. It seems strange for them to be there, is the code written wrong? --- source/Generating/Noise3DGenerator.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/source/Generating/Noise3DGenerator.cpp b/source/Generating/Noise3DGenerator.cpp index e44f5f135..c39bb5594 100644 --- a/source/Generating/Noise3DGenerator.cpp +++ b/source/Generating/Noise3DGenerator.cpp @@ -389,10 +389,6 @@ void cNoise3DComposable::GenerateNoiseArrayIfNeeded(int a_ChunkX, int a_ChunkZ) const int UPSCALE_Y = 4; const int UPSCALE_Z = 8; - const int DIM_X = 1 + cChunkDef::Width / UPSCALE_X; - const int DIM_Y = 1 + cChunkDef::Height / UPSCALE_Y; - const int DIM_Z = 1 + cChunkDef::Width / UPSCALE_Z; - // Precalculate a "height" array: NOISE_DATATYPE Height[17 * 17]; // x + 17 * z for (int z = 0; z < 17; z += UPSCALE_Z) -- cgit v1.2.3 From c1880e1162001b72b7fbecbf4f4a1af9820bdee8 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sat, 16 Nov 2013 18:47:25 +0000 Subject: Got rid of another unused variable. --- source/Generating/Noise3DGenerator.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/source/Generating/Noise3DGenerator.cpp b/source/Generating/Noise3DGenerator.cpp index c39bb5594..03626a800 100644 --- a/source/Generating/Noise3DGenerator.cpp +++ b/source/Generating/Noise3DGenerator.cpp @@ -402,7 +402,6 @@ void cNoise3DComposable::GenerateNoiseArrayIfNeeded(int a_ChunkX, int a_ChunkZ) } } - int idx = 0; for (int y = 0; y < 257; y += UPSCALE_Y) { NOISE_DATATYPE NoiseY = ((NOISE_DATATYPE)y) / m_FrequencyY; -- cgit v1.2.3 From 9ac95fc24ac48919a85318c5c2015f5cfa023a36 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sat, 16 Nov 2013 18:50:33 +0000 Subject: Got rid of yet another unused variable. --- source/Generating/Caves.cpp | 101 ++++++++++++++++++++++---------------------- 1 file changed, 50 insertions(+), 51 deletions(-) diff --git a/source/Generating/Caves.cpp b/source/Generating/Caves.cpp index 4221ea187..5aebc111b 100644 --- a/source/Generating/Caves.cpp +++ b/source/Generating/Caves.cpp @@ -55,7 +55,7 @@ struct cCaveDefPoint int m_BlockY; int m_BlockZ; int m_Radius; - + cCaveDefPoint(int a_BlockX, int a_BlockY, int a_BlockZ, int a_Radius) : m_BlockX(a_BlockX), m_BlockY(a_BlockY), @@ -78,22 +78,22 @@ class cCaveTunnel int m_MinBlockX, m_MaxBlockX; int m_MinBlockY, m_MaxBlockY; int m_MinBlockZ, m_MaxBlockZ; - + /// Generates the shaping defpoints for the ravine, based on the ravine block coords and noise void Randomize(cNoise & a_Noise); - + /// Refines (adds and smooths) defpoints from a_Src into a_Dst; returns false if no refinement possible (segments too short) bool RefineDefPoints(const cCaveDefPoints & a_Src, cCaveDefPoints & a_Dst); - + /// Does rounds of smoothing, two passes of RefineDefPoints(), as long as they return true void Smooth(void); - + /// Linearly interpolates the points so that the maximum distance between two neighbors is max 1 block void FinishLinear(void); - + /// Calculates the bounding box of the points present void CalcBoundingBox(void); - + public: cCaveDefPoints m_Points; @@ -102,14 +102,14 @@ public: int a_BlockEndX, int a_BlockEndY, int a_BlockEndZ, int a_EndRadius, cNoise & a_Noise ); - + /// Carves the tunnel into the chunk specified void ProcessChunk( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, + int a_ChunkX, int a_ChunkZ, + cChunkDef::BlockTypes & a_BlockTypes, cChunkDef::HeightMap & a_HeightMap ); - + #ifdef _DEBUG AString ExportAsSVG(int a_Color, int a_OffsetX, int a_OffsetZ) const; #endif // _DEBUG @@ -128,17 +128,17 @@ public: // The generating block position; is read directly in cStructGenWormNestCaves::GetCavesForChunk() int m_BlockX; int m_BlockZ; - + cCaveSystem(int a_BlockX, int a_BlockZ, int a_MaxOffset, int a_Size, cNoise & a_Noise); ~cCaveSystem(); - + /// Carves the cave system into the chunk specified void ProcessChunk( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, + int a_ChunkX, int a_ChunkZ, + cChunkDef::BlockTypes & a_BlockTypes, cChunkDef::HeightMap & a_HeightMap ); - + #ifdef _DEBUG AString ExportAsSVG(int a_Color, int a_OffsetX, int a_OffsetZ) const; #endif // _DEBUG @@ -146,15 +146,15 @@ public: protected: int m_Size; cCaveTunnels m_Tunnels; - + void Clear(void); /// Generates a_Segment successive tunnels, with possible branches. Generates the same output for the same [x, y, z, a_Segments] void GenerateTunnelsFromPoint( - int a_OriginX, int a_OriginY, int a_OriginZ, + int a_OriginX, int a_OriginY, int a_OriginZ, cNoise & a_Noise, int a_Segments ); - + /// Returns a radius based on the location provided. int GetRadius(cNoise & a_Noise, int a_OriginX, int a_OriginY, int a_OriginZ); } ; @@ -174,19 +174,19 @@ cCaveTunnel::cCaveTunnel( { m_Points.push_back(cCaveDefPoint(a_BlockStartX, a_BlockStartY, a_BlockStartZ, a_StartRadius)); m_Points.push_back(cCaveDefPoint(a_BlockEndX, a_BlockEndY, a_BlockEndZ, a_EndRadius)); - + if ((a_BlockStartY <= 0) && (a_BlockEndY <= 0)) { // Don't bother detailing this cave, it's under the world anyway return; } - + Randomize(a_Noise); Smooth(); - + // We know that the linear finishing won't affect the bounding box, so let's calculate it now, as we have less data: CalcBoundingBox(); - + FinishLinear(); } @@ -308,7 +308,7 @@ void cCaveTunnel::FinishLinear(void) // For each segment, use Bresenham's 3D line algorithm to draw a "line" of defpoints cCaveDefPoints Pts; std::swap(Pts, m_Points); - + m_Points.reserve(Pts.size() * 3); int PrevX = Pts.front().m_BlockX; int PrevY = Pts.front().m_BlockY; @@ -324,7 +324,6 @@ void cCaveTunnel::FinishLinear(void) int sx = (PrevX < x1) ? 1 : -1; int sy = (PrevY < y1) ? 1 : -1; int sz = (PrevZ < z1) ? 1 : -1; - int err = dx - dz; int R = itr->m_Radius; if (dx >= std::max(dy, dz)) // x dominant @@ -418,7 +417,7 @@ void cCaveTunnel::FinishLinear(void) PrevY += sy; yd -= dz; } - + // move along z PrevZ += sz; xd += dx; @@ -453,8 +452,8 @@ void cCaveTunnel::CalcBoundingBox(void) void cCaveTunnel::ProcessChunk( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, + int a_ChunkX, int a_ChunkZ, + cChunkDef::BlockTypes & a_BlockTypes, cChunkDef::HeightMap & a_HeightMap ) { @@ -485,7 +484,7 @@ void cCaveTunnel::ProcessChunk( // Cannot intersect, bail out early continue; } - + // Carve out a sphere around the xyz point, m_Radius in diameter; skip 3/7 off the top and bottom: int DifX = itr->m_BlockX - BlockStartX; // substitution for faster calc int DifY = itr->m_BlockY; @@ -493,7 +492,7 @@ void cCaveTunnel::ProcessChunk( int Bottom = std::max(itr->m_BlockY - 3 * itr->m_Radius / 7, 1); int Top = std::min(itr->m_BlockY + 3 * itr->m_Radius / 7, (int)(cChunkDef::Height)); int SqRad = itr->m_Radius * itr->m_Radius; - for (int z = 0; z < cChunkDef::Width; z++) for (int x = 0; x < cChunkDef::Width; x++) + for (int z = 0; z < cChunkDef::Width; z++) for (int x = 0; x < cChunkDef::Width; x++) { for (int y = Bottom; y <= Top; y++) { @@ -527,9 +526,9 @@ void cCaveTunnel::ProcessChunk( } // for y } // for x, z } // for itr - m_Points[] - + /* - #ifdef _DEBUG + #ifdef _DEBUG // For debugging purposes, outline the shape of the cave using glowstone, *after* carving the entire cave: for (cCaveDefPoints::const_iterator itr = m_Points.begin(), end = m_Points.end(); itr != end; ++itr) { @@ -587,7 +586,7 @@ cStructGenWormNestCaves::cCaveSystem::cCaveSystem(int a_BlockX, int a_BlockZ, in int OriginX = a_BlockX + (a_Noise.IntNoise3DInt(13 * a_BlockX, 17 * a_BlockZ, 11 * i) / 19) % a_MaxOffset; int OriginZ = a_BlockZ + (a_Noise.IntNoise3DInt(17 * a_BlockX, 13 * a_BlockZ, 11 * i) / 23) % a_MaxOffset; int OriginY = 20 + (a_Noise.IntNoise3DInt(19 * a_BlockX, 13 * a_BlockZ, 11 * i) / 17) % 20; - + // Generate three branches from the origin point: // The tunnels generated depend on X, Y, Z and Branches, // for the same set of numbers it generates the same offsets! @@ -613,8 +612,8 @@ cStructGenWormNestCaves::cCaveSystem::~cCaveSystem() void cStructGenWormNestCaves::cCaveSystem::ProcessChunk( - int a_ChunkX, int a_ChunkZ, - cChunkDef::BlockTypes & a_BlockTypes, + int a_ChunkX, int a_ChunkZ, + cChunkDef::BlockTypes & a_BlockTypes, cChunkDef::HeightMap & a_HeightMap ) { @@ -645,14 +644,14 @@ AString cStructGenWormNestCaves::cCaveSystem::ExportAsSVG(int a_Color, int a_Off AppendPrintf(SVG, "\n", a_OffsetX + m_BlockX, a_OffsetZ + m_BlockZ - 5, a_OffsetX + m_BlockX, a_OffsetZ + m_BlockZ + 5 ); - + // A gray line from the base point to the first point of the ravine, for identification: AppendPrintf(SVG, "\n", - a_OffsetX + m_BlockX, a_OffsetZ + m_BlockZ, - a_OffsetX + m_Tunnels.front()->m_Points.front().m_BlockX, + a_OffsetX + m_BlockX, a_OffsetZ + m_BlockZ, + a_OffsetX + m_Tunnels.front()->m_Points.front().m_BlockX, a_OffsetZ + m_Tunnels.front()->m_Points.front().m_BlockZ ); - + // Offset guides: if (a_OffsetX > 0) { @@ -666,7 +665,7 @@ AString cStructGenWormNestCaves::cCaveSystem::ExportAsSVG(int a_Color, int a_Off a_OffsetZ, a_OffsetZ ); } - + return SVG; } #endif // _DEBUG @@ -689,7 +688,7 @@ void cStructGenWormNestCaves::cCaveSystem::Clear(void) void cStructGenWormNestCaves::cCaveSystem::GenerateTunnelsFromPoint( - int a_OriginX, int a_OriginY, int a_OriginZ, + int a_OriginX, int a_OriginY, int a_OriginZ, cNoise & a_Noise, int a_NumSegments ) { @@ -727,7 +726,7 @@ int cStructGenWormNestCaves::cCaveSystem::GetRadius(cNoise & a_Noise, int a_Orig // We want mapping 384 -> 3, 0 -> 19, 768 -> 19, so divide by 24 to get [0 .. 31] with center at 16, then use abs() to fold around the center int res = 3 + abs((sum / 24) - 16); */ - + // Algorithm of choice: random value in the range of zero to random value - heavily towards zero int res = MIN_RADIUS + (rnd >> 8) % ((rnd % (MAX_RADIUS - MIN_RADIUS)) + 1); return res; @@ -815,7 +814,7 @@ void cStructGenWormNestCaves::GetCavesForChunk(int a_ChunkX, int a_ChunkZ, cStru ++itr; } } // for itr - m_Cache[] - + for (int x = 0; x < NEIGHBORHOOD_SIZE; x++) { int RealX = (BaseX + x) * m_Grid; @@ -837,11 +836,11 @@ void cStructGenWormNestCaves::GetCavesForChunk(int a_ChunkX, int a_ChunkZ, cStru } } } - + // Copy a_Caves into m_Cache to the beginning: cCaveSystems CavesCopy(a_Caves); m_Cache.splice(m_Cache.begin(), CavesCopy, CavesCopy.begin(), CavesCopy.end()); - + // Trim the cache if it's too long: if (m_Cache.size() > 100) { @@ -855,7 +854,7 @@ void cStructGenWormNestCaves::GetCavesForChunk(int a_ChunkX, int a_ChunkZ, cStru std::advance(itr, 100); m_Cache.erase(itr, m_Cache.end()); } - + /* // Uncomment this block for debugging the caves' shapes in 2D using an SVG export #ifdef _DEBUG @@ -869,7 +868,7 @@ void cStructGenWormNestCaves::GetCavesForChunk(int a_ChunkX, int a_ChunkZ, cStru SVG.append((*itr)->ExportAsSVG(Color, 512, 512)); } SVG.append("\n"); - + AString fnam; Printf(fnam, "wnc\\%03d_%03d.svg", a_ChunkX, a_ChunkZ); cFile File(fnam, cFile::fmWrite); @@ -905,13 +904,13 @@ static float GetMarbleNoise( float x, float y, float z, cNoise & a_Noise ) void cStructGenMarbleCaves::GenStructures(cChunkDesc & a_ChunkDesc) { cNoise Noise(m_Seed); - for (int z = 0; z < cChunkDef::Width; z++) + for (int z = 0; z < cChunkDef::Width; z++) { const float zz = (float)(a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z); for (int x = 0; x < cChunkDef::Width; x++) { const float xx = (float)(a_ChunkDesc.GetChunkX() * cChunkDef::Width + x); - + int Top = a_ChunkDesc.GetHeight(x, z); for (int y = 1; y < Top; ++y ) { @@ -940,13 +939,13 @@ void cStructGenMarbleCaves::GenStructures(cChunkDesc & a_ChunkDesc) void cStructGenDualRidgeCaves::GenStructures(cChunkDesc & a_ChunkDesc) { - for (int z = 0; z < cChunkDef::Width; z++) + for (int z = 0; z < cChunkDef::Width; z++) { const float zz = (float)(a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z) / 10; for (int x = 0; x < cChunkDef::Width; x++) { const float xx = (float)(a_ChunkDesc.GetChunkX() * cChunkDef::Width + x) / 10; - + int Top = a_ChunkDesc.GetHeight(x, z); for (int y = 1; y <= Top; ++y) { -- cgit v1.2.3 From 45aebbd5abe653045a6b647aec61df32b227bc78 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sat, 16 Nov 2013 18:52:48 +0000 Subject: This is a copy-paste fail, right? --- source/Generating/Caves.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Generating/Caves.cpp b/source/Generating/Caves.cpp index 5aebc111b..535ca4fb2 100644 --- a/source/Generating/Caves.cpp +++ b/source/Generating/Caves.cpp @@ -461,7 +461,7 @@ void cCaveTunnel::ProcessChunk( int BaseZ = a_ChunkZ * cChunkDef::Width; if ( (BaseX > m_MaxBlockX) || (BaseX + cChunkDef::Width < m_MinBlockX) || - (BaseX > m_MaxBlockX) || (BaseX + cChunkDef::Width < m_MinBlockX) + (BaseZ > m_MaxBlockZ) || (BaseZ + cChunkDef::Width < m_MinBlockZ) ) { // Tunnel does not intersect the chunk at all, bail out -- cgit v1.2.3 From 755fe9cb2188e64369ef4067d9074dd629744e02 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sat, 16 Nov 2013 18:54:01 +0000 Subject: WaveNoise not used, removing. --- source/Generating/Caves.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/source/Generating/Caves.cpp b/source/Generating/Caves.cpp index 535ca4fb2..df45bb4c2 100644 --- a/source/Generating/Caves.cpp +++ b/source/Generating/Caves.cpp @@ -950,7 +950,6 @@ void cStructGenDualRidgeCaves::GenStructures(cChunkDesc & a_ChunkDesc) for (int y = 1; y <= Top; ++y) { const float yy = (float)y / 10; - const float WaveNoise = 1; float n1 = m_Noise1.CubicNoise3D(xx, yy, zz); float n2 = m_Noise2.CubicNoise3D(xx, yy, zz); float n3 = m_Noise1.CubicNoise3D(xx * 4, yy * 4, zz * 4) / 4; -- cgit v1.2.3 From 0150de36888404782f8a27b9a23400ced1c7084b Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sat, 16 Nov 2013 18:55:49 +0000 Subject: Fixed some unsigned int comparison warnings. --- source/Generating/ChunkGenerator.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/source/Generating/ChunkGenerator.cpp b/source/Generating/ChunkGenerator.cpp index 59a00b540..33c956eba 100644 --- a/source/Generating/ChunkGenerator.cpp +++ b/source/Generating/ChunkGenerator.cpp @@ -15,10 +15,10 @@ /// If the generation queue size exceeds this number, a warning will be output -const int QUEUE_WARNING_LIMIT = 1000; +const unsigned int QUEUE_WARNING_LIMIT = 1000; /// If the generation queue size exceeds this number, chunks with no clients will be skipped -const int QUEUE_SKIP_LIMIT = 500; +const unsigned int QUEUE_SKIP_LIMIT = 500; @@ -53,7 +53,7 @@ bool cChunkGenerator::Start(cWorld * a_World, cIniFile & a_IniFile) m_World = a_World; m_Seed = a_IniFile.GetValueSetI("Seed", "Seed", rnd.randInt()); AString GeneratorName = a_IniFile.GetValueSet("Generator", "Generator", "Composable"); - + if (NoCaseCompare(GeneratorName, "Noise3D") == 0) { m_Generator = new cNoise3DGenerator(*this); @@ -72,9 +72,9 @@ bool cChunkGenerator::Start(cWorld * a_World, cIniFile & a_IniFile) LOGERROR("Generator could not start, aborting the server"); return false; } - + m_Generator->Initialize(a_World, a_IniFile); - + return super::Start(); } @@ -101,7 +101,7 @@ void cChunkGenerator::QueueGenerateChunk(int a_ChunkX, int a_ChunkY, int a_Chunk { { cCSLock Lock(m_CS); - + // Check if it is already in the queue: for (cChunkCoordsList::iterator itr = m_Queue.begin(); itr != m_Queue.end(); ++itr) { @@ -111,7 +111,7 @@ void cChunkGenerator::QueueGenerateChunk(int a_ChunkX, int a_ChunkY, int a_Chunk return; } } // for itr - m_Queue[] - + // Add to queue, issue a warning if too many: if (m_Queue.size() >= QUEUE_WARNING_LIMIT) { @@ -119,7 +119,7 @@ void cChunkGenerator::QueueGenerateChunk(int a_ChunkX, int a_ChunkY, int a_Chunk } m_Queue.push_back(cChunkCoords(a_ChunkX, a_ChunkY, a_ChunkZ)); } - + m_Event.Set(); } @@ -196,7 +196,7 @@ void cChunkGenerator::Execute(void) int NumChunksGenerated = 0; // Number of chunks generated since the queue was last empty clock_t GenerationStart = clock(); // Clock tick when the queue started to fill clock_t LastReportTick = clock(); // Clock tick of the last report made (so that performance isn't reported too often) - + while (!m_ShouldTerminate) { cCSLock Lock(m_CS); @@ -219,7 +219,7 @@ void cChunkGenerator::Execute(void) GenerationStart = clock(); LastReportTick = clock(); } - + cChunkCoords coords = m_Queue.front(); // Get next coord from queue m_Queue.erase( m_Queue.begin() ); // Remove coordinate from queue bool SkipEnabled = (m_Queue.size() > QUEUE_SKIP_LIMIT); @@ -243,19 +243,19 @@ void cChunkGenerator::Execute(void) // Already generated, ignore request continue; } - + if (SkipEnabled && !m_World->HasChunkAnyClients(coords.m_ChunkX, coords.m_ChunkZ)) { LOGWARNING("Chunk generator overloaded, skipping chunk [%d, %d]", coords.m_ChunkX, coords.m_ChunkZ); continue; } - + LOGD("Generating chunk [%d, %d, %d]", coords.m_ChunkX, coords.m_ChunkY, coords.m_ChunkZ); DoGenerate(coords.m_ChunkX, coords.m_ChunkY, coords.m_ChunkZ); - + // Save the chunk right after generating, so that we don't have to generate it again on next run m_World->GetStorage().QueueSaveChunk(coords.m_ChunkX, coords.m_ChunkY, coords.m_ChunkZ); - + NumChunksGenerated++; } // while (!bStop) } @@ -269,17 +269,17 @@ void cChunkGenerator::DoGenerate(int a_ChunkX, int a_ChunkY, int a_ChunkZ) cRoot::Get()->GetPluginManager()->CallHookChunkGenerating(m_World, a_ChunkX, a_ChunkZ, &ChunkDesc); m_Generator->DoGenerate(a_ChunkX, a_ChunkZ, ChunkDesc); cRoot::Get()->GetPluginManager()->CallHookChunkGenerated(m_World, a_ChunkX, a_ChunkZ, &ChunkDesc); - + #ifdef _DEBUG // Verify that the generator has produced valid data: ChunkDesc.VerifyHeightmap(); #endif - + cChunkDef::BlockNibbles BlockMetas; ChunkDesc.CompressBlockMetas(BlockMetas); - + m_World->SetChunkData( - a_ChunkX, a_ChunkZ, + a_ChunkX, a_ChunkZ, ChunkDesc.GetBlockTypes(), BlockMetas, NULL, NULL, // We don't have lighting, chunk will be lighted when needed &ChunkDesc.GetHeightMap(), &ChunkDesc.GetBiomeMap(), -- cgit v1.2.3 From ef8ac545d8d9f93bfc489f61365b960731a16bd8 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sat, 16 Nov 2013 18:57:03 +0000 Subject: Fixed another one. --- source/Generating/EndGen.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/source/Generating/EndGen.cpp b/source/Generating/EndGen.cpp index 3eba5c47b..90a8071fa 100644 --- a/source/Generating/EndGen.cpp +++ b/source/Generating/EndGen.cpp @@ -18,7 +18,7 @@ enum INTERPOL_X = 4, INTERPOL_Y = 4, INTERPOL_Z = 4, - + // Size of chunk data, downscaled before interpolation: DIM_X = 16 / INTERPOL_X + 1, DIM_Y = 256 / INTERPOL_Y + 1, @@ -59,7 +59,7 @@ void cEndGen::Initialize(cIniFile & a_IniFile) m_FrequencyX = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "EndGenFrequencyX", m_FrequencyX); m_FrequencyY = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "EndGenFrequencyY", m_FrequencyY); m_FrequencyZ = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "EndGenFrequencyZ", m_FrequencyZ); - + // Recalculate the min and max chunk coords of the island m_MaxChunkX = (m_IslandSizeX + cChunkDef::Width - 1) / cChunkDef::Width; m_MinChunkX = -m_MaxChunkX; @@ -75,15 +75,15 @@ void cEndGen::Initialize(cIniFile & a_IniFile) void cEndGen::PrepareState(int a_ChunkX, int a_ChunkZ) { ASSERT(!IsChunkOutsideRange(a_ChunkX, a_ChunkZ)); // Should be filtered before calling this function - + if ((m_LastChunkX == a_ChunkX) && (m_LastChunkZ == a_ChunkZ)) { return; } - + m_LastChunkX = a_ChunkX; m_LastChunkZ = a_ChunkZ; - + GenerateNoiseArray(); } @@ -96,7 +96,7 @@ void cEndGen::GenerateNoiseArray(void) { NOISE_DATATYPE NoiseData[DIM_X * DIM_Y * DIM_Z]; // [x + DIM_X * z + DIM_X * DIM_Z * y] NOISE_DATATYPE Workspace[DIM_X * DIM_Y * DIM_Z]; // [x + DIM_X * z + DIM_X * DIM_Z * y] - + // Generate the downscaled noise: NOISE_DATATYPE StartX = ((NOISE_DATATYPE)(m_LastChunkX * cChunkDef::Width)) / m_FrequencyX; NOISE_DATATYPE EndX = ((NOISE_DATATYPE)((m_LastChunkX + 1) * cChunkDef::Width)) / m_FrequencyX; @@ -105,7 +105,7 @@ void cEndGen::GenerateNoiseArray(void) NOISE_DATATYPE StartY = 0; NOISE_DATATYPE EndY = ((NOISE_DATATYPE)257) / m_FrequencyY; m_Perlin.Generate3D(NoiseData, DIM_X, DIM_Z, DIM_Y, StartX, EndX, StartZ, EndZ, StartY, EndY, Workspace); - + // Add distance: int idx = 0; for (int y = 0; y < DIM_Y; y++) @@ -125,7 +125,7 @@ void cEndGen::GenerateNoiseArray(void) } // for x } // for z } // for y - + // Upscale into real chunk size: LinearUpscale3DArray(NoiseData, DIM_X, DIM_Z, DIM_Y, m_NoiseArray, INTERPOL_X, INTERPOL_Z, INTERPOL_Y); } @@ -133,14 +133,14 @@ void cEndGen::GenerateNoiseArray(void) - + /// Returns true if the chunk is outside of the island's dimensions bool cEndGen::IsChunkOutsideRange(int a_ChunkX, int a_ChunkZ) { return ( (a_ChunkX < m_MinChunkX) || (a_ChunkX > m_MaxChunkX) || (a_ChunkZ < m_MinChunkZ) || (a_ChunkZ > m_MaxChunkZ) - ); + ); } @@ -151,15 +151,15 @@ void cEndGen::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_ { if (IsChunkOutsideRange(a_ChunkX, a_ChunkZ)) { - for (int i = 0; i < ARRAYCOUNT(a_HeightMap); i++) + for (unsigned int i = 0; i < ARRAYCOUNT(a_HeightMap); i++) { a_HeightMap[i] = 0; } return; } - + PrepareState(a_ChunkX, a_ChunkZ); - + int MaxY = std::min((int)(1.75 * m_IslandSizeY + 1), cChunkDef::Height - 1); for (int z = 0; z < cChunkDef::Width; z++) { @@ -189,9 +189,9 @@ void cEndGen::ComposeTerrain(cChunkDesc & a_ChunkDesc) a_ChunkDesc.FillBlocks(E_BLOCK_AIR, 0); return; } - + PrepareState(a_ChunkDesc.GetChunkX(), a_ChunkDesc.GetChunkZ()); - + int MaxY = std::min((int)(1.75 * m_IslandSizeY + 1), cChunkDef::Height - 1); for (int z = 0; z < cChunkDef::Width; z++) { -- cgit v1.2.3 From f4f906563fdf60c2de61df8ed02d51c5591c8639 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sat, 16 Nov 2013 18:58:17 +0000 Subject: another --- source/Generating/ChunkDesc.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/source/Generating/ChunkDesc.cpp b/source/Generating/ChunkDesc.cpp index dc6c74a3c..4e2a85abe 100644 --- a/source/Generating/ChunkDesc.cpp +++ b/source/Generating/ChunkDesc.cpp @@ -270,7 +270,7 @@ void cChunkDesc::ReadBlockArea(cBlockArea & a_Dest, int a_MinRelX, int a_MaxRelX a_MaxRelX += 1; a_MaxRelY += 1; a_MaxRelZ += 1; - + // Check coords validity: if (a_MinRelX < 0) { @@ -313,7 +313,7 @@ void cChunkDesc::ReadBlockArea(cBlockArea & a_Dest, int a_MinRelX, int a_MaxRelX LOGWARNING("%s: MaxRelY more than chunk height, adjusting to chunk height", __FUNCTION__); a_MaxRelY = cChunkDef::Height - 1; } - + if (a_MinRelZ < 0) { LOGWARNING("%s: MinRelZ less than zero, adjusting to zero", __FUNCTION__); @@ -370,7 +370,7 @@ void cChunkDesc::ReadBlockArea(cBlockArea & a_Dest, int a_MinRelX, int a_MaxRelX HEIGHTTYPE cChunkDesc::GetMaxHeight(void) const { HEIGHTTYPE MaxHeight = m_HeightMap[0]; - for (int i = 1; i < ARRAYCOUNT(m_HeightMap); i++) + for (unsigned int i = 1; i < ARRAYCOUNT(m_HeightMap); i++) { if (m_HeightMap[i] > MaxHeight) { @@ -397,7 +397,7 @@ void cChunkDesc::FillRelCuboid( int MaxX = std::min(a_MaxX, cChunkDef::Width - 1); int MaxY = std::min(a_MaxY, cChunkDef::Height - 1); int MaxZ = std::min(a_MaxZ, cChunkDef::Width - 1); - + for (int y = MinY; y <= MaxY; y++) { for (int z = MinZ; z <= MaxZ; z++) @@ -428,7 +428,7 @@ void cChunkDesc::ReplaceRelCuboid( int MaxX = std::min(a_MaxX, cChunkDef::Width - 1); int MaxY = std::min(a_MaxY, cChunkDef::Height - 1); int MaxZ = std::min(a_MaxZ, cChunkDef::Width - 1); - + for (int y = MinY; y <= MaxY; y++) { for (int z = MinZ; z <= MaxZ; z++) @@ -464,7 +464,7 @@ void cChunkDesc::FloorRelCuboid( int MaxX = std::min(a_MaxX, cChunkDef::Width - 1); int MaxY = std::min(a_MaxY, cChunkDef::Height - 1); int MaxZ = std::min(a_MaxZ, cChunkDef::Width - 1); - + for (int y = MinY; y <= MaxY; y++) { for (int z = MinZ; z <= MaxZ; z++) @@ -505,7 +505,7 @@ void cChunkDesc::RandomFillRelCuboid( int MaxX = std::min(a_MaxX, cChunkDef::Width - 1); int MaxY = std::min(a_MaxY, cChunkDef::Height - 1); int MaxZ = std::min(a_MaxZ, cChunkDef::Width - 1); - + for (int y = MinY; y <= MaxY; y++) { for (int z = MinZ; z <= MaxZ; z++) -- cgit v1.2.3 From dbf2982e52b71e106923d4f36c6006fe68ca29e5 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sat, 16 Nov 2013 18:58:38 +0000 Subject: And another... --- source/Generating/ChunkDesc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Generating/ChunkDesc.cpp b/source/Generating/ChunkDesc.cpp index 4e2a85abe..df7574c58 100644 --- a/source/Generating/ChunkDesc.cpp +++ b/source/Generating/ChunkDesc.cpp @@ -538,7 +538,7 @@ void cChunkDesc::AddBlockEntity(cBlockEntity * a_BlockEntity) void cChunkDesc::CompressBlockMetas(cChunkDef::BlockNibbles & a_DestMetas) { const NIBBLETYPE * AreaMetas = m_BlockArea.GetBlockMetas(); - for (int i = 0; i < ARRAYCOUNT(a_DestMetas); i++) + for (unsigned int i = 0; i < ARRAYCOUNT(a_DestMetas); i++) { a_DestMetas[i] = AreaMetas[2 * i] | (AreaMetas[2 * i + 1] << 4); } -- cgit v1.2.3