-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c49c373
commit fceeaa4
Showing
25 changed files
with
1,215 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* This file is part of OpenTTD. | ||
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. | ||
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
/** @file unix_main.cpp Main entry for Mac OSX. */ | ||
|
||
#include "../../stdafx.h" | ||
#include "../../openttd.h" | ||
#include "../../crashlog.h" | ||
#include "../../core/random_func.hpp" | ||
#include "../../string_func.h" | ||
#include "../../thread.h" | ||
|
||
#include <time.h> | ||
#include <signal.h> | ||
|
||
#include "macos.h" | ||
|
||
#include "../../safeguards.h" | ||
|
||
void CocoaSetupAutoreleasePool(); | ||
void CocoaReleaseAutoreleasePool(); | ||
|
||
int CDECL main(int argc, char *argv[]) | ||
{ | ||
/* Make sure our arguments contain only valid UTF-8 characters. */ | ||
for (int i = 0; i < argc; i++) StrMakeValidInPlace(argv[i]); | ||
|
||
CocoaSetupAutoreleasePool(); | ||
/* This is passed if we are launched by double-clicking */ | ||
if (argc >= 2 && strncmp(argv[1], "-psn", 4) == 0) { | ||
argv[1] = nullptr; | ||
argc = 1; | ||
} | ||
|
||
PerThreadSetupInit(); | ||
CrashLog::InitialiseCrashLog(); | ||
|
||
SetRandomSeed(time(nullptr)); | ||
|
||
signal(SIGPIPE, SIG_IGN); | ||
|
||
int ret = openttd_main(argc, argv); | ||
|
||
CocoaReleaseAutoreleasePool(); | ||
|
||
return ret; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* This file is part of OpenTTD. | ||
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. | ||
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
/** @file unix_main.cpp Main entry for Unix. */ | ||
|
||
#include "../../stdafx.h" | ||
#include "../../openttd.h" | ||
#include "../../crashlog.h" | ||
#include "../../core/random_func.hpp" | ||
#include "../../string_func.h" | ||
#include "../../thread.h" | ||
|
||
#include <time.h> | ||
#include <signal.h> | ||
|
||
#include "../../safeguards.h" | ||
|
||
int CDECL main(int argc, char *argv[]) | ||
{ | ||
/* Make sure our arguments contain only valid UTF-8 characters. */ | ||
for (int i = 0; i < argc; i++) StrMakeValidInPlace(argv[i]); | ||
|
||
PerThreadSetupInit(); | ||
CrashLog::InitialiseCrashLog(); | ||
|
||
SetRandomSeed(time(nullptr)); | ||
|
||
signal(SIGPIPE, SIG_IGN); | ||
|
||
return openttd_main(argc, argv); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* This file is part of OpenTTD. | ||
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. | ||
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
/** @file win32_main.cpp Implementation main for Windows. */ | ||
|
||
#include "../../stdafx.h" | ||
#include <windows.h> | ||
#include <mmsystem.h> | ||
#include "../../openttd.h" | ||
#include "../../core/random_func.hpp" | ||
#include "../../string_func.h" | ||
#include "../../crashlog.h" | ||
#include "../../debug.h" | ||
#include "../../thread.h" | ||
|
||
#include "../../safeguards.h" | ||
|
||
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(); | ||
|
||
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); | ||
|
||
PerThreadSetupInit(); | ||
CrashLog::InitialiseCrashLog(); | ||
|
||
/* Convert the command line to UTF-8. */ | ||
std::string cmdline = FS2OTTD(GetCommandLine()); | ||
|
||
/* 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.data(), 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); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.