Make client-side NPC collisionPoly override opt-in

This commit is contained in:
Kae 2023-07-29 00:49:38 +10:00
parent f2afd91d0f
commit 5c650d7809

View File

@ -254,13 +254,15 @@ RectF Npc::collisionArea() const {
pair<ByteArray, uint64_t> Npc::writeNetState(uint64_t fromVersion) { pair<ByteArray, uint64_t> Npc::writeNetState(uint64_t fromVersion) {
// client-side npcs error nearby vanilla NPC scripts because callScriptedEntity // client-side npcs error nearby vanilla NPC scripts because callScriptedEntity
// for now, scrungle the collision poly to avoid their queries. hacky :( // for now, scrungle the collision poly to avoid their queries. hacky :(
if (auto mode = entityMode()) { if (m_npcVariant.overrides.getBool("overrideNetPoly", false)) {
if (*mode == EntityMode::Master && connectionForEntity(entityId()) != ServerConnectionId) { if (auto mode = entityMode()) {
PolyF poly = m_movementController->collisionPoly(); if (*mode == EntityMode::Master && connectionForEntity(entityId()) != ServerConnectionId) {
m_movementController->setCollisionPoly({ { 0.0f, -FLT_MAX } }); PolyF poly = m_movementController->collisionPoly();
auto result = m_netGroup.writeNetState(fromVersion); m_movementController->setCollisionPoly({ { 0.0f, -FLT_MAX } });
m_movementController->setCollisionPoly(poly); auto result = m_netGroup.writeNetState(fromVersion);
return result; m_movementController->setCollisionPoly(poly);
return result;
}
} }
} }