void UHighlightManager::ClearTileColors()
{
if (Instance == nullptr)
{
UE_LOG(LogHighlight, Error, TEXT("Instance is null"));
return;
}
//if (Instance->TextureData == nullptr) //this isn't allowed, apparently
//{
// UE_LOG(LogHighlight, Error, TEXT("Instance->TextureData is null"));
// return;
//}
for (int x = 0; x < (int)(Instance->TileSize); x++)
{
for (int y = 0; y < (int)(Instance->TileSize); y++)
{
if (Instance->TileData[x + y * (Instance->TileSize)].A == 0) continue;
Instance->TileData[x + y * (Instance->TileSize)] = FColor(0, 0, 0, 0);
if (!Instance->TextureData.IsValidIndex(x * 32 + (y * 32) * Instance->TextureSize)
|| !Instance->TextureData.IsValidIndex(x * 32 + 31 + (y * 32 + 31) * Instance->TextureSize))
{
UE_LOG(LogHighlight, Error, TEXT("Invalid index: %d <> %d (%d, %d)"), x * 32 + (y * 32) * Instance->TextureSize, x * 32 + 31 + (y * 32 + 31) * Instance->TextureSize, x, y);
}
else
{
for (int i = 0; i < 32; i++)
{
for (int j = 0; j < 32; j++)
{
Instance->TextureData[x * 32 + i + (y * 32 + j) * Instance->TextureSize] = FColor(0, 0, 0, 0); //Crashing here
}
}
}
Instance->bHasTextureUpdate = true;
}
}
}
not sure what it’s failing to access; Instance, Instance->TextureData, and Instance->TextureSize are all successfully accessed before that line. Unless FColor(0, 0, 0, 0) is somehow responsible