Fix bug causing logins to be lost when The Game is closed.
This commit is contained in:
parent
203db57e57
commit
b20e1c5e13
30
src/misc.c
30
src/misc.c
@ -127,19 +127,21 @@ void save_presets(int do_update)
|
|||||||
cJSON_AddStringToObject(root, "Powder Toy Preferences", "Don't modify this file unless you know what you're doing. P.S: editing the admin/mod fields in your user info doesn't give you magical powers");
|
cJSON_AddStringToObject(root, "Powder Toy Preferences", "Don't modify this file unless you know what you're doing. P.S: editing the admin/mod fields in your user info doesn't give you magical powers");
|
||||||
|
|
||||||
//User Info
|
//User Info
|
||||||
cJSON_AddItemToObject(root, "user", userobj=cJSON_CreateObject());
|
if(svf_login){
|
||||||
cJSON_AddStringToObject(userobj, "name", svf_user);
|
cJSON_AddItemToObject(root, "user", userobj=cJSON_CreateObject());
|
||||||
cJSON_AddStringToObject(userobj, "id", svf_user_id);
|
cJSON_AddStringToObject(userobj, "name", svf_user);
|
||||||
cJSON_AddStringToObject(userobj, "session_id", svf_session_id);
|
cJSON_AddStringToObject(userobj, "id", svf_user_id);
|
||||||
if(svf_admin){
|
cJSON_AddStringToObject(userobj, "session_id", svf_session_id);
|
||||||
cJSON_AddTrueToObject(userobj, "admin");
|
if(svf_admin){
|
||||||
cJSON_AddFalseToObject(userobj, "mod");
|
cJSON_AddTrueToObject(userobj, "admin");
|
||||||
} else if(svf_mod){
|
cJSON_AddFalseToObject(userobj, "mod");
|
||||||
cJSON_AddFalseToObject(userobj, "admin");
|
} else if(svf_mod){
|
||||||
cJSON_AddTrueToObject(userobj, "mod");
|
cJSON_AddFalseToObject(userobj, "admin");
|
||||||
} else {
|
cJSON_AddTrueToObject(userobj, "mod");
|
||||||
cJSON_AddFalseToObject(userobj, "admin");
|
} else {
|
||||||
cJSON_AddFalseToObject(userobj, "mod");
|
cJSON_AddFalseToObject(userobj, "admin");
|
||||||
|
cJSON_AddFalseToObject(userobj, "mod");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Version Info
|
//Version Info
|
||||||
@ -219,6 +221,7 @@ void load_presets(void)
|
|||||||
//Read user data
|
//Read user data
|
||||||
userobj = cJSON_GetObjectItem(root, "user");
|
userobj = cJSON_GetObjectItem(root, "user");
|
||||||
if(userobj){
|
if(userobj){
|
||||||
|
svf_login = 1;
|
||||||
if((tmpobj = cJSON_GetObjectItem(userobj, "name")) && tmpobj->type == cJSON_String) strncpy(svf_user, tmpobj->valuestring, 63); else svf_user[0] = 0;
|
if((tmpobj = cJSON_GetObjectItem(userobj, "name")) && tmpobj->type == cJSON_String) strncpy(svf_user, tmpobj->valuestring, 63); else svf_user[0] = 0;
|
||||||
if((tmpobj = cJSON_GetObjectItem(userobj, "id")) && tmpobj->type == cJSON_String) strncpy(svf_user_id, tmpobj->valuestring, 63); else svf_user_id[0] = 0;
|
if((tmpobj = cJSON_GetObjectItem(userobj, "id")) && tmpobj->type == cJSON_String) strncpy(svf_user_id, tmpobj->valuestring, 63); else svf_user_id[0] = 0;
|
||||||
if((tmpobj = cJSON_GetObjectItem(userobj, "session_id")) && tmpobj->type == cJSON_String) strncpy(svf_session_id, tmpobj->valuestring, 63); else svf_session_id[0] = 0;
|
if((tmpobj = cJSON_GetObjectItem(userobj, "session_id")) && tmpobj->type == cJSON_String) strncpy(svf_session_id, tmpobj->valuestring, 63); else svf_session_id[0] = 0;
|
||||||
@ -233,6 +236,7 @@ void load_presets(void)
|
|||||||
svf_mod = 0;
|
svf_mod = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
svf_login = 0;
|
||||||
svf_user[0] = 0;
|
svf_user[0] = 0;
|
||||||
svf_user_id[0] = 0;
|
svf_user_id[0] = 0;
|
||||||
svf_session_id[0] = 0;
|
svf_session_id[0] = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user