diff --git a/AutoReplayUploader/AutoReplayUploaderPlugin.cpp b/AutoReplayUploader/AutoReplayUploaderPlugin.cpp index 032d087..2be3e4a 100644 --- a/AutoReplayUploader/AutoReplayUploaderPlugin.cpp +++ b/AutoReplayUploader/AutoReplayUploaderPlugin.cpp @@ -32,6 +32,7 @@ BAKKESMOD_PLUGIN(AutoReplayUploaderPlugin, "Auto replay uploader plugin", "0.2", #define CVAR_BALLCHASING_AUTH_TEST_RESULT "cl_autoreplayupload_ballchasing_testkeyresult" #define CVAR_BALLCHASING_REPLAY_VISIBILITY "cl_autoreplayupload_ballchasing_visibility" #define CVAR_CALCULATED_REPLAY_VISIBILITY "cl_autoreplayupload_calculated_visibility" +#define CVAR_UPLOAD_ONLINE_FREEPLAY "cl_autoreplayupload_online_freeplay" Player ConstructPlayer(PriWrapper wrapper) { @@ -39,7 +40,7 @@ Player ConstructPlayer(PriWrapper wrapper) if (!wrapper.IsNull()) { p.Name = wrapper.GetPlayerName().ToString(); - p.UniqueId = wrapper.GetUniqueId().ID; + p.UniqueId = wrapper.GetUniqueIdWrapper().GetUID(); p.Team = wrapper.GetTeamNum(); p.Score = wrapper.GetScore(); p.Goals = wrapper.GetMatchGoals(); @@ -61,10 +62,10 @@ struct MMRCacheWrapper { MMRData data; bool addToAfter; - void AddPlayer(std::string name, SteamID id, float mmr, SkillRank extra, int platform) { + void AddPlayer(std::string name, UniqueIDWrapper id, float mmr, SkillRank extra, int platform) { if (mmr < 101) return; MMR newValue{ extra.Tier, extra.Division, extra.MatchesPlayed, mmr }; - std::string sid = std::to_string(id.ID); + std::string sid = std::to_string(id.GetUID()); PlayerMMRData newPlayerData{ platform, sid, newValue }; newPlayerData.debug = name; auto it = std::find_if(data.players.begin(), data.players.end(), [&](PlayerMMRData& p) { return p.id == sid; }); @@ -229,6 +230,9 @@ void AutoReplayUploaderPlugin::InitializeVariables() // Set the default status of uploading replay to false needToUploadReplay = false; + // Default to not uploading Online Freeplay replays + cvarManager->registerCvar(CVAR_UPLOAD_ONLINE_FREEPLAY, "0", "Upload replays from online freeplay matches", true, true, 0, true, 1).bindTo(uploadOnlineFreeplay); + // Calculated variables cvarManager->registerCvar(CVAR_UPLOAD_TO_CALCULATED, "0", "Upload to replays to calculated.gg automatically", true, true, 0, true, 1).bindTo(uploadToCalculated); cvarManager->registerCvar(CVAR_CALCULATED_REPLAY_VISIBILITY, "DEFAULT", "Replay visibility when uploading to calculated.gg", false, false, 0, false, 0, true).bindTo(calculated->visibility); @@ -414,13 +418,13 @@ void AutoReplayUploaderPlugin::OnMMRSync() cvarManager->log("got " + std::to_string(players.Count()) + " players"); for (size_t i = 0; i < players.Count(); i++) { - auto player = players.Get(i); + auto player = players.Get(static_cast(i)); if (!player) continue; auto playerName = player.GetPlayerName().ToString(); auto platform = player.GetPlatform(); //cvarManager->log("Getting MMR for : "+ playerName); - auto playerSteam = player.GetUniqueId(); - if (playerSteam.ID == 0) continue; //bot + auto playerSteam = player.GetUniqueIdWrapper(); + if (playerSteam.GetUID() == 0) continue; //bot if (!mmrWrapper.IsSyncing(playerSteam)) { auto mmr = mmrWrapper.GetPlayerMMR(playerSteam, playlist); auto extra = mmrWrapper.GetPlayerRank(playerSteam, playlist); @@ -447,18 +451,18 @@ void AutoReplayUploaderPlugin::GetPlayerData(ServerWrapper caller, void* params, * when uploading the replay, and that is why we save it in at start of the match. * *****************************************************************************************/ - //Function GameEvent_Soccar_TA.Active.StartRound -event will fire in all modes - //like freeplay, custom training etc. Set the needToUploadReplay flag replay only - //if we are in an online game. - if (gameWrapper->IsInOnlineGame()) { - needToUploadReplay = true; - } else { - //If we are not in online game, we are in freeplay, custom training etc - // We will set the needToUploadReplay flag to false and no need to save the player data. - needToUploadReplay = false; - return; + // Function GameEvent_Soccar_TA.Active.StartRound -event will fire in all modes + // like freeplay, custom training etc. Set the needToUploadReplay flag replay only + // if we are in an online game. Online freeplay is also an online game mode, but we will + // only upload those replays if CVAR_UPLOAD_ONLINE_FREEPLAY (bound to uploadOnlineFreeplay) + // has been set to true. + + int playlistID = caller.GetPlaylist().GetPlaylistId(); + needToUploadReplay = gameWrapper->IsInOnlineGame() && (playlistID != ONLINE_FREEPLAY_PLAYLIST_ID ? true : *uploadOnlineFreeplay); + if (!needToUploadReplay) { + return; } - + // We are in online game and now storing some important player data, if needed after the game // When uploading the replay. backupPlayerSteamID = std::to_string(gameWrapper->GetSteamID()); diff --git a/AutoReplayUploader/AutoReplayUploaderPlugin.h b/AutoReplayUploader/AutoReplayUploaderPlugin.h index 0abb7f2..ef65996 100644 --- a/AutoReplayUploader/AutoReplayUploaderPlugin.h +++ b/AutoReplayUploader/AutoReplayUploaderPlugin.h @@ -10,6 +10,7 @@ #define DEAULT_EXPORT_PATH "./bakkesmod/data/" #define DEFAULT_REPLAY_NAME_TEMPLATE "{YEAR}-{MONTH}-{DAY}.{HOUR}.{MIN} {PLAYER} {MODE} {WINLOSS}" +#define ONLINE_FREEPLAY_PLAYLIST_ID 73 // TODO: uncomment or remove #ifdef's when new Bakkes mod API becomes available that has Toast notifications //#define TOAST @@ -25,6 +26,7 @@ class AutoReplayUploaderPlugin : public BakkesMod::Plugin::BakkesModPlugin std::shared_ptr uploadToCalculated = std::make_shared(false); std::shared_ptr uploadToBallchasing = std::make_shared(false); std::shared_ptr uploadToBallchasingMMR = std::make_shared(false); + std::shared_ptr uploadOnlineFreeplay = std::make_shared(false); // Replay name template variables std::shared_ptr templateSequence = std::make_shared(0); diff --git a/AutoReplayUploader/bakkesmod.props b/AutoReplayUploader/bakkesmod.props index f1dc3f1..08205a3 100644 --- a/AutoReplayUploader/bakkesmod.props +++ b/AutoReplayUploader/bakkesmod.props @@ -10,7 +10,7 @@ $(BakkesModPath)\bakkesmodsdk\lib;%(AdditionalLibraryDirectories) - bakkesmod.lib;%(AdditionalDependencies) + pluginsdk.lib;%(AdditionalDependencies) python "$(BakkesModPath)\bakkesmodsdk\bakkes_patchplugin.py" "$(TargetPath)" diff --git a/autoreplayuploader.set b/autoreplayuploader.set index e674d29..4ac02f8 100644 --- a/autoreplayuploader.set +++ b/autoreplayuploader.set @@ -14,4 +14,7 @@ Auto replay uploader 8| 1|Save all replay files to export filepath below|cl_autoreplayupload_save 12|Path to export replays to|cl_autoreplayupload_filepath -9|Note: For this to work, you do NOT have to have "save all replays" enabled! \ No newline at end of file +9|Note: For this to work, you do NOT have to have "save all replays" enabled! +8| +1|Upload Online Freeplay replays|cl_autoreplayupload_online_freeplay +9|Note: You probably do not want to upload Online Freeplay replays. \ No newline at end of file