mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-12 00:56:40 -04:00
Windows: Less warnings when compiling
This commit is contained in:
parent
9cc6ae25da
commit
5f96ca2eac
@ -2369,6 +2369,7 @@ static void RegisterDefaultModels(void) {
|
|||||||
HumanoidModel_Register();
|
HumanoidModel_Register();
|
||||||
MakeModel(&human_model);
|
MakeModel(&human_model);
|
||||||
Models.Human = &human_model;
|
Models.Human = &human_model;
|
||||||
|
BlockModel_Register();
|
||||||
|
|
||||||
ChickenModel_Register();
|
ChickenModel_Register();
|
||||||
CreeperModel_Register();
|
CreeperModel_Register();
|
||||||
@ -2379,7 +2380,6 @@ static void RegisterDefaultModels(void) {
|
|||||||
SpiderModel_Register();
|
SpiderModel_Register();
|
||||||
ZombieModel_Register();
|
ZombieModel_Register();
|
||||||
|
|
||||||
BlockModel_Register();
|
|
||||||
ChibiModel_Register();
|
ChibiModel_Register();
|
||||||
HeadModel_Register();
|
HeadModel_Register();
|
||||||
SittingModel_Register();
|
SittingModel_Register();
|
||||||
|
@ -663,16 +663,20 @@ static cc_result Process_RawGetExePath(cc_winstring* path, int* len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cc_result Process_StartGame2(const cc_string* args, int numArgs) {
|
cc_result Process_StartGame2(const cc_string* args, int numArgs) {
|
||||||
|
union STARTUPINFO_union {
|
||||||
|
STARTUPINFOW wide;
|
||||||
|
STARTUPINFOA ansi;
|
||||||
|
} si = { 0 }; // less compiler warnings this way
|
||||||
|
|
||||||
cc_winstring path;
|
cc_winstring path;
|
||||||
cc_string argv; char argvBuffer[NATIVE_STR_LEN];
|
cc_string argv; char argvBuffer[NATIVE_STR_LEN];
|
||||||
STARTUPINFOW si = { 0 };
|
|
||||||
PROCESS_INFORMATION pi = { 0 };
|
PROCESS_INFORMATION pi = { 0 };
|
||||||
cc_winstring raw;
|
cc_winstring raw;
|
||||||
cc_result res;
|
cc_result res;
|
||||||
int len, i;
|
int len, i;
|
||||||
|
|
||||||
if ((res = Process_RawGetExePath(&path, &len))) return res;
|
if ((res = Process_RawGetExePath(&path, &len))) return res;
|
||||||
si.cb = sizeof(STARTUPINFOW);
|
si.wide.cb = sizeof(STARTUPINFOW);
|
||||||
|
|
||||||
String_InitArray(argv, argvBuffer);
|
String_InitArray(argv, argvBuffer);
|
||||||
/* Game doesn't actually care about argv[0] */
|
/* Game doesn't actually care about argv[0] */
|
||||||
@ -689,11 +693,11 @@ cc_result Process_StartGame2(const cc_string* args, int numArgs) {
|
|||||||
|
|
||||||
if (path.uni[0]) {
|
if (path.uni[0]) {
|
||||||
if (!CreateProcessW(path.uni, raw.uni, NULL, NULL,
|
if (!CreateProcessW(path.uni, raw.uni, NULL, NULL,
|
||||||
false, 0, NULL, NULL, &si, &pi)) return GetLastError();
|
false, 0, NULL, NULL, &si.wide, &pi)) return GetLastError();
|
||||||
} else {
|
} else {
|
||||||
/* Windows 9x does not support W API functions */
|
/* Windows 9x does not support W API functions */
|
||||||
if (!CreateProcessA(path.ansi, raw.ansi, NULL, NULL,
|
if (!CreateProcessA(path.ansi, raw.ansi, NULL, NULL,
|
||||||
false, 0, NULL, NULL, &si, &pi)) return GetLastError();
|
false, 0, NULL, NULL, &si.ansi, &pi)) return GetLastError();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Don't leak memory for process return code */
|
/* Don't leak memory for process return code */
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#define NOSERVICE
|
#define NOSERVICE
|
||||||
#define NOMCX
|
#define NOMCX
|
||||||
#define NOIME
|
#define NOIME
|
||||||
|
#define NOMINMAX
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#define SECURITY_WIN32
|
#define SECURITY_WIN32
|
||||||
#include <sspi.h>
|
#include <sspi.h>
|
||||||
|
@ -558,9 +558,13 @@ static void ShowDialogCore(const char* title, const char* msg) {
|
|||||||
|
|
||||||
static cc_result OpenSaveFileDialog(const cc_string* filters, FileDialogCallback callback, cc_bool load,
|
static cc_result OpenSaveFileDialog(const cc_string* filters, FileDialogCallback callback, cc_bool load,
|
||||||
const char* const* fileExts, const cc_string* defaultName) {
|
const char* const* fileExts, const cc_string* defaultName) {
|
||||||
|
union OPENFILENAME_union {
|
||||||
|
OPENFILENAMEW wide;
|
||||||
|
OPENFILENAMEA ansi;
|
||||||
|
} ofn = { 0 }; // less compiler warnings this way
|
||||||
|
|
||||||
cc_string path; char pathBuffer[NATIVE_STR_LEN];
|
cc_string path; char pathBuffer[NATIVE_STR_LEN];
|
||||||
cc_winstring str = { 0 };
|
cc_winstring str = { 0 };
|
||||||
OPENFILENAMEW ofn = { 0 };
|
|
||||||
cc_winstring filter;
|
cc_winstring filter;
|
||||||
cc_result res;
|
cc_result res;
|
||||||
BOOL ok;
|
BOOL ok;
|
||||||
@ -571,35 +575,37 @@ static cc_result OpenSaveFileDialog(const cc_string* filters, FileDialogCallback
|
|||||||
/* NOTE: OPENFILENAME_SIZE_VERSION_400 is used instead of sizeof(OFN), because the size of */
|
/* NOTE: OPENFILENAME_SIZE_VERSION_400 is used instead of sizeof(OFN), because the size of */
|
||||||
/* OPENFILENAME increased after Windows 9x/NT4 with the addition of pvReserved and later fields */
|
/* OPENFILENAME increased after Windows 9x/NT4 with the addition of pvReserved and later fields */
|
||||||
/* (and Windows 9x/NT4 return an error if a lStructSize > OPENFILENAME_SIZE_VERSION_400 is used) */
|
/* (and Windows 9x/NT4 return an error if a lStructSize > OPENFILENAME_SIZE_VERSION_400 is used) */
|
||||||
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
|
ofn.wide.lStructSize = OPENFILENAME_SIZE_VERSION_400;
|
||||||
/* also note that this only works when you *don't* have OFN_HOOK in Flags - if you do, then */
|
/* also note that this only works when you *don't* have OFN_HOOK in Flags - if you do, then */
|
||||||
/* on modern Windows versions the dialogs are altered to show an old Win 9x style appearance */
|
/* on modern Windows versions the dialogs are altered to show an old Win 9x style appearance */
|
||||||
/* (see https://github.com/geany/geany/issues/578 for example of this problem) */
|
/* (see https://github.com/geany/geany/issues/578 for example of this problem) */
|
||||||
|
|
||||||
ofn.hwndOwner = win_handle;
|
ofn.wide.hwndOwner = win_handle;
|
||||||
ofn.lpstrFile = str.uni;
|
ofn.wide.lpstrFile = str.uni;
|
||||||
ofn.nMaxFile = MAX_PATH;
|
ofn.wide.nMaxFile = MAX_PATH;
|
||||||
ofn.lpstrFilter = filter.uni;
|
ofn.wide.lpstrFilter = filter.uni;
|
||||||
ofn.nFilterIndex = 1;
|
ofn.wide.nFilterIndex = 1;
|
||||||
ofn.Flags = OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST | (load ? OFN_FILEMUSTEXIST : OFN_OVERWRITEPROMPT);
|
ofn.wide.Flags = OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST | (load ? OFN_FILEMUSTEXIST : OFN_OVERWRITEPROMPT);
|
||||||
|
|
||||||
String_InitArray(path, pathBuffer);
|
String_InitArray(path, pathBuffer);
|
||||||
ok = load ? GetOpenFileNameW(&ofn) : GetSaveFileNameW(&ofn);
|
ok = load ? GetOpenFileNameW(&ofn.wide) : GetSaveFileNameW(&ofn.wide);
|
||||||
|
|
||||||
if (ok) {
|
if (ok) {
|
||||||
/* Successfully got a unicode filesystem path */
|
/* Successfully got a unicode filesystem path */
|
||||||
for (i = 0; i < MAX_PATH && str.uni[i]; i++) {
|
for (i = 0; i < MAX_PATH && str.uni[i]; i++)
|
||||||
|
{
|
||||||
String_Append(&path, Convert_CodepointToCP437(str.uni[i]));
|
String_Append(&path, Convert_CodepointToCP437(str.uni[i]));
|
||||||
}
|
}
|
||||||
} else if ((res = CommDlgExtendedError()) == 2) {
|
} else if ((res = CommDlgExtendedError()) == 2) {
|
||||||
/* CDERR_INITIALIZATION - probably running on Windows 9x */
|
/* CDERR_INITIALIZATION - probably running on Windows 9x */
|
||||||
ofn.lpstrFile = str.ansi;
|
ofn.ansi.lpstrFile = str.ansi;
|
||||||
ofn.lpstrFilter = filter.ansi;
|
ofn.ansi.lpstrFilter = filter.ansi;
|
||||||
|
|
||||||
ok = load ? GetOpenFileNameA(&ofn) : GetSaveFileNameA(&ofn);
|
ok = load ? GetOpenFileNameA(&ofn.ansi) : GetSaveFileNameA(&ofn.ansi);
|
||||||
if (!ok) return CommDlgExtendedError();
|
if (!ok) return CommDlgExtendedError();
|
||||||
|
|
||||||
for (i = 0; i < MAX_PATH && str.ansi[i]; i++) {
|
for (i = 0; i < MAX_PATH && str.ansi[i]; i++)
|
||||||
|
{
|
||||||
String_Append(&path, str.ansi[i]);
|
String_Append(&path, str.ansi[i]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -607,8 +613,8 @@ static cc_result OpenSaveFileDialog(const cc_string* filters, FileDialogCallback
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Add default file extension if user didn't provide one */
|
/* Add default file extension if user didn't provide one */
|
||||||
if (!load && ofn.nFileExtension == 0 && ofn.nFilterIndex > 0) {
|
if (!load && ofn.wide.nFileExtension == 0 && ofn.wide.nFilterIndex > 0) {
|
||||||
String_AppendConst(&path, fileExts[ofn.nFilterIndex - 1]);
|
String_AppendConst(&path, fileExts[ofn.wide.nFilterIndex - 1]);
|
||||||
}
|
}
|
||||||
callback(&path);
|
callback(&path);
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user