From abd0c3a98bbbe6bcd0425351207120a00babe329 Mon Sep 17 00:00:00 2001 From: skotlex Date: Fri, 7 Dec 2007 08:44:52 +0000 Subject: - removed the timer heap correction code when the timers overflow since Flavio points out that it is not needed. - Modified a bit the changesex code so you get saved and quit before changing your sex rather than afterwards. - Cleaned up #changesex - Signum Crucis now works on bosses. - party_recv_data will not set the sd pointer for not-yet-authed characters. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11867 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/timer.c | 33 --------------------------------- 1 file changed, 33 deletions(-) (limited to 'src/common/timer.c') diff --git a/src/common/timer.c b/src/common/timer.c index a2be88876..5f1f17e2f 100644 --- a/src/common/timer.c +++ b/src/common/timer.c @@ -351,43 +351,13 @@ int settick_timer(int tid, unsigned int tick) return tick; } -//Correcting the heap when the tick overflows is an idea taken from jA to -//prevent timer problems. Thanks to [End of Exam] for providing the required data. [Skotlex] -//This funtion will rearrange the heap and assign new tick values. -static void fix_timer_heap(unsigned int tick) -{ - if (timer_heap_num >= 0 && tick < 0x00010000 && timer_data[timer_heap[0]].tick > 0xf0000000) - { //The last timer is way too far into the future, and the current tick is too close to 0, overflow was very likely - //(not perfect, but will work as long as the timer is not expected to happen 50 or so days into the future) - int i; - int *tmp_heap; - for (i=0; i < timer_heap_num && timer_data[timer_heap[i]].tick > 0xf0000000; i++) - { //All functions with high tick value should had been executed already... - timer_data[timer_heap[i]].tick = 0; - } - //Move elements to readjust the heap. - tmp_heap = aCalloc(sizeof(int), i); - memcpy(tmp_heap, timer_heap, i*sizeof(int)); - memmove(timer_heap, &timer_heap[i], (timer_heap_num-i)*sizeof(int)); - memmove(&timer_heap[timer_heap_num-i], tmp_heap, i*sizeof(int)); - aFree(tmp_heap); - } -} - /// Executes all expired timers. /// Returns the value of the smallest non-expired timer (or 1 second if there aren't any). int do_timer(unsigned int tick) { int nextmin = 1000; // return value - static int fix_heap_flag = 0; //Flag for fixing the stack only once per tick loop. May not be the best way, but it's all I can think of currently :X [Skotlex] int i; - if( tick < 0x010000 && fix_heap_flag ) - { - fix_timer_heap(tick); - fix_heap_flag = 0; - } - // process all timers one by one while( timer_heap_num ) { @@ -444,9 +414,6 @@ int do_timer(unsigned int tick) if( nextmin < TIMER_MIN_INTERVAL ) nextmin = TIMER_MIN_INTERVAL; - if( UINT_MAX - nextmin < tick ) //Tick will loop, rearrange the heap on the next iteration. - fix_heap_flag = 1; - return nextmin; } -- cgit v1.2.3-60-g2f50