Hey all, I have an array of structs with different variables for my inventory system. When I store items that stack I just add them that many times to the inventory, so the inventory just has duplicates of the same struct for every instance.
At the current moment if I have 10 apples in my inventory, and I try to find 5 apples and remove them, it usually succeeds and removes them. But occasionally despite having 10 apples in my array it can’t find all of them and returns -1 on the find.
I have printed out the entire inventory and it’s always the same thing in each array slot for the name variable for example, and then I instead I did a for each loop and broke the inventory struct and dropped item struct to see if the name matched. And again in most cases it was fine, but some it couldn’t find the match for some reason.
I’m probably doing something stupid, or forgot something. I can provide more info if needed for whatever would be helpful, wasn’t sure if more was needed. If anyone can help me out, it would be greatly appreciated! Thanks!
Edit: This is the other method I tried. Works for a few times, and then all of the sudden it throws an error despite everything still matching: