| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- /*
- ** Command & Conquer Renegade(tm)
- ** Copyright 2025 Electronic Arts 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/>.
- */
- /******************************************************************************
- *
- * FILE
- * $Archive: /Commando/Code/WWOnline/WOLProduct.cpp $
- *
- * DESCRIPTION
- * This class specifies product-specific information, such as SKU.
- *
- * Client code should create a Product::Initializer object. This will create
- * a Product object and set it as the current product. Creating additional
- * Initializer objects will replace the current product information. This
- * will change the application's "identity" on the fly; this may cause
- * problems if Westwood Online activity is in progress. I don't expect there
- * to be any need to do this, except perhaps during early product development.
- *
- * PROGRAMMER
- * $Author: Denzil_l $
- *
- * VERSION INFO
- * $Revision: 4 $
- * $Modtime: 1/25/02 6:45p $
- *
- ******************************************************************************/
- #include "WOLProduct.h"
- #include <WWLib\win.h>
- namespace WWOnline {
- /******************************************************************************
- *
- * NAME
- * CurrentProduct
- *
- * DESCRIPTION
- * Current WWOnline product.
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * Product -
- *
- ******************************************************************************/
- static RefPtr<Product>& CurrentProduct(void)
- {
- static RefPtr<Product> _current;
- return _current;
- }
- /******************************************************************************
- *
- * NAME
- * Product::Current
- *
- * DESCRIPTION
- * Get the current WWOnline product
- *
- * INPUTS
- * NONE
- *
- * RESULT
- *
- ******************************************************************************/
- RefPtr<Product> Product::Current(void)
- {
- return CurrentProduct().ReferencedObject();
- }
- /******************************************************************************
- *
- * NAME
- * Product::Create
- *
- * DESCRIPTION
- *
- * INPUTS
- *
- * RESULT
- *
- ******************************************************************************/
- RefPtr<Product> Product::Create(const char* registryPath, int gameCode,
- const wchar_t* chanPass, unsigned long ladderSKU)
- {
- return new Product(registryPath, gameCode, chanPass, ladderSKU);
- }
- /******************************************************************************
- *
- * NAME
- * Product::Product
- *
- * DESCRIPTION
- *
- * INPUTS
- *
- * RESULT
- *
- ******************************************************************************/
- Product::Product(const char* registryPath, int gameCode, const wchar_t* chanPass, unsigned long ladderSKU) :
- mRegistryPath(registryPath),
- mProductSKU(0),
- mLadderSKU(0),
- mProductVersion(0),
- mLanguageCode(0),
- mGameCode(gameCode),
- mChannelPassword(chanPass)
- {
- WWASSERT(registryPath && "Invalid parameter");
- HKEY rKey;
- LONG result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, registryPath, 0, KEY_READ, &rKey);
-
- if (result == ERROR_SUCCESS)
- {
- // Get SKU
- DWORD type;
- DWORD sku = 0;
- DWORD sizeOfBuffer = sizeof(sku);
- result = RegQueryValueEx(rKey, "SKU", NULL, &type, (unsigned char*)&sku, &sizeOfBuffer);
- mProductSKU = sku;
- mLanguageCode = (sku & 0xFF);
- mLadderSKU = ladderSKU;
- // Get version
- DWORD version = 0;
- sizeOfBuffer = sizeof(version);
- result = RegQueryValueEx(rKey, "Version", NULL, &type, (unsigned char*)&version, &sizeOfBuffer);
- mProductVersion = version;
- RegCloseKey(rKey);
- }
- }
- /******************************************************************************
- *
- * NAME
- * WOLProduct::Initializer
- *
- * DESCRIPTION
- *
- * INPUTS
- *
- * RESULT
- *
- ******************************************************************************/
- Product::Initializer::Initializer(const char* registryPath, int gameCode,
- const wchar_t* chanPass, unsigned long ladderSKU)
- {
- CurrentProduct() = Product::Create(registryPath, gameCode, chanPass, ladderSKU);
- }
- /******************************************************************************
- *
- * NAME
- * WOLProduct::Initializer
- *
- * DESCRIPTION
- *
- * INPUTS
- *
- * RESULT
- *
- ******************************************************************************/
- Product::Initializer::~Initializer()
- {
- }
- }
|