Browse Source

Merge pull request #208 from Hoikas/deadweight

Remove Junk
Branan Purvine-Riley 13 years ago
parent
commit
5a93553651
  1. 3
      Sources/Plasma/Apps/plClient/CMakeLists.txt
  2. 7
      Sources/Plasma/Apps/plClient/plClient.cpp
  3. 51
      Sources/Plasma/Apps/plClientKey/DllMain.cpp
  4. 63
      Sources/Plasma/Apps/plClientKey/plClientKey.cpp
  5. 5
      Sources/Plasma/Apps/plClientKey/plClientKey.def
  6. 59
      Sources/Plasma/Apps/plClientKey/plClientKey.h
  7. BIN
      Sources/Plasma/Apps/plPlasmaInstaller/Dirt.ICO
  8. 63
      Sources/Plasma/Apps/plPlasmaInstaller/main.cpp
  9. 113
      Sources/Plasma/Apps/plPlasmaInstaller/plInstallerReg.cpp
  10. 50
      Sources/Plasma/Apps/plPlasmaInstaller/plInstallerReg.h
  11. 408
      Sources/Plasma/Apps/plPlasmaInstaller/plPlasmaInstaller.cpp
  12. 73
      Sources/Plasma/Apps/plPlasmaInstaller/plPlasmaInstaller.h
  13. 122
      Sources/Plasma/Apps/plPlasmaInstaller/plPlasmaInstaller.rc
  14. 120
      Sources/Plasma/Apps/plPlasmaInstaller/plSetPlasmaPath.cpp
  15. 42
      Sources/Plasma/Apps/plPlasmaInstaller/plSetPlasmaPath.h
  16. 169
      Sources/Plasma/Apps/plPlasmaInstaller/plUnzip.cpp
  17. 66
      Sources/Plasma/Apps/plPlasmaInstaller/plUnzip.h
  18. 30
      Sources/Plasma/Apps/plPlasmaInstaller/resource.h
  19. BIN
      Sources/Plasma/Apps/plPlasmaUpdate/Dirt.ICO
  20. 67
      Sources/Plasma/Apps/plPlasmaUpdate/main.cpp
  21. 186
      Sources/Plasma/Apps/plPlasmaUpdate/plFileGrabber.cpp
  22. 89
      Sources/Plasma/Apps/plPlasmaUpdate/plFileGrabber.h
  23. 361
      Sources/Plasma/Apps/plPlasmaUpdate/plManifest.cpp
  24. 93
      Sources/Plasma/Apps/plPlasmaUpdate/plManifest.h
  25. 94
      Sources/Plasma/Apps/plPlasmaUpdate/plPlasmaServers.cpp
  26. 75
      Sources/Plasma/Apps/plPlasmaUpdate/plPlasmaServers.h
  27. 514
      Sources/Plasma/Apps/plPlasmaUpdate/plPlasmaUpdate.cpp
  28. 94
      Sources/Plasma/Apps/plPlasmaUpdate/plPlasmaUpdate.h
  29. 131
      Sources/Plasma/Apps/plPlasmaUpdate/plPlasmaUpdate.rc
  30. 27
      Sources/Plasma/Apps/plPlasmaUpdate/resource.h
  31. 1
      Sources/Plasma/Apps/plUruLauncher/CMakeLists.txt
  32. 4
      Sources/Plasma/FeatureLib/CMakeLists.txt
  33. 51
      Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCommandsCore.cpp
  34. 19
      Sources/Plasma/FeatureLib/pfCsrSrv/CMakeLists.txt
  35. 58
      Sources/Plasma/FeatureLib/pfCsrSrv/Pch.h
  36. 160
      Sources/Plasma/FeatureLib/pfCsrSrv/pfCsrSrv.cpp
  37. 66
      Sources/Plasma/FeatureLib/pfCsrSrv/pfCsrSrv.h
  38. 23
      Sources/Plasma/FeatureLib/pfLoginDialog/CMakeLists.txt
  39. 103
      Sources/Plasma/FeatureLib/pfLoginDialog/pfLoginDialog.rc
  40. 672
      Sources/Plasma/FeatureLib/pfLoginDialog/plLoginDialog.cpp
  41. 138
      Sources/Plasma/FeatureLib/pfLoginDialog/plLoginDialog.h
  42. 24
      Sources/Plasma/FeatureLib/pfLoginDialog/resource.h
  43. 3
      Sources/Plasma/NucleusLib/CMakeLists.txt
  44. 4
      Sources/Plasma/NucleusLib/pnAsyncCore/Private/pnAcIo.h
  45. 16
      Sources/Plasma/NucleusLib/pnCsrCli/CMakeLists.txt
  46. 56
      Sources/Plasma/NucleusLib/pnCsrCli/Pch.h
  47. 269
      Sources/Plasma/NucleusLib/pnCsrCli/pnCsrCli.cpp
  48. 83
      Sources/Plasma/NucleusLib/pnCsrCli/pnCsrCli.h
  49. 16
      Sources/Plasma/NucleusLib/pnCsrNet/CMakeLists.txt
  50. 54
      Sources/Plasma/NucleusLib/pnCsrNet/Pch.h
  51. 49
      Sources/Plasma/NucleusLib/pnCsrNet/pnCsrNet.cpp
  52. 88
      Sources/Plasma/NucleusLib/pnCsrNet/pnCsrNet.h
  53. 14
      Sources/Plasma/NucleusLib/pnNetBase/pnNbConst.h
  54. 4
      Sources/Plasma/NucleusLib/pnNetBase/pnNbKeys.cpp
  55. 5
      Sources/Plasma/NucleusLib/pnNetBase/pnNbKeys.h
  56. 4
      Sources/Plasma/NucleusLib/pnNetBase/pnNbProtocol.cpp
  57. 2
      Sources/Plasma/NucleusLib/pnNetBase/pnNbProtocol.h
  58. 22
      Sources/Plasma/NucleusLib/pnNetBase/pnNbSrvs.cpp
  59. 5
      Sources/Plasma/NucleusLib/pnNetBase/pnNbSrvs.h
  60. 17
      Sources/Plasma/NucleusLib/pnNetProtocol/CMakeLists.txt
  61. 122
      Sources/Plasma/NucleusLib/pnNetProtocol/Private/Protocols/Cli2Csr/pnNpCli2Csr.cpp
  62. 178
      Sources/Plasma/NucleusLib/pnNetProtocol/Private/Protocols/Cli2Csr/pnNpCli2Csr.h
  63. 4
      Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpAllIncludes.h
  64. 15
      Sources/Plasma/NucleusLib/pnSimpleNet/CMakeLists.txt
  65. 658
      Sources/Plasma/NucleusLib/pnSimpleNet/pnSimpleNet.cpp
  66. 185
      Sources/Plasma/NucleusLib/pnSimpleNet/pnSimpleNet.h
  67. 4
      Sources/Plasma/PubUtilLib/CMakeLists.txt
  68. 587
      Sources/Plasma/PubUtilLib/plDeviceSelector/plDeviceSelector.cpp
  69. 160
      Sources/Plasma/PubUtilLib/plDeviceSelector/plDeviceSelector.h
  70. 1
      Sources/Plasma/PubUtilLib/plGClip/placeholder.txt
  71. 250
      Sources/Plasma/PubUtilLib/plGRenderProcs/hsGRenderProcs.cpp
  72. 218
      Sources/Plasma/PubUtilLib/plGRenderProcs/hsGRenderProcs.h
  73. 234
      Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxAngleFade.cpp
  74. 90
      Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxAngleFade.h
  75. 331
      Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxDistFade.cpp
  76. 107
      Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxDistFade.h
  77. 292
      Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxDistShade.cpp
  78. 97
      Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxDistShade.h
  79. 242
      Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxGlobalShade.cpp
  80. 120
      Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxGlobalShade.h
  81. 81
      Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxIntenseAlpha.cpp
  82. 82
      Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxIntenseAlpha.h
  83. 320
      Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxObjDistFade.cpp
  84. 116
      Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxObjDistFade.h
  85. 217
      Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxObjDistShade.cpp
  86. 98
      Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxObjDistShade.h
  87. 80
      Sources/Plasma/PubUtilLib/plGRenderProcs/plGRenderProcsCreatable.h
  88. 763
      Sources/Plasma/PubUtilLib/plGeometry/hsOscillator.cpp
  89. 180
      Sources/Plasma/PubUtilLib/plGeometry/hsOscillator.h
  90. 350
      Sources/Plasma/PubUtilLib/plGeometry/hsPerterber.cpp
  91. 107
      Sources/Plasma/PubUtilLib/plGeometry/hsPerterber.h
  92. 70
      Sources/Plasma/PubUtilLib/plGeometry/plGeometryCreatable.h
  93. 2
      Sources/Plasma/PubUtilLib/plNetGameLib/CMakeLists.txt
  94. 34
      Sources/Plasma/PubUtilLib/plNetGameLib/Intern.h
  95. 1
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAllIncludes.h
  96. 3
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglCore.cpp
  97. 900
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglCsr.cpp
  98. 94
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglCsr.h
  99. 1
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglMisc.cpp
  100. 1
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglTrans.cpp
  101. Some files were not shown because too many files have changed in this diff Show More

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)

7
Sources/Plasma/Apps/plClient/plClient.cpp

@ -144,7 +144,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plAvatar/plAGAnimInstance.h"
#include "plAgeLoader/plAgeLoader.h"
#include "plClientKey/plClientKey.h"
#include "plQuality.h"
#include "plGLight/plShadowCaster.h"
@ -156,8 +155,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 +260,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 +2539,6 @@ void plClient::ICompleteInit () {
plClientMsg* clientMsg = new plClientMsg(plClientMsg::kInitComplete);
clientMsg->SetBCastFlag(plMessage::kBCastByType);
clientMsg->Send();
CsrSrvInitialize();
}
//============================================================================

51
Sources/Plasma/Apps/plClientKey/DllMain.cpp

@ -1,51 +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==*/
#include <windows.h>
__declspec(dllexport) const unsigned long* GetKey()
{
// So the crackers know who the tard is
static const char* tauntText = "My copy protection is uncrackable! -Brice";
static const unsigned long kDefaultKey[4] = { 0x6c0a5452, 0x3827d0f, 0x3a170b92, 0x16db7fc2 };
return kDefaultKey;
}

63
Sources/Plasma/Apps/plClientKey/plClientKey.cpp

@ -1,63 +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==*/
#include "plClientKey.h"
typedef const uint32_t* (*GETKEY)();
const uint32_t* plClientKey::GetKey()
{
HMODULE hDll = LoadLibrary("sp.dll");
if (hDll)
{
GETKEY getKey = (GETKEY)GetProcAddress(hDll, "GetKey");
if (getKey)
{
static uint32_t key[4];
memcpy(key, getKey(), sizeof(key));
FreeLibrary(hDll);
return key;
}
}
return nil;
}

5
Sources/Plasma/Apps/plClientKey/plClientKey.def

@ -1,5 +0,0 @@
LIBRARY
EXPORTS
GetKey @1
SECTIONS
.data READ WRITE

59
Sources/Plasma/Apps/plClientKey/plClientKey.h

@ -1,59 +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==*/
#ifndef plClientKey_h_inc
#define plClientKey_h_inc
#include "HeadSpin.h"
//
// For getting the "SafeDisc protected" encryption key in single player mode
//
// Include plClientKey.cpp/h in your project and call plClientKey::GetKey
// It will load the Dll and get the key for you
// Returns nil if it fails
//
namespace plClientKey
{
const uint32_t* GetKey();
}
#endif // plClientKey_h_inc

BIN
Sources/Plasma/Apps/plPlasmaInstaller/Dirt.ICO

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

63
Sources/Plasma/Apps/plPlasmaInstaller/main.cpp

@ -1,63 +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==*/
#include "HeadSpin.h"
#include "plPlasmaInstaller.h"
#include "jvCoreUtil.h"
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
jvCoreUtil::SetHInstance(hInstance);
plPlasmaInstaller installer;
installer.Create();
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
if (!IsDialogMessage(installer.GetHWnd(), &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return msg.wParam;
}

113
Sources/Plasma/Apps/plPlasmaInstaller/plInstallerReg.cpp

@ -1,113 +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==*/
#include "HeadSpin.h"
#include "plInstallerReg.h"
#include <windows.h>
static HKEY GetInstallerKey()
{
HKEY hSoftKey = NULL;
HKEY hCompanyKey = NULL;
HKEY hAppKey = NULL;
if(RegOpenKeyEx(HKEY_CURRENT_USER, "software", 0, KEY_WRITE|KEY_READ,
&hSoftKey) == ERROR_SUCCESS)
{
DWORD dw;
if(RegCreateKeyEx(hSoftKey, "Cyan", 0, REG_NONE,
REG_OPTION_NON_VOLATILE, KEY_WRITE|KEY_READ, NULL,
&hCompanyKey, &dw) == ERROR_SUCCESS)
{
RegCreateKeyEx(hCompanyKey, "PlasmaInstaller", 0, REG_NONE,
REG_OPTION_NON_VOLATILE, KEY_WRITE|KEY_READ, NULL,
&hAppKey, &dw);
}
}
if (hSoftKey != NULL)
RegCloseKey(hSoftKey);
if (hCompanyKey != NULL)
RegCloseKey(hCompanyKey);
return hAppKey;
}
static void WriteRegString(const char* valueName, const char* value)
{
HKEY installKey = GetInstallerKey();
RegSetValueEx(installKey, valueName, 0, REG_SZ, (const BYTE*)value, strlen(value)+1);
RegCloseKey(installKey);
}
static bool ReadRegString(const char* valueName, char* value, DWORD size)
{
HKEY installKey = GetInstallerKey();
bool ret = (RegQueryValueEx(installKey, valueName, NULL, NULL, (LPBYTE)value, &size) == ERROR_SUCCESS);
RegCloseKey(installKey);
return ret;
}
void plInstallerReg::SetClientDir(const char* dir)
{
WriteRegString("Client", dir);
}
void plInstallerReg::SetMaxDir(const char* dir)
{
WriteRegString("3dsmax", dir);
}
const char* plInstallerReg::GetClientDir()
{
static char dir[MAX_PATH];
if (!ReadRegString("Client", dir, sizeof(dir)))
strcpy(dir, "C:\\PlasmaClient");
return dir;
}
const char* plInstallerReg::GetMaxDir()
{
static char dir[MAX_PATH];
dir[0] = '\0';
ReadRegString("3dsmax", dir, sizeof(dir));
return dir;
}

50
Sources/Plasma/Apps/plPlasmaInstaller/plInstallerReg.h

@ -1,50 +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==*/
namespace plInstallerReg
{
void SetClientDir(const char* dir);
void SetMaxDir(const char* dir);
const char* GetClientDir();
const char* GetMaxDir();
}

408
Sources/Plasma/Apps/plPlasmaInstaller/plPlasmaInstaller.cpp

@ -1,408 +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==*/
#include "HeadSpin.h"
#include "plPlasmaInstaller.h"
#include "resource.h"
#include <windowsx.h>
#include <commctrl.h>
#include "../plFile/hsFiles.h"
#include "plUnzip.h"
#include "plInstallerReg.h"
#include "../plFile/plBrowseFolder.h"
#include "plSetPlasmaPath.h"
plPlasmaInstaller::plPlasmaInstaller()
{
fDailyDir[0] = '\0';
fDidGet = false;
fStatusList = nil;
INITCOMMONCONTROLSEX icc = {0};
icc.dwSize = sizeof(INITCOMMONCONTROLSEX);
icc.dwICC = ICC_DATE_CLASSES;
InitCommonControlsEx(&icc);
}
void plPlasmaInstaller::Create()
{
ICreateDialog(IDD_INSTALLER, NULL);
}
static const char* kAllClientExes = "AllClientExes.zip";
static const char* kAllDllsRelease = "AllDllsRelease.zip";
static const char* kScripts = "Scripts.zip";
static const char* kTools = "AllToolsRelease.zip";
bool FileExists(const char* path, const char* filename)
{
char fullpath[MAX_PATH];
sprintf(fullpath, "%s%s", path, filename);
HANDLE hFile = CreateFile(fullpath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
if (hFile != INVALID_HANDLE_VALUE)
{
CloseHandle(hFile);
return true;
}
return false;
}
bool plPlasmaInstaller::IGetDailyDir()
{
// Get the branch
HWND hBuild = GetDlgItem(fDlg, IDC_BUILD_COMBO);
int idx = ComboBox_GetCurSel(hBuild);
int buildServer = ComboBox_GetItemData(hBuild, idx);
HWND hTime = GetDlgItem(fDlg, IDC_TIME_COMBO);
idx = ComboBox_GetCurSel(hTime);
int time = ComboBox_GetItemData(hTime, idx);
// Get the build date
SYSTEMTIME date;
DateTime_GetSystemtime(GetDlgItem(fDlg, IDC_BRANCH_DATE), &date);
char dateStr[] = "xx-xx-xxxx";
sprintf(dateStr, "%02d-%02d-%04d", date.wMonth, date.wDay, date.wYear);
fDailyDir[0] = '\0';
IAddStatusLine("Searching for %s build...", dateStr);
char buildDir[MAX_PATH];
static const char* kMainBuild = "\\\\Plasmabuild\\Output\\";
static const char* kBranchBuild = "\\\\Branchbuild\\Output\\";
static const char* kActiveBuild = "\\\\Activebuild\\Output\\";
static const char* kInternalMain = "Main-Internal\\";
static const char* kInternalBranch = "Branch-Internal\\";
static const char* kInternalActive = "Active-Internal\\";
switch (buildServer)
{
case kBuildMain: strcpy(buildDir, kMainBuild); break;
case kBuildBranch: strcpy(buildDir, kBranchBuild); break;
case kBuildActive: strcpy(buildDir, kActiveBuild); break;
}
switch (time)
{
case kNightly:
strcat(buildDir, "Nightly\\");
break;
case kAfternoon:
strcat(buildDir, "Afternoon\\");
break;
case kEvening:
strcat(buildDir, "Evening\\");
break;
}
strcat(buildDir, dateStr);
strcat(buildDir, "\\");
switch (buildServer)
{
case kBuildMain: strcat(buildDir, kInternalMain); break;
case kBuildBranch: strcat(buildDir, kInternalBranch); break;
case kBuildActive: strcat(buildDir, kInternalActive); break;
}
if (FileExists(buildDir, kAllClientExes) && FileExists(buildDir, kAllDllsRelease) && FileExists(buildDir, kScripts))
{
strcpy(fDailyDir, buildDir);
const char* serverName = nil;
switch (buildServer)
{
case kBuildMain: serverName = "Main"; break;
case kBuildBranch: serverName = "Branch"; break;
case kBuildActive: serverName = "Active"; break;
}
IAddStatusLine("Found %s at %s", serverName, fDailyDir);
EnableWindow(GetDlgItem(fDlg, IDC_GET_BUTTON), TRUE);
return true;
}
IAddStatusLine("Couldn't find build");
EnableWindow(GetDlgItem(fDlg, IDC_GET_BUTTON), FALSE);
return false;
}
void plPlasmaInstaller::IInit()
{
const char* clientDir = plInstallerReg::GetClientDir();
SetDlgItemText(fDlg, IDC_CLIENT_EDIT, clientDir);
const char* maxDir = plInstallerReg::GetMaxDir();
SetDlgItemText(fDlg, IDC_3DSMAX_EDIT, maxDir);
fStatusList = GetDlgItem(fDlg, IDC_STATUS_LIST);
HWND hCombo = GetDlgItem(fDlg, IDC_BUILD_COMBO);
int idx = ComboBox_AddString(hCombo, "Main");
ComboBox_SetItemData(hCombo, idx, kBuildMain);
ComboBox_SetCurSel(hCombo, idx);
idx = ComboBox_AddString(hCombo, "Branch");
ComboBox_SetItemData(hCombo, idx, kBuildBranch);
idx = ComboBox_AddString(hCombo, "Active");
ComboBox_SetItemData(hCombo, idx, kBuildActive);
HWND hTime = GetDlgItem(fDlg, IDC_TIME_COMBO);
idx = ComboBox_AddString(hTime, "Nightly");
ComboBox_SetItemData(hTime, idx, kNightly);
ComboBox_SetCurSel(hTime, idx);
idx = ComboBox_AddString(hTime, "Afternoon");
ComboBox_SetItemData(hTime, idx, kAfternoon);
idx = ComboBox_AddString(hTime, "Evening");
ComboBox_SetItemData(hTime, idx, kEvening);
CheckDlgButton(fDlg, IDC_CLIENT_CHECK, BST_CHECKED);
CheckDlgButton(fDlg, IDC_SCRIPTS_CHECK, BST_CHECKED);
CheckDlgButton(fDlg, IDC_PLUGINS_CHECK, BST_CHECKED);
ShowWindow(fDlg, SW_SHOW);
IGetDailyDir();
}
BOOL plPlasmaInstaller::IDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_INITDIALOG:
IInit();
SetFocus(GetDlgItem(fDlg, IDC_GET_BUTTON));
return FALSE;
case WM_CLOSE:
DestroyWindow(hDlg);
return TRUE;
case WM_DESTROY:
PostQuitMessage(0);
return TRUE;
case WM_COMMAND:
if (HIWORD(wParam) == BN_CLICKED)
{
switch (LOWORD(wParam))
{
case IDCANCEL:
PostMessage(hDlg, WM_CLOSE, 0, 0);
return TRUE;
case IDC_BROWSE_3DSMAX:
case IDC_BROWSE_CLIENT:
IGetFolder(LOWORD(wParam) == IDC_BROWSE_CLIENT);
return TRUE;
case IDC_GET_BUTTON:
if (fDidGet)
PostMessage(hDlg, WM_CLOSE, 0, 0);
else
IGet();
return TRUE;
}
}
else if (HIWORD(wParam) == CBN_SELCHANGE && (LOWORD(wParam) == IDC_TIME_COMBO || LOWORD(wParam) == IDC_BUILD_COMBO))
{
IGetDailyDir();
return TRUE;
}
break;
case WM_NOTIFY:
{
NMHDR* nmhdr = (NMHDR*)lParam;
if (nmhdr->idFrom == IDC_BRANCH_DATE && nmhdr->code == DTN_CLOSEUP/*DTN_DATETIMECHANGE*/)
{
IGetDailyDir();
return TRUE;
}
}
break;
}
return FALSE;
}
void plPlasmaInstaller::IExtractZip(const char* filename, const char* dest)
{
plUnzip unzip;
if (unzip.Open(filename))
{
IAddStatusLine("Extracting %s...", filename);
char buf[MAX_PATH];
while (unzip.ExtractNext(dest, buf))
IAddStatusLine(" %s", buf);
IAddStatusLine(" %s", buf);
unzip.Close();
}
}
void plPlasmaInstaller::IGet()
{
bool getClient = (IsDlgButtonChecked(fDlg, IDC_CLIENT_CHECK) == BST_CHECKED);
bool getScripts = (IsDlgButtonChecked(fDlg, IDC_SCRIPTS_CHECK) == BST_CHECKED);
bool getPlugins = (IsDlgButtonChecked(fDlg, IDC_PLUGINS_CHECK) == BST_CHECKED);
bool getTools = (IsDlgButtonChecked(fDlg, IDC_TOOLS_CHECK) == BST_CHECKED);
const char* clientDir = plInstallerReg::GetClientDir();
if (*clientDir == '\0' && (getClient || getScripts))
{
MessageBox(fDlg, "You need to set your client directory", "Plasma Installer", MB_OK | MB_ICONASTERISK);
return;
}
const char* maxDir = plInstallerReg::GetMaxDir();
if (*maxDir == '\0' && getPlugins)
{
MessageBox(fDlg, "You need to set your 3dsmax directory", "Plasma Installer", MB_OK | MB_ICONASTERISK);
return;
}
HWND hGetButton = GetDlgItem(fDlg, IDC_GET_BUTTON);
EnableWindow(hGetButton, FALSE);
HCURSOR hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
char buf[MAX_PATH];
if (getScripts)
{
sprintf(buf, "%s%s", fDailyDir, kScripts);
IExtractZip(buf, clientDir);
}
if (getClient)
{
sprintf(buf, "%s%s", fDailyDir, kAllClientExes);
IExtractZip(buf, clientDir);
}
if (getPlugins)
{
sprintf(buf, "%s%s", fDailyDir, kAllDllsRelease);
char pluginDir[MAX_PATH];
sprintf(pluginDir, "%s\\plugins", maxDir);
IExtractZip(buf, pluginDir);
IAddStatusLine("Updating PlasmaMAX2.ini...");
sprintf(buf, "%s\\plugcfg\\PlasmaMAX2.ini", maxDir);
WritePrivateProfileString("SceneViewer", "Directory", clientDir, buf);
}
if (getTools)
{
sprintf(buf, "%s%s", fDailyDir, kTools);
char toolBuf[MAX_PATH];
sprintf(toolBuf, "%s\\Tools", clientDir);
IExtractZip(buf, toolBuf);
}
IAddStatusLine("Updating path...");
SetPlasmaPath(clientDir);
IAddStatusLine("Done");
SetCursor(hOldCursor);
fDidGet = true;
SetWindowText(hGetButton, "Close");
EnableWindow(hGetButton, TRUE);
}
void plPlasmaInstaller::IGetFolder(bool client)
{
char path[MAX_PATH];
if (client)
strcpy(path, plInstallerReg::GetClientDir());
else
strcpy(path, plInstallerReg::GetMaxDir());
if (plBrowseFolder::GetFolder(path, path))
{
if (client)
{
SetDlgItemText(fDlg, IDC_CLIENT_EDIT, path);
plInstallerReg::SetClientDir(path);
}
else
{
SetDlgItemText(fDlg, IDC_3DSMAX_EDIT, path);
plInstallerReg::SetMaxDir(path);
}
}
}
void plPlasmaInstaller::IAddStatusLine(const char* format, ...)
{
if (!format || *format == '\0')
return;
va_list args;
va_start(args, format);
char buf[2048];
int numWritten = _vsnprintf(buf, sizeof(buf), format, args);
hsAssert(numWritten > 0, "Buffer too small");
va_end(args);
int idx = ListBox_AddString(fStatusList, buf);
ListBox_SetCurSel(fStatusList, idx);
// Pump the message queue
MSG msg;
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (!IsDialogMessage(&msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}

73
Sources/Plasma/Apps/plPlasmaInstaller/plPlasmaInstaller.h

@ -1,73 +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==*/
#include "jvBaseDlg.h"
class plPlasmaInstaller : public jvBaseDlg
{
protected:
char fDailyDir[MAX_PATH];
bool fDidGet;
HWND fStatusList;
enum { kBuildMain, kBuildBranch, kBuildActive };
enum { kNightly, kAfternoon, kEvening };
virtual BOOL IDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
bool IGetDailyDir();
void IGetFolder(bool client);
void IGet();
void IInit();
void IExtractZip(const char* filename, const char* dest);
void IAddStatusLine(const char* format, ...);
public:
plPlasmaInstaller();
void Create();
HWND GetHWnd() { return fDlg; }
};

122
Sources/Plasma/Apps/plPlasmaInstaller/plPlasmaInstaller.rc

@ -1,122 +0,0 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#define IDC_STATIC (-1) // all static controls
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_INSTALLER DIALOG DISCARDABLE 0, 0, 241, 170
STYLE DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Plasma Installer"
FONT 8, "MS Sans Serif"
BEGIN
LTEXT "Build:",IDC_STATIC,7,8,18,8
COMBOBOX IDC_TIME_COMBO,27,6,46,167,CBS_DROPDOWNLIST | WS_VSCROLL |
WS_TABSTOP
LTEXT "3dsmax Directory:",IDC_STATIC,7,26,57,8
EDITTEXT IDC_3DSMAX_EDIT,7,36,173,12,ES_AUTOHSCROLL | ES_READONLY
PUSHBUTTON "Browse...",IDC_BROWSE_3DSMAX,183,35,50,14
LTEXT "Client Directory:",IDC_STATIC,7,53,50,8
EDITTEXT IDC_CLIENT_EDIT,7,63,173,12,ES_AUTOHSCROLL | ES_READONLY
PUSHBUTTON "Browse...",IDC_BROWSE_CLIENT,183,62,50,14
DEFPUSHBUTTON "Get",IDC_GET_BUTTON,93,146,56,16,WS_DISABLED
LISTBOX IDC_STATUS_LIST,7,85,226,54,LBS_NOSEL | WS_VSCROLL |
WS_TABSTOP
CONTROL "DateTimePicker1",IDC_BRANCH_DATE,"SysDateTimePick32",
DTS_RIGHTALIGN | WS_TABSTOP,125,6,55,12
COMBOBOX IDC_BUILD_COMBO,76,6,46,167,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
CONTROL "Client",IDC_CLIENT_CHECK,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,159,144,33,10
CONTROL "Scripts",IDC_SCRIPTS_CHECK,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,159,154,37,10
CONTROL "Plugins",IDC_PLUGINS_CHECK,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,197,144,39,10
CONTROL "Tools",IDC_TOOLS_CHECK,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,197,154,33,10
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_INSTALLER, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 234
TOPMARGIN, 7
BOTTOMMARGIN, 163
END
END
#endif // APSTUDIO_INVOKED
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON1 ICON DISCARDABLE "Dirt.ICO"
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

120
Sources/Plasma/Apps/plPlasmaInstaller/plSetPlasmaPath.cpp

@ -1,120 +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==*/
#include "HeadSpin.h"
#include <windows.h>
static HKEY GetEnvironKey()
{
HKEY hSystemKey = NULL;
HKEY hControlSetKey = NULL;
HKEY hControlKey = NULL;
HKEY hSessionKey = NULL;
HKEY hEnvironKey = NULL;
if ((RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SYSTEM", 0, KEY_READ, &hSystemKey) == ERROR_SUCCESS) &&
(RegOpenKeyEx(hSystemKey, "CurrentControlSet", 0, KEY_READ, &hControlSetKey) == ERROR_SUCCESS) &&
(RegOpenKeyEx(hControlSetKey, "Control", 0, KEY_READ, &hControlKey) == ERROR_SUCCESS) &&
(RegOpenKeyEx(hControlKey, "Session Manager", 0, KEY_READ, &hSessionKey) == ERROR_SUCCESS))
{
RegOpenKeyEx(hSessionKey, "Environment", 0, KEY_READ | KEY_WRITE, &hEnvironKey);
}
if (hSystemKey != NULL)
RegCloseKey(hSystemKey);
if (hControlSetKey != NULL)
RegCloseKey(hControlSetKey);
if (hControlKey != NULL)
RegCloseKey(hControlKey);
if (hSessionKey != NULL)
RegCloseKey(hSessionKey);
return hEnvironKey;
}
void SetPlasmaPath(const char* plasmaPath)
{
bool pathSet = false;
HKEY hEnvironKey = GetEnvironKey();
if (hEnvironKey)
{
// Make sure the PlasmaGameDir var is in the path
DWORD size = 0;
if (ERROR_SUCCESS == RegQueryValueEx(hEnvironKey, "Path", NULL, NULL, NULL, &size))
{
char* oldPath = new char[size];
static const char* kPlasmaVar = "%PlasmaGameDir%";
if (ERROR_SUCCESS == RegQueryValueEx(hEnvironKey, "Path", NULL, NULL, (BYTE*)oldPath, &size))
{
pathSet = (strstr(oldPath, kPlasmaVar) != NULL);
if (!pathSet)
{
char* newPath = new char[size+strlen(kPlasmaVar)+1];
strcpy(newPath, oldPath);
strcat(newPath, ";");
strcat(newPath, kPlasmaVar);
RegSetValueEx(hEnvironKey, "Path", 0, REG_EXPAND_SZ, (BYTE*)newPath, strlen(newPath)+1);
delete [] newPath;
}
}
delete [] oldPath;
}
// Set the PlasmaGameDir var
RegSetValueEx(hEnvironKey, "PlasmaGameDir", 0, REG_SZ, (BYTE*)plasmaPath, strlen(plasmaPath)+1);
// Notify command prompts and stuff that environ changed
DWORD ret;
SendMessageTimeout(HWND_BROADCAST,
WM_SETTINGCHANGE,
0,
(LPARAM)"Environment",
SMTO_ABORTIFHUNG,
5000,
&ret);
}
}

42
Sources/Plasma/Apps/plPlasmaInstaller/plSetPlasmaPath.h

@ -1,42 +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==*/
void SetPlasmaPath(const char* plasmaPath);

169
Sources/Plasma/Apps/plPlasmaInstaller/plUnzip.cpp

@ -1,169 +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==*/
#include "HeadSpin.h"
#include "plUnzip.h"
#include "hsTypes.h"
#include "hsWindows.h"
#include "hsStream.h"
plUnzip::plUnzip() : fFile(nil)
{
}
bool plUnzip::Open(const char* filename)
{
fFile = unzOpen(filename);
return (fFile != nil);
}
bool plUnzip::Close()
{
bool ret = false;
if (fFile != nil)
{
ret = (UNZ_OK == unzClose(fFile));
fFile = nil;
}
return ret;
}
void plUnzip::IGetFullPath(const char* destDir, const char* filename, char* outFilename)
{
// Make sure the dest ends with a slash
strcpy(outFilename, destDir);
char lastChar = outFilename[strlen(outFilename)-1];
if (lastChar != '\\' && lastChar != '/')
strcat(outFilename, "\\");
// Check if the output filename has any directories in it
const char* forward = strrchr(filename, '/');
const char* backward = strrchr(filename, '\\');
if (!forward && !backward)
{
CreateDirectory(outFilename, NULL);
strcat(outFilename, filename);
}
else
{
const char* fileOnly = (forward > backward) ? forward+1 : backward+1;
strncat(outFilename, filename, fileOnly-filename);
CreateDirectory(outFilename, NULL);
strcat(outFilename, fileOnly);
}
}
void plUnzip::IExtractCurrent(const char* destDir, char* fileName)
{
char filename[MAX_PATH];
if (unzGetCurrentFileInfo(fFile, nil, filename, sizeof(filename), nil, 0, nil, 0) == UNZ_OK)
{
strcpy(fileName, filename);
if (unzOpenCurrentFile(fFile) == UNZ_OK)
{
char outFilename[MAX_PATH];
IGetFullPath(destDir, filename, outFilename);
// Make sure to take off the read-only flag if the file exists, and is RO
DWORD attrs = GetFileAttributes(outFilename);
if (attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_READONLY))
SetFileAttributes(outFilename, attrs & ~FILE_ATTRIBUTE_READONLY);
hsUNIXStream outFile;
if (outFile.Open(outFilename, "wb"))
{
char buf[2048];
int numRead;
while ((numRead = unzReadCurrentFile(fFile, buf, sizeof(buf))) > 0)
{
outFile.Write(numRead, buf);
}
outFile.Close();
unz_file_info_s info;
unzGetCurrentFileInfo(fFile, &info, NULL, 0, NULL, 0, NULL, 0);
SYSTEMTIME sysTime = {0};
sysTime.wDay = info.tmu_date.tm_mday;
sysTime.wMonth = info.tmu_date.tm_mon+1;
sysTime.wYear = info.tmu_date.tm_year;
sysTime.wHour = info.tmu_date.tm_hour;
sysTime.wMinute = info.tmu_date.tm_min;
sysTime.wSecond = info.tmu_date.tm_sec;
FILETIME localFileTime, utcFileTime;
SystemTimeToFileTime(&sysTime, &localFileTime);
LocalFileTimeToFileTime(&localFileTime, &utcFileTime);
HANDLE hFile = CreateFile(outFilename, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
SetFileTime(hFile, NULL, NULL, &utcFileTime);
CloseHandle(hFile);
}
unzCloseCurrentFile(fFile);
}
}
}
void plUnzip::ExtractAll(const char* destDir)
{
if (unzGoToFirstFile(fFile) != UNZ_OK)
return;
do
{
IExtractCurrent(destDir);
}
while (unzGoToNextFile(fFile) == UNZ_OK);
}
bool plUnzip::ExtractNext(const char* destDir, char* fileName)
{
IExtractCurrent(destDir, fileName);
return (unzGoToNextFile(fFile) == UNZ_OK);
}

66
Sources/Plasma/Apps/plPlasmaInstaller/plUnzip.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==*/
#ifndef plUnzip_h_inc
#define plUnzip_h_inc
#include "hsTypes.h"
#include "../src/contrib/minizip/unzip.h"
class plUnzip
{
protected:
unzFile fFile;
void IGetFullPath(const char* destDir, const char* filename, char* outFilename);
void IExtractCurrent(const char* destDir, char* fileName=nil);
public:
plUnzip();
bool Open(const char* filename);
bool Close();
void ExtractAll(const char* destDir);
bool ExtractNext(const char* destDir, char* fileName);
};
#endif // plUnzip_h_inc

30
Sources/Plasma/Apps/plPlasmaInstaller/resource.h

@ -1,30 +0,0 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by plPlasmaInstaller.rc
//
#define IDD_INSTALLER 101
#define IDI_ICON1 102
#define IDC_3DSMAX_EDIT 1000
#define IDC_BROWSE_3DSMAX 1001
#define IDC_TIME_COMBO 1002
#define IDC_CLIENT_EDIT 1003
#define IDC_BROWSE_CLIENT 1004
#define IDC_GET_BUTTON 1005
#define IDC_STATUS_LIST 1006
#define IDC_BRANCH_DATE 1007
#define IDC_BUILD_COMBO 1008
#define IDC_CLIENT_CHECK 1009
#define IDC_SCRIPTS_CHECK 1010
#define IDC_PLUGINS_CHECK 1011
#define IDC_TOOLS_CHECK 1012
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 103
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1013
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

BIN
Sources/Plasma/Apps/plPlasmaUpdate/Dirt.ICO

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

67
Sources/Plasma/Apps/plPlasmaUpdate/main.cpp

@ -1,67 +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==*/
#include "HeadSpin.h"
#include "plPlasmaUpdate.h"
#include "jvCoreUtil.h"
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
jvCoreUtil::SetHInstance(hInstance);
plPlasmaUpdate installer;
if (!installer.Create())
return 0;
if (!stricmp(lpCmdLine, "AutoDownload"))
installer.SetAutoDownload();
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
if (!jvBaseDlg::IsDialogMessage(&msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return 0;
}

186
Sources/Plasma/Apps/plPlasmaUpdate/plFileGrabber.cpp

@ -1,186 +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==*/
#include "plFileGrabber.h"
/* Not needed currently - if we want it again we'll have to reimplement HTTP comm
plHttpFileGrabber::plHttpFileGrabber()
{
fRequestMgr.SetHostname("");
}
bool plHttpFileGrabber::FileToStream(const char* path, hsStream* stream)
{
std::string pathStr(path);
bool retVal = fRequestMgr.GetFileToStream(path, stream);
stream->SetPosition(0);
return retVal;
}
void plHttpFileGrabber::SetServer(const char* server)
{
std::string serverPath(server);
fRequestMgr.SetHostname(serverPath);
}
void plHttpFileGrabber::MakeProperPath(char* path)
{
char* slash = NULL;
do {
slash = strchr(path, '\\');
if (slash)
*slash = '/';
} while(slash != NULL);
}
void plHttpFileGrabber::SetUsernamePassword(const std::string& username, const std::string& password)
{
fRequestMgr.SetUsername(username);
fRequestMgr.SetPassword(password);
}
bool plHttpFileGrabber::IsServerAvailable(const char* serverName)
{
bool retVal = false;
HINTERNET hInternet = InternetOpen("Parable Patcher",INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0);
if (hInternet)
{
HINTERNET hHttp = InternetConnect(hInternet,serverName,8080,fUserName.c_str(),fPassword.c_str(),INTERNET_SERVICE_HTTP,0,0);
if (hHttp)
{
HINTERNET hRequest = HttpOpenRequest(hHttp, "GET", "/Current/Current.txt", NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_KEEP_CONNECTION, 0);
if (hRequest)
{
DWORD dwCode;
DWORD dwSize = sizeof(dwCode);
HttpSendRequest(hRequest, NULL, 0, NULL, 0);
HttpQueryInfo(hRequest, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &dwCode, &dwSize, NULL);
if (dwCode >= 200 && dwCode < 300)
{
retVal = true;
}
InternetCloseHandle(hRequest);
}
InternetCloseHandle(hHttp);
}
InternetCloseHandle(hInternet);
}
return retVal;
}
*/
plNetShareFileGrabber::plNetShareFileGrabber()
{
}
#define BUFFER_SIZE 1024*1024
bool plNetShareFileGrabber::FileToStream(const char* path, hsStream* stream)
{
hsUNIXStream fileStream;
std::string filePath = fServerName + path;
if (fileStream.Open(filePath.c_str()))
{
char* buffer = new char[BUFFER_SIZE];
uint32_t streamSize = fileStream.GetSizeLeft();
while (streamSize > (BUFFER_SIZE))
{
fileStream.Read(BUFFER_SIZE, buffer);
stream->Write(BUFFER_SIZE, buffer);
streamSize = fileStream.GetSizeLeft();
}
if (streamSize > 0)
{
fileStream.Read(streamSize, buffer);
stream->Write(streamSize, buffer);
}
stream->Rewind();
fileStream.Close();
delete [] buffer;
return true;
}
return false;
}
void plNetShareFileGrabber::SetServer(const char* server)
{
fServerName = "\\\\";
fServerName += server;
}
void plNetShareFileGrabber::MakeProperPath(char* path)
{
char* slash = NULL;
do {
slash = strchr(path, '/');
if (slash)
*slash = '\\';
} while(slash != NULL);
}
bool plNetShareFileGrabber::IsServerAvailable(const char* serverName, const char* currentDir)
{
bool retVal = false;
char serverPath[MAX_PATH];
sprintf(serverPath, "\\\\%s\\%s\\Current.txt", serverName, currentDir);
hsUNIXStream si;
if (si.Open(serverPath, "rb"))
{
retVal = true;
si.Close();
}
return retVal;
}

89
Sources/Plasma/Apps/plPlasmaUpdate/plFileGrabber.h

@ -1,89 +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==*/
#ifndef plFileGrabber_h_inc
#define plFileGrabber_h_inc
#include <string>
#include "hsStream.h"
class plFileGrabber
{
public:
virtual bool IsServerAvailable(const char* serverName, const char* currentDir) = 0;
virtual bool FileToStream(const char* path, hsStream* stream) = 0;
virtual void SetServer(const char* server) = 0;
virtual void MakeProperPath(char* path) = 0;
virtual bool NeedsAuth() { return false; }
virtual void SetUsernamePassword(const std::string& username, const std::string& password) {}
};
/* Not needed currently - if we want it again we'll have to reimplement HTTP comm
class plHttpFileGrabber : public plFileGrabber
{
private:
plHttpDiverseRequestMgr fRequestMgr;
public:
plHttpFileGrabber();
virtual bool IsServerAvailable(const char* serverName);
virtual bool FileToStream(const char* path, hsStream* stream);
virtual void SetServer(const char* server);
virtual void MakeProperPath(char* path);
virtual bool NeedsAuth() { return true; }
virtual void SetUsernamePassword(const std::string& username, const std::string& password);
};
*/
class plNetShareFileGrabber : public plFileGrabber
{
private:
std::string fServerName;
public:
plNetShareFileGrabber();
virtual bool IsServerAvailable(const char* serverName, const char* currentDir);
virtual bool FileToStream(const char* path, hsStream* stream);
virtual void SetServer(const char* server);
virtual void MakeProperPath(char* path);
};
#endif

361
Sources/Plasma/Apps/plPlasmaUpdate/plManifest.cpp

@ -1,361 +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==*/
#include "HeadSpin.h"
#include "plManifest.h"
#include "../pnEncryption/plChecksum.h"
#include "../plCompression/plZlibStream.h"
#include "../plFile/plEncryptedStream.h"
#include "../plFile/plFileUtils.h"
#include "../plUnifiedTime/plUnifiedTime.h"
class plManifestFile
{
public:
char* fFilename;
plMD5Checksum fSum;
plMD5Checksum fLocalSum;
uint32_t fSize;
uint32_t fCompressedSize;
uint32_t fFlags;
};
plManifest::plManifest(LogFunc log) :
fDownloadFiles(0),
fDownloadBytes(0),
fDirtySums(false),
fLog(log)
{
}
plManifest::~plManifest()
{
if (fDirtySums)
IWriteCache();
delete [] fManifestName;
for (int i = 0; i < fFiles.size(); i++)
{
delete [] fFiles[i]->fFilename;
delete fFiles[i];
}
}
bool plManifest::Read(hsStream* mfsStream, const char* basePath, const char* mfsName)
{
fBasePath = basePath;
fManifestName = hsStrcpy(mfsName);
fLog("--- Reading manifest for %s", fManifestName);
char buf[256];
while (mfsStream->ReadLn(buf, sizeof(buf)))
{
plManifestFile* file = new plManifestFile;
char* tok = strtok(buf, "\t");
file->fFilename = hsStrcpy(tok);
tok = strtok(nil, "\t");
file->fSum.SetFromHexString(tok);
tok = strtok(nil, "\t");
file->fSize = atoi(tok);
tok = strtok(nil, "\t");
file->fCompressedSize = atoi(tok);
tok = strtok(nil, "\t");
file->fFlags = atoi(tok);
fFiles.push_back(file);
}
return true;
}
void plManifest::ValidateFiles(ProgressFunc progress)
{
if (fFiles.empty())
return;
fLog("--- Validating files for %s", fManifestName);
IReadCache(progress);
fDownloadFiles = 0;
fDownloadBytes = 0;
for (int i = 0; i < fFiles.size(); i++)
{
plManifestFile* file = fFiles[i];
// If the local checksum is invalid, this file wasn't in our cache.
// Get the sum, and update the progress bar.
if (!file->fLocalSum.IsValid())
{
fLog(" No sum for %s, calculating", file->fFilename);
file->fLocalSum.CalcFromFile(file->fFilename);
fDirtySums = true;
progress(file->fFilename, 1);
}
if (file->fLocalSum != file->fSum)
{
fLog(" Incorrect sum for %s", file->fFilename);
fDownloadFiles++;
fDownloadBytes += file->fCompressedSize;
}
}
fLog("--- Need to download %d files, %.1f MB", fDownloadFiles, float(fDownloadBytes) / (1024.f*1024.f));
}
void plManifest::DownloadUpdates(ProgressFunc progress, plFileGrabber* grabber)
{
for (int i = 0; i < fFiles.size(); i++)
{
plManifestFile* file = fFiles[i];
if (file->fLocalSum != file->fSum)
{
char serverPath[MAX_PATH];
sprintf(serverPath, "%s%s.gz", fBasePath.c_str(), file->fFilename);
grabber->MakeProperPath(serverPath);
hsRAMStream serverStream;
if (grabber->FileToStream(serverPath, &serverStream))
{
plFileUtils::EnsureFilePathExists(file->fFilename);
plFileUtils::RemoveFile(file->fFilename, true);
plZlibStream localStream;
if (localStream.Open(file->fFilename, "wb"))
{
char dataBuf[1024];
uint32_t sizeLeft = serverStream.GetSizeLeft();
while (uint32_t amtRead = serverStream.Read( (sizeof(dataBuf) > sizeLeft) ? sizeLeft : sizeof(dataBuf), dataBuf))
{
progress(file->fFilename, amtRead);
localStream.Write(amtRead, dataBuf);
sizeLeft = serverStream.GetSizeLeft();
}
localStream.Close();
// FIXME - Should we recalc this?
file->fLocalSum = file->fSum;
fDirtySums = true;
if (file->fFlags != 0)
IDecompressSound(file);
}
}
}
}
}
plManifestFile* plManifest::IFindFile(const char* name)
{
// FIXME
for (int i = 0; i < fFiles.size(); i++)
{
if (hsStrEQ(fFiles[i]->fFilename, name))
return fFiles[i];
}
return nil;
}
// KLUDGE - Put age checksums in the dat dir, for backwards compatability
const char* plManifest::IGetCacheDir()
{
const char* prefix = "";
if (strncmp(fFiles[0]->fFilename, "dat\\", strlen("dat\\")) == 0)
return "dat\\";
else
return "";
}
#define kCacheFileVersion 1
void plManifest::IWriteCache()
{
plEncryptedStream s;
bool openedFile = false;
uint32_t numFiles = 0;
for (int i = 0; i < fFiles.size(); i++)
{
plManifestFile* file = fFiles[i];
plUnifiedTime modifiedTime;
if (file->fLocalSum.IsValid() &&
plFileUtils::GetFileTimes(file->fFilename, nil, &modifiedTime))
{
if (!openedFile)
{
openedFile = true;
char buf[256];
sprintf(buf, "%s%s.sum", IGetCacheDir(), fManifestName);
s.Open(buf, "wb");
s.WriteSwap32(0);
s.WriteSwap32(kCacheFileVersion);
}
s.WriteSafeString(file->fFilename);
plMD5Checksum& checksum = file->fLocalSum;
s.Write(checksum.GetSize(), checksum.GetValue());
modifiedTime.Write(&s);
numFiles++;
}
}
if (openedFile)
{
s.Rewind();
s.WriteSwap32(numFiles);
s.Close();
}
}
void plManifest::IReadCache(ProgressFunc progress)
{
//
// Load valid cached checksums
//
char buf[256];
sprintf(buf, "%s%s.sum", IGetCacheDir(), fManifestName);
hsStream* s = plEncryptedStream::OpenEncryptedFile(buf);
if (s)
{
uint32_t numCached = s->ReadSwap32();
uint32_t cacheFileVersion = s->ReadSwap32();
if (cacheFileVersion != kCacheFileVersion)
{
s->Close();
delete s;
return;
}
fLog(" Reading cache...found %d cached sums", numCached);
for (int i = 0; i < numCached; i++)
{
char* name = s->ReadSafeString();
uint8_t checksumBuf[MD5_DIGEST_LENGTH];
s->Read(sizeof(checksumBuf), checksumBuf);
plMD5Checksum checksum;
checksum.SetValue(checksumBuf);
plUnifiedTime modifiedTime;
modifiedTime.Read(s);
plManifestFile* file = IFindFile(name);
if (file)
{
plUnifiedTime curModifiedTime;
if (plFileUtils::GetFileTimes(file->fFilename, nil, &curModifiedTime))
{
if (curModifiedTime == modifiedTime)
file->fLocalSum = checksum;
else
fLog(" Invalid modified time for %s", name);
}
else
fLog(" Couldn't get modified time for %s", name);
progress(file->fFilename, 1);
}
else
fLog(" Couldn't find cached file '%s' in manifest, discarding", name);
delete [] name;
}
s->Close();
delete s;
}
}
#include "../plAudioCore/plAudioFileReader.h"
#include "../plAudio/plOGGCodec.h"
#include "../plAudio/plWavFile.h"
bool plManifest::IDecompressSound(plManifestFile* file)
{
enum
{
kSndFlagCacheSplit = 1<<0,
kSndFlagCacheStereo = 1<<2,
};
if (hsCheckBits(file->fFlags, kSndFlagCacheSplit) ||
hsCheckBits(file->fFlags, kSndFlagCacheStereo))
{
plAudioFileReader* reader = plAudioFileReader::CreateReader(file->fFilename, plAudioCore::kAll, plAudioFileReader::kStreamNative);
if (!reader)
return false;
uint32_t size = reader->GetDataSize();
delete reader;
if (hsCheckBits(file->fFlags, kSndFlagCacheSplit))
plAudioFileReader::CacheFile(file->fFilename, true);
if (hsCheckBits(file->fFlags, kSndFlagCacheStereo))
plAudioFileReader::CacheFile(file->fFilename, false);
}
return true;
}

93
Sources/Plasma/Apps/plPlasmaUpdate/plManifest.h

@ -1,93 +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==*/
#ifndef plManifest_h_inc
#define plManifest_h_inc
#include "HeadSpin.h"
#include "plFileGrabber.h"
#include <vector>
#include <string>
class plManifestFile;
typedef void (*ProgressFunc)(const char* name, int progDelta);
typedef void (*LogFunc)(const char* format, ...);
class plManifest
{
protected:
std::string fBasePath;
char* fManifestName;
typedef std::vector<plManifestFile*> FileVec;
FileVec fFiles;
uint32_t fDownloadFiles;
uint32_t fDownloadBytes;
bool fDirtySums;
LogFunc fLog;
bool IDecompressSound(plManifestFile* file);
plManifestFile* IFindFile(const char* name);
const char* IGetCacheDir();
void IReadCache(ProgressFunc progress);
void IWriteCache();
public:
plManifest(LogFunc log);
~plManifest();
bool Read(hsStream* mfsStream, const char* basePath, const char* mfsName);
void ValidateFiles(ProgressFunc progress);
void DownloadUpdates(ProgressFunc progress, plFileGrabber* grabber);
int NumFiles() { return fFiles.size(); }
uint32_t NumDownloadFiles() { return fDownloadFiles; }
uint32_t DownloadSize() { return fDownloadBytes; }
};
#endif // plManifest_h_inc

94
Sources/Plasma/Apps/plPlasmaUpdate/plPlasmaServers.cpp

@ -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==*/
#include "plPlasmaServers.h"
#include "hsStream.h"
bool plPlasmaServers::GetServerInfo()
{
bool ret = true;
hsUNIXStream si;
if (si.Open("\\\\dirtcake\\ServerInfo\\ServerInfo.txt", "rb"))
{
char line[256];
// Make sure we've got the latest version
if (si.ReadLn(line, sizeof(line)))
{
int version = atoi(line);
si.ReadLn(line, sizeof(line));
if (version != 4)
{
char errorMsg[512];
sprintf(errorMsg, "This installer is out of date.\nPlease get the latest version from:\n\n%s", line);
hsMessageBox(errorMsg, "Error", hsMessageBoxNormal, hsMessageBoxIconError);
ret = false;
}
}
else
ret = false;
// Read in the servers, one per line
while (ret && si.ReadLn(line, sizeof(line)))
{
ServerInfo info;
info.fServerAddress = strtok(line, ",");
info.fServerName = strtok(nil, ",");
info.fURLBase = strtok(nil, ",");
info.fOutputDir = strtok(nil, ",");
info.fCurrentDir = strtok(nil, ",");
info.fCodeDir = strtok(nil, ",");
fServers.push_back(info);
}
si.Close();
}
else
{
hsMessageBox("Couldn't find server info", "Error", hsMessageBoxNormal, hsMessageBoxIconError);
ret = false;
}
return ret;
}

75
Sources/Plasma/Apps/plPlasmaUpdate/plPlasmaServers.h

@ -1,75 +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==*/
#ifndef plPlasmaServers_h_inc
#define plPlasmaServers_h_inc
#include "HeadSpin.h"
#include <vector>
class plPlasmaServers
{
protected:
class ServerInfo
{
public:
std::string fServerAddress;
std::string fServerName;
std::string fURLBase;
std::string fOutputDir;
std::string fCurrentDir;
std::string fCodeDir;
};
std::vector<ServerInfo> fServers;
public:
bool GetServerInfo();
int GetNumServers() { return fServers.size(); }
std::string& GetServerAddress(int i) { return fServers[i].fServerAddress; }
std::string& GetServerName(int i) { return fServers[i].fServerName; }
std::string& GetServerURLBase(int i) { return fServers[i].fURLBase; }
std::string& GetServerOutputDir(int i) { return fServers[i].fOutputDir; }
std::string& GetServerCurrentDir(int i) { return fServers[i].fCurrentDir; }
std::string& GetServerCodeDir(int i) { return fServers[i].fCodeDir; }
};
#endif // plPlasmaServers_h_inc

514
Sources/Plasma/Apps/plPlasmaUpdate/plPlasmaUpdate.cpp

@ -1,514 +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==*/
#include "HeadSpin.h"
#include "plPlasmaUpdate.h"
#include "resource.h"
#include <windowsx.h>
#include <commctrl.h>
#include <direct.h>
#include "jvCoreUtil.h"
#include "jvDialogResizer.h"
#include "hsTypes.h"
#include "../plFile/plFileUtils.h"
#include "../plUnifiedTime/plUnifiedTime.h"
#include "hsStream.h"
#include "plManifest.h"
#include "../plStatusLog/plStatusLog.h"
static plPlasmaUpdate* gInst = nil;
#define WM_UPDATE_SERVER WM_APP+1
std::string plPlasmaUpdate::fUserName = "dataserver";
std::string plPlasmaUpdate::fPassword = "parabledata";
plPlasmaUpdate::plPlasmaUpdate() : fCanExit(true), fProgressType(kValidating), fResizer(nil), fAutoDownload(false)
{
INITCOMMONCONTROLSEX icc = {0};
icc.dwSize = sizeof(INITCOMMONCONTROLSEX);
icc.dwICC = ICC_PROGRESS_CLASS;
InitCommonControlsEx(&icc);
gInst = this;
_getcwd(fIniPath, sizeof(fIniPath));
char lastChar = fIniPath[strlen(fIniPath)];
if (lastChar != '\\' && lastChar != '/')
strcat(fIniPath, "\\");
strcat(fIniPath, "ParableUpdate.ini");
fFileGrabber = new plNetShareFileGrabber;
}
plPlasmaUpdate::~plPlasmaUpdate()
{
delete fResizer;
if (fFileGrabber)
delete fFileGrabber;
}
bool plPlasmaUpdate::Create()
{
if (!fServers.GetServerInfo())
return false;
ICreateDialog(IDD_UPDATE, NULL);
return true;
}
BOOL CALLBACK plPlasmaUpdate::ILoginWinProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch( msg )
{
case WM_INITDIALOG:
SetFocus(GetDlgItem(hDlg, IDC_USERNAME));
break;
case WM_COMMAND:
if (HIWORD(wParam) == BN_CLICKED && (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL))
{
bool ok = (LOWORD(wParam) == IDOK);
if (ok)
{
char username[25];
char password[25];
GetDlgItemText(hDlg, IDC_USERNAME, username, 25);
GetDlgItemText(hDlg, IDC_PASSWORD, password, 25);
fUserName = username;
hsAssert(false, "who uses this program?");
// plChallengeResponse::HashPassword(password, fPassword);
}
EndDialog(hDlg, ok);
return TRUE;
}
break;
}
return FALSE;
}
void plPlasmaUpdate::IInit()
{
char curServerAddress[256];
GetPrivateProfileString("PlasmaUpdate", "ServerAddress", "", curServerAddress, sizeof(curServerAddress), fIniPath);
bool external = (GetPrivateProfileInt("PlasmaUpdate", "External", 0, fIniPath) != 0);
HWND hCombo = GetDlgItem(fDlg, IDC_BUILD_COMBO);
for (int i = 0; i < fServers.GetNumServers(); i++)
{
std::string& serverAddress = fServers.GetServerAddress(i);
std::string& serverName = fServers.GetServerName(i);
std::string& currentDir = fServers.GetServerCurrentDir(i);
if (!fFileGrabber->IsServerAvailable(serverAddress.c_str(), currentDir.c_str()))
continue;
bool thisServer = (serverAddress == curServerAddress);
int idx = ComboBox_AddString(hCombo, serverName.c_str());
ComboBox_SetItemData(hCombo, idx, MAKELPARAM(i, 0));
if (thisServer && !external)
ComboBox_SetCurSel(hCombo, idx);
std::string extName = serverName + " (External)";
idx = ComboBox_AddString(hCombo, extName.c_str());
ComboBox_SetItemData(hCombo, idx, MAKELPARAM(i, 1));
if (thisServer && external)
ComboBox_SetCurSel(hCombo, idx);
}
if (ComboBox_GetCurSel(hCombo) == -1)
ComboBox_SetCurSel(hCombo, 0);
SendMessage(fDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(jvCoreUtil::GetHInstance(), MAKEINTRESOURCE(IDI_ICON)));
SendMessage(fDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(jvCoreUtil::GetHInstance(), MAKEINTRESOURCE(IDI_ICON)));
fResizer = new jvDialogResizer(fDlg);
fResizer->AddControl(IDC_BUILD_COMBO, jvDialogResizer::kResizeX);
fResizer->AddControl(IDC_STATUS_LIST, jvDialogResizer::kResizeX | jvDialogResizer::kResizeY);
fResizer->AddControl(IDC_PROGRESS, jvDialogResizer::kLockBottom | jvDialogResizer::kResizeX);
fResizer->AddControl(IDC_DL_TEXT, jvDialogResizer::kLockBottom | jvDialogResizer::kResizeX);
fResizer->AddControl(IDC_DL_BUTTON, jvDialogResizer::kLockBottom | jvDialogResizer::kCenterX);
fResizer->SetSize(360, 320);
fResizer->LoadPosAndSize("PlasmaUpdate");
bool goTime = true;
if (fFileGrabber->NeedsAuth())
{
/*
if (!DialogBox(NULL, MAKEINTRESOURCE(IDD_PLASMAUPDATE_LOGIN), fDlg, ILoginWinProc))
goTime = false;
else
*/
fFileGrabber->SetUsernamePassword(fUserName, fPassword);
}
if (goTime)
{
ShowWindow(fDlg, SW_SHOW);
PostMessage(fDlg, WM_UPDATE_SERVER, 0, 0);
}
else
PostQuitMessage(0);
}
void plPlasmaUpdate::IShutdown()
{
fResizer->SavePosAndSize("PlasmaUpdate");
delete fResizer;
fResizer = NULL;
IDeleteManifests();
}
void plPlasmaUpdate::IEnableCtrls(bool enable)
{
fCanExit = enable;
EnableWindow(GetDlgItem(fDlg, IDC_BUILD_COMBO), enable);
HWND hDlButton = GetDlgItem(fDlg, IDC_DL_BUTTON);
if (fManifests.empty())
SetWindowText(hDlButton, "Close");
else
SetWindowText(hDlButton, "Download");
EnableWindow(hDlButton, enable);
if (enable)
SetFocus(hDlButton);
}
void plPlasmaUpdate::IDeleteManifests()
{
for (int i = 0; i < fManifests.size(); i++)
delete fManifests[i];
fManifests.clear();
}
bool plPlasmaUpdate::IGetManifests(const char* serverRoot, bool external)
{
IDeleteManifests();
char filePath[MAX_PATH];
sprintf(filePath, "%sCurrent.txt", serverRoot);
enum Sections
{
kVersion,
kInternal,
kExternal,
kAll
};
int curSection = kVersion;
hsRAMStream s;
hsRAMStream manifestStream;
if (fFileGrabber->FileToStream(filePath, &s))
{
char buf[256];
while (s.ReadLn(buf, sizeof(buf)))
{
if (buf[0] == '[')
{
if (hsStrEQ(buf, "[Version]"))
curSection = kVersion;
else if (hsStrEQ(buf, "[Internal]"))
curSection = kInternal;
else if (hsStrEQ(buf, "[External]"))
curSection = kExternal;
else if (hsStrEQ(buf, "[All]"))
curSection = kAll;
}
else
{
if (curSection == kVersion)
{
int version = atoi(buf);
if (version != 1)
{
hsMessageBox("Your copy of PlasmaUpdate is out of date.\nPlease get the latest version.", "Error", hsMessageBoxNormal, hsMessageBoxIconError);
return false;
}
}
else if ((!external && curSection == kInternal)
|| (external && curSection == kExternal)
|| curSection == kAll)
{
//if (curSection == kAll && !(!strcmp(buf, "Data\\Movies.mfs") || !strcmp(buf, "Data\\Sounds.mfs")))
// continue;
sprintf(filePath, "%s%s", serverRoot, buf);
fFileGrabber->MakeProperPath(filePath);
manifestStream.Reset();
fFileGrabber->FileToStream(filePath, &manifestStream);
plFileUtils::StripFile(filePath);
plManifest* manifest = new plManifest(ILog);
manifest->Read(&manifestStream, filePath, buf);
fManifests.push_back(manifest);
}
}
}
return true;
}
return false;
}
void plPlasmaUpdate::IUpdateServer()
{
char buf[256];
IEnableCtrls(false);
SetDlgItemText(fDlg, IDC_DL_TEXT, "Checking for updates...");
//
// Figure out what server we're checking
//
bool external = false;
char serverRoot[MAX_PATH];
{
HWND hCombo = GetDlgItem(fDlg, IDC_BUILD_COMBO);
int idx = ComboBox_GetCurSel(hCombo);
LPARAM data = ComboBox_GetItemData(hCombo, idx);
int server = LOWORD(data);
external = (HIWORD(data) != 0);
sprintf(serverRoot, "/%s/", fServers.GetServerCurrentDir(server).c_str());
const char* serverName = fServers.GetServerAddress(server).c_str();
ILog("===== Server set to %s %s =====", serverName, external ? "external" : "internal");
WritePrivateProfileString("PlasmaUpdate", "ServerAddress", serverName, fIniPath);
WritePrivateProfileString("PlasmaUpdate", "External", external ? "1" : "0", fIniPath);
fFileGrabber->SetServer(serverName);
}
//
// Get the latest publish notes
//
{
HWND hList = GetDlgItem(fDlg, IDC_STATUS_LIST);
ListBox_ResetContent(hList);
char updateFile[MAX_PATH];
if (external)
sprintf(updateFile, "%sUpdates-External.txt", serverRoot);
else
sprintf(updateFile, "%sUpdates-Internal.txt", serverRoot);
hsRAMStream updates;
fFileGrabber->MakeProperPath(updateFile);
if (fFileGrabber->FileToStream(updateFile, &updates))
{
while (updates.ReadLn(buf, sizeof(buf)))
ListBox_InsertString(hList, 0, buf);
}
}
//
// Get the manifests
//
bool gotManifests = IGetManifests(serverRoot, external);
uint32_t dlSize = 0;
fProgressType = kValidating;
if (gotManifests)
{
int i;
uint32_t numFiles = 0;
for (i = 0; i < fManifests.size(); i++)
numFiles += fManifests[i]->NumFiles();
HWND hProgress = GetDlgItem(fDlg, IDC_PROGRESS);
SendMessage(hProgress, PBM_SETRANGE32, 0, numFiles);
for (i = 0; i < fManifests.size(); i++)
{
fManifests[i]->ValidateFiles(ProgressFunc);
dlSize += fManifests[i]->DownloadSize();
}
SendMessage(hProgress, PBM_SETPOS, 0, 0);
}
// Print how many megs there are to download
if (dlSize == 0)
{
strcpy(buf, "No updates to download");
IDeleteManifests();
}
else
{
float dlMegs = float(dlSize) / (1024.f*1024.f);
if (dlMegs < .1)
dlMegs = .1;
sprintf(buf, "%.1f MB of updates to download", dlMegs);
}
SetDlgItemText(fDlg, IDC_DL_TEXT, buf);
IEnableCtrls(true);
if (fAutoDownload)
PostMessage(fDlg, WM_COMMAND, MAKEWPARAM(IDC_DL_BUTTON, BN_CLICKED), LPARAM(GetDlgItem(fDlg, IDC_DL_BUTTON)));
}
void plPlasmaUpdate::IDownloadUpdates()
{
fProgressType = kDownloading;
IEnableCtrls(false);
int i;
uint32_t dlSize = 0;
for (i = 0; i < fManifests.size(); i++)
dlSize += fManifests[i]->DownloadSize();
HWND hProgress = GetDlgItem(fDlg, IDC_PROGRESS);
SendMessage(hProgress, PBM_SETRANGE32, 0, dlSize);
for (i = 0; i < fManifests.size(); i++)
fManifests[i]->DownloadUpdates(ProgressFunc, fFileGrabber);
SendMessage(hProgress, PBM_SETPOS, 0, 0);
EnableWindow(GetDlgItem(fDlg, IDC_DL_BUTTON), false);
SetDlgItemText(fDlg, IDC_DL_TEXT, "No updates to download");
IDeleteManifests();
IEnableCtrls(true);
if (fAutoDownload)
PostMessage(fDlg, WM_COMMAND, MAKEWPARAM(IDC_DL_BUTTON, BN_CLICKED), LPARAM(GetDlgItem(fDlg, IDC_DL_BUTTON)));
}
void plPlasmaUpdate::ProgressFunc(const char* name, int delta)
{
static const char* lastName = nil;
if (lastName != name)
{
lastName = name;
char buf[256];
if (gInst->fProgressType == kValidating)
strcpy(buf, "Checking ");
else
strcpy(buf, "Downloading ");
strcat(buf, name);
SetDlgItemText(gInst->fDlg, IDC_DL_TEXT, buf);
}
SendDlgItemMessage(gInst->fDlg, IDC_PROGRESS, PBM_DELTAPOS, delta, 0);
jvBaseDlg::PumpQueue();
}
void plPlasmaUpdate::ILog(const char* format, ...)
{
static plStatusLog* log = nil;
if (!log)
log = plStatusLogMgr::GetInstance().CreateStatusLog(0, "PlasmaUpdate.log");
va_list args;
va_start(args, format);
log->AddLineV(format, args);
va_end(args);
}
BOOL plPlasmaUpdate::IDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_INITDIALOG:
IInit();
SetFocus(GetDlgItem(fDlg, IDC_DL_BUTTON));
return FALSE;
case WM_CLOSE:
if (fCanExit)
DestroyWindow(hDlg);
return TRUE;
case WM_DESTROY:
IShutdown();
PostQuitMessage(0);
return TRUE;
case WM_COMMAND:
if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_DL_BUTTON)
{
if (fManifests.empty())
SendMessage(fDlg, WM_CLOSE, 0, 0);
else
IDownloadUpdates();
return TRUE;
}
else if (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_BUILD_COMBO)
{
IUpdateServer();
return TRUE;
}
break;
case WM_UPDATE_SERVER:
IUpdateServer();
return TRUE;
}
return FALSE;
}

94
Sources/Plasma/Apps/plPlasmaUpdate/plPlasmaUpdate.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==*/
#include "hsTypes.h"
#include "jvBaseDlg.h"
#include <vector>
#include <string>
#include "plPlasmaServers.h"
#include "plFileGrabber.h"
class plManifest;
class jvDialogResizer;
class plPlasmaUpdate : public jvBaseDlg
{
protected:
static BOOL CALLBACK ILoginWinProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
static std::string fUserName;
static std::string fPassword;
std::vector<plManifest*> fManifests;
char fIniPath[MAX_PATH];
bool fCanExit;
enum ProgressType { kValidating, kDownloading };
ProgressType fProgressType;
jvDialogResizer* fResizer;
plPlasmaServers fServers;
bool fAutoDownload;
plFileGrabber* fFileGrabber;
void IInit();
void IShutdown();
bool IReadServerInfo();
void IEnableCtrls(bool enable);
BOOL IDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
static void ProgressFunc(const char* name, int delta);
static void ILog(const char* format, ...);
void IUpdateServer();
void IDeleteManifests();
bool IGetManifests(const char* serverRoot, bool external);
void IDownloadUpdates();
public:
plPlasmaUpdate();
virtual ~plPlasmaUpdate();
bool Create();
void SetAutoDownload() { fAutoDownload = true; }
};

131
Sources/Plasma/Apps/plPlasmaUpdate/plPlasmaUpdate.rc

@ -1,131 +0,0 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#define IDC_STATIC (-1) // all static controls
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_UPDATE DIALOGEX 0, 0, 128, 105
STYLE DS_SETFONT | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU |
WS_THICKFRAME
CAPTION "Parable Update"
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
LTEXT "Build:",IDC_STATIC,7,8,18,8
COMBOBOX IDC_BUILD_COMBO,27,6,90,167,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
DEFPUSHBUTTON "Download",IDC_DL_BUTTON,34,86,56,16,WS_DISABLED
LISTBOX IDC_STATUS_LIST,7,36,110,11,LBS_NOINTEGRALHEIGHT |
LBS_NOSEL | WS_VSCROLL | WS_TABSTOP
CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",WS_BORDER |
0x1,7,54,110,16
LTEXT "Latest Updates:",IDC_STATIC,7,26,51,8
CONTROL "xx.x MB of updates to download",IDC_DL_TEXT,"Static",
SS_LEFTNOWORDWRAP | WS_GROUP,7,74,110,8
END
IDD_PLASMAUPDATE_LOGIN DIALOGEX 0, 0, 150, 102
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Login"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,48,62,50,14
PUSHBUTTON "Cancel",IDCANCEL,48,80,50,14
EDITTEXT IDC_USERNAME,7,17,135,12,ES_AUTOHSCROLL
EDITTEXT IDC_PASSWORD,7,45,135,12,ES_PASSWORD | ES_AUTOHSCROLL
LTEXT "Username",IDC_STATIC,7,7,134,8
LTEXT "Password",IDC_STATIC,7,35,136,10
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_UPDATE, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 121
TOPMARGIN, 7
BOTTOMMARGIN, 98
END
IDD_PLASMAUPDATE_LOGIN, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 143
TOPMARGIN, 7
BOTTOMMARGIN, 95
END
END
#endif // APSTUDIO_INVOKED
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON ICON "Dirt.ICO"
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

27
Sources/Plasma/Apps/plPlasmaUpdate/resource.h

@ -1,27 +0,0 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by plPlasmaUpdate.rc
//
#define IDD_UPDATE 101
#define IDI_ICON1 102
#define IDI_ICON 102
#define IDD_PLASMAUPDATE_LOGIN 103
#define IDC_DL_BUTTON 1005
#define IDC_STATUS_LIST 1006
#define IDC_BUILD_COMBO 1008
#define IDC_PROGRESS 1014
#define IDC_DL_TEXT 1015
#define IDC_EDIT1 1016
#define IDC_USERNAME 1016
#define IDC_PASSWORD 1017
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 104
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1018
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

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)

4
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)
@ -17,9 +16,6 @@ add_subdirectory(pfJournalBook)
# pfKI is apparently just a historical oddity at this point
# add_subdirectory(pfKI)
add_subdirectory(pfLocalizationMgr)
# This is missing required parts in other plasma libraries.
# Also not referenced by any sln file
# add_subdirectory(pfLoginDialog)
add_subdirectory(pfMessage)
add_subdirectory(pfPython)
add_subdirectory(pfSecurePreloader)

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

23
Sources/Plasma/FeatureLib/pfLoginDialog/CMakeLists.txt

@ -1,23 +0,0 @@
include_directories(../../CoreLib)
include_directories(../../NucleusLib)
include_directories(../../NucleusLib/inc)
include_directories(../../PubUtilLib)
set(pfLoginDialog_SOURCES
plLoginDialog.cpp
)
set(pfLoginDialog_HEADERS
plLoginDialog.h
resource.h
)
set(pfLoginDialog_RESOURCES
pfLoginDialog.rc
)
add_library(pfLoginDialog STATIC ${pfLoginDialog_SOURCES} ${pfLoginDialog_HEADERS} ${pfLoginDialog_RESOURCES})
source_group("Source Files" FILES ${pfLoginDialog_SOURCES})
source_group("Header Files" FILES ${pfLoginDialog_HEADERS})
source_group("Resource Files" FILES ${pfLoginDialog_RESOURCES})

103
Sources/Plasma/FeatureLib/pfLoginDialog/pfLoginDialog.rc

@ -1,103 +0,0 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#define IDC_STATIC (-1) // all static controls
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_DIALOG_LOGIN DIALOGEX 0, 0, 186, 114
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
EXSTYLE WS_EX_CONTROLPARENT
CAPTION "Login"
FONT 8, "Tahoma"
BEGIN
EDITTEXT IDC_LOGIN_USERNAME,55,7,98,12,ES_AUTOHSCROLL
EDITTEXT IDC_LOGIN_PASSWORD,55,23,98,12,ES_PASSWORD |
ES_AUTOHSCROLL
COMBOBOX IDC_LOGIN_LOBBYLIST,55,39,98,76,CBS_DROPDOWN |
CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
DEFPUSHBUTTON "Login",IDC_LOGIN_LOGIN,41,58,50,14
PUSHBUTTON "Cancel",IDC_LOGIN_CANCEL,94,58,50,14
LTEXT "Account:",IDC_STATIC,21,9,30,8,0,WS_EX_RIGHT
LTEXT "Password:",IDC_STATIC,17,25,34,8,0,WS_EX_RIGHT
LTEXT "Server:",IDC_LOGIN_STATIC_SERVER,27,41,24,8,0,
WS_EX_RIGHT
PUSHBUTTON "?",IDC_SERVER_QUERY_BTN,157,39,22,13,NOT WS_VISIBLE
CONTROL "Remember Password",IDC_REMEMBER_PASSWORD,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,18,79,119,12
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_DIALOG_LOGIN, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 179
TOPMARGIN, 7
BOTTOMMARGIN, 107
END
END
#endif // APSTUDIO_INVOKED
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

672
Sources/Plasma/FeatureLib/pfLoginDialog/plLoginDialog.cpp

@ -1,672 +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==*/
#include "plLoginDialog.h"
#include "resource.h"
#include "plNetCommon/plNetCommonConstants.h"
#include "plNetMessage/plNetMessage.h"
// #include "plHttpServer/plHttpResponse.h"
#include "plSDL/plSDL.h"
#include "plFile/hsFiles.h"
#include "plNetMessage/plNetCommonMessage.h"
// 'this' : used in base member initializer list
#pragma warning(disable:4355)
#define kAuthTimedOut WM_USER+2
plLoginDialog::plLoginDialog( HWND parentWnd )
: plDialog(IDD_DIALOG_LOGIN)
, fParentWnd( parentWnd )
, fLoginBtn(this, IDC_LOGIN_LOGIN, plDelegate(this,(TDelegate)ILogin))
, fCancelBtn(this, IDC_LOGIN_CANCEL, plDelegate(this,(TDelegate)IExit))
, fAccountName(this,IDC_LOGIN_USERNAME)
, fPassword(this,IDC_LOGIN_PASSWORD)
, fLobbyList(this,IDC_LOGIN_LOBBYLIST)
, fLobbyText(this, IDC_LOGIN_STATIC_SERVER)
, fRememberPassword(this, IDC_REMEMBER_PASSWORD, plDelegate(this, (TDelegate)IOnRememberPwdChanged))
, fCancelled(false)
, fAutoLogin(false)
#ifndef PLASMA_EXTERNAL_RELEASE
, fServerQueryBtn(this, IDC_SERVER_QUERY_BTN)
#endif
{
fLobbyList.fSelectionEndOkDelegate = plDelegate(this,(TDelegate)SelectedLobbyChanged);
fLobbyList.fEditUpdateDelegate = plDelegate(this,(TDelegate)SelectedLobbyTextEdited);
fLobbyList.fKillFocusDelegate = plDelegate(this,(TDelegate)OnLobbyListLostFocus);
#ifndef PLASMA_EXTERNAL_RELEASE
fServerQueryBtn.fClickDelegate = plDelegate(this,(TDelegate)ServerQueryBtnClicked);
#endif
}
std::string plLoginDialog::MakeSafeLobbyServerName(const std::string & value)
{
return "";
}
void plLoginDialog::SelectedLobbyChanged()
{
fLobbyVal.SetValue(fLobbyList.GetValue().c_str());
fLobbyList.SetEdited(false);
}
void plLoginDialog::SelectedLobbyTextEdited()
{
fLobbyVal.SetValue(fLobbyList.GetValue().c_str());
fLobbyList.SetEdited(true);
}
// Ugh
#ifdef PLASMA_EXTERNAL_RELEASE
#include <time.h>
#endif
bool plLoginDialog::RefreshLobbyList()
{
fStatusBar.SetText(L"Refreshing lobby server list...");
plStringList lobbies;
std::vector<std::wstring> wLobbies;
GetLobbyList(lobbies);
// Strip off the shard name and just leave the address
for (int i = 0; i < lobbies.size(); i++)
{
std::string& str = lobbies[i];
std::string::size_type endofname = str.find('\t');
if (endofname != std::string::npos)
str.erase(str.begin() + endofname, str.end());
wchar_t *wLobby = hsStringToWString(str.c_str());
wLobbies.push_back(wLobby);
delete [] wLobby;
}
fLobbyList.Empty();
#ifdef PLASMA_EXTERNAL_RELEASE
// In release mode, put the user in a random lobby for rudimentary load balancing
int numLobbies = lobbies.size();
if (numLobbies > 0)
{
srand(time(NULL));
int rnum = rand();
int whichLobby = rnum % numLobbies;
fLobbyList.AddString(wLobbies[whichLobby].c_str());
}
fLobbyList.SetCurrent(0);
#else
if (AllowSinglePlayerLobby())
fLobbyList.AddString(L"Single Player");
fLobbyList.AddStrings(wLobbies);
wchar_t *wLobby = hsStringToWString(fLobbyVal.GetValue().c_str());
int index = fLobbyList.FindStringExact(wLobby);
if (index==LB_ERR && fLobbyVal.GetValue().length()>0)
{
fLobbyList.AddString(wLobby);
index = fLobbyList.FindStringExact(wLobby);
}
delete [] wLobby;
fLobbyList.SetCurrent((index!=LB_ERR)?index:0);
#endif // PLASMA_EXTERNAL_RELEASE
SelectedLobbyChanged();
fStatusBar.SetText(L"");
return true;
}
void plLoginDialog::OnLobbyListLostFocus()
{
std::string value = fLobbyList.GetValue();
if (value.length()==0)
{
fLobbyList.SetCurrent(0);
fLobbyList.SetValue(MakeSafeLobbyServerName(fLobbyList.GetValue()).c_str());
SelectedLobbyChanged();
}
}
#if 0
void plLoginDialog::UpdateCtrls()
{
bool networkEnabled = IsNetworkPlayEnabled();
bool loggedIn = GetLoggedIn();
bool loggingIn = GetLoggingIn();
bool loggedOut = GetLoggedOut();
if (!networkEnabled && (loggedIn || loggingIn))
{
Logout();
// these don't do anything. need to set the vars in fMainDIalog?
loggedIn = false;
loggingIn = false;
loggedOut = true;
}
}
#endif
bool plLoginDialog::IsNetworkPlayDisabled()
{
#ifdef PLASMA_EXTERNAL_RELEASE
return false;
#else
xtl::istring tmp = fLobbyVal.GetValue().c_str();
return (tmp.compare("single player")==0);
#endif
}
bool plLoginDialog::IsNetworkPlayEnabled()
{
return !IsNetworkPlayDisabled();
}
void plLoginDialog::OnInitDialog()
{
plDialog::OnInitDialog();
if ( fParentWnd )
SetParent( Handle(), fParentWnd );
fStatusBar.OpenWindow(this,true);
#ifdef PLASMA_EXTERNAL_RELEASE
fLobbyList.Show(false);
fLobbyText.Show(false);
#endif
#ifndef PLASMA_EXTERNAL_RELEASE
fServerQueryBtn.Show(true);
#endif
bool rememberPwd = (fRememberPasswordVal.GetValue()=="true");
fAccountName.SetValue(fAccountNameVal.GetValue().c_str());
if (rememberPwd)
{
int len = atoi(fPasswordLen.GetValue().c_str());
std::string fakePwd(len, '*');
fPassword.SetValue(fakePwd.c_str());
}
fRememberPassword.Check(rememberPwd);
RefreshLobbyList();
if ( fAutoLogin )
fLoginBtn.Click();
// SetForegroundWindow(*this);
}
bool plLoginDialog::Login()
{
int ret = DoModal();
if (ret<0)
{
hsAssert(false, xtl::format("plLoginDialog failed to initialize, err code %d, GetLastError %d",
ret, GetLastError()).c_str());
}
return (ret != 0);
}
void plLoginDialog::ILogin()
{
OnLoginClicked();
fAccountNameVal.SetValue(fAccountName.GetValue().c_str());
std::string pwd = fPassword.GetValue();
int pwdSize = pwd.size();
std::string fakePwd = "*" + std::string(pwdSize-1, '*');
if (pwd != fakePwd) // user has entered a real pwd
{
fPasswordLen.SetValue(xtl::format("%d",pwd.size()).c_str());
// MD5 HASH the pwd
std::string hex;
plChallengeResponse::HashPassword(pwd.c_str(), hex);
fPasswordVal.SetValue(hex.c_str());
}
SetDataServerUserName(true, fAccountNameVal.GetValue().c_str());
SetDataServerPassword(true, fPasswordVal.GetValue().c_str());
SetDataServerUserName(false, fAccountNameVal.GetValue().c_str());
SetDataServerPassword(false, fPasswordVal.GetValue().c_str());
if (IsNetworkPlayEnabled())
StartLogin();
else
CompleteLogin();
}
void plLoginDialog::IOnRememberPwdChanged()
{
fRememberPasswordVal.SetValue(fRememberPassword.IsChecked() ? "true" : "false");
}
void plLoginDialog::IExit()
{
fAccountNameVal.SetValue(fAccountName.GetValue().c_str());
fPasswordVal.SetValue(fPassword.GetValue().c_str());
fLobbyVal.SetValue(fLobbyList.GetValue().c_str());
SetDataServerUserName(true, fAccountNameVal.GetValue().c_str());
SetDataServerPassword(true, fPasswordVal.GetValue().c_str());
SetDataServerUserName(false, fAccountNameVal.GetValue().c_str());
SetDataServerPassword(false, fPasswordVal.GetValue().c_str());
SHORT state = GetKeyState(VK_SHIFT);
if (state&0x8000)
EndDialogTrue();
else
EndDialogFalse();
fCancelled=true;
}
int plLoginDialog::ICheckNetVersion(plNetMsgAuthenticateChallenge * msg)
{
if (msg)
{
if (msg->GetVersionMajor() != plNetMessage::kVerMajor ||
msg->GetVersionMinor() != plNetMessage::kVerMinor)
{
std::string str = xtl::format("Login Failed, client/server version mismatch, client %d.%d, server %d.%d",
plNetMessage::kVerMajor, plNetMessage::kVerMinor,
msg->GetVersionMajor(),
msg->GetVersionMinor());
FailLogin(str.c_str());
return hsFail;
}
return hsOK;
}
return hsFail;
}
void plLoginDialog::HandleAuthChallenge(plNetMsgAuthenticateChallenge * msg)
{
int cnt = msg->PeekBuffer(msg->GetNetCoreMsg()->GetData(),msg->GetNetCoreMsg()->GetLen());
// check protocol version first, in case msg contents are hosed
if (ICheckNetVersion(msg) == hsFail)
return; // version err
if (msg->IsContinuing())
{
// Respond to the Challenge
std::string hex = plChallengeResponse::GetBufferAsHexStr(msg->GetChallenge().data(), msg->GetChallenge().size(), true);
fChallengeResponse.SetChallenge(hex);
fChallengeResponse.GenerateResponse(fAccountNameVal.GetValue().c_str(),fPasswordVal.GetValue().c_str());
KillTimer(*this,kAuthTimedOut);
SendAuthenticateResponse();
}
else
{
FailLogin(msg->GetHelloResult());
}
}
void plLoginDialog::HandleAccountAuthenticated(plNetMsgAccountAuthenticated * msg)
{
int cnt = msg->PeekBuffer(msg->GetNetCoreMsg()->GetData(),msg->GetNetCoreMsg()->GetLen());
if (msg->IsAuthenticated())
{
CompleteLogin();
}
else
{
FailLogin(msg->GetAuthResult());
}
}
void plLoginDialog::StartLogin()
{
fLoginBtn.SetEnabled(false);
std::string value = fLobbyList.GetValue();
if (value.length()==0)
{
fLobbyList.SetCurrent(0);
fLobbyList.SetValue(MakeSafeLobbyServerName(fLobbyList.GetValue()).c_str());
SelectedLobbyChanged();
}
fStatusBar.SetText(L"Authenticating...");
// fMainDialog->InitNetCore();
// fMainDialog->fLoginState = kLoggingIn;
// fAccountTab.UpdateCtrls();
// fPlayerTab.SetPlayerVault(nil);
SendAuthenticateHello();
}
void plLoginDialog::CompleteLogin()
{
if ( Handle() )
fLoginBtn.SetEnabled(true);
KillTimer(*this,kAuthTimedOut);
fStatusBar.SetText(L"");
if (IsNetworkPlayEnabled())
NotifyConnected();
else
NotifyDisconnected();
EndDialogTrue();
GetClientManifests();
UpdateAllCtrls();
}
void plLoginDialog::FailLogin(const char* str)
{
fLoginBtn.SetEnabled(true);
KillTimer(*this, kAuthTimedOut);
fStatusBar.SetText(L"");
hsMessageBoxWithOwner((void*)*this,str,"Error",hsMessageBoxNormal);
Logout();
}
void plLoginDialog::FailLogin(int reasonCode)
{
std::string str = xtl::format("Failed to login to lobby server %s: %s",
fLobbyVal.GetValue().c_str(), plNetMsgAccountAuthenticated::GetAuthResultString(reasonCode));
FailLogin(str.c_str());
}
void plLoginDialog::TimeoutLogin()
{
fLoginBtn.SetEnabled(true);
wchar_t *wStr = hsStringToWString(xtl::format("Timed out logging into lobby server %s.", fLobbyVal.GetValue().c_str()).c_str());
fStatusBar.SetText(wStr);
delete [] wStr;
KillTimer(*this, kAuthTimedOut);
Logout();
}
void plLoginDialog::Logout()
{
KillTimer(*this, kAuthTimedOut);
SendLobbyLeave();
//fMainDialog->ShutdownNetCore();
NotifyDisconnected();
}
void plLoginDialog::SendLobbyLeave()
{
plNetMsgLeave msg;
msg.SetReason( plPlayerUpdateConstants::kPlayerQuitting );
SendMsg(&msg,plNetAddress(fLobbyVal.GetValue().c_str(),plNetLobbyServerConstants::GetPort()));
RemoveLobbyPeer();
}
#define MSG_TIMEOUT 8000
#include "../pnNetCommon/plNetAddress.h"
void plLoginDialog::SendAuthenticateHello()
{
SetTimer(*this,kAuthTimedOut,MSG_TIMEOUT,nil);
plNetMsgAuthenticateHello msg;
msg.SetAccountName(fAccountNameVal.GetValue().c_str());
msg.SetMaxPacketSize(GetPacketSize());
SendMsg(&msg,plNetAddress(fLobbyVal.GetValue().c_str(),plNetLobbyServerConstants::GetPort()));
}
void plLoginDialog::SendAuthenticateResponse()
{
SetTimer(*this,kAuthTimedOut,MSG_TIMEOUT,nil);
plNetMsgAuthenticateResponse msg;
msg.SetResponse(fChallengeResponse.GetResponse());
SendMsg(&msg,plNetAddress(fLobbyVal.GetValue().c_str(),plNetLobbyServerConstants::GetPort()));
}
int plLoginDialog::CallDefaultProc( unsigned int message, unsigned int wParam, LONG lParam )
{
switch (message)
{
case WM_TIMER:
switch (wParam)
{
case kAuthTimedOut:
TimeoutLogin();
break;
}
}
return 0;
}
/////////////////////////////////////////////////////////////////////////////
#ifndef PLASMA_EXTERNAL_RELEASE
#define kServerInfoFilename "server_info.html"
static void StringToLines(std::string str, plStringList & lines, bool includeBlankLines=true)
{
xtl::trim(str);
if (str.length()==0)
return;
str.append("\n");
int pos;
while ((pos=str.find("\n"))!=std::string::npos)
{
std::string line = xtl::trim(str.substr(0,pos).c_str());
str.erase(0,pos+1);
if (includeBlankLines || (!includeBlankLines && line.length()>0))
lines.push_back(line);
}
}
static void GetPathElements(std::string filename, plStringList & lst)
{
int pos;
while ((pos=filename.find_first_of("\\/"))!=std::string::npos)
{
std::string element = filename.substr(0,pos);
filename.erase(0,pos+1);
if (element.length())
lst.push_back(element);
}
}
struct SDLInfoParser
{
std::string fFilename;
std::string fDescriptorName;
int fVersion;
void ParseString( const char * s )
{
std::string str = s;
int p = str.find(",");
fFilename = str.substr(0,p);
str.erase(0,p+1);
p = str.find(",");
fDescriptorName = str.substr(0,p);
str.erase(0,p+1);
fVersion = atoi(str.c_str());
p = fFilename.find_last_of("\\");
if( p!=std::string::npos )
fFilename.erase(0,p+1);
p = fFilename.find_last_of("/");
if( p!=std::string::npos )
fFilename.erase(0,p+1);
}
};
struct DescriptorReport
{
int fServerVersion; // 0 means the descriptor is missing
int fClientVersion;
DescriptorReport(): fServerVersion(0),fClientVersion(0){}
};
#define kStyleSheet \
"<style>" \
"BODY {" \
" font-size : 10pt;" \
" font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;" \
"}" \
"TD {" \
" font-size : 10pt;" \
" font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;" \
"}" \
"PRE {" \
" margin-top : 0px;" \
"}" \
".SDLFile { background-color : #FFFF99; }" \
".Title {" \
" font-weight : bold;" \
" text-align : center;" \
" text-decoration : underline;" \
"}" \
".SectionHeader {" \
" margin-bottom : 0px;" \
"}" \
"</style>"
void plLoginDialog::ServerQueryBtnClicked()
{
hsUNIXStream file;
file.Open( kServerInfoFilename, "wt" );
file.WriteString("<html>"kStyleSheet"<body>\n");
try
{
typedef std::map< std::string, DescriptorReport > DescriptorReports;
typedef std::map< std::string, DescriptorReports > FileReports;
FileReports fileReports;
/*plURL url;
plHttpRequest request;
plHttpResponse response;
// read server build date etc.
url.SetHost( fLobbyList.GetValue().c_str() );
url.SetPort( 7676 );
url.SetFile( "VersionInfo" );
request.SetUrl( url );
request.SetType( plHttpRequest::kGet );
if ( !request.MakeRequest( response ) )
throw 0;
file.WriteString("<h3 class=SectionHeader>Server Info</h3>\n" );
file.WriteString( "<pre>\n" );
file.WriteString( response.c_str() );
file.WriteString( "</pre>\n" );
// get server's SDL info
url.SetFile( "SDLInfo" );
request.SetUrl( url );
if ( !request.MakeRequest( response ) )
throw 0;
plStringList lines;
StringToLines( response, lines, false );
SDLInfoParser parser;
{for ( plStringList::iterator ii=lines.begin(); ii!=lines.end(); ++ii )
{
parser.ParseString( (*ii).c_str() );
fileReports[ parser.fFilename ][ parser.fDescriptorName ].fServerVersion = parser.fVersion;
}}
// get client's SDL info
plSDLMgr::GetInstance()->DeInit();
plSDLMgr::GetInstance()->SetSDLDir( "SDL" );
plSDLMgr::GetInstance()->Init();
const plSDL::DescriptorList * cds = plSDLMgr::GetInstance()->GetDescriptors();
{for ( plSDL::DescriptorList::const_iterator ii=cds->begin(); ii!=cds->end(); ++ii )
{
plStateDescriptor * descriptor = *ii;
std::string filename = descriptor->GetFilename();
int p = filename.find_last_of(PATH_SEPARATOR_STR);
if( p!=std::string::npos )
filename.erase(0,p+1);
fileReports[ filename ][ descriptor->GetName() ].fClientVersion = descriptor->GetVersion();
}}
// write SDL comparison report
file.WriteString("<h3 class=SectionHeader>SDL File Comparison</h3>\n" );
file.WriteString("Version=0 means descriptor doesn't exist.<br><br>\n" );
file.WriteString( "<table><tr class=Title><td>File</td><td>Server Version</td><td>Client Version</td><td>Status</td></tr>\n" );
{ for ( FileReports::iterator ii=fileReports.begin(); ii!=fileReports.end(); ++ii )
{
std::string sdlFilename = ii->first;
DescriptorReports & descrReports = ii->second;
file.WriteFmt( "<tr><td colspan=5 class=SDLFile>%s</td></tr>\n", sdlFilename.c_str() );
{ for ( DescriptorReports::iterator jj=descrReports.begin(); jj!=descrReports.end(); ++jj )
{
#define kSDLBad "<font color=red><b>Bad</b></font>"
#define kSDLOk "<font color=green><b>Ok</b></font>"
std::string descrName = jj->first;
DescriptorReport & descrReport = jj->second;
file.WriteFmt( "<tr><td>&nbsp;&nbsp;&nbsp;%s</td><td align=right>%d</td><td align=right>%d</td><td align=center>%s</td></tr>\n",
descrName.c_str(), descrReport.fServerVersion, descrReport.fClientVersion,
( descrReport.fServerVersion==descrReport.fClientVersion ) ? kSDLOk:kSDLBad );
}}
}}
file.WriteString("</table>\n");*/
}
catch (...)
{
file.WriteString("<p>An error occurred while querying the server.\n");
}
file.WriteString("</body></html>\n");
file.Close();
ShellExecute( nil, nil, kServerInfoFilename, nil, nil, SW_SHOWNORMAL );
}
#endif
/////////////////////////////////////////////////////////////////////////////

138
Sources/Plasma/FeatureLib/pfLoginDialog/plLoginDialog.h

@ -1,138 +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==*/
#ifndef plLoginDialog_h_inc
#define plLoginDialog_h_inc
#include "plWndCtrls/plWndCtrls.h"
// #include "plEncryption/plChallengeResponse.h"
#include "pnNetCommon/plNetAddress.h"
class plMainDialog;
class plNetMsgAuthenticateChallenge;
class plNetMsgAccountAuthenticated;
class plNetMessage;
class plLoginDialog : public plDialog
{
HWND fParentWnd;
public:
DECLARE_WINDOWCLASS(plLoginDialog, plDialog);
plLoginDialog( HWND parentWnd=nil );
bool Login();
void OnInitDialog();
void HandleAuthChallenge(plNetMsgAuthenticateChallenge * msg);
void HandleAccountAuthenticated(plNetMsgAccountAuthenticated * msg);
void StartLogin();
void CompleteLogin();
void FailLogin(int reasonCode);
void FailLogin(const char* str);
void TimeoutLogin();
void Logout();
void SendAuthenticateHello();
void SendAuthenticateResponse();
bool IsNetworkPlayDisabled();
bool IsNetworkPlayEnabled();
// void UpdateCtrls();
void SelectedLobbyChanged();
void SelectedLobbyTextEdited();
void OnLobbyListLostFocus();
void SendLobbyLeave();
bool RefreshLobbyList();
bool GetCancelled() const { return fCancelled; }
bool GetRememberPassword() const { return fRememberPassword.IsChecked(); }
// callbacks
virtual void GetLobbyList(plStringList& lobbies) = 0;
virtual bool AllowSinglePlayerLobby() { return true; } // checked in non external-release build
virtual void SetDataServerUserName(bool local, const char* s) {}
virtual void SetDataServerPassword(bool local, const char* s) {}
virtual void RemoveLobbyPeer() {}
virtual void NotifyConnected() {}
virtual void NotifyDisconnected() {}
virtual void GetClientManifests() {}
virtual void UpdateAllCtrls() {}
virtual unsigned int GetPacketSize() = 0;
virtual bool SendMsg(plNetMessage * msg, plNetAddress & addr) = 0;
virtual void OnLoginClicked() {}
std::string MakeSafeLobbyServerName(const std::string & value);
int CallDefaultProc( unsigned int message, unsigned int wParam, LONG lParam );
plEdit fAccountName;
plEdit fPassword;
plChallengeResponse fChallengeResponse;
plComboBox fLobbyList;
plLabel fLobbyText;
plCheckBox fRememberPassword;
#ifndef PLASMA_EXTERNAL_RELEASE
plButton fServerQueryBtn;
void ServerQueryBtnClicked();
#endif
plConfigValue fAccountNameVal;
plConfigValue fPasswordVal; // the pwd as a MD5 hash
plConfigValue fRememberPasswordVal; // the checkbox state
plConfigValue fPasswordLen; // the length of the original pwd
plConfigValue fLobbyVal;
bool fAutoLogin;
plStatusBar fStatusBar;
protected:
int ICheckNetVersion(plNetMsgAuthenticateChallenge * msg);
void ILogin();
void IExit();
void IOnRememberPwdChanged();
bool fCancelled;
plButton fLoginBtn;
plButton fCancelBtn;
};
#endif // plLoginDialog_h_inc

24
Sources/Plasma/FeatureLib/pfLoginDialog/resource.h

@ -1,24 +0,0 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by pfLoginDialog.rc
//
#define IDD_DIALOG_LOGIN 326
#define IDC_LOGIN_USERNAME 3029
#define IDC_LOGIN_PASSWORD 3031
#define IDC_LOGIN_LOBBYLIST 3033
#define IDC_LOGIN_STATIC_SERVER 3127
#define IDC_LOGIN_LOGIN 3130
#define IDC_LOGIN_CANCEL 3131
#define IDC_SERVER_QUERY_BTN 3132
#define IDC_REMEMBER_PASSWORD 3133
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 327
#define _APS_NEXT_COMMAND_VALUE 42001
#define _APS_NEXT_CONTROL_VALUE 3134
#define _APS_NEXT_SYMED_VALUE 327
#endif
#endif

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];

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

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

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

4
Sources/Plasma/PubUtilLib/CMakeLists.txt

@ -10,14 +10,10 @@ add_subdirectory(plClientResMgr)
add_subdirectory(plClipboard)
add_subdirectory(plCompression)
add_subdirectory(plContainer)
#add_subdirectory(plDeviceSelector) # Not being used by any current slns
add_subdirectory(plDrawable)
add_subdirectory(plFile)
#add_subdirectory(plGClip) # Not being used by any current slns
#add_subdirectory(plGeometry) # Not being used by any current slns
add_subdirectory(plGImage)
add_subdirectory(plGLight)
#add_subdirectory(plGRenderProcs) # Not being used by any current slns
add_subdirectory(plInputCore)
add_subdirectory(plInterp)
add_subdirectory(plIntersect)

587
Sources/Plasma/PubUtilLib/plDeviceSelector/plDeviceSelector.cpp

@ -1,587 +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==*/
#include "plDeviceSelector.h"
#include "hsStream.h"
#include "hsUtils.h"
#include <algorithm>
DeviceSelector::DeviceSelector() :
fSelDevType(hsG3DDeviceSelector::kDevTypeUnknown),
fSelDev(0),
fSelMode(0),
fDevDesc(0),
fModeDesc(0),
fPerformance(0),
fFilterBPP(0),
fFilterWidth(0),
fFilterHeight(0),
fWindowed(false)
{
memset(fStr, 0x00, sizeof(fStr));
}
const char *DeviceSelector::GetErrorString( void )
{
return fSelector.GetErrorString();
}
hsBool DeviceSelector::Enumerate(HWND hWnd, hsBool expertMode )
{
plDemoDebugFile::Enable( true ); /// ALWAYS enable (well, for now at least)
if( !fSelector.Init() )
return false;
fSelector.Enumerate(hWnd);
// 11.25.2000 mcn - Now we are tough if we're not in expert mode
fSelector.RemoveUnusableDevModes( !expertMode );
// Sort the modes
hsTArray<hsG3DDeviceRecord> &recs = fSelector.GetDeviceRecords();
for (int32_t i = 0; i < recs.Count(); i++)
{
hsTArray<hsG3DDeviceMode> &modes = recs[i].GetModes();
std::sort(modes.FirstIter(), modes.StopIter());
}
IRefreshFilter();
return true;
}
void DeviceSelector::SetModeFilter( int bitDepth, int minWidth, int minHeight )
{
fFilterBPP = bitDepth;
fFilterWidth = minWidth;
fFilterHeight = minHeight;
IRefreshFilter();
}
void DeviceSelector::IRefreshFilter( void )
{
if (fSelDev >= fRecords.Count() )
return;
// Make sure to preserve fSelMode if possible
const hsG3DDeviceMode *oldMode = nil;
if( fSelMode < fFilteredModes.GetCount() && fFilteredModes[ fSelMode ]<fSelRec.GetModes().GetCount() )
oldMode = fSelRec.GetMode( fFilteredModes[ fSelMode ] );
fFilteredModes.Reset();
int i;
for( i = 0; i < fRecords[ fSelDev ].GetModes().Count(); i++ )
{
hsG3DDeviceMode* mode = fRecords[ fSelDev ].GetMode( i );
// Filter out modes we don't want listed
if( fFilterBPP != 0 && fFilterBPP != mode->GetColorDepth() )
continue;
if( mode->GetWidth() < fFilterWidth || mode->GetHeight() < fFilterHeight )
continue;
// Remove any non 4:3 modes
bool goodAspectRatio = (mode->GetWidth() / 4 == mode->GetHeight() / 3) &&
(mode->GetWidth() % 4 == 0) &&
(mode->GetHeight() % 3 == 0);
if (!goodAspectRatio && !(mode->GetWidth() == 1280 && mode->GetHeight() == 1024))
{
continue;
}
// Add the remaining to our filter index
fFilteredModes.Append( i );
}
if( oldMode != nil )
{
fSelMode = IFindFiltered( GetModeNum( oldMode ) );
if( fSelMode == -1 )
{
// Try w/o bpp
fSelMode = IFindFiltered( IGetModeNumNoBPP( oldMode ) );
if( fSelMode == -1 )
fSelMode = 0;
}
}
else
fSelMode = 0;
}
int DeviceSelector::IFindFiltered( int realIndex )
{
int idx = fFilteredModes.Find( realIndex );
if( idx == fFilteredModes.kMissingIndex )
return -1;
return idx;
}
hsBool DeviceSelector::CheckDeviceType(uint32_t type)
{
hsTArray<hsG3DDeviceRecord>& records = fSelector.GetDeviceRecords();
for (int32_t i = 0; i < records.Count(); i++)
{
if (type == records[i].GetG3DDeviceType())
return true;
}
return false;
}
hsBool DeviceSelector::IsDirect3DAvailable()
{
return CheckDeviceType(hsG3DDeviceSelector::kDevTypeDirect3D);
}
hsBool DeviceSelector::IsDirect3DTnLAvailable()
{
return CheckDeviceType(hsG3DDeviceSelector::kDevTypeDirect3DTnL);
}
hsBool DeviceSelector::IsGlideAvailable()
{
return CheckDeviceType(hsG3DDeviceSelector::kDevTypeGlide);
}
hsBool DeviceSelector::IsOpenGLAvailable()
{
return CheckDeviceType(hsG3DDeviceSelector::kDevTypeOpenGL);
}
void DeviceSelector::SetDirect3D()
{
SetDeviceType(hsG3DDeviceSelector::kDevTypeDirect3D);
}
void DeviceSelector::SetDirect3DTnL()
{
SetDeviceType(hsG3DDeviceSelector::kDevTypeDirect3DTnL);
}
void DeviceSelector::SetGlide()
{
SetDeviceType(hsG3DDeviceSelector::kDevTypeGlide);
}
void DeviceSelector::SetOpenGL()
{
SetDeviceType(hsG3DDeviceSelector::kDevTypeOpenGL);
}
void DeviceSelector::SetDeviceType (uint32_t type)
{
int32_t i;
for(i = 0; i < fRecords.GetCount(); i++)
fRecords[i].Clear();
fRecords.Reset();
hsTArray<hsG3DDeviceRecord>& records = fSelector.GetDeviceRecords();
for (i = 0; i < records.Count(); i++)
{
if (records[i].GetG3DDeviceType() == type)
fRecords.Push(records[i]);
}
fSelDevType = type;
fSelDev = 0;
fDevDesc = 0;
fModeDesc = 0;
IRefreshFilter();
}
hsBool DeviceSelector::IsDirect3D()
{
if (fSelDevType == hsG3DDeviceSelector::kDevTypeDirect3D)
return true;
else
return false;
}
hsBool DeviceSelector::IsDirect3DTnL()
{
return ( fSelDevType == hsG3DDeviceSelector::kDevTypeDirect3DTnL ) ? true : false;
}
hsBool DeviceSelector::IsGlide()
{
if (fSelDevType == hsG3DDeviceSelector::kDevTypeGlide)
return true;
else
return false;
}
hsBool DeviceSelector::IsOpenGL()
{
if (fSelDevType == hsG3DDeviceSelector::kDevTypeOpenGL)
return true;
else
return false;
}
hsBool DeviceSelector::SetDevice(uint32_t index)
{
if (index < fRecords.Count())
{
fSelDev = index;
fSelMode = 0;
fSelRec = fRecords[index];
fSelRec.SetMaxAnisotropicSamples(0);
IRefreshFilter();
return true;
}
return false;
}
hsBool DeviceSelector::SetMode(uint32_t index)
{
if (fSelDev >= fRecords.Count())
return false;
if (index < fFilteredModes.GetCount())
{
fSelMode = index;
return true;
}
return false;
}
char* DeviceSelector::GetDeviceDescription()
{
if (fDevDesc == fRecords.Count())
{
fDevDesc = 0;
return nil;
}
sprintf(fStr, "%s [%s]", fRecords[fDevDesc].GetDriverDesc(), fRecords[fDevDesc].GetDeviceDesc());
fDevDesc++;
return fStr;
}
char* DeviceSelector::GetModeDescription( void )
{
if (fSelDev >= fRecords.Count() )
return nil;
if (fModeDesc == fFilteredModes.GetCount())
{
fModeDesc = 0;
return nil;
}
hsG3DDeviceMode* mode = fRecords[fSelDev].GetMode( fFilteredModes[ fModeDesc ] );
fModeDesc++;
if( fFilterBPP != 0 )
sprintf( fStr, "%ux%u", mode->GetWidth(), mode->GetHeight() );
else
sprintf(fStr, "%ux%u %u bit", mode->GetWidth(), mode->GetHeight(), mode->GetColorDepth());
return fStr;
}
uint32_t DeviceSelector::GetNumModes()
{
return fFilteredModes.GetCount();
}
void DeviceSelector::GetMode(uint32_t i, int& width, int& height, int& depth)
{
if (i >= fFilteredModes.GetCount())
return;
hsG3DDeviceMode* mode = fRecords[fSelDev].GetMode(fFilteredModes[i]);
width = mode->GetWidth();
height = mode->GetHeight();
depth = mode->GetColorDepth();
}
hsBool DeviceSelector::SetDefault()
{
hsG3DDeviceModeRecord dmr;
if (fSelector.GetDefault(&dmr))
{
SetDeviceType(dmr.GetDevice()->GetG3DDeviceType());
fSelDev = GetDeviceNum(dmr.GetDevice());
fSelMode = IFindFiltered( GetModeNum(dmr.GetMode()) );
fSelRec = fRecords[fSelDev];
fSelRec.SetMaxAnisotropicSamples( 0 ); // Also off unless explicitly requested
// Set a default detail level based on the available memory
if (hsMemorySpec() == kBlows)
fPerformance = 25;
else
fPerformance = 100;
IRefreshFilter();
return true;
}
return false;
}
hsBool DeviceSelector::Save()
{
hsUNIXStream stream;
if (!stream.Open(DEV_MODE_DAT, "wb"))
return false;
hsG3DDeviceRecord selRec = fSelRec;
hsG3DDeviceMode selMode = *(selRec.GetMode( fFilteredModes[ fSelMode ] ));
selRec.ClearModes();
selRec.Write(&stream);
if (fWindowed)
selMode.SetColorDepth(0);
selMode.Write(&stream);
stream.WriteSwap16(fPerformance);
stream.Close();
return true;
}
hsBool DeviceSelector::Load()
{
hsUNIXStream stream;
if (!stream.Open(DEV_MODE_DAT, "rb"))
return false;
hsG3DDeviceRecord LoadRec; // Device copy for reading/writing
hsG3DDeviceMode LoadMode; // Modes copy for reading/writing
LoadRec.Read(&stream);
if (LoadRec.IsInvalid())
{
stream.Close();
return false;
}
LoadMode.Read(&stream);
fPerformance = stream.ReadSwap16();
stream.Close();
// If selected device is available use it, otherwise return false
if ((LoadRec.GetG3DDeviceType() == hsG3DDeviceSelector::kDevTypeDirect3D) && IsDirect3DAvailable())
SetDirect3D();
else if ((LoadRec.GetG3DDeviceType() == hsG3DDeviceSelector::kDevTypeDirect3DTnL) && IsDirect3DTnLAvailable())
SetDirect3DTnL();
else if ((LoadRec.GetG3DDeviceType() == hsG3DDeviceSelector::kDevTypeGlide) && IsGlideAvailable())
SetGlide();
else
return false;
////////////////////////////////////////////////////////////////////////////
// Attempt to match the saved device and mode to the ones that are currently
// available.
////////////////////////////////////////////////////////////////////////////
int num = GetDeviceNum(&LoadRec);
if (num == -1)
return false;
SetDevice(num);
// Copy the flags
fSelRec.SetCap(hsG3DDeviceSelector::kCapsCompressTextures,
LoadRec.GetCap(hsG3DDeviceSelector::kCapsCompressTextures));
fSelRec.SetAASetting( LoadRec.GetAASetting() );
fSelRec.SetMaxAnisotropicSamples( LoadRec.GetMaxAnisotropicSamples() );
if (LoadMode.GetColorDepth() == 0)
{
fWindowed = true;
LoadMode.SetColorDepth(32);
}
num = GetModeNum(&LoadMode);
if (num == -1)
return false;
SetMode(IFindFiltered(num));
return true;
}
int DeviceSelector::GetDeviceNum(const hsG3DDeviceRecord *pLoadRec)
{
hsTArray<hsG3DDeviceRecord>& records = fRecords;
for (int i = 0; i < records.Count(); i++)
{
if (!strcmp(records[i].GetDriverDesc(), pLoadRec->GetDriverDesc()) &&
!strcmp(records[i].GetDriverName(), pLoadRec->GetDriverName()) &&
!strcmp(records[i].GetDriverVersion(), pLoadRec->GetDriverVersion()) &&
!strcmp(records[i].GetDeviceDesc(), pLoadRec->GetDeviceDesc()))
return i;
}
return -1;
}
int DeviceSelector::IGetModeNumNoBPP( const hsG3DDeviceMode *pLoadMode )
{
hsTArray<hsG3DDeviceMode>& modes = fRecords[fSelDev].GetModes();
for (int i = 0; i < modes.Count(); i++)
{
if ((modes[i].GetWidth() == pLoadMode->GetWidth()) &&
(modes[i].GetHeight() == pLoadMode->GetHeight())
)
{
if( fFilteredModes.Find( i ) != fFilteredModes.kMissingIndex )
{
#ifndef M3DRELEASE
if (pLoadMode->GetColorDepth() == 0)
fSelRec.GetMode( i )->SetColorDepth(0);
#endif
return i;
}
}
}
return -1;
}
int DeviceSelector::GetModeNum(const hsG3DDeviceMode *pLoadMode)
{
hsTArray<hsG3DDeviceMode>& modes = fRecords[fSelDev].GetModes();
for (int i = 0; i < modes.Count(); i++)
{
if ((modes[i].GetWidth() == pLoadMode->GetWidth()) &&
(modes[i].GetHeight() == pLoadMode->GetHeight()) &&
(modes[i].GetColorDepth() == pLoadMode->GetColorDepth()))
{
return i;
}
}
return -1;
}
uint8_t DeviceSelector::CanAntiAlias()
{
hsG3DDeviceMode *mode = fRecords[ fSelDev ].GetMode( fFilteredModes[ fSelMode ] );
return mode->GetNumFSAATypes();
}
uint8_t DeviceSelector::IsAntiAliased()
{
return fSelRec.GetAASetting();
}
void DeviceSelector::SetAntiAlias(uint8_t numSamples)
{
fSelRec.SetAASetting( numSamples );
}
uint8_t DeviceSelector::CanAnisotropicFilter()
{
uint8_t hi = fRecords[ fSelDev ].GetMaxAnisotropicSamples();
if( hi > 1 )
return hi;
return 0;
}
uint8_t DeviceSelector::GetAnisotropicLevel()
{
return fSelRec.GetMaxAnisotropicSamples();
}
void DeviceSelector::SetAnisotropicLevel( uint8_t level )
{
fSelRec.SetMaxAnisotropicSamples( level );
}
bool DeviceSelector::CanWindow ()
{
return !fSelRec.GetCap(hsG3DDeviceSelector::kCapsNoWindow);
}
bool DeviceSelector::IsWindowed()
{
return fWindowed;
}
void DeviceSelector::SetWindowed(bool state)
{
fWindowed = state;
}
hsBool DeviceSelector::CanCompress ()
{
return fRecords[fSelDev].GetCap(hsG3DDeviceSelector::kCapsCompressTextures);
}
hsBool DeviceSelector::IsCompressed()
{
return fSelRec.GetCap(hsG3DDeviceSelector::kCapsCompressTextures);
}
void DeviceSelector::SetCompressed(hsBool state)
{
fSelRec.SetCap(hsG3DDeviceSelector::kCapsCompressTextures, state);
}
bool DeviceSelector::GetCap(uint32_t cap)
{
return fSelRec.GetCap(cap) != 0;
}

160
Sources/Plasma/PubUtilLib/plDeviceSelector/plDeviceSelector.h

@ -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==*/
#ifndef DEVICESELECTOR_H
#define DEVICESELECTOR_H
#include "HeadSpin.h"
//#include "plRender.h"
#include "../../PubUtilLib/plPipeline/hsG3DDeviceSelector.h"
#define DEV_MODE_DAT "dev_mode.dat"
//
// A wrapper class to simplify hsG3DDeviceSelector.
// Make sure to call Enumerate before doing anything else.
//
class DeviceSelector
{
protected:
uint32_t fSelDevType; // Current type of driver. Set by the SetDirect3D/Glide/OpenGL functions
uint32_t fSelDev; // Index of selected device. Set by SetDevice() or
uint32_t fSelMode; // Index of selected mode for current device
int fDevDesc; // Used by GetDeviceDescription() to store index of current device
int fModeDesc; // Used by GetModeDescription() to store index of current mode
char fStr[1024]; // Used to return text
uint16_t fPerformance; // Performance level (0-100)
int fFilterBPP, fFilterWidth, fFilterHeight;
bool fWindowed;
hsG3DDeviceSelector fSelector;
hsTArray<hsG3DDeviceRecord> fRecords; // Copy of all records for the current device type
hsG3DDeviceRecord fSelRec; // Device copy for reading/writing
hsTArray<int> fFilteredModes;
void IRefreshFilter( void );
int IFindFiltered( int realIndex );
int IGetModeNumNoBPP( const hsG3DDeviceMode *pLoadMode ); // Returns index of passed in mode
public:
DeviceSelector();
hsBool Enumerate(HWND hWnd, hsBool expertMode); // Enumerates all devices
const char *GetErrorString( void );
// Determines if any devices of the specified type are available
hsBool IsDirect3DAvailable();
hsBool IsGlideAvailable();
hsBool IsOpenGLAvailable();
hsBool IsDirect3DTnLAvailable();
// Set current device type
void SetDirect3D();
void SetGlide();
void SetOpenGL();
void SetDirect3DTnL();
// Returns true if current device is of the specified type
hsBool IsDirect3D();
hsBool IsDirect3DTnL();
hsBool IsGlide();
hsBool IsOpenGL();
// Gets and sets the current device or mode.
uint32_t GetSelectedDevice() { return fSelDev; }
uint32_t GetSelectedMode() { return fSelMode; }
hsBool SetDevice(uint32_t index);
hsBool SetMode(uint32_t index);
// Returns the device or mode descriptions. Call repeatedly until nil is returned.
char* GetDeviceDescription();
char* GetModeDescription( void );
uint32_t GetNumModes();
void GetMode(uint32_t i, int& width, int& height, int& depth);
void SetModeFilter( int bitDepth = 0, int minWidth = 0, int minHeight = 0 );
void SetPerformance (uint16_t value) { fPerformance = value; }
uint16_t GetPerformance () { return fPerformance; }
// Returns max number of samples allowed for AA
uint8_t CanAntiAlias ();
// Returns current # of samples selected for AA, 0 if none
uint8_t IsAntiAliased ();
void SetAntiAlias (uint8_t numSamples);
uint8_t CanAnisotropicFilter();
uint8_t GetAnisotropicLevel();
void SetAnisotropicLevel( uint8_t level );
bool CanWindow();
bool IsWindowed();
void SetWindowed(bool state);
hsBool CanCompress ();
hsBool IsCompressed ();
void SetCompressed (hsBool state);
// Caps from hsG3DDeviceSelector
bool GetCap(uint32_t cap);
// Save and load
hsBool Save(); // Returns false if output file can't be opened
hsBool Load(); // Returns false if input file can't be opened
hsBool SetDefault(); // Returns false if no suitable renderers are found
protected:
hsBool CheckDeviceType(uint32_t type); // Used by the Is*Available() functions
void SetDeviceType(uint32_t type); // Used by SetDirect3D/Glide/OpenGL
// Helpers for LoadDeviceMode()
int GetDeviceNum(const hsG3DDeviceRecord *pLoadRec); // Returns index of passed in device
int GetModeNum(const hsG3DDeviceMode *pLoadMode); // Returns index of passed in mode
};
#endif //DEVICESELECTOR_H

1
Sources/Plasma/PubUtilLib/plGClip/placeholder.txt

@ -1 +0,0 @@
What do you see? An empty folder.

250
Sources/Plasma/PubUtilLib/plGRenderProcs/hsGRenderProcs.cpp

@ -1,250 +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==*/
#include "hsTypes.h"
#include "hsUtils.h"
#include "hsScalar.h"
#include "hsMemory.h"
#include "hsGRenderProcs.h"
#include "hsStream.h"
#include "../plResMgr/plKey.h"
#include "../plResMgr/hsResMgr.h"
hsGRenderProcs::hsGRenderProcs()
: fNext(nil),
fBack(nil),
fPipeline(nil),
fFlags(kNone),
fLinkCount(0)
{
}
hsGRenderProcs::~hsGRenderProcs()
{
}
hsGRenderProcs** hsGRenderProcs::IOneBeforeMe(hsGRenderProcs** base)
{
hsAssert(base, "Searching for place in baseless list");
if( !*base ||((*base)->GetPriority() > GetPriority()) )
return base;
hsGRenderProcs* trav = *base;
while( trav->fNext && (trav->fNext->GetPriority() > GetPriority()) )
trav = trav->fNext;
hsAssert((trav != this)&&(trav->fNext != this), "Found self in bad place");
return &trav->fNext;
}
void hsGRenderProcs::IInsert(hsGRenderProcs** ptr)
{
hsAssert(*ptr != this, "Re-Inserting self");
hsAssert(ptr, "Inserting into nil list");
if( *ptr )
(*ptr)->fBack = &fNext;
fNext = *ptr;
fBack = ptr;
*ptr = this;
}
void hsGRenderProcs::IDetach()
{
if( fNext )
fNext->fBack = fBack;
*fBack = fNext;
fNext = nil;
fBack = nil;
}
void hsGRenderProcs::Enqueue(hsGRenderProcs** base)
{
// Already linked? Just note another link.
if( fLinkCount++ )
return;
IInsert(IOneBeforeMe(base));
Ref();
}
void hsGRenderProcs::Dequeue()
{
if( fBack && !--fLinkCount )
{
IDetach();
UnRef();
}
}
void hsGRenderProcs::Read(hsStream* s, hsResMgr* mgr)
{
SetFlags(s->ReadSwap32());
ReadObjectRefs(s, mgr);
Read(s);
}
void hsGRenderProcs::ReadObjectRefs(hsStream* s, hsResMgr* mgr)
{
if( fFlags & kObjectRefs )
{
int n = s->ReadSwap32();
fObjectRefs.SetCount(n);
int i;
for( i = 0; i < n; i++ )
{
fObjectRefs[i] = mgr->ReadKey(s);
}
}
}
void hsGRenderProcs::WriteObjectRefs(hsStream* s, hsResMgr* mgr)
{
if( fFlags & kObjectRefs )
{
s->WriteSwap32(fObjectRefs.GetCount());
int i;
for( i = 0; i < fObjectRefs.GetCount(); i++ )
{
// if( fObjectRefs[i] )
{
mgr->WriteKey(s,fObjectRefs[i]); // writes nil any...right?
}
// else
// {
// mgr->WriteKey(s, nil);
// }
}
}
}
void hsGRenderProcs::Write(hsStream* s, hsResMgr* mgr)
{
s->WriteSwap32(fFlags);
WriteObjectRefs(s, mgr);
Write(s);
}
plDrawable* hsGRenderProcs::GetObjectRef(int i)
{
return (plDrawable*)((i < fObjectRefs.GetCount()) && fObjectRefs[i] ? fObjectRefs[i]->GetObjectPtr() : nil);
}
void hsGRenderProcs::SetNumObjectRefs(int n)
{
if( n > fObjectRefs.GetCount() )
{
int oldCnt = fObjectRefs.GetCount();
fObjectRefs.SetCount(n);
int i;
for( i = oldCnt; i < n; i++ )
fObjectRefs[i] = nil;
}
}
void hsGRenderProcs::SetObjectRef(plKey* key, int i)
{
if( i >= fObjectRefs.GetCount() )
SetNumObjectRefs(i+1);
fObjectRefs[i] = key;
fFlags |= kObjectRefs;
}
hsBool32 hsGRenderProcs::BeginTree(plPipeline* pipe, plDrawable* root)
{
hsAssert(fFlags & kObjectRefsInit, "Should have had refs initialized on read");
fPipeline = pipe;
if( Inclusive() )
{
fColorizer.Init(pipe);
hsColorRGBA col = fColorizer.GetCurrentColor();
if( !fColorizer.Colorizing() )
{
col.r = col.g = col.b = 1.f;
}
if( !fColorizer.Alpharizing() )
col.a = 0.999f;
fColorizer.PushColorize(col, !fColorizer.Colorizing() /* alpha only */);
}
return true;
}
hsBool32 hsGRenderProcs::BeginObject(plPipeline* pipe, plDrawable* obj)
{
hsAssert(fFlags & kObjectRefsInit, "Should have had refs initialized on read");
fPipeline = pipe;
if( !Inclusive() )
{
fColorizer.Init(pipe);
hsColorRGBA col = fColorizer.GetCurrentColor();
if( !fColorizer.Colorizing() )
{
col.r = col.g = col.b = 1.f;
}
if( !fColorizer.Alpharizing() )
col.a = 0.999f;
fColorizer.PushColorize(col, !fColorizer.Colorizing() /* alpha only */);
}
return true;
}
void hsGRenderProcs::EndObject()
{
if( !Inclusive() )
fColorizer.PopColorize();
}
void hsGRenderProcs::EndTree()
{
if( Inclusive() )
fColorizer.PopColorize();
fPipeline = nil;
}

218
Sources/Plasma/PubUtilLib/plGRenderProcs/hsGRenderProcs.h

@ -1,218 +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==*/
#ifndef hsGRenderProcs_inc
#define hsGRenderProcs_inc
#include "hsRefCnt.h"
#include "hsScalar.h"
#include "hsMemory.h"
#include "hsBiExpander.h"
#include "../plPipeline/hsGColorizer.h"
#include "../plResMgr/plCreatable.h"
class plPipeline;
class plDrawable;
class hsTriangle3;
struct hsGTriVertex;
struct hsGVertex3;
struct hsGShadeVertex;
struct hsGSplat3;
class hsStream;
class plKey;
class hsBounds3Ext;
class hsResMgr;
class hsGRenderProcs : public plCreatable {
public:
enum {
kMaxLabelLen = 128
};
enum ProcType {
kTypeAngleFade,
kTypeDistFade,
kTypeMotionBlur1,
kTypeMotionBlur2,
kTypeIntenseAlpha,
kTypeGlobalShade,
kTypeObjDistFade,
kTypeDistShade,
kTypeObjDistShade
};
enum {
kNone = 0x0,
kInclusive = 0x1, // Affect children
kNOP = 0x2, // Turned off (till EndObject)
kOpaque = 0x4,
kCulled = 0x8,
kObjectRefs = 0x10,
kObjectRefsInit = 0x20
};
private:
// Base class private stuff for managing the Queue of Procs on the device.
uint32_t fLinkCount;
hsGRenderProcs* fNext;
hsGRenderProcs** fBack;
hsGRenderProcs** IOneBeforeMe(hsGRenderProcs** base);
void IInsert(hsGRenderProcs** beforeMe);
void IDetach();
protected:
uint32_t fFlags;
hsGColorizer fColorizer;
plPipeline* fPipeline;
hsDynamicArray<plKey*> fObjectRefs;
public:
hsGRenderProcs();
virtual ~hsGRenderProcs();
// BeginTree returns false if entire subtree is don't bother to draw,
// else true. Mostly a culling tool.
virtual hsBool32 BeginTree(plPipeline* pipe, plDrawable* root);
// BeginObject returns true if the object should be drawn, false if
// don't bother. Can also do any initialization it wants. Should this
// get something more innocuous like a bound instead of the SceneObject?
// Is there anything else it might need to know?
virtual hsBool32 BeginObject(plPipeline* pipe, plDrawable* obj);
// ProcessVerts takes the list of TriVerts and does what it will.
// I'll outline the hsGTriVertex below. The difference between
// the BaseVertex list and the UsedVertex list is interpolation.
// Shade values and generated Texture Coords are computed for
// the Base Triangle only, and then interpolated for vertices
// generated by clipping. So Shade Values and Texture Coordinates
// should only be computed in ProcessBaseVerts(). On the other
// hand, only the vertices from actual drawn triangles are
// transformed, and hence have a screen position to mess with.
// So any wiggling of the screen position should happen in
// ProcessUsedVerts(). These functions might be better named
// ProcessShadeVerts() and ProcessXformVerts(), except that
// vertex illumination (shade) is interpolated, but then
// the interpolated shade is fed into the material to calculate
// color. So messing with final color would happen in ProcessUsedVerts(),
// whereas messing with illumination's in ProcessBaseVerts(). Messing
// with UV's is equally valid in either. In general though, the number
// of BaseVerts is less than or equal to the number of UsedVerts. Most
// shaders would have one or the other a no-op.
// Process list of unique vertices (with unique hsGXformVerts) which will be drawn to screen
virtual void ProcessScreenVerts(hsExpander<hsGVertex3*>& vList) {}
// Take a list of verts and modulate shades for them. Care should be taken to only bother with verts that
// are not (hsGVertex3::kCulled|hsGVertex3::kDisabled). Also, any verts that this RenderProc causes
// to go completely transparent should be flagged hsGVertex3::kCulled (NOT DISABLED).
// See hsSfxDistFade for example (not exemplary) code.
// Process list of unique vertices (unique hsGShadeVerts) before interpolation
virtual void ProcessPreInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList) {}
// Process list of unique vertices (unique hsGShadeVerts) after interpolation - these will be drawn to screen
virtual void ProcessPostInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList) {}
// Process list of unique Pre or Post Interpolation TriVerts (with hsGShade and hsGXformVerts)
// While the TriVerts are unique, there may be sharing among constituents, i.e. position and uv.
// Care must be taken when accumulating effects.
virtual void ProcessPreInterpVerts(hsExpander<hsGTriVertex*>& vList) {}
virtual void ProcessPostInterpVerts(hsExpander<hsGTriVertex*>& vList) {}
// Process list of triangles which are headed for the screen. vList is the full list of unique TriVerts
// used by these triangles. If triangles are added, any generated verts MUST be added to vList. If
// Triangles are removed, verts may be removed from vList (keeping in mind that vList verts may be
// shared between triangles).
virtual void ProcessPreClipTris(hsExpander<hsTriangle3*>& tList, hsExpander<hsGTriVertex*>& vList) {}
virtual void ProcessPreInterpTris(hsExpander<hsTriangle3*>& tList, hsExpander<hsGTriVertex*>& vList) {}
virtual void ProcessPostInterpTris(hsExpander<hsTriangle3*>& tList, hsExpander<hsGTriVertex*>& vList) {}
// Any cleanup for this object
virtual void EndObject();
// Any cleanup for this subtree
virtual void EndTree();
// Shaders can set their priority to affect order in which they are called
// When pushed onto device, device uses this priority to sort into queue
virtual hsScalar GetPriority() { return 0; }
// When a shader is pushed onto the device (by an object), the object
// will pop it back off either before or after drawing its children,
// depending on Inclusive(). Not meaningful for mate
virtual hsBool32 Inclusive() { return fFlags & kInclusive; }
virtual void Enqueue(hsGRenderProcs** list);
virtual void Dequeue();
hsGRenderProcs* GetNext() { return fNext; }
// External object references. Individual RenderProc type responsible for what they're used for.
void SetNumObjectRefs(int n);
uint32_t GetNumObjectRefs() { return fObjectRefs.GetCount(); }
void AddObjectRef(plKey* key) { fObjectRefs.Append(key); fFlags |= kObjectRefs; }
void SetObjectRef(plKey* key, int i=0);
void InsertObjectRef(int i, plKey* key) { fObjectRefs.InsertAtIndex(i, key); fFlags |= kObjectRefs; }
plDrawable* GetObjectRef(int i);
plKey* GetObjectRefKey(int i) { return fObjectRefs[i]; }
void ReadObjectRefs(hsStream* s, hsResMgr* mgr);
void WriteObjectRefs(hsStream* s, hsResMgr* mgr);
virtual void Read(hsStream* s, hsResMgr* mgr);
virtual void Write(hsStream* s, hsResMgr* mgr);
virtual void Read(hsStream* s) = 0;
virtual void Write(hsStream* s) = 0;
virtual const char* GetLabel() const = 0;
virtual ProcType GetType() const = 0;
uint32_t GetFlags() { return fFlags; }
void SetFlags(uint32_t f) { fFlags = f; }
CLASSNAME_REGISTER( hsGRenderProcs );
GETINTERFACE_ANY( hsGRenderProcs, plCreatable );
};
#endif // hsGRenderProcs_inc

234
Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxAngleFade.cpp

@ -1,234 +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==*/
#include "hsTypes.h"
#include "hsMemory.h"
#include "hsSfxAngleFade.h"
#include "hsStream.h"
#include "../plPipeline/plPipeline.h"
//#include "../plPipeline/hsG3DDevice.h"
#include "../plGeometry/hsTriangle3.h"
#include "../plMath/hsFastMath.h"
hsSfxAngleFade::hsSfxAngleFade()
{
}
hsSfxAngleFade::~hsSfxAngleFade()
{
}
hsScalar hsSfxAngleFade::IOpacFromDot(hsScalar dot)
{
if( (fFlags & kTwoSided)
&&(dot < 0) )
dot = -dot;
if( dot <= fTable[0].fCosineDel )
return fTable[0].fOpacity;
int i;
for( i = 0; (i < fTable.GetCount()) && (dot >= fTable[i].fCosineDel); i++ )
dot -= fTable[i].fCosineDel;
if( i >= fTable.GetCount() )
return fTable[fTable.GetCount()-1].fOpacity;
dot *= fTable[i-1].fCosineNorm;
hsScalar opac0 = fTable[i-1].fOpacity;
hsScalar opac1 = fTable[i].fOpacity;
return opac0 + dot * (opac1 - opac0);
}
void hsSfxAngleFade::ProcessPreInterpTris(hsExpander<hsTriangle3*>& tList, hsExpander<hsGTriVertex*>& vList)
{
if( !(fFlags & kFaceNormals) )
return;
#if 0 // Taken out 2.26.2001 mcn 'cause it accesses the (now defunct) 3DDevice directly
hsPoint3 vPos = fPipeline->GetViewPositionLocal();
hsG3DDevice* dev = fPipeline->Get3DDevice();
fSetVector.Clear();
for( tList.First(); tList.More(); tList.Plus() )
{
hsTriangle3* tri = tList.Current();
hsVector3& norm = tri->fNormal;
hsScalar dot, opac;
hsGVertex3* vtx;
hsGShadeVertex* shade;
hsVector3 vDir;
vtx = tri->GetVertex(0);
if( !fSetVector.IsBitSet(vtx->fShadeIdx) )
{
vDir.Set(&vPos, &vtx->fLocalPos);
dot = hsFastMath::InvSqrtAppr(vDir.MagnitudeSquared());
dot *= norm.InnerProduct(vDir);
shade = dev->GetShadeEntry(vtx);
opac = IOpacFromDot(dot);
shade->fColor.a *= opac;
fSetVector.SetBit(vtx->fShadeIdx);
}
vtx = tri->GetVertex(1);
if( !fSetVector.IsBitSet(vtx->fShadeIdx) )
{
vDir.Set(&vPos, &vtx->fLocalPos);
dot = hsFastMath::InvSqrtAppr(vDir.MagnitudeSquared());
dot *= norm.InnerProduct(vDir);
shade = dev->GetShadeEntry(vtx);
opac = IOpacFromDot(dot);
shade->fColor.a *= opac;
fSetVector.SetBit(vtx->fShadeIdx);
}
vtx = tri->GetVertex(2);
if( !fSetVector.IsBitSet(vtx->fShadeIdx) )
{
vDir.Set(&vPos, &vtx->fLocalPos);
dot = hsFastMath::InvSqrtAppr(vDir.MagnitudeSquared());
dot *= norm.InnerProduct(vDir);
shade = dev->GetShadeEntry(vtx);
opac = IOpacFromDot(dot);
shade->fColor.a *= opac;
fSetVector.SetBit(vtx->fShadeIdx);
}
}
#endif
}
void hsSfxAngleFade::ProcessPreInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList)
{
if( fFlags & kFaceNormals )
return;
hsVector3 vDir =fPipeline->GetViewDirLocal();
hsPoint3 vPos = fPipeline->GetViewPositionLocal();
for( vList.First(); vList.More(); vList.Plus() )
{
hsGShadeVertex* shade = vList.Current();
hsScalar dot;
if( !(fFlags & kDirectional) )
{
vDir.Set(&vPos, &shade->fLocalPos);
dot = hsFastMath::InvSqrtAppr(vDir.MagnitudeSquared());
dot *= shade->fNormal.InnerProduct(vDir);
}
else
{
dot = shade->fNormal.InnerProduct(vDir);
}
hsScalar opac = IOpacFromDot(dot);
shade->fShade.a *= opac;
}
}
void hsSfxAngleFade::MakeTable(float* cosList, float* opacList, int num)
{
fTable.Reset();
if( !num )
return;
int i;
for( i = 0; i < num; i++ )
{
hsSfxAfTableEntry* t = fTable.Append();
t->fCosineDel = cosList[i];
t->fOpacity = opacList[i];
}
for( i = num-1; i > 0; i-- )
fTable[i].fCosineDel -= fTable[i-1].fCosineDel;
for( i = 0; i < num-1; i++ )
fTable[i].fCosineNorm = hsScalarInvert(fTable[i+1].fCosineDel);
fTable[num-1].fCosineNorm = 0;
hsAssert(fTable.GetCount() == num, "Mismatch making table");
}
void hsSfxAngleFade::Read(hsStream* s)
{
fTable.Reset();
int32_t cnt = s->ReadSwap32();
if( cnt )
{
hsSfxAfTableEntry* arr = new hsSfxAfTableEntry[cnt];
int i;
for( i = 0; i < cnt; i++ )
{
arr[i].fCosineDel = s->ReadSwapScalar();
arr[i].fCosineNorm = s->ReadSwapScalar();
arr[i].fOpacity = s->ReadSwapScalar();
}
fTable.SetArray(arr, cnt);
}
}
void hsSfxAngleFade::Write(hsStream* s)
{
s->WriteSwap32(fTable.GetCount());
for( fTable.First(); fTable.More(); fTable.Plus() )
{
s->WriteSwapScalar(fTable.Current().fCosineDel);
s->WriteSwapScalar(fTable.Current().fCosineNorm);
s->WriteSwapScalar(fTable.Current().fOpacity);
}
}

90
Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxAngleFade.h

@ -1,90 +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==*/
#ifndef hsSfxAngleFade_inc
#define hsSfxAngleFade_inc
#include "hsBiExpander.h"
#include "hsGRenderProcs.h"
#include "hsBitVector.h"
class hsSfxAngleFade : public hsGRenderProcs {
public:
enum {
kDirectional = 0x10000,
kTargetRelative = 0x20000,
kTwoSided = 0x40000,
kFaceNormals = 0x80000
};
struct hsSfxAfTableEntry {
hsScalar fCosineDel;
hsScalar fCosineNorm;
hsScalar fOpacity;
};
protected:
hsBitVector fSetVector;
hsExpander<hsSfxAfTableEntry> fTable;
hsScalar IOpacFromDot(hsScalar dot);
public:
hsSfxAngleFade();
virtual ~hsSfxAngleFade();
virtual void ProcessPreInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList);
virtual void ProcessPreInterpTris(hsExpander<hsTriangle3*>& tList, hsExpander<hsGTriVertex*>& vList);
void MakeTable(float* cosList, float* opacList, int num); // lists sorted from lowest cosine to highest
virtual void Read(hsStream* s);
virtual void Write(hsStream* s);
virtual const char* GetLabel() const { return "hsSfxAngleFade"; }
virtual ProcType GetType() const { return kTypeAngleFade; }
CLASSNAME_REGISTER( hsSfxAngleFade );
GETINTERFACE_ANY( hsSfxAngleFade, hsGRenderProcs );
};
#endif // hsSfxAngleFade_inc

331
Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxDistFade.cpp

@ -1,331 +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==*/
#include "hsTypes.h"
#include "hsMemory.h"
#include "hsSfxDistFade.h"
#include "hsStream.h"
#include "../plPipeline/plPipeline.h"
#include "../plGeometry/hsTriangle3.h"
#include "../plDrawable/plDrawable.h"
#include "../plIntersect/hsBounds.h"
static hsScalar globalScale = 1.f;
hsSfxDistFade::hsSfxDistFade()
: fMinDist(0), fMaxDist(0)
{
}
hsSfxDistFade::~hsSfxDistFade()
{
}
hsScalar hsSfxDistFade::IOpacFromDist(hsScalar dist)
{
if( dist <= fTable[0].fDistDel )
return fTable[0].fOpacity;
int i;
for( i = 0; (i < fTable.GetCount()) && (dist >= fTable[i].fDistDel); i++ )
dist -= fTable[i].fDistDel;
if( i >= fTable.GetCount() )
return fTable[fTable.GetCount()-1].fOpacity;
dist *= fTable[i-1].fDistNorm;
hsScalar opac0 = fTable[i-1].fOpacity;
hsScalar opac1 = fTable[i].fOpacity;
return opac0 + dist * (opac1 - opac0);
}
hsBool32 hsSfxDistFade::BeginObject(plPipeline* pipe, plDrawable* obj)
{
hsGRenderProcs::BeginObject(pipe, obj);
fFlags &= ~(kCulled | kNOP);
hsPoint3 vPos;
if( GetObjectRef(1) )
{
hsPoint3 wPos;
GetObjectRef(1)->GetLocalToWorld().GetTranslate(&wPos);
hsMatrix44 w2l = fPipeline->GetWorldToLocal();
vPos = w2l * wPos;
}
else
{
vPos = fPipeline->GetViewPositionLocal();
}
hsScalar scale = 1.f / fPipeline->GetLocalScale();
scale *= globalScale;
const hsBounds3Ext& bnd = obj->GetLocalBounds();
hsPoint3 inner, outer;
bnd.ClosestPoint(vPos, inner, outer);
hsScalar minDist, maxDist;
minDist = hsVector3(&vPos, &inner).Magnitude();
maxDist = hsVector3(&vPos, &outer).Magnitude();
minDist *= scale;
maxDist *= scale;
if( (fFlags & kCullsBefore)
&&(maxDist <= fMinDist) )
{
fFlags |= kCulled;
return false;
}
if( (fFlags & kCullsBeyond)
&&(minDist > fMaxDist) )
{
fFlags |= kCulled;
return false;
}
if( (fFlags & kIdleBefore)
&&(maxDist < fMinIdle) )
fFlags |= kNOP;
if( (fFlags & kIdleBeyond)
&&(minDist > fMaxIdle) )
fFlags |= kNOP;
return true;
}
void hsSfxDistFade::ProcessPreInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList)
{
if( fFlags & (kPostInterp | kNOP) )
return;
hsPoint3 vPos;
if( GetObjectRef(1) )
{
hsPoint3 wPos;
GetObjectRef(1)->GetLocalToWorld().GetTranslate(&wPos);
hsMatrix44 w2l = fPipeline->GetWorldToLocal();
vPos = w2l * wPos;
}
else
{
vPos = fPipeline->GetViewPositionLocal();
}
hsScalar scale = 1.f / fPipeline->GetLocalScale();
scale *= globalScale;
for( vList.First(); vList.More(); vList.Plus() )
{
hsGShadeVertex* shade = vList.Current();
hsScalar dist = hsVector3(&shade->fLocalPos, &vPos).Magnitude();
dist *= scale;
hsScalar opac = IOpacFromDist(dist);
if( opac > 0 )
shade->fShade.a *= opac;
else
{
shade->fShade.a = 0;
shade->fBaseVertex->fFlags |= hsGVertex3::kCulled;
}
}
}
void hsSfxDistFade::ProcessPostInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList)
{
if( !(fFlags & kPostInterp) )
return;
if( fFlags & kNOP )
return;
hsPoint3 vPos;
if( GetObjectRef(1) )
{
hsPoint3 wPos;
GetObjectRef(1)->GetLocalToWorld().GetTranslate(&wPos);
hsMatrix44 w2l = fPipeline->GetWorldToLocal();
vPos = w2l * wPos;
}
else
{
vPos = fPipeline->GetViewPositionLocal();
}
hsScalar scale = 1.f / fPipeline->GetLocalScale();
for( vList.First(); vList.More(); vList.Plus() )
{
hsGShadeVertex* shade = vList.Current();
hsScalar dist = hsVector3(&shade->fLocalPos, &vPos).Magnitude();
dist *= scale;
hsScalar opac = IOpacFromDist(dist);
if( opac > 0 )
shade->fColor.a *= opac;
else
{
shade->fColor.a = 0;
shade->fBaseVertex->fFlags |= hsGVertex3::kCulled;
}
}
}
void hsSfxDistFade::MakeTable(float* distList, float* opacList, int num)
{
fTable.Reset();
if( !num )
return;
int i;
for( i = 0; i < num; i++ )
{
hsSfxDfTableEntry* t = fTable.Append();
t->fDistDel = distList[i];
t->fOpacity = opacList[i];
}
for( i = num-1; i > 0; i-- )
fTable[i].fDistDel -= fTable[i-1].fDistDel;
for( i = 0; i < num-1; i++ )
fTable[i].fDistNorm = hsScalarInvert(fTable[i+1].fDistDel);
fTable[num-1].fDistNorm = 0;
hsAssert(fTable.GetCount() == num, "Mismatch making table");
if( fTable[0].fOpacity <= 0 )
fFlags |= kCullsBefore;
if( fTable[num-1].fOpacity <= 0 )
fFlags |= kCullsBeyond;
if( fTable[0].fOpacity >= 1.f )
fFlags |= kIdleBefore;
if( fTable[num-1].fOpacity >= 1.f )
fFlags |= kIdleBeyond;
int iMin;
for( iMin = 0; (iMin < fTable.GetCount())&&(fTable[iMin].fOpacity <= 0); iMin++ );
fMinDist = fTable[0].fDistDel;
for( i = 1; i < iMin; i++ )
fMinDist += fTable[i].fDistDel;
for( iMin = 0; (iMin < fTable.GetCount())&&(fTable[iMin].fOpacity >= 1.f); iMin++ );
fMinIdle = fTable[0].fDistDel;
for( i = 1; i < iMin; i++ )
fMinIdle += fTable[i].fDistDel;
int iMax;
for( iMax = fTable.GetCount()-1; (iMax >= 0)&&(fTable[iMax].fOpacity <= 0); iMax-- );
if( ++iMax >= fTable.GetCount() )
iMax = fTable.GetCount()-1;
fMaxDist = fTable[0].fDistDel;
for( i = 1; i <= iMax; i++ )
fMaxDist += fTable[i].fDistDel;
for( iMax = fTable.GetCount()-1; (iMax >= 0)&&(fTable[iMax].fOpacity >= 1.f); iMax-- );
if( ++iMax >= fTable.GetCount() )
iMax = fTable.GetCount()-1;
fMaxIdle = fTable[0].fDistDel;
for( i = 1; i <= iMax; i++ )
fMaxIdle += fTable[i].fDistDel;
}
void hsSfxDistFade::Read(hsStream* s)
{
fTable.Reset();
fMinDist = s->ReadSwapScalar();
fMaxDist = s->ReadSwapScalar();
if( fFlags & (kIdleBefore | kIdleBeyond) )
{
fMinIdle = s->ReadSwapScalar();
fMaxIdle = s->ReadSwapScalar();
}
int32_t cnt = s->ReadSwap32();
if( cnt )
{
hsSfxDfTableEntry* arr = new hsSfxDfTableEntry[cnt];
int i;
for( i = 0; i < cnt; i++ )
{
arr[i].fDistDel = s->ReadSwapScalar();
arr[i].fDistNorm = s->ReadSwapScalar();
arr[i].fOpacity = s->ReadSwapScalar();
}
fTable.SetArray(arr, cnt);
}
}
void hsSfxDistFade::Write(hsStream* s)
{
s->WriteSwapScalar(fMinDist);
s->WriteSwapScalar(fMaxDist);
if( fFlags & (kIdleBefore | kIdleBeyond) )
{
s->WriteSwapScalar(fMinIdle);
s->WriteSwapScalar(fMaxIdle);
}
s->WriteSwap32(fTable.GetCount());
for( fTable.First(); fTable.More(); fTable.Plus() )
{
s->WriteSwapScalar(fTable.Current().fDistDel);
s->WriteSwapScalar(fTable.Current().fDistNorm);
s->WriteSwapScalar(fTable.Current().fOpacity);
}
}

107
Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxDistFade.h

@ -1,107 +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==*/
#ifndef hsSfxDistFade_inc
#define hsSfxDistFade_inc
#include "hsBiExpander.h"
#include "hsGRenderProcs.h"
class hsSfxDistFade : public hsGRenderProcs {
public:
enum {
kCullsBefore = 0x10000,
kCullsBeyond = 0x20000,
kDistFromView = 0x40000,
kDistFromTarget = 0x80000,
kDistAlongX = 0x100000,
kDistAlongY = 0x200000,
kDistAlongZ = 0x400000,
kWorldDist = 0x800000,
kPostInterp = 0x1000000,
kIdleBefore = 0x2000000,
kIdleBeyond = 0x4000000
};
struct hsSfxDfTableEntry {
hsScalar fDistDel;
hsScalar fDistNorm;
hsScalar fOpacity;
};
protected:
hsScalar fMinDist;
hsScalar fMaxDist;
hsScalar fMinIdle;
hsScalar fMaxIdle;
hsExpander<hsSfxDfTableEntry> fTable;
hsScalar IOpacFromDist(hsScalar dist);
public:
hsSfxDistFade();
virtual ~hsSfxDistFade();
virtual hsBool32 BeginObject(plPipeline* pipe, plDrawable* obj);
virtual void ProcessPreInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList);
virtual void ProcessPostInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList);
void MakeTable(float* distList, float* opacList, int num); // lists sorted from lowest cosine to highest
virtual void Read(hsStream* s);
virtual void Write(hsStream* s);
virtual const char* GetLabel() const { return "hsSfxDistFade"; }
virtual ProcType GetType() const { return kTypeDistFade; }
CLASSNAME_REGISTER( hsSfxDistFade );
GETINTERFACE_ANY( hsSfxDistFade, hsGRenderProcs );
};
#endif // hsSfxDistFade_inc

292
Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxDistShade.cpp

@ -1,292 +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==*/
#include "hsTypes.h"
#include "hsMemory.h"
#include "hsSfxDistShade.h"
#include "hsStream.h"
#include "../plGeometry/hsTriangle3.h"
#include "../plIntersect/hsBounds.h"
#include "../plDrawable/plDrawable.h"
#include "../plPipeline/plPipeline.h"
static hsScalar globalScale = 1.f;
hsSfxDistShade::hsSfxDistShade()
: fMinDist(0), fMaxDist(0)
{
}
hsSfxDistShade::~hsSfxDistShade()
{
}
hsScalar hsSfxDistShade::IShadeFromDist(hsScalar dist)
{
if( dist <= fTable[0].fDistDel )
return fTable[0].fShade;
int i;
for( i = 0; (i < fTable.GetCount()) && (dist >= fTable[i].fDistDel); i++ )
dist -= fTable[i].fDistDel;
if( i >= fTable.GetCount() )
return fTable[fTable.GetCount()-1].fShade;
dist *= fTable[i-1].fDistNorm;
hsScalar shade0 = fTable[i-1].fShade;
hsScalar shade1 = fTable[i].fShade;
return shade0 + dist * (shade1 - shade0);
}
hsBool32 hsSfxDistShade::BeginObject(plPipeline* pipe, plDrawable* obj)
{
hsGRenderProcs::BeginObject(pipe, obj);
fFlags &= ~(kCulled | kNOP);
hsPoint3 vPos;
if( GetObjectRef(1) )
{
hsPoint3 wPos;
GetObjectRef(1)->GetLocalToWorld().GetTranslate(&wPos);
hsMatrix44 w2l = pipe->GetWorldToLocal();
vPos = w2l * wPos;
}
else
{
vPos = pipe->GetViewPositionLocal();
}
hsVector3 vDir = -pipe->GetViewDirLocal();
hsScalar scale = 1.f / fPipeline->GetLocalScale();
scale *= globalScale;
hsScalar vD = -(vDir.InnerProduct(vPos));
vD *= scale;
const hsBounds3Ext& bnd = obj->GetLocalBounds();
hsPoint3 corner;
bnd.GetCorner(&corner);
hsVector3 axis[3];
bnd.GetAxes(axis+0, axis+1, axis+2);
hsScalar dist = vDir.InnerProduct(corner) + vD;
hsScalar minDist = dist;
hsScalar maxDist = dist;
int i;
for( i = 0; i < 3; i++ )
{
dist = vDir.InnerProduct(axis[i]);
if( dist < 0 )
minDist += dist;
else
maxDist += dist;
}
minDist *= scale;
maxDist *= scale;
fFlags &= ~kShadeConstant;
if( maxDist < fMinDist )
{
fFlags |= kShadeConstant;
fConstShade = fTable[0].fShade;
}
else if( minDist > fMaxDist )
{
fFlags |= kShadeConstant;
fConstShade = fTable[fTable.GetCount()-1].fShade;
}
return true;
}
void hsSfxDistShade::ProcessPreInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList)
{
if( fFlags & kShadeConstant )
{
IConstShadeVerts(vList);
}
else
{
ICalcShadeVerts(vList);
}
}
void hsSfxDistShade::IConstShadeVerts(hsExpander<hsGShadeVertex*>& vList)
{
for( vList.First(); vList.More(); vList.Plus() )
{
hsGShadeVertex* svtx = vList.Current();
svtx->fShade.r *= fConstShade;
svtx->fShade.g *= fConstShade;
svtx->fShade.b *= fConstShade;
}
}
void hsSfxDistShade::ICalcShadeVerts(hsExpander<hsGShadeVertex*>& vList)
{
hsPoint3 vPos;
if( GetObjectRef(1) )
{
hsPoint3 wPos;
GetObjectRef(1)->GetLocalToWorld().GetTranslate(&wPos);
hsMatrix44 w2l = fPipeline->GetWorldToLocal();
vPos = w2l * wPos;
}
else
{
vPos = fPipeline->GetViewPositionLocal();
}
hsVector3 vDir = fPipeline->GetViewDirLocal();
hsScalar vDist = vDir.InnerProduct(vPos);
hsScalar scale = 1.f / fPipeline->GetLocalScale();
scale *= globalScale;
for( vList.First(); vList.More(); vList.Plus() )
{
hsGShadeVertex* svtx = vList.Current();
hsScalar dist = -vDir.InnerProduct(svtx->fLocalPos);
dist += vDist;
dist *= scale;
hsScalar shade = IShadeFromDist(dist);
if( shade > 0 )
{
svtx->fShade.r *= shade;
svtx->fShade.g *= shade;
svtx->fShade.b *= shade;
}
else
{
svtx->fShade.r = 0;
svtx->fShade.g = 0;
svtx->fShade.b = 0;
}
}
}
void hsSfxDistShade::MakeTable(float* distList, float* shadeList, int num)
{
fTable.Reset();
if( !num )
return;
int i;
for( i = 0; i < num; i++ )
{
hsSfxDfTableEntry* t = fTable.Append();
t->fDistDel = distList[i];
t->fShade = shadeList[i];
}
for( i = num-1; i > 0; i-- )
fTable[i].fDistDel -= fTable[i-1].fDistDel;
for( i = 0; i < num-1; i++ )
fTable[i].fDistNorm = hsScalarInvert(fTable[i+1].fDistDel);
fTable[num-1].fDistNorm = 0;
hsAssert(fTable.GetCount() == num, "Mismatch making table");
int iMin;
for( iMin = 0; (iMin < fTable.GetCount())&&(fTable[iMin].fShade <= 0); iMin++ );
fMinDist = fTable[0].fDistDel;
for( i = 1; i < iMin; i++ )
fMinDist += fTable[i].fDistDel;
int iMax;
for( iMax = fTable.GetCount()-1; (iMax >= 0)&&(fTable[iMax].fShade <= 0); iMax-- );
if( ++iMax >= fTable.GetCount() )
iMax = fTable.GetCount()-1;
fMaxDist = fTable[0].fDistDel;
for( i = 1; i <= iMax; i++ )
fMaxDist += fTable[i].fDistDel;
}
void hsSfxDistShade::Read(hsStream* s)
{
fTable.Reset();
fMinDist = s->ReadSwapScalar();
fMaxDist = s->ReadSwapScalar();
int32_t cnt = s->ReadSwap32();
if( cnt )
{
hsSfxDfTableEntry* arr = new hsSfxDfTableEntry[cnt];
int i;
for( i = 0; i < cnt; i++ )
{
arr[i].fDistDel = s->ReadSwapScalar();
arr[i].fDistNorm = s->ReadSwapScalar();
arr[i].fShade = s->ReadSwapScalar();
}
fTable.SetArray(arr, cnt);
}
}
void hsSfxDistShade::Write(hsStream* s)
{
s->WriteSwapScalar(fMinDist);
s->WriteSwapScalar(fMaxDist);
s->WriteSwap32(fTable.GetCount());
for( fTable.First(); fTable.More(); fTable.Plus() )
{
s->WriteSwapScalar(fTable.Current().fDistDel);
s->WriteSwapScalar(fTable.Current().fDistNorm);
s->WriteSwapScalar(fTable.Current().fShade);
}
}

97
Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxDistShade.h

@ -1,97 +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==*/
#ifndef hsSfxDistShade_inc
#define hsSfxDistShade_inc
#include "hsBiExpander.h"
#include "hsGRenderProcs.h"
class hsSfxDistShade : public hsGRenderProcs {
public:
enum {
kShadeConstant = 0x10000
};
struct hsSfxDfTableEntry {
hsScalar fDistDel;
hsScalar fDistNorm;
hsScalar fShade;
};
protected:
hsScalar fMinDist;
hsScalar fMaxDist;
hsScalar fConstShade;
hsScalar fMinIdle;
hsScalar fMaxIdle;
hsExpander<hsSfxDfTableEntry> fTable;
void IConstShadeVerts(hsExpander<hsGShadeVertex*>& vList);
void ICalcShadeVerts(hsExpander<hsGShadeVertex*>& vList);
hsScalar IShadeFromDist(hsScalar dist);
public:
hsSfxDistShade();
virtual ~hsSfxDistShade();
virtual hsBool32 BeginObject(plPipeline* pipe, plDrawable* obj);
virtual void ProcessPreInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList);
void MakeTable(float* distList, float* shadeList, int num); // lists sorted from lowest cosine to highest
virtual void Read(hsStream* s);
virtual void Write(hsStream* s);
virtual const char* GetLabel() const { return "hsSfxDistShade"; }
virtual ProcType GetType() const { return kTypeDistShade; }
CLASSNAME_REGISTER( hsSfxDistShade );
GETINTERFACE_ANY( hsSfxDistShade, hsGRenderProcs );
};
#endif // hsSfxDistShade_inc

242
Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxGlobalShade.cpp

@ -1,242 +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==*/
#include "hsTypes.h"
#include "hsMemory.h"
#include "hsSfxGlobalShade.h"
#include "hsStream.h"
//#include "../plPipeline/hsG3DDevice.h"
#include "../plPipeline/plPipeline.h"
#include "../plGLight/hsGProjector3.h"
#include "../plSurface/hsGLayer.h"
#include "../plSurface/hsGMaterial.h"
#include "../plDrawable/plDrawable.h"
#include "../plIntersect/hsBounds.h"
void hsSfxGlobalShade::ISetIntensity(hsPoint3& pos)
{
if( fGSFlags & kFromFog )
ISetFromFog(pos);
else
if( fGSFlags & kFromClear )
ISetFromClear(pos);
else
if( fGSFlags & kFromLights )
ISetFromLights(pos);
fIntensity.a = hsMaximum(fIntensity.r, hsMaximum(fIntensity.g, fIntensity.b));
}
void hsSfxGlobalShade::ISetFromClear(hsPoint3& pos)
{
fIntensity.Set(0,0,0,0);
#if 0 // Taken out 2.26.2001 mcn 'cause it accesses the (now defunct) 3DDevice directly
hsG3DDevice* dev = fPipeline->Get3DDevice();
hsGEnvironment* env = dev->GetEnvironment();
if( env && (env->GetFlags() & hsGEnvironment::kClearColorSet) )
{
fIntensity = env->GetClearColor();
}
#endif
}
void hsSfxGlobalShade::ISetFromFog(hsPoint3& pos)
{
fIntensity.Set(0,0,0,0);
#if 0 // Taken out 2.26.2001 mcn 'cause it accesses the (now defunct) 3DDevice directly
hsG3DDevice* dev = fPipeline->Get3DDevice();
hsGEnvironment* env = dev->GetEnvironment();
if( env && (env->GetFlags() & hsGEnvironment::kFogColorSet) )
{
fIntensity = env->GetFogColor();
}
#endif
}
void hsSfxGlobalShade::ISetFromLights(hsPoint3& pos)
{
fIntensity = ISumLights(pos);
}
hsColorRGBA hsSfxGlobalShade::ISumLights(hsPoint3& pos)
{
hsColorRGBA accum;
accum.Set(0,0,0,0);
#if 0 // Taken out 2.26.2001 mcn 'cause it accesses the (now defunct) 3DDevice directly
hsG3DDevice* dev = fPipeline->Get3DDevice();
for( dev->FirstProjector(); dev->MoreProjectors(); dev->IncProjector() )
{
hsGProjector3* proj = dev->CurrProjector();
if( proj->IsOmni() )
{
hsScalar intensity = proj->AttenuatePoint(&pos) * proj->GetIntensity();
if( intensity > 0.f )
{
hsColorRGBA col = intensity * proj->GetLightColor();
accum += col;
}
}
else
if( proj->IsPerspective() ) // spot
{
hsPoint4 ang;
uint32_t clips;
proj->GetNdcPoints(1, &pos, sizeof(pos), &ang, kClipAll, &clips);
if( !clips
|| !( proj->IsAttenuated() || proj->AttenuatesAlpha() || (clips & ~kClipYon) )
)
{
hsScalar intensity = proj->AttenuatePoint(&pos) * proj->GetIntensity();
if( intensity > 0.f )
{
hsColorRGBA col = intensity * proj->GetLightColor();
accum += col;
}
}
}
else // directional
{
hsColorRGBA col = proj->GetIntensity() * proj->GetLightColor();
accum += col;
}
}
#endif
return accum;
}
void hsSfxGlobalShade::ProcessPreInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList)
{
if( fCurrentLayer )
{
if( fGSFlags & kAffectDiffuse )
fCurrentLayer->SetColor(fRestoreColor.r, fRestoreColor.g, fRestoreColor.b, fRestoreColor.a);
else
fCurrentLayer->SetAmbientColor(fRestoreColor.r, fRestoreColor.g, fRestoreColor.b, fRestoreColor.a);
}
#if 0 // Taken out 2.26.2001 mcn 'cause it accesses the (now defunct) 3DDevice directly
hsG3DDevice* dev = fPipeline->Get3DDevice();
hsRefCnt_SafeAssign(fCurrentLayer, dev->GetCurrentLayer());
if( fCurrentLayer )
{
fRestoreColor = fGSFlags & kAffectDiffuse ? fCurrentLayer->GetColor() : fCurrentLayer->GetAmbientColor();
hsColorRGBA col = fAmbient;
if( fGSFlags & kScalarIntensity )
{
col.r += fDiffuse.r * fIntensity.a;
col.g += fDiffuse.g * fIntensity.a;
col.b += fDiffuse.b * fIntensity.a;
}
else
{
col.r += fDiffuse.r * fIntensity.r;
col.g += fDiffuse.g * fIntensity.g;
col.b += fDiffuse.b * fIntensity.b;
}
if( fGSFlags & kAffectDiffuse )
fCurrentLayer->SetColor(col.r, col.g, col.b, fRestoreColor.a);
else
fCurrentLayer->SetAmbientColor(col.r, col.g, col.b, fRestoreColor.a);
}
#endif
}
hsBool32 hsSfxGlobalShade::BeginObject(plPipeline* pipe, plDrawable* obj)
{
hsBool32 retVal = hsGRenderProcs::BeginObject(pipe, obj);
const hsBounds3Ext& bnd = obj->GetLocalBounds();
hsPoint3 pos = bnd.GetCenter();
ISetIntensity(pos);
return retVal;
}
void hsSfxGlobalShade::EndObject()
{
hsGRenderProcs::EndObject();
if( fCurrentLayer )
{
if( fGSFlags & kAffectDiffuse )
fCurrentLayer->SetColor(fRestoreColor.r, fRestoreColor.g, fRestoreColor.b, fRestoreColor.a);
else
fCurrentLayer->SetAmbientColor(fRestoreColor.r, fRestoreColor.g, fRestoreColor.b, fRestoreColor.a);
hsRefCnt_SafeUnRef(fCurrentLayer);
fCurrentLayer = nil;
}
}
void hsSfxGlobalShade::Read(hsStream* s)
{
fGSFlags = s->ReadSwap32();
fAmbient.Read(s);
fDiffuse.Read(s);
if( fGSFlags & kFromLights )
fGSFlags |= kAffectDiffuse;
}
void hsSfxGlobalShade::Write(hsStream* s)
{
s->WriteSwap32(fGSFlags);
fAmbient.Write(s);
fDiffuse.Write(s);
}
hsSfxGlobalShade::hsSfxGlobalShade()
{
fCurrentLayer = nil;
fGSFlags = 0;
fAmbient.Set(0,0,0,0);
fDiffuse.Set(1.f,1.f,1.f,1.f);
}
hsSfxGlobalShade::~hsSfxGlobalShade()
{
hsRefCnt_SafeUnRef(fCurrentLayer); // should be nil anyway unless we're destroyed during processing
}

120
Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxGlobalShade.h

@ -1,120 +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==*/
#ifndef hsSfxGlobalShade_inc
#define hsSfxGlobalShade_inc
#include "hsBiExpander.h"
#include "hsGRenderProcs.h"
#include "hsColorRGBA.h"
#include "hsGeometry3.h"
class hsGLayer;
class hsSfxGlobalShade : public hsGRenderProcs {
public:
enum {
kNone = 0x0,
kFromFog = 0x1,
kFromClear = 0x2,
kFromLights = 0x4,
kSourceMask = kFromFog | kFromClear | kFromLights,
kScalarIntensity = 0x8,
kAffectDiffuse = 0x10
};
protected:
// Constants from which to work.
uint32_t fGSFlags;
hsColorRGBA fAmbient;
hsColorRGBA fDiffuse;
// Calculated each invocation.
hsColorRGBA fIntensity;
hsGLayer* fCurrentLayer;
hsColorRGBA fRestoreColor;
void ISetIntensity(hsPoint3& pos);
void ISetFromFog(hsPoint3& pos);
void ISetFromClear(hsPoint3& pos);
void ISetFromLights(hsPoint3& pos);
hsColorRGBA ISumLights(hsPoint3& pos);
public:
hsSfxGlobalShade();
virtual ~hsSfxGlobalShade();
virtual void ProcessPreInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList);
virtual hsBool32 BeginObject(plPipeline* pipe, plDrawable* obj);
virtual void EndObject();
virtual void Read(hsStream* s);
virtual void Write(hsStream* s);
virtual const char* GetLabel() const { return "hsSfxGlobalShade"; }
virtual ProcType GetType() const { return kTypeGlobalShade; }
void SetAmbient(const hsColorRGBA& col) { fAmbient = col; }
hsColorRGBA GetAmbient() const { return fAmbient; }
void SetDiffuse(const hsColorRGBA& col) { fDiffuse = col; }
hsColorRGBA GetDiffuse() const { return fDiffuse; }
void SetSource(uint32_t f) { fGSFlags &= ~kSourceMask; fGSFlags |= f; }
uint32_t GetSource() { return fGSFlags & kSourceMask; }
void SetScalar(hsBool32 on) { if(on)fGSFlags |= kScalarIntensity; else fGSFlags &= ~kScalarIntensity; }
hsBool32 GetScalar() { return 0 != (fGSFlags & kScalarIntensity); }
void SetAffectDiffuse(hsBool32 on) { if(on)fGSFlags |= kAffectDiffuse; else fGSFlags &= ~kAffectDiffuse; }
hsBool32 GetAffectDiffuse() { return 0 != (fGSFlags & kAffectDiffuse); }
CLASSNAME_REGISTER( hsSfxGlobalShade );
GETINTERFACE_ANY( hsSfxGlobalShade, hsGRenderProcs );
};
#endif // hsSfxGlobalShade_inc

81
Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxIntenseAlpha.cpp

@ -1,81 +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==*/
#include "hsTypes.h"
#include "hsGeometry3.h"
#include "hsSfxIntenseAlpha.h"
#include "../plGeometry/hsTriangle3.h"
hsSfxIntenseAlpha::hsSfxIntenseAlpha()
: fMinAlpha(0)
{
fFlags |= kInclusive;
}
hsSfxIntenseAlpha::~hsSfxIntenseAlpha()
{
}
void hsSfxIntenseAlpha::ProcessPreInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList)
{
hsScalar oScale = 1.f - fMinAlpha;
for( vList.First(); vList.More(); vList.Plus() )
{
hsGShadeVertex* s = vList.Current();
hsScalar o = hsMaximum(hsMaximum(s->fShade.r, s->fShade.g), s->fShade.b);
o *= oScale;
o += fMinAlpha;
s->fShade.a *= o;
}
}
void hsSfxIntenseAlpha::Read(hsStream* s)
{
fMinAlpha = s->ReadSwapScalar();
}
void hsSfxIntenseAlpha::Write(hsStream* s)
{
s->WriteSwapScalar(fMinAlpha);
}

82
Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxIntenseAlpha.h

@ -1,82 +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==*/
#ifndef hsSfxIntenseAlpha_inc
#define hsSfxIntenseAlpha_inc
#include "hsGRenderProcs.h"
#include "hsGeometry3.h"
class hsSfxIntenseAlpha : public hsGRenderProcs
{
protected:
hsVector3 fDirViewPerp;
hsVector3 fDirScreen;
hsScalar fOpacityScale;
hsScalar fOpacityMax;
hsScalar fMinAlpha;
public:
hsSfxIntenseAlpha();
virtual ~hsSfxIntenseAlpha();
void SetMinAlpha(hsScalar s) { fMinAlpha = s; }
hsScalar GetMinAlpha() { return fMinAlpha; }
virtual void ProcessPreInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList);
virtual void Read(hsStream* s);
virtual void Write(hsStream* s);
virtual const char* GetLabel() const { return "hsSfxIntenseAlpha"; }
virtual ProcType GetType() const { return kTypeIntenseAlpha; }
CLASSNAME_REGISTER( hsSfxIntenseAlpha );
GETINTERFACE_ANY( hsSfxIntenseAlpha, hsGRenderProcs );
};
#endif // hsSfxIntenseAlpha_inc

320
Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxObjDistFade.cpp

@ -1,320 +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==*/
#include "hsTypes.h"
#include "hsMemory.h"
#include "hsSfxObjDistFade.h"
#include "hsStream.h"
//#include "hsG3DDevice.h"
#include "../plPipeline/plPipeline.h"
#include "../plGeometry/hsTriangle3.h"
#include "../plIntersect/hsBounds.h"
#include "../plDrawable/plDrawable.h"
static hsScalar globalScale = 1.f;
hsSfxObjDistFade::hsSfxObjDistFade()
: fMinDist(0), fMaxDist(0), fTreeCnt(0)
{
}
hsSfxObjDistFade::~hsSfxObjDistFade()
{
}
hsScalar hsSfxObjDistFade::IOpacFromDist(hsScalar dist)
{
if( dist <= fTable[0].fDistDel )
return fTable[0].fOpacity;
int i;
for( i = 0; (i < fTable.GetCount()) && (dist >= fTable[i].fDistDel); i++ )
dist -= fTable[i].fDistDel;
if( i >= fTable.GetCount() )
return fTable[fTable.GetCount()-1].fOpacity;
dist *= fTable[i-1].fDistNorm;
hsScalar opac0 = fTable[i-1].fOpacity;
hsScalar opac1 = fTable[i].fOpacity;
return opac0 + dist * (opac1 - opac0);
}
hsBool32 hsSfxObjDistFade::ISetOpac(plDrawable* refObj)
{
hsPoint3 refPos;
if( fFlags & kByBoundsCenter )
{
const hsBounds3Ext& bnd = refObj->GetWorldBounds();
if( kBoundsNormal != bnd.GetType() )
return true;
refPos = bnd.GetCenter();
}
else
{
refObj->GetLocalToWorld().GetTranslate(&refPos);
}
fFlags &= ~(kCulled | kNOP);
hsPoint3 vPos;
if( GetObjectRef(1) )
{
GetObjectRef(1)->GetLocalToWorld().GetTranslate(&vPos);
}
else
{
vPos = fPipeline->GetViewPositionWorld();
}
hsScalar dist = hsVector3(&vPos, &refPos).Magnitude();
if( (fFlags & kCullsBefore)
&&(dist <= fMinDist) )
{
fFlags |= kCulled;
return false;
}
if( (fFlags & kCullsBeyond)
&&(dist > fMaxDist) )
{
fFlags |= kCulled;
return false;
}
if( (fFlags & kIdleBefore)
&&(dist < fMinIdle) )
fFlags |= kNOP;
else
if( (fFlags & kIdleBeyond)
&&(dist > fMaxIdle) )
fFlags |= kNOP;
else
{
hsScalar opac = IOpacFromDist(dist);
hsColorRGBA col = fColorizer.GetCurrentColor();
if( fColorizer.Alpharizing() )
col.a *= opac;
else
col.a = opac;
fColorizer.PushColorize(col, fColorizer.Colorizing());
if( fFlags & kNoZTrans )
{
if( !(fPipeline->GetMaterialOverrideOff(hsGMatState::kZ) & hsGMatState::kZNoZWrite) )
{
fRestoreOver = fPipeline->PushMaterialOverride(hsGMatState::kZ, hsGMatState::kZNoZWrite, true);
}
}
}
return true;
}
hsBool32 hsSfxObjDistFade::BeginObject(plPipeline* pipe, plDrawable* obj)
{
if( Inclusive() )
return true;
hsGRenderProcs::BeginObject(pipe, obj);
#if 0
// This is bogus. We may want to fade something, but not fade it out entirely.
if( !(fFlags & (kCullsBefore | kCullsBeyond | kIdleBefore | kIdleBeyond)) )
return true;
#endif
plDrawable* refObj = fFlags & kObjectRefs ? GetObjectRef(0) : nil;
if( !refObj )
refObj = obj;
return ISetOpac(refObj);
}
hsBool32 hsSfxObjDistFade::BeginTree(plPipeline* pipe, plDrawable* obj)
{
if( !Inclusive() )
return true;
if( fTreeCnt++ )
return true;
hsGRenderProcs::BeginTree(pipe, obj);
plDrawable* refObj = fFlags & kObjectRefs ? GetObjectRef(0) : nil;
if( !refObj )
refObj = obj;
return ISetOpac(refObj);
}
void hsSfxObjDistFade::EndObject()
{
if( !Inclusive() )
{
fPipeline->PopMaterialOverride(fRestoreOver, true);
}
hsGRenderProcs::EndObject();
}
void hsSfxObjDistFade::EndTree()
{
if( Inclusive() )
{
fPipeline->PopMaterialOverride(fRestoreOver, true);
fTreeCnt--;
hsAssert(fTreeCnt >= 0, "Push/Pop tree problem");
}
hsGRenderProcs::EndTree();
}
void hsSfxObjDistFade::MakeTable(float* distList, float* opacList, int num)
{
fTable.Reset();
if( !num )
return;
int i;
for( i = 0; i < num; i++ )
{
hsSfxDfTableEntry* t = fTable.Append();
t->fDistDel = distList[i];
t->fOpacity = opacList[i];
}
for( i = num-1; i > 0; i-- )
fTable[i].fDistDel -= fTable[i-1].fDistDel;
for( i = 0; i < num-1; i++ )
fTable[i].fDistNorm = hsScalarInvert(fTable[i+1].fDistDel);
fTable[num-1].fDistNorm = 0;
hsAssert(fTable.GetCount() == num, "Mismatch making table");
if( fTable[0].fOpacity <= 0 )
fFlags |= kCullsBefore;
if( fTable[num-1].fOpacity <= 0 )
fFlags |= kCullsBeyond;
if( fTable[0].fOpacity >= 1.f )
fFlags |= kIdleBefore;
if( fTable[num-1].fOpacity >= 1.f )
fFlags |= kIdleBeyond;
int iMin;
for( iMin = 0; (iMin < fTable.GetCount())&&(fTable[iMin].fOpacity <= 0); iMin++ );
fMinDist = fTable[0].fDistDel;
for( i = 1; i < iMin; i++ )
fMinDist += fTable[i].fDistDel;
for( iMin = 0; (iMin < fTable.GetCount())&&(fTable[iMin].fOpacity >= 1.f); iMin++ );
fMinIdle = fTable[0].fDistDel;
for( i = 1; i < iMin; i++ )
fMinIdle += fTable[i].fDistDel;
int iMax;
for( iMax = fTable.GetCount()-1; (iMax >= 0)&&(fTable[iMax].fOpacity <= 0); iMax-- );
if( ++iMax >= fTable.GetCount() )
iMax = fTable.GetCount()-1;
fMaxDist = fTable[0].fDistDel;
for( i = 1; i <= iMax; i++ )
fMaxDist += fTable[i].fDistDel;
for( iMax = fTable.GetCount()-1; (iMax >= 0)&&(fTable[iMax].fOpacity >= 1.f); iMax-- );
if( ++iMax >= fTable.GetCount() )
iMax = fTable.GetCount()-1;
fMaxIdle = fTable[0].fDistDel;
for( i = 1; i <= iMax; i++ )
fMaxIdle += fTable[i].fDistDel;
}
void hsSfxObjDistFade::Read(hsStream* s)
{
fTable.Reset();
fMinDist = s->ReadSwapScalar();
fMaxDist = s->ReadSwapScalar();
if( fFlags & (kIdleBefore | kIdleBeyond) )
{
fMinIdle = s->ReadSwapScalar();
fMaxIdle = s->ReadSwapScalar();
}
int32_t cnt = s->ReadSwap32();
if( cnt )
{
hsSfxDfTableEntry* arr = new hsSfxDfTableEntry[cnt];
int i;
for( i = 0; i < cnt; i++ )
{
arr[i].fDistDel = s->ReadSwapScalar();
arr[i].fDistNorm = s->ReadSwapScalar();
arr[i].fOpacity = s->ReadSwapScalar();
}
fTable.SetArray(arr, cnt);
}
}
void hsSfxObjDistFade::Write(hsStream* s)
{
s->WriteSwapScalar(fMinDist);
s->WriteSwapScalar(fMaxDist);
if( fFlags & (kIdleBefore | kIdleBeyond) )
{
s->WriteSwapScalar(fMinIdle);
s->WriteSwapScalar(fMaxIdle);
}
s->WriteSwap32(fTable.GetCount());
for( fTable.First(); fTable.More(); fTable.Plus() )
{
s->WriteSwapScalar(fTable.Current().fDistDel);
s->WriteSwapScalar(fTable.Current().fDistNorm);
s->WriteSwapScalar(fTable.Current().fOpacity);
}
}

116
Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxObjDistFade.h

@ -1,116 +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==*/
#ifndef hsSfxObjDistFade_inc
#define hsSfxObjDistFade_inc
#include "hsBiExpander.h"
#include "hsGRenderProcs.h"
#include "../plPipeline/hsGMatState.h"
class hsSfxObjDistFade : public hsGRenderProcs {
public:
enum {
kCullsBefore = 0x10000,
kCullsBeyond = 0x20000,
kDistFromView = 0x40000,
kDistFromTarget = 0x80000,
kDistAlongX = 0x100000,
kZOff = 0x200000,
kNoZTrans = 0x400000,
kByBoundsCenter = 0x800000,
kPostInterp = 0x1000000,
kIdleBefore = 0x2000000,
kIdleBeyond = 0x4000000,
kZWasOff = 0x8000000
};
struct hsSfxDfTableEntry {
hsScalar fDistDel;
hsScalar fDistNorm;
hsScalar fOpacity;
};
protected:
hsScalar fMinDist;
hsScalar fMaxDist;
hsScalar fMinIdle;
hsScalar fMaxIdle;
int32_t fTreeCnt;
hsExpander<hsSfxDfTableEntry> fTable;
hsGMatState fRestoreOver;
hsBool32 ISetOpac(plDrawable* refObj);
hsScalar IOpacFromDist(hsScalar dist);
public:
hsSfxObjDistFade();
virtual ~hsSfxObjDistFade();
virtual hsBool32 BeginTree(plPipeline* pipe, plDrawable* root);
virtual hsBool32 BeginObject(plPipeline* pipe, plDrawable* obj);
virtual void EndObject();
virtual void EndTree();
void MakeTable(float* distList, float* opacList, int num); // lists sorted from lowest cosine to highest
virtual void Read(hsStream* s);
virtual void Write(hsStream* s);
virtual const char* GetLabel() const { return "hsSfxObjDistFade"; }
virtual ProcType GetType() const { return kTypeObjDistFade; }
CLASSNAME_REGISTER( hsSfxObjDistFade );
GETINTERFACE_ANY( hsSfxObjDistFade, hsGRenderProcs );
};
#endif // hsSfxObjDistFade_inc

217
Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxObjDistShade.cpp

@ -1,217 +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==*/
#include "hsTypes.h"
#include "hsMemory.h"
#include "hsSfxObjDistShade.h"
#include "hsStream.h"
#include "../plPipeline/plPipeline.h"
#include "../plGeometry/hsTriangle3.h"
#include "../plIntersect/hsBounds.h"
#include "../plDrawable/plDrawable.h"
static hsScalar globalScale = 1.f;
hsSfxObjDistShade::hsSfxObjDistShade()
: fMinDist(0), fMaxDist(0), fTreeCnt(0)
{
}
hsSfxObjDistShade::~hsSfxObjDistShade()
{
}
hsScalar hsSfxObjDistShade::IShadeFromDist(hsScalar dist)
{
if( dist <= fTable[0].fDistDel )
return fTable[0].fShade;
int i;
for( i = 0; (i < fTable.GetCount()) && (dist >= fTable[i].fDistDel); i++ )
dist -= fTable[i].fDistDel;
if( i >= fTable.GetCount() )
return fTable[fTable.GetCount()-1].fShade;
dist *= fTable[i-1].fDistNorm;
hsScalar shade0 = fTable[i-1].fShade;
hsScalar shade1 = fTable[i].fShade;
return shade0 + dist * (shade1 - shade0);
}
hsBool32 hsSfxObjDistShade::ISetShade(plDrawable* refObj)
{
hsPoint3 refPos;
if( fFlags & kByBoundsCenter )
{
const hsBounds3Ext& bnd = refObj->GetWorldBounds();
if( kBoundsNormal != bnd.GetType() )
return true;
refPos = bnd.GetCenter();
}
else
{
refObj->GetLocalToWorld().GetTranslate(&refPos);
}
hsPoint3 vPos;
if( GetObjectRef(1) )
{
GetObjectRef(1)->GetLocalToWorld().GetTranslate(&vPos);
}
else
{
vPos = fPipeline->GetViewPositionWorld();
}
hsScalar dist = hsVector3(&vPos, &refPos).Magnitude();
hsScalar shade = IShadeFromDist(dist);
hsColorRGBA col = fColorizer.GetCurrentColor();
if( fColorizer.Colorizing() )
{
col.r *= shade;
col.g *= shade;
col.b *= shade;
}
else
{
col.r = shade;
col.g = shade;
col.b = shade;
}
fColorizer.PushColorize(col, false);
return true;
}
hsBool32 hsSfxObjDistShade::BeginObject(plPipeline* pipe, plDrawable* obj)
{
hsGRenderProcs::BeginObject(pipe, obj);
plDrawable* refObj = fFlags & kObjectRefs ? GetObjectRef(0) : nil;
if( !refObj )
refObj = obj;
return ISetShade(refObj);
}
void hsSfxObjDistShade::MakeTable(float* distList, float* shadeList, int num)
{
fTable.Reset();
if( !num )
return;
int i;
for( i = 0; i < num; i++ )
{
hsSfxDfTableEntry* t = fTable.Append();
t->fDistDel = distList[i];
t->fShade = shadeList[i];
}
for( i = num-1; i > 0; i-- )
fTable[i].fDistDel -= fTable[i-1].fDistDel;
for( i = 0; i < num-1; i++ )
fTable[i].fDistNorm = hsScalarInvert(fTable[i+1].fDistDel);
fTable[num-1].fDistNorm = 0;
hsAssert(fTable.GetCount() == num, "Mismatch making table");
int iMin;
for( iMin = 0; (iMin < fTable.GetCount())&&(fTable[iMin].fShade <= 0); iMin++ );
fMinDist = fTable[0].fDistDel;
for( i = 1; i < iMin; i++ )
fMinDist += fTable[i].fDistDel;
int iMax;
for( iMax = fTable.GetCount()-1; (iMax >= 0)&&(fTable[iMax].fShade <= 0); iMax-- );
if( ++iMax >= fTable.GetCount() )
iMax = fTable.GetCount()-1;
fMaxDist = fTable[0].fDistDel;
for( i = 1; i <= iMax; i++ )
fMaxDist += fTable[i].fDistDel;
}
void hsSfxObjDistShade::Read(hsStream* s)
{
fTable.Reset();
fMinDist = s->ReadSwapScalar();
fMaxDist = s->ReadSwapScalar();
int32_t cnt = s->ReadSwap32();
if( cnt )
{
hsSfxDfTableEntry* arr = new hsSfxDfTableEntry[cnt];
int i;
for( i = 0; i < cnt; i++ )
{
arr[i].fDistDel = s->ReadSwapScalar();
arr[i].fDistNorm = s->ReadSwapScalar();
arr[i].fShade = s->ReadSwapScalar();
}
fTable.SetArray(arr, cnt);
}
}
void hsSfxObjDistShade::Write(hsStream* s)
{
s->WriteSwapScalar(fMinDist);
s->WriteSwapScalar(fMaxDist);
s->WriteSwap32(fTable.GetCount());
for( fTable.First(); fTable.More(); fTable.Plus() )
{
s->WriteSwapScalar(fTable.Current().fDistDel);
s->WriteSwapScalar(fTable.Current().fDistNorm);
s->WriteSwapScalar(fTable.Current().fShade);
}
}

98
Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxObjDistShade.h

@ -1,98 +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==*/
#ifndef hsSfxObjDistShade_inc
#define hsSfxObjDistShade_inc
#include "hsBiExpander.h"
#include "hsGRenderProcs.h"
class hsSfxObjDistShade : public hsGRenderProcs {
public:
enum {
kShadeConstant = 0x10000,
kByBoundsCenter = 0x800000,
};
struct hsSfxDfTableEntry {
hsScalar fDistDel;
hsScalar fDistNorm;
hsScalar fShade;
};
protected:
hsScalar fMinDist;
hsScalar fMaxDist;
hsScalar fConstShade;
hsScalar fMinIdle;
hsScalar fMaxIdle;
int32_t fTreeCnt;
hsExpander<hsSfxDfTableEntry> fTable;
hsBool32 ISetShade(plDrawable* refObj);
hsScalar IShadeFromDist(hsScalar dist);
public:
hsSfxObjDistShade();
virtual ~hsSfxObjDistShade();
virtual hsBool32 BeginObject(plPipeline* pipe, plDrawable* obj);
void MakeTable(float* distList, float* shadeList, int num); // lists sorted from lowest cosine to highest
virtual void Read(hsStream* s);
virtual void Write(hsStream* s);
virtual const char* GetLabel() const { return "hsSfxObjDistShade"; }
virtual ProcType GetType() const { return kTypeObjDistShade; }
CLASSNAME_REGISTER( hsSfxObjDistShade );
GETINTERFACE_ANY( hsSfxObjDistShade, hsGRenderProcs );
};
#endif // hsSfxObjDistShade_inc

80
Sources/Plasma/PubUtilLib/plGRenderProcs/plGRenderProcsCreatable.h

@ -1,80 +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==*/
#ifndef plGRenderProcsCreatable_inc
#define plGRenderProcsCreatable_inc
#include "../plResMgr/plCreator.h"
#include "hsGRenderProcs.h"
REGISTER_NONCREATABLE( hsGRenderProcs );
#include "hsSfxAngleFade.h"
REGISTER_CREATABLE( hsSfxAngleFade );
#include "hsSfxDistFade.h"
REGISTER_CREATABLE( hsSfxDistFade );
#include "hsSfxDistShade.h"
REGISTER_CREATABLE( hsSfxDistShade );
#include "hsSfxGlobalShade.h"
REGISTER_CREATABLE( hsSfxGlobalShade );
#include "hsSfxIntenseAlpha.h"
REGISTER_CREATABLE( hsSfxIntenseAlpha );
#include "hsSfxObjDistFade.h"
REGISTER_CREATABLE( hsSfxObjDistFade );
#include "hsSfxObjDistShade.h"
REGISTER_CREATABLE( hsSfxObjDistShade );
#endif // plGRenderProcsCreatable_inc

763
Sources/Plasma/PubUtilLib/plGeometry/hsOscillator.cpp

@ -1,763 +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==*/
#include "hsTypes.h"
#include "hsStream.h"
#include "hsOscillator.h"
#include "../plMath/hsFastMath.h"
#include "hsGTriMesh.h"
#include "hsTriangle3.h"
#include "../plPipeline/plPipeline.h"
#if defined(__MWERKS__) && !defined(HS_DEBUGGING)
#pragma optimization_level 0
#endif
static hsScalar rnd0_1()
{
return hsScalar(rand()) / hsScalar(RAND_MAX);
}
void hsWave::Save(hsStream* s, hsScalar secs)
{
fWorldCenter.Write(s);
s->WriteSwapScalar(fWorldFrequency);
s->WriteSwapScalar(fWorldAmplitude);
s->WriteSwapScalar(fPhase);
s->WriteSwapScalar(fRate);
s->WriteSwapScalar(secs - fStartSecs);
s->WriteSwapScalar(fSecsToLive);
}
void hsWave::Load(hsStream* s, hsScalar secs)
{
fWorldCenter.Read(s);
fWorldFrequency = s->ReadSwapScalar();
fWorldAmplitude = s->ReadSwapScalar();
fPhase = s->ReadSwapScalar();
fRate = s->ReadSwapScalar();
fStartSecs = s->ReadSwapScalar();
fStartSecs = secs - fStartSecs;
fSecsToLive = s->ReadSwapScalar();
}
void hsWave::Init(hsScalar secs, hsPoint3& center, hsScalar per, hsScalar amp, hsScalar rate, hsScalar life, hsBool32 attenOut)
{
fStartSecs = secs;
fWorldCenter = center;
fWorldFrequency = hsScalarInvert(per);
fWorldAmplitude = amp;
fRate = rate;
fSecsToLive = life;
AttenuateOut(attenOut);
}
hsBool32 hsWave::IsSpent(hsScalar secs) const
{
return secs - fStartSecs > fSecsToLive;
}
void hsWave::Accumulate(const hsPoint3& pos, const hsVector3& localZ, hsVector3& accum, hsVector3& accumNorm) const
{
hsVector3 del(&pos, &fLocalCenter);
hsScalar dot = del.InnerProduct(localZ);
dot *= -2.f;
del += localZ * dot;
hsScalar dist = del.MagnitudeSquared();
dist = hsFastMath::InvSqrtAppr(dist);
del *= dist;
dist = hsScalarInvert(dist);
hsScalar ampl = fLocalAmplitude;
if( fAttenuateOutScale > 0 )
{
if( dist > fInnerRadius )
{
if( dist > fOuterRadius )
return;
ampl *= fOuterRadius - dist;
ampl *= fAttenuateOutScale;
}
}
dist *= fLocalFrequency;
dist += fPhase;
hsScalar s, c;
hsFastMath::SinCosAppr(dist, s, c);
s *= ampl;
s += ampl;
c *= ampl * fLocalFrequency;
// accum += s * localZ;
accum.fZ += s / localZ.fZ;
hsVector3 norm;
norm = localZ;
norm += del * -c;
accumNorm += norm;
return;
}
void hsWave::Update(hsScalar secs, const hsMatrix44& l2w, const hsMatrix44& w2l)
{
if( l2w.fFlags & hsMatrix44::kIsIdent )
{
fLocalCenter = fWorldCenter;
fLocalFrequency = fWorldFrequency;
fLocalAmplitude = fWorldAmplitude;
}
else
{
hsVector3 ax;
ax.Set(w2l.fMap[0][2], w2l.fMap[1][2], w2l.fMap[2][2]);
hsScalar ooScale = ax.MagnitudeSquared();
ooScale = hsFastMath::InvSqrtAppr(ooScale);
fLocalCenter = w2l * fWorldCenter;
fLocalFrequency = fWorldFrequency * ooScale;
hsScalar scale = 1.f / ooScale;
fLocalAmplitude = fWorldAmplitude * scale;
}
fLocalAmplitude *= AgeScale(secs);
if( fAttenuateOutScale > 0 )
{
fInnerRadius = fRate * (secs - fStartSecs) * hsScalarPI * 2.f;
fOuterRadius = fInnerRadius * (5.f/4.f);
fAttenuateOutScale = hsScalarInvert(fOuterRadius - fInnerRadius);
}
fPhase = -(secs - fStartSecs) * fRate * hsScalarPI * 2.f;
}
hsScalar hsWave::ScaledAmplitude(hsScalar secs) const
{
return fWorldAmplitude * AgeScale(secs);
}
hsScalar hsWave::AgeScale(hsScalar secs) const
{
hsScalar age = secs - fStartSecs;
extern int dbgCurrentTest;
if( dbgCurrentTest )
{
age *= 4.f;
age -= 2.f * fSecsToLive;
if( age < 0 )
age = -age;
age -= fSecsToLive;
}
else
{
age *= 2.f;
age -= fSecsToLive;
if( age < 0 )
age = -age;
}
hsScalar ageScale = 1.f - age / fSecsToLive;
if( ageScale < 0 )
ageScale = 0;
else if( ageScale > 1.f )
ageScale = 1.f;
return ageScale;
}
hsOscillator::hsOscillator()
{
}
hsOscillator::~hsOscillator()
{
}
hsWave& hsOscillator::GetWeakestWave(hsScalar secs)
{
hsAssert(!GetDisabled(), "Shouldn't be messing with disabled oscillator system");
int weakest = 0;
hsScalar amp = fWaves[0].ScaledAmplitude(secs);
int i;
for( i = 0; i < fWaves.GetCount(); i++ )
{
hsScalar tAmp = fWaves[i].ScaledAmplitude(secs);
if( tAmp < amp )
{
weakest = i;
amp = tAmp;
}
}
return fWaves[weakest];
}
hsWave& hsOscillator::GetTempWave(hsScalar secs)
{
int i;
for( i = 0; i < fTempWaves.GetCount(); i++ )
{
if( fTempWaves[i].IsSpent(secs) )
return fTempWaves[i];
}
fTempWaves.Push();
return fTempWaves[fTempWaves.GetCount()-1];
}
void hsOscillator::ISpawnWave(hsScalar secs, int i)
{
hsPoint3 corner;
fWorldCenterBounds.GetCorner(&corner);
hsVector3 ax[3];
fWorldCenterBounds.GetAxes(ax+0, ax+1, ax+2);
hsScalar r;
r = rnd0_1();
ax[0] *= r;
corner += ax[0];
r = rnd0_1();
ax[1] *= r;
corner += ax[1];
r = rnd0_1();
ax[2] *= r;
corner += ax[2];
hsScalar per = fMinPeriod;
r = rnd0_1();
hsScalar rr = r;
r *= fMaxPeriod - fMinPeriod;
per += r;
hsScalar amp = fMinAmplitude;
r = rr * rnd0_1();
r *= fMaxAmplitude - fMinAmplitude;
amp += r;
hsScalar life = fMinLife;
r = rnd0_1();
r *= fMaxLife - fMinLife;
life += r;
hsScalar rate = fMinRate;
r = rnd0_1();
r *= fMaxRate - fMinRate;
rate += r;
fWaves[i].Init(secs, corner, per, amp, rate, life);
}
void hsOscillator::IUpdate(hsScalar secs, plPipeline* pipe, const hsMatrix44& l2w, const hsMatrix44& w2l)
{
if( GetDisabled() )
return;
fWorldCenter = pipe->GetViewPositionWorld();
fWorldCenter.fZ = (fWorldCenterBounds.GetMins().fZ + fWorldCenterBounds.GetMaxs().fZ) * 0.5f;
fLocalCenter = w2l * fWorldCenter;
fLocalToWorld = l2w;
fWorldToLocal = w2l;
fLocalX.Set(w2l.fMap[0][0],w2l.fMap[1][0],w2l.fMap[2][0]);
fLocalX.Normalize();
fLocalY.Set(w2l.fMap[0][1],w2l.fMap[1][1],w2l.fMap[2][1]);
fLocalY.Normalize();
fLocalZ.Set(w2l.fMap[0][2],w2l.fMap[1][2],w2l.fMap[2][2]);
fLocalZ.Normalize();
hsVector3 ax;
hsScalar ooScale;
ax.Set(w2l.fMap[0][0], w2l.fMap[1][0], w2l.fMap[2][0]);
ooScale = ax.MagnitudeSquared();
ooScale = hsFastMath::InvSqrtAppr(ooScale);
fLocalAttenScale.fX = fWorldAttenScale.fX * ooScale;
ax.Set(w2l.fMap[0][1], w2l.fMap[1][1], w2l.fMap[2][1]);
ooScale = ax.MagnitudeSquared();
ooScale = hsFastMath::InvSqrtAppr(ooScale);
fLocalAttenScale.fY = fWorldAttenScale.fY * ooScale;
fLocalAttenScale.fZ = 0;
int i;
for( i = 0; i < fWaves.GetCount(); i++ )
{
if( fWaves[i].IsSpent(secs) )
ISpawnWave(secs, i);
fWaves[i].Update(secs, l2w, w2l);
}
for( i = 0; i < fTempWaves.GetCount(); i++ )
{
while( (i < fTempWaves.GetCount()) && fTempWaves[i].IsSpent(secs) )
fTempWaves.Remove(i, 1);
if( i < fTempWaves.GetCount() )
fTempWaves[i].Update(secs, l2w, w2l);
}
}
hsScalar hsOscillator::IAttenuate(const hsPoint3& in) const
{
const hsPoint3& cen = fLocalCenter;
hsVector3 del(&in, &cen);
hsScalar atX = del.InnerProduct(fLocalX);
atX *= fLocalAttenScale.fX;
if( atX > 0 )
atX = -atX;
atX += 1.f;
if( atX < 0 )
atX = 0;
hsScalar atY = del.InnerProduct(fLocalY);
atY *= fLocalAttenScale.fY;
if( atY > 0 )
atY = -atY;
atY += 1.f;
if( atY < 0 )
atY = 0;
hsScalar at = atX * atY;
return at;
}
void hsOscillator::AdjustWorldBounds(const hsMatrix44& l2w, const hsMatrix44& w2l, hsBounds3Ext& bnd) const
{
if( GetDisabled() )
return;
hsVector3 adj;
adj.Set(0,1.f/fLocalZ.fZ,0);
adj = l2w * adj;
adj *= fMaxAmplitude * fWaves.GetCount();
bnd.Union(&adj);
adj = -adj;
bnd.Union(&adj);
}
void hsOscillator::IPerterb(const hsPoint3& in, hsGVertex3& out) const
{
hsPoint3 pos = in;
hsVector3 del(&pos, &fLocalCenter);
hsScalar dot = del.InnerProduct(fLocalZ);
pos += fLocalZ * -dot;
hsVector3 accum;
hsVector3 accumNorm;
accum.Set(0,0,0);
accumNorm.Set(0,0,0);
int i;
for( i = 0; i < fWaves.GetCount(); i++ )
{
fWaves[i].Accumulate(pos, fLocalZ, accum, accumNorm);
}
for( i = 0; i < fTempWaves.GetCount(); i++ )
{
fTempWaves[i].Accumulate(pos, fLocalZ, accum, accumNorm);
}
hsScalar atten = IAttenuate(pos);
static int attenuating = 1;
if( attenuating ) // nuke me
accum *= atten;
out.fLocalPos = in + accum;
hsScalar invNorm = hsFastMath::InvSqrtAppr(accumNorm.MagnitudeSquared());
accumNorm *= invNorm;
out.fNormal = accumNorm;
}
void hsOscillator::Read(hsStream* s)
{
int n = s->ReadSwap32();
SetNumWaves(n);
fWorldAttenScale.Read(s);
fWorldCenterBounds.Read(s);
fMinPeriod = s->ReadSwapScalar();
fMaxPeriod = s->ReadSwapScalar();
fMinAmplitude = s->ReadSwapScalar();
fMaxAmplitude = s->ReadSwapScalar();
fMinRate = s->ReadSwapScalar();
fMaxRate = s->ReadSwapScalar();
fMinLife = s->ReadSwapScalar();
fMaxLife = s->ReadSwapScalar();
int i;
for( i = 0; i < fWaves.GetCount(); i++ )
fWaves[i].Kill();
fTempWaves.Reset();
}
void hsOscillator::Load(hsStream* s, hsScalar secs)
{
Read(s);
int i;
for( i = 0; i < fWaves.GetCount(); i++ )
fWaves[i].Load(s, secs);
fTempWaves.Reset();
}
void hsOscillator::Write(hsStream* s)
{
s->WriteSwap32(fWaves.GetCount());
fWorldAttenScale.Write(s);
fWorldCenterBounds.Write(s);
s->WriteSwapScalar(fMinPeriod);
s->WriteSwapScalar(fMaxPeriod);
s->WriteSwapScalar(fMinAmplitude);
s->WriteSwapScalar(fMaxAmplitude);
s->WriteSwapScalar(fMinRate);
s->WriteSwapScalar(fMaxRate);
s->WriteSwapScalar(fMinLife);
s->WriteSwapScalar(fMaxLife);
}
void hsOscillator::Save(hsStream* s, hsScalar secs)
{
Write(s);
int i;
for( i = 0; i < fWaves.GetCount(); i++ )
fWaves[i].Save(s, secs);
}
void hsOscillator::SetNumWaves(int n)
{
fWaves.SetCount(n);
int i;
for( i = 0; i < n; i++ )
fWaves[i].Kill();
}
void hsOscillator::Init(int32_t nParams, hsScalar* params)
{
// NumWaves = 1
// AttenScale = 2
// WorldCenterBounds = 6
// Period = 2
// Amp = 2
// Rate = 2
// Life = 2
hsAssert(17 == nParams, "Parameter input mismatch");
SetNumWaves(int(*params++));
fWorldAttenScale.fX = *params++;
fWorldAttenScale.fY = *params++;
fWorldAttenScale.fZ = 0;
hsPoint3 pt;
hsBounds3Ext bnd;
pt.fX = *params++;
pt.fY = *params++;
pt.fZ = *params++;
bnd.Reset(&pt);
pt.fX = *params++;
pt.fY = *params++;
pt.fZ = *params++;
bnd.Union(&pt);
SetWorldCenterBounds(bnd);
SetPeriodRange(params[0], params[1]);
params += 2;
SetAmplitudeRange(params[0], params[1]);
params += 2;
SetRateRange(params[0], params[1]);
params += 2;
SetLifeRange(params[0], params[1]);
fTempWaves.Reset();
}
#if 1
hsGTriMesh* hsOscillator::MakeWaveMesh(int nSpokes, const hsPoint3& center, hsScalar minRad, hsScalar maxRad, hsScalar uRange, hsScalar vRange, hsScalar attenStartFrac, hsBool32 stitch)
{
hsGTriMesh* triMesh = new hsGTriMesh;
hsTArray<hsScalar> radii;
hsScalar cRad = 0;
while( cRad < maxRad )
{
// OOPS - for the half circle, this should be PI*R/n, not 2PI. Don't fix until we've corrected the callers. Or we might want to leave it like
// this anyway, since we're looking obliquely at these faces anyway, and this error stretches the side that perspective compresses. May
// want to make the unstitched version wrong in the same way.
hsScalar tRad = 2.f * hsScalarPI * cRad / nSpokes;
if( tRad < minRad )
tRad = minRad;
cRad += tRad;
radii.Append(cRad);
}
int nShell = radii.GetCount();
int nTris = stitch
? 2 * nSpokes * (nShell-1) + nSpokes
: 2 * (nSpokes-1) * (nShell-1) + (nSpokes-1);
int nVerts = nSpokes * nShell + 1;
triMesh->AllocatePointers(nTris, nVerts, nVerts, nVerts);
triMesh->SetNumTriVertex(nVerts);
triMesh->SetNumPoints(nVerts);
triMesh->SetNumUvs(nVerts);
triMesh->SetHasColors(true);
*triMesh->GetPoint(0) = center;
triMesh->GetNormal(0)->Set(0,1.f,0);
triMesh->GetColor(0)->Set(0,0,0,1.f);
triMesh->GetUvs(0)->fX = triMesh->GetUvs(0)->fY = triMesh->GetUvs(0)->fZ = 0;
hsScalar iToRadians = stitch
? 2.f * hsScalarPI / nSpokes
: hsScalarPI / nSpokes;
hsScalar attenStart = maxRad * attenStartFrac;
hsScalar attenEnd = maxRad;
hsScalar attenScale = hsScalarInvert(attenEnd - attenStart);
int i, j;
for( i = 0; i < nSpokes; i++ )
{
hsScalar s = hsSine(i * iToRadians);
hsScalar c = hsCosine(i * iToRadians);
for( j = 0; j < nShell; j++ )
{
hsAssert(1 + i*nShell + j < nVerts, "Going out of range on verts");
hsGVertex3* vtx = triMesh->GetVertex(1 + i*nShell + j);
hsColorRGBA* col = triMesh->GetColor(1 + i*nShell + j);
hsGUv* uv = triMesh->GetUvs(1 + i*nShell + j);
hsScalar x = c * radii[j];
hsScalar y = s * radii[j];
hsScalar u = x / uRange;
hsScalar v = y / vRange;
vtx->fLocalPos.fX = center.fX + x;
vtx->fLocalPos.fY = center.fY + y;
vtx->fLocalPos.fZ = 0.f;
vtx->fNormal.Set(0,0,1.f);
uv->fX = u;
uv->fY = v;
uv->fZ = 0.f;
if( radii[j] > attenStart )
{
hsScalar a = (attenEnd - radii[j]) * attenScale;
if( a < 0 )
a = 0;
else if( a > 1.f )
a = 1.f;
col->Set(0,0,0,a);
}
else
col->Set(0,0,0,1.f);
}
}
int spokeEnd = stitch ? nSpokes : nSpokes-1;
int nextTri = 0;
for( i = 0; i < spokeEnd; i++ )
{
hsTriangle3* tri = triMesh->GetTriFromPool(nextTri);
tri->Zero();
tri->fOrigTri = tri;
triMesh->SetTriangle(nextTri++, tri);
tri->fVert[0] = triMesh->GetTriVertex(0);
tri->fVert[0]->fVtx = triMesh->GetVertex(0);
tri->fVert[0]->SetNumUvChannels(1);
tri->fVert[0]->fUvChan[0] = triMesh->GetUvs(0);
tri->fVert[0]->fVtxColor = triMesh->GetColor(0);
int iv0 = 1 + i * nShell;
int iv1 = i < nSpokes - 1 ? 1 + (i+1)*nShell : 1;
hsAssert((iv0 < nVerts)&&(iv1 < nVerts), "Out of range on triverts");
tri->fVert[1] = triMesh->GetTriVertex(iv0);
tri->fVert[1]->fVtx = triMesh->GetVertex(iv0);
tri->fVert[1]->SetNumUvChannels(1);
tri->fVert[1]->fUvChan[0] = triMesh->GetUvs(iv0);
tri->fVert[1]->fVtxColor = triMesh->GetColor(iv0);
tri->fVert[2] = triMesh->GetTriVertex(iv1);
tri->fVert[2]->fVtx = triMesh->GetVertex(iv1);
tri->fVert[2]->SetNumUvChannels(1);
tri->fVert[2]->fUvChan[0] = triMesh->GetUvs(iv1);
tri->fVert[2]->fVtxColor = triMesh->GetColor(iv1);
tri->fVert[0]->fFlags = hsGTriVertex::kHasPointers
| hsGTriVertex::kHasVertexUvs
| hsGTriVertex::kHasVertexColors;
tri->fVert[1]->fFlags = hsGTriVertex::kHasPointers
| hsGTriVertex::kHasVertexUvs
| hsGTriVertex::kHasVertexColors;
tri->fVert[2]->fFlags = hsGTriVertex::kHasPointers
| hsGTriVertex::kHasVertexUvs
| hsGTriVertex::kHasVertexColors;
tri->fFlags |= hsTriangle3::kHasVertexPosNorms
| hsTriangle3::kHasVertexUvs
| hsTriangle3::kHasVertexColors
| hsTriangle3::kHasPointers;
int iv2 = iv0 + 1;
int iv3 = iv1 + 1;
hsAssert((iv1 < nVerts)&&(iv2 < nVerts), "Out of range on triverts");
for( j = 0; j < nShell-1; j++ )
{
tri = triMesh->GetTriFromPool(nextTri);
tri->Zero();
tri->fOrigTri = tri;
triMesh->SetTriangle(nextTri++, tri);
tri->fVert[0] = triMesh->GetTriVertex(iv0);
tri->fVert[0]->fVtx = triMesh->GetVertex(iv0);
tri->fVert[0]->SetNumUvChannels(1);
tri->fVert[0]->fUvChan[0] = triMesh->GetUvs(iv0);
tri->fVert[0]->fVtxColor = triMesh->GetColor(iv0);
tri->fVert[1] = triMesh->GetTriVertex(iv2);
tri->fVert[1]->fVtx = triMesh->GetVertex(iv2);
tri->fVert[1]->SetNumUvChannels(1);
tri->fVert[1]->fUvChan[1] = triMesh->GetUvs(iv2);
tri->fVert[1]->fVtxColor = triMesh->GetColor(iv2);
tri->fVert[2] = triMesh->GetTriVertex(iv3);
tri->fVert[2]->fVtx = triMesh->GetVertex(iv3);
tri->fVert[2]->SetNumUvChannels(1);
tri->fVert[2]->fUvChan[0] = triMesh->GetUvs(iv3);
tri->fVert[2]->fVtxColor = triMesh->GetColor(iv3);
tri->fVert[0]->fFlags = hsGTriVertex::kHasPointers
| hsGTriVertex::kHasVertexUvs
| hsGTriVertex::kHasVertexColors;
tri->fVert[1]->fFlags = hsGTriVertex::kHasPointers
| hsGTriVertex::kHasVertexUvs
| hsGTriVertex::kHasVertexColors;
tri->fVert[2]->fFlags = hsGTriVertex::kHasPointers
| hsGTriVertex::kHasVertexUvs
| hsGTriVertex::kHasVertexColors;
tri->fFlags |= hsTriangle3::kHasVertexPosNorms
| hsTriangle3::kHasVertexUvs
| hsTriangle3::kHasVertexColors
| hsTriangle3::kHasPointers;
tri = triMesh->GetTriFromPool(nextTri);
tri->Zero();
tri->fOrigTri = tri;
triMesh->SetTriangle(nextTri++, tri);
tri->fVert[0] = triMesh->GetTriVertex(iv0);
tri->fVert[0]->fVtx = triMesh->GetVertex(iv0);
tri->fVert[0]->SetNumUvChannels(1);
tri->fVert[0]->fUvChan[0] = triMesh->GetUvs(iv0);
tri->fVert[0]->fVtxColor = triMesh->GetColor(iv0);
tri->fVert[1] = triMesh->GetTriVertex(iv3);
tri->fVert[1]->fVtx = triMesh->GetVertex(iv3);
tri->fVert[1]->SetNumUvChannels(1);
tri->fVert[1]->fUvChan[0] = triMesh->GetUvs(iv3);
tri->fVert[1]->fVtxColor = triMesh->GetColor(iv3);
tri->fVert[2] = triMesh->GetTriVertex(iv1);
tri->fVert[2]->fVtx = triMesh->GetVertex(iv1);
tri->fVert[2]->SetNumUvChannels(1);
tri->fVert[2]->fUvChan[0] = triMesh->GetUvs(iv1);
tri->fVert[2]->fVtxColor = triMesh->GetColor(iv1);
tri->fVert[0]->fFlags = hsGTriVertex::kHasPointers
| hsGTriVertex::kHasVertexUvs
| hsGTriVertex::kHasVertexColors;
tri->fVert[1]->fFlags = hsGTriVertex::kHasPointers
| hsGTriVertex::kHasVertexUvs
| hsGTriVertex::kHasVertexColors;
tri->fVert[2]->fFlags = hsGTriVertex::kHasPointers
| hsGTriVertex::kHasVertexUvs
| hsGTriVertex::kHasVertexColors;
tri->fFlags |= hsTriangle3::kHasVertexPosNorms
| hsTriangle3::kHasVertexUvs
| hsTriangle3::kHasVertexColors
| hsTriangle3::kHasPointers;
iv0++;
iv1++;
iv2++;
iv3++;
}
}
hsAssert(nextTri <= nTris, "Out of range on tris");
triMesh->StoreOrigPoints();
return triMesh;
}
#endif

180
Sources/Plasma/PubUtilLib/plGeometry/hsOscillator.h

@ -1,180 +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==*/
#ifndef hsOscillator_inc
#define hsOscillator_inc
#include "hsPerterber.h"
#include "hsTemplates.h"
#include "hsGeometry3.h"
#include "../plIntersect/hsBounds.h"
class hsStream;
class plPipeline;
class hsWave
{
protected:
hsPoint3 fWorldCenter;
hsPoint3 fLocalCenter;
hsScalar fWorldFrequency; // 1.0 / Period
hsScalar fLocalFrequency;
hsScalar fWorldAmplitude;
hsScalar fLocalAmplitude;
hsScalar fPhase;
hsScalar fRate; // how long a crest takes to reach next crest
hsScalar fStartSecs;
hsScalar fSecsToLive;
hsScalar fInnerRadius;
hsScalar fOuterRadius;
hsScalar fAttenuateOutScale;
hsScalar AgeScale(hsScalar secs) const;
public:
void Accumulate(const hsPoint3& pos, const hsVector3& localZ, hsVector3& accum, hsVector3& accumNorm) const;
hsScalar ScaledAmplitude(hsScalar secs) const;
void Init(hsScalar secs, hsPoint3& center, hsScalar per, hsScalar amp, hsScalar rate, hsScalar life, hsBool32 attenOut=false);
void Update(hsScalar secs, const hsMatrix44& l2w, const hsMatrix44& w2l);
hsBool32 IsSpent(hsScalar secs) const;
void Kill() { fStartSecs = fSecsToLive = 0; }
void AttenuateOut(hsBool32 on) { fAttenuateOutScale = (on ? 1.f : 0); }
hsBool32 GetAttenuateOut() { return fAttenuateOutScale > 0; }
void Save(hsStream* s, hsScalar secs);
void Load(hsStream* s, hsScalar secs);
};
class hsOscillator : public hsPerterber
{
protected:
hsTArray<hsWave> fWaves;
hsTArray<hsWave> fTempWaves;
hsMatrix44 fLocalToWorld;
hsMatrix44 fWorldToLocal;
hsPoint3 fWorldCenter;
hsPoint3 fLocalCenter;
hsVector3 fWorldAttenScale;
hsVector3 fLocalAttenScale;
hsBounds3Ext fWorldCenterBounds;
hsScalar fMinPeriod;
hsScalar fMaxPeriod;
hsScalar fMinAmplitude;
hsScalar fMaxAmplitude;
hsScalar fMinRate;
hsScalar fMaxRate;
hsScalar fMinLife;
hsScalar fMaxLife;
hsVector3 fLocalX;
hsVector3 fLocalY;
hsVector3 fLocalZ;
hsScalar IAttenuate(const hsPoint3& in) const;
void ISpawnWave(hsScalar secs, int i);
virtual void IUpdate(hsScalar secs, plPipeline* pipe, const hsMatrix44& l2w, const hsMatrix44& w2l);
virtual void IPerterb(const hsPoint3& in, hsGVertex3& out) const;
public:
hsOscillator();
virtual ~hsOscillator();
virtual void AdjustWorldBounds(const hsMatrix44& l2w, const hsMatrix44& w2l, hsBounds3Ext& bnd) const;
virtual uint32_t GetType() const { return kTypeOscillator; }
// Don't call these, use base class LabelAndWrite() and CreateAndRead()
virtual void Read(hsStream* s);
virtual void Write(hsStream* s);
virtual void Load(hsStream* s, hsScalar secs);
virtual void Save(hsStream* s, hsScalar secs);
void SetPeriodRange(hsScalar lo, hsScalar hi) { fMinPeriod = lo; fMaxPeriod = hi; }
void SetAmplitudeRange(hsScalar lo, hsScalar hi) { fMinAmplitude = lo; fMaxAmplitude = hi; }
void SetRateRange(hsScalar lo, hsScalar hi) { fMinRate = lo; fMaxRate = hi; }
void SetLifeRange(hsScalar lo, hsScalar hi) { fMinLife = lo; fMaxLife = hi; }
hsScalar GetMinPeriod() const { return fMinPeriod; }
hsScalar GetMaxPeriod() const { return fMaxPeriod; }
hsScalar GetMinAmplitude() const { return fMinAmplitude; }
hsScalar GetMaxAmplitude() const { return fMaxAmplitude; }
hsScalar GetMinRate() const { return fMinRate; }
hsScalar GetMaxRate() const { return fMaxRate; }
hsScalar GetMinLife() const { return fMinLife; }
hsScalar GetMaxLife() const { return fMaxLife; }
void SetWorldAttenScale(const hsVector3& s) { fWorldAttenScale = s; }
void SetWorldCenterBounds(const hsBounds3Ext& bnd) { fWorldCenterBounds = bnd; }
const hsVector3& GetWorldAttenScale() const { return fWorldAttenScale; }
const hsBounds3Ext& GetWorldCenterBounds() const { return fWorldCenterBounds; }
void SetNumWaves(int n);
uint32_t GetNumWaves() const { return fWaves.GetCount(); }
hsWave& GetWeakestWave(hsScalar secs);
hsWave& GetTempWave(hsScalar secs);
virtual void Init(int32_t nParams, hsScalar* params);
static hsGTriMesh* MakeWaveMesh(int nSpokes, const hsPoint3& center, hsScalar minRad, hsScalar maxRad, hsScalar uRange, hsScalar vRange, hsScalar attenStartFrac, hsBool32 stitch);
};
#endif // hsOscillator_inc

350
Sources/Plasma/PubUtilLib/plGeometry/hsPerterber.cpp

@ -1,350 +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==*/
#include "hsTypes.h"
#include "hsStream.h"
#include "hsPerterber.h"
#include "hsOscillator.h"
#include "hsGMesh.h"
#if 0 // GET_RID_OF_SHAPE_LAYER_DEFER
#include "hsGShape3.h"
#include "hsGShape3MegaMesh.h"
#endif// GET_RID_OF_SHAPE_LAYER_DEFER
#include "../plResMgr/plKey.h"
#include "../plSurface/hsGMaterial.h"
#include "hsTimer.h"
#include "../plPipeline/plPipeline.h"
hsBool32 hsPerterber::fDisabled = false;
hsPerterber::hsPerterber()
{
}
hsPerterber::~hsPerterber()
{
}
void hsPerterber::IUpdate(hsScalar secs, plPipeline* pipe, const hsMatrix44& l2w, const hsMatrix44& w2l)
{
}
void hsPerterber::TimeStampAndSave(hsStream* s)
{
hsScalar secs = hsTimer::GetSeconds();
hsKeyedObject::Save(s, nil);
Save(s, secs);
}
void hsPerterber::TimeStampAndLoad(hsStream* s)
{
hsScalar secs = hsTimer::GetSeconds();
hsKeyedObject::Load(s, nil);
Load(s, secs);
}
void hsPerterber::LabelAndWrite(hsStream* s)
{
s->WriteSwap32(GetType());
Write(s);
}
hsPerterber* hsPerterber::CreateAndRead(hsStream* s)
{
hsPerterber* retVal = nil;
uint32_t t = s->ReadSwap32();
switch( t )
{
case kTypeOscillator:
retVal = new hsOscillator;
break;
default:
hsAssert(false, "Unknown perterber type");
return nil;
}
retVal->Read(s);
return retVal;
}
hsGMesh* hsPerterber::IGetMesh(hsGShape3* shape)
{
hsGMesh* mesh = nil;
#if 0 // GET_RID_OF_SHAPE_LAYER_DEFER
if( shape->GetShapeType() == hsGShape3::kTypeTriMesh )
{
hsGShape3TriMesh* shp = (hsGShape3TriMesh*)shape;
mesh = shp->GetMesh();
#if 0 // move to export
if( mesh->GetKey() && strstr(mesh->GetKey()->GetName(), "create") )
{
hsTArray<hsGMaterial*> matList;
shp->AppendMaterials(matList);
hsGTriMesh* newMesh = hsOscillator::MakeWaveMesh(40, hsPoint3(0,0,0), 4.f, 75.f, 1200.f, 1200.f, 0.75f, false);
newMesh->SetMaterial(matList[0]);
hsRefCnt_SafeUnRef(matList[0]);
shp->SetMesh(newMesh);
hsRefCnt_SafeUnRef(newMesh);
mesh = newMesh;
}
else if( mesh->GetKey() && strstr(mesh->GetKey()->GetName(), "destroy") )
{
hsTArray<hsGMaterial*> matList;
shp->AppendMaterials(matList);
hsGTriMesh* newMesh = hsOscillator::MakeWaveMesh(50, hsPoint3(0,0,0), 1.5f, 30.f, 600.f, 600.f, 0.6f, true);
newMesh->SetMaterial(matList[0]);
hsRefCnt_SafeUnRef(matList[0]);
shp->SetMesh(newMesh);
hsRefCnt_SafeUnRef(newMesh);
mesh = newMesh;
}
else
#endif // move to export
{
hsGTriMesh* triMesh = (hsGTriMesh*)shp->GetMesh();
if( triMesh->GetTriangle(0)->fFlags & hsTriangle3::kHasFacePlane )
triMesh->TrashPlanes();
mesh = triMesh;
}
}
else if( shape->GetShapeType() == hsGShape3::kTypeMegaMesh )
{
hsGShape3MegaMesh* mega = (hsGShape3MegaMesh*)shape;
hsGMegaMesh* megaMesh = (hsGMegaMesh*)mega->GetMegaMesh();
hsGTriMesh* triMesh = (hsGTriMesh*)megaMesh->GetMesh(0);
if( triMesh->GetTriangle(0)->fFlags & hsTriangle3::kHasFacePlane )
{
int iMesh;
for( iMesh = 0; iMesh < megaMesh->GetMeshCount(); iMesh++ )
{
triMesh = (hsGTriMesh*)megaMesh->GetMesh(iMesh);
triMesh->TrashPlanes();
}
}
mesh = mega->GetMegaMesh();
}
#endif // GET_RID_OF_SHAPE_LAYER_DEFER
return mesh;
}
void hsPerterber::Perterb(hsScalar secs, plPipeline* pipe, const hsMatrix44& l2w, const hsMatrix44& w2l, hsGShape3* shape)
{
if( GetDisabled() )
return;
hsGMesh* mesh = IGetMesh(shape);
IUpdate(secs, pipe, l2w, w2l);
if( !mesh->HasOrigPoints() )
mesh->StoreOrigPoints();
int i;
for( i = 0; i < mesh->GetNumPoints(); i++ )
{
IPerterb(*mesh->GetOrigPoint(i), *mesh->GetVertex(i));
}
}
const int kPertCount = 6;
const int kMaxPertParams = 32;
struct hsPertDesc
{
char fName[256];
uint32_t fType;
uint32_t fNumParams;
hsScalar fParams[kMaxPertParams];
};
// NumWaves = 1
// AttenScale = 2
// WorldCenterBounds = 6
// Period = 2
// Amp = 2
// Rate = 2
// Life = 2
//
hsPertDesc sPertTable[kPertCount] =
{
{
"mystocean",
hsPerterber::kTypeOscillator,
17,
{
5.f,
1.f/100.f, 1.f/100.f,
-100.f, 100.f, 0, 100.f, 150.f, 0,
2.f, 5.f,
0.5, 0.75f,
0.68f, 0.68f,
5.f, 10.f
}
},
{
"stoneocean",
hsPerterber::kTypeOscillator,
17,
{
5.f,
1.f/100.f, 1.f/100.f,
-100.f, 100.f, 0, 100.f, 150.f, 0,
2.f, 5.f,
0.5, 0.75f,
0.68f, 0.68f,
5.f, 10.f
}
},
{
"seleniticocean",
hsPerterber::kTypeOscillator,
17,
{
5.f,
1.f/100.f, 1.f/100.f,
-100.f, 100.f, 0, 100.f, 150.f, 0,
2.f, 5.f,
0.25, 0.45f,
0.6f, 0.6f,
5.f, 10.f
}
},
{
"channelocean",
hsPerterber::kTypeOscillator,
17,
{
5.f,
1.f/30.f, 1.f/30.f,
-100.f, -100.f, 0, 100.f, 100.f, 0,
0.25f, 0.5f,
0.1, 0.2f,
0.4f, 0.8f,
5.f, 10.f
}
},
{
"mechocean",
hsPerterber::kTypeOscillator,
17,
{
5.f,
1.f/100.f, 1.f/100.f,
-100.f, 100.f, 0, 100.f, 150.f, 0,
2.f, 5.f,
0.5, 0.4f,
0.68f, 0.68f,
5.f, 10.f
}
},
{
"rimeocean",
hsPerterber::kTypeOscillator,
17,
{
5.f,
1.f/100.f, 1.f/100.f,
-100.f, 100.f, 0, 100.f, 150.f, 0,
2.f, 5.f,
0.5, 0.75,
0.68f, 0.68f,
5.f, 10.f
}
}
};
#if 0 // Used Registry...need to change paulg
void hsPerterber::InitSystem(hsRegistry* reg)
{
if( GetDisabled() )
return;
int i;
for( i = 0; i < kPertCount; i++ )
{
switch( sPertTable[i].fType )
{
case kTypeOscillator:
{
hsOscillator* oscar = new hsOscillator;
oscar->Init(sPertTable[i].fNumParams, sPertTable[i].fParams);
#ifdef PAULFIX
oscar->Register(reg, sPertTable[i].fName, 0, true);
#endif
}
break;
default:
hsAssert(false, "Unknown perterber type");
break;
}
}
}
void hsPerterber::Shutdown(hsRegistry* reg)
{
#ifdef PAULFIX
int i;
for( i = 0; i < reg->GetNumKeys(); i++ )
{
hsPerterber* pert = (hsPerterber*)(reg->GetKey(i)->GetObjectPtr());
delete pert;
}
#endif
}
#endif

107
Sources/Plasma/PubUtilLib/plGeometry/hsPerterber.h

@ -1,107 +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==*/
#ifndef hsPerterber_inc
#define hsPerterber_inc
#include "../plResMgr/hsKeyedObject.h"
#include "hsGeometry3.h"
class hsStream;
class hsGShape3;
class hsBounds3Ext;
class hsGMesh;
class plPipeline;
struct hsMatrix44;
struct hsGVertex3;
class hsPerterber : public hsKeyedObject
{
public:
enum {
kTypeUndefined = 0x0,
kTypeOscillator = 0x1
};
protected:
static hsBool32 fDisabled;
virtual void IUpdate(hsScalar secs, plPipeline* pipe, const hsMatrix44& l2w, const hsMatrix44& w2l);
virtual void IPerterb(const hsPoint3& in, hsGVertex3& out) const = 0;
hsGMesh* IGetMesh(hsGShape3* shape);
public:
hsPerterber();
virtual ~hsPerterber();
static void SetDisabled(hsBool32 on) { fDisabled = on; }
static void ToggleDisabled() { fDisabled = !fDisabled; }
static hsBool32 GetDisabled() { return fDisabled; }
virtual void Perterb(hsScalar secs, plPipeline* pipe, const hsMatrix44& l2w, const hsMatrix44& w2l, hsGShape3* shape);
virtual void AdjustWorldBounds(const hsMatrix44& l2w, const hsMatrix44& w2l, hsBounds3Ext& bnd) const = 0;
virtual uint32_t GetType() const = 0;
virtual void Write(hsStream* s) = 0;
virtual void Read(hsStream* s) = 0;
virtual void Save(hsStream* s, hsScalar secs) = 0;
virtual void Load(hsStream* s, hsScalar secs) = 0;
void TimeStampAndSave(hsStream* s);
void TimeStampAndLoad(hsStream* s);
void LabelAndWrite(hsStream* s);
static hsPerterber* CreateAndRead(hsStream* s);
virtual void Init(int32_t nParams, hsScalar* params) = 0;
#if 0 // Used Registry...need to change paulg
static void InitSystem(plResMgr* reg);
static void Shutdown(plResMgr* reg);
#endif
};
#endif hsPerterber_inc

70
Sources/Plasma/PubUtilLib/plGeometry/plGeometryCreatable.h

@ -1,70 +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==*/
#ifndef plGeometryCreatable_inc
#define plGeometryCreatable_inc
#include "../pnFactory/plCreator.h"
/* Taken out 6.12.2001 mcn - You can remove this file entirely if you wish, I just left
it in in case we wanted to use it in the future...
#include "hsGVertexPool.h"
REGISTER_CREATABLE( hsGVertexPool );
#include "hsGMesh.h"
REGISTER_NONCREATABLE( hsGMesh );
#include "hsGTriMesh.h"
REGISTER_CREATABLE( hsGTriMesh );
#include "hsGMegaMesh.h"
REGISTER_CREATABLE( hsGMegaMesh );
*/
#endif plGeometryCreatable_inc

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,
@ -281,10 +263,6 @@ static const char * s_transTypes[] = {
"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);
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save