summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-09-25 01:58:31 +0000
committerFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-09-25 01:58:31 +0000
commit1041b3bbad62766df85393254a93602a1851895a (patch)
tree0c3e433ec1b0c8b2bed7371ef9c65aa5c112755b /src/common
parent02ff54ba1d0b87b29f19c29524ba77a2f30a6d85 (diff)
downloadhercules-1041b3bbad62766df85393254a93602a1851895a.tar.gz
hercules-1041b3bbad62766df85393254a93602a1851895a.tar.bz2
hercules-1041b3bbad62766df85393254a93602a1851895a.tar.xz
hercules-1041b3bbad62766df85393254a93602a1851895a.zip
* Disabled tick cache (to enable it: define TICK_CACHE to the number of calls that should be cached).
* Added a charid2sd database for fast charid searches. * Reworked the nick cache to only contain offline characters. Note: The tick cache was causing _some_ of the desync problems in eA. Gameplay should be much smother, but desync problems still exist. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11290 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common')
-rw-r--r--src/common/timer.c29
-rw-r--r--src/common/timer.h4
2 files changed, 28 insertions, 5 deletions
diff --git a/src/common/timer.c b/src/common/timer.c
index 15e50a05d..a24e2da8f 100644
--- a/src/common/timer.c
+++ b/src/common/timer.c
@@ -109,19 +109,21 @@ char* search_timer_func_list(TimerFunc func)
/*----------------------------
* Get tick time
*----------------------------*/
-static unsigned int gettick_cache;
-static int gettick_count;
+//////////////////////////////////////////////////////////////////////////
+#if defined(TICK_CACHE) && TICK_CACHE > 1
+//////////////////////////////////////////////////////////////////////////
+// tick is cached for TICK_CACHE calls
unsigned int gettick_nocache(void)
{
-#ifdef _WIN32
- gettick_count = 256;
+#ifdef WIN32
+ gettick_count = TICK_CACHE;
return gettick_cache = GetTickCount();
#else
struct timeval tval;
gettimeofday(&tval, NULL);
- gettick_count = 256;
+ gettick_count = TICK_CACHE;
return gettick_cache = tval.tv_sec * 1000 + tval.tv_usec / 1000;
#endif
@@ -134,6 +136,23 @@ unsigned int gettick(void)
return gettick_cache;
}
+//////////////////////////////
+#else
+//////////////////////////////
+// tick doesn't get cached
+unsigned int gettick(void)
+{
+#ifdef WIN32
+ return GetTickCount();
+#else
+ struct timeval tval;
+ gettimeofday(&tval, NULL);
+ return tval.tv_sec * 1000 + tval.tv_usec / 1000;
+#endif
+}
+//////////////////////////////////////////////////////////////////////////
+#endif
+//////////////////////////////////////////////////////////////////////////
/*======================================
* CORE : Timer Heap
diff --git a/src/common/timer.h b/src/common/timer.h
index b75cc6641..cbefbe158 100644
--- a/src/common/timer.h
+++ b/src/common/timer.h
@@ -41,7 +41,11 @@ struct TimerData {
// Function prototype declaration
+#if defined(TICK_CACHE) && TICK_CACHE > 1
unsigned int gettick_nocache(void);
+#else
+#define gettick_nocache gettick
+#endif
unsigned int gettick(void);
int add_timer(unsigned int,TimerFunc f,int,int);