simplified conversion

This commit is contained in:
EmosewaMC 2022-03-31 03:20:13 -07:00
parent 6499139a49
commit cf70881370

View File

@ -5890,7 +5890,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; int32_t reporterID = 0;
//Reading: //Reading:
inStream->Read(messageLength); inStream->Read(messageLength);
@ -5920,18 +5920,9 @@ void GameMessages::HandleReportBug(RakNet::BitStream* inStream, Entity* entity)
nOtherPlayerID.push_back(character); nOtherPlayerID.push_back(character);
} }
// Convert other player id from LWOOBJID to the database id. // Convert other player id from LWOOBJID to the database id.
std::istringstream iss(nOtherPlayerID); uint32_t otherPlayer = LWOOBJID_EMPTY;
LWOOBJID nOtherPlayerLWOOBJID; if (nOtherPlayerID != "") otherPlayer = std::atoi(nOtherPlayerID.c_str());
iss >> nOtherPlayerLWOOBJID;
if (nOtherPlayerLWOOBJID != LWOOBJID_EMPTY) {
auto otherPlayer = EntityManager::Instance()->GetEntity(nOtherPlayerLWOOBJID);
if (otherPlayer) {
auto character = otherPlayer->GetCharacter();
if (character) {
nOtherPlayerID = std::to_string(character->GetID());
}
}
}
uint32_t selectionLength; uint32_t selectionLength;
inStream->Read(selectionLength); inStream->Read(selectionLength);
for (unsigned int k = 0; k < selectionLength; k++) { for (unsigned int k = 0; k < selectionLength; k++) {
@ -5944,14 +5935,14 @@ void GameMessages::HandleReportBug(RakNet::BitStream* inStream, Entity* entity)
sql::PreparedStatement* insertBug = Database::CreatePreppedStmt("INSERT INTO `bug_reports`(body, client_version, other_player_id, selection, reporter_id) 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->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());
} }
} }