summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gles2/rasterizer_gles2.cpp78
-rw-r--r--drivers/gles2/rasterizer_gles2.h2
-rw-r--r--drivers/jpegd/image_loader_jpegd.cpp54
-rw-r--r--drivers/nrex/regex.cpp9
-rw-r--r--drivers/nrex/regex.h1
-rw-r--r--drivers/openssl/stream_peer_openssl.cpp46
-rw-r--r--drivers/openssl/stream_peer_openssl.h1
-rw-r--r--drivers/png/SCsub11
-rw-r--r--drivers/register_driver_types.cpp1
-rw-r--r--drivers/theora/video_stream_theora.cpp3
-rw-r--r--drivers/unix/dir_access_unix.cpp7
-rw-r--r--drivers/unix/memory_pool_static_malloc.cpp29
-rw-r--r--drivers/unix/os_unix.cpp3
-rw-r--r--drivers/unix/thread_posix.cpp17
-rw-r--r--drivers/unix/thread_posix.h5
-rw-r--r--drivers/windows/dir_access_windows.cpp7
16 files changed, 191 insertions, 83 deletions
diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp
index 23d5860d2a..f9b58939dc 100644
--- a/drivers/gles2/rasterizer_gles2.cpp
+++ b/drivers/gles2/rasterizer_gles2.cpp
@@ -4781,9 +4781,12 @@ void RasterizerGLES2::_add_geometry( const Geometry* p_geometry, const InstanceD
if (has_blend_alpha || (has_base_alpha && m->depth_draw_mode!=VS::MATERIAL_DEPTH_DRAW_OPAQUE_PRE_PASS_ALPHA))
return; //bye
- if (m->shader_cache && !m->shader_cache->writes_vertex && !m->shader_cache->uses_discard && m->depth_draw_mode!=VS::MATERIAL_DEPTH_DRAW_OPAQUE_PRE_PASS_ALPHA) {
+ if (!m->shader_cache || (!m->shader_cache->writes_vertex && !m->shader_cache->uses_discard && m->depth_draw_mode!=VS::MATERIAL_DEPTH_DRAW_OPAQUE_PRE_PASS_ALPHA)) {
//shader does not use discard and does not write a vertex position, use generic material
- m = shadow_mat_ptr;
+ if (p_instance->cast_shadows == VS::SHADOW_CASTING_SETTING_DOUBLE_SIDED)
+ m = shadow_mat_double_sided_ptr;
+ else
+ m = shadow_mat_ptr;
if (m->last_pass!=frame) {
if (m->shader.is_valid()) {
@@ -6368,6 +6371,8 @@ void RasterizerGLES2::_render_list_forward(RenderList *p_render_list,const Trans
uint8_t prev_sort_flags=0xFF;
const BakedLightData *prev_baked_light=NULL;
RID prev_baked_light_texture;
+ const float *prev_morph_values=NULL;
+ int prev_receive_shadows_state=-1;
Geometry::Type prev_geometry_type=Geometry::GEOMETRY_INVALID;
@@ -6406,6 +6411,8 @@ void RasterizerGLES2::_render_list_forward(RenderList *p_render_list,const Trans
const Skeleton *skeleton = e->skeleton;
const Geometry *geometry_cmp = e->geometry_cmp;
const BakedLightData *baked_light = e->instance->baked_light;
+ const float *morph_values = e->instance->morph_values.ptr();
+ int receive_shadows_state = e->instance->receive_shadows == true ? 1 : 0;
bool rebind=false;
bool bind_baked_light_octree=false;
@@ -6428,6 +6435,8 @@ void RasterizerGLES2::_render_list_forward(RenderList *p_render_list,const Trans
prev_overrides=NULL; // make it diferent than NULL
prev_skeleton =NULL;
prev_sort_flags=0xFF;
+ prev_morph_values=NULL;
+ prev_receive_shadows_state=-1;
prev_geometry_type=Geometry::GEOMETRY_INVALID;
glEnable(GL_BLEND);
glDepthMask(GL_TRUE);
@@ -6436,7 +6445,7 @@ void RasterizerGLES2::_render_list_forward(RenderList *p_render_list,const Trans
}
- if (light_type!=prev_light_type) {
+ if (light_type!=prev_light_type || receive_shadows_state!=prev_receive_shadows_state) {
if (material->flags[VS::MATERIAL_FLAG_UNSHADED] || current_debug==VS::SCENARIO_DEBUG_SHADELESS) {
material_shader.set_conditional(MaterialShaderGLES2::LIGHT_TYPE_DIRECTIONAL,false);
@@ -6450,9 +6459,16 @@ void RasterizerGLES2::_render_list_forward(RenderList *p_render_list,const Trans
material_shader.set_conditional(MaterialShaderGLES2::LIGHT_TYPE_DIRECTIONAL,(light_type&0x3)==VS::LIGHT_DIRECTIONAL);
material_shader.set_conditional(MaterialShaderGLES2::LIGHT_TYPE_OMNI,(light_type&0x3)==VS::LIGHT_OMNI);
material_shader.set_conditional(MaterialShaderGLES2::LIGHT_TYPE_SPOT,(light_type&0x3)==VS::LIGHT_SPOT);
- material_shader.set_conditional(MaterialShaderGLES2::LIGHT_USE_SHADOW,(light_type&0x8));
- material_shader.set_conditional(MaterialShaderGLES2::LIGHT_USE_PSSM,(light_type&0x10));
- material_shader.set_conditional(MaterialShaderGLES2::LIGHT_USE_PSSM4,(light_type&0x20));
+ if (receive_shadows_state==1) {
+ material_shader.set_conditional(MaterialShaderGLES2::LIGHT_USE_SHADOW,(light_type&0x8));
+ material_shader.set_conditional(MaterialShaderGLES2::LIGHT_USE_PSSM,(light_type&0x10));
+ material_shader.set_conditional(MaterialShaderGLES2::LIGHT_USE_PSSM4,(light_type&0x20));
+ }
+ else {
+ material_shader.set_conditional(MaterialShaderGLES2::LIGHT_USE_SHADOW,false);
+ material_shader.set_conditional(MaterialShaderGLES2::LIGHT_USE_PSSM,false);
+ material_shader.set_conditional(MaterialShaderGLES2::LIGHT_USE_PSSM4,false);
+ }
material_shader.set_conditional(MaterialShaderGLES2::SHADELESS,false);
}
@@ -6650,10 +6666,15 @@ void RasterizerGLES2::_render_list_forward(RenderList *p_render_list,const Trans
}
rebind=true;
}
- if (use_hw_skeleton_xform && skeleton!=prev_skeleton) {
+
+ if (use_hw_skeleton_xform && (skeleton!=prev_skeleton||morph_values!=prev_morph_values)) {
if (!prev_skeleton || !skeleton)
rebind=true; //went from skeleton <-> no skeleton, needs rebind
- _setup_skeleton(skeleton);
+
+ if (morph_values==NULL)
+ _setup_skeleton(skeleton);
+ else
+ _setup_skeleton(NULL);
}
if (material!=prev_material || rebind) {
@@ -6726,10 +6747,6 @@ void RasterizerGLES2::_render_list_forward(RenderList *p_render_list,const Trans
if (i==0 || rebind) {
material_shader.set_uniform(MaterialShaderGLES2::CAMERA_INVERSE_TRANSFORM, p_view_transform_inverse);
material_shader.set_uniform(MaterialShaderGLES2::PROJECTION_TRANSFORM, p_projection);
- if (skeleton && use_hw_skeleton_xform) {
- material_shader.set_uniform(MaterialShaderGLES2::SKELETON_MATRICES,GL_TEXTURE0+max_texture_units-2);
- material_shader.set_uniform(MaterialShaderGLES2::SKELTEX_PIXEL_SIZE,skeleton->pixel_size);
- }
if (!shadow) {
if (!additive && current_env && current_env->fx_enabled[VS::ENV_FX_AMBIENT_LIGHT]) {
@@ -6744,6 +6761,13 @@ void RasterizerGLES2::_render_list_forward(RenderList *p_render_list,const Trans
_rinfo.shader_change_count++;
}
+ if (skeleton != prev_skeleton || rebind) {
+ if (skeleton && morph_values == NULL) {
+ material_shader.set_uniform(MaterialShaderGLES2::SKELETON_MATRICES, max_texture_units - 2);
+ material_shader.set_uniform(MaterialShaderGLES2::SKELTEX_PIXEL_SIZE, skeleton->pixel_size);
+ }
+ }
+
if (e->instance->billboard || e->instance->depth_scale) {
Transform xf=e->instance->transform;
@@ -6795,7 +6819,9 @@ void RasterizerGLES2::_render_list_forward(RenderList *p_render_list,const Trans
prev_light_type=e->light_type;
prev_sort_flags=sort_flags;
prev_baked_light=baked_light;
+ prev_morph_values=morph_values;
// prev_geometry_type=geometry->type;
+ prev_receive_shadows_state=receive_shadows_state;
}
//print_line("shaderchanges: "+itos(p_alpha_pass)+": "+itos(_rinfo.shader_change_count));
@@ -7099,11 +7125,13 @@ void RasterizerGLES2::_draw_tex_bg() {
copy_shader.set_uniform(CopyShaderGLES2::ENERGY,nrg);
copy_shader.set_uniform(CopyShaderGLES2::CUSTOM_ALPHA,float(current_env->bg_param[VS::ENV_BG_PARAM_GLOW]));
+ float flip_sign = (current_env->bg_mode==VS::ENV_BG_TEXTURE && current_rt && current_rt_vflip)?-1:1;
+
Vector3 vertices[4]={
- Vector3(-1,-1,1),
- Vector3( 1,-1,1),
- Vector3( 1, 1,1),
- Vector3(-1, 1,1)
+ Vector3(-1,-1*flip_sign,1),
+ Vector3( 1,-1*flip_sign,1),
+ Vector3( 1, 1*flip_sign,1),
+ Vector3(-1, 1*flip_sign,1)
};
@@ -7249,7 +7277,7 @@ void RasterizerGLES2::end_scene() {
bgcolor = current_env->bg_param[VS::ENV_BG_PARAM_COLOR];
else
bgcolor = Globals::get_singleton()->get("render/default_clear_color");
- bgcolor = _convert_color(bgcolor);
+ bgcolor = _convert_color(bgcolor);
float a = use_fb ? float(current_env->bg_param[VS::ENV_BG_PARAM_GLOW]) : 1.0;
glClearColor(bgcolor.r,bgcolor.g,bgcolor.b,a);
_glClearDepth(1.0);
@@ -10828,7 +10856,6 @@ void RasterizerGLES2::init() {
use_depth24 =true;
s3tc_supported = true;
atitc_supported = false;
- use_hw_skeleton_xform = false;
// use_texture_instancing=false;
// use_attribute_instancing=true;
use_texture_instancing=false;
@@ -10839,7 +10866,11 @@ void RasterizerGLES2::init() {
s3tc_srgb_supported=true;
use_anisotropic_filter=true;
float_linear_supported=true;
- float_supported=true;
+
+ GLint vtf;
+ glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS,&vtf);
+ float_supported = extensions.has("GL_OES_texture_float") || extensions.has("GL_ARB_texture_float");
+ use_hw_skeleton_xform=vtf>0 && float_supported;
read_depth_supported=_test_depth_shadow_buffer();
use_rgba_shadowmaps=!read_depth_supported;
@@ -10889,7 +10920,7 @@ void RasterizerGLES2::init() {
GLint vtf;
glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS,&vtf);
- float_supported = extensions.has("GL_OES_texture_float");
+ float_supported = extensions.has("GL_OES_texture_float") || extensions.has("GL_ARB_texture_float");
use_hw_skeleton_xform=vtf>0 && float_supported;
float_linear_supported = extensions.has("GL_OES_texture_float_linear");
@@ -10922,7 +10953,6 @@ void RasterizerGLES2::init() {
//etc_supported=false;
- use_hw_skeleton_xform=false;
#endif
@@ -10964,6 +10994,12 @@ void RasterizerGLES2::init() {
shadow_material = material_create(); //empty with nothing
shadow_mat_ptr = material_owner.get(shadow_material);
+
+ // Now create a second shadow material for double-sided shadow instances
+ shadow_material_double_sided = material_create();
+ shadow_mat_double_sided_ptr = material_owner.get(shadow_material_double_sided);
+ shadow_mat_double_sided_ptr->flags[VS::MATERIAL_FLAG_DOUBLE_SIDED] = true;
+
overdraw_material = create_overdraw_debug_material();
copy_shader.set_conditional(CopyShaderGLES2::USE_8BIT_HDR,!use_fp16_fb);
canvas_shader.set_conditional(CanvasShaderGLES2::USE_DEPTH_SHADOWS,read_depth_supported);
diff --git a/drivers/gles2/rasterizer_gles2.h b/drivers/gles2/rasterizer_gles2.h
index 0f70ceaa97..2a2f587f11 100644
--- a/drivers/gles2/rasterizer_gles2.h
+++ b/drivers/gles2/rasterizer_gles2.h
@@ -829,7 +829,9 @@ class RasterizerGLES2 : public Rasterizer {
bool fragment_lighting;
RID shadow_material;
+ RID shadow_material_double_sided;
Material *shadow_mat_ptr;
+ Material *shadow_mat_double_sided_ptr;
int max_texture_units;
GLuint base_framebuffer;
diff --git a/drivers/jpegd/image_loader_jpegd.cpp b/drivers/jpegd/image_loader_jpegd.cpp
index 9d1263b81b..5339e9f69d 100644
--- a/drivers/jpegd/image_loader_jpegd.cpp
+++ b/drivers/jpegd/image_loader_jpegd.cpp
@@ -17,23 +17,9 @@
#include <string.h>
-Error ImageLoaderJPG::load_image(Image *p_image,FileAccess *f) {
-
-
- DVector<uint8_t> src_image;
- int src_image_len = f->get_len();
- ERR_FAIL_COND_V(src_image_len == 0, ERR_FILE_CORRUPT);
- src_image.resize(src_image_len);
-
- DVector<uint8_t>::Write w = src_image.write();
-
- f->get_buffer(&w[0],src_image_len);
-
- f->close();
-
+Error jpeg_load_image_from_buffer(Image *p_image,const uint8_t* p_buffer, int p_buffer_len) {
-
- jpgd::jpeg_decoder_mem_stream mem_stream(w.ptr(),src_image_len);
+ jpgd::jpeg_decoder_mem_stream mem_stream(p_buffer,p_buffer_len);
jpgd::jpeg_decoder decoder(&mem_stream);
@@ -85,14 +71,36 @@ Error ImageLoaderJPG::load_image(Image *p_image,FileAccess *f) {
fmt=Image::FORMAT_RGBA;
dw = DVector<uint8_t>::Write();
- w = DVector<uint8_t>::Write();
-
p_image->create(image_width,image_height,0,fmt,data);
return OK;
}
+
+Error ImageLoaderJPG::load_image(Image *p_image,FileAccess *f) {
+
+
+ DVector<uint8_t> src_image;
+ int src_image_len = f->get_len();
+ ERR_FAIL_COND_V(src_image_len == 0, ERR_FILE_CORRUPT);
+ src_image.resize(src_image_len);
+
+ DVector<uint8_t>::Write w = src_image.write();
+
+ f->get_buffer(&w[0],src_image_len);
+
+ f->close();
+
+
+ Error err = jpeg_load_image_from_buffer(p_image,w.ptr(),src_image_len);
+
+ w = DVector<uint8_t>::Write();
+
+ return err;
+
+}
+
void ImageLoaderJPG::get_recognized_extensions(List<String> *p_extensions) const {
p_extensions->push_back("jpg");
@@ -100,9 +108,17 @@ void ImageLoaderJPG::get_recognized_extensions(List<String> *p_extensions) const
}
-ImageLoaderJPG::ImageLoaderJPG() {
+static Image _jpegd_mem_loader_func(const uint8_t* p_png,int p_size) {
+
+ Image img;
+ Error err = jpeg_load_image_from_buffer(&img,p_png,p_size);
+ return img;
+}
+
+ImageLoaderJPG::ImageLoaderJPG() {
+ Image::_jpg_mem_loader_func=_jpegd_mem_loader_func;
}
diff --git a/drivers/nrex/regex.cpp b/drivers/nrex/regex.cpp
index 459cf28e1e..5d6c9583ef 100644
--- a/drivers/nrex/regex.cpp
+++ b/drivers/nrex/regex.cpp
@@ -21,6 +21,7 @@ void RegEx::_bind_methods() {
ObjectTypeDB::bind_method(_MD("is_valid"),&RegEx::is_valid);
ObjectTypeDB::bind_method(_MD("get_capture_count"),&RegEx::get_capture_count);
ObjectTypeDB::bind_method(_MD("get_capture","capture"),&RegEx::get_capture);
+ ObjectTypeDB::bind_method(_MD("get_capture_start","capture"),&RegEx::get_capture_start);
ObjectTypeDB::bind_method(_MD("get_captures"),&RegEx::_bind_get_captures);
};
@@ -68,6 +69,14 @@ String RegEx::get_capture(int capture) const {
}
+int RegEx::get_capture_start(int capture) const {
+
+ ERR_FAIL_COND_V( get_capture_count() <= capture, -1 );
+
+ return captures[capture].start;
+
+}
+
Error RegEx::compile(const String& p_pattern, int capture) {
clear();
diff --git a/drivers/nrex/regex.h b/drivers/nrex/regex.h
index ae8d40ceab..4b063f0bf1 100644
--- a/drivers/nrex/regex.h
+++ b/drivers/nrex/regex.h
@@ -35,6 +35,7 @@ public:
void clear();
bool is_valid() const;
int get_capture_count() const;
+ int get_capture_start(int capture) const;
String get_capture(int capture) const;
Error compile(const String& p_pattern, int capture = 9);
int find(const String& p_text, int p_start = 0, int p_end = -1) const;
diff --git a/drivers/openssl/stream_peer_openssl.cpp b/drivers/openssl/stream_peer_openssl.cpp
index 81795fdc60..aad3a11b7e 100644
--- a/drivers/openssl/stream_peer_openssl.cpp
+++ b/drivers/openssl/stream_peer_openssl.cpp
@@ -532,8 +532,26 @@ StreamPeerSSL* StreamPeerOpenSSL::_create_func() {
Vector<X509*> StreamPeerOpenSSL::certs;
+void StreamPeerOpenSSL::_load_certs(const ByteArray& p_array) {
+
+ ByteArray::Read r = p_array.read();
+ BIO* mem = BIO_new(BIO_s_mem());
+ BIO_puts(mem,(const char*)r.ptr());
+ while(true) {
+ X509*cert = PEM_read_bio_X509(mem, NULL, 0, NULL);
+ if (!cert)
+ break;
+ certs.push_back(cert);
+ }
+ BIO_free(mem);
+}
+
void StreamPeerOpenSSL::initialize_ssl() {
+ available=true;
+
+ load_certs_func=_load_certs;
+
_create=_create_func;
CRYPTO_malloc_init(); // Initialize malloc, free, etc for OpenSSL's use
SSL_library_init(); // Initialize OpenSSL's SSL libraries
@@ -544,20 +562,24 @@ void StreamPeerOpenSSL::initialize_ssl() {
Globals::get_singleton()->set_custom_property_info("ssl/certificates",PropertyInfo(Variant::STRING,"ssl/certificates",PROPERTY_HINT_FILE,"*.crt"));
if (certs_path!="") {
- Vector<uint8_t> data = FileAccess::get_file_as_array(certs_path);;
- if (data.size()) {
- data.push_back(0);
- BIO* mem = BIO_new(BIO_s_mem());
- BIO_puts(mem,(const char*) data.ptr());
- while(true) {
- X509*cert = PEM_read_bio_X509(mem, NULL, 0, NULL);
- if (!cert)
- break;
- certs.push_back(cert);
+
+
+ FileAccess *f=FileAccess::open(certs_path,FileAccess::READ);
+ if (f) {
+ ByteArray arr;
+ int flen = f->get_len();
+ arr.resize(flen+1);
+ {
+ ByteArray::Write w = arr.write();
+ f->get_buffer(w.ptr(),flen);
+ w[flen]=0; //end f string
}
- BIO_free(mem);
+
+ memdelete(f);
+
+ _load_certs(arr);
+ print_line("Loaded certs from '"+certs_path+"': "+itos(certs.size()));
}
- print_line("Loaded certs from '"+certs_path+"': "+itos(certs.size()));
}
String config_path =GLOBAL_DEF("ssl/config","");
Globals::get_singleton()->set_custom_property_info("ssl/config",PropertyInfo(Variant::STRING,"ssl/config",PROPERTY_HINT_FILE,"*.cnf"));
diff --git a/drivers/openssl/stream_peer_openssl.h b/drivers/openssl/stream_peer_openssl.h
index 64f5a1d7ac..20266ee584 100644
--- a/drivers/openssl/stream_peer_openssl.h
+++ b/drivers/openssl/stream_peer_openssl.h
@@ -54,6 +54,7 @@ private:
static Vector<X509*> certs;
+ static void _load_certs(const ByteArray& p_array);
protected:
static void _bind_methods();
public:
diff --git a/drivers/png/SCsub b/drivers/png/SCsub
index 5532e28ade..df521de3eb 100644
--- a/drivers/png/SCsub
+++ b/drivers/png/SCsub
@@ -22,17 +22,16 @@ png_sources = [
"png/image_loader_png.cpp"
]
-if ("neon_enabled" in env and env["neon_enabled"]):
+# Currently .ASM filter_neon.S does not compile on NT.
+import os
+if ("neon_enabled" in env and env["neon_enabled"]) and os.name!="nt":
env.Append(CPPFLAGS=["-DPNG_ARM_NEON_OPT=2"])
env_neon = env.Clone();
if "S_compiler" in env:
env_neon['CC'] = env['S_compiler']
#env_neon.Append(CPPFLAGS=["-DPNG_ARM_NEON"])
- import os
- # Currently .ASM filter_neon.S does not compile on NT.
- if (os.name!="nt"):
- png_sources.append(env_neon.Object("#drivers/png/arm/arm_init.c"))
- png_sources.append(env_neon.Object("#drivers/png/arm/filter_neon.S"))
+ png_sources.append(env_neon.Object("#drivers/png/arm/arm_init.c"))
+ png_sources.append(env_neon.Object("#drivers/png/arm/filter_neon.S"))
else:
env.Append(CPPFLAGS=["-DPNG_ARM_NEON_OPT=0"])
diff --git a/drivers/register_driver_types.cpp b/drivers/register_driver_types.cpp
index e7bbf28f01..235438f126 100644
--- a/drivers/register_driver_types.cpp
+++ b/drivers/register_driver_types.cpp
@@ -31,7 +31,6 @@
#endif
#ifdef TOOLS_ENABLED
-#include "pe_bliss/pe_bliss_godot.h"
#include "platform/windows/export/export.h"
#endif
diff --git a/drivers/theora/video_stream_theora.cpp b/drivers/theora/video_stream_theora.cpp
index 1d2e6b9dda..e577c3f932 100644
--- a/drivers/theora/video_stream_theora.cpp
+++ b/drivers/theora/video_stream_theora.cpp
@@ -489,6 +489,9 @@ Ref<Texture> VideoStreamPlaybackTheora::get_texture() {
void VideoStreamPlaybackTheora::update(float p_delta) {
+ if (!file)
+ return;
+
if (!playing || paused) {
//printf("not playing\n");
return;
diff --git a/drivers/unix/dir_access_unix.cpp b/drivers/unix/dir_access_unix.cpp
index 23a63be339..8b097ad25e 100644
--- a/drivers/unix/dir_access_unix.cpp
+++ b/drivers/unix/dir_access_unix.cpp
@@ -292,8 +292,11 @@ Error DirAccessUnix::rename(String p_path,String p_new_path) {
}
Error DirAccessUnix::remove(String p_path) {
- p_path=fix_path(p_path);
-
+ if (p_path.is_rel_path())
+ p_path=get_current_dir().plus_file(p_path);
+ else
+ p_path=fix_path(p_path);
+
struct stat flags;
if ((stat(p_path.utf8().get_data(),&flags)!=0))
return FAILED;
diff --git a/drivers/unix/memory_pool_static_malloc.cpp b/drivers/unix/memory_pool_static_malloc.cpp
index 1a79272dc1..f89b55de12 100644
--- a/drivers/unix/memory_pool_static_malloc.cpp
+++ b/drivers/unix/memory_pool_static_malloc.cpp
@@ -48,7 +48,12 @@ void* MemoryPoolStaticMalloc::alloc(size_t p_bytes,const char *p_description) {
#else
- int total = p_bytes + DEFAULT_ALIGNMENT;
+ size_t total;
+ #if defined(_add_overflow)
+ if (_add_overflow(p_bytes, DEFAULT_ALIGNMENT, &total)) return NULL;
+ #else
+ total = p_bytes + DEFAULT_ALIGNMENT;
+ #endif
uint8_t* ptr = (uint8_t*)_alloc(total, p_description);
ERR_FAIL_COND_V( !ptr, ptr );
int ofs = (DEFAULT_ALIGNMENT - ((uintptr_t)ptr & (DEFAULT_ALIGNMENT - 1)));
@@ -64,11 +69,18 @@ void* MemoryPoolStaticMalloc::_alloc(size_t p_bytes,const char *p_description) {
MutexLock lock(mutex);
#ifdef DEBUG_MEMORY_ENABLED
- void *mem=malloc(p_bytes+sizeof(RingPtr)); /// add for size and ringlist
+
+ size_t total;
+ #if defined(_add_overflow)
+ if (_add_overflow(p_bytes, sizeof(RingPtr), &total)) return NULL;
+ #else
+ total = p_bytes + sizeof(RingPtr);
+ #endif
+ void *mem=malloc(total); /// add for size and ringlist
if (!mem) {
- printf("**ERROR: out of memory while allocating %i bytes by %s?\n",(int) p_bytes, p_description);
- printf("**ERROR: memory usage is %i\n", (int)get_total_usage());
+ printf("**ERROR: out of memory while allocating %lu bytes by %s?\n", (unsigned long) p_bytes, p_description);
+ printf("**ERROR: memory usage is %lu\n", (unsigned long) get_total_usage());
};
ERR_FAIL_COND_V(!mem,0); //out of memory, or unreasonable request
@@ -129,7 +141,12 @@ void* MemoryPoolStaticMalloc::realloc(void *p_memory,size_t p_bytes) {
if (!p_memory)
return alloc(p_bytes);
- int total = p_bytes + DEFAULT_ALIGNMENT;
+ size_t total;
+ #if defined(_add_overflow)
+ if (_add_overflow(p_bytes, DEFAULT_ALIGNMENT, &total)) return NULL;
+ #else
+ total = p_bytes + DEFAULT_ALIGNMENT;
+ #endif
uint8_t* mem = (uint8_t*)p_memory;
int ofs = *(mem-1);
mem = mem - ofs;
@@ -321,7 +338,7 @@ size_t MemoryPoolStaticMalloc::get_max_usage() {
/* Most likely available only if memory debugger was compiled in */
int MemoryPoolStaticMalloc::get_alloc_count() {
- return 0;
+ return total_pointers;
}
void * MemoryPoolStaticMalloc::get_alloc_ptr(int p_alloc_idx) {
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp
index a004a116e0..84b6dc24dc 100644
--- a/drivers/unix/os_unix.cpp
+++ b/drivers/unix/os_unix.cpp
@@ -251,6 +251,9 @@ OS::Date OS_Unix::get_date(bool utc) const {
lt=localtime(&t);
Date ret;
ret.year=1900+lt->tm_year;
+ // Index starting at 1 to match OS_Unix::get_date
+ // and Windows SYSTEMTIME and tm_mon follows the typical structure
+ // of 0-11, noted here: http://www.cplusplus.com/reference/ctime/tm/
ret.month=(Month)(lt->tm_mon + 1);
ret.day=lt->tm_mday;
ret.weekday=(Weekday)lt->tm_wday;
diff --git a/drivers/unix/thread_posix.cpp b/drivers/unix/thread_posix.cpp
index bd33c81298..6ace64a923 100644
--- a/drivers/unix/thread_posix.cpp
+++ b/drivers/unix/thread_posix.cpp
@@ -81,9 +81,9 @@ void ThreadPosix::wait_to_finish_func_posix(Thread* p_thread) {
tp->pthread=0;
}
-Error ThreadPosix::set_name(const String& p_name) {
+Error ThreadPosix::set_name_func_posix(const String& p_name) {
- ERR_FAIL_COND_V(pthread == 0, ERR_UNCONFIGURED);
+ pthread_t running_thread = pthread_self();
#ifdef PTHREAD_NO_RENAME
return ERR_UNAVAILABLE;
@@ -93,22 +93,15 @@ Error ThreadPosix::set_name(const String& p_name) {
#ifdef PTHREAD_RENAME_SELF
// check if thread is the same as caller
- int caller = Thread::get_caller_ID();
- int self = get_ID();
- if (caller != self) {
- ERR_EXPLAIN("On this platform, thread can only be renamed with calls from the threads to be renamed.");
- ERR_FAIL_V(ERR_UNAVAILABLE);
- return ERR_UNAVAILABLE;
- };
int err = pthread_setname_np(p_name.utf8().get_data());
#else
#ifdef PTHREAD_BSD_SET_NAME
- pthread_set_name_np(pthread, p_name.utf8().get_data());
+ pthread_set_name_np(running_thread, p_name.utf8().get_data());
int err = 0; // Open/FreeBSD ignore errors in this function
#else
- int err = pthread_setname_np(pthread, p_name.utf8().get_data());
+ int err = pthread_setname_np(running_thread, p_name.utf8().get_data());
#endif // PTHREAD_BSD_SET_NAME
#endif // PTHREAD_RENAME_SELF
@@ -123,7 +116,7 @@ void ThreadPosix::make_default() {
create_func=create_func_posix;
get_thread_ID_func=get_thread_ID_func_posix;
wait_to_finish_func=wait_to_finish_func_posix;
-
+ set_name_func = set_name_func_posix;
}
ThreadPosix::ThreadPosix() {
diff --git a/drivers/unix/thread_posix.h b/drivers/unix/thread_posix.h
index 179d56d5bd..06a17c2ae6 100644
--- a/drivers/unix/thread_posix.h
+++ b/drivers/unix/thread_posix.h
@@ -55,13 +55,14 @@ class ThreadPosix : public Thread {
static Thread* create_func_posix(ThreadCreateCallback p_callback,void *,const Settings&);
static ID get_thread_ID_func_posix();
static void wait_to_finish_func_posix(Thread* p_thread);
-
+
+ static Error set_name_func_posix(const String& p_name);
+
ThreadPosix();
public:
virtual ID get_ID() const;
- Error set_name(const String& p_name);
static void make_default();
diff --git a/drivers/windows/dir_access_windows.cpp b/drivers/windows/dir_access_windows.cpp
index 0a413979fc..b9476b870b 100644
--- a/drivers/windows/dir_access_windows.cpp
+++ b/drivers/windows/dir_access_windows.cpp
@@ -310,8 +310,11 @@ Error DirAccessWindows::rename(String p_path,String p_new_path) {
Error DirAccessWindows::remove(String p_path) {
- p_path=fix_path(p_path);
-
+ if (p_path.is_rel_path())
+ p_path=get_current_dir().plus_file(p_path);
+ else
+ p_path=fix_path(p_path);
+
printf("erasing %s\n",p_path.utf8().get_data());
//WIN32_FILE_ATTRIBUTE_DATA fileInfo;
//DWORD fileAttr = GetFileAttributesExW(p_path.c_str(), GetFileExInfoStandard, &fileInfo);