Core/Tickets: Don't try to save the same sub-survey more than once

This commit is contained in:
jackpoz
2014-06-04 19:45:02 +02:00
parent 84d0094ffa
commit bd45a0bba9

View File

@@ -187,6 +187,7 @@ void WorldSession::HandleGMSurveySubmit(WorldPacket& recvData)
uint32 mainSurvey; // GMSurveyCurrentSurvey.dbc, column 1 (all 9) ref to GMSurveySurveys.dbc
recvData >> mainSurvey;
std::unordered_set<uint32> surveyIds;
SQLTransaction trans = CharacterDatabase.BeginTransaction();
// sub_survey1, r1, comment1, sub_survey2, r2, comment2, sub_survey3, r3, comment3, sub_survey4, r4, comment4, sub_survey5, r5, comment5, sub_survey6, r6, comment6, sub_survey7, r7, comment7, sub_survey8, r8, comment8, sub_survey9, r9, comment9, sub_survey10, r10, comment10,
for (uint8 i = 0; i < 10; i++)
@@ -201,6 +202,10 @@ void WorldSession::HandleGMSurveySubmit(WorldPacket& recvData)
std::string comment; // comment ("Usage: GMSurveyAnswerSubmit(question, rank, comment)")
recvData >> comment;
// make sure the same sub survey is not added to DB twice
if (!surveyIds.insert(subSurveyId).second)
continue;
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GM_SUBSURVEY);
stmt->setUInt32(0, nextSurveyID);
stmt->setUInt32(1, subSurveyId);