From a66eb7f8c3d35ab6927dcb5334329dc762419af7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 26 Dec 2008 08:53:12 +0000 Subject: [PATCH] - Fixed: The Boss Brain could crash when it tried to shoot a cube but having no spawn spots placed. SVN r1331 (trunk) --- src/g_shared/a_specialspot.cpp | 2 +- src/tarray.h | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/g_shared/a_specialspot.cpp b/src/g_shared/a_specialspot.cpp index 5064b04864..dbf2cffca8 100644 --- a/src/g_shared/a_specialspot.cpp +++ b/src/g_shared/a_specialspot.cpp @@ -129,7 +129,7 @@ struct FSpotList ASpecialSpot *GetNextInList(int skipcounter) { - if (++SkipCount > skipcounter) + if (Spots.Size() > 0 && ++SkipCount > skipcounter) { SkipCount = 0; diff --git a/src/tarray.h b/src/tarray.h index 1ce5ba5242..5006beb636 100644 --- a/src/tarray.h +++ b/src/tarray.h @@ -149,6 +149,24 @@ public: } } } + + void Delete (unsigned int index, int deletecount) + { + if (index + deletecount > Count) deletecount = Count - index; + if (deletecount > 0) + { + for(int i = 0; i < deletecount; i++) + { + Array[index + i].~T(); + } + Count -= deletecount; + if (index < Count) + { + memmove (&Array[index], &Array[index+deletecount], sizeof(T)*(Count - index)); + } + } + } + // Inserts an item into the array, shifting elements as needed void Insert (unsigned int index, const T &item) {