diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/SCsub | 4 | ||||
-rw-r--r-- | core/bind/core_bind.cpp | 2 | ||||
-rw-r--r-- | core/global_config.cpp (renamed from core/globals.cpp) | 137 | ||||
-rw-r--r-- | core/global_config.h (renamed from core/globals.h) | 4 | ||||
-rw-r--r-- | core/input_map.cpp | 2 | ||||
-rw-r--r-- | core/io/file_access_memory.cpp | 2 | ||||
-rw-r--r-- | core/io/file_access_network.cpp | 2 | ||||
-rw-r--r-- | core/io/file_access_pack.cpp | 6 | ||||
-rw-r--r-- | core/io/packet_peer.cpp | 2 | ||||
-rw-r--r-- | core/io/resource_format_binary.cpp | 2 | ||||
-rw-r--r-- | core/io/resource_loader.cpp | 2 | ||||
-rw-r--r-- | core/io/resource_saver.cpp | 2 | ||||
-rw-r--r-- | core/message_queue.cpp | 2 | ||||
-rw-r--r-- | core/os/dir_access.cpp | 2 | ||||
-rw-r--r-- | core/os/file_access.cpp | 2 | ||||
-rw-r--r-- | core/os/input.cpp | 2 | ||||
-rw-r--r-- | core/os/os.cpp | 2 | ||||
-rw-r--r-- | core/register_core_types.cpp | 2 | ||||
-rw-r--r-- | core/script_debugger_remote.cpp | 2 | ||||
-rw-r--r-- | core/translation.cpp | 2 | ||||
-rw-r--r-- | core/ustring.cpp | 32 | ||||
-rw-r--r-- | core/ustring.h | 2 |
22 files changed, 110 insertions, 107 deletions
diff --git a/core/SCsub b/core/SCsub index 8d89f6427b..a9721a1052 100644 --- a/core/SCsub +++ b/core/SCsub @@ -13,7 +13,7 @@ for x in env.global_defaults: gd_inc += '#include "platform/' + x + '/globals/global_defaults.h"\n' gd_call += "\tregister_" + x + "_global_defaults();\n" -gd_cpp = '#include "globals.h"\n' +gd_cpp = '#include "global_config.h"\n' gd_cpp += gd_inc gd_cpp += "void GlobalConfig::register_global_defaults() {\n" + gd_call + "\n}\n" @@ -45,7 +45,7 @@ if ("SCRIPT_AES256_ENCRYPTION_KEY" in os.environ): print("Invalid AES256 encryption key, not 64 bits hex: " + e) f = open("script_encryption_key.cpp", "wb") -f.write("#include \"globals.h\"\nuint8_t script_encryption_key[32]={" + txt + "};\n") +f.write("#include \"global_config.h\"\nuint8_t script_encryption_key[32]={" + txt + "};\n") f.close() diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 7bd652349d..54ab51657b 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -31,7 +31,7 @@ #include "geometry.h" #include "io/marshalls.h" #include "io/base64.h" -#include "core/globals.h" +#include "core/global_config.h" #include "io/file_access_encrypted.h" #include "os/keyboard.h" diff --git a/core/globals.cpp b/core/global_config.cpp index 0c35a9f89a..b76991c04e 100644 --- a/core/globals.cpp +++ b/core/global_config.cpp @@ -26,7 +26,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "globals.h" +#include "global_config.h" #include "os/dir_access.h" #include "os/file_access.h" @@ -247,9 +247,22 @@ bool GlobalConfig::_load_resource_pack(const String& p_pack) { Error GlobalConfig::setup(const String& p_path,const String & p_main_pack) { - //an absolute mess of a function, must be cleaned up and reorganized somehow at some point + //If looking for files in network, just use network! - //_load_settings(p_path+"/override.cfg"); + if (FileAccessNetworkClient::get_singleton()) { + + if (_load_settings("res://godot.cfg")==OK || _load_settings_binary("res://godot.cfb")==OK) { + + _load_settings("res://override.cfg"); + + } + + return OK; + } + + String exec_path = OS::get_singleton()->get_executable_path(); + + //Attempt with a passed main pack first if (p_main_pack!="") { @@ -257,8 +270,8 @@ Error GlobalConfig::setup(const String& p_path,const String & p_main_pack) { ERR_FAIL_COND_V(!ok,ERR_CANT_OPEN); if (_load_settings("res://godot.cfg")==OK || _load_settings_binary("res://godot.cfb")==OK) { - - _load_settings("res://override.cfg"); + //load override from location of the main pack + _load_settings(p_main_pack.get_base_dir().plus_file("override.cfg")); } @@ -266,21 +279,15 @@ Error GlobalConfig::setup(const String& p_path,const String & p_main_pack) { } - if (OS::get_singleton()->get_executable_path()!="") { + //Attempt with execname.pck + if (exec_path!="") { - if (_load_resource_pack(OS::get_singleton()->get_executable_path())) { - if (p_path!="") { - resource_path=p_path; - } else { - DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); - resource_path=d->get_current_dir(); - memdelete(d); + if (_load_resource_pack(exec_path.get_basename()+".pck")) { - } if (_load_settings("res://godot.cfg")==OK || _load_settings_binary("res://godot.cfb")==OK) { - - _load_settings("res://override.cfg"); + //load override from location of executable + _load_settings(exec_path.get_base_dir().plus_file("override.cfg")); } @@ -292,31 +299,19 @@ Error GlobalConfig::setup(const String& p_path,const String & p_main_pack) { } - if (FileAccessNetworkClient::get_singleton()) { - - if (_load_settings("res://godot.cfg")==OK || _load_settings_binary("res://godot.cfb")==OK) { - - _load_settings("res://override.cfg"); - - } - - return OK; - } - + //Try to use the filesystem for files, according to OS. (only Android -when reading from pck- and iOS use this) if (OS::get_singleton()->get_resource_dir()!="") { - //OS will call Globals->get_resource_path which will be empty if not overriden! + //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. + resource_path=OS::get_singleton()->get_resource_dir().replace("\\","/"); if (resource_path.length() && resource_path[ resource_path.length()-1]=='/') resource_path=resource_path.substr(0,resource_path.length()-1); // chop end - print_line("has res dir: "+resource_path); - if (!_load_resource_pack("res://data.pck")) - _load_resource_pack("res://data.zip"); - // make sure this is load from the resource path - print_line("exists engine cfg? "+itos(FileAccess::exists("/godot.cfg"))); + // data.pck and data.zip are deprecated and no longer supported, apologies. + // make sure this is loaded from the resource path + if (_load_settings("res://godot.cfg")==OK || _load_settings_binary("res://godot.cfb")==OK) { - print_line("loaded godot.cfg"); _load_settings("res://override.cfg"); } @@ -324,67 +319,41 @@ Error GlobalConfig::setup(const String& p_path,const String & p_main_pack) { return OK; } - DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); - if (!d) { - - resource_path = p_path; - - } else { - - d->change_dir(p_path); - - String candidate = d->get_current_dir(); - String current_dir = d->get_current_dir(); - String exec_name = OS::get_singleton()->get_executable_path().get_file().get_basename(); - bool found = false; - bool first_time=true; - - while(true) { - //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://godot.cfg")==OK || _load_settings_binary("res://godot.cfb")==OK) { + //Nothing was found, try to find a godot.cfg somewhere! - _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 (_load_settings("res://godot.cfg")==OK || _load_settings_binary("res://godot.cfb")==OK) { + DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); + ERR_FAIL_COND_V(!d,ERR_CANT_CREATE); - _load_settings("res://override.cfg"); - found=true; + d->change_dir(p_path); + String candidate = d->get_current_dir(); + String current_dir = d->get_current_dir(); + bool found = false; - } - break; - } else if (_load_settings(current_dir+"/godot.cfg")==OK || _load_settings_binary(current_dir+"/godot.cfb")==OK) { + while(true) { + //try to load settings in ascending through dirs shape! - _load_settings(current_dir+"/override.cfg"); - candidate=current_dir; - found=true; - break; - } + if (_load_settings(current_dir+"/godot.cfg")==OK || _load_settings_binary(current_dir+"/godot.cfb")==OK) { - d->change_dir(".."); - if (d->get_current_dir()==current_dir) - break; //not doing anything useful - current_dir=d->get_current_dir(); - first_time=false; + _load_settings(current_dir+"/override.cfg"); + candidate=current_dir; + found=true; + break; } + d->change_dir(".."); + if (d->get_current_dir()==current_dir) + break; //not doing anything useful + current_dir=d->get_current_dir(); + } - resource_path=candidate; - resource_path = resource_path.replace("\\","/"); // windows path to unix path just in case - memdelete(d); - if (!found) - return ERR_FILE_NOT_FOUND; - }; + resource_path=candidate; + resource_path = resource_path.replace("\\","/"); // windows path to unix path just in case + memdelete(d); + if (!found) + return ERR_FILE_NOT_FOUND; if (resource_path.length() && resource_path[ resource_path.length()-1]=='/') resource_path=resource_path.substr(0,resource_path.length()-1); // chop end diff --git a/core/globals.h b/core/global_config.h index faf077f2a5..471f1ff885 100644 --- a/core/globals.h +++ b/core/global_config.h @@ -26,8 +26,8 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef GLOBALS_H -#define GLOBALS_H +#ifndef GLOBAL_CONFIG_H +#define GLOBAL_CONFIG_H #include "object.h" #include "set.h" diff --git a/core/input_map.cpp b/core/input_map.cpp index 249c75cea0..444c55cac6 100644 --- a/core/input_map.cpp +++ b/core/input_map.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "input_map.h" -#include "globals.h" +#include "global_config.h" #include "os/keyboard.h" InputMap *InputMap::singleton=NULL; diff --git a/core/io/file_access_memory.cpp b/core/io/file_access_memory.cpp index 32eb003228..b4ba14ddc9 100644 --- a/core/io/file_access_memory.cpp +++ b/core/io/file_access_memory.cpp @@ -30,7 +30,7 @@ #include "os/dir_access.h" #include "os/copymem.h" -#include "globals.h" +#include "global_config.h" #include "map.h" static Map<String, Vector<uint8_t> >* files = NULL; diff --git a/core/io/file_access_network.cpp b/core/io/file_access_network.cpp index 7bf750f6e1..d9fdc9cedc 100644 --- a/core/io/file_access_network.cpp +++ b/core/io/file_access_network.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "file_access_network.h" #include "marshalls.h" -#include "globals.h" +#include "global_config.h" #include "os/os.h" #include "io/ip.h" diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index d63539a7a5..fa1bebde16 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -31,7 +31,7 @@ #include <stdio.h> -#define PACK_VERSION 0 +#define PACK_VERSION 1 Error PackedData::add_pack(const String& p_path) { @@ -167,8 +167,8 @@ bool PackedSourcePCK::try_open_pack(const String& p_path) { uint32_t ver_minor = f->get_32(); uint32_t ver_rev = f->get_32(); - ERR_EXPLAIN("Pack version newer than supported by engine: "+itos(version)); - ERR_FAIL_COND_V( version > PACK_VERSION, ERR_INVALID_DATA); + ERR_EXPLAIN("Pack version unsupported: "+itos(version)); + ERR_FAIL_COND_V( version != PACK_VERSION, ERR_INVALID_DATA); ERR_EXPLAIN("Pack created with a newer version of the engine: "+itos(ver_major)+"."+itos(ver_minor)+"."+itos(ver_rev)); ERR_FAIL_COND_V( ver_major > VERSION_MAJOR || (ver_major == VERSION_MAJOR && ver_minor > VERSION_MINOR), ERR_INVALID_DATA); diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp index aca095b6a5..cf5883121f 100644 --- a/core/io/packet_peer.cpp +++ b/core/io/packet_peer.cpp @@ -29,7 +29,7 @@ #include "packet_peer.h" #include "io/marshalls.h" -#include "globals.h" +#include "global_config.h" /* helpers / binders */ diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 2c02dbcc9b..2d733842fa 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "version.h" #include "resource_format_binary.h" -#include "globals.h" +#include "global_config.h" #include "io/file_access_compressed.h" #include "io/marshalls.h" #include "os/dir_access.h" diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index b6d28bccfa..c14389eefa 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "resource_loader.h" #include "print_string.h" -#include "globals.h" +#include "global_config.h" #include "path_remap.h" #include "os/file_access.h" #include "os/os.h" diff --git a/core/io/resource_saver.cpp b/core/io/resource_saver.cpp index 222d3e6bc0..f0bea30051 100644 --- a/core/io/resource_saver.cpp +++ b/core/io/resource_saver.cpp @@ -27,7 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "resource_saver.h" -#include "globals.h" +#include "global_config.h" #include "os/file_access.h" #include "script_language.h" #include "resource_loader.h" diff --git a/core/message_queue.cpp b/core/message_queue.cpp index 668d321e05..50b52e4970 100644 --- a/core/message_queue.cpp +++ b/core/message_queue.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "message_queue.h" -#include "globals.h" +#include "global_config.h" #include "script_language.h" MessageQueue *MessageQueue::singleton=NULL; diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp index 804fe15c39..974225a3e8 100644 --- a/core/os/dir_access.cpp +++ b/core/os/dir_access.cpp @@ -30,7 +30,7 @@ #include "os/file_access.h" #include "os/memory.h" #include "os/os.h" -#include "globals.h" +#include "global_config.h" String DirAccess::_get_root_path() const { diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp index 06723c5131..ae592720e8 100644 --- a/core/os/file_access.cpp +++ b/core/os/file_access.cpp @@ -27,7 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "file_access.h" -#include "globals.h" +#include "global_config.h" #include "os/os.h" #include "core/io/marshalls.h" #include "io/md5.h" diff --git a/core/os/input.cpp b/core/os/input.cpp index e20c966ff2..34883e63ba 100644 --- a/core/os/input.cpp +++ b/core/os/input.cpp @@ -29,7 +29,7 @@ #include "input.h" #include "input_map.h" #include "os/os.h" -#include "globals.h" +#include "global_config.h" Input *Input::singleton=NULL; Input *Input::get_singleton() { diff --git a/core/os/os.cpp b/core/os/os.cpp index 3a8e15a692..912f7f0b0f 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -29,7 +29,7 @@ #include "os.h" #include "dir_access.h" -#include "globals.h" +#include "global_config.h" #include "input.h" #include "os/file_access.h" diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index ab94b56cdc..00f6f8662f 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -35,7 +35,7 @@ #include "io/packet_peer.h" #include "math/a_star.h" #include "math/triangle_mesh.h" -#include "globals.h" +#include "global_config.h" #include "class_db.h" #include "geometry.h" #include "bind/core_bind.h" diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp index 62d14c4e5a..b14eb51b6c 100644 --- a/core/script_debugger_remote.cpp +++ b/core/script_debugger_remote.cpp @@ -30,7 +30,7 @@ #include "os/os.h" #include "io/ip.h" -#include "globals.h" +#include "global_config.h" #include "os/input.h" void ScriptDebuggerRemote::_send_video_memory() { diff --git a/core/translation.cpp b/core/translation.cpp index 655bfd36b8..d9d4fe7784 100644 --- a/core/translation.cpp +++ b/core/translation.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "translation.h" -#include "globals.h" +#include "global_config.h" #include "io/resource_loader.h" #include "os/os.h" diff --git a/core/ustring.cpp b/core/ustring.cpp index a0d26ea0af..c13c13ec11 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -52,8 +52,40 @@ #define UPPERCASE(m_c) (((m_c)>='a' && (m_c)<='z')?((m_c)-('a'-'A')):(m_c)) #define LOWERCASE(m_c) (((m_c)>='A' && (m_c)<='Z')?((m_c)+('a'-'A')):(m_c)) + + + /** STRING **/ +bool CharString::operator<(const CharString& p_right) const { + + if (length()==0) { + return p_right.length()!=0; + } + + + const char *this_str=get_data(); + const char *that_str=get_data(); + while (true) { + + if (*that_str==0 && *this_str==0) + return false; //this can't be equal, sadly + else if (*this_str==0) + return true; //if this is empty, and the other one is not, then we're less.. I think? + else if (*that_str==0) + return false; //otherwise the other one is smaller.. + else if (*this_str < *that_str ) //more than + return true; + else if (*this_str > *that_str ) //less than + return false; + + this_str++; + that_str++; + } + + return false; //should never reach here anyway +} + const char *CharString::get_data() const { if (size()) diff --git a/core/ustring.h b/core/ustring.h index 5665a23112..87289f9e16 100644 --- a/core/ustring.h +++ b/core/ustring.h @@ -41,6 +41,8 @@ class CharString : public Vector<char> { public: + + bool operator<(const CharString& p_right) const; int length() const { return size() ? size()-1 : 0; } const char *get_data() const; operator const char*() {return get_data();}; |