summaryrefslogtreecommitdiff
path: root/core/io
AgeCommit message (Collapse)Author
2021-09-07[Net] Move multiplayer to core subdir, split RPCManager.Fabio Alessandrelli
Move multiplayer classes to "core/multiplayer" subdir. Move the RPCConfig and enums (TransferMode, RPCMode) to a separate file (multiplayer.h), and bind them to the global namespace. Move the RPC handling code to its own class (RPCManager). Renames "get_rpc_sender_id" to "get_remote_sender_id".
2021-09-02Fix _send_default_spawn_default function sending zero lengthSaracenOne
PackedByteArray when deriving from a single PackedByteArray state variant.
2021-08-30Merge pull request #52240 from Rubonnek/rename-rel-pathJuan Linietsky
Rename `String::is_rel_path` to `String::is_relative_path`
2021-08-30Try other resolved IPs if one fails to connectHaoyu Qiu
2021-08-29Rename String::is_rel_path to String::is_relative_pathWilson E. Alvarez
2021-08-30[Net] Rename RPC "puppet" to "auth" (authority). Drop "master".Fabio Alessandrelli
This commit completely removes the RPC_MODE_MASTER ("master" keyword), and renames the RPC_MODE_PUPPET to RPC_MODE_AUTHORITY ("auth" keyword). This commit also renames the "Node.[get|set]_network_master" methods to "Node.[get|set]_network_authority". This commit also renames the RPC_MODE_REMOTE constant to RPC_MODE_ANY. RPC_MODE_MASTER in Godot 3.x meant that a given RPC would be callable by any puppet peer on the master, while RPC_MODE_PUPPET meant that it would be callable by the master on any puppet. Beside proving to be very confusing to the user (referring to where it could be called instead of who can call it) the RPC_MODE_MASTER is quite useless. It is almost the same as RPC_MODE_REMOTE (anyone can call) with the exception that the network master cannot. While this could be useful to check in some case, in such a function you would anyway need to check in code who is the caller via get_rpc_sender_id(), so adding the check there for those rare cases does not warrants a dedicated mode.
2021-08-30Merge pull request #51788 from Faless/mp/4.x_replicator_syncFabio Alessandrelli
[Net] MultiplayerReplicator state sync.
2021-08-28Quote and escape ConfigFile keys when necessaryHaoyu Qiu
2021-08-26Data structure optimizations as per review.Fabio Alessandrelli
2021-08-24Implement error return documetationreduz
Adds ability to add error return documetation to the binder and class reference. Usage example: ```C++ void MyClass::_bind_method() { [..] BIND_METHOD_ERR_RETURN_DOC("load", ERR_FILE_CANT_OPEN, ERR_FILE_UNRECOGNIZED); } ``` One function of ConfigFile was changed as example.
2021-08-22Replace BIND_VMETHOD by new GDVIRTUAL syntaxreduz
* New syntax is type safe. * New syntax allows for type safe virtuals in native extensions. * New syntax permits extremely fast calling. Note: Everything was replaced where possible except for `_gui_input` `_input` and `_unhandled_input`. These will require API rework on a separate PR as they work different than the rest of the functions. Added a new method flag METHOD_FLAG_OBJECT_CORE, used internally. Allows to not dump the core virtuals like `_notification` to the json API, since each language will implement those as it is best fits.
2021-08-18[Net] Add state sync to replicator.Fabio Alessandrelli
Like the spawn/despawn feature, it can be completely overridden with 2 custom callables. The callables will be called with the list of tracked objects. In SERVER mode, objects are automatically tracked, while in CUSTOM mode you can manually track them via `track`/`untrack` (but that's optional). The default sync only happens from server to client, with batch updates, over unreliable channel (but with custom ordering). The default sync will warn you, if your state representation gets too big.
2021-08-18[Net] MultiplayerReplicator with initial state.Fabio Alessandrelli
Move the former "spawnables" functions to a dedicated MultiplayerReplicator class. Support custom overrides in replicator. Spawn/despawn messages can now contain a state. The state can be automatically encoded/decoded by passing the desired object properties to `spawnable_config`. You can use script properties to optimize the state representation. 2 Callables can be also specified to completely override the default implementation for sending and receiving the spawn/despawn event. (9 bytes overhead, and there's room for improvement here). When using a custom implementation `spawn` and `despawn` can be called with any Object, `send_spawn`/`send_despawn` can receive any Variant as a state, and the path is not required. Two new functions, `spawn` and `despawn`, convey the implementation independent method for requesting a spawn/despawn of an Object, while `send_spawn` and `send_despawn` represent the more low-level send event for a Variant to be used by the custom implementations.
2021-08-12Resource: Remove unused `_use_builtin_script()` virtual methodRémi Verschelde
And another piece of dead code found while searching for "use_builtin".
2021-08-09[Net] Basic extensible MultiplayerAPI spawn/despawn.Fabio Alessandrelli
`PackedScene`s can be configured to be spawnable via a new `MultiplayerAPI.spawnable_config` method. They can be configured either to be spawned automatically when coming from the server or to always require verification. Another method, `MultiplayerAPI.send_spawn` lets you request a spawn on the remote peers. When a peer receive a spawn request: - If it comes from the server and the scene is configured as `SPAWN_MODE_SERVER`: - Spawn the scene (instantiate it, add it to tree). - Emit signal `network_spawn`. - Else: - Emit signal `network_spawn_request`. In a similar way, `despawn`s are handled automatically in `SPAWN_MODE_SERVER`. In `SPAWN_MODE_SERVER`, when a new client connects it will also receive, from the server all the spawned (and not yet despawned) instances.
2021-08-06OS: Fix used resource debug printsRémi Verschelde
These methods were broken by 22419082d9bedbc9dc060ea5784bb0871f8710a3 5 years ago and nobody complained, so maybe they're not so useful... But at least this should restore them to a working state.
2021-08-06Merge pull request #51234 from akien-mga/tests-file-get_csv_lineRémi Verschelde
Tests: Improve coverage for `File::get_csv_line()`
2021-08-04Tests: Improve coverage for `File::get_csv_line()`Rémi Verschelde
Adds a few more complex edge cases which are supported. Also adds some documentation, simplifies the code a bit and forbids using double quotes as a delimiter.
2021-08-04Merge pull request #51005 from Faless/mp/4.x_channelsRémi Verschelde
[Net] Implement RPC channels in MultiplayerAPI.
2021-08-03Merge pull request #51199 from Faless/net/4.x_ip_lockRémi Verschelde
2021-08-02Merge pull request #51042 from nikitalita/fix_binary_res_load_saveK. S. Ernest (iFire) Lee
Fix binary resource loading and saving
2021-08-03[Net] Fix IP address resolution incorrectly locking the main thread.Fabio Alessandrelli
This seems to be a pretty old bug, older then originally reported (at least under certain circumstances). The IP singleton uses a resolve queue so developers can queue hostnames for resolution in a separate while keeping the main thread unlocked (address-resolution OS functions are blocking, and could block for a long time in case of network disruption). In most places though, the address resolution function was called with the mutex locked, causing other functions (querying status, queueing another hostname, ecc) to block until that resolution ended. This commit ensures that all calls to OS address resolution are done with the mutex unlocked.
2021-08-02[Marshalls] Fix Float64Array and Int64Array serialization.Fabio Alessandrelli
One was incorrectly reading the size (potentially causing out-of-buffer read), the other also potentially causing out-of-buffer write during encoding.
2021-07-30[Net] Implement RPC channels in MultiplayerAPI.Fabio Alessandrelli
2021-07-30[Net] Fix Marshalls infinite recursion crash.Fabio Alessandrelli
Variants like dictionaries and arrays can have cyclic references, which caused `encode_variant` to run an infinite recursion. Instead of keeping a stack and looking for cyclic references which would make serialization slower, this commit adds a `MAX_RECURSION_DEPTH` constant to Variant, and have `encode_variant` keep track of the current recursion depth, bailing when it's too high since this likely means a cyclic reference has been encountered.
2021-07-29skip uid field length in binary resource if not usednikitalita
2021-07-29Use constant for reserved field countnikitalita
2021-07-29Fix binary resource loading and savingnikitalita
2021-07-29[Net] Add generate_unique_id to MultiplayerPeer.Fabio Alessandrelli
Used by ENetMultiplayerPeer and WebSocketServer to generate network IDs, and exposed to the user for p2p networks (e.g. WebRTCMultiplayerPeer) and custom MultiplayerPeer implementations.
2021-07-29[Net] Fix RPC ID encoding/decoding for Node methods.Fabio Alessandrelli
2021-07-25Fix various typosluz paz
Follow-up typos found via `codespell -q 3 -S ./thirdparty,*.po,./DONORS.md -L ackward,ang,ans,ba,beng,cas,childs,childrens,dof,doubleclick,fave,findn,hist,inout,leapyear,lod,nd,numer,ois,ony,paket,seeked,sinc,switchs,te,uint`
2021-07-25Merge pull request #50809 from akien-mga/iterators-const-referencesRémi Verschelde
2021-07-25Merge pull request #50250 from luzpaz/typosRémi Verschelde
Fix various typos
2021-07-25Use const references where possible for List range iteratorsRémi Verschelde
2021-07-25ResourceUID: Fix `remove_id` bindingRémi Verschelde
Fixes #50833.
2021-07-25Fix various typos with codespellluz paz
Found via `codespell -q 3 -S ./thirdparty,*.po,./DONORS.md -L ackward,ang,ans,ba,beng,cas,childs,childrens,dof,doubleclick,fave,findn,hist,inout,leapyear,lod,nd,numer,ois,ony,paket,seeked,sinc,switchs,te,uint`
2021-07-24Fix check for the first key in JSON stringify from Dictionary codeAaron Franke
2021-07-24Merge pull request #50786 from reduz/implement-resource-uidsRémi Verschelde
Implement Resource UIDs
2021-07-24Implement Resource UIDsreduz
* 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-23Use C++ iterators for Lists in many situationsAaron Franke
2021-07-23Expose an ImportOrder enum in ResourceImporterHugo Locurcio
This avoids using magic numbers in code.
2021-07-22Implement textual ext/subresource IDs.reduz
* Friendlier with version control. * Generates pseudo unique IDs, to minimize conflicts when merging, but still user readable (so, not UUID). * Eventually will also allow to have more precisely named sub-resources in imported files. * This will allow better reloading on changes (including resources already loaded) as well as better keeping track of changes on the DCC. * Keeps backward compatibility with the old formats. * Binary and text format version incremented to mark breakage in forward compatibility.
2021-07-20[Net] Single `rpc` annotation. "sync" no longer part of mode.Fabio Alessandrelli
- Move the "sync" property for RPCs to RPCConfig. - Unify GDScript annotations into a single one: - `@rpc(master)` # default - `@rpc(puppet)` - `@rpc(any)` # former `@remote` - Implement three additional `@rpc` options: - The second parameter is the "sync" option (which also calls the function locally when RPCing). One of "sync", "nosync". - The third parameter is the transfer mode (reliable, unreliable, ordered). - The third parameter is the channel (unused for now).
2021-07-18Optimize StringName usagereduz
* Added a new macro SNAME() that constructs and caches a local stringname. * Subsequent usages use the cached version. * Since these use a global static variable, a second refcounter of static usages need to be kept for cleanup time. * Replaced all theme usages by this new macro. * Replace all signal emission usages by this new macro. * Replace all call_deferred usages by this new macro. This is part of ongoing work to optimize GUI and the editor.
2021-07-16Merge pull request #46554 from likeich/is_server_quiet_failureFabio Alessandrelli
MultiplayerAPI is_network_server Fails Silently
2021-07-13Fix decompression with FastLZ when buffer size is less than 16 bytesHaoyu Qiu
2021-07-12[Net] Rename NetworkedMultiplayerPeer to MultiplayerPeer.Fabio Alessandrelli
2021-07-11[Net] Fix crash when receiving RPC on node without a script.Fabio Alessandrelli
2021-07-11Merge pull request #50362 from timothyqiu/http-eofRémi Verschelde
Fix unicode invalid skip error in AssetLib
2021-07-11Fix unicode invalid skip error in AssetLibHaoyu Qiu