FlappyBug: Port to LibMain
Simplified two pledge() and two unveil() by using TRY().
This commit is contained in:
parent
ca7b603578
commit
85ae298b85
Notes:
sideshowbarker
2024-07-18 00:50:31 +09:00
Author: https://github.com/pmhpereira Commit: https://github.com/SerenityOS/serenity/commit/85ae298b85c Pull-request: https://github.com/SerenityOS/serenity/pull/11026
2 changed files with 9 additions and 21 deletions
Userland/Games/FlappyBug
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue