safer cloth destroy routine

main
cosmonaut 2021-09-27 11:18:22 -07:00
parent 26516c9829
commit 47ceb50cd9
2 changed files with 8 additions and 5 deletions

View File

@ -1461,7 +1461,7 @@ double Silkworm_DestroyClothInRadius(double x, double y, double radius)
/* TODO: spatial hash implementation */
uint32_t i, j;
double clothId = -1;
int32_t clothId = -1;
for (i = 0; i < context->nodeCount; i += 1)
{
@ -1488,9 +1488,7 @@ double Silkworm_DestroyClothInRadius(double x, double y, double radius)
if (arrayCount > 0)
{
clothId = (double)cloth->id;
Silkworm_Internal_DestroyCloth(cloth);
break;
clothId = cloth->id;
}
}
}
@ -1498,6 +1496,11 @@ double Silkworm_DestroyClothInRadius(double x, double y, double radius)
}
}
if (clothId != -1)
{
Silkworm_DestroyCloth((double)clothId);
}
Silkworm_PerformDestroys();
return clothId;
}

View File

@ -19,7 +19,7 @@
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{4F20502A-F926-4D12-872D-64AC2E065078}</ProjectGuid>
<ProjectGuid>{6DB15344-E000-45CB-A48A-1D72F7D6E945}</ProjectGuid>
<RootNamespace>Silkworm</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>