mirror of https://github.com/OpenTTD/OpenTTD
(svn r7466) -Cleanup: [win32] Coding style, indentation, variable localization.
parent
db96bd4b1b
commit
2158acb1ae
52
win32.c
52
win32.c
|
@ -129,22 +129,19 @@ static uint32 CalcCRC(byte *data, uint size, uint32 crc) {
|
|||
|
||||
static void GetFileInfo(DebugFileInfo *dfi, const TCHAR *filename)
|
||||
{
|
||||
HANDLE file;
|
||||
memset(dfi, 0, sizeof(dfi));
|
||||
|
||||
{
|
||||
HANDLE file;
|
||||
file = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
|
||||
if (file != INVALID_HANDLE_VALUE) {
|
||||
byte buffer[1024];
|
||||
DWORD numread;
|
||||
uint32 filesize = 0;
|
||||
FILETIME write_time;
|
||||
uint32 crc = (uint32)-1;
|
||||
|
||||
file = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL,
|
||||
OPEN_EXISTING, 0, 0);
|
||||
if (file != INVALID_HANDLE_VALUE) {
|
||||
for (;;) {
|
||||
if (ReadFile(file, buffer, sizeof(buffer), &numread, NULL) == 0 ||
|
||||
numread == 0)
|
||||
if (ReadFile(file, buffer, sizeof(buffer), &numread, NULL) == 0 || numread == 0)
|
||||
break;
|
||||
filesize += numread;
|
||||
crc = CalcCRC(buffer, numread, crc);
|
||||
|
@ -158,7 +155,6 @@ static void GetFileInfo(DebugFileInfo *dfi, const TCHAR *filename)
|
|||
CloseHandle(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static char *PrintModuleInfo(char *output, HMODULE mod)
|
||||
|
@ -186,22 +182,21 @@ static char *PrintModuleInfo(char *output, HMODULE mod)
|
|||
static char *PrintModuleList(char *output)
|
||||
{
|
||||
BOOL (WINAPI *EnumProcessModules)(HANDLE, HMODULE*, DWORD, LPDWORD);
|
||||
HANDLE proc;
|
||||
|
||||
if (LoadLibraryList((Function*)&EnumProcessModules, "psapi.dll\0EnumProcessModules\0\0")) {
|
||||
HMODULE modules[100];
|
||||
DWORD needed;
|
||||
BOOL res;
|
||||
int count, i;
|
||||
|
||||
if (LoadLibraryList((Function*)&EnumProcessModules, "psapi.dll\0EnumProcessModules\0\0")) {
|
||||
proc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, GetCurrentProcessId());
|
||||
if (proc) {
|
||||
HANDLE proc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, GetCurrentProcessId());
|
||||
if (proc != NULL) {
|
||||
res = EnumProcessModules(proc, modules, sizeof(modules), &needed);
|
||||
CloseHandle(proc);
|
||||
if (res) {
|
||||
count =
|
||||
min(needed / sizeof(HMODULE), lengthof(modules));
|
||||
for (i = 0; i != count; i++)
|
||||
output = PrintModuleInfo(output, modules[i]);
|
||||
count = min(needed / sizeof(HMODULE), lengthof(modules));
|
||||
|
||||
for (i = 0; i != count; i++) output = PrintModuleInfo(output, modules[i]);
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
@ -257,7 +252,6 @@ static const char wininet_files[] =
|
|||
|
||||
static WinInetProcs _wininet;
|
||||
|
||||
|
||||
static const TCHAR *SubmitCrashReport(HWND wnd, void *msg, size_t msglen, const TCHAR *arg)
|
||||
{
|
||||
HINTERNET inet, conn, http;
|
||||
|
@ -378,17 +372,16 @@ static INT_PTR CALLBACK CrashDialogFunc(HWND wnd,UINT msg,WPARAM wParam,LPARAM l
|
|||
} return TRUE;
|
||||
case WM_COMMAND:
|
||||
switch (wParam) {
|
||||
case 12: // Close
|
||||
case 12: /* Close */
|
||||
ExitProcess(0);
|
||||
case 13: { // Emergency save
|
||||
case 13: /* Emergency save */
|
||||
if (DoEmergencySave(wnd)) {
|
||||
MessageBox(wnd, _save_succeeded, _T("Save successful"), MB_ICONINFORMATION);
|
||||
} else {
|
||||
MessageBox(wnd, _T("Save failed"), _T("Save failed"), MB_ICONINFORMATION);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 14: { // Submit crash report
|
||||
case 14: { /* Submit crash report */
|
||||
const TCHAR *s;
|
||||
|
||||
SetCursor(LoadCursor(NULL, IDC_WAIT));
|
||||
|
@ -411,16 +404,14 @@ static INT_PTR CALLBACK CrashDialogFunc(HWND wnd,UINT msg,WPARAM wParam,LPARAM l
|
|||
EnableWindow(GetDlgItem(wnd, 14), FALSE);
|
||||
SetCursor(LoadCursor(NULL, IDC_ARROW));
|
||||
MessageBox(wnd, _T("Crash report submitted. Thank you."), _T("Crash Report"), MB_ICONINFORMATION);
|
||||
break;
|
||||
}
|
||||
case 15: // Expand
|
||||
} break;
|
||||
case 15: /* Expand window to show crash-message */
|
||||
_expanded ^= 1;
|
||||
SetWndSize(wnd, _expanded);
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
case WM_CLOSE:
|
||||
ExitProcess(0);
|
||||
case WM_CLOSE: ExitProcess(0);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
@ -775,12 +766,10 @@ static int ParseCommandLine(char *line, char **argv, int max_argc)
|
|||
|
||||
do {
|
||||
// skip whitespace
|
||||
while (*line == ' ' || *line == '\t')
|
||||
line++;
|
||||
while (*line == ' ' || *line == '\t') line++;
|
||||
|
||||
// end?
|
||||
if (*line == '\0')
|
||||
break;
|
||||
if (*line == '\0') break;
|
||||
|
||||
// special handling when quoted
|
||||
if (*line == '"') {
|
||||
|
@ -808,7 +797,6 @@ void CreateConsole(void)
|
|||
CONSOLE_SCREEN_BUFFER_INFO coninfo;
|
||||
|
||||
if (_has_console) return;
|
||||
|
||||
_has_console = true;
|
||||
|
||||
AllocConsole();
|
||||
|
@ -883,7 +871,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
|||
|
||||
_set_error_mode(_OUT_TO_MSGBOX); // force assertion output to messagebox
|
||||
|
||||
// setup random seed to something quite random
|
||||
/* setup random seed to something quite random */
|
||||
_random_seeds[1][0] = _random_seeds[0][0] = GetTickCount();
|
||||
_random_seeds[1][1] = _random_seeds[0][1] = _random_seeds[0][0] * 0x1234567;
|
||||
SeedMT(_random_seeds[0][0]);
|
||||
|
|
Loading…
Reference in New Issue