Commit graph

285 commits

Author SHA1 Message Date
Daniel Gibson
8ff66b7eab 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.
2021-01-18 03:42:58 +01:00
Daniel Gibson
e957bd3460 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.
2021-01-18 03:42:58 +01:00
Daniel Gibson
273b1d4a4f 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.
2021-01-18 03:42:58 +01:00
Daniel Gibson
cad0660add 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.
2021-01-18 03:42:58 +01:00
Daniel Gibson
912f2d6dd7 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).

(This includes "Fix ID_MAYBE_INLINE on non-Windows platforms")
2021-01-18 03:42:58 +01:00
Daniel Gibson
c921508eef MSVC: Shut up Compiler warning in Matrix.h if asserts are disabled 2021-01-18 03:42:58 +01:00
Daniel Gibson
a9f0df28c0 Port CMake-changes that were added to dhewm3 since the SDK was created
Make source files listing in VS usable (incl. fallback for old CMake)
CMake: Fix build in path with spaces
2021-01-18 03:42:58 +01:00
Daniel Gibson
ddc635a03c Hopefully fix "shooting arrows at Dead Souls" freezing game (Rivensin)
For some reason the idMoveableArrow's animator didn't have a modelDef,
which caused masterAnimator->GetJointTransform() to return immediately
without setting masterAxis or masterOrigin - so they contained garbage
data which lead to NaNs which lead to trouble.

I check for that issue now to make sure they're initialized, but I'm not
100% sure this is a proper fix - the underlying issue is that this
animator has no modelDef. Is that bad? Could it create other issues?
No idea.
2021-01-18 03:42:58 +01:00
Daniel Gibson
4c6341ed3d idProjectile::Launch() warns about missing snd_tracer 2021-01-18 03:42:58 +01:00
Daniel Gibson
522a8fc330 Bugfix from Rivensin: idAnimState::Save() checks if(animator != NULL)
at least in Rivensin this caused crashes, possible that it causes
trouble here as well (Rivensin is based on Dentonmod after all)
2021-01-18 03:42:58 +01:00
Daniel Gibson
4a2d4751ac (Hopefully) fix one of the assertions rarely happening in Rivensen
I hope I guessed this right: This could prevent the rare assertion
in RenderWorld.cpp:954 ("bounds[0][0] <= bounds[1][0]
  && bounds[0][1] <= bounds[1][1] && bounds[0][2] <= bounds[1][2]").
2021-01-18 03:42:58 +01:00
Daniel Gibson
f0ff1f878d Fix another arrow-shooting Assertion (from Rivensin) 2021-01-18 03:43:40 +01:00
Daniel Gibson
351a1744a7 Fix Assertion in Engine when shooting Arrows (from Rivensin)
it was caused by decals of size 0 (when the arrow hits the floor)

at least in Rivensin this caused trouble, so it seems likely that it's
responsible for some of the reported Dentonmod crashes as well
2021-01-18 03:42:58 +01:00
Daniel Gibson
aa0e2268bc Increase Script MAX_GLOBALS in game/
It's the same value d3xp uses and thus probably a better default for
mods.
2021-01-18 03:11:54 +01:00
Daniel Gibson
aaec7be627 CMake 2.8 is sufficient
this way I can build it in my wheezy chroot for release binaries
without upgrading cmake there.
2018-12-15 04:31:19 +00:00
Daniel Gibson
fd514f2281 Fix pot. Crash in idWinding2D::ExpandForAxialBox()
it could happen that i is 1 but numPlanes is still 0
(=> if for i = 0:  ( p[j] - p[i] ).LengthSqr() < 0.01f )
so planes[-1] would be accessed which of course is invalid and can crash
2018-12-09 04:59:20 +01:00
Daniel Gibson
885f594a59 change engine version to "dhewm3 SDK 1.5.x"; no -ffast-math
it's only shown in the g_version CVar, but if we have this constant
in the SDK make it show something sensible.. and this SDK code should
be compatible with all dhewm 1.5.x releases (=> dhewm3 version will
be bumped to 1.6.x if game API compatibility is broken)

Also disabled (GCC/Clang-specific) -ffast-math - even with
 -fno-unsafe-math-optimizations I don't trust it.
2018-11-12 00:31:49 +01:00
Daniel Gibson
50561cfa69 idCommon::SetCallback() + GetAdditionalFunction(); GAME_API_VERSION=9
This is an ugly hack that allows both exporting additional functions
(incl. methods via static function + void* userArg) to Game DLLs
and setting callback functions from the Game DLL that the Engine will
call, without breaking the Game API (again after this change).
This is mostly meant for replacing ugly hacks with SourceHook and
similar and mods (yes, this is still an ugly hack, but less ugly).

See the huge comment in Common.h for more information.

Right now the only thing implemented is a Callback for when images
are reloaded (via reloadImages or vid_restart) - Ruiner needs that.

Also increased GAME_API_VERSION to 9, because this breaks the A[PB]I
(hopefully after the next release it won't be broken in the foreseeable
 future)
2018-09-30 05:44:36 +02:00
Daniel Gibson
66e58d1d32 It builds with VS 2017 now 2018-09-02 01:26:31 +02:00
Daniel Gibson
7bfaf4cbf7 Import Denton's Enhanced Doom3 Mod 2018-08-26 05:41:08 +02:00
Daniel Gibson
4dd278d6fb Make game dll names and compiler defines for mods configurable
so mod authors can tell cmake to call it mymod.dll instead of base.dll
or d3xp.dll

and the compiler defines are also easily configurable now

I also added a comment to EndLevel.cpp, which was released with the GPL
source (and in d3xp/ it already existed in the SDK), but has not been
used to build the dlls.
2018-08-26 04:47:00 +02:00
Daniel Gibson
53db277bae Make it build as SDK
I created this repo from the original dhewm3 repo, but I used
git filter-branch to kill all the files that are not needed to just
build base.dll and d3xp.dll (or .so or .dylib or whatever).
So this is basically just the files the original Doom3 SDK had, but
taken from dhewm3 instead (and thus GPL licensed and patched for
64bit-support etc) + some dhewm3 specific stuff + CMakeLists.txt
to build them.

The git filter-branch details:

filter-branch -f --prune-empty --tree-filter /tmp/killkill.sh @

## /tmp/killkill.sh:

#!/bin/sh

find . -exec /tmp/removeothers.sh {} \;

exit 0

## /tmp/removeothers.sh:

#!/bin/bash

FNAME="$1"

if [[ $FNAME == \./\.git* ]] || [[ $FNAME == \./d3xp/* ]] || [[ $FNAME == \./game/* ]]
then
	#echo "ignoring $FNAME"
	exit 0
fi

if ! grep -Fxq "$FNAME" /tmp/d3sdklist.txt
then
	#echo "REMOVING $FNAME"
	rm -rf "$FNAME"
fi

exit 0

## /tmp/d3sdklist.txt was is just a textfile with one path per line with
   all the files (and directories!) I wanted to keep, like:

.
..
./sys/platform.h
./framework/Game.h
./config.h.in
./CMakeLists.txt
## ... and all the relevant files from the SDK
2018-08-26 01:43:10 +02:00
Yamagi Burmeister
aa40145157 Lower release build optimizations from -O3 to -O2.
In the last few weeks I've played again through the game and kept an eye
on small oddities. And there're a lot of them. For example some GUIs and
videos getting stuck after the first frame (issue #192) or being unable
to protect the guy with the lamp in Alpha Labs 3. Some digging proved
that most - if not all - of these problems are caused by the compilers
optimization level. When build with -O2 both g++ 8.1 and clang 6.0.0 are
producing working code. g++ 8.1 with -O3 has some small, hard to notice
oddities, clang 6.0.0 with -O3 shows a lot of them. Since there's not
measurable difference between -O3 and -O2 just go down to the later:

x doom_o3.txt
+ doom_o2.txt
+----------------------------------------------------------------------+
|                                                               +      |
|                                      +                        *      |
|x                                     *           x            *      |
|                 |_____________________|___A______M__A_________M___|_||
+----------------------------------------------------------------------+

    N        Min           Max        Median           Avg        Stddev
x   5        173           178           177         176.4     2.0736441
+   5        176           178           178         177.2     1.0954451
2018-08-20 01:46:40 +02:00
Tobias Frost
84e5ef45bc Some spelling error fixes found during Debian build
- s/allready/already
- s/Uknown/Unknown
- s/thier/their
2018-08-20 01:46:40 +02:00
Kalamatee
b86dac5719 use the correct extension for x86 2018-08-20 01:46:40 +02:00
Kalamatee
2fb870b13f import AROS changes 2018-08-20 01:46:39 +02:00
Turo Lamminen
ae17dad2f9 Fix idStr self-assignment
Was calling memcpy with overlapping parameters which is inefficient,
undefined behavior and Valgrind complained about it.
2018-08-20 01:46:39 +02:00
Turo Lamminen
db977e6f75 Fix stack overflow in SSE code
This was checking the wrong variable so when count was < 4 it was writing
past the end of buffer and potentially breaking the stack.
2018-08-20 01:46:39 +02:00
David Carlier
45d826d31c make it compilable under openbsd 2018-08-20 01:46:39 +02:00
Daniel Gibson
b8b5f20154 Version 1.4.1 2018-08-20 01:46:39 +02:00
Daniel Gibson
4bb04c13ef 1.4.1 Release Candidate 1 2018-08-20 01:46:39 +02:00
Daniel Gibson
86c634b55c 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)
2018-08-20 01:46:39 +02:00
Daniel Gibson
018e13feef Unix: On failed assertion, break gracefully into debugger
__builtin_trap() causes an illegal instruction and thus the process
can't resume afterwards.
raise(SIGTRAP) only breaks into the debugger and thus allows to
"ignore" the assertion while debugging.
2018-08-20 01:46:39 +02:00
Daniel Gibson
4ad1349113 Fix crash by assert in last RoE level (and maybe elsewhere)
The assertion in idBounds::operator-(const idBounds&) was triggered
from idWeapon::Event_LaunchProjectiles() (ownerBounds - projBounds)
It only happened when using the BFG.
So I added a check to make sure calling operator- is legal.

I guess this also caused #122
2018-08-20 01:46:39 +02:00
leffmann
a5a46de8f9 make d3xp build with Visual Studio 14 2018-08-20 01:46:39 +02:00
leffmann
5baf5deca7 make base build with Visual Studio 14 2018-08-20 01:46:39 +02:00
leffmann
99bbd70af5 make idlib build with Visual Studio 14 2018-08-20 01:46:39 +02:00
Daniel Gibson
746f2cb454 change version number to 1.4.1pre
so hopefully people trying code from git won't report problems (that
might be new) as bugs in 1.4.0
2018-08-20 01:46:39 +02:00
Daniel Gibson
c2a36a8f13 Version 1.4.0
Thanks to all the testers!
Especially from http://idtechforums.fuzzylogicinc.com/
http://www.holarse-linuxgaming.de/ (special thanks to NoXPhasma!)
http://www.quakehaus.com/ and #iodoom3.

Also many thanks to everyone reporting bugs and sending pull requests
over the years.
And dhewg of course for starting this and doing all the hard work :-)
2018-08-20 01:46:39 +02:00
Daniel Gibson
cd87ba09f7 Release Candiate 1 preparations, other small fixes 2018-08-20 01:46:38 +02:00
svdijk
c95cce323a Win32: Add an icon to the dhewm3 executable 2018-08-20 01:46:38 +02:00
Daniel Gibson
c4fdd99443 print "dhewm 3 1.4.0" in the console, not "dhewm 1.4.0"
Thanks for pointing this out, svdijk!
2018-08-20 01:46:38 +02:00
Daniel Gibson
34490bb875 Fix some compiler warnings (wrong types, superfluous checks, printf-fuckup) 2018-08-20 01:46:38 +02:00
Daniel Gibson
5e13e6f36f (Hopefully) fix crashes in MP if r_aspectRatio = -1, fix #70
While I couldn't reproduce the crash, according to the bugreport it
happens if renderSystem->GetScreenWidth()/Height() returned 0 - and
that is indeed the only plausible reason I can imagine for it.

So I check for that case and handle it gracefully by defaulting to
4:3 FOV values.
2018-08-20 01:46:38 +02:00
Daniel Gibson
ff09de0aaa Prepare for 1.4.0 release, make SDL2 default, update README
The version will be 1.4.0 because it's not compatible with
Doom3 1.3.1 mod DLLs.

(Note that this commit doesn't mean 1.4.0 is done, I might do some
 minor changes before tagging the Release!)
2018-08-20 01:46:38 +02:00
Daniel Gibson
7e39919bd5 Remove jpeg_memory_src hack that worked around old libjpeg versions
Because Debian Squeeze's libjpeg6 didn't have jpeg_mem_src(), we added
jpeg_memory_src() to provide the functionality.
This shouldn't be needed anymore and without it we can drop libjpeg code
from our repo.

Fixes #110
2018-08-20 01:46:38 +02:00
Tobias Frost
7b7c7a5238 Fixing some spelling errors: s/unkown/unknown, s/seperate/separate. (#107) 2018-08-20 01:46:38 +02:00
Zohar Malamant
5a9cdc2ed8 fixed potential bug. 2018-08-20 01:46:38 +02:00
Daniel Gibson
b3dc1ee9c6 Replace custom unzip functions with standard ones
unz[SG]etCurrentFileInfoPosition() isn't needed anymore,
because newer minizip versions have unz[SG]etOffset() for
that purpose.
2018-08-20 01:46:38 +02:00
Daniel Gibson
6aea4b59fb Use updated minizip version for unzip
The implementation is now in framework/minizip/*
instead of framework/Unzip.cpp

This was version 0.15beta, now we use 1.1 from
zlib 1.2.7/contrib/minizip

Some code had to be adjusted for this, but it got
cleaner on the way
2018-08-20 01:46:38 +02:00