diff options
author | Ben Longbons <b.r.longbons@gmail.com> | 2011-09-10 16:43:26 -0700 |
---|---|---|
committer | Ben Longbons <b.r.longbons@gmail.com> | 2011-09-10 16:43:26 -0700 |
commit | 8f4e4e9a92f6af89820a358ab99b990697117502 (patch) | |
tree | cb312b5367c71dfe89543a5463be9555177c6445 /src/common | |
parent | f841b6fdcc802e73d52da0e67ee192c0c2c1c7e1 (diff) | |
parent | 2c863c0d99aa3df9ef2eb4ceb112c4d946520f0a (diff) | |
download | tmwa-8f4e4e9a92f6af89820a358ab99b990697117502.tar.gz tmwa-8f4e4e9a92f6af89820a358ab99b990697117502.tar.bz2 tmwa-8f4e4e9a92f6af89820a358ab99b990697117502.tar.xz tmwa-8f4e4e9a92f6af89820a358ab99b990697117502.zip |
Merge commit '2c863c0d99aa3df9ef2eb4ceb112c4d946520f0a'
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/GNUmakefile | 7 | ||||
-rw-r--r-- | src/common/Makefile | 15 | ||||
-rw-r--r-- | src/common/db.c | 2 | ||||
-rw-r--r-- | src/common/md5calc.c | 8 | ||||
-rw-r--r-- | src/common/md5calc.h | 2 | ||||
-rw-r--r-- | src/common/mmo.h | 10 | ||||
-rw-r--r-- | src/common/nullpo.c | 2 | ||||
-rw-r--r-- | src/common/socket.c | 22 | ||||
-rw-r--r-- | src/common/socket.h | 2 | ||||
-rw-r--r-- | src/common/timer.c | 8 | ||||
-rw-r--r-- | src/common/timer.h | 5 |
11 files changed, 36 insertions, 47 deletions
diff --git a/src/common/GNUmakefile b/src/common/GNUmakefile new file mode 100644 index 0000000..555f81e --- /dev/null +++ b/src/common/GNUmakefile @@ -0,0 +1,7 @@ +.SUFFIXES: +all: + make -C ../.. common +clean: + rm -r ../../obj/common/ +%:: + make -C ../.. obj/common/$@ diff --git a/src/common/Makefile b/src/common/Makefile deleted file mode 100644 index 43552dc..0000000 --- a/src/common/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -include ../../make.defs -all: core.o socket.o timer.o grfio.o db.o lock.o nullpo.o mt_rand.o md5calc.o - -core.o: core.c core.h -socket.o: socket.c socket.h mmo.h -timer.o: timer.c timer.h -grfio.o: grfio.c grfio.h -db.o: db.c db.h -lock.o: lock.c lock.h -nullpo.o: nullpo.c nullpo.h -mt_rand.o: mt_rand.c mt_rand.h -md5calc.o: md5calc.c md5calc.h - -clean: - rm -f *.o diff --git a/src/common/db.c b/src/common/db.c index cee17df..f56a511 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -229,7 +229,7 @@ static void db_rebalance_erase (struct dbn *z, struct dbn **root) z->parent->right = y; y->parent = z->parent; { - int tmp = y->color; + dbn_color tmp = y->color; y->color = z->color; z->color = tmp; } diff --git a/src/common/md5calc.c b/src/common/md5calc.c index d5ebcf8..ba8f6af 100644 --- a/src/common/md5calc.c +++ b/src/common/md5calc.c @@ -165,7 +165,7 @@ void MD5_to_bin(MD5_state state, uint8_t out[0x10]) out[i] = state.val[i/4] >> 8*(i%4); } -static const char hex[0x10] = "0123456789abcdef"; +static const char hex[] = "0123456789abcdef"; void MD5_to_str(MD5_state state, char out[0x21]) { @@ -198,7 +198,7 @@ MD5_state MD5_from_string(const char* msg, const size_t msglen) if (64 - rem > 8) { for (int i=0; i<8; i++) - buf[0x38+i] = (msglen*8) >> (i*8); + buf[0x38+i] = ((uint64_t)msglen*8) >> (i*8); } for (int i=0; i<0x10; i++) X[i] = buf[4*i+0] | buf[4*i+1]<<8 | buf[4*i+2]<<16 | buf[4*i+3]<<24; @@ -207,7 +207,7 @@ MD5_state MD5_from_string(const char* msg, const size_t msglen) { memset(buf,'\0', 0x38); for (int i=0; i<8; i++) - buf[0x38+i] = (msglen*8) >> (i*8); + buf[0x38+i] = ((uint64_t)msglen*8) >> (i*8); for (int i=0; i<0x10; i++) X[i] = buf[4*i+0] | buf[4*i+1]<<8 | buf[4*i+2]<<16 | buf[4*i+3]<<24; MD5_do_block(&state, block); @@ -291,7 +291,7 @@ const char *MD5_saltcrypt(const char *key, const char *salt) return obuf; } -const char *make_salt() { +const char *make_salt(void) { static char salt[6]; for (int i=0; i<5; i++) salt[i] = MPRAND(48, 78); diff --git a/src/common/md5calc.h b/src/common/md5calc.h index cf1425f..b864791 100644 --- a/src/common/md5calc.h +++ b/src/common/md5calc.h @@ -53,7 +53,7 @@ const char *MD5_saltcrypt(const char *key, const char *salt); /// return some random characters (statically allocated) // Currently, returns a 5-char string -const char *make_salt(); +const char *make_salt(void); /// check plaintext password against saved saltcrypt bool pass_ok(const char *password, const char *crypted); diff --git a/src/common/mmo.h b/src/common/mmo.h index 906f5c1..64e0523 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -5,12 +5,6 @@ # include <time.h> # include "utils.h" // LCCWIN32 -# ifdef CYGWIN -# define RETCODE "\r\n" -# else -# define RETCODE "\n" -# endif - # define FIFOSIZE_SERVERLINK 256*1024 // set to 0 to not check IP of player between each server. @@ -101,7 +95,7 @@ struct mmo_charstatus int base_exp, job_exp, zeny; - short class; + short pc_class; short status_point, skill_point; int hp, max_hp, sp, max_sp; short option, karma, manner; @@ -176,7 +170,7 @@ struct party struct guild_member { int account_id, char_id; - short hair, hair_color, gender, class, lv; + short hair, hair_color, gender, pc_class, lv; int exp, exp_payper; short online, position; int rsv1, rsv2; diff --git a/src/common/nullpo.c b/src/common/nullpo.c index de10517..8c7c405 100644 --- a/src/common/nullpo.c +++ b/src/common/nullpo.c @@ -47,6 +47,8 @@ void nullpo_info (const char *file, int line, const char *func) /// Actual output function static void nullpo_info_core (const char *file, int line, const char *func, + const char *fmt, va_list ap) __attribute__((format(printf, 4, 0))); +static void nullpo_info_core (const char *file, int line, const char *func, const char *fmt, va_list ap) { if (!file) diff --git a/src/common/socket.c b/src/common/socket.c index 7c86b1a..67a5102 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -23,8 +23,8 @@ fd_set readfds; int fd_max; int currentuse; -const uint32_t rfifo_size = 65536; -const uint32_t wfifo_size = 65536; +const uint32_t RFIFO_SIZE = 65536; +const uint32_t WFIFO_SIZE = 65536; struct socket_data *session[FD_SETSIZE]; @@ -126,11 +126,11 @@ static void connect_client (int listen_fd) fcntl (fd, F_SETFL, O_NONBLOCK); CREATE (session[fd], struct socket_data, 1); - CREATE (session[fd]->rdata, uint8_t, rfifo_size); - CREATE (session[fd]->wdata, uint8_t, wfifo_size); + CREATE (session[fd]->rdata, uint8_t, RFIFO_SIZE); + CREATE (session[fd]->wdata, uint8_t, WFIFO_SIZE); - session[fd]->max_rdata = rfifo_size; - session[fd]->max_wdata = wfifo_size; + session[fd]->max_rdata = RFIFO_SIZE; + session[fd]->max_wdata = WFIFO_SIZE; session[fd]->func_recv = recv_to_fifo; session[fd]->func_send = send_from_fifo; session[fd]->func_parse = default_func_parse; @@ -231,11 +231,11 @@ int make_connection (uint32_t ip, uint16_t port) FD_SET (fd, &readfds); CREATE (session[fd], struct socket_data, 1); - CREATE (session[fd]->rdata, uint8_t, rfifo_size); - CREATE (session[fd]->wdata, uint8_t, wfifo_size); + CREATE (session[fd]->rdata, uint8_t, RFIFO_SIZE); + CREATE (session[fd]->wdata, uint8_t, WFIFO_SIZE); - session[fd]->max_rdata = rfifo_size; - session[fd]->max_wdata = wfifo_size; + session[fd]->max_rdata = RFIFO_SIZE; + session[fd]->max_wdata = WFIFO_SIZE; session[fd]->func_recv = recv_to_fifo; session[fd]->func_send = send_from_fifo; session[fd]->func_parse = default_func_parse; @@ -399,7 +399,7 @@ FILE *fopen_ (const char *path, const char *mode) return f; } -bool free_fds () +bool free_fds (void) { return currentuse < SOFT_LIMIT; } diff --git a/src/common/socket.h b/src/common/socket.h index 0e15f5b..b886df0 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -130,6 +130,6 @@ void set_defaultparse (void (*defaultparse) (int)); /// Wrappers to track number of free FDs void fclose_ (FILE * fp); FILE *fopen_ (const char *path, const char *mode); -bool free_fds (); +bool free_fds (void); #endif // SOCKET_H diff --git a/src/common/timer.c b/src/common/timer.c index f4be19b..6795824 100644 --- a/src/common/timer.c +++ b/src/common/timer.c @@ -51,7 +51,7 @@ static void push_timer_heap (timer_id index) if (timer_heap == NULL || timer_heap[0] + 1 >= timer_heap_max) { timer_heap_max += 256; - RECREATE (timer_heap, int, timer_heap_max); + RECREATE (timer_heap, timer_id, timer_heap_max); memset (timer_heap + (timer_heap_max - 256), 0, sizeof (timer_id) * 256); } // timer_heap[0] is the greatest index into the heap, which increases @@ -71,14 +71,14 @@ static void push_timer_heap (timer_id index) timer_heap[h + 1] = index; } -static timer_id top_timer_heap () +static timer_id top_timer_heap (void) { if (!timer_heap || !timer_heap[0]) return -1; return timer_heap[1]; } -static timer_id pop_timer_heap () +static timer_id pop_timer_heap (void) { if (!timer_heap || !timer_heap[0]) return -1; @@ -227,7 +227,7 @@ interval_t do_timer (tick_t tick) switch (timer_data[i].type) { case TIMER_ONCE_AUTODEL: - timer_data[i].type = 0; + timer_data[i].type = TIMER_NONE; if (free_timer_list_pos >= free_timer_list_max) { free_timer_list_max += 256; diff --git a/src/common/timer.h b/src/common/timer.h index e363a56..e6a292c 100644 --- a/src/common/timer.h +++ b/src/common/timer.h @@ -5,8 +5,9 @@ enum TIMER_TYPE { - TIMER_ONCE_AUTODEL = 1, - TIMER_INTERVAL = 2, + TIMER_NONE, + TIMER_ONCE_AUTODEL, + TIMER_INTERVAL, }; /// This is needed to produce a signed result when 2 ticks are subtracted # define DIFF_TICK(a,b) ((int32_t)((a)-(b))) |