Commit graph

56 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
Daniel Gibson
8cb4843022 Shorten file path in backtraces
The build dir isn't relevant, only the source path starting with neo/ is

Also removed instances of nullptr
2022-01-08 17:02:24 +01:00
Daniel Gibson
ea781c577e Use idStr::Copynz() instead of strncpy()
to guarantee \0-termination
2022-01-08 16:58:48 +01:00
SiliconExarch
4f0c54f63f Fix compatibility with Mac OSX 10.4 and 10.5
- Fix build with SDL <=2.0.3
  SDL_GetGlobalMouseState was introduced in 2.0.4
  (which doesn't support OSX 10.5 or older)
- Don't include execinfo.h on Mac OS X 10.4
  This file isn't included in the 10.4 SDK
- Use custom typedef for PFNGLSTENCILOPSEPARATEPROC on OSX 10.4/10.5
  because the system OpenGL headers for those versions don't have it
2021-10-12 19:07:41 +02:00
Daniel Gibson
61a49a2547 Implement clipboard support on POSIX platforms with SDL2
Added Sys_FreeClipboardData(char*) so I don't have to copy the string
from SDL_GetClipboardText() into a Mem_Alloc() buffer, but can just
do the right thing per platform, which in case of POSIX/SDL2 is
SDL_free().
SDL1.2 doesn't have clipboard support, otherwise I'd have removed all
platform-specific implementations and used SDL_Get/SetClipboardText()
everywhere (IIRC AROS only supports SDL1.2?)
2021-07-03 02:25:20 +02:00
Daniel Gibson
d55b7fa6c9 Don't use stringDataAllocator in idStr, it's not thread-safe
idStr is used in both the main thread and the async sound thread, so
it should better be thread-safe.. idDynamicBlockAlloc is not.
Use realloc() and free() instead.

For some reason this caused a lot more crashes (due to inconsistencies
in the allocator's heap) with newer Linux distros (like XUbuntu 20.04)
and when using GCC9, while they rarely reproduced with GCC7 or on
XUbuntu 18.04

fixes #391
2021-06-24 03:26:51 +02:00
Daniel Gibson
227fe5fc92 Use backtrace in crash handler on POSIX platforms
Non-ancient versions of GCC and clang should ship it, and in contrast
to the <execinfo.h> backtrace_symbols() it also works with
-fvisibility=hidden
2021-05-12 07:56:57 +02: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
430a8f5e95 POSIX: Show errormessage if loading a (Mod) .so failed, refs #318
.. but only if the file exists.
It's ok if mods don't have their own DLL/.so, but if they do have one
and loading fails it's interesting why they failed (e.g. no access
rights, 64bit lib with 32bit executable or other way around, missing
symbols due to wrong libc version, ...)

The same should be done for Windows, but that's still TODO.
2021-01-17 06:58:13 +01:00
Daniel Gibson
117f0948e4 Posix_InitConsoleInput(): Accept everything that starts with "xterm-"
no matter if it's xterm-color or xterm-256color or whatever
2021-01-16 05:34:58 +01:00
Dan Church
9110437e2d Fix FTBFS 2019-10-08 23:21:34 +02:00
Victor Diego Alejandro Diaz Urbaneja
80d9c79944 Making AlpineLinux Compatible 2019-10-07 19:05:15 +02:00
Victor Diego Alejandro Diaz Urbaneja
6c7f8b1b07 Making AlpineLinux Compatible 2019-10-07 19:05:15 +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
Andre Heider
bbcb2b00dc Fix endless loop with in_tty on selected archs
Ran into this on aarch64.

Quoting http://c-faq.com/stdio/getcharc.html
"The bug can go undetected for a long time" :)

Fixes #102
2018-02-22 22:42:00 +01:00
Daniel Gibson
befe732dbb Fix new[]/delete missmatches and memory leaks found by clang's ASAN
Sometimes memory was allocated with new[] but freed with delete instead
of delete[], which is wrong.
And there were some small memory leaks, too.
Furtunately clang's AddressSanitizer detected all that so I could easily
fix it.

(There seem to be some more small memory leaks which are harder to fix,
though)
2015-12-17 18:11:03 +01:00
Daniel Gibson
5c99ff4657 make "./dhewm3 +set in_tty 0" actually work
the problem was that the CVar was initialized from the commandline
*after* Posix_InitConsoleInput() is called, so it was too late.
common->StartupVariable() seems to be the right way to initialize a
CVar early.
2015-09-27 18:14:06 +02:00
dhewg
a96635219c Fix pointer check/access in Sys_InitNetworking()
Reported by scaronni.
Fixes #25.
2012-07-17 18:25:06 +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
0bc457063f Get rid of the signal handler
SDL covers this via e.g. SDL_QUIT event on ctrl+c.
2012-07-06 01:31:27 +02:00
dhewg
d2b7eac843 Get rid of Sys_SetFatalError()
Unnecessary.
2012-07-06 01:24:25 +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
b58f51dbfa Get rid of Sys_FPU_StackIsEmpty()
Same as with Sys_FPU_GetState().
2012-07-06 01:06:53 +02:00
dhewg
0ccef1eba8 Get rid of Sys_FPU_GetState()
This was only implemented with MSVC style asm.
Comments suggest that it was used to help catch invalid FOV calculations,
which were probably only happening with ancient compiler bugs.
2012-07-06 01:06:53 +02:00
dhewg
65b13cb73e Use a more modern way to set the fpu precision 2012-07-06 01:06:51 +02:00
Andre d
7a5b8b1ec0 Remove (faulty/outdated) video ram detection 2012-07-04 22:47:38 +02:00
dhewg
1da44eb856 Fix Sys_IsLANAddress() on *nix
Don't just convert the first char of the IP.
LAN clients now get properly detected and don't need to auth
against the master server.
2012-07-04 02:18:51 +02:00
dhewg
b242041319 Make Sys_DLL_Load() on *nix non verbose on errors
Just like the windows port.
2012-07-04 02:18:44 +02:00
dhewg
2d69979be2 Use the portable getifaddrs() on *nix
Cleanup the OSX specific code in Sys_InitNetworking() and use it
for all *nix platforms.
Fixes nic detection on BSD.
2012-07-03 21:11:05 +02:00
dhewg
99864667a7 Use PATH_MAX for MAX_OSPATH on all platforms
The hardcoded 256 doesn't cut it.
2012-07-03 21:10:45 +02:00
dhewg
1ce658e835 Get rid of memory status functions
Unused.
2012-01-08 12:24:58 +01:00
dhewg
6a1d6cb842 Always allow multiple instances 2012-01-08 12:24:58 +01:00
dhewg
438685e6e6 Get rid of Sys_FlushCacheMemory()
Stub on all platforms.
2012-01-08 12:24:58 +01:00
dhewg
9542663097 Get rid of Sys_DefaultCDPath()
Stub on all platforms.
2012-01-08 12:24:58 +01:00
dhewg
bf69f7ec76 Use SDL GLimp and input implementations on OSX 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
5d69699edf Rename Posix_ConsoleInput() to Sys_ConsoleInput()
Sync with Windows implementation and add it to sys_public.h in
preparation to move the event queue to SDL.
2012-01-02 15:44:16 -05:00
dhewg
ca04dd36d8 Get rid of the unused Sys_FPU_ClearStack 2011-12-22 11:07:01 +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
317e63887c Port Sys_Sleep() to SDL 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
5a052e846f Move MAX_THREADS as define to BuildDefines.h 2011-12-21 17:50:39 +01:00
dhewg
1a25b165b0 Port critical sections and events to SDL
Use SDL mutexes and conditions.
One new critical section CRITICAL_SECTION_SYS for events.
2011-12-21 17:50:35 +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
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
a8b1d3a364 Fix POSIX net code for x86_64
Multiplayer working from 32bit dedicated server on FreeBSD with a
64bit Linux client.
2011-12-10 19:24:30 +01:00
dhewg
56bd47ac43 Fix Sys_FileTimeStamp return type
Sync with its header.
2011-12-10 15:36:15 +01:00
dhewg
5c9973773b Force exit on double segfault
All bets are off in this scenario, don't deinit anything.
2011-12-10 15:36:14 +01:00