Compare commits
5 Commits
2.0-stable
...
1.1
| Author | SHA1 | Date | |
|---|---|---|---|
| eb26ca7ae1 | |||
| c47810c33b | |||
| 8ee6e3848e | |||
| 7ae44a055b | |||
| a3a3cafbc8 |
@ -1,10 +0,0 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_style = tab
|
||||
|
||||
[.travis.yml]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
4
.gitattributes
vendored
4
.gitattributes
vendored
@ -1,4 +0,0 @@
|
||||
*.cpp eol=lf
|
||||
*.h eol=lf
|
||||
*.py eol=lf
|
||||
*.hpp eol=lf
|
||||
24
.gitignore
vendored
24
.gitignore
vendored
@ -15,7 +15,6 @@ core/method_bind.inc
|
||||
core/method_bind_ext.inc
|
||||
core/script_encryption_key.cpp
|
||||
core/global_defaults.cpp
|
||||
drivers/unix/os_unix_global_settings_path.cpp
|
||||
tools/editor/register_exporters.cpp
|
||||
tools/editor/doc_data_compressed.h
|
||||
tools/editor/editor_icons.cpp
|
||||
@ -24,15 +23,10 @@ tools/editor/editor_icons.cpp
|
||||
make.bat
|
||||
log.txt
|
||||
|
||||
# Documentation generated by doxygen or from classes.xml
|
||||
doc/_build/
|
||||
|
||||
# Javascript specific
|
||||
*.bc
|
||||
|
||||
# Android specific
|
||||
platform/android/java/.gradle
|
||||
platform/android/java/.gradletasknamecache
|
||||
platform/android/java/local.properties
|
||||
platform/android/java/project.properties
|
||||
platform/android/java/AndroidManifest.xml
|
||||
@ -56,14 +50,6 @@ platform/android/libs/play_licensing/gen/*
|
||||
*.d
|
||||
*.so
|
||||
*.os
|
||||
*.Plo
|
||||
*.lo
|
||||
*.Po
|
||||
|
||||
# Libs generated files
|
||||
.deps/*
|
||||
.dirstamp
|
||||
|
||||
|
||||
# QT project files
|
||||
*.config
|
||||
@ -87,8 +73,6 @@ platform/android/libs/play_licensing/gen/*
|
||||
*.suo
|
||||
*.user
|
||||
*.sln.docstates
|
||||
*.sln
|
||||
*.vcxproj*
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
@ -191,6 +175,9 @@ AutoTest.Net/
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# dumpdoc generated files
|
||||
doc/html/class_list
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
@ -293,7 +280,4 @@ cscope.files
|
||||
cscope.out
|
||||
cscope.in.out
|
||||
cscope.po.out
|
||||
godot.creator.*
|
||||
|
||||
projects/
|
||||
platform/windows/godot_res.res
|
||||
godot.creator.user.wd3476
|
||||
|
||||
60
.travis.yml
60
.travis.yml
@ -1,52 +1,14 @@
|
||||
language: cpp
|
||||
|
||||
sudo: required
|
||||
dist: trusty
|
||||
|
||||
compiler:
|
||||
compiler:
|
||||
- gcc
|
||||
- clang
|
||||
before_install:
|
||||
|
||||
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
env:
|
||||
- GODOT_TARGET=iphone
|
||||
- GODOT_TARGET=osx
|
||||
- GODOT_TARGET=x11
|
||||
- GODOT_TARGET=android
|
||||
- GODOT_TARGET=windows
|
||||
|
||||
matrix:
|
||||
exclude:
|
||||
- os: linux
|
||||
env: GODOT_TARGET=iphone
|
||||
- os: linux
|
||||
env: GODOT_TARGET=osx
|
||||
- os: linux
|
||||
env: GODOT_TARGET=android
|
||||
- os: osx
|
||||
env: GODOT_TARGET=x11
|
||||
- os: osx
|
||||
env: GODOT_TARGET=windows
|
||||
- compiler: gcc
|
||||
env: GODOT_TARGET=iphone
|
||||
- compiler: gcc
|
||||
env: GODOT_TARGET=osx
|
||||
- compiler: clang
|
||||
env: GODOT_TARGET=android
|
||||
- compiler: clang
|
||||
env: GODOT_TARGET=windows
|
||||
- compiler: clang
|
||||
env: GODOT_TARGET=x11
|
||||
|
||||
|
||||
before_script:
|
||||
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get update -qq; sudo apt-get install -y scons pkg-config libx11-dev libxcursor-dev build-essential libasound2-dev libfreetype6-dev libgl1-mesa-dev libglu-dev libssl-dev libxinerama-dev libudev-dev; fi
|
||||
- if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$GODOT_TARGET" = "windows" ]; then sudo apt-get update -qq; sudo apt-get install -y mingw32 mingw-w64; fi
|
||||
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew update; brew install scons; fi
|
||||
- if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$GODOT_TARGET" = "android" ]; then brew update; brew install android-sdk android-ndk; export ANDROID_HOME=/usr/local/opt/android-sdk; export ANDROID_NDK_ROOT=/usr/local/opt/android-ndk; fi
|
||||
|
||||
script:
|
||||
- scons platform=$GODOT_TARGET CXX=$CXX
|
||||
before_script:
|
||||
- sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -qq scons pkg-config libx11-dev libxcursor-dev build-essential libasound2-dev libfreetype6-dev libgl1-mesa-dev libglu-dev
|
||||
- if [ "$CXX" = "g++" ]; then sudo apt-get install -qq g++-4.8; fi
|
||||
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi
|
||||
|
||||
script: scons platform=x11
|
||||
|
||||
@ -1,59 +0,0 @@
|
||||
# How to contribute efficiently
|
||||
|
||||
**Please read the first section before reporting a bug!**
|
||||
|
||||
## 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.
|
||||
|
||||
Everything refered to hereafter as "bug" also applies for feature requests.
|
||||
|
||||
If you are reporting a new issue, you will make our life much simpler (and the fix come much sooner) by following those guidelines:
|
||||
|
||||
#### Search first in the existing database
|
||||
|
||||
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. 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)
|
||||
|
||||
#### 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.
|
||||
|
||||
#### Provide a simple, example project
|
||||
|
||||
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 and then figure out why it's failing.
|
||||
|
||||
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.
|
||||
|
||||
## Contributing pull requests
|
||||
|
||||
If you want to add new engine functionalities, please make sure that:
|
||||
|
||||
* 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.
|
||||
|
||||
#### Be nice to the git history
|
||||
|
||||
Try to make simple PRs with that handle one specific topic. Just like for reporting issues, it's better to open 3 different PRs that each address a different issue than one big PR with three commits.
|
||||
|
||||
When updating your fork with upstream changes, please use ``git pull --rebase`` to avoid creating "merge commits". Those commits unnecessarily pollute the git history when coming from PRs.
|
||||
|
||||
Also try to make commits that bring the engine from one stable state to another stable state, i.e. if your first commit has a bug that you fixed in the second commit, try to merge them together before making your pull request (see ``git rebase -i`` and relevant help about rebasing or ammending commits on the Internet).
|
||||
|
||||
This git style guide has some good practices to have in mind: https://github.com/agis-/git-style-guide
|
||||
|
||||
Thanks!
|
||||
|
||||
The Godot development team
|
||||
@ -51,14 +51,14 @@ PROJECT_BRIEF = "Game Engine MIT"
|
||||
# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy
|
||||
# the logo to the output directory.
|
||||
|
||||
PROJECT_LOGO = ../logo.png
|
||||
PROJECT_LOGO = E:/development/godot/logo_small.png
|
||||
|
||||
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path
|
||||
# into which the generated documentation will be written. If a relative path is
|
||||
# entered, it will be relative to the location where doxygen was started. If
|
||||
# left blank the current directory will be used.
|
||||
|
||||
OUTPUT_DIRECTORY = ./_build/doxygen/
|
||||
OUTPUT_DIRECTORY = E:/development/godot/doxygen
|
||||
|
||||
# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
|
||||
# directories (in 2 levels) under the output directory of each output format and
|
||||
@ -768,7 +768,7 @@ WARN_LOGFILE =
|
||||
# spaces.
|
||||
# Note: If this tag is empty the current directory is searched.
|
||||
|
||||
INPUT = ../core/ ../main/ ../scene/
|
||||
INPUT = E:/development/godot
|
||||
|
||||
# This tag can be used to specify the character encoding of the source files
|
||||
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
|
||||
@ -1,10 +0,0 @@
|
||||
**Operating system or device:**
|
||||
|
||||
|
||||
**Issue description** (what happened, and what was expected):
|
||||
|
||||
|
||||
**Steps to reproduce:**
|
||||
|
||||
|
||||
**Link to minimal example project** (optional but very welcome):
|
||||
50
LICENSE.md
50
LICENSE.md
@ -1,27 +1,27 @@
|
||||
GODOT ENGINE
|
||||
http://www.godotengine.org
|
||||
|
||||
************************************************************************
|
||||
|
||||
Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur.
|
||||
|
||||
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
|
||||
GODOT ENGINE
|
||||
http://www.godotengine.org
|
||||
**********************************************************************
|
||||
Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur.
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
|
||||
**********************************************************************
|
||||
|
||||
************************************************************************
|
||||
|
||||
@ -1,2 +0,0 @@
|
||||
Godot Logo (c) Andrea Calabró, distributed under the terms of the CC By License:
|
||||
https://creativecommons.org/licenses/by/3.0/legalcode
|
||||
11
README.md
11
README.md
@ -1,7 +1,5 @@
|
||||

|
||||
|
||||
http://www.godotengine.org
|
||||
|
||||
### The Engine
|
||||
|
||||
Godot is a fully featured, open source, MIT licensed, game engine. It focuses on having great tools, and a visual oriented workflow that can export to PC, Mobile and Web platforms with no hassle.
|
||||
@ -9,11 +7,12 @@ The editor, language and APIs are feature rich, yet simple to learn, allowing yo
|
||||
|
||||
### About
|
||||
|
||||
Godot has been developed by Juan Linietsky and Ariel Manzur for several years, and was born as an in-house engine, used to publish several work-for-hire titles. Godot is a member project of the [Software Freedom Conservancy](https://sfconservancy.org)
|
||||
Godot has been developed by Juan Linietsky and Ariel Manzur for several years, and was born as an in-house engine, used to publish several work-for-hire titles.
|
||||
Development is sponsored by OKAM Studio (http://www.okamstudio.com).
|
||||
|
||||
### Documentation
|
||||
|
||||
Documentation has been moved to [ReadTheDocs](http://docs.godotengine.org).
|
||||
Documentation has been moved to the [GitHub Wiki](https://github.com/okamstudio/godot/wiki).
|
||||
|
||||
### Binary Downloads, Community, etc.
|
||||
|
||||
@ -24,6 +23,4 @@ http://www.godotengine.org
|
||||
### Compiling from Source
|
||||
|
||||
Compilation instructions for every platform can be found in the Wiki:
|
||||
http://docs.godotengine.org/en/latest/reference/_compiling.html
|
||||
|
||||
[](https://travis-ci.org/godotengine/godot)
|
||||
https://github.com/okamstudio/godot/wiki/advanced
|
||||
|
||||
126
SConstruct
126
SConstruct
@ -1,6 +1,5 @@
|
||||
EnsureSConsVersion(0,14);
|
||||
|
||||
|
||||
import string
|
||||
import os
|
||||
import os.path
|
||||
@ -55,50 +54,32 @@ methods.save_active_platforms(active_platforms,active_platform_ids)
|
||||
|
||||
custom_tools=['default']
|
||||
|
||||
platform_arg = ARGUMENTS.get("platform", False)
|
||||
|
||||
if (os.name=="posix"):
|
||||
pass
|
||||
elif (os.name=="nt"):
|
||||
if (os.getenv("VSINSTALLDIR")==None or platform_arg=="android"):
|
||||
custom_tools=['mingw']
|
||||
if (os.getenv("VSINSTALLDIR")==None):
|
||||
custom_tools=['mingw']
|
||||
|
||||
env_base=Environment(tools=custom_tools,ENV = {'PATH' : os.environ['PATH']});
|
||||
|
||||
#env_base=Environment(tools=custom_tools);
|
||||
env_base.global_defaults=global_defaults
|
||||
env_base.android_maven_repos=[]
|
||||
env_base.android_dependencies=[]
|
||||
env_base.android_java_dirs=[]
|
||||
env_base.android_res_dirs=[]
|
||||
env_base.android_aidl_dirs=[]
|
||||
env_base.android_jni_dirs=[]
|
||||
env_base.android_source_modules=[]
|
||||
env_base.android_source_files=[]
|
||||
env_base.android_module_libraries=[]
|
||||
env_base.android_manifest_chunk=""
|
||||
env_base.android_permission_chunk=""
|
||||
env_base.android_appattributes_chunk=""
|
||||
env_base.disabled_modules=[]
|
||||
|
||||
env_base.split_drivers=False
|
||||
|
||||
|
||||
|
||||
env_base.__class__.android_add_maven_repository=methods.android_add_maven_repository
|
||||
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_aidl_dir=methods.android_add_aidl_dir
|
||||
env_base.__class__.android_add_jni_dir=methods.android_add_jni_dir
|
||||
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_module_source = methods.android_module_source
|
||||
env_base.__class__.android_module_library = methods.android_module_library
|
||||
env_base.__class__.android_module_file = methods.android_module_file
|
||||
env_base.__class__.android_module_manifest = methods.android_module_manifest
|
||||
env_base.__class__.android_module_permission = methods.android_module_permission
|
||||
env_base.__class__.android_module_attribute = methods.android_module_attribute
|
||||
env_base.__class__.disable_module = methods.disable_module
|
||||
|
||||
env_base.__class__.add_source_files = methods.add_source_files
|
||||
env_base.__class__.use_windows_spawn_fix = methods.use_windows_spawn_fix
|
||||
|
||||
env_base["x86_opt_gcc"]=False
|
||||
env_base["x86_opt_vc"]=False
|
||||
env_base["armv7_opt_gcc"]=False
|
||||
|
||||
customs = ['custom.py']
|
||||
|
||||
@ -118,11 +99,10 @@ opts.Add('p','Platform (same as platform=).',"")
|
||||
opts.Add('tools','Build Tools (Including Editor): (yes/no)','yes')
|
||||
opts.Add('gdscript','Build GDSCript support: (yes/no)','yes')
|
||||
opts.Add('vorbis','Build Ogg Vorbis Support: (yes/no)','yes')
|
||||
opts.Add('opus','Build Opus Audio Format Support: (yes/no)','yes')
|
||||
opts.Add('minizip','Build Minizip Archive Support: (yes/no)','yes')
|
||||
opts.Add('squish','Squish BC Texture Compression in editor (yes/no)','yes')
|
||||
opts.Add('theora','Theora Video (yes/no)','yes')
|
||||
opts.Add('theoralib','Theora Video (yes/no)','no')
|
||||
opts.Add('use_theoraplayer_binary', "Use precompiled binaries from libtheoraplayer for ogg/theora/vorbis (yes/no)", "no")
|
||||
opts.Add('freetype','Freetype support in editor','yes')
|
||||
opts.Add('speex','Speex Audio (yes/no)','yes')
|
||||
opts.Add('xml','XML Save/Load support (yes/no)','yes')
|
||||
@ -139,7 +119,6 @@ opts.Add("CXX", "Compiler");
|
||||
opts.Add("CCFLAGS", "Custom flags for the C++ compiler");
|
||||
opts.Add("CFLAGS", "Custom flags for the C compiler");
|
||||
opts.Add("LINKFLAGS", "Custom flags for the linker");
|
||||
opts.Add('unix_global_settings_path', 'unix-specific path to system-wide settings. Currently only used by templates.','')
|
||||
opts.Add('disable_3d', 'Disable 3D nodes for smaller executable (yes/no)', "no")
|
||||
opts.Add('disable_advanced_gui', 'Disable advance 3D gui nodes and behaviors (yes/no)', "no")
|
||||
opts.Add('colored', 'Enable colored output for the compilation (yes/no)', 'no')
|
||||
@ -202,7 +181,7 @@ if selected_platform in platform_list:
|
||||
if env['vsproj']=="yes":
|
||||
env.vs_incs = []
|
||||
env.vs_srcs = []
|
||||
|
||||
|
||||
def AddToVSProject( sources ):
|
||||
for x in sources:
|
||||
if type(x) == type(""):
|
||||
@ -214,12 +193,12 @@ if selected_platform in platform_list:
|
||||
basename = pieces[0]
|
||||
basename = basename.replace('\\\\','/')
|
||||
env.vs_srcs = env.vs_srcs + [basename + ".cpp"]
|
||||
env.vs_incs = env.vs_incs + [basename + ".h"]
|
||||
#print basename
|
||||
env.AddToVSProject = AddToVSProject
|
||||
|
||||
env.vs_incs = env.vs_incs + [basename + ".h"]
|
||||
#print basename
|
||||
env.AddToVSProject = AddToVSProject
|
||||
|
||||
env.extra_suffix=""
|
||||
|
||||
|
||||
if env["extra_suffix"] != '' :
|
||||
env.extra_suffix += '.'+env["extra_suffix"]
|
||||
|
||||
@ -238,15 +217,30 @@ if selected_platform in platform_list:
|
||||
|
||||
env.Append(LINKFLAGS=string.split(str(LINKFLAGS)))
|
||||
|
||||
detect.configure(env)
|
||||
|
||||
# Set our C and C++ standard requirements.
|
||||
# Prepending to make it possible to override.
|
||||
# This MSVC "detection" is an extreme hack.
|
||||
is_msvc = (os.name=="nt") and (os.getenv("VSINSTALLDIR")!=None or os.getenv("VCINSTALLDIR")!=None) and (selected_platform in ["windows", "winrt"])
|
||||
if (not is_msvc):
|
||||
# Specifying GNU extensions support explicitly, which are supported by both GCC and Clang.
|
||||
# We don't support C++17 so stick to earlier standards.
|
||||
# Godot 1.0 definitely started as a C++98 codebase.
|
||||
env.Prepend(CFLAGS=["-std=gnu11"])
|
||||
env.Prepend(CXXFLAGS=["-std=gnu++98"])
|
||||
# Disable these auto-enabled warnings which are treated as errors by modern compilers.
|
||||
env.Prepend(CCFLAGS=["-Wno-error=implicit-function-declaration", "-Wno-error=incompatible-pointer-types"])
|
||||
else:
|
||||
# MSVC doesn't support setting C++ to pre-C++14 standards, so do nothing and hope it works.
|
||||
pass
|
||||
|
||||
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, so when flags are used by configure, stuff happens (ie, ssl on x11)
|
||||
detect.configure(env)
|
||||
|
||||
#env['platform_libsuffix'] = env['LIBSUFFIX']
|
||||
#env['platform_libsuffix'] = env['LIBSUFFIX']
|
||||
|
||||
suffix="."+selected_platform
|
||||
|
||||
@ -301,11 +295,10 @@ if selected_platform in platform_list:
|
||||
|
||||
if (env['musepack']=='yes'):
|
||||
env.Append(CPPFLAGS=['-DMUSEPACK_ENABLED']);
|
||||
|
||||
if (env['openssl']!='no'):
|
||||
env.Append(CPPFLAGS=['-DOPENSSL_ENABLED']);
|
||||
if (env['openssl']=="builtin"):
|
||||
env.Append(CPPPATH=['#drivers/builtin_openssl2'])
|
||||
if (env['openssl']!='no'):
|
||||
env.Append(CPPFLAGS=['-DOPENSSL_ENABLED']);
|
||||
if (env['openssl']=="builtin"):
|
||||
env.Append(CPPPATH=['#drivers/builtin_openssl2'])
|
||||
|
||||
if (env["builtin_zlib"]=='yes'):
|
||||
env.Append(CPPPATH=['#drivers/builtin_zlib/zlib'])
|
||||
@ -318,15 +311,9 @@ if selected_platform in platform_list:
|
||||
|
||||
if (env['vorbis']=='yes'):
|
||||
env.Append(CPPFLAGS=['-DVORBIS_ENABLED']);
|
||||
if (env['opus']=='yes'):
|
||||
env.Append(CPPFLAGS=['-DOPUS_ENABLED']);
|
||||
|
||||
|
||||
if (env['theora']=='yes'):
|
||||
env['theoralib']='yes'
|
||||
env.Append(CPPFLAGS=['-DTHEORA_ENABLED']);
|
||||
if (env['theoralib']=='yes'):
|
||||
env.Append(CPPFLAGS=['-DTHEORALIB_ENABLED']);
|
||||
env.Append(CPPFLAGS=['-DTHEORA_ENABLED']);
|
||||
|
||||
if (env['png']=='yes'):
|
||||
env.Append(CPPFLAGS=['-DPNG_ENABLED']);
|
||||
@ -359,7 +346,7 @@ if selected_platform in platform_list:
|
||||
|
||||
if (env['colored']=='yes'):
|
||||
methods.colored(sys,env)
|
||||
|
||||
|
||||
if (env['etc1']=='yes'):
|
||||
env.Append(CPPFLAGS=['-DETC1_ENABLED'])
|
||||
|
||||
@ -378,22 +365,17 @@ if selected_platform in platform_list:
|
||||
SConscript("main/SCsub")
|
||||
|
||||
SConscript("platform/"+selected_platform+"/SCsub"); # build selected platform
|
||||
|
||||
# Microsoft Visual Studio Project Generation
|
||||
if (env['vsproj'])=="yes":
|
||||
|
||||
|
||||
# Microsoft Visual Studio Project Generation
|
||||
if (env['vsproj'])=="yes":
|
||||
|
||||
AddToVSProject(env.core_sources)
|
||||
AddToVSProject(env.main_sources)
|
||||
AddToVSProject(env.modules_sources)
|
||||
AddToVSProject(env.modules_sources)
|
||||
AddToVSProject(env.scene_sources)
|
||||
AddToVSProject(env.servers_sources)
|
||||
AddToVSProject(env.tool_sources)
|
||||
|
||||
#env['MSVS_VERSION']='9.0'
|
||||
env['MSVSBUILDCOM'] = "scons platform=" + selected_platform + " target=" + env["target"] + " bits=" + env["bits"] + " tools=yes"
|
||||
env['MSVSREBUILDCOM'] = "scons platform=" + selected_platform + " target=" + env["target"] + " bits=" + env["bits"] + " tools=yes vsproj=true"
|
||||
env['MSVSCLEANCOM'] = "scons --clean platform=" + selected_platform + " target=" + env["target"] + " bits=" + env["bits"] + " tools=yes"
|
||||
|
||||
|
||||
debug_variants = ['Debug|Win32']+['Debug|x64']
|
||||
release_variants = ['Release|Win32']+['Release|x64']
|
||||
release_debug_variants = ['Release_Debug|Win32']+['Release_Debug|x64']
|
||||
@ -404,11 +386,11 @@ if selected_platform in platform_list:
|
||||
targets = debug_targets + release_targets + release_debug_targets
|
||||
msvproj = env.MSVSProject(target = ['#godot' + env['MSVSPROJECTSUFFIX'] ],
|
||||
incs = env.vs_incs,
|
||||
srcs = env.vs_srcs,
|
||||
runfile = targets,
|
||||
buildtarget = targets,
|
||||
auto_build_solution=1,
|
||||
variant = variants)
|
||||
srcs = env.vs_srcs,
|
||||
runfile = targets,
|
||||
buildtarget = targets,
|
||||
auto_build_solution=1,
|
||||
variant = variants)
|
||||
|
||||
else:
|
||||
|
||||
|
||||
@ -10,3 +10,5 @@ Export('env')
|
||||
lib = env.Library("tests",env.tests_sources)
|
||||
|
||||
env.Prepend(LIBS=[lib])
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
@ -109,9 +109,6 @@ public:
|
||||
frame->set_anchor( MARGIN_RIGHT, Control::ANCHOR_END );
|
||||
frame->set_anchor( MARGIN_BOTTOM, Control::ANCHOR_END );
|
||||
frame->set_end( Point2(0,0) );
|
||||
|
||||
Ref<Theme> t = memnew( Theme );
|
||||
frame->set_theme(t);
|
||||
|
||||
get_root()->add_child( frame );
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
@ -61,7 +61,6 @@ const char ** tests_get_names() {
|
||||
"gui",
|
||||
"io",
|
||||
"shaderlang",
|
||||
"physics",
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
@ -75,90 +75,9 @@ fix: 0, 0, 100, 100
|
||||
|
||||
}
|
||||
|
||||
uint32_t ihash( uint32_t a)
|
||||
{
|
||||
a = (a+0x7ed55d16) + (a<<12);
|
||||
a = (a^0xc761c23c) ^ (a>>19);
|
||||
a = (a+0x165667b1) + (a<<5);
|
||||
a = (a+0xd3a2646c) ^ (a<<9);
|
||||
a = (a+0xfd7046c5) + (a<<3);
|
||||
a = (a^0xb55a4f09) ^ (a>>16);
|
||||
return a;
|
||||
}
|
||||
|
||||
uint32_t ihash2( uint32_t a) {
|
||||
a = (a ^ 61) ^ (a >> 16);
|
||||
a = a + (a << 3);
|
||||
a = a ^ (a >> 4);
|
||||
a = a * 0x27d4eb2d;
|
||||
a = a ^ (a >> 15);
|
||||
return a;
|
||||
}
|
||||
|
||||
uint32_t ihash3( uint32_t a)
|
||||
{
|
||||
a = (a+0x479ab41d) + (a<<8);
|
||||
a = (a^0xe4aa10ce) ^ (a>>5);
|
||||
a = (a+0x9942f0a6) - (a<<14);
|
||||
a = (a^0x5aedd67d) ^ (a>>3);
|
||||
a = (a+0x17bea992) + (a<<7);
|
||||
return a;
|
||||
}
|
||||
|
||||
MainLoop* test() {
|
||||
|
||||
|
||||
{
|
||||
|
||||
Vector<int32_t> hashes;
|
||||
List<StringName> tl;
|
||||
ObjectTypeDB::get_type_list(&tl);
|
||||
|
||||
|
||||
for (List<StringName>::Element *E=tl.front();E;E=E->next()) {
|
||||
|
||||
Vector<uint8_t> m5b = E->get().operator String().md5_buffer();
|
||||
uint32_t *ub = (uint32_t*)m5b.ptr();
|
||||
//hashes.push_back(ihash(ihash2(ihash3(*ub))));
|
||||
hashes.push_back(hashes.size());
|
||||
//hashes.push_back(E->get().hash());
|
||||
|
||||
}
|
||||
|
||||
//hashes.resize(50);
|
||||
|
||||
for(int i=nearest_shift(hashes.size());i<20;i++) {
|
||||
|
||||
bool success=true;
|
||||
for(int s=0;s<10000;s++) {
|
||||
Set<uint32_t> existing;
|
||||
success=true;
|
||||
|
||||
for(int j=0;j<hashes.size();j++) {
|
||||
|
||||
uint32_t eh = ihash2(ihash3(hashes[j]+ihash(s)+s))&((1<<i)-1);
|
||||
if (existing.has(eh)) {
|
||||
success=false;
|
||||
break;
|
||||
}
|
||||
existing.insert(eh);
|
||||
}
|
||||
|
||||
if (success) {
|
||||
print_line("success at "+itos(i)+"/"+itos(nearest_shift(hashes.size()))+" shift "+itos(s));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (success)
|
||||
break;
|
||||
}
|
||||
|
||||
print_line("DONE");
|
||||
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* 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 @@
|
||||
//#include "math_funcs.h"
|
||||
#include <stdio.h>
|
||||
#include "os/os.h"
|
||||
#include "drivers/nrex/regex.h"
|
||||
#include "drivers/trex/regex.h"
|
||||
|
||||
#include "test_string.h"
|
||||
|
||||
@ -463,16 +463,20 @@ bool test_26() {
|
||||
|
||||
OS::get_singleton()->print("\n\nTest 26: RegEx\n");
|
||||
RegEx regexp("(.*):(.*)");
|
||||
List<String> captures;
|
||||
|
||||
int res = regexp.find("name:password");
|
||||
printf("\tmatch: %s\n", (res>=0)?"true":"false");
|
||||
bool match = regexp.match("name:password", &captures);
|
||||
printf("\tmatch: %s\n", match?"true":"false");
|
||||
|
||||
printf("\t%i captures:\n", regexp.get_capture_count());
|
||||
for (int i = 0; i<regexp.get_capture_count(); i++)
|
||||
{
|
||||
printf("%ls\n", regexp.get_capture(i).c_str());
|
||||
}
|
||||
return (res>=0);
|
||||
printf("\t%i captures:\n", captures.size());
|
||||
List<String>::Element *I = captures.front();
|
||||
while (I) {
|
||||
|
||||
printf("%ls\n", I->get().c_str());
|
||||
|
||||
I = I->next();
|
||||
};
|
||||
return captures.size();
|
||||
};
|
||||
|
||||
struct test_27_data {
|
||||
@ -904,7 +908,7 @@ MainLoop* test() {
|
||||
OS::get_singleton()->print("***TOTALS!***\n");
|
||||
OS::get_singleton()->print("*************\n");
|
||||
|
||||
OS::get_singleton()->print("Passed %i of %i tests\n", passed, count);
|
||||
OS::get_singleton()->print("Passed %i of %i tests\n",count,passed);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -63,3 +63,5 @@ SConscript('bind/SCsub');
|
||||
lib = env.Library("core",env.core_sources)
|
||||
|
||||
env.Prepend(LIBS=[lib])
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
@ -222,24 +222,6 @@ void Array::invert(){
|
||||
}
|
||||
|
||||
|
||||
void Array::push_front(const Variant& p_value) {
|
||||
|
||||
_p->array.insert(0,p_value);
|
||||
}
|
||||
|
||||
void Array::pop_back(){
|
||||
|
||||
if (!_p->array.empty())
|
||||
_p->array.resize( _p->array.size() -1 );
|
||||
|
||||
}
|
||||
void Array::pop_front(){
|
||||
|
||||
if (!_p->array.empty())
|
||||
_p->array.remove(0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Array::Array(const Array& p_from) {
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
@ -53,7 +53,7 @@ public:
|
||||
bool empty() const;
|
||||
void clear();
|
||||
|
||||
bool is_shared() const;
|
||||
bool is_shared() const;
|
||||
|
||||
bool operator==(const Array& p_array) const;
|
||||
|
||||
@ -75,10 +75,6 @@ public:
|
||||
|
||||
void erase(const Variant& p_value);
|
||||
|
||||
void push_front(const Variant& p_value);
|
||||
void pop_back();
|
||||
void pop_front();
|
||||
|
||||
Array(const Array& p_from);
|
||||
Array(bool p_shared=false);
|
||||
~Array();
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -3,3 +3,5 @@ Import('env')
|
||||
env.add_source_files(env.core_sources,"*.cpp")
|
||||
|
||||
Export('env')
|
||||
|
||||
|
||||
|
||||
@ -62,8 +62,8 @@ void _ResourceLoader::_bind_methods() {
|
||||
ObjectTypeDB::bind_method(_MD("load:Resource","path","type_hint", "p_no_cache"),&_ResourceLoader::load,DEFVAL(""), DEFVAL(false));
|
||||
ObjectTypeDB::bind_method(_MD("get_recognized_extensions_for_type","type"),&_ResourceLoader::get_recognized_extensions_for_type);
|
||||
ObjectTypeDB::bind_method(_MD("set_abort_on_missing_resources","abort"),&_ResourceLoader::set_abort_on_missing_resources);
|
||||
ObjectTypeDB::bind_method(_MD("get_dependencies","path"),&_ResourceLoader::get_dependencies);
|
||||
ObjectTypeDB::bind_method(_MD("has","path"),&_ResourceLoader::has);
|
||||
ObjectTypeDB::bind_method(_MD("get_dependencies"),&_ResourceLoader::get_dependencies);
|
||||
ObjectTypeDB::bind_method(_MD("has"),&_ResourceLoader::has);
|
||||
}
|
||||
|
||||
_ResourceLoader::_ResourceLoader() {
|
||||
@ -96,7 +96,7 @@ _ResourceSaver *_ResourceSaver::singleton=NULL;
|
||||
|
||||
void _ResourceSaver::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("save","path","resource:Resource","flags"),&_ResourceSaver::save,DEFVAL(0));
|
||||
ObjectTypeDB::bind_method(_MD("save","path","resource:Resource"),&_ResourceSaver::save, DEFVAL(0));
|
||||
ObjectTypeDB::bind_method(_MD("get_recognized_extensions","type"),&_ResourceSaver::get_recognized_extensions);
|
||||
|
||||
BIND_CONSTANT(FLAG_RELATIVE_PATHS);
|
||||
@ -390,12 +390,6 @@ bool _OS::is_ok_left_and_cancel_right() const {
|
||||
return OS::get_singleton()->get_swap_ok_cancel();
|
||||
}
|
||||
|
||||
Error _OS::set_thread_name(const String& p_name) {
|
||||
|
||||
return Thread::set_name(p_name);
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
enum Weekday {
|
||||
DAY_SUNDAY,
|
||||
@ -463,9 +457,9 @@ void _OS::set_icon(const Image& p_icon) {
|
||||
OS::get_singleton()->set_icon(p_icon);
|
||||
}
|
||||
|
||||
Dictionary _OS::get_date(bool utc) const {
|
||||
Dictionary _OS::get_date() const {
|
||||
|
||||
OS::Date date = OS::get_singleton()->get_date(utc);
|
||||
OS::Date date = OS::get_singleton()->get_date();
|
||||
Dictionary dated;
|
||||
dated["year"]=date.year;
|
||||
dated["month"]=date.month;
|
||||
@ -476,9 +470,9 @@ Dictionary _OS::get_date(bool utc) const {
|
||||
|
||||
|
||||
}
|
||||
Dictionary _OS::get_time(bool utc) const {
|
||||
Dictionary _OS::get_time() const {
|
||||
|
||||
OS::Time time = OS::get_singleton()->get_time(utc);
|
||||
OS::Time time = OS::get_singleton()->get_time();
|
||||
Dictionary timed;
|
||||
timed["hour"]=time.hour;
|
||||
timed["minute"]=time.min;
|
||||
@ -486,24 +480,11 @@ Dictionary _OS::get_time(bool utc) const {
|
||||
return timed;
|
||||
|
||||
}
|
||||
|
||||
Dictionary _OS::get_time_zone_info() const {
|
||||
OS::TimeZoneInfo info = OS::get_singleton()->get_time_zone_info();
|
||||
Dictionary infod;
|
||||
infod["bias"] = info.bias;
|
||||
infod["name"] = info.name;
|
||||
return infod;
|
||||
}
|
||||
|
||||
uint64_t _OS::get_unix_time() const {
|
||||
|
||||
return OS::get_singleton()->get_unix_time();
|
||||
};
|
||||
|
||||
uint64_t _OS::get_system_time_secs() const {
|
||||
return OS::get_singleton()->get_system_time_secs();
|
||||
}
|
||||
|
||||
void _OS::delay_usec(uint32_t p_usec) const {
|
||||
|
||||
OS::get_singleton()->delay_usec(p_usec);
|
||||
@ -689,10 +670,6 @@ void _OS::native_video_pause() {
|
||||
OS::get_singleton()->native_video_pause();
|
||||
};
|
||||
|
||||
void _OS::native_video_unpause() {
|
||||
OS::get_singleton()->native_video_unpause();
|
||||
};
|
||||
|
||||
void _OS::native_video_stop() {
|
||||
|
||||
OS::get_singleton()->native_video_stop();
|
||||
@ -708,26 +685,6 @@ bool _OS::is_debug_build() const {
|
||||
|
||||
}
|
||||
|
||||
void _OS::set_screen_orientation(ScreenOrientation p_orientation) {
|
||||
|
||||
OS::get_singleton()->set_screen_orientation(OS::ScreenOrientation(p_orientation));
|
||||
}
|
||||
|
||||
_OS::ScreenOrientation _OS::get_screen_orientation() const {
|
||||
|
||||
return ScreenOrientation(OS::get_singleton()->get_screen_orientation());
|
||||
}
|
||||
|
||||
void _OS::set_keep_screen_on(bool p_enabled) {
|
||||
|
||||
OS::get_singleton()->set_keep_screen_on(p_enabled);
|
||||
}
|
||||
|
||||
bool _OS::is_keep_screen_on() const {
|
||||
|
||||
return OS::get_singleton()->is_keep_screen_on();
|
||||
}
|
||||
|
||||
String _OS::get_system_dir(SystemDir p_dir) const {
|
||||
|
||||
return OS::get_singleton()->get_system_dir(OS::SystemDir(p_dir));
|
||||
@ -751,11 +708,6 @@ int _OS::find_scancode_from_string(const String& p_code) const {
|
||||
return find_keycode(p_code);
|
||||
}
|
||||
|
||||
void _OS::alert(const String& p_alert,const String& p_title) {
|
||||
|
||||
OS::get_singleton()->alert(p_alert,p_title);
|
||||
}
|
||||
|
||||
_OS *_OS::singleton=NULL;
|
||||
|
||||
void _OS::_bind_methods() {
|
||||
@ -791,11 +743,6 @@ void _OS::_bind_methods() {
|
||||
ObjectTypeDB::bind_method(_MD("set_window_maximized", "enabled"),&_OS::set_window_maximized);
|
||||
ObjectTypeDB::bind_method(_MD("is_window_maximized"),&_OS::is_window_maximized);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_screen_orientation","orientation"),&_OS::set_screen_orientation);
|
||||
ObjectTypeDB::bind_method(_MD("get_screen_orientation"),&_OS::get_screen_orientation);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_keep_screen_on","enabled"),&_OS::set_keep_screen_on);
|
||||
ObjectTypeDB::bind_method(_MD("is_keep_screen_on"),&_OS::is_keep_screen_on);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_iterations_per_second","iterations_per_second"),&_OS::set_iterations_per_second);
|
||||
ObjectTypeDB::bind_method(_MD("get_iterations_per_second"),&_OS::get_iterations_per_second);
|
||||
@ -827,13 +774,11 @@ void _OS::_bind_methods() {
|
||||
ObjectTypeDB::bind_method(_MD("get_cmdline_args"),&_OS::get_cmdline_args);
|
||||
ObjectTypeDB::bind_method(_MD("get_main_loop"),&_OS::get_main_loop);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("get_date","utc"),&_OS::get_date,DEFVAL(false));
|
||||
ObjectTypeDB::bind_method(_MD("get_time","utc"),&_OS::get_time,DEFVAL(false));
|
||||
ObjectTypeDB::bind_method(_MD("get_time_zone_info"),&_OS::get_time_zone_info);
|
||||
ObjectTypeDB::bind_method(_MD("get_date"),&_OS::get_date);
|
||||
ObjectTypeDB::bind_method(_MD("get_time"),&_OS::get_time);
|
||||
ObjectTypeDB::bind_method(_MD("get_unix_time"),&_OS::get_unix_time);
|
||||
ObjectTypeDB::bind_method(_MD("get_system_time_secs"), &_OS::get_system_time_secs);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_icon","icon"),&_OS::set_icon);
|
||||
ObjectTypeDB::bind_method(_MD("set_icon"),&_OS::set_icon);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("delay_usec","usec"),&_OS::delay_usec);
|
||||
ObjectTypeDB::bind_method(_MD("delay_msec","msec"),&_OS::delay_msec);
|
||||
@ -872,13 +817,12 @@ void _OS::_bind_methods() {
|
||||
ObjectTypeDB::bind_method(_MD("get_frames_per_second"),&_OS::get_frames_per_second);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("print_all_textures_by_size"),&_OS::print_all_textures_by_size);
|
||||
ObjectTypeDB::bind_method(_MD("print_resources_by_type","types"),&_OS::print_resources_by_type);
|
||||
ObjectTypeDB::bind_method(_MD("print_resources_by_type"),&_OS::print_resources_by_type);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("native_video_play","path","volume","audio_track","subtitle_track"),&_OS::native_video_play);
|
||||
ObjectTypeDB::bind_method(_MD("native_video_play"),&_OS::native_video_play);
|
||||
ObjectTypeDB::bind_method(_MD("native_video_is_playing"),&_OS::native_video_is_playing);
|
||||
ObjectTypeDB::bind_method(_MD("native_video_stop"),&_OS::native_video_stop);
|
||||
ObjectTypeDB::bind_method(_MD("native_video_pause"),&_OS::native_video_pause);
|
||||
ObjectTypeDB::bind_method(_MD("native_video_unpause"),&_OS::native_video_unpause);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("get_scancode_string","code"),&_OS::get_scancode_string);
|
||||
ObjectTypeDB::bind_method(_MD("is_scancode_unicode","code"),&_OS::is_scancode_unicode);
|
||||
@ -886,9 +830,6 @@ void _OS::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_use_file_access_save_and_swap","enabled"),&_OS::set_use_file_access_save_and_swap);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("alert","text","title"),&_OS::alert,DEFVAL("Alert!"));
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_thread_name","name"),&_OS::set_thread_name);
|
||||
|
||||
|
||||
BIND_CONSTANT( DAY_SUNDAY );
|
||||
@ -912,14 +853,6 @@ void _OS::_bind_methods() {
|
||||
BIND_CONSTANT( MONTH_NOVEMBER );
|
||||
BIND_CONSTANT( MONTH_DECEMBER );
|
||||
|
||||
BIND_CONSTANT( SCREEN_ORIENTATION_LANDSCAPE );
|
||||
BIND_CONSTANT( SCREEN_ORIENTATION_PORTRAIT );
|
||||
BIND_CONSTANT( SCREEN_ORIENTATION_REVERSE_LANDSCAPE );
|
||||
BIND_CONSTANT( SCREEN_ORIENTATION_REVERSE_PORTRAIT );
|
||||
BIND_CONSTANT( SCREEN_ORIENTATION_SENSOR_LANDSCAPE );
|
||||
BIND_CONSTANT( SCREEN_ORIENTATION_SENSOR_PORTRAIT );
|
||||
BIND_CONSTANT( SCREEN_ORIENTATION_SENSOR );
|
||||
|
||||
BIND_CONSTANT( SYSTEM_DIR_DESKTOP);
|
||||
BIND_CONSTANT( SYSTEM_DIR_DCIM );
|
||||
BIND_CONSTANT( SYSTEM_DIR_DOCUMENTS );
|
||||
@ -1326,9 +1259,9 @@ String _File::get_line() const{
|
||||
|
||||
}
|
||||
|
||||
Vector<String> _File::get_csv_line(String delim) const {
|
||||
Vector<String> _File::get_csv_line() const {
|
||||
ERR_FAIL_COND_V(!f,Vector<String>());
|
||||
return f->get_csv_line(delim);
|
||||
return f->get_csv_line();
|
||||
}
|
||||
|
||||
/**< use this for files WRITTEN in _big_ endian machines (ie, amiga/mac)
|
||||
@ -1511,7 +1444,7 @@ void _File::_bind_methods() {
|
||||
ObjectTypeDB::bind_method(_MD("set_endian_swap","enable"),&_File::set_endian_swap);
|
||||
ObjectTypeDB::bind_method(_MD("get_error:Error"),&_File::get_error);
|
||||
ObjectTypeDB::bind_method(_MD("get_var"),&_File::get_var);
|
||||
ObjectTypeDB::bind_method(_MD("get_csv_line","delim"),&_File::get_csv_line,DEFVAL(","));
|
||||
ObjectTypeDB::bind_method(_MD("get_csv_line"),&_File::get_csv_line);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("store_8","value"),&_File::store_8);
|
||||
ObjectTypeDB::bind_method(_MD("store_16","value"),&_File::store_16);
|
||||
@ -1533,7 +1466,6 @@ void _File::_bind_methods() {
|
||||
BIND_CONSTANT( READ );
|
||||
BIND_CONSTANT( WRITE );
|
||||
BIND_CONSTANT( READ_WRITE );
|
||||
BIND_CONSTANT( WRITE_READ );
|
||||
}
|
||||
|
||||
_File::_File(){
|
||||
@ -1736,89 +1668,12 @@ Variant _Marshalls::base64_to_variant(const String& p_str) {
|
||||
return v;
|
||||
};
|
||||
|
||||
String _Marshalls::raw_to_base64(const DVector<uint8_t> &p_arr) {
|
||||
|
||||
int len = p_arr.size();
|
||||
DVector<uint8_t>::Read r = p_arr.read();
|
||||
|
||||
int b64len = len / 3 * 4 + 4 + 1;
|
||||
DVector<uint8_t> b64buff;
|
||||
b64buff.resize(b64len);
|
||||
DVector<uint8_t>::Write w64 = b64buff.write();
|
||||
|
||||
int strlen = base64_encode((char*)(&w64[0]), (char*)(&r[0]), len);
|
||||
w64[strlen] = 0;
|
||||
String ret = (char*)&w64[0];
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
DVector<uint8_t> _Marshalls::base64_to_raw(const String &p_str) {
|
||||
|
||||
int strlen = p_str.length();
|
||||
CharString cstr = p_str.ascii();
|
||||
|
||||
int arr_len;
|
||||
DVector<uint8_t> buf;
|
||||
{
|
||||
buf.resize(strlen / 4 * 3 + 1);
|
||||
DVector<uint8_t>::Write w = buf.write();
|
||||
|
||||
arr_len = base64_decode((char*)(&w[0]), (char*)cstr.get_data(), strlen);
|
||||
};
|
||||
buf.resize(arr_len);
|
||||
|
||||
// conversion from DVector<uint8_t> to raw array?
|
||||
return buf;
|
||||
};
|
||||
|
||||
String _Marshalls::utf8_to_base64(const String& p_str) {
|
||||
|
||||
CharString cstr = p_str.utf8();
|
||||
int len = cstr.length();
|
||||
|
||||
int b64len = len / 3 * 4 + 4 + 1;
|
||||
DVector<uint8_t> b64buff;
|
||||
b64buff.resize(b64len);
|
||||
DVector<uint8_t>::Write w64 = b64buff.write();
|
||||
|
||||
int strlen = base64_encode((char*)(&w64[0]), (char*)cstr.get_data(), len);
|
||||
|
||||
w64[strlen] = 0;
|
||||
String ret = (char*)&w64[0];
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
String _Marshalls::base64_to_utf8(const String& p_str) {
|
||||
|
||||
int strlen = p_str.length();
|
||||
CharString cstr = p_str.ascii();
|
||||
|
||||
DVector<uint8_t> buf;
|
||||
buf.resize(strlen / 4 * 3 + 1 + 1);
|
||||
DVector<uint8_t>::Write w = buf.write();
|
||||
|
||||
int len = base64_decode((char*)(&w[0]), (char*)cstr.get_data(), strlen);
|
||||
|
||||
w[len] = 0;
|
||||
String ret = String::utf8((char*)&w[0]);
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
|
||||
void _Marshalls::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("variant_to_base64:String","variant"),&_Marshalls::variant_to_base64);
|
||||
ObjectTypeDB::bind_method(_MD("base64_to_variant:Variant","base64_str"),&_Marshalls::base64_to_variant);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("raw_to_base64:String","array"),&_Marshalls::raw_to_base64);
|
||||
ObjectTypeDB::bind_method(_MD("base64_to_raw:RawArray","base64_str"),&_Marshalls::base64_to_raw);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("utf8_to_base64:String","utf8_str"),&_Marshalls::utf8_to_base64);
|
||||
ObjectTypeDB::bind_method(_MD("base64_to_utf8:String","base64_str"),&_Marshalls::base64_to_utf8);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -1907,9 +1762,6 @@ void _Thread::_start_func(void *ud) {
|
||||
memdelete(tud);
|
||||
Variant::CallError ce;
|
||||
const Variant* arg[1]={&t->userdata};
|
||||
|
||||
Thread::set_name(t->target_method);
|
||||
|
||||
t->ret=t->target_instance->call(t->target_method,arg,1,ce);
|
||||
if (ce.error!=Variant::CallError::CALL_OK) {
|
||||
|
||||
@ -1934,7 +1786,6 @@ void _Thread::_start_func(void *ud) {
|
||||
default: {}
|
||||
}
|
||||
|
||||
|
||||
ERR_EXPLAIN("Could not call function '"+t->target_method.operator String()+"'' starting thread ID: "+t->get_id()+" Reason: "+reason);
|
||||
ERR_FAIL();
|
||||
}
|
||||
@ -2004,7 +1855,7 @@ void _Thread::_bind_methods() {
|
||||
ObjectTypeDB::bind_method(_MD("start:Error","instance","method","userdata","priority"),&_Thread::start,DEFVAL(Variant()),DEFVAL(PRIORITY_NORMAL));
|
||||
ObjectTypeDB::bind_method(_MD("get_id"),&_Thread::get_id);
|
||||
ObjectTypeDB::bind_method(_MD("is_active"),&_Thread::is_active);
|
||||
ObjectTypeDB::bind_method(_MD("wait_to_finish:Variant"),&_Thread::wait_to_finish);
|
||||
ObjectTypeDB::bind_method(_MD("wait_to_finish:var"),&_Thread::wait_to_finish);
|
||||
|
||||
BIND_CONSTANT( PRIORITY_LOW );
|
||||
BIND_CONSTANT( PRIORITY_NORMAL );
|
||||
|
||||
@ -131,7 +131,6 @@ public:
|
||||
Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track);
|
||||
bool native_video_is_playing();
|
||||
void native_video_pause();
|
||||
void native_video_unpause();
|
||||
void native_video_stop();
|
||||
|
||||
void set_iterations_per_second(int p_ips);
|
||||
@ -205,11 +204,9 @@ public:
|
||||
void set_use_file_access_save_and_swap(bool p_enable);
|
||||
|
||||
void set_icon(const Image& p_icon);
|
||||
Dictionary get_date(bool utc) const;
|
||||
Dictionary get_time(bool utc) const;
|
||||
Dictionary get_time_zone_info() const;
|
||||
Dictionary get_date() const;
|
||||
Dictionary get_time() const;
|
||||
uint64_t get_unix_time() const;
|
||||
uint64_t get_system_time_secs() const;
|
||||
|
||||
int get_static_memory_usage() const;
|
||||
int get_static_memory_peak_usage() const;
|
||||
@ -241,45 +238,22 @@ public:
|
||||
SYSTEM_DIR_RINGTONES,
|
||||
};
|
||||
|
||||
enum ScreenOrientation {
|
||||
|
||||
SCREEN_ORIENTATION_LANDSCAPE,
|
||||
SCREEN_ORIENTATION_PORTRAIT,
|
||||
SCREEN_ORIENTATION_REVERSE_LANDSCAPE,
|
||||
SCREEN_ORIENTATION_REVERSE_PORTRAIT,
|
||||
SCREEN_ORIENTATION_SENSOR_LANDSCAPE,
|
||||
SCREEN_ORIENTATION_SENSOR_PORTRAIT,
|
||||
SCREEN_ORIENTATION_SENSOR,
|
||||
};
|
||||
|
||||
String get_system_dir(SystemDir p_dir) const;
|
||||
|
||||
|
||||
String get_data_dir() const;
|
||||
|
||||
void alert(const String& p_alert,const String& p_title="ALERT!");
|
||||
|
||||
|
||||
void set_screen_orientation(ScreenOrientation p_orientation);
|
||||
ScreenOrientation get_screen_orientation() const;
|
||||
|
||||
void set_keep_screen_on(bool p_enabled);
|
||||
bool is_keep_screen_on() const;
|
||||
|
||||
void set_time_scale(float p_scale);
|
||||
float get_time_scale();
|
||||
|
||||
bool is_ok_left_and_cancel_right() const;
|
||||
|
||||
Error set_thread_name(const String& p_name);
|
||||
|
||||
static _OS *get_singleton() { return singleton; }
|
||||
|
||||
_OS();
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(_OS::SystemDir);
|
||||
VARIANT_ENUM_CAST(_OS::ScreenOrientation);
|
||||
|
||||
|
||||
class _Geometry : public Object {
|
||||
@ -335,7 +309,6 @@ public:
|
||||
READ=1,
|
||||
WRITE=2,
|
||||
READ_WRITE=3,
|
||||
WRITE_READ=7,
|
||||
};
|
||||
|
||||
Error open_encrypted(const String& p_path, int p_mode_flags,const Vector<uint8_t>& p_key);
|
||||
@ -393,7 +366,7 @@ public:
|
||||
virtual void store_pascal_string(const String& p_string);
|
||||
virtual String get_pascal_string();
|
||||
|
||||
Vector<String> get_csv_line(String delim=",") const;
|
||||
Vector<String> get_csv_line() const;
|
||||
|
||||
|
||||
void store_buffer(const DVector<uint8_t>& p_buffer); ///< store an array of bytes
|
||||
@ -462,12 +435,6 @@ public:
|
||||
String variant_to_base64(const Variant& p_var);
|
||||
Variant base64_to_variant(const String& p_str);
|
||||
|
||||
String raw_to_base64(const DVector<uint8_t>& p_arr);
|
||||
DVector<uint8_t> base64_to_raw(const String& p_str);
|
||||
|
||||
String utf8_to_base64(const String& p_str);
|
||||
String base64_to_utf8(const String& p_str);
|
||||
|
||||
_Marshalls() {};
|
||||
};
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
@ -117,31 +117,29 @@ void Color::set_hsv(float p_h, float p_s, float p_v, float p_alpha) {
|
||||
}
|
||||
|
||||
p_h *=6.0;
|
||||
p_h = Math::fmod(p_h,6);
|
||||
i = Math::floor( p_h );
|
||||
|
||||
f = p_h - i;
|
||||
p = p_v * ( 1 - p_s );
|
||||
q = p_v * ( 1 - p_s * f );
|
||||
t = p_v * ( 1 - p_s * ( 1 - f ) );
|
||||
|
||||
switch( i ) {
|
||||
case 0: // Red is the dominant color
|
||||
case 0:
|
||||
r = p_v;
|
||||
g = t;
|
||||
b = p;
|
||||
break;
|
||||
case 1: // Green is the dominant color
|
||||
case 1:
|
||||
r = q;
|
||||
g = p_v;
|
||||
b = p;
|
||||
break;
|
||||
case 2:
|
||||
case 2:
|
||||
r = p;
|
||||
g = p_v;
|
||||
b = t;
|
||||
break;
|
||||
case 3: // Blue is the dominant color
|
||||
case 3:
|
||||
r = p;
|
||||
g = q;
|
||||
b = p_v;
|
||||
@ -151,7 +149,7 @@ void Color::set_hsv(float p_h, float p_s, float p_v, float p_alpha) {
|
||||
g = p;
|
||||
b = p_v;
|
||||
break;
|
||||
default: // (5) Red is the dominant color
|
||||
default: // cap_se 5:
|
||||
r = p_v;
|
||||
g = p;
|
||||
b = q;
|
||||
@ -163,7 +161,7 @@ void Color::invert() {
|
||||
|
||||
r=1.0-r;
|
||||
g=1.0-g;
|
||||
b=1.0-b;
|
||||
g=1.0-b;
|
||||
}
|
||||
void Color::contrast() {
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
@ -174,7 +174,7 @@ class CommandQueueMT {
|
||||
R* ret;
|
||||
SyncSemaphore *sync;
|
||||
|
||||
virtual void call() { *ret = (instance->*method)(p1); sync->sem->post(); sync->in_use=false; }
|
||||
virtual void call() { *ret = (instance->*method)(p1); sync->sem->post(); sync->in_use=false; ; }
|
||||
};
|
||||
|
||||
template<class T,class M,class P1,class P2,class R>
|
||||
@ -981,7 +981,7 @@ public:
|
||||
|
||||
void flush_all() {
|
||||
|
||||
//ERR_FAIL_COND(sync);
|
||||
ERR_FAIL_COND(sync);
|
||||
lock();
|
||||
while (true) {
|
||||
bool exit = !flush_one();
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
@ -410,15 +410,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()));
|
||||
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()));
|
||||
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()));
|
||||
print_line("translation: loaded string table of size: "+itos(strings.size()));
|
||||
} else if (name=="load_from") {
|
||||
//print_line("generating");
|
||||
print_line("generating");
|
||||
generate(p_value);
|
||||
} else
|
||||
return false;
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
@ -160,20 +160,7 @@ void Dictionary::_unref() const {
|
||||
}
|
||||
uint32_t Dictionary::hash() const {
|
||||
|
||||
uint32_t h=hash_djb2_one_32(Variant::DICTIONARY);
|
||||
|
||||
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;
|
||||
return hash_djb2_one_64(make_uint64_t(_p));
|
||||
}
|
||||
|
||||
Array Dictionary::keys() const {
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
@ -54,7 +54,6 @@ enum Error {
|
||||
ERR_FILE_CANT_READ,
|
||||
ERR_FILE_UNRECOGNIZED, // (15)
|
||||
ERR_FILE_CORRUPT,
|
||||
ERR_FILE_MISSING_DEPENDENCIES,
|
||||
ERR_FILE_EOF,
|
||||
ERR_CANT_OPEN, ///< Can't open a resource/socket/file
|
||||
ERR_CANT_CREATE,
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
@ -104,7 +104,7 @@ extern bool _err_error_exists;
|
||||
|
||||
#define ERR_FAIL_INDEX(m_index,m_size) \
|
||||
do {if ((m_index)<0 || (m_index)>=(m_size)) { \
|
||||
_err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Index " _STR(m_index)" out of size (" _STR(m_size)")."); \
|
||||
_err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Index "_STR(m_index)" out of size ("_STR(m_size)")."); \
|
||||
return; \
|
||||
} else _err_error_exists=false; } while(0); \
|
||||
|
||||
@ -115,7 +115,7 @@ extern bool _err_error_exists;
|
||||
|
||||
#define ERR_FAIL_INDEX_V(m_index,m_size,m_retval) \
|
||||
do {if ((m_index)<0 || (m_index)>=(m_size)) { \
|
||||
_err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Index " _STR(m_index)" out of size (" _STR(m_size)")."); \
|
||||
_err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Index "_STR(m_index)" out of size ("_STR(m_size)")."); \
|
||||
return m_retval; \
|
||||
} else _err_error_exists=false;} while (0);
|
||||
|
||||
@ -125,14 +125,14 @@ extern bool _err_error_exists;
|
||||
|
||||
#define ERR_FAIL_NULL(m_param) \
|
||||
{ if ( !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; } \
|
||||
|
||||
|
||||
#define ERR_FAIL_NULL_V(m_param,m_retval) \
|
||||
{ if ( !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; } \
|
||||
|
||||
@ -142,7 +142,7 @@ extern bool _err_error_exists;
|
||||
|
||||
#define ERR_FAIL_COND(m_cond) \
|
||||
{ if ( 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; } \
|
||||
|
||||
@ -154,7 +154,7 @@ extern bool _err_error_exists;
|
||||
|
||||
#define ERR_FAIL_COND_V(m_cond,m_retval) \
|
||||
{ if ( 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; } \
|
||||
|
||||
@ -164,7 +164,7 @@ extern bool _err_error_exists;
|
||||
|
||||
#define ERR_CONTINUE(m_cond) \
|
||||
{ if ( m_cond ) { \
|
||||
_err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Condition ' " _STR(m_cond)" ' is true. Continuing..:"); \
|
||||
_err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Condition ' "_STR(m_cond)" ' is true. Continuing..:"); \
|
||||
continue;\
|
||||
} else _err_error_exists=false;} \
|
||||
|
||||
@ -174,7 +174,7 @@ extern bool _err_error_exists;
|
||||
|
||||
#define ERR_BREAK(m_cond) \
|
||||
{ if ( m_cond ) { \
|
||||
_err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Condition ' " _STR(m_cond)" ' is true. Breaking..:"); \
|
||||
_err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Condition ' "_STR(m_cond)" ' is true. Breaking..:"); \
|
||||
break;\
|
||||
} else _err_error_exists=false;} \
|
||||
|
||||
@ -193,7 +193,7 @@ extern bool _err_error_exists;
|
||||
|
||||
#define ERR_FAIL_V(m_value) \
|
||||
{ \
|
||||
_err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Method/Function Failed, returning: " __STR(m_value)); \
|
||||
_err_print_error(FUNCTION_STR,__FILE__,__LINE__,"Method/Function Failed, returning: "__STR(m_value)); \
|
||||
_err_error_exists=false; \
|
||||
return m_value;\
|
||||
} \
|
||||
@ -207,11 +207,6 @@ extern bool _err_error_exists;
|
||||
_err_error_exists=false;\
|
||||
} \
|
||||
|
||||
#define ERR_PRINTS(m_string) \
|
||||
{ \
|
||||
_err_print_error(FUNCTION_STR,__FILE__,__LINE__,String(m_string).utf8().get_data()); \
|
||||
_err_error_exists=false;\
|
||||
} \
|
||||
|
||||
/** Print a warning string.
|
||||
*/
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -31,7 +31,8 @@ void FuncRef::_bind_methods() {
|
||||
|
||||
{
|
||||
MethodInfo mi;
|
||||
mi.name="call_func";
|
||||
mi.name="call";
|
||||
mi.arguments.push_back( PropertyInfo( Variant::STRING, "method"));
|
||||
Vector<Variant> defargs;
|
||||
for(int i=0;i<10;i++) {
|
||||
mi.arguments.push_back( PropertyInfo( Variant::NIL, "arg"+itos(i)));
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
@ -106,7 +106,7 @@ static _GlobalConstant _global_constants[]={
|
||||
BIND_GLOBAL_CONSTANT( KEY_KP_ENTER ),
|
||||
BIND_GLOBAL_CONSTANT( KEY_KP_MULTIPLY ),
|
||||
BIND_GLOBAL_CONSTANT( KEY_KP_DIVIDE ),
|
||||
BIND_GLOBAL_CONSTANT( KEY_KP_SUBTRACT ),
|
||||
BIND_GLOBAL_CONSTANT( KEY_KP_SUBSTRACT ),
|
||||
BIND_GLOBAL_CONSTANT( KEY_KP_PERIOD ),
|
||||
BIND_GLOBAL_CONSTANT( KEY_KP_ADD ),
|
||||
BIND_GLOBAL_CONSTANT( KEY_KP_0 ),
|
||||
@ -317,19 +317,16 @@ static _GlobalConstant _global_constants[]={
|
||||
BIND_GLOBAL_CONSTANT( KEY_MASK_KPAD ),
|
||||
BIND_GLOBAL_CONSTANT( KEY_MASK_GROUP_SWITCH ),
|
||||
|
||||
// mouse
|
||||
// joysticks
|
||||
BIND_GLOBAL_CONSTANT( BUTTON_LEFT ),
|
||||
BIND_GLOBAL_CONSTANT( BUTTON_RIGHT ),
|
||||
BIND_GLOBAL_CONSTANT( BUTTON_MIDDLE ),
|
||||
BIND_GLOBAL_CONSTANT( BUTTON_WHEEL_UP ),
|
||||
BIND_GLOBAL_CONSTANT( BUTTON_WHEEL_DOWN ),
|
||||
BIND_GLOBAL_CONSTANT( BUTTON_WHEEL_LEFT ),
|
||||
BIND_GLOBAL_CONSTANT( BUTTON_WHEEL_RIGHT ),
|
||||
BIND_GLOBAL_CONSTANT( BUTTON_MASK_LEFT ),
|
||||
BIND_GLOBAL_CONSTANT( BUTTON_MASK_RIGHT ),
|
||||
BIND_GLOBAL_CONSTANT( BUTTON_MASK_MIDDLE ),
|
||||
|
||||
//joysticks
|
||||
BIND_GLOBAL_CONSTANT( JOY_BUTTON_0 ),
|
||||
BIND_GLOBAL_CONSTANT( JOY_BUTTON_1 ),
|
||||
BIND_GLOBAL_CONSTANT( JOY_BUTTON_2 ),
|
||||
@ -405,9 +402,6 @@ static _GlobalConstant _global_constants[]={
|
||||
BIND_GLOBAL_CONSTANT( JOY_ANALOG_2_X ),
|
||||
BIND_GLOBAL_CONSTANT( JOY_ANALOG_2_Y ),
|
||||
|
||||
BIND_GLOBAL_CONSTANT( JOY_ANALOG_L2 ),
|
||||
BIND_GLOBAL_CONSTANT( JOY_ANALOG_R2 ),
|
||||
|
||||
|
||||
// error list
|
||||
|
||||
@ -428,7 +422,6 @@ static _GlobalConstant _global_constants[]={
|
||||
BIND_GLOBAL_CONSTANT( ERR_FILE_CANT_READ ),
|
||||
BIND_GLOBAL_CONSTANT( ERR_FILE_UNRECOGNIZED ),
|
||||
BIND_GLOBAL_CONSTANT( ERR_FILE_CORRUPT ),
|
||||
BIND_GLOBAL_CONSTANT( ERR_FILE_MISSING_DEPENDENCIES),
|
||||
BIND_GLOBAL_CONSTANT( ERR_FILE_EOF ),
|
||||
BIND_GLOBAL_CONSTANT( ERR_CANT_OPEN ), ///< Can't open a resource/socket/file
|
||||
BIND_GLOBAL_CONSTANT( ERR_CANT_CREATE ),
|
||||
@ -479,16 +472,6 @@ static _GlobalConstant _global_constants[]={
|
||||
BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_EDITOR ),
|
||||
BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_NETWORK ),
|
||||
BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_DEFAULT ),
|
||||
|
||||
BIND_GLOBAL_CONSTANT( METHOD_FLAG_NORMAL ),
|
||||
BIND_GLOBAL_CONSTANT( METHOD_FLAG_EDITOR ),
|
||||
BIND_GLOBAL_CONSTANT( METHOD_FLAG_NOSCRIPT ),
|
||||
BIND_GLOBAL_CONSTANT( METHOD_FLAG_CONST ),
|
||||
BIND_GLOBAL_CONSTANT( METHOD_FLAG_REVERSE ),
|
||||
BIND_GLOBAL_CONSTANT( METHOD_FLAG_VIRTUAL ),
|
||||
BIND_GLOBAL_CONSTANT( METHOD_FLAG_FROM_SCRIPT ),
|
||||
BIND_GLOBAL_CONSTANT( METHOD_FLAGS_DEFAULT ),
|
||||
|
||||
{"TYPE_NIL",Variant::NIL},
|
||||
{"TYPE_BOOL",Variant::BOOL},
|
||||
{"TYPE_INT",Variant::INT},
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
@ -54,7 +54,7 @@ String Globals::localize_path(const String& p_path) const {
|
||||
if (resource_path=="")
|
||||
return p_path; //not initialied yet
|
||||
|
||||
if (p_path.find(":/") != -1)
|
||||
if (p_path.begins_with("res://"))
|
||||
return p_path.simplify_path();
|
||||
|
||||
|
||||
@ -132,12 +132,8 @@ bool Globals::_set(const StringName& p_name, const Variant& p_value) {
|
||||
if (props.has(p_name)) {
|
||||
if (!props[p_name].overrided)
|
||||
props[p_name].variant=p_value;
|
||||
|
||||
if (props[p_name].order>=NO_ORDER_BASE && registering_order) {
|
||||
props[p_name].order=last_order++;
|
||||
}
|
||||
} else {
|
||||
props[p_name]=VariantContainer(p_value,last_order++ + (registering_order?0:NO_ORDER_BASE));
|
||||
props[p_name]=VariantContainer(p_value,last_order++);
|
||||
}
|
||||
}
|
||||
|
||||
@ -304,7 +300,6 @@ Error Globals::setup(const String& p_path,const String & p_main_pack) {
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
if (OS::get_singleton()->get_resource_dir()!="") {
|
||||
//OS will call Globals->get_resource_path which will be empty if not overriden!
|
||||
//if the OS would rather use somewhere else, then it will not be empty.
|
||||
@ -314,7 +309,7 @@ Error Globals::setup(const String& p_path,const String & p_main_pack) {
|
||||
|
||||
print_line("has res dir: "+resource_path);
|
||||
if (!_load_resource_pack("res://data.pck"))
|
||||
_load_resource_pack("res://data.zip");
|
||||
_load_resource_pack("res://data.pcz");
|
||||
// make sure this is load from the resource path
|
||||
print_line("exists engine cfg? "+itos(FileAccess::exists("/engine.cfg")));
|
||||
if (_load_settings("res://engine.cfg")==OK || _load_settings_binary("res://engine.cfb")==OK) {
|
||||
@ -337,7 +332,6 @@ Error Globals::setup(const String& p_path,const String & p_main_pack) {
|
||||
|
||||
String candidate = d->get_current_dir();
|
||||
String current_dir = d->get_current_dir();
|
||||
String exec_name = OS::get_singleton()->get_executable_path().get_file().basename();
|
||||
bool found = false;
|
||||
bool first_time=true;
|
||||
|
||||
@ -345,16 +339,7 @@ Error Globals::setup(const String& p_path,const String & p_main_pack) {
|
||||
//try to load settings in ascending through dirs shape!
|
||||
|
||||
//tries to open pack, but only first time
|
||||
if (first_time && (_load_resource_pack(current_dir+"/"+exec_name+".pck") || _load_resource_pack(current_dir+"/"+exec_name+".zip") )) {
|
||||
if (_load_settings("res://engine.cfg")==OK || _load_settings_binary("res://engine.cfb")==OK) {
|
||||
|
||||
_load_settings("res://override.cfg");
|
||||
found=true;
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
} else if (first_time && (_load_resource_pack(current_dir+"/data.pck") || _load_resource_pack(current_dir+"/data.zip") )) {
|
||||
if (first_time && _load_resource_pack(current_dir+"/data.pck")) {
|
||||
if (_load_settings("res://engine.cfg")==OK || _load_settings_binary("res://engine.cfb")==OK) {
|
||||
|
||||
_load_settings("res://override.cfg");
|
||||
@ -638,9 +623,7 @@ static Variant _decode_variant(const String& p_string) {
|
||||
InputEvent ie;
|
||||
ie.type=InputEvent::JOYSTICK_MOTION;
|
||||
ie.device=params[0].to_int();
|
||||
int axis = params[1].to_int();;
|
||||
ie.joy_motion.axis=axis>>1;
|
||||
ie.joy_motion.axis_value=axis&1?1:-1;
|
||||
ie.joy_motion.axis=params[1].to_int();
|
||||
|
||||
return ie;
|
||||
}
|
||||
@ -748,10 +731,6 @@ static Variant _decode_variant(const String& p_string) {
|
||||
return Variant();
|
||||
}
|
||||
|
||||
void Globals::set_registering_order(bool p_enable) {
|
||||
|
||||
registering_order=p_enable;
|
||||
}
|
||||
|
||||
Error Globals::_load_settings_binary(const String p_path) {
|
||||
|
||||
@ -771,8 +750,6 @@ Error Globals::_load_settings_binary(const String p_path) {
|
||||
ERR_FAIL_V(ERR_FILE_CORRUPT;)
|
||||
}
|
||||
|
||||
set_registering_order(false);
|
||||
|
||||
uint32_t count=f->get_32();
|
||||
|
||||
for(int i=0;i<count;i++) {
|
||||
@ -797,9 +774,6 @@ Error Globals::_load_settings_binary(const String p_path) {
|
||||
set_persisting(key,true);
|
||||
}
|
||||
|
||||
set_registering_order(true);
|
||||
|
||||
|
||||
return OK;
|
||||
}
|
||||
Error Globals::_load_settings(const String p_path) {
|
||||
@ -818,8 +792,6 @@ Error Globals::_load_settings(const String p_path) {
|
||||
String section;
|
||||
String subpath;
|
||||
|
||||
set_registering_order(false);
|
||||
|
||||
int line_count = 0;
|
||||
|
||||
while(!f->eof_reached()) {
|
||||
@ -895,7 +867,6 @@ Error Globals::_load_settings(const String p_path) {
|
||||
|
||||
memdelete(f);
|
||||
|
||||
set_registering_order(true);
|
||||
|
||||
return OK;
|
||||
}
|
||||
@ -916,14 +887,6 @@ static String _encode_variant(const Variant& p_variant) {
|
||||
float val = p_variant;
|
||||
return rtos(val)+(val==int(val)?".0":"");
|
||||
} break;
|
||||
case Variant::VECTOR2: {
|
||||
Vector2 val = p_variant;
|
||||
return String("Vector2(")+rtos(val.x)+String(", ")+rtos(val.y)+String(")");
|
||||
} break;
|
||||
case Variant::VECTOR3: {
|
||||
Vector3 val = p_variant;
|
||||
return String("Vector3(")+rtos(val.x)+ String(", ") +rtos(val.y)+ String(", ") +rtos(val.z)+String(")");
|
||||
} break;
|
||||
case Variant::STRING: {
|
||||
String val = p_variant;
|
||||
return "\""+val.xml_escape()+"\"";
|
||||
@ -1039,7 +1002,7 @@ static String _encode_variant(const Variant& p_variant) {
|
||||
} break;
|
||||
case InputEvent::JOYSTICK_MOTION: {
|
||||
|
||||
return "jaxis("+itos(ev.device)+", "+itos(ev.joy_motion.axis * 2 + (ev.joy_motion.axis_value<0?0:1))+")";
|
||||
return "jaxis("+itos(ev.device)+", "+itos(ev.joy_motion.axis)+")";
|
||||
} break;
|
||||
default: {
|
||||
|
||||
@ -1186,12 +1149,6 @@ Error Globals::_save_settings_text(const String& p_file,const Map<String,List<St
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
Error Globals::_save_custom_bnd(const String &p_file) { // add other params as dictionary and array?
|
||||
|
||||
return save_custom(p_file);
|
||||
};
|
||||
|
||||
Error Globals::save_custom(const String& p_path,const CustomMap& p_custom,const Set<String>& p_ignore_masks) {
|
||||
|
||||
ERR_FAIL_COND_V(p_path=="",ERR_INVALID_PARAMETER);
|
||||
@ -1364,7 +1321,7 @@ Vector<String> Globals::get_optimizer_presets() const {
|
||||
|
||||
if (!E->get().name.begins_with("optimizer_presets/"))
|
||||
continue;
|
||||
names.push_back(E->get().name.get_slicec('/',1));
|
||||
names.push_back(E->get().name.get_slice("/",1));
|
||||
}
|
||||
|
||||
names.sort();
|
||||
@ -1401,12 +1358,9 @@ void Globals::_bind_methods() {
|
||||
ObjectTypeDB::bind_method(_MD("localize_path","path"),&Globals::localize_path);
|
||||
ObjectTypeDB::bind_method(_MD("globalize_path","path"),&Globals::globalize_path);
|
||||
ObjectTypeDB::bind_method(_MD("save"),&Globals::save);
|
||||
ObjectTypeDB::bind_method(_MD("has_singleton","name"),&Globals::has_singleton);
|
||||
ObjectTypeDB::bind_method(_MD("get_singleton","name"),&Globals::get_singleton_object);
|
||||
ObjectTypeDB::bind_method(_MD("load_resource_pack","pack"),&Globals::_load_resource_pack);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("save_custom","file"),&Globals::_save_custom_bnd);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("has_singleton"),&Globals::has_singleton);
|
||||
ObjectTypeDB::bind_method(_MD("get_singleton"),&Globals::get_singleton_object);
|
||||
ObjectTypeDB::bind_method(_MD("load_resource_pack"),&Globals::_load_resource_pack);
|
||||
}
|
||||
|
||||
Globals::Globals() {
|
||||
@ -1415,7 +1369,7 @@ Globals::Globals() {
|
||||
singleton=this;
|
||||
last_order=0;
|
||||
disable_platform_override=false;
|
||||
registering_order=true;
|
||||
|
||||
|
||||
|
||||
Array va;
|
||||
@ -1427,7 +1381,7 @@ Globals::Globals() {
|
||||
|
||||
set("application/name","" );
|
||||
set("application/main_scene","");
|
||||
custom_prop_info["application/main_scene"]=PropertyInfo(Variant::STRING,"application/main_scene",PROPERTY_HINT_FILE,"scn,res,xscn,xml,tscn");
|
||||
custom_prop_info["application/main_scene"]=PropertyInfo(Variant::STRING,"application/main_scene",PROPERTY_HINT_FILE,"scn,res,xscn,xml");
|
||||
set("application/disable_stdout",false);
|
||||
set("application/use_shared_user_dir",true);
|
||||
|
||||
@ -1441,15 +1395,6 @@ Globals::Globals() {
|
||||
joyb.joy_button.button_index=JOY_BUTTON_0;
|
||||
va.push_back(joyb);
|
||||
set("input/ui_accept",va);
|
||||
input_presets.push_back("input/ui_accept");
|
||||
|
||||
va=Array();
|
||||
key.key.scancode=KEY_SPACE;
|
||||
va.push_back(key);
|
||||
joyb.joy_button.button_index=JOY_BUTTON_3;
|
||||
va.push_back(joyb);
|
||||
set("input/ui_select",va);
|
||||
input_presets.push_back("input/ui_select");
|
||||
|
||||
va=Array();
|
||||
key.key.scancode=KEY_ESCAPE;
|
||||
@ -1457,20 +1402,17 @@ Globals::Globals() {
|
||||
joyb.joy_button.button_index=JOY_BUTTON_1;
|
||||
va.push_back(joyb);
|
||||
set("input/ui_cancel",va);
|
||||
input_presets.push_back("input/ui_cancel");
|
||||
|
||||
va=Array();
|
||||
key.key.scancode=KEY_TAB;
|
||||
va.push_back(key);
|
||||
set("input/ui_focus_next",va);
|
||||
input_presets.push_back("input/ui_focus_next");
|
||||
|
||||
va=Array();
|
||||
key.key.scancode=KEY_TAB;
|
||||
key.key.mod.shift=true;
|
||||
va.push_back(key);
|
||||
set("input/ui_focus_prev",va);
|
||||
input_presets.push_back("input/ui_focus_prev");
|
||||
key.key.mod.shift=false;
|
||||
|
||||
va=Array();
|
||||
@ -1479,7 +1421,6 @@ Globals::Globals() {
|
||||
joyb.joy_button.button_index=JOY_DPAD_LEFT;
|
||||
va.push_back(joyb);
|
||||
set("input/ui_left",va);
|
||||
input_presets.push_back("input/ui_left");
|
||||
|
||||
va=Array();
|
||||
key.key.scancode=KEY_RIGHT;
|
||||
@ -1487,7 +1428,6 @@ Globals::Globals() {
|
||||
joyb.joy_button.button_index=JOY_DPAD_RIGHT;
|
||||
va.push_back(joyb);
|
||||
set("input/ui_right",va);
|
||||
input_presets.push_back("input/ui_right");
|
||||
|
||||
va=Array();
|
||||
key.key.scancode=KEY_UP;
|
||||
@ -1495,7 +1435,6 @@ Globals::Globals() {
|
||||
joyb.joy_button.button_index=JOY_DPAD_UP;
|
||||
va.push_back(joyb);
|
||||
set("input/ui_up",va);
|
||||
input_presets.push_back("input/ui_up");
|
||||
|
||||
va=Array();
|
||||
key.key.scancode=KEY_DOWN;
|
||||
@ -1503,20 +1442,17 @@ Globals::Globals() {
|
||||
joyb.joy_button.button_index=JOY_DPAD_DOWN;
|
||||
va.push_back(joyb);
|
||||
set("input/ui_down",va);
|
||||
input_presets.push_back("input/ui_down");
|
||||
|
||||
|
||||
va=Array();
|
||||
key.key.scancode=KEY_PAGEUP;
|
||||
va.push_back(key);
|
||||
set("input/ui_page_up",va);
|
||||
input_presets.push_back("input/ui_page_up");
|
||||
|
||||
va=Array();
|
||||
key.key.scancode=KEY_PAGEDOWN;
|
||||
va.push_back(key);
|
||||
set("input/ui_page_down",va);
|
||||
input_presets.push_back("input/ui_page_down");
|
||||
|
||||
// set("display/orientation", "landscape");
|
||||
|
||||
@ -1524,7 +1460,7 @@ Globals::Globals() {
|
||||
custom_prop_info["display/orientation"]=PropertyInfo(Variant::STRING,"display/orientation",PROPERTY_HINT_ENUM,"landscape,portrait,reverse_landscape,reverse_portrait,sensor_landscape,sensor_portrait,sensor");
|
||||
custom_prop_info["render/mipmap_policy"]=PropertyInfo(Variant::INT,"render/mipmap_policy",PROPERTY_HINT_ENUM,"Allow,Allow For Po2,Disallow");
|
||||
custom_prop_info["render/thread_model"]=PropertyInfo(Variant::INT,"render/thread_model",PROPERTY_HINT_ENUM,"Single-Unsafe,Single-Safe,Multi-Threaded");
|
||||
custom_prop_info["physics_2d/thread_model"]=PropertyInfo(Variant::INT,"physics_2d/thread_model",PROPERTY_HINT_ENUM,"Single-Unsafe,Single-Safe,Multi-Threaded");
|
||||
set("display/emulate_touchscreen",false);
|
||||
|
||||
using_datapack=false;
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
@ -54,10 +54,6 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
enum {
|
||||
NO_ORDER_BASE=1<<18
|
||||
};
|
||||
|
||||
struct VariantContainer {
|
||||
int order;
|
||||
bool persist;
|
||||
@ -68,14 +64,12 @@ protected:
|
||||
VariantContainer(const Variant& p_variant, int p_order, bool p_persist=false) { variant=p_variant; order=p_order; hide_from_editor=false; persist=p_persist; overrided=false; }
|
||||
};
|
||||
|
||||
bool registering_order;
|
||||
int last_order;
|
||||
Map<StringName,VariantContainer> props;
|
||||
String resource_path;
|
||||
Map<StringName,PropertyInfo> custom_prop_info;
|
||||
bool disable_platform_override;
|
||||
bool using_datapack;
|
||||
List<String> input_presets;
|
||||
|
||||
|
||||
bool _set(const StringName& p_name, const Variant& p_value);
|
||||
@ -92,7 +86,6 @@ protected:
|
||||
|
||||
List<Singleton> singletons;
|
||||
|
||||
Error _save_custom_bnd(const String& p_file);
|
||||
|
||||
bool _load_resource_pack(const String& p_pack);
|
||||
|
||||
@ -130,8 +123,6 @@ public:
|
||||
|
||||
Vector<String> get_optimizer_presets() const;
|
||||
|
||||
List<String> get_input_presets() const { return input_presets; }
|
||||
|
||||
void set_disable_platform_override(bool p_disable);
|
||||
Object* get_singleton_object(const String& p_name) const;
|
||||
|
||||
@ -139,8 +130,6 @@ public:
|
||||
|
||||
bool is_using_datapack() const;
|
||||
|
||||
void set_registering_order(bool p_registering);
|
||||
|
||||
Globals();
|
||||
~Globals();
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
239
core/image.cpp
239
core/image.cpp
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
@ -34,33 +34,6 @@
|
||||
#include "print_string.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
const char* Image::format_names[Image::FORMAT_MAX]={
|
||||
"Grayscale",
|
||||
"Intensity",
|
||||
"GrayscaleAlpha",
|
||||
"RGB",
|
||||
"RGBA",
|
||||
"Indexed",
|
||||
"IndexedAlpha",
|
||||
"YUV422",
|
||||
"YUV444",
|
||||
"BC1",
|
||||
"BC2",
|
||||
"BC3",
|
||||
"BC4",
|
||||
"BC5",
|
||||
"PVRTC2",
|
||||
"PVRTC2Alpha",
|
||||
"PVRTC4",
|
||||
"PVRTC4Alpha",
|
||||
"ETC",
|
||||
"ATC",
|
||||
"ATCAlphaExp",
|
||||
"ATCAlphaInterp",
|
||||
|
||||
};
|
||||
|
||||
SavePNGFunc Image::save_png_func = NULL;
|
||||
|
||||
void Image::_put_pixel(int p_x,int p_y, const BColor& p_color, unsigned char *p_data) {
|
||||
@ -322,7 +295,7 @@ void Image::set_pallete(const DVector<uint8_t>& p_data) {
|
||||
DVector<uint8_t>::Write wp = data.write();
|
||||
unsigned char *dst=wp.ptr() + pal_ofs;
|
||||
|
||||
DVector<uint8_t>::Read r = p_data.read();
|
||||
DVector<uint8_t>::Read r = data.read();
|
||||
const unsigned char *src=r.ptr();
|
||||
|
||||
copymem(dst, src, len);
|
||||
@ -427,102 +400,6 @@ Image::Format Image::get_format() const{
|
||||
return format;
|
||||
}
|
||||
|
||||
static double _bicubic_interp_kernel( double x ) {
|
||||
|
||||
x = ABS(x);
|
||||
|
||||
double bc = 0;
|
||||
|
||||
if ( x <= 1 )
|
||||
bc = ( 1.5 * x - 2.5 ) * x * x + 1;
|
||||
else if ( x < 2 )
|
||||
bc = ( ( -0.5 * x + 2.5 ) * x - 4 ) * x + 2;
|
||||
|
||||
|
||||
return bc;
|
||||
}
|
||||
|
||||
template<int CC>
|
||||
static void _scale_cubic(const uint8_t* p_src, uint8_t* p_dst, uint32_t p_src_width, uint32_t p_src_height, uint32_t p_dst_width, uint32_t p_dst_height) {
|
||||
|
||||
|
||||
// get source image size
|
||||
int width = p_src_width;
|
||||
int height = p_src_height;
|
||||
double xfac = (double) width / p_dst_width;
|
||||
double yfac = (double) height / p_dst_height;
|
||||
// coordinates of source points and cooefficiens
|
||||
double ox, oy, dx, dy, k1, k2;
|
||||
int ox1, oy1, ox2, oy2;
|
||||
// destination pixel values
|
||||
// width and height decreased by 1
|
||||
int ymax = height - 1;
|
||||
int xmax = width - 1;
|
||||
// temporary pointer
|
||||
|
||||
for ( int y = 0; y < p_dst_height; y++ ) {
|
||||
// Y coordinates
|
||||
oy = (double) y * yfac - 0.5f;
|
||||
oy1 = (int) oy;
|
||||
dy = oy - (double) oy1;
|
||||
|
||||
for ( int x = 0; x < p_dst_width; x++ ) {
|
||||
// X coordinates
|
||||
ox = (double) x * xfac - 0.5f;
|
||||
ox1 = (int) ox;
|
||||
dx = ox - (double) ox1;
|
||||
|
||||
// initial pixel value
|
||||
|
||||
uint8_t *dst=p_dst + (y*p_dst_width+x)*CC;
|
||||
|
||||
double color[CC];
|
||||
for(int i=0;i<CC;i++) {
|
||||
color[i]=0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
for ( int n = -1; n < 3; n++ ) {
|
||||
// get Y cooefficient
|
||||
k1 = _bicubic_interp_kernel( dy - (double) n );
|
||||
|
||||
oy2 = oy1 + n;
|
||||
if ( oy2 < 0 )
|
||||
oy2 = 0;
|
||||
if ( oy2 > ymax )
|
||||
oy2 = ymax;
|
||||
|
||||
for ( int m = -1; m < 3; m++ ) {
|
||||
// get X cooefficient
|
||||
k2 = k1 * _bicubic_interp_kernel( (double) m - dx );
|
||||
|
||||
ox2 = ox1 + m;
|
||||
if ( ox2 < 0 )
|
||||
ox2 = 0;
|
||||
if ( ox2 > xmax )
|
||||
ox2 = xmax;
|
||||
|
||||
// get pixel of original image
|
||||
const uint8_t *p = p_src + (oy2 * p_src_width + ox2)*CC;
|
||||
|
||||
for(int i=0;i<CC;i++) {
|
||||
|
||||
color[i]+=p[i]*k2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(int i=0;i<CC;i++) {
|
||||
dst[i]=CLAMP(Math::fast_ftoi(color[i]),0,255);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<int CC>
|
||||
static void _scale_bilinear(const uint8_t* p_src, uint8_t* p_dst, uint32_t p_src_width, uint32_t p_src_height, uint32_t p_dst_width, uint32_t p_dst_height) {
|
||||
|
||||
@ -682,17 +559,6 @@ void Image::resize( int p_width, int p_height, Interpolation p_interpolation ) {
|
||||
}
|
||||
|
||||
} break;
|
||||
case INTERPOLATE_CUBIC: {
|
||||
|
||||
switch(get_format_pixel_size(format)) {
|
||||
case 1: _scale_cubic<1>(r_ptr,w_ptr,width,height,p_width,p_height); break;
|
||||
case 2: _scale_cubic<2>(r_ptr,w_ptr,width,height,p_width,p_height); break;
|
||||
case 3: _scale_cubic<3>(r_ptr,w_ptr,width,height,p_width,p_height); break;
|
||||
case 4: _scale_cubic<4>(r_ptr,w_ptr,width,height,p_width,p_height); break;
|
||||
}
|
||||
|
||||
} break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1150,10 +1016,10 @@ void Image::create( const char ** p_xpm ) {
|
||||
String line_str=line_ptr;
|
||||
line_str.replace("\t"," ");
|
||||
|
||||
size_width=line_str.get_slicec(' ',0).to_int();
|
||||
size_height=line_str.get_slicec(' ',1).to_int();
|
||||
colormap_size=line_str.get_slicec(' ',2).to_int();
|
||||
pixelchars=line_str.get_slicec(' ',3).to_int();
|
||||
size_width=line_str.get_slice(" ",0).to_int();
|
||||
size_height=line_str.get_slice(" ",1).to_int();
|
||||
colormap_size=line_str.get_slice(" ",2).to_int();
|
||||
pixelchars=line_str.get_slice(" ",3).to_int();
|
||||
ERR_FAIL_COND(colormap_size > 32766);
|
||||
ERR_FAIL_COND(pixelchars > 5);
|
||||
ERR_FAIL_COND(size_width > 32767);
|
||||
@ -1258,7 +1124,6 @@ void Image::create( const char ** p_xpm ) {
|
||||
}
|
||||
#define DETECT_ALPHA_MAX_TRESHOLD 254
|
||||
#define DETECT_ALPHA_MIN_TRESHOLD 2
|
||||
|
||||
#define DETECT_ALPHA( m_value )\
|
||||
{ \
|
||||
uint8_t value=m_value;\
|
||||
@ -1271,82 +1136,6 @@ void Image::create( const char ** p_xpm ) {
|
||||
}\
|
||||
}
|
||||
|
||||
#define DETECT_NON_ALPHA( m_value )\
|
||||
{ \
|
||||
uint8_t value=m_value;\
|
||||
if (value>0) {\
|
||||
\
|
||||
detected=true;\
|
||||
break;\
|
||||
}\
|
||||
}
|
||||
|
||||
|
||||
bool Image::is_invisible() const {
|
||||
|
||||
if (format==FORMAT_GRAYSCALE ||
|
||||
format==FORMAT_RGB ||
|
||||
format==FORMAT_INDEXED)
|
||||
return false;
|
||||
|
||||
int len = data.size();
|
||||
|
||||
if (len==0)
|
||||
return true;
|
||||
|
||||
if (format >= FORMAT_YUV_422 && format <= FORMAT_YUV_444)
|
||||
return false;
|
||||
|
||||
int w,h;
|
||||
_get_mipmap_offset_and_size(1,len,w,h);
|
||||
|
||||
DVector<uint8_t>::Read r = data.read();
|
||||
const unsigned char *data_ptr=r.ptr();
|
||||
|
||||
bool detected=false;
|
||||
|
||||
switch(format) {
|
||||
case FORMAT_INTENSITY: {
|
||||
|
||||
for(int i=0;i<len;i++) {
|
||||
DETECT_NON_ALPHA(data_ptr[i]);
|
||||
}
|
||||
} break;
|
||||
case FORMAT_GRAYSCALE_ALPHA: {
|
||||
|
||||
|
||||
for(int i=0;i<(len>>1);i++) {
|
||||
DETECT_NON_ALPHA(data_ptr[(i<<1)+1]);
|
||||
}
|
||||
|
||||
} break;
|
||||
case FORMAT_RGBA: {
|
||||
|
||||
for(int i=0;i<(len>>2);i++) {
|
||||
DETECT_NON_ALPHA(data_ptr[(i<<2)+3])
|
||||
}
|
||||
|
||||
} break;
|
||||
case FORMAT_INDEXED: {
|
||||
|
||||
return false;
|
||||
} break;
|
||||
case FORMAT_INDEXED_ALPHA: {
|
||||
|
||||
return false;
|
||||
} break;
|
||||
case FORMAT_PVRTC2_ALPHA:
|
||||
case FORMAT_PVRTC4_ALPHA:
|
||||
case FORMAT_BC2:
|
||||
case FORMAT_BC3: {
|
||||
detected=true;
|
||||
} break;
|
||||
default: {}
|
||||
}
|
||||
|
||||
return !detected;
|
||||
}
|
||||
|
||||
Image::AlphaMode Image::detect_alpha() const {
|
||||
|
||||
if (format==FORMAT_GRAYSCALE ||
|
||||
@ -1957,10 +1746,6 @@ Error Image::_decompress_bc() {
|
||||
return OK;
|
||||
}
|
||||
|
||||
bool Image::is_compressed() const {
|
||||
return format>=FORMAT_BC1;
|
||||
}
|
||||
|
||||
|
||||
Image Image::decompressed() const {
|
||||
|
||||
@ -2213,7 +1998,7 @@ void Image::blit_rect(const Image& p_src, const Rect2& p_src_rect,const Point2&
|
||||
}
|
||||
|
||||
|
||||
Image (*Image::_png_mem_loader_func)(const uint8_t*,int)=NULL;
|
||||
Image (*Image::_png_mem_loader_func)(const uint8_t*)=NULL;
|
||||
void (*Image::_image_compress_bc_func)(Image *)=NULL;
|
||||
void (*Image::_image_compress_pvrtc2_func)(Image *)=NULL;
|
||||
void (*Image::_image_compress_pvrtc4_func)(Image *)=NULL;
|
||||
@ -2382,13 +2167,7 @@ void Image::fix_alpha_edges() {
|
||||
|
||||
}
|
||||
|
||||
String Image::get_format_name(Format p_format) {
|
||||
|
||||
ERR_FAIL_INDEX_V(p_format,FORMAT_MAX,String());
|
||||
return format_names[p_format];
|
||||
}
|
||||
|
||||
Image::Image(const uint8_t* p_png,int p_len) {
|
||||
Image::Image(const uint8_t* p_png) {
|
||||
|
||||
width=0;
|
||||
height=0;
|
||||
@ -2396,7 +2175,7 @@ Image::Image(const uint8_t* p_png,int p_len) {
|
||||
format=FORMAT_GRAYSCALE;
|
||||
|
||||
if (_png_mem_loader_func) {
|
||||
*this = _png_mem_loader_func(p_png,p_len);
|
||||
*this = _png_mem_loader_func(p_png);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
12
core/image.h
12
core/image.h
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
@ -87,16 +87,14 @@ public:
|
||||
FORMAT_MAX
|
||||
};
|
||||
|
||||
static const char* format_names[FORMAT_MAX];
|
||||
enum Interpolation {
|
||||
|
||||
INTERPOLATE_NEAREST,
|
||||
INTERPOLATE_BILINEAR,
|
||||
INTERPOLATE_CUBIC,
|
||||
/* INTERPOLATE GAUSS */
|
||||
};
|
||||
|
||||
static Image (*_png_mem_loader_func)(const uint8_t* p_png,int p_size);
|
||||
static Image (*_png_mem_loader_func)(const uint8_t* p_png);
|
||||
static void (*_image_compress_bc_func)(Image *);
|
||||
static void (*_image_compress_pvrtc2_func)(Image *);
|
||||
static void (*_image_compress_pvrtc4_func)(Image *);
|
||||
@ -307,7 +305,6 @@ public:
|
||||
};
|
||||
|
||||
AlphaMode detect_alpha() const;
|
||||
bool is_invisible() const;
|
||||
|
||||
void put_indexed_pixel(int p_x, int p_y, uint8_t p_idx,int p_mipmap=0);
|
||||
uint8_t get_indexed_pixel(int p_x, int p_y,int p_mipmap=0) const;
|
||||
@ -338,7 +335,6 @@ public:
|
||||
Image compressed(int p_mode); /* from the Image::CompressMode enum */
|
||||
Error decompress();
|
||||
Image decompressed() const;
|
||||
bool is_compressed() const;
|
||||
|
||||
void fix_alpha_edges();
|
||||
void premultiply_alpha();
|
||||
@ -353,9 +349,7 @@ public:
|
||||
Image get_rect(const Rect2& p_area) const;
|
||||
|
||||
static void set_compress_bc_func(void (*p_compress_func)(Image *));
|
||||
static String get_format_name(Format p_format);
|
||||
|
||||
Image(const uint8_t* p_mem_png, int p_len=-1);
|
||||
Image(const uint8_t* p_mem_png);
|
||||
Image(const char **p_xpm);
|
||||
~Image();
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
@ -204,64 +204,6 @@ bool InputMap::event_is_action(const InputEvent& p_event, const StringName& p_ac
|
||||
return _find_event(E->get().inputs,p_event)!=NULL;
|
||||
}
|
||||
|
||||
bool InputMap::event_is_joy_motion_action_pressed(const InputEvent& p_event) const {
|
||||
|
||||
ERR_FAIL_COND_V(p_event.type!=InputEvent::JOYSTICK_MOTION,false);
|
||||
bool pressed=false;
|
||||
|
||||
//this could be optimized by having a separate list of joymotions?
|
||||
|
||||
for (Map<StringName, Action>::Element *A=input_map.front();A;A=A->next()) {
|
||||
|
||||
for (List<InputEvent>::Element *E=A->get().inputs.front();E;E=E->next()) {
|
||||
|
||||
const InputEvent& e=E->get();
|
||||
if(e.type!=p_event.type)
|
||||
continue;
|
||||
if (e.type!=InputEvent::KEY && e.device!=p_event.device)
|
||||
continue;
|
||||
|
||||
switch(p_event.type) {
|
||||
|
||||
case InputEvent::KEY: {
|
||||
|
||||
if (e.key.scancode==p_event.key.scancode && e.key.mod == p_event.key.mod)
|
||||
return e.key.pressed;
|
||||
|
||||
} break;
|
||||
case InputEvent::JOYSTICK_BUTTON: {
|
||||
|
||||
if (e.joy_button.button_index==p_event.joy_button.button_index) {
|
||||
return e.joy_button.pressed;
|
||||
}
|
||||
|
||||
} break;
|
||||
case InputEvent::MOUSE_BUTTON: {
|
||||
|
||||
if (e.mouse_button.button_index==p_event.mouse_button.button_index) {
|
||||
return e.mouse_button.pressed;
|
||||
}
|
||||
|
||||
} break;
|
||||
case InputEvent::JOYSTICK_MOTION: {
|
||||
|
||||
if (e.joy_motion.axis==p_event.joy_motion.axis) {
|
||||
if (
|
||||
(e.joy_motion.axis_value * p_event.joy_motion.axis_value >0) && //same axis
|
||||
ABS(e.joy_motion.axis_value)>0.5 && ABS(p_event.joy_motion.axis_value)>0.5 )
|
||||
pressed=true;
|
||||
}
|
||||
|
||||
} break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return pressed;
|
||||
|
||||
}
|
||||
|
||||
void InputMap::load_from_globals() {
|
||||
|
||||
input_map.clear();;
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
@ -68,7 +68,6 @@ public:
|
||||
|
||||
const List<InputEvent> *get_action_list(const StringName& p_action);
|
||||
bool event_is_action(const InputEvent& p_event, const StringName& p_action) const;
|
||||
bool event_is_joy_motion_action_pressed(const InputEvent& p_event) const;
|
||||
|
||||
|
||||
void load_from_globals();
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,3 +5,5 @@ env.add_source_files(env.core_sources,"*.c")
|
||||
#env.core_sources.append("io/fastlz.c")
|
||||
|
||||
Export('env')
|
||||
|
||||
|
||||
|
||||
@ -1,399 +1,359 @@
|
||||
/*
|
||||
* Byte-oriented AES-256 implementation.
|
||||
* All lookup tables replaced with 'on the fly' calculations.
|
||||
*
|
||||
* Copyright (c) 2007-2011 Ilya O. Levin, http://www.literatecode.com
|
||||
* Other contributors: Hal Finney
|
||||
*
|
||||
* 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" 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.
|
||||
*/
|
||||
#include "aes256.h"
|
||||
|
||||
#define FD(x) (((x) >> 1) ^ (((x) & 1) ? 0x8d : 0))
|
||||
|
||||
#define BACK_TO_TABLES
|
||||
|
||||
static uint8_t rj_xtime(uint8_t);
|
||||
static void aes_subBytes(uint8_t *);
|
||||
static void aes_subBytes_inv(uint8_t *);
|
||||
static void aes_addRoundKey(uint8_t *, uint8_t *);
|
||||
static void aes_addRoundKey_cpy(uint8_t *, uint8_t *, uint8_t *);
|
||||
static void aes_shiftRows(uint8_t *);
|
||||
static void aes_shiftRows_inv(uint8_t *);
|
||||
static void aes_mixColumns(uint8_t *);
|
||||
static void aes_mixColumns_inv(uint8_t *);
|
||||
static void aes_expandEncKey(uint8_t *, uint8_t *);
|
||||
static void aes_expandDecKey(uint8_t *, uint8_t *);
|
||||
#ifndef BACK_TO_TABLES
|
||||
static uint8_t gf_alog(uint8_t);
|
||||
static uint8_t gf_log(uint8_t);
|
||||
static uint8_t gf_mulinv(uint8_t);
|
||||
static uint8_t rj_sbox(uint8_t);
|
||||
static uint8_t rj_sbox_inv(uint8_t);
|
||||
#endif
|
||||
|
||||
#ifdef BACK_TO_TABLES
|
||||
|
||||
static const uint8_t sbox[256] =
|
||||
{
|
||||
0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5,
|
||||
0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
|
||||
0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0,
|
||||
0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
|
||||
0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc,
|
||||
0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
|
||||
0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a,
|
||||
0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
|
||||
0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0,
|
||||
0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
|
||||
0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b,
|
||||
0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
|
||||
0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85,
|
||||
0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
|
||||
0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5,
|
||||
0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
|
||||
0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17,
|
||||
0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
|
||||
0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88,
|
||||
0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
|
||||
0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c,
|
||||
0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
|
||||
0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9,
|
||||
0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
|
||||
0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6,
|
||||
0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
|
||||
0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e,
|
||||
0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
|
||||
0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94,
|
||||
0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
|
||||
0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68,
|
||||
0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16
|
||||
};
|
||||
static const uint8_t sboxinv[256] =
|
||||
{
|
||||
0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38,
|
||||
0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb,
|
||||
0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87,
|
||||
0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb,
|
||||
0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d,
|
||||
0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e,
|
||||
0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2,
|
||||
0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25,
|
||||
0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16,
|
||||
0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92,
|
||||
0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda,
|
||||
0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84,
|
||||
0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a,
|
||||
0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06,
|
||||
0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02,
|
||||
0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b,
|
||||
0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea,
|
||||
0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73,
|
||||
0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85,
|
||||
0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e,
|
||||
0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89,
|
||||
0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b,
|
||||
0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20,
|
||||
0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4,
|
||||
0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31,
|
||||
0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f,
|
||||
0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d,
|
||||
0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef,
|
||||
0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0,
|
||||
0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61,
|
||||
0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26,
|
||||
0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d
|
||||
};
|
||||
|
||||
#define rj_sbox(x) sbox[(x)]
|
||||
#define rj_sbox_inv(x) sboxinv[(x)]
|
||||
|
||||
#else /* tableless subroutines */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
static uint8_t gf_alog(uint8_t x) // calculate anti-logarithm gen 3
|
||||
{
|
||||
uint8_t y = 1, i;
|
||||
|
||||
for (i = 0; i < x; i++) y ^= rj_xtime(y);
|
||||
|
||||
return y;
|
||||
} /* gf_alog */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
static uint8_t gf_log(uint8_t x) // calculate logarithm gen 3
|
||||
{
|
||||
uint8_t y, i = 0;
|
||||
|
||||
if (x)
|
||||
for (i = 1, y = 1; i > 0; i++ )
|
||||
{
|
||||
y ^= rj_xtime(y);
|
||||
if (y == x) break;
|
||||
}
|
||||
|
||||
return i;
|
||||
} /* gf_log */
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
static uint8_t gf_mulinv(uint8_t x) // calculate multiplicative inverse
|
||||
{
|
||||
return (x) ? gf_alog(255 - gf_log(x)) : 0;
|
||||
} /* gf_mulinv */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
static uint8_t rj_sbox(uint8_t x)
|
||||
{
|
||||
uint8_t y, sb;
|
||||
|
||||
sb = y = gf_mulinv(x);
|
||||
y = (uint8_t)(y << 1) | (y >> 7), sb ^= y;
|
||||
y = (uint8_t)(y << 1) | (y >> 7), sb ^= y;
|
||||
y = (uint8_t)(y << 1) | (y >> 7), sb ^= y;
|
||||
y = (uint8_t)(y << 1) | (y >> 7), sb ^= y;
|
||||
|
||||
return (sb ^ 0x63);
|
||||
} /* rj_sbox */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
static uint8_t rj_sbox_inv(uint8_t x)
|
||||
{
|
||||
uint8_t y, sb;
|
||||
|
||||
y = x ^ 0x63;
|
||||
sb = y = (uint8_t)(y << 1) | (y >> 7);
|
||||
y = (uint8_t)(y << 2) | (y >> 6);
|
||||
sb ^= y;
|
||||
y = (uint8_t)(y << 3) | (y >> 5);
|
||||
sb ^= y;
|
||||
|
||||
return gf_mulinv(sb);
|
||||
} /* rj_sbox_inv */
|
||||
|
||||
#endif
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
static uint8_t rj_xtime(uint8_t x)
|
||||
{
|
||||
uint8_t y = (uint8_t)(x << 1);
|
||||
return (x & 0x80) ? (y ^ 0x1b) : y;
|
||||
} /* rj_xtime */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
static void aes_subBytes(uint8_t *buf)
|
||||
{
|
||||
register uint8_t i = 16;
|
||||
|
||||
while (i--) buf[i] = rj_sbox(buf[i]);
|
||||
} /* aes_subBytes */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
static void aes_subBytes_inv(uint8_t *buf)
|
||||
{
|
||||
register uint8_t i = 16;
|
||||
|
||||
while (i--) buf[i] = rj_sbox_inv(buf[i]);
|
||||
} /* aes_subBytes_inv */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
static void aes_addRoundKey(uint8_t *buf, uint8_t *key)
|
||||
{
|
||||
register uint8_t i = 16;
|
||||
|
||||
while (i--) buf[i] ^= key[i];
|
||||
} /* aes_addRoundKey */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
static void aes_addRoundKey_cpy(uint8_t *buf, uint8_t *key, uint8_t *cpk)
|
||||
{
|
||||
register uint8_t i = 16;
|
||||
|
||||
while (i--) buf[i] ^= (cpk[i] = key[i]), cpk[16 + i] = key[16 + i];
|
||||
} /* aes_addRoundKey_cpy */
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
static void aes_shiftRows(uint8_t *buf)
|
||||
{
|
||||
register uint8_t i, j; /* to make it potentially parallelable :) */
|
||||
|
||||
i = buf[1], buf[1] = buf[5], buf[5] = buf[9], buf[9] = buf[13], buf[13] = i;
|
||||
i = buf[10], buf[10] = buf[2], buf[2] = i;
|
||||
j = buf[3], buf[3] = buf[15], buf[15] = buf[11], buf[11] = buf[7], buf[7] = j;
|
||||
j = buf[14], buf[14] = buf[6], buf[6] = j;
|
||||
|
||||
} /* aes_shiftRows */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
static void aes_shiftRows_inv(uint8_t *buf)
|
||||
{
|
||||
register uint8_t i, j; /* same as above :) */
|
||||
|
||||
i = buf[1], buf[1] = buf[13], buf[13] = buf[9], buf[9] = buf[5], buf[5] = i;
|
||||
i = buf[2], buf[2] = buf[10], buf[10] = i;
|
||||
j = buf[3], buf[3] = buf[7], buf[7] = buf[11], buf[11] = buf[15], buf[15] = j;
|
||||
j = buf[6], buf[6] = buf[14], buf[14] = j;
|
||||
|
||||
} /* aes_shiftRows_inv */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
static void aes_mixColumns(uint8_t *buf)
|
||||
{
|
||||
register uint8_t i, a, b, c, d, e;
|
||||
|
||||
for (i = 0; i < 16; i += 4)
|
||||
{
|
||||
a = buf[i];
|
||||
b = buf[i + 1];
|
||||
c = buf[i + 2];
|
||||
d = buf[i + 3];
|
||||
e = a ^ b ^ c ^ d;
|
||||
buf[i] ^= e ^ rj_xtime(a ^ b);
|
||||
buf[i + 1] ^= e ^ rj_xtime(b ^ c);
|
||||
buf[i + 2] ^= e ^ rj_xtime(c ^ d);
|
||||
buf[i + 3] ^= e ^ rj_xtime(d ^ a);
|
||||
}
|
||||
} /* aes_mixColumns */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
void aes_mixColumns_inv(uint8_t *buf)
|
||||
{
|
||||
register uint8_t i, a, b, c, d, e, x, y, z;
|
||||
|
||||
for (i = 0; i < 16; i += 4)
|
||||
{
|
||||
a = buf[i];
|
||||
b = buf[i + 1];
|
||||
c = buf[i + 2];
|
||||
d = buf[i + 3];
|
||||
e = a ^ b ^ c ^ d;
|
||||
z = rj_xtime(e);
|
||||
x = e ^ rj_xtime(rj_xtime(z ^ a ^ c));
|
||||
y = e ^ rj_xtime(rj_xtime(z ^ b ^ d));
|
||||
buf[i] ^= x ^ rj_xtime(a ^ b);
|
||||
buf[i + 1] ^= y ^ rj_xtime(b ^ c);
|
||||
buf[i + 2] ^= x ^ rj_xtime(c ^ d);
|
||||
buf[i + 3] ^= y ^ rj_xtime(d ^ a);
|
||||
}
|
||||
} /* aes_mixColumns_inv */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
static void aes_expandEncKey(uint8_t *k, uint8_t *rc)
|
||||
{
|
||||
register uint8_t i;
|
||||
|
||||
k[0] ^= rj_sbox(k[29]) ^ (*rc);
|
||||
k[1] ^= rj_sbox(k[30]);
|
||||
k[2] ^= rj_sbox(k[31]);
|
||||
k[3] ^= rj_sbox(k[28]);
|
||||
*rc = rj_xtime( *rc);
|
||||
|
||||
for(i = 4; i < 16; i += 4) k[i] ^= k[i - 4], k[i + 1] ^= k[i - 3],
|
||||
k[i + 2] ^= k[i - 2], k[i + 3] ^= k[i - 1];
|
||||
k[16] ^= rj_sbox(k[12]);
|
||||
k[17] ^= rj_sbox(k[13]);
|
||||
k[18] ^= rj_sbox(k[14]);
|
||||
k[19] ^= rj_sbox(k[15]);
|
||||
|
||||
for(i = 20; i < 32; i += 4) k[i] ^= k[i - 4], k[i + 1] ^= k[i - 3],
|
||||
k[i + 2] ^= k[i - 2], k[i + 3] ^= k[i - 1];
|
||||
|
||||
} /* aes_expandEncKey */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
void aes_expandDecKey(uint8_t *k, uint8_t *rc)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
for(i = 28; i > 16; i -= 4) k[i + 0] ^= k[i - 4], k[i + 1] ^= k[i - 3],
|
||||
k[i + 2] ^= k[i - 2], k[i + 3] ^= k[i - 1];
|
||||
|
||||
k[16] ^= rj_sbox(k[12]);
|
||||
k[17] ^= rj_sbox(k[13]);
|
||||
k[18] ^= rj_sbox(k[14]);
|
||||
k[19] ^= rj_sbox(k[15]);
|
||||
|
||||
for(i = 12; i > 0; i -= 4) k[i + 0] ^= k[i - 4], k[i + 1] ^= k[i - 3],
|
||||
k[i + 2] ^= k[i - 2], k[i + 3] ^= k[i - 1];
|
||||
|
||||
*rc = FD(*rc);
|
||||
k[0] ^= rj_sbox(k[29]) ^ (*rc);
|
||||
k[1] ^= rj_sbox(k[30]);
|
||||
k[2] ^= rj_sbox(k[31]);
|
||||
k[3] ^= rj_sbox(k[28]);
|
||||
} /* aes_expandDecKey */
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
void aes256_init(aes256_context *ctx, uint8_t *k)
|
||||
{
|
||||
uint8_t rcon = 1;
|
||||
register uint8_t i;
|
||||
|
||||
for (i = 0; i < sizeof(ctx->key); i++) ctx->enckey[i] = ctx->deckey[i] = k[i];
|
||||
for (i = 8; --i;) aes_expandEncKey(ctx->deckey, &rcon);
|
||||
} /* aes256_init */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
void aes256_done(aes256_context *ctx)
|
||||
{
|
||||
register uint8_t i;
|
||||
|
||||
for (i = 0; i < sizeof(ctx->key); i++)
|
||||
ctx->key[i] = ctx->enckey[i] = ctx->deckey[i] = 0;
|
||||
} /* aes256_done */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
void aes256_encrypt_ecb(aes256_context *ctx, uint8_t *buf)
|
||||
{
|
||||
uint8_t i, rcon;
|
||||
|
||||
aes_addRoundKey_cpy(buf, ctx->enckey, ctx->key);
|
||||
for(i = 1, rcon = 1; i < 14; ++i)
|
||||
{
|
||||
aes_subBytes(buf);
|
||||
aes_shiftRows(buf);
|
||||
aes_mixColumns(buf);
|
||||
if( i & 1 ) aes_addRoundKey( buf, &ctx->key[16]);
|
||||
else aes_expandEncKey(ctx->key, &rcon), aes_addRoundKey(buf, ctx->key);
|
||||
}
|
||||
aes_subBytes(buf);
|
||||
aes_shiftRows(buf);
|
||||
aes_expandEncKey(ctx->key, &rcon);
|
||||
aes_addRoundKey(buf, ctx->key);
|
||||
} /* aes256_encrypt */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
void aes256_decrypt_ecb(aes256_context *ctx, uint8_t *buf)
|
||||
{
|
||||
uint8_t i, rcon;
|
||||
|
||||
aes_addRoundKey_cpy(buf, ctx->deckey, ctx->key);
|
||||
aes_shiftRows_inv(buf);
|
||||
aes_subBytes_inv(buf);
|
||||
|
||||
for (i = 14, rcon = 0x80; --i;)
|
||||
{
|
||||
if( ( i & 1 ) )
|
||||
{
|
||||
aes_expandDecKey(ctx->key, &rcon);
|
||||
aes_addRoundKey(buf, &ctx->key[16]);
|
||||
}
|
||||
else aes_addRoundKey(buf, ctx->key);
|
||||
aes_mixColumns_inv(buf);
|
||||
aes_shiftRows_inv(buf);
|
||||
aes_subBytes_inv(buf);
|
||||
}
|
||||
aes_addRoundKey( buf, ctx->key);
|
||||
} /* aes256_decrypt */
|
||||
/*
|
||||
* Byte-oriented AES-256 implementation.
|
||||
* All lookup tables replaced with 'on the fly' calculations.
|
||||
*
|
||||
* Copyright (c) 2007-2009 Ilya O. Levin, http://www.literatecode.com
|
||||
* Other contributors: Hal Finney
|
||||
*
|
||||
* 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" 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.
|
||||
*/
|
||||
#include "aes256.h"
|
||||
|
||||
#define F(x) (((x)<<1) ^ ((((x)>>7) & 1) * 0x1b))
|
||||
#define FD(x) (((x) >> 1) ^ (((x) & 1) ? 0x8d : 0))
|
||||
|
||||
// #define BACK_TO_TABLES
|
||||
#ifdef BACK_TO_TABLES
|
||||
|
||||
const uint8_t sbox[256] = {
|
||||
0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5,
|
||||
0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
|
||||
0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0,
|
||||
0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
|
||||
0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc,
|
||||
0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
|
||||
0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a,
|
||||
0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
|
||||
0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0,
|
||||
0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
|
||||
0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b,
|
||||
0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
|
||||
0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85,
|
||||
0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
|
||||
0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5,
|
||||
0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
|
||||
0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17,
|
||||
0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
|
||||
0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88,
|
||||
0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
|
||||
0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c,
|
||||
0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
|
||||
0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9,
|
||||
0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
|
||||
0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6,
|
||||
0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
|
||||
0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e,
|
||||
0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
|
||||
0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94,
|
||||
0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
|
||||
0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68,
|
||||
0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16
|
||||
};
|
||||
const uint8_t sboxinv[256] = {
|
||||
0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38,
|
||||
0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb,
|
||||
0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87,
|
||||
0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb,
|
||||
0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d,
|
||||
0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e,
|
||||
0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2,
|
||||
0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25,
|
||||
0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16,
|
||||
0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92,
|
||||
0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda,
|
||||
0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84,
|
||||
0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a,
|
||||
0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06,
|
||||
0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02,
|
||||
0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b,
|
||||
0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea,
|
||||
0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73,
|
||||
0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85,
|
||||
0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e,
|
||||
0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89,
|
||||
0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b,
|
||||
0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20,
|
||||
0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4,
|
||||
0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31,
|
||||
0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f,
|
||||
0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d,
|
||||
0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef,
|
||||
0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0,
|
||||
0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61,
|
||||
0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26,
|
||||
0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d
|
||||
};
|
||||
|
||||
#define rj_sbox(x) sbox[(x)]
|
||||
#define rj_sbox_inv(x) sboxinv[(x)]
|
||||
|
||||
#else /* tableless subroutines */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
uint8_t gf_alog(uint8_t x) // calculate anti-logarithm gen 3
|
||||
{
|
||||
uint8_t atb = 1, z;
|
||||
|
||||
while (x--) {z = atb; atb <<= 1; if (z & 0x80) atb^= 0x1b; atb ^= z;}
|
||||
|
||||
return atb;
|
||||
} /* gf_alog */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
uint8_t gf_log(uint8_t x) // calculate logarithm gen 3
|
||||
{
|
||||
uint8_t atb = 1, i = 0, z;
|
||||
|
||||
do {
|
||||
if (atb == x) break;
|
||||
z = atb; atb <<= 1; if (z & 0x80) atb^= 0x1b; atb ^= z;
|
||||
} while (++i > 0);
|
||||
|
||||
return i;
|
||||
} /* gf_log */
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
uint8_t gf_mulinv(uint8_t x) // calculate multiplicative inverse
|
||||
{
|
||||
return (x) ? gf_alog(255 - gf_log(x)) : 0;
|
||||
} /* gf_mulinv */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
uint8_t rj_sbox(uint8_t x)
|
||||
{
|
||||
uint8_t y, sb;
|
||||
|
||||
sb = y = gf_mulinv(x);
|
||||
y = (y<<1)|(y>>7); sb ^= y; y = (y<<1)|(y>>7); sb ^= y;
|
||||
y = (y<<1)|(y>>7); sb ^= y; y = (y<<1)|(y>>7); sb ^= y;
|
||||
|
||||
return (sb ^ 0x63);
|
||||
} /* rj_sbox */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
uint8_t rj_sbox_inv(uint8_t x)
|
||||
{
|
||||
uint8_t y, sb;
|
||||
|
||||
y = x ^ 0x63;
|
||||
sb = y = (y<<1)|(y>>7);
|
||||
y = (y<<2)|(y>>6); sb ^= y; y = (y<<3)|(y>>5); sb ^= y;
|
||||
|
||||
return gf_mulinv(sb);
|
||||
} /* rj_sbox_inv */
|
||||
|
||||
#endif
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
uint8_t rj_xtime(uint8_t x)
|
||||
{
|
||||
return (x & 0x80) ? ((x << 1) ^ 0x1b) : (x << 1);
|
||||
} /* rj_xtime */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
void aes_subBytes(uint8_t *buf)
|
||||
{
|
||||
register uint8_t i = 16;
|
||||
|
||||
while (i--) buf[i] = rj_sbox(buf[i]);
|
||||
} /* aes_subBytes */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
void aes_subBytes_inv(uint8_t *buf)
|
||||
{
|
||||
register uint8_t i = 16;
|
||||
|
||||
while (i--) buf[i] = rj_sbox_inv(buf[i]);
|
||||
} /* aes_subBytes_inv */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
void aes_addRoundKey(uint8_t *buf, uint8_t *key)
|
||||
{
|
||||
register uint8_t i = 16;
|
||||
|
||||
while (i--) buf[i] ^= key[i];
|
||||
} /* aes_addRoundKey */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
void aes_addRoundKey_cpy(uint8_t *buf, uint8_t *key, uint8_t *cpk)
|
||||
{
|
||||
register uint8_t i = 16;
|
||||
|
||||
while (i--) buf[i] ^= (cpk[i] = key[i]), cpk[16+i] = key[16 + i];
|
||||
} /* aes_addRoundKey_cpy */
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
void aes_shiftRows(uint8_t *buf)
|
||||
{
|
||||
register uint8_t i, j; /* to make it potentially parallelable :) */
|
||||
|
||||
i = buf[1]; buf[1] = buf[5]; buf[5] = buf[9]; buf[9] = buf[13]; buf[13] = i;
|
||||
i = buf[10]; buf[10] = buf[2]; buf[2] = i;
|
||||
j = buf[3]; buf[3] = buf[15]; buf[15] = buf[11]; buf[11] = buf[7]; buf[7] = j;
|
||||
j = buf[14]; buf[14] = buf[6]; buf[6] = j;
|
||||
|
||||
} /* aes_shiftRows */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
void aes_shiftRows_inv(uint8_t *buf)
|
||||
{
|
||||
register uint8_t i, j; /* same as above :) */
|
||||
|
||||
i = buf[1]; buf[1] = buf[13]; buf[13] = buf[9]; buf[9] = buf[5]; buf[5] = i;
|
||||
i = buf[2]; buf[2] = buf[10]; buf[10] = i;
|
||||
j = buf[3]; buf[3] = buf[7]; buf[7] = buf[11]; buf[11] = buf[15]; buf[15] = j;
|
||||
j = buf[6]; buf[6] = buf[14]; buf[14] = j;
|
||||
|
||||
} /* aes_shiftRows_inv */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
void aes_mixColumns(uint8_t *buf)
|
||||
{
|
||||
register uint8_t i, a, b, c, d, e;
|
||||
|
||||
for (i = 0; i < 16; i += 4)
|
||||
{
|
||||
a = buf[i]; b = buf[i + 1]; c = buf[i + 2]; d = buf[i + 3];
|
||||
e = a ^ b ^ c ^ d;
|
||||
buf[i] ^= e ^ rj_xtime(a^b); buf[i+1] ^= e ^ rj_xtime(b^c);
|
||||
buf[i+2] ^= e ^ rj_xtime(c^d); buf[i+3] ^= e ^ rj_xtime(d^a);
|
||||
}
|
||||
} /* aes_mixColumns */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
void aes_mixColumns_inv(uint8_t *buf)
|
||||
{
|
||||
register uint8_t i, a, b, c, d, e, x, y, z;
|
||||
|
||||
for (i = 0; i < 16; i += 4)
|
||||
{
|
||||
a = buf[i]; b = buf[i + 1]; c = buf[i + 2]; d = buf[i + 3];
|
||||
e = a ^ b ^ c ^ d;
|
||||
z = rj_xtime(e);
|
||||
x = e ^ rj_xtime(rj_xtime(z^a^c)); y = e ^ rj_xtime(rj_xtime(z^b^d));
|
||||
buf[i] ^= x ^ rj_xtime(a^b); buf[i+1] ^= y ^ rj_xtime(b^c);
|
||||
buf[i+2] ^= x ^ rj_xtime(c^d); buf[i+3] ^= y ^ rj_xtime(d^a);
|
||||
}
|
||||
} /* aes_mixColumns_inv */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
void aes_expandEncKey(uint8_t *k, uint8_t *rc)
|
||||
{
|
||||
register uint8_t i;
|
||||
|
||||
k[0] ^= rj_sbox(k[29]) ^ (*rc);
|
||||
k[1] ^= rj_sbox(k[30]);
|
||||
k[2] ^= rj_sbox(k[31]);
|
||||
k[3] ^= rj_sbox(k[28]);
|
||||
*rc = F( *rc);
|
||||
|
||||
for(i = 4; i < 16; i += 4) k[i] ^= k[i-4], k[i+1] ^= k[i-3],
|
||||
k[i+2] ^= k[i-2], k[i+3] ^= k[i-1];
|
||||
k[16] ^= rj_sbox(k[12]);
|
||||
k[17] ^= rj_sbox(k[13]);
|
||||
k[18] ^= rj_sbox(k[14]);
|
||||
k[19] ^= rj_sbox(k[15]);
|
||||
|
||||
for(i = 20; i < 32; i += 4) k[i] ^= k[i-4], k[i+1] ^= k[i-3],
|
||||
k[i+2] ^= k[i-2], k[i+3] ^= k[i-1];
|
||||
|
||||
} /* aes_expandEncKey */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
void aes_expandDecKey(uint8_t *k, uint8_t *rc)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
for(i = 28; i > 16; i -= 4) k[i+0] ^= k[i-4], k[i+1] ^= k[i-3],
|
||||
k[i+2] ^= k[i-2], k[i+3] ^= k[i-1];
|
||||
|
||||
k[16] ^= rj_sbox(k[12]);
|
||||
k[17] ^= rj_sbox(k[13]);
|
||||
k[18] ^= rj_sbox(k[14]);
|
||||
k[19] ^= rj_sbox(k[15]);
|
||||
|
||||
for(i = 12; i > 0; i -= 4) k[i+0] ^= k[i-4], k[i+1] ^= k[i-3],
|
||||
k[i+2] ^= k[i-2], k[i+3] ^= k[i-1];
|
||||
|
||||
*rc = FD(*rc);
|
||||
k[0] ^= rj_sbox(k[29]) ^ (*rc);
|
||||
k[1] ^= rj_sbox(k[30]);
|
||||
k[2] ^= rj_sbox(k[31]);
|
||||
k[3] ^= rj_sbox(k[28]);
|
||||
} /* aes_expandDecKey */
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
void aes256_init(aes256_context *ctx, uint8_t *k)
|
||||
{
|
||||
uint8_t rcon = 1;
|
||||
register uint8_t i;
|
||||
|
||||
for (i = 0; i < sizeof(ctx->key); i++) ctx->enckey[i] = ctx->deckey[i] = k[i];
|
||||
for (i = 8;--i;) aes_expandEncKey(ctx->deckey, &rcon);
|
||||
} /* aes256_init */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
void aes256_done(aes256_context *ctx)
|
||||
{
|
||||
register uint8_t i;
|
||||
|
||||
for (i = 0; i < sizeof(ctx->key); i++)
|
||||
ctx->key[i] = ctx->enckey[i] = ctx->deckey[i] = 0;
|
||||
} /* aes256_done */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
void aes256_encrypt_ecb(aes256_context *ctx, uint8_t *buf)
|
||||
{
|
||||
uint8_t i, rcon;
|
||||
|
||||
aes_addRoundKey_cpy(buf, ctx->enckey, ctx->key);
|
||||
for(i = 1, rcon = 1; i < 14; ++i)
|
||||
{
|
||||
aes_subBytes(buf);
|
||||
aes_shiftRows(buf);
|
||||
aes_mixColumns(buf);
|
||||
if( i & 1 ) aes_addRoundKey( buf, &ctx->key[16]);
|
||||
else aes_expandEncKey(ctx->key, &rcon), aes_addRoundKey(buf, ctx->key);
|
||||
}
|
||||
aes_subBytes(buf);
|
||||
aes_shiftRows(buf);
|
||||
aes_expandEncKey(ctx->key, &rcon);
|
||||
aes_addRoundKey(buf, ctx->key);
|
||||
} /* aes256_encrypt */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
void aes256_decrypt_ecb(aes256_context *ctx, uint8_t *buf)
|
||||
{
|
||||
uint8_t i, rcon;
|
||||
|
||||
aes_addRoundKey_cpy(buf, ctx->deckey, ctx->key);
|
||||
aes_shiftRows_inv(buf);
|
||||
aes_subBytes_inv(buf);
|
||||
|
||||
for (i = 14, rcon = 0x80; --i;)
|
||||
{
|
||||
if( ( i & 1 ) )
|
||||
{
|
||||
aes_expandDecKey(ctx->key, &rcon);
|
||||
aes_addRoundKey(buf, &ctx->key[16]);
|
||||
}
|
||||
else aes_addRoundKey(buf, ctx->key);
|
||||
aes_mixColumns_inv(buf);
|
||||
aes_shiftRows_inv(buf);
|
||||
aes_subBytes_inv(buf);
|
||||
}
|
||||
aes_addRoundKey( buf, ctx->key);
|
||||
} /* aes256_decrypt */
|
||||
|
||||
@ -1,46 +1,46 @@
|
||||
/*
|
||||
* Byte-oriented AES-256 implementation.
|
||||
* All lookup tables replaced with 'on the fly' calculations.
|
||||
*
|
||||
* Copyright (c) 2007-2009 Ilya O. Levin, http://www.literatecode.com
|
||||
* Other contributors: Hal Finney
|
||||
*
|
||||
* 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" 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.
|
||||
*/
|
||||
|
||||
#ifndef AES_256_H
|
||||
#define AES_256_H
|
||||
|
||||
#include "typedefs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
uint8_t key[32];
|
||||
uint8_t enckey[32];
|
||||
uint8_t deckey[32];
|
||||
} aes256_context;
|
||||
|
||||
|
||||
void aes256_init(aes256_context *, uint8_t * /* key */);
|
||||
void aes256_done(aes256_context *);
|
||||
void aes256_encrypt_ecb(aes256_context *, uint8_t * /* plaintext */);
|
||||
void aes256_decrypt_ecb(aes256_context *, uint8_t * /* cipertext */);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/*
|
||||
* Byte-oriented AES-256 implementation.
|
||||
* All lookup tables replaced with 'on the fly' calculations.
|
||||
*
|
||||
* Copyright (c) 2007-2009 Ilya O. Levin, http://www.literatecode.com
|
||||
* Other contributors: Hal Finney
|
||||
*
|
||||
* 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" 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.
|
||||
*/
|
||||
|
||||
#ifndef AES_256_H
|
||||
#define AES_256_H
|
||||
|
||||
#include "typedefs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
uint8_t key[32];
|
||||
uint8_t enckey[32];
|
||||
uint8_t deckey[32];
|
||||
} aes256_context;
|
||||
|
||||
|
||||
void aes256_init(aes256_context *, uint8_t * /* key */);
|
||||
void aes256_done(aes256_context *);
|
||||
void aes256_encrypt_ecb(aes256_context *, uint8_t * /* plaintext */);
|
||||
void aes256_decrypt_ecb(aes256_context *, uint8_t * /* cipertext */);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
@ -26,12 +26,12 @@
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
#include "zlib.h"
|
||||
#include "os/copymem.h"
|
||||
#include "compression.h"
|
||||
|
||||
#include "fastlz.h"
|
||||
#include "zlib.h"
|
||||
#include "zip_io.h"
|
||||
#include "os/copymem.h"
|
||||
|
||||
int Compression::compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size,Mode p_mode) {
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
@ -29,7 +29,6 @@
|
||||
#include "config_file.h"
|
||||
#include "os/keyboard.h"
|
||||
#include "os/file_access.h"
|
||||
#include "variant_parser.h"
|
||||
|
||||
StringArray ConfigFile::_get_sections() const {
|
||||
|
||||
@ -84,10 +83,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 {
|
||||
Variant ConfigFile::get_value(const String& p_section, const String& p_key) const{
|
||||
|
||||
ERR_FAIL_COND_V(!values.has(p_section),p_default);
|
||||
ERR_FAIL_COND_V(!values[p_section].has(p_key),p_default);
|
||||
ERR_FAIL_COND_V(!values.has(p_section),Variant());
|
||||
ERR_FAIL_COND_V(!values[p_section].has(p_key),Variant());
|
||||
return values[p_section][p_key];
|
||||
|
||||
}
|
||||
@ -119,6 +118,151 @@ void ConfigFile::get_section_keys(const String& p_section,List<String> *r_keys)
|
||||
|
||||
}
|
||||
|
||||
static String _encode_variant(const Variant& p_variant) {
|
||||
|
||||
switch(p_variant.get_type()) {
|
||||
|
||||
case Variant::BOOL: {
|
||||
bool val = p_variant;
|
||||
return (val?"true":"false");
|
||||
} break;
|
||||
case Variant::INT: {
|
||||
int val = p_variant;
|
||||
return itos(val);
|
||||
} break;
|
||||
case Variant::REAL: {
|
||||
float val = p_variant;
|
||||
return rtos(val)+(val==int(val)?".0":"");
|
||||
} break;
|
||||
case Variant::STRING: {
|
||||
String val = p_variant;
|
||||
return "\""+val.xml_escape()+"\"";
|
||||
} break;
|
||||
case Variant::COLOR: {
|
||||
|
||||
Color val = p_variant;
|
||||
return "#"+val.to_html();
|
||||
} break;
|
||||
case Variant::STRING_ARRAY:
|
||||
case Variant::INT_ARRAY:
|
||||
case Variant::REAL_ARRAY:
|
||||
case Variant::ARRAY: {
|
||||
Array arr = p_variant;
|
||||
String str="[";
|
||||
for(int i=0;i<arr.size();i++) {
|
||||
|
||||
if (i>0)
|
||||
str+=", ";
|
||||
str+=_encode_variant(arr[i]);
|
||||
}
|
||||
str+="]";
|
||||
return str;
|
||||
} break;
|
||||
case Variant::DICTIONARY: {
|
||||
Dictionary d = p_variant;
|
||||
String str="{";
|
||||
List<Variant> keys;
|
||||
d.get_key_list(&keys);
|
||||
for(List<Variant>::Element *E=keys.front();E;E=E->next()) {
|
||||
|
||||
if (E!=keys.front())
|
||||
str+=", ";
|
||||
str+=_encode_variant(E->get());
|
||||
str+=":";
|
||||
str+=_encode_variant(d[E->get()]);
|
||||
|
||||
}
|
||||
str+="}";
|
||||
return str;
|
||||
} break;
|
||||
case Variant::IMAGE: {
|
||||
String str="img(";
|
||||
|
||||
Image img=p_variant;
|
||||
if (!img.empty()) {
|
||||
|
||||
String format;
|
||||
switch(img.get_format()) {
|
||||
|
||||
case Image::FORMAT_GRAYSCALE: format="grayscale"; break;
|
||||
case Image::FORMAT_INTENSITY: format="intensity"; break;
|
||||
case Image::FORMAT_GRAYSCALE_ALPHA: format="grayscale_alpha"; break;
|
||||
case Image::FORMAT_RGB: format="rgb"; break;
|
||||
case Image::FORMAT_RGBA: format="rgba"; break;
|
||||
case Image::FORMAT_INDEXED : format="indexed"; break;
|
||||
case Image::FORMAT_INDEXED_ALPHA: format="indexed_alpha"; break;
|
||||
case Image::FORMAT_BC1: format="bc1"; break;
|
||||
case Image::FORMAT_BC2: format="bc2"; break;
|
||||
case Image::FORMAT_BC3: format="bc3"; break;
|
||||
case Image::FORMAT_BC4: format="bc4"; break;
|
||||
case Image::FORMAT_BC5: format="bc5"; break;
|
||||
case Image::FORMAT_CUSTOM: format="custom custom_size="+itos(img.get_data().size())+""; break;
|
||||
default: {}
|
||||
}
|
||||
|
||||
str+=format+", ";
|
||||
str+=itos(img.get_mipmaps())+", ";
|
||||
str+=itos(img.get_width())+", ";
|
||||
str+=itos(img.get_height())+", ";
|
||||
DVector<uint8_t> data = img.get_data();
|
||||
int ds=data.size();
|
||||
DVector<uint8_t>::Read r = data.read();
|
||||
for(int i=0;i<ds;i++) {
|
||||
uint8_t byte = r[i];
|
||||
const char hex[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
|
||||
char bstr[3]={ hex[byte>>4], hex[byte&0xF], 0};
|
||||
str+=bstr;
|
||||
}
|
||||
}
|
||||
str+=")";
|
||||
return str;
|
||||
} break;
|
||||
case Variant::INPUT_EVENT: {
|
||||
|
||||
InputEvent ev = p_variant;
|
||||
|
||||
switch(ev.type) {
|
||||
|
||||
case InputEvent::KEY: {
|
||||
|
||||
String mods;
|
||||
if (ev.key.mod.control)
|
||||
mods+="C";
|
||||
if (ev.key.mod.shift)
|
||||
mods+="S";
|
||||
if (ev.key.mod.alt)
|
||||
mods+="A";
|
||||
if (ev.key.mod.meta)
|
||||
mods+="M";
|
||||
if (mods!="")
|
||||
mods=", "+mods;
|
||||
|
||||
return "key("+keycode_get_string(ev.key.scancode)+mods+")";
|
||||
} break;
|
||||
case InputEvent::MOUSE_BUTTON: {
|
||||
|
||||
return "mbutton("+itos(ev.device)+", "+itos(ev.mouse_button.button_index)+")";
|
||||
} break;
|
||||
case InputEvent::JOYSTICK_BUTTON: {
|
||||
|
||||
return "jbutton("+itos(ev.device)+", "+itos(ev.joy_button.button_index)+")";
|
||||
} break;
|
||||
case InputEvent::JOYSTICK_MOTION: {
|
||||
|
||||
return "jaxis("+itos(ev.device)+", "+itos(ev.joy_motion.axis)+")";
|
||||
} break;
|
||||
default: {
|
||||
|
||||
return "nil";
|
||||
} break;
|
||||
|
||||
}
|
||||
} break;
|
||||
default: {}
|
||||
}
|
||||
|
||||
return "nil"; //don't know wha to do with this
|
||||
}
|
||||
|
||||
|
||||
Error ConfigFile::save(const String& p_path){
|
||||
@ -127,8 +271,6 @@ Error ConfigFile::save(const String& p_path){
|
||||
FileAccess *file = FileAccess::open(p_path,FileAccess::WRITE,&err);
|
||||
|
||||
if (err) {
|
||||
if (file)
|
||||
memdelete(file);
|
||||
return err;
|
||||
}
|
||||
|
||||
@ -141,9 +283,7 @@ Error ConfigFile::save(const String& p_path){
|
||||
|
||||
for(Map<String, Variant>::Element *F=E->get().front();F;F=F->next()) {
|
||||
|
||||
String vstr;
|
||||
VariantWriter::write_to_string(F->get(),vstr);
|
||||
file->store_string(F->key()+"="+vstr+"\n");
|
||||
file->store_string(F->key()+"="+_encode_variant(F->get())+"\n");
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,49 +292,432 @@ Error ConfigFile::save(const String& p_path){
|
||||
return OK;
|
||||
}
|
||||
|
||||
static Vector<String> _decode_params(const String& p_string) {
|
||||
|
||||
int begin=p_string.find("(");
|
||||
ERR_FAIL_COND_V(begin==-1,Vector<String>());
|
||||
begin++;
|
||||
int end=p_string.find(")");
|
||||
ERR_FAIL_COND_V(end<begin,Vector<String>());
|
||||
return p_string.substr(begin,end-begin).split(",");
|
||||
}
|
||||
|
||||
static String _get_chunk(const String& str,int &pos, int close_pos) {
|
||||
|
||||
|
||||
enum {
|
||||
MIN_COMMA,
|
||||
MIN_COLON,
|
||||
MIN_CLOSE,
|
||||
MIN_QUOTE,
|
||||
MIN_PARENTHESIS,
|
||||
MIN_CURLY_OPEN,
|
||||
MIN_OPEN
|
||||
};
|
||||
|
||||
int min_pos=close_pos;
|
||||
int min_what=MIN_CLOSE;
|
||||
|
||||
#define TEST_MIN(m_how,m_what) \
|
||||
{\
|
||||
int res = str.find(m_how,pos);\
|
||||
if (res!=-1 && res < min_pos) {\
|
||||
min_pos=res;\
|
||||
min_what=m_what;\
|
||||
}\
|
||||
}\
|
||||
|
||||
|
||||
TEST_MIN(",",MIN_COMMA);
|
||||
TEST_MIN("[",MIN_OPEN);
|
||||
TEST_MIN("{",MIN_CURLY_OPEN);
|
||||
TEST_MIN("(",MIN_PARENTHESIS);
|
||||
TEST_MIN("\"",MIN_QUOTE);
|
||||
|
||||
int end=min_pos;
|
||||
|
||||
|
||||
switch(min_what) {
|
||||
|
||||
case MIN_COMMA: {
|
||||
} break;
|
||||
case MIN_CLOSE: {
|
||||
//end because it's done
|
||||
} break;
|
||||
case MIN_QUOTE: {
|
||||
end=str.find("\"",min_pos+1)+1;
|
||||
ERR_FAIL_COND_V(end==-1,Variant());
|
||||
|
||||
} break;
|
||||
case MIN_PARENTHESIS: {
|
||||
|
||||
end=str.find(")",min_pos+1)+1;
|
||||
ERR_FAIL_COND_V(end==-1,Variant());
|
||||
|
||||
} break;
|
||||
case MIN_OPEN: {
|
||||
int level=1;
|
||||
end++;
|
||||
while(end<close_pos) {
|
||||
|
||||
if (str[end]=='[')
|
||||
level++;
|
||||
if (str[end]==']') {
|
||||
level--;
|
||||
if (level==0)
|
||||
break;
|
||||
}
|
||||
end++;
|
||||
}
|
||||
ERR_FAIL_COND_V(level!=0,Variant());
|
||||
end++;
|
||||
} break;
|
||||
case MIN_CURLY_OPEN: {
|
||||
int level=1;
|
||||
end++;
|
||||
while(end<close_pos) {
|
||||
|
||||
if (str[end]=='{')
|
||||
level++;
|
||||
if (str[end]=='}') {
|
||||
level--;
|
||||
if (level==0)
|
||||
break;
|
||||
}
|
||||
end++;
|
||||
}
|
||||
ERR_FAIL_COND_V(level!=0,Variant());
|
||||
end++;
|
||||
} break;
|
||||
|
||||
}
|
||||
|
||||
String ret = str.substr(pos,end-pos);
|
||||
|
||||
pos=end;
|
||||
while(pos<close_pos) {
|
||||
if (str[pos]!=',' && str[pos]!=' ' && str[pos]!=':')
|
||||
break;
|
||||
pos++;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
|
||||
static Variant _decode_variant(const String& p_string) {
|
||||
|
||||
|
||||
String str = p_string.strip_edges();
|
||||
|
||||
if (str.nocasecmp_to("true")==0)
|
||||
return Variant(true);
|
||||
if (str.nocasecmp_to("false")==0)
|
||||
return Variant(false);
|
||||
if (str.nocasecmp_to("nil")==0)
|
||||
return Variant();
|
||||
if (str.is_valid_float()) {
|
||||
if (str.find(".")==-1)
|
||||
return str.to_int();
|
||||
else
|
||||
return str.to_double();
|
||||
|
||||
}
|
||||
if (str.begins_with("#")) { //string
|
||||
return Color::html(str);
|
||||
}
|
||||
if (str.begins_with("\"")) { //string
|
||||
int end = str.find_last("\"");
|
||||
ERR_FAIL_COND_V(end==0,Variant());
|
||||
return str.substr(1,end-1).xml_unescape();
|
||||
|
||||
}
|
||||
|
||||
if (str.begins_with("[")) { //array
|
||||
|
||||
int close_pos = str.find_last("]");
|
||||
ERR_FAIL_COND_V(close_pos==-1,Variant());
|
||||
Array array;
|
||||
|
||||
int pos=1;
|
||||
|
||||
while(pos<close_pos) {
|
||||
|
||||
String s = _get_chunk(str,pos,close_pos);
|
||||
array.push_back(_decode_variant(s));
|
||||
}
|
||||
return array;
|
||||
|
||||
}
|
||||
|
||||
if (str.begins_with("{")) { //array
|
||||
|
||||
int close_pos = str.find_last("}");
|
||||
ERR_FAIL_COND_V(close_pos==-1,Variant());
|
||||
Dictionary d;
|
||||
|
||||
int pos=1;
|
||||
|
||||
while(pos<close_pos) {
|
||||
|
||||
String key = _get_chunk(str,pos,close_pos);
|
||||
String data = _get_chunk(str,pos,close_pos);
|
||||
d[_decode_variant(key)]=_decode_variant(data);
|
||||
}
|
||||
return d;
|
||||
|
||||
}
|
||||
if (str.begins_with("key")) {
|
||||
Vector<String> params = _decode_params(p_string);
|
||||
ERR_FAIL_COND_V(params.size()!=1 && params.size()!=2,Variant());
|
||||
int scode=0;
|
||||
|
||||
if (params[0].is_numeric()) {
|
||||
scode=params[0].to_int();
|
||||
if (scode < 10) {
|
||||
scode=KEY_0+scode;
|
||||
}
|
||||
} else
|
||||
scode=find_keycode(params[0]);
|
||||
|
||||
InputEvent ie;
|
||||
ie.type=InputEvent::KEY;
|
||||
ie.key.scancode=scode;
|
||||
|
||||
if (params.size()==2) {
|
||||
String mods=params[1];
|
||||
if (mods.findn("C")!=-1)
|
||||
ie.key.mod.control=true;
|
||||
if (mods.findn("A")!=-1)
|
||||
ie.key.mod.alt=true;
|
||||
if (mods.findn("S")!=-1)
|
||||
ie.key.mod.shift=true;
|
||||
if (mods.findn("M")!=-1)
|
||||
ie.key.mod.meta=true;
|
||||
}
|
||||
return ie;
|
||||
|
||||
}
|
||||
|
||||
if (str.begins_with("mbutton")) {
|
||||
Vector<String> params = _decode_params(p_string);
|
||||
ERR_FAIL_COND_V(params.size()!=2,Variant());
|
||||
|
||||
InputEvent ie;
|
||||
ie.type=InputEvent::MOUSE_BUTTON;
|
||||
ie.device=params[0].to_int();
|
||||
ie.mouse_button.button_index=params[1].to_int();
|
||||
|
||||
return ie;
|
||||
}
|
||||
|
||||
if (str.begins_with("jbutton")) {
|
||||
Vector<String> params = _decode_params(p_string);
|
||||
ERR_FAIL_COND_V(params.size()!=2,Variant());
|
||||
|
||||
InputEvent ie;
|
||||
ie.type=InputEvent::JOYSTICK_BUTTON;
|
||||
ie.device=params[0].to_int();
|
||||
ie.joy_button.button_index=params[1].to_int();
|
||||
|
||||
return ie;
|
||||
}
|
||||
|
||||
if (str.begins_with("jaxis")) {
|
||||
Vector<String> params = _decode_params(p_string);
|
||||
ERR_FAIL_COND_V(params.size()!=2,Variant());
|
||||
|
||||
InputEvent ie;
|
||||
ie.type=InputEvent::JOYSTICK_MOTION;
|
||||
ie.device=params[0].to_int();
|
||||
ie.joy_motion.axis=params[1].to_int();
|
||||
|
||||
return ie;
|
||||
}
|
||||
if (str.begins_with("img")) {
|
||||
Vector<String> params = _decode_params(p_string);
|
||||
if (params.size()==0) {
|
||||
return Image();
|
||||
}
|
||||
|
||||
ERR_FAIL_COND_V(params.size()!=5,Image());
|
||||
|
||||
String format=params[0].strip_edges();
|
||||
|
||||
Image::Format imgformat;
|
||||
|
||||
if (format=="grayscale") {
|
||||
imgformat=Image::FORMAT_GRAYSCALE;
|
||||
} else if (format=="intensity") {
|
||||
imgformat=Image::FORMAT_INTENSITY;
|
||||
} else if (format=="grayscale_alpha") {
|
||||
imgformat=Image::FORMAT_GRAYSCALE_ALPHA;
|
||||
} else if (format=="rgb") {
|
||||
imgformat=Image::FORMAT_RGB;
|
||||
} else if (format=="rgba") {
|
||||
imgformat=Image::FORMAT_RGBA;
|
||||
} else if (format=="indexed") {
|
||||
imgformat=Image::FORMAT_INDEXED;
|
||||
} else if (format=="indexed_alpha") {
|
||||
imgformat=Image::FORMAT_INDEXED_ALPHA;
|
||||
} else if (format=="bc1") {
|
||||
imgformat=Image::FORMAT_BC1;
|
||||
} else if (format=="bc2") {
|
||||
imgformat=Image::FORMAT_BC2;
|
||||
} else if (format=="bc3") {
|
||||
imgformat=Image::FORMAT_BC3;
|
||||
} else if (format=="bc4") {
|
||||
imgformat=Image::FORMAT_BC4;
|
||||
} else if (format=="bc5") {
|
||||
imgformat=Image::FORMAT_BC5;
|
||||
} else if (format=="custom") {
|
||||
imgformat=Image::FORMAT_CUSTOM;
|
||||
} else {
|
||||
|
||||
ERR_FAIL_V( Image() );
|
||||
}
|
||||
|
||||
int mipmaps=params[1].to_int();
|
||||
int w=params[2].to_int();
|
||||
int h=params[3].to_int();
|
||||
|
||||
if (w == 0 && h == 0) {
|
||||
//r_v = Image(w, h, imgformat);
|
||||
return Image();
|
||||
};
|
||||
|
||||
|
||||
String data=params[4];
|
||||
int datasize=data.length()/2;
|
||||
DVector<uint8_t> pixels;
|
||||
pixels.resize(datasize);
|
||||
DVector<uint8_t>::Write wb = pixels.write();
|
||||
const CharType *cptr=data.c_str();
|
||||
|
||||
int idx=0;
|
||||
uint8_t byte;
|
||||
while( idx<datasize*2) {
|
||||
|
||||
CharType c=*(cptr++);
|
||||
|
||||
ERR_FAIL_COND_V(c=='<',ERR_FILE_CORRUPT);
|
||||
|
||||
if ( (c>='0' && c<='9') || (c>='A' && c<='F') || (c>='a' && c<='f') ) {
|
||||
|
||||
if (idx&1) {
|
||||
|
||||
byte|=HEX2CHR(c);
|
||||
wb[idx>>1]=byte;
|
||||
} else {
|
||||
|
||||
byte=HEX2CHR(c)<<4;
|
||||
}
|
||||
|
||||
idx++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
wb = DVector<uint8_t>::Write();
|
||||
|
||||
return Image(w,h,mipmaps,imgformat,pixels);
|
||||
}
|
||||
|
||||
if (str.find(",")!=-1) { //vector2 or vector3
|
||||
Vector<float> farr = str.split_floats(",",true);
|
||||
if (farr.size()==2) {
|
||||
return Point2(farr[0],farr[1]);
|
||||
}
|
||||
if (farr.size()==3) {
|
||||
return Vector3(farr[0],farr[1],farr[2]);
|
||||
}
|
||||
ERR_FAIL_V(Variant());
|
||||
}
|
||||
|
||||
|
||||
return Variant();
|
||||
}
|
||||
|
||||
Error ConfigFile::load(const String& p_path) {
|
||||
|
||||
Error err;
|
||||
FileAccess *f= FileAccess::open(p_path,FileAccess::READ,&err);
|
||||
|
||||
if (!f)
|
||||
return ERR_CANT_OPEN;
|
||||
if (err!=OK) {
|
||||
|
||||
VariantParser::StreamFile stream;
|
||||
stream.f=f;
|
||||
return err;
|
||||
}
|
||||
|
||||
String assign;
|
||||
Variant value;
|
||||
VariantParser::Tag next_tag;
|
||||
|
||||
int lines=0;
|
||||
String error_text;
|
||||
|
||||
String line;
|
||||
String section;
|
||||
String subpath;
|
||||
|
||||
while(true) {
|
||||
int line_count = 0;
|
||||
|
||||
assign=Variant();
|
||||
next_tag.fields.clear();
|
||||
next_tag.name=String();
|
||||
while(!f->eof_reached()) {
|
||||
|
||||
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_PRINTS("ConfgFile::load - "+p_path+":"+itos(lines)+" error: "+error_text);
|
||||
memdelete(f);
|
||||
return err;
|
||||
String line = f->get_line().strip_edges();
|
||||
line_count++;
|
||||
|
||||
if (line=="")
|
||||
continue;
|
||||
|
||||
// find comments
|
||||
|
||||
{
|
||||
|
||||
int pos=0;
|
||||
while (true) {
|
||||
int ret = line.find(";",pos);
|
||||
if (ret==-1)
|
||||
break;
|
||||
|
||||
int qc=0;
|
||||
for(int i=0;i<ret;i++) {
|
||||
|
||||
if (line[i]=='"')
|
||||
qc++;
|
||||
}
|
||||
|
||||
if ( !(qc&1) ) {
|
||||
//not inside string, real comment
|
||||
line=line.substr(0,ret);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
pos=ret+1;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (assign!=String()) {
|
||||
set_value(section,assign,value);
|
||||
} else if (next_tag.name!=String()) {
|
||||
section=next_tag.name;
|
||||
}
|
||||
if (line.begins_with("[")) {
|
||||
|
||||
int end = line.find_last("]");
|
||||
ERR_CONTINUE(end!=line.length()-1);
|
||||
|
||||
section=line.substr(1,line.length()-2);
|
||||
|
||||
} else if (line.find("=")!=-1) {
|
||||
|
||||
|
||||
int eqpos = line.find("=");
|
||||
String var=line.substr(0,eqpos).strip_edges();
|
||||
String value=line.substr(eqpos+1,line.length()).strip_edges();
|
||||
|
||||
Variant val = _decode_variant(value);
|
||||
|
||||
set_value(section,var,val);
|
||||
|
||||
} else {
|
||||
|
||||
if (line.length() > 0) {
|
||||
ERR_PRINT(String("Syntax error on line "+itos(line_count)+" of file "+p_path).ascii().get_data());
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
memdelete(f);
|
||||
@ -207,13 +730,13 @@ Error ConfigFile::load(const String& p_path) {
|
||||
void ConfigFile::_bind_methods(){
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_value","section","key","value"),&ConfigFile::set_value);
|
||||
ObjectTypeDB::bind_method(_MD("get_value","section","key","default"),&ConfigFile::get_value,DEFVAL(Variant()));
|
||||
ObjectTypeDB::bind_method(_MD("get_value","section","key"),&ConfigFile::get_value);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("has_section","section"),&ConfigFile::has_section);
|
||||
ObjectTypeDB::bind_method(_MD("has_section_key","section","key"),&ConfigFile::has_section_key);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("get_sections"),&ConfigFile::_get_sections);
|
||||
ObjectTypeDB::bind_method(_MD("get_section_keys","section"),&ConfigFile::_get_section_keys);
|
||||
ObjectTypeDB::bind_method(_MD("get_section_keys"),&ConfigFile::_get_section_keys);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("load:Error","path"),&ConfigFile::load);
|
||||
ObjectTypeDB::bind_method(_MD("save:Error","path"),&ConfigFile::save);
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
@ -46,7 +46,7 @@ protected:
|
||||
public:
|
||||
|
||||
void set_value(const String& p_section, const String& p_key, const Variant& p_value);
|
||||
Variant get_value(const String& p_section, const String& p_key, Variant p_default=Variant()) const;
|
||||
Variant get_value(const String& p_section, const String& p_key) const;
|
||||
|
||||
bool has_section(const String& p_section) const;
|
||||
bool has_section_key(const String& p_section,const String& p_key) const;
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
|
||||
@ -5,12 +5,10 @@
|
||||
#include "print_string.h"
|
||||
#define COMP_MAGIC 0x43454447
|
||||
|
||||
#include "core/variant.h"
|
||||
#include <stdio.h>
|
||||
|
||||
Error FileAccessEncrypted::open_and_parse(FileAccess *p_base,const Vector<uint8_t>& p_key,Mode p_mode) {
|
||||
|
||||
//print_line("open and parse!");
|
||||
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);
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
@ -74,14 +74,6 @@ bool FileAccessMemory::file_exists(const String& p_name) {
|
||||
}
|
||||
|
||||
|
||||
Error FileAccessMemory::open_custom(const uint8_t* p_data, int p_len) {
|
||||
|
||||
data=(uint8_t*)p_data;
|
||||
length=p_len;
|
||||
pos=0;
|
||||
return OK;
|
||||
}
|
||||
|
||||
Error FileAccessMemory::_open(const String& p_path, int p_mode_flags) {
|
||||
|
||||
ERR_FAIL_COND_V(!files, ERR_FILE_NOT_FOUND);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user