ErrorReporting: MP error attribution
This commit is contained in:
parent
cbe46468d1
commit
de90c281a5
3 changed files with 60 additions and 5 deletions
src
|
@ -249,6 +249,11 @@ FGAIBase::removeModel()
|
|||
}
|
||||
}
|
||||
|
||||
void FGAIBase::setScenarioPath(const std::string& scenarioPath)
|
||||
{
|
||||
_scenarioPath = scenarioPath;
|
||||
}
|
||||
|
||||
void FGAIBase::readFromScenario(SGPropertyNode* scFileNode)
|
||||
{
|
||||
if (!scFileNode)
|
||||
|
@ -330,6 +335,10 @@ void FGAIBase::update(double dt) {
|
|||
if (fxpath != "")
|
||||
{
|
||||
simgear::ErrorReportContext ec("ai-model", _name);
|
||||
if (!_scenarioPath.empty()) {
|
||||
ec.add("scenario-path", _scenarioPath);
|
||||
}
|
||||
|
||||
props->setStringValue("sim/sound/path", fxpath.c_str());
|
||||
|
||||
// Remove any existing sound FX (e.g. from another model)
|
||||
|
@ -629,6 +638,10 @@ bool FGAIBase::init(ModelSearchOrder searchOrder)
|
|||
_modeldata->addErrorContext("ai", _name);
|
||||
_modeldata->captureErrorContext("scenario-path");
|
||||
|
||||
if (_otype == otMultiplayer) {
|
||||
_modeldata->addErrorContext("multiplayer", getCallSign());
|
||||
}
|
||||
|
||||
vector<string> model_list = resolveModelPath(searchOrder);
|
||||
_model= SGModelLib::loadPagedModel(model_list, props, _modeldata);
|
||||
_model->setName("AI-model range animation node");
|
||||
|
|
|
@ -147,6 +147,9 @@ public:
|
|||
double _getCartPosZ() const;
|
||||
|
||||
osg::PagedLOD* getSceneBranch() const;
|
||||
|
||||
void setScenarioPath(const std::string& scenarioPath);
|
||||
|
||||
protected:
|
||||
double _elevation_m;
|
||||
|
||||
|
@ -167,6 +170,7 @@ protected:
|
|||
std::string _submodel;
|
||||
std::string _name;
|
||||
std::string _parent;
|
||||
std::string _scenarioPath;
|
||||
|
||||
/**
|
||||
* Tied-properties helper, record nodes which are tied for easy un-tie-ing
|
||||
|
|
|
@ -68,7 +68,9 @@ enum class Aggregation {
|
|||
Scenario,
|
||||
InputDevice,
|
||||
FGData,
|
||||
Unknown ///< error coudln't be attributed more specifcially
|
||||
MultiPlayer,
|
||||
Unknown, ///< error coudln't be attributed more specifcially
|
||||
OutOfMemory ///< seperate category to give it a custom message
|
||||
};
|
||||
|
||||
// these should correspond to simgear::ErrorCode enum
|
||||
|
@ -83,9 +85,9 @@ string_list static_errorIds = {
|
|||
"error-audio-fx-load",
|
||||
"error-xml-load-command",
|
||||
"error-aircraft-systems",
|
||||
"error-input-device-config"
|
||||
"error-input-device-config",
|
||||
"error-ai-traffic-schedule",
|
||||
};
|
||||
"error-terrasync"};
|
||||
|
||||
string_list static_errorTypeIds = {
|
||||
"error-type-unknown",
|
||||
|
@ -93,7 +95,9 @@ string_list static_errorTypeIds = {
|
|||
"error-type-out-of-memory",
|
||||
"error-type-bad-header",
|
||||
"error-type-bad-data",
|
||||
"error-type-misconfigured"};
|
||||
"error-type-misconfigured",
|
||||
"error-type-io",
|
||||
"error-type-network"};
|
||||
|
||||
|
||||
string_list static_categoryIds = {
|
||||
|
@ -105,7 +109,9 @@ string_list static_categoryIds = {
|
|||
"error-category-scenario",
|
||||
"error-category-input-device",
|
||||
"error-category-fgdata",
|
||||
"error-category-unknown"};
|
||||
"error-category-multiplayer",
|
||||
"error-category-unknown",
|
||||
"error-category-out-of-memory"};
|
||||
|
||||
class RecentLogCallback : public simgear::LogCallback
|
||||
{
|
||||
|
@ -164,6 +170,7 @@ public:
|
|||
SGPropertyNode_ptr _enabledNode;
|
||||
SGPropertyNode_ptr _displayNode;
|
||||
SGPropertyNode_ptr _activeErrorNode;
|
||||
SGPropertyNode_ptr _mpReportNode;
|
||||
|
||||
using ErrorContext = std::map<std::string, std::string>;
|
||||
/**
|
||||
|
@ -328,6 +335,13 @@ public:
|
|||
auto ErrorReporter::ErrorReporterPrivate::getAggregateForOccurence(const ErrorReporter::ErrorReporterPrivate::ErrorOcurrence& oc)
|
||||
-> AggregateErrors::iterator
|
||||
{
|
||||
// all OOM errors go to a dedicated category. This is so we don't blame
|
||||
// out of memory on the aircraft/scenery/etc, when it's not the underlying
|
||||
// cause.
|
||||
if (oc.type == simgear::LoadFailure::OutOfMemory) {
|
||||
return getAggregate(Aggregation::OutOfMemory, {});
|
||||
}
|
||||
|
||||
if (oc.hasContextKey("primary-aircraft")) {
|
||||
const auto fullId = fgGetString("/sim/aircraft-id");
|
||||
if (fullId != fgGetString("/sim/aircraft")) {
|
||||
|
@ -337,6 +351,16 @@ auto ErrorReporter::ErrorReporterPrivate::getAggregateForOccurence(const ErrorRe
|
|||
return getAggregate(Aggregation::HangarAircraft, fullId);
|
||||
}
|
||||
|
||||
if (oc.hasContextKey("multiplayer")) {
|
||||
return getAggregate(Aggregation::MultiPlayer, {});
|
||||
}
|
||||
|
||||
// all TerraSync coded errors go there: this is errors for the
|
||||
// actual download process (eg, failed to write to disk)
|
||||
if (oc.code == simgear::ErrorCode::TerraSync) {
|
||||
return getAggregate(Aggregation::TerraSync, {});
|
||||
}
|
||||
|
||||
if (oc.hasContextKey("terrain-stg")) {
|
||||
// determine if it's custom scenery, TerraSync or FGData
|
||||
|
||||
|
@ -550,6 +574,7 @@ void ErrorReporter::bind()
|
|||
|
||||
d->_displayNode = n->getNode("display", true);
|
||||
d->_activeErrorNode = n->getNode("active", true);
|
||||
d->_mpReportNode = n->getNode("mp-report-enabled", true);
|
||||
}
|
||||
|
||||
void ErrorReporter::unbind()
|
||||
|
@ -594,6 +619,7 @@ void ErrorReporter::init()
|
|||
void ErrorReporter::update(double dt)
|
||||
{
|
||||
bool showDialog = false;
|
||||
bool havePendingReports = false;
|
||||
|
||||
// beginning of locked section
|
||||
{
|
||||
|
@ -623,6 +649,13 @@ void ErrorReporter::update(double dt)
|
|||
|
||||
// check if an error is current active
|
||||
for (auto& report : d->_aggregated) {
|
||||
if (report.type == Aggregation::MultiPlayer) {
|
||||
if (!d->_mpReportNode->getBoolValue()) {
|
||||
// mark it as shown, to supress it
|
||||
report.haveShownToUser = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (report.haveShownToUser) {
|
||||
// unless we ever re-show?
|
||||
continue;
|
||||
|
@ -635,9 +668,14 @@ void ErrorReporter::update(double dt)
|
|||
|
||||
// if we show one report, don't consider any others for now
|
||||
break;
|
||||
} else {
|
||||
havePendingReports = true;
|
||||
}
|
||||
} // of active aggregates iteration
|
||||
|
||||
if (!havePendingReports) {
|
||||
d->_reportsDirty = false;
|
||||
}
|
||||
} // end of locked section
|
||||
|
||||
// do not call into another subsystem with our lock held,
|
||||
|
|
Loading…
Add table
Reference in a new issue