Compare commits

..

636 Commits

Author SHA1 Message Date
8ac39d8863 3.0.6 changelog 2018-07-31 20:03:50 +02:00
83140541dc Fix Mono compilation on Windows/Ming 2018-07-28 23:01:38 +02:00
4491151aa9 Version 3.0.6-stable 2018-07-28 21:39:16 +02:00
5262d1bbcc Fix marshalls size checks.
Yesterday, when playing around with my network code, I realized there is
a security issue in decode_variant, at least when decoding PoolArrays.
Basically, the size of the PoolArray is encoded in a uint32_t, when
decoding it, that value is cast to int when comparing if the packet is
actually that size causing numbers with MSB=1 to be interpreted as
negative thus always passing the check. That same value though, is used
as uint32_t again to resize the output vector.  For this reason, sending
a malformed packet with declared type PoolByteArray and size of 2^31(+x)
causes the engine to try to allocate 2+GB of pool memory, causing the
engine to crash.
2018-07-28 21:21:19 +02:00
1a325e3580 Fix continuous attempt to reload domain with API assemblies out of sync
(cherry picked from commit 762c912e8e)
2018-07-28 16:06:30 +02:00
fc678567d7 Mono: Fix domain reload never triggering
(cherry picked from commit f1130f9a8a)
2018-07-28 16:06:30 +02:00
286ff21dd1 Fix '!valid' error spam on C# script instance create
(cherry picked from commit 8edf85b09c)
2018-07-28 16:06:30 +02:00
cf1c127c23 Mono: Fix null dereferences
(cherry picked from commit 5aefe5d936)
2018-07-28 16:06:30 +02:00
e7110984f3 Add Dictionary::erase_checked(key) method
Same as erase, but it returns a boolean value indicating whether the pair was erased or not.
This method should be removed during the next compatibility breakage, and 'Dictionary::erase(key)' should be changed to return a boolean.

(cherry picked from commit 2f69e36cef)
2018-07-28 16:06:30 +02:00
31f8d3525d Add Array and Dictionary wrapper classes to C#
(cherry picked from commit ee3c476c9a)
2018-07-28 16:06:30 +02:00
e1cf8dc2cb Mono: Pending exceptions and cleanup
(cherry picked from commit 4739cb8c00)
2018-07-28 16:06:30 +02:00
291be24742 Mono: Default to not shipping C# scripts content
Fixes #20053.

(cherry picked from commit df170d81cc)
2018-07-28 16:06:30 +02:00
3304c7620a [Mono] Improvements to GD.cs: PascalCasing and real_t
[Mono] Improvements to GD.cs: PascalCasing and real_t

(cherry picked from commit 174cf31d00)
2018-07-28 16:06:30 +02:00
ba441c48b0 Makes Mono bindings partial & adds GetNode<T>.
(cherry picked from commit a8c97eb094)
2018-07-28 16:06:30 +02:00
e5aedf130f Fix bug with Basis.Transposed()
Fix bug where Basis.Transposed() incorrectly updated local basis, and
returned an unmodified copy. This also fixes Transform.Inverse().

(cherry picked from commit 7a4d593198)
2018-07-28 16:06:30 +02:00
94debea0a9 Make C# bindings generator ignore disabled classes
(cherry picked from commit 92c7fe422b)
2018-07-28 16:06:30 +02:00
c6a48e11e9 [Mono] Update about/warning text
I've removed the section about being unable to export games using C# - as you are now able to do this, as long as the export templates are installed. Also, I've made a few minor grammar tweaks.

(cherry picked from commit 69530ef614)
2018-07-28 16:06:30 +02:00
327452cb09 Added path for Mono installed through Homebrew
On macOS, it is common to install packages like Mono through the third-party
package-manager Homebrew. This commit simply adds an additional path to
where Homebrew installs the Mono framework.

(cherry picked from commit 39aabba0a9)
2018-07-28 16:06:30 +02:00
c751b66d38 convert unicode mono root path to ascii string
(cherry picked from commit 753230c275)
2018-07-28 16:06:30 +02:00
5928b18cf3 The build-solutions flag now forces editor mode.
(cherry picked from commit 03bb14bcc5)
2018-07-28 16:06:30 +02:00
f37779ba20 Travis: Build Mono module in linux tools job
(cherry picked from commit 7bf0c134a7)
2018-07-28 16:06:30 +02:00
ef67ef3155 Travis: Make dependencies follow the matrix requirements
Also make the coverity addon only applied to the static checks build job.

(cherry picked from commit c58f73fd35)
2018-07-28 16:06:30 +02:00
ba3406fffe Travis: Cleanup build matrix
Remove unused MinGW config, switch server build to gcc/tools.
Update COVERITY_SCAN_TOKEN's secure.

(cherry picked from commit f827dcba44)
2018-07-28 16:06:30 +02:00
68bfea5aa0 [Mono] Rename Fposmod to PosMod
[Mono] Rename Fposmod to PosMod

(cherry picked from commit 5b2b23c9a9)
2018-07-28 16:06:30 +02:00
be588f9493 Fix crash on editor startup when running with platform=server
(cherry picked from commit 4e58db9f12)
2018-07-28 16:06:30 +02:00
c3fcb18bc6 Fix scene import when platform=server
Adds code in RasterizerStorageDummy to store off mesh surface information,
rather than just throwing it away. Without this, all surface arrays were
just defaulting to empty when the packed scene was written.

(cherry picked from commit 5b639269a2)
2018-07-28 16:06:30 +02:00
4897227d04 fix can't set AudioStreamPlayer stream to null
(cherry picked from commit 2bdac0a5d9)
2018-07-28 16:06:30 +02:00
11cbf850a4 Fix vsync initialization
(cherry picked from commit 5c0a576630)
2018-07-28 16:06:30 +02:00
c00c3f10a4 Fix possible NullPointerException crash on cancel payment
(cherry picked from commit d05db4de8e)
2018-07-28 16:06:30 +02:00
00fa61f8f5 Preventing an editor crash in the event that a plugin scene's root-node is null.
(cherry picked from commit 2adfdbe184)
2018-07-28 16:06:30 +02:00
d3a482ab65 Fix possible bug with AudioStreamPlayer2D audio position
(cherry picked from commit 0c78a58b64)
2018-07-27 17:14:22 +02:00
b64850e732 Make _ALWAYS_INLINE_ and _FORCE_INLINE_ equivalent
_ALWAYS_INLINE_ and _FORCE_INLINE_ are now equivalent for debug and
non-debug builds. This is a lot faster for Vector in the editor and
while running tests. The reason why this difference used to exist is
because force-inlined methods used to give a bad debugging experience.
After extensive testing with modern compilers this is no longer the
case.
2018-07-27 17:14:22 +02:00
bc2ee93758 Fix touch issues on Windows
(cherry picked from commit 2f161ffd4f)
2018-07-27 17:14:22 +02:00
2843a3f7e7 Merge pull request #20517 from akien-mga/openssl-1.0.2o
openssl: Update to pristine 1.0.2o (security update)
2018-07-27 17:10:51 +02:00
33a9bda1d9 openssl: Update to pristine 1.0.2o (security update) 2018-07-27 16:17:27 +02:00
d3c4f91c9c Workaround for clang 6 bug.
(cherry picked from commit b68222e4e7)
2018-07-26 16:09:42 +02:00
5c6c88ef15 i18n: Sync translations with Weblate 2018-07-26 11:22:43 +02:00
69cdb35820 Travis: Update clang-format version in shell script
(cherry picked from commit 36efa7d445)
2018-07-18 17:49:27 +02:00
4d89153e5f Travis: Install libstdc++ >= 4.9 for clang-format-6.0
(cherry picked from commit 22b176f69d)
2018-07-18 17:45:39 +02:00
c709dff1a2 Style: Format code with clang-format 6.0.1
(cherry picked from commit 7c9f7452f4)

Travis: Update style checks to clang-format 6.0.1

(cherry picked from commit 003ac67df1)
2018-07-18 16:37:23 +02:00
d859aa1438 Update AUTHORS and DONORS list
New contributor added to AUTHORS:
@JFonS
Also updated alphabetically sorting with `sort -d`.

Thanks to all contributors and donors for making Godot possible!

[ci skip]

(cherry picked from commit b631306de1)
2018-07-18 10:31:45 +02:00
4fcb0d036c fix default glTF metallic & roughness factor values
The glTF 2.0 spec says that these pbrMetallicRoughness material
properties should be set as 1.0 by default.
In fact, KhronosGroup's official Blender Exporter does not even write
down those parameters if they are set as 1.0.

However, Godot import them as 0.0.

https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#pbrmetallicroughness

Fixes: #19613 https://github.com/godotengine/godot/issues/19613
(cherry picked from commit 01b01209a3)
2018-07-10 00:10:39 +02:00
b5338b640f Bump to 3.0.6-devel 2018-07-09 14:32:35 +02:00
6a88e22423 Version 3.0.5-stable 2018-07-08 16:03:43 +02:00
861d341dff Write new permissions to the AndroidManifest.xml
Instead of editing the placeholder permissions actually write new ones.
This should solve the privacy statement problems for the Play store.
This means we also no longer need to placeholder permissions in the
template.

(cherry picked from commit 2a126242dd)
2018-07-08 15:48:08 +02:00
a34daf6851 Fix segfault at quiting editor
(cherry picked from commit e639db0529)
2018-07-08 15:39:15 +02:00
59a00c3cdd Fix debugger focus stealing
At least on Windows, the authorization must be given every time, not only at startup.

(cherry picked from commit 2fcbf9dd81)
2018-07-08 15:39:15 +02:00
e86ef017f2 allow undefined GODOT_DEBUG_MSBUILD environment variable
(cherry picked from commit 17516822f9)
2018-07-08 15:39:15 +02:00
d4a226500b Mono: Add 'View log' button to open the MSBuild log of a build
(cherry picked from commit 4a021fa7a2)
2018-07-08 15:39:15 +02:00
16550339ba Mono: Fix passing wrong logger assembly path to MSBuild
- Add option to print MSBuild's stdout and stderr instead of redirecting it. This can be enabled by setting the environment variable: Godot_DEBUG_MSBUILD=1

(cherry picked from commit 25f10b3c40)
2018-07-08 15:39:15 +02:00
84e1551c64 Mono: Null checks when marshaling from MonoArray* and managed Dictionary
(cherry picked from commit 7933a6cc9f)
2018-07-08 15:39:15 +02:00
af902dc042 Lerp now consistent with Godot API. InverseLerp fixed.
(cherry picked from commit c2315e3291)
2018-07-08 15:39:15 +02:00
d99b247cc7 Revert "Fix saving unmodified scenes and resources"
This reverts commits 28ab60422d
and 7821b70a00.

Fixes #19576, and likely the fact that subresources are no
longer saved when saving scenes with no change.

(cherry picked from commit 5d7f9f804a)
2018-07-08 15:39:15 +02:00
139185e543 Fix CORS problems due to added headers on JS target
Before this change, missing User-Agent and Accept headers were automatically
added on all platforms. Setting the User-Agent header forces the browser to
do a CORS preflight (see 1) which fails if the HTTP endpoint is not
configured appropriate. It's not neccesary to set either header as the
browser sets them and so this commit disables that functionality on the JS
target.

1: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#Simple_requests
(cherry picked from commit 8a4dccc4ce)
2018-07-08 15:39:15 +02:00
=
64bcefb7cd Mono: Fixes annotated signal loading in exported binaries
(cherry picked from commit 489c9adf03)
2018-07-08 15:39:15 +02:00
4ac9932128 Merge pull request #19944 from PatrickKaster/feature/android_modules_asset_dir
asset_dir method in Android modules' gradle config
2018-07-04 23:29:38 +02:00
9190ae2be7 added 'android_add_asset_dir('...') method to Android module gradle build config 2018-07-04 23:04:14 +02:00
a03cf8964f Fix date typo in changelog 2018-06-28 14:22:43 +02:00
4bf441c32b Bump to 3.0.5
And onwards!
2018-06-23 17:05:45 +02:00
b116a45f07 Add changelog for 3.0.4 2018-06-23 16:45:07 +02:00
d91613592b Godot 3.0.4-stable 'brown paper bag' 2018-06-22 15:33:45 +02:00
e6df472e8f doc: Remove extraneous empty lines in descriptions 2018-06-22 14:51:59 +02:00
f6abffdb4a Add longer description to ViewportTexture doc
(cherry picked from commit cf63abac36)
2018-06-22 14:47:09 +02:00
a1930b1772 [DOCS] Builtin keywords because search is terribad
(cherry picked from commit 5002db6be1)
2018-06-22 14:46:48 +02:00
9530ce9d3f [DOCS] TreeItem: Small fix for remove_child()
(cherry picked from commit 25b5242d9f)
2018-06-22 14:46:35 +02:00
3d8e49d9e8 [DOCS] InputEventMouseButton: Factor
(cherry picked from commit 03250259d3)
2018-06-22 14:46:17 +02:00
64419a2ea1 Add a little to ViewportTexture docs
(cherry picked from commit b820056b38)
2018-06-22 14:45:44 +02:00
34eabc0602 Fix Vector2 doc of floor, add ceil doc
(cherry picked from commit d759d25aca)
2018-06-22 14:45:18 +02:00
ade470352c Added some details in skeleton docs.
Workaround for #19551.

(cherry picked from commit 195e963613)
2018-06-22 14:44:53 +02:00
ae48b1b94a Added description for abs function in Rect2
(cherry picked from commit d1b3f36eab)
2018-06-22 14:44:34 +02:00
394838901d updated Viewport docs to correct wrong information and fill out empty sections
(cherry picked from commit 650ebdc832)
2018-06-22 14:44:06 +02:00
f49fcc960b Added some documentation to particles
(cherry picked from commit c4dfef58d9)
2018-06-22 14:43:45 +02:00
2f3e4c1a7a add NoCache wrapper to Command
(cherry picked from commit 920224a535)
2018-06-22 14:42:14 +02:00
d04cc2855a i18n: Sync translations with Weblate 2018-06-22 10:57:15 +02:00
909eaede4c Disable threading in Asset Library
Threaded HTTPRequest appears to be crashy on 3.0.x.
Fixes #19336.
2018-06-22 09:30:17 +02:00
4d7aa0b762 Make heightmap shape usable from PhysicsServer
- Fixed bad size check
- Fixed bad member initialization
- Removed unused cell_size (Bullet expects us to use localScaling)
- Accept precomputed min/max height, will be calculated if not provided

(cherry picked from commit a66e1af168)
2018-06-14 15:50:15 +00:00
98609279b6 Bump version to 3.0.4
And onwards!
2018-06-14 15:37:51 +00:00
25047050b7 Update AUTHORS and DONORS list
New contributors added to AUTHORS:
@Nallebeorn, @ibrahn, @KellyThomas, @ShyRed

Thanks to all contributors and donors for making Godot possible!

[ci skip]

(cherry picked from commit a18fe06773)
2018-06-14 15:22:48 +00:00
38e6ba10b4 Update changelog for 3.0.3-stable 2018-06-14 15:21:42 +00:00
e649ec71df Fix some missed changes from a cherrypick 2018-06-13 12:21:29 +00:00
711aa196af Bump version to 3.0.3-stable 2018-06-13 11:57:40 +00:00
518a691231 Mono: Allow loading mscorlib from resources.
(cherry picked from commit b3ddf12fb1)
2018-06-13 11:57:40 +00:00
e8bfc09b81 i18n: Sync translations with Weblate 2018-06-05 22:10:51 +02:00
74808e71d2 i18n: Sync translation templates with current source 2018-06-05 22:04:33 +02:00
403f7dc35f Change ".." punctuation for "..." in editor strings (#16507)
(cherry picked from commit 1c419531a0)
2018-06-05 21:42:33 +02:00
e09170dffa Revert "Prevent visibility notification been called twice in object creation"
This reverts commit 826108efec.

This caused a regression (#18614), and potentially other unintended regressions.
2018-06-05 12:14:57 +02:00
f640639867 Fix Mono static linking on Mingw 2018-06-01 21:45:21 +02:00
d24f77be99 Fix documentation version strings 2018-06-01 18:19:33 +02:00
f697b53eba round / ceil methods for c sharp vectors
(cherry picked from commit a6bd2c6e72)
2018-06-01 18:08:52 +02:00
8231b3cef8 Vector3::round, Vector2::round & Vector2::ceil methods were added.
Now both structs (Vector2 & Vector3) have round, floor & ceil methods.
(see #18603)

(cherry picked from commit 26963473a9)
2018-06-01 18:08:29 +02:00
b95cc40640 Set current SynchronizationContext before the game loop starts
This fixes the problem that `SynchronizationContext.Current` would be null
during the call to `_EnterTree`, `_Ready` and the first call to `_Process` thus
the task continuations would be scheduled outside the main thread, which is unexpected and might lead to crashes.

With this change, task continuations are scheduled always on the main thread and so async/await can be used without any explicit synchronization, which is what is expected.

Fixes #18849

(cherry picked from commit f25240cfe6)
2018-06-01 18:07:32 +02:00
9294978596 fixes build error on Linux after its introduction in #18949
The function expects now a return value. Returning NULL seems to work in
this case.

(cherry picked from commit 6c74f3de6d)
2018-06-01 18:06:44 +02:00
3d3e4e62af Mono: Project building fixes
- Set (Csc/Vbc/Fsc)ToolExe environment variables to point to the batch files in Mono's bin directory when building with Mono's MSBuild.
- Set Mono's MSBuild as the default build tool on Windows.
- Generate projects with portable DebugType instead of full.

(cherry picked from commit 01397a10d9)
2018-06-01 18:06:42 +02:00
d00926894e mono: add Slerp method to vector classes, expose Cross method for Vector2, and fix unnecessary casts in Basis
(cherry picked from commit b335274bcd)
2018-06-01 18:05:28 +02:00
5d2ad1e5c7 Reduce allocations when converting mono arrays to pool arrays
(cherry picked from commit 56262ceafe)
2018-06-01 18:04:54 +02:00
9945da3efc Mono: Improve 'script class not found' error
No longer printed when using using placeholder script instances (for non-tool scripts in the editor).
Print different error if the project assembly is not loaded

(cherry picked from commit c8945fe7d8)
2018-06-01 18:04:12 +02:00
d1e5677fe6 Travis: Add server build with clang
(cherry picked from commit 1e19e2846d)
2018-06-01 18:02:49 +02:00
49ddd7b0e7 Add more IDE created files into .gitignore
(cherry picked from commit d3a6960437)
2018-06-01 18:01:21 +02:00
e29800ea7b Javascript: Remove weird log
(cherry picked from commit 0c56e011ad)
2018-06-01 18:00:51 +02:00
97ad6b813a Make filename clipped on Import dock
(cherry picked from commit 12fb5f58d9)
2018-06-01 18:00:17 +02:00
77542276f8 Check for 0 roll influence
(cherry picked from commit 660bebec94)
2018-06-01 17:59:15 +02:00
0a3779135d Improve side impulse calculation
(cherry picked from commit a36e5951ff)
2018-06-01 17:59:11 +02:00
edf423a7aa fixed minor doc wording problem
(cherry picked from commit 4fe2605ab3)
2018-06-01 17:56:56 +02:00
02b1586de2 filled in docs for panorama sky
filled in docs for panorama sky

(cherry picked from commit 1bf7f8fcd1)
2018-06-01 17:56:24 +02:00
a2a136ea02 added documentation for procedural sky
Added documentation for procedural sky

added documentation for procedural sky

added documentation for procedural sky

(cherry picked from commit 6711691d10)
2018-06-01 17:55:54 +02:00
9b8388dab1 [docs] fix links in class docs
(cherry picked from commit 888eefa0fd)
2018-06-01 17:55:13 +02:00
fbad7c2dd9 [docs] fix links in class docs
(cherry picked from commit c6ed46891d)
2018-06-01 17:53:52 +02:00
12fe774844 [DOCS] Update VideoPlayer classref
(cherry picked from commit 393125a6a4)
2018-06-01 17:52:07 +02:00
8dc021925f [DOCS] Array sort
(cherry picked from commit 9115d84913)
2018-06-01 17:50:56 +02:00
6843ccf462 Added some quick info on shaders to the docs
(cherry picked from commit b7ae2ca128)
2018-06-01 17:50:29 +02:00
b27352a401 Fixed GroupCallFlags links in the SceneTree's doc.
(cherry picked from commit e10687a520)
2018-06-01 17:49:22 +02:00
8461d6b5f9 Mono: Basis constructor for euler parameter
(cherry picked from commit c26d30986a)
2018-06-01 17:46:38 +02:00
0febfa9eea mono: New Color methods: Darkened, Lightened and ToRgba32
(cherry picked from commit 88bd33f451)
2018-06-01 17:45:49 +02:00
232a3a524b mono: Plane, expose Normal, and D
(cherry picked from commit 16e1b4bacf)
2018-06-01 17:44:56 +02:00
b04c9a1b66 fixed capital A osx
(cherry picked from commit 6476b708d9)
2018-06-01 17:43:28 +02:00
dd026c77e3 fixed a input not registered in osx script editor
(cherry picked from commit d927e972d1)
2018-06-01 17:43:14 +02:00
00bf66d7f2 Add additional macos shortcuts for going to start/end of line
(cherry picked from commit 166c7fdc9d)
2018-06-01 17:43:10 +02:00
6224f02c56 Fix index out of range error in string.Extension()
(cherry picked from commit c7e98eef67)
2018-06-01 17:37:43 +02:00
31ce9ba07f Fix scons installation on AppVeyor
Seems like AppVeyor just upgraded pip and finally removed the
deprecated --egg switch.

(cherry picked from commit 79e76d8329)
2018-06-01 17:35:29 +02:00
94b4bb2a12 Mono: Fix MonoImage filename being set to an invalid path
(cherry picked from commit 97fb999976)
2018-06-01 17:33:51 +02:00
188bfd2ac9 Increase versionCode range 3.0
(cherry picked from commit d71d968987)
2018-06-01 17:33:27 +02:00
04defcca4f Bump to 3.0.3rc3 2018-06-01 17:27:54 +02:00
81eb60434a [mono] fix signals parameter retrieval
(cherry picked from commit 7a72395412)
2018-05-16 12:27:45 +02:00
6635f2a108 Add back missing method from e10a2e5999 2018-05-14 00:25:34 +02:00
1d3be8c453 fix API string path
(cherry picked from commit a35c8bbdc7)
2018-05-13 23:03:48 +02:00
4de1d0905a Fix vector reduction in shader language
(cherry picked from commit 5b50685b38)
2018-05-13 23:02:32 +02:00
c461b15720 Fix icon if remote icon load fails
(cherry picked from commit c3e921fba3)
2018-05-13 22:58:13 +02:00
5c93f887ba Implement missing methods in dummy rasterizer
(cherry picked from commit 0cad1417b6)
2018-05-13 22:56:53 +02:00
9dc5ca0e7c Fix duplicate definitions with FreeType
(cherry picked from commit b8c35b4078)
2018-05-13 22:46:11 +02:00
c7b141d20a [DOCS] Vector2/Vector3/TileMap wording fixes
(cherry picked from commit 8bc4882dd3)
2018-05-13 22:45:08 +02:00
0b3b3de2cd Ability to change path color with self modulate
Fix #18164

(cherry picked from commit d77ffa3e97)
2018-05-13 22:43:10 +02:00
5e551a584e added custom aabb to primitives
(cherry picked from commit 1ee40206d4)
2018-05-13 22:41:29 +02:00
fd95935fef hide tab changed debug print
(cherry picked from commit 31f28885f9)
2018-05-13 22:40:28 +02:00
4fbb460a02 Fix:code editor text size should change at least one each time, don't mind how you setting your display scale
(cherry picked from commit eeb0534426)
2018-05-13 22:39:13 +02:00
4aad40d249 Small changes for some strings.
(cherry picked from commit 5b0ddb1354)
2018-05-13 22:37:56 +02:00
8ccb27ce18 Tweak the property hint ranges of caret blink and line length guideline
This allows for more precise adjustments.

(cherry picked from commit 0eb2f6c223)
2018-05-13 22:36:21 +02:00
9a0a40042e Adds keywords to autocomplete predictions.
Adds keywords to the autocomplete prediction in GDScript so
they are not replaced by irrelevant predictions.

Fixes: #5972
(cherry picked from commit 6e32157a65)
2018-05-13 22:35:19 +02:00
09277c8fd8 LinkButtons are now responsive to engine theme
Fixes #18636, so now LinkButtons (like those in the asset store) will change font colour to remain visible in any engine theme, just like Labels etc

(cherry picked from commit c364a1278e)
2018-05-13 22:34:10 +02:00
faceb5b75d Implement pull/18665 for 3.0
Windows detect.py: Detect missing WindowsSdkDir
2018-05-13 22:32:01 +02:00
9dc5ba1aaf Bump version to 3.0.3rc2 2018-05-13 22:28:07 +02:00
a187fb381e Fix placeholders position in LineEdit when editing inside the Editor
Editing the `Text` property through the editor causes a wrong
placement of the placeholder, as it calls `LineEdit::clear_internal`,
which was wrongly reseting the cached placeholder width.

Fix #18184.

(cherry picked from commit c17de1f70f)
2018-05-13 22:19:42 +02:00
868c44b239 Fix keyboard focus lock-out with HTML5 canvas in iframe
(cherry picked from commit 9080e96bc8)
2018-05-13 22:17:53 +02:00
10c12b37ec Consider TextEdit paste operation complex.
Not considering a paste operation as a complex one ends up
adding an unneeded extra step when pasting over a selection.

This fixes issue #18325

(cherry picked from commit b09e0454bb)
2018-05-13 22:16:56 +02:00
ae32bcf4c3 Fix a crash when trying to run Godot debugger on a release build.
The GDScriptLanguage::enter_function is wrapped in #ifdef DEBUG but the exit_function is not, resulting in a stack underflow error.

(cherry picked from commit 9149b11973)
2018-05-13 22:14:44 +02:00
3491e776dd fix clang6 assignment error
(cherry picked from commit f48ff4dc64)
2018-05-13 22:13:14 +02:00
5f632391ca fix for segfault when using CallBasic in visual script on release build
(cherry picked from commit 95dfa5b96d)
2018-05-13 22:11:08 +02:00
2e61ca6193 Particles: fix corrupted scene when saved after convert (2nd try)
(cherry picked from commit 38865345d9)
2018-05-13 22:08:53 +02:00
3013f4cf2b Fix AnimationPlayer edited scene bug
(cherry picked from commit 223f085857)
2018-05-13 22:05:28 +02:00
31c4b743cb Fix enums without class name not opening docs page
(cherry picked from commit ccd986f53e)
2018-05-13 22:04:37 +02:00
78e2e48d57 Fix for Issue#18457 - Folder name with trailing space on Windows
(cherry picked from commit 164dceab28)
2018-05-13 22:03:40 +02:00
736e574a5e Fix editor detecting msbuild with a msvc 'tools only' install
(cherry picked from commit 93d13bee8b)
2018-05-13 22:00:53 +02:00
664052824e Fix MSVC check when building with mono
(cherry picked from commit a1aa98e05a)
2018-05-13 22:00:20 +02:00
0b9f61c9a6 add condition check in Imgae::create(...)
(cherry picked from commit 63e258cc8f)
2018-05-13 21:59:22 +02:00
41bb321962 For uwp the ARM architecture needs to be in lower case
(cherry picked from commit 07f590046a)
2018-05-13 21:58:37 +02:00
0c030d6e08 Fix double free for drag preview control in viewport
(cherry picked from commit 56c2463f8c)
2018-05-13 21:56:56 +02:00
c8ce9c0080 Fix Variant leak in call_native
(cherry picked from commit 474eda9e30)
2018-05-13 21:55:19 +02:00
a519dcd576 Disable 'run' button if any project not selected and tiny refactoring
(cherry picked from commit 965b6ac273)
2018-05-13 21:53:27 +02:00
66c0be642f Fix relative mouse motion when captured in HTML5 platform
(cherry picked from commit d78b10313b)
2018-05-13 21:52:14 +02:00
2fa54c1df6 Fix custom cursor disappearing on osx
(cherry picked from commit 48f9e6a05b)
2018-05-13 21:51:25 +02:00
7f65584f28 Use mimetype according to glTF spec.
(cherry picked from commit 9a50a4442d)
2018-05-13 21:48:37 +02:00
7e09206e5c Proper focus in/out handling on iOS
PR #18675 (commit 96301e9) revealed a problem with how iOS lifecycle
callbacks were handled by Godot. Before that PR it was possible to get
NOTIFICATION_WM_FOCUS_IN callback without getting the corresponding
NOTIFICATION_WM_FOCUS_OUT. That commit added a flag to ensure they are
always coupled, but now there is an issue when, for example, you open a
notification panel on iOS without moving the app to background.
It resulted in view.stopAnimation being called without the
corresponding startAnimation when the app moves to foreground again, so
it looked like the game hanged.

I changed focus out notification to be sent in applicationWillResignActive,
because it makes more sense than to do it in applicationDidEnterBackground,
because it is always called in pair with applicationDidBecomeActive, where
focus in is sent. applicationDidEnterBackground may not come under
circumstances that are now described as a comment in code.

(cherry picked from commit 08a924bcee)
2018-05-13 21:46:57 +02:00
ecb4c4268c Resume audio on iOS after phone call or alarm
When a phone call or an alarm triggers on iOS, the application receives
an "audio interruption" and it's up to the application to resume
playback when the interruption ends. I added handling for audio
interruptions same as if the game is focused out and then back in.

(cherry picked from commit 96301e934d)
2018-05-13 21:46:53 +02:00
db76c54117 Fix Linux/X11 build on ARMs.
(cherry picked from commit ce64c2a32e)
2018-05-13 21:45:09 +02:00
c2a8eb2081 Use fake audio playing property in editor
It appears that some time ago users were supposed to be able to include the playback of sound effects in their animations by placing keys on the "playing" property. Back then the key frame editor took the value of the checkbox in the property_editor.

Somewhere / Sometime this behaviour changed and the key frame editor is now reading the actual value from the object instead of relying on the property editor.

This commit introduces a fake active field that is returned when reading the playing property in the editor. While the actual active flag is changed when playback is finished the fake one will stay the same thus allowing the user to take their time with setting the key in the animation editor.

(cherry picked from commit bc1522e268)
2018-05-13 21:42:27 +02:00
5917063192 Merge pull request #18082 from RandomShaper/improve-gui-touch-3.0
Implement universal translation of touch to mouse (3.0)
2018-05-13 21:30:37 +02:00
bcb38393a5 Merge pull request #18157 from RandomShaper/improve-uri-utils-3.0
Improve/fix URI utils (3.0)
2018-05-13 21:11:42 +02:00
1905e1c8a2 Android: Increase targetSdkVersion to 27
Matches the change for 2.1 in #18626, and the new requirements from Google
for new apps starting with August 2018 (targetSdkVersion 26 or higher):
https://android-developers.googleblog.com/2017/12/improving-app-security-and-performance.html

(cherry picked from commit a6552819b1)
2018-05-08 15:30:11 +02:00
a6c9527c2f Fix for large .pck files
An error in unix file IO was causing crashes when getting the size of a file larger than max integer size
As ftell returns a long the fix is trivial

(cherry picked from commit 8a7840a304)
2018-05-08 09:10:26 +02:00
f4c469f1b7 Rewrite Tween class reference.
(cherry picked from commit d7218c742c)
2018-05-08 09:09:04 +02:00
196107cd9e correct documentation for version number data type
(cherry picked from commit 28eb97c8ab)
2018-05-08 09:08:52 +02:00
33b78c0ad6 [DOCS] Clarify look_at and looking_at
(cherry picked from commit b431264f77)
2018-05-08 09:07:52 +02:00
fa19d01c7b Fix: JAR files signed with the MD5 algorithm as unsigned
(cherry picked from commit d3182248c4)
2018-05-08 09:06:54 +02:00
f847837fb2 Update AUTHORS and DONORS list
New contributor added to AUTHORS:
@mysticfall

Thanks to all contributors and donors for making Godot possible!

[ci skip]

(cherry picked from commit bd54ff78d9)
2018-05-04 15:14:16 +02:00
056348a8c0 i18n: Sync translation templates with current source 2018-05-03 11:25:51 +02:00
ddbe559c04 i18n: Sync translations with Weblate 2018-05-03 11:20:59 +02:00
63e70e3cd1 Bump to 3.0.3-rc1 2018-05-01 22:08:47 +02:00
4866733a74 GDNative Unix: fix shared lib loading, dlopen expects leading ./ to interpret as relative path.
(cherry picked from commit 8287441955)
2018-05-01 22:07:02 +02:00
01e64eb247 Prevent PulseAudio driver to lock its mutex for too long
(cherry picked from commit cf4371a0ad)
2018-05-01 22:05:20 +02:00
4fe0a8efd8 Fixed high cpu usage with PulseAudio
(cherry picked from commit 11078101db)
2018-05-01 22:04:51 +02:00
0551c5c2cd PCKPacker:pck_start(): Update version
(cherry picked from commit a3aa5ad0d0)
2018-05-01 22:04:08 +02:00
e10a2e5999 Implement universal translation of touch to mouse
Now generating mouse events from touch is optional (on by default) and it's performed by `InputDefault` instead of having each OS abstraction doing it. (*)

The translation algorithm waits for a touch index to be pressed and tracks it translating its events to mouse events until it is raised, while ignoring other pointers.

Furthermore, to avoid an stuck "touch mouse", since not all platforms may report touches raised when the window is unfocused, it checks if touches are still down by the time it's focused again and if so it resets the state of the emulated mouse.

*: In the case of Windows, since it already provides touch-to-mouse translation by itself, "echo" mouse events are filtered out to have it working like the rest.

On X11 a little hack has been needed to avoid a case of a spurious mouse motion event that is generated during touch interaction.

Plus: Improve/fix tracking of current mouse position.
2018-04-30 19:04:35 +02:00
cd9b0d7cc3 Fix msbuild with a msvc 'tools only' install
Taken from https://github.com/Microsoft/vswhere/wiki/Find-MSBuild
without '-products *' vswhere does not locate msbuild when installing a
tools-only (no IDE) version of the microsoft compilers.

(cherry picked from commit 0ec912a79e)
2018-04-30 12:54:51 +02:00
8e301c69cb Fix lto builds on clang compilers
This needs to go to master also
2018-04-30 00:52:42 +02:00
3ee4d6af2e Hand-merge API hash fixes #18514
This hasn't made it into master yet but is important for mono support.
If this turns out to be the wrong call we'll revert and merge whatever
next version of this becomes available.
2018-04-29 20:44:48 +02:00
00c55bb2eb Fix _export_begin not being called when exporting to android
(cherry picked from commit c8884ce3bd)
2018-04-29 18:45:09 +02:00
fe9da69f96 Make 'Export PCK/ZIP' work well with EditorExportPlugin
Add debug flag to the 'Export PCK/ZIP' option
Make 'Export PCK/ZIP' notify when the export process begins. This is necessary to receive the 'EditorExportPlugin::_export_begin' callback

(cherry picked from commit 68b35de2b6)
2018-04-29 18:44:55 +02:00
c358e4c728 Add option to link mono statically on Windows
(cherry picked from commit b5e6e142ef)
2018-04-29 16:16:26 +02:00
7645c539c8 Fix new Node dialog Create button behavior
Added a one-liner to update the Create button disabled state when
selecting an item from the search results list.

Fixes #17265, long live the Realm!

(cherry picked from commit 68a4241131)
2018-04-29 15:14:09 +02:00
e7837828f6 Improved error checking at EditorExportPlatformPC::export_project
(cherry picked from commit 0876502f72)
2018-04-29 15:12:21 +02:00
272fb05270 Added File.get_path and File.get_path_absolute functions
(cherry picked from commit a4e64c5454)
2018-04-29 15:09:29 +02:00
41f360f9c2 Update preview on filesystem change
Check and recreate a file's preview, if it has changes to it in the filesystem.

(cherry picked from commit 188ccf190b)
2018-04-29 15:08:11 +02:00
4ce6a8f5f9 Show error icon at "Output" in case of errors
(cherry picked from commit 5120690013)
2018-04-29 15:06:29 +02:00
dfe6d42a01 A few fixes on the ARVR Server
(cherry picked from commit 5356423377)
2018-04-29 15:05:38 +02:00
c20776945d Set default file name for exported projects
(cherry picked from commit bff73bdbf1)
2018-04-29 15:03:45 +02:00
0d6c64b38a Removed unneeded sort from SpriteFramesEditor plugin
(cherry picked from commit bb9c75c5ed)
2018-04-29 15:02:18 +02:00
c968c787e5 Disable Emscripten assertions in release_debug builds
The messages generated by some assertions can be confusing to users.

(cherry picked from commit d6c9d8d778)
2018-04-29 15:01:29 +02:00
6e658fdcc1 Warn about WorldEnvironment being ignored
(cherry picked from commit 29d305599d)
2018-04-29 15:00:41 +02:00
aedc4a4e80 Explicitly print an error when --export fails.
Previously this would not explicitly say the export failed.
Sure you might see another error somewhere,
but that's not very reliable/obvious.

(cherry picked from commit 4954982b95)
2018-04-29 14:57:32 +02:00
7417b6adb4 Comment out some debugging messages when playing Theora files
(cherry picked from commit 9590282ae8)
2018-04-29 14:56:52 +02:00
66b36235c9 Fix IPhone and OSX cross compilation
(cherry picked from commit e7b9e2f970)
2018-04-29 14:46:03 +02:00
e317ab9abe Add --print-fps option to output FPS to stdout
Works both for the editor and games.

Projects can still use "debug/settings/stdout/print_fps" to enable it
permanently. The --print-fps option takes precedence (so works even if
the project setting is disabled). That setting is also no longer redefined
on the fly based on the verbose flag, that was a mess.

(cherry picked from commit 10fa69285c)
2018-04-29 14:44:43 +02:00
6a48c552e2 Updated thekla_atlas to support arm64
(cherry picked from commit cd63e699ca)
2018-04-29 14:43:53 +02:00
a1fd60f7d2 Docs update for several classes
Namely: Dictionary, GraphEdit, Object, TileMap, Script, ScollBar,
ScrollContainer and SplitContainer

(cherry picked from commit 0dd526e062)
2018-04-29 14:42:13 +02:00
b5ecdd8ce8 Fixed (minor) typo in CapsuleShape2D doc page
(cherry picked from commit 2dcd499707)
2018-04-29 14:35:59 +02:00
20ea59332f [DOCS] Popup.popup_exclusive description
(cherry picked from commit d4ce53b9b1)
2018-04-29 14:35:42 +02:00
57b895338b [DOCS] Add note that Pool*Arrays are passed by value (#18340)
(cherry picked from commit 6b797574a2)
2018-04-29 14:33:28 +02:00
2f82b67071 [DOCS] add HTTPRequest.request return values
(cherry picked from commit f05e24ed18)
2018-04-29 14:32:44 +02:00
56b8c4b0eb Add descriptions for GroupCall flags
Add descriptions for GroupCall flags

(cherry picked from commit 7eed3cc199)
2018-04-29 14:32:13 +02:00
bae5f9feb8 [DOCS] OS
(cherry picked from commit 66714a3d29)
2018-04-29 14:31:56 +02:00
e95f542204 Add new transform tutorial to appropriate classes
(cherry picked from commit e83af5dfc6)
2018-04-29 14:30:45 +02:00
e7c42f132c Add Navigation docs
(cherry picked from commit 89b9e8852e)
2018-04-29 14:30:25 +02:00
1608f04851 Add Navigation2D docs
(cherry picked from commit a7f3933a51)
2018-04-29 14:30:13 +02:00
93ebac318b [DOCS] SceneTree
(cherry picked from commit bc66869d4c)
2018-04-29 14:29:25 +02:00
c4d66d087f [DOCS] Tweaks and fixes for (Interpolated)Camera
(cherry picked from commit 99110772c0)
2018-04-29 14:28:58 +02:00
feee8ddd3c Add detail to doc for add_surface_from_arrays (#17911)
Includes review comments from #17911 from @cbscribe and @Noshyaar

(cherry picked from commit 06c5a9ed5f)
2018-04-29 14:27:46 +02:00
659df8cbd8 Added missing end points for brief descriptions in the docs.
(cherry picked from commit d912e10c65)
2018-04-29 14:27:30 +02:00
19a010cc3a [DOCS] Some content for InterpolatedCamera
(cherry picked from commit c05d12384a)
2018-04-29 14:27:15 +02:00
307fcb2713 [DOCS] Typo fix for CollisionShape[2D]
(cherry picked from commit 41da122875)
2018-04-29 14:27:01 +02:00
ec017f4c01 [DOCS] Node & PackedScene (#17833)
* [DOCS] Node: SceneSaver -> PackedScene

* [DOCS] PackedScene: Code example, resolve TODO

(cherry picked from commit 13d5ee01f9)
2018-04-29 14:25:17 +02:00
f12db4013e Improve Input.is_action_just_* docs.
More clarification.

(cherry picked from commit 11aa330a6f)
2018-04-29 14:24:52 +02:00
e53f01a7af [DOCS] Node: Networking updates, fix outdated and missing docs
(cherry picked from commit 5a3e841c60)
2018-04-29 14:24:26 +02:00
46de6afc40 [DOCS] Input
(cherry picked from commit 22cb4a1cf9)
2018-04-29 14:23:23 +02:00
90bf0b7aec [DOCS] Net.MultiplayerEnet: List returned errors
(cherry picked from commit ec3f5218e8)
2018-04-29 14:23:04 +02:00
6cdf6d3044 Update Image format enumeration documentation
Provides more information about each image format.

(cherry picked from commit 60f1f58158)
2018-04-29 14:22:40 +02:00
1da969736f Remove duplicated declaration of RoundToInt() from Mathf
(cherry picked from commit 9e2e6bb1e2)
2018-04-29 14:15:09 +02:00
486f4d2769 [mono] add the 'Facades' subfolder to the searched directories in _preload_hook
(cherry picked from commit 22606a7bec)
2018-04-29 13:54:16 +02:00
199a54d5ac Mono: BindingsGenerator enum fixes
- Make enums have an unique signature name of int. This means that when generating internal methods, there is no difference between different enums types nor between enums and int. This way enums can re-use internal methods.
- Make type resolver fallback to int if a type is not found and it's an enum.

(cherry picked from commit fbc808012f)
2018-04-29 13:49:27 +02:00
57c281557a #18051: Fix indentation issues introduced during clean up
(cherry picked from commit 6b611e6431)
2018-04-29 13:40:15 +02:00
d330bee1c2 #18051: Do not use var in a for-loop, or where type is not obvious
(cherry picked from commit e59fad3924)
2018-04-29 13:40:09 +02:00
72bcacf2b6 #18051: Use common name for Color type argument
(cherry picked from commit 94edd92248)
2018-04-29 13:40:04 +02:00
3876a8776e #18051: Remove redundant verbatim prefixes
(cherry picked from commit f0bf5532fa)
2018-04-29 13:39:51 +02:00
37ce381e3d #18051: Use default parameter value
(cherry picked from commit 85787776a5)
2018-04-29 13:39:40 +02:00
939d50243b #18051: Use array initializer when applicable
(cherry picked from commit b765c051cb)
2018-04-29 13:39:34 +02:00
57f18194f5 #18051: Remove redundant parenthesis
(cherry picked from commit 9097c71255)
2018-04-29 13:39:28 +02:00
58f2953ddf #18051: Remove unnecessary variable assignments
(cherry picked from commit 93dd59d763)
2018-04-29 13:39:22 +02:00
31171ea5a2 #18051: Use 'var' when applicable
(cherry picked from commit fdfc478c88)
2018-04-29 13:39:08 +02:00
e7b97af276 #18051: Remove redundant casts and 'using', 'else', 'this' statements
(cherry picked from commit 0ef3e0577b)
2018-04-29 13:38:58 +02:00
95004aafb2 Fix use64 used without being initialized
(cherry picked from commit 9b4d23e898)
2018-04-28 23:06:24 +02:00
3f6ea30f8d Mono: Fix '!t' error messages when generating bindings
This error wasn't affecting the bindings generation process.

(cherry picked from commit ff7fe9e771)
2018-04-28 22:59:38 +02:00
58918b629d Mono: Do not spam script class not found error
Print this error only when trying to instantiate the script. This way we prevent errors being printed for source files which are not meant to be used as scripts.

(cherry picked from commit f8ce412560)
2018-04-28 22:59:25 +02:00
736d8db007 Mono: Fix crash on script load if the scripts domain isn't loaded
(cherry picked from commit 89e84185e8)
2018-04-28 22:59:11 +02:00
1e8ff7460a Fixes a typo in the VisualServer.canvas_item_add_set_transform docs.
(cherry picked from commit 09f79cde69)
2018-04-28 22:58:29 +02:00
b5425e3d87 Fixed context menu TTR bugs
(cherry picked from commit a1cfc89108)
2018-04-28 22:57:32 +02:00
3acd6fb728 Fix names of Variant operators
(cherry picked from commit fefee533ae)
2018-04-28 22:56:33 +02:00
94ddb499df Fix error spam with Sprite has compressed texture
Fix #18177

(cherry picked from commit 3ecf8eef37)
2018-04-28 22:54:54 +02:00
5a947ebc42 Fix index out of size error on Image
Fix #18229

(cherry picked from commit af0d547c02)
2018-04-28 22:54:44 +02:00
44f4c8e745 Fix crash resulting from bad month check in core_bind.cpp
Also, make it clear that day is 0-based. This might cause very slight differcies in existing games.
Fixes #18221

(cherry picked from commit 4b9cf93338)
2018-04-28 22:53:02 +02:00
4eed7cb9b2 Fix Android input source checks
Input source types are not pure bit flags, they are combinations of
flags, so != 0 check was incorrect and resulted in crashes later, when
trying to obtain the device.

(cherry picked from commit 5dffa506dc)
2018-04-28 22:50:25 +02:00
ca00323e7f Minor fixes for the AnimationPlayer doc.
(cherry picked from commit 9c3698dee2)
2018-04-28 22:48:28 +02:00
d49fc76ab8 Remove incorrect & potentially confusing references to Euler
e is referred to as Euler’s number, so technically the MATH_EXP description in VisualScript doc was not incorrect, though could potentially lead to confusion.

e is different from Euler’s constant however, making the existing GDScript exp & VisualScriptMathConstant descriptions nvalid.

(cherry picked from commit b6b8c7b215)
2018-04-28 22:47:43 +02:00
d89015cfe3 ItemList selection: Check against item count
ItemList needs to check against the number of items available when the user moves the selection via "ui_right" action.

(cherry picked from commit cbcb96ae85)
2018-04-28 22:43:36 +02:00
826108efec Prevent visibility notification been called twice in object creation
(cherry picked from commit d42b17607e)
2018-04-28 22:38:19 +02:00
739c14b07d Fixed wrong function call
(cherry picked from commit df2a626b49)
2018-04-28 22:35:25 +02:00
7f64090401 LineEdit placeholder alignment, content margins, and overflow bugs
LineEdit doesn't correctly uses style margins nor use placeholders
width correctly, causing multiple rendering bugs.

(cherry picked from commit 53b51f68bf)
2018-04-28 22:30:06 +02:00
3bda257163 Fix theme editor sample widgets
(cherry picked from commit a0626d7d9c)
2018-04-28 22:19:54 +02:00
02f767fe0d Add support for radio-looking items with icon
Letting users of `PopupMenu` use them. `OptionButton` was one of those interested and is updated in this commit.

Fixes #18063.

(cherry picked from commit b964a9e678)
2018-04-28 22:17:08 +02:00
20fa30bde6 Use radio-button-like menu entries where applicable
(cherry picked from commit a6dc160d5c)
2018-04-28 22:16:53 +02:00
b5b0e42b85 Support radio-button entries in ItemListPlugin
(cherry picked from commit bf14a6deff)
2018-04-28 22:16:38 +02:00
a525ea128d Add radio-button-looking entries to PopupMenu
They work exactly the same as current checkbox-decorated items, but in order to preserve compatibility, separate methods are used, like `add_radio_check_item()`. The other option would have been to add a new parameter at the end of `add_check_item()` and the like, but that would have forced callers to provide the defaults manually.

`is_item_checkable()`, `is_item_checked()` and `set_item_checked()` are used regardless the item is set to look as check box or radio button.

Keeping check in the name adds an additional clue about these facts.

Closes #13055.

(cherry picked from commit ab3b1d9f3e)
2018-04-28 22:16:25 +02:00
3b57b95efb Fixed area overlap cleaning
(cherry picked from commit 45b778c7f8)
2018-04-28 22:10:29 +02:00
4002da9603 Fix RigidBody's configuration warning for Z axis
(cherry picked from commit 6a5ed3a42b)
2018-04-28 20:30:34 +02:00
e5a17617e6 Resolves Inccorect Quaternion Conversion
Fixes https://github.com/godotengine/godot/issues/18025

(cherry picked from commit ae7a9df292)
2018-04-28 20:29:40 +02:00
4e756d61c8 Fix skeleton import from glTF
For some glTF files, the order of bones in the skeleton array wasn't matching the joints array in the meshes.

Fixes #17808.

(cherry picked from commit d8765dd103)
2018-04-28 20:24:43 +02:00
0f5a3d23ea Update transform buttons in tile editor while using T, A, S shortcuts (fixes #17962)
(cherry picked from commit 0853ac2006)
2018-04-28 20:24:00 +02:00
2e31c9fe10 fix bone scale/rotation in AnimationPlayers
fixes #17325.

The bone pose transform was created by setting the rotation and
**then** scaling the transform. This leads to object "deformation"
that's not intended.

(cherry picked from commit 4303fbca5a)
2018-04-28 20:19:35 +02:00
cf3c1d878d Fix of a possible memory leak: ConcavePolygonShapeBullet::setup was able to exit without releasing the 'shapeInterface' pointer.
(cherry picked from commit b569251110)
2018-04-28 20:18:03 +02:00
c5dfe6824c Mesh: fix crash when creating mesh outline from QuadMesh
Since create_outline can only make outline for PRIMITIVE_TRIANGLES,
when QuadMesh (which is PRIMITIVE_TRIANGLE_FAN) is used to create
outline, will leave `arrays` empty, and crash when it is being indexed
for "indices" subarray.

This PR shows error when there's only one surface and it is not
TRIANGLES. Also prevent the crash if it has more than one surface
and none of them are TRIANGLES (and any other cases that could leave
`arrays` empty) by checking the size of `arrays` == 8 before indexing
it, since the method seems to expect `arrays` to be of that size.

(cherry picked from commit a492d22952)
2018-04-28 20:16:22 +02:00
640063334d physics area added monitorable check
(cherry picked from commit fe768f4f00)
2018-04-28 20:15:24 +02:00
ac9e87aae3 Fixed physics server area cleaning
(cherry picked from commit 776942981b)
2018-04-28 20:14:28 +02:00
5e09cf3e89 Corrected physics query max result checking
(cherry picked from commit 444b8471a3)
2018-04-28 20:13:28 +02:00
6989a7ac53 Fix UpdatePowerInfo method implementation in PowerIphone class
(cherry picked from commit 06fab24348)
2018-04-28 20:11:49 +02:00
060f9f2cd7 Trigger IO error only after exhausting attempts
(cherry picked from commit a4fae0e5e3)
2018-04-28 20:06:30 +02:00
4c19fc2eb1 Implement missing navgiation polygon debugging in tilemap
(cherry picked from commit 84d60b0829)
2018-04-28 20:03:46 +02:00
5e70e4469a Fix bug in HTML5 HTTPClient.
The URL parameter already has a slash, adding an extra one results in
an invalid resource path

(cherry picked from commit b8c73b195f)
2018-04-28 20:01:35 +02:00
287f169f2a [Docs] fix typos
(cherry picked from commit a88ee7d920)
2018-04-28 20:00:42 +02:00
60bc0f79a7 Fixed some popups not shrinking their size back when losing items.
(cherry picked from commit 7cbf301f31)
2018-04-28 19:59:37 +02:00
c8d0d38cab Add safety checks when handling Android input
It is possible that input comes before the engine is fully initialized.
This fixes the crashes that ocurred when that happens.

(cherry picked from commit 995724b762)
2018-04-28 19:58:00 +02:00
d3ffc8ad0c Fix engine.js startGame() when loading from directory
(cherry picked from commit 3014e48ec5)
2018-04-28 19:54:29 +02:00
393e1ef4ee Allow custom path when using engine.js preloadFile() with URL
(cherry picked from commit d373029382)
2018-04-28 19:54:19 +02:00
78b44eab0a Fix engine.js preloadFile() with directories
(cherry picked from commit 6f1bddf4b5)
2018-04-28 19:54:12 +02:00
0f6626977b Expose Emscripten libs to engine.js discreetly
(cherry picked from commit 63c7fc6358)
2018-04-28 19:54:00 +02:00
71885e5ae4 multiply blend mode fix for spatial materials
(cherry picked from commit 314a419511)
2018-04-28 17:53:53 +02:00
038c4d3a83 Fix all categories unfold when one key binding is changed
(cherry picked from commit eda1e266c8)
2018-04-28 17:52:20 +02:00
de66976ff0 Fix dragging window from non-retina to retina display.
(cherry picked from commit 14597dc2b2)
2018-04-28 17:51:11 +02:00
b08aa6fb3c Fix compressor audio effect sidechain selection
(cherry picked from commit 7792dfe554)
2018-04-28 17:49:39 +02:00
ce944bc3fb Prevented external editor from running multiple times
Fixes #16923. I'm not a fan of the special case for scripts in editor_node.cpp, but in any case,
I made it so it wouldn't make the external editor to re-open just because we switched scenes.

(cherry picked from commit f5147befb6)
2018-04-28 17:47:23 +02:00
5485939233 [DOCS] minor ParticlesMaterial docs fix Linear -> Radial
(cherry picked from commit 7d18334ad2)
2018-04-28 17:46:34 +02:00
3cc2eee4e8 Fix crash in canvas_item_add_polyline when passing more points than colors
When `p_points.size() > p_colors.size()`, it crashed with invalid
array access to `p_colors`. Also, when `p_colors` was an empty
`Vector` it crashed due a missing `else` checking the `size`
condition, as the code handling that special case exists.

This PR fixes the missing `else` for `p_colors.size == 0` and,
following the `canvas_item_add_multiline` spirit, it only uses the
first color for the whole polyline if points and colors differ in
size.

Fix #17621.

(cherry picked from commit 8eedb2afe2)
2018-04-28 17:45:25 +02:00
56395b03e1 Fix oversampled font artifacts after resize
Font update after resize relies on the viewport size which was updated
after the font was already refreshed, which resulted in artifacts when
it was rendered into the actual/new viewport size.

Fixes #15173.

(cherry picked from commit 47747718d6)
2018-04-28 17:42:57 +02:00
448d281222 Fixes wrong calculation of gridcontainer's children size
(cherry picked from commit 896e5a64d3)
2018-04-28 17:40:29 +02:00
c07d588e80 Fix listing files inside directory in pack file
When adding a directory path to the inventory of the pack, an empty file name was being added to the file list. That made `Directory.get_ntext()` signal end-of-list too early so that files in a subdirectory were missed.

Fixes #15801.
Helps with #16798.

(cherry picked from commit 536611704a)
2018-04-28 17:35:48 +02:00
52c710f25a Changed debug max distance to avoid overflow
Changed it to roughly sqrt(FLT_MAX), it's a little less to account for float inaccuracies.
Fixes #1835

(cherry picked from commit 55f79f2e80)
2018-04-28 17:32:59 +02:00
29a02a78df Fixed small typo in the "InstancePlaceholder" doc.
(cherry picked from commit 712d6e724a)
2018-04-28 17:31:08 +02:00
91525e3075 Fix bug added in PR#17589. Resources couldn't be saved to files
This PR fixes the code to avoid saving default environment every time
the project is run whitin the editor.

Should fix #17727. Sorry for the troubles!

(cherry picked from commit 7821b70a00)
2018-04-28 17:22:42 +02:00
7563c17113 Fix saving unmodified scenes and resources
When `_save_all_scenes` or `save_resource_in_path` was called, they
always saved all the scenes and the resource no matter if they were
modified or not. For example, when `saving before run` option was
checked, it always overwrote the current scene and the default
environment simply by opening and runing the project.

This PR adds checks for unsaved scenes (using the same `unsave` check
others method used) and modified resources (comparing last modified
time and last import time).

Fix #6025.

(cherry picked from commit 28ab60422d)
2018-04-28 17:22:29 +02:00
43dcf23990 Hinted shader uniforms can have a default value
(cherry picked from commit 479f531635)
2018-04-28 17:16:07 +02:00
1182637ec9 Fix debugger_stdout_settings being ignored
(cherry picked from commit 2b728de8f2)
2018-04-28 17:12:41 +02:00
d40f40e1c9 Fix pressing F3 do both changing to script editor AND find next text
As `KEY_F3` was used both for changing to script editor window and, in
the script editor, for finding the next result in the last search, and
the key event is **not** consumed, the resulting behaviour was similar
to press `F3` twice, first to change to script editor and second to
find the next result of a previous search.

This PR sets the `key_pressed` status of `InputEvent` to `false` if
this event is responsible of an editor change, simulating the
consumption of the event.

Fix #17334

(cherry picked from commit 8939f44f6a)
2018-04-28 17:09:55 +02:00
fa831f0224 Fix non-valid characters for input_action
Add a new function to check action names, `_validate_action_name`, in
the spirit of `_valprop`. Offending characters include non-printable
ascii, and `\/=:"`. Also set only one text for the UI message.

(cherry picked from commit da6c07698f)
2018-04-28 17:07:20 +02:00
141e389c3f Fix non working action names containing whitespaces
Now the action name is quoted if it contains spaces. Also, quotation
mark (") is added to the forbidden character list for action names, as
it was also a bug.

Fix #17322

(cherry picked from commit ea94a82596)
2018-04-28 17:04:20 +02:00
72350eebb2 ScriptTextEditor: fix capitalize offset
(cherry picked from commit caa0d513ab)
2018-04-28 16:45:17 +02:00
80fbea28fb Fixes importing hdr files with extra header info
(cherry picked from commit 886156da2c)
2018-04-28 16:42:27 +02:00
7ec8a6e756 Fix converting a tilset if the existing file is not a tileset
See ed3b080ca6
2018-04-28 16:40:31 +02:00
ddb31e9c5a EditorNode: fix clicking ok keeps trying to save
(cherry picked from commit e12e6cacdb)
2018-04-28 16:29:58 +02:00
dc97f91a18 Fix column width on AutoLoad table on hidpi displays
(cherry picked from commit f494d5ac5c)
2018-04-28 16:28:47 +02:00
171542d96a Update TileMap when its TileSet changes
Make TileMap monitor its TileSet for changes and emit a signal when the TileSet changes. This makes the editor update and show the updated version of the TileSet.

(cherry picked from commit 67f4944a21)
2018-04-28 16:25:33 +02:00
b855bc44ae Implement line clipping for TextureProgress to avoid bad rendering due to imprecise UV mapping
Original code used a quick aproximation for simulating the
correspondent texel in the `TextureProgress` texture as radial
progress indicator. This lead to visualization errors. Changed it for
a Liang-Barsky line clipping algorithm stripped to its minimum for
this specific use case.

Fix #17364.

(cherry picked from commit 7991bd168d)
2018-04-28 16:19:52 +02:00
c39e32ae60 Update Sprite when Texture changes
Make Sprite monitor its Texture for changes and trigger an update when the sprite changes.

(cherry picked from commit a23c0877f1)
2018-04-28 16:13:28 +02:00
5eef26b64e Fix broken hover/select coloring of keys in animation editor
(cherry picked from commit 172aa6c61e)
2018-04-28 16:07:03 +02:00
0d2a2a9300 Fixes canvas light shaders.
Fixes #16904

Restore more out functionality, fix built-ins.

Requested changes, I think?

(cherry picked from commit 25ba49fd88)
2018-04-28 16:03:23 +02:00
6d767b0f9a AnimationPlayer: fix scrubbing after play backwards
(cherry picked from commit b553b38e7b)
2018-04-28 15:55:36 +02:00
d49579b038 Fix overwriting all common properties when using Change Type tool
If you change the type of an existing node, it checks if you have
modified the initial value of their properties before overwriting
their values in the new node.

For example, if you created a `Label` and changed it to
`LineEdit`, the `mouse_filter` property was created as `Ignore`
for the original `Label` node, and was maintained after changing
it to `LineEdit` causing not to work as expected. Now it checks if
`Ignore` is the default value for `Label` nodes, and as it is, the
property value is left unchanged, maintaining the default value
for `LineEdit`, which is `Stop`.

Fix #13955 and alike.

(cherry picked from commit 8ea4ea0d53)
2018-04-28 15:47:57 +02:00
a3ba1b0280 Fix script template on _ready behavior
(cherry picked from commit 01ec06d9ae)
2018-04-15 01:18:49 +02:00
c2e02e2066 Added error checks for fscache saving
(cherry picked from commit 06e537fec5)
2018-04-15 01:17:01 +02:00
3503ee4be6 Fix invalid mix function overload
(cherry picked from commit 97bef8d908)
2018-04-15 01:13:38 +02:00
069b429795 AnimationPlayer: fix popups close on double click
(cherry picked from commit 6d51b6ab42)
2018-04-15 01:08:45 +02:00
2f7aa6c2aa Make the shader token names consistent.
(cherry picked from commit b095e21d91)
2018-04-15 01:07:37 +02:00
a29680c25a [Mono] Improve Mathf
(cherry picked from commit 655a4e6540)
2018-04-15 00:57:14 +02:00
3a430e46b9 [mono] Fixes #17936 as GodotSharp (Core\Basic.cs) requires C#7 now, but we most probably should keep C#6 yet
(cherry picked from commit 5677aed175)
2018-04-15 00:56:14 +02:00
b4733a1da9 Fixed _issue_activated to take the correct issue id from the list
(cherry picked from commit 4fdee1d9f1)
2018-04-15 00:55:25 +02:00
8ebd4bb874 Move GodotSharp and MonoBuildTab member variables to initializer list
(cherry picked from commit 3f86fefb64)
2018-04-15 00:54:00 +02:00
63a88c69ac Added wrap functions to C#
(cherry picked from commit d52722c6da)
2018-04-15 00:52:29 +02:00
bfc94dd4c9 Mono: Runtime main args and assembly search fixes
- Setup runtime main args during initialization. This must be done manually by embedders who do not call mono_runtime_run_main. Fixes NullReferenceException in System.Environment.
- Continue to search the assembly in the rest of the search locations if loading it from one of them failed.

(cherry picked from commit fa1d656af4)
2018-04-15 00:48:15 +02:00
6472d8c7d4 Mono: Avoid invalid class names.
Disallow reserved keywords as class names and prefix base class with the Godot
namespace if it's the same as the class name.

Fixes #12483

(cherry picked from commit 700d07cf7c)
2018-04-15 00:48:11 +02:00
e4fadebc3b Fix a merge error 2018-04-15 00:43:26 +02:00
548ec63f76 EditorExport: Allow export plugins to add shared libraries
(cherry picked from commit a38b59b656)
2018-04-15 00:04:18 +02:00
9e4d34aebb Mono: Add project export plugin
(cherry picked from commit 9fd606c549)
2018-04-15 00:04:14 +02:00
d02c891a4b [mono] write classes with no constructor as abstract
(cherry picked from commit ef5672d3f9)
2018-04-14 23:54:11 +02:00
3bd414786c [mono] rename functions to conform to PascalCase
in:
* StringExtensions.cs
* Transform.cs

(cherry picked from commit d7020aef8d)
2018-04-14 23:53:56 +02:00
c7adcc8dca Fix mono basis GetEuler bug and marshalling/unmarshalling
(cherry picked from commit 91f271fa9e)
2018-04-14 23:20:33 +02:00
577f3ccaf9 Replace float with real_t, default Vectors, other misc C# improvements
Replace float with real_t in most files, defined at the top of each file via using. Objects such as Vector3 now accept doubles as inputs, and convert to real_t internally. I've added default Vectors such as Vector3.Zero. Other misc C# improvements such as Mathf.RoundToInt(). Color continues to use float only because high precision is not needed for 8-bit color math and to keep things simple. Everything seems to compile and work fine, but testing is requested, as this is the first time I've ever contributed to Godot.

(cherry picked from commit ff97c97c93)
2018-04-14 23:20:03 +02:00
bffd4f0548 Fix bad autocomplete of partially written node paths when using syntactic sugar notation ($)
If you had a tree like Node2D->Sprite->Camera2D and you write a
code like $Node2D/Spr and chose the autocompletion sugested
Node2D/Sprite, the resulting string was $Node2D/Node2D/Sprite
instead $Node2D/Sprite. If you chose Node2D/Sprite/Camera2D, then
you ended with $Node2D/Node2D/Sprite/Camera2D.

Fix #15813.

(cherry picked from commit 95f186b621)
2018-04-14 23:14:30 +02:00
4c8c383876 Update Hack font to v3.003
(cherry picked from commit 93f52813bf)
2018-04-14 23:11:18 +02:00
125b403c0f WASAPI driver will now resample when the device rate != audio/mix_rate
(cherry picked from commit d21a2019f1)
2018-04-14 22:07:30 +02:00
5f5ec7e162 WASAPI audio driver compile fix on mingw
(cherry picked from commit 3316a64e12)
2018-04-14 22:03:10 +02:00
a91d9cb918 Fix possible crash when audio channels change
(cherry picked from commit 87ebdd6041)
2018-04-14 21:47:05 +02:00
a7ea441504 Fix PulseAudio problems with 8 channels devices
(cherry picked from commit 34395c6a38)
2018-04-14 21:46:11 +02:00
4b5472b100 Fix error detecting for PulseAudio pa_stream_new call
(cherry picked from commit 86e101ec82)
2018-04-14 21:46:06 +02:00
3dc4447cb8 CoreAudio: Fix iphone build after audio device refactor (#17742)
(cherry picked from commit e955fbc36e)
2018-04-14 21:44:57 +02:00
9a21f964ba Added new audio device functions to set/get the audio device
(cherry picked from commit ecc1b34cbc)
2018-04-14 21:42:44 +02:00
1f07f71b6c Fix PulseAudio driver for audio devices that report unknown number of channels
(cherry picked from commit 11fbfab7ec)
2018-04-14 21:38:26 +02:00
259b9664ef auto-completion edge jump
arrow up/down jumps to end/start on edges

(cherry picked from commit e36dd4282b)
2018-04-14 21:29:48 +02:00
b5a55810c5 Disable FreeType SIMD in HTML5 builds
SIMD is currently unsupported in WebAssembly.

(cherry picked from commit 315983c90d)
2018-04-14 21:15:37 +02:00
4fc6256010 Change shebang of pre-commit-clang-format hook to make it portable
The default one is "#!/bin/bash", but BSD systems doesn't have bash
in that path. For portability reasons, it should be changed to
"#!/usr/bin/env bash".

More info: https://en.wikipedia.org/wiki/Shebang_%28Unix%29#Portability

(cherry picked from commit 52abf4ba84)
2018-04-14 20:59:39 +02:00
ce1b62a01f Explicitly set OpenGL profile to core (X11, Windows).
Enable GLES2 on Windows.

(cherry picked from commit ad67911f1a)
2018-04-14 20:56:49 +02:00
28d4271e3e skip demo download prompt if ssl is unavailable
(cherry picked from commit 0071c04dcb)
2018-04-14 20:44:54 +02:00
30b5265417 completed-signal is emitted by all GDScriptFunctionStates of a coroutine now, allowing to yield for completion of a function with more than one yield inside.
(cherry picked from commit 3dfef37628)
2018-04-14 20:42:44 +02:00
2f53325bed Fix round preview getting square on "run scene" (issue 16734)
(cherry picked from commit 899f7b125e)
2018-04-14 20:37:54 +02:00
7ad6a9aeea Fix selection of Sprites using AtlasTexture in the editor.
Fixes #16261.

(cherry picked from commit a01ba4523b)
2018-04-14 20:30:51 +02:00
8018dc6599 Fix for a possible crash when a custom theme is not loaded properly
(cherry picked from commit 2f1429eb24)
2018-04-14 20:28:13 +02:00
aaed3ef5ed FIX Windows enter/exit mouse notifications
Fix to this issue #17202

(cherry picked from commit 979dccbd8d)
2018-04-14 20:25:57 +02:00
99cf2ffb19 iPhone X support and iOS-related fixes
Starting from April 2018 Apple no longer accepts apps that do not
support iPhone X. For games this mainly means respecting the safe area,
unobstructed by notch and virtual home button. UI controls must be
placed within the safe area so that users can interact with them.

This commit:

- Adds OS::get_window_safe_area method that returns unobscured area of
  the window, where interactive controls should be rendered.

- Reorganizes how launch screens are exported - the previous way was
  incorrect and modern iPhones did not pick up the correct screens and
  because of that used a non-native resolution to render the game.

- Adds launch screen options for iPhone X.

- Makes launch screens optional in the export template. If not
  specified, a white screen will be used.

- Adds App Store icon (1024x1024) export option as it now has to be
  bundled with the app instead of being provided in iTunes Connect.

- Fixes crash when launching games in iOS Simulator. It happened because
  controllerWasConnected callback came before the engine was
  initialized. Now in such case the controllers will be queued up and
  registered after initialization is done.

- Fixes issue with the virtual keyboard where for some reason
  autocorrection panel would intersect with the keyboard itself and not
  allow you to use the top row of the keyboard. This is fixed by
  disabling autocorrection altogether.

Closes #17358. Fixes #17428. Fixes #17331.

(cherry picked from commit 1d9a3a9b1c)
2018-04-14 20:17:47 +02:00
3b200c55b6 GridMap: fix next/prev plane text, fix meta not found
(cherry picked from commit 89323f94bb)
2018-04-14 20:10:02 +02:00
13e9b605cf Moves the md5sum's from the <filename>.import file into .import/<filename>.md5
Saves asset md5sum's in a file that doesn't contain data that needs to be VC'd
Now saves the md5s to a different file (.import.md5)

Now reads the md5's from a separate file

Now uses a file in the .import folder to store md5s

(cherry picked from commit 030b59502f)
2018-04-14 19:57:45 +02:00
5d7b7f798a Made print_tree_pretty() function which displays scene tree graphically
(cherry picked from commit 8362ce4769)
2018-04-14 19:56:55 +02:00
710b57d493 Make BaseButton not emit press when container is scrolled
This fixes the problem described in #13996 in a proper way.

This also adds "deadzone" property to ScrollContainer. It can be used
on mobile, where taps are not as precise as mouse clicks. Player could
slightly move their finger when tapping, in which case we still want
the button to be pressed rather than the container to be scrolled.

(cherry picked from commit dcf5be92a3)
2018-04-14 19:36:10 +02:00
ef44ed93a7 For-in loop variable added to autocompletion
Fix for #16494

(cherry picked from commit f97ebdcab3)
2018-04-14 19:19:47 +02:00
4f0b5f7307 Implement always-on-top for MacOS
Courtesy of @bruvzg.

(cherry picked from commit 2e8c7824c0)
2018-04-14 19:04:13 +02:00
1c25e50490 Add new window setting: always on top
Implemented for Windows and Linux.

(cherry picked from commit ee2c31d306)
2018-04-14 19:03:53 +02:00
a9ec1e3913 Fix buggy http-encoding
(cherry picked from commit 1fc85b87bd)

The original commit's message said "percent-encoding" because it was fixing the same code under a different method name. That rename was reverted but the fix was and is still relevant.
2018-04-12 21:22:46 +02:00
46101928bd Enhance HTTPClient.query_string_from_dict()
(cherry picked from commit 8d8e9d54c8)
2018-04-12 21:20:10 +02:00
74e72c995d Update AUTHORS and DONORS list
New contributor added to AUTHORS:
@robfram

Thanks to all contributors and donors! :)

[ci skip]

(cherry picked from commit e6e911eb2b)
2018-04-06 21:46:45 +02:00
b6f30f1b5b Fixes infinite loop in GridContainer
(cherry picked from commit 44cb8eb3a2)
2018-03-29 00:41:03 +02:00
b09d06fcf7 Fix getting Android device information
Fix #17644

(cherry picked from commit 4e378aeeb8)
2018-03-29 00:34:31 +02:00
9567297a66 Fixed several leaks in VisualServerScene, RasterizerSceneGLES3 and RasterizerGLES3
(cherry picked from commit e9ac87390c)
2018-03-29 00:29:06 +02:00
607884139c Fix a potential bug hinted by clang
(cherry picked from commit 4d81e8afe6)
2018-03-29 00:27:46 +02:00
42f351db0d Fixed leak in BulletPhysicsServer
(cherry picked from commit e5ae9750ed)
2018-03-29 00:24:09 +02:00
9ab9dd73b0 SCons: Fix running 'scons' without platform argument
The cache and progress logic assumed the 'env' to be defined,
but it is only when the selected platform is in the supported list.

Fixes #17497.

(cherry picked from commit a44f9ca545)
2018-03-29 00:21:41 +02:00
fa9e03996c Prevent android to split-screen
(cherry picked from commit 61e8f8a866)
2018-03-29 00:19:49 +02:00
814b610ed3 Fix for clang warning at distance_to
(cherry picked from commit bbd21c2203)
2018-03-29 00:15:24 +02:00
a5ccaa919e Prevent division by zero in GridContainer
(cherry picked from commit 38623e07ac)
2018-03-29 00:12:35 +02:00
5042d0c30a Fix silent failure of importing OGG Vorbis files
When importing non-valid OGG Vorbis audio files, now the filesystem
navigation tree shows the correct sad red-face icon, as it does with
non-valid PNG, JPG or WAV files.

Fix #9793.

(cherry picked from commit a8d37de461)
2018-03-29 00:11:46 +02:00
27f5e404a7 Update libwebm
Update of libwebm.

Up-to-date version of libwebm contains several bugfixes that allow playback of files that would crash Godot otherwise.

(cherry picked from commit e71f109910)
2018-03-29 00:06:05 +02:00
2e9c9f7d74 Fix animation length from glTF not correctly set
(cherry picked from commit 1f26da0ad1)
2018-03-29 00:04:15 +02:00
6063e74e06 Fix glTF not accepting VEC3 colors
Aside from the colors themselves, the rejection was adding somes issues later in the mesh import process.

(cherry picked from commit adbe749513)
2018-03-29 00:04:10 +02:00
449e75455b Fix BaseButton not always calling _pressed()
Fix "ui_accept" action in BaseButton.cpp not calling _pressed() func in
GDScript

(cherry picked from commit ceb079fa35)
2018-03-28 23:55:58 +02:00
73cc3a96c0 Fix uninitialized data in Sprite::_get_rects()
(cherry picked from commit 5f917139ab)
2018-03-28 23:54:10 +02:00
683511310e Fix garbage in string padding.
(cherry picked from commit 0269e366f1)
2018-03-28 23:51:31 +02:00
12336dc253 Added a check for trailing dot when creating folder.
Merge the trailing dot test into existing test. Removed OS test.

(cherry picked from commit 96f61b2d65)
2018-03-28 23:50:29 +02:00
8da76f3bb8 Fix wrong SSL handshake
The name of the remote host is passed to mbed TLS in all cases so the client hello message is correctly formed.

(cherry picked from commit 602da6fa4f)
2018-03-28 23:49:00 +02:00
8289f8628d Modify OSX can_export logic to match the logic from EditorExportPlatformPC::can_export
(cherry picked from commit a42dfd7882)
2018-03-28 23:47:22 +02:00
91bc845152 Fix infinite loop in GridContainer layout
I had a grid container and tried to set rect.min_height larger in the
editor; that caused an infinite loop in GridContainer::_notification
at line 118. The reason is max_index was being set to the *height* of
the row, not the *index* of the row. So later when it tried to erase
that row and try again, there was nothing to erase.
I applied the same fix to the width code.

(cherry picked from commit 561e57df13)
2018-03-28 23:45:39 +02:00
d8a0b6ba63 Hack to force macOS window activation for non-bundled app.
(cherry picked from commit 506e17ee70)
2018-03-28 23:39:16 +02:00
bf4d8ee69c EditorAudioBus: expand effects list
(cherry picked from commit 555a8c0b8d)
2018-03-28 23:36:58 +02:00
2c93def09d Add "Show Origin" and "Show Viewport" options to 2D Editor Viewport
(cherry picked from commit 934498d37a)
2018-03-28 23:33:03 +02:00
9cbcff4e91 ScriptEditor: Use EditorSettings instead of hardcoded values in constructor.
(cherry picked from commit 1cfc43421e)
2018-03-28 23:13:46 +02:00
985b84689f Support for uneven amount of channels on PulseAudio
(cherry picked from commit 00693f4ad0)
2018-03-28 23:05:23 +02:00
89e4125241 Use GL_LINE_STRIP instead of GL_LINES when drawing polylines.
(cherry picked from commit 20cab06f9a)
2018-03-28 23:01:09 +02:00
209acbaac7 Add documentation for the DynamicFont hinting property
(cherry picked from commit a0ddd6122c)
2018-03-28 22:56:29 +02:00
8a0966a8cb Add an hinting mode setting to DynamicFonts
- Editor font hinting can now be tweaked in the Editor Settings.
- DynamicFonts used in projects now have tweakable hinting settings
  in their DynamicFontData child. Changes will be visible upon
  reloading the scene in the editor.

(cherry picked from commit c1544c12ef)
2018-03-28 22:56:04 +02:00
99331ca395 Added pitch scale property to AudioStreamPlayer, AudioStreamPlayer2D and AudioStreamPlayer3D
(cherry picked from commit 5bc010e8ee)
2018-03-28 22:43:44 +02:00
ec362d54a9 Fix Automatic switch to viewport when playing a scene #16357
(cherry picked from commit d002b7d24a)
2018-03-28 22:41:06 +02:00
5e8e2a8730 AudioServer emit bus_layout_changed signal when adding, moving or deleting a bus
(cherry picked from commit 56dcf4b983)
2018-03-28 22:34:43 +02:00
df7d60a9d3 Abort compilation on missing return values (CGG/clang)
(cherry picked from commit 5ec09455ed)
2018-03-28 22:21:33 +02:00
fe20a1e35b add restore purchases for iOS
(cherry picked from commit da652c1539)
2018-03-28 22:16:07 +02:00
55a66efa38 Fix get_drive (bookmarks) in linux not working
(cherry picked from commit 7e5b10b7d3)
2018-03-28 22:13:39 +02:00
5eebe51014 Fix builtin script cannot open from debug stacks
(cherry picked from commit 095e2bcc26)
2018-03-28 22:12:31 +02:00
9febb6f747 Don't print error message when select debugger stacks if the debugger is stopped.
Clear debugger stack inspector if the debugger is stopped when selected stack changed.

(cherry picked from commit cfde737478)
2018-03-28 22:09:16 +02:00
626525d23a Draw relationship line on scene tree dock if option is on
(cherry picked from commit 36aa62802a)
2018-03-28 22:06:01 +02:00
a026e2626c Fix weird editor crash when switching from editing one gradient to another keeps 'grabbing' variable to true
(cherry picked from commit f68594a525)
2018-03-28 22:01:19 +02:00
cf2e30b30c Fix Line2D tile mode for non-square textures
(cherry picked from commit d2fae5c9a6)
2018-03-28 21:33:49 +02:00
f7efa9d43a Fix line thickness for CollisionPolygon2D.
(cherry picked from commit a36f6e5386)
2018-03-28 21:23:42 +02:00
dfb739aff0 Fix grid mesh tile panning bug (issue 16524)
Fix basic function and interference of touch pad pan with mesh tile delete (shift + right click on touch pad) in grid map editor (fix 16524)

(cherry picked from commit b90810ce8e)
2018-03-28 21:11:38 +02:00
89bff17cd2 More threading in AssetLib
AssetLib now uses thread as requested to download previews and items

(cherry picked from commit 3a25415a1c)
2018-03-28 21:03:56 +02:00
3e1716b2c3 GridMapEditorPlgn: fix a leak
(cherry picked from commit 5cf331588a)
2018-03-28 21:02:51 +02:00
e6200de73a Bump version to 3.0.3-devel
And onwards!
2018-03-18 02:38:31 +01:00
593e616a48 Dist: Fix Linux desktop file launch argument
(cherry picked from commit a55e2f2dac)
2018-03-14 12:06:18 +01:00
eeb7385f02 SCons: Fix linking system pcre2 on server platform
Fixes #17245.

(cherry picked from commit e619727e99)
2018-03-04 13:47:35 +01:00
2ff3b08583 Bump to 3.0.2-stable
Thanks to all of our contributors!
2018-03-03 15:22:04 +01:00
6ab8fb04af Fix documentation indentation for apply_torqe_impulse 2018-03-03 15:19:40 +01:00
498d177cfe Update changelog for 3.0.2 2018-03-03 15:12:41 +01:00
06a60bb6ef Fix floatBitsToUint function
(cherry picked from commit c6b6af7bb5)
2018-03-03 14:54:52 +01:00
c0132f30c4 Viewport: Fix missing tooltips w/ disabled physics object picking
Previously this option seemed to be the sole responsible for enabling
physics processing in Viewport, while several other features like
tooltips and debugging collision hints rely on it.

All this logic is moved to internal processing (it's incorrect to let
it be affected by users disabling physics/idle processing), and disabling
physics object picking no longer affects the internal physics processing.

Fixes #17001.

(cherry picked from commit ce7da2c7d6)
2018-03-03 14:19:57 +01:00
649cb70ddb [DOCS] Small fix to Area: Fix copy/paste errors
(cherry picked from commit fdd0f18959)
2018-03-03 11:00:41 +01:00
65d214d3da i18n: Sync translation templates with current source 2018-03-03 10:58:19 +01:00
9ee98e999b i18n: Sync translations with Weblate
(cherry picked from commit 7c7d3efb5b)
2018-03-03 10:56:41 +01:00
5bcc7f88b6 [DOCS] Small fix to PinJoint2D
(cherry picked from commit 0b65bac1a1)
2018-03-03 01:55:33 +01:00
93e99846b0 [DOCS] NetworkedMultiplayerENet
(cherry picked from commit 5aae17a6fb)
2018-03-03 01:55:27 +01:00
5c2e554853 prune cache only at the start and end of build
(cherry picked from commit 29e6ec6594)
2018-03-03 01:53:22 +01:00
c4468aef5d s/Camear/Camera in docs
(cherry picked from commit b099a500eb)
2018-03-03 01:52:12 +01:00
f967334f53 Fix more regressions in RichTextLabel from PR 15711
(cherry picked from commit 0e1e95c41f)
2018-03-03 01:47:52 +01:00
4132f2ea7e Update AUTHORS and DONORS list
New contributors added as AUTHORS:
@mrcdk, @binbitten, @paulloz, @PJB3005

New Gold sponsor: Skirmish <https://skirmish.io>

Thanks and welcome! :)

[ci skip]

(cherry picked from commit 741af0652d)
2018-03-02 19:48:12 +01:00
262c97098d Fix serialization of identifiers with non printable ASCII characters
Fixes #6888.

(cherry picked from commit ab001d830b)
2018-03-02 14:54:45 +01:00
cee20e24bd Don't crash when trying to add an invalid navmesh
It is possible to try to add an invalid object as a navmesh through
GDScript which results in an engine crash. This creates a debug message
that should help the user figure out what's wrong.

(cherry picked from commit 555eebf3f4)
2018-03-02 12:06:46 +01:00
87476c057a NativeScript: Fix initialization in wrong scope
Regression from d702d7b335 which broke javascript build.

(cherry picked from commit 08cadc3d87)
2018-03-02 02:08:50 +01:00
53693e393d Revert "Make KEY_ESCAPE close all output/debugger docks on bottom"
This reverts commit c04d868476.

This caused a regression when trying to close the typing suggestion.
Reverting this for now until a better implementation for this behavior
gets made.
2018-03-01 23:06:26 +01:00
3f7e036c4f Godot now allows built-in irrespective of the filepath.
Since the file in the filepath is irrelevant when setting the file
as built-in, changes have been made to allow setting to built-in
even if the file in the path exists.

Fixes #16425

(cherry picked from commit 1fdb8251d2)
2018-03-01 21:38:15 +01:00
0aab429453 AnimationEditor: fix time indicator offset
(cherry picked from commit acf54f8bdc)
2018-03-01 21:18:58 +01:00
61fd30c00e Fixed Windows ignoring minimized/maximized status set by user
(cherry picked from commit f8da9550f4)
2018-03-01 21:15:35 +01:00
44b206a3fa Fix server build on FreeBSD
(cherry picked from commit 8f9914bd94)
2018-03-01 21:12:28 +01:00
675899a521 Fix various valgrind reported uninitialized variable uses
(cherry picked from commit d702d7b335)
2018-03-01 21:06:31 +01:00
61a9ef5d81 Fix intermittent audio driver crash during startup on Android
set_pause can be called before the driver is initialized, and there
already is a check for that. The problem is that the 'active' field
was not initialied in the constructor, which lead to it having an
undefined value.

(cherry picked from commit c10749d51f)
2018-03-01 21:05:15 +01:00
9c27e4d885 Allow degenerate triangles in polygon triangulation when necessary.
(cherry picked from commit e73266a51c)
2018-03-01 20:18:08 +01:00
c800653c6f Fix regression through fa98637aca
(cherry picked from commit 89f607604e)
2018-03-01 19:19:29 +01:00
3e931e258c More reliably find mscorlib.dll on Linux
(cherry picked from commit c094e90b25)
2018-02-27 22:12:01 +01:00
7e5a374825 Deprecate a typo for a new method introduced in 3.0.1 2018-02-27 17:53:46 +01:00
a850ebf352 Revert "fix spurious error messages during autocomplete and validate"
This reverts commit b7faa76485.

This causes a regression in 3.0.1. We haven't found a proper fix yet so
we're removing this from 3.0.2
2018-02-27 17:52:18 +01:00
4e1d19b20c Revert "[Mono] Basis values now marshalled in the correct order."
This reverts commit 9173819b71.

The fixes for these issues aren't quite baked yet. Taking them out of
3.0.2
2018-02-27 17:52:18 +01:00
d7430ef077 Revert "The marshalling in was also incorrect."
This reverts commit b6f958965b.

The fixes for these issues aren't quite baked yet. Taking them out of
3.0.2
2018-02-27 17:52:18 +01:00
17408bea9c (Magnify|Pan)Gesture: implement as_text
(cherry picked from commit 67e20dc2b6)
2018-02-27 17:52:18 +01:00
2c55064708 doc: Sync with current source 2018-02-27 13:57:29 +01:00
42e82b9377 doc: Update version string for 3.0.2 2018-02-27 13:57:10 +01:00
a4b077a0ba Android: Mark GLES3 as required in the manifest
Fixes #17076.

(cherry picked from commit 7d09e6540a)
2018-02-27 13:33:59 +01:00
f6c65d9d15 Mono: Buildsystem improvements
- Bundle with mscorlib.dll to avoid compatibilities issues
- Add build option 'mono_assemblies_output_dir' to specify the output directory where the assemblies will be copied to. '#bin' by default.

(cherry picked from commit a45697d8df)
2018-02-27 11:35:19 +01:00
990bddcf36 fix release builds with mono
"_signals" and "signals_invalidated" were moved out of the
"TOOLS_ENABLED" directive. Updated also the two "update_signals" and
"_update_signals" methods so it makes sense.

(cherry picked from commit 3c7d9001bc)
2018-02-27 11:34:52 +01:00
c730a6ce44 Fix error spam when using PanoramaSky without texture
(cherry picked from commit 7a1b7ddf6c)
2018-02-27 11:34:03 +01:00
115c0a7415 added docs on Control's drag and drop api
(cherry picked from commit 7154a96d3f)
2018-02-27 11:32:35 +01:00
87242c7b92 fix build error when compiling with mono, tools=no, target=release
change TTR to RTR in `print_unhandled_exception`

(cherry picked from commit 90a705d671)
2018-02-27 11:25:10 +01:00
4eb9ee9355 Fixed physics server typo
(cherry picked from commit 134cca0cf2)
2018-02-27 11:22:56 +01:00
48ed52184d Add missing return statements (iOS and server).
(cherry picked from commit e3c2778d7e)
2018-02-27 00:06:01 +01:00
69274ef368 Fix visibility of gizmos on scene load
(cherry picked from commit 99d740c46e)
2018-02-27 00:02:01 +01:00
039fc750d5 only show information we have in stacktrace
do not show line number and/or file if not defined

(cherry picked from commit 3ee4ce51a9)
2018-02-26 23:55:27 +01:00
58a7d78c22 [mono] get stacktraces for all inner exceptions
(cherry picked from commit 89af6c2cd7)
2018-02-26 23:55:13 +01:00
c0386f0124 Mono: Fix bindings for parameters in vararg methods
(cherry picked from commit 0c82858121)
2018-02-26 23:54:32 +01:00
b6f958965b The marshalling in was also incorrect.
(cherry picked from commit 60daa9d718)
2018-02-26 22:45:53 +01:00
dde14e15c6 Mono: Better versioning and gracefully unloading of Godot API assemblies
(cherry picked from commit f37090ccf4)
2018-02-26 22:36:03 +01:00
1ea805a4aa Add missing #endif for the main.cpp fix.
I forgot to amend my previous commit.
2018-02-26 21:02:03 +01:00
3b96b3fd12 Allow running with a custom resource without a main scene
After 3f8a4cc719 trying to run an
individual scene on a project without a main scene fails. We move the
check until after we've determined whether or not we're trying to run an
individual scene.

We also stop trying to show the project manager if any game pack is
found at all, unless the user explicitly asks for the project manager to
be shown.

(cherry picked from commit b4215c991a)
2018-02-26 20:39:48 +01:00
e499b9b4b6 Bump to version 3.0.2-devel 2018-02-26 20:36:43 +01:00
8ea709a7a9 Update the changelog for 3.0.1 2018-02-26 20:35:13 +01:00
f2e19a26f5 Add a project changelog
(cherry picked from commit f00b2dfc55)
2018-02-25 15:32:08 +01:00
be771e7165 Fix version.txt validation logic for export templates .tpz
It assumed that the version would always be `x.y-status`,
with no dot possible in `status`, so:
- It would not work for 3.0.1-stable (nor 3.0.1.stable with new version logic)
- It would not support Mono templates when we provide them

The validation it did was not really useful anyway, so we just use the raw
string.

(cherry picked from commit eec9261a75)
2018-02-25 15:29:28 +01:00
cb65617897 Revert "Bump to version 3.0.2-devel"
This reverts commit bcbe7a8a6f.

Need to push a fix and retag 3.0.1-stable, sorry.
2018-02-25 14:09:38 +01:00
bcbe7a8a6f Bump to version 3.0.2-devel
The start of the next patch release. Wooooooooooo
2018-02-24 20:08:32 +01:00
ae540c2efe Bump version to 3.0.1-stable
Thanks everyone for all your amazing work getting our first stable patch
release out for the 3.0 series. I'd particularly like to thank @fales
and @fire for their work on the server platform.

Onwards to 3.0.2!
2018-02-24 19:21:52 +01:00
5f15642fde Update doc version strings to 3.0.1 2018-02-24 18:59:38 +01:00
17d7084780 Correct version number for 3.0.1 in the manpage 2018-02-24 18:37:01 +01:00
fe38b648b0 [DOCS] clarify that OS.get_user_data_dir needs project name
[ci skip]

(cherry picked from commit 2c22c9dcfb)
2018-02-24 18:33:43 +01:00
ad325be5a0 Add --quit option to help output and update manpage
(cherry picked from commit 95b8984d5f)
2018-02-24 18:32:22 +01:00
d69d58deea Fix Windows file case changing
Windows APIs don't really provide a way to change a filename case. This
implements a little juggling to make this work. We first create a
guaranteed unique temporary file, we then replace the original file with
the temporary file and we finally rename it to the desired filename
case.
2018-02-24 17:37:07 +01:00
34591f9451 Fixes collisions shape selection
(cherry picked from commit c250a9a9f9)
2018-02-24 10:53:10 +01:00
d79a7a2773 Refactor version macros and fix related bugs
The previous logic with VERSION_MKSTRING was a bit unwieldy, so there were
several places hardcoding their own variant of the version string, potentially
with bugs (e.g. forgetting the patch number when defined).

The new logic defines:

- VERSION_BRANCH, the main 'major.minor' version (e.g. 3.1)
- VERSION_NUMBER, which can be 'major.minor' or 'major.minor.patch',
  depending on whether the latter is defined (e.g. 3.1.4)
- VERSION_FULL_CONFIG, which contains the version status (e.g. stable)
  and the module-specific suffix (e.g. mono)
- VERSION_FULL_BUILD, same as above but with build/reference name
  (e.g. official, custom_build, mageia, etc.)
  Note: Slight change here, as the previous format had the build name
  *before* the module-specific suffix; now it's after
- VERSION_FULL_NAME, same as before, so VERSION_FULL_BUILD prefixed
  with "Godot v" for readability

Bugs fixed thanks to that:

- Export templates version matching now properly takes VERSION_PATCH
  into account by relying on VERSION_FULL_CONFIG.
- ClassDB hash no longer takes the build name into account, but limits
  itself to VERSION_FULL_CONFIG (build name is cosmetic, not relevant
  for the API hash).
- Docs XML no longer hardcode the VERSION_STATUS, this was annoying.
- Small cleanup in Windows .rc file thanks to new macros.

(cherry picked from commit 23ebae01dc)
2018-02-24 01:34:34 +01:00
05fec82f31 Merge pull request #16934 from anakimluke/fix_space_around_args
Removed whitespaces around arguments of functions.
2018-02-24 01:32:59 +01:00
370f84f41c Removed whitespaces around arguments of functions.
Functions automatically generated by conneting
signals via GUI put whitespaces around the
arguments of the generated function. This is
inconsistent with the style guide.

This commit fixes that.
2018-02-22 19:41:37 -03:00
689dfcd9ec server: Add support for statically linking libgcc and libstdc++
(cherry picked from commit be7bfdfac3)
2018-02-22 19:06:36 +01:00
46b594054c doc: Sync classref with current source 2018-02-22 19:02:37 +01:00
07e2461995 i18n: Sync translation templates with current source 2018-02-22 18:47:07 +01:00
ca5f3b9f8d i18n: Sync translations with Weblate
(cherry picked from commit 661ab3c88e)
2018-02-22 18:42:25 +01:00
3d804778fd Fix quotation in string
fix for #16404

(cherry picked from commit f38e819fc1)
2018-02-22 13:23:44 +01:00
3e8c214a19 Delete all selected lines using the delete line shortcut in script editor
(cherry picked from commit 7368978a48)
2018-02-22 13:09:02 +01:00
e9d8dfbf0e Ignore tools CLI flags in non-tools builds.
Some flags were still parsed but either did nothing or broke everything.

No reason to parse them.

(cherry picked from commit dd19826277)
2018-02-22 13:08:03 +01:00
3687faa78f Enforce insert_final_newline in the editorconfig.
(cherry picked from commit 6861886f70)
2018-02-22 13:06:25 +01:00
eacd66e784 Clean up some bad words from code comments
(cherry picked from commit d35e486228)
2018-02-22 12:22:41 +01:00
b5f8c1a53b Fix timer second not zero padded when < 10
Also RTR "Time Left:"

(cherry picked from commit d2e3607fa0)
2018-02-22 12:20:23 +01:00
f04cd405ac Fix loading project.binary from PCK file
Regression introduced in #16825.
My logic was correct, but not the error code I was expecting.
The error reporting in FileAccess likely needs a review too.

(cherry picked from commit 57d562b394)
2018-02-22 12:19:43 +01:00
f55b376d78 Improve error reporting of ProjectSettings::setup()
And use it to better report errors in the console and project manager
when a project.godot file is corrupted.

Fixes #14963.

(cherry picked from commit 7839076f95)
2018-02-22 12:19:28 +01:00
fdac09a0aa Made the Debugger's Stack Frames items reselectable.
(cherry picked from commit 32e3f257ac)
2018-02-22 12:18:45 +01:00
751806b5c7 Fix typos with codespell
Found via `codespell -q 3 --skip="./thirdparty,./editor/translations" -I ../godot-word-whitelist.txt`
Whitelist consists of:
```
ang
doubleclick
lod
nd
que
te
unselect
```

(cherry picked from commit 612ab4bbc6)
2018-02-22 12:17:06 +01:00
40018e995c Color:fix setting V switch S to old V value
(cherry picked from commit f4f92b55e1)
2018-02-22 12:07:07 +01:00
be6323d848 Added documentation for VehicleBody
(cherry picked from commit 234b86e6b2)
2018-02-22 12:03:10 +01:00
29089b715d Insert proper copy icon to debugger
(cherry picked from commit db2a1544c0)
2018-02-22 12:02:41 +01:00
7e89cc46dd Icons update
includes new enum, MeshInstance2D, Skeleton2D, Cut, Copy and Paste icons.

(cherry picked from commit cecf274364)
2018-02-22 12:02:02 +01:00
a86829211a Added missing shader functions
(cherry picked from commit 8f04a13c98)
2018-02-22 00:02:52 +01:00
f01821b60a Force controls to save rect_clip_content since they do not all default to false.
(cherry picked from commit cc902cf9ab)
2018-02-22 00:01:33 +01:00
245c11be08 Change function signature from float to double to match type get_doubleCloses #16160
(cherry picked from commit d2f1c87063)
2018-02-21 23:59:15 +01:00
fa98637aca Fixes wrong vertical font layout in RichTextLabel
(cherry picked from commit 77b1320fb4)
2018-02-21 23:52:49 +01:00
Ian
723613dbc3 TextEdit folding over unindented comments
(cherry picked from commit d327f75392)
2018-02-21 23:51:45 +01:00
99efa7ce62 Revert "Fix wrong return type of xform functions"
As this will change bindings API this will have to wait for 3.1

This reverts commit 187c40d64d.
2018-02-21 23:47:04 +01:00
c7040f3218 Fixed sky reflection rendering when transparent BG
(cherry picked from commit c34f18acce)
2018-02-21 23:40:59 +01:00
5975b44ded Fixes gravity calculation for kinematic bodies in Bullet
(cherry picked from commit 5fb8a6a6c2)
2018-02-21 23:38:30 +01:00
8efb9c8cdd Actually fix the db/dc renaming mess
Local builds save lives :)
2018-02-21 23:21:21 +01:00
75289b4017 revert the renaming _tree_db_selected function 2018-02-21 22:57:50 +01:00
ccf27376a6 Update warning about C# support
(cherry picked from commit 24cf4fe062)
2018-02-21 22:55:46 +01:00
23b9f09c58 Fixed "Open" button being enabled when nothing is selected in a FileDialog while in "Open folder" mode.
(cherry picked from commit db80d56388)
2018-02-21 22:23:24 +01:00
e1fc7776f6 gltf: improve embedded data discovery
Some editors seems to use the image resource's mime type (e.g. "image/png") for data embedded uris instead of "application/octet-stream".

(cherry picked from commit 1abf464b59)
2018-02-21 22:17:09 +01:00
c6a96fc360 Enable snapping when control key pressed
(cherry picked from commit 24c170555d)
2018-02-21 22:16:20 +01:00
Max
4383fae5a4 Fixed disappearing text on filedialog buttons
(cherry picked from commit 6a48f952ca)
2018-02-21 22:15:05 +01:00
9cfcf102a0 [Mono] Fixed "expression did not evaluate to a constant" compiler error for visual studio.
(cherry picked from commit 72fe70272d)
2018-02-21 22:12:57 +01:00
8dc946c89c Fix a rendering bug with screen_texture
(cherry picked from commit ea57a19b34)
2018-02-21 22:11:47 +01:00
327fea741a using TIME in light shader enables uses_fragment_time
The GLES3 shader compiler performs certain checks to enable or disable
the usage of certain uniform variables (and with that the set-up of UBOs).

If the `TIME` variable gets used inside the `vertex` function then the
renderer knows that it has to insert that value into the UBO.
The same applies to the `fragment` function.

The `light` function gets executed inside the fragment shader for every
light source that is relevant to the current pixel. If the `TIME` variable
gets used in that function then it needs to be present in the fragment-UBO.
The check for this was missing, so if a shader uses `TIME` inside `light`
but not inside `fragment` then the uniform will not actually be set up.

(cherry picked from commit bb655856e2)
2018-02-21 22:10:28 +01:00
317cb336eb Keep to show current script when closing all docs
also fix error when removing multiple tabs from TabContainer at same frame.
like closing multiple docs at once.

Fix #16403

(cherry picked from commit df84290a7e)
2018-02-21 22:09:23 +01:00
83b76a8171 Added an auto quit and auto build flag to the command line options.
(cherry picked from commit 4bfb504c2f)
2018-02-21 21:56:37 +01:00
70b082c0d9 Create and return LightmapCapture.
(cherry picked from commit 2e66730061)
2018-02-21 21:49:16 +01:00
bbfec2a7cc Add dummy audio driver, fix dummy rasterizer
(cherry picked from commit 4e1923a931)
2018-02-21 21:49:10 +01:00
8849377f6d Fixes to OS_Server and DummyRasterizer to match new signatures
(cherry picked from commit 2de10aa467)
2018-02-21 21:48:58 +01:00
149ffcb1a4 server platform now compiles and run on linux.
Seems to also be able to do exports of some demos I tried.

(cherry picked from commit 6784d743f7)
2018-02-21 21:48:46 +01:00
fb4a784319 Add dummy Texture handling
(cherry picked from commit 72ef766dfa)
2018-02-21 21:48:33 +01:00
8f231d82bb Disable GLES builders and source from server compilation
(cherry picked from commit 8699f643c9)
2018-02-21 21:48:21 +01:00
cc280545dc Add dummy resterizer driver
(cherry picked from commit c0dce6e480)
2018-02-21 21:47:38 +01:00
fa02b58b46 Remove unused variable from plugin settings update
Fix #16199

(cherry picked from commit 9f0cce840d)
2018-02-19 23:15:56 +01:00
000caef623 Fixing folder/file case sensitive renaming issue
Example:
Could not rename "Objects" to "objects" or vice versa

(cherry picked from commit e790ca084d)
2018-02-19 22:47:39 +01:00
b7faa76485 fix spurious error messages during autocomplete and validate
_parse() caused resets on members like validating and
for_completion by calling clear().

(cherry picked from commit 48c9ed4545)
2018-02-19 22:46:49 +01:00
a76dfe9c72 Fix 2d collision body update on shape remove
(cherry picked from commit 3659df6624)
2018-02-19 22:43:33 +01:00
a423adbee6 Flush HTTPClient response data only on request/close in HTML5 platform
(cherry picked from commit 98039909f2)
2018-02-19 22:42:38 +01:00
c5b5fd61d4 Warn when polling HTTPClient synchronously in HTML5 platform
(cherry picked from commit ca9fa9cca8)
2018-02-19 22:42:31 +01:00
5bb269d01d Disable insecure HTTP methods CONNECT and TRACE in HTML5 platform
(cherry picked from commit 2cd7bc04ea)
2018-02-19 22:42:22 +01:00
d5535d9357 Fix HTML5 HTTPClient response header retrieval
(cherry picked from commit 8a21f27f54)
2018-02-19 22:42:08 +01:00
2714b851bf Fix HTML5 HTTPClient failure detection
(cherry picked from commit 9ea4452d21)
2018-02-19 22:42:01 +01:00
2abbdcaa20 Mono: Fix build status icons
(cherry picked from commit 8bd05f0c71)
2018-02-19 22:40:21 +01:00
9cba5ef772 implement signal related methods in csharp_script so signals can be used with emit
(cherry picked from commit cfbd7fd21e)
2018-02-19 22:39:51 +01:00
416cd9c8b8 add a [Signal] attribute to CSharpScripts
(cherry picked from commit efd52cd172)
2018-02-19 22:39:44 +01:00
7a20495a80 Direct to InputEventJoypadButton for using buttons
(cherry picked from commit 6af7dafd6c)
2018-02-19 22:37:09 +01:00
bafbd73b51 Remove window decorations for fullscreen on X11
(cherry picked from commit 935a99e758)
2018-02-19 22:36:20 +01:00
ac6811c4fa Gridmap editor now lists plane instead of floor when not horizontal.
Instead of gridmap editor calling grid as floor irrespective of the
orientation, it now calls the grid plane if it's vertical and floor
if horizontal.

Resolves: #14611
(cherry picked from commit 7c356a9c05)
2018-02-19 22:34:16 +01:00
8372a404bb X11: Link libgcc statically with use_static_cpp option
We were already linking libstdc++ statically for official binaries,
protecting us against most portability issues. But apparently since
we started using GCC 7 for official builds, we also need to link
libgcc statically for at least 32-bit builds to be portable.

Fixes #16409.

(cherry picked from commit b526088ae2)
2018-02-19 22:33:29 +01:00
5b04dcfabd Update CA certificates to latest Mozilla bundle
Copied from an up-to-date Fedora 27 install (ca-certificates-2018.2.22-1.0.fc27).

(cherry picked from commit 294af5617a)
2018-02-19 22:32:53 +01:00
4b581104e7 Makes project manager never initialize mono debug.
The heuristic whether we're in the project manager inside GDMono
didn't work if the project manager was launched by not having any path
to run.

This is fixed now by making a Main::is_project_manager().

(cherry picked from commit 1099838079)
2018-02-19 22:32:17 +01:00
f49601a934 Give C# NodePath a ToString().
It already had an implicit cast operator to string,
but this doesn't get used in say string formatting.

So now something like $"path: {GetPath()}" works.

(cherry picked from commit 3c1f8efd9e)
2018-02-19 22:31:33 +01:00
3e6ab9f3d5 Makes NodePath and RID follow PascalCase in C#.
Fixes #15685

(cherry picked from commit b1a81374d4)
2018-02-19 22:30:45 +01:00
9f9731da3a fix crash autotile edit mode
(cherry picked from commit cceb176be3)
2018-02-19 22:30:13 +01:00
18735ff6f2 Fixes OptionButton selection index being reset to zero at instanciation
Bug: engine tries to set selected item before items were added during save scene/run project, because of wrong properties order.
Fixes #10213.

(cherry picked from commit 66c39b1426)
2018-02-19 22:29:36 +01:00
237cf72f89 Made modifications to the RigidBody(2D) descriptions.
(cherry picked from commit 50e6b3c005)
2018-02-19 22:28:47 +01:00
5c2b2ca95b Documentation tool does not add escapes to code and codeblocks
Instead of adding the escapes to all * and _ the tool now excludes
the characters inside [code] and [codeblock].

Resolves: #15156
(cherry picked from commit 84e8c49f5d)
2018-02-19 22:28:03 +01:00
57f707f951 Add locale renames for Hebrew and Indonesian on Windows
Windows does not fully respect ISO 639-1 like other systems,
so we have to override its locale values for those languages.

Also added comments to document the locale provenance.

(cherry picked from commit 0c7bed45c4)
2018-02-19 22:27:19 +01:00
2f87e7ffe9 option to disable sort in script list
(cherry picked from commit e1778fb921)
2018-02-19 22:26:29 +01:00
12da8dcdeb PEP3101 applied with changing old type string formatting as new ones
(cherry picked from commit 78dba05fc0)
2018-02-19 22:25:41 +01:00
c5388fb0cf Fix for a possible compile error under OS X
(cherry picked from commit 621d28adef)
2018-02-19 22:24:57 +01:00
02e910275c Fixed small typos in the SConstruct file.
(cherry picked from commit b92c5669de)
2018-02-19 22:23:38 +01:00
285f47f037 Added return true o collide when no rusult is NULL
(cherry picked from commit f48845428d)
2018-02-19 22:21:58 +01:00
9fb843db06 Added "allow_reselect" property to ItemList and enabled it for the method/help lists.
(cherry picked from commit 4dbf6ac1b8)
2018-02-19 22:21:14 +01:00
4bdcee2b9d [X11] Improving error detection in move_to_trash
(cherry picked from commit 268d7c7c5b)
2018-02-19 22:20:06 +01:00
fd033473c7 Fix broken APK expansion due to missed option renames
Command line options were refactored for 3.0 to follow the common usage
of double-dashed long options, but `--main-pack` went through the cracks.

Fixes #16533.

(cherry picked from commit e3658a6464)
2018-02-19 22:19:08 +01:00
a39930c5b9 Add a function to remove controls from containers
Closes #5968

(cherry picked from commit da69a06253)
2018-02-19 22:18:22 +01:00
c94d8e6577 Fix #16543 (add button to copy error from debugger)
(cherry picked from commit b169b16f98)
2018-02-19 22:17:26 +01:00
eb5e5200cc Fix infinite recursion with editor import plugins
(cherry picked from commit 95f7879923)
2018-02-19 22:16:33 +01:00
d54ac732ae Expose priority and order for custom import plugins
(cherry picked from commit c68948fdfa)
2018-02-19 22:16:13 +01:00
62fcd772be Add Xbox One Elite and Xbox 360 Afterglow pads
(cherry picked from commit ae579a256e)
2018-02-19 22:15:05 +01:00
150423203b Added OS::center_window to center the window precisely on desktop platforms
(cherry picked from commit ea1d726a46)
2018-02-19 22:14:05 +01:00
ef60123938 Add import option "scale_mesh" to obj file importer
The new import option "scale_mesh" allows setting a scale that is applied to the mesh's vertices during import.

(cherry picked from commit 291c1d0f45)
2018-02-19 22:13:46 +01:00
0d03b5f162 Add and use mono build variables with cloned environment.
(cherry picked from commit 70d281b946)
2018-02-19 22:13:46 +01:00
148e059940 Fixed members overview not scrolling to correct line
(cherry picked from commit 4d92c5e1c3)
2018-02-19 22:13:46 +01:00
7af43c4ca3 Fix #16479 (deselect text when jumping to function)
(cherry picked from commit 3094e89782)
2018-02-19 22:13:46 +01:00
5b32be4701 Update an outdated method name in error message
set_enable_monitoring -> set_monitoring

(cherry picked from commit 5e8f7c9782)
2018-02-19 22:13:46 +01:00
47b49200b0 Fixed KinematicBody move_and_slide documentation naming
(cherry picked from commit da81d9f843)
2018-02-19 22:13:46 +01:00
a7d7f763d0 Remove debugging prints related to the asset library
(cherry picked from commit 5513e4e1f9)
2018-02-19 22:13:46 +01:00
eda94419df SpinBoxes calculate correctly their width before first redraw.
(cherry picked from commit fe1ca3c6e6)
2018-02-19 22:13:46 +01:00
e6252bda5e download templates to a file using separate thread
(cherry picked from commit b4f1a035e3)
2018-02-19 22:13:46 +01:00
069658f1be Fixed #15082: line edit emits two "text_changed" signals when pasting while text is selected
(cherry picked from commit 9cd3ed4ace)
2018-02-19 22:13:46 +01:00
a0e59a7259 Fix polygon triangulation failure.
The ear clipping algorithm used to triangulate polygons has a slightly too conservative point-in-triangle test which can, in some configurations prevent it from finding a possible tessellation. Relaxing the test by considering that points exactly on edges don't belong the triangle fixes the issue. Changing the semantic of the test is safe because no other code makes use of it. A more detailed explanation can be found in issue #16395.

Fixes #16395.

(cherry picked from commit 91215e1919)
2018-02-19 22:13:46 +01:00
82b9a13e0c Fix timeline track name overlapping keyframe area
(cherry picked from commit 398f5b74e3)
2018-02-19 22:13:46 +01:00
79ef5f92a9 Remove a few debugging prints
(cherry picked from commit 84267915f5)
2018-02-19 22:13:46 +01:00
5d7867082d Always detect and use hiDPI in the project manager if needed
This makes its hiDPI behavior consistent with the editor.

(cherry picked from commit 55a2bffac9)
2018-02-19 22:13:45 +01:00
fda35b3f42 Draw the Camera gizmo more accurately
The Camera gizmo no longer looks twice as wide as it actually is.
This fixes #16399.

(cherry picked from commit 0d7d293889)
2018-02-19 22:13:45 +01:00
a0e9d751a3 Fixed wrong example in JSONParseResult.
(cherry picked from commit 24e87f97c6)
2018-02-19 22:13:45 +01:00
d4a70c6c08 fix buffer write performance on Windows and Unix
(cherry picked from commit 8315aa40cc)
2018-02-19 22:13:45 +01:00
65aa9063c4 Fix spaces and quotes in external editor flags
(cherry picked from commit fb8d2420b5)
2018-02-19 22:13:45 +01:00
9eb546e7ff drop path text at mouse pos
(cherry picked from commit 06965f2770)
2018-02-19 22:13:45 +01:00
f031e2f665 disable scene tree shortcuts when in a textfield
(cherry picked from commit 4e96e04389)
2018-02-19 22:13:45 +01:00
4bed14f69b Gradient: fix wrong property type
(cherry picked from commit 4f9ef96b54)
2018-02-19 22:13:45 +01:00
91692ce72a Fix gradient texture preview
(cherry picked from commit 3ba43ac975)
2018-02-19 22:13:45 +01:00
05e97db6f2 Fix wrong property type for fixed icon size in ItemList
(cherry picked from commit 331cfc1d18)
2018-02-19 22:13:45 +01:00
617bcd1b91 Capitalized "View" menu options.
(cherry picked from commit b507eeddcc)
2018-02-19 22:13:45 +01:00
34d8625d82 Fix pkgconfig detection of mono
(cherry picked from commit 5920bc6f72)
2018-02-19 22:13:45 +01:00
79b931d093 Fix UX with project settings search functionality
(cherry picked from commit e7b98119df)
2018-02-19 22:13:45 +01:00
9173819b71 [Mono] Basis values now marshalled in the correct order.
(cherry picked from commit 0cc4de1f24)
2018-02-19 22:13:45 +01:00
8787850286 Fix gizmo solid box mesh being added twice
(cherry picked from commit d0a2931cd7)
2018-02-19 22:13:45 +01:00
2515d42a14 [DOCS] parse_json: Objects do not keep key order
Document JSON not guaranteeing key order.

(cherry picked from commit 82b8f1729d)
2018-02-19 22:13:44 +01:00
1a9a40fe31 Make parent folder selectable. Fix #16253
(cherry picked from commit 6e1c02b828)
2018-02-19 22:13:44 +01:00
eda3169cd1 Fixes open button not appearing with multiple selection
Fix #16231

(cherry picked from commit 09c277693e)
2018-02-19 22:13:44 +01:00
d7f73031fb Show default values in docs for GDScript built-in functions
(cherry picked from commit dca2ae78dd)
2018-02-19 22:13:44 +01:00
ba36ef5465 3DEditor: fix selecting node in viewport not update inspector
(cherry picked from commit cfac160f9f)
2018-02-19 22:13:44 +01:00
41f9904e71 3DEditor: fix multiple node selection crash the editor
I'm not sure about this fix. This seems to also fixes the weird
selection bug where when selecting node 1 to 3 it focuses on
2nd node.

(cherry picked from commit 25dd1f0681)
2018-02-19 22:13:44 +01:00
a206d3d2fc Fixes a Gridcontainer wrong children fitting with expanded+non-zero minisize
(cherry picked from commit d1f32708b7)
2018-02-19 22:13:44 +01:00
a6ca62ac79 Fixes a bas resizing with SplitContainer
(cherry picked from commit 30e1e42175)
2018-02-19 22:13:44 +01:00
85dedc09a8 Readd VS.sync and VS.draw to keep compatibility
Those are deprecated as VS.force_sync and VS.force_draw do the same and more explicitly,
but we cannot remove them without marking them as deprecated before that.

Fixes issue introduced in #15892.

(cherry picked from commit fd92e571ac)
2018-02-19 22:13:44 +01:00
9e7c3016d1 Added all missing VisualServer bindings
- Added bindings for multimesh, immediate, skeleton, light, reflection probe, gi probe, lightmap, particles, camera, environment, scenario, instance
- Removed draw and sync, were duplicates of force_* equivalents
- Bumped binders max arguments from 11 to 13
- Wrote some wrappers as not all methods were variant-friendly

(cherry picked from commit e415fd05bb)
2018-02-19 22:13:44 +01:00
906cf28dae Improved WASAPI driver so that it always uses the default audio device
(cherry picked from commit d5afcf7ab1)
2018-02-19 22:13:44 +01:00
801b544ee1 Windows: Fix case of imm32 for case-sensitive MinGW build
Fixes #16713.

(cherry picked from commit 4fa8987494)
2018-02-19 22:13:44 +01:00
097f95993f Windows: implement OS.get_unique_id and OS.set_ime_position
(cherry picked from commit 3be04f73f5)
2018-02-19 22:13:39 +01:00
c04d868476 Make KEY_ESCAPE close all output/debugger docks on bottom
(cherry picked from commit 2ae2735a7a)
2018-02-19 21:01:41 +01:00
50674dbe15 Expose 'lightmap_unwrap' method to the scripting engine.
(cherry picked from commit e3fdacdf90)
2018-02-19 20:57:40 +01:00
71607d9198 Fix bug when launching a game with no main scene
Check for a main scene after loading project settings and exit if there's none (except if launching in editor mode).

(cherry picked from commit 3f8a4cc719)
2018-02-19 20:56:54 +01:00
3548f71cc4 Display path to preloaded res + button to open it
(cherry picked from commit b766a849ad)
2018-02-19 20:56:16 +01:00
a1455f6a03 Change 'Build Project' button style in Mono panel
Address #15208

(cherry picked from commit 484f664331)
2018-02-19 20:50:39 +01:00
f64b68d870 Change primitive meshes acccuracy value
(cherry picked from commit b72c9b85d0)
2018-02-19 20:49:41 +01:00
f1d26c1c72 Re-enabled type icons.
(cherry picked from commit f7547a7f28)
2018-02-19 20:48:36 +01:00
7f5fde6459 Select root node if search_box is empty in create_dialog
(cherry picked from commit 586e735125)
2018-02-19 20:47:44 +01:00
611caa06a5 Fixed android arm64v8
(cherry picked from commit 853b1daa49)
2018-02-19 20:46:49 +01:00
3f6e8d70cf Added async and await as C# keywords.
(cherry picked from commit 3dcf0567a1)
2018-02-05 09:33:01 +01:00
40c779fb70 Mono: Remove automatic script multilevel calls
(cherry picked from commit 84437b4864)
2018-02-05 09:32:29 +01:00
532abf228c Fix texture import spelling
(cherry picked from commit d1a471f909)
2018-02-04 20:11:13 +01:00
248fea2a79 Small fixes for the Control description in the docs.
(cherry picked from commit 5e0821e867)
2018-02-04 20:10:45 +01:00
7de47fbabb Fix inconsistencies and typos in argument names
(cherry picked from commit 08d4bfacaf)
2018-02-04 20:10:13 +01:00
62dc7ba82f Expand project root directory on editor start
close #16232
Option for expanding all directories on start up is a bit tricky and buggy.

(cherry picked from commit 127d1241bd)
2018-02-04 20:09:26 +01:00
4a3a597377 Fix an infinite recursion in the Mathf.Decimals method when using floats.
(cherry picked from commit 2109bd3f97)
2018-02-04 20:08:26 +01:00
501880e9ba Hide button tree when file system dock isn't in split mode
(cherry picked from commit bb936b5503)
2018-02-04 20:07:56 +01:00
bd02969263 Errata fix on Image get_format() description
The description of this function seems to be duplicated from the preceding description.

(cherry picked from commit 9d735ffacb)
2018-02-04 20:07:19 +01:00
0fa4325153 Fix TextEdit current line highlight horizontal offset
(cherry picked from commit ba8c5bff69)
2018-02-04 20:06:46 +01:00
acf01c955f Expose a few GraphEdit methods to script languages
(cherry picked from commit b80bc73a17)
2018-02-04 20:05:47 +01:00
0a75a38db4 Add interface for plugins to enable/disable other plugins
(cherry picked from commit 87be0bc110)
2018-02-04 20:05:12 +01:00
845f44b976 ProjectSettings: Disallow adding properties without name.
(cherry picked from commit d664d6e634)
2018-02-04 20:04:31 +01:00
77ee4ced30 AudioEffectReverb: max predelay_feedback to 0.98
(cherry picked from commit 5a26e0786c)
2018-02-04 20:03:16 +01:00
780a7a281b Viewport doc improvements
(cherry picked from commit ffcbb0c358)
2018-02-04 20:02:38 +01:00
5481ece976 Display set_nodelay to GDScript
Pass enabled arg

Rename set_nodelay to set_no_delay

Add description to the method

Change description

(cherry picked from commit 87adf9cfba)
2018-02-04 20:02:04 +01:00
ef49c166f6 Allow focus on disabled buttons
This behavior better matches other gui toolkits. A selected disabled
button still can't be interacted with but it can now be selected. This
seems to be what QT and GTK do also.

This fixes #16131

(cherry picked from commit 713f190a30)
2018-02-04 20:00:23 +01:00
77cc0a023b attemp to fix #15870
(cherry picked from commit 517ff5c8d7)
2018-02-04 19:59:34 +01:00
1036a76bc5 Fix issue 15895, audio streams don't signalling finished after the first one
if the audio player is set to play again due to the order of calls in
_notification. First it emits the signal, and later it disable the internal
processing regardless what the callback did.

Changed to emit the signal at the end to ensure the changes done at callback
remains.

(cherry picked from commit d588fe2740)
2018-02-04 19:56:37 +01:00
e44bef4404 Update DONORS list
[ci skip]

(cherry picked from commit f13d034485)
2018-02-02 10:07:40 +01:00
c77047d6a3 Ability to import .escn files, which is just a .tscn but with forced import.
This works together with the new Blender to Godot exporter.

(cherry picked from commit 1322ca6fb2)
2018-01-31 01:15:00 +01:00
a34afa3820 Implement OS::get_processor_count() for Windows
Current this is hardcoded as '1' for any platform except Unix. The
little is_wow64() dance is required to get correct output on a 32bit
compiled godot running on 64bit Windows according to MSDN.

This code should be UWP safe but I have no way to test that so it's not
implemented for UWP yet.

(cherry picked from commit b4d369c887)
2018-01-30 20:56:53 +01:00
77d27053c3 [macOS] Strip executable when separate_debug_symbols is set to yes
(cherry picked from commit 9ef0315b06)
2018-01-30 20:56:16 +01:00
187c40d64d Fix wrong return type of xform functions
(cherry picked from commit ebe2337515)
2018-01-30 20:55:41 +01:00
e69b30b276 Fix Copy/Paste problems on X11
The target of the TARGETS type should be XA_ATOM and not XA_TARGETS when
requested. Since we are sending a number of ATOMS the size should be set
to the integer size and not the char size.

The size field of the atoms is also the number of atoms and not the size
of the array. This caused some clients to wrongly interpret the data and
read garbage in the X11 packet.

I also add the more modern representation for UTF-8 and clarify the
error message if a client attempts to request a type we don't know
about.

This fixes #10431

(cherry picked from commit fb60f2dbe6)
2018-01-30 20:55:11 +01:00
99e72894a2 Remote debugger send the real instance of WeakRef referenced to
(cherry picked from commit 10f0451cc2)
2018-01-30 20:54:25 +01:00
258119a9cf Expose audio streams get_length()
(cherry picked from commit 8a9f1c2a5d)
2018-01-30 20:53:37 +01:00
3f6694b894 Bump version to 3.0.1-devel
Onwards, but slowly, towards stability. And the stars.
2018-01-30 20:51:06 +01:00
6114 changed files with 722764 additions and 951162 deletions

View File

@ -4,7 +4,7 @@ environment:
HOME: "%HOMEDRIVE%%HOMEPATH%"
PYTHON: C:\Python27
SCONS_CACHE_ROOT: "%HOME%\\scons_cache"
SCONS_CACHE_LIMIT: 1024
SCONS_CACHE_LIMIT: 512
matrix:
- VS: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat
GD_PLATFORM: windows
@ -12,16 +12,13 @@ environment:
TARGET: release_debug
ARCH: amd64
init:
- ps: if ($env:APPVEYOR_REPO_BRANCH -ne "master") { $env:APPVEYOR_CACHE_SKIP_SAVE = "true" }
cache:
- "%SCONS_CACHE_ROOT%"
install:
- SET "PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
- pip install -U wheel # needed for pip install scons to work, otherwise a flag is missing
- pip install scons==3.0.1
- pip install scons
- if defined VS call "%VS%" %ARCH% # if defined - so we can also use mingw
before_build:
@ -29,7 +26,7 @@ before_build:
- python --version
- scons --version
- cl.exe
- set "SCONS_CACHE=%SCONS_CACHE_ROOT%\%APPVEYOR_REPO_BRANCH%"
- SET "SCONS_CACHE=%SCONS_CACHE_ROOT%\master"
build_script:
- scons platform=%GD_PLATFORM% target=%TARGET% tools=%TOOLS% debug_symbols=no verbose=yes progress=no gdnative_wrapper=yes
- scons platform=%GD_PLATFORM% target=%TARGET% tools=%TOOLS% verbose=yes progress=no gdnative_wrapper=yes

View File

@ -116,7 +116,6 @@ Standard: Cpp03
---
### ObjC specific config ###
Language: ObjC
Standard: Cpp03
ObjCBlockIndentWidth: 4
# ObjCSpaceAfterProperty: false
# ObjCSpaceBeforeProtocolList: true

View File

@ -9,7 +9,7 @@ insert_final_newline = true
[*.{cpp,hpp,c,h,mm}]
trim_trailing_whitespace = true
[{*.{py,cs},SCsub}]
[*.py]
indent_style = space
indent_size = 4

1
.gitattributes vendored
View File

@ -9,4 +9,3 @@ drivers/* linguist-vendored
*.py eol=lf
*.hpp eol=lf
*.xml eol=lf
*.natvis eol=lf

18
.gitignore vendored
View File

@ -91,9 +91,6 @@ bld/
*.debug
*.dSYM
# Visual Studio cache/options directory
.vs/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
@ -101,6 +98,9 @@ bld/
# Hints for improving IntelliSense, created together with VS project
cpp.hint
# Visualizers for the VS debugger
*.natvis
#NUNIT
*.VisualState.xml
TestResult.xml
@ -238,7 +238,6 @@ ClientBin/
*.pfx
*.publishsettings
node_modules/
__pycache__/
# KDE
.directory
@ -292,7 +291,6 @@ logo.h
TAGS
!TAGS/
tags
*.tags
!tags/
gtags.files
GTAGS
@ -311,15 +309,5 @@ platform/windows/godot_res.res
/.vs
/.vscode
# Visual Studio Code workspace file
*.code-workspace
# Scons progress indicator
.scons_node_count
# ccls cache (https://github.com/MaskRay/ccls)
.ccls-cache/
# compile commands (https://clang.llvm.org/docs/JSONCompilationDatabase.html)
compile_commands.json

111
.mailmap
View File

@ -1,120 +1,29 @@
Alexander Holland <alexander.holland@live.de>
Alexander Holland <alexander.holland@live.de> <alexander.holland@haw-hamburg.de>
Alexander Holland <alexander.holland@live.de> <AlexHolly>
Andrea Catania <info@andreacatania.com>
Andreas Haas <liu.gam3@gmail.com>
Andreas Haas <liu.gam3@gmail.com> <hinsbart@gmail.com>
Andreas Haas <liu.gam3@gmail.com> <hinsbart@users.noreply.github.com>
Andreas Haas <liu.gam3@gmail.com> <entenflugstuhl@gmail.com>
Anish Bhobe <anishbhobe@hotmail.com>
Anutrix <numaanzaheerahmed@yahoo.com>
Aren Villanueva <arenvillanueva@yomogi-soft.com> <aren@displaysweet.com>
Andreas Haas <Hinsbart@users.noreply.github.com>
Andreas Haas <entenflugstuhl@gmail.com>
Ariel Manzur <ariel@godotengine.org>
Ariel Manzur <ariel@godotengine.org> <punto@godotengine.org>
Ariel Manzur <ariel@godotengine.org> <ariel@okamstudio.com>
Ariel Manzur <ariel@godotengine.org> <punto@Ariels-Mac-mini.local>
Ariel Manzur <ariel@godotengine.org> <punto@Ariels-Mac-mini-2.local>
Ariel Manzur <ariel@okamstudio.com>
Bastiaan Olij <mux213@gmail.com>
Benjamin <mafortion.benjamin@gmail.com>
Bernhard Liebl <Bernhard.Liebl@gmx.org> <poke1024@gmx.de>
Bernhard Liebl <Bernhard.Liebl@gmx.org> <poke1024@gmx.org>
Bruno Lourenço <madequa@users.noreply.github.com> <bmlourenco@gmail.com>
Chaosus <chaosus89@gmail.com>
Chris Bradfield <chris@kidscancode.org> <cb@scribe.net>
Clay John <claynjohn@gmail.com>
Clay John <claynjohn@gmail.com> <clayjohn@shaw.ca>
Dana Olson <dana@shineuponthee.com> <adolson@gmail.com>
dankan1890 <mewuidev2@gmail.com>
Daniel J. Ramirez <djrmuv@gmail.com>
Emmanuel Barroga <emmanuelbarroga@gmail.com>
Erik Selecký <35656626+rxlecky@users.noreply.github.com>
Erik Selecký <35656626+rxlecky@users.noreply.github.com> <35656626+SeleckyErik@users.noreply.github.com>
Fabian <supagu@gmail.com>
Ferenc Arn <tagcup@yahoo.com>
Ferenc Arn <tagcup@yahoo.com> <tagcup@users.noreply.github.com>
Fredia Huya-Kouadio <fhuyakou@gmail.com>
Fredia Huya-Kouadio <fhuyakou@gmail.com> <fhuya@google.com>
Bernhard Liebl <poke1024@gmx.de>
Bernhard Liebl <poke1024@gmx.org>
Geequlim <geequlim@gmail.com>
Gilles Roudiere <gilles.roudiere@gmail.com>
Gilles Roudiere <gilles.roudiere@gmail.com> <gilles.roudiere@laas.fr>
Gordon MacPherson <gordon@gordonite.tech>
Guilherme Felipe <guilhermefelipecgs@gmail.com>
Hanif Bin Ariffin <hanif.ariffin.4326@gmail.com>
Hein-Pieter van Braam-Stewart <hp@tmm.cx>
Hubert Jarosz <marqin.pl@gmail.com>
Hubert Jarosz <marqin.pl@gmail.com> <marqin.pl+git@gmail.com>
Hugo Locurcio <hugo.locurcio@hugo.pro>
Hugo Locurcio <hugo.locurcio@hugo.pro> <hugo.l@openmailbox.org>
Hugo Locurcio <hugo.locurcio@hugo.pro> <Calinou@users.noreply.github.com>
Hugo Locurcio <hugo.locurcio@hugo.pro> Calinou <calinou@opmbx.org>
Ian Bishop <ianb96@gmail.com>
Ignacio Etcheverry <ignalfonsore@gmail.com>
Ignacio Etcheverry <ignalfonsore@gmail.com> <neikeq@users.noreply.github.com>
Ilaria Cislaghi <cislaghi.ilaria@gmail.com>
Ilaria Cislaghi <cislaghi.ilaria@gmail.com> <ilaria.cislaghi@simedis.com>
Indah Sylvia <ISylvox@yahoo.com>
J08nY <johny@neuromancer.sk> <jancar.jj@gmail.com>
J08nY <johny@neuromancer.sk> <J08nY@users.noreply.github.com>
Jakub Grzesik <kubecz3k@gmail.com>
Jérôme Gully <jerome.gully0@gmail.com>
JFonS <joan.fonssanchez@gmail.com>
Juan Linietsky <reduzio@gmail.com>
Juan Linietsky <reduzio@gmail.com> <juan@godotengine.org>
Juan Linietsky <reduzio@gmail.com> <juan@okamstudio.com>
Juan Linietsky <reduzio@gmail.com> <reduz@Juans-MBP.fibertel.com.ar>
Juan Linietsky <reduzio@gmail.com> <red@kyoko>
Juan Linietsky <juan@okamstudio.com>
Juan Linietsky <reduz@Juans-MBP.fibertel.com.ar>
Julian Murgia <the.straton@gmail.com>
Kanabenki <lucien.menassol@gmail.com> <18357657+Kanabenki@users.noreply.github.com>
Kelly Thomas <kelly.thomas@hotmail.com.au>
K. S. Ernest (iFire) Lee <ernest.lee@chibifire.com>
Leon Krause <lk@leonkrause.com> <eska@eska.me>
Leon Krause <lk@leonkrause.com> <eska014@users.noreply.github.com>
Manuel Strey <manuel.strey@gmx.de>
Leon Krause <eska@eska.me>
Leon Krause <eska@eska.me> <eska014@users.noreply.github.com>
Marcelo Fernandez <marcelofg55@gmail.com>
Marcin Zawiejski <dragmz@gmail.com>
Mariano Javier Suligoy <marianognu.easyrpg@gmail.com>
Mario Schlack <m4r10.5ch14ck@gmail.com>
marxin <mliska@suse.cz>
marynate <mary.w.nate@gmail.com> <marynate@github.com>
Max Hilbrunner <m.hilbrunner@gmail.com>
Max Hilbrunner <m.hilbrunner@gmail.com> <mhilbrunner@users.noreply.github.com>
Michael Alexsander <michaelalexsander@protonmail.com>
Nathan Lovato <nathan@gdquest.com>
Nathan Warden <nathan@nathanwarden.com> <nathanwardenlee@icloud.com>
Nils ANDRÉ-CHANG <nils@nilsand.re>
Nils ANDRÉ-CHANG <nils@nilsand.re> <nils.andre.chang@gmail.com>
Nuno Donato <nunodonato@gmail.com> <n.donato@estrelasustentavel.pt>
Pedro J. Estébanez <pedrojrulez@gmail.com> <RandomShaper@users.noreply.github.com>
Paul Batty <p_batty@hotmail.co.uk>
Paul Batty <p_batty@hotmail.co.uk> <Paulb23@users.noreply.github.com>
Pawel Kowal <pkowal1982@gmail.com> <pawel.kowal@javart.eu>
Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
Pieter-Jan Briers <pieterjan.briers+git@gmail.com> <pieterjan.briers@gmail.com>
Poommetee Ketson <poommetee@protonmail.com>
Przemysław Gołąb (n-pigeon) <golab.przemyslaw@gmail.com>
Rafał Mikrut <mikrutrafal54@gmail.com>
Ralf Hölzemer <r.hoelzemer@posteo.de> <rollenrolm@posteo.de>
Ralf Hölzemer <r.hoelzemer@posteo.de> <rollenrolm@users.noreply.github.com>
Ramesh Ravone <ramesh.maran443@gmail.com>
RaphaelHunter <raphael10241024@gmail.com>
RaphaelHunter <raphael10241024@gmail.com> <Raphael10241024@gmail.com>
RaphaelHunter <raphael10241024@gmail.com> <raphael20141024@gmail.com>
Rémi Verschelde <rverschelde@gmail.com> <remi@verschelde.fr>
Rhody Lugo <rhodylugo@gmail.com> <rhodylugo@me.com>
Robin Hübner <profan@prfn.se> <robinhubner@gmail.com>
romulox_x <romulox_x@yahoo.com>
Ruslan Mustakov <r.mustakov@gmail.com> <ruslan.mustakov@xored.com>
Saracen <SaracenOne@gmail.com>
sheepandshepherd <sheepandshepherd@hotmail.com> <sheepandshepherd@users.noreply.github.com>
Swarnim Arun <swarnimarun11@gmail.com>
Theo Hallenius <redsymbzone@hotmail.com>
Thomas Herzog <therzog@mail.de>
Thomas Herzog <therzog@mail.de> <thomas.herzog@mail.com>
Thomas Herzog <therzog@mail.de> <thomas.herzog@simedis.com>
Twarit <wtwarit@gmail.com>
V.VamsiKrishna <vk@bsb.in> <vamsikrishna.v@gmail.com>
Wilhem Barbier <nounoursheureux@openmailbox.org> <wilhem.b@free.fr>
Wilhem Barbier <nounoursheureux@openmailbox.org> <schtroumps31@gmail.com>
Will Nations <willnationsdev@gmail.com>
yg2f <yoann@terminajones.com>
Zak Stam <zakscomputers@hotmail.com>
Zher Huei Lee <lee.zh.92@gmail.com>

View File

@ -1,15 +1,15 @@
language: cpp
# OS config, depends on actual 'os' in build matrix
dist: xenial
dist: trusty
sudo: false
env:
global:
- SCONS_CACHE=$HOME/.scons_cache/$TRAVIS_BRANCH
- SCONS_CACHE=$HOME/.scons_cache
- SCONS_CACHE_LIMIT=1024
- OPTIONS="debug_symbols=no verbose=yes progress=no"
- secure: "uch9QszCgsl1qVbuzY41P7S2hWL2IiNFV4SbAYRCdi0oJ9MIu+pVyrQdpf3+jG4rH6j4Rffl+sN17Zz4dIDDioFL1JwqyCqyCyswR8uACC0Rr8gr4Mi3+HIRbv+2s2P4cIQq41JM8FJe84k9jLEMGCGh69w+ibCWoWs74CokYVA="
- OPTIONS="verbose=yes progress=no gdnative_wrapper=yes"
- secure: "QLFRizqry/Y5pnEZvDlQz5S3YydQ+600u4rHEzFgUTd0heYeQaETXAQeMzp0ymuG1BkdRAl5YJoLVJgAzjwI9hrvugvoUlh2//SfpqZCHN/Q1fYbtGgNTn01R3VFEpcfYQL93I2EjrxVm0WTM4PwCvMO+hU0aWTRDvCt1Lty0kMR+RMDQOO/woqunoXh5wvFNxTJJkAmuLe0v962DJYOIwJAnqMLR0aFYjmeQJ20bc/2X5oLt+WuJDuf/lGj6WSlD6z/o/kL3YxHoUyw4A/HAZ2IX0IfNHKuay60ESWzl/NlobnePiPwHAE2pdDVu//q16fanb9VeYnBYRFse49TpFRb86Lo+Qz8nKDJqpQEIY0YKNCFqekrubqTM++Lj6QvGpykQZNxUhybmELcEsRG4PS0UMvCpebdnJD46nNB+DtO2Lgb4xXDLQwpq19z1wizq/XDQ5hz61TIIx8+i8TsgdSQKCTeWovd4HcD4CVjAD5XTLGgyRmI/zC2d+lTnKo6W9diLq/bX/Goq2QPeaTPABqv817IaJka2JyugQ7Qal/+gNTjYRRsimRCL9B2tVh+Uh8rWhTFhQL4QbP5P65HF+p8qojUzqtAhPMbZ8mxUtNukUI3liVgPgiMss96sG0nTVglFgkkAkEjIMFnqMSKnTfG812K4jIhp2jCO2Q3NeI="
cache:
directories:
@ -23,22 +23,9 @@ matrix:
addons:
apt:
sources:
- llvm-toolchain-xenial-6.0
- llvm-toolchain-trusty-5.0
packages:
- clang-format-6.0
- env: PLATFORM=x11 TOOLS=yes TARGET=debug CACHE_NAME=${PLATFORM}-tools-mono-gcc-8 MATRIX_EVAL="CC=gcc-8 && CXX=g++-8" EXTRA_ARGS="module_mono_enabled=yes mono_glue=no warnings=extra werror=yes"
os: linux
compiler: gcc-8
addons:
apt:
sources:
- mono
- ubuntu-toolchain-r-test
packages:
- &gcc8_deps [gcc-8, g++-8]
- &linux_deps [libasound2-dev, libfreetype6-dev, libgl1-mesa-dev, libglu1-mesa-dev, libx11-dev, libxcursor-dev, libxi-dev, libxinerama-dev, libxrandr-dev]
- &linux_mono_deps [mono-devel, msbuild, nuget]
- clang-format-5.0
coverity_scan:
project:
@ -49,38 +36,40 @@ matrix:
build_command: "scons p=x11 -j2 $OPTIONS"
branch_pattern: coverity_scan
- env: PLATFORM=x11 TOOLS=no TARGET=release CACHE_NAME=${PLATFORM}-clang EXTRA_ARGS="warnings=extra werror=yes"
- env: GODOT_TARGET=x11 TOOLS=yes CACHE_NAME=${GODOT_TARGET}-tools-mono-gcc EXTRA_ARGS="module_mono_enabled=yes mono_glue=no"
os: linux
compiler: clang
addons:
apt:
packages:
- *linux_deps
- env: PLATFORM=android TOOLS=no TARGET=release_debug CACHE_NAME=${PLATFORM}-clang EXTRA_ARGS="warnings=extra werror=yes"
os: linux
compiler: clang
- env: PLATFORM=osx TOOLS=yes TARGET=debug CACHE_NAME=${PLATFORM}-tools-clang
os: osx
compiler: clang
- env: PLATFORM=iphone TOOLS=no TARGET=debug CACHE_NAME=${PLATFORM}-clang
os: osx
compiler: clang
- env: PLATFORM=server TOOLS=yes TARGET=release_debug CACHE_NAME=${PLATFORM}-tools-gcc-8 MATRIX_EVAL="CC=gcc-8 && CXX=g++-8" EXTRA_ARGS="warnings=extra werror=yes"
os: linux
compiler: gcc-8
compiler: gcc
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- mono
packages:
- &linux_deps [libasound2-dev, libfreetype6-dev, libgl1-mesa-dev, libglu1-mesa-dev, libx11-dev, libxcursor-dev, libxi-dev, libxinerama-dev, libxrandr-dev]
- &linux_mono_deps [mono-devel, msbuild]
- env: GODOT_TARGET=x11 TOOLS=no CACHE_NAME=${GODOT_TARGET}-clang
os: linux
compiler: clang
addons:
apt:
packages:
- *gcc8_deps
- *linux_deps
- env: PLATFORM=x11 TOOLS=no TARGET=release_debug CACHE_NAME=${PLATFORM}-gcc-5
- env: GODOT_TARGET=android TOOLS=no CACHE_NAME=${GODOT_TARGET}-clang
os: linux
compiler: clang
- env: GODOT_TARGET=osx TOOLS=yes CACHE_NAME=${GODOT_TARGET}-tools-clang
os: osx
osx_image: xcode9.3
compiler: clang
- env: GODOT_TARGET=iphone TOOLS=no CACHE_NAME=${GODOT_TARGET}-clang
os: osx
osx_image: xcode9.3
compiler: clang
- env: GODOT_TARGET=server TOOLS=yes CACHE_NAME=${GODOT_TARGET}-tools-gcc
os: linux
compiler: gcc
addons:
@ -89,25 +78,23 @@ matrix:
- *linux_deps
before_install:
- eval "${MATRIX_EVAL}"
- if [ "$STATIC_CHECKS" = "yes" ]; then
unset SCONS_CACHE;
fi
install:
- pip install --user scons;
- if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$PLATFORM" = "android" ]; then
- if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$GODOT_TARGET" = "android" ]; then
misc/travis/android-tools-linux.sh;
fi
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then
export PATH=${PATH}:/Users/travis/Library/Python/2.7/bin;
misc/travis/scons-local-osx.sh;
fi
- if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$PLATFORM" = "android" ]; then
- if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$GODOT_TARGET" = "android" ]; then
misc/travis/android-tools-osx.sh;
fi
before_script:
- if [ "$PLATFORM" = "android" ]; then
- if [ "$GODOT_TARGET" = "android" ]; then
export ANDROID_HOME=$TRAVIS_BUILD_DIR/godot-dev/build-tools/android-sdk;
export ANDROID_NDK_ROOT=$TRAVIS_BUILD_DIR/godot-dev/build-tools/android-ndk;
fi
@ -116,5 +103,5 @@ script:
- if [ "$STATIC_CHECKS" = "yes" ]; then
sh ./misc/travis/clang-format.sh;
else
scons -j2 CC=$CC CXX=$CXX platform=$PLATFORM tools=$TOOLS target=$TARGET $OPTIONS $EXTRA_ARGS;
scons -j2 CC=$CC CXX=$CXX platform=$GODOT_TARGET TOOLS=$TOOLS $EXTRA_ARGS $OPTIONS;
fi

View File

@ -25,77 +25,51 @@ name is available.
## Developers
(in alphabetical order, with over 10 commits excluding merges)
(in alphabetical order, with 10 commits or more excluding merges)
Aaron Franke (aaronfranke)
Alexander Holland (AlexHolly)
Alexey Khoroshavin (allkhor)
Alexey Velikiy (jonyrock)
Alket Rexhepi (alketii)
Andrea Catania (AndreaCatania)
Andreas Haas (Hinsbart)
Andrii Doroshenko (Xrayez)
Andy Moss (MillionOstrich)
Anish Bhobe (KidRigger)
Anton Yabchinskiy (a12n)
Anutrix
Aren Villanueva (kurikaesu)
Ariel Manzur (punto-)
Bastiaan Olij (BastiaanOlij)
Ben Brookshire (sheepandshepherd)
Benjamin Larsson (Nallebeorn)
Benjamin (Nallebeorn)
Bernard Liebl (poke1024)
Błażej Szczygieł (zaps166)
Bojidar Marinov (bojidar-bg)
Bruno Lourenço (MadEqua)
bruvzg
Cameron Reikes (creikey)
Camille Mohr-Daurat (pouleyKetchoupp)
Carl Olsson (not-surt)
Carter Anderson (cart)
Chris Bradfield (cbscribe)
Clay John (clayjohn)
Dana Olson (adolson)
Daniel J. Ramirez (djrm)
Daniel Rakos (aqnuep)
dankan1890
David Sichma (DavidSichma)
Dharkael (lupoDharkael)
Dmitry Koteroff (Krakean)
DualMatrix
Emmanuel Barroga (codecustard)
Emmanuel Leblond (touilleMan)
Eoin O'Neill (Eoin-ONeill-Yokai)
Eric Lasota (elasota)
Eric Rybicki (ericrybick)
Erik Selecký (rxlecky)
est31
Fabian Mathews (supagu)
Fabio Alessandrelli (Faless)
Ferenc Arn (tagcup)
Franklin Sobrinho (TheHX)
Fredia Huya-Kouadio (m4gr3d)
Geequlim
Gen (dbsGen)
George Marques (vnen)
Gerrit Großkopf (Grosskopf)
Gilles Roudiere (groud)
Gordon MacPherson (RevoluPowered)
Guilherme Felipe de C. G. da Silva (guilhermefelipecgs)
Hanif Bin Ariffin (hbina)
Haoyu Qiu (timothyqiu)
Hein-Pieter van Braam-Stewart (hpvb)
Hein-Pieter van Braam (hpvb)
Hiroshi Ogawa (hi-ogawa)
homer666
Hubert Jarosz (Marqin)
Hugo Locurcio (Calinou)
Ian Bishop (ianb96)
Ibrahn Sahir (ibrahn)
Ignacio Etcheverry (neikeq)
Ilaria Cislaghi (QbieShay)
Indah Sylvia (ISylvox)
J08nY
Jakub Grzesik (kubecz3k)
Jérôme Gully (Nutriz)
Joan Fons Sanchez (JFonS)
Jérôme GULLY (Nutriz)
JFonS
Johan Manuel (29jm)
Joshua Grams (JoshuaGrams)
Juan Linietsky (reduz)
@ -103,66 +77,45 @@ name is available.
Justo Delgado (mrcdk)
Kelly Thomas (KellyThomas)
Kostadin Damyanov (Max-Might)
K. S. Ernest (iFire) Lee (fire)
Leon Krause (eska014)
Lucien Menassol (Kanabenki)
m4nu3lf
Marcel Admiraal (madmiraal)
Marcelo Fernandez (marcelofg55)
Marc Gilleron (Zylann)
Marcin Zawiejski (dragmz)
Mariano Javier Suligoy (MarianoGnu)
Mario Schlack (hurikhan)
Martin Capitanio (capnm)
Martin Liška (marxin)
Martin Sjursen (binbitten)
marynate
Masoud BH (masoudbh3)
Matthias Hölzl (hoelzl)
Max Hilbrunner (mhilbrunner)
merumelu
Michael Alexsander (YeldhamDev)
MichiRecRoom (LikeLakers2)
Michael Alexsander Silva Dias (YeldhamDev)
mrezai
muiroc
Nathan Warden (NathanWarden)
Nils André-Chang (NilsIrl)
Nuno Donato (nunodonato)
Ovnuniarchos
Pascal Richter (ShyRed)
Patrick (firefly2442)
Paul Batty (Paulb23)
Paul Joannon (paulloz)
Paul Trojahn (ptrojahn)
Pawel Kowal (pkowal1982)
Pedro J. Estébanez (RandomShaper)
Pieter-Jan Briers (PJB3005)
Poommetee Ketson (Noshyaar)
Przemysław Gołąb (n-pigeon)
Rafał Mikrut (qarmin)
Ralf Hölzemer (rollenrolm)
Ramesh Ravone (RameshRavone)
raphael10241024
Ray Koopa (RayKoopa)
Rémi Verschelde (akien-mga)
Rhody Lugo (rraallvv)
Roberto F. Arroyo (robfram)
Robin Hübner (profan)
romulox-x
rraallvv
Ruslan Mustakov (endragor)
Saniko (sanikoyes)
santouits
SaracenOne
sersoong
Shiqing (kawa-yoiko)
Simon Wenner (swenner)
Swarnim Arun (minraws)
Theo Hallenius (TheoXD)
Thomas Herzog (karroffel)
Timo Schwarzer (timoschwarzer)
Timo (toger5)
Tomasz Chabora (KoBeWi)
Twarit Waikar (IronicallySerious)
Vinzenz Feenstra (vinzenz)
박한얼 (volzhs)
V. Vamsi Krishna (vkbsb)
@ -171,7 +124,7 @@ name is available.
Wilson E. Alvarez (Rubonnek)
Xavier Cho (mysticfall)
yg2f (SuperUserNameMan)
Yuri Roubinsky (Chaosus)
Zak Stam (zaksnet)
Yuri Roubinski (Chaosus)
Zher Huei Lee (leezh)
ZuBsPaCe
Дмитрий Сальников (DmitriySalnikov)

View File

@ -4,264 +4,151 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
## [3.1] - 2019-03-13
## [3.0.6] - 2018-07-29
### Added
- OpenGL ES 2.0 renderer.
- [Visual shader editor.](https://godotengine.org/article/visual-shader-editor-back)
- New PBR output nodes.
- Conversion between Vector3 and scalar types is now automatic.
- Ability to create custom nodes via scripting.
- Ports can now be previewed.
- [3D soft body physics.](https://godotengine.org/article/soft-body)
- [3D ragdoll system.](https://godotengine.org/article/godot-ragdoll-system)
- [Constructive solid geometry in 3D.](https://godotengine.org/article/godot-gets-csg-support)
- [2D meshes and skeletal deformation.](https://godotengine.org/article/godot-gets-2d-skeletal-deform)
- [Various improvements to KinematicBody2D.](https://godotengine.org/article/godot-31-will-get-many-improvements-kinematicbody)
- Support for snapping the body to the floor.
- Support for RayCast shapes in kinematic bodies.
- Support for synchronizing kinematic movement to physics, avoiding an one-frame delay.
- WebSockets support using [libwebsockets](https://libwebsockets.org/).
- UPnP support using [MiniUPnP](http://miniupnp.free.fr).
- [Revamped inspector.](https://godotengine.org/article/godot-gets-new-inspector)
- Improved visualization and editing of numeric properties.
- Vector and matrix types can now be edited directly (no pop-ups).
- Subresources can now be edited directly within the same inspector.
- Layer names can now be displayed in the inspector.
- Proper editing of arrays and dictionaries.
- Ability to reset any property to its default value.
- [Improved animation editor.](https://godotengine.org/article/godot-gets-brand-new-animation-editor-cinematic-support)
- Simpler, less cluttered layout.
- New Bezier, Audio and Animation tracks.
- Several key types can be previewed directly in the track editor.
- Tracks can now be grouped and filtered on a per-node basis.
- Copying and pasting tracks between animations is now possible.
- New Capture mode to blend from a node's current value to the first key in a track.
- [Improved animation tree and new state machine.](https://godotengine.org/article/godot-gets-new-animation-tree-state-machine)
- More visual feedback in the blend tree editor.
- 1D and 2D blend spaces are now supported.
- Ability to write custom blending logic.
- Support for root motion.
- [New FileSystem dock.](https://godotengine.org/article/godot-gets-new-filesystem-dock-3-1)
- Unified view of folders and files in the same panel.
- Files can now be marked as favorites, not only folders.
- Files now have icons representing their type, or thumbnail previews when relevant.
- New search field to filter entries in the tree.
- [OpenSimplexNoise and NoiseTexture resources.](https://godotengine.org/article/simplex-noise-lands-godot-31)
- [Optional static typing in GDScript.](https://godotengine.org/article/optional-typing-gdscript)
- Does not currently improve performance, but helps write more robust code.
- Warning system in GDScript.
- Reports potential code issues such as:
- unused variables,
- standalone expressions,
- discarded return values from functions,
- unreachable code after a `return` statement,
-
- Warnings can be disabled in the Project Settings or by writing special comments.
- [GDScript keyword `class_name` to register scripts as classes.](http://docs.godotengine.org/en/latest/getting_started/step_by_step/scripting_continued.html#register-scripts-as-classes)
- Simple expression language independent from GDScript, used by inspector boxes that accept numeric values.
- Can also be used in projects.
- C# projects can now be exported for Windows, Linux, and macOS targets.
- The `server` platform is back as it was in Godot 2.1.
- It is now again possible to run a headless Godot instance on Linux.
- Support for BPTC texture compression on desktop platforms.
- New properties for SpatialMaterial.
- Dithering-based distance fade, for fading materials without making them transparent.
- Disable ambient light on a per-material basis.
- Option to link Mono statically on Windows.
- Unified class and reference search in the editor.
- Revamped TileSet editor with support for undo/redo operations.
- Various quality-of-life improvements to the Polygon2D and TextureRegion editors.
- RandomNumberGenerator class that allows for multiple instances at once.
- Array methods `min()` and `max()` to return the smallest and largest value respectively.
- Dictionary method `get(key[, default])` where `default` is returned if the key does not exist.
- Node method `print_tree_pretty()` to print a graphical view of the scene tree.
- String methods `trim_prefix()`, `trim_suffix()`, `lstrip()`, `rstrip()`.
- OS methods:
- `get_system_time_msecs()`: Return the system time with milliseconds.
- `get_audio_driver_name()` and `get_audio_driver_count()` to query audio driver information.
- `get_video_driver_count()` and `get_video_driver_name()` to query renderer information.
- `center_window()`: Center the window on the screen.
- `move_window_to_foreground()`: Move the window to the foreground.
- StreamPeerTCP method `set_no_delay()` to enable the `TCP_NODELAY` option.
- EditorPlugin method `remove_control_from_container()`.
- Ability to set Godot windows as "always on top".
- Ability to create windows with per-pixel transparency.
- New GLSL built-in functions in the shader language:
- `radians()`
- `degrees()`
- `asinh()`
- `acosh()`
- `atanh()`
- `exp2()`
- `log2()`
- `roundEven()`
- New command-line options:
- `--build-solutions`: Build C# solutions without starting the editor.
- `--print-fps`: Display frames per second to standard output.
- `--quit`: Quit the engine after the first main loop iteration.
- Debugger button to copy error messages.
- Support for `.escn` scenes has been added for use with the new Blender exporter.
- It is now possible to scale an OBJ mesh when importing.
- `popup_closed` signal for `ColorPickerButton`.
- Methods that are deprecated can now print warnings.
- Input actions can now provide an analog value.
- Input actions can now be mapped to either a specific device or all devices.
- DNS resolution for high-level networking.
- Servers can now kick/disconnect peers in high-level networking.
- Servers can now access IP and port information of peers in high-level networking.
- High-level multiplayer API decoupled from SceneTree (see `SceneTree.multiplayer_api`/`SceneTree.custom_multiplayer_api`), can now be extended.
- `Input.set_default_cursor_shape()` to change the default shape in the viewport.
- Custom cursors can now be as large as 256×256 (needed to be exactly 32×32 before).
- Support for radio-looking items with icon in `PopupMenu`s.
- Drag and drop to rearrange Editor docks.
- TileSet's `TileMode` is now exposed to GDScript.
- `OS.get_ticks_usec()` is now exposed to GDScript.
- Normals can now be flipped when generated via `SurfaceTool`.
- TextureProgress bars can now be bilinear (extending in both directions).
- The character used for masking secrets in LineEdit can now be changed.
- Improved DynamicFont:
- DynamicFonts can now use high-quality outlines generated by FreeType.
- DynamicFonts can now have their anti-aliasing disabled.
- DynamicFonts can now have their hinting tweaked ("Normal", "Light" or "None").
- Colored glyphs such as emoji are now supported.
- Universal translation of touch input to mouse input.
- AudioStreamPlayer, AudioStreamPlayer2D, and AudioStreamPlayer3D now have a pitch scale property.
- Support for MIDI input.
- Support for audio capture from microphones.
- `GROW_DIRECTION_BOTH` for Controls.
- Selected tiles can be moved in the tile map editor.
- The editor can now be configured to display the project window on the previous or next monitor (relative to the editor).
- If either end is reached, then the project will start on the last or first monitor (respectively).
- Signal in VideoPlayer to notify when the video finished playing.
- `Image.bumpmap_to_normalmap()` to convert bump maps to normal maps.
- `File.get_path()` and `File.get_path_absolute()`.
- Unselected tabs in the editor now have a subtle background for easier identification.
- The depth fog's end distance is now configurable independently of the far plane distance.
- The alpha component of the fog color can now be used to control fog density.
- The 3D editor's information panel now displays the camera's coordinates.
- New options to hide the origin and viewport in the 2D editor.
- Improved 3D editor grid:
- The grid size and number of subdivisions can now be configured.
- Its primary and secondary colors can now also be changed.
- <kbd>Ctrl</kbd> now toggles snapping in the 3D viewport.
- Find & replace in files (<kbd>Ctrl + Shift + F</kbd> by default).
- Batch node renaming tool (<kbd>Ctrl + F2</kbd> by default).
- More editor scaling options to support HiDPI displays.
- Type icons can now be enabled in the editor again.
- Buttons in the editor to open common directories in the OS file manager:
- project data directory,
- user data directory,
- user settings directory.
- Projects can now be sorted by name or modification date in the project manager.
- Projects can now be imported from ZIP archives in the project manager.
- Improved autocompletion.
- Keywords are now present in autocompletion results.
- `editor` and `standalone` feature tags to check whether the project is running from an editor or non-editor binary.
- `android_add_asset_dir("...")` method to Android module Gradle build configuration.
- **iOS:** Support for exporting to the iPhone X.
- **iOS:** Readded support for in-app purchases.
### Changed
- [Built-in vector types now use copy-on-write mode as originally intended](https://godotengine.org/article/why-we-broke-your-pr), resulting in increased engine performance.
- The [mbedtls](https://tls.mbed.org/) library is now used instead of OpenSSL.
- [Renamed several core files](https://github.com/godotengine/godot/pull/25821).
- Third-party modules may have to be updated to reflect this.
- SSL certificates are now bundled in exported projects unless a custom bundle is specified.
- Improved buffer writing performance on Windows and Linux.
- Removed many debugging prints in the console.
- Export templates now display an error dialog if no project was found when starting.
- DynamicFont oversampling is now enabled by default.
- Nodes' internal logic now consistently use internal physics processing.
- Allow attaching and clearing scripts on multiple nodes at once.
- Default values are no longer saved in scene and resource files.
- The selection rectangle of 2D nodes is now hidden when not pertinent (no more rectangle for collision shapes).
- SSE2 is now enabled in libsquish, resulting in improved S3TC encoding performance.
- Tangent and binormal coordinates are now more consistent across mesh types (primitive/imported), resulting in more predictable normal map and depth map appearance.
- Better defaults for 3D scenes.
- The default procedural sky now has a more neutral blue tone.
- The default SpatialMaterial now has a roughness value of 1 and metallic value of 0.
- The fallback material now uses the same values as the default SpatialMaterial.
- Text editor themes are now sorted alphabetically in the selection dropdown.
- The 3D manipulator gizmo now has a smoother, more detailed appearance.
- The 3D viewport menu button now has a background to make it easier to read.
- QuadMeshes are now built using two triangles (6 vertices) instead of one quad (4 vertices).
- This was done because quads are deprecated in OpenGL.
- Controls inside containers are no longer movable or resizable but can still be selected.
- The `is` GDScript keyword can now be used to compare a value against built-in types.
- Exported variables with type hints are now always initialized.
- For example, `export(int) var a` will be initialized to `0`.
- Named enums in GDScript no longer create script constants.
- This means `enum Name { VALUE }` must now be accessed with `Name.VALUE` instead of `VALUE`.
- Cyclic references to other scripts with `preload()` are no longer allowed.
- `load()` should be used in at least one of the scripts instead.
- `switch`, `case` and `do` are no longer reserved identifiers in GDScript.
- Shadowing variables from parent scopes is no longer allowed in GDScript.
- Function parameters' default values can no longer depend on other parameters in GDScript.
- Indentation guides are now displayed in a more subtle way in the script editor.
- Indentation guides are now displayed when indenting using spaces.
- Multi-line strings are now highlighted as strings rather than as comments in the script editor.
- This is because GDScript does not officially support multiline comments.
- Increased the script editor's line spacing (4 pixels → 6 pixels).
- Increased the caret width in the script editor (1 pixel → 2 pixels).
- The project manager window is now resized to match the editor scale.
- The asset library now makes use of threading, making loading more responsive.
- Line spacing in the script editor, underlines and caret widths are now resized to match the editor scale.
- Replaced editor icons for checkboxes and radio buttons with simpler designs.
- Tweaked the editor's success, error, and warning text colors for better readability and consistency.
- **Android:** Custom permissions are now stored in an array and their amount is no longer limited to 20.
- Custom permissions will have to be redefined in projects imported from older versions.
- **Android:** Provide error details when an in-app purchase fails.
- **Linux:** `OS.alert()` now uses Zenity or KDialog if available instead of xmessage.
- **Mono:** Display stack traces for inner exceptions.
- **Mono:** Bundle `mscorlib.dll` with Godot to improve portability.
### Removed
- Removed the RtAudio backend on Windows in favor of WASAPI, which is the default since 3.0.
- **macOS:** Support for 32-bit and fat binaries.
- Upgrade bundled OpenSSL to 1.0.2o.
### Fixed
- [`move_and_slide()` now behaves differently at low velocities](https://github.com/godotengine/godot/issues/21683), which makes it function as originally intended.
- AnimatedSprite2D's `animation_finished` signal is now triggered at the end of the animation, instead of as soon as the last frame displays.
- Audio buses can now be removed in the editor while they are used by AudioStreamPlayer2D/3D nodes.
- Do not show the project manager unless no project was found at all.
- The animation editor time offset indicator no longer "walks" when resizing the editor.
- Allow creation of a built-in GDScript file even if the filename suggested already exists.
- Show tooltips in the editor when physics object picking is disabled.
- Button shortcuts can now be triggered by gamepad buttons.
- Fix a serialization bug that could cause TSCN files to grow very large.
- Gizmos are now properly hidden on scene load if the object they control is hidden.
- Camera gizmos in the 3D viewport no longer look twice as wide as they actually are.
- Copy/pasting from the editor on X11 will now work more reliably.
- `libgcc_s` and `libstdc++` are now linked statically for better Linux binary portability.
- The FPS cap set by `force_fps` in the Project Settings is no longer applied to the editor.
- Low FPS caps no longer cause the editor to feel sluggish.
- hiDPI is now detected and used if needed in the project manager.
- The Visual Studio Code external editor option now recognizes more binary names such as `code-oss`, making detection more reliable.
- The `-ffast-math` flag is no longer used when compiling Godot, resulting in increased floating-point determinism.
- Security issue relating to deserializing Variants.
- Several editor crashes.
- GLTF import fixes.
- Windows: Fix touch/pen input.
- Mono: --build-solutions now forces editor mode.
- Mono: Several bugfixes.
- Headless: Fix scene imports.
## [3.0.5] - 2018-07-08
### Added
- 'android_add_asset_dir('...') method to Android module gradle build config.
### Fixed
- Android exporter no longer writes unnecessary permissions to the exported APK.
- Segfault when quitting the editor.
- Debugger 'focus stealing' now works more reliably.
- Subresources are now always saved when saving a scene.
- WebAssembly: Supply proper CORS heards.
- Mono: Annotated signal loading in exported projects.
- Mono: Serveral fixes.
## [3.0.4] - 2018-06-23
### Added
- Fix for Bullet's heightmap collider.
- Several documentation fixes.
### Fixed
- Threading problem causing asset library to crash on low threadcount systems.
## [3.0.3] - 2018-06-13
### Added
- C# projects can now be exported for Windows, Linux, and MacOS targets.
- Universal translation of touch to mouse.
- Dynamic fonts can now have a hinting mode set.
- print_tree_pretty() was added allowing a graphical view of the scene tree.
- Restore purchases feature for iOS.
- AudioStreamPlayer, AudioStreamPlayer2D, and AudioStreamPlayer3D now have a pitch scale property.
- Show origin and Show viewport setting in 2D editor.
- You can now set Godot windows as 'always on top'.
- --print-fps options to print FPS to stdout.
### Fixed
- Mono: Signal parameters no longer crash the engine.
- Asset library thread usage, this makes the asset library more responsive.
- Several GLTF import fixes.
- Several memory leaks.
- iPhone X support.
- Several fixes to audio drivers (WASAPI and PulseAudio).
- Several crashes.
- Export PCK/ZIP now works again.
## [3.0.2] - 2018-03-03
### Added
- Mono: We now display stack traces for inner exceptions.
- Mono: Bundle mscorlib.dll with Godot to improve portability.
### Fixed
- Running a scene from a project with a main scene now works again (regression in 3.0.1).
- Correct line spacing in RichTextLabel (regression in 3.0.1).
- TextureProgress now correctly displays when progress > 62 (regression in 3.0.1).
- The editor no longer complains about using an enum from an autoloaded resource (regression in 3.0.1).
- Pressing Escape no longer closes unexpected subwindows (regression in 3.0.1).
- Fix spelling of `apply_torque_impulse()` and deprecate the misspelled method.
- Escape sequences like `\n` and `\t` are now recognized in CSV translation files.
- Gizmos are now properly hidden on scene load if the object they control is hidden.
- Remove spurious errors when using a PanoramaSky without textures.
- Show tooltips in the editor when physics object picking is disabled.
- Fix a serialization bug that could cause tscn files to grow very large.
- Do not show the project manager unless no project was found at all.
- The animation editor time offset indicator no longer 'walks' when resizing the editor.
- Allow creation of an in-tscn file GDScript function even if the filename suggested already exists.
- Mono: Godot no longer crashes when opening a project created with an older release.
- Mono: Fix builds of tools=no builds.
- Mono: Fix transformation regression since 3.0.1
- Android: We now require GLESv3 support in the manifest.
- Android: Fix intermittent audio driver crash.
## [3.0.1] - 2018-02-25
### Added
- The 'server' platform is back as it was in Godot 2.1.
- It is now again possible to run a headless Godot on Linux.
- New CLI options
- --build-solutions: build C# solutions without starting the editor.
- --quit: quit the engine after the first main loop iteration.
- It is now possible to scale an .obj mesh when importing.
- Type icons can now be enabled in the editor again.
- New GLSL built-in functions in the shader language
- radians
- degrees
- asinh
- acosh
- atanh
- exp2
- log2
- roundEven
- New GDScript features
- `OS.center_window()`.
- `StreamPeerTCP.set_no_delay()`.
- `EditorPlugin.remove_control_from_container()`.
- A button has been added to the debugger to copy the error messages.
- The Ctrl toggles snapping in the 3D viewport.
- Support has been added for a new .escn, for use with the new Blender exporter.
- CA certificates have been updated to the latest Mozilla bundle.
### Fixed
- Copy/pasting from the editor on X11 will now work more reliably.
- The lightmap baker will now use all available cores on Windows.
- Fixed missing text in some FileDialog buttons.
- Fixes to HTTP requests on the HTML5 platform.
- Many, many fixes and improvements to C# support (including a [Signal] attribute).
- Static linking of `libgcc_s` as well as `libstdc++` for better Linux binary portability.
- Fix broken APK expansion on Android.
- Several crashes in the editor have been fixed.
- Many documentation fixes.
- Several hiDPI fixes.
## Changed
- Bullet physics now correctly calculates effective gravity on KinematicBodies.
- Setting the color `v` member now correctly sets the `s` member.
- RichTextLabels now correctly determine the baseline for all fonts.
- SpinBoxes now correctly calculate their initial size.
- OGG streams now correctly signal the end of playback.
- Android exporter no longer writes unnecessary permissions to the exported APK.
- Debugger "focus stealing" now works more reliably.
- Subresources are now always saved when saving a scene.
- Many fixes related to importers (glTF, Collada, audio), physics (Bullet), Mono/C#, GDNative, Android/iOS.
- **Mono:** Many fixes and improvements to C# support (including a `[Signal]` attribute).
- **WebAssembly:** Supply proper CORS headers.
### Security
- Fixed a security issue relating to deserializing Variants.
## [3.0] - 2018-01-29
@ -306,7 +193,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Setters and getters for node properties.
- Underscores in number literals are now allowed for improved readability (for example,`1_000_000`).
- Improved performance (+20% to +40%, based on various benchmarks).
- [Feature tags](http://docs.godotengine.org/en/latest/getting_started/workflow/export/feature_tags.html) in the Project Settings, for custom per-platform settings.
- [Feature tags](http://docs.godotengine.org/en/latest/learning/workflow/export/feature_tags.html) in the Project Settings, for custom per-platform settings.
- Full support for the [glTF 2.0](https://www.khronos.org/gltf/) 3D interchange format.
- Freelook and fly navigation to the 3D editor.
- Built-in editor logging (logging standard output to a file), disabled by default.
@ -396,5 +283,4 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- HTML5 export using asm.js.
- Only WebAssembly is supported now, since all browsers supporting WebGL 2.0 also support WebAssembly.
[Unreleased]: https://github.com/godotengine/godot/compare/3.0-stable...HEAD
[3.0]: https://github.com/godotengine/godot/compare/2.1-stable...3.0-stable

View File

@ -1,57 +0,0 @@
# Lines starting with '#' are comments.
# Each line is a file pattern followed by one or more owners.
# Owners can be @users, @org/teams or emails
/core/ @reduz
/doc/ @godotengine/documentation
doc_classes/* @godotengine/documentation
# Rendering
/drivers/gl_context/ @reduz
/drivers/gles2/ @reduz
/drivers/gles3/ @reduz
# Audio
/drivers/alsa/ @marcelofg55
/drivers/alsamidi/ @marcelofg55
/drivers/coreaudio/ @marcelofg55
/drivers/coremidi/ @marcelofg55
/drivers/pulseaudio/ @marcelofg55
/drivers/wasapi/ @marcelofg55
/drivers/winmidi/ @marcelofg55
/drivers/xaudio2/ @marcelofg55
# Porting
/drivers/unix/ @reduz @hpvb
/drivers/windows/ @reduz @hpvb
/editor/icons/ @djrm
/main/ @reduz
/misc/ @akien-mga
/modules/bullet/ @AndreaCatania
/modules/csg/ @reduz @BastiaanOlij
/modules/enet/ @godotengine/network
/modules/gdnative/ @karroffel
/modules/gdnative/*arvr/ @BastiaanOlij
/modules/gdscript/ @reduz @vnen @bojidar-bg
/modules/mbedtls/ @godotengine/network
/modules/mobile_vr/ @BastiaanOlij
/modules/mono/ @neikeq
/modules/opensimplex/ @JFonS
/modules/regex/ @LeeZH
/modules/upnp/ @godotengine/network
/modules/websocket/ @godotengine/network
/platform/javascript/ @eska014
/platform/uwp/ @vnen
/scene/main/ @reduz
/server/physics*/ @reduz @AndreaCatania
/server/visual*/ @reduz @karroffel
/thirdparty/ @akien-mga

View File

@ -59,8 +59,7 @@ by drag and dropping the file in the GitHub edition field.
If you want to add new engine functionalities, please make sure that:
* This functionality is desired, which means that it solves a common use case
that several users will need in their real-life projects.
* This functionality is desired.
* You talked to other developers on how to implement it best (on either
communication channel, and maybe in a GitHub issue first before making your
PR).
@ -71,23 +70,11 @@ Similar rules can be applied when contributing bug fixes - it's always best to
discuss the implementation in the bug report first if you are not 100% about
what would be the best fix.
[This blog post](https://godotengine.org/article/will-your-contribution-be-merged-heres-how-tell)
outlines the process used by core developers when assessing PRs. We strongly
recommend that you have a look at it to know what's important to take into
account for a PR to be considered for merging.
In addition to the following tips, also take a look at the
[Engine development guide](https://docs.godotengine.org/en/latest/development/cpp/)
for an introduction to developing on Godot.
The [Contributing docs](http://docs.godotengine.org/en/latest/community/contributing/index.html)
also have important information on the PR workflow and the code style we use.
#### Be nice to the git history
Try to make simple PRs that handle one specific topic. Just like for reporting
issues, it's better to open 3 different PRs that each address a different issue
than one big PR with three commits.
Try to make simple PRs with that handle one specific topic. Just like for
reporting issues, it's better to open 3 different PRs that each address a
different issue than one big PR with three commits.
When updating your fork with upstream changes, please use ``git pull --rebase``
to avoid creating "merge commits". Those commits unnecessarily pollute the git
@ -102,9 +89,6 @@ Internet).
This git style guide has some good practices to have in mind:
[Git Style Guide](https://github.com/agis-/git-style-guide)
See our [PR workflow](http://docs.godotengine.org/en/latest/community/contributing/pr_workflow.html)
documentation for tips on using Git, amending commits and rebasing branches.
#### Format your commit logs with readability in mind
The way you format your commit logs is quite important to ensure that the
@ -150,10 +134,6 @@ Weblate](https://hosted.weblate.org/projects/godot-engine/godot), an open
source and web-based translation platform. Please refer to the [translation
readme](editor/translations/README.md) for more information.
You can also help translate [Godot's
documentation](https://hosted.weblate.org/projects/godot-engine/godot-docs/)
on Weblate.
## Communicating with developers
The Godot Engine community has [many communication

File diff suppressed because it is too large Load Diff

571
DONORS.md
View File

@ -12,516 +12,281 @@ generous deed immortalized in the next stable release of Godot Engine.
## Platinum sponsors
Heroic Labs <https://heroiclabs.com>
Interblock <http://interblockgaming.com>
Enjin Coin <https://enjincoin.io>
## Gold sponsors
Gamblify <https://www.gamblify.com>
Moonwards <https://www.moonwards.com>
GameDev.TV <https://www.gamedev.tv>
Skirmish <https://skirmish.io>
## Mini sponsors
AD Ford
Alan Beauchamp
Anand Mallik
Andres Hernandez
Andrew Dunai
Brandon Lamb
Christian Baune
Christopher Montesano
Darkhan Baimyrza
Darrin Massena
Dov Zimring
Edward Flick
Gamechuck
GameDev.net
GameDev.tv
Grady
Christian Uldall Pedersen
Christopher Igoe
Christoph Woinke
Claudiu Dumitru
E Hewert
Hein-Pieter van Braam
Jacob McKenney
Javary Co.
Jeffery Chiu
Justin Arnold
Justo Delgado Baudí
Kyle Szklenski
Igors Vaitkus
Jamal Alyafei
Jay Sistar
Matthieu Huvé
Maxim Karsten
Mike King
Nathan Warden
Neal Gompa (Conan Kudo)
Péter Magyar
Pascal Julien
Ruslan Mustakov
Sébastien Manin
Slobodan Milnovic
Stephan Lanfermann
Steve
Tristan Pemble
Stoney Meyerhoeffer
Thomas Mathews
VilliHaukka
## Gold donors
Andrei
Dave
David Gehrig
David Snopek
Ed Morley
Florian Krick
Florian Rämisch
Jakub Grzesik
3Dexplorer
Alexander Otto
Asdf
cheese65536
K9Kraken
Kris Michael
Manuele Finocchiaro
Nathanael Beisiegel
Officine Pixel S.n.c.
Retro Village
Ronan Zeegers
Sofox
Taylor Ritenour
Zaven Muradyan
Asher Glick
Allen Schade
Andreas Schüle
Austen McRae
Bernhard Werner
beVR
Carlo Cabanilla
Daniel James
David Giardi
Default Name
eggs
Felix Bohmann
Bernhard Liebl
Catalin Moldovan
DeepSquid
Fidget Sinner
Florian Breisch
Gamejunkey
Javier Roman
Jay Horton
Jon Woodward
Karl Werf
Keinan Powers
Klavdij Voncina
Lex Steers
Luke
Maciej Pendolski
Matthew Hillier
Mohamed Ikbel Boulabiar
Mored4u
Rob Messick
Ryan Badour
Sandro Jenny
Scott Wadden
Sergey
thechris
Tom Langwaldt
tukon
William Wold
Gary Oberbrunner
Johannes Wuensch
Josep G. Camarasa
Joshua Lesperance
Kyle Szklenski
Libre-Dépanne
Matthew Bennett
Olafur Gislason
Paul LaMotte
Ranoller
Svenne Krap
Timothy Hagberg
Alex Khayrullin
Chris Goddard
BanjoNode2D
Beliar
Chris Serino
Christian Padilla
Conrad Curry
Craig Smith
Darrian Little
Horváth Péter
Ivan Trombley
Jakub Dering
Joan Fons
Joshua Flores
Krzysztof Jankowski
Lord Bloodhound
Pascal Grüter
Petr Malac
Daniel Egger
David Churchill
Dean Harmon
Dexter Miguel
John
Justo Delgado Baudí
KTL
Laurence Bannister
paul gruenbacher
Rami
Reneator
Rob
Robert Willes
Robin Arys
Rodrigo Loli
Ronnie Ashlock
SKison
Rufus Xavier Sarsaparilla
ScottMakesGames
Thomas Bjarnelöf
Unseen Domains
Valryia
Vincent Henderson
William Connell
Wojciech Chojnacki
Xavier PATRICELLI
Zaq Poi
Adam Nakonieczny
Adam Neumann
Alexander J Maynard
Alessandra Pereyra
Alexey Dyadchenko
Alex Z
Andreas Funke
André Frélicot
aoshiwik
Ben Powell
Carlos de Sousa Marques
Charlie Whitfield
Chase Taranto
Amanda Haldy
Chris Brown
Chris Petrich
Christian Leth Jeppesen
Christoph Schröder
Chris Wilson
Cody Parker
Coldragon
Craig Ostrin
Corey Auger
D
Daniel Eichler
David White
Denis Janßen
Easypete
E.G.
Eric
Eric Monson
ethan ball
Eugenio Hugo Salgüero Jáñez
Fain
flesk
Gary Hulst
gavlig
floopf
G Barnes
GGGames.org
Green Fox
Giovanni Solimeno
Guilherme Felipe de C. G. da Silva
Halom Vered
Hasen Judy
Heath Hayes
Idzard Kwadijk
Isaac Clausman
Jared White
Jeff Nyte
Jeremy Sims
Jerry Ling
Joe Flood
John G Gentzel
Jon Hermansen
Jose Malheiro
Joshua Lesperance
Juan Velandia
Jay Horton
Jeppe Zapp
joe513
Jordan M Lucas
Juraj Móza
kinfox
Marcelo Dornbusch Lopes
Markus Fehr
Justin Arnold
Leandro Voltolino
Lisandro Lorea
Markus Wiesner
Martin Eigel
Matt Eunson
Max Bulai
MuffinManKen
Marvin
Mohammad Taleb
Neal Barry
Nick Nikitin
Oliver Dick
Patrick Ting
Paul Hocker
Paul Von Zimmerman
Pablo Cholaky
Patrick Schnorbus
Pete Goodwin
pl
Ranoller
Robert Larnach
Rocknight Studios
Romildo Franco
Samuel Judd
Scott Pilet
Sean Morgan
SleepCircle
spilldata
Steve Hyatt
Phyronnaz
Ruben Soares Luis
Sindre Sømme
Sofox
Stoned Xander
TheLevelOfDetail .
Thomas Krampl
Thomas Kurz
Tobias Bocanegra
Tricky Fat Cat
Urho
William Foster
Zhou Tuizhi
Zie Weaver
蕭惟允
Tim Dalporto
Trent McPheron
## Silver donors
1D_Inc
Abraham Haskins
Adam
Adam Brunnmeier
Adam Carr
Adam Long
Adam McCurdy
Adam N Webber
Adam Smeltzer
Adam Szymański
Adisibio
Adrian Demetrescu
Agustinus Arya
Aidan O'Flannagain
Aki Mimoto
Alan Mervitz
Alan Stice
Albin Jonasson Svärdsby
Alder Stefano
Alessandro Senese
Alexander Erlemann
alex clavelle
Allan Davis
Allen Schade
Andreas Evers
Andreas Krampitz
André Simões
Andrew Thomas
Anthony Staunton
AP Condomines
Anders Jensen-Urstad
Anthony Bongiovanni
Arda Erol
Armin Preiml
Arseniy M
Arthur S. Muszynski
Asger
Artur Barichello
Aubrey Falconer
Avencherus
B A
Balázs Batári
Bailey
Bastian Böhm
Benedikt
Ben G
Ben Phelan
Benjamin Beshara
Ben Vercammen
Bernd Jänichen
Black Block
Blair Allen
Bobby CC Wong
brian
bugcaptor
Burney Waring
Cameron Meyer
Carl van der Geest
Brandon
Bryan Stevenson
Carl Winder
Carwyn Edwards
Cassidy James
Chris Brown
Casey Foote
Chris Chapin
Christian Baune
Christian Winter
Christoffer Sundbom
Christoph Brodmann
Christopher Schmitt
Christoph Woinke
Clay Heaton
Curt King
Dancin Liao
Collin Shooltz
Daniel Johnson
Daniel Kimblad
Daniel Pontillo
Daniel Kaplan
DanielMaximiano
Daniel Mircea
David
David Cravens
David May
David Woodard
DiCola Jamn
Dominic Cooney
Dominik Wetzel
Donn Eddy
Donovan Hutcheon
Dragontrapper
Dr Ewan Murray
Duobix
Duodecimal
Dylan Todd
Eduardo Teixeira
Duy Kevin Nguyen
Edward Herbert
Edward Moulsdale
Edward Swartz
Egon Elbre
Elias Nykrem
Elmeri '- Duy Kevin Nguyen
Ephemeral
Eric Ellingson
Eric Rogers
Eric Williams
Erkki Seppälä
Evan Rose
Fancy Ants Studios
Fekinox
Felix Kollmann
Flaredown
Forty Doubleu
FuDiggity
Gadzhi Kharkharov
gamedev by Celio
Gary Thomas
George Marques
GiulianoB
Gordian Arragon
Greg Olson
GREGORY C FEIN
Greg P
Greyson Richey
Grid
Edwin Acosta
Eric Martini
Fabian Becker
fengjiongmax
Francesco Lisi
G3Dev sàrl
Gerrit Großkopf
Gerrit Procee
Gilberto K. Otubo
Guillaume Laforte
Guldoman
Hal A
Gumichan01
Heribert Hirth
Hudson Thorpe-Doubble
Hunter Jones
Hylpher
Ichiro Dohi
Iiari
iKlem
IndustrialRobot
Jaiden Gerig
ialex32x
Ivan Vodopiviz
Jahn Johansen
Jaime Ruiz-Borau Vizárraga
Jako Danar
James A F Manley
Janders
Jannik Gröger
JARKKO PARVIAINEN
Jarrod Davis
Jed
Jeff Hungerford
Jennifer Graves
Jeremy Kahn
Jesse Dubay
Joel Fivat
Joel Höglund
Joel Setterberg
Johannes Wuensch
John Gabriel
Jomei Jackson
Johan Lindberg
Jonas Rudlang
Jonas Yamazaki
Jonathan G
Jonathan Martin
Jonathan Nieto
Jonathon
Jon Bonazza
Jon Sully
Jorge Caballero
Jose Aleman
Jose C. Rubio
Joseph Catrambone
Juanfran
Josh 'Cheeseness' Bush
Juan Negrier
Judd
Julian Murgia
JungleRobba
Justin Spedding
KaDokta
Kauzig
Keedong Park
Keith Bradner
Kevin McPhillips
kickmaniac
Kiyohiro Kawamura (kyorohiro)
Kjetil Haugland
Klagsam
KR McGinley
KsyTek Games
Kuan Cheang
kycho
Kyle Appelgate
Laurent Tréguier
Leonardo Dimano
Levi Lindsey
Justin Luk
KC Chan
Kevin Boyer
Kevin Kamper Meejach Petersen
Klavdij Voncina
Krzysztof Jankowski
Linus Lind Lundgren
Lionel Gaillard
Luigi Renna
LunaticInAHat
Lurkars
Major Haul
Malcolm
Malik Ahmed
Malik Nejer
Markus Michael Egger
Martin Holas
Martin Liška
Marvin
Mathieu Rimelen
Matt Edwards
Matthew Little
Matti Pohjanvirta
Maxime Blade
Luis Moraes
Macil
magodev
Martin Eigel
Martins Odabi
Max R.R. Collada
Maxwell
medecau
Megasploot
Melissa Mears
mewin
Mertcan Mermerkaya
mhilbrunner
Michael Haney
Michael Dürwald
Michael Gringauz
Michael Labbe
Mikael Olsson
Mikayla
Mike Birkhead
Mike Cunningham
Mitchell J. Wagner
MoM
Nathan Fish
Moritz Laass
Natrim
nee
Neil Blakey-Milner
Neil Wang
Nerdforge
Nicholas
Nicholas Girga
Nick Macholl
Nicolás Montaña
Nick Pavlica
Niclas Eriksen
Nicolas SAN AGUSTIN
Nima Farid
NZ
Oleg Reva
Olivier
Omar Delarosa
Oscar Norlander
Niko Leopold
Noi Sek
Oleg Tyshchenko
Pablo Seibelt
Pan Ip
Pat LaBine
Patrick Nafarrete
Paul Gieske
Patric Vormstein
Paul Mason
Paweł Kowal
Pedro Assuncao
Penguin
Petrus Prinsloo
Philip Cohoe
Point08
Rad Cat
Rafa Laguna
rainerLinux
Raphael Leroux
Remi Rampin
Pierre-Igor Berthet
Pietro Vertechi
Piotr Kaczmarski
Rémi Verschelde
Ricardo Alcantara
Richard Diss
Richard Ivánek
Robert Farr (Larington)
Robert Hernandez
Roberto Sánchez
Richman Stewart
Roger Burgess
Roger Smith
Roland Rząsa
Roman Tinkov
Ronald Ho Hip (CrimsonZA)
Ronan
Ryan Groom
Ryan Hentz
Sam.C
Sam Edson
Samuele Zolfanelli
Ryan Whited
Sasori Olkof
Scott D. Yelich
Scott Longley
Sebastian Michailidis
Sergio Mello-Grand
sgnsajgon
Shane
Shane Sicienski
Shane Spoor
Siim Raidma
Simon Wenner
SK
smbe19
smo1704
Svenne Krap
Terry
tezuvholovdr
thomas
Thomas Bechtold
Thomas Detoy
Thomas Kelly
Tim Drumheller
Timothy B. MacDonald
Tobbun
Torgeir Lilleskog
Torsten Crass
Travis O'Brien
Trent Skinner
Troy Bonneau
Tryggve Sollid
Turgut Temucin
Tyler Compton
Sootstone
Stefan Butucea
Theo Cranmore
Thibault Barbaroux
Thomas Bell
Thomas Hermansen
Thomas Holmes
Thomas Kurz
Tom Larrow
Tyler Stafos
UltyX
Vaughan Ling
Victor
Vigilant Watch
Vincent Cloutier
Victor Gonzalez Fernandez
Viktor Ferenczi
waka nya
Wayne Haak
werner mendizabal
Wiley Thompson
Will
William Hogben
Wyatt Goodin
Yegor
Yuri Sizov
Wout Standaert
Yu He
## Bronze donors

View File

@ -1,5 +1,5 @@
Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur.
Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md)
Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur.
Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,3 @@
Godot Engine Logo
Copyright (c) 2017 Andrea Calabró
This work is licensed under a Creative Commons Attribution 4.0 International
License (CC-BY-4.0 International) <https://creativecommons.org/licenses/by/4.0/>.
Godot Logo (C) Andrea Calabró
Distributed under the terms of the Creative Commons Attribution License
version 3.0 (CC-BY 3.0) <https://creativecommons.org/licenses/by/3.0/legalcode>.

View File

@ -26,7 +26,7 @@ Before being open sourced in February 2014, Godot had been developed by Juan
Linietsky and Ariel Manzur (both still maintaining the project) for several
years as an in-house engine, used to publish several work-for-hire titles.
![Screenshot of a 3D scene in Godot Engine](https://download.tuxfamily.org/godotengine/media/screenshots/editor_3d_fracteed.jpg)
![Screenshot of a 3D scene in Godot Engine](http://download.tuxfamily.org/godotengine/media/screenshots/editor_3d_fracteed.jpg)
### Getting the engine
@ -37,10 +37,10 @@ Official binaries for the Godot editor and the export templates can be found
#### Compiling from source
[See the official docs](https://docs.godotengine.org/en/latest/development/compiling/)
[See the official docs](http://docs.godotengine.org/en/latest/development/compiling/)
for compilation instructions for every supported platform.
### Community and contributing
### Community
Godot is not only an engine but an ever-growing community of users and engine
developers. The main community channels are listed [on the homepage](https://godotengine.org/community).
@ -49,14 +49,12 @@ To get in touch with the developers, the best way is to join the
[#godotengine IRC channel](https://webchat.freenode.net/?channels=godotengine)
on Freenode.
To get started contributing to the project, see the [contributing guide](CONTRIBUTING.md).
### Documentation and demos
The official documentation is hosted on [ReadTheDocs](https://docs.godotengine.org).
The official documentation is hosted on [ReadTheDocs](http://docs.godotengine.org).
It is maintained by the Godot community in its own [GitHub repository](https://github.com/godotengine/godot-docs).
The [class reference](https://docs.godotengine.org/en/latest/classes/)
The [class reference](http://docs.godotengine.org/en/latest/classes/)
is also accessible from within the engine.
The official demos are maintained in their own [GitHub repository](https://github.com/godotengine/godot-demo-projects)

View File

@ -2,15 +2,16 @@
EnsureSConsVersion(0, 98, 1)
# System
import glob
import os
import sys
# Local
import string
import os
import os.path
import glob
import sys
import methods
import gles_builders
from platform_methods import run_in_subprocess
# moved below to compensate with module version string
# methods.update_version()
# scan possible build platforms
@ -22,19 +23,22 @@ active_platforms = []
active_platform_ids = []
platform_exporters = []
platform_apis = []
global_defaults = []
for x in sorted(glob.glob("platform/*")):
for x in glob.glob("platform/*"):
if (not os.path.isdir(x) or not os.path.exists(x + "/detect.py")):
continue
tmppath = "./" + x
sys.path.insert(0, tmppath)
sys.path.append(tmppath)
import detect
if (os.path.exists(x + "/export/export.cpp")):
platform_exporters.append(x[9:])
if (os.path.exists(x + "/api/api.cpp")):
platform_apis.append(x[9:])
if (os.path.exists(x + "/globals/global_defaults.cpp")):
global_defaults.append(x[9:])
if (detect.is_active()):
active_platforms.append(detect.get_name())
active_platform_ids.append(x)
@ -49,23 +53,27 @@ for x in sorted(glob.glob("platform/*")):
module_list = methods.detect_modules()
# print "Detected Platforms: "+str(platform_list)
methods.save_active_platforms(active_platforms, active_platform_ids)
custom_tools = ['default']
platform_arg = ARGUMENTS.get("platform", ARGUMENTS.get("p", False))
if os.name == "nt" and (platform_arg == "android" or ARGUMENTS.get("use_mingw", False)):
custom_tools = ['mingw']
elif platform_arg == 'javascript':
# Use generic POSIX build toolchain for Emscripten.
custom_tools = ['cc', 'c++', 'ar', 'link', 'textfile', 'zip']
if (os.name == "posix"):
pass
elif (os.name == "nt"):
if (os.getenv("VCINSTALLDIR") == None or platform_arg == "android" or platform_arg == "javascript"):
custom_tools = ['mingw']
env_base = Environment(tools=custom_tools)
if 'TERM' in os.environ:
env_base['ENV']['TERM'] = os.environ['TERM']
env_base.AppendENVPath('PATH', os.getenv('PATH'))
env_base.AppendENVPath('PKG_CONFIG_PATH', os.getenv('PKG_CONFIG_PATH'))
env_base.global_defaults = global_defaults
env_base.android_maven_repos = []
env_base.android_flat_dirs = []
env_base.android_dependencies = []
@ -82,8 +90,17 @@ env_base.android_permission_chunk = ""
env_base.android_appattributes_chunk = ""
env_base.disabled_modules = []
env_base.use_ptrcall = False
env_base.split_drivers = False
env_base.split_modules = False
env_base.module_version_string = ""
env_base.msvc = False
# To decide whether to rebuild a file, use the MD5 sum only if the timestamp has changed.
# http://scons.org/doc/production/HTML/scons-user/ch06.html#idm139837621851792
env_base.Decider('MD5-timestamp')
# Use cached implicit dependencies by default. Can be overridden by specifying `--implicit-deps-changed` in the command line.
# http://scons.org/doc/production/HTML/scons-user/ch06s04.html
env_base.SetOption('implicit_cache', 1)
env_base.__class__.android_add_maven_repository = methods.android_add_maven_repository
env_base.__class__.android_add_flat_dir = methods.android_add_flat_dir
@ -111,7 +128,6 @@ env_base.__class__.add_shared_library = methods.add_shared_library
env_base.__class__.add_library = methods.add_library
env_base.__class__.add_program = methods.add_program
env_base.__class__.CommandNoCache = methods.CommandNoCache
env_base.__class__.disable_warnings = methods.disable_warnings
env_base["x86_libtheora_opt_gcc"] = False
env_base["x86_libtheora_opt_vc"] = False
@ -122,6 +138,7 @@ customs = ['custom.py']
profile = ARGUMENTS.get("profile", False)
if profile:
import os.path
if os.path.isfile(profile):
customs.append(profile)
elif os.path.isfile(profile + ".py"):
@ -130,58 +147,52 @@ if profile:
opts = Variables(customs, ARGUMENTS)
# Target build options
opts.Add('arch', "Platform-dependent architecture (arm/arm64/x86/x64/mips/...)", '')
opts.Add(EnumVariable('bits', "Target platform bits", 'default', ('default', '32', '64')))
opts.Add('arch', "Platform-dependent architecture (arm/arm64/x86/x64/mips/etc)", '')
opts.Add(EnumVariable('bits', "Target platform bits", 'default', ('default', '32', '64', 'fat')))
opts.Add('p', "Platform (alias for 'platform')", '')
opts.Add('platform', "Target platform (%s)" % ('|'.join(platform_list), ), '')
opts.Add(EnumVariable('target', "Compilation target", 'debug', ('debug', 'release_debug', 'release')))
opts.Add(EnumVariable('optimize', "Optimization type", 'speed', ('speed', 'size')))
opts.Add(BoolVariable('tools', "Build the tools (a.k.a. the Godot editor)", True))
opts.Add(BoolVariable('use_lto', 'Use link-time optimization', False))
opts.Add(BoolVariable('use_precise_math_checks', 'Math checks use very precise epsilon (useful to debug the engine)', False))
opts.Add(BoolVariable('tools', "Build the tools a.k.a. the Godot editor", True))
opts.Add(BoolVariable('use_lto', 'Use linking time optimization', False))
# Components
opts.Add(BoolVariable('deprecated', "Enable deprecated features", True))
opts.Add(BoolVariable('gdscript', "Enable GDScript support", True))
opts.Add(BoolVariable('minizip', "Enable ZIP archive support using minizip", True))
opts.Add(BoolVariable('xaudio2', "Enable the XAudio2 audio driver", False))
opts.Add(BoolVariable('gdscript', "Build GDSCript support", True))
opts.Add(BoolVariable('minizip', "Build minizip archive support", True))
opts.Add(BoolVariable('xaudio2', "XAudio2 audio driver", False))
opts.Add(BoolVariable('xml', "XML format support for resources", True))
# Advanced options
opts.Add(BoolVariable('verbose', "Enable verbose output for the compilation", False))
opts.Add(BoolVariable('progress', "Show a progress indicator during compilation", True))
opts.Add(EnumVariable('warnings', "Set the level of warnings emitted during compilation", 'all', ('extra', 'all', 'moderate', 'no')))
opts.Add(BoolVariable('werror', "Treat compiler warnings as errors. Depends on the level of warnings set with 'warnings'", False))
opts.Add(BoolVariable('dev', "If yes, alias for verbose=yes warnings=all", False))
opts.Add(BoolVariable('disable_3d', "Disable 3D nodes for smaller executable", False))
opts.Add(BoolVariable('disable_advanced_gui', "Disable advanced 3D gui nodes and behaviors", False))
opts.Add('extra_suffix', "Custom extra suffix added to the base filename of all generated binary files", '')
opts.Add(BoolVariable('vsproj', "Generate a Visual Studio solution", False))
opts.Add(EnumVariable('macports_clang', "Build using Clang from MacPorts", 'no', ('no', '5.0', 'devel')))
opts.Add(BoolVariable('split_libmodules', "Split intermediate libmodules.a in smaller chunks to prevent exceeding linker command line size (forced to True when using MinGW)", False))
opts.Add(BoolVariable('disable_3d', "Disable 3D nodes for a smaller executable", False))
opts.Add(BoolVariable('disable_advanced_gui', "Disable advanced GUI nodes and behaviors", False))
opts.Add(BoolVariable('no_editor_splash', "Don't use the custom splash screen for the editor", False))
opts.Add('system_certs_path', "Use this path as SSL certificates default for editor (for package maintainers)", '')
opts.Add('unix_global_settings_path', "UNIX-specific path to system-wide settings. Currently only used for templates", '')
opts.Add(BoolVariable('verbose', "Enable verbose output for the compilation", False))
opts.Add(BoolVariable('vsproj', "Generate Visual Studio Project", False))
opts.Add(EnumVariable('warnings', "Set the level of warnings emitted during compilation", 'no', ('extra', 'all', 'moderate', 'no')))
opts.Add(BoolVariable('progress', "Show a progress indicator during build", True))
opts.Add(BoolVariable('dev', "If yes, alias for verbose=yes warnings=all", False))
opts.Add(EnumVariable('macports_clang', "Build using clang from MacPorts", 'no', ('no', '5.0', 'devel')))
# Thirdparty libraries
opts.Add(BoolVariable('builtin_bullet', "Use the built-in Bullet library", True))
opts.Add(BoolVariable('builtin_certs', "Bundle default SSL certificates to be used if you don't specify an override in the project settings", True))
opts.Add(BoolVariable('builtin_enet', "Use the built-in ENet library", True))
opts.Add(BoolVariable('builtin_freetype', "Use the built-in FreeType library", True))
opts.Add(BoolVariable('builtin_libogg', "Use the built-in libogg library", True))
opts.Add(BoolVariable('builtin_libpng', "Use the built-in libpng library", True))
opts.Add(BoolVariable('builtin_libtheora', "Use the built-in libtheora library", True))
opts.Add(BoolVariable('builtin_libvorbis', "Use the built-in libvorbis library", True))
opts.Add(BoolVariable('builtin_libvpx', "Use the built-in libvpx library", True))
opts.Add(BoolVariable('builtin_libwebp', "Use the built-in libwebp library", True))
opts.Add(BoolVariable('builtin_libwebsockets', "Use the built-in libwebsockets library", True))
opts.Add(BoolVariable('builtin_mbedtls', "Use the built-in mbedTLS library", True))
opts.Add(BoolVariable('builtin_miniupnpc', "Use the built-in miniupnpc library", True))
opts.Add(BoolVariable('builtin_opus', "Use the built-in Opus library", True))
opts.Add(BoolVariable('builtin_pcre2', "Use the built-in PCRE2 library)", True))
opts.Add(BoolVariable('builtin_recast', "Use the built-in Recast library", True))
opts.Add(BoolVariable('builtin_squish', "Use the built-in squish library", True))
opts.Add(BoolVariable('builtin_xatlas', "Use the built-in xatlas library", True))
opts.Add(BoolVariable('builtin_zlib', "Use the built-in zlib library", True))
opts.Add(BoolVariable('builtin_zstd', "Use the built-in Zstd library", True))
opts.Add(BoolVariable('builtin_bullet', "Use the builtin bullet library", True))
opts.Add(BoolVariable('builtin_enet', "Use the builtin enet library", True))
opts.Add(BoolVariable('builtin_freetype', "Use the builtin freetype library", True))
opts.Add(BoolVariable('builtin_libogg', "Use the builtin libogg library", True))
opts.Add(BoolVariable('builtin_libpng', "Use the builtin libpng library", True))
opts.Add(BoolVariable('builtin_libtheora', "Use the builtin libtheora library", True))
opts.Add(BoolVariable('builtin_libvorbis', "Use the builtin libvorbis library", True))
opts.Add(BoolVariable('builtin_libvpx', "Use the builtin libvpx library", True))
opts.Add(BoolVariable('builtin_libwebp', "Use the builtin libwebp library", True))
opts.Add(BoolVariable('builtin_openssl', "Use the builtin openssl library", True))
opts.Add(BoolVariable('builtin_opus', "Use the builtin opus library", True))
opts.Add(BoolVariable('builtin_pcre2', "Use the builtin pcre2 library)", True))
opts.Add(BoolVariable('builtin_recast', "Use the builtin recast library", True))
opts.Add(BoolVariable('builtin_squish', "Use the builtin squish library", True))
opts.Add(BoolVariable('builtin_thekla_atlas', "Use the builtin thekla_altas library", True))
opts.Add(BoolVariable('builtin_zlib', "Use the builtin zlib library", True))
opts.Add(BoolVariable('builtin_zstd', "Use the builtin zstd library", True))
opts.Add(BoolVariable('no_editor_splash', "Don't use the custom splash screen for the editor", False))
# Compilation environment setup
opts.Add("CXX", "C++ compiler")
@ -192,6 +203,7 @@ opts.Add("CXXFLAGS", "Custom flags for the C++ compiler")
opts.Add("CFLAGS", "Custom flags for the C compiler")
opts.Add("LINKFLAGS", "Custom flags for the linker")
# add platform specific options
for k in platform_opts.keys():
@ -202,7 +214,7 @@ for k in platform_opts.keys():
for x in module_list:
module_enabled = True
tmppath = "./modules/" + x
sys.path.insert(0, tmppath)
sys.path.append(tmppath)
import config
enabled_attr = getattr(config, "is_enabled", None)
if (callable(enabled_attr) and not config.is_enabled()):
@ -216,36 +228,33 @@ Help(opts.GenerateHelpText(env_base)) # generate help
# add default include paths
env_base.Append(CPPPATH=['#editor', '#'])
env_base.Append(CPPPATH=['#core', '#core/math', '#editor', '#drivers', '#'])
# configure ENV for platform
env_base.platform_exporters = platform_exporters
env_base.platform_apis = platform_apis
if (env_base["use_precise_math_checks"]):
env_base.Append(CPPDEFINES=['PRECISE_MATH_CHECKS'])
"""
sys.path.append("./platform/"+env_base["platform"])
import detect
detect.configure(env_base)
sys.path.remove("./platform/"+env_base["platform"])
sys.modules.pop('detect')
"""
if (env_base['target'] == 'debug'):
env_base.Append(CPPDEFINES=['DEBUG_MEMORY_ALLOC','DISABLE_FORCED_INLINE'])
# The two options below speed up incremental builds, but reduce the certainty that all files
# will properly be rebuilt. As such, we only enable them for debug (dev) builds, not release.
# To decide whether to rebuild a file, use the MD5 sum only if the timestamp has changed.
# http://scons.org/doc/production/HTML/scons-user/ch06.html#idm139837621851792
env_base.Decider('MD5-timestamp')
# Use cached implicit dependencies by default. Can be overridden by specifying `--implicit-deps-changed` in the command line.
# http://scons.org/doc/production/HTML/scons-user/ch06s04.html
env_base.SetOption('implicit_cache', 1)
env_base.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC'])
env_base.Append(CPPFLAGS=['-DSCI_NAMESPACE'])
if (env_base['no_editor_splash']):
env_base.Append(CPPDEFINES=['NO_EDITOR_SPLASH'])
env_base.Append(CPPFLAGS=['-DNO_EDITOR_SPLASH'])
if not env_base['deprecated']:
env_base.Append(CPPDEFINES=['DISABLE_DEPRECATED'])
env_base.Append(CPPFLAGS=['-DDISABLE_DEPRECATED'])
env_base.platforms = {}
selected_platform = ""
if env_base['platform'] != "":
@ -254,9 +263,10 @@ elif env_base['p'] != "":
selected_platform = env_base['p']
env_base["platform"] = selected_platform
if selected_platform in platform_list:
tmppath = "./platform/" + selected_platform
sys.path.insert(0, tmppath)
sys.path.append("./platform/" + selected_platform)
import detect
if "create" in dir(detect):
env = detect.create(env_base)
@ -319,60 +329,45 @@ if selected_platform in platform_list:
# must happen after the flags, so when flags are used by configure, stuff happens (ie, ssl on x11)
detect.configure(env)
# Configure compiler warnings
if env.msvc:
# Truncations, narrowing conversions, signed/unsigned comparisons...
disable_nonessential_warnings = ['/wd4267', '/wd4244', '/wd4305', '/wd4018', '/wd4800']
if (env["warnings"] == 'yes'):
print("WARNING: warnings=yes is deprecated; assuming warnings=all")
env.msvc = 0
if (os.name == "nt" and os.getenv("VCINSTALLDIR") and (platform_arg == "windows" or platform_arg == "uwp")): # MSVC, needs to stand out of course
env.msvc = 1
disable_nonessential_warnings = ['/wd4267', '/wd4244', '/wd4305', '/wd4800'] # Truncations, narrowing conversions...
if (env["warnings"] == 'extra'):
env.Append(CCFLAGS=['/Wall']) # Implies /W4
elif (env["warnings"] == 'all'):
elif (env["warnings"] == 'all' or env["warnings"] == 'yes'):
env.Append(CCFLAGS=['/W3'] + disable_nonessential_warnings)
elif (env["warnings"] == 'moderate'):
# C4244 shouldn't be needed here being a level-3 warning, but it is
env.Append(CCFLAGS=['/W2'] + disable_nonessential_warnings)
else: # 'no'
env.Append(CCFLAGS=['/w'])
# Set exception handling model to avoid warnings caused by Windows system headers.
env.Append(CCFLAGS=['/EHsc'])
if (env["werror"]):
env.Append(CCFLAGS=['/WX'])
else: # Rest of the world
shadow_local_warning = []
all_plus_warnings = ['-Wwrite-strings']
if methods.using_gcc(env):
version = methods.get_compiler_version(env)
if version != None and version[0] >= '7':
shadow_local_warning = ['-Wshadow-local']
if (env["warnings"] == 'extra'):
# FIXME: enable -Wclobbered once #26351 is fixed
# Note: enable -Wimplicit-fallthrough for Clang (already part of -Wextra for GCC)
# once we switch to C++11 or later (necessary for our FALLTHROUGH macro).
env.Append(CCFLAGS=['-Wall', '-Wextra', '-Wno-unused-parameter'] + all_plus_warnings + shadow_local_warning)
if methods.using_gcc(env):
env['CCFLAGS'] += ['-Wno-clobbered']
elif (env["warnings"] == 'all'):
env.Append(CCFLAGS=['-Wall'] + shadow_local_warning)
env.Append(CCFLAGS=['-Wall', '-Wextra'])
elif (env["warnings"] == 'all' or env["warnings"] == 'yes'):
env.Append(CCFLAGS=['-Wall'])
elif (env["warnings"] == 'moderate'):
env.Append(CCFLAGS=['-Wall', '-Wno-unused'] + shadow_local_warning)
env.Append(CCFLAGS=['-Wall', '-Wno-unused'])
else: # 'no'
env.Append(CCFLAGS=['-w'])
if (env["werror"]):
env.Append(CCFLAGS=['-Werror'])
else: # always enable those errors
env.Append(CCFLAGS=['-Werror=return-type'])
env.Append(CCFLAGS=['-Werror=return-type'])
if (hasattr(detect, 'get_program_suffix')):
suffix = "." + detect.get_program_suffix()
else:
suffix = "." + selected_platform
#env['platform_libsuffix'] = env['LIBSUFFIX']
suffix = "." + selected_platform
if (env["target"] == "release"):
if env["tools"]:
print("Tools can only be built with targets 'debug' and 'release_debug'.")
sys.exit(255)
suffix += ".opt"
env.Append(CPPDEFINES=['NDEBUG'])
env.Append(CCFLAGS=['-DNDEBUG'])
elif (env["target"] == "release_debug"):
if env["tools"]:
@ -391,10 +386,12 @@ if selected_platform in platform_list:
suffix += ".32"
elif (env["bits"] == "64"):
suffix += ".64"
elif (env["bits"] == "fat"):
suffix += ".fat"
suffix += env.extra_suffix
sys.path.remove(tmppath)
sys.path.remove("./platform/" + selected_platform)
sys.modules.pop('detect')
env.module_list = []
@ -404,20 +401,10 @@ if selected_platform in platform_list:
if not env['module_' + x + '_enabled']:
continue
tmppath = "./modules/" + x
sys.path.insert(0, tmppath)
sys.path.append(tmppath)
env.current_module = x
import config
# can_build changed number of arguments between 3.0 (1) and 3.1 (2),
# so try both to preserve compatibility for 3.0 modules
can_build = False
try:
can_build = config.can_build(env, selected_platform)
except TypeError:
print("Warning: module '%s' uses a deprecated `can_build` "
"signature in its config.py file, it should be "
"`can_build(env, platform)`." % x)
can_build = config.can_build(selected_platform)
if (can_build):
if (config.can_build(selected_platform)):
config.configure(env)
env.module_list.append(x)
try:
@ -435,46 +422,35 @@ if selected_platform in platform_list:
env["PROGSUFFIX"] = suffix + env.module_version_string + env["PROGSUFFIX"]
env["OBJSUFFIX"] = suffix + env["OBJSUFFIX"]
# (SH)LIBSUFFIX will be used for our own built libraries
# LIBSUFFIXES contains LIBSUFFIX and SHLIBSUFFIX by default,
# so we need to append the default suffixes to keep the ability
# to link against thirdparty libraries (.a, .so, .lib, etc.).
if os.name == "nt":
# On Windows, only static libraries and import libraries can be
# statically linked - both using .lib extension
env["LIBSUFFIXES"] += [env["LIBSUFFIX"]]
else:
env["LIBSUFFIXES"] += [env["LIBSUFFIX"], env["SHLIBSUFFIX"]]
env["LIBSUFFIX"] = suffix + env["LIBSUFFIX"]
env["SHLIBSUFFIX"] = suffix + env["SHLIBSUFFIX"]
if (env.use_ptrcall):
env.Append(CPPDEFINES=['PTRCALL_ENABLED'])
env.Append(CPPFLAGS=['-DPTRCALL_ENABLED'])
# to test 64 bits compiltion
# env.Append(CPPFLAGS=['-m64'])
if env['tools']:
env.Append(CPPDEFINES=['TOOLS_ENABLED'])
env.Append(CPPFLAGS=['-DTOOLS_ENABLED'])
if env['disable_3d']:
if env['tools']:
print("Build option 'disable_3d=yes' cannot be used with 'tools=yes' (editor), only with 'tools=no' (export template).")
sys.exit(255)
else:
env.Append(CPPDEFINES=['_3D_DISABLED'])
env.Append(CPPFLAGS=['-D_3D_DISABLED'])
if env['gdscript']:
env.Append(CPPDEFINES=['GDSCRIPT_ENABLED'])
env.Append(CPPFLAGS=['-DGDSCRIPT_ENABLED'])
if env['disable_advanced_gui']:
if env['tools']:
print("Build option 'disable_advanced_gui=yes' cannot be used with 'tools=yes' (editor), only with 'tools=no' (export template).")
sys.exit(255)
else:
env.Append(CPPDEFINES=['ADVANCED_GUI_DISABLED'])
env.Append(CPPFLAGS=['-DADVANCED_GUI_DISABLED'])
if env['minizip']:
env.Append(CPPDEFINES=['MINIZIP_ENABLED'])
env.Append(CPPFLAGS=['-DMINIZIP_ENABLED'])
if env['xml']:
env.Append(CPPFLAGS=['-DXML_ENABLED'])
if not env['verbose']:
methods.no_verbose(sys, env)
if (not env["platform"] == "server"): # FIXME: detect GLES3
env.Append(BUILDERS = { 'GLES3_GLSL' : env.Builder(action=run_in_subprocess(gles_builders.build_gles3_headers), suffix='glsl.gen.h', src_suffix='.glsl')})
env.Append(BUILDERS = { 'GLES2_GLSL' : env.Builder(action=run_in_subprocess(gles_builders.build_gles2_headers), suffix='glsl.gen.h', src_suffix='.glsl')})
env.Append( BUILDERS = { 'GLES3_GLSL' : env.Builder(action = methods.build_gles3_headers, suffix = 'glsl.gen.h',src_suffix = '.glsl') } )
scons_cache_path = os.environ.get("SCONS_CACHE")
if scons_cache_path != None:
@ -508,15 +484,19 @@ if selected_platform in platform_list:
if ("check_c_headers" in env):
for header in env["check_c_headers"]:
if (conf.CheckCHeader(header[0])):
env.AppendUnique(CPPDEFINES=[header[1]])
if (env.msvc):
env.Append(CCFLAGS=['/D' + header[1]])
else:
env.Append(CCFLAGS=['-D' + header[1]])
else:
print("No valid target platform selected.")
print("The following platforms were detected:")
print("The following were detected:")
for x in platform_list:
print("\t" + x)
print("\nPlease run SCons again with the argument: platform=<string>")
print("\nPlease run scons again with argument: platform=<string>")
# The following only makes sense when the env is defined, and assumes it is
if 'env' in locals():
@ -565,7 +545,7 @@ if 'env' in locals():
[os.remove(f) for f in files]
def file_list(self):
if self.path is None:
if self.path == None:
# Nothing to do
return []
# Gather a list of (filename, (size, atime)) within the
@ -590,7 +570,7 @@ if 'env' in locals():
if sum > self.limit:
mark = i
break
if mark is None:
if mark == None:
return []
else:
return [x[0] for x in file_stat[mark:]]

View File

@ -16,8 +16,6 @@ if sys.version_info < (3,):
return x
def iteritems(d):
return d.iteritems()
def itervalues(d):
return d.itervalues()
def escape_string(s):
if isinstance(s, unicode):
s = s.encode('ascii')
@ -46,8 +44,6 @@ else:
return codecs.utf_8_decode(x)[0]
def iteritems(d):
return iter(d.items())
def itervalues(d):
return iter(d.values())
def charcode_to_c_escapes(c):
rev_result = []
while c >= 256:

View File

@ -2,13 +2,27 @@
Import('env')
import core_builders
import make_binders
from platform_methods import run_in_subprocess
env.core_sources = []
# Generate global defaults
gd_call = ""
gd_inc = ""
for x in env.global_defaults:
env.core_sources.append("#platform/" + x + "/globals/global_defaults.cpp")
gd_inc += '#include "platform/' + x + '/globals/global_defaults.h"\n'
gd_call += "\tregister_" + x + "_global_defaults();\n"
gd_cpp = '#include "project_settings.h"\n'
gd_cpp += gd_inc
gd_cpp += "void ProjectSettings::register_global_defaults() {\n" + gd_call + "\n}\n"
f = open("global_defaults.gen.cpp", "w")
f.write(gd_cpp)
f.close()
# Generate AES256 script encryption key
import os
txt = "0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0"
@ -33,141 +47,64 @@ if ("SCRIPT_AES256_ENCRYPTION_KEY" in os.environ):
txt = "0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0"
print("Invalid AES256 encryption key, not 64 bits hex: " + e)
# NOTE: It is safe to generate this file here, since this is still executed serially
with open("script_encryption_key.gen.cpp", "w") as f:
f.write("#include \"core/project_settings.h\"\nuint8_t script_encryption_key[32]={" + txt + "};\n")
f = open("script_encryption_key.gen.cpp", "w")
f.write("#include \"project_settings.h\"\nuint8_t script_encryption_key[32]={" + txt + "};\n")
f.close()
# Add required thirdparty code.
env_thirdparty = env.Clone()
env_thirdparty.disable_warnings()
# Misc thirdparty code: header paths are hardcoded, we don't need to append
# Add required thirdparty code. Header paths are hardcoded, we don't need to append
# to the include path (saves a few chars on the compiler invocation for touchy MSVC...)
thirdparty_misc_dir = "#thirdparty/misc/"
thirdparty_misc_sources = [
# C sources
"base64.c",
"fastlz.c",
"sha256.c",
"smaz.c",
thirdparty_dir = "#thirdparty/misc/"
thirdparty_sources = [
# C sources
"base64.c",
"fastlz.c",
"sha256.c",
"smaz.c",
# C++ sources
"aes256.cpp",
"hq2x.cpp",
"md5.cpp",
"pcg.cpp",
"triangulator.cpp",
# C++ sources
"aes256.cpp",
"hq2x.cpp",
"md5.cpp",
"pcg.cpp",
"triangulator.cpp",
]
thirdparty_misc_sources = [thirdparty_misc_dir + file for file in thirdparty_misc_sources]
env_thirdparty.add_source_files(env.core_sources, thirdparty_misc_sources)
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
env.add_source_files(env.core_sources, thirdparty_sources)
# Zlib library, can be unbundled
if env['builtin_zlib']:
thirdparty_zlib_dir = "#thirdparty/zlib/"
thirdparty_zlib_sources = [
"adler32.c",
"compress.c",
"crc32.c",
"deflate.c",
"infback.c",
"inffast.c",
"inflate.c",
"inftrees.c",
"trees.c",
"uncompr.c",
"zutil.c",
]
thirdparty_zlib_sources = [thirdparty_zlib_dir + file for file in thirdparty_zlib_sources]
env_thirdparty.Append(CPPPATH=[thirdparty_zlib_dir])
# Needs to be available in main env too
env.Append(CPPPATH=[thirdparty_zlib_dir])
env_thirdparty.add_source_files(env.core_sources, thirdparty_zlib_sources)
# Minizip library, could be unbundled in theory
# Minizip library, can be unbundled in theory
# However, our version has some custom modifications, so it won't compile with the system one
thirdparty_minizip_dir = "#thirdparty/minizip/"
thirdparty_minizip_sources = [
"ioapi.c",
"unzip.c",
"zip.c",
"ioapi.c",
"unzip.c",
"zip.c",
]
thirdparty_minizip_sources = [thirdparty_minizip_dir + file for file in thirdparty_minizip_sources]
env_thirdparty.add_source_files(env.core_sources, thirdparty_minizip_sources)
env.add_source_files(env.core_sources, thirdparty_minizip_sources)
# Zstd library, can be unbundled in theory
# though we currently use some private symbols
# https://github.com/godotengine/godot/issues/17374
if env['builtin_zstd']:
thirdparty_zstd_dir = "#thirdparty/zstd/"
thirdparty_zstd_sources = [
"common/debug.c",
"common/entropy_common.c",
"common/error_private.c",
"common/fse_decompress.c",
"common/pool.c",
"common/threading.c",
"common/xxhash.c",
"common/zstd_common.c",
"compress/fse_compress.c",
"compress/hist.c",
"compress/huf_compress.c",
"compress/zstd_compress.c",
"compress/zstd_double_fast.c",
"compress/zstd_fast.c",
"compress/zstd_lazy.c",
"compress/zstd_ldm.c",
"compress/zstd_opt.c",
"compress/zstdmt_compress.c",
"compress/zstd_compress_literals.c",
"compress/zstd_compress_sequences.c",
"decompress/huf_decompress.c",
"decompress/zstd_ddict.c",
"decompress/zstd_decompress_block.c",
"decompress/zstd_decompress.c",
]
thirdparty_zstd_sources = [thirdparty_zstd_dir + file for file in thirdparty_zstd_sources]
env_thirdparty.Append(CPPPATH=[thirdparty_zstd_dir, thirdparty_zstd_dir + "common"])
env_thirdparty.Append(CCFLAGS="-DZSTD_STATIC_LINKING_ONLY")
env.Append(CPPPATH=thirdparty_zstd_dir)
# Also needed in main env includes will trigger warnings
env.Append(CCFLAGS="-DZSTD_STATIC_LINKING_ONLY")
env_thirdparty.add_source_files(env.core_sources, thirdparty_zstd_sources)
if 'builtin_zstd' in env and env['builtin_zstd']:
SConscript("#thirdparty/zstd/SCsub")
# Godot's own sources
env.add_source_files(env.core_sources, "*.cpp")
# Certificates
env.Depends("#core/io/certs_compressed.gen.h", ["#thirdparty/certs/ca-certificates.crt", env.Value(env['builtin_certs']), env.Value(env['system_certs_path'])])
env.CommandNoCache("#core/io/certs_compressed.gen.h", "#thirdparty/certs/ca-certificates.crt", run_in_subprocess(core_builders.make_certs_header))
# Make binders
env.CommandNoCache(['method_bind.gen.inc', 'method_bind_ext.gen.inc'], 'make_binders.py', run_in_subprocess(make_binders.run))
import make_binders
env.CommandNoCache(['method_bind.gen.inc', 'method_bind_ext.gen.inc'], 'make_binders.py', make_binders.run)
# Authors
env.Depends('#core/authors.gen.h', "../AUTHORS.md")
env.CommandNoCache('#core/authors.gen.h', "../AUTHORS.md", run_in_subprocess(core_builders.make_authors_header))
# Donors
env.Depends('#core/donors.gen.h', "../DONORS.md")
env.CommandNoCache('#core/donors.gen.h', "../DONORS.md", run_in_subprocess(core_builders.make_donors_header))
# License
env.Depends('#core/license.gen.h', ["../COPYRIGHT.txt", "../LICENSE.txt"])
env.CommandNoCache('#core/license.gen.h', ["../COPYRIGHT.txt", "../LICENSE.txt"], run_in_subprocess(core_builders.make_license_header))
# Chain load SCsubs
SConscript('os/SCsub')
SConscript('math/SCsub')
SConscript('io/SCsub')
SConscript('bind/SCsub')
SConscript('helper/SCsub')
# Build it all as a library
lib = env.add_library("core", env.core_sources)
env.Prepend(LIBS=[lib])
Export('env')

194
core/allocators.h Normal file
View File

@ -0,0 +1,194 @@
/*************************************************************************/
/* allocators.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef ALLOCATORS_H
#define ALLOCATORS_H
#include "os/memory.h"
template <int PREALLOC_COUNT = 64, int MAX_HANDS = 8>
class BalloonAllocator {
enum {
USED_FLAG = (1 << 30),
USED_MASK = USED_FLAG - 1
};
struct Balloon {
Balloon *next;
Balloon *prev;
uint32_t hand;
};
struct Hand {
int used;
int allocated;
Balloon *first;
Balloon *last;
};
Hand hands[MAX_HANDS];
public:
void *alloc(size_t p_size) {
size_t max = (1 << MAX_HANDS);
ERR_FAIL_COND_V(p_size > max, NULL);
unsigned int hand = 0;
while (p_size > (size_t)(1 << hand))
++hand;
Hand &h = hands[hand];
if (h.used == h.allocated) {
for (int i = 0; i < PREALLOC_COUNT; i++) {
Balloon *b = (Balloon *)memalloc(sizeof(Balloon) + (1 << hand));
b->hand = hand;
if (h.last) {
b->prev = h.last;
h.last->next = b;
h.last = b;
} else {
b->prev = NULL;
h.last = b;
h.first = b;
}
}
h.last->next = NULL;
h.allocated += PREALLOC_COUNT;
}
Balloon *pick = h.last;
ERR_FAIL_COND_V((pick->hand & USED_FLAG), NULL);
// remove last
h.last = h.last->prev;
h.last->next = NULL;
pick->next = h.first;
h.first->prev = pick;
pick->prev = NULL;
h.first = pick;
h.used++;
pick->hand |= USED_FLAG;
return (void *)(pick + 1);
}
void free(void *p_ptr) {
Balloon *b = (Balloon *)p_ptr;
b -= 1;
ERR_FAIL_COND(!(b->hand & USED_FLAG));
b->hand = b->hand & USED_MASK; // not used
int hand = b->hand;
Hand &h = hands[hand];
if (b == h.first)
h.first = b->next;
if (b->prev)
b->prev->next = b->next;
if (b->next)
b->next->prev = b->prev;
if (h.last != b) {
h.last->next = b;
b->prev = h.last;
b->next = NULL;
h.last = b;
}
h.used--;
if (h.used <= (h.allocated - (PREALLOC_COUNT * 2))) { // this is done to ensure no alloc/free is done constantly
for (int i = 0; i < PREALLOC_COUNT; i++) {
ERR_CONTINUE(h.last->hand & USED_FLAG);
Balloon *new_last = h.last->prev;
if (new_last)
new_last->next = NULL;
memfree(h.last);
h.last = new_last;
}
h.allocated -= PREALLOC_COUNT;
}
}
BalloonAllocator() {
for (int i = 0; i < MAX_HANDS; i++) {
hands[i].allocated = 0;
hands[i].used = 0;
hands[i].first = NULL;
hands[i].last = NULL;
}
}
void clear() {
for (int i = 0; i < MAX_HANDS; i++) {
while (hands[i].first) {
Balloon *b = hands[i].first;
hands[i].first = b->next;
memfree(b);
}
hands[i].allocated = 0;
hands[i].used = 0;
hands[i].first = NULL;
hands[i].last = NULL;
}
}
~BalloonAllocator() {
clear();
}
};
#endif // ALLOCATORS_H

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -30,13 +30,13 @@
#include "array.h"
#include "core/hashfuncs.h"
#include "core/object.h"
#include "core/variant.h"
#include "core/vector.h"
#include "hashfuncs.h"
#include "object.h"
#include "variant.h"
#include "vector.h"
struct ArrayPrivate {
class ArrayPrivate {
public:
SafeRefCount refcount;
Vector<Variant> array;
};
@ -72,7 +72,7 @@ void Array::_unref() const {
Variant &Array::operator[](int p_idx) {
return _p->array.write[p_idx];
return _p->array[p_idx];
}
const Variant &Array::operator[](int p_idx) const {
@ -211,13 +211,13 @@ const Variant &Array::get(int p_idx) const {
return operator[](p_idx);
}
Array Array::duplicate(bool p_deep) const {
Array Array::duplicate() const {
Array new_arr;
int element_count = size();
new_arr.resize(element_count);
for (int i = 0; i < element_count; i++) {
new_arr[i] = p_deep ? get(i).duplicate(p_deep) : get(i);
new_arr[i] = get(i);
}
return new_arr;
@ -259,27 +259,13 @@ Array &Array::sort_custom(Object *p_obj, const StringName &p_function) {
ERR_FAIL_NULL_V(p_obj, *this);
SortArray<Variant, _ArrayVariantSortCustom, true> avs;
SortArray<Variant, _ArrayVariantSortCustom> avs;
avs.compare.obj = p_obj;
avs.compare.func = p_function;
avs.sort(_p->array.ptrw(), _p->array.size());
return *this;
}
void Array::shuffle() {
const int n = _p->array.size();
if (n < 2)
return;
Variant *data = _p->array.ptrw();
for (int i = n - 1; i >= 1; i--) {
const int j = Math::rand() % (i + 1);
const Variant tmp = data[j];
data[j] = data[i];
data[i] = tmp;
}
}
template <typename Less>
_FORCE_INLINE_ int bisect(const Vector<Variant> &p_array, const Variant &p_value, bool p_before, const Less &p_less) {
@ -355,58 +341,11 @@ Variant Array::pop_front() {
return Variant();
}
Variant Array::min() const {
Variant minval;
for (int i = 0; i < size(); i++) {
if (i == 0) {
minval = get(i);
} else {
bool valid;
Variant ret;
Variant test = get(i);
Variant::evaluate(Variant::OP_LESS, test, minval, ret, valid);
if (!valid) {
return Variant(); //not a valid comparison
}
if (bool(ret)) {
//is less
minval = test;
}
}
}
return minval;
}
Variant Array::max() const {
Variant maxval;
for (int i = 0; i < size(); i++) {
if (i == 0) {
maxval = get(i);
} else {
bool valid;
Variant ret;
Variant test = get(i);
Variant::evaluate(Variant::OP_GREATER, test, maxval, ret, valid);
if (!valid) {
return Variant(); //not a valid comparison
}
if (bool(ret)) {
//is less
maxval = test;
}
}
}
return maxval;
}
Array::Array(const Array &p_from) {
_p = NULL;
_ref(p_from);
}
Array::Array() {
_p = memnew(ArrayPrivate);

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -31,8 +31,7 @@
#ifndef ARRAY_H
#define ARRAY_H
#include "core/typedefs.h"
#include "typedefs.h"
class Variant;
class ArrayPrivate;
class Object;
@ -72,7 +71,6 @@ public:
Array &sort();
Array &sort_custom(Object *p_obj, const StringName &p_function);
void shuffle();
int bsearch(const Variant &p_value, bool p_before = true);
int bsearch_custom(const Variant &p_value, Object *p_obj, const StringName &p_function, bool p_before = true);
Array &invert();
@ -89,10 +87,7 @@ public:
Variant pop_back();
Variant pop_front();
Array duplicate(bool p_deep = false) const;
Variant min() const;
Variant max() const;
Array duplicate() const;
Array(const Array &p_from);
Array();

View File

@ -3,3 +3,5 @@
Import('env')
env.add_source_files(env.core_sources, "*.cpp")
Export('env')

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -30,14 +30,14 @@
#include "core_bind.h"
#include "core/io/file_access_compressed.h"
#include "core/io/file_access_encrypted.h"
#include "core/io/json.h"
#include "core/io/marshalls.h"
#include "core/math/geometry.h"
#include "core/os/keyboard.h"
#include "core/os/os.h"
#include "core/project_settings.h"
#include "geometry.h"
#include "io/file_access_compressed.h"
#include "io/file_access_encrypted.h"
#include "io/json.h"
#include "io/marshalls.h"
#include "os/keyboard.h"
#include "os/os.h"
#include "thirdparty/misc/base64.h"
@ -112,35 +112,20 @@ PoolStringArray _ResourceLoader::get_dependencies(const String &p_path) {
return ret;
};
#ifndef DISABLE_DEPRECATED
bool _ResourceLoader::has(const String &p_path) {
WARN_PRINTS("ResourceLoader.has() is deprecated, please replace it with the equivalent has_cached() or the new exists().");
return has_cached(p_path);
}
#endif // DISABLE_DEPRECATED
bool _ResourceLoader::has_cached(const String &p_path) {
String local_path = ProjectSettings::get_singleton()->localize_path(p_path);
return ResourceCache::has(local_path);
}
bool _ResourceLoader::exists(const String &p_path, const String &p_type_hint) {
return ResourceLoader::exists(p_path, p_type_hint);
}
};
void _ResourceLoader::_bind_methods() {
ClassDB::bind_method(D_METHOD("load_interactive", "path", "type_hint"), &_ResourceLoader::load_interactive, DEFVAL(""));
ClassDB::bind_method(D_METHOD("load", "path", "type_hint", "no_cache"), &_ResourceLoader::load, DEFVAL(""), DEFVAL(false));
ClassDB::bind_method(D_METHOD("load", "path", "type_hint", "p_no_cache"), &_ResourceLoader::load, DEFVAL(""), DEFVAL(false));
ClassDB::bind_method(D_METHOD("get_recognized_extensions_for_type", "type"), &_ResourceLoader::get_recognized_extensions_for_type);
ClassDB::bind_method(D_METHOD("set_abort_on_missing_resources", "abort"), &_ResourceLoader::set_abort_on_missing_resources);
ClassDB::bind_method(D_METHOD("get_dependencies", "path"), &_ResourceLoader::get_dependencies);
ClassDB::bind_method(D_METHOD("has_cached", "path"), &_ResourceLoader::has_cached);
ClassDB::bind_method(D_METHOD("exists", "path", "type_hint"), &_ResourceLoader::exists, DEFVAL(""));
#ifndef DISABLE_DEPRECATED
ClassDB::bind_method(D_METHOD("has", "path"), &_ResourceLoader::has);
#endif // DISABLE_DEPRECATED
}
_ResourceLoader::_ResourceLoader() {
@ -180,7 +165,6 @@ void _ResourceSaver::_bind_methods() {
BIND_ENUM_CONSTANT(FLAG_OMIT_EDITOR_PROPERTIES);
BIND_ENUM_CONSTANT(FLAG_SAVE_BIG_ENDIAN);
BIND_ENUM_CONSTANT(FLAG_COMPRESS);
BIND_ENUM_CONSTANT(FLAG_REPLACE_SUBRESOURCE_PATHS);
}
_ResourceSaver::_ResourceSaver() {
@ -221,38 +205,6 @@ String _OS::get_clipboard() const {
return OS::get_singleton()->get_clipboard();
}
int _OS::get_video_driver_count() const {
return OS::get_singleton()->get_video_driver_count();
}
String _OS::get_video_driver_name(VideoDriver p_driver) const {
return OS::get_singleton()->get_video_driver_name((int)p_driver);
}
_OS::VideoDriver _OS::get_current_video_driver() const {
return (VideoDriver)OS::get_singleton()->get_current_video_driver();
}
int _OS::get_audio_driver_count() const {
return OS::get_singleton()->get_audio_driver_count();
}
String _OS::get_audio_driver_name(int p_driver) const {
return OS::get_singleton()->get_audio_driver_name(p_driver);
}
PoolStringArray _OS::get_connected_midi_inputs() {
return OS::get_singleton()->get_connected_midi_inputs();
}
void _OS::open_midi_inputs() {
return OS::get_singleton()->open_midi_inputs();
}
void _OS::close_midi_inputs() {
return OS::get_singleton()->close_midi_inputs();
}
void _OS::set_video_mode(const Size2 &p_size, bool p_fullscreen, bool p_resizeable, int p_screen) {
OS::VideoMode vm;
@ -368,34 +320,13 @@ void _OS::set_borderless_window(bool p_borderless) {
OS::get_singleton()->set_borderless_window(p_borderless);
}
bool _OS::get_window_per_pixel_transparency_enabled() const {
return OS::get_singleton()->get_window_per_pixel_transparency_enabled();
}
void _OS::set_window_per_pixel_transparency_enabled(bool p_enabled) {
OS::get_singleton()->set_window_per_pixel_transparency_enabled(p_enabled);
}
bool _OS::get_borderless_window() const {
return OS::get_singleton()->get_borderless_window();
}
void _OS::set_ime_active(const bool p_active) {
OS::get_singleton()->set_ime_active(p_active);
}
void _OS::set_ime_position(const Point2 &p_pos) {
OS::get_singleton()->set_ime_position(p_pos);
}
Point2 _OS::get_ime_selection() const {
return OS::get_singleton()->get_ime_selection();
}
String _OS::get_ime_text() const {
return OS::get_singleton()->get_ime_text();
return OS::get_singleton()->set_ime_position(p_pos);
}
void _OS::set_use_file_access_save_and_swap(bool p_enable) {
@ -444,7 +375,7 @@ Error _OS::shell_open(String p_uri) {
int _OS::execute(const String &p_path, const Vector<String> &p_arguments, bool p_blocking, Array p_output) {
OS::ProcessID pid = -2;
OS::ProcessID pid;
List<String> args;
for (int i = 0; i < p_arguments.size(); i++)
args.push_back(p_arguments[i]);
@ -457,7 +388,6 @@ int _OS::execute(const String &p_path, const Vector<String> &p_arguments, bool p
else
return pid;
}
Error _OS::kill(int p_pid) {
return OS::get_singleton()->kill(p_pid);
@ -596,17 +526,17 @@ struct Time {
};
*/
uint64_t _OS::get_static_memory_usage() const {
int _OS::get_static_memory_usage() const {
return OS::get_singleton()->get_static_memory_usage();
}
uint64_t _OS::get_static_memory_peak_usage() const {
int _OS::get_static_memory_peak_usage() const {
return OS::get_singleton()->get_static_memory_peak_usage();
}
uint64_t _OS::get_dynamic_memory_usage() const {
int _OS::get_dynamic_memory_usage() const {
return OS::get_singleton()->get_dynamic_memory_usage();
}
@ -679,7 +609,7 @@ Dictionary _OS::get_time(bool utc) const {
*
* @return epoch calculated
*/
int64_t _OS::get_unix_time_from_datetime(Dictionary datetime) const {
uint64_t _OS::get_unix_time_from_datetime(Dictionary datetime) const {
// Bunch of conversion constants
static const unsigned int SECONDS_PER_MINUTE = 60;
@ -724,18 +654,13 @@ int64_t _OS::get_unix_time_from_datetime(Dictionary datetime) const {
// Calculate all the seconds from months past in this year
uint64_t SECONDS_FROM_MONTHS_PAST_THIS_YEAR = DAYS_PAST_THIS_YEAR_TABLE[LEAPYEAR(year)][month - 1] * SECONDS_PER_DAY;
int64_t SECONDS_FROM_YEARS_PAST = 0;
if (year >= EPOCH_YR) {
for (unsigned int iyear = EPOCH_YR; iyear < year; iyear++) {
SECONDS_FROM_YEARS_PAST += YEARSIZE(iyear) * SECONDS_PER_DAY;
}
} else {
for (unsigned int iyear = EPOCH_YR - 1; iyear >= year; iyear--) {
SECONDS_FROM_YEARS_PAST -= YEARSIZE(iyear) * SECONDS_PER_DAY;
}
uint64_t SECONDS_FROM_YEARS_PAST = 0;
for (unsigned int iyear = EPOCH_YR; iyear < year; iyear++) {
SECONDS_FROM_YEARS_PAST += YEARSIZE(iyear) * SECONDS_PER_DAY;
}
int64_t epoch =
uint64_t epoch =
second +
minute * SECONDS_PER_MINUTE +
hour * SECONDS_PER_HOUR +
@ -758,41 +683,39 @@ int64_t _OS::get_unix_time_from_datetime(Dictionary datetime) const {
*
* @return dictionary of date and time values
*/
Dictionary _OS::get_datetime_from_unix_time(int64_t unix_time_val) const {
Dictionary _OS::get_datetime_from_unix_time(uint64_t unix_time_val) const {
// Just fail if unix time is negative (when interpreted as an int).
// This means the user passed in a negative value by accident
ERR_EXPLAIN("unix_time_val was really huge!" + itos(unix_time_val) + " You probably passed in a negative value!");
ERR_FAIL_COND_V((int64_t)unix_time_val < 0, Dictionary());
OS::Date date;
OS::Time time;
long dayclock, dayno;
unsigned long dayclock, dayno;
int year = EPOCH_YR;
if (unix_time_val >= 0) {
dayno = unix_time_val / SECS_DAY;
dayclock = unix_time_val % SECS_DAY;
/* day 0 was a thursday */
date.weekday = static_cast<OS::Weekday>((dayno + 4) % 7);
while (dayno >= YEARSIZE(year)) {
dayno -= YEARSIZE(year);
year++;
}
} else {
dayno = (unix_time_val - SECS_DAY + 1) / SECS_DAY;
dayclock = unix_time_val - dayno * SECS_DAY;
date.weekday = static_cast<OS::Weekday>((dayno - 3) % 7 + 7);
do {
year--;
dayno += YEARSIZE(year);
} while (dayno < 0);
}
dayclock = (unsigned long)unix_time_val % SECS_DAY;
dayno = (unsigned long)unix_time_val / SECS_DAY;
time.sec = dayclock % 60;
time.min = (dayclock % 3600) / 60;
time.hour = dayclock / 3600;
/* day 0 was a thursday */
date.weekday = static_cast<OS::Weekday>((dayno + 4) % 7);
while (dayno >= YEARSIZE(year)) {
dayno -= YEARSIZE(year);
year++;
}
date.year = year;
size_t imonth = 0;
while ((unsigned long)dayno >= MONTH_DAYS_TABLE[LEAPYEAR(year)][imonth]) {
while (dayno >= MONTH_DAYS_TABLE[LEAPYEAR(year)][imonth]) {
dayno -= MONTH_DAYS_TABLE[LEAPYEAR(year)][imonth];
imonth++;
}
@ -831,10 +754,6 @@ uint64_t _OS::get_system_time_secs() const {
return OS::get_singleton()->get_system_time_secs();
}
uint64_t _OS::get_system_time_msecs() const {
return OS::get_singleton()->get_system_time_msecs();
}
void _OS::delay_usec(uint32_t p_usec) const {
OS::get_singleton()->delay_usec(p_usec);
@ -850,11 +769,6 @@ uint32_t _OS::get_ticks_msec() const {
return OS::get_singleton()->get_ticks_msec();
}
uint64_t _OS::get_ticks_usec() const {
return OS::get_singleton()->get_ticks_usec();
}
uint32_t _OS::get_splash_tick_msec() const {
return OS::get_singleton()->get_splash_tick_msec();
@ -1036,11 +950,6 @@ void _OS::center_window() {
OS::get_singleton()->center_window();
}
void _OS::move_window_to_foreground() {
OS::get_singleton()->move_window_to_foreground();
}
bool _OS::is_debug_build() const {
#ifdef DEBUG_ENABLED
@ -1093,11 +1002,6 @@ void _OS::alert(const String &p_alert, const String &p_title) {
OS::get_singleton()->alert(p_alert, p_title);
}
bool _OS::request_permission(const String &p_name) {
return OS::get_singleton()->request_permission(p_name);
}
_OS *_OS::singleton = NULL;
void _OS::_bind_methods() {
@ -1115,16 +1019,6 @@ void _OS::_bind_methods() {
//ClassDB::bind_method(D_METHOD("is_video_mode_resizable","screen"),&_OS::is_video_mode_resizable,DEFVAL(0));
//ClassDB::bind_method(D_METHOD("get_fullscreen_mode_list","screen"),&_OS::get_fullscreen_mode_list,DEFVAL(0));
ClassDB::bind_method(D_METHOD("get_video_driver_count"), &_OS::get_video_driver_count);
ClassDB::bind_method(D_METHOD("get_video_driver_name", "driver"), &_OS::get_video_driver_name);
ClassDB::bind_method(D_METHOD("get_current_video_driver"), &_OS::get_current_video_driver);
ClassDB::bind_method(D_METHOD("get_audio_driver_count"), &_OS::get_audio_driver_count);
ClassDB::bind_method(D_METHOD("get_audio_driver_name", "driver"), &_OS::get_audio_driver_name);
ClassDB::bind_method(D_METHOD("get_connected_midi_inputs"), &_OS::get_connected_midi_inputs);
ClassDB::bind_method(D_METHOD("open_midi_inputs"), &_OS::open_midi_inputs);
ClassDB::bind_method(D_METHOD("close_midi_inputs"), &_OS::close_midi_inputs);
ClassDB::bind_method(D_METHOD("get_screen_count"), &_OS::get_screen_count);
ClassDB::bind_method(D_METHOD("get_current_screen"), &_OS::get_current_screen);
ClassDB::bind_method(D_METHOD("set_current_screen", "screen"), &_OS::set_current_screen);
@ -1149,18 +1043,11 @@ void _OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("request_attention"), &_OS::request_attention);
ClassDB::bind_method(D_METHOD("get_real_window_size"), &_OS::get_real_window_size);
ClassDB::bind_method(D_METHOD("center_window"), &_OS::center_window);
ClassDB::bind_method(D_METHOD("move_window_to_foreground"), &_OS::move_window_to_foreground);
ClassDB::bind_method(D_METHOD("set_borderless_window", "borderless"), &_OS::set_borderless_window);
ClassDB::bind_method(D_METHOD("get_borderless_window"), &_OS::get_borderless_window);
ClassDB::bind_method(D_METHOD("get_window_per_pixel_transparency_enabled"), &_OS::get_window_per_pixel_transparency_enabled);
ClassDB::bind_method(D_METHOD("set_window_per_pixel_transparency_enabled", "enabled"), &_OS::set_window_per_pixel_transparency_enabled);
ClassDB::bind_method(D_METHOD("set_ime_active", "active"), &_OS::set_ime_active);
ClassDB::bind_method(D_METHOD("set_ime_position", "position"), &_OS::set_ime_position);
ClassDB::bind_method(D_METHOD("get_ime_selection"), &_OS::get_ime_selection);
ClassDB::bind_method(D_METHOD("get_ime_text"), &_OS::get_ime_text);
ClassDB::bind_method(D_METHOD("set_screen_orientation", "orientation"), &_OS::set_screen_orientation);
ClassDB::bind_method(D_METHOD("get_screen_orientation"), &_OS::get_screen_orientation);
@ -1197,7 +1084,6 @@ void _OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_datetime_from_unix_time", "unix_time_val"), &_OS::get_datetime_from_unix_time);
ClassDB::bind_method(D_METHOD("get_unix_time_from_datetime", "datetime"), &_OS::get_unix_time_from_datetime);
ClassDB::bind_method(D_METHOD("get_system_time_secs"), &_OS::get_system_time_secs);
ClassDB::bind_method(D_METHOD("get_system_time_msecs"), &_OS::get_system_time_msecs);
ClassDB::bind_method(D_METHOD("set_icon", "icon"), &_OS::set_icon);
@ -1207,7 +1093,6 @@ void _OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("delay_usec", "usec"), &_OS::delay_usec);
ClassDB::bind_method(D_METHOD("delay_msec", "msec"), &_OS::delay_msec);
ClassDB::bind_method(D_METHOD("get_ticks_msec"), &_OS::get_ticks_msec);
ClassDB::bind_method(D_METHOD("get_ticks_usec"), &_OS::get_ticks_usec);
ClassDB::bind_method(D_METHOD("get_splash_tick_msec"), &_OS::get_splash_tick_msec);
ClassDB::bind_method(D_METHOD("get_locale"), &_OS::get_locale);
ClassDB::bind_method(D_METHOD("get_latin_keyboard_variant"), &_OS::get_latin_keyboard_variant);
@ -1270,8 +1155,6 @@ void _OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_power_seconds_left"), &_OS::get_power_seconds_left);
ClassDB::bind_method(D_METHOD("get_power_percent_left"), &_OS::get_power_percent_left);
ClassDB::bind_method(D_METHOD("request_permission", "name"), &_OS::request_permission);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "clipboard"), "set_clipboard", "get_clipboard");
ADD_PROPERTY(PropertyInfo(Variant::INT, "current_screen"), "set_current_screen", "get_current_screen");
ADD_PROPERTY(PropertyInfo(Variant::INT, "exit_code"), "set_exit_code", "get_exit_code");
@ -1281,7 +1164,6 @@ void _OS::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "screen_orientation", PROPERTY_HINT_ENUM, "Landscape,Portrait,Reverse Landscape,Reverse Portrait,Sensor Landscape,Sensor Portrait,Sensor"), "set_screen_orientation", "get_screen_orientation");
ADD_GROUP("Window", "window_");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "window_borderless"), "set_borderless_window", "get_borderless_window");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "window_per_pixel_transparency_enabled"), "set_window_per_pixel_transparency_enabled", "get_window_per_pixel_transparency_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "window_fullscreen"), "set_window_fullscreen", "is_window_fullscreen");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "window_maximized"), "set_window_maximized", "is_window_maximized");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "window_minimized"), "set_window_minimized", "is_window_minimized");
@ -1289,9 +1171,6 @@ void _OS::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "window_position"), "set_window_position", "get_window_position");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "window_size"), "set_window_size", "get_window_size");
BIND_ENUM_CONSTANT(VIDEO_DRIVER_GLES2);
BIND_ENUM_CONSTANT(VIDEO_DRIVER_GLES3);
BIND_ENUM_CONSTANT(DAY_SUNDAY);
BIND_ENUM_CONSTANT(DAY_MONDAY);
BIND_ENUM_CONSTANT(DAY_TUESDAY);
@ -1381,16 +1260,6 @@ Variant _Geometry::segment_intersects_segment_2d(const Vector2 &p_from_a, const
};
};
Variant _Geometry::line_intersects_line_2d(const Vector2 &p_from_a, const Vector2 &p_dir_a, const Vector2 &p_from_b, const Vector2 &p_dir_b) {
Vector2 result;
if (Geometry::line_intersects_line_2d(p_from_a, p_dir_a, p_from_b, p_dir_b, result)) {
return result;
} else {
return Variant();
}
}
PoolVector<Vector2> _Geometry::get_closest_points_between_segments_2d(const Vector2 &p1, const Vector2 &q1, const Vector2 &p2, const Vector2 &q2) {
Vector2 r1, r2;
@ -1546,7 +1415,6 @@ void _Geometry::_bind_methods() {
ClassDB::bind_method(D_METHOD("build_capsule_planes", "radius", "height", "sides", "lats", "axis"), &_Geometry::build_capsule_planes, DEFVAL(Vector3::AXIS_Z));
ClassDB::bind_method(D_METHOD("segment_intersects_circle", "segment_from", "segment_to", "circle_position", "circle_radius"), &_Geometry::segment_intersects_circle);
ClassDB::bind_method(D_METHOD("segment_intersects_segment_2d", "from_a", "to_a", "from_b", "to_b"), &_Geometry::segment_intersects_segment_2d);
ClassDB::bind_method(D_METHOD("line_intersects_line_2d", "from_a", "dir_a", "from_b", "dir_b"), &_Geometry::line_intersects_line_2d);
ClassDB::bind_method(D_METHOD("get_closest_points_between_segments_2d", "p1", "q1", "p2", "q2"), &_Geometry::get_closest_points_between_segments_2d);
ClassDB::bind_method(D_METHOD("get_closest_points_between_segments", "p1", "p2", "q1", "q2"), &_Geometry::get_closest_points_between_segments);
@ -1786,9 +1654,9 @@ String _File::get_line() const {
return f->get_line();
}
Vector<String> _File::get_csv_line(const String &p_delim) const {
Vector<String> _File::get_csv_line(String delim) const {
ERR_FAIL_COND_V(!f, Vector<String>());
return f->get_csv_line(p_delim);
return f->get_csv_line(delim);
}
/**< use this for files WRITTEN in _big_ endian machines (ie, amiga/mac)
@ -1885,11 +1753,6 @@ void _File::store_line(const String &p_string) {
f->store_line(p_string);
}
void _File::store_csv_line(const Vector<String> &p_values, const String &p_delim) {
ERR_FAIL_COND(!f);
f->store_csv_line(p_values, p_delim);
}
void _File::store_buffer(const PoolVector<uint8_t> &p_buffer) {
ERR_FAIL_COND(!f);
@ -1908,18 +1771,18 @@ bool _File::file_exists(const String &p_name) const {
return FileAccess::exists(p_name);
}
void _File::store_var(const Variant &p_var, bool p_full_objects) {
void _File::store_var(const Variant &p_var) {
ERR_FAIL_COND(!f);
int len;
Error err = encode_variant(p_var, NULL, len, p_full_objects);
Error err = encode_variant(p_var, NULL, len);
ERR_FAIL_COND(err != OK);
PoolVector<uint8_t> buff;
buff.resize(len);
PoolVector<uint8_t>::Write w = buff.write();
err = encode_variant(p_var, &w[0], len, p_full_objects);
err = encode_variant(p_var, &w[0], len);
ERR_FAIL_COND(err != OK);
w = PoolVector<uint8_t>::Write();
@ -1927,7 +1790,7 @@ void _File::store_var(const Variant &p_var, bool p_full_objects) {
store_buffer(buff);
}
Variant _File::get_var(bool p_allow_objects) const {
Variant _File::get_var() const {
ERR_FAIL_COND_V(!f, Variant());
uint32_t len = get_32();
@ -1937,7 +1800,7 @@ Variant _File::get_var(bool p_allow_objects) const {
PoolVector<uint8_t>::Read r = buff.read();
Variant v;
Error err = decode_variant(v, &r[0], len, NULL, p_allow_objects);
Error err = decode_variant(v, &r[0], len);
ERR_FAIL_COND_V(err != OK, Variant());
return v;
@ -1973,14 +1836,14 @@ void _File::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_real"), &_File::get_real);
ClassDB::bind_method(D_METHOD("get_buffer", "len"), &_File::get_buffer);
ClassDB::bind_method(D_METHOD("get_line"), &_File::get_line);
ClassDB::bind_method(D_METHOD("get_csv_line", "delim"), &_File::get_csv_line, DEFVAL(","));
ClassDB::bind_method(D_METHOD("get_as_text"), &_File::get_as_text);
ClassDB::bind_method(D_METHOD("get_md5", "path"), &_File::get_md5);
ClassDB::bind_method(D_METHOD("get_sha256", "path"), &_File::get_sha256);
ClassDB::bind_method(D_METHOD("get_endian_swap"), &_File::get_endian_swap);
ClassDB::bind_method(D_METHOD("set_endian_swap", "enable"), &_File::set_endian_swap);
ClassDB::bind_method(D_METHOD("get_error"), &_File::get_error);
ClassDB::bind_method(D_METHOD("get_var", "allow_objects"), &_File::get_var, DEFVAL(false));
ClassDB::bind_method(D_METHOD("get_var"), &_File::get_var);
ClassDB::bind_method(D_METHOD("get_csv_line", "delim"), &_File::get_csv_line, DEFVAL(","));
ClassDB::bind_method(D_METHOD("store_8", "value"), &_File::store_8);
ClassDB::bind_method(D_METHOD("store_16", "value"), &_File::store_16);
@ -1991,9 +1854,8 @@ void _File::_bind_methods() {
ClassDB::bind_method(D_METHOD("store_real", "value"), &_File::store_real);
ClassDB::bind_method(D_METHOD("store_buffer", "buffer"), &_File::store_buffer);
ClassDB::bind_method(D_METHOD("store_line", "line"), &_File::store_line);
ClassDB::bind_method(D_METHOD("store_csv_line", "values", "delim"), &_File::store_csv_line, DEFVAL(","));
ClassDB::bind_method(D_METHOD("store_string", "string"), &_File::store_string);
ClassDB::bind_method(D_METHOD("store_var", "value", "full_objects"), &_File::store_var, DEFVAL(false));
ClassDB::bind_method(D_METHOD("store_var", "value"), &_File::store_var);
ClassDB::bind_method(D_METHOD("store_pascal_string", "string"), &_File::store_pascal_string);
ClassDB::bind_method(D_METHOD("get_pascal_string"), &_File::get_pascal_string);
@ -2223,17 +2085,17 @@ _Marshalls *_Marshalls::get_singleton() {
return singleton;
}
String _Marshalls::variant_to_base64(const Variant &p_var, bool p_full_objects) {
String _Marshalls::variant_to_base64(const Variant &p_var) {
int len;
Error err = encode_variant(p_var, NULL, len, p_full_objects);
Error err = encode_variant(p_var, NULL, len);
ERR_FAIL_COND_V(err != OK, "");
PoolVector<uint8_t> buff;
buff.resize(len);
PoolVector<uint8_t>::Write w = buff.write();
err = encode_variant(p_var, &w[0], len, p_full_objects);
err = encode_variant(p_var, &w[0], len);
ERR_FAIL_COND_V(err != OK, "");
int b64len = len / 3 * 4 + 4 + 1;
@ -2249,7 +2111,7 @@ String _Marshalls::variant_to_base64(const Variant &p_var, bool p_full_objects)
return ret;
};
Variant _Marshalls::base64_to_variant(const String &p_str, bool p_allow_objects) {
Variant _Marshalls::base64_to_variant(const String &p_str) {
int strlen = p_str.length();
CharString cstr = p_str.ascii();
@ -2261,7 +2123,7 @@ Variant _Marshalls::base64_to_variant(const String &p_str, bool p_allow_objects)
int len = base64_decode((char *)(&w[0]), (char *)cstr.get_data(), strlen);
Variant v;
Error err = decode_variant(v, &w[0], len, NULL, p_allow_objects);
Error err = decode_variant(v, &w[0], len);
ERR_FAIL_COND_V(err != OK, Variant());
return v;
@ -2340,8 +2202,8 @@ String _Marshalls::base64_to_utf8(const String &p_str) {
void _Marshalls::_bind_methods() {
ClassDB::bind_method(D_METHOD("variant_to_base64", "variant", "full_objects"), &_Marshalls::variant_to_base64, DEFVAL(false));
ClassDB::bind_method(D_METHOD("base64_to_variant", "base64_str", "allow_objects"), &_Marshalls::base64_to_variant, DEFVAL(false));
ClassDB::bind_method(D_METHOD("variant_to_base64", "variant"), &_Marshalls::variant_to_base64);
ClassDB::bind_method(D_METHOD("base64_to_variant", "base64_str"), &_Marshalls::base64_to_variant);
ClassDB::bind_method(D_METHOD("raw_to_base64", "array"), &_Marshalls::raw_to_base64);
ClassDB::bind_method(D_METHOD("base64_to_raw", "base64_str"), &_Marshalls::base64_to_raw);
@ -2439,7 +2301,7 @@ void _Thread::_start_func(void *ud) {
} break;
case Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS: {
reason = "Too Few Arguments";
reason = "Too Many Arguments";
} break;
case Variant::CallError::CALL_ERROR_INVALID_METHOD: {
@ -2532,7 +2394,7 @@ _Thread::~_Thread() {
if (active) {
ERR_EXPLAIN("Reference to a Thread object object was lost while the thread is still running...");
}
ERR_FAIL_COND(active);
ERR_FAIL_COND(active == true);
}
/////////////////////////////////////
@ -2758,14 +2620,6 @@ int _Engine::get_iterations_per_second() const {
return Engine::get_singleton()->get_iterations_per_second();
}
void _Engine::set_physics_jitter_fix(float p_threshold) {
Engine::get_singleton()->set_physics_jitter_fix(p_threshold);
}
float _Engine::get_physics_jitter_fix() const {
return Engine::get_singleton()->get_physics_jitter_fix();
}
void _Engine::set_target_fps(int p_fps) {
Engine::get_singleton()->set_target_fps(p_fps);
}
@ -2804,26 +2658,6 @@ Dictionary _Engine::get_version_info() const {
return Engine::get_singleton()->get_version_info();
}
Dictionary _Engine::get_author_info() const {
return Engine::get_singleton()->get_author_info();
}
Array _Engine::get_copyright_info() const {
return Engine::get_singleton()->get_copyright_info();
}
Dictionary _Engine::get_donor_info() const {
return Engine::get_singleton()->get_donor_info();
}
Dictionary _Engine::get_license_info() const {
return Engine::get_singleton()->get_license_info();
}
String _Engine::get_license_text() const {
return Engine::get_singleton()->get_license_text();
}
bool _Engine::is_in_physics_frame() const {
return Engine::get_singleton()->is_in_physics_frame();
}
@ -2852,8 +2686,6 @@ void _Engine::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_iterations_per_second", "iterations_per_second"), &_Engine::set_iterations_per_second);
ClassDB::bind_method(D_METHOD("get_iterations_per_second"), &_Engine::get_iterations_per_second);
ClassDB::bind_method(D_METHOD("set_physics_jitter_fix", "physics_jitter_fix"), &_Engine::set_physics_jitter_fix);
ClassDB::bind_method(D_METHOD("get_physics_jitter_fix"), &_Engine::get_physics_jitter_fix);
ClassDB::bind_method(D_METHOD("set_target_fps", "target_fps"), &_Engine::set_target_fps);
ClassDB::bind_method(D_METHOD("get_target_fps"), &_Engine::get_target_fps);
@ -2866,11 +2698,6 @@ void _Engine::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_main_loop"), &_Engine::get_main_loop);
ClassDB::bind_method(D_METHOD("get_version_info"), &_Engine::get_version_info);
ClassDB::bind_method(D_METHOD("get_author_info"), &_Engine::get_author_info);
ClassDB::bind_method(D_METHOD("get_copyright_info"), &_Engine::get_copyright_info);
ClassDB::bind_method(D_METHOD("get_donor_info"), &_Engine::get_donor_info);
ClassDB::bind_method(D_METHOD("get_license_info"), &_Engine::get_license_info);
ClassDB::bind_method(D_METHOD("get_license_text"), &_Engine::get_license_text);
ClassDB::bind_method(D_METHOD("is_in_physics_frame"), &_Engine::is_in_physics_frame);
@ -2884,7 +2711,6 @@ void _Engine::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "iterations_per_second"), "set_iterations_per_second", "get_iterations_per_second");
ADD_PROPERTY(PropertyInfo(Variant::INT, "target_fps"), "set_target_fps", "get_target_fps");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "time_scale"), "set_time_scale", "get_time_scale");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "physics_jitter_fix"), "set_physics_jitter_fix", "get_physics_jitter_fix");
}
_Engine *_Engine::singleton = NULL;
@ -2904,10 +2730,10 @@ void JSONParseResult::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_error_line", "error_line"), &JSONParseResult::set_error_line);
ClassDB::bind_method(D_METHOD("set_result", "result"), &JSONParseResult::set_result);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "error", PROPERTY_HINT_NONE, "Error", PROPERTY_USAGE_CLASS_IS_ENUM), "set_error", "get_error");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "error_string"), "set_error_string", "get_error_string");
ADD_PROPERTY(PropertyInfo(Variant::INT, "error_line"), "set_error_line", "get_error_line");
ADD_PROPERTY(PropertyInfo(Variant::NIL, "result", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NIL_IS_VARIANT), "set_result", "get_result");
ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "error", PROPERTY_HINT_NONE, "Error", PROPERTY_USAGE_CLASS_IS_ENUM), "set_error", "get_error");
ADD_PROPERTYNZ(PropertyInfo(Variant::STRING, "error_string"), "set_error_string", "get_error_string");
ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "error_line"), "set_error_line", "get_error_line");
ADD_PROPERTYNZ(PropertyInfo(Variant::NIL, "result", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NIL_IS_VARIANT), "set_result", "get_result");
}
void JSONParseResult::set_error(Error p_error) {

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -31,15 +31,15 @@
#ifndef CORE_BIND_H
#define CORE_BIND_H
#include "core/image.h"
#include "core/io/compression.h"
#include "core/io/resource_loader.h"
#include "core/io/resource_saver.h"
#include "core/os/dir_access.h"
#include "core/os/file_access.h"
#include "core/os/os.h"
#include "core/os/semaphore.h"
#include "core/os/thread.h"
#include "image.h"
#include "io/compression.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
#include "os/dir_access.h"
#include "os/file_access.h"
#include "os/os.h"
#include "os/semaphore.h"
#include "os/thread.h"
class _ResourceLoader : public Object {
GDCLASS(_ResourceLoader, Object);
@ -55,11 +55,7 @@ public:
PoolVector<String> get_recognized_extensions_for_type(const String &p_type);
void set_abort_on_missing_resources(bool p_abort);
PoolStringArray get_dependencies(const String &p_path);
#ifndef DISABLE_DEPRECATED
bool has(const String &p_path);
#endif // DISABLE_DEPRECATED
bool has_cached(const String &p_path);
bool exists(const String &p_path, const String &p_type_hint = "");
_ResourceLoader();
};
@ -80,7 +76,6 @@ public:
FLAG_OMIT_EDITOR_PROPERTIES = 8,
FLAG_SAVE_BIG_ENDIAN = 16,
FLAG_COMPRESS = 32,
FLAG_REPLACE_SUBRESOURCE_PATHS = 64,
};
static _ResourceSaver *get_singleton() { return singleton; }
@ -103,11 +98,6 @@ protected:
static _OS *singleton;
public:
enum VideoDriver {
VIDEO_DRIVER_GLES3,
VIDEO_DRIVER_GLES2,
};
enum PowerState {
POWERSTATE_UNKNOWN, /**< cannot determine power status */
POWERSTATE_ON_BATTERY, /**< Not plugged in, running on the battery */
@ -156,17 +146,6 @@ public:
bool is_video_mode_resizable(int p_screen = 0) const;
Array get_fullscreen_mode_list(int p_screen = 0) const;
virtual int get_video_driver_count() const;
virtual String get_video_driver_name(VideoDriver p_driver) const;
virtual VideoDriver get_current_video_driver() const;
virtual int get_audio_driver_count() const;
virtual String get_audio_driver_name(int p_driver) const;
virtual PoolStringArray get_connected_midi_inputs();
virtual void open_midi_inputs();
virtual void close_midi_inputs();
virtual int get_screen_count() const;
virtual int get_current_screen() const;
virtual void set_current_screen(int p_screen);
@ -191,18 +170,11 @@ public:
virtual bool is_window_always_on_top() const;
virtual void request_attention();
virtual void center_window();
virtual void move_window_to_foreground();
virtual void set_borderless_window(bool p_borderless);
virtual bool get_borderless_window() const;
virtual bool get_window_per_pixel_transparency_enabled() const;
virtual void set_window_per_pixel_transparency_enabled(bool p_enabled);
virtual void set_ime_active(const bool p_active);
virtual void set_ime_position(const Point2 &p_pos);
virtual Point2 get_ime_selection() const;
virtual String get_ime_text() const;
Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track);
bool native_video_is_playing();
@ -282,21 +254,19 @@ public:
Dictionary get_date(bool utc) const;
Dictionary get_time(bool utc) const;
Dictionary get_datetime(bool utc) const;
Dictionary get_datetime_from_unix_time(int64_t unix_time_val) const;
int64_t get_unix_time_from_datetime(Dictionary datetime) const;
Dictionary get_datetime_from_unix_time(uint64_t unix_time_val) const;
uint64_t get_unix_time_from_datetime(Dictionary datetime) const;
Dictionary get_time_zone_info() const;
uint64_t get_unix_time() const;
uint64_t get_system_time_secs() const;
uint64_t get_system_time_msecs() const;
uint64_t get_static_memory_usage() const;
uint64_t get_static_memory_peak_usage() const;
uint64_t get_dynamic_memory_usage() const;
int get_static_memory_usage() const;
int get_static_memory_peak_usage() const;
int get_dynamic_memory_usage() const;
void delay_usec(uint32_t p_usec) const;
void delay_msec(uint32_t p_msec) const;
uint32_t get_ticks_msec() const;
uint64_t get_ticks_usec() const;
uint32_t get_splash_tick_msec() const;
bool can_use_threads() const;
@ -356,14 +326,11 @@ public:
bool has_feature(const String &p_feature) const;
bool request_permission(const String &p_name);
static _OS *get_singleton() { return singleton; }
_OS();
};
VARIANT_ENUM_CAST(_OS::VideoDriver);
VARIANT_ENUM_CAST(_OS::PowerState);
VARIANT_ENUM_CAST(_OS::Weekday);
VARIANT_ENUM_CAST(_OS::Month);
@ -385,7 +352,6 @@ public:
PoolVector<Plane> build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis = Vector3::AXIS_Z);
PoolVector<Plane> build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis = Vector3::AXIS_Z);
Variant segment_intersects_segment_2d(const Vector2 &p_from_a, const Vector2 &p_to_a, const Vector2 &p_from_b, const Vector2 &p_to_b);
Variant line_intersects_line_2d(const Vector2 &p_from_a, const Vector2 &p_dir_a, const Vector2 &p_from_b, const Vector2 &p_dir_b);
PoolVector<Vector2> get_closest_points_between_segments_2d(const Vector2 &p1, const Vector2 &q1, const Vector2 &p2, const Vector2 &q2);
PoolVector<Vector3> get_closest_points_between_segments(const Vector3 &p1, const Vector3 &p2, const Vector3 &q1, const Vector3 &q2);
Vector2 get_closest_point_to_segment_2d(const Vector2 &p_point, const Vector2 &p_a, const Vector2 &p_b);
@ -463,11 +429,10 @@ public:
double get_double() const;
real_t get_real() const;
Variant get_var(bool p_allow_objects = false) const;
Variant get_var() const;
PoolVector<uint8_t> get_buffer(int p_length) const; ///< get an array of bytes
String get_line() const;
Vector<String> get_csv_line(const String &p_delim = ",") const;
String get_as_text() const;
String get_md5(const String &p_path) const;
String get_sha256(const String &p_path) const;
@ -493,14 +458,15 @@ public:
void store_string(const String &p_string);
void store_line(const String &p_string);
void store_csv_line(const Vector<String> &p_values, const String &p_delim = ",");
virtual void store_pascal_string(const String &p_string);
virtual String get_pascal_string();
Vector<String> get_csv_line(String delim = ",") const;
void store_buffer(const PoolVector<uint8_t> &p_buffer); ///< store an array of bytes
void store_var(const Variant &p_var, bool p_full_objects = false);
void store_var(const Variant &p_var);
bool file_exists(const String &p_name) const; ///< return true if a file exists
@ -569,8 +535,8 @@ protected:
public:
static _Marshalls *get_singleton();
String variant_to_base64(const Variant &p_var, bool p_full_objects = false);
Variant base64_to_variant(const String &p_str, bool p_allow_objects = false);
String variant_to_base64(const Variant &p_var);
Variant base64_to_variant(const String &p_str);
String raw_to_base64(const PoolVector<uint8_t> &p_arr);
PoolVector<uint8_t> base64_to_raw(const String &p_str);
@ -697,9 +663,6 @@ public:
void set_iterations_per_second(int p_ips);
int get_iterations_per_second() const;
void set_physics_jitter_fix(float p_threshold);
float get_physics_jitter_fix() const;
void set_target_fps(int p_fps);
int get_target_fps() const;
@ -713,11 +676,6 @@ public:
MainLoop *get_main_loop() const;
Dictionary get_version_info() const;
Dictionary get_author_info() const;
Array get_copyright_info() const;
Dictionary get_donor_info() const;
Dictionary get_license_info() const;
String get_license_text() const;
bool is_in_physics_frame() const;

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -30,13 +30,21 @@
#include "class_db.h"
#include "core/engine.h"
#include "core/os/mutex.h"
#include "core/version.h"
#include "os/mutex.h"
#include "version.h"
#ifdef NO_THREADS
#define OBJTYPE_RLOCK
#define OBJTYPE_WLOCK
#else
#define OBJTYPE_RLOCK RWLockRead _rw_lockr_(lock);
#define OBJTYPE_WLOCK RWLockWrite _rw_lockw_(lock);
#endif
#ifdef DEBUG_METHODS_ENABLED
MethodDefinition D_METHOD(const char *p_name) {
@ -59,8 +67,8 @@ MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_
MethodDefinition md;
md.name = StaticCString::create(p_name);
md.args.resize(2);
md.args.write[0] = StaticCString::create(p_arg1);
md.args.write[1] = StaticCString::create(p_arg2);
md.args[0] = StaticCString::create(p_arg1);
md.args[1] = StaticCString::create(p_arg2);
return md;
}
@ -69,9 +77,9 @@ MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_
MethodDefinition md;
md.name = StaticCString::create(p_name);
md.args.resize(3);
md.args.write[0] = StaticCString::create(p_arg1);
md.args.write[1] = StaticCString::create(p_arg2);
md.args.write[2] = StaticCString::create(p_arg3);
md.args[0] = StaticCString::create(p_arg1);
md.args[1] = StaticCString::create(p_arg2);
md.args[2] = StaticCString::create(p_arg3);
return md;
}
@ -80,10 +88,10 @@ MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_
MethodDefinition md;
md.name = StaticCString::create(p_name);
md.args.resize(4);
md.args.write[0] = StaticCString::create(p_arg1);
md.args.write[1] = StaticCString::create(p_arg2);
md.args.write[2] = StaticCString::create(p_arg3);
md.args.write[3] = StaticCString::create(p_arg4);
md.args[0] = StaticCString::create(p_arg1);
md.args[1] = StaticCString::create(p_arg2);
md.args[2] = StaticCString::create(p_arg3);
md.args[3] = StaticCString::create(p_arg4);
return md;
}
@ -92,11 +100,11 @@ MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_
MethodDefinition md;
md.name = StaticCString::create(p_name);
md.args.resize(5);
md.args.write[0] = StaticCString::create(p_arg1);
md.args.write[1] = StaticCString::create(p_arg2);
md.args.write[2] = StaticCString::create(p_arg3);
md.args.write[3] = StaticCString::create(p_arg4);
md.args.write[4] = StaticCString::create(p_arg5);
md.args[0] = StaticCString::create(p_arg1);
md.args[1] = StaticCString::create(p_arg2);
md.args[2] = StaticCString::create(p_arg3);
md.args[3] = StaticCString::create(p_arg4);
md.args[4] = StaticCString::create(p_arg5);
return md;
}
@ -105,12 +113,12 @@ MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_
MethodDefinition md;
md.name = StaticCString::create(p_name);
md.args.resize(6);
md.args.write[0] = StaticCString::create(p_arg1);
md.args.write[1] = StaticCString::create(p_arg2);
md.args.write[2] = StaticCString::create(p_arg3);
md.args.write[3] = StaticCString::create(p_arg4);
md.args.write[4] = StaticCString::create(p_arg5);
md.args.write[5] = StaticCString::create(p_arg6);
md.args[0] = StaticCString::create(p_arg1);
md.args[1] = StaticCString::create(p_arg2);
md.args[2] = StaticCString::create(p_arg3);
md.args[3] = StaticCString::create(p_arg4);
md.args[4] = StaticCString::create(p_arg5);
md.args[5] = StaticCString::create(p_arg6);
return md;
}
@ -119,13 +127,13 @@ MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_
MethodDefinition md;
md.name = StaticCString::create(p_name);
md.args.resize(7);
md.args.write[0] = StaticCString::create(p_arg1);
md.args.write[1] = StaticCString::create(p_arg2);
md.args.write[2] = StaticCString::create(p_arg3);
md.args.write[3] = StaticCString::create(p_arg4);
md.args.write[4] = StaticCString::create(p_arg5);
md.args.write[5] = StaticCString::create(p_arg6);
md.args.write[6] = StaticCString::create(p_arg7);
md.args[0] = StaticCString::create(p_arg1);
md.args[1] = StaticCString::create(p_arg2);
md.args[2] = StaticCString::create(p_arg3);
md.args[3] = StaticCString::create(p_arg4);
md.args[4] = StaticCString::create(p_arg5);
md.args[5] = StaticCString::create(p_arg6);
md.args[6] = StaticCString::create(p_arg7);
return md;
}
@ -134,14 +142,14 @@ MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_
MethodDefinition md;
md.name = StaticCString::create(p_name);
md.args.resize(8);
md.args.write[0] = StaticCString::create(p_arg1);
md.args.write[1] = StaticCString::create(p_arg2);
md.args.write[2] = StaticCString::create(p_arg3);
md.args.write[3] = StaticCString::create(p_arg4);
md.args.write[4] = StaticCString::create(p_arg5);
md.args.write[5] = StaticCString::create(p_arg6);
md.args.write[6] = StaticCString::create(p_arg7);
md.args.write[7] = StaticCString::create(p_arg8);
md.args[0] = StaticCString::create(p_arg1);
md.args[1] = StaticCString::create(p_arg2);
md.args[2] = StaticCString::create(p_arg3);
md.args[3] = StaticCString::create(p_arg4);
md.args[4] = StaticCString::create(p_arg5);
md.args[5] = StaticCString::create(p_arg6);
md.args[6] = StaticCString::create(p_arg7);
md.args[7] = StaticCString::create(p_arg8);
return md;
}
@ -150,15 +158,15 @@ MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_
MethodDefinition md;
md.name = StaticCString::create(p_name);
md.args.resize(9);
md.args.write[0] = StaticCString::create(p_arg1);
md.args.write[1] = StaticCString::create(p_arg2);
md.args.write[2] = StaticCString::create(p_arg3);
md.args.write[3] = StaticCString::create(p_arg4);
md.args.write[4] = StaticCString::create(p_arg5);
md.args.write[5] = StaticCString::create(p_arg6);
md.args.write[6] = StaticCString::create(p_arg7);
md.args.write[7] = StaticCString::create(p_arg8);
md.args.write[8] = StaticCString::create(p_arg9);
md.args[0] = StaticCString::create(p_arg1);
md.args[1] = StaticCString::create(p_arg2);
md.args[2] = StaticCString::create(p_arg3);
md.args[3] = StaticCString::create(p_arg4);
md.args[4] = StaticCString::create(p_arg5);
md.args[5] = StaticCString::create(p_arg6);
md.args[6] = StaticCString::create(p_arg7);
md.args[7] = StaticCString::create(p_arg8);
md.args[8] = StaticCString::create(p_arg9);
return md;
}
@ -167,16 +175,16 @@ MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_
MethodDefinition md;
md.name = StaticCString::create(p_name);
md.args.resize(10);
md.args.write[0] = StaticCString::create(p_arg1);
md.args.write[1] = StaticCString::create(p_arg2);
md.args.write[2] = StaticCString::create(p_arg3);
md.args.write[3] = StaticCString::create(p_arg4);
md.args.write[4] = StaticCString::create(p_arg5);
md.args.write[5] = StaticCString::create(p_arg6);
md.args.write[6] = StaticCString::create(p_arg7);
md.args.write[7] = StaticCString::create(p_arg8);
md.args.write[8] = StaticCString::create(p_arg9);
md.args.write[9] = StaticCString::create(p_arg10);
md.args[0] = StaticCString::create(p_arg1);
md.args[1] = StaticCString::create(p_arg2);
md.args[2] = StaticCString::create(p_arg3);
md.args[3] = StaticCString::create(p_arg4);
md.args[4] = StaticCString::create(p_arg5);
md.args[5] = StaticCString::create(p_arg6);
md.args[6] = StaticCString::create(p_arg7);
md.args[7] = StaticCString::create(p_arg8);
md.args[8] = StaticCString::create(p_arg9);
md.args[9] = StaticCString::create(p_arg10);
return md;
}
@ -185,17 +193,17 @@ MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_
MethodDefinition md;
md.name = StaticCString::create(p_name);
md.args.resize(11);
md.args.write[0] = StaticCString::create(p_arg1);
md.args.write[1] = StaticCString::create(p_arg2);
md.args.write[2] = StaticCString::create(p_arg3);
md.args.write[3] = StaticCString::create(p_arg4);
md.args.write[4] = StaticCString::create(p_arg5);
md.args.write[5] = StaticCString::create(p_arg6);
md.args.write[6] = StaticCString::create(p_arg7);
md.args.write[7] = StaticCString::create(p_arg8);
md.args.write[8] = StaticCString::create(p_arg9);
md.args.write[9] = StaticCString::create(p_arg10);
md.args.write[10] = StaticCString::create(p_arg11);
md.args[0] = StaticCString::create(p_arg1);
md.args[1] = StaticCString::create(p_arg2);
md.args[2] = StaticCString::create(p_arg3);
md.args[3] = StaticCString::create(p_arg4);
md.args[4] = StaticCString::create(p_arg5);
md.args[5] = StaticCString::create(p_arg6);
md.args[6] = StaticCString::create(p_arg7);
md.args[7] = StaticCString::create(p_arg8);
md.args[8] = StaticCString::create(p_arg9);
md.args[9] = StaticCString::create(p_arg10);
md.args[10] = StaticCString::create(p_arg11);
return md;
}
@ -204,18 +212,18 @@ MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_
MethodDefinition md;
md.name = StaticCString::create(p_name);
md.args.resize(12);
md.args.write[0] = StaticCString::create(p_arg1);
md.args.write[1] = StaticCString::create(p_arg2);
md.args.write[2] = StaticCString::create(p_arg3);
md.args.write[3] = StaticCString::create(p_arg4);
md.args.write[4] = StaticCString::create(p_arg5);
md.args.write[5] = StaticCString::create(p_arg6);
md.args.write[6] = StaticCString::create(p_arg7);
md.args.write[7] = StaticCString::create(p_arg8);
md.args.write[8] = StaticCString::create(p_arg9);
md.args.write[9] = StaticCString::create(p_arg10);
md.args.write[10] = StaticCString::create(p_arg11);
md.args.write[11] = StaticCString::create(p_arg12);
md.args[0] = StaticCString::create(p_arg1);
md.args[1] = StaticCString::create(p_arg2);
md.args[2] = StaticCString::create(p_arg3);
md.args[3] = StaticCString::create(p_arg4);
md.args[4] = StaticCString::create(p_arg5);
md.args[5] = StaticCString::create(p_arg6);
md.args[6] = StaticCString::create(p_arg7);
md.args[7] = StaticCString::create(p_arg8);
md.args[8] = StaticCString::create(p_arg9);
md.args[9] = StaticCString::create(p_arg10);
md.args[10] = StaticCString::create(p_arg11);
md.args[11] = StaticCString::create(p_arg12);
return md;
}
@ -224,19 +232,19 @@ MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_
MethodDefinition md;
md.name = StaticCString::create(p_name);
md.args.resize(13);
md.args.write[0] = StaticCString::create(p_arg1);
md.args.write[1] = StaticCString::create(p_arg2);
md.args.write[2] = StaticCString::create(p_arg3);
md.args.write[3] = StaticCString::create(p_arg4);
md.args.write[4] = StaticCString::create(p_arg5);
md.args.write[5] = StaticCString::create(p_arg6);
md.args.write[6] = StaticCString::create(p_arg7);
md.args.write[7] = StaticCString::create(p_arg8);
md.args.write[8] = StaticCString::create(p_arg9);
md.args.write[9] = StaticCString::create(p_arg10);
md.args.write[10] = StaticCString::create(p_arg11);
md.args.write[11] = StaticCString::create(p_arg12);
md.args.write[12] = StaticCString::create(p_arg13);
md.args[0] = StaticCString::create(p_arg1);
md.args[1] = StaticCString::create(p_arg2);
md.args[2] = StaticCString::create(p_arg3);
md.args[3] = StaticCString::create(p_arg4);
md.args[4] = StaticCString::create(p_arg5);
md.args[5] = StaticCString::create(p_arg6);
md.args[6] = StaticCString::create(p_arg7);
md.args[7] = StaticCString::create(p_arg8);
md.args[8] = StaticCString::create(p_arg9);
md.args[9] = StaticCString::create(p_arg10);
md.args[10] = StaticCString::create(p_arg11);
md.args[11] = StaticCString::create(p_arg12);
md.args[12] = StaticCString::create(p_arg13);
return md;
}
@ -249,24 +257,17 @@ void ClassDB::set_current_api(APIType p_api) {
current_api = p_api;
}
ClassDB::APIType ClassDB::get_current_api() {
return current_api;
}
HashMap<StringName, ClassDB::ClassInfo> ClassDB::classes;
HashMap<StringName, StringName> ClassDB::resource_base_extensions;
HashMap<StringName, StringName> ClassDB::compat_classes;
HashMap<StringName, ClassDB::ClassInfo, StringNameHasher> ClassDB::classes;
HashMap<StringName, StringName, StringNameHasher> ClassDB::resource_base_extensions;
HashMap<StringName, StringName, StringNameHasher> ClassDB::compat_classes;
ClassDB::ClassInfo::ClassInfo() {
api = API_NONE;
creation_func = NULL;
inherits_ptr = NULL;
disabled = false;
exposed = false;
}
ClassDB::ClassInfo::~ClassInfo() {
}
@ -518,12 +519,7 @@ Object *ClassDB::instance(const StringName &p_class) {
ERR_FAIL_COND_V(ti->disabled, NULL);
ERR_FAIL_COND_V(!ti->creation_func, NULL);
}
#ifdef TOOLS_ENABLED
if (ti->api == API_EDITOR && !Engine::get_singleton()->is_editor_hint()) {
ERR_PRINTS("Class '" + String(p_class) + "' can only be instantiated by editor.");
return NULL;
}
#endif
return ti->creation_func();
}
bool ClassDB::can_instance(const StringName &p_class) {
@ -664,6 +660,7 @@ void ClassDB::bind_integer_constant(const StringName &p_class, const StringName
}
type->constant_map[p_name] = p_constant;
#ifdef DEBUG_METHODS_ENABLED
String enum_name = p_enum;
if (enum_name != String()) {
@ -682,7 +679,6 @@ void ClassDB::bind_integer_constant(const StringName &p_class, const StringName
}
}
#ifdef DEBUG_METHODS_ENABLED
type->constant_order.push_back(p_name);
#endif
}
@ -738,6 +734,7 @@ int ClassDB::get_integer_constant(const StringName &p_class, const StringName &p
return 0;
}
#ifdef DEBUG_METHODS_ENABLED
StringName ClassDB::get_integer_constant_enum(const StringName &p_class, const StringName &p_name, bool p_no_inheritance) {
OBJTYPE_RLOCK;
@ -806,6 +803,7 @@ void ClassDB::get_enum_constants(const StringName &p_class, const StringName &p_
type = type->inherits_ptr;
}
}
#endif
void ClassDB::add_signal(StringName p_class, const MethodInfo &p_signal) {
@ -814,10 +812,10 @@ void ClassDB::add_signal(StringName p_class, const MethodInfo &p_signal) {
ClassInfo *type = classes.getptr(p_class);
ERR_FAIL_COND(!type);
StringName sname = p_signal.name;
#ifdef DEBUG_METHODS_ENABLED
ClassInfo *check = type;
StringName sname = p_signal.name;
#ifdef DEBUG_METHODS_ENABLED
while (check) {
if (check->signal_map.has(sname)) {
ERR_EXPLAIN("Type " + String(p_class) + " already has signal: " + String(sname));
@ -897,9 +895,15 @@ void ClassDB::add_property_group(StringName p_class, const String &p_name, const
void ClassDB::add_property(StringName p_class, const PropertyInfo &p_pinfo, const StringName &p_setter, const StringName &p_getter, int p_index) {
#ifndef NO_THREADS
lock->read_lock();
#endif
ClassInfo *type = classes.getptr(p_class);
#ifndef NO_THREADS
lock->read_unlock();
#endif
ERR_FAIL_COND(!type);
@ -941,8 +945,9 @@ void ClassDB::add_property(StringName p_class, const PropertyInfo &p_pinfo, cons
}
#ifdef DEBUG_METHODS_ENABLED
if (type->property_setget.has(p_pinfo.name)) {
ERR_EXPLAIN("Object " + p_class + " already has property: " + p_pinfo.name);
ERR_EXPLAIN("Object already has property: " + p_class);
ERR_FAIL();
}
#endif
@ -1256,7 +1261,7 @@ MethodBind *ClassDB::bind_methodfi(uint32_t p_flags, MethodBind *p_bind, const c
defvals.resize(p_defcount);
for (int i = 0; i < p_defcount; i++) {
defvals.write[i] = *p_defs[p_defcount - i - 1];
defvals[i] = *p_defs[p_defcount - i - 1];
}
p_bind->set_default_arguments(defvals);
@ -1371,46 +1376,14 @@ void ClassDB::get_extensions_for_type(const StringName &p_class, List<String> *p
}
}
HashMap<StringName, HashMap<StringName, Variant> > ClassDB::default_values;
Variant ClassDB::class_get_default_property_value(const StringName &p_class, const StringName &p_property) {
if (!default_values.has(p_class)) {
default_values[p_class] = HashMap<StringName, Variant>();
if (ClassDB::can_instance(p_class)) {
Object *c = ClassDB::instance(p_class);
List<PropertyInfo> plist;
c->get_property_list(&plist);
for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
if (E->get().usage & (PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR)) {
Variant v = c->get(E->get().name);
default_values[p_class][E->get().name] = v;
}
}
memdelete(c);
}
}
if (!default_values.has(p_class)) {
return Variant();
}
if (!default_values[p_class].has(p_property)) {
return Variant();
}
return default_values[p_class][p_property];
}
RWLock *ClassDB::lock = NULL;
void ClassDB::init() {
#ifndef NO_THREADS
lock = RWLock::create();
#endif
}
void ClassDB::cleanup() {
@ -1432,9 +1405,11 @@ void ClassDB::cleanup() {
classes.clear();
resource_base_extensions.clear();
compat_classes.clear();
default_values.clear();
#ifndef NO_THREADS
memdelete(lock);
#endif
}
//

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -31,18 +31,14 @@
#ifndef CLASS_DB_H
#define CLASS_DB_H
#include "core/method_bind.h"
#include "core/object.h"
#include "core/print_string.h"
#include "method_bind.h"
#include "object.h"
#include "print_string.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
/** To bind more then 6 parameters include this:
* #include "core/method_bind_ext.gen.inc"
*/
#define DEFVAL(m_defval) (m_defval)
//#define SIMPLE_METHODDEF
@ -118,19 +114,19 @@ public:
APIType api;
ClassInfo *inherits_ptr;
HashMap<StringName, MethodBind *> method_map;
HashMap<StringName, int> constant_map;
HashMap<StringName, List<StringName> > enum_map;
HashMap<StringName, MethodInfo> signal_map;
HashMap<StringName, MethodBind *, StringNameHasher> method_map;
HashMap<StringName, int, StringNameHasher> constant_map;
HashMap<StringName, MethodInfo, StringNameHasher> signal_map;
List<PropertyInfo> property_list;
#ifdef DEBUG_METHODS_ENABLED
HashMap<StringName, List<StringName> > enum_map;
List<StringName> constant_order;
List<StringName> method_order;
Set<StringName> methods_in_properties;
List<MethodInfo> virtual_methods;
StringName category;
#endif
HashMap<StringName, PropertySetGet> property_setget;
HashMap<StringName, PropertySetGet, StringNameHasher> property_setget;
StringName inherits;
StringName name;
@ -147,9 +143,9 @@ public:
}
static RWLock *lock;
static HashMap<StringName, ClassInfo> classes;
static HashMap<StringName, StringName> resource_base_extensions;
static HashMap<StringName, StringName> compat_classes;
static HashMap<StringName, ClassInfo, StringNameHasher> classes;
static HashMap<StringName, StringName, StringNameHasher> resource_base_extensions;
static HashMap<StringName, StringName, StringNameHasher> compat_classes;
#ifdef DEBUG_METHODS_ENABLED
static MethodBind *bind_methodfi(uint32_t p_flags, MethodBind *p_bind, const MethodDefinition &method_name, const Variant **p_defs, int p_defcount);
@ -161,8 +157,6 @@ public:
static void _add_class2(const StringName &p_class, const StringName &p_inherits);
static HashMap<StringName, HashMap<StringName, Variant> > default_values;
public:
// DO NOT USE THIS!!!!!! NEEDS TO BE PUBLIC BUT DO NOT USE NO MATTER WHAT!!!
template <class T>
@ -350,11 +344,11 @@ public:
static void get_integer_constant_list(const StringName &p_class, List<String> *p_constants, bool p_no_inheritance = false);
static int get_integer_constant(const StringName &p_class, const StringName &p_name, bool *p_success = NULL);
#ifdef DEBUG_METHODS_ENABLED
static StringName get_integer_constant_enum(const StringName &p_class, const StringName &p_name, bool p_no_inheritance = false);
static void get_enum_list(const StringName &p_class, List<StringName> *p_enums, bool p_no_inheritance = false);
static void get_enum_constants(const StringName &p_class, const StringName &p_enum, List<StringName> *p_constants, bool p_no_inheritance = false);
static Variant class_get_default_property_value(const StringName &p_class, const StringName &p_property);
#endif
static StringName get_category(const StringName &p_node);
@ -371,7 +365,6 @@ public:
static void init();
static void set_current_api(APIType p_api);
static APIType get_current_api();
static void cleanup();
};

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -30,85 +30,45 @@
#include "color.h"
#include "core/color_names.inc"
#include "core/map.h"
#include "core/math/math_funcs.h"
#include "core/print_string.h"
#include "color_names.inc"
#include "map.h"
#include "math_funcs.h"
#include "print_string.h"
uint32_t Color::to_argb32() const {
uint32_t c = (uint8_t)Math::round(a * 255);
uint32_t c = (uint8_t)(a * 255);
c <<= 8;
c |= (uint8_t)Math::round(r * 255);
c |= (uint8_t)(r * 255);
c <<= 8;
c |= (uint8_t)Math::round(g * 255);
c |= (uint8_t)(g * 255);
c <<= 8;
c |= (uint8_t)Math::round(b * 255);
c |= (uint8_t)(b * 255);
return c;
}
uint32_t Color::to_abgr32() const {
uint32_t c = (uint8_t)Math::round(a * 255);
uint32_t c = (uint8_t)(a * 255);
c <<= 8;
c |= (uint8_t)Math::round(b * 255);
c |= (uint8_t)(b * 255);
c <<= 8;
c |= (uint8_t)Math::round(g * 255);
c |= (uint8_t)(g * 255);
c <<= 8;
c |= (uint8_t)Math::round(r * 255);
c |= (uint8_t)(r * 255);
return c;
}
uint32_t Color::to_rgba32() const {
uint32_t c = (uint8_t)Math::round(r * 255);
uint32_t c = (uint8_t)(r * 255);
c <<= 8;
c |= (uint8_t)Math::round(g * 255);
c |= (uint8_t)(g * 255);
c <<= 8;
c |= (uint8_t)Math::round(b * 255);
c |= (uint8_t)(b * 255);
c <<= 8;
c |= (uint8_t)Math::round(a * 255);
return c;
}
uint64_t Color::to_abgr64() const {
uint64_t c = (uint16_t)Math::round(a * 65535);
c <<= 16;
c |= (uint16_t)Math::round(b * 65535);
c <<= 16;
c |= (uint16_t)Math::round(g * 65535);
c <<= 16;
c |= (uint16_t)Math::round(r * 65535);
return c;
}
uint64_t Color::to_argb64() const {
uint64_t c = (uint16_t)Math::round(a * 65535);
c <<= 16;
c |= (uint16_t)Math::round(r * 65535);
c <<= 16;
c |= (uint16_t)Math::round(g * 65535);
c <<= 16;
c |= (uint16_t)Math::round(b * 65535);
return c;
}
uint64_t Color::to_rgba64() const {
uint64_t c = (uint16_t)Math::round(r * 65535);
c <<= 16;
c |= (uint16_t)Math::round(g * 65535);
c <<= 16;
c |= (uint16_t)Math::round(b * 65535);
c <<= 16;
c |= (uint16_t)Math::round(a * 65535);
c |= (uint8_t)(a * 255);
return c;
}
@ -240,34 +200,6 @@ Color Color::hex(uint32_t p_hex) {
return Color(r, g, b, a);
}
Color Color::hex64(uint64_t p_hex) {
float a = (p_hex & 0xFFFF) / 65535.0;
p_hex >>= 16;
float b = (p_hex & 0xFFFF) / 65535.0;
p_hex >>= 16;
float g = (p_hex & 0xFFFF) / 65535.0;
p_hex >>= 16;
float r = (p_hex & 0xFFFF) / 65535.0;
return Color(r, g, b, a);
}
Color Color::from_rgbe9995(uint32_t p_rgbe) {
float r = p_rgbe & 0x1ff;
float g = (p_rgbe >> 9) & 0x1ff;
float b = (p_rgbe >> 18) & 0x1ff;
float e = (p_rgbe >> 27);
float m = Math::pow(2, e - 15.0 - 9.0);
float rd = r * m;
float gd = g * m;
float bd = b * m;
return Color(rd, gd, bd, 1.0f);
}
static float _parse_col(const String &p_str, int p_ofs) {
int ig = 0;
@ -436,7 +368,7 @@ Color Color::named(const String &p_name) {
String _to_hex(float p_val) {
int v = Math::round(p_val * 255);
int v = p_val * 255;
v = CLAMP(v, 0, 255);
String ret;
@ -468,64 +400,8 @@ String Color::to_html(bool p_alpha) const {
return txt;
}
Color Color::from_hsv(float p_h, float p_s, float p_v, float p_a) const {
p_h = Math::fmod(p_h * 360.0f, 360.0f);
if (p_h < 0.0)
p_h += 360.0f;
const float h_ = p_h / 60.0f;
const float c = p_v * p_s;
const float x = c * (1.0f - Math::abs(Math::fmod(h_, 2.0f) - 1.0f));
float r, g, b;
switch ((int)h_) {
case 0: {
r = c;
g = x;
b = 0;
} break;
case 1: {
r = x;
g = c;
b = 0;
} break;
case 2: {
r = 0;
g = c;
b = x;
} break;
case 3: {
r = 0;
g = x;
b = c;
} break;
case 4: {
r = x;
g = 0;
b = c;
} break;
case 5: {
r = c;
g = 0;
b = x;
} break;
default: {
r = 0;
g = 0;
b = 0;
} break;
}
const float m = p_v - c;
return Color(m + r, m + g, m + b, p_a);
}
// FIXME: Remove once Godot 3.1 has been released
float Color::gray() const {
ERR_EXPLAIN("Color.gray() is deprecated and will be removed in a future version. Use Color.get_v() for a better grayscale approximation.");
WARN_DEPRECATED
return (r + g + b) / 3.0;
}

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -31,8 +31,8 @@
#ifndef COLOR_H
#define COLOR_H
#include "core/math/math_funcs.h"
#include "core/ustring.h"
#include "math_funcs.h"
#include "ustring.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
@ -55,9 +55,6 @@ struct Color {
uint32_t to_rgba32() const;
uint32_t to_argb32() const;
uint32_t to_abgr32() const;
uint64_t to_rgba64() const;
uint64_t to_argb64() const;
uint64_t to_abgr64() const;
float gray() const;
float get_h() const;
float get_s() const;
@ -189,13 +186,10 @@ struct Color {
}
static Color hex(uint32_t p_hex);
static Color hex64(uint64_t p_hex);
static Color html(const String &p_color);
static bool html_is_valid(const String &p_color);
static Color named(const String &p_name);
String to_html(bool p_alpha = true) const;
Color from_hsv(float p_h, float p_s, float p_v, float p_a) const;
static Color from_rgbe9995(uint32_t p_color);
_FORCE_INLINE_ bool operator<(const Color &p_color) const; //used in set keys
operator String() const;

View File

@ -1,9 +1,9 @@
// Names from https://en.wikipedia.org/wiki/List_of_colors (through https://raw.githubusercontent.com/SuperUserNameMan/color_to_name/616a7cddafefda91478b7bc26167de97fb5badb1/godot_version.gd), slightly edited and normalized
#include "core/map.h"
#include "map.h"
static Map<String, Color> _named_colors;
static void _populate_named_colors() {
if (!_named_colors.empty()) return;
if(!_named_colors.empty()) return;
_named_colors.insert("aliceblue", Color(0.94, 0.97, 1.00));
_named_colors.insert("antiquewhite", Color(0.98, 0.92, 0.84));
_named_colors.insert("aqua", Color(0.00, 1.00, 1.00));

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -30,7 +30,7 @@
#include "command_queue_mt.h"
#include "core/os/os.h"
#include "os/os.h"
void CommandQueueMT::lock() {
@ -97,7 +97,7 @@ tryagain:
return false;
}
dealloc_ptr += (size >> 1) + 8;
dealloc_ptr += (size >> 1) + sizeof(uint32_t);
return true;
}
@ -105,9 +105,7 @@ CommandQueueMT::CommandQueueMT(bool p_sync) {
read_ptr = 0;
write_ptr = 0;
dealloc_ptr = 0;
mutex = Mutex::create();
command_mem = (uint8_t *)memalloc(COMMAND_MEM_SIZE);
for (int i = 0; i < SYNC_SEMAPHORES; i++) {
@ -129,5 +127,4 @@ CommandQueueMT::~CommandQueueMT() {
memdelete(sync_sems[i].sem);
}
memfree(command_mem);
}

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -31,12 +31,11 @@
#ifndef COMMAND_QUEUE_MT_H
#define COMMAND_QUEUE_MT_H
#include "core/os/memory.h"
#include "core/os/mutex.h"
#include "core/os/semaphore.h"
#include "core/simple_type.h"
#include "core/typedefs.h"
#include "os/memory.h"
#include "os/mutex.h"
#include "os/semaphore.h"
#include "simple_type.h"
#include "typedefs.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
@ -55,13 +54,9 @@
#define _COMMA_10 ,
#define _COMMA_11 ,
#define _COMMA_12 ,
#define _COMMA_13 ,
// 1-based comma separated list of ITEMs
#define COMMA_SEP_LIST(ITEM, LENGTH) _COMMA_SEP_LIST_##LENGTH(ITEM)
#define _COMMA_SEP_LIST_13(ITEM) \
_COMMA_SEP_LIST_12(ITEM) \
, ITEM(13)
#define _COMMA_SEP_LIST_12(ITEM) \
_COMMA_SEP_LIST_11(ITEM) \
, ITEM(12)
@ -102,9 +97,6 @@
// 1-based semicolon separated list of ITEMs
#define SEMIC_SEP_LIST(ITEM, LENGTH) _SEMIC_SEP_LIST_##LENGTH(ITEM)
#define _SEMIC_SEP_LIST_13(ITEM) \
_SEMIC_SEP_LIST_12(ITEM); \
ITEM(13)
#define _SEMIC_SEP_LIST_12(ITEM) \
_SEMIC_SEP_LIST_11(ITEM); \
ITEM(12)
@ -145,9 +137,6 @@
// 1-based space separated list of ITEMs
#define SPACE_SEP_LIST(ITEM, LENGTH) _SPACE_SEP_LIST_##LENGTH(ITEM)
#define _SPACE_SEP_LIST_13(ITEM) \
_SPACE_SEP_LIST_12(ITEM) \
ITEM(13)
#define _SPACE_SEP_LIST_12(ITEM) \
_SPACE_SEP_LIST_11(ITEM) \
ITEM(12)
@ -255,7 +244,6 @@
unlock(); \
if (sync) sync->post(); \
ss->sem->wait(); \
ss->in_use = false; \
}
#define CMD_SYNC_TYPE(N) CommandSync##N<T, M COMMA(N) COMMA_SEP_LIST(TYPE_ARG, N)>
@ -272,10 +260,9 @@
unlock(); \
if (sync) sync->post(); \
ss->sem->wait(); \
ss->in_use = false; \
}
#define MAX_CMD_PARAMS 13
#define MAX_CMD_PARAMS 12
class CommandQueueMT {
@ -298,19 +285,20 @@ class CommandQueueMT {
virtual void post() {
sync_sem->sem->post();
sync_sem->in_use = false;
}
};
DECL_CMD(0)
SPACE_SEP_LIST(DECL_CMD, 13)
SPACE_SEP_LIST(DECL_CMD, 12)
/* comands that return */
DECL_CMD_RET(0)
SPACE_SEP_LIST(DECL_CMD_RET, 13)
SPACE_SEP_LIST(DECL_CMD_RET, 12)
/* commands that don't return but sync */
DECL_CMD_SYNC(0)
SPACE_SEP_LIST(DECL_CMD_SYNC, 13)
SPACE_SEP_LIST(DECL_CMD_SYNC, 12)
/***** BASE *******/
@ -320,10 +308,10 @@ class CommandQueueMT {
SYNC_SEMAPHORES = 8
};
uint8_t *command_mem;
uint32_t read_ptr;
uint32_t write_ptr;
uint32_t dealloc_ptr;
uint8_t command_mem[COMMAND_MEM_SIZE];
uint32_t read_ptr = 0;
uint32_t write_ptr = 0;
uint32_t dealloc_ptr = 0;
SyncSemaphore sync_sems[SYNC_SEMAPHORES];
Mutex *mutex;
Semaphore *sync;
@ -332,7 +320,7 @@ class CommandQueueMT {
T *allocate() {
// alloc size is size+T+safeguard
uint32_t alloc_size = ((sizeof(T) + 8 - 1) & ~(8 - 1)) + 8;
uint32_t alloc_size = sizeof(T) + sizeof(uint32_t);
tryagain:
@ -362,7 +350,7 @@ class CommandQueueMT {
}
// if this happens, it's a bug
ERR_FAIL_COND_V((COMMAND_MEM_SIZE - write_ptr) < 8, NULL);
ERR_FAIL_COND_V((COMMAND_MEM_SIZE - write_ptr) < sizeof(uint32_t), NULL);
// zero means, wrap to beginning
uint32_t *p = (uint32_t *)&command_mem[write_ptr];
@ -374,13 +362,12 @@ class CommandQueueMT {
// Allocate the size and the 'in use' bit.
// First bit used to mark if command is still in use (1)
// or if it has been destroyed and can be deallocated (0).
uint32_t size = (sizeof(T) + 8 - 1) & ~(8 - 1);
uint32_t *p = (uint32_t *)&command_mem[write_ptr];
*p = (size << 1) | 1;
write_ptr += 8;
*p = (sizeof(T) << 1) | 1;
write_ptr += sizeof(uint32_t);
// allocate the command
T *cmd = memnew_placement(&command_mem[write_ptr], T);
write_ptr += size;
write_ptr += sizeof(T);
return cmd;
}
@ -418,7 +405,7 @@ class CommandQueueMT {
goto tryagain;
}
read_ptr += 8;
read_ptr += sizeof(uint32_t);
CommandBase *cmd = reinterpret_cast<CommandBase *>(&command_mem[read_ptr]);
@ -445,15 +432,15 @@ class CommandQueueMT {
public:
/* NORMAL PUSH COMMANDS */
DECL_PUSH(0)
SPACE_SEP_LIST(DECL_PUSH, 13)
SPACE_SEP_LIST(DECL_PUSH, 12)
/* PUSH AND RET COMMANDS */
DECL_PUSH_AND_RET(0)
SPACE_SEP_LIST(DECL_PUSH_AND_RET, 13)
SPACE_SEP_LIST(DECL_PUSH_AND_RET, 12)
/* PUSH AND RET SYNC COMMANDS*/
DECL_PUSH_AND_SYNC(0)
SPACE_SEP_LIST(DECL_PUSH_AND_SYNC, 13)
SPACE_SEP_LIST(DECL_PUSH_AND_SYNC, 12)
void wait_and_flush_one() {
ERR_FAIL_COND(!sync);

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -30,7 +30,7 @@
#include "compressed_translation.h"
#include "core/pair.h"
#include "pair.h"
extern "C" {
#include "thirdparty/misc/smaz.h"
@ -50,6 +50,7 @@ void PHashTranslation::generate(const Ref<Translation> &p_from) {
int size = Math::larger_prime(keys.size());
print_line("compressing keys: " + itos(keys.size()));
Vector<Vector<Pair<int, CharString> > > buckets;
Vector<Map<uint32_t, int> > table;
Vector<uint32_t> hfunc_table;
@ -72,7 +73,7 @@ void PHashTranslation::generate(const Ref<Translation> &p_from) {
Pair<int, CharString> p;
p.first = idx;
p.second = cs;
buckets.write[h % size].push_back(p);
buckets[h % size].push_back(p);
//compress string
CharString src_s = p_from->get_message(E->get()).operator String().utf8();
@ -83,7 +84,7 @@ void PHashTranslation::generate(const Ref<Translation> &p_from) {
if (ps.orig_len != 0) {
CharString dst_s;
dst_s.resize(src_s.size());
int ret = smaz_compress(src_s.get_data(), src_s.size(), dst_s.ptrw(), src_s.size());
int ret = smaz_compress(src_s.get_data(), src_s.size(), &dst_s[0], src_s.size());
if (ret >= src_s.size()) {
//if compressed is larger than original, just use original
ps.orig_len = src_s.size();
@ -99,22 +100,25 @@ void PHashTranslation::generate(const Ref<Translation> &p_from) {
ps.compressed[0] = 0;
}
compressed.write[idx] = ps;
compressed[idx] = ps;
total_compression_size += ps.compressed.size();
total_string_size += src_s.size();
idx++;
}
int bucket_table_size = 0;
print_line("total compressed string size: " + itos(total_compression_size) + " (" + itos(total_string_size) + " uncompressed).");
for (int i = 0; i < size; i++) {
const Vector<Pair<int, CharString> > &b = buckets[i];
Map<uint32_t, int> &t = table.write[i];
Vector<Pair<int, CharString> > &b = buckets[i];
Map<uint32_t, int> &t = table[i];
if (b.size() == 0)
continue;
//print_line("bucket: "+itos(i)+" - elements: "+itos(b.size()));
int d = 1;
int item = 0;
@ -132,10 +136,13 @@ void PHashTranslation::generate(const Ref<Translation> &p_from) {
}
}
hfunc_table.write[i] = d;
hfunc_table[i] = d;
bucket_table_size += 2 + b.size() * 4;
}
print_line("bucket table size: " + itos(bucket_table_size * 4));
print_line("hash table size: " + itos(size * 4));
hash_table.resize(size);
bucket_table.resize(bucket_table_size);
@ -150,7 +157,7 @@ void PHashTranslation::generate(const Ref<Translation> &p_from) {
for (int i = 0; i < size; i++) {
const Map<uint32_t, int> &t = table[i];
Map<uint32_t, int> &t = table[i];
if (t.size() == 0) {
htw[i] = 0xFFFFFFFF; //nothing
continue;
@ -171,6 +178,8 @@ void PHashTranslation::generate(const Ref<Translation> &p_from) {
}
}
print_line("total collisions: " + itos(collisions));
strings.resize(total_compression_size);
PoolVector<uint8_t>::Write cw = strings.write();
@ -189,11 +198,15 @@ bool PHashTranslation::_set(const StringName &p_name, const Variant &p_value) {
String name = p_name.operator String();
if (name == "hash_table") {
hash_table = p_value;
//print_line("translation: loaded hash table of size: "+itos(hash_table.size()));
} else if (name == "bucket_table") {
bucket_table = p_value;
//print_line("translation: loaded bucket table of size: "+itos(bucket_table.size()));
} else if (name == "strings") {
strings = p_value;
//print_line("translation: loaded string table of size: "+itos(strings.size()));
} else if (name == "load_from") {
//print_line("generating");
generate(p_value);
} else
return false;
@ -235,7 +248,11 @@ StringName PHashTranslation::get_message(const StringName &p_src_text) const {
uint32_t p = htptr[h % htsize];
//print_line("String: "+p_src_text.operator String());
//print_line("Hash: "+itos(p));
if (p == 0xFFFFFFFF) {
//print_line("GETMSG: Nothing!");
return StringName(); //nothing
}
@ -254,7 +271,9 @@ StringName PHashTranslation::get_message(const StringName &p_src_text) const {
}
}
//print_line("bucket pos: "+itos(idx));
if (idx == -1) {
//print_line("GETMSG: Not in Bucket!");
return StringName();
}
@ -262,6 +281,8 @@ StringName PHashTranslation::get_message(const StringName &p_src_text) const {
String rstr;
rstr.parse_utf8(&sptr[bucket.elem[idx].str_offset], bucket.elem[idx].uncomp_size);
//print_line("Uncompressed, size: "+itos(bucket.elem[idx].comp_size));
//print_line("Return: "+rstr);
return rstr;
} else {
@ -271,6 +292,8 @@ StringName PHashTranslation::get_message(const StringName &p_src_text) const {
smaz_decompress(&sptr[bucket.elem[idx].str_offset], bucket.elem[idx].comp_size, uncomp.ptrw(), bucket.elem[idx].uncomp_size);
String rstr;
rstr.parse_utf8(uncomp.get_data());
//print_line("Compressed, size: "+itos(bucket.elem[idx].comp_size));
//print_line("Return: "+rstr);
return rstr;
}
}

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -31,7 +31,7 @@
#ifndef COMPRESSED_TRANSLATION_H
#define COMPRESSED_TRANSLATION_H
#include "core/translation.h"
#include "translation.h"
class PHashTranslation : public Translation {

View File

@ -1,269 +0,0 @@
"""Functions used to generate source files during build time
All such functions are invoked in a subprocess on Windows to prevent build flakiness.
"""
from platform_methods import subprocess_main
from compat import iteritems, itervalues, open_utf8, escape_string, byte_to_str
def make_certs_header(target, source, env):
src = source[0]
dst = target[0]
f = open(src, "rb")
g = open_utf8(dst, "w")
buf = f.read()
decomp_size = len(buf)
import zlib
buf = zlib.compress(buf)
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
g.write("#ifndef _CERTS_RAW_H\n")
g.write("#define _CERTS_RAW_H\n")
# System certs path. Editor will use them if defined. (for package maintainers)
path = env['system_certs_path']
g.write("#define _SYSTEM_CERTS_PATH \"%s\"\n" % str(path))
if env['builtin_certs']:
# Defined here and not in env so changing it does not trigger a full rebuild.
g.write("#define BUILTIN_CERTS_ENABLED\n")
g.write("static const int _certs_compressed_size = " + str(len(buf)) + ";\n")
g.write("static const int _certs_uncompressed_size = " + str(decomp_size) + ";\n")
g.write("static const unsigned char _certs_compressed[] = {\n")
for i in range(len(buf)):
g.write("\t" + byte_to_str(buf[i]) + ",\n")
g.write("};\n")
g.write("#endif")
g.close()
f.close()
def make_authors_header(target, source, env):
sections = ["Project Founders", "Lead Developer", "Project Manager", "Developers"]
sections_id = ["AUTHORS_FOUNDERS", "AUTHORS_LEAD_DEVELOPERS", "AUTHORS_PROJECT_MANAGERS", "AUTHORS_DEVELOPERS"]
src = source[0]
dst = target[0]
f = open_utf8(src, "r")
g = open_utf8(dst, "w")
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
g.write("#ifndef _EDITOR_AUTHORS_H\n")
g.write("#define _EDITOR_AUTHORS_H\n")
reading = False
def close_section():
g.write("\t0\n")
g.write("};\n")
for line in f:
if reading:
if line.startswith(" "):
g.write("\t\"" + escape_string(line.strip()) + "\",\n")
continue
if line.startswith("## "):
if reading:
close_section()
reading = False
for section, section_id in zip(sections, sections_id):
if line.strip().endswith(section):
current_section = escape_string(section_id)
reading = True
g.write("const char *const " + current_section + "[] = {\n")
break
if reading:
close_section()
g.write("#endif\n")
g.close()
f.close()
def make_donors_header(target, source, env):
sections = ["Platinum sponsors", "Gold sponsors", "Mini sponsors",
"Gold donors", "Silver donors", "Bronze donors"]
sections_id = ["DONORS_SPONSOR_PLAT", "DONORS_SPONSOR_GOLD", "DONORS_SPONSOR_MINI",
"DONORS_GOLD", "DONORS_SILVER", "DONORS_BRONZE"]
src = source[0]
dst = target[0]
f = open_utf8(src, "r")
g = open_utf8(dst, "w")
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
g.write("#ifndef _EDITOR_DONORS_H\n")
g.write("#define _EDITOR_DONORS_H\n")
reading = False
def close_section():
g.write("\t0\n")
g.write("};\n")
for line in f:
if reading >= 0:
if line.startswith(" "):
g.write("\t\"" + escape_string(line.strip()) + "\",\n")
continue
if line.startswith("## "):
if reading:
close_section()
reading = False
for section, section_id in zip(sections, sections_id):
if line.strip().endswith(section):
current_section = escape_string(section_id)
reading = True
g.write("const char *const " + current_section + "[] = {\n")
break
if reading:
close_section()
g.write("#endif\n")
g.close()
f.close()
def make_license_header(target, source, env):
src_copyright = source[0]
src_license = source[1]
dst = target[0]
class LicenseReader:
def __init__(self, license_file):
self._license_file = license_file
self.line_num = 0
self.current = self.next_line()
def next_line(self):
line = self._license_file.readline()
self.line_num += 1
while line.startswith("#"):
line = self._license_file.readline()
self.line_num += 1
self.current = line
return line
def next_tag(self):
if not ':' in self.current:
return ('', [])
tag, line = self.current.split(":", 1)
lines = [line.strip()]
while self.next_line() and self.current.startswith(" "):
lines.append(self.current.strip())
return (tag, lines)
from collections import OrderedDict
projects = OrderedDict()
license_list = []
with open_utf8(src_copyright, "r") as copyright_file:
reader = LicenseReader(copyright_file)
part = {}
while reader.current:
tag, content = reader.next_tag()
if tag in ("Files", "Copyright", "License"):
part[tag] = content[:]
elif tag == "Comment":
# attach part to named project
projects[content[0]] = projects.get(content[0], []) + [part]
if not tag or not reader.current:
# end of a paragraph start a new part
if "License" in part and not "Files" in part:
# no Files tag in this one, so assume standalone license
license_list.append(part["License"])
part = {}
reader.next_line()
data_list = []
for project in itervalues(projects):
for part in project:
part["file_index"] = len(data_list)
data_list += part["Files"]
part["copyright_index"] = len(data_list)
data_list += part["Copyright"]
with open_utf8(dst, "w") as f:
f.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
f.write("#ifndef _EDITOR_LICENSE_H\n")
f.write("#define _EDITOR_LICENSE_H\n")
f.write("const char *const GODOT_LICENSE_TEXT =")
with open_utf8(src_license, "r") as license_file:
for line in license_file:
escaped_string = escape_string(line.strip())
f.write("\n\t\t\"" + escaped_string + "\\n\"")
f.write(";\n\n")
f.write("struct ComponentCopyrightPart {\n"
"\tconst char *license;\n"
"\tconst char *const *files;\n"
"\tconst char *const *copyright_statements;\n"
"\tint file_count;\n"
"\tint copyright_count;\n"
"};\n\n")
f.write("struct ComponentCopyright {\n"
"\tconst char *name;\n"
"\tconst ComponentCopyrightPart *parts;\n"
"\tint part_count;\n"
"};\n\n")
f.write("const char *const COPYRIGHT_INFO_DATA[] = {\n")
for line in data_list:
f.write("\t\"" + escape_string(line) + "\",\n")
f.write("};\n\n")
f.write("const ComponentCopyrightPart COPYRIGHT_PROJECT_PARTS[] = {\n")
part_index = 0
part_indexes = {}
for project_name, project in iteritems(projects):
part_indexes[project_name] = part_index
for part in project:
f.write("\t{ \"" + escape_string(part["License"][0]) + "\", "
+ "&COPYRIGHT_INFO_DATA[" + str(part["file_index"]) + "], "
+ "&COPYRIGHT_INFO_DATA[" + str(part["copyright_index"]) + "], "
+ str(len(part["Files"])) + ", "
+ str(len(part["Copyright"])) + " },\n")
part_index += 1
f.write("};\n\n")
f.write("const int COPYRIGHT_INFO_COUNT = " + str(len(projects)) + ";\n")
f.write("const ComponentCopyright COPYRIGHT_INFO[] = {\n")
for project_name, project in iteritems(projects):
f.write("\t{ \"" + escape_string(project_name) + "\", "
+ "&COPYRIGHT_PROJECT_PARTS[" + str(part_indexes[project_name]) + "], "
+ str(len(project)) + " },\n")
f.write("};\n\n")
f.write("const int LICENSE_COUNT = " + str(len(license_list)) + ";\n")
f.write("const char *const LICENSE_NAMES[] = {\n")
for l in license_list:
f.write("\t\"" + escape_string(l[0]) + "\",\n")
f.write("};\n\n")
f.write("const char *const LICENSE_BODIES[] = {\n\n")
for l in license_list:
for line in l[1:]:
if line == ".":
f.write("\t\"\\n\"\n")
else:
f.write("\t\"" + escape_string(line) + "\\n\"\n")
f.write("\t\"\",\n\n")
f.write("};\n\n")
f.write("#endif\n")
if __name__ == '__main__':
subprocess_main(globals())

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -47,27 +47,28 @@ CoreStringNames::CoreStringNames() :
#ifdef TOOLS_ENABLED
_sections_unfolded(StaticCString::create("_sections_unfolded")),
#endif
_custom_features(StaticCString::create("_custom_features")),
x(StaticCString::create("x")),
y(StaticCString::create("y")),
z(StaticCString::create("z")),
w(StaticCString::create("w")),
r(StaticCString::create("r")),
g(StaticCString::create("g")),
b(StaticCString::create("b")),
a(StaticCString::create("a")),
position(StaticCString::create("position")),
size(StaticCString::create("size")),
end(StaticCString::create("end")),
basis(StaticCString::create("basis")),
origin(StaticCString::create("origin")),
normal(StaticCString::create("normal")),
d(StaticCString::create("d")),
h(StaticCString::create("h")),
s(StaticCString::create("s")),
v(StaticCString::create("v")),
r8(StaticCString::create("r8")),
g8(StaticCString::create("g8")),
b8(StaticCString::create("b8")),
a8(StaticCString::create("a8")) {
_custom_features(StaticCString::create("_custom_features")) {
x = StaticCString::create("x");
y = StaticCString::create("y");
z = StaticCString::create("z");
w = StaticCString::create("w");
r = StaticCString::create("r");
g = StaticCString::create("g");
b = StaticCString::create("b");
a = StaticCString::create("a");
position = StaticCString::create("position");
size = StaticCString::create("size");
end = StaticCString::create("end");
basis = StaticCString::create("basis");
origin = StaticCString::create("origin");
normal = StaticCString::create("normal");
d = StaticCString::create("d");
h = StaticCString::create("h");
s = StaticCString::create("s");
v = StaticCString::create("v");
r8 = StaticCString::create("r8");
g8 = StaticCString::create("g8");
b8 = StaticCString::create("b8");
a8 = StaticCString::create("a8");
}

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -31,7 +31,7 @@
#ifndef CORE_STRING_NAMES_H
#define CORE_STRING_NAMES_H
#include "core/string_name.h"
#include "string_db.h"
class CoreStringNames {

View File

@ -1,372 +0,0 @@
/*************************************************************************/
/* cowdata.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef COWDATA_H_
#define COWDATA_H_
#include <string.h>
#include "core/os/memory.h"
#include "core/safe_refcount.h"
template <class T>
class Vector;
class String;
class CharString;
template <class T, class V>
class VMap;
template <class T>
class CowData {
template <class TV>
friend class Vector;
friend class String;
friend class CharString;
template <class TV, class VV>
friend class VMap;
private:
mutable T *_ptr;
// internal helpers
_FORCE_INLINE_ uint32_t *_get_refcount() const {
if (!_ptr)
return NULL;
return reinterpret_cast<uint32_t *>(_ptr) - 2;
}
_FORCE_INLINE_ uint32_t *_get_size() const {
if (!_ptr)
return NULL;
return reinterpret_cast<uint32_t *>(_ptr) - 1;
}
_FORCE_INLINE_ T *_get_data() const {
if (!_ptr)
return NULL;
return reinterpret_cast<T *>(_ptr);
}
_FORCE_INLINE_ size_t _get_alloc_size(size_t p_elements) const {
//return nearest_power_of_2_templated(p_elements*sizeof(T)+sizeof(SafeRefCount)+sizeof(int));
return next_power_of_2(p_elements * sizeof(T));
}
_FORCE_INLINE_ bool _get_alloc_size_checked(size_t p_elements, size_t *out) const {
#if defined(_add_overflow) && defined(_mul_overflow)
size_t o;
size_t p;
if (_mul_overflow(p_elements, sizeof(T), &o)) {
*out = 0;
return false;
}
*out = next_power_of_2(o);
if (_add_overflow(o, static_cast<size_t>(32), &p)) return false; //no longer allocated here
return true;
#else
// Speed is more important than correctness here, do the operations unchecked
// and hope the best
*out = _get_alloc_size(p_elements);
return true;
#endif
}
void _unref(void *p_data);
void _ref(const CowData *p_from);
void _ref(const CowData &p_from);
void _copy_on_write();
public:
void operator=(const CowData<T> &p_from) { _ref(p_from); }
_FORCE_INLINE_ T *ptrw() {
_copy_on_write();
return (T *)_get_data();
}
_FORCE_INLINE_ const T *ptr() const {
return _get_data();
}
_FORCE_INLINE_ int size() const {
uint32_t *size = (uint32_t *)_get_size();
if (size)
return *size;
else
return 0;
}
_FORCE_INLINE_ void clear() { resize(0); }
_FORCE_INLINE_ bool empty() const { return _ptr == 0; }
_FORCE_INLINE_ void set(int p_index, const T &p_elem) {
CRASH_BAD_INDEX(p_index, size());
_copy_on_write();
_get_data()[p_index] = p_elem;
}
_FORCE_INLINE_ T &get_m(int p_index) {
CRASH_BAD_INDEX(p_index, size());
_copy_on_write();
return _get_data()[p_index];
}
_FORCE_INLINE_ const T &get(int p_index) const {
CRASH_BAD_INDEX(p_index, size());
return _get_data()[p_index];
}
Error resize(int p_size);
_FORCE_INLINE_ void remove(int p_index) {
ERR_FAIL_INDEX(p_index, size());
T *p = ptrw();
int len = size();
for (int i = p_index; i < len - 1; i++) {
p[i] = p[i + 1];
};
resize(len - 1);
};
Error insert(int p_pos, const T &p_val) {
ERR_FAIL_INDEX_V(p_pos, size() + 1, ERR_INVALID_PARAMETER);
resize(size() + 1);
for (int i = (size() - 1); i > p_pos; i--)
set(i, get(i - 1));
set(p_pos, p_val);
return OK;
};
int find(const T &p_val, int p_from = 0) const;
_FORCE_INLINE_ CowData();
_FORCE_INLINE_ ~CowData();
_FORCE_INLINE_ CowData(CowData<T> &p_from) { _ref(p_from); };
};
template <class T>
void CowData<T>::_unref(void *p_data) {
if (!p_data)
return;
uint32_t *refc = _get_refcount();
if (atomic_decrement(refc) > 0)
return; // still in use
// clean up
if (!__has_trivial_destructor(T)) {
uint32_t *count = _get_size();
T *data = (T *)(count + 1);
for (uint32_t i = 0; i < *count; ++i) {
// call destructors
data[i].~T();
}
}
// free mem
Memory::free_static((uint8_t *)p_data, true);
}
template <class T>
void CowData<T>::_copy_on_write() {
if (!_ptr)
return;
uint32_t *refc = _get_refcount();
if (unlikely(*refc > 1)) {
/* in use by more than me */
uint32_t current_size = *_get_size();
uint32_t *mem_new = (uint32_t *)Memory::alloc_static(_get_alloc_size(current_size), true);
*(mem_new - 2) = 1; //refcount
*(mem_new - 1) = current_size; //size
T *_data = (T *)(mem_new);
// initialize new elements
if (__has_trivial_copy(T)) {
memcpy(mem_new, _ptr, current_size * sizeof(T));
} else {
for (uint32_t i = 0; i < current_size; i++) {
memnew_placement(&_data[i], T(_get_data()[i]));
}
}
_unref(_ptr);
_ptr = _data;
}
}
template <class T>
Error CowData<T>::resize(int p_size) {
ERR_FAIL_COND_V(p_size < 0, ERR_INVALID_PARAMETER);
if (p_size == size())
return OK;
if (p_size == 0) {
// wants to clean up
_unref(_ptr);
_ptr = NULL;
return OK;
}
// possibly changing size, copy on write
_copy_on_write();
size_t alloc_size;
ERR_FAIL_COND_V(!_get_alloc_size_checked(p_size, &alloc_size), ERR_OUT_OF_MEMORY);
if (p_size > size()) {
if (size() == 0) {
// alloc from scratch
uint32_t *ptr = (uint32_t *)Memory::alloc_static(alloc_size, true);
ERR_FAIL_COND_V(!ptr, ERR_OUT_OF_MEMORY);
*(ptr - 1) = 0; //size, currently none
*(ptr - 2) = 1; //refcount
_ptr = (T *)ptr;
} else {
void *_ptrnew = (T *)Memory::realloc_static(_ptr, alloc_size, true);
ERR_FAIL_COND_V(!_ptrnew, ERR_OUT_OF_MEMORY);
_ptr = (T *)(_ptrnew);
}
// construct the newly created elements
if (!__has_trivial_constructor(T)) {
T *elems = _get_data();
for (int i = *_get_size(); i < p_size; i++) {
memnew_placement(&elems[i], T);
}
}
*_get_size() = p_size;
} else if (p_size < size()) {
if (!__has_trivial_destructor(T)) {
// deinitialize no longer needed elements
for (uint32_t i = p_size; i < *_get_size(); i++) {
T *t = &_get_data()[i];
t->~T();
}
}
void *_ptrnew = (T *)Memory::realloc_static(_ptr, alloc_size, true);
ERR_FAIL_COND_V(!_ptrnew, ERR_OUT_OF_MEMORY);
_ptr = (T *)(_ptrnew);
*_get_size() = p_size;
}
return OK;
}
template <class T>
int CowData<T>::find(const T &p_val, int p_from) const {
int ret = -1;
if (p_from < 0 || size() == 0) {
return ret;
}
for (int i = p_from; i < size(); i++) {
if (get(i) == p_val) {
ret = i;
break;
}
}
return ret;
}
template <class T>
void CowData<T>::_ref(const CowData *p_from) {
_ref(*p_from);
}
template <class T>
void CowData<T>::_ref(const CowData &p_from) {
if (_ptr == p_from._ptr)
return; // self assign, do nothing.
_unref(_ptr);
_ptr = NULL;
if (!p_from._ptr)
return; //nothing to do
if (atomic_conditional_increment(p_from._get_refcount()) > 0) { // could reference
_ptr = p_from._ptr;
}
}
template <class T>
CowData<T>::CowData() {
_ptr = NULL;
}
template <class T>
CowData<T>::~CowData() {
_unref(_ptr);
}
#endif /* COW_H_ */

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -30,9 +30,9 @@
#include "dictionary.h"
#include "core/ordered_hash_map.h"
#include "core/safe_refcount.h"
#include "core/variant.h"
#include "ordered_hash_map.h"
#include "safe_refcount.h"
#include "variant.h"
struct DictionaryPrivate {
@ -50,32 +50,6 @@ void Dictionary::get_key_list(List<Variant> *p_keys) const {
}
}
Variant Dictionary::get_key_at_index(int p_index) const {
int index = 0;
for (OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::Element E = _p->variant_map.front(); E; E = E.next()) {
if (index == p_index) {
return E.key();
}
index++;
}
return Variant();
}
Variant Dictionary::get_value_at_index(int p_index) const {
int index = 0;
for (OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::Element E = _p->variant_map.front(); E; E = E.next()) {
if (index == p_index) {
return E.value();
}
index++;
}
return Variant();
}
Variant &Dictionary::operator[](const Variant &p_key) {
return _p->variant_map[p_key];
@ -112,15 +86,6 @@ Variant Dictionary::get_valid(const Variant &p_key) const {
return E.get();
}
Variant Dictionary::get(const Variant &p_key, const Variant &p_default) const {
const Variant *result = getptr(p_key);
if (!result) {
return p_default;
}
return *result;
}
int Dictionary::size() const {
return _p->variant_map.size();
@ -144,7 +109,12 @@ bool Dictionary::has_all(const Array &p_keys) const {
return true;
}
bool Dictionary::erase(const Variant &p_key) {
void Dictionary::erase(const Variant &p_key) {
_p->variant_map.erase(p_key);
}
bool Dictionary::erase_checked(const Variant &p_key) {
return _p->variant_map.erase(p_key);
}
@ -154,11 +124,6 @@ bool Dictionary::operator==(const Dictionary &p_dictionary) const {
return _p == p_dictionary._p;
}
bool Dictionary::operator!=(const Dictionary &p_dictionary) const {
return _p != p_dictionary._p;
}
void Dictionary::_ref(const Dictionary &p_from) const {
//make a copy first (thread safe)
@ -251,7 +216,7 @@ const Variant *Dictionary::next(const Variant *p_key) const {
return NULL;
}
Dictionary Dictionary::duplicate(bool p_deep) const {
Dictionary Dictionary::duplicate() const {
Dictionary n;
@ -259,7 +224,7 @@ Dictionary Dictionary::duplicate(bool p_deep) const {
get_key_list(&keys);
for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
n[E->get()] = p_deep ? operator[](E->get()).duplicate(p_deep) : operator[](E->get());
n[E->get()] = operator[](E->get());
}
return n;

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -31,10 +31,9 @@
#ifndef DICTIONARY_H
#define DICTIONARY_H
#include "core/array.h"
#include "core/list.h"
#include "core/ustring.h"
#include "array.h"
#include "list.h"
#include "ustring.h"
class Variant;
struct DictionaryPrivate;
@ -48,8 +47,6 @@ class Dictionary {
public:
void get_key_list(List<Variant> *p_keys) const;
Variant get_key_at_index(int p_index) const;
Variant get_value_at_index(int p_index) const;
Variant &operator[](const Variant &p_key);
const Variant &operator[](const Variant &p_key) const;
@ -58,7 +55,6 @@ public:
Variant *getptr(const Variant &p_key);
Variant get_valid(const Variant &p_key) const;
Variant get(const Variant &p_key, const Variant &p_default) const;
int size() const;
bool empty() const;
@ -67,10 +63,10 @@ public:
bool has(const Variant &p_key) const;
bool has_all(const Array &p_keys) const;
bool erase(const Variant &p_key);
void erase(const Variant &p_key);
bool erase_checked(const Variant &p_key);
bool operator==(const Dictionary &p_dictionary) const;
bool operator!=(const Dictionary &p_dictionary) const;
uint32_t hash() const;
void operator=(const Dictionary &p_dictionary);
@ -80,7 +76,7 @@ public:
Array keys() const;
Array values() const;
Dictionary duplicate(bool p_deep = false) const;
Dictionary duplicate() const;
Dictionary(const Dictionary &p_from);
Dictionary();

71
core/dvector.cpp Normal file
View File

@ -0,0 +1,71 @@
/*************************************************************************/
/* dvector.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "dvector.h"
Mutex *dvector_lock = NULL;
PoolAllocator *MemoryPool::memory_pool = NULL;
uint8_t *MemoryPool::pool_memory = NULL;
size_t *MemoryPool::pool_size = NULL;
MemoryPool::Alloc *MemoryPool::allocs = NULL;
MemoryPool::Alloc *MemoryPool::free_list = NULL;
uint32_t MemoryPool::alloc_count = 0;
uint32_t MemoryPool::allocs_used = 0;
Mutex *MemoryPool::alloc_mutex = NULL;
size_t MemoryPool::total_memory = 0;
size_t MemoryPool::max_memory = 0;
void MemoryPool::setup(uint32_t p_max_allocs) {
allocs = memnew_arr(Alloc, p_max_allocs);
alloc_count = p_max_allocs;
allocs_used = 0;
for (uint32_t i = 0; i < alloc_count - 1; i++) {
allocs[i].free_list = &allocs[i + 1];
}
free_list = &allocs[0];
alloc_mutex = Mutex::create();
}
void MemoryPool::cleanup() {
memdelete_arr(allocs);
memdelete(alloc_mutex);
ERR_EXPLAINC("There are still MemoryPool allocs in use at exit!");
ERR_FAIL_COND(allocs_used > 0);
}

643
core/dvector.h Normal file
View File

@ -0,0 +1,643 @@
/*************************************************************************/
/* dvector.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef DVECTOR_H
#define DVECTOR_H
#include "os/copymem.h"
#include "os/memory.h"
#include "os/rw_lock.h"
#include "pool_allocator.h"
#include "safe_refcount.h"
#include "ustring.h"
struct MemoryPool {
//avoid accessing these directly, must be public for template access
static PoolAllocator *memory_pool;
static uint8_t *pool_memory;
static size_t *pool_size;
struct Alloc {
SafeRefCount refcount;
uint32_t lock;
void *mem;
PoolAllocator::ID pool_id;
size_t size;
Alloc *free_list;
Alloc() {
mem = NULL;
lock = 0;
pool_id = POOL_ALLOCATOR_INVALID_ID;
size = 0;
free_list = NULL;
}
};
static Alloc *allocs;
static Alloc *free_list;
static uint32_t alloc_count;
static uint32_t allocs_used;
static Mutex *alloc_mutex;
static size_t total_memory;
static size_t max_memory;
static void setup(uint32_t p_max_allocs = (1 << 16));
static void cleanup();
};
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
template <class T>
class PoolVector {
MemoryPool::Alloc *alloc;
void _copy_on_write() {
if (!alloc)
return;
// ERR_FAIL_COND(alloc->lock>0); should not be illegal to lock this for copy on write, as it's a copy on write after all
// Refcount should not be zero, otherwise it's a misuse of COW
if (alloc->refcount.get() == 1)
return; //nothing to do
//must allocate something
MemoryPool::alloc_mutex->lock();
if (MemoryPool::allocs_used == MemoryPool::alloc_count) {
MemoryPool::alloc_mutex->unlock();
ERR_EXPLAINC("All memory pool allocations are in use, can't COW.");
ERR_FAIL();
}
MemoryPool::Alloc *old_alloc = alloc;
//take one from the free list
alloc = MemoryPool::free_list;
MemoryPool::free_list = alloc->free_list;
//increment the used counter
MemoryPool::allocs_used++;
//copy the alloc data
alloc->size = old_alloc->size;
alloc->refcount.init();
alloc->pool_id = POOL_ALLOCATOR_INVALID_ID;
alloc->lock = 0;
#ifdef DEBUG_ENABLED
MemoryPool::total_memory += alloc->size;
if (MemoryPool::total_memory > MemoryPool::max_memory) {
MemoryPool::max_memory = MemoryPool::total_memory;
}
#endif
MemoryPool::alloc_mutex->unlock();
if (MemoryPool::memory_pool) {
} else {
alloc->mem = memalloc(alloc->size);
}
{
Write w;
w._ref(alloc);
Read r;
r._ref(old_alloc);
int cur_elements = alloc->size / sizeof(T);
T *dst = (T *)w.ptr();
const T *src = (const T *)r.ptr();
for (int i = 0; i < cur_elements; i++) {
memnew_placement(&dst[i], T(src[i]));
}
}
if (old_alloc->refcount.unref() == true) {
//this should never happen but..
#ifdef DEBUG_ENABLED
MemoryPool::alloc_mutex->lock();
MemoryPool::total_memory -= old_alloc->size;
MemoryPool::alloc_mutex->unlock();
#endif
{
Write w;
w._ref(old_alloc);
int cur_elements = old_alloc->size / sizeof(T);
T *elems = (T *)w.ptr();
for (int i = 0; i < cur_elements; i++) {
elems[i].~T();
}
}
if (MemoryPool::memory_pool) {
//resize memory pool
//if none, create
//if some resize
} else {
memfree(old_alloc->mem);
old_alloc->mem = NULL;
old_alloc->size = 0;
MemoryPool::alloc_mutex->lock();
old_alloc->free_list = MemoryPool::free_list;
MemoryPool::free_list = old_alloc;
MemoryPool::allocs_used--;
MemoryPool::alloc_mutex->unlock();
}
}
}
void _reference(const PoolVector &p_dvector) {
if (alloc == p_dvector.alloc)
return;
_unreference();
if (!p_dvector.alloc) {
return;
}
if (p_dvector.alloc->refcount.ref()) {
alloc = p_dvector.alloc;
}
}
void _unreference() {
if (!alloc)
return;
if (alloc->refcount.unref() == false) {
alloc = NULL;
return;
}
//must be disposed!
{
int cur_elements = alloc->size / sizeof(T);
// Don't use write() here because it could otherwise provoke COW,
// which is not desirable here because we are destroying the last reference anyways
Write w;
// Reference to still prevent other threads from touching the alloc
w._ref(alloc);
for (int i = 0; i < cur_elements; i++) {
w[i].~T();
}
}
#ifdef DEBUG_ENABLED
MemoryPool::alloc_mutex->lock();
MemoryPool::total_memory -= alloc->size;
MemoryPool::alloc_mutex->unlock();
#endif
if (MemoryPool::memory_pool) {
//resize memory pool
//if none, create
//if some resize
} else {
memfree(alloc->mem);
alloc->mem = NULL;
alloc->size = 0;
MemoryPool::alloc_mutex->lock();
alloc->free_list = MemoryPool::free_list;
MemoryPool::free_list = alloc;
MemoryPool::allocs_used--;
MemoryPool::alloc_mutex->unlock();
}
alloc = NULL;
}
public:
class Access {
friend class PoolVector;
protected:
MemoryPool::Alloc *alloc;
T *mem;
_FORCE_INLINE_ void _ref(MemoryPool::Alloc *p_alloc) {
alloc = p_alloc;
if (alloc) {
if (atomic_increment(&alloc->lock) == 1) {
if (MemoryPool::memory_pool) {
//lock it and get mem
}
}
mem = (T *)alloc->mem;
}
}
_FORCE_INLINE_ void _unref() {
if (alloc) {
if (atomic_decrement(&alloc->lock) == 0) {
if (MemoryPool::memory_pool) {
//put mem back
}
}
mem = NULL;
alloc = NULL;
}
}
Access() {
alloc = NULL;
mem = NULL;
}
public:
virtual ~Access() {
_unref();
}
};
class Read : public Access {
public:
_FORCE_INLINE_ const T &operator[](int p_index) const { return this->mem[p_index]; }
_FORCE_INLINE_ const T *ptr() const { return this->mem; }
void operator=(const Read &p_read) {
if (this->alloc == p_read.alloc)
return;
this->_unref();
this->_ref(p_read.alloc);
}
Read(const Read &p_read) {
this->_ref(p_read.alloc);
}
Read() {}
};
class Write : public Access {
public:
_FORCE_INLINE_ T &operator[](int p_index) const { return this->mem[p_index]; }
_FORCE_INLINE_ T *ptr() const { return this->mem; }
void operator=(const Write &p_read) {
if (this->alloc == p_read.alloc)
return;
this->_unref();
this->_ref(p_read.alloc);
}
Write(const Write &p_read) {
this->_ref(p_read.alloc);
}
Write() {}
};
Read read() const {
Read r;
if (alloc) {
r._ref(alloc);
}
return r;
}
Write write() {
Write w;
if (alloc) {
_copy_on_write(); //make sure there is only one being acessed
w._ref(alloc);
}
return w;
}
template <class MC>
void fill_with(const MC &p_mc) {
int c = p_mc.size();
resize(c);
Write w = write();
int idx = 0;
for (const typename MC::Element *E = p_mc.front(); E; E = E->next()) {
w[idx++] = E->get();
}
}
void remove(int p_index) {
int s = size();
ERR_FAIL_INDEX(p_index, s);
Write w = write();
for (int i = p_index; i < s - 1; i++) {
w[i] = w[i + 1];
};
w = Write();
resize(s - 1);
}
inline int size() const;
T get(int p_index) const;
void set(int p_index, const T &p_val);
void push_back(const T &p_val);
void append(const T &p_val) { push_back(p_val); }
void append_array(const PoolVector<T> &p_arr) {
int ds = p_arr.size();
if (ds == 0)
return;
int bs = size();
resize(bs + ds);
Write w = write();
Read r = p_arr.read();
for (int i = 0; i < ds; i++)
w[bs + i] = r[i];
}
PoolVector<T> subarray(int p_from, int p_to) {
if (p_from < 0) {
p_from = size() + p_from;
}
if (p_to < 0) {
p_to = size() + p_to;
}
CRASH_BAD_INDEX(p_from, size());
CRASH_BAD_INDEX(p_to, size());
PoolVector<T> slice;
int span = 1 + p_to - p_from;
slice.resize(span);
Read r = read();
Write w = slice.write();
for (int i = 0; i < span; ++i) {
w[i] = r[p_from + i];
}
return slice;
}
Error insert(int p_pos, const T &p_val) {
int s = size();
ERR_FAIL_INDEX_V(p_pos, s + 1, ERR_INVALID_PARAMETER);
resize(s + 1);
{
Write w = write();
for (int i = s; i > p_pos; i--)
w[i] = w[i - 1];
w[p_pos] = p_val;
}
return OK;
}
String join(String delimiter) {
String rs = "";
int s = size();
Read r = read();
for (int i = 0; i < s; i++) {
rs += r[i] + delimiter;
}
rs.erase(rs.length() - delimiter.length(), delimiter.length());
return rs;
}
bool is_locked() const { return alloc && alloc->lock > 0; }
inline const T operator[](int p_index) const;
Error resize(int p_size);
void invert();
void operator=(const PoolVector &p_dvector) { _reference(p_dvector); }
PoolVector() { alloc = NULL; }
PoolVector(const PoolVector &p_dvector) {
alloc = NULL;
_reference(p_dvector);
}
~PoolVector() { _unreference(); }
};
template <class T>
int PoolVector<T>::size() const {
return alloc ? alloc->size / sizeof(T) : 0;
}
template <class T>
T PoolVector<T>::get(int p_index) const {
return operator[](p_index);
}
template <class T>
void PoolVector<T>::set(int p_index, const T &p_val) {
if (p_index < 0 || p_index >= size()) {
ERR_FAIL_COND(p_index < 0 || p_index >= size());
}
Write w = write();
w[p_index] = p_val;
}
template <class T>
void PoolVector<T>::push_back(const T &p_val) {
resize(size() + 1);
set(size() - 1, p_val);
}
template <class T>
const T PoolVector<T>::operator[](int p_index) const {
CRASH_BAD_INDEX(p_index, size());
Read r = read();
return r[p_index];
}
template <class T>
Error PoolVector<T>::resize(int p_size) {
if (alloc == NULL) {
if (p_size == 0)
return OK; //nothing to do here
//must allocate something
MemoryPool::alloc_mutex->lock();
if (MemoryPool::allocs_used == MemoryPool::alloc_count) {
MemoryPool::alloc_mutex->unlock();
ERR_EXPLAINC("All memory pool allocations are in use.");
ERR_FAIL_V(ERR_OUT_OF_MEMORY);
}
//take one from the free list
alloc = MemoryPool::free_list;
MemoryPool::free_list = alloc->free_list;
//increment the used counter
MemoryPool::allocs_used++;
//cleanup the alloc
alloc->size = 0;
alloc->refcount.init();
alloc->pool_id = POOL_ALLOCATOR_INVALID_ID;
MemoryPool::alloc_mutex->unlock();
} else {
ERR_FAIL_COND_V(alloc->lock > 0, ERR_LOCKED); //can't resize if locked!
}
size_t new_size = sizeof(T) * p_size;
if (alloc->size == new_size)
return OK; //nothing to do
if (p_size == 0) {
_unreference();
return OK;
}
_copy_on_write(); // make it unique
#ifdef DEBUG_ENABLED
MemoryPool::alloc_mutex->lock();
MemoryPool::total_memory -= alloc->size;
MemoryPool::total_memory += new_size;
if (MemoryPool::total_memory > MemoryPool::max_memory) {
MemoryPool::max_memory = MemoryPool::total_memory;
}
MemoryPool::alloc_mutex->unlock();
#endif
int cur_elements = alloc->size / sizeof(T);
if (p_size > cur_elements) {
if (MemoryPool::memory_pool) {
//resize memory pool
//if none, create
//if some resize
} else {
if (alloc->size == 0) {
alloc->mem = memalloc(new_size);
} else {
alloc->mem = memrealloc(alloc->mem, new_size);
}
}
alloc->size = new_size;
Write w = write();
for (int i = cur_elements; i < p_size; i++) {
memnew_placement(&w[i], T);
}
} else {
{
Write w = write();
for (int i = p_size; i < cur_elements; i++) {
w[i].~T();
}
}
if (MemoryPool::memory_pool) {
//resize memory pool
//if none, create
//if some resize
} else {
if (new_size == 0) {
memfree(alloc->mem);
alloc->mem = NULL;
alloc->size = 0;
MemoryPool::alloc_mutex->lock();
alloc->free_list = MemoryPool::free_list;
MemoryPool::free_list = alloc;
MemoryPool::allocs_used--;
MemoryPool::alloc_mutex->unlock();
} else {
alloc->mem = memrealloc(alloc->mem, new_size);
alloc->size = new_size;
}
}
}
return OK;
}
template <class T>
void PoolVector<T>::invert() {
T temp;
Write w = write();
int s = size();
int half_s = s / 2;
for (int i = 0; i < half_s; i++) {
temp = w[i];
w[i] = w[s - i - 1];
w[s - i - 1] = temp;
}
}
#endif

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -30,11 +30,8 @@
#include "engine.h"
#include "core/authors.gen.h"
#include "core/donors.gen.h"
#include "core/license.gen.h"
#include "core/version.h"
#include "core/version_hash.gen.h"
#include "version.h"
#include "version_hash.gen.h"
void Engine::set_iterations_per_second(int p_ips) {
@ -45,16 +42,6 @@ int Engine::get_iterations_per_second() const {
return ips;
}
void Engine::set_physics_jitter_fix(float p_threshold) {
if (p_threshold < 0)
p_threshold = 0;
physics_jitter_fix = p_threshold;
}
float Engine::get_physics_jitter_fix() const {
return physics_jitter_fix;
}
void Engine::set_target_fps(int p_fps) {
_target_fps = p_fps > 0 ? p_fps : 0;
}
@ -98,7 +85,6 @@ Dictionary Engine::get_version_info() const {
#else
dict["patch"] = 0;
#endif
dict["hex"] = VERSION_HEX;
dict["status"] = VERSION_STATUS;
dict["build"] = VERSION_BUILD;
dict["year"] = VERSION_YEAR;
@ -115,78 +101,6 @@ Dictionary Engine::get_version_info() const {
return dict;
}
static Array array_from_info(const char *const *info_list) {
Array arr;
for (int i = 0; info_list[i] != NULL; i++) {
arr.push_back(info_list[i]);
}
return arr;
}
static Array array_from_info_count(const char *const *info_list, int info_count) {
Array arr;
for (int i = 0; i < info_count; i++) {
arr.push_back(info_list[i]);
}
return arr;
}
Dictionary Engine::get_author_info() const {
Dictionary dict;
dict["lead_developers"] = array_from_info(AUTHORS_LEAD_DEVELOPERS);
dict["project_managers"] = array_from_info(AUTHORS_PROJECT_MANAGERS);
dict["founders"] = array_from_info(AUTHORS_FOUNDERS);
dict["developers"] = array_from_info(AUTHORS_DEVELOPERS);
return dict;
}
Array Engine::get_copyright_info() const {
Array components;
for (int component_index = 0; component_index < COPYRIGHT_INFO_COUNT; component_index++) {
const ComponentCopyright &cp_info = COPYRIGHT_INFO[component_index];
Dictionary component_dict;
component_dict["name"] = cp_info.name;
Array parts;
for (int i = 0; i < cp_info.part_count; i++) {
const ComponentCopyrightPart &cp_part = cp_info.parts[i];
Dictionary part_dict;
part_dict["files"] = array_from_info_count(cp_part.files, cp_part.file_count);
part_dict["copyright"] = array_from_info_count(cp_part.copyright_statements, cp_part.copyright_count);
part_dict["license"] = cp_part.license;
parts.push_back(part_dict);
}
component_dict["parts"] = parts;
components.push_back(component_dict);
}
return components;
}
Dictionary Engine::get_donor_info() const {
Dictionary donors;
donors["platinum_sponsors"] = array_from_info(DONORS_SPONSOR_PLAT);
donors["gold_sponsors"] = array_from_info(DONORS_SPONSOR_GOLD);
donors["mini_sponsors"] = array_from_info(DONORS_SPONSOR_MINI);
donors["gold_donors"] = array_from_info(DONORS_GOLD);
donors["silver_donors"] = array_from_info(DONORS_SILVER);
donors["bronze_donors"] = array_from_info(DONORS_BRONZE);
return donors;
}
Dictionary Engine::get_license_info() const {
Dictionary licenses;
for (int i = 0; i < LICENSE_COUNT; i++) {
licenses[LICENSE_NAMES[i]] = LICENSE_BODIES[i];
}
return licenses;
}
String Engine::get_license_text() const {
return String(GODOT_LICENSE_TEXT);
}
void Engine::add_singleton(const Singleton &p_singleton) {
singletons.push_back(p_singleton);
@ -223,7 +137,6 @@ Engine::Engine() {
singleton = this;
frames_drawn = 0;
ips = 60;
physics_jitter_fix = 0.5;
_frame_delay = 0;
_fps = 1;
_target_fps = 0;

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -31,10 +31,10 @@
#ifndef ENGINE_H
#define ENGINE_H
#include "core/list.h"
#include "core/os/main_loop.h"
#include "core/ustring.h"
#include "core/vector.h"
#include "list.h"
#include "os/main_loop.h"
#include "ustring.h"
#include "vector.h"
class Engine {
@ -57,7 +57,6 @@ private:
float _frame_step;
int ips;
float physics_jitter_fix;
float _fps;
int _target_fps;
float _time_scale;
@ -80,9 +79,6 @@ public:
virtual void set_iterations_per_second(int p_ips);
virtual int get_iterations_per_second() const;
void set_physics_jitter_fix(float p_threshold);
float get_physics_jitter_fix() const;
virtual void set_target_fps(int p_fps);
virtual float get_target_fps() const;
@ -118,14 +114,8 @@ public:
#endif
Dictionary get_version_info() const;
Dictionary get_author_info() const;
Array get_copyright_info() const;
Dictionary get_donor_info() const;
Dictionary get_license_info() const;
String get_license_text() const;
Engine();
virtual ~Engine() {}
};
#endif // ENGINE_H

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -39,7 +39,7 @@
*/
enum Error {
OK, // (0)
OK,
FAILED, ///< Generic fail error
ERR_UNAVAILABLE, ///< What is requested is unsupported/unavailable
ERR_UNCONFIGURED, ///< The object being used hasn't been properly set up yet
@ -69,12 +69,12 @@ enum Error {
ERR_CONNECTION_ERROR,
ERR_CANT_ACQUIRE_RESOURCE,
ERR_CANT_FORK,
ERR_INVALID_DATA, ///< Data passed is invalid (30)
ERR_INVALID_DATA, ///< Data passed is invalid (30)
ERR_INVALID_PARAMETER, ///< Parameter passed is invalid
ERR_ALREADY_EXISTS, ///< When adding, item already exists
ERR_DOES_NOT_EXIST, ///< When retrieving/erasing, if item does not exist
ERR_DOES_NOT_EXIST, ///< When retrieving/erasing, it item does not exist
ERR_DATABASE_CANT_READ, ///< database is full
ERR_DATABASE_CANT_WRITE, ///< database is full (35)
ERR_DATABASE_CANT_WRITE, ///< database is full (35)
ERR_COMPILATION_FAILED,
ERR_METHOD_NOT_FOUND,
ERR_LINK_FAILED,

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -30,7 +30,7 @@
#include "error_macros.h"
#include "core/io/logger.h"
#include "io/logger.h"
#include "os/os.h"
bool _err_error_exists = false;

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -31,7 +31,7 @@
#ifndef ERROR_MACROS_H
#define ERROR_MACROS_H
#include "core/typedefs.h"
#include "typedefs.h"
/**
* Error macros. Unlike exceptions and asserts, these macros try to maintain consistency and stability
* inside the code. It is recommended to always return processable data, so in case of an error, the
@ -154,20 +154,6 @@ extern bool _err_error_exists;
_err_error_exists = false; \
} while (0); // (*)
/** An index has failed if m_index >=m_size, the function exists.
* This function returns an error value, if returning Error, please select the most
* appropriate error condition from error_macros.h
*/
#define ERR_FAIL_UNSIGNED_INDEX_V(m_index, m_size, m_retval) \
do { \
if (unlikely((m_index) >= (m_size))) { \
_err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size)); \
return m_retval; \
} else \
_err_error_exists = false; \
} while (0); // (*)
/** Use this one if there is no sensible fallback, that is, the error is unrecoverable.
* We'll return a null reference and try to keep running.
*/
@ -310,16 +296,6 @@ extern bool _err_error_exists;
_err_error_exists = false; \
}
#define ERR_PRINT_ONCE(m_string) \
{ \
static bool first_print = true; \
if (first_print) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, m_string); \
_err_error_exists = false; \
first_print = false; \
} \
}
/** Print a warning string.
*/
@ -335,24 +311,4 @@ extern bool _err_error_exists;
_err_error_exists = false; \
}
#define WARN_PRINT_ONCE(m_string) \
{ \
static bool first_print = true; \
if (first_print) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, m_string, ERR_HANDLER_WARNING); \
_err_error_exists = false; \
first_print = false; \
} \
}
#define WARN_DEPRECATED \
{ \
static volatile bool warning_shown = false; \
if (!warning_shown) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "This method has been deprecated and will be removed in the future", ERR_HANDLER_WARNING); \
_err_error_exists = false; \
warning_shown = true; \
} \
}
#endif

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -69,6 +69,7 @@ void FuncRef::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_function", "name"), &FuncRef::set_function);
}
FuncRef::FuncRef() :
id(0) {
FuncRef::FuncRef() {
id = 0;
}

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -31,7 +31,7 @@
#ifndef FUNC_REF_H
#define FUNC_REF_H
#include "core/reference.h"
#include "reference.h"
class FuncRef : public Reference {

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -30,10 +30,10 @@
#include "global_constants.h"
#include "core/object.h"
#include "core/os/input_event.h"
#include "core/os/keyboard.h"
#include "core/variant.h"
#include "object.h"
#include "os/input_event.h"
#include "os/keyboard.h"
#include "variant.h"
struct _GlobalConstant {
@ -89,7 +89,6 @@ VARIANT_ENUM_CAST(KeyList);
VARIANT_ENUM_CAST(KeyModifierMask);
VARIANT_ENUM_CAST(ButtonList);
VARIANT_ENUM_CAST(JoystickList);
VARIANT_ENUM_CAST(MidiMessageList);
void register_global_constants() {
@ -379,8 +378,6 @@ void register_global_constants() {
BIND_GLOBAL_ENUM_CONSTANT(BUTTON_LEFT);
BIND_GLOBAL_ENUM_CONSTANT(BUTTON_RIGHT);
BIND_GLOBAL_ENUM_CONSTANT(BUTTON_MIDDLE);
BIND_GLOBAL_ENUM_CONSTANT(BUTTON_XBUTTON1);
BIND_GLOBAL_ENUM_CONSTANT(BUTTON_XBUTTON2);
BIND_GLOBAL_ENUM_CONSTANT(BUTTON_WHEEL_UP);
BIND_GLOBAL_ENUM_CONSTANT(BUTTON_WHEEL_DOWN);
BIND_GLOBAL_ENUM_CONSTANT(BUTTON_WHEEL_LEFT);
@ -388,8 +385,6 @@ void register_global_constants() {
BIND_GLOBAL_ENUM_CONSTANT(BUTTON_MASK_LEFT);
BIND_GLOBAL_ENUM_CONSTANT(BUTTON_MASK_RIGHT);
BIND_GLOBAL_ENUM_CONSTANT(BUTTON_MASK_MIDDLE);
BIND_GLOBAL_ENUM_CONSTANT(BUTTON_MASK_XBUTTON1);
BIND_GLOBAL_ENUM_CONSTANT(BUTTON_MASK_XBUTTON2);
//joypads
BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_0);
@ -459,66 +454,49 @@ void register_global_constants() {
BIND_GLOBAL_ENUM_CONSTANT(JOY_ANALOG_L2);
BIND_GLOBAL_ENUM_CONSTANT(JOY_ANALOG_R2);
// midi
BIND_GLOBAL_ENUM_CONSTANT(MIDI_MESSAGE_NOTE_OFF);
BIND_GLOBAL_ENUM_CONSTANT(MIDI_MESSAGE_NOTE_ON);
BIND_GLOBAL_ENUM_CONSTANT(MIDI_MESSAGE_AFTERTOUCH);
BIND_GLOBAL_ENUM_CONSTANT(MIDI_MESSAGE_CONTROL_CHANGE);
BIND_GLOBAL_ENUM_CONSTANT(MIDI_MESSAGE_PROGRAM_CHANGE);
BIND_GLOBAL_ENUM_CONSTANT(MIDI_MESSAGE_CHANNEL_PRESSURE);
BIND_GLOBAL_ENUM_CONSTANT(MIDI_MESSAGE_PITCH_BEND);
// error list
BIND_GLOBAL_ENUM_CONSTANT(OK); // (0)
BIND_GLOBAL_ENUM_CONSTANT(FAILED);
BIND_GLOBAL_ENUM_CONSTANT(ERR_UNAVAILABLE);
BIND_GLOBAL_ENUM_CONSTANT(ERR_UNCONFIGURED);
BIND_GLOBAL_ENUM_CONSTANT(ERR_UNAUTHORIZED);
BIND_GLOBAL_ENUM_CONSTANT(ERR_PARAMETER_RANGE_ERROR); // (5)
BIND_GLOBAL_ENUM_CONSTANT(ERR_OUT_OF_MEMORY);
BIND_GLOBAL_ENUM_CONSTANT(OK);
BIND_GLOBAL_ENUM_CONSTANT(FAILED); ///< Generic fail error
BIND_GLOBAL_ENUM_CONSTANT(ERR_UNAVAILABLE); ///< What is requested is unsupported/unavailable
BIND_GLOBAL_ENUM_CONSTANT(ERR_UNCONFIGURED); ///< The object being used hasn't been properly set up yet
BIND_GLOBAL_ENUM_CONSTANT(ERR_UNAUTHORIZED); ///< Missing credentials for requested resource
BIND_GLOBAL_ENUM_CONSTANT(ERR_PARAMETER_RANGE_ERROR); ///< Parameter given out of range
BIND_GLOBAL_ENUM_CONSTANT(ERR_OUT_OF_MEMORY); ///< Out of memory
BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_NOT_FOUND);
BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_BAD_DRIVE);
BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_BAD_PATH);
BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_NO_PERMISSION); // (10)
BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_NO_PERMISSION);
BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_ALREADY_IN_USE);
BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_CANT_OPEN);
BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_CANT_WRITE);
BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_CANT_READ);
BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_UNRECOGNIZED); // (15)
BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_UNRECOGNIZED);
BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_CORRUPT);
BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_MISSING_DEPENDENCIES);
BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_EOF);
BIND_GLOBAL_ENUM_CONSTANT(ERR_CANT_OPEN);
BIND_GLOBAL_ENUM_CONSTANT(ERR_CANT_CREATE); // (20)
BIND_GLOBAL_ENUM_CONSTANT(ERR_CANT_OPEN); ///< Can't open a resource/socket/file
BIND_GLOBAL_ENUM_CONSTANT(ERR_CANT_CREATE);
BIND_GLOBAL_ENUM_CONSTANT(ERR_PARSE_ERROR);
BIND_GLOBAL_ENUM_CONSTANT(ERR_QUERY_FAILED);
BIND_GLOBAL_ENUM_CONSTANT(ERR_ALREADY_IN_USE);
BIND_GLOBAL_ENUM_CONSTANT(ERR_LOCKED);
BIND_GLOBAL_ENUM_CONSTANT(ERR_LOCKED); ///< resource is locked
BIND_GLOBAL_ENUM_CONSTANT(ERR_TIMEOUT);
BIND_GLOBAL_ENUM_CONSTANT(ERR_CANT_CONNECT); // (25)
BIND_GLOBAL_ENUM_CONSTANT(ERR_CANT_RESOLVE);
BIND_GLOBAL_ENUM_CONSTANT(ERR_CONNECTION_ERROR);
BIND_GLOBAL_ENUM_CONSTANT(ERR_CANT_ACQUIRE_RESOURCE);
BIND_GLOBAL_ENUM_CONSTANT(ERR_CANT_FORK);
BIND_GLOBAL_ENUM_CONSTANT(ERR_INVALID_DATA); // (30)
BIND_GLOBAL_ENUM_CONSTANT(ERR_INVALID_PARAMETER);
BIND_GLOBAL_ENUM_CONSTANT(ERR_ALREADY_EXISTS);
BIND_GLOBAL_ENUM_CONSTANT(ERR_DOES_NOT_EXIST);
BIND_GLOBAL_ENUM_CONSTANT(ERR_DATABASE_CANT_READ);
BIND_GLOBAL_ENUM_CONSTANT(ERR_DATABASE_CANT_WRITE); // (35)
BIND_GLOBAL_ENUM_CONSTANT(ERR_INVALID_DATA); ///< Data passed is invalid
BIND_GLOBAL_ENUM_CONSTANT(ERR_INVALID_PARAMETER); ///< Parameter passed is invalid
BIND_GLOBAL_ENUM_CONSTANT(ERR_ALREADY_EXISTS); ///< When adding ), item already exists
BIND_GLOBAL_ENUM_CONSTANT(ERR_DOES_NOT_EXIST); ///< When retrieving/erasing ), it item does not exist
BIND_GLOBAL_ENUM_CONSTANT(ERR_DATABASE_CANT_READ); ///< database is full
BIND_GLOBAL_ENUM_CONSTANT(ERR_DATABASE_CANT_WRITE); ///< database is full
BIND_GLOBAL_ENUM_CONSTANT(ERR_COMPILATION_FAILED);
BIND_GLOBAL_ENUM_CONSTANT(ERR_METHOD_NOT_FOUND);
BIND_GLOBAL_ENUM_CONSTANT(ERR_LINK_FAILED);
BIND_GLOBAL_ENUM_CONSTANT(ERR_SCRIPT_FAILED);
BIND_GLOBAL_ENUM_CONSTANT(ERR_CYCLIC_LINK); // (40)
BIND_GLOBAL_ENUM_CONSTANT(ERR_INVALID_DECLARATION);
BIND_GLOBAL_ENUM_CONSTANT(ERR_DUPLICATE_SYMBOL);
BIND_GLOBAL_ENUM_CONSTANT(ERR_PARSE_ERROR);
BIND_GLOBAL_ENUM_CONSTANT(ERR_CYCLIC_LINK);
BIND_GLOBAL_ENUM_CONSTANT(ERR_BUSY);
BIND_GLOBAL_ENUM_CONSTANT(ERR_SKIP); // (45)
BIND_GLOBAL_ENUM_CONSTANT(ERR_HELP);
BIND_GLOBAL_ENUM_CONSTANT(ERR_BUG);
BIND_GLOBAL_ENUM_CONSTANT(ERR_PRINTER_ON_FIRE);
BIND_GLOBAL_ENUM_CONSTANT(ERR_HELP); ///< user requested help!!
BIND_GLOBAL_ENUM_CONSTANT(ERR_BUG); ///< a bug in the software certainly happened ), due to a double check failing or unexpected behavior.
BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_NONE);
BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_RANGE);
@ -540,7 +518,6 @@ void register_global_constants() {
BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_GLOBAL_DIR);
BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_RESOURCE_TYPE);
BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_MULTILINE_TEXT);
BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_PLACEHOLDER_TEXT);
BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_COLOR_NO_ALPHA);
BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_IMAGE_COMPRESS_LOSSY);
BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_IMAGE_COMPRESS_LOSSLESS);
@ -555,9 +532,8 @@ void register_global_constants() {
BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_USAGE_INTERNATIONALIZED);
BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_USAGE_GROUP);
BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_USAGE_CATEGORY);
//deprecated, replaced by ClassDB function to check default value
//BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_USAGE_STORE_IF_NONZERO);
//BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_USAGE_STORE_IF_NONONE);
BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_USAGE_STORE_IF_NONZERO);
BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_USAGE_STORE_IF_NONONE);
BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_USAGE_NO_INSTANCE_STATE);
BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_USAGE_RESTART_IF_CHANGED);
BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_USAGE_SCRIPT_VARIABLE);

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -31,7 +31,7 @@
#ifndef GLOBAL_CONSTANTS_H
#define GLOBAL_CONSTANTS_H
#include "core/string_name.h"
#include "string_db.h"
class GlobalConstants {
public:

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -31,12 +31,12 @@
#ifndef HASH_MAP_H
#define HASH_MAP_H
#include "core/error_macros.h"
#include "core/hashfuncs.h"
#include "core/list.h"
#include "core/math/math_funcs.h"
#include "core/os/memory.h"
#include "core/ustring.h"
#include "error_macros.h"
#include "hashfuncs.h"
#include "list.h"
#include "math_funcs.h"
#include "os/memory.h"
#include "ustring.h"
/**
* @class HashMap
@ -150,7 +150,7 @@ private:
if (new_hash_table_power == -1)
return;
Element **new_hash_table = memnew_arr(Element *, ((uint64_t)1 << new_hash_table_power));
Element **new_hash_table = memnew_arr(Element *, (1 << new_hash_table_power));
if (!new_hash_table) {
ERR_PRINT("Out of Memory");
@ -230,7 +230,7 @@ private:
if (!p_t.hash_table || p_t.hash_table_power == 0)
return; /* not copying from empty table */
hash_table = memnew_arr(Element *, (uint64_t)1 << p_t.hash_table_power);
hash_table = memnew_arr(Element *, 1 << p_t.hash_table_power);
hash_table_power = p_t.hash_table_power;
elements = p_t.elements;

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -31,12 +31,10 @@
#ifndef HASHFUNCS_H
#define HASHFUNCS_H
#include "core/math/math_defs.h"
#include "core/math/math_funcs.h"
#include "core/node_path.h"
#include "core/string_name.h"
#include "core/typedefs.h"
#include "core/ustring.h"
#include "math_defs.h"
#include "math_funcs.h"
#include "typedefs.h"
#include "ustring.h"
/**
* Hashing functions
@ -133,7 +131,6 @@ static inline uint64_t make_uint64_t(T p_in) {
}
struct HashMapHasherDefault {
static _FORCE_INLINE_ uint32_t hash(const String &p_string) { return p_string.hash(); }
static _FORCE_INLINE_ uint32_t hash(const char *p_cstr) { return hash_djb2(p_cstr); }
static _FORCE_INLINE_ uint32_t hash(const uint64_t p_int) { return hash_one_uint64(p_int); }
@ -148,10 +145,6 @@ struct HashMapHasherDefault {
static _FORCE_INLINE_ uint32_t hash(const uint8_t p_int) { return p_int; }
static _FORCE_INLINE_ uint32_t hash(const int8_t p_int) { return (uint32_t)p_int; }
static _FORCE_INLINE_ uint32_t hash(const wchar_t p_wchar) { return (uint32_t)p_wchar; }
static _FORCE_INLINE_ uint32_t hash(const StringName &p_string_name) { return p_string_name.hash(); }
static _FORCE_INLINE_ uint32_t hash(const NodePath &p_path) { return p_path.hash(); }
//static _FORCE_INLINE_ uint32_t hash(const void* p_ptr) { return uint32_t(uint64_t(p_ptr))*(0x9e3779b1L); }
};

7
core/helper/SCsub Normal file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env python
Import('env')
env.add_source_files(env.core_sources, "*.cpp")
Export('env')

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -30,7 +30,7 @@
#ifdef TOOLS_ENABLED
#include "math_fieldwise.h"
#include "core/helper/math_fieldwise.h"
#define SETUP_TYPE(m_type) \
m_type source = p_source; \

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */

View File

@ -0,0 +1,46 @@
/*************************************************************************/
/* value_evaluator.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef VALUE_EVALUATOR_H
#define VALUE_EVALUATOR_H
#include "core/object.h"
class ValueEvaluator : public Object {
GDCLASS(ValueEvaluator, Object);
public:
virtual double eval(const String &p_text) {
return p_text.to_double();
}
};
#endif // VALUE_EVALUATOR_H

File diff suppressed because it is too large Load Diff

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -31,10 +31,10 @@
#ifndef IMAGE_H
#define IMAGE_H
#include "core/color.h"
#include "core/math/rect2.h"
#include "core/pool_vector.h"
#include "core/resource.h"
#include "color.h"
#include "dvector.h"
#include "math_2d.h"
#include "resource.h"
/**
* @author Juan Linietsky <reduzio@gmail.com>
@ -47,19 +47,18 @@
class Image;
typedef Error (*SavePNGFunc)(const String &p_path, const Ref<Image> &p_img);
typedef Ref<Image> (*ImageMemLoadFunc)(const uint8_t *p_png, int p_size);
class Image : public Resource {
GDCLASS(Image, Resource);
public:
static SavePNGFunc save_png_func;
enum {
MAX_WIDTH = 16384, // force a limit somehow
MAX_HEIGHT = 16384 // force a limit somehow
};
public:
static SavePNGFunc save_png_func;
enum Format {
FORMAT_L8, //luminance
@ -108,26 +107,21 @@ public:
INTERPOLATE_NEAREST,
INTERPOLATE_BILINEAR,
INTERPOLATE_CUBIC,
INTERPOLATE_TRILINEAR,
/* INTERPOLATE_TRICUBIC, */
/* INTERPOLATE GAUSS */
};
enum CompressSource {
COMPRESS_SOURCE_GENERIC,
COMPRESS_SOURCE_SRGB,
COMPRESS_SOURCE_NORMAL,
COMPRESS_SOURCE_LAYERED,
COMPRESS_SOURCE_NORMAL
};
//some functions provided by something else
static ImageMemLoadFunc _png_mem_loader_func;
static ImageMemLoadFunc _jpg_mem_loader_func;
static ImageMemLoadFunc _webp_mem_loader_func;
static Ref<Image> (*_png_mem_loader_func)(const uint8_t *p_png, int p_size);
static Ref<Image> (*_jpg_mem_loader_func)(const uint8_t *p_png, int p_size);
static void (*_image_compress_bc_func)(Image *, float, CompressSource p_source);
static void (*_image_compress_bptc_func)(Image *, float p_lossy_quality, CompressSource p_source);
static void (*_image_compress_bc_func)(Image *, CompressSource p_source);
static void (*_image_compress_pvrtc2_func)(Image *);
static void (*_image_compress_pvrtc4_func)(Image *);
static void (*_image_compress_etc1_func)(Image *, float);
@ -135,7 +129,6 @@ public:
static void (*_image_decompress_pvrtc)(Image *);
static void (*_image_decompress_bc)(Image *);
static void (*_image_decompress_bptc)(Image *);
static void (*_image_decompress_etc1)(Image *);
static void (*_image_decompress_etc2)(Image *);
@ -182,17 +175,6 @@ private:
void _set_data(const Dictionary &p_data);
Dictionary _get_data() const;
Error _load_from_buffer(const PoolVector<uint8_t> &p_array, ImageMemLoadFunc p_loader);
static void average_4_uint8(uint8_t &p_out, const uint8_t &p_a, const uint8_t &p_b, const uint8_t &p_c, const uint8_t &p_d);
static void average_4_float(float &p_out, const float &p_a, const float &p_b, const float &p_c, const float &p_d);
static void average_4_half(uint16_t &p_out, const uint16_t &p_a, const uint16_t &p_b, const uint16_t &p_c, const uint16_t &p_d);
static void average_4_rgbe9995(uint32_t &p_out, const uint32_t &p_a, const uint32_t &p_b, const uint32_t &p_c, const uint32_t &p_d);
static void renormalize_uint8(uint8_t *p_rgb);
static void renormalize_float(float *p_rgb);
static void renormalize_half(uint16_t *p_rgb);
static void renormalize_rgbe9995(uint32_t *p_rgb);
public:
int get_width() const; ///< Get image width
int get_height() const; ///< Get image height
@ -223,7 +205,6 @@ public:
void resize(int p_width, int p_height, Interpolation p_interpolation = INTERPOLATE_BILINEAR);
void shrink_x2();
void expand_x2_hq2x();
bool is_size_po2() const;
/**
* Crop the image to a specific size, if larger, then the image is filled by black
*/
@ -236,10 +217,9 @@ public:
/**
* Generate a mipmap to an image (creates an image 1/4 the size, with averaging of 4->1)
*/
Error generate_mipmaps(bool p_renormalize = false);
Error generate_mipmaps();
void clear_mipmaps();
void normalize(); //for normal maps
/**
* Create a new image of a given size and format. Current image will be lost
@ -285,9 +265,8 @@ public:
static int get_format_block_size(Format p_format);
static void get_format_min_pixel_size(Format p_format, int &r_w, int &r_h);
static int get_image_data_size(int p_width, int p_height, Format p_format, bool p_mipmaps = false);
static int get_image_data_size(int p_width, int p_height, Format p_format, int p_mipmaps = 0);
static int get_image_required_mipmaps(int p_width, int p_height, Format p_format);
static int get_image_mipmap_offset(int p_width, int p_height, Format p_format, int p_mipmap);
enum CompressMode {
COMPRESS_S3TC,
@ -295,7 +274,6 @@ public:
COMPRESS_PVRTC4,
COMPRESS_ETC,
COMPRESS_ETC2,
COMPRESS_BPTC
};
Error compress(CompressMode p_mode = COMPRESS_S3TC, CompressSource p_source = COMPRESS_SOURCE_GENERIC, float p_lossy_quality = 0.7);
@ -306,8 +284,6 @@ public:
void premultiply_alpha();
void srgb_to_linear();
void normalmap_to_xy();
Ref<Image> rgbe_to_srgb();
void bumpmap_to_normalmap(float bump_scale = 1.0);
void blit_rect(const Ref<Image> &p_src, const Rect2 &p_src_rect, const Point2 &p_dest);
void blit_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, const Rect2 &p_src_rect, const Point2 &p_dest);
@ -318,13 +294,11 @@ public:
Rect2 get_used_rect() const;
Ref<Image> get_rect(const Rect2 &p_area) const;
static void set_compress_bc_func(void (*p_compress_func)(Image *, float, CompressSource));
static void set_compress_bptc_func(void (*p_compress_func)(Image *, float, CompressSource));
static void set_compress_bc_func(void (*p_compress_func)(Image *, CompressSource));
static String get_format_name(Format p_format);
Error load_png_from_buffer(const PoolVector<uint8_t> &p_array);
Error load_jpg_from_buffer(const PoolVector<uint8_t> &p_array);
Error load_webp_from_buffer(const PoolVector<uint8_t> &p_array);
Image(const uint8_t *p_mem_png_jpg, int p_len = -1);
Image(const char **p_xpm);
@ -345,11 +319,8 @@ public:
};
DetectChannels get_detected_channels();
void optimize_channels();
Color get_pixelv(const Point2 &p_src) const;
Color get_pixel(int p_x, int p_y) const;
void set_pixelv(const Point2 &p_dest, const Color &p_color);
void set_pixel(int p_x, int p_y, const Color &p_color);
void copy_internals_from(const Ref<Image> &p_image) {

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -30,37 +30,32 @@
#include "input_map.h"
#include "core/os/keyboard.h"
#include "core/project_settings.h"
#include "os/keyboard.h"
#include "project_settings.h"
InputMap *InputMap::singleton = NULL;
int InputMap::ALL_DEVICES = -1;
void InputMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("has_action", "action"), &InputMap::has_action);
ClassDB::bind_method(D_METHOD("get_actions"), &InputMap::_get_actions);
ClassDB::bind_method(D_METHOD("add_action", "action", "deadzone"), &InputMap::add_action, DEFVAL(0.5f));
ClassDB::bind_method(D_METHOD("add_action", "action"), &InputMap::add_action);
ClassDB::bind_method(D_METHOD("erase_action", "action"), &InputMap::erase_action);
ClassDB::bind_method(D_METHOD("action_set_deadzone", "action", "deadzone"), &InputMap::action_set_deadzone);
ClassDB::bind_method(D_METHOD("action_add_event", "action", "event"), &InputMap::action_add_event);
ClassDB::bind_method(D_METHOD("action_has_event", "action", "event"), &InputMap::action_has_event);
ClassDB::bind_method(D_METHOD("action_erase_event", "action", "event"), &InputMap::action_erase_event);
ClassDB::bind_method(D_METHOD("action_erase_events", "action"), &InputMap::action_erase_events);
ClassDB::bind_method(D_METHOD("get_action_list", "action"), &InputMap::_get_action_list);
ClassDB::bind_method(D_METHOD("event_is_action", "event", "action"), &InputMap::event_is_action);
ClassDB::bind_method(D_METHOD("load_from_globals"), &InputMap::load_from_globals);
}
void InputMap::add_action(const StringName &p_action, float p_deadzone) {
void InputMap::add_action(const StringName &p_action) {
ERR_FAIL_COND(input_map.has(p_action));
input_map[p_action] = Action();
static int last_id = 1;
input_map[p_action].id = last_id;
input_map[p_action].deadzone = p_deadzone;
last_id++;
}
@ -99,21 +94,19 @@ List<StringName> InputMap::get_actions() const {
return actions;
}
List<Ref<InputEvent> >::Element *InputMap::_find_event(Action &p_action, const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength) const {
List<Ref<InputEvent> >::Element *InputMap::_find_event(List<Ref<InputEvent> > &p_list, const Ref<InputEvent> &p_event, bool p_action_test) const {
for (List<Ref<InputEvent> >::Element *E = p_action.inputs.front(); E; E = E->next()) {
for (List<Ref<InputEvent> >::Element *E = p_list.front(); E; E = E->next()) {
const Ref<InputEvent> e = E->get();
//if (e.type != Ref<InputEvent>::KEY && e.device != p_event.device) -- unsure about the KEY comparison, why is this here?
// continue;
int device = e->get_device();
if (device == ALL_DEVICES || device == p_event->get_device()) {
if (e->action_match(p_event, p_pressed, p_strength, p_action.deadzone)) {
return E;
}
}
if (e->get_device() != p_event->get_device())
continue;
if (e->action_match(p_event))
return E;
}
return NULL;
@ -124,18 +117,11 @@ bool InputMap::has_action(const StringName &p_action) const {
return input_map.has(p_action);
}
void InputMap::action_set_deadzone(const StringName &p_action, float p_deadzone) {
ERR_FAIL_COND(!input_map.has(p_action));
input_map[p_action].deadzone = p_deadzone;
}
void InputMap::action_add_event(const StringName &p_action, const Ref<InputEvent> &p_event) {
ERR_FAIL_COND(p_event.is_null());
ERR_FAIL_COND(!input_map.has(p_action));
if (_find_event(input_map[p_action], p_event))
if (_find_event(input_map[p_action].inputs, p_event))
return; //already gots
input_map[p_action].inputs.push_back(p_event);
@ -144,25 +130,18 @@ void InputMap::action_add_event(const StringName &p_action, const Ref<InputEvent
bool InputMap::action_has_event(const StringName &p_action, const Ref<InputEvent> &p_event) {
ERR_FAIL_COND_V(!input_map.has(p_action), false);
return (_find_event(input_map[p_action], p_event) != NULL);
return (_find_event(input_map[p_action].inputs, p_event) != NULL);
}
void InputMap::action_erase_event(const StringName &p_action, const Ref<InputEvent> &p_event) {
ERR_FAIL_COND(!input_map.has(p_action));
List<Ref<InputEvent> >::Element *E = _find_event(input_map[p_action], p_event);
List<Ref<InputEvent> >::Element *E = _find_event(input_map[p_action].inputs, p_event);
if (E)
input_map[p_action].inputs.erase(E);
}
void InputMap::action_erase_events(const StringName &p_action) {
ERR_FAIL_COND(!input_map.has(p_action));
input_map[p_action].inputs.clear();
}
Array InputMap::_get_action_list(const StringName &p_action) {
Array ret;
@ -187,37 +166,19 @@ const List<Ref<InputEvent> > *InputMap::get_action_list(const StringName &p_acti
}
bool InputMap::event_is_action(const Ref<InputEvent> &p_event, const StringName &p_action) const {
return event_get_action_status(p_event, p_action);
}
bool InputMap::event_get_action_status(const Ref<InputEvent> &p_event, const StringName &p_action, bool *p_pressed, float *p_strength) const {
Map<StringName, Action>::Element *E = input_map.find(p_action);
if (!E) {
ERR_EXPLAIN("Request for nonexistent InputMap action: " + String(p_action));
ERR_FAIL_COND_V(!E, false);
}
Ref<InputEventAction> input_event_action = p_event;
if (input_event_action.is_valid()) {
if (p_pressed != NULL)
*p_pressed = input_event_action->is_pressed();
if (p_strength != NULL)
*p_strength = (*p_pressed) ? 1.0f : 0.0f;
return input_event_action->get_action() == p_action;
Ref<InputEventAction> iea = p_event;
if (iea.is_valid()) {
return iea->get_action() == p_action;
}
bool pressed;
float strength;
List<Ref<InputEvent> >::Element *event = _find_event(E->get(), p_event, &pressed, &strength);
if (event != NULL) {
if (p_pressed != NULL)
*p_pressed = pressed;
if (p_strength != NULL)
*p_strength = strength;
return true;
} else {
return false;
}
return _find_event(E->get().inputs, p_event, true) != NULL;
}
const Map<StringName, InputMap::Action> &InputMap::get_action_map() const {
@ -239,16 +200,16 @@ void InputMap::load_from_globals() {
String name = pi.name.substr(pi.name.find("/") + 1, pi.name.length());
Dictionary action = ProjectSettings::get_singleton()->get(pi.name);
float deadzone = action.has("deadzone") ? (float)action["deadzone"] : 0.5f;
Array events = action["events"];
add_action(name);
add_action(name, deadzone);
for (int i = 0; i < events.size(); i++) {
Ref<InputEvent> event = events[i];
if (event.is_null())
Array va = ProjectSettings::get_singleton()->get(pi.name);
for (int i = 0; i < va.size(); i++) {
Ref<InputEvent> ie = va[i];
if (ie.is_null())
continue;
action_add_event(name, event);
action_add_event(name, ie);
}
}
}
@ -321,16 +282,6 @@ void InputMap::load_default() {
key->set_scancode(KEY_PAGEDOWN);
action_add_event("ui_page_down", key);
add_action("ui_home");
key.instance();
key->set_scancode(KEY_HOME);
action_add_event("ui_home", key);
add_action("ui_end");
key.instance();
key->set_scancode(KEY_END);
action_add_event("ui_end", key);
//set("display/window/handheld/orientation", "landscape");
}

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -31,22 +31,16 @@
#ifndef INPUT_MAP_H
#define INPUT_MAP_H
#include "core/object.h"
#include "core/os/input_event.h"
#include "object.h"
#include "os/input_event.h"
class InputMap : public Object {
GDCLASS(InputMap, Object);
public:
/**
* A special value used to signify that a given Action can be triggered by any device
*/
static int ALL_DEVICES;
struct Action {
int id;
float deadzone;
List<Ref<InputEvent> > inputs;
};
@ -55,7 +49,7 @@ private:
mutable Map<StringName, Action> input_map;
List<Ref<InputEvent> >::Element *_find_event(Action &p_action, const Ref<InputEvent> &p_event, bool *p_pressed = NULL, float *p_strength = NULL) const;
List<Ref<InputEvent> >::Element *_find_event(List<Ref<InputEvent> > &p_list, const Ref<InputEvent> &p_event, bool p_action_test = false) const;
Array _get_action_list(const StringName &p_action);
Array _get_actions();
@ -68,18 +62,15 @@ public:
bool has_action(const StringName &p_action) const;
List<StringName> get_actions() const;
void add_action(const StringName &p_action, float p_deadzone = 0.5);
void add_action(const StringName &p_action);
void erase_action(const StringName &p_action);
void action_set_deadzone(const StringName &p_action, float p_deadzone);
void action_add_event(const StringName &p_action, const Ref<InputEvent> &p_event);
bool action_has_event(const StringName &p_action, const Ref<InputEvent> &p_event);
void action_erase_event(const StringName &p_action, const Ref<InputEvent> &p_event);
void action_erase_events(const StringName &p_action);
const List<Ref<InputEvent> > *get_action_list(const StringName &p_action);
bool event_is_action(const Ref<InputEvent> &p_event, const StringName &p_action) const;
bool event_get_action_status(const Ref<InputEvent> &p_event, const StringName &p_action, bool *p_pressed = NULL, float *p_strength = NULL) const;
const Map<StringName, Action> &get_action_map() const;
void load_from_globals();

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */

View File

@ -3,3 +3,6 @@
Import('env')
env.add_source_files(env.core_sources, "*.cpp")
Export('env')

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -29,10 +29,9 @@
/*************************************************************************/
#include "compression.h"
#include "core/io/zip_io.h"
#include "core/os/copymem.h"
#include "core/project_settings.h"
#include "os/copymem.h"
#include "project_settings.h"
#include "zip_io.h"
#include "thirdparty/misc/fastlz.h"
@ -81,10 +80,10 @@ int Compression::compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size,
} break;
case MODE_ZSTD: {
ZSTD_CCtx *cctx = ZSTD_createCCtx();
ZSTD_CCtx_setParameter(cctx, ZSTD_c_compressionLevel, zstd_level);
ZSTD_CCtx_setParameter(cctx, ZSTD_p_compressionLevel, zstd_level);
if (zstd_long_distance_matching) {
ZSTD_CCtx_setParameter(cctx, ZSTD_c_enableLongDistanceMatching, 1);
ZSTD_CCtx_setParameter(cctx, ZSTD_c_windowLog, zstd_window_log_size);
ZSTD_CCtx_setParameter(cctx, ZSTD_p_enableLongDistanceMatching, 1);
ZSTD_CCtx_setParameter(cctx, ZSTD_p_windowLog, zstd_window_log_size);
}
int max_dst_size = get_max_compressed_buffer_size(p_src_size, MODE_ZSTD);
int ret = ZSTD_compressCCtx(cctx, p_dst, max_dst_size, p_src, p_src_size, zstd_level);
@ -175,9 +174,7 @@ int Compression::decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *p
} break;
case MODE_ZSTD: {
ZSTD_DCtx *dctx = ZSTD_createDCtx();
if (zstd_long_distance_matching) {
ZSTD_DCtx_setParameter(dctx, ZSTD_d_windowLogMax, zstd_window_log_size);
}
if (zstd_long_distance_matching) ZSTD_DCtx_setMaxWindowSize(dctx, 1 << zstd_window_log_size);
int ret = ZSTD_decompressDCtx(dctx, p_dst, p_dst_max_size, p_src, p_src_size);
ZSTD_freeDCtx(dctx);
return ret;
@ -191,4 +188,4 @@ int Compression::zlib_level = Z_DEFAULT_COMPRESSION;
int Compression::gzip_level = Z_DEFAULT_COMPRESSION;
int Compression::zstd_level = 3;
bool Compression::zstd_long_distance_matching = false;
int Compression::zstd_window_log_size = 27; // ZSTD_WINDOWLOG_LIMIT_DEFAULT
int Compression::zstd_window_log_size = 27;

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -31,7 +31,7 @@
#ifndef COMPRESSION_H
#define COMPRESSION_H
#include "core/typedefs.h"
#include "typedefs.h"
class Compression {

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -29,10 +29,9 @@
/*************************************************************************/
#include "config_file.h"
#include "core/os/file_access.h"
#include "core/os/keyboard.h"
#include "core/variant_parser.h"
#include "os/file_access.h"
#include "os/keyboard.h"
#include "variant_parser.h"
PoolStringArray ConfigFile::_get_sections() const {

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -32,7 +32,7 @@
#define CONFIG_FILE_H
#include "core/ordered_hash_map.h"
#include "core/reference.h"
#include "reference.h"
class ConfigFile : public Reference {

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -30,7 +30,9 @@
#include "file_access_buffered.h"
#include "core/error_macros.h"
#include <string.h>
#include "error_macros.h"
Error FileAccessBuffered::set_error(Error p_error) const {

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -31,9 +31,10 @@
#ifndef FILE_ACCESS_BUFFERED_H
#define FILE_ACCESS_BUFFERED_H
#include "core/os/file_access.h"
#include "core/pool_vector.h"
#include "core/ustring.h"
#include "os/file_access.h"
#include "dvector.h"
#include "ustring.h"
class FileAccessBuffered : public FileAccess {

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -54,7 +54,7 @@ class FileAccessBufferedFA : public FileAccessBuffered {
cache.offset = p_offset;
cache.buffer.resize(p_size);
// on PoolVector
// on dvector
//PoolVector<uint8_t>::Write write = cache.buffer.write();
//f.get_buffer(write.ptrw(), p_size);

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -29,9 +29,7 @@
/*************************************************************************/
#include "file_access_compressed.h"
#include "core/print_string.h"
#include "print_string.h"
void FileAccessCompressed::configure(const String &p_magic, Compression::Mode p_mode, int p_block_size) {
magic = p_magic.ascii().get_data();
@ -208,8 +206,7 @@ void FileAccessCompressed::seek(size_t p_position) {
if (p_position == read_total) {
at_end = true;
} else {
at_end = false;
read_eof = false;
int block_idx = p_position / block_size;
if (block_idx != read_block) {
@ -294,6 +291,7 @@ uint8_t FileAccessCompressed::get_8() const {
} else {
read_block--;
at_end = true;
ret = 0;
}
}
@ -374,23 +372,24 @@ uint64_t FileAccessCompressed::_get_modified_time(const String &p_file) {
return 0;
}
FileAccessCompressed::FileAccessCompressed() :
cmode(Compression::MODE_ZSTD),
writing(false),
write_ptr(0),
write_buffer_size(0),
write_max(0),
block_size(0),
read_eof(false),
at_end(false),
read_ptr(NULL),
read_block(0),
read_block_count(0),
read_block_size(0),
read_pos(0),
read_total(0),
magic("GCMP"),
f(NULL) {
FileAccessCompressed::FileAccessCompressed() {
f = NULL;
magic = "GCMP";
cmode = Compression::MODE_ZSTD;
writing = false;
write_ptr = 0;
write_buffer_size = 0;
write_max = 0;
block_size = 0;
read_eof = false;
at_end = false;
read_total = 0;
read_ptr = NULL;
read_block = 0;
read_block_count = 0;
read_block_size = 0;
read_pos = 0;
}
FileAccessCompressed::~FileAccessCompressed() {

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -31,8 +31,8 @@
#ifndef FILE_ACCESS_COMPRESSED_H
#define FILE_ACCESS_COMPRESSED_H
#include "core/io/compression.h"
#include "core/os/file_access.h"
#include "io/compression.h"
#include "os/file_access.h"
class FileAccessCompressed : public FileAccess {

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -30,9 +30,9 @@
#include "file_access_encrypted.h"
#include "core/os/copymem.h"
#include "core/print_string.h"
#include "core/variant.h"
#include "os/copymem.h"
#include "print_string.h"
#include "thirdparty/misc/aes256.h"
#include "thirdparty/misc/md5.h"
@ -43,6 +43,7 @@
Error FileAccessEncrypted::open_and_parse(FileAccess *p_base, const Vector<uint8_t> &p_key, Mode p_mode) {
//print_line("open and parse!");
ERR_FAIL_COND_V(file != NULL, ERR_ALREADY_IN_USE);
ERR_FAIL_COND_V(p_key.size() != 32, ERR_INVALID_PARAMETER);
@ -88,7 +89,7 @@ Error FileAccessEncrypted::open_and_parse(FileAccess *p_base, const Vector<uint8
for (size_t i = 0; i < ds; i += 16) {
aes256_decrypt_ecb(&ctx, &data.write[i]);
aes256_decrypt_ecb(&ctx, &data[i]);
}
aes256_done(&ctx);
@ -116,7 +117,7 @@ Error FileAccessEncrypted::open_and_parse_password(FileAccess *p_base, const Str
key.resize(32);
for (int i = 0; i < 32; i++) {
key.write[i] = cs[i];
key[i] = cs[i];
}
return open_and_parse(p_base, key, p_mode);
@ -147,7 +148,7 @@ void FileAccessEncrypted::close() {
compressed.resize(len);
zeromem(compressed.ptrw(), len);
for (int i = 0; i < data.size(); i++) {
compressed.write[i] = data[i];
compressed[i] = data[i];
}
aes256_context ctx;
@ -155,7 +156,7 @@ void FileAccessEncrypted::close() {
for (size_t i = 0; i < len; i += 16) {
aes256_encrypt_ecb(&ctx, &compressed.write[i]);
aes256_encrypt_ecb(&ctx, &compressed[i]);
}
aes256_done(&ctx);
@ -262,7 +263,7 @@ void FileAccessEncrypted::store_buffer(const uint8_t *p_src, int p_length) {
data.resize(pos + p_length);
for (int i = 0; i < p_length; i++) {
data.write[pos + i] = p_src[i];
data[pos + i] = p_src[i];
}
pos += p_length;
}
@ -279,7 +280,7 @@ void FileAccessEncrypted::store_8(uint8_t p_dest) {
ERR_FAIL_COND(!writing);
if (pos < data.size()) {
data.write[pos] = p_dest;
data[pos] = p_dest;
pos++;
} else if (pos == data.size()) {
data.push_back(p_dest);

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -31,7 +31,7 @@
#ifndef FILE_ACCESS_ENCRYPTED_H
#define FILE_ACCESS_ENCRYPTED_H
#include "core/os/file_access.h"
#include "os/file_access.h"
class FileAccessEncrypted : public FileAccess {
public:

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -30,10 +30,10 @@
#include "file_access_memory.h"
#include "core/map.h"
#include "core/os/copymem.h"
#include "core/os/dir_access.h"
#include "core/project_settings.h"
#include "map.h"
#include "os/copymem.h"
#include "os/dir_access.h"
#include "project_settings.h"
static Map<String, Vector<uint8_t> > *files = NULL;
@ -92,7 +92,7 @@ Error FileAccessMemory::_open(const String &p_path, int p_mode_flags) {
Map<String, Vector<uint8_t> >::Element *E = files->find(name);
ERR_FAIL_COND_V(!E, ERR_FILE_NOT_FOUND);
data = E->get().ptrw();
data = &(E->get()[0]);
length = E->get().size();
pos = 0;

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -31,7 +31,7 @@
#ifndef FILE_ACCESS_MEMORY_H
#define FILE_ACCESS_MEMORY_H
#include "core/os/file_access.h"
#include "os/file_access.h"
class FileAccessMemory : public FileAccess {

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -29,11 +29,10 @@
/*************************************************************************/
#include "file_access_network.h"
#include "core/io/ip.h"
#include "core/io/marshalls.h"
#include "core/os/os.h"
#include "core/project_settings.h"
#include "io/ip.h"
#include "marshalls.h"
#include "os/os.h"
#include "project_settings.h"
//#define DEBUG_PRINT(m_p) print_line(m_p)
//#define DEBUG_TIME(m_what) printf("MS: %s - %lli\n",m_what,OS::get_singleton()->get_ticks_usec());
@ -94,6 +93,8 @@ void FileAccessNetworkClient::_thread_func() {
DEBUG_TIME("sem_unlock");
//DEBUG_PRINT("semwait returned "+itos(werr));
DEBUG_PRINT("MUTEX LOCK " + itos(lockcount));
DEBUG_PRINT("POPO");
DEBUG_PRINT("PEPE");
lock_mutex();
DEBUG_PRINT("MUTEX PASS");
@ -227,7 +228,7 @@ FileAccessNetworkClient::FileAccessNetworkClient() {
quit = false;
singleton = this;
last_id = 0;
client.instance();
client = Ref<StreamPeerTCP>(StreamPeerTCP::create_ref());
sem = Semaphore::create();
lockcount = 0;
}
@ -257,8 +258,8 @@ void FileAccessNetwork::_set_block(int p_offset, const Vector<uint8_t> &p_block)
}
buffer_mutex->lock();
pages.write[page].buffer = p_block;
pages.write[page].queued = false;
pages[page].buffer = p_block;
pages[page].queued = false;
buffer_mutex->unlock();
if (waiting_on_page == page) {
@ -388,7 +389,7 @@ void FileAccessNetwork::_queue_page(int p_page) const {
br.offset = size_t(p_page) * page_size;
br.size = page_size;
nc->block_requests.push_back(br);
pages.write[p_page].queued = true;
pages[p_page].queued = true;
nc->blockrequest_mutex->unlock();
DEBUG_PRINT("QUEUE PAGE POST");
nc->sem->post();
@ -432,12 +433,12 @@ int FileAccessNetwork::get_buffer(uint8_t *p_dst, int p_length) const {
_queue_page(page + j);
}
buff = pages.write[page].buffer.ptrw();
buff = pages[page].buffer.ptrw();
//queue pages
buffer_mutex->unlock();
}
buff = pages.write[page].buffer.ptrw();
buff = pages[page].buffer.ptrw();
last_page_buff = buff;
last_page = page;
}
@ -500,9 +501,8 @@ uint64_t FileAccessNetwork::_get_modified_time(const String &p_file) {
void FileAccessNetwork::configure() {
GLOBAL_DEF("network/remote_fs/page_size", 65536);
ProjectSettings::get_singleton()->set_custom_property_info("network/remote_fs/page_size", PropertyInfo(Variant::INT, "network/remote_fs/page_size", PROPERTY_HINT_RANGE, "1,65536,1,or_greater")); //is used as denominator and can't be zero
GLOBAL_DEF("network/remote_fs/page_read_ahead", 4);
ProjectSettings::get_singleton()->set_custom_property_info("network/remote_fs/page_read_ahead", PropertyInfo(Variant::INT, "network/remote_fs/page_read_ahead", PROPERTY_HINT_RANGE, "0,8,1,or_greater"));
GLOBAL_DEF("network/remote_fs/max_pages", 20);
}
FileAccessNetwork::FileAccessNetwork() {
@ -520,6 +520,7 @@ FileAccessNetwork::FileAccessNetwork() {
nc->unlock_mutex();
page_size = GLOBAL_GET("network/remote_fs/page_size");
read_ahead = GLOBAL_GET("network/remote_fs/page_read_ahead");
max_pages = GLOBAL_GET("network/remote_fs/max_pages");
last_activity_val = 0;
waiting_on_page = -1;
last_page = -1;

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -31,10 +31,10 @@
#ifndef FILE_ACCESS_NETWORK_H
#define FILE_ACCESS_NETWORK_H
#include "core/io/stream_peer_tcp.h"
#include "core/os/file_access.h"
#include "core/os/semaphore.h"
#include "core/os/thread.h"
#include "io/stream_peer_tcp.h"
#include "os/file_access.h"
#include "os/semaphore.h"
#include "os/thread.h"
class FileAccessNetwork;
@ -47,6 +47,8 @@ class FileAccessNetworkClient {
int size;
};
int ml;
List<BlockRequest> block_requests;
Semaphore *sem;
@ -98,6 +100,7 @@ class FileAccessNetwork : public FileAccess {
int page_size;
int read_ahead;
int max_pages;
mutable int waiting_on_page;
mutable int last_activity_val;

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -29,8 +29,7 @@
/*************************************************************************/
#include "file_access_pack.h"
#include "core/version.h"
#include "version.h"
#include <stdio.h>
@ -90,7 +89,7 @@ void PackedData::add_path(const String &pkg_path, const String &path, uint64_t o
}
}
String filename = path.get_file();
// Don't add as a file if the path points to a directory
// Don't add as a file if the path points to a directoryy
if (!filename.empty()) {
cd->files.insert(filename);
}
@ -169,11 +168,11 @@ bool PackedSourcePCK::try_open_pack(const String &p_path) {
uint32_t version = f->get_32();
uint32_t ver_major = f->get_32();
uint32_t ver_minor = f->get_32();
f->get_32(); // ver_rev
uint32_t ver_rev = f->get_32();
ERR_EXPLAIN("Pack version unsupported: " + itos(version));
ERR_FAIL_COND_V(version != PACK_VERSION, false);
ERR_EXPLAIN("Pack created with a newer version of the engine: " + itos(ver_major) + "." + itos(ver_minor));
ERR_EXPLAIN("Pack created with a newer version of the engine: " + itos(ver_major) + "." + itos(ver_minor) + "." + itos(ver_rev));
ERR_FAIL_COND_V(ver_major > VERSION_MAJOR || (ver_major == VERSION_MAJOR && ver_minor > VERSION_MINOR), false);
for (int i = 0; i < 16; i++) {
@ -272,7 +271,7 @@ int FileAccessPack::get_buffer(uint8_t *p_dst, int p_length) const {
if (eof)
return 0;
uint64_t to_read = p_length;
int64_t to_read = p_length;
if (to_read + pos > pf.size) {
eof = true;
to_read = int64_t(pf.size) - int64_t(pos);
@ -455,7 +454,7 @@ String DirAccessPack::get_current_dir() {
while (pd->parent) {
pd = pd->parent;
p = pd->name.plus_file(p);
p = pd->name + "/" + p;
}
return "res://" + p;
@ -463,15 +462,11 @@ String DirAccessPack::get_current_dir() {
bool DirAccessPack::file_exists(String p_file) {
p_file = fix_path(p_file);
return current->files.has(p_file);
}
bool DirAccessPack::dir_exists(String p_dir) {
p_dir = fix_path(p_dir);
return current->subdirs.has(p_dir);
}
@ -494,10 +489,6 @@ size_t DirAccessPack::get_space_left() {
return 0;
}
String DirAccessPack::get_filesystem_type() const {
return "PCK";
}
DirAccessPack::DirAccessPack() {
current = PackedData::get_singleton()->root;

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -31,11 +31,11 @@
#ifndef FILE_ACCESS_PACK_H
#define FILE_ACCESS_PACK_H
#include "core/list.h"
#include "core/map.h"
#include "core/os/dir_access.h"
#include "core/os/file_access.h"
#include "core/print_string.h"
#include "list.h"
#include "map.h"
#include "os/dir_access.h"
#include "os/file_access.h"
#include "print_string.h"
class PackSource;
@ -175,6 +175,7 @@ public:
FileAccess *PackedData::try_open_path(const String &p_path) {
//print_line("try open path " + p_path);
PathMD5 pmd5(p_path.md5_buffer());
Map<PathMD5, PackedFile>::Element *E = files.find(pmd5);
if (!E)
@ -221,8 +222,6 @@ public:
size_t get_space_left();
virtual String get_filesystem_type() const;
DirAccessPack();
~DirAccessPack();
};

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -43,31 +43,31 @@ static void *godot_open(void *data, const char *p_fname, int mode) {
if (mode & ZLIB_FILEFUNC_MODE_WRITE) {
return NULL;
}
};
FileAccess *f = (FileAccess *)data;
f->open(p_fname, FileAccess::READ);
return f->is_open() ? data : NULL;
}
};
static uLong godot_read(void *data, void *fdata, void *buf, uLong size) {
FileAccess *f = (FileAccess *)data;
f->get_buffer((uint8_t *)buf, size);
return size;
}
};
static uLong godot_write(voidpf opaque, voidpf stream, const void *buf, uLong size) {
return 0;
}
};
static long godot_tell(voidpf opaque, voidpf stream) {
FileAccess *f = (FileAccess *)opaque;
return f->get_position();
}
};
static long godot_seek(voidpf opaque, voidpf stream, uLong offset, int origin) {
@ -84,36 +84,36 @@ static long godot_seek(voidpf opaque, voidpf stream, uLong offset, int origin) {
break;
default:
break;
}
};
f->seek(pos);
return 0;
}
};
static int godot_close(voidpf opaque, voidpf stream) {
FileAccess *f = (FileAccess *)opaque;
f->close();
return 0;
}
};
static int godot_testerror(voidpf opaque, voidpf stream) {
FileAccess *f = (FileAccess *)opaque;
return f->get_error() != OK ? 1 : 0;
}
};
static voidpf godot_alloc(voidpf opaque, uInt items, uInt size) {
return memalloc(items * size);
}
};
static void godot_free(voidpf opaque, voidpf address) {
memfree(address);
}
};
} // extern "C"
}; // extern "C"
void ZipArchive::close_handle(unzFile p_file) const {
@ -122,7 +122,7 @@ void ZipArchive::close_handle(unzFile p_file) const {
unzCloseCurrentFile(p_file);
unzClose(p_file);
memdelete(f);
}
};
unzFile ZipArchive::get_file_handle(String p_file) const {
@ -155,10 +155,10 @@ unzFile ZipArchive::get_file_handle(String p_file) const {
unzClose(pkg);
ERR_FAIL_V(NULL);
}
};
return pkg;
}
};
bool ZipArchive::try_open_pack(const String &p_path) {
@ -168,10 +168,10 @@ bool ZipArchive::try_open_pack(const String &p_path) {
zlib_filefunc_def io;
FileAccess *fa = FileAccess::open(p_path, FileAccess::READ);
if (!fa)
FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
if (!f)
return false;
io.opaque = fa;
io.opaque = f;
io.zopen_file = godot_open;
io.zread_file = godot_read;
io.zwrite_file = godot_write;
@ -215,36 +215,36 @@ bool ZipArchive::try_open_pack(const String &p_path) {
if ((i + 1) < gi.number_entry) {
unzGoToNextFile(zfile);
}
}
};
};
return true;
}
};
bool ZipArchive::file_exists(String p_name) const {
return files.has(p_name);
}
};
FileAccess *ZipArchive::get_file(const String &p_path, PackedData::PackedFile *p_file) {
return memnew(FileAccessZip(p_path, *p_file));
}
};
ZipArchive *ZipArchive::get_singleton() {
if (instance == NULL) {
instance = memnew(ZipArchive);
}
};
return instance;
}
};
ZipArchive::ZipArchive() {
instance = this;
//fa_create_func = FileAccess::get_create_func();
}
};
ZipArchive::~ZipArchive() {
@ -253,10 +253,10 @@ ZipArchive::~ZipArchive() {
FileAccess *f = (FileAccess *)unzGetOpaque(packages[i].zfile);
unzClose(packages[i].zfile);
memdelete(f);
}
};
packages.clear();
}
};
Error FileAccessZip::_open(const String &p_path, int p_mode_flags) {
@ -272,7 +272,7 @@ Error FileAccessZip::_open(const String &p_path, int p_mode_flags) {
ERR_FAIL_COND_V(err != UNZ_OK, FAILED);
return OK;
}
};
void FileAccessZip::close() {
@ -283,50 +283,50 @@ void FileAccessZip::close() {
ERR_FAIL_COND(!arch);
arch->close_handle(zfile);
zfile = NULL;
}
};
bool FileAccessZip::is_open() const {
return zfile != NULL;
}
};
void FileAccessZip::seek(size_t p_position) {
ERR_FAIL_COND(!zfile);
unzSeekCurrentFile(zfile, p_position);
}
};
void FileAccessZip::seek_end(int64_t p_position) {
ERR_FAIL_COND(!zfile);
unzSeekCurrentFile(zfile, get_len() + p_position);
}
};
size_t FileAccessZip::get_position() const {
ERR_FAIL_COND_V(!zfile, 0);
return unztell(zfile);
}
};
size_t FileAccessZip::get_len() const {
ERR_FAIL_COND_V(!zfile, 0);
return file_info.uncompressed_size;
}
};
bool FileAccessZip::eof_reached() const {
ERR_FAIL_COND_V(!zfile, true);
return at_eof;
}
};
uint8_t FileAccessZip::get_8() const {
uint8_t ret = 0;
get_buffer(&ret, 1);
return ret;
}
};
int FileAccessZip::get_buffer(uint8_t *p_dst, int p_length) const {
@ -339,20 +339,20 @@ int FileAccessZip::get_buffer(uint8_t *p_dst, int p_length) const {
if (read < p_length)
at_eof = true;
return read;
}
};
Error FileAccessZip::get_error() const {
if (!zfile) {
return ERR_UNCONFIGURED;
}
};
if (eof_reached()) {
return ERR_FILE_EOF;
}
};
return OK;
}
};
void FileAccessZip::flush() {
@ -362,21 +362,22 @@ void FileAccessZip::flush() {
void FileAccessZip::store_8(uint8_t p_dest) {
ERR_FAIL();
}
};
bool FileAccessZip::file_exists(const String &p_name) {
return false;
}
};
FileAccessZip::FileAccessZip(const String &p_path, const PackedData::PackedFile &p_file) :
zfile(NULL) {
FileAccessZip::FileAccessZip(const String &p_path, const PackedData::PackedFile &p_file) {
zfile = NULL;
_open(p_path, FileAccess::READ);
}
};
FileAccessZip::~FileAccessZip() {
close();
}
};
#endif

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -34,7 +34,7 @@
#define FILE_ACCESS_ZIP_H
#include "core/io/file_access_pack.h"
#include "core/map.h"
#include "map.h"
#include "thirdparty/minizip/unzip.h"
@ -90,6 +90,8 @@ class FileAccessZip : public FileAccess {
mutable bool at_eof;
ZipArchive *archive;
public:
virtual Error _open(const String &p_path, int p_mode_flags); ///< open a file
virtual void close(); ///< close a file

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -29,9 +29,8 @@
/*************************************************************************/
#include "http_client.h"
#include "core/io/stream_peer_ssl.h"
#include "core/version.h"
#include "io/stream_peer_ssl.h"
#include "version.h"
const char *HTTPClient::_methods[METHOD_MAX] = {
"GET",
@ -275,13 +274,10 @@ void HTTPClient::close() {
response_headers.clear();
response_str.clear();
body_size = -1;
body_size = 0;
body_left = 0;
chunk_left = 0;
chunk_trailer_part = 0;
read_until_eof = false;
response_num = 0;
handshaking = false;
}
Error HTTPClient::poll() {
@ -330,46 +326,16 @@ Error HTTPClient::poll() {
} break;
case StreamPeerTCP::STATUS_CONNECTED: {
if (ssl) {
Ref<StreamPeerSSL> ssl;
if (!handshaking) {
// Connect the StreamPeerSSL and start handshaking
ssl = Ref<StreamPeerSSL>(StreamPeerSSL::create());
ssl->set_blocking_handshake_enabled(false);
Error err = ssl->connect_to_stream(tcp_connection, ssl_verify_host, conn_host);
if (err != OK) {
close();
status = STATUS_SSL_HANDSHAKE_ERROR;
return ERR_CANT_CONNECT;
}
connection = ssl;
handshaking = true;
} else {
// We are already handshaking, which means we can use your already active SSL connection
ssl = static_cast<Ref<StreamPeerSSL> >(connection);
if (ssl.is_null()) {
close();
status = STATUS_SSL_HANDSHAKE_ERROR;
return ERR_CANT_CONNECT;
}
ssl->poll(); // Try to finish the handshake
}
if (ssl->get_status() == StreamPeerSSL::STATUS_CONNECTED) {
// Handshake has been successful
handshaking = false;
status = STATUS_CONNECTED;
return OK;
} else if (ssl->get_status() != StreamPeerSSL::STATUS_HANDSHAKING) {
// Handshake has failed
Ref<StreamPeerSSL> ssl = StreamPeerSSL::create();
Error err = ssl->connect_to_stream(tcp_connection, ssl_verify_host, conn_host);
if (err != OK) {
close();
status = STATUS_SSL_HANDSHAKE_ERROR;
return ERR_CANT_CONNECT;
}
// ... we will need to poll more for handshake to finish
} else {
status = STATUS_CONNECTED;
connection = ssl;
}
status = STATUS_CONNECTED;
return OK;
} break;
case StreamPeerTCP::STATUS_ERROR:
@ -381,20 +347,7 @@ Error HTTPClient::poll() {
} break;
}
} break;
case STATUS_BODY:
case STATUS_CONNECTED: {
// Check if we are still connected
if (ssl) {
Ref<StreamPeerSSL> tmp = connection;
tmp->poll();
if (tmp->get_status() != StreamPeerSSL::STATUS_CONNECTED) {
status = STATUS_CONNECTION_ERROR;
return ERR_CONNECTION_ERROR;
}
} else if (tcp_connection->get_status() != StreamPeerTCP::STATUS_CONNECTED) {
status = STATUS_CONNECTION_ERROR;
return ERR_CONNECTION_ERROR;
}
// Connection established, requests can now be made
return OK;
} break;
@ -424,21 +377,14 @@ Error HTTPClient::poll() {
String response;
response.parse_utf8((const char *)response_str.ptr());
Vector<String> responses = response.split("\n");
body_size = -1;
body_size = 0;
chunked = false;
body_left = 0;
chunk_left = 0;
chunk_trailer_part = false;
read_until_eof = false;
response_str.clear();
response_headers.clear();
response_num = RESPONSE_OK;
// Per the HTTP 1.1 spec, keep-alive is the default.
// Not following that specification breaks standard implemetations.
// Broken web servers should be fixed.
bool keep_alive = true;
for (int i = 0; i < responses.size(); i++) {
String header = responses[i].strip_edges();
@ -448,14 +394,13 @@ Error HTTPClient::poll() {
if (s.begins_with("content-length:")) {
body_size = s.substr(s.find(":") + 1, s.length()).strip_edges().to_int();
body_left = body_size;
}
} else if (s.begins_with("transfer-encoding:")) {
if (s.begins_with("transfer-encoding:")) {
String encoding = header.substr(header.find(":") + 1, header.length()).strip_edges();
if (encoding == "chunked") {
chunked = true;
}
} else if (s.begins_with("connection: close")) {
keep_alive = false;
}
if (i == 0 && responses[i].begins_with("HTTP")) {
@ -468,16 +413,11 @@ Error HTTPClient::poll() {
}
}
if (body_size != -1 || chunked) {
if (body_size == 0 && !chunked) {
status = STATUS_BODY;
} else if (!keep_alive) {
read_until_eof = true;
status = STATUS_BODY;
status = STATUS_CONNECTED; // Ready for new requests
} else {
status = STATUS_CONNECTED;
status = STATUS_BODY;
}
return OK;
}
@ -488,8 +428,7 @@ Error HTTPClient::poll() {
case STATUS_DISCONNECTED: {
return ERR_UNCONFIGURED;
} break;
case STATUS_CONNECTION_ERROR:
case STATUS_SSL_HANDSHAKE_ERROR: {
case STATUS_CONNECTION_ERROR: {
return ERR_CONNECTION_ERROR;
} break;
case STATUS_CANT_CONNECT: {
@ -512,37 +451,13 @@ PoolByteArray HTTPClient::read_response_body_chunk() {
ERR_FAIL_COND_V(status != STATUS_BODY, PoolByteArray());
PoolByteArray ret;
Error err = OK;
if (chunked) {
while (true) {
if (chunk_trailer_part) {
// We need to consume the trailer part too or keep-alive will break
uint8_t b;
int rec = 0;
err = _get_http_data(&b, 1, rec);
if (rec == 0)
break;
chunk.push_back(b);
int cs = chunk.size();
if ((cs >= 2 && chunk[cs - 2] == '\r' && chunk[cs - 1] == '\n')) {
if (cs == 2) {
// Finally over
chunk_trailer_part = false;
status = STATUS_CONNECTED;
chunk.clear();
break;
} else {
// We do not process nor return the trailer data
chunk.clear();
}
}
} else if (chunk_left == 0) {
if (chunk_left == 0) {
// Reading length
uint8_t b;
int rec = 0;
@ -556,7 +471,7 @@ PoolByteArray HTTPClient::read_response_body_chunk() {
if (chunk.size() > 32) {
ERR_PRINT("HTTP Invalid chunk hex len");
status = STATUS_CONNECTION_ERROR;
break;
return PoolByteArray();
}
if (chunk.size() > 2 && chunk[chunk.size() - 2] == '\r' && chunk[chunk.size() - 1] == '\n') {
@ -574,22 +489,22 @@ PoolByteArray HTTPClient::read_response_body_chunk() {
else {
ERR_PRINT("HTTP Chunk len not in hex!!");
status = STATUS_CONNECTION_ERROR;
break;
return PoolByteArray();
}
len <<= 4;
len |= v;
if (len > (1 << 24)) {
ERR_PRINT("HTTP Chunk too big!! >16mb");
status = STATUS_CONNECTION_ERROR;
break;
return PoolByteArray();
}
}
if (len == 0) {
// End reached!
chunk_trailer_part = true;
status = STATUS_CONNECTED;
chunk.clear();
break;
return PoolByteArray();
}
chunk_left = len + 2;
@ -598,7 +513,7 @@ PoolByteArray HTTPClient::read_response_body_chunk() {
} else {
int rec = 0;
err = _get_http_data(&chunk.write[chunk.size() - chunk_left], chunk_left, rec);
err = _get_http_data(&chunk[chunk.size() - chunk_left], chunk_left, rec);
if (rec == 0) {
break;
}
@ -609,13 +524,18 @@ PoolByteArray HTTPClient::read_response_body_chunk() {
if (chunk[chunk.size() - 2] != '\r' || chunk[chunk.size() - 1] != '\n') {
ERR_PRINT("HTTP Invalid chunk terminator (not \\r\\n)");
status = STATUS_CONNECTION_ERROR;
break;
return PoolByteArray();
}
PoolByteArray ret;
ret.resize(chunk.size() - 2);
PoolByteArray::Write w = ret.write();
copymem(w.ptr(), chunk.ptr(), chunk.size() - 2);
{
PoolByteArray::Write w = ret.write();
copymem(w.ptr(), chunk.ptr(), chunk.size() - 2);
}
chunk.clear();
return ret;
}
break;
@ -624,7 +544,8 @@ PoolByteArray HTTPClient::read_response_body_chunk() {
} else {
int to_read = !read_until_eof ? MIN(body_left, read_chunk_size) : read_chunk_size;
int to_read = MIN(body_left, read_chunk_size);
PoolByteArray ret;
ret.resize(to_read);
int _offset = 0;
while (to_read > 0) {
@ -633,25 +554,24 @@ PoolByteArray HTTPClient::read_response_body_chunk() {
PoolByteArray::Write w = ret.write();
err = _get_http_data(w.ptr() + _offset, to_read, rec);
}
if (rec <= 0) { // Ended up reading less
ret.resize(_offset);
break;
} else {
_offset += rec;
if (rec > 0) {
body_left -= rec;
to_read -= rec;
if (!read_until_eof) {
body_left -= rec;
}
}
if (err != OK)
_offset += rec;
} else {
if (to_read > 0) // Ended up reading less
ret.resize(_offset);
break;
}
}
if (body_left == 0) {
status = STATUS_CONNECTED;
}
return ret;
}
if (err != OK) {
close();
if (err == ERR_FILE_EOF) {
status = STATUS_DISCONNECTED; // Server disconnected
@ -659,12 +579,12 @@ PoolByteArray HTTPClient::read_response_body_chunk() {
status = STATUS_CONNECTION_ERROR;
}
} else if (body_left == 0 && !chunked && !read_until_eof) {
} else if (body_left == 0 && !chunked) {
status = STATUS_CONNECTED;
}
return ret;
return PoolByteArray();
}
HTTPClient::Status HTTPClient::get_status() const {
@ -686,24 +606,11 @@ Error HTTPClient::_get_http_data(uint8_t *p_buffer, int p_bytes, int &r_received
if (blocking) {
// We can't use StreamPeer.get_data, since when reaching EOF we will get an
// error without knowing how many bytes we received.
Error err = ERR_FILE_EOF;
int read = 0;
int left = p_bytes;
r_received = 0;
while (left > 0) {
err = connection->get_partial_data(p_buffer + r_received, left, read);
if (err == OK) {
r_received += read;
} else if (err == ERR_FILE_EOF) {
r_received += read;
return err;
} else {
return err;
}
left -= read;
}
Error err = connection->get_data(p_buffer, p_bytes);
if (err == OK)
r_received = p_bytes;
else
r_received = 0;
return err;
} else {
return connection->get_partial_data(p_buffer, p_bytes, r_received);
@ -717,20 +624,17 @@ void HTTPClient::set_read_chunk_size(int p_size) {
HTTPClient::HTTPClient() {
tcp_connection.instance();
tcp_connection = StreamPeerTCP::create_ref();
resolving = IP::RESOLVER_INVALID_ID;
status = STATUS_DISCONNECTED;
conn_port = -1;
body_size = -1;
body_size = 0;
chunked = false;
body_left = 0;
read_until_eof = false;
chunk_left = 0;
chunk_trailer_part = false;
response_num = 0;
ssl = false;
blocking = false;
handshaking = false;
read_chunk_size = 4096;
}

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -31,10 +31,10 @@
#ifndef HTTP_CLIENT_H
#define HTTP_CLIENT_H
#include "core/io/ip.h"
#include "core/io/stream_peer.h"
#include "core/io/stream_peer_tcp.h"
#include "core/reference.h"
#include "io/ip.h"
#include "io/stream_peer.h"
#include "io/stream_peer_tcp.h"
#include "reference.h"
class HTTPClient : public Reference {
@ -165,17 +165,14 @@ private:
bool ssl;
bool ssl_verify_host;
bool blocking;
bool handshaking;
Vector<uint8_t> response_str;
bool chunked;
Vector<uint8_t> chunk;
int chunk_left;
bool chunk_trailer_part;
int body_size;
int body_left;
bool read_until_eof;
Ref<StreamPeerTCP> tcp_connection;
Ref<StreamPeer> connection;

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -30,8 +30,7 @@
#include "image_loader.h"
#include "core/print_string.h"
#include "print_string.h"
bool ImageFormatLoader::recognize(const String &p_extension) const {
List<String> extensions;
@ -60,7 +59,7 @@ Error ImageLoader::load_image(String p_file, Ref<Image> p_image, FileAccess *p_c
String extension = p_file.get_extension();
for (int i = 0; i < loader.size(); i++) {
for (int i = 0; i < loader_count; i++) {
if (!loader[i]->recognize(extension))
continue;
@ -83,122 +82,28 @@ Error ImageLoader::load_image(String p_file, Ref<Image> p_image, FileAccess *p_c
void ImageLoader::get_recognized_extensions(List<String> *p_extensions) {
for (int i = 0; i < loader.size(); i++) {
for (int i = 0; i < loader_count; i++) {
loader[i]->get_recognized_extensions(p_extensions);
}
}
ImageFormatLoader *ImageLoader::recognize(const String &p_extension) {
bool ImageLoader::recognize(const String &p_extension) {
for (int i = 0; i < loader.size(); i++) {
for (int i = 0; i < loader_count; i++) {
if (loader[i]->recognize(p_extension))
return loader[i];
return true;
}
return NULL;
return false;
}
Vector<ImageFormatLoader *> ImageLoader::loader;
ImageFormatLoader *ImageLoader::loader[MAX_LOADERS];
int ImageLoader::loader_count = 0;
void ImageLoader::add_image_format_loader(ImageFormatLoader *p_loader) {
loader.push_back(p_loader);
}
void ImageLoader::remove_image_format_loader(ImageFormatLoader *p_loader) {
loader.erase(p_loader);
}
const Vector<ImageFormatLoader *> &ImageLoader::get_image_format_loaders() {
return loader;
}
void ImageLoader::cleanup() {
while (loader.size()) {
remove_image_format_loader(loader[0]);
}
}
/////////////////
RES ResourceFormatLoaderImage::load(const String &p_path, const String &p_original_path, Error *r_error) {
FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
if (!f) {
if (r_error) {
*r_error = ERR_CANT_OPEN;
}
return RES();
}
uint8_t header[4] = { 0, 0, 0, 0 };
f->get_buffer(header, 4);
bool unrecognized = header[0] != 'G' || header[1] != 'D' || header[2] != 'I' || header[3] != 'M';
if (unrecognized) {
memdelete(f);
if (r_error) {
*r_error = ERR_FILE_UNRECOGNIZED;
}
ERR_FAIL_V(RES());
}
String extension = f->get_pascal_string();
int idx = -1;
for (int i = 0; i < ImageLoader::loader.size(); i++) {
if (ImageLoader::loader[i]->recognize(extension)) {
idx = i;
break;
}
}
if (idx == -1) {
memdelete(f);
if (r_error) {
*r_error = ERR_FILE_UNRECOGNIZED;
}
ERR_FAIL_V(RES());
}
Ref<Image> image;
image.instance();
Error err = ImageLoader::loader[idx]->load_image(image, f, false, 1.0);
memdelete(f);
if (err != OK) {
if (r_error) {
*r_error = err;
}
return RES();
}
if (r_error) {
*r_error = OK;
}
return image;
}
void ResourceFormatLoaderImage::get_recognized_extensions(List<String> *p_extensions) const {
p_extensions->push_back("image");
}
bool ResourceFormatLoaderImage::handles_type(const String &p_type) const {
return p_type == "Image";
}
String ResourceFormatLoaderImage::get_resource_type(const String &p_path) const {
return p_path.get_extension().to_lower() == "image" ? "Image" : String();
ERR_FAIL_COND(loader_count >= MAX_LOADERS);
loader[loader_count++] = p_loader;
}

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -31,12 +31,10 @@
#ifndef IMAGE_LOADER_H
#define IMAGE_LOADER_H
#include "core/image.h"
#include "core/io/resource_loader.h"
#include "core/list.h"
#include "core/os/file_access.h"
#include "core/ustring.h"
#include "image.h"
#include "list.h"
#include "os/file_access.h"
#include "ustring.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
@ -57,7 +55,6 @@ class ImageLoader;
class ImageFormatLoader {
friend class ImageLoader;
friend class ResourceFormatLoaderImage;
protected:
virtual Error load_image(Ref<Image> p_image, FileAccess *p_fileaccess, bool p_force_linear, float p_scale) = 0;
@ -70,30 +67,20 @@ public:
class ImageLoader {
static Vector<ImageFormatLoader *> loader;
friend class ResourceFormatLoaderImage;
enum {
MAX_LOADERS = 8
};
static ImageFormatLoader *loader[MAX_LOADERS];
static int loader_count;
protected:
public:
static Error load_image(String p_file, Ref<Image> p_image, FileAccess *p_custom = NULL, bool p_force_linear = false, float p_scale = 1.0);
static void get_recognized_extensions(List<String> *p_extensions);
static ImageFormatLoader *recognize(const String &p_extension);
static bool recognize(const String &p_extension);
static void add_image_format_loader(ImageFormatLoader *p_loader);
static void remove_image_format_loader(ImageFormatLoader *p_loader);
static const Vector<ImageFormatLoader *> &get_image_format_loaders();
static void cleanup();
};
class ResourceFormatLoaderImage : public ResourceFormatLoader {
GDCLASS(ResourceFormatLoaderImage, ResourceFormatLoader)
public:
virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
virtual bool handles_type(const String &p_type) const;
virtual String get_resource_type(const String &p_path) const;
};
#endif

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -29,10 +29,9 @@
/*************************************************************************/
#include "ip.h"
#include "core/hash_map.h"
#include "core/os/semaphore.h"
#include "core/os/thread.h"
#include "hash_map.h"
#include "os/semaphore.h"
#include "os/thread.h"
VARIANT_ENUM_CAST(IP::ResolverStatus);
@ -118,7 +117,7 @@ IP_Address IP::resolve_hostname(const String &p_hostname, IP::Type p_type) {
resolver->mutex->lock();
String key = _IP_ResolverPrivate::get_cache_key(p_hostname, p_type);
if (resolver->cache.has(key) && resolver->cache[key].is_valid()) {
if (resolver->cache.has(key)) {
IP_Address res = resolver->cache[key];
resolver->mutex->unlock();
return res;
@ -145,7 +144,7 @@ IP::ResolverID IP::resolve_hostname_queue_item(const String &p_hostname, IP::Typ
String key = _IP_ResolverPrivate::get_cache_key(p_hostname, p_type);
resolver->queue[id].hostname = p_hostname;
resolver->queue[id].type = p_type;
if (resolver->cache.has(key) && resolver->cache[key].is_valid()) {
if (resolver->cache.has(key)) {
resolver->queue[id].response = resolver->cache[key];
resolver->queue[id].status = IP::RESOLVER_STATUS_DONE;
} else {

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -31,8 +31,8 @@
#ifndef IP_H
#define IP_H
#include "core/io/ip_address.h"
#include "core/os/os.h"
#include "io/ip_address.h"
#include "os/os.h"
struct _IP_ResolverPrivate;

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -184,7 +184,7 @@ bool IP_Address::is_ipv4() const {
}
const uint8_t *IP_Address::get_ipv4() const {
ERR_FAIL_COND_V(!is_ipv4(), &(field8[12])); // Not the correct IPv4 (it's an IPv6), but we don't want to return a null pointer risking an engine crash.
ERR_FAIL_COND_V(!is_ipv4(), 0);
return &(field8[12]);
}

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -31,7 +31,7 @@
#ifndef IP_ADDRESS_H
#define IP_ADDRESS_H
#include "core/ustring.h"
#include "ustring.h"
struct IP_Address {

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -29,8 +29,7 @@
/*************************************************************************/
#include "json.h"
#include "core/print_string.h"
#include "print_string.h"
const char *JSON::tk_name[TK_MAX] = {
"'{'",

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -31,7 +31,7 @@
#ifndef JSON_H
#define JSON_H
#include "core/variant.h"
#include "variant.h"
class JSON {

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -30,9 +30,9 @@
#include "logger.h"
#include "core/os/dir_access.h"
#include "core/os/os.h"
#include "core/print_string.h"
#include "os/dir_access.h"
#include "os/os.h"
#include "print_string.h"
// va_copy was defined in the C99, but not in C++ standards before C++11.
// When you compile C++ without --std=c++<XX> option, compilers still define
@ -45,10 +45,6 @@
#endif
#endif
#if defined(MINGW_ENABLED) || defined(_MSC_VER)
#define sprintf sprintf_s
#endif
bool Logger::should_log(bool p_err) {
return (!p_err || _print_error_enabled) && (p_err || _print_line_enabled);
}
@ -116,7 +112,7 @@ void RotatedFileLogger::clear_old_backups() {
int max_backups = max_files - 1; // -1 for the current file
String basename = base_path.get_file().get_basename();
String extension = base_path.get_extension();
String extension = "." + base_path.get_extension();
DirAccess *da = DirAccess::open(base_path.get_base_dir());
if (!da) {
@ -127,7 +123,7 @@ void RotatedFileLogger::clear_old_backups() {
String f = da->get_next();
Set<String> backups;
while (f != String()) {
if (!da->current_is_dir() && f.begins_with(basename) && f.get_extension() == extension && f != base_path.get_file()) {
if (!da->current_is_dir() && f.begins_with(basename) && f.ends_with(extension) && f != base_path.get_file()) {
backups.insert(f);
}
f = da->get_next();
@ -156,10 +152,7 @@ void RotatedFileLogger::rotate_file() {
OS::Time time = OS::get_singleton()->get_time();
sprintf(timestamp, "-%04d-%02d-%02d-%02d-%02d-%02d", date.year, date.month, date.day, time.hour, time.min, time.sec);
String backup_name = base_path.get_basename() + timestamp;
if (base_path.get_extension() != String()) {
backup_name += "." + base_path.get_extension();
}
String backup_name = base_path.get_basename() + timestamp + "." + base_path.get_extension();
DirAccess *da = DirAccess::open(base_path.get_base_dir());
if (da) {
@ -179,10 +172,11 @@ void RotatedFileLogger::rotate_file() {
file = FileAccess::open(base_path, FileAccess::WRITE);
}
RotatedFileLogger::RotatedFileLogger(const String &p_base_path, int p_max_files) :
base_path(p_base_path.simplify_path()),
max_files(p_max_files > 0 ? p_max_files : 1),
file(NULL) {
RotatedFileLogger::RotatedFileLogger(const String &p_base_path, int p_max_files) {
file = NULL;
base_path = p_base_path.simplify_path();
max_files = p_max_files > 0 ? p_max_files : 1;
rotate_file();
}
@ -239,8 +233,8 @@ void StdLogger::logv(const char *p_format, va_list p_list, bool p_err) {
StdLogger::~StdLogger() {}
CompositeLogger::CompositeLogger(Vector<Logger *> p_loggers) :
loggers(p_loggers) {
CompositeLogger::CompositeLogger(Vector<Logger *> p_loggers) {
loggers = p_loggers;
}
void CompositeLogger::logv(const char *p_format, va_list p_list, bool p_err) {

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -31,10 +31,9 @@
#ifndef LOGGER_H
#define LOGGER_H
#include "core/os/file_access.h"
#include "core/ustring.h"
#include "core/vector.h"
#include "os/file_access.h"
#include "ustring.h"
#include "vector.h"
#include <stdarg.h>
class Logger {
@ -49,11 +48,11 @@ public:
ERR_SHADER
};
virtual void logv(const char *p_format, va_list p_list, bool p_err) _PRINTF_FORMAT_ATTRIBUTE_2_0 = 0;
virtual void logv(const char *p_format, va_list p_list, bool p_err) = 0;
virtual void log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, ErrorType p_type = ERR_ERROR);
void logf(const char *p_format, ...) _PRINTF_FORMAT_ATTRIBUTE_2_3;
void logf_error(const char *p_format, ...) _PRINTF_FORMAT_ATTRIBUTE_2_3;
void logf(const char *p_format, ...);
void logf_error(const char *p_format, ...);
virtual ~Logger();
};
@ -64,7 +63,7 @@ public:
class StdLogger : public Logger {
public:
virtual void logv(const char *p_format, va_list p_list, bool p_err) _PRINTF_FORMAT_ATTRIBUTE_2_0;
virtual void logv(const char *p_format, va_list p_list, bool p_err);
virtual ~StdLogger();
};
@ -88,7 +87,7 @@ class RotatedFileLogger : public Logger {
public:
RotatedFileLogger(const String &p_base_path, int p_max_files = 10);
virtual void logv(const char *p_format, va_list p_list, bool p_err) _PRINTF_FORMAT_ATTRIBUTE_2_0;
virtual void logv(const char *p_format, va_list p_list, bool p_err);
virtual ~RotatedFileLogger();
};
@ -99,7 +98,7 @@ class CompositeLogger : public Logger {
public:
CompositeLogger(Vector<Logger *> p_loggers);
virtual void logv(const char *p_format, va_list p_list, bool p_err) _PRINTF_FORMAT_ATTRIBUTE_2_0;
virtual void logv(const char *p_format, va_list p_list, bool p_err);
virtual void log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, ErrorType p_type = ERR_ERROR);
void add_logger(Logger *p_logger);
@ -107,4 +106,4 @@ public:
virtual ~CompositeLogger();
};
#endif
#endif

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -29,19 +29,19 @@
/*************************************************************************/
#include "marshalls.h"
#include "core/os/keyboard.h"
#include "core/print_string.h"
#include "core/reference.h"
#include "os/keyboard.h"
#include "print_string.h"
#include "reference.h"
#include <limits.h>
#include <stdio.h>
#define _S(a) ((int32_t)a)
#define ERR_FAIL_ADD_OF(a, b, err) ERR_FAIL_COND_V(_S(b) < 0 || _S(a) < 0 || _S(a) > INT_MAX - _S(b), err)
#define ERR_FAIL_MUL_OF(a, b, err) ERR_FAIL_COND_V(_S(a) < 0 || _S(b) <= 0 || _S(a) > INT_MAX / _S(b), err)
void EncodedObjectAsID::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_object_id", "id"), &EncodedObjectAsID::set_object_id);
ClassDB::bind_method(D_METHOD("get_object_id"), &EncodedObjectAsID::get_object_id);
ADD_PROPERTY(PropertyInfo(Variant::INT, "object_id"), "set_object_id", "get_object_id");
}
void EncodedObjectAsID::set_object_id(ObjectID p_id) {
@ -53,13 +53,10 @@ ObjectID EncodedObjectAsID::get_object_id() const {
return id;
}
EncodedObjectAsID::EncodedObjectAsID() :
id(0) {
}
EncodedObjectAsID::EncodedObjectAsID() {
#define _S(a) ((int32_t)a)
#define ERR_FAIL_ADD_OF(a, b, err) ERR_FAIL_COND_V(_S(b) < 0 || _S(a) < 0 || _S(a) > INT_MAX - _S(b), err)
#define ERR_FAIL_MUL_OF(a, b, err) ERR_FAIL_COND_V(_S(a) < 0 || _S(b) <= 0 || _S(a) > INT_MAX / _S(b), err)
id = 0;
}
#define ENCODE_MASK 0xFF
#define ENCODE_FLAG_64 1 << 16
@ -796,7 +793,7 @@ static void _encode_string(const String &p_string, uint8_t *&buf, int &r_len) {
}
}
Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bool p_full_objects) {
Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bool p_object_as_id) {
uint8_t *buf = r_buffer;
@ -808,7 +805,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
case Variant::INT: {
int64_t val = p_variant;
if (val > (int64_t)INT_MAX || val < (int64_t)INT_MIN) {
if (val > 0x7FFFFFFF || val < -0x80000000) {
flags |= ENCODE_FLAG_64;
}
} break;
@ -821,11 +818,10 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
}
} break;
case Variant::OBJECT: {
if (!p_full_objects) {
if (p_object_as_id) {
flags |= ENCODE_FLAG_OBJECT_AS_ID;
}
} break;
default: {} // nothing to do at this stage
}
if (buf) {
@ -851,16 +847,17 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
} break;
case Variant::INT: {
if (flags & ENCODE_FLAG_64) {
int64_t val = p_variant;
if (val > 0x7FFFFFFF || val < -0x80000000) {
//64 bits
if (buf) {
encode_uint64(p_variant.operator int64_t(), buf);
encode_uint64(val, buf);
}
r_len += 8;
} else {
if (buf) {
encode_uint32(p_variant.operator int32_t(), buf);
encode_uint32(int32_t(val), buf);
}
r_len += 4;
@ -868,7 +865,9 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
} break;
case Variant::REAL: {
if (flags & ENCODE_FLAG_64) {
double d = p_variant;
float f = d;
if (double(f) != d) {
if (buf) {
encode_double(p_variant.operator double(), buf);
}
@ -891,11 +890,11 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
if (buf) {
encode_uint32(uint32_t(np.get_name_count()) | 0x80000000, buf); //for compatibility with the old format
encode_uint32(np.get_subname_count(), buf + 4);
uint32_t np_flags = 0;
uint32_t flags = 0;
if (np.is_absolute())
np_flags |= 1;
flags |= 1;
encode_uint32(np_flags, buf + 8);
encode_uint32(flags, buf + 8);
buf += 12;
}
@ -1088,8 +1087,22 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
} break;
case Variant::OBJECT: {
if (p_full_objects) {
if (p_object_as_id) {
if (buf) {
Object *obj = p_variant;
ObjectID id = 0;
if (obj && ObjectDB::instance_validate(obj)) {
id = obj->get_instance_id();
}
encode_uint64(id, buf);
}
r_len += 8;
} else {
Object *obj = p_variant;
if (!obj) {
if (buf) {
@ -1127,7 +1140,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
_encode_string(E->get().name, buf, r_len);
int len;
Error err = encode_variant(obj->get(E->get().name), buf, len, p_full_objects);
Error err = encode_variant(obj->get(E->get().name), buf, len, p_object_as_id);
if (err)
return err;
ERR_FAIL_COND_V(len % 4, ERR_BUG);
@ -1136,19 +1149,6 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
buf += len;
}
}
} else {
if (buf) {
Object *obj = p_variant;
ObjectID id = 0;
if (obj && ObjectDB::instance_validate(obj)) {
id = obj->get_instance_id();
}
encode_uint64(id, buf);
}
r_len += 8;
}
} break;
@ -1181,14 +1181,12 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
r_len++; //pad
*/
int len;
encode_variant(E->get(), buf, len, p_full_objects);
encode_variant(E->get(), buf, len, p_object_as_id);
ERR_FAIL_COND_V(len % 4, ERR_BUG);
r_len += len;
if (buf)
buf += len;
Variant *v = d.getptr(E->get());
ERR_FAIL_COND_V(!v, ERR_BUG);
encode_variant(*v, buf, len, p_full_objects);
encode_variant(d[E->get()], buf, len, p_object_as_id);
ERR_FAIL_COND_V(len % 4, ERR_BUG);
r_len += len;
if (buf)
@ -1210,7 +1208,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
for (int i = 0; i < v.size(); i++) {
int len;
encode_variant(v.get(i), buf, len, p_full_objects);
encode_variant(v.get(i), buf, len, p_object_as_id);
ERR_FAIL_COND_V(len % 4, ERR_BUG);
r_len += len;
if (buf)
@ -1230,15 +1228,11 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
buf += 4;
PoolVector<uint8_t>::Read r = data.read();
copymem(buf, &r[0], datalen * datasize);
buf += datalen * datasize;
}
r_len += 4 + datalen * datasize;
while (r_len % 4) {
while (r_len % 4)
r_len++;
if (buf)
*(buf++) = 0;
}
} break;
case Variant::POOL_INT_ARRAY: {

View File

@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@ -31,10 +31,10 @@
#ifndef MARSHALLS_H
#define MARSHALLS_H
#include "core/reference.h"
#include "core/typedefs.h"
#include "core/variant.h"
#include "typedefs.h"
#include "reference.h"
#include "variant.h"
/**
* Miscellaneous helpers for marshalling data types, and encoding
* in an endian independent way
@ -199,7 +199,7 @@ public:
EncodedObjectAsID();
};
Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int *r_len = NULL, bool p_allow_objects = false);
Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bool p_full_objects = false);
Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int *r_len = NULL, bool p_allow_objects = true);
Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bool p_object_as_id = false);
#endif

View File

@ -1,888 +0,0 @@
/*************************************************************************/
/* multiplayer_api.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "multiplayer_api.h"
#include "core/io/marshalls.h"
#include "scene/main/node.h"
_FORCE_INLINE_ bool _should_call_local(MultiplayerAPI::RPCMode mode, bool is_master, bool &r_skip_rpc) {
switch (mode) {
case MultiplayerAPI::RPC_MODE_DISABLED: {
// Do nothing.
} break;
case MultiplayerAPI::RPC_MODE_REMOTE: {
// Do nothing also. Remote cannot produce a local call.
} break;
case MultiplayerAPI::RPC_MODE_MASTERSYNC: {
if (is_master)
r_skip_rpc = true; // I am the master, so skip remote call.
FALLTHROUGH;
}
case MultiplayerAPI::RPC_MODE_REMOTESYNC:
case MultiplayerAPI::RPC_MODE_PUPPETSYNC: {
// Call it, sync always results in a local call.
return true;
} break;
case MultiplayerAPI::RPC_MODE_MASTER: {
if (is_master)
r_skip_rpc = true; // I am the master, so skip remote call.
return is_master;
} break;
case MultiplayerAPI::RPC_MODE_PUPPET: {
return !is_master;
} break;
}
return false;
}
_FORCE_INLINE_ bool _can_call_mode(Node *p_node, MultiplayerAPI::RPCMode mode, int p_remote_id) {
switch (mode) {
case MultiplayerAPI::RPC_MODE_DISABLED: {
return false;
} break;
case MultiplayerAPI::RPC_MODE_REMOTE:
case MultiplayerAPI::RPC_MODE_REMOTESYNC: {
return true;
} break;
case MultiplayerAPI::RPC_MODE_MASTERSYNC:
case MultiplayerAPI::RPC_MODE_MASTER: {
return p_node->is_network_master();
} break;
case MultiplayerAPI::RPC_MODE_PUPPETSYNC:
case MultiplayerAPI::RPC_MODE_PUPPET: {
return !p_node->is_network_master() && p_remote_id == p_node->get_network_master();
} break;
}
return false;
}
void MultiplayerAPI::poll() {
if (!network_peer.is_valid() || network_peer->get_connection_status() == NetworkedMultiplayerPeer::CONNECTION_DISCONNECTED)
return;
network_peer->poll();
if (!network_peer.is_valid()) // It's possible that polling might have resulted in a disconnection, so check here.
return;
while (network_peer->get_available_packet_count()) {
int sender = network_peer->get_packet_peer();
const uint8_t *packet;
int len;
Error err = network_peer->get_packet(&packet, len);
if (err != OK) {
ERR_PRINT("Error getting packet!");
}
rpc_sender_id = sender;
_process_packet(sender, packet, len);
rpc_sender_id = 0;
if (!network_peer.is_valid()) {
break; // It's also possible that a packet or RPC caused a disconnection, so also check here.
}
}
}
void MultiplayerAPI::clear() {
connected_peers.clear();
path_get_cache.clear();
path_send_cache.clear();
packet_cache.clear();
last_send_cache_id = 1;
}
void MultiplayerAPI::set_root_node(Node *p_node) {
root_node = p_node;
}
void MultiplayerAPI::set_network_peer(const Ref<NetworkedMultiplayerPeer> &p_peer) {
if (p_peer == network_peer) return; // Nothing to do
if (network_peer.is_valid()) {
network_peer->disconnect("peer_connected", this, "_add_peer");
network_peer->disconnect("peer_disconnected", this, "_del_peer");
network_peer->disconnect("connection_succeeded", this, "_connected_to_server");
network_peer->disconnect("connection_failed", this, "_connection_failed");
network_peer->disconnect("server_disconnected", this, "_server_disconnected");
clear();
}
network_peer = p_peer;
ERR_EXPLAIN("Supplied NetworkedNetworkPeer must be connecting or connected.");
ERR_FAIL_COND(p_peer.is_valid() && p_peer->get_connection_status() == NetworkedMultiplayerPeer::CONNECTION_DISCONNECTED);
if (network_peer.is_valid()) {
network_peer->connect("peer_connected", this, "_add_peer");
network_peer->connect("peer_disconnected", this, "_del_peer");
network_peer->connect("connection_succeeded", this, "_connected_to_server");
network_peer->connect("connection_failed", this, "_connection_failed");
network_peer->connect("server_disconnected", this, "_server_disconnected");
}
}
Ref<NetworkedMultiplayerPeer> MultiplayerAPI::get_network_peer() const {
return network_peer;
}
void MultiplayerAPI::_process_packet(int p_from, const uint8_t *p_packet, int p_packet_len) {
ERR_EXPLAIN("Multiplayer root node was not initialized. If you are using custom multiplayer, remember to set the root node via MultiplayerAPI.set_root_node before using it");
ERR_FAIL_COND(root_node == NULL);
ERR_EXPLAIN("Invalid packet received. Size too small.");
ERR_FAIL_COND(p_packet_len < 1);
uint8_t packet_type = p_packet[0];
switch (packet_type) {
case NETWORK_COMMAND_SIMPLIFY_PATH: {
_process_simplify_path(p_from, p_packet, p_packet_len);
} break;
case NETWORK_COMMAND_CONFIRM_PATH: {
_process_confirm_path(p_from, p_packet, p_packet_len);
} break;
case NETWORK_COMMAND_REMOTE_CALL:
case NETWORK_COMMAND_REMOTE_SET: {
ERR_EXPLAIN("Invalid packet received. Size too small.");
ERR_FAIL_COND(p_packet_len < 6);
Node *node = _process_get_node(p_from, p_packet, p_packet_len);
ERR_EXPLAIN("Invalid packet received. Requested node was not found.");
ERR_FAIL_COND(node == NULL);
// Detect cstring end.
int len_end = 5;
for (; len_end < p_packet_len; len_end++) {
if (p_packet[len_end] == 0) {
break;
}
}
ERR_EXPLAIN("Invalid packet received. Size too small.");
ERR_FAIL_COND(len_end >= p_packet_len);
StringName name = String::utf8((const char *)&p_packet[5]);
if (packet_type == NETWORK_COMMAND_REMOTE_CALL) {
_process_rpc(node, name, p_from, p_packet, p_packet_len, len_end + 1);
} else {
_process_rset(node, name, p_from, p_packet, p_packet_len, len_end + 1);
}
} break;
case NETWORK_COMMAND_RAW: {
_process_raw(p_from, p_packet, p_packet_len);
} break;
}
}
Node *MultiplayerAPI::_process_get_node(int p_from, const uint8_t *p_packet, int p_packet_len) {
uint32_t target = decode_uint32(&p_packet[1]);
Node *node = NULL;
if (target & 0x80000000) {
// Use full path (not cached yet).
int ofs = target & 0x7FFFFFFF;
ERR_EXPLAIN("Invalid packet received. Size smaller than declared.");
ERR_FAIL_COND_V(ofs >= p_packet_len, NULL);
String paths;
paths.parse_utf8((const char *)&p_packet[ofs], p_packet_len - ofs);
NodePath np = paths;
node = root_node->get_node(np);
if (!node)
ERR_PRINTS("Failed to get path from RPC: " + String(np));
} else {
// Use cached path.
int id = target;
Map<int, PathGetCache>::Element *E = path_get_cache.find(p_from);
ERR_EXPLAIN("Invalid packet received. Requests invalid peer cache.");
ERR_FAIL_COND_V(!E, NULL);
Map<int, PathGetCache::NodeInfo>::Element *F = E->get().nodes.find(id);
ERR_EXPLAIN("Invalid packet received. Unabled to find requested cached node.");
ERR_FAIL_COND_V(!F, NULL);
PathGetCache::NodeInfo *ni = &F->get();
// Do proper caching later.
node = root_node->get_node(ni->path);
if (!node)
ERR_PRINTS("Failed to get cached path from RPC: " + String(ni->path));
}
return node;
}
void MultiplayerAPI::_process_rpc(Node *p_node, const StringName &p_name, int p_from, const uint8_t *p_packet, int p_packet_len, int p_offset) {
ERR_EXPLAIN("Invalid packet received. Size too small.");
ERR_FAIL_COND(p_offset >= p_packet_len);
// Check that remote can call the RPC on this node.
RPCMode rpc_mode = RPC_MODE_DISABLED;
const Map<StringName, RPCMode>::Element *E = p_node->get_node_rpc_mode(p_name);
if (E) {
rpc_mode = E->get();
} else if (p_node->get_script_instance()) {
rpc_mode = p_node->get_script_instance()->get_rpc_mode(p_name);
}
bool can_call = _can_call_mode(p_node, rpc_mode, p_from);
ERR_EXPLAIN("RPC '" + String(p_name) + "' is not allowed on node " + p_node->get_path() + " from: " + itos(p_from) + ". Mode is " + itos((int)rpc_mode) + ", master is " + itos(p_node->get_network_master()) + ".");
ERR_FAIL_COND(!can_call);
int argc = p_packet[p_offset];
Vector<Variant> args;
Vector<const Variant *> argp;
args.resize(argc);
argp.resize(argc);
p_offset++;
for (int i = 0; i < argc; i++) {
ERR_EXPLAIN("Invalid packet received. Size too small.");
ERR_FAIL_COND(p_offset >= p_packet_len);
int vlen;
Error err = decode_variant(args.write[i], &p_packet[p_offset], p_packet_len - p_offset, &vlen, allow_object_decoding || network_peer->is_object_decoding_allowed());
ERR_EXPLAIN("Invalid packet received. Unable to decode RPC argument.");
ERR_FAIL_COND(err != OK);
argp.write[i] = &args[i];
p_offset += vlen;
}
Variant::CallError ce;
p_node->call(p_name, (const Variant **)argp.ptr(), argc, ce);
if (ce.error != Variant::CallError::CALL_OK) {
String error = Variant::get_call_error_text(p_node, p_name, (const Variant **)argp.ptr(), argc, ce);
error = "RPC - " + error;
ERR_PRINTS(error);
}
}
void MultiplayerAPI::_process_rset(Node *p_node, const StringName &p_name, int p_from, const uint8_t *p_packet, int p_packet_len, int p_offset) {
ERR_EXPLAIN("Invalid packet received. Size too small.");
ERR_FAIL_COND(p_offset >= p_packet_len);
// Check that remote can call the RSET on this node.
RPCMode rset_mode = RPC_MODE_DISABLED;
const Map<StringName, RPCMode>::Element *E = p_node->get_node_rset_mode(p_name);
if (E) {
rset_mode = E->get();
} else if (p_node->get_script_instance()) {
rset_mode = p_node->get_script_instance()->get_rset_mode(p_name);
}
bool can_call = _can_call_mode(p_node, rset_mode, p_from);
ERR_EXPLAIN("RSET '" + String(p_name) + "' is not allowed on node " + p_node->get_path() + " from: " + itos(p_from) + ". Mode is " + itos((int)rset_mode) + ", master is " + itos(p_node->get_network_master()) + ".");
ERR_FAIL_COND(!can_call);
Variant value;
Error err = decode_variant(value, &p_packet[p_offset], p_packet_len - p_offset, NULL, allow_object_decoding || network_peer->is_object_decoding_allowed());
ERR_EXPLAIN("Invalid packet received. Unable to decode RSET value.");
ERR_FAIL_COND(err != OK);
bool valid;
p_node->set(p_name, value, &valid);
if (!valid) {
String error = "Error setting remote property '" + String(p_name) + "', not found in object of type " + p_node->get_class();
ERR_PRINTS(error);
}
}
void MultiplayerAPI::_process_simplify_path(int p_from, const uint8_t *p_packet, int p_packet_len) {
ERR_EXPLAIN("Invalid packet received. Size too small.");
ERR_FAIL_COND(p_packet_len < 5);
int id = decode_uint32(&p_packet[1]);
String paths;
paths.parse_utf8((const char *)&p_packet[5], p_packet_len - 5);
NodePath path = paths;
if (!path_get_cache.has(p_from)) {
path_get_cache[p_from] = PathGetCache();
}
PathGetCache::NodeInfo ni;
ni.path = path;
ni.instance = 0;
path_get_cache[p_from].nodes[id] = ni;
// Encode path to send ack.
CharString pname = String(path).utf8();
int len = encode_cstring(pname.get_data(), NULL);
Vector<uint8_t> packet;
packet.resize(1 + len);
packet.write[0] = NETWORK_COMMAND_CONFIRM_PATH;
encode_cstring(pname.get_data(), &packet.write[1]);
network_peer->set_transfer_mode(NetworkedMultiplayerPeer::TRANSFER_MODE_RELIABLE);
network_peer->set_target_peer(p_from);
network_peer->put_packet(packet.ptr(), packet.size());
}
void MultiplayerAPI::_process_confirm_path(int p_from, const uint8_t *p_packet, int p_packet_len) {
ERR_EXPLAIN("Invalid packet received. Size too small.");
ERR_FAIL_COND(p_packet_len < 2);
String paths;
paths.parse_utf8((const char *)&p_packet[1], p_packet_len - 1);
NodePath path = paths;
PathSentCache *psc = path_send_cache.getptr(path);
ERR_EXPLAIN("Invalid packet received. Tries to confirm a path which was not found in cache.");
ERR_FAIL_COND(!psc);
Map<int, bool>::Element *E = psc->confirmed_peers.find(p_from);
ERR_EXPLAIN("Invalid packet received. Source peer was not found in cache for the given path.");
ERR_FAIL_COND(!E);
E->get() = true;
}
bool MultiplayerAPI::_send_confirm_path(NodePath p_path, PathSentCache *psc, int p_target) {
bool has_all_peers = true;
List<int> peers_to_add; // If one is missing, take note to add it.
for (Set<int>::Element *E = connected_peers.front(); E; E = E->next()) {
if (p_target < 0 && E->get() == -p_target)
continue; // Continue, excluded.
if (p_target > 0 && E->get() != p_target)
continue; // Continue, not for this peer.
Map<int, bool>::Element *F = psc->confirmed_peers.find(E->get());
if (!F || !F->get()) {
// Path was not cached, or was cached but is unconfirmed.
if (!F) {
// Not cached at all, take note.
peers_to_add.push_back(E->get());
}
has_all_peers = false;
}
}
// Those that need to be added, send a message for this.
for (List<int>::Element *E = peers_to_add.front(); E; E = E->next()) {
// Encode function name.
CharString pname = String(p_path).utf8();
int len = encode_cstring(pname.get_data(), NULL);
Vector<uint8_t> packet;
packet.resize(1 + 4 + len);
packet.write[0] = NETWORK_COMMAND_SIMPLIFY_PATH;
encode_uint32(psc->id, &packet.write[1]);
encode_cstring(pname.get_data(), &packet.write[5]);
network_peer->set_target_peer(E->get()); // To all of you.
network_peer->set_transfer_mode(NetworkedMultiplayerPeer::TRANSFER_MODE_RELIABLE);
network_peer->put_packet(packet.ptr(), packet.size());
psc->confirmed_peers.insert(E->get(), false); // Insert into confirmed, but as false since it was not confirmed.
}
return has_all_peers;
}
void MultiplayerAPI::_send_rpc(Node *p_from, int p_to, bool p_unreliable, bool p_set, const StringName &p_name, const Variant **p_arg, int p_argcount) {
if (network_peer.is_null()) {
ERR_EXPLAIN("Attempt to remote call/set when networking is not active in SceneTree.");
ERR_FAIL();
}
if (network_peer->get_connection_status() == NetworkedMultiplayerPeer::CONNECTION_CONNECTING) {
ERR_EXPLAIN("Attempt to remote call/set when networking is not connected yet in SceneTree.");
ERR_FAIL();
}
if (network_peer->get_connection_status() == NetworkedMultiplayerPeer::CONNECTION_DISCONNECTED) {
ERR_EXPLAIN("Attempt to remote call/set when networking is disconnected.");
ERR_FAIL();
}
if (p_argcount > 255) {
ERR_EXPLAIN("Too many arguments >255.");
ERR_FAIL();
}
if (p_to != 0 && !connected_peers.has(ABS(p_to))) {
if (p_to == network_peer->get_unique_id()) {
ERR_EXPLAIN("Attempt to remote call/set yourself! unique ID: " + itos(network_peer->get_unique_id()));
} else {
ERR_EXPLAIN("Attempt to remote call unexisting ID: " + itos(p_to));
}
ERR_FAIL();
}
NodePath from_path = (root_node->get_path()).rel_path_to(p_from->get_path());
ERR_EXPLAIN("Unable to send RPC. Relative path is empty. THIS IS LIKELY A BUG IN THE ENGINE!");
ERR_FAIL_COND(from_path.is_empty());
// See if the path is cached.
PathSentCache *psc = path_send_cache.getptr(from_path);
if (!psc) {
// Path is not cached, create.
path_send_cache[from_path] = PathSentCache();
psc = path_send_cache.getptr(from_path);
psc->id = last_send_cache_id++;
}
// Create base packet, lots of hardcode because it must be tight.
int ofs = 0;
#define MAKE_ROOM(m_amount) \
if (packet_cache.size() < m_amount) packet_cache.resize(m_amount);
// Encode type.
MAKE_ROOM(1);
packet_cache.write[0] = p_set ? NETWORK_COMMAND_REMOTE_SET : NETWORK_COMMAND_REMOTE_CALL;
ofs += 1;
// Encode ID.
MAKE_ROOM(ofs + 4);
encode_uint32(psc->id, &(packet_cache.write[ofs]));
ofs += 4;
// Encode function name.
CharString name = String(p_name).utf8();
int len = encode_cstring(name.get_data(), NULL);
MAKE_ROOM(ofs + len);
encode_cstring(name.get_data(), &(packet_cache.write[ofs]));
ofs += len;
if (p_set) {
// Set argument.
Error err = encode_variant(*p_arg[0], NULL, len, allow_object_decoding || network_peer->is_object_decoding_allowed());
ERR_EXPLAIN("Unable to encode RSET value. THIS IS LIKELY A BUG IN THE ENGINE!");
ERR_FAIL_COND(err != OK);
MAKE_ROOM(ofs + len);
encode_variant(*p_arg[0], &(packet_cache.write[ofs]), len, allow_object_decoding || network_peer->is_object_decoding_allowed());
ofs += len;
} else {
// Call arguments.
MAKE_ROOM(ofs + 1);
packet_cache.write[ofs] = p_argcount;
ofs += 1;
for (int i = 0; i < p_argcount; i++) {
Error err = encode_variant(*p_arg[i], NULL, len, allow_object_decoding || network_peer->is_object_decoding_allowed());
ERR_EXPLAIN("Unable to encode RPC argument. THIS IS LIKELY A BUG IN THE ENGINE!");
ERR_FAIL_COND(err != OK);
MAKE_ROOM(ofs + len);
encode_variant(*p_arg[i], &(packet_cache.write[ofs]), len, allow_object_decoding || network_peer->is_object_decoding_allowed());
ofs += len;
}
}
// See if all peers have cached path (is so, call can be fast).
bool has_all_peers = _send_confirm_path(from_path, psc, p_to);
// Take chance and set transfer mode, since all send methods will use it.
network_peer->set_transfer_mode(p_unreliable ? NetworkedMultiplayerPeer::TRANSFER_MODE_UNRELIABLE : NetworkedMultiplayerPeer::TRANSFER_MODE_RELIABLE);
if (has_all_peers) {
// They all have verified paths, so send fast.
network_peer->set_target_peer(p_to); // To all of you.
network_peer->put_packet(packet_cache.ptr(), ofs); // A message with love.
} else {
// Not all verified path, so send one by one.
// Append path at the end, since we will need it for some packets.
CharString pname = String(from_path).utf8();
int path_len = encode_cstring(pname.get_data(), NULL);
MAKE_ROOM(ofs + path_len);
encode_cstring(pname.get_data(), &(packet_cache.write[ofs]));
for (Set<int>::Element *E = connected_peers.front(); E; E = E->next()) {
if (p_to < 0 && E->get() == -p_to)
continue; // Continue, excluded.
if (p_to > 0 && E->get() != p_to)
continue; // Continue, not for this peer.
Map<int, bool>::Element *F = psc->confirmed_peers.find(E->get());
ERR_CONTINUE(!F); // Should never happen.
network_peer->set_target_peer(E->get()); // To this one specifically.
if (F->get()) {
// This one confirmed path, so use id.
encode_uint32(psc->id, &(packet_cache.write[1]));
network_peer->put_packet(packet_cache.ptr(), ofs);
} else {
// This one did not confirm path yet, so use entire path (sorry!).
encode_uint32(0x80000000 | ofs, &(packet_cache.write[1])); // Offset to path and flag.
network_peer->put_packet(packet_cache.ptr(), ofs + path_len);
}
}
}
}
void MultiplayerAPI::_add_peer(int p_id) {
connected_peers.insert(p_id);
path_get_cache.insert(p_id, PathGetCache());
emit_signal("network_peer_connected", p_id);
}
void MultiplayerAPI::_del_peer(int p_id) {
connected_peers.erase(p_id);
path_get_cache.erase(p_id); // I no longer need your cache, sorry.
emit_signal("network_peer_disconnected", p_id);
}
void MultiplayerAPI::_connected_to_server() {
emit_signal("connected_to_server");
}
void MultiplayerAPI::_connection_failed() {
emit_signal("connection_failed");
}
void MultiplayerAPI::_server_disconnected() {
emit_signal("server_disconnected");
}
void MultiplayerAPI::rpcp(Node *p_node, int p_peer_id, bool p_unreliable, const StringName &p_method, const Variant **p_arg, int p_argcount) {
ERR_EXPLAIN("Trying to call an RPC while no network peer is active.");
ERR_FAIL_COND(!network_peer.is_valid());
ERR_EXPLAIN("Trying to call an RPC on a node which is not inside SceneTree.");
ERR_FAIL_COND(!p_node->is_inside_tree());
ERR_EXPLAIN("Trying to call an RPC via a network peer which is not connected.");
ERR_FAIL_COND(network_peer->get_connection_status() != NetworkedMultiplayerPeer::CONNECTION_CONNECTED);
int node_id = network_peer->get_unique_id();
bool skip_rpc = false;
bool call_local_native = false;
bool call_local_script = false;
bool is_master = p_node->is_network_master();
if (p_peer_id == 0 || p_peer_id == node_id || (p_peer_id < 0 && p_peer_id != -node_id)) {
// Check that send mode can use local call.
const Map<StringName, RPCMode>::Element *E = p_node->get_node_rpc_mode(p_method);
if (E) {
call_local_native = _should_call_local(E->get(), is_master, skip_rpc);
}
if (call_local_native) {
// Done below.
} else if (p_node->get_script_instance()) {
// Attempt with script.
RPCMode rpc_mode = p_node->get_script_instance()->get_rpc_mode(p_method);
call_local_script = _should_call_local(rpc_mode, is_master, skip_rpc);
}
}
if (!skip_rpc) {
_send_rpc(p_node, p_peer_id, p_unreliable, false, p_method, p_arg, p_argcount);
}
if (call_local_native) {
Variant::CallError ce;
p_node->call(p_method, p_arg, p_argcount, ce);
if (ce.error != Variant::CallError::CALL_OK) {
String error = Variant::get_call_error_text(p_node, p_method, p_arg, p_argcount, ce);
error = "rpc() aborted in local call: - " + error;
ERR_PRINTS(error);
return;
}
}
if (call_local_script) {
Variant::CallError ce;
ce.error = Variant::CallError::CALL_OK;
p_node->get_script_instance()->call(p_method, p_arg, p_argcount, ce);
if (ce.error != Variant::CallError::CALL_OK) {
String error = Variant::get_call_error_text(p_node, p_method, p_arg, p_argcount, ce);
error = "rpc() aborted in script local call: - " + error;
ERR_PRINTS(error);
return;
}
}
}
void MultiplayerAPI::rsetp(Node *p_node, int p_peer_id, bool p_unreliable, const StringName &p_property, const Variant &p_value) {
ERR_EXPLAIN("Trying to RSET while no network peer is active.");
ERR_FAIL_COND(!network_peer.is_valid());
ERR_EXPLAIN("Trying to RSET on a node which is not inside SceneTree.");
ERR_FAIL_COND(!p_node->is_inside_tree());
ERR_EXPLAIN("Trying to send an RSET via a network peer which is not connected.");
ERR_FAIL_COND(network_peer->get_connection_status() != NetworkedMultiplayerPeer::CONNECTION_CONNECTED);
int node_id = network_peer->get_unique_id();
bool is_master = p_node->is_network_master();
bool skip_rset = false;
if (p_peer_id == 0 || p_peer_id == node_id || (p_peer_id < 0 && p_peer_id != -node_id)) {
// Check that send mode can use local call.
bool set_local = false;
const Map<StringName, RPCMode>::Element *E = p_node->get_node_rset_mode(p_property);
if (E) {
set_local = _should_call_local(E->get(), is_master, skip_rset);
}
if (set_local) {
bool valid;
p_node->set(p_property, p_value, &valid);
if (!valid) {
String error = "rset() aborted in local set, property not found: - " + String(p_property);
ERR_PRINTS(error);
return;
}
} else if (p_node->get_script_instance()) {
// Attempt with script.
RPCMode rpc_mode = p_node->get_script_instance()->get_rset_mode(p_property);
set_local = _should_call_local(rpc_mode, is_master, skip_rset);
if (set_local) {
bool valid = p_node->get_script_instance()->set(p_property, p_value);
if (!valid) {
String error = "rset() aborted in local script set, property not found: - " + String(p_property);
ERR_PRINTS(error);
return;
}
}
}
}
if (skip_rset)
return;
const Variant *vptr = &p_value;
_send_rpc(p_node, p_peer_id, p_unreliable, true, p_property, &vptr, 1);
}
Error MultiplayerAPI::send_bytes(PoolVector<uint8_t> p_data, int p_to, NetworkedMultiplayerPeer::TransferMode p_mode) {
ERR_EXPLAIN("Trying to send an empty raw packet.");
ERR_FAIL_COND_V(p_data.size() < 1, ERR_INVALID_DATA);
ERR_EXPLAIN("Trying to send a raw packet while no network peer is active.");
ERR_FAIL_COND_V(!network_peer.is_valid(), ERR_UNCONFIGURED);
ERR_EXPLAIN("Trying to send a raw packet via a network peer which is not connected.");
ERR_FAIL_COND_V(network_peer->get_connection_status() != NetworkedMultiplayerPeer::CONNECTION_CONNECTED, ERR_UNCONFIGURED);
MAKE_ROOM(p_data.size() + 1);
PoolVector<uint8_t>::Read r = p_data.read();
packet_cache.write[0] = NETWORK_COMMAND_RAW;
memcpy(&packet_cache.write[1], &r[0], p_data.size());
network_peer->set_target_peer(p_to);
network_peer->set_transfer_mode(p_mode);
return network_peer->put_packet(packet_cache.ptr(), p_data.size() + 1);
}
void MultiplayerAPI::_process_raw(int p_from, const uint8_t *p_packet, int p_packet_len) {
ERR_EXPLAIN("Invalid packet received. Size too small.");
ERR_FAIL_COND(p_packet_len < 2);
PoolVector<uint8_t> out;
int len = p_packet_len - 1;
out.resize(len);
{
PoolVector<uint8_t>::Write w = out.write();
memcpy(&w[0], &p_packet[1], len);
}
emit_signal("network_peer_packet", p_from, out);
}
int MultiplayerAPI::get_network_unique_id() const {
ERR_EXPLAIN("No network peer is assigned. Unable to get unique network ID.");
ERR_FAIL_COND_V(!network_peer.is_valid(), 0);
return network_peer->get_unique_id();
}
bool MultiplayerAPI::is_network_server() const {
// XXX Maybe fail silently? Maybe should actually return true to make development of both local and online multiplayer easier?
ERR_EXPLAIN("No network peer is assigned. I can't be a server.");
ERR_FAIL_COND_V(!network_peer.is_valid(), false);
return network_peer->is_server();
}
void MultiplayerAPI::set_refuse_new_network_connections(bool p_refuse) {
ERR_EXPLAIN("No network peer is assigned. Unable to set 'refuse_new_connections'.");
ERR_FAIL_COND(!network_peer.is_valid());
network_peer->set_refuse_new_connections(p_refuse);
}
bool MultiplayerAPI::is_refusing_new_network_connections() const {
ERR_EXPLAIN("No network peer is assigned. Unable to get 'refuse_new_connections'.");
ERR_FAIL_COND_V(!network_peer.is_valid(), false);
return network_peer->is_refusing_new_connections();
}
Vector<int> MultiplayerAPI::get_network_connected_peers() const {
ERR_EXPLAIN("No network peer is assigned. Assume no peers are connected.");
ERR_FAIL_COND_V(!network_peer.is_valid(), Vector<int>());
Vector<int> ret;
for (Set<int>::Element *E = connected_peers.front(); E; E = E->next()) {
ret.push_back(E->get());
}
return ret;
}
void MultiplayerAPI::set_allow_object_decoding(bool p_enable) {
allow_object_decoding = p_enable;
}
bool MultiplayerAPI::is_object_decoding_allowed() const {
return allow_object_decoding;
}
void MultiplayerAPI::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_root_node", "node"), &MultiplayerAPI::set_root_node);
ClassDB::bind_method(D_METHOD("send_bytes", "bytes", "id", "mode"), &MultiplayerAPI::send_bytes, DEFVAL(NetworkedMultiplayerPeer::TARGET_PEER_BROADCAST), DEFVAL(NetworkedMultiplayerPeer::TRANSFER_MODE_RELIABLE));
ClassDB::bind_method(D_METHOD("has_network_peer"), &MultiplayerAPI::has_network_peer);
ClassDB::bind_method(D_METHOD("get_network_peer"), &MultiplayerAPI::get_network_peer);
ClassDB::bind_method(D_METHOD("get_network_unique_id"), &MultiplayerAPI::get_network_unique_id);
ClassDB::bind_method(D_METHOD("is_network_server"), &MultiplayerAPI::is_network_server);
ClassDB::bind_method(D_METHOD("get_rpc_sender_id"), &MultiplayerAPI::get_rpc_sender_id);
ClassDB::bind_method(D_METHOD("_add_peer", "id"), &MultiplayerAPI::_add_peer);
ClassDB::bind_method(D_METHOD("_del_peer", "id"), &MultiplayerAPI::_del_peer);
ClassDB::bind_method(D_METHOD("set_network_peer", "peer"), &MultiplayerAPI::set_network_peer);
ClassDB::bind_method(D_METHOD("poll"), &MultiplayerAPI::poll);
ClassDB::bind_method(D_METHOD("clear"), &MultiplayerAPI::clear);
ClassDB::bind_method(D_METHOD("_connected_to_server"), &MultiplayerAPI::_connected_to_server);
ClassDB::bind_method(D_METHOD("_connection_failed"), &MultiplayerAPI::_connection_failed);
ClassDB::bind_method(D_METHOD("_server_disconnected"), &MultiplayerAPI::_server_disconnected);
ClassDB::bind_method(D_METHOD("get_network_connected_peers"), &MultiplayerAPI::get_network_connected_peers);
ClassDB::bind_method(D_METHOD("set_refuse_new_network_connections", "refuse"), &MultiplayerAPI::set_refuse_new_network_connections);
ClassDB::bind_method(D_METHOD("is_refusing_new_network_connections"), &MultiplayerAPI::is_refusing_new_network_connections);
ClassDB::bind_method(D_METHOD("set_allow_object_decoding", "enable"), &MultiplayerAPI::set_allow_object_decoding);
ClassDB::bind_method(D_METHOD("is_object_decoding_allowed"), &MultiplayerAPI::is_object_decoding_allowed);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_object_decoding"), "set_allow_object_decoding", "is_object_decoding_allowed");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "refuse_new_network_connections"), "set_refuse_new_network_connections", "is_refusing_new_network_connections");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "network_peer", PROPERTY_HINT_RESOURCE_TYPE, "NetworkedMultiplayerPeer", 0), "set_network_peer", "get_network_peer");
ADD_SIGNAL(MethodInfo("network_peer_connected", PropertyInfo(Variant::INT, "id")));
ADD_SIGNAL(MethodInfo("network_peer_disconnected", PropertyInfo(Variant::INT, "id")));
ADD_SIGNAL(MethodInfo("network_peer_packet", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::POOL_BYTE_ARRAY, "packet")));
ADD_SIGNAL(MethodInfo("connected_to_server"));
ADD_SIGNAL(MethodInfo("connection_failed"));
ADD_SIGNAL(MethodInfo("server_disconnected"));
BIND_ENUM_CONSTANT(RPC_MODE_DISABLED);
BIND_ENUM_CONSTANT(RPC_MODE_REMOTE);
BIND_ENUM_CONSTANT(RPC_MODE_MASTER);
BIND_ENUM_CONSTANT(RPC_MODE_PUPPET);
BIND_ENUM_CONSTANT(RPC_MODE_SLAVE); // Deprecated.
BIND_ENUM_CONSTANT(RPC_MODE_REMOTESYNC);
BIND_ENUM_CONSTANT(RPC_MODE_SYNC); // Deprecated.
BIND_ENUM_CONSTANT(RPC_MODE_MASTERSYNC);
BIND_ENUM_CONSTANT(RPC_MODE_PUPPETSYNC);
}
MultiplayerAPI::MultiplayerAPI() :
allow_object_decoding(false) {
rpc_sender_id = 0;
root_node = NULL;
clear();
}
MultiplayerAPI::~MultiplayerAPI() {
clear();
}

View File

@ -1,139 +0,0 @@
/*************************************************************************/
/* multiplayer_api.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef MULTIPLAYER_PROTOCOL_H
#define MULTIPLAYER_PROTOCOL_H
#include "core/io/networked_multiplayer_peer.h"
#include "core/reference.h"
class MultiplayerAPI : public Reference {
GDCLASS(MultiplayerAPI, Reference);
private:
//path sent caches
struct PathSentCache {
Map<int, bool> confirmed_peers;
int id;
};
//path get caches
struct PathGetCache {
struct NodeInfo {
NodePath path;
ObjectID instance;
};
Map<int, NodeInfo> nodes;
};
Ref<NetworkedMultiplayerPeer> network_peer;
int rpc_sender_id;
Set<int> connected_peers;
HashMap<NodePath, PathSentCache> path_send_cache;
Map<int, PathGetCache> path_get_cache;
int last_send_cache_id;
Vector<uint8_t> packet_cache;
Node *root_node;
bool allow_object_decoding;
protected:
static void _bind_methods();
void _process_packet(int p_from, const uint8_t *p_packet, int p_packet_len);
void _process_simplify_path(int p_from, const uint8_t *p_packet, int p_packet_len);
void _process_confirm_path(int p_from, const uint8_t *p_packet, int p_packet_len);
Node *_process_get_node(int p_from, const uint8_t *p_packet, int p_packet_len);
void _process_rpc(Node *p_node, const StringName &p_name, int p_from, const uint8_t *p_packet, int p_packet_len, int p_offset);
void _process_rset(Node *p_node, const StringName &p_name, int p_from, const uint8_t *p_packet, int p_packet_len, int p_offset);
void _process_raw(int p_from, const uint8_t *p_packet, int p_packet_len);
void _send_rpc(Node *p_from, int p_to, bool p_unreliable, bool p_set, const StringName &p_name, const Variant **p_arg, int p_argcount);
bool _send_confirm_path(NodePath p_path, PathSentCache *psc, int p_from);
public:
enum NetworkCommands {
NETWORK_COMMAND_REMOTE_CALL,
NETWORK_COMMAND_REMOTE_SET,
NETWORK_COMMAND_SIMPLIFY_PATH,
NETWORK_COMMAND_CONFIRM_PATH,
NETWORK_COMMAND_RAW,
};
enum RPCMode {
RPC_MODE_DISABLED, // No rpc for this method, calls to this will be blocked (default)
RPC_MODE_REMOTE, // Using rpc() on it will call method / set property in all remote peers
RPC_MODE_MASTER, // Using rpc() on it will call method on wherever the master is, be it local or remote
RPC_MODE_PUPPET, // Using rpc() on it will call method for all puppets
RPC_MODE_SLAVE = RPC_MODE_PUPPET, // Deprecated, same as puppet
RPC_MODE_REMOTESYNC, // Using rpc() on it will call method / set property in all remote peers and locally
RPC_MODE_SYNC = RPC_MODE_REMOTESYNC, // Deprecated. Same as RPC_MODE_REMOTESYNC
RPC_MODE_MASTERSYNC, // Using rpc() on it will call method / set property in the master peer and locally
RPC_MODE_PUPPETSYNC, // Using rpc() on it will call method / set property in all puppets peers and locally
};
void poll();
void clear();
void set_root_node(Node *p_node);
void set_network_peer(const Ref<NetworkedMultiplayerPeer> &p_peer);
Ref<NetworkedMultiplayerPeer> get_network_peer() const;
Error send_bytes(PoolVector<uint8_t> p_data, int p_to = NetworkedMultiplayerPeer::TARGET_PEER_BROADCAST, NetworkedMultiplayerPeer::TransferMode p_mode = NetworkedMultiplayerPeer::TRANSFER_MODE_RELIABLE);
// Called by Node.rpc
void rpcp(Node *p_node, int p_peer_id, bool p_unreliable, const StringName &p_method, const Variant **p_arg, int p_argcount);
// Called by Node.rset
void rsetp(Node *p_node, int p_peer_id, bool p_unreliable, const StringName &p_property, const Variant &p_value);
void _add_peer(int p_id);
void _del_peer(int p_id);
void _connected_to_server();
void _connection_failed();
void _server_disconnected();
bool has_network_peer() const { return network_peer.is_valid(); }
Vector<int> get_network_connected_peers() const;
int get_rpc_sender_id() const { return rpc_sender_id; }
int get_network_unique_id() const;
bool is_network_server() const;
void set_refuse_new_network_connections(bool p_refuse);
bool is_refusing_new_network_connections() const;
void set_allow_object_decoding(bool p_enable);
bool is_object_decoding_allowed() const;
MultiplayerAPI();
~MultiplayerAPI();
};
VARIANT_ENUM_CAST(MultiplayerAPI::RPCMode);
#endif // MULTIPLAYER_PROTOCOL_H

View File

@ -1,42 +0,0 @@
/*************************************************************************/
/* net_socket.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "net_socket.h"
NetSocket *(*NetSocket::_create)() = NULL;
NetSocket *NetSocket::create() {
if (_create)
return _create();
ERR_PRINT("Unable to create network socket, platform not supported");
return NULL;
}

View File

@ -1,79 +0,0 @@
/*************************************************************************/
/* net_socket.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef NET_SOCKET_H
#define NET_SOCKET_H
#include "core/io/ip.h"
#include "core/reference.h"
class NetSocket : public Reference {
protected:
static NetSocket *(*_create)();
public:
static NetSocket *create();
enum PollType {
POLL_TYPE_IN,
POLL_TYPE_OUT,
POLL_TYPE_IN_OUT
};
enum Type {
TYPE_NONE,
TYPE_TCP,
TYPE_UDP,
};
virtual Error open(Type p_type, IP::Type &ip_type) = 0;
virtual void close() = 0;
virtual Error bind(IP_Address p_addr, uint16_t p_port) = 0;
virtual Error listen(int p_max_pending) = 0;
virtual Error connect_to_host(IP_Address p_addr, uint16_t p_port) = 0;
virtual Error poll(PollType p_type, int timeout) const = 0;
virtual Error recv(uint8_t *p_buffer, int p_len, int &r_read) = 0;
virtual Error recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Address &r_ip, uint16_t &r_port) = 0;
virtual Error send(const uint8_t *p_buffer, int p_len, int &r_sent) = 0;
virtual Error sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IP_Address p_ip, uint16_t p_port) = 0;
virtual Ref<NetSocket> accept(IP_Address &r_ip, uint16_t &r_port) = 0;
virtual bool is_open() const = 0;
virtual int get_available_bytes() const = 0;
virtual void set_broadcasting_enabled(bool p_enabled) = 0;
virtual void set_blocking_enabled(bool p_enabled) = 0;
virtual void set_ipv6_only_enabled(bool p_enabled) = 0;
virtual void set_tcp_no_delay_enabled(bool p_enabled) = 0;
virtual void set_reuse_address_enabled(bool p_enabled) = 0;
};
#endif // NET_SOCKET_H

Some files were not shown because too many files have changed in this diff Show More