Showing the changes to assignment-client/src/scripts/EntityScriptServer.cpp (1 of 38 files). Show all
Unified · Split
| @@ -125,8 +125,18 @@ void EntityScriptServer::handleEntityScriptGetStatusPacket(QSharedPointer<Receiv · 124 unmodified lines | ||
| 125 | 125 | auto replyPacketList = NLPacketList::create(PacketType::EntityScriptGetStatusReply, QByteArray(), true, true); |
| 126 | 126 | replyPacketList->writePrimitive(messageID); |
| 127 | 127 | |
| 128 | + EntityTreePointer tree = _entityViewer.getTree(); | |
| 129 | + if (!tree) { | |
| 130 | + return; | |
| 131 | + } | |
| 132 | + | |
| 133 | + EntityItemPointer entity = tree->findEntityByEntityItemID(entityID); | |
| 134 | + if (!entity) { | |
| 135 | + return; | |
| 136 | + } | |
| 137 | + | |
| 128 | 138 | EntityScriptDetails details; |
| 129 | − if (_entitiesScriptManager->getEntityScriptDetails(entityID, details)) { | |
| 139 | + if (_entitiesScriptManager->getEntityScriptDetails(entityID, entity->getServerScripts(), details)) { | |
| 130 | 140 | replyPacketList->writePrimitive(true); |
| 131 | 141 | replyPacketList->writePrimitive(details.status); |
| 132 | 142 | replyPacketList->writeString(details.errorInfo); |
| @@ -568,7 +578,7 @@ void EntityScriptServer::addingEntity(const EntityItemID& entityID) { · 435 unmodified lines | ||
| 568 | 578 | void EntityScriptServer::deletingEntity(const EntityItemID& entityID) { |
| 569 | 579 | if (_entityViewer.getTree() && !_shuttingDown && _entitiesScriptManager) { |
| 570 | 580 | // TODO: Check if this is running on script engine thread, otherwise lambda capturing script engine pointer is needed |
| 571 | − _entitiesScriptManager->unloadEntityScript(entityID, true); | |
| 581 | + _entitiesScriptManager->unloadAllEntityScriptsForEntity(entityID, true); | |
| 572 | 582 | } |
| 573 | 583 | } |
| 574 | 584 | |
| @@ -582,12 +592,17 @@ void EntityScriptServer::checkAndCallPreload(const EntityItemID& entityID, bool · 7 unmodified lines | ||
| 582 | 592 | if (_entityViewer.getTree() && !_shuttingDown && _entitiesScriptManager) { |
| 583 | 593 | |
| 584 | 594 | EntityItemPointer entity = _entityViewer.getTree()->findEntityByEntityItemID(entityID); |
| 595 | + if (!entity) { | |
| 596 | + return; | |
| 597 | + } | |
| 598 | + | |
| 599 | + QString serverScripts = entity->getServerScripts(); | |
| 585 | 600 | EntityScriptDetails details; |
| 586 | − bool isRunning = _entitiesScriptManager->getEntityScriptDetails(entityID, details); | |
| 587 | − if (entity && (forceRedownload || !isRunning || details.scriptText != entity->getServerScripts())) { | |
| 601 | + bool isRunning = _entitiesScriptManager->getEntityScriptDetails(entityID, serverScripts, details); | |
| 602 | + if (forceRedownload || !isRunning || details.scriptText != serverScripts) { | |
| 588 | 603 | // TODO: Check if this is running on script engine thread, otherwise lambda capturing script engine pointer is needed |
| 589 | 604 | if (isRunning) { |
| 590 | − _entitiesScriptManager->unloadEntityScript(entityID, true); | |
| 605 | + _entitiesScriptManager->unloadEntityScript(entityID, serverScripts, true); | |
| 591 | 606 | } |
| 592 | 607 | |
| 593 | 608 | QString scriptUrl = entity->getServerScripts(); |