Browse Source

Remove unused dead weight CSR and SimpleNet code

Adam Johnson 13 years ago
parent
commit
95e1fe34b8
  1. 3
      Sources/Plasma/Apps/plClient/CMakeLists.txt
  2. 6
      Sources/Plasma/Apps/plClient/plClient.cpp
  3. 1
      Sources/Plasma/Apps/plUruLauncher/CMakeLists.txt
  4. 1
      Sources/Plasma/FeatureLib/CMakeLists.txt
  5. 51
      Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCommandsCore.cpp
  6. 19
      Sources/Plasma/FeatureLib/pfCsrSrv/CMakeLists.txt
  7. 58
      Sources/Plasma/FeatureLib/pfCsrSrv/Pch.h
  8. 160
      Sources/Plasma/FeatureLib/pfCsrSrv/pfCsrSrv.cpp
  9. 66
      Sources/Plasma/FeatureLib/pfCsrSrv/pfCsrSrv.h
  10. 3
      Sources/Plasma/NucleusLib/CMakeLists.txt
  11. 4
      Sources/Plasma/NucleusLib/pnAsyncCore/Private/pnAcIo.h
  12. 16
      Sources/Plasma/NucleusLib/pnCsrCli/CMakeLists.txt
  13. 56
      Sources/Plasma/NucleusLib/pnCsrCli/Pch.h
  14. 269
      Sources/Plasma/NucleusLib/pnCsrCli/pnCsrCli.cpp
  15. 83
      Sources/Plasma/NucleusLib/pnCsrCli/pnCsrCli.h
  16. 16
      Sources/Plasma/NucleusLib/pnCsrNet/CMakeLists.txt
  17. 54
      Sources/Plasma/NucleusLib/pnCsrNet/Pch.h
  18. 49
      Sources/Plasma/NucleusLib/pnCsrNet/pnCsrNet.cpp
  19. 88
      Sources/Plasma/NucleusLib/pnCsrNet/pnCsrNet.h
  20. 14
      Sources/Plasma/NucleusLib/pnNetBase/pnNbConst.h
  21. 4
      Sources/Plasma/NucleusLib/pnNetBase/pnNbKeys.cpp
  22. 5
      Sources/Plasma/NucleusLib/pnNetBase/pnNbKeys.h
  23. 12
      Sources/Plasma/NucleusLib/pnNetBase/pnNbProtocol.cpp
  24. 2
      Sources/Plasma/NucleusLib/pnNetBase/pnNbProtocol.h
  25. 22
      Sources/Plasma/NucleusLib/pnNetBase/pnNbSrvs.cpp
  26. 5
      Sources/Plasma/NucleusLib/pnNetBase/pnNbSrvs.h
  27. 17
      Sources/Plasma/NucleusLib/pnNetProtocol/CMakeLists.txt
  28. 122
      Sources/Plasma/NucleusLib/pnNetProtocol/Private/Protocols/Cli2Csr/pnNpCli2Csr.cpp
  29. 178
      Sources/Plasma/NucleusLib/pnNetProtocol/Private/Protocols/Cli2Csr/pnNpCli2Csr.h
  30. 4
      Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpAllIncludes.h
  31. 15
      Sources/Plasma/NucleusLib/pnSimpleNet/CMakeLists.txt
  32. 658
      Sources/Plasma/NucleusLib/pnSimpleNet/pnSimpleNet.cpp
  33. 185
      Sources/Plasma/NucleusLib/pnSimpleNet/pnSimpleNet.h
  34. 2
      Sources/Plasma/PubUtilLib/plNetGameLib/CMakeLists.txt
  35. 34
      Sources/Plasma/PubUtilLib/plNetGameLib/Intern.h
  36. 1
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAllIncludes.h
  37. 3
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglCore.cpp
  38. 900
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglCsr.cpp
  39. 94
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglCsr.h
  40. 1
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglMisc.cpp
  41. 1
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglTrans.cpp
  42. 3
      Sources/Tools/MaxMain/CMakeLists.txt
  43. 3
      Sources/Tools/MaxPlasmaLights/CMakeLists.txt

3
Sources/Plasma/Apps/plClient/CMakeLists.txt

@ -80,7 +80,6 @@ target_link_libraries(plClient pfConditional)
target_link_libraries(plClient pfConsole)
target_link_libraries(plClient pfConsoleCore)
target_link_libraries(plClient pfCrashHandler)
target_link_libraries(plClient pfCsrSrv)
target_link_libraries(plClient pfGameGUIMgr)
target_link_libraries(plClient pfGameMgr)
target_link_libraries(plClient pfGameScoreMgr)
@ -138,7 +137,6 @@ target_link_libraries(plClient plVault)
target_link_libraries(plClient pnAddrInfo)
target_link_libraries(plClient pnAsyncCore)
target_link_libraries(plClient pnAsyncCoreExe)
target_link_libraries(plClient pnCsrNet)
target_link_libraries(plClient pnDispatch)
target_link_libraries(plClient pnEncryption)
target_link_libraries(plClient pnFactory)
@ -154,7 +152,6 @@ target_link_libraries(plClient pnNetProtocol)
target_link_libraries(plClient pnNucleusInc)
target_link_libraries(plClient pnProduct)
target_link_libraries(plClient pnSceneObject)
target_link_libraries(plClient pnSimpleNet)
target_link_libraries(plClient pnTimer)
target_link_libraries(plClient pnUtils)
target_link_libraries(plClient pnUtilsExe)

6
Sources/Plasma/Apps/plClient/plClient.cpp

@ -156,8 +156,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pfSecurePreloader/pfSecurePreloader.h"
#include "pfLocalizationMgr/pfLocalizationMgr.h"
#include "pfCsrSrv/pfCsrSrv.h"
#include "plTweak.h"
#define MSG_LOADING_BAR
@ -263,8 +261,6 @@ hsBool plClient::Shutdown()
plSynchEnabler ps(false); // disable dirty state tracking during shutdown
delete fProgressBar;
CsrSrvShutdown();
// Just in case, clear this out (trying to fix a crash bug where this is still active at shutdown)
plDispatch::SetMsgRecieveCallback(nil);
@ -2544,8 +2540,6 @@ void plClient::ICompleteInit () {
plClientMsg* clientMsg = new plClientMsg(plClientMsg::kInitComplete);
clientMsg->SetBCastFlag(plMessage::kBCastByType);
clientMsg->Send();
CsrSrvInitialize();
}
//============================================================================

1
Sources/Plasma/Apps/plUruLauncher/CMakeLists.txt

@ -53,7 +53,6 @@ target_link_libraries(plUruLauncher pnNetCli)
target_link_libraries(plUruLauncher pnNetCommon)
target_link_libraries(plUruLauncher pnNetProtocol)
target_link_libraries(plUruLauncher pnProduct)
target_link_libraries(plUruLauncher pnSimpleNet)
target_link_libraries(plUruLauncher pnTimer)
target_link_libraries(plUruLauncher pnUtils)
target_link_libraries(plUruLauncher pnUtilsExe)

1
Sources/Plasma/FeatureLib/CMakeLists.txt

@ -9,7 +9,6 @@ add_subdirectory(pfConditional)
add_subdirectory(pfConsole)
add_subdirectory(pfConsoleCore)
add_subdirectory(pfCrashHandler)
add_subdirectory(pfCsrSrv)
add_subdirectory(pfGameGUIMgr)
add_subdirectory(pfGameMgr)
add_subdirectory(pfGameScoreMgr)

51
Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCommandsCore.cpp

@ -179,57 +179,6 @@ PF_CONSOLE_CMD(
}
//============================================================================
// Server.Csr group
PF_CONSOLE_SUBGROUP(Server, Csr)
//============================================================================
PF_CONSOLE_CMD(
Server_Csr,
Host,
"string address",
"Set the Csr Server address"
) {
SetCsrSrvHostname(params[0]);
}
//============================================================================
PF_CONSOLE_CMD(
Server_Csr,
N,
"string base64Key",
"Set the Csr Server N key"
) {
int baseLength = hsStrlen((const char *)params[0]);
if ((kNetDiffieHellmanKeyBits / 8) != Base64DecodeSize(baseLength, (const char *)params[0])) {
PrintStringF(PrintString, "Invalid key: should be exactly %u bytes",
kNetDiffieHellmanKeyBits / 8);
return;
}
Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0],
kNetDiffieHellmanKeyBits / 8, kCsrDhNData);
}
//============================================================================
PF_CONSOLE_CMD(
Server_Csr,
X,
"string base64Key",
"Set the Csr Server X key"
) {
int baseLength = hsStrlen((const char *)params[0]);
if ((kNetDiffieHellmanKeyBits / 8) != Base64DecodeSize(baseLength, (const char *)params[0])) {
PrintStringF(PrintString, "Invalid key: should be exactly %u bytes",
kNetDiffieHellmanKeyBits / 8);
return;
}
Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0],
kNetDiffieHellmanKeyBits / 8, kCsrDhXData);
}
//============================================================================
// Server.Game group
PF_CONSOLE_SUBGROUP(Server, Game)

19
Sources/Plasma/FeatureLib/pfCsrSrv/CMakeLists.txt

@ -1,19 +0,0 @@
include_directories(../../CoreLib)
include_directories(../../FeatureLib)
include_directories(../../NucleusLib)
include_directories(../../NucleusLib/inc)
include_directories(../../PubUtilLib)
set(pfCsrSrv_SOURCES
pfCsrSrv.cpp
)
set(pfCsrSrv_HEADERS
Pch.h
pfCsrSrv.h
)
add_library(pfCsrSrv STATIC ${pfCsrSrv_SOURCES} ${pfCsrSrv_HEADERS})
source_group("Source Files" FILES ${pfCsrSrv_SOURCES})
source_group("Header Files" FILES ${pfCsrSrv_HEADERS})

58
Sources/Plasma/FeatureLib/pfCsrSrv/Pch.h

@ -1,58 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/FeatureLib/pfCsrSrv/Pch.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_FEATURELIB_PFCSRSRV_PCH_H
#error "Header $/Plasma20/Sources/Plasma/FeatureLib/pfCsrSrv/Pch.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_FEATURELIB_PFCSRSRV_PCH_H
#include "pfCsrSrv.h"
#pragma warning(push, 0)
#include "pfConsole/pfConsole.h"
#pragma warning(pop)

160
Sources/Plasma/FeatureLib/pfCsrSrv/pfCsrSrv.cpp

@ -1,160 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/FeatureLib/pfCsrSrv/pfCsrSrv.cpp
*
***/
#include "Pch.h"
#pragma hdrstop
/*****************************************************************************
*
* Local types
*
***/
/*****************************************************************************
*
* Local data
*
***/
static bool s_running;
/*****************************************************************************
*
* Local functions
*
***/
//============================================================================
static bool Recv_ExecConsoleCmd (
SimpleNetConn * ,
CsrNet_ExecConsoleCmd * msg
) {
LogMsg(kLogPerf, L"pfCsrSrv: ExecConsoleCmd: %S", msg->cmd);
pfConsole::RunCommandAsync(msg->cmd);
return true;
}
//============================================================================
static bool OnMsg (
SimpleNetConn * conn,
SimpleNet_MsgHeader * msg
) {
bool result;
#define DISPATCH(a) case kCsrNet_##a: result = Recv_##a(conn, (CsrNet_##a *) msg); break
switch (msg->messageId) {
DISPATCH(ExecConsoleCmd);
default:
result = false;
}
#undef DISPATCH
return result;
}
//============================================================================
static void OnError (
SimpleNetConn * ,
ENetError error
) {
LogMsg(kLogPerf, L"pfCsrSrv NetError: %s", NetErrorToString(error));
}
//============================================================================
static bool QueryAccept (
void * ,
unsigned channel,
SimpleNetConn * ,
const plNetAddress& addr
) {
plString str = addr.AsString();
LogMsg(kLogPerf, L"pfCsrSrv: Accepted connection from %s", str.c_str());
return channel == kSimpleNetChannelCsr;
}
/*****************************************************************************
*
* Exports
*
***/
//============================================================================
void CsrSrvInitialize () {
#ifdef PLASMA_ENABLE_CSR_EXTERNAL
LogMsg(kLogPerf, L"pfCsrSrv: Initializing");
s_running = true;
SimpleNetInitialize();
SimpleNetCreateChannel(kSimpleNetChannelCsr, OnMsg, OnError);
SimpleNetStartListening(QueryAccept, nil);
#endif
}
//============================================================================
void CsrSrvShutdown () {
#ifdef PLASMA_ENABLE_CSR_EXTERNAL
LogMsg(kLogPerf, L"pfCsrSrv: Shutting down");
s_running = false;
SimpleNetStopListening();
SimpleNetDestroyChannel(kSimpleNetChannelCsr);
SimpleNetShutdown();
#endif
}

66
Sources/Plasma/FeatureLib/pfCsrSrv/pfCsrSrv.h

@ -1,66 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/FeatureLib/pfCsrSrv/pfCsrSrv.h
*
***/
#ifndef PLASMA20_SOURCES_PLASMA_FEATURELIB_PFCSRSRV_PFCSRSRV_H
#define PLASMA20_SOURCES_PLASMA_FEATURELIB_PFCSRSRV_PFCSRSRV_H
#include "pnCsrNet/pnCsrNet.h"
/*****************************************************************************
*
* pfCsrSrv
* - Executes remote CSR commands received through pnCsrNet
*
***/
void CsrSrvInitialize ();
void CsrSrvShutdown ();
#endif // PLASMA20_SOURCES_PLASMA_FEATURELIB_PFCSRSRV_PFCSRSRV_H

3
Sources/Plasma/NucleusLib/CMakeLists.txt

@ -4,8 +4,6 @@ add_subdirectory(inc)
add_subdirectory(pnAddrInfo)
add_subdirectory(pnAsyncCore)
add_subdirectory(pnAsyncCoreExe)
#add_subdirectory(pnCsrCli) # Not being used in any current sln
add_subdirectory(pnCsrNet)
add_subdirectory(pnDispatch)
add_subdirectory(pnEncryption)
add_subdirectory(pnFactory)
@ -20,7 +18,6 @@ add_subdirectory(pnNetCommon)
add_subdirectory(pnNetProtocol)
add_subdirectory(pnProduct)
add_subdirectory(pnSceneObject)
add_subdirectory(pnSimpleNet)
add_subdirectory(pnTimer)
add_subdirectory(pnUtils)
add_subdirectory(pnUtilsExe)

4
Sources/Plasma/NucleusLib/pnAsyncCore/Private/pnAcIo.h

@ -162,8 +162,8 @@ enum EConnType {
kConnTypeSrvToState = 17,
kConnTypeSrvToLog = 18,
kConnTypeSrvToScore = 19,
kConnTypeCliToCsr = 20,
kConnTypeSimpleNet = 21,
kConnTypeCliToCsr = 20, // DEAD
kConnTypeSimpleNet = 21, // DEAD
kConnTypeCliToGateKeeper = 22,
// Text connections

16
Sources/Plasma/NucleusLib/pnCsrCli/CMakeLists.txt

@ -1,16 +0,0 @@
include_directories(../../CoreLib)
include_directories(../../NucleusLib)
set(pnCsrCli_SOURCES
pnCsrCli.cpp
)
set(pnCsrCli_HEADERS
Pch.h
pnCsrCli.h
)
add_library(pnCsrCli STATIC ${pnCsrCli_SOURCES} ${pnCsrCli_HEADERS})
source_group("Source Files" FILES ${pnCsrCli_SOURCES})
source_group("Header Files" FILES ${pnCsrCli_HEADERS})

56
Sources/Plasma/NucleusLib/pnCsrCli/Pch.h

@ -1,56 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnCsrCli/Pch.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCSRCLI_PCH_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnCsrCli/Pch.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCSRCLI_PCH_H
#include "pnCsrCli.h"
#include <malloc.h>

269
Sources/Plasma/NucleusLib/pnCsrCli/pnCsrCli.cpp

@ -1,269 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnCsrCli/pnCsrCli.cpp
*
***/
#include "Pch.h"
#pragma hdrstop
/*****************************************************************************
*
* Local types
*
***/
/*****************************************************************************
*
* Local data
*
***/
static bool s_running;
static CCritSect s_critsect;
static SimpleNetConn * s_conn;
static FCsrCliOnError s_onError;
/*****************************************************************************
*
* Local functions
*
***/
//============================================================================
static SimpleNetConn * GetConnIncRef () {
SimpleNetConn * conn;
s_critsect.Enter();
{
if (nil != (conn = s_conn))
SimpleNetConnIncRef(conn);
}
s_critsect.Leave();
return conn;
}
//============================================================================
static bool SimpleNetOnMsg (
SimpleNetConn * ,
SimpleNet_MsgHeader *
) {
LogMsg(kLogPerf, L"pnCsrCli: Rcvd unexpected message from peer");
return false;
}
//============================================================================
static void SimpleNetOnError (
SimpleNetConn * ,
ENetError error
) {
if (!s_running)
return;
LogMsg(kLogPerf, L"pnCsrCli: NetError: %s", NetErrorToString(error));
if (error == kNetErrDisconnected)
CsrCliDisconnect();
s_onError(error);
}
//============================================================================
static void SimpleNetOnConnect (
void * param,
SimpleNetConn * conn,
ENetError result
) {
FCsrCliOnConnect onConnect = (FCsrCliOnConnect)param;
LogMsg(kLogPerf, L"pnCsrCli: OnConnect: %s", NetErrorToString(result));
if (s_conn)
CsrCliDisconnect();
if (IS_NET_SUCCESS(result)) {
s_critsect.Enter();
{
s_conn = conn;
}
s_critsect.Leave();
}
if (onConnect)
onConnect(result);
}
//============================================================================
static void Send_ExecConsoleCmd (const char cmd[]) {
SimpleNetConn * conn = GetConnIncRef();
if (!conn)
return;
unsigned cmdBytes = StrBytes(cmd);
CsrNet_ExecConsoleCmd * msg;
unsigned msgBytes
= sizeof(*msg)
- sizeof(msg->cmd)
+ cmdBytes
+ sizeof(cmd[0])
;
msg = new(_alloca(msgBytes)) CsrNet_ExecConsoleCmd();
msg->messageBytes = msgBytes;
StrCopy(msg->cmd, cmd, cmdBytes / sizeof(cmd[0]));
msg->cmd[cmdBytes] = 0;
SimpleNetSend(conn, msg);
SimpleNetConnDecRef(conn);
}
/*****************************************************************************
*
* Exports
*
***/
//============================================================================
void CsrCliInitialize (FCsrCliOnError onError) {
ASSERT(!s_running);
ASSERT(onError);
s_running = true;
s_onError = onError;
SimpleNetInitialize();
SimpleNetCreateChannel(kSimpleNetChannelCsr, SimpleNetOnMsg, SimpleNetOnError);
};
//============================================================================
void CsrCliShutdown () {
s_running = false;
s_onError = nil;
CsrCliDisconnect();
SimpleNetDestroyChannel(kSimpleNetChannelCsr);
SimpleNetShutdown();
}
//============================================================================
void CsrCliStartConnecting (
const wchar_t addr[],
FCsrCliOnConnect onConnect
) {
ASSERT(s_running);
CsrCliDisconnect();
SimpleNetStartConnecting(kSimpleNetChannelCsr, addr, SimpleNetOnConnect, onConnect);
}
//============================================================================
void CsrCliDisconnect () {
SimpleNetConn * conn = nil;
s_critsect.Enter();
{
SWAP(conn, s_conn);
}
s_critsect.Leave();
if (conn)
SimpleNetDisconnect(conn);
}
//============================================================================
void CsrCliToggleAvatarPhysical () {
ASSERT(s_running);
Send_ExecConsoleCmd("Avatar.Physics.TogglePhysical");
}
//============================================================================
void CsrCliWarpPlayerHere (unsigned playerId) {
ASSERT(s_running);
char cmd[1024];
StrPrintf(cmd, arrsize(cmd), "CCR.WarpPlayerHere %u", playerId);
Send_ExecConsoleCmd(cmd);
}
//============================================================================
void CsrCliWarpToPlayer (unsigned playerId) {
ASSERT(s_running);
char cmd[1024];
StrPrintf(cmd, arrsize(cmd), "CCR.WarpToPlayer %u", playerId);
Send_ExecConsoleCmd(cmd);
}
//============================================================================
void CsrCliLinkPlayerHere (unsigned playerId) {
ASSERT(s_running);
char cmd[1024];
StrPrintf(cmd, arrsize(cmd), "CCR.LinkPlayerHere %u", playerId);
Send_ExecConsoleCmd(cmd);
}
//============================================================================
void CsrCliLinkToPlayer (unsigned playerId) {
ASSERT(s_running);
char cmd[1024];
StrPrintf(cmd, arrsize(cmd), "CCR.LinkToPlayer %u", playerId);
Send_ExecConsoleCmd(cmd);
}

83
Sources/Plasma/NucleusLib/pnCsrCli/pnCsrCli.h

@ -1,83 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnCsrCli/pnCsrCli.h
*
***/
#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCSRCLI_PNCSRCLI_H
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCSRCLI_PNCSRCLI_H
#include "pnCsrNet/pnCsrNet.h"
/*****************************************************************************
*
* pnCsrCli
* - Connects to pfCsrSrv in remote CSR client.
* - Sends commands to pfCsrSrv for remote execution.
*
***/
typedef void (*FCsrCliOnError) (ENetError error);
void CsrCliInitialize (FCsrCliOnError onError);
void CsrCliShutdown ();
typedef void (*FCsrCliOnConnect) (ENetError result);
void CsrCliStartConnecting (
const wchar_t addr[],
FCsrCliOnConnect onConnect
);
void CsrCliDisconnect ();
void CsrCliToggleAvatarPhysical ();
void CsrCliWarpPlayerHere (unsigned playerId);
void CsrCliWarpToPlayer (unsigned playerId);
void CsrCliLinkPlayerHere (unsigned playerId);
void CsrCliLinkToPlayer (unsigned playerId);
#endif // PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCSRCLI_PNCSRCLI_H

16
Sources/Plasma/NucleusLib/pnCsrNet/CMakeLists.txt

@ -1,16 +0,0 @@
include_directories(../../CoreLib)
include_directories(../../NucleusLib)
set(pnCsrNet_SOURCES
pnCsrNet.cpp
)
set(pnCsrNet_HEADERS
Pch.h
pnCsrNet.h
)
add_library(pnCsrNet STATIC ${pnCsrNet_SOURCES} ${pnCsrNet_HEADERS})
source_group("Source Files" FILES ${pnCsrNet_SOURCES})
source_group("Header Files" FILES ${pnCsrNet_HEADERS})

54
Sources/Plasma/NucleusLib/pnCsrNet/Pch.h

@ -1,54 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnCsrNet/Pch.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCSRNET_PCH_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnCsrNet/Pch.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCSRNET_PCH_H
#include "pnCsrNet.h"

49
Sources/Plasma/NucleusLib/pnCsrNet/pnCsrNet.cpp

@ -1,49 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnCsrNet/pnCsrNet.cpp
*
***/
#include "Pch.h"
#pragma hdrstop

88
Sources/Plasma/NucleusLib/pnCsrNet/pnCsrNet.h

@ -1,88 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnCsrNet/pnCsrNet.h
*
***/
#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCSRNET_PNCSRNET_H
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCSRNET_PNCSRNET_H
#include "pnSimpleNet/pnSimpleNet.h"
/*****************************************************************************
*
* CSR Client Automation - Types and Constants
*
***/
// Newer CSR game clients must remain compatible with older CSR tools,
// therefore these values may not change. Only append to this enum.
enum {
kCsrNet_ExecConsoleCmd,
};
//============================================================================
// BEGIN PACKED DATA STRUCTURES
//============================================================================
#pragma pack(push,1)
#define CSRNET_MSG(a) \
CsrNet_##a () : SimpleNet_MsgHeader(kSimpleNetChannelCsr, kCsrNet_##a) { }
struct CsrNet_ExecConsoleCmd : SimpleNet_MsgHeader {
CSRNET_MSG (ExecConsoleCmd);
char cmd[1]; // null-terminated string
};
#undef CSRNET_MSG
//============================================================================
// END PACKED DATA STRUCTURES
//============================================================================
#pragma pack(pop)
#endif // PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCSRNET_PNCSRNET_H

14
Sources/Plasma/NucleusLib/pnNetBase/pnNbConst.h

@ -121,20 +121,6 @@ const AccountRoleInfo kAccountRoles[] = {
{ kAccountRolesAllUserFlags, "End" }
};
/*****************************************************************************
*
* Csr
*
***/
enum ECsrFlags {
kCsrFlagAdmin = 1 << 0,
kCsrFlagDisabled = 1 << 1,
kCsrFlagServer = 1 << 2,
};
/*****************************************************************************
*
* Game Score Types

4
Sources/Plasma/NucleusLib/pnNetBase/pnNbKeys.cpp

@ -46,10 +46,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
uint8_t kAuthDhNData[kNetDiffieHellmanKeyBits / 8] = {0};
uint8_t kAuthDhXData[kNetDiffieHellmanKeyBits / 8] = {0};
// CSR Server
uint8_t kCsrDhNData[kNetDiffieHellmanKeyBits / 8] = {0};
uint8_t kCsrDhXData[kNetDiffieHellmanKeyBits / 8] = {0};
// Game Server
uint8_t kGameDhNData[kNetDiffieHellmanKeyBits / 8] = {0};
uint8_t kGameDhXData[kNetDiffieHellmanKeyBits / 8] = {0};

5
Sources/Plasma/NucleusLib/pnNetBase/pnNbKeys.h

@ -51,11 +51,6 @@ static const unsigned kAuthDhGValue = 41;
extern uint8_t kAuthDhNData[kNetDiffieHellmanKeyBits / 8];
extern uint8_t kAuthDhXData[kNetDiffieHellmanKeyBits / 8];
// CSR Server
static const unsigned kCsrDhGValue = 97;
extern uint8_t kCsrDhNData[kNetDiffieHellmanKeyBits / 8];
extern uint8_t kCsrDhXData[kNetDiffieHellmanKeyBits / 8];
// Game Server
static const unsigned kGameDhGValue = 73;
extern uint8_t kGameDhNData[kNetDiffieHellmanKeyBits / 8];

12
Sources/Plasma/NucleusLib/pnNetBase/pnNbProtocol.cpp

@ -59,12 +59,12 @@ const wchar_t * NetProtocolToString (ENetProtocol protocol) {
{ kNetProtocolDebug, L"kNetProtocolDebug" },
// Client connections
{ kNetProtocolCli2Csr, L"GateKeeper Server" },
{ kNetProtocolCli2Csr, L"Csr Server" },
{ kNetProtocolCli2Auth, L"Auth Server" },
{ kNetProtocolCli2Game, L"Game Server" },
{ kNetProtocolCli2File, L"File Server" },
{ kNetProtocolCli2Unused_01, L"kNetProtocolCli2Unused_01" },
{ kNetProtocolCli2GateKeeper, L"GateKeeper Server" },
{ kNetProtocolCli2Unused_02, L"kNetProtocolCli2Unused_02" },
{ kNetProtocolCli2Auth, L"Auth Server" },
{ kNetProtocolCli2Game, L"Game Server" },
{ kNetProtocolCli2File, L"File Server" },
{ kNetProtocolCli2Unused_01, L"kNetProtocolCli2Unused_01" },
// Server connections
{ kNetProtocolSrvConn, L"kNetProtocolSrvConn" },

2
Sources/Plasma/NucleusLib/pnNetBase/pnNbProtocol.h

@ -64,7 +64,7 @@ enum ENetProtocol {
// Client connections
kNetProtocolCli2GateKeeper = 2,
kNetProtocolCli2Csr = 3,
kNetProtocolCli2Unused_02 = 3,
kNetProtocolCli2Auth = 4,
kNetProtocolCli2Game = 5,
kNetProtocolCli2File = 6,

22
Sources/Plasma/NucleusLib/pnNetBase/pnNbSrvs.cpp

@ -65,12 +65,6 @@ static const char* s_fileAddrs[] = {
};
static char s_csrAddrConsole[64] = {0};
static const char* s_csrAddrs[] = {
s_csrAddrConsole
};
static char s_gateKeeperAddrConsole[64] = {0};
static const char* s_gateKeeperAddrs[] = {
s_gateKeeperAddrConsole
@ -113,22 +107,6 @@ void SetFileSrvHostname (const char addr[]) {
strncpy(s_fileAddrConsole, addr, arrsize(s_fileAddrConsole));
}
//============================================================================
// Csr
//============================================================================
unsigned GetCsrSrvHostnames (const char*** addrs) {
*addrs = s_csrAddrs;
return arrsize(s_csrAddrs);
}
//============================================================================
void SetCsrSrvHostname (const char addr[]) {
strncpy(s_csrAddrConsole, addr, arrsize(s_csrAddrConsole));
}
//============================================================================
// GateKeeper
//============================================================================

5
Sources/Plasma/NucleusLib/pnNetBase/pnNbSrvs.h

@ -68,7 +68,7 @@ enum ESrvType {
kSrvTypeLog = 9,
kSrvTypeDll = 10,
kSrvTypeScore = 11,
kSrvTypeCsr = 12,
kSrvTypeCsr = 12, // DEAD
kSrvTypeGateKeeper = 13,
kNumSrvTypes,
@ -90,9 +90,6 @@ void SetAuthSrvHostname (const char addr[]);
unsigned GetFileSrvHostnames (const char*** addrs); // returns addrCount
void SetFileSrvHostname (const char addr[]);
unsigned GetCsrSrvHostnames (const char*** addrs); // returns addrCount
void SetCsrSrvHostname (const char addr[]);
unsigned GetGateKeeperSrvHostnames (const char*** addrs); // returns addrCount
void SetGateKeeperSrvHostname (const char addr[]);

17
Sources/Plasma/NucleusLib/pnNetProtocol/CMakeLists.txt

@ -22,11 +22,6 @@ set(pnNetProtocol_PROTO_CLI2AUTH
Private/Protocols/Cli2Auth/pnNpCli2Auth.cpp
)
set(pnNetProtocol_PROTO_CLI2CSR
Private/Protocols/Cli2Csr/pnNpCli2Csr.h
Private/Protocols/Cli2Csr/pnNpCli2Csr.cpp
)
set(pnNetProtocol_PROTO_CLI2FILE
Private/Protocols/Cli2File/pnNpCli2File.h
Private/Protocols/Cli2File/pnNpCli2File.cpp
@ -73,18 +68,16 @@ set(pnNetProtocol_PROTO_SRV2VAULT
)
add_library(pnNetProtocol STATIC ${pnNetProtocol_HEADERS} ${pnNetProtocol_PRIVATE}
${pnNetProtocol_PROTO_CLI2AUTH} ${pnNetProtocol_PROTO_CLI2CSR}
${pnNetProtocol_PROTO_CLI2FILE} ${pnNetProtocol_PROTO_CLI2GAME}
${pnNetProtocol_PROTO_CLI2GK} ${pnNetProtocol_PROTO_SRV2DB}
${pnNetProtocol_PROTO_SRV2LOG} ${pnNetProtocol_PROTO_SRV2MCP}
${pnNetProtocol_PROTO_SRV2SCORE} ${pnNetProtocol_PROTO_SRV2STATE}
${pnNetProtocol_PROTO_SRV2VAULT}
${pnNetProtocol_PROTO_CLI2AUTH} ${pnNetProtocol_PROTO_CLI2FILE}
${pnNetProtocol_PROTO_CLI2GAME} ${pnNetProtocol_PROTO_CLI2GK}
${pnNetProtocol_PROTO_SRV2DB} ${pnNetProtocol_PROTO_SRV2LOG}
${pnNetProtocol_PROTO_SRV2MCP} ${pnNetProtocol_PROTO_SRV2SCORE}
${pnNetProtocol_PROTO_SRV2STATE} ${pnNetProtocol_PROTO_SRV2VAULT}
)
source_group("Header Files" FILES ${pnNetProtocol_HEADERS})
source_group("Private" FILES ${pnNetProtocol_PRIVATE})
source_group("Private\\Cli2Auth" FILES ${pnNetProtocol_PROTO_CLI2AUTH})
source_group("Private\\Cli2Csr" FILES ${pnNetProtocol_PROTO_CLI2CSR})
source_group("Private\\Cli2File" FILES ${pnNetProtocol_PROTO_CLI2FILE})
source_group("Private\\Cli2Game" FILES ${pnNetProtocol_PROTO_CLI2GAME})
source_group("Private\\Cli2GateKeeper" FILES ${pnNetProtocol_PROTO_CLI2GK})

122
Sources/Plasma/NucleusLib/pnNetProtocol/Private/Protocols/Cli2Csr/pnNpCli2Csr.cpp

@ -1,122 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnNetProtocol/Private/Protocols/Cli2Csr/pnNpCli2Csr.cpp
*
***/
#define USES_PROTOCOL_CLI2CSR
#include "../../../Pch.h"
#pragma hdrstop
namespace Cli2Csr {
/*****************************************************************************
*
* Cli2Csr message field definitions
*
***/
static const NetMsgField kPingRequestFields[] = {
kNetMsgFieldTransId, // transId
kNetMsgFieldTimeMs, // pingTimeMs
NET_MSG_FIELD_VAR_COUNT(1, 64 * 1024), // payloadBytes
NET_MSG_FIELD_VAR_PTR(), // payload
};
static const NetMsgField kRegisterRequestFields[] = {
kNetMsgFieldTransId, // transId
};
static const NetMsgField kLoginRequestFields[] = {
kNetMsgFieldTransId, // transId
NET_MSG_FIELD_DWORD(), // clientChallenge
kNetMsgFieldAccountName, // csrName
kNetMsgFieldShaDigest, // challenge
};
/*****************************************************************************
*
* Csr2Cli message field definitions
*
***/
static const NetMsgField kPingReplyFields[] = {
kNetMsgFieldTransId, // transId
kNetMsgFieldTimeMs, // pingTimeMs
NET_MSG_FIELD_VAR_COUNT(1, 64 * 1024), // payloadBytes
NET_MSG_FIELD_VAR_PTR(), // payload
};
static const NetMsgField kRegisterReplyFields[] = {
kNetMsgFieldTransId, // transId
NET_MSG_FIELD_DWORD(), // serverChallenge
NET_MSG_FIELD_DWORD(), // latestBuildId
};
static const NetMsgField kLoginReplyFields[] = {
kNetMsgFieldTransId, // transId
kNetMsgFieldENetError, // result
kNetMsgFieldUuid, // csrId
NET_MSG_FIELD_DWORD(), // csrFlags
};
} using namespace Cli2Csr;
/*****************************************************************************
*
* Exports
*
***/
const NetMsg kNetMsg_Cli2Csr_PingRequest = NET_MSG(kCli2Csr_PingRequest, kPingRequestFields);
const NetMsg kNetMsg_Cli2Csr_RegisterRequest = NET_MSG(kCli2Csr_RegisterRequest, kRegisterRequestFields);
const NetMsg kNetMsg_Cli2Csr_LoginRequest = NET_MSG(kCli2Csr_LoginRequest, kLoginRequestFields);
const NetMsg kNetMsg_Csr2Cli_PingReply = NET_MSG(kCsr2Cli_PingReply, kPingReplyFields);
const NetMsg kNetMsg_Csr2Cli_RegisterReply = NET_MSG(kCsr2Cli_RegisterReply, kRegisterReplyFields);
const NetMsg kNetMsg_Csr2Cli_LoginReply = NET_MSG(kCsr2Cli_LoginReply, kLoginReplyFields);

178
Sources/Plasma/NucleusLib/pnNetProtocol/Private/Protocols/Cli2Csr/pnNpCli2Csr.h

@ -1,178 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnNetProtocol/Private/Protocols/Cli2Csr/pnNpCli2Csr.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNNETPROTOCOL_PRIVATE_PROTOCOLS_CLI2CSR_PNNPCLI2CSR_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnNetProtocol/Private/Protocols/Cli2Csr/pnNpCli2Csr.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNNETPROTOCOL_PRIVATE_PROTOCOLS_CLI2CSR_PNNPCLI2CSR_H
/*****************************************************************************
*
* kNetProtocolCli2Csr message ids
*
***/
// Because SrvCsr must remain backward compatible with all client builds,
// the following enum values may never change under any circumstances.
//============================================================================
// Cli2Csr
enum {
// Misc
kCli2Csr_PingRequest = 0,
// Encrypt
kCli2Csr_RegisterRequest = 1,
// Login
kCli2Csr_LoginRequest = 2,
// Patch
kCli2Csr_PatchRequest = 3,
kNumCli2CsrMessages
};
COMPILER_ASSERT_HEADER(Cli2Scr, kNumCli2CsrMessages <= (uint16_t)-1);
//============================================================================
// Csr2Cli
enum {
// Misc
kCsr2Cli_PingReply = 0,
// Encrypt
kCsr2Cli_RegisterReply = 1,
// Login
kCsr2Cli_LoginReply = 2,
// Patch
kCli2Csr_PatchReply = 3,
kNumCsr2CliMessages
};
COMPILER_ASSERT_HEADER(Cli2Scr, kNumCsr2CliMessages <= (uint16_t)-1);
/*****************************************************************************
*
* Networked structures
*
***/
#pragma pack(push,1)
//============================================================================
// Connect packet
struct Cli2Csr_ConnData {
uint32_t dataBytes;
};
struct Cli2Csr_Connect {
AsyncSocketConnectPacket hdr;
Cli2Csr_ConnData data;
};
//============================================================================
// Message header
struct Cli2Csr_MsgHeader {
uint32_t messageId;
uint32_t transId;
};
//============================================================================
// Cli --> Csr message structures
// PingRequest
extern const NetMsg kNetMsg_Cli2Csr_PingRequest;
struct Cli2Csr_PingRequest : Cli2Csr_MsgHeader {
uint32_t pingTimeMs;
uint32_t payloadBytes;
uint8_t payload[1]; // [payloadBytes]
};
// RegisterRequest
extern const NetMsg kNetMsg_Cli2Csr_RegisterRequest;
struct Cli2Csr_RegisterRequest : Cli2Csr_MsgHeader {
};
// LoginRequest
extern const NetMsg kNetMsg_Cli2Csr_LoginRequest;
struct Cli2Csr_LoginRequest : Cli2Csr_MsgHeader {
uint32_t clientChallenge;
wchar_t csrName[kMaxAccountNameLength];
ShaDigest challengeHash;
};
//============================================================================
// Csr --> Cli message structures
// PingReply
extern const NetMsg kNetMsg_Csr2Cli_PingReply;
struct Csr2Cli_PingReply : Cli2Csr_MsgHeader {
uint32_t pingTimeMs;
uint32_t payloadBytes;
uint8_t payload[1]; // [payloadBytes]
};
// RegisterReply
extern const NetMsg kNetMsg_Csr2Cli_RegisterReply;
struct Csr2Cli_RegisterReply : Cli2Csr_MsgHeader {
uint32_t serverChallenge;
uint32_t csrBuildId; // buildId of the latest csr client
};
// LoginReply
extern const NetMsg kNetMsg_Csr2Cli_LoginReply;
struct Csr2Cli_LoginReply : Cli2Csr_MsgHeader {
ENetError result;
Uuid csrId;
uint32_t csrFlags;
};
#pragma pack(pop)

4
Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpAllIncludes.h

@ -76,10 +76,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
# include "Protocols/Cli2Game/pnNpCli2Game.h"
# endif
# ifdef USES_PROTOCOL_CLI2CSR
# include "Protocols/Cli2Csr/pnNpCli2Csr.h"
# endif
# ifdef USES_PROTOCOL_CLI2GATEKEEPER
# include "Protocols/Cli2GateKeeper/pnNpCli2GateKeeper.h"
# endif

15
Sources/Plasma/NucleusLib/pnSimpleNet/CMakeLists.txt

@ -1,15 +0,0 @@
include_directories("../../CoreLib")
include_directories("../../NucleusLib")
set(pnSimpleNet_HEADERS
pnSimpleNet.h
)
set(pnSimpleNet_SOURCES
pnSimpleNet.cpp
)
add_library(pnSimpleNet STATIC ${pnSimpleNet_HEADERS} ${pnSimpleNet_SOURCES})
source_group("Header Files" FILES ${pnSimpleNet_HEADERS})
source_group("Source Files" FILES ${pnSimpleNet_SOURCES})

658
Sources/Plasma/NucleusLib/pnSimpleNet/pnSimpleNet.cpp

@ -1,658 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnSimpleNet/pnSimpleNet.cpp
*
***/
#include "pnSimpleNet.h"
#include "hsThread.h"
#include <list>
#include <map>
/*****************************************************************************
*
* Local types
*
***/
struct SimpleNetConn : AtomicRef {
AsyncSocket sock;
AsyncCancelId cancelId;
uint32_t channelId;
bool abandoned;
struct ConnectParam * connectParam;
SimpleNet_MsgHeader * oversizeMsg;
ARRAY(uint8_t) oversizeBuffer;
};
struct SimpleNetChannel : AtomicRef {
FSimpleNetOnMsg onMsg;
FSimpleNetOnError onError;
uint32_t channelId;
std::list<SimpleNetConn*> conns;
SimpleNetChannel (uint32_t channel) : channelId(channel) { }
~SimpleNetChannel () {
ASSERT(!conns.size());
}
};
struct ConnectParam {
SimpleNetChannel * channel;
FSimpleNetOnConnect callback;
void * param;
~ConnectParam () {
if (channel)
channel->DecRef();
}
};
/*****************************************************************************
*
* Local data
*
***/
static bool s_running;
static hsMutex s_critsect;
static FSimpleNetQueryAccept s_queryAccept;
static void * s_queryAcceptParam;
static std::map<uint32_t, SimpleNetChannel*> s_channels;
/*****************************************************************************
*
* Local functions
*
***/
//============================================================================
static void NotifyConnSocketConnect (SimpleNetConn * conn) {
conn->TransferRef("Connecting", "Connected");
conn->connectParam->callback(
conn->connectParam->param,
conn,
kNetSuccess
);
delete conn->connectParam;
conn->connectParam = nil;
}
//============================================================================
static void NotifyConnSocketConnectFailed (SimpleNetConn * conn) {
s_critsect.Lock();
{
std::map<uint32_t, SimpleNetChannel*>::iterator it;
if ((it = s_channels.find(conn->channelId)) != s_channels.end()) {
it->second->conns.remove(conn);
}
}
s_critsect.Unlock();
conn->connectParam->callback(
conn->connectParam->param,
nil,
kNetErrConnectFailed
);
delete conn->connectParam;
conn->connectParam = nil;
conn->DecRef("Connecting");
conn->DecRef("Lifetime");
}
//============================================================================
static void NotifyConnSocketDisconnect (SimpleNetConn * conn) {
bool abandoned;
SimpleNetChannel* channel = nil;
s_critsect.Lock();
{
abandoned = conn->abandoned;
std::map<uint32_t, SimpleNetChannel*>::iterator it;
if ((it = s_channels.find(conn->channelId)) != s_channels.end()) {
channel = it->second;
channel->IncRef();
channel->conns.remove(conn);
}
}
s_critsect.Unlock();
if (channel && !abandoned) {
channel->onError(conn, kNetErrDisconnected);
channel->DecRef();
}
conn->DecRef("Connected");
}
//============================================================================
static bool NotifyConnSocketRead (SimpleNetConn * conn, AsyncNotifySocketRead * read) {
SimpleNetChannel* channel = nil;
s_critsect.Lock();
{
std::map<uint32_t, SimpleNetChannel*>::iterator it;
if ((it = s_channels.find(conn->channelId)) != s_channels.end()) {
channel = it->second;
channel->IncRef();
}
}
s_critsect.Unlock();
if (!channel)
return false;
bool result = true;
const uint8_t * curr = read->buffer;
const uint8_t * term = curr + read->bytes;
while (curr < term) {
// Reading oversize msg?
if (conn->oversizeBuffer.Count()) {
unsigned spaceLeft = conn->oversizeMsg->messageBytes - conn->oversizeBuffer.Count();
unsigned copyBytes = min(spaceLeft, term - curr);
conn->oversizeBuffer.Add(curr, copyBytes);
curr += copyBytes;
// Wait until we have received the entire message
if (copyBytes != spaceLeft)
break;
// Dispatch oversize msg
if (!channel->onMsg(conn, conn->oversizeMsg)) {
result = false;
break;
}
conn->oversizeBuffer.SetCount(0);
continue;
}
// Wait until we receive the entire message header
if (term - curr < sizeof(SimpleNet_MsgHeader))
break;
SimpleNet_MsgHeader * msg = (SimpleNet_MsgHeader *) read->buffer;
// Sanity check message size
if (msg->messageBytes < sizeof(*msg)) {
result = false;
break;
}
// Handle oversized messages
if (msg->messageBytes > kAsyncSocketBufferSize) {
conn->oversizeBuffer.SetCount(msg->messageBytes);
conn->oversizeMsg = (SimpleNet_MsgHeader *) conn->oversizeBuffer.Ptr();
*conn->oversizeMsg = *msg;
curr += sizeof(*msg);
continue;
}
// Wait until we have received the entire message
const uint8_t * msgTerm = (const uint8_t *) curr + msg->messageBytes;
if (msgTerm > term)
break;
curr = msgTerm;
// Dispatch msg
if (!channel->onMsg(conn, msg)) {
result = false;
break;
}
}
// Return count of bytes we processed
read->bytesProcessed = curr - read->buffer;
channel->DecRef();
return result;
}
//============================================================================
static bool AsyncNotifySocketProc (
AsyncSocket sock,
EAsyncNotifySocket code,
AsyncNotifySocket * notify,
void ** userState
) {
bool result = true;
SimpleNetConn * conn;
switch (code) {
case kNotifySocketListenSuccess: {
AsyncNotifySocketListen * listen = (AsyncNotifySocketListen *) notify;
const SimpleNet_ConnData & connect = *(const SimpleNet_ConnData *) listen->buffer;
listen->bytesProcessed += sizeof(connect);
SimpleNetChannel* channel = nil;
s_critsect.Lock();
{
std::map<uint32_t, SimpleNetChannel*>::iterator it;
if ((it = s_channels.find(connect.channelId)) != s_channels.end()) {
channel = it->second;
channel->IncRef();
}
}
s_critsect.Unlock();
if (!channel)
break;
conn = NEWZERO(SimpleNetConn);
conn->channelId = channel->channelId;
conn->IncRef("Lifetime");
conn->IncRef("Connected");
conn->sock = sock;
*userState = conn;
bool accepted = s_queryAccept(
s_queryAcceptParam,
channel->channelId,
conn,
listen->remoteAddr
);
if (!accepted) {
SimpleNetDisconnect(conn);
}
else {
s_critsect.Lock();
{
channel->conns.push_back(conn);
}
s_critsect.Unlock();
}
channel->DecRef();
}
break;
case kNotifySocketConnectSuccess: {
conn = (SimpleNetConn *) notify->param;
*userState = conn;
bool abandoned;
s_critsect.Lock();
{
conn->sock = sock;
conn->cancelId = 0;
abandoned = conn->abandoned;
}
s_critsect.Unlock();
if (abandoned)
AsyncSocketDisconnect(sock, true);
else
NotifyConnSocketConnect(conn);
}
break;
case kNotifySocketConnectFailed:
conn = (SimpleNetConn *) notify->param;
NotifyConnSocketConnectFailed(conn);
break;
case kNotifySocketDisconnect:
conn = (SimpleNetConn *) *userState;
NotifyConnSocketDisconnect(conn);
break;
case kNotifySocketRead:
conn = (SimpleNetConn *) *userState;
result = NotifyConnSocketRead(conn, (AsyncNotifySocketRead *) notify);
break;
default:
break;
}
return result;
}
//============================================================================
static void Connect(const plNetAddress& addr, ConnectParam * cp) {
SimpleNetConn * conn = NEWZERO(SimpleNetConn);
conn->channelId = cp->channel->channelId;
conn->connectParam = cp;
conn->IncRef("Lifetime");
conn->IncRef("Connecting");
s_critsect.Lock();
{
cp->channel->conns.push_back(conn);
SimpleNet_Connect connect;
connect.hdr.connType = kConnTypeSimpleNet;
connect.hdr.hdrBytes = sizeof(connect.hdr);
connect.hdr.buildId = BuildId();
connect.hdr.buildType = BUILD_TYPE_LIVE;
connect.hdr.branchId = BranchId();
connect.hdr.productId = ProductId();
connect.data.channelId = cp->channel->channelId;
AsyncSocketConnect(
&conn->cancelId,
addr,
AsyncNotifySocketProc,
conn,
&connect,
sizeof(connect)
);
conn = nil;
cp = nil;
}
s_critsect.Unlock();
delete conn;
delete cp;
}
//============================================================================
static void AsyncLookupCallback (
void * param,
const char name[],
unsigned addrCount,
const plNetAddress addrs[]
) {
ConnectParam * cp = (ConnectParam *)param;
if (!addrCount) {
if (cp->callback)
cp->callback(cp->param, nil, kNetErrNameLookupFailed);
delete cp;
return;
}
Connect(addrs[0], (ConnectParam *)param);
}
/*****************************************************************************
*
* Exported functions
*
***/
//============================================================================
void SimpleNetInitialize () {
s_running = true;
AsyncSocketRegisterNotifyProc(
kConnTypeSimpleNet,
AsyncNotifySocketProc
);
}
//============================================================================
void SimpleNetShutdown () {
s_running = false;
ASSERT(!s_channels.size());
AsyncSocketUnregisterNotifyProc(
kConnTypeSimpleNet,
AsyncNotifySocketProc
);
}
//============================================================================
void SimpleNetConnIncRef (SimpleNetConn * conn) {
ASSERT(s_running);
ASSERT(conn);
conn->IncRef();
}
//============================================================================
void SimpleNetConnDecRef (SimpleNetConn * conn) {
ASSERT(s_running);
ASSERT(conn);
conn->DecRef();
}
//============================================================================
bool SimpleNetStartListening (
FSimpleNetQueryAccept queryAccept,
void * param
) {
ASSERT(s_running);
ASSERT(queryAccept);
ASSERT(!s_queryAccept);
s_queryAccept = queryAccept;
s_queryAcceptParam = param;
plNetAddress addr;
addr.SetPort(kNetDefaultSimpleNetPort);
addr.SetAnyAddr();
return (0 != AsyncSocketStartListening(addr, nil));
}
//============================================================================
void SimpleNetStopListening () {
ASSERT(s_running);
plNetAddress addr;
addr.SetPort(kNetDefaultSimpleNetPort);
addr.SetAnyAddr();
AsyncSocketStopListening(addr, nil);
s_queryAccept = nil;
s_queryAcceptParam = nil;
}
//============================================================================
void SimpleNetCreateChannel (
unsigned channelId,
FSimpleNetOnMsg onMsg,
FSimpleNetOnError onError
) {
ASSERT(s_running);
SimpleNetChannel * channel = NEWZERO(SimpleNetChannel)(channelId);
channel->IncRef();
s_critsect.Lock();
{
#ifdef HS_DEBUGGING
{
std::map<uint32_t, SimpleNetChannel*>::iterator it = s_channels.find(channelId);
ASSERT(it == s_channels.end());
}
#endif
channel->onMsg = onMsg;
channel->onError = onError;
s_channels[channelId] = channel;
channel->IncRef();
}
s_critsect.Unlock();
channel->DecRef();
}
//============================================================================
void SimpleNetDestroyChannel (unsigned channelId) {
ASSERT(s_running);
SimpleNetChannel * channel;
s_critsect.Lock();
{
std::map<uint32_t, SimpleNetChannel*>::iterator it;
if ((it = s_channels.find(channelId)) != s_channels.end()) {
channel = it->second;
while (channel->conns.size()) {
SimpleNetConn* conn = channel->conns.front();
SimpleNetDisconnect(conn);
channel->conns.pop_front();
}
s_channels.erase(it);
}
}
s_critsect.Unlock();
if (channel)
channel->DecRef();
}
//============================================================================
void SimpleNetStartConnecting (
unsigned channelId,
const char addr[],
FSimpleNetOnConnect onConnect,
void * param
) {
ASSERT(s_running);
ASSERT(onConnect);
ConnectParam * cp = new ConnectParam;
cp->callback = onConnect;
cp->param = param;
cp->channel = nil;
s_critsect.Lock();
{
std::map<uint32_t, SimpleNetChannel*>::iterator it;
if ((it = s_channels.find(channelId)) != s_channels.end()) {
cp->channel = it->second;
cp->channel->IncRef();
}
}
s_critsect.Unlock();
ASSERT(cp->channel);
// Do we need to lookup the address?
const char* name = addr;
while (unsigned ch = *name) {
++name;
if (!(isdigit(ch) || ch == L'.' || ch == L':')) {
AsyncCancelId cancelId;
AsyncAddressLookupName(
&cancelId,
AsyncLookupCallback,
addr,
kNetDefaultSimpleNetPort,
cp
);
break;
}
}
if (!name[0]) {
plNetAddress netAddr(addr, kNetDefaultSimpleNetPort);
Connect(netAddr, cp);
}
}
//============================================================================
void SimpleNetDisconnect (
SimpleNetConn * conn
) {
ASSERT(s_running);
ASSERT(conn);
s_critsect.Lock();
{
conn->abandoned = true;
if (conn->sock) {
AsyncSocketDisconnect(conn->sock, true);
conn->sock = nil;
}
else if (conn->cancelId) {
AsyncSocketConnectCancel(AsyncNotifySocketProc, conn->cancelId);
conn->cancelId = nil;
}
}
s_critsect.Unlock();
conn->DecRef("Lifetime");
}
//============================================================================
void SimpleNetSend (
SimpleNetConn * conn,
SimpleNet_MsgHeader * msg
) {
ASSERT(s_running);
ASSERT(msg);
ASSERT(msg->messageBytes != (uint32_t)-1);
ASSERT(conn);
s_critsect.Lock();
{
if (conn->sock)
AsyncSocketSend(conn->sock, msg, msg->messageBytes);
}
s_critsect.Unlock();
}

185
Sources/Plasma/NucleusLib/pnSimpleNet/pnSimpleNet.h

@ -1,185 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnSimpleNet/pnSimpleNet.h
*
***/
#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNSIMPLENET_PNSIMPLENET_H
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNSIMPLENET_PNSIMPLENET_H
#include "pnUtils/pnUtils.h"
#include "pnProduct/pnProduct.h"
#include "pnNetBase/pnNetBase.h"
#include "pnAsyncCore/pnAsyncCore.h"
#include "pnNetCommon/plNetAddress.h"
/*****************************************************************************
*
* SimpleNet:
* - TCP only, Nagle buffered only.
* - Asynchronous callbacks only.
* - Not encrypted, not compressed, no transaction support.
* - Good for trivial networked applications only. Examples include:
* - CSR client automation by CSR tools.
* - Bob and I (eap) talked about 3dsmax automating
* the client for the purpose of reloading reexported
* assets. With SimpleNet, the client could be running
* on a separate machine than Max.
*
***/
// Because newer clients must remain compatible with older servers,
// these values may never change.
enum ESimpleNetChannel {
kSimpleNetChannelNil = 0,
kSimpleNetChannelCsr = 1,
kSimpleNetChannelMax = 2,
kMaxSimpleNetChannels
};
COMPILER_ASSERT_HEADER(ESimpleNetChannel, kMaxSimpleNetChannels <= 0xff);
//============================================================================
// BEGIN PACKED DATA STRUCTURES
//============================================================================
#pragma pack(push,1)
//============================================================================
// Connect packet
struct SimpleNet_ConnData {
unsigned channelId;
};
struct SimpleNet_Connect {
AsyncSocketConnectPacket hdr;
SimpleNet_ConnData data;
};
//============================================================================
// Message header
struct SimpleNet_MsgHeader {
private:
uint32_t channelId;
public:
uint32_t messageId;
uint32_t messageBytes;
SimpleNet_MsgHeader (uint32_t channelId, uint32_t messageId)
: channelId(channelId)
, messageId(messageId)
#ifdef HS_DEBUGGING
, messageBytes((uint32_t)-1)
#endif
{ }
};
/*****************************************************************************
*
* Simple Network API
*
***/
struct SimpleNetConn;
void SimpleNetInitialize ();
void SimpleNetShutdown ();
void SimpleNetConnIncRef (SimpleNetConn * conn);
void SimpleNetConnDecRef (SimpleNetConn * conn);
typedef bool (*FSimpleNetOnMsg) ( // return false to disconnect socket
SimpleNetConn * conn,
SimpleNet_MsgHeader * msg
);
typedef void (*FSimpleNetOnError) (
SimpleNetConn * conn,
ENetError error
);
typedef void (*FSimpleNetOnConnect) (
void * param,
SimpleNetConn * conn,
ENetError result
);
typedef bool (*FSimpleNetQueryAccept) ( // return true to accept incoming connection
void * param,
unsigned channel,
SimpleNetConn * conn,
const plNetAddress& addr
);
void SimpleNetCreateChannel (
unsigned channel,
FSimpleNetOnMsg onMsg,
FSimpleNetOnError onError
);
void SimpleNetDestroyChannel (
unsigned channel
);
bool SimpleNetStartListening (
FSimpleNetQueryAccept queryAccept,
void * param
);
void SimpleNetStopListening ();
void SimpleNetStartConnecting (
unsigned channel,
const wchar_t addr[],
FSimpleNetOnConnect onConnect,
void * param
);
void SimpleNetDisconnect (
SimpleNetConn * conn
);
void SimpleNetSend (
SimpleNetConn * conn,
SimpleNet_MsgHeader * msg
);
#pragma pack(pop)
#endif // PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNSIMPLENET_PNSIMPLENET_H

2
Sources/Plasma/PubUtilLib/plNetGameLib/CMakeLists.txt

@ -9,8 +9,6 @@ set(plNetGameLib_PRIVATE
Private/plNglAuth.cpp
Private/plNglCore.h
Private/plNglCore.cpp
Private/plNglCsr.h
Private/plNglCsr.cpp
Private/plNglFile.h
Private/plNglFile.cpp
Private/plNglGame.h

34
Sources/Plasma/PubUtilLib/plNetGameLib/Intern.h

@ -118,19 +118,6 @@ bool FileQueryConnected ();
unsigned FileGetConnId ();
/*****************************************************************************
*
* Csr
*
***/
void CsrInitialize ();
void CsrDestroy (bool wait);
bool CsrQueryConnected ();
unsigned CsrGetConnId ();
/*****************************************************************************
*
* GateKeeper
@ -208,11 +195,6 @@ enum ETransType {
kDownloadRequestTrans,
kFileRcvdFileDownloadChunkTrans,
//========================================================================
// NglCsr.cpp transactions
kCsrConnectedNotifyTrans,
kCsrLoginTrans,
//========================================================================
// NglCore.cpp transactions
kReportNetErrorTrans,
@ -280,10 +262,6 @@ static const char * s_transTypes[] = {
"ManifestRequestTrans",
"DownloadRequestTrans",
"FileRcvdFileDownloadChunkTrans",
// NglCsr.cpp
"CsrConnectedNotifyTrans",
"CsrLoginTrans",
// NglCore.cpp
"ReportNetErrorTrans",
@ -300,7 +278,6 @@ static long s_perfTransCount[kNumTransTypes];
namespace Auth { struct CliAuConn; }
namespace Game { struct CliGmConn; }
namespace Csr { struct CliCsConn; }
namespace File { struct CliFileConn; }
namespace GateKeeper { struct CliGkConn; }
@ -364,17 +341,6 @@ struct NetFileTrans : NetTrans {
void ReleaseConn ();
};
struct NetCsrTrans : NetTrans {
Csr::CliCsConn * m_conn;
NetCsrTrans (ETransType transType);
~NetCsrTrans ();
bool AcquireConn ();
void ReleaseConn ();
};
struct NetGateKeeperTrans : NetTrans {
GateKeeper::CliGkConn * m_conn;

1
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAllIncludes.h

@ -58,5 +58,4 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plNglAuth.h"
#include "plNglGame.h"
#include "plNglFile.h"
#include "plNglCsr.h"
#include "plNglGateKeeper.h"

3
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglCore.cpp

@ -148,7 +148,6 @@ void NetClientInitialize () {
AuthInitialize();
GameInitialize();
FileInitialize();
CsrInitialize();
GateKeeperInitialize();
}
}
@ -165,14 +164,12 @@ void NetClientDestroy (bool wait) {
s_errorProc = nil;
GateKeeperDestroy(false);
CsrDestroy(false);
FileDestroy(false);
GameDestroy(false);
AuthDestroy(false);
NetTransDestroy(false);
if (wait) {
GateKeeperDestroy(true);
CsrDestroy(true);
FileDestroy(true);
GameDestroy(true);
AuthDestroy(true);

900
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglCsr.cpp

@ -1,900 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglCsr.cpp
*
***/
#include "../Pch.h"
#pragma hdrstop
#include "pnEncryption/plChallengeHash.h"
namespace Ngl { namespace Csr {
/*****************************************************************************
*
* Internal types
*
***/
struct ConnectParam {
FNetCliCsrConnectedCallback callback;
void * param;
};
//============================================================================
// Connection record
//============================================================================
struct CliCsConn : AtomicRef {
LINK(CliCsConn) link;
CCritSect critsect;
AsyncSocket sock;
AsyncCancelId cancelId;
NetCli * cli;
plNetAddress addr;
unsigned seq;
bool abandoned;
unsigned serverChallenge;
unsigned latestBuildId;
ConnectParam * connectParam;
// ping
AsyncTimer * pingTimer;
unsigned pingSendTimeMs;
unsigned lastHeardTimeMs;
CliCsConn ();
~CliCsConn ();
void AutoPing ();
void StopAutoPing ();
void TimerPing ();
void Send (const uintptr_t fields[], unsigned count);
};
//============================================================================
// Transaction objects
//============================================================================
struct ConnectedNotifyTrans : NetNotifyTrans {
ConnectParam * m_connectParam;
unsigned m_latestBuildId;
ConnectedNotifyTrans (ConnectParam * cp, unsigned lbi)
: NetNotifyTrans(kCsrConnectedNotifyTrans)
, m_connectParam(cp)
, m_latestBuildId(lbi)
{ }
~ConnectedNotifyTrans () {
delete m_connectParam;
}
void Post ();
};
struct LoginRequestTrans : NetCsrTrans {
wchar_t m_csrName[kMaxAccountNameLength];
ShaDigest m_namePassHash;
FNetCliCsrLoginCallback m_callback;
void * m_param;
Uuid m_csrId;
unsigned m_csrFlags;
LoginRequestTrans (
const wchar_t csrName[],
const ShaDigest & namePassHash,
FNetCliCsrLoginCallback callback,
void * param
);
bool Send ();
void Post ();
bool Recv (
const uint8_t msg[],
unsigned bytes
);
};
/*****************************************************************************
*
* Internal data
*
***/
enum {
kPerfConnCount,
kPingDisabled,
kNumPerf
};
static bool s_running;
static CCritSect s_critsect;
static LISTDECL(CliCsConn, link) s_conns;
static CliCsConn * s_active;
static long s_perf[kNumPerf];
/*****************************************************************************
*
* Internal functions
*
***/
//===========================================================================
static unsigned GetNonZeroTimeMs () {
if (unsigned ms = TimeGetMs())
return ms;
return 1;
}
//============================================================================
static CliCsConn * GetConnIncRef_CS (const char tag[]) {
if (CliCsConn * conn = s_active)
if (conn->cli) {
conn->IncRef(tag);
return conn;
}
return nil;
}
//============================================================================
static CliCsConn * GetConnIncRef (const char tag[]) {
CliCsConn * conn;
s_critsect.Enter();
{
conn = GetConnIncRef_CS(tag);
}
s_critsect.Leave();
return conn;
}
//============================================================================
static void UnlinkAndAbandonConn_CS (CliCsConn * conn) {
s_conns.Unlink(conn);
conn->abandoned = true;
if (conn->cancelId) {
AsyncSocketConnectCancel(nil, conn->cancelId);
conn->cancelId = 0;
}
else if (conn->sock) {
AsyncSocketDisconnect(conn->sock, true);
}
else {
conn->DecRef("Lifetime");
}
}
//============================================================================
static void SendRegisterRequest (CliCsConn * conn) {
const uintptr_t msg[] = {
kCli2Csr_RegisterRequest,
0
};
conn->Send(msg, arrsize(msg));
}
//============================================================================
static bool ConnEncrypt (ENetError error, void * param) {
CliCsConn * conn = (CliCsConn *) param;
if (IS_NET_SUCCESS(error)) {
s_critsect.Enter();
{
s_active = conn;
conn->AutoPing();
conn->IncRef();
}
s_critsect.Leave();
SendRegisterRequest(conn);
conn->DecRef();
}
return IS_NET_SUCCESS(error);
}
//============================================================================
static void NotifyConnSocketConnect (CliCsConn * conn) {
conn->cli = NetCliConnectAccept(
conn->sock,
kNetProtocolCli2Csr,
false,
ConnEncrypt,
0,
nil,
conn
);
}
//============================================================================
static void NotifyConnSocketConnectFailed (CliCsConn * conn) {
bool notify;
s_critsect.Enter();
{
conn->cancelId = 0;
s_conns.Unlink(conn);
notify
= s_running
&& !conn->abandoned
&& (!s_active || conn == s_active);
if (conn == s_active)
s_active = nil;
}
s_critsect.Leave();
NetTransCancelByConnId(conn->seq, kNetErrTimeout);
conn->DecRef("Connecting");
conn->DecRef("Lifetime");
if (notify)
ReportNetError(kNetProtocolCli2Csr, kNetErrConnectFailed);
}
//============================================================================
static void NotifyConnSocketDisconnect (CliCsConn * conn) {
conn->StopAutoPing();
bool notify;
s_critsect.Enter();
{
s_conns.Unlink(conn);
notify
= s_running
&& !conn->abandoned
&& (!s_active || conn == s_active);
if (conn == s_active)
s_active = nil;
}
s_critsect.Leave();
// Cancel all transactions in process on this connection.
NetTransCancelByConnId(conn->seq, kNetErrTimeout);
conn->DecRef("Connected");
conn->DecRef("Lifetime");
if (notify)
ReportNetError(kNetProtocolCli2Csr, kNetErrDisconnected);
}
//============================================================================
static bool NotifyConnSocketRead (CliCsConn * conn, AsyncNotifySocketRead * read) {
conn->lastHeardTimeMs = GetNonZeroTimeMs();
bool result = NetCliDispatch(conn->cli, read->buffer, read->bytes, conn);
read->bytesProcessed += read->bytes;
return result;
}
//============================================================================
static bool SocketNotifyCallback (
AsyncSocket sock,
EAsyncNotifySocket code,
AsyncNotifySocket * notify,
void ** userState
) {
bool result = true;
CliCsConn * conn;
switch (code) {
case kNotifySocketConnectSuccess: {
conn = (CliCsConn *) notify->param;
*userState = conn;
conn->TransferRef("Connecting", "Connected");
bool abandoned = true;
if (abandoned)
AsyncSocketDisconnect(sock, true);
else
NotifyConnSocketConnect(conn);
}
break;
case kNotifySocketConnectFailed:
conn = (CliCsConn *) notify->param;
NotifyConnSocketConnectFailed(conn);
break;
case kNotifySocketDisconnect:
conn = (CliCsConn *) *userState;
NotifyConnSocketDisconnect(conn);
break;
case kNotifySocketRead:
conn = (CliCsConn *) *userState;
result = NotifyConnSocketRead(conn, (AsyncNotifySocketRead *) notify);
break;
}
return result;
}
//============================================================================
static void Connect (
const plNetAddress& addr,
ConnectParam * cp
) {
CliCsConn * conn = NEWZERO(CliCsConn);
conn->addr = addr;
conn->seq = ConnNextSequence();
conn->lastHeardTimeMs = GetNonZeroTimeMs();
conn->connectParam = cp;
conn->IncRef("Lifetime");
conn->IncRef("Connecting");
s_critsect.Enter();
{
while (CliCsConn * conn = s_conns.Head())
UnlinkAndAbandonConn_CS(conn);
s_conns.Link(conn);
}
s_critsect.Leave();
Cli2Csr_Connect connect;
connect.hdr.connType = kConnTypeCliToCsr;
connect.hdr.hdrBytes = sizeof(connect.hdr);
connect.hdr.buildId = BuildId();
connect.hdr.buildType = BUILD_TYPE_LIVE;
connect.hdr.branchId = BranchId();
connect.hdr.productId = ProductId();
connect.data.dataBytes = sizeof(connect.data);
AsyncSocketConnect(
&conn->cancelId,
addr,
SocketNotifyCallback,
conn,
&connect,
sizeof(connect),
0,
0
);
}
//============================================================================
static void AsyncLookupCallback (
void * param,
const char name[],
unsigned addrCount,
const plNetAddress addrs[]
) {
if (!addrCount) {
ReportNetError(kNetProtocolCli2Auth, kNetErrNameLookupFailed);
return;
}
// Only connect to one server
addrCount = MIN(addrCount, 1);
for (unsigned i = 0; i < addrCount; ++i) {
Connect(addrs[i], (ConnectParam *)param);
}
}
/*****************************************************************************
*
* Message handlers
*
***/
//============================================================================
static bool Recv_PingReply (
const uint8_t msg[],
unsigned bytes,
void *
) {
const Csr2Cli_PingReply & reply = *(const Csr2Cli_PingReply *)msg;
NetTransRecv(reply.transId, msg, bytes);
return true;
}
//============================================================================
static bool Recv_RegisterReply (
const uint8_t msg[],
unsigned ,
void * param
) {
CliCsConn * conn = (CliCsConn *)param;
const Csr2Cli_RegisterReply & reply = *(const Csr2Cli_RegisterReply *)msg;
conn->serverChallenge = reply.serverChallenge;
conn->latestBuildId = reply.csrBuildId;
ConnectedNotifyTrans * trans = new ConnectedNotifyTrans(
conn->connectParam,
conn->latestBuildId
);
NetTransSend(trans);
conn->connectParam = nil;
return true;
}
//============================================================================
static bool Recv_LoginReply (
const uint8_t msg[],
unsigned bytes,
void *
) {
const Csr2Cli_LoginReply & reply = *(const Csr2Cli_LoginReply *)msg;
NetTransRecv(reply.transId, msg, bytes);
return true;
}
/*****************************************************************************
*
* Protocol
*
***/
#define MSG(s) kNetMsg_Cli2Csr_##s
static NetMsgInitSend s_send[] = {
{ MSG(PingRequest) },
{ MSG(RegisterRequest) },
{ MSG(LoginRequest) },
};
#undef MSG
#define MSG(s) kNetMsg_Csr2Cli_##s, Recv_##s
static NetMsgInitRecv s_recv[] = {
{ MSG(PingReply) },
{ MSG(RegisterReply) },
{ MSG(LoginReply) },
};
#undef MSG
/*****************************************************************************
*
* CliCsConn
*
***/
//===========================================================================
static unsigned CliCsConnTimerDestroyed (void * param) {
CliCsConn * conn = (CliCsConn *) param;
conn->DecRef("PingTimer");
return kAsyncTimeInfinite;
}
//===========================================================================
static unsigned CliCsConnPingTimerProc (void * param) {
((CliCsConn *) param)->TimerPing();
return kPingIntervalMs;
}
//============================================================================
CliCsConn::CliCsConn () {
AtomicAdd(&s_perf[kPerfConnCount], 1);
}
//============================================================================
CliCsConn::~CliCsConn () {
// Delete 'cli' after all refs have been removed
if (cli)
NetCliDelete(cli, true);
delete connectParam;
AtomicAdd(&s_perf[kPerfConnCount], -1);
}
//============================================================================
void CliCsConn::AutoPing () {
ASSERT(!pingTimer);
IncRef("PingTimer");
critsect.Enter();
{
AsyncTimerCreate(
&pingTimer,
CliCsConnPingTimerProc,
sock ? 0 : kAsyncTimeInfinite,
this
);
}
critsect.Leave();
}
//============================================================================
void CliCsConn::StopAutoPing () {
critsect.Enter();
{
if (AsyncTimer * timer = pingTimer) {
pingTimer = nil;
AsyncTimerDeleteCallback(timer, CliCsConnTimerDestroyed);
}
}
critsect.Leave();
}
//============================================================================
void CliCsConn::TimerPing () {
// Send a ping request
pingSendTimeMs = GetNonZeroTimeMs();
const uintptr_t msg[] = {
kCli2Auth_PingRequest,
0, // not a transaction
pingSendTimeMs,
0, // no payload
nil
};
Send(msg, arrsize(msg));
}
//============================================================================
void CliCsConn::Send (const uintptr_t fields[], unsigned count) {
critsect.Enter();
{
NetCliSend(cli, fields, count);
NetCliFlush(cli);
}
critsect.Leave();
}
/*****************************************************************************
*
* ConnectedNotifyTrans
*
***/
//============================================================================
void ConnectedNotifyTrans::Post () {
if (m_connectParam && m_connectParam->callback)
m_connectParam->callback(m_connectParam->param, m_latestBuildId);
}
/*****************************************************************************
*
* LoginRequestTrans
*
***/
//============================================================================
LoginRequestTrans::LoginRequestTrans (
const wchar_t csrName[],
const ShaDigest & namePassHash,
FNetCliCsrLoginCallback callback,
void * param
) : NetCsrTrans(kCsrLoginTrans)
, m_callback(callback)
, m_param(param)
{
ASSERT(callback);
memcpy(m_namePassHash, namePassHash, sizeof(ShaDigest));
StrCopy(m_csrName, csrName, arrsize(m_csrName));
}
//============================================================================
bool LoginRequestTrans::Send () {
if (!AcquireConn())
return false;
ShaDigest challengeHash;
uint32_t clientChallenge = 0;
CryptCreateRandomSeed(
sizeof(clientChallenge),
(uint8_t *) &clientChallenge
);
CryptHashPasswordChallenge(
clientChallenge,
s_active->serverChallenge,
m_namePassHash,
challengeHash
);
const uintptr_t msg[] = {
kCli2Csr_LoginRequest,
m_transId,
clientChallenge,
(uintptr_t) m_csrName,
(uintptr_t) &challengeHash
};
m_conn->Send(msg, arrsize(msg));
return true;
}
//============================================================================
void LoginRequestTrans::Post () {
m_callback(
m_result,
m_param,
m_csrId,
m_csrFlags
);
}
//============================================================================
bool LoginRequestTrans::Recv (
const uint8_t msg[],
unsigned bytes
) {
const Csr2Cli_LoginReply & reply = *(const Csr2Cli_LoginReply *) msg;
m_result = reply.result;
m_csrId = reply.csrId;
m_csrFlags = reply.csrFlags;
m_state = kTransStateComplete;
return true;
}
} using namespace Csr;
/*****************************************************************************
*
* NetCsrTrans
*
***/
//============================================================================
NetCsrTrans::NetCsrTrans (ETransType transType)
: NetTrans(kNetProtocolCli2Csr, transType)
, m_conn(nil)
{
}
//============================================================================
NetCsrTrans::~NetCsrTrans () {
ReleaseConn();
}
//============================================================================
bool NetCsrTrans::AcquireConn () {
if (!m_conn)
m_conn = GetConnIncRef("AcquireConn");
return m_conn != nil;
}
//============================================================================
void NetCsrTrans::ReleaseConn () {
if (m_conn) {
m_conn->DecRef("AcquireConn");
m_conn = nil;
}
}
/*****************************************************************************
*
* Module functions
*
***/
//============================================================================
void CsrInitialize () {
s_running = true;
NetMsgProtocolRegister(
kNetProtocolCli2Csr,
false,
s_send, arrsize(s_send),
s_recv, arrsize(s_recv),
kCsrDhGValue,
plBigNum(sizeof(kCsrDhXData), kCsrDhXData),
plBigNum(sizeof(kCsrDhNData), kCsrDhNData)
);
}
//============================================================================
void CsrDestroy (bool wait) {
s_running = false;
NetTransCancelByProtocol(
kNetProtocolCli2Csr,
kNetErrRemoteShutdown
);
NetMsgProtocolDestroy(
kNetProtocolCli2Csr,
false
);
s_critsect.Enter();
{
while (CliCsConn * conn = s_conns.Head())
UnlinkAndAbandonConn_CS(conn);
s_active = nil;
}
s_critsect.Leave();
if (!wait)
return;
while (s_perf[kPerfConnCount]) {
NetTransUpdate();
AsyncSleep(10);
}
}
//============================================================================
bool CsrQueryConnected () {
bool result;
s_critsect.Enter();
{
if (nil != (result = s_active))
result &= (nil != s_active->cli);
}
s_critsect.Leave();
return result;
}
//============================================================================
unsigned CsrGetConnId () {
unsigned connId;
s_critsect.Enter();
{
connId = (s_active) ? s_active->seq : 0;
}
s_critsect.Leave();
return connId;
}
} using namespace Ngl;
/*****************************************************************************
*
* Exports
*
***/
//============================================================================
void NetCliCsrStartConnect (
const char* addrList[],
uint32_t addrCount,
FNetCliCsrConnectedCallback callback,
void * param
) {
// Only connect to one server
addrCount = min(addrCount, 1);
for (unsigned i = 0; i < addrCount; ++i) {
// Do we need to lookup the address?
const char* name = addrList[i];
while (unsigned ch = *name) {
++name;
if (!(isdigit(ch) || ch == L'.' || ch == L':')) {
ConnectParam * cp = new ConnectParam;
cp->callback = callback;
cp->param = param;
AsyncCancelId cancelId;
AsyncAddressLookupName(
&cancelId,
AsyncLookupCallback,
addrList[i],
kNetDefaultClientPort,
cp
);
break;
}
}
if (!name[0]) {
plNetAddress addr(addrList[i], kNetDefaultClientPort);
ConnectParam * cp = new ConnectParam;
cp->callback = callback;
cp->param = param;
Connect(addr, cp);
}
}
}
//============================================================================
void NetCliCsrDisconnect () {
s_critsect.Enter();
{
while (CliCsConn * conn = s_conns.Head())
UnlinkAndAbandonConn_CS(conn);
s_active = nil;
}
s_critsect.Leave();
}
//============================================================================
void NetCliCsrLoginRequest (
const wchar_t csrName[],
const ShaDigest & namePassHash,
FNetCliCsrLoginCallback callback,
void * param
) {
LoginRequestTrans * trans = new LoginRequestTrans(
csrName,
namePassHash,
callback,
param
);
NetTransSend(trans);
}

94
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglCsr.h

@ -1,94 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglCsr.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_PRIVATE_PLNGLCSR_H
#error "Header $/Plasma20/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglCsr.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_PRIVATE_PLNGLCSR_H
/*****************************************************************************
*
* Client-side CSR functions
*
***/
typedef void (*FNetCliCsrConnectedCallback) (
void * param,
unsigned latestBuildId
);
void NetCliCsrStartConnect (
const char* addrList[],
uint32_t addrCount,
FNetCliCsrConnectedCallback callback = nil,
void * param = nil
);
void NetCliCsrDisconnect ();
typedef void (*FNetCliCsrLoginCallback)(
ENetError result,
void * param,
const Uuid & csrId,
unsigned csrFlags
);
void NetCliCsrLoginRequest (
const wchar_t csrName[],
const ShaDigest & namePassHash,
FNetCliCsrLoginCallback callback,
void * param
);
typedef void (*FNetCliCsrSetTicketFilterCallback)(
ENetError result,
void * param
);
void NetCliCsrSetTicketFilter (
const wchar_t filterSpec[],
FNetCliCsrSetTicketFilterCallback callback,
void * param
);

1
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglMisc.cpp

@ -79,7 +79,6 @@ unsigned ConnGetId (ENetProtocol protocol) {
case kNetProtocolCli2Auth: return AuthGetConnId();
case kNetProtocolCli2Game: return GameGetConnId();
case kNetProtocolCli2File: return FileGetConnId();
case kNetProtocolCli2Csr: return CsrGetConnId();
case kNetProtocolCli2GateKeeper: return GateKeeperGetConnId();
DEFAULT_FATAL(protocol);
}

1
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglTrans.cpp

@ -144,7 +144,6 @@ bool NetTrans::CanStart () const {
case kNetProtocolCli2Auth: return AuthQueryConnected();
case kNetProtocolCli2Game: return GameQueryConnected();
case kNetProtocolCli2File: return FileQueryConnected();
case kNetProtocolCli2Csr: return CsrQueryConnected();
case kNetProtocolCli2GateKeeper: return GateKeeperQueryConnected();
DEFAULT_FATAL(m_protocol);
}

3
Sources/Tools/MaxMain/CMakeLists.txt

@ -117,7 +117,6 @@ target_link_libraries(MaxMain pfCCR)
target_link_libraries(MaxMain pfCharacter)
target_link_libraries(MaxMain pfConditional)
target_link_libraries(MaxMain pfConsole)
target_link_libraries(MaxMain pfCsrSrv)
target_link_libraries(MaxMain pfGameGUIMgr)
target_link_libraries(MaxMain pfGameMgr)
target_link_libraries(MaxMain pfGameScoreMgr)
@ -175,7 +174,6 @@ target_link_libraries(MaxMain plVault)
target_link_libraries(MaxMain pnAddrInfo)
target_link_libraries(MaxMain pnAsyncCore)
target_link_libraries(MaxMain pnAsyncCoreExe)
target_link_libraries(MaxMain pnCsrNet)
target_link_libraries(MaxMain pnDispatch)
target_link_libraries(MaxMain pnEncryption)
target_link_libraries(MaxMain pnFactory)
@ -191,7 +189,6 @@ target_link_libraries(MaxMain pnNetProtocol)
target_link_libraries(MaxMain pnNucleusInc)
target_link_libraries(MaxMain pnProduct)
target_link_libraries(MaxMain pnSceneObject)
target_link_libraries(MaxMain pnSimpleNet)
target_link_libraries(MaxMain pnTimer)
target_link_libraries(MaxMain pnUtils)
target_link_libraries(MaxMain pnUtilsExe)

3
Sources/Tools/MaxPlasmaLights/CMakeLists.txt

@ -53,7 +53,6 @@ target_link_libraries(MaxPlasmaLights pfCCR)
target_link_libraries(MaxPlasmaLights pfCharacter)
target_link_libraries(MaxPlasmaLights pfConditional)
target_link_libraries(MaxPlasmaLights pfConsole)
target_link_libraries(MaxPlasmaLights pfCsrSrv)
target_link_libraries(MaxPlasmaLights pfGameGUIMgr)
target_link_libraries(MaxPlasmaLights pfGameMgr)
target_link_libraries(MaxPlasmaLights pfGameScoreMgr)
@ -108,7 +107,6 @@ target_link_libraries(MaxPlasmaLights plVault)
target_link_libraries(MaxPlasmaLights pnAddrInfo)
target_link_libraries(MaxPlasmaLights pnAsyncCore)
target_link_libraries(MaxPlasmaLights pnAsyncCoreExe)
target_link_libraries(MaxPlasmaLights pnCsrNet)
target_link_libraries(MaxPlasmaLights pnDispatch)
target_link_libraries(MaxPlasmaLights pnEncryption)
target_link_libraries(MaxPlasmaLights pnFactory)
@ -123,7 +121,6 @@ target_link_libraries(MaxPlasmaLights pnNetCommon)
target_link_libraries(MaxPlasmaLights pnNucleusInc)
target_link_libraries(MaxPlasmaLights pnProduct)
target_link_libraries(MaxPlasmaLights pnSceneObject)
target_link_libraries(MaxPlasmaLights pnSimpleNet)
target_link_libraries(MaxPlasmaLights pnTimer)
target_link_libraries(MaxPlasmaLights pnUtils)
target_link_libraries(MaxPlasmaLights pnUtilsExe)

Loading…
Cancel
Save