From cc700f1fb56e89efda2b94fb073d4a89af0813ee Mon Sep 17 00:00:00 2001 From: Jeybla Date: Mon, 22 May 2017 06:23:34 +0200 Subject: [PATCH] Fixes Instance idle timer. (#2155) * Fixes #2154 * Fixes an incorrect start of the instance idle timer. * Thanks to generic! --- src/map/instance.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/map/instance.c b/src/map/instance.c index 3607612c13..8c3e3c55c4 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -812,7 +812,7 @@ int instance_addusers(unsigned short instance_id) int instance_delusers(unsigned short instance_id) { struct instance_data *im; - int i, idle = 0; + int i, users = 0; if(instance_id == 0 || instance_id > MAX_INSTANCE_DATA) return 1; @@ -823,10 +823,11 @@ int instance_delusers(unsigned short instance_id) // If no one is in the instance, start the idle timer for(i = 0; i < im->cnt_map && im->map[i]->m; i++) - if(map[im->map[i]->m].users > 1) // We check this before the actual map.users are updated, hence the 1 - idle++; + users += max(map[im->map[i]->m].users,0); - if(!idle) // If idle wasn't added to, we know no one was in the instance + // We check the actual map.users before being updated, hence the 1 + // The instance should be empty if users are now <= 1 + if(users <= 1) instance_startidletimer(im, instance_id); return 0;