Skip to content

Commit

Permalink
Merge pull request #2023 from MishimaHaruna/remove-stat-server
Browse files Browse the repository at this point in the history
Remove stat server
  • Loading branch information
MishimaHaruna committed Apr 25, 2018
2 parents a4df55e + 0903a1f commit a1f048f
Show file tree
Hide file tree
Showing 14 changed files with 9 additions and 312 deletions.
46 changes: 1 addition & 45 deletions src/char/char.c
Expand Up @@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
* Copyright (C) 2012-2016 Hercules Dev Team
* Copyright (C) 2012-2018 Hercules Dev Team
* Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -3803,41 +3803,6 @@ void char_parse_frommap_update_ip(int fd, int id)
RFIFOSKIP(fd,6);
}

void char_parse_frommap_request_stats_report(int fd)
{
int sfd;/* stat server fd */
struct hSockOpt opt;
RFIFOSKIP(fd, 2);/* we skip first 2 bytes which are the 0x3008, so we end up with a buffer equal to the one we send */

opt.silent = 1;
opt.setTimeo = 1;

if ((sfd = sockt->make_connection(sockt->host2ip("stats.herc.ws"),(uint16)25427,&opt) ) == -1) {
RFIFOSKIP(fd, RFIFOW(fd,2) );/* skip this packet */
RFIFOFLUSH(fd);
return;/* connection not possible, we drop the report */
}

sockt->session[sfd]->flag.server = 1;/* to ensure we won't drop our own packet */
sockt->realloc_fifo(sfd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);

WFIFOHEAD(sfd, RFIFOW(fd,2) );

memcpy(WFIFOP(sfd,0), RFIFOP(fd, 0), RFIFOW(fd,2));

WFIFOSET(sfd, RFIFOW(fd,2) );

do {
sockt->flush(sfd);
HSleep(1);
} while( !sockt->session[sfd]->flag.eof && sockt->session[sfd]->wdata_size );

sockt->close(sfd);

RFIFOSKIP(fd, RFIFOW(fd,2) );/* skip this packet */
RFIFOFLUSH(fd);
}

void char_parse_frommap_scdata_update(int fd)
{
int account_id = RFIFOL(fd, 2);
Expand Down Expand Up @@ -4068,14 +4033,6 @@ int char_parse_frommap(int fd)
chr->parse_frommap_update_ip(fd, id);
break;

case 0x3008:
if( RFIFOREST(fd) < RFIFOW(fd,4) )
return 0;/* packet wasn't fully received yet (still fragmented) */
else {
chr->parse_frommap_request_stats_report(fd);
}
break;

/* individual sc data insertion/update */
case 0x2740:
if( RFIFOREST(fd) < 28 )
Expand Down Expand Up @@ -6577,7 +6534,6 @@ void char_defaults(void)
chr->map_auth_failed = char_map_auth_failed;
chr->parse_frommap_auth_request = char_parse_frommap_auth_request;
chr->parse_frommap_update_ip = char_parse_frommap_update_ip;
chr->parse_frommap_request_stats_report = char_parse_frommap_request_stats_report;
chr->parse_frommap_scdata_update = char_parse_frommap_scdata_update;
chr->parse_frommap_scdata_delete = char_parse_frommap_scdata_delete;
chr->parse_frommap = char_parse_frommap;
Expand Down
3 changes: 1 addition & 2 deletions src/char/char.h
Expand Up @@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
* Copyright (C) 2012-2016 Hercules Dev Team
* Copyright (C) 2012-2018 Hercules Dev Team
* Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -225,7 +225,6 @@ struct char_interface {
void (*map_auth_failed) (int fd, int account_id, int char_id, int login_id1, char sex, uint32 ip);
void (*parse_frommap_auth_request) (int fd, int id);
void (*parse_frommap_update_ip) (int fd, int id);
void (*parse_frommap_request_stats_report) (int fd);
void (*parse_frommap_scdata_update) (int fd);
void (*parse_frommap_scdata_delete) (int fd);
int (*parse_frommap) (int fd);
Expand Down
3 changes: 1 addition & 2 deletions src/char/inter.c
Expand Up @@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
* Copyright (C) 2012-2016 Hercules Dev Team
* Copyright (C) 2012-2018 Hercules Dev Team
* Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -1411,7 +1411,6 @@ int inter_parse_frommap(int fd)
case 0x3005: mapif->parse_RegistryRequest(fd); break;
case 0x3006: mapif->parse_NameChangeRequest(fd); break;
case 0x3007: mapif->parse_accinfo(fd); break;
/* 0x3008 is used by the report stuff */
default:
if( inter_party->parse_frommap(fd)
|| inter_guild->parse_frommap(fd)
Expand Down
6 changes: 1 addition & 5 deletions src/config/core.h
Expand Up @@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
* Copyright (C) 2012-2016 Hercules Dev Team
* Copyright (C) 2012-2018 Hercules Dev Team
* Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -58,10 +58,6 @@
/// Maximum number of characters 'CONSOLE_INPUT' will support per line.
#define MAX_CONSOLE_INPUT 150

/// Uncomment to disable Hercules' anonymous stat report
/// We kindly ask you to consider keeping it enabled, it helps us improve Hercules.
//#define STATS_OPT_OUT

/// Uncomment to enable the Cell Stack Limit mod.
/// It's only config is the battle_config custom_cell_stack_limit.
/// Only chars affected are those defined in BL_CHAR
Expand Down
173 changes: 2 additions & 171 deletions src/map/battle.c
Expand Up @@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
* Copyright (C) 2012-2016 Hercules Dev Team
* Copyright (C) 2012-2018 Hercules Dev Team
* Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
Expand All @@ -20,11 +20,10 @@
*/
#define HERCULES_CORE

#include "config/core.h" // CELL_NOSTACK, CIRCULAR_AREA, CONSOLE_INPUT, HMAP_ZONE_DAMAGE_CAP_TYPE, OFFICIAL_WALKPATH, RENEWAL, RENEWAL_ASPD, RENEWAL_CAST, RENEWAL_DROP, RENEWAL_EDP, RENEWAL_EXP, RENEWAL_LVDMG, RE_LVL_DMOD(), RE_LVL_MDMOD(), RE_LVL_TMDMOD(), RE_SKILL_REDUCTION(), SCRIPT_CALLFUNC_CHECK, SECURE_NPCTIMEOUT, STATS_OPT_OUT
#include "config/core.h" // CELL_NOSTACK, CIRCULAR_AREA, CONSOLE_INPUT, HMAP_ZONE_DAMAGE_CAP_TYPE, OFFICIAL_WALKPATH, RENEWAL, RENEWAL_ASPD, RENEWAL_CAST, RENEWAL_DROP, RENEWAL_EDP, RENEWAL_EXP, RENEWAL_LVDMG, RE_LVL_DMOD(), RE_LVL_MDMOD(), RE_LVL_TMDMOD(), RE_SKILL_REDUCTION(), SCRIPT_CALLFUNC_CHECK, SECURE_NPCTIMEOUT
#include "battle.h"

#include "map/battleground.h"
#include "map/chrif.h"
#include "map/clan.h"
#include "map/clif.h"
#include "map/elemental.h"
Expand Down Expand Up @@ -7324,168 +7323,6 @@ static const struct battle_data {
{ "features/enable_attendance_system", &battle_config.feature_enable_attendance_system,1, 0, 1, },
{ "features/feature_attendance_endtime",&battle_config.feature_attendance_endtime, 1, 0, 99999999, },
};
#ifndef STATS_OPT_OUT
/**
* Hercules anonymous statistic usage report -- packet is built here, and sent to char server to report.
**/
void Hercules_report(char* date, char *time_c) {
int i, bd_size = ARRAYLENGTH(battle_data);
unsigned int config = 0;
char timestring[25];
time_t curtime;
char* buf;

enum config_table {
C_CIRCULAR_AREA = 0x0001,
C_CELLNOSTACK = 0x0002,
C_CONSOLE_INPUT = 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_DB_ITEM = 0x2000,
C_SQL_LOGS = 0x4000,
C_MEMWATCH = 0x8000,
C_DMALLOC = 0x10000,
C_GCOLLECT = 0x20000,
C_SEND_SHORTLIST = 0x40000,
//C_SQL_DB_MOB = 0x80000,
//C_SQL_DB_MOBSKILL = 0x100000,
C_PACKETVER_RE = 0x200000,
};

/* 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 CONSOLE_INPUT
config |= C_CONSOLE_INPUT;
#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

#ifdef SECURE_NPCTIMEOUT
config |= C_SECURE_NPCTIMEOUT;
#endif

#ifdef PACKETVER_RE
config |= C_PACKETVER_RE;
#endif

/* non-define part */
if( logs->config.sql_logs )
config |= C_SQL_LOGS;

#ifdef MEMWATCH
config |= C_MEMWATCH;
#endif
#ifdef DMALLOC
config |= C_DMALLOC;
#endif
#ifdef GCOLLECT
config |= C_GCOLLECT;
#endif

#ifdef SEND_SHORTLIST
config |= C_SEND_SHORTLIST;
#endif

#define BFLAG_LENGTH 35

CREATE(buf, char, 262 + ( bd_size * ( BFLAG_LENGTH + 4 ) ) + 1 );

/* build packet */

WBUFW(buf,0) = 0x3000;
WBUFW(buf,2) = 262 + ( bd_size * ( BFLAG_LENGTH + 4 ) );
WBUFW(buf,4) = 0x9f;

safestrncpy(WBUFP(buf,6), date, 12);
safestrncpy(WBUFP(buf,18), time_c, 9);
safestrncpy(WBUFP(buf,27), timestring, 24);

safestrncpy(WBUFP(buf,51), sysinfo->platform(), 16);
safestrncpy(WBUFP(buf,67), sysinfo->osversion(), 50);
safestrncpy(WBUFP(buf,117), sysinfo->cpu(), 32);
WBUFL(buf,149) = sysinfo->cpucores();
safestrncpy(WBUFP(buf,153), sysinfo->arch(), 8);
WBUFB(buf,161) = sysinfo->vcstypeid();
WBUFB(buf,162) = sysinfo->is64bit();
safestrncpy(WBUFP(buf,163), sysinfo->vcsrevision_src(), 41);
safestrncpy(WBUFP(buf,204), sysinfo->vcsrevision_scripts(), 41);
WBUFB(buf,245) = (sysinfo->is_superuser()? 1 : 0);
WBUFL(buf,246) = map->getusers();

WBUFL(buf,250) = config;
WBUFL(buf,254) = PACKETVER;

WBUFL(buf,258) = bd_size;
for( i = 0; i < bd_size; i++ ) {
safestrncpy(WBUFP(buf,262 + ( i * ( BFLAG_LENGTH + 4 ) ) ), battle_data[i].str, BFLAG_LENGTH);
WBUFL(buf,262 + BFLAG_LENGTH + ( i * ( BFLAG_LENGTH + 4 ) ) ) = *battle_data[i].val;
}

chrif->send_report(buf, 262 + ( bd_size * ( BFLAG_LENGTH + 4 ) ) );

aFree(buf);

#undef BFLAG_LENGTH
}
static int Hercules_report_timer(int tid, int64 tick, int id, intptr_t data) {
if( chrif->isconnected() ) {/* char server relays it, so it must be online. */
Hercules_report(__DATE__,__TIME__);
}
return 0;
}
#endif

bool battle_set_value_sub(int index, int value)
{
Expand Down Expand Up @@ -7694,12 +7531,6 @@ void do_init_battle(bool minimal) {

battle->delay_damage_ers = ers_new(sizeof(struct delay_damage),"battle.c::delay_damage_ers",ERS_OPT_CLEAR);
timer->add_func_list(battle->delay_damage_sub, "battle_delay_damage_sub");

#ifndef STATS_OPT_OUT
timer->add_func_list(Hercules_report_timer, "Hercules_report_timer");
timer->add_interval(timer->gettick()+30000, Hercules_report_timer, 0, 0, 60000 * 30);
#endif

}

void do_final_battle(void) {
Expand Down
21 changes: 2 additions & 19 deletions src/map/chrif.c
Expand Up @@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
* Copyright (C) 2012-2016 Hercules Dev Team
* Copyright (C) 2012-2018 Hercules Dev Team
* Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
Expand All @@ -20,7 +20,7 @@
*/
#define HERCULES_CORE

#include "config/core.h" // AUTOTRADE_PERSISTENCY, STATS_OPT_OUT
#include "config/core.h" // AUTOTRADE_PERSISTENCY
#include "chrif.h"

#include "map/battle.h"
Expand Down Expand Up @@ -1561,22 +1561,6 @@ bool chrif_removefriend(int char_id, int friend_id)
return true;
}

void chrif_send_report(char* buf, int len) {
#ifndef STATS_OPT_OUT
if( chrif->fd > 0 ) {
nullpo_retv(buf);
WFIFOHEAD(chrif->fd,len + 2);

WFIFOW(chrif->fd,0) = 0x3008;
memcpy(WFIFOP(chrif->fd,2), buf, len);

WFIFOSET(chrif->fd,len + 2);

sockt->flush(chrif->fd); /* ensure it's sent now. */
}
#endif
}

/**
* Sends a single scdata for saving into char server, meant to ensure integrity of duration-less conditions
**/
Expand Down Expand Up @@ -1756,7 +1740,6 @@ void chrif_defaults(void) {
chrif->divorce = chrif_divorce;

chrif->removefriend = chrif_removefriend;
chrif->send_report = chrif_send_report;

chrif->flush = chrif_flush;
chrif->skillid2idx = chrif_skillid2idx;
Expand Down
3 changes: 1 addition & 2 deletions src/map/chrif.h
Expand Up @@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
* Copyright (C) 2012-2016 Hercules Dev Team
* Copyright (C) 2012-2018 Hercules Dev Team
* Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -124,7 +124,6 @@ struct chrif_interface {
bool (*divorce) (int partner_id1, int partner_id2);

bool (*removefriend) (int char_id, int friend_id);
void (*send_report) (char* buf, int len);

bool (*flush) (void);
void (*skillid2idx) (int fd);
Expand Down

0 comments on commit a1f048f

Please sign in to comment.