diff --git a/src/char_sql/int_auction.c b/src/char_sql/int_auction.c index a21dbb22f1..2e5e90c1d0 100644 --- a/src/char_sql/int_auction.c +++ b/src/char_sql/int_auction.c @@ -23,12 +23,6 @@ void auction_delete(struct auction_data *auction); static int auction_end_timer(int tid, unsigned int tick, int id, int data); // Copy Paste from map/mail.c -time_t calc_times(void) -{ - time_t temp = time(NULL); - return mktime(localtime(&temp)); -} - static int auction_count(int char_id, bool buy) { int i = 0; @@ -86,7 +80,7 @@ unsigned int auction_create(struct auction_data *auction) if( !auction ) return false; - auction->timestamp = (int)calc_times() + (auction->hours * 3600); + auction->timestamp = calc_times() + (auction->hours * 3600); StringBuf_Init(&buf); StringBuf_Printf(&buf, "INSERT INTO `%s` (`seller_id`,`seller_name`,`buyer_id`,`buyer_name`,`price`,`buynow`,`hours`,`timestamp`,`nameid`,`item_name`,`type`,`refine`,`attribute`", auction_db); @@ -184,7 +178,7 @@ void inter_auctions_fromsql(void) struct item *item; char *data; StringBuf buf; - unsigned int tick = gettick(), endtick, now = (unsigned int)calc_times(); + unsigned int tick = gettick(), endtick, now = calc_times(); StringBuf_Init(&buf); StringBuf_AppendStr(&buf, "SELECT `auction_id`,`seller_id`,`seller_name`,`buyer_id`,`buyer_name`," diff --git a/src/char_sql/int_mail.c b/src/char_sql/int_mail.c index 9ae4e1ccdc..86a076b0d1 100644 --- a/src/char_sql/int_mail.c +++ b/src/char_sql/int_mail.c @@ -7,6 +7,7 @@ #include "../common/socket.h" #include "../common/strlib.h" #include "../common/sql.h" +#include "../common/timer.h" #include "char.h" #include "inter.h" @@ -14,13 +15,6 @@ #include #include -static time_t calc_times(void) -{ - time_t temp = time(NULL); - return mktime(localtime(&temp)); -} - - static int mail_fromsql(int char_id, struct mail_data* md) { int i, j; @@ -359,7 +353,7 @@ static void mapif_Mail_return(int fd, int char_id, int mail_id) safestrncpy(msg.title, temp_, MAIL_TITLE_LENGTH); msg.status = MAIL_NEW; - msg.timestamp = (unsigned int)calc_times(); + msg.timestamp = calc_times(); new_mail = mail_savemessage(&msg); mapif_Mail_new(&msg); @@ -444,7 +438,7 @@ void mail_sendmail(int send_id, const char* send_name, int dest_id, const char* if( item != NULL ) memcpy(&msg.item, item, sizeof(struct item)); - msg.timestamp = (int)calc_times(); + msg.timestamp = calc_times(); mail_savemessage(&msg); mapif_Mail_new(&msg); diff --git a/src/common/timer.c b/src/common/timer.c index 2c8236e3d5..0eb16c45f6 100644 --- a/src/common/timer.c +++ b/src/common/timer.c @@ -42,6 +42,12 @@ static int* timer_heap = NULL; // server startup time time_t start_time; +unsigned int calc_times(void) +{ + time_t temp = time(NULL); + + return (unsigned int)mktime(localtime(&temp)); +} /*---------------------------- * Timer debugging diff --git a/src/common/timer.h b/src/common/timer.h index 4fa4a3c2da..7eedb689e5 100644 --- a/src/common/timer.h +++ b/src/common/timer.h @@ -49,6 +49,7 @@ int settick_timer(int tid, unsigned int tick); int add_timer_func_list(TimerFunc func, char* name); unsigned long get_uptime(void); +unsigned int calc_times(void); int do_timer(); void timer_init(void); diff --git a/src/map/clif.c b/src/map/clif.c index cbcada2b19..3f6cf94f66 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -11714,7 +11714,7 @@ void clif_parse_Mail_send(int fd, struct map_session_data *sd) else memset(msg.body, 0x00, MAIL_BODY_LENGTH); - msg.timestamp = (int)mail_calctimes(); + msg.timestamp = calc_times(); if( !intif_Mail_send(sd->status.account_id, &msg) ) mail_deliveryfail(sd, &msg); diff --git a/src/map/mail.c b/src/map/mail.c index d6fc875a3b..733fce646e 100644 --- a/src/map/mail.c +++ b/src/map/mail.c @@ -16,12 +16,6 @@ #include #include -time_t mail_calctimes(void) -{ - time_t temp = time(NULL); - return mktime(localtime(&temp)); -} - void mail_clear(struct map_session_data *sd) { sd->mail.nameid = 0; diff --git a/src/map/mail.h b/src/map/mail.h index 9a867daa59..cab582e558 100644 --- a/src/map/mail.h +++ b/src/map/mail.h @@ -6,8 +6,6 @@ #include "../common/mmo.h" -time_t mail_calctimes(void); - void mail_clear(struct map_session_data *sd); int mail_removeitem(struct map_session_data *sd, short flag); int mail_removezeny(struct map_session_data *sd, short flag);