OpenTTD Source 20260206-master-g4d4e37dbf1
unix_main.cpp
Go to the documentation of this file.
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
9
10#include "../../stdafx.h"
11#include "../../openttd.h"
12#include "../../crashlog.h"
14#include "../../string_func.h"
15
16#include <time.h>
17#include <signal.h>
18
19#include "../../safeguards.h"
20
21int CDECL main(int argc, char *argv[])
22{
23 /* Make sure our arguments contain only valid UTF-8 characters. */
24 std::vector<std::string_view> params;
25 for (int i = 0; i < argc; ++i) {
26 StrMakeValidInPlace(argv[i]);
27 params.emplace_back(argv[i]);
28 }
29
31
32 SetRandomSeed(time(nullptr));
33
34 signal(SIGPIPE, SIG_IGN);
35
36 return openttd_main(params);
37}
static void InitialiseCrashLog()
Initialiser for crash logs; do the appropriate things so crashes are handled by our crash handler ins...
Functions to be called to log a crash.
int openttd_main(std::span< std::string_view > arguments)
Main entry point for this lovely game.
Definition openttd.cpp:500
Some generic types.
void SetRandomSeed(uint32_t seed)
(Re)set the state of the random number generators.
Pseudo random number generator.
A number of safeguards to prevent using unsafe methods.
Definition of base types and functions in a cross-platform compatible way.
void StrMakeValidInPlace(char *str, StringValidationSettings settings)
Scans the string for invalid characters and replaces them with a question mark '?
Definition string.cpp:157
Functions related to low-level strings.