Commit graph

262 commits

Author SHA1 Message Date
Daniel Gibson
2139a122c5 Revert "Use SDL2's own SDL2.cmake."
This reverts commit 01ac144b09.

Looks like this broke the build on some systems, because some
package managers pack SDL2Config.cmake and others pack sdl2-config.cmake
in their SDL2 development packages (for some reason, SDL2 seems
to ship both in their source, and they appear to be incompatible).

Shipping our own FindSDL2.cmake might be unclean/ugly/whatever, but
at least it works (most of the time? at least it appears to work better
than not shipping it)
2021-01-24 04:10:18 +01:00
HarrievG
5dd826ee38 Dll load errors (#1)
* Windows DLL-Load-Errors
Added error reporting using formatmessage, ignoring if the DLL just
doesn't exist, custom warning for "[193 (0xC1)] is not a valid Win32
application." (probably wrong architecture)

* update gitignore with build folder
2021-01-18 00:38:29 +01: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
Daniel Gibson
8f467d678b Fix build on Windows+MSVC after removing FindSDL2.cmake
I updated sdl2-config.cmake in dhewm3-libs so building on Windows with
them works again, however that required also a little change in
dhewm3's CMakeLists.txt

I also still had some uncommited changes for that fullscreen workaround
that I'm committing now.
2021-01-16 04:47:27 +01:00
Tobias Frost
01ac144b09 Use SDL2's own SDL2.cmake. 2021-01-16 04:40:38 +01:00
Daniel Gibson
9a83b3def4 Add r_fullscreenDesktop CVar for "desktop"/windowed fullscreen mode
.. that doesn't switch the display resolution, but creates a borderless
fullscreen window at current desktop resolution.
SDL2-only (SDL_WINDOW_FULLSCREEN_DESKTOP).

Doing this with an additional CVar instead of r_fullscreen 2 or similar
has the advantage that it works properly with Alt-Enter
2021-01-15 18:24:48 +01:00
Daniel Gibson
d1b0073582 Try to enforce selected fullscreen resolution
SDL has a bug (at least on Windows) where SDL_CreateWindow() with
SDL_WINDOW_FULLSCREEN doesn't use the configured resolution (if it's
higher than the current desktop resolution).
Try to work around that - based on Yamagi Quake II code.

Also, if GLimp_Init() fails, the "safe mode" fallback is now in
windowed mode instead of fullscreen mode.
2021-01-15 18:24:48 +01:00
Daniel Gibson
c684c38f2d SDL2: Create window on display the cursor is currently on, fix #309
I hope this provides a good enough way to "select" the display to play on.
2020-09-05 20:31:14 +02:00
Daniel Gibson
b9e13d2f17 Make switching from Radiant to game work
the game was frozen (the main menu and console worked though) when
switching from the Radiant to the engine (with F2 or that button).
Turned out common->ActivateTool( false ) must be called if the game window
has forcus, so idSessionLocal::Frame() doesn't return early (and thus not
run the game code).

Furthermore, there was no sound when switching from Radiant to the game,
because the SoundWorld was set to sth editor-specific. Fixed that as well.
2020-07-20 05:06:57 +02:00
Dave Nicolson
3e8601e925 Restore deleted file 2020-07-19 16:18:35 +02:00
Daniel Gibson
e6f3713169 OpenAL: Try to reset disconnected devices, fixes #209
OpenAL devices can disconnect, and with some luck they're back after
a few seconds. This especially seems to happen with Intels Windows GPU
driver and display-audio when switching the resolution or enabling
fullscreen, see #209
Now a disconnect is detected and we try to reset the device for 20
seconds, hoping it comes back. This needs at least openal-soft 1.17.0
to build and 1.20.0 or newer to actually work.

Also added missing stub functions in openal_stub.cpp (used by dedicated
server so it doesn't have to link libopenal)
2020-06-01 22:13:41 +02:00
C.W. Betts
88559af603 Update Mac source
Remove the rsrc file (unused)
-[NSString cString] is deprecated. Use -[NSString UTF8String] instead.
2020-05-27 01:29:26 +02:00
Daniel Gibson
b4a029c234 Fix ID_MAYBE_INLINE on non-Windows platforms 2020-01-16 20:43:38 +01:00
Daniel Gibson
b756276b54 ID_MAYBE_INLINE for not-forced inlining
On Windows, ID_INLINE does __forceinline, which is bad if the function
calls alloca() and is called in a loop..
So use just __inline there so the compiler can choose not to inline
(if called in a loop).
This didn't cause actual stack overflows as far as I know, but it could
(and MSVC warns about it).
2020-01-11 16:15:34 +01:00
Daniel Gibson
aca8c24c3a Assertions in _alloca() and _alloca16() for too big stack allocations
not on Windows though, for some reason MSVC doesn't like my ugly
hack to add an assert() to the _alloca16() macro :-/
2020-01-11 16:14:43 +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
04a50e1927 Recreate s_scantokey_* tables in win_input.cpp to fix MinGW build
the tables contain character constants like ('ä') that are supposed to
be interpreted as ISO8859-1 or WINDOWS-1252 or sth, but that doesn't
seem to work with MinGW (anymore) - seems like it assumes UTF-8 by
default, and for some reason -finput-charset=ISO8859-1 doesn't help
either, it complains about multichar character constants then..

Anyway, now the table entries are represented as the corresponding
integer constants which seems to work as intended.

Fixes #238
2019-06-17 03:50:07 +02:00
Daniel Gibson
9a95a2a1cf Building with editor support (on Win w/ VS2017) works \o/
Editor also seems to start, didn't test much further.

Only tested 32bit Windows, I fear the editor code isn't 64bit clean..

I hope I haven't broken anything elsewhere..
2019-01-13 22:52:28 +01:00
Daniel Gibson
08970f186d CMake: Don't try to find X11
causes trouble on macOS, and we shouldn't interact with X11 directly
anyway, because SDL does it for us.
OpenBSD apparently needed it (at least it was added for OpenBSD
support), but the only place I can imagine it being needed is the
superfluous #include <SDL_syswm.h> in neo/sys/glimp.cpp - which I now
removed. In case it's needed after all please tell me, then I'll add it
again - but guarded by if(os STREQUALS "OpenBSD") or however one checks
for OpenBSD in CMake.
2019-01-13 19:06:32 +01: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
6a507c6a5b Windows: Don't put stdout.txt and stderr.txt into binary dir
It might not be writable.. which will cause game startup to fail.
Put them in My Documents/My Games/dhewm3/ instead, like the save games.
2019-01-07 15:06:59 +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
Daniel Gibson
4e2f2c6241 Show dhewm3 version in window title 2018-11-11 23:24:07 +01:00
Daniel Gibson
84a70a3a05 Tell Windows we're High DPI aware, (hopefully) fixes #191
taken (with permission) from Yamagi Quake II, thanks a lot!
2018-07-14 20:54:21 +02: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
Kalamatee
c8cdb641d4 # move the AROS specific folder icon and default.cfg mmakefile.src under neo/sys/aros/setup
# add a comment to the top level AROS mmakefile.src to clarify that it is specifically for AROS.
2017-04-22 16:21:14 +02:00
Kalamatee
4813718954 use socklen_t 2017-04-22 16:21:14 +02:00
Kalamatee
315d66f8f8 rename the resurrection of evil files to just "ROE". 2017-04-22 16:21:14 +02:00
Kalamatee
1a7c574dce delint 2017-04-22 16:21:14 +02:00
Kalamatee
46279bf11f import AROS changes 2017-04-02 00:42:28 +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
David Carlier
09c1330a0e make it compilable under openbsd 2016-12-09 16:21:54 +00: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
df90fce6a5 small improvement for handling up to 8 mouse buttons
as we do int buttonIndex = ev.button.button - SDL_BUTTON_LEFT;
it's only consistent to do if(ev.button.button < SDL_BUTTON_LEFT + 8)

it doesn't really make any difference as long as SDL_BUTTON_LEFT is 1,
but this way it's safe for SDL3 or whatever future version might break
the ABI.
2015-12-13 03:49:29 +01:00
Sébastien Noel
32feff2be1 handle up to 8 buttons with SDL2 based on https://github.com/RobertBeckebans/RBDOOM-3-BFG/pull/213
it's buggy on Linux/X11 before 2.0.4, but it works fine on other platforms
extra bonus: don't generate garbage events for unknown mouse buttons
2015-12-13 03:30:43 +01:00
Daniel Gibson
c5ad45368a Workaround to better support AZERTY keyboards
The first row of AZERTY-Keyboards (used in France and Belgium) doesn't
have numbers as keys but ², &, é, ", ', (, -, è, _, ç, à, ), =
(with small differences between France and Belgium).
For some of those keys we don't have keycodes - and neither does SDL2.
See also https://bugzilla.libsdl.org/show_bug.cgi?id=3188

As a workaround, just map those keys to 1, 2, ..., 9, 0 anyway, as those
are keys Quake2 already knows (and those chars are printed on the keys
too, for typing they're reachable via shift).
This workaround only works for SDL2, as SDL1.2 doesn't have Scancodes
which we need to identify the keys.

This should obsolete one part of pull request #135
2015-11-22 23:21:30 +01:00
Daniel Gibson
4198f92bd5 ignore unknown SDL events
they just spam the console and don't matter anyway.
for example, on OS X you get lots of SDL_FINGER* events that spam
the console.
2015-10-23 18:19:46 +02:00
Daniel Gibson
8f4f1ca39f Get rid of "WARNING: unknown event 770" on Windows
It's an SDL_TEXTEDITING event which we seem to get on Windows whenever
the Window gains focus (or is created). I think it can be safely
ignored, so that's what I do.

I also changed how those warnings are printed - as a hex number now,
because they're defined as hex numbers in the SDL source and it's easier
to find out what kind of event it is this way.
2015-10-05 15:14:42 +02:00
svdijk
dd082b78de Win32: Add an icon to the dhewm3 executable 2015-10-03 09:17:30 +02:00
Daniel Gibson
412dad6758 Sys_GetEvent(): Don't return res_none when more events are available
If res_none (event with .evType == EV_NONE) is returned,
idEventLoop::RunEventLoop() will assume there are no more events this
frame => pending events will be delayed til next frame (or later if
again res_none is returned in the meantime).
So res_none shouldn't be returned just because there was an SDL event
we didn't care about or we did care about but don't generate a doom3
event for (but toggle fullscreen or something).
Instead we should just fetch and handle the next SDL event.
2015-09-30 15:58:50 +02:00
Daniel Gibson
66f7b6aa87 no allocation per SDL_TEXTINPUT event
those event have a max size (SDL_TEXTINPUTEVENT_TEXT_SIZE) so we can
just use a static buffer.
2015-09-30 15:41:14 +02:00
Francisco Magalhães
32afbca7c1 Add support for brazilian keyboard layout 2015-09-30 15:12:10 +02: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
Daniel Gibson
0327a42ad9 Fix input on Windows with SDL2 (fix #100)
Seems like the ::SetFocus() in main() screwed it up.
2015-09-28 15:35:57 +02: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
Daniel Gibson
1de6ab0d50 Fix some compiler warnings (wrong types, superfluous checks, printf-fuckup) 2015-09-27 18:12:16 +02:00
Daniel Gibson
555d233867 Window Icon, make in_nograb work with SDL2 2015-03-02 00:03:30 +01:00