- Clean up of calc_times function.

- Moved to timer.c/h because it's used in both map and char servers.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@12382 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
zephyrus 2008-03-17 15:03:03 +00:00
parent d102bab107
commit a6e03e1102
7 changed files with 13 additions and 26 deletions

View File

@ -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); static int auction_end_timer(int tid, unsigned int tick, int id, int data);
// Copy Paste from map/mail.c // 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) static int auction_count(int char_id, bool buy)
{ {
int i = 0; int i = 0;
@ -86,7 +80,7 @@ unsigned int auction_create(struct auction_data *auction)
if( !auction ) if( !auction )
return false; return false;
auction->timestamp = (int)calc_times() + (auction->hours * 3600); auction->timestamp = calc_times() + (auction->hours * 3600);
StringBuf_Init(&buf); 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); 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; struct item *item;
char *data; char *data;
StringBuf buf; StringBuf buf;
unsigned int tick = gettick(), endtick, now = (unsigned int)calc_times(); unsigned int tick = gettick(), endtick, now = calc_times();
StringBuf_Init(&buf); StringBuf_Init(&buf);
StringBuf_AppendStr(&buf, "SELECT `auction_id`,`seller_id`,`seller_name`,`buyer_id`,`buyer_name`," StringBuf_AppendStr(&buf, "SELECT `auction_id`,`seller_id`,`seller_name`,`buyer_id`,`buyer_name`,"

View File

@ -7,6 +7,7 @@
#include "../common/socket.h" #include "../common/socket.h"
#include "../common/strlib.h" #include "../common/strlib.h"
#include "../common/sql.h" #include "../common/sql.h"
#include "../common/timer.h"
#include "char.h" #include "char.h"
#include "inter.h" #include "inter.h"
@ -14,13 +15,6 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
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) static int mail_fromsql(int char_id, struct mail_data* md)
{ {
int i, j; 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); safestrncpy(msg.title, temp_, MAIL_TITLE_LENGTH);
msg.status = MAIL_NEW; msg.status = MAIL_NEW;
msg.timestamp = (unsigned int)calc_times(); msg.timestamp = calc_times();
new_mail = mail_savemessage(&msg); new_mail = mail_savemessage(&msg);
mapif_Mail_new(&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 ) if( item != NULL )
memcpy(&msg.item, item, sizeof(struct item)); memcpy(&msg.item, item, sizeof(struct item));
msg.timestamp = (int)calc_times(); msg.timestamp = calc_times();
mail_savemessage(&msg); mail_savemessage(&msg);
mapif_Mail_new(&msg); mapif_Mail_new(&msg);

View File

@ -42,6 +42,12 @@ static int* timer_heap = NULL;
// server startup time // server startup time
time_t start_time; time_t start_time;
unsigned int calc_times(void)
{
time_t temp = time(NULL);
return (unsigned int)mktime(localtime(&temp));
}
/*---------------------------- /*----------------------------
* Timer debugging * Timer debugging

View File

@ -49,6 +49,7 @@ int settick_timer(int tid, unsigned int tick);
int add_timer_func_list(TimerFunc func, char* name); int add_timer_func_list(TimerFunc func, char* name);
unsigned long get_uptime(void); unsigned long get_uptime(void);
unsigned int calc_times(void);
int do_timer(); int do_timer();
void timer_init(void); void timer_init(void);

View File

@ -11714,7 +11714,7 @@ void clif_parse_Mail_send(int fd, struct map_session_data *sd)
else else
memset(msg.body, 0x00, MAIL_BODY_LENGTH); 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) ) if( !intif_Mail_send(sd->status.account_id, &msg) )
mail_deliveryfail(sd, &msg); mail_deliveryfail(sd, &msg);

View File

@ -16,12 +16,6 @@
#include <time.h> #include <time.h>
#include <string.h> #include <string.h>
time_t mail_calctimes(void)
{
time_t temp = time(NULL);
return mktime(localtime(&temp));
}
void mail_clear(struct map_session_data *sd) void mail_clear(struct map_session_data *sd)
{ {
sd->mail.nameid = 0; sd->mail.nameid = 0;

View File

@ -6,8 +6,6 @@
#include "../common/mmo.h" #include "../common/mmo.h"
time_t mail_calctimes(void);
void mail_clear(struct map_session_data *sd); void mail_clear(struct map_session_data *sd);
int mail_removeitem(struct map_session_data *sd, short flag); int mail_removeitem(struct map_session_data *sd, short flag);
int mail_removezeny(struct map_session_data *sd, short flag); int mail_removezeny(struct map_session_data *sd, short flag);