Parcourir la source

Use fixed kNet build config and simplify kNet CMakeLists.txt.

Lasse Öörni il y a 12 ans
Parent
commit
3fe1352773

+ 2 - 142
ThirdParty/kNet/CMakeLists.txt

@@ -14,118 +14,9 @@
 
 # Modified by Lasse Oorni for Urho3D
 
-# Generate a build configuration file to ensure the build flags match for the user of the library.
-SET(BUILD_CONFIG_FILE include/kNetBuildConfig.h)
-file(WRITE ${BUILD_CONFIG_FILE} "// This file is programmatically generated using CMake.\n// This file shows the compilation settings that were used to build kNet.\n// These need to match for the client code using kNet.\n")
-file(APPEND ${BUILD_CONFIG_FILE} "#pragma once\n\n")
-
-macro(AddCompilationDefine define)
-   add_definitions(-D${define})
-   file(APPEND ${BUILD_CONFIG_FILE} "#ifndef ${define}\n#define ${define}\n#endif\n\n")
-endmacro()
-
-#set(USE_BOOST TRUE)
-#set(BOOST_ROOT "TODO_SpecifyYourBoostRootHereIfCMakeAutoSearchFails")
-
-# TinyXML is embedded to the repository, so you can safely keep this true.
-# However, it is not required for core kNet use, but only for the MessageCompiler tool, in which
-# case you can disable it here by setting USE_TINYXML to FALSE, and excluding MessageCompiler from the build.
-#set(USE_TINYXML TRUE)
-set(TINYXML_ROOT "src/tinyxml")
-
-# If you want to enable the use of visual debugging/profiling windows, uncomment the following line (must
-# have Qt installed and set up)
-#set(USE_QT TRUE)
-
-# To enable specific flags only in debug mode, use the following syntax.
-# set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DKNET_LOGGING_SUPPORT_ENABLED")
-
-# If set, the function GetThreadId is not used, which was introduced to Kernel32.dll only in Windows Vista.
-# Affects only Boost threads. When native Win32 threads are used, the id is stored on creation.
-AddCompilationDefine(KNET_ENABLE_WINXP_SUPPORT)
-
-if (NOT USE_BOOST) # USE_BOOST and KNET_THREAD_CHECKING_ENABLED are mutually exclusive, because boost::thread_id() does not work across .dll boundaries.
-   # If set, extra code is inserted in debug mode to assert that certain thread race conditions don't occur.
-   # (This can considerably slow down kNet performance)
-   #AddCompilationDefine(KNET_THREAD_CHECKING_ENABLED)
-endif()
-
-# Enable internal LOG messaging if this flag is enabled. Comment this out to squeeze the last bit of 
-# extra performance by avoiding all logging-related string operations.
-#AddCompilationDefine(KNET_LOGGING_SUPPORT_ENABLED)
-
-# Enable storing profiling data from different network level events.
-#AddCompilationDefine(KNET_NETWORK_PROFILING)
-
-# Urho3D does not need message priorities. Disable MaxHeap for improved performance.
-AddCompilationDefine(KNET_NO_MAXHEAP)
-
-if (USE_BOOST)
-   AddCompilationDefine(KNET_USE_BOOST)
-
-   if (WIN32)
-      set(Boost_FIND_REQUIRED TRUE)
-      set(Boost_FIND_QUIETLY TRUE)
-      set(Boost_DEBUG FALSE)
-      set(Boost_USE_MULTITHREADED TRUE)
-      set(Boost_DETAILED_FAILURE_MSG FALSE)
-      set(Boost_ADDITIONAL_VERSIONS "1.39.0" "1.40.0" "1.41.0" "1.42.0" "1.43.0" "1.44.0")
-      set(Boost_USE_STATIC_LIBS TRUE)
-   endif()
-endif()
-
 file(GLOB kNetSourceFiles ./src/*.cpp)
 file(GLOB kNetHeaderFiles ./include/*.h ./include/kNet/*.h ./include/kNet/*.inl)
 
-if (USE_TINYXML)
-   AddCompilationDefine(KNET_USE_TINYXML)
-   
-   file(GLOB TinyXmlSourceFiles ${TINYXML_ROOT}/*.cpp)
-   set(kNetSourceFiles ${kNetSourceFiles} ${TinyXmlSourceFiles})
-   include_directories(${TINYXML_ROOT})
-endif()
-
-if (USE_QT)
-   AddCompilationDefine(KNET_USE_QT)
-   
-   set(QT_USE_QTMAIN TRUE)
-   set(QT_USE_QTUITOOLS TRUE)
-   find_package(Qt4 REQUIRED)
-   
-   file(GLOB kNetMocHeaderFiles ./include/kNet/qt/*.h)
-   file(GLOB kNetQtSourceFiles ./src/qt/*.cpp)
-   file(GLOB kNetQtUiFiles ./ui/*.ui)
-   QT4_WRAP_CPP(kNetMocSrcFiles ${kNetMocHeaderFiles})
-   set(QT4_UI_OUTPUT_DIR ./include/kNet/qt/ui)
-   
-   MACRO(QT4_WRAP_UI_CUSTOM_OUTPUT outfiles)
-     QT4_EXTRACT_OPTIONS(ui_files ui_options ${ARGN})
-     FOREACH(it ${ui_files})
-       GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
-       GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
-       SET(outfile ${QT4_UI_OUTPUT_DIR}/ui_${outfile}.h)
-       GET_FILENAME_COMPONENT(outfile ${outfile} ABSOLUTE)
-       ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
-         COMMAND ${QT_UIC_EXECUTABLE}
-         ARGS ${ui_options} -o ${outfile} ${infile}
-         MAIN_DEPENDENCY ${infile})
-       SET(${outfiles} ${${outfiles}} ${outfile})
-     ENDFOREACH()    
-   ENDMACRO()   
-   
-  include_directories(${QT4_UI_OUTPUT_DIR})
-  QT4_WRAP_UI_CUSTOM_OUTPUT(kNetUiHeaderFiles ${kNetQtUiFiles})
-  set(kNetSourceFiles ${kNetSourceFiles} ${kNetMocSrcFiles} ${kNetQtSourceFiles})
-  set(kNetHeaderFiles ${kNetHeaderFiles} ${kNetMocHeaderFiles} ${kNetUiHeaderFiles})
-  include(${QT_USE_FILE})
-  set(kNetLinkLibraries ${kNetLinkLibraries} ${QT_LIBRARIES})
-endif()
-
-if (USE_BOOST)
-   file(GLOB kNetBoostSourceFiles ./src/boost/*.cpp)
-   set(kNetSourceFiles ${kNetSourceFiles} ${kNetBoostSourceFiles})
-endif()
-
 if (WIN32)
    file(GLOB kNetWin32SourceFiles ./src/win32/*.cpp)
    file(GLOB kNetWin32HeaderFiles ./include/kNet/win32/*.h)
@@ -142,7 +33,7 @@ if (WIN32)
    add_definitions(-DKNET_MEMORY_LEAK_CHECK)
    
    set(kNetLinkLibraries ${kNetLinkLibraries} ws2_32.lib)
-   
+
 elseif (UNIX)
    file(GLOB kNetUnixSourceFiles ./src/unix/*.cpp)
    file(GLOB kNetUnixHeaderFiles ./include/*.h ./include/kNet/*.h ./include/kNet/unix/*.h)
@@ -159,7 +50,7 @@ elseif (UNIX)
    add_definitions(-DUNIX)
 endif()
 
-# Urho3D: set DEBUG_CPP_NAME only on Windows, at least Xcode project file can not be opened if this is included
+# Urho3D: set DEBUG_CPP_NAME only on Windows, Xcode project file can not be opened if this is included
 if (WIN32)
     foreach(srcFile ${kNetSourceFiles})
         get_filename_component(baseName ${srcFile} NAME)
@@ -172,35 +63,4 @@ add_library(kNet STATIC ${kNetSourceFiles} ${kNetHeaderFiles})
 # Add the main kNet include directory root folder to all projects.
 include_directories(./include)
 
-if (USE_BOOST)
-   if (WIN32)
-      find_package(Boost 1.38.0 COMPONENTS thread)
-   else()
-      find_package(Boost)
-   endif()
-   if (Boost_FOUND)
-      include_directories(${Boost_INCLUDE_DIRS})
-      link_directories(${Boost_LIBRARY_DIRS})
-   else()
-      message(FATAL_ERROR "Boost not found!")
-   endif()
-   
-   set(kNetLinkLibraries ${kNetLinkLibraries} ${Boost_LIBRARIES})   
-endif()
-
 target_link_libraries(kNet ${kNetLinkLibraries})
-
-#add_subdirectory(samples/ConnectFlood)
-#add_subdirectory(samples/FileTransfer)
-#add_subdirectory(samples/FirewallTest)
-#add_subdirectory(samples/HelloClient)
-#add_subdirectory(samples/HelloServer)
-#add_subdirectory(samples/LatencyTest)
-#add_subdirectory(samples/MessageCompiler)
-#add_subdirectory(samples/SilenceTest)
-#add_subdirectory(samples/SimpleChat)
-#add_subdirectory(samples/SpeedTest)
-#add_subdirectory(samples/TrashTalk)
-
-#add_subdirectory(tests)
-

+ 0 - 52
ThirdParty/kNet/include/kNet/qt/GraphDialog.h

@@ -1,52 +0,0 @@
-/* Copyright The kNet Project.
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License. */
-#pragma once
-
-/** @file GraphDialog.h
-	@brief Shows a graph display of a network event counter. */
-
-#include "kNetBuildConfig.h"
-
-#ifdef KNET_USE_QT
-
-#include <QObject>
-#include <QWidget>
-#include <QTimer>
-
-#include "kNet/MessageConnection.h"
-#include "kNet/SharedPtr.h"
-#include "kNet/StatsEventHierarchy.h"
-
-class Ui_GraphDialog;
-
-namespace kNet
-{
-
-class GraphDialog : public QWidget
-{
-	Q_OBJECT;
-
-	Ui_GraphDialog *dialog;
-	std::string hierarchyNodeName;
-
-public:
-	GraphDialog(QWidget *parent, const char *hierarchyNodeName);
-	~GraphDialog();
-
-	void Update(StatsEventHierarchyNode &node, int timeMSecs);
-};
-
-} // ~kNet
-
-#endif

+ 0 - 54
ThirdParty/kNet/include/kNet/qt/MessageConnectionDialog.h

@@ -1,54 +0,0 @@
-/* Copyright The kNet Project.
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License. */
-#pragma once
-
-/** @file MessageConnectionDialog.h
-	@brief Shows a debugging console dialog of a kNet MessageConnection object. */
-
-#include "kNetBuildConfig.h"
-
-#ifdef KNET_USE_QT
-
-#include <QObject>
-#include <QWidget>
-#include <QTimer>
-
-#include "kNet/MessageConnection.h"
-#include "kNet/SharedPtr.h"
-
-class Ui_MessageConnectionDialog;
-
-namespace kNet
-{
-
-class MessageConnectionDialog : public QWidget
-{
-	Q_OBJECT;
-
-	Ptr(MessageConnection) connection;
-	Ui_MessageConnectionDialog *dialog;
-
-public:
-	MessageConnectionDialog(QWidget *parent, Ptr(MessageConnection) connection);
-	~MessageConnectionDialog();
-
-public slots:
-	void Update();
-
-	void OpenSendSimulationWindow();
-};
-
-} // ~kNet
-
-#endif

+ 0 - 63
ThirdParty/kNet/include/kNet/qt/NetworkDialog.h

@@ -1,63 +0,0 @@
-/* Copyright The kNet Project.
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License. */
-#pragma once
-
-/** @file NetworkDialog.h
-	@brief Shows a debugging console dialog of the main kNet Network object. */
-
-#include "kNetBuildConfig.h"
-
-#ifdef KNET_USE_QT
-
-#include <QObject>
-#include <QPointer>
-#include <QWidget>
-
-class QTimer;
-class QTreeWidgetItem;
-class Ui_NetworkDialog;
-
-#include "kNet/Network.h"
-
-namespace kNet
-{
-
-class GraphDialog;
-
-class NetworkDialog : public QWidget
-{
-	Q_OBJECT;
-
-	Network *network;
-	Ui_NetworkDialog *dialog;
-
-public:
-	NetworkDialog(QWidget *parent, Network *network);
-	~NetworkDialog();
-
-public slots:
-	void Update();
-	void ItemDoubleClicked(QTreeWidgetItem *item);
-	void EventItemDoubleClicked(QTreeWidgetItem *item);
-
-private:
-	void PopulateStatsTree();
-
-	typedef std::map<std::string, QPointer<GraphDialog> > GraphMap;
-	GraphMap graphs;
-};
-
-} // ~kNet
-
-#endif

+ 0 - 52
ThirdParty/kNet/include/kNet/qt/NetworkSimulationDialog.h

@@ -1,52 +0,0 @@
-/* Copyright The kNet Project.
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License. */
-#pragma once
-
-/** @file NetworkSimulationDialog.h
-	@brief Shows a UI for specifying parameters for network simulations. */
-
-#include "kNetBuildConfig.h"
-
-#ifdef KNET_USE_QT
-
-#include <QObject>
-#include <QWidget>
-#include <QTimer>
-
-#include "kNet/MessageConnection.h"
-#include "kNet/SharedPtr.h"
-
-class Ui_NetworkSimulationDialog;
-
-namespace kNet
-{
-
-class NetworkSimulationDialog : public QWidget
-{
-	Q_OBJECT;
-
-	Ptr(MessageConnection) connection;
-	Ui_NetworkSimulationDialog *dialog;
-
-public:
-	NetworkSimulationDialog(QWidget *parent, Ptr(MessageConnection) connection);
-	~NetworkSimulationDialog();
-
-public slots:
-	void ParameterChanged();
-};
-
-} // ~kNet
-
-#endif

+ 0 - 1
ThirdParty/kNet/include/kNet/qt/ui/readme.txt

@@ -1 +0,0 @@
-The contents of this directory are automatically generated from Qt .ui files. Modifying these files is useless, since they will get regenerated on a new compilation. This file is present here as a dummy to enforce this directory is added to source control.

+ 13 - 0
ThirdParty/kNet/include/kNetBuildConfig.h

@@ -0,0 +1,13 @@
+// This file is programmatically generated using CMake.
+// This file shows the compilation settings that were used to build kNet.
+// These need to match for the client code using kNet.
+#pragma once
+
+#ifndef KNET_ENABLE_WINXP_SUPPORT
+#define KNET_ENABLE_WINXP_SUPPORT
+#endif
+
+#ifndef KNET_NO_MAXHEAP
+#define KNET_NO_MAXHEAP
+#endif
+

+ 0 - 98
ThirdParty/kNet/src/qt/GraphDialog.cpp

@@ -1,98 +0,0 @@
-/* Copyright The kNet Project.
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License. */
-
-/** @file GraphDialog.cpp
-	@brief */
-
-#include <QUiLoader>
-#include <QFile>
-#include <QVBoxLayout>
-#include <QLabel>
-#include <QTreeWidget>
-#include <QPainter>
-#include <sstream>
-#include <algorithm>
-
-#ifdef KNET_USE_BOOST
-#include <boost/thread/thread.hpp>
-#endif
-
-#include "kNet/DebugMemoryLeakCheck.h"
-#include "kNet/Network.h"
-#include "kNet/qt/GraphDialog.h"
-#include "kNet/qt/ui/ui_Graph.h"
-
-namespace kNet
-{
-
-/// Specifies in msecs how often we update MessageConnectionDialog.
-const int dialogUpdateInterval = 200;
-
-GraphDialog::GraphDialog(QWidget *parent, const char *hierarchyNodeName_)
-:QWidget(parent), hierarchyNodeName(hierarchyNodeName_)
-{
-	dialog = new Ui_GraphDialog;
-	dialog->setupUi(this);
-
-	setWindowTitle(hierarchyNodeName.c_str());
-}
-
-GraphDialog::~GraphDialog()
-{
-	delete dialog;
-}
-
-QPointF MapPoint(tick_t x, float y, tick_t minX, tick_t maxX, float minY, float maxY, const QPointF &topLeft, const QPointF &bottomRight)
-{
-	float mappedX = topLeft.x() + (bottomRight.x() - topLeft.x()) * (float)(x - minX) / (maxX - minX);
-	float mappedY = bottomRight.y() - (bottomRight.y() - topLeft.y()) * (float)(y - minY) / (maxY - minY);
-	return QPointF(mappedX, mappedY);
-}
-
-void GraphDialog::Update(StatsEventHierarchyNode &node, int timeMSecs)
-{
-	QPixmap *image = new QPixmap(dialog->graphLabel->width(), dialog->graphLabel->height());
-	{
-		QPainter painter(image);
-		painter.fillRect(0, 0, image->width(), image->height(), QColor(255, 255, 255, 255));
-		painter.setRenderHint(QPainter::Antialiasing, true);
-
-		const QPointF topLeft(5, 5);
-		const QPointF bottomRight(image->width() - 5, image->height() - 5);
-		const tick_t rightX = Clock::Tick();
-		const tick_t leftX = rightX - timeMSecs * Clock::TicksPerSec() / 1000;
-		const float minY = 0.f;
-		float maxY = 0.f;
-		for(int i = 0; i < node.events.Size(); ++i)
-		{
-			StatsEvent *e = node.events.ItemAt(i);
-			if (Clock::IsNewer(e->time, leftX) && Clock::IsNewer(rightX, e->time))
-				maxY = std::max(maxY, e->value);
-		}
-
-		painter.setPen(QPen(QColor(0,0,0)));
-		for(int i = 0; i+1 < node.events.Size(); ++i)
-		{
-			StatsEvent *e = node.events.ItemAt(i);
-			StatsEvent *e2 = node.events.ItemAt(i+1);
-			QPointF pt1 = MapPoint(e->time, e->value, leftX, rightX, minY, maxY, topLeft, bottomRight);
-			QPointF pt2 = MapPoint(e2->time, e2->value, leftX, rightX, minY, maxY, topLeft, bottomRight);
-			painter.drawLine(pt1, pt2);
-		}
-	}
-
-	dialog->graphLabel->setPixmap(*image);
-}
-
-} // ~kNet

+ 0 - 141
ThirdParty/kNet/src/qt/MessageConnectionDialog.cpp

@@ -1,141 +0,0 @@
-/* Copyright The kNet Project.
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License. */
-
-/** @file MessageConnectionDialog.cpp
-	@brief */
-
-#include <QUiLoader>
-#include <QFile>
-#include <QVBoxLayout>
-#include <QLabel>
-#include <QTreeWidget>
-#include <sstream>
-
-#ifdef KNET_USE_BOOST
-#include <boost/thread/thread.hpp>
-#endif
-
-#include "kNet/DebugMemoryLeakCheck.h"
-#include "kNet/Network.h"
-#include "kNet/UDPMessageConnection.h"
-
-#include "kNet/qt/MessageConnectionDialog.h"
-#include "kNet/qt/NetworkSimulationDialog.h"
-#include "kNet/qt/ui/ui_MessageConnectionDialog.h"
-
-namespace kNet
-{
-
-/// Specifies in msecs how often we update MessageConnectionDialog.
-const int dialogUpdateInterval = 200;
-
-MessageConnectionDialog::MessageConnectionDialog(QWidget *parent, Ptr(MessageConnection) connection_)
-:connection(connection_), QWidget(parent)
-{
-	dialog = new Ui_MessageConnectionDialog;
-	dialog->setupUi(this);
-
-	if (connection_ && connection_->GetSocket() && connection_->GetSocket()->TransportLayer() == SocketOverTCP)
-	{
-		dialog->labelDatagramsIn->setText("# recv() calls:");
-		dialog->labelDatagramsOut->setText("# send() calls:");
-	}
-
-	connect(dialog->pushButtonSendSimulation, SIGNAL(pressed()), this, SLOT(OpenSendSimulationWindow()));
-	Update();
-}
-
-MessageConnectionDialog::~MessageConnectionDialog()
-{
-	delete dialog;
-}
-
-void MessageConnectionDialog::Update()
-{
-	if (!connection)
-		return;
-
-	Socket *socket = connection->GetSocket();
-
-	std::stringstream ss;
-	if (!socket)
-		ss << "(null connection)";
-	else
-		ss << SocketTransportLayerToString(socket->TransportLayer()) << " connection to " << connection->RemoteEndPoint().ToString()
-		   << " (from " << connection->LocalEndPoint().ToString() << ")";
-	dialog->connectionLine->setText(ss.str().c_str());
-	setWindowTitle(ss.str().c_str());
-
-	dialog->statusLine->setText(ConnectionStateToString(connection->GetConnectionState()).c_str());
-	dialog->inboundMessagesPending->setText(QString::number(connection->NumInboundMessagesPending()));
-	dialog->outboundMessagesPending->setText(QString::number(connection->NumOutboundMessagesPending()) + " (unaccepted: " + QString::number(connection->OutboundAcceptQueueSize()) + ")");
-	dialog->messageConnectionStatus->setText(connection->Connected() ? QString("Connected") : QString("") + 
-		(connection->IsReadOpen() ? " Read-open" : "") + (connection->IsWriteOpen() ? "Write-open" : ""));
-	if (!socket)
-		dialog->socketStatus->setText("(null)");
-	else
-		dialog->socketStatus->setText(socket->Connected() ? QString("Connected") : QString("") + 
-			(socket->IsReadOpen() ? " Read-open" : "") + (socket->IsWriteOpen() ? "Write-open" : ""));
-	dialog->roundTripTime->setText(QString::number(connection->RoundTripTime()) + "ms");
-	dialog->lastHeardTime->setText(QString::number(connection->LastHeardTime()) + "ms");
-	dialog->datagramsIn->setText(QString::number(connection->PacketsInPerSec()) + "/sec");
-	dialog->datagramsOut->setText(QString::number(connection->PacketsOutPerSec()) + "/sec");
-	dialog->messagesIn->setText(QString::number(connection->MsgsInPerSec()) + "/sec");
-	dialog->messagesOut->setText(QString::number(connection->MsgsOutPerSec()) + "/sec");
-	dialog->bytesIn->setText(QString(FormatBytes(connection->BytesInPerSec()).c_str()) + "/sec");
-	dialog->bytesOut->setText(QString(FormatBytes(connection->BytesOutPerSec()).c_str()) + "/sec");
-	dialog->totalBytesReceived->setText(QString(FormatBytes(connection->BytesInTotal()).c_str()));
-	dialog->totalBytesSent->setText(QString(FormatBytes(connection->BytesOutTotal()).c_str()));
-
-	UDPMessageConnection *udpConnection = dynamic_cast<UDPMessageConnection *>(connection.ptr());
-	QLabel *labels[] =
-	{
-		dialog->retransmissionTimeoutHeader, dialog->retransmissionTimeout,
-		dialog->datagramSendRateHeader, dialog->datagramSendRate,
-		dialog->smoothedRTTHeader, dialog->smoothedRTT,
-		dialog->rttVariationHeader, dialog->rttVariation,
-		dialog->outUnackedDatagramsHeader, dialog->outUnackedDatagrams,
-		dialog->recvUnackedDatagramsHeader, dialog->recvUnackedDatagrams,
-		dialog->packetLossCountHeader, dialog->packetLossCount,
-		dialog->packetLossRateHeader, dialog->packetLossRate
-	};
-	for(int i = 0; i < sizeof(labels)/sizeof(labels[0]); ++i)
-		labels[i]->setVisible(udpConnection != 0);
-
-	if (udpConnection)
-	{
-		dialog->retransmissionTimeout->setText(QString::number(udpConnection->RetransmissionTimeout()) + "ms");
-		dialog->datagramSendRate->setText(QString::number(udpConnection->DatagramSendRate()) + "/sec");
-		dialog->smoothedRTT->setText(QString::number(udpConnection->SmoothedRtt()) + "ms");
-		dialog->rttVariation->setText(QString::number(udpConnection->RttVariation()));
-		dialog->outUnackedDatagrams->setText(QString::number(udpConnection->NumOutboundUnackedDatagrams()));
-		dialog->recvUnackedDatagrams->setText(QString::number(udpConnection->NumReceivedUnackedDatagrams()));
-		dialog->packetLossCount->setText(QString::number(udpConnection->PacketLossCount()));
-		dialog->packetLossRate->setText(QString::number(udpConnection->PacketLossRate()));
-	}
-	QTimer::singleShot(dialogUpdateInterval, this, SLOT(Update()));
-}
-
-void MessageConnectionDialog::OpenSendSimulationWindow()
-{
-	if (connection)
-	{
-		NetworkSimulationDialog *dialog = new NetworkSimulationDialog(0, connection);
-		dialog->setWindowTitle(QString("Outbound connection to ") + connection->RemoteEndPoint().ToString().c_str());
-		dialog->show();
-		dialog->setAttribute(Qt::WA_DeleteOnClose);
-	}
-}
-
-} // ~kNet

+ 0 - 343
ThirdParty/kNet/src/qt/NetworkDialog.cpp

@@ -1,343 +0,0 @@
-/* Copyright The kNet Project.
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License. */
-
-/** @file NetworkDialog.cpp
-	@brief */
-
-#include <QFile>
-#include <QVBoxLayout>
-#include <QLabel>
-#include <QTreeWidget>
-
-#ifdef KNET_USE_BOOST
-#include <boost/thread/thread.hpp>
-#endif
-
-#include "kNet/DebugMemoryLeakCheck.h"
-#include "kNet/StatsEventHierarchy.h"
-#include "kNet/qt/NetworkDialog.h"
-#include "kNet/qt/MessageConnectionDialog.h"
-#include "kNet/qt/GraphDialog.h"
-#include "kNet/qt/ui/ui_NetworkDialog.h"
-
-namespace kNet
-{
-
-/// Specifies in msecs how often we update NetworkDialog.
-const int dialogUpdateInterval = 100;
-
-NetworkDialog::NetworkDialog(QWidget *parent, Network *network_)
-:network(network_), QWidget(parent)
-{
-	dialog = new Ui_NetworkDialog;
-	dialog->setupUi(this);
-
-	connect(dialog->connectionsTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(ItemDoubleClicked(QTreeWidgetItem *)));
-	connect(dialog->treeStats, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(EventItemDoubleClicked(QTreeWidgetItem *)));
-
-	Update();
-}
-
-NetworkDialog::~NetworkDialog()
-{
-	delete dialog;
-}
-
-class MessageConnectionTreeItem : public QTreeWidgetItem
-{
-public:
-	MessageConnectionTreeItem(QTreeWidgetItem *parent, Ptr(MessageConnection) connection_)
-	:QTreeWidgetItem(parent), connection(connection_)
-	{
-		UpdateText();
-	}
-
-	void UpdateText()
-	{
-		if (connection)
-			setText(0, connection->ToString().c_str());
-	}
-
-	Ptr(MessageConnection) connection;
-};
-
-class StatsEventTreeItem : public QTreeWidgetItem
-{
-public:
-	StatsEventTreeItem(QTreeWidgetItem *parent, const char *eventName_)
-	:QTreeWidgetItem(parent), eventName(eventName_)
-	{
-	}
-
-	std::string eventName;
-};
-
-QTreeWidgetItem *NewTreeItemFromString(QTreeWidget *parent, const char *str)
-{
-	QTreeWidgetItem *item = new QTreeWidgetItem(parent);
-	item->setText(0, str);
-	return item;
-}
-
-void GetItems(QTreeWidgetItem *widget, QList<QTreeWidgetItem *> &items)
-{
-	for(int i = 0; i < widget->childCount(); ++i)
-	{
-		items.append(widget->child(i));
-		GetItems(widget->child(i), items);
-	}
-}
-
-QTreeWidgetItem *FindItem(QList<QTreeWidgetItem *> &items, void *data)
-{
-	foreach(QTreeWidgetItem *item, items)
-		if (item->data(0, Qt::UserRole).value<void*>() == data)
-			return item;
-	return 0;
-}
-
-void NetworkDialog::Update()
-{
-	if (!network)
-		return;
-
-	QLabel *machineIp = findChild<QLabel*>("machineIP");
-	if (!machineIp)
-		return;
-	QLabel *numRunningThreads = findChild<QLabel*>("numRunningThreads");
-	if (!numRunningThreads)
-		return;
-	QTreeWidget *connectionsTree = findChild<QTreeWidget*>("connectionsTree");
-	if (!connectionsTree)
-		return;
-
-	machineIp->setText(network->LocalAddress());
-	numRunningThreads->setText(QString::number(network->NumWorkerThreads()));
-
-	QList<QTreeWidgetItem *> items;
-	GetItems(connectionsTree->invisibleRootItem(), items);
-//	connectionsTree->clear();
-
-	Ptr(NetworkServer) server = network->GetServer();
-	if (server)
-	{
-		setWindowTitle("kNet Server");
-		QTreeWidgetItem *serverItem = FindItem(items, (void*)server.ptr());
-		if (!serverItem)
-		{
-			serverItem = NewTreeItemFromString(connectionsTree, server->ToString().c_str());
-			connectionsTree->addTopLevelItem(serverItem);
-		}
-		else
-			items.removeOne(serverItem);
-		serverItem->setData(0, Qt::UserRole, QVariant::fromValue<void*>(server.ptr()));
-
-		NetworkServer::ConnectionMap connections = server->GetConnections();
-		for(NetworkServer::ConnectionMap::iterator iter = connections.begin(); iter != connections.end(); ++iter)
-		{
-			QTreeWidgetItem *connectionItem = FindItem(items, (void*)iter->second.ptr());
-			if (!connectionItem)
-			{
-				connectionItem = new MessageConnectionTreeItem(serverItem, iter->second);
-				serverItem->addChild(connectionItem);
-				connectionItem->setData(0, Qt::UserRole, QVariant::fromValue<void*>((void*)iter->second.ptr()));
-			}
-			else
-				items.removeOne(connectionItem);
-			serverItem->setExpanded(true);
-		}
-	}
-	else
-		setWindowTitle("kNet Client");
-
-	std::set<MessageConnection*> connections = network->Connections();
-	for(std::set<MessageConnection*>::iterator iter = connections.begin(); iter != connections.end(); ++iter)
-		if ((*iter)->GetSocket() && (*iter)->GetSocket()->Type() == ClientSocket)
-		{
-			QTreeWidgetItem *existingItem = FindItem(items, (void*)*iter);
-			if (existingItem && dynamic_cast<MessageConnectionTreeItem*>(existingItem))
-			{
-				dynamic_cast<MessageConnectionTreeItem*>(existingItem)->UpdateText();
-				items.removeOne(existingItem);
-			}
-			else
-			{
-				MessageConnectionTreeItem* item = new MessageConnectionTreeItem(connectionsTree->invisibleRootItem(), *iter);
-				item->setData(0, Qt::UserRole, QVariant::fromValue<void*>((void*)*iter));
-			}
-		}
-
-	PopulateStatsTree();
-
-	// Clear all old items from the connection list.
-	while(items.size() > 0)
-	{
-		delete items.back();
-		items.pop_back();
-	}
-
-	QTimer::singleShot(dialogUpdateInterval, this, SLOT(Update()));
-}
-
-QTreeWidgetItem *FindChild(QTreeWidgetItem *parent, int column, QString text)
-{
-	for(int i = 0; i < parent->childCount(); ++i)
-	{
-		QTreeWidgetItem *child = parent->child(i);
-		if (child->text(column) == text)
-			return child;
-	}
-	return 0;
-}
-
-void PopulateStatsTreeNode(QTreeWidgetItem *parent, StatsEventHierarchyNode &statsNode, int timeMSecs, std::string parentNodeName)
-{
-	for(StatsEventHierarchyNode::NodeMap::iterator iter = statsNode.children.begin(); iter != statsNode.children.end();
-		++iter)
-	{
-		QTreeWidgetItem *child = FindChild(parent, 0, iter->first.c_str());
-		std::string childNodeName = parentNodeName.empty() ? iter->first : (parentNodeName + "." + iter->first);
-		if (!child)
-		{
-			child = new StatsEventTreeItem(parent, childNodeName.c_str());
-			child->setText(0, iter->first.c_str());
-		}
-		StatsEventHierarchyNode &node = iter->second;
-		bool hasChildren = node.children.size() > 0;
-
-		int totalCountThisLevel = hasChildren ? node.AccumulateTotalCountThisLevel() : 0;
-		int totalCountHierarchy = node.AccumulateTotalCountHierarchy();
-		float totalValueThisLevel = hasChildren ? node.AccumulateTotalValueThisLevel() : 0.f;
-		float totalValueHierarchy = node.AccumulateTotalValueHierarchy();
-		float timeSpan = timeMSecs / 1000.f;
-
-		QString totalCountHierarchyStr = (totalCountHierarchy == 0) ? "-" : QString::number(totalCountHierarchy);
-		QString totalValueHierarchyStr = (totalCountHierarchy == 0) ? "-" : 
-			(node.valueType == "bytes" ? FormatBytes(totalValueHierarchy).c_str() : QString::number(totalValueHierarchy));
-
-		QString totalCountHierarchyPerTimeStr = (totalCountHierarchy == 0) ? "-" : 
-			(QString::number(totalCountHierarchy / timeSpan, 'f', 2) + "/sec");
-		QString totalValueHierarchyPerTimeStr = (totalCountHierarchy == 0) ? "-" : 
-			(node.valueType == "bytes" ? (FormatBytes((double)totalValueHierarchy / timeSpan).c_str() + QString("/sec")) : (QString::number(totalValueHierarchy / timeSpan, 'f', 2) + "/sec"));
-
-		QString totalValueHierarchyPerCountStr = (totalCountHierarchy == 0) ? "-" : 
-			(node.valueType == "bytes" ? FormatBytes((double)totalValueHierarchy / totalCountHierarchy).c_str() : QString::number((float)totalValueHierarchy / totalCountHierarchy, 'f', 2));
-
-		if (hasChildren && totalCountThisLevel > 0)
-		{
-			QString totalCountThisLevelStr = (totalCountThisLevel == 0) ? "-" : QString::number(totalCountThisLevel);
-			QString totalValueThisLevelStr = (totalCountThisLevel == 0) ? "-" : 
-				(node.valueType == "bytes" ? FormatBytes(totalValueThisLevel).c_str() : QString::number(totalValueThisLevel));
-
-			QString totalCountThisLevelPerTimeStr = (totalCountThisLevel == 0) ? "-" : 
-				(QString::number(totalCountThisLevel / timeSpan, 'f', 2) + "/sec");
-			QString totalValueThisLevelPerTimeStr = (totalCountThisLevel == 0) ? "-" : 
-				(node.valueType == "bytes" ? (FormatBytes((double)totalValueThisLevel / timeSpan).c_str() + QString("/sec")) : (QString::number(totalValueThisLevel / timeSpan, 'f', 2) + "/sec"));
-
-			QString totalValueThisLevelPerCountStr = (totalCountThisLevel == 0) ? "-" : 
-				(node.valueType == "bytes" ? FormatBytes((double)totalValueThisLevel / totalCountThisLevel).c_str() : QString::number((float)totalValueThisLevel / totalCountThisLevel, 'f', 2));
-
-			child->setText(1, QString("%1 (%2)").arg(totalCountHierarchyStr).arg(totalCountThisLevelStr));
-			child->setText(2, QString("%1 (%2)").arg(totalValueHierarchyStr).arg(totalValueThisLevelStr));
-			child->setText(3, QString("%1 (%2)").arg(totalCountHierarchyPerTimeStr).arg(totalCountThisLevelPerTimeStr));
-			child->setText(4, QString("%1 (%2)").arg(totalValueHierarchyPerTimeStr).arg(totalValueThisLevelPerTimeStr));
-			child->setText(5, QString("%1 (%2)").arg(totalValueHierarchyPerCountStr).arg(totalValueThisLevelPerCountStr));
-		}
-		else
-		{
-			child->setText(1, QString("%1").arg(totalCountHierarchyStr));
-			child->setText(2, QString("%1").arg(totalValueHierarchyStr));
-			child->setText(3, QString("%1").arg(totalCountHierarchyPerTimeStr));
-			child->setText(4, QString("%1").arg(totalValueHierarchyPerTimeStr));
-			child->setText(5, QString("%1").arg(totalValueHierarchyPerCountStr));
-		}
-		if (totalCountThisLevel == 0 && hasChildren)
-			child->setText(6, "-");
-		else if (node.valueType == "bytes")
-			child->setText(6, FormatBytes(node.LatestValue()).c_str());
-		else
-			child->setText(6, QString("%1").arg(node.LatestValue()));
-
-		PopulateStatsTreeNode(child, node, timeMSecs, childNodeName);
-	}
-}
-
-void NetworkDialog::PopulateStatsTree()
-{
-	// Make a deep copy of all profiling data so that we don't stall the network worker threads with a lock.
-	StatsEventHierarchyNode statistics;
-
-	int timeMSecs = 60 * 1000;
-	if (dialog->comboTimePeriod->currentIndex() == 0) timeMSecs = 5 * 1000;
-	else if (dialog->comboTimePeriod->currentIndex() == 1) timeMSecs = 15 * 1000;
-	else if (dialog->comboTimePeriod->currentIndex() == 2) timeMSecs = 30 * 1000;
-
-	{
-		Lock<StatsEventHierarchyNode> stats = network->Statistics();
-		stats->PruneOldEventsHierarchy(timeMSecs);
-		statistics = *stats;
-	}
-
-	PopulateStatsTreeNode(dialog->treeStats->invisibleRootItem(), statistics, timeMSecs, "");
-	for(int i = 0; i < 7; ++i)
-		dialog->treeStats->resizeColumnToContents(i);
-
-	for(GraphMap::iterator iter = graphs.begin(); iter != graphs.end();)
-	{
-		StatsEventHierarchyNode *node = statistics.FindChild(iter->first.c_str());
-		if (node && iter->second)
-		{
-			iter->second->Update(*node, timeMSecs);
-			++iter;
-		}
-		else
-		{
-         GraphMap::iterator next = iter;
-			graphs.erase(iter);
-         iter = next;
-		}
-	}
-}
-
-void NetworkDialog::ItemDoubleClicked(QTreeWidgetItem *item)
-{
-	MessageConnectionTreeItem *msgItem = dynamic_cast<MessageConnectionTreeItem*>(item);
-	if (!msgItem)
-		return;
-
-	MessageConnectionDialog *dialog = new MessageConnectionDialog(0, msgItem->connection);
-	dialog->show();
-	dialog->setAttribute(Qt::WA_DeleteOnClose);
-}
-
-void NetworkDialog::EventItemDoubleClicked(QTreeWidgetItem *item)
-{
-	StatsEventTreeItem *msgItem = dynamic_cast<StatsEventTreeItem*>(item);
-	if (!msgItem)
-		return;
-
-	GraphMap::iterator iter = graphs.find(msgItem->eventName);
-	if (iter != graphs.end() && iter->second)
-	{
-		iter->second->activateWindow();
-		return;
-	}
-
-	QPointer<GraphDialog> graphDialog = new GraphDialog(0, msgItem->eventName.c_str());
-	graphDialog->show();
-	graphDialog->setAttribute(Qt::WA_DeleteOnClose);
-	graphs[msgItem->eventName] = graphDialog;
-}
-
-} // ~kNet

+ 0 - 90
ThirdParty/kNet/src/qt/NetworkSimulationDialog.cpp

@@ -1,90 +0,0 @@
-/* Copyright The kNet Project.
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License. */
-
-/** @file MessageConnectionDialog.cpp
-	@brief */
-
-#include "kNet/qt/NetworkSimulationDialog.h"
-#include "kNet/qt/ui/ui_NetworkSimulationDialog.h"
-
-namespace kNet
-{
-
-NetworkSimulationDialog::NetworkSimulationDialog(QWidget *parent, Ptr(MessageConnection) connection_)
-:connection(connection_), QWidget(parent)
-{
-	dialog = new Ui_NetworkSimulationDialog;
-	dialog->setupUi(this);
-
-	NetworkSimulator &s = connection->NetworkSendSimulator();
-
-	dialog->labelConnectionName->setText(connection->ToString().c_str());
-	dialog->checkBoxPacketDelayEnabled->setChecked(s.enabled && (s.constantPacketSendDelay > 0 || s.uniformRandomPacketSendDelay > 0));
-	dialog->checkBoxPacketLossEnabled->setChecked(s.enabled && s.packetLossRate > 0);
-	dialog->spinBoxConstantDelay->setValue(s.constantPacketSendDelay);
-	dialog->spinBoxRandomDelay->setValue(s.uniformRandomPacketSendDelay);
-	dialog->spinBoxUniformLoss->setValue(s.packetLossRate * 100.f);
-
-	connect(dialog->checkBoxPacketDelayEnabled, SIGNAL(toggled(bool)), this, SLOT(ParameterChanged()));
-	connect(dialog->checkBoxPacketLossEnabled, SIGNAL(toggled(bool)), this, SLOT(ParameterChanged()));
-	connect(dialog->checkBoxPacketDuplicationEnabled, SIGNAL(toggled(bool)), this, SLOT(ParameterChanged()));
-	connect(dialog->checkBoxPacketCorruptionEnabled, SIGNAL(toggled(bool)), this, SLOT(ParameterChanged()));
-	connect(dialog->checkBoxCorruptPayload, SIGNAL(toggled(bool)), this, SLOT(ParameterChanged()));
-	connect(dialog->checkBoxBurstsEnabled, SIGNAL(toggled(bool)), this, SLOT(ParameterChanged()));
-	connect(dialog->spinBoxConstantDelay, SIGNAL(valueChanged(int)), this, SLOT(ParameterChanged()));
-	connect(dialog->spinBoxRandomDelay, SIGNAL(valueChanged(int)), this, SLOT(ParameterChanged()));
-	connect(dialog->spinBoxNormalMean, SIGNAL(valueChanged(int)), this, SLOT(ParameterChanged()));
-	connect(dialog->doubleSpinBoxNormalVar, SIGNAL(valueChanged(double)), this, SLOT(ParameterChanged()));
-	connect(dialog->spinBoxUniformLoss, SIGNAL(valueChanged(int)), this, SLOT(ParameterChanged()));
-	connect(dialog->spinBoxUniformDuplication, SIGNAL(valueChanged(int)), this, SLOT(ParameterChanged()));
-	connect(dialog->spinBoxToggleBitsPr, SIGNAL(valueChanged(int)), this, SLOT(ParameterChanged()));
-	connect(dialog->spinBoxBitsMin, SIGNAL(valueChanged(int)), this, SLOT(ParameterChanged()));
-	connect(dialog->spinBoxBitsMax, SIGNAL(valueChanged(int)), this, SLOT(ParameterChanged()));
-	connect(dialog->spinBoxBurstInterval, SIGNAL(valueChanged(int)), this, SLOT(ParameterChanged()));
-	connect(dialog->spinBoxBurstLength, SIGNAL(valueChanged(int)), this, SLOT(ParameterChanged()));
-}
-
-NetworkSimulationDialog::~NetworkSimulationDialog()
-{
-	delete dialog;
-}
-
-void NetworkSimulationDialog::ParameterChanged()
-{
-	if (!connection)
-		return;
-	
-	NetworkSimulator &s = connection->NetworkSendSimulator();
-	s.enabled = dialog->checkBoxPacketDelayEnabled->isChecked() || dialog->checkBoxPacketLossEnabled->isChecked()
-		|| dialog->checkBoxPacketCorruptionEnabled->isChecked() || dialog->checkBoxPacketDuplicationEnabled->isChecked();
-
-	if (dialog->checkBoxPacketDelayEnabled->isChecked())
-	{
-		s.constantPacketSendDelay = dialog->spinBoxConstantDelay->value();
-		s.uniformRandomPacketSendDelay = dialog->spinBoxRandomDelay->value();
-	}
-	else
-	{
-		s.constantPacketSendDelay = 0;
-		s.uniformRandomPacketSendDelay = 0;
-	}
-
-	if (dialog->checkBoxPacketLossEnabled->isChecked())
-		s.packetLossRate = dialog->spinBoxUniformLoss->value() / 100.f;
-	else
-		s.packetLossRate = 0;
-}
-
-
-} // ~kNet