Commit Graph

1254 Commits

Author SHA1 Message Date
Azamat H. Hackimov
68f8771845 Fix compilation of editor 2024-09-25 23:47:03 +03:00
Azamat H. Hackimov
3b83d493e2 Sync DMFC debug functionality with core codebase 2024-09-24 23:03:02 +03:00
Azamat H. Hackimov
f7b7f18e0d Replace debugbreak with SDL_assert()
Reworked ASSERT() and Int3() macros to use SDL_assert(). SDL_assert() allows to debug break from user decision.

Major reorganizing platform-dependent code to make it platform-independent.
2024-09-24 23:03:02 +03:00
Azamat H. Hackimov
cc9e054509 Avoid using ASSERT in interface headers 2024-09-24 23:03:02 +03:00
Azamat H. Hackimov
a59503f881 Move pserror.h to ddebug module 2024-09-24 23:00:53 +03:00
Azamat H. Hackimov
c3b1225c6e Remove mprintf_at() usage
This function is stubbed and does nothing.
2024-09-24 23:00:53 +03:00
Azamat H. Hackimov
21576c86a5 Unify Debug_Init() for all platforms 2024-09-24 23:00:53 +03:00
Azamat H. Hackimov
585a3804c4 Remove unused serial check code 2024-09-24 23:00:53 +03:00
Louis Gombert
0e228aa9db
Merge pull request #591 from winterheart/ddio-update
Update DDIO and related to it's code OSIRIS
2024-09-23 22:37:14 +02:00
Louis Gombert
515b8b5744
Merge pull request #601 from winterheart/dd_video_cleanup
Remove dd_video module
2024-09-23 21:03:59 +02:00
Azamat H. Hackimov
eb0f6a2865 Remove dd_video module
Functions from module are stubbed and unused.
2024-09-23 00:37:25 +03:00
Azamat H. Hackimov
39e128cb0f
Merge pull request #582 from jengelh/master
ASAN/UBSAN fixes
2024-09-21 21:25:46 +03:00
Louis Gombert
398699e045
Merge pull request #598 from pzychotic/fix-594
[Init] Fixed Default_pilot initialization
2024-09-20 23:53:55 +02:00
Thomas Roß
78906c3373 [Init] Fixed Default_pilot initialization
When we have no config file yet, e.g. on first start of the game, or the entry for "Default_pilot" is missing in the config, the variable Default_pilot will be filled with random memory. This might later crash when we try to interpret this string as std::filesystem::path in PilotSelect() in pilot.cpp.
2024-09-20 19:39:37 +02:00
Louis Gombert
770e9e8f22
Merge pull request #593 from jengelh/cxx17
build: work around compile failure under g++-9
2024-09-18 23:48:03 +02:00
Louis Gombert
b33cc21dce
Merge pull request #587 from winterheart/module-fixes
Update module, add logger module
2024-09-18 22:18:13 +02:00
Jan Engelhardt
85f640d0bb build: work around compile failure under g++-9
Under gcc-9 (e.g. used by Ubuntu 20.04), compilation fails with:

```
/usr/include/c++/9/variant: In instantiation of ‘constexpr const size_t std::variant_size_v<user_var>’:
/usr/include/c++/9/variant:1023:10:   required from ‘struct std::__detail::__variant::__gen_vtable<true, void, user_var::operator++(int)::<lambda(auto:22&&)>&&, user_var&>’
/usr/include/c++/9/variant:1656:23:   required from ‘constexpr decltype(auto) std::__do_visit(_Visitor&&, _Variants&& ...) [with bool __use_index = false; bool __same_return_types = true; _Visitor = user_var::operator++(int)::<lambda(auto:22&&)>; _Variants = {user_var&}]’
/usr/include/c++/9/variant:1672:29:   required from ‘constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...) [with _Visitor = user_var::operator++(int)::<lambda(auto:22&&)>; _Variants = {user_var&}; std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> = void]’
scripts/DallasFuncs.h:21:75:   required from here
/usr/include/c++/9/variant:94:29: error: incomplete type ‘std::variant_size<user_var>’ used in nested name specifier
   94 |     inline constexpr size_t variant_size_v = variant_size<_Variant>::value;
```

Judging from the date of P2162, calling std::visit with std::variant
derivatives is only specified for C++20 and onwards. But Descent3
only asks for C++17.

Since ``class user_var`` does not have any members that need would
need to be accessed via std::visit, we can "add a hint" and
explicitly specify the base type.
2024-09-18 22:15:41 +02:00
Azamat H. Hackimov
85cceef2af module: use cf_FindRealFileNameCaseInsensitive() instead duplicated
In mod_GetRealModuleName() there was error - arguments of mod_FindRealFileNameCaseInsensitive() is misplaced.
2024-09-18 22:50:08 +03:00
Azamat H. Hackimov
dc0cd880e4 Add logger module
Implementing separated logger module.
2024-09-18 22:50:08 +03:00
Azamat H. Hackimov
3b49fb45c8
Merge pull request #589 from Lgt2x/sdlcontroller
Merge WinController and lnxcontroller
2024-09-18 21:58:02 +03:00
Louis Gombert
c20ea914d6 sdlcontroller: mark functions override 2024-09-18 22:32:56 +02:00
Louis Gombert
8f63c0ded6 Remove unimplemented '-rjoy' option
The '-rjoy' option would be used to connect to a remote controller, but was not implemented in the SDL or DX version
2024-09-18 22:32:56 +02:00
Louis Gombert
6c533364f6 Remove outdated '-slowkey', '-alternatejoy' & '-directinput' options
Removes key_emulation and joy_emulation toggles from ddio_init_info structures, that were not used in the SDL implementation.
All input is now handled using SDL for all platforms, alternatejoy/directinput options were only relevant for Windows-specific DirectInput. 'slowkey' was an unimplemented feature.
2024-09-18 22:32:56 +02:00
Louis Gombert
d7063e7ff7 Remove leftover wincontroller.h 2024-09-18 22:32:56 +02:00
Louis Gombert
259b54e5a3 Don't import sdlcontroller in controller.h
Respect encapsulation of subclass
2024-09-18 22:32:09 +02:00
Louis Gombert
387ef339f4 Rename lnxcontroller to sdlcontroller 2024-09-18 22:32:09 +02:00
Louis Gombert
ef113543ab Merge WinController and lnxcontroller files
move controller IO processing to the DDIO module
2024-09-18 22:32:09 +02:00
Louis Gombert
b8b50d9b08 sdljoy: minor fixes
Use nullptr instead of 0, parenthesize sizeof, remove extra forward declaration
2024-09-18 22:32:09 +02:00
Azamat H. Hackimov
09ab370821 Convert OSIRIS_Extracted_scripts to std::map usage
Simplify object management.
2024-09-18 21:23:18 +03:00
Azamat H. Hackimov
2d29dd4f7c Convert tExtractedScriptInfo to std::fs::path 2024-09-18 21:23:18 +03:00
Azamat H. Hackimov
548b1f63d7 Convert OSIRIS_Extracted_script_dir to std::fs::path 2024-09-18 21:23:18 +03:00
Azamat H. Hackimov
28fccea676 Convert Osiris functions to use std::fs::path 2024-09-18 21:23:18 +03:00
Azamat H. Hackimov
627ab62f1f Remove unused ddio_GetTempFileName() 2024-09-18 21:23:18 +03:00
Azamat H. Hackimov
3e402d78d5 Replace ddio_GetTempFileName() with ddio_GetTmpFileName()
Convert global variable Descent3_temp_directory to std::fs::path.
2024-09-18 21:23:18 +03:00
Azamat H. Hackimov
511743d4b3 Implementing new ddio_GetTmpFileName()
New function uses std::filesystem::path and generates result faster than ddio_GetTempFileName() (benchmarked on Linux).
2024-09-18 21:23:18 +03:00
Azamat H. Hackimov
8940a5ae38 Remove unused ddio_CleanPath() 2024-09-18 21:23:14 +03:00
Azamat H. Hackimov
cab252f66c Remove unused ddio_GetParentPath() 2024-09-18 21:22:22 +03:00
Louis Gombert
a33c79c5a6
Merge pull request #574 from jengelh/uninit_vars
Resolve 2 UBSAN warnings about uninitialized vars; establish allocation/type check along with it
2024-09-18 19:46:25 +02:00
Azamat H. Hackimov
4f4ab3bd20 Isolate module submodule 2024-09-17 23:16:58 +03:00
Jan Engelhardt
08004b9a47 Add member initializers for struct game_controls
UBSAN warns:

$GIT/Descent3/object.cpp:2452:91: runtime error: load of value 2, which is not a valid value for type 'bool'
2024-09-16 22:12:14 +02:00
Jan Engelhardt
72fc5c6784 Add member initializers for struct lnxController/wincontroller
lnxgameController::flush accesses this->m_MouseActive before that
member being initialized with something sensible, making ASAN report:

linux/lnxcontroller.cpp:259:8: runtime error: load of value 190, which is not a valid value for type 'bool'
linux/lnxcontroller.cpp:259:33: runtime error: load of value 190, which is not a valid value for type 'bool'

Thanks to the introduction of mem_rmalloc, it has been established
that struct lnxgameController is not malloc'd anywhere, so any
instantiation runs its constructor properly.
2024-09-16 22:12:14 +02:00
Jan Engelhardt
3c9234c4c0 mem_malloc type triviality checks (8/8)
(Manual modification.) Change mem_malloc callsites with
non-fundamental types to mem_rmalloc.
2024-09-16 22:12:14 +02:00
Jan Engelhardt
a23c6a42a3 mem_malloc type triviality checks (7/8)
```
git grep -l mem_malloc | xargs perl -i -lpe 's{\((char) \*\)mem_malloc\((\S+)\)}{mem_rmalloc<$1>($2)}'
```
2024-09-16 22:12:14 +02:00
Jan Engelhardt
de0af3b10d mem_malloc type triviality checks (6/8)
```
git grep -l mem_malloc | xargs perl -i -lpe 's{\((uint8_t) \*\)mem_malloc\((\S+)\)}{mem_rmalloc<$1>($2)}'
```
2024-09-16 22:12:13 +02:00
Jan Engelhardt
1551b240d3 mem_malloc type triviality checks (4/8)
```
git grep -l mem_malloc | xargs perl -i -lpe 's{\((\w+) \*\*\)mem_malloc\((\S+) \* sizeof\(\1 \*\)\)}{mem_rmalloc<$1 *>($2)}'
```
2024-09-16 22:12:13 +02:00
Jan Engelhardt
4d2fdb2316 mem_malloc type triviality checks (4/8)
```
git grep -l mem_malloc | xargs perl -i -lpe 's{\((\w+) \*\)mem_malloc\((\S+) \* sizeof\(\1\)\)}{mem_rmalloc<$1 *>($2)}'
```
2024-09-16 22:12:13 +02:00
Jan Engelhardt
bb38a4a565 mem_malloc type triviality checks (3/8)
```
git grep -l mem_malloc | xargs perl -i -lpe 's{\((\w+) \*\*\)mem_malloc\(sizeof\(\1 \*\) \* (\S+)\)}{mem_rmalloc<$1>($2)}'
```
2024-09-16 22:12:13 +02:00
Jan Engelhardt
c7da9daee2 mem_malloc type triviality checks (2/8)
Automated replacement with

```
git grep -l mem_malloc |
xargs perl -i -lpe 's{\((\w+) \*\)mem_malloc\(sizeof\(\1\) \* (\S+)\)}{mem_rmalloc<$1>($2)}'
```
2024-09-16 22:12:12 +02:00
Jan Engelhardt
6fbc86efec mem_malloc type triviality checks (1/8)
git grep -l mem_malloc | xargs perl -i -lpe 's{\((\w+) \*\)mem_malloc\(sizeof\(\1\)\)}{mem_rmalloc<$1>()}'
2024-09-16 21:57:41 +02:00
Jan Engelhardt
ce3a988ad6 Add a mem_malloc wrapper to check type triviality
UBSAN is reporting that some uninitialized variables. To that end, I
would like to add member default initializers to e.g. ``struct
object``. Doing that makes classes nontrivial.

Allocations throughout the code occur with e.g.
``mem_malloc(sizeof(T))``, which is, tersely speaking, incompatible
with triviality. Therefore, mem_malloc call sites will be rewritten
to invoke ``mem_rmalloc<T>`` instead, to enforce a compile-time check
that ``T`` is indeed trivial.

``mem_rmalloc<T>`` is modeled to look like ``make_unique<T>``, i.e.
can be called with no arguments to allocate space for a single thing,
or called with a size_t argument that specifies the number of
elements (automatic byte sizing is applied internally).
2024-09-16 21:57:41 +02:00