Commit graph

229 commits

Author SHA1 Message Date
Jupeyy 3c597aff95 Switch to nanoseconds 2022-05-18 18:05:41 +02:00
heinrich5991 6977bdc782 Make NETADDR forward-declarable 2022-05-18 09:16:08 +02:00
heinrich5991 b9e255a7a1 Mark dbg_break as [[noreturn]] 2022-05-13 09:04:39 +02:00
heinrich5991 52d0dc8b5b Add functions to encode/decode base64 2022-05-13 09:00:48 +02:00
heinrich5991 fa4bcd5ec0 Unify logging infrastructure between IConsole and dbg_msg
This makes the "black console window" less important on Windows (or
anywhere else, for that matter), lets you see logs from other threads in
the f1 console, and removes the distinction between `IConsole::Print`
and `dbg_msg`.
2022-04-29 15:21:26 +02:00
Edgar 2fca2872b4
Merge branch 'master' into pr/system/documentation 2022-04-29 10:26:45 +02:00
def 790c1cc0aa Switch new players to DDNet config dir, support Teeworlds as fallback
This way new players will get DDNet directory, old ones can switch
directory if they want, or keep using the old one.

If we ever enforce a switch in a future version, this will make it
easier since older DDNet versions will also support the DDNet directory
already.
2022-04-25 09:50:45 +02:00
heinrich5991 103b663662 Rename ActCur, some "actual" → "current"
Seems like it got introduced by means of the false friend "actual" ≠
"aktuell" = "current".
2022-04-23 00:42:37 +02:00
bors[bot] f49afca3dc
Merge #4818
4818: Add str_startswith_nocase and str_endswith_nocase r=def- a=ChillerDragon

Gets rid of the more complex str_comp_nocase_num usage

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [x] 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)


Co-authored-by: ChillerDragon <ChillerDragon@gmail.com>
2022-03-20 10:27:18 +00:00
heinrich5991 897ba5854a Use system.h style for system.h 2022-03-13 19:45:01 +01:00
ChillerDragon 99b0eb2819 Add str_startswith_nocase and str_endswith_nocase 2022-03-13 11:42:45 +01:00
Jupeyy 25ceea6f5f Write log to disk on assert 2022-03-12 13:48:29 +01:00
heinrich5991 1a35595bce Unify buffer handling in UDP sockets across operating systems
Previously, only Linux used an internal buffer (for optimized
receiving). Now all OSs use an internal buffer so that the call to
`net_udp_recv` behaves the same on all platforms.
2022-03-05 14:11:03 +01:00
heinrich5991 a8664a0100 Hide the recvmmsg as an implementation detail 2022-03-04 19:33:06 +01:00
heinrich5991 471bb441a1 Move NETSOCKET behind a pointer so it can grow 2022-03-04 19:33:06 +01:00
Edgar a7c25964f4
progress 2022-03-04 12:02:18 +01:00
Edgar 7fbcaa6d36
start document system.h with doxygen 2022-02-18 11:35:46 +01:00
Jupeyy 4330ff83cf Add exception handling for Windows 2022-02-18 11:35:06 +01:00
ChillerDrgon 064ba50230 Add secure_random_uninit 2022-02-14 12:06:31 +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
def bc78ba57b9 Enable readability-inconsistent-declaration-parameter-name 2022-01-22 14:12:59 +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 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 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 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 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
heinrich5991 406bb85873 Fix dbg_* comments to reflect reality
They also work in release mode.
2021-09-13 12:58:18 +02:00
heinrich5991 deb4917563 Revert "Let's not crash the client and server on dbg_assert"
This reverts commit a6e144ea72.
2021-09-13 12:57:53 +02:00
bors[bot] 121173b5d6
Merge #4111
4111: Fix filesystem/IO with unicode filenames on windows r=def- a=Robyt3

It was previously not possible to load a map or really any file with a filename containing unicode, e.g. german umlauts.

Now all filenames are converted from multibyte to widechar on windows, and the correct functions and structs (with the `W` suffix) are used consistently.

Some changes are made to synchronize ddnet's implementation with upstream (once https://github.com/teeworlds/teeworlds/pull/2936 has been merged there):
- The unused and not working `IOFLAG_RANDOM` is removed (on upstream ddnet's `IOFLAG_APPEND` is added instead).
- The `fs_listdir_info` function is renamed to `fs_listdir_fileinfo` and now using the parameter object `CFsFileInfo` that contains the filename, modified date and creation date, making it easier to add more properties in the future. `FS_LISTDIR_INFO_CALLBACK` is renamed to `FS_LISTDIR_CALLBACK_FILEINFO`.

## 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: Robert Müller <robert.mueller@uni-siegen.de>
2021-08-30 09:02:24 +00:00
BloodWod b9d660dd95 Add colors for dbg_msg console 2021-08-28 04:42:42 +05:00
Robert Müller c89cdc6806 add fs_file_time 2021-08-23 13:29:33 +02:00
Robert Müller 4a375242c5 fix fs_listdir and fs_listdir_fileinfo with unicode on windows 2021-08-23 12:49:15 +02:00
Robert Müller 75662b6c1a remove unused and not implemented IOFLAG_RANDOM, add assert 2021-08-23 12:30:12 +02:00
Jupeyy c7580b374c Remove Windows XP code 2021-08-23 12:05:01 +02:00
Jupeyy 69aa97fe9e Remove (void) parameter of functions 2021-06-24 17:19:17 +02:00
Jupeyy a663799188 uint64 -> uint64_t, int64 -> int64_t 2021-06-24 17:19:17 +02:00
Jupeyy 9dfea5511a Use cpp 2021-06-24 17:19:17 +02:00
heinrich5991 fb27b83d79 Add function to remove directories
Add tests. Unify behavior of `fs_remove` across operating systems to
only remove files, not directories. Previously on Linux, it would also
delete directories.
2021-05-14 01:00:41 +02:00
heinrich5991 782c826381 Add secure_rand_below function
It works by masking the numbers and the using rejection sampling to
ensure a uniform generation.
2021-05-12 17:02:02 +02:00
Panagiotis Vasilopoulos 6c02076c05 Copied Teeworld patches for the Haiku operating system
Co-authored-by: Gerasim Troeglazov <3dEyes@gmail.com>
2021-04-17 20:10:56 +02:00