Commit Graph

1144 Commits

Author SHA1 Message Date
Jan Engelhardt
b6ef3b591a build: avoid repeat compilation of DallasFuncs.cpp
Due to ``#include "DallasFuncs.cpp"``, DF is recompiled 52 times.
Rework it to build just once. The compile time goes down for me
from 1m45.3s to 1m38.8s on my 1135G7 CPU running make -j8.
2024-09-09 15:29:40 +02:00
Jan Engelhardt
90110e43e9 build: resolve include issue with osiris_import.h
The switcheroo involving OSIRISEXTERN is unnecessary; if it is empty,
it is "extern" anyway.

One function, ``osicommon_Initialize``, is present twice and can lead
to duplicate definitions in the linker stage, which is probably what
the DallasFuncs.cpp comment alluded to. It is moved away into its own
.cpp file.
2024-09-09 15:29:38 +02:00
Jan Engelhardt
006c2fb4ec build: split osiris_vector.h into header and implementation
Both e.g. AIGame3.cpp and DallasFuncs.cpp include
``osiris_vector.h``. Right now, this is not a problem because
DallasFuncs.cpp is not compiled itself, but included from
AIGame3.cpp, in other words, it is all just one translation unit.

I have a plan to do away with ``#include "DallasFuncs.cpp"``, which
means the linker invocation for AIGame3.so will have at least two
translation units, and thus two definitions of the osiris vector
functions, which is not allowed.

This also has the side-effect to reduce compile-time a little,
from 1m57.5s to 1m48.7s on my 1135G7 CPU using `make -j8`.
2024-09-09 14:57:44 +02:00
Jan Engelhardt
ea3f11b6b5 scripts: remove unused files
"lnx" is not mentioned anywhere in CMakeLists.txt, so it also does
not appear on the compiler command lines, which means it is wholly
unused.
2024-09-09 14:35:06 +02:00
Jan Engelhardt
7a53958617 scripts: delete extraneous prototypes in level15 code
I want to namespace the stuff in DallasFuncs.cpp, and when I do that,
there comes about an ambiguity between ``NewNamespace::aUserFlagSet``
and the ``::aUserFlagSet`` declared by LEVEL15 (also ``qUserFlag``).

Due to ``#include "DallasFuncs.cpp"``, LEVEL15.cpp already has a
declaration (and definition) for ``aUserFlagSet``, and so we can jsut
remove the two lines.
2024-09-09 12:55:27 +02:00
Jan Engelhardt
b7b2f1e9aa Delete unused fixed math functions
gcc warns about strict aliasing violations in fix.cpp:

fix/fix.cpp: In function "int FloatRound(float)":
fix/fix.cpp:157:14: warning: dereferencing type-punned pointer will
break strict-aliasing rules [-Wstrict-aliasing]
  157 |   return ((*((int *)&nf)) & 0x7FFFFF) - 2048;

But these functions and then some are unused, so delete them altogether.
2024-09-09 12:55:27 +02:00
Azamat H. Hackimov
c003a98835
Merge pull request #579 from jengelh/dedi
Resolve out-of-bounds accesses with dedicated server code [ASAN]

fixes #571
2024-09-09 13:33:29 +03:00
Jan Engelhardt
b9fbee0e25 Resolve out-of-bounds accesses in DLLMultiInit
vp[26] is `int *`, so it tries to read 4 bytes on amd64, even though
TCP_Active, which is behind vp[26] is just a bool and 1 byte.

==95927==ERROR: AddressSanitizer: global-buffer-overflow on address 0x000004734f40 at pc 0x7f4f8d93b952 bp 0x7ffc57f191b0 sp 0x7ffc57f191a8
READ of size 4 at 0x000004734f40 thread T0
    f0 DLLMultiInit $GIT/netcon/includes/mdllinit.h:314
    f1 LoadMultiDLL(char const*) $GIT/Descent3/multi_dll_mgr.cpp:690
    f2 RunServerConfigs $GIT/Descent3/dedicated_server.cpp:236
    f3 LoadServerConfigFile() $GIT/Descent3/dedicated_server.cpp:357
    f4 InitDedicatedServer $GIT/Descent3/init.cpp:1778
    f5 InitD3Systems2(bool) $GIT/Descent3/init.cpp:1952
    f6 Descent3() $GIT/Descent3/descent.cpp:504
    f7 oeD3LnxApp::run() $GIT/Descent3/sdlmain.cpp:151

0x000004734f41 is located 0 bytes after global variable 'TCP_active' defined in '$GIT/networking/networking.cpp:383:6' (0x4734f40) of size 1
SUMMARY: AddressSanitizer: global-buffer-overflow $GIT/netcon/includes/mdllinit.h:314 in DLLMultiInit
2024-09-09 12:15:05 +02:00
Jan Engelhardt
009645ac83 Switch netgame_info::server_config_name to dynamically allocated
Resolve an out-of-bounds write in LoadServerConfigFile.
A sufficiently long path,

	descent3 -dedicated /home/jengelh/.config/descent3/dedicated.conf

causes the game server to exit with

	Error loading connection DLL 'cated.conf'

Which hints at a buffer overflow.
2024-09-09 12:15:04 +02:00
Jan Engelhardt
69dbf5bca7 Resolve alloc-dealloc-mismatch in CFile::FreeSymbols
==89545==ERROR: AddressSanitizer: alloc-dealloc-mismatch (operator new [] vs operator delete) on 0x5020001007f0
    f0 operator delete(void*, unsigned long) (/lib64/libasan.so.8+0xfe1f8)
    f1 InfFile::FreeSymbols() $GIT/cfile/inffile.cpp:63
    f2 InfFile::Close() $GIT/cfile/inffile.cpp:115
    f3 LoadServerConfigFile() $GIT/Descent3/dedicated_server.cpp:355

0x5020001007f0 is located 0 bytes inside of 11-byte region [0x5020001007f0,0x5020001007fb)
allocated by thread T0 here:
    f0 operator new[](unsigned long) (/lib64/libasan.so.8+0xfd458)
    f1 InfFile::AddSymbol(char const*, char const*) $GIT/cfile/inffile.cpp:49
    f2 InfFile::ParseLine(char*, int) $GIT/cfile/inffile.cpp:187
2024-09-09 10:38:17 +02:00
Jan Engelhardt
dfa0560aff dedicated: resolve out-of-bounds access during config parse
ASAN reports:

$GIT/Descent3/dedicated_server.cpp:350:24: runtime error: index 1024
out of bounds for type 'cvar_entry [36]'
$GIT/Descent3/dedicated_server.cpp:350:14: runtime error: load of
address 0x000001e677c0 with insufficient space for an object of type
'const char *'

This can happen if a line in the .cfg starts with a '#'.
2024-09-09 10:38:17 +02:00
Louis Gombert
40aae150b3
Merge pull request #577 from jengelh/tu
Consolidate duplicated `struct obj_sort_item`
2024-09-09 08:58:44 +02:00
Jan Engelhardt
26e5cfa2d5 Consolidate duplicated struct obj_sort_item 2024-09-09 08:31:14 +02:00
Louis Gombert
6ad7a3d5cb
Merge pull request #575 from jengelh/fvi_room
Rework fvi_room patch
2024-09-08 23:19:31 +02:00
Louis Gombert
f34c8e51aa
Merge pull request #572 from jengelh/crashes.3
Resolve 2 ASAN crashes
2024-09-08 23:11:51 +02:00
Louis Gombert
dfc192ac81
Merge pull request #548 from pzychotic/fix-errors
Fix small collection of errors
2024-09-08 22:41:46 +02:00
Jan Engelhardt
b7e3652c42 Rework fvi_room patch
In Retribution level 15, the cinematic animation would not start
playing when entering Dravis's room (after defating Hellion).

Fixes: cb5c2913b2
2024-09-08 17:57:06 +02:00
Jan Engelhardt
cf41191f78 Resolve ODR violation between two TUs
Descent3/render.cpp:2989:8: warning: type "struct obj_sort_item" violates the C++ One Definition Rule [-Wodr]
 2989 | struct obj_sort_item {
Descent3/terrainrender.cpp:943:8: note: a different type is defined in another translation unit
2024-09-08 13:52:21 +02:00
Jan Engelhardt
bbb74b976b Resolve assertion in multisafe
During Retribution level 13, after about 5 minutes when some timed
level script seems to run and the message "GB: Engine malfunction" is
printed, there is also an assert:

Assertion failure at msafe_CallFunction ($GIT/Descent3/multisafe.cpp:1719), triggered 1 time:
  'mstruct->id != -1'

The result from SpewCreate is -1 because there are no more gun slots
available, i.e. this condition is where the function exited thru:

	if (spew->gp.gunpoint < 0 || spew->gp.gunpoint >= pm->n_guns)
2024-09-07 23:13:32 +02:00
Jan Engelhardt
6c0dd1ad9d Resolve out-of-bounds access on Retribution level 13
ASAN complained:

$GIT/Descent3/BOA.cpp:443:54: runtime error: index -1 out of bounds for type 'float [40]'

At that particular time, important variables had these values:

cur_room=36 this_portal=-1
2024-09-07 23:11:51 +02:00
Louis Gombert
9fcd4e7857
Merge pull request #558 from jengelh/crashes.2
Fix some 8 other game crashes [ASAN]
2024-09-07 21:57:49 +02:00
Louis Gombert
7c9fd48ea6
Merge pull request #566 from jengelh/scorch
Repair non-sensical scorch iterations
2024-09-07 21:49:34 +02:00
Louis Gombert
8c39002076
Merge pull request #567 from jengelh/spello
Fix a bunch of spellos in comments and strings
2024-09-07 21:48:51 +02:00
Thomas Roß
edb596b731 [Comment] Fixed messed up character encoding in comment 2024-09-07 16:58:36 +02:00
Thomas Roß
582869bc50 [DMFC] Fixed missing va_end calls in case of function early outs 2024-09-07 16:58:08 +02:00
Thomas Roß
68334c54f4 [Linux] Fixed too many parameters to fprintf call 2024-09-07 16:57:37 +02:00
Thomas Roß
fcccc9aafa [DDGR] Fixed accidental assignment in 'if' statement 2024-09-07 16:57:11 +02:00
Jan Engelhardt
5f0bdf8184 Fix spello "it's" 2024-09-03 13:26:51 +02:00
Jan Engelhardt
38b835a03b Fix spello "its" 2024-09-03 13:26:51 +02:00
Jan Engelhardt
a3a31c77a2 Fix spello "seperate.." 2024-09-03 13:26:51 +02:00
Jan Engelhardt
4d9ff9cdc6 Fix some one-off spellos 2024-09-03 13:26:51 +02:00
Jan Engelhardt
1c32732f59 Fix spello "wierd" 2024-09-03 13:26:51 +02:00
Jan Engelhardt
a09efdaf20 Fix spello "conforming" 2024-09-03 13:26:51 +02:00
Jan Engelhardt
96c787bfb2 Fix spello "interative why" 2024-09-03 13:26:51 +02:00
Jan Engelhardt
b14470bbff Fix spello "independan.." 2024-09-03 13:26:51 +02:00
Jan Engelhardt
1036c3c677 Fix spello "targett" 2024-09-03 13:26:51 +02:00
Jan Engelhardt
edbde82918 Fix spello "agression" 2024-09-03 13:26:51 +02:00
Jan Engelhardt
b88d7d4b7a Fix spello "recersive" 2024-09-03 13:26:51 +02:00
Jan Engelhardt
762d0689fb Fix spello "visabil.." 2024-09-03 13:26:51 +02:00
Jan Engelhardt
ad9c2ba1d0 Fix spello "guarentee" 2024-09-03 13:26:51 +02:00
Jan Engelhardt
234e666ce0 Fix spello "charactor" 2024-09-03 13:26:51 +02:00
Jan Engelhardt
337e8eaa17 Repair non-sensical scorch iterations
Gazing at my own code/modification, I find it is embarrasingly wrong.
Since ``sp`` is re-initialized at every loop iteration, setting it to
(the locally-constant) ``Scorch_start`` is incorrect. Make ``sp``
really mirror ``i`` at all times; this way, it also will not be
necessary anymore to update ``sp`` within the loop.

Fixes: 20ed30eef8
2024-09-03 00:09:39 +02:00
Louis Gombert
a4ef5fd0d5
Merge pull request #556 from winterheart/gamespy-reactivate
Reactivate Gamespy functionality
2024-09-02 23:18:07 +02:00
Louis Gombert
221a2abc53
Merge pull request #561 from tophyr/pr/osx-xattr
Add xattr command to OS X usage instructions
2024-09-02 23:06:55 +02:00
Jan Engelhardt
c3a6b1258c Resolve assertion when CollectorNomad2 dies
It is possible to cause the death of the CollectorNomad2 object (rush
to it before it possibly leaves again into the sidepackets the ship
won't fit through). The transition happens here:

```
f0  KillObject (objp=0x3d4d3e0 <Objects+384000>, killer=0x3cef7e0 <Objects>, damage=3) at /home/jengelh/D3/Descent3/damage.cpp:1036
f1  ApplyDamageToGeneric (hit_obj=0x3d4d3e0 <Objects+384000>, killer=0x3cef7e0 <Objects>, damage_type=6, damage=3, server_says=0, weapon_id=255) at /home/jengelh/D3/Descent3/damage.cpp:1401
f2  collide_generic_and_player (robotobj=0x3d4d3e0 <Objects+384000>, playerobj=0x3cef7e0 <Objects>, collision_point=0x7f877f40a830, collision_normal=0x7f877f40a858, f_reverse_normal=true, hit_info=0x7f877f40a810) at /home/jengelh/D3/physics/collide.cpp:2127
f3  collide_two_objects (A=0x3cef7e0 <Objects>, B=0x3d4d3e0 <Objects+384000>, collision_point=0x7f877f40a830, collision_normal=0x7f877f40a858, hit_info=0x7f877f40a810) at /home/jengelh/D3/physics/collide.cpp:2505
f4  do_physics_sim (obj=0x3cef7e0 <Objects>) at /home/jengelh/D3/physics/physics.cpp:1515
f5  ObjDoFrame (obj=0x3cef7e0 <Objects>) at /home/jengelh/D3/Descent3/object.cpp:2824
f6  ObjDoFrameAll () at /home/jengelh/D3/Descent3/object.cpp:2988
f7  GameFrame () at /home/jengelh/D3/Descent3/GameLoop.cpp:2980
f8  GameSequencer () at /home/jengelh/D3/Descent3/gamesequence.cpp:1221
f9  PlayGame () at /home/jengelh/D3/Descent3/game.cpp:834
f10 MainLoop () at /home/jengelh/D3/Descent3/descent.cpp:550
f11 Descent3 () at /home/jengelh/D3/Descent3/descent.cpp:508
f12 oeD3LnxApp::run (this=0x7f877f00db50) at /home/jengelh/D3/Descent3/sdlmain.cpp:151

<frame 2> (gdb) p robotobj
$1 = {
	type = 2 '\002' (OBJ_ROBOT), dummy_type = 255 '\377', id = 276,
	flags = 2135072, name = 0x5020000aff30 "CollectorNomad2",
	handle = 2432, next = 178, prev = -1,
	control_type = 1 '\001' (CT_AI), movement_type = 2 '\002' (MC_ROLLING),
	render_type = 1 '\001' (LRT_GOURAUD), lighting_render_type = 1 '\001', roomnum = 58,
	pos = {x = 2350.21484, y = -263.523956, z = 1868.59888},
	orient = {
		rvec = {x = 0.882905424, y = 1.63964216e-14, z = -0.469550878},
		uvec = {x = -1.25793295e-14, y = 1, z = 1.12662192e-14},
		fvec = {x = 0.469550878, y = -4.04037088e-15, z = 0.882905424}
	},...}
```

Thus, KillObject sets obj->control_type=CT_DYING. In the same game
tick, Level6.cpp then calls aAIGoalFollowPathSimple which triggers
the assertion.

```
Int3 in $GIT/Descent3/osiris_predefs.cpp at line 571.(Descent 3 Debug Break)

f0  osipf_AIGoalFollowPathSimple (objhandle=2432, path_id=21, guid=7, flags=1052928, slot=3) at $GIT/Descent3/osiris_predefs.cpp:571
f1  AI_GoalFollowPathSimple (objhandle=2432, path_id=21, guid=7, flags=1052928, slot=3) at $GIT/scripts/osiris_import.h:170
f2  aAIGoalFollowPathSimple (objhandle=2432, pathid=21, flags=1052928, goalid=7, priority=3) at $GIT/scripts/DallasFuncs.cpp:3649
f3  LevelScript_0000::CallEvent (this=0x5020000ba430, event=256, data=0x7f963e71d930) at $GIT/scripts/Level6.cpp:2465
f4  CallInstanceEvent (id=0, ptr=0x5020000ba430, event=256, data=0x7f963e71d930) at $GIT/scripts/Level6.cpp:2209
f5  Osiris_CallLevelEvent (event=256, data=0x7f963e71d930) at $GIT/Descent3/OsirisLoadandBind.cpp:2000
f6  GameFrame () at $GIT/Descent3/GameLoop.cpp:3020
f7  GameSequencer () at $GIT/Descent3/gamesequence.cpp:1221
f8  PlayGame () at $GIT/Descent3/game.cpp:834
f9  MainLoop () at $GIT/Descent3/descent.cpp:550
f10 Descent3 () at $GIT/Descent3/descent.cpp:508
f11 oeD3LnxApp::run (this=0x7f963e80db50) at $GIT/Descent3/sdlmain.cpp:151
```
2024-09-02 22:53:27 +02:00
Louis Gombert
fb6573e1b0
Merge pull request #562 from winterheart/ps_rand-fixes
Fixes to RNG-related functions
2024-09-02 22:23:27 +02:00
Louis Gombert
dd6e684712
Merge pull request #555 from jengelh/collide
Resolve out-of-bounds in PolyCollideObject [ASAN]
2024-09-02 21:03:32 +02:00
Louis Gombert
97efd520a7
Merge pull request #554 from jengelh/align
Resolve some non-fatal ASAN reports about alignment
2024-09-02 20:57:02 +02:00
Louis Gombert
0800723af8
Merge pull request #553 from jengelh/master
Fix 13 different crashes [ASAN]
2024-09-02 20:44:05 +02:00
Louis Gombert
9df3316bd9
Merge pull request #552 from winterheart/mve-pipewire
Fix audio distortions on MVE playback with pipewire backend
2024-09-02 20:31:58 +02:00