mirror of https://github.com/OpenTTD/OpenTTD
(svn r2697) Make compiling with SDL on Windows work again (missing #includes) and fix some warnings
parent
23c20173b1
commit
475d7fc0ae
4
sdl.c
4
sdl.c
|
@ -17,7 +17,7 @@ static int _sdl_usage;
|
||||||
|
|
||||||
#ifdef DYNAMICALLY_LOADED_SDL
|
#ifdef DYNAMICALLY_LOADED_SDL
|
||||||
|
|
||||||
bool LoadLibraryList(void **proc, const char *dll);
|
#include "win32.h"
|
||||||
|
|
||||||
#define M(x) x "\0"
|
#define M(x) x "\0"
|
||||||
static const char sdl_files[] =
|
static const char sdl_files[] =
|
||||||
|
@ -59,7 +59,7 @@ static const char *LoadSdlDLL(void)
|
||||||
{
|
{
|
||||||
if (sdl_proc.SDL_Init != NULL)
|
if (sdl_proc.SDL_Init != NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!LoadLibraryList((void**)&sdl_proc, sdl_files))
|
if (!LoadLibraryList((Function*)&sdl_proc, sdl_files))
|
||||||
return "Unable to load sdl.dll";
|
return "Unable to load sdl.dll";
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
36
win32.c
36
win32.c
|
@ -14,6 +14,7 @@
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include "variables.h"
|
#include "variables.h"
|
||||||
|
#include "win32.h"
|
||||||
|
|
||||||
#include "driver.h"
|
#include "driver.h"
|
||||||
|
|
||||||
|
@ -22,10 +23,12 @@
|
||||||
#include "music/win32_m.h"
|
#include "music/win32_m.h"
|
||||||
|
|
||||||
#include "sound/null_s.h"
|
#include "sound/null_s.h"
|
||||||
|
#include "sound/sdl_s.h"
|
||||||
#include "sound/win32_s.h"
|
#include "sound/win32_s.h"
|
||||||
|
|
||||||
#include "video/dedicated_v.h"
|
#include "video/dedicated_v.h"
|
||||||
#include "video/null_v.h"
|
#include "video/null_v.h"
|
||||||
|
#include "video/sdl_v.h"
|
||||||
#include "video/win32_v.h"
|
#include "video/win32_v.h"
|
||||||
|
|
||||||
static bool _has_console;
|
static bool _has_console;
|
||||||
|
@ -36,23 +39,20 @@ static bool _has_console;
|
||||||
|
|
||||||
|
|
||||||
// Helper function needed by dynamically loading SDL
|
// Helper function needed by dynamically loading SDL
|
||||||
bool LoadLibraryList(void **proc, const char *dll)
|
bool LoadLibraryList(Function proc[], const char* dll)
|
||||||
{
|
{
|
||||||
HMODULE lib;
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
while (*dll != '\0') {
|
while (*dll != '\0') {
|
||||||
lib = LoadLibrary(dll);
|
HMODULE lib = LoadLibrary(dll);
|
||||||
if (lib == NULL)
|
|
||||||
return false;
|
if (lib == NULL) return false;
|
||||||
while (true) {
|
while (true) {
|
||||||
while(*dll++ != '\0');
|
FARPROC p;
|
||||||
if (*dll == '\0')
|
|
||||||
break;
|
while (*dll++ != '\0');
|
||||||
|
if (*dll == '\0') break;
|
||||||
p = GetProcAddress(lib, dll);
|
p = GetProcAddress(lib, dll);
|
||||||
if (p == NULL)
|
if (p == NULL) return false;
|
||||||
return false;
|
*proc++ = (Function)p;
|
||||||
*proc++ = p;
|
|
||||||
}
|
}
|
||||||
dll++;
|
dll++;
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,7 @@ static char *PrintModuleList(char *output)
|
||||||
BOOL res;
|
BOOL res;
|
||||||
int count,i;
|
int count,i;
|
||||||
|
|
||||||
if (LoadLibraryList((void*)&EnumProcessModules, "psapi.dll\0EnumProcessModules\0")) {
|
if (LoadLibraryList((Function*)&EnumProcessModules, "psapi.dll\0EnumProcessModules\0")) {
|
||||||
proc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, GetCurrentProcessId());
|
proc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, GetCurrentProcessId());
|
||||||
if (proc) {
|
if (proc) {
|
||||||
res = EnumProcessModules(proc, modules, sizeof(modules), &needed);
|
res = EnumProcessModules(proc, modules, sizeof(modules), &needed);
|
||||||
|
@ -241,15 +241,15 @@ static const char wininet_files[] =
|
||||||
static WinInetProcs _wininet;
|
static WinInetProcs _wininet;
|
||||||
|
|
||||||
|
|
||||||
static char *SubmitCrashReport(HWND wnd, void *msg, size_t msglen, const char *arg)
|
static const char *SubmitCrashReport(HWND wnd, void *msg, size_t msglen, const char *arg)
|
||||||
{
|
{
|
||||||
HINTERNET inet, conn, http;
|
HINTERNET inet, conn, http;
|
||||||
char *err = NULL;
|
const char *err = NULL;
|
||||||
DWORD code, len;
|
DWORD code, len;
|
||||||
static char buf[100];
|
static char buf[100];
|
||||||
char buff[100];
|
char buff[100];
|
||||||
|
|
||||||
if (_wininet.InternetOpen == NULL && !LoadLibraryList((void**)&_wininet, wininet_files)) return "can't load wininet.dll";
|
if (_wininet.InternetOpen == NULL && !LoadLibraryList((Function*)&_wininet, wininet_files)) return "can't load wininet.dll";
|
||||||
|
|
||||||
inet = _wininet.InternetOpen("OTTD", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 );
|
inet = _wininet.InternetOpen("OTTD", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 );
|
||||||
if (inet == NULL) { err = "internetopen failed"; goto error1; }
|
if (inet == NULL) { err = "internetopen failed"; goto error1; }
|
||||||
|
@ -368,7 +368,7 @@ static BOOL CALLBACK CrashDialogFunc(HWND wnd,UINT msg,WPARAM wParam,LPARAM lPar
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 14: { // Submit crash report
|
case 14: { // Submit crash report
|
||||||
char *s;
|
const char *s;
|
||||||
|
|
||||||
SetCursor(LoadCursor(NULL, IDC_WAIT));
|
SetCursor(LoadCursor(NULL, IDC_WAIT));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue