summaryrefslogtreecommitdiff
path: root/core/io
diff options
context:
space:
mode:
Diffstat (limited to 'core/io')
-rw-r--r--core/io/LICENSE-InfoZip.txt60
-rw-r--r--core/io/LICENSE-MiniZip.txt32
-rw-r--r--core/io/compression.cpp23
-rw-r--r--core/io/compression.h2
-rw-r--r--core/io/file_access_encrypted.cpp28
-rw-r--r--core/io/file_access_encrypted.h28
-rw-r--r--core/io/file_access_memory.cpp6
-rw-r--r--core/io/http_client.cpp3
-rw-r--r--core/io/http_client.h3
-rw-r--r--core/io/image_loader.cpp3
-rw-r--r--core/io/ioapi.c2
-rw-r--r--core/io/ioapi.h2
-rw-r--r--core/io/marshalls.cpp3
-rw-r--r--core/io/networked_multiplayer_peer.cpp41
-rw-r--r--core/io/networked_multiplayer_peer.h54
-rw-r--r--core/io/packet_peer.cpp2
-rw-r--r--core/io/packet_peer_udp.cpp28
-rw-r--r--core/io/packet_peer_udp.h28
-rw-r--r--core/io/resource_format_binary.cpp45
-rw-r--r--core/io/resource_format_xml.cpp6
-rw-r--r--core/io/resource_loader.cpp19
-rw-r--r--core/io/resource_loader.h2
-rw-r--r--core/io/resource_saver.cpp14
-rw-r--r--core/io/resource_saver.h2
-rw-r--r--core/io/sha-README.md5
-rw-r--r--core/io/sha256.c245
-rw-r--r--core/io/sha256.h50
-rw-r--r--core/io/stream_peer.cpp145
-rw-r--r--core/io/stream_peer.h36
-rw-r--r--core/io/stream_peer_ssl.cpp28
-rw-r--r--core/io/stream_peer_ssl.h28
-rw-r--r--core/io/translation_loader_po.cpp3
-rw-r--r--core/io/unzip.c19
-rw-r--r--core/io/unzip.h2
-rw-r--r--core/io/zip.c2
-rw-r--r--core/io/zip.h2
-rw-r--r--core/io/zip_io.h7
37 files changed, 929 insertions, 79 deletions
diff --git a/core/io/LICENSE-InfoZip.txt b/core/io/LICENSE-InfoZip.txt
new file mode 100644
index 0000000000..bcfe47e978
--- /dev/null
+++ b/core/io/LICENSE-InfoZip.txt
@@ -0,0 +1,60 @@
+This is version 2007-Mar-4 of the Info-ZIP license.
+The definitive version of this document should be available at
+ftp://ftp.info-zip.org/pub/infozip/license.html indefinitely and
+a copy at http://www.info-zip.org/pub/infozip/license.html.
+
+
+Copyright (c) 1990-2007 Info-ZIP. All rights reserved.
+
+For the purposes of this copyright and license, "Info-ZIP" is defined as
+the following set of individuals:
+
+ Mark Adler, John Bush, Karl Davis, Harald Denker, Jean-Michel Dubois,
+ Jean-loup Gailly, Hunter Goatley, Ed Gordon, Ian Gorman, Chris Herborth,
+ Dirk Haase, Greg Hartwig, Robert Heath, Jonathan Hudson, Paul Kienitz,
+ David Kirschbaum, Johnny Lee, Onno van der Linden, Igor Mandrichenko,
+ Steve P. Miller, Sergio Monesi, Keith Owens, George Petrov, Greg Roelofs,
+ Kai Uwe Rommel, Steve Salisbury, Dave Smith, Steven M. Schweda,
+ Christian Spieler, Cosmin Truta, Antoine Verheijen, Paul von Behren,
+ Rich Wales, Mike White.
+
+This software is provided "as is," without warranty of any kind, express
+or implied. In no event shall Info-ZIP or its contributors be held liable
+for any direct, indirect, incidental, special or consequential damages
+arising out of the use of or inability to use this software.
+
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely, subject to the above disclaimer and the following restrictions:
+
+ 1. Redistributions of source code (in whole or in part) must retain
+ the above copyright notice, definition, disclaimer, and this list
+ of conditions.
+
+ 2. Redistributions in binary form (compiled executables and libraries)
+ must reproduce the above copyright notice, definition, disclaimer,
+ and this list of conditions in documentation and/or other materials
+ provided with the distribution. The sole exception to this condition
+ is redistribution of a standard UnZipSFX binary (including SFXWiz) as
+ part of a self-extracting archive; that is permitted without inclusion
+ of this license, as long as the normal SFX banner has not been removed
+ from the binary or disabled.
+
+ 3. Altered versions--including, but not limited to, ports to new operating
+ systems, existing ports with new graphical interfaces, versions with
+ modified or added functionality, and dynamic, shared, or static library
+ versions not from Info-ZIP--must be plainly marked as such and must not
+ be misrepresented as being the original source or, if binaries,
+ compiled from the original source. Such altered versions also must not
+ be misrepresented as being Info-ZIP releases--including, but not
+ limited to, labeling of the altered versions with the names "Info-ZIP"
+ (or any variation thereof, including, but not limited to, different
+ capitalizations), "Pocket UnZip," "WiZ" or "MacZip" without the
+ explicit permission of Info-ZIP. Such altered versions are further
+ prohibited from misrepresentative use of the Zip-Bugs or Info-ZIP
+ e-mail addresses or the Info-ZIP URL(s), such as to imply Info-ZIP
+ will provide support for the altered versions.
+
+ 4. Info-ZIP retains the right to use the names "Info-ZIP," "Zip," "UnZip,"
+ "UnZipSFX," "WiZ," "Pocket UnZip," "Pocket Zip," and "MacZip" for its
+ own source and binary releases.
diff --git a/core/io/LICENSE-MiniZip.txt b/core/io/LICENSE-MiniZip.txt
new file mode 100644
index 0000000000..0e8950f86f
--- /dev/null
+++ b/core/io/LICENSE-MiniZip.txt
@@ -0,0 +1,32 @@
+Credits
+
+ Gilles Vollant - Original MiniZip author
+ Even Rouault - ZIP64 unzip Support
+ Daniel Borca - BZip Compression method support in unzip
+ Mathias Svensson - ZIP64 zip support
+ Mathias Svensson - BZip Compression method support in zip
+
+ This version has been modified for Godot Engine
+
+
+License
+----------------------------------------------------------------------------
+ Condition of use and distribution are the same than zlib :
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+
+----------------------------------------------------------------------------
diff --git a/core/io/compression.cpp b/core/io/compression.cpp
index a17e358cbb..ca44d24911 100644
--- a/core/io/compression.cpp
+++ b/core/io/compression.cpp
@@ -60,6 +60,10 @@ int Compression::compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size,M
strm.avail_in=p_src_size;
int aout = deflateBound(&strm,p_src_size);;
+ /*if (aout>p_src_size) {
+ deflateEnd(&strm);
+ return -1;
+ }*/
strm.avail_out=aout;
strm.next_in=(Bytef*)p_src;
strm.next_out=p_dst;
@@ -107,19 +111,21 @@ int Compression::get_max_compressed_buffer_size(int p_src_size,Mode p_mode){
-void Compression::decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *p_src, int p_src_size,Mode p_mode){
+int Compression::decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *p_src, int p_src_size,Mode p_mode){
switch(p_mode) {
case MODE_FASTLZ: {
+ int ret_size=0;
+
if (p_dst_max_size<16) {
uint8_t dst[16];
- fastlz_decompress(p_src,p_src_size,dst,16);
+ ret_size = fastlz_decompress(p_src,p_src_size,dst,16);
copymem(p_dst,dst,p_dst_max_size);
} else {
- fastlz_decompress(p_src,p_src_size,p_dst,p_dst_max_size);
+ ret_size = fastlz_decompress(p_src,p_src_size,p_dst,p_dst_max_size);
}
- return;
+ return ret_size;
} break;
case MODE_DEFLATE: {
@@ -130,7 +136,7 @@ void Compression::decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *
strm.avail_in= 0;
strm.next_in=Z_NULL;
int err = inflateInit(&strm);
- ERR_FAIL_COND(err!=Z_OK);
+ ERR_FAIL_COND_V(err!=Z_OK,-1);
strm.avail_in=p_src_size;
strm.avail_out=p_dst_max_size;
@@ -138,11 +144,12 @@ void Compression::decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *
strm.next_out=p_dst;
err = inflate(&strm,Z_FINISH);
+ int total = strm.total_out;
inflateEnd(&strm);
- ERR_FAIL_COND(err!=Z_STREAM_END);
- return;
+ ERR_FAIL_COND_V(err!=Z_STREAM_END,-1);
+ return total;
} break;
}
- ERR_FAIL();
+ ERR_FAIL_V(-1);
}
diff --git a/core/io/compression.h b/core/io/compression.h
index 07a293c940..e0a4d31a51 100644
--- a/core/io/compression.h
+++ b/core/io/compression.h
@@ -43,7 +43,7 @@ public:
static int compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size,Mode p_mode=MODE_FASTLZ);
static int get_max_compressed_buffer_size(int p_src_size,Mode p_mode=MODE_FASTLZ);
- static void decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *p_src, int p_src_size,Mode p_mode=MODE_FASTLZ);
+ static int decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *p_src, int p_src_size,Mode p_mode=MODE_FASTLZ);
Compression();
};
diff --git a/core/io/file_access_encrypted.cpp b/core/io/file_access_encrypted.cpp
index 65b1ca5207..4d4b4d8ee7 100644
--- a/core/io/file_access_encrypted.cpp
+++ b/core/io/file_access_encrypted.cpp
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* file_access_encrypted.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* 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 */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
#include "file_access_encrypted.h"
#include "aes256.h"
#include "md5.h"
diff --git a/core/io/file_access_encrypted.h b/core/io/file_access_encrypted.h
index 3bdcc2dfd0..34926faadf 100644
--- a/core/io/file_access_encrypted.h
+++ b/core/io/file_access_encrypted.h
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* file_access_encrypted.h */
+/*************************************************************************/
+/* This file is part of: */
+/* 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 */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
#ifndef FILE_ACCESS_ENCRYPTED_H
#define FILE_ACCESS_ENCRYPTED_H
diff --git a/core/io/file_access_memory.cpp b/core/io/file_access_memory.cpp
index 7db3499505..11a425001e 100644
--- a/core/io/file_access_memory.cpp
+++ b/core/io/file_access_memory.cpp
@@ -46,7 +46,7 @@ void FileAccessMemory::register_file(String p_name, Vector<uint8_t> p_data) {
name = Globals::get_singleton()->globalize_path(p_name);
else
name = p_name;
- name = DirAccess::normalize_path(name);
+ //name = DirAccess::normalize_path(name);
(*files)[name] = p_data;
}
@@ -68,7 +68,7 @@ FileAccess* FileAccessMemory::create() {
bool FileAccessMemory::file_exists(const String& p_name) {
String name = fix_path(p_name);
- name = DirAccess::normalize_path(name);
+// name = DirAccess::normalize_path(name);
return files && (files->find(name) != NULL);
}
@@ -87,7 +87,7 @@ Error FileAccessMemory::_open(const String& p_path, int p_mode_flags) {
ERR_FAIL_COND_V(!files, ERR_FILE_NOT_FOUND);
String name = fix_path(p_path);
- name = DirAccess::normalize_path(name);
+// name = DirAccess::normalize_path(name);
Map<String, Vector<uint8_t> >::Element* E = files->find(name);
ERR_FAIL_COND_V(!E, ERR_FILE_NOT_FOUND);
diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp
index 3520680118..2a831dd992 100644
--- a/core/io/http_client.cpp
+++ b/core/io/http_client.cpp
@@ -29,8 +29,6 @@
#include "http_client.h"
#include "io/stream_peer_ssl.h"
-VARIANT_ENUM_CAST(HTTPClient::Status);
-
Error HTTPClient::connect(const String &p_host, int p_port, bool p_ssl,bool p_verify_host){
@@ -76,6 +74,7 @@ void HTTPClient::set_connection(const Ref<StreamPeer>& p_connection){
close();
connection=p_connection;
+ status=STATUS_CONNECTED;
}
diff --git a/core/io/http_client.h b/core/io/http_client.h
index a9cfb1ed73..32d2e72101 100644
--- a/core/io/http_client.h
+++ b/core/io/http_client.h
@@ -40,7 +40,7 @@ class HTTPClient : public Reference {
OBJ_TYPE(HTTPClient,Reference);
public:
- enum RespondeCode {
+ enum ResponseCode {
// 1xx informational
RESPONSE_CONTINUE = 100,
@@ -201,5 +201,6 @@ public:
};
VARIANT_ENUM_CAST(HTTPClient::Method);
+VARIANT_ENUM_CAST(HTTPClient::Status);
#endif // HTTP_CLIENT_H
diff --git a/core/io/image_loader.cpp b/core/io/image_loader.cpp
index 05bad97e90..ac6c00dc61 100644
--- a/core/io/image_loader.cpp
+++ b/core/io/image_loader.cpp
@@ -51,7 +51,7 @@ Error ImageLoader::load_image(String p_file,Image *p_image, FileAccess *p_custom
Error err;
f=FileAccess::open(p_file,FileAccess::READ,&err);
if (!f) {
- print_line("ERROR OPENING FILE: "+p_file);
+ ERR_PRINTS("Error opening file: "+p_file);
return err;
}
}
@@ -76,7 +76,6 @@ Error ImageLoader::load_image(String p_file,Image *p_image, FileAccess *p_custom
}
- print_line("NO LOADER?");
if (!p_custom)
memdelete(f);
diff --git a/core/io/ioapi.c b/core/io/ioapi.c
index 8818199f0b..d6063a5fe6 100644
--- a/core/io/ioapi.c
+++ b/core/io/ioapi.c
@@ -6,7 +6,7 @@
Modifications for Zip64 support
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
- For more info read MiniZip_info.txt
+ For more info read LICENSE-MiniZip.txt
*/
diff --git a/core/io/ioapi.h b/core/io/ioapi.h
index 24bf612617..cb6cb7e766 100644
--- a/core/io/ioapi.h
+++ b/core/io/ioapi.h
@@ -5,7 +5,7 @@
Modifications for Zip64 support
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
- For more info read MiniZip_info.txt
+ For more info read LICENSE-MiniZip.txt
Changes
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp
index 60617e1237..c9bd38c654 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -685,7 +685,6 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int *
if (count) {
varray.resize(count);
DVector<Vector2>::Write w = varray.write();
- const float *r = (const float*)buf;
for(int i=0;i<(int)count;i++) {
@@ -724,7 +723,6 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int *
if (count) {
varray.resize(count);
DVector<Vector3>::Write w = varray.write();
- const float *r = (const float*)buf;
for(int i=0;i<(int)count;i++) {
@@ -764,7 +762,6 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int *
if (count) {
carray.resize(count);
DVector<Color>::Write w = carray.write();
- const float *r = (const float*)buf;
for(int i=0;i<(int)count;i++) {
diff --git a/core/io/networked_multiplayer_peer.cpp b/core/io/networked_multiplayer_peer.cpp
new file mode 100644
index 0000000000..47e5f3729c
--- /dev/null
+++ b/core/io/networked_multiplayer_peer.cpp
@@ -0,0 +1,41 @@
+#include "networked_multiplayer_peer.h"
+
+
+void NetworkedMultiplayerPeer::_bind_methods() {
+
+ ObjectTypeDB::bind_method(_MD("set_transfer_mode","mode"), &NetworkedMultiplayerPeer::set_transfer_mode );
+ ObjectTypeDB::bind_method(_MD("set_target_peer","id"), &NetworkedMultiplayerPeer::set_target_peer );
+
+ ObjectTypeDB::bind_method(_MD("get_packet_peer"), &NetworkedMultiplayerPeer::get_packet_peer );
+
+ ObjectTypeDB::bind_method(_MD("poll"), &NetworkedMultiplayerPeer::poll );
+
+ ObjectTypeDB::bind_method(_MD("get_connection_status"), &NetworkedMultiplayerPeer::get_connection_status );
+ ObjectTypeDB::bind_method(_MD("get_unique_id"), &NetworkedMultiplayerPeer::get_unique_id );
+
+ ObjectTypeDB::bind_method(_MD("set_refuse_new_connections","enable"), &NetworkedMultiplayerPeer::set_refuse_new_connections );
+ ObjectTypeDB::bind_method(_MD("is_refusing_new_connections"), &NetworkedMultiplayerPeer::is_refusing_new_connections );
+
+ BIND_CONSTANT( TRANSFER_MODE_UNRELIABLE );
+ BIND_CONSTANT( TRANSFER_MODE_UNRELIABLE_ORDERED );
+ BIND_CONSTANT( TRANSFER_MODE_RELIABLE );
+
+ BIND_CONSTANT( CONNECTION_DISCONNECTED );
+ BIND_CONSTANT( CONNECTION_CONNECTING );
+ BIND_CONSTANT( CONNECTION_CONNECTED );
+
+ BIND_CONSTANT( TARGET_PEER_BROADCAST );
+ BIND_CONSTANT( TARGET_PEER_SERVER );
+
+
+ ADD_SIGNAL( MethodInfo("peer_connected",PropertyInfo(Variant::INT,"id")));
+ ADD_SIGNAL( MethodInfo("peer_disconnected",PropertyInfo(Variant::INT,"id")));
+ ADD_SIGNAL( MethodInfo("server_disconnected"));
+ ADD_SIGNAL( MethodInfo("connection_succeeded") );
+ ADD_SIGNAL( MethodInfo("connection_failed") );
+}
+
+NetworkedMultiplayerPeer::NetworkedMultiplayerPeer() {
+
+
+}
diff --git a/core/io/networked_multiplayer_peer.h b/core/io/networked_multiplayer_peer.h
new file mode 100644
index 0000000000..485200a9a9
--- /dev/null
+++ b/core/io/networked_multiplayer_peer.h
@@ -0,0 +1,54 @@
+#ifndef NETWORKED_MULTIPLAYER_PEER_H
+#define NETWORKED_MULTIPLAYER_PEER_H
+
+#include "io/packet_peer.h"
+
+class NetworkedMultiplayerPeer : public PacketPeer {
+
+ OBJ_TYPE(NetworkedMultiplayerPeer,PacketPeer);
+
+protected:
+ static void _bind_methods();
+public:
+
+ enum {
+ TARGET_PEER_BROADCAST=0,
+ TARGET_PEER_SERVER=1
+ };
+ enum TransferMode {
+ TRANSFER_MODE_UNRELIABLE,
+ TRANSFER_MODE_UNRELIABLE_ORDERED,
+ TRANSFER_MODE_RELIABLE,
+ };
+
+ enum ConnectionStatus {
+ CONNECTION_DISCONNECTED,
+ CONNECTION_CONNECTING,
+ CONNECTION_CONNECTED,
+ };
+
+
+ virtual void set_transfer_mode(TransferMode p_mode)=0;
+ virtual void set_target_peer(int p_peer_id)=0;
+
+ virtual int get_packet_peer() const=0;
+
+ virtual bool is_server() const=0;
+
+ virtual void poll()=0;
+
+ virtual int get_unique_id() const=0;
+
+ virtual void set_refuse_new_connections(bool p_enable)=0;
+ virtual bool is_refusing_new_connections() const=0;
+
+
+ virtual ConnectionStatus get_connection_status() const=0;
+
+ NetworkedMultiplayerPeer();
+};
+
+VARIANT_ENUM_CAST( NetworkedMultiplayerPeer::TransferMode )
+VARIANT_ENUM_CAST( NetworkedMultiplayerPeer::ConnectionStatus )
+
+#endif // NetworkedMultiplayerPeer_H
diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp
index 22b8bc0b39..8e96697ac9 100644
--- a/core/io/packet_peer.cpp
+++ b/core/io/packet_peer.cpp
@@ -126,7 +126,7 @@ Error PacketPeer::_get_packet_error() const {
void PacketPeer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("get_var"),&PacketPeer::_bnd_get_var);
+ ObjectTypeDB::bind_method(_MD("get_var:Variant"),&PacketPeer::_bnd_get_var);
ObjectTypeDB::bind_method(_MD("put_var", "var:Variant"),&PacketPeer::put_var);
ObjectTypeDB::bind_method(_MD("get_packet"),&PacketPeer::_get_packet);
ObjectTypeDB::bind_method(_MD("put_packet:Error", "buffer"),&PacketPeer::_put_packet);
diff --git a/core/io/packet_peer_udp.cpp b/core/io/packet_peer_udp.cpp
index 83217ffc41..efc619e414 100644
--- a/core/io/packet_peer_udp.cpp
+++ b/core/io/packet_peer_udp.cpp
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* packet_peer_udp.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* 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 */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
#include "packet_peer_udp.h"
#include "io/ip.h"
diff --git a/core/io/packet_peer_udp.h b/core/io/packet_peer_udp.h
index 73ff487b19..70d92834fc 100644
--- a/core/io/packet_peer_udp.h
+++ b/core/io/packet_peer_udp.h
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* packet_peer_udp.h */
+/*************************************************************************/
+/* This file is part of: */
+/* 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 */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
#ifndef PACKET_PEER_UDP_H
#define PACKET_PEER_UDP_H
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index 58f3a4df2b..0544fd6ba8 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -447,13 +447,17 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) {
} break;
case VARIANT_INPUT_EVENT: {
+ InputEvent ev;
+ ev.type=f->get_32(); //will only work for null though.
+ r_v=ev;
+
} break;
case VARIANT_DICTIONARY: {
- uint32_t len=f->get_32();
- Dictionary d(len&0x80000000); //last bit means shared
- len&=0x7FFFFFFF;
- for(uint32_t i=0;i<len;i++) {
+ uint32_t len=f->get_32();
+ Dictionary d(len&0x80000000); //last bit means shared
+ len&=0x7FFFFFFF;
+ for(uint32_t i=0;i<len;i++) {
Variant key;
Error err = parse_variant(key);
ERR_FAIL_COND_V(err,ERR_FILE_CORRUPT);
@@ -466,11 +470,11 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) {
} break;
case VARIANT_ARRAY: {
- uint32_t len=f->get_32();
- Array a(len&0x80000000); //last bit means shared
- len&=0x7FFFFFFF;
+ uint32_t len=f->get_32();
+ Array a(len&0x80000000); //last bit means shared
+ len&=0x7FFFFFFF;
a.resize(len);
- for(uint32_t i=0;i<len;i++) {
+ for(uint32_t i=0;i<len;i++) {
Variant val;
Error err = parse_variant(val);
ERR_FAIL_COND_V(err,ERR_FILE_CORRUPT);
@@ -1105,14 +1109,9 @@ void ResourceFormatLoaderBinary::get_recognized_extensions_for_type(const String
for(List<String>::Element *E=extensions.front();E;E=E->next()) {
String ext = E->get().to_lower();
- if (ext=="res")
- continue;
-// p_extensions->push_back("x"+ext);
p_extensions->push_back(ext);
}
- p_extensions->push_back("res");
-
}
void ResourceFormatLoaderBinary::get_recognized_extensions(List<String> *p_extensions) const{
@@ -1122,12 +1121,9 @@ void ResourceFormatLoaderBinary::get_recognized_extensions(List<String> *p_exten
for(List<String>::Element *E=extensions.front();E;E=E->next()) {
String ext = E->get().to_lower();
- if (ext=="res")
- continue;
p_extensions->push_back(ext);
}
- p_extensions->push_back("res");
}
bool ResourceFormatLoaderBinary::handles_type(const String& p_type) const{
@@ -1733,7 +1729,9 @@ void ResourceFormatSaverBinaryInstance::write_variant(const Variant& p_property,
case Variant::INPUT_EVENT: {
f->store_32(VARIANT_INPUT_EVENT);
- WARN_PRINT("Can't save InputEvent (maybe it could..)");
+ InputEvent event=p_property;
+ f->store_32(0); //event type none, nothing else suported for now.
+
} break;
case Variant::DICTIONARY: {
@@ -2177,6 +2175,9 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path,const RES& p_
if (takeover_paths) {
r->set_path(p_path+"::"+itos(r->get_subindex()),true);
}
+#ifdef TOOLS_ENABLED
+ r->set_edited(false);
+#endif
} else {
save_unicode_string(r->get_path()); //actual external
}
@@ -2270,16 +2271,8 @@ bool ResourceFormatSaverBinary::recognize(const RES& p_resource) const {
void ResourceFormatSaverBinary::get_recognized_extensions(const RES& p_resource,List<String> *p_extensions) const {
-
- //here comes the sun, lalalala
String base = p_resource->get_base_extension().to_lower();
- if (base!="res") {
-
- p_extensions->push_back(base);
- }
-
- p_extensions->push_back("res");
-
+ p_extensions->push_back(base);
}
diff --git a/core/io/resource_format_xml.cpp b/core/io/resource_format_xml.cpp
index a42a922baf..44fbaf02ac 100644
--- a/core/io/resource_format_xml.cpp
+++ b/core/io/resource_format_xml.cpp
@@ -1862,8 +1862,6 @@ void ResourceInteractiveLoaderXML::open(FileAccess *p_f) {
}
int major = version.get_slicec('.',0).to_int();
- int minor = version.get_slicec('.',1).to_int();
-
if (major>VERSION_MAJOR) {
error=ERR_FILE_UNRECOGNIZED;
@@ -2802,6 +2800,10 @@ Error ResourceFormatSaverXMLInstance::save(const String &p_path,const RES& p_res
if (takeover_paths) {
res->set_path(p_path+"::"+itos(idx),true);
}
+#ifdef TOOLS_ENABLED
+ res->set_edited(false);
+#endif
+
}
write_string("\n",false);
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index b547dc0e85..08b4139047 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -319,7 +319,11 @@ Ref<ResourceInteractiveLoader> ResourceLoader::load_interactive(const String &p_
if (OS::get_singleton()->is_stdout_verbose())
print_line("load resource: "+local_path+" (cached)");
- return RES( ResourceCache::get(local_path ) );
+ Ref<Resource> res_cached = ResourceCache::get(local_path);
+ Ref<ResourceInteractiveLoaderDefault> ril = Ref<ResourceInteractiveLoaderDefault>(memnew(ResourceInteractiveLoaderDefault));
+
+ ril->resource = res_cached;
+ return ril;
}
if (OS::get_singleton()->is_stdout_verbose())
@@ -356,10 +360,18 @@ Ref<ResourceInteractiveLoader> ResourceLoader::load_interactive(const String &p_
}
-void ResourceLoader::add_resource_format_loader(ResourceFormatLoader *p_format_loader) {
+void ResourceLoader::add_resource_format_loader(ResourceFormatLoader *p_format_loader, bool p_at_front) {
ERR_FAIL_COND( loader_count >= MAX_LOADERS );
- loader[loader_count++]=p_format_loader;
+ if (p_at_front) {
+ for(int i=loader_count;i>0;i--) {
+ loader[i]=loader[i-1];
+ }
+ loader[0]=p_format_loader;
+ loader_count++;
+ } else {
+ loader[loader_count++]=p_format_loader;
+ }
}
void ResourceLoader::get_dependencies(const String& p_path, List<String> *p_dependencies, bool p_add_types) {
@@ -439,7 +451,6 @@ String ResourceLoader::get_resource_type(const String &p_path) {
String remapped_path = PathRemap::get_singleton()->get_remap(local_path);
String extension=remapped_path.extension();
- bool found=false;
for (int i=0;i<loader_count;i++) {
String result = loader[i]->get_resource_type(local_path);
diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h
index 6404e6cb13..f976a43d91 100644
--- a/core/io/resource_loader.h
+++ b/core/io/resource_loader.h
@@ -102,7 +102,7 @@ public:
static Ref<ResourceImportMetadata> load_import_metadata(const String &p_path);
static void get_recognized_extensions_for_type(const String& p_type,List<String> *p_extensions);
- static void add_resource_format_loader(ResourceFormatLoader *p_format_loader);
+ static void add_resource_format_loader(ResourceFormatLoader *p_format_loader,bool p_at_front=false);
static String get_resource_type(const String &p_path);
static void get_dependencies(const String& p_path,List<String> *p_dependencies,bool p_add_types=false);
static Error rename_dependencies(const String &p_path,const Map<String,String>& p_map);
diff --git a/core/io/resource_saver.cpp b/core/io/resource_saver.cpp
index 8d78ecabbf..2ead405440 100644
--- a/core/io/resource_saver.cpp
+++ b/core/io/resource_saver.cpp
@@ -116,10 +116,20 @@ void ResourceSaver::get_recognized_extensions(const RES& p_resource,List<String>
}
-void ResourceSaver::add_resource_format_saver(ResourceFormatSaver *p_format_saver) {
+void ResourceSaver::add_resource_format_saver(ResourceFormatSaver *p_format_saver, bool p_at_front) {
ERR_FAIL_COND( saver_count >= MAX_SAVERS );
- saver[saver_count++]=p_format_saver;
+
+ if (p_at_front) {
+ for(int i=saver_count;i>0;i--) {
+ saver[i]=saver[i-1];
+ }
+ saver[0]=p_format_saver;
+ saver_count++;
+ } else {
+ saver[saver_count++]=p_format_saver;
+ }
+
}
diff --git a/core/io/resource_saver.h b/core/io/resource_saver.h
index 97500c46f4..b05ae23afc 100644
--- a/core/io/resource_saver.h
+++ b/core/io/resource_saver.h
@@ -80,7 +80,7 @@ public:
static Error save(const String &p_path,const RES& p_resource,uint32_t p_flags=0);
static void get_recognized_extensions(const RES& p_resource,List<String> *p_extensions);
- static void add_resource_format_saver(ResourceFormatSaver *p_format_saver);
+ static void add_resource_format_saver(ResourceFormatSaver *p_format_saver,bool p_at_front=false);
static void set_timestamp_on_save(bool p_timestamp) { timestamp_on_save=p_timestamp; }
static void set_save_callback(ResourceSavedCallback p_callback);
diff --git a/core/io/sha-README.md b/core/io/sha-README.md
new file mode 100644
index 0000000000..27a73cffe7
--- /dev/null
+++ b/core/io/sha-README.md
@@ -0,0 +1,5 @@
+SHA256
+======
+
+SHA-256 implementation to compliment a portable byte-oriented AES-256
+implementation in C at http://www.literatecode.com/aes256
diff --git a/core/io/sha256.c b/core/io/sha256.c
new file mode 100644
index 0000000000..68a4339af9
--- /dev/null
+++ b/core/io/sha256.c
@@ -0,0 +1,245 @@
+/*
+* SHA-256 implementation.
+*
+* Copyright (c) 2010 Ilya O. Levin, http://www.literatecode.com
+*
+* 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.
+*/
+#define SWAP_BYTES
+// #define USE_STD_MEMCPY
+// #define SELF_TEST
+
+#ifdef USE_STD_MEMCPY
+#include <string.h>
+#endif
+#include "sha256.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define RL(x,n) (((x) << n) | ((x) >> (32 - n)))
+#define RR(x,n) (((x) >> n) | ((x) << (32 - n)))
+
+#define S0(x) (RR((x), 2) ^ RR((x),13) ^ RR((x),22))
+#define S1(x) (RR((x), 6) ^ RR((x),11) ^ RR((x),25))
+#define G0(x) (RR((x), 7) ^ RR((x),18) ^ ((x) >> 3))
+#define G1(x) (RR((x),17) ^ RR((x),19) ^ ((x) >> 10))
+
+#ifdef SWAP_BYTES
+#define BSWP(x,y) _bswapw((uint32_t *)(x), (uint32_t)(y))
+#else
+#define BSWP(p,n)
+#endif
+#ifdef USE_STD_MEMCPY
+#define MEMCP(x,y,z) memcpy((x),(y),(z))
+#else
+#define MEMCP(x,y,z) _memcp((x),(y),(z))
+#endif
+
+#ifndef __cdecl
+#define __cdecl
+#endif
+
+static const uint32_t K[64] = {
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
+ 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
+ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
+ 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
+ 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
+ 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
+ 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
+ 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
+ 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
+ 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
+};
+
+/* -------------------------------------------------------------------------- */
+static void _bswapw(uint32_t *p, uint32_t i)
+{
+ while (i--) p[i] = (RR(p[i],24) & 0x00ff00ff) | (RR(p[i],8) & 0xff00ff00);
+
+} /* _bswapw */
+
+/* -------------------------------------------------------------------------- */
+#ifndef USE_STD_MEMCPY
+void * __cdecl _memcp (void *d, const void *s, uint32_t sz)
+{
+ void *rv = d;
+
+ while (sz--) *(char *)d = *(char *)s, d = (char *)d + 1, s = (char *)s + 1;
+
+ return(rv);
+} /* _memcp */
+#endif
+
+/* -------------------------------------------------------------------------- */
+static void _rtrf(uint32_t *b, uint32_t *p, uint32_t i, uint32_t j)
+{
+ #define B(x, y) b[(x-y) & 7]
+ #define P(x, y) p[(x+y) & 15]
+
+ B(7,i) += (j ? (p[i & 15] += G1(P(i,14)) + P(i,9) + G0(P(i,1))) : p[i & 15])
+ + K[i+j] + S1(B(4,i))
+ + (B(6,i) ^ (B(4,i) & (B(5,i) ^ B(6,i))));
+ B(3,i) += B(7,i);
+ B(7,i) += S0(B(0,i)) + ( (B(0,i) & B(1,i)) | (B(2,i) & (B(0,i) ^ B(1,i))) );
+
+ #undef P
+ #undef B
+} /* _rtrf */
+
+/* -------------------------------------------------------------------------- */
+static void _hash(sha256_context *ctx)
+{
+ uint32_t b[8], *p, j;
+
+ b[0] = ctx->hash[0]; b[1] = ctx->hash[1]; b[2] = ctx->hash[2];
+ b[3] = ctx->hash[3]; b[4] = ctx->hash[4]; b[5] = ctx->hash[5];
+ b[6] = ctx->hash[6]; b[7] = ctx->hash[7];
+
+ for (p = ctx->buf, j = 0; j < 64; j += 16)
+ _rtrf(b, p, 0, j), _rtrf(b, p, 1, j), _rtrf(b, p, 2, j),
+ _rtrf(b, p, 3, j), _rtrf(b, p, 4, j), _rtrf(b, p, 5, j),
+ _rtrf(b, p, 6, j), _rtrf(b, p, 7, j), _rtrf(b, p, 8, j),
+ _rtrf(b, p, 9, j), _rtrf(b, p, 10, j), _rtrf(b, p, 11, j),
+ _rtrf(b, p, 12, j), _rtrf(b, p, 13, j), _rtrf(b, p, 14, j),
+ _rtrf(b, p, 15, j);
+
+ ctx->hash[0] += b[0]; ctx->hash[1] += b[1]; ctx->hash[2] += b[2];
+ ctx->hash[3] += b[3]; ctx->hash[4] += b[4]; ctx->hash[5] += b[5];
+ ctx->hash[6] += b[6]; ctx->hash[7] += b[7];
+
+} /* _hash */
+
+/* -------------------------------------------------------------------------- */
+void sha256_init(sha256_context ctx[1])
+{
+ ctx->len[0] = ctx->len[1] = 0;
+ ctx->hash[0] = 0x6a09e667; ctx->hash[1] = 0xbb67ae85;
+ ctx->hash[2] = 0x3c6ef372; ctx->hash[3] = 0xa54ff53a;
+ ctx->hash[4] = 0x510e527f; ctx->hash[5] = 0x9b05688c;
+ ctx->hash[6] = 0x1f83d9ab; ctx->hash[7] = 0x5be0cd19;
+
+} /* sha256_init */
+
+/* -------------------------------------------------------------------------- */
+void sha256_hash(sha256_context *ctx, uint8_t *dat, uint32_t sz)
+{
+ register uint32_t i = ctx->len[0] & 63, l, j;
+
+ if ((ctx->len[0] += sz) < sz) ++(ctx->len[1]);
+
+ for (j = 0, l = 64-i; sz >= l; j += l, sz -= l, l = 64, i = 0)
+ {
+ MEMCP(&ctx->buf[i], &dat[j], l);
+ BSWP(ctx->buf, 16 );
+ _hash(ctx);
+ }
+ MEMCP(&ctx->buf[i], &dat[j], sz);
+
+} /* _hash */
+
+/* -------------------------------------------------------------------------- */
+void sha256_done(sha256_context *ctx, uint8_t *buf)
+{
+ uint32_t i = (uint32_t)(ctx->len[0] & 63), j = ((~i) & 3) << 3;
+
+ BSWP(ctx->buf, (i + 3) >> 2);
+
+ ctx->buf[i >> 2] &= 0xffffff80 << j; /* add padding */
+ ctx->buf[i >> 2] |= 0x00000080 << j;
+
+ if (i < 56) i = (i >> 2) + 1;
+ else ctx->buf[15] ^= (i < 60) ? ctx->buf[15] : 0, _hash(ctx), i = 0;
+
+ while (i < 14) ctx->buf[i++] = 0;
+
+ ctx->buf[14] = (ctx->len[1] << 3)|(ctx->len[0] >> 29); /* add length */
+ ctx->buf[15] = ctx->len[0] << 3;
+
+ _hash(ctx);
+
+ for (i = 0; i < 32; i++)
+ ctx->buf[i % 16] = 0, /* may remove this line in case of a DIY cleanup */
+ buf[i] = (uint8_t)(ctx->hash[i >> 2] >> ((~i & 3) << 3));
+
+} /* sha256_done */
+
+
+#ifdef SELF_TEST
+#pragma warning (push, 0)
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#pragma warning(pop)
+
+char *buf[] = {
+ "",
+ "e3b0c442 98fc1c14 9afbf4c8 996fb924 27ae41e4 649b934c a495991b 7852b855",
+
+ "abc",
+ "ba7816bf 8f01cfea 414140de 5dae2223 b00361a3 96177a9c b410ff61 f20015ad",
+
+ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+ "248d6a61 d20638b8 e5c02693 0c3e6039 a33ce459 64ff2167 f6ecedd4 19db06c1",
+
+ "The quick brown fox jumps over the lazy dog",
+ "d7a8fbb3 07d78094 69ca9abc b0082e4f 8d5651e4 6d3cdb76 2d02d0bf 37c9e592",
+
+ "The quick brown fox jumps over the lazy cog", /* avalanche effect test */
+ "e4c4d8f3 bf76b692 de791a17 3e053211 50f7a345 b46484fe 427f6acc 7ecc81be",
+
+ "bhn5bjmoniertqea40wro2upyflkydsibsk8ylkmgbvwi420t44cq034eou1szc1k0mk46oeb7ktzmlxqkbte2sy",
+ "9085df2f 02e0cc45 5928d0f5 1b27b4bf 1d9cd260 a66ed1fd a11b0a3f f5756d99"
+};
+
+int main(int argc, char *argv[])
+{
+ sha256_context ctx;
+ uint8_t hv[32];
+ uint32_t i, j;
+
+ for (j = 0; j < (sizeof(buf)/sizeof(buf[0])); j += 2)
+ {
+ sha256_init(&ctx);
+ sha256_hash(&ctx, (uint8_t *)buf[j], (uint32_t)strlen(buf[j]));
+ sha256_done(&ctx, hv);
+ printf("input = %s\ndigest: %s\nresult: ", buf[j], buf[j+1]);
+ for (i = 0; i < 32; i++) printf("%02x%s", hv[i], ((i%4)==3)?" ":"");
+ printf("\n\n");
+ }
+
+ for (j = 1; j < (uint32_t)argc; j++)
+ {
+ printf("argv[%d]: %s\nresult: ", (int)j, argv[j]);
+ sha256_init(&ctx);
+ sha256_hash(&ctx, (uint8_t *)argv[j], (uint32_t)strlen(argv[j]));
+ sha256_done(&ctx, hv);
+ for (i = 0; i < 32; i++) printf("%02x%s", hv[i], ((i%4)==3)?" ":"");
+ printf("\n\n");
+ }
+
+ return 0;
+} /* main */
+#endif
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/core/io/sha256.h b/core/io/sha256.h
new file mode 100644
index 0000000000..e19e56b4cc
--- /dev/null
+++ b/core/io/sha256.h
@@ -0,0 +1,50 @@
+/*
+* SHA-256 implementation.
+*
+* Copyright (c) 2010 Ilya O. Levin, http://www.literatecode.com
+*
+* 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.
+*/
+#ifdef _MSC_VER
+#ifndef uint8_t
+typedef unsigned __int8 uint8_t;
+#endif
+#ifndef uint32_t
+typedef unsigned __int32 uint32_t;
+#endif
+#ifndef uint64_t
+typedef __int64 int64_t;
+typedef unsigned __int64 uint64_t;
+#endif
+#else
+#include <stdint.h>
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ typedef struct {
+ uint32_t buf[16];
+ uint32_t hash[8];
+ uint32_t len[2];
+ } sha256_context;
+
+ void sha256_init(sha256_context *);
+ void sha256_hash(sha256_context *, uint8_t * /* data */, uint32_t /* len */);
+ void sha256_done(sha256_context *, uint8_t * /* hash */);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/core/io/stream_peer.cpp b/core/io/stream_peer.cpp
index 2a9dff86f8..baaeacaf18 100644
--- a/core/io/stream_peer.cpp
+++ b/core/io/stream_peer.cpp
@@ -222,6 +222,7 @@ void StreamPeer::put_double(double p_val){
void StreamPeer::put_utf8_string(const String& p_string) {
CharString cs=p_string.utf8();
+ put_u32(p_string.length());
put_data((const uint8_t*)cs.get_data(),cs.length());
}
@@ -348,8 +349,10 @@ String StreamPeer::get_string(int p_bytes){
ERR_FAIL_COND_V(p_bytes<0,String());
Vector<char> buf;
- buf.resize(p_bytes+1);
- get_data((uint8_t*)&buf[0],p_bytes);
+ Error err = buf.resize(p_bytes+1);
+ ERR_FAIL_COND_V(err!=OK,String());
+ err = get_data((uint8_t*)&buf[0],p_bytes);
+ ERR_FAIL_COND_V(err!=OK,String());
buf[p_bytes]=0;
return buf.ptr();
@@ -357,11 +360,12 @@ String StreamPeer::get_string(int p_bytes){
String StreamPeer::get_utf8_string(int p_bytes){
ERR_FAIL_COND_V(p_bytes<0,String());
- ERR_FAIL_COND_V(p_bytes<0,String());
Vector<uint8_t> buf;
- buf.resize(p_bytes);
- get_data(buf.ptr(),p_bytes);
+ Error err = buf.resize(p_bytes);
+ ERR_FAIL_COND_V(err!=OK,String());
+ err = get_data(buf.ptr(),p_bytes);
+ ERR_FAIL_COND_V(err!=OK,String());
String ret;
ret.parse_utf8((const char*)buf.ptr(),buf.size());
@@ -372,8 +376,10 @@ Variant StreamPeer::get_var(){
int len = get_32();
Vector<uint8_t> var;
- var.resize(len);
- get_data(var.ptr(),len);
+ Error err = var.resize(len);
+ ERR_FAIL_COND_V(err!=OK,Variant());
+ err = get_data(var.ptr(),len);
+ ERR_FAIL_COND_V(err!=OK,Variant());
Variant ret;
decode_variant(ret,var.ptr(),len);
@@ -421,3 +427,128 @@ void StreamPeer::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_utf8_string","bytes"),&StreamPeer::get_utf8_string);
ObjectTypeDB::bind_method(_MD("get_var:Variant"),&StreamPeer::get_var);
}
+////////////////////////////////
+
+
+void StreamPeerBuffer::_bind_methods() {
+
+ ObjectTypeDB::bind_method(_MD("seek","pos"),&StreamPeerBuffer::seek);
+ ObjectTypeDB::bind_method(_MD("get_size"),&StreamPeerBuffer::get_size);
+ ObjectTypeDB::bind_method(_MD("get_pos"),&StreamPeerBuffer::get_pos);
+ ObjectTypeDB::bind_method(_MD("resize","size"),&StreamPeerBuffer::resize);
+ ObjectTypeDB::bind_method(_MD("set_data_array","data"),&StreamPeerBuffer::set_data_array);
+ ObjectTypeDB::bind_method(_MD("get_data_array"),&StreamPeerBuffer::get_data_array);
+ ObjectTypeDB::bind_method(_MD("clear"),&StreamPeerBuffer::clear);
+ ObjectTypeDB::bind_method(_MD("duplicate:StreamPeerBuffer"),&StreamPeerBuffer::duplicate);
+
+}
+
+
+Error StreamPeerBuffer::put_data(const uint8_t* p_data,int p_bytes) {
+
+ if (p_bytes<=0)
+ return OK;
+
+ if (pointer+p_bytes > data.size()) {
+ data.resize(pointer+p_bytes);
+
+ }
+
+ DVector<uint8_t>::Write w = data.write();
+ copymem(&w[pointer],p_data,p_bytes);
+
+ pointer+=p_bytes;
+ return OK;
+}
+
+Error StreamPeerBuffer::put_partial_data(const uint8_t* p_data,int p_bytes, int &r_sent){
+
+ r_sent=p_bytes;
+ return put_data(p_data,p_bytes);
+}
+
+Error StreamPeerBuffer::get_data(uint8_t* p_buffer, int p_bytes){
+
+ int recv;
+ get_partial_data(p_buffer,p_bytes,recv);
+ if (recv!=p_bytes)
+ return ERR_INVALID_PARAMETER;
+
+ return OK;
+
+}
+Error StreamPeerBuffer::get_partial_data(uint8_t* p_buffer, int p_bytes,int &r_received){
+
+
+ if (pointer+p_bytes > data.size()) {
+ r_received=data.size()-pointer;
+ if (r_received<=0) {
+ r_received=0;
+ return OK; //you got 0
+ }
+ } else {
+ r_received=p_bytes;
+ }
+
+ DVector<uint8_t>::Read r = data.read();
+ copymem(p_buffer,r.ptr(),r_received);
+}
+
+int StreamPeerBuffer::get_available_bytes() const {
+
+ return data.size()-pointer;
+}
+
+void StreamPeerBuffer::seek(int p_pos){
+
+ ERR_FAIL_COND(p_pos < 0);
+ ERR_FAIL_COND(p_pos > data.size());
+ pointer=p_pos;
+}
+int StreamPeerBuffer::get_size() const{
+
+ return data.size();
+}
+
+int StreamPeerBuffer::get_pos() const {
+
+ return pointer;
+}
+
+void StreamPeerBuffer::resize(int p_size){
+
+ data.resize(p_size);
+}
+
+void StreamPeerBuffer::set_data_array(const DVector<uint8_t> & p_data){
+
+ data=p_data;
+ pointer=0;
+}
+
+DVector<uint8_t> StreamPeerBuffer::get_data_array() const{
+
+ return data;
+}
+
+
+void StreamPeerBuffer::clear() {
+
+ data.resize(0);
+ pointer=0;
+}
+
+
+Ref<StreamPeerBuffer> StreamPeerBuffer::duplicate() const {
+
+ Ref<StreamPeerBuffer> spb;
+ spb.instance();
+ spb->data=data;
+ return spb;
+}
+
+
+StreamPeerBuffer::StreamPeerBuffer() {
+
+ pointer=0;
+}
diff --git a/core/io/stream_peer.h b/core/io/stream_peer.h
index 970e6695a5..f28e6f594d 100644
--- a/core/io/stream_peer.h
+++ b/core/io/stream_peer.h
@@ -91,4 +91,40 @@ public:
StreamPeer() { big_endian=false; }
};
+
+class StreamPeerBuffer : public StreamPeer {
+
+ OBJ_TYPE(StreamPeerBuffer,StreamPeer);
+
+ DVector<uint8_t> data;
+ int pointer;
+protected:
+
+ static void _bind_methods();
+public:
+ Error put_data(const uint8_t* p_data,int p_bytes);
+ Error put_partial_data(const uint8_t* p_data,int p_bytes, int &r_sent);
+
+ Error get_data(uint8_t* p_buffer, int p_bytes);
+ Error get_partial_data(uint8_t* p_buffer, int p_bytes,int &r_received);
+
+ virtual int get_available_bytes() const;
+
+ void seek(int p_pos);
+ int get_size() const;
+ int get_pos() const;
+ void resize(int p_size);
+
+
+ void set_data_array(const DVector<uint8_t> & p_data);
+ DVector<uint8_t> get_data_array() const;
+
+ void clear();
+
+ Ref<StreamPeerBuffer> duplicate() const;
+
+ StreamPeerBuffer();
+};
+
+
#endif // STREAM_PEER_H
diff --git a/core/io/stream_peer_ssl.cpp b/core/io/stream_peer_ssl.cpp
index 2114993783..a58be84225 100644
--- a/core/io/stream_peer_ssl.cpp
+++ b/core/io/stream_peer_ssl.cpp
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* stream_peer_ssl.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* 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 */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
#include "stream_peer_ssl.h"
diff --git a/core/io/stream_peer_ssl.h b/core/io/stream_peer_ssl.h
index 4b1c8e93bb..3435a9a445 100644
--- a/core/io/stream_peer_ssl.h
+++ b/core/io/stream_peer_ssl.h
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* stream_peer_ssl.h */
+/*************************************************************************/
+/* This file is part of: */
+/* 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 */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
#ifndef STREAM_PEER_SSL_H
#define STREAM_PEER_SSL_H
diff --git a/core/io/translation_loader_po.cpp b/core/io/translation_loader_po.cpp
index 4ddb276a27..a22c57b941 100644
--- a/core/io/translation_loader_po.cpp
+++ b/core/io/translation_loader_po.cpp
@@ -47,7 +47,6 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error, const S
String msg_id;
String msg_str;
String config;
- int msg_line=0;
if (r_error)
*r_error=ERR_FILE_CORRUPT;
@@ -97,7 +96,6 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error, const S
status=STATUS_READING_ID;
msg_id="";
msg_str="";
- msg_line=line;
}
if (l.begins_with("msgstr")) {
@@ -111,7 +109,6 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error, const S
l=l.substr(6,l.length()).strip_edges();
status=STATUS_READING_STRING;
- msg_line=line;
}
if (l=="" || l.begins_with("#")) {
diff --git a/core/io/unzip.c b/core/io/unzip.c
index b438021ad7..7aa0a86d13 100644
--- a/core/io/unzip.c
+++ b/core/io/unzip.c
@@ -10,7 +10,7 @@
Modifications for Zip64 support on both zip and unzip
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
- For more info read MiniZip_info.txt
+ For more info read LICENSE-MiniZip.txt
------------------------------------------------------------------------------------
@@ -1031,10 +1031,19 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file,
if (lSeek!=0)
{
- if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
- lSeek=0;
- else
- err=UNZ_ERRNO;
+ if (lSeek<0) {
+ // WORKAROUND for backwards seeking
+ z_off_t pos = ZTELL64(s->z_filefunc, s->filestream);
+ if (ZSEEK64(s->z_filefunc, s->filestream,pos+lSeek,ZLIB_FILEFUNC_SEEK_SET)==0)
+ lSeek=0;
+ else
+ err=UNZ_ERRNO;
+ } else {
+ if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
+ lSeek=0;
+ else
+ err=UNZ_ERRNO;
+ }
}
while(acc < file_info.size_file_extra)
diff --git a/core/io/unzip.h b/core/io/unzip.h
index cb3d239eac..f67c3b2fa8 100644
--- a/core/io/unzip.h
+++ b/core/io/unzip.h
@@ -10,7 +10,7 @@
Modifications for Zip64 support on both zip and unzip
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
- For more info read MiniZip_info.txt
+ For more info read LICENSE-MiniZip.txt
---------------------------------------------------------------------------------
diff --git a/core/io/zip.c b/core/io/zip.c
index c4ab93ab81..44c79195d9 100644
--- a/core/io/zip.c
+++ b/core/io/zip.c
@@ -7,7 +7,7 @@
Modifications for Zip64 support
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
- For more info read MiniZip_info.txt
+ For more info read LICENSE-MiniZip.txt
Changes
Oct-2009 - Mathias Svensson - Remove old C style function prototypes
diff --git a/core/io/zip.h b/core/io/zip.h
index 85f93568c9..37478b34c0 100644
--- a/core/io/zip.h
+++ b/core/io/zip.h
@@ -6,7 +6,7 @@
Modifications for Zip64 support
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
- For more info read MiniZip_info.txt
+ For more info read LICENSE-MiniZip.txt
---------------------------------------------------------------------------
diff --git a/core/io/zip_io.h b/core/io/zip_io.h
index 355003d947..0668c47d97 100644
--- a/core/io/zip_io.h
+++ b/core/io/zip_io.h
@@ -39,11 +39,14 @@ static void* zipio_open(void* data, const char* p_fname, int mode) {
FileAccess *&f = *(FileAccess**)data;
+ String fname;
+ fname.parse_utf8(p_fname);
+
if (mode & ZLIB_FILEFUNC_MODE_WRITE) {
- f = FileAccess::open(p_fname,FileAccess::WRITE);
+ f = FileAccess::open(fname,FileAccess::WRITE);
} else {
- f = FileAccess::open(p_fname,FileAccess::READ);
+ f = FileAccess::open(fname,FileAccess::READ);
}
if (!f)