فهرست منبع

- 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

zephyrus 17 سال پیش
والد
کامیت
a6e03e1102
7فایلهای تغییر یافته به همراه13 افزوده شده و 26 حذف شده
  1. 2 8
      src/char_sql/int_auction.c
  2. 3 9
      src/char_sql/int_mail.c
  3. 6 0
      src/common/timer.c
  4. 1 0
      src/common/timer.h
  5. 1 1
      src/map/clif.c
  6. 0 6
      src/map/mail.c
  7. 0 2
      src/map/mail.h

+ 2 - 8
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`,"

+ 3 - 9
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 <string.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)
 {
 	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);

+ 6 - 0
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

+ 1 - 0
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);

+ 1 - 1
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);
 

+ 0 - 6
src/map/mail.c

@@ -16,12 +16,6 @@
 #include <time.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)
 {
 	sd->mail.nameid = 0;

+ 0 - 2
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);