Skip to content

Commit

Permalink
-renamed globals.h to global_config.cpp (this seems to have caused a …
Browse files Browse the repository at this point in the history
…few modified files)

-.pck and .zip exporting redone, seems to be working..
  • Loading branch information
reduz committed Feb 21, 2017
1 parent 6e2bf31 commit de0045c
Show file tree
Hide file tree
Showing 121 changed files with 542 additions and 226 deletions.
4 changes: 2 additions & 2 deletions core/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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()


Expand Down
2 changes: 1 addition & 1 deletion core/bind/core_bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
137 changes: 53 additions & 84 deletions core/globals.cpp → core/global_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -247,40 +247,47 @@ 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!="") {

bool ok = _load_resource_pack(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"));

}

return OK;

}

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"));

}

Expand All @@ -292,99 +299,61 @@ 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");

}

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
Expand Down
4 changes: 2 additions & 2 deletions core/globals.h → core/global_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion core/input_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/*************************************************************************/
#include "input_map.h"

#include "globals.h"
#include "global_config.h"
#include "os/keyboard.h"

InputMap *InputMap::singleton=NULL;
Expand Down
2 changes: 1 addition & 1 deletion core/io/file_access_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion core/io/file_access_network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
6 changes: 3 additions & 3 deletions core/io/file_access_pack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#include <stdio.h>

#define PACK_VERSION 0
#define PACK_VERSION 1

Error PackedData::add_pack(const String& p_path) {

Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion core/io/packet_peer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "packet_peer.h"

#include "io/marshalls.h"
#include "globals.h"
#include "global_config.h"
/* helpers / binders */


Expand Down
2 changes: 1 addition & 1 deletion core/io/resource_format_binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion core/io/resource_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion core/io/resource_saver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion core/message_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/*************************************************************************/
#include "message_queue.h"

#include "globals.h"
#include "global_config.h"
#include "script_language.h"

MessageQueue *MessageQueue::singleton=NULL;
Expand Down
2 changes: 1 addition & 1 deletion core/os/dir_access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion core/os/file_access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion core/os/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion core/os/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion core/register_core_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion core/script_debugger_remote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion core/translation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/*************************************************************************/
#include "translation.h"

#include "globals.h"
#include "global_config.h"
#include "io/resource_loader.h"
#include "os/os.h"

Expand Down
Loading

0 comments on commit de0045c

Please sign in to comment.