OpenTTD Source  14.0-beta3
osx_main.cpp
1 /*
2  * This file is part of OpenTTD.
3  * 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.
4  * 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.
5  * 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/>.
6  */
7 
10 #include "../../stdafx.h"
11 #include "../../openttd.h"
12 #include "../../crashlog.h"
13 #include "../../core/random_func.hpp"
14 #include "../../string_func.h"
15 
16 #include <time.h>
17 #include <signal.h>
18 
19 #include "macos.h"
20 
21 #include "../../safeguards.h"
22 
23 void CocoaSetupAutoreleasePool();
24 void CocoaReleaseAutoreleasePool();
25 
26 int CDECL main(int argc, char *argv[])
27 {
28  /* Make sure our arguments contain only valid UTF-8 characters. */
29  for (int i = 0; i < argc; i++) StrMakeValidInPlace(argv[i]);
30 
31  CocoaSetupAutoreleasePool();
32  /* This is passed if we are launched by double-clicking */
33  if (argc >= 2 && strncmp(argv[1], "-psn", 4) == 0) {
34  argv[1] = nullptr;
35  argc = 1;
36  }
37 
39 
40  SetRandomSeed(time(nullptr));
41 
42  signal(SIGPIPE, SIG_IGN);
43 
44  int ret = openttd_main(argc, argv);
45 
46  CocoaReleaseAutoreleasePool();
47 
48  return ret;
49 }
openttd_main
int openttd_main(int argc, char *argv[])
Main entry point for this lovely game.
Definition: openttd.cpp:518
StrMakeValidInPlace
void StrMakeValidInPlace(char *str, const char *last, StringValidationSettings settings)
Scans the string for invalid characters and replaces then with a question mark '?' (if not ignored).
Definition: string.cpp:185
SetRandomSeed
void SetRandomSeed(uint32_t seed)
(Re)set the state of the random number generators.
Definition: random_func.cpp:77
CrashLog::InitialiseCrashLog
static void InitialiseCrashLog()
Initialiser for crash logs; do the appropriate things so crashes are handled by our crash handler ins...
Definition: crashlog_osx.cpp:233
main
int CDECL main(int argc, char *argv[])
And the main program (what else?)
Definition: settingsgen.cpp:433
macos.h