Refactor Controller in main to use std::unique_ptr

This commit is contained in:
Justin Scofield
2024-12-30 08:19:17 -05:00
parent e7ff32e223
commit d1a032a1f5

View File

@@ -35,18 +35,18 @@ int main(int argc, char** argv) {
SDL_SetMainReady(); SDL_SetMainReady();
#endif #endif
core::Controller controller; auto controller = std::make_unique<core::Controller>();
EXIT_IF_ERROR(controller.OnEntry(rom_filename)) EXIT_IF_ERROR(controller->OnEntry(rom_filename))
while (controller.IsActive()) { while (controller->IsActive()) {
controller.OnInput(); controller->OnInput();
if (auto status = controller.OnLoad(); !status.ok()) { if (auto status = controller->OnLoad(); !status.ok()) {
std::cerr << status.message() << std::endl; std::cerr << status.message() << std::endl;
break; break;
} }
controller.DoRender(); controller->DoRender();
} }
controller.OnExit(); controller->OnExit();
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }