Browse files

Fix resume being broken and getting corrupted, fix closed client inst…

…ances spawned by launcher showing as zombie/defunct processes
  • Loading branch information...
UnknownShadow200 committed Dec 31, 2018
1 parent e806d40 commit 5e8a8ddba1aa122f073baa5a06ebfe37e8a2bcf2
Showing with 16 additions and 8 deletions.
  1. +14 −8 src/LScreens.c
  2. +2 −0 src/Platform.c
@@ -658,15 +658,21 @@ static struct MainScreen {

struct ResumeInfo {
String User, Ip, Port, Server, Mppass;
char _mppassBuffer[STRING_SIZE];
char _userBuffer[STRING_SIZE], _serverBuffer[STRING_SIZE];
char _ipBuffer[16], _portBuffer[16], _mppassBuffer[STRING_SIZE];
bool Valid;

CC_NOINLINE static void MainScreen_UNSAFE_GetResume(struct ResumeInfo* info, bool full) {
Options_UNSAFE_Get("launcher-server", &info->Server);
Options_UNSAFE_Get("launcher-username", &info->User);
Options_UNSAFE_Get("launcher-ip", &info->Ip);
Options_UNSAFE_Get("launcher-port", &info->Port);
CC_NOINLINE static void MainScreen_GetResume(struct ResumeInfo* info, bool full) {
String_InitArray(info->Server, info->_serverBuffer);
Options_Get("launcher-server", &info->Server, NULL);
String_InitArray(info->User, info->_userBuffer);
Options_Get("launcher-username", &info->User, NULL);

String_InitArray(info->Ip, info->_ipBuffer);
Options_Get("launcher-ip", &info->Ip, NULL);
String_InitArray(info->Port, info->_portBuffer);
Options_Get("launcher-port", &info->Port, NULL);

if (!full) return;
String_InitArray(info->Mppass, info->_mppassBuffer);
@@ -723,7 +729,7 @@ static void MainScreen_Login(void* w, int x, int y) {

static void MainScreen_Resume(void* w, int x, int y) {
struct ResumeInfo info;
MainScreen_UNSAFE_GetResume(&info, true);
MainScreen_GetResume(&info, true);

if (!info.Valid) return;
Launcher_StartGame(&info.User, &info.Mppass, &info.Ip, &info.Port, &info.Server);
@@ -800,7 +806,7 @@ static void MainScreen_HoverWidget(struct LScreen* s_, struct LWidget* w) {
struct ResumeInfo info;
if (s->SigningIn || w != (struct LWidget*)&s->BtnResume) return;

MainScreen_UNSAFE_GetResume(&info, false);
MainScreen_GetResume(&info, false);
if (!info.User.length) return;
String_InitArray(str, strBuffer);

@@ -72,6 +72,7 @@ const ReturnCode ReturnCode_SocketWouldBlock = WSAEWOULDBLOCK;
#include <sys/stat.h>
#include <utime.h>
#include <poll.h>
#include <signal.h>

#define Socket__Error() errno
char* Platform_NewLine = "\n";
@@ -1911,6 +1912,7 @@ int Platform_ConvertString(void* data, const String* src) {

void Platform_Init(void) {
pthread_mutex_init(&event_mutex, NULL);

0 comments on commit 5e8a8dd

Please sign in to comment.