Merge pull request #476 from EmosewaMC/bugReportFixing

Added more specific bug reporting.  There is a new migration called migrations/dlu/2_reporter_id.sql to run on the database.
This commit is contained in:
David Markowitz 2022-04-01 15:12:58 -07:00 committed by GitHub
commit db0f363967
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View File

@ -5925,6 +5925,7 @@ void GameMessages::HandleReportBug(RakNet::BitStream* inStream, Entity* entity)
std::string nOtherPlayerID; std::string nOtherPlayerID;
std::string selection; std::string selection;
uint32_t messageLength; uint32_t messageLength;
int32_t reporterID = 0;
//Reading: //Reading:
inStream->Read(messageLength); inStream->Read(messageLength);
@ -5935,6 +5936,9 @@ void GameMessages::HandleReportBug(RakNet::BitStream* inStream, Entity* entity)
body.push_back(character); body.push_back(character);
} }
auto character = entity->GetCharacter();
if (character) reporterID = character->GetID();
uint32_t clientVersionLength; uint32_t clientVersionLength;
inStream->Read(clientVersionLength); inStream->Read(clientVersionLength);
for (unsigned int k = 0; k < clientVersionLength; k++) { for (unsigned int k = 0; k < clientVersionLength; k++) {
@ -5950,6 +5954,9 @@ void GameMessages::HandleReportBug(RakNet::BitStream* inStream, Entity* entity)
inStream->Read(character); inStream->Read(character);
nOtherPlayerID.push_back(character); nOtherPlayerID.push_back(character);
} }
// Convert other player id from LWOOBJID to the database id.
uint32_t otherPlayer = LWOOBJID_EMPTY;
if (nOtherPlayerID != "") otherPlayer = std::atoi(nOtherPlayerID.c_str());
uint32_t selectionLength; uint32_t selectionLength;
inStream->Read(selectionLength); inStream->Read(selectionLength);
@ -5960,16 +5967,17 @@ void GameMessages::HandleReportBug(RakNet::BitStream* inStream, Entity* entity)
} }
try { try {
sql::PreparedStatement* insertBug = Database::CreatePreppedStmt("INSERT INTO `bug_reports`(body, client_version, other_player_id, selection) VALUES (?, ?, ?, ?)"); sql::PreparedStatement* insertBug = Database::CreatePreppedStmt("INSERT INTO `bug_reports`(body, client_version, other_player_id, selection, reporter_id) VALUES (?, ?, ?, ?, ?)");
insertBug->setString(1, GeneralUtils::UTF16ToWTF8(body)); insertBug->setString(1, GeneralUtils::UTF16ToWTF8(body));
insertBug->setString(2, clientVersion); insertBug->setString(2, clientVersion);
insertBug->setString(3, nOtherPlayerID); insertBug->setString(3, std::to_string(otherPlayer));
insertBug->setString(4, selection); insertBug->setString(4, selection);
insertBug->setInt(5, reporterID);
insertBug->execute(); insertBug->execute();
delete insertBug; delete insertBug;
} }
catch (sql::SQLException& e) { catch (sql::SQLException& e) {
Game::logger->Log("HandleReportBug", "Couldn't save bug report!\n"); Game::logger->Log("HandleReportBug", "Couldn't save bug report! (%s)\n", e.what());
} }
} }

View File

@ -0,0 +1 @@
ALTER TABLE bug_reports ADD reporter_id INT NOT NULL DEFAULT 0;