summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Tools/BiomeVisualiser/.gitignore3
-rw-r--r--Tools/BiomeVisualiser/BiomeViewWnd.cpp2
-rw-r--r--Tools/BiomeVisualiser/BiomeVisualiser.cpp4
-rw-r--r--Tools/BiomeVisualiser/BiomeVisualiser.h2
-rw-r--r--Tools/BiomeVisualiser/BiomeVisualiser.vcproj28
-rw-r--r--Tools/ProtoProxy/.gitignore1
-rw-r--r--Tools/ProtoProxy/Connection.cpp109
-rw-r--r--Tools/ProtoProxy/Connection.h1
8 files changed, 128 insertions, 22 deletions
diff --git a/Tools/BiomeVisualiser/.gitignore b/Tools/BiomeVisualiser/.gitignore
new file mode 100644
index 000000000..b4e15dc3c
--- /dev/null
+++ b/Tools/BiomeVisualiser/.gitignore
@@ -0,0 +1,3 @@
+Debug/
+logs/
+Release/
diff --git a/Tools/BiomeVisualiser/BiomeViewWnd.cpp b/Tools/BiomeVisualiser/BiomeViewWnd.cpp
index 3dd1bb4e0..7d4db58c0 100644
--- a/Tools/BiomeVisualiser/BiomeViewWnd.cpp
+++ b/Tools/BiomeVisualiser/BiomeViewWnd.cpp
@@ -45,7 +45,7 @@ bool cBiomeViewWnd::Create(HWND a_ParentWnd, LPCTSTR a_Title)
cIniFile IniFile;
cBiomeGen * BioGen = new cBioGenMultiStepMap(2);
- BioGen->Initialize(IniFile);
+ BioGen->InitializeBiomeGen(IniFile);
m_Renderer.SetSource(new cGeneratorBiomeSource(BioGen));
return true;
diff --git a/Tools/BiomeVisualiser/BiomeVisualiser.cpp b/Tools/BiomeVisualiser/BiomeVisualiser.cpp
index e1d379f83..a36111d77 100644
--- a/Tools/BiomeVisualiser/BiomeVisualiser.cpp
+++ b/Tools/BiomeVisualiser/BiomeVisualiser.cpp
@@ -21,8 +21,8 @@ int WINAPI WinMain(HINSTANCE a_Instance, HINSTANCE a_PrevInstance, LPSTR a_CmdLi
-cBiomeVisualiser::cBiomeVisualiser(void)
- // : m_Logger(Printf("BiomeVisualiser_%08x", time(NULL)))
+cBiomeVisualiser::cBiomeVisualiser(void) :
+ m_Logger(new cMCLogger(Printf("BiomeVisualiser_%08x.log", time(NULL))))
{
}
diff --git a/Tools/BiomeVisualiser/BiomeVisualiser.h b/Tools/BiomeVisualiser/BiomeVisualiser.h
index 3fa90646b..4f8ce7513 100644
--- a/Tools/BiomeVisualiser/BiomeVisualiser.h
+++ b/Tools/BiomeVisualiser/BiomeVisualiser.h
@@ -23,7 +23,7 @@ public:
protected:
cBiomeViewWnd m_MainWnd;
- cMCLogger m_Logger;
+ cMCLogger * m_Logger;
} ;
diff --git a/Tools/BiomeVisualiser/BiomeVisualiser.vcproj b/Tools/BiomeVisualiser/BiomeVisualiser.vcproj
index 522606d60..5f840129d 100644
--- a/Tools/BiomeVisualiser/BiomeVisualiser.vcproj
+++ b/Tools/BiomeVisualiser/BiomeVisualiser.vcproj
@@ -332,6 +332,22 @@
>
</File>
<File
+ RelativePath="..\..\source\Enchantments.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\Enchantments.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\WorldStorage\FastNBT.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\WorldStorage\FastNBT.h"
+ >
+ </File>
+ <File
RelativePath="..\..\source\Globals.cpp"
>
<FileConfiguration
@@ -364,6 +380,10 @@
>
</File>
<File
+ RelativePath="..\..\source\Item.h"
+ >
+ </File>
+ <File
RelativePath="..\..\source\Log.cpp"
>
</File>
@@ -435,14 +455,6 @@
>
</File>
<File
- RelativePath="..\..\source\OSSupport\MakeDir.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\MakeDir.h"
- >
- </File>
- <File
RelativePath="..\..\source\OSSupport\Sleep.h"
>
</File>
diff --git a/Tools/ProtoProxy/.gitignore b/Tools/ProtoProxy/.gitignore
index 3097f7aab..2a38341e5 100644
--- a/Tools/ProtoProxy/.gitignore
+++ b/Tools/ProtoProxy/.gitignore
@@ -1,4 +1,5 @@
Debug
Release
+Logs/
*.log
*.nbt
diff --git a/Tools/ProtoProxy/Connection.cpp b/Tools/ProtoProxy/Connection.cpp
index fc8fceb99..c4776949e 100644
--- a/Tools/ProtoProxy/Connection.cpp
+++ b/Tools/ProtoProxy/Connection.cpp
@@ -8,11 +8,21 @@
#include "Server.h"
#include <iostream>
+#ifdef _WIN32
+ #include <direct.h> // For _mkdir()
+#endif
-#ifdef _DEBUG
+/// When defined, the following macro causes a sleep after each parsed packet (DEBUG-mode only)
+// #define SLEEP_AFTER_PACKET
+
+
+
+
+
+#if defined(_DEBUG) && defined(SLEEP_AFTER_PACKET)
#define DebugSleep Sleep
#else
#define DebugSleep(X)
@@ -179,6 +189,7 @@ enum
PACKET_BLOCK_CHANGE = 0x35,
PACKET_BLOCK_ACTION = 0x36,
PACKET_MAP_CHUNK_BULK = 0x38,
+ PACKET_EXPLOSION = 0x3c,
PACKET_SOUND_EFFECT = 0x3d,
PACKET_NAMED_SOUND_EFFECT = 0x3e,
PACKET_CHANGE_GAME_STATE = 0x46,
@@ -261,7 +272,14 @@ cConnection::cConnection(SOCKET a_ClientSocket, cServer & a_Server) :
m_ServerBuffer(1024 KiB),
m_HasClientPinged(false)
{
- Printf(m_LogNameBase, "Log_%d", (int)time(NULL));
+ // Create the Logs subfolder, if not already created:
+ #if defined(_WIN32)
+ _mkdir("Logs");
+ #else
+ mkdir("Logs", 0777);
+ #endif
+
+ Printf(m_LogNameBase, "Logs/Log_%d", (int)time(NULL));
AString fnam(m_LogNameBase);
fnam.append(".log");
m_LogFile = fopen(fnam.c_str(), "w");
@@ -289,7 +307,7 @@ void cConnection::Run(void)
Log("Cannot connect to server; aborting");
return;
}
-
+
while (true)
{
fd_set ReadFDs;
@@ -684,6 +702,7 @@ bool cConnection::DecodeServersPackets(const char * a_Data, int a_Size)
case PACKET_ENTITY_STATUS: HANDLE_SERVER_READ(HandleServerEntityStatus); break;
case PACKET_ENTITY_TELEPORT: HANDLE_SERVER_READ(HandleServerEntityTeleport); break;
case PACKET_ENTITY_VELOCITY: HANDLE_SERVER_READ(HandleServerEntityVelocity); break;
+ case PACKET_EXPLOSION: HANDLE_SERVER_READ(HandleServerExplosion); break;
case PACKET_INCREMENT_STATISTIC: HANDLE_SERVER_READ(HandleServerIncrementStatistic); break;
case PACKET_KEEPALIVE: HANDLE_SERVER_READ(HandleServerKeepAlive); break;
case PACKET_KICK: HANDLE_SERVER_READ(HandleServerKick); break;
@@ -1576,6 +1595,49 @@ bool cConnection::HandleServerEntityVelocity(void)
+bool cConnection::HandleServerExplosion(void)
+{
+ HANDLE_SERVER_PACKET_READ(ReadBEDouble, double, PosX);
+ HANDLE_SERVER_PACKET_READ(ReadBEDouble, double, PosY);
+ HANDLE_SERVER_PACKET_READ(ReadBEDouble, double, PosZ);
+ HANDLE_SERVER_PACKET_READ(ReadBEFloat, float, Force);
+ HANDLE_SERVER_PACKET_READ(ReadBEInt, int, NumRecords);
+ struct sCoords
+ {
+ int x, y, z;
+
+ sCoords(int a_X, int a_Y, int a_Z) : x(a_X), y(a_Y), z(a_Z) {}
+ } ;
+ std::vector<sCoords> Records;
+ Records.reserve(NumRecords);
+ int PosXI = (int)PosX, PosYI = (int)PosY, PosZI = (int)PosZ;
+ for (int i = 0; i < NumRecords; i++)
+ {
+ HANDLE_SERVER_PACKET_READ(ReadChar, char, rx);
+ HANDLE_SERVER_PACKET_READ(ReadChar, char, ry);
+ HANDLE_SERVER_PACKET_READ(ReadChar, char, rz);
+ Records.push_back(sCoords(PosXI + rx, PosYI + ry, PosZI + rz));
+ }
+ HANDLE_SERVER_PACKET_READ(ReadBEFloat, float, PlayerMotionX);
+ HANDLE_SERVER_PACKET_READ(ReadBEFloat, float, PlayerMotionY);
+ HANDLE_SERVER_PACKET_READ(ReadBEFloat, float, PlayerMotionZ);
+ Log("Received a PACKET_EXPLOSION from the server:");
+ Log(" Pos = {%.02f, %.02f, %.02f}", PosX, PosY, PosZ);
+ Log(" Force = %.02f", Force);
+ Log(" NumRecords = %d", NumRecords);
+ for (int i = 0; i < NumRecords; i++)
+ {
+ Log(" Records[%d] = {%d, %d, %d}", i, Records[i].x, Records[i].y, Records[i].z);
+ }
+ Log(" Player motion = <%.02f, %.02f, %.02f>", PlayerMotionX, PlayerMotionY, PlayerMotionZ);
+ COPY_TO_CLIENT();
+ return true;
+}
+
+
+
+
+
bool cConnection::HandleServerIncrementStatistic(void)
{
// 0xc8
@@ -1636,7 +1698,8 @@ bool cConnection::HandleServerKick(void)
// Split by NULL chars (StringSplit() won't work here):
size_t Last = 0;
- for (size_t i = 0; i < Reason.size(); i++)
+ size_t Len = Reason.size();
+ for (size_t i = 0; i < Len; i++)
{
if (Reason[i] == 0)
{
@@ -1644,14 +1707,40 @@ bool cConnection::HandleServerKick(void)
Last = i + 1;
}
}
+ if (Last < Len)
+ {
+ Split.push_back(Reason.substr(Last));
+ }
- if (Split.size() == 5)
+ if (Split.size() == 6)
{
- Log(" Protocol version: \"%s\"", Split[0].c_str());
- Log(" Server version: \"%s\"", Split[1].c_str());
- Log(" MOTD: \"%s\"", Split[2].c_str());
- Log(" Cur players: \"%s\"", Split[3].c_str());
- Log(" Max players: \"%s\"", Split[4].c_str());
+ Log(" Preamble: \"%s\"", Split[0].c_str());
+ Log(" Protocol version: \"%s\"", Split[1].c_str());
+ Log(" Server version: \"%s\"", Split[2].c_str());
+ Log(" MOTD: \"%s\"", Split[3].c_str());
+ Log(" Cur players: \"%s\"", Split[4].c_str());
+ Log(" Max players: \"%s\"", Split[5].c_str());
+
+ // Modify the MOTD to show that it's being ProtoProxied:
+ Reason.assign(Split[0]);
+ Reason.push_back(0);
+ Reason.append(Split[1]);
+ Reason.push_back(0);
+ Reason.append(Split[2]);
+ Reason.push_back(0);
+ Reason.append(Printf("ProtoProxy: %s", Split[3].c_str()));
+ Reason.push_back(0);
+ Reason.append(Split[4]);
+ Reason.push_back(0);
+ Reason.append(Split[5]);
+ AString ReasonBE16;
+ UTF8ToRawBEUTF16(Reason.data(), Reason.size(), ReasonBE16);
+ AString PacketStart("\xff");
+ PacketStart.push_back((ReasonBE16.size() / 2) / 256);
+ PacketStart.push_back((ReasonBE16.size() / 2) % 256);
+ CLIENTSEND(PacketStart.data(), PacketStart.size());
+ CLIENTSEND(ReasonBE16.data(), ReasonBE16.size());
+ return true;
}
else
{
diff --git a/Tools/ProtoProxy/Connection.h b/Tools/ProtoProxy/Connection.h
index c30a28727..6093408d6 100644
--- a/Tools/ProtoProxy/Connection.h
+++ b/Tools/ProtoProxy/Connection.h
@@ -158,6 +158,7 @@ protected:
bool HandleServerEntityStatus(void);
bool HandleServerEntityTeleport(void);
bool HandleServerEntityVelocity(void);
+ bool HandleServerExplosion(void);
bool HandleServerIncrementStatistic(void);
bool HandleServerKeepAlive(void);
bool HandleServerKick(void);