1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-23 01:59:43 +01:00

Fix regression with counting out-of-bounds custom entities

My latest rebase of #624 (refactoring/splitting editor.cpp) accidentally
overwrote #787 and essentially reverted it entirely. So, add it back in.

This is the same as #787 except it uses the new names, uses SDL_INLINE
to inline the function, and uses named constants.
This commit is contained in:
Misa 2021-10-27 16:49:57 -07:00
parent 58c518c856
commit 1bc1149ab5

View file

@ -1746,12 +1746,21 @@ Uint32 customlevelclass::getonewaycol(void)
return graphics.getRGB(255, 255, 255);
}
static SDL_INLINE bool inbounds(const CustomEntity* entity)
{
extern customlevelclass cl;
return entity->x >= 0
&& entity->y >= 0
&& entity->x < cl.mapwidth * SCREEN_WIDTH_TILES
&& entity->y < cl.mapheight * SCREEN_HEIGHT_TILES;
}
int customlevelclass::numtrinkets(void)
{
int temp = 0;
for (size_t i = 0; i < customentities.size(); i++)
{
if (customentities[i].t == 9)
if (customentities[i].t == 9 && inbounds(&customentities[i]))
{
temp++;
}
@ -1764,7 +1773,7 @@ int customlevelclass::numcrewmates(void)
int temp = 0;
for (size_t i = 0; i < customentities.size(); i++)
{
if (customentities[i].t == 15)
if (customentities[i].t == 15 && inbounds(&customentities[i]))
{
temp++;
}