So every tile has
std::list<Unit*> UnitsOnTile
It's a collection of pointers to units. That are on the tile. It's not even doing anything at the moment other than being used to retrieve a unit list occasionally. As far as I can tell units are only added at the proper times. Yet when I step through the code, it sometimes gives me some absurdly high number of objects in containers that aren't empty with garbage values. When I go to remove items from the container, it also seems to not actually remove, as far as I can tell from stepping through the code. The values will be correct before the line that removes them, and after the line that removes them, the container is still the same size, except that the element removed is just replaced with garbage values. I've been trying to figure this out all day, it's been driving me mad. I'm just calling UnitsOnTile.remove(UnitToRemove), unit to remove being a pointer that points to the same object as one of the items in the list. I'm going to lose my hair from programming.
std::list<Unit*> UnitsOnTile
It's a collection of pointers to units. That are on the tile. It's not even doing anything at the moment other than being used to retrieve a unit list occasionally. As far as I can tell units are only added at the proper times. Yet when I step through the code, it sometimes gives me some absurdly high number of objects in containers that aren't empty with garbage values. When I go to remove items from the container, it also seems to not actually remove, as far as I can tell from stepping through the code. The values will be correct before the line that removes them, and after the line that removes them, the container is still the same size, except that the element removed is just replaced with garbage values. I've been trying to figure this out all day, it's been driving me mad. I'm just calling UnitsOnTile.remove(UnitToRemove), unit to remove being a pointer that points to the same object as one of the items in the list. I'm going to lose my hair from programming.