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) {
// client-side npcs error nearby vanilla NPC scripts because callScriptedEntity
// for now, scrungle the collision poly to avoid their queries. hacky :(
if (auto mode = entityMode()) {
if (*mode == EntityMode::Master && connectionForEntity(entityId()) != ServerConnectionId) {
PolyF poly = m_movementController->collisionPoly();
m_movementController->setCollisionPoly({ { 0.0f, -FLT_MAX } });
auto result = m_netGroup.writeNetState(fromVersion);
m_movementController->setCollisionPoly(poly);
return result;
if (m_npcVariant.overrides.getBool("overrideNetPoly", false)) {
if (auto mode = entityMode()) {
if (*mode == EntityMode::Master && connectionForEntity(entityId()) != ServerConnectionId) {
PolyF poly = m_movementController->collisionPoly();
m_movementController->setCollisionPoly({ { 0.0f, -FLT_MAX } });
auto result = m_netGroup.writeNetState(fromVersion);
m_movementController->setCollisionPoly(poly);
return result;
}
}
}