You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found it in the project-restructure branch, so it is probably in the master as well. The list_remove_element_with_data() function should be checked for errors where it is used in other places as well.
I've labelled them BUG 1a) and BUG 1b) in game.c:
void item_lifetime_update() {
ListElement *e = list_head(carriedItems);
while (e != NULL) {
GameObject *go = (GameObject *)list_data(e);
Equipment *eq = game_object_get_component(go, COMP_EQUIPMENT);
eq->lifetime -= 1;
// Check to see if the item is aged beyond use
if (eq->lifetime <= 0) {
// Unequip the item if equipped
bool wasEquipped = false;
if (eq->isEquipped) {
wasEquipped = true;
item_toggle_equip(go);
}
// Remove from carried items
// BUG 1a) list_remove_element_with_data: the ListElement removed here is deleted
list_remove_element_with_data(carriedItems, go);
// Display a message to the player
Visibility *v = (Visibility *)game_object_get_component(go, COMP_VISIBILITY);
char *msg;
if (wasEquipped) {
msg = String_Create("The %s crumbles in your hands.", v->name);
} else {
msg = String_Create("The %s you are carrying crumbles to dust.", v->name);
}
add_message(msg, 0x990000ff);
String_Destroy(msg);
game_object_destroy(go);
}
// BUG 1b) list_remove_element_with_data: the deleted ListElement is used again here and is corrupt
e = list_next(e);
}
}
The text was updated successfully, but these errors were encountered:
I found it in the project-restructure branch, so it is probably in the master as well. The list_remove_element_with_data() function should be checked for errors where it is used in other places as well.
I've labelled them BUG 1a) and BUG 1b) in game.c:
The text was updated successfully, but these errors were encountered: