Try to read account's charinfo directory after creating it when the directory was initially nonexistant
This commit is contained in:
parent
dba5e6db69
commit
14c5c0fdeb
1 changed files with 138 additions and 104 deletions
|
@ -854,6 +854,9 @@ static int on_client_charlistreq(t_connection * c, t_packet * packet)
|
|||
packet_set_type(rpacket,D2CS_CLIENT_CHARLISTREPLY);
|
||||
bn_short_set(&rpacket->u.d2cs_client_charlistreply.u1,0);
|
||||
n=0;
|
||||
bool retry = true;
|
||||
while (retry)
|
||||
{
|
||||
try {
|
||||
Directory dir(path);
|
||||
while ((charname = dir.read())) {
|
||||
|
@ -870,7 +873,8 @@ static int on_client_charlistreq(t_connection * c, t_packet * packet)
|
|||
}
|
||||
if (prefs_allow_newchar() && (n < maxchar)) {
|
||||
bn_short_set(&rpacket->u.d2cs_client_charlistreply.maxchar, maxchar);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
bn_short_set(&rpacket->u.d2cs_client_charlistreply.maxchar, 0);
|
||||
}
|
||||
if (!std::strcmp(charlist_sort_order, "ASC"))
|
||||
|
@ -902,9 +906,22 @@ static int on_client_charlistreq(t_connection * c, t_packet * packet)
|
|||
|
||||
}
|
||||
}
|
||||
} catch(const Directory::OpenError&) {
|
||||
INFO1("(*{}) charinfo directory do not exist, building it",account);
|
||||
p_mkdir(path,S_IRWXU);
|
||||
|
||||
retry = false;
|
||||
}
|
||||
catch (const Directory::OpenError&) {
|
||||
ERROR1("(*{}) charinfo directory do not exist, building it", account);
|
||||
if (p_mkdir(path, S_IRWXU) == 0)
|
||||
{
|
||||
INFO1("Successfully created charinfo directory ({})", path);
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR2("Failed to create charinfo directory ({}), errno = {}", path, errno);
|
||||
retry = false;
|
||||
bn_short_set(&rpacket->u.d2cs_client_charlistreply.maxchar, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
bn_short_set(&rpacket->u.d2cs_client_charlistreply.currchar,n);
|
||||
bn_short_set(&rpacket->u.d2cs_client_charlistreply.currchar2,n);
|
||||
|
@ -953,6 +970,9 @@ static int on_client_charlistreq_110(t_connection * c, t_packet * packet)
|
|||
packet_set_type(rpacket,D2CS_CLIENT_CHARLISTREPLY_110);
|
||||
bn_short_set(&rpacket->u.d2cs_client_charlistreply_110.u1,0);
|
||||
n=0;
|
||||
bool retry = true;
|
||||
while (retry)
|
||||
{
|
||||
try {
|
||||
Directory dir(path);
|
||||
|
||||
|
@ -966,7 +986,8 @@ static int on_client_charlistreq_110(t_connection * c, t_packet * packet)
|
|||
}
|
||||
if (exp_time) {
|
||||
curr_exp_time = bn_int_get(charinfo->header.last_time) + exp_time;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
curr_exp_time = 0x7FFFFFFF;
|
||||
}
|
||||
eventlog(eventlog_level_debug, __FUNCTION__, "adding char {} (*{})", charname, account);
|
||||
|
@ -1013,10 +1034,23 @@ static int on_client_charlistreq_110(t_connection * c, t_packet * packet)
|
|||
xfree((void*)ccharlist);
|
||||
}
|
||||
}
|
||||
} catch (const Directory::OpenError&) {
|
||||
INFO1("(*{}) charinfo directory do not exist, building it",account);
|
||||
p_mkdir(path,S_IRWXU);
|
||||
|
||||
retry = false;
|
||||
}
|
||||
catch (const Directory::OpenError&) {
|
||||
ERROR1("(*{}) charinfo directory do not exist, building it", account);
|
||||
if (p_mkdir(path, S_IRWXU) == 0)
|
||||
{
|
||||
INFO1("Successfully created charinfo directory ({})", path);
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR2("Failed to create charinfo directory ({}), errno = {}", path, errno);
|
||||
retry = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bn_short_set(&rpacket->u.d2cs_client_charlistreply.currchar,n);
|
||||
bn_short_set(&rpacket->u.d2cs_client_charlistreply.currchar2,n);
|
||||
bn_short_set(&rpacket->u.d2cs_client_charlistreply.maxchar,maxchar);
|
||||
|
|
Loading…
Reference in a new issue