UFO: Alien Invasion
Loading...
Searching...
No Matches
android_system.cpp
Go to the documentation of this file.
1
5
6/*
7Copyright (C) 2002-2025 UFO: Alien Invasion.
8
9This program is free software; you can redistribute it and/or
10modify it under the terms of the GNU General Public License
11as published by the Free Software Foundation; either version 2
12of the License, or (at your option) any later version.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
18See the GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
24*/
25
26#include <unistd.h>
27#include <sys/time.h>
28#include <stdlib.h>
29#include <sys/stat.h>
30#include <sys/types.h>
31#include <pwd.h>
32#include <dlfcn.h>
33#include <fcntl.h>
34#include <locale.h>
35#include <signal.h>
36#include <dirent.h>
37
38#include "../../common/common.h"
39#include "../system.h"
40
41#include <android/log.h>
43
44const char *Sys_GetCurrentUser (void)
45{
46 char * user = getenv("USER");
47 if (user)
48 return user;
49 return "Player";
50}
51
57void Sys_Error (const char *error, ...)
58{
59 va_list argptr;
60 char string[1024];
61
63
64#ifdef COMPILE_UFO
67#endif
68
69#ifdef COMPILE_MAP
71#endif
72
73 va_start(argptr,error);
74 Q_vsnprintf(string, sizeof(string), error, argptr);
75 va_end(argptr);
76
77 __android_log_print(ANDROID_LOG_FATAL, "UFOAI", "Error: %s", string);
78
79 exit(1);
80}
81
86void Sys_Quit (void)
87{
88#ifdef COMPILE_UFO
92#elif COMPILE_MAP
94#endif
95
96 exit(0);
97}
98
102void Sys_Backtrace (void)
103{
104#ifdef COMPILE_UFO
106#endif
107
108 const char *dumpFile = "crashdump.txt";
109 FILE *file = Sys_Fopen(dumpFile, "w");
110 FILE *crash = file != nullptr ? file : stderr;
111
112 fprintf(crash, "======start======\n");
113
114 fprintf(crash, BUILDSTRING ", cpu: " CPUSTRING ", version: " UFO_VERSION "\n\n");
115 fflush(crash);
116
118
119 fprintf(crash, "======end========\n");
120
121 if (file != nullptr)
122 fclose(file);
123}
void Sys_ConsoleShutdown(void)
void androidDumpBacktrace(FILE *out)
void Sys_Backtrace(void)
On platforms supporting it, print a backtrace.
void Sys_Error(const char *error,...)
Errors out of the game.
void Sys_Quit(void)
const char * Sys_GetCurrentUser(void)
void CL_Shutdown(void)
Saves configuration file and shuts the client systems down.
Definition cl_main.cpp:1219
void Com_BreakIntoDebugger(void)
Definition common.cpp:512
void Qcommon_Shutdown(void)
Definition common.cpp:1555
definitions common between client and server, but not game lib
#define CPUSTRING
Definition common.h:109
#define UFO_VERSION
Definition common.h:36
#define BUILDSTRING
Definition common.h:121
void Mem_Shutdown(void)
Definition mem.cpp:518
int Q_vsnprintf(char *str, size_t size, const char *format, va_list ap)
Safe (null terminating) vsnprintf implementation.
Definition shared.cpp:535
System specific stuff.
FILE * Sys_Fopen(const char *filename, const char *mode)
#define FILE
static const char * user