diff --git a/scenes/game_systems.c b/scenes/game_systems.c index ef12ac9..19fa132 100644 --- a/scenes/game_systems.c +++ b/scenes/game_systems.c @@ -1028,13 +1028,19 @@ void moveable_update_system(Scene_t* scene) { Entity_t* other_ent = get_entity(&scene->ent_manager, idx_to_check); CBBox_t* p_other_bbox = get_component(other_ent, CBBOX_COMP_T); - any_solid |= p_other_bbox->solid; + if (p_other_bbox != NULL) + { + any_solid |= p_other_bbox->solid; + } } sc_map_foreach_key(&tilemap.tiles[tile_idx2].entities_set, idx_to_check) { Entity_t* other_ent = get_entity(&scene->ent_manager, idx_to_check); CBBox_t* p_other_bbox = get_component(other_ent, CBBOX_COMP_T); - any_solid |= p_other_bbox->solid; + if (p_other_bbox != NULL) + { + any_solid |= p_other_bbox->solid; + } } if (!any_solid) { @@ -1057,13 +1063,19 @@ void moveable_update_system(Scene_t* scene) { Entity_t* other_ent = get_entity(&scene->ent_manager, idx_to_check); CBBox_t* p_other_bbox = get_component(other_ent, CBBOX_COMP_T); - any_solid |= p_other_bbox->solid; + if (p_other_bbox != NULL) + { + any_solid |= p_other_bbox->solid; + } } sc_map_foreach_key(&tilemap.tiles[tile_idx2].entities_set, idx_to_check) { Entity_t* other_ent = get_entity(&scene->ent_manager, idx_to_check); CBBox_t* p_other_bbox = get_component(other_ent, CBBOX_COMP_T); - any_solid |= p_other_bbox->solid; + if (p_other_bbox != NULL) + { + any_solid |= p_other_bbox->solid; + } } if (!any_solid) { diff --git a/scenes/water_flow.c b/scenes/water_flow.c index 25aa5a7..b7d2e91 100644 --- a/scenes/water_flow.c +++ b/scenes/water_flow.c @@ -40,7 +40,9 @@ void free_water_runner(Entity_t* ent, EntityManager_t* ent_manager) { CWaterRunner_t* p_crunner = get_component(ent, CWATERRUNNER_T); free(p_crunner->bfs_tilemap.tilemap); + p_crunner->bfs_tilemap.tilemap = NULL; free(p_crunner->visited); + p_crunner->visited = NULL; sc_queue_term(&p_crunner->bfs_queue); remove_entity(ent_manager, ent->m_id); }