diff options
author | shennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2012-09-16 21:14:33 +0000 |
---|---|---|
committer | shennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2012-09-16 21:14:33 +0000 |
commit | 5cd75ecd95c257e61c15fef5692918c5642e2aea (patch) | |
tree | 76433fa0e32f228d737b651a81ded6da34fbf1aa /src/map/battle.c | |
parent | 77912311a7ad7151e4a2476cac73f3ec181d27bd (diff) | |
download | hercules-5cd75ecd95c257e61c15fef5692918c5642e2aea.tar.gz hercules-5cd75ecd95c257e61c15fef5692918c5642e2aea.tar.bz2 hercules-5cd75ecd95c257e61c15fef5692918c5642e2aea.tar.xz hercules-5cd75ecd95c257e61c15fef5692918c5642e2aea.zip |
Introducing rAthena's anonymous data collector. This aims at improving rAthena's overall features by letting we know which options are most and least used.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16785 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/battle.c')
-rw-r--r-- | src/map/battle.c | 142 |
1 files changed, 142 insertions, 0 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) |