OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
ClonkMain.cpp File Reference
#include "C4Include.h"
#include "game/C4Application.h"
#include "lib/C4Log.h"
#include "game/C4Game.h"
#include "C4Version.h"
#include "network/C4Network2.h"
#include <unistd.h>
#include <fcntl.h>
Include dependency graph for ClonkMain.cpp:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 209 of file ClonkMain.cpp.

References Application, C4XRV_Aborted, C4XRV_Completed, C4XRV_Failure, C4Application::Clear(), Game, C4Game::GameOver, C4AbstractApp::Init(), C4Application::restartAtEnd, and C4AbstractApp::Run().

210 {
211  if (!geteuid())
212  {
213  printf("Do not run %s as root!\n", argc ? argv[0] : "this program");
214  return C4XRV_Failure;
215  }
216 #ifdef HAVE_BACKWARD
217  backward::SignalHandling sh;
218 #elif defined(HAVE_SIGNAL_H)
219  struct sigaction sa;
220  sa.sa_sigaction = crash_handler;
221  sigemptyset(&sa.sa_mask);
222  sa.sa_flags = SA_SIGINFO;
223  // Quit the program when asked
224  sigaction(SIGINT, &sa, nullptr);
225  sigaction(SIGTERM, &sa, nullptr);
226  sigaction(SIGHUP, &sa, nullptr);
227  // Set up debugging facilities
228  sa.sa_flags |= SA_RESETHAND;
229  sigaction(SIGBUS, &sa, nullptr);
230  sigaction(SIGILL, &sa, nullptr);
231  sigaction(SIGSEGV, &sa, nullptr);
232  sigaction(SIGABRT, &sa, nullptr);
233  sigaction(SIGFPE, &sa, nullptr);
234 #endif
235 
236  // Init application
237  if (!Application.Init(argc, argv))
238  {
239  Application.Clear();
240  return C4XRV_Failure;
241  }
242  // Execute application
243  Application.Run();
244  // free app stuff
245  Application.Clear();
246  if (Application.restartAtEnd) restart(argv);
247  // Return exit code
248  if (!Game.GameOver) return C4XRV_Aborted;
249  return C4XRV_Completed;
250 }
C4Game Game
Definition: C4Globals.cpp:52
bool GameOver
Definition: C4Game.h:116
const int C4XRV_Failure
Definition: C4Constants.h:71
void Run()
Definition: C4App.cpp:26
const int C4XRV_Aborted
Definition: C4Constants.h:72
bool Init(int argc, char *argv[])
Definition: C4AppSDL.cpp:91
const int C4XRV_Completed
Definition: C4Constants.h:70
C4Application Application
Definition: C4Globals.cpp:44

Here is the call graph for this function: