Refactor room properties to use setter and getter funcs

This replaces all raw ed.level accesses with new setter and getter
funcs, which makes it easier to add bounds checks later. And I've also
removed all the manually-written bounds checks, since they will go into
the new getter and setter.

To get the room properties of a specific room, you use
editorclass::getroomprop(), which returns a pointer to the room
properties - then you just read off of that pointer. To set a room
property, you use editorclass::setroom<PROP>(), where <PROP> is the name
of the property. These are maintained using X macros to avoid
copy-pasting. editorclass::getroompropidx() is a helper function and
shouldn't be used directly.
This commit is contained in:
Misa
2021-03-24 11:59:36 -07:00
committed by Ethan Lee
parent cfd5be1bc5
commit 945d5f244a
6 changed files with 207 additions and 200 deletions

View File

@@ -1250,9 +1250,8 @@ void entityclass::createentity( float xp, float yp, int t, float vx /*= 0*/, flo
#if !defined(NO_CUSTOM_LEVELS)
// Special case for gray Warp Zone tileset!
int room = game.roomx-100 + (game.roomy-100) * ed.maxwidth;
bool custom_gray = INBOUNDS_ARR(room, ed.level)
&& ed.level[room].tileset == 3 && ed.level[room].tilecol == 6;
const edlevelclass* const room = ed.getroomprop(game.roomx - 100, game.roomy - 100);
bool custom_gray = room->tileset == 3 && room->tilecol == 6;
#else
bool custom_gray = false;
#endif