From 57757281f8c0e9e049c32eb0acbf980d4b9d6663 Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Sun, 17 Apr 2011 19:37:33 -0700 Subject: [PATCH] Split out minimal core console functionality from the pfConsole module --HG-- rename : Sources/Plasma/FeatureLib/pfConsole/pfConsoleCmd.cpp => Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCmd.cpp rename : Sources/Plasma/FeatureLib/pfConsole/pfConsoleCmd.h => Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCmd.h rename : Sources/Plasma/FeatureLib/pfConsole/pfConsoleContext.cpp => Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleContext.cpp rename : Sources/Plasma/FeatureLib/pfConsole/pfConsoleContext.h => Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleContext.h rename : Sources/Plasma/FeatureLib/pfConsole/pfConsoleEngine.cpp => Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleEngine.cpp --- Sources/Plasma/Apps/plClient/CMakeLists.txt | 1 + Sources/Plasma/Apps/plClient/plClient.cpp | 2 +- Sources/Plasma/Apps/plClient/winmain.cpp | 6 +- Sources/Plasma/FeatureLib/CMakeLists.txt | 1 + .../FeatureLib/pfConsole/CMakeLists.txt | 6 - .../pfConsole/pfAvatarConsoleCommands.cpp | 8 +- .../pfConsole/pfCCRConsoleCommands.cpp | 9 +- .../Plasma/FeatureLib/pfConsole/pfConsole.cpp | 2 +- .../pfConsole/pfConsoleCommands.cpp | 21 +- .../pfConsole/pfConsoleCommandsNet.cpp | 288 +-------------- .../FeatureLib/pfConsole/pfConsoleDirSrc.h | 2 +- .../pfConsole/pfGameConsoleCommands.cpp | 8 +- .../FeatureLib/pfConsoleCore/CMakeLists.txt | 22 ++ .../pfConsoleCmd.cpp | 6 - .../pfConsoleCmd.h | 11 +- .../pfConsoleCore/pfConsoleCommandsCore.cpp | 335 ++++++++++++++++++ .../pfConsoleContext.cpp | 0 .../pfConsoleContext.h | 0 .../pfConsoleEngine.cpp | 0 .../pfConsoleEngine.h | 25 ++ 20 files changed, 412 insertions(+), 341 deletions(-) create mode 100644 Sources/Plasma/FeatureLib/pfConsoleCore/CMakeLists.txt rename Sources/Plasma/FeatureLib/{pfConsole => pfConsoleCore}/pfConsoleCmd.cpp (99%) rename Sources/Plasma/FeatureLib/{pfConsole => pfConsoleCore}/pfConsoleCmd.h (97%) create mode 100644 Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCommandsCore.cpp rename Sources/Plasma/FeatureLib/{pfConsole => pfConsoleCore}/pfConsoleContext.cpp (100%) rename Sources/Plasma/FeatureLib/{pfConsole => pfConsoleCore}/pfConsoleContext.h (100%) rename Sources/Plasma/FeatureLib/{pfConsole => pfConsoleCore}/pfConsoleEngine.cpp (100%) rename Sources/Plasma/FeatureLib/{pfConsole => pfConsoleCore}/pfConsoleEngine.h (84%) diff --git a/Sources/Plasma/Apps/plClient/CMakeLists.txt b/Sources/Plasma/Apps/plClient/CMakeLists.txt index 834a95e6..1efd5a95 100644 --- a/Sources/Plasma/Apps/plClient/CMakeLists.txt +++ b/Sources/Plasma/Apps/plClient/CMakeLists.txt @@ -102,6 +102,7 @@ target_link_libraries(plClient pfCCR) target_link_libraries(plClient pfCharacter) target_link_libraries(plClient pfConditional) target_link_libraries(plClient pfConsole) +target_link_libraries(plClient pfConsoleCore) target_link_libraries(plClient pfCsrSrv) target_link_libraries(plClient pfGameGUIMgr) target_link_libraries(plClient pfGameMgr) diff --git a/Sources/Plasma/Apps/plClient/plClient.cpp b/Sources/Plasma/Apps/plClient/plClient.cpp index ca7880af..88fd43eb 100644 --- a/Sources/Plasma/Apps/plClient/plClient.cpp +++ b/Sources/Plasma/Apps/plClient/plClient.cpp @@ -63,7 +63,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plMessage/plNetCommMsgs.h" #include "plMessage/plAgeLoadedMsg.h" -#include "pfConsole/pfConsoleEngine.h" +#include "pfConsoleCore/pfConsoleEngine.h" #include "pfConsole/pfConsole.h" #include "pfConsole/pfConsoleDirSrc.h" #include "plScene/plPageTreeMgr.h" diff --git a/Sources/Plasma/Apps/plClient/winmain.cpp b/Sources/Plasma/Apps/plClient/winmain.cpp index 32604a3c..b8a0e5b2 100644 --- a/Sources/Plasma/Apps/plClient/winmain.cpp +++ b/Sources/Plasma/Apps/plClient/winmain.cpp @@ -1528,9 +1528,13 @@ LONG WINAPI plCustomUnhandledExceptionFilter( struct _EXCEPTION_POINTERS *Except return EXCEPTION_EXECUTE_HANDLER; } -#include "pfConsole/pfConsoleEngine.h" +#include "pfConsoleCore/pfConsoleEngine.h" +PF_CONSOLE_LINK_ALL() + int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow) { + PF_CONSOLE_INIT_ALL() + // Set global handle gHInst = hInst; diff --git a/Sources/Plasma/FeatureLib/CMakeLists.txt b/Sources/Plasma/FeatureLib/CMakeLists.txt index f215ff41..37f4763e 100644 --- a/Sources/Plasma/FeatureLib/CMakeLists.txt +++ b/Sources/Plasma/FeatureLib/CMakeLists.txt @@ -7,6 +7,7 @@ add_subdirectory(pfCamera) add_subdirectory(pfCharacter) add_subdirectory(pfConditional) add_subdirectory(pfConsole) +add_subdirectory(pfConsoleCore) add_subdirectory(pfCsrSrv) add_subdirectory(pfGameGUIMgr) add_subdirectory(pfGameMgr) diff --git a/Sources/Plasma/FeatureLib/pfConsole/CMakeLists.txt b/Sources/Plasma/FeatureLib/pfConsole/CMakeLists.txt index 81f995be..b44a8b9b 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/CMakeLists.txt +++ b/Sources/Plasma/FeatureLib/pfConsole/CMakeLists.txt @@ -12,23 +12,17 @@ set(pfConsole_SOURCES pfAvatarConsoleCommands.cpp pfCCRConsoleCommands.cpp pfConsole.cpp - pfConsoleCmd.cpp pfConsoleCommands.cpp pfConsoleCommandsNet.cpp - pfConsoleContext.cpp pfConsoleDirSrc.cpp - pfConsoleEngine.cpp pfDispatchLog.cpp pfGameConsoleCommands.cpp ) set(pfConsole_HEADERS pfConsole.h - pfConsoleCmd.h - pfConsoleContext.h pfConsoleCreatable.h pfConsoleDirSrc.h - pfConsoleEngine.h pfDispatchLog.h ) diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfAvatarConsoleCommands.cpp b/Sources/Plasma/FeatureLib/pfConsole/pfAvatarConsoleCommands.cpp index b575e474..8fbec9c8 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfAvatarConsoleCommands.cpp +++ b/Sources/Plasma/FeatureLib/pfConsole/pfAvatarConsoleCommands.cpp @@ -33,7 +33,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #define LIMIT_CONSOLE_COMMANDS 1 #endif -#include "pfConsoleCmd.h" +#include "pfConsoleCore/pfConsoleCmd.h" #include "plgDispatch.h" #include "pfConsole.h" #include "hsResMgr.h" @@ -76,10 +76,10 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #define PF_SANITY_CHECK( cond, msg ) { if( !( cond ) ) { PrintString( msg ); return; } } +//// DO NOT REMOVE!!!! //// This is here so Microsoft VC won't decide to "optimize" this file out -void pfConsoleCmdGroup::DummyAvatar( void ) -{ -} +PF_CONSOLE_FILE_DUMMY(Avatar) +//// DO NOT REMOVE!!!! ///////////////////////////////////////////////////////////////// // diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfCCRConsoleCommands.cpp b/Sources/Plasma/FeatureLib/pfConsole/pfCCRConsoleCommands.cpp index b719868d..da9ea7f9 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfCCRConsoleCommands.cpp +++ b/Sources/Plasma/FeatureLib/pfConsole/pfCCRConsoleCommands.cpp @@ -36,16 +36,15 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com // Only calls to the CCRMgr interface are allowed here // See me if you need to include any other files... // -#include "pfConsoleCmd.h" +#include "pfConsoleCore/pfConsoleCmd.h" #include "pfConsole.h" #include "pfCCR/plCCRMgr.h" #include "plNetClient/plNetClientMgr.h" +//// DO NOT REMOVE!!!! //// This is here so Microsoft VC won't decide to "optimize" this file out -// YOU ALSO NEED TO CALL THIS FXN -void pfConsoleCmdGroup::DummyCCR( void ) -{ -} +PF_CONSOLE_FILE_DUMMY(CCR) +//// DO NOT REMOVE!!!! void PrintStringF(void pfun(const char *),const char * fmt, ...); diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfConsole.cpp b/Sources/Plasma/FeatureLib/pfConsole/pfConsole.cpp index ff0eaf4d..6f076168 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfConsole.cpp +++ b/Sources/Plasma/FeatureLib/pfConsole/pfConsole.cpp @@ -30,7 +30,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com ////////////////////////////////////////////////////////////////////////////// #include "pfConsole.h" -#include "pfConsoleEngine.h" +#include "pfConsoleCore/pfConsoleEngine.h" #include "plPipeline/plDebugText.h" #include "plInputCore/plInputDevice.h" #include "plInputCore/plInputInterface.h" diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp index e858deef..f52353dc 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp +++ b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp @@ -34,7 +34,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #endif -#include "pfConsoleCmd.h" +#include "pfConsoleCore/pfConsoleCmd.h" #include "plgDispatch.h" #include "plAgeLoader/plAgeLoader.h" @@ -75,7 +75,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plVault/plVault.h" #include "../../Apps/plClient/plClient.h" #include "pfConsole.h" -#include "pfConsoleContext.h" +#include "pfConsoleCore/pfConsoleContext.h" #include "plResMgr/plKeyFinder.h" #include "plModifier/plSimpleModifier.h" #include "plAvatar/plAvatarMgr.h" @@ -160,10 +160,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com //// DO NOT REMOVE!!!! //// This is here so Microsoft VC won't decide to "optimize" this file out -//// DO NOT REMOVE!!!! -void pfConsoleCmdGroup::Dummy( void ) -{ -} +PF_CONSOLE_FILE_DUMMY(Main) //// DO NOT REMOVE!!!! //// Defining Console Commands /////////////////////////////////////////////// @@ -258,6 +255,7 @@ plKey FindSceneObjectByName(const char* name, const char* ageName, char* statusS plKey FindObjectByName(const char* name, int type, const char* ageName, char* statusStr, bool subString=false); plKey FindObjectByNameAndType(const char* name, const char* typeName, const char* ageName, char* statusStr, bool subString=false); +void PrintStringF(void pfun(const char *),const char * fmt, ...); // // Find an object from name, type (int), and optionally age. @@ -355,17 +353,6 @@ plKey FindObjectByNameAndType(const char* name, const char* typeName, const char return FindObjectByName(name, plFactory::FindClassIndex(typeName), ageName, statusStr, subString); } -void PrintStringF(void pfun(const char *),const char * fmt, ...) -{ - va_list args; - - char buffy[512]; - va_start(args, fmt); - vsprintf(buffy, fmt, args); - va_end(args); - pfun(buffy); -} - //// plDoesFileExist ////////////////////////////////////////////////////////// // Utility function to determine whether the given file exists diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp index 01ae2d39..bcea676e 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp +++ b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp @@ -34,7 +34,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #endif -#include "pfConsoleCmd.h" +#include "pfConsoleCore/pfConsoleCmd.h" #include "plgDispatch.h" #include "plAgeLoader/plAgeLoader.h" @@ -89,10 +89,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com //// DO NOT REMOVE!!!! //// This is here so Microsoft VC won't decide to "optimize" this file out -//// DO NOT REMOVE!!!! -void pfConsoleCmdGroup::DummyNet( void ) -{ -} +PF_CONSOLE_FILE_DUMMY(Net) //// DO NOT REMOVE!!!! //// Defining Console Commands /////////////////////////////////////////////// @@ -1053,284 +1050,3 @@ PF_CONSOLE_CMD( } #endif - -/////////////////////////////////////// - -/***************************************************************************** -* -* Server -* -***/ - -//TODO: Fix Plasma to use OpenSSL's byte order (or better yet, to use OpenSSL), -// so this hack isn't needed -static void swap_key_bytes(byte keyData[]) -{ - for (size_t i = 0; i < (kNetDiffieHellmanKeyBits / 16); ++i) - std::swap(keyData[i], keyData[ (kNetDiffieHellmanKeyBits / 8) - i - 1 ]); -} - -//============================================================================ -// Server group -PF_CONSOLE_GROUP(Server) - -//============================================================================ -PF_CONSOLE_CMD( - Server, - Status, - "string url", - "Set the server's status URL" -) { - wchar_t *wurl = hsStringToWString((const char *)params[0]); - SetServerStatusUrl(wurl); - delete [] wurl; -} - -//============================================================================ -PF_CONSOLE_CMD( - Server, - Signup, - "string url", - "Set the server's new user sign-up URL" -) { - wchar_t *wurl = hsStringToWString((const char *)params[0]); - SetServerSignupUrl(wurl); - delete [] wurl; -} - -//============================================================================ -PF_CONSOLE_CMD( - Server, - DispName, - "string name", - "Set the displayable server name" -) { - wchar_t *wname = hsStringToWString((const char *)params[0]); - SetServerDisplayName(wname); - delete [] wname; -} - - -//============================================================================ -// Server.File group -PF_CONSOLE_SUBGROUP(Server, File) - -//============================================================================ -PF_CONSOLE_CMD( - Server_File, - Host, - "string address", - "Set the File Server address" -) { - wchar_t *wHost = hsStringToWString((const char *)params[0]); - SetFileSrvHostname(wHost); - delete [] wHost; -} - - -//============================================================================ -// Server.Auth group -PF_CONSOLE_SUBGROUP(Server, Auth) - -//============================================================================ -PF_CONSOLE_CMD( - Server_Auth, - Host, - "string address", - "Set the Auth Server address" -) { - wchar_t *wHost = hsStringToWString((const char *)params[0]); - SetAuthSrvHostname(wHost); - delete [] wHost; -} - -//============================================================================ -PF_CONSOLE_CMD( - Server_Auth, - N, - "string base64Key", - "Set the Auth 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, kAuthDhNData); - swap_key_bytes(kAuthDhNData); -} - -//============================================================================ -PF_CONSOLE_CMD( - Server_Auth, - X, - "string base64Key", - "Set the Auth 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, kAuthDhXData); - swap_key_bytes(kAuthDhXData); -} - - -//============================================================================ -// Server.Csr group -PF_CONSOLE_SUBGROUP(Server, Csr) - -//============================================================================ -PF_CONSOLE_CMD( - Server_Csr, - Host, - "string address", - "Set the Csr Server address" -) { - wchar_t *wHost = hsStringToWString((const char *)params[0]); - SetCsrSrvHostname(wHost); - delete [] wHost; -} - -//============================================================================ -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); - swap_key_bytes(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); - swap_key_bytes(kCsrDhXData); -} - - -//============================================================================ -// Server.Game group -PF_CONSOLE_SUBGROUP(Server, Game) - -//============================================================================ -PF_CONSOLE_CMD( - Server_Game, - N, - "string base64Key", - "Set the Game 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, kGameDhNData); - swap_key_bytes(kGameDhNData); -} - -//============================================================================ -PF_CONSOLE_CMD( - Server_Game, - X, - "string base64Key", - "Set the Game 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, kGameDhXData); - swap_key_bytes(kGameDhXData); -} - - -//============================================================================ -// Server.Gate group -PF_CONSOLE_SUBGROUP(Server, Gate) - -//============================================================================ -PF_CONSOLE_CMD( - Server_Gate, - Host, - "string address", - "Set the GateKeeper Server address" -) { - wchar_t *wHost = hsStringToWString((const char *)params[0]); - SetGateKeeperSrvHostname(wHost); - delete [] wHost; -} - -//============================================================================ -PF_CONSOLE_CMD( - Server_Gate, - N, - "string base64Key", - "Set the GateKeeper 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, kGateKeeperDhNData); - swap_key_bytes(kGateKeeperDhNData); -} - -//============================================================================ -PF_CONSOLE_CMD( - Server_Gate, - X, - "string base64Key", - "Set the GateKeeper 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, kGateKeeperDhXData); - swap_key_bytes(kGateKeeperDhXData); -} diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleDirSrc.h b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleDirSrc.h index 24e6aac1..6154ac0c 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleDirSrc.h +++ b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleDirSrc.h @@ -41,7 +41,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "hsTypes.h" #include "hsStlUtils.h" -#include "pfConsoleEngine.h" +#include "pfConsoleCore/pfConsoleEngine.h" //// pfConsoleDirSrc Class Definition //////////////////////////////////////// diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfGameConsoleCommands.cpp b/Sources/Plasma/FeatureLib/pfConsole/pfGameConsoleCommands.cpp index 8dd84a2f..24cbbec9 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfGameConsoleCommands.cpp +++ b/Sources/Plasma/FeatureLib/pfConsole/pfGameConsoleCommands.cpp @@ -53,7 +53,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #endif -#include "pfConsoleCmd.h" +#include "pfConsoleCore/pfConsoleCmd.h" #include "pfConsole.h" #include "plPipeline.h" @@ -75,12 +75,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com //// DO NOT REMOVE!!!! //// This is here so Microsoft VC won't decide to "optimize" this file out +PF_CONSOLE_FILE_DUMMY(Game) //// DO NOT REMOVE!!!! -void pfConsoleCmdGroup::DummyJunior( void ) -{ -} -//// DO NOT REMOVE!!!! - //// plDoesFileExist ////////////////////////////////////////////////////////// // Utility function to determine whether the given file exists diff --git a/Sources/Plasma/FeatureLib/pfConsoleCore/CMakeLists.txt b/Sources/Plasma/FeatureLib/pfConsoleCore/CMakeLists.txt new file mode 100644 index 00000000..c54c31a0 --- /dev/null +++ b/Sources/Plasma/FeatureLib/pfConsoleCore/CMakeLists.txt @@ -0,0 +1,22 @@ +include_directories(../../CoreLib) +include_directories(../../FeatureLib) +include_directories(../../NucleusLib) +include_directories(../../PubUtilLib) + +set(pfConsoleCore_SOURCES + pfConsoleCmd.cpp + pfConsoleCommandsCore.cpp + pfConsoleContext.cpp + pfConsoleEngine.cpp +) + +set(pfConsoleCore_HEADERS + pfConsoleCmd.h + pfConsoleContext.h + pfConsoleEngine.h +) + +add_library(pfConsoleCore STATIC ${pfConsoleCore_SOURCES} ${pfConsoleCore_HEADERS}) + +source_group("Source Files" FILES ${pfConsoleCore_SOURCES}) +source_group("Header Files" FILES ${pfConsoleCore_HEADERS}) diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCmd.cpp b/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCmd.cpp similarity index 99% rename from Sources/Plasma/FeatureLib/pfConsole/pfConsoleCmd.cpp rename to Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCmd.cpp index 5cad3793..6c811bfd 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCmd.cpp +++ b/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCmd.cpp @@ -45,12 +45,6 @@ UInt32 pfConsoleCmdGroup::fBaseCmdGroupRef = 0; pfConsoleCmdGroup::pfConsoleCmdGroup( char *name, char *parent ) { - Dummy(); - DummyJunior(); - DummyNet(); - DummyAvatar(); - DummyCCR(); - fNext = nil; fPrevPtr = nil; fCommands = nil; diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCmd.h b/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCmd.h similarity index 97% rename from Sources/Plasma/FeatureLib/pfConsole/pfConsoleCmd.h rename to Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCmd.h index 2d14ab5c..c4485e5b 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCmd.h +++ b/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCmd.h @@ -94,12 +94,6 @@ class pfConsoleCmdGroup static pfConsoleCmdGroup *FindSubGroupRecurse( const char *name ); static void DecBaseCmdGroupRef( void ); - - static void Dummy( void ); - static void DummyJunior( void ); - static void DummyNet( void ); - static void DummyAvatar( void ); - static void DummyCCR( void ); }; //// pfConsoleCmdParam Class Definition ////////////////////////////////////// @@ -267,6 +261,9 @@ public: pfConsoleCmdGroup conGroup_##parent##_##name( #name, #parent ); +//// Force the console sources to generate a linkable output ///////////////// -#endif //_pfConsoleCmd_h +#define PF_CONSOLE_FILE_DUMMY( name ) \ + void _console_##name##_file_dummy() { } +#endif //_pfConsoleCmd_h diff --git a/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCommandsCore.cpp b/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCommandsCore.cpp new file mode 100644 index 00000000..644d089a --- /dev/null +++ b/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCommandsCore.cpp @@ -0,0 +1,335 @@ +/*==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 . + +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==*/ +////////////////////////////////////////////////////////////////////////////// +// // +// Actual CORE Console Commands and Groups // +// // +////////////////////////////////////////////////////////////////////////////// + +#include "pfConsoleCmd.h" +#include "pnNetBase/Pch.h" + +#include + +//// DO NOT REMOVE!!!! +//// This is here so Microsoft VC won't decide to "optimize" this file out +PF_CONSOLE_FILE_DUMMY(Core) +//// DO NOT REMOVE!!!! + +// +// utility functions +// +////////////////////////////////////////////////////////////////////////////// +void PrintStringF(void pfun(const char *),const char * fmt, ...) +{ + va_list args; + + char buffy[512]; + va_start(args, fmt); + vsprintf(buffy, fmt, args); + va_end(args); + pfun(buffy); +} + + +/***************************************************************************** +* +* Server +* +***/ + +//TODO: Fix Plasma to use OpenSSL's byte order (or better yet, to use OpenSSL), +// so this hack isn't needed +static void swap_key_bytes(byte keyData[]) +{ + for (size_t i = 0; i < (kNetDiffieHellmanKeyBits / 16); ++i) + std::swap(keyData[i], keyData[ (kNetDiffieHellmanKeyBits / 8) - i - 1 ]); +} + +//============================================================================ +// Server group +PF_CONSOLE_GROUP(Server) + +//============================================================================ +PF_CONSOLE_CMD( + Server, + Status, + "string url", + "Set the server's status URL" +) { + wchar_t *wurl = hsStringToWString((const char *)params[0]); + SetServerStatusUrl(wurl); + delete [] wurl; +} + +//============================================================================ +PF_CONSOLE_CMD( + Server, + Signup, + "string url", + "Set the server's new user sign-up URL" +) { + wchar_t *wurl = hsStringToWString((const char *)params[0]); + SetServerSignupUrl(wurl); + delete [] wurl; +} + +//============================================================================ +PF_CONSOLE_CMD( + Server, + DispName, + "string name", + "Set the displayable server name" +) { + wchar_t *wname = hsStringToWString((const char *)params[0]); + SetServerDisplayName(wname); + delete [] wname; +} + + +//============================================================================ +// Server.File group +PF_CONSOLE_SUBGROUP(Server, File) + +//============================================================================ +PF_CONSOLE_CMD( + Server_File, + Host, + "string address", + "Set the File Server address" +) { + wchar_t *wHost = hsStringToWString((const char *)params[0]); + SetFileSrvHostname(wHost); + delete [] wHost; +} + + +//============================================================================ +// Server.Auth group +PF_CONSOLE_SUBGROUP(Server, Auth) + +//============================================================================ +PF_CONSOLE_CMD( + Server_Auth, + Host, + "string address", + "Set the Auth Server address" +) { + wchar_t *wHost = hsStringToWString((const char *)params[0]); + SetAuthSrvHostname(wHost); + delete [] wHost; +} + +//============================================================================ +PF_CONSOLE_CMD( + Server_Auth, + N, + "string base64Key", + "Set the Auth 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, kAuthDhNData); + swap_key_bytes(kAuthDhNData); +} + +//============================================================================ +PF_CONSOLE_CMD( + Server_Auth, + X, + "string base64Key", + "Set the Auth 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, kAuthDhXData); + swap_key_bytes(kAuthDhXData); +} + + +//============================================================================ +// Server.Csr group +PF_CONSOLE_SUBGROUP(Server, Csr) + +//============================================================================ +PF_CONSOLE_CMD( + Server_Csr, + Host, + "string address", + "Set the Csr Server address" +) { + wchar_t *wHost = hsStringToWString((const char *)params[0]); + SetCsrSrvHostname(wHost); + delete [] wHost; +} + +//============================================================================ +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); + swap_key_bytes(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); + swap_key_bytes(kCsrDhXData); +} + + +//============================================================================ +// Server.Game group +PF_CONSOLE_SUBGROUP(Server, Game) + +//============================================================================ +PF_CONSOLE_CMD( + Server_Game, + N, + "string base64Key", + "Set the Game 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, kGameDhNData); + swap_key_bytes(kGameDhNData); +} + +//============================================================================ +PF_CONSOLE_CMD( + Server_Game, + X, + "string base64Key", + "Set the Game 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, kGameDhXData); + swap_key_bytes(kGameDhXData); +} + + +//============================================================================ +// Server.Gate group +PF_CONSOLE_SUBGROUP(Server, Gate) + +//============================================================================ +PF_CONSOLE_CMD( + Server_Gate, + Host, + "string address", + "Set the GateKeeper Server address" +) { + wchar_t *wHost = hsStringToWString((const char *)params[0]); + SetGateKeeperSrvHostname(wHost); + delete [] wHost; +} + +//============================================================================ +PF_CONSOLE_CMD( + Server_Gate, + N, + "string base64Key", + "Set the GateKeeper 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, kGateKeeperDhNData); + swap_key_bytes(kGateKeeperDhNData); +} + +//============================================================================ +PF_CONSOLE_CMD( + Server_Gate, + X, + "string base64Key", + "Set the GateKeeper 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, kGateKeeperDhXData); + swap_key_bytes(kGateKeeperDhXData); +} diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleContext.cpp b/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleContext.cpp similarity index 100% rename from Sources/Plasma/FeatureLib/pfConsole/pfConsoleContext.cpp rename to Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleContext.cpp diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleContext.h b/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleContext.h similarity index 100% rename from Sources/Plasma/FeatureLib/pfConsole/pfConsoleContext.h rename to Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleContext.h diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleEngine.cpp b/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleEngine.cpp similarity index 100% rename from Sources/Plasma/FeatureLib/pfConsole/pfConsoleEngine.cpp rename to Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleEngine.cpp diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleEngine.h b/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleEngine.h similarity index 84% rename from Sources/Plasma/FeatureLib/pfConsole/pfConsoleEngine.h rename to Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleEngine.h index 1683e097..04ecf38e 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleEngine.h +++ b/Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleEngine.h @@ -95,4 +95,29 @@ class pfConsoleEngine }; +//// Use in your Main module to provide Console functionality //////////////// + +#define PF_CONSOLE_LINK_FILE( name ) \ + void _console_##name##_file_dummy(); + +#define PF_CONSOLE_INITIALIZE( name ) \ + _console_##name##_file_dummy(); + +#define PF_CONSOLE_LINK_ALL() \ + PF_CONSOLE_LINK_FILE(Avatar) \ + PF_CONSOLE_LINK_FILE(CCR) \ + PF_CONSOLE_LINK_FILE(Core) \ + PF_CONSOLE_LINK_FILE(Game) \ + PF_CONSOLE_LINK_FILE(Main) \ + PF_CONSOLE_LINK_FILE(Net) + +#define PF_CONSOLE_INIT_ALL() \ + PF_CONSOLE_INITIALIZE(Avatar) \ + PF_CONSOLE_INITIALIZE(CCR) \ + PF_CONSOLE_INITIALIZE(Core) \ + PF_CONSOLE_INITIALIZE(Game) \ + PF_CONSOLE_INITIALIZE(Main) \ + PF_CONSOLE_INITIALIZE(Net) + + #endif //_pfConsoleEngine_h