2
3
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-14 02:27:40 -04:00

Fix line endings and tabs

This commit is contained in:
Branan Purvine-Riley
2011-04-11 16:27:55 -07:00
parent d4250e19b5
commit 908aaeb6f6
2738 changed files with 702562 additions and 702562 deletions

View File

@ -1,33 +1,33 @@
include_directories("../../CoreLib")
include_directories("../../NucleusLib/inc")
include_directories("../../NucleusLib")
include_directories("../../PubUtilLib")
set(plNetGameLib_PRIVATE
Private/plNglAllIncludes.h
Private/plNglAuth.h
Private/plNglAuth.cpp
Private/plNglCore.h
Private/plNglCore.cpp
Private/plNglCsr.h
Private/plNglCsr.cpp
Private/plNglFile.h
Private/plNglFile.cpp
Private/plNglGame.h
Private/plNglGame.cpp
Private/plNglGateKeeper.h
Private/plNglGateKeeper.cpp
Private/plNglMisc.cpp
Private/plNglTrans.cpp
)
set(plNetGameLib_HEADERS
Intern.h
Pch.h
plNetGameLib.h
)
add_library(plNetGameLib STATIC ${plNetGameLib_PRIVATE} ${plNetGameLib_HEADERS})
source_group("Private" FILES ${plNetGameLib_PRIVATE})
source_group("Header Files" FILES ${plNetGameLib_HEADERS})
include_directories("../../CoreLib")
include_directories("../../NucleusLib/inc")
include_directories("../../NucleusLib")
include_directories("../../PubUtilLib")
set(plNetGameLib_PRIVATE
Private/plNglAllIncludes.h
Private/plNglAuth.h
Private/plNglAuth.cpp
Private/plNglCore.h
Private/plNglCore.cpp
Private/plNglCsr.h
Private/plNglCsr.cpp
Private/plNglFile.h
Private/plNglFile.cpp
Private/plNglGame.h
Private/plNglGame.cpp
Private/plNglGateKeeper.h
Private/plNglGateKeeper.cpp
Private/plNglMisc.cpp
Private/plNglTrans.cpp
)
set(plNetGameLib_HEADERS
Intern.h
Pch.h
plNetGameLib.h
)
add_library(plNetGameLib STATIC ${plNetGameLib_PRIVATE} ${plNetGameLib_HEADERS})
source_group("Private" FILES ${plNetGameLib_PRIVATE})
source_group("Header Files" FILES ${plNetGameLib_HEADERS})

View File

@ -1,407 +1,407 @@
/*==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/>.
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/Intern.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_INTERN_H
#error "Header $/Plasma20/Sources/Plasma/PubUtilLib/plNetGameLib/Intern.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_INTERN_H
namespace Ngl {
/*****************************************************************************
*
* Module constants
*
***/
const unsigned kMaxReconnectIntervalMs = 5 * 1000;
const unsigned kMaxImmediateDisconnects = 5;
const unsigned kMaxFailedConnects = 5;
const unsigned kPingIntervalMs = 30 * 1000;
const unsigned kPingTimeoutMs = kPingIntervalMs * 10;
const unsigned kDisconnectedTimeoutMs = kPingIntervalMs;
/*****************************************************************************
*
* Core
*
***/
void ReportNetError (ENetProtocol protocol, ENetError error);
/*****************************************************************************
*
* Auth
*
***/
void AuthInitialize ();
void AuthDestroy (bool wait);
bool AuthQueryConnected ();
unsigned AuthGetConnId ();
void AuthPingEnable (bool enable);
/*****************************************************************************
*
* Game
*
***/
void GameInitialize ();
void GameDestroy (bool wait);
bool GameQueryConnected ();
unsigned GameGetConnId ();
void GamePingEnable (bool enable);
/*****************************************************************************
*
* File
*
***/
void FileInitialize ();
void FileDestroy (bool wait);
bool FileQueryConnected ();
unsigned FileGetConnId ();
/*****************************************************************************
*
* Csr
*
***/
void CsrInitialize ();
void CsrDestroy (bool wait);
bool CsrQueryConnected ();
unsigned CsrGetConnId ();
/*****************************************************************************
*
* GateKeeper
*
***/
void GateKeeperInitialize();
void GateKeeperDestroy(bool wait);
bool GateKeeperQueryConnected ();
unsigned GateKeeperGetConnId();
/*****************************************************************************
*
* Transactions
*
***/
enum ETransType {
//========================================================================
// NglAuth.cpp transactions
kPingRequestTrans,
kLoginRequestTrans,
kAgeRequestTrans,
kAccountCreateRequestTrans,
kAccountCreateFromKeyRequestTrans,
kPlayerCreateRequestTrans,
kPlayerDeleteRequestTrans,
kUpgradeVisitorRequestTrans,
kSetPlayerRequestTrans,
kAccountChangePasswordRequestTrans,
kGetPublicAgeListTrans,
kAccountSetRolesRequestTrans,
kAccountSetBillingTypeRequestTrans,
kAccountActivateRequestTrans,
kFileListRequestTrans,
kFileDownloadRequestTrans,
kRcvdFileDownloadChunkTrans,
kRcvdPropagatedBufferTrans,
kVaultNodeChangedTrans,
kVaultNodeAddedTrans,
kVaultNodeRemovedTrans,
kVaultNodeDeletedTrans,
kVaultFetchNodeRefsTrans,
kVaultInitAgeTrans,
kVaultFetchNodeTrans,
kVaultFindNodeTrans,
kVaultCreateNodeTrans,
kVaultSaveNodeTrans,
kVaultAddNodeTrans,
kVaultRemoveNodeTrans,
kNotifyNewBuildTrans,
kSetPlayerBanStatusRequestTrans,
kChangePlayerNameRequestTrans,
kAuthConnectedNotifyTrans,
kScoreCreateTrans,
kScoreDeleteTrans,
kScoreGetScoresTrans,
kScoreAddPointsTrans,
kScoreTransferPointsTrans,
kScoreSetPointsTrans,
kScoreGetRanksTrans,
kSendFriendInviteTrans,
//========================================================================
// NglGame.cpp transactions
kJoinAgeRequestTrans,
kGmRcvdPropagatedBufferTrans,
kGmRcvdGameMgrMsgTrans,
//========================================================================
// NglFile.cpp transactions
kBuildIdRequestTrans,
kManifestRequestTrans,
kDownloadRequestTrans,
kFileRcvdFileDownloadChunkTrans,
//========================================================================
// NglCsr.cpp transactions
kCsrConnectedNotifyTrans,
kCsrLoginTrans,
//========================================================================
// NglCore.cpp transactions
kReportNetErrorTrans,
//========================================================================
// NglGateKeeper.cpp transactions
kGkFileSrvIpAddressRequestTrans,
kGkAuthSrvIpAddressRequestTrans,
kNumTransTypes
};
static char * s_transTypes[] = {
// NglAuth.cpp
"PingRequestTrans",
"LoginRequestTrans",
"AgeRequestTrans",
"AccountCreateRequestTrans",
"AccountCreateFromKeyRequestTrans",
"PlayerCreateRequestTrans",
"PlayerDeleteRequestTrans",
"UpgradeVisitorRequestTrans",
"SetPlayerRequestTrans",
"AccountChangePasswordRequestTrans",
"GetPublicAgeListTrans",
"AccountSetRolesRequestTrans",
"AccountSetBillingTypeRequestTrans",
"AccountActivateRequestTrans",
"FileListRequestTrans",
"FileDownloadRequestTrans",
"RcvdFileDownloadChunkTrans",
"RcvdPropagatedBufferTrans",
"VaultNodeChangedTrans",
"VaultNodeAddedTrans",
"VaultNodeRemovedTrans",
"VaultNodeDeletedTrans",
"VaultFetchNodeRefsTrans",
"VaultInitAgeTrans",
"VaultFetchNodeTrans",
"VaultFindNodeTrans",
"VaultCreateNodeTrans",
"VaultSaveNodeTrans",
"VaultAddNodeTrans",
"VaultRemoveNodeTrans",
"NotifyNewBuildTrans",
"SetPlayerBanStatusfRequestTrans",
"ChangePlayerNameRequestTrans",
"AuthConnectedNotifyTrans",
"ScoreCreateTrans",
"ScoreDeleteTrans",
"ScoreGetScoresTrans",
"ScoreAddPointsTrans",
"ScoreTransferPointsTrans",
"ScoreSetPointsTrans",
"ScoreGetRanksTrans",
"SendFriendInviteTrans",
// NglGame.cpp
"JoinAgeRequestTrans",
"GmRcvdPropagatedBufferTrans",
"GmRcvdGameMgrMsgTrans",
// NglFile.cpp
"BuildIdRequestTrans",
"ManifestRequestTrans",
"DownloadRequestTrans",
"FileRcvdFileDownloadChunkTrans",
// NglCsr.cpp
"CsrConnectedNotifyTrans",
"CsrLoginTrans",
// NglCore.cpp
"ReportNetErrorTrans",
// NglGateKeeper.cpp
"GkFileSrvIpAddress",
"GkAuthSrvIpAddress",
};
COMPILER_ASSERT(arrsize(s_transTypes) == kNumTransTypes);
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; }
enum ENetTransState {
kTransStateWaitServerConnect,
kTransStateWaitServerResponse,
kTransStateComplete,
};
struct NetTrans : AtomicRef {
LINK(NetTrans) m_link;
ENetTransState m_state;
ENetError m_result;
unsigned m_transId;
unsigned m_connId;
ENetProtocol m_protocol;
bool m_hasSubTrans; // set to specify this transaction should be completed after all others in the frame
unsigned m_timeoutAtMs; // curTime + s_timeoutMs (set upon send)
ETransType m_transType;
NetTrans (ENetProtocol protocol, ETransType transType);
virtual ~NetTrans ();
virtual bool CanStart () const;
virtual bool TimedOut () { return true; } // return true if we really did time out, false to reset the timeout timer
virtual bool Send () = 0;
virtual void Post () = 0;
virtual bool Recv ( // return false to disconnect from server
const byte msg[],
unsigned bytes
) = 0;
};
struct NetAuthTrans : NetTrans {
Auth::CliAuConn * m_conn;
NetAuthTrans (ETransType transType);
~NetAuthTrans ();
bool AcquireConn ();
void ReleaseConn ();
};
struct NetGameTrans : NetTrans {
Game::CliGmConn * m_conn;
NetGameTrans (ETransType transType);
~NetGameTrans ();
bool AcquireConn ();
void ReleaseConn ();
};
struct NetFileTrans : NetTrans {
File::CliFileConn * m_conn;
NetFileTrans (ETransType transType);
~NetFileTrans ();
bool AcquireConn ();
void ReleaseConn ();
};
struct NetCsrTrans : NetTrans {
Csr::CliCsConn * m_conn;
NetCsrTrans (ETransType transType);
~NetCsrTrans ();
bool AcquireConn ();
void ReleaseConn ();
};
struct NetGateKeeperTrans : NetTrans {
GateKeeper::CliGkConn * m_conn;
NetGateKeeperTrans (ETransType transType);
~NetGateKeeperTrans ();
bool AcquireConn ();
void ReleaseConn ();
};
struct NetNotifyTrans : NetTrans {
NetNotifyTrans (ETransType transType);
bool CanStart () const { return true; }
bool Send () { m_state = kTransStateComplete; return true; }
bool Recv (
const byte [],
unsigned
) { return true; }
};
void NetTransInitialize ();
void NetTransDestroy (bool wait);
void NetTransSetTimeoutMs (unsigned ms);
unsigned NetTransGetTimeoutMs ();
void NetTransSend (NetTrans * trans);
bool NetTransRecv (unsigned transId, const byte msg[], unsigned bytes);
void NetTransCancel (unsigned transId, ENetError error);
void NetTransCancelByProtocol (ENetProtocol protocol, ENetError error);
void NetTransCancelByConnId (unsigned connId, ENetError error);
void NetTransCancelAll (ENetError error);
void NetTransUpdate ();
/*****************************************************************************
*
* Misc
*
***/
unsigned ConnNextSequence ();
unsigned ConnGetId (ENetProtocol protocol);
} using namespace Ngl;
/*==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/>.
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/Intern.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_INTERN_H
#error "Header $/Plasma20/Sources/Plasma/PubUtilLib/plNetGameLib/Intern.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_INTERN_H
namespace Ngl {
/*****************************************************************************
*
* Module constants
*
***/
const unsigned kMaxReconnectIntervalMs = 5 * 1000;
const unsigned kMaxImmediateDisconnects = 5;
const unsigned kMaxFailedConnects = 5;
const unsigned kPingIntervalMs = 30 * 1000;
const unsigned kPingTimeoutMs = kPingIntervalMs * 10;
const unsigned kDisconnectedTimeoutMs = kPingIntervalMs;
/*****************************************************************************
*
* Core
*
***/
void ReportNetError (ENetProtocol protocol, ENetError error);
/*****************************************************************************
*
* Auth
*
***/
void AuthInitialize ();
void AuthDestroy (bool wait);
bool AuthQueryConnected ();
unsigned AuthGetConnId ();
void AuthPingEnable (bool enable);
/*****************************************************************************
*
* Game
*
***/
void GameInitialize ();
void GameDestroy (bool wait);
bool GameQueryConnected ();
unsigned GameGetConnId ();
void GamePingEnable (bool enable);
/*****************************************************************************
*
* File
*
***/
void FileInitialize ();
void FileDestroy (bool wait);
bool FileQueryConnected ();
unsigned FileGetConnId ();
/*****************************************************************************
*
* Csr
*
***/
void CsrInitialize ();
void CsrDestroy (bool wait);
bool CsrQueryConnected ();
unsigned CsrGetConnId ();
/*****************************************************************************
*
* GateKeeper
*
***/
void GateKeeperInitialize();
void GateKeeperDestroy(bool wait);
bool GateKeeperQueryConnected ();
unsigned GateKeeperGetConnId();
/*****************************************************************************
*
* Transactions
*
***/
enum ETransType {
//========================================================================
// NglAuth.cpp transactions
kPingRequestTrans,
kLoginRequestTrans,
kAgeRequestTrans,
kAccountCreateRequestTrans,
kAccountCreateFromKeyRequestTrans,
kPlayerCreateRequestTrans,
kPlayerDeleteRequestTrans,
kUpgradeVisitorRequestTrans,
kSetPlayerRequestTrans,
kAccountChangePasswordRequestTrans,
kGetPublicAgeListTrans,
kAccountSetRolesRequestTrans,
kAccountSetBillingTypeRequestTrans,
kAccountActivateRequestTrans,
kFileListRequestTrans,
kFileDownloadRequestTrans,
kRcvdFileDownloadChunkTrans,
kRcvdPropagatedBufferTrans,
kVaultNodeChangedTrans,
kVaultNodeAddedTrans,
kVaultNodeRemovedTrans,
kVaultNodeDeletedTrans,
kVaultFetchNodeRefsTrans,
kVaultInitAgeTrans,
kVaultFetchNodeTrans,
kVaultFindNodeTrans,
kVaultCreateNodeTrans,
kVaultSaveNodeTrans,
kVaultAddNodeTrans,
kVaultRemoveNodeTrans,
kNotifyNewBuildTrans,
kSetPlayerBanStatusRequestTrans,
kChangePlayerNameRequestTrans,
kAuthConnectedNotifyTrans,
kScoreCreateTrans,
kScoreDeleteTrans,
kScoreGetScoresTrans,
kScoreAddPointsTrans,
kScoreTransferPointsTrans,
kScoreSetPointsTrans,
kScoreGetRanksTrans,
kSendFriendInviteTrans,
//========================================================================
// NglGame.cpp transactions
kJoinAgeRequestTrans,
kGmRcvdPropagatedBufferTrans,
kGmRcvdGameMgrMsgTrans,
//========================================================================
// NglFile.cpp transactions
kBuildIdRequestTrans,
kManifestRequestTrans,
kDownloadRequestTrans,
kFileRcvdFileDownloadChunkTrans,
//========================================================================
// NglCsr.cpp transactions
kCsrConnectedNotifyTrans,
kCsrLoginTrans,
//========================================================================
// NglCore.cpp transactions
kReportNetErrorTrans,
//========================================================================
// NglGateKeeper.cpp transactions
kGkFileSrvIpAddressRequestTrans,
kGkAuthSrvIpAddressRequestTrans,
kNumTransTypes
};
static char * s_transTypes[] = {
// NglAuth.cpp
"PingRequestTrans",
"LoginRequestTrans",
"AgeRequestTrans",
"AccountCreateRequestTrans",
"AccountCreateFromKeyRequestTrans",
"PlayerCreateRequestTrans",
"PlayerDeleteRequestTrans",
"UpgradeVisitorRequestTrans",
"SetPlayerRequestTrans",
"AccountChangePasswordRequestTrans",
"GetPublicAgeListTrans",
"AccountSetRolesRequestTrans",
"AccountSetBillingTypeRequestTrans",
"AccountActivateRequestTrans",
"FileListRequestTrans",
"FileDownloadRequestTrans",
"RcvdFileDownloadChunkTrans",
"RcvdPropagatedBufferTrans",
"VaultNodeChangedTrans",
"VaultNodeAddedTrans",
"VaultNodeRemovedTrans",
"VaultNodeDeletedTrans",
"VaultFetchNodeRefsTrans",
"VaultInitAgeTrans",
"VaultFetchNodeTrans",
"VaultFindNodeTrans",
"VaultCreateNodeTrans",
"VaultSaveNodeTrans",
"VaultAddNodeTrans",
"VaultRemoveNodeTrans",
"NotifyNewBuildTrans",
"SetPlayerBanStatusfRequestTrans",
"ChangePlayerNameRequestTrans",
"AuthConnectedNotifyTrans",
"ScoreCreateTrans",
"ScoreDeleteTrans",
"ScoreGetScoresTrans",
"ScoreAddPointsTrans",
"ScoreTransferPointsTrans",
"ScoreSetPointsTrans",
"ScoreGetRanksTrans",
"SendFriendInviteTrans",
// NglGame.cpp
"JoinAgeRequestTrans",
"GmRcvdPropagatedBufferTrans",
"GmRcvdGameMgrMsgTrans",
// NglFile.cpp
"BuildIdRequestTrans",
"ManifestRequestTrans",
"DownloadRequestTrans",
"FileRcvdFileDownloadChunkTrans",
// NglCsr.cpp
"CsrConnectedNotifyTrans",
"CsrLoginTrans",
// NglCore.cpp
"ReportNetErrorTrans",
// NglGateKeeper.cpp
"GkFileSrvIpAddress",
"GkAuthSrvIpAddress",
};
COMPILER_ASSERT(arrsize(s_transTypes) == kNumTransTypes);
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; }
enum ENetTransState {
kTransStateWaitServerConnect,
kTransStateWaitServerResponse,
kTransStateComplete,
};
struct NetTrans : AtomicRef {
LINK(NetTrans) m_link;
ENetTransState m_state;
ENetError m_result;
unsigned m_transId;
unsigned m_connId;
ENetProtocol m_protocol;
bool m_hasSubTrans; // set to specify this transaction should be completed after all others in the frame
unsigned m_timeoutAtMs; // curTime + s_timeoutMs (set upon send)
ETransType m_transType;
NetTrans (ENetProtocol protocol, ETransType transType);
virtual ~NetTrans ();
virtual bool CanStart () const;
virtual bool TimedOut () { return true; } // return true if we really did time out, false to reset the timeout timer
virtual bool Send () = 0;
virtual void Post () = 0;
virtual bool Recv ( // return false to disconnect from server
const byte msg[],
unsigned bytes
) = 0;
};
struct NetAuthTrans : NetTrans {
Auth::CliAuConn * m_conn;
NetAuthTrans (ETransType transType);
~NetAuthTrans ();
bool AcquireConn ();
void ReleaseConn ();
};
struct NetGameTrans : NetTrans {
Game::CliGmConn * m_conn;
NetGameTrans (ETransType transType);
~NetGameTrans ();
bool AcquireConn ();
void ReleaseConn ();
};
struct NetFileTrans : NetTrans {
File::CliFileConn * m_conn;
NetFileTrans (ETransType transType);
~NetFileTrans ();
bool AcquireConn ();
void ReleaseConn ();
};
struct NetCsrTrans : NetTrans {
Csr::CliCsConn * m_conn;
NetCsrTrans (ETransType transType);
~NetCsrTrans ();
bool AcquireConn ();
void ReleaseConn ();
};
struct NetGateKeeperTrans : NetTrans {
GateKeeper::CliGkConn * m_conn;
NetGateKeeperTrans (ETransType transType);
~NetGateKeeperTrans ();
bool AcquireConn ();
void ReleaseConn ();
};
struct NetNotifyTrans : NetTrans {
NetNotifyTrans (ETransType transType);
bool CanStart () const { return true; }
bool Send () { m_state = kTransStateComplete; return true; }
bool Recv (
const byte [],
unsigned
) { return true; }
};
void NetTransInitialize ();
void NetTransDestroy (bool wait);
void NetTransSetTimeoutMs (unsigned ms);
unsigned NetTransGetTimeoutMs ();
void NetTransSend (NetTrans * trans);
bool NetTransRecv (unsigned transId, const byte msg[], unsigned bytes);
void NetTransCancel (unsigned transId, ENetError error);
void NetTransCancelByProtocol (ENetProtocol protocol, ENetError error);
void NetTransCancelByConnId (unsigned connId, ENetError error);
void NetTransCancelAll (ENetError error);
void NetTransUpdate ();
/*****************************************************************************
*
* Misc
*
***/
unsigned ConnNextSequence ();
unsigned ConnGetId (ENetProtocol protocol);
} using namespace Ngl;

View File

@ -1,53 +1,53 @@
/*==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/>.
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/Pch.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_PCH_H
#error "Header $/Plasma20/Sources/Plasma/PubUtilLib/plNetGameLib/Pch.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_PCH_H
#include "pnUtils/pnUtils.h"
#include "pnNetBase/pnNetBase.h"
#include "pnAsyncCore/pnAsyncCore.h"
#include "pnNetCli/pnNetCli.h"
#include "pnProduct/pnProduct.h"
#define USES_PROTOCOL_CLI2AUTH
#define USES_PROTOCOL_CLI2GAME
#define USES_PROTOCOL_CLI2FILE
#define USES_PROTOCOL_CLI2CSR
#define USES_PROTOCOL_CLI2GATEKEEPER
#include "pnNetProtocol/pnNetProtocol.h"
#include "Private/plNglAllIncludes.h"
#include "Intern.h"
#include <malloc.h>
/*==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/>.
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/Pch.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_PCH_H
#error "Header $/Plasma20/Sources/Plasma/PubUtilLib/plNetGameLib/Pch.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_PCH_H
#include "pnUtils/pnUtils.h"
#include "pnNetBase/pnNetBase.h"
#include "pnAsyncCore/pnAsyncCore.h"
#include "pnNetCli/pnNetCli.h"
#include "pnProduct/pnProduct.h"
#define USES_PROTOCOL_CLI2AUTH
#define USES_PROTOCOL_CLI2GAME
#define USES_PROTOCOL_CLI2FILE
#define USES_PROTOCOL_CLI2CSR
#define USES_PROTOCOL_CLI2GATEKEEPER
#include "pnNetProtocol/pnNetProtocol.h"
#include "Private/plNglAllIncludes.h"
#include "Intern.h"
#include <malloc.h>

View File

@ -1,46 +1,46 @@
/*==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/>.
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/plNglAllIncludes.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_PRIVATE_PLNGLALLINCLUDES_H
#error "Header $/Plasma20/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAllIncludes.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_PRIVATE_PLNGLALLINCLUDES_H
// libs on which we rely
#include "pnGameMgr/pnGameMgr.h"
#include "plNglCore.h"
#include "plNglAuth.h"
#include "plNglGame.h"
#include "plNglFile.h"
#include "plNglCsr.h"
#include "plNglGateKeeper.h"
/*==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/>.
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/plNglAllIncludes.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_PRIVATE_PLNGLALLINCLUDES_H
#error "Header $/Plasma20/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAllIncludes.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_PRIVATE_PLNGLALLINCLUDES_H
// libs on which we rely
#include "pnGameMgr/pnGameMgr.h"
#include "plNglCore.h"
#include "plNglAuth.h"
#include "plNglGame.h"
#include "plNglFile.h"
#include "plNglCsr.h"
#include "plNglGateKeeper.h"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,187 +1,187 @@
/*==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/>.
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/plNglCore.cpp
*
***/
#include "../Pch.h"
#pragma hdrstop
namespace Ngl {
/*****************************************************************************
*
* Private
*
***/
struct ReportNetErrorTrans : NetNotifyTrans {
ENetProtocol m_errProtocol;
ENetError m_errError;
ReportNetErrorTrans (
ENetProtocol errProtocol,
ENetError errError
);
void Post ();
};
/*****************************************************************************
*
* Private data
*
***/
static FNetClientErrorProc s_errorProc;
static long s_initCount;
/*****************************************************************************
*
* Local functions
*
***/
/*****************************************************************************
*
* Transactions
*
***/
//============================================================================
// NetNotifyTrans
//============================================================================
NetNotifyTrans::NetNotifyTrans (ETransType transType)
: NetTrans(kNetProtocolNil, transType)
{
}
//============================================================================
// ReportNetErrorTrans
//============================================================================
ReportNetErrorTrans::ReportNetErrorTrans (
ENetProtocol errProtocol,
ENetError errError
) : NetNotifyTrans(kReportNetErrorTrans)
, m_errProtocol(errProtocol)
, m_errError(errError)
{ }
//============================================================================
void ReportNetErrorTrans::Post () {
if (s_errorProc)
s_errorProc(m_errProtocol, m_errError);
}
/*****************************************************************************
*
* Module functions
*
***/
//============================================================================
void ReportNetError (ENetProtocol protocol, ENetError error) {
ReportNetErrorTrans * trans = NEW(ReportNetErrorTrans)(protocol, error);
NetTransSend(trans);
}
} using namespace Ngl;
/*****************************************************************************
*
* Exports
*
***/
//============================================================================
void NetClientInitialize () {
if (0 == AtomicAdd(&s_initCount, 1)) {
NetTransInitialize();
AuthInitialize();
GameInitialize();
FileInitialize();
CsrInitialize();
GateKeeperInitialize();
}
}
//============================================================================
void NetClientCancelAllTrans () {
NetTransCancelAll(kNetErrTimeout);
}
//============================================================================
void NetClientDestroy (bool wait) {
if (1 == AtomicAdd(&s_initCount, -1)) {
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);
NetTransDestroy(true);
}
}
}
//============================================================================
void NetClientUpdate () {
NetTransUpdate();
}
//============================================================================
void NetClientSetTransTimeoutMs (unsigned ms) {
NetTransSetTimeoutMs(ms);
}
//============================================================================
void NetClientPingEnable (bool enable) {
AuthPingEnable(enable);
GamePingEnable(enable);
}
//============================================================================
void NetClientSetErrorHandler (FNetClientErrorProc errorProc) {
s_errorProc = errorProc;
}
/*==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/>.
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/plNglCore.cpp
*
***/
#include "../Pch.h"
#pragma hdrstop
namespace Ngl {
/*****************************************************************************
*
* Private
*
***/
struct ReportNetErrorTrans : NetNotifyTrans {
ENetProtocol m_errProtocol;
ENetError m_errError;
ReportNetErrorTrans (
ENetProtocol errProtocol,
ENetError errError
);
void Post ();
};
/*****************************************************************************
*
* Private data
*
***/
static FNetClientErrorProc s_errorProc;
static long s_initCount;
/*****************************************************************************
*
* Local functions
*
***/
/*****************************************************************************
*
* Transactions
*
***/
//============================================================================
// NetNotifyTrans
//============================================================================
NetNotifyTrans::NetNotifyTrans (ETransType transType)
: NetTrans(kNetProtocolNil, transType)
{
}
//============================================================================
// ReportNetErrorTrans
//============================================================================
ReportNetErrorTrans::ReportNetErrorTrans (
ENetProtocol errProtocol,
ENetError errError
) : NetNotifyTrans(kReportNetErrorTrans)
, m_errProtocol(errProtocol)
, m_errError(errError)
{ }
//============================================================================
void ReportNetErrorTrans::Post () {
if (s_errorProc)
s_errorProc(m_errProtocol, m_errError);
}
/*****************************************************************************
*
* Module functions
*
***/
//============================================================================
void ReportNetError (ENetProtocol protocol, ENetError error) {
ReportNetErrorTrans * trans = NEW(ReportNetErrorTrans)(protocol, error);
NetTransSend(trans);
}
} using namespace Ngl;
/*****************************************************************************
*
* Exports
*
***/
//============================================================================
void NetClientInitialize () {
if (0 == AtomicAdd(&s_initCount, 1)) {
NetTransInitialize();
AuthInitialize();
GameInitialize();
FileInitialize();
CsrInitialize();
GateKeeperInitialize();
}
}
//============================================================================
void NetClientCancelAllTrans () {
NetTransCancelAll(kNetErrTimeout);
}
//============================================================================
void NetClientDestroy (bool wait) {
if (1 == AtomicAdd(&s_initCount, -1)) {
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);
NetTransDestroy(true);
}
}
}
//============================================================================
void NetClientUpdate () {
NetTransUpdate();
}
//============================================================================
void NetClientSetTransTimeoutMs (unsigned ms) {
NetTransSetTimeoutMs(ms);
}
//============================================================================
void NetClientPingEnable (bool enable) {
AuthPingEnable(enable);
GamePingEnable(enable);
}
//============================================================================
void NetClientSetErrorHandler (FNetClientErrorProc errorProc) {
s_errorProc = errorProc;
}

View File

@ -1,58 +1,58 @@
/*==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/>.
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/plNglCore.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_PRIVATE_PLNGLCORE_H
#error "Header $/Plasma20/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglCore.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_PRIVATE_PLNGLCORE_H
/*****************************************************************************
*
* Core functions
*
***/
void NetClientInitialize ();
// void NetClientCancelAllTrans ();
void NetClientDestroy (bool wait = true);
void NetClientUpdate ();
void NetClientSetTransTimeoutMs (unsigned ms);
void NetClientPingEnable (bool enable);
typedef void (*FNetClientErrorProc)(
ENetProtocol protocol,
ENetError error
);
void NetClientSetErrorHandler (FNetClientErrorProc errorProc);
/*==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/>.
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/plNglCore.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_PRIVATE_PLNGLCORE_H
#error "Header $/Plasma20/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglCore.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_PRIVATE_PLNGLCORE_H
/*****************************************************************************
*
* Core functions
*
***/
void NetClientInitialize ();
// void NetClientCancelAllTrans ();
void NetClientDestroy (bool wait = true);
void NetClientUpdate ();
void NetClientSetTransTimeoutMs (unsigned ms);
void NetClientPingEnable (bool enable);
typedef void (*FNetClientErrorProc)(
ENetProtocol protocol,
ENetError error
);
void NetClientSetErrorHandler (FNetClientErrorProc errorProc);

File diff suppressed because it is too large Load Diff

View File

@ -1,78 +1,78 @@
/*==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/>.
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 wchar * addrList[],
unsigned 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 csrName[],
const ShaDigest & namePassHash,
FNetCliCsrLoginCallback callback,
void * param
);
typedef void (*FNetCliCsrSetTicketFilterCallback)(
ENetError result,
void * param
);
void NetCliCsrSetTicketFilter (
const wchar filterSpec[],
FNetCliCsrSetTicketFilterCallback callback,
void * param
);
/*==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/>.
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 wchar * addrList[],
unsigned 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 csrName[],
const ShaDigest & namePassHash,
FNetCliCsrLoginCallback callback,
void * param
);
typedef void (*FNetCliCsrSetTicketFilterCallback)(
ENetError result,
void * param
);
void NetCliCsrSetTicketFilter (
const wchar filterSpec[],
FNetCliCsrSetTicketFilterCallback callback,
void * param
);

File diff suppressed because it is too large Load Diff

View File

@ -1,121 +1,121 @@
/*==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/>.
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/plNglFile.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_PRIVATE_PLNGLFILE_H
#error "Header $/Plasma20/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_PRIVATE_PLNGLFILE_H
/*****************************************************************************
*
* Client file functions
*
***/
//============================================================================
// Connect
//============================================================================
void NetCliFileStartConnect (
const wchar * fileAddrList[],
unsigned fileAddrCount,
bool isPatcher = false
);
void NetCliFileStartConnectAsServer (
const wchar * fileAddrList[],
unsigned fileAddrCount,
unsigned serverType,
unsigned serverBuildId
);
//============================================================================
// Disconnect
//============================================================================
void NetCliFileDisconnect ();
//============================================================================
// File server related messages
//============================================================================
typedef void (*FNetCliFileBuildIdRequestCallback)(
ENetError result,
void * param,
unsigned buildId
);
void NetCliFileBuildIdRequest (
FNetCliFileBuildIdRequestCallback callback,
void * param
);
typedef void (*FNetCliFileBuildIdUpdateCallback)(unsigned buildId);
void NetCliFileRegisterBuildIdUpdate (FNetCliFileBuildIdUpdateCallback callback);
//============================================================================
// Manifest
//============================================================================
struct NetCliFileManifestEntry {
wchar clientName[MAX_PATH]; // path and file on client side (for comparison)
wchar downloadName[MAX_PATH]; // path and file on server side (for download)
wchar md5[MAX_PATH];
wchar md5compressed[MAX_PATH]; // md5 for the compressed file
unsigned fileSize;
unsigned zipSize;
unsigned flags;
};
typedef void (*FNetCliFileManifestRequestCallback)(
ENetError result,
void * param,
const wchar group[],
const NetCliFileManifestEntry manifest[],
unsigned entryCount
);
void NetCliFileManifestRequest (
FNetCliFileManifestRequestCallback callback,
void * param,
const wchar group[], // the group of files you want (empty or nil = all)
unsigned buildId = 0 // 0 = get latest, other = get particular build (servers only)
);
//============================================================================
// File Download
//============================================================================
typedef void (*FNetCliFileDownloadRequestCallback)(
ENetError result,
void * param,
const wchar filename[],
hsStream * writer
);
void NetCliFileDownloadRequest (
const wchar filename[],
hsStream * writer,
FNetCliFileDownloadRequestCallback callback,
void * param,
unsigned buildId = 0 // 0 = get latest, other = get particular build (servers only)
);
/*==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/>.
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/plNglFile.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_PRIVATE_PLNGLFILE_H
#error "Header $/Plasma20/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_PRIVATE_PLNGLFILE_H
/*****************************************************************************
*
* Client file functions
*
***/
//============================================================================
// Connect
//============================================================================
void NetCliFileStartConnect (
const wchar * fileAddrList[],
unsigned fileAddrCount,
bool isPatcher = false
);
void NetCliFileStartConnectAsServer (
const wchar * fileAddrList[],
unsigned fileAddrCount,
unsigned serverType,
unsigned serverBuildId
);
//============================================================================
// Disconnect
//============================================================================
void NetCliFileDisconnect ();
//============================================================================
// File server related messages
//============================================================================
typedef void (*FNetCliFileBuildIdRequestCallback)(
ENetError result,
void * param,
unsigned buildId
);
void NetCliFileBuildIdRequest (
FNetCliFileBuildIdRequestCallback callback,
void * param
);
typedef void (*FNetCliFileBuildIdUpdateCallback)(unsigned buildId);
void NetCliFileRegisterBuildIdUpdate (FNetCliFileBuildIdUpdateCallback callback);
//============================================================================
// Manifest
//============================================================================
struct NetCliFileManifestEntry {
wchar clientName[MAX_PATH]; // path and file on client side (for comparison)
wchar downloadName[MAX_PATH]; // path and file on server side (for download)
wchar md5[MAX_PATH];
wchar md5compressed[MAX_PATH]; // md5 for the compressed file
unsigned fileSize;
unsigned zipSize;
unsigned flags;
};
typedef void (*FNetCliFileManifestRequestCallback)(
ENetError result,
void * param,
const wchar group[],
const NetCliFileManifestEntry manifest[],
unsigned entryCount
);
void NetCliFileManifestRequest (
FNetCliFileManifestRequestCallback callback,
void * param,
const wchar group[], // the group of files you want (empty or nil = all)
unsigned buildId = 0 // 0 = get latest, other = get particular build (servers only)
);
//============================================================================
// File Download
//============================================================================
typedef void (*FNetCliFileDownloadRequestCallback)(
ENetError result,
void * param,
const wchar filename[],
hsStream * writer
);
void NetCliFileDownloadRequest (
const wchar filename[],
hsStream * writer,
FNetCliFileDownloadRequestCallback callback,
void * param,
unsigned buildId = 0 // 0 = get latest, other = get particular build (servers only)
);

File diff suppressed because it is too large Load Diff

View File

@ -1,94 +1,94 @@
/*==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/>.
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/plNglGame.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_PRIVATE_PLNGLGAME_H
#error "Header $/Plasma20/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_PRIVATE_PLNGLGAME_H
/*****************************************************************************
*
* Client-side Game functions
*
***/
//============================================================================
// Connect
//============================================================================
void NetCliGameStartConnect (
const NetAddressNode & node
);
//============================================================================
// Disconnect
//============================================================================
void NetCliGameDisconnect ();
//============================================================================
// Join Age
//============================================================================
typedef void (*FNetCliGameJoinAgeRequestCallback)(
ENetError result,
void * param
);
void NetCliGameJoinAgeRequest (
unsigned ageMcpId,
const Uuid & accountUuid,
unsigned playerInt,
FNetCliGameJoinAgeRequestCallback callback,
void * param
);
//============================================================================
// Propagate app-specific data
//============================================================================
typedef void (*FNetCliGameRecvBufferHandler)(
unsigned type,
unsigned bytes,
const byte buffer[]
);
void NetCliGameSetRecvBufferHandler (
FNetCliGameRecvBufferHandler handler
);
void NetCliGamePropagateBuffer (
unsigned type,
unsigned bytes,
const byte buffer[]
);
//============================================================================
// GameMgrMsg
//============================================================================
struct GameMsgHeader;
typedef void (*FNetCliGameRecvGameMgrMsgHandler)(GameMsgHeader * msg);
void NetCliGameSetRecvGameMgrMsgHandler (FNetCliGameRecvGameMgrMsgHandler handler);
void NetCliGameSendGameMgrMsg (GameMsgHeader * msg);
/*==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/>.
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/plNglGame.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_PRIVATE_PLNGLGAME_H
#error "Header $/Plasma20/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_PRIVATE_PLNGLGAME_H
/*****************************************************************************
*
* Client-side Game functions
*
***/
//============================================================================
// Connect
//============================================================================
void NetCliGameStartConnect (
const NetAddressNode & node
);
//============================================================================
// Disconnect
//============================================================================
void NetCliGameDisconnect ();
//============================================================================
// Join Age
//============================================================================
typedef void (*FNetCliGameJoinAgeRequestCallback)(
ENetError result,
void * param
);
void NetCliGameJoinAgeRequest (
unsigned ageMcpId,
const Uuid & accountUuid,
unsigned playerInt,
FNetCliGameJoinAgeRequestCallback callback,
void * param
);
//============================================================================
// Propagate app-specific data
//============================================================================
typedef void (*FNetCliGameRecvBufferHandler)(
unsigned type,
unsigned bytes,
const byte buffer[]
);
void NetCliGameSetRecvBufferHandler (
FNetCliGameRecvBufferHandler handler
);
void NetCliGamePropagateBuffer (
unsigned type,
unsigned bytes,
const byte buffer[]
);
//============================================================================
// GameMgrMsg
//============================================================================
struct GameMsgHeader;
typedef void (*FNetCliGameRecvGameMgrMsgHandler)(GameMsgHeader * msg);
void NetCliGameSetRecvGameMgrMsgHandler (FNetCliGameRecvGameMgrMsgHandler handler);
void NetCliGameSendGameMgrMsg (GameMsgHeader * msg);

View File

@ -1,121 +1,121 @@
/*==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/>.
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/plNglGateKeeper.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_PRIVATE_PLNGLGATEKEEPER_H
#error "Header $/Plasma20/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_PRIVATE_PLNGLGATEKEEPER_H
/*****************************************************************************
*
* Client gatekeeper functions
*
***/
//============================================================================
// Connect
//============================================================================
void NetCliGateKeeperStartConnect (
const wchar * gateKeeperAddrList[],
unsigned gateKeeperAddrCount
);
bool NetCliGateKeeperQueryConnected ();
void NetCliGateKeeperAutoReconnectEnable (bool enable); // is enabled by default
// Called after the gatekeeper/client connection is encrypted
typedef void (*FNetCliGateKeeperConnectCallback)();
void NetCliGateKeeperSetConnectCallback (
FNetCliGateKeeperConnectCallback callback
);
//============================================================================
// Disconnect
//============================================================================
void NetCliGateKeeperDisconnect ();
void NetCliGateKeeperUnexpectedDisconnect ();
//============================================================================
// Ping
//============================================================================
typedef void (*FNetCliGateKeeperPingRequestCallback)(
ENetError result,
void * param,
unsigned pingAtMs,
unsigned replyAtMs,
unsigned payloadbytes,
const byte payload[]
);
void NetCliGateKeeperPingRequest (
unsigned pingTimeMs,
unsigned payloadBytes, // max 64k (pnNetCli enforced upon send)
const void * payload,
FNetCliGateKeeperPingRequestCallback callback,
void * param
);
//============================================================================
// FileSrvIpAddress
//============================================================================
typedef void (*FNetCliGateKeeperFileSrvIpAddressRequestCallback)(
ENetError result,
void * param,
const wchar addr[]
);
void NetCliGateKeeperFileSrvIpAddressRequest (
FNetCliGateKeeperFileSrvIpAddressRequestCallback callback,
void * param,
bool isPatcher
);
//============================================================================
// AuthSrvIpAddress
//============================================================================
typedef void (*FNetCliGateKeeperAuthSrvIpAddressRequestCallback)(
ENetError result,
void * param,
const wchar addr[]
);
void NetCliGateKeeperAuthSrvIpAddressRequest (
FNetCliGateKeeperAuthSrvIpAddressRequestCallback callback,
void * param
);
/*==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/>.
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/plNglGateKeeper.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_PRIVATE_PLNGLGATEKEEPER_H
#error "Header $/Plasma20/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_PRIVATE_PLNGLGATEKEEPER_H
/*****************************************************************************
*
* Client gatekeeper functions
*
***/
//============================================================================
// Connect
//============================================================================
void NetCliGateKeeperStartConnect (
const wchar * gateKeeperAddrList[],
unsigned gateKeeperAddrCount
);
bool NetCliGateKeeperQueryConnected ();
void NetCliGateKeeperAutoReconnectEnable (bool enable); // is enabled by default
// Called after the gatekeeper/client connection is encrypted
typedef void (*FNetCliGateKeeperConnectCallback)();
void NetCliGateKeeperSetConnectCallback (
FNetCliGateKeeperConnectCallback callback
);
//============================================================================
// Disconnect
//============================================================================
void NetCliGateKeeperDisconnect ();
void NetCliGateKeeperUnexpectedDisconnect ();
//============================================================================
// Ping
//============================================================================
typedef void (*FNetCliGateKeeperPingRequestCallback)(
ENetError result,
void * param,
unsigned pingAtMs,
unsigned replyAtMs,
unsigned payloadbytes,
const byte payload[]
);
void NetCliGateKeeperPingRequest (
unsigned pingTimeMs,
unsigned payloadBytes, // max 64k (pnNetCli enforced upon send)
const void * payload,
FNetCliGateKeeperPingRequestCallback callback,
void * param
);
//============================================================================
// FileSrvIpAddress
//============================================================================
typedef void (*FNetCliGateKeeperFileSrvIpAddressRequestCallback)(
ENetError result,
void * param,
const wchar addr[]
);
void NetCliGateKeeperFileSrvIpAddressRequest (
FNetCliGateKeeperFileSrvIpAddressRequestCallback callback,
void * param,
bool isPatcher
);
//============================================================================
// AuthSrvIpAddress
//============================================================================
typedef void (*FNetCliGateKeeperAuthSrvIpAddressRequestCallback)(
ENetError result,
void * param,
const wchar addr[]
);
void NetCliGateKeeperAuthSrvIpAddressRequest (
FNetCliGateKeeperAuthSrvIpAddressRequestCallback callback,
void * param
);

View File

@ -1,73 +1,73 @@
/*==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/>.
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/plNglMisc.cpp
*
***/
#include "../Pch.h"
#pragma hdrstop
namespace Ngl {
/*****************************************************************************
*
* Private data
*
***/
static unsigned s_connSequence;
/*****************************************************************************
*
* Module functions
*
***/
//============================================================================
unsigned ConnNextSequence () {
if (!++s_connSequence)
++s_connSequence;
return s_connSequence;
}
//============================================================================
unsigned ConnGetId (ENetProtocol protocol) {
switch (protocol) {
case kNetProtocolCli2Auth: return AuthGetConnId();
case kNetProtocolCli2Game: return GameGetConnId();
case kNetProtocolCli2File: return FileGetConnId();
case kNetProtocolCli2Csr: return CsrGetConnId();
case kNetProtocolCli2GateKeeper: return GateKeeperGetConnId();
DEFAULT_FATAL(protocol);
}
}
} // namespace Ngl
/*==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/>.
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/plNglMisc.cpp
*
***/
#include "../Pch.h"
#pragma hdrstop
namespace Ngl {
/*****************************************************************************
*
* Private data
*
***/
static unsigned s_connSequence;
/*****************************************************************************
*
* Module functions
*
***/
//============================================================================
unsigned ConnNextSequence () {
if (!++s_connSequence)
++s_connSequence;
return s_connSequence;
}
//============================================================================
unsigned ConnGetId (ENetProtocol protocol) {
switch (protocol) {
case kNetProtocolCli2Auth: return AuthGetConnId();
case kNetProtocolCli2Game: return GameGetConnId();
case kNetProtocolCli2File: return FileGetConnId();
case kNetProtocolCli2Csr: return CsrGetConnId();
case kNetProtocolCli2GateKeeper: return GateKeeperGetConnId();
DEFAULT_FATAL(protocol);
}
}
} // namespace Ngl

View File

@ -1,343 +1,343 @@
/*==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/>.
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/plNglTrans.cpp
*
***/
#include "../Pch.h"
#pragma hdrstop
namespace Ngl {
/*****************************************************************************
*
* Private
*
***/
enum {
kPerfCurrTransactions,
kNumPerf
};
static const unsigned kDefaultTimeoutMs = 5 * 60 * 1000;
static bool s_running;
static CCritSect s_critsect;
static LISTDECL(NetTrans, m_link) s_transactions;
static long s_perf[kNumPerf];
static unsigned s_timeoutMs = kDefaultTimeoutMs;
/*****************************************************************************
*
* Internal functions
*
***/
//============================================================================
static NetTrans * FindTransIncRef_CS (unsigned transId, const char tag[]) {
// There shouldn't be more than a few transactions; just do a linear scan
for (NetTrans * trans = s_transactions.Head(); trans; trans = s_transactions.Next(trans))
if (trans->m_transId == transId) {
trans->IncRef(tag);
return trans;
}
return nil;
}
//============================================================================
static NetTrans * FindTransIncRef (unsigned transId, const char tag[]) {
NetTrans * trans;
s_critsect.Enter();
{
trans = FindTransIncRef_CS(transId, tag);
}
s_critsect.Leave();
return trans;
}
//============================================================================
static void CancelTrans_CS (NetTrans * trans, ENetError error) {
ASSERT(IS_NET_ERROR(error));
if (trans->m_state != kTransStateComplete) {
trans->m_result = error;
trans->m_state = kTransStateComplete;
}
}
/*****************************************************************************
*
* NetTrans implementation
*
***/
//============================================================================
NetTrans::NetTrans (ENetProtocol protocol, ETransType transType)
: m_state(kTransStateWaitServerConnect)
, m_result(kNetPending)
, m_transId(0)
, m_connId(0)
, m_protocol(protocol)
, m_hasSubTrans(false)
, m_transType(transType)
{
AtomicAdd(&s_perf[kPerfCurrTransactions], 1);
AtomicAdd(&s_perfTransCount[m_transType], 1);
// DebugMsg("%s@%p created", s_transTypes[m_transType], this);
}
//============================================================================
NetTrans::~NetTrans () {
ASSERT(!m_link.IsLinked());
AtomicAdd(&s_perfTransCount[m_transType], -1);
AtomicAdd(&s_perf[kPerfCurrTransactions], -1);
// DebugMsg("%s@%p destroyed", s_transTypes[m_transType], this);
}
//============================================================================
bool NetTrans::CanStart () const {
switch (m_protocol) {
case kNetProtocolCli2Auth: return AuthQueryConnected();
case kNetProtocolCli2Game: return GameQueryConnected();
case kNetProtocolCli2File: return FileQueryConnected();
case kNetProtocolCli2Csr: return CsrQueryConnected();
case kNetProtocolCli2GateKeeper: return GateKeeperQueryConnected();
DEFAULT_FATAL(m_protocol);
}
}
/*****************************************************************************
*
* Module functions
*
***/
//============================================================================
void NetTransInitialize () {
s_critsect.Enter();
{
s_running = true;
}
s_critsect.Leave();
}
//============================================================================
void NetTransDestroy (bool wait) {
s_critsect.Enter();
{
s_running = false;
}
s_critsect.Leave();
NetTransCancelAll(kNetErrRemoteShutdown);
if (!wait)
return;
while (s_perf[kPerfCurrTransactions]) {
NetTransUpdate();
AsyncSleep(10);
}
}
//============================================================================
void NetTransSetTimeoutMs (unsigned ms) {
s_timeoutMs = ms ? ms : kDefaultTimeoutMs;
}
//============================================================================
unsigned NetTransGetTimeoutMs () {
return s_timeoutMs;
}
//============================================================================
void NetTransSend (NetTrans * trans) {
trans->IncRef("Lifetime");
s_critsect.Enter();
{
static unsigned s_transId;
while (!trans->m_transId)
trans->m_transId = ++s_transId;
s_transactions.Link(trans, kListTail);
if (!s_running)
CancelTrans_CS(trans, kNetErrRemoteShutdown);
}
s_critsect.Leave();
}
//============================================================================
bool NetTransRecv (unsigned transId, const byte msg[], unsigned bytes) {
NetTrans * trans = FindTransIncRef(transId, "Recv");
if (!trans)
return true; // transaction was canceled.
// Update the timeout time
trans->m_timeoutAtMs = TimeGetMs() + s_timeoutMs;
bool result = trans->Recv(msg, bytes);
if (!result)
NetTransCancel(transId, kNetErrInternalError);
trans->DecRef("Recv");
return result;
}
//============================================================================
void NetTransCancel (unsigned transId, ENetError error) {
s_critsect.Enter();
{
NetTrans * trans = s_transactions.Head();
for (; trans; trans = trans->m_link.Next()) {
if (trans->m_transId == transId) {
CancelTrans_CS(trans, error);
break;
}
}
}
s_critsect.Leave();
}
//============================================================================
void NetTransCancelByProtocol (ENetProtocol protocol, ENetError error) {
s_critsect.Enter();
{
NetTrans * trans = s_transactions.Head();
for (; trans; trans = trans->m_link.Next()) {
if (trans->m_protocol == protocol)
CancelTrans_CS(trans, error);
}
}
s_critsect.Leave();
}
//============================================================================
void NetTransCancelByConnId (unsigned connId, ENetError error) {
s_critsect.Enter();
{
NetTrans * trans = s_transactions.Head();
for (; trans; trans = trans->m_link.Next()) {
if (trans->m_connId == connId)
CancelTrans_CS(trans, error);
}
}
s_critsect.Leave();
}
//============================================================================
void NetTransCancelAll (ENetError error) {
s_critsect.Enter();
{
NetTrans * trans = s_transactions.Head();
for (; trans; trans = trans->m_link.Next())
CancelTrans_CS(trans, error);
}
s_critsect.Leave();
}
//============================================================================
void NetTransUpdate () {
LISTDECL(NetTrans, m_link) completed;
LISTDECL(NetTrans, m_link) parentCompleted;
s_critsect.Enter();
NetTrans * next, * trans = s_transactions.Head();
for (; trans; trans = next) {
next = s_transactions.Next(trans);
bool done = false;
while (!done) {
switch (trans->m_state) {
case kTransStateComplete:
if (trans->m_hasSubTrans)
parentCompleted.Link(trans);
else
completed.Link(trans);
done = true;
break;
case kTransStateWaitServerConnect:
if (!trans->CanStart()) {
done = true;
break;
}
if (trans->m_protocol && 0 == (trans->m_connId = ConnGetId(trans->m_protocol))) {
done = true;
break;
}
// This is the default "next state", trans->Send() can override this
trans->m_state = kTransStateWaitServerResponse;
// Set timeout time before calling Send(), allowing Send() to change it if it wants to.
trans->m_timeoutAtMs = TimeGetMs() + s_timeoutMs;
if (!trans->Send()) {
// Revert back to current state so that we'll attempt to send again
trans->m_state = kTransStateWaitServerConnect;
done = true;
break;
}
break;
case kTransStateWaitServerResponse:
// Check for timeout
if ((int)(TimeGetMs() - trans->m_timeoutAtMs) > 0) {
// Check to see if the transaction wants to "abort" the timeout
if (trans->TimedOut())
CancelTrans_CS(trans, kNetErrTimeout);
else
trans->m_timeoutAtMs = TimeGetMs() + s_timeoutMs; // Reset the timeout counter
}
done = true;
break;
DEFAULT_FATAL(trans->m_state);
}
}
}
s_critsect.Leave();
// Post completed transactions
while (NetTrans * trans = completed.Head()) {
completed.Unlink(trans);
trans->Post();
trans->DecRef("Lifetime");
}
// Post completed parent transactions
while (NetTrans * trans = parentCompleted.Head()) {
parentCompleted.Unlink(trans);
trans->Post();
trans->DecRef("Lifetime");
}
}
} // namespace Ngl
/*==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/>.
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/plNglTrans.cpp
*
***/
#include "../Pch.h"
#pragma hdrstop
namespace Ngl {
/*****************************************************************************
*
* Private
*
***/
enum {
kPerfCurrTransactions,
kNumPerf
};
static const unsigned kDefaultTimeoutMs = 5 * 60 * 1000;
static bool s_running;
static CCritSect s_critsect;
static LISTDECL(NetTrans, m_link) s_transactions;
static long s_perf[kNumPerf];
static unsigned s_timeoutMs = kDefaultTimeoutMs;
/*****************************************************************************
*
* Internal functions
*
***/
//============================================================================
static NetTrans * FindTransIncRef_CS (unsigned transId, const char tag[]) {
// There shouldn't be more than a few transactions; just do a linear scan
for (NetTrans * trans = s_transactions.Head(); trans; trans = s_transactions.Next(trans))
if (trans->m_transId == transId) {
trans->IncRef(tag);
return trans;
}
return nil;
}
//============================================================================
static NetTrans * FindTransIncRef (unsigned transId, const char tag[]) {
NetTrans * trans;
s_critsect.Enter();
{
trans = FindTransIncRef_CS(transId, tag);
}
s_critsect.Leave();
return trans;
}
//============================================================================
static void CancelTrans_CS (NetTrans * trans, ENetError error) {
ASSERT(IS_NET_ERROR(error));
if (trans->m_state != kTransStateComplete) {
trans->m_result = error;
trans->m_state = kTransStateComplete;
}
}
/*****************************************************************************
*
* NetTrans implementation
*
***/
//============================================================================
NetTrans::NetTrans (ENetProtocol protocol, ETransType transType)
: m_state(kTransStateWaitServerConnect)
, m_result(kNetPending)
, m_transId(0)
, m_connId(0)
, m_protocol(protocol)
, m_hasSubTrans(false)
, m_transType(transType)
{
AtomicAdd(&s_perf[kPerfCurrTransactions], 1);
AtomicAdd(&s_perfTransCount[m_transType], 1);
// DebugMsg("%s@%p created", s_transTypes[m_transType], this);
}
//============================================================================
NetTrans::~NetTrans () {
ASSERT(!m_link.IsLinked());
AtomicAdd(&s_perfTransCount[m_transType], -1);
AtomicAdd(&s_perf[kPerfCurrTransactions], -1);
// DebugMsg("%s@%p destroyed", s_transTypes[m_transType], this);
}
//============================================================================
bool NetTrans::CanStart () const {
switch (m_protocol) {
case kNetProtocolCli2Auth: return AuthQueryConnected();
case kNetProtocolCli2Game: return GameQueryConnected();
case kNetProtocolCli2File: return FileQueryConnected();
case kNetProtocolCli2Csr: return CsrQueryConnected();
case kNetProtocolCli2GateKeeper: return GateKeeperQueryConnected();
DEFAULT_FATAL(m_protocol);
}
}
/*****************************************************************************
*
* Module functions
*
***/
//============================================================================
void NetTransInitialize () {
s_critsect.Enter();
{
s_running = true;
}
s_critsect.Leave();
}
//============================================================================
void NetTransDestroy (bool wait) {
s_critsect.Enter();
{
s_running = false;
}
s_critsect.Leave();
NetTransCancelAll(kNetErrRemoteShutdown);
if (!wait)
return;
while (s_perf[kPerfCurrTransactions]) {
NetTransUpdate();
AsyncSleep(10);
}
}
//============================================================================
void NetTransSetTimeoutMs (unsigned ms) {
s_timeoutMs = ms ? ms : kDefaultTimeoutMs;
}
//============================================================================
unsigned NetTransGetTimeoutMs () {
return s_timeoutMs;
}
//============================================================================
void NetTransSend (NetTrans * trans) {
trans->IncRef("Lifetime");
s_critsect.Enter();
{
static unsigned s_transId;
while (!trans->m_transId)
trans->m_transId = ++s_transId;
s_transactions.Link(trans, kListTail);
if (!s_running)
CancelTrans_CS(trans, kNetErrRemoteShutdown);
}
s_critsect.Leave();
}
//============================================================================
bool NetTransRecv (unsigned transId, const byte msg[], unsigned bytes) {
NetTrans * trans = FindTransIncRef(transId, "Recv");
if (!trans)
return true; // transaction was canceled.
// Update the timeout time
trans->m_timeoutAtMs = TimeGetMs() + s_timeoutMs;
bool result = trans->Recv(msg, bytes);
if (!result)
NetTransCancel(transId, kNetErrInternalError);
trans->DecRef("Recv");
return result;
}
//============================================================================
void NetTransCancel (unsigned transId, ENetError error) {
s_critsect.Enter();
{
NetTrans * trans = s_transactions.Head();
for (; trans; trans = trans->m_link.Next()) {
if (trans->m_transId == transId) {
CancelTrans_CS(trans, error);
break;
}
}
}
s_critsect.Leave();
}
//============================================================================
void NetTransCancelByProtocol (ENetProtocol protocol, ENetError error) {
s_critsect.Enter();
{
NetTrans * trans = s_transactions.Head();
for (; trans; trans = trans->m_link.Next()) {
if (trans->m_protocol == protocol)
CancelTrans_CS(trans, error);
}
}
s_critsect.Leave();
}
//============================================================================
void NetTransCancelByConnId (unsigned connId, ENetError error) {
s_critsect.Enter();
{
NetTrans * trans = s_transactions.Head();
for (; trans; trans = trans->m_link.Next()) {
if (trans->m_connId == connId)
CancelTrans_CS(trans, error);
}
}
s_critsect.Leave();
}
//============================================================================
void NetTransCancelAll (ENetError error) {
s_critsect.Enter();
{
NetTrans * trans = s_transactions.Head();
for (; trans; trans = trans->m_link.Next())
CancelTrans_CS(trans, error);
}
s_critsect.Leave();
}
//============================================================================
void NetTransUpdate () {
LISTDECL(NetTrans, m_link) completed;
LISTDECL(NetTrans, m_link) parentCompleted;
s_critsect.Enter();
NetTrans * next, * trans = s_transactions.Head();
for (; trans; trans = next) {
next = s_transactions.Next(trans);
bool done = false;
while (!done) {
switch (trans->m_state) {
case kTransStateComplete:
if (trans->m_hasSubTrans)
parentCompleted.Link(trans);
else
completed.Link(trans);
done = true;
break;
case kTransStateWaitServerConnect:
if (!trans->CanStart()) {
done = true;
break;
}
if (trans->m_protocol && 0 == (trans->m_connId = ConnGetId(trans->m_protocol))) {
done = true;
break;
}
// This is the default "next state", trans->Send() can override this
trans->m_state = kTransStateWaitServerResponse;
// Set timeout time before calling Send(), allowing Send() to change it if it wants to.
trans->m_timeoutAtMs = TimeGetMs() + s_timeoutMs;
if (!trans->Send()) {
// Revert back to current state so that we'll attempt to send again
trans->m_state = kTransStateWaitServerConnect;
done = true;
break;
}
break;
case kTransStateWaitServerResponse:
// Check for timeout
if ((int)(TimeGetMs() - trans->m_timeoutAtMs) > 0) {
// Check to see if the transaction wants to "abort" the timeout
if (trans->TimedOut())
CancelTrans_CS(trans, kNetErrTimeout);
else
trans->m_timeoutAtMs = TimeGetMs() + s_timeoutMs; // Reset the timeout counter
}
done = true;
break;
DEFAULT_FATAL(trans->m_state);
}
}
}
s_critsect.Leave();
// Post completed transactions
while (NetTrans * trans = completed.Head()) {
completed.Unlink(trans);
trans->Post();
trans->DecRef("Lifetime");
}
// Post completed parent transactions
while (NetTrans * trans = parentCompleted.Head()) {
parentCompleted.Unlink(trans);
trans->Post();
trans->DecRef("Lifetime");
}
}
} // namespace Ngl

View File

@ -1,44 +1,44 @@
/*==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/>.
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/plNetGameLib.h
*
***/
#ifndef PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_PLNETGAMELIB_H
#define PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_PLNETGAMELIB_H
#define PLNETGAMELIB_INCLUDED
#ifdef PNNETDIAG_INCLUDED
#error "plNetGameLib and pnNetDiag libraries may not be included in the same project because they invalidate each other's pnNetCli settings"
#endif
#include "Private/plNglAllIncludes.h"
#endif // PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_PLNETGAMELIB_H
/*==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/>.
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/plNetGameLib.h
*
***/
#ifndef PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_PLNETGAMELIB_H
#define PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_PLNETGAMELIB_H
#define PLNETGAMELIB_INCLUDED
#ifdef PNNETDIAG_INCLUDED
#error "plNetGameLib and pnNetDiag libraries may not be included in the same project because they invalidate each other's pnNetCli settings"
#endif
#include "Private/plNglAllIncludes.h"
#endif // PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_PLNETGAMELIB_H