mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-21 02:08:12 +03:00
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
@ -10,4 +10,4 @@ set(SOURCES
|
|||||||
)
|
)
|
||||||
|
|
||||||
serenity_app(FlappyBug ICON app-flappybug)
|
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/Menubar.h>
|
||||||
#include <LibGUI/MessageBox.h>
|
#include <LibGUI/MessageBox.h>
|
||||||
#include <LibGUI/Window.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) {
|
TRY(System::pledge("stdio rpath recvfd sendfd unix", nullptr));
|
||||||
perror("pledge");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto app = GUI::Application::construct(argc, argv);
|
auto app = GUI::Application::construct(arguments.argc, arguments.argv);
|
||||||
|
|
||||||
Config::pledge_domains("FlappyBug");
|
Config::pledge_domains("FlappyBug");
|
||||||
|
|
||||||
if (pledge("stdio rpath recvfd sendfd", nullptr) < 0) {
|
TRY(System::pledge("stdio rpath recvfd sendfd", nullptr));
|
||||||
perror("pledge");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (unveil("/res", "r") < 0) {
|
TRY(System::unveil("/res", "r"));
|
||||||
perror("unveil");
|
TRY(System::unveil(nullptr, nullptr));
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (unveil(nullptr, nullptr) < 0) {
|
|
||||||
perror("unveil");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 high_score = Config::read_i32("FlappyBug", "Game", "HighScore", 0);
|
u32 high_score = Config::read_i32("FlappyBug", "Game", "HighScore", 0);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user