Skip to content

Commit

Permalink
Fix compiler warnings in cfgmgr.c
Browse files Browse the repository at this point in the history
Change defaults for Write INI File.
Add help for Write INI File.
Fix SetCursorPos test in DXGL Test.
Remove beta tag for release.

git-svn-id: https://www.williamfeely.info/svn/dxgl@825 8a90861a-4eca-46d5-b744-240ff16d0c4d
  • Loading branch information
dxgldotorg committed Jul 1, 2018
1 parent 72bb0a8 commit 9b16ac2
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 38 deletions.
2 changes: 2 additions & 0 deletions Help/Help.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@
<None Include="html\config\advanced\textureaccessmethod.htmltitle" />
<None Include="html\config\advanced\textureformat.htmlbody" />
<None Include="html\config\advanced\textureformat.htmltitle" />
<None Include="html\config\advanced\writeinifile.htmlbody" />
<None Include="html\config\advanced\writeinifile.htmltitle" />
<None Include="html\config\debugtab.htmlbody" />
<None Include="html\config\debugtab.htmltitle" />
<None Include="html\config\debug\debugblenddestinationcolor.htmlbody" />
Expand Down
6 changes: 6 additions & 0 deletions Help/Help.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -507,5 +507,11 @@
<None Include="html\config\advanced\capturemouseinwindowmode.htmlbody">
<Filter>Help files\html\config\advanced</Filter>
</None>
<None Include="html\config\advanced\writeinifile.htmltitle">
<Filter>Help files\html\config\advanced</Filter>
</None>
<None Include="html\config\advanced\writeinifile.htmlbody">
<Filter>Help files\html\config\advanced</Filter>
</None>
</ItemGroup>
</Project>
2 changes: 2 additions & 0 deletions Help/dxgl.hhp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ images\dxglcfg-debug.png
images\dxglcfg-effects.png
images\dxglcfg-hacks.png
images\dxglcfg-tests.png
images\dxglcfg-saveini.png
html\introduction.html
html\troubleshooting.html
html\configuration.html
Expand Down Expand Up @@ -71,6 +72,7 @@ html\config\advanced\startresizablewindowmaximized.html
html\config\advanced\textureaccessmethod.html
html\config\advanced\textureformat.html
html\config\advanced\capturemouseinwindowmode.html
html\config\advanced\writeinifile.html
html\config\debug\debugblenddestinationcolor.html
html\config\debug\disablearbdirectstateaccess.html
html\config\debug\disablearbframebuffers.html
Expand Down
15 changes: 15 additions & 0 deletions Help/html/config/advanced/writeinifile.htmlbody
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<p><img class="alignnone size-full wp-image-427" src="images/dxglcfg-saveini.png" alt="Save .ini File" width="285" height="179" /></p>
<p>Saves a .ini file called dxgl.ini in the profile&#8217;s folder. You may need to launch DXGL Config as administrator in order to use this feature. The .ini file will contain all profile-specific settings. This does not currently allow saving a .ini file for the Global profile.</p>
<p>For more information about dxgl.ini files, please refer to the example configuration file dxgl-example.ini in the DXGL installation folder.</p>
<p><em>This function is available in DXGL 0.5.14 and up.</em></p>
<p>The following functions will affect the saved .ini file:</p>
<h3>Don&#8217;t write application profile to registry</h3>
<p>Adds an option to the .ini file that prevents DXGL from automatically creating a profile for the application. This option is recommended when distributing DXGL with a third-party application or game.</p>
<h3>Override global registry settings</h3>
<p>Adds an option to the .ini file that suppresses loading of the &#8220;Global&#8221; profile when initializing DXGL. Profile-specific settings will still override .ini settings.</p>
<h3>Prevent DXGL Config from overwriting ddraw.dll</h3>
<p>Add an option to the .ini file that prevents DXGL Config from overwriting the ddraw.dll file in the folder where the .ini file resides. This will take effect regardless of whether the ddraw.dll file is from DXGL. This option can be useful for software distributed via clients like Steam where the file&#8217;s contents are managed by the client.</p>
<h3>Save SHA-256 signature of existing ddraw.dll</h3>
<p>If a copy of ddraw.dll is in the profile folder, DXGL Config will calculate its SHA-256 signature and save the results in the .ini file. When DXGL Config creates a profile or DXGL is updated, DXGL will check the SHA-256 signature of the existing ddraw.dll file, and if it matches, back it up to ddraw.dll.dxgl-backup. When removing a profile or uninstalling DXGL, the backup file will be restored back to ddraw.dll unless &#8220;Prevent DXGL Config from deleting ddraw.dll&#8221; is set. This option is recommended when distributing DXGL with a third-party application or game.</p>
<h3>Prevent DXGL Config from deleting ddraw.dll</h3>
<p>Prevents DXGL Config or DXGL uninstallation from deleting the ddraw.dll file in the profile folder. If a backup file is present, the user will have to manually copy it back to ddraw.dll.</p>
1 change: 1 addition & 0 deletions Help/html/config/advanced/writeinifile.htmltitle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Write INI file...
3 changes: 3 additions & 0 deletions Help/html/config/advancedtab.htmlbody
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@
</p>
<p>
<a href="advanced/installationpath.html">Installation path</a>
</p>
<p>
<a href="advanced/writeinifile.html">Write INI file...</a>
</p>
Binary file modified Help/images/dxglcfg-advanced.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Help/images/dxglcfg-saveini.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions Help/toc.hhc
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@
<param name="Name" value="Capture mouse in window mode (Press Ctrl+Alt to release)">
<param name="Local" value="html\config\advanced\capturemouseinwindowmode.html">
</OBJECT>
<LI> <OBJECT type="text/sitemap">
<param name="Name" value="Write INI file...">
<param name="Local" value="html\config\advanced\writeinifile.html">
</OBJECT>
</UL>
<LI> <OBJECT type="text/sitemap">
<param name="Name" value="Debug Tab">
Expand Down
68 changes: 33 additions & 35 deletions cfgmgr/cfgmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ typedef LONG LSTATUS;
#include "../ddraw/resource.h"
#include <tchar.h>
#include <math.h>
#include <float.h>
#include <stdarg.h>
#include "inih/ini.h"

Expand Down Expand Up @@ -1230,7 +1231,7 @@ void INIWriteInt(HANDLE file, const char *name, DWORD value, DWORD mask, int sec
SetINISection(file, section);
strcpy(buffer, name);
strcat(buffer, "=");
itoa(value, number, 10);
_itoa(value, number, 10);
strcat(buffer, number);
strcat(buffer, "\r\n");
buffersize = strlen(buffer);
Expand All @@ -1249,7 +1250,7 @@ void INIWriteHex(HANDLE file, const char *name, DWORD value, DWORD mask, int sec
SetINISection(file, section);
strcpy(buffer, name);
strcat(buffer, "=0x");
itoa(value, number, 16);
_itoa(value, number, 16);
strcat(buffer, number);
strcat(buffer, "\r\n");
buffersize = strlen(buffer);
Expand All @@ -1269,12 +1270,11 @@ void INIWriteFloat(HANDLE file, const char *name, float value, float mask, int d
SetINISection(file, section);
strcpy(buffer, name);
strcat(buffer, "=");
itoa(digits, number, 10);
_itoa(digits, number, 10);
strcpy(floatformat, "%.");
strcat(floatformat, number);
strcat(floatformat, "g");
_snprintf(number, 31, floatformat, value);
itoa(value, number, 10);
strcat(buffer, number);
strcat(buffer, "\r\n");
buffersize = strlen(buffer);
Expand Down Expand Up @@ -1338,7 +1338,7 @@ void FloatToAspectString(float f, char *aspect)
{
if (fabs(modf(fract*i, &dummy)) < 0.0001f)
{
_itoa((f*i) + .5f, aspect, 10);
_itoa((int)((f*i) + .5f), aspect, 10);
_itoa(i, denominator, 10);
strcat(aspect, ":");
strcat(aspect, denominator);
Expand All @@ -1353,7 +1353,6 @@ void INIWriteAspect(HANDLE file, const char *name, float value, float mask, int
{
char buffer[256];
char number[32];
char floatformat[16];
int buffersize;
int outsize;
if (mask)
Expand Down Expand Up @@ -1390,7 +1389,7 @@ void INIWriteTCHARString(HANDLE file, const char *name, LPCTSTR value, DWORD mas
{
char buffer[512];
#ifdef _UNICODE
wchar_t unicodebuffer[MAX_PATH + 1];
char unicodebuffer[MAX_PATH + 1];
#endif
int buffersize;
int outsize;
Expand Down Expand Up @@ -1861,7 +1860,7 @@ void UpgradeDXGLTestToDXGLCfg()
{
sizeout = olddirsize;
sizeout2 = oldvaluesize;
error = RegEnumValue(hKeyProfile, numvalue, olddir, &sizeout, NULL, &regtype, oldvalue, &sizeout2);
error = RegEnumValue(hKeyProfile, numvalue, olddir, &sizeout, NULL, &regtype, (LPBYTE)oldvalue, &sizeout2);
if (error == ERROR_MORE_DATA)
{
if (sizeout > olddirsize)
Expand All @@ -1886,12 +1885,12 @@ void UpgradeDXGLTestToDXGLCfg()
}
sizeout = olddirsize;
sizeout2 = oldvaluesize;
error = RegEnumValue(hKeyProfile, numvalue, olddir, &sizeout, NULL, &regtype, oldvalue, &sizeout2);
error = RegEnumValue(hKeyProfile, numvalue, olddir, &sizeout, NULL, &regtype, (LPBYTE)oldvalue, &sizeout2);
}
if (error == ERROR_SUCCESS)
{
if (_tcsnicmp(olddir, _T("InstallPaths"), sizeout))
RegSetValueEx(hKeyDest, olddir, 0, regtype, oldvalue, sizeout2);
RegSetValueEx(hKeyDest, olddir, 0, regtype, (LPBYTE)oldvalue, sizeout2);
}
numvalue++;
} while (error == ERROR_SUCCESS);
Expand Down Expand Up @@ -1942,7 +1941,7 @@ void UpgradeConfig()
Sha256Context sha_context;
LONG error;
LONG error2;
int i;
DWORD i;
// Check configuration version first
_tcscpy(regkey, regkeybase);
error = RegCreateKeyEx(HKEY_CURRENT_USER, regkey, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKey, NULL);
Expand All @@ -1953,7 +1952,7 @@ void UpgradeConfig()
}
sizeout = 4;
regtype = REG_DWORD;
error = RegQueryValueEx(hKey, _T("Configuration Version"), NULL, &regtype, &version, &sizeout);
error = RegQueryValueEx(hKey, _T("Configuration Version"), NULL, &regtype, (LPBYTE)&version, &sizeout);
if (error != ERROR_SUCCESS) version = 0; // Version is 0 if not set (alpha didn't have version)
if (regtype != REG_DWORD) version = 0; // Is the key the wrong type?
if (version >= 1) goto ver1to2; // If version is 1 check for version 2.
Expand All @@ -1966,7 +1965,7 @@ void UpgradeConfig()
do
{
sizeout = MAX_PATH;
error = RegEnumKeyEx(hKey, keyindex, &subkey, &sizeout,
error = RegEnumKeyEx(hKey, keyindex, subkey, &sizeout,
NULL, NULL, NULL, NULL);
keyindex++;
if (error == ERROR_SUCCESS)
Expand All @@ -1977,7 +1976,7 @@ void UpgradeConfig()
regtype = REG_MULTI_SZ;
sizeout = olddirsize;
error2 = RegQueryValueEx(hKeyProfile, _T("InstallPaths"), NULL,
&regtype, olddir, &sizeout);
&regtype, (LPBYTE)olddir, &sizeout);
if (error2 == ERROR_MORE_DATA)
{
olddirsize = sizeout;
Expand All @@ -1989,7 +1988,7 @@ void UpgradeConfig()
}
sizeout = olddirsize;
error2 = RegQueryValueEx(hKeyProfile, _T("InstallPaths"), NULL,
&regtype, olddir, &sizeout);
&regtype, (LPBYTE)olddir, &sizeout);
}
if (error2 == ERROR_SUCCESS)
{
Expand Down Expand Up @@ -2027,7 +2026,7 @@ void UpgradeConfig()
do
{
sizeout = MAX_PATH;
error = RegEnumKeyEx(hKey, keyindex, &subkey, &sizeout,
error = RegEnumKeyEx(hKey, keyindex, subkey, &sizeout,
NULL, NULL, NULL, NULL);
keyindex++;
if (error == ERROR_SUCCESS)
Expand All @@ -2038,7 +2037,7 @@ void UpgradeConfig()
regtype = REG_MULTI_SZ;
sizeout = olddirsize;
error2 = RegQueryValueEx(hKeyProfile, _T("InstallPaths"), NULL,
&regtype, olddir, &sizeout);
&regtype, (LPBYTE)olddir, &sizeout);
if (error2 == ERROR_MORE_DATA)
{
olddirsize = sizeout;
Expand All @@ -2050,7 +2049,7 @@ void UpgradeConfig()
}
sizeout = olddirsize;
error2 = RegQueryValueEx(hKeyProfile, _T("InstallPaths"), NULL,
&regtype, olddir, &sizeout);
&regtype, (LPBYTE)olddir, &sizeout);
}
if (error2 == ERROR_SUCCESS)
{
Expand Down Expand Up @@ -2084,7 +2083,7 @@ void UpgradeConfig()
}
else
{
_tcscpy(oldkeys[oldconfigcount].crc32, "0");
_tcscpy(oldkeys[oldconfigcount].crc32, _T("0"));
}
_tcscpy(exepath, oldkeys[oldconfigcount].InstallPath);
_tcscat(exepath, _T("\\"));
Expand Down Expand Up @@ -2150,7 +2149,7 @@ void UpgradeConfig()
{
sizeout = olddirsize;
sizeout2 = oldvaluesize;
error = RegEnumValue(hKeyProfile, numvalue, olddir, &sizeout, NULL, &regtype, oldvalue, &sizeout2);
error = RegEnumValue(hKeyProfile, numvalue, olddir, &sizeout, NULL, &regtype, (LPBYTE)oldvalue, &sizeout2);
if (error == ERROR_MORE_DATA)
{
if (sizeout > olddirsize)
Expand All @@ -2175,16 +2174,16 @@ void UpgradeConfig()
}
sizeout = olddirsize;
sizeout2 = oldvaluesize;
error = RegEnumValue(hKeyProfile, numvalue, olddir, &sizeout, NULL, &regtype, oldvalue, &sizeout2);
error = RegEnumValue(hKeyProfile, numvalue, olddir, &sizeout, NULL, &regtype, (LPBYTE)oldvalue, &sizeout2);
}
if (error == ERROR_SUCCESS)
{
if (_tcsnicmp(olddir, _T("InstallPaths"), sizeout))
RegSetValueEx(hKeyDest, olddir, 0, regtype, oldvalue, sizeout2);
RegSetValueEx(hKeyDest, olddir, 0, regtype, (BYTE*)oldvalue, sizeout2);
}
numvalue++;
} while (error == ERROR_SUCCESS);
RegSetValueEx(hKeyDest, _T("InstallPath"), 0, REG_SZ, oldkeys[i].InstallPath,
RegSetValueEx(hKeyDest, _T("InstallPath"), 0, REG_SZ, (BYTE*)oldkeys[i].InstallPath,
((_tcslen(oldkeys[i].InstallPath) + 1) * sizeof(TCHAR)));
RegCloseKey(hKeyDest);
}
Expand All @@ -2199,7 +2198,7 @@ void UpgradeConfig()
if(olddir) free(olddir);
if(oldvalue) free(oldvalue);
sizeout = 1;
RegSetValueEx(hKey, _T("Configuration Version"), 0, REG_DWORD, &sizeout, 4);
RegSetValueEx(hKey, _T("Configuration Version"), 0, REG_DWORD, (BYTE*)&sizeout, 4);
ver1to2:
RegCloseKey(hKey);
// Version 1 to 2: Fix an incorrectly written AddColorDepths value
Expand All @@ -2210,13 +2209,13 @@ void UpgradeConfig()
sizeout = 4;
regtype = REG_DWORD;
error = RegQueryValueEx(hKey,_T("AddColorDepths"),NULL,
&regtype, &numvalue, &sizeout);
&regtype, (LPBYTE)&numvalue, &sizeout);
if (error == ERROR_SUCCESS)
{
if (numvalue == 1)
{
numvalue = 1 | 4 | 16;
RegSetValueEx(hKey, _T("AddColorDepths"), 0, REG_DWORD, &numvalue, 4);
RegSetValueEx(hKey, _T("AddColorDepths"), 0, REG_DWORD, (LPBYTE)&numvalue, 4);
}
}
RegCloseKey(hKey);
Expand All @@ -2229,7 +2228,7 @@ void UpgradeConfig()
do
{
sizeout = MAX_PATH;
error = RegEnumKeyEx(hKey, keyindex, &subkey, &sizeout,
error = RegEnumKeyEx(hKey, keyindex, subkey, &sizeout,
NULL, NULL, NULL, NULL);
keyindex++;
if (error == ERROR_SUCCESS)
Expand All @@ -2238,13 +2237,13 @@ void UpgradeConfig()
if (error2 == ERROR_SUCCESS)
{
error2 = RegQueryValueEx(hKeyProfile, _T("AddColorDepths"), NULL,
&regtype, &numvalue, &sizeout);
&regtype, (LPBYTE)&numvalue, &sizeout);
if (error2 == ERROR_SUCCESS)
{
if (numvalue == 1)
{
numvalue = 1 | 4 | 16;
RegSetValueEx(hKeyProfile, _T("AddColorDepths"), 0, REG_DWORD, &numvalue, 4);
RegSetValueEx(hKeyProfile, _T("AddColorDepths"), 0, REG_DWORD, (BYTE*)&numvalue, 4);
}
}
RegCloseKey(hKeyProfile);
Expand All @@ -2258,24 +2257,24 @@ void UpgradeConfig()
if (error == ERROR_SUCCESS)
{
sizeout = 2;
RegSetValueEx(hKey, _T("Configuration Version"), 0, REG_DWORD, &sizeout, 4);
RegSetValueEx(hKey, _T("Configuration Version"), 0, REG_DWORD, (BYTE*)&sizeout, 4);
RegCloseKey(hKey);
}
}

int ReadINIOptionsCallback(app_ini_options *options, const char *section, const char *name,
const char *value)
{
if (!stricmp(section, "system"))
if (!_stricmp(section, "system"))
{
if (!stricmp(name, "NoOverwrite")) options->NoOverwrite = INIBoolValue(value);
if (!stricmp(name, "BundledDDrawSHA256"))
if (!_stricmp(name, "NoOverwrite")) options->NoOverwrite = INIBoolValue(value);
if (!_stricmp(name, "BundledDDrawSHA256"))
{
strncpy(options->sha256comp, value, 65);
options->sha256comp[64] = 0;
if (options->sha256comp[63] == 0) options->sha256comp[0] = 0;
}
if (!stricmp(name, "NoUninstall")) options->NoUninstall = INIBoolValue(value);
if (!_stricmp(name, "NoUninstall")) options->NoUninstall = INIBoolValue(value);
}
return 1;
}
Expand All @@ -2285,7 +2284,6 @@ void ReadAppINIOptions(LPCTSTR path, app_ini_options *options)
int i;
Sha256Context sha_context;
SHA256_HASH sha256;
TCHAR sha256string[65];
FILE *file;
HANDLE file2;
char buffer[512];
Expand Down
2 changes: 1 addition & 1 deletion common/releasever.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#define DXGLMAJORVER 0
#define DXGLMINORVER 5
#define DXGLPOINTVER 14
#define DXGLBETA 1
#define DXGLBETA 0

#define STR2(x) #x
#define STR(x) STR2(x)
Expand Down
2 changes: 1 addition & 1 deletion dxglcfg/dxglcfg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1963,7 +1963,7 @@ LRESULT CALLBACK SaveINICallback(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lPar
SendDlgItemMessage(hWnd, IDC_OVERRIDEREGISTRY, BM_SETCHECK, BST_UNCHECKED, 0);
SendDlgItemMessage(hWnd, IDC_NOOVERWRITE, BM_SETCHECK, BST_UNCHECKED, 0);
SendDlgItemMessage(hWnd, IDC_SAVESHA256, BM_SETCHECK, BST_CHECKED, 0);
SendDlgItemMessage(hWnd, IDC_NOUNINSTALL, BM_SETCHECK, BST_CHECKED, 0);
SendDlgItemMessage(hWnd, IDC_NOUNINSTALL, BM_SETCHECK, BST_UNCHECKED, 0);
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
Expand Down
2 changes: 1 addition & 1 deletion dxglcfg/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static bool fullscreen,resizable;
static HWND hWnd;
static int testnum;
static unsigned int randnum;
static int testtypes[] = {0,1,0,1,0,1,0,0,2,1,0,0,0,0,0,0};
static int testtypes[] = {0,1,0,1,0,1,0,0,2,1,0,0,0,0,0,0,0};
static DWORD counter;

#define FVF_COLORVERTEX (D3DFVF_VERTEX | D3DFVF_DIFFUSE | D3DFVF_SPECULAR)
Expand Down

0 comments on commit 9b16ac2

Please sign in to comment.