summaryrefslogtreecommitdiff
path: root/src/win32.cpp
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2007-08-04 12:53:41 +0000
committertruelight <truelight@openttd.org>2007-08-04 12:53:41 +0000
commit424757c078410041cce35a8678b59b7a56c47ccb (patch)
tree95e47824c2caa1c36c3ad2d37010fe7f16650f26 /src/win32.cpp
parentcb9d0c69d1fac53c479b678741f82df084b1b5ba (diff)
downloadopenttd-424757c078410041cce35a8678b59b7a56c47ccb.tar.xz
(svn r10781) -Fix: ported more pieces to WinCE, so it compiles a bit more
-Fix: WinCE doesn't support console -Fix: Set debug lvl4 when running a debug WinCE build (as you can't give parameters any easy way)
Diffstat (limited to 'src/win32.cpp')
-rw-r--r--src/win32.cpp33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/win32.cpp b/src/win32.cpp
index bcc1fda43..892f724c1 100644
--- a/src/win32.cpp
+++ b/src/win32.cpp
@@ -94,7 +94,7 @@ void ShowOSErrorBox(const char *buf)
#endif
}
-#ifdef _MSC_VER
+#if defined(_MSC_VER) && !defined(WINCE)
static void *_safe_esp;
static char *_crash_msg;
@@ -734,6 +734,14 @@ bool FiosIsRoot(const char *file)
void FiosGetDrives()
{
+#if defined(WINCE)
+ /* WinCE only knows one drive: / */
+ FiosItem *fios = FiosAlloc();
+ fios->type = FIOS_TYPE_DRIVE;
+ fios->mtime = 0;
+ snprintf(fios->name, lengthof(fios->name), PATHSEP "");
+ ttd_strlcpy(fios->title, fios->name, lengthof(fios->title));
+#else
TCHAR drives[256];
const TCHAR *s;
@@ -746,6 +754,7 @@ void FiosGetDrives()
ttd_strlcpy(fios->title, fios->name, lengthof(fios->title));
while (*s++ != '\0');
}
+#endif
}
bool FiosIsValidFile(const char *path, const struct dirent *ent, struct stat *sb)
@@ -821,6 +830,9 @@ static int ParseCommandLine(char *line, char **argv, int max_argc)
void CreateConsole()
{
+#if defined(WINCE)
+ /* WinCE doesn't support console stuff */
+#else
HANDLE hand;
CONSOLE_SCREEN_BUFFER_INFO coninfo;
@@ -849,6 +861,7 @@ void CreateConsole()
setvbuf(stdin, NULL, _IONBF, 0);
setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stderr, NULL, _IONBF, 0);
+#endif
}
void ShowInfo(const char *str)
@@ -882,7 +895,11 @@ void ShowInfo(const char *str)
int _set_error_mode(int);
#endif
+#if defined(WINCE)
+int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
+#else
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
+#endif
{
int argc;
char *argv[64]; // max 64 command line arguments
@@ -893,8 +910,11 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
#endif /* UNICODE */
#if defined(UNICODE)
+
+#if !defined(WINCE)
/* Check if a win9x user started the win32 version */
if (HASBIT(GetVersion(), 31)) error("This version of OpenTTD doesn't run on windows 95/98/ME.\nPlease download the win9x binary and try again.");
+#endif
/* For UNICODE we need to convert the commandline to char* _AND_
* save it because argv[] points into this buffer and thus needs to
@@ -908,7 +928,9 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
CreateConsole();
#endif
+#if !defined(WINCE)
_set_error_mode(_OUT_TO_MSGBOX); // force assertion output to messagebox
+#endif
/* setup random seed to something quite random */
_random_seeds[1][0] = _random_seeds[0][0] = GetTickCount();
@@ -951,7 +973,14 @@ void GetCurrentDirectoryW(int length, wchar_t *path)
char *getcwd(char *buf, size_t size)
{
-#if defined(UNICODE)
+#if defined(WINCE)
+ TCHAR path[MAX_PATH];
+ GetModuleFileName(NULL, path, MAX_PATH);
+ convert_from_fs(path, buf, size);
+ /* GetModuleFileName returns dir with file, so remove everything behind latest '\\' */
+ char *p = strrchr(buf, '\\');
+ if (p != NULL) *p = '\0';
+#elif defined(UNICODE)
TCHAR path[MAX_PATH];
GetCurrentDirectory(MAX_PATH - 1, path);
convert_from_fs(path, buf, size);