Permalink
Browse files

Merge branch 'master' into Inventory

  • Loading branch information...
Howaner committed Feb 6, 2015
2 parents 1f94c31 + e7424ad commit 2c7925f0adc17d7680ff9791832ab2c349c2301f
Showing with 1,386 additions and 2,098 deletions.
  1. +99 −0 Install/ThirdPartyLicenses/LibEvent-LICENSE.txt
  2. +6 −3 MCServer/Plugins/Debuggers/Debuggers.lua
  3. +1 −0 MCServer/webadmin/GenerateSelfSignedHTTPSCertUsingOpenssl.cmd
  4. +40 −2 Tools/RCONClient/Globals.h
  5. +10 −9 Tools/RCONClient/RCONClient.cpp
  6. +5 −3 Tools/RCONClient/RCONClient.sln
  7. +1 −1 lib/libevent
  8. +1 −1 lib/polarssl
  9. +1 −15 src/Bindings/LuaState.h
  10. +1 −0 src/CheckBasicStyle.lua
  11. +12 −6 src/Chunk.cpp
  12. +134 −111 src/ClientHandle.cpp
  13. +54 −30 src/ClientHandle.h
  14. +17 −7 src/Entities/Player.cpp
  15. +15 −3 src/Entities/Player.h
  16. +1 −2 src/Generating/BioGen.cpp
  17. +53 −33 src/HTTPServer/HTTPConnection.cpp
  18. +26 −13 src/HTTPServer/HTTPConnection.h
  19. +4 −1 src/HTTPServer/HTTPMessage.cpp
  20. +66 −68 src/HTTPServer/HTTPServer.cpp
  21. +20 −32 src/HTTPServer/HTTPServer.h
  22. +15 −18 src/HTTPServer/SslHTTPConnection.cpp
  23. +2 −2 src/HTTPServer/SslHTTPConnection.h
  24. +36 −0 src/IniFile.cpp
  25. +20 −4 src/IniFile.h
  26. +1 −7 src/OSSupport/CMakeLists.txt
  27. +1 −1 src/OSSupport/File.h
  28. +0 −238 src/OSSupport/ListenThread.cpp
  29. +0 −85 src/OSSupport/ListenThread.h
  30. +33 −11 src/OSSupport/NetworkSingleton.cpp
  31. +10 −1 src/OSSupport/NetworkSingleton.h
  32. +5 −5 src/OSSupport/ServerHandleImpl.cpp
  33. +0 −702 src/OSSupport/SocketThreads.cpp
  34. +0 −194 src/OSSupport/SocketThreads.h
  35. +8 −2 src/OSSupport/TCPLinkImpl.cpp
  36. +164 −12 src/PolarSSL++/BlockingSslClientSocket.cpp
  37. +33 −2 src/PolarSSL++/BlockingSslClientSocket.h
  38. +1 −1 src/PolarSSL++/SslContext.cpp
  39. +17 −8 src/Protocol/Protocol18x.cpp
  40. +112 −86 src/RCONServer.cpp
  41. +28 −41 src/RCONServer.h
  42. +35 −29 src/Root.cpp
  43. +78 −193 src/Server.cpp
  44. +41 −56 src/Server.h
  45. +44 −0 src/StringUtils.cpp
  46. +10 −1 src/StringUtils.h
  47. +43 −32 src/WebAdmin.cpp
  48. +12 −5 src/WebAdmin.h
  49. +17 −14 src/World.cpp
  50. +6 −3 src/World.h
  51. +9 −2 src/main.cpp
  52. +13 −1 tests/Network/EchoServer.cpp
  53. +14 −1 tests/Network/Google.cpp
  54. +11 −1 tests/Network/NameLookup.cpp
@@ -0,0 +1,99 @@
Libevent is available for use under the following license, commonly known
as the 3-clause (or "modified") BSD license:
==============================
Copyright (c) 2000-2007 Niels Provos <provos@citi.umich.edu>
Copyright (c) 2007-2012 Niels Provos and Nick Mathewson
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
==============================
Portions of Libevent are based on works by others, also made available by
them under the three-clause BSD license above. The copyright notices are
available in the corresponding source files; the license is as above. Here's
a list:
log.c:
Copyright (c) 2000 Dug Song <dugsong@monkey.org>
Copyright (c) 1993 The Regents of the University of California.
strlcpy.c:
Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
win32select.c:
Copyright (c) 2003 Michael A. Davis <mike@datanerds.net>
evport.c:
Copyright (c) 2007 Sun Microsystems
ht-internal.h:
Copyright (c) 2002 Christopher Clark
minheap-internal.h:
Copyright (c) 2006 Maxim Yegorushkin <maxim.yegorushkin@gmail.com>
==============================
The arc4module is available under the following, sometimes called the
"OpenBSD" license:
Copyright (c) 1996, David Mazieres <dm@uun.org>
Copyright (c) 2008, Damien Miller <djm@openbsd.org>
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
==============================
The Windows timer code is based on code from libutp, which is
distributed under this license, sometimes called the "MIT" license.
Copyright (c) 2010 BitTorrent, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
@@ -1164,7 +1164,7 @@ function HandleSched(a_Split, a_Player)
end
-- Schedule a broadcast of the final message and a note to the originating player
-- Note that we CANNOT us the a_Player in the callback - what if the player disconnected?
-- Note that we CANNOT use the a_Player in the callback - what if the player disconnected?
-- Therefore we store the player's EntityID
local PlayerID = a_Player:GetUniqueID()
World:ScheduleTask(220,
@@ -1607,10 +1607,13 @@ end
function HandleConsoleSchedule(a_Split)
LOG("Scheduling a task for 2 seconds in the future")
local prev = os.clock()
LOG("Scheduling a task for 2 seconds in the future (current os.clock is " .. prev .. ")")
cRoot:Get():GetDefaultWorld():ScheduleTask(40,
function ()
LOG("Scheduled function is called.")
local current = os.clock()
local diff = current - prev
LOG("Scheduled function is called. Current os.clock is " .. current .. ", difference is " .. diff .. ")")
end
)
return true, "Task scheduled"
@@ -1,3 +1,4 @@
@echo off
echo This script generates the certificate and private key for the https webadmin
echo Note that the generated certificate is self-signed, and therefore not trusted by browsers
echo Note that this script requires openssl to be installed and in PATH
View
@@ -22,6 +22,18 @@
#define ALIGN_8
#define ALIGN_16
#define FORMATSTRING(formatIndex, va_argsIndex)
// MSVC has its own custom version of zu format
#define SIZE_T_FMT "%Iu"
#define SIZE_T_FMT_PRECISION(x) "%" #x "Iu"
#define SIZE_T_FMT_HEX "%Ix"
#define NORETURN __declspec(noreturn)
// Use non-standard defines in <cmath>
#define _USE_MATH_DEFINES
#elif defined(__GNUC__)
// TODO: Can GCC explicitly mark classes as abstract (no instances can be created)?
@@ -38,6 +50,29 @@
// Some portability macros :)
#define stricmp strcasecmp
#define FORMATSTRING(formatIndex, va_argsIndex) __attribute__((format (printf, formatIndex, va_argsIndex)))
#if defined(_WIN32)
// We're compiling on MinGW, which uses an old MSVCRT library that has no support for size_t printfing.
// We need direct size formats:
#if defined(_WIN64)
#define SIZE_T_FMT "%I64u"
#define SIZE_T_FMT_PRECISION(x) "%" #x "I64u"
#define SIZE_T_FMT_HEX "%I64x"
#else
#define SIZE_T_FMT "%u"
#define SIZE_T_FMT_PRECISION(x) "%" #x "u"
#define SIZE_T_FMT_HEX "%x"
#endif
#else
// We're compiling on Linux, so we can use libc's size_t printf format:
#define SIZE_T_FMT "%zu"
#define SIZE_T_FMT_PRECISION(x) "%" #x "zu"
#define SIZE_T_FMT_HEX "%zx"
#endif
#define NORETURN __attribute((__noreturn__))
#else
#error "You are using an unsupported compiler, you might need to #define some stuff here for your compiler"
@@ -74,6 +109,8 @@ typedef unsigned long long UInt64;
typedef unsigned int UInt32;
typedef unsigned short UInt16;
typedef unsigned char Byte;
@@ -94,7 +131,7 @@ typedef unsigned short UInt16;
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#define _WIN32_WINNT 0x501 // We want to target WinXP and higher
#define _WIN32_WINNT 0x502 // We want to target WinXP SP2 and higher
#include <Windows.h>
#include <winsock2.h>
@@ -175,7 +212,8 @@ typedef unsigned short UInt16;
#include "StringUtils.h"
#include "OSSupport/CriticalSection.h"
#include "OSSupport/File.h"
#include "MCLogger.h"
#include "OSSupport/Event.h"
#include "Logger.h"
@@ -80,14 +80,14 @@ bool cRCONPacketizer::SendPacket(int a_PacketType, const AString & a_PacketPaylo
size_t Length = Packet.size();
if (!m_Socket.Send((const char *)&Length, 4))
{
fprintf(stderr, "Network error while sending packet: %d (%s). Aborting.",
fprintf(stderr, "Network error while sending packet: %d (%s). Aborting.\n",
cSocket::GetLastError(), cSocket::GetLastErrorString().c_str()
);
return false;
}
if (!m_Socket.Send(Packet.data(), Packet.size()))
{
fprintf(stderr, "Network error while sending packet: %d (%s). Aborting.",
fprintf(stderr, "Network error while sending packet: %d (%s). Aborting.\n",
cSocket::GetLastError(), cSocket::GetLastErrorString().c_str()
);
return false;
@@ -110,12 +110,12 @@ bool cRCONPacketizer::ReceiveResponse(void)
int NumReceived = m_Socket.Receive(buf, sizeof(buf), 0);
if (NumReceived == 0)
{
fprintf(stderr, "The remote end closed the connection. Aborting.");
fprintf(stderr, "The remote end closed the connection. Aborting.\n");
return false;
}
if (NumReceived < 0)
{
fprintf(stderr, "Network error while receiving response: %d, %d (%s). Aborting.",
fprintf(stderr, "Network error while receiving response: %d, %d (%s). Aborting.\n",
NumReceived, cSocket::GetLastError(), cSocket::GetLastErrorString().c_str()
);
return false;
@@ -156,13 +156,13 @@ bool cRCONPacketizer::ParsePacket(cByteBuffer & a_Buffer, int a_PacketLength)
{
if ((RequestID == -1) && (m_RequestID == 0))
{
fprintf(stderr, "Login failed. Aborting.");
fprintf(stderr, "Login failed. Aborting.\n");
IsValid = false;
// Continue, so that the payload is printed before the program aborts.
}
else
{
fprintf(stderr, "The server returned an invalid request ID, got %d, exp. %d. Aborting.", RequestID, m_RequestID);
fprintf(stderr, "The server returned an invalid request ID, got %d, exp. %d. Aborting.\n", RequestID, m_RequestID);
return false;
}
}
@@ -172,7 +172,7 @@ bool cRCONPacketizer::ParsePacket(cByteBuffer & a_Buffer, int a_PacketLength)
VERIFY(a_Buffer.ReadLEInt(PacketType));
if (PacketType != ptCommand)
{
fprintf(stderr, "The server returned an unknown packet type: %d. Aborting.", PacketType);
fprintf(stderr, "The server returned an unknown packet type: %d. Aborting.\n", PacketType);
IsValid = false;
// Continue, so that the payload is printed before the program aborts.
}
@@ -200,8 +200,8 @@ bool cRCONPacketizer::ParsePacket(cByteBuffer & a_Buffer, int a_PacketLength)
int RealMain(int argc, char * argv[])
{
new cMCLogger; // Create a new logger
cLogger::InitiateMultithreading();
// Parse the cmdline params for server IP, port, password and the commands to send:
AString ServerAddress, Password;
int ServerPort = -1;
@@ -301,6 +301,7 @@ int RealMain(int argc, char * argv[])
}
}
// Send each command:
for (AStringVector::const_iterator itr = Commands.begin(), end = Commands.end(); itr != end; ++itr)
{
if (g_IsVerbose)
@@ -1,7 +1,9 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual C++ Express 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RCONClient", "RCONClient.vcproj", "{1A48B032-07D0-4DDD-8362-66C0FC7F7849}"
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Express 2013 for Windows Desktop
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RCONClient", "RCONClient.vcxproj", "{1A48B032-07D0-4DDD-8362-66C0FC7F7849}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
View
@@ -346,20 +346,6 @@ class cLuaState
/** Number of arguments currently pushed (for the Push / Call chain) */
int m_NumCurrentFunctionArgs;
/** Variadic template terminator: Counting zero args returns zero. */
int CountArgs(void)
{
return 0;
}
/** Variadic template: Counting args means add one to the count of the rest. */
template <typename T, typename... Args>
int CountArgs(T, Args... args)
{
return 1 + CountArgs(args...);
}
/** Variadic template terminator: If there's nothing more to push / pop, just call the function.
Note that there are no return values either, because those are prefixed by a cRet value, so the arg list is never empty. */
bool PushCallPop(void)
@@ -380,7 +366,7 @@ class cLuaState
bool PushCallPop(cLuaState::cRet, Args &&... args)
{
// Calculate the number of return values (number of args left):
int NumReturns = CountArgs(args...);
int NumReturns = sizeof...(args);
// Call the function:
if (!CallFunction(NumReturns))
View
@@ -167,6 +167,7 @@ local function ProcessFile(a_FileName)
os.exit(1)
end
local all = f:read("*all")
f:close()
-- Check that the last line is empty - otherwise processing won't work properly:
local lastChar = string.byte(all, string.len(all))
View
@@ -1570,12 +1570,18 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT
if (
a_SendToClients && // ... we are told to do so AND ...
(
(OldBlockMeta != a_BlockMeta) || // ... the meta value is different OR ...
!( // ... the old and new blocktypes AREN'T liquids (because client doesn't need to distinguish betwixt them):
((OldBlockType == E_BLOCK_STATIONARY_WATER) && (a_BlockType == E_BLOCK_WATER)) || // Replacing stationary water with water
((OldBlockType == E_BLOCK_WATER) && (a_BlockType == E_BLOCK_STATIONARY_WATER)) || // Replacing water with stationary water
((OldBlockType == E_BLOCK_STATIONARY_LAVA) && (a_BlockType == E_BLOCK_LAVA)) || // Replacing stationary water with water
((OldBlockType == E_BLOCK_LAVA) && (a_BlockType == E_BLOCK_STATIONARY_LAVA)) // Replacing water with stationary water
!( // ... the old and new blocktypes AREN'T leaves (because the client doesn't need meta updates)
((OldBlockType == E_BLOCK_LEAVES) && (a_BlockType == E_BLOCK_LEAVES)) ||
((OldBlockType == E_BLOCK_NEW_LEAVES) && (a_BlockType == E_BLOCK_NEW_LEAVES))
) && // ... AND ...
(
(OldBlockMeta != a_BlockMeta) || // ... the meta value is different OR ...
!( // ... the old and new blocktypes AREN'T liquids (because client doesn't need to distinguish betwixt them):
((OldBlockType == E_BLOCK_STATIONARY_WATER) && (a_BlockType == E_BLOCK_WATER)) || // Replacing stationary water with water
((OldBlockType == E_BLOCK_WATER) && (a_BlockType == E_BLOCK_STATIONARY_WATER)) || // Replacing water with stationary water
((OldBlockType == E_BLOCK_STATIONARY_LAVA) && (a_BlockType == E_BLOCK_LAVA)) || // Replacing stationary water with water
((OldBlockType == E_BLOCK_LAVA) && (a_BlockType == E_BLOCK_STATIONARY_LAVA)) // Replacing water with stationary water
)
)
)
)
Oops, something went wrong.

0 comments on commit 2c7925f

Please sign in to comment.