Commit graph

62 commits

Author SHA1 Message Date
Daniel Gibson
952292b4a6 POSIX: log output to save_path/dhewm3log.txt
and refactorings needed for that (I want to create the log right at the
 beginning before much else has been initialized, so using things like
 idStr or Sys_GetPath() isn't safe)

save_path being $XDG_DATA_HOME/dhewm3/ (usually ~/.local/share/dhewm3/)
on most POSIX systems, $HOME/Library/Application Support/dhewm3/ on Mac

If the log file already exists, it's renamed to dhewm3log-old.txt first,
so there's always the most recent and the last log available.
2022-01-16 06:11:20 +01:00
Felipe Woods
8e0d28374d Prevent user from running dhewm3 as root. 2021-12-16 23:08:09 +01:00
Daniel Gibson
64b21fcd0c Add Posix_GetExePath() function
I'm gonna use it with libbacktrace - I'll need the path of the
executable before I can use idStr (and thus before I could call
Sys_GetPath(PATH_EXE, str)).
2021-05-12 07:44:07 +02:00
Daniel Gibson
1320e29aaf Implement Signal-Handlers for POSIX systems, incl. SIGTTIN/SIGTTOU
handling SIGTTIN/OU allows running Doom3 in the background (or even
sending it to the background with Ctrl-Z + bg) by disabling TTY input
(before it would get stuck when run in background without +set in_tty 0,
 see #215)

While at it, I also added signal handlers for some common crash signals
(SIGILL, SIGABRT, SIGFPE, SIGSEGV) to print a backtrace before exiting
the game (partly based on Yamagi Quake II code).
2019-01-13 07:07:39 +01:00
Daniel Gibson
fa363ab5ef Fallback to demo/ should work better now
i.e. also when not starting the game with +set fs_basepath /bla/
2019-01-07 15:06:59 +01:00
Turo Lamminen
9e628e8474 Fix read from uninitialized part of buffer
According to "man 2 readlink": "readlink() does not append a null byte to buf."
I have no idea how this worked up to now.
2017-03-14 22:19:20 +01:00
Daniel Gibson
c333a46373 Linux: Fix fallback to look for gamedata in /usr/local/games/doom3/
Before checking there I look for gamedata next to the executable, but
the check was broken: I got the directory the executable is in and
checked if it exists.. well.. of course it does, but that doesn't mean
there's game data in it..
So now I check if that directory actually has a "base/" subdirectory
(or whatever is #defined in BASE_GAMEDIR) and if that fails
/usr/local/games/doom3/ is tried instead.

Thanks chungy for pointing the bug out in #97 !
2015-09-30 15:07:51 +02:00
Rohit Nirmal
c20218f9cd Minor spelling fix. 2013-07-13 23:07:22 -05:00
Daniel Gibson
6d9a43cb23 On Linux/Unix, return EXE-path as base-path if BUILD_DATADIR fails
Using this path was the old behavior and is expected by many users.
2012-11-13 23:16:03 +01:00
dhewg
90bd14564f Remove redundant setenv() call
The version which overwrites existing envvars is just below.
2012-07-06 01:41:12 +02:00
dhewg
5a9c2006ff Get rid of Posix_EarlyInit() and Posix_LateInit()
Since we don't have our own signal handler anymore, those two
init functions can be merged into the existing Sys_Init(), which
is already called by common->Init().
2012-07-06 01:39:01 +02:00
dhewg
68284f9a09 Get rid of empty sys/linux/dedicated.cpp 2012-07-06 01:06:56 +02:00
dhewg
d53c91b023 Get rid of useless files in sys/linux 2012-07-06 01:06:55 +02:00
dhewg
b073f281ad Get rid of the SIGFPE handler
If shit happens, let it crash.
2012-07-06 01:06:55 +02:00
dhewg
93fdc96e60 Get rid of Sys_FPU_EnableExceptions()
No exceptions were ever enabled.
2012-07-06 01:06:51 +02:00
dhewg
0ef470de6c Use common->Warning() in linux/main.cpp 2012-07-05 19:15:12 +02:00
Andre d
7a5b8b1ec0 Remove (faulty/outdated) video ram detection 2012-07-04 22:47:38 +02:00
dhewg
3e9545fb71 Overhaul the *nix based BASE path
Try BUILD_DATADIR first (build time setting), then the vanilla
doom3 path.
2012-07-04 02:18:44 +02:00
dhewg
ff00686218 Provide a fallback for PATH_EXE on *nix
Less pain on BSD.
2012-07-03 21:12:59 +02:00
dhewg
14ba5b82c6 Use XDG Base Directories on *nix
See
http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
2012-07-03 21:12:59 +02:00
dhewg
e55753e626 Introduce fs_configpath
Split fs_savepath for config files. This is in preparation for
moving the writable paths on *nix to $XDG_DATA_HOME and
$XDG_CONFIG_HOME.
Affected files: config.spec, *.cfg, doomkey, xpkey.
2012-07-03 21:12:58 +02:00
dhewg
478fa783f6 Unify Sys_*Path() into Sys_GetPath() 2012-07-03 21:12:56 +02:00
dhewg
3256783af1 Get rid of ID_DEMO_BUILD
There are no demo pk4s compatible to this 1.3.1 codebase.
2012-07-03 21:12:55 +02:00
dhewg
b9cc8548dc Remove leftover X11 header 2012-06-15 18:25:48 +02:00
Daniel Gibson
6a23b17509 Work around broken libs that call setlocale(LC_ALL, "");
Because that can fuck up parsing floats if your locale uses ',' as a radix.

LADSPA plugins that may be used by ALSA do this. A PITA to debug.
2012-05-13 00:04:17 +02:00
dhewg
79fa35d0ec Get rid of ID_MCHECK
mcheck() is not thread safe, use MALLOC_CHECK_ or TCMalloc
instead.
2012-01-08 12:24:57 +01:00
dhewg
1fed72fbb4 Get rid of Sys_DoPreferences()
The OSX backend was the only one utilizing this to set CVars
for the video mode.
Not required anymore since its now based on SDL.
2012-01-05 00:24:13 +01:00
dhewg
79aea4082f Port Linux events to SDL
New CVar "in_kbd" to set the layout for the keyboard. SDL 1.2
doesn't offer any way to determine it, and we need this feature
to use the same key for toggling the console independent of the
keyboard layout.
The old "in_nograb" from the Linux backend is still supported.
2012-01-02 15:44:16 -05:00
dhewg
502aaa6fe2 Port Linux GLimp to SDL
Use SDL to set video modes, get a GL context and detect the
amount of VRAM.
As with the Linux GLimp implementation, sys_videoRam can be used
in case the SDL detection fails.
2012-01-02 15:44:09 -05:00
dhewg
32530bf7a2 Get rid of GLimp_EnableLogging
Only stubs left.
2012-01-02 15:44:00 -05:00
dhewg
1afe61cc8d Get rid of dead render thread code
The Windows backend had some preparing code for this feature,
but there is no support at all for this in renderer/.
2012-01-02 15:43:48 -05:00
dhewg
6e0c766d14 Unify all Sys_GetProcessorId()
Use SDL functions whenever possible.
2011-12-22 11:07:00 +01:00
dhewg
d4281b56bf Get rid of Sys_GetProcessorString()
This was only used for a printf() and not implemented for all
the platforms we can now run on.
We also don't want to force a CPU type on Windows.
2011-12-22 10:38:40 +01:00
dhewg
4150029322 Unify CPUID_FTZ and CPUID_DAZ
Get rid of the 2 CPUID flags and combine them with SSE in one
implementation.
SSE flags can now be set on all x86 and x86_64 platforms -
independent of -ffast-math.
Helper defines borrowed from STREFLOP.
2011-12-22 10:38:40 +01:00
dhewg
e2b46a5a34 Get rid of Sys_GetClockticks() and Sys_ClockTicksPerSecond()
Now unused.
2011-12-22 10:38:39 +01:00
dhewg
c994974ffc Port Sys_Milliseconds() to SDL
Sync with SDL and use unsigned int as return type.
Code outside of sys/ still uses signed ints to store the result.
2011-12-22 10:38:38 +01:00
dhewg
e7482b4957 Port all thread related functions to SDL
Setting thread priorities has been dropped (it is not portable).
The background download thread now exits gracefully.
g_threads is not public anymore.
2011-12-22 10:38:37 +01:00
dhewg
7865e432a7 Port the async thread to a SDL timer
SDL implements timers via threads and it lets us easily aim at
a 60Hz frequency.
2011-12-21 17:50:39 +01:00
dhewg
005677494f Initial SDL setup
Use SDL_main on all platforms.
Fix main() for non-const argv so it matches with the SDL
prototype.
Adapt win32 WinMain() to main() and get rid of the win32 special
case in Common::Init().
2011-12-21 17:40:05 +01:00
dhewg
736ec20d4d Untangle the epic precompiled.h mess
Don't include the lazy precompiled.h everywhere, only what's
required for the compilation unit.
platform.h needs to be included instead to provide all essential
defines and types.
All includes use the relative path to the neo or the game
specific root.
Move all idlib related includes from idlib/Lib.h to precompiled.h.
precompiled.h still exists for the MFC stuff in tools/.
Add some missing header guards.
2011-12-19 23:21:47 +01:00
dhewg
b62b033b88 Get rid of all idAudioHardware implementations 2011-12-14 18:37:03 +01:00
dhewg
9df3383b61 Remove Sys_LoadOpenAL() and Sys_FreeOpenAL()
This is not required anymore, all binaries on all platforms
either link against OpenAL or use the stub.
2011-12-14 18:23:49 +01:00
dhewg
41a1122a82 Remove the unused and useless CallStack code
This was never enabled and only implemented for Windows.
2011-12-14 02:39:42 +01:00
dhewg
f81d32918f Implement Sys_GetProcessorId for x86 and x86_64
Detect CPU features at runtime via cpuid - code borrowed from
libavutil.
Availability of cpuid is not checked since pentium3 supports it
and that was the minimum requirement anyway.
Only features enabled at compile time will be available.

Forced MMX/SSE/SSE2/SSE3 and it passed all tests via:
./doom3.x86_64 +disconnect +set s_noSound 1 +testSIMD
2011-12-13 19:26:16 +01:00
dhewg
18762483e6 Change return type of [Sys_]GetProcessorId to int
Fixes compile error: invalid conversion from 'int' to 'cpuid_t'
2011-12-13 18:57:30 +01:00
dhewg
74acc03147 Enable OpenAL for all platforms
New scons variable 'OPENAL' (defaults to '1') to toggle the
OpenAL sound backend.

Enable via "s_useOpenAL 1".
2011-12-11 17:07:13 +01:00
dhewg
82aaccc1ad Use the local OSS headers 2011-12-10 15:36:16 +01:00
dhewg
1b8777a008 Get rid of GL_HARDLINK, always link against libGL
This kills the funky GL logging stubs, which unnecessarily
complicates the build process (think future cmake).
As for logging GL calls: Use apitrace for that
https://github.com/apitrace/apitrace
2011-12-10 15:36:16 +01:00
dhewg
9678020677 Fix compilation for *BSD
Change most __linux__ defines to __unix__ for all UNIX like systems.
2011-12-10 15:36:16 +01:00
dhewg
f9dd2f93eb Fix platform dependent thread function definitions
Thread return types are different between platforms, and its
probably not a good idea to return something of a different size,
cast the callback and expect it to not crash.
2011-12-10 15:36:13 +01:00