Fix DrawGraph.GetAlphaColor/SACT2.SP_GetAMapValue

Properly handle cases where the coordinate is outside of the sprite.
Fixes an issue on the Haru Urare menu sceen.
This commit is contained in:
Nunuhara Cabbage
2021-05-09 21:49:53 -07:00
parent e74fc33cf0
commit c735ee5af2
2 changed files with 8 additions and 0 deletions
+6
View File
@@ -191,6 +191,12 @@ static void DrawGraph_CopyReverseAMapLR(int dst, int dx, int dy, int src, int sx
static bool DrawGraph_GetAlphaColor(int surface, int x, int y, int *a)
{
struct sact_sprite *sp = sact_get_sprite(surface);
// NOTE: System40.exe errors here
if (!sp)
VM_ERROR("Invalid sprite index: %d", surface);
if (x < 0 || x >= sp->rect.w || y < 0 || y >= sp->rect.h)
return false;
*a = sact_SP_GetAMapValue(surface, x, y);
return true;
}
+2
View File
@@ -568,6 +568,8 @@ int sact_SP_GetAMapValue(int sp_no, int x, int y)
{
struct sact_sprite *sp = sact_get_sprite(sp_no);
if (!sp) return 0;
if (x < 0 || x >= sp->rect.w || y < 0 || y >= sp->rect.h)
return -1;
return sprite_get_amap_value(sp, x, y);
}