diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index 3747de04..178f68b4 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -5179,65 +5179,68 @@ void savePlayerStats(Game* game, Stats& endStats, PlayerAchievementsInterface *p const double MIN_PLAY_TIME_MINUTES = 10.0; // Write out achievements here + double elapsedGameMinutes = (game->getWorld()->getStats()->getFramesToCalculatePlaytime() / GameConstants::updateFps / 60.0); + for (int factionIndex = 0; factionIndex < game->getWorld()->getFactionCount(); ++factionIndex) { if (factionIndex == game->getWorld()->getThisFactionIndex()) { //printf("\nWriting out game stats for Faction Index: %d won status: %d\n",factionIndex,endStats.getVictory(factionIndex)); - if (endStats.getVictory(factionIndex)) { - double elapsedGameMinutes = (game->getWorld()->getStats()->getFramesToCalculatePlaytime() / GameConstants::updateFps / 60.0); - if(elapsedGameMinutes >= MIN_PLAY_TIME_MINUTES) { - int gamesWonCount = playerStats->getStatAsInt("games-won") + 1; - playerStats->setStatAsInt("games-won",gamesWonCount); + if(elapsedGameMinutes >= MIN_PLAY_TIME_MINUTES) { + int gamesPlayedCount = playerStats->getStatAsInt(EnumParser::getString(games_played).c_str()) + 1; + playerStats->setStatAsInt(EnumParser::getString(games_played).c_str(),gamesPlayedCount); + if(gamesPlayedCount >= 50 && playerStats->isUnlocked(EnumParser::getString(ACH_PLAY_FIFTY_GAMES).c_str()) == false) { + playerStats->unlock(EnumParser::getString(ACH_PLAY_FIFTY_GAMES).c_str()); + } + if(gamesPlayedCount >= 100 && playerStats->isUnlocked(EnumParser::getString(ACH_PLAY_ONE_HUNDRED_GAMES).c_str()) == false) { + playerStats->unlock(EnumParser::getString(ACH_PLAY_ONE_HUNDRED_GAMES).c_str()); + } + if(gamesPlayedCount >= 250 && playerStats->isUnlocked(EnumParser::getString(ACH_PLAY_TWO_HUNDRED_FIFTY_GAMES).c_str()) == false) { + playerStats->unlock(EnumParser::getString(ACH_PLAY_TWO_HUNDRED_FIFTY_GAMES).c_str()); + } + if(gamesPlayedCount >= 500 && playerStats->isUnlocked(EnumParser::getString(ACH_PLAY_FIVE_HUNDRED_GAMES).c_str()) == false) { + playerStats->unlock(EnumParser::getString(ACH_PLAY_FIVE_HUNDRED_GAMES).c_str()); + } + if(gamesPlayedCount > 1000 && playerStats->isUnlocked(EnumParser::getString(ACH_PLAY_OVER_THOUSAND_GAMES).c_str()) == false) { + playerStats->unlock(EnumParser::getString(ACH_PLAY_OVER_THOUSAND_GAMES).c_str()); + } + + if (NetworkManager::getInstance().isNetworkGame()) { + int networkGamesPlayedCount = playerStats->getStatAsInt(EnumParser::getString(network_games_played).c_str()) + 1; + playerStats->setStatAsInt(EnumParser::getString(network_games_played).c_str(),networkGamesPlayedCount); + + if(networkGamesPlayedCount >= 50 && playerStats->isUnlocked(EnumParser::getString(ACH_PLAY_FIFTY_GAMES_ONLINE).c_str()) == false) { + playerStats->unlock(EnumParser::getString(ACH_PLAY_FIFTY_GAMES_ONLINE).c_str()); + } + if(networkGamesPlayedCount >= 100 && playerStats->isUnlocked(EnumParser::getString(ACH_PLAY_ONE_HUNDRED_GAMES_ONLINE).c_str()) == false) { + playerStats->unlock(EnumParser::getString(ACH_PLAY_ONE_HUNDRED_GAMES_ONLINE).c_str()); + } + if(networkGamesPlayedCount >= 250 && playerStats->isUnlocked(EnumParser::getString(ACH_PLAY_TWO_HUNDRED_FIFTY_GAMES_ONLINE).c_str()) == false) { + playerStats->unlock(EnumParser::getString(ACH_PLAY_TWO_HUNDRED_FIFTY_GAMES_ONLINE).c_str()); + } + if(networkGamesPlayedCount >= 500 && playerStats->isUnlocked(EnumParser::getString(ACH_PLAY_FIVE_HUNDRED_GAMES_ONLINE).c_str()) == false) { + playerStats->unlock(EnumParser::getString(ACH_PLAY_FIVE_HUNDRED_GAMES_ONLINE).c_str()); + } + if(networkGamesPlayedCount > 1000 && playerStats->isUnlocked(EnumParser::getString(ACH_PLAY_OVER_THOUSAND_GAMES_ONLINE).c_str()) == false) { + playerStats->unlock(EnumParser::getString(ACH_PLAY_OVER_THOUSAND_GAMES_ONLINE).c_str()); + } + } + + if (endStats.getVictory(factionIndex)) { if(playerStats->isUnlocked(EnumParser::getString(ACH_WIN_ONE_GAME).c_str()) == false) { playerStats->unlock(EnumParser::getString(ACH_WIN_ONE_GAME).c_str()); } - if(gamesWonCount >= 50 && playerStats->isUnlocked(EnumParser::getString(ACH_WIN_FIFTY_GAMES).c_str()) == false) { - playerStats->unlock(EnumParser::getString(ACH_WIN_FIFTY_GAMES).c_str()); - } - if(gamesWonCount >= 100 && playerStats->isUnlocked(EnumParser::getString(ACH_WIN_ONE_HUNDRED_GAMES).c_str()) == false) { - playerStats->unlock(EnumParser::getString(ACH_WIN_ONE_HUNDRED_GAMES).c_str()); - } - if(gamesWonCount >= 250 && playerStats->isUnlocked(EnumParser::getString(ACH_WIN_TWO_HUNDRED_FIFTY_GAMES).c_str()) == false) { - playerStats->unlock(EnumParser::getString(ACH_WIN_TWO_HUNDRED_FIFTY_GAMES).c_str()); - } - if(gamesWonCount >= 500 && playerStats->isUnlocked(EnumParser::getString(ACH_WIN_FIVE_HUNDRED_GAMES).c_str()) == false) { - playerStats->unlock(EnumParser::getString(ACH_WIN_FIVE_HUNDRED_GAMES).c_str()); - } - if(gamesWonCount > 1000 && playerStats->isUnlocked(EnumParser::getString(ACH_WIN_OVER_THOUSAND_GAMES).c_str()) == false) { - playerStats->unlock(EnumParser::getString(ACH_WIN_OVER_THOUSAND_GAMES).c_str()); - } - if (NetworkManager::getInstance().isNetworkGame()) { int networkGamesWonCount = playerStats->getStatAsInt("network-games-won") + 1; playerStats->setStatAsInt("network-games-won",networkGamesWonCount); - - if(playerStats->isUnlocked(EnumParser::getString(ACH_WIN_ONE_GAME_ONLINE).c_str()) == false) { - playerStats->unlock(EnumParser::getString(ACH_WIN_ONE_GAME_ONLINE).c_str()); - } - if(networkGamesWonCount >= 50 && playerStats->isUnlocked(EnumParser::getString(ACH_WIN_FIFTY_GAMES_ONLINE).c_str()) == false) { - playerStats->unlock(EnumParser::getString(ACH_WIN_FIFTY_GAMES_ONLINE).c_str()); - } - if(networkGamesWonCount >= 100 && playerStats->isUnlocked(EnumParser::getString(ACH_WIN_ONE_HUNDRED_GAMES_ONLINE).c_str()) == false) { - playerStats->unlock(EnumParser::getString(ACH_WIN_ONE_HUNDRED_GAMES_ONLINE).c_str()); - } - if(networkGamesWonCount >= 250 && playerStats->isUnlocked(EnumParser::getString(ACH_WIN_TWO_HUNDRED_FIFTY_GAMES_ONLINE).c_str()) == false) { - playerStats->unlock(EnumParser::getString(ACH_WIN_TWO_HUNDRED_FIFTY_GAMES_ONLINE).c_str()); - } - if(networkGamesWonCount >= 500 && playerStats->isUnlocked(EnumParser::getString(ACH_WIN_FIVE_HUNDRED_GAMES_ONLINE).c_str()) == false) { - playerStats->unlock(EnumParser::getString(ACH_WIN_FIVE_HUNDRED_GAMES_ONLINE).c_str()); - } - if(networkGamesWonCount > 1000 && playerStats->isUnlocked(EnumParser::getString(ACH_WIN_OVER_THOUSAND_GAMES_ONLINE).c_str()) == false) { - playerStats->unlock(EnumParser::getString(ACH_WIN_OVER_THOUSAND_GAMES_ONLINE).c_str()); - } } //printf("\nPlayer won the game with at least 10 minutes of play: %f!\n",elapsedGameMinutes); } - else { - //printf("\nPlayer won the game BUT NOT with at least 10 minutes of play: %f!\n",elapsedGameMinutes); - } + } + else { + //printf("\nPlayer won the game BUT NOT with at least 10 minutes of play: %f!\n",elapsedGameMinutes); } } } diff --git a/source/glest_game/steam/steam.h b/source/glest_game/steam/steam.h index b5a486c9..5b1c6905 100644 --- a/source/glest_game/steam/steam.h +++ b/source/glest_game/steam/steam.h @@ -22,7 +22,9 @@ enum SteamStatName { stat_online_units, stat_online_resources_harvested, stat_online_quit_before_end, - stat_online_minutes_played + stat_online_minutes_played, + games_played, + network_games_played }; enum SteamStatType { @@ -42,40 +44,42 @@ inline EnumParser::EnumParser() { enumMap["stat_online_resources_harvested"] = stat_online_resources_harvested; enumMap["stat_online_quit_before_end"] = stat_online_quit_before_end; enumMap["stat_online_minutes_played"] = stat_online_minutes_played; + enumMap["games_played"] = games_played; + enumMap["network_games_played"] = network_games_played; } enum SteamAchievementName { ACH_WIN_ONE_GAME, - ACH_WIN_FIFTY_GAMES, - ACH_WIN_ONE_HUNDRED_GAMES, - ACH_WIN_TWO_HUNDRED_FIFTY_GAMES, - ACH_WIN_FIVE_HUNDRED_GAMES, - ACH_WIN_OVER_THOUSAND_GAMES, + ACH_PLAY_FIFTY_GAMES, + ACH_PLAY_ONE_HUNDRED_GAMES, + ACH_PLAY_TWO_HUNDRED_FIFTY_GAMES, + ACH_PLAY_FIVE_HUNDRED_GAMES, + ACH_PLAY_OVER_THOUSAND_GAMES, ACH_WIN_ONE_GAME_ONLINE, - ACH_WIN_FIFTY_GAMES_ONLINE, - ACH_WIN_ONE_HUNDRED_GAMES_ONLINE, - ACH_WIN_TWO_HUNDRED_FIFTY_GAMES_ONLINE, - ACH_WIN_FIVE_HUNDRED_GAMES_ONLINE, - ACH_WIN_OVER_THOUSAND_GAMES_ONLINE + ACH_PLAY_FIFTY_GAMES_ONLINE, + ACH_PLAY_ONE_HUNDRED_GAMES_ONLINE, + ACH_PLAY_TWO_HUNDRED_FIFTY_GAMES_ONLINE, + ACH_PLAY_FIVE_HUNDRED_GAMES_ONLINE, + ACH_PLAY_OVER_THOUSAND_GAMES_ONLINE }; template <> inline EnumParser::EnumParser() { enumMap["ACH_WIN_ONE_GAME"] = ACH_WIN_ONE_GAME; - enumMap["ACH_WIN_FIFTY_GAMES"] = ACH_WIN_FIFTY_GAMES; - enumMap["ACH_WIN_ONE_HUNDRED_GAMES"] = ACH_WIN_ONE_HUNDRED_GAMES; - enumMap["ACH_WIN_TWO_HUNDRED_FIFTY_GAMES"] = ACH_WIN_TWO_HUNDRED_FIFTY_GAMES; - enumMap["ACH_WIN_FIVE_HUNDRED_GAMES"] = ACH_WIN_FIVE_HUNDRED_GAMES; - enumMap["ACH_WIN_OVER_THOUSAND_GAMES"] = ACH_WIN_OVER_THOUSAND_GAMES; + enumMap["ACH_PLAY_FIFTY_GAMES"] = ACH_PLAY_FIFTY_GAMES; + enumMap["ACH_PLAY_ONE_HUNDRED_GAMES"] = ACH_PLAY_ONE_HUNDRED_GAMES; + enumMap["ACH_PLAY_TWO_HUNDRED_FIFTY_GAMES"] = ACH_PLAY_TWO_HUNDRED_FIFTY_GAMES; + enumMap["ACH_PLAY_FIVE_HUNDRED_GAMES"] = ACH_PLAY_FIVE_HUNDRED_GAMES; + enumMap["ACH_PLAY_OVER_THOUSAND_GAMES"] = ACH_PLAY_OVER_THOUSAND_GAMES; enumMap["ACH_WIN_ONE_GAME_ONLINE"] = ACH_WIN_ONE_GAME_ONLINE; - enumMap["ACH_WIN_FIFTY_GAMES_ONLINE"] = ACH_WIN_FIFTY_GAMES_ONLINE; - enumMap["ACH_WIN_ONE_HUNDRED_GAMES_ONLINE"] = ACH_WIN_ONE_HUNDRED_GAMES_ONLINE; - enumMap["ACH_WIN_TWO_HUNDRED_FIFTY_GAMES_ONLINE"] = ACH_WIN_TWO_HUNDRED_FIFTY_GAMES_ONLINE; - enumMap["ACH_WIN_FIVE_HUNDRED_GAMES_ONLINE"] = ACH_WIN_FIVE_HUNDRED_GAMES_ONLINE; - enumMap["ACH_WIN_OVER_THOUSAND_GAMES_ONLINE"] = ACH_WIN_OVER_THOUSAND_GAMES_ONLINE; + enumMap["ACH_PLAY_FIFTY_GAMES_ONLINE"] = ACH_PLAY_FIFTY_GAMES_ONLINE; + enumMap["ACH_PLAY_ONE_HUNDRED_GAMES_ONLINE"] = ACH_PLAY_ONE_HUNDRED_GAMES_ONLINE; + enumMap["ACH_PLAY_TWO_HUNDRED_FIFTY_GAMES_ONLINE"] = ACH_PLAY_TWO_HUNDRED_FIFTY_GAMES_ONLINE; + enumMap["ACH_PLAY_FIVE_HUNDRED_GAMES_ONLINE"] = ACH_PLAY_FIVE_HUNDRED_GAMES_ONLINE; + enumMap["ACH_PLAY_OVER_THOUSAND_GAMES_ONLINE"] = ACH_PLAY_OVER_THOUSAND_GAMES_ONLINE; } //