Commit graph

81 commits

Author SHA1 Message Date
James Addison
8123900e14 Fixup: typo: 'hiehgt' -> 'height' in a few places around the codebase 2024-03-18 23:20:42 +01:00
Daniel Gibson
c8a202a125 Fix/work around other misc. compiler warnings
or, in the case of AF.cpp, at least comment on them

I think this fixes most of the remaining "interesting" GCC 12 on Linux
warnings
2024-03-18 23:20:42 +01:00
Daniel Gibson
3d15ce367b Work around false positive GCC -W(maybe-)uninitialized warnings
shouldn't hurt too much, and the R_IssueEntityDefCallback() code
even is a bit better now
2024-03-18 23:20:42 +01:00
Daniel Gibson
c33612dc19 Fix -Wformat-security warnings - thanks James Addison!
This is based on https://github.com/dhewm/dhewm3/pull/500
by https://github.com/jayaddison

See also https://github.com/blendogames/quadrilateralcowboy/pull/4
2024-03-18 23:20:42 +01:00
Daniel Gibson
fa448d6919 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
2024-03-18 23:20:42 +01:00
Daniel Gibson
627af08602 Fix some ubsan warnings 2024-03-18 23:20:42 +01:00
Daniel Gibson
2307f26577 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)
2024-03-18 23:20:42 +01:00
Daniel Gibson
d0062f4a82 Improve some messages in game code
- TestHugeTranslation() prints positions (and asserts only afterwards),
  from "Work around assertion in alphalabs4, fix #409"
- idCompiler::CompileFile() prints proper filename
  from "Fix usage of invalid pointer in idCompiler::CompileFile()"
2022-05-28 19:15:17 +02:00
Daniel Gibson
a16895aca6 Use idStr::Copynz() instead of strncpy()
to guarantee \0-termination
(only the applicable parts of that dhewm3 commit)
2022-05-28 19:15:17 +02:00
Daniel Gibson
8a38d12237 From dhewm3: Fix most (according to warnings) remaining 64bit issues in tool code
only the TypeInfo changes are applicable to the SDK
2022-05-28 19:15:16 +02:00
Daniel Gibson
853f934abf Remove usage of C++11 nullptr 2022-05-28 19:15:16 +02:00
Daniel Gibson
347679c454 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-22 05:01:03 +01:00
Daniel Gibson
7c7a291f40 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-22 05:01:03 +01:00
Daniel Gibson
16821c07d0 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-22 05:01:03 +01:00
Daniel Gibson
bc9c799d94 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 02:53:35 +01:00
Daniel Gibson
f548573c8d 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 02:53:35 +01:00
Daniel Gibson
8d10759cb7 Increase Script MAX_GLOBALS in game/
It's the same value d3xp uses and thus probably a better default for
mods.
2021-01-18 02:53:35 +01: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
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
2fb870b13f import AROS changes 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
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
5baf5deca7 make base build with Visual Studio 14 2018-08-20 01:46:39 +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
Tobias Frost
7b7c7a5238 Fixing some spelling errors: s/unkown/unknown, s/seperate/separate. (#107) 2018-08-20 01:46:38 +02:00
Daniel Gibson
385a1965e7 Guess x/y FOV/aspectratio from resolution
Added r_aspectratio -1 which means "auto" (as new default).
This mode sets fov_x and fov_y according to screen-width/height.
=> No need to set r_aspectratio manually anymore (assuming your display's
   pixels are about square).

The standard aspect ratios can still be enforced as before, though.
2018-08-20 01:46:37 +02:00
dhewg
8275299d7e More logging cleanup 2018-08-20 01:46:36 +02:00
dhewg
49067a82aa Get rid of Sys_FPU_StackIsEmpty()
Same as with Sys_FPU_GetState().
2018-08-20 01:46:35 +02:00
dhewg
16871256f8 Get rid of Sys_FPU_GetState()
This was only implemented with MSVC style asm.
Comments suggest that it was used to help catch invalid FOV calculations,
which were probably only happening with ancient compiler bugs.
2018-08-20 01:46:35 +02:00
dhewg
5aa122978d Don't try to extract libraries from gamepaks. 2018-08-20 01:46:34 +02:00
dhewg
e632cd030b Get rid of ID_DEMO_BUILD
There are no demo pk4s compatible to this 1.3.1 codebase.
2018-08-20 01:46:34 +02:00
dhewg
16657c0ce3 Rename PVS vars to match their type 2018-08-20 01:46:33 +02:00
dhewg
8dfc6df02a s/ReadDeltaLong/ReadDeltaInt/
to match the argument type
2018-08-20 01:46:33 +02:00
dhewg
8cd1580d60 s/WriteDeltaLong/WriteDeltaInt/
to match the return type
2018-08-20 01:46:33 +02:00
dhewg
431415c51c s/ReadLong/ReadInt/ to match the return type 2018-08-20 01:46:33 +02:00
dhewg
814abb55b9 s/WriteLong/WriteInt/ to match the argument type 2018-08-20 01:46:33 +02:00
Daniel Gibson
ce87a8904c Remove longs from game/ and d3xp/
(Except for handling of longs in TypeInfo and win32-only Maya import stuff).

sizeof(long) == sizeof(int) on x86 and win64,
but not on 64bit (x86_64) linux/unix/osx/.. so they should be avoided.
2018-08-20 01:46:33 +02:00
Daniel Gibson
5c08cb0140 Fix PVS calculations on 64bit systems
Monsters got stuck in same places of d3xp because PVS calculations
returned that they were not in the players PVS.
This only happened on LP64 systems like Unix/Linux amd64 where
sizeof(long) == 8 - it did not happen on Win64 because it's LLP64, i.e.
sizeof(long) == 4 (like on x86 32bit).

Bit fiddling code in Pvs.cpp seemed to assume that sizeof(long) == 4
like on win32.

Fixes #7.
2018-08-20 01:46:33 +02:00
Daniel Gibson
ca4b20eb08 Fix several bugs from iodoom3 bugtracker
rhyskidd@gmail.com found them (with PVS studio IIRC), reported them and posted
patches.
Some of the patches were incorrect so I rewrote them.
2018-08-20 01:46:33 +02:00
dhewg
c5c5762ae4 Fix "unreachable code" warnings 2018-08-20 01:46:32 +02:00
dhewg
9de64efa62 This is dhewm 3
Rename project, now at https://github.com/dhewm
2018-08-20 01:46:32 +02:00
dhewg
6b30d96d44 Get rid of CPU_EASYARGS
Never use the event callbacks with mismatching prototypes.
2018-08-20 01:46:32 +02:00
dhewg
151288e170 CMake: Use config.h for BUILD_OS and BUILD_CPU
This fixes, among others, FreeBSD 64bit builds where the build
system used a "amd64" suffix and runtime "x86_64".
2018-08-20 01:46:32 +02:00
dhewg
ac090883ac More fixes regarding event saving and restoring
Fix silly issue from 3d692b58 (sizeof(E_EVENT_SIZEOF_VEC)).
Align entity values of events to the native pointer size, which
is noticeably faster on x86_64 and fixes another assert() in
debug builds.

Past savegames with entities in events are not compatible.
2018-08-20 01:46:32 +02:00
dhewg
0fb3d2d37f Prevent assert() while saving and restoring events
The argument size of each event is checked in debug builds
and this change was missing from the x86_64 commits.

Surprisingly this didn't trigger yet with the original game,
only with the mod 'Classic Doom 3'.
2018-08-20 01:46:32 +02:00
dhewg
a8b4f9e5f6 Fix miscompilation with gcc 4.5
idAnimator::GetJointLocalTransform() miscompiles with gcc 4.5 and
-ftree-vrp (implied by -O2).

Reorder code to avoid the compiler bug, no functional change.
2018-08-20 01:46:31 +02:00
dhewg
851bd5901d Use correct idStr::Append() while saving event strings
Used the wrong Append() in fad99572, we want to stop at a
terminating null char.
2018-08-20 01:46:30 +02:00
dhewg
92023f44ca Implement saving and restoring of event strings
Required for events with string arguments. On debug builds
an assert() is triggered when trying to save such an event,
while events could not be properly restored in any build.

This happens when going from map delta4 to hell1 and the
autosave feature kicks in. The trigger event 'selectWeapon'
with the string argument 'weapon_fists' is in the event queue.

With the binary from id a warning is issued:
WARNING: player1 is not carrying weapon ''
so the bug exists in there too, just that its a release build
and doesn't abort().

I also managed to trigger this while saving shortly after
activating an elevator switch.
2018-08-20 01:46:30 +02:00