diff --git a/.gitignore b/.gitignore index 7bd7ec6..1a6d3b6 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,4 @@ ipch*/ *.ipch LilithPort.sdf LilithPortCLI/ +*.VC.opendb diff --git a/LilithPort/MainForm.cpp b/LilithPort/MainForm.cpp index 51f86fb..f4f0c38 100644 --- a/LilithPort/MainForm.cpp +++ b/LilithPort/MainForm.cpp @@ -1124,11 +1124,10 @@ void MainForm::ReceivePackets(IAsyncResult^ asyncResult) // 格ツクじゃないよ try{ - //TODO: change FM exe check String^ exe = gcnew String(MTOPTION.GAME_EXE); FileVersionInfo^ info = FileVersionInfo::GetVersionInfo(exe); - if(info->FileDescription != L"2D格闘ツクール2nd." && info->FileDescription != L"2D格闘ツクール95"){ + if(!IsCompatibleFMExecutable(info->FileDescription)){ throw gcnew Exception; } /* @@ -1143,7 +1142,7 @@ void MainForm::ReceivePackets(IAsyncResult^ asyncResult) if((INT32)(Path::GetFileNameWithoutExtension(exe)->GetHashCode()) != BitConverter::ToInt32(rcv, 3)){ send[1] = 0xFE; } - if(info->FileDescription == L"2D格闘ツクール2nd."){ + if(IsCompatibleFM2KExecutable(info->FileDescription)){ MTINFO.KGT2K = true; } else{ @@ -1154,7 +1153,7 @@ void MainForm::ReceivePackets(IAsyncResult^ asyncResult) catch(Exception^){ send[1] = 0xFF; form->WriteMessage(L"ERROR: This is not a valid 2D Fighter Maker executable.\n", ErrorMessageColor); - form->WriteMessage(L"Please go to the settings menu and set it.\n", ErrorMessageColor); + form->WriteMessage(L"Please go to the settings menu and set the path to a compatible game executable.\n", ErrorMessageColor); } UDP->BeginSend(send, send->Length, ep, gcnew AsyncCallback(SendPackets), UDP); diff --git a/LilithPort/OptionForm.cpp b/LilithPort/OptionForm.cpp index bf8af94..9b38110 100644 --- a/LilithPort/OptionForm.cpp +++ b/LilithPort/OptionForm.cpp @@ -5,13 +5,12 @@ using namespace LilithPort; void OptionForm::SaveOption(bool apply){ - //TODO: change FM exe check MainForm^ parent = safe_cast(this->Owner); try{ FileVersionInfo^ info = FileVersionInfo::GetVersionInfo(textBoxGameExe->Text); - if(info->FileDescription != L"2D格闘ツクール2nd." && info->FileDescription != L"2D格闘ツクール95"){ + if(!IsCompatibleFMExecutable(info->FileDescription)){ throw gcnew Exception; } } diff --git a/LilithPort/OptionForm.h b/LilithPort/OptionForm.h index 472ae5b..d4133d9 100644 --- a/LilithPort/OptionForm.h +++ b/LilithPort/OptionForm.h @@ -2407,14 +2407,13 @@ private: System::Windows::Forms::CheckBox^ checkBoxShowResult; openFileDialog1->Title = gcnew String(L"Select a Fighter Maker executable file"); openFileDialog1->Filter = gcnew String(L"Executable file (*.exe)|*.exe"); - //TODO: Again, detecting whether it is supported should NOT be dependent on the file description. if(openFileDialog1->ShowDialog() == ::DialogResult::OK){ FileVersionInfo^ info = FileVersionInfo::GetVersionInfo(openFileDialog1->FileName); if (MTINFO.DEBUG) MessageBox::Show(info->Language + "\n" + info->FileDescription, "Debug: File version info"); - if(info->FileDescription == L"2D格闘ツクール2nd." || info->FileDescription == L"2D格闘ツクール95"){ + if(IsCompatibleFMExecutable(info->FileDescription)){ textBoxGameExe->Text = openFileDialog1->FileName; } else{ @@ -2628,8 +2627,7 @@ private: System::Windows::Forms::CheckBox^ checkBoxShowResult; String^ extension = Path::GetExtension(file[0])->ToLower(); FileVersionInfo^ info = FileVersionInfo::GetVersionInfo(file[0]); - //TODO: game file detection - if(extension == ".exe" && (info->FileDescription == L"2D格闘ツクール2nd." || info->FileDescription == L"2D格闘ツクール95")){ + if(extension == ".exe" && (IsCompatibleFMExecutable(info->FileDescription))) { e->Effect = DragDropEffects::All; } } diff --git a/LilithPort/stdafx.cpp b/LilithPort/stdafx.cpp index 2746a12..6ce5e5e 100644 --- a/LilithPort/stdafx.cpp +++ b/LilithPort/stdafx.cpp @@ -606,6 +606,22 @@ void SetCaption() LeaveCriticalSection(&CS_CAPTION); } +bool IsCompatibleFM2KExecutable(String ^ fileDesc) +{ + return fileDesc == L"2D格闘ツクール2nd." || + fileDesc == L"2D Fighter Maker 2015"; +} + +bool IsCompatibleFM95Executable(String ^ fileDesc) +{ + return fileDesc == L"2D格闘ツクール95"; +} + +bool IsCompatibleFMExecutable(String ^ fileDesc) +{ + return IsCompatibleFM2KExecutable(fileDesc) || IsCompatibleFM95Executable(fileDesc); +} + // 暗号復号用乱数 UINT CipherRand(UINT32 seed) { diff --git a/LilithPort/stdafx.h b/LilithPort/stdafx.h index 5ea68ca..f4efba4 100644 --- a/LilithPort/stdafx.h +++ b/LilithPort/stdafx.h @@ -35,6 +35,10 @@ void DeleteSection(TCHAR* obj); void ChangeStageValue(); void SetCaption(); +bool IsCompatibleFM2KExecutable(String^ fileDesc); +bool IsCompatibleFM95Executable(String^ fileDesc); +bool IsCompatibleFMExecutable(String^ fileDesc); + String^ EncryptionIP(String^ ip); String^ MTEncryptionIP(String^ ip); _int64 DecryptionIP(String^ cipher_ip, bool enc);