Commit graph

100 commits

Author SHA1 Message Date
Daniel Gibson
27e051a1f0 Fix GCC -W(maybe-)uninitialized warnings that at least kinda had a point 2024-03-18 23:28:29 +01:00
Daniel Gibson
d561197004 Don't use "register" keyword, it was deprecated in C++11
.. and even removed in C++17 - and before that it probably didn't do
much in most compilers
2024-03-18 23:28:29 +01:00
Daniel Gibson
0afb7cc4f7 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:28:29 +01:00
Daniel Gibson
dfff91f607 Use idStr::Copynz() instead of strncpy()
to guarantee \0-termination
(only the applicable parts of that dhewm3 commit)
2022-05-29 00:29:54 +02:00
Daniel Gibson
450320057f 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-05-29 00:29:54 +02:00
Daniel Gibson
279abd8097 Don't use stringDataAllocator in idStr, it's not thread-safe
idStr is used in both the main thread and the async sound thread, so
it should better be thread-safe.. idDynamicBlockAlloc is not.
Use realloc() and free() instead.

For some reason this caused a lot more crashes (due to inconsistencies
in the allocator's heap) with newer Linux distros (like XUbuntu 20.04)
and when using GCC9, while they rarely reproduced with GCC7 or on
XUbuntu 18.04

fixes #391
2022-05-29 00:29:54 +02:00
Turo Lamminen
77824c9909 Silence an uninitialized variable warning 2022-05-29 00:29:54 +02:00
Turo Lamminen
b18766e259 Several commits about memcpy() and memset() from turol in idlib squashed
"Don't use memcpy in idMat2 constructor" up to "Don't use memset to zero
non-trivial type volumeIntegrals_t" from Turo Lamminen (in orig dhewm3
repo)
2022-05-29 00:29:54 +02:00
yamir
0c481cd869 Fix ppc64le build 2022-05-29 00:29:54 +02:00
Daniel Gibson
cb0775e7d3 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 02:59:03 +01:00
Daniel Gibson
431de18a60 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 02:59:03 +01:00
Daniel Gibson
7123e0ef54 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 02:59:03 +01:00
Daniel Gibson
a533e0ce60 MSVC: Shut up Compiler warning in Matrix.h if asserts are disabled 2021-01-18 02:59:03 +01:00
Daniel Gibson
85a1020490 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:23:41 +01: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
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
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
leffmann
99bbd70af5 make idlib 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
Tobias Frost
7b7c7a5238 Fixing some spelling errors: s/unkown/unknown, s/seperate/separate. (#107) 2018-08-20 01:46:38 +02:00
Daniel Gibson
ba549be284 math.h should #include sys/platform.h
Similar to f317b05
2018-08-20 01:46:37 +02:00
Daniel Gibson
20879f6972 List.h needs sys/platform.h for ID_INLINE
Everytime List.h is included in a new file (and sys/platform.h isn't)
there are confusing compiler-errors..
So just #include sys/platform.h in List.h directly, because it uses
ID_INLINE which is defined there
2018-08-20 01:46:37 +02:00
Daniel Gibson
d1527301b0 Use current type for BT_CLOSED enum
doesn't really make a difference code-wise, but removes one compiler warning.
2018-08-20 01:46:37 +02:00
Daniel Gibson
01545faf94 Get rid of some compiler warnings
GCC had shitloads of superfluous warnings wherever List.h and Str.h were
included.. get rid of them by using #pragma GCC diagnostic at some places
in List.h and Str.h.
Also add some casts, initialize some variables for other warnings
2018-08-20 01:46:37 +02:00
dhewg
eb38c04357 Get rid of precompiled.[h|.cpp]
Both unused, except for the mfc editors, which don't compile anyway.
2018-08-20 01:46:36 +02:00
dhewg
d832144482 Use _exit() in AssertFailed()
Ensure application exit.
2018-08-20 01:46:35 +02:00
dhewg
575668da57 Replace "__asm int 0x03" with __debugbreak()
Fixes compilation with msvc 64bit.
2018-08-20 01:46:35 +02:00
dhewg
d16d3a5534 Only compile msvc style asm with 32bit msvc
The 64bit compiler doesn't support __asm.
2018-08-20 01:46:35 +02:00
dhewg
a385bbeb29 Fixes issues with MacOSX.
- Fixes compiler errors with mismatching types in DoomController.mm
- Adds PPC_INTRINSICS fix to Simd_Altivec.h
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
ae319dbe4a s/ReadDeltaLongCounter/ReadDeltaIntCounter/
to match the return type
2018-08-20 01:46:33 +02:00
dhewg
c971755d98 s/WriteDeltaLongCounter/WriteDeltaIntCounter/
to match the argument 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
dhewg
a9ffb336f6 s/BigLong/BigInt/ to match the return type 2018-08-20 01:46:33 +02:00
dhewg
420783b151 s/LittleLong/LittleInt/ to match the return type 2018-08-20 01:46:33 +02:00
Daniel Gibson
a9a6042a04 Remove usage of long type from idlib/
Apart from some minor stuff, this changes the signature of some methods
of Parser and Token classes and of the (unused) Random2 class.
That no problem though, because the calling code uses normal ints
anyway.
2018-08-20 01:46:33 +02:00
Daniel Gibson
d51c05c768 Fix idMatX::IsOrthonormal()
The original implementation was pretty broken (but not used anyway),
it is now fixed and improved a bit (got rid of one inner loop).
This (at least part of the problem) was detected by PVS-Studio,
see http://www.viva64.com/en/b/0120/ Fragment 3
2018-08-20 01:46:33 +02:00
dhewg
c5c5762ae4 Fix "unreachable code" warnings 2018-08-20 01:46:32 +02:00
dhewg
5fa6e06748 Use SDL GLimp and input implementations on Windows
The DirectX SDK is not required anymore.
2018-08-20 01:46:30 +02:00
spiral
3dc6127529 Remove MWERKS stuff 2018-08-20 01:46:29 +02:00
dhewg
01b5e365e8 Fix alignment issue with idBlockAlloc::Free()
Bug introduced with e97d3288. This doesn't work with MinGW, since
the struct members might not be aligned to the native pointer
size (in this case idSampleDecoderLocal was aligned to a 8 byte
boundary on win32).
Just switch the two members to avoid ugly code.
2018-08-20 01:46:29 +02:00
dhewg
27c5fd76ff Fix -Woverloaded-virtual warnings
We want to use the SIMD functions of the base class if the
deriving class does not implement every overloaded variant.

Added missing idLight::SetColor(idVec3) which is declared in
idEntity.
2018-08-20 01:46:29 +02:00
dhewg
a86defb0ca Change another _WIN32 to _MSC_VER for MinGW
Older MinGW versions do not know about __assume().
Change _WIN32 in comments too to match their opening #if.

Reported by serpentine.
2018-08-20 01:46:29 +02:00
dhewg
84d64029e5 New define IDSTR_NO_REDIRECT
The defines in idlib/Str.h won't be set to redirect the low
level c string functions to idStr when IDSTR_NO_REDIRECT is
set.

Fixes compilation for MSVC:
error C2761: 'Cmp' : member function redeclaration not allowed

Reported by spiral.
2018-08-20 01:46:29 +02:00
spiral
139726bc37 Add missing includes for MSVC
- MSVC doesn't provide C99 headers
- Default to min. req. 64Mb video mem if no COM present
- Move misplaced __attribute__((packed)) from MSVC to MinGW
2018-08-20 01:46:29 +02:00