diff --git a/MSCeditor/MSCeditor.rc b/MSCeditor/MSCeditor.rc index 042b163..54658bf 100644 Binary files a/MSCeditor/MSCeditor.rc and b/MSCeditor/MSCeditor.rc differ diff --git a/MSCeditor/MSCeditor.vcxproj b/MSCeditor/MSCeditor.vcxproj index c71abe1..1e69085 100644 --- a/MSCeditor/MSCeditor.vcxproj +++ b/MSCeditor/MSCeditor.vcxproj @@ -37,40 +37,40 @@ Application true - v142 + v143 Unicode Application false - v142 + v143 true Unicode Application false - v142 + v143 true Unicode Application true - v142 + v143 Unicode Application false - v142 + v143 true Unicode Application false - v142 + v143 true Unicode diff --git a/MSCeditor/MapAsset/map_dxt.jpg b/MSCeditor/MapAsset/map_dxt.jpg new file mode 100644 index 0000000..bf6a433 Binary files /dev/null and b/MSCeditor/MapAsset/map_dxt.jpg differ diff --git a/MSCeditor/externs.cpp b/MSCeditor/externs.cpp index 8d36de7..5ed74f9 100644 --- a/MSCeditor/externs.cpp +++ b/MSCeditor/externs.cpp @@ -28,7 +28,7 @@ DebugOutput *dbglog; class MapDialog* EditorMap = NULL; #endif /*_MAP*/ -bool bFiledateinit = FALSE, bMakeBackup = TRUE, bEulerAngles = FALSE, bCheckForUpdate = TRUE, bBackupChangeNotified = FALSE, bFirstStartup = TRUE, bAllowScale = FALSE, bDisplayRawNames = FALSE, bCheckIssues = FALSE, bStartWithMap = FALSE; +bool bFiledateinit = FALSE, bMakeBackup = TRUE, bEulerAngles = FALSE, bBackupChangeNotified = FALSE, bFirstStartup = TRUE, bAllowScale = FALSE, bDisplayRawNames = FALSE, bCheckIssues = FALSE, bStartWithMap = FALSE; const std::wstring settings[] = { L"make_backup", L"backup_change_notified", L"check_updates", L"first_startup", L"allow_scale", L"use_euler", L"raw_names", L"check_issues", L"start_with_map"}; PVOID pResizeState = NULL; @@ -39,7 +39,7 @@ const float deg2Rad = pi / 180.f; const std::wstring posInfinity(1, wchar_t(0x221E)); const std::wstring negInfinity = L"-" + posInfinity; -const std::wstring Version = std::to_wstring(VERSION_MAJOR) + L"." + std::to_wstring(VERSION_MINOR); +const std::wstring Version = std::to_wstring(VERSION_MAJOR) + L"." + std::to_wstring(VERSION_MINOR) + L"." + std::to_wstring(VERSION_REVISION); const std::wstring bools[2] = { L"false", L"true" }; const std::wstring Title = L"MSCEditor " + Version; const std::wstring IniFile = L"msce.ini"; diff --git a/MSCeditor/externs.h b/MSCeditor/externs.h index 4c9ab84..033feac 100644 --- a/MSCeditor/externs.h +++ b/MSCeditor/externs.h @@ -88,7 +88,7 @@ extern HFONT hListFont; #ifdef _MAP extern class MapDialog* EditorMap; #endif /*_MAP*/ -extern bool bFiledateinit, bMakeBackup, bEulerAngles, bCheckForUpdate, bBackupChangeNotified, bFirstStartup, bAllowScale, bDisplayRawNames, bCheckIssues, bStartWithMap; +extern bool bFiledateinit, bMakeBackup, bEulerAngles, bBackupChangeNotified, bFirstStartup, bAllowScale, bDisplayRawNames, bCheckIssues, bStartWithMap; extern PVOID pResizeState; diff --git a/MSCeditor/main.cpp b/MSCeditor/main.cpp index 05957df..e57df45 100644 --- a/MSCeditor/main.cpp +++ b/MSCeditor/main.cpp @@ -63,38 +63,10 @@ INT_PTR CALLBACK DlgProc(HWND hwnd, uint32_t Message, WPARAM wParam, LPARAM lPar HWND hHelp = CreateDialog(hInst, MAKEINTRESOURCE(IDD_HELP), hDialog, HelpProc); ShowWindow(hHelp, SW_SHOW); } - - //check updates - if (bCheckForUpdate && !appfolderpath.empty()) - { - std::wstring path; -#ifdef _DEBUG - if (!DownloadUpdatefile(L"", path)) -#else - if (!DownloadUpdatefile(L"http://mscedit.superskalar.org/current", path)) -#endif - { - std::wstring link, changelog; - if (CheckUpdate(path, link, changelog)) - { - switch (MessageBox(NULL, (GLOB_STRS[36] + changelog).c_str(), Title.c_str(), MB_YESNO | MB_ICONINFORMATION)) - { - case IDYES: - ShellExecute(NULL, L"open", link.c_str(), NULL, NULL, SW_SHOWDEFAULT); - EndDialog(hDialog, 0); - break; - default: - break; - } - } - } - } // Apply settings if (!bMakeBackup) CheckMenuItem(GetSubMenu(GetMenu(hDialog), 2), GetMenuItemID(GetSubMenu(GetMenu(hDialog), 2), 0), MF_UNCHECKED); - if (!bCheckForUpdate) - CheckMenuItem(GetSubMenu(GetMenu(hDialog), 2), GetMenuItemID(GetSubMenu(GetMenu(hDialog), 2), 1), MF_UNCHECKED); if (!bEulerAngles) CheckMenuItem(GetSubMenu(GetMenu(hDialog), 2), GetMenuItemID(GetSubMenu(GetMenu(hDialog), 2), 2), MF_UNCHECKED); if (!bDisplayRawNames) @@ -339,11 +311,6 @@ INT_PTR CALLBACK DlgProc(HWND hwnd, uint32_t Message, WPARAM wParam, LPARAM lPar bMakeBackup = !bMakeBackup; break; } - case ID_OPTIONS_CHECKFORUPDATES: - { - bCheckForUpdate = MF_CHECKED != (bCheckForUpdate ? CheckMenuItem(GetSubMenu(GetMenu(hDialog), 2), GetMenuItemID(GetSubMenu(GetMenu(hDialog), 2), 1), MF_UNCHECKED) : CheckMenuItem(GetSubMenu(GetMenu(hDialog), 2), GetMenuItemID(GetSubMenu(GetMenu(hDialog), 2), 1), MF_CHECKED)); - break; - } case ID_OPTIONS_USEEULERANGLES: { bEulerAngles = MF_CHECKED != (bEulerAngles ? CheckMenuItem(GetSubMenu(GetMenu(hDialog), 2), GetMenuItemID(GetSubMenu(GetMenu(hDialog), 2), 2), MF_UNCHECKED) : CheckMenuItem(GetSubMenu(GetMenu(hDialog), 2), GetMenuItemID(GetSubMenu(GetMenu(hDialog), 2), 2), MF_CHECKED)); diff --git a/MSCeditor/map.cpp b/MSCeditor/map.cpp index d5738ee..e55d120 100644 --- a/MSCeditor/map.cpp +++ b/MSCeditor/map.cpp @@ -88,28 +88,6 @@ D2D1_SIZE_F GetCursorSize() return size; } -// MAKE SURE THESE AREN'T INCLUDED IN THE SOURCE -namespace Obfuscate -{ - HRESULT ObfuscateIStream(IStream* pOutStream) - { - /* Omitted */ - return S_OK; - } - - HRESULT DeobfuscateResource(BYTE* ResourceBytes, const DWORD imageFileSize, BYTE* OutputBytes) - { - /* Omitted */ - return S_OK; - } - - HRESULT IsValidJPG(BYTE* Bytes, const DWORD NumBytes) - { - /* Omitted */ - return S_OK; - } -} - HRESULT PrepareResource(BYTE** pResource, DWORD& imageFileSize) { HRESULT hr = S_OK; @@ -141,16 +119,7 @@ HRESULT PrepareResource(BYTE** pResource, DWORD& imageFileSize) if (SUCCEEDED(hr)) { *pResource = new BYTE[imageFileSize](); - hr = Obfuscate::DeobfuscateResource(reinterpret_cast(pImageFile), imageFileSize, *pResource); - } - if (SUCCEEDED(hr)) - { - hr = Obfuscate::IsValidJPG(*pResource, imageFileSize); - if (FAILED(hr)) - { - delete[] *pResource; - *pResource = NULL; - } + std::memcpy(*pResource, reinterpret_cast(pImageFile), imageFileSize); } if (imageResDataHandle) FreeResource(imageResDataHandle); @@ -202,11 +171,10 @@ MapDialog::~MapDialog() m_MapDistanceNodes.clear(); m_MapDistanceNodes.shrink_to_fit(); std::forward_list().swap(m_MapMarkers); - CoUninitialize(); EditorMap = NULL; } -HERROR MapDialog::PrepareRawImage(BYTE** pDeobfuscatedResource, ComPtr& pConverter, const DWORD imageFileSize, const GUID& format) +HERROR MapDialog::PrepareRawImage(BYTE** pResource, ComPtr& pConverter, const DWORD imageFileSize, const GUID& format) { HERROR hr = { S_OK, std::string(s_eSz, '\0') }; ComPtr pResourceStream; @@ -220,7 +188,7 @@ HERROR MapDialog::PrepareRawImage(BYTE** pDeobfuscatedResource, ComPtrInitializeFromMemory(*pDeobfuscatedResource, imageFileSize); + hr.first = pResourceStream->InitializeFromMemory(*pResource, imageFileSize); MAKE_HR(hr); @@ -254,140 +222,142 @@ HERROR MapDialog::PrepareRawImage(BYTE** pDeobfuscatedResource, ComPtr pRawImage; + HRESULT hres = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); + if (SUCCEEDED(hres)) { - DWORD imageFileSize; - // Lock and allocate resource - hr.first = PrepareResource(&pDeobfuscatedResource, imageFileSize); + HERROR hr = { S_OK, std::string(s_eSz, '\0') }; + BYTE* pResource = NULL; + ComPtr pRawImage; - // Convert JPG to raw image - if (SUCCEEDED(hr.first)) - hr = PrepareRawImage(&pDeobfuscatedResource, pRawImage, imageFileSize, GUID_WICPixelFormat32bppBGR); + { + DWORD imageFileSize; + // Lock and allocate resource + hr.first = PrepareResource(&pResource, imageFileSize); - MAKE_HR(hr); - } + // Convert JPG to raw image + if (SUCCEEDED(hr.first)) + hr = PrepareRawImage(&pResource, pRawImage, imageFileSize, GUID_WICPixelFormat32bppBGR); - // Encode and save DDS - { - ComPtr pDDSEncoder; - ComPtr pBitMapEncoder; - ComPtr pDDSFrame; - ComPtr pOutStream; - WICDdsParameters DDSParams = { 0 }; + MAKE_HR(hr); + } - if (SUCCEEDED(hr.first)) + // Encode and save DDS { - UINT JPGHeight = UINT_MAX, JPGWidth = UINT_MAX; - pRawImage->GetSize(&JPGWidth, &JPGHeight); - DDSParams.AlphaMode = WICDdsAlphaModePremultiplied; - DDSParams.ArraySize = 1; - DDSParams.Depth = 1; - DDSParams.Dimension = WICDdsTexture2D; - DDSParams.DxgiFormat = DXGI_FORMAT_BC1_UNORM; - DDSParams.Height = JPGHeight; - DDSParams.Width = JPGWidth; - DDSParams.MipLevels = 1; - } + ComPtr pDDSEncoder; + ComPtr pBitMapEncoder; + ComPtr pDDSFrame; + ComPtr pOutStream; + WICDdsParameters DDSParams = { 0 }; - MAKE_HR(hr); + if (SUCCEEDED(hr.first)) + { + UINT JPGHeight = UINT_MAX, JPGWidth = UINT_MAX; + pRawImage->GetSize(&JPGWidth, &JPGHeight); + DDSParams.AlphaMode = WICDdsAlphaModePremultiplied; + DDSParams.ArraySize = 1; + DDSParams.Depth = 1; + DDSParams.Dimension = WICDdsTexture2D; + DDSParams.DxgiFormat = DXGI_FORMAT_BC1_UNORM; + DDSParams.Height = JPGHeight; + DDSParams.Width = JPGWidth; + DDSParams.MipLevels = 1; + } - if (SUCCEEDED(hr.first)) - hr.first = m_IWICFactory->CreateStream(pOutStream.GetAddressOf()); + MAKE_HR(hr); - MAKE_HR(hr); + if (SUCCEEDED(hr.first)) + hr.first = m_IWICFactory->CreateStream(pOutStream.GetAddressOf()); - if (SUCCEEDED(hr.first)) - hr.first = FindAndCreateAppFolder(); + MAKE_HR(hr); - MAKE_HR(hr); + if (SUCCEEDED(hr.first)) + hr.first = FindAndCreateAppFolder(); - if (SUCCEEDED(hr.first)) - hr.first = pOutStream->InitializeFromFilename(m_MapDDSPath.c_str(), GENERIC_WRITE | GENERIC_READ); + MAKE_HR(hr); - MAKE_HR(hr); + if (SUCCEEDED(hr.first)) + hr.first = pOutStream->InitializeFromFilename(m_MapDDSPath.c_str(), GENERIC_WRITE | GENERIC_READ); - if (SUCCEEDED(hr.first)) - hr.first = m_IWICFactory->CreateEncoder(GUID_ContainerFormatDds, NULL, pBitMapEncoder.GetAddressOf()); + MAKE_HR(hr); - MAKE_HR(hr); + if (SUCCEEDED(hr.first)) + hr.first = m_IWICFactory->CreateEncoder(GUID_ContainerFormatDds, NULL, pBitMapEncoder.GetAddressOf()); - if (SUCCEEDED(hr.first)) - hr.first = pBitMapEncoder->Initialize(pOutStream.Get(), WICBitmapEncoderNoCache); + MAKE_HR(hr); - MAKE_HR(hr); + if (SUCCEEDED(hr.first)) + hr.first = pBitMapEncoder->Initialize(pOutStream.Get(), WICBitmapEncoderNoCache); - if (SUCCEEDED(hr.first)) - hr.first = pBitMapEncoder.As(&pDDSEncoder); + MAKE_HR(hr); - MAKE_HR(hr); + if (SUCCEEDED(hr.first)) + hr.first = pBitMapEncoder.As(&pDDSEncoder); - if (SUCCEEDED(hr.first)) - hr.first = pDDSEncoder->SetParameters(&DDSParams); - - MAKE_HR(hr); + MAKE_HR(hr); - if (SUCCEEDED(hr.first)) - { - UINT ArrayIndex = UINT_MAX, MipLevelIndex = UINT_MAX, SliceIndex = UINT_MAX; - hr.first = pDDSEncoder->CreateNewFrame(pDDSFrame.GetAddressOf(), &ArrayIndex, &MipLevelIndex, &SliceIndex); - } + if (SUCCEEDED(hr.first)) + hr.first = pDDSEncoder->SetParameters(&DDSParams); + + MAKE_HR(hr); - MAKE_HR(hr); + if (SUCCEEDED(hr.first)) + { + UINT ArrayIndex = UINT_MAX, MipLevelIndex = UINT_MAX, SliceIndex = UINT_MAX; + hr.first = pDDSEncoder->CreateNewFrame(pDDSFrame.GetAddressOf(), &ArrayIndex, &MipLevelIndex, &SliceIndex); + } - if (SUCCEEDED(hr.first)) - hr.first = pDDSFrame->Initialize(NULL); + MAKE_HR(hr); - MAKE_HR(hr); + if (SUCCEEDED(hr.first)) + hr.first = pDDSFrame->Initialize(NULL); - if (SUCCEEDED(hr.first)) - hr.first = pDDSFrame->WriteSource(pRawImage.Get(), NULL); + MAKE_HR(hr); - MAKE_HR(hr); + if (SUCCEEDED(hr.first)) + hr.first = pDDSFrame->WriteSource(pRawImage.Get(), NULL); - if (SUCCEEDED(hr.first)) - hr.first = pDDSFrame->Commit(); + MAKE_HR(hr); - MAKE_HR(hr); + if (SUCCEEDED(hr.first)) + hr.first = pDDSFrame->Commit(); - if (SUCCEEDED(hr.first)) - hr.first = pBitMapEncoder->Commit(); + MAKE_HR(hr); - MAKE_HR(hr); + if (SUCCEEDED(hr.first)) + hr.first = pBitMapEncoder->Commit(); - if (SUCCEEDED(hr.first)) - hr.first = Obfuscate::ObfuscateIStream(pOutStream.Get()); + MAKE_HR(hr); - MAKE_HR(hr); + if (pResource) + { + delete[] pResource; + pResource = NULL; + } + } - if (pDeobfuscatedResource) + if (FAILED(hr.first)) { - delete[] pDeobfuscatedResource; - pDeobfuscatedResource = NULL; + std::wstring hrstr(64, '\0'); + HRToStr(hr.first, hrstr); + hrstr += WidenStr(hr.second); + size_t sz = hrstr.size() + 64; + std::wstring buffer(sz, '\0'); + buffer.resize(swprintf(&buffer[0], sz, GLOB_STRS[62].c_str(), hrstr.c_str())); + MessageBox(hDialog, buffer.c_str(), ErrorTitle.c_str(), MB_OK | MB_ICONERROR); } - } - if (FAILED(hr.first)) - { - std::wstring hrstr(64, '\0'); - HRToStr(hr.first, hrstr); - hrstr += WidenStr(hr.second); - size_t sz = hrstr.size() + 64; - std::wstring buffer(sz, '\0'); - buffer.resize(swprintf(&buffer[0], sz, GLOB_STRS[62].c_str(), hrstr.c_str())); - MessageBox(hDialog, buffer.c_str(), ErrorTitle.c_str(), MB_OK | MB_ICONERROR); - } + //if (SUCCEEDED(hr.first)) + // hr.first = IsMapDDSValid() ? S_OK : E_FAIL; - if (SUCCEEDED(hr.first)) - hr.first = IsMapDDSValid() ? S_OK : E_FAIL; + if (SUCCEEDED(hr.first)) + hr = LoadDDS(TRUE); - if (SUCCEEDED(hr.first)) - hr = LoadDDS(TRUE); + if (SUCCEEDED(hr.first)) + OnMapRender(m_MapRenderTarget->GetHwnd()); - if (SUCCEEDED(hr.first)) - OnMapRender(m_MapRenderTarget->GetHwnd()); + CoUninitialize(); + } } HERROR MapDialog::LoadJPG() @@ -395,7 +365,7 @@ HERROR MapDialog::LoadJPG() HERROR hr = { S_OK, std::string(s_eSz, '\0') }; ComPtr pRawImage; - BYTE* pDeobfuscatedResource = NULL; + BYTE* pResource = NULL; DWORD imageFileSize; // If the rendertarget isn't valid, exit here @@ -404,13 +374,13 @@ HERROR MapDialog::LoadJPG() // Lock and allocate resource if (SUCCEEDED(hr.first)) - hr.first = PrepareResource(&pDeobfuscatedResource, imageFileSize); + hr.first = PrepareResource(&pResource, imageFileSize); MAKE_HR(hr); // Convert JPG to raw image if (SUCCEEDED(hr.first)) - hr = PrepareRawImage(&pDeobfuscatedResource, pRawImage, imageFileSize, GUID_WICPixelFormat32bppBGR); + hr = PrepareRawImage(&pResource, pRawImage, imageFileSize, GUID_WICPixelFormat32bppBGR); MAKE_HR(hr); @@ -436,10 +406,10 @@ HERROR MapDialog::LoadJPG() MAKE_HR(hr); // Free memory. We can't do this earlier because pRawImage actually points to this - if (pDeobfuscatedResource) + if (pResource) { - delete[] pDeobfuscatedResource; - pDeobfuscatedResource = NULL; + delete[] pResource; + pResource = NULL; } // Update the map @@ -456,7 +426,7 @@ HERROR MapDialog::LoadDDS(const bool bCalledFromThread) ComPtr pDecoder; ComPtr pFrame; ComPtr pInStream; - ComPtr pDeobfuscatedStream; + ComPtr pOutStream; #ifdef _MAP // If this is called from the worker thread after the object it is called from is destroyed underneath it @@ -480,31 +450,28 @@ HERROR MapDialog::LoadDDS(const bool bCalledFromThread) if (SUCCEEDED(hr.first)) { - pDeobfuscatedStream.Attach(SHCreateMemStream(NULL, 0)); - hr.first = pDeobfuscatedStream ? S_OK : E_OUTOFMEMORY; + pOutStream.Attach(SHCreateMemStream(NULL, 0)); + hr.first = pOutStream ? S_OK : E_OUTOFMEMORY; } MAKE_HR(hr); if (SUCCEEDED(hr.first)) - hr.first = pDeobfuscatedStream->SetSize(stat.cbSize); + hr.first = pOutStream->SetSize(stat.cbSize); MAKE_HR(hr); ULARGE_INTEGER BytesWritten, BytesRead; if (SUCCEEDED(hr.first)) - hr.first = pInStream->CopyTo(pDeobfuscatedStream.Get(), stat.cbSize, &BytesRead, &BytesWritten); + hr.first = pInStream->CopyTo(pOutStream.Get(), stat.cbSize, &BytesRead, &BytesWritten); MAKE_HR(hr); } - if (SUCCEEDED(hr.first)) - hr.first = Obfuscate::ObfuscateIStream(pDeobfuscatedStream.Get()); - MAKE_HR(hr); if (SUCCEEDED(hr.first)) - hr.first = m_IWICFactory->CreateDecoderFromStream(pDeobfuscatedStream.Get(), NULL, WICDecodeMetadataCacheOnDemand, pDecoder.GetAddressOf()); + hr.first = m_IWICFactory->CreateDecoderFromStream(pOutStream.Get(), NULL, WICDecodeMetadataCacheOnDemand, pDecoder.GetAddressOf()); MAKE_HR(hr); diff --git a/MSCeditor/map.h b/MSCeditor/map.h index e190394..5f92a8b 100644 --- a/MSCeditor/map.h +++ b/MSCeditor/map.h @@ -136,7 +136,7 @@ class MapDialog void SidebarUpdateScrollbar(uint32_t nPage = UINT_MAX); // Convert JPG to raw bitmap - HERROR PrepareRawImage(BYTE** pDeobfuscatedResource, Microsoft::WRL::ComPtr& pConverter, const DWORD imageFileSize, const GUID& format); + HERROR PrepareRawImage(BYTE** pResource, Microsoft::WRL::ComPtr& pConverter, const DWORD imageFileSize, const GUID& format); // Gets the JPG from resource, converts it to bitmap, then to DDS and then saves it to file. Is working on a seperate thread. Only executed for Windows 8 and greater void PrepareMapDDS(); diff --git a/MSCeditor/resource.h b/MSCeditor/resource.h index 08e793e..8fa426f 100644 Binary files a/MSCeditor/resource.h and b/MSCeditor/resource.h differ diff --git a/MSCeditor/utils.cpp b/MSCeditor/utils.cpp index 350124c..95385dd 100644 --- a/MSCeditor/utils.cpp +++ b/MSCeditor/utils.cpp @@ -238,13 +238,6 @@ HRESULT FindAndCreateAppFolder() return S_OK; } -BOOL DownloadUpdatefile(const std::wstring url, std::wstring &path) -{ - path = appfolderpath; - AppendPath(path, L"update.tmp"); - return URLDownloadToFile(NULL, (LPCWSTR)url.c_str(), (LPCWSTR)path.c_str(), 0, NULL); -} - void FlipString(std::string &str, std::wstring file = L"") { for (uint32_t i = 0; i < str.size(); i++) @@ -257,85 +250,6 @@ void FlipString(std::string &str, std::wstring file = L"") } } -BOOL ParseUpdateData(const std::string &str, std::vector &strs) -{ - uint32_t i = 0; - - while (TRUE) - { - uint32_t size; - if (str[i] < 0) - size = 128 - (-128 - str[i]); - else - size = (uint32_t)str[i]; - strs.push_back(str.substr(i + 1, size)); - i += 1 + size; - if ((i + 1) >= str.size()) - break; - } - return i == str.size(); -} - -// true = newer than local version, false = identical or older -BOOL IsRemoteVersionNewer(const std::string &localV, const std::string &remoteV) -{ - uint32_t iMax = static_cast(std::max(localV.size(), remoteV.size())); - std::string sl (iMax, '0'); - sl.replace(0, localV.size(), localV); - std::string sr (iMax, '0'); - sr.replace(0, remoteV.size(), remoteV); - - for (uint32_t i = 0; i < iMax; i++) - { - if (isdigit(sl[i]) && isdigit(sr[i])) - { - int ln = atoi(&sl[i]); - int rn = atoi(&sr[i]); - if (ln != rn) - return (rn > ln); - } - } - return FALSE; -} - -BOOL CheckUpdate(std::wstring &file, std::wstring &apppath, std::wstring &changelog) -{ - using namespace std; - - ifstream iwc(file, ifstream::in, ifstream::binary); - if (!iwc.is_open()) - return 1; - - iwc.seekg(0, iwc.end); - uint32_t length = static_cast(iwc.tellg()); - iwc.seekg(0, iwc.beg); - char *buffer = new char[length + 1]; - memset(buffer, '\0', length + 1); - iwc.read(buffer, length); - iwc.close(); - std::string str = buffer; - delete[] buffer; - FlipString(str); - std::vector strs; - bool up2date = TRUE; - if (ParseUpdateData(str, strs)) - { - for (uint32_t i = 0; (i + 1) < strs.size(); i++) - { - if ((strs[i]) == "changelog") - changelog = WidenStr(strs[i + 1]); - if ((strs[i]) == "path1") - apppath = WidenStr(strs[i + 1]); - if ((strs[i]) == "version") - up2date = !IsRemoteVersionNewer(NarrowStr(Version), strs[i + 1]); - } - } - SetFileAttributes(file.c_str(), FILE_ATTRIBUTE_NORMAL); - DeleteFile(file.c_str()); - - return (!up2date && !changelog.empty() && !apppath.empty()); -} - // We might have to read the registry to find out where steam installed My Summer Car std::wstring ReadRegistry(const HKEY root, const std::wstring key, const std::wstring name) { @@ -947,8 +861,6 @@ void FillVector(const std::vector ¶ms, const std::wstring &ide bMakeBackup = bSetting; else if (params[0] == settings[1]) bBackupChangeNotified = bSetting; - else if (params[0] == settings[2]) - bCheckForUpdate = bSetting; else if (params[0] == settings[3]) bFirstStartup = bSetting; else if (params[0] == settings[4]) @@ -1406,7 +1318,6 @@ bool SaveSettings(const std::wstring &savefilename) setting += L'\"' + settings[0] + L"\" \"" + std::to_wstring(bMakeBackup == 1) + L"\"\n"; setting += L'\"' + settings[1] + L"\" \"" + std::to_wstring(bBackupChangeNotified == 1) + L"\"\n"; - setting += L'\"' + settings[2] + L"\" \"" + std::to_wstring(bCheckForUpdate == 1) + L"\"\n"; setting += L'\"' + settings[3] + L"\" \"" + std::to_wstring(bFirstStartup == 1) + L"\"\n"; setting += L'\"' + settings[4] + L"\" \"" + std::to_wstring(bAllowScale == 1) + L"\"\n"; setting += L'\"' + settings[5] + L"\" \"" + std::to_wstring(bEulerAngles == 1) + L"\"\n"; @@ -2830,7 +2741,7 @@ ANGLES NormalizeAngles(ANGLES *angles) ANGLES QuatToEuler(const QTRN *q) { // unit correction factor - float unit = pow(q->x, 2) + pow(q->y, 2) + pow(q->z, 2) + pow(q->w, 2); + float unit = static_cast(pow(q->x, 2) + pow(q->y, 2) + pow(q->z, 2) + pow(q->w, 2)); float test = q->x * q->w - q->y * q->z; float sign = test > 0.4995f * unit ? 1.f : (test < -0.4995f * unit ? -1.f : 0.f); diff --git a/MSCeditor/version.h b/MSCeditor/version.h index 058dba6..4c7aafd 100644 --- a/MSCeditor/version.h +++ b/MSCeditor/version.h @@ -4,11 +4,13 @@ #define VERSION_MAJOR 1 #define VERSION_MINOR 12 +#define VERSION_REVISION 1 #define VER_FILE_DESCRIPTION_STR "My Summer Car Save Editor" -#define VER_FILE_VERSION VERSION_MAJOR, VERSION_MINOR +#define VER_FILE_VERSION VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION #define VER_FILE_VERSION_STR STRINGIZE(VERSION_MAJOR) \ - "." STRINGIZE(VERSION_MINOR) + "." STRINGIZE(VERSION_MINOR) \ + "." STRINGIZE(VERSION_REVISION) #define VER_PRODUCTNAME_STR "MSCEditor" #define VER_PRODUCT_VERSION VER_FILE_VERSION