OpenTTD Source: src/os/macosx/osx_main.cpp Source File

OpenTTD Source 15.0-RC2

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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
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
23void CocoaSetupAutoreleasePool();
24void CocoaReleaseAutoreleasePool();
25
26int CDECL main(int argc, char *argv[])
27{
28 /* Make sure our arguments contain only valid UTF-8 characters. */
29 std::vector<std::string_view> params;
30 for (int i = 0; i < argc; ++i) {
31 StrMakeValidInPlace(argv[i]);
32 params.emplace_back(argv[i]);
33 }
34
35 CocoaSetupAutoreleasePool();
36 /* This is passed if we are launched by double-clicking */
37 if (params.size() >= 2 && params[1].starts_with("-psn")) {
38 params.resize(1);
39 }
40
41 CrashLog::InitialiseCrashLog();
42
43 SetRandomSeed(time(nullptr));
44
45 signal(SIGPIPE, SIG_IGN);
46
47 int ret = openttd_main(params);
48
49 CocoaReleaseAutoreleasePool();
50
51 return ret;
52}
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:232
macos.h
Functions related to MacOS support.
openttd_main
int openttd_main(std::span< std::string_view > arguments)
Main entry point for this lovely game.
Definition openttd.cpp:500
SetRandomSeed
void SetRandomSeed(uint32_t seed)
(Re)set the state of the random number generators.
Definition random_func.cpp:65
StrMakeValidInPlace
void StrMakeValidInPlace(char *str, StringValidationSettings settings)
Scans the string for invalid characters and replaces them with a question mark '?' (if not ignored).
Definition string.cpp:157