Commit graph

923 commits

Author SHA1 Message Date
Daniel Gibson
a7e4eb8644 Fix renderlights loaded from savegames aliasing other lights
Some entities wrote the handle from gameRenderWorld->AddLightDef()
into savegames and reused it after restoring it.
That's a bad idea, because at that point the handle most likely belongs
to something else (likely some idLight). The most visible issue this
can create is that the flashlight may not work correctly after loading
a savegame with flashlight on, when it happens to alias a light that's
updated each frame to (mostly) being off..

The correct way to handle this (THAT FOR SOME REASON WAS ALREADY
IMPLEMENTED IN D3XP BUT NOT THE BASE GAME - WHY?!) is to get a fresh
handle with AddLightDef() when restoring a savegame - unless the handle
was -1, which means that the light didn't exist when saving.

fixes #495
2022-11-06 18:12:54 +01:00
Daniel Gibson
2a85b73110 Fix some ubsan warnings 2022-11-06 03:09:05 +01:00
Daniel Gibson
e1e8103982 HARDLINK_GAME option in cmake
to compile game code into executable instead of base.dll/d3xp.dll

allows using UBsan
2022-11-06 03:09:05 +01:00
Daniel Gibson
4dcc7efe59 StartSoundShader() event: special-case for soundName "", refs #494
Some level scripts in d3xp (erebus4, erebus4, phobos2) use
  $entity.startSoundShader( "", SND_CHANNEL_BODY );
(or whatever channel) to stop the sound currently playing there.
With s_playDefaultSound 1 that results in a beep..
Added a special case to that event implementation to call StopSound()
instead when the soundName is "" (or NULL)
2022-10-31 03:20:57 +01:00
Daniel Gibson
d0d00c0095 Bump version to 1.5.3pre
this is not 1.5.2 anymore
2022-10-22 20:57:48 +02:00
Daniel Gibson
177740ca88 Fix crash in Radiant Model Preview Dialog, fix #496
the problem was a double-free on files, because USE_COLLADA is not defined.
I'm not even sure why this USE_COLLADA code exists, as we don't have any
real collada support code anywhere..
2022-10-22 20:47:33 +02:00
PLG
cc0f49f9a8 Remove deprecated warnings on mac for cString use. 2022-07-07 22:47:12 +02:00
Daniel Gibson
2e71b99ee0 dhewm3 1.5.2 2022-06-13 03:36:23 +02:00
Daniel Gibson
89c44d7ac9 Make warning about falling back to base.dll more visible
.. by surrounding it with newlines.
This warning is shown when trying to start a mod without its game dll
(because the user has forgotten to unpack the mod dll archive, or
 because it's a mod that doesn't have its own dll).
Surrounding it with empty lines hopefully makes it easier for users
to figure out what went wrong when they look at the log.
2022-06-08 03:22:12 +02:00
Kevin Degeling
42b37b039e Include Linux metadata based on App Stream standard 2022-06-08 00:53:39 +02:00
Daniel Gibson
a2929d9062 Fix Light Editor in Radiant (#456)
When selecting a light in the Radiant (builtin Windows-only level editor)
and pressing `j`, the light editor opened (as expected) but said that
no entity was selected.
That was because com_editorActive was false, most probably because of
  e8a1eb8b Fix mouse remaining ungrabbed when running map from Radiant
which sets com_editorActive to false (via com->ActivateTool(false)) if
the Radiant window loses focus, which should be the case when opening
the light editor window.

`com_editors & EDITOR_RADIANT` is != 0 as long as the radiant is
running, no matter which window currently has focus, so it works better.
2022-05-30 00:33:16 +02:00
Daniel Gibson
6dfada9af0 Update version to 1.5.2rc2
and add entry to changelog about absolute mouse input etc - this change
was already in RC1 but I forgot to mention it..

and fixed comments for GAME_NAME and ENGINE_VERSION (nowadays dhewm3
uses ENGINE_VERSION for the window title)
2022-05-28 18:06:52 +02:00
Daniel Gibson
860181867a Disable assertion in idSampleDecoderLocal::Decode*(), fix #461
It happened a lot more since
  504b572a Update sounds at ~60Hz instead of ~10Hz, fixes #141
(because then MixLoop() is more likely to be called in the narrow
 timeframe this can happen during level load) but could happen before.
So far I only observed it when starting a new game in Classic Doom 3.
See comment in the change and #461 for more information.
2022-05-28 18:05:49 +02:00
Daniel Gibson
cdbb526a3b Add Doom3: Phobos to list of mods that need d3xp (STILL UNSUPPORTED!)
Hoping that Team Future eventually fulfills their promise of releasing
the source of the highly praised Phobos mod, I'm adding it to the list.

Currently this is not very useful, but when (if) the phobos source
becomes available I at least won't have to do a new dhewm3 release to
support it (but only provide tfphobos.dll/.so/.dylib).
2022-05-25 06:34:04 +02:00
Daniel Gibson
2f92bc268d Support loading The Lost Mission and librecoopd3xp via mods menu
by adding special cases for them that set `fs_game_base d3xp`.
Unfortunately there is no more generic way to do this, as mods have
no way to tell the engine if they need fs_game_base.
2022-05-25 06:17:29 +02:00
Daniel Gibson
b88b99fadb Fix assertion when switching to mod via menu, #458
The assertion that triggered was "assert(iconvDesc == (SDL_iconv_t)-1);"
in Sys_InitInput() - because when loading a mod the window is recreated,
calling Com_ReloadEngine_f() -> idCommonLocal::InitGame()
 -> idCommonLocal::InitRenderSystem() -> idCommonLocal::InitOpenGL()
 -> R_InitOpenGL() -> Sys_InitInput()

Before that Com_ReloadEngine_f() calls commonLocal.ShutdownGame( true );
which calls the equivalent Shutdown() functions - except so far no one
called Sys_ShutdownInput() (which closes iconvDesc and resets it to -1).
Fixed that by making idRenderSystemLocal::ShutdownOpenGL() call it.
2022-05-24 03:33:13 +02:00
Daniel Gibson
77e70b5df7 Add some missing newlines and fix typo in changelog 2022-05-21 06:30:54 +02:00
Daniel Gibson
0f9e066bf6 Fix running script debugger if fs_basepath is used
I don't think fs_cdpath is relevant (anymore? has it ever been?), but
fs_basepath sure is.
2022-05-18 04:22:25 +02:00
Daniel Gibson
e8a1eb8baf Fix mouse remaining ungrabbed when running map from Radiant 2022-05-18 04:01:33 +02:00
Daniel Gibson
a363ab4e31 Update version to 1.5.2rc1
.. and fix a link in the changelog
2022-05-16 17:44:15 +02:00
Daniel Gibson
c22965bf58 Work around assertion in alphalabs4, fix #409
In the savegame from that bugreport, "monster_zsec_shotgun_12" was
lying dead pretty much at its spawn point.
script/map_alphalabs4.script moves those "ride_of_death" platforms
around, and at the end of a cycle teleports "ride_of_death*_parent" back
to its starting position - and the "ride_of_death*" bound to it, which
is a pushing mover, just gets dragged along by the physics code and thus
can collide with that zombie cadaver, which then tries to push it along,
causing that assertion in TestHugeTranslation().
This is a map bug - Doom3 even prints a warning:
 WARNING: script/map_alphalabs4.script(722): Thread
  'map_alphalabs4::RideOfDeathPath': teleported 'ride_of_death2_parent'
  which has the pushing mover 'ride_of_death2' bound to it
So I just disable that assertion for this specific case..
Also moved the assertion behind the corresponding warning, so that gets
printed before the assertion kills the game..

Also a small change to CMakeLists.txt that should make enabling
LINUX_RELEASE_BINS after CMake has already been run without it work
2022-05-16 05:43:47 +02:00
Daniel Gibson
adad73cda7
CMake: Fix typo in MSVC-specific CPU detection for x64 2022-02-27 00:37:31 +01:00
Daniel Gibson
699779e9ca Make window alpha chan opaque on Wayland, fix #426
For some reason Wayland thought it would be clever to be the only
windowing system that (non-optionally) uses the alpha chan of the
window's default OpenGL framebuffer for window transparency.
This always caused glitches with dhewm3, as Doom3 uses that alpha-chan
for blending tricks (with GL_DST_ALPHA) - especially visible in the main
menu or when the flashlight is on.
So far the workaround has been r_waylandcompat which requests an OpenGL
context/visual without alpha chan (0 alpha bits), but that also causes
glitches.
There's an EGL extension that's supposed to fix this issue
(EGL_EXT_present_opaque), and newer SDL2 versions use it (when using
the wayland backend) - but unfortunately the Mesa implementation is
broken (seems to provide a visual without alpha channel even if one was
requested), see https://gitlab.freedesktop.org/mesa/mesa/-/issues/5886
and https://github.com/libsdl-org/SDL/pull/4306#issuecomment-1014770600
for the corresponding SDL2 discussion

To work around this issue, dhewm3 now disables the use of that EGL
extension and (optionally) makes sure the alpha channel is opaque at
the end of the frame.
This behavior is controlled with the r_fillWindowAlphaChan CVar:
If it's 1, this always is done (regardless if wayland is used or not),
if it's 0 it's not done (even on wayland),
if it's -1 (the default) it's only done if the SDL "video driver" is
  wayland (this could be easily enhanced later in case other windowing
  systems have the same issue)

r_waylandcompat has been removed (it never worked properly anyway),
so now the window always has an alpha chan
2022-02-05 16:34:34 +01:00
Daniel Gibson
d09ccb8539 If creating window fails, first try to reduce MSAA level, fix #440
so if someone configured 16x AA on a system that doesn't support it
(like when using AMDs open source driver), 8x will be tried before
falling back to a 640x480 window with no AA at all.
(and then it'll try 4x and then 2x and then no AA at all, and only then
 reducing color depth will start, and even later it'll fall back to
 a small 640x480 window)
2022-01-24 06:00:55 +01:00
Daniel Gibson
815099f833
Changelog: Mention #386
that was an important fix
2022-01-20 14:29:54 +01:00
Daniel Gibson
d34832e4fc Fix Mac build 2022-01-17 15:31:10 +01:00
Daniel Gibson
eff9fd6ac3 GLimp_Init(): Log r_mode and resolution used for creating window 2022-01-16 19:39:35 +01:00
Daniel Gibson
5f3356627e CMake: (Theoretically) support Windows on ARM, try to unify ARM CPU names
I don't have such hardware, so I can't test; I also didn't actually build
dhewm3 (would have to build dependencies for ARM first..), but when
configuring ARM or ARM64 targets for Visual C++ in CMake, that's now
correctly detected in CMake.

Also, now D3_ARCH should always be "arm" for 32bit ARM
and "arm64" for 64bit ARM, also when building with GCC or clang.
2022-01-16 18:17:39 +01:00
Daniel Gibson
67d0b7cf01 dhewm3log.txt for Windows, update changelog
I was lazy and just renamed SDL_win32_main's stdout.txt - but I still
added the dhewm3log-old.txt backup function.

I also renamed Sys_GetHomeDir() to Win_GetHomeDir() as it's Win32-only

On Windows it's in Documents\My Games\dhewm3\dhewm3log.txt
2022-01-16 18:17:39 +01:00
Daniel Gibson
5438c9409f dhewm3log.txt for AROS
basically the same as for POSIX, except I don't know where the
save dir is. I hope this works, can't test it myself..
2022-01-16 06:12:51 +01:00
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
4f74c15afe Make sure MAX_OSPATH has sane size; fix some typos 2022-01-16 06:02:40 +01:00
Daniel Gibson
d679e393c3 Add D3_(v)snprintfC99() for C99-compatible implementations
These are now used by idStr::(v)snPrintf(), and in the future can
be used if a (v)snprintf() that's guaranteed not to call
common->Warning() or similar is needed (e.g. used during early startup)
2022-01-10 04:06:54 +01:00
Daniel Gibson
ae63021d00 Add absolute mouse mode and refactor mouse grabbing code
There were lots of places in the code that called Sys_GrabInput(),
some of them each frame.
Most of this is unified in events.cpp now, in handleMouseGrab() which
is called once per frame by Sys_GenerateEvents() - this makes reasoning
about when the mouse is grabbed and when not a lot easier.
Sys_GrabInput(false) still is called in a few places, before operations
that tend to take long (like loading a map or vid_restart), but
(hopefully) not regularly anymore.

The other big change is that the game now uses SDLs absolute mouse mode
for fullscreen menus (except the PDA which is an ugly hack), so the
ingame cursor is at the same position as the system cursor, which
especially helps when debugging with `in_nograb 1` and should also help
if someone wants to integrate an additional GUI toolkit like Dear ImGui.
2022-01-10 00:46:32 +01:00
Daniel Gibson
00b58d1f0f Print available displays and mouse position before creating window
to debug issues like "dhewm3 chose wrong fullscreen resolution"
or "dhewm3 started on wrong display"
2022-01-08 18:10:06 +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
3e039ca898 Fix misleading indentation in roq codec.cpp 2022-01-08 16:59:10 +01:00
Daniel Gibson
ea781c577e Use idStr::Copynz() instead of strncpy()
to guarantee \0-termination
2022-01-08 16:58:48 +01:00
Daniel Gibson
df0916ecf8 Mac: Fix RAM detection for >2GB
Sys_GetSystemRam() for OSX used some deprecated MacOS function from 1989
that used int32 for the amount of bytes.
Now using sysctl() instead, should be supported since at least 10.2.8
at least it's in
https://github.com/phracker/MacOSX-SDKs/blob/master/MacOSX10.2.8.sdk/usr/include/sys/sysctl.h
2022-01-08 16:07:22 +01:00
Daniel Gibson
5becb2d14d
README: Recommend vcpkg for Windows, Update Mac instructions
https://github.com/microsoft/vcpkg/issues/18098 has been resolved

Apparently Homebrew (package manager for macOS) has changed their install directories, mention that
(thanks to @rullinoiz for pointing that out in #433)
2022-01-05 03:26:46 +01:00
Felipe Woods
8e0d28374d Prevent user from running dhewm3 as root. 2021-12-16 23:08:09 +01:00
Daniel Gibson
dcbe0b172e Print SDL2 "video driver" at startup 2021-11-21 03:13:35 +01:00
Daniel Gibson
4b97bbca00 Update stb_vorbis to v1.22 and stb_image to v2.27
.. the latest releases.
Fixes sound issues on macOS/intel

While I was at it, updated stb_image as well
2021-10-31 06:14:59 +01:00
David CARLIER
3bf55225ab SDL backend, macOs warning build fixes proposal. 2021-10-30 23:55:31 +02:00
Daniel Gibson
0958d8464a CMakeLists.txt: Make D3_ARCH/dumpmachine output prettier
the newline in ${cc_dumpmachine_out} was a bit ugly
2021-10-12 19:59:40 +02:00
Daniel Gibson
ad327d34d1 Add support for GL_ATI_separate_stencil
glStencilOpSeparateATI() should behave exactly the same as
glStencilOpSeparate() so supporting it is easy enough and might help
some people with hardware or drivers that don't support OpenGL 2.0,
like the Mac OSX versions for PPC.
2021-10-12 19:32:32 +02: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
443802b683 Fix D3_ARCH (work around CMake being useless)
CMAKE_SYSTEM_PROCESSOR used to be broken, CMake "fixed" it by redefining
its meaning (from "Target CPU" to "Host CPU except when crosscompiling").
On Windows it always prints the host CPU, on Linux it at least made trouble
in chroots and when running 64bit kernels with 32bit userlands (this used
to be not totally uncommon on x86 before distros completely switched to
amd64, and apparently Raspbian/Raspberry Pi OS does this on RPi4, see #267)

Thankfully gcc and clang support "-dumpmachine" to print their (default)
target system, so use that instead (MSVC already had a special case).
On the upside, this allows getting rid of the MinGW special case.
I hope this also works with Apple Clang..
2021-09-13 09:10:11 +02:00
SiliconExarch
f6bfdd16f9 Fix runtime assert on PPC OS X
Passing the -mone-byte-bool flag when building for PPC on OS X overrides the defaults so that sizeof( bool )==1
2021-08-26 22:56:45 +02:00
Daniel Gibson
78eef43d50 Fix rendering of mars globe in main menu with some drivers
The problem was that negative values (from dhewm3tmpres.xyz) were passed
to POW, and POW doesn't have to support negative bases, according to
ARB_fragment_program.txt, and Intels Linux drive apparently doesn't,
see also https://gitlab.freedesktop.org/mesa/mesa/-/issues/5131

Using MUL_SAT instead of MUL to clamp the value that gets passed to POW
afterwards to [0, 1] fixes the problem without any disadvantages.
2021-08-17 19:43:01 +02:00