mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-17 07:46:36 +02:00
Merge pull request #3161 from ZappoMan/fixeParticleServerCrash
fix crash in particle and model server from attempting to edit items that dont exist in the server
This commit is contained in:
commit
a5222c7bbd
2 changed files with 14 additions and 12 deletions
|
@ -331,6 +331,7 @@ ModelItem ModelItem::fromEditPacket(const unsigned char* data, int length, int&
|
|||
|
||||
newModelItem.setCreatorTokenID(creatorTokenID);
|
||||
newModelItem._newlyCreated = true;
|
||||
valid = true;
|
||||
|
||||
} else {
|
||||
// look up the existing modelItem
|
||||
|
@ -339,20 +340,19 @@ ModelItem ModelItem::fromEditPacket(const unsigned char* data, int length, int&
|
|||
// copy existing properties before over-writing with new properties
|
||||
if (existingModelItem) {
|
||||
newModelItem = *existingModelItem;
|
||||
valid = true;
|
||||
} else {
|
||||
// the user attempted to edit a modelItem that doesn't exist
|
||||
qDebug() << "user attempted to edit a modelItem that doesn't exist...";
|
||||
qDebug() << "user attempted to edit a modelItem that doesn't exist... editID=" << editID;
|
||||
|
||||
// NOTE: even though this is a bad editID, we have to consume the edit details, so that
|
||||
// the buffer doesn't get corrupted for further processing...
|
||||
valid = false;
|
||||
return newModelItem;
|
||||
}
|
||||
newModelItem._id = editID;
|
||||
newModelItem._newlyCreated = false;
|
||||
}
|
||||
|
||||
// if we got this far, then our result will be valid
|
||||
valid = true;
|
||||
|
||||
|
||||
// lastEdited
|
||||
memcpy(&newModelItem._lastEdited, dataAt, sizeof(newModelItem._lastEdited));
|
||||
dataAt += sizeof(newModelItem._lastEdited);
|
||||
|
|
|
@ -385,6 +385,8 @@ Particle Particle::fromEditPacket(const unsigned char* data, int length, int& pr
|
|||
newParticle._newlyCreated = true;
|
||||
newParticle.setAge(0); // this guy is new!
|
||||
|
||||
valid = true;
|
||||
|
||||
} else {
|
||||
// look up the existing particle
|
||||
const Particle* existingParticle = tree->findParticleByID(editID, true);
|
||||
|
@ -392,20 +394,20 @@ Particle Particle::fromEditPacket(const unsigned char* data, int length, int& pr
|
|||
// copy existing properties before over-writing with new properties
|
||||
if (existingParticle) {
|
||||
newParticle = *existingParticle;
|
||||
valid = true;
|
||||
|
||||
} else {
|
||||
// the user attempted to edit a particle that doesn't exist
|
||||
qDebug() << "user attempted to edit a particle that doesn't exist...";
|
||||
qDebug() << "user attempted to edit a particle that doesn't exist... editID=" << editID;
|
||||
|
||||
// NOTE: even though this is a bad particle ID, we have to consume the edit details, so that
|
||||
// the buffer doesn't get corrupted for further processing...
|
||||
valid = false;
|
||||
return newParticle;
|
||||
}
|
||||
newParticle._id = editID;
|
||||
newParticle._newlyCreated = false;
|
||||
}
|
||||
|
||||
// if we got this far, then our result will be valid
|
||||
valid = true;
|
||||
|
||||
|
||||
// lastEdited
|
||||
memcpy(&newParticle._lastEdited, dataAt, sizeof(newParticle._lastEdited));
|
||||
dataAt += sizeof(newParticle._lastEdited);
|
||||
|
|
Loading…
Reference in a new issue