Commit graph

611 commits

Author SHA1 Message Date
Daniel Gibson
f3a4d92d33 Remove C++11-isms
accidentally used nullptr instead of NULL, oops..
2020-07-13 05:34:13 +02:00
Daniel Gibson
80f9a5ca52 dhewm3 1.5.1 RC1 2020-07-13 01:39:52 +02:00
Daniel Gibson
5e7019ebfe Support reproducible builds, fixes #172
If REPRODUCIBLE_BUILD is enabled in CMake, the code will not use
__DATE__ or __TIME__ macros, but instead hardcoded values.

Wherever __DATE__ or __TIME__ were previously used, we now use
ID__DATE__ and ID__TIME__, which are either set to hardcoded values or
to __DATE__ and __TIME__ in neo/framework/Licensee.h.
2020-07-13 01:33:40 +02:00
Daniel Gibson
504b572ae4 Update sounds at ~60Hz instead of ~10Hz, fixes #141
For some reason sounds were only updated/started about every 100ms,
which could lead to delays of up to around 100ms after a sound gets
started (with idSoundEmitterLocal::StartSound()) until OpenAL is finally
told to play the sound.
Also, the actual delay drifted over time between 1ms and 100ms, as the
sound ticks weren't a fixed multiple of the (16ms) gameticks - and the
sound updates didn't even happen at the regular 92-94ms intervals they
should because they run in the async thread which only updates every
16ms...
Because of this, the machine gun and other rapid firing weapons sounded
like they shot in bursts or left out shots occasionally, even though
they don't.
Anyway, now sound is updated every 16ms in the async thread so delays
are <= 16ms and hopefully less noticeable.

You can still get the old behavior with com_asyncSound 2 if you want.
2020-07-12 04:43:53 +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
Daniel Gibson
964efa191d Disable sound if initializing OpenAL failed, fixes #292
idSoundSystemLocal::Init() didn't consider the case that opening the
default device (alcOpenDevice(NULL)) could fail, but this can happen if no
audio devices exist (or all are disabled or they're sleeping bluetooth
headphones or whatever).
Starting a map failed then with
  ERROR: idSoundCache: error generating OpenAL hardware buffer
Now this and "s_noSound 1" are handled the same and one can play.
2020-06-01 22:13:41 +02:00
Daniel Gibson
5919717d05 Fix looping .wav sounds with leadin, fixes #291
If the main sound in a shader was a .wav
(soundShader->entries[0]->hardwareBuffer == true), only that sound was
played (and looped with AL_LOOPING), even if a leadin was configured.
If the main sound was an .ogg it worked.
Not it should always work.
2020-06-01 22:13:41 +02:00
Daniel Gibson
e24b62d3e0 Use g_hitEffect CVar variable directly instead of getting it by name
No need to do a lookup of the CVar by name every time the player is hit,
we can just access the variable holding it.
2020-05-30 05:41:22 +02:00
Maksim Zinal
75e9af81e1 Fixed SIGSEGV caused to references to already deleted data values in idWindow ops and updateVars 2020-05-30 05:28:40 +02:00
dobosken
e93ba6ce0c Added "g_hitEffect" CVar to disable damage effects to the player camera
Defaults to "1" (on) so the default behavior is like in the original
game, but setting it to 0 disables the effects.
2020-05-30 05:23:13 +02:00
Stradex
bbbc23dbdd Master server working again 2020-05-28 00:18:54 +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
Corey O'Connor
636c3a0b54 ignore errors unloading OpenAL data. mitigates #178 2020-01-30 01:08:10 +01: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
Daniel Gibson
bcf647cf71 Prevent stackoverflow in R_DeriveTangentsWithoutNormals()
turns out tri->numIndexes can be quite big so _alloca16() would be
called with >1MB - and the Win32 stack only is 1MB, so that overflows.
As a workaround, use Mem_Alloc16() if we need >600KB

was reported in #265
2020-01-11 15:39:34 +01:00
Daniel Gibson
dd7a6b2832 idLangDict: Workaround for Doom3: Lost Mission stringtables #265
The Doom3: Lost Mission (aka D3LE) mod uses string table entry keys that
don't follow the proper Doom3 scheme of "#str_01234", but look like
"#str_adil_exis_pda_01_audio_info" - the "hash" algorithm of idLangDict,
which basically just converts the number after "#str_" into an int,
probably doesn't work very well with this and there was an assertion
to prevent this..
However, it seems to work well enough, so now I only print one warning
for the first "invalid" key and otherwise accept those keys.

The stringtable (strings/*.lang) also has font-related entries
(like "#font" "Chainlink_Semi-Bold") that triggered another assertion,
now everything that starts with "#font" is silently skipped.
2020-01-05 02:34:53 +01:00
Daniel Gibson
f24f18a61e Use OpenGL2 glStencilOpSeparate() for shadows, if available
can be enabled/disabled with the r_useStencilOpSeparate for comparisons

(like Z-Fail, this doesn't really seem to make a difference on my main
 machine, neither on my RPi4)

Partly based on Pat Raynor's Code:
2933cb5545/neo/renderer/draw_stencilshadow.cpp
2019-11-03 03:13:21 +01:00
Daniel Gibson
aeb03cc4e4 Allow switching off "Carmacks Reverse" via CVar r_useCarmacksReverse
mainly useful for comparisons

The Z-Fail code is based on Leith Bade's code by the way:
d4de024341
2019-11-03 03:13:21 +01:00
Leith Bade
b6b5827aff Put back the old patented "Carmack's Reverse" depth fail stencil shadow technique. 2019-11-03 00:19:03 +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
yamir
12fa28b260 Fix ppc64le build 2019-09-11 13:02:55 -01: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
e33921a28a Fix build with CMake < 3.8 by replacing source_group() with stub
dhewm3 uses source_group(TREE ...) which is only supported in
CMake 3.8 and newer.
As it's only cosmetical (so files show up in correct path in IDEs like
Visual Studio), I just replace the source_group() function with a dummy
for affected CMake versions. At least people can still compile then..

fixes #232
2019-04-08 00:59:31 +02:00
Daniel Gibson
3a763fc685 Merge branch 'tools'
Bringing back support for the (MFC-based Windows-only) editing tools.
Only tested 32bit (not sure if the code is 64bit-clean), needs a
"proper" (non-Express) version of Visual Studio *including* MFC support,
tested the free "Community" Editions of VS 2013 and 2017.
(For VS2013 I needed to install the "Visual C++ MFC MBCS Library for
Visual Studio 2013" because it either didn't include MFC support at all
or only the wrong version, don't remember, you'll need that one anyway)
2019-03-11 01:30:26 +01:00
Daniel Gibson
5c1e1d7708 Fix ParticleEditor's Materialpicker screwing up ViewPort
In short, it uses a idGLDrawableMaterial widget that calls
renderSystem->BeginFrame(w, h); (with w and h being small for the texture
preview window) and BeginFrame() sets glConfig.vidWidth and vidHeight to
w/h and that never got reset to the original value (window width/height).
This breaks everything because for some reason
renderSystem->GetSCreenWidth()/Height() return glConfig.vidWidth/Height
so it will just continue to render everything at that resolution (in a
small rectangle on the lower left corner of the window).
This bug has already existed in Doom3 1.3.1 (but was less noticable because
apparently  when switching away from Doom3 and back to the window it reset
vidWidth/Height to the window resolution)
I only implemented a workaround (restore glConfig.vid* after rendering the
texture preview), it's possible that the same issue exists in other
(probably editor-) code - but a "proper fix" might also break code (and I'm
not super-familiar with the editor code or even just using them)
2019-03-10 05:23:06 +01:00
Daniel Gibson
b0d022f559 Fix crash when selecting nonexistant texture in D3Radiant
When selecting a texture in Inspectors -> Media -> Textures that doesn't
really exist (.mtr defines it, but referenced image files are missing),
the game/editor used to crash.
The problem was that somehow people thought the best way to communicate
that a file wasn't found was by setting the timestamp to 0xFFFFFFFF
and then checking for that - sometimes (incorrectly) by comparing it to -1.
That worked for 32bit ID_TIME_T (typedefed to time_t), but not with 64bit
time_t, which now seems to be the default for Win32 in VS.
So I replaced a few -1 and 0xFF... with FILE_NOT_FOUND_TIMESTAMP and now it
works.
FILE_NOT_FOUND_TIMESTAMP is still defined as 0xFFFFFFFF, maybe I should
change that, unsure if that'd break anything though..
When changing it one should keep in mind that time_t might still be 32bit
on some platforms (Linux x86?) so that should still work.. (-1 could work)
2019-03-10 05:11:33 +01:00
Dmitry Marakasov
17c10d40a5 Fix build on powerpc but not mac
...by including `vecLib/vecLib.h` only on `__APPLE__`, and not just any `__ppc__`

From https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=235668:

> On powerpc* platforms vecLib/vecLib.h is included by default.
> This header is only available on Mac OS X, so remove it. It
> doesn't seem to be actually needed to compile this port.
2019-02-14 16:53:38 +01:00
Klez
31e877e7e4 Compilation fix on 64 bit macOS. Upgrade min SDK version
Upgrade CMakeLists.txt minimum SDK version for compiling in macOS to v.10.9 "Mavericks" for 64 bit builds.
Until now, make failed with this error:

warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
In file included from /Juegos/dhewm3/neo/idlib/bv/Bounds.cpp:29:
/Juegos/dhewm3/neo/sys/platform.h:185:10: fatal error: 'cstddef' file not found
#include <cstddef>
         ^~~~~~~~~
1 warning and 1 error generated.
2019-01-15 16:28:07 +01: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
596d40d5c9 MSVC: Shut up Compiler warning in Matrix.h if asserts are disabled 2019-01-13 22:12:36 +01:00
Daniel Gibson
c60f630eea GUI Editor code/integration from SteelStorm2, doesn't build yet 2019-01-13 22:12:36 +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
cd0ec54991 CMake: Fix build in path with spaces
fixes #174
2019-01-13 19:03:12 +01:00
Yamagi Burmeister
48b8c199d9 We need to link libexecinfo for the backtrace() functions on FreeBSD. 2019-01-13 18:39:10 +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
bd39f9ecf2 CMake: Make source files listing in VS usable
For some reason CMake thinks it's a great default to display all the source
files of a project in Visual Studio as a flat list (instead of in the
directory structure they're physically in).
source_group(TREE ...) *per project/"target"* helps.

Also, so far there was no reason to list or otherwise use header files
in CMakeLists.txt - but for them to turn up in VS they must be added to
the source lists. I've done that, but I'm sloppily globbing them instead
of adding each headder manually like it's done for the source files
(because it doesn't matter if a header that's not really used turns up
in those lists)
2019-01-07 15:06:59 +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
efd814a4e0 Fall back to demo/ if no gamedata can be found in base/
The demo game data is in demo/ instead of base/, so try to fall back
to that to cause minimal confusion.
2019-01-07 15:06:59 +01:00
Daniel Gibson
42886f0e4b Modify check for Demo version to not break Game DLL ABI
Changing idSession would break the interface for Game DLLs, making the
existing ports of Mods incompatible.
Luckily we have idCommon::GetAdditionalFunction() for cases like this..

Also added a check for WEAPON_NETFIRING in idWeapon::EnterCinematic(),
I got an Assert() there in Debug builds.

Running the Demo seems to work now, at least I could finish it without
any problems (ignoring some warnings in the console)
2019-01-07 15:06:59 +01:00
Daniel Gibson
cf35cecbc7 Revert changes for Demo to d3xp/ - Demo only needs game/ code 2019-01-07 15:06:59 +01:00
gab
7d9d8680e1 Additional fix 2019-01-07 15:06:59 +01:00
gab
12629e1f66 Support for D3 demo data files (minimum viable changes) 2019-01-07 15:06:59 +01:00
Daniel Gibson
53e0db9f41 Bump version to 1.5.1pre
this is not 1.5.0 anymore.
2019-01-07 15:06:59 +01:00
Daniel Gibson
593141651a Fix ModWiki links in --help text, link Mods page in README 2018-12-21 04:49:00 +01:00
Daniel Gibson
9822aea458 Change version to 1.5.0
I think the release is ready, not 100% sure though
2018-12-15 05:49:59 +01:00