CleverRaven/Cataclysm-DDA — pull request #7496 by CIB (2014-05-01 23:52:40+00:00)
Title: Submap refactor: Item container accessor. [WIP][CR]

Instead of being given a direct reference to the vector of items in a tile, you get a "view"/accessor class that can iterate over the items, replace items, and remove them.

To showcase the way this is used, acid field item processing has been converted to this API.

This is a seriously hard nut to crack. There's no way to do this with simple getters and setters like in the other submap refactors, because items don't have a unique identification. You can't say "remove item X from the tile". You can only say "remove this specific item you just gave me a reference to", and even then, there's the problem of such a removal possibly invalidating the iterator. So we need to wrap the whole iteration process in an abstraction layer, not just the individual accessors. That's what item_accessor does. It's a bit complex for my liking, but I can't come up with a simpler solution that will fully hide away the actual way items are stored in the submap.