Refactor tiles to use setter and getter functions

This makes it easier to add bounds checks to all accesses of
ed.contents.

To do this, I've added editorclass::gettile(), editorclass::settile(),
and editorclass::getabstile() (with a helper function of
editorclass::gettileidx() that really shouldn't be used directly), and
replaced all raw accesses of ed.contents with those functions
appropriately.

This also makes the code more readable, as a side effect.
This commit is contained in:
Misa
2021-03-24 11:26:19 -07:00
committed by Ethan Lee
parent ccdb0c9148
commit 344c93e754
2 changed files with 186 additions and 55 deletions

View File

@@ -120,6 +120,27 @@ class editorclass{
void getlin(const enum textmode mode, const std::string& prompt, std::string* ptr);
const short* loadlevel(int rxi, int ryi);
int gettileidx(
const int rx,
const int ry,
const int x,
const int y
);
void settile(
const int rx,
const int ry,
const int x,
const int y,
const int t
);
int gettile(
const int rx,
const int ry,
const int x,
const int y
);
int getabstile(const int x, const int y);
void placetilelocal(int x, int y, int t);
int getenemyframe(int t);