Skip to content

Commit

Permalink
feat: add mhf.exe hash
Browse files Browse the repository at this point in the history
  • Loading branch information
DorielRivalet committed Feb 10, 2023
1 parent e713b5c commit 53e9d9e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
17 changes: 13 additions & 4 deletions MHFZ_Overlay/Core/Class/DataAccessLayer/DatabaseManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,8 @@ public void InsertQuestData(DataLoader dataLoader)
mhfinfHash,
mhfsqdHash,
mhfodllHash,
mhfohddllHash
mhfohddllHash,
mhfexeHash
) VALUES (
@GameFolderHash,
@CreatedAt,
Expand All @@ -528,7 +529,9 @@ public void InsertQuestData(DataLoader dataLoader)
@mhfinfHash,
@mhfsqdHash,
@mhfodllHash,
@mhfohddllHash)";
@mhfohddllHash,
@mhfexeHash)";

using (SQLiteCommand cmd = new SQLiteCommand(sql, conn))
{
string gameFolderPath = s.GameFolderPath;
Expand All @@ -538,11 +541,14 @@ public void InsertQuestData(DataLoader dataLoader)
string mhfsqdHash = CalculateFileHash(gameFolderPath, @"\dat\mhfsqd.bin");
string mhfodllHash = CalculateFileHash(gameFolderPath, @"\mhfo.dll");
string mhfohddllHash = CalculateFileHash(gameFolderPath, @"\mhfo-hd.dll");
string mhfexeHash = CalculateFileHash(gameFolderPath, @"\mhf.exe");

string datFolderData = string.Format(
"{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}",
"{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}",
createdAt, createdBy, runID,
gameFolderPath, mhfdatHash, mhfemdHash,
mhfinfHash, mhfsqdHash, mhfodllHash, mhfohddllHash);
mhfinfHash, mhfsqdHash, mhfodllHash,
mhfohddllHash, mhfexeHash);
string datFolderHash = CalculateStringHash(datFolderData);

cmd.Parameters.AddWithValue("@GameFolderHash", datFolderHash);
Expand All @@ -556,6 +562,8 @@ public void InsertQuestData(DataLoader dataLoader)
cmd.Parameters.AddWithValue("@mhfsqdHash", mhfsqdHash);
cmd.Parameters.AddWithValue("@mhfodllHash", mhfodllHash);
cmd.Parameters.AddWithValue("@mhfohddllHash", mhfohddllHash);
cmd.Parameters.AddWithValue("@mhfexeHash", mhfexeHash);

cmd.ExecuteNonQuery();
}

Expand Down Expand Up @@ -2870,6 +2878,7 @@ CREATE TABLE IF NOT EXISTS GameFolder (
mhfsqdHash TEXT NOT NULL,
mhfodllHash TEXT NOT NULL,
mhfohddllHash TEXT NOT NULL,
mhfexeHash TEXT NOT NULL,
FOREIGN KEY(RunID) REFERENCES Quests(RunID)
)";
using (SQLiteCommand cmd = new SQLiteCommand(sql, conn))
Expand Down
5 changes: 3 additions & 2 deletions MHFZ_Overlay/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1947,8 +1947,9 @@ private void UpdateDiscordRPC()
return;
}

if (string.Format("{0}{1}{2}{3}{4}{5}", GetPartySize(), GetQuestState(), GetCaravanScore(), DataLoader.model.GetOverlayModeForRPC(), DataLoader.model.GetAreaName(DataLoader.model.AreaID()), GetGameMode(DataLoader.isHighGradeEdition)).Length >= 128)
presenceTemplate.Details = string.Format("{0}{1}{2}{3}", GetQuestState(), DataLoader.model.GetOverlayModeForRPC(), DataLoader.model.GetAreaName(DataLoader.model.AreaID()), GetGameMode(DataLoader.isHighGradeEdition));
// TODO also need to handle the other fields lengths
if (string.Format("{0}{1}{2}{3}{4}{5}", GetPartySize(), GetQuestState(), GetCaravanScore(), DataLoader.model.GetOverlayModeForRPC(), DataLoader.model.GetAreaName(DataLoader.model.AreaID()), GetGameMode(DataLoader.isHighGradeEdition)).Length >= 63)
presenceTemplate.Details = string.Format("{0}{1}{2}", GetQuestState(), DataLoader.model.GetOverlayModeForRPC(), DataLoader.model.GetAreaName(DataLoader.model.AreaID()));
else
presenceTemplate.Details = string.Format("{0}{1}{2}{3}{4}{5}", GetPartySize(), GetQuestState(), GetCaravanScore(), DataLoader.model.GetOverlayModeForRPC(), DataLoader.model.GetAreaName(DataLoader.model.AreaID()), GetGameMode(DataLoader.isHighGradeEdition));

Expand Down
3 changes: 2 additions & 1 deletion MHFZ_Overlay/addresses/AddressModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9074,7 +9074,8 @@ public bool ValidateGameFolder()
s.GameFolderPath + @"\dat\mhfemd.bin",
s.GameFolderPath + @"\dat\mhfsqd.bin",
s.GameFolderPath + @"\mhfo.dll",
s.GameFolderPath + @"\mhfo-hd.dll"
s.GameFolderPath + @"\mhfo-hd.dll",
s.GameFolderPath + @"\mhf.exe"
};

//check if the folder is named dat and contains dat, emd, and sqd.
Expand Down

0 comments on commit 53e9d9e

Please sign in to comment.