diff options
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/battle.c | 142 | ||||
-rw-r--r-- | src/map/chrif.c | 16 | ||||
-rw-r--r-- | src/map/chrif.h | 5 |
3 files changed, 159 insertions, 4 deletions
diff --git a/src/map/battle.c b/src/map/battle.c index c48f4ce63..b83e2053d 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -8,6 +8,7 @@ #include "../common/showmsg.h" #include "../common/ers.h" #include "../common/random.h" +#include "../common/socket.h" #include "../common/strlib.h" #include "../common/utils.h" @@ -27,6 +28,7 @@ #include "party.h" #include "battle.h" #include "battleground.h" +#include "chrif.h" #include <stdio.h> #include <stdlib.h> @@ -5717,7 +5719,141 @@ static const struct _battle_data { { "homunculus_max_level", &battle_config.hom_max_level, 99, 0, MAX_LEVEL, }, { "homunculus_S_max_level", &battle_config.hom_S_max_level, 150, 0, MAX_LEVEL, }, }; +#ifndef STATS_OPT_OUT +/** + * rAthena anonymous statistic usage report -- packet is built here, and sent to char server to report. + **/ +void rAthena_report(char* date, char *time_c) { + int i, rev = 0, bd_size = ARRAYLENGTH(battle_data); + unsigned int config = 0; + const char* rev_str; + char timestring[25]; + time_t curtime; + char* buf; + + enum config_table { + C_CIRCULAR_AREA = 0x0001, + C_CELLNOSTACK = 0x0002, + C_BETA_THREAD_TEST = 0x0004, + C_SCRIPT_CALLFUNC_CHECK = 0x0008, + C_OFFICIAL_WALKPATH = 0x0010, + C_RENEWAL = 0x0020, + C_RENEWAL_CAST = 0x0040, + C_RENEWAL_DROP = 0x0080, + C_RENEWAL_EXP = 0x0100, + C_RENEWAL_LVDMG = 0x0200, + C_RENEWAL_EDP = 0x0400, + C_RENEWAL_ASPD = 0x0800, + C_SECURE_NPCTIMEOUT = 0x1000, + C_SQL_DBS = 0x2000, + C_SQL_LOGS = 0x4000, + }; + + if( (rev_str = get_svn_revision()) != 0 ) + rev = atoi(rev_str); + + /* we get the current time */ + time(&curtime); + strftime(timestring, 24, "%Y-%m-%d %H:%M:%S", localtime(&curtime)); + + +#ifdef CIRCULAR_AREA + config |= C_CIRCULAR_AREA; +#endif + +#ifdef CELL_NOSTACK + config |= C_CELLNOSTACK; +#endif + +#ifdef BETA_THREAD_TEST + config |= C_BETA_THREAD_TEST; +#endif + +#ifdef SCRIPT_CALLFUNC_CHECK + config |= C_SCRIPT_CALLFUNC_CHECK; +#endif + +#ifdef OFFICIAL_WALKPATH + config |= C_OFFICIAL_WALKPATH; +#endif + +#ifdef RENEWAL + config |= C_RENEWAL; +#endif + +#ifdef RENEWAL_CAST + config |= C_RENEWAL_CAST; +#endif + +#ifdef RENEWAL_DROP + config |= C_RENEWAL_DROP; +#endif + +#ifdef RENEWAL_EXP + config |= C_RENEWAL_EXP; +#endif + +#ifdef RENEWAL_LVDMG + config |= C_RENEWAL_LVDMG; +#endif +#ifdef RENEWAL_EDP + config |= C_RENEWAL_EDP; +#endif + +#ifdef RENEWAL_ASPD + config |= C_RENEWAL_ASPD; +#endif + +/* not a ifdef because SECURE_NPCTIMEOUT is always defined, but either as 0 or higher */ +#if SECURE_NPCTIMEOUT + config |= C_SECURE_NPCTIMEOUT; +#endif + /* non-define part */ + if( db_use_sqldbs ) + config |= C_SQL_DBS; + + if( log_config.sql_logs ) + config |= C_SQL_LOGS; + +#define BFLAG_LENGTH 35 + + CREATE(buf, char, 6 + 12 + 9 + 24 + 4 + 4 + 4 + 4 + ( bd_size * ( BFLAG_LENGTH + 4 ) ) + 1 ); + + /* build packet */ + + WBUFW(buf,0) = 0x3000; + WBUFW(buf,2) = 6 + 12 + 9 + 24 + 4 + 4 + 4 + 4 + ( bd_size * ( BFLAG_LENGTH + 4 ) ); + WBUFW(buf,4) = 0x9c; + + safestrncpy((char*)WBUFP(buf,6), date, 12); + safestrncpy((char*)WBUFP(buf,6 + 12), time_c, 9); + safestrncpy((char*)WBUFP(buf,6 + 12 + 9), timestring, 24); + + WBUFL(buf,6 + 12 + 9 + 24) = rev; + WBUFL(buf,6 + 12 + 9 + 24 + 4) = map_getusers(); + + WBUFL(buf,6 + 12 + 9 + 24 + 4 + 4) = config; + WBUFL(buf,6 + 12 + 9 + 24 + 4 + 4 + 4) = bd_size; + + for( i = 0; i < bd_size; i++ ) { + safestrncpy((char*)WBUFP(buf,6 + 12 + 9+ 24 + 4 + 4 + 4 + 4 + ( i * ( BFLAG_LENGTH + 4 ) ) ), battle_data[i].str, 35); + WBUFL(buf,6 + 12 + 9 + 24 + 4 + 4 + 4 + 4 + BFLAG_LENGTH + ( i * ( BFLAG_LENGTH + 4 ) ) ) = *battle_data[i].val; + } + + chrif_send_report(buf, 6 + 12 + 9 + 24 + 4 + 4 + 4 + 4 + ( bd_size * ( BFLAG_LENGTH + 4 ) ) ); + + aFree(buf); + +#undef BFLAG_LENGTH +} +static int rAthena_report_timer(int tid, unsigned int tick, int id, intptr_t data) { + if( chrif_isconnected() ) {/* char server relays it, so it must be online. */ + rAthena_report(__DATE__,__TIME__); + } + return 0; +} +#endif int battle_set_value(const char* w1, const char* w2) { @@ -5841,6 +5977,12 @@ void do_init_battle(void) { delay_damage_ers = ers_new(sizeof(struct delay_damage),"battle.c::delay_damage_ers",ERS_OPT_CLEAR); add_timer_func_list(battle_delay_damage_sub, "battle_delay_damage_sub"); + +#ifndef STATS_OPT_OUT + add_timer_func_list(rAthena_report_timer, "rAthena_report_timer"); + add_timer_interval(gettick()+30000, rAthena_report_timer, 0, 0, 60000 * 30); +#endif + } void do_final_battle(void) diff --git a/src/map/chrif.c b/src/map/chrif.c index 064104018..02bd3686c 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -1523,7 +1523,7 @@ static int check_connect_char_server(int tid, unsigned int tick, int id, intptr_ } chrif_state = 0; - char_fd = make_connection(char_ip, char_port); + char_fd = make_connection(char_ip, char_port,false); if (char_fd == -1) { //Attempt to connect later. [Skotlex] return 0; @@ -1562,6 +1562,20 @@ int chrif_removefriend(int char_id, int friend_id) { return 0; } +void chrif_send_report(char* buf, int len) { +#ifndef STATS_OPT_OUT + WFIFOHEAD(char_fd,len + 2); + + WFIFOW(char_fd,0) = 0x3008; + + memcpy(WFIFOP(char_fd,2), buf, len); + + WFIFOSET(char_fd,len + 2); + + flush_fifo(char_fd); /* ensure it's sent now. */ +#endif +} + /** * @see DBApply */ diff --git a/src/map/chrif.h b/src/map/chrif.h index dda80cec9..0aadb1a7b 100644 --- a/src/map/chrif.h +++ b/src/map/chrif.h @@ -57,10 +57,9 @@ int chrif_char_online(struct map_session_data *sd); int chrif_changesex(struct map_session_data *sd); int chrif_chardisconnect(struct map_session_data *sd); int chrif_divorce(int partner_id1, int partner_id2); -/** - * rAthena - **/ + int chrif_removefriend(int char_id, int friend_id); +void chrif_send_report(char* buf, int len); int do_final_chrif(void); int do_init_chrif(void); |