FlappyBug: Port to LibMain

Simplified two pledge() and two unveil() by using TRY().
This commit is contained in:
Pedro Pereira 2021-11-22 23:46:18 +00:00 committed by Brian Gianforcaro
parent ca7b603578
commit 85ae298b85
Notes: sideshowbarker 2024-07-18 00:50:31 +09:00
2 changed files with 9 additions and 21 deletions

View File

@ -10,4 +10,4 @@ set(SOURCES
)
serenity_app(FlappyBug ICON app-flappybug)
target_link_libraries(FlappyBug LibGUI LibConfig)
target_link_libraries(FlappyBug LibGUI LibConfig LibMain)

View File

@ -12,33 +12,21 @@
#include <LibGUI/Menubar.h>
#include <LibGUI/MessageBox.h>
#include <LibGUI/Window.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 rpath recvfd sendfd unix", nullptr) < 0) {
perror("pledge");
return 1;
}
TRY(System::pledge("stdio rpath recvfd sendfd unix", nullptr));
auto app = GUI::Application::construct(argc, argv);
auto app = GUI::Application::construct(arguments.argc, arguments.argv);
Config::pledge_domains("FlappyBug");
if (pledge("stdio rpath recvfd sendfd", nullptr) < 0) {
perror("pledge");
return 1;
}
TRY(System::pledge("stdio rpath recvfd sendfd", 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));
u32 high_score = Config::read_i32("FlappyBug", "Game", "HighScore", 0);