From 58cda02a389759d18176216c06f375d364cefef1 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Thu, 13 Feb 2014 18:03:28 -0300 Subject: -fixed export templates not loading/exporting on Windows -fixed TouchScreenButton with stretch2d -fixed(?) OSX crash on startup (test!!) -compilation fixes on windows -CollisionPolygon editor works again -find buttons en find dialog -TileMap editor cleanup (removed "error", made nicer) -viewport flicker fixed -make .scn default extension for saving scenes -export the rest of the network classes to gdscript --- core/io/file_access_network.cpp | 2 +- core/io/file_access_pack.cpp | 8 +++- core/io/file_access_pack.h | 15 ++++--- core/io/file_access_zip.cpp | 3 +- core/io/http_client.cpp | 2 +- core/io/ioapi.c | 2 + core/io/ioapi.h | 5 +++ core/io/stream_peer_tcp.cpp | 63 +++++++++++++++------------ core/io/stream_peer_tcp.h | 95 +++++++++++++++++++++-------------------- core/io/tcp_server.cpp | 9 +++- core/io/tcp_server.h | 3 +- core/io/unzip.c | 5 ++- core/io/zip.c | 5 ++- core/io/zip_io.h | 18 ++++++++ 14 files changed, 143 insertions(+), 92 deletions(-) (limited to 'core/io') diff --git a/core/io/file_access_network.cpp b/core/io/file_access_network.cpp index a5636b137d..26194040b0 100644 --- a/core/io/file_access_network.cpp +++ b/core/io/file_access_network.cpp @@ -243,7 +243,7 @@ FileAccessNetworkClient::FileAccessNetworkClient() { quit=false; singleton=this; last_id=0; - client = Ref( StreamPeerTCP::create() ); + client = Ref( StreamPeerTCP::create_ref() ); sem=Semaphore::create(); lockcount=0; } diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index 4443dd3575..4ae60947fa 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -44,7 +44,7 @@ Error PackedData::add_pack(const String& p_path) { return ERR_FILE_UNRECOGNIZED; }; -void PackedData::add_path(const String& pkg_path, const String& path, uint64_t ofs, uint64_t size, PackSource* p_src) { +void PackedData::add_path(const String& pkg_path, const String& path, uint64_t ofs, uint64_t size,const uint8_t* p_md5, PackSource* p_src) { bool exists = files.has(path); @@ -52,6 +52,8 @@ void PackedData::add_path(const String& pkg_path, const String& path, uint64_t o pf.pack=pkg_path; pf.offset=ofs; pf.size=size; + for(int i=0;i<16;i++) + pf.md5[i]=p_md5[i]; pf.src = p_src; files[path]=pf; @@ -163,8 +165,10 @@ bool PackedSourcePCK::try_open_pack(const String& p_path) { uint64_t ofs = f->get_64(); uint64_t size = f->get_64(); + uint8_t md5[16]; + f->get_buffer(md5,16); - PackedData::get_singleton()->add_path(p_path, path, ofs, size, this); + PackedData::get_singleton()->add_path(p_path, path, ofs, size, md5,this); }; return true; diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h index 97e236009e..07ce8cbaf8 100644 --- a/core/io/file_access_pack.h +++ b/core/io/file_access_pack.h @@ -46,8 +46,9 @@ public: struct PackedFile { String pack; - uint64_t offset; + uint64_t offset; //if offset is ZERO, the file was ERASED uint64_t size; + uint8_t md5[16]; PackSource* src; }; @@ -72,7 +73,7 @@ private: public: void add_pack_source(PackSource* p_source); - void add_path(const String& pkg_path, const String& path, uint64_t ofs, uint64_t size, PackSource* p_src); // for PackSource + void add_path(const String& pkg_path, const String& path, uint64_t ofs, uint64_t size,const uint8_t* p_md5, PackSource* p_src); // for PackSource void set_disabled(bool p_disabled) { disabled=p_disabled; } _FORCE_INLINE_ bool is_disabled() const { return disabled; } @@ -150,11 +151,13 @@ public: FileAccess *PackedData::try_open_path(const String& p_path) { - if (files.has(p_path)) { - return files[p_path].src->get_file(p_path, &files[p_path]); - } + Map::Element *E=files.find(p_path); + if (!E) + return NULL; //not found + if (E->get().offset==0) + return NULL; //was erased - return NULL; + return E->get().src->get_file(p_path, &E->get()); } bool PackedData::has_path(const String& p_path) { diff --git a/core/io/file_access_zip.cpp b/core/io/file_access_zip.cpp index 72e929619f..55c0dedad9 100644 --- a/core/io/file_access_zip.cpp +++ b/core/io/file_access_zip.cpp @@ -197,7 +197,8 @@ bool ZipArchive::try_open_pack(const String& p_name) { String fname = String("res://") + filename_inzip; files[fname] = f; - PackedData::get_singleton()->add_path(p_name, fname, 0, 0, this); + uint8_t md5[16]={0,0,0,0,0,0,0,0 , 0,0,0,0,0,0,0,0}; + PackedData::get_singleton()->add_path(p_name, fname, 0, 0, md5, this); if ((i+1)zfile_func64.opaque = p_filefunc32->opaque; p_filefunc64_32->zseek32_file = p_filefunc32->zseek_file; p_filefunc64_32->ztell32_file = p_filefunc32->ztell_file; + p_filefunc64_32->zfile_func64.alloc_mem = p_filefunc32->alloc_mem; + p_filefunc64_32->zfile_func64.free_mem = p_filefunc32->free_mem; } /* diff --git a/core/io/ioapi.h b/core/io/ioapi.h index 53d01d65c5..f6934e5866 100644 --- a/core/io/ioapi.h +++ b/core/io/ioapi.h @@ -144,6 +144,8 @@ typedef struct zlib_filefunc_def_s close_file_func zclose_file; testerror_file_func zerror_file; voidpf opaque; + alloc_func alloc_mem; + free_func free_mem; } zlib_filefunc_def; typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream)); @@ -160,6 +162,9 @@ typedef struct zlib_filefunc64_def_s close_file_func zclose_file; testerror_file_func zerror_file; voidpf opaque; + alloc_func alloc_mem; + free_func free_mem; + } zlib_filefunc64_def; void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def)); diff --git a/core/io/stream_peer_tcp.cpp b/core/io/stream_peer_tcp.cpp index 0fdaab885a..13a158ea4d 100644 --- a/core/io/stream_peer_tcp.cpp +++ b/core/io/stream_peer_tcp.cpp @@ -26,31 +26,38 @@ /* 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_tcp.h" - -StreamPeerTCP* (*StreamPeerTCP::_create)()=NULL; - -void StreamPeerTCP::_bind_methods() { - - ObjectTypeDB::bind_method(_MD("connect","host","ip"),&StreamPeerTCP::connect); - ObjectTypeDB::bind_method(_MD("is_connected"),&StreamPeerTCP::is_connected); - ObjectTypeDB::bind_method(_MD("get_connected_host"),&StreamPeerTCP::get_connected_host); - ObjectTypeDB::bind_method(_MD("get_connected_port"),&StreamPeerTCP::get_connected_port); - ObjectTypeDB::bind_method(_MD("disconnect"),&StreamPeerTCP::disconnect); -} - -Ref StreamPeerTCP::create() { - - if (!_create) - return Ref(); - return Ref(_create()); -} - -StreamPeerTCP::StreamPeerTCP() { - -} - -StreamPeerTCP::~StreamPeerTCP() { - -}; - +#include "stream_peer_tcp.h" + +StreamPeerTCP* (*StreamPeerTCP::_create)()=NULL; + +void StreamPeerTCP::_bind_methods() { + + ObjectTypeDB::bind_method(_MD("connect","host","ip"),&StreamPeerTCP::connect); + ObjectTypeDB::bind_method(_MD("is_connected"),&StreamPeerTCP::is_connected); + ObjectTypeDB::bind_method(_MD("get_connected_host"),&StreamPeerTCP::get_connected_host); + ObjectTypeDB::bind_method(_MD("get_connected_port"),&StreamPeerTCP::get_connected_port); + ObjectTypeDB::bind_method(_MD("disconnect"),&StreamPeerTCP::disconnect); +} + +Ref StreamPeerTCP::create_ref() { + + if (!_create) + return Ref(); + return Ref(_create()); +} + +StreamPeerTCP* StreamPeerTCP::create() { + + if (!_create) + return NULL; + return _create(); +} + +StreamPeerTCP::StreamPeerTCP() { + +} + +StreamPeerTCP::~StreamPeerTCP() { + +}; + diff --git a/core/io/stream_peer_tcp.h b/core/io/stream_peer_tcp.h index 428ccd3d32..69c9d0c592 100644 --- a/core/io/stream_peer_tcp.h +++ b/core/io/stream_peer_tcp.h @@ -26,50 +26,51 @@ /* 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_TCP_H -#define STREAM_PEER_TCP_H - -#include "stream_peer.h" - -#include "ip_address.h" - -class StreamPeerTCP : public StreamPeer { - - OBJ_TYPE( StreamPeerTCP, StreamPeer ); - OBJ_CATEGORY("Networking"); - -public: - - enum Status { - - STATUS_NONE, - STATUS_CONNECTING, - STATUS_CONNECTED, - STATUS_ERROR, - }; - -protected: - - static StreamPeerTCP* (*_create)(); - static void _bind_methods(); - -public: - - virtual Error connect(const IP_Address& p_host, uint16_t p_port)=0; - - //read/write from streampeer - - virtual bool is_connected() const=0; - virtual Status get_status() const=0; - virtual void disconnect()=0; - virtual IP_Address get_connected_host() const=0; - virtual uint16_t get_connected_port() const=0; - virtual void set_nodelay(bool p_enabled)=0; - - static Ref create(); - - StreamPeerTCP(); - ~StreamPeerTCP(); -}; - -#endif +#ifndef STREAM_PEER_TCP_H +#define STREAM_PEER_TCP_H + +#include "stream_peer.h" + +#include "ip_address.h" + +class StreamPeerTCP : public StreamPeer { + + OBJ_TYPE( StreamPeerTCP, StreamPeer ); + OBJ_CATEGORY("Networking"); + +public: + + enum Status { + + STATUS_NONE, + STATUS_CONNECTING, + STATUS_CONNECTED, + STATUS_ERROR, + }; + +protected: + + static StreamPeerTCP* (*_create)(); + static void _bind_methods(); + +public: + + virtual Error connect(const IP_Address& p_host, uint16_t p_port)=0; + + //read/write from streampeer + + virtual bool is_connected() const=0; + virtual Status get_status() const=0; + virtual void disconnect()=0; + virtual IP_Address get_connected_host() const=0; + virtual uint16_t get_connected_port() const=0; + virtual void set_nodelay(bool p_enabled)=0; + + static Ref create_ref(); + static StreamPeerTCP* create(); + + StreamPeerTCP(); + ~StreamPeerTCP(); +}; + +#endif diff --git a/core/io/tcp_server.cpp b/core/io/tcp_server.cpp index 06419b9c6b..bce9e19ae3 100644 --- a/core/io/tcp_server.cpp +++ b/core/io/tcp_server.cpp @@ -30,13 +30,20 @@ TCP_Server* (*TCP_Server::_create)()=NULL; -Ref TCP_Server::create() { +Ref TCP_Server::create_ref() { if (!_create) return NULL; return Ref(_create()); } +TCP_Server* TCP_Server::create() { + + if (!_create) + return NULL; + return _create(); +} + Error TCP_Server::_listen(uint16_t p_port,DVector p_accepted_hosts) { List hosts; diff --git a/core/io/tcp_server.h b/core/io/tcp_server.h index 31949be3b6..fff00e5ce0 100644 --- a/core/io/tcp_server.h +++ b/core/io/tcp_server.h @@ -51,7 +51,8 @@ public: virtual void stop()=0; //stop listening - static Ref create(); + static Ref create_ref(); + static TCP_Server* create(); TCP_Server(); }; diff --git a/core/io/unzip.c b/core/io/unzip.c index ac72457f38..39e91834b9 100644 --- a/core/io/unzip.c +++ b/core/io/unzip.c @@ -1588,8 +1588,8 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method, } else if ((s->cur_file_info.compression_method==Z_DEFLATED) && (!raw)) { - pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; - pfile_in_zip_read_info->stream.zfree = (free_func)0; + pfile_in_zip_read_info->stream.zalloc = s->z_filefunc.zfile_func64.alloc_mem; + pfile_in_zip_read_info->stream.zfree = s->z_filefunc.zfile_func64.free_mem; pfile_in_zip_read_info->stream.opaque = (voidpf)0; pfile_in_zip_read_info->stream.next_in = 0; pfile_in_zip_read_info->stream.avail_in = 0; @@ -1599,6 +1599,7 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method, pfile_in_zip_read_info->stream_initialised=Z_DEFLATED; else { + printf("NO OPEN ZLIB %i\n",err); TRYFREE(pfile_in_zip_read_info); return err; } diff --git a/core/io/zip.c b/core/io/zip.c index edf5560ddb..86c85e116b 100644 --- a/core/io/zip.c +++ b/core/io/zip.c @@ -1210,8 +1210,9 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename, { if(zi->ci.method == Z_DEFLATED) { - zi->ci.stream.zalloc = (alloc_func)0; - zi->ci.stream.zfree = (free_func)0; + zi->ci.stream.zalloc = zi->z_filefunc.zfile_func64.alloc_mem; + zi->ci.stream.zfree = zi->z_filefunc.zfile_func64.free_mem; + zi->ci.stream.opaque = (voidpf)0; if (windowBits>0) diff --git a/core/io/zip_io.h b/core/io/zip_io.h index c7d5a70135..2f99113392 100644 --- a/core/io/zip_io.h +++ b/core/io/zip_io.h @@ -32,6 +32,7 @@ #include "io/zip.h" #include "io/unzip.h" #include "os/file_access.h" +//#include "copymem.h" static void* zipio_open(void* data, const char* p_fname, int mode) { @@ -110,6 +111,21 @@ static int zipio_testerror(voidpf opaque, voidpf stream) { }; + +static voidpf zipio_alloc(voidpf opaque, uInt items, uInt size) { + + voidpf ptr =memalloc(items*size); + zeromem(ptr,items*size); + return ptr; +} + + +static void zipio_free(voidpf opaque, voidpf address) { + + memfree(address); +} + + static zlib_filefunc_def zipio_create_io_from_file(FileAccess **p_file) { zlib_filefunc_def io; @@ -121,6 +137,8 @@ static zlib_filefunc_def zipio_create_io_from_file(FileAccess **p_file) { io.zseek_file = zipio_seek; io.zclose_file = zipio_close; io.zerror_file = zipio_testerror; + io.alloc_mem=zipio_alloc; + io.free_mem=zipio_free; return io; } -- cgit v1.2.3