-
Notifications
You must be signed in to change notification settings - Fork 16
Correctly set winning team #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,12 +82,13 @@ | |
| <FunctionLevelLinking>true</FunctionLevelLinking> | ||
| <IntrinsicFunctions>true</IntrinsicFunctions> | ||
| <SDLCheck>true</SDLCheck> | ||
| <AdditionalIncludeDirectories>K:\bakkesmod\BakkesMod-rewrite\BakkesMod Rewrite;K:\bakkesmod\AutoReplayUploader\Uploader;..\Uploader;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. K:\bakkesmod\BakkesMod-rewrite\PluginSDK;K:\bakkesmod\AutoReplayUploader\Uploader;..\Uploader;%(AdditionalIncludeDirectories) |
||
| <PreprocessorDefinitions>_WINDLL;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;TOAST</PreprocessorDefinitions> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. _WINDLL;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;TOAST;WIN32_MEAN_AND_LEAN; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. _WINDLL;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;TOAST;WIN32_MEAN_AND_LEAN; |
||
| <AdditionalIncludeDirectories>K:\bakkesmod\BakkesMod-rewrite\PluginSDK;K:\bakkesmod\AutoReplayUploader\Uploader;..\Uploader;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| <PreprocessorDefinitions>_WINDLL;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;TOAST;WIN32_MEAN_AND_LEAN;</PreprocessorDefinitions> | ||
| <RuntimeLibrary>MultiThreaded</RuntimeLibrary> | ||
| <LanguageStandard>stdcpp17</LanguageStandard> | ||
| </ClCompile> | ||
| <Link> | ||
| <GenerateDebugInformation>False</GenerateDebugInformation> | ||
| <GenerateDebugInformation>true</GenerateDebugInformation> | ||
| <EnableCOMDATFolding>true</EnableCOMDATFolding> | ||
| <OptimizeReferences>true</OptimizeReferences> | ||
| <AdditionalDependencies>BakkesMod.lib;%(AdditionalDependencies)</AdditionalDependencies> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -140,8 +140,8 @@ void AutoReplayUploaderPlugin::onLoad() | |
|
|
||
| // Initialize notification plugin assets | ||
| #ifdef TOAST | ||
| gameWrapper->LoadToastTexture("calculated_logo", "./bakkesmod/data/assets/calculated_logo.tga"); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| gameWrapper->LoadToastTexture("ballchasing_logo", "./bakkesmod/data/assets/ballchasing_logo.tga"); | ||
| gameWrapper->LoadToastTexture("calculated_logo", gameWrapper->FixRelativePath("./bakkesmod/data/assets/calculated_logo.tga")); | ||
| gameWrapper->LoadToastTexture("ballchasing_logo", gameWrapper->FixRelativePath("./bakkesmod/data/assets/ballchasing_logo.tga")); | ||
| #endif | ||
| } | ||
|
|
||
|
|
@@ -199,10 +199,10 @@ void AutoReplayUploaderPlugin::InitializeVariables() | |
|
|
||
| // Path to export replays to | ||
| cvarManager->registerCvar(CVAR_REPLAY_EXPORT, "0", "Save all replay files to export filepath above.", true, true, 0, true, 1).bindTo(saveReplay); | ||
| cvarManager->registerCvar(CVAR_REPLAY_EXPORT_PATH, DEAULT_EXPORT_PATH, "Path to export replays to.").bindTo(exportPath); | ||
| cvarManager->registerCvar(CVAR_REPLAY_EXPORT_PATH, DEFAULT_EXPORT_PATH, "Path to export replays to.").bindTo(exportPath); | ||
| cvarManager->getCvar(CVAR_REPLAY_EXPORT_PATH).addOnValueChanged([this](string oldVal, CVarWrapper cvar) | ||
| { | ||
| if (SanitizeExportPath(exportPath, DEAULT_EXPORT_PATH)) | ||
| if (SanitizeExportPath(exportPath, DEFAULT_EXPORT_PATH)) | ||
| { | ||
| cvarManager->getCvar(CVAR_REPLAY_EXPORT_PATH).setValue(*exportPath); | ||
| } | ||
|
|
@@ -261,41 +261,46 @@ void AutoReplayUploaderPlugin::OnGameComplete(ServerWrapper caller, void * param | |
| // If we have a template for the replay name then set the replay name based off that template else use default template | ||
| string replayName = SetReplayName(caller, soccarReplay); | ||
|
|
||
|
|
||
| cvarManager->log("Exporting replay!"); | ||
| // Export the replay to a file for upload | ||
| string replayPath = ExportReplay(soccarReplay, replayName); | ||
|
|
||
| // If we are saving this with event Function TAGame.GameEvent_Soccar_TA.Destroyed | ||
| // the steamID might not be available. Using prestored steamID | ||
| string playerSteamID = to_string(gameWrapper->GetSteamID()); | ||
| if (playerSteamID.length() < 1) { | ||
| playerSteamID = backupPlayerSteamID; | ||
| cvarManager->log("Using backup steamId to upload: " + playerSteamID); | ||
| std::filesystem::path replayPath = ExportReplay(soccarReplay, replayName); | ||
| if (!std::filesystem::exists(replayPath) || std::filesystem::is_directory(replayPath)) | ||
| { | ||
| cvarManager->log("Failed exporting replay to " + replayPath.string()); | ||
| return; | ||
| } | ||
|
|
||
|
|
||
| UniqueIDWrapper playerSteamID = gameWrapper->GetUniqueID(); | ||
| std::string uploadID = std::to_string(playerSteamID.GetUID()); | ||
| if (uploadID.size() < 1) { | ||
| uploadID = playerSteamID.str(); | ||
| cvarManager->log("Using backup steamId to upload: " + uploadID); | ||
| } else { | ||
| cvarManager->log("Using steamId to upload: " + playerSteamID); | ||
| cvarManager->log("Using steamId to upload: " + uploadID); | ||
| } | ||
|
|
||
| // Upload replay | ||
| if (*uploadToCalculated) | ||
| { | ||
| calculated->UploadReplay(replayPath, playerSteamID); | ||
| calculated->UploadReplay(gameWrapper->GetBakkesModPath(), replayPath, uploadID); | ||
| } | ||
| if (*uploadToBallchasing) | ||
| { | ||
| ballchasing->UploadReplay(replayPath); | ||
| ballchasing->UploadReplay(gameWrapper->GetBakkesModPath(), replayPath); | ||
| } | ||
|
|
||
| // If we aren't saving the replay remove it after we've uploaded | ||
| if (!(*saveReplay)) | ||
| { | ||
| cvarManager->log("Removing replay file: " + replayPath); | ||
| remove(replayPath.c_str()); | ||
| cvarManager->log("Removing replay file: " + replayPath.string()); | ||
| std::filesystem::remove(replayPath); | ||
| } | ||
| #ifdef TOAST | ||
| else if(*showNotifications) | ||
| { | ||
| bool exported = file_exists(replayPath); | ||
| string msg = exported ? "Exported replay to: " + replayPath : "Failed to export replay to: " + replayPath; | ||
| bool exported = std::filesystem::exists(replayPath); | ||
| string msg = exported ? "Exported replay to: " + replayPath.string() : "Failed to export replay to: " + replayPath.string(); | ||
| gameWrapper->Toast("Autoreplayuploader", msg, "default", 3.5f, exported ? ToastType_OK : ToastType_Error); | ||
| } | ||
| #endif | ||
|
|
@@ -307,7 +312,9 @@ Player ConstructPlayer(PriWrapper wrapper) | |
| if (!wrapper.IsNull()) | ||
| { | ||
| p.Name = wrapper.GetPlayerName().ToString(); | ||
| p.UniqueId = wrapper.GetUniqueId().ID; | ||
| p.UniqueId = wrapper.GetUniqueIdWrapper().GetUID(); | ||
| p.EpicID = wrapper.GetUniqueIdWrapper().GetEpicAccountID(); | ||
|
|
||
| p.Team = wrapper.GetTeamNum(); | ||
| p.Score = wrapper.GetScore(); | ||
| p.Goals = wrapper.GetMatchGoals(); | ||
|
|
@@ -407,6 +414,7 @@ string AutoReplayUploaderPlugin::SetReplayName(ServerWrapper& server, ReplaySocc | |
| cvarManager->log("Using prerecorder username for replay: " + backupMatchForReplayName.PrimaryPlayer.Name); | ||
| match.PrimaryPlayer.Name = backupMatchForReplayName.PrimaryPlayer.Name; | ||
| match.PrimaryPlayer.UniqueId = backupMatchForReplayName.PrimaryPlayer.UniqueId; | ||
| match.PrimaryPlayer.EpicID = backupMatchForReplayName.PrimaryPlayer.EpicID; | ||
| match.PrimaryPlayer.Team = backupMatchForReplayName.PrimaryPlayer.Team; | ||
| } | ||
|
|
||
|
|
@@ -420,6 +428,20 @@ string AutoReplayUploaderPlugin::SetReplayName(ServerWrapper& server, ReplaySocc | |
| // Get Team scores | ||
| match.Team0Score = soccarReplay.GetTeam0Score(); | ||
| match.Team1Score = soccarReplay.GetTeam1Score(); | ||
|
|
||
| if (auto matchWinner = server.GetMatchWinner(); !matchWinner.IsNull()) | ||
| { | ||
| match.WinningTeam = matchWinner.GetTeamIndex(); | ||
| } | ||
| else if (auto gameWinner = server.GetGameWinner(); !gameWinner.IsNull()) | ||
| { | ||
| match.WinningTeam = gameWinner.GetTeamIndex(); | ||
| } | ||
| else | ||
| { | ||
| match.WinningTeam = match.Team0Score > match.Team1Score ? 0 : 1; | ||
| } | ||
|
|
||
|
|
||
| // Get current Sequence number | ||
| auto seq = *templateSequence; | ||
|
|
@@ -440,30 +462,42 @@ string AutoReplayUploaderPlugin::SetReplayName(ServerWrapper& server, ReplaySocc | |
| return replayName; | ||
| } | ||
|
|
||
| string AutoReplayUploaderPlugin::ExportReplay(ReplaySoccarWrapper& soccarReplay, string replayName) | ||
| std::filesystem::path AutoReplayUploaderPlugin::ExportReplay(ReplaySoccarWrapper& soccarReplay, string replayName) | ||
| { | ||
| string replayPath = CalculateReplayPath(*exportPath, replayName); | ||
|
|
||
| std::filesystem::path replayPath = CalculateReplayPath(*exportPath, replayName); | ||
| cvarManager->log("Calculated replay path: " + replayPath.string()); | ||
| if (replayPath.is_relative()) | ||
| { | ||
| cvarManager->log("Path is a relative path, fixing it!"); | ||
| replayPath = gameWrapper->FixRelativePath(replayPath); | ||
| cvarManager->log("Fixed path: " + replayPath.string()); | ||
| } | ||
| // Remove file if it already exists | ||
| if (file_exists(replayPath)) | ||
| if (std::filesystem::exists(replayPath)) | ||
| { | ||
| cvarManager->log("Removing duplicate replay file: " + replayPath); | ||
| remove(replayPath.c_str()); | ||
| cvarManager->log("Removing duplicate replay file: " + replayPath.string()); | ||
| if (std::filesystem::is_directory(replayPath)) | ||
| { | ||
| cvarManager->log("Calculated export path is somehow a directory. " + replayPath.string()); | ||
| return replayPath / "err.replay"; | ||
| } | ||
| std::filesystem::remove(replayPath); | ||
| cvarManager->log("File removed."); | ||
| } | ||
|
|
||
| // Export Replay | ||
|
|
||
| soccarReplay.ExportReplay(replayPath); | ||
| cvarManager->log("Exported replay to: " + replayPath); | ||
| cvarManager->log("Exported replay to: " + replayPath.string()); | ||
|
|
||
| // Check to see if replay exists, if not then export to default path | ||
| if (!file_exists(replayPath)) | ||
| if (!std::filesystem::exists(replayPath)) | ||
| { | ||
| cvarManager->log("Export failed to path: " + replayPath + " exporting to default path."); | ||
| replayPath = string(DEAULT_EXPORT_PATH) + "autosaved.replay"; | ||
| cvarManager->log("Export failed to path: " + replayPath.string() + " exporting to default path."); | ||
| replayPath = gameWrapper->GetDataFolder() / "autosaved.replay"; | ||
|
|
||
| soccarReplay.ExportReplay(replayPath); | ||
| cvarManager->log("Exported replay to: " + replayPath); | ||
| cvarManager->log("Exported replay to: " + replayPath.string()); | ||
| } | ||
|
|
||
| return replayPath; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Write