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 ++++++++ core/object_type_db.h | 17 ++++++++ core/os/input.h | 2 +- core/os/os.cpp | 19 ++++++++- core/os/os.h | 4 ++ core/register_core_types.cpp | 12 +++--- core/safe_refcount.h | 8 ++-- core/script_debugger_remote.cpp | 2 +- 21 files changed, 194 insertions(+), 105 deletions(-) (limited to 'core') 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; } diff --git a/core/object_type_db.h b/core/object_type_db.h index 43a6bb2689..9eaec6171e 100644 --- a/core/object_type_db.h +++ b/core/object_type_db.h @@ -205,6 +205,23 @@ public: //nothing } + template + static Object* _create_ptr_func() { + + return T::create(); + } + + template + static void register_create_type() { + + GLOBAL_LOCK_FUNCTION; + T::initialize_type(); + TypeInfo *t=types.getptr(T::get_type_static()); + ERR_FAIL_COND(!t); + t->creation_func=&_create_ptr_func; + T::register_custom_data_to_otdb(); + } + static void get_type_list( List *p_types); static void get_inheriters_from( const String& p_type,List *p_types); static String type_inherits_from(const String& p_type); diff --git a/core/os/input.h b/core/os/input.h index 3f62b93972..5987d6ef6c 100644 --- a/core/os/input.h +++ b/core/os/input.h @@ -55,7 +55,7 @@ public: static Input *get_singleton(); - virtual bool is_key_pressed(int p_scancode)=0; + virtual bool is_key_pressed(int p_scancode)=0; virtual bool is_mouse_button_pressed(int p_button)=0; virtual bool is_joy_button_pressed(int p_device, int p_button)=0; virtual bool is_action_pressed(const StringName& p_action)=0; diff --git a/core/os/os.cpp b/core/os/os.cpp index 1ee87099a2..141d5f2b58 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -425,8 +425,25 @@ int OS::get_processor_count() const { return 1; } -void OS::set_mouse_mode(MouseMode p_mode) { +Error OS::native_video_play(String p_path) { + + return FAILED; +}; + +bool OS::native_video_is_playing() { + + return false; +}; +void OS::native_video_pause() { + +}; + +void OS::native_video_stop() { + +}; + +void OS::set_mouse_mode(MouseMode p_mode) { } diff --git a/core/os/os.h b/core/os/os.h index 5fc4893a97..d77d9bee7f 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -315,6 +315,10 @@ public: virtual String get_unique_ID() const; + virtual Error native_video_play(String p_path); + virtual bool native_video_is_playing(); + virtual void native_video_pause(); + virtual void native_video_stop(); virtual Error dialog_show(String p_title, String p_description, Vector p_buttons, Object* p_obj, String p_callback); virtual Error dialog_input_text(String p_title, String p_description, String p_partial, Object* p_obj, String p_callback); diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index 6beafc70c9..6d107f97e7 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -106,10 +106,6 @@ void register_core_types() { object_format_loader_xml = memnew( ObjectFormatLoaderInstancerXML ); ObjectLoader::add_object_format_loader_instancer( object_format_loader_xml ); #endif - resource_saver_xml = memnew( ResourceFormatSaverXML ); - ResourceSaver::add_resource_format_saver(resource_saver_xml); - resource_loader_xml = memnew( ResourceFormatLoaderXML ); - ResourceLoader::add_resource_format_loader(resource_loader_xml); #endif #ifdef OLD_SCENE_FORMAT_ENABLED object_format_saver_binary = memnew( ObjectFormatSaverInstancerBinary ); @@ -128,6 +124,10 @@ void register_core_types() { resource_loader_binary = memnew( ResourceFormatLoaderBinary ); ResourceLoader::add_resource_format_loader(resource_loader_binary); + resource_saver_xml = memnew( ResourceFormatSaverXML ); + ResourceSaver::add_resource_format_saver(resource_saver_xml); + resource_loader_xml = memnew( ResourceFormatLoaderXML ); + ResourceLoader::add_resource_format_loader(resource_loader_xml); ObjectTypeDB::register_type(); @@ -136,8 +136,8 @@ void register_core_types() { ObjectTypeDB::register_type(); ObjectTypeDB::register_type(); ObjectTypeDB::register_virtual_type(); - ObjectTypeDB::register_virtual_type(); - ObjectTypeDB::register_virtual_type(); + ObjectTypeDB::register_create_type(); + ObjectTypeDB::register_create_type(); ObjectTypeDB::register_virtual_type(); ObjectTypeDB::register_virtual_type(); ObjectTypeDB::register_type(); diff --git a/core/safe_refcount.h b/core/safe_refcount.h index 0ee32c3fe7..4357786732 100644 --- a/core/safe_refcount.h +++ b/core/safe_refcount.h @@ -148,7 +148,7 @@ static inline int atomic_decrement( volatile int *pw) { /* PowerPC32/64 GCC */ -#elif defined( __GNUC__ ) && ( defined( __powerpc__ ) || defined( __ppc__ ) ) +#elif ( defined( __GNUC__ ) ) && ( defined( __powerpc__ ) || defined( __ppc__ ) ) #define REFCOUNT_T int #define REFCOUNT_GET_T int const volatile& @@ -257,14 +257,14 @@ inline int atomic_decrement(volatile int* v) /* CW PPC */ -#elif defined( __MWERKS__ ) && defined( __POWERPC__ ) +#elif ( defined( __MWERKS__ ) ) && defined( __POWERPC__ ) inline long atomic_conditional_increment( register long * pw ) { register int a; - asm - { + asm + { loop: lwarx a, 0, pw diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp index ce9fff559d..cd8303b542 100644 --- a/core/script_debugger_remote.cpp +++ b/core/script_debugger_remote.cpp @@ -415,7 +415,7 @@ void ScriptDebuggerRemote::set_request_scene_tree_message_func(RequestSceneTreeM ScriptDebuggerRemote::ScriptDebuggerRemote() { - tcp_client = StreamPeerTCP::create(); + tcp_client = StreamPeerTCP::create_ref(); packet_peer_stream = Ref( memnew(PacketPeerStream) ); packet_peer_stream->set_stream_peer(tcp_client); mutex = Mutex::create(); -- cgit v1.2.3