diff options
author | FlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2007-12-27 03:35:57 +0000 |
---|---|---|
committer | FlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2007-12-27 03:35:57 +0000 |
commit | 1307b441cd2cdc94bdde1999d48aefb55d91e082 (patch) | |
tree | 4674edabfa271c4f0dd2b4f21f783640958e8cac | |
parent | dfe4ede046db94e2e6e580d2efa13bb9a773ce15 (diff) | |
download | hercules-1307b441cd2cdc94bdde1999d48aefb55d91e082.tar.gz hercules-1307b441cd2cdc94bdde1999d48aefb55d91e082.tar.bz2 hercules-1307b441cd2cdc94bdde1999d48aefb55d91e082.tar.xz hercules-1307b441cd2cdc94bdde1999d48aefb55d91e082.zip |
* Tweeked the declaration and initialization defines for vectors.
* Made do_sockets leave the for loop as soon as the readable number of sockets returned by select is found.
* Made all posix compliant systems that support it and FreeBSD >= 5.1 (implements it but doesn't have the posix defines) use the precise and consistent tick() implementation.
* Minor tweek to HEAP_SEARCH (same variable can be used in from and to).
* Fixed the map server not exiting when make_listen_bind fails and returns -1.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11983 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r-- | Changelog-Trunk.txt | 10 | ||||
-rw-r--r-- | src/common/db.h | 38 | ||||
-rw-r--r-- | src/common/socket.c | 6 | ||||
-rw-r--r-- | src/common/timer.c | 6 | ||||
-rw-r--r-- | src/map/clif.c | 3 | ||||
-rw-r--r-- | src/map/map.h | 6 |
6 files changed, 50 insertions, 19 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 500bf2615..d56f3c333 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -3,6 +3,16 @@ Date Added AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. +2007/12/27 + * Tweeked the declaration and initialization defines for vectors. + * Made do_sockets leave the for loop as soon as the readable number of + sockets returned by select is found. + * Made all posix compliant systems that support it and FreeBSD >= 5.1 + (implements it but doesn't have the posix defines) use the precise and + consistent tick() implementation. + * Minor tweek to HEAP_SEARCH (same variable can be used in from and to). + * Fixed the map server not exiting when make_listen_bind fails and + returns -1. [FlavioJS] 2007/12/26 * Fixed the incorrect interpretation of the map-cell height information stored in .gat files; this was causing an overall of 20000 cells to diff --git a/src/common/db.h b/src/common/db.h index 30948b0cb..cf9e4e82e 100644 --- a/src/common/db.h +++ b/src/common/db.h @@ -854,11 +854,23 @@ void linkdb_final ( struct linkdb_node** head ); +/// Declares an anonymous vector struct. +/// +/// @param __type Type of data +#define VECTOR_DECL(__type) \ + struct { \ + size_t _max_; \ + size_t _len_; \ + __type* _data_; \ + } + + + /// Declares a named vector struct. /// /// @param __name Structure name /// @param __type Type of data -#define VECTOR_STRUCT(__name,__type) \ +#define VECTOR_STRUCT_DECL(__name,__type) \ struct __name { \ size_t _max_; \ size_t _len_; \ @@ -867,7 +879,16 @@ void linkdb_final ( struct linkdb_node** head ); -/// Declares a named vector struct variable. +/// Declares and initializes an anonymous vector variable. +/// +/// @param __type Type of data +/// @param __var Variable name +#define VECTOR_VAR(__type,__var) \ + VECTOR_DECL(__type) __var = {0,0,NULL} + + + +/// Declares and initializes a named vector variable. /// /// @param __name Structure name /// @param __var Variable name @@ -876,16 +897,11 @@ void linkdb_final ( struct linkdb_node** head ); -/// Declares a vector variable with an anonymous struct. +/// Initializes a vector. /// -/// @param __type Type of data -/// @param __var Variable name -#define VECTOR_VAR(__type,__var) \ - struct { \ - size_t _max_; \ - size_t _len_; \ - __type* _data_; \ - } __var = {0,0,NULL} +/// @param __vec Vector +#define VECTOR_INIT(__vec) \ + memset(&(__vec), 0, sizeof(__vec)) diff --git a/src/common/socket.c b/src/common/socket.c index b1c564034..0173ee846 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -716,11 +716,13 @@ int do_sockets(int next) } #else // otherwise assume that the fd_set is a bit-array and enumerate it in a standard way - //TODO: select() returns the number of readable sockets; use that to exit the fd_max loop faster - for (i = 1; i < fd_max; i++) + for( i = 1; ret && i < fd_max; ++i ) { if(sFD_ISSET(i,&rfd) && session[i]) + { session[i]->func_recv(i); + --ret; + } } #endif diff --git a/src/common/timer.c b/src/common/timer.c index c66fd5960..2c8236e3d 100644 --- a/src/common/timer.c +++ b/src/common/timer.c @@ -12,8 +12,10 @@ #include <time.h> #ifdef WIN32 +#define WIN32_LEAN_AND_MEAN #include <windows.h> // GetTickCount() #else +#include <unistd.h> #include <sys/time.h> // struct timeval, gettimeofday() #endif @@ -93,7 +95,7 @@ static unsigned int tick(void) { #if defined(WIN32) return GetTickCount(); -#elif defined(__FREEBSD__) +#elif (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0 && defined(_POSIX_MONOTONIC_CLOCK) /* posix compliant */) || (defined(__FreeBSD_cc_version) && __FreeBSD_cc_version >= 500005 /* FreeBSD >= 5.1.0 */) struct timespec tval; clock_gettime(CLOCK_MONOTONIC, &tval); return tval.tv_sec * 1000 + tval.tv_nsec / 1000000; @@ -147,8 +149,8 @@ unsigned int gettick(void) #define HEAP_SEARCH(target,from,to,pos) \ do { \ int max,pivot; \ - pos = from; \ max = to; \ + pos = from; \ while (pos < max) { \ pivot = (pos + max) / 2; \ if (DIFF_TICK(target, timer_data[timer_heap[pivot]].tick) < 0) \ diff --git a/src/map/clif.c b/src/map/clif.c index 3ee08824c..d176a9415 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -12043,7 +12043,8 @@ int do_init_clif(void) packetdb_readdb(); set_defaultparse(clif_parse); - if (!make_listen_bind(bind_ip,map_port)) { + if( make_listen_bind(bind_ip,map_port) == -1 ) + { ShowFatalError("can't bind game port\n"); exit(EXIT_FAILURE); } diff --git a/src/map/map.h b/src/map/map.h index 3ee4e0c7d..ecdc72c4f 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -374,10 +374,10 @@ struct status_change_entry { }; struct status_change { - unsigned int option;// effect state - unsigned int opt3;// skill state + unsigned int option;// effect state (bitfield) + unsigned int opt3;// skill state (bitfield) unsigned short opt1;// body state - unsigned short opt2;// health state + unsigned short opt2;// health state (bitfield) unsigned char count; //TODO: See if it is possible to implement the following SC's without requiring extra parameters while the SC is inactive. unsigned char jb_flag; //Joint Beat type flag |