Commit Graph

931 Commits

Author SHA1 Message Date
C.W. Betts
7d5b51e8f8 macOS: Make sure the netcon modules end with dylib. 2024-08-05 15:54:38 -06:00
Louis Gombert
fd08fab0dd
Merge pull request #507 from MaddTheSane/clangWarn
Quiet warnings about uninitialized values.
2024-08-03 15:37:33 +02:00
C.W. Betts
1384aa62af Quiet warnings about uninitialized values. 2024-07-31 15:40:16 -06:00
Louis Gombert
ae5840f314
Merge pull request #502 from winterheart/modules-split
Splitting submodules of project
2024-07-30 23:17:47 +02:00
Azamat H. Hackimov
5b80408450
Merge pull request #503 from Lgt2x/main-cleanup
Cleanup sdlmain.cpp
2024-07-31 00:11:25 +03:00
Louis Gombert
9c016dde45
Merge pull request #504 from pzychotic/msvc-build-settings
Cleanup MSVC build settings
2024-07-29 08:54:03 +02:00
Thomas Roß
8c88a8fc21 [Build] Removed unused IS_WINDOWS and duplicate _CRT_SECURE_NO_WARNINGS compiler defines. 2024-07-29 00:29:12 +02:00
Thomas Roß
3b3cd434e3 [Build] Add /LTCG (Link Time Code Generation) to linker flags in Relese builds.
We already add /GL (Whole Program Optimization) to the compiler flags in Release builds. By not using /LTCG for the linker, the build output will be spammed with following message:
MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance
2024-07-29 00:29:12 +02:00
Thomas Roß
ead9f61558 [Build] Replaced string based handling of linker flags with add_link_options(). 2024-07-29 00:29:12 +02:00
Azamat H. Hackimov
4b192f8960
Merge pull request #500 from Lgt2x/cache-dir
Use standard temporary directory instead of custom/cache
2024-07-28 22:10:34 +03:00
Azamat H. Hackimov
dd32f4e3ed Split libacm files to third_party/libacm and AudioEncode
Logically adecode/aencode belongs to AudioEncode.
2024-07-28 21:51:35 +03:00
Louis Gombert
a0a4195a3a SDLMain: remove unused defines, superfluous logging 2024-07-28 17:52:01 +02:00
Louis Gombert
ae58bb674f Remove leftover glide renderer references 2024-07-28 17:52:01 +02:00
Louis Gombert
529e5de6d3 sdlmain: remove unused and outdated d3ArgTable 2024-07-28 17:52:01 +02:00
Louis Gombert
1328a8c846 Remove non-functional OpenGL logging methods 2024-07-28 17:52:01 +02:00
Louis Gombert
fc2268d629 DMFC: declare external DMCFStringTable, DMFCStringTableSize, _DMFCErrorString, basethis and DMFCGetString only when needed 2024-07-28 17:52:01 +02:00
Louis Gombert
292d9086a7 Create temp directory when set with -tempdir too 2024-07-28 17:47:53 +02:00
Louis Gombert
bfd04737b9 Non-throwable temp path function 2024-07-28 16:27:50 +02:00
Azamat H. Hackimov
cb9e0f8828 Remove unused osTask class 2024-07-28 16:50:43 +03:00
Azamat H. Hackimov
fc209ddba4 Remove unused texture.h 2024-07-28 16:50:43 +03:00
Azamat H. Hackimov
220108f650 Isolate libacm module
Update libacm module, minor cleanups.
2024-07-28 16:50:43 +03:00
Azamat H. Hackimov
c773fbbe70 Isolate unzip module
Update unzip module, minor cleanups.
2024-07-28 16:50:43 +03:00
Azamat H. Hackimov
7ba009b811 Isolate rtperformance module
Update rtperformance module, minor cleanups.
2024-07-28 16:50:42 +03:00
Azamat H. Hackimov
b9da6b59ff Isolate physics module
Update physics module, minor cleanups, remove unused code.
2024-07-28 16:50:42 +03:00
Azamat H. Hackimov
b876716115 Update model module
Remove ddio module usage.
2024-07-28 16:50:42 +03:00
Azamat H. Hackimov
9e3563de4d Isolate model submodule
Isolate model from rest of the project, minor cleanups.
2024-07-28 16:50:42 +03: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
Azamat H. Hackimov
e9ac3b3ceb Merge d3movie module into Descent3
Simplify project layout, minor cleanup.
2024-07-28 16:50:41 +03:00
Azamat H. Hackimov
73d4853505 Merge d3music module into Descent3
Simplify project layout, minor cleanup.
2024-07-28 16:50:41 +03:00
Azamat H. Hackimov
e93a8bfc0e Remove czip module as unused 2024-07-28 16:50:41 +03:00
Azamat H. Hackimov
f1737d2a19 Isolate AudioEncode submodule
Isolate AudioEncode from rest of the project, minor cleanups
2024-07-28 16:50:41 +03:00
Azamat H. Hackimov
61d1d9e757
Merge pull request #498 from Lgt2x/cpack-installer
Add icons to Windows and MacOS bundles
2024-07-28 16:12:57 +03:00
Louis Gombert
2693922e10 Add more detail to RC file 2024-07-28 16:11:44 +02:00
Azamat H. Hackimov
506521695a Isolate 2dlib submodule
Isolate 2dlib from rest of the project, minor cleanups
2024-07-27 22:21:29 +03:00
Louis Gombert
0d7ad92c61 Use standard temporary directory to store cache data instead of custom/cache 2024-07-26 01:22:32 +02:00
Louis Gombert
f23607f91f Add more information in Windows RC file 2024-07-23 00:14:09 +02:00
Louis Gombert
d3659bb56b
Merge pull request #499 from vlohacks/main
fix path creation in gamesave.cpp
2024-07-22 08:18:27 +00:00
vlohacks
07a99c348f
Update gamesave.cpp
Fix wrong comparison
2024-07-22 10:03:36 +02:00
vlohacks
06c416837c
Update gamesave.cpp
Fix integer / std::error_code comparison
2024-07-22 09:47:52 +02:00
vlohacks
7a35de0efa
fix path creation in gamesave.cpp
std::filesystem::create_directories returns false but no error code if the path already exists.
Hence no longer saving was possible as soon as the path exists.
Added check for the error code (ec) to be non-zero for the error message
2024-07-22 09:15:36 +02:00
Louis Gombert
f4c142b6db Set app icon for MacOS, build a bundle instead of executable 2024-07-20 21:24:03 +02:00
Louis Gombert
592191a325 Set executable icon for Windows 2024-07-20 21:24:03 +02:00
Louis Gombert
7cd7902584
Merge pull request #494 from Jayman2000/encoding-improvements
Ensure UTF-8 is used in more places
2024-07-20 18:04:54 +00:00
Azamat H. Hackimov
f78bd57a81
Merge pull request #489 from Lgt2x/mve-no-sound
Support -nosound option for movie playbacks
2024-07-19 13:41:41 +03:00
Louis Gombert
5641ba49bd
Merge pull request #491 from winterheart/mve-update
MVE refactoring
2024-07-18 21:37:59 +00:00
Jason Yundt
5a199429b6 Set activeCodePage to UTF-8
Consider this program:

  #include <cstdio>

  int main(void) {
    const char *filename = u8"ディセント3.txt";
    auto fp = std::fopen(filename, "r");
    if (fp) {
      std::fclose(fp);
      return 0;
    } else {
      return 1;
    };
  }

If a file named ディセント3.txt exists, then will that program
successfully open it? The answer is: it depends.

filename is going to point to these bytes:

  Raw bytes: e3 83 87 e3 82 a3 e3 82 bb e3 83 b3 e3 83 88 33 2e 74 78 74 00
  Characters: ディセント3.txt␀

Internally, Windows uses UTF-16. When you call fopen(), Windows will
convert the filename parameter into UTF-16 [1]. If the program is run
with a UTF-8 Windows code page, then the above bytes will be correctly
interpreted as UTF-8 when being converted into UTF-16 [2]. The final
UTF-16 string will be this*:

  Raw bytes: ff fe c7 30 a3 30 bb 30 f3 30 c8 30 33 00 2e 00 74 00 78 00 74 00
  Characters: ディセント3.txt

On the other hand, if the program is run with code page 932, then the
original bytes will be incorrectly interpreted as code page 932 when
being converted into UTF-16. The final UTF-16 string will be this*:

  Raw bytes: ff fe 5d 7e fd ff 67 7e 63 ff 67 7e 7b ff 5d 7e 73 ff 5d 7e fd ff 33 00 2e 00 74 00 78 00 74 00
  Characters: 繝�繧」繧サ繝ウ繝�3.txt

In other words, if that program gets compiled on Windows with a UTF-8
execution character set, then it needs to be run with a UTF-8 Windows
code page. Otherwise, mojibake might happen.

*Unlike the first string, this one does not have a null terminator. This
is because the Windows kernel doesn’t use null terminated strings for
paths [3][4].

---

Before this commit, Descent 3 would pass UTF-8 to fopen(), even if
Descent 3 is run with a non-UTF-8 Windows code page [5]. This commit
makes sure that Descent 3 gets run with a UTF-8 Windows code page.

The Windows code page isn’t just used by fopen(). It also gets used by
many other functions in the Windows API [6]. I don’t know if Descent 3
uses any of those other functions, but if it does, then this commit will
also help make sure that those functions receive strings with the
correct character encoding. Descent 3 uses UTF-8 for strings by default
[7]. Making sure that Descent 3 uses UTF-8 everywhere will make
encoding-related mistakes less likely in the future.

Fixes #483.

[1]: <https://stackoverflow.com/a/7950569/7593853>
[2]: <https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/fopen-wfopen?view=msvc-170#remarks>
[3]: <https://stackoverflow.com/a/52372115/7593853>
[4]: <https://googleprojectzero.blogspot.com/2016/02/the-definitive-guide-on-win32-to-nt.html>
[5]: <https://github.com/DescentDevelopers/Descent3/pull/475#discussion_r1664888080>
[6]: <https://learn.microsoft.com/en-us/windows/apps/design/globalizing/use-utf8-code-page#-a-vs--w-apis>
[7]: adf58eca (Explicitly declare execution character set, 2024-07-07)
2024-07-17 10:25:40 -04:00
Jason Yundt
adf58eca81 Explicitly declare execution character set
Consider this program:

  #include <cstdio>

  int main(void) {
    const char *example_string = "ディセント3";
    for (size_t i = 0; example_string[i] != '\0'; ++i) {
      printf("%02hhx ", example_string[i]);
    }
    puts("");

    return 0;
  }

What will that program output? The answer is: it depends. If that
program is compiled with a UTF-8 execution character set, then it will
print this:

  e3 83 87 e3 82 a3 e3 82 bb e3 83 b3 e3 83 88 33

If that program is compiled with a Shift JIS execution character set,
then it will print this:

  83 66 83 42 83 5a 83 93 83 67 33

This is especially a problem when using MSVC. MSVC doesn’t necessarily
default to using UTF-8 as a program’s execution character set [1].

---

Before this change, Descent 3 would use whatever the default execution
character set was. This commit ensures that the execution character set
is UTF-8 as long as Descent 3 gets compiled with MSVC, GCC or Clang. If
Descent 3 is compiled with a different compiler, then a different
execution character set might get used, but as far as I know, we only
support MSVC, GCC and Clang.

I’m not sure whether or not this change has any noticeable effects. If
using different execution character sets do have noticeable effects,
then this change will hopefully ensure that those effects are the same
for everyone.

[1]: <https://learn.microsoft.com/en-us/answers/questions/1805730/what-is-msvc-s-default-execution-character-set>
2024-07-17 10:13:34 -04:00
Jason Yundt
dd757e9034 Explicitly declare that source files are UTF-8
Before this change, there was a chance that a text editor or compiler
would use the wrong character encoding. For text editors, this commit
adds “charset = utf-8” to .editorconfig. That will cause editors that
support EditorConfig files [1] to automatically use UTF-8 when reading
and writing files. For compilers, this commit adds compiler options that
guarantee that compilers will decode source code files using UTF-8. The
compiler options are known to work on MSVC, GCC and Clang. If we ever
want to support additional compilers, then we might have to edit the if
statement that this commit adds.

This commit does not eliminate the chance that a wrong character
encoding will be used. Someone could always use a text editor that
doesn’t support EditorConfig files or a compiler that doesn’t support
the compiler options that we use. This commit does, however, make an
encoding mismatch much less likely.

[1]: <https://editorconfig.org/#pre-installed>
2024-07-17 10:12:09 -04:00
Azamat H. Hackimov
91354d5b9a
Merge pull request #492 from tophyr/pr/posix-defines
Use `POSIX` instead of `__LINUX__` for general OS checks
2024-07-15 23:33:10 +03:00