Unverified Commit 1337a4f4 authored by Libretro-Admin's avatar Libretro-Admin Committed by GitHub
Browse files

Merge pull request #24 from BringerethOfLight/master

fixes some of the remaining memory access issues
parents 359b5137 44fc059d
DEBUG=0
PERF_TEST=0
HAVE_SHARED_CONTEXT=0
HAVE_OPENGL=1
FORCE_GLES=0
HAVE_LIBCURL=0
DEBUG ?= 0
PERF_TEST ?= 0
HAVE_SHARED_CONTEXT ?= 0
HAVE_OPENGL ?= 1
FORCE_GLES ?= 0
HAVE_LIBCURL ?= 0
INCFLAGS :=
......
......@@ -1224,6 +1224,15 @@ static void compute_chunk(WorkerItem *item)
int oz = item->q * CHUNK_SIZE - CHUNK_SIZE - 1;
/* check for lights */
int has_light = 0;
if (!opaque || !light || !highest)
{
free(opaque);
free(light);
free(highest);
return;
}
if (SHOW_LIGHTS)
{
for (a = 0; a < 3; a++)
......@@ -1402,6 +1411,7 @@ static void compute_chunk(WorkerItem *item)
item->miny = miny;
item->maxy = maxy;
item->faces = faces;
free(item->data);
item->data = data;
}
}
......@@ -1412,6 +1422,7 @@ static void generate_chunk(Chunk *chunk, WorkerItem *item) {
chunk->faces = item->faces;
renderer_del_buffer(chunk->buffer);
chunk->buffer = renderer_gen_faces(10, item->faces, item->data);
item->data = 0;
gen_sign_buffer(chunk);
}
......@@ -1421,6 +1432,8 @@ static void gen_chunk_buffer(Chunk *chunk)
WorkerItem _item;
WorkerItem *item = &_item;
memset(item, 0, sizeof(*item));
item->p = chunk->p;
item->q = chunk->q;
......@@ -1502,11 +1515,11 @@ static void init_chunk(Chunk *chunk, int p, int q)
static void create_chunk(Chunk *chunk, int p, int q)
{
WorkerItem _item;
WorkerItem *item;
WorkerItem *item = &_item;
memset(item, 0, sizeof(*item));
init_chunk(chunk, p, q);
item = &_item;
item->p = chunk->p;
item->q = chunk->q;
item->block_maps[1][1] = &chunk->map;
......@@ -3350,6 +3363,7 @@ int main_load_game(int argc, char **argv)
// INITIALIZE WORKER THREADS
for (i = 0; i < WORKERS; i++) {
Worker *worker = g->workers + i;
memset(worker, 0, sizeof(*worker));
worker->index = i;
worker->state = WORKER_IDLE;
mtx_init(&worker->mtx, mtx_plain);
......
......@@ -398,6 +398,8 @@ uintptr_t renderer_gen_buffer(size_t size, float *data)
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
GLuint buffer;
glGenBuffers(1, &buffer);
if (!size || !data)
return buffer;
glBindBuffer(GL_ARRAY_BUFFER, buffer);
glBufferData(GL_ARRAY_BUFFER, (GLsizei)size, data, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment