Commit graph

776 commits

Author SHA1 Message Date
Daniel Gibson
07da116640 Fix debugger resume 2021-06-19 21:30:26 +02:00
HarrievG
d455ac5223 - set com_editors appropiately when debugger forces connection. 2021-06-19 21:30:26 +02:00
HarrievG
5260de58c4 - fixed command line arguments for game when debugger client launches it. 2021-06-19 21:30:26 +02:00
HarrievG
d7be3964d4 - always accept debugger messages from loopback 2021-06-19 21:30:26 +02:00
HarrievG
02dcd00788 - Hide game window when launching script debugger 2021-06-19 21:30:26 +02:00
HarrievG
8a455c3c7a - Debugger server can be toggled with : com_enableDebuggerServer [1 / 0]
- Added com_dbgClientAdr for debugger server to connect to
- Added com_dbgServerAdr for the debugger client to connect to
2021-06-19 21:30:26 +02:00
Daniel Gibson
c2b34e6fe8 Remove idBitMsg::Read/WriteInt64() again
not used anymore
2021-06-19 21:30:26 +02:00
Daniel Gibson
0b644a1648 Fix crashes on shutdown
idCommonLocal::VPrintf() wanted to call session->UpdateScreen() even though
the renderer was in the process of being shut down and that caused crashes
2021-06-19 21:30:26 +02:00
Daniel Gibson
2cff2ae137 DebuggerServer: should now also work with SDL1.2 2021-06-19 21:30:26 +02:00
Daniel Gibson
6b6b28a401 Make DebuggerServer portable (use SDL instead of WinAPI) 2021-06-19 21:30:26 +02:00
HarrievG
85167fa180 - fixed deadlock fix for debugger server 2021-06-17 05:44:23 +02:00
HarrievG
3ce93c7749 - Debuggersever now always builds, but is disabled by default in runtime.
- use com_enableDebuggerServer=1 to enable debugger server.
2021-06-17 05:44:23 +02:00
HarrievG
5ff3b0b9ee - fixed wierd bracked position 2021-06-17 05:44:23 +02:00
HarrievG
99ca9f0543 - D3XP debugger fixes 2021-06-17 05:44:23 +02:00
HarrievG
5ebda5eab5 - removed clientside use of mBreakprogram ptr 2021-06-17 05:44:23 +02:00
HarrievG
cd9284d876 - Debugger is guarded behind tools. 2021-06-17 05:44:23 +02:00
HarrievG
a8709206d8 - Whitespace fix 2021-06-17 05:44:23 +02:00
HarrievG
46157857b5 - Always write 64b program pointer 2021-06-17 05:44:23 +02:00
HarrievG
7f7ed7e45f - Removing ugly (and wrong) include hack for SDL on MSCV+VCPKG.
This has been resolved anyway, and should never been submitted.
2021-06-17 05:44:23 +02:00
HarrievG
af5f395256 - Putting back the "Original by Raven" texts 2021-06-17 05:44:23 +02:00
HarrievG
5e27330233 - 64bit debugger fixes 2021-06-17 05:44:23 +02:00
HarrievG
7a2ccee330 debugger 2021-06-17 05:44:23 +02:00
Daniel Gibson
c212148d41 Remove R_LockSurfaceScene(), clean up temporary changes
R_LockSurfaceScene() isn't used anymore, surface locking is implemented
differently (so it actually works now :-p)
2021-06-15 03:27:52 +02:00
Daniel Gibson
a11b2d352c r_lockSurfaces: Make mirrors look only a bit broken
it's still not great, but at least they don't float around anymore
2021-06-15 03:27:52 +02:00
Daniel Gibson
633ce814ca r_lockSurfaces: Cleaner handling of view matrix creation etc 2021-06-15 03:27:52 +02:00
Daniel Gibson
907fc5771b Disable r_useScissor when r_lockSurfaces is active 2021-06-15 03:27:52 +02:00
Daniel Gibson
d17fa6b2b6 Fix rendering of ingame GUIs with r_lockSurfaces 1 2021-06-15 03:27:52 +02:00
Daniel Gibson
dcb933efb5 Fix rendering HUD with r_lockSurfaces 1
only override cmd->viewDef in RB_DrawView() if we're drawing the
primary view (which for several calculations before actual drawing
was set to the saved/locked render view)

Note that r_lockSurfaces is more useful with r_useScissor 0 (otherwise
there's black bars over the screen when moving) and r_shadows 0 (otherwise
areas that weren't visible when locking are black because the lights
there are skipped)

remaining bug: gui surfaces move around the screen when looking around
2021-06-15 03:27:52 +02:00
Daniel Gibson
1a6998781b Make r_locksurfaces kinda work
refs #357
2021-06-15 03:26:44 +02:00
Daniel Gibson
1aedbe7dd8 Fix build if libbacktrace is not installed, update README
set(CMAKE_REQUIRED_LIBRARIES backtrace) tells our custom libbacktrace
availability check that it needs to link against libbacktrace.
Seems like it also tells other unrelated compiler-checks like for
-fvisibility=hidden to link against libbacktrace, so if it's not
available they fail as well.
Fixed by unsetting CMAKE_REQUIRED_LIBRARIES after the backtrace check.

While debian-based distros ship libbacktrace as part of libgcc,
apparently in Arch Linux and openSUSE (and possibly others) it's a
separate package, so I mantion it in the README as an (optional)
dependency now and made CMake print a warning if it's not found.
2021-06-03 01:38:17 +02:00
Daniel Gibson
2521c3dfdb (Hopefully) better workaround for miscompiled cross products, #147
according to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100839
the real compiler flag enabling this bullshit isn't
-fexpensive-optimizations but -ffp-contract=fast which for some(*)
reason is default in optimized builds.
I think it's best to disabled that optimization globally in case it
also breaks other code (I really don't want to spend several days to
hunt such an idiot bug again). I really doubt it makes any measurable
performance difference.
As https://twitter.com/stephentyrone/status/1399424911328874499 says
that clang might also enable this in the future (though to =on instead
of =fast which should be a bit saner but would still break our code),
just set this option for all GCC-ish compilers incl. clang.

(*) the reason of course is that GCC developers don't develop GCC for
    their users but to win idiotic SPEC benchmarks
2021-05-31 21:37:31 +02:00
Daniel Gibson
320c15f63a Fix dmap bug if compiled with GCC and x86 FMA enabled
Only happend if `ONATIVE` was enabled (or some other flag was set
that enables the FMA extension), the root cause was that the cross
product didn't return 0 when it should, but a small value < 0.
Caused some faces to be missing in maps compiled with dmap.
https://github.com/RobertBeckebans/RBDOOM-3-BFG/issues/436#issuecomment-851061826
has lots of explanation.

I think this is a compiler bug, this commit works around it.

fixes #147
2021-05-31 02:03:46 +02:00
Daniel Gibson
0b28322500 Fix loading .ASE models with no materials
The "A Place of Malice" custom map has such a model which caused a crash
(models/z13sp2/temple/pushable_collision_box.ASE), see #382
2021-05-19 02:48:31 +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
b054261a0e Make MFC Tools work with MSAA enabled
The problem was that the editors called ChoosePixelFormat() instead of
wglChoosePixelFormatARB() - and the normal ChoosePixelFormat() has no
attribute for MSAA, so if MSAA is enabled (by SDL2 which calls the wgl
variant), ChoosePixelFormat() will return an incomaptible format and
the editors don't get a working OpenGL context.
So I wrote a wrapper around ChoosePixelFormat() that calls the wgl variant
if available, and all the necessary plumbing around that.

While at it, removed the unused qwgl*PixelFormat function pointers and
supressed the "inconsistent dll linkage" warnings for the gl stubs
2021-05-11 00:39:00 +02:00
Daniel Gibson
c3d480afe4 Rename GetWindowScalingFactor() to Win_GetW.., support older Win versions
Minimum required Windows version is XP again (instead of Win10).
Win_GetWindowScalingFactor() tries to use two dynamically loaded functions
from newer windows versions (8.1+, Win10 1607+) and has a fallback for
older versions that also seems to work (at least if all displays have
the same DPI).

Moved the function to win_main.cpp so the dynamically loaded functions
can be loaded at startup; so edit_gui_common.cpp could be removed again.
2021-05-10 03:18:24 +02:00
HarrievG
e67b77ba5d - Wrapped GetDpiForWindow in GetWindowScalingFactor
- Use GetDeviceCaps for dpi on anything else than win10.
2021-05-10 01:09:47 +02:00
HarrievG
67d325cc61 update cmake
- Upped windows version ( needs to go back, and a runtime dpi check comes in place )
- Changed warning settings for msvc to confirm latest compilers
- Fixed up _afxdll
2021-05-10 01:09:47 +02:00
HarrievG
86866b73d5 - 4K / DPI aware Tool fixes
- Nullptr guard/Crashfix in material editor : meMainFrame can be null
  when starting immedeatly from commandline.
2021-05-10 01:09:47 +02:00
Daniel Gibson
981857f067 Fix PDAEditor (editPDAs opens it now), #378 2021-05-09 20:20:18 +02:00
Daniel Gibson
2dc2d3adb5 Fix "Save as" in Particle Editor
In idDeclManagerLocal::CreateNewDecl() decl->self->DefaultDefinition();
crashed because self was uninitialized.
Now it gets set to NULL in the constructor and initialized to something
sensible in decl->AllocateSelf();

this is part of #378
2021-05-08 21:05:56 +02:00
Daniel Gibson
5f137955ac Make rvGEWindowWrapper (for GUI editor) 64bit clean
it wants to store a pointer to itself in an idWinVar - on 32bit idWinInt
was suitable for that, on 64bit it's not, so instead convert the pointer
to a hex-string and stuff it in a idWinStr

also fix a crash when adding a choiceDef in the gui editor
2021-05-08 07:03:55 +02:00
Daniel Gibson
e1c9e7a351 MSVC: Treat pointer truncation warnings as errors, adjust idCVar for that
All pointer<->integer conversion truncation warnings I'm aware of are
now enabled for MSVC, to hopefully finally get that tool code 64bit-clean.

I had to adjust the idCVar code for this - it should've been safe enough
(highly unlikely that a valid pointer is exactly 0xFFFFFFFF on 64bit),
but triggered those warnings - now it should behave the same as before
but the warnings (which are now errors) are silenced.

The only thing that still prevents dhewm3 from building with these
warnings-as-errors is rvGEWindowWrapper
2021-05-08 05:54:42 +02:00
Daniel Gibson
5dc9b69374 Fix most (according to warnings) remaining 64bit issues in tool code
rvGEWindowWrapper is still TODO - it's not as straightforward, because
it insists on storing a pointer in an idWinVar (using idWinInt), but there
is no idWinVar type for pointers
2021-05-08 05:43:52 +02:00
raynorpat
bd37c3f91a Some additional LONG to LONG_PTR fixes for the tools as well as some warning fixes 2021-05-07 16:06:06 -04:00
raynorpat
d4c3d4a9df Resolve Win32-isms trying to build tools with x64 MSVC 2021-05-06 03:31:56 +02:00
Daniel Gibson
409dd8e3d9 Fix crash if both image_useCache and image_downSize are 1
the commented out code clamped the loaded filesize of affected .dds
images (crash observed with dds/guis/assets/splash/pdtempa.dds) to
200KB - but then later tries to load it and skip the first mipmap,
resuling in reading invalid memory (> 200KB into the file).
No idea what this was supposed to achieve, but it's disabled now
and the crash (at startup) is gone.

fixes #374
2021-04-28 00:04:24 +02:00
Daniel Gibson
5f346c7355 Add s_alReverbGain CVar to reduce intensity of reverb effects, fix #365
It can be set to a value between 0.0 and 1.0.
1.0 sounds like it did before introducing this cvar; as many people
found the the effect way to strong, I made 0.5 the default value
2021-04-27 20:08:59 +02:00
Daniel Gibson
954ff88759 Properly pause sounds when entering menu, fixes #330
Otherwise especially looped sounds continue playing while the menu
is open, especially noticeable when opening the menu while firing
the chaingun (the whirring sound continues playing).
2021-04-27 20:08:59 +02:00
Daniel Gibson
1b61053c53 idSoundSample::Load() uses s_decompressionLimit for oggs again
The code to decompress OGG files directly on load if they're shorter
than s_decompressionLimit seconds (usually 6) accidentally got broken
when removing the non-OpenAL soundbackends:
`if ( objectInfo.wFormatTag == WAVE_FORMAT_TAG_OGG )` slipped into the
`if ( objectInfo.wFormatTag == WAVE_FORMAT_TAG_PCM )` block - obviously
both can't be true at the same time so the OGG case was never executed.
Now it's in its own block again. I put it into a {} scope so it doesn't
have to be re-indented (=> more useful with git blame)
2021-04-27 20:08:59 +02:00
Daniel Gibson
1c13fe2d39 Use stb_vorbis instead of libogg and libvorbis(file)
Seems to work; note that idWaveFile is only ever used in idSoundSample::Load()

As stb_vorbis doesn't support custom callbacks for reading, I feed it
the full .ogg files as a buffer. Shouldn't make much of a difference
though - either the whole file is decoded on load anyway (so the buffer
is freed after decoding, or it's streamed, but in that case the old code
also kept the whole ogg file in memory by using idFily_Memory.

I also added warning messages in places where calls to stb_vorbis_*()
can fail, where there were none in the equivalent libvorbis code.
2021-04-27 20:08:59 +02:00
Daniel Gibson
1ae268a20e Fix stb_vorbis failing to load .ogg files without comments
fix taken from https://github.com/nothings/stb/pull/1095
2021-04-27 20:08:59 +02:00
Daniel Gibson
c1c8de214a Add stb_vorbis so it can replace libogg/vorbis(file)
from https://github.com/nothings/stb/

renamed it from .c to .h so build systems don't get confused.
2021-04-27 20:08:59 +02:00
Daniel Gibson
b0e0883f6e Replace libjpeg with stb_image.h
libjpeg is a pain in the ass, especially due to Ubuntu shipping
libjpeg-turbo in jpeg8 mode as their default libjpeg, while every other
distro I checked (including debian!) ships libjpeg-turbo in jpeg6.2 mode

Thankfully stb_image.h exists - just a single header and it even
has a (much!) friendlier API.

It's not like Doom3 (or any of the mods I checked) actually use JPEGs,
but I'm sure if I'd drop support completely, someone would complain
(perhaps rightfully so).
2021-04-27 20:08:59 +02:00
Daniel Gibson
bb7346579e GLimp_Init() Print actually received color/alpha/stencil/depth bits
to help debugging #368 and #348
2021-04-24 20:27:16 +02:00
Daniel Gibson
13ac657ebf Make deleting listenerSlot in idSoundWorldLocal::Shutdown() work
the problem was that the sources were still associated to it, because
they get deleted after the listenerSlot: the sources get freed in
idSoundSystemLocal::Shutdown() which is called by
idCommonLocal::ShutdownGame() in line 3217,
while the listenerSlot is deleted via idSessionLocal::Shutdown()
-> delete sw/rw -> idSoundWorldLocal::~idSoundWorldLocal()
-> idSoundWorldLocal::Shutdown() - and idSessionLocal::Shutdown() is
called in idCommonLocal::ShutdownGame() line 3211, before the other.

I'm not gonna mess with the order of deleting things in ShutdownGame(),
but it's sufficient to unassociate the effect slot from the source
when destroying the emitters in idSoundWorldLocal::Shutdown(),
by adding a call for that to idSoundChannel::ALStop() - and destroying
the emitters before deleting listenerSlot.

Before this fix, with ALSOFT_LOGLEVEL=3 you got the following warning:
  (WW) Error generated on context 0x5578fce2a280, code 0xa004,
  "Deleting in-use effect slot 1"
Thanks for openal-soft's KittyCat for pointing this out!
2021-04-12 19:17:12 +02:00
Turo Lamminen
9c6b835f16 Fix uninitialized members of drawInteraction_t in RB_CreateSingleDrawInteractions 2021-04-12 19:13:39 +02:00
Turo Lamminen
cbd59321a8 Fix uninitialized members in idSoundWorldLocal 2021-04-12 19:13:39 +02:00
Daniel Gibson
81a8611aba
Merge pull request #342 from turol/warnings
Fix some warnings
2021-04-08 17:22:33 +02:00
Daniel Gibson
5adff43c6f Update ENGINE_VERSION to 1.5.2pre 2021-04-08 04:13:08 +02:00
Turo Lamminen
7aee2af217 Silence misleading indentation warnings 2021-03-15 13:02:45 +02:00
Turo Lamminen
8cfeb51b84 Silence an uninitialized variable warning 2021-03-15 13:02:45 +02:00
Turo Lamminen
1ae9ff7d74 Don't use memset to zero non-trivial type volumeIntegrals_t 2021-03-15 13:02:45 +02:00
Turo Lamminen
59940c9b2f Don't memcpy non-trivial type idDrawVert in idSurface constructor 2021-03-15 13:02:45 +02:00
Turo Lamminen
8d2d41345d Don't use memset in idMat6::Zero 2021-03-15 13:02:45 +02:00
Turo Lamminen
30175c72ae Be more careful with memcpy in idMat6 constructor 2021-03-15 13:02:45 +02:00
Turo Lamminen
669e259787 Don't use memset in idMat5::Zero 2021-03-15 13:02:45 +02:00
Turo Lamminen
6a7bb7e305 Don't use memcpy in idMat5 constructor 2021-03-15 13:02:45 +02:00
Turo Lamminen
8fa3793410 Don't use memset in idMat4::Zero 2021-03-15 13:02:45 +02:00
Turo Lamminen
57f09de425 Don't use memcpy in idMat4 constructor 2021-03-15 13:02:45 +02:00
Turo Lamminen
37ed3e9e46 Don't use memset in idMat3::Zero 2021-03-15 13:02:45 +02:00
Turo Lamminen
c67c455180 Don't use memcpy in idMat3 constructor 2021-03-15 13:02:45 +02:00
Turo Lamminen
df9d8cf0ce Don't use memcpy in idMat2 constructor 2021-03-15 13:02:45 +02:00
Daniel Gibson
c0421c9e0f Set ENGINE_VERSION to 1.5.1, remove usage of C++11 nullptr 2021-03-14 03:43:58 +01:00
Stradex
f2239c75da fix: cdkey check now properly disable in clients 2021-03-08 17:56:26 +01:00
Daniel Gibson
d54ccee1f5 Update date for reproducible builds for 1.5.1 RC3 2021-02-22 03:18:34 +01:00
Daniel Gibson
891f8720fc Fix Win32/VS build on Win64 hosts
Turns out that ${CMAKE_SYSTEM_PROCESSOR} is broken on Windows
(both for Visual Studio and for 32bit MinGW/msys shells which for some
 reason seem to output x86_64 in uname -a)

Also suppressed -Wclass-memaccess warnings from GCC >= 8
2021-02-22 02:48:39 +01:00
Daniel Gibson
4bd46b3e28 Fix player's clipModel->axis when loading savegame, fixes #328
idClipModel::axis is an idMat3 rotation matrix.
Usually it's an identity matrix, but if the player is pushed around by
an idPush entity it's modified and apparently can (wrongly) remain
modified, possibly when saving while idPush is active.
This seems to happen sometimes on the crashing elevator in game/delta1.
The fix/workaround is to reset it to mat3_identity when loading a
savegame.
2021-02-21 06:05:47 +01:00
Daniel Gibson
1b2baf43ad Add information about dhewm3 build to savegames
like the dhewm3 version and the OS and architecture of the dhewm3
version that created the savegame.
Also added an internalSavegameVersion so be independent of BUILD_NUMBER

fixes #344
2021-02-21 06:05:47 +01:00
Daniel Gibson
2c58b2fb44 Fix savegame-compatibility of scripts, increase BUILD_NUMBER
"Fix "t->c->value.argSize == func->parmTotal" Assertion in Scripts, #303"
had broken old savegames because the script checksum
(idProgram::CalculateChecksum()) changed, see #344.
This is fixed now, also the BUILD_NUMBER is increased so old savegames
can be identified for a workaround.

Don't use this commit without the next one which will further modify the
savegame format (for the new BUILD_NUMBER 1305)
2021-02-21 06:05:47 +01:00
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
Tobias Frost
8c699cd030 s/referneces/references 2021-01-15 18:00:25 +01:00
Boris I. Bendovsky
fa51007a6f Calculate EFX occlusion as in Creative's EFX-Util 2021-01-15 17:57:39 +01:00
Boris I. Bendovsky
432b86fdeb Calculate EFX density as in EFX-Util 2021-01-15 17:57:17 +01:00
Daniel Gibson
7297ebcaf6 Fix fonts on Big Endian systems, fixes #148
The code used #ifdef __ppc__, probably a leftover from old Mac support,
which apparently doesn't work on all PPC systems (maybe not 64bit PPC).

Now using the LittleFloat() function instead which exists for
exactly this purpose and already handles endianess properly.
2021-01-14 12:25:22 +01:00
Petter Uvesten
bbe30e300c Enable building on Apple Silicon 2020-11-02 06:01:02 +01:00
Daniel Gibson
c4c7236352 Fix "t->c->value.argSize == func->parmTotal" Assertion in Scripts, #303
If a "class" (object) in a Script has multiple member function
prototypes, and one function implementation later calls another before
that is implemented, there was an assertion when the script was parsed
(at map start), because the size of function arguments at the call-site
didn't match what the function expected - because the function hadn't
calculated that size yet, that only happened once its own
implementation was parsed.
Now it's calculated (and stored) when the prototype/declaration is
parsed to prevent this issue, which seems to be kinda common with Mods,
esp. Script-only mods, as the release game DLLs had Assertions disabled.
2020-09-05 20:46:01 +02: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
12fa3eb814 Disable broken idSIMD_SSE::UpSampleOGGTo44kHz()
It corrupted the stack when called with buffers allocated on the stack
and numSamples that are not a multiple of four, apparently, by writing
4 floats too many, at least in the 22KHz Stereo case..

This caused the crash described in
  https://github.com/dhewm/dhewm3/issues/303#issuecomment-678809662

Now it just uses the generic C code, like all platforms besides MSVC/x86
already do.
2020-09-05 20:28:03 +02:00
Daniel Gibson
8b66bad68f Windows/VS: Fix Build with VS2019 integrated CMake, set startup project
Apparently VS2019 (or its integrated CMake?) interpreted
add_definitions(/MP) as "also pass it to rc.exe" which didn't like it..
no idea why this worked before, but now it seems to work everywhere.
fix #304

Also set VS_STARTUP_PROJECT so when launching the debugger in VS it doesn't
try to launch ALL_BUILD (...) but dhewm3.
2020-08-02 04:41:45 +02:00
Daniel Gibson
7d2bda07a3 Don't use translation in Autosave filenames, fixes #305
idSessionLocal::SaveGame() uses saveName for both the description in
savegames/bla.txt and the filename itself ("bla" in this case), which
is a "scrubbed" version of that string ("file extension" removed,
problematic chars replaced with '_').
In case of Autosaves, MoveToNewMap() passes a translated name of the
map as saveName, which makes sense for the description, but not so much
for the filename.
In Spanish the Alpha Labs names are like "LAB. ALFA 1", "LAB. ALFA 2" ..
and everything after "LAB" is cut off as a file extension - so every
autosave of an Alpha Labs part overwrites the last one, as they all get
the same name...

The solution is to pass an additional (optional) argument saveFileName
to idSessionLocal::SaveGame(), and for autosaves pass the mapname
(which is the filename without .map; yes, it might contain slashes,
but the scrubber will turn them into _) instead of the translated name
as saveFileName.
2020-08-02 03:48:25 +02:00
Daniel Gibson
d708fbd974 Fix lingering messages in HUD after loading savegame
If you save, you get a message like "Game Saved..." which goes away
after a few seconds. This happens at the very end of idPlayer::Save():
    if ( hud ) {
        hud->SetStateString( "message", /* .. left out .. */ );
        hud->HandleNamedEvent( "Message" );
    }
And handled in hud.gui, "onNamedEvent Message { ..."

However, if you save again before it's gone, it'll be shown after
loading the savegame and not go away until you save again..
This works around that issue by setting an empty message after loading
a savegame.

The underlying problem (which is not fixed!) seems to be that the
transition GUI command (that's executed when hud.gui handles the
"Message" event that's used to show this message) is probably not
properly saved/restored so fading out the message isn't continued
after loading.
2020-07-27 03:39:12 +02:00
Daniel Gibson
d98fd2739f 1.5.1 RC2 2020-07-21 15:01:15 +02:00
Daniel Gibson
aa77e49de7 Fix handling of paths with dots in dir names, fix #299, #301
idStr::StripFileExtension() (and SetFileExtension() which uses it) and
others didn't work correctly if there was a dot in a directory name,
because they just searched from last to first char for '.', so if the
current filename didn't have an extension to cut off, they'd just cut off
at any other '.' they found.
So D:\dev\doom3.data\base\maps\bla could turn into D:\dev\doom3
(or, for SetFileExtension(), D:\dev\doom3.map)

While at it, I made most of the idStr code that explicitly checked for '\\'
and '/' (and maybe ':' for AROS) use a little "bool isDirSeparator(int c)"
function so we don't have the #ifdefs for different platforms all over
the place.
2020-07-21 05:58:44 +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
Daniel Gibson
31e26856e0 (Hopefully) fix Editors messing up game viewport for good, fix #300
I worked around the issue for the particle editor, but now it turned out
it can also somehow happen when switching from the Radiant to the Engine
(with F2), so I implemented the "proper" fix of restoring
glConfig.vidWidth/Height, that are overwritten in
RenderSystemLocal::BeginFrame(), in RenderSystemLocal::EndFrame().
2020-07-20 05:01:51 +02:00
Daniel Gibson
28e83b27a1 Make sure / or C:\ doesn't get search by idFileSystemLocal::ListMods()
That could happen if the searchpath was "" (like the default value of
fs_cdpath ...).
I don't think it could do any damage, but it's confusing (if "developer"
CVar is enabled) and pointless.
It caused lots of "Non-portable: path contains uppercase characters: .."
Warnings, which now also become more readable by adding a newline.
2020-07-20 02:19:11 +02:00
Dave Nicolson
3e8601e925 Restore deleted file 2020-07-19 16:18:35 +02:00
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