Codechange: move main function(s) to separate files
This commit is contained in:
@@ -22,10 +22,7 @@
|
||||
#include "win32.h"
|
||||
#include "../../fios.h"
|
||||
#include "../../core/alloc_func.hpp"
|
||||
#include "../../openttd.h"
|
||||
#include "../../core/random_func.hpp"
|
||||
#include "../../string_func.h"
|
||||
#include "../../crashlog.h"
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
#include "../../language.h"
|
||||
@@ -229,37 +226,6 @@ bool FiosGetDiskFreeSpace(const char *path, uint64 *tot)
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int ParseCommandLine(char *line, char **argv, int max_argc)
|
||||
{
|
||||
int n = 0;
|
||||
|
||||
do {
|
||||
/* skip whitespace */
|
||||
while (*line == ' ' || *line == '\t') line++;
|
||||
|
||||
/* end? */
|
||||
if (*line == '\0') break;
|
||||
|
||||
/* special handling when quoted */
|
||||
if (*line == '"') {
|
||||
argv[n++] = ++line;
|
||||
while (*line != '"') {
|
||||
if (*line == '\0') return n;
|
||||
line++;
|
||||
}
|
||||
} else {
|
||||
argv[n++] = line;
|
||||
while (*line != ' ' && *line != '\t') {
|
||||
if (*line == '\0') return n;
|
||||
line++;
|
||||
}
|
||||
}
|
||||
*line++ = '\0';
|
||||
} while (n != max_argc);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
void CreateConsole()
|
||||
{
|
||||
HANDLE hand;
|
||||
@@ -378,47 +344,6 @@ void ShowInfo(const char *str)
|
||||
}
|
||||
}
|
||||
|
||||
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
|
||||
{
|
||||
int argc;
|
||||
char *argv[64]; // max 64 command line arguments
|
||||
|
||||
/* Set system timer resolution to 1ms. */
|
||||
timeBeginPeriod(1);
|
||||
|
||||
CrashLog::InitialiseCrashLog();
|
||||
|
||||
/* Convert the command line to UTF-8. We need a dedicated buffer
|
||||
* for this because argv[] points into this buffer and this needs to
|
||||
* be available between subsequent calls to FS2OTTD(). */
|
||||
char *cmdline = stredup(FS2OTTD(GetCommandLine()).c_str());
|
||||
|
||||
/* Set the console codepage to UTF-8. */
|
||||
SetConsoleOutputCP(CP_UTF8);
|
||||
|
||||
#if defined(_DEBUG)
|
||||
CreateConsole();
|
||||
#endif
|
||||
|
||||
_set_error_mode(_OUT_TO_MSGBOX); // force assertion output to messagebox
|
||||
|
||||
/* setup random seed to something quite random */
|
||||
SetRandomSeed(GetTickCount());
|
||||
|
||||
argc = ParseCommandLine(cmdline, argv, lengthof(argv));
|
||||
|
||||
/* Make sure our arguments contain only valid UTF-8 characters. */
|
||||
for (int i = 0; i < argc; i++) StrMakeValidInPlace(argv[i]);
|
||||
|
||||
openttd_main(argc, argv);
|
||||
|
||||
/* Restore system timer resolution. */
|
||||
timeEndPeriod(1);
|
||||
|
||||
free(cmdline);
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *getcwd(char *buf, size_t size)
|
||||
{
|
||||
wchar_t path[MAX_PATH];
|
||||
|
Reference in New Issue
Block a user