Skip to content

Commit

Permalink
Merge: Remove unused cryptmanager functionality related to profile si…
Browse files Browse the repository at this point in the history
…gning #870
  • Loading branch information
poco0317 committed Aug 14, 2020
2 parents 606e62d + 63a2787 commit d99d824
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 399 deletions.
17 changes: 5 additions & 12 deletions src/Etterna/Globals/StepMania.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1222,8 +1222,6 @@ sm_main(int argc, char* argv[])
SONGMAN->InitAll(pLoadingWindow); // this takes a long time
SONGINDEX->FinishTransaction();
CRYPTMAN = new CryptManager; // need to do this before ProfileMan
if (PREFSMAN->m_bSignProfileData)
CRYPTMAN->GenerateGlobalKeys();
SCOREMAN = new ScoreManager;
PROFILEMAN = new ProfileManager;
PROFILEMAN->Init(pLoadingWindow); // must load after SONGMAN
Expand Down Expand Up @@ -1288,7 +1286,6 @@ sm_main(int argc, char* argv[])
std::string
StepMania::SaveScreenshot(const std::string& Dir,
bool SaveCompressed,
bool MakeSignature,
const std::string& NamePrefix,
const std::string& NameSuffix)
{
Expand Down Expand Up @@ -1322,9 +1319,6 @@ StepMania::SaveScreenshot(const std::string& Dir,

SCREENMAN->PlayScreenshotSound();

if (PREFSMAN->m_bSignProfileData && MakeSignature)
CryptManager::SignFileToFile(Path);

return FileName;
}

Expand Down Expand Up @@ -1492,8 +1486,7 @@ HandleGlobalInputs(const InputEventPlus& input)
DeviceInput(DEVICE_KEYBOARD, KEY_RSHIFT)));
bool bSaveCompressed = bHoldingShift;
RageTimer timer;
StepMania::SaveScreenshot(
"Screenshots/", bSaveCompressed, false, "", "");
StepMania::SaveScreenshot("Screenshots/", bSaveCompressed, "", "");
LOG->Trace("Screenshot took %f seconds.", timer.GetDeltaTime());
return true; // handled
}
Expand Down Expand Up @@ -1601,16 +1594,16 @@ HandleInputEvents(float fDeltaTime)
}

#include "Etterna/Singletons/LuaManager.h"
int
LuaFunc_SaveScreenshot(lua_State* L);

int
LuaFunc_SaveScreenshot(lua_State* L)
{
// If pn is provided, save to that player's profile.
// Otherwise, save to the machine.
PlayerNumber pn = Enum::Check<PlayerNumber>(L, 1, true);
bool compress = lua_toboolean(L, 2) != 0;
bool sign = lua_toboolean(L, 3) != 0;
bool sign =
lua_toboolean(L, 3) != 0; // Legacy, unused. This should be removed later.
std::string prefix = luaL_optstring(L, 4, "");
std::string suffix = luaL_optstring(L, 5, "");
std::string dir;
Expand All @@ -1621,7 +1614,7 @@ LuaFunc_SaveScreenshot(lua_State* L)
"Screenshots/";
}
std::string filename =
StepMania::SaveScreenshot(dir, compress, sign, prefix, suffix);
StepMania::SaveScreenshot(dir, compress, prefix, suffix);
if (pn != PlayerNumber_Invalid) {
}
std::string path = dir + filename;
Expand Down
1 change: 0 additions & 1 deletion src/Etterna/Globals/StepMania.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ InitializeCurrentGame(const Game* g);
std::string
SaveScreenshot(const std::string& Dir,
bool SaveCompressed,
bool MakeSignature,
const std::string& NamePrefix,
const std::string& NameSuffix);

Expand Down
20 changes: 5 additions & 15 deletions src/Etterna/Models/Misc/Profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ Profile::LoadCustomFunction(const std::string& sDir)
}

void
Profile::HandleStatsPrefixChange(std::string dir, bool require_signature)
Profile::HandleStatsPrefixChange(std::string dir)
{
// Temp variables to preserve stuff across the reload.
// Some stuff intentionally left out because the original reason for the
Expand All @@ -290,7 +290,7 @@ Profile::HandleStatsPrefixChange(std::string dir, bool require_signature)
const auto user_table = m_UserTable;
auto need_to_create_file = false;
if (IsAFile(dir + PROFILEMAN->GetStatsPrefix() + ETT_XML)) {
LoadAllFromDir(dir, require_signature, nullptr);
LoadAllFromDir(dir, nullptr);
} else {
ClearStats();
need_to_create_file = true;
Expand All @@ -309,14 +309,12 @@ Profile::HandleStatsPrefixChange(std::string dir, bool require_signature)
m_iTotalGameplaySeconds = total_gameplay_seconds;
m_UserTable = user_table;
if (need_to_create_file) {
SaveAllToDir(dir, require_signature);
SaveAllToDir(dir);
}
}

ProfileLoadResult
Profile::LoadAllFromDir(const std::string& sDir,
bool bRequireSignature,
LoadingWindow* ld)
Profile::LoadAllFromDir(const std::string& sDir, LoadingWindow* ld)
{
LOG->Trace("Profile::LoadAllFromDir( %s )", sDir.c_str());
ASSERT(sDir.back() == '/');
Expand Down Expand Up @@ -391,7 +389,7 @@ Profile::CalculateStatsFromScores()
}

bool
Profile::SaveAllToDir(const std::string& sDir, bool bSignData) const
Profile::SaveAllToDir(const std::string& sDir) const
{
m_LastPlayedDate = DateTime::GetNowDate();

Expand Down Expand Up @@ -656,14 +654,6 @@ Profile::SaveStatsWebPageToDir(const std::string& sDir) const
ASSERT(PROFILEMAN != nullptr);
}

void
Profile::SaveMachinePublicKeyToDir(const std::string& sDir) const
{
if (PREFSMAN->m_bSignProfileData &&
IsAFile(CRYPTMAN->GetPublicKeyFileName()))
FileCopy(CRYPTMAN->GetPublicKeyFileName(), sDir + PUBLIC_KEY_FILE);
}

void
Profile::AddScreenshot(const Screenshot& screenshot)
{
Expand Down
10 changes: 4 additions & 6 deletions src/Etterna/Models/Misc/Profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,15 +294,14 @@ class Profile
void swap(Profile& other);

// Loading and saving
void HandleStatsPrefixChange(std::string dir, bool require_signature);
auto LoadAllFromDir(const std::string& sDir,
bool bRequireSignature,
LoadingWindow* ld) -> ProfileLoadResult;
void HandleStatsPrefixChange(std::string dir);
auto LoadAllFromDir(const std::string& sDir, LoadingWindow* ld)
-> ProfileLoadResult;
auto LoadStatsFromDir(std::string dir, bool require_signature)
-> ProfileLoadResult;
void LoadTypeFromDir(const std::string& dir);
void LoadCustomFunction(const std::string& sDir);
auto SaveAllToDir(const std::string& sDir, bool bSignData) const -> bool;
auto SaveAllToDir(const std::string& sDir) const -> bool;

auto LoadEditableDataFromDir(const std::string& sDir) -> ProfileLoadResult;

Expand All @@ -313,7 +312,6 @@ class Profile
void CalculateStatsFromScores();

void SaveStatsWebPageToDir(const std::string& sDir) const;
void SaveMachinePublicKeyToDir(const std::string& sDir) const;

static void MoveBackupToDir(const std::string& sFromDir,
const std::string& sToDir);
Expand Down
6 changes: 3 additions & 3 deletions src/Etterna/Screen/Others/ScreenEvaluation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ ScreenEvaluation::Input(const InputEventPlus& input)
Profile* pProfile = PROFILEMAN->GetProfile(pn);
sDir = PROFILEMAN->GetProfileDir((ProfileSlot)pn) +
"Screenshots/";
sFileName = StepMania::SaveScreenshot(
sDir, bHoldingShift, true, "", "");
sFileName =
StepMania::SaveScreenshot(sDir, bHoldingShift, "", "");
if (!sFileName.empty()) {
std::string sPath = sDir + sFileName;

Expand All @@ -161,7 +161,7 @@ ScreenEvaluation::Input(const InputEventPlus& input)
} else {
sDir = "Screenshots/";
sFileName =
StepMania::SaveScreenshot(sDir, bHoldingShift, true, "", "");
StepMania::SaveScreenshot(sDir, bHoldingShift, "", "");
}
return true; // handled
}
Expand Down
Loading

0 comments on commit d99d824

Please sign in to comment.