Feature: opt-in survey when exiting a game

On first start-up, the game will ask if you want to participate
in our automated survey. You have to opt-in, and can easily opt-out
(via the Options) at any time.

When opt-in, whenever you exit a game, a JSON blob will be send
to the survey server hosted by OpenTTD. This JSON blob contains
information that gives a global picture of the game just played:
- What settings were used
- How many humans vs AIs
- How long the game has been played
- Basic information about the OS / CPU

All this information is kept very generic, so there is no
chance we send private information to our survey server.
Nothing in the JSON blob could identify you as a person; it
mostly tells about the game played. At any time you can see
what the JSON blob includes, by pressing the "Preview Survey
Results" button in-game.
This commit is contained in:
Patric Stout
2023-04-25 19:43:45 +02:00
committed by Patric Stout
parent 021c45c4f6
commit 7634553d22
54 changed files with 1018 additions and 53 deletions

View File

@@ -67,6 +67,7 @@
#include "framerate_type.h"
#include "industry.h"
#include "network/network_gui.h"
#include "network/network_survey.h"
#include "misc_cmd.h"
#include "timer/timer.h"
#include "timer/timer_game_calendar.h"
@@ -822,6 +823,7 @@ void HandleExitGameRequest()
_exit_game = true;
} else if (_settings_client.gui.autosave_on_exit) {
DoExitSave();
_survey.Transmit(NetworkSurveyHandler::Reason::EXIT, true);
_exit_game = true;
} else {
AskExitGame();
@@ -1036,9 +1038,16 @@ void SwitchToMode(SwitchMode new_mode)
/* When we change mode, reset the autosave. */
if (new_mode != SM_SAVE_GAME) ChangeAutosaveFrequency(true);
/* Transmit the survey if we were in normal-mode and not saving. It always means we leaving the current game. */
if (_game_mode == GM_NORMAL && new_mode != SM_SAVE_GAME) _survey.Transmit(NetworkSurveyHandler::Reason::LEAVE);
/* Keep track when we last switch mode. Used for survey, to know how long someone was in a game. */
if (new_mode != SM_SAVE_GAME) _switch_mode_time = std::chrono::steady_clock::now();
switch (new_mode) {
case SM_EDITOR: // Switch to scenario editor
MakeNewEditorWorld();
GenerateSavegameId();
break;
case SM_RELOADGAME: // Reload with what-ever started the game
@@ -1055,11 +1064,13 @@ void SwitchToMode(SwitchMode new_mode)
}
MakeNewGame(false, new_mode == SM_NEWGAME);
GenerateSavegameId();
break;
case SM_RESTARTGAME: // Restart --> 'Random game' with current settings
case SM_NEWGAME: // New Game --> 'Random game'
MakeNewGame(false, new_mode == SM_NEWGAME);
GenerateSavegameId();
break;
case SM_LOAD_GAME: { // Load game, Play Scenario
@@ -1083,18 +1094,21 @@ void SwitchToMode(SwitchMode new_mode)
case SM_RESTART_HEIGHTMAP: // Load a heightmap and start a new game from it with current settings
case SM_START_HEIGHTMAP: // Load a heightmap and start a new game from it
MakeNewGame(true, new_mode == SM_START_HEIGHTMAP);
GenerateSavegameId();
break;
case SM_LOAD_HEIGHTMAP: // Load heightmap from scenario editor
SetLocalCompany(OWNER_NONE);
GenerateWorld(GWM_HEIGHTMAP, 1 << _settings_game.game_creation.map_x, 1 << _settings_game.game_creation.map_y);
GenerateSavegameId();
MarkWholeScreenDirty();
break;
case SM_LOAD_SCENARIO: { // Load scenario from scenario editor
if (SafeLoad(_file_to_saveload.name, _file_to_saveload.file_op, _file_to_saveload.detail_ftype, GM_EDITOR, NO_DIRECTORY)) {
SetLocalCompany(OWNER_NONE);
GenerateSavegameId();
_settings_newgame.game_creation.starting_year = TimerGameCalendar::year;
/* Cancel the saveload pausing */
Command<CMD_PAUSE>::Post(PM_PAUSED_SAVELOAD, false);
@@ -1116,6 +1130,14 @@ void SwitchToMode(SwitchMode new_mode)
ShowErrorMessage(STR_WARNING_FALLBACK_SOUNDSET, INVALID_STRING_ID, WL_CRITICAL);
BaseSounds::ini_set = BaseSounds::GetUsedSet()->name;
}
if (_settings_client.network.participate_survey == PS_ASK) {
/* No matter how often you go back to the main menu, only ask the first time. */
static bool asked_once = false;
if (!asked_once) {
asked_once = true;
ShowNetworkAskSurvey();
}
}
break;
case SM_SAVE_GAME: // Save game.