Commit graph

607 commits

Author SHA1 Message Date
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
Haoyu Qiu aca0b2a459 Fixes XMLParser leak when open multiple times 2020-01-20 11:29:14 +08:00
Fabio Alessandrelli 534bf89976 PacketPeer use heap buffer for var encoding.
Used to allocate in stack (via alloca) which causes crashes when trying
to encode big variables.
The buffer grows as needed up to `encode_buffer_max_size` (which is
8MiB by default) and always in power of 2.
2020-01-19 11:49:10 +01:00
George Marques 3718f8f592
GDScript: Validate object instance on is operation
Avoids crashes on debug mode. Instead it now breaks the execution and
show the error in-editor. Will still crash on release.

Also add a similar check to Marshalls to ensure the debugger doesn't
crash when trying to serialize the invalid instance.
2020-01-09 13:59:33 -03:00
Tomasz Chabora 97273ce378 Check if resource exists before loading 2020-01-08 15:24:43 +01:00
Joost Heitbrink dc61323b2c PCK: Set VERSION_PATCH in header, factor out header magic
Unify pack file version and magic to avoid hardcoded literals.

`version.py` now always includes `patch` even for the first release in
a new stable branch (e.g. 3.2). The public name stays without the patch
number, but `Engine.get_version_info()` already included `patch == 0`,
and we can remove some extra handling of undefined `VERSION_PATCH` this
way.

Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
2020-01-06 13:13:17 +01:00
Rémi Verschelde 3cbfb11460 MultiplayerAPI: Fix disconnect errors when passing invalid peer
Fixes #34634.
2020-01-03 13:34:54 +01:00
Rémi Verschelde a7f49ac9a1 Update copyright statements to 2020
Happy new year to the wonderful Godot community!

We're starting a new decade with a well-established, non-profit, free
and open source game engine, and tons of further improvements in the
pipeline from hundreds of contributors.

Godot will keep getting better, and we're looking forward to all the
games that the community will keep developing and releasing with it.
2020-01-01 11:16:22 +01:00
Fabio Alessandrelli cbc772d696 Fix buffers size calculation in PacketPeerStream.
The calculation used to be wrong when exactly at a power of 2.
`nearest_shift` always return the "next" power of 2
`nearest_shift(4) == 3 # 2^3 = 8`.

On the other hand `next_power_of_2` returns the exact value if that
value is a power of 2 (i.e. `next_power_of_2(4) == 4`).

I.e. :
```
WARN_PRINT(itos(next_power_of_2(4)) + " " + itos(1 << nearest_shift(4)));
// WARNING: ... : 4 8
```

Is this by design?
2019-12-22 15:35:44 +01:00
Fabio Alessandrelli 9269d6be32 UDP sockets broadcast is now disabled by default.
Add method `set_broadcast_enabled` to allow enabling broadcast via
GDScript.
2019-12-14 17:48:16 +01:00
Fabio Alessandrelli ab1bfb9007 NetSocket set_broadcast_enabled returns Error enum 2019-12-10 12:11:52 +01:00
Hugo Locurcio fe06966181
Make some arguments in PCKPacker methods optional
Those arguments aren't required for most common use cases,
so making them optional should help with code readability.
2019-12-07 01:06:42 +01:00
Rémi Verschelde 95242b7faf ResourceLoader: Add language code matching for localized resources
Near matching was not implemented like in TranslationServer, so a
resource remapped for 'ru' (but not 'ru_RU') would not be used as
fallback if the system locale was 'ru_RU'.

Fixes #34058.
2019-12-04 16:53:40 +01:00
Fabio Alessandrelli 6f38aeef52
Merge pull request #33640 from mewin/http_head_request
Fix HTTP HEAD requests
2019-12-01 05:50:33 +01:00
Patrick Wuttke 2cd68a2566 do not wait for response body when making a HEAD request 2019-11-26 14:17:34 +01:00
Rémi Verschelde 967cc2c014
Merge pull request #33862 from Faless/net/http_request_chunk_size
Add download_chunk_size property to HTTPRequest.
2019-11-25 14:29:59 +01:00
Fabio Alessandrelli ed19b4076e Add download_chunk_size property to HTTPRequest.
This allows setting the `read_chunk_size` of the internal HTTPClient.
This is important to reduce the allocation overhead and number of file
writes when downloading large files, allowing for better download speed.
2019-11-24 19:32:20 +01:00
Fabio Alessandrelli 9b2073aa97
Merge pull request #33652 from Black-Cat/http-client-fix
Fix HTTPClient::poll crash when connection set to null
2019-11-23 10:15:45 +01:00
Artem Burjachenko b73073ae36 Fix HTTPClient::poll crash when connection set to null 2019-11-23 11:06:14 +04:00
Rafał Mikrut 99d8626f4a Fix some overflows and unitialized variables 2019-11-20 16:22:16 +01:00
Fabio Alessandrelli 198af06ff6 MultiplayerAPI cleanup cache when peer disconnects
We used to only cleanup path_get_cache and not path_send_cache causing
issues when a peer disconnects and then reconnects with the same ID.
2019-10-25 18:03:58 +02:00
Rémi Verschelde c2edaa97f3
Merge pull request #32426 from gianllucah/master
Option to erase a section key in ConfigFile
2019-10-08 15:46:13 +02:00
Gianlluca 54cba54a45 Added a method to erase section key in ConfigFile 2019-10-07 18:11:19 -03:00
qarmin 2bc7f9e545 Fix small memory leak in PackedSourcePCK::try_open_pack 2019-10-03 19:45:41 +02:00
Fabio Alessandrelli dcf0a60a52
Merge pull request #32228 from damianday/patch-1
TCP is_connected_to_host comparison error
2019-09-26 03:02:14 +02:00
Damian Day 5631850152
Update stream_peer_tcp.cpp 2019-09-25 23:45:32 +01:00
Rémi Verschelde 28fcc5e25a
Merge pull request #32291 from Dragoncraft89/add_load_resource_flag
Add flag to control the replacement of files by ProjectSettings.load_resource_pack
2019-09-25 16:30:01 +02:00
Florian Kothmeier aae25abf30
Add flag to control the replacement of files by ProjectSettings.load_resource_pack 2019-09-25 15:29:59 +02:00
Rémi Verschelde dec10dd776
Merge pull request #32051 from qarmin/some_error_explanation
Added some obvious errors explanations
2019-09-25 11:51:54 +02:00
qarmin 17732fe698 Added some obvious errors explanations 2019-09-25 10:28:50 +02:00
Rémi Verschelde 393a0152ea
Merge pull request #32055 from qarmin/some_code_fixes
Changed some code found by Clang Tidy and Coverity
2019-09-23 10:00:31 +02:00
Rémi Verschelde b94460b328
Merge pull request #32032 from nekomatata/encrypted-file-get-path
Implemented get_path() & get_path_absolute() for FileAccessEncrypted
2019-09-23 09:32:58 +02:00