diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2020-08-20 21:04:28 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@outlook.com> | 2020-08-21 01:50:09 +0200 |
commit | d8c8d0124da12587bbaf52992f7a8d2e0b010544 (patch) | |
tree | 305983c82fdb55ec7f9bc37cda1b54304f4a0ecf /src/Simulator/IncrementalRedstoneSimulator/PressurePlateHandler.h | |
parent | cChunk's deleted copy constructor needs const (diff) | |
download | cuberite-d8c8d0124da12587bbaf52992f7a8d2e0b010544.tar cuberite-d8c8d0124da12587bbaf52992f7a8d2e0b010544.tar.gz cuberite-d8c8d0124da12587bbaf52992f7a8d2e0b010544.tar.bz2 cuberite-d8c8d0124da12587bbaf52992f7a8d2e0b010544.tar.lz cuberite-d8c8d0124da12587bbaf52992f7a8d2e0b010544.tar.xz cuberite-d8c8d0124da12587bbaf52992f7a8d2e0b010544.tar.zst cuberite-d8c8d0124da12587bbaf52992f7a8d2e0b010544.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Simulator/IncrementalRedstoneSimulator/PressurePlateHandler.h | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/Simulator/IncrementalRedstoneSimulator/PressurePlateHandler.h b/src/Simulator/IncrementalRedstoneSimulator/PressurePlateHandler.h index 61450278f..14d8c3017 100644 --- a/src/Simulator/IncrementalRedstoneSimulator/PressurePlateHandler.h +++ b/src/Simulator/IncrementalRedstoneSimulator/PressurePlateHandler.h @@ -91,7 +91,7 @@ namespace PressurePlateHandler } } - inline unsigned char GetPowerDeliveredToPosition(const cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType, bool IsLinked) + inline PowerLevel GetPowerDeliveredToPosition(const cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType, bool IsLinked) { UNUSED(a_BlockType); UNUSED(a_QueryPosition); @@ -99,10 +99,10 @@ namespace PressurePlateHandler // Plates only link power blocks below // Retrieve and return the cached power calculated by Update for performance: - return (IsLinked && (a_QueryPosition != (a_Position + OffsetYM))) ? 0 : DataForChunk(a_Chunk).GetCachedPowerData(a_Position).PowerLevel; + return (IsLinked && (a_QueryPosition != (a_Position + OffsetYM))) ? 0 : DataForChunk(a_Chunk).GetCachedPowerData(a_Position); } - inline void Update(cChunk & a_Chunk, cChunk & CurrentlyTicking, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) + inline void Update(cChunk & a_Chunk, cChunk & CurrentlyTicking, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, const PowerLevel Power) { // LOGD("Evaluating clicky the pressure plate (%d %d %d)", a_Position.x, a_Position.y, a_Position.z); @@ -110,13 +110,13 @@ namespace PressurePlateHandler const auto PreviousPower = ChunkData.GetCachedPowerData(a_Position); const auto Absolute = cChunkDef::RelativeToAbsolute(a_Position, a_Chunk.GetPos()); - const auto Power = GetPowerLevel(a_Chunk, Absolute, a_BlockType); // Get the current power of the platey + const auto PowerLevel = GetPowerLevel(a_Chunk, Absolute, a_BlockType); // Get the current power of the platey const auto DelayInfo = ChunkData.GetMechanismDelayInfo(a_Position); // Resting state? if (DelayInfo == nullptr) { - if (Power == 0) + if (PowerLevel == 0) { // Nothing happened, back to rest return; @@ -129,7 +129,7 @@ namespace PressurePlateHandler a_Chunk.GetWorld()->BroadcastSoundEffect(GetClickOnSound(a_BlockType), Absolute, 0.5f, 0.6f); // Update power - ChunkData.SetCachedPowerData(a_Position, PoweringData(a_BlockType, Power)); + ChunkData.SetCachedPowerData(a_Position, PowerLevel); // Immediately depress plate a_Chunk.SetMeta(a_Position, E_META_PRESSURE_PLATE_DEPRESSED); @@ -148,7 +148,7 @@ namespace PressurePlateHandler if (DelayTicks > 0) { // Nothing changes, if there is nothing on it anymore, because the state is locked. - if (Power == 0) + if (PowerLevel == 0) { return; } @@ -161,10 +161,10 @@ namespace PressurePlateHandler } // Did the power level change and is still above zero? - if (Power != PreviousPower.PowerLevel) + if (PowerLevel != PreviousPower) { // Yes. Update power - ChunkData.SetCachedPowerData(a_Position, PoweringData(a_BlockType, Power)); + ChunkData.SetCachedPowerData(a_Position, PowerLevel); UpdateAdjustedRelatives(a_Chunk, CurrentlyTicking, a_Position, RelativeAdjacents); } @@ -175,7 +175,7 @@ namespace PressurePlateHandler if (HasExitedMinimumOnDelayPhase) { // Yep, initial delay elapsed. Has the player gotten off? - if (Power == 0) + if (PowerLevel == 0) { // Yes. Go into subsequent release delay, for a further 0.5 seconds *DelayInfo = std::make_pair(5, false); @@ -183,10 +183,10 @@ namespace PressurePlateHandler } // Did the power level change and is still above zero? - if (Power != PreviousPower.PowerLevel) + if (PowerLevel != PreviousPower) { // Yes. Update power - ChunkData.SetCachedPowerData(a_Position, PoweringData(a_BlockType, Power)); + ChunkData.SetCachedPowerData(a_Position, PowerLevel); UpdateAdjustedRelatives(a_Chunk, CurrentlyTicking, a_Position, RelativeAdjacents); } @@ -198,7 +198,7 @@ namespace PressurePlateHandler ChunkData.m_MechanismDelays.erase(a_Position); a_Chunk.GetWorld()->BroadcastSoundEffect(GetClickOffSound(a_BlockType), Absolute, 0.5f, 0.5f); - ChunkData.SetCachedPowerData(a_Position, PoweringData(a_BlockType, Power)); + ChunkData.SetCachedPowerData(a_Position, PowerLevel); a_Chunk.SetMeta(a_Position, E_META_PRESSURE_PLATE_RAISED); UpdateAdjustedRelatives(a_Chunk, CurrentlyTicking, a_Position, RelativeAdjacents); |