Commit Graph

110 Commits

Author SHA1 Message Date
Pedro J. Estébanez d904d05e65 Fix dangling and reassigned Variants
This commit addresses multiple issues with `Variant`s that point to an `Object`
which is later released, when it's tried to be accessed again.

Formerly, **while running on the debugger the system would check if the instance id was
still valid** to print warnings or return special values. Some cases weren't being
warned about whatsoever.

Also, a newly allocated `Object` could happen to be allocated at the same memory
address of an old one, making cases of use hard to find and having **`Variant`s pointing
to the old one magically reassigned to the new**.

This commit makes the engine realize all these situations **under debugging**
so you can detect and fix them. Running without a debugger attached will still
behave as it always did.

Also the warning messages have been extended and made clearer.

All that said, in the name of performance there's still one possible case of undefined
behavior: in multithreaded scripts there would be a race condition between a thread freeing
an `Object` and another one trying to operate on it. The latter may not realize the
`Object` has been freed soon enough. But that's a case of bad scripting that was never
supported anyway.
2020-04-23 13:51:02 +02:00
Rémi Verschelde a7f49ac9a1 Update copyright statements to 2020
Happy new year to the wonderful Godot community!

We're starting a new decade with a well-established, non-profit, free
and open source game engine, and tons of further improvements in the
pipeline from hundreds of contributors.

Godot will keep getting better, and we're looking forward to all the
games that the community will keep developing and releasing with it.
2020-01-01 11:16:22 +01:00
Rafał Mikrut 162a64efcd Don't allow to use too big or too small shift operators 2019-12-12 20:00:26 +01:00
qarmin 6cbaf7662f Changed some code showed in LGTM and Coverage 2019-07-20 08:09:57 +02:00
qarmin 3c154eb93b Remove unnecessary code and add some error explanations 2019-07-01 12:59:42 +02:00
Rémi Verschelde c8994b56f9 Style: Apply new changes from clang-format 8.0
It seems to stay compatible with formatting done by clang-format 6.0 and 7.0,
so contributors can keep using those versions for now (they will not undo those
changes).
2019-04-09 17:09:48 +02:00
Rémi Verschelde dd5376f9df
Merge pull request #25934 from mrcdk/pool_int_real_color_interpolate
Added PoolIntArray, PoolRealArray and PoolColorArray interpolate
2019-03-03 13:30:43 +01:00
marxin 8d51618949 Add -Wshadow=local to warnings and fix reported issues.
Fixes #25316.
2019-02-20 19:44:12 +01:00
MrCdK 3441e2a96f Added PoolIntArray, PoolRealArray and PoolColorArray interpolate 2019-02-16 12:20:01 +01:00
Rémi Verschelde b16c309f82 Update copyright statements to 2019
Happy new year to the wonderful Godot community!
2019-01-01 12:58:10 +01:00
Aaron Franke cb01268562 Fix many errors found by PVS-Studio
Fix errors 2, 3, 4, 6, 8, 9, 11, 12, 13, 14, and 15.
2018-11-28 05:03:24 -05:00
qonnop 50fae2b1a7 Optimize interpolation algorithms
Interpolation in the form of va + (vb - va) * c is faster and prevents floating point issues for int/string
Followup to https://github.com/godotengine/godot/pull/22786
2018-10-07 15:43:51 +02:00
Rémi Verschelde 44d82b3a07
Merge pull request #22752 from aaronfranke/equals-redundant
Remove redundant "== true" and "== false" code
2018-10-07 10:58:45 +02:00
Aaron Franke 4f7b33cdcf Remove redundant "== false" code
Some of this code has been re-organized.
f
2018-10-06 16:20:41 -04:00
qonnop bbfc6f6985 Fixed int interpolation issue, closes #22763
When interpolating between two equal int values a and b, floating point
calculation imprecisions can result in different values depending on
the interpolation factor.
2018-10-06 15:52:42 +02:00
Rémi Verschelde c4f14e091c Color: Fix rounding error converting from float to 8-bit
Fixes #16736.
2018-09-18 17:11:15 +02:00
Rémi Verschelde 277b24dfb7 Make core/ includes absolute, remove subfolders from include path
This allows more consistency in the manner we include core headers,
where previously there would be a mix of absolute, relative and
include path-dependent includes.
2018-09-12 09:52:22 +02:00
Juan Linietsky d280b14e6e Hacked around duplication bug. I think duplicate needs to be even smarter, maybe pass two bools? (containers and/or resources) 2018-07-03 08:34:06 -03:00
Juan Linietsky 2dc738ce27 -Fixes to how hashing happened, now StringName and NodePath use default hasher, this was leading to some severe slowdown in scenarios
-Fixes to some duplication scenarios for instanced scenes
2018-07-02 15:08:35 -03:00
ShyRed 100a775260 Keep alpha when changing h, s or v on color
When modifying the h, s or v properties of a color in GDScript the alpha value needs to stay unchanged.
2018-04-22 17:00:45 +02:00
George Marques fefee533ae
Fix names of Variant operators 2018-04-16 14:54:49 -03:00
Juan Linietsky 4ee3f3251d
Merge pull request #17382 from bojidar-bg/13971-path-array-unsaved
Duplicate Arrays and Dictionaries when instancing scene in editor
2018-04-08 09:39:03 -03:00
Bojidar Marinov 9f6c0c6eae
Duplicate Arrays and Dictionaries when instancing scene in editor
Also, add deep (=false) parameter to Array.duplicate and Dictionary.duplicate

Fixes #13971
2018-03-13 17:18:08 +02:00
Bojidar Marinov 4d81e8afe6 Fix a potential bug hinted by clang 2018-03-13 17:10:28 +02:00
Poommetee Ketson f4f92b55e1 Color:fix setting V switch S to old V value 2018-02-22 16:43:00 +07:00
luz.paz 612ab4bbc6 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
```
2018-02-21 19:46:06 +01:00
MrCdK b2617e72e5 Fix NEQ operation between 2 different Arrays
it was returning false if it found the same content in both arrays which isn't correct, it should return true when it finds different values
2018-01-06 04:19:48 +01:00
Rémi Verschelde e4213e66b2 Add missing copyright headers and fix formatting
Using `misc/scripts/fix_headers.py` on all Godot files.
Some missing header guards were added, and the header inclusion order
was fixed in the Bullet module.
2018-01-05 01:22:23 +01:00
Rémi Verschelde b50a9114b1 Update copyright statements to 2018
Happy new year to the wonderful Godot community!
2018-01-01 14:40:47 +01:00
Ferenc Arn d28763a4c1 Rename Rect3 to AABB.
Fixes #12973.
2017-11-17 11:01:41 -05:00
Marcelo Fernandez d3a039cb2f Fix Color.r8/g8/b8/a8 being type float instead of type int 2017-10-19 12:36:06 -03:00
Hein-Pieter van Braam 758accdcc2 Make variant_op jumptable const
Not doing this was a bit of an oversight
2017-09-25 18:29:44 +02:00
Hein-Pieter van Braam a124651280 Merge pull request #11549 from hpvb/fix-11543
Fix Dictionary set_named
2017-09-24 20:22:53 +02:00
Marcelo Fernandez 57d438eb7a Fix Variant::get_named return when p_index is invalid 2017-09-24 14:50:51 -03:00
Hein-Pieter van Braam 4d14d61bbc Fix Dictionary set_named
Reduz optimized field indexing in 3c85703 but the changes didn't apply
to dictionary so this code remained untouched. However, the logic for
validity checking was changed but not updated for the dictionary case.
2017-09-24 19:44:49 +02:00
Rémi Verschelde ebaf2d89e9 Merge pull request #11473 from hpvb/fix-11466
Implement operator != on Pool*Array types
2017-09-24 15:59:59 +02:00
Juan Linietsky 3c857033df Massive optimization to Variant::set_named/get_named. Should give a nice boost to GDScript. 2017-09-23 21:05:35 -03:00
Hein-Pieter van Braam 7b492e6a23 Implement operator != on Pool*Array types
These types previously had equality checks but not inequality checks.
Add these too.

This fixes #11466
2017-09-22 14:40:42 +02:00
Hein-Pieter van Braam 6565cf3360 Allow equality checks between null and arbitrary types
Uninitialzed values in GDScript are of type NIL so not allowing null
comparisons did end up breaking some code.

This commit reenables NULL equality checks for all types. We're going to
have to figure out how to make this fast for the compiler later.
2017-09-20 22:14:38 +02:00
Hein-Pieter van Braam 833c3917b2 Allow booleanization of all types
We now allow booleanization of all types. This means that empty versions
of all types now evaluate to false. So a Vector2(0,0), Dictionary(),
etc.

This allows you to write GDScript like:
if not Dictionary():
  print("Empty dict")

Booleanization can now also no longer fail. There is no more valid flag,
this changes Variant and GDNative API.
2017-09-19 18:55:31 +02:00
Hein-Pieter van Braam 85641c545b Be type-strict checking on equality checks
After a short discussion with @reduz and @karroffel we decided to make
all non number/number comparisons return type errors on comparisons.

Now bool == bool is allowed but Vector2 == Vector3 is a type error and
no longer 'not equal'. The same has been done for the != operators.

In addition I forgot to add some failures to some Object operators
meaning that there was a potential for a crasher.
2017-09-19 16:00:19 +02:00
Hein-Pieter van Braam 36e8bee752 Fix accidental cast to Vector3 for Vector2 iter 2017-09-19 14:18:12 +02:00
Hein-Pieter van Braam 137f8a58a8 Move Variant::evaluate() switch to computed goto
In an effort to make GDScript a little faster replace the double
switch() with a computed goto on compilers that set __GNUC__. For
compilers that don't support computed goto it will fall back to regular
switch/case statements.

In addition disable using boolean values in a mathematical context. Now
boolean values can only be compared with other booleans. Booleans will
also no longer be coerced to integers.

This PR replaces #11308 and fixes #11291
2017-09-17 22:49:23 +02:00
bncastle 9d9cfc6f61 Implement +,-,/, * and negate operators for Color type. 2017-09-16 13:09:49 -04:00
Thomas Herzog 111dae950d Revert "Don't allow division by false (zero)" 2017-09-15 23:39:09 +02:00
Hein-Pieter van Braam 4f16baca43 Don't allow division by false (zero)
This fixes #10717
2017-09-15 22:02:22 +02:00
Rémi Verschelde bd282ff43f Use HTTPS URL for Godot's website in the headers 2017-08-27 14:16:55 +02:00
Juan Linietsky 2a3e00c8c7 -Many fixes to VisualScript, fixed property names, etc.
-Added ability to set/get a field in GetSet, as well as assignment ops
-Added a Select node
-Fixed update bugs related to variable list and exported properties, closes #9458
2017-06-30 21:35:05 -03:00
Juan Linietsky db3b05d289 Reworked translation system
-Label and Button reload translation on the fly
-Resources are loaded and reload depending on locale
2017-06-28 17:01:35 -03:00
Bojidar Marinov 26a51c3c0b
Reimplement for..in range() so that it always results in ints
Fixes #8278, fixup of bfef8de1bc
2017-06-22 20:41:52 +03:00