Example #1
0
static void DoPatchGame(const char* patch_name, char* game_name, UINT8* base)
{
	char s[MAX_PATH];
	char* p = NULL;
	char* rom_name = NULL;
	char* ips_name = NULL;
	FILE* fp = NULL;
	unsigned long nIpsSize;

	if ((fp = fopen(patch_name, "rb")) != NULL) {
		// get ips size
		fseek(fp, 0, SEEK_END);
		nIpsSize = ftell(fp);
		fseek(fp, 0, SEEK_SET);

		while (!feof(fp)) {
			if (fgets(s, sizeof s, fp) != NULL) {
				p = s;

				// skip UTF-8 sig
				if (strncmp(p, UTF8_SIGNATURE, strlen(UTF8_SIGNATURE)) == 0)
					p += strlen(UTF8_SIGNATURE);

				if (p[0] == '[')	// '['
					break;

				rom_name = strtok(p, " \t\r\n");
				if (!rom_name)
					continue;
				if (*rom_name == '#')
					continue;
				if (_stricmp(rom_name, game_name))
					continue;

				ips_name = strtok(NULL, " \t\r\n");
				if (!ips_name)
					continue;

				// skip CRC check
				strtok(NULL, "\r\n");

				char ips_path[MAX_PATH];
				char ips_dir[MAX_PATH];
				TCHARToANSI(szAppIpsPath, ips_dir, sizeof(ips_dir));

				if (strchr(ips_name, '\\')) {
					// ips in parent's folder
					sprintf(ips_path, "%s\\%s%s", ips_dir, ips_name, IPS_EXT);
				} else {
					sprintf(ips_path, "%s%s\\%s%s", ips_dir, BurnDrvGetTextA(DRV_NAME), ips_name, IPS_EXT);
				}

				PatchFile(ips_path, base);
			}
		}
		fclose(fp);
	}
}
Example #2
0
bool GitPatch::ApplyPatches()
{
	
	for (int i = 0; i < m_patch.GetNumberOfFiles(); ++i)
	{
		if (!PatchFile(i, m_targetpath))
			return false;
	}

	return true;
}
Example #3
0
/************************************************************************************
  타이머
*************************************************************************************/
void CNewAppDlg::OnTimer(UINT nIDEvent)
{
	// 업데이트 타이머
	if ( nIDEvent == 0)
	{
		static DWORD tStartTime = timeGetTime();
		DWORD currTime = timeGetTime() - tStartTime;


		// 런쳐 프로세스가 종료되는 것을 확인한다
		static bool bClosedLauncher = false;
		if ( !bClosedLauncher && (currTime > 500))
		{
			bClosedLauncher = FindLauncherProcess();
		}


		// 파일 패치
		if ( bClosedLauncher)
		{
			static int nPatchCount = 0;
			static int nErrorCount = 0;
			switch ( nPatchCount)
			{
				case 0 :
					nPatchCount++;
					if ( PatchFile( ".\\PATCH\\AbbyLauncher.exe_", ".\\AbbyLauncher.exe") == false)
						nErrorCount++;
					break;

				case 1 :
					nPatchCount++;
					if ( PatchFile( ".\\PATCH\\HanAuthForClient.dll_", ".\\HanAuthForClient.dll") == false)
						nErrorCount++;
					break;

				case 2 :
					nPatchCount++;
					if ( PatchFile( ".\\PATCH\\HanReportForClient.dll_", ".\\HanReportForClient.dll") == false)
						nErrorCount++;
					break;

				case 3 :
					nPatchCount++;

					if ( nErrorCount)
					{
						((CListBox*)GetDlgItem( IDC_OUTPUT))->ShowScrollBar( SB_HORZ);
						((CListBox*)GetDlgItem( IDC_OUTPUT))->SetHorizontalExtent( 1000);
						
						char szMsg[ 512];
						sprintf( szMsg, "%d error has been found.", nErrorCount);
						OutputMsg( szMsg);
					}
					else
						OutputMsg( "Patch successfully completed.");
					
					tStartTime = timeGetTime();
					m_cOK.EnableWindow( TRUE);
					break;

				// 윈도우 종료
				case 4 :
					if ( (nErrorCount == 0) && (currTime > 2000))
						OnOK();
					break;

				default :
					break;
			}
		}
	}


	CDDBDialog::OnTimer(nIDEvent);
}