thesadrogue / TheSadRogue.Integration

An integration library between SadConsole and GoRogue
MIT License
8 stars 5 forks source link

SettableSurface allows `null` for ColoredGlyph #30

Closed Chris3606 closed 3 years ago

Chris3606 commented 3 years ago

Issue

Currently, SettableSurface is allowed to return null when accessed via indexer, in the case where there is no terrain object at the corresponding position in the map it exposes. This is inviable, because SadConsole conducts no null checks during rendering; and as such this situation will cause a null reference exception as soon as rendering occurs.

Proposed Solution

I propose that RogulikeMap.TerrainView be implemented to return a fully transparent appearance for locations where there are no terrain, and thus guarantee its return value is non-nullable. Further, I propose that SettableSurface be modified to use TerrainView to obtain its values.