From 2b78fd6227b315dd2966a3143279313b4e350c2d Mon Sep 17 00:00:00 2001 From: Lukas Pioch Date: Fri, 1 Jul 2016 21:51:18 +0200 Subject: Revert "Made redstone handlers static" --- .../IncrementalRedstoneSimulator.cpp | 120 ++++++--------------- .../IncrementalRedstoneSimulator.h | 4 +- 2 files changed, 31 insertions(+), 93 deletions(-) diff --git a/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.cpp index c7be24dc4..4669dbd2c 100644 --- a/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.cpp +++ b/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.cpp @@ -30,122 +30,62 @@ -cRedstoneHandler * cIncrementalRedstoneSimulator::CreateComponent(cWorld & a_World, BLOCKTYPE a_BlockType, cIncrementalRedstoneSimulatorChunkData * a_Data) +std::unique_ptr cIncrementalRedstoneSimulator::CreateComponent(cWorld & a_World, BLOCKTYPE a_BlockType, cIncrementalRedstoneSimulatorChunkData * a_Data) { switch (a_BlockType) { case E_BLOCK_ACTIVATOR_RAIL: case E_BLOCK_DETECTOR_RAIL: - case E_BLOCK_POWERED_RAIL: - { - static cPoweredRailHandler ComponentHandler(a_World); - return &ComponentHandler; - } + case E_BLOCK_POWERED_RAIL: return cpp14::make_unique(a_World); + case E_BLOCK_ACTIVE_COMPARATOR: - case E_BLOCK_INACTIVE_COMPARATOR: - { - static cRedstoneComparatorHandler ComponentHandler(a_World); - return &ComponentHandler; - } + case E_BLOCK_INACTIVE_COMPARATOR: return cpp14::make_unique(a_World); + case E_BLOCK_DISPENSER: - case E_BLOCK_DROPPER: - { - static cDropSpenserHandler ComponentHandler(a_World); - return &ComponentHandler; - } + case E_BLOCK_DROPPER: return cpp14::make_unique(a_World); + case E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE: case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE: case E_BLOCK_STONE_PRESSURE_PLATE: - case E_BLOCK_WOODEN_PRESSURE_PLATE: - { - static cPressurePlateHandler ComponentHandler(a_World); - return &ComponentHandler; - } + case E_BLOCK_WOODEN_PRESSURE_PLATE: return cpp14::make_unique(a_World); + case E_BLOCK_FENCE_GATE: case E_BLOCK_IRON_TRAPDOOR: - case E_BLOCK_TRAPDOOR: - { - static cSmallGateHandler ComponentHandler(a_World); - return &ComponentHandler; - } + case E_BLOCK_TRAPDOOR: return cpp14::make_unique(a_World); + case E_BLOCK_REDSTONE_LAMP_OFF: - case E_BLOCK_REDSTONE_LAMP_ON: - { - static cRedstoneLampHandler ComponentHandler(a_World); - return &ComponentHandler; - } + case E_BLOCK_REDSTONE_LAMP_ON: return cpp14::make_unique(a_World); + case E_BLOCK_REDSTONE_REPEATER_OFF: - case E_BLOCK_REDSTONE_REPEATER_ON: - { - static cRedstoneRepeaterHandler ComponentHandler(a_World); - return &ComponentHandler; - } + case E_BLOCK_REDSTONE_REPEATER_ON: return cpp14::make_unique(a_World); + case E_BLOCK_REDSTONE_TORCH_OFF: - case E_BLOCK_REDSTONE_TORCH_ON: - { - static cRedstoneTorchHandler ComponentHandler(a_World); - return &ComponentHandler; - } + case E_BLOCK_REDSTONE_TORCH_ON: return cpp14::make_unique(a_World); + case E_BLOCK_PISTON: - case E_BLOCK_STICKY_PISTON: - { - static cPistonHandler ComponentHandler(a_World); - return &ComponentHandler; - } + case E_BLOCK_STICKY_PISTON: return cpp14::make_unique(a_World); + case E_BLOCK_LEVER: case E_BLOCK_STONE_BUTTON: - case E_BLOCK_WOODEN_BUTTON: - { - static cRedstoneToggleHandler ComponentHandler(a_World); - return &ComponentHandler; - } - case E_BLOCK_BLOCK_OF_REDSTONE: - { - static cRedstoneBlockHandler ComponentHandler(a_World); - return &ComponentHandler; - } - case E_BLOCK_COMMAND_BLOCK: - { - static cCommandBlockHandler ComponentHandler(a_World); - return &ComponentHandler; - } - case E_BLOCK_NOTE_BLOCK: - { - static cNoteBlockHandler ComponentHandler(a_World); - return &ComponentHandler; - } - case E_BLOCK_REDSTONE_WIRE: - { - static cRedstoneWireHandler ComponentHandler(a_World); - return &ComponentHandler; - } - case E_BLOCK_TNT: - { - static cTNTHandler ComponentHandler(a_World); - return &ComponentHandler; - } - case E_BLOCK_TRAPPED_CHEST: - { - static cTrappedChestHandler ComponentHandler(a_World); - return &ComponentHandler; - } - case E_BLOCK_TRIPWIRE_HOOK: - { - static cTripwireHookHandler ComponentHandler(a_World); - return &ComponentHandler; - } + case E_BLOCK_WOODEN_BUTTON: return cpp14::make_unique(a_World); + + case E_BLOCK_BLOCK_OF_REDSTONE: return cpp14::make_unique(a_World); + case E_BLOCK_COMMAND_BLOCK: return cpp14::make_unique(a_World); + case E_BLOCK_NOTE_BLOCK: return cpp14::make_unique(a_World); + case E_BLOCK_REDSTONE_WIRE: return cpp14::make_unique(a_World); + case E_BLOCK_TNT: return cpp14::make_unique(a_World); + case E_BLOCK_TRAPPED_CHEST: return cpp14::make_unique(a_World); + case E_BLOCK_TRIPWIRE_HOOK: return cpp14::make_unique(a_World); default: { if (cBlockDoorHandler::IsDoorBlockType(a_BlockType)) { - static cDoorHandler ComponentHandler(a_World); - return &ComponentHandler; + return cpp14::make_unique(a_World); } if (cBlockInfo::FullyOccupiesVoxel(a_BlockType)) { - static cSolidBlockHandler ComponentHandler(a_World); - return &ComponentHandler; + return cpp14::make_unique(a_World); } return nullptr; } diff --git a/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.h b/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.h index 5145cf7d1..673d50e49 100644 --- a/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.h +++ b/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.h @@ -18,8 +18,6 @@ public: { } - cIncrementalRedstoneSimulator(const cIncrementalRedstoneSimulator & a_Simulator) = delete; - virtual void Simulate(float a_dt) override; virtual void SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override {} @@ -160,7 +158,7 @@ public: } cIncrementalRedstoneSimulatorChunkData * GetChunkData() { return &m_Data; } - static cRedstoneHandler * CreateComponent(cWorld & a_World, BLOCKTYPE a_BlockType, cIncrementalRedstoneSimulatorChunkData * a_Data); + static std::unique_ptr CreateComponent(cWorld & a_World, BLOCKTYPE a_BlockType, cIncrementalRedstoneSimulatorChunkData * a_Data); private: -- cgit v1.2.3