HRESULT CLobbyApp::Init() { HRESULT hr = E_FAIL; m_plas->LogEvent(EVENTLOG_INFORMATION_TYPE, LE_Initializing); ZVerify(m_perfshare.Initialize()); m_pCounters = (LOBBY_COUNTERS *)m_perfshare.AllocateCounters( "AllLobby", "0", // if there are ever multiple lobbies running, change this sizeof(LOBBY_COUNTERS)); ZeroMemory(m_pCounters, sizeof(LOBBY_COUNTERS)); #ifdef USECLUB hr = m_sql.Init(m_strSQLConfig.m_str, GetCurrentThreadId(), m_csqlSilentThreads, m_csqlNotifyThreads); if (FAILED(hr)) { m_plas->LogEvent(EVENTLOG_ERROR_TYPE, LE_SQLInitFailed); return hr; } #endif // TODO: Make keep-alives an option if (FAILED(hr = m_fmServers.HostSession(m_fFreeLobby ? FEDFREELOBBYSERVERS_GUID : FEDLOBBYSERVERS_GUID, false, 0, m_fProtocol, m_sPort + 1)) || // Mdvalley: I don't know what happens if you try to host 2 servers on one port. Let's not find out. FAILED(hr = m_fmClients.HostSession(m_fFreeLobby ? FEDFREELOBBYCLIENTS_GUID : FEDLOBBYCLIENTS_GUID, true, 0, m_fProtocol, m_sPort))) // The first session doesn't need the port fixed, but I don't want to risk having it take the one the second is going to use. { m_plas->LogEvent(EVENTLOG_ERROR_TYPE, LE_HostSessionFailure); return hr; } // // Read Registry // DWORD dw; // Gets result of whether it opened or created... HKEY hk; if (RegCreateKeyEx(HKEY_LOCAL_MACHINE, HKLM_AllLobby, 0, L"", REG_OPTION_NON_VOLATILE, KEY_READ | KEY_WRITE, NULL, &hk, &dw) == ERROR_SUCCESS) { // read AutoUpdate portion of registry DWORD dwWantAutoDownload; bool bSuccess = _Module.ReadFromRegistry(hk, false, "AutoUpdateActive", &dwWantAutoDownload, 0); if(bSuccess && dwWantAutoDownload) { char szFileName[MAX_PATH+16]; strcpy(szFileName, _Module.GetModulePath()); Strcat(szFileName, "FileList.txt"); // BT - 7/15 - Enable to lobby to use a FileList.txt from the AutoUpdate folder instead of from the lobby folder. This way, only a single FileList.txt is required. _Module.ReadFromRegistry(hk, true, "AutoUpdateFileListLocation", szFileName, (DWORD)szFileName, false); CreateAutoUpdate(hk, szFileName); } else g_pAutoUpdate = NULL; RegCloseKey(hk); } return hr; }
ZString GetRegistryString(HKEY hkey, const ZString& strName) { DWORD cb = MAX_STRING; BYTE pb[MAX_STRING]; pb[0] = 0; ZVerify(RegQueryValueEx(hkey, strName, NULL, NULL, pb, &cb) == ERROR_SUCCESS); return ZString((PCC)pb); }
void CclusterIGC::AddModel(ImodelIGC* modelNew) { assert (modelNew); ZVerify(m_models.first(modelNew)); modelNew->AddRef(); m_pClusterSite->AddThingSite(modelNew->GetThingSite()); { //Add the model to the collision set HitTest* ht = modelNew->GetHitTest(); ModelAttributes mt = modelNew->GetAttributes(); if ((mt & c_mtNotPickable) == 0) { ZVerify(m_modelsPickable.last(modelNew)); modelNew->AddRef(); } if (mt & c_mtCastRay) { ZVerify(m_modelsCastRay.last(modelNew)); modelNew->AddRef(); } if (mt & c_mtHitable) { ((mt & c_mtStatic) ? m_kdrStatic : m_kdrMoving).addHitTest(ht); } else ht->SetDeadF(false); ZRetailAssert(!ht->GetDeadF()); } }
~CDVolume() { // restore the volume settings for all of the CD players while (!m_listMixerLines.empty()) { MixerLineData& mixerlinedata = m_listMixerLines.back(); MIXERCONTROLDETAILS mixercontroldetails; mixercontroldetails.cbStruct = sizeof(MIXERCONTROLDETAILS); mixercontroldetails.dwControlID = mixerlinedata.mixercontrol.dwControlID; mixercontroldetails.cChannels = mixerlinedata.cChannels; mixercontroldetails.cMultipleItems = 0; mixercontroldetails.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED); mixercontroldetails.paDetails = &(mixerlinedata.vmixercontrolsOld); ZVerify(mixerSetControlDetails(mixerlinedata.hmixer, &mixercontroldetails, MIXER_SETCONTROLDETAILSF_VALUE) == MMSYSERR_NOERROR); ZVerify(mixerClose((HMIXER)mixerlinedata.hmixer) == MMSYSERR_NOERROR); m_listMixerLines.pop_back(); } }
bool IsWindows9x() { static bool bChecked = false; static bool bIs9x; if (!bChecked) { OSVERSIONINFO osversioninfo; osversioninfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); ZVerify(GetVersionEx(&osversioninfo)); bIs9x = osversioninfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS; bChecked = true; } return bIs9x; }
HRESULT SetGain(float fGain) { if (fGain > 0.0f) { return E_INVALIDARG; } const float fMinGain = -40; float fClippedGain = max(fMinGain, fGain); // set the volume on every CD player (since we can't map to the right one) // restore the volume settings for all of the CD players std::list<MixerLineData>::iterator mixerline; for (mixerline = m_listMixerLines.begin(); mixerline != m_listMixerLines.end(); ++mixerline) { MixerLineData& mixerlinedata = *mixerline; // translate the gain to a linear volume setting. MIXERCONTROLDETAILS_UNSIGNED volume; volume.dwValue = (DWORD)(mixerlinedata.mixercontrol.Bounds.dwMinimum + (mixerlinedata.mixercontrol.Bounds.dwMaximum - mixerlinedata.mixercontrol.Bounds.dwMinimum) * (1 - fClippedGain/fMinGain)); // set the volume for this control MIXERCONTROLDETAILS mixercontroldetails; mixercontroldetails.cbStruct = sizeof(MIXERCONTROLDETAILS); mixercontroldetails.dwControlID = mixerlinedata.mixercontrol.dwControlID; mixercontroldetails.cChannels = 1; mixercontroldetails.cMultipleItems = 0; mixercontroldetails.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED); mixercontroldetails.paDetails = &volume; ZVerify(mixerSetControlDetails(mixerlinedata.hmixer, &mixercontroldetails, MIXER_SETCONTROLDETAILSF_VALUE) == MMSYSERR_NOERROR); } return S_OK; }
bool FillDDPF( D3D9PixelFormat& ddpf, HDC hdc, HBITMAP hbitmap, DWORD * dwPaletteIndex ) { BYTE ajBitmapInfo[sizeof(BITMAPINFO) + 3 * sizeof(DWORD)]; BITMAPINFO* pbmi = (BITMAPINFO*)ajBitmapInfo; BOOL bRet = FALSE; memset(pbmi, 0, sizeof(ajBitmapInfo)); pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); ZVerify(::GetDIBits(hdc, hbitmap, 0, 0, NULL, pbmi, DIB_RGB_COLORS)); ddpf.dwRGBBitCount = pbmi->bmiHeader.biBitCount; ddpf.dwRGBAlphaBitMask = 0; switch(pbmi->bmiHeader.biCompression) { // // Default DIB format. Color masks are implicit for each bit depth. // case BI_RGB: switch (ddpf.dwRGBBitCount) { case 4: case 8: { _ASSERT( false ); // Need to look at palette conversion if this is used. /* ddpf.dwFlags |= ((ddpf.dwRGBBitCount == 4) ? DDPF_PALETTEINDEXED4 : DDPF_PALETTEINDEXED8); // // Create a palette for the surface // RGBQUAD prgb[256]; int ncolors = GetDIBColorTable(hdc, 0, 256, prgb); ZAssert(ncolors == (1 << ddpf.dwRGBBitCount)); PALETTEENTRY ppe[256]; // // convert BGR to RGB // for (int index = 0; index < ncolors; index++) { ppe[index].peRed = prgb[index].rgbRed; ppe[index].peGreen = prgb[index].rgbGreen; ppe[index].peBlue = prgb[index].rgbBlue; } // // create a DirectDraw palette for the texture. // _ASSERT( false && "TBD" ); // Add palette management to CVRAMManager. Should be easy. // DDCall(pdd->CreatePalette( // (ddpf.dwRGBBitCount == 4) ? DDPCAPS_4BIT : DDPCAPS_8BIT, // ppe, // pppalette, // NULL // )); return true;*/ return false; } case 16: // 16bpp default is 555 BGR-ordering ddpf.dwRBitMask = MakeMask(5, 10); ddpf.dwGBitMask = MakeMask(5, 5); ddpf.dwBBitMask = MakeMask(5, 0); return true; case 24: case 32: // 24 and 32bpp default is 888 BGR-ordering ddpf.dwRBitMask = MakeMask(8, 16); ddpf.dwGBitMask = MakeMask(8, 8); ddpf.dwBBitMask = MakeMask(8, 0); return true; } break; case BI_BITFIELDS: // // Call a second time to get the color masks. // It's a GetDIBits Win32 "feature". // ZVerify(::GetDIBits(hdc, hbitmap, 0, pbmi->bmiHeader.biHeight, NULL, pbmi, DIB_RGB_COLORS)); ddpf.dwRBitMask = *(DWORD *)&pbmi->bmiColors[0]; ddpf.dwGBitMask = *(DWORD *)&pbmi->bmiColors[1]; ddpf.dwBBitMask = *(DWORD *)&pbmi->bmiColors[2]; return true; } return false; }
// MouseInputStreamImpl(IDirectInputDevice2* pdid, HWND hwnd) : MouseInputStreamImpl(IDirectInputDevice7* pdid, HWND hwnd) : // mdvalley: DInput7 m_pdid(pdid), m_rect(0, 0, 0, 0), m_point(0, 0), m_vvalueObject(3), m_bEnabled(false), m_bBuffered(true), m_pbuttonEventSource(ButtonEvent::Source::Create()) { // // Are we running on NT // /*!!! OSVERSIONINFO osvi = { sizeof(osvi) }; ZVerify(GetVersionEx(&osvi)); if ((VER_PLATFORM_WIN32_NT & osvi.dwPlatformId) != 0) { m_bBuffered = false; } */ // // Enumerate the buttons and values // DDCall(m_pdid->EnumObjects(StaticEnumObjectsCallback, this, DIDFT_ALL)); // // Setup the device // SetupDevice(); // // We only need mouse input when we are in the foreground // DDCall(m_pdid->SetCooperativeLevel(hwnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND)); // // Get the mouse acceleration values // int pvalue[3]; ZVerify(SystemParametersInfo(SPI_GETMOUSE, 0, pvalue, 0)); m_threshold1 = pvalue[0]; m_threshold2 = pvalue[1]; m_acceleration = pvalue[2]; m_sensitivity = 1.0f; /* !!! this only works on NT50 int speed; ZVerify(SystemParametersInfo(SPI_GETMOUSESPEED, 0, &speed, 0)); if (speed <= 2) { m_sensitivity = float(speed) / 32.0f; } else if(speed >= 3 && speed <= 10 ) { m_sensitivity = float(speed-2) / 8.0f; } else { m_sensitivity = float(speed-6) / 4.0f; } */ }
bool CheckDevice(int index, bool& bValid, ZString& strDriverURL) { char szDevice[MAX_STRING]; bValid = false; if (_FindDevice(index, "Net", szDevice, FALSE)) { // // Is this the bad driver? // BYTE pb[MAX_STRING]; if (!_GetDeviceValue(szDevice, NULL, "DeviceDesc", pb, sizeof(pb))) { bValid = true; return true; }; enum { dtRTL8139, dtRTL8129, dtRTL8029, dtPNPNT } driverType; if (_stricmp((PCC)pb, "rtl8139.sys") == 0) { driverType = dtRTL8139; } else if (_stricmp((PCC)pb, "rtl8129.sys") == 0) { driverType = dtRTL8129; } else if (_stricmp((PCC)pb, "rtl8029.sys") == 0) { driverType = dtRTL8029; } else if (_stricmp((PCC)pb, "pnpnt.sys") == 0) { driverType = dtPNPNT; } else { bValid = true; return true; }; // // Get the driver version number // if (!_GetDeviceValue(szDevice, NULL, "Driver", pb, sizeof(pb))) { return true; } HKEY hkey; ZString strKey = "System\\CurrentControlSet\\Services\\Class\\" + ZString((PCC)pb); if (RegOpenKey(HKEY_LOCAL_MACHINE, strKey, &hkey) != ERROR_SUCCESS) { return true; } ZString strDeviceVxDs = GetRegistryString(hkey, "DeviceVxDs"); //data.m_strNTMPDriver = GetRegistryString(hkey, "NTMPDriver"); //data.m_strDriverDate = GetRegistryString(hkey, "DriverDate"); char pszWindowsPath[MAX_PATH]; GetWindowsDirectory(pszWindowsPath, sizeof(pszWindowsPath)); ZString strDriverPath = ZString(pszWindowsPath) + "\\system\\" + strDeviceVxDs; DWORD dwTemp; DWORD dwVerInfoSize = GetFileVersionInfoSize((char*)(PCC)strDriverPath, &dwTemp); if (dwVerInfoSize == 0) { ZError("This should never happen"); bValid = false; } else { void *pvVerInfo = _alloca(dwVerInfoSize); ZVerify(GetFileVersionInfo((char*)(PCC)strDriverPath, NULL, dwVerInfoSize, pvVerInfo)); VS_FIXEDFILEINFO *lpvsFixedFileInfo = NULL; unsigned uTemp; ZVerify(VerQueryValue(pvVerInfo, "\\", (LPVOID*) &lpvsFixedFileInfo, &uTemp)); WORD ver1 = HIWORD(lpvsFixedFileInfo->dwFileVersionMS); WORD ver2 = LOWORD(lpvsFixedFileInfo->dwFileVersionMS); WORD ver3 = HIWORD(lpvsFixedFileInfo->dwFileVersionLS); WORD ver4 = LOWORD(lpvsFixedFileInfo->dwFileVersionLS); switch (driverType) { case dtRTL8139: if (ver1 > 5 || ver1 == 5 && ver2 >= 373) bValid = true; else strDriverURL = "http://www.realtek.com.tw"; break; case dtRTL8129: if (ver1 > 5 || ver1 == 5 && ver2 >= 368) bValid = true; else strDriverURL = "http://www.realtek.com.tw"; break; case dtRTL8029: if (ver1 > 5 || ver1 == 5 && ver2 >= 505) bValid = true; else strDriverURL = "http://www.realtek.com.tw"; break; case dtPNPNT: { const char* szRealTek = "REALTEK"; const char* szCompanyName; ZVerify(VerQueryValue(pvVerInfo, "\\StringFileInfo\\040904b0\\CompanyName", (LPVOID*) &szCompanyName, &uTemp)); if (strncmp(szCompanyName, szRealTek, sizeof(szRealTek)) != 0) { bValid = true; break; } OSVERSIONINFO osversioninfo; osversioninfo.dwOSVersionInfoSize = sizeof(osversioninfo); GetVersionEx(&osversioninfo); if (osversioninfo.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS || osversioninfo.dwMajorVersion != 4){ bValid = true; break; } if (osversioninfo.dwMinorVersion == 0) // if Win95 { // at least 4.0.1381.1 if (ver1 > 4 || ver1 == 4 && (ver2 > 0 || ver2 == 0 && (ver3 > 1381 || ver3 == 1381 && ver4 >=1))) bValid = true; else strDriverURL = "http://www.realtek.com.tw"; } else { // Win98, at least ver 3.19.98.901 if (ver1 > 3 || ver1 == 3 && (ver2 > 19 || ver2 == 19 && (ver3 > 98 || ver3 == 98 && ver4 >= 901))) bValid = true; else strDriverURL = "http://www.realtek.com.tw"; } } break; default: assert(0); } } return true; } return false; }
DWORD Window::WndProc( UINT message, WPARAM wParam, LPARAM lParam ) { switch (message) { case WM_CLOSE: OnClose(); return 0; case WM_DESTROY: OnDestroy(); return 0; case WM_PAINT: PAINTSTRUCT paint; BeginPaint(GetHWND(), &paint); OnPaint(paint.hdc, paint.rcPaint); EndPaint(GetHWND(), &paint); return 0; case WM_MOVE: case WM_SIZE: UpdateRect(); RectChanged(); break; case WM_TIMER: if (OnTimer()) return 0; break; case WM_HSCROLL: if (OnHScroll((int)LOWORD(wParam), (short int) HIWORD(wParam), (HWND)lParam)) return 0; break; case WM_VSCROLL: if (OnVScroll((int)LOWORD(wParam), (short int) HIWORD(wParam), (HWND)lParam)) return 0; break; case WM_COMMAND: if (OnCommand(wParam, lParam)) return 0; break; case WM_SYSCOMMAND: if (OnSysCommand(wParam & 0xFFF0, MakePoint(lParam))) return 0; break; case WM_ACTIVATE: if (OnActivate(LOWORD(wParam), HIWORD(wParam) != 0)) return 0; break; case WM_ACTIVATEAPP: if (OnActivateApp(wParam != 0)) return 0; break; case WM_CHAR: { KeyState ks; ks.vk = wParam; ks.bShift = (GetKeyState(VK_SHIFT) & 0x8000) != 0; ks.bControl = (GetKeyState(VK_CONTROL) & 0x8000) != 0; ks.countRepeat = LOWORD(lParam); return !OnChar(ks); } break; case WM_KEYDOWN: case WM_SYSKEYDOWN: case WM_KEYUP: case WM_SYSKEYUP: { KeyState ks; ks.vk = wParam; ks.bShift = (GetKeyState(VK_SHIFT) & 0x8000) != 0; ks.bControl = (GetKeyState(VK_CONTROL) & 0x8000) != 0; ks.bAlt = (message == WM_SYSKEYUP || message == WM_SYSKEYDOWN) && (lParam & (1 << 29)); // See help for WM_SYSKEYDOWN ks.bDown = (message == WM_KEYDOWN || message == WM_SYSKEYDOWN); ks.countRepeat = LOWORD(lParam); return !OnKey(ks); } break; case WM_MOUSEWHEEL: //imago 8/13/09 case WM_XBUTTONDOWN: case WM_XBUTTONUP: case WM_MOUSEHOVER: // imago --^ case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: case WM_MBUTTONDOWN: case WM_LBUTTONUP: case WM_RBUTTONUP: case WM_MBUTTONUP: case WM_MOUSEMOVE: case WM_MOUSELEAVE: case WM_NCMOUSEHOVER: //Imago 7/10 case WM_NCMOUSELEAVE: //<--^ { WinPoint pointMouse; if (message != WM_MOUSEWHEEL) { WinPoint point(MakePoint(lParam)); pointMouse = WinPoint(point.X(),m_rectClient.YSize() - 1 - point.Y()); m_lastPointMouse = pointMouse; } else { pointMouse = m_lastPointMouse; } // // Handle mouse leave // if (message == WM_MOUSELEAVE || message == WM_NCMOUSELEAVE) { if (m_bMouseInside) { m_bMouseInside = false; OnMouseMessage(WM_MOUSELEAVE, 0, pointMouse); } } else { // // Handle mouse enter // if (!m_bMouseInside && (message != WM_NCMOUSEHOVER && message != WM_MOUSEHOVER && message != 0)) { m_bMouseInside = true; OnMouseMessage(0, 0, pointMouse); if (s_pfnTrackMouseEvent) { TRACKMOUSEEVENT tme; tme.cbSize = sizeof(TRACKMOUSEEVENT); tme.dwFlags = TME_LEAVE; tme.hwndTrack = m_hwnd; tme.dwHoverTime = HOVER_DEFAULT; ZVerify(s_pfnTrackMouseEvent(&tme)); } } // // Handle the mouse message // DWORD ret = OnMouseMessage(message, wParam, pointMouse) ? 0 : 1; } return true; } break; case WM_SETCURSOR: // // use the custom cursor for the client area // if (LOWORD(lParam) == HTCLIENT) { ::SetCursor(NULL); } else { ::SetCursor(GetCursor()); } break; case WM_WINDOWPOSCHANGING: if (OnWindowPosChanging((LPWINDOWPOS)lParam)) return 0; break; } return m_pfnWndProc(m_hwnd, message, wParam, lParam); }