commit
5676632a3b
6 changed files with 19 additions and 16 deletions
|
@ -850,17 +850,16 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
|
||||||
} break;
|
} break;
|
||||||
case Variant::INT: {
|
case Variant::INT: {
|
||||||
|
|
||||||
int64_t val = p_variant;
|
|
||||||
if (flags & ENCODE_FLAG_64) {
|
if (flags & ENCODE_FLAG_64) {
|
||||||
//64 bits
|
//64 bits
|
||||||
if (buf) {
|
if (buf) {
|
||||||
encode_uint64(val, buf);
|
encode_uint64(p_variant.operator int64_t(), buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
r_len += 8;
|
r_len += 8;
|
||||||
} else {
|
} else {
|
||||||
if (buf) {
|
if (buf) {
|
||||||
encode_uint32(int32_t(val), buf);
|
encode_uint32(p_variant.operator int32_t(), buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
r_len += 4;
|
r_len += 4;
|
||||||
|
|
|
@ -57,9 +57,7 @@ class RWLockRead {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RWLockRead(const RWLock *p_lock) {
|
RWLockRead(const RWLock *p_lock) {
|
||||||
if (p_lock) {
|
lock = const_cast<RWLock *>(p_lock);
|
||||||
lock = const_cast<RWLock *>(p_lock);
|
|
||||||
}
|
|
||||||
if (lock) lock->read_lock();
|
if (lock) lock->read_lock();
|
||||||
}
|
}
|
||||||
~RWLockRead() {
|
~RWLockRead() {
|
||||||
|
|
|
@ -309,7 +309,7 @@ Error DirAccessUnix::change_dir(String p_dir) {
|
||||||
// prev_dir is the directory we are changing out of
|
// prev_dir is the directory we are changing out of
|
||||||
String prev_dir;
|
String prev_dir;
|
||||||
char real_current_dir_name[2048];
|
char real_current_dir_name[2048];
|
||||||
getcwd(real_current_dir_name, 2048);
|
ERR_FAIL_COND_V(getcwd(real_current_dir_name, 2048) == NULL, ERR_BUG);
|
||||||
if (prev_dir.parse_utf8(real_current_dir_name))
|
if (prev_dir.parse_utf8(real_current_dir_name))
|
||||||
prev_dir = real_current_dir_name; //no utf8, maybe latin?
|
prev_dir = real_current_dir_name; //no utf8, maybe latin?
|
||||||
|
|
||||||
|
@ -330,7 +330,7 @@ Error DirAccessUnix::change_dir(String p_dir) {
|
||||||
|
|
||||||
// the directory exists, so set current_dir to try_dir
|
// the directory exists, so set current_dir to try_dir
|
||||||
current_dir = try_dir;
|
current_dir = try_dir;
|
||||||
chdir(prev_dir.utf8().get_data());
|
ERR_FAIL_COND_V(chdir(prev_dir.utf8().get_data()) != 0, ERR_BUG);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -405,7 +405,7 @@ DirAccessUnix::DirAccessUnix() {
|
||||||
|
|
||||||
// set current directory to an absolute path of the current directory
|
// set current directory to an absolute path of the current directory
|
||||||
char real_current_dir_name[2048];
|
char real_current_dir_name[2048];
|
||||||
getcwd(real_current_dir_name, 2048);
|
ERR_FAIL_COND(getcwd(real_current_dir_name, 2048) == NULL);
|
||||||
if (current_dir.parse_utf8(real_current_dir_name))
|
if (current_dir.parse_utf8(real_current_dir_name))
|
||||||
current_dir = real_current_dir_name;
|
current_dir = real_current_dir_name;
|
||||||
|
|
||||||
|
|
|
@ -487,9 +487,11 @@ String OS_Unix::get_executable_path() const {
|
||||||
//fix for running from a symlink
|
//fix for running from a symlink
|
||||||
char buf[256];
|
char buf[256];
|
||||||
memset(buf, 0, 256);
|
memset(buf, 0, 256);
|
||||||
readlink("/proc/self/exe", buf, sizeof(buf));
|
ssize_t len = readlink("/proc/self/exe", buf, sizeof(buf));
|
||||||
String b;
|
String b;
|
||||||
b.parse_utf8(buf);
|
if (len > 0) {
|
||||||
|
b.parse_utf8(buf, len);
|
||||||
|
}
|
||||||
if (b == "") {
|
if (b == "") {
|
||||||
WARN_PRINT("Couldn't get executable path from /proc/self/exe, using argv[0]");
|
WARN_PRINT("Couldn't get executable path from /proc/self/exe, using argv[0]");
|
||||||
return OS::get_executable_path();
|
return OS::get_executable_path();
|
||||||
|
|
|
@ -80,9 +80,12 @@ Error LWSClient::connect_to_host(String p_host, String p_path, uint16_t p_port,
|
||||||
char hbuf[1024];
|
char hbuf[1024];
|
||||||
char pbuf[2048];
|
char pbuf[2048];
|
||||||
String addr_str = (String)addr;
|
String addr_str = (String)addr;
|
||||||
strncpy(abuf, addr_str.ascii().get_data(), 1024);
|
strncpy(abuf, addr_str.ascii().get_data(), 1023);
|
||||||
strncpy(hbuf, p_host.utf8().get_data(), 1024);
|
abuf[1023] = '\0';
|
||||||
strncpy(pbuf, p_path.utf8().get_data(), 2048);
|
strncpy(hbuf, p_host.utf8().get_data(), 1023);
|
||||||
|
hbuf[1023] = '\0';
|
||||||
|
strncpy(pbuf, p_path.utf8().get_data(), 2047);
|
||||||
|
pbuf[2047] = '\0';
|
||||||
|
|
||||||
i.context = context;
|
i.context = context;
|
||||||
if (p_protocols.size() > 0)
|
if (p_protocols.size() > 0)
|
||||||
|
|
|
@ -43,7 +43,7 @@ int main(int argc, char *argv[]) {
|
||||||
setlocale(LC_CTYPE, "");
|
setlocale(LC_CTYPE, "");
|
||||||
|
|
||||||
char *cwd = (char *)malloc(PATH_MAX);
|
char *cwd = (char *)malloc(PATH_MAX);
|
||||||
getcwd(cwd, PATH_MAX);
|
char *ret = getcwd(cwd, PATH_MAX);
|
||||||
|
|
||||||
Error err = Main::setup(argv[0], argc - 1, &argv[1]);
|
Error err = Main::setup(argv[0], argc - 1, &argv[1]);
|
||||||
if (err != OK) {
|
if (err != OK) {
|
||||||
|
@ -55,7 +55,8 @@ int main(int argc, char *argv[]) {
|
||||||
os.run(); // it is actually the OS that decides how to run
|
os.run(); // it is actually the OS that decides how to run
|
||||||
Main::cleanup();
|
Main::cleanup();
|
||||||
|
|
||||||
chdir(cwd);
|
if (ret)
|
||||||
|
chdir(cwd);
|
||||||
free(cwd);
|
free(cwd);
|
||||||
|
|
||||||
return os.get_exit_code();
|
return os.get_exit_code();
|
||||||
|
|
Loading…
Reference in a new issue