Skip to content

Commit

Permalink
Replace fake error workaround with proper process kill for System.exit.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rinnegatamante committed Feb 12, 2023
1 parent ef0d902 commit be12f45
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 44 deletions.
6 changes: 2 additions & 4 deletions source/luaSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,10 +696,8 @@ static int lua_exit(lua_State *L) {
if (argc != 0)
return luaL_error(L, "wrong number of arguments");
#endif
char stringbuffer[256];
strcpy(stringbuffer,"lpp_shutdown");
luaL_dostring(L, "collectgarbage()");
return luaL_error(L, stringbuffer); //Fake LUA error
sceKernelExitProcess(0);
return 0;
}

static int lua_wait(lua_State *L) {
Expand Down
77 changes: 37 additions & 40 deletions source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ int main()
// Load main script
SceUID main_file = sceIoOpen("app0:/index.lua", SCE_O_RDONLY, 0777);
if (main_file < 0) errMsg = "index.lua not found.";
else{
else {
SceOff size = sceIoLseek(main_file, 0, SEEK_END);
if (size < 1) errMsg = "Invalid main script.";
else{
else {
sceIoLseek(main_file, 0, SEEK_SET);
script = (unsigned char*)malloc(size + 1);
sceIoRead(main_file, script, size);
Expand All @@ -90,47 +90,44 @@ int main()
}
}

if (errMsg != NULL){
if (strstr(errMsg, "lpp_shutdown")) break;
else{
int restore = 0;
bool s = true;
while (restore == 0){
vita2d_start_drawing();
vita2d_clear_screen();
vita2d_pgf_draw_textf(debug_font, 2, 19.402, RGBA8(255, 255, 255, 255), 1.0, "An error occurred:\n%s\n\nPress X to restart.\nPress O to enable/disable FTP.", errorMex);
if (vita_port != 0) vita2d_pgf_draw_textf(debug_font, 2, 200, RGBA8(255, 255, 255, 255), 1.0, "PSVITA listening on IP %s , Port %u", vita_ip, vita_port);
vita2d_end_drawing();
vita2d_swap_buffers();
sceDisplayWaitVblankStart();
if (s){
sceKernelDelayThread(800000);
s = false;
if (errMsg != NULL) {
int restore = 0;
bool s = true;
while (restore == 0) {
vita2d_start_drawing();
vita2d_clear_screen();
vita2d_pgf_draw_textf(debug_font, 2, 19.402, RGBA8(255, 255, 255, 255), 1.0, "An error occurred:\n%s\n\nPress X to restart.\nPress O to enable/disable FTP.", errorMex);
if (vita_port != 0) vita2d_pgf_draw_textf(debug_font, 2, 200, RGBA8(255, 255, 255, 255), 1.0, "PSVITA listening on IP %s , Port %u", vita_ip, vita_port);
vita2d_end_drawing();
vita2d_swap_buffers();
sceDisplayWaitVblankStart();
if (s) {
sceKernelDelayThread(800000);
s = false;
}
sceCtrlPeekBufferPositive(0, &pad, 1);
if (pad.buttons & SCE_CTRL_CROSS) {
errMsg = NULL;
restore = 1;
if (vita_port != 0) {
ftpvita_fini();
vita_port = 0;
}
sceCtrlPeekBufferPositive(0, &pad, 1);
if (pad.buttons & SCE_CTRL_CROSS) {
errMsg = NULL;
restore = 1;
if (vita_port != 0){
ftpvita_fini();
vita_port = 0;
}
sceKernelDelayThread(800000);
}else if ((pad.buttons & SCE_CTRL_CIRCLE) && (!(oldpad.buttons & SCE_CTRL_CIRCLE))){
if (vita_port == 0){
ftpvita_init(vita_ip, &vita_port);
ftpvita_add_device("app0:");
ftpvita_add_device("ux0:");
ftpvita_add_device("ur0:");
ftpvita_add_device("music0:");
ftpvita_add_device("photo0:");
}else{
ftpvita_fini();
vita_port = 0;
}
sceKernelDelayThread(800000);
} else if ((pad.buttons & SCE_CTRL_CIRCLE) && (!(oldpad.buttons & SCE_CTRL_CIRCLE))) {
if (vita_port == 0){
ftpvita_init(vita_ip, &vita_port);
ftpvita_add_device("app0:");
ftpvita_add_device("ux0:");
ftpvita_add_device("ur0:");
ftpvita_add_device("music0:");
ftpvita_add_device("photo0:");
} else {
ftpvita_fini();
vita_port = 0;
}
oldpad = pad;
}
oldpad = pad;
}
}
}
Expand Down

0 comments on commit be12f45

Please sign in to comment.