diff --git a/code/source-c/chunk.c b/code/source-c/chunk.c index f7236bb..b6b7a2b 100644 --- a/code/source-c/chunk.c +++ b/code/source-c/chunk.c @@ -38,6 +38,10 @@ void tc_draw_chunkloader_zone(tc_chunkloader_s *loader) tc_chunklist_s *list = &loader->chunklist; for(tc_chunklist_entry_s *current = list->first; current != NULL; current = current->next) { + if(current->entity == NULL) + { + return; + } tc_send_pointer_to_entity(current->entity, "draw", 0); } diff --git a/code/source-c/chunkloader.c b/code/source-c/chunkloader.c index 5e20e93..0d5d030 100644 --- a/code/source-c/chunkloader.c +++ b/code/source-c/chunkloader.c @@ -117,7 +117,10 @@ void tc_chunklist_remove_item(tc_chunklist_s *list, tc_entity_s *chunk) if(entry->previous != NULL) entry->previous->next = entry->next; - entry->entity = NULL; + if(entry->next != NULL) + entry->next->previous = entry->previous; + + entry->entity = NULL; list->first_free = entry; } @@ -130,7 +133,7 @@ tc_chunkloader_s tc_create_chunkloader(tc_chunk_location_s location) loader.extent.y = UPDATE_DISTANCE * 2 + 1; loader.extent.z = UPDATE_DISTANCE * 2 + 1; loader.center = location; - loader.chunklist = tc_create_chunklist(200); + loader.chunklist = tc_create_chunklist(512); loader.needs_reload = FALSE; return loader; diff --git a/code/source-c/entity.c b/code/source-c/entity.c index 7edecc2..7e16b07 100644 --- a/code/source-c/entity.c +++ b/code/source-c/entity.c @@ -322,10 +322,11 @@ void tc_schedule_interval(tc_entity_s *entity, float wanted_delta, void (*fn_int void tc_send_pointer_to_entity(tc_entity_s *entity, char *event_name, void *pointer) { - tc_entity_event_s event; + tc_entity_event_s event; event.identifier = event_name; event.value.pointer = pointer; - entity->type->functions.fn_send_event(entity, event); + tc_entity_type_s *type = entity->type; + type->functions.fn_send_event(entity, event); } void tc_send_string_to_entity(tc_entity_s *entity, char *event_name, char *string) diff --git a/code/source-c/entity/chunk.c b/code/source-c/entity/chunk.c index 2d286de..037aba5 100644 --- a/code/source-c/entity/chunk.c +++ b/code/source-c/entity/chunk.c @@ -39,8 +39,10 @@ void tc_delete_chunk_entity(tc_entity_s *entity) if(chunk->vertex_uvs != NULL) free(chunk->vertex_uvs); tc_physics_entity_s *physics_body = tc_get_pointer_from_entity(entity, "physics_body"); - tc_remove_physics_entity(physics_body); - + if(physics_body != 0) + { + tc_remove_physics_entity(physics_body); + } tc_deallocate_chunk(entity->specific); } diff --git a/code/source-c/world_physics.c b/code/source-c/world_physics.c index 8e93e48..df10a6d 100644 --- a/code/source-c/world_physics.c +++ b/code/source-c/world_physics.c @@ -4,6 +4,7 @@ void tc_initialize_chunk_physics(tc_entity_s *chunk_entity, void *userdata) { + /* tc_chunk_s *chunk = chunk_entity->specific; tc_world_s *world = chunk->location.world; tc_physics_simulation_s *simulation = world->physics; @@ -39,6 +40,7 @@ void tc_initialize_chunk_physics(tc_entity_s *chunk_entity, void *userdata) tc_add_physics_object(world->physics, chunk_body); tc_set_pointer_for_entity(chunk_entity, "physics_body", chunk_body); + */ } void tc_create_world_physics(tc_world_s *world, void *userdata)