Compare commits
976 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b7a00df980 | |||
| 362774c617 | |||
| 040254ef7c | |||
| 7bfb7df673 | |||
| ffa4e3fa7d | |||
| fe3d7ba5b0 | |||
| 5bfb10f585 | |||
| e647b5b73c | |||
| f7eed5166b | |||
| 5b28699eba | |||
| 1ca01acfe4 | |||
| 8c73f79492 | |||
| 21596fb992 | |||
| f6ab796bf3 | |||
| 25007bdb61 | |||
| 104b06e967 | |||
| 9864066ec6 | |||
| 2fa9cae76c | |||
| 0ce197f238 | |||
| 7fb435f787 | |||
| 82e52c32a6 | |||
| 2d386ec2fa | |||
| 68ce59a12d | |||
| 84a227b663 | |||
| 455d1d3a7e | |||
| 5385f52486 | |||
| 38f1a2c5dd | |||
| 56b5af2ba7 | |||
| 1b05404dbf | |||
| 41fe1bd887 | |||
| 6aaca81d2b | |||
| 0621d2a28c | |||
| 3b5837e4d9 | |||
| b87d819aad | |||
| d092798038 | |||
| 57e19f1e8c | |||
| b896eb5fd4 | |||
| 3600735b24 | |||
| 0c4881f1db | |||
| 57a03a051f | |||
| bcbc198992 | |||
| ad8f85f8b7 | |||
| 6604638d82 | |||
| 816366ba05 | |||
| d9992a2b78 | |||
| c27f44f525 | |||
| 95fe095a5a | |||
| 0b4dec63a9 | |||
| 733668074a | |||
| 41cda84b11 | |||
| d127f92bd5 | |||
| 0f2e3976d0 | |||
| aca8176341 | |||
| 633ac4f753 | |||
| 2ff2b727b6 | |||
| c2541188f2 | |||
| 8718f898c1 | |||
| 194ed96e89 | |||
| 740e77f47f | |||
| 0195619925 | |||
| cada03eedb | |||
| c6cc6c86e5 | |||
| cf2ebf5d47 | |||
| 49d724ac52 | |||
| 69673367a1 | |||
| c42cacfc3d | |||
| fc38c87030 | |||
| 58c87e5d26 | |||
| dafdd9a08e | |||
| a2381b9049 | |||
| b680939036 | |||
| 94476aba94 | |||
| a1b0e7b12c | |||
| 08fd792c45 | |||
| 02585688cd | |||
| 4d610757af | |||
| 0b2a884fe2 | |||
| f666a5f34a | |||
| a110937a16 | |||
| 811b11c452 | |||
| 9e91d4e5cb | |||
| 0f5538e44d | |||
| e689fe0451 | |||
| c658929cf3 | |||
| 53f484fbba | |||
| 9776f0da4d | |||
| 6392a7d7f1 | |||
| 6dcb5f5ed9 | |||
| 1a703c3254 | |||
| a7d070d2d5 | |||
| 8ce8a45219 | |||
| b9ee398cbc | |||
| 661885dbd8 | |||
| 251282d2cf | |||
| 2e86a5f929 | |||
| a3753eda62 | |||
| 049c91f4d1 | |||
| 7ac73098fc | |||
| a2dae3379d | |||
| 6be8a83584 | |||
| c3ac242181 | |||
| 2a66cfc2d0 | |||
| 0da50fecbf | |||
| 61b6c9c348 | |||
| 7957a7bd2e | |||
| 5955526b25 | |||
| 681c22375b | |||
| 3b89c2be89 | |||
| ebe8bcd0cf | |||
| 37bb769470 | |||
| 73fa1470b3 | |||
| 75f1731232 | |||
| 7624e1009a | |||
| 7586957720 | |||
| 68d09255bd | |||
| e4733c5fc4 | |||
| 5e25f40d83 | |||
| f7aaf161fb | |||
| 2e34a922f0 | |||
| d3b67bde8a | |||
| 771f1fe5c1 | |||
| 209c6164f4 | |||
| 92fb290f69 | |||
| d2bf31bdad | |||
| ff35310650 | |||
| 005d1c8901 | |||
| 112075b3ad | |||
| 5c69f83c96 | |||
| 754514df7e | |||
| 0572b52ba1 | |||
| f302888a47 | |||
| 392d988228 | |||
| c68a465f47 | |||
| fd5dca2689 | |||
| 47c7bfd678 | |||
| 854fc3cb97 | |||
| 33a93311ec | |||
| b890ed527b | |||
| 4b69ed4124 | |||
| 493e220ab9 | |||
| 16e6d6fede | |||
| b1bb7e48ca | |||
| f4db382c50 | |||
| f17983e9cf | |||
| dae30964a2 | |||
| f27c989829 | |||
| 042a74a696 | |||
| 56a82b473e | |||
| deef878f6f | |||
| fab378abf5 | |||
| a41f7579c8 | |||
| 3808544891 | |||
| 69f08cd2cc | |||
| 2107517f2f | |||
| 82e54db588 | |||
| 793a205ae1 | |||
| a5a9d887da | |||
| 12458ebe8c | |||
| 367bec2010 | |||
| f85b2a62f7 | |||
| 13a90fdd89 | |||
| 761bfb156d | |||
| 46f091bfcb | |||
| d1c93a0af3 | |||
| 9d006730ad | |||
| e867befd46 | |||
| fdbef334bb | |||
| dfb839ebce | |||
| 6c9bddef53 | |||
| cc8e1e93c3 | |||
| 3fcdb3198b | |||
| 3d5c5c28d5 | |||
| ac1520325c | |||
| 5a89810238 | |||
| b977e8ab0c | |||
| 2ccca78929 | |||
| 768f5fd1ac | |||
| 3066616e1a | |||
| 197ea38552 | |||
| 67a72a2759 | |||
| 64a7a6b2f4 | |||
| adb9815199 | |||
| 3daca13f72 | |||
| 68148b16d3 | |||
| 1fae776445 | |||
| 413f4db585 | |||
| c85d2d7420 | |||
| e284ea344d | |||
| 315abb0513 | |||
| cae8e9fa8e | |||
| 069c4908c8 | |||
| 2e18a4acdf | |||
| 0921e68913 | |||
| c9fdaa412a | |||
| bed09c2af6 | |||
| b9e0da98bb | |||
| 73f3bf15ea | |||
| 4845b27126 | |||
| 37423caa06 | |||
| 1b991ef095 | |||
| 9b8929cd28 | |||
| f5dbc64e10 | |||
| c1b14b220b | |||
| c3ad539b41 | |||
| 3f94d2697a | |||
| 51c3b1cf7c | |||
| 1c9e21ab8a | |||
| cd25c9724f | |||
| adadff09b8 | |||
| dcdb707dec | |||
| 0dddfc12db | |||
| 1949f8c7f5 | |||
| a68965f64a | |||
| a3f901ecad | |||
| f4b3756e85 | |||
| 917d027941 | |||
| 0aa350306b | |||
| 392e5cfa1e | |||
| 9b226e60e3 | |||
| 49929c1e57 | |||
| 0eab0d9343 | |||
| 468b3dccab | |||
| 202528c557 | |||
| 134428aefd | |||
| bf6186449f | |||
| c02ef4d7b9 | |||
| b5866566d0 | |||
| 22b105e421 | |||
| 9c8d84ed6c | |||
| 586b73adf7 | |||
| a1b748f5f4 | |||
| ce87428cfb | |||
| e7886978bd | |||
| 7e1e73c719 | |||
| 701683e557 | |||
| 272c31c837 | |||
| a142f89540 | |||
| 07c85d3cdf | |||
| 5c8e340a3f | |||
| 3f5d9074e4 | |||
| 96ed1801aa | |||
| 5dd8f775f9 | |||
| e08eb964c4 | |||
| 36027d425c | |||
| 248eee819a | |||
| 8ff42771a4 | |||
| a93e28291f | |||
| 10a71ab4d6 | |||
| 4bcea9de74 | |||
| a2297c64e6 | |||
| 482d60854a | |||
| cff0913be8 | |||
| 8bde816efd | |||
| 176f5c648d | |||
| 4c35d33ef6 | |||
| 2b54f0e680 | |||
| 2b1f692455 | |||
| aba24e6866 | |||
| 24269555a3 | |||
| e2267c80a0 | |||
| 67a108b196 | |||
| d4e4c4f7e3 | |||
| 8514b4d403 | |||
| 5d53d6dd8c | |||
| 51317569f9 | |||
| 5d7a22e6d9 | |||
| 8cdcd45561 | |||
| f7bd6c1948 | |||
| f35e821d57 | |||
| d9d1a91c5f | |||
| 8970abd67f | |||
| cee98e5a0b | |||
| acd6ef1b3b | |||
| 2da5e51eee | |||
| 924f7c6261 | |||
| bba922c562 | |||
| 27f606db1b | |||
| 8b895dda3e | |||
| f442bc4b18 | |||
| 9a867f3da1 | |||
| 72000d7b35 | |||
| a9657c63f4 | |||
| e6ae704f32 | |||
| f0cdf4294e | |||
| b404e9da00 | |||
| 21be3316b8 | |||
| 5581d12e44 | |||
| 7e8736a47d | |||
| ef66d357a7 | |||
| c6f8ceface | |||
| 0cdcecb813 | |||
| 2eeeb163ba | |||
| 9a126f75bb | |||
| d2b6a0dc7a | |||
| 0e992e6089 | |||
| 0f62f281ae | |||
| c4e827bba4 | |||
| ef1376306a | |||
| 000e3c8585 | |||
| 709c44485a | |||
| a8b2e475fa | |||
| 0795dc22b9 | |||
| 9355d9c5a2 | |||
| 5bf8f2cf9e | |||
| fa43d3b190 | |||
| 4afb9fcf1c | |||
| 2fad317498 | |||
| 0cceb0f261 | |||
| 6faa928979 | |||
| fdc2bb1952 | |||
| 3395a55db4 | |||
| 172c6c615e | |||
| 2d0e7bd484 | |||
| d533bb9552 | |||
| cb935f030f | |||
| c682baa97a | |||
| a1134e861e | |||
| 9a3a714ee1 | |||
| 052919fe44 | |||
| 08555b9bde | |||
| 548777910b | |||
| 13177d2635 | |||
| b4b544ff73 | |||
| caea1601c4 | |||
| 2b954b0d55 | |||
| 5281636de4 | |||
| bb5312d3f7 | |||
| dd81ee9855 | |||
| 80e66a6214 | |||
| d73de3fb97 | |||
| c9ab2bab22 | |||
| ce362c03cf | |||
| 83b53ce6c8 | |||
| 74fe5968c1 | |||
| 8c714bf8cd | |||
| d3ca68aee4 | |||
| a063074346 | |||
| f16f9b2b8a | |||
| d95d136550 | |||
| 16ab5e091d | |||
| 8ac39d8863 | |||
| 83140541dc | |||
| 4491151aa9 | |||
| 5262d1bbcc | |||
| 1a325e3580 | |||
| fc678567d7 | |||
| 286ff21dd1 | |||
| cf1c127c23 | |||
| e7110984f3 | |||
| 31f8d3525d | |||
| e1cf8dc2cb | |||
| 291be24742 | |||
| 3304c7620a | |||
| ba441c48b0 | |||
| e5aedf130f | |||
| 94debea0a9 | |||
| c6a48e11e9 | |||
| 327452cb09 | |||
| c751b66d38 | |||
| 5928b18cf3 | |||
| f37779ba20 | |||
| ef67ef3155 | |||
| ba3406fffe | |||
| 68bfea5aa0 | |||
| be588f9493 | |||
| c3fcb18bc6 | |||
| 4897227d04 | |||
| 11cbf850a4 | |||
| c00c3f10a4 | |||
| 00fa61f8f5 | |||
| d3a482ab65 | |||
| b64850e732 | |||
| bc2ee93758 | |||
| 2843a3f7e7 | |||
| 33a9bda1d9 | |||
| d3c4f91c9c | |||
| 5c6c88ef15 | |||
| 69cdb35820 | |||
| 4d89153e5f | |||
| c709dff1a2 | |||
| d859aa1438 | |||
| 4fcb0d036c | |||
| b5338b640f | |||
| 6a88e22423 | |||
| 861d341dff | |||
| a34daf6851 | |||
| 59a00c3cdd | |||
| e86ef017f2 | |||
| d4a226500b | |||
| 16550339ba | |||
| 84e1551c64 | |||
| af902dc042 | |||
| d99b247cc7 | |||
| 139185e543 | |||
| 64bcefb7cd | |||
| 4ac9932128 | |||
| 9190ae2be7 | |||
| a03cf8964f | |||
| 4bf441c32b | |||
| b116a45f07 | |||
| d91613592b | |||
| e6df472e8f | |||
| f6abffdb4a | |||
| a1930b1772 | |||
| 9530ce9d3f | |||
| 3d8e49d9e8 | |||
| 64419a2ea1 | |||
| 34eabc0602 | |||
| ade470352c | |||
| ae48b1b94a | |||
| 394838901d | |||
| f49fcc960b | |||
| 2f3e4c1a7a | |||
| d04cc2855a | |||
| 909eaede4c | |||
| 4d7aa0b762 | |||
| 98609279b6 | |||
| 25047050b7 | |||
| 38e6ba10b4 | |||
| e649ec71df | |||
| 711aa196af | |||
| 518a691231 | |||
| e8bfc09b81 | |||
| 74808e71d2 | |||
| 403f7dc35f | |||
| e09170dffa | |||
| f640639867 | |||
| d24f77be99 | |||
| f697b53eba | |||
| 8231b3cef8 | |||
| b95cc40640 | |||
| 9294978596 | |||
| 3d3e4e62af | |||
| d00926894e | |||
| 5d2ad1e5c7 | |||
| 9945da3efc | |||
| d1e5677fe6 | |||
| 49ddd7b0e7 | |||
| e29800ea7b | |||
| 97ad6b813a | |||
| 77542276f8 | |||
| 0a3779135d | |||
| edf423a7aa | |||
| 02b1586de2 | |||
| a2a136ea02 | |||
| 9b8388dab1 | |||
| fbad7c2dd9 | |||
| 12fe774844 | |||
| 8dc021925f | |||
| 6843ccf462 | |||
| b27352a401 | |||
| 8461d6b5f9 | |||
| 0febfa9eea | |||
| 232a3a524b | |||
| b04c9a1b66 | |||
| dd026c77e3 | |||
| 00bf66d7f2 | |||
| 6224f02c56 | |||
| 31ce9ba07f | |||
| 94b4bb2a12 | |||
| 188bfd2ac9 | |||
| 04defcca4f | |||
| 81eb60434a | |||
| 6635f2a108 | |||
| 1d3be8c453 | |||
| 4de1d0905a | |||
| c461b15720 | |||
| 5c93f887ba | |||
| 9dc5ca0e7c | |||
| c7b141d20a | |||
| 0b3b3de2cd | |||
| 5e551a584e | |||
| fd95935fef | |||
| 4fbb460a02 | |||
| 4aad40d249 | |||
| 8ccb27ce18 | |||
| 9a0a40042e | |||
| 09277c8fd8 | |||
| faceb5b75d | |||
| 9dc5ba1aaf | |||
| a187fb381e | |||
| 868c44b239 | |||
| 10c12b37ec | |||
| ae32bcf4c3 | |||
| 3491e776dd | |||
| 5f632391ca | |||
| 2e61ca6193 | |||
| 3013f4cf2b | |||
| 31c4b743cb | |||
| 78e2e48d57 | |||
| 736e574a5e | |||
| 664052824e | |||
| 0b9f61c9a6 | |||
| 41bb321962 | |||
| 0c030d6e08 | |||
| c8ce9c0080 | |||
| a519dcd576 | |||
| 66c0be642f | |||
| 2fa54c1df6 | |||
| 7f65584f28 | |||
| 7e09206e5c | |||
| ecb4c4268c | |||
| db76c54117 | |||
| c2a8eb2081 | |||
| 5917063192 | |||
| bcb38393a5 | |||
| 1905e1c8a2 | |||
| a6c9527c2f | |||
| f4c469f1b7 | |||
| 196107cd9e | |||
| 33b78c0ad6 | |||
| fa19d01c7b | |||
| f847837fb2 | |||
| 056348a8c0 | |||
| ddbe559c04 | |||
| 63e70e3cd1 | |||
| 4866733a74 | |||
| 01e64eb247 | |||
| 4fe0a8efd8 | |||
| 0551c5c2cd | |||
| e10a2e5999 | |||
| cd9b0d7cc3 | |||
| 8e301c69cb | |||
| 3ee4d6af2e | |||
| 00c55bb2eb | |||
| fe9da69f96 | |||
| c358e4c728 | |||
| 7645c539c8 | |||
| e7837828f6 | |||
| 272fb05270 | |||
| 41f360f9c2 | |||
| 4ce6a8f5f9 | |||
| dfe6d42a01 | |||
| c20776945d | |||
| 0d6c64b38a | |||
| c968c787e5 | |||
| 6e658fdcc1 | |||
| aedc4a4e80 | |||
| 7417b6adb4 | |||
| 66b36235c9 | |||
| e317ab9abe | |||
| 6a48c552e2 | |||
| a1fd60f7d2 | |||
| b5ecdd8ce8 | |||
| 20ea59332f | |||
| 57b895338b | |||
| 2f82b67071 | |||
| 56b8c4b0eb | |||
| bae5f9feb8 | |||
| e95f542204 | |||
| e7c42f132c | |||
| 1608f04851 | |||
| 93ebac318b | |||
| c4d66d087f | |||
| feee8ddd3c | |||
| 659df8cbd8 | |||
| 19a010cc3a | |||
| 307fcb2713 | |||
| ec017f4c01 | |||
| f12db4013e | |||
| e53f01a7af | |||
| 46de6afc40 | |||
| 90bf0b7aec | |||
| 6cdf6d3044 | |||
| 1da969736f | |||
| 486f4d2769 | |||
| 199a54d5ac | |||
| 57c281557a | |||
| d330bee1c2 | |||
| 72bcacf2b6 | |||
| 3876a8776e | |||
| 37ce381e3d | |||
| 939d50243b | |||
| 57f18194f5 | |||
| 58f2953ddf | |||
| 31171ea5a2 | |||
| e7b97af276 | |||
| 95004aafb2 | |||
| 3f6ea30f8d | |||
| 58918b629d | |||
| 736d8db007 | |||
| 1e8ff7460a | |||
| b5425e3d87 | |||
| 3acd6fb728 | |||
| 94ddb499df | |||
| 5a947ebc42 | |||
| 44f4c8e745 | |||
| 4eed7cb9b2 | |||
| ca00323e7f | |||
| d49fc76ab8 | |||
| d89015cfe3 | |||
| 826108efec | |||
| 739c14b07d | |||
| 7f64090401 | |||
| 3bda257163 | |||
| 02f767fe0d | |||
| 20fa30bde6 | |||
| b5b0e42b85 | |||
| a525ea128d | |||
| 3b57b95efb | |||
| 4002da9603 | |||
| e5a17617e6 | |||
| 4e756d61c8 | |||
| 0f5a3d23ea | |||
| 2e31c9fe10 | |||
| cf3c1d878d | |||
| c5dfe6824c | |||
| 640063334d | |||
| ac9e87aae3 | |||
| 5e09cf3e89 | |||
| 6989a7ac53 | |||
| 060f9f2cd7 | |||
| 4c19fc2eb1 | |||
| 5e70e4469a | |||
| 287f169f2a | |||
| 60bc0f79a7 | |||
| c8d0d38cab | |||
| d3ffc8ad0c | |||
| 393e1ef4ee | |||
| 78b44eab0a | |||
| 0f6626977b | |||
| 71885e5ae4 | |||
| 038c4d3a83 | |||
| de66976ff0 | |||
| b08aa6fb3c | |||
| ce944bc3fb | |||
| 5485939233 | |||
| 3cc2eee4e8 | |||
| 56395b03e1 | |||
| 448d281222 | |||
| c07d588e80 | |||
| 52c710f25a | |||
| 29a02a78df | |||
| 91525e3075 | |||
| 7563c17113 | |||
| 43dcf23990 | |||
| 1182637ec9 | |||
| d40f40e1c9 | |||
| fa831f0224 | |||
| 141e389c3f | |||
| 72350eebb2 | |||
| 80fbea28fb | |||
| 7ec8a6e756 | |||
| ddb31e9c5a | |||
| dc97f91a18 | |||
| 171542d96a | |||
| b855bc44ae | |||
| c39e32ae60 | |||
| 5eef26b64e | |||
| 0d2a2a9300 | |||
| 6d767b0f9a | |||
| d49579b038 | |||
| a3ba1b0280 | |||
| c2e02e2066 | |||
| 3503ee4be6 | |||
| 069b429795 | |||
| 2f7aa6c2aa | |||
| a29680c25a | |||
| 3a430e46b9 | |||
| b4733a1da9 | |||
| 8ebd4bb874 | |||
| 63a88c69ac | |||
| bfc94dd4c9 | |||
| 6472d8c7d4 | |||
| e4fadebc3b | |||
| 548ec63f76 | |||
| 9e4d34aebb | |||
| d02c891a4b | |||
| 3bd414786c | |||
| c7adcc8dca | |||
| 577f3ccaf9 | |||
| bffd4f0548 | |||
| 4c8c383876 | |||
| 125b403c0f | |||
| 5f5ec7e162 | |||
| a91d9cb918 | |||
| a7ea441504 | |||
| 4b5472b100 | |||
| 3dc4447cb8 | |||
| 9a21f964ba | |||
| 1f07f71b6c | |||
| 259b9664ef | |||
| b5a55810c5 | |||
| 4fc6256010 | |||
| ce1b62a01f | |||
| 28d4271e3e | |||
| 30b5265417 | |||
| 2f53325bed | |||
| 7ad6a9aeea | |||
| 8018dc6599 | |||
| aaed3ef5ed | |||
| 99cf2ffb19 | |||
| 3b200c55b6 | |||
| 13e9b605cf | |||
| 5d7b7f798a | |||
| 710b57d493 | |||
| ef44ed93a7 | |||
| 4f0b5f7307 | |||
| 1c25e50490 | |||
| a9ec1e3913 | |||
| 46101928bd | |||
| 74e72c995d | |||
| b6f30f1b5b | |||
| b09d06fcf7 | |||
| 9567297a66 | |||
| 607884139c | |||
| 42f351db0d | |||
| 9ab9dd73b0 | |||
| fa9e03996c | |||
| 814b610ed3 | |||
| a5ccaa919e | |||
| 5042d0c30a | |||
| 27f5e404a7 | |||
| 2e9c9f7d74 | |||
| 6063e74e06 | |||
| 449e75455b | |||
| 73cc3a96c0 | |||
| 683511310e | |||
| 12336dc253 | |||
| 8da76f3bb8 | |||
| 8289f8628d | |||
| 91bc845152 | |||
| d8a0b6ba63 | |||
| bf4d8ee69c | |||
| 2c93def09d | |||
| 9cbcff4e91 | |||
| 985b84689f | |||
| 89e4125241 | |||
| 209acbaac7 | |||
| 8a0966a8cb | |||
| 99331ca395 | |||
| ec362d54a9 | |||
| 5e8e2a8730 | |||
| df7d60a9d3 | |||
| fe20a1e35b | |||
| 55a66efa38 | |||
| 5eebe51014 | |||
| 9febb6f747 | |||
| 626525d23a | |||
| a026e2626c | |||
| cf2e30b30c | |||
| f7efa9d43a | |||
| dfb739aff0 | |||
| 89bff17cd2 | |||
| 3e1716b2c3 | |||
| e6200de73a | |||
| 593e616a48 | |||
| eeb7385f02 | |||
| 2ff3b08583 | |||
| 6ab8fb04af | |||
| 498d177cfe | |||
| 06a60bb6ef | |||
| c0132f30c4 | |||
| 649cb70ddb | |||
| 65d214d3da | |||
| 9ee98e999b | |||
| 5bcc7f88b6 | |||
| 93e99846b0 | |||
| 5c2e554853 | |||
| c4468aef5d | |||
| f967334f53 | |||
| 4132f2ea7e | |||
| 262c97098d | |||
| cee20e24bd | |||
| 87476c057a | |||
| 53693e393d | |||
| 3f7e036c4f | |||
| 0aab429453 | |||
| 61fd30c00e | |||
| 44b206a3fa | |||
| 675899a521 | |||
| 61a9ef5d81 | |||
| 9c27e4d885 | |||
| c800653c6f | |||
| 3e931e258c | |||
| 7e5a374825 | |||
| a850ebf352 | |||
| 4e1d19b20c | |||
| d7430ef077 | |||
| 17408bea9c | |||
| 2c55064708 | |||
| 42e82b9377 | |||
| a4b077a0ba | |||
| f6c65d9d15 | |||
| 990bddcf36 | |||
| c730a6ce44 | |||
| 115c0a7415 | |||
| 87242c7b92 | |||
| 4eb9ee9355 | |||
| 48ed52184d | |||
| 69274ef368 | |||
| 039fc750d5 | |||
| 58a7d78c22 | |||
| c0386f0124 | |||
| b6f958965b | |||
| dde14e15c6 | |||
| 1ea805a4aa | |||
| 3b96b3fd12 | |||
| e499b9b4b6 | |||
| 8ea709a7a9 | |||
| f2e19a26f5 | |||
| be771e7165 | |||
| cb65617897 | |||
| bcbe7a8a6f | |||
| ae540c2efe | |||
| 5f15642fde | |||
| 17d7084780 | |||
| fe38b648b0 | |||
| ad325be5a0 | |||
| d69d58deea | |||
| 34591f9451 | |||
| d79a7a2773 | |||
| 05fec82f31 | |||
| 370f84f41c | |||
| 689dfcd9ec | |||
| 46b594054c | |||
| 07e2461995 | |||
| ca5f3b9f8d | |||
| 3d804778fd | |||
| 3e8c214a19 | |||
| e9d8dfbf0e | |||
| 3687faa78f | |||
| eacd66e784 | |||
| b5f8c1a53b | |||
| f04cd405ac | |||
| f55b376d78 | |||
| fdac09a0aa | |||
| 751806b5c7 | |||
| 40018e995c | |||
| be6323d848 | |||
| 29089b715d | |||
| 7e89cc46dd | |||
| a86829211a | |||
| f01821b60a | |||
| 245c11be08 | |||
| fa98637aca | |||
| 723613dbc3 | |||
| 99efa7ce62 | |||
| c7040f3218 | |||
| 5975b44ded | |||
| 8efb9c8cdd | |||
| 75289b4017 | |||
| ccf27376a6 | |||
| 23b9f09c58 | |||
| e1fc7776f6 | |||
| c6a96fc360 | |||
| 4383fae5a4 | |||
| 9cfcf102a0 | |||
| 8dc946c89c | |||
| 327fea741a | |||
| 317cb336eb | |||
| 83b76a8171 | |||
| 70b082c0d9 | |||
| bbfec2a7cc | |||
| 8849377f6d | |||
| 149ffcb1a4 | |||
| fb4a784319 | |||
| 8f231d82bb | |||
| cc280545dc | |||
| fa02b58b46 | |||
| 000caef623 | |||
| b7faa76485 | |||
| a76dfe9c72 | |||
| a423adbee6 | |||
| c5b5fd61d4 | |||
| 5bb269d01d | |||
| d5535d9357 | |||
| 2714b851bf | |||
| 2abbdcaa20 | |||
| 9cba5ef772 | |||
| 416cd9c8b8 | |||
| 7a20495a80 | |||
| bafbd73b51 | |||
| ac6811c4fa | |||
| 8372a404bb | |||
| 5b04dcfabd | |||
| 4b581104e7 | |||
| f49601a934 | |||
| 3e6ab9f3d5 | |||
| 9f9731da3a | |||
| 18735ff6f2 | |||
| 237cf72f89 | |||
| 5c2b2ca95b | |||
| 57f707f951 | |||
| 2f87e7ffe9 | |||
| 12da8dcdeb | |||
| c5388fb0cf | |||
| 02e910275c | |||
| 285f47f037 | |||
| 9fb843db06 | |||
| 4bdcee2b9d | |||
| fd033473c7 | |||
| a39930c5b9 | |||
| c94d8e6577 | |||
| eb5e5200cc | |||
| d54ac732ae | |||
| 62fcd772be | |||
| 150423203b | |||
| ef60123938 | |||
| 0d03b5f162 | |||
| 148e059940 | |||
| 7af43c4ca3 | |||
| 5b32be4701 | |||
| 47b49200b0 | |||
| a7d7f763d0 | |||
| eda94419df | |||
| e6252bda5e | |||
| 069658f1be | |||
| a0e59a7259 | |||
| 82b9a13e0c | |||
| 79ef5f92a9 | |||
| 5d7867082d | |||
| fda35b3f42 | |||
| a0e9d751a3 | |||
| d4a70c6c08 | |||
| 65aa9063c4 | |||
| 9eb546e7ff | |||
| f031e2f665 | |||
| 4bed14f69b | |||
| 91692ce72a | |||
| 05e97db6f2 | |||
| 617bcd1b91 | |||
| 34d8625d82 | |||
| 79b931d093 | |||
| 9173819b71 | |||
| 8787850286 | |||
| 2515d42a14 | |||
| 1a9a40fe31 | |||
| eda3169cd1 | |||
| d7f73031fb | |||
| ba36ef5465 | |||
| 41f9904e71 | |||
| a206d3d2fc | |||
| a6ca62ac79 | |||
| 85dedc09a8 | |||
| 9e7c3016d1 | |||
| 906cf28dae | |||
| 801b544ee1 | |||
| 097f95993f | |||
| c04d868476 | |||
| 50674dbe15 | |||
| 71607d9198 | |||
| 3548f71cc4 | |||
| a1455f6a03 | |||
| f64b68d870 | |||
| f1d26c1c72 | |||
| 7f5fde6459 | |||
| 611caa06a5 | |||
| 3f6e8d70cf | |||
| 40c779fb70 | |||
| 532abf228c | |||
| 248fea2a79 | |||
| 7de47fbabb | |||
| 62dc7ba82f | |||
| 4a3a597377 | |||
| 501880e9ba | |||
| bd02969263 | |||
| 0fa4325153 | |||
| acf01c955f | |||
| 0a75a38db4 | |||
| 845f44b976 | |||
| 77ee4ced30 | |||
| 780a7a281b | |||
| 5481ece976 | |||
| ef49c166f6 | |||
| 77cc0a023b | |||
| 1036a76bc5 | |||
| e44bef4404 | |||
| c77047d6a3 | |||
| a34afa3820 | |||
| 77d27053c3 | |||
| 187c40d64d | |||
| e69b30b276 | |||
| 99e72894a2 | |||
| 258119a9cf | |||
| 3f6694b894 |
35
.appveyor.yml
Normal file
35
.appveyor.yml
Normal file
@ -0,0 +1,35 @@
|
||||
os: Visual Studio 2015
|
||||
|
||||
environment:
|
||||
HOME: "%HOMEDRIVE%%HOMEPATH%"
|
||||
PYTHON: C:\Python27
|
||||
SCONS_CACHE_ROOT: "%HOME%\\scons_cache"
|
||||
SCONS_CACHE_LIMIT: 512
|
||||
matrix:
|
||||
- VS: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat
|
||||
GD_PLATFORM: windows
|
||||
TOOLS: yes
|
||||
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
|
||||
- if defined VS call "%VS%" %ARCH% # if defined - so we can also use mingw
|
||||
|
||||
before_build:
|
||||
- echo %GD_PLATFORM%
|
||||
- python --version
|
||||
- scons --version
|
||||
- cl.exe
|
||||
- set "SCONS_CACHE=%SCONS_CACHE_ROOT%\%APPVEYOR_REPO_BRANCH%"
|
||||
|
||||
build_script:
|
||||
- scons platform=%GD_PLATFORM% target=%TARGET% tools=%TOOLS% verbose=yes progress=no gdnative_wrapper=yes
|
||||
@ -116,7 +116,6 @@ Standard: Cpp03
|
||||
---
|
||||
### ObjC specific config ###
|
||||
Language: ObjC
|
||||
Standard: Cpp03
|
||||
ObjCBlockIndentWidth: 4
|
||||
# ObjCSpaceAfterProperty: false
|
||||
# ObjCSpaceBeforeProtocolList: true
|
||||
@ -124,5 +123,4 @@ ObjCBlockIndentWidth: 4
|
||||
### Java specific config ###
|
||||
Language: Java
|
||||
# BreakAfterJavaFieldAnnotations: false
|
||||
JavaImportGroups: ['org.godotengine', 'android', 'androidx', 'com.android', 'com.google', 'java', 'javax']
|
||||
...
|
||||
|
||||
@ -9,18 +9,10 @@ insert_final_newline = true
|
||||
[*.{cpp,hpp,c,h,mm}]
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[{*.gradle,AndroidManifest.xml}]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
[{*.{py,cs},SConstruct,SCsub}]
|
||||
[*.py]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
[.travis.yml]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.{csproj,props,targets,nuspec}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
18
.gitattributes
vendored
18
.gitattributes
vendored
@ -1,15 +1,11 @@
|
||||
# Properly detect languages on Github
|
||||
*.h linguist-language=cpp
|
||||
*.inc linguist-language=cpp
|
||||
thirdparty/* linguist-vendored
|
||||
drivers/* linguist-vendored
|
||||
|
||||
# Normalize EOL for all files that Git considers text files
|
||||
* text=auto eol=lf
|
||||
|
||||
# The above only works properly for Git 2.10+, so for older versions
|
||||
# we need to manually list the binary files we don't want modified.
|
||||
*.icns binary
|
||||
*.ico binary
|
||||
*.jar binary
|
||||
*.png binary
|
||||
*.ttf binary
|
||||
*.cpp eol=lf
|
||||
*.mm eol=lf
|
||||
*.h eol=lf
|
||||
*.py eol=lf
|
||||
*.hpp eol=lf
|
||||
*.xml eol=lf
|
||||
|
||||
174
.github/CODEOWNERS
vendored
174
.github/CODEOWNERS
vendored
@ -1,174 +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
|
||||
|
||||
# Buildsystem
|
||||
|
||||
.* @godotengine/buildsystem
|
||||
.github/ @godotengine/buildsystem
|
||||
*.py @godotengine/buildsystem
|
||||
SConstruct @godotengine/buildsystem
|
||||
SCsub @godotengine/buildsystem
|
||||
|
||||
# Core
|
||||
|
||||
/core/ @godotengine/core
|
||||
/core/crypto/ @godotengine/network
|
||||
/core/input*.* @godotengine/input
|
||||
|
||||
# Doc
|
||||
|
||||
/doc/ @godotengine/documentation
|
||||
doc_classes/* @godotengine/documentation
|
||||
|
||||
# Drivers
|
||||
|
||||
## Audio
|
||||
/drivers/alsa/ @godotengine/audio
|
||||
/drivers/alsamidi/ @godotengine/audio
|
||||
/drivers/coreaudio/ @godotengine/audio
|
||||
/drivers/coremidi/ @godotengine/audio
|
||||
/drivers/pulseaudio/ @godotengine/audio
|
||||
/drivers/wasapi/ @godotengine/audio
|
||||
/drivers/winmidi/ @godotengine/audio
|
||||
/drivers/xaudio2/ @godotengine/audio
|
||||
|
||||
## Rendering
|
||||
/drivers/dummy/ @godotengine/rendering
|
||||
/drivers/gl_context/ @godotengine/rendering
|
||||
/drivers/gles2/ @godotengine/rendering
|
||||
/drivers/gles3/ @godotengine/rendering
|
||||
/drivers/gles_common/ @godotengine/rendering
|
||||
|
||||
## OS
|
||||
/drivers/unix/ @godotengine/_platforms
|
||||
/drivers/windows/ @godotengine/windows
|
||||
|
||||
## Misc
|
||||
/drivers/png/ @godotengine/import
|
||||
|
||||
# Editor
|
||||
|
||||
/editor/*debugger* @godotengine/debugger
|
||||
/editor/icons/ @godotengine/usability
|
||||
/editor/import/ @godotengine/import
|
||||
/editor/plugins/*2d_*.* @godotengine/2d-editor
|
||||
/editor/plugins/script_*.* @godotengine/script-editor
|
||||
/editor/plugins/*shader*.* @godotengine/shaders
|
||||
/editor/code_editor.* @godotengine/script-editor
|
||||
/editor/*dock*.* @godotengine/docks
|
||||
|
||||
# Main
|
||||
|
||||
/main/ @godotengine/core
|
||||
/main/tests/ @godotengine/tests
|
||||
|
||||
# Misc
|
||||
|
||||
/misc/ @godotengine/buildsystem
|
||||
|
||||
# Modules
|
||||
|
||||
## Audio (+ video)
|
||||
/modules/minimp3/ @godotengine/audio
|
||||
/modules/ogg/ @godotengine/audio
|
||||
/modules/opus/ @godotengine/audio
|
||||
/modules/stb_vorbis/ @godotengine/audio
|
||||
/modules/theora/ @godotengine/audio
|
||||
/modules/vorbis/ @godotengine/audio
|
||||
/modules/webm/ @godotengine/audio
|
||||
|
||||
## Import
|
||||
/modules/basis_universal/ @godotengine/import
|
||||
/modules/bmp/ @godotengine/import
|
||||
/modules/cvtt/ @godotengine/import
|
||||
/modules/dds/ @godotengine/import
|
||||
/modules/etc/ @godotengine/import
|
||||
/modules/fbx/ @godotengine/import
|
||||
/modules/gltf/ @godotengine/import
|
||||
/modules/hdr/ @godotengine/import
|
||||
/modules/jpg/ @godotengine/import
|
||||
/modules/pvr/ @godotengine/import
|
||||
/modules/squish/ @godotengine/import
|
||||
/modules/svg/ @godotengine/import
|
||||
/modules/tga/ @godotengine/import
|
||||
/modules/tinyexr/ @godotengine/import
|
||||
/modules/webp/ @godotengine/import
|
||||
|
||||
## Network
|
||||
/modules/enet/ @godotengine/network
|
||||
/modules/mbedtls/ @godotengine/network
|
||||
/modules/upnp/ @godotengine/network
|
||||
/modules/webrtc/ @godotengine/network
|
||||
/modules/websocket/ @godotengine/network
|
||||
|
||||
## Rendering
|
||||
/modules/denoise/ @godotengine/rendering
|
||||
/modules/glslang/ @godotengine/rendering
|
||||
/modules/lightmapper_cpu/ @godotengine/rendering
|
||||
/modules/meshoptimizer/ @godotengine/rendering
|
||||
/modules/raycast/ @godotengine/rendering
|
||||
/modules/vhacd/ @godotengine/rendering
|
||||
/modules/xatlas_unwrap/ @godotengine/rendering
|
||||
|
||||
## Scripting
|
||||
/modules/gdnative/ @godotengine/gdnative
|
||||
/modules/gdscript/ @godotengine/gdscript
|
||||
/modules/jsonrpc/ @godotengine/gdscript
|
||||
/modules/mono/ @godotengine/mono
|
||||
/modules/visual_script/ @godotengine/visualscript
|
||||
|
||||
## Text
|
||||
/modules/freetype/ @godotengine/buildsystem
|
||||
/modules/gdnative/text/ @godotengine/gui-nodes
|
||||
/modules/text_server_adv/ @godotengine/gui-nodes
|
||||
/modules/text_server_fb/ @godotengine/gui-nodes
|
||||
|
||||
## XR
|
||||
/modules/camera/ @godotengine/xr
|
||||
/modules/gdnative/arvr/ @godotengine/xr
|
||||
/modules/mobile_vr/ @godotengine/xr
|
||||
/modules/webxr/ @godotengine/xr
|
||||
|
||||
## Misc
|
||||
/modules/bullet/ @godotengine/physics
|
||||
/modules/csg/ @godotengine/3d-nodes
|
||||
/modules/gridmap/ @godotengine/3d-nodes
|
||||
/modules/opensimplex/ @godotengine/3d-nodes
|
||||
/modules/recast/ @godotengine/navigation
|
||||
/modules/regex/ @godotengine/core
|
||||
|
||||
# Platform
|
||||
|
||||
/platform/android/ @godotengine/android
|
||||
/platform/iphone/ @godotengine/ios
|
||||
/platform/javascript/ @godotengine/html5
|
||||
/platform/x11/ @godotengine/linux-bsd
|
||||
/platform/osx/ @godotengine/macos
|
||||
/platform/uwp/ @godotengine/uwp
|
||||
/platform/windows/ @godotengine/windows
|
||||
|
||||
# Scene
|
||||
|
||||
/scene/2d/ @godotengine/2d-nodes
|
||||
/scene/3d/ @godotengine/3d-nodes
|
||||
/scene/animation/ @godotengine/animation
|
||||
/scene/audio/ @godotengine/audio
|
||||
/scene/debugger/ @godotengine/debugger
|
||||
/scene/gui/ @godotengine/gui-nodes
|
||||
/scene/main/ @godotengine/core
|
||||
/scene/resources/default_theme/ @godotengine/gui-nodes
|
||||
/scene/resources/font.* @godotengine/gui-nodes
|
||||
/scene/resources/visual_shader*.* @godotengine/shaders
|
||||
|
||||
# Servers
|
||||
|
||||
/servers/arvr* @godotengine/xr
|
||||
/servers/audio* @godotengine/audio
|
||||
/servers/camera* @godotengine/xr
|
||||
/servers/physics* @godotengine/physics
|
||||
/servers/visual* @godotengine/rendering
|
||||
|
||||
# Thirdparty
|
||||
|
||||
/thirdparty/ @godotengine/buildsystem
|
||||
18
.github/ISSUE_TEMPLATE/bug_report.md
vendored
18
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@ -1,18 +0,0 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Report a bug in Godot
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Godot version:**
|
||||
|
||||
**OS/device including version:**
|
||||
|
||||
**Issue description:**
|
||||
|
||||
**Steps to reproduce:**
|
||||
|
||||
**Minimal reproduction project:**
|
||||
@ -1,19 +0,0 @@
|
||||
---
|
||||
name: Feature / Enhancement Request
|
||||
about: Adding new features or improving existing ones.
|
||||
title: 'IMPORTANT: This repository no longer accepts feature / enhancement requests.'
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**IMPORTANT, PLEASE READ**
|
||||
|
||||
Feature / Enhancement requests are no longer accepted in the main Godot repository.
|
||||
Please open an item by filling the relevant fields in the *Proposals* repository:
|
||||
|
||||
https://github.com/godotengine/godot-proposals/issues/new/choose
|
||||
|
||||
Do not submit to this repository or your issue will be closed.
|
||||
|
||||
**IMPORTANT, PLEASE READ**
|
||||
38
.github/actions/godot-build/action.yml
vendored
38
.github/actions/godot-build/action.yml
vendored
@ -1,38 +0,0 @@
|
||||
name: Build Godot
|
||||
description: Build Godot with the provided options.
|
||||
inputs:
|
||||
target:
|
||||
description: The scons target (debug/release_debug/release).
|
||||
default: "debug"
|
||||
tools:
|
||||
description: If tools are to be built.
|
||||
default: false
|
||||
tests:
|
||||
description: If tests are to be built.
|
||||
default: false
|
||||
platform:
|
||||
description: The Godot platform to build.
|
||||
required: false
|
||||
sconsflags:
|
||||
default: ""
|
||||
scons-cache:
|
||||
description: The scons cache path.
|
||||
default: "${{ github.workspace }}/.scons-cache/"
|
||||
scons-cache-limit:
|
||||
description: The scons cache size limit.
|
||||
# actions/cache has 10 GiB limit, and GitHub runners have a 14 GiB disk.
|
||||
# Limit to 7 GiB to avoid having the extracted cache fill the disk.
|
||||
default: 7168
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Scons Build
|
||||
shell: sh
|
||||
env:
|
||||
SCONSFLAGS: ${{ inputs.sconsflags }}
|
||||
SCONS_CACHE: ${{ inputs.scons-cache }}
|
||||
SCONS_CACHE_LIMIT: ${{ inputs.scons-cache-limit }}
|
||||
run: |
|
||||
echo "Building with flags:" ${{ env.SCONSFLAGS }}
|
||||
scons p=${{ inputs.platform }} target=${{ inputs.target }} tools=${{ inputs.tools }} tests=${{ inputs.tests }} --jobs=2 ${{ env.SCONSFLAGS }}
|
||||
ls -l bin/
|
||||
21
.github/actions/godot-cache-restore/action.yml
vendored
21
.github/actions/godot-cache-restore/action.yml
vendored
@ -1,21 +0,0 @@
|
||||
name: Restore Godot build cache
|
||||
description: Restore Godot build cache.
|
||||
inputs:
|
||||
cache-name:
|
||||
description: The cache base name (job name by default).
|
||||
default: "${{github.job}}"
|
||||
scons-cache:
|
||||
description: The scons cache path.
|
||||
default: "${{github.workspace}}/.scons-cache/"
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Restore .scons_cache directory
|
||||
uses: actions/cache/restore@v4
|
||||
with:
|
||||
path: ${{inputs.scons-cache}}
|
||||
key: ${{inputs.cache-name}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}}
|
||||
restore-keys: |
|
||||
${{inputs.cache-name}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}}
|
||||
${{inputs.cache-name}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}
|
||||
${{inputs.cache-name}}-${{env.GODOT_BASE_BRANCH}}
|
||||
17
.github/actions/godot-cache-save/action.yml
vendored
17
.github/actions/godot-cache-save/action.yml
vendored
@ -1,17 +0,0 @@
|
||||
name: Save Godot build cache
|
||||
description: Save Godot build cache.
|
||||
inputs:
|
||||
cache-name:
|
||||
description: The cache base name (job name by default).
|
||||
default: "${{github.job}}"
|
||||
scons-cache:
|
||||
description: The scons cache path.
|
||||
default: "${{github.workspace}}/.scons-cache/"
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Save .scons_cache directory
|
||||
uses: actions/cache/save@v4
|
||||
with:
|
||||
path: ${{inputs.scons-cache}}
|
||||
key: ${{inputs.cache-name}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}}
|
||||
27
.github/actions/godot-deps/action.yml
vendored
27
.github/actions/godot-deps/action.yml
vendored
@ -1,27 +0,0 @@
|
||||
name: Setup python and scons
|
||||
description: Setup python, install the pip version of scons.
|
||||
inputs:
|
||||
python-version:
|
||||
description: The python version to use.
|
||||
default: "3.x"
|
||||
python-arch:
|
||||
description: The python architecture.
|
||||
default: "x64"
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
# Use python 3.x release (works cross platform)
|
||||
- name: Set up Python 3.x
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
# Semantic version range syntax or exact version of a Python version
|
||||
python-version: ${{ inputs.python-version }}
|
||||
# Optional - x64 or x86 architecture, defaults to x64
|
||||
architecture: ${{ inputs.python-arch }}
|
||||
|
||||
- name: Setup scons
|
||||
shell: bash
|
||||
run: |
|
||||
python -c "import sys; print(sys.version)"
|
||||
python -m pip install scons==4.7.0
|
||||
scons --version
|
||||
19
.github/actions/upload-artifact/action.yml
vendored
19
.github/actions/upload-artifact/action.yml
vendored
@ -1,19 +0,0 @@
|
||||
name: Upload Godot artifact
|
||||
description: Upload the Godot artifact.
|
||||
inputs:
|
||||
name:
|
||||
description: The artifact name.
|
||||
default: "${{ github.job }}"
|
||||
path:
|
||||
description: The path to upload.
|
||||
required: true
|
||||
default: "bin/*"
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Upload Godot Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ inputs.name }}
|
||||
path: ${{ inputs.path }}
|
||||
retention-days: 14
|
||||
78
.github/workflows/android_builds.yml
vendored
78
.github/workflows/android_builds.yml
vendored
@ -1,78 +0,0 @@
|
||||
name: 🤖 Android Builds
|
||||
on:
|
||||
workflow_call:
|
||||
|
||||
# Global Settings
|
||||
env:
|
||||
# Only used for the cache key. Increment version to force clean build.
|
||||
GODOT_BASE_BRANCH: 3.2
|
||||
SCONSFLAGS: verbose=yes warnings=all werror=yes debug_symbols=no
|
||||
ANDROID_HOME: /home/runner/work/godot/godot/android-sdk
|
||||
ANDROID_NDK_ROOT: /home/runner/work/godot/godot/android-sdk/ndk/21.1.6352462
|
||||
ANDROID_NDK_VERSION: 21.1.6352462
|
||||
|
||||
concurrency:
|
||||
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-android
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
android-template:
|
||||
runs-on: "ubuntu-20.04"
|
||||
name: Template (target=release, tools=no)
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Java 8, Android SDK and NDK
|
||||
run: |
|
||||
# Not using actions/setup-java and android-actions/setup-android as I couldn't make them work for such old Java/SDK/NDK combination.
|
||||
# Azure repositories are flaky, remove them.
|
||||
sudo rm -f /etc/apt/sources.list.d/{azure,microsoft}*
|
||||
sudo apt-get update
|
||||
sudo apt-get install openjdk-8-jdk
|
||||
sudo update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
|
||||
mkdir -p ${{env.ANDROID_HOME}}
|
||||
cd ${{env.ANDROID_HOME}}
|
||||
# Using an old version to be compatible with older Java.
|
||||
curl -LO https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip
|
||||
unzip commandlinetools-linux-8512546_latest.zip
|
||||
yes | ./cmdline-tools/bin/sdkmanager --sdk_root=${{env.ANDROID_HOME}} --licenses
|
||||
# https://github.com/godotengine/build-containers/blob/3.2/Dockerfile.android
|
||||
./cmdline-tools/bin/sdkmanager --sdk_root=${{env.ANDROID_HOME}} 'build-tools;28.0.3' 'platforms;android-28' 'cmake;3.10.2.4988404' 'ndk;${{env.ANDROID_NDK_VERSION}}'
|
||||
|
||||
- name: Restore Godot build cache
|
||||
uses: ./.github/actions/godot-cache-restore
|
||||
continue-on-error: true
|
||||
|
||||
- name: Setup python and scons
|
||||
uses: ./.github/actions/godot-deps
|
||||
|
||||
- name: Compilation (armv7)
|
||||
uses: ./.github/actions/godot-build
|
||||
with:
|
||||
sconsflags: ${{ env.SCONSFLAGS }} android_arch=armv7
|
||||
platform: android
|
||||
target: release
|
||||
tools: false
|
||||
|
||||
- name: Compilation (arm64v8)
|
||||
uses: ./.github/actions/godot-build
|
||||
with:
|
||||
sconsflags: ${{ env.SCONSFLAGS }} android_arch=arm64v8
|
||||
platform: android
|
||||
target: release
|
||||
tools: false
|
||||
|
||||
- name: Save Godot build cache
|
||||
uses: ./.github/actions/godot-cache-save
|
||||
continue-on-error: true
|
||||
|
||||
- name: Generate Godot templates
|
||||
run: |
|
||||
cd platform/android/java
|
||||
./gradlew generateGodotTemplates
|
||||
cd ../../..
|
||||
ls -l bin/
|
||||
|
||||
- name: Upload artifact
|
||||
uses: ./.github/actions/upload-artifact
|
||||
44
.github/workflows/ios_builds.yml
vendored
44
.github/workflows/ios_builds.yml
vendored
@ -1,44 +0,0 @@
|
||||
name: 🍏 iOS Builds
|
||||
on:
|
||||
workflow_call:
|
||||
|
||||
# Global Settings
|
||||
env:
|
||||
# Only used for the cache key. Increment version to force clean build.
|
||||
GODOT_BASE_BRANCH: 3.2
|
||||
# iOS platform on this branch doesn't build without errors.
|
||||
SCONSFLAGS: verbose=yes warnings=all werror=no debug_symbols=no
|
||||
|
||||
concurrency:
|
||||
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-ios
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
ios-template:
|
||||
runs-on: "macos-latest"
|
||||
name: Template (target=release, tools=no)
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Restore Godot build cache
|
||||
uses: ./.github/actions/godot-cache-restore
|
||||
continue-on-error: true
|
||||
|
||||
- name: Setup python and scons
|
||||
uses: ./.github/actions/godot-deps
|
||||
|
||||
- name: Compilation (arm64v8)
|
||||
uses: ./.github/actions/godot-build
|
||||
with:
|
||||
sconsflags: ${{ env.SCONSFLAGS }}
|
||||
platform: iphone
|
||||
target: release
|
||||
tools: false
|
||||
|
||||
- name: Save Godot build cache
|
||||
uses: ./.github/actions/godot-cache-save
|
||||
continue-on-error: true
|
||||
|
||||
- name: Upload artifact
|
||||
uses: ./.github/actions/upload-artifact
|
||||
56
.github/workflows/javascript_builds.yml
vendored
56
.github/workflows/javascript_builds.yml
vendored
@ -1,56 +0,0 @@
|
||||
name: 🌐 JavaScript Builds
|
||||
on:
|
||||
workflow_call:
|
||||
|
||||
# Global Settings
|
||||
env:
|
||||
# Only used for the cache key. Increment version to force clean build.
|
||||
GODOT_BASE_BRANCH: 3.2
|
||||
SCONSFLAGS: verbose=yes warnings=all werror=yes debug_symbols=no
|
||||
EM_VERSION: 1.39.20
|
||||
EM_CACHE_FOLDER: "emsdk-cache"
|
||||
|
||||
concurrency:
|
||||
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-javascript
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
javascript-template:
|
||||
runs-on: "ubuntu-20.04"
|
||||
name: Template (target=release, tools=no)
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Emscripten latest
|
||||
uses: mymindstorm/setup-emsdk@v14
|
||||
with:
|
||||
version: ${{env.EM_VERSION}}
|
||||
actions-cache-folder: ${{env.EM_CACHE_FOLDER}}
|
||||
cache-key: emsdk-${{ matrix.cache-name }}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}}
|
||||
|
||||
- name: Verify Emscripten setup
|
||||
run: |
|
||||
emcc -v
|
||||
|
||||
- name: Restore Godot build cache
|
||||
uses: ./.github/actions/godot-cache-restore
|
||||
continue-on-error: true
|
||||
|
||||
- name: Setup python and scons
|
||||
uses: ./.github/actions/godot-deps
|
||||
|
||||
- name: Compilation
|
||||
uses: ./.github/actions/godot-build
|
||||
with:
|
||||
sconsflags: ${{ env.SCONSFLAGS }}
|
||||
platform: javascript
|
||||
target: release
|
||||
tools: false
|
||||
|
||||
- name: Save Godot build cache
|
||||
uses: ./.github/actions/godot-cache-save
|
||||
continue-on-error: true
|
||||
|
||||
- name: Upload artifact
|
||||
uses: ./.github/actions/upload-artifact
|
||||
154
.github/workflows/linux_builds.yml
vendored
154
.github/workflows/linux_builds.yml
vendored
@ -1,154 +0,0 @@
|
||||
name: 🐧 Linux Builds
|
||||
on:
|
||||
workflow_call:
|
||||
|
||||
# Global Settings
|
||||
env:
|
||||
# Only used for the cache key. Increment version to force clean build.
|
||||
GODOT_BASE_BRANCH: 3.2
|
||||
SCONSFLAGS: verbose=yes warnings=all werror=yes
|
||||
|
||||
concurrency:
|
||||
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-linux
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build-linux:
|
||||
runs-on: "ubuntu-20.04"
|
||||
name: ${{ matrix.name }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- name: Editor w/ Mono (target=release_debug, tools=yes)
|
||||
cache-name: linux-editor-mono
|
||||
target: release_debug
|
||||
tools: true
|
||||
sconsflags: module_mono_enabled=yes mono_static=yes mono_glue=no
|
||||
bin: "./bin/godot.x11.opt.tools.64.mono"
|
||||
build-mono: true
|
||||
artifact: true
|
||||
|
||||
- name: Editor and sanitizers (target=debug, tools=yes, use_asan=yes, use_ubsan=yes, linker=gold)
|
||||
cache-name: linux-editor-sanitizers
|
||||
target: debug
|
||||
tools: true
|
||||
sconsflags: use_asan=yes use_ubsan=yes linker=gold
|
||||
test: true
|
||||
bin: "./bin/godot.x11.tools.64s"
|
||||
build-mono: false
|
||||
# Skip 2GiB artifact speeding up action.
|
||||
artifact: false
|
||||
|
||||
- name: Template w/ Mono (target=release, tools=no)
|
||||
cache-name: linux-template-mono
|
||||
target: release
|
||||
tools: false
|
||||
sconsflags: module_mono_enabled=yes mono_static=yes mono_glue=no debug_symbols=no
|
||||
build-mono: false
|
||||
artifact: true
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Linux dependencies
|
||||
shell: bash
|
||||
run: |
|
||||
# Azure repositories are flaky, remove them.
|
||||
sudo rm -f /etc/apt/sources.list.d/{azure,microsoft}*
|
||||
sudo apt-get update
|
||||
# The actual dependencies.
|
||||
sudo apt-get install --no-install-recommends build-essential pkg-config libx11-dev \
|
||||
libxcursor-dev libxinerama-dev libgl1-mesa-dev libglu-dev libasound2-dev \
|
||||
libpulse-dev libdbus-1-dev libudev-dev libxi-dev libxrandr-dev yasm xvfb wget unzip
|
||||
|
||||
- name: Free disk space on runner
|
||||
run: |
|
||||
echo "Disk usage before:" && df -h
|
||||
sudo rm -rf /usr/local/lib/android
|
||||
echo "Disk usage after:" && df -h
|
||||
|
||||
- name: Restore Godot build cache
|
||||
uses: ./.github/actions/godot-cache-restore
|
||||
with:
|
||||
cache-name: ${{ matrix.cache-name }}
|
||||
continue-on-error: true
|
||||
|
||||
- name: Setup python and scons
|
||||
uses: ./.github/actions/godot-deps
|
||||
|
||||
- name: Setup GCC problem matcher
|
||||
uses: ammaraskar/gcc-problem-matcher@master
|
||||
|
||||
- name: Compilation
|
||||
uses: ./.github/actions/godot-build
|
||||
with:
|
||||
sconsflags: ${{ env.SCONSFLAGS }} ${{ matrix.sconsflags }}
|
||||
platform: linuxbsd
|
||||
target: ${{ matrix.target }}
|
||||
tools: ${{ matrix.tools }}
|
||||
|
||||
- name: Save Godot build cache
|
||||
uses: ./.github/actions/godot-cache-save
|
||||
with:
|
||||
cache-name: ${{ matrix.cache-name }}
|
||||
continue-on-error: true
|
||||
|
||||
# Generate mono glue
|
||||
- name: Generate Mono glue code
|
||||
if: ${{ matrix.build-mono }}
|
||||
run: |
|
||||
DRI_PRIME=0 xvfb-run ${{ matrix.bin }} --generate-mono-glue modules/mono/glue || true
|
||||
|
||||
# Rebuild with mono
|
||||
- name: Compilation (mono_glue=yes)
|
||||
uses: ./.github/actions/godot-build
|
||||
if: ${{ matrix.build-mono }}
|
||||
with:
|
||||
sconsflags: ${{ env.SCONSFLAGS }} ${{ matrix.sconsflags }} mono_glue=yes
|
||||
platform: linuxbsd
|
||||
target: ${{ matrix.target }}
|
||||
tools: ${{ matrix.tools }}
|
||||
|
||||
# Download and extract zip archive with project, folder is renamed to be able to easy change used project
|
||||
- name: Download test project
|
||||
if: ${{ matrix.test }}
|
||||
run: |
|
||||
wget https://github.com/godotengine/regression-test-project/archive/3.2.zip
|
||||
unzip 3.2.zip
|
||||
mv "regression-test-project-3.2" "test_project"
|
||||
|
||||
# Editor is quite complicated piece of software, so it is easy to introduce bug here
|
||||
- name: Open and close editor
|
||||
if: ${{ matrix.test }}
|
||||
run: |
|
||||
DRI_PRIME=0 xvfb-run ${{ matrix.bin }} --audio-driver Dummy -e -q --path test_project 2>&1 | tee sanitizers_log.txt || true
|
||||
misc/scripts/check_ci_log.py sanitizers_log.txt
|
||||
|
||||
# Run test project
|
||||
- name: Run project
|
||||
if: ${{ matrix.test }}
|
||||
run: |
|
||||
DRI_PRIME=0 xvfb-run ${{ matrix.bin }} 30 --video-driver GLES3 --audio-driver Dummy --path test_project 2>&1 | tee sanitizers_log.txt || true
|
||||
misc/scripts/check_ci_log.py sanitizers_log.txt
|
||||
|
||||
# Check class reference
|
||||
- name: Check for class reference updates
|
||||
if: ${{ matrix.test }}
|
||||
run: |
|
||||
echo "Running --doctool to see if this changes the public API without updating the documentation."
|
||||
echo -e "If a diff is shown, it means that your code/doc changes are incomplete and you should update the class reference with --doctool.\n\n"
|
||||
DRI_PRIME=0 xvfb-run ${{ matrix.bin }} --doctool . 2>&1 > /dev/null || true
|
||||
git diff --color --exit-code && ! git ls-files --others --exclude-standard | sed -e 's/^/New doc file missing in PR: /' | grep 'xml$'
|
||||
|
||||
- name: Prepare artifact
|
||||
if: ${{ matrix.artifact }}
|
||||
run: |
|
||||
strip bin/godot.*
|
||||
chmod +x bin/godot.*
|
||||
|
||||
- name: Upload artifact
|
||||
uses: ./.github/actions/upload-artifact
|
||||
if: ${{ matrix.artifact }}
|
||||
with:
|
||||
name: ${{ matrix.cache-name }}
|
||||
68
.github/workflows/macos_builds.yml
vendored
68
.github/workflows/macos_builds.yml
vendored
@ -1,68 +0,0 @@
|
||||
name: 🍎 macOS Builds
|
||||
on:
|
||||
workflow_call:
|
||||
|
||||
# Global Settings
|
||||
env:
|
||||
# Only used for the cache key. Increment version to force clean build.
|
||||
GODOT_BASE_BRANCH: 3.2
|
||||
SCONSFLAGS: verbose=yes warnings=all werror=yes debug_symbols=no
|
||||
|
||||
concurrency:
|
||||
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-macos
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build-macos:
|
||||
runs-on: "macos-latest"
|
||||
name: ${{ matrix.name }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- name: Editor (target=release_debug, tools=yes)
|
||||
cache-name: macos-editor
|
||||
target: release_debug
|
||||
tools: true
|
||||
bin: "./bin/godot.osx.opt.tools.64"
|
||||
|
||||
- name: Template (target=release, tools=no)
|
||||
cache-name: macos-template
|
||||
target: release
|
||||
tools: false
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Restore Godot build cache
|
||||
uses: ./.github/actions/godot-cache-restore
|
||||
with:
|
||||
cache-name: ${{ matrix.cache-name }}
|
||||
continue-on-error: true
|
||||
|
||||
- name: Setup python and scons
|
||||
uses: ./.github/actions/godot-deps
|
||||
|
||||
- name: Compilation
|
||||
uses: ./.github/actions/godot-build
|
||||
with:
|
||||
sconsflags: ${{ env.SCONSFLAGS }}
|
||||
platform: osx
|
||||
target: ${{ matrix.target }}
|
||||
tools: ${{ matrix.tools }}
|
||||
|
||||
- name: Save Godot build cache
|
||||
uses: ./.github/actions/godot-cache-save
|
||||
with:
|
||||
cache-name: ${{ matrix.cache-name }}
|
||||
continue-on-error: true
|
||||
|
||||
- name: Prepare artifact
|
||||
run: |
|
||||
strip bin/godot.*
|
||||
chmod +x bin/godot.*
|
||||
|
||||
- name: Upload artifact
|
||||
uses: ./.github/actions/upload-artifact
|
||||
with:
|
||||
name: ${{ matrix.cache-name }}
|
||||
46
.github/workflows/runner.yml
vendored
46
.github/workflows/runner.yml
vendored
@ -1,46 +0,0 @@
|
||||
name: 🔗 GHA
|
||||
on: [push, pull_request]
|
||||
|
||||
concurrency:
|
||||
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-runner
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
static-checks:
|
||||
name: 📊 Static
|
||||
uses: ./.github/workflows/static_checks.yml
|
||||
|
||||
android-build:
|
||||
name: 🤖 Android
|
||||
needs: static-checks
|
||||
uses: ./.github/workflows/android_builds.yml
|
||||
|
||||
ios-build:
|
||||
name: 🍏 iOS
|
||||
needs: static-checks
|
||||
uses: ./.github/workflows/ios_builds.yml
|
||||
|
||||
javascript-build:
|
||||
name: 🌐 JavaScript
|
||||
needs: static-checks
|
||||
uses: ./.github/workflows/javascript_builds.yml
|
||||
|
||||
linux-build:
|
||||
name: 🐧 Linux
|
||||
needs: static-checks
|
||||
uses: ./.github/workflows/linux_builds.yml
|
||||
|
||||
macos-build:
|
||||
name: 🍎 macOS
|
||||
needs: static-checks
|
||||
uses: ./.github/workflows/macos_builds.yml
|
||||
|
||||
server-build:
|
||||
name: ☁ Server
|
||||
needs: static-checks
|
||||
uses: ./.github/workflows/server_builds.yml
|
||||
|
||||
windows-build:
|
||||
name: 🏁 Windows
|
||||
needs: static-checks
|
||||
uses: ./.github/workflows/windows_builds.yml
|
||||
68
.github/workflows/server_builds.yml
vendored
68
.github/workflows/server_builds.yml
vendored
@ -1,68 +0,0 @@
|
||||
name: ☁ Server Builds
|
||||
on:
|
||||
workflow_call:
|
||||
|
||||
# Global Settings
|
||||
env:
|
||||
# Only used for the cache key. Increment version to force clean build.
|
||||
GODOT_BASE_BRANCH: 3.2
|
||||
SCONSFLAGS: verbose=yes warnings=all werror=yes debug_symbols=no module_mono_enabled=yes mono_static=yes mono_glue=no
|
||||
|
||||
concurrency:
|
||||
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-server
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build-server:
|
||||
runs-on: "ubuntu-20.04"
|
||||
name: ${{ matrix.name }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- name: Linux Headless w/ Mono (target=release_debug, tools=yes)
|
||||
cache-name: server-editor-mono
|
||||
target: release_debug
|
||||
tools: true
|
||||
|
||||
- name: Linux Server w/ Mono (target=release, tools=no)
|
||||
cache-name: server-template-mono
|
||||
target: release
|
||||
tools: false
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Linux dependencies
|
||||
shell: bash
|
||||
run: |
|
||||
# Azure repositories are flaky, remove them.
|
||||
sudo rm -f /etc/apt/sources.list.d/{azure,microsoft}*
|
||||
sudo apt-get update
|
||||
# The actual dependencies.
|
||||
sudo apt-get install --no-install-recommends build-essential pkg-config libx11-dev \
|
||||
libxcursor-dev libxinerama-dev libgl1-mesa-dev libglu-dev libasound2-dev \
|
||||
libpulse-dev libdbus-1-dev libudev-dev libxi-dev libxrandr-dev yasm xvfb wget unzip
|
||||
|
||||
- name: Restore Godot build cache
|
||||
uses: ./.github/actions/godot-cache-restore
|
||||
with:
|
||||
cache-name: ${{ matrix.cache-name }}
|
||||
continue-on-error: true
|
||||
|
||||
- name: Setup python and scons
|
||||
uses: ./.github/actions/godot-deps
|
||||
|
||||
- name: Compilation
|
||||
uses: ./.github/actions/godot-build
|
||||
with:
|
||||
sconsflags: ${{ env.SCONSFLAGS }} ${{ matrix.sconsflags }}
|
||||
platform: server
|
||||
target: ${{ matrix.target }}
|
||||
tools: ${{ matrix.tools }}
|
||||
|
||||
- name: Save Godot build cache
|
||||
uses: ./.github/actions/godot-cache-save
|
||||
with:
|
||||
cache-name: ${{ matrix.cache-name }}
|
||||
continue-on-error: true
|
||||
41
.github/workflows/static_checks.yml
vendored
41
.github/workflows/static_checks.yml
vendored
@ -1,41 +0,0 @@
|
||||
name: 📊 Static Checks
|
||||
on:
|
||||
workflow_call:
|
||||
|
||||
concurrency:
|
||||
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-static
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
static-checks:
|
||||
name: Static Checks (clang-format, black format, file format, documentation checks)
|
||||
runs-on: "ubuntu-20.04"
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
# Azure repositories are flaky, remove them.
|
||||
sudo rm -f /etc/apt/sources.list.d/{azure,microsoft}*
|
||||
sudo apt-get update
|
||||
sudo apt-get install -qq dos2unix python3-pip moreutils
|
||||
sudo update-alternatives --remove-all clang-format || true
|
||||
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-10 100
|
||||
sudo pip3 install black==24.8.0 pygments
|
||||
|
||||
- name: File formatting checks (file_format.sh)
|
||||
run: |
|
||||
bash ./misc/scripts/file_format.sh
|
||||
|
||||
- name: Python style checks via black (black_format.sh)
|
||||
run: |
|
||||
bash ./misc/scripts/black_format.sh
|
||||
|
||||
- name: Documentation checks
|
||||
run: |
|
||||
doc/tools/makerst.py --dry-run doc/classes modules
|
||||
|
||||
- name: Style checks via clang-format (clang_format.sh)
|
||||
run: |
|
||||
bash ./misc/scripts/clang_format.sh
|
||||
73
.github/workflows/windows_builds.yml
vendored
73
.github/workflows/windows_builds.yml
vendored
@ -1,73 +0,0 @@
|
||||
name: 🏁 Windows Builds
|
||||
on:
|
||||
workflow_call:
|
||||
|
||||
# Global Settings
|
||||
# SCONS_CACHE for windows must be set in the build environment
|
||||
env:
|
||||
# Only used for the cache key. Increment version to force clean build.
|
||||
GODOT_BASE_BRANCH: 3.2
|
||||
SCONSFLAGS: verbose=yes warnings=all werror=yes debug_symbols=no
|
||||
SCONS_CACHE_MSVC_CONFIG: true
|
||||
|
||||
concurrency:
|
||||
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-windows
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build-windows:
|
||||
# Windows 10 with latest image
|
||||
runs-on: "windows-latest"
|
||||
name: ${{ matrix.name }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- name: Editor (target=release_debug, tools=yes)
|
||||
cache-name: windows-editor
|
||||
target: release_debug
|
||||
tools: true
|
||||
bin: "./bin/godot.windows.opt.tools.64.exe"
|
||||
|
||||
- name: Template (target=release, tools=no)
|
||||
cache-name: windows-template
|
||||
target: release
|
||||
tools: false
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Restore Godot build cache
|
||||
uses: ./.github/actions/godot-cache-restore
|
||||
with:
|
||||
cache-name: ${{ matrix.cache-name }}
|
||||
continue-on-error: true
|
||||
|
||||
- name: Setup python and scons
|
||||
uses: ./.github/actions/godot-deps
|
||||
|
||||
- name: Setup MSVC problem matcher
|
||||
uses: ammaraskar/msvc-problem-matcher@master
|
||||
|
||||
- name: Compilation
|
||||
uses: ./.github/actions/godot-build
|
||||
with:
|
||||
sconsflags: ${{ env.SCONSFLAGS }}
|
||||
platform: windows
|
||||
target: ${{ matrix.target }}
|
||||
tools: ${{ matrix.tools }}
|
||||
|
||||
- name: Save Godot build cache
|
||||
uses: ./.github/actions/godot-cache-save
|
||||
with:
|
||||
cache-name: ${{ matrix.cache-name }}
|
||||
continue-on-error: true
|
||||
|
||||
- name: Prepare artifact
|
||||
run: |
|
||||
Remove-Item bin/* -Include *.exp,*.lib,*.pdb -Force
|
||||
|
||||
- name: Upload artifact
|
||||
uses: ./.github/actions/upload-artifact
|
||||
with:
|
||||
name: ${{ matrix.cache-name }}
|
||||
89
.gitignore
vendored
89
.gitignore
vendored
@ -1,6 +1,5 @@
|
||||
# Godot auto generated files
|
||||
*.gen.*
|
||||
.import/
|
||||
|
||||
# Documentation generated by doxygen or from classes.xml
|
||||
doc/_build/
|
||||
@ -8,19 +7,18 @@ doc/_build/
|
||||
# Javascript specific
|
||||
*.bc
|
||||
|
||||
# CLion
|
||||
cmake-build-debug
|
||||
|
||||
# Android specific
|
||||
.gradle
|
||||
local.properties
|
||||
*.iml
|
||||
.idea
|
||||
.gradletasknamecache
|
||||
project.properties
|
||||
platform/android/java/app/libs/*
|
||||
platform/android/java/build.gradle
|
||||
platform/android/java/.gradle
|
||||
platform/android/java/.gradletasknamecache
|
||||
platform/android/java/local.properties
|
||||
platform/android/java/project.properties
|
||||
platform/android/java/build.gradle
|
||||
platform/android/java/AndroidManifest.xml
|
||||
platform/android/java/libs/*
|
||||
platform/android/java/lib/.cxx/
|
||||
platform/android/java/assets
|
||||
platform/android/java/.idea/*
|
||||
platform/android/java/*.iml
|
||||
|
||||
# General c++ generated files
|
||||
*.lib
|
||||
@ -33,8 +31,6 @@ platform/android/java/lib/.cxx/
|
||||
*.os
|
||||
*.Plo
|
||||
*.lo
|
||||
# Binutils tmp linker output of the form "stXXXXXX" where "X" is alphanumeric
|
||||
st[A-Za-z0-9][A-Za-z0-9][A-Za-z0-9][A-Za-z0-9][A-Za-z0-9][A-Za-z0-9]
|
||||
|
||||
# Libs generated files
|
||||
.deps/*
|
||||
@ -47,43 +43,31 @@ gmon.out
|
||||
*.swo
|
||||
*.swp
|
||||
|
||||
# Qt project files
|
||||
# QT project files
|
||||
*.config
|
||||
*.creator
|
||||
*.creator.*
|
||||
*.files
|
||||
*.includes
|
||||
*.cflags
|
||||
*.cxxflags
|
||||
|
||||
# Code::Blocks files
|
||||
*.cbp
|
||||
*.layout
|
||||
*.depend
|
||||
|
||||
# Eclipse CDT files
|
||||
.cproject
|
||||
.settings/
|
||||
*.pydevproject
|
||||
*.launch
|
||||
|
||||
# Geany/geany-plugins files
|
||||
*.geany
|
||||
.geanyprj
|
||||
|
||||
# Jetbrains IDEs
|
||||
.idea/
|
||||
|
||||
# Misc
|
||||
.DS_Store
|
||||
__MACOSX
|
||||
logs/
|
||||
|
||||
# for projects that use SCons for building: http://http://www.scons.org/
|
||||
.sconf_temp
|
||||
.sconsign*.dblite
|
||||
.sconsign.dblite
|
||||
*.pyc
|
||||
|
||||
|
||||
# https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
@ -95,9 +79,6 @@ logs/
|
||||
*.sln
|
||||
*.vcxproj*
|
||||
|
||||
# Custom SCons configuration override
|
||||
/custom.py
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
@ -110,9 +91,6 @@ bld/
|
||||
*.debug
|
||||
*.dSYM
|
||||
|
||||
# Visual Studio cache/options directory
|
||||
.vs/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
@ -120,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
|
||||
@ -143,7 +124,6 @@ TestResult.xml
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*.bak
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
@ -151,7 +131,6 @@ TestResult.xml
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
*.nib
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
@ -259,7 +238,6 @@ ClientBin/
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
node_modules/
|
||||
__pycache__/
|
||||
|
||||
# KDE
|
||||
.directory
|
||||
@ -267,11 +245,8 @@ __pycache__/
|
||||
#Kdevelop project files
|
||||
*.kdev4
|
||||
|
||||
# Xcode
|
||||
xcuserdata/
|
||||
*.xcscmblueprint
|
||||
*.xccheckout
|
||||
*.xcodeproj/*
|
||||
# xCode
|
||||
xcuserdata
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
@ -300,19 +275,11 @@ FakesAssemblies/
|
||||
# =========================
|
||||
|
||||
# Windows image file caches
|
||||
[Tt]humbs.db
|
||||
[Tt]humbs.db:encryptable
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
|
||||
# Windows stackdumps
|
||||
*.stackdump
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
# Folder config file
|
||||
[Dd]esktop.ini
|
||||
Desktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
@ -324,7 +291,6 @@ logo.h
|
||||
TAGS
|
||||
!TAGS/
|
||||
tags
|
||||
*.tags
|
||||
!tags/
|
||||
gtags.files
|
||||
GTAGS
|
||||
@ -346,20 +312,5 @@ platform/windows/godot_res.res
|
||||
# Visual Studio Code workspace file
|
||||
*.code-workspace
|
||||
|
||||
# Scons construction environment dump
|
||||
.scons_env.json
|
||||
|
||||
# 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
|
||||
|
||||
# Cppcheck
|
||||
*.cppcheck
|
||||
|
||||
# https://clangd.llvm.org/ cache folder
|
||||
.clangd/
|
||||
|
||||
18
.mailmap
18
.mailmap
@ -2,6 +2,10 @@ 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>
|
||||
@ -14,17 +18,12 @@ 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>
|
||||
Dominik 'dreamsComeTrue' Jasiński <dominikjasinski@o2.pl>
|
||||
Emmanuel Barroga <emmanuelbarroga@gmail.com>
|
||||
Eric M <itsjusteza@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>
|
||||
@ -66,20 +65,13 @@ 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>
|
||||
Liz Haas <27thLiz@gmail.com>
|
||||
Liz Haas <27thLiz@gmail.com> <liu.gam3@gmail.com>
|
||||
Liz Haas <27thLiz@gmail.com> <hinsbart@gmail.com>
|
||||
Liz Haas <27thLiz@gmail.com> <hinsbart@users.noreply.github.com>
|
||||
Liz Haas <27thLiz@gmail.com> <entenflugstuhl@gmail.com>
|
||||
Manuel Strey <manuel.strey@gmx.de>
|
||||
Marcelo Fernandez <marcelofg55@gmail.com>
|
||||
Marcin Zawiejski <dragmz@gmail.com>
|
||||
Marcus Elg <marcusaccounts@yahoo.se>
|
||||
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>
|
||||
Mateo Kuruk Miccino <mateomiccino@gmail.com>
|
||||
Max Hilbrunner <m.hilbrunner@gmail.com>
|
||||
Max Hilbrunner <m.hilbrunner@gmail.com> <mhilbrunner@users.noreply.github.com>
|
||||
Michael Alexsander <michaelalexsander@protonmail.com>
|
||||
@ -96,7 +88,6 @@ 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>
|
||||
@ -121,5 +112,4 @@ 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>
|
||||
|
||||
109
.travis.yml
Normal file
109
.travis.yml
Normal file
@ -0,0 +1,109 @@
|
||||
language: cpp
|
||||
|
||||
# OS config, depends on actual 'os' in build matrix
|
||||
dist: trusty
|
||||
sudo: false
|
||||
|
||||
env:
|
||||
global:
|
||||
- SCONS_CACHE=$HOME/.scons_cache/$TRAVIS_BRANCH
|
||||
- SCONS_CACHE_LIMIT=1024
|
||||
- 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:
|
||||
- $SCONS_CACHE
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- env: STATIC_CHECKS=yes
|
||||
os: linux
|
||||
compiler: gcc
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- llvm-toolchain-trusty-6.0
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- clang-format-6.0
|
||||
- libstdc++6 # >= 4.9 needed for clang-format-6.0
|
||||
|
||||
coverity_scan:
|
||||
project:
|
||||
name: "godotengine/godot"
|
||||
description: "Godot Engine Coverity scans"
|
||||
notification_email: coverity@godotengine.org
|
||||
build_command_prepend: ""
|
||||
build_command: "scons p=x11 -j2 $OPTIONS"
|
||||
branch_pattern: coverity_scan
|
||||
|
||||
- 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: gcc
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- 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:
|
||||
- *linux_deps
|
||||
|
||||
- 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:
|
||||
apt:
|
||||
packages:
|
||||
- *linux_deps
|
||||
|
||||
before_install:
|
||||
- if [ "$STATIC_CHECKS" = "yes" ]; then
|
||||
unset SCONS_CACHE;
|
||||
fi
|
||||
|
||||
install:
|
||||
- if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$GODOT_TARGET" = "android" ]; then
|
||||
misc/travis/android-tools-linux.sh;
|
||||
fi
|
||||
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then
|
||||
misc/travis/scons-local-osx.sh;
|
||||
fi
|
||||
- if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$GODOT_TARGET" = "android" ]; then
|
||||
misc/travis/android-tools-osx.sh;
|
||||
fi
|
||||
|
||||
before_script:
|
||||
- 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
|
||||
|
||||
script:
|
||||
- if [ "$STATIC_CHECKS" = "yes" ]; then
|
||||
sh ./misc/travis/clang-format.sh;
|
||||
else
|
||||
scons -j2 CC=$CC CXX=$CXX platform=$GODOT_TARGET TOOLS=$TOOLS $EXTRA_ARGS $OPTIONS;
|
||||
fi
|
||||
18
AUTHORS.md
18
AUTHORS.md
@ -32,6 +32,7 @@ name is available.
|
||||
Alexey Khoroshavin (allkhor)
|
||||
Alket Rexhepi (alketii)
|
||||
Andrea Catania (AndreaCatania)
|
||||
Andreas Haas (Hinsbart)
|
||||
Andrii Doroshenko (Xrayez)
|
||||
Andy Moss (MillionOstrich)
|
||||
Anish Bhobe (KidRigger)
|
||||
@ -60,13 +61,11 @@ name is available.
|
||||
David Sichma (DavidSichma)
|
||||
Dharkael (lupoDharkael)
|
||||
Dmitry Koteroff (Krakean)
|
||||
Dominik Jasiński (dreamsComeTrue)
|
||||
DualMatrix
|
||||
Emmanuel Barroga (codecustard)
|
||||
Emmanuel Leblond (touilleMan)
|
||||
Eoin O'Neill (Eoin-ONeill-Yokai)
|
||||
Eric Lasota (elasota)
|
||||
Eric M (EricEzaM)
|
||||
Eric Rybicki (ericrybick)
|
||||
Erik Selecký (rxlecky)
|
||||
est31
|
||||
@ -95,9 +94,7 @@ name is available.
|
||||
Indah Sylvia (ISylvox)
|
||||
J08nY
|
||||
Jakub Grzesik (kubecz3k)
|
||||
James Buck (jbuck3)
|
||||
Jérôme Gully (Nutriz)
|
||||
Jia Jun Chai (SkyLucilfer)
|
||||
Joan Fons Sanchez (JFonS)
|
||||
Johan Manuel (29jm)
|
||||
Joshua Grams (JoshuaGrams)
|
||||
@ -107,18 +104,13 @@ name is available.
|
||||
Kelly Thomas (KellyThomas)
|
||||
Kostadin Damyanov (Max-Might)
|
||||
K. S. Ernest (iFire) Lee (fire)
|
||||
lawnjelly
|
||||
Leon Krause (leonkrause)
|
||||
Liz Haas (27thLiz)
|
||||
Leon Krause (eska014)
|
||||
Lucien Menassol (Kanabenki)
|
||||
m4nu3lf
|
||||
Maganty Rushyendra (mrushyendra)
|
||||
Marcel Admiraal (madmiraal)
|
||||
Marcelo Fernandez (marcelofg55)
|
||||
Marc Gilleron (Zylann)
|
||||
Marcin Zawiejski (dragmz)
|
||||
Marcus Brummer (mbrlabs)
|
||||
Marcus (MCrafterzz)
|
||||
Mariano Javier Suligoy (MarianoGnu)
|
||||
Mario Schlack (hurikhan)
|
||||
Martin Capitanio (capnm)
|
||||
@ -126,7 +118,6 @@ name is available.
|
||||
Martin Sjursen (binbitten)
|
||||
marynate
|
||||
Masoud BH (masoudbh3)
|
||||
Mateo Kuruk Miccino (kuruk-mm)
|
||||
Matthias Hölzl (hoelzl)
|
||||
Max Hilbrunner (mhilbrunner)
|
||||
merumelu
|
||||
@ -136,7 +127,6 @@ name is available.
|
||||
muiroc
|
||||
Nathan Warden (NathanWarden)
|
||||
Nils André-Chang (NilsIrl)
|
||||
Noah Beard (TwistedTwigleg)
|
||||
Nuno Donato (nunodonato)
|
||||
Ovnuniarchos
|
||||
Pascal Richter (ShyRed)
|
||||
@ -160,17 +150,13 @@ name is available.
|
||||
Robin Hübner (profan)
|
||||
romulox-x
|
||||
Ruslan Mustakov (endragor)
|
||||
Ryan Roden-Corrent (rrcore)
|
||||
Saniko (sanikoyes)
|
||||
santouits
|
||||
SaracenOne
|
||||
Sergey Minakov (naithar)
|
||||
sersoong
|
||||
Shiqing (kawa-yoiko)
|
||||
Simon Wenner (swenner)
|
||||
Stijn Hinlopen (hinlopen)
|
||||
Swarnim Arun (minraws)
|
||||
Thakee Nathees (ThakeeNathees)
|
||||
Theo Hallenius (TheoXD)
|
||||
Thomas Herzog (karroffel)
|
||||
Timo Schwarzer (timoschwarzer)
|
||||
|
||||
1257
CHANGELOG.md
1257
CHANGELOG.md
File diff suppressed because it is too large
Load Diff
183
CONTRIBUTING.md
183
CONTRIBUTING.md
@ -1,141 +1,80 @@
|
||||
# How to contribute efficiently
|
||||
|
||||
## Table of contents
|
||||
Sections covered in this file:
|
||||
|
||||
- [Reporting bugs](#reporting-bugs)
|
||||
- [Proposing features or improvements](#proposing-features-or-improvements)
|
||||
- [Contributing pull requests](#contributing-pull-requests)
|
||||
- [Contributing to Godot's translation](#contributing-to-godots-translation)
|
||||
- [Communicating with developers](#communicating-with-developers)
|
||||
* [Reporting bugs or proposing features](#reporting-bugs-or-proposing-features)
|
||||
* [Contributing pull requests](#contributing-pull-requests)
|
||||
* [Contributing to Godot's translation](#contributing-to-godots-translation)
|
||||
* [Communicating with developers](#communicating-with-developers)
|
||||
|
||||
**Please read the first section before reporting a bug!**
|
||||
|
||||
## Reporting bugs
|
||||
## Reporting bugs or proposing features
|
||||
|
||||
The golden rule is to **always open *one* issue for *one* bug**. If you notice
|
||||
several bugs and want to report them, make sure to create one new issue for
|
||||
each of them.
|
||||
|
||||
If you're reporting a new bug, you'll make our life simpler (and the
|
||||
fix will come sooner) by following these guidelines:
|
||||
Everything referred to hereafter as "bug" also applies for feature requests.
|
||||
|
||||
### Search first in the existing database
|
||||
If you are reporting a new issue, you will make our life much simpler (and the
|
||||
fix come much sooner) by following those guidelines:
|
||||
|
||||
Issues are often reported several times by various users. It's good practice to
|
||||
**search first in the [issue tracker](https://github.com/godotengine/godot/issues)
|
||||
before reporting your issue**. If you don't find a relevant match or if you're
|
||||
unsure, don't hesitate to **open a new issue**. The bugsquad will handle it
|
||||
from there if it's a duplicate.
|
||||
#### Search first in the existing database
|
||||
|
||||
### Specify the platform
|
||||
Issues are often reported several times by various users. It's a good practice
|
||||
to **search first** in the issues database before reporting your issue. If you
|
||||
don't find a relevant match or if you are unsure, don't hesitate to **open a
|
||||
new issue**. The bugsquad will handle it from there if it's a duplicate.
|
||||
|
||||
#### Specify the platform
|
||||
|
||||
Godot runs on a large variety of platforms and operating systems and devices.
|
||||
**In your bug reports, please always specify:**
|
||||
If you believe your issue is device/platform dependent (for example if it is
|
||||
related to the rendering, crashes or compilation errors), please specify:
|
||||
* Operating system
|
||||
* Device (including architecture, e.g. x86, x86_64, arm, etc.)
|
||||
* GPU model (and driver in use if you know it)
|
||||
|
||||
- Operating system and version (e.g. Windows 10, macOS 10.15, Ubuntu 19.10)
|
||||
- Godot version (e.g. 3.2, 3.1.2, or the Git commit hash if you're using a development branch)
|
||||
|
||||
For bugs that are likely OS-specific and/or graphics-related, please also specify:
|
||||
|
||||
- Device (CPU model including architecture, e.g. x86, x86_64, ARM, etc.)
|
||||
- GPU model (and the driver version in use if you know it)
|
||||
|
||||
**Bug reports not including the required information may be closed at the
|
||||
maintainers' discretion.** If in doubt, always include all the requested
|
||||
information; it's better to include too much information than not enough
|
||||
information.
|
||||
|
||||
### Specify steps to reproduce
|
||||
#### Specify steps to reproduce
|
||||
|
||||
Many bugs can't be reproduced unless specific steps are taken. Please **specify
|
||||
the exact steps** that must be taken to reproduce the condition, and try to
|
||||
keep them as minimal as possible. If you're describing a procedure to follow
|
||||
in the editor, don't hesitate to include screenshots.
|
||||
keep them as minimal as possible.
|
||||
|
||||
Making your bug report easy to reproduce will make it easier for contributors
|
||||
to fix the bug.
|
||||
#### Provide a simple, example project
|
||||
|
||||
### Provide a simple, example project
|
||||
|
||||
Sometimes, unexpected behavior can happen in your project. In such case,
|
||||
Sometimes an unexpected behavior happens in your project. In such case,
|
||||
understand that:
|
||||
|
||||
- What happens to you may not happen to other users.
|
||||
- We can't take the time to look at your project, understand how it is set up
|
||||
* What happens to you may not happen to other users.
|
||||
* We can't take the time to look at your project, understand how it is set up
|
||||
and then figure out why it's failing.
|
||||
|
||||
To speed up our work, **please upload a minimal project** that isolates
|
||||
and reproduces the issue. This is always the **best way for us to fix it**.
|
||||
You can attach a ZIP file with the minimal project directly to the bug report,
|
||||
To speed up our work, please prepare for us **a simple project** that isolates
|
||||
and reproduces the issue. This is always the **the best way for us to fix it**.
|
||||
You can attach a zip file with the minimal project directly to the bug report,
|
||||
by drag and dropping the file in the GitHub edition field.
|
||||
|
||||
We recommend always attaching a minimal reproduction project, even if the issue
|
||||
may seem simple to reproduce manually.
|
||||
|
||||
**If you've been asked by a maintainer to upload a minimal reproduction project,
|
||||
you *must* do so within 7 days.** Otherwise, your bug report will be closed as
|
||||
it'll be considered too difficult to diagnose.
|
||||
|
||||
Now that you've read the guidelines, click the link below to create a
|
||||
bug report:
|
||||
|
||||
- **[Report a bug](https://github.com/godotengine/godot/issues/new?assignees=&labels=&template=bug_report.md&title=)**
|
||||
|
||||
## Proposing features or improvements
|
||||
|
||||
**Since August 2019, the main issue tracker no longer accepts feature proposals.**
|
||||
Instead, head to the [Godot Proposals repository](https://github.com/godotengine/godot-proposals)
|
||||
and follow the instructions in the README file. High-quality feature proposals
|
||||
are more likely to be well-received by the maintainers and community, so do
|
||||
your best :)
|
||||
|
||||
See [this article](https://godotengine.org/article/introducing-godot-proposals-repository)
|
||||
for detailed rationale on this change.
|
||||
|
||||
## Contributing pull requests
|
||||
|
||||
If you want to add new engine features, please make sure that:
|
||||
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.
|
||||
- You talked to other developers on how to implement it best. See also
|
||||
[Proposing features or improvements](#proposing-features-or-improvements).
|
||||
- Even if it doesn't get merged, your PR is useful for future work by another
|
||||
* 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).
|
||||
* Even if it does not get merged, your PR is useful for future work by another
|
||||
developer.
|
||||
|
||||
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/)
|
||||
[Engine development guide](http://docs.godotengine.org/en/latest/development/cpp/)
|
||||
for an introduction to developing on Godot.
|
||||
|
||||
The [Contributing docs](https://docs.godotengine.org/en/latest/community/contributing/index.html)
|
||||
also have important information on the PR workflow and the code style we use.
|
||||
|
||||
### Document your changes
|
||||
|
||||
If your pull request adds methods, properties or signals that are exposed to
|
||||
scripting APIs, you **must** update the class reference to document those.
|
||||
This is to ensure the documentation coverage doesn't decrease as contributions
|
||||
are merged.
|
||||
|
||||
[Update the documentation template](https://docs.godotengine.org/en/latest/community/contributing/updating_the_class_reference.html#updating-the-documentation-template)
|
||||
using your compiled binary, then fill in the descriptions.
|
||||
Follow the style guide described in the
|
||||
[Docs writing guidelines](https://docs.godotengine.org/en/latest/community/contributing/docs_writing_guidelines.html).
|
||||
|
||||
If your pull request modifies parts of the code in a non-obvious way, make sure
|
||||
to add comments in the code as well. This helps other people understand the
|
||||
change without having to look at `git blame`.
|
||||
|
||||
### Be nice to the Git history
|
||||
#### 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
|
||||
@ -151,31 +90,30 @@ commit, try to merge them together before making your pull request (see ``git
|
||||
rebase -i`` and relevant help about rebasing or amending commits on the
|
||||
Internet).
|
||||
|
||||
This [Git style guide](https://github.com/agis-/git-style-guide) has some
|
||||
good practices to have in mind.
|
||||
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](https://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
|
||||
|
||||
### Format your commit messages with readability in mind
|
||||
|
||||
The way you format your commit messages is quite important to ensure that the
|
||||
commit history and changelog will be easy to read and understand. A Git commit
|
||||
message is formatted as a short title (first line) and an extended description
|
||||
The way you format your commit logs is quite important to ensure that the
|
||||
commit history and changelog will be easy to read and understand. A git commit
|
||||
log is formatted as a short title (first line) and an extended description
|
||||
(everything after the first line and an empty separation line).
|
||||
|
||||
The short title is the most important part, as it is what will appear in the
|
||||
`shortlog` changelog (one line per commit, so no description shown) or in the
|
||||
GitHub interface unless you click the "expand" button. As the name says, try to
|
||||
keep that first line under 72 characters. It should describe what the commit
|
||||
does globally, while details would go in the description. Typically, if you
|
||||
can't keep the title short because you have too much stuff to mention, it means
|
||||
you should probably split your changes in several commits :)
|
||||
GitHub interface unless you click the "expand" button. As the name tells it,
|
||||
try to keep that first line relatively short (ideally <= 50 chars, though it's
|
||||
rare to be able to tell enough in so few characters, so you can go a bit
|
||||
higher) - it should describe what the commit does globally, while details would
|
||||
go in the description. Typically, if you can't keep the title short because you
|
||||
have too much stuff to mention, it means that you should probably split your
|
||||
changes in several commits :)
|
||||
|
||||
Here's an example of a well-formatted commit message (note how the extended
|
||||
Here's an example of a well-formatted commit log (note how the extended
|
||||
description is also manually wrapped at 80 chars for readability):
|
||||
|
||||
```text
|
||||
```
|
||||
Prevent French fries carbonization by fixing heat regulation
|
||||
|
||||
When using the French fries frying module, Godot would not regulate the heat
|
||||
@ -189,9 +127,9 @@ of cooking oil under normal atmospheric conditions.
|
||||
Fixes #1789, long live the Realm!
|
||||
```
|
||||
|
||||
**Note:** When using the GitHub online editor or its drag-and-drop
|
||||
feature, *please* edit the commit title to something meaningful. Commits named
|
||||
"Update my_file.cpp" won't be accepted.
|
||||
*Note:* When using the GitHub online editor (or worse, the drag and drop
|
||||
feature), *please* edit the commit title to something meaningful. Commits named
|
||||
"Update my_file.cpp" will not be accepted.
|
||||
|
||||
## Contributing to Godot's translation
|
||||
|
||||
@ -200,10 +138,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
|
||||
@ -212,7 +146,6 @@ discussions and support, others more for development discussions.
|
||||
|
||||
To communicate with developers (e.g. to discuss a feature you want to implement
|
||||
or a bug you want to fix), the following channels can be used:
|
||||
|
||||
- [GitHub issues](https://github.com/godotengine/godot/issues): If there is an
|
||||
existing issue about a topic you want to discuss, just add a comment to it -
|
||||
all developers watch the repository and will get an email notification. You
|
||||
@ -233,6 +166,6 @@ or a bug you want to fix), the following channels can be used:
|
||||
page](https://listengine.tuxfamily.org/godotengine.org/devel/) for
|
||||
subscription instructions.
|
||||
|
||||
Thanks for your interest in contributing!
|
||||
Thanks!
|
||||
|
||||
—The Godot development team
|
||||
The Godot development team
|
||||
|
||||
415
COPYRIGHT.txt
415
COPYRIGHT.txt
@ -43,8 +43,8 @@ Source: https://github.com/godotengine/godot
|
||||
|
||||
Files: *
|
||||
Comment: Godot Engine
|
||||
Copyright: 2007-2020, Juan Linietsky, Ariel Manzur.
|
||||
2014-2020, Godot Engine contributors.
|
||||
Copyright: 2007-2019, Juan Linietsky, Ariel Manzur.
|
||||
2014-2019, Godot Engine contributors.
|
||||
License: Expat
|
||||
|
||||
Files: ./icon.png
|
||||
@ -55,16 +55,31 @@ Comment: Godot Engine logo
|
||||
Copyright: 2017, Andrea Calabró
|
||||
License: CC-BY-3.0
|
||||
|
||||
Files: ./platform/android/java/aidl/com/android/vending/billing/IInAppBillingService.aidl
|
||||
Files: ./platform/android/android_native_app_glue.c
|
||||
./platform/android/android_native_app_glue.h
|
||||
./platform/android/java/aidl/com/android/vending/billing/IInAppBillingService.aidl
|
||||
./platform/android/java/res/layout/status_bar_ongoing_event_progress_bar.xml
|
||||
./platform/android/java/src/com/android/vending/licensing/*
|
||||
./platform/android/java/src/com/google/android/vending/expansion/downloader/*
|
||||
./platform/android/java/src/com/google/android/vending/licensing/*
|
||||
./platform/android/java/src/org/godotengine/godot/input/InputManagerCompat.java
|
||||
./platform/android/java/src/org/godotengine/godot/input/InputManagerV16.java
|
||||
./platform/android/java/src/org/godotengine/godot/input/InputManagerV9.java
|
||||
Comment: The Android Open Source Project
|
||||
Copyright: 2008-2013, The Android Open Source Project
|
||||
License: Apache-2.0
|
||||
|
||||
Files: ./platform/android/cpu-features.c
|
||||
./platform/android/cpu-features.h
|
||||
Comment: The Android Open Source Project
|
||||
Copyright: 2010, The Android Open Source Project
|
||||
License: BSD-2-clause
|
||||
|
||||
Files: ./platform/android/ifaddrs_android.cpp
|
||||
./platform/android/ifaddrs_android.h
|
||||
Comment: The Android Open Source Project
|
||||
Copyright: 2012-2013, Google Inc.
|
||||
License: BSD-3-clause
|
||||
|
||||
Files: ./platform/android/java/src/com/android/vending/licensing/util/Base64.java
|
||||
./platform/android/java/src/com/android/vending/licensing/util/Base64DecoderException.java
|
||||
Comment: The Android Open Source Project
|
||||
@ -77,15 +92,10 @@ Files: ./platform/android/power_android.cpp
|
||||
./platform/x11/power_x11.cpp
|
||||
Comment: Simple DirectMedia Layer
|
||||
Copyright: 1997-2017, Sam Lantinga
|
||||
2007-2020, Juan Linietsky, Ariel Manzur.
|
||||
2014-2020, Godot Engine contributors.
|
||||
2007-2019, Juan Linietsky, Ariel Manzur.
|
||||
2014-2019, Godot Engine contributors.
|
||||
License: Expat and Zlib
|
||||
|
||||
Files: ./scene/animation/tween_interpolaters.cpp
|
||||
Comment: Penner Easing
|
||||
Copyright: 2001, Robert Penner
|
||||
License: BSD-3-clause
|
||||
|
||||
Files: ./servers/physics/gjk_epa.cpp
|
||||
./servers/physics/joints/generic_6dof_joint_sw.cpp
|
||||
./servers/physics/joints/generic_6dof_joint_sw.h
|
||||
@ -98,26 +108,27 @@ Files: ./servers/physics/gjk_epa.cpp
|
||||
./servers/physics/joints/slider_joint_sw.h
|
||||
Comment: Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright: 2003-2008, Erwin Coumans
|
||||
2007-2020, Juan Linietsky, Ariel Manzur.
|
||||
2014-2020, Godot Engine contributors.
|
||||
2007-2019, Juan Linietsky, Ariel Manzur.
|
||||
2014-2019, Godot Engine contributors.
|
||||
License: Expat and Zlib
|
||||
|
||||
Files: ./servers/physics/joints/cone_twist_joint_sw.cpp
|
||||
./servers/physics/joints/cone_twist_joint_sw.h
|
||||
Comment: Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright: 2007, Starbreeze Studios
|
||||
2007-2020, Juan Linietsky, Ariel Manzur.
|
||||
2014-2020, Godot Engine contributors.
|
||||
2007-2019, Juan Linietsky, Ariel Manzur.
|
||||
2014-2019, Godot Engine contributors.
|
||||
License: Expat and Zlib
|
||||
|
||||
Files: ./thirdparty/assimp/
|
||||
Comment: Open Asset Import Library (assimp)
|
||||
Copyright: 2006-2016, assimp team
|
||||
License: BSD-3-clause
|
||||
Files: ./thirdparty/b2d_convexdecomp/
|
||||
Comment: Box2D (ConvexDecomp)
|
||||
Copyright: 2007, Eric Jordan
|
||||
2006-2009, Erin Catto
|
||||
License: Zlib
|
||||
|
||||
Files: ./thirdparty/bullet/
|
||||
Comment: Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright: 2003-2013, Erwin Coumans
|
||||
Copyright: 2003-2008, Erwin Coumans
|
||||
License: Zlib
|
||||
|
||||
Files: ./thirdparty/certs/ca-certificates.crt
|
||||
@ -125,15 +136,9 @@ Comment: CA certificates
|
||||
Copyright: Mozilla Contributors
|
||||
License: MPL-2.0
|
||||
|
||||
Files: ./thirdparty/cvtt/
|
||||
Comment: Convection Texture Tools Stand-Alone Kernels
|
||||
Copyright: 2018, Eric Lasota
|
||||
2018, Microsoft Corp.
|
||||
License: Expat
|
||||
|
||||
Files: ./thirdparty/enet/
|
||||
Comment: ENet
|
||||
Copyright: 2002-2020, Lee Salzman
|
||||
Copyright: 2002-2016, Lee Salzman
|
||||
License: Expat
|
||||
|
||||
Files: ./thirdparty/etc2comp/
|
||||
@ -159,12 +164,12 @@ License: Expat and Bitstream Vera Fonts Copyright
|
||||
|
||||
Files: ./thirdparty/freetype/
|
||||
Comment: The FreeType Project
|
||||
Copyright: 1996-2020, David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
Copyright: 1996-2017, David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
License: FTL
|
||||
|
||||
Files: ./thirdparty/glad/
|
||||
Comment: glad
|
||||
Copyright: 2013-2019, David Herberth
|
||||
Copyright: 2013, David Herberth
|
||||
License: Expat
|
||||
|
||||
Files: ./thirdparty/jpeg_compressor/
|
||||
@ -211,49 +216,42 @@ Comment: The WebM Project
|
||||
Copyright: 2010, The WebM Project authors.
|
||||
License: BSD-3-clause
|
||||
|
||||
Files: ./thirdparty/libvpx/third_party/android/cpu-features.c
|
||||
./thirdparty/libvpx/third_party/android/cpu-features.h
|
||||
Comment: The Android Open Source Project
|
||||
Copyright: 2010, The Android Open Source Project
|
||||
License: BSD-2-clause
|
||||
|
||||
Files: ./thirdparty/libwebp/
|
||||
Comment: WebP codec
|
||||
Copyright: 2010, Google Inc.
|
||||
License: BSD-3-clause
|
||||
|
||||
Files: ./thirdparty/mbedtls/
|
||||
Comment: Mbed TLS
|
||||
Copyright: 2006-2018, Arm Limited (or its affiliates)
|
||||
License: Apache-2.0
|
||||
|
||||
Files: ./thirdparty/miniupnpc/
|
||||
Comment: MiniUPnPc
|
||||
Copyright: 2005-2018, Thomas Bernard
|
||||
License: BSD-3-clause
|
||||
|
||||
Files: ./thirdparty/minizip/
|
||||
Comment: MiniZip
|
||||
Copyright: 1998-2010, Gilles Vollant
|
||||
2007-2008, Even Rouault
|
||||
2009-2010, Mathias Svensson
|
||||
2007-2008, Even Rouault
|
||||
2009-2010, Mathias Svensson
|
||||
License: Zlib
|
||||
|
||||
Files: ./thirdparty/misc/clipper.cpp
|
||||
./thirdparty/misc/clipper.hpp
|
||||
Comment: Clipper
|
||||
Copyright: 2010-2017, Angus Johnson
|
||||
License: BSL-1.0
|
||||
Files: ./thirdparty/misc/aes256.cpp
|
||||
./thirdparty/misc/aes256.h
|
||||
./thirdparty/misc/sha256.c
|
||||
./thirdparty/misc/sha256.h
|
||||
Comment: AES-256 and SHA-256 implementation
|
||||
Copyright: 2007-2011, Ilya O. Levin
|
||||
License: ISC
|
||||
|
||||
Files: ./thirdparty/misc/easing_equations.cpp
|
||||
Comment: Robert Penner's Easing Functions
|
||||
Copyright: 2001, Robert Penner
|
||||
License: BSD-3-clause
|
||||
Files: ./thirdparty/misc/base64.c
|
||||
./thirdparty/misc/base64.h
|
||||
Comment: BASE64 conversion methods
|
||||
Copyright: Ari Edelkind
|
||||
License: public-domain
|
||||
|
||||
Files: ./thirdparty/misc/curl_hostcheck.c
|
||||
./thirdparty/misc/curl_hostcheck.h
|
||||
Comment: curl
|
||||
Copyright: 1998-2012, Daniel Stenberg et al.
|
||||
License: curl
|
||||
|
||||
Files: ./thirdparty/misc/fastlz.c
|
||||
./thirdparty/misc/fastlz.h
|
||||
Comment: FastLZ
|
||||
Copyright: 2005-2020, Ariya Hidayat
|
||||
Copyright: 2005-2007, Ariya Hidayat
|
||||
License: Expat
|
||||
|
||||
Files: ./thirdparty/misc/hq2x.cpp
|
||||
@ -262,11 +260,11 @@ Comment: hq2x implementation
|
||||
Copyright: 2016, Bruno Ribeiro
|
||||
License: Apache-2.0
|
||||
|
||||
Files: ./thirdparty/misc/ifaddrs-android.cc
|
||||
./thirdparty/misc/ifaddrs-android.h
|
||||
Comment: libjingle
|
||||
Copyright: 2012-2013, Google Inc.
|
||||
License: BSD-3-clause
|
||||
Files: ./thirdparty/misc/md5.cpp
|
||||
./thirdparty/misc/md5.h
|
||||
Comment: MD5 Message Digest Algorithm
|
||||
Copyright: 1990, RSA Data Security, Inc.
|
||||
License: RSA-MD
|
||||
|
||||
Files: ./thirdparty/misc/mikktspace.c
|
||||
./thirdparty/misc/mikktspace.h
|
||||
@ -286,6 +284,12 @@ Comment: SMAZ
|
||||
Copyright: 2006-2009, Salvatore Sanfilippo
|
||||
License: BSD-3-clause
|
||||
|
||||
Files: ./thirdparty/misc/stb_truetype.h
|
||||
./thirdparty/misc/stb_vorbis.c
|
||||
Comment: stb libraries
|
||||
Copyright: 2007-2019, Sean Barrett
|
||||
License: public-domain
|
||||
|
||||
Files: ./thirdparty/misc/triangulator.cpp
|
||||
./thirdparty/misc/triangulator.h
|
||||
Comment: PolyPartition
|
||||
@ -302,6 +306,11 @@ Comment: NanoSVG
|
||||
Copyright: 2013-2014, Mikko Mononen
|
||||
License: Zlib
|
||||
|
||||
Files: ./thirdparty/openssl/
|
||||
Comment: The OpenSSL Project
|
||||
Copyright: 1998-2019, The OpenSSL Project.
|
||||
License: OpenSSL
|
||||
|
||||
Files: ./thirdparty/opus/
|
||||
Comment: Opus
|
||||
Copyright: 2001-2011, Xiph.Org, Skype Limited, Octasic,
|
||||
@ -312,8 +321,8 @@ License: BSD-3-clause
|
||||
|
||||
Files: ./thirdparty/pcre2/
|
||||
Comment: PCRE2
|
||||
Copyright: 1997-2019, University of Cambridge,
|
||||
2009-2019, Zoltan Herczeg
|
||||
Copyright: 1997-2017, University of Cambridge,
|
||||
2009-2017, Zoltan Herczeg
|
||||
License: BSD-3-clause
|
||||
|
||||
Files: ./thirdparty/pvrtccompressor/
|
||||
@ -326,35 +335,30 @@ Comment: Recast
|
||||
Copyright: 2009, Mikko Mononen
|
||||
License: Zlib
|
||||
|
||||
Files: ./thirdparty/rtaudio/
|
||||
Comment: RtAudio
|
||||
Copyright: 2001-2016, Gary P. Scavone
|
||||
License: Expat
|
||||
|
||||
Files: ./thirdparty/squish/
|
||||
Comment: libSquish
|
||||
Copyright: 2006, Simon Brown
|
||||
License: Expat
|
||||
|
||||
Files: ./thirdparty/thekla_atlas/
|
||||
Comment: Thekla Atlas
|
||||
Copyright: 2013, Thekla, Inc
|
||||
2009-2017, Ignacio Castaño
|
||||
2007-2009, NVIDIA Corporation
|
||||
2004, Brian Hook
|
||||
License: Expat and BSD-3-clause
|
||||
|
||||
Files: ./thirdparty/tinyexr/
|
||||
Comment: TinyEXR
|
||||
Copyright: 2014-2019, Syoyo Fujita
|
||||
Copyright: 2014-2018, Syoyo Fujita
|
||||
2002, Industrial Light & Magic, a division of Lucas Digital Ltd. LLC
|
||||
License: BSD-3-clause
|
||||
|
||||
Files: ./thirdparty/vhacd/
|
||||
Comment: V-HACD
|
||||
Copyright: 2011, Khaled Mamou
|
||||
2003-2009, Erwin Coumans
|
||||
License: BSD-3-clause
|
||||
|
||||
Files: ./thirdparty/wslay/
|
||||
Comment: Wslay
|
||||
Copyright: 2011-2015, Tatsuhiro Tsujikawa
|
||||
License: Expat
|
||||
|
||||
Files: ./thirdparty/xatlas/
|
||||
Comment: xatlas
|
||||
Copyright: 2018-2020, Jonathan Young
|
||||
2013, Thekla, Inc
|
||||
2006, NVIDIA Corporation, Ignacio Castano
|
||||
License: Expat
|
||||
|
||||
Files: ./thirdparty/zlib/
|
||||
Comment: zlib
|
||||
Copyright: 1995-2017, Jean-loup Gailly and Mark Adler
|
||||
@ -362,7 +366,7 @@ License: Zlib
|
||||
|
||||
Files: ./thirdparty/zstd/
|
||||
Comment: Zstandard
|
||||
Copyright: 2016-2019, Facebook, Inc.
|
||||
Copyright: 2016-2018, Facebook, Inc.
|
||||
License: BSD-3-clause
|
||||
|
||||
|
||||
@ -380,6 +384,30 @@ License: Apache-2.0
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
License: BSD-2-clause
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
.
|
||||
Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
.
|
||||
Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or
|
||||
other materials provided with the distribution. Neither the name of the author
|
||||
nor the names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
.
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
License: Bitstream Vera Fonts Copyright
|
||||
Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is a
|
||||
trademark of Bitstream, Inc.
|
||||
@ -422,28 +450,6 @@ License: Bitstream Vera Fonts Copyright
|
||||
authorization from the GNOME Foundation or Bitstream Inc., respectively. For
|
||||
further information, contact: fonts at gnome dot org.
|
||||
|
||||
License: BSD-2-clause
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
.
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
.
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
License: BSD-3-clause
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
@ -472,31 +478,6 @@ License: BSD-3-clause
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
|
||||
License: BSL-1.0
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
.
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
.
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
.
|
||||
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, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
License: CC-BY-3.0
|
||||
Creative Commons Attribution 3.0 Unported
|
||||
.
|
||||
@ -832,6 +813,25 @@ License: CC-BY-3.0
|
||||
.
|
||||
Creative Commons may be contacted at http://creativecommons.org/.
|
||||
|
||||
License: curl
|
||||
All rights reserved.
|
||||
.
|
||||
Permission to use, copy, modify, and distribute this software for any purpose
|
||||
with or without fee is hereby granted, provided that the above copyright
|
||||
notice and this permission notice appear in all copies.
|
||||
.
|
||||
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 OF THIRD PARTY RIGHTS. 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.
|
||||
.
|
||||
Except as contained in this notice, the name of a copyright holder shall not
|
||||
be used in advertising or otherwise to promote the sale, use or other dealings
|
||||
in this Software without prior written authorization of the copyright holder.
|
||||
|
||||
License: Expat
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
@ -1015,6 +1015,19 @@ License: FTL
|
||||
Robert Wilhelm <robert.wilhelm@freetype.org>
|
||||
Werner Lemberg <werner.lemberg@freetype.org>
|
||||
|
||||
License: ISC
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
.
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
License: MPL-2.0
|
||||
Mozilla Public License Version 2.0
|
||||
==================================
|
||||
@ -1473,6 +1486,146 @@ License: OFL-1.1
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE.
|
||||
|
||||
License: OpenSSL
|
||||
LICENSE ISSUES
|
||||
==============
|
||||
.
|
||||
The OpenSSL toolkit stays under a double license, i.e. both the conditions of
|
||||
the OpenSSL License and the original SSLeay license apply to the toolkit.
|
||||
See below for the actual license texts.
|
||||
.
|
||||
OpenSSL License
|
||||
---------------
|
||||
.
|
||||
====================================================================
|
||||
Copyright (c) 1998-2017 The OpenSSL Project. All rights reserved.
|
||||
.
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
.
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
.
|
||||
3. All advertising materials mentioning features or use of this
|
||||
software must display the following acknowledgment:
|
||||
"This product includes software developed by the OpenSSL Project
|
||||
for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
.
|
||||
4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
endorse or promote products derived from this software without
|
||||
prior written permission. For written permission, please contact
|
||||
openssl-core@openssl.org.
|
||||
.
|
||||
5. Products derived from this software may not be called "OpenSSL"
|
||||
nor may "OpenSSL" appear in their names without prior written
|
||||
permission of the OpenSSL Project.
|
||||
.
|
||||
6. Redistributions of any form whatsoever must retain the following
|
||||
acknowledgment:
|
||||
"This product includes software developed by the OpenSSL Project
|
||||
for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
.
|
||||
THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
====================================================================
|
||||
.
|
||||
This product includes cryptographic software written by Eric Young
|
||||
(eay@cryptsoft.com). This product includes software written by Tim
|
||||
Hudson (tjh@cryptsoft.com).
|
||||
.
|
||||
Original SSLeay License
|
||||
-----------------------
|
||||
.
|
||||
Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
All rights reserved.
|
||||
.
|
||||
This package is an SSL implementation written
|
||||
by Eric Young (eay@cryptsoft.com).
|
||||
The implementation was written so as to conform with Netscapes SSL.
|
||||
.
|
||||
This library is free for commercial and non-commercial use as long as
|
||||
the following conditions are aheared to. The following conditions
|
||||
apply to all code found in this distribution, be it the RC4, RSA,
|
||||
lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
included with this distribution is covered by the same copyright terms
|
||||
except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
.
|
||||
Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
the code are not to be removed.
|
||||
If this package is used in a product, Eric Young should be given attribution
|
||||
as the author of the parts of the library used.
|
||||
This can be in the form of a textual message at program startup or
|
||||
in documentation (online or textual) provided with the package.
|
||||
.
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
"This product includes cryptographic software written by
|
||||
Eric Young (eay@cryptsoft.com)"
|
||||
The word 'cryptographic' can be left out if the rouines from the library
|
||||
being used are not cryptographic related :-).
|
||||
4. If you include any Windows specific code (or a derivative thereof) from
|
||||
the apps directory (application code) you must include an acknowledgement:
|
||||
"This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
.
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
.
|
||||
The licence and distribution terms for any publically available version or
|
||||
derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
copied and put under another distribution licence
|
||||
[including the GNU Public Licence.]
|
||||
|
||||
License: RSA-MD
|
||||
License to copy and use this software is granted provided that it is
|
||||
identified as the "RSA Data Security, Inc. MD5 Message-Digest Algorithm"
|
||||
in all material mentioning or referencing this software or this function.
|
||||
.
|
||||
License is also granted to make and use derivative works provided that such
|
||||
works are identified as "derived from the RSA Data Security, Inc. MD5
|
||||
Message-Digest Algorithm" in all material mentioning or referencing the
|
||||
derived work.
|
||||
.
|
||||
RSA Data Security, Inc. makes no representations concerning either the
|
||||
merchantability of this software or the suitability of this software for
|
||||
any particular purpose. It is provided "as is" without express or implied
|
||||
warranty of any kind.
|
||||
.
|
||||
These notices must be retained in any copies of any part of this
|
||||
documentation and/or software.
|
||||
|
||||
License: Zlib
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
475
DONORS.md
475
DONORS.md
@ -12,486 +12,388 @@ generous deed immortalized in the next stable release of Godot Engine.
|
||||
|
||||
## Platinum sponsors
|
||||
|
||||
Gamblify <https://www.gamblify.com>
|
||||
Heroic Labs <https://heroiclabs.com>
|
||||
Interblock <http://interblockgaming.com>
|
||||
|
||||
## Gold sponsors
|
||||
|
||||
None currently, become one! <https://godotengine.org/donate>
|
||||
|
||||
## Silver sponsors
|
||||
|
||||
Gamblify <https://www.gamblify.com>
|
||||
Moonwards <https://www.moonwards.com>
|
||||
|
||||
## Bronze sponsors
|
||||
|
||||
Brandon Lamb
|
||||
Garry Newman
|
||||
|
||||
## Mini sponsors
|
||||
|
||||
AD Ford
|
||||
albinaask
|
||||
Alejandro Saucedo
|
||||
alex brown
|
||||
Alan Beauchamp
|
||||
Anand Mallik
|
||||
Andres Hernandez
|
||||
Andrew Dunai
|
||||
Brandon Lamb
|
||||
Christian Baune
|
||||
Christoffer Sundbom
|
||||
Christopher Montesano
|
||||
Darkhan Baimyrza
|
||||
Darrin Massena
|
||||
David Mydlarz
|
||||
Digital Grows
|
||||
Dov Zimring
|
||||
Edward Flick
|
||||
Gamechuck
|
||||
GameDev.net
|
||||
GameDev.tv
|
||||
Grady
|
||||
Hein-Pieter van Braam
|
||||
Jacob McKenney
|
||||
Jasper Brooks
|
||||
Javary Co.
|
||||
Jeffery Chiu
|
||||
Jonah Stich
|
||||
Justin Arnold
|
||||
Justo Delgado Baudí
|
||||
Kyle Szklenski
|
||||
Marcel Kräml
|
||||
Matthieu Huvé
|
||||
Maxim Karsten
|
||||
Mike King
|
||||
Nathan Warden
|
||||
Neal Gompa (Conan Kudo)
|
||||
Patrick Schmidt
|
||||
Ronnie Cheng
|
||||
Péter Magyar
|
||||
Slobodan Milnovic
|
||||
Stephan Lanfermann
|
||||
Steve
|
||||
Thomas Krampl
|
||||
Tristan Pemble
|
||||
VilliHaukka
|
||||
Violin Iliev
|
||||
蕭惟允
|
||||
|
||||
## Gold donors
|
||||
|
||||
Andrew Morsillo
|
||||
Andrei
|
||||
Dave
|
||||
David Gehrig
|
||||
David Snopek
|
||||
Ed Morley
|
||||
Florian Krick
|
||||
Florian Rämisch
|
||||
Jakub Grzesik
|
||||
Manuele Finocchiaro
|
||||
Officine Pixel S.n.c.
|
||||
Retro Village
|
||||
Ronan Zeegers
|
||||
Sofox
|
||||
Taylor Ritenour
|
||||
Zaven Muradyan
|
||||
|
||||
Asher Glick
|
||||
Austen McRae
|
||||
Bernhard Werner
|
||||
beVR
|
||||
Carlo Cabanilla
|
||||
Chris Goddard
|
||||
Christopher Case
|
||||
Daniel James
|
||||
David Gehrig
|
||||
David Giardi
|
||||
David Snopek
|
||||
Ed Morley
|
||||
Default Name
|
||||
eggs
|
||||
Ellen Poe
|
||||
Felix Bohmann
|
||||
Florian Breisch
|
||||
Florian Rämisch
|
||||
Forge
|
||||
Gamejunkey
|
||||
Grady
|
||||
Jakub Grzesik
|
||||
Javier Roman
|
||||
Jeff Nyte
|
||||
Joan Fons
|
||||
Jay Horton
|
||||
Jon Woodward
|
||||
Karl Werf
|
||||
Keinan Powers
|
||||
Klavdij Voncina
|
||||
Lex Steers
|
||||
Luke
|
||||
Maciej Pendolski
|
||||
Manuele Finocchiaro
|
||||
Markus Wiesner
|
||||
Mason Bially
|
||||
Matthew Hillier
|
||||
m kaersten
|
||||
Mohamed Ikbel Boulabiar
|
||||
Monster Vial
|
||||
Officine Pixel S.n.c.
|
||||
Rami
|
||||
Rene
|
||||
Rene Tailleur
|
||||
Retro Village
|
||||
Mored4u
|
||||
Rob Messick
|
||||
Roland Fredenhagen
|
||||
Ronan Zeegers
|
||||
Ryan Badour
|
||||
Sandro Jenny
|
||||
Sarksus
|
||||
Sean
|
||||
Scott Wadden
|
||||
Sergey
|
||||
Sofox
|
||||
Spicylewd
|
||||
Taylor Ritenour
|
||||
thechris
|
||||
Tom Langwaldt
|
||||
Tricky Fat Cat
|
||||
tukon
|
||||
William Wold
|
||||
xagonist
|
||||
Zaven Muradyan
|
||||
|
||||
Aaron Winter
|
||||
Alex Khayrullin
|
||||
Chris Goddard
|
||||
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
|
||||
Rami
|
||||
Reneator
|
||||
Rob
|
||||
Robert Willes
|
||||
Ronnie Ashlock
|
||||
SKison
|
||||
Thomas Bjarnelöf
|
||||
Unseen Domains
|
||||
Valryia
|
||||
Vincent Henderson
|
||||
Wojciech Chojnacki
|
||||
Xavier PATRICELLI
|
||||
|
||||
Adam Nakonieczny
|
||||
Adam Neumann
|
||||
Alexander J Maynard
|
||||
Alex de la Mare
|
||||
Alexey Dyadchenko
|
||||
Alex Khayrullin
|
||||
alice gambrell
|
||||
Alex Z
|
||||
Andreas Funke
|
||||
André Frélicot
|
||||
Andrew Harris
|
||||
Antoni Batchelli
|
||||
aoshiwik
|
||||
Arisaka Mayuki
|
||||
Barugon
|
||||
Can Eris
|
||||
Ben Powell
|
||||
Carlos de Sousa Marques
|
||||
Charlie Whitfield
|
||||
Chase Taranto
|
||||
Chelsea Hash
|
||||
Chris Petrich
|
||||
Chris Serino
|
||||
Christian Leth Jeppesen
|
||||
Christoph Schröder
|
||||
Cody Parker
|
||||
Conrad Curry
|
||||
Coldragon
|
||||
Craig Ostrin
|
||||
Craig Smith
|
||||
D
|
||||
Darrian Little
|
||||
Dev To be curious
|
||||
Digital Denizen
|
||||
Daniel Eichler
|
||||
David White
|
||||
Denis Janßen
|
||||
Easypete
|
||||
Edgar Sun
|
||||
Eric Monson
|
||||
ethan ball
|
||||
Eugenio Hugo Salgüero Jáñez
|
||||
Felix Brückner
|
||||
Fain
|
||||
flesk
|
||||
F S
|
||||
Gabrielius Vaiškūnas
|
||||
Gary Hulst
|
||||
gavlig
|
||||
GGGames.org
|
||||
GiulianoB
|
||||
Green Fox
|
||||
Guilherme Felipe de C. G. da Silva
|
||||
Halom Vered
|
||||
Heath Hayes
|
||||
Hoai Nam Tran
|
||||
Horváth Péter
|
||||
Hu Hund
|
||||
James Couzens
|
||||
Jared
|
||||
Idzard Kwadijk
|
||||
Isaac Clausman
|
||||
Jared White
|
||||
Joel Fivat
|
||||
Joel Höglund
|
||||
Jeff Nyte
|
||||
Jeremy Sims
|
||||
Jerry Ling
|
||||
Joe Flood
|
||||
John G Gentzel
|
||||
Jon Hermansen
|
||||
Jose Malheiro
|
||||
Joseph Crane
|
||||
Joshie Sparks
|
||||
Joshua Flores
|
||||
Joshua Lesperance
|
||||
Juan Velandia
|
||||
Judd
|
||||
Julian Todd
|
||||
Juraj Móza
|
||||
JUSTIN CARROLL
|
||||
Justo Delgado Baudí
|
||||
Kelteseth
|
||||
kickmaniac
|
||||
kinfox
|
||||
kuku
|
||||
Lachie
|
||||
Lain Ballard
|
||||
Leo Fidel R Liban
|
||||
luca duran
|
||||
Luc-Frédéric Langis
|
||||
MadScientistCarl
|
||||
Marcelo Dornbusch Lopes
|
||||
Marisa Clardy
|
||||
Markus Fehr
|
||||
Markus Wiesner
|
||||
Martin Eigel
|
||||
Martin Kotz
|
||||
Martin Soucek
|
||||
Matt Eunson
|
||||
Michael
|
||||
Michael Dürwald
|
||||
Mikado069
|
||||
Max Bulai
|
||||
MuffinManKen
|
||||
Nick Abousselam
|
||||
Nick Nikitin
|
||||
Oliver Dick
|
||||
Oscar Campos
|
||||
Patrick Ting
|
||||
Paul Hocker
|
||||
Paul Von Zimmerman
|
||||
Pedro Silva
|
||||
Pete Goodwin
|
||||
Péter Magyar
|
||||
Petr Malac
|
||||
PhaineOfCatz
|
||||
pl
|
||||
Ranoller
|
||||
Raymond Harris
|
||||
razmie
|
||||
Ricardo Alcantara
|
||||
Rob
|
||||
Robert Willes
|
||||
Rob McInroy
|
||||
Robert Larnach
|
||||
Rocknight Studios
|
||||
Ronnie Ashlock
|
||||
Ryan Wilson
|
||||
Romildo Franco
|
||||
Samuel Judd
|
||||
Scott Pilet
|
||||
Sean Morgan
|
||||
Sean Robertson
|
||||
Sébastien
|
||||
Serban Serafimescu
|
||||
Sergey Minakov
|
||||
Shishir Tandale
|
||||
SKison
|
||||
SleepCircle
|
||||
spilldata
|
||||
Steven Landow
|
||||
Steve Hyatt
|
||||
Stoned Xander
|
||||
Tahiti Bos
|
||||
TheLevelOfDetail .
|
||||
Thomas Bjarnelöf
|
||||
Thomas Krampl
|
||||
Thomas Kurz
|
||||
Tim Howard
|
||||
Timothy Pulliam
|
||||
Tobias Bocanegra
|
||||
Trent Fehl
|
||||
Valryia
|
||||
VikFro
|
||||
Vojtěch
|
||||
voxelv
|
||||
Tricky Fat Cat
|
||||
Urho
|
||||
William Foster
|
||||
Wojciech Chojnacki
|
||||
Xavier PATRICELLI
|
||||
xzibiting
|
||||
Zhou Tuizhi
|
||||
Zie Weaver
|
||||
Zoran Kukulj
|
||||
蕭惟允
|
||||
|
||||
## Silver donors
|
||||
|
||||
1D_Inc
|
||||
Aaron
|
||||
Aaron Passchier
|
||||
Abraham Haskins
|
||||
Acheron
|
||||
Adam
|
||||
Adam Brunnmeier
|
||||
Adam Carr
|
||||
Adam Carr
|
||||
Adam Long
|
||||
Adam McCurdy
|
||||
Adam N Webber
|
||||
Adam Smeltzer
|
||||
Adam Szymański
|
||||
Adisibio
|
||||
Agar3s - Giovanny Beltrán
|
||||
Adrian Demetrescu
|
||||
Agustinus Arya
|
||||
Aidan O'Flannagain
|
||||
Aki Mimoto
|
||||
Alan Beauchamp
|
||||
Alan Mervitz
|
||||
Alan Stice
|
||||
Albin Jonasson Svärdsby
|
||||
Alder Stefano
|
||||
AleMax
|
||||
Alessandro Senese
|
||||
Alexander Erlemann
|
||||
Alexandre Beaudoin
|
||||
alex clavelle
|
||||
Ali Al-Khalifa
|
||||
Allan Davis
|
||||
Allen Schade
|
||||
Andreas Evers
|
||||
Andreas Krampitz
|
||||
André Simões
|
||||
Andre Stackhouse
|
||||
andrew james morris
|
||||
Andrew Mansuetti
|
||||
Andrew Rosenwinkel
|
||||
Andrew Thomas
|
||||
Ano Nim
|
||||
Anthony Avina
|
||||
Anthony Staunton
|
||||
AP Condomines
|
||||
Arda Erol
|
||||
Armin Preiml
|
||||
Arseniy M
|
||||
Arthur S. Muszynski
|
||||
Ashley Claymore
|
||||
Ashton Scott Snapp
|
||||
Astier Mickael
|
||||
Asger
|
||||
Aubrey Falconer
|
||||
Avencherus
|
||||
B A
|
||||
Balázs Batári
|
||||
Balázs Kondákor
|
||||
Bartosz Bielecki
|
||||
Bekhoucha Danyl
|
||||
Benedikt
|
||||
Ben G
|
||||
Ben Phelan
|
||||
Ben Vercammen
|
||||
Bernd Jänichen
|
||||
Bjarne Voigtländer
|
||||
Black Block
|
||||
Blair Allen
|
||||
Bobby CC Wong
|
||||
Borkzilla
|
||||
Bram
|
||||
brian
|
||||
Brian mc gowan
|
||||
Brodie Fairhall
|
||||
bugcaptor
|
||||
Burney Waring
|
||||
Caleb Gartner
|
||||
Cameron Meyer
|
||||
Carlos Cejudo
|
||||
Carl van der Geest
|
||||
Carwyn Edwards
|
||||
Cas Brugman
|
||||
Cassidy James
|
||||
Chad Steadman
|
||||
Chris Brown
|
||||
Chris Chapin
|
||||
Chris Jagusch
|
||||
Christian Clavet
|
||||
Christian Winter
|
||||
Christoffer Dahlblom
|
||||
Christophe Gagnier
|
||||
Christoffer Sundbom
|
||||
Christoph Brodmann
|
||||
Christopher Schmitt
|
||||
Christoph Woinke
|
||||
Clay Heaton
|
||||
Cole Johnson
|
||||
Conall O
|
||||
Curt King
|
||||
CzechBlueBear
|
||||
Daniel De Macedo
|
||||
Dancin Liao
|
||||
Daniel Johnson
|
||||
DanielMaximiano
|
||||
Daniel Szarfman
|
||||
Daniel Tebbutt
|
||||
Danny Welch
|
||||
Daren Scot Wilson
|
||||
Dave Walker
|
||||
David Bôle
|
||||
Daniel Kimblad
|
||||
Daniel Pontillo
|
||||
David May
|
||||
David Woodard
|
||||
David Zanetti
|
||||
Dmitry Fisher
|
||||
Dmytro Korchynskyi
|
||||
DiCola Jamn
|
||||
Dominic Cooney
|
||||
Dominik Wetzel
|
||||
Donn Eddy
|
||||
Donovan Hutcheon
|
||||
Dragontrapper
|
||||
Dr Ewan Murray
|
||||
Dr.Raccoon
|
||||
Duobix
|
||||
Duodecimal
|
||||
Dylan Todd
|
||||
Eduardo Teixeira
|
||||
Edward Herbert
|
||||
Edward Moulsdale
|
||||
Edward Swartz
|
||||
Eelco F Hillenius
|
||||
Egon Elbre
|
||||
Elgenzay
|
||||
Elias Nykrem
|
||||
Elmeri '- Duy Kevin Nguyen
|
||||
Ephemeral
|
||||
Eric Ellingson
|
||||
Eric Rogers
|
||||
Eric Williams
|
||||
Erkki Seppälä
|
||||
ET Garcia
|
||||
Evan Rose
|
||||
Fain
|
||||
Faisal Alkubaisi
|
||||
Fancy Ants Studios
|
||||
Fekinox
|
||||
Felix Bohmann
|
||||
Felix Kollmann
|
||||
Flaredown
|
||||
Forty Doubleu
|
||||
Frank
|
||||
FuDiggity
|
||||
Gadzhi Kharkharov
|
||||
gamedev by Celio
|
||||
Gary Thomas
|
||||
George Marques
|
||||
Greg Lincoln
|
||||
GiulianoB
|
||||
Gordian Arragon
|
||||
Greg Olson
|
||||
GREGORY C FEIN
|
||||
Greg P
|
||||
Greyson Richey
|
||||
Grid
|
||||
Guillaume Audirac
|
||||
Guillaume Pham Ngoc
|
||||
Guldoman
|
||||
Gustavo Loureiro dos Reis
|
||||
Hal A
|
||||
helija
|
||||
Heribert Hirth
|
||||
Hudson Thorpe-Doubble
|
||||
Hunter Jones
|
||||
Hylpher
|
||||
Ian Williams
|
||||
Ichiro Dohi
|
||||
Iiari
|
||||
iKlem
|
||||
IndustrialRobot
|
||||
Ivan Nikolaev
|
||||
Jackson Harmer
|
||||
Jacob
|
||||
Jaguar
|
||||
Jaiden Gerig
|
||||
Jaime Ruiz-Borau Vizárraga
|
||||
Jake Huxell
|
||||
Jako Danar
|
||||
James
|
||||
James A F Manley
|
||||
James Thomas
|
||||
Jamiee H
|
||||
Jamie Massey
|
||||
Janders
|
||||
Jannik Gröger
|
||||
JARKKO PARVIAINEN
|
||||
Jason Uechi
|
||||
Jean-Baptiste LEPESME
|
||||
Jarrod Davis
|
||||
Jeff Hungerford
|
||||
Jennifer Graves
|
||||
Jeremy Kahn
|
||||
Jesse Dubay
|
||||
Joe Alden
|
||||
Joe Klemmer
|
||||
Joel Fivat
|
||||
Joel Höglund
|
||||
Joel Setterberg
|
||||
Johannes Wuensch
|
||||
John Gabriel
|
||||
Jomei Jackson
|
||||
Jonas
|
||||
Jonas Bernemann
|
||||
Jonas Rudlang
|
||||
Jonas Yamazaki
|
||||
Jonatan R
|
||||
Jonathan G
|
||||
Jonathon
|
||||
Jon Bonazza
|
||||
Jon Oakes
|
||||
Jon Sully
|
||||
Jordy Goodridge
|
||||
Jorge Antunes
|
||||
Jorge Caballero
|
||||
Jose Aleman
|
||||
Jose C. Rubio
|
||||
Joseph Catrambone
|
||||
Josh Mitchell
|
||||
Joshua Southerland
|
||||
Juanfran
|
||||
Judd
|
||||
Julian Murgia
|
||||
June Little
|
||||
JungleRobba
|
||||
Justin Calleja
|
||||
Justin Hamilton
|
||||
Justin Oaksford
|
||||
Justin Spedding
|
||||
KaDokta
|
||||
Karel Němec
|
||||
Kauzig
|
||||
Keedong Park
|
||||
Keinan Powers
|
||||
Keith Bradner
|
||||
Kent Jofur
|
||||
Kevin McPhillips
|
||||
Kiri Jolly
|
||||
kickmaniac
|
||||
Kiyohiro Kawamura (kyorohiro)
|
||||
Kjetil Haugland
|
||||
Kristian Nygaard Jensen
|
||||
Klagsam
|
||||
KR McGinley
|
||||
KsyTek Games
|
||||
Kuan Cheang
|
||||
kycho
|
||||
Kyle Appelgate
|
||||
Kyuppin
|
||||
Laurent CHEA
|
||||
Laurent Tréguier
|
||||
LEMMiNO
|
||||
Leonardo Dimano
|
||||
Lin Chear
|
||||
Levi Lindsey
|
||||
Linus Lind Lundgren
|
||||
Lionel Gaillard
|
||||
Luigi Renna
|
||||
@ -499,35 +401,30 @@ generous deed immortalized in the next stable release of Godot Engine.
|
||||
Lurkars
|
||||
Major Haul
|
||||
Malcolm
|
||||
Marco Lardelli
|
||||
Mark Jad
|
||||
Mark Krenz
|
||||
Markus Martin
|
||||
Malik Ahmed
|
||||
Malik Nejer
|
||||
Markus Michael Egger
|
||||
Martin FIbik
|
||||
Martin Holas
|
||||
Martin Linklater
|
||||
Martin Liška
|
||||
Martin Trbola
|
||||
Marvin
|
||||
Mathieu
|
||||
Mathieu Rimelen
|
||||
Matt Edwards
|
||||
Matthew Booe
|
||||
Max Fiedler
|
||||
Matthew Little
|
||||
Matti Pohjanvirta
|
||||
Maxime Blade
|
||||
Maxwell
|
||||
medecau
|
||||
Megasploot
|
||||
Melissa Mears
|
||||
mewin
|
||||
Michael Cullen
|
||||
mhilbrunner
|
||||
Michael Haney
|
||||
Michał Skwarek
|
||||
Michael Labbe
|
||||
Mikael Olsson
|
||||
Mikayla
|
||||
Mike Birkhead
|
||||
Mike Cunningham
|
||||
Mitchell J. Wagner
|
||||
Molinghu
|
||||
Molly Jameson
|
||||
MoM
|
||||
Nathan Fish
|
||||
Natrim
|
||||
@ -535,142 +432,96 @@ generous deed immortalized in the next stable release of Godot Engine.
|
||||
Neil Blakey-Milner
|
||||
Neil Wang
|
||||
Nerdforge
|
||||
Nerdyninja
|
||||
Nicholas
|
||||
Nicholas Girga
|
||||
Nick Allen
|
||||
Nick Macholl
|
||||
Niclas Eriksen
|
||||
Nicolas Goll-Perrier
|
||||
Nicolás Montaña
|
||||
Nicolas SAN AGUSTIN
|
||||
Nima Farid
|
||||
NZ
|
||||
'@oddgoo
|
||||
OKV
|
||||
Oleg Reva
|
||||
Olivier
|
||||
Omar Delarosa
|
||||
Orinxlm
|
||||
Oscar Domingo
|
||||
Oscar Norlander
|
||||
Parinya Teerakasemsuk
|
||||
Patrick Dully
|
||||
Pan Ip
|
||||
Patrick Nafarrete
|
||||
Paul Gieske
|
||||
Paul Mason
|
||||
Paweł Kowal
|
||||
Paweł Łyczkowski
|
||||
Pedro Assuncao
|
||||
Penguin
|
||||
Petrus Prinsloo
|
||||
Philip Cohoe
|
||||
Pierre-Nicolas Tollitte
|
||||
Piotr Góral
|
||||
Point08
|
||||
Preethi Vaidyanathan
|
||||
Price Comstock
|
||||
pwab
|
||||
Rad Cat
|
||||
Rafa Laguna
|
||||
rainerLinux
|
||||
Raphael Leroux
|
||||
Remi Rampin
|
||||
Rémi Verschelde
|
||||
Reneator
|
||||
Ricardo Alcantara
|
||||
Richard Diss
|
||||
Richard Ivánek
|
||||
Robert Farr (Larington)
|
||||
Robert Larnach
|
||||
Rob Ruana
|
||||
Robert Hernandez
|
||||
Roberto Sánchez
|
||||
Roger Smith
|
||||
Roland Rząsa
|
||||
Roman Tinkov
|
||||
Ronald Ho Hip (CrimsonZA)
|
||||
Ronan
|
||||
Ronny Mühle
|
||||
Ross Squires
|
||||
Ryan Groom
|
||||
Sam Caulfield
|
||||
Ryan Hentz
|
||||
Sam.C
|
||||
Sam Edson
|
||||
Samuele Zolfanelli
|
||||
sayaks
|
||||
Sasori Olkof
|
||||
Scott D. Yelich
|
||||
Scott Longley
|
||||
ScottMakesGames
|
||||
Sebastian Michailidis
|
||||
Sebastian Vetter
|
||||
Sergio Mello-Grand
|
||||
Shaher
|
||||
sgnsajgon
|
||||
Shane
|
||||
Shane Sicienski
|
||||
Shane Spoor
|
||||
Shiomi - Duy Kevin Nguyen
|
||||
Siim Raidma
|
||||
Simon Jonas Larsen
|
||||
Simon Schoenenberger
|
||||
Simon Wenner
|
||||
Sintinium
|
||||
Skalli
|
||||
SK
|
||||
smbe19
|
||||
smo1704
|
||||
soft circles
|
||||
Squirrel
|
||||
Stefano Caronia
|
||||
Steve Cloete
|
||||
Svenne Krap
|
||||
tadashi endo
|
||||
Tannen Helmers
|
||||
Terry
|
||||
tezuvholovdr
|
||||
Theodore Lindsey
|
||||
TheVoiceInMyHead
|
||||
thomas
|
||||
Thomas Bechtold
|
||||
Thomas Detoy
|
||||
Thomas Kelly
|
||||
Tim Drumheller
|
||||
Tim Erskine
|
||||
Tim Gleason
|
||||
Timothy B. MacDonald
|
||||
Tobbun
|
||||
Tobias Bradtke
|
||||
Toni Duran
|
||||
Tony Zhao
|
||||
Torgeir Lilleskog
|
||||
Torsten Crass
|
||||
Travis O'Brien
|
||||
Trent Skinner
|
||||
Triptych
|
||||
Triumph263 .
|
||||
Troy Bonneau
|
||||
Tryggve Sollid
|
||||
Turgut Temucin
|
||||
Tyler Compton
|
||||
Tyler Stafos
|
||||
UltyX
|
||||
Uther
|
||||
Valentí Gàmez
|
||||
Vaughan Ling
|
||||
Victor
|
||||
Vigilant Watch
|
||||
Viktor Ismagilov
|
||||
Vincent Cloutier
|
||||
Vitor Balbio
|
||||
Vladimir Savin
|
||||
waka nya
|
||||
Wayne Haak
|
||||
werner mendizabal
|
||||
Wiley Thompson
|
||||
Will
|
||||
William Edwards
|
||||
William F Siqueira
|
||||
William Hogben
|
||||
Windvis
|
||||
Wyatt Goodin
|
||||
x1212
|
||||
Yegor Smirnov
|
||||
YiYin Gu
|
||||
Yegor
|
||||
Yuri Sizov
|
||||
Zak Stephens
|
||||
Zgegnesh Hemomancer
|
||||
ΒΑΣΙΛΗΣ ΓΕΩΡΓΑΚΟΠΟΥΛΟΣ
|
||||
郝晨煜
|
||||
|
||||
## Bronze donors
|
||||
|
||||
|
||||
21
ISSUE_TEMPLATE.md
Normal file
21
ISSUE_TEMPLATE.md
Normal file
@ -0,0 +1,21 @@
|
||||
<!-- Please search existing issues for potential duplicates before filing yours:
|
||||
https://github.com/godotengine/godot/issues?q=is%3Aissue
|
||||
-->
|
||||
|
||||
**Godot version:**
|
||||
<!-- Specify commit hash if non-official. -->
|
||||
|
||||
|
||||
**OS/device including version:**
|
||||
<!-- Specify GPU model and drivers if graphics-related. -->
|
||||
|
||||
|
||||
**Issue description:**
|
||||
<!-- What happened, and what was expected. -->
|
||||
|
||||
|
||||
**Steps to reproduce:**
|
||||
|
||||
|
||||
**Minimal reproduction project:**
|
||||
<!-- Recommended as it greatly speeds up debugging. Drag and drop a zip archive to upload it. -->
|
||||
@ -1,5 +1,5 @@
|
||||
Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur.
|
||||
Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md).
|
||||
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
|
||||
|
||||
83
README.md
83
README.md
@ -1,96 +1,71 @@
|
||||
**Important:** The `3.2` branch is no longer maintained, as what was planned to be
|
||||
released as Godot 3.2.4 has been renamed to Godot 3.3:
|
||||
https://godotengine.org/article/versioning-change-godot-3x
|
||||
[](https://godotengine.org)
|
||||
|
||||
This branch was therefore reset to the `3.2.3-stable` state, and will not receive further
|
||||
updates, unless we decide that a hotfix 3.2.3.1 release is needed.
|
||||
## Godot Engine
|
||||
|
||||
We recommend that all Godot 3.2 users upgrade to Godot 3.3, which has been developed to be
|
||||
a safe and compatible upgrade for Godot 3.2 users.
|
||||
Homepage: https://godotengine.org
|
||||
|
||||
If you had a custom branch based on `3.2`, you should rebase on the stable `3.3` branch
|
||||
which is its continuation, or the `3.x` branch which is the new development branch for
|
||||
future 3.x releases. All commits which were in the `3.2` branch prior to the rename are
|
||||
in the `3.3` and `3.x` branches.
|
||||
#### 2D and 3D cross-platform game engine
|
||||
|
||||
-----
|
||||
Godot Engine is a feature-packed, cross-platform game engine to create 2D and
|
||||
3D games from a unified interface. It provides a comprehensive set of common
|
||||
tools, so that users can focus on making games without having to reinvent the
|
||||
wheel. Games can be exported in one click to a number of platforms, including
|
||||
the major desktop platforms (Linux, Mac OSX, Windows) as well as mobile
|
||||
(Android, iOS) and web-based (HTML5) platforms.
|
||||
|
||||
# Godot Engine
|
||||
|
||||
<p align="center">
|
||||
<a href="https://godotengine.org">
|
||||
<img src="logo.svg" width="400" alt="Godot Engine logo">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
## 2D and 3D cross-platform game engine
|
||||
|
||||
**[Godot Engine](https://godotengine.org) is a feature-packed, cross-platform
|
||||
game engine to create 2D and 3D games from a unified interface.** It provides a
|
||||
comprehensive set of common tools, so that users can focus on making games
|
||||
without having to reinvent the wheel. Games can be exported in one click to a
|
||||
number of platforms, including the major desktop platforms (Linux, macOS,
|
||||
Windows), mobile platforms (Android, iOS), as well as Web-based platforms
|
||||
(HTML5) and
|
||||
[consoles](https://docs.godotengine.org/en/latest/tutorials/platform/consoles.html).
|
||||
|
||||
## Free, open source and community-driven
|
||||
#### Free, open source and community-driven
|
||||
|
||||
Godot is completely free and open source under the very permissive MIT license.
|
||||
No strings attached, no royalties, nothing. The users' games are theirs, down
|
||||
to the last line of engine code. Godot's development is fully independent and
|
||||
community-driven, empowering users to help shape their engine to match their
|
||||
expectations. It is supported by the [Software Freedom Conservancy](https://sfconservancy.org/)
|
||||
expectations. It is supported by the Software Freedom Conservancy
|
||||
not-for-profit.
|
||||
|
||||
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.
|
||||
|
||||

|
||||

|
||||
|
||||
## Getting the engine
|
||||
### Getting the engine
|
||||
|
||||
### Binary downloads
|
||||
#### Binary downloads
|
||||
|
||||
Official binaries for the Godot editor and the export templates can be found
|
||||
[on the homepage](https://godotengine.org/download).
|
||||
|
||||
### Compiling from source
|
||||
#### 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 and contributing
|
||||
|
||||
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).
|
||||
|
||||
To get in touch with the engine developers, the best way is to join the
|
||||
[#godotengine-devel IRC channel](https://webchat.freenode.net/?channels=godotengine-devel)
|
||||
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
|
||||
### 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/)
|
||||
is also accessible from the Godot editor.
|
||||
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)
|
||||
as well.
|
||||
|
||||
There are also a number of other
|
||||
[learning resources](https://docs.godotengine.org/en/latest/community/tutorials.html)
|
||||
provided by the community, such as text and video tutorials, demos, etc.
|
||||
Consult the [community channels](https://godotengine.org/community)
|
||||
for more information.
|
||||
There are also a number of other learning resources provided by the community,
|
||||
such as text and video tutorials, demos, etc. Consult the [community channels](https://godotengine.org/community)
|
||||
for more info.
|
||||
|
||||
[](https://github.com/godotengine/godot/actions)
|
||||
[](https://travis-ci.org/godotengine/godot)
|
||||
[](https://ci.appveyor.com/project/akien-mga/godot)
|
||||
[](https://www.codetriage.com/godotengine/godot)
|
||||
[](https://hosted.weblate.org/engage/godot-engine/?utm_source=widget)
|
||||
[](https://lgtm.com/projects/g/godotengine/godot/alerts)
|
||||
[](https://www.tickgit.com/browse?repo=github.com/godotengine/godot)
|
||||
|
||||
757
SConstruct
757
SConstruct
@ -5,14 +5,14 @@ EnsureSConsVersion(0, 98, 1)
|
||||
# System
|
||||
import glob
|
||||
import os
|
||||
import pickle
|
||||
import string
|
||||
import sys
|
||||
from collections import OrderedDict
|
||||
|
||||
# Local
|
||||
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
|
||||
|
||||
@ -24,53 +24,99 @@ active_platforms = []
|
||||
active_platform_ids = []
|
||||
platform_exporters = []
|
||||
platform_apis = []
|
||||
global_defaults = []
|
||||
|
||||
for x in sorted(glob.glob("platform/*")):
|
||||
if not os.path.isdir(x) or not os.path.exists(x + "/detect.py"):
|
||||
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)
|
||||
import detect
|
||||
|
||||
if os.path.exists(x + "/export/export.cpp"):
|
||||
if (os.path.exists(x + "/export/export.cpp")):
|
||||
platform_exporters.append(x[9:])
|
||||
if os.path.exists(x + "/api/api.cpp"):
|
||||
if (os.path.exists(x + "/api/api.cpp")):
|
||||
platform_apis.append(x[9:])
|
||||
if detect.is_active():
|
||||
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)
|
||||
if detect.can_build():
|
||||
if (detect.can_build()):
|
||||
x = x.replace("platform/", "") # rest of world
|
||||
x = x.replace("platform\\", "") # win32
|
||||
platform_list += [x]
|
||||
platform_opts[x] = detect.get_opts()
|
||||
platform_flags[x] = detect.get_flags()
|
||||
sys.path.remove(tmppath)
|
||||
sys.modules.pop("detect")
|
||||
sys.modules.pop('detect')
|
||||
|
||||
module_list = methods.detect_modules()
|
||||
|
||||
|
||||
# print "Detected Platforms: "+str(platform_list)
|
||||
|
||||
methods.save_active_platforms(active_platforms, active_platform_ids)
|
||||
|
||||
custom_tools = ["default"]
|
||||
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"))
|
||||
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 = []
|
||||
env_base.android_gradle_plugins = []
|
||||
env_base.android_gradle_classpath = []
|
||||
env_base.android_java_dirs = []
|
||||
env_base.android_res_dirs = []
|
||||
env_base.android_asset_dirs = []
|
||||
env_base.android_aidl_dirs = []
|
||||
env_base.android_jni_dirs = []
|
||||
env_base.android_default_config = []
|
||||
env_base.android_manifest_chunk = ""
|
||||
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
|
||||
env_base.__class__.android_add_dependency = methods.android_add_dependency
|
||||
env_base.__class__.android_add_java_dir = methods.android_add_java_dir
|
||||
env_base.__class__.android_add_res_dir = methods.android_add_res_dir
|
||||
env_base.__class__.android_add_asset_dir = methods.android_add_asset_dir
|
||||
env_base.__class__.android_add_aidl_dir = methods.android_add_aidl_dir
|
||||
env_base.__class__.android_add_jni_dir = methods.android_add_jni_dir
|
||||
env_base.__class__.android_add_default_config = methods.android_add_default_config
|
||||
env_base.__class__.android_add_to_manifest = methods.android_add_to_manifest
|
||||
env_base.__class__.android_add_to_permissions = methods.android_add_to_permissions
|
||||
env_base.__class__.android_add_to_attributes = methods.android_add_to_attributes
|
||||
env_base.__class__.android_add_gradle_plugin = methods.android_add_gradle_plugin
|
||||
env_base.__class__.android_add_gradle_classpath = methods.android_add_gradle_classpath
|
||||
env_base.__class__.disable_module = methods.disable_module
|
||||
|
||||
env_base.__class__.add_module_version_string = methods.add_module_version_string
|
||||
@ -83,17 +129,13 @@ 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
|
||||
|
||||
# avoid issues when building with different versions of python out of the same directory
|
||||
env_base.SConsignFile(".sconsign{0}.dblite".format(pickle.HIGHEST_PROTOCOL))
|
||||
|
||||
# Build options
|
||||
|
||||
customs = ["custom.py"]
|
||||
customs = ['custom.py']
|
||||
|
||||
profile = ARGUMENTS.get("profile", False)
|
||||
if profile:
|
||||
@ -105,77 +147,63 @@ 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("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 (debug option)", False))
|
||||
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(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("custom_modules", "A list of comma-separated directory paths containing custom modules to build.", "")
|
||||
opts.Add(BoolVariable('deprecated', "Enable deprecated features", True))
|
||||
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", "Level of compilation warnings", "all", ("extra", "all", "moderate", "no")))
|
||||
opts.Add(BoolVariable("werror", "Treat compiler warnings as errors", False))
|
||||
opts.Add(BoolVariable("dev", "If yes, alias for verbose=yes warnings=extra werror=yes", 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(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('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_assimp', "Use the built-in Assimp library", True))
|
||||
opts.Add(BoolVariable("builtin_bullet", "Use the built-in Bullet library", True))
|
||||
opts.Add(BoolVariable("builtin_certs", "Use the built-in SSL certificates bundles", 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_wslay", "Use the built-in wslay 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_pcre2_with_jit", "Use JIT compiler for 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")
|
||||
opts.Add("CC", "C compiler")
|
||||
opts.Add("LINK", "Linker")
|
||||
opts.Add("CCFLAGS", "Custom flags for both the C and C++ compilers")
|
||||
opts.Add("CFLAGS", "Custom flags for the C compiler")
|
||||
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():
|
||||
@ -183,140 +211,65 @@ for k in platform_opts.keys():
|
||||
for o in opt_list:
|
||||
opts.Add(o)
|
||||
|
||||
# Update the environment now as the "custom_modules" option may be
|
||||
# defined in a file rather than specified via the command line.
|
||||
opts.Update(env_base)
|
||||
|
||||
# Detect modules.
|
||||
modules_detected = OrderedDict()
|
||||
module_search_paths = ["modules"] # Built-in path.
|
||||
|
||||
if env_base["custom_modules"]:
|
||||
paths = env_base["custom_modules"].split(",")
|
||||
for p in paths:
|
||||
try:
|
||||
module_search_paths.append(methods.convert_custom_modules_path(p))
|
||||
except ValueError as e:
|
||||
print(e)
|
||||
sys.exit(255)
|
||||
|
||||
for path in module_search_paths:
|
||||
# Note: custom modules can override built-in ones.
|
||||
modules_detected.update(methods.detect_modules(path))
|
||||
include_path = os.path.dirname(path)
|
||||
if include_path:
|
||||
env_base.Prepend(CPPPATH=[include_path])
|
||||
|
||||
# Add module options
|
||||
for name, path in modules_detected.items():
|
||||
enabled = True
|
||||
sys.path.insert(0, path)
|
||||
for x in module_list:
|
||||
module_enabled = True
|
||||
tmppath = "./modules/" + x
|
||||
sys.path.insert(0, tmppath)
|
||||
import config
|
||||
enabled_attr = getattr(config, "is_enabled", None)
|
||||
if (callable(enabled_attr) and not config.is_enabled()):
|
||||
module_enabled = False
|
||||
sys.path.remove(tmppath)
|
||||
sys.modules.pop('config')
|
||||
opts.Add(BoolVariable('module_' + x + '_enabled', "Enable module '%s'" % (x, ), module_enabled))
|
||||
|
||||
try:
|
||||
enabled = config.is_enabled()
|
||||
except AttributeError:
|
||||
pass
|
||||
sys.path.remove(path)
|
||||
sys.modules.pop("config")
|
||||
opts.Add(BoolVariable("module_" + name + "_enabled", "Enable module '%s'" % (name,), enabled))
|
||||
|
||||
methods.write_modules(modules_detected)
|
||||
|
||||
# Update the environment again after all the module options are added.
|
||||
opts.Update(env_base)
|
||||
Help(opts.GenerateHelpText(env_base))
|
||||
opts.Update(env_base) # update environment
|
||||
Help(opts.GenerateHelpText(env_base)) # generate help
|
||||
|
||||
# add default include paths
|
||||
|
||||
env_base.Prepend(CPPPATH=["#"])
|
||||
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"])
|
||||
if (env_base['target'] == 'debug'):
|
||||
env_base.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC'])
|
||||
env_base.Append(CPPFLAGS=['-DSCI_NAMESPACE'])
|
||||
|
||||
if env_base["target"] == "debug":
|
||||
env_base.Append(CPPDEFINES=["DEBUG_MEMORY_ALLOC", "DISABLE_FORCED_INLINE"])
|
||||
if (env_base['no_editor_splash']):
|
||||
env_base.Append(CPPFLAGS=['-DNO_EDITOR_SPLASH'])
|
||||
|
||||
# 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)
|
||||
|
||||
if env_base["no_editor_splash"]:
|
||||
env_base.Append(CPPDEFINES=["NO_EDITOR_SPLASH"])
|
||||
|
||||
if not env_base["deprecated"]:
|
||||
env_base.Append(CPPDEFINES=["DISABLE_DEPRECATED"])
|
||||
if not env_base['deprecated']:
|
||||
env_base.Append(CPPFLAGS=['-DDISABLE_DEPRECATED'])
|
||||
|
||||
env_base.platforms = {}
|
||||
|
||||
|
||||
selected_platform = ""
|
||||
|
||||
if env_base["platform"] != "":
|
||||
selected_platform = env_base["platform"]
|
||||
elif env_base["p"] != "":
|
||||
selected_platform = env_base["p"]
|
||||
if env_base['platform'] != "":
|
||||
selected_platform = env_base['platform']
|
||||
elif env_base['p'] != "":
|
||||
selected_platform = env_base['p']
|
||||
env_base["platform"] = selected_platform
|
||||
else:
|
||||
# Missing `platform` argument, try to detect platform automatically
|
||||
if sys.platform.startswith("linux"):
|
||||
selected_platform = "x11"
|
||||
elif sys.platform == "darwin":
|
||||
selected_platform = "osx"
|
||||
elif sys.platform == "win32":
|
||||
selected_platform = "windows"
|
||||
else:
|
||||
print("Could not detect platform automatically. Supported platforms:")
|
||||
for x in platform_list:
|
||||
print("\t" + x)
|
||||
print("\nPlease run SCons again and select a valid platform: platform=<string>")
|
||||
|
||||
if selected_platform != "":
|
||||
print("Automatically detected platform: " + selected_platform)
|
||||
env_base["platform"] = selected_platform
|
||||
|
||||
if selected_platform in ["linux", "bsd", "linuxbsd"]:
|
||||
if selected_platform == "linuxbsd":
|
||||
# Alias for forward compatibility.
|
||||
print('Platform "linuxbsd" is still called "x11" in Godot 3.2.x. Building for platform "x11".')
|
||||
# Alias for convenience.
|
||||
selected_platform = "x11"
|
||||
env_base["platform"] = selected_platform
|
||||
|
||||
if selected_platform in platform_list:
|
||||
tmppath = "./platform/" + selected_platform
|
||||
sys.path.insert(0, tmppath)
|
||||
import detect
|
||||
|
||||
if "create" in dir(detect):
|
||||
env = detect.create(env_base)
|
||||
else:
|
||||
env = env_base.Clone()
|
||||
|
||||
# Compilation DB requires SCons 3.1.1+.
|
||||
from SCons import __version__ as scons_raw_version
|
||||
if env['dev']:
|
||||
env["warnings"] = "all"
|
||||
env['verbose'] = True
|
||||
|
||||
scons_ver = env._get_major_minor_revision(scons_raw_version)
|
||||
|
||||
if scons_ver >= (4, 0, 0):
|
||||
env.Tool("compilation_db")
|
||||
env.Alias("compiledb", env.CompilationDatabase())
|
||||
|
||||
if env["dev"]:
|
||||
env["verbose"] = True
|
||||
env["warnings"] = "extra"
|
||||
env["werror"] = True
|
||||
|
||||
if env["vsproj"]:
|
||||
if env['vsproj']:
|
||||
env.vs_incs = []
|
||||
env.vs_srcs = []
|
||||
|
||||
@ -329,7 +282,7 @@ if selected_platform in platform_list:
|
||||
pieces = fname.split(".")
|
||||
if len(pieces) > 0:
|
||||
basename = pieces[0]
|
||||
basename = basename.replace("\\\\", "/")
|
||||
basename = basename.replace('\\\\', '/')
|
||||
if os.path.isfile(basename + ".h"):
|
||||
env.vs_incs = env.vs_incs + [basename + ".h"]
|
||||
elif os.path.isfile(basename + ".hpp"):
|
||||
@ -338,128 +291,77 @@ if selected_platform in platform_list:
|
||||
env.vs_srcs = env.vs_srcs + [basename + ".c"]
|
||||
elif os.path.isfile(basename + ".cpp"):
|
||||
env.vs_srcs = env.vs_srcs + [basename + ".cpp"]
|
||||
|
||||
env.AddToVSProject = AddToVSProject
|
||||
|
||||
env.extra_suffix = ""
|
||||
|
||||
if env["extra_suffix"] != "":
|
||||
env.extra_suffix += "." + env["extra_suffix"]
|
||||
if env["extra_suffix"] != '':
|
||||
env.extra_suffix += '.' + env["extra_suffix"]
|
||||
|
||||
CCFLAGS = env.get('CCFLAGS', '')
|
||||
env['CCFLAGS'] = ''
|
||||
|
||||
# Environment flags
|
||||
CCFLAGS = env.get("CCFLAGS", "")
|
||||
env["CCFLAGS"] = ""
|
||||
env.Append(CCFLAGS=str(CCFLAGS).split())
|
||||
|
||||
CFLAGS = env.get("CFLAGS", "")
|
||||
env["CFLAGS"] = ""
|
||||
CFLAGS = env.get('CFLAGS', '')
|
||||
env['CFLAGS'] = ''
|
||||
|
||||
env.Append(CFLAGS=str(CFLAGS).split())
|
||||
|
||||
CXXFLAGS = env.get("CXXFLAGS", "")
|
||||
env["CXXFLAGS"] = ""
|
||||
env.Append(CXXFLAGS=str(CXXFLAGS).split())
|
||||
LINKFLAGS = env.get('LINKFLAGS', '')
|
||||
env['LINKFLAGS'] = ''
|
||||
|
||||
LINKFLAGS = env.get("LINKFLAGS", "")
|
||||
env["LINKFLAGS"] = ""
|
||||
env.Append(LINKFLAGS=str(LINKFLAGS).split())
|
||||
|
||||
# Platform specific flags
|
||||
flag_list = platform_flags[selected_platform]
|
||||
for f in flag_list:
|
||||
if not (f[0] in ARGUMENTS): # allow command line to override platform flags
|
||||
env[f[0]] = f[1]
|
||||
|
||||
# Must happen after the flags definition, so that they can be used by platform detect
|
||||
# must happen after the flags, so when flags are used by configure, stuff happens (ie, ssl on x11)
|
||||
detect.configure(env)
|
||||
|
||||
# Set our C and C++ standard requirements.
|
||||
# Prepending to make it possible to override
|
||||
# This needs to come after `configure`, otherwise we don't have env.msvc.
|
||||
if not env.msvc:
|
||||
# Specifying GNU extensions support explicitly, which are supported by
|
||||
# both GCC and Clang. This mirrors GCC and Clang's current default
|
||||
# compile flags if no -std is specified.
|
||||
env.Prepend(CFLAGS=["-std=gnu11"])
|
||||
env.Prepend(CXXFLAGS=["-std=gnu++14"])
|
||||
else:
|
||||
# MSVC doesn't have clear C standard support, /std only covers C++.
|
||||
# We apply it to CCFLAGS (both C and C++ code) in case it impacts C features.
|
||||
env.Prepend(CCFLAGS=["/std:c++14"])
|
||||
if (env["warnings"] == 'yes'):
|
||||
print("WARNING: warnings=yes is deprecated; assuming warnings=all")
|
||||
|
||||
# Configure compiler warnings
|
||||
if env.msvc:
|
||||
# Truncations, narrowing conversions, signed/unsigned comparisons...
|
||||
disable_nonessential_warnings = ["/wd4267", "/wd4244", "/wd4305", "/wd4018", "/wd4800"]
|
||||
if env["warnings"] == "extra":
|
||||
env.Append(CCFLAGS=["/Wall"]) # Implies /W4
|
||||
elif env["warnings"] == "all":
|
||||
env.Append(CCFLAGS=["/W3"] + disable_nonessential_warnings)
|
||||
elif env["warnings"] == "moderate":
|
||||
env.Append(CCFLAGS=["/W2"] + disable_nonessential_warnings)
|
||||
else: # 'no'
|
||||
env.Append(CCFLAGS=["/w"])
|
||||
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' 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"])
|
||||
# Force to use Unicode encoding
|
||||
env.Append(MSVC_FLAGS=["/utf8"])
|
||||
else: # Rest of the world
|
||||
version = methods.get_compiler_version(env) or [-1, -1]
|
||||
env.Append(CCFLAGS=['/EHsc'])
|
||||
else: # Rest of the world
|
||||
if (env["warnings"] == 'extra'):
|
||||
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'])
|
||||
else: # 'no'
|
||||
env.Append(CCFLAGS=['-w'])
|
||||
env.Append(CCFLAGS=['-Werror=return-type'])
|
||||
|
||||
common_warnings = []
|
||||
#env['platform_libsuffix'] = env['LIBSUFFIX']
|
||||
|
||||
if methods.using_gcc(env):
|
||||
common_warnings += ["-Wno-misleading-indentation"]
|
||||
if version[0] >= 7:
|
||||
common_warnings += ["-Wshadow-local"]
|
||||
elif methods.using_clang(env):
|
||||
# We often implement `operator<` for structs of pointers as a requirement
|
||||
# for putting them in `Set` or `Map`. We don't mind about unreliable ordering.
|
||||
common_warnings += ["-Wno-ordered-compare-function-pointers"]
|
||||
suffix = "." + selected_platform
|
||||
|
||||
if env["warnings"] == "extra":
|
||||
# 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", "-Wwrite-strings", "-Wno-unused-parameter"] + common_warnings)
|
||||
env.Append(CXXFLAGS=["-Wctor-dtor-privacy", "-Wnon-virtual-dtor"])
|
||||
if methods.using_gcc(env):
|
||||
env.Append(
|
||||
CCFLAGS=[
|
||||
"-Walloc-zero",
|
||||
"-Wduplicated-branches",
|
||||
"-Wduplicated-cond",
|
||||
"-Wstringop-overflow=4",
|
||||
"-Wlogical-op",
|
||||
]
|
||||
)
|
||||
env.Append(CXXFLAGS=["-Wnoexcept", "-Wplacement-new=1"])
|
||||
if version[0] >= 9:
|
||||
env.Append(CCFLAGS=["-Wattribute-alias=2"])
|
||||
elif env["warnings"] == "all":
|
||||
env.Append(CCFLAGS=["-Wall"] + common_warnings)
|
||||
elif env["warnings"] == "moderate":
|
||||
env.Append(CCFLAGS=["-Wall", "-Wno-unused"] + common_warnings)
|
||||
else: # 'no'
|
||||
env.Append(CCFLAGS=["-w"])
|
||||
if env["werror"]:
|
||||
env.Append(CCFLAGS=["-Werror"])
|
||||
else: # always enable those errors
|
||||
env.Append(CCFLAGS=["-Werror=return-type"])
|
||||
|
||||
if hasattr(detect, "get_program_suffix"):
|
||||
suffix = "." + detect.get_program_suffix()
|
||||
else:
|
||||
suffix = "." + selected_platform
|
||||
|
||||
if env["target"] == "release":
|
||||
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":
|
||||
elif (env["target"] == "release_debug"):
|
||||
if env["tools"]:
|
||||
suffix += ".opt.tools"
|
||||
else:
|
||||
@ -472,142 +374,82 @@ if selected_platform in platform_list:
|
||||
|
||||
if env["arch"] != "":
|
||||
suffix += "." + env["arch"]
|
||||
elif env["bits"] == "32":
|
||||
elif (env["bits"] == "32"):
|
||||
suffix += ".32"
|
||||
elif env["bits"] == "64":
|
||||
elif (env["bits"] == "64"):
|
||||
suffix += ".64"
|
||||
elif (env["bits"] == "fat"):
|
||||
suffix += ".fat"
|
||||
|
||||
suffix += env.extra_suffix
|
||||
|
||||
sys.path.remove(tmppath)
|
||||
sys.modules.pop("detect")
|
||||
sys.modules.pop('detect')
|
||||
|
||||
modules_enabled = OrderedDict()
|
||||
env.module_icons_paths = []
|
||||
env.module_list = []
|
||||
env.doc_class_path = {}
|
||||
|
||||
for name, path in modules_detected.items():
|
||||
if not env["module_" + name + "_enabled"]:
|
||||
for x in module_list:
|
||||
if not env['module_' + x + '_enabled']:
|
||||
continue
|
||||
sys.path.insert(0, path)
|
||||
env.current_module = name
|
||||
tmppath = "./modules/" + x
|
||||
sys.path.insert(0, 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)
|
||||
# Get doc classes paths (if present)
|
||||
env.module_list.append(x)
|
||||
try:
|
||||
doc_classes = config.get_doc_classes()
|
||||
doc_path = config.get_doc_path()
|
||||
for c in doc_classes:
|
||||
env.doc_class_path[c] = path + "/" + doc_path
|
||||
doc_classes = config.get_doc_classes()
|
||||
doc_path = config.get_doc_path()
|
||||
for c in doc_classes:
|
||||
env.doc_class_path[c] = "modules/" + x + "/" + doc_path
|
||||
except:
|
||||
pass
|
||||
# Get icon paths (if present)
|
||||
try:
|
||||
icons_path = config.get_icons_path()
|
||||
env.module_icons_paths.append(path + "/" + icons_path)
|
||||
except:
|
||||
# Default path for module icons
|
||||
env.module_icons_paths.append(path + "/" + "icons")
|
||||
modules_enabled[name] = path
|
||||
|
||||
sys.path.remove(path)
|
||||
sys.modules.pop("config")
|
||||
|
||||
env.module_list = modules_enabled
|
||||
sys.path.remove(tmppath)
|
||||
sys.modules.pop('config')
|
||||
|
||||
methods.update_version(env.module_version_string)
|
||||
|
||||
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"])
|
||||
if env["tools"]:
|
||||
env.Append(CPPDEFINES=["TOOLS_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"])
|
||||
if env["gdscript"]:
|
||||
env.Append(CPPDEFINES=["GDSCRIPT_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"])
|
||||
if env["minizip"]:
|
||||
env.Append(CPPDEFINES=["MINIZIP_ENABLED"])
|
||||
if (env.use_ptrcall):
|
||||
env.Append(CPPFLAGS=['-DPTRCALL_ENABLED'])
|
||||
|
||||
editor_module_list = ["regex"]
|
||||
for x in editor_module_list:
|
||||
if not env["module_" + x + "_enabled"]:
|
||||
if env["tools"]:
|
||||
print(
|
||||
"Build option 'module_" + x + "_enabled=no' cannot be used with 'tools=yes' (editor), "
|
||||
"only with 'tools=no' (export template)."
|
||||
)
|
||||
sys.exit(255)
|
||||
# to test 64 bits compiltion
|
||||
# env.Append(CPPFLAGS=['-m64'])
|
||||
|
||||
if not env["verbose"]:
|
||||
if env['tools']:
|
||||
env.Append(CPPFLAGS=['-DTOOLS_ENABLED'])
|
||||
if env['disable_3d']:
|
||||
env.Append(CPPFLAGS=['-D_3D_DISABLED'])
|
||||
if env['gdscript']:
|
||||
env.Append(CPPFLAGS=['-DGDSCRIPT_ENABLED'])
|
||||
if env['disable_advanced_gui']:
|
||||
env.Append(CPPFLAGS=['-DADVANCED_GUI_DISABLED'])
|
||||
|
||||
if env['minizip']:
|
||||
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"
|
||||
)
|
||||
}
|
||||
)
|
||||
if (not env["platform"] == "server"): # FIXME: detect GLES3
|
||||
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:
|
||||
CacheDir(scons_cache_path)
|
||||
print("Scons cache enabled... (path: '" + scons_cache_path + "')")
|
||||
|
||||
Export("env")
|
||||
Export('env')
|
||||
|
||||
# build subdirs, the build order is dependent on link order.
|
||||
|
||||
@ -624,39 +466,142 @@ if selected_platform in platform_list:
|
||||
SConscript("platform/" + selected_platform + "/SCsub") # build selected platform
|
||||
|
||||
# Microsoft Visual Studio Project Generation
|
||||
if env["vsproj"]:
|
||||
env["CPPPATH"] = [Dir(path) for path in env["CPPPATH"]]
|
||||
if env['vsproj']:
|
||||
env['CPPPATH'] = [Dir(path) for path in env['CPPPATH']]
|
||||
methods.generate_vs_project(env, GetOption("num_jobs"))
|
||||
methods.generate_cpp_hint_file("cpp.hint")
|
||||
|
||||
# Check for the existence of headers
|
||||
conf = Configure(env)
|
||||
if "check_c_headers" in env:
|
||||
if ("check_c_headers" in env):
|
||||
for header in env["check_c_headers"]:
|
||||
if conf.CheckCHeader(header[0]):
|
||||
env.AppendUnique(CPPDEFINES=[header[1]])
|
||||
if (conf.CheckCHeader(header[0])):
|
||||
if (env.msvc):
|
||||
env.Append(CCFLAGS=['/D' + header[1]])
|
||||
else:
|
||||
env.Append(CCFLAGS=['-D' + header[1]])
|
||||
|
||||
elif selected_platform != "":
|
||||
if selected_platform == "list":
|
||||
print("The following platforms are available:\n")
|
||||
else:
|
||||
print('Invalid target platform "' + selected_platform + '".')
|
||||
print("The following platforms were detected:\n")
|
||||
else:
|
||||
|
||||
print("No valid target platform selected.")
|
||||
print("The following were detected:")
|
||||
for x in platform_list:
|
||||
print("\t" + x)
|
||||
print("\nPlease run scons again with argument: platform=<string>")
|
||||
|
||||
print("\nPlease run SCons again and select a valid platform: platform=<string>")
|
||||
|
||||
if selected_platform == "list":
|
||||
# Exit early to suppress the rest of the built-in SCons messages
|
||||
sys.exit(0)
|
||||
else:
|
||||
sys.exit(255)
|
||||
# The following only makes sense when the env is defined, and assumes it is
|
||||
if 'env' in locals():
|
||||
screen = sys.stdout
|
||||
# Progress reporting is not available in non-TTY environments since it
|
||||
# messes with the output (for example, when writing to a file)
|
||||
show_progress = (env['progress'] and sys.stdout.isatty())
|
||||
node_count = 0
|
||||
node_count_max = 0
|
||||
node_count_interval = 1
|
||||
node_count_fname = str(env.Dir('#')) + '/.scons_node_count'
|
||||
|
||||
# The following only makes sense when the 'env' is defined, and assumes it is.
|
||||
if "env" in locals():
|
||||
methods.show_progress(env)
|
||||
# TODO: replace this with `env.Dump(format="json")`
|
||||
# once we start requiring SCons 4.0 as min version.
|
||||
methods.dump(env)
|
||||
import time, math
|
||||
|
||||
class cache_progress:
|
||||
# The default is 1 GB cache and 12 hours half life
|
||||
def __init__(self, path = None, limit = 1073741824, half_life = 43200):
|
||||
self.path = path
|
||||
self.limit = limit
|
||||
self.exponent_scale = math.log(2) / half_life
|
||||
if env['verbose'] and path != None:
|
||||
screen.write('Current cache limit is ' + self.convert_size(limit) + ' (used: ' + self.convert_size(self.get_size(path)) + ')\n')
|
||||
self.delete(self.file_list())
|
||||
|
||||
def __call__(self, node, *args, **kw):
|
||||
global node_count, node_count_max, node_count_interval, node_count_fname, show_progress
|
||||
if show_progress:
|
||||
# Print the progress percentage
|
||||
node_count += node_count_interval
|
||||
if (node_count_max > 0 and node_count <= node_count_max):
|
||||
screen.write('\r[%3d%%] ' % (node_count * 100 / node_count_max))
|
||||
screen.flush()
|
||||
elif (node_count_max > 0 and node_count > node_count_max):
|
||||
screen.write('\r[100%] ')
|
||||
screen.flush()
|
||||
else:
|
||||
screen.write('\r[Initial build] ')
|
||||
screen.flush()
|
||||
|
||||
def delete(self, files):
|
||||
if len(files) == 0:
|
||||
return
|
||||
if env['verbose']:
|
||||
# Utter something
|
||||
screen.write('\rPurging %d %s from cache...\n' % (len(files), len(files) > 1 and 'files' or 'file'))
|
||||
[os.remove(f) for f in files]
|
||||
|
||||
def file_list(self):
|
||||
if self.path == None:
|
||||
# Nothing to do
|
||||
return []
|
||||
# Gather a list of (filename, (size, atime)) within the
|
||||
# cache directory
|
||||
file_stat = [(x, os.stat(x)[6:8]) for x in glob.glob(os.path.join(self.path, '*', '*'))]
|
||||
if file_stat == []:
|
||||
# Nothing to do
|
||||
return []
|
||||
# Weight the cache files by size (assumed to be roughly
|
||||
# proportional to the recompilation time) times an exponential
|
||||
# decay since the ctime, and return a list with the entries
|
||||
# (filename, size, weight).
|
||||
current_time = time.time()
|
||||
file_stat = [(x[0], x[1][0], (current_time - x[1][1])) for x in file_stat]
|
||||
# Sort by the most resently accessed files (most sensible to keep) first
|
||||
file_stat.sort(key=lambda x: x[2])
|
||||
# Search for the first entry where the storage limit is
|
||||
# reached
|
||||
sum, mark = 0, None
|
||||
for i,x in enumerate(file_stat):
|
||||
sum += x[1]
|
||||
if sum > self.limit:
|
||||
mark = i
|
||||
break
|
||||
if mark == None:
|
||||
return []
|
||||
else:
|
||||
return [x[0] for x in file_stat[mark:]]
|
||||
|
||||
def convert_size(self, size_bytes):
|
||||
if size_bytes == 0:
|
||||
return "0 bytes"
|
||||
size_name = ("bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB")
|
||||
i = int(math.floor(math.log(size_bytes, 1024)))
|
||||
p = math.pow(1024, i)
|
||||
s = round(size_bytes / p, 2)
|
||||
return "%s %s" % (int(s) if i == 0 else s, size_name[i])
|
||||
|
||||
def get_size(self, start_path = '.'):
|
||||
total_size = 0
|
||||
for dirpath, dirnames, filenames in os.walk(start_path):
|
||||
for f in filenames:
|
||||
fp = os.path.join(dirpath, f)
|
||||
total_size += os.path.getsize(fp)
|
||||
return total_size
|
||||
|
||||
def progress_finish(target, source, env):
|
||||
global node_count, progressor
|
||||
with open(node_count_fname, 'w') as f:
|
||||
f.write('%d\n' % node_count)
|
||||
progressor.delete(progressor.file_list())
|
||||
|
||||
try:
|
||||
with open(node_count_fname) as f:
|
||||
node_count_max = int(f.readline())
|
||||
except:
|
||||
pass
|
||||
|
||||
cache_directory = os.environ.get("SCONS_CACHE")
|
||||
# Simple cache pruning, attached to SCons' progress callback. Trim the
|
||||
# cache directory to a size not larger than cache_limit.
|
||||
cache_limit = float(os.getenv("SCONS_CACHE_LIMIT", 1024)) * 1024 * 1024
|
||||
progressor = cache_progress(cache_directory, cache_limit)
|
||||
Progress(progressor, interval = node_count_interval)
|
||||
|
||||
progress_finish_command = Command('progress_finish', [], progress_finish)
|
||||
AlwaysBuild(progress_finish_command)
|
||||
|
||||
52
compat.py
52
compat.py
@ -1,96 +1,64 @@
|
||||
import sys
|
||||
|
||||
if sys.version_info < (3,):
|
||||
|
||||
def isbasestring(s):
|
||||
return isinstance(s, basestring)
|
||||
|
||||
def open_utf8(filename, mode):
|
||||
return open(filename, mode)
|
||||
|
||||
def byte_to_str(x):
|
||||
return str(ord(x))
|
||||
|
||||
import cStringIO
|
||||
|
||||
def StringIO():
|
||||
return cStringIO.StringIO()
|
||||
|
||||
def encode_utf8(x):
|
||||
return x
|
||||
|
||||
def decode_utf8(x):
|
||||
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")
|
||||
result = ""
|
||||
s = s.encode('ascii')
|
||||
result = ''
|
||||
for c in s:
|
||||
if not (32 <= ord(c) < 127) or c in ("\\", '"'):
|
||||
result += "\\%03o" % ord(c)
|
||||
if not (32 <= ord(c) < 127) or c in ('\\', '"'):
|
||||
result += '\\%03o' % ord(c)
|
||||
else:
|
||||
result += c
|
||||
return result
|
||||
|
||||
def qualname(obj):
|
||||
# Not properly equivalent to __qualname__ in py3, but it doesn't matter.
|
||||
return obj.__name__
|
||||
|
||||
else:
|
||||
|
||||
def isbasestring(s):
|
||||
return isinstance(s, (str, bytes))
|
||||
|
||||
def open_utf8(filename, mode):
|
||||
return open(filename, mode, encoding="utf-8")
|
||||
|
||||
def byte_to_str(x):
|
||||
return str(x)
|
||||
|
||||
import io
|
||||
|
||||
def StringIO():
|
||||
return io.StringIO()
|
||||
|
||||
import codecs
|
||||
|
||||
def encode_utf8(x):
|
||||
return codecs.utf_8_encode(x)[0]
|
||||
|
||||
def decode_utf8(x):
|
||||
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:
|
||||
c, low = (c // 256, c % 256)
|
||||
rev_result.append("\\%03o" % low)
|
||||
rev_result.append("\\%03o" % c)
|
||||
return "".join(reversed(rev_result))
|
||||
|
||||
rev_result.append('\\%03o' % low)
|
||||
rev_result.append('\\%03o' % c)
|
||||
return ''.join(reversed(rev_result))
|
||||
def escape_string(s):
|
||||
result = ""
|
||||
result = ''
|
||||
if isinstance(s, str):
|
||||
s = s.encode("utf-8")
|
||||
s = s.encode('utf-8')
|
||||
for c in s:
|
||||
if not (32 <= c < 127) or c in (ord("\\"), ord('"')):
|
||||
if not(32 <= c < 127) or c in (ord('\\'), ord('"')):
|
||||
result += charcode_to_c_escapes(c)
|
||||
else:
|
||||
result += chr(c)
|
||||
return result
|
||||
|
||||
def qualname(obj):
|
||||
return obj.__qualname__
|
||||
|
||||
194
core/SCsub
194
core/SCsub
@ -1,186 +1,110 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
Import("env")
|
||||
|
||||
import core_builders
|
||||
import make_binders
|
||||
from platform_methods import run_in_subprocess
|
||||
Import('env')
|
||||
|
||||
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"
|
||||
if "SCRIPT_AES256_ENCRYPTION_KEY" in os.environ:
|
||||
if ("SCRIPT_AES256_ENCRYPTION_KEY" in os.environ):
|
||||
e = os.environ["SCRIPT_AES256_ENCRYPTION_KEY"]
|
||||
txt = ""
|
||||
ec_valid = True
|
||||
if len(e) != 64:
|
||||
if (len(e) != 64):
|
||||
ec_valid = False
|
||||
else:
|
||||
|
||||
for i in range(len(e) >> 1):
|
||||
if i > 0:
|
||||
if (i > 0):
|
||||
txt += ","
|
||||
txts = "0x" + e[i * 2 : i * 2 + 2]
|
||||
txts = "0x" + e[i * 2:i * 2 + 2]
|
||||
try:
|
||||
int(txts, 16)
|
||||
except:
|
||||
ec_valid = False
|
||||
txt += txts
|
||||
if not ec_valid:
|
||||
if (not ec_valid):
|
||||
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
|
||||
"fastlz.c",
|
||||
"smaz.c",
|
||||
# C++ sources
|
||||
"hq2x.cpp",
|
||||
"pcg.cpp",
|
||||
"triangulator.cpp",
|
||||
"clipper.cpp",
|
||||
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",
|
||||
]
|
||||
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.Prepend(CPPPATH=[thirdparty_zlib_dir])
|
||||
# Needs to be available in main env too
|
||||
env.Prepend(CPPPATH=[thirdparty_zlib_dir])
|
||||
if env["target"] == "debug":
|
||||
env_thirdparty.Append(CPPDEFINES=["ZLIB_DEBUG"])
|
||||
|
||||
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.Prepend(CPPPATH=[thirdparty_zstd_dir, thirdparty_zstd_dir + "common"])
|
||||
env_thirdparty.Append(CPPDEFINES=["ZSTD_STATIC_LINKING_ONLY"])
|
||||
env.Prepend(CPPPATH=thirdparty_zstd_dir)
|
||||
# Also needed in main env includes will trigger warnings
|
||||
env.Append(CPPDEFINES=["ZSTD_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", "method_bind_free_func.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("crypto/SCsub")
|
||||
SConscript("io/SCsub")
|
||||
SConscript("bind/SCsub")
|
||||
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
194
core/allocators.h
Normal file
@ -0,0 +1,194 @@
|
||||
/*************************************************************************/
|
||||
/* allocators.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 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
|
||||
151
core/array.cpp
151
core/array.cpp
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -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 {
|
||||
@ -133,12 +133,12 @@ void Array::erase(const Variant &p_value) {
|
||||
}
|
||||
|
||||
Variant Array::front() const {
|
||||
ERR_FAIL_COND_V_MSG(_p->array.size() == 0, Variant(), "Can't take value from empty array.");
|
||||
ERR_FAIL_COND_V(_p->array.size() == 0, Variant());
|
||||
return operator[](0);
|
||||
}
|
||||
|
||||
Variant Array::back() const {
|
||||
ERR_FAIL_COND_V_MSG(_p->array.size() == 0, Variant(), "Can't take value from empty array.");
|
||||
ERR_FAIL_COND_V(_p->array.size() == 0, Variant());
|
||||
return operator[](_p->array.size() - 1);
|
||||
}
|
||||
|
||||
@ -165,8 +165,8 @@ int Array::rfind(const Variant &p_value, int p_from) const {
|
||||
|
||||
if (_p->array[i] == p_value) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
return -1;
|
||||
}
|
||||
@ -186,8 +186,8 @@ int Array::count(const Variant &p_value) const {
|
||||
|
||||
if (_p->array[i] == p_value) {
|
||||
amount++;
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
return amount;
|
||||
}
|
||||
@ -211,67 +211,17 @@ 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;
|
||||
}
|
||||
|
||||
int Array::_clamp_slice_index(int p_index) const {
|
||||
|
||||
int arr_size = size();
|
||||
int fixed_index = CLAMP(p_index, -arr_size, arr_size - 1);
|
||||
if (fixed_index < 0) {
|
||||
fixed_index = arr_size + fixed_index;
|
||||
}
|
||||
return fixed_index;
|
||||
}
|
||||
|
||||
Array Array::slice(int p_begin, int p_end, int p_step, bool p_deep) const { // like python, but inclusive on upper bound
|
||||
|
||||
Array new_arr;
|
||||
|
||||
ERR_FAIL_COND_V_MSG(p_step == 0, new_arr, "Array slice step size cannot be zero.");
|
||||
|
||||
if (empty()) // Don't try to slice empty arrays.
|
||||
return new_arr;
|
||||
if (p_step > 0) {
|
||||
if (p_begin >= size() || p_end < -size())
|
||||
return new_arr;
|
||||
} else { // p_step < 0
|
||||
if (p_begin < -size() || p_end >= size())
|
||||
return new_arr;
|
||||
}
|
||||
|
||||
int begin = _clamp_slice_index(p_begin);
|
||||
int end = _clamp_slice_index(p_end);
|
||||
|
||||
int new_arr_size = MAX(((end - begin + p_step) / p_step), 0);
|
||||
new_arr.resize(new_arr_size);
|
||||
|
||||
if (p_step > 0) {
|
||||
int dest_idx = 0;
|
||||
for (int idx = begin; idx <= end; idx += p_step) {
|
||||
ERR_FAIL_COND_V_MSG(dest_idx < 0 || dest_idx >= new_arr_size, Array(), "Bug in Array slice()");
|
||||
new_arr[dest_idx++] = p_deep ? get(idx).duplicate(p_deep) : get(idx);
|
||||
}
|
||||
} else { // p_step < 0
|
||||
int dest_idx = 0;
|
||||
for (int idx = begin; idx >= end; idx += p_step) {
|
||||
ERR_FAIL_COND_V_MSG(dest_idx < 0 || dest_idx >= new_arr_size, Array(), "Bug in Array slice()");
|
||||
new_arr[dest_idx++] = p_deep ? get(idx).duplicate(p_deep) : get(idx);
|
||||
}
|
||||
}
|
||||
|
||||
return new_arr;
|
||||
}
|
||||
|
||||
struct _ArrayVariantSort {
|
||||
|
||||
_FORCE_INLINE_ bool operator()(const Variant &p_l, const Variant &p_r) const {
|
||||
@ -309,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) {
|
||||
|
||||
@ -405,62 +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;
|
||||
}
|
||||
|
||||
const void *Array::id() const {
|
||||
return _p->array.ptr();
|
||||
}
|
||||
|
||||
Array::Array(const Array &p_from) {
|
||||
|
||||
_p = NULL;
|
||||
_ref(p_from);
|
||||
}
|
||||
|
||||
Array::Array() {
|
||||
|
||||
_p = memnew(ArrayPrivate);
|
||||
|
||||
19
core/array.h
19
core/array.h
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -31,8 +31,7 @@
|
||||
#ifndef ARRAY_H
|
||||
#define ARRAY_H
|
||||
|
||||
#include "core/typedefs.h"
|
||||
|
||||
#include "typedefs.h"
|
||||
class Variant;
|
||||
class ArrayPrivate;
|
||||
class Object;
|
||||
@ -44,8 +43,6 @@ class Array {
|
||||
void _ref(const Array &p_from) const;
|
||||
void _unref() const;
|
||||
|
||||
inline int _clamp_slice_index(int p_index) const;
|
||||
|
||||
public:
|
||||
Variant &operator[](int p_idx);
|
||||
const Variant &operator[](int p_idx) const;
|
||||
@ -74,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();
|
||||
@ -91,14 +87,7 @@ public:
|
||||
Variant pop_back();
|
||||
Variant pop_front();
|
||||
|
||||
Array duplicate(bool p_deep = false) const;
|
||||
|
||||
Array slice(int p_begin, int p_end, int p_step = 1, bool p_deep = false) const;
|
||||
|
||||
Variant min() const;
|
||||
Variant max() const;
|
||||
|
||||
const void *id() const;
|
||||
Array duplicate() const;
|
||||
|
||||
Array(const Array &p_from);
|
||||
Array();
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
Import("env")
|
||||
Import('env')
|
||||
|
||||
env.add_source_files(env.core_sources, "*.cpp")
|
||||
|
||||
Export('env')
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -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,12 +76,11 @@ 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; }
|
||||
|
||||
Error save(const String &p_path, const RES &p_resource, SaverFlags p_flags);
|
||||
Error save(const String &p_path, const RES &p_resource, uint32_t p_flags);
|
||||
PoolVector<String> get_recognized_extensions(const RES &p_resource);
|
||||
|
||||
_ResourceSaver();
|
||||
@ -103,17 +98,12 @@ 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.
|
||||
POWERSTATE_NO_BATTERY, // Plugged in, no battery available.
|
||||
POWERSTATE_CHARGING, // Plugged in, charging battery.
|
||||
POWERSTATE_CHARGED // Plugged in, battery charged.
|
||||
POWERSTATE_UNKNOWN, /**< cannot determine power status */
|
||||
POWERSTATE_ON_BATTERY, /**< Not plugged in, running on the battery */
|
||||
POWERSTATE_NO_BATTERY, /**< Plugged in, no battery available */
|
||||
POWERSTATE_CHARGING, /**< Plugged in, charging battery */
|
||||
POWERSTATE_CHARGED /**< Plugged in, battery charged */
|
||||
};
|
||||
|
||||
enum Weekday {
|
||||
@ -127,8 +117,8 @@ public:
|
||||
};
|
||||
|
||||
enum Month {
|
||||
// Start at 1 to follow Windows SYSTEMTIME structure
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724950(v=vs.85).aspx
|
||||
/// Start at 1 to follow Windows SYSTEMTIME structure
|
||||
/// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724950(v=vs.85).aspx
|
||||
MONTH_JANUARY = 1,
|
||||
MONTH_FEBRUARY,
|
||||
MONTH_MARCH,
|
||||
@ -143,11 +133,6 @@ public:
|
||||
MONTH_DECEMBER
|
||||
};
|
||||
|
||||
void global_menu_add_item(const String &p_menu, const String &p_label, const Variant &p_signal, const Variant &p_meta);
|
||||
void global_menu_add_separator(const String &p_menu);
|
||||
void global_menu_remove_item(const String &p_menu, int p_idx);
|
||||
void global_menu_clear(const String &p_menu);
|
||||
|
||||
Point2 get_mouse_position() const;
|
||||
void set_window_title(const String &p_title);
|
||||
int get_mouse_button_state() const;
|
||||
@ -161,34 +146,17 @@ 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);
|
||||
virtual Point2 get_screen_position(int p_screen = -1) const;
|
||||
virtual Size2 get_screen_size(int p_screen = -1) const;
|
||||
virtual int get_screen_dpi(int p_screen = -1) const;
|
||||
virtual float get_screen_scale(int p_screen = -1) const;
|
||||
virtual float get_screen_max_scale() const;
|
||||
virtual Point2 get_window_position() const;
|
||||
virtual void set_window_position(const Point2 &p_position);
|
||||
virtual Size2 get_max_window_size() const;
|
||||
virtual Size2 get_min_window_size() const;
|
||||
virtual Size2 get_window_size() const;
|
||||
virtual Size2 get_real_window_size() const;
|
||||
virtual Rect2 get_window_safe_area() const;
|
||||
virtual void set_max_window_size(const Size2 &p_size);
|
||||
virtual void set_min_window_size(const Size2 &p_size);
|
||||
virtual void set_window_size(const Size2 &p_size);
|
||||
virtual void set_window_fullscreen(bool p_enabled);
|
||||
virtual bool is_window_fullscreen() const;
|
||||
@ -200,21 +168,13 @@ public:
|
||||
virtual bool is_window_maximized() const;
|
||||
virtual void set_window_always_on_top(bool p_enabled);
|
||||
virtual bool is_window_always_on_top() const;
|
||||
virtual bool is_window_focused() 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();
|
||||
@ -225,11 +185,8 @@ public:
|
||||
void set_low_processor_usage_mode(bool p_enabled);
|
||||
bool is_in_low_processor_usage_mode() const;
|
||||
|
||||
void set_low_processor_usage_mode_sleep_usec(int p_usec);
|
||||
int get_low_processor_usage_mode_sleep_usec() const;
|
||||
|
||||
String get_executable_path() const;
|
||||
int execute(const String &p_path, const Vector<String> &p_arguments, bool p_blocking = true, Array p_output = Array(), bool p_read_stderr = false);
|
||||
int execute(const String &p_path, const Vector<String> &p_arguments, bool p_blocking, Array p_output = Array());
|
||||
|
||||
Error kill(int p_pid);
|
||||
Error shell_open(String p_uri);
|
||||
@ -244,11 +201,6 @@ public:
|
||||
|
||||
String get_locale() const;
|
||||
String get_latin_keyboard_variant() const;
|
||||
int keyboard_get_layout_count() const;
|
||||
int keyboard_get_current_layout() const;
|
||||
void keyboard_set_current_layout(int p_index);
|
||||
String keyboard_get_layout_language(int p_index) const;
|
||||
String keyboard_get_layout_name(int p_index) const;
|
||||
|
||||
String get_model_name() const;
|
||||
|
||||
@ -256,7 +208,7 @@ public:
|
||||
void dump_resources_to_file(const String &p_file);
|
||||
|
||||
bool has_virtual_keyboard() const;
|
||||
void show_virtual_keyboard(const String &p_existing_text = "", bool p_multiline = false);
|
||||
void show_virtual_keyboard(const String &p_existing_text = "");
|
||||
void hide_virtual_keyboard();
|
||||
int get_virtual_keyboard_height();
|
||||
|
||||
@ -275,9 +227,26 @@ public:
|
||||
bool is_scancode_unicode(uint32_t p_unicode) const;
|
||||
int find_scancode_from_string(const String &p_code) const;
|
||||
|
||||
/*
|
||||
struct Date {
|
||||
|
||||
int year;
|
||||
Month month;
|
||||
int day;
|
||||
Weekday weekday;
|
||||
bool dst;
|
||||
};
|
||||
|
||||
struct Time {
|
||||
|
||||
int hour;
|
||||
int min;
|
||||
int sec;
|
||||
};
|
||||
*/
|
||||
|
||||
void set_use_file_access_save_and_swap(bool p_enable);
|
||||
|
||||
void set_native_icon(const String &p_filename);
|
||||
void set_icon(const Ref<Image> &p_icon);
|
||||
|
||||
int get_exit_code() const;
|
||||
@ -285,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;
|
||||
@ -353,30 +320,17 @@ public:
|
||||
void set_use_vsync(bool p_enable);
|
||||
bool is_vsync_enabled() const;
|
||||
|
||||
void set_vsync_via_compositor(bool p_enable);
|
||||
bool is_vsync_via_compositor_enabled() const;
|
||||
|
||||
PowerState get_power_state();
|
||||
int get_power_seconds_left();
|
||||
int get_power_percent_left();
|
||||
|
||||
bool has_feature(const String &p_feature) const;
|
||||
|
||||
bool request_permission(const String &p_name);
|
||||
bool request_permissions();
|
||||
Vector<String> get_granted_permissions() const;
|
||||
|
||||
int get_tablet_driver_count() const;
|
||||
String get_tablet_driver_name(int p_driver) const;
|
||||
String get_current_tablet_driver() const;
|
||||
void set_current_tablet_driver(const String &p_driver);
|
||||
|
||||
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);
|
||||
@ -398,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);
|
||||
@ -412,58 +365,18 @@ public:
|
||||
PoolVector<Vector3> segment_intersects_sphere(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_sphere_pos, real_t p_sphere_radius);
|
||||
PoolVector<Vector3> segment_intersects_cylinder(const Vector3 &p_from, const Vector3 &p_to, float p_height, float p_radius);
|
||||
PoolVector<Vector3> segment_intersects_convex(const Vector3 &p_from, const Vector3 &p_to, const Vector<Plane> &p_planes);
|
||||
bool is_point_in_circle(const Vector2 &p_point, const Vector2 &p_circle_pos, real_t p_circle_radius);
|
||||
real_t segment_intersects_circle(const Vector2 &p_from, const Vector2 &p_to, const Vector2 &p_circle_pos, real_t p_circle_radius);
|
||||
int get_uv84_normal_bit(const Vector3 &p_vector);
|
||||
|
||||
bool is_polygon_clockwise(const Vector<Vector2> &p_polygon);
|
||||
bool is_point_in_polygon(const Point2 &p_point, const Vector<Vector2> &p_polygon);
|
||||
Vector<int> triangulate_polygon(const Vector<Vector2> &p_polygon);
|
||||
Vector<int> triangulate_delaunay_2d(const Vector<Vector2> &p_points);
|
||||
Vector<Point2> convex_hull_2d(const Vector<Point2> &p_points);
|
||||
Vector<Vector3> clip_polygon(const Vector<Vector3> &p_points, const Plane &p_plane);
|
||||
|
||||
enum PolyBooleanOperation {
|
||||
OPERATION_UNION,
|
||||
OPERATION_DIFFERENCE,
|
||||
OPERATION_INTERSECTION,
|
||||
OPERATION_XOR
|
||||
};
|
||||
// 2D polygon boolean operations.
|
||||
Array merge_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Union (add).
|
||||
Array clip_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Difference (subtract).
|
||||
Array intersect_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Common area (multiply).
|
||||
Array exclude_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // All but common area (xor).
|
||||
|
||||
// 2D polyline vs polygon operations.
|
||||
Array clip_polyline_with_polygon_2d(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon); // Cut.
|
||||
Array intersect_polyline_with_polygon_2d(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon); // Chop.
|
||||
|
||||
// 2D offset polygons/polylines.
|
||||
enum PolyJoinType {
|
||||
JOIN_SQUARE,
|
||||
JOIN_ROUND,
|
||||
JOIN_MITER
|
||||
};
|
||||
enum PolyEndType {
|
||||
END_POLYGON,
|
||||
END_JOINED,
|
||||
END_BUTT,
|
||||
END_SQUARE,
|
||||
END_ROUND
|
||||
};
|
||||
Array offset_polygon_2d(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type = JOIN_SQUARE);
|
||||
Array offset_polyline_2d(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type = JOIN_SQUARE, PolyEndType p_end_type = END_SQUARE);
|
||||
|
||||
Dictionary make_atlas(const Vector<Size2> &p_rects);
|
||||
|
||||
_Geometry();
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(_Geometry::PolyBooleanOperation);
|
||||
VARIANT_ENUM_CAST(_Geometry::PolyJoinType);
|
||||
VARIANT_ENUM_CAST(_Geometry::PolyEndType);
|
||||
|
||||
class _File : public Reference {
|
||||
|
||||
GDCLASS(_File, Reference);
|
||||
@ -489,56 +402,55 @@ public:
|
||||
COMPRESSION_GZIP = Compression::MODE_GZIP
|
||||
};
|
||||
|
||||
Error open_encrypted(const String &p_path, ModeFlags p_mode_flags, const Vector<uint8_t> &p_key);
|
||||
Error open_encrypted_pass(const String &p_path, ModeFlags p_mode_flags, const String &p_pass);
|
||||
Error open_compressed(const String &p_path, ModeFlags p_mode_flags, CompressionMode p_compress_mode = COMPRESSION_FASTLZ);
|
||||
Error open_encrypted(const String &p_path, int p_mode_flags, const Vector<uint8_t> &p_key);
|
||||
Error open_encrypted_pass(const String &p_path, int p_mode_flags, const String &p_pass);
|
||||
Error open_compressed(const String &p_path, int p_mode_flags, int p_compress_mode = 0);
|
||||
|
||||
Error open(const String &p_path, ModeFlags p_mode_flags); // open a file.
|
||||
void close(); // Close a file.
|
||||
bool is_open() const; // True when file is open.
|
||||
Error open(const String &p_path, int p_mode_flags); ///< open a file
|
||||
void close(); ///< close a file
|
||||
bool is_open() const; ///< true when file is open
|
||||
|
||||
String get_path() const; // Returns the path for the current open file.
|
||||
String get_path_absolute() const; // Returns the absolute path for the current open file.
|
||||
String get_path() const; /// returns the path for the current open file
|
||||
String get_path_absolute() const; /// returns the absolute path for the current open file
|
||||
|
||||
void seek(int64_t p_position); // Seek to a given position.
|
||||
void seek_end(int64_t p_position = 0); // Seek from the end of file.
|
||||
int64_t get_position() const; // Get position in the file.
|
||||
int64_t get_len() const; // Get size of the file.
|
||||
void seek(int64_t p_position); ///< seek to a given position
|
||||
void seek_end(int64_t p_position = 0); ///< seek from the end of file
|
||||
int64_t get_position() const; ///< get position in the file
|
||||
int64_t get_len() const; ///< get size of the file
|
||||
|
||||
bool eof_reached() const; // Reading passed EOF.
|
||||
bool eof_reached() const; ///< reading passed EOF
|
||||
|
||||
uint8_t get_8() const; // Get a byte.
|
||||
uint16_t get_16() const; // Get 16 bits uint.
|
||||
uint32_t get_32() const; // Get 32 bits uint.
|
||||
uint64_t get_64() const; // Get 64 bits uint.
|
||||
uint8_t get_8() const; ///< get a byte
|
||||
uint16_t get_16() const; ///< get 16 bits uint
|
||||
uint32_t get_32() const; ///< get 32 bits uint
|
||||
uint64_t get_64() const; ///< get 64 bits uint
|
||||
|
||||
float get_float() const;
|
||||
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.
|
||||
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;
|
||||
|
||||
/* Use this for files WRITTEN in _big_ endian machines (ie, amiga/mac).
|
||||
/**< use this for files WRITTEN in _big_ endian machines (ie, amiga/mac)
|
||||
* It's not about the current CPU type but file formats.
|
||||
* This flags get reset to false (little endian) on each open.
|
||||
* this flags get reset to false (little endian) on each open
|
||||
*/
|
||||
|
||||
void set_endian_swap(bool p_swap);
|
||||
bool get_endian_swap();
|
||||
|
||||
Error get_error() const; // Get last error.
|
||||
Error get_error() const; ///< get last error
|
||||
|
||||
void store_8(uint8_t p_dest); // Store a byte.
|
||||
void store_16(uint16_t p_dest); // Store 16 bits uint.
|
||||
void store_32(uint32_t p_dest); // Store 32 bits uint.
|
||||
void store_64(uint64_t p_dest); // Store 64 bits uint.
|
||||
void store_8(uint8_t p_dest); ///< store a byte
|
||||
void store_16(uint16_t p_dest); ///< store 16 bits uint
|
||||
void store_32(uint32_t p_dest); ///< store 32 bits uint
|
||||
void store_64(uint64_t p_dest); ///< store 64 bits uint
|
||||
|
||||
void store_float(float p_dest);
|
||||
void store_double(double p_dest);
|
||||
@ -546,16 +458,17 @@ 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();
|
||||
|
||||
void store_buffer(const PoolVector<uint8_t> &p_buffer); // Store an array of bytes.
|
||||
Vector<String> get_csv_line(String delim = ",") const;
|
||||
|
||||
void store_var(const Variant &p_var, bool p_full_objects = false);
|
||||
void store_buffer(const PoolVector<uint8_t> &p_buffer); ///< store an array of bytes
|
||||
|
||||
bool file_exists(const String &p_name) const; // Return true if a file exists.
|
||||
void store_var(const Variant &p_var);
|
||||
|
||||
bool file_exists(const String &p_name) const; ///< return true if a file exists
|
||||
|
||||
uint64_t get_modified_time(const String &p_file) const;
|
||||
|
||||
@ -577,18 +490,18 @@ protected:
|
||||
public:
|
||||
Error open(const String &p_path);
|
||||
|
||||
Error list_dir_begin(bool p_skip_navigational = false, bool p_skip_hidden = false); // This starts dir listing.
|
||||
Error list_dir_begin(bool p_skip_navigational = false, bool p_skip_hidden = false); ///< This starts dir listing
|
||||
String get_next();
|
||||
bool current_is_dir() const;
|
||||
|
||||
void list_dir_end();
|
||||
void list_dir_end(); ///<
|
||||
|
||||
int get_drive_count();
|
||||
String get_drive(int p_drive);
|
||||
int get_current_drive();
|
||||
|
||||
Error change_dir(String p_dir); // Can be relative or absolute, return false on success.
|
||||
String get_current_dir(); // Return current dir location.
|
||||
Error change_dir(String p_dir); ///< can be relative or absolute, return false on success
|
||||
String get_current_dir(); ///< return current dir location
|
||||
|
||||
Error make_dir(String p_dir);
|
||||
Error make_dir_recursive(String p_dir);
|
||||
@ -610,9 +523,9 @@ private:
|
||||
bool _list_skip_hidden;
|
||||
};
|
||||
|
||||
class _Marshalls : public Object {
|
||||
class _Marshalls : public Reference {
|
||||
|
||||
GDCLASS(_Marshalls, Object);
|
||||
GDCLASS(_Marshalls, Reference);
|
||||
|
||||
static _Marshalls *singleton;
|
||||
|
||||
@ -622,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);
|
||||
@ -685,11 +598,10 @@ public:
|
||||
|
||||
PRIORITY_LOW,
|
||||
PRIORITY_NORMAL,
|
||||
PRIORITY_HIGH,
|
||||
PRIORITY_MAX
|
||||
PRIORITY_HIGH
|
||||
};
|
||||
|
||||
Error start(Object *p_instance, const StringName &p_method, const Variant &p_userdata = Variant(), Priority p_priority = PRIORITY_NORMAL);
|
||||
Error start(Object *p_instance, const StringName &p_method, const Variant &p_userdata = Variant(), int p_priority = PRIORITY_NORMAL);
|
||||
String get_id() const;
|
||||
bool is_active() const;
|
||||
Variant wait_to_finish();
|
||||
@ -702,7 +614,7 @@ VARIANT_ENUM_CAST(_Thread::Priority);
|
||||
|
||||
class _ClassDB : public Object {
|
||||
|
||||
GDCLASS(_ClassDB, Object);
|
||||
GDCLASS(_ClassDB, Object)
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
@ -751,16 +663,10 @@ 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;
|
||||
float get_physics_interpolation_fraction() const;
|
||||
|
||||
void set_target_fps(int p_fps);
|
||||
int get_target_fps() const;
|
||||
|
||||
float get_frames_per_second() const;
|
||||
uint64_t get_physics_frames() const;
|
||||
uint64_t get_idle_frames() const;
|
||||
|
||||
int get_frames_drawn();
|
||||
|
||||
@ -770,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;
|
||||
|
||||
@ -790,7 +691,7 @@ public:
|
||||
class _JSON;
|
||||
|
||||
class JSONParseResult : public Reference {
|
||||
GDCLASS(JSONParseResult, Reference);
|
||||
GDCLASS(JSONParseResult, Reference)
|
||||
|
||||
friend class _JSON;
|
||||
|
||||
@ -815,13 +716,10 @@ public:
|
||||
|
||||
void set_result(const Variant &p_result);
|
||||
Variant get_result() const;
|
||||
|
||||
JSONParseResult() :
|
||||
error_line(-1) {}
|
||||
};
|
||||
|
||||
class _JSON : public Object {
|
||||
GDCLASS(_JSON, Object);
|
||||
GDCLASS(_JSON, Object)
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -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() {
|
||||
}
|
||||
|
||||
@ -312,19 +313,6 @@ void ClassDB::get_inheriters_from_class(const StringName &p_class, List<StringNa
|
||||
}
|
||||
}
|
||||
|
||||
void ClassDB::get_direct_inheriters_from_class(const StringName &p_class, List<StringName> *p_classes) {
|
||||
|
||||
OBJTYPE_RLOCK;
|
||||
|
||||
const StringName *k = NULL;
|
||||
|
||||
while ((k = classes.next(k))) {
|
||||
|
||||
if (*k != p_class && get_parent_class(*k) == p_class)
|
||||
p_classes->push_back(*k);
|
||||
}
|
||||
}
|
||||
|
||||
StringName ClassDB::get_parent_class_nocheck(const StringName &p_class) {
|
||||
|
||||
OBJTYPE_RLOCK;
|
||||
@ -340,7 +328,7 @@ StringName ClassDB::get_parent_class(const StringName &p_class) {
|
||||
OBJTYPE_RLOCK;
|
||||
|
||||
ClassInfo *ti = classes.getptr(p_class);
|
||||
ERR_FAIL_COND_V_MSG(!ti, StringName(), "Cannot get class '" + String(p_class) + "'.");
|
||||
ERR_FAIL_COND_V(!ti, StringName());
|
||||
return ti->inherits;
|
||||
}
|
||||
|
||||
@ -350,7 +338,7 @@ ClassDB::APIType ClassDB::get_api_type(const StringName &p_class) {
|
||||
|
||||
ClassInfo *ti = classes.getptr(p_class);
|
||||
|
||||
ERR_FAIL_COND_V_MSG(!ti, API_NONE, "Cannot get class '" + String(p_class) + "'.");
|
||||
ERR_FAIL_COND_V(!ti, API_NONE);
|
||||
return ti->api;
|
||||
}
|
||||
|
||||
@ -375,7 +363,7 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
|
||||
for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
|
||||
|
||||
ClassInfo *t = classes.getptr(E->get());
|
||||
ERR_FAIL_COND_V_MSG(!t, 0, "Cannot get class '" + String(E->get()) + "'.");
|
||||
ERR_FAIL_COND_V(!t, 0);
|
||||
if (t->api != p_api || !t->exposed)
|
||||
continue;
|
||||
hash = hash_djb2_one_64(t->name.hash(), hash);
|
||||
@ -389,13 +377,6 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
|
||||
|
||||
while ((k = t->method_map.next(k))) {
|
||||
|
||||
String name = k->operator String();
|
||||
|
||||
ERR_CONTINUE(name.empty());
|
||||
|
||||
if (name[0] == '_')
|
||||
continue; // Ignore non-virtual methods that start with an underscore
|
||||
|
||||
snames.push_back(*k);
|
||||
}
|
||||
|
||||
@ -487,7 +468,6 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
|
||||
for (List<StringName>::Element *F = snames.front(); F; F = F->next()) {
|
||||
|
||||
PropertySetGet *psg = t->property_setget.getptr(F->get());
|
||||
ERR_FAIL_COND_V(!psg, 0);
|
||||
|
||||
hash = hash_djb2_one_64(F->get().hash(), hash);
|
||||
hash = hash_djb2_one_64(psg->setter.hash(), hash);
|
||||
@ -535,16 +515,11 @@ Object *ClassDB::instance(const StringName &p_class) {
|
||||
ti = classes.getptr(compat_classes[p_class]);
|
||||
}
|
||||
}
|
||||
ERR_FAIL_COND_V_MSG(!ti, NULL, "Cannot get class '" + String(p_class) + "'.");
|
||||
ERR_FAIL_COND_V_MSG(ti->disabled, NULL, "Class '" + String(p_class) + "' is disabled.");
|
||||
ERR_FAIL_COND_V(!ti, NULL);
|
||||
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) {
|
||||
@ -552,12 +527,7 @@ bool ClassDB::can_instance(const StringName &p_class) {
|
||||
OBJTYPE_RLOCK;
|
||||
|
||||
ClassInfo *ti = classes.getptr(p_class);
|
||||
ERR_FAIL_COND_V_MSG(!ti, false, "Cannot get class '" + String(p_class) + "'.");
|
||||
#ifdef TOOLS_ENABLED
|
||||
if (ti->api == API_EDITOR && !Engine::get_singleton()->is_editor_hint()) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
ERR_FAIL_COND_V(!ti, false);
|
||||
return (!ti->disabled && ti->creation_func != NULL);
|
||||
}
|
||||
|
||||
@ -565,9 +535,9 @@ void ClassDB::_add_class2(const StringName &p_class, const StringName &p_inherit
|
||||
|
||||
OBJTYPE_WLOCK;
|
||||
|
||||
const StringName &name = p_class;
|
||||
StringName name = p_class;
|
||||
|
||||
ERR_FAIL_COND_MSG(classes.has(name), "Class '" + String(p_class) + "' already exists.");
|
||||
ERR_FAIL_COND(classes.has(name));
|
||||
|
||||
classes[name] = ClassInfo();
|
||||
ClassInfo &ti = classes[name];
|
||||
@ -679,8 +649,10 @@ void ClassDB::bind_integer_constant(const StringName &p_class, const StringName
|
||||
OBJTYPE_WLOCK;
|
||||
|
||||
ClassInfo *type = classes.getptr(p_class);
|
||||
if (!type) {
|
||||
|
||||
ERR_FAIL_COND(!type);
|
||||
ERR_FAIL_COND(!type);
|
||||
}
|
||||
|
||||
if (type->constant_map.has(p_name)) {
|
||||
|
||||
@ -688,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()) {
|
||||
@ -706,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
|
||||
}
|
||||
@ -762,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;
|
||||
@ -830,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) {
|
||||
|
||||
@ -838,12 +812,15 @@ 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) {
|
||||
ERR_FAIL_COND_MSG(check->signal_map.has(sname), "Class '" + String(p_class) + "' already has signal '" + String(sname) + "'.");
|
||||
if (check->signal_map.has(sname)) {
|
||||
ERR_EXPLAIN("Type " + String(p_class) + " already has signal: " + String(sname));
|
||||
ERR_FAIL();
|
||||
}
|
||||
check = check->inherits_ptr;
|
||||
}
|
||||
#endif
|
||||
@ -918,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);
|
||||
|
||||
@ -928,11 +911,16 @@ void ClassDB::add_property(StringName p_class, const PropertyInfo &p_pinfo, cons
|
||||
if (p_setter) {
|
||||
mb_set = get_method(p_class, p_setter);
|
||||
#ifdef DEBUG_METHODS_ENABLED
|
||||
|
||||
ERR_FAIL_COND_MSG(!mb_set, "Invalid setter '" + p_class + "::" + p_setter + "' for property '" + p_pinfo.name + "'.");
|
||||
|
||||
int exp_args = 1 + (p_index >= 0 ? 1 : 0);
|
||||
ERR_FAIL_COND_MSG(mb_set->get_argument_count() != exp_args, "Invalid function for setter '" + p_class + "::" + p_setter + " for property '" + p_pinfo.name + "'.");
|
||||
if (!mb_set) {
|
||||
ERR_EXPLAIN("Invalid Setter: " + p_class + "::" + p_setter + " for property: " + p_pinfo.name);
|
||||
ERR_FAIL_COND(!mb_set);
|
||||
} else {
|
||||
int exp_args = 1 + (p_index >= 0 ? 1 : 0);
|
||||
if (mb_set->get_argument_count() != exp_args) {
|
||||
ERR_EXPLAIN("Invalid Function for Setter: " + p_class + "::" + p_setter + " for property: " + p_pinfo.name);
|
||||
ERR_FAIL();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -942,15 +930,26 @@ void ClassDB::add_property(StringName p_class, const PropertyInfo &p_pinfo, cons
|
||||
mb_get = get_method(p_class, p_getter);
|
||||
#ifdef DEBUG_METHODS_ENABLED
|
||||
|
||||
ERR_FAIL_COND_MSG(!mb_get, "Invalid getter '" + p_class + "::" + p_getter + "' for property '" + p_pinfo.name + "'.");
|
||||
if (!mb_get) {
|
||||
ERR_EXPLAIN("Invalid Getter: " + p_class + "::" + p_getter + " for property: " + p_pinfo.name);
|
||||
ERR_FAIL_COND(!mb_get);
|
||||
} else {
|
||||
|
||||
int exp_args = 0 + (p_index >= 0 ? 1 : 0);
|
||||
ERR_FAIL_COND_MSG(mb_get->get_argument_count() != exp_args, "Invalid function for getter '" + p_class + "::" + p_getter + "' for property: '" + p_pinfo.name + "'.");
|
||||
int exp_args = 0 + (p_index >= 0 ? 1 : 0);
|
||||
if (mb_get->get_argument_count() != exp_args) {
|
||||
ERR_EXPLAIN("Invalid Function for Getter: " + p_class + "::" + p_getter + " for property: " + p_pinfo.name);
|
||||
ERR_FAIL();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef DEBUG_METHODS_ENABLED
|
||||
ERR_FAIL_COND_MSG(type->property_setget.has(p_pinfo.name), "Object '" + p_class + "' already has property '" + p_pinfo.name + "'.");
|
||||
|
||||
if (type->property_setget.has(p_pinfo.name)) {
|
||||
ERR_EXPLAIN("Object already has property: " + p_class);
|
||||
ERR_FAIL();
|
||||
}
|
||||
#endif
|
||||
|
||||
OBJTYPE_WLOCK
|
||||
@ -975,13 +974,6 @@ void ClassDB::add_property(StringName p_class, const PropertyInfo &p_pinfo, cons
|
||||
type->property_setget[p_pinfo.name] = psg;
|
||||
}
|
||||
|
||||
void ClassDB::set_property_default_value(StringName p_class, const StringName &p_name, const Variant &p_default) {
|
||||
if (!default_values.has(p_class)) {
|
||||
default_values[p_class] = HashMap<StringName, Variant>();
|
||||
}
|
||||
default_values[p_class][p_name] = p_default;
|
||||
}
|
||||
|
||||
void ClassDB::get_property_list(StringName p_class, List<PropertyInfo> *p_list, bool p_no_inheritance, const Object *p_validator) {
|
||||
|
||||
OBJTYPE_RLOCK;
|
||||
@ -1138,7 +1130,7 @@ Variant::Type ClassDB::get_property_type(const StringName &p_class, const String
|
||||
return Variant::NIL;
|
||||
}
|
||||
|
||||
StringName ClassDB::get_property_setter(StringName p_class, const StringName &p_property) {
|
||||
StringName ClassDB::get_property_setter(StringName p_class, const StringName p_property) {
|
||||
|
||||
ClassInfo *type = classes.getptr(p_class);
|
||||
ClassInfo *check = type;
|
||||
@ -1155,7 +1147,7 @@ StringName ClassDB::get_property_setter(StringName p_class, const StringName &p_
|
||||
return StringName();
|
||||
}
|
||||
|
||||
StringName ClassDB::get_property_getter(StringName p_class, const StringName &p_property) {
|
||||
StringName ClassDB::get_property_getter(StringName p_class, const StringName p_property) {
|
||||
|
||||
ClassInfo *type = classes.getptr(p_class);
|
||||
ClassInfo *check = type;
|
||||
@ -1229,26 +1221,32 @@ MethodBind *ClassDB::bind_methodfi(uint32_t p_flags, MethodBind *p_bind, const c
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
|
||||
ERR_FAIL_COND_V_MSG(has_method(instance_type, mdname), NULL, "Class " + String(instance_type) + " already has a method " + String(mdname) + ".");
|
||||
if (has_method(instance_type, mdname)) {
|
||||
ERR_EXPLAIN("Class " + String(instance_type) + " already has a method " + String(mdname));
|
||||
ERR_FAIL_V(NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
ClassInfo *type = classes.getptr(instance_type);
|
||||
if (!type) {
|
||||
ERR_PRINTS("Couldn't bind method '" + mdname + "' for instance: " + instance_type);
|
||||
memdelete(p_bind);
|
||||
ERR_FAIL_V_MSG(NULL, "Couldn't bind method '" + mdname + "' for instance '" + instance_type + "'.");
|
||||
ERR_FAIL_V(NULL);
|
||||
}
|
||||
|
||||
if (type->method_map.has(mdname)) {
|
||||
memdelete(p_bind);
|
||||
// overloading not supported
|
||||
ERR_FAIL_V_MSG(NULL, "Method already bound '" + instance_type + "::" + mdname + "'.");
|
||||
ERR_EXPLAIN("Method already bound: " + instance_type + "::" + mdname);
|
||||
ERR_FAIL_V(NULL);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_METHODS_ENABLED
|
||||
|
||||
if (method_name.args.size() > p_bind->get_argument_count()) {
|
||||
memdelete(p_bind);
|
||||
ERR_FAIL_V_MSG(NULL, "Method definition provides more arguments than the method actually has '" + instance_type + "::" + mdname + "'.");
|
||||
ERR_EXPLAIN("Method definition provides more arguments than the method actually has: " + instance_type + "::" + mdname);
|
||||
ERR_FAIL_V(NULL);
|
||||
}
|
||||
|
||||
p_bind->set_argument_names(method_name.args);
|
||||
@ -1263,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);
|
||||
@ -1272,7 +1270,7 @@ MethodBind *ClassDB::bind_methodfi(uint32_t p_flags, MethodBind *p_bind, const c
|
||||
}
|
||||
|
||||
void ClassDB::add_virtual_method(const StringName &p_class, const MethodInfo &p_method, bool p_virtual) {
|
||||
ERR_FAIL_COND_MSG(!classes.has(p_class), "Request for nonexistent class '" + p_class + "'.");
|
||||
ERR_FAIL_COND(!classes.has(p_class));
|
||||
|
||||
OBJTYPE_WLOCK;
|
||||
|
||||
@ -1287,7 +1285,7 @@ void ClassDB::add_virtual_method(const StringName &p_class, const MethodInfo &p_
|
||||
|
||||
void ClassDB::get_virtual_methods(const StringName &p_class, List<MethodInfo> *p_methods, bool p_no_inheritance) {
|
||||
|
||||
ERR_FAIL_COND_MSG(!classes.has(p_class), "Request for nonexistent class '" + p_class + "'.");
|
||||
ERR_FAIL_COND(!classes.has(p_class));
|
||||
|
||||
#ifdef DEBUG_METHODS_ENABLED
|
||||
|
||||
@ -1311,7 +1309,7 @@ void ClassDB::set_class_enabled(StringName p_class, bool p_enable) {
|
||||
|
||||
OBJTYPE_WLOCK;
|
||||
|
||||
ERR_FAIL_COND_MSG(!classes.has(p_class), "Request for nonexistent class '" + p_class + "'.");
|
||||
ERR_FAIL_COND(!classes.has(p_class));
|
||||
classes[p_class].disabled = !p_enable;
|
||||
}
|
||||
|
||||
@ -1326,7 +1324,7 @@ bool ClassDB::is_class_enabled(StringName p_class) {
|
||||
}
|
||||
}
|
||||
|
||||
ERR_FAIL_COND_V_MSG(!ti, false, "Cannot get class '" + String(p_class) + "'.");
|
||||
ERR_FAIL_COND_V(!ti, false);
|
||||
return !ti->disabled;
|
||||
}
|
||||
|
||||
@ -1335,7 +1333,7 @@ bool ClassDB::is_class_exposed(StringName p_class) {
|
||||
OBJTYPE_RLOCK;
|
||||
|
||||
ClassInfo *ti = classes.getptr(p_class);
|
||||
ERR_FAIL_COND_V_MSG(!ti, false, "Cannot get class '" + String(p_class) + "'.");
|
||||
ERR_FAIL_COND_V(!ti, false);
|
||||
return ti->exposed;
|
||||
}
|
||||
|
||||
@ -1378,75 +1376,14 @@ void ClassDB::get_extensions_for_type(const StringName &p_class, List<String> *p
|
||||
}
|
||||
}
|
||||
|
||||
HashMap<StringName, HashMap<StringName, Variant> > ClassDB::default_values;
|
||||
Set<StringName> ClassDB::default_values_cached;
|
||||
|
||||
Variant ClassDB::class_get_default_property_value(const StringName &p_class, const StringName &p_property, bool *r_valid) {
|
||||
|
||||
if (!default_values_cached.has(p_class)) {
|
||||
|
||||
if (!default_values.has(p_class)) {
|
||||
default_values[p_class] = HashMap<StringName, Variant>();
|
||||
}
|
||||
|
||||
Object *c = NULL;
|
||||
bool cleanup_c = false;
|
||||
|
||||
if (Engine::get_singleton()->has_singleton(p_class)) {
|
||||
c = Engine::get_singleton()->get_singleton_object(p_class);
|
||||
cleanup_c = false;
|
||||
} else if (ClassDB::can_instance(p_class)) {
|
||||
c = ClassDB::instance(p_class);
|
||||
cleanup_c = true;
|
||||
}
|
||||
|
||||
if (c) {
|
||||
|
||||
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)) {
|
||||
|
||||
if (!default_values[p_class].has(E->get().name)) {
|
||||
Variant v = c->get(E->get().name);
|
||||
default_values[p_class][E->get().name] = v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cleanup_c) {
|
||||
memdelete(c);
|
||||
}
|
||||
}
|
||||
|
||||
default_values_cached.insert(p_class);
|
||||
}
|
||||
|
||||
if (!default_values.has(p_class)) {
|
||||
if (r_valid != NULL) *r_valid = false;
|
||||
return Variant();
|
||||
}
|
||||
|
||||
if (!default_values[p_class].has(p_property)) {
|
||||
if (r_valid != NULL) *r_valid = false;
|
||||
return Variant();
|
||||
}
|
||||
|
||||
if (r_valid != NULL) *r_valid = true;
|
||||
return default_values[p_class][p_property];
|
||||
}
|
||||
|
||||
RWLock *ClassDB::lock = NULL;
|
||||
|
||||
void ClassDB::init() {
|
||||
|
||||
#ifndef NO_THREADS
|
||||
|
||||
lock = RWLock::create();
|
||||
}
|
||||
|
||||
void ClassDB::cleanup_defaults() {
|
||||
|
||||
default_values.clear();
|
||||
default_values_cached.clear();
|
||||
#endif
|
||||
}
|
||||
|
||||
void ClassDB::cleanup() {
|
||||
@ -1469,7 +1406,10 @@ void ClassDB::cleanup() {
|
||||
resource_base_extensions.clear();
|
||||
compat_classes.clear();
|
||||
|
||||
#ifndef NO_THREADS
|
||||
|
||||
memdelete(lock);
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -31,13 +31,13 @@
|
||||
#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"
|
||||
|
||||
/** To bind more then 6 parameters include this:
|
||||
* #include "core/method_bind_ext.gen.inc"
|
||||
*/
|
||||
/**
|
||||
@author Juan Linietsky <reduzio@gmail.com>
|
||||
*/
|
||||
|
||||
#define DEFVAL(m_defval) (m_defval)
|
||||
|
||||
@ -114,20 +114,19 @@ public:
|
||||
|
||||
APIType api;
|
||||
ClassInfo *inherits_ptr;
|
||||
void *class_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;
|
||||
@ -144,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);
|
||||
@ -158,9 +157,6 @@ public:
|
||||
|
||||
static void _add_class2(const StringName &p_class, const StringName &p_inherits);
|
||||
|
||||
static HashMap<StringName, HashMap<StringName, Variant> > default_values;
|
||||
static Set<StringName> default_values_cached;
|
||||
|
||||
public:
|
||||
// DO NOT USE THIS!!!!!! NEEDS TO BE PUBLIC BUT DO NOT USE NO MATTER WHAT!!!
|
||||
template <class T>
|
||||
@ -178,7 +174,6 @@ public:
|
||||
ERR_FAIL_COND(!t);
|
||||
t->creation_func = &creator<T>;
|
||||
t->exposed = true;
|
||||
t->class_ptr = T::get_class_ptr_static();
|
||||
T::register_custom_data_to_otdb();
|
||||
}
|
||||
|
||||
@ -190,7 +185,6 @@ public:
|
||||
ClassInfo *t = classes.getptr(T::get_class_static());
|
||||
ERR_FAIL_COND(!t);
|
||||
t->exposed = true;
|
||||
t->class_ptr = T::get_class_ptr_static();
|
||||
//nothing
|
||||
}
|
||||
|
||||
@ -209,13 +203,11 @@ public:
|
||||
ERR_FAIL_COND(!t);
|
||||
t->creation_func = &_create_ptr_func<T>;
|
||||
t->exposed = true;
|
||||
t->class_ptr = T::get_class_ptr_static();
|
||||
T::register_custom_data_to_otdb();
|
||||
}
|
||||
|
||||
static void get_class_list(List<StringName> *p_classes);
|
||||
static void get_inheriters_from_class(const StringName &p_class, List<StringName> *p_classes);
|
||||
static void get_direct_inheriters_from_class(const StringName &p_class, List<StringName> *p_classes);
|
||||
static StringName get_parent_class_nocheck(const StringName &p_class);
|
||||
static StringName get_parent_class(const StringName &p_class);
|
||||
static bool class_exists(const StringName &p_class);
|
||||
@ -288,30 +280,12 @@ public:
|
||||
return bind_methodfi(METHOD_FLAGS_DEFAULT, bind, p_method_name, ptr, 6);
|
||||
}
|
||||
|
||||
template <class N, class M>
|
||||
static MethodBind *bind_method(N p_method_name, M p_method, const Variant &p_def1, const Variant &p_def2, const Variant &p_def3, const Variant &p_def4, const Variant &p_def5, const Variant &p_def6, const Variant &p_def7) {
|
||||
|
||||
MethodBind *bind = create_method_bind(p_method);
|
||||
const Variant *ptr[7] = { &p_def1, &p_def2, &p_def3, &p_def4, &p_def5, &p_def6, &p_def7 };
|
||||
|
||||
return bind_methodfi(METHOD_FLAGS_DEFAULT, bind, p_method_name, ptr, 7);
|
||||
}
|
||||
|
||||
template <class N, class M>
|
||||
static MethodBind *bind_method(N p_method_name, M p_method, const Variant &p_def1, const Variant &p_def2, const Variant &p_def3, const Variant &p_def4, const Variant &p_def5, const Variant &p_def6, const Variant &p_def7, const Variant &p_def8) {
|
||||
|
||||
MethodBind *bind = create_method_bind(p_method);
|
||||
const Variant *ptr[8] = { &p_def1, &p_def2, &p_def3, &p_def4, &p_def5, &p_def6, &p_def7, &p_def8 };
|
||||
|
||||
return bind_methodfi(METHOD_FLAGS_DEFAULT, bind, p_method_name, ptr, 8);
|
||||
}
|
||||
|
||||
template <class M>
|
||||
static MethodBind *bind_vararg_method(uint32_t p_flags, StringName p_name, M p_method, const MethodInfo &p_info = MethodInfo(), const Vector<Variant> &p_default_args = Vector<Variant>(), bool p_return_nil_is_variant = true) {
|
||||
static MethodBind *bind_vararg_method(uint32_t p_flags, StringName p_name, M p_method, const MethodInfo &p_info = MethodInfo(), const Vector<Variant> &p_default_args = Vector<Variant>()) {
|
||||
|
||||
GLOBAL_LOCK_FUNCTION;
|
||||
|
||||
MethodBind *bind = create_vararg_method_bind(p_method, p_info, p_return_nil_is_variant);
|
||||
MethodBind *bind = create_vararg_method_bind(p_method, p_info);
|
||||
ERR_FAIL_COND_V(!bind, NULL);
|
||||
|
||||
bind->set_name(p_name);
|
||||
@ -328,7 +302,8 @@ public:
|
||||
if (type->method_map.has(p_name)) {
|
||||
memdelete(bind);
|
||||
// overloading not supported
|
||||
ERR_FAIL_V_MSG(NULL, "Method already bound: " + instance_type + "::" + p_name + ".");
|
||||
ERR_EXPLAIN("Method already bound: " + instance_type + "::" + p_name);
|
||||
ERR_FAIL_V(NULL);
|
||||
}
|
||||
type->method_map[p_name] = bind;
|
||||
#ifdef DEBUG_METHODS_ENABLED
|
||||
@ -347,15 +322,14 @@ public:
|
||||
|
||||
static void add_property_group(StringName p_class, const String &p_name, const String &p_prefix = "");
|
||||
static void add_property(StringName p_class, const PropertyInfo &p_pinfo, const StringName &p_setter, const StringName &p_getter, int p_index = -1);
|
||||
static void set_property_default_value(StringName p_class, const StringName &p_name, const Variant &p_default);
|
||||
static void get_property_list(StringName p_class, List<PropertyInfo> *p_list, bool p_no_inheritance = false, const Object *p_validator = NULL);
|
||||
static bool set_property(Object *p_object, const StringName &p_property, const Variant &p_value, bool *r_valid = NULL);
|
||||
static bool get_property(Object *p_object, const StringName &p_property, Variant &r_value);
|
||||
static bool has_property(const StringName &p_class, const StringName &p_property, bool p_no_inheritance = false);
|
||||
static int get_property_index(const StringName &p_class, const StringName &p_property, bool *r_is_valid = NULL);
|
||||
static Variant::Type get_property_type(const StringName &p_class, const StringName &p_property, bool *r_is_valid = NULL);
|
||||
static StringName get_property_setter(StringName p_class, const StringName &p_property);
|
||||
static StringName get_property_getter(StringName p_class, const StringName &p_property);
|
||||
static StringName get_property_setter(StringName p_class, const StringName p_property);
|
||||
static StringName get_property_getter(StringName p_class, const StringName p_property);
|
||||
|
||||
static bool has_method(StringName p_class, StringName p_method, bool p_no_inheritance = false);
|
||||
static void set_method_flags(StringName p_class, StringName p_method, int p_flags);
|
||||
@ -370,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, bool *r_valid = NULL);
|
||||
#endif
|
||||
|
||||
static StringName get_category(const StringName &p_node);
|
||||
|
||||
@ -391,8 +365,6 @@ public:
|
||||
static void init();
|
||||
|
||||
static void set_current_api(APIType p_api);
|
||||
static APIType get_current_api();
|
||||
static void cleanup_defaults();
|
||||
static void cleanup();
|
||||
};
|
||||
|
||||
|
||||
200
core/color.cpp
200
core/color.cpp
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -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;
|
||||
}
|
||||
@ -214,11 +174,6 @@ void Color::set_hsv(float p_h, float p_s, float p_v, float p_alpha) {
|
||||
}
|
||||
}
|
||||
|
||||
bool Color::is_equal_approx(const Color &p_color) const {
|
||||
|
||||
return Math::is_equal_approx(r, p_color.r) && Math::is_equal_approx(g, p_color.g) && Math::is_equal_approx(b, p_color.b) && Math::is_equal_approx(a, p_color.a);
|
||||
}
|
||||
|
||||
void Color::invert() {
|
||||
|
||||
r = 1.0 - r;
|
||||
@ -245,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;
|
||||
@ -340,23 +267,36 @@ Color Color::html(const String &p_color) {
|
||||
} else if (color.length() == 6) {
|
||||
alpha = false;
|
||||
} else {
|
||||
ERR_FAIL_V_MSG(Color(), "Invalid color code: " + p_color + ".");
|
||||
ERR_EXPLAIN("Invalid Color Code: " + p_color);
|
||||
ERR_FAIL_V(Color());
|
||||
}
|
||||
|
||||
int a = 255;
|
||||
if (alpha) {
|
||||
a = _parse_col(color, 0);
|
||||
ERR_FAIL_COND_V_MSG(a < 0, Color(), "Invalid color code: " + p_color + ".");
|
||||
if (a < 0) {
|
||||
ERR_EXPLAIN("Invalid Color Code: " + p_color);
|
||||
ERR_FAIL_V(Color());
|
||||
}
|
||||
}
|
||||
|
||||
int from = alpha ? 2 : 0;
|
||||
|
||||
int r = _parse_col(color, from + 0);
|
||||
ERR_FAIL_COND_V_MSG(r < 0, Color(), "Invalid color code: " + p_color + ".");
|
||||
if (r < 0) {
|
||||
ERR_EXPLAIN("Invalid Color Code: " + p_color);
|
||||
ERR_FAIL_V(Color());
|
||||
}
|
||||
int g = _parse_col(color, from + 2);
|
||||
ERR_FAIL_COND_V_MSG(g < 0, Color(), "Invalid color code: " + p_color + ".");
|
||||
if (g < 0) {
|
||||
ERR_EXPLAIN("Invalid Color Code: " + p_color);
|
||||
ERR_FAIL_V(Color());
|
||||
}
|
||||
int b = _parse_col(color, from + 4);
|
||||
ERR_FAIL_COND_V_MSG(b < 0, Color(), "Invalid color code: " + p_color + ".");
|
||||
if (b < 0) {
|
||||
ERR_EXPLAIN("Invalid Color Code: " + p_color);
|
||||
ERR_FAIL_V(Color());
|
||||
}
|
||||
|
||||
return Color(r / 255.0, g / 255.0, b / 255.0, a / 255.0);
|
||||
}
|
||||
@ -380,8 +320,9 @@ bool Color::html_is_valid(const String &p_color) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int a = 255;
|
||||
if (alpha) {
|
||||
int a = _parse_col(color, 0);
|
||||
a = _parse_col(color, 0);
|
||||
if (a < 0) {
|
||||
return false;
|
||||
}
|
||||
@ -417,13 +358,17 @@ Color Color::named(const String &p_name) {
|
||||
name = name.to_lower();
|
||||
|
||||
const Map<String, Color>::Element *color = _named_colors.find(name);
|
||||
ERR_FAIL_NULL_V_MSG(color, Color(), "Invalid color name: " + p_name + ".");
|
||||
return color->value();
|
||||
if (color) {
|
||||
return color->value();
|
||||
} else {
|
||||
ERR_EXPLAIN("Invalid Color Name: " + p_name);
|
||||
ERR_FAIL_V(Color());
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@ -455,63 +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 {
|
||||
|
||||
WARN_DEPRECATED_MSG("'Color.gray()' is deprecated and will be removed in a future version. Use 'Color.v' for a better grayscale approximation.");
|
||||
return (r + g + b) / 3.0;
|
||||
}
|
||||
|
||||
|
||||
20
core/color.h
20
core/color.h
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -31,9 +31,11 @@
|
||||
#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>
|
||||
*/
|
||||
struct Color {
|
||||
|
||||
union {
|
||||
@ -53,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;
|
||||
@ -86,8 +85,6 @@ struct Color {
|
||||
void operator/=(const Color &p_color);
|
||||
void operator/=(const real_t &rvalue);
|
||||
|
||||
bool is_equal_approx(const Color &p_color) const;
|
||||
|
||||
void invert();
|
||||
void contrast();
|
||||
Color inverted() 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_rgbe);
|
||||
|
||||
_FORCE_INLINE_ bool operator<(const Color &p_color) const; //used in set keys
|
||||
operator String() const;
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
// Names from https://en.wikipedia.org/wiki/X11_color_names
|
||||
#include "core/map.h"
|
||||
// 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 "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));
|
||||
@ -143,7 +143,6 @@ static void _populate_named_colors() {
|
||||
_named_colors.insert("thistle", Color(0.85, 0.75, 0.85));
|
||||
_named_colors.insert("tomato", Color(1.00, 0.39, 0.28));
|
||||
_named_colors.insert("turquoise", Color(0.25, 0.88, 0.82));
|
||||
_named_colors.insert("transparent", Color(1.00, 1.00, 1.00, 0.00));
|
||||
_named_colors.insert("violet", Color(0.93, 0.51, 0.93));
|
||||
_named_colors.insert("wheat", Color(0.96, 0.87, 0.70));
|
||||
_named_colors.insert("white", Color(1.00, 1.00, 1.00));
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -31,11 +31,14 @@
|
||||
#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>
|
||||
*/
|
||||
|
||||
#define COMMA(N) _COMMA_##N
|
||||
#define _COMMA_0
|
||||
@ -51,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)
|
||||
@ -98,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)
|
||||
@ -141,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)
|
||||
@ -251,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)>
|
||||
@ -268,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 {
|
||||
|
||||
@ -294,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 *******/
|
||||
|
||||
@ -316,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;
|
||||
@ -328,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:
|
||||
|
||||
@ -342,7 +334,7 @@ class CommandQueueMT {
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
} else if (write_ptr >= dealloc_ptr) {
|
||||
// ahead of dealloc_ptr, check that there is room
|
||||
|
||||
if ((COMMAND_MEM_SIZE - write_ptr) < alloc_size + sizeof(uint32_t)) {
|
||||
@ -358,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];
|
||||
@ -370,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;
|
||||
}
|
||||
|
||||
@ -402,10 +393,8 @@ class CommandQueueMT {
|
||||
tryagain:
|
||||
|
||||
// tried to read an empty queue
|
||||
if (read_ptr == write_ptr) {
|
||||
if (p_lock) unlock();
|
||||
if (read_ptr == write_ptr)
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t size_ptr = read_ptr;
|
||||
uint32_t size = *(uint32_t *)&command_mem[read_ptr] >> 1;
|
||||
@ -416,7 +405,7 @@ class CommandQueueMT {
|
||||
goto tryagain;
|
||||
}
|
||||
|
||||
read_ptr += 8;
|
||||
read_ptr += sizeof(uint32_t);
|
||||
|
||||
CommandBase *cmd = reinterpret_cast<CommandBase *>(&command_mem[read_ptr]);
|
||||
|
||||
@ -443,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);
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -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;
|
||||
@ -62,6 +63,7 @@ void PHashTranslation::generate(const Ref<Translation> &p_from) {
|
||||
|
||||
int idx = 0;
|
||||
int total_compression_size = 0;
|
||||
int total_string_size = 0;
|
||||
|
||||
for (List<StringName>::Element *E = keys.front(); E; E = E->next()) {
|
||||
|
||||
@ -71,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();
|
||||
@ -82,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();
|
||||
@ -98,21 +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;
|
||||
|
||||
@ -130,11 +136,12 @@ void PHashTranslation::generate(const Ref<Translation> &p_from) {
|
||||
}
|
||||
}
|
||||
|
||||
hfunc_table.write[i] = d;
|
||||
hfunc_table[i] = d;
|
||||
bucket_table_size += 2 + b.size() * 4;
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(bucket_table_size == 0);
|
||||
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);
|
||||
@ -146,13 +153,16 @@ void PHashTranslation::generate(const Ref<Translation> &p_from) {
|
||||
uint32_t *btw = (uint32_t *)&btwb[0];
|
||||
|
||||
int btindex = 0;
|
||||
int collisions = 0;
|
||||
|
||||
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;
|
||||
} else if (t.size() > 1) {
|
||||
collisions += t.size() - 1;
|
||||
}
|
||||
|
||||
htw[i] = btindex;
|
||||
@ -168,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();
|
||||
|
||||
@ -186,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;
|
||||
@ -232,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
|
||||
}
|
||||
|
||||
@ -251,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();
|
||||
}
|
||||
|
||||
@ -259,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 {
|
||||
@ -268,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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -31,7 +31,7 @@
|
||||
#ifndef COMPRESSED_TRANSLATION_H
|
||||
#define COMPRESSED_TRANSLATION_H
|
||||
|
||||
#include "core/translation.h"
|
||||
#include "translation.h"
|
||||
|
||||
class PHashTranslation : public Translation {
|
||||
|
||||
|
||||
@ -1,309 +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",
|
||||
"Silver sponsors",
|
||||
"Bronze sponsors",
|
||||
"Mini sponsors",
|
||||
"Gold donors",
|
||||
"Silver donors",
|
||||
"Bronze donors",
|
||||
]
|
||||
sections_id = [
|
||||
"DONORS_SPONSOR_PLATINUM",
|
||||
"DONORS_SPONSOR_GOLD",
|
||||
"DONORS_SPONSOR_SILVER",
|
||||
"DONORS_SPONSOR_BRONZE",
|
||||
"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])
|
||||
+ '", '
|
||||
+ "©RIGHT_INFO_DATA["
|
||||
+ str(part["file_index"])
|
||||
+ "], "
|
||||
+ "©RIGHT_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)
|
||||
+ '", '
|
||||
+ "©RIGHT_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())
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -44,31 +44,31 @@ CoreStringNames::CoreStringNames() :
|
||||
_iter_next(StaticCString::create("_iter_next")),
|
||||
_iter_get(StaticCString::create("_iter_get")),
|
||||
get_rid(StaticCString::create("get_rid")),
|
||||
_to_string(StaticCString::create("_to_string")),
|
||||
#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");
|
||||
}
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -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 {
|
||||
|
||||
@ -62,7 +62,6 @@ public:
|
||||
StringName _iter_next;
|
||||
StringName _iter_get;
|
||||
StringName get_rid;
|
||||
StringName _to_string;
|
||||
#ifdef TOOLS_ENABLED
|
||||
StringName _sections_unfolded;
|
||||
#endif
|
||||
|
||||
380
core/cowdata.h
380
core/cowdata.h
@ -1,380 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* cowdata.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 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 <type_traits>
|
||||
|
||||
#include "core/error_macros.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 (!std::is_trivially_destructible<T>::value) {
|
||||
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 (std::is_trivially_copyable<T>::value) {
|
||||
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);
|
||||
|
||||
int current_size = size();
|
||||
|
||||
if (p_size == current_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 current_alloc_size = _get_alloc_size(current_size);
|
||||
size_t alloc_size;
|
||||
ERR_FAIL_COND_V(!_get_alloc_size_checked(p_size, &alloc_size), ERR_OUT_OF_MEMORY);
|
||||
|
||||
if (p_size > current_size) {
|
||||
|
||||
if (alloc_size != current_alloc_size) {
|
||||
if (current_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 (!std::is_trivially_constructible<T>::value) {
|
||||
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 < current_size) {
|
||||
if (!std::is_trivially_destructible<T>::value) {
|
||||
// deinitialize no longer needed elements
|
||||
for (uint32_t i = p_size; i < *_get_size(); i++) {
|
||||
T *t = &_get_data()[i];
|
||||
t->~T();
|
||||
}
|
||||
}
|
||||
|
||||
if (alloc_size != current_alloc_size) {
|
||||
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_ */
|
||||
@ -1,40 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
Import("env")
|
||||
|
||||
env_crypto = env.Clone()
|
||||
|
||||
is_builtin = env["builtin_mbedtls"]
|
||||
has_module = env["module_mbedtls_enabled"]
|
||||
|
||||
if is_builtin or not has_module:
|
||||
# Use our headers for builtin or if the module is not going to be compiled.
|
||||
# We decided not to depend on system mbedtls just for these few files that can
|
||||
# be easily extracted.
|
||||
env_crypto.Prepend(CPPPATH=["#thirdparty/mbedtls/include"])
|
||||
|
||||
# MbedTLS core functions (for CryptoCore).
|
||||
# If the mbedtls module is compiled we don't need to add the .c files with our
|
||||
# custom config since they will be built by the module itself.
|
||||
# Only if the module is not enabled, we must compile here the required sources
|
||||
# to make a "light" build with only the necessary mbedtls files.
|
||||
if not has_module:
|
||||
env_thirdparty = env_crypto.Clone()
|
||||
env_thirdparty.disable_warnings()
|
||||
# Custom config file
|
||||
env_thirdparty.Append(
|
||||
CPPDEFINES=[("MBEDTLS_CONFIG_FILE", '\\"thirdparty/mbedtls/include/godot_core_mbedtls_config.h\\"')]
|
||||
)
|
||||
thirdparty_mbedtls_dir = "#thirdparty/mbedtls/library/"
|
||||
thirdparty_mbedtls_sources = [
|
||||
"aes.c",
|
||||
"base64.c",
|
||||
"md5.c",
|
||||
"sha1.c",
|
||||
"sha256.c",
|
||||
"godot_core_mbedtls_platform.c",
|
||||
]
|
||||
thirdparty_mbedtls_sources = [thirdparty_mbedtls_dir + file for file in thirdparty_mbedtls_sources]
|
||||
env_thirdparty.add_source_files(env.core_sources, thirdparty_mbedtls_sources)
|
||||
|
||||
env_crypto.add_source_files(env.core_sources, "*.cpp")
|
||||
@ -1,158 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* crypto.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 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 "crypto.h"
|
||||
|
||||
#include "core/engine.h"
|
||||
#include "core/io/certs_compressed.gen.h"
|
||||
#include "core/io/compression.h"
|
||||
|
||||
/// Resources
|
||||
|
||||
CryptoKey *(*CryptoKey::_create)() = NULL;
|
||||
CryptoKey *CryptoKey::create() {
|
||||
if (_create)
|
||||
return _create();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CryptoKey::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("save", "path"), &CryptoKey::save);
|
||||
ClassDB::bind_method(D_METHOD("load", "path"), &CryptoKey::load);
|
||||
}
|
||||
|
||||
X509Certificate *(*X509Certificate::_create)() = NULL;
|
||||
X509Certificate *X509Certificate::create() {
|
||||
if (_create)
|
||||
return _create();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void X509Certificate::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("save", "path"), &X509Certificate::save);
|
||||
ClassDB::bind_method(D_METHOD("load", "path"), &X509Certificate::load);
|
||||
}
|
||||
|
||||
/// Crypto
|
||||
|
||||
void (*Crypto::_load_default_certificates)(String p_path) = NULL;
|
||||
Crypto *(*Crypto::_create)() = NULL;
|
||||
Crypto *Crypto::create() {
|
||||
if (_create)
|
||||
return _create();
|
||||
ERR_FAIL_V_MSG(NULL, "Crypto is not available when the mbedtls module is disabled.");
|
||||
}
|
||||
|
||||
void Crypto::load_default_certificates(String p_path) {
|
||||
|
||||
if (_load_default_certificates)
|
||||
_load_default_certificates(p_path);
|
||||
}
|
||||
|
||||
void Crypto::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("generate_random_bytes", "size"), &Crypto::generate_random_bytes);
|
||||
ClassDB::bind_method(D_METHOD("generate_rsa", "size"), &Crypto::generate_rsa);
|
||||
ClassDB::bind_method(D_METHOD("generate_self_signed_certificate", "key", "issuer_name", "not_before", "not_after"), &Crypto::generate_self_signed_certificate, DEFVAL("CN=myserver,O=myorganisation,C=IT"), DEFVAL("20140101000000"), DEFVAL("20340101000000"));
|
||||
}
|
||||
|
||||
Crypto::Crypto() {
|
||||
}
|
||||
|
||||
/// Resource loader/saver
|
||||
|
||||
RES ResourceFormatLoaderCrypto::load(const String &p_path, const String &p_original_path, Error *r_error) {
|
||||
|
||||
String el = p_path.get_extension().to_lower();
|
||||
if (el == "crt") {
|
||||
X509Certificate *cert = X509Certificate::create();
|
||||
if (cert)
|
||||
cert->load(p_path);
|
||||
return cert;
|
||||
} else if (el == "key") {
|
||||
CryptoKey *key = CryptoKey::create();
|
||||
if (key)
|
||||
key->load(p_path);
|
||||
return key;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ResourceFormatLoaderCrypto::get_recognized_extensions(List<String> *p_extensions) const {
|
||||
|
||||
p_extensions->push_back("crt");
|
||||
p_extensions->push_back("key");
|
||||
}
|
||||
|
||||
bool ResourceFormatLoaderCrypto::handles_type(const String &p_type) const {
|
||||
|
||||
return p_type == "X509Certificate" || p_type == "CryptoKey";
|
||||
}
|
||||
|
||||
String ResourceFormatLoaderCrypto::get_resource_type(const String &p_path) const {
|
||||
|
||||
String el = p_path.get_extension().to_lower();
|
||||
if (el == "crt")
|
||||
return "X509Certificate";
|
||||
else if (el == "key")
|
||||
return "CryptoKey";
|
||||
return "";
|
||||
}
|
||||
|
||||
Error ResourceFormatSaverCrypto::save(const String &p_path, const RES &p_resource, uint32_t p_flags) {
|
||||
|
||||
Error err;
|
||||
Ref<X509Certificate> cert = p_resource;
|
||||
Ref<CryptoKey> key = p_resource;
|
||||
if (cert.is_valid()) {
|
||||
err = cert->save(p_path);
|
||||
} else if (key.is_valid()) {
|
||||
err = key->save(p_path);
|
||||
} else {
|
||||
ERR_FAIL_V(ERR_INVALID_PARAMETER);
|
||||
}
|
||||
ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot save Crypto resource to file '" + p_path + "'.");
|
||||
return OK;
|
||||
}
|
||||
|
||||
void ResourceFormatSaverCrypto::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
|
||||
|
||||
const X509Certificate *cert = Object::cast_to<X509Certificate>(*p_resource);
|
||||
const CryptoKey *key = Object::cast_to<CryptoKey>(*p_resource);
|
||||
if (cert) {
|
||||
p_extensions->push_back("crt");
|
||||
}
|
||||
if (key) {
|
||||
p_extensions->push_back("key");
|
||||
}
|
||||
}
|
||||
bool ResourceFormatSaverCrypto::recognize(const RES &p_resource) const {
|
||||
|
||||
return Object::cast_to<X509Certificate>(*p_resource) || Object::cast_to<CryptoKey>(*p_resource);
|
||||
}
|
||||
@ -1,101 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* crypto.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 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 CRYPTO_H
|
||||
#define CRYPTO_H
|
||||
|
||||
#include "core/reference.h"
|
||||
#include "core/resource.h"
|
||||
|
||||
#include "core/io/resource_loader.h"
|
||||
#include "core/io/resource_saver.h"
|
||||
|
||||
class CryptoKey : public Resource {
|
||||
GDCLASS(CryptoKey, Resource);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
static CryptoKey *(*_create)();
|
||||
|
||||
public:
|
||||
static CryptoKey *create();
|
||||
virtual Error load(String p_path) = 0;
|
||||
virtual Error save(String p_path) = 0;
|
||||
};
|
||||
|
||||
class X509Certificate : public Resource {
|
||||
GDCLASS(X509Certificate, Resource);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
static X509Certificate *(*_create)();
|
||||
|
||||
public:
|
||||
static X509Certificate *create();
|
||||
virtual Error load(String p_path) = 0;
|
||||
virtual Error load_from_memory(const uint8_t *p_buffer, int p_len) = 0;
|
||||
virtual Error save(String p_path) = 0;
|
||||
};
|
||||
|
||||
class Crypto : public Reference {
|
||||
GDCLASS(Crypto, Reference);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
static Crypto *(*_create)();
|
||||
static void (*_load_default_certificates)(String p_path);
|
||||
|
||||
public:
|
||||
static Crypto *create();
|
||||
static void load_default_certificates(String p_path);
|
||||
|
||||
virtual PoolByteArray generate_random_bytes(int p_bytes) = 0;
|
||||
virtual Ref<CryptoKey> generate_rsa(int p_bytes) = 0;
|
||||
virtual Ref<X509Certificate> generate_self_signed_certificate(Ref<CryptoKey> p_key, String p_issuer_name, String p_not_before, String p_not_after) = 0;
|
||||
|
||||
Crypto();
|
||||
};
|
||||
|
||||
class ResourceFormatLoaderCrypto : public 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;
|
||||
};
|
||||
|
||||
class ResourceFormatSaverCrypto : public ResourceFormatSaver {
|
||||
public:
|
||||
virtual Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0);
|
||||
virtual void get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const;
|
||||
virtual bool recognize(const RES &p_resource) const;
|
||||
};
|
||||
|
||||
#endif // CRYPTO_H
|
||||
@ -1,183 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* crypto_core.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 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 "crypto_core.h"
|
||||
|
||||
#include <mbedtls/aes.h>
|
||||
#include <mbedtls/base64.h>
|
||||
#include <mbedtls/md5.h>
|
||||
#include <mbedtls/sha1.h>
|
||||
#include <mbedtls/sha256.h>
|
||||
|
||||
// MD5
|
||||
CryptoCore::MD5Context::MD5Context() {
|
||||
ctx = memalloc(sizeof(mbedtls_md5_context));
|
||||
mbedtls_md5_init((mbedtls_md5_context *)ctx);
|
||||
}
|
||||
|
||||
CryptoCore::MD5Context::~MD5Context() {
|
||||
mbedtls_md5_free((mbedtls_md5_context *)ctx);
|
||||
memfree((mbedtls_md5_context *)ctx);
|
||||
}
|
||||
|
||||
Error CryptoCore::MD5Context::start() {
|
||||
int ret = mbedtls_md5_starts_ret((mbedtls_md5_context *)ctx);
|
||||
return ret ? FAILED : OK;
|
||||
}
|
||||
|
||||
Error CryptoCore::MD5Context::update(const uint8_t *p_src, size_t p_len) {
|
||||
int ret = mbedtls_md5_update_ret((mbedtls_md5_context *)ctx, p_src, p_len);
|
||||
return ret ? FAILED : OK;
|
||||
}
|
||||
|
||||
Error CryptoCore::MD5Context::finish(unsigned char r_hash[16]) {
|
||||
int ret = mbedtls_md5_finish_ret((mbedtls_md5_context *)ctx, r_hash);
|
||||
return ret ? FAILED : OK;
|
||||
}
|
||||
|
||||
// SHA1
|
||||
CryptoCore::SHA1Context::SHA1Context() {
|
||||
ctx = memalloc(sizeof(mbedtls_sha1_context));
|
||||
mbedtls_sha1_init((mbedtls_sha1_context *)ctx);
|
||||
}
|
||||
|
||||
CryptoCore::SHA1Context::~SHA1Context() {
|
||||
mbedtls_sha1_free((mbedtls_sha1_context *)ctx);
|
||||
memfree((mbedtls_sha1_context *)ctx);
|
||||
}
|
||||
|
||||
Error CryptoCore::SHA1Context::start() {
|
||||
int ret = mbedtls_sha1_starts_ret((mbedtls_sha1_context *)ctx);
|
||||
return ret ? FAILED : OK;
|
||||
}
|
||||
|
||||
Error CryptoCore::SHA1Context::update(const uint8_t *p_src, size_t p_len) {
|
||||
int ret = mbedtls_sha1_update_ret((mbedtls_sha1_context *)ctx, p_src, p_len);
|
||||
return ret ? FAILED : OK;
|
||||
}
|
||||
|
||||
Error CryptoCore::SHA1Context::finish(unsigned char r_hash[20]) {
|
||||
int ret = mbedtls_sha1_finish_ret((mbedtls_sha1_context *)ctx, r_hash);
|
||||
return ret ? FAILED : OK;
|
||||
}
|
||||
|
||||
// SHA256
|
||||
CryptoCore::SHA256Context::SHA256Context() {
|
||||
ctx = memalloc(sizeof(mbedtls_sha256_context));
|
||||
mbedtls_sha256_init((mbedtls_sha256_context *)ctx);
|
||||
}
|
||||
|
||||
CryptoCore::SHA256Context::~SHA256Context() {
|
||||
mbedtls_sha256_free((mbedtls_sha256_context *)ctx);
|
||||
memfree((mbedtls_sha256_context *)ctx);
|
||||
}
|
||||
|
||||
Error CryptoCore::SHA256Context::start() {
|
||||
int ret = mbedtls_sha256_starts_ret((mbedtls_sha256_context *)ctx, 0);
|
||||
return ret ? FAILED : OK;
|
||||
}
|
||||
|
||||
Error CryptoCore::SHA256Context::update(const uint8_t *p_src, size_t p_len) {
|
||||
int ret = mbedtls_sha256_update_ret((mbedtls_sha256_context *)ctx, p_src, p_len);
|
||||
return ret ? FAILED : OK;
|
||||
}
|
||||
|
||||
Error CryptoCore::SHA256Context::finish(unsigned char r_hash[32]) {
|
||||
int ret = mbedtls_sha256_finish_ret((mbedtls_sha256_context *)ctx, r_hash);
|
||||
return ret ? FAILED : OK;
|
||||
}
|
||||
|
||||
// AES256
|
||||
CryptoCore::AESContext::AESContext() {
|
||||
ctx = memalloc(sizeof(mbedtls_aes_context));
|
||||
mbedtls_aes_init((mbedtls_aes_context *)ctx);
|
||||
}
|
||||
|
||||
CryptoCore::AESContext::~AESContext() {
|
||||
mbedtls_aes_free((mbedtls_aes_context *)ctx);
|
||||
memfree((mbedtls_aes_context *)ctx);
|
||||
}
|
||||
|
||||
Error CryptoCore::AESContext::set_encode_key(const uint8_t *p_key, size_t p_bits) {
|
||||
int ret = mbedtls_aes_setkey_enc((mbedtls_aes_context *)ctx, p_key, p_bits);
|
||||
return ret ? FAILED : OK;
|
||||
}
|
||||
|
||||
Error CryptoCore::AESContext::set_decode_key(const uint8_t *p_key, size_t p_bits) {
|
||||
int ret = mbedtls_aes_setkey_dec((mbedtls_aes_context *)ctx, p_key, p_bits);
|
||||
return ret ? FAILED : OK;
|
||||
}
|
||||
|
||||
Error CryptoCore::AESContext::encrypt_ecb(const uint8_t p_src[16], uint8_t r_dst[16]) {
|
||||
int ret = mbedtls_aes_crypt_ecb((mbedtls_aes_context *)ctx, MBEDTLS_AES_ENCRYPT, p_src, r_dst);
|
||||
return ret ? FAILED : OK;
|
||||
}
|
||||
|
||||
Error CryptoCore::AESContext::decrypt_ecb(const uint8_t p_src[16], uint8_t r_dst[16]) {
|
||||
int ret = mbedtls_aes_crypt_ecb((mbedtls_aes_context *)ctx, MBEDTLS_AES_DECRYPT, p_src, r_dst);
|
||||
return ret ? FAILED : OK;
|
||||
}
|
||||
|
||||
// CryptoCore
|
||||
String CryptoCore::b64_encode_str(const uint8_t *p_src, int p_src_len) {
|
||||
int b64len = p_src_len / 3 * 4 + 4 + 1;
|
||||
PoolVector<uint8_t> b64buff;
|
||||
b64buff.resize(b64len);
|
||||
PoolVector<uint8_t>::Write w64 = b64buff.write();
|
||||
size_t strlen = 0;
|
||||
int ret = b64_encode(&w64[0], b64len, &strlen, p_src, p_src_len);
|
||||
w64[strlen] = 0;
|
||||
return ret ? String() : (const char *)&w64[0];
|
||||
}
|
||||
|
||||
Error CryptoCore::b64_encode(uint8_t *r_dst, int p_dst_len, size_t *r_len, const uint8_t *p_src, int p_src_len) {
|
||||
int ret = mbedtls_base64_encode(r_dst, p_dst_len, r_len, p_src, p_src_len);
|
||||
return ret ? FAILED : OK;
|
||||
}
|
||||
|
||||
Error CryptoCore::b64_decode(uint8_t *r_dst, int p_dst_len, size_t *r_len, const uint8_t *p_src, int p_src_len) {
|
||||
int ret = mbedtls_base64_decode(r_dst, p_dst_len, r_len, p_src, p_src_len);
|
||||
return ret ? FAILED : OK;
|
||||
}
|
||||
|
||||
Error CryptoCore::md5(const uint8_t *p_src, int p_src_len, unsigned char r_hash[16]) {
|
||||
int ret = mbedtls_md5_ret(p_src, p_src_len, r_hash);
|
||||
return ret ? FAILED : OK;
|
||||
}
|
||||
|
||||
Error CryptoCore::sha1(const uint8_t *p_src, int p_src_len, unsigned char r_hash[20]) {
|
||||
int ret = mbedtls_sha1_ret(p_src, p_src_len, r_hash);
|
||||
return ret ? FAILED : OK;
|
||||
}
|
||||
|
||||
Error CryptoCore::sha256(const uint8_t *p_src, int p_src_len, unsigned char r_hash[32]) {
|
||||
int ret = mbedtls_sha256_ret(p_src, p_src_len, r_hash, 0);
|
||||
return ret ? FAILED : OK;
|
||||
}
|
||||
@ -1,104 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* crypto_core.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 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 CRYPTO_CORE_H
|
||||
#define CRYPTO_CORE_H
|
||||
|
||||
#include "core/reference.h"
|
||||
|
||||
class CryptoCore {
|
||||
|
||||
public:
|
||||
class MD5Context {
|
||||
|
||||
private:
|
||||
void *ctx; // To include, or not to include...
|
||||
|
||||
public:
|
||||
MD5Context();
|
||||
~MD5Context();
|
||||
|
||||
Error start();
|
||||
Error update(const uint8_t *p_src, size_t p_len);
|
||||
Error finish(unsigned char r_hash[16]);
|
||||
};
|
||||
|
||||
class SHA1Context {
|
||||
|
||||
private:
|
||||
void *ctx; // To include, or not to include...
|
||||
|
||||
public:
|
||||
SHA1Context();
|
||||
~SHA1Context();
|
||||
|
||||
Error start();
|
||||
Error update(const uint8_t *p_src, size_t p_len);
|
||||
Error finish(unsigned char r_hash[20]);
|
||||
};
|
||||
|
||||
class SHA256Context {
|
||||
|
||||
private:
|
||||
void *ctx; // To include, or not to include...
|
||||
|
||||
public:
|
||||
SHA256Context();
|
||||
~SHA256Context();
|
||||
|
||||
Error start();
|
||||
Error update(const uint8_t *p_src, size_t p_len);
|
||||
Error finish(unsigned char r_hash[32]);
|
||||
};
|
||||
|
||||
class AESContext {
|
||||
|
||||
private:
|
||||
void *ctx; // To include, or not to include...
|
||||
|
||||
public:
|
||||
AESContext();
|
||||
~AESContext();
|
||||
|
||||
Error set_encode_key(const uint8_t *p_key, size_t p_bits);
|
||||
Error set_decode_key(const uint8_t *p_key, size_t p_bits);
|
||||
Error encrypt_ecb(const uint8_t p_src[16], uint8_t r_dst[16]);
|
||||
Error decrypt_ecb(const uint8_t p_src[16], uint8_t r_dst[16]);
|
||||
};
|
||||
|
||||
static String b64_encode_str(const uint8_t *p_src, int p_src_len);
|
||||
static Error b64_encode(uint8_t *r_dst, int p_dst_len, size_t *r_len, const uint8_t *p_src, int p_src_len);
|
||||
static Error b64_decode(uint8_t *r_dst, int p_dst_len, size_t *r_len, const uint8_t *p_src, int p_src_len);
|
||||
|
||||
static Error md5(const uint8_t *p_src, int p_src_len, unsigned char r_hash[16]);
|
||||
static Error sha1(const uint8_t *p_src, int p_src_len, unsigned char r_hash[20]);
|
||||
static Error sha256(const uint8_t *p_src, int p_src_len, unsigned char r_hash[32]);
|
||||
};
|
||||
#endif // CRYPTO_CORE_H
|
||||
@ -1,138 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* hashing_context.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 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 "hashing_context.h"
|
||||
|
||||
#include "core/crypto/crypto_core.h"
|
||||
|
||||
Error HashingContext::start(HashType p_type) {
|
||||
ERR_FAIL_COND_V(ctx != NULL, ERR_ALREADY_IN_USE);
|
||||
_create_ctx(p_type);
|
||||
ERR_FAIL_COND_V(ctx == NULL, ERR_UNAVAILABLE);
|
||||
switch (type) {
|
||||
case HASH_MD5:
|
||||
return ((CryptoCore::MD5Context *)ctx)->start();
|
||||
case HASH_SHA1:
|
||||
return ((CryptoCore::SHA1Context *)ctx)->start();
|
||||
case HASH_SHA256:
|
||||
return ((CryptoCore::SHA256Context *)ctx)->start();
|
||||
}
|
||||
return ERR_UNAVAILABLE;
|
||||
}
|
||||
|
||||
Error HashingContext::update(PoolByteArray p_chunk) {
|
||||
ERR_FAIL_COND_V(ctx == NULL, ERR_UNCONFIGURED);
|
||||
size_t len = p_chunk.size();
|
||||
ERR_FAIL_COND_V(len == 0, FAILED);
|
||||
PoolByteArray::Read r = p_chunk.read();
|
||||
switch (type) {
|
||||
case HASH_MD5:
|
||||
return ((CryptoCore::MD5Context *)ctx)->update(&r[0], len);
|
||||
case HASH_SHA1:
|
||||
return ((CryptoCore::SHA1Context *)ctx)->update(&r[0], len);
|
||||
case HASH_SHA256:
|
||||
return ((CryptoCore::SHA256Context *)ctx)->update(&r[0], len);
|
||||
}
|
||||
return ERR_UNAVAILABLE;
|
||||
}
|
||||
|
||||
PoolByteArray HashingContext::finish() {
|
||||
ERR_FAIL_COND_V(ctx == NULL, PoolByteArray());
|
||||
PoolByteArray out;
|
||||
Error err = FAILED;
|
||||
switch (type) {
|
||||
case HASH_MD5:
|
||||
out.resize(16);
|
||||
err = ((CryptoCore::MD5Context *)ctx)->finish(out.write().ptr());
|
||||
break;
|
||||
case HASH_SHA1:
|
||||
out.resize(20);
|
||||
err = ((CryptoCore::SHA1Context *)ctx)->finish(out.write().ptr());
|
||||
break;
|
||||
case HASH_SHA256:
|
||||
out.resize(32);
|
||||
err = ((CryptoCore::SHA256Context *)ctx)->finish(out.write().ptr());
|
||||
break;
|
||||
}
|
||||
_delete_ctx();
|
||||
ERR_FAIL_COND_V(err != OK, PoolByteArray());
|
||||
return out;
|
||||
}
|
||||
|
||||
void HashingContext::_create_ctx(HashType p_type) {
|
||||
type = p_type;
|
||||
switch (type) {
|
||||
case HASH_MD5:
|
||||
ctx = memnew(CryptoCore::MD5Context);
|
||||
break;
|
||||
case HASH_SHA1:
|
||||
ctx = memnew(CryptoCore::SHA1Context);
|
||||
break;
|
||||
case HASH_SHA256:
|
||||
ctx = memnew(CryptoCore::SHA256Context);
|
||||
break;
|
||||
default:
|
||||
ctx = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void HashingContext::_delete_ctx() {
|
||||
|
||||
switch (type) {
|
||||
case HASH_MD5:
|
||||
memdelete((CryptoCore::MD5Context *)ctx);
|
||||
break;
|
||||
case HASH_SHA1:
|
||||
memdelete((CryptoCore::SHA1Context *)ctx);
|
||||
break;
|
||||
case HASH_SHA256:
|
||||
memdelete((CryptoCore::SHA256Context *)ctx);
|
||||
break;
|
||||
}
|
||||
ctx = NULL;
|
||||
}
|
||||
|
||||
void HashingContext::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("start", "type"), &HashingContext::start);
|
||||
ClassDB::bind_method(D_METHOD("update", "chunk"), &HashingContext::update);
|
||||
ClassDB::bind_method(D_METHOD("finish"), &HashingContext::finish);
|
||||
BIND_ENUM_CONSTANT(HASH_MD5);
|
||||
BIND_ENUM_CONSTANT(HASH_SHA1);
|
||||
BIND_ENUM_CONSTANT(HASH_SHA256);
|
||||
}
|
||||
|
||||
HashingContext::HashingContext() {
|
||||
ctx = NULL;
|
||||
}
|
||||
|
||||
HashingContext::~HashingContext() {
|
||||
if (ctx != NULL)
|
||||
_delete_ctx();
|
||||
}
|
||||
@ -1,66 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* hashing_context.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 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 HASHING_CONTEXT_H
|
||||
#define HASHING_CONTEXT_H
|
||||
|
||||
#include "core/reference.h"
|
||||
|
||||
class HashingContext : public Reference {
|
||||
GDCLASS(HashingContext, Reference);
|
||||
|
||||
public:
|
||||
enum HashType {
|
||||
HASH_MD5,
|
||||
HASH_SHA1,
|
||||
HASH_SHA256
|
||||
};
|
||||
|
||||
private:
|
||||
void *ctx;
|
||||
HashType type;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
void _create_ctx(HashType p_type);
|
||||
void _delete_ctx();
|
||||
|
||||
public:
|
||||
Error start(HashType p_type);
|
||||
Error update(PoolByteArray p_chunk);
|
||||
PoolByteArray finish();
|
||||
|
||||
HashingContext();
|
||||
~HashingContext();
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(HashingContext::HashType);
|
||||
|
||||
#endif // HASHING_CONTEXT_H
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -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)
|
||||
@ -192,9 +157,13 @@ uint32_t Dictionary::hash() const {
|
||||
|
||||
uint32_t h = hash_djb2_one_32(Variant::DICTIONARY);
|
||||
|
||||
for (OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::Element E = _p->variant_map.front(); E; E = E.next()) {
|
||||
h = hash_djb2_one_32(E.key().hash(), h);
|
||||
h = hash_djb2_one_32(E.value().hash(), h);
|
||||
List<Variant> keys;
|
||||
get_key_list(&keys);
|
||||
|
||||
for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
|
||||
|
||||
h = hash_djb2_one_32(E->get().hash(), h);
|
||||
h = hash_djb2_one_32(operator[](E->get()).hash(), h);
|
||||
}
|
||||
|
||||
return h;
|
||||
@ -203,11 +172,10 @@ uint32_t Dictionary::hash() const {
|
||||
Array Dictionary::keys() const {
|
||||
|
||||
Array varr;
|
||||
varr.resize(size());
|
||||
if (_p->variant_map.empty())
|
||||
return varr;
|
||||
|
||||
varr.resize(size());
|
||||
|
||||
int i = 0;
|
||||
for (OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::Element E = _p->variant_map.front(); E; E = E.next()) {
|
||||
varr[i] = E.key();
|
||||
@ -220,11 +188,10 @@ Array Dictionary::keys() const {
|
||||
Array Dictionary::values() const {
|
||||
|
||||
Array varr;
|
||||
varr.resize(size());
|
||||
if (_p->variant_map.empty())
|
||||
return varr;
|
||||
|
||||
varr.resize(size());
|
||||
|
||||
int i = 0;
|
||||
for (OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::Element E = _p->variant_map.front(); E; E = E.next()) {
|
||||
varr[i] = E.get();
|
||||
@ -249,12 +216,15 @@ const Variant *Dictionary::next(const Variant *p_key) const {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Dictionary Dictionary::duplicate(bool p_deep) const {
|
||||
Dictionary Dictionary::duplicate() const {
|
||||
|
||||
Dictionary n;
|
||||
|
||||
for (OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::Element E = _p->variant_map.front(); E; E = E.next()) {
|
||||
n[E.key()] = p_deep ? E.value().duplicate(true) : E.value();
|
||||
List<Variant> keys;
|
||||
get_key_list(&keys);
|
||||
|
||||
for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
|
||||
n[E->get()] = operator[](E->get());
|
||||
}
|
||||
|
||||
return n;
|
||||
@ -265,10 +235,6 @@ void Dictionary::operator=(const Dictionary &p_dictionary) {
|
||||
_ref(p_dictionary);
|
||||
}
|
||||
|
||||
const void *Dictionary::id() const {
|
||||
return _p->variant_map.id();
|
||||
}
|
||||
|
||||
Dictionary::Dictionary(const Dictionary &p_from) {
|
||||
_p = NULL;
|
||||
_ref(p_from);
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -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,9 +76,7 @@ public:
|
||||
Array keys() const;
|
||||
Array values() const;
|
||||
|
||||
Dictionary duplicate(bool p_deep = false) const;
|
||||
|
||||
const void *id() const;
|
||||
Dictionary duplicate() const;
|
||||
|
||||
Dictionary(const Dictionary &p_from);
|
||||
Dictionary();
|
||||
|
||||
71
core/dvector.cpp
Normal file
71
core/dvector.cpp
Normal file
@ -0,0 +1,71 @@
|
||||
/*************************************************************************/
|
||||
/* dvector.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 "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
643
core/dvector.h
Normal file
@ -0,0 +1,643 @@
|
||||
/*************************************************************************/
|
||||
/* dvector.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 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
|
||||
108
core/engine.cpp
108
core/engine.cpp
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -30,15 +30,11 @@
|
||||
|
||||
#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) {
|
||||
|
||||
ERR_FAIL_COND_MSG(p_ips <= 0, "Engine iterations per second must be greater than 0.");
|
||||
ips = p_ips;
|
||||
}
|
||||
int Engine::get_iterations_per_second() const {
|
||||
@ -46,21 +42,11 @@ 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;
|
||||
}
|
||||
|
||||
int Engine::get_target_fps() const {
|
||||
float Engine::get_target_fps() const {
|
||||
return _target_fps;
|
||||
}
|
||||
|
||||
@ -94,8 +80,11 @@ Dictionary Engine::get_version_info() const {
|
||||
Dictionary dict;
|
||||
dict["major"] = VERSION_MAJOR;
|
||||
dict["minor"] = VERSION_MINOR;
|
||||
#ifdef VERSION_PATCH
|
||||
dict["patch"] = VERSION_PATCH;
|
||||
dict["hex"] = VERSION_HEX;
|
||||
#else
|
||||
dict["patch"] = 0;
|
||||
#endif
|
||||
dict["status"] = VERSION_STATUS;
|
||||
dict["build"] = VERSION_BUILD;
|
||||
dict["year"] = VERSION_YEAR;
|
||||
@ -112,80 +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_PLATINUM);
|
||||
donors["gold_sponsors"] = array_from_info(DONORS_SPONSOR_GOLD);
|
||||
donors["silver_sponsors"] = array_from_info(DONORS_SPONSOR_SILVER);
|
||||
donors["bronze_sponsors"] = array_from_info(DONORS_SPONSOR_BRONZE);
|
||||
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);
|
||||
@ -195,7 +110,8 @@ void Engine::add_singleton(const Singleton &p_singleton) {
|
||||
Object *Engine::get_singleton_object(const String &p_name) const {
|
||||
|
||||
const Map<StringName, Object *>::Element *E = singleton_ptrs.find(p_name);
|
||||
ERR_FAIL_COND_V_MSG(!E, NULL, "Failed to retrieve non-existent singleton '" + p_name + "'.");
|
||||
ERR_EXPLAIN("Failed to retrieve non-existent singleton '" + p_name + "'");
|
||||
ERR_FAIL_COND_V(!E, NULL);
|
||||
return E->get();
|
||||
};
|
||||
|
||||
@ -221,8 +137,6 @@ Engine::Engine() {
|
||||
singleton = this;
|
||||
frames_drawn = 0;
|
||||
ips = 60;
|
||||
physics_jitter_fix = 0.5;
|
||||
_physics_interpolation_fraction = 0.0f;
|
||||
_frame_delay = 0;
|
||||
_fps = 1;
|
||||
_target_fps = 0;
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -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,13 +57,11 @@ private:
|
||||
float _frame_step;
|
||||
|
||||
int ips;
|
||||
float physics_jitter_fix;
|
||||
float _fps;
|
||||
int _target_fps;
|
||||
float _time_scale;
|
||||
bool _pixel_snap;
|
||||
uint64_t _physics_frames;
|
||||
float _physics_interpolation_fraction;
|
||||
|
||||
uint64_t _idle_frames;
|
||||
bool _in_physics;
|
||||
@ -81,11 +79,8 @@ 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 int get_target_fps() const;
|
||||
virtual float get_target_fps() const;
|
||||
|
||||
virtual float get_frames_per_second() const { return _fps; }
|
||||
|
||||
@ -96,7 +91,6 @@ public:
|
||||
bool is_in_physics_frame() const { return _in_physics; }
|
||||
uint64_t get_idle_frame_ticks() const { return _frame_ticks; }
|
||||
float get_idle_frame_step() const { return _frame_step; }
|
||||
float get_physics_interpolation_fraction() const { return _physics_interpolation_fraction; }
|
||||
|
||||
void set_time_scale(float p_scale);
|
||||
float get_time_scale() const;
|
||||
@ -120,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
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -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,
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -30,12 +30,23 @@
|
||||
|
||||
#include "error_macros.h"
|
||||
|
||||
#include "core/io/logger.h"
|
||||
#include "core/ustring.h"
|
||||
#include "io/logger.h"
|
||||
#include "os/os.h"
|
||||
|
||||
bool _err_error_exists = false;
|
||||
|
||||
static ErrorHandlerList *error_handler_list = NULL;
|
||||
|
||||
void _err_set_last_error(const char *p_err) {
|
||||
|
||||
OS::get_singleton()->set_last_error(p_err);
|
||||
}
|
||||
|
||||
void _err_clear_last_error() {
|
||||
|
||||
OS::get_singleton()->clear_last_error();
|
||||
}
|
||||
|
||||
void add_error_handler(ErrorHandlerList *p_handler) {
|
||||
|
||||
_global_lock();
|
||||
@ -69,47 +80,28 @@ void remove_error_handler(ErrorHandlerList *p_handler) {
|
||||
}
|
||||
|
||||
void _err_print_error(const char *p_function, const char *p_file, int p_line, const char *p_error, ErrorHandlerType p_type) {
|
||||
_err_print_error(p_function, p_file, p_line, p_error, "", p_type);
|
||||
}
|
||||
|
||||
void _err_print_error(const char *p_function, const char *p_file, int p_line, const String &p_error, ErrorHandlerType p_type) {
|
||||
_err_print_error(p_function, p_file, p_line, p_error.utf8().get_data(), "", p_type);
|
||||
}
|
||||
|
||||
void _err_print_error(const char *p_function, const char *p_file, int p_line, const char *p_error, const char *p_message, ErrorHandlerType p_type) {
|
||||
|
||||
OS::get_singleton()->print_error(p_function, p_file, p_line, p_error, p_message, (Logger::ErrorType)p_type);
|
||||
OS::get_singleton()->print_error(p_function, p_file, p_line, p_error, _err_error_exists ? OS::get_singleton()->get_last_error() : "", (Logger::ErrorType)p_type);
|
||||
|
||||
_global_lock();
|
||||
ErrorHandlerList *l = error_handler_list;
|
||||
while (l) {
|
||||
|
||||
l->errfunc(l->userdata, p_function, p_file, p_line, p_error, p_message, p_type);
|
||||
l->errfunc(l->userdata, p_function, p_file, p_line, p_error, _err_error_exists ? OS::get_singleton()->get_last_error() : "", p_type);
|
||||
l = l->next;
|
||||
}
|
||||
|
||||
_global_unlock();
|
||||
|
||||
if (_err_error_exists) {
|
||||
OS::get_singleton()->clear_last_error();
|
||||
_err_error_exists = false;
|
||||
}
|
||||
}
|
||||
|
||||
void _err_print_error(const char *p_function, const char *p_file, int p_line, const String &p_error, const char *p_message, ErrorHandlerType p_type) {
|
||||
_err_print_error(p_function, p_file, p_line, p_error.utf8().get_data(), p_message, p_type);
|
||||
}
|
||||
|
||||
void _err_print_error(const char *p_function, const char *p_file, int p_line, const char *p_error, const String &p_message, ErrorHandlerType p_type) {
|
||||
_err_print_error(p_function, p_file, p_line, p_error, p_message.utf8().get_data(), p_type);
|
||||
}
|
||||
|
||||
void _err_print_error(const char *p_function, const char *p_file, int p_line, const String &p_error, const String &p_message, ErrorHandlerType p_type) {
|
||||
_err_print_error(p_function, p_file, p_line, p_error.utf8().get_data(), p_message.utf8().get_data(), p_type);
|
||||
}
|
||||
|
||||
void _err_print_index_error(const char *p_function, const char *p_file, int p_line, int64_t p_index, int64_t p_size, const char *p_index_str, const char *p_size_str, const char *p_message, bool fatal) {
|
||||
void _err_print_index_error(const char *p_function, const char *p_file, int p_line, int64_t p_index, int64_t p_size, const char *p_index_str, const char *p_size_str, bool fatal) {
|
||||
|
||||
String fstr(fatal ? "FATAL: " : "");
|
||||
String err(fstr + "Index " + p_index_str + " = " + itos(p_index) + " is out of bounds (" + p_size_str + " = " + itos(p_size) + ").");
|
||||
_err_print_error(p_function, p_file, p_line, err.utf8().get_data(), p_message);
|
||||
}
|
||||
|
||||
void _err_print_index_error(const char *p_function, const char *p_file, int p_line, int64_t p_index, int64_t p_size, const char *p_index_str, const char *p_size_str, const String &p_message, bool fatal) {
|
||||
_err_print_index_error(p_function, p_file, p_line, p_index, p_size, p_index_str, p_size_str, p_message.utf8().get_data(), fatal);
|
||||
String err(fstr + "Index " + p_index_str + "=" + itos(p_index) + " out of size (" + p_size_str + "=" + itos(p_size) + ")");
|
||||
_err_print_error(p_function, p_file, p_line, err.utf8().get_data());
|
||||
}
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -31,17 +31,17 @@
|
||||
#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 engine can keep working well.
|
||||
* inside the code. It is recommended to always return processable data, so in case of an error, the
|
||||
* engine can stay working well.
|
||||
* In most cases, bugs and/or invalid data are not fatal and should never allow a perfectly running application
|
||||
* to fail or crash.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Pointer to the error macro printing function. Reassign to any function to have errors printed
|
||||
* Pointer to the error macro priting function. Reassign to any function to have errors printed
|
||||
*/
|
||||
|
||||
/** Function used by the error macros */
|
||||
@ -55,8 +55,9 @@ enum ErrorHandlerType {
|
||||
ERR_HANDLER_SHADER,
|
||||
};
|
||||
|
||||
class String;
|
||||
typedef void (*ErrorHandlerFunc)(void *, const char *, const char *, int p_line, const char *, const char *, ErrorHandlerType p_type);
|
||||
void _err_set_last_error(const char *p_err);
|
||||
void _err_clear_last_error();
|
||||
|
||||
struct ErrorHandlerList {
|
||||
|
||||
@ -76,13 +77,7 @@ void add_error_handler(ErrorHandlerList *p_handler);
|
||||
void remove_error_handler(ErrorHandlerList *p_handler);
|
||||
|
||||
void _err_print_error(const char *p_function, const char *p_file, int p_line, const char *p_error, ErrorHandlerType p_type = ERR_HANDLER_ERROR);
|
||||
void _err_print_error(const char *p_function, const char *p_file, int p_line, const String &p_error, ErrorHandlerType p_type = ERR_HANDLER_ERROR);
|
||||
void _err_print_error(const char *p_function, const char *p_file, int p_line, const char *p_error, const char *p_message, ErrorHandlerType p_type = ERR_HANDLER_ERROR);
|
||||
void _err_print_error(const char *p_function, const char *p_file, int p_line, const String &p_error, const char *p_message, ErrorHandlerType p_type = ERR_HANDLER_ERROR);
|
||||
void _err_print_error(const char *p_function, const char *p_file, int p_line, const char *p_error, const String &p_message, ErrorHandlerType p_type = ERR_HANDLER_ERROR);
|
||||
void _err_print_error(const char *p_function, const char *p_file, int p_line, const String &p_error, const String &p_message, ErrorHandlerType p_type = ERR_HANDLER_ERROR);
|
||||
void _err_print_index_error(const char *p_function, const char *p_file, int p_line, int64_t p_index, int64_t p_size, const char *p_index_str, const char *p_size_str, const char *p_message = "", bool fatal = false);
|
||||
void _err_print_index_error(const char *p_function, const char *p_file, int p_line, int64_t p_index, int64_t p_size, const char *p_index_str, const char *p_size_str, const String &p_message, bool fatal = false);
|
||||
void _err_print_index_error(const char *p_function, const char *p_file, int p_line, int64_t p_index, int64_t p_size, const char *p_index_str, const char *p_size_str, bool fatal = false);
|
||||
|
||||
#ifndef _STR
|
||||
#define _STR(m_x) #m_x
|
||||
@ -91,7 +86,30 @@ void _err_print_index_error(const char *p_function, const char *p_file, int p_li
|
||||
|
||||
#define _FNL __FILE__ ":"
|
||||
|
||||
/** An index has failed if m_index<0 or m_index >=m_size, the function exits */
|
||||
/** An index has failed if m_index<0 or m_index >=m_size, the function exists */
|
||||
|
||||
extern bool _err_error_exists;
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
/** Print a warning string.
|
||||
*/
|
||||
#define ERR_EXPLAINC(m_reason) \
|
||||
{ \
|
||||
_err_set_last_error(m_reason); \
|
||||
_err_error_exists = true; \
|
||||
}
|
||||
#define ERR_EXPLAIN(m_string) \
|
||||
{ \
|
||||
_err_set_last_error(String(m_string).utf8().get_data()); \
|
||||
_err_error_exists = true; \
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define ERR_EXPLAIN(m_text)
|
||||
#define ERR_EXPLAINC(m_text)
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
//#define FUNCTION_STR __PRETTY_FUNCTION__ - too annoying
|
||||
@ -111,418 +129,186 @@ void _err_print_index_error(const char *p_function, const char *p_file, int p_li
|
||||
#define GENERATE_TRAP __builtin_trap();
|
||||
#endif
|
||||
|
||||
// Used to strip debug messages in release mode
|
||||
#ifdef DEBUG_ENABLED
|
||||
#define DEBUG_STR(m_msg) m_msg
|
||||
#else
|
||||
#define DEBUG_STR(m_msg) ""
|
||||
#endif
|
||||
|
||||
// (*): See https://stackoverflow.com/questions/257418/do-while-0-what-is-it-good-for
|
||||
|
||||
/**
|
||||
* If `m_index` is less than 0 or greater than or equal to `m_size`, prints a generic
|
||||
* error message and returns from the function. This macro should be preferred to
|
||||
* `ERR_FAIL_COND` for bounds checking.
|
||||
*/
|
||||
#define ERR_FAIL_INDEX(m_index, m_size) \
|
||||
do { \
|
||||
if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \
|
||||
_err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size)); \
|
||||
return; \
|
||||
} \
|
||||
} else \
|
||||
_err_error_exists = false; \
|
||||
} while (0); // (*)
|
||||
|
||||
/**
|
||||
* If `m_index` is less than 0 or greater than or equal to `m_size`, prints a custom
|
||||
* error message and returns from the function. This macro should be preferred to
|
||||
* `ERR_FAIL_COND_MSG` for bounds checking.
|
||||
*/
|
||||
#define ERR_FAIL_INDEX_MSG(m_index, m_size, m_msg) \
|
||||
do { \
|
||||
if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \
|
||||
_err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), DEBUG_STR(m_msg)); \
|
||||
return; \
|
||||
} \
|
||||
} while (0); // (*)
|
||||
/** An index has failed if m_index<0 or 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
|
||||
*/
|
||||
|
||||
/**
|
||||
* If `m_index` is less than 0 or greater than or equal to `m_size`,
|
||||
* prints a generic error message and returns the value specified in `m_retval`.
|
||||
* This macro should be preferred to `ERR_FAIL_COND_V` for bounds checking.
|
||||
*/
|
||||
#define ERR_FAIL_INDEX_V(m_index, m_size, m_retval) \
|
||||
do { \
|
||||
if (unlikely((m_index) < 0 || (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); // (*)
|
||||
|
||||
/**
|
||||
* If `m_index` is less than 0 or greater than or equal to `m_size`,
|
||||
* prints a custom error message and returns the value specified in `m_retval`.
|
||||
* This macro should be preferred to `ERR_FAIL_COND_V_MSG` for bounds checking.
|
||||
*/
|
||||
#define ERR_FAIL_INDEX_V_MSG(m_index, m_size, m_retval, m_msg) \
|
||||
do { \
|
||||
if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \
|
||||
_err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), DEBUG_STR(m_msg)); \
|
||||
return m_retval; \
|
||||
} \
|
||||
/** 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.
|
||||
*/
|
||||
#define CRASH_BAD_INDEX(m_index, m_size) \
|
||||
do { \
|
||||
if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \
|
||||
_err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), true); \
|
||||
GENERATE_TRAP \
|
||||
} \
|
||||
} while (0); // (*)
|
||||
|
||||
/**
|
||||
* If `m_index` is greater than or equal to `m_size`,
|
||||
* prints a generic error message and returns the value specified in `m_retval`.
|
||||
* This macro should be preferred to `ERR_FAIL_COND_V` for unsigned bounds checking.
|
||||
*/
|
||||
#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; \
|
||||
} \
|
||||
} while (0); // (*)
|
||||
/** An error condition happened (m_cond tested true) (WARNING this is the opposite as assert().
|
||||
* the function will exit.
|
||||
*/
|
||||
|
||||
/**
|
||||
* If `m_index` is greater than or equal to `m_size`,
|
||||
* prints a custom error message and returns the value specified in `m_retval`.
|
||||
* This macro should be preferred to `ERR_FAIL_COND_V_MSG` for unsigned bounds checking.
|
||||
*/
|
||||
#define ERR_FAIL_UNSIGNED_INDEX_V_MSG(m_index, m_size, m_retval, m_msg) \
|
||||
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), DEBUG_STR(m_msg)); \
|
||||
return m_retval; \
|
||||
} \
|
||||
} while (0); // (*)
|
||||
|
||||
/**
|
||||
* If `m_index` is less than 0 or greater than or equal to `m_size`,
|
||||
* crashes the engine immediately with a generic error message.
|
||||
* Only use this if there's no sensible fallback (i.e. the error is unrecoverable).
|
||||
* This macro should be preferred to `CRASH_COND` for bounds checking.
|
||||
*/
|
||||
#define CRASH_BAD_INDEX(m_index, m_size) \
|
||||
do { \
|
||||
if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \
|
||||
_err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), "", true); \
|
||||
GENERATE_TRAP \
|
||||
} \
|
||||
} while (0); // (*)
|
||||
|
||||
/**
|
||||
* If `m_index` is less than 0 or greater than or equal to `m_size`,
|
||||
* crashes the engine immediately with a custom error message.
|
||||
* Only use this if there's no sensible fallback (i.e. the error is unrecoverable).
|
||||
* This macro should be preferred to `CRASH_COND` for bounds checking.
|
||||
*/
|
||||
#define CRASH_BAD_INDEX_MSG(m_index, m_size, m_msg) \
|
||||
do { \
|
||||
if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \
|
||||
_err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), m_msg, true); \
|
||||
GENERATE_TRAP \
|
||||
} \
|
||||
} while (0); // (*)
|
||||
|
||||
/**
|
||||
* If `m_param` is `null`, prints a generic error message and returns from the function.
|
||||
*/
|
||||
#define ERR_FAIL_NULL(m_param) \
|
||||
{ \
|
||||
if (unlikely(!m_param)) { \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter \"" _STR(m_param) "\" is null."); \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter ' " _STR(m_param) " ' is null."); \
|
||||
return; \
|
||||
} \
|
||||
} else \
|
||||
_err_error_exists = false; \
|
||||
}
|
||||
|
||||
/**
|
||||
* If `m_param` is `null`, prints a custom error message and returns from the function.
|
||||
*/
|
||||
#define ERR_FAIL_NULL_MSG(m_param, m_msg) \
|
||||
{ \
|
||||
if (unlikely(!m_param)) { \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter \"" _STR(m_param) "\" is null.", DEBUG_STR(m_msg)); \
|
||||
return; \
|
||||
} \
|
||||
}
|
||||
|
||||
/**
|
||||
* If `m_param` is `null`, prints a generic error message and returns the value specified in `m_retval`.
|
||||
*/
|
||||
#define ERR_FAIL_NULL_V(m_param, m_retval) \
|
||||
{ \
|
||||
if (unlikely(!m_param)) { \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter \"" _STR(m_param) "\" is null."); \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter ' " _STR(m_param) " ' is null."); \
|
||||
return m_retval; \
|
||||
} \
|
||||
} else \
|
||||
_err_error_exists = false; \
|
||||
}
|
||||
|
||||
/**
|
||||
* If `m_param` is `null`, prints a custom error message and returns the value specified in `m_retval`.
|
||||
/** An error condition happened (m_cond tested true) (WARNING this is the opposite as assert().
|
||||
* the function will exit.
|
||||
*/
|
||||
#define ERR_FAIL_NULL_V_MSG(m_param, m_retval, m_msg) \
|
||||
{ \
|
||||
if (unlikely(!m_param)) { \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter \"" _STR(m_param) "\" is null.", DEBUG_STR(m_msg)); \
|
||||
return m_retval; \
|
||||
} \
|
||||
}
|
||||
|
||||
/**
|
||||
* If `m_cond` evaluates to `true`, prints a generic error message and returns from the function.
|
||||
*/
|
||||
#define ERR_FAIL_COND(m_cond) \
|
||||
{ \
|
||||
if (unlikely(m_cond)) { \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true."); \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition ' " _STR(m_cond) " ' is true."); \
|
||||
return; \
|
||||
} \
|
||||
} else \
|
||||
_err_error_exists = false; \
|
||||
}
|
||||
|
||||
/**
|
||||
* If `m_cond` evaluates to `true`, prints a custom error message and returns from the function.
|
||||
/** Use this one if there is no sensible fallback, that is, the error is unrecoverable.
|
||||
*/
|
||||
#define ERR_FAIL_COND_MSG(m_cond, m_msg) \
|
||||
{ \
|
||||
if (unlikely(m_cond)) { \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true.", DEBUG_STR(m_msg)); \
|
||||
return; \
|
||||
} \
|
||||
}
|
||||
|
||||
/**
|
||||
* If `m_cond` evaluates to `true`, crashes the engine immediately with a generic error message.
|
||||
* Only use this if there's no sensible fallback (i.e. the error is unrecoverable).
|
||||
*/
|
||||
#define CRASH_COND(m_cond) \
|
||||
{ \
|
||||
if (unlikely(m_cond)) { \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Condition \"" _STR(m_cond) "\" is true."); \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Condition ' " _STR(m_cond) " ' is true."); \
|
||||
GENERATE_TRAP \
|
||||
} \
|
||||
}
|
||||
|
||||
/**
|
||||
* If `m_cond` evaluates to `true`, crashes the engine immediately with a custom error message.
|
||||
* Only use this if there's no sensible fallback (i.e. the error is unrecoverable).
|
||||
/** An error condition happened (m_cond tested true) (WARNING this is the opposite as assert().
|
||||
* the function will exit.
|
||||
* This function returns an error value, if returning Error, please select the most
|
||||
* appropriate error condition from error_macros.h
|
||||
*/
|
||||
#define CRASH_COND_MSG(m_cond, m_msg) \
|
||||
{ \
|
||||
if (unlikely(m_cond)) { \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Condition \"" _STR(m_cond) "\" is true.", DEBUG_STR(m_msg)); \
|
||||
GENERATE_TRAP \
|
||||
} \
|
||||
}
|
||||
|
||||
/**
|
||||
* If `m_cond` evaluates to `true`, prints a generic error message and returns the value specified in `m_retval`.
|
||||
*/
|
||||
#define ERR_FAIL_COND_V(m_cond, m_retval) \
|
||||
{ \
|
||||
if (unlikely(m_cond)) { \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Returned: " _STR(m_retval)); \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition ' " _STR(m_cond) " ' is true. returned: " _STR(m_retval)); \
|
||||
return m_retval; \
|
||||
} \
|
||||
} else \
|
||||
_err_error_exists = false; \
|
||||
}
|
||||
|
||||
/**
|
||||
* If `m_cond` evaluates to `true`, prints a custom error message and returns the value specified in `m_retval`.
|
||||
/** An error condition happened (m_cond tested true) (WARNING this is the opposite as assert().
|
||||
* the loop will skip to the next iteration.
|
||||
*/
|
||||
#define ERR_FAIL_COND_V_MSG(m_cond, m_retval, m_msg) \
|
||||
{ \
|
||||
if (unlikely(m_cond)) { \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Returned: " _STR(m_retval), DEBUG_STR(m_msg)); \
|
||||
return m_retval; \
|
||||
} \
|
||||
|
||||
#define ERR_CONTINUE(m_cond) \
|
||||
{ \
|
||||
if (unlikely(m_cond)) { \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition ' " _STR(m_cond) " ' is true. Continuing..:"); \
|
||||
continue; \
|
||||
} else \
|
||||
_err_error_exists = false; \
|
||||
}
|
||||
|
||||
/**
|
||||
* If `m_cond` evaluates to `true`, prints a custom error message and continues the loop the macro is located in.
|
||||
/** An error condition happened (m_cond tested true) (WARNING this is the opposite as assert().
|
||||
* the loop will break
|
||||
*/
|
||||
#define ERR_CONTINUE(m_cond) \
|
||||
|
||||
#define ERR_BREAK(m_cond) \
|
||||
{ \
|
||||
if (unlikely(m_cond)) { \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Continuing."); \
|
||||
continue; \
|
||||
} \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition ' " _STR(m_cond) " ' is true. Breaking..:"); \
|
||||
break; \
|
||||
} else \
|
||||
_err_error_exists = false; \
|
||||
}
|
||||
|
||||
/**
|
||||
* If `m_cond` evaluates to `true`, prints a custom error message and continues the loop the macro is located in.
|
||||
/** Print an error string and return
|
||||
*/
|
||||
#define ERR_CONTINUE_MSG(m_cond, m_msg) \
|
||||
{ \
|
||||
if (unlikely(m_cond)) { \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Continuing.", DEBUG_STR(m_msg)); \
|
||||
continue; \
|
||||
} \
|
||||
|
||||
#define ERR_FAIL() \
|
||||
{ \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method/Function Failed."); \
|
||||
_err_error_exists = false; \
|
||||
return; \
|
||||
}
|
||||
|
||||
/**
|
||||
* If `m_cond` evaluates to `true`, prints a generic error message and breaks from the loop the macro is located in.
|
||||
/** Print an error string and return with value
|
||||
*/
|
||||
#define ERR_BREAK(m_cond) \
|
||||
{ \
|
||||
if (unlikely(m_cond)) { \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Breaking."); \
|
||||
break; \
|
||||
} \
|
||||
|
||||
#define ERR_FAIL_V(m_value) \
|
||||
{ \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method/Function Failed, returning: " __STR(m_value)); \
|
||||
_err_error_exists = false; \
|
||||
return m_value; \
|
||||
}
|
||||
|
||||
/**
|
||||
* If `m_cond` evaluates to `true`, prints a custom error message and breaks from the loop the macro is located in.
|
||||
/** Use this one if there is no sensible fallback, that is, the error is unrecoverable.
|
||||
*/
|
||||
#define ERR_BREAK_MSG(m_cond, m_msg) \
|
||||
{ \
|
||||
if (unlikely(m_cond)) { \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Breaking.", DEBUG_STR(m_msg)); \
|
||||
break; \
|
||||
} \
|
||||
|
||||
#define CRASH_NOW() \
|
||||
{ \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Method/Function Failed."); \
|
||||
GENERATE_TRAP \
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a generic error message and returns from the function.
|
||||
/** Print an error string.
|
||||
*/
|
||||
#define ERR_FAIL() \
|
||||
{ \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method failed."); \
|
||||
return; \
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a custom error message and returns from the function.
|
||||
*/
|
||||
#define ERR_FAIL_MSG(m_msg) \
|
||||
{ \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method failed.", DEBUG_STR(m_msg)); \
|
||||
return; \
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a generic error message and returns the value specified in `m_retval`.
|
||||
*/
|
||||
#define ERR_FAIL_V(m_retval) \
|
||||
{ \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method failed. Returning: " __STR(m_retval)); \
|
||||
return m_retval; \
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a custom error message and returns the value specified in `m_retval`.
|
||||
*/
|
||||
#define ERR_FAIL_V_MSG(m_retval, m_msg) \
|
||||
{ \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method failed. Returning: " __STR(m_retval), DEBUG_STR(m_msg)); \
|
||||
return m_retval; \
|
||||
}
|
||||
|
||||
/**
|
||||
* Crashes the engine immediately with a generic error message.
|
||||
* Only use this if there's no sensible fallback (i.e. the error is unrecoverable).
|
||||
*/
|
||||
#define CRASH_NOW() \
|
||||
{ \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Method failed."); \
|
||||
GENERATE_TRAP \
|
||||
}
|
||||
|
||||
/**
|
||||
* Crashes the engine immediately with a custom error message.
|
||||
* Only use this if there's no sensible fallback (i.e. the error is unrecoverable).
|
||||
*/
|
||||
#define CRASH_NOW_MSG(m_msg) \
|
||||
{ \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Method failed.", DEBUG_STR(m_msg)); \
|
||||
GENERATE_TRAP \
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints an error message without returning.
|
||||
*/
|
||||
#define ERR_PRINT(m_string) \
|
||||
{ \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, m_string); \
|
||||
_err_error_exists = false; \
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints an error message without returning.
|
||||
* FIXME: Remove this macro and replace all uses with `ERR_PRINT` as it's identical.
|
||||
*/
|
||||
#define ERR_PRINTS(m_string) \
|
||||
{ \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, m_string); \
|
||||
#define ERR_PRINTS(m_string) \
|
||||
{ \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, String(m_string).utf8().get_data()); \
|
||||
_err_error_exists = false; \
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints an error message without returning, but only do so once in the application lifecycle.
|
||||
* This can be used to avoid spamming the console with error messages.
|
||||
/** Print a warning string.
|
||||
*/
|
||||
#define ERR_PRINT_ONCE(m_string) \
|
||||
{ \
|
||||
static bool first_print = true; \
|
||||
if (first_print) { \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, m_string); \
|
||||
first_print = false; \
|
||||
} \
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a warning message without returning. To warn about deprecated usage,
|
||||
* use `WARN_DEPRECATED` or `WARN_DEPRECATED_MSG` instead.
|
||||
*/
|
||||
#define WARN_PRINT(m_string) \
|
||||
{ \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, m_string, ERR_HANDLER_WARNING); \
|
||||
_err_error_exists = false; \
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a warning message without returning.
|
||||
* FIXME: Remove this macro and replace all uses with `WARN_PRINT` as it's identical.
|
||||
*/
|
||||
#define WARN_PRINTS(m_string) \
|
||||
{ \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, m_string, ERR_HANDLER_WARNING); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a warning message without returning, but only do so once in the application lifecycle.
|
||||
* This can be used to avoid spamming the console with warning messages.
|
||||
*/
|
||||
#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); \
|
||||
first_print = false; \
|
||||
} \
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a generic deprecation warning message without returning.
|
||||
* This should be preferred to `WARN_PRINT` for deprecation warnings.
|
||||
*/
|
||||
#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); \
|
||||
warning_shown = true; \
|
||||
} \
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a custom deprecation warning message without returning.
|
||||
* This should be preferred to `WARN_PRINT` for deprecation warnings.
|
||||
*/
|
||||
#define WARN_DEPRECATED_MSG(m_msg) \
|
||||
{ \
|
||||
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.", m_msg, ERR_HANDLER_WARNING); \
|
||||
warning_shown = true; \
|
||||
} \
|
||||
#define WARN_PRINTS(m_string) \
|
||||
{ \
|
||||
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, String(m_string).utf8().get_data(), ERR_HANDLER_WARNING); \
|
||||
_err_error_exists = false; \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -46,39 +46,16 @@ Variant FuncRef::call_func(const Variant **p_args, int p_argcount, Variant::Call
|
||||
return obj->call(function, p_args, p_argcount, r_error);
|
||||
}
|
||||
|
||||
Variant FuncRef::call_funcv(const Array &p_args) {
|
||||
|
||||
ERR_FAIL_COND_V(id == 0, Variant());
|
||||
|
||||
Object *obj = ObjectDB::get_instance(id);
|
||||
|
||||
ERR_FAIL_COND_V(!obj, Variant());
|
||||
|
||||
return obj->callv(function, p_args);
|
||||
}
|
||||
|
||||
void FuncRef::set_instance(Object *p_obj) {
|
||||
|
||||
ERR_FAIL_NULL(p_obj);
|
||||
id = p_obj->get_instance_id();
|
||||
}
|
||||
|
||||
void FuncRef::set_function(const StringName &p_func) {
|
||||
|
||||
function = p_func;
|
||||
}
|
||||
|
||||
bool FuncRef::is_valid() const {
|
||||
if (id == 0)
|
||||
return false;
|
||||
|
||||
Object *obj = ObjectDB::get_instance(id);
|
||||
if (!obj)
|
||||
return false;
|
||||
|
||||
return obj->has_method(function);
|
||||
}
|
||||
|
||||
void FuncRef::_bind_methods() {
|
||||
|
||||
{
|
||||
@ -88,13 +65,11 @@ void FuncRef::_bind_methods() {
|
||||
ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "call_func", &FuncRef::call_func, mi, defargs);
|
||||
}
|
||||
|
||||
ClassDB::bind_method(D_METHOD("call_funcv", "arg_array"), &FuncRef::call_funcv);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_instance", "instance"), &FuncRef::set_instance);
|
||||
ClassDB::bind_method(D_METHOD("set_function", "name"), &FuncRef::set_function);
|
||||
ClassDB::bind_method(D_METHOD("is_valid"), &FuncRef::is_valid);
|
||||
}
|
||||
|
||||
FuncRef::FuncRef() :
|
||||
id(0) {
|
||||
FuncRef::FuncRef() {
|
||||
|
||||
id = 0;
|
||||
}
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -31,7 +31,7 @@
|
||||
#ifndef FUNC_REF_H
|
||||
#define FUNC_REF_H
|
||||
|
||||
#include "core/reference.h"
|
||||
#include "reference.h"
|
||||
|
||||
class FuncRef : public Reference {
|
||||
|
||||
@ -44,10 +44,8 @@ protected:
|
||||
|
||||
public:
|
||||
Variant call_func(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
|
||||
Variant call_funcv(const Array &p_args);
|
||||
void set_instance(Object *p_obj);
|
||||
void set_function(const StringName &p_func);
|
||||
bool is_valid() const;
|
||||
FuncRef();
|
||||
};
|
||||
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -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,11 +385,8 @@ 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_INVALID_OPTION);
|
||||
BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_0);
|
||||
BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_1);
|
||||
BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_2);
|
||||
@ -426,16 +420,6 @@ void register_global_constants() {
|
||||
BIND_GLOBAL_ENUM_CONSTANT(JOY_DS_X);
|
||||
BIND_GLOBAL_ENUM_CONSTANT(JOY_DS_Y);
|
||||
|
||||
BIND_GLOBAL_ENUM_CONSTANT(JOY_VR_GRIP);
|
||||
BIND_GLOBAL_ENUM_CONSTANT(JOY_VR_PAD);
|
||||
BIND_GLOBAL_ENUM_CONSTANT(JOY_VR_TRIGGER);
|
||||
|
||||
BIND_GLOBAL_ENUM_CONSTANT(JOY_OCULUS_AX);
|
||||
BIND_GLOBAL_ENUM_CONSTANT(JOY_OCULUS_BY);
|
||||
BIND_GLOBAL_ENUM_CONSTANT(JOY_OCULUS_MENU);
|
||||
|
||||
BIND_GLOBAL_ENUM_CONSTANT(JOY_OPENVR_MENU);
|
||||
|
||||
BIND_GLOBAL_ENUM_CONSTANT(JOY_SELECT);
|
||||
BIND_GLOBAL_ENUM_CONSTANT(JOY_START);
|
||||
BIND_GLOBAL_ENUM_CONSTANT(JOY_DPAD_UP);
|
||||
@ -470,72 +454,49 @@ void register_global_constants() {
|
||||
BIND_GLOBAL_ENUM_CONSTANT(JOY_ANALOG_L2);
|
||||
BIND_GLOBAL_ENUM_CONSTANT(JOY_ANALOG_R2);
|
||||
|
||||
BIND_GLOBAL_ENUM_CONSTANT(JOY_VR_ANALOG_TRIGGER);
|
||||
BIND_GLOBAL_ENUM_CONSTANT(JOY_VR_ANALOG_GRIP);
|
||||
|
||||
BIND_GLOBAL_ENUM_CONSTANT(JOY_OPENVR_TOUCHPADX);
|
||||
BIND_GLOBAL_ENUM_CONSTANT(JOY_OPENVR_TOUCHPADY);
|
||||
|
||||
// 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);
|
||||
@ -557,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);
|
||||
@ -572,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);
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -31,7 +31,7 @@
|
||||
#ifndef GLOBAL_CONSTANTS_H
|
||||
#define GLOBAL_CONSTANTS_H
|
||||
|
||||
#include "core/string_name.h"
|
||||
#include "string_db.h"
|
||||
|
||||
class GlobalConstants {
|
||||
public:
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -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
|
||||
@ -112,7 +112,7 @@ private:
|
||||
|
||||
void erase_hash_table() {
|
||||
|
||||
ERR_FAIL_COND_MSG(elements, "Cannot erase hash table if there are still elements inside.");
|
||||
ERR_FAIL_COND(elements);
|
||||
|
||||
memdelete_arr(hash_table);
|
||||
hash_table = 0;
|
||||
@ -150,29 +150,32 @@ private:
|
||||
if (new_hash_table_power == -1)
|
||||
return;
|
||||
|
||||
Element **new_hash_table = memnew_arr(Element *, ((uint64_t)1 << new_hash_table_power));
|
||||
ERR_FAIL_COND_MSG(!new_hash_table, "Out of memory.");
|
||||
Element **new_hash_table = memnew_arr(Element *, (1 << new_hash_table_power));
|
||||
if (!new_hash_table) {
|
||||
|
||||
ERR_PRINT("Out of Memory");
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (1 << new_hash_table_power); i++) {
|
||||
|
||||
new_hash_table[i] = 0;
|
||||
}
|
||||
|
||||
if (hash_table) {
|
||||
for (int i = 0; i < (1 << hash_table_power); i++) {
|
||||
for (int i = 0; i < (1 << hash_table_power); i++) {
|
||||
|
||||
while (hash_table[i]) {
|
||||
while (hash_table[i]) {
|
||||
|
||||
Element *se = hash_table[i];
|
||||
hash_table[i] = se->next;
|
||||
int new_pos = se->hash & ((1 << new_hash_table_power) - 1);
|
||||
se->next = new_hash_table[new_pos];
|
||||
new_hash_table[new_pos] = se;
|
||||
}
|
||||
Element *se = hash_table[i];
|
||||
hash_table[i] = se->next;
|
||||
int new_pos = se->hash & ((1 << new_hash_table_power) - 1);
|
||||
se->next = new_hash_table[new_pos];
|
||||
new_hash_table[new_pos] = se;
|
||||
}
|
||||
|
||||
memdelete_arr(hash_table);
|
||||
}
|
||||
|
||||
if (hash_table)
|
||||
memdelete_arr(hash_table);
|
||||
hash_table = new_hash_table;
|
||||
hash_table_power = new_hash_table_power;
|
||||
}
|
||||
@ -204,13 +207,12 @@ private:
|
||||
|
||||
/* if element doesn't exist, create it */
|
||||
Element *e = memnew(Element);
|
||||
ERR_FAIL_COND_V_MSG(!e, NULL, "Out of memory.");
|
||||
ERR_FAIL_COND_V(!e, NULL); /* out of memory */
|
||||
uint32_t hash = Hasher::hash(p_key);
|
||||
uint32_t index = hash & ((1 << hash_table_power) - 1);
|
||||
e->next = hash_table[index];
|
||||
e->hash = hash;
|
||||
e->pair.key = p_key;
|
||||
e->pair.data = TData();
|
||||
|
||||
hash_table[index] = e;
|
||||
elements++;
|
||||
@ -228,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;
|
||||
|
||||
@ -294,14 +296,14 @@ public:
|
||||
const TData &get(const TKey &p_key) const {
|
||||
|
||||
const TData *res = getptr(p_key);
|
||||
CRASH_COND_MSG(!res, "Map key not found.");
|
||||
ERR_FAIL_COND_V(!res, *res);
|
||||
return *res;
|
||||
}
|
||||
|
||||
TData &get(const TKey &p_key) {
|
||||
|
||||
TData *res = getptr(p_key);
|
||||
CRASH_COND_MSG(!res, "Map key not found.");
|
||||
ERR_FAIL_COND_V(!res, *res);
|
||||
return *res;
|
||||
}
|
||||
|
||||
@ -492,7 +494,8 @@ public:
|
||||
} else { /* get the next key */
|
||||
|
||||
const Element *e = get_element(*p_key);
|
||||
ERR_FAIL_COND_V_MSG(!e, NULL, "Invalid key supplied.");
|
||||
ERR_FAIL_COND_V(!e, NULL); /* invalid key supplied */
|
||||
|
||||
if (e->next) {
|
||||
/* if there is a "next" in the list, return that */
|
||||
return &e->next->pair.key;
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -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
7
core/helper/SCsub
Normal file
@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
Import('env')
|
||||
|
||||
env.add_source_files(env.core_sources, "*.cpp")
|
||||
|
||||
Export('env')
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -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; \
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
46
core/helper/value_evaluator.h
Normal file
46
core/helper/value_evaluator.h
Normal file
@ -0,0 +1,46 @@
|
||||
/*************************************************************************/
|
||||
/* value_evaluator.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 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
|
||||
1293
core/image.cpp
1293
core/image.cpp
File diff suppressed because it is too large
Load Diff
69
core/image.h
69
core/image.h
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -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,18 +47,12 @@
|
||||
class Image;
|
||||
|
||||
typedef Error (*SavePNGFunc)(const String &p_path, const Ref<Image> &p_img);
|
||||
typedef PoolVector<uint8_t> (*SavePNGBufferFunc)(const Ref<Image> &p_img);
|
||||
typedef Ref<Image> (*ImageMemLoadFunc)(const uint8_t *p_png, int p_size);
|
||||
|
||||
typedef Error (*SaveEXRFunc)(const String &p_path, const Ref<Image> &p_img, bool p_grayscale);
|
||||
|
||||
class Image : public Resource {
|
||||
GDCLASS(Image, Resource);
|
||||
|
||||
public:
|
||||
static SavePNGFunc save_png_func;
|
||||
static SaveEXRFunc save_exr_func;
|
||||
static SavePNGBufferFunc save_png_buffer_func;
|
||||
|
||||
enum {
|
||||
MAX_WIDTH = 16384, // force a limit somehow
|
||||
@ -113,28 +107,21 @@ public:
|
||||
INTERPOLATE_NEAREST,
|
||||
INTERPOLATE_BILINEAR,
|
||||
INTERPOLATE_CUBIC,
|
||||
INTERPOLATE_TRILINEAR,
|
||||
INTERPOLATE_LANCZOS,
|
||||
/* 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 ImageMemLoadFunc _tga_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);
|
||||
@ -142,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 *);
|
||||
|
||||
@ -189,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,12 +198,13 @@ public:
|
||||
|
||||
/**
|
||||
* Resize the image, using the preferred interpolation method.
|
||||
* Indexed-Color images always use INTERPOLATE_NEAREST.
|
||||
*/
|
||||
|
||||
void resize_to_po2(bool p_square = false);
|
||||
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
|
||||
*/
|
||||
@ -241,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
|
||||
@ -262,8 +237,6 @@ public:
|
||||
|
||||
Error load(const String &p_path);
|
||||
Error save_png(const String &p_path) const;
|
||||
PoolVector<uint8_t> save_png_to_buffer() const;
|
||||
Error save_exr(const String &p_path, bool p_grayscale) const;
|
||||
|
||||
/**
|
||||
* create an empty image
|
||||
@ -292,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,
|
||||
@ -302,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);
|
||||
@ -313,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);
|
||||
@ -325,14 +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);
|
||||
Error load_tga_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);
|
||||
@ -353,15 +319,12 @@ 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_dst, 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) {
|
||||
ERR_FAIL_COND_MSG(p_image.is_null(), "It's not a reference to a valid Image object.");
|
||||
ERR_FAIL_COND(p_image.is_null());
|
||||
format = p_image->format;
|
||||
width = p_image->width;
|
||||
height = p_image->height;
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -30,43 +30,38 @@
|
||||
|
||||
#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_MSG(input_map.has(p_action), "InputMap already has action '" + String(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++;
|
||||
}
|
||||
|
||||
void InputMap::erase_action(const StringName &p_action) {
|
||||
|
||||
ERR_FAIL_COND_MSG(!input_map.has(p_action), "Request for nonexistent InputMap action '" + String(p_action) + "'.");
|
||||
ERR_FAIL_COND(!input_map.has(p_action));
|
||||
input_map.erase(p_action);
|
||||
}
|
||||
|
||||
@ -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_MSG(!input_map.has(p_action), "Request for nonexistent InputMap action '" + String(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_MSG(p_event.is_null(), "It's not a reference to a valid InputEvent object.");
|
||||
ERR_FAIL_COND_MSG(!input_map.has(p_action), "Request for nonexistent InputMap action '" + String(p_action) + "'.");
|
||||
if (_find_event(input_map[p_action], p_event))
|
||||
ERR_FAIL_COND(p_event.is_null());
|
||||
ERR_FAIL_COND(!input_map.has(p_action));
|
||||
if (_find_event(input_map[p_action].inputs, p_event))
|
||||
return; //already gots
|
||||
|
||||
input_map[p_action].inputs.push_back(p_event);
|
||||
@ -143,26 +129,19 @@ 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_MSG(!input_map.has(p_action), false, "Request for nonexistent InputMap action '" + String(p_action) + "'.");
|
||||
return (_find_event(input_map[p_action], p_event) != NULL);
|
||||
ERR_FAIL_COND_V(!input_map.has(p_action), false);
|
||||
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_MSG(!input_map.has(p_action), "Request for nonexistent InputMap action '" + String(p_action) + "'.");
|
||||
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_MSG(!input_map.has(p_action), "Request for nonexistent InputMap action '" + String(p_action) + "'.");
|
||||
|
||||
input_map[p_action].inputs.clear();
|
||||
}
|
||||
|
||||
Array InputMap::_get_action_list(const StringName &p_action) {
|
||||
|
||||
Array ret;
|
||||
@ -187,34 +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);
|
||||
ERR_FAIL_COND_V_MSG(!E, false, "Request for nonexistent InputMap action '" + String(p_action) + "'.");
|
||||
|
||||
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 != NULL && *p_pressed) ? input_event_action->get_strength() : 0.0f;
|
||||
return input_event_action->get_action() == p_action;
|
||||
if (!E) {
|
||||
ERR_EXPLAIN("Request for nonexistent InputMap action: " + String(p_action));
|
||||
ERR_FAIL_COND_V(!E, false);
|
||||
}
|
||||
|
||||
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;
|
||||
Ref<InputEventAction> iea = p_event;
|
||||
if (iea.is_valid()) {
|
||||
return iea->get_action() == p_action;
|
||||
}
|
||||
|
||||
return _find_event(E->get().inputs, p_event, true) != NULL;
|
||||
}
|
||||
|
||||
const Map<StringName, InputMap::Action> &InputMap::get_action_map() const {
|
||||
@ -236,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -318,21 +282,11 @@ 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");
|
||||
}
|
||||
|
||||
InputMap::InputMap() {
|
||||
|
||||
ERR_FAIL_COND_MSG(singleton, "Singleton in InputMap already exist.");
|
||||
ERR_FAIL_COND(singleton);
|
||||
singleton = this;
|
||||
}
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -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();
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
Import("env")
|
||||
Import('env')
|
||||
|
||||
env.add_source_files(env.core_sources, "*.cpp")
|
||||
|
||||
Export('env')
|
||||
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -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;
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -31,7 +31,7 @@
|
||||
#ifndef COMPRESSION_H
|
||||
#define COMPRESSION_H
|
||||
|
||||
#include "core/typedefs.h"
|
||||
#include "typedefs.h"
|
||||
|
||||
class Compression {
|
||||
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -29,10 +29,9 @@
|
||||
/*************************************************************************/
|
||||
|
||||
#include "config_file.h"
|
||||
|
||||
#include "core/io/file_access_encrypted.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 {
|
||||
|
||||
@ -86,8 +85,10 @@ void ConfigFile::set_value(const String &p_section, const String &p_key, const V
|
||||
Variant ConfigFile::get_value(const String &p_section, const String &p_key, Variant p_default) const {
|
||||
|
||||
if (!values.has(p_section) || !values[p_section].has(p_key)) {
|
||||
ERR_FAIL_COND_V_MSG(p_default.get_type() == Variant::NIL, Variant(),
|
||||
vformat("Couldn't find the given section \"%s\" and key \"%s\", and no default was given.", p_section, p_key));
|
||||
if (p_default.get_type() == Variant::NIL) {
|
||||
ERR_EXPLAIN("Couldn't find the given section/key and no default was given");
|
||||
ERR_FAIL_V(p_default);
|
||||
}
|
||||
return p_default;
|
||||
}
|
||||
return values[p_section][p_key];
|
||||
@ -112,7 +113,7 @@ void ConfigFile::get_sections(List<String> *r_sections) const {
|
||||
}
|
||||
void ConfigFile::get_section_keys(const String &p_section, List<String> *r_keys) const {
|
||||
|
||||
ERR_FAIL_COND_MSG(!values.has(p_section), vformat("Cannot get keys from nonexistent section \"%s\".", p_section));
|
||||
ERR_FAIL_COND(!values.has(p_section));
|
||||
|
||||
for (OrderedHashMap<String, Variant>::ConstElement E = values[p_section].front(); E; E = E.next()) {
|
||||
r_keys->push_back(E.key());
|
||||
@ -121,18 +122,9 @@ void ConfigFile::get_section_keys(const String &p_section, List<String> *r_keys)
|
||||
|
||||
void ConfigFile::erase_section(const String &p_section) {
|
||||
|
||||
ERR_FAIL_COND_MSG(!values.has(p_section), vformat("Cannot erase nonexistent section \"%s\".", p_section));
|
||||
values.erase(p_section);
|
||||
}
|
||||
|
||||
void ConfigFile::erase_section_key(const String &p_section, const String &p_key) {
|
||||
|
||||
ERR_FAIL_COND_MSG(!values.has(p_section), vformat("Cannot erase key \"%s\" from nonexistent section \"%s\".", p_key, p_section));
|
||||
ERR_FAIL_COND_MSG(!values[p_section].has(p_key), vformat("Cannot erase nonexistent key \"%s\" from section \"%s\".", p_key, p_section));
|
||||
|
||||
values[p_section].erase(p_key);
|
||||
}
|
||||
|
||||
Error ConfigFile::save(const String &p_path) {
|
||||
|
||||
Error err;
|
||||
@ -144,48 +136,6 @@ Error ConfigFile::save(const String &p_path) {
|
||||
return err;
|
||||
}
|
||||
|
||||
return _internal_save(file);
|
||||
}
|
||||
|
||||
Error ConfigFile::save_encrypted(const String &p_path, const Vector<uint8_t> &p_key) {
|
||||
|
||||
Error err;
|
||||
FileAccess *f = FileAccess::open(p_path, FileAccess::WRITE, &err);
|
||||
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
FileAccessEncrypted *fae = memnew(FileAccessEncrypted);
|
||||
err = fae->open_and_parse(f, p_key, FileAccessEncrypted::MODE_WRITE_AES256);
|
||||
if (err) {
|
||||
memdelete(fae);
|
||||
memdelete(f);
|
||||
return err;
|
||||
}
|
||||
return _internal_save(fae);
|
||||
}
|
||||
|
||||
Error ConfigFile::save_encrypted_pass(const String &p_path, const String &p_pass) {
|
||||
|
||||
Error err;
|
||||
FileAccess *f = FileAccess::open(p_path, FileAccess::WRITE, &err);
|
||||
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
FileAccessEncrypted *fae = memnew(FileAccessEncrypted);
|
||||
err = fae->open_and_parse_password(f, p_pass, FileAccessEncrypted::MODE_WRITE_AES256);
|
||||
if (err) {
|
||||
memdelete(fae);
|
||||
memdelete(f);
|
||||
return err;
|
||||
}
|
||||
|
||||
return _internal_save(fae);
|
||||
}
|
||||
|
||||
Error ConfigFile::_internal_save(FileAccess *file) {
|
||||
|
||||
for (OrderedHashMap<String, OrderedHashMap<String, Variant> >::Element E = values.front(); E; E = E.next()) {
|
||||
|
||||
if (E != values.front())
|
||||
@ -211,69 +161,11 @@ Error ConfigFile::load(const String &p_path) {
|
||||
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
|
||||
|
||||
if (!f)
|
||||
return err;
|
||||
|
||||
return _internal_load(p_path, f);
|
||||
}
|
||||
|
||||
Error ConfigFile::load_encrypted(const String &p_path, const Vector<uint8_t> &p_key) {
|
||||
|
||||
Error err;
|
||||
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
|
||||
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
FileAccessEncrypted *fae = memnew(FileAccessEncrypted);
|
||||
err = fae->open_and_parse(f, p_key, FileAccessEncrypted::MODE_READ);
|
||||
if (err) {
|
||||
memdelete(fae);
|
||||
memdelete(f);
|
||||
return err;
|
||||
}
|
||||
return _internal_load(p_path, fae);
|
||||
}
|
||||
|
||||
Error ConfigFile::load_encrypted_pass(const String &p_path, const String &p_pass) {
|
||||
|
||||
Error err;
|
||||
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
|
||||
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
FileAccessEncrypted *fae = memnew(FileAccessEncrypted);
|
||||
err = fae->open_and_parse_password(f, p_pass, FileAccessEncrypted::MODE_READ);
|
||||
if (err) {
|
||||
memdelete(fae);
|
||||
memdelete(f);
|
||||
return err;
|
||||
}
|
||||
|
||||
return _internal_load(p_path, fae);
|
||||
}
|
||||
|
||||
Error ConfigFile::_internal_load(const String &p_path, FileAccess *f) {
|
||||
return ERR_CANT_OPEN;
|
||||
|
||||
VariantParser::StreamFile stream;
|
||||
stream.f = f;
|
||||
|
||||
Error err = _parse(p_path, &stream);
|
||||
|
||||
memdelete(f);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
Error ConfigFile::parse(const String &p_data) {
|
||||
|
||||
VariantParser::StreamString stream;
|
||||
stream.s = p_data;
|
||||
return _parse("<string>", &stream);
|
||||
}
|
||||
|
||||
Error ConfigFile::_parse(const String &p_path, VariantParser::Stream *p_stream) {
|
||||
|
||||
String assign;
|
||||
Variant value;
|
||||
VariantParser::Tag next_tag;
|
||||
@ -289,11 +181,13 @@ Error ConfigFile::_parse(const String &p_path, VariantParser::Stream *p_stream)
|
||||
next_tag.fields.clear();
|
||||
next_tag.name = String();
|
||||
|
||||
Error err = VariantParser::parse_tag_assign_eof(p_stream, lines, error_text, next_tag, assign, value, NULL, true);
|
||||
err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, NULL, true);
|
||||
if (err == ERR_FILE_EOF) {
|
||||
memdelete(f);
|
||||
return OK;
|
||||
} else if (err != OK) {
|
||||
ERR_PRINT(vformat("ConfigFile parse error at %s:%d: %s.", p_path, lines, error_text));
|
||||
ERR_PRINTS("ConfgFile::load - " + p_path + ":" + itos(lines) + " error: " + error_text);
|
||||
memdelete(f);
|
||||
return err;
|
||||
}
|
||||
|
||||
@ -304,6 +198,8 @@ Error ConfigFile::_parse(const String &p_path, VariantParser::Stream *p_stream)
|
||||
}
|
||||
}
|
||||
|
||||
memdelete(f);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -319,15 +215,10 @@ void ConfigFile::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_section_keys", "section"), &ConfigFile::_get_section_keys);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("erase_section", "section"), &ConfigFile::erase_section);
|
||||
ClassDB::bind_method(D_METHOD("erase_section_key", "section", "key"), &ConfigFile::erase_section_key);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("load", "path"), &ConfigFile::load);
|
||||
ClassDB::bind_method(D_METHOD("parse", "data"), &ConfigFile::parse);
|
||||
ClassDB::bind_method(D_METHOD("save", "path"), &ConfigFile::save);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("load_encrypted", "path", "key"), &ConfigFile::load_encrypted);
|
||||
ClassDB::bind_method(D_METHOD("load_encrypted_pass", "path", "password"), &ConfigFile::load_encrypted_pass);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("save_encrypted", "path", "key"), &ConfigFile::save_encrypted);
|
||||
ClassDB::bind_method(D_METHOD("save_encrypted_pass", "path", "password"), &ConfigFile::save_encrypted_pass);
|
||||
}
|
||||
|
||||
ConfigFile::ConfigFile() {
|
||||
}
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -32,9 +32,7 @@
|
||||
#define CONFIG_FILE_H
|
||||
|
||||
#include "core/ordered_hash_map.h"
|
||||
#include "core/os/file_access.h"
|
||||
#include "core/reference.h"
|
||||
#include "core/variant_parser.h"
|
||||
#include "reference.h"
|
||||
|
||||
class ConfigFile : public Reference {
|
||||
|
||||
@ -44,10 +42,6 @@ class ConfigFile : public Reference {
|
||||
|
||||
PoolStringArray _get_sections() const;
|
||||
PoolStringArray _get_section_keys(const String &p_section) const;
|
||||
Error _internal_load(const String &p_path, FileAccess *f);
|
||||
Error _internal_save(FileAccess *file);
|
||||
|
||||
Error _parse(const String &p_path, VariantParser::Stream *p_stream);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
@ -63,17 +57,11 @@ public:
|
||||
void get_section_keys(const String &p_section, List<String> *r_keys) const;
|
||||
|
||||
void erase_section(const String &p_section);
|
||||
void erase_section_key(const String &p_section, const String &p_key);
|
||||
|
||||
Error save(const String &p_path);
|
||||
Error load(const String &p_path);
|
||||
Error parse(const String &p_data);
|
||||
|
||||
Error load_encrypted(const String &p_path, const Vector<uint8_t> &p_key);
|
||||
Error load_encrypted_pass(const String &p_path, const String &p_pass);
|
||||
|
||||
Error save_encrypted(const String &p_path, const Vector<uint8_t> &p_key);
|
||||
Error save_encrypted_pass(const String &p_path, const String &p_pass);
|
||||
ConfigFile();
|
||||
};
|
||||
|
||||
#endif // CONFIG_FILE_H
|
||||
|
||||
@ -1,57 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* dtls_server.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 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 "dtls_server.h"
|
||||
#include "core/os/file_access.h"
|
||||
#include "core/project_settings.h"
|
||||
|
||||
DTLSServer *(*DTLSServer::_create)() = NULL;
|
||||
bool DTLSServer::available = false;
|
||||
|
||||
DTLSServer *DTLSServer::create() {
|
||||
|
||||
if (_create) {
|
||||
return _create();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool DTLSServer::is_available() {
|
||||
return available;
|
||||
}
|
||||
|
||||
void DTLSServer::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("setup", "key", "certificate", "chain"), &DTLSServer::setup, DEFVAL(Ref<X509Certificate>()));
|
||||
ClassDB::bind_method(D_METHOD("take_connection", "udp_peer"), &DTLSServer::take_connection);
|
||||
}
|
||||
|
||||
DTLSServer::DTLSServer() {
|
||||
}
|
||||
@ -1,57 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* dtls_server.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 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 DTLS_SERVER_H
|
||||
#define DTLS_SERVER_H
|
||||
|
||||
#include "core/io/net_socket.h"
|
||||
#include "core/io/packet_peer_dtls.h"
|
||||
|
||||
class DTLSServer : public Reference {
|
||||
GDCLASS(DTLSServer, Reference);
|
||||
|
||||
protected:
|
||||
static DTLSServer *(*_create)();
|
||||
static void _bind_methods();
|
||||
|
||||
static bool available;
|
||||
|
||||
public:
|
||||
static bool is_available();
|
||||
static DTLSServer *create();
|
||||
|
||||
virtual Error setup(Ref<CryptoKey> p_key, Ref<X509Certificate> p_cert, Ref<X509Certificate> p_ca_chain = Ref<X509Certificate>()) = 0;
|
||||
virtual void stop() = 0;
|
||||
virtual Ref<PacketPeerDTLS> take_connection(Ref<PacketPeerUDP> p_peer) = 0;
|
||||
|
||||
DTLSServer();
|
||||
};
|
||||
|
||||
#endif // DTLS_SERVER_H
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -30,80 +30,86 @@
|
||||
|
||||
#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 {
|
||||
|
||||
return (last_error = p_error);
|
||||
}
|
||||
};
|
||||
|
||||
void FileAccessBuffered::set_cache_size(int p_size) {
|
||||
|
||||
cache_size = p_size;
|
||||
}
|
||||
};
|
||||
|
||||
int FileAccessBuffered::get_cache_size() {
|
||||
|
||||
return cache_size;
|
||||
}
|
||||
};
|
||||
|
||||
int FileAccessBuffered::cache_data_left() const {
|
||||
|
||||
if (file.offset >= file.size) {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
if (cache.offset == -1 || file.offset < cache.offset || file.offset >= cache.offset + cache.buffer.size()) {
|
||||
|
||||
return read_data_block(file.offset, cache_size);
|
||||
}
|
||||
|
||||
return cache.buffer.size() - (file.offset - cache.offset);
|
||||
}
|
||||
} else {
|
||||
|
||||
return cache.buffer.size() - (file.offset - cache.offset);
|
||||
};
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
void FileAccessBuffered::seek(size_t p_position) {
|
||||
|
||||
file.offset = p_position;
|
||||
}
|
||||
};
|
||||
|
||||
void FileAccessBuffered::seek_end(int64_t p_position) {
|
||||
|
||||
file.offset = file.size + p_position;
|
||||
}
|
||||
};
|
||||
|
||||
size_t FileAccessBuffered::get_position() const {
|
||||
|
||||
return file.offset;
|
||||
}
|
||||
};
|
||||
|
||||
size_t FileAccessBuffered::get_len() const {
|
||||
|
||||
return file.size;
|
||||
}
|
||||
};
|
||||
|
||||
bool FileAccessBuffered::eof_reached() const {
|
||||
|
||||
return file.offset > file.size;
|
||||
}
|
||||
};
|
||||
|
||||
uint8_t FileAccessBuffered::get_8() const {
|
||||
|
||||
ERR_FAIL_COND_V_MSG(!file.open, 0, "Can't get data, when file is not opened.");
|
||||
ERR_FAIL_COND_V(!file.open, 0);
|
||||
|
||||
uint8_t byte = 0;
|
||||
if (cache_data_left() >= 1) {
|
||||
|
||||
byte = cache.buffer[file.offset - cache.offset];
|
||||
}
|
||||
};
|
||||
|
||||
++file.offset;
|
||||
|
||||
return byte;
|
||||
}
|
||||
};
|
||||
|
||||
int FileAccessBuffered::get_buffer(uint8_t *p_dest, int p_length) const {
|
||||
|
||||
ERR_FAIL_COND_V_MSG(!file.open, -1, "Can't get buffer, when file is not opened.");
|
||||
ERR_FAIL_COND_V(!file.open, -1);
|
||||
|
||||
if (p_length > cache_size) {
|
||||
|
||||
@ -120,16 +126,16 @@ int FileAccessBuffered::get_buffer(uint8_t *p_dest, int p_length) const {
|
||||
p_length -= size;
|
||||
file.offset += size;
|
||||
total_read += size;
|
||||
}
|
||||
};
|
||||
|
||||
int err = read_data_block(file.offset, p_length, p_dest);
|
||||
if (err >= 0) {
|
||||
total_read += err;
|
||||
file.offset += err;
|
||||
}
|
||||
};
|
||||
|
||||
return total_read;
|
||||
}
|
||||
};
|
||||
|
||||
int to_read = p_length;
|
||||
int total_read = 0;
|
||||
@ -137,12 +143,14 @@ int FileAccessBuffered::get_buffer(uint8_t *p_dest, int p_length) const {
|
||||
|
||||
int left = cache_data_left();
|
||||
if (left == 0) {
|
||||
file.offset += to_read;
|
||||
if (to_read > 0) {
|
||||
file.offset += to_read;
|
||||
};
|
||||
return total_read;
|
||||
}
|
||||
};
|
||||
if (left < 0) {
|
||||
return left;
|
||||
}
|
||||
};
|
||||
|
||||
int r = MIN(left, to_read);
|
||||
//PoolVector<uint8_t>::Read read = cache.buffer.read();
|
||||
@ -152,25 +160,25 @@ int FileAccessBuffered::get_buffer(uint8_t *p_dest, int p_length) const {
|
||||
file.offset += r;
|
||||
total_read += r;
|
||||
to_read -= r;
|
||||
}
|
||||
};
|
||||
|
||||
return p_length;
|
||||
}
|
||||
};
|
||||
|
||||
bool FileAccessBuffered::is_open() const {
|
||||
|
||||
return file.open;
|
||||
}
|
||||
};
|
||||
|
||||
Error FileAccessBuffered::get_error() const {
|
||||
|
||||
return last_error;
|
||||
}
|
||||
};
|
||||
|
||||
FileAccessBuffered::FileAccessBuffered() {
|
||||
|
||||
cache_size = DEFAULT_CACHE_SIZE;
|
||||
}
|
||||
};
|
||||
|
||||
FileAccessBuffered::~FileAccessBuffered() {
|
||||
}
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -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 {
|
||||
|
||||
@ -52,16 +53,18 @@ protected:
|
||||
Error set_error(Error p_error) const;
|
||||
|
||||
mutable struct File {
|
||||
bool open = false;
|
||||
int size = 0;
|
||||
int offset = 0;
|
||||
|
||||
bool open;
|
||||
int size;
|
||||
int offset;
|
||||
String name;
|
||||
int access_flags = 0;
|
||||
int access_flags;
|
||||
} file;
|
||||
|
||||
mutable struct Cache {
|
||||
|
||||
Vector<uint8_t> buffer;
|
||||
int offset = 0;
|
||||
int offset;
|
||||
} cache;
|
||||
|
||||
virtual int read_data_block(int p_offset, int p_size, uint8_t *p_dest = 0) const = 0;
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -40,7 +40,7 @@ class FileAccessBufferedFA : public FileAccessBuffered {
|
||||
|
||||
int read_data_block(int p_offset, int p_size, uint8_t *p_dest = 0) const {
|
||||
|
||||
ERR_FAIL_COND_V_MSG(!f.is_open(), -1, "Can't read data block when file is not opened.");
|
||||
ERR_FAIL_COND_V(!f.is_open(), -1);
|
||||
|
||||
((T *)&f)->seek(p_offset);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -143,14 +143,6 @@ public:
|
||||
return f._get_modified_time(p_file);
|
||||
}
|
||||
|
||||
virtual uint32_t _get_unix_permissions(const String &p_file) {
|
||||
return f._get_unix_permissions(p_file);
|
||||
}
|
||||
|
||||
virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions) {
|
||||
return f._set_unix_permissions(p_file, p_permissions);
|
||||
}
|
||||
|
||||
FileAccessBufferedFA(){
|
||||
|
||||
};
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -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();
|
||||
@ -63,10 +61,6 @@ Error FileAccessCompressed::open_after_magic(FileAccess *p_base) {
|
||||
f = p_base;
|
||||
cmode = (Compression::Mode)f->get_32();
|
||||
block_size = f->get_32();
|
||||
if (block_size == 0) {
|
||||
f = NULL; // Let the caller to handle the FileAccess object if failed to open as compressed file.
|
||||
ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Can't open compressed file '" + p_base->get_path() + "' with block size 0, it is corrupted.");
|
||||
}
|
||||
read_total = f->get_32();
|
||||
int bc = (read_total / block_size) + 1;
|
||||
int acc_ofs = f->get_position() + bc * 4;
|
||||
@ -129,11 +123,13 @@ Error FileAccessCompressed::_open(const String &p_path, int p_mode_flags) {
|
||||
char rmagic[5];
|
||||
f->get_buffer((uint8_t *)rmagic, 4);
|
||||
rmagic[4] = 0;
|
||||
if (magic != rmagic || open_after_magic(f) != OK) {
|
||||
if (magic != rmagic) {
|
||||
memdelete(f);
|
||||
f = NULL;
|
||||
return ERR_FILE_UNRECOGNIZED;
|
||||
}
|
||||
|
||||
open_after_magic(f);
|
||||
}
|
||||
|
||||
return OK;
|
||||
@ -197,7 +193,7 @@ bool FileAccessCompressed::is_open() const {
|
||||
|
||||
void FileAccessCompressed::seek(size_t p_position) {
|
||||
|
||||
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
|
||||
ERR_FAIL_COND(!f);
|
||||
if (writing) {
|
||||
|
||||
ERR_FAIL_COND(p_position > write_max);
|
||||
@ -210,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) {
|
||||
|
||||
@ -229,7 +224,7 @@ void FileAccessCompressed::seek(size_t p_position) {
|
||||
|
||||
void FileAccessCompressed::seek_end(int64_t p_position) {
|
||||
|
||||
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
|
||||
ERR_FAIL_COND(!f);
|
||||
if (writing) {
|
||||
|
||||
seek(write_max + p_position);
|
||||
@ -240,7 +235,7 @@ void FileAccessCompressed::seek_end(int64_t p_position) {
|
||||
}
|
||||
size_t FileAccessCompressed::get_position() const {
|
||||
|
||||
ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
|
||||
ERR_FAIL_COND_V(!f, 0);
|
||||
if (writing) {
|
||||
|
||||
return write_pos;
|
||||
@ -251,7 +246,7 @@ size_t FileAccessCompressed::get_position() const {
|
||||
}
|
||||
size_t FileAccessCompressed::get_len() const {
|
||||
|
||||
ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
|
||||
ERR_FAIL_COND_V(!f, 0);
|
||||
if (writing) {
|
||||
|
||||
return write_max;
|
||||
@ -262,7 +257,7 @@ size_t FileAccessCompressed::get_len() const {
|
||||
|
||||
bool FileAccessCompressed::eof_reached() const {
|
||||
|
||||
ERR_FAIL_COND_V_MSG(!f, false, "File must be opened before use.");
|
||||
ERR_FAIL_COND_V(!f, false);
|
||||
if (writing) {
|
||||
return false;
|
||||
} else {
|
||||
@ -272,8 +267,8 @@ bool FileAccessCompressed::eof_reached() const {
|
||||
|
||||
uint8_t FileAccessCompressed::get_8() const {
|
||||
|
||||
ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
|
||||
ERR_FAIL_COND_V_MSG(writing, 0, "File has not been opened in read mode.");
|
||||
ERR_FAIL_COND_V(writing, 0);
|
||||
ERR_FAIL_COND_V(!f, 0);
|
||||
|
||||
if (at_end) {
|
||||
read_eof = true;
|
||||
@ -303,8 +298,8 @@ uint8_t FileAccessCompressed::get_8() const {
|
||||
}
|
||||
int FileAccessCompressed::get_buffer(uint8_t *p_dst, int p_length) const {
|
||||
|
||||
ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
|
||||
ERR_FAIL_COND_V_MSG(writing, 0, "File has not been opened in read mode.");
|
||||
ERR_FAIL_COND_V(writing, 0);
|
||||
ERR_FAIL_COND_V(!f, 0);
|
||||
|
||||
if (at_end) {
|
||||
read_eof = true;
|
||||
@ -344,16 +339,16 @@ Error FileAccessCompressed::get_error() const {
|
||||
}
|
||||
|
||||
void FileAccessCompressed::flush() {
|
||||
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
|
||||
ERR_FAIL_COND_MSG(!writing, "File has not been opened in read mode.");
|
||||
ERR_FAIL_COND(!f);
|
||||
ERR_FAIL_COND(!writing);
|
||||
|
||||
// compressed files keep data in memory till close()
|
||||
}
|
||||
|
||||
void FileAccessCompressed::store_8(uint8_t p_dest) {
|
||||
|
||||
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
|
||||
ERR_FAIL_COND_MSG(!writing, "File has not been opened in read mode.");
|
||||
ERR_FAIL_COND(!f);
|
||||
ERR_FAIL_COND(!writing);
|
||||
|
||||
WRITE_FIT(1);
|
||||
write_ptr[write_pos++] = p_dest;
|
||||
@ -376,36 +371,24 @@ uint64_t FileAccessCompressed::_get_modified_time(const String &p_file) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t FileAccessCompressed::_get_unix_permissions(const String &p_file) {
|
||||
if (f)
|
||||
return f->_get_unix_permissions(p_file);
|
||||
return 0;
|
||||
}
|
||||
FileAccessCompressed::FileAccessCompressed() {
|
||||
|
||||
Error FileAccessCompressed::_set_unix_permissions(const String &p_file, uint32_t p_permissions) {
|
||||
if (f) {
|
||||
return f->_set_unix_permissions(p_file, p_permissions);
|
||||
}
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
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) {
|
||||
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() {
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -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 {
|
||||
|
||||
@ -91,8 +91,6 @@ public:
|
||||
virtual bool file_exists(const String &p_name); ///< return true if a file exists
|
||||
|
||||
virtual uint64_t _get_modified_time(const String &p_file);
|
||||
virtual uint32_t _get_unix_permissions(const String &p_file);
|
||||
virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions);
|
||||
|
||||
FileAccessCompressed();
|
||||
virtual ~FileAccessCompressed();
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -30,10 +30,12 @@
|
||||
|
||||
#include "file_access_encrypted.h"
|
||||
|
||||
#include "core/crypto/crypto_core.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"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@ -41,7 +43,8 @@
|
||||
|
||||
Error FileAccessEncrypted::open_and_parse(FileAccess *p_base, const Vector<uint8_t> &p_key, Mode p_mode) {
|
||||
|
||||
ERR_FAIL_COND_V_MSG(file != NULL, ERR_ALREADY_IN_USE, "Can't open file while another file from path '" + file->get_path_absolute() + "' is open.");
|
||||
//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);
|
||||
|
||||
pos = 0;
|
||||
@ -81,20 +84,24 @@ Error FileAccessEncrypted::open_and_parse(FileAccess *p_base, const Vector<uint8
|
||||
uint32_t blen = p_base->get_buffer(data.ptrw(), ds);
|
||||
ERR_FAIL_COND_V(blen != ds, ERR_FILE_CORRUPT);
|
||||
|
||||
CryptoCore::AESContext ctx;
|
||||
ctx.set_decode_key(key.ptrw(), 256);
|
||||
aes256_context ctx;
|
||||
aes256_init(&ctx, key.ptrw());
|
||||
|
||||
for (size_t i = 0; i < ds; i += 16) {
|
||||
|
||||
ctx.decrypt_ecb(&data.write[i], &data.write[i]);
|
||||
aes256_decrypt_ecb(&ctx, &data[i]);
|
||||
}
|
||||
|
||||
aes256_done(&ctx);
|
||||
|
||||
data.resize(length);
|
||||
|
||||
unsigned char hash[16];
|
||||
ERR_FAIL_COND_V(CryptoCore::md5(data.ptr(), data.size(), hash) != OK, ERR_BUG);
|
||||
MD5_CTX md5;
|
||||
MD5Init(&md5);
|
||||
MD5Update(&md5, (uint8_t *)data.ptr(), data.size());
|
||||
MD5Final(&md5);
|
||||
|
||||
ERR_FAIL_COND_V_MSG(String::md5(hash) != String::md5(md5d), ERR_FILE_CORRUPT, "The MD5 sum of the decrypted file does not match the expected value. It could be that the file is corrupt, or that the provided decryption key is invalid.");
|
||||
ERR_FAIL_COND_V(String::md5(md5.digest) != String::md5(md5d), ERR_FILE_CORRUPT);
|
||||
|
||||
file = p_base;
|
||||
}
|
||||
@ -110,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);
|
||||
@ -133,27 +140,31 @@ void FileAccessEncrypted::close() {
|
||||
len += 16 - (len % 16);
|
||||
}
|
||||
|
||||
unsigned char hash[16];
|
||||
ERR_FAIL_COND(CryptoCore::md5(data.ptr(), data.size(), hash) != OK); // Bug?
|
||||
MD5_CTX md5;
|
||||
MD5Init(&md5);
|
||||
MD5Update(&md5, (uint8_t *)data.ptr(), data.size());
|
||||
MD5Final(&md5);
|
||||
|
||||
compressed.resize(len);
|
||||
zeromem(compressed.ptrw(), len);
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
compressed.write[i] = data[i];
|
||||
compressed[i] = data[i];
|
||||
}
|
||||
|
||||
CryptoCore::AESContext ctx;
|
||||
ctx.set_encode_key(key.ptrw(), 256);
|
||||
aes256_context ctx;
|
||||
aes256_init(&ctx, key.ptrw());
|
||||
|
||||
for (size_t i = 0; i < len; i += 16) {
|
||||
|
||||
ctx.encrypt_ecb(&compressed.write[i], &compressed.write[i]);
|
||||
aes256_encrypt_ecb(&ctx, &compressed[i]);
|
||||
}
|
||||
|
||||
aes256_done(&ctx);
|
||||
|
||||
file->store_32(COMP_MAGIC);
|
||||
file->store_32(mode);
|
||||
|
||||
file->store_buffer(hash, 16);
|
||||
file->store_buffer(md5.digest, 16);
|
||||
file->store_64(data.size());
|
||||
|
||||
file->store_buffer(compressed.ptr(), compressed.size());
|
||||
@ -176,22 +187,6 @@ bool FileAccessEncrypted::is_open() const {
|
||||
return file != NULL;
|
||||
}
|
||||
|
||||
String FileAccessEncrypted::get_path() const {
|
||||
|
||||
if (file)
|
||||
return file->get_path();
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
String FileAccessEncrypted::get_path_absolute() const {
|
||||
|
||||
if (file)
|
||||
return file->get_path_absolute();
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
void FileAccessEncrypted::seek(size_t p_position) {
|
||||
|
||||
if (p_position > (size_t)data.size())
|
||||
@ -221,7 +216,7 @@ bool FileAccessEncrypted::eof_reached() const {
|
||||
|
||||
uint8_t FileAccessEncrypted::get_8() const {
|
||||
|
||||
ERR_FAIL_COND_V_MSG(writing, 0, "File has not been opened in read mode.");
|
||||
ERR_FAIL_COND_V(writing, 0);
|
||||
if (pos >= data.size()) {
|
||||
eofed = true;
|
||||
return 0;
|
||||
@ -233,7 +228,7 @@ uint8_t FileAccessEncrypted::get_8() const {
|
||||
}
|
||||
int FileAccessEncrypted::get_buffer(uint8_t *p_dst, int p_length) const {
|
||||
|
||||
ERR_FAIL_COND_V_MSG(writing, 0, "File has not been opened in read mode.");
|
||||
ERR_FAIL_COND_V(writing, 0);
|
||||
|
||||
int to_copy = MIN(p_length, data.size() - pos);
|
||||
for (int i = 0; i < to_copy; i++) {
|
||||
@ -255,7 +250,7 @@ Error FileAccessEncrypted::get_error() const {
|
||||
|
||||
void FileAccessEncrypted::store_buffer(const uint8_t *p_src, int p_length) {
|
||||
|
||||
ERR_FAIL_COND_MSG(!writing, "File has not been opened in read mode.");
|
||||
ERR_FAIL_COND(!writing);
|
||||
|
||||
if (pos < data.size()) {
|
||||
|
||||
@ -268,24 +263,24 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
void FileAccessEncrypted::flush() {
|
||||
ERR_FAIL_COND_MSG(!writing, "File has not been opened in read mode.");
|
||||
ERR_FAIL_COND(!writing);
|
||||
|
||||
// encrypted files keep data in memory till close()
|
||||
}
|
||||
|
||||
void FileAccessEncrypted::store_8(uint8_t p_dest) {
|
||||
|
||||
ERR_FAIL_COND_MSG(!writing, "File has not been opened in read mode.");
|
||||
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);
|
||||
@ -307,16 +302,6 @@ uint64_t FileAccessEncrypted::_get_modified_time(const String &p_file) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t FileAccessEncrypted::_get_unix_permissions(const String &p_file) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Error FileAccessEncrypted::_set_unix_permissions(const String &p_file, uint32_t p_permissions) {
|
||||
ERR_PRINT("Setting UNIX permissions on encrypted files is not implemented yet.");
|
||||
return ERR_UNAVAILABLE;
|
||||
}
|
||||
|
||||
FileAccessEncrypted::FileAccessEncrypted() {
|
||||
|
||||
file = NULL;
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -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:
|
||||
@ -60,9 +60,6 @@ public:
|
||||
virtual void close(); ///< close a file
|
||||
virtual bool is_open() const; ///< true when file is open
|
||||
|
||||
virtual String get_path() const; /// returns the path for the current open file
|
||||
virtual String get_path_absolute() const; /// returns the absolute path for the current open file
|
||||
|
||||
virtual void seek(size_t p_position); ///< seek to a given position
|
||||
virtual void seek_end(int64_t p_position = 0); ///< seek from the end of file
|
||||
virtual size_t get_position() const; ///< get position in the file
|
||||
@ -82,8 +79,6 @@ public:
|
||||
virtual bool file_exists(const String &p_name); ///< return true if a file exists
|
||||
|
||||
virtual uint64_t _get_modified_time(const String &p_file);
|
||||
virtual uint32_t _get_unix_permissions(const String &p_file);
|
||||
virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions);
|
||||
|
||||
FileAccessEncrypted();
|
||||
~FileAccessEncrypted();
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* 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 */
|
||||
@ -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;
|
||||
|
||||
@ -90,9 +90,9 @@ Error FileAccessMemory::_open(const String &p_path, int p_mode_flags) {
|
||||
//name = DirAccess::normalize_path(name);
|
||||
|
||||
Map<String, Vector<uint8_t> >::Element *E = files->find(name);
|
||||
ERR_FAIL_COND_V_MSG(!E, ERR_FILE_NOT_FOUND, "Can't find file '" + p_path + "'.");
|
||||
ERR_FAIL_COND_V(!E, ERR_FILE_NOT_FOUND);
|
||||
|
||||
data = E->get().ptrw();
|
||||
data = &(E->get()[0]);
|
||||
length = E->get().size();
|
||||
pos = 0;
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user