From 47ceb50cd9d2d2aecf61fddffbc55239a145d00e Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Mon, 27 Sep 2021 11:18:22 -0700 Subject: [PATCH] safer cloth destroy routine --- src/Silkworm.c | 11 +++++++---- visualc/Silkworm.vcxproj | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Silkworm.c b/src/Silkworm.c index 71cfeb7..4098f9e 100644 --- a/src/Silkworm.c +++ b/src/Silkworm.c @@ -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; } diff --git a/visualc/Silkworm.vcxproj b/visualc/Silkworm.vcxproj index ba0de5c..94b617c 100644 --- a/visualc/Silkworm.vcxproj +++ b/visualc/Silkworm.vcxproj @@ -19,7 +19,7 @@ - {4F20502A-F926-4D12-872D-64AC2E065078} + {6DB15344-E000-45CB-A48A-1D72F7D6E945} Silkworm 10.0