HRESULT CServiceModule::InitAGC()
{
	// Initialize AGC
	HRESULT hr;
	ZSucceeded(hr = _AGCModule.Init());
	RETURN_FAILED(hr);

	_AGCModule.SetDebugBreakOnErrors(g.fWantInt3);

#ifdef _DEBUG
	_AGCModule.GetAGCGlobal()->SetDebugHook(&g_DebugHook);
#endif // _DEBUG

	// Create the set of available AGCEventID ranges
	CComPtr<IAGCEventIDRanges> spRanges;
	ZSucceeded(hr = spRanges.CoCreateInstance(L"AGC.EventIDRanges"));
	RETURN_FAILED(hr);

	// Add our ranges to it
	ZSucceeded(spRanges->AddByValues(EventID_AGC_LowerBound, EventID_AGC_UpperBound));
	ZSucceeded(spRanges->AddByValues(AllsrvEventID_Allsrv_LowerBound, AllsrvEventID_Allsrv_UpperBound));
	ZSucceeded(spRanges->AddByValues(EventID_Admin_LowerBound, EventID_Admin_UpperBound));

	// Set the ranges of available events
	GetAGCGlobal()->SetAvailableEventIDRanges(spRanges);

	// Create the event logger object
	ZSucceeded(hr = m_spEventLogger.CreateInstance("AGC.EventLogger"));
	RETURN_FAILED(hr);

	// Initialize the event logger object
	CComBSTR bstrEventSource(__MODULE__);
	CComBSTR bstrRegKey("HKLM\\" HKLM_FedSrvA);
	IAGCEventLoggerPrivatePtr spPrivate(m_spEventLogger);
	hr = spPrivate->Initialize(bstrEventSource, bstrRegKey);
	ZSucceeded(hr);
	RETURN_FAILED(hr);

	// Hook the event logger for DB event logging
	ZSucceeded(hr = spPrivate->put_HookForDBLogging(&g_DBLoggingHook));

	// Indicate success
	return S_OK;
}
Example #2
0
HRESULT CPigEngine::Construct()
{
  // Get the path name of the module
  TCHAR szModule[_MAX_PATH];
  _VERIFYE(GetModuleFileName(_Module.GetModuleInstance(), szModule,
    sizeofArray(szModule)));

  // Break the path name of the module into pieces
  TCHAR szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szName[_MAX_FNAME];
  _tsplitpath(szModule, szDrive, szDir, szName, NULL);

  // Open the registry key of the AppID
  CRegKey key;
  RETURN_FAILED(_Module.OpenAppIDRegKey(key, KEY_READ));

  // Create the event logger object
  RETURN_FAILED(m_spEventLogger.CreateInstance("AGC.EventLogger"));

  // Initialize the event logger object
  CComBSTR bstrEventSource(L"PigSrv");
  CComBSTR bstrRegKey(L"HKCR\\AppID\\{F132B4E3-C6EF-11D2-85C9-00C04F68DEB0}");
  IAGCEventLoggerPrivatePtr spPrivate(m_spEventLogger);
  RETURN_FAILED(spPrivate->Initialize(bstrEventSource, bstrRegKey));

  // Load the MissionServer registry value
  LoadRegString(key, TEXT("MissionServer"), m_bstrMissionServer);

  // Load the AccountServer registry value
  LoadRegString(key, TEXT("AccountServer"), m_bstrAccountServer);

  // Load the ZoneAuthServer registry value
  LoadRegString(key, TEXT("ZoneAuthServer"), m_bstrZoneAuthServer);

  // Load the ZoneAuthTimeout registry value
  DWORD dwZoneAuthTimeout;
  if (ERROR_SUCCESS == key.QueryValue(dwZoneAuthTimeout, TEXT("ZoneAuthTimeout")))
    m_nZoneAuthTimeout = static_cast<long>(dwZoneAuthTimeout);

  // Load the LobbyMode registry value
  DWORD dwLobbyMode;
  if (ERROR_SUCCESS == key.QueryValue(dwLobbyMode, TEXT("LobbyMode")))
    m_eLobbyMode =
      (PigLobbyMode_Club <= dwLobbyMode && dwLobbyMode <= PigLobbyMode_Free) ?
        static_cast<PigLobbyMode>(dwLobbyMode) : PigLobbyMode_Club;

  // Attempt to read the ScriptDir value from the registry
  ZString strScriptDir;
  LoadRegString(key, TEXT("ScriptDir"), strScriptDir);

  // Create a directory name from the root directory, by default
  if (strScriptDir.IsEmpty())
  {
    TCHAR szScriptDir[_MAX_PATH + 1];
    _tmakepath(szScriptDir, szDrive, szDir, TEXT("Scripts"), NULL);
    strScriptDir = szScriptDir;
  }

  // Ensure that m_bstrScriptDir ends with a whack
  int nLastChar = strScriptDir.GetLength() - 1;
  if (TEXT('\\') != strScriptDir[nLastChar])
    strScriptDir += ZString("\\");

  // Save the directory name
  m_bstrScriptDir = strScriptDir;

  // Create the pigs collection object with a ref count
  assert(!m_pPigs);
  CComObject<CPigs>* pPigs = NULL;
  RETURN_FAILED(pPigs->CreateInstance(&pPigs));
  (m_pPigs = pPigs)->AddRef();

  // Indicate success
  return S_OK;
}