Commit Graph

94 Commits

Author SHA1 Message Date
Haoyu Qiu
fc3b845c07 Add dedicated macros for property name extraction
* Replace case-by-case extraction with PNAME & GNAME
* Fix group handling when group hint begins with property name
* Exclude properties that are PROPERTY_USAGE_NO_EDITOR
* Extract missing ADD_ARRAY*, ADD_SUBGROUP* macros
2022-05-19 14:08:47 +08: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
de0ca3b999 Refactor module initialization
* Changed to use the same stages as extensions.
* Makes the initialization more coherent, helping solve problems due to lack of stages.
* Makes it easier to port between module and extension.
* removed the DRIVER initialization level (no longer needed).
2022-05-04 17:34:51 +02:00
bruvzg
f851c4aa33
Fix some issues found by cppcheck. 2022-04-06 14:34:37 +03: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
Rémi Verschelde
1769f80547 WebRTC: Fix potential nullptr dereference in error message
This was evidently a typo. Didn't get a crash but GCC 12 raised a
`-Warray-bounds` warning:

```
In file included from ./core/io/stream_peer.h:34,
                 from ./core/io/packet_peer.h:34,
                 from ./core/multiplayer/multiplayer_peer.h:34,
                 from modules/webrtc/webrtc_multiplayer_peer.h:34,
                 from modules/webrtc/webrtc_multiplayer_peer.cpp:31:
In member function 'T* Ref<T>::operator->() [with T = WebRTCMultiplayerPeer::ConnectedPeer]',
    inlined from 'virtual Error WebRTCMultiplayerPeer::put_packet(const uint8_t*, int)' at modules/webrtc/webrtc_multiplayer_peer.cpp:376:4:
./core/object/ref_counted.h:101:24: error: array subscript 0 is outside array bounds of 'Ref<WebRTCMultiplayerPeer::ConnectedPeer> [0]' [-Werror=array-bounds]
  101 |                 return reference;
      |                        ^~~~~~~~~
```
2022-03-04 16:02:40 +01: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
Hugo Locurcio
b68dd2e189
Add an XML schema for documentation
This makes it easier to spot syntax errors when editing the
class reference. The schema is referenced locally so validation
can still work offline.

Each class XML's schema conformance is also checked on GitHub Actions.
2022-02-15 00:03:31 +01:00
Rémi Verschelde
7c3003fcbe
Improve some signal bindings to use specific Object subtypes 2022-01-28 15:35:40 +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
Rémi Verschelde
8898d6dadc
Dictionary: Serialize empty dict as {} instead of {\n}
Also make sure to always convert multiline dictionaries to a single line for
its EditorHelp representation, as multiline values break formatting.
2022-01-18 11:31:21 +01: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
kobewi
2cad775461 Fix usage of "Return" in the docs 2022-01-02 21:09:18 +01:00
Fabio Alessandrelli
84112d9610 [Net] Fix WebRTC returning packets from peers too early.
Due to the async nature of WebRTC implementations, the multiplayer peer
could end up having queued packets from a given connection before it is
able to emit the "peer_added" signal.
This commit ensures that packets from peers which are not notified yet
are skipped by `get_packet` and `get_available_packet_count`.
2021-12-15 11:07:46 +01:00
Rémi Verschelde
788b3aa27a
doc: Fix style inconsistencies for [b]Note:[/b] paragraphs
And fix up formatting not supported by makerst.
2021-10-05 19:13:20 +02:00
Fabio Alessandrelli
24a949ea11 [Net] Rename RPC constants and annotation arguments.
any -> any_peer
sync -> call_local
ordered -> unreliable_ordered

Multiplayer.RPC_MODE_ANY -> RPC_MODE_ANY_PEER
Multiplayer.TRANSFER_MODE_ORDERED -> TRANSFER_MODE_UNRELIABLE_ORDERED
2021-10-01 18:14:38 +02:00
Lightning_A
c63b18507d Use range iterators for Map 2021-09-30 15:09:12 -06:00
Fabio Alessandrelli
0276c2e74a Fix const pointers types in docs and extension API.
The GDVIRTUAL_NATIVE_PTR did not declare the correct GDNativeConstPtr
template, resulting in "void*" being used as it's type info in both the
documentation and the extension API dump.
2021-09-29 16:04:20 +02:00
Fabio Alessandrelli
d18cbdf5e4
Merge pull request #52481 from Faless/net/4.x_native_peers
[Net] Extension system for network peers, webrtc.
2021-09-28 12:57:45 +02:00
Hugo Locurcio
7a62bd1e44
Document Android permission requirements for network access where needed 2021-09-25 12:32:46 +02:00
Fabio Alessandrelli
2d810e8cd9 [Net/Docs] Update extensions documentation. 2021-09-24 21:23:43 +02:00
Fabio Alessandrelli
6cb81543d4 [Net] Expose WebRTC classes to extensions. 2021-09-24 21:23:43 +02:00
Fabio Alessandrelli
25226329be [Net] MultiplayerPeer cleanup, defaults. 2021-09-24 18:40:39 +02:00
Aaron Franke
d54f2ad7ca
Don't generate empty doc sections and reduce code duplication 2021-09-20 20:59:33 -05:00
Max Hilbrunner
5b25457794 Multiplayer networking renames/simplification
Removes _networking_ prefix from some methods and members, now that multiplayer has been largely moved out of Node and SceneTree and is seperated into its own set of classes.
2021-09-08 12:05:54 +02:00
Fabio Alessandrelli
bf9aae09ba [Net] Move multiplayer to core subdir, split RPCManager.
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-07 11:14:30 +02:00
Fabio Alessandrelli
2cf39b97ae [Net] Implement RPC channels in MultiplayerAPI. 2021-07-30 17:29:50 +02:00
Rémi Verschelde
7adf4cc9b5
doc: Use self-closing tags for return and argument
For the time being we don't support writing a description for those, preferring
having all details in the method's description.

Using self-closing tags saves half the lines, and prevents contributors from
thinking that they should write the argument or return documentation there.
2021-07-30 15:29:52 +02:00
Rémi Verschelde
92299989bd
Use Ref<T> references as iterators where relevant
And const when possible.
2021-07-26 19:27:11 +02:00
Aaron Franke
4e6efd1b07
Use C++ iterators for Lists in many situations 2021-07-23 17:38:28 -04:00
David Snopek
abb45f5fe7 Add get_buffered_amount() to WebRTCDataChannel 2021-07-20 12:58:39 -05:00
reduz
6631f66c2a Optimize StringName usage
* 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-18 21:20:02 -03:00
David Snopek
756ed308ee Fix "IDHandler.get_prop is not a function" error when calling some methods on WebRTCDataChannel 2021-07-17 20:03:37 -05:00
Fabio Alessandrelli
3d8acc7a54 [HTML5] Fix build (with module_webxr_enabled=no).
The XR API changed a bit, and it's not just a rename, though probably an
easy update for someone who is qualified :).
2021-07-15 14:37:21 +02:00
Rémi Verschelde
06568bbfdf
Misc cleanup of header includes
Was looking for misuse of module headers without checking that the module is
actually enabled and got carried away...
2021-07-15 00:46:43 +02:00
reduz
5ad4f26659 Implement the ability to disable classes
* This PR adds the ability to disable classes when building.
* For now it's only possible to do this via command like:
  `scons disable_classes=RayCast2D,Area3D`
* Eventually, a proper UI will be implemented to create a build config file to do this at large scale, as well as detect what is used in the project.
2021-07-13 09:25:14 -03:00
Fabio Alessandrelli
97e763dddf [Net] Rename WebRTCMultiplayer to WebRTCMultiplayerPeer. 2021-07-12 16:36:34 +02:00
Fabio Alessandrelli
88d68346ee [Net] Rename NetworkedMultiplayerPeer to MultiplayerPeer. 2021-07-12 16:36:34 +02:00
Pedro J. Estébanez
04688b92ff Rename Reference to RefCounted 2021-06-11 18:48:42 +02:00
Rémi Verschelde
4219a4cb6f
Fix typos with codespell
Using codespell 2.0.0.

Method:
```
$ cat > ../godot-word-whitelist.txt << EOF
ang
curvelinear
dof
doubleclick
fave
findn
GIRD
leapyear
lod
merchantibility
nd
numer
ois
ony
que
seeked
synching
te
uint
unselect
webp
EOF

$ codespell -w -q 3 -I ../godot-word-whitelist.txt --skip="./thirdparty,*.po"
$ git diff // undo unwanted changes
```
2021-05-20 12:38:56 +02:00
Rafał Mikrut
f7209b459b Initialize class/struct variables with default values in modules/ 2021-02-08 10:57:18 +01: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
Rémi Verschelde
c7b53c03ae
SCons: Add explicit dependencies on thirdparty code in cloned env
Since we clone the environments to build thirdparty code, we don't get an
explicit dependency on the build objects produced by that environment.

So when we update thirdparty code, Godot code using it is not necessarily
rebuilt (I think it is for changed headers, but not for changed .c/.cpp files),
which can lead to an invalid compilation output (linking old Godot .o files
with a newer, potentially ABI breaking version of thirdparty code).

This was only seen as really problematic with bullet updates (leading to
crashes when rebuilding Godot after a bullet update without cleaning .o files),
but it's safer to fix it everywhere, even if it's a LOT of hacky boilerplate.
2020-12-18 10:29:34 +01:00
Fabio Alessandrelli
1167ab96e9 [HTML5] Add function signatures to JS libraries. 2020-12-04 23:21:33 +01:00
Marcel Admiraal
4f654dad13 Fix useless assignement in webrtc/library_godot_webrtc.js 2020-11-25 10:09:53 +00:00
Fabio Alessandrelli
4617a7fa9c [HTML5] Run eslint --fix.
Should I write a poem about this whole new world? ;)
2020-11-23 12:15:18 +01:00
Fabio Alessandrelli
a82f70ea9f [HTML5] Libraries refactor for linting.
Initial work to make liniting easier.

This includes:
- Rename http_request.js to library_godot_http_request.js.
- Rename externs.js to engine.externs.js.
- New library_godot_runtime.js (GodotRuntime) wraps around emscripten
  functions.
- Refactor of XMLHttpRequest handler in engine/preloader.js.
- Few fixes to bugs spotted by early stage linting.
2020-11-21 14:22:40 +01:00
Aaron Franke
02161aad5a
Remove empty lines around braces with the formatting script 2020-11-16 23:38:11 -05:00
Fabio Alessandrelli
e2083871eb [HTML5] Port JavaScript inline code to libraries.
The API is implemented in javascript, and generates C functions that can
be called from godot.
This allows much cleaner code replacing all `EM_ASM` calls in our C++
code with plain C function calls.
This also gets rid of few hacks and comes with few optimizations (e.g.
custom cursor shapes should be much faster now).
2020-11-10 11:42:51 +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