48 Commits

Author SHA1 Message Date
Jan Engelhardt
a84408d5fc ui: cure UBSAN warning about cast in UIStatic::SetTitle
```
ui/UIStatic.cpp:113:15: runtime error: downcast of address 0x7b9f03ae6a00 which does not point to an object of type 'UIPrimativeItem'
0x7b9f03ae6a00: note: object is of type 'UITextItem'
 00 00 00 00  d0 f9 57 02 00 00 00 00  ff be be be 00 ff 00 00  03 00 00 00 be be be be  70 64 dd 02
              ^~~~~~~~~~~~~~~~~~~~~~~
              vptr for 'UITextItem'

[lines as per 51fb3fea609e81d3897c33d901dce0b7be68c082; ±1 line]
f0  UIStatic::SetTitle (this=0x7ccff4a8b200, item=0x7bfff384a030) at ui/UIStatic.cpp:113
f1  newuiSheet::UpdateChanges (this=0x7bfff3a8ee38) at Descent3/newui_core.cpp:1721
f2  newuiMenu::DoUI (this=0x7bfff3a8e4c0) at Descent3/newui_core.cpp:921
f3  OptionsMenu () at Descent3/config.cpp:1432
f4  MainMenu () at Descent3/menu.cpp:837
f5  MainLoop () at Descent3/descent.cpp:541
f6  Descent3 () at Descent3/descent.cpp:503
f7  oeD3LnxApp::run (this=0x7bfff3901050) at Descent3/sdlmain.cpp:142
f8  main (argc=1, argv=0x7fffffffdae8) at Descent3/sdlmain.cpp:322
```

In `SetTitle`, `CopyUIItem()` returns a `UIItem *` backed by the same class
that `item` is, which is not guaranteed to be a UIPrimativeItem object. That
guarantee only holds in the `SetBackground` function.

Fixes: df209742fc (bogus cast added)
Fixes: 51fb3fea60 (added UITextItem in the options dialog)
2025-05-27 00:28:01 +02:00
Chris Sarbora
5b18e22e18 Fix mouselook
Likely with the change to SDL's 'captured mouse' mode, mouse movements
during fullscreen became deltas *from the last movement*, not from
the last sampled position or frame. In order to correctly measure the
mouse movement, the deltas must be summed up and then reset when 'read'
at input-processing time.

Moving to summing the deltas threw many other mouse-related calibration
factors out of whack, so these factors are re-determined empirically
across a range of mice, from 400dpi 125hz to 30,000dpi 8khz. Reasonable
defaults are chosen targeting an 'average' mouse of 1000dpi, and the
mouse sensitivity precision is increased to allow finer user tuning.
2025-04-12 01:57:43 -05:00
Jan Engelhardt
48953868df build: resolve 101 instances of -Wunused-variable 2024-11-04 22:20:18 +01:00
Jan Engelhardt
9687cd5e27 ui: delete empty function bodies 2024-11-03 23:39:38 +01:00
Jan Engelhardt
a6d37b68e5 ui: replace in-constructor assignments by initializations 2024-11-03 23:39:37 +01:00
Jan Engelhardt
71772b9c9c Add "final" marker to a number of classes
Devirtualization is an optimization in the generated assembly: when a
class C is polymorphic but also final, ``((C *)ptr)->func()`` can be
turned from an indirect into a static call.
2024-11-03 23:39:37 +01: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
eb0f6a2865 Remove dd_video module
Functions from module are stubbed and unused.
2024-09-23 00:37:25 +03: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
Azamat H. Hackimov
dc0cd880e4 Add logger module
Implementing separated logger module.
2024-09-18 22:50:08 +03: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
Azamat H. Hackimov
0abd11f08f Convert ui to use new logging facility 2024-09-10 03:00:26 +03:00
Thomas Roß
c738327e79 [UI] Replaced busy wait loop with a sleep. 2024-08-26 00:45:06 +02:00
Azamat H. Hackimov
54f9d75e62 Reduce linux_fix.h usage in project 2024-08-20 23:08:10 +03:00
Thomas Roß
7b71873a69 [Cleanup] Removed function declarations that are not implemented. 2024-08-20 20:03:02 +02:00
Louis Gombert
60c5dbf1fe CMake: add all headers to target sources
This can help with CMake IDE integration and file indexing.
2024-08-09 17:09:14 +02:00
Azamat H. Hackimov
7b31572d05 Isolate grtext submodule
Isolate grtext from rest of the project, minor cleanups.
2024-07-28 16:50:42 +03:00
Azamat H. Hackimov
87882c9976 Isolate ui submodule
Isolate ui from rest of the project, minor cleanups.
2024-07-28 16:50:41 +03:00
Chris Sarbora
3da53e567f Programmatically replace all __LINUX__ with POSIX
Steps:
```sh
srcs=$(mktemp)
find . -name "*.cpp" -or -name "*.c" -or -name "*.h" -or -name "*.hpp" -or -name "*.cc" -or -name "*.hh" > $srcs
xargs sed -i 's/ifndef __LINUX__/if !defined(POSIX)/' < $srcs
xargs sed -i 's/ifdef __LINUX__/if defined(POSIX)/' < $srcs
xargs sed -i 's/defined(__LINUX__)/defined(POSIX)/' < $srcs
```
2024-07-12 18:11:54 -05:00
Azamat H. Hackimov
59487976f6 Isolate misc module
Isolate misc module for better dependency handling.
2024-06-27 01:26:35 +03:00
Azamat H. Hackimov
db8aa64d2f Make mem module isolated from project
Properly define MEM_USE_RTL definition only for mem library. Link other dependant modules with mem.
2024-06-20 00:43:51 +03:00
GravisZro
f7ae658fe2 Modernize struct/enum/unions type declarations 2024-05-30 03:35:17 -04:00
GravisZro
9cf9781369 Properly format/use variadic macros 2024-05-24 20:57:17 -04:00
Azamat H. Hackimov
a0929aefe2 Rename ddio_common to ddio 2024-05-24 22:18:14 +03:00
Azamat H. Hackimov
6bc3c71a83 Reordering ddio_common module
Merge ddio_lnx and ddio_win into ddio_common module.
2024-05-24 22:17:44 +03:00
GravisZro
26b7776f43 Replace "ubyte" with "uint8_t" 2024-05-23 23:07:26 -04:00
GravisZro
dec9de7456 64-bit fixes
Switch all the (u)long types to (u)int32_t where appropriate.
2024-05-22 18:14:45 -04:00
Azamat H. Hackimov
bde23461ea Replace non-portable itoa with sprintf
Minor fixes and header cleanup.
2024-05-19 02:34:09 +03:00
C.W. Betts
1746a57688 Quiet another asan bug. 2024-05-09 21:15:18 -06:00
Edu García
fbd6350917 more software renderer code removal 2024-05-09 12:11:49 +01:00
JeodC
a4ab78192c Join license header with historical commentrs
Join the license header with historical comments using a separator so IDEs can correctly parse the initial header.

Also use .gitattributes to ensure all files are LF.
2024-05-08 14:41:19 -04:00
Edu Garcia
553f851714 remove unused code 2024-05-06 22:06:26 +01:00
Ryan C. Gordon
6c8977caf0 Heavy patching for compiler warnings.
The vast majority of this is fixing up `char *` that should be `const char *`
but a handful of other fixes, like potential buffer overflows that GCC
noticed, etc, were applied as well.

This removes `-Wno-write-strings` from CMakeLists.txt, as it is no longer
necessary, as there is no longer a flood of compiler warning spam when
building.

This does not fix all compiler warnings; there are still a handful, and they
are legitimate, but they can be dealt with in a future commit.
2024-04-29 00:18:56 -04:00
Chris Sarbora
e6ba1906c9 Remove MacOS (Classic) code and all references (1/3)
The MACINTOSH define refers to MacOS Classic (not OS X) which we do not
plan to support. Rather than carry the cruft forever, let's delete it.

NOTE: legacy/ is unused but we're keeping it around, so MACINTOSH uses
there are left alone.

Process used for this commit:
```
git rm -r mac
find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" \) \
  -exec unifdef -UMACINTOSH -o {} {} \;
git restore legacy
git add .
```

Test Plan:
On Mac, build both Debug and Release
```
cmake --build --preset mac --config Debug
cmake --build --preset mac --config Release
```
2024-04-27 07:38:14 -07:00
Thomas Otto
00389c50ea Some more CMake white space formatting
- tabs to spaces
 - use Unix line endings everywhere
 - newline at end of file
 - remove trailing white space
 - no space between keywords and opening parenthesis
 - use 2 spaces to indent
2024-04-21 11:46:32 +02:00
Louis Gombert
3515bc0043 Merge pull request #82 from th1000s/fix
Fix -fpermissive issues, remove workaround flags
2024-04-20 17:17:28 +00:00
Kevin Bentley
1f45163248 Updated source to reflect the license that this code is released under. 2024-04-20 09:57:49 -06:00
Thomas Otto
b737ec39d3 Don't take the address of an rvalue
Create items explicitly on the stack first, then these are copied in the
following call.
2024-04-20 17:22:27 +02:00
Louis Gombert
c2b71b8147 Standardize CMake formatting
lowercase function names, blocks indent
2024-04-20 14:45:49 +02:00
C.W. Betts
57078ae4b5 Change most sprintf to snprintf.
This also includes vsprintf to vsnprintf.
2024-04-19 12:31:28 -06:00
GravisZro
b5632bbc3e Fix simple warnings
Most of these warnings are due to the use of NULL instead of 0 or NULL instead of '\0'.
Some are macro redefinitions. None of them are pointer storage related. Those will be
in another PR.
2024-04-18 15:13:35 -04:00
Louis Gombert
47f0f6e443 UIEdit: set char to 0 instead of NULL 2024-04-18 19:14:25 +02:00
Azamat H. Hackimov
38128ea134 Additional clang-format 2024-04-17 00:25:04 +03:00
Kevin Bentley
61be1317b2 More clanging 2024-04-16 14:46:12 -06:00
Kevin Bentley
c6640cc631 clang-format on everything. 2024-04-16 12:56:40 -06:00
Kevin Bentley
df209742fc Initial import 2024-04-15 21:43:29 -06:00