Skip to content

Commit

Permalink
Merge pull request #1513 from dgelessus/reduce_pnutils
Browse files Browse the repository at this point in the history
Move most pnUtils code into more appropriate places
  • Loading branch information
Hoikas authored Oct 22, 2023
2 parents 50f6537 + a1ae126 commit 55ba2ae
Show file tree
Hide file tree
Showing 35 changed files with 33 additions and 411 deletions.
1 change: 0 additions & 1 deletion Sources/Plasma/NucleusLib/pnAsyncCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ target_link_libraries(
PRIVATE
pnAsyncCoreExe # Implementation is here
pnNetBase
pnUtils
plStatusLog # :(
)

Expand Down
1 change: 0 additions & 1 deletion Sources/Plasma/NucleusLib/pnAsyncCore/Pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ You can contact Cyan Worlds, Inc. by email [email protected]

#include <thread>

#include "pnUtils/pnUtils.h"
#include "plProduct.h"
#include "pnNetBase/pnNetBase.h"
#include "Private/pnAcAllIncludes.h"
1 change: 0 additions & 1 deletion Sources/Plasma/NucleusLib/pnAsyncCore/Private/pnAcThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ You can contact Cyan Worlds, Inc. by email [email protected]
#include <thread>

#include "pnNetBase/pnNbError.h"
#include "pnUtils/pnUtils.h"


/****************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion Sources/Plasma/NucleusLib/pnAsyncCoreExe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ target_link_libraries(
CoreLib
pnAsyncCore
pnNetBase
pnUtils
pnNucleusInc
ASIO::ASIO
$<$<BOOL:${USE_VLD}>:${VLD_LIBRARY}>
)
Expand Down
2 changes: 1 addition & 1 deletion Sources/Plasma/NucleusLib/pnAsyncCoreExe/Pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ You can contact Cyan Worlds, Inc. by email [email protected]

#include "Private/pnAceInt.h"
#include "hsThread.h"
#include "hsTimer.h"
#include "plProduct.h"
#include "pnAsyncCore/pnAsyncCore.h"
#include "pnNetBase/pnNetBase.h"
#include "pnUtils/pnUtils.h"

#ifdef USE_VLD
#include <vld.h>
Expand Down
6 changes: 3 additions & 3 deletions Sources/Plasma/NucleusLib/pnAsyncCoreExe/pnAceSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ static bool SocketInitConnect(ConnectOperation& op)
// This steals ownership of op->fSock
auto sock = std::make_unique<AsyncSocketStruct>(op);

sock->initTimeMs = TimeGetMs();
sock->initTimeMs = hsTimer::GetMilliSeconds<unsigned>();

asio::error_code err;
sock->fSock.non_blocking(true, err);
Expand Down Expand Up @@ -422,7 +422,7 @@ static bool SocketQueueAsyncWrite(AsyncSocket conn, const void* data, size_t byt
// check for data backlog
if (!conn->fWriteOps.empty()) {
WriteOperation* firstQueuedWrite = conn->fWriteOps.front();
unsigned currTimeMs = TimeGetMs();
unsigned currTimeMs = hsTimer::GetMilliSeconds<unsigned>();
if (((long)(currTimeMs - firstQueuedWrite->queueTimeMs) >= (long)kBacklogFailMs) && ((long)(currTimeMs - conn->initTimeMs) >= (long)kBacklogInitMs)) {
PerfAddCounter(kAsyncPerfSocketDisconnectBacklog, 1);

Expand Down Expand Up @@ -464,7 +464,7 @@ static bool SocketQueueAsyncWrite(AsyncSocket conn, const void* data, size_t byt
op->fNotify.buffer = membuf + sizeof(WriteOperation);
op->fNotify.bytes = bytes;
op->fNotify.bytesProcessed = 0;
op->queueTimeMs = TimeGetMs();
op->queueTimeMs = hsTimer::GetMilliSeconds<unsigned>();
memcpy(op->fNotify.buffer, data, bytes);

PerfAddCounter(kAsyncPerfSocketBytesWaitQueued, bytes);
Expand Down
5 changes: 3 additions & 2 deletions Sources/Plasma/NucleusLib/pnAsyncCoreExe/pnAceThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ static void CreateThreadProc(AsyncThreadRef thread)
//============================================================================
void ThreadDestroy(unsigned exitThreadWaitMs)
{
unsigned bailAt = TimeGetMs() + exitThreadWaitMs;
while (AsyncPerfGetCounter(kAsyncPerfThreadsCurr) && signed(bailAt - TimeGetMs()) > 0)
unsigned bailAt = hsTimer::GetMilliSeconds<unsigned>() + exitThreadWaitMs;
while (AsyncPerfGetCounter(kAsyncPerfThreadsCurr) && hsTimer::GetMilliSeconds<unsigned>() < bailAt) {
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}

//============================================================================
Expand Down
2 changes: 2 additions & 0 deletions Sources/Plasma/NucleusLib/pnEncryption/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ set(pnEncryption_SOURCES
plBigNum.cpp
plChallengeHash.cpp
plChecksum.cpp
plEncryption.cpp
plSha0.cpp
)

set(pnEncryption_HEADERS
plBigNum.h
plChallengeHash.h
plChecksum.h
plEncryption.h
plSha0.h
plRandom.h
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,8 @@ You can contact Cyan Worlds, Inc. by email [email protected]
Mead, WA 99021
*==LICENSE==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtCrypt.cpp
*
***/

#include "Pch.h"

#include "pnUtCrypt.h"
#include "pnUtStr.h"
#include "pnUtTime.h"
#include "plEncryption.h"

#include <openssl/rc4.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,11 @@ You can contact Cyan Worlds, Inc. by email [email protected]
Mead, WA 99021
*==LICENSE==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtCrypt.h
*
***/

#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTCRYPT_H
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTCRYPT_H
#ifndef PL_ENCRYPTION_H
#define PL_ENCRYPTION_H

#include "pnEncryption/plChecksum.h"
#include "plChecksum.h"

/*****************************************************************************
*
Expand Down
1 change: 0 additions & 1 deletion Sources/Plasma/NucleusLib/pnNetCli/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ target_link_libraries(
PRIVATE
pnAsyncCore
pnNetBase
pnUtils
pnUUID
)

Expand Down
1 change: 0 additions & 1 deletion Sources/Plasma/NucleusLib/pnNetCli/Pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ You can contact Cyan Worlds, Inc. by email [email protected]
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNNETCLI_PCH_H


#include "pnUtils/pnUtils.h"
#include "pnNetBase/pnNetBase.h"
#include "pnAsyncCore/pnAsyncCore.h"
#include "pnEncryption/plBigNum.h"
Expand Down
1 change: 1 addition & 0 deletions Sources/Plasma/NucleusLib/pnNetCli/pnNcCli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ You can contact Cyan Worlds, Inc. by email [email protected]

#include "hsWindows.h"
#include "pnEncryption/plChallengeHash.h"
#include "pnEncryption/plEncryption.h"
#include "pnUUID/pnUUID.h"
#include "hsLockGuard.h"
#include <mutex>
Expand Down
1 change: 1 addition & 0 deletions Sources/Plasma/NucleusLib/pnNetProtocol/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ target_link_libraries(
pnNetProtocol
PUBLIC
CoreLib
pnEncryption
pnNetBase
pnUUID
PRIVATE
Expand Down
1 change: 0 additions & 1 deletion Sources/Plasma/NucleusLib/pnNetProtocol/Pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ You can contact Cyan Worlds, Inc. by email [email protected]
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNNETPROTOCOL_PCH_H

#include "HeadSpin.h"
#include "pnUtils/pnUtils.h"
#include "pnNetBase/pnNetBase.h"
#include "pnAsyncCore/pnAsyncCore.h"
#include "pnNetCli/pnNetCli.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ You can contact Cyan Worlds, Inc. by email [email protected]
***/

#include "../Pch.h"

#include "pnUtils/pnUtStr.h"
#include "pnUUID/pnUUID.h"

#include <string>
Expand Down
2 changes: 2 additions & 0 deletions Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ You can contact Cyan Worlds, Inc. by email [email protected]

#ifdef USES_NETCLI

#include "pnEncryption/plChecksum.h"

const NetMsgField kNetMsgFieldAccountName = NET_MSG_FIELD_STRING(kMaxAccountNameLength);
const NetMsgField kNetMsgFieldPlayerName = NET_MSG_FIELD_STRING(kMaxPlayerNameLength);
const NetMsgField kNetMsgFieldShaDigest = NET_MSG_FIELD_RAW_DATA(sizeof(ShaDigest));
Expand Down
17 changes: 1 addition & 16 deletions Sources/Plasma/NucleusLib/pnUtils/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,31 +1,16 @@
set(pnUtils_HEADERS
Pch.h
pnUtils.h
pnUtCoreLib.h
pnUtAllIncludes.h
pnUtCrypt.h
pnUtStr.h
pnUtTime.h
)

set(pnUtils_SOURCES
pnUtCrypt.cpp
pnUtStr.cpp
pnUtTime.cpp
)

plasma_library(pnUtils
SOURCES ${pnUtils_HEADERS} ${pnUtils_SOURCES}
PRECOMPILED_HEADERS Pch.h
UNITY_BUILD
)
plasma_library(pnUtils SOURCES ${pnUtils_HEADERS} ${pnUtils_SOURCES})
target_link_libraries(
pnUtils
PUBLIC
CoreLib
pnEncryption
PRIVATE
OpenSSL::Crypto
)

source_group("Header Files" FILES ${pnUtils_HEADERS})
Expand Down
54 changes: 0 additions & 54 deletions Sources/Plasma/NucleusLib/pnUtils/Pch.h

This file was deleted.

57 changes: 0 additions & 57 deletions Sources/Plasma/NucleusLib/pnUtils/pnUtAllIncludes.h

This file was deleted.

54 changes: 0 additions & 54 deletions Sources/Plasma/NucleusLib/pnUtils/pnUtCoreLib.h

This file was deleted.

Loading

0 comments on commit 55ba2ae

Please sign in to comment.