Scan for trinkets and put them into shinytrinkets in customs

For showtrinkets() to work, we'll need the correct map data in custom
levels.
This commit is contained in:
Misa
2020-06-30 12:30:19 -07:00
committed by Ethan Lee
parent 3f7ed4b94a
commit 9e9b1b3c6d
3 changed files with 55 additions and 0 deletions

View File

@@ -397,6 +397,15 @@ std::string mapclass::getglitchname(int x, int y)
void mapclass::initmapdata()
{
if (custommode)
{
initcustommapdata();
return;
}
teleporters.clear();
shinytrinkets.clear();
//Set up static map information like teleporters and shiny trinkets.
setteleporter(0, 0);
setteleporter(0, 16);
@@ -436,6 +445,27 @@ void mapclass::initmapdata()
settrinket(10, 8);
}
void mapclass::initcustommapdata()
{
shinytrinkets.clear();
#if !defined(NO_CUSTOM_LEVELS)
for (size_t i = 0; i < edentity.size(); i++)
{
const edentities& ent = edentity[i];
if (ent.t != 9)
{
continue;
}
const int rx = ent.x / 40;
const int ry = ent.y / 30;
settrinket(rx, ry);
}
#endif
}
int mapclass::finalat(int x, int y)
{
//return the tile index of the final stretch tiles offset by the colour difference