This commit is contained in:
2025-11-24 14:19:51 +05:30
commit f5c1412b28
6734 changed files with 1527575 additions and 0 deletions

View File

@ -0,0 +1,91 @@
/*
* This file was taken from RakNet 4.082.
* Please see licenses/RakNet license.txt for the underlying license and related copyright.
*
* Modified work: Copyright (c) 2017-2020, SLikeSoft UG (haftungsbeschränkt)
*
* This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
* license found in the license.txt file in the root directory of this source tree.
*/
#include "DX9_BackbufferGrabber.h"
DX9_BackbufferGrabber::DX9_BackbufferGrabber()
{
pDestSurface=0;
pRenderTargetSurface=0;
deviceUsedToInit=0;
width=0;
height=0;
needsUnlock=false;
}
DX9_BackbufferGrabber::~DX9_BackbufferGrabber()
{
if (pDestSurface)
pDestSurface->Release();
if (pRenderTargetSurface)
pRenderTargetSurface->Release();
}
void DX9_BackbufferGrabber::InitBackbufferGrabber(LPDIRECT3DDEVICE9 pd3dDevice, int _width, int _height)
{
if (width==_width && height==_height && pDestSurface && pRenderTargetSurface)
return;
if (pDestSurface)
pDestSurface->Release();
if (pRenderTargetSurface)
pRenderTargetSurface->Release();
width=_width;
height=_height;
deviceUsedToInit=pd3dDevice;
HRESULT hr;
// KevinJ: Surface to copy to in system memory
hr = deviceUsedToInit->CreateOffscreenPlainSurface(width, height, D3DFMT_A8R8G8B8,D3DPOOL_SYSTEMMEM, &pDestSurface, nullptr);
if (hr!=S_OK) return;
// Surface to downsize to
hr = deviceUsedToInit->CreateRenderTarget(
width,
height,
D3DFMT_A8R8G8B8,
D3DMULTISAMPLE_NONE,
0,
false,
&pRenderTargetSurface,
nullptr
);
}
void DX9_BackbufferGrabber::LockBackbufferCopy(SLNet::RGBImageBlob *blob)
{
LPDIRECT3DDEVICE9 pd3dDevice;
pd3dDevice=deviceUsedToInit;
IDirect3DSurface9 * pBackBuffer;
HRESULT hr;
hr = deviceUsedToInit->GetBackBuffer(0,0,D3DBACKBUFFER_TYPE_MONO, &pBackBuffer);
hr = deviceUsedToInit->StretchRect(pBackBuffer, nullptr, pRenderTargetSurface, nullptr, D3DTEXF_NONE);
hr = deviceUsedToInit->GetRenderTargetData(pRenderTargetSurface,pDestSurface);
// SLNet::TimeMS t1 = SLNet::GetTimeMS();
D3DLOCKED_RECT lockedRect;
hr = pDestSurface->LockRect(&lockedRect,0,D3DLOCK_DONOTWAIT|D3DLOCK_READONLY|D3DLOCK_NOSYSLOCK);
if (hr==D3D_OK)
{
blob->data=(unsigned char*)(lockedRect.pBits);
// #high - consider changing data types or add error handling
blob->imageHeight=static_cast<uint16_t>(height);
blob->imageWidth=static_cast<uint16_t>(width);
blob->input_components=4;
blob->linePitch=static_cast<uint16_t>(lockedRect.Pitch);
needsUnlock=true;
}
}
void DX9_BackbufferGrabber::ReleaseBackbufferCopy(void)
{
if (needsUnlock)
{
pDestSurface->UnlockRect();
needsUnlock=false;
}
}

View File

@ -0,0 +1,38 @@
/*
* This file was taken from RakNet 4.082.
* Please see licenses/RakNet license.txt for the underlying license and related copyright.
*
* Modified work: Copyright (c) 2017, SLikeSoft UG (haftungsbeschränkt)
*
* This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
* license found in the license.txt file in the root directory of this source tree.
*/
#include <d3dx9.h>
#include "SQLiteLoggerCommon.h"
class DX9_BackbufferGrabber
{
public:
// Width and height are size of the surface to copy to
DX9_BackbufferGrabber();
~DX9_BackbufferGrabber();
// Call before using LockBackbufferCopy or ReleaseBackbufferCopy
void InitBackbufferGrabber(LPDIRECT3DDEVICE9 pd3dDevice, int _width, int _height);
// blob is an output parameter. Unchanged if the copy fails.
// blob->data is only valid until you call ReleaseBackbufferCopy
// If pd3dDevice is 0, it will use whatever was passed to InitBackbufferGrabber
void LockBackbufferCopy(SLNet::RGBImageBlob *blob);
// Call ReleaseBackbufferCopy after calling LockBackbufferCopy, when you are done with blob.
void ReleaseBackbufferCopy(void);
protected:
IDirect3DSurface9 * pDestSurface, *pRenderTargetSurface;
int width;
int height;
bool needsUnlock;
LPDIRECT3DDEVICE9 deviceUsedToInit;
};

View File

@ -0,0 +1,13 @@
/*
* This file was taken from RakNet 4.082 without any modifications.
* Please see licenses/RakNet license.txt for the underlying license and related copyright.
*/
#include "Ogre3D_DX9_BackbufferGrabber.h"
void Ogre3D_DX9_BackbufferGrabber::InitBackbufferGrabber(Ogre::RenderWindow* renderWindow, int _width, int _height)
{
LPDIRECT3DDEVICE9 DX9Device;
renderWindow->getCustomAttribute("D3DDEVICE", &DX9Device);
DX9_BackbufferGrabber::InitBackbufferGrabber(DX9Device, _width, _height);
}

View File

@ -0,0 +1,18 @@
/*
* This file was taken from RakNet 4.082 without any modifications.
* Please see licenses/RakNet license.txt for the underlying license and related copyright.
*/
#ifndef OGRE3D_DX9_BACKBUFFER_GRABBER_H
#define OGRE3D_DX9_BACKBUFFER_GRABBER_H
#include "DX9_BackbufferGrabber.h"
#include "OgreRenderWindow.h"
class Ogre3D_DX9_BackbufferGrabber : public DX9_BackbufferGrabber
{
public:
void InitBackbufferGrabber(Ogre::RenderWindow* renderWindow, int _width, int _height);
};
#endif

View File

@ -0,0 +1,113 @@
/*
* This file was taken from RakNet 4.082.
* Please see licenses/RakNet license.txt for the underlying license and related copyright.
*
* Modified work: Copyright (c) 2016-2018, SLikeSoft UG (haftungsbeschränkt)
*
* This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
* license found in the license.txt file in the root directory of this source tree.
*/
#include "SQLiteClientLogger_PacketLogger.h"
#include "SQLiteClientLoggerPlugin.h"
#include "slikenet/peerinterface.h"
#include "slikenet/InternalPacket.h"
#include "slikenet/MessageIdentifiers.h"
using namespace SLNet;
static const char *DEFAULT_PACKET_LOGGER_TABLE="PacketLogger";
SQLiteClientLogger_PacketLogger::SQLiteClientLogger_PacketLogger()
{
}
SQLiteClientLogger_PacketLogger::~SQLiteClientLogger_PacketLogger()
{
}
void SQLiteClientLogger_PacketLogger::OnDirectSocketSend(const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress)
{
char str1[64], str2[62], str3[64], str4[64];
SystemAddress localSystemAddress = rakPeerInterface->GetExternalID(remoteSystemAddress);
localSystemAddress.ToString(true, str1, static_cast<size_t>(64));
rakPeerInterface->GetGuidFromSystemAddress(SLNet::UNASSIGNED_SYSTEM_ADDRESS).ToString(str2, 62);
remoteSystemAddress.ToString(true, str3, static_cast<size_t>(64));
rakPeerInterface->GetGuidFromSystemAddress(remoteSystemAddress).ToString(str4, 64);
rakSqlLog(DEFAULT_PACKET_LOGGER_TABLE, "SndRcv,Type,PacketNumber,FrameNumber,PacketID,BitLength,LocalIP,LocalGuid,RemoteIP,RemoteGuid,splitPacketId,SplitPacketIndex,splitPacketCount,orderingIndex,misc", \
("Snd", "Raw",0, 0, IDTOString(data[0]), bitsUsed, str1, str2, str3, str4, "","","","","") );
}
void SQLiteClientLogger_PacketLogger::OnDirectSocketReceive(const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress)
{
char str1[64], str2[62], str3[64], str4[64];
SystemAddress localSystemAddress = rakPeerInterface->GetExternalID(remoteSystemAddress);
localSystemAddress.ToString(true, str1, static_cast<size_t>(64));
rakPeerInterface->GetGuidFromSystemAddress(SLNet::UNASSIGNED_SYSTEM_ADDRESS).ToString(str2, 62);
remoteSystemAddress.ToString(true, str3, static_cast<size_t>(64));
rakPeerInterface->GetGuidFromSystemAddress(remoteSystemAddress).ToString(str4, 64);
rakSqlLog(DEFAULT_PACKET_LOGGER_TABLE, "SndRcv,Type,PacketNumber,FrameNumber,PacketID,BitLength,LocalIP,LocalGuid,RemoteIP,RemoteGuid,splitPacketId,SplitPacketIndex,splitPacketCount,orderingIndex,misc", \
("Rcv", "Raw", "", "", IDTOString(data[0]),bitsUsed, str1, str2, str3, str4, "","","","","") );
}
void SQLiteClientLogger_PacketLogger::OnInternalPacket(InternalPacket *internalPacket, unsigned frameNumber, SystemAddress remoteSystemAddress, SLNet::TimeMS time, bool isSend)
{
// unused parameters
(void)time;
char str1[64], str2[62], str3[64], str4[64];
SystemAddress localSystemAddress = rakPeerInterface->GetExternalID(remoteSystemAddress);
localSystemAddress.ToString(true, str1, static_cast<size_t>(64));
rakPeerInterface->GetGuidFromSystemAddress(SLNet::UNASSIGNED_SYSTEM_ADDRESS).ToString(str2, 62);
remoteSystemAddress.ToString(true, str3, static_cast<size_t>(64));
rakPeerInterface->GetGuidFromSystemAddress(remoteSystemAddress).ToString(str4, 64);
unsigned char typeByte;
char *typeStr;
if (internalPacket->data[0]==ID_TIMESTAMP && BITS_TO_BYTES(internalPacket->dataBitLength)>sizeof(SLNet::TimeMS)+1)
{
typeByte=internalPacket->data[1+sizeof(SLNet::TimeMS)];
typeStr="Timestamp";
}
else
{
typeByte=internalPacket->data[0];
typeStr="Normal";
}
const char* sendType = (isSend) ? "Snd" : "Rcv";
rakSqlLog(DEFAULT_PACKET_LOGGER_TABLE, "SndRcv,Type,PacketNumber,FrameNumber,PacketID,BitLength,LocalIP,LocalGuid,RemoteIP,RemoteGuid,splitPacketId,SplitPacketIndex,splitPacketCount,orderingIndex,misc", \
(sendType, typeStr, internalPacket->reliableMessageNumber, frameNumber, IDTOString(typeByte), internalPacket->dataBitLength, str1, str2, str3, str4, internalPacket->splitPacketId, internalPacket->splitPacketIndex, internalPacket->splitPacketCount, internalPacket->orderingIndex,"") );
}
void SQLiteClientLogger_PacketLogger::OnAck(unsigned int messageNumber, SystemAddress remoteSystemAddress, SLNet::TimeMS time)
{
// unused parameters
(void)time;
char str1[64], str2[62], str3[64], str4[64];
SystemAddress localSystemAddress = rakPeerInterface->GetExternalID(remoteSystemAddress);
localSystemAddress.ToString(true, str1, static_cast<size_t>(64));
rakPeerInterface->GetGuidFromSystemAddress(SLNet::UNASSIGNED_SYSTEM_ADDRESS).ToString(str2, 62);
remoteSystemAddress.ToString(true, str3, static_cast<size_t>(64));
rakPeerInterface->GetGuidFromSystemAddress(remoteSystemAddress).ToString(str4, 64);
rakSqlLog(DEFAULT_PACKET_LOGGER_TABLE, "SndRcv,Type,PacketNumber,FrameNumber,PacketID,BitLength,LocalIP,LocalGuid,RemoteIP,RemoteGuid,splitPacketId,SplitPacketIndex,splitPacketCount,orderingIndex,misc", \
("Rcv", "Ack",messageNumber, "", "", "", str1, str2, str3, str4, "","","","","") );
}
void SQLiteClientLogger_PacketLogger::OnPushBackPacket(const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress)
{
char str1[64], str2[62], str3[64], str4[64];
SystemAddress localSystemAddress = rakPeerInterface->GetExternalID(remoteSystemAddress);
localSystemAddress.ToString(true, str1, static_cast<size_t>(64));
rakPeerInterface->GetGuidFromSystemAddress(SLNet::UNASSIGNED_SYSTEM_ADDRESS).ToString(str2, 62);
remoteSystemAddress.ToString(true, str3, static_cast<size_t>(64));
rakPeerInterface->GetGuidFromSystemAddress(remoteSystemAddress).ToString(str4, 64);
rakSqlLog(DEFAULT_PACKET_LOGGER_TABLE, "SndRcv,Type,PacketNumber,FrameNumber,PacketID,BitLength,LocalIP,LocalGuid,RemoteIP,RemoteGuid,splitPacketId,SplitPacketIndex,splitPacketCount,orderingIndex,misc", \
("Local", "PushBackPacket","", "", IDTOString(data[0]), bitsUsed, str1, str2, str3, str4, "","","","","") );
}
void SQLiteClientLogger_PacketLogger::WriteMiscellaneous(const char *type, const char *msg)
{
rakSqlLog(DEFAULT_PACKET_LOGGER_TABLE, "SndRcv,Type,PacketNumber,FrameNumber,PacketID,BitLength,LocalIP,LocalGuid,RemoteIP,RemoteGuid,splitPacketId,SplitPacketIndex,splitPacketCount,orderingIndex,misc", \
("Local", type,"", "", "", "", "", "", "","","","","","",msg) );
}

View File

@ -0,0 +1,55 @@
/*
* Original work: Copyright (c) 2014, Oculus VR, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* RakNet License.txt file in the licenses directory of this source tree. An additional grant
* of patent rights can be found in the RakNet Patents.txt file in the same directory.
*
*
* Modified work: Copyright (c) 2017, SLikeSoft UG (haftungsbeschränkt)
*
* This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
* license found in the license.txt file in the root directory of this source tree.
*/
/// \file
/// \brief This will write all incoming and outgoing network messages the SQLiteClientLoggerPlugin
///
#ifndef __SQL_LITE_CLIENT_LOGGER_PACKET_LOGGER_H_
#define __SQL_LITE_CLIENT_LOGGER_PACKET_LOGGER_H_
#include "slikenet/PacketLogger.h"
namespace SLNet
{
/// \ingroup PACKETLOGGER_GROUP
/// \brief Packetlogger that outputs to a file
class RAK_DLL_EXPORT SQLiteClientLogger_PacketLogger : public PacketLogger
{
public:
SQLiteClientLogger_PacketLogger();
virtual ~SQLiteClientLogger_PacketLogger();
virtual void OnDirectSocketSend(const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress);
virtual void OnDirectSocketReceive(const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress);
virtual void OnInternalPacket(InternalPacket *internalPacket, unsigned frameNumber, SystemAddress remoteSystemAddress, SLNet::TimeMS time, bool isSend);
virtual void OnAck(unsigned int messageNumber, SystemAddress remoteSystemAddress, SLNet::TimeMS time);
virtual void OnPushBackPacket(const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress);
virtual void WriteMiscellaneous(const char *type, const char *msg);
protected:
virtual void WriteLog(const char *str)
{
// unused parameters
(void)str;
}
};
}
#endif

View File

@ -0,0 +1,112 @@
/*
* This file was taken from RakNet 4.082.
* Please see licenses/RakNet license.txt for the underlying license and related copyright.
*
* Modified work: Copyright (c) 2017, SLikeSoft UG (haftungsbeschränkt)
*
* This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
* license found in the license.txt file in the root directory of this source tree.
*/
#include "SQLiteClientLogger_RNSLogger.h"
#include "slikenet/time.h"
#include "slikenet/GetTime.h"
#include "slikenet/statistics.h"
#include "slikenet/peerinterface.h"
#include "SQLiteClientLoggerPlugin.h"
using namespace SLNet;
static const char *DEFAULT_RAKNET_STATISTICS_TABLE="RakNetStatistics";
SQLiteClientLogger_RakNetStatistics::SQLiteClientLogger_RakNetStatistics()
{
lastUpdate=0;
}
SQLiteClientLogger_RakNetStatistics::~SQLiteClientLogger_RakNetStatistics()
{
}
void SQLiteClientLogger_RakNetStatistics::Update(void)
{
SLNet::TimeUS time = SLNet::GetTimeUS();
if (time-lastUpdate>1000000)
{
lastUpdate=time;
unsigned int i;
RakNetStatistics rns;
for (i=0; i < rakPeerInterface->GetMaximumNumberOfPeers(); i++)
{
if (rakPeerInterface->GetStatistics( i, &rns ))
{
/*
rns.valueOverLastSecond[USER_MESSAGE_BYTES_PUSHED],
rns.valueOverLastSecond[USER_MESSAGE_BYTES_SENT],
rns.valueOverLastSecond[USER_MESSAGE_BYTES_RESENT],
rns.valueOverLastSecond[USER_MESSAGE_BYTES_RECEIVED_PROCESSED],
rns.valueOverLastSecond[USER_MESSAGE_BYTES_RECEIVED_IGNORED],
rns.valueOverLastSecond[ACTUAL_BYTES_SENT],
rns.valueOverLastSecond[ACTUAL_BYTES_RECEIVED],
rns.runningTotal[USER_MESSAGE_BYTES_PUSHED],
rns.runningTotal[USER_MESSAGE_BYTES_SENT],
rns.runningTotal[USER_MESSAGE_BYTES_RESENT],
rns.runningTotal[USER_MESSAGE_BYTES_RECEIVED_PROCESSED],
rns.runningTotal[USER_MESSAGE_BYTES_RECEIVED_IGNORED],
rns.runningTotal[ACTUAL_BYTES_SENT],
rns.runningTotal[ACTUAL_BYTES_RECEIVED],
rns.connectionStartTime,
rns.BPSLimitByCongestionControl,
rns.isLimitedByCongestionControl,
rns.BPSLimitByOutgoingBandwidthLimit,
rns.isLimitedByOutgoingBandwidthLimit,
rns.messageInSendBuffer[IMMEDIATE_PRIORITY],
rns.messageInSendBuffer[HIGH_PRIORITY],
rns.messageInSendBuffer[MEDIUM_PRIORITY],
rns.messageInSendBuffer[LOW_PRIORITY],
rns.bytesInSendBuffer[IMMEDIATE_PRIORITY],
rns.bytesInSendBuffer[HIGH_PRIORITY],
rns.bytesInSendBuffer[MEDIUM_PRIORITY],
rns.bytesInSendBuffer[LOW_PRIORITY],
rns.messagesInResendBuffer,
rns.bytesInResendBuffer,
rns.packetlossLastSecond,
rns.packetlossTotal,
*/
rakSqlLog(
DEFAULT_RAKNET_STATISTICS_TABLE,
"valueOverLastSecond[USER_MESSAGE_BYTES_PUSHED],"
"valueOverLastSecond[USER_MESSAGE_BYTES_SENT],"
"valueOverLastSecond[USER_MESSAGE_BYTES_RESENT],"
"valueOverLastSecond[USER_MESSAGE_BYTES_RECEIVED_PROCESSED],"
"valueOverLastSecond[USER_MESSAGE_BYTES_RECEIVED_IGNORED],"
"valueOverLastSecond[ACTUAL_BYTES_SENT],"
"valueOverLastSecond[ACTUAL_BYTES_RECEIVED],"
"BPSLimitByCongestionControl,"
"BPSLimitByOutgoingBandwidthLimit,"
"bytesInSendBuffer,"
"messagesInResendBuffer,"
"bytesInResendBuffer,"
"packetlossLastSecond,"
"packetlossTotal",
( \
rns.valueOverLastSecond[USER_MESSAGE_BYTES_PUSHED], \
rns.valueOverLastSecond[USER_MESSAGE_BYTES_SENT], \
rns.valueOverLastSecond[USER_MESSAGE_BYTES_RESENT], \
rns.valueOverLastSecond[USER_MESSAGE_BYTES_RECEIVED_PROCESSED], \
rns.valueOverLastSecond[USER_MESSAGE_BYTES_RECEIVED_IGNORED], \
rns.valueOverLastSecond[ACTUAL_BYTES_SENT], \
rns.valueOverLastSecond[ACTUAL_BYTES_RECEIVED], \
rns.BPSLimitByCongestionControl, \
rns.BPSLimitByOutgoingBandwidthLimit, \
rns.bytesInSendBuffer[IMMEDIATE_PRIORITY]+rns.bytesInSendBuffer[HIGH_PRIORITY]+rns.bytesInSendBuffer[MEDIUM_PRIORITY]+rns.bytesInSendBuffer[LOW_PRIORITY], \
rns.messagesInResendBuffer, \
rns.bytesInResendBuffer, \
rns.packetlossLastSecond, \
rns.packetlossTotal \
));
}
}
}
}

View File

@ -0,0 +1,42 @@
/*
* Original work: Copyright (c) 2014, Oculus VR, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* RakNet License.txt file in the licenses directory of this source tree. An additional grant
* of patent rights can be found in the RakNet Patents.txt file in the same directory.
*
*
* Modified work: Copyright (c) 2017, SLikeSoft UG (haftungsbeschränkt)
*
* This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
* license found in the license.txt file in the root directory of this source tree.
*/
/// \file
/// \brief Writes RakNetStatistics for all connected systems once per second to SQLiteClientLogger
///
#ifndef __SQL_LITE_CLIENT_LOGGER_RAKNET_STATISTICS_H_
#define __SQL_LITE_CLIENT_LOGGER_RAKNET_STATISTICS_H_
#include "slikenet/PluginInterface2.h"
namespace SLNet
{
/// \ingroup PACKETLOGGER_GROUP
/// \brief Packetlogger that outputs to a file
class RAK_DLL_EXPORT SQLiteClientLogger_RakNetStatistics : public PluginInterface2
{
public:
SQLiteClientLogger_RakNetStatistics();
virtual ~SQLiteClientLogger_RakNetStatistics();
virtual void Update(void);
protected:
SLNet::TimeUS lastUpdate;
};
}
#endif