bool CSettingsMenu::OnSaveButtonClick(const CEGUI::EventArgs &eventArgs) { bool bWindowed = ((CEGUI::Checkbox *)m_GUIElements.pWindowedCheckBox)->isSelected(); bool bShowFPS = ((CEGUI::Checkbox *)m_GUIElements.pFPSCheckBox)->isSelected(); String strNick(m_GUIElements.pNickEditBox->getText().c_str()); String strFont(m_GUIElements.pChatFontEditBox->getText().c_str()); String strFontSize(m_GUIElements.pChatFontSizeEditBox->getText().c_str()); String strBackgroundAlpha(m_GUIElements.pChatBGColorAEditBox->getText().c_str()); String strBackgroundRed(m_GUIElements.pChatBGColorREditBox->getText().c_str()); String strBackgroundGreen(m_GUIElements.pChatBGColorGEditBox->getText().c_str()); String strBackgroundBlue(m_GUIElements.pChatBGColorBEditBox->getText().c_str()); CVAR_SET_BOOL("windowed", bWindowed); CVAR_SET_BOOL("fps", g_pClient->GetFPSToggle()); g_pClient->SetFPSToggle(bShowFPS); CVAR_SET_INTEGER("chatfont", strFont.ToInteger()); CVAR_SET_INTEGER("chatsize", strFontSize.ToInteger()); CVAR_SET_INTEGER("chatbga", strBackgroundAlpha.ToInteger()); CVAR_SET_INTEGER("chatbgr", strBackgroundRed.ToInteger()); CVAR_SET_INTEGER("chatbgg", strBackgroundGreen.ToInteger()); CVAR_SET_INTEGER("chatbgb", strBackgroundBlue.ToInteger()); // Init the chat window font and background g_pClient->GetChatWindow()->InitFontAndBackground(); if(CVAR_GET_STRING("nick").Compare(strNick) != 0) { CVAR_SET_STRING("nick", strNick); g_pClient->SetNick(strNick); CNetworkManager * pNetworkManager = g_pClient->GetNetworkManager(); if(pNetworkManager && pNetworkManager->IsConnected()) { CBitStream bsSend; bsSend.Write(strNick); pNetworkManager->RPC(RPC_NameChange, &bsSend, PRIORITY_HIGH, RELIABILITY_RELIABLE_ORDERED); } } if(bWindowed != g_pClient->IsWindowedMode()) g_pClient->GetGUI()->ShowMessageBox("You must restart IV:MP for the windowed mode option to take effect", "Information."); SetVisible(false); return true; }
// toggleFrequentEvents(toggle) SQInteger CServerNatives::ToggleFrequentEvents(SQVM * pVM) { bool bToggle; sq_getinteger(pVM, -1, (SQInteger*)&bToggle); CVAR_SET_BOOL("frequentevents", bToggle); sq_pushbool(pVM, true); return 1; }
// toggleFrequentEvents(toggle) int CServerNatives::ToggleFrequentEvents(lua_State * pVM) { int bToggle; script_getinteger(pVM, -1, &bToggle); CVAR_SET_BOOL("frequentevents", bToggle != 0); script_pushbool(pVM, true); return 1; }
// toggleAutoAim(toggle) SQInteger CServerNatives::ToggleAutoAim(SQVM * pVM) { SQBool bSwitch; sq_getbool(pVM, -1, &bSwitch); bool bToggle = (bSwitch != 0); CVAR_SET_BOOL("autoaim", bToggle); CBitStream bsSend; bsSend.Write(bToggle); g_pNetworkManager->RPC(RPC_ScriptingToggleAutoAim, &bsSend, PRIORITY_HIGH, RELIABILITY_RELIABLE, INVALID_ENTITY_ID, true); return 1; }
// togglePayAndSpray(toggle) int CServerNatives::TogglePayAndSpray(lua_State * pVM) { bool bSwitch; script_getbool(pVM, -1, &bSwitch); bool bToggle = (bSwitch != 0); CVAR_SET_BOOL("paynspray", bToggle); CBitStream bsSend; bsSend.Write(bToggle); g_pNetworkManager->RPC(RPC_ScriptingTogglePayAndSpray, &bsSend, PRIORITY_HIGH, RELIABILITY_RELIABLE, INVALID_ENTITY_ID, true); return 1; }
BOOL APIENTRY DllMain(HMODULE hModule, DWORD fdwReason, LPVOID lpReserved) { switch(fdwReason) { case DLL_PROCESS_ATTACH: { // Disable thread library notifications DisableThreadLibraryCalls(hModule); // Install the exception handler CExceptionHandler::Install(); // Delete chatlog CLogFile::Open("Chatlog.log"); CLogFile::Printf("New chatlog created!"); CLogFile::Close(); // Open the log file CLogFile::Open("Client.log"); // Log the version CLogFile::Printf(VERSION_IDENTIFIER "| " __DATE__ " - " __TIME__ ""); // Open the settings file CSettings::Open(SharedUtility::GetAbsolutePath("clientsettings.xml")); // Parse the command line CSettings::ParseCommandLine(GetCommandLine()); // Load the global vars from the settings g_strHost = CVAR_GET_STRING("ip"); g_usPort = CVAR_GET_INTEGER("port"); g_strNick = CVAR_GET_STRING("nick"); g_strPassword = CVAR_GET_STRING("pass"); g_bWindowedMode = CVAR_GET_BOOL("windowed"); g_bFPSToggle = CVAR_GET_BOOL("fps"); // IE9 fix - disabled if disableie9fix is set or shift is pressed if(!CVAR_GET_BOOL("disableie9fix") || GetAsyncKeyState(VK_SHIFT) > 0) { // Get the version info DWORD dwHandle; DWORD dwSize = GetFileVersionInfoSize("wininet.dll", &dwHandle); BYTE* byteFileInfo = new BYTE[dwSize]; GetFileVersionInfo("wininet.dll", dwHandle, dwSize, byteFileInfo); unsigned int uiLen; VS_FIXEDFILEINFO* fileInfo; VerQueryValue(byteFileInfo, "\\", (LPVOID *)&fileInfo, &uiLen); delete byteFileInfo; // using IE9? if(fileInfo->dwFileVersionMS == 0x90000) { // Try and load a wininet.dll from the iv:mp directory if(!LoadLibrary(SharedUtility::GetAbsolutePath("wininet.dll"))) { // Get path to it char szFindPath[MAX_PATH] = {0}; char szWinSxsPath[MAX_PATH] = {0}; char szBuildVersion[] = "00000"; GetEnvironmentVariable("windir", szWinSxsPath, sizeof(szWinSxsPath)); strcat_s(szWinSxsPath, sizeof(szWinSxsPath), "\\WinSxS\\"); strcpy_s(szFindPath, sizeof(szFindPath), szWinSxsPath); strcat_s(szFindPath, sizeof(szFindPath), "x86_microsoft-windows-i..tocolimplementation_31bf3856ad364e35*"); // try to find a usable wininet.dll in WinSXS (basically any non-9.x version) bool bLoaded = false; WIN32_FIND_DATA lpFindFileData; HANDLE hFindFile = FindFirstFile(szFindPath, &lpFindFileData); do { if(hFindFile == INVALID_HANDLE_VALUE) break; if(strlen(lpFindFileData.cFileName) > 63) { if(lpFindFileData.cFileName[62] < '9') { char szFullPath[MAX_PATH]; sprintf_s(szFullPath, MAX_PATH, "%s%s\\wininet.dll", szWinSxsPath, lpFindFileData.cFileName); if(LoadLibrary(szFullPath)) { CLogFile::Printf("Using %s to address IE9 issue", szFullPath); bLoaded = true; break; } } } } while(FindNextFile(hFindFile, &lpFindFileData)); // Still failed, tell the user if(!bLoaded) { if(MessageBox(0, "Unfortunately, you have Internet Explorer 9 installed which is not compatible with GTA:IV. Do you want proceed anyway (and possibly crash?)", "IV:MP", MB_YESNO | MB_ICONERROR) == IDNO) { // Doesn't want to continue ExitProcess(0); } // Save the user's choice CVAR_SET_BOOL("disableie9fix", true); } } } } // Initialize the streamer g_pStreamer = new CStreamer(); // Initialize the time g_pTime = new CTime(); // Initialize the traffic lights g_pTrafficLights = new CTrafficLights(); // Initialize the client task manager g_pClientTaskManager = new CClientTaskManager(); // Initialize the game CGame::Initialize(); // Install the XLive hook CXLiveHook::Install(); // Install the Direct3D hook CDirect3DHook::Install(); // Install the DirectInput hook CDirectInputHook::Install(); // Install the Cursor hook #ifdef IVMP_DEBUG CCursorHook::Install(); g_pDebugView = new CDebugView(); #endif // Initialize the client script manager g_pClientScriptManager = new CClientScriptManager(); // Initialize the events manager g_pEvents = new CEvents(); // Initialize the network module, if it fails, exit if(!CNetworkModule::Init()) { CLogFile::Printf("Failed to initialize the network module!\n"); ExitProcess(0); } // Initialize the file transfer g_pFileTransfer = new CFileTransfer(); // Initialize audio manager CAudioManager::Init(); } break; case DLL_PROCESS_DETACH: { // Delete our file transfer SAFE_DELETE(g_pFileTransfer); // Delete our camera SAFE_DELETE(g_pCamera); // Delete our model manager SAFE_DELETE(g_pModelManager); // Delete our pickup manager SAFE_DELETE(g_pPickupManager); // Delete our checkpoint manager SAFE_DELETE(g_pCheckpointManager); // Delete our object manager SAFE_DELETE(g_pObjectManager); // Delete our blip manager SAFE_DELETE(g_pBlipManager); // Delete our actor manager SAFE_DELETE(g_pActorManager); // Delete our vehicle manager SAFE_DELETE(g_pVehicleManager); // Delete our local player SAFE_DELETE(g_pLocalPlayer); // Delete our player manager SAFE_DELETE(g_pPlayerManager); // Delete our network manager SAFE_DELETE(g_pNetworkManager); // Delete our name tags SAFE_DELETE(g_pNameTags); // Delete our input window SAFE_DELETE(g_pInputWindow); // Delete our chat window SAFE_DELETE(g_pChatWindow); // Delete our fps counter SAFE_DELETE(g_pFPSCounter); #ifdef IVMP_DEBUG // Delete out debug viewer SAFE_DELETE(g_pDebugView); #endif // Delete our credits SAFE_DELETE(g_pCredits); // Delete our main menu SAFE_DELETE(g_pMainMenu); // Delete our gui SAFE_DELETE(g_pGUI); // Delete our streamer class SAFE_DELETE(g_pStreamer); // Delete our time class SAFE_DELETE(g_pTime); // Delete our traffic lights SAFE_DELETE(g_pTrafficLights); // Delete our client script manager SAFE_DELETE(g_pClientScriptManager); // Delete our client task manager SAFE_DELETE(g_pClientTaskManager); // Delete our events manager SAFE_DELETE(g_pEvents); // Uninstall the Cursor hook #ifdef IVMP_DEBUG CCursorHook::Uninstall(); #endif // Uninstall the DirectInput hook CDirectInputHook::Uninstall(); // Uninstall the Direct3D hook CDirect3DHook::Uninstall(); // Shutdown audio manager CAudioManager::SetAllVolume(0.0f); CAudioManager::RemoveAll(); // Shutdown our game CGame::Shutdown(); // Close the settings file CSettings::Close(); // Close the log file CLogFile::Close(); // Uninstall the XLive hook //CXLiveHook::Uninstall(); // Not needed } break; } return TRUE; }
bool CClient::OnLoad() { // Install the exception handler CExceptionHandler::Install(); // Set our exception handler callback CExceptionHandler::SetCallback(ExceptionHandlerCallback); // jenksta: wtf? // Delete chatlog CLogFile::Open("Chatlog.log"); CLogFile::Printf("New chatlog created!"); CLogFile::Close(); // Open the log file CLogFile::Open("Client.log"); // Log the version CLogFile::Printf(VERSION_IDENTIFIER "| " __DATE__ " - " __TIME__ ""); // Open the settings file CSettings::Open(SharedUtility::GetAbsolutePath("clientsettings.xml")); // Parse the command line CSettings::ParseCommandLine(GetCommandLine()); // Load the global vars from the settings m_strHost = CVAR_GET_STRING("ip"); m_usPort = CVAR_GET_INTEGER("port"); m_strNick = CVAR_GET_STRING("nick"); m_strPassword = CVAR_GET_STRING("pass"); m_bWindowedMode = CVAR_GET_BOOL("windowed"); m_bFPSToggle = CVAR_GET_BOOL("fps"); m_strConnectHost = CVAR_GET_STRING("currentconnect_server"); m_usConnectPort = CVAR_GET_INTEGER("currentconnect_port"); // IE9 fix - disabled if disableie9fix is set or shift is pressed if(!CVAR_GET_BOOL("disableie9fix") || GetAsyncKeyState(VK_SHIFT) > 0) { // Get the version info DWORD dwHandle; DWORD dwSize = GetFileVersionInfoSize("wininet.dll", &dwHandle); BYTE* byteFileInfo = new BYTE[dwSize]; GetFileVersionInfo("wininet.dll", dwHandle, dwSize, byteFileInfo); unsigned int uiLen; VS_FIXEDFILEINFO* fileInfo; VerQueryValue(byteFileInfo, "\\", (LPVOID *)&fileInfo, &uiLen); delete byteFileInfo; // using IE9? if(fileInfo->dwFileVersionMS == 0x90000) { // Try and load a wininet.dll from the iv:mp directory if(!LoadLibrary(SharedUtility::GetAbsolutePath("wininet.dll"))) { // Get path to it char szFindPath[MAX_PATH] = {0}; char szWinSxsPath[MAX_PATH] = {0}; char szBuildVersion[] = "00000"; GetEnvironmentVariable("windir", szWinSxsPath, sizeof(szWinSxsPath)); strcat_s(szWinSxsPath, sizeof(szWinSxsPath), "\\WinSxS\\"); strcpy_s(szFindPath, sizeof(szFindPath), szWinSxsPath); strcat_s(szFindPath, sizeof(szFindPath), "x86_microsoft-windows-i..tocolimplementation_31bf3856ad364e35*"); // try to find a usable wininet.dll in WinSXS (basically any non-9.x version) bool bLoaded = false; WIN32_FIND_DATA lpFindFileData; HANDLE hFindFile = FindFirstFile(szFindPath, &lpFindFileData); do { if(hFindFile == INVALID_HANDLE_VALUE) break; if(strlen(lpFindFileData.cFileName) > 63) { if(lpFindFileData.cFileName[62] < '9') { char szFullPath[MAX_PATH]; sprintf_s(szFullPath, MAX_PATH, "%s%s\\wininet.dll", szWinSxsPath, lpFindFileData.cFileName); if(LoadLibrary(szFullPath)) { CLogFile::Printf("Using %s to address IE9 issue", szFullPath); bLoaded = true; break; } } } } while(FindNextFile(hFindFile, &lpFindFileData)); // Still failed, tell the user if(!bLoaded) { if(MessageBox(0, "Unfortunately, you have Internet Explorer 9 installed which is not compatible with GTA:IV. Do you want proceed anyway (and possibly crash?)", "IV:MP", MB_YESNO | MB_ICONERROR) == IDNO) { // Doesn't want to continue return false; } // Save the user's choice CVAR_SET_BOOL("disableie9fix", true); } } } } // Initialize the streamer m_pStreamer = new CStreamer(); // Initialize the time m_pTime = new CTime(); // Initialize the traffic lights m_pTrafficLights = new CTrafficLights(); // Initialize the client task manager m_pClientTaskManager = new CClientTaskManager(); // Initialize the game CGame::Initialize(); // Install the XLive hook CXLiveHook::Install(); // Install the Direct3D hook CDirect3DHook::Install(); // Install the DirectInput hook CDirectInputHook::Install(); #ifdef IVMP_DEBUG // Install the Cursor hook CCursorHook::Install(); // Create our Debug View m_pDebugView = new CDebugView(); #endif // Initialize the client script manager m_pClientScriptManager = new CClientScriptManager(); // Initialize the events manager m_pEvents = new CEvents(); // Initialize the network module, if it fails, exit if(!CNetworkModule::Init()) { CLogFile::Printf("Failed to initialize the network module!\n"); return false; } // Initialize the file transfer manager m_pFileTransfer = new CFileTransferManager(); // Initialize the http client m_pHttpClient = new CHttpClient(); m_pHttpClient->SetRequestTimeout(10000); m_pHttpClient->SetHost(MASTERLIST_ADDRESS); return true; }