nonperforming/openspadesplus

prevent fallingblocks from being created in the first place?

Opened this issue · 0 comments

current method only prevents fallingblocks from being rendered.

how about we dont create fallingblocks to begin with?
this will prevent fallingblocks from being created and updated completely which will save a bit of computing and might boost performance a bit.

BlocksFell() creates the falling blocks entities

void Client::BlocksFell(std::vector<IntVector3> blocks) {
SPADES_MARK_FUNCTION();
if (blocks.empty())
return;
AddLocalEntity(stmp::make_unique<FallingBlock>(this, blocks));
if (!IsMuted()) {
IntVector3 v = blocks[0];
Vector3 o;
o.x = v.x;
o.y = v.y;
o.z = v.z;
o += .5f;
Handle<IAudioChunk> c = audioDevice->RegisterSound("Sounds/Misc/BlockFall.opus");
audioDevice->Play(c.GetPointerOrNull(), o, AudioParam());
}
}

then check for p_fallingblocks and serverlimits for permission to call AddLocalEntity (creates the fallingblocks entity)

AddLocalEntity(stmp::make_unique<FallingBlock>(this, blocks));

if we still want the tear sound to play then move these lines up before AddLocalEntity

if (!IsMuted()) {
IntVector3 v = blocks[0];
Vector3 o;
o.x = v.x;
o.y = v.y;
o.z = v.z;
o += .5f;
Handle<IAudioChunk> c = audioDevice->RegisterSound("Sounds/Misc/BlockFall.opus");
audioDevice->Play(c.GetPointerOrNull(), o, AudioParam());
}