Commit graph

638 commits

Author SHA1 Message Date
Pedro J. Estébanez
4485b43a57 Modernize atomics
- Based on C++11's `atomic`
- Reworked `SafeRefCount` (based on the rewrite by @hpvb)
- Replaced free atomic functions by the new `SafeNumeric<T>`
- Replaced wrong cases of `volatile` by the new `SafeFlag`
- Platform-specific implementations no longer needed

Co-authored-by: Hein-Pieter van Braam-Stewart <hp@tmm.cx>
2021-02-18 12:23:25 +01:00
Pedro J. Estébanez
6d89f675b1 Modernize Thread
- Based on C++11's `thread` and `thread_local`
- No more need to allocate-deallocate or check for null
- No pointer anymore, just a member variable
- Platform-specific implementations no longer needed (except for the few cases of non-portable functions)
- Simpler for `NO_THREADS`
- Thread ids are now the same across platforms (main is 1; others follow)
2021-02-18 11:58:08 +01:00
Pedro J. Estébanez
8f6a636ae7 Modernize Semaphore
- Based on C++11's `mutex` and `condition_variable`
- No more need to allocate-deallocate or check for null
- No pointer anymore, just a member variable
- Platform-specific implementations no longer needed
- Simpler for `NO_THREADS`
2021-02-18 11:58:08 +01:00
Pedro J. Estébanez
4ddcdc031b Modernize Mutex
- Based on C++11's `mutex`
- No more need to allocate-deallocate or check for null
- No pointer anymore, just a member variable
- Platform-specific implementations no longer needed
- Simpler for `NO_THREADS`
- `BinaryMutex` added for special cases as the non-recursive version
- `MutexLock` now takes a reference. At this point the cases of null `Mutex`es are rare. If you ever need that, just don't use `MutexLock`.
- `ScopedMutexLock` is dropped and replaced by `MutexLock`, because they were pretty much the same.
2021-02-18 11:58:08 +01:00
Pedro J. Estébanez
b450036120 Modernize RWLock
- Based on C++14's `shared_time_mutex`
- No more need to allocate-deallocate or check for null
- No pointer anymore, just a member variable
- Platform-specific implementations no longer needed
- Simpler for `NO_THREADS`
2021-02-18 11:41:07 +01:00
Hugo Locurcio
15d9f77f97
Add a project setting to enable stdout flushing in release builds
This can be used in server builds for journalctl compatibility.

(cherry picked from commit 341b9cf15a)

Fixes crash when exiting with --verbose with leaked resources

(cherry picked from commit 25c4dacb88)
2021-02-16 14:27:38 +01:00
Rémi Verschelde
49646383f1
Update copyright statements to 2021
Happy new year to the wonderful Godot community!

2020 has been a tough year for most of us personally, but a good year for
Godot development nonetheless with a huge amount of work done towards Godot
4.0 and great improvements backported to the long-lived 3.2 branch.

We've had close to 400 contributors to engine code this year, authoring near
7,000 commit! (And that's only for the `master` branch and for the engine code,
there's a lot more when counting docs, demos and other first-party repos.)

Here's to a great year 2021 for all Godot users 🎆

(cherry picked from commit b5334d14f7)
2021-01-13 16:17:06 +01:00
Rémi Verschelde
66bfe855a8
Revert "Add a project setting to enable stdout flushing in release builds"
This reverts commit 341b9cf15a.

This makes the logger crash when used during cleanup: #44850.
2021-01-05 21:33:33 +01:00
Andy Savage
d097c0213c
Quick fix to incorrect error messages when writing to compressed or encrypted files.
(cherry picked from commit c65f097ebd)
2020-12-29 16:02:00 +01:00
Hugo Locurcio
f5f04a10f5
Add a project setting to enable stdout flushing in release builds
This can be used in server builds for journalctl compatibility.

(cherry picked from commit 341b9cf15a)
2020-12-29 16:02:00 +01:00
Fabio Alessandrelli
f73c9e555f
Remove now unused FileAccessBuffered.
(cherry picked from commit 781efc26e0)
2020-12-09 11:36:58 +01:00
Hugo Locurcio
8542d6ecd5
Tweak log file names for consistency between Mono and non-Mono logs
- Avoid spaces in Mono log file names.
- Use a `.log` extension for Mono logs, just like non-Mono logs.
- Use periods to separate hours/minutes/seconds for non-Mono logs.

(cherry picked from commit 4d81776fc9)
2020-12-09 11:22:05 +01:00
Jummit
deda90bad7
add root_node as property of MultiplayerAPI
(cherry picked from commit d4c4d2db4c)
2020-12-01 09:00:54 +01:00
Fabio Alessandrelli
f6cca77d8f
Disable SO_REUSEADDR for UDP.
It allows binding multiple sockets to the same ADDR:PORT (unlike TCP,
which still requires different ADDR:PORT combinations).

(cherry picked from commit 4b6a35c74a)
2020-12-01 09:00:52 +01:00
Haoyu Qiu
8361caad86
Allows HTTPClient to talk to proxy server
* Makes request uri accept absolute URL and authority
* Adds Host header only when missing

(cherry picked from commit d92ca6fbb1)
2020-11-17 12:07:01 +01:00
Zae
171768ab7c fix custom loader/saver broken 2020-11-14 23:30:57 +08:00
Hugo Locurcio
2c6b3074fc
Increase the default HTTPClient download chunk size to 64 KiB
This improves download speeds at the cost of increased memory usage.

This change also effects HTTPRequest automatically.

See #32807 and #33862.

(cherry picked from commit 13357095ee)
2020-11-11 15:30:55 +01:00
Rémi Verschelde
1dd2cf7914
Merge pull request #40747 from RandomShaper/improve_packed_fs_api_3.2
Improve/fix packed data API (3.2)
2020-11-10 10:59:59 +01:00
Haoyu Qiu
9119560d4d
Fixes HTTPClient::poll crash after connection is self-assigned
(cherry picked from commit 8226cee8d8)
2020-10-19 16:10:00 +02:00
Rémi Verschelde
6c03ac6625
Improve format version mismatch error in binary loader
(cherry picked from commit e35bb04c53)
2020-10-05 20:32:31 +02:00
Yilin Ma
d571de5f81
added load resource pack with offset feature
(cherry picked from commit c524d50444)
2020-09-24 14:43:09 +02:00
Hugo Locurcio
e04855ce00
Fix crash when opening a ZIP data pack
Co-authored-by: bruvzg <7645683+bruvzg@users.noreply.github.com>
(cherry picked from commit 0b65342fd2)
2020-09-24 14:43:07 +02:00
Rémi Verschelde
c8859f0463
Fix typos with codespell
Using codespell 1.17.1.

Method:
```
$ cat > ../godot-word-whitelist.txt << EOF
ang
curvelinear
dof
doubleclick
fave
findn
leapyear
lod
merchantibility
nd
numer
ois
ony
que
seeked
synching
te
uint
unselect
webp
EOF

$ codespell -w -q 3 -I ../godot-word-whitelist.txt --skip="./thirdparty,*.po"
$ git diff // undo unwanted changes
```
2020-09-18 14:09:51 +02:00
Marcel Admiraal
c6cccdf0c6 Ensure header guards enclose entire header.
(cherry picked from commit f6ad1954f7)
2020-09-04 08:48:35 +02:00
Hugo Locurcio
ee97e45a69 Improve the resource loading error message to mention the need to import
This is a common pitfall when setting up projects in a headless
environment.

(cherry picked from commit 58ed3037c0)
2020-09-04 08:48:17 +02:00
Yakov Borevich
63b2f69c7f
[funexpected] clear missed remaps on deinitialization, fixes godotengine/godot#34221
(cherry picked from commit 604bd75438)
2020-08-31 15:29:46 +02:00
Pedro J. Estébanez
fa08b0f377 Improve/fix packed data API
- Enhance directory API
- Fix `FileAccess::exists()` not checking for PackedData being disabled
- Fix moving to the parent directory (`..`)
- Allow absolute paths in existence checks
2020-07-27 11:24:00 +02:00
Adam Bates
b35970b9a5 issue-40396 - Added missing error strings to JSON parsing when array or object is never closed.
(cherry picked from commit 8f84dfa91d)
2020-07-24 10:31:57 +02:00
Fabio Alessandrelli
468a1c0271 UDPServer handles PacketPeerUDP-client association
UDPServer now uses a single socket which is shared with the
PacketPeerUDP it creates and has a new `poll` function to read incoming
packets on that socket and delivers them to the appropriate peer.
PacketPeerUDP created this way never reads from the socket, but are
allowed to write on it using sendto.

This is needed because Windows (unlike Linux/BSD) does not support
packet routing when multiple sockets are bound on the same address/port.

(cherry picked from commit 147bbe2155)
2020-07-15 12:48:18 +02:00
Rémi Verschelde
a06ee5e763 PO loader: Fix unclosed files and error messages
Fixes #40324.

(cherry picked from commit 47cc202972)

Also removes empty `p_path` as done in 4857648a16.
2020-07-15 12:48:18 +02:00
Hugo Locurcio
c2a4ce9380 Enable file logging by default on desktops to help with troubleshooting
- Use the `.log` file extension (recognized on Windows out of the box)
  to better hint that generated files are logs. Some editors provide
  dedicated syntax highlighting for those files.
- Use an underscore to separate the basename from the date and
  the date from the time in log filenames. This makes the filename
  easier to read.
- Keep only 5 log files by default to decrease disk usage in case
  messages are spammed.

(cherry picked from commit 20af28ec06)
2020-07-10 11:03:32 +02:00
Pedro J. Estébanez
b02e0b0c4b Fix debugger error when Dictionary key is a freed Object 2020-06-28 02:36:13 +02:00
Andy Maloney
7f18163ea6 [3.2] Ensure FileAccessBuffered structs are properly initialized 2020-06-19 11:32:53 -04:00
Rémi Verschelde
7bf9787921 SCons: Format buildsystem files with psf/black
Configured for a max line length of 120 characters.

psf/black is very opinionated and purposely doesn't leave much room for
configuration. The output is mostly OK so that should be fine for us,
but some things worth noting:

- Manually wrapped strings will be reflowed, so by using a line length
  of 120 for the sake of preserving readability for our long command
  calls, it also means that some manually wrapped strings are back on
  the same line and should be manually merged again.

- Code generators using string concatenation extensively look awful,
  since black puts each operand on a single line. We need to refactor
  these generators to use more pythonic string formatting, for which
  many options are available (`%`, `format` or f-strings).

- CI checks and a pre-commit hook will be added to ensure that future
  buildsystem changes are well-formatted.

(cherry picked from commit cd4e46ee65)
2020-06-10 15:30:52 +02:00
Fabio Alessandrelli
402a7e0094 Fix editor crash when mbedtls is disabled.
(cherry picked from commit 054f52364f)
2020-06-10 15:30:51 +02:00
Rémi Verschelde
ef715f37d5
Merge pull request #35091 from Faless/dtls/enet
[3.2] DTLS support + optional ENet encryption
2020-05-05 13:40:59 +02:00
Rémi Verschelde
faf858fe41 Revert "Made possible to specify where to dump the contents when loading a ".pck" file"
This reverts commit ffcfd9c8ea.

This was not so useful as is due to the way dependency paths are stored
in scenes and resources.
2020-04-20 13:48:02 +02:00
Michael Alexsander
ffcfd9c8ea Made possible to specify where to dump the contents when loading a ".pck" file
(cherry picked from commit 3c261e0dfa)
2020-04-17 13:00:52 +02:00
Rémi Verschelde
86ecefa1a2 Fix potential divisions by 0 reported by MSVC
The `TextEdit` one was indeed a potential bug.
The `PCKPacker` one seems to be a false positive, it's already in a
`for` loop that depends on `files.size()`.

(cherry picked from commit ca4e4506db)
2020-03-25 11:38:54 +01:00
Rémi Verschelde
d4e6eff2de ConfigFile: Improve error messages and complete docs
(cherry picked from commit f7c87ed3dd)
2020-03-06 23:51:26 +01:00
Fabio Alessandrelli
35a9f0fe64 New PacketPeerDTLS and DTLSServer classes.
Custom instance implementation via the mbedtls module.
2020-02-25 11:35:47 +01:00
Fabio Alessandrelli
2c8340bee9 UDPServer and PacketPeerUDP connect_to_host.
UDP sockets can be "connected" to filter packets from a specific source.
In case of a bound socket (e.g. server), a new socket can be created on
the same address/port that will receive all packets that are not
filtered by a more specific socket (e.g. the previously connect socket).

This way, a UDPServer can listen to new packets, and return a new
PacketPeerUDP when receiving one, knowing that is a "new client".
2020-02-25 11:35:47 +01:00
Fabio Alessandrelli
6b9240aa84 Add peek option to NetSocket recv_from. 2020-02-25 11:26:34 +01:00
Haoyu Qiu
c81241e6c0 Fixes crash when resource file is corrupted
(cherry picked from commit 832a5c860b)
2020-02-14 16:07:41 +01:00
Pedro J. Estébanez
541251dff7 Add ConfigFile::parse()
(cherry picked from commit e5bd3b707f)
2020-02-14 16:06:36 +01:00
Haoyu Qiu
a7368a519e Fixes leak when importing zip in AssetLib 2020-01-22 09:34:18 +08:00
Rémi Verschelde
79aaafc686
Merge pull request #35408 from Faless/ws/fix_packet_count
Fix MultiplayerAPI crash when peer implementation misbehave.
2020-01-21 21:06:11 +01:00
Fabio Alessandrelli
50f1b035b8 Fix MultiplayerAPI crash when peer impl misbehave.
Also fix WebSocketMultiplayer::get_available_packet_count() return value
when peer is not configured to use the multiplayer API.
2020-01-21 20:46:32 +01:00
Rémi Verschelde
11260fb87f
Merge pull request #35345 from timothyqiu/pck-packer-leak
Fixes leak when calling PCKPacker::pck_start multiple times
2020-01-20 07:00:11 +01:00
Haoyu Qiu
07941178f0 Fixes leak when pck_start multiple times 2020-01-20 12:16:37 +08:00