diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/core_bind.cpp | 2 | ||||
-rw-r--r-- | core/crypto/crypto.cpp | 3 | ||||
-rw-r--r-- | core/input/gamecontrollerdb.txt | 17 | ||||
-rw-r--r-- | core/math/dynamic_bvh.cpp | 29 | ||||
-rw-r--r-- | core/math/dynamic_bvh.h | 35 | ||||
-rw-r--r-- | core/object/class_db.cpp | 4 | ||||
-rw-r--r-- | core/os/os.cpp | 28 | ||||
-rw-r--r-- | core/os/os.h | 7 | ||||
-rw-r--r-- | core/string/ustring.cpp | 6 | ||||
-rw-r--r-- | core/templates/list.h | 2 | ||||
-rw-r--r-- | core/templates/vector.h | 4 | ||||
-rw-r--r-- | core/variant/array.cpp | 4 | ||||
-rw-r--r-- | core/variant/array.h | 2 | ||||
-rw-r--r-- | core/variant/binder_common.h | 66 | ||||
-rw-r--r-- | core/variant/variant_call.cpp | 365 | ||||
-rw-r--r-- | core/variant/variant_setget.cpp | 6 |
16 files changed, 488 insertions, 92 deletions
diff --git a/core/core_bind.cpp b/core/core_bind.cpp index c3d547c2c7..84d8d0d4d3 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -1334,7 +1334,7 @@ Vector<uint8_t> _File::get_buffer(int p_length) const { ERR_FAIL_COND_V(len < 0, Vector<uint8_t>()); if (len < p_length) { - data.resize(p_length); + data.resize(len); } return data; diff --git a/core/crypto/crypto.cpp b/core/crypto/crypto.cpp index 6b3953f588..fe913549c9 100644 --- a/core/crypto/crypto.cpp +++ b/core/crypto/crypto.cpp @@ -157,8 +157,9 @@ RES ResourceFormatLoaderCrypto::load(const String &p_path, const String &p_origi return key; } else if (el == "pub") { CryptoKey *key = CryptoKey::create(); - if (key) + if (key) { key->load(p_path, true); + } return key; } return nullptr; diff --git a/core/input/gamecontrollerdb.txt b/core/input/gamecontrollerdb.txt index f2a3135b05..884fb9550c 100644 --- a/core/input/gamecontrollerdb.txt +++ b/core/input/gamecontrollerdb.txt @@ -65,6 +65,7 @@ 03000000808300000300000000000000,Betop Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,platform:Windows, 030000006b1400000055000000000000,Bigben PS3 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows, 030000006b1400000103000000000000,Bigben PS3 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Windows, +03000000120c0000210e000000000000,Brook Mars,a:b1,b:b2,x:b0,y:b3,back:b8,guide:b12,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,platform:Windows, 0300000066f700000500000000000000,BrutalLegendTest,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b3,platform:Windows, 03000000d81d00000b00000000000000,BUFFALO BSGP1601 Series ,a:b5,b:b3,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b8,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b9,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b13,x:b4,y:b2,platform:Windows, 03000000e82000006058000000000000,Cideko AK08b,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows, @@ -374,6 +375,8 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2, 03000000c62400001a89000000010000,BDA MOGA XP5-X Plus,a:b0,b:b1,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b14,leftshoulder:b6,leftstick:b15,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b16,righttrigger:a4,rightx:a2,righty:a3,start:b13,x:b3,y:b4,platform:Mac OS X, 03000000c62400001b89000000010000,BDA MOGA XP5-X Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X, 03000000d62000002a79000000010000,BDA PS4 Fightpad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X, +03000000120c0000200e000000010000,Brook Mars,a:b1,b:b2,x:b0,y:b3,back:b8,guide:b12,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a5,lefttrigger:a3,righttrigger:a4,platform:Mac OS X, +03000000120c0000210e000000010000,Brook Mars,a:b1,b:b2,x:b0,y:b3,back:b8,guide:b12,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,platform:Mac OS X, 030000008305000031b0000000000000,Cideko AK08b,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X, 03000000260900008888000088020000,Cyber Gadget GameCube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:a5,rightx:a2,righty:a3~,start:b7,x:b2,y:b3,platform:Mac OS X, 03000000a306000022f6000001030000,Cyborg V.3 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:-a3,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Mac OS X, @@ -552,6 +555,8 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2, 03000000c31100000791000011010000,Be1 GC101 GAMEPAD 1.03 mode,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux, 030000005e0400008e02000003030000,Be1 GC101 Xbox 360 Controller mode,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, 03000000666600006706000000010000,boom PSX to PC Converter,a:b2,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a2,righty:a3,start:b11,x:b3,y:b0,platform:Linux, +03000000120c0000200e000011010000,Brook Mars,a:b1,b:b2,x:b0,y:b3,back:b8,guide:b12,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a5,lefttrigger:a3,righttrigger:a4,platform:Linux, +03000000120c0000210e000011010000,Brook Mars,a:b1,b:b2,x:b0,y:b3,back:b8,guide:b12,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,platform:Linux, 03000000ffff0000ffff000000010000,Chinese-made Xbox Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b5,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b4,platform:Linux, 03000000e82000006058000001010000,Cideko AK08b,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux, 030000000b0400003365000000010000,Competition Pro,a:b0,b:b1,back:b2,leftx:a0,lefty:a1,start:b3,platform:Linux, @@ -680,9 +685,11 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2, 060000007e0500000820000000000000,Nintendo Combined Joy-Cons (joycond),a:b0,b:b1,back:b9,dpdown:b15,dpleft:b16,dpright:b17,dpup:b14,guide:b11,leftshoulder:b5,leftstick:b12,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b13,righttrigger:b8,rightx:a2,righty:a3,start:b10,x:b3,y:b2,platform:Linux, 030000007e0500003703000000016800,Nintendo GameCube Controller,a:b0,b:b2,dpdown:b6,dpleft:b4,dpright:b5,dpup:b7,lefttrigger:a4,leftx:a0,lefty:a1~,rightshoulder:b9,righttrigger:a5,rightx:a2,righty:a3~,start:b8,x:b1,y:b3,platform:Linux, 03000000790000004618000010010000,Nintendo GameCube Controller Adapter,a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,rightx:a5~,righty:a2~,start:b9,x:b0,y:b3,platform:Linux, +050000007e0500000620000001800000,Nintendo Switch Left Joy-Con,a:b9,b:b8,x:b7,y:b10,back:b5,start:b0,leftstick:b6,leftshoulder:b2,rightshoulder:b4,leftx:a1,lefty:a0~,platform:Linux, +050000007e0500000720000001800000,Nintendo Switch Right Joy-Con,a:b1,b:b2,x:b0,y:b3,back:b9,start:b8,leftstick:b10,leftshoulder:b4,rightshoulder:b6,leftx:a1~,lefty:a0~,platform:Linux, 050000007e0500000920000001000000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux, -050000007e0500000920000001800000,Nintendo Switch Pro Controller (joycond),a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b11,leftshoulder:b5,leftstick:b12,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b13,righttrigger:b8,rightx:a2,righty:a3,start:b10,x:b3,y:b2,platform:Linux, -030000007e0500000920000011810000,Nintendo Switch Pro Controller Wired (joycond),a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b11,leftshoulder:b5,leftstick:b12,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b13,righttrigger:b8,rightx:a2,righty:a3,start:b10,x:b3,y:b2,platform:Linux, +050000007e0500000920000001800000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b11,leftshoulder:b5,leftstick:b12,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b13,righttrigger:b8,rightx:a2,righty:a3,start:b10,x:b3,y:b2,platform:Linux, +030000007e0500000920000011810000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b11,leftshoulder:b5,leftstick:b12,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b13,righttrigger:b8,rightx:a2,righty:a3,start:b10,x:b3,y:b2,platform:Linux, 050000007e0500003003000001000000,Nintendo Wii Remote Pro Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Linux, 05000000010000000100000003000000,Nintendo Wiimote,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux, 030000000d0500000308000010010000,Nostromo n45 Dual Analog Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b12,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b10,x:b2,y:b3,platform:Linux, @@ -715,7 +722,9 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2, 03000000c62400000053000000010000,PowerA,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, 03000000c62400003a54000001010000,PowerA 1428124-01,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, 03000000d62000006dca000011010000,PowerA Pro Ex,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, +03000000d62000000228000001010000,PowerA Wired Controller for Xbox One,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, 03000000c62400001a58000001010000,PowerA Xbox One Cabled,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, +03000000c62400001a54000001010000,PowerA Xbox One Mini Wired Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, 030000006d040000d2ca000011010000,Precision Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, 03000000ff1100004133000010010000,PS2 Controller,a:b2,b:b1,back:b8,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Linux, 03000000341a00003608000011010000,PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, @@ -801,7 +810,8 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2, 03000000de2800000112000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux, 03000000de2800000211000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux, 03000000de2800004211000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux, -03000000de2800004211000011010000,Steam Controller,a:b2,b:b3,back:b10,dpdown:b18,dpleft:b19,dpright:b20,dpup:b17,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b5,platform:Linux, +03000000de2800000211000011010000,Steam Controller,a:b2,b:b3,back:b10,dpdown:b18,dpleft:b19,dpright:b20,dpup:b17,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,paddle1:b15,paddle2:b16,rightshoulder:b7,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b5,platform:Linux, +03000000de2800004211000011010000,Steam Controller,a:b2,b:b3,back:b10,dpdown:b18,dpleft:b19,dpright:b20,dpup:b17,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,paddle1:b15,paddle2:b16,rightshoulder:b7,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b5,platform:Linux, 03000000de280000fc11000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, 05000000de2800000212000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux, 05000000de2800000511000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux, @@ -890,6 +900,7 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2, 050000003512000020ab000000780f00,8BitDo SNES30 Gamepad,a:b21,b:b20,back:b30,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b26,rightshoulder:b27,start:b31,x:b24,y:b23,platform:Android, 05000000c82d000018900000ffff0f00,8BitDo Zero 2,a:b1,b:b0,back:b4,leftshoulder:b9,leftx:a0,lefty:a1,rightshoulder:b10,start:b6,x:b3,y:b2,platform:Android, 05000000c82d000030320000ffff0f00,8BitDo Zero 2,a:b1,b:b0,back:b4,leftshoulder:b9,leftx:a0,lefty:a1,rightshoulder:b10,start:b6,x:b3,y:b2,platform:Android, +38383337343564366131323064613561,Brook Mars,a:b1,b:b19,x:b0,y:b2,leftshoulder:b3,rightshoulder:b20,lefttrigger:b9,righttrigger:b10,back:b17,start:b18,leftx:a0,lefty:a1,rightx:a2,righty:a3,leftstick:b15,rightstick:b6,platform:Android, 05000000bc20000000550000ffff3f00,GameSir G3w,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android, 05000000d6020000e5890000dfff3f00,GPD XD Plus,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a5,start:b6,x:b2,y:b3,platform:Android, 0500000031366332860c44aadfff0f00,GS Gamepad,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:b15,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:b16,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android, diff --git a/core/math/dynamic_bvh.cpp b/core/math/dynamic_bvh.cpp index 4639a52278..200095d8cb 100644 --- a/core/math/dynamic_bvh.cpp +++ b/core/math/dynamic_bvh.cpp @@ -61,7 +61,7 @@ DynamicBVH::Node *DynamicBVH::_create_node_with_volume(Node *p_parent, const Vol void DynamicBVH::_insert_leaf(Node *p_root, Node *p_leaf) { if (!bvh_root) { bvh_root = p_leaf; - p_leaf->parent = 0; + p_leaf->parent = nullptr; } else { if (!p_root->is_leaf()) { do { @@ -71,7 +71,7 @@ void DynamicBVH::_insert_leaf(Node *p_root, Node *p_leaf) { } while (!p_root->is_leaf()); } Node *prev = p_root->parent; - Node *node = _create_node_with_volume(prev, p_leaf->volume.merge(p_root->volume), 0); + Node *node = _create_node_with_volume(prev, p_leaf->volume.merge(p_root->volume), nullptr); if (prev) { prev->childs[p_root->get_index_in_parent()] = node; node->childs[0] = p_root; @@ -85,7 +85,7 @@ void DynamicBVH::_insert_leaf(Node *p_root, Node *p_leaf) { break; } node = prev; - } while (0 != (prev = node->parent)); + } while (nullptr != (prev = node->parent)); } else { node->childs[0] = p_root; p_root->parent = node; @@ -98,8 +98,8 @@ void DynamicBVH::_insert_leaf(Node *p_root, Node *p_leaf) { DynamicBVH::Node *DynamicBVH::_remove_leaf(Node *leaf) { if (leaf == bvh_root) { - bvh_root = 0; - return (0); + bvh_root = nullptr; + return (nullptr); } else { Node *parent = leaf->parent; Node *prev = parent->parent; @@ -113,13 +113,14 @@ DynamicBVH::Node *DynamicBVH::_remove_leaf(Node *leaf) { prev->volume = prev->childs[0]->volume.merge(prev->childs[1]->volume); if (pb.is_not_equal_to(prev->volume)) { prev = prev->parent; - } else + } else { break; + } } return (prev ? prev : bvh_root); } else { bvh_root = sibling; - sibling->parent = 0; + sibling->parent = nullptr; _delete_node(parent); return (bvh_root); } @@ -262,10 +263,11 @@ DynamicBVH::Node *DynamicBVH::_node_sort(Node *n, Node *&r) { Node *s = p->childs[j]; Node *q = p->parent; ERR_FAIL_COND_V(n != p->childs[i], nullptr); - if (q) + if (q) { q->childs[p->get_index_in_parent()] = n; - else + } else { r = n; + } s->parent = n; p->parent = n; n->parent = q; @@ -307,8 +309,9 @@ void DynamicBVH::optimize_top_down(int bu_threshold) { } void DynamicBVH::optimize_incremental(int passes) { - if (passes < 0) + if (passes < 0) { passes = total_leaves; + } if (bvh_root && (passes > 0)) { do { Node *node = bvh_root; @@ -345,8 +348,9 @@ void DynamicBVH::_update(Node *leaf, int lookahead) { for (int i = 0; (i < lookahead) && root->parent; ++i) { root = root->parent; } - } else + } else { root = bvh_root; + } } _insert_leaf(root, leaf); } @@ -370,8 +374,9 @@ bool DynamicBVH::update(const ID &p_id, const AABB &p_box) { for (int i = 0; (i < lkhd) && base->parent; ++i) { base = base->parent; } - } else + } else { base = bvh_root; + } } leaf->volume = volume; _insert_leaf(base, leaf); diff --git a/core/math/dynamic_bvh.h b/core/math/dynamic_bvh.h index c71db2d24d..3fb22515a2 100644 --- a/core/math/dynamic_bvh.h +++ b/core/math/dynamic_bvh.h @@ -87,14 +87,16 @@ private: _FORCE_INLINE_ Volume merge(const Volume &b) const { Volume r; for (int i = 0; i < 3; ++i) { - if (min[i] < b.min[i]) + if (min[i] < b.min[i]) { r.min[i] = min[i]; - else + } else { r.min[i] = b.min[i]; - if (max[i] > b.max[i]) + } + if (max[i] > b.max[i]) { r.max[i] = max[i]; - else + } else { r.max[i] = b.max[i]; + } } return r; } @@ -202,10 +204,11 @@ private: // int count_leaves() const { - if (is_internal()) + if (is_internal()) { return childs[0]->count_leaves() + childs[1]->count_leaves(); - else + } else { return (1); + } } bool is_left_of_axis(const Vector3 &org, const Vector3 &axis) const { @@ -254,31 +257,37 @@ private: tymin = (bounds[raySign[1]].y - rayFrom.y) * rayInvDirection.y; tymax = (bounds[1 - raySign[1]].y - rayFrom.y) * rayInvDirection.y; - if ((tmin > tymax) || (tymin > tmax)) + if ((tmin > tymax) || (tymin > tmax)) { return false; + } - if (tymin > tmin) + if (tymin > tmin) { tmin = tymin; + } - if (tymax < tmax) + if (tymax < tmax) { tmax = tymax; + } tzmin = (bounds[raySign[2]].z - rayFrom.z) * rayInvDirection.z; tzmax = (bounds[1 - raySign[2]].z - rayFrom.z) * rayInvDirection.z; - if ((tmin > tzmax) || (tzmin > tmax)) + if ((tmin > tzmax) || (tzmin > tmax)) { return false; - if (tzmin > tmin) + } + if (tzmin > tmin) { tmin = tzmin; - if (tzmax < tmax) + } + if (tzmax < tmax) { tmax = tzmax; + } return ((tmin < lambda_max) && (tmax > lambda_min)); } public: // Methods void clear(); - bool is_empty() const { return (0 == bvh_root); } + bool is_empty() const { return (nullptr == bvh_root); } void optimize_bottom_up(); void optimize_top_down(int bu_threshold = 128); void optimize_incremental(int passes); diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp index 375ad8fae1..fb7eb42738 100644 --- a/core/object/class_db.cpp +++ b/core/object/class_db.cpp @@ -1095,6 +1095,8 @@ bool ClassDB::get_property_info(StringName p_class, StringName p_property, Prope } bool ClassDB::set_property(Object *p_object, const StringName &p_property, const Variant &p_value, bool *r_valid) { + ERR_FAIL_NULL_V(p_object, false); + ClassInfo *type = classes.getptr(p_object->get_class_name()); ClassInfo *check = type; while (check) { @@ -1142,6 +1144,8 @@ bool ClassDB::set_property(Object *p_object, const StringName &p_property, const } bool ClassDB::get_property(Object *p_object, const StringName &p_property, Variant &r_value) { + ERR_FAIL_NULL_V(p_object, false); + ClassInfo *type = classes.getptr(p_object->get_class_name()); ClassInfo *check = type; while (check) { diff --git a/core/os/os.cpp b/core/os/os.cpp index 182bab4058..ca1b798e11 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -106,10 +106,18 @@ void OS::add_logger(Logger *p_logger) { } void OS::print_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, Logger::ErrorType p_type) { + if (!_stderr_enabled) { + return; + } + _logger->log_error(p_function, p_file, p_line, p_code, p_rationale, p_type); } void OS::print(const char *p_format, ...) { + if (!_stdout_enabled) { + return; + } + va_list argp; va_start(argp, p_format); @@ -119,6 +127,10 @@ void OS::print(const char *p_format, ...) { } void OS::printerr(const char *p_format, ...) { + if (!_stderr_enabled) { + return; + } + va_list argp; va_start(argp, p_format); @@ -163,6 +175,22 @@ bool OS::is_stdout_debug_enabled() const { return _debug_stdout; } +bool OS::is_stdout_enabled() const { + return _stdout_enabled; +} + +bool OS::is_stderr_enabled() const { + return _stderr_enabled; +} + +void OS::set_stdout_enabled(bool p_enabled) { + _stdout_enabled = p_enabled; +} + +void OS::set_stderr_enabled(bool p_enabled) { + _stderr_enabled = p_enabled; +} + void OS::dump_memory_to_file(const char *p_file) { //Memory::dump_static_mem_to_file(p_file); } diff --git a/core/os/os.h b/core/os/os.h index e41d788e12..7198607237 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -60,6 +60,8 @@ class OS { bool _allow_layered = false; bool _use_vsync; bool _vsync_via_compositor; + bool _stdout_enabled = true; + bool _stderr_enabled = true; char *last_error; @@ -219,6 +221,11 @@ public: bool is_stdout_verbose() const; bool is_stdout_debug_enabled() const; + bool is_stdout_enabled() const; + bool is_stderr_enabled() const; + void set_stdout_enabled(bool p_enabled); + void set_stderr_enabled(bool p_enabled); + virtual void disable_crash_handler() {} virtual bool is_disable_crash_handler() const { return false; } virtual void initialize_debugging() {} diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index 28228e4a83..cf0040353d 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -1138,7 +1138,7 @@ Vector<String> String::rsplit(const String &p_splitter, bool p_allow_empty, int remaining_len = left_edge; } - ret.invert(); + ret.reverse(); return ret; } @@ -3772,9 +3772,9 @@ String String::uri_encode() const { } else { char h_Val[3]; #if defined(__GNUC__) || defined(_MSC_VER) - snprintf(h_Val, 3, "%hhX", ord); + snprintf(h_Val, 3, "%02hhX", ord); #else - sprintf(h_Val, "%hhX", ord); + sprintf(h_Val, "%02hhX", ord); #endif res += "%"; res += h_Val; diff --git a/core/templates/list.h b/core/templates/list.h index eaf1dbb4a0..010e35eed8 100644 --- a/core/templates/list.h +++ b/core/templates/list.h @@ -492,7 +492,7 @@ public: _data->last = p_I; } - void invert() { + void reverse() { int s = size() / 2; Element *F = front(); Element *B = back(); diff --git a/core/templates/vector.h b/core/templates/vector.h index 6a8902707c..a56a941dbc 100644 --- a/core/templates/vector.h +++ b/core/templates/vector.h @@ -74,7 +74,7 @@ public: remove(idx); } } - void invert(); + void reverse(); _FORCE_INLINE_ T *ptrw() { return _cowdata.ptrw(); } _FORCE_INLINE_ const T *ptr() const { return _cowdata.ptr(); } @@ -194,7 +194,7 @@ public: }; template <class T> -void Vector<T>::invert() { +void Vector<T>::reverse() { for (int i = 0; i < size() / 2; i++) { T *p = ptrw(); SWAP(p[i], p[size() - i - 1]); diff --git a/core/variant/array.cpp b/core/variant/array.cpp index 707140ba1b..2ad728ec5e 100644 --- a/core/variant/array.cpp +++ b/core/variant/array.cpp @@ -446,8 +446,8 @@ int Array::bsearch_custom(const Variant &p_value, Callable p_callable, bool p_be return bisect(_p->array, p_value, p_before, less); } -void Array::invert() { - _p->array.invert(); +void Array::reverse() { + _p->array.reverse(); } void Array::push_front(const Variant &p_value) { diff --git a/core/variant/array.h b/core/variant/array.h index 8b67f7f085..6b58ed12cb 100644 --- a/core/variant/array.h +++ b/core/variant/array.h @@ -83,7 +83,7 @@ public: void shuffle(); int bsearch(const Variant &p_value, bool p_before = true); int bsearch_custom(const Variant &p_value, Callable p_callable, bool p_before = true); - void invert(); + void reverse(); int find(const Variant &p_value, int p_from = 0) const; int rfind(const Variant &p_value, int p_from = -1) const; diff --git a/core/variant/binder_common.h b/core/variant/binder_common.h index 8c0b7907e3..86bbf43266 100644 --- a/core/variant/binder_common.h +++ b/core/variant/binder_common.h @@ -233,6 +233,11 @@ void call_with_ptr_args_retc_helper(T *p_instance, R (T::*p_method)(P...) const, PtrToArg<R>::encode((p_instance->*p_method)(PtrToArg<P>::convert(p_args[Is])...), r_ret); } +template <class T, class... P, size_t... Is> +void call_with_ptr_args_static_helper(T *p_instance, void (*p_method)(T *, P...), const void **p_args, IndexSequence<Is...>) { + p_method(p_instance, PtrToArg<P>::convert(p_args[Is])...); +} + template <class T, class R, class... P, size_t... Is> void call_with_ptr_args_static_retc_helper(T *p_instance, R (*p_method)(T *, P...), const void **p_args, void *r_ret, IndexSequence<Is...>) { PtrToArg<R>::encode(p_method(p_instance, PtrToArg<P>::convert(p_args[Is])...), r_ret); @@ -273,6 +278,11 @@ void call_with_validated_variant_args_static_retc_helper(T *p_instance, R (*p_me VariantInternalAccessor<typename GetSimpleTypeT<R>::type_t>::set(r_ret, p_method(p_instance, (VariantInternalAccessor<typename GetSimpleTypeT<P>::type_t>::get(p_args[Is]))...)); } +template <class T, class... P, size_t... Is> +void call_with_validated_variant_args_static_helper(T *p_instance, void (*p_method)(T *, P...), const Variant **p_args, IndexSequence<Is...>) { + p_method(p_instance, (VariantInternalAccessor<typename GetSimpleTypeT<P>::type_t>::get(p_args[Is]))...); +} + template <class R, class... P, size_t... Is> void call_with_validated_variant_args_static_method_ret_helper(R (*p_method)(P...), const Variant **p_args, Variant *r_ret, IndexSequence<Is...>) { VariantInternalAccessor<typename GetSimpleTypeT<R>::type_t>::set(r_ret, p_method((VariantInternalAccessor<typename GetSimpleTypeT<P>::type_t>::get(p_args[Is]))...)); @@ -471,6 +481,11 @@ void call_with_ptr_args_retc(T *p_instance, R (T::*p_method)(P...) const, const call_with_ptr_args_retc_helper<T, R, P...>(p_instance, p_method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{}); } +template <class T, class... P> +void call_with_ptr_args_static(T *p_instance, void (*p_method)(T *, P...), const void **p_args) { + call_with_ptr_args_static_helper<T, P...>(p_instance, p_method, p_args, BuildIndexSequence<sizeof...(P)>{}); +} + template <class T, class R, class... P> void call_with_ptr_args_static_retc(T *p_instance, R (*p_method)(T *, P...), const void **p_args, void *r_ret) { call_with_ptr_args_static_retc_helper<T, R, P...>(p_instance, p_method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{}); @@ -501,6 +516,11 @@ void call_with_validated_variant_args_retc(Variant *base, R (T::*p_method)(P...) call_with_validated_variant_args_retc_helper<T, R, P...>(VariantGetInternalPtr<T>::get_ptr(base), p_method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{}); } +template <class T, class... P> +void call_with_validated_variant_args_static(Variant *base, void (*p_method)(T *, P...), const Variant **p_args) { + call_with_validated_variant_args_static_helper<T, P...>(VariantGetInternalPtr<T>::get_ptr(base), p_method, p_args, BuildIndexSequence<sizeof...(P)>{}); +} + template <class T, class R, class... P> void call_with_validated_variant_args_static_retc(Variant *base, R (*p_method)(T *, P...), const Variant **p_args, Variant *r_ret) { call_with_validated_variant_args_static_retc_helper<T, R, P...>(VariantGetInternalPtr<T>::get_ptr(base), p_method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{}); @@ -758,6 +778,52 @@ void call_with_variant_args_retc_static_helper_dv(T *p_instance, R (*p_method)(T call_with_variant_args_retc_static_helper(p_instance, p_method, args, r_ret, r_error, BuildIndexSequence<sizeof...(P)>{}); } +template <class T, class... P, size_t... Is> +void call_with_variant_args_static_helper(T *p_instance, void (*p_method)(T *, P...), const Variant **p_args, Callable::CallError &r_error, IndexSequence<Is...>) { + r_error.error = Callable::CallError::CALL_OK; + +#ifdef DEBUG_METHODS_ENABLED + (p_method)(p_instance, VariantCasterAndValidate<P>::cast(p_args, Is, r_error)...); +#else + (p_method)(p_instance, VariantCaster<P>::cast(*p_args[Is])...); +#endif + + (void)p_args; +} + +template <class T, class... P> +void call_with_variant_args_static_helper_dv(T *p_instance, void (*p_method)(T *, P...), const Variant **p_args, int p_argcount, const Vector<Variant> &default_values, Callable::CallError &r_error) { +#ifdef DEBUG_ENABLED + if ((size_t)p_argcount > sizeof...(P)) { + r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS; + r_error.argument = sizeof...(P); + return; + } +#endif + + int32_t missing = (int32_t)sizeof...(P) - (int32_t)p_argcount; + + int32_t dvs = default_values.size(); +#ifdef DEBUG_ENABLED + if (missing > dvs) { + r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; + r_error.argument = sizeof...(P); + return; + } +#endif + + const Variant *args[sizeof...(P) == 0 ? 1 : sizeof...(P)]; //avoid zero sized array + for (int32_t i = 0; i < (int32_t)sizeof...(P); i++) { + if (i < p_argcount) { + args[i] = p_args[i]; + } else { + args[i] = &default_values[i - p_argcount + (dvs - missing)]; + } + } + + call_with_variant_args_static_helper(p_instance, p_method, args, r_error, BuildIndexSequence<sizeof...(P)>{}); +} + template <class R, class... P> void call_with_variant_args_static_ret_dv(R (*p_method)(P...), const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error, const Vector<Variant> &default_values) { #ifdef DEBUG_ENABLED diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp index 8c1d8066d6..61f3f7d82e 100644 --- a/core/variant/variant_call.cpp +++ b/core/variant/variant_call.cpp @@ -34,6 +34,7 @@ #include "core/crypto/crypto_core.h" #include "core/debugger/engine_debugger.h" #include "core/io/compression.h" +#include "core/io/marshalls.h" #include "core/object/class_db.h" #include "core/os/os.h" #include "core/templates/local_vector.h" @@ -73,6 +74,16 @@ static _FORCE_INLINE_ void vc_method_call(void (T::*method)(P...) const, Variant } template <class R, class T, class... P> +static _FORCE_INLINE_ void vc_method_call_static(R (*method)(T *, P...), Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { + call_with_variant_args_retc_static_helper_dv(VariantGetInternalPtr<T>::get_ptr(base), method, p_args, p_argcount, r_ret, p_defvals, r_error); +} + +template <class T, class... P> +static _FORCE_INLINE_ void vc_method_call_static(void (*method)(T *, P...), Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { + call_with_variant_args_static_helper_dv(VariantGetInternalPtr<T>::get_ptr(base), method, p_args, p_argcount, p_defvals, r_error); +} + +template <class R, class T, class... P> static _FORCE_INLINE_ void vc_validated_call(R (T::*method)(P...), Variant *base, const Variant **p_args, Variant *r_ret) { call_with_validated_variant_args_ret(base, method, p_args, r_ret); } @@ -91,6 +102,16 @@ static _FORCE_INLINE_ void vc_validated_call(void (T::*method)(P...) const, Vari call_with_validated_variant_argsc(base, method, p_args); } +template <class R, class T, class... P> +static _FORCE_INLINE_ void vc_validated_call_static(R (*method)(T *, P...), Variant *base, const Variant **p_args, Variant *r_ret) { + call_with_validated_variant_args_static_retc(base, method, p_args, r_ret); +} + +template <class T, class... P> +static _FORCE_INLINE_ void vc_validated_call_static(void (*method)(T *, P...), Variant *base, const Variant **p_args, Variant *r_ret) { + call_with_validated_variant_args_static(base, method, p_args); +} + template <class R, class... P> static _FORCE_INLINE_ void vc_validated_static_call(R (*method)(P...), const Variant **p_args, Variant *r_ret) { call_with_validated_variant_args_static_method_ret(method, p_args, r_ret); @@ -146,6 +167,11 @@ static _FORCE_INLINE_ void vc_change_return_type(R (*method)(P...), Variant *v) VariantTypeAdjust<R>::adjust(v); } +template <class... P> +static _FORCE_INLINE_ void vc_change_return_type(void (*method)(P...), Variant *v) { + VariantInternal::clear(v); +} + template <class R, class T, class... P> static _FORCE_INLINE_ int vc_get_argument_count(R (T::*method)(P...)) { return sizeof...(P); @@ -229,6 +255,11 @@ static _FORCE_INLINE_ Variant::Type vc_get_return_type(R (*method)(P...)) { return GetTypeInfo<R>::VARIANT_TYPE; } +template <class... P> +static _FORCE_INLINE_ Variant::Type vc_get_return_type(void (*method)(P...)) { + return Variant::NIL; +} + template <class R, class T, class... P> static _FORCE_INLINE_ bool vc_has_return_type(R (T::*method)(P...)) { return true; @@ -393,45 +424,50 @@ static _FORCE_INLINE_ void vc_ptrcall(R (*method)(T *, P...), void *p_base, cons call_with_ptr_args_static_retc<T, R, P...>(reinterpret_cast<T *>(p_base), method, p_args, r_ret); } -#define FUNCTION_CLASS(m_class, m_method_name, m_method_ptr) \ - struct Method_##m_class##_##m_method_name { \ - static void call(Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { \ - call_with_variant_args_retc_static_helper_dv(VariantGetInternalPtr<m_class>::get_ptr(base), m_method_ptr, p_args, p_argcount, r_ret, p_defvals, r_error); \ - } \ - static void validated_call(Variant *base, const Variant **p_args, int p_argcount, Variant *r_ret) { \ - vc_change_return_type(m_method_ptr, r_ret); \ - call_with_validated_variant_args_static_retc(base, m_method_ptr, p_args, r_ret); \ - } \ - static void ptrcall(void *p_base, const void **p_args, void *r_ret, int p_argcount) { \ - vc_ptrcall(m_method_ptr, p_base, p_args, r_ret); \ - } \ - static int get_argument_count() { \ - return vc_get_argument_count(m_method_ptr); \ - } \ - static Variant::Type get_argument_type(int p_arg) { \ - return vc_get_argument_type(m_method_ptr, p_arg); \ - } \ - static Variant::Type get_return_type() { \ - return vc_get_return_type(m_method_ptr); \ - } \ - static bool has_return_type() { \ - return true; \ - } \ - static bool is_const() { \ - return true; \ - } \ - static bool is_static() { \ - return false; \ - } \ - static bool is_vararg() { \ - return false; \ - } \ - static Variant::Type get_base_type() { \ - return GetTypeInfo<m_class>::VARIANT_TYPE; \ - } \ - static StringName get_name() { \ - return #m_method_name; \ - } \ +template <class T, class... P> +static _FORCE_INLINE_ void vc_ptrcall(void (*method)(T *, P...), void *p_base, const void **p_args, void *r_ret) { + call_with_ptr_args_static<T, P...>(reinterpret_cast<T *>(p_base), method, p_args); +} + +#define FUNCTION_CLASS(m_class, m_method_name, m_method_ptr, m_const) \ + struct Method_##m_class##_##m_method_name { \ + static void call(Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { \ + vc_method_call_static(m_method_ptr, base, p_args, p_argcount, r_ret, p_defvals, r_error); \ + } \ + static void validated_call(Variant *base, const Variant **p_args, int p_argcount, Variant *r_ret) { \ + vc_change_return_type(m_method_ptr, r_ret); \ + vc_validated_call_static(m_method_ptr, base, p_args, r_ret); \ + } \ + static void ptrcall(void *p_base, const void **p_args, void *r_ret, int p_argcount) { \ + vc_ptrcall(m_method_ptr, p_base, p_args, r_ret); \ + } \ + static int get_argument_count() { \ + return vc_get_argument_count(m_method_ptr); \ + } \ + static Variant::Type get_argument_type(int p_arg) { \ + return vc_get_argument_type(m_method_ptr, p_arg); \ + } \ + static Variant::Type get_return_type() { \ + return vc_get_return_type(m_method_ptr); \ + } \ + static bool has_return_type() { \ + return vc_has_return_type_static(m_method_ptr); \ + } \ + static bool is_const() { \ + return m_const; \ + } \ + static bool is_static() { \ + return false; \ + } \ + static bool is_vararg() { \ + return false; \ + } \ + static Variant::Type get_base_type() { \ + return GetTypeInfo<m_class>::VARIANT_TYPE; \ + } \ + static StringName get_name() { \ + return #m_method_name; \ + } \ }; #define VARARG_CLASS(m_class, m_method_name, m_method_ptr, m_has_return, m_return_type) \ @@ -590,6 +626,195 @@ struct _VariantCall { return s; } + static int64_t func_PackedByteArray_decode_u8(PackedByteArray *p_instance, int64_t p_offset) { + uint64_t size = p_instance->size(); + ERR_FAIL_COND_V(p_offset < 0 || p_offset > int64_t(size) - 1, 0); + const uint8_t *r = p_instance->ptr(); + return r[p_offset]; + } + static int64_t func_PackedByteArray_decode_s8(PackedByteArray *p_instance, int64_t p_offset) { + uint64_t size = p_instance->size(); + ERR_FAIL_COND_V(p_offset < 0 || p_offset > int64_t(size) - 1, 0); + const uint8_t *r = p_instance->ptr(); + return *((const int8_t *)&r[p_offset]); + } + static int64_t func_PackedByteArray_decode_u16(PackedByteArray *p_instance, int64_t p_offset) { + uint64_t size = p_instance->size(); + ERR_FAIL_COND_V(p_offset < 0 || p_offset > (int64_t(size) - 2), 0); + const uint8_t *r = p_instance->ptr(); + return decode_uint16(&r[p_offset]); + } + static int64_t func_PackedByteArray_decode_s16(PackedByteArray *p_instance, int64_t p_offset) { + uint64_t size = p_instance->size(); + ERR_FAIL_COND_V(p_offset < 0 || p_offset > (int64_t(size) - 2), 0); + const uint8_t *r = p_instance->ptr(); + return (int16_t)decode_uint16(&r[p_offset]); + } + static int64_t func_PackedByteArray_decode_u32(PackedByteArray *p_instance, int64_t p_offset) { + uint64_t size = p_instance->size(); + ERR_FAIL_COND_V(p_offset < 0 || p_offset > (int64_t(size) - 4), 0); + const uint8_t *r = p_instance->ptr(); + return decode_uint32(&r[p_offset]); + } + static int64_t func_PackedByteArray_decode_s32(PackedByteArray *p_instance, int64_t p_offset) { + uint64_t size = p_instance->size(); + ERR_FAIL_COND_V(p_offset < 0 || p_offset > (int64_t(size) - 4), 0); + const uint8_t *r = p_instance->ptr(); + return (int32_t)decode_uint32(&r[p_offset]); + } + static int64_t func_PackedByteArray_decode_u64(PackedByteArray *p_instance, int64_t p_offset) { + uint64_t size = p_instance->size(); + ERR_FAIL_COND_V(p_offset < 0 || p_offset > (int64_t(size) - 8), 0); + const uint8_t *r = p_instance->ptr(); + return (int64_t)decode_uint64(&r[p_offset]); + } + static int64_t func_PackedByteArray_decode_s64(PackedByteArray *p_instance, int64_t p_offset) { + uint64_t size = p_instance->size(); + ERR_FAIL_COND_V(p_offset < 0 || p_offset > (int64_t(size) - 8), 0); + const uint8_t *r = p_instance->ptr(); + return (int64_t)decode_uint64(&r[p_offset]); + } + static double func_PackedByteArray_decode_half(PackedByteArray *p_instance, int64_t p_offset) { + uint64_t size = p_instance->size(); + ERR_FAIL_COND_V(p_offset < 0 || p_offset > (int64_t(size) - 2), 0); + const uint8_t *r = p_instance->ptr(); + return Math::half_to_float(decode_uint16(&r[p_offset])); + } + static double func_PackedByteArray_decode_float(PackedByteArray *p_instance, int64_t p_offset) { + uint64_t size = p_instance->size(); + ERR_FAIL_COND_V(p_offset < 0 || p_offset > (int64_t(size) - 4), 0); + const uint8_t *r = p_instance->ptr(); + return decode_float(&r[p_offset]); + } + + static double func_PackedByteArray_decode_double(PackedByteArray *p_instance, int64_t p_offset) { + uint64_t size = p_instance->size(); + ERR_FAIL_COND_V(p_offset < 0 || p_offset > (int64_t(size) - 8), 0); + const uint8_t *r = p_instance->ptr(); + return decode_double(&r[p_offset]); + } + + static bool func_PackedByteArray_has_encoded_var(PackedByteArray *p_instance, int64_t p_offset, bool p_allow_objects) { + uint64_t size = p_instance->size(); + ERR_FAIL_COND_V(p_offset < 0, false); + const uint8_t *r = p_instance->ptr(); + Variant ret; + Error err = decode_variant(ret, r + p_offset, size - p_offset, nullptr, p_allow_objects); + return err == OK; + } + + static Variant func_PackedByteArray_decode_var(PackedByteArray *p_instance, int64_t p_offset, bool p_allow_objects) { + uint64_t size = p_instance->size(); + ERR_FAIL_COND_V(p_offset < 0, Variant()); + const uint8_t *r = p_instance->ptr(); + Variant ret; + Error err = decode_variant(ret, r + p_offset, size - p_offset, nullptr, p_allow_objects); + if (err != OK) { + ret = Variant(); + } + return ret; + } + + static int64_t func_PackedByteArray_decode_var_size(PackedByteArray *p_instance, int64_t p_offset, bool p_allow_objects) { + uint64_t size = p_instance->size(); + ERR_FAIL_COND_V(p_offset < 0, 0); + const uint8_t *r = p_instance->ptr(); + Variant ret; + int r_size; + Error err = decode_variant(ret, r + p_offset, size - p_offset, &r_size, p_allow_objects); + if (err == OK) { + return r_size; + } + return 0; + } + + static void func_PackedByteArray_encode_u8(PackedByteArray *p_instance, int64_t p_offset, int64_t p_value) { + uint64_t size = p_instance->size(); + ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(size) - 1); + uint8_t *w = p_instance->ptrw(); + *((uint8_t *)&w[p_offset]) = p_value; + } + static void func_PackedByteArray_encode_s8(PackedByteArray *p_instance, int64_t p_offset, int64_t p_value) { + uint64_t size = p_instance->size(); + ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(size) - 1); + uint8_t *w = p_instance->ptrw(); + *((int8_t *)&w[p_offset]) = p_value; + } + + static void func_PackedByteArray_encode_u16(PackedByteArray *p_instance, int64_t p_offset, int64_t p_value) { + uint64_t size = p_instance->size(); + ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(size) - 2); + uint8_t *w = p_instance->ptrw(); + encode_uint16((uint16_t)p_value, &w[p_offset]); + } + static void func_PackedByteArray_encode_s16(PackedByteArray *p_instance, int64_t p_offset, int64_t p_value) { + uint64_t size = p_instance->size(); + ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(size) - 2); + uint8_t *w = p_instance->ptrw(); + encode_uint16((int16_t)p_value, &w[p_offset]); + } + + static void func_PackedByteArray_encode_u32(PackedByteArray *p_instance, int64_t p_offset, int64_t p_value) { + uint64_t size = p_instance->size(); + ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(size) - 4); + uint8_t *w = p_instance->ptrw(); + encode_uint32((uint32_t)p_value, &w[p_offset]); + } + static void func_PackedByteArray_encode_s32(PackedByteArray *p_instance, int64_t p_offset, int64_t p_value) { + uint64_t size = p_instance->size(); + ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(size) - 4); + uint8_t *w = p_instance->ptrw(); + encode_uint32((int32_t)p_value, &w[p_offset]); + } + + static void func_PackedByteArray_encode_u64(PackedByteArray *p_instance, int64_t p_offset, int64_t p_value) { + uint64_t size = p_instance->size(); + ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(size) - 8); + uint8_t *w = p_instance->ptrw(); + encode_uint64((uint64_t)p_value, &w[p_offset]); + } + static void func_PackedByteArray_encode_s64(PackedByteArray *p_instance, int64_t p_offset, int64_t p_value) { + uint64_t size = p_instance->size(); + ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(size) - 8); + uint8_t *w = p_instance->ptrw(); + encode_uint64((int64_t)p_value, &w[p_offset]); + } + + static void func_PackedByteArray_encode_half(PackedByteArray *p_instance, int64_t p_offset, double p_value) { + uint64_t size = p_instance->size(); + ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(size) - 2); + uint8_t *w = p_instance->ptrw(); + encode_uint16(Math::make_half_float(p_value), &w[p_offset]); + } + static void func_PackedByteArray_encode_float(PackedByteArray *p_instance, int64_t p_offset, double p_value) { + uint64_t size = p_instance->size(); + ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(size) - 4); + uint8_t *w = p_instance->ptrw(); + encode_float(p_value, &w[p_offset]); + } + static void func_PackedByteArray_encode_double(PackedByteArray *p_instance, int64_t p_offset, double p_value) { + uint64_t size = p_instance->size(); + ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(size) - 8); + uint8_t *w = p_instance->ptrw(); + encode_double(p_value, &w[p_offset]); + } + static int64_t func_PackedByteArray_encode_var(PackedByteArray *p_instance, int64_t p_offset, const Variant &p_value, bool p_allow_objects) { + uint64_t size = p_instance->size(); + ERR_FAIL_COND_V(p_offset < 0, -1); + uint8_t *w = p_instance->ptrw(); + int len; + Error err = encode_variant(p_value, nullptr, len, p_allow_objects); + if (err != OK) { + return -1; + } + if (uint64_t(p_offset + len) > size) { + return -1; // did not fit + } + encode_variant(p_value, w + p_offset, len, p_allow_objects); + + return len; + } + static void func_Callable_call(Variant *v, const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error) { Callable *callable = VariantGetInternalPtr<Callable>::get_ptr(v); callable->call(p_args, p_argcount, r_ret, r_error); @@ -1005,11 +1230,21 @@ Variant Variant::get_constant_value(Variant::Type p_type, const StringName &p_va #ifdef DEBUG_METHODS_ENABLED #define bind_function(m_type, m_name, m_method, m_arg_names, m_default_args) \ - FUNCTION_CLASS(m_type, m_name, m_method); \ + FUNCTION_CLASS(m_type, m_name, m_method, true); \ register_builtin_method<Method_##m_type##_##m_name>(m_arg_names, m_default_args); #else #define bind_function(m_type, m_name, m_method, m_arg_names, m_default_args) \ - FUNCTION_CLASS(m_type, m_name, m_method); \ + FUNCTION_CLASS(m_type, m_name, m_method, true); \ + register_builtin_method<Method_##m_type##_##m_name>(sarray(), m_default_args); +#endif + +#ifdef DEBUG_METHODS_ENABLED +#define bind_functionnc(m_type, m_name, m_method, m_arg_names, m_default_args) \ + FUNCTION_CLASS(m_type, m_name, m_method, false); \ + register_builtin_method<Method_##m_type##_##m_name>(m_arg_names, m_default_args); +#else +#define bind_functionnc(m_type, m_name, m_method, m_arg_names, m_default_args) \ + FUNCTION_CLASS(m_type, m_name, m_method, false); \ register_builtin_method<Method_##m_type##_##m_name>(sarray(), m_default_args); #endif @@ -1460,7 +1695,7 @@ static void _register_variant_builtin_methods() { bind_method(Array, shuffle, sarray(), varray()); bind_method(Array, bsearch, sarray("value", "before"), varray(true)); bind_method(Array, bsearch_custom, sarray("value", "func", "before"), varray(true)); - bind_method(Array, invert, sarray(), varray()); + bind_method(Array, reverse, sarray(), varray()); bind_method(Array, duplicate, sarray("deep"), varray(false)); bind_method(Array, slice, sarray("begin", "end", "step", "deep"), varray(1, false)); bind_method(Array, max, sarray(), varray()); @@ -1477,7 +1712,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedByteArray, insert, sarray("at_index", "value"), varray()); bind_method(PackedByteArray, resize, sarray("new_size"), varray()); bind_method(PackedByteArray, has, sarray("value"), varray()); - bind_method(PackedByteArray, invert, sarray(), varray()); + bind_method(PackedByteArray, reverse, sarray(), varray()); bind_method(PackedByteArray, subarray, sarray("from", "to"), varray()); bind_method(PackedByteArray, sort, sarray(), varray()); bind_method(PackedByteArray, duplicate, sarray(), varray()); @@ -1491,6 +1726,34 @@ static void _register_variant_builtin_methods() { bind_function(PackedByteArray, decompress, _VariantCall::func_PackedByteArray_decompress, sarray("buffer_size", "compression_mode"), varray(0)); bind_function(PackedByteArray, decompress_dynamic, _VariantCall::func_PackedByteArray_decompress_dynamic, sarray("max_output_size", "compression_mode"), varray(0)); + bind_function(PackedByteArray, decode_u8, _VariantCall::func_PackedByteArray_decode_u8, sarray("byte_offset"), varray()); + bind_function(PackedByteArray, decode_s8, _VariantCall::func_PackedByteArray_decode_s8, sarray("byte_offset"), varray()); + bind_function(PackedByteArray, decode_u16, _VariantCall::func_PackedByteArray_decode_u16, sarray("byte_offset"), varray()); + bind_function(PackedByteArray, decode_s16, _VariantCall::func_PackedByteArray_decode_s16, sarray("byte_offset"), varray()); + bind_function(PackedByteArray, decode_u32, _VariantCall::func_PackedByteArray_decode_u32, sarray("byte_offset"), varray()); + bind_function(PackedByteArray, decode_s32, _VariantCall::func_PackedByteArray_decode_s32, sarray("byte_offset"), varray()); + bind_function(PackedByteArray, decode_u64, _VariantCall::func_PackedByteArray_decode_u64, sarray("byte_offset"), varray()); + bind_function(PackedByteArray, decode_s64, _VariantCall::func_PackedByteArray_decode_s64, sarray("byte_offset"), varray()); + bind_function(PackedByteArray, decode_half, _VariantCall::func_PackedByteArray_decode_half, sarray("byte_offset"), varray()); + bind_function(PackedByteArray, decode_float, _VariantCall::func_PackedByteArray_decode_float, sarray("byte_offset"), varray()); + bind_function(PackedByteArray, decode_double, _VariantCall::func_PackedByteArray_decode_double, sarray("byte_offset"), varray()); + bind_function(PackedByteArray, has_encoded_var, _VariantCall::func_PackedByteArray_has_encoded_var, sarray("byte_offset", "allow_objects"), varray(false)); + bind_function(PackedByteArray, decode_var, _VariantCall::func_PackedByteArray_decode_var, sarray("byte_offset", "allow_objects"), varray(false)); + bind_function(PackedByteArray, decode_var_size, _VariantCall::func_PackedByteArray_decode_var_size, sarray("byte_offset", "allow_objects"), varray(false)); + + bind_functionnc(PackedByteArray, encode_u8, _VariantCall::func_PackedByteArray_encode_u8, sarray("byte_offset", "value"), varray()); + bind_functionnc(PackedByteArray, encode_s8, _VariantCall::func_PackedByteArray_encode_s8, sarray("byte_offset", "value"), varray()); + bind_functionnc(PackedByteArray, encode_u16, _VariantCall::func_PackedByteArray_encode_u16, sarray("byte_offset", "value"), varray()); + bind_functionnc(PackedByteArray, encode_s16, _VariantCall::func_PackedByteArray_encode_s16, sarray("byte_offset", "value"), varray()); + bind_functionnc(PackedByteArray, encode_u32, _VariantCall::func_PackedByteArray_encode_u32, sarray("byte_offset", "value"), varray()); + bind_functionnc(PackedByteArray, encode_s32, _VariantCall::func_PackedByteArray_encode_s32, sarray("byte_offset", "value"), varray()); + bind_functionnc(PackedByteArray, encode_u64, _VariantCall::func_PackedByteArray_encode_u64, sarray("byte_offset", "value"), varray()); + bind_functionnc(PackedByteArray, encode_s64, _VariantCall::func_PackedByteArray_encode_s64, sarray("byte_offset", "value"), varray()); + bind_functionnc(PackedByteArray, encode_half, _VariantCall::func_PackedByteArray_encode_half, sarray("byte_offset", "value"), varray()); + bind_functionnc(PackedByteArray, encode_float, _VariantCall::func_PackedByteArray_encode_float, sarray("byte_offset", "value"), varray()); + bind_functionnc(PackedByteArray, encode_double, _VariantCall::func_PackedByteArray_encode_double, sarray("byte_offset", "value"), varray()); + bind_functionnc(PackedByteArray, encode_var, _VariantCall::func_PackedByteArray_encode_var, sarray("byte_offset", "value", "allow_objects"), varray(false)); + /* Int32 Array */ bind_method(PackedInt32Array, size, sarray(), varray()); @@ -1503,7 +1766,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedInt32Array, insert, sarray("at_index", "value"), varray()); bind_method(PackedInt32Array, resize, sarray("new_size"), varray()); bind_method(PackedInt32Array, has, sarray("value"), varray()); - bind_method(PackedInt32Array, invert, sarray(), varray()); + bind_method(PackedInt32Array, reverse, sarray(), varray()); bind_method(PackedInt32Array, subarray, sarray("from", "to"), varray()); bind_method(PackedInt32Array, to_byte_array, sarray(), varray()); bind_method(PackedInt32Array, sort, sarray(), varray()); @@ -1521,7 +1784,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedInt64Array, insert, sarray("at_index", "value"), varray()); bind_method(PackedInt64Array, resize, sarray("new_size"), varray()); bind_method(PackedInt64Array, has, sarray("value"), varray()); - bind_method(PackedInt64Array, invert, sarray(), varray()); + bind_method(PackedInt64Array, reverse, sarray(), varray()); bind_method(PackedInt64Array, subarray, sarray("from", "to"), varray()); bind_method(PackedInt64Array, to_byte_array, sarray(), varray()); bind_method(PackedInt64Array, sort, sarray(), varray()); @@ -1539,7 +1802,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedFloat32Array, insert, sarray("at_index", "value"), varray()); bind_method(PackedFloat32Array, resize, sarray("new_size"), varray()); bind_method(PackedFloat32Array, has, sarray("value"), varray()); - bind_method(PackedFloat32Array, invert, sarray(), varray()); + bind_method(PackedFloat32Array, reverse, sarray(), varray()); bind_method(PackedFloat32Array, subarray, sarray("from", "to"), varray()); bind_method(PackedFloat32Array, to_byte_array, sarray(), varray()); bind_method(PackedFloat32Array, sort, sarray(), varray()); @@ -1557,7 +1820,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedFloat64Array, insert, sarray("at_index", "value"), varray()); bind_method(PackedFloat64Array, resize, sarray("new_size"), varray()); bind_method(PackedFloat64Array, has, sarray("value"), varray()); - bind_method(PackedFloat64Array, invert, sarray(), varray()); + bind_method(PackedFloat64Array, reverse, sarray(), varray()); bind_method(PackedFloat64Array, subarray, sarray("from", "to"), varray()); bind_method(PackedFloat64Array, to_byte_array, sarray(), varray()); bind_method(PackedFloat64Array, sort, sarray(), varray()); @@ -1575,7 +1838,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedStringArray, insert, sarray("at_index", "value"), varray()); bind_method(PackedStringArray, resize, sarray("new_size"), varray()); bind_method(PackedStringArray, has, sarray("value"), varray()); - bind_method(PackedStringArray, invert, sarray(), varray()); + bind_method(PackedStringArray, reverse, sarray(), varray()); bind_method(PackedStringArray, subarray, sarray("from", "to"), varray()); bind_method(PackedStringArray, to_byte_array, sarray(), varray()); bind_method(PackedStringArray, sort, sarray(), varray()); @@ -1593,7 +1856,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedVector2Array, insert, sarray("at_index", "value"), varray()); bind_method(PackedVector2Array, resize, sarray("new_size"), varray()); bind_method(PackedVector2Array, has, sarray("value"), varray()); - bind_method(PackedVector2Array, invert, sarray(), varray()); + bind_method(PackedVector2Array, reverse, sarray(), varray()); bind_method(PackedVector2Array, subarray, sarray("from", "to"), varray()); bind_method(PackedVector2Array, to_byte_array, sarray(), varray()); bind_method(PackedVector2Array, sort, sarray(), varray()); @@ -1611,7 +1874,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedVector3Array, insert, sarray("at_index", "value"), varray()); bind_method(PackedVector3Array, resize, sarray("new_size"), varray()); bind_method(PackedVector3Array, has, sarray("value"), varray()); - bind_method(PackedVector3Array, invert, sarray(), varray()); + bind_method(PackedVector3Array, reverse, sarray(), varray()); bind_method(PackedVector3Array, subarray, sarray("from", "to"), varray()); bind_method(PackedVector3Array, to_byte_array, sarray(), varray()); bind_method(PackedVector3Array, sort, sarray(), varray()); @@ -1629,7 +1892,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedColorArray, insert, sarray("at_index", "value"), varray()); bind_method(PackedColorArray, resize, sarray("new_size"), varray()); bind_method(PackedColorArray, has, sarray("value"), varray()); - bind_method(PackedColorArray, invert, sarray(), varray()); + bind_method(PackedColorArray, reverse, sarray(), varray()); bind_method(PackedColorArray, subarray, sarray("from", "to"), varray()); bind_method(PackedColorArray, to_byte_array, sarray(), varray()); bind_method(PackedColorArray, sort, sarray(), varray()); diff --git a/core/variant/variant_setget.cpp b/core/variant/variant_setget.cpp index b86ae3ebb2..f319631ce5 100644 --- a/core/variant/variant_setget.cpp +++ b/core/variant/variant_setget.cpp @@ -891,8 +891,9 @@ struct VariantIndexedSetGet_Array { static void ptr_get(const void *base, int64_t index, void *member) { /* avoid ptrconvert for performance*/ const Array &v = *reinterpret_cast<const Array *>(base); - if (index < 0) + if (index < 0) { index += v.size(); + } OOB_TEST(index, v.size()); PtrToArg<Variant>::encode(v[index], member); } @@ -925,8 +926,9 @@ struct VariantIndexedSetGet_Array { static void ptr_set(void *base, int64_t index, const void *member) { /* avoid ptrconvert for performance*/ Array &v = *reinterpret_cast<Array *>(base); - if (index < 0) + if (index < 0) { index += v.size(); + } OOB_TEST(index, v.size()); v.set(index, PtrToArg<Variant>::convert(member)); } |