1
0
Fork 0

Add protection to the multiplayer (AI) interpolation to protect against segfaults when the previous and next packets contain different properties.

This commit is contained in:
Richard Harrison 2017-01-30 23:24:39 +01:00
parent e39eac8a6d
commit 0bf80f9b2a

View file

@ -319,6 +319,19 @@ void FGAIMultiplayer::update(double dt)
int ival;
float val;
/*
* RJH - 2017-01-25
* During multiplayer operations a series of crashes were encountered that affected all players
* within range of each other and resulting in an exception being thrown at exactly the same moment in time
* (within case props::STRING: ref http://i.imgur.com/y6MBoXq.png)
* Investigation showed that the nextPropIt and prevPropIt were pointing to different properties
* which may be caused due to certain models that have overloaded mp property transmission and
* these craft have their properties truncated due to packet size. However the result of this
* will be different contents in the previous and current packets, so here we protect against
* this by only considering properties where the previous and next id are the same.
* It might be a better solution to search the previous and next lists to locate the matching id's
*/
if (*nextPropIt && (*nextPropIt)->id == (*prevPropIt)->id ) {
switch ((*prevPropIt)->type) {
case props::INT:
case props::BOOL:
@ -350,6 +363,11 @@ void FGAIMultiplayer::update(double dt)
}
}
else
{
SG_LOG(SG_AI, SG_WARN, "MP packet mismatch during lag interpolation: " << (*prevPropIt)->id << " != " << (*nextPropIt)->id << "\n");
}
}
else
{
SG_LOG(SG_AI, SG_DEBUG, "Unable to find property: " << (*prevPropIt)->id << "\n");
}