Commit graph

555 commits

Author SHA1 Message Date
bors[bot] a5b3bd9fa0
Merge #4733
4733: Fix MinGW warnings (fixes #4731) r=Jupeyy a=def-

`@Jupeyy` `@Robyt3` `@Zwelf` 

## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Dennis Felsing <dennis@felsin9.de>
2022-02-19 08:51:54 +00:00
Dennis Felsing aaec807963 Disable invalid cast warning in set_exception_handler_log_file 2022-02-18 12:55:13 +01:00
Dennis Felsing ded32c4334 Fix MinGW warnings (fixes #4731) 2022-02-18 12:54:19 +01:00
Jupeyy 4330ff83cf Add exception handling for Windows 2022-02-18 11:35:06 +01:00
Dennis Felsing dbfc62d2c0 Add modernize-deprecated-headers 2022-02-15 00:22:52 +01:00
Dennis Felsing 68e4eb21d5 Add modernize-use-bool-literals 2022-02-15 00:12:52 +01:00
ChillerDrgon 064ba50230 Add secure_random_uninit 2022-02-14 12:06:31 +01:00
Robert Müller 082e26d5ba Reduce system API calls when listing directory contents 2022-02-04 16:30:12 +01:00
heinrich5991 4d90119f25 Don't flush all files, some improvements to io_sync
- Empty buffers using `io_flush` before calling the OS function for
  syncing the file to disk.
- Fix error return of `io_sync` on Windows.
- Don't indiscriminately flush all files on close.
- Add a test that `io_sync` can return without error.
2022-02-01 02:33:18 +01:00
def 31f3c841ed Lower chance of losing written files by syncing them to disk on close
I'm wondering if this helps. Overhead exists, but is not that much (on
my system): 333 ms for initialization instead of 311 ms

If we only want to do this for files written to, then we need to keep
track of how the file was opened.
2022-02-01 02:32:53 +01:00
heinrich5991 7a6f5a8af4 Add a function for getting a handle to the current executable file 2022-01-31 21:31:26 +01:00
heinrich5991 67508adff1 Add function to get the OS version 2022-01-31 03:15:19 +01:00
bors[bot] 155a922d47
Merge #4628 #4639
4628: Disable or fix some spammy new clang-tidy 13 warnings r=heinrich5991 a=def-

```
src/engine/client/backend/opengles/opengles_sl_program.cpp:10:11: warning: suspicious #include of file with '.cpp' extension [bugprone-suspicious-include]
          ^

src/engine/graphics.h:330:67: warning: 2 adjacent parameters of 'CFreeformItem' of similar type ('float') are easily swapped by mistake [bugprone-easily-swappable-parameters]
                CFreeformItem(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3) :
                                                                                ^~~~~~~~~~~~~~~~~~

src/game/editor/layer_tiles.cpp:1802:14: warning: result of multiplication in type 'int' is used as a pointer offset after an implicit widening conversion to type 'ptrdiff_t' [bugprone-implicit-widening-of-multiplication-result]
                        mem_zero(&m_pSwitchTile[y * m_Width], o * sizeof(CSwitchTile));
                                  ^

src/game/server/entities/plasma.cpp💯152: warning: operator has equivalent nested operands [misc-redundant-expression]
        if(SnapPlayer && SnapPlayer->GetTeam() != TEAM_SPECTATORS && !SnapPlayer->IsPaused() && SnapChar && SnapChar && SnapChar->Team() != m_ResponsibleTeam && SnapPlayer->m_ShowOthers != 1)
                                                                                                ~~~~~~~~    ~~~~~~~~                                          ^

src/game/editor/editor.cpp:4295:38: warning: The right operand of '>' is a garbage value [clang-analyzer-core.UndefinedBinaryOperatorResult]
                        if(m_FilePreviewImageInfo.m_Width > Preview.w)
                                                          ^ ~~~~~~~~~
```
<!-- What is the motivation for the changes of this pull request -->

## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


4639: Fix SendStartWarning() to only warn every 3 seconds r=heinrich5991 a=def-

Thanks for Skeith for report

<!-- What is the motivation for the changes of this pull request -->

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: def <dennis@felsin9.de>
Co-authored-by: Dennis Felsing <dennis@felsin9.de>
2022-01-26 13:17:54 +00:00
Dennis Felsing 7903b40066 Quiet clang-tidy on macOS 2022-01-23 19:04:01 +01:00
Dennis Felsing c79320ed71 Improve macos performance
by declaring all threads as QoS class interactive
2022-01-23 18:23:09 +01:00
def 3f7befdd8b Add some further readability checks, mostly redundancy
/media/ddnet/src/engine/server/databases/sqlite.cpp:232:55: warning: the address of ‘char* sqlite3_expanded_sql(sqlite3_stmt*)’ will never be NULL [-Waddress]
  232 |         if(m_pStmt != nullptr && sqlite3_expanded_sql != nullptr)
      |                                  ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
2022-01-22 17:22:01 +01:00
def bc78ba57b9 Enable readability-inconsistent-declaration-parameter-name 2022-01-22 14:12:59 +01:00
Robert Müller 2f17fa9b39 close find handle in fs_file_time on windows 2022-01-18 22:42:08 +01:00
Zwelf dcabb07707 Fix uninitialized count variable and naming convention 2022-01-09 22:51:55 +01:00
Robert Müller 0726703937 fix undefined behavior in byte packing functions, add tests 2021-12-31 13:18:41 +01:00
bors[bot] 768a007eed
Merge #4429 #4517
4429: Pr sql fail fast r=heinrich5991 a=Zwelf

Remaining changes for #4424. Improving sql write times during shutdown and slow mysql responses/timeouts. I still want to test this change, especially for the last commit. Might have time for testing this evening. Thoughts and feedback on this patchset welcome.

## Checklist

- [ ] Tested the change ingame
   - [x] in mysql mod
   - [ ] in sqlite3 mode
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [x] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


4517: Rename EXPLODING BULLET to BULLET r=heinrich5991 a=def-

As suggested by Yuzu

<!-- What is the motivation for the changes of this pull request -->

## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Zwelf <zwelf@strct.cc>
Co-authored-by: def <dennis@felsin9.de>
2021-12-27 23:11:09 +00:00
Zwelf d8258fcda9 Add semaphore getvalue functionality 2021-12-25 10:53:26 +01:00
def 440baa17be Support building universal binaries with discord
For now only x86-64 is supported by discord sdk, arm64 we ship without
discord sdk. So players can choose if they want more performance without
discord integration, or less performance with discord integration.
2021-12-20 16:07:00 +01:00
heinrich5991 58533cddef Fix string functions not to truncate in the middle of a UTF-8 character
This makes `str_utf8_copy` obsolete.
2021-12-20 02:34:02 +01:00
heinrich5991 27f18824d6 Fix str_utf8_forward to use the same logic as str_utf8_decode 2021-12-20 02:17:10 +01:00
heinrich5991 ae9944550c Add a function to fix UTF-8 truncation at the end of a string
This can be used after truncating at byte boundaries.
2021-12-20 02:05:07 +01:00
def ffc532a302 Add open_file, works on macOS, safer 2021-12-19 23:22:04 +01:00
bors[bot] 79e5703e21
Merge #3638
3638: Revert "Let's not crash the client and server on dbg_assert" r=def- a=heinrich5991

This reverts commit a6e144e.

## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: heinrich5991 <heinrich5991@gmail.com>
2021-12-19 18:45:38 +00:00
heinrich5991 49c861372a Add a flag to skip a UTF-8 BOM when opening files for reading
https://en.wikipedia.org/w/index.php?title=Byte_order_mark&oldid=1059783325#UTF-8

This allows to read text files created by Windows users transparently,
even if they contain a UTF-8 BOM.
2021-12-17 22:07:01 +01:00
Robert Müller f20443b694 fix command line arguments with unicode on windows
Co-authored-by: heinrich5991 <heinrich5991@gmail.com>
2021-12-06 19:48:25 +01:00
Robert Müller 06a1d28a7f remove redundant *count >= max_count check 2021-11-28 11:00:49 +01:00
Robert Müller 7578386538 add empty lines to method documentation 2021-11-25 20:01:29 +01:00
Robert Müller 2ada540988 update str_utf8_stats documentation 2021-11-25 19:54:50 +01:00
Robert Müller 0253b6e25c refactor str_utf8_stats 2021-11-25 19:54:32 +01:00
Robert Müller 84ecbdb9d0 add str_utf8_stats to base system 2021-11-24 23:24:46 +01:00
Robert Müller e37ff4db65 remove unused fs_getmtime in favor of fs_file_time 2021-11-21 11:14:18 +01:00
Robert Müller 4bb5dbc84a do fs_is_dir smarter 2021-11-21 11:14:11 +01:00
Robert Müller b96fc7479e use str_format, improve code format 2021-11-21 10:41:57 +01:00
Robert Müller e1df7669f0 fix incorrect/inconsistent buffer sizes 2021-11-21 10:34:11 +01:00
Robert Müller c9dfbb6f45 fix unicode winsock error messages 2021-11-20 16:37:03 +01:00
Robert Müller 00606d1e2a fix open_link with unicode on windows 2021-11-20 13:36:05 +01:00
Robert Müller 30c65dedad add UNICODE defines on windows, misc. unicode fixes 2021-11-20 12:39:52 +01:00
bors[bot] cdfc521132
Merge #4340 #4350
4340: Add functions for packing/unpacking int/unsigned using char arrays r=heinrich5991 a=Robyt3

Add `uint_to_bytes_be` and `bytes_be_to_uint` functions from upstream and use them where applicable to reduce duplicate code.

## Checklist

- [X] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


4350: Fix map_extract r=heinrich5991 a=def-

Reported by cheeser0613

<!-- What is the motivation for the changes of this pull request -->

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [x] Considered possible null pointers and out of bounds array indexing
- [x] Changed no physics that affect existing maps
- [x] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Robert Müller <robert.mueller@uni-siegen.de>
Co-authored-by: def <dennis@felsin9.de>
2021-11-15 19:33:45 +00:00
Robert Müller c4e2dc5c5f make opening files for reading on windows case insensitive 2021-11-13 23:16:20 +01:00
Robert Müller 12699aa3e4 add functions for packing/unpacking int/unsigned using char arrays 2021-11-09 22:19:32 +01:00
def 724fbffaf0 Use uint64_t for network stats (fixes #4309)
Doesn't overflow so quickly, if it overflows has deterministic behavior
at least.
2021-11-06 23:32:54 +01:00
Robert Müller 385481462e fix fs_chdir with unicode on windows 2021-11-04 21:35:46 +01:00
Robert Müller 83d8e2bf7f fix fs_getcwd with unicode on windows 2021-11-04 21:22:17 +01:00
Robert Müller 3df3feb024 fix fs_makedir and fs_storage_path with unicode on windows 2021-11-04 21:20:36 +01:00
Jupeyy 66947b70b7 Fix detect.h 2021-10-16 21:16:47 +02:00