summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MCServer/Plugins/Debuggers/Debuggers.lua17
-rw-r--r--MCServer/favicon.pngbin0 -> 9265 bytes
-rw-r--r--MCServer/settings_apidump.ini30
-rw-r--r--MakeLuaAPI.cmd1
-rw-r--r--Nightbuild2008.cmd27
-rw-r--r--Tools/BiomeVisualiser/.gitignore1
-rw-r--r--Tools/BiomeVisualiser/BiomeRenderer.cpp12
-rw-r--r--Tools/BiomeVisualiser/BiomeRenderer.h5
-rw-r--r--Tools/BiomeVisualiser/BiomeViewWnd.cpp64
-rw-r--r--Tools/BiomeVisualiser/BiomeViewWnd.h4
-rw-r--r--Tools/BiomeVisualiser/BiomeVisualiser.vcproj10
-rw-r--r--Tools/ProtoProxy/Connection.cpp4
-rw-r--r--src/Bindings/ManualBindings.cpp30
-rw-r--r--src/Bindings/PluginLua.cpp13
-rw-r--r--src/ClientHandle.cpp9
-rw-r--r--src/ClientHandle.h1
-rw-r--r--src/Generating/ComposableGenerator.cpp192
-rw-r--r--src/Generating/ComposableGenerator.h15
-rw-r--r--src/Generating/HeiGen.cpp73
-rw-r--r--src/Protocol/Protocol.h1
-rw-r--r--src/Protocol/Protocol125.cpp14
-rw-r--r--src/Protocol/Protocol125.h1
-rw-r--r--src/Protocol/Protocol17x.cpp12
-rw-r--r--src/Protocol/Protocol17x.h1
-rw-r--r--src/Protocol/ProtocolRecognizer.cpp10
-rw-r--r--src/Protocol/ProtocolRecognizer.h1
26 files changed, 404 insertions, 144 deletions
diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua
index 7b43b6c20..8512fbd5f 100644
--- a/MCServer/Plugins/Debuggers/Debuggers.lua
+++ b/MCServer/Plugins/Debuggers/Debuggers.lua
@@ -966,6 +966,23 @@ end
function OnPluginMessage(a_Client, a_Channel, a_Message)
LOGINFO("Received a plugin message from client " .. a_Client:GetUsername() .. ": channel '" .. a_Channel .. "', message '" .. a_Message .. "'");
+
+ if (a_Channel == "REGISTER") then
+ if (a_Message:find("WECUI")) then
+ -- The client has WorldEditCUI mod installed, test the comm by sending a few WECUI messages:
+ --[[
+ WECUI messages have the following generic format:
+ <shape>|<params>
+ If shape is p (cuboid selection), the params are sent individually for each corner click and have the following format:
+ <point-index>|<x>|<y>|<z>|<volume>
+ point-index is 0 or 1 (lclk / rclk)
+ volume is the 3D volume of the current cuboid selected (all three coords' deltas multiplied), including the edge blocks; -1 if N/A
+ --]]
+ -- Select a 51 * 51 * 51 block cuboid:
+ a_Client:SendPluginMessage("WECUI", "p|0|50|50|50|-1");
+ a_Client:SendPluginMessage("WECUI", "p|1|100|100|100|132651"); -- 132651 = 51 * 51 * 51
+ end
+ end
end
diff --git a/MCServer/favicon.png b/MCServer/favicon.png
new file mode 100644
index 000000000..946cce005
--- /dev/null
+++ b/MCServer/favicon.png
Binary files differ
diff --git a/MCServer/settings_apidump.ini b/MCServer/settings_apidump.ini
new file mode 100644
index 000000000..80227a713
--- /dev/null
+++ b/MCServer/settings_apidump.ini
@@ -0,0 +1,30 @@
+; This settings file is used by the $/MakeLuaAPI.cmd script
+; It is copied over settings.ini so that the APIDump plugin gets loaded upon server start
+
+[Server]
+Description=MCServer - in C++!
+MaxPlayers=100
+HardcoreEnabled=0
+Port=25565
+PortsIPv6=
+DefaultViewDistance=10
+
+[RCON]
+Enabled=0
+
+[Authentication]
+Authenticate=1
+Server=session.minecraft.net
+Address=/game/checkserver.jsp?user=%USERNAME%&serverId=%SERVERID%
+
+[Worlds]
+; World=secondworld
+DefaultWorld=world
+
+[Plugins]
+Plugin=APIDump
+
+[DeadlockDetect]
+Enabled=0
+IntervalSec=20
+
diff --git a/MakeLuaAPI.cmd b/MakeLuaAPI.cmd
index 6ea44c9fb..7054977a0 100644
--- a/MakeLuaAPI.cmd
+++ b/MakeLuaAPI.cmd
@@ -29,6 +29,7 @@ if "a%ftpsite%" == "a" (
:: Create the API documentation by running the server and stopping it right after it starts:
cd MCServer
+copy /Y settings_apidump.ini settings.ini
echo stop | MCServer
cd ..
diff --git a/Nightbuild2008.cmd b/Nightbuild2008.cmd
index f3f1ca4cb..8dcd5dc46 100644
--- a/Nightbuild2008.cmd
+++ b/Nightbuild2008.cmd
@@ -44,6 +44,7 @@ if "a%ftpsite%" == "a" (
:: Get the date and time into vars:
+:: This is locale-dependent!
For /f "tokens=2-4 delims=/. " %%a in ('date /t') do (
set MYYEAR=%%c
set MYMONTH=%%b
@@ -66,13 +67,11 @@ if errorlevel 1 goto haderror
:: Update the external plugins to the latest revision:
-cd MCServer\Plugins\Core
-git pull
-if errorlevel 1 goto haderror
-cd ..\ProtectionAreas
-git pull
+git submodule update
if errorlevel 1 goto haderror
-cd ..\..\..
+
+
+
:: Get the Git commit ID into an environment var
For /f "tokens=1 delims=/. " %%a in ('git log -1 --oneline --no-abbrev-commit') do (set COMMITID=%%a)
@@ -114,9 +113,23 @@ if errorlevel 1 goto haderror
+:: Generate the .example.ini files by running the server without any ini files:
+cd MCServer
+del groups.ini
+del settings.ini
+del webadmin.ini
+echo stop | MCServer
+cd ..
+
+
:: Copy all the example ini files into the Install folder for zipping:
-copy MCServer\*.example.ini Install\
+copy MCServer\groups.ini Install\groups.example.ini
+copy MCServer\settings.ini Install\settings.example.ini
+copy MCServer\webadmin.ini Install\webadmin.example.ini
+
+
+
:: Use 7-zip to compress the resulting files into a single file:
set FILESUFFIX=%MYYEAR%_%MYMONTH%_%MYDAY%_%MYTIME%_%COMMITID%
diff --git a/Tools/BiomeVisualiser/.gitignore b/Tools/BiomeVisualiser/.gitignore
index b4e15dc3c..cfbc9164c 100644
--- a/Tools/BiomeVisualiser/.gitignore
+++ b/Tools/BiomeVisualiser/.gitignore
@@ -1,3 +1,4 @@
Debug/
logs/
Release/
+Release profiled/
diff --git a/Tools/BiomeVisualiser/BiomeRenderer.cpp b/Tools/BiomeVisualiser/BiomeRenderer.cpp
index 758eb4b48..569128a12 100644
--- a/Tools/BiomeVisualiser/BiomeRenderer.cpp
+++ b/Tools/BiomeVisualiser/BiomeRenderer.cpp
@@ -40,10 +40,10 @@ bool cBiomeRenderer::Render(cPixmap & a_Pixmap)
int Hei = a_Pixmap.GetHeight();
// Hint the approximate view area to the biome source so that it can adjust its caches:
- int MinBlockX = ( - m_OriginX) / m_Zoom;
- int MaxBlockX = (Wid - m_OriginX) / m_Zoom;
- int MinBlockZ = ( - m_OriginY) / m_Zoom;
- int MaxBlockZ = (Hei - m_OriginY) / m_Zoom;
+ int MinBlockX = ( - m_OriginX) * m_Zoom;
+ int MaxBlockX = (Wid - m_OriginX) * m_Zoom;
+ int MinBlockZ = ( - m_OriginY) * m_Zoom;
+ int MaxBlockZ = (Hei - m_OriginY) * m_Zoom;
m_Cache.HintViewArea(MinBlockX / 16 - 1, MaxBlockX / 16 + 1, MinBlockZ / 16 - 1, MaxBlockZ / 16 + 1);
// Hold one current chunk of biome data:
@@ -55,12 +55,12 @@ bool cBiomeRenderer::Render(cPixmap & a_Pixmap)
for (int y = 0; y < Hei; y++)
{
- int BlockZ = (y - m_OriginY) / m_Zoom;
+ int BlockZ = (y - m_OriginY) * m_Zoom;
int ChunkZ = (BlockZ >= 0) ? (BlockZ / 16) : ((BlockZ + 1) / 16 - 1);
int RelZ = BlockZ - ChunkZ * 16;
for (int x = 0; x < Wid; x++)
{
- int BlockX = (x - m_OriginX) / m_Zoom;
+ int BlockX = (x - m_OriginX) * m_Zoom;
int ChunkX = (BlockX >= 0) ? (BlockX / 16) : ((BlockX + 1) / 16 - 1);
int RelX = BlockX - ChunkX * 16;
if ((ChunkZ != CurChunkZ) || (ChunkX != CurChunkX))
diff --git a/Tools/BiomeVisualiser/BiomeRenderer.h b/Tools/BiomeVisualiser/BiomeRenderer.h
index 2590e0406..752b61811 100644
--- a/Tools/BiomeVisualiser/BiomeRenderer.h
+++ b/Tools/BiomeVisualiser/BiomeRenderer.h
@@ -37,6 +37,11 @@ public:
void MoveViewBy(int a_OffsX, int a_OffsY);
+ void SetZoom(int a_NewZoom)
+ {
+ m_Zoom = a_NewZoom;
+ }
+
protected:
cBiomeCache m_Cache;
diff --git a/Tools/BiomeVisualiser/BiomeViewWnd.cpp b/Tools/BiomeVisualiser/BiomeViewWnd.cpp
index 5c1240bc7..7fb61c062 100644
--- a/Tools/BiomeVisualiser/BiomeViewWnd.cpp
+++ b/Tools/BiomeVisualiser/BiomeViewWnd.cpp
@@ -67,17 +67,41 @@ void cBiomeViewWnd::InitBiomeView(void)
+void cBiomeViewWnd::SetZoom(int a_NewZoom)
+{
+ m_Renderer.SetZoom(a_NewZoom);
+ Redraw();
+}
+
+
+
+
+
+void cBiomeViewWnd::Redraw(void)
+{
+ if (m_Renderer.Render(m_Pixmap))
+ {
+ SetTimer(m_Wnd, TIMER_RERENDER, 200, NULL);
+ }
+ InvalidateRect(m_Wnd, NULL, FALSE);
+}
+
+
+
+
+
LRESULT cBiomeViewWnd::WndProc(HWND a_Wnd, UINT a_Msg, WPARAM wParam, LPARAM lParam)
{
switch (a_Msg)
{
- case WM_CLOSE: return OnClose();
- case WM_COMMAND: return OnCommand(wParam, lParam);
+ case WM_CHAR: return OnChar (wParam, lParam);
+ case WM_CLOSE: return OnClose ();
+ case WM_COMMAND: return OnCommand (wParam, lParam);
case WM_LBUTTONDOWN: return OnLButtonDown(wParam, lParam);
case WM_LBUTTONUP: return OnLButtonUp (wParam, lParam);
case WM_MOUSEMOVE: return OnMouseMove (wParam, lParam);
- case WM_PAINT: return OnPaint();
- case WM_TIMER: return OnTimer(wParam);
+ case WM_PAINT: return OnPaint ();
+ case WM_TIMER: return OnTimer (wParam);
}
return ::DefWindowProc(a_Wnd, a_Msg, wParam, lParam);
}
@@ -86,6 +110,32 @@ LRESULT cBiomeViewWnd::WndProc(HWND a_Wnd, UINT a_Msg, WPARAM wParam, LPARAM lPa
+LRESULT cBiomeViewWnd::OnChar(WPARAM wParam, LPARAM lParam)
+{
+ switch (wParam)
+ {
+ case '1': SetZoom(1); break;
+ case '2': SetZoom(2); break;
+ case '3': SetZoom(3); break;
+ case '4': SetZoom(4); break;
+ case '5': SetZoom(5); break;
+ case '6': SetZoom(6); break;
+ case '7': SetZoom(7); break;
+ case '8': SetZoom(8); break;
+ case 27:
+ {
+ // Esc pressed, exit
+ PostQuitMessage(0);
+ break;
+ }
+ }
+ return 0;
+}
+
+
+
+
+
LRESULT cBiomeViewWnd::OnClose(void)
{
PostQuitMessage(0);
@@ -126,12 +176,8 @@ LRESULT cBiomeViewWnd::OnMouseMove(WPARAM wParam, LPARAM lParam)
POINT pnt;
GetCursorPos(&pnt);
m_Renderer.MoveViewBy(pnt.x - m_MouseDown.x, pnt.y - m_MouseDown.y);
- if (m_Renderer.Render(m_Pixmap))
- {
- SetTimer(m_Wnd, TIMER_RERENDER, 200, NULL);
- }
m_MouseDown = pnt;
- InvalidateRect(m_Wnd, NULL, FALSE);
+ Redraw();
return 0;
}
diff --git a/Tools/BiomeVisualiser/BiomeViewWnd.h b/Tools/BiomeVisualiser/BiomeViewWnd.h
index e3f70c7e6..70c5e38f2 100644
--- a/Tools/BiomeVisualiser/BiomeViewWnd.h
+++ b/Tools/BiomeVisualiser/BiomeViewWnd.h
@@ -48,9 +48,13 @@ protected:
void InitBiomeView(void);
+ void SetZoom(int a_NewZoom);
+ void Redraw(void);
+
LRESULT WndProc(HWND a_Wnd, UINT a_Msg, WPARAM wParam, LPARAM lParam);
// Message handlers:
+ LRESULT OnChar (WPARAM wParam, LPARAM lParam);
LRESULT OnClose (void);
LRESULT OnCommand (WPARAM wParam, LPARAM lParam);
LRESULT OnLButtonDown(WPARAM wParam, LPARAM lParam);
diff --git a/Tools/BiomeVisualiser/BiomeVisualiser.vcproj b/Tools/BiomeVisualiser/BiomeVisualiser.vcproj
index e42870b13..368657938 100644
--- a/Tools/BiomeVisualiser/BiomeVisualiser.vcproj
+++ b/Tools/BiomeVisualiser/BiomeVisualiser.vcproj
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="windows-1250"?>
<VisualStudioProject
ProjectType="Visual C++"
- Version="9,00"
+ Version="9.00"
Name="BiomeVisualiser"
ProjectGUID="{6DF3D88B-AD47-45B6-B831-1BDE74F86B5C}"
RootNamespace="BiomeVisualiser"
@@ -273,6 +273,10 @@
>
</File>
<File
+ RelativePath=".\BiomeColors.h"
+ >
+ </File>
+ <File
RelativePath=".\BiomeRenderer.cpp"
>
</File>
@@ -501,10 +505,6 @@
</Filter>
</Filter>
</Filter>
- <File
- RelativePath=".\BiomeColors.h"
- >
- </File>
</Files>
<Globals>
</Globals>
diff --git a/Tools/ProtoProxy/Connection.cpp b/Tools/ProtoProxy/Connection.cpp
index 10f2b4073..f38ea02ed 100644
--- a/Tools/ProtoProxy/Connection.cpp
+++ b/Tools/ProtoProxy/Connection.cpp
@@ -2390,12 +2390,12 @@ bool cConnection::HandleServerStatusResponse(void)
{
Response.assign(Response.substr(0, idx + sizeof(DescSearch) - 1) + "ProtoProxy: " + Response.substr(idx + sizeof(DescSearch) - 1));
}
- cByteBuffer Packet(1000);
+ cByteBuffer Packet(Response.size() + 50);
Packet.WriteVarInt(0); // Packet type - status response
Packet.WriteVarUTF8String(Response);
AString Pkt;
Packet.ReadAll(Pkt);
- cByteBuffer ToClient(1000);
+ cByteBuffer ToClient(Response.size() + 50);
ToClient.WriteVarUTF8String(Pkt);
CLIENTSEND(ToClient);
return true;
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp
index 6221727c4..344d5d2e0 100644
--- a/src/Bindings/ManualBindings.cpp
+++ b/src/Bindings/ManualBindings.cpp
@@ -1904,6 +1904,35 @@ static int tolua_cWebPlugin_GetTabNames(lua_State * tolua_S)
+static int tolua_cClientHandle_SendPluginMessage(lua_State * L)
+{
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserType(1, "cClientHandle") ||
+ !S.CheckParamString(2, 3) ||
+ !S.CheckParamEnd(4)
+ )
+ {
+ return 0;
+ }
+ cClientHandle * Client = (cClientHandle *)tolua_tousertype(L, 1, NULL);
+ if (Client == NULL)
+ {
+ LOGWARNING("ClientHandle is nil in cClientHandle:SendPluginMessage()");
+ S.LogStackTrace();
+ return 0;
+ }
+ AString Channel, Message;
+ Channel.assign(lua_tostring(L, 2), lua_strlen(L, 2));
+ Message.assign(lua_tostring(L, 3), lua_strlen(L, 3));
+ Client->SendPluginMessage(Channel, Message);
+ return 0;
+}
+
+
+
+
+
static int Lua_ItemGrid_GetSlotCoords(lua_State * L)
{
tolua_Error tolua_err;
@@ -2292,6 +2321,7 @@ void ManualBindings::Bind(lua_State * tolua_S)
tolua_beginmodule(tolua_S, "cClientHandle");
tolua_constant(tolua_S, "MAX_VIEW_DISTANCE", cClientHandle::MAX_VIEW_DISTANCE);
tolua_constant(tolua_S, "MIN_VIEW_DISTANCE", cClientHandle::MIN_VIEW_DISTANCE);
+ tolua_function(tolua_S, "SendPluginMessage", tolua_cClientHandle_SendPluginMessage);
tolua_endmodule(tolua_S);
tolua_beginmodule(tolua_S, "cItemGrid");
diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp
index 209842e55..eefcd2b09 100644
--- a/src/Bindings/PluginLua.cpp
+++ b/src/Bindings/PluginLua.cpp
@@ -90,6 +90,8 @@ bool cPluginLua::Initialize(void)
// Load all files for this plugin, and execute them
AStringVector Files = cFile::GetFolderContents(PluginPath.c_str());
+
+ int numFiles = 0;
for (AStringVector::const_iterator itr = Files.begin(); itr != Files.end(); ++itr)
{
if (itr->rfind(".lua") == AString::npos)
@@ -101,9 +103,20 @@ bool cPluginLua::Initialize(void)
{
Close();
return false;
+ }
+ else
+ {
+ numFiles++;
}
} // for itr - Files[]
+ if (numFiles == 0)
+ {
+ LOGWARNING("No lua files found: plugin %s is missing.", GetName().c_str());
+ Close();
+ return false;
+ }
+
// Call intialize function
bool res = false;
if (!m_LuaState.Call("Initialize", this, cLuaState::Return, res))
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 8125acb47..9348a1825 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -1978,6 +1978,15 @@ void cClientHandle::SendPlayerSpawn(const cPlayer & a_Player)
+void cClientHandle::SendPluginMessage(const AString & a_Channel, const AString & a_Message)
+{
+ m_Protocol->SendPluginMessage(a_Channel, a_Message);
+}
+
+
+
+
+
void cClientHandle::SendRemoveEntityEffect(const cEntity & a_Entity, int a_EffectID)
{
m_Protocol->SendRemoveEntityEffect(a_Entity, a_EffectID);
diff --git a/src/ClientHandle.h b/src/ClientHandle.h
index bc17df780..297d62d57 100644
--- a/src/ClientHandle.h
+++ b/src/ClientHandle.h
@@ -120,6 +120,7 @@ public:
void SendPlayerMoveLook (void);
void SendPlayerPosition (void);
void SendPlayerSpawn (const cPlayer & a_Player);
+ void SendPluginMessage (const AString & a_Channel, const AString & a_Message); // Exported in ManualBindings.cpp
void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID);
void SendRespawn (void);
void SendExperience (void);
diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp
index c86568c95..76d06724d 100644
--- a/src/Generating/ComposableGenerator.cpp
+++ b/src/Generating/ComposableGenerator.cpp
@@ -28,11 +28,87 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cTerrainCompositionGen:
+cTerrainCompositionGen * cTerrainCompositionGen::CreateCompositionGen(cIniFile & a_IniFile, cBiomeGen & a_BiomeGen, cTerrainHeightGen & a_HeightGen, int a_Seed)
+{
+ AString CompoGenName = a_IniFile.GetValueSet("Generator", "CompositionGen", "");
+ if (CompoGenName.empty())
+ {
+ LOGWARN("[Generator] CompositionGen value not set in world.ini, using \"Biomal\".");
+ CompoGenName = "Biomal";
+ a_IniFile.SetValue("Generator", "CompositionGen", CompoGenName);
+ }
+
+ cTerrainCompositionGen * res = NULL;
+ if (NoCaseCompare(CompoGenName, "sameblock") == 0)
+ {
+ res = new cCompoGenSameBlock;
+ }
+ else if (NoCaseCompare(CompoGenName, "debugbiomes") == 0)
+ {
+ res = new cCompoGenDebugBiomes;
+ }
+ else if (NoCaseCompare(CompoGenName, "classic") == 0)
+ {
+ res = new cCompoGenClassic;
+ }
+ else if (NoCaseCompare(CompoGenName, "DistortedHeightmap") == 0)
+ {
+ res = new cDistortedHeightmap(a_Seed, a_BiomeGen);
+ }
+ else if (NoCaseCompare(CompoGenName, "end") == 0)
+ {
+ res = new cEndGen(a_Seed);
+ }
+ else if (NoCaseCompare(CompoGenName, "nether") == 0)
+ {
+ res = new cCompoGenNether(a_Seed);
+ }
+ else if (NoCaseCompare(CompoGenName, "Noise3D") == 0)
+ {
+ res = new cNoise3DComposable(a_Seed);
+ }
+ else if (NoCaseCompare(CompoGenName, "biomal") == 0)
+ {
+ res = new cCompoGenBiomal(a_Seed);
+
+ /*
+ // Performance-testing:
+ LOGINFO("Measuring performance of cCompoGenBiomal...");
+ clock_t BeginTick = clock();
+ for (int x = 0; x < 500; x++)
+ {
+ cChunkDesc Desc(200 + x * 8, 200 + x * 8);
+ a_BiomeGen->GenBiomes(Desc.GetChunkX(), Desc.GetChunkZ(), Desc.GetBiomeMap());
+ a_HeightGen->GenHeightMap(Desc.GetChunkX(), Desc.GetChunkZ(), Desc.GetHeightMap());
+ res->ComposeTerrain(Desc);
+ }
+ clock_t Duration = clock() - BeginTick;
+ LOGINFO("CompositionGen for 500 chunks took %d ticks (%.02f sec)", Duration, (double)Duration / CLOCKS_PER_SEC);
+ //*/
+ }
+ else
+ {
+ LOGWARN("Unknown CompositionGen \"%s\", using \"biomal\" instead.", CompoGenName.c_str());
+ a_IniFile.SetValue("Generator", "CompositionGen", "Biomal");
+ return CreateCompositionGen(a_IniFile, a_BiomeGen, a_HeightGen, a_Seed);
+ }
+ ASSERT(res != NULL);
+
+ // Read the settings from the ini file:
+ res->InitializeCompoGen(a_IniFile);
+
+ return res;
+}
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cComposableGenerator:
+
cComposableGenerator::cComposableGenerator(cChunkGenerator & a_ChunkGenerator) :
super(a_ChunkGenerator),
m_BiomeGen(NULL),
@@ -173,60 +249,8 @@ void cComposableGenerator::InitBiomeGen(cIniFile & a_IniFile)
void cComposableGenerator::InitHeightGen(cIniFile & a_IniFile)
{
- AString HeightGenName = a_IniFile.GetValueSet("Generator", "HeightGen", "");
- if (HeightGenName.empty())
- {
- LOGWARN("[Generator] HeightGen value not set in world.ini, using \"Biomal\".");
- HeightGenName = "Biomal";
- }
-
- int Seed = m_ChunkGenerator.GetSeed();
bool CacheOffByDefault = false;
- if (NoCaseCompare(HeightGenName, "flat") == 0)
- {
- m_HeightGen = new cHeiGenFlat;
- CacheOffByDefault = true; // We're generating faster than a cache would retrieve data
- }
- else if (NoCaseCompare(HeightGenName, "classic") == 0)
- {
- m_HeightGen = new cHeiGenClassic(Seed);
- }
- else if (NoCaseCompare(HeightGenName, "DistortedHeightmap") == 0)
- {
- m_HeightGen = new cDistortedHeightmap(Seed, *m_BiomeGen);
- }
- else if (NoCaseCompare(HeightGenName, "End") == 0)
- {
- m_HeightGen = new cEndGen(Seed);
- }
- else if (NoCaseCompare(HeightGenName, "Noise3D") == 0)
- {
- m_HeightGen = new cNoise3DComposable(Seed);
- }
- else // "biomal" or <not found>
- {
- if (NoCaseCompare(HeightGenName, "biomal") != 0)
- {
- LOGWARN("Unknown HeightGen \"%s\", using \"Biomal\" instead.", HeightGenName.c_str());
- }
- m_HeightGen = new cHeiGenBiomal(Seed, *m_BiomeGen);
-
- /*
- // Performance-testing:
- LOGINFO("Measuring performance of cHeiGenBiomal...");
- clock_t BeginTick = clock();
- for (int x = 0; x < 500; x++)
- {
- cChunkDef::HeightMap Heights;
- m_HeightGen->GenHeightMap(x * 5, x * 5, Heights);
- }
- clock_t Duration = clock() - BeginTick;
- LOGINFO("HeightGen for 500 chunks took %d ticks (%.02f sec)", Duration, (double)Duration / CLOCKS_PER_SEC);
- //*/
- }
-
- // Read the settings:
- m_HeightGen->InitializeHeightGen(a_IniFile);
+ m_HeightGen = cTerrainHeightGen::CreateHeightGen(a_IniFile, *m_BiomeGen, m_ChunkGenerator.GetSeed(), CacheOffByDefault);
// Add a cache, if requested:
int CacheSize = a_IniFile.GetValueSetI("Generator", "HeightGenCacheSize", CacheOffByDefault ? 0 : 64);
@@ -251,67 +275,7 @@ void cComposableGenerator::InitHeightGen(cIniFile & a_IniFile)
void cComposableGenerator::InitCompositionGen(cIniFile & a_IniFile)
{
- int Seed = m_ChunkGenerator.GetSeed();
- AString CompoGenName = a_IniFile.GetValueSet("Generator", "CompositionGen", "");
- if (CompoGenName.empty())
- {
- LOGWARN("[Generator] CompositionGen value not set in world.ini, using \"Biomal\".");
- CompoGenName = "Biomal";
- }
- if (NoCaseCompare(CompoGenName, "sameblock") == 0)
- {
- m_CompositionGen = new cCompoGenSameBlock;
- }
- else if (NoCaseCompare(CompoGenName, "debugbiomes") == 0)
- {
- m_CompositionGen = new cCompoGenDebugBiomes;
- }
- else if (NoCaseCompare(CompoGenName, "classic") == 0)
- {
- m_CompositionGen = new cCompoGenClassic;
- }
- else if (NoCaseCompare(CompoGenName, "DistortedHeightmap") == 0)
- {
- m_CompositionGen = new cDistortedHeightmap(Seed, *m_BiomeGen);
- }
- else if (NoCaseCompare(CompoGenName, "end") == 0)
- {
- m_CompositionGen = new cEndGen(Seed);
- }
- else if (NoCaseCompare(CompoGenName, "nether") == 0)
- {
- m_CompositionGen = new cCompoGenNether(Seed);
- }
- else if (NoCaseCompare(CompoGenName, "Noise3D") == 0)
- {
- m_CompositionGen = new cNoise3DComposable(m_ChunkGenerator.GetSeed());
- }
- else
- {
- if (NoCaseCompare(CompoGenName, "biomal") != 0)
- {
- LOGWARN("Unknown CompositionGen \"%s\", using \"biomal\" instead.", CompoGenName.c_str());
- }
- m_CompositionGen = new cCompoGenBiomal(Seed);
-
- /*
- // Performance-testing:
- LOGINFO("Measuring performance of cCompoGenBiomal...");
- clock_t BeginTick = clock();
- for (int x = 0; x < 500; x++)
- {
- cChunkDesc Desc(200 + x * 8, 200 + x * 8);
- m_BiomeGen->GenBiomes(Desc.GetChunkX(), Desc.GetChunkZ(), Desc.GetBiomeMap());
- m_HeightGen->GenHeightMap(Desc.GetChunkX(), Desc.GetChunkZ(), Desc.GetHeightMap());
- m_CompositionGen->ComposeTerrain(Desc);
- }
- clock_t Duration = clock() - BeginTick;
- LOGINFO("CompositionGen for 500 chunks took %d ticks (%.02f sec)", Duration, (double)Duration / CLOCKS_PER_SEC);
- //*/
- }
-
- // Read the settings from the ini file:
- m_CompositionGen->InitializeCompoGen(a_IniFile);
+ m_CompositionGen = cTerrainCompositionGen::CreateCompositionGen(a_IniFile, *m_BiomeGen, *m_HeightGen, m_ChunkGenerator.GetSeed());
int CompoGenCacheSize = a_IniFile.GetValueSetI("Generator", "CompositionGenCacheSize", 64);
if (CompoGenCacheSize > 1)
diff --git a/src/Generating/ComposableGenerator.h b/src/Generating/ComposableGenerator.h
index 732f64303..7c9c97586 100644
--- a/src/Generating/ComposableGenerator.h
+++ b/src/Generating/ComposableGenerator.h
@@ -50,7 +50,7 @@ public:
virtual void InitializeBiomeGen(cIniFile & a_IniFile) {}
/// Creates the correct BiomeGen descendant based on the ini file settings and the seed provided.
- /// a_CacheOffByDefault gets set to whether the cache should be enabled by default
+ /// a_CacheOffByDefault gets set to whether the cache should be disabled by default
/// Used in BiomeVisualiser, too.
/// Implemented in BioGen.cpp!
static cBiomeGen * CreateBiomeGen(cIniFile & a_IniFile, int a_Seed, bool & a_CacheOffByDefault);
@@ -77,6 +77,13 @@ public:
/// Reads parameters from the ini file, prepares generator for use.
virtual void InitializeHeightGen(cIniFile & a_IniFile) {}
+
+ /** Creates the correct TerrainHeightGen descendant based on the ini file settings and the seed provided.
+ a_BiomeGen is the underlying biome generator, some height generators may depend on it to generate more biomes
+ a_CacheOffByDefault gets set to whether the cache should be disabled by default
+ Implemented in HeiGen.cpp!
+ */
+ static cTerrainHeightGen * CreateHeightGen(cIniFile & a_IniFile, cBiomeGen & a_BiomeGen, int a_Seed, bool & a_CacheOffByDefault);
} ;
@@ -97,6 +104,12 @@ public:
/// Reads parameters from the ini file, prepares generator for use.
virtual void InitializeCompoGen(cIniFile & a_IniFile) {}
+
+ /** Creates the correct TerrainCompositionGen descendant based on the ini file settings and the seed provided.
+ a_BiomeGen is the underlying biome generator, some composition generators may depend on it to generate more biomes
+ a_HeightGen is the underlying height generator, some composition generators may depend on it providing additional values
+ */
+ static cTerrainCompositionGen * CreateCompositionGen(cIniFile & a_IniFile, cBiomeGen & a_BiomeGen, cTerrainHeightGen & a_HeightGen, int a_Seed);
} ;
diff --git a/src/Generating/HeiGen.cpp b/src/Generating/HeiGen.cpp
index 2bf641089..051758f71 100644
--- a/src/Generating/HeiGen.cpp
+++ b/src/Generating/HeiGen.cpp
@@ -7,6 +7,9 @@
#include "HeiGen.h"
#include "../LinearUpscale.h"
#include "inifile/iniFile.h"
+#include "DistortedHeightmap.h"
+#include "EndGen.h"
+#include "Noise3DGenerator.h"
@@ -14,6 +17,76 @@
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cTerrainHeightGen:
+
+cTerrainHeightGen * cTerrainHeightGen::CreateHeightGen(cIniFile &a_IniFile, cBiomeGen & a_BiomeGen, int a_Seed, bool & a_CacheOffByDefault)
+{
+ AString HeightGenName = a_IniFile.GetValueSet("Generator", "HeightGen", "");
+ if (HeightGenName.empty())
+ {
+ LOGWARN("[Generator] HeightGen value not set in world.ini, using \"Biomal\".");
+ HeightGenName = "Biomal";
+ }
+
+ a_CacheOffByDefault = false;
+ cTerrainHeightGen * res = NULL;
+ if (NoCaseCompare(HeightGenName, "flat") == 0)
+ {
+ res = new cHeiGenFlat;
+ a_CacheOffByDefault = true; // We're generating faster than a cache would retrieve data
+ }
+ else if (NoCaseCompare(HeightGenName, "classic") == 0)
+ {
+ res = new cHeiGenClassic(a_Seed);
+ }
+ else if (NoCaseCompare(HeightGenName, "DistortedHeightmap") == 0)
+ {
+ res = new cDistortedHeightmap(a_Seed, a_BiomeGen);
+ }
+ else if (NoCaseCompare(HeightGenName, "End") == 0)
+ {
+ res = new cEndGen(a_Seed);
+ }
+ else if (NoCaseCompare(HeightGenName, "Noise3D") == 0)
+ {
+ res = new cNoise3DComposable(a_Seed);
+ }
+ else if (NoCaseCompare(HeightGenName, "biomal") == 0)
+ {
+ res = new cHeiGenBiomal(a_Seed, a_BiomeGen);
+
+ /*
+ // Performance-testing:
+ LOGINFO("Measuring performance of cHeiGenBiomal...");
+ clock_t BeginTick = clock();
+ for (int x = 0; x < 500; x++)
+ {
+ cChunkDef::HeightMap Heights;
+ res->GenHeightMap(x * 5, x * 5, Heights);
+ }
+ clock_t Duration = clock() - BeginTick;
+ LOGINFO("HeightGen for 500 chunks took %d ticks (%.02f sec)", Duration, (double)Duration / CLOCKS_PER_SEC);
+ //*/
+ }
+ else
+ {
+ // No match found, force-set the default and retry
+ LOGWARN("Unknown HeightGen \"%s\", using \"Biomal\" instead.", HeightGenName.c_str());
+ a_IniFile.SetValue("Generator", "HeightGen", "Biomal");
+ return CreateHeightGen(a_IniFile, a_BiomeGen, a_Seed, a_CacheOffByDefault);
+ }
+
+ // Read the settings:
+ res->InitializeHeightGen(a_IniFile);
+
+ return res;
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cHeiGenFlat:
void cHeiGenFlat::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap)
diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h
index fdbffb3e9..3293da32c 100644
--- a/src/Protocol/Protocol.h
+++ b/src/Protocol/Protocol.h
@@ -87,6 +87,7 @@ public:
virtual void SendPlayerMoveLook (void) = 0;
virtual void SendPlayerPosition (void) = 0;
virtual void SendPlayerSpawn (const cPlayer & a_Player) = 0;
+ virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) = 0;
virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) = 0;
virtual void SendRespawn (void) = 0;
virtual void SendExperience (void) = 0;
diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp
index e49dd43ff..48c085ae5 100644
--- a/src/Protocol/Protocol125.cpp
+++ b/src/Protocol/Protocol125.cpp
@@ -704,6 +704,20 @@ void cProtocol125::SendPlayerSpawn(const cPlayer & a_Player)
+void cProtocol125::SendPluginMessage(const AString & a_Channel, const AString & a_Message)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte(PACKET_PLUGIN_MESSAGE);
+ WriteString(a_Channel);
+ WriteShort((short)a_Message.size());
+ SendData(a_Message.data(), a_Message.size());
+ Flush();
+}
+
+
+
+
+
void cProtocol125::SendRemoveEntityEffect(const cEntity & a_Entity, int a_EffectID)
{
cCSLock Lock(m_CSPacket);
diff --git a/src/Protocol/Protocol125.h b/src/Protocol/Protocol125.h
index 0b32137d8..d0e5c9428 100644
--- a/src/Protocol/Protocol125.h
+++ b/src/Protocol/Protocol125.h
@@ -63,6 +63,7 @@ public:
virtual void SendPlayerMoveLook (void) override;
virtual void SendPlayerPosition (void) override;
virtual void SendPlayerSpawn (const cPlayer & a_Player) override;
+ virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) override;
virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override;
virtual void SendRespawn (void) override;
virtual void SendExperience (void) override;
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index 8ec5dec29..9c46c6843 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -628,6 +628,18 @@ void cProtocol172::SendPlayerSpawn(const cPlayer & a_Player)
+void cProtocol172::SendPluginMessage(const AString & a_Channel, const AString & a_Message)
+{
+ cPacketizer Pkt(*this, 0x3f);
+ Pkt.WriteString(a_Channel);
+ Pkt.WriteShort((short)a_Message.size());
+ Pkt.WriteBuf(a_Message.data(), a_Message.size());
+}
+
+
+
+
+
void cProtocol172::SendRemoveEntityEffect(const cEntity & a_Entity, int a_EffectID)
{
cPacketizer Pkt(*this, 0x1E);
diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h
index 23ff2365d..fd6b1fc0f 100644
--- a/src/Protocol/Protocol17x.h
+++ b/src/Protocol/Protocol17x.h
@@ -86,6 +86,7 @@ public:
virtual void SendPlayerMoveLook (void) override;
virtual void SendPlayerPosition (void) override;
virtual void SendPlayerSpawn (const cPlayer & a_Player) override;
+ virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) override;
virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override;
virtual void SendRespawn (void) override;
virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override; // a_Src coords are Block * 8
diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp
index e2ea0e6e5..a21f4f042 100644
--- a/src/Protocol/ProtocolRecognizer.cpp
+++ b/src/Protocol/ProtocolRecognizer.cpp
@@ -476,6 +476,16 @@ void cProtocolRecognizer::SendPlayerSpawn(const cPlayer & a_Player)
+void cProtocolRecognizer::SendPluginMessage(const AString & a_Channel, const AString & a_Message)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendPluginMessage(a_Channel, a_Message);
+}
+
+
+
+
+
void cProtocolRecognizer::SendRemoveEntityEffect(const cEntity & a_Entity, int a_EffectID)
{
ASSERT(m_Protocol != NULL);
diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h
index fbcf59f3b..e94f4cde8 100644
--- a/src/Protocol/ProtocolRecognizer.h
+++ b/src/Protocol/ProtocolRecognizer.h
@@ -98,6 +98,7 @@ public:
virtual void SendPlayerMoveLook (void) override;
virtual void SendPlayerPosition (void) override;
virtual void SendPlayerSpawn (const cPlayer & a_Player) override;
+ virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) override;
virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override;
virtual void SendRespawn (void) override;
virtual void SendExperience (void) override;