feat(servei): reinici real via execv

This commit is contained in:
JailDesigner committed 2026-05-25 17:29:42 +02:00
1 parent 774874deb0
commit a8ccb3fae1
5 files changed
+97 -11

No files matched your search

+9 -9
View File
@@ -15,6 +15,7 @@
#include "core/rendering/screen.hpp"
#include "core/rendering/text.hpp"
#include "core/system/event_buffer.hpp"
#include "core/system/relaunch.hpp"
#include "core/ui/ui_config.hpp"
#include "game/gameplay_config.hpp"
#include "game/options.hpp"
@@ -1228,18 +1229,17 @@ auto ServiceMenu::buildSystem() -> Page {
page.items.push_back(makeLabel(
std::string("ver.") + Texts::VERSION + " (" + Version::GIT_HASH + ")"));
// Reiniciar el joc: tornem al LOGO amb `reset=true` perquè LogoScene
// ature música i sons abans de mostrar-se. Tanquem el menú a la
// mateixa acció — Director recollirà la transició al final del frame
// via `takePendingSceneRequest()` i reconstruirà l'escena.
// Reinici real del procés: marquem el flag i empenyem QUIT. SDL_AppQuit
// destruirà tots els subsistemes i llavors farà execv (al final, amb tot
// net) per substituir el binari per ell mateix. Si execv falla, el procés
// surt amb error.
page.items.push_back(makeAction(
"menu.items.restart",
[]() {
ServiceMenu::get().requestSceneTransition(ExitRequest{
.next = SceneId::LOGO,
.params = LogoParams{.reset = true},
});
ServiceMenu::get().close();
System::Relaunch::request();
SDL_Event quit_event{};
quit_event.type = SDL_EVENT_QUIT;
EventBuffer::events.push_back(quit_event);
}));
page.items.push_back(makeAction(