mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-29 17:38:16 +03: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:
@@ -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++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user