From ef165773b82da9fa04a042bdd60c9d8becba8245 Mon Sep 17 00:00:00 2001 From: aurhat Date: Sat, 15 Feb 2014 10:55:07 +0100 Subject: [PATCH] This commit fixes removing sleeps in "resetsleep" function. To test this bug make, for example, 3 long-standing sleeps, add checking of number of sleeps before and after existing "loopv(sleep)", and later type "/resetsleeps" command in AC - result: 3 sleeps "before" and 1 remains "after". Explanation by stef: after deleting elements from vectors there are no holes, so if there were sleeps[0], sleeps[1] and sleeps[2], then after removing sleeps[0] there left sleeps[0] and sleeps[1], so during next loop cycle this sleeps[0] is neglected (because i=1). Commit just changes loopv to loopvrev (loop from end to begin). --- source/src/clientgame.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 08eec25e..59e89e93 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -599,7 +599,7 @@ void addsleep_(int *msec, char *cmd, int *persist) void resetsleep(bool force) { - loopv(sleeps) if(!sleeps[i].persist || force) + loopvrev(sleeps) if(!sleeps[i].persist || force) { DELETEA(sleeps[i].cmd); sleeps.remove(i);