Skip to content

Commit

Permalink
Fix report limit termination off by one error (#598)
Browse files Browse the repository at this point in the history
* Fix report limit termination off by one error

Signed-off-by: Nate Koenig <nate@openrobotics.org>

* Exceed to reached

Signed-off-by: Nate Koenig <nate@openrobotics.org>

* Fail safe

Signed-off-by: Nate Koenig <nate@openrobotics.org>

Co-authored-by: Nate Koenig <nate@openrobotics.org>
  • Loading branch information
nkoenig and Nate Koenig authored Sep 16, 2020
1 parent 9b8c41f commit 9cb0ee8
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions subt_ign/src/GameLogicPlugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1385,6 +1385,8 @@ bool GameLogicPluginPrivate::OnNewArtifact(const subt::msgs::Artifact &_req,
<< " time_sec: " << this->simTime.sec() << "\n"
<< " total_score: " << this->totalScore << std::endl;
this->LogEvent(stream.str());
this->Finish();
return true;
}
else if (!this->ArtifactFromInt(_req.type(), artifactType))
{
Expand Down Expand Up @@ -1432,11 +1434,20 @@ bool GameLogicPluginPrivate::OnNewArtifact(const subt::msgs::Artifact &_req,
return true;
}

if (!this->finished && this->reportCount > this->reportCountLimit)
if (!this->finished && this->reportCount >= this->reportCountLimit)
{
_resp.set_report_status("report limit exceeded");
this->Log() << "report_limit_exceeded" << std::endl;
ignmsg << "Report limit exceed." << std::endl;
_resp.set_report_status("report limit reached");
this->Log() << "report_limit_reached" << std::endl;
ignmsg << "Report limit reached." << std::endl;

std::ostringstream stream;
stream
<< "- event:\n"
<< " type: artifact_report_limit_reached\n"
<< " time_sec: " << this->simTime.sec() << "\n"
<< " total_score: " << this->totalScore << std::endl;
this->LogEvent(stream.str());

this->Finish();
return true;
}
Expand Down

0 comments on commit 9cb0ee8

Please sign in to comment.