diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/globals.cpp | 5 | ||||
-rw-r--r-- | core/io/file_access_pack.cpp | 11 | ||||
-rw-r--r-- | core/math/math_funcs.cpp | 3 |
3 files changed, 14 insertions, 5 deletions
diff --git a/core/globals.cpp b/core/globals.cpp index 85e03ead81..2eb26a7b19 100644 --- a/core/globals.cpp +++ b/core/globals.cpp @@ -319,11 +319,13 @@ Error Globals::setup(const String& p_path) { String candidate = d->get_current_dir(); String current_dir = d->get_current_dir(); bool found = false; + bool first_time=true; while(true) { //try to load settings in ascending through dirs shape! - if (_load_resource_pack(current_dir+"/data.pck") || _load_resource_pack(current_dir+"/data.pcz")) { + //tries to open pack, but only first time + if (first_time && _load_resource_pack(current_dir+"/data.pck")) { if (_load_settings("res://engine.cfg")==OK || _load_settings_binary("res://engine.cfb")==OK) { _load_settings("res://override.cfg"); @@ -344,6 +346,7 @@ Error Globals::setup(const String& p_path) { if (d->get_current_dir()==current_dir) break; //not doing anything useful current_dir=d->get_current_dir(); + first_time=false; } diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index 4ae60947fa..edecbb6a3e 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -31,6 +31,8 @@ #include <stdio.h> +#define PACK_VERSION 0 + Error PackedData::add_pack(const String& p_path) { for (int i=0; i<sources.size(); i++) { @@ -113,12 +115,12 @@ bool PackedSourcePCK::try_open_pack(const String& p_path) { uint32_t magic= f->get_32(); - if (magic != 0x4b435047) { + if (magic != 0x43504447) { //maybe at he end.... self contained exe f->seek_end(); f->seek( f->get_pos() -4 ); magic = f->get_32(); - if (magic != 0x4b435047) { + if (magic != 0x43504447) { memdelete(f); return false; @@ -130,7 +132,7 @@ bool PackedSourcePCK::try_open_pack(const String& p_path) { f->seek( f->get_pos() -ds-8 ); magic = f->get_32(); - if (magic != 0x4b435047) { + if (magic != 0x43504447) { memdelete(f); return false; @@ -138,10 +140,13 @@ bool PackedSourcePCK::try_open_pack(const String& p_path) { } + uint32_t version = f->get_32(); uint32_t ver_major = f->get_32(); 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 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/math/math_funcs.cpp b/core/math/math_funcs.cpp index 2ba36e5a49..5d3887d72c 100644 --- a/core/math/math_funcs.cpp +++ b/core/math/math_funcs.cpp @@ -75,7 +75,8 @@ void Math::seed(uint32_t x) { void Math::randomize() { - seed(OS::get_singleton()->get_ticks_usec()); /* *OS::get_singleton()->get_time().sec); // windows doesn't have get_time(), returns always 0 */ + OS::Time time = OS::get_singleton()->get_time(); + seed(OS::get_singleton()->get_ticks_usec()*time.hour*time.min*time.sec*rand()); /* *OS::get_singleton()->get_time().sec); // windows doesn't have get_time(), returns always 0 */ } uint32_t Math::rand() { |