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 "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 207 of file ClonkMain.cpp.

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

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

Here is the call graph for this function: