summaryrefslogtreecommitdiff
path: root/Userland/Games/Breakout
diff options
context:
space:
mode:
authorPedro Pereira <pmh.pereira@gmail.com>2021-11-22 22:37:30 +0000
committerAndreas Kling <kling@serenityos.org>2021-11-22 23:44:09 +0100
commit6e6228d40d86a39ceeede0bd0a5c07d029885704 (patch)
treea7daf134061ed9fd6ff38b49466484fd0cab3610 /Userland/Games/Breakout
parent8fa5dc7241845858fa95fbc69b2b527baf224eb4 (diff)
downloadserenity-6e6228d40d86a39ceeede0bd0a5c07d029885704.zip
Breakout: Port to LibMain
Simplified two pledge() and two unveil() by using TRY().
Diffstat (limited to 'Userland/Games/Breakout')
-rw-r--r--Userland/Games/Breakout/CMakeLists.txt2
-rw-r--r--Userland/Games/Breakout/main.cpp28
2 files changed, 9 insertions, 21 deletions
diff --git a/Userland/Games/Breakout/CMakeLists.txt b/Userland/Games/Breakout/CMakeLists.txt
index 0cd3d1d1fd..3fad09eb26 100644
--- a/Userland/Games/Breakout/CMakeLists.txt
+++ b/Userland/Games/Breakout/CMakeLists.txt
@@ -11,4 +11,4 @@ set(SOURCES
)
serenity_app(Breakout ICON app-breakout)
-target_link_libraries(Breakout LibGUI)
+target_link_libraries(Breakout LibGUI LibMain)
diff --git a/Userland/Games/Breakout/main.cpp b/Userland/Games/Breakout/main.cpp
index 789f49f1fb..ef8a28997c 100644
--- a/Userland/Games/Breakout/main.cpp
+++ b/Userland/Games/Breakout/main.cpp
@@ -11,31 +11,19 @@
#include <LibGUI/Menubar.h>
#include <LibGUI/Window.h>
#include <LibGfx/Bitmap.h>
-#include <unistd.h>
+#include <LibMain/Main.h>
+#include <LibSystem/Wrappers.h>
-int main(int argc, char** argv)
+ErrorOr<int> serenity_main(Main::Arguments arguments)
{
- if (pledge("stdio recvfd sendfd rpath unix", nullptr) < 0) {
- perror("pledge");
- return 1;
- }
+ TRY(System::pledge("stdio recvfd sendfd rpath unix", nullptr));
- auto app = GUI::Application::construct(argc, argv);
+ auto app = GUI::Application::construct(arguments.argc, arguments.argv);
- if (pledge("stdio recvfd sendfd rpath", nullptr) < 0) {
- perror("pledge");
- return 1;
- }
+ TRY(System::pledge("stdio recvfd sendfd rpath", nullptr));
- if (unveil("/res", "r") < 0) {
- perror("unveil");
- return 1;
- }
-
- if (unveil(nullptr, nullptr) < 0) {
- perror("unveil");
- return 1;
- }
+ TRY(System::unveil("/res", "r"));
+ TRY(System::unveil(nullptr, nullptr));
auto window = GUI::Window::construct();
window->resize(Breakout::Game::game_width, Breakout::Game::game_height);