| 69 | } |
| 70 | |
| 71 | void WorldUndoManager::undo() { |
| 72 | if(undoQueue.empty()) |
| 73 | return; |
| 74 | |
| 75 | world.bMan.refresh_gui_data(); |
| 76 | |
| 77 | bool undoFail = false; |
| 78 | |
| 79 | world.send_reliable_multi_command_to_all([&]() { |
| 80 | for(auto& u : std::views::reverse(undoQueue.back())) { |
| 81 | if(!u->undo(*this)) { |
| 82 | undoFail = true; |
| 83 | break; |
| 84 | } |
| 85 | } |
| 86 | }); |
| 87 | |
| 88 | if(undoFail) { |
| 89 | clear(); |
| 90 | Logger::get().log(Logger::LogType::INFO, "[WorldUndoManager::undo] Undo failed"); |
| 91 | } |
| 92 | else { |
| 93 | push_redo(std::move(undoQueue.back())); |
| 94 | undoQueue.pop_back(); |
| 95 | } |
| 96 | |
| 97 | set_world_has_unsaved_local_changes(); |
| 98 | |
| 99 | world.main.g.gui.set_to_layout(); |
| 100 | } |
| 101 | |
| 102 | void WorldUndoManager::redo() { |
| 103 | if(redoQueue.empty()) |
nothing calls this directly
no test coverage detected