Commit graph

1055 commits

Author SHA1 Message Date
Danil Alexeev
1ca227af1d
Fix saving section-less keys in ConfigFile 2022-06-07 18:05:49 +03:00
Rémi Verschelde
6cd730ea98
Merge pull request #61339 from lyuma/streampeerssl_get_stream 2022-06-02 00:27:07 +02:00
Lyuma
7e28385948 Add StreamPeerSSL.get_stream() accessor. 2022-05-25 12:43:19 -07:00
Rémi Verschelde
9923851370 Fix typos with codespell
Using codespell 2.2-dev from current git.
2022-05-23 21:32:19 +02:00
reduz
45af29da80 Add a new HashSet template
* Intended to replace RBSet in most cases.
* Optimized for iteration speed
2022-05-20 22:40:38 +02:00
Aaron Record
900c676b02 Use range iterators for RBSet in most cases 2022-05-19 12:09:16 +02:00
Rémi Verschelde
d6edc6d18a
Merge pull request #60126 from Calinou/image-improve-error-messages 2022-05-16 15:02:49 +02:00
reduz
746dddc067 Replace most uses of Map by HashMap
* Map is unnecessary and inefficient in almost every case.
* Replaced by the new HashMap.
* Renamed Map to RBMap and Set to RBSet for cases that still make sense
  (order matters) but use is discouraged.

There were very few cases where replacing by HashMap was undesired because
keeping the key order was intended.
I tried to keep those (as RBMap) as much as possible, but might have missed
some. Review appreciated!
2022-05-16 10:37:48 +02:00
reduz
8b7c7f5a75 Add a new HashMap implementation
Adds a new, cleaned up, HashMap implementation.

* Uses Robin Hood Hashing (https://en.wikipedia.org/wiki/Hash_table#Robin_Hood_hashing).
* Keeps elements in a double linked list for simpler, ordered, iteration.
* Allows keeping iterators for later use in removal (Unlike Map<>, it does not do much
  for performance vs keeping the key, but helps replace old code).
* Uses a more modern C++ iterator API, deprecates the old one.
* Supports custom allocator (in case there is a wish to use a paged one).

This class aims to unify all the associative template usage and replace it by this one:
* Map<> (whereas key order does not matter, which is 99% of cases)
* HashMap<>
* OrderedHashMap<>
* OAHashMap<>
2022-05-12 11:21:29 +02:00
Rémi Verschelde
2fd73bd32e
Merge pull request #60943 from bruvzg/fix_zipio 2022-05-11 16:59:31 +02:00
bruvzg
d36c5514d3
Fix ZipIO crash when reused (and possible leaks). 2022-05-11 16:08:17 +03:00
Haoyu Qiu
34c1a2beaa Fix invalid memory usage when using Image.convert 2022-05-11 17:39:27 +08:00
Rémi Verschelde
d8935b27a9 Fix warnings found by Emscripten 3.1.10
Fix `-Wunused-but-set-variable`, `-Wunqualified-std-cast-call`, and
`-Wliteral-range` warnings.
2022-05-10 13:03:13 +02:00
Rémi Verschelde
71e41eb395
Merge pull request #60597 from reduz/missing-node-resource-placeholders 2022-05-05 15:57:50 +02:00
Fabio Alessandrelli
e5137fafbe [Net] Fix StreamPeerTCP accepted status. 2022-05-04 20:13:32 +02:00
reduz
0a57f964a3 Implement missing Node & Resource placeholders
Implemented by request of @neikeq to advance in the GDExtension version of Mono.

* If a Resource type is missing upon load, it will be remembered together with its data (Unless manually overriden).
* If a Node type is missing upon load, it will be also be remembered together with its data (unless deleted).

This feature makes working with GDExtension much easier, as it ensures that missing types no longer cause data loss.
2022-05-03 17:08:09 +02:00
Rémi Verschelde
931838b330
Merge pull request #60627 from aaronfranke/rename-elements
Rename Transform2D and Basis `elements` to `columns` and `rows` respectively
2022-05-03 14:40:01 +02:00
Hugo Locurcio
180e5d3028
Remove RES and REF typedefs in favor of spelled out Ref<>
These typedefs don't save much typing compared to the full `Ref<Resource>`
and `Ref<RefCounted>`, yet they sometimes introduce confusion among
new contributors.
2022-05-03 01:43:50 +02:00
Rémi Verschelde
78193788d0
Merge pull request #59895 from akien-mga/clang-tidy 2022-05-02 17:45:13 +02:00
Rémi Verschelde
c273ddc3ee Style: Partially apply clang-tidy's cppcoreguidelines-pro-type-member-init
Didn't commit all the changes where it wants to initialize a struct
with `{}`. Should be reviewed in a separate PR.

Option `IgnoreArrays` enabled for now to be conservative, can be
disabled to see if it proposes more useful changes.

Also fixed manually a handful of other missing initializations / moved
some from constructors.
2022-05-02 16:28:25 +02:00
bruvzg
7b18c35ab2 Fix resource dependence renaming. 2022-05-02 16:38:09 +03:00
Aaron Franke
1bf94dff3a
Rename Basis "elements" to "rows" 2022-04-29 08:02:56 -05:00
Aaron Franke
b831fb0a54
Rename Transform2D "elements" to "columns" 2022-04-29 08:02:39 -05:00
Rémi Verschelde
504708ae21
Merge pull request #56093 from bruvzg/pck_section_load
Improve embedded PCK loading and exporting.
2022-04-27 14:29:21 +02:00
Rémi Verschelde
6e6fe2b025
Merge pull request #59582 from Faless/net/4.x_tcp_explicit_poll 2022-04-27 13:56:58 +02:00
Rémi Verschelde
8dfa12cae7
Merge pull request #59979 from bruvzg/cpp_check2 2022-04-27 10:08:26 +02:00
Haoyu Qiu
caf8e5e339 Close FileAccess before accessing it with DirAccess 2022-04-22 18:15:31 +08:00
bruvzg
c0cc41d6c1
Improve embedded PCK loading and exporting.
Windows export process:
  Limit size of executable with embedded PCK to 4 GB.
  Use "rcedit" before embedding PCK.
  Capture and process "rcedit" errors.

Windows, Linux:
  Add support for PCK loading from executable "pck" section.
2022-04-20 11:09:59 +03:00
bruvzg
de4c97758a
Fix more issues found by cppcheck. 2022-04-20 10:34:00 +03:00
Hugo Locurcio
3ca4514866
Merge pull request #50175 from kleonc/image-blit-blend-fix-rects
`Image.blit_rect/blend_rect` Fix rects calculations for negative arguments
2022-04-19 16:30:08 +02:00
Rémi Verschelde
46ef52162e Color: Rename to_srgb/to_linear to include base color space
This helps reduce confusion around sRGB <> Linear conversions by making
both input and output color spaces explicit.
2022-04-13 11:45:52 +02:00
bruvzg
d2ebac3a30
Remove or make private FileAccess close() methods. 2022-04-12 14:50:14 +03:00
bruvzg
4bf99f4af2 Narrow FileAccess scope to prevent deadlocks. 2022-04-12 10:54:39 +03:00
bruvzg
9381acb6a4
Make FileAccess and DirAccess classes reference counted. 2022-04-11 13:28:51 +03:00
Hugo Locurcio
18e9e6a81a
Improve error messages when creating Images from code
The rationale behind the expected number of bytes is now displayed
in clear (width, height, format, number of mipmaps expected if any).
2022-04-11 01:13:50 +02:00
Rémi Verschelde
bf153b82c7
Merge pull request #59324 from Zylann/fix_fvec_array_binary_load
Fix loading binary resources with float=64
2022-04-08 09:06:04 +02:00
Marc Gilleron
0b108f159a Fix loading binary resources with float=64
- PackedVector2Array
- PackedVector3Array
- PackedColorArray
2022-04-08 00:29:44 +01:00
bruvzg
f851c4aa33
Fix some issues found by cppcheck. 2022-04-06 14:34:37 +03:00
Rémi Verschelde
f8ab79e68a Zero initialize all pointer class and struct members
This prevents the pitfall of UB when checking if they have been
assigned something valid by comparing to nullptr.
2022-04-04 19:49:50 +02:00
reduz
45f74ceb85 Add PortableCompressedTexture
* Resource that allows saving textures embedded in scenes or standalone.
* Supports only formats that are portable: Lossy, Lossles or BasisUniversal

This is something I wanted to add for a long time. I made it now because @fire
requires it for importing GLTF2 files with embedded textures, but also this
will allow saving Godot scenes as standalone binary files that will run
in all platforms (because textures will load everywhere).

This is ideal when you want to distribute individual standalone assets online
in games that can be built from Godot scenes.
2022-03-30 10:39:41 +02:00
Rémi Verschelde
7119d355eb String: Remove TTR and DTR defines in non-tools build
This ensures we don't use TTR in runtime code, as it's specifically meant
to source translations for the editor.
2022-03-28 20:26:35 +02:00
Fabio Alessandrelli
331f1662df [Net] Drop is_connected_to_host for TCP and UDP.
The UDP method is now called `is_socket_connected` to limit confusion
with the actual host connection status which doesn't make sense in UDP.

The TCP method is completly dropped, use get_status instead.

The only one left is the WebSocketPeer one, which should be fine as is
for now.
2022-03-27 16:36:44 +02:00
Fabio Alessandrelli
0e52867668 [Net] Make StreamPeerTCP::_poll_connection explicit.
No longer hacked into `get_status` and renamed to `poll`.

The old `poll` (for *nix `poll`, win `select`) is now called `wait`.
2022-03-27 16:36:44 +02:00
Rémi Verschelde
5371009d8e Object: Remove unused category boilerplate
We might want to re-add something like this if/when we find a good use case
for it and do the effort to categorize all objects in the API properly.

Until then, it's better to remove that boilerplate since it's not needed.

Closes #18711.
2022-03-26 15:46:01 +01:00
Hugo Locurcio
7d8b344f01
Increase the maximum number of concurrent DNS queries from 32 to 256
This makes the following error message less likely to be printed
when performing many concurrent HTTP requests:

    Condition ' resolving == IP::RESOLVER_INVALID_ID ' is true. returned: ERR_BUG
2022-03-23 18:18:23 +01:00
Haoyu Qiu
680bcef825 Fix crash when exporting projects with shared libraries 2022-03-23 13:53:32 +08:00
bruvzg
35e8fd4d04
Add binary MO translation file support. 2022-03-18 23:23:32 +02:00
bruvzg
f19cd44346
Unify TextServer built-in module and GDExtension code. 2022-03-17 08:15:29 +02:00
Rémi Verschelde
51bbcbdec2
Merge pull request #45263 from KoBeWi/😕 2022-03-15 13:18:27 +01:00
Rémi Verschelde
2724e57288
Merge pull request #58772 from keptsecret/fix_filedialog_user_data_access
Fix unable to change directory in user access mode
2022-03-12 20:53:43 +01:00
Rémi Verschelde
768f9422bc Convert uses of DirAccess * to DirAccessRef to prevent memleaks
`DirAccess *` needs to be deleted manually, and this is often forgotten
especially when doing early returns with `ERR_FAIL_COND`.
`DirAccessRef` is deleted automatically when it goes out of scope.

Co-authored-by: bruvzg <7645683+bruvzg@users.noreply.github.com>
2022-03-11 09:13:11 +01:00
reduz
6f51eca1e3 Discern between virtual and abstract class bindings
* Previous "virtual" classes (which can't be instantiated) are not corretly named "abstract".
* Added a new "virtual" category for classes, they can't be instantiated from the editor, but can be inherited from script and extensions.
* Converted a large amount of classes from "abstract" to "virtual" where it makes sense.

Most classes that make sense have been converted. Missing:

* Physics servers
* VideoStream
* Script* classes.

which will go in a separate PR due to the complexity involved.
2022-03-10 12:28:11 +01:00
keptsecret
664c461d28 fixed unable to change directory in user access mode 2022-03-09 19:33:56 -05:00
kobewi
39d429e497 Change some math macros to constexpr
Changes `MAX`, `MIN`, `ABS`, `CLAMP` and `SIGN`.
2022-03-09 16:24:32 +01:00
Rémi Verschelde
6c3170e875
Merge pull request #57930 from piiertho/bugfix/add-none-flag-to-resource-saver 2022-03-07 12:05:35 +01:00
Pierre-Thomas Meisels
f9d4f08090 Fix ResourceSaver::save method exposition flag parameter
enh: Add FLAG_NONE to SaverFlags in ResourceSaver to fix api inconsistency
fix: flags parameter of ResourceSaver::save is now uint32_t to allow flag composition in scripts
2022-03-07 10:39:51 +01:00
Hugo Locurcio
8e57e5dc6a
Print every file exported with PCKPacker.flush()s verbose parameter
Previously, only one line per 100 files was printed.

This also refactors the print statement to use Godot methods and
make it more informative overall.
2022-02-25 02:42:58 +01:00
Rémi Verschelde
719762d4dc
Merge pull request #58166 from Zylann/fix_binary_resource_with_doubles
Fix loading of binary resources with 64-bit floats
2022-02-19 08:22:42 +01:00
Rémi Verschelde
420ad25348
Merge pull request #58205 from Zylann/fix_variant_encode_with_doubles
Add missing flag when encode_variant writes math types with doubles
2022-02-19 08:22:05 +01:00
Ricardo Subtil
61790a03f5 Fix decompression functions not returning errcodes 2022-02-18 13:50:25 +00:00
Marc Gilleron
c69d303ba9 Add missing flag when encode_variant writes math types with doubles 2022-02-16 20:47:36 +00:00
Rémi Verschelde
b8b4580448
Style: Cleanup single-line blocks, semicolons, dead code
Remove currently unused implementation of TextureBasisU, could be re-added
later on if needed and ported.
2022-02-16 14:06:29 +01:00
Marc Gilleron
722945be61 Fix loading of binary resources with 64-bit floats 2022-02-16 00:55:13 +00:00
Max
6aede992a9 Fixed variant decoding Segmentation Fault 2022-02-14 23:04:05 +03:00
Fabio Alessandrelli
f72bd67068 [ResourceUID] Use CryptoCore::RandomGenerator for IDs. 2022-02-14 10:45:50 +01:00
reduz
97feafd0ea Fix resource reuse in binary loader
* Reuse was not setting the internal index.
* Supersedes #52599, without re-reading all properties.
2022-02-12 10:57:51 +01:00
Rémi Verschelde
1bdb82c64e
Fix typos with codespell
Using codespell 2.2-dev from current git.

Added `misc/scripts/codespell.sh` to make it easier to run it once in a
while and update the skip and ignore lists.
2022-02-10 12:30:19 +01:00
Rémi Verschelde
ec00283f91
ResourceImporter: Restore default append logic for new importers
This was changed in #56943 to allow adding new importers from plugins that
take precedence over built-in ones, but this should be opt-in, not the default
behavior.

Fixes #57730.
2022-02-07 09:47:16 +01:00
Rémi Verschelde
bd32dd4a48
Merge pull request #56943 from V-Sekai/override-import
Make add_importer and add_post_importer_plugin override existing importers.
2022-02-05 19:50:37 +01:00
Rémi Verschelde
df1724470d
Merge pull request #49775 from fire/faster-cvtt
Faster CVTT by lowering default quality
2022-02-05 10:28:07 +01:00
Fabio Alessandrelli
3acc39095e [Net] Fix bogus FileAccessNetwork deconstructor.
Now correctly erases old instances.
The code will likely need overhaul anyway to be usable.
It doesn't apply to editor runs, there's a bunch of inconsistencies on
how to clients are handled, and I don't really understand why multiple
instances are created for a single client/server.
2022-02-05 03:27:19 +01:00
K. S. Ernest (iFire) Lee
419b342a9a Faster CVTT by reducing quality.
Make BC6 and BC7 CVTT faster while still having better quality than DXT5.
2022-02-04 15:15:26 -08:00
bruvzg
244db37508
Cleanup and move char functions to the char_utils.h header. 2022-02-04 11:35:01 +02:00
Rémi Verschelde
f8f19b313d
Merge pull request #57562 from AnilBK/string-add-contains
String: Add contains().
2022-02-03 22:21:24 +01:00
Anilforextra
adbe948bda String: Add contains(). 2022-02-04 01:28:02 +05:45
Fabio Alessandrelli
ac4fb2996b [Net] Non-blocking request in HTTPClientTCP.
HTTPClientJavaScript already supports non-blocking requests.
2022-02-03 02:45:30 +01:00
Fabio Alessandrelli
6ff753675a
Merge pull request #56771 from mhilbrunner/unacceptable
Verify custom HTTP headers, fix off by one error
2022-02-02 18:28:30 +01:00
Anilforextra
fc27636999 Vectors: Use clear() and has().
Use clear() instead of resize(0).

Use has() instead of "find(p_val) != -1".
2022-02-02 00:11:09 +05:45
Fabio Alessandrelli
49297d937c [Net] Simplify IP resolution code, fix caching.
First, we should not insert into cache if the hostname resolution has
failed (as it might be a temporary internet issue), second, the async
resolver should also properly insert into cache.

Took the chance to remove some duplicate code with critical section in
it at the cost of little performance when calling the blocking
resolve_hostname function.
2022-01-29 01:56:36 +01:00
Rémi Verschelde
9686d680b7
Merge pull request #57116 from bruvzg/win_net_share 2022-01-28 11:03:23 +01:00
Rémi Verschelde
e6caaf4c80
Merge pull request #57205 from TechnoPorg/variant-template-cast
Allow method binds to take Object subclasses as arguments
2022-01-27 23:46:37 +01:00
Max Hilbrunner
3ef5a97505 Verify custom HTTP headers, fix off by one error 2022-01-27 03:22:37 +01:00
Max Hilbrunner
3a83872d26 HTTP comment cleanup 2022-01-27 03:22:37 +01:00
TechnoPorg
051ef479c9 Allow method binds to take Object subclasses as arguments
This commit adds a condition to VariantCaster that casts Variants of type OBJECT to any type T, if T is derived from Object.
This change enables a fair bit of code cleanup. First, the Variant implicit cast operators for Node and Control can be removed, which allows for some invalid includes to be removed. Second, helper methods in Tree whose sole purpose was to cast arguments to TreeItem * are no longer necessary.
A few small changes also had to be made to other files, due to the changes cascading down all the includes.
2022-01-25 09:03:36 -07:00
bruvzg
9456454109
Fix translation with multiple sources for the same language.
Remove unnecessary locale length checks.
Add "C" -> "en" locale remap.
2022-01-24 18:58:16 +02:00
bruvzg
cba8280515 [Windows] Add support for handling network share paths. 2022-01-24 16:22:59 +02:00
Rémi Verschelde
ce42ab238a
Merge pull request #56931 from lyuma/etcpak_po2
Enforce mult-of-4 requirements on etcpak input.
2022-01-23 09:31:35 +01:00
Lyuma
b1b20f5f91 Pad etcpak input to 4x4 blocks. Fixes #49981 2022-01-22 17:20:17 -08:00
Fabio Alessandrelli
01e5e98312 [Net] Fix get_response_body_length for large files.
Parsing was fixed, but not the return value for the exposed getter.
2022-01-23 01:30:35 +01:00
Omar Polo
bd448e5535 Rename or refactor macros to avoid leading underscores
These are not used consistently and some can conflict with
system-specific defines.  While here, also delete some unused macros.
2022-01-20 20:29:15 +01:00
bruvzg
de48d5101b
Fix locale always selecting translation instead of "en", when no match found. 2022-01-19 16:46:48 +02:00
K. S. Ernest (iFire) Lee
a6f34ea2d0 Make add_importer and add_post_importer_plugin override existing importers. 2022-01-19 04:53:28 -08:00
bruvzg
40c56ed410
Improve locale detection.
Use separate language, script and country lists.
Add locale selection dialog and property hint.
2022-01-18 14:30:00 +02:00
Hugo Locurcio
40be15920f
Remove support for PVRTC texture encoding and decoding
On the only platform where PVRTC is supported (iOS),
ETC2 generally supersedes PVRTC in every possible way. The increased
memory usage is not really a problem thanks to modern iOS' devices
processing power being higher than its Android counterparts.
2022-01-14 21:08:22 +01:00
Rémi Verschelde
585231a172
Merge pull request #56492 from akien-mga/remove-author-docstrings 2022-01-12 15:24:17 +01:00
Aaron Franke
05ce2c80bb
Rename Variant enum members in resource_format_binary.cpp 2022-01-06 08:12:26 -08:00
Rémi Verschelde
8d83da5bf9
Merge pull request #56224 from Calinou/variant-rename-packed-array-constants 2022-01-06 17:08:36 +01:00
bruvzg
c69e0d16bc
Fix multiple missing UTF-8 decoding. 2022-01-06 14:35:22 +02:00
Rémi Verschelde
0157742422
Merge pull request #53434 from Faless/io/4.x_file_access_compressed
[File] Fix FileAccessCompressed::get_buffer return value.
2022-01-06 09:20:27 +01:00
Rémi Verschelde
ba2bdc478b
Style: Remove inconsistently used @author docstrings
Each file in Godot has had multiple contributors who co-authored it over the
years, and the information of who was the original person to create that file
is not very relevant, especially when used so inconsistently.

`git blame` is a much better way to know who initially authored or later
modified a given chunk of code, and most IDEs now have good integration to
show this information.
2022-01-04 20:42:50 +01:00