mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:07:35 +00:00
FlappyBug: Port to LibMain
Simplified two pledge() and two unveil() by using TRY().
This commit is contained in:
parent
ca7b603578
commit
85ae298b85
2 changed files with 9 additions and 21 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue