Commit graph

36 commits

Author SHA1 Message Date
Lukas Tenbrink
1db0a60dc0 Replace std::size usage with std_size to avoid <iterator> include. 2025-10-05 00:26:11 +02:00
Lukas Tenbrink
b13a0e1834 Rename String::resize to resize_uninitialized, to better communicate to callers that new characters must be initialized. 2025-06-11 18:13:02 +02:00
kobewi
9c37ca5383 Expose helper methods for converting UIDs 2025-05-25 00:26:16 +02:00
Fabio Alessandrelli
2c789788c0 mbedTLS: Fix concurrency issues with TLS
When we first integrated mbedTLS, we decided not to enable
MBEDTLS_THREADING_C (which adds mutex locking to calls modifying the
state), and instead to simply create separate contexts ("states") for
each connection.

This worked fine until recently.
Sadly, mbedTLS 3 added a global state for the new PSA crypto
functionalities (which are required to support TLSv1.3).
This results in TLSv1.3 connections to access and modify the global
state concurrently when running in threads.

This commit enables MBEDTLS_THREADING_C, and MBEDTLS_THREADING_C_ALT to
provide a generic Godot implementation using the engine Mutex class.
2025-05-08 11:45:00 +02:00
kobewi
ff1f040893 Add create_id_for_path() to ResourceUID 2025-04-11 00:53:34 +02:00
Pāvels Nadtočajevs
abe413ff8c
Fix icons with non-ASCII file names in project manager. 2025-03-20 16:33:01 +02:00
Thaddeus Crews
c937b6d180
Merge pull request #102419 from Ivorforce/std-size
Use `std::size` instead of `sizeof(a) / sizeof(a[0])` pattern throughout the codebase.
2025-03-07 15:12:25 -06:00
Thaddeus Crews
d9125ebebe
Merge pull request #101293 from Ivorforce/string-to-pointer-conversion
Remove implicit conversions from `String`, `Char16String` and `CharString` to data pointers.
2025-03-07 15:12:12 -06:00
Hilderin
9457666bba Fix accessing UID before first scan 2025-02-08 20:04:32 -05:00
Lukas Tenbrink
e34f1f504c Use std::size instead of sizeof(a) / sizeof(a[0]) pattern throughout the codebase. 2025-02-07 14:57:48 +01:00
Lukas Tenbrink
512abc38b2 Remove implicit conversions from String, Char16String and CharString to data pointers. Make conversions to StrRange implicit to aid transition. 2025-01-17 17:31:58 +01:00
kobewi
d3d874e0d1 Improve missing UID errors 2025-01-11 21:30:25 +01:00
Rémi Verschelde
653f5a9613
Merge pull request #100976 from AThousandShips/uid_fixes
[Core] Fix UID encoding
2025-01-06 22:48:13 +01:00
AThousandShips
25ecf5ec83
[Core] Fix UID encoding
Fixes edge case where `0` encoded as `uid://` instead of `uid://a`, and
fixes the size of the temporary buffer storing encoded UID strings.
2024-12-31 15:20:09 +01:00
kobewi
81b1138a7f Fix icon UIDs in Project Manager 2024-12-26 14:54:09 +01:00
Rémi Verschelde
851d8e49e8
Merge pull request #100386 from hpvb/core-ubsan
Core: Fix UBSAN reports
2024-12-18 17:23:32 +01:00
HP van Braam
240f510fa7 Core ubsan fixes
This fixes UBSAN errors reported by running our testsuite, importing the
TPS demo, and running the TPS demo. I have tried, wherever possible, to
fix issues related to reported issues but not directly reported by UBSAN
because thse code paths just happened to not have been exercised in
these cases.

These fixes apply only to errors reported, and caused by, core/

The following things have been changed:

* Make sure there are no implicit sign changing casts in core.
* Explicitly type enums that are part of a public API such that users of
  the API cannot pass in wrongly-sized values leading to potential stack
  corruption.
* Ensure that memcpy is never called with invalid or null pointers as
  this is undefined behavior, and when the engine is built with
  optimizations turned on leads to memory corruption and hard to debug
  crashes.
* Replace enum values only used as static values with constexpr static
  const values instead. This has no runtime overhead. This makes it so
  that the size of the enums is explicit.
* Make sure that nan and inf is handled consistently in String.
* Implement a _to_int template to ensure that all of the paths use the
  same algorhithm, and correct the negative integer case.
* Changed the way the json serializer precision work, and added tests to
  verify the new behavior. The behavior doesn't quite match master in
  particulary for negative doubles as the original code tried to cast -inf
  to an int. This then led to negative doubles losing all but one of
  their decimal points when serializing. Behavior in GDScript remains
  unchanged.
2024-12-18 14:31:12 +01:00
Kiro
5f401e63b5 Improve ResourceUID::id_to_text performance 2024-12-15 10:41:13 +01:00
kobewi
67b95f341e Fix UID support in MultiplayerSpawner 2024-12-03 22:11:43 +01:00
kobewi
0dabcd9941 Resource UID fixes and improvements 2024-11-14 16:37:54 +01:00
David Nikdel
5e6adb4a2d Merge uid_cache.bin and global_script_class_cache.cfg after mounting PCKs
fixes godotengine#82061
fixes godotengine#61556

Also, distinguish between main pack and DLC packs.
It's desirable to downloaded content to be as small as possible. This change avoids bloating non-main pack files with new versions of resources that are all read on startup and never used again. They have no effect if loaded after startup.
- project.godot/project.binary file
- extension_list.cfg
- app icon and boot_splash
- .ico and .icns files (these can still be opted in for DLC by listing them explicitly in the include filter)
2024-03-06 12:14:21 -05:00
Thomas ten Cate
2263d94cc3 Add comment why off-by-one error is hard to fix
See #83843

Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
2023-11-01 11:14:13 +01:00
Rémi Verschelde
d95794ec8a
One Copyright Update to rule them all
As many open source projects have started doing it, we're removing the
current year from the copyright notice, so that we don't need to bump
it every year.

It seems like only the first year of publication is technically
relevant for copyright notices, and even that seems to be something
that many companies stopped listing altogether (in a version controlled
codebase, the commits are a much better source of date of publication
than a hardcoded copyright statement).

We also now list Godot Engine contributors first as we're collectively
the current maintainers of the project, and we clarify that the
"exclusive" copyright of the co-founders covers the timespan before
opensourcing (their further contributions are included as part of Godot
Engine contributors).

Also fixed "cf." Frenchism - it's meant as "refer to / see".
2023-01-05 13:25:55 +01:00
Haoyu Qiu
d873c549a2 Fix crash when executing ResourceUID.set_id 2022-09-30 09:41:05 +08:00
Aaron Franke
10a56981dc
Rename String plus_file to path_join 2022-08-29 19:38:13 -05: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
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
Fabio Alessandrelli
f72bd67068 [ResourceUID] Use CryptoCore::RandomGenerator for IDs. 2022-02-14 10:45:50 +01: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
fe52458154
Update copyright statements to 2022
Happy new year to the wonderful Godot community!
2022-01-03 21:27:34 +01:00
Rémi Verschelde
a7ba227631
Merge pull request #52711 from m4gr3d/provide_getter_for_project_data_dir_master 2021-10-05 21:02:27 +02:00
Haoyu Qiu
b024d16bc1 Parse UTF-8 when getting path from resource UID 2021-09-27 19:10:32 +08:00
ne0fhyk
69f890ff11 Provide a getter for the project data directory. 2021-09-15 12:52:03 -07:00
Rémi Verschelde
c91860bb11
ResourceUID: Fix remove_id binding
Fixes #50833.
2021-07-25 11:55:56 +02:00
reduz
32b43cfeb3 Implement Resource UIDs
* Most resource types now have unique identifiers.
* Applies to text, binary and imported resources.
* File formats reference both by text and UID (when available). UID always has priority.
* Resource UIDs are 64 bits for better compatibility with the engine.
* Can be represented and used textually, example `uuid://dapwmgsmnl28u`.
* A special binary cache file is used and exported, containing the mappings.

Example of how it looks:

```GDScript
[gd_scene load_steps=2 format=3 uid="uid://dw86wq31afig2"]

[ext_resource type="PackedScene" uid="uid://bt36ojelx8q6c" path="res://subscene.scn" id="1_t56hs"]
```

GDScript, shaders and other special resource files can't currently provide UIDs, but this should be doable with special keywords on the files.
This will be reserved for future PRs.
2021-07-24 09:16:52 -03:00