Commit graph

411 commits

Author SHA1 Message Date
Rémi Verschelde
ac3322b0af
Use const references where possible for List range iterators 2021-07-25 12:22:25 +02:00
Rémi Verschelde
2b1e6e303e
Merge pull request #50786 from reduz/implement-resource-uids
Implement Resource UIDs
2021-07-24 17:18:12 +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
Aaron Franke
4e6efd1b07
Use C++ iterators for Lists in many situations 2021-07-23 17:38:28 -04:00
bruvzg
618eb27e8b Move alert function from DisplayServer to OS. 2021-07-22 21:50:35 +03:00
Hugo Locurcio
257a8a337e
Remove unused code related to Travis CI 2021-07-01 18:02:00 +02:00
Rémi Verschelde
ac73059b56
Merge pull request #49123 from aaronfranke/it-is-time
Add a Time singleton
2021-06-12 22:55:25 +02:00
Aaron Franke
f64fea1b23
Add Time singleton 2021-06-11 09:32:39 -04:00
Rémi Verschelde
9e328bb5b7
Core: Move DirAccess and FileAccess to core/io
File handling APIs are typically considered part of I/O, and we did have most
`FileAccess` implementations in `core/io` already.
2021-06-11 14:52:39 +02:00
Rémi Verschelde
01d5c463be
FileAccess: Don't err in store_buffer with buffer of size 0
The error check was added for `FileAccessUnix` but it's not an error when both
`p_src` and `p_length` are zero.

Added correct error checks to all implementations to prevent the actual
erroneous case: `p_src` is nullptr but `p_length > 0` (risk of null pointer
indexing).

Fixes #33564.
2021-06-07 18:34:00 +02:00
Rémi Verschelde
c1c76850cb
Style: Cleanup uses of double spaces between words
Or after punctuation. Tried to leave third-party stuff alone, unless it has
been heavily modified for Godot.
2021-06-07 11:03:08 +02:00
Rémi Verschelde
9990f28d84
Merge pull request #49026 from sarchar/multiple-dns-resolves 2021-06-01 18:41:41 +02:00
Chuck
dd8fa11ac1 Support multiple address resolution in DNS requests
Add two new functions to the IP class that returns all addresses/aliases associated with a given address.

This is a cherry-pick merge from 010a3433df which was merged in 2.1, and has been updated to build with the latest code.

This merge adds two new methods IP.resolve_hostname_addresses and IP.get_resolve_item_addresses that returns a List of all addresses returned from the DNS request.
2021-06-01 11:24:34 +07:00
bruvzg
1d7a63fb8f
Fix Directory::get_space_left() result on macOS and Linux. 2021-05-31 12:57:18 +03:00
Marcel Admiraal
da5d7db610 Rename File::get_len() get_length() 2021-05-25 11:54:28 +01:00
bruvzg
139a9d6370
Add symlink API to the DirAccess (on macOS and Linux). 2021-05-22 17:33:34 +03:00
Pedro J. Estébanez
469fa47e06
Make all file access 64-bit (uint64_t)
This changes the types of a big number of variables.

General rules:
- Using `uint64_t` in general. We also considered `int64_t` but eventually
  settled on keeping it unsigned, which is also closer to what one would expect
  with `size_t`/`off_t`.
- We only keep `int64_t` for `seek_end` (takes a negative offset from the end)
  and for the `Variant` bindings, since `Variant::INT` is `int64_t`. This means
  we only need to guard against passing negative values in `core_bind.cpp`.
- Using `uint32_t` integers for concepts not needing such a huge range, like
  pages, blocks, etc.

In addition:
- Improve usage of integer types in some related places; namely, `DirAccess`,
  core binds.

Note:
- On Windows, `_ftelli64` reports invalid values when using 32-bit MinGW with
  version < 8.0. This was an upstream bug fixed in 8.0. It breaks support for
  big files on 32-bit Windows builds made with that toolchain. We might add a
  workaround.

Fixes #44363.
Fixes godotengine/godot-proposals#400.

Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
2021-05-17 15:06:19 +02:00
Hugo Locurcio
3f078c99f6
Rename IP_Unix, IP_Address and TCP_Server to remove underscores 2021-05-06 02:52:01 +02:00
bruvzg
b6a21f85a7
Fix url_decode with mixed percent-encoding/Unicode strings. Treat Unix drive names as UTF-8 encoded. 2021-04-30 21:22:39 +03:00
Rémi Verschelde
8247667a3e
Core: Drop custom copymem/zeromem defines
We've been using standard C library functions `memcpy`/`memset` for these since
2016 with 67f65f6639.

There was still the possibility for third-party platform ports to override the
definitions with a custom header, but this doesn't seem useful anymore.
2021-04-27 16:26:27 +02:00
Rémi Verschelde
72bd64c1d5
Merge pull request #47398 from Faless/feature/network-local-port-salvaged 2021-04-27 15:04:30 +02:00
Fabio Alessandrelli
46f7b0f74b [Net] Fix socket poll timeout on Windows.
Now correctly computes the timeout value in milliseconds.
2021-04-26 07:23:39 +02:00
dam
da8c2310b5 Allow local port control on net_socket connections 2021-04-12 21:05:33 +02:00
bruvzg
b202a0dd2a
FileDialog: add Back/Forward buttons, add message for inaccessible folders. 2021-03-23 08:03:41 +02:00
Alex Hirsch
c28428fe4d Allow nullptr with zero length in FileAccess get_buffer
fix #47071
2021-03-16 22:55:11 +01:00
Rémi Verschelde
7a64819c2f
Thread: Re-add pthread_np.h include for FreeBSD/OpenBSD
Was a regression from #45315.

Fixes #46998.
2021-03-14 22:42:48 +01:00
Alex Hirsch
cdf3099c68 Add parameter checkes to FileAccess get_buffer functions
fix #46540
2021-03-09 13:55:20 +01:00
Rémi Verschelde
5525cd85c6
Merge pull request #45315 from RandomShaper/modernize_thread
Modernize Thread
2021-01-31 15:24:56 +01:00
Pedro J. Estébanez
99fe462452 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-01-29 12:02:13 +01:00
Aaron Franke
e829b7aee4
Unify URI encoding/decoding and add to C#
http_escape and percent_encode have been unified into uri_encode, and http_unescape and percent_decode have been unified into uri_decode.
2021-01-28 07:45:01 -05:00
Pedro J. Estébanez
8ed259b792 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-01-19 11:53:10 +01:00
Rémi Verschelde
59495adb7c
Merge pull request #45157 from madmiraal/fix-44514
Raise SIGKILL instead of CRASH_NOW in child process when fork fails
2021-01-13 15:51:09 +01:00
Marcel Admiraal
89225884f6 Raise SIGKILL instead of CRASH_NOW in child process when fork fails 2021-01-13 10:18:57 +00:00
bruvzg
533ed0c7c8
Fix OS::execute() and OS::create_process() command line argument CharStrings freed before use. 2021-01-13 11:38:02 +02:00
Rémi Verschelde
1218441b16
Merge pull request #44514 from madmiraal/split-os-execute
Split OS::execute into two methods
2021-01-12 16:17:04 +01:00
Rémi Verschelde
f414a323b1
Merge pull request #42740 from lolleko/fix-nanosleep-usage
Fix nanosleep usage
2021-01-11 14:42:10 +01:00
Marcel Admiraal
2a74b388d0 Split OS::execute into two methods
1. execute(): Executes a command and returns the results.
2. create_process(): Creates a new process and returns the new process' id.
2021-01-09 10:03:23 +00:00
Rémi Verschelde
b5334d14f7
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 🎆
2021-01-01 20:19:21 +01:00
Marcel Admiraal
fa435a550a Add override keywords to core/os.h derived classes. 2020-12-17 18:02:31 +00:00
Fabio Alessandrelli
781efc26e0 Remove now unused FileAccessBuffered. 2020-12-06 19:37:11 +01:00
Rafał Mikrut
7bd03b7188 Initialize class/struct variables with default values in core/ and drivers/ 2020-11-23 17:38:46 +01:00
Rémi Verschelde
a655de89e3
doc: Warn about using Node internal processing
See #43689.

Also 'fixed' some spelling for behavior in publicly visible strings.
(Sorry en_GB, en_CA, en_AU, and more... Silicon Valley won the tech spelling
war.)
2020-11-20 09:52:37 +01:00
reduz
127458ed17 Reorganized core/ directory, it was too fatty already
-Removed FuncRef, since Callable makes it obsolete
-Removed int_types.h as its obsolete in c++11+
-Changed color names code
2020-11-07 20:17:12 -03:00
Ev1lbl0w
0d3a168a53
Fix wrong exit code being returned 2020-10-24 19:16:49 +01:00
Lorenz Junglas
1107c7f327 Fix nanosleep usage
nanosleep returns 0 or -1 not the error code.
The error code "EINTR" (if encountered) is placed in errno, in which case nanosleep can be safely recalled with the remaining time.

This is required, so that nanosleep continues if the calling thread is interrupted by a signal.

See manpage nanosleep(2) for additional details.
2020-10-12 16:27:31 +02:00
Haoyu Qiu
1998f78679 Hides special folders in FileDialog for macOS 2020-09-28 14:36:21 +08:00
Rémi Verschelde
01185acecb
NetBSD: Implement OS_Unix::get_executable_path()
Same implementation as OpenBSD seems to work fine.
2020-09-18 11:54:18 +02:00
Rémi Verschelde
5f4d64f4f3
Linux/BSD: Fix support for NetBSD
Add __NetBSD__ to `platform_config.h` so that it can find `alloca`
and use the proper `pthread_setname_np` format.

Rename RANDOM_MAX to avoid conflict with NetBSD stdlib.

Fixes #42145.
2020-09-18 10:27:55 +02:00
Marcel Admiraal
4b3aec50c0 Replace calls to gmtime with gmtime_r and localtime with localtime_r. 2020-09-04 12:22:43 +01:00
bruvzg
80b8eff6aa
[Complex Test Layouts] Change String to use UTF-32 encoding on all platforms. 2020-09-03 19:56:24 +03:00