make the game upload stats by default
This commit is contained in:
parent
4dcc742e56
commit
ee8ee9c413
5 changed files with 31 additions and 7 deletions
|
@ -1,4 +1,8 @@
|
|||
#textdomain wesnoth
|
||||
[tip]
|
||||
text= _ "Battle for Wesnoth automatically sends anonymized statistics about your game advancement to a server where they are stored. This enables several features, and allows us to improve Wesnoth. To learn more about this or disable it, click the envelope in the bottom-right corner."
|
||||
source= _ "Wesnoth Developers"
|
||||
[/tip]
|
||||
[tip]
|
||||
text= _ "Don't neglect to earn your leader experience! You need to keep him safe, but if you coddle him too much he may be at too low a level to survive future battles."
|
||||
source= _ "- Great Mage Delfador, 516YW"
|
||||
|
|
|
@ -690,14 +690,19 @@ void set_flip_time(bool value)
|
|||
preferences::set("flip_time", value ? "yes" : "no");
|
||||
}
|
||||
|
||||
bool has_upload_log()
|
||||
{
|
||||
return preferences::get("upload_log_new").empty() == false;
|
||||
}
|
||||
|
||||
bool upload_log()
|
||||
{
|
||||
return utils::string_bool(preferences::get("upload_log"), false);
|
||||
return utils::string_bool(preferences::get("upload_log_new"), true);
|
||||
}
|
||||
|
||||
void set_upload_log(bool value)
|
||||
{
|
||||
preferences::set("upload_log", value ? "yes" : "no");
|
||||
preferences::set("upload_log_new", value ? "yes" : "no");
|
||||
}
|
||||
|
||||
std::string upload_id()
|
||||
|
|
|
@ -163,6 +163,7 @@ namespace preferences {
|
|||
bool flip_time();
|
||||
void set_flip_time(bool value);
|
||||
|
||||
bool has_upload_log();
|
||||
bool upload_log();
|
||||
void set_upload_log(bool value);
|
||||
std::string upload_id();
|
||||
|
|
|
@ -142,11 +142,21 @@ static void read_tips_of_day(config& tips_of_day)
|
|||
ERR_CONFIG << "Could not read data/hardwired/tips.cfg\n";
|
||||
}
|
||||
|
||||
//we shuffle the tips after each initial loading
|
||||
//we shuffle the tips after each initial loading. We only shuffle if
|
||||
//the upload_log preference has been set. If it hasn't been set, it's the
|
||||
//user's first time playing since this feature has been added, so we'll
|
||||
//leave the tips in their default order, which will always contain a tip
|
||||
//regarding the upload log first, so the user sees it.
|
||||
config::child_itors tips = tips_of_day.child_range("tip");
|
||||
if (tips.first != tips.second) {
|
||||
if (tips.first != tips.second && preferences::has_upload_log()) {
|
||||
std::random_shuffle(tips.first, tips.second);
|
||||
}
|
||||
|
||||
//Make sure that the upload log preference is set, if it's not already, so
|
||||
//that we know next time we've already seen the message about uploads.
|
||||
if(!preferences::has_upload_log()) {
|
||||
preferences::set_upload_log(preferences::upload_log);
|
||||
}
|
||||
}
|
||||
|
||||
/** Go to the next tips-of-the-day */
|
||||
|
|
|
@ -31,8 +31,8 @@
|
|||
|
||||
|
||||
|
||||
#define TARGET_HOST "stats.wesnoth.org"
|
||||
#define TARGET_URL "/upload.cgi"
|
||||
#define TARGET_HOST "www.wesnoth.org"
|
||||
#define TARGET_URL "/cgi-bin/upload"
|
||||
#define TARGET_PORT 80
|
||||
|
||||
struct upload_log::thread_info upload_log::thread_;
|
||||
|
@ -106,6 +106,11 @@ static int upload_logs(void *_ti)
|
|||
send_string(sock, "\n\n");
|
||||
send_string(sock, contents.c_str());
|
||||
|
||||
// As long as we can actually send the data, delete the file.
|
||||
// Even if the server gives a bad response, we don't want to
|
||||
// be sending the same bad data over and over to the server.
|
||||
delete_directory(*i);
|
||||
|
||||
if (SDLNet_TCP_Recv(sock, response, sizeof(response))
|
||||
!= sizeof(response))
|
||||
break;
|
||||
|
@ -115,7 +120,6 @@ static int upload_logs(void *_ti)
|
|||
if (memcmp(response+8, " 2", strlen(" 2")) != 0)
|
||||
break;
|
||||
|
||||
delete_directory(*i);
|
||||
SDLNet_TCP_Close(sock);
|
||||
sock = NULL;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue