summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/admin/ladmin.cpp441
-rw-r--r--src/char/char.cpp1101
-rw-r--r--src/char/char.hpp8
-rw-r--r--src/char/int_party.cpp188
-rw-r--r--src/char/int_party.hpp4
-rw-r--r--src/char/int_storage.cpp50
-rw-r--r--src/char/int_storage.hpp4
-rw-r--r--src/char/inter.cpp214
-rw-r--r--src/char/inter.hpp6
-rw-r--r--src/common/socket.cpp197
-rw-r--r--src/common/socket.hpp120
-rw-r--r--src/login/login.cpp1021
-rw-r--r--src/map/atcommand.cpp1106
-rw-r--r--src/map/atcommand.hpp2
-rw-r--r--src/map/chrif.cpp441
-rw-r--r--src/map/chrif.hpp2
-rw-r--r--src/map/clif.cpp1646
-rw-r--r--src/map/clif.hpp18
-rw-r--r--src/map/intif.cpp364
-rw-r--r--src/map/intif.hpp2
-rw-r--r--src/map/magic-stmt.cpp6
-rw-r--r--src/map/map.cpp6
-rw-r--r--src/map/map.hpp4
-rw-r--r--src/map/party.cpp8
-rw-r--r--src/map/pc.cpp30
-rw-r--r--src/map/pc.hpp4
-rw-r--r--src/map/script.cpp4
-rw-r--r--src/map/tmw.cpp8
28 files changed, 3499 insertions, 3506 deletions
diff --git a/src/admin/ladmin.cpp b/src/admin/ladmin.cpp
index ff83530..6b49f35 100644
--- a/src/admin/ladmin.cpp
+++ b/src/admin/ladmin.cpp
@@ -229,7 +229,7 @@ FString ladmin_log_filename = "log/ladmin.log";
//
//-------------------------------------------------------------------------
static
-int login_fd;
+Session *login_session;
static
int bytes_to_read = 0; // flag to know if we waiting bytes from login-server
static
@@ -689,12 +689,12 @@ void addaccount(ZString param, int emailflag)
LADMIN_LOG("Request to login-server to create an account.\n");
- WFIFOW(login_fd, 0) = 0x7930;
- WFIFO_STRING(login_fd, 2, name, 24);
- WFIFO_STRING(login_fd, 26, password, 24);
- WFIFOB(login_fd, 50) = sex;
- WFIFO_STRING(login_fd, 51, email, 40);
- WFIFOSET(login_fd, 91);
+ WFIFOW(login_session, 0) = 0x7930;
+ WFIFO_STRING(login_session, 2, name, 24);
+ WFIFO_STRING(login_session, 26, password, 24);
+ WFIFOB(login_session, 50) = sex;
+ WFIFO_STRING(login_session, 51, email, 40);
+ WFIFOSET(login_session, 91);
bytes_to_read = 1;
}
@@ -739,10 +739,10 @@ void banaddaccount(ZString param)
LADMIN_LOG("Request to login-server to modify a ban date/time.\n");
- WFIFOW(login_fd, 0) = 0x794c;
- WFIFO_STRING(login_fd, 2, name, 24);
- WFIFO_STRUCT(login_fd, 26, modif);
- WFIFOSET(login_fd, 38);
+ WFIFOW(login_session, 0) = 0x794c;
+ WFIFO_STRING(login_session, 2, name, 24);
+ WFIFO_STRUCT(login_session, 26, modif);
+ WFIFOSET(login_session, 38);
bytes_to_read = 1;
}
@@ -848,10 +848,10 @@ void bansetaccountsub(AccountName name, XString date, XString time_)
LADMIN_LOG("Request to login-server to set a ban.\n");
- WFIFOW(login_fd, 0) = 0x794a;
- WFIFO_STRING(login_fd, 2, name, 24);
- WFIFOL(login_fd, 26) = static_cast<time_t>(ban_until_time);
- WFIFOSET(login_fd, 30);
+ WFIFOW(login_session, 0) = 0x794a;
+ WFIFO_STRING(login_session, 2, name, 24);
+ WFIFOL(login_session, 26) = static_cast<time_t>(ban_until_time);
+ WFIFOSET(login_session, 30);
bytes_to_read = 1;
}
@@ -961,10 +961,10 @@ void checkaccount(ZString param)
LADMIN_LOG("Request to login-server to check a password.\n");
- WFIFOW(login_fd, 0) = 0x793a;
- WFIFO_STRING(login_fd, 2, name, 24);
- WFIFO_STRING(login_fd, 26, password, 24);
- WFIFOSET(login_fd, 50);
+ WFIFOW(login_session, 0) = 0x793a;
+ WFIFO_STRING(login_session, 2, name, 24);
+ WFIFO_STRING(login_session, 26, password, 24);
+ WFIFOSET(login_session, 50);
bytes_to_read = 1;
}
@@ -1011,9 +1011,9 @@ void delaccount(ZString param)
LADMIN_LOG("Request to login-server to delete an acount.\n");
- WFIFOW(login_fd, 0) = 0x7932;
- WFIFO_STRING(login_fd, 2, name, 24);
- WFIFOSET(login_fd, 26);
+ WFIFOW(login_session, 0) = 0x7932;
+ WFIFO_STRING(login_session, 2, name, 24);
+ WFIFOSET(login_session, 26);
bytes_to_read = 1;
}
@@ -1048,10 +1048,10 @@ void changeemail(ZString param)
LADMIN_LOG("Request to login-server to change an email.\n");
- WFIFOW(login_fd, 0) = 0x7940;
- WFIFO_STRING(login_fd, 2, name, 24);
- WFIFO_STRING(login_fd, 26, email, 40);
- WFIFOSET(login_fd, 66);
+ WFIFOW(login_session, 0) = 0x7940;
+ WFIFO_STRING(login_session, 2, name, 24);
+ WFIFO_STRING(login_session, 26, email, 40);
+ WFIFOSET(login_session, 66);
bytes_to_read = 1;
}
@@ -1063,8 +1063,8 @@ void getlogincount(void)
{
LADMIN_LOG("Request to login-server to obtain the # of online players.\n");
- WFIFOW(login_fd, 0) = 0x7938;
- WFIFOSET(login_fd, 2);
+ WFIFOW(login_session, 0) = 0x7938;
+ WFIFOSET(login_session, 2);
bytes_to_read = 1;
}
@@ -1099,10 +1099,10 @@ void changegmlevel(ZString param)
LADMIN_LOG("Request to login-server to change a GM level.\n");
- WFIFOW(login_fd, 0) = 0x793e;
- WFIFO_STRING(login_fd, 2, name, 24);
- WFIFOB(login_fd, 26) = GM_level;
- WFIFOSET(login_fd, 27);
+ WFIFOW(login_session, 0) = 0x793e;
+ WFIFO_STRING(login_session, 2, name, 24);
+ WFIFOB(login_session, 26) = GM_level;
+ WFIFOSET(login_session, 27);
bytes_to_read = 1;
}
@@ -1129,9 +1129,9 @@ void idaccount(ZString param)
LADMIN_LOG("Request to login-server to know an account id.\n");
- WFIFOW(login_fd, 0) = 0x7944;
- WFIFO_STRING(login_fd, 2, name, 24);
- WFIFOSET(login_fd, 26);
+ WFIFOW(login_session, 0) = 0x7944;
+ WFIFO_STRING(login_session, 2, name, 24);
+ WFIFOSET(login_session, 26);
bytes_to_read = 1;
}
@@ -1150,9 +1150,9 @@ void infoaccount(int account_id)
LADMIN_LOG("Request to login-server to obtain information about an account (by its id).\n");
- WFIFOW(login_fd, 0) = 0x7954;
- WFIFOL(login_fd, 2) = account_id;
- WFIFOSET(login_fd, 6);
+ WFIFOW(login_session, 0) = 0x7954;
+ WFIFOL(login_session, 2) = account_id;
+ WFIFOSET(login_session, 6);
bytes_to_read = 1;
}
@@ -1172,12 +1172,12 @@ void sendbroadcast(ZString message)
return;
}
- WFIFOW(login_fd, 0) = 0x794e;
- WFIFOW(login_fd, 2) = 0;
+ WFIFOW(login_session, 0) = 0x794e;
+ WFIFOW(login_session, 2) = 0;
size_t len = message.size() + 1;
- WFIFOL(login_fd, 4) = len;
- WFIFO_STRING(login_fd, 8, message, len);
- WFIFOSET(login_fd, 8 + len);
+ WFIFOL(login_session, 4) = len;
+ WFIFO_STRING(login_session, 8, message, len);
+ WFIFOSET(login_session, 8 + len);
bytes_to_read = 1;
}
@@ -1224,10 +1224,10 @@ void listaccount(ZString param, int type)
LADMIN_LOG("Request to login-server to obtain the list of accounts from %d to %d.\n",
list_first, list_last);
- WFIFOW(login_fd, 0) = 0x7920;
- WFIFOL(login_fd, 2) = list_first;
- WFIFOL(login_fd, 6) = list_last;
- WFIFOSET(login_fd, 10);
+ WFIFOW(login_session, 0) = 0x7920;
+ WFIFOL(login_session, 2) = list_first;
+ WFIFOL(login_session, 6) = list_last;
+ WFIFOSET(login_session, 10);
bytes_to_read = 1;
// 0123456789 01 01234567890123456789012301234 012345 0123456789012345678901234567
@@ -1250,10 +1250,10 @@ int itemfrob(ZString param)
return 1;
}
- WFIFOW(login_fd, 0) = 0x7924;
- WFIFOL(login_fd, 2) = source_id;
- WFIFOL(login_fd, 6) = dest_id;
- WFIFOSET(login_fd, 10);
+ WFIFOW(login_session, 0) = 0x7924;
+ WFIFOL(login_session, 2) = source_id;
+ WFIFOL(login_session, 6) = dest_id;
+ WFIFOSET(login_session, 10);
bytes_to_read = 1; // all logging is done to the three main servers
return 0;
@@ -1292,11 +1292,11 @@ void changememo(ZString param)
LADMIN_LOG("Request to login-server to change a memo.\n");
- WFIFOW(login_fd, 0) = 0x7942;
- WFIFO_STRING(login_fd, 2, name, 24);
- WFIFOW(login_fd, 26) = len1;
- WFIFO_STRING(login_fd, 28, memo, len);
- WFIFOSET(login_fd, 28 + len1);
+ WFIFOW(login_session, 0) = 0x7942;
+ WFIFO_STRING(login_session, 2, name, 24);
+ WFIFOW(login_session, 26) = len1;
+ WFIFO_STRING(login_session, 28, memo, len);
+ WFIFOSET(login_session, 28 + len1);
bytes_to_read = 1;
}
@@ -1315,9 +1315,9 @@ void nameaccount(int id)
LADMIN_LOG("Request to login-server to know an account name.\n");
- WFIFOW(login_fd, 0) = 0x7946;
- WFIFOL(login_fd, 2) = id;
- WFIFOSET(login_fd, 6);
+ WFIFOW(login_session, 0) = 0x7946;
+ WFIFOL(login_session, 2) = id;
+ WFIFOSET(login_session, 6);
bytes_to_read = 1;
}
@@ -1349,10 +1349,10 @@ void changepasswd(ZString param)
LADMIN_LOG("Request to login-server to change a password.\n");
- WFIFOW(login_fd, 0) = 0x7934;
- WFIFO_STRING(login_fd, 2, name, 24);
- WFIFO_STRING(login_fd, 26, password, 24);
- WFIFOSET(login_fd, 50);
+ WFIFOW(login_session, 0) = 0x7934;
+ WFIFO_STRING(login_session, 2, name, 24);
+ WFIFO_STRING(login_session, 26, password, 24);
+ WFIFOSET(login_session, 50);
bytes_to_read = 1;
}
@@ -1363,8 +1363,8 @@ void changepasswd(ZString param)
static
void reloadGM(ZString params)
{
- WFIFOW(login_fd, 0) = 0x7955;
- WFIFOSET(login_fd, 2);
+ WFIFOW(login_session, 0) = 0x7955;
+ WFIFOSET(login_session, 2);
bytes_to_read = 0;
LADMIN_LOG("Request to reload the GM configuration file sended.\n");
@@ -1406,10 +1406,10 @@ void changesex(ZString param)
LADMIN_LOG("Request to login-server to change a sex.\n");
- WFIFOW(login_fd, 0) = 0x793c;
- WFIFO_STRING(login_fd, 2, name, 24);
- WFIFOB(login_fd, 26) = sex;
- WFIFOSET(login_fd, 27);
+ WFIFOW(login_session, 0) = 0x793c;
+ WFIFO_STRING(login_session, 2, name, 24);
+ WFIFOB(login_session, 26) = sex;
+ WFIFOSET(login_session, 27);
bytes_to_read = 1;
}
@@ -1462,11 +1462,11 @@ void changestatesub(AccountName name, int state, XString error_message)
LADMIN_LOG("Request to login-server to change a state.\n");
- WFIFOW(login_fd, 0) = 0x7936;
- WFIFO_STRING(login_fd, 2, name, 24);
- WFIFOL(login_fd, 26) = state;
- WFIFO_STRING(login_fd, 30, error_message, 20);
- WFIFOSET(login_fd, 50);
+ WFIFOW(login_session, 0) = 0x7936;
+ WFIFO_STRING(login_session, 2, name, 24);
+ WFIFOL(login_session, 26) = state;
+ WFIFO_STRING(login_session, 30, error_message, 20);
+ WFIFOSET(login_session, 50);
bytes_to_read = 1;
}
@@ -1581,10 +1581,10 @@ void timeaddaccount(ZString param)
LADMIN_LOG("Request to login-server to modify a time limit.\n");
- WFIFOW(login_fd, 0) = 0x7950;
- WFIFO_STRING(login_fd, 2, name, 24);
- WFIFO_STRUCT(login_fd, 26, modif);
- WFIFOSET(login_fd, 38);
+ WFIFOW(login_session, 0) = 0x7950;
+ WFIFO_STRING(login_session, 2, name, 24);
+ WFIFO_STRUCT(login_session, 26, modif);
+ WFIFOSET(login_session, 38);
bytes_to_read = 1;
}
@@ -1704,10 +1704,10 @@ void timesetaccount(ZString param)
LADMIN_LOG("Request to login-server to set a time limit.\n");
- WFIFOW(login_fd, 0) = 0x7948;
- WFIFO_STRING(login_fd, 2, name, 24);
- WFIFOL(login_fd, 26) = static_cast<time_t>(connect_until_time);
- WFIFOSET(login_fd, 30);
+ WFIFOW(login_session, 0) = 0x7948;
+ WFIFO_STRING(login_session, 2, name, 24);
+ WFIFOL(login_session, 26) = static_cast<time_t>(connect_until_time);
+ WFIFOSET(login_session, 30);
bytes_to_read = 1;
}
@@ -1733,9 +1733,9 @@ void whoaccount(ZString param)
LADMIN_LOG("Request to login-server to obtain information about an account (by its name).\n");
- WFIFOW(login_fd, 0) = 0x7952;
- WFIFO_STRING(login_fd, 2, name, 24);
- WFIFOSET(login_fd, 26);
+ WFIFOW(login_session, 0) = 0x7952;
+ WFIFO_STRING(login_session, 2, name, 24);
+ WFIFOSET(login_session, 26);
bytes_to_read = 1;
}
@@ -1747,8 +1747,8 @@ void checkloginversion(void)
{
LADMIN_LOG("Request to login-server to obtain its version.\n");
- WFIFOW(login_fd, 0) = 0x7530;
- WFIFOSET(login_fd, 2);
+ WFIFOW(login_session, 0) = 0x7530;
+ WFIFOSET(login_session, 2);
bytes_to_read = 1;
}
@@ -1922,35 +1922,35 @@ void prompt(void)
// Function: Parse receiving informations from the login-server
//-------------------------------------------------------------
static
-void parse_fromlogin(int fd)
+void parse_fromlogin(Session *s)
{
- if (session[fd]->eof)
+ if (s->eof)
{
PRINTF("Impossible to have a connection with the login-server [%s:%d] !\n",
login_ip, login_port);
LADMIN_LOG("Impossible to have a connection with the login-server [%s:%d] !\n",
login_ip, login_port);
- delete_session(fd);
+ delete_session(s);
exit(0);
}
// PRINTF("parse_fromlogin : %d %d %d\n", fd, RFIFOREST(fd), RFIFOW(fd,0));
- while (RFIFOREST(fd) >= 2)
+ while (RFIFOREST(s) >= 2)
{
- switch (RFIFOW(fd, 0))
+ switch (RFIFOW(s, 0))
{
case 0x7919: // answer of a connection request
- if (RFIFOREST(fd) < 3)
+ if (RFIFOREST(s) < 3)
return;
- if (RFIFOB(fd, 2) != 0)
+ if (RFIFOB(s, 2) != 0)
{
PRINTF("Error at login:\n");
PRINTF(" - incorrect password,\n");
PRINTF(" - administration system not activated, or\n");
PRINTF(" - unauthorised IP.\n");
LADMIN_LOG("Error at login: incorrect password, administration system not activated, or unauthorised IP.\n");
- session[fd]->eof = 1;
+ s->eof = 1;
//bytes_to_read = 1; // not stop at prompt
}
else
@@ -1962,17 +1962,17 @@ void parse_fromlogin(int fd)
//bytes_to_read = 1; // unchanged
checkloginversion();
}
- RFIFOSKIP(fd, 3);
+ RFIFOSKIP(s, 3);
break;
case 0x7531: // Displaying of the version of the login-server
- if (RFIFOREST(fd) < 10)
+ if (RFIFOREST(s) < 10)
return;
{
Iprintf(" Login-Server [%s:%d]\n",
login_ip, login_port);
Version version;
- RFIFO_STRUCT(login_fd, 2, version);
+ RFIFO_STRUCT(login_session, 2, version);
Iprintf(" tmwA version %hhu.%hhu.%hhu (dev? %hhu) (flags %hhx) (which %hhx) (vend %hu)\n",
version.major, version.minor, version.patch,
version.devel,
@@ -1981,18 +1981,18 @@ void parse_fromlogin(int fd)
version.vend);
}
bytes_to_read = 0;
- RFIFOSKIP(fd, 10);
+ RFIFOSKIP(s, 10);
break;
case 0x7925: // Itemfrob-OK
- RFIFOSKIP(fd, 2);
+ RFIFOSKIP(s, 2);
bytes_to_read = 0;
break;
case 0x7921: // Displaying of the list of accounts
- if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd, 2))
+ if (RFIFOREST(s) < 4 || RFIFOREST(s) < RFIFOW(s, 2))
return;
- if (RFIFOW(fd, 2) < 5)
+ if (RFIFOW(s, 2) < 5)
{
LADMIN_LOG(" Receiving of a void accounts list.\n");
if (list_count == 0)
@@ -2011,32 +2011,32 @@ void parse_fromlogin(int fd)
{
int i;
LADMIN_LOG(" Receiving of a accounts list.\n");
- for (i = 4; i < RFIFOW(fd, 2); i += 38)
+ for (i = 4; i < RFIFOW(s, 2); i += 38)
{
- AccountName userid = stringish<AccountName>(RFIFO_STRING<24>(fd, i + 5));
+ AccountName userid = stringish<AccountName>(RFIFO_STRING<24>(s, i + 5));
VString<23> lower_userid = userid.to_lower();
- list_first = RFIFOL(fd, i) + 1;
+ list_first = RFIFOL(s, i) + 1;
// here are checks...
if (list_type == 0
- || (list_type == 1 && RFIFOB(fd, i + 4) > 0)
+ || (list_type == 1 && RFIFOB(s, i + 4) > 0)
|| (list_type == 2 && lower_userid.contains_seq(parameters))
- || (list_type == 3 && RFIFOL(fd, i + 34) != 0)
- || (list_type == 4 && RFIFOL(fd, i + 34) == 0))
+ || (list_type == 3 && RFIFOL(s, i + 34) != 0)
+ || (list_type == 4 && RFIFOL(s, i + 34) == 0))
{
- PRINTF("%10d ", RFIFOL(fd, i));
- if (RFIFOB(fd, i + 4) == 0)
+ PRINTF("%10d ", RFIFOL(s, i));
+ if (RFIFOB(s, i + 4) == 0)
PRINTF(" ");
else
- PRINTF("%2d ", RFIFOB(fd, i + 4));
+ PRINTF("%2d ", RFIFOB(s, i + 4));
PRINTF("%-24s", userid);
- if (RFIFOB(fd, i + 29) == 0)
+ if (RFIFOB(s, i + 29) == 0)
PRINTF("%-5s ", "Femal");
- else if (RFIFOB(fd, i + 29) == 1)
+ else if (RFIFOB(s, i + 29) == 1)
PRINTF("%-5s ", "Male");
else
PRINTF("%-5s ", "Servr");
- PRINTF("%6d ", RFIFOL(fd, i + 30));
- switch (RFIFOL(fd, i + 34))
+ PRINTF("%6d ", RFIFOL(s, i + 30));
+ switch (RFIFOL(s, i + 34))
{
case 0:
PRINTF("%-27s\n", "Account OK");
@@ -2081,21 +2081,21 @@ void parse_fromlogin(int fd)
// asking of the following acounts
LADMIN_LOG("Request to login-server to obtain the list of accounts from %d to %d (complement).\n",
list_first, list_last);
- WFIFOW(login_fd, 0) = 0x7920;
- WFIFOL(login_fd, 2) = list_first;
- WFIFOL(login_fd, 6) = list_last;
- WFIFOSET(login_fd, 10);
+ WFIFOW(login_session, 0) = 0x7920;
+ WFIFOL(login_session, 2) = list_first;
+ WFIFOL(login_session, 6) = list_last;
+ WFIFOSET(login_session, 10);
bytes_to_read = 1;
}
- RFIFOSKIP(fd, RFIFOW(fd, 2));
+ RFIFOSKIP(s, RFIFOW(s, 2));
break;
case 0x7931: // Answer of login-server about an account creation
- if (RFIFOREST(fd) < 30)
+ if (RFIFOREST(s) < 30)
return;
{
- int accid = RFIFOL(fd, 2);
- AccountName name = stringish<AccountName>(RFIFO_STRING<24>(fd, 6));
+ int accid = RFIFOL(s, 2);
+ AccountName name = stringish<AccountName>(RFIFO_STRING<24>(s, 6));
if (accid == -1)
{
PRINTF("Account [%s] creation failed. Same account already exists.\n",
@@ -2112,15 +2112,15 @@ void parse_fromlogin(int fd)
}
bytes_to_read = 0;
}
- RFIFOSKIP(fd, 30);
+ RFIFOSKIP(s, 30);
break;
case 0x7933: // Answer of login-server about an account deletion
- if (RFIFOREST(fd) < 30)
+ if (RFIFOREST(s) < 30)
return;
{
- int accid = RFIFOL(fd, 2);
- AccountName name = stringish<AccountName>(RFIFO_STRING<24>(fd, 6));
+ int accid = RFIFOL(s, 2);
+ AccountName name = stringish<AccountName>(RFIFO_STRING<24>(s, 6));
if (accid == -1)
{
PRINTF("Account [%s] deletion failed. Account doesn't exist.\n",
@@ -2137,15 +2137,15 @@ void parse_fromlogin(int fd)
}
bytes_to_read = 0;
}
- RFIFOSKIP(fd, 30);
+ RFIFOSKIP(s, 30);
break;
case 0x7935: // answer of the change of an account password
- if (RFIFOREST(fd) < 30)
+ if (RFIFOREST(s) < 30)
return;
{
- int accid = RFIFOL(fd, 2);
- AccountName name = stringish<AccountName>(RFIFO_STRING<24>(fd, 6));
+ int accid = RFIFOL(s, 2);
+ AccountName name = stringish<AccountName>(RFIFO_STRING<24>(s, 6));
if (accid == -1)
{
PRINTF("Account [%s] password changing failed.\n",
@@ -2164,16 +2164,16 @@ void parse_fromlogin(int fd)
}
bytes_to_read = 0;
}
- RFIFOSKIP(fd, 30);
+ RFIFOSKIP(s, 30);
break;
case 0x7937: // answer of the change of an account state
- if (RFIFOREST(fd) < 34)
+ if (RFIFOREST(s) < 34)
return;
{
- int accid = RFIFOL(fd, 2);
- AccountName name = stringish<AccountName>(RFIFO_STRING<24>(fd, 6));
- int state = RFIFOL(fd, 30);
+ int accid = RFIFOL(s, 2);
+ AccountName name = stringish<AccountName>(RFIFO_STRING<24>(s, 6));
+ int state = RFIFOL(s, 30);
if (accid == -1)
{
PRINTF("Account [%s] state changing failed. Account doesn't exist.\n",
@@ -2230,17 +2230,17 @@ void parse_fromlogin(int fd)
}
bytes_to_read = 0;
}
- RFIFOSKIP(fd, 34);
+ RFIFOSKIP(s, 34);
break;
case 0x7939: // answer of the number of online players
- if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd, 2))
+ if (RFIFOREST(s) < 4 || RFIFOREST(s) < RFIFOW(s, 2))
return;
{
// Get length of the received packet
LADMIN_LOG(" Receiving of the number of online players.\n");
// Read information of the servers
- if (RFIFOW(fd, 2) < 5)
+ if (RFIFOW(s, 2) < 5)
{
PRINTF(" No server is connected to the login-server.\n");
}
@@ -2248,24 +2248,24 @@ void parse_fromlogin(int fd)
{
PRINTF(" Number of online players (server: number).\n");
// Displaying of result
- for (int i = 4; i < RFIFOW(fd, 2); i += 32)
+ for (int i = 4; i < RFIFOW(s, 2); i += 32)
{
- ServerName name = stringish<ServerName>(RFIFO_STRING<20>(fd, i + 6));
+ ServerName name = stringish<ServerName>(RFIFO_STRING<20>(s, i + 6));
PRINTF(" %-20s : %5d\n", name,
- RFIFOW(fd, i + 26));
+ RFIFOW(s, i + 26));
}
}
}
bytes_to_read = 0;
- RFIFOSKIP(fd, RFIFOW(fd, 2));
+ RFIFOSKIP(s, RFIFOW(s, 2));
break;
case 0x793b: // answer of the check of a password
- if (RFIFOREST(fd) < 30)
+ if (RFIFOREST(s) < 30)
return;
{
- int account_id = RFIFOL(fd, 2);
- AccountName name = stringish<AccountName>(RFIFO_STRING<24>(fd, 6));
+ int account_id = RFIFOL(s, 2);
+ AccountName name = stringish<AccountName>(RFIFO_STRING<24>(s, 6));
if (account_id == -1)
{
PRINTF("The account [%s] doesn't exist or the password is incorrect.\n",
@@ -2282,15 +2282,15 @@ void parse_fromlogin(int fd)
}
bytes_to_read = 0;
}
- RFIFOSKIP(fd, 30);
+ RFIFOSKIP(s, 30);
break;
case 0x793d: // answer of the change of an account sex
- if (RFIFOREST(fd) < 30)
+ if (RFIFOREST(s) < 30)
return;
{
- int account_id = RFIFOL(fd, 2);
- AccountName name = stringish<AccountName>(RFIFO_STRING<24>(fd, 6));
+ int account_id = RFIFOL(s, 2);
+ AccountName name = stringish<AccountName>(RFIFO_STRING<24>(s, 6));
if (account_id == -1)
{
PRINTF("Account [%s] sex changing failed.\n",
@@ -2309,15 +2309,15 @@ void parse_fromlogin(int fd)
}
bytes_to_read = 0;
}
- RFIFOSKIP(fd, 30);
+ RFIFOSKIP(s, 30);
break;
case 0x793f: // answer of the change of an account GM level
- if (RFIFOREST(fd) < 30)
+ if (RFIFOREST(s) < 30)
return;
{
- int account_id = RFIFOL(fd, 2);
- AccountName name = stringish<AccountName>(RFIFO_STRING<24>(fd, 6));
+ int account_id = RFIFOL(s, 2);
+ AccountName name = stringish<AccountName>(RFIFO_STRING<24>(s, 6));
if (account_id == -1)
{
PRINTF("Account [%s] GM level changing failed.\n",
@@ -2337,15 +2337,15 @@ void parse_fromlogin(int fd)
}
bytes_to_read = 0;
}
- RFIFOSKIP(fd, 30);
+ RFIFOSKIP(s, 30);
break;
case 0x7941: // answer of the change of an account email
- if (RFIFOREST(fd) < 30)
+ if (RFIFOREST(s) < 30)
return;
{
- int account_id = RFIFOL(fd, 2);
- AccountName name = stringish<AccountName>(RFIFO_STRING<24>(fd, 6));
+ int account_id = RFIFOL(s, 2);
+ AccountName name = stringish<AccountName>(RFIFO_STRING<24>(s, 6));
if (account_id == -1)
{
PRINTF("Account [%s] e-mail changing failed.\n",
@@ -2364,15 +2364,15 @@ void parse_fromlogin(int fd)
}
bytes_to_read = 0;
}
- RFIFOSKIP(fd, 30);
+ RFIFOSKIP(s, 30);
break;
case 0x7943: // answer of the change of an account memo
- if (RFIFOREST(fd) < 30)
+ if (RFIFOREST(s) < 30)
return;
{
- int account_id = RFIFOL(fd, 2);
- AccountName name = stringish<AccountName>(RFIFO_STRING<24>(fd, 6));
+ int account_id = RFIFOL(s, 2);
+ AccountName name = stringish<AccountName>(RFIFO_STRING<24>(s, 6));
if (account_id == -1)
{
PRINTF("Account [%s] memo changing failed. Account doesn't exist.\n",
@@ -2389,15 +2389,15 @@ void parse_fromlogin(int fd)
}
bytes_to_read = 0;
}
- RFIFOSKIP(fd, 30);
+ RFIFOSKIP(s, 30);
break;
case 0x7945: // answer of an account id search
- if (RFIFOREST(fd) < 30)
+ if (RFIFOREST(s) < 30)
return;
{
- int account_id = RFIFOL(fd, 2);
- AccountName name = stringish<AccountName>(RFIFO_STRING<24>(fd, 6));
+ int account_id = RFIFOL(s, 2);
+ AccountName name = stringish<AccountName>(RFIFO_STRING<24>(s, 6));
if (account_id == -1)
{
PRINTF("Unable to find the account [%s] id. Account doesn't exist.\n",
@@ -2414,15 +2414,15 @@ void parse_fromlogin(int fd)
}
bytes_to_read = 0;
}
- RFIFOSKIP(fd, 30);
+ RFIFOSKIP(s, 30);
break;
case 0x7947: // answer of an account name search
- if (RFIFOREST(fd) < 30)
+ if (RFIFOREST(s) < 30)
return;
{
- int account_id = RFIFOL(fd, 2);
- AccountName name = stringish<AccountName>(RFIFO_STRING<24>(fd, 6));
+ int account_id = RFIFOL(s, 2);
+ AccountName name = stringish<AccountName>(RFIFO_STRING<24>(s, 6));
if (!name)
{
PRINTF("Unable to find the account [%d] name. Account doesn't exist.\n",
@@ -2439,16 +2439,16 @@ void parse_fromlogin(int fd)
}
bytes_to_read = 0;
}
- RFIFOSKIP(fd, 30);
+ RFIFOSKIP(s, 30);
break;
case 0x7949: // answer of an account validity limit set
- if (RFIFOREST(fd) < 34)
+ if (RFIFOREST(s) < 34)
return;
{
- int account_id = RFIFOL(fd, 2);
- AccountName name = stringish<AccountName>(RFIFO_STRING<24>(fd, 6));
- if (RFIFOL(fd, 2) == -1)
+ int account_id = RFIFOL(s, 2);
+ AccountName name = stringish<AccountName>(RFIFO_STRING<24>(s, 6));
+ if (RFIFOL(s, 2) == -1)
{
PRINTF("Account [%s] validity limit changing failed. Account doesn't exist.\n",
name);
@@ -2457,7 +2457,7 @@ void parse_fromlogin(int fd)
}
else
{
- TimeT timestamp = static_cast<time_t>(RFIFOL(fd, 30));
+ TimeT timestamp = static_cast<time_t>(RFIFOL(s, 30));
if (!timestamp)
{
PRINTF("Validity Limit of the account [%s][id: %d] successfully changed to [unlimited].\n",
@@ -2478,15 +2478,15 @@ void parse_fromlogin(int fd)
}
bytes_to_read = 0;
}
- RFIFOSKIP(fd, 34);
+ RFIFOSKIP(s, 34);
break;
case 0x794b: // answer of an account ban set
- if (RFIFOREST(fd) < 34)
+ if (RFIFOREST(s) < 34)
return;
{
- int account_id = RFIFOL(fd, 2);
- AccountName name = stringish<AccountName>(RFIFO_STRING<24>(fd, 6));
+ int account_id = RFIFOL(s, 2);
+ AccountName name = stringish<AccountName>(RFIFO_STRING<24>(s, 6));
if (account_id == -1)
{
PRINTF("Account [%s] final date of banishment changing failed. Account doesn't exist.\n",
@@ -2496,7 +2496,7 @@ void parse_fromlogin(int fd)
}
else
{
- TimeT timestamp = static_cast<time_t>(RFIFOL(fd, 30));
+ TimeT timestamp = static_cast<time_t>(RFIFOL(s, 30));
if (!timestamp)
{
PRINTF("Final date of banishment of the account [%s][id: %d] successfully changed to [unbanished].\n",
@@ -2509,23 +2509,23 @@ void parse_fromlogin(int fd)
timestamp_seconds_buffer tmpstr;
stamp_time(tmpstr, &timestamp);
PRINTF("Final date of banishment of the account [%s][id: %d] successfully changed to be until %s.\n",
- name, RFIFOL(fd, 2), tmpstr);
+ name, RFIFOL(s, 2), tmpstr);
LADMIN_LOG("Final date of banishment of the account [%s][id: %d] successfully changed to be until %s.\n",
- name, RFIFOL(fd, 2),
+ name, RFIFOL(s, 2),
tmpstr);
}
}
bytes_to_read = 0;
}
- RFIFOSKIP(fd, 34);
+ RFIFOSKIP(s, 34);
break;
case 0x794d: // answer of an account ban date/time changing
- if (RFIFOREST(fd) < 34)
+ if (RFIFOREST(s) < 34)
return;
{
- int account_id = RFIFOL(fd, 2);
- AccountName name = stringish<AccountName>(RFIFO_STRING<24>(fd, 6));
+ int account_id = RFIFOL(s, 2);
+ AccountName name = stringish<AccountName>(RFIFO_STRING<24>(s, 6));
if (account_id == -1)
{
PRINTF("Account [%s] final date of banishment changing failed. Account doesn't exist.\n",
@@ -2535,7 +2535,7 @@ void parse_fromlogin(int fd)
}
else
{
- TimeT timestamp = static_cast<time_t>(RFIFOL(fd, 30));
+ TimeT timestamp = static_cast<time_t>(RFIFOL(s, 30));
if (!timestamp)
{
PRINTF("Final date of banishment of the account [%s][id: %d] successfully changed to [unbanished].\n",
@@ -2557,13 +2557,13 @@ void parse_fromlogin(int fd)
}
bytes_to_read = 0;
}
- RFIFOSKIP(fd, 34);
+ RFIFOSKIP(s, 34);
break;
case 0x794f: // answer of a broadcast
- if (RFIFOREST(fd) < 4)
+ if (RFIFOREST(s) < 4)
return;
- if (RFIFOW(fd, 2) == static_cast<uint16_t>(-1))
+ if (RFIFOW(s, 2) == static_cast<uint16_t>(-1))
{
PRINTF("Message sending failed. No online char-server.\n");
LADMIN_LOG("Message sending failed. No online char-server.\n");
@@ -2574,15 +2574,15 @@ void parse_fromlogin(int fd)
LADMIN_LOG("Message successfully sended to login-server.\n");
}
bytes_to_read = 0;
- RFIFOSKIP(fd, 4);
+ RFIFOSKIP(s, 4);
break;
case 0x7951: // answer of an account validity limit changing
- if (RFIFOREST(fd) < 34)
+ if (RFIFOREST(s) < 34)
return;
{
- int account_id = RFIFOL(fd, 2);
- AccountName name = stringish<AccountName>(RFIFO_STRING<24>(fd, 6));
+ int account_id = RFIFOL(s, 2);
+ AccountName name = stringish<AccountName>(RFIFO_STRING<24>(s, 6));
if (account_id == -1)
{
PRINTF("Account [%s] validity limit changing failed. Account doesn't exist.\n",
@@ -2592,7 +2592,7 @@ void parse_fromlogin(int fd)
}
else
{
- TimeT timestamp = static_cast<time_t>(RFIFOL(fd, 30));
+ TimeT timestamp = static_cast<time_t>(RFIFOL(s, 30));
if (!timestamp)
{
PRINTF("Validity limit of the account [%s][id: %d] unchanged.\n",
@@ -2616,27 +2616,27 @@ void parse_fromlogin(int fd)
}
bytes_to_read = 0;
}
- RFIFOSKIP(fd, 34);
+ RFIFOSKIP(s, 34);
break;
case 0x7953: // answer of a request about informations of an account (by account name/id)
- if (RFIFOREST(fd) < 150
- || RFIFOREST(fd) < (150 + RFIFOW(fd, 148)))
+ if (RFIFOREST(s) < 150
+ || RFIFOREST(s) < (150 + RFIFOW(s, 148)))
return;
{
- int account_id = RFIFOL(fd, 2);
- uint8_t gm = RFIFOB(fd, 6);
- AccountName userid = stringish<AccountName>(RFIFO_STRING<24>(fd, 7));
- uint8_t sex = RFIFOB(fd, 31);
- int connections = RFIFOL(fd, 32);
- int state = RFIFOL(fd, 36);
- timestamp_seconds_buffer error_message = stringish<timestamp_seconds_buffer>(RFIFO_STRING<20>(fd, 40));
- timestamp_milliseconds_buffer lastlogin = stringish<timestamp_milliseconds_buffer>(RFIFO_STRING<24>(fd, 60));
- VString<15> last_ip_ = RFIFO_STRING<16>(fd, 84);
- AccountEmail email = stringish<AccountEmail>(RFIFO_STRING<40>(fd, 100));
- TimeT connect_until_time = static_cast<time_t>(RFIFOL(fd, 140));
- TimeT ban_until_time = static_cast<time_t>(RFIFOL(fd, 144));
- FString memo = RFIFO_STRING(fd, 150, RFIFOW(fd, 148));
+ int account_id = RFIFOL(s, 2);
+ uint8_t gm = RFIFOB(s, 6);
+ AccountName userid = stringish<AccountName>(RFIFO_STRING<24>(s, 7));
+ uint8_t sex = RFIFOB(s, 31);
+ int connections = RFIFOL(s, 32);
+ int state = RFIFOL(s, 36);
+ timestamp_seconds_buffer error_message = stringish<timestamp_seconds_buffer>(RFIFO_STRING<20>(s, 40));
+ timestamp_milliseconds_buffer lastlogin = stringish<timestamp_milliseconds_buffer>(RFIFO_STRING<24>(s, 60));
+ VString<15> last_ip_ = RFIFO_STRING<16>(s, 84);
+ AccountEmail email = stringish<AccountEmail>(RFIFO_STRING<40>(s, 100));
+ TimeT connect_until_time = static_cast<time_t>(RFIFOL(s, 140));
+ TimeT ban_until_time = static_cast<time_t>(RFIFOL(s, 144));
+ FString memo = RFIFO_STRING(s, 150, RFIFOW(s, 148));
if (account_id == -1)
{
PRINTF("Unabled to find the account [%s]. Account doesn't exist.\n",
@@ -2743,13 +2743,13 @@ void parse_fromlogin(int fd)
}
}
bytes_to_read = 0;
- RFIFOSKIP(fd, 150 + RFIFOW(fd, 148));
+ RFIFOSKIP(s, 150 + RFIFOW(s, 148));
break;
default:
PRINTF("Remote administration has been disconnected (unknown packet).\n");
LADMIN_LOG("'End of connection, unknown packet.\n");
- session[fd]->eof = 1;
+ s->eof = 1;
return;
}
}
@@ -2767,14 +2767,15 @@ int Connect_login_server(void)
Iprintf("Attempt to connect to login-server...\n");
LADMIN_LOG("Attempt to connect to login-server...\n");
- if ((login_fd = make_connection(login_ip, login_port)) < 0)
+ login_session = make_connection(login_ip, login_port);
+ if (!login_session)
return 0;
{
- WFIFOW(login_fd, 0) = 0x7918; // Request for administation login
- WFIFOW(login_fd, 2) = 0; // no encrypted
- WFIFO_STRING(login_fd, 4, admin_pass, 24);
- WFIFOSET(login_fd, 28);
+ WFIFOW(login_session, 0) = 0x7918; // Request for administation login
+ WFIFOW(login_session, 2) = 0; // no encrypted
+ WFIFO_STRING(login_session, 4, admin_pass, 24);
+ WFIFOSET(login_session, 28);
bytes_to_read = 1;
Iprintf("Sending of the password...\n");
@@ -2832,7 +2833,7 @@ void term_func(void)
if (already_exit_function == 0)
{
- delete_session(login_fd);
+ delete_session(login_session);
Iprintf("\033[0m----End of Ladmin (normal end with closing of all files).\n");
LADMIN_LOG("----End of Ladmin (normal end with closing of all files).\n");
diff --git a/src/char/char.cpp b/src/char/char.cpp
index 8ed78f6..f98fc4b 100644
--- a/src/char/char.cpp
+++ b/src/char/char.cpp
@@ -42,7 +42,7 @@
static
struct mmo_map_server server[MAX_MAP_SERVERS];
static
-int server_fd[MAX_MAP_SERVERS];
+Session *server_session[MAX_MAP_SERVERS];
static
int server_freezeflag[MAX_MAP_SERVERS]; // Map-server anti-freeze system. Counter. 5 ok, 4...0 freezed
static
@@ -54,9 +54,8 @@ constexpr
std::chrono::milliseconds DEFAULT_AUTOSAVE_INTERVAL =
std::chrono::minutes(5);
-// TODO replace all string forms of IP addresses with class instances
static
-int login_fd, char_fd;
+Session *login_session, *char_session;
static
AccountName userid;
static
@@ -151,7 +150,7 @@ static
int online_gm_display_min_level = 20; // minimum GM level to display 'GM' when we want to display it
static
-std::vector<int> online_chars; // same size of char_data, and id value of current server (or -1)
+std::vector<Session *> online_chars; // same size of char_data, and id value of current server (or -1)
static
TimeT update_online; // to update online files when we receiving information from a server (not less than 8 seconds)
@@ -205,6 +204,29 @@ const mmo_charstatus *search_character(CharName character_name)
return nullptr;
}
+const mmo_charstatus *search_character_id(int char_id)
+{
+ for (const mmo_charstatus& cd : char_data)
+ {
+ if (cd.char_id == char_id)
+ return &cd;
+ }
+
+ return nullptr;
+}
+
+Session *server_for(const mmo_charstatus *mcs)
+{
+ if (!mcs)
+ return nullptr;
+ return online_chars[mcs - &char_data.front()];
+}
+static
+Session *& server_for_m(const mmo_charstatus *mcs)
+{
+ return online_chars[mcs - &char_data.front()];
+}
+
//-------------------------------------------------
// Function to create the character line (for save)
//-------------------------------------------------
@@ -474,7 +496,7 @@ int mmo_char_init(void)
if (cd.char_id >= char_id_count)
char_id_count = cd.char_id + 1;
char_data.push_back(std::move(cd));
- online_chars.push_back(-1);
+ online_chars.push_back(nullptr);
}
PRINTF("mmo_char_init: %zu characters read in %s.\n",
@@ -547,16 +569,16 @@ void mmo_char_sync_timer(TimerData *, tick_t)
// Function to create a new character
//-----------------------------------
static
-mmo_charstatus *make_new_char(int fd, CharName name, const uint8_t (&stats)[6], uint8_t slot, uint16_t hair_color, uint16_t hair_style)
+mmo_charstatus *make_new_char(Session *s, CharName name, const uint8_t (&stats)[6], uint8_t slot, uint16_t hair_color, uint16_t hair_style)
{
// ugh
- char_session_data *sd = static_cast<char_session_data *>(session[fd]->session_data.get());
+ char_session_data *sd = static_cast<char_session_data *>(s->session_data.get());
// remove control characters from the name
if (!name.to__actual().is_print())
{
CHAR_LOG("Make new char error (control char received in the name): (connection #%d, account: %d).\n",
- fd, sd->account_id);
+ s, sd->account_id);
return nullptr;
}
@@ -564,7 +586,7 @@ mmo_charstatus *make_new_char(int fd, CharName name, const uint8_t (&stats)[6],
if (name.to__actual() != name.to__actual().strip())
{
CHAR_LOG("Make new char error (leading/trailing whitespace): (connection #%d, account: %d, name: '%s'.\n",
- fd, sd->account_id, name);
+ s, sd->account_id, name);
return nullptr;
}
@@ -572,7 +594,7 @@ mmo_charstatus *make_new_char(int fd, CharName name, const uint8_t (&stats)[6],
if (name.to__actual().size() < 4)
{
CHAR_LOG("Make new char error (character name too small): (connection #%d, account: %d, name: '%s').\n",
- fd, sd->account_id, name);
+ s, sd->account_id, name);
return nullptr;
}
@@ -584,7 +606,7 @@ mmo_charstatus *make_new_char(int fd, CharName name, const uint8_t (&stats)[6],
if (!char_name_letters[c])
{
CHAR_LOG("Make new char error (invalid letter in the name): (connection #%d, account: %d), name: %s, invalid letter: %c.\n",
- fd, sd->account_id, name, c);
+ s, sd->account_id, name, c);
return nullptr;
}
}
@@ -595,7 +617,7 @@ mmo_charstatus *make_new_char(int fd, CharName name, const uint8_t (&stats)[6],
if (char_name_letters[c])
{
CHAR_LOG("Make new char error (invalid letter in the name): (connection #%d, account: %d), name: %s, invalid letter: %c.\n",
- fd, sd->account_id, name, c);
+ s, sd->account_id, name, c);
return nullptr;
}
} // else, all letters/symbols are authorised (except control char removed before)
@@ -607,7 +629,7 @@ mmo_charstatus *make_new_char(int fd, CharName name, const uint8_t (&stats)[6],
hair_color >= 12)
{
CHAR_LOG("Make new char error (invalid values): (connection #%d, account: %d) slot %d, name: %s, stats: %d+%d+%d+%d+%d+%d=%d, hair: %d, hair color: %d\n",
- fd, sd->account_id, slot, name,
+ s, sd->account_id, slot, name,
stats[0], stats[1], stats[2], stats[3], stats[4], stats[5],
stats[0] + stats[1] + stats[2] + stats[3] + stats[4] + stats[5],
hair_style, hair_color);
@@ -620,7 +642,7 @@ mmo_charstatus *make_new_char(int fd, CharName name, const uint8_t (&stats)[6],
if (stats[i] < 1 || stats[i] > 9)
{
CHAR_LOG("Make new char error (invalid stat value: not between 1 to 9): (connection #%d, account: %d) slot %d, name: %s, stats: %d+%d+%d+%d+%d+%d=%d, hair: %d, hair color: %d\n",
- fd, sd->account_id, slot, name,
+ s, sd->account_id, slot, name,
stats[0], stats[1], stats[2], stats[3], stats[4], stats[5],
stats[0] + stats[1] + stats[2] + stats[3] + stats[4] + stats[5],
hair_style, hair_color);
@@ -633,7 +655,7 @@ mmo_charstatus *make_new_char(int fd, CharName name, const uint8_t (&stats)[6],
if (cd.name == name)
{
CHAR_LOG("Make new char error (name already exists): (connection #%d, account: %d) slot %d, name: %s (actual name of other char: %s), stats: %d+%d+%d+%d+%d+%d=%d, hair: %d, hair color: %d.\n",
- fd, sd->account_id, slot, name, cd.name,
+ s, sd->account_id, slot, name, cd.name,
stats[0], stats[1], stats[2], stats[3], stats[4], stats[5],
stats[0] + stats[1] + stats[2] + stats[3] + stats[4] + stats[5],
hair_style, hair_color);
@@ -643,7 +665,7 @@ mmo_charstatus *make_new_char(int fd, CharName name, const uint8_t (&stats)[6],
&& cd.char_num == slot)
{
CHAR_LOG("Make new char error (slot already used): (connection #%d, account: %d) slot %d, name: %s (actual name of other char: %s), stats: %d+%d+%d+%d+%d+%d=%d, hair: %d, hair color: %d.\n",
- fd, sd->account_id, slot, name, cd.name,
+ s, sd->account_id, slot, name, cd.name,
stats[0], stats[1], stats[2], stats[3], stats[4], stats[5],
stats[0] + stats[1] + stats[2] + stats[3] + stats[4] + stats[5],
hair_style, hair_color);
@@ -654,17 +676,17 @@ mmo_charstatus *make_new_char(int fd, CharName name, const uint8_t (&stats)[6],
if (wisp_server_name == name)
{
CHAR_LOG("Make new char error (name used is wisp name for server): (connection #%d, account: %d) slot %d, name: %s (actual name whisper server: %s), stats: %d+%d+%d+%d+%d+%d=%d, hair: %d, hair color: %d.\n",
- fd, sd->account_id, slot, name, wisp_server_name,
+ s, sd->account_id, slot, name, wisp_server_name,
stats[0], stats[1], stats[2], stats[3], stats[4], stats[5],
stats[0] + stats[1] + stats[2] + stats[3] + stats[4] + stats[5],
hair_style, hair_color);
return nullptr;
}
- IP4Address ip = session[fd]->client_ip;
+ IP4Address ip = s->client_ip;
CHAR_LOG("Creation of New Character: (connection #%d, account: %d) slot %d, character Name: %s, stats: %d+%d+%d+%d+%d+%d=%d, hair: %d, hair color: %d. [%s]\n",
- fd, sd->account_id, slot, name,
+ s, sd->account_id, slot, name,
stats[0], stats[1], stats[2], stats[3], stats[4], stats[5],
stats[0] + stats[1] + stats[2] + stats[3] + stats[4] + stats[5],
hair_style, hair_color, ip);
@@ -710,7 +732,7 @@ mmo_charstatus *make_new_char(int fd, CharName name, const uint8_t (&stats)[6],
cd.last_point = start_point;
cd.save_point = start_point;
char_data.push_back(std::move(cd));
- online_chars.push_back(-1);
+ online_chars.push_back(nullptr);
return &char_data.back();
}
@@ -768,7 +790,7 @@ void create_online_files(void)
// display each player.
for (struct mmo_charstatus& cd : char_data)
{
- if (online_chars[&cd - &char_data.front()] == -1)
+ if (!server_for(&cd))
continue;
players++;
FPRINTF(fp2, " <tr>\n");
@@ -848,7 +870,7 @@ int count_users(void)
users = 0;
for (i = 0; i < MAX_MAP_SERVERS; i++)
- if (server_fd[i] >= 0)
+ if (server_session[i])
users += server[i].users;
return users;
@@ -871,7 +893,7 @@ int find_equip_view(const mmo_charstatus *p, EPOS equipmask)
// Function to send characters to a player
//----------------------------------------
static
-int mmo_char_send006b(int fd, struct char_session_data *sd)
+int mmo_char_send006b(Session *s, struct char_session_data *sd)
{
int found_num = 0;
std::array<const mmo_charstatus *, 9> found_char;
@@ -887,62 +909,62 @@ int mmo_char_send006b(int fd, struct char_session_data *sd)
}
const int offset = 24;
- WFIFO_ZERO(fd, 0, offset + found_num * 106);
- WFIFOW(fd, 0) = 0x6b;
- WFIFOW(fd, 2) = offset + found_num * 106;
+ WFIFO_ZERO(s, 0, offset + found_num * 106);
+ WFIFOW(s, 0) = 0x6b;
+ WFIFOW(s, 2) = offset + found_num * 106;
for (int i = 0; i < found_num; i++)
{
const mmo_charstatus *p = found_char[i];
int j = offset + (i * 106);
- WFIFOL(fd, j) = p->char_id;
- WFIFOL(fd, j + 4) = p->base_exp;
- WFIFOL(fd, j + 8) = p->zeny;
- WFIFOL(fd, j + 12) = p->job_exp;
- WFIFOL(fd, j + 16) = p->job_level;
-
- WFIFOW(fd, j + 20) = find_equip_view(p, EPOS::SHOES);
- WFIFOW(fd, j + 22) = find_equip_view(p, EPOS::GLOVES);
- WFIFOW(fd, j + 24) = find_equip_view(p, EPOS::CAPE);
- WFIFOW(fd, j + 26) = find_equip_view(p, EPOS::MISC1);
- WFIFOL(fd, j + 28) = static_cast<uint16_t>(p->option);
-
- WFIFOL(fd, j + 32) = p->karma;
- WFIFOL(fd, j + 36) = p->manner;
-
- WFIFOW(fd, j + 40) = p->status_point;
- WFIFOW(fd, j + 42) = (p->hp > 0x7fff) ? 0x7fff : p->hp;
- WFIFOW(fd, j + 44) = (p->max_hp > 0x7fff) ? 0x7fff : p->max_hp;
- WFIFOW(fd, j + 46) = (p->sp > 0x7fff) ? 0x7fff : p->sp;
- WFIFOW(fd, j + 48) = (p->max_sp > 0x7fff) ? 0x7fff : p->max_sp;
- WFIFOW(fd, j + 50) = static_cast<uint16_t>(DEFAULT_WALK_SPEED.count()); // p->speed;
- WFIFOW(fd, j + 52) = p->species;
- WFIFOW(fd, j + 54) = p->hair;
-// WFIFOW(fd,j+56) = p->weapon; // dont send weapon since TMW does not support it
- WFIFOW(fd, j + 56) = 0;
- WFIFOW(fd, j + 58) = p->base_level;
- WFIFOW(fd, j + 60) = p->skill_point;
- WFIFOW(fd, j + 62) = p->head_bottom;
- WFIFOW(fd, j + 64) = p->shield;
- WFIFOW(fd, j + 66) = p->head_top;
- WFIFOW(fd, j + 68) = p->head_mid;
- WFIFOW(fd, j + 70) = p->hair_color;
- WFIFOW(fd, j + 72) = find_equip_view(p, EPOS::MISC2);
-// WFIFOW(fd,j+72) = p->clothes_color;
-
- WFIFO_STRING(fd, j + 74, p->name.to__actual(), 24);
-
- WFIFOB(fd, j + 98) = min(p->attrs[ATTR::STR], 255);
- WFIFOB(fd, j + 99) = min(p->attrs[ATTR::AGI], 255);
- WFIFOB(fd, j + 100) = min(p->attrs[ATTR::VIT], 255);
- WFIFOB(fd, j + 101) = min(p->attrs[ATTR::INT], 255);
- WFIFOB(fd, j + 102) = min(p->attrs[ATTR::DEX], 255);
- WFIFOB(fd, j + 103) = min(p->attrs[ATTR::LUK], 255);
- WFIFOB(fd, j + 104) = p->char_num;
+ WFIFOL(s, j) = p->char_id;
+ WFIFOL(s, j + 4) = p->base_exp;
+ WFIFOL(s, j + 8) = p->zeny;
+ WFIFOL(s, j + 12) = p->job_exp;
+ WFIFOL(s, j + 16) = p->job_level;
+
+ WFIFOW(s, j + 20) = find_equip_view(p, EPOS::SHOES);
+ WFIFOW(s, j + 22) = find_equip_view(p, EPOS::GLOVES);
+ WFIFOW(s, j + 24) = find_equip_view(p, EPOS::CAPE);
+ WFIFOW(s, j + 26) = find_equip_view(p, EPOS::MISC1);
+ WFIFOL(s, j + 28) = static_cast<uint16_t>(p->option);
+
+ WFIFOL(s, j + 32) = p->karma;
+ WFIFOL(s, j + 36) = p->manner;
+
+ WFIFOW(s, j + 40) = p->status_point;
+ WFIFOW(s, j + 42) = (p->hp > 0x7fff) ? 0x7fff : p->hp;
+ WFIFOW(s, j + 44) = (p->max_hp > 0x7fff) ? 0x7fff : p->max_hp;
+ WFIFOW(s, j + 46) = (p->sp > 0x7fff) ? 0x7fff : p->sp;
+ WFIFOW(s, j + 48) = (p->max_sp > 0x7fff) ? 0x7fff : p->max_sp;
+ WFIFOW(s, j + 50) = static_cast<uint16_t>(DEFAULT_WALK_SPEED.count()); // p->speed;
+ WFIFOW(s, j + 52) = p->species;
+ WFIFOW(s, j + 54) = p->hair;
+// WFIFOW(s,j+56) = p->weapon; // dont send weapon since TMW does not support it
+ WFIFOW(s, j + 56) = 0;
+ WFIFOW(s, j + 58) = p->base_level;
+ WFIFOW(s, j + 60) = p->skill_point;
+ WFIFOW(s, j + 62) = p->head_bottom;
+ WFIFOW(s, j + 64) = p->shield;
+ WFIFOW(s, j + 66) = p->head_top;
+ WFIFOW(s, j + 68) = p->head_mid;
+ WFIFOW(s, j + 70) = p->hair_color;
+ WFIFOW(s, j + 72) = find_equip_view(p, EPOS::MISC2);
+// WFIFOW(s,j+72) = p->clothes_color;
+
+ WFIFO_STRING(s, j + 74, p->name.to__actual(), 24);
+
+ WFIFOB(s, j + 98) = min(p->attrs[ATTR::STR], 255);
+ WFIFOB(s, j + 99) = min(p->attrs[ATTR::AGI], 255);
+ WFIFOB(s, j + 100) = min(p->attrs[ATTR::VIT], 255);
+ WFIFOB(s, j + 101) = min(p->attrs[ATTR::INT], 255);
+ WFIFOB(s, j + 102) = min(p->attrs[ATTR::DEX], 255);
+ WFIFOB(s, j + 103) = min(p->attrs[ATTR::LUK], 255);
+ WFIFOB(s, j + 104) = p->char_num;
}
- WFIFOSET(fd, WFIFOW(fd, 2));
+ WFIFOSET(s, WFIFOW(s, 2));
return 0;
}
@@ -1065,34 +1087,34 @@ int char_delete(struct mmo_charstatus *cs)
}
static
-void parse_tologin(int fd)
+void parse_tologin(Session *ls)
{
// only login-server can have an access to here.
// so, if it isn't the login-server, we disconnect the session (fd != login_fd).
- if (fd != login_fd || session[fd]->eof)
+ if (ls != login_session || ls->eof)
{
- if (fd == login_fd)
+ if (ls == login_session)
{
PRINTF("Char-server can't connect to login-server (connection #%d).\n",
- fd);
- login_fd = -1;
+ ls);
+ login_session = nullptr;
}
- delete_session(fd);
+ delete_session(ls);
return;
}
- char_session_data *sd = static_cast<char_session_data *>(session[fd]->session_data.get());
+ char_session_data *sd = static_cast<char_session_data *>(ls->session_data.get());
- while (RFIFOREST(fd) >= 2)
+ while (RFIFOREST(ls) >= 2)
{
// PRINTF("parse_tologin: connection #%d, packet: 0x%x (with being read: %d bytes).\n", fd, RFIFOW(fd,0), RFIFOREST(fd));
- switch (RFIFOW(fd, 0))
+ switch (RFIFOW(ls, 0))
{
case 0x2711:
- if (RFIFOREST(fd) < 3)
+ if (RFIFOREST(ls) < 3)
return;
- if (RFIFOB(fd, 2))
+ if (RFIFOB(ls, 2))
{
// PRINTF("connect login server error : %d\n", RFIFOB(fd,2));
PRINTF("Can not connect to login-server.\n");
@@ -1104,34 +1126,35 @@ void parse_tologin(int fd)
else
{
PRINTF("Connected to login-server (connection #%d).\n",
- fd);
+ ls);
// if no map-server already connected, display a message...
int i;
for (i = 0; i < MAX_MAP_SERVERS; i++)
- if (server_fd[i] >= 0 && server[i].maps[0]) // if map-server online and at least 1 map
+ if (server_session[i] && server[i].maps[0]) // if map-server online and at least 1 map
break;
if (i == MAX_MAP_SERVERS)
PRINTF("Awaiting maps from map-server.\n");
}
- RFIFOSKIP(fd, 3);
+ RFIFOSKIP(ls, 3);
break;
case 0x2713:
- if (RFIFOREST(fd) < 51)
+ if (RFIFOREST(ls) < 51)
return;
// PRINTF("parse_tologin 2713 : %d\n", RFIFOB(fd,6));
for (int i = 0; i < fd_max; i++)
{
- if (!session[i])
+ Session *s2 = session[i].get();
+ if (!s2)
continue;
- sd = static_cast<char_session_data *>(session[i]->session_data.get());
- if (sd && sd->account_id == RFIFOL(fd, 2))
+ sd = static_cast<char_session_data *>(s2->session_data.get());
+ if (sd && sd->account_id == RFIFOL(ls, 2))
{
- if (RFIFOB(fd, 6) != 0)
+ if (RFIFOB(ls, 6) != 0)
{
- WFIFOW(i, 0) = 0x6c;
- WFIFOB(i, 2) = 0x42;
- WFIFOSET(i, 3);
+ WFIFOW(s2, 0) = 0x6c;
+ WFIFOB(s2, 2) = 0x42;
+ WFIFOSET(s2, 3);
}
else if (max_connect_user == 0
|| count_users() < max_connect_user)
@@ -1140,73 +1163,74 @@ void parse_tologin(int fd)
// PRINTF("max_connect_user (unlimited) -> accepted.\n");
// else
// PRINTF("count_users(): %d < max_connect_user (%d) -> accepted.\n", count_users(), max_connect_user);
- sd->email = stringish<AccountEmail>(RFIFO_STRING<40>(fd, 7));
+ sd->email = stringish<AccountEmail>(RFIFO_STRING<40>(ls, 7));
if (!e_mail_check(sd->email))
sd->email = DEFAULT_EMAIL;
- sd->connect_until_time = static_cast<time_t>(RFIFOL(fd, 47));
+ sd->connect_until_time = static_cast<time_t>(RFIFOL(ls, 47));
// send characters to player
- mmo_char_send006b(i, sd);
+ mmo_char_send006b(s2, sd);
}
else
{
// refuse connection: too much online players
// PRINTF("count_users(): %d < max_connect_use (%d) -> fail...\n", count_users(), max_connect_user);
- WFIFOW(i, 0) = 0x6c;
- WFIFOB(i, 2) = 0;
- WFIFOSET(i, 3);
+ WFIFOW(s2, 0) = 0x6c;
+ WFIFOB(s2, 2) = 0;
+ WFIFOSET(s2, 3);
}
break;
}
}
- RFIFOSKIP(fd, 51);
+ RFIFOSKIP(ls, 51);
break;
// Receiving of an e-mail/time limit from the login-server (answer of a request because a player comes back from map-server to char-server) by [Yor]
case 0x2717:
- if (RFIFOREST(fd) < 50)
+ if (RFIFOREST(ls) < 50)
return;
for (int i = 0; i < fd_max; i++)
{
- if (!session[i])
+ Session *s2 = session[i].get();
+ if (!s2)
continue;
- sd = static_cast<char_session_data *>(session[i]->session_data.get());
+ sd = static_cast<char_session_data *>(s2->session_data.get());
if (sd)
{
- if (sd->account_id == RFIFOL(fd, 2))
+ if (sd->account_id == RFIFOL(ls, 2))
{
- sd->email = stringish<AccountEmail>(RFIFO_STRING<40>(fd, 6));
+ sd->email = stringish<AccountEmail>(RFIFO_STRING<40>(ls, 6));
if (!e_mail_check(sd->email))
sd->email = DEFAULT_EMAIL;
- sd->connect_until_time = static_cast<time_t>(RFIFOL(fd, 46));
+ sd->connect_until_time = static_cast<time_t>(RFIFOL(ls, 46));
break;
}
}
}
- RFIFOSKIP(fd, 50);
+ RFIFOSKIP(ls, 50);
break;
case 0x2721: // gm reply
- if (RFIFOREST(fd) < 10)
+ if (RFIFOREST(ls) < 10)
return;
{
unsigned char buf[10];
WBUFW(buf, 0) = 0x2b0b;
- WBUFL(buf, 2) = RFIFOL(fd, 2); // account
- WBUFL(buf, 6) = RFIFOL(fd, 6); // GM level
+ WBUFL(buf, 2) = RFIFOL(ls, 2); // account
+ WBUFL(buf, 6) = RFIFOL(ls, 6); // GM level
mapif_sendall(buf, 10);
// PRINTF("parse_tologin: To become GM answer: char -> map.\n");
}
- RFIFOSKIP(fd, 10);
+ RFIFOSKIP(ls, 10);
break;
case 0x2723: // changesex reply (modified by [Yor])
- if (RFIFOREST(fd) < 7)
+ if (RFIFOREST(ls) < 7)
return;
{
unsigned char buf[7];
- int acc = RFIFOL(fd, 2);
- SEX sex = static_cast<SEX>(RFIFOB(fd, 6));
- RFIFOSKIP(fd, 7);
+ int acc = RFIFOL(ls, 2);
+ SEX sex = static_cast<SEX>(RFIFOB(ls, 6));
+ RFIFOSKIP(ls, 7);
if (acc > 0)
{
for (struct mmo_charstatus& cd : char_data)
@@ -1240,24 +1264,24 @@ void parse_tologin(int fd)
break;
case 0x2726: // Request to send a broadcast message (no answer)
- if (RFIFOREST(fd) < 8
- || RFIFOREST(fd) < (8 + RFIFOL(fd, 4)))
+ if (RFIFOREST(ls) < 8
+ || RFIFOREST(ls) < (8 + RFIFOL(ls, 4)))
return;
- if (RFIFOL(fd, 4) < 1)
+ if (RFIFOL(ls, 4) < 1)
CHAR_LOG("Receiving a message for broadcast, but message is void.\n");
else
{
int i;
// at least 1 map-server
for (i = 0; i < MAX_MAP_SERVERS; i++)
- if (server_fd[i] >= 0)
+ if (server_session[i])
break;
if (i == MAX_MAP_SERVERS)
CHAR_LOG("'ladmin': Receiving a message for broadcast, but no map-server is online.\n");
else
{
- size_t len = RFIFOL(fd, 4);
- FString message = RFIFO_STRING(fd, 8, len).to_print().lstrip();
+ size_t len = RFIFOL(ls, 4);
+ FString message = RFIFO_STRING(ls, 8, len).to_print().lstrip();
// if message is only composed of spaces
if (!message)
CHAR_LOG("Receiving a message for broadcast, but message is only a lot of spaces.\n");
@@ -1275,42 +1299,42 @@ void parse_tologin(int fd)
}
}
}
- RFIFOSKIP(fd, 8 + RFIFOL(fd, 4));
+ RFIFOSKIP(ls, 8 + RFIFOL(ls, 4));
break;
// account_reg2変更通知
case 0x2729:
- if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd, 2))
+ if (RFIFOREST(ls) < 4 || RFIFOREST(ls) < RFIFOW(ls, 2))
return;
{
struct global_reg reg[ACCOUNT_REG2_NUM];
int j, p, acc;
- acc = RFIFOL(fd, 4);
+ acc = RFIFOL(ls, 4);
for (p = 8, j = 0;
- p < RFIFOW(fd, 2) && j < ACCOUNT_REG2_NUM;
+ p < RFIFOW(ls, 2) && j < ACCOUNT_REG2_NUM;
p += 36, j++)
{
- reg[j].str = stringish<VarName>(RFIFO_STRING<32>(fd, p));
- reg[j].value = RFIFOL(fd, p + 32);
+ reg[j].str = stringish<VarName>(RFIFO_STRING<32>(ls, p));
+ reg[j].value = RFIFOL(ls, p + 32);
}
set_account_reg2(acc, j, reg);
- size_t len = RFIFOW(fd, 2);
+ size_t len = RFIFOW(ls, 2);
uint8_t buf[len];
- RFIFO_BUF_CLONE(fd, buf, len);
+ RFIFO_BUF_CLONE(ls, buf, len);
WBUFW(buf, 0) = 0x2b11;
mapif_sendall(buf, len);
// PRINTF("char: save_account_reg_reply\n");
}
- RFIFOSKIP(fd, RFIFOW(fd, 2));
+ RFIFOSKIP(ls, RFIFOW(ls, 2));
break;
case 0x7924:
{ // [Fate] Itemfrob package: forwarded from login-server
- if (RFIFOREST(fd) < 10)
+ if (RFIFOREST(ls) < 10)
return;
- int source_id = RFIFOL(fd, 2);
- int dest_id = RFIFOL(fd, 6);
+ int source_id = RFIFOL(ls, 2);
+ int dest_id = RFIFOL(ls, 6);
unsigned char buf[10];
WBUFW(buf, 0) = 0x2afa;
@@ -1348,13 +1372,13 @@ void parse_tologin(int fd)
mmo_char_sync();
inter_storage_save();
- RFIFOSKIP(fd, 10);
+ RFIFOSKIP(ls, 10);
break;
}
// Account deletion notification (from login-server)
case 0x2730:
- if (RFIFOREST(fd) < 6)
+ if (RFIFOREST(ls) < 6)
return;
// Deletion of all characters of the account
//#warning "This comment is a lie, but it's still true."
@@ -1362,14 +1386,14 @@ void parse_tologin(int fd)
for (int idx = 0; idx < char_data.size(); idx++)
{
mmo_charstatus& cd = char_data[idx];
- if (cd.account_id == RFIFOL(fd, 2))
+ if (cd.account_id == RFIFOL(ls, 2))
{
char_delete(&cd);
if (&cd != &char_data.back())
{
std::swap(cd, char_data.back());
// if moved character owns to deleted account, check again it's character
- if (cd.account_id == RFIFOL(fd, 2))
+ if (cd.account_id == RFIFOL(ls, 2))
{
idx--;
// Correct moved character reference in the character's owner by [Yor]
@@ -1379,49 +1403,49 @@ void parse_tologin(int fd)
}
}
// Deletion of the storage
- inter_storage_delete(RFIFOL(fd, 2));
+ inter_storage_delete(RFIFOL(ls, 2));
// send to all map-servers to disconnect the player
{
unsigned char buf[6];
WBUFW(buf, 0) = 0x2b13;
- WBUFL(buf, 2) = RFIFOL(fd, 2);
+ WBUFL(buf, 2) = RFIFOL(ls, 2);
mapif_sendall(buf, 6);
}
// disconnect player if online on char-server
- disconnect_player(RFIFOL(fd, 2));
- RFIFOSKIP(fd, 6);
+ disconnect_player(RFIFOL(ls, 2));
+ RFIFOSKIP(ls, 6);
break;
// State change of account/ban notification (from login-server) by [Yor]
case 0x2731:
- if (RFIFOREST(fd) < 11)
+ if (RFIFOREST(ls) < 11)
return;
// send to all map-servers to disconnect the player
{
unsigned char buf[11];
WBUFW(buf, 0) = 0x2b14;
- WBUFL(buf, 2) = RFIFOL(fd, 2);
- WBUFB(buf, 6) = RFIFOB(fd, 6); // 0: change of statut, 1: ban
- WBUFL(buf, 7) = RFIFOL(fd, 7); // status or final date of a banishment
+ WBUFL(buf, 2) = RFIFOL(ls, 2);
+ WBUFB(buf, 6) = RFIFOB(ls, 6); // 0: change of statut, 1: ban
+ WBUFL(buf, 7) = RFIFOL(ls, 7); // status or final date of a banishment
mapif_sendall(buf, 11);
}
// disconnect player if online on char-server
- disconnect_player(RFIFOL(fd, 2));
- RFIFOSKIP(fd, 11);
+ disconnect_player(RFIFOL(ls, 2));
+ RFIFOSKIP(ls, 11);
break;
// Receiving GM acounts info from login-server (by [Yor])
case 0x2732:
- if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd, 2))
+ if (RFIFOREST(ls) < 4 || RFIFOREST(ls) < RFIFOW(ls, 2))
return;
{
- size_t len = RFIFOW(fd, 2);
+ size_t len = RFIFOW(ls, 2);
uint8_t buf[len];
gm_accounts.clear();
gm_accounts.reserve((len - 4) / 5);
for (int i = 4; i < len; i += 5)
{
- gm_accounts.push_back({static_cast<int>(RFIFOL(fd, i)), RFIFOB(fd, i + 4)});
+ gm_accounts.push_back({static_cast<int>(RFIFOL(ls, i)), RFIFOB(ls, i + 4)});
}
PRINTF("From login-server: receiving of %zu GM accounts information.\n",
gm_accounts.size());
@@ -1429,43 +1453,44 @@ void parse_tologin(int fd)
gm_accounts.size());
create_online_files(); // update online players files (perhaps some online players change of GM level)
// send new gm acccounts level to map-servers
- RFIFO_BUF_CLONE(fd, buf, len);
+ RFIFO_BUF_CLONE(ls, buf, len);
WBUFW(buf, 0) = 0x2b15;
mapif_sendall(buf, len);
}
- RFIFOSKIP(fd, RFIFOW(fd, 2));
+ RFIFOSKIP(ls, RFIFOW(ls, 2));
break;
case 0x2741: // change password reply
- if (RFIFOREST(fd) < 7)
+ if (RFIFOREST(ls) < 7)
return;
{
int acc, status, i;
- acc = RFIFOL(fd, 2);
- status = RFIFOB(fd, 6);
+ acc = RFIFOL(ls, 2);
+ status = RFIFOB(ls, 6);
for (i = 0; i < fd_max; i++)
{
- if (!session[i])
+ Session *s2 = session[i].get();
+ if (!s2)
continue;
- sd = static_cast<char_session_data *>(session[i]->session_data.get());
+ sd = static_cast<char_session_data *>(s2->session_data.get());
if (sd)
{
if (sd->account_id == acc)
{
- WFIFOW(i, 0) = 0x62;
- WFIFOB(i, 2) = status;
- WFIFOSET(i, 3);
+ WFIFOW(s2, 0) = 0x62;
+ WFIFOB(s2, 2) = status;
+ WFIFOSET(s2, 3);
break;
}
}
}
}
- RFIFOSKIP(fd, 7);
+ RFIFOSKIP(ls, 7);
break;
default:
- session[fd]->eof = 1;
+ ls->eof = 1;
return;
}
}
@@ -1482,7 +1507,7 @@ void map_anti_freeze_system(TimerData *, tick_t)
//PRINTF("Entering in map_anti_freeze_system function to check freeze of servers.\n");
for (i = 0; i < MAX_MAP_SERVERS; i++)
{
- if (server_fd[i] >= 0)
+ if (server_session[i])
{ // if map-server is online
//PRINTF("map_anti_freeze_system: server #%d, flag: %d.\n", i, server_freezeflag[i]);
if (server_freezeflag[i]-- < 1)
@@ -1491,63 +1516,63 @@ void map_anti_freeze_system(TimerData *, tick_t)
i);
CHAR_LOG("Map-server anti-freeze system: char-server #%d is freezed -> disconnection.\n",
i);
- session[server_fd[i]]->eof = 1;
+ server_session[i]->eof = 1;
}
}
}
}
static
-void parse_frommap(int fd)
+void parse_frommap(Session *ms)
{
int id;
for (id = 0; id < MAX_MAP_SERVERS; id++)
- if (server_fd[id] == fd)
+ if (server_session[id] == ms)
break;
- if (id == MAX_MAP_SERVERS || session[fd]->eof)
+ if (id == MAX_MAP_SERVERS || ms->eof)
{
if (id < MAX_MAP_SERVERS)
{
PRINTF("Map-server %d (session #%d) has disconnected.\n", id,
- fd);
+ ms);
server[id] = mmo_map_server{};
- server_fd[id] = -1;
- for (int& oci : online_chars)
- if (oci == fd)
- oci = -1;
+ server_session[id] = nullptr;
+ for (Session *& oci : online_chars)
+ if (oci == ms)
+ oci = nullptr;
create_online_files(); // update online players files (to remove all online players of this server)
}
- delete_session(fd);
+ delete_session(ms);
return;
}
- while (RFIFOREST(fd) >= 2)
+ while (RFIFOREST(ms) >= 2)
{
// PRINTF("parse_frommap: connection #%d, packet: 0x%x (with being read: %d bytes).\n", fd, RFIFOW(fd,0), RFIFOREST(fd));
- switch (RFIFOW(fd, 0))
+ switch (RFIFOW(ms, 0))
{
// request from map-server to reload GM accounts. Transmission to login-server (by Yor)
case 0x2af7:
- if (login_fd > 0)
+ if (login_session)
{ // don't send request if no login-server
- WFIFOW(login_fd, 0) = 0x2709;
- WFIFOSET(login_fd, 2);
+ WFIFOW(login_session, 0) = 0x2709;
+ WFIFOSET(login_session, 2);
}
- RFIFOSKIP(fd, 2);
+ RFIFOSKIP(ms, 2);
break;
// Receiving map names list from the map-server
case 0x2afa:
- if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd, 2))
+ if (RFIFOREST(ms) < 4 || RFIFOREST(ms) < RFIFOW(ms, 2))
return;
{
for (MapName &foo : server[id].maps)
foo = MapName();
int j = 0;
- for (int i = 4; i < RFIFOW(fd, 2); i += 16)
+ for (int i = 4; i < RFIFOW(ms, 2); i += 16)
{
- server[id].maps[j] = RFIFO_STRING<16>(fd, i);
+ server[id].maps[j] = RFIFO_STRING<16>(ms, i);
j++;
}
{
@@ -1558,10 +1583,10 @@ void parse_frommap(int fd)
id, j, server[id].ip,
server[id].port, id);
}
- WFIFOW(fd, 0) = 0x2afb;
- WFIFOB(fd, 2) = 0;
- WFIFO_STRING(fd, 3, wisp_server_name.to__actual(), 24);
- WFIFOSET(fd, 27);
+ WFIFOW(ms, 0) = 0x2afb;
+ WFIFOB(ms, 2) = 0;
+ WFIFO_STRING(ms, 3, wisp_server_name.to__actual(), 24);
+ WFIFOSET(ms, 27);
{
unsigned char buf[16384];
if (j == 0)
@@ -1580,42 +1605,42 @@ void parse_frommap(int fd)
// server[id].maps[i] = RFIFO_STRING(fd, 4 + i * 16)
for (int i = 0; i < j; ++i)
WBUF_STRING(buf, 10, server[id].maps[i], 16);
- mapif_sendallwos(fd, buf, WBUFW(buf, 2));
+ mapif_sendallwos(ms, buf, WBUFW(buf, 2));
}
// Transmitting the maps of the other map-servers to the new map-server
for (int x = 0; x < MAX_MAP_SERVERS; x++)
{
- if (server_fd[x] >= 0 && x != id)
+ if (server_session[x] && x != id)
{
- WFIFOW(fd, 0) = 0x2b04;
- WFIFOIP(fd, 4) = server[x].ip;
- WFIFOW(fd, 8) = server[x].port;
+ WFIFOW(ms, 0) = 0x2b04;
+ WFIFOIP(ms, 4) = server[x].ip;
+ WFIFOW(ms, 8) = server[x].port;
j = 0;
for (int i = 0; i < MAX_MAP_PER_SERVER; i++)
if (server[x].maps[i])
- WFIFO_STRING(fd, 10 + (j++) * 16, server[x].maps[i], 16);
+ WFIFO_STRING(ms, 10 + (j++) * 16, server[x].maps[i], 16);
if (j > 0)
{
- WFIFOW(fd, 2) = j * 16 + 10;
- WFIFOSET(fd, WFIFOW(fd, 2));
+ WFIFOW(ms, 2) = j * 16 + 10;
+ WFIFOSET(ms, WFIFOW(ms, 2));
}
}
}
}
}
- RFIFOSKIP(fd, RFIFOW(fd, 2));
+ RFIFOSKIP(ms, RFIFOW(ms, 2));
break;
// 認証要求
case 0x2afc:
- if (RFIFOREST(fd) < 22)
+ if (RFIFOREST(ms) < 22)
return;
{
- int account_id = RFIFOL(fd, 2);
- int char_id = RFIFOL(fd, 6);
- int login_id1 = RFIFOL(fd, 10);
- int login_id2 = RFIFOL(fd, 14);
- IP4Address ip = RFIFOIP(fd, 18);
+ int account_id = RFIFOL(ms, 2);
+ int char_id = RFIFOL(ms, 6);
+ int login_id1 = RFIFOL(ms, 10);
+ int login_id2 = RFIFOL(ms, 14);
+ IP4Address ip = RFIFOIP(ms, 18);
//PRINTF("auth_fifo search: account: %d, char: %d, secure: %08x-%08x\n", RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOL(fd,14));
for (AuthFifoEntry& afi : auth_fifo)
{
@@ -1638,55 +1663,60 @@ void parse_frommap(int fd)
}
assert (cd && "uh-oh - deleted while in queue?");
afi.delflag = 1;
- WFIFOW(fd, 0) = 0x2afd;
- WFIFOW(fd, 2) = 18 + sizeof(*cd);
- WFIFOL(fd, 4) = account_id;
- WFIFOL(fd, 8) = afi.login_id2;
- WFIFOL(fd, 12) = static_cast<time_t>(afi.connect_until_time);
+ WFIFOW(ms, 0) = 0x2afd;
+ WFIFOW(ms, 2) = 18 + sizeof(*cd);
+ WFIFOL(ms, 4) = account_id;
+ WFIFOL(ms, 8) = afi.login_id2;
+ WFIFOL(ms, 12) = static_cast<time_t>(afi.connect_until_time);
cd->sex = afi.sex;
- WFIFOW(fd, 16) = afi.packet_tmw_version;
+ WFIFOW(ms, 16) = afi.packet_tmw_version;
FPRINTF(stderr,
"From queue index %zd: recalling packet version %d\n",
(&afi - &auth_fifo.front()), afi.packet_tmw_version);
- WFIFO_STRUCT(fd, 18, *cd);
- WFIFOSET(fd, WFIFOW(fd, 2));
+ WFIFO_STRUCT(ms, 18, *cd);
+ WFIFOSET(ms, WFIFOW(ms, 2));
//PRINTF("auth_fifo search success (auth #%d, account %d, character: %d).\n", i, RFIFOL(fd,2), RFIFOL(fd,6));
goto x2afc_out;
}
}
{
- WFIFOW(fd, 0) = 0x2afe;
- WFIFOL(fd, 2) = account_id;
- WFIFOSET(fd, 6);
+ WFIFOW(ms, 0) = 0x2afe;
+ WFIFOL(ms, 2) = account_id;
+ WFIFOSET(ms, 6);
PRINTF("auth_fifo search error! account %d not authentified.\n",
account_id);
}
}
x2afc_out:
- RFIFOSKIP(fd, 22);
+ RFIFOSKIP(ms, 22);
break;
// MAPサーバー上のユーザー数受信
case 0x2aff:
- if (RFIFOREST(fd) < 6 || RFIFOREST(fd) < RFIFOW(fd, 2))
+ if (RFIFOREST(ms) < 6 || RFIFOREST(ms) < RFIFOW(ms, 2))
return;
- server[id].users = RFIFOW(fd, 4);
+ server[id].users = RFIFOW(ms, 4);
if (anti_freeze_enable)
server_freezeflag[id] = 5; // Map anti-freeze system. Counter. 5 ok, 4...0 freezed
// remove all previously online players of the server
- for (int& oci : online_chars)
- if (oci == id)
- oci = -1;
+ for (Session *& oci : online_chars)
+ {
+ // there was a bug here
+ if (oci == ms)
+ oci = nullptr;
+ }
// add online players in the list by [Yor]
for (int i = 0; i < server[id].users; i++)
{
- int char_id = RFIFOL(fd, 6 + i * 4);
+ int char_id = RFIFOL(ms, 6 + i * 4);
for (const mmo_charstatus& cd : char_data)
+ {
if (cd.char_id == char_id)
{
- online_chars[&cd - &char_data.front()] = id;
+ server_for_m(&cd) = ms;
break;
}
+ }
}
if (update_online < TimeT::now())
{
@@ -1696,244 +1726,244 @@ void parse_frommap(int fd)
// only every 8 sec. (normally, 1 server send users every 5 sec.) Don't update every time, because that takes time, but only every 2 connection.
// it set to 8 sec because is more than 5 (sec) and if we have more than 1 map-server, informations can be received in shifted.
}
- RFIFOSKIP(fd, RFIFOW(fd, 2));
+ RFIFOSKIP(ms, RFIFOW(ms, 2));
break;
// キャラデータ保存
case 0x2b01:
- if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd, 2))
+ if (RFIFOREST(ms) < 4 || RFIFOREST(ms) < RFIFOW(ms, 2))
return;
for (mmo_charstatus& cd : char_data)
{
- if (cd.account_id == RFIFOL(fd, 4) &&
- cd.char_id == RFIFOL(fd, 8))
+ if (cd.account_id == RFIFOL(ms, 4) &&
+ cd.char_id == RFIFOL(ms, 8))
{
- RFIFO_STRUCT(fd, 12, cd);
+ RFIFO_STRUCT(ms, 12, cd);
break;
}
}
- RFIFOSKIP(fd, RFIFOW(fd, 2));
+ RFIFOSKIP(ms, RFIFOW(ms, 2));
break;
// キャラセレ要求
case 0x2b02:
- if (RFIFOREST(fd) < 18)
+ if (RFIFOREST(ms) < 18)
return;
{
- int account_id = RFIFOL(fd, 2);
+ int account_id = RFIFOL(ms, 2);
if (auth_fifo_iter == auth_fifo.end())
auth_fifo_iter = auth_fifo.begin();
auth_fifo_iter->account_id = account_id;
auth_fifo_iter->char_id = 0;
- auth_fifo_iter->login_id1 = RFIFOL(fd, 6);
- auth_fifo_iter->login_id2 = RFIFOL(fd, 10);
+ auth_fifo_iter->login_id1 = RFIFOL(ms, 6);
+ auth_fifo_iter->login_id2 = RFIFOL(ms, 10);
auth_fifo_iter->delflag = 2;
auth_fifo_iter->connect_until_time = TimeT(); // unlimited/unknown time by default (not display in map-server)
- auth_fifo_iter->ip = RFIFOIP(fd, 14);
+ auth_fifo_iter->ip = RFIFOIP(ms, 14);
auth_fifo_iter++;
- WFIFOW(fd, 0) = 0x2b03;
- WFIFOL(fd, 2) = account_id;
- WFIFOB(fd, 6) = 0;
- WFIFOSET(fd, 7);
+ WFIFOW(ms, 0) = 0x2b03;
+ WFIFOL(ms, 2) = account_id;
+ WFIFOB(ms, 6) = 0;
+ WFIFOSET(ms, 7);
}
- RFIFOSKIP(fd, 18);
+ RFIFOSKIP(ms, 18);
break;
// マップサーバー間移動要求
case 0x2b05:
- if (RFIFOREST(fd) < 49)
+ if (RFIFOREST(ms) < 49)
return;
if (auth_fifo_iter == auth_fifo.end())
auth_fifo_iter = auth_fifo.begin();
- RFIFO_WFIFO_CLONE(fd, fd, 44);
+ RFIFO_WFIFO_CLONE(ms, ms, 44);
// overwrite
- WFIFOW(fd, 0) = 0x2b06;
- auth_fifo_iter->account_id = RFIFOL(fd, 2);
- auth_fifo_iter->char_id = RFIFOL(fd, 14);
- auth_fifo_iter->login_id1 = RFIFOL(fd, 6);
- auth_fifo_iter->login_id2 = RFIFOL(fd, 10);
+ WFIFOW(ms, 0) = 0x2b06;
+ auth_fifo_iter->account_id = RFIFOL(ms, 2);
+ auth_fifo_iter->char_id = RFIFOL(ms, 14);
+ auth_fifo_iter->login_id1 = RFIFOL(ms, 6);
+ auth_fifo_iter->login_id2 = RFIFOL(ms, 10);
auth_fifo_iter->delflag = 0;
- auth_fifo_iter->sex = static_cast<SEX>(RFIFOB(fd, 44));
+ auth_fifo_iter->sex = static_cast<SEX>(RFIFOB(ms, 44));
auth_fifo_iter->connect_until_time = TimeT(); // unlimited/unknown time by default (not display in map-server)
- auth_fifo_iter->ip = RFIFOIP(fd, 45);
+ auth_fifo_iter->ip = RFIFOIP(ms, 45);
// default, if not found in the loop
- WFIFOW(fd, 6) = 1;
+ WFIFOW(ms, 6) = 1;
for (const mmo_charstatus& cd : char_data)
- if (cd.account_id == RFIFOL(fd, 2) &&
- cd.char_id == RFIFOL(fd, 14))
+ if (cd.account_id == RFIFOL(ms, 2) &&
+ cd.char_id == RFIFOL(ms, 14))
{
auth_fifo_iter++;
- WFIFOL(fd, 6) = 0;
+ WFIFOL(ms, 6) = 0;
break;
}
- WFIFOSET(fd, 44);
- RFIFOSKIP(fd, 49);
+ WFIFOSET(ms, 44);
+ RFIFOSKIP(ms, 49);
break;
// it is a request to become GM
case 0x2b0a:
- if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd, 2))
+ if (RFIFOREST(ms) < 4 || RFIFOREST(ms) < RFIFOW(ms, 2))
return;
{
- int account_id = RFIFOL(fd, 4);
- if (login_fd > 0)
+ int account_id = RFIFOL(ms, 4);
+ if (login_session)
{ // don't send request if no login-server
- size_t len = RFIFOW(fd, 2);
- RFIFO_WFIFO_CLONE(fd, login_fd, len);
- WFIFOW(login_fd, 0) = 0x2720;
- WFIFOSET(login_fd, len);
+ size_t len = RFIFOW(ms, 2);
+ RFIFO_WFIFO_CLONE(ms, login_session, len);
+ WFIFOW(login_session, 0) = 0x2720;
+ WFIFOSET(login_session, len);
}
else
{
- WFIFOW(fd, 0) = 0x2b0b;
- WFIFOL(fd, 2) = account_id;
- WFIFOL(fd, 6) = 0;
- WFIFOSET(fd, 10);
+ WFIFOW(ms, 0) = 0x2b0b;
+ WFIFOL(ms, 2) = account_id;
+ WFIFOL(ms, 6) = 0;
+ WFIFOSET(ms, 10);
}
}
- RFIFOSKIP(fd, RFIFOW(fd, 2));
+ RFIFOSKIP(ms, RFIFOW(ms, 2));
break;
// Map server send information to change an email of an account -> login-server
case 0x2b0c:
- if (RFIFOREST(fd) < 86)
+ if (RFIFOREST(ms) < 86)
return;
- if (login_fd > 0)
+ if (login_session)
{ // don't send request if no login-server
- RFIFO_WFIFO_CLONE(fd, login_fd, 86); // 0x2722 <account_id>.L <actual_e-mail>.40B <new_e-mail>.40B
- WFIFOW(login_fd, 0) = 0x2722;
- WFIFOSET(login_fd, 86);
+ RFIFO_WFIFO_CLONE(ms, login_session, 86); // 0x2722 <account_id>.L <actual_e-mail>.40B <new_e-mail>.40B
+ WFIFOW(login_session, 0) = 0x2722;
+ WFIFOSET(login_session, 86);
}
- RFIFOSKIP(fd, 86);
+ RFIFOSKIP(ms, 86);
break;
// Map server ask char-server about a character name to do some operations (all operations are transmitted to login-server)
case 0x2b0e:
- if (RFIFOREST(fd) < 44)
+ if (RFIFOREST(ms) < 44)
return;
{
- int acc = RFIFOL(fd, 2); // account_id of who ask (-1 if nobody)
- CharName character_name = stringish<CharName>(RFIFO_STRING<24>(fd, 6));
- int operation = RFIFOW(fd, 30);
+ int acc = RFIFOL(ms, 2); // account_id of who ask (-1 if nobody)
+ CharName character_name = stringish<CharName>(RFIFO_STRING<24>(ms, 6));
+ int operation = RFIFOW(ms, 30);
// prepare answer
- WFIFOW(fd, 0) = 0x2b0f; // answer
- WFIFOL(fd, 2) = acc; // who want do operation
- WFIFOW(fd, 30) = operation; // type of operation: 1-block, 2-ban, 3-unblock, 4-unban, 5-changesex
+ WFIFOW(ms, 0) = 0x2b0f; // answer
+ WFIFOL(ms, 2) = acc; // who want do operation
+ WFIFOW(ms, 30) = operation; // type of operation: 1-block, 2-ban, 3-unblock, 4-unban, 5-changesex
// search character
const mmo_charstatus *cd = search_character(character_name);
if (cd)
{
- WFIFO_STRING(fd, 6, cd->name.to__actual(), 24); // put correct name if found
- WFIFOW(fd, 32) = 0; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
- switch (RFIFOW(fd, 30))
+ WFIFO_STRING(ms, 6, cd->name.to__actual(), 24); // put correct name if found
+ WFIFOW(ms, 32) = 0; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
+ switch (RFIFOW(ms, 30))
{
case 1: // block
if (acc == -1
|| isGM(acc) >= isGM(cd->account_id))
{
- if (login_fd > 0)
+ if (login_session)
{ // don't send request if no login-server
- WFIFOW(login_fd, 0) = 0x2724;
- WFIFOL(login_fd, 2) = cd->account_id; // account value
- WFIFOL(login_fd, 6) = 5; // status of the account
- WFIFOSET(login_fd, 10);
+ WFIFOW(login_session, 0) = 0x2724;
+ WFIFOL(login_session, 2) = cd->account_id; // account value
+ WFIFOL(login_session, 6) = 5; // status of the account
+ WFIFOSET(login_session, 10);
// PRINTF("char : status -> login: account %d, status: %d \n", char_data[i].account_id, 5);
}
else
- WFIFOW(fd, 32) = 3; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
+ WFIFOW(ms, 32) = 3; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
}
else
- WFIFOW(fd, 32) = 2; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
+ WFIFOW(ms, 32) = 2; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
break;
case 2: // ban
if (acc == -1
|| isGM(acc) >= isGM(cd->account_id))
{
- if (login_fd > 0)
+ if (login_session)
{ // don't send request if no login-server
- WFIFOW(login_fd, 0) = 0x2725;
- WFIFOL(login_fd, 2) = cd->account_id; // account value
+ WFIFOW(login_session, 0) = 0x2725;
+ WFIFOL(login_session, 2) = cd->account_id; // account value
HumanTimeDiff ban_change;
- RFIFO_STRUCT(fd, 32, ban_change);
- WFIFO_STRUCT(login_fd, 6, ban_change);
- WFIFOSET(login_fd, 18);
+ RFIFO_STRUCT(ms, 32, ban_change);
+ WFIFO_STRUCT(login_session, 6, ban_change);
+ WFIFOSET(login_session, 18);
// PRINTF("char : status -> login: account %d, ban: %dy %dm %dd %dh %dmn %ds\n",
// char_data[i].account_id, (short)RFIFOW(fd,32), (short)RFIFOW(fd,34), (short)RFIFOW(fd,36), (short)RFIFOW(fd,38), (short)RFIFOW(fd,40), (short)RFIFOW(fd,42));
}
else
- WFIFOW(fd, 32) = 3; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
+ WFIFOW(ms, 32) = 3; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
}
else
- WFIFOW(fd, 32) = 2; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
+ WFIFOW(ms, 32) = 2; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
break;
case 3: // unblock
if (acc == -1
|| isGM(acc) >= isGM(cd->account_id))
{
- if (login_fd > 0)
+ if (login_session)
{ // don't send request if no login-server
- WFIFOW(login_fd, 0) = 0x2724;
- WFIFOL(login_fd, 2) = cd->account_id; // account value
- WFIFOL(login_fd, 6) = 0; // status of the account
- WFIFOSET(login_fd, 10);
+ WFIFOW(login_session, 0) = 0x2724;
+ WFIFOL(login_session, 2) = cd->account_id; // account value
+ WFIFOL(login_session, 6) = 0; // status of the account
+ WFIFOSET(login_session, 10);
// PRINTF("char : status -> login: account %d, status: %d \n", char_data[i].account_id, 0);
}
else
- WFIFOW(fd, 32) = 3; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
+ WFIFOW(ms, 32) = 3; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
}
else
- WFIFOW(fd, 32) = 2; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
+ WFIFOW(ms, 32) = 2; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
break;
case 4: // unban
if (acc == -1
|| isGM(acc) >= isGM(cd->account_id))
{
- if (login_fd > 0)
+ if (login_session)
{ // don't send request if no login-server
- WFIFOW(login_fd, 0) = 0x272a;
- WFIFOL(login_fd, 2) = cd->account_id; // account value
- WFIFOSET(login_fd, 6);
+ WFIFOW(login_session, 0) = 0x272a;
+ WFIFOL(login_session, 2) = cd->account_id; // account value
+ WFIFOSET(login_session, 6);
// PRINTF("char : status -> login: account %d, unban request\n", char_data[i].account_id);
}
else
- WFIFOW(fd, 32) = 3; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
+ WFIFOW(ms, 32) = 3; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
}
else
- WFIFOW(fd, 32) = 2; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
+ WFIFOW(ms, 32) = 2; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
break;
case 5: // changesex
if (acc == -1
|| isGM(acc) >= isGM(cd->account_id))
{
- if (login_fd > 0)
+ if (login_session)
{ // don't send request if no login-server
- WFIFOW(login_fd, 0) = 0x2727;
- WFIFOL(login_fd, 2) = cd->account_id; // account value
- WFIFOSET(login_fd, 6);
+ WFIFOW(login_session, 0) = 0x2727;
+ WFIFOL(login_session, 2) = cd->account_id; // account value
+ WFIFOSET(login_session, 6);
// PRINTF("char : status -> login: account %d, change sex request\n", char_data[i].account_id);
}
else
- WFIFOW(fd, 32) = 3; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
+ WFIFOW(ms, 32) = 3; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
}
else
- WFIFOW(fd, 32) = 2; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
+ WFIFOW(ms, 32) = 2; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
break;
}
}
else
{
// character name not found
- WFIFO_STRING(fd, 6, character_name.to__actual(), 24);
- WFIFOW(fd, 32) = 1; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
+ WFIFO_STRING(ms, 6, character_name.to__actual(), 24);
+ WFIFOW(ms, 32) = 1; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
}
// send answer if a player ask, not if the server ask
if (acc != -1)
{
- WFIFOSET(fd, 34);
+ WFIFOSET(ms, 34);
}
- RFIFOSKIP(fd, 44);
+ RFIFOSKIP(ms, 44);
break;
}
@@ -1941,45 +1971,45 @@ void parse_frommap(int fd)
// account_reg保存要求
case 0x2b10:
- if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd, 2))
+ if (RFIFOREST(ms) < 4 || RFIFOREST(ms) < RFIFOW(ms, 2))
return;
{
struct global_reg reg[ACCOUNT_REG2_NUM];
int p, j;
- int acc = RFIFOL(fd, 4);
+ int acc = RFIFOL(ms, 4);
for (p = 8, j = 0;
- p < RFIFOW(fd, 2) && j < ACCOUNT_REG2_NUM;
+ p < RFIFOW(ms, 2) && j < ACCOUNT_REG2_NUM;
p += 36, j++)
{
- reg[j].str = stringish<VarName>(RFIFO_STRING<32>(fd, p));
- reg[j].value = RFIFOL(fd, p + 32);
+ reg[j].str = stringish<VarName>(RFIFO_STRING<32>(ms, p));
+ reg[j].value = RFIFOL(ms, p + 32);
}
set_account_reg2(acc, j, reg);
// loginサーバーへ送る
- if (login_fd > 0)
+ if (login_session)
{
// don't send request if no login-server
- RFIFO_WFIFO_CLONE(fd, login_fd, RFIFOW(fd, 2));
- WFIFOW(login_fd, 0) = 0x2728;
- WFIFOSET(login_fd, WFIFOW(login_fd, 2));
+ RFIFO_WFIFO_CLONE(ms, login_session, RFIFOW(ms, 2));
+ WFIFOW(login_session, 0) = 0x2728;
+ WFIFOSET(login_session, WFIFOW(login_session, 2));
}
- RFIFOSKIP(fd, RFIFOW(fd, 2));
+ RFIFOSKIP(ms, RFIFOW(ms, 2));
break;
}
// Map server is requesting a divorce
case 0x2b16:
- if (RFIFOREST(fd) < 4)
+ if (RFIFOREST(ms) < 4)
return;
{
for (mmo_charstatus& cd : char_data)
- if (cd.char_id == RFIFOL(fd, 2))
+ if (cd.char_id == RFIFOL(ms, 2))
{
char_divorce(&cd);
break;
}
- RFIFOSKIP(fd, 6);
+ RFIFOSKIP(ms, 6);
break;
}
@@ -1987,7 +2017,7 @@ void parse_frommap(int fd)
default:
// inter server処理に渡す
{
- int r = inter_parse_frommap(fd);
+ int r = inter_parse_frommap(ms);
if (r == 1) // 処理できた
break;
if (r == 2) // パケット長が足りない
@@ -1995,8 +2025,8 @@ void parse_frommap(int fd)
}
// inter server処理でもない場合は切断
PRINTF("char: unknown packet 0x%04x (%zu bytes to read in buffer)! (from map).\n",
- RFIFOW(fd, 0), RFIFOREST(fd));
- session[fd]->eof = 1;
+ RFIFOW(ms, 0), RFIFOREST(ms));
+ ms->eof = 1;
return;
}
}
@@ -2006,10 +2036,16 @@ static
int search_mapserver(XString map)
{
for (int i = 0; i < MAX_MAP_SERVERS; i++)
- if (server_fd[i] >= 0)
+ {
+ if (server_session[i])
+ {
for (int j = 0; server[i].maps[j]; j++)
+ {
if (server[i].maps[j] == map)
return i;
+ }
+ }
+ }
return -1;
}
@@ -2028,7 +2064,7 @@ int lan_ip_check(IP4Address addr)
}
static
-void handle_x0066(int fd, struct char_session_data *sd, uint8_t rfifob_2, IP4Address ip)
+void handle_x0066(Session *s, struct char_session_data *sd, uint8_t rfifob_2, IP4Address ip)
{
{
mmo_charstatus *cd = nullptr;
@@ -2054,7 +2090,7 @@ void handle_x0066(int fd, struct char_session_data *sd, uint8_t rfifob_2, IP4Add
// get first online server (with a map)
i = 0;
for (j = 0; j < MAX_MAP_SERVERS; j++)
- if (server_fd[j] >= 0
+ if (server_session[j]
&& server[j].maps[0])
{ // change save point to one of map found on the server (the first)
i = j;
@@ -2067,25 +2103,25 @@ void handle_x0066(int fd, struct char_session_data *sd, uint8_t rfifob_2, IP4Add
// if no map-server is connected, we send: server closed
if (j == MAX_MAP_SERVERS)
{
- WFIFOW(fd, 0) = 0x81;
- WFIFOB(fd, 2) = 1; // 01 = Server closed
- WFIFOSET(fd, 3);
+ WFIFOW(s, 0) = 0x81;
+ WFIFOB(s, 2) = 1; // 01 = Server closed
+ WFIFOSET(s, 3);
return;
}
}
- WFIFOW(fd, 0) = 0x71;
- WFIFOL(fd, 2) = cd->char_id;
- WFIFO_STRING(fd, 6, cd->last_point.map_, 16);
+ WFIFOW(s, 0) = 0x71;
+ WFIFOL(s, 2) = cd->char_id;
+ WFIFO_STRING(s, 6, cd->last_point.map_, 16);
PRINTF("Character selection '%s' (account: %d, slot: %d) [%s]\n",
cd->name,
sd->account_id, cd->char_num, ip);
PRINTF("--Send IP of map-server. ");
if (lan_ip_check(ip))
- WFIFOIP(fd, 22) = lan_map_ip;
+ WFIFOIP(s, 22) = lan_map_ip;
else
- WFIFOIP(fd, 22) = server[i].ip;
- WFIFOW(fd, 26) = server[i].port;
- WFIFOSET(fd, 28);
+ WFIFOIP(s, 22) = server[i].ip;
+ WFIFOW(s, 26) = server[i].port;
+ WFIFOSET(s, 28);
if (auth_fifo_iter == auth_fifo.end())
auth_fifo_iter = auth_fifo.begin();
auth_fifo_iter->account_id = sd->account_id;
@@ -2095,7 +2131,7 @@ void handle_x0066(int fd, struct char_session_data *sd, uint8_t rfifob_2, IP4Add
auth_fifo_iter->delflag = 0;
auth_fifo_iter->sex = sd->sex;
auth_fifo_iter->connect_until_time = sd->connect_until_time;
- auth_fifo_iter->ip = session[fd]->client_ip;
+ auth_fifo_iter->ip = s->client_ip;
auth_fifo_iter->packet_tmw_version = sd->packet_tmw_version;
auth_fifo_iter++;
}
@@ -2103,53 +2139,53 @@ void handle_x0066(int fd, struct char_session_data *sd, uint8_t rfifob_2, IP4Add
}
static
-void parse_char(int fd)
+void parse_char(Session *s)
{
- IP4Address ip = session[fd]->client_ip;
+ IP4Address ip = s->client_ip;
- if (login_fd < 0 || session[fd]->eof)
+ if (!login_session || s->eof)
{ // disconnect any player (already connected to char-server or coming back from map-server) if login-server is diconnected.
- if (fd == login_fd)
- login_fd = -1;
- delete_session(fd);
+ if (s == login_session)
+ login_session = nullptr;
+ delete_session(s);
return;
}
- char_session_data *sd = static_cast<char_session_data *>(session[fd]->session_data.get());
+ char_session_data *sd = static_cast<char_session_data *>(s->session_data.get());
- while (RFIFOREST(fd) >= 2)
+ while (RFIFOREST(s) >= 2)
{
// if (RFIFOW(fd,0) < 30000)
// PRINTF("parse_char: connection #%d, packet: 0x%x (with being read: %d bytes).\n", fd, RFIFOW(fd,0), RFIFOREST(fd));
- switch (RFIFOW(fd, 0))
+ switch (RFIFOW(s, 0))
{
case 0x20b: //20040622暗号化ragexe対応
- if (RFIFOREST(fd) < 19)
+ if (RFIFOREST(s) < 19)
return;
- RFIFOSKIP(fd, 19);
+ RFIFOSKIP(s, 19);
break;
case 0x61: // change password request
- if (RFIFOREST(fd) < 50)
+ if (RFIFOREST(s) < 50)
return;
{
- WFIFOW(login_fd, 0) = 0x2740;
- WFIFOL(login_fd, 2) = sd->account_id;
- AccountPass old_pass = stringish<AccountPass>(RFIFO_STRING<24>(fd, 2));
- WFIFO_STRING(login_fd, 6, old_pass, 24);
- AccountPass new_pass = stringish<AccountPass>(RFIFO_STRING<24>(fd, 26));
- WFIFO_STRING(login_fd, 30, new_pass, 24);
- WFIFOSET(login_fd, 54);
+ WFIFOW(login_session, 0) = 0x2740;
+ WFIFOL(login_session, 2) = sd->account_id;
+ AccountPass old_pass = stringish<AccountPass>(RFIFO_STRING<24>(s, 2));
+ WFIFO_STRING(login_session, 6, old_pass, 24);
+ AccountPass new_pass = stringish<AccountPass>(RFIFO_STRING<24>(s, 26));
+ WFIFO_STRING(login_session, 30, new_pass, 24);
+ WFIFOSET(login_session, 54);
}
- RFIFOSKIP(fd, 50);
+ RFIFOSKIP(s, 50);
break;
case 0x65: // 接続要求
- if (RFIFOREST(fd) < 17)
+ if (RFIFOREST(s) < 17)
return;
{
- int account_id = RFIFOL(fd, 2);
+ int account_id = RFIFOL(s, 2);
int GM_value = isGM(account_id);
if (GM_value)
PRINTF("Account Logged On; Account ID: %d (GM level %d).\n",
@@ -2159,19 +2195,19 @@ void parse_char(int fd)
account_id);
if (sd == NULL)
{
- session[fd]->session_data = make_unique<char_session_data, SessionDeleter>();
- sd = static_cast<char_session_data *>(session[fd]->session_data.get());
+ s->session_data = make_unique<char_session_data, SessionDeleter>();
+ sd = static_cast<char_session_data *>(s->session_data.get());
sd->email = stringish<AccountEmail>("no mail"); // put here a mail without '@' to refuse deletion if we don't receive the e-mail
sd->connect_until_time = TimeT(); // unknow or illimited (not displaying on map-server)
}
sd->account_id = account_id;
- sd->login_id1 = RFIFOL(fd, 6);
- sd->login_id2 = RFIFOL(fd, 10);
- sd->packet_tmw_version = RFIFOW(fd, 14);
- sd->sex = static_cast<SEX>(RFIFOB(fd, 16));
+ sd->login_id1 = RFIFOL(s, 6);
+ sd->login_id2 = RFIFOL(s, 10);
+ sd->packet_tmw_version = RFIFOW(s, 14);
+ sd->sex = static_cast<SEX>(RFIFOB(s, 16));
// send back account_id
- WFIFOL(fd, 0) = account_id;
- WFIFOSET(fd, 4);
+ WFIFOL(s, 0) = account_id;
+ WFIFOSET(s, 4);
// search authentification
for (AuthFifoEntry& afi : auth_fifo)
{
@@ -2179,138 +2215,138 @@ void parse_char(int fd)
&& afi.login_id1 == sd->login_id1
&& afi.login_id2 == sd->login_id2
&& (!check_ip_flag
- || afi.ip == session[fd]->client_ip)
+ || afi.ip == s->client_ip)
&& afi.delflag == 2)
{
afi.delflag = 1;
if (max_connect_user == 0
|| count_users() < max_connect_user)
{
- if (login_fd > 0)
+ if (login_session)
{ // don't send request if no login-server
// request to login-server to obtain e-mail/time limit
- WFIFOW(login_fd, 0) = 0x2716;
- WFIFOL(login_fd, 2) = sd->account_id;
- WFIFOSET(login_fd, 6);
+ WFIFOW(login_session, 0) = 0x2716;
+ WFIFOL(login_session, 2) = sd->account_id;
+ WFIFOSET(login_session, 6);
}
// Record client version
afi.packet_tmw_version =
sd->packet_tmw_version;
// send characters to player
- mmo_char_send006b(fd, sd);
+ mmo_char_send006b(s, sd);
}
else
{
// refuse connection (over populated)
- WFIFOW(fd, 0) = 0x6c;
- WFIFOB(fd, 2) = 0;
- WFIFOSET(fd, 3);
+ WFIFOW(s, 0) = 0x6c;
+ WFIFOB(s, 2) = 0;
+ WFIFOSET(s, 3);
}
goto x65_out;
}
}
// authentification not found
{
- if (login_fd > 0)
+ if (login_session)
{
// don't send request if no login-server
- WFIFOW(login_fd, 0) = 0x2712; // ask login-server to authentify an account
- WFIFOL(login_fd, 2) = sd->account_id;
- WFIFOL(login_fd, 6) = sd->login_id1;
- WFIFOL(login_fd, 10) = sd->login_id2; // relate to the versions higher than 18
- WFIFOB(login_fd, 14) = static_cast<uint8_t>(sd->sex);
- WFIFOIP(login_fd, 15) = session[fd]->client_ip;
- WFIFOSET(login_fd, 19);
+ WFIFOW(login_session, 0) = 0x2712; // ask login-server to authentify an account
+ WFIFOL(login_session, 2) = sd->account_id;
+ WFIFOL(login_session, 6) = sd->login_id1;
+ WFIFOL(login_session, 10) = sd->login_id2; // relate to the versions higher than 18
+ WFIFOB(login_session, 14) = static_cast<uint8_t>(sd->sex);
+ WFIFOIP(login_session, 15) = s->client_ip;
+ WFIFOSET(login_session, 19);
}
else
{ // if no login-server, we must refuse connection
- WFIFOW(fd, 0) = 0x6c;
- WFIFOB(fd, 2) = 0;
- WFIFOSET(fd, 3);
+ WFIFOW(s, 0) = 0x6c;
+ WFIFOB(s, 2) = 0;
+ WFIFOSET(s, 3);
}
}
}
x65_out:
- RFIFOSKIP(fd, 17);
+ RFIFOSKIP(s, 17);
break;
case 0x66: // キャラ選択
- if (!sd || RFIFOREST(fd) < 3)
+ if (!sd || RFIFOREST(s) < 3)
return;
- handle_x0066(fd, sd, RFIFOB(fd, 2), ip);
- RFIFOSKIP(fd, 3);
+ handle_x0066(s, sd, RFIFOB(s, 2), ip);
+ RFIFOSKIP(s, 3);
break;
case 0x67: // 作成
- if (!sd || RFIFOREST(fd) < 37)
+ if (!sd || RFIFOREST(s) < 37)
return;
{
- CharName name = stringish<CharName>(RFIFO_STRING<24>(fd, 2));
+ CharName name = stringish<CharName>(RFIFO_STRING<24>(s, 2));
uint8_t stats[6];
for (int i = 0; i < 6; ++i)
- stats[i] = RFIFOB(fd, 26 + i);
- uint8_t slot = RFIFOB(fd, 32);
- uint16_t hair_color = RFIFOW(fd, 33);
- uint16_t hair_style = RFIFOW(fd, 35);
- const struct mmo_charstatus *cd = make_new_char(fd, name, stats, slot, hair_color, hair_style);
+ stats[i] = RFIFOB(s, 26 + i);
+ uint8_t slot = RFIFOB(s, 32);
+ uint16_t hair_color = RFIFOW(s, 33);
+ uint16_t hair_style = RFIFOW(s, 35);
+ const struct mmo_charstatus *cd = make_new_char(s, name, stats, slot, hair_color, hair_style);
if (!cd)
{
- WFIFOW(fd, 0) = 0x6e;
- WFIFOB(fd, 2) = 0x00;
- WFIFOSET(fd, 3);
- RFIFOSKIP(fd, 37);
+ WFIFOW(s, 0) = 0x6e;
+ WFIFOB(s, 2) = 0x00;
+ WFIFOSET(s, 3);
+ RFIFOSKIP(s, 37);
break;
}
- WFIFOW(fd, 0) = 0x6d;
- WFIFO_ZERO(fd, 2, 106);
-
- WFIFOL(fd, 2) = cd->char_id;
- WFIFOL(fd, 2 + 4) = cd->base_exp;
- WFIFOL(fd, 2 + 8) = cd->zeny;
- WFIFOL(fd, 2 + 12) = cd->job_exp;
- WFIFOL(fd, 2 + 16) = cd->job_level;
-
- WFIFOL(fd, 2 + 28) = cd->karma;
- WFIFOL(fd, 2 + 32) = cd->manner;
-
- WFIFOW(fd, 2 + 40) = 0x30;
- WFIFOW(fd, 2 + 42) = min(cd->hp, 0x7fff);
- WFIFOW(fd, 2 + 44) = min(cd->max_hp, 0x7fff);
- WFIFOW(fd, 2 + 46) = min(cd->sp, 0x7fff);
- WFIFOW(fd, 2 + 48) = min(cd->max_sp, 0x7fff);
- WFIFOW(fd, 2 + 50) = static_cast<uint16_t>(DEFAULT_WALK_SPEED.count()); // char_data[i].speed;
- WFIFOW(fd, 2 + 52) = cd->species;
- WFIFOW(fd, 2 + 54) = cd->hair;
-
- WFIFOW(fd, 2 + 58) = cd->base_level;
- WFIFOW(fd, 2 + 60) = cd->skill_point;
-
- WFIFOW(fd, 2 + 64) = cd->shield;
- WFIFOW(fd, 2 + 66) = cd->head_top;
- WFIFOW(fd, 2 + 68) = cd->head_mid;
- WFIFOW(fd, 2 + 70) = cd->hair_color;
-
- WFIFO_STRING(fd, 2 + 74, cd->name.to__actual(), 24);
-
- WFIFOB(fd, 2 + 98) = min(cd->attrs[ATTR::STR], 255);
- WFIFOB(fd, 2 + 99) = min(cd->attrs[ATTR::AGI], 255);
- WFIFOB(fd, 2 + 100) = min(cd->attrs[ATTR::VIT], 255);
- WFIFOB(fd, 2 + 101) = min(cd->attrs[ATTR::INT], 255);
- WFIFOB(fd, 2 + 102) = min(cd->attrs[ATTR::DEX], 255);
- WFIFOB(fd, 2 + 103) = min(cd->attrs[ATTR::LUK], 255);
- WFIFOB(fd, 2 + 104) = cd->char_num;
-
- WFIFOSET(fd, 108);
+ WFIFOW(s, 0) = 0x6d;
+ WFIFO_ZERO(s, 2, 106);
+
+ WFIFOL(s, 2) = cd->char_id;
+ WFIFOL(s, 2 + 4) = cd->base_exp;
+ WFIFOL(s, 2 + 8) = cd->zeny;
+ WFIFOL(s, 2 + 12) = cd->job_exp;
+ WFIFOL(s, 2 + 16) = cd->job_level;
+
+ WFIFOL(s, 2 + 28) = cd->karma;
+ WFIFOL(s, 2 + 32) = cd->manner;
+
+ WFIFOW(s, 2 + 40) = 0x30;
+ WFIFOW(s, 2 + 42) = min(cd->hp, 0x7fff);
+ WFIFOW(s, 2 + 44) = min(cd->max_hp, 0x7fff);
+ WFIFOW(s, 2 + 46) = min(cd->sp, 0x7fff);
+ WFIFOW(s, 2 + 48) = min(cd->max_sp, 0x7fff);
+ WFIFOW(s, 2 + 50) = static_cast<uint16_t>(DEFAULT_WALK_SPEED.count()); // char_data[i].speed;
+ WFIFOW(s, 2 + 52) = cd->species;
+ WFIFOW(s, 2 + 54) = cd->hair;
+
+ WFIFOW(s, 2 + 58) = cd->base_level;
+ WFIFOW(s, 2 + 60) = cd->skill_point;
+
+ WFIFOW(s, 2 + 64) = cd->shield;
+ WFIFOW(s, 2 + 66) = cd->head_top;
+ WFIFOW(s, 2 + 68) = cd->head_mid;
+ WFIFOW(s, 2 + 70) = cd->hair_color;
+
+ WFIFO_STRING(s, 2 + 74, cd->name.to__actual(), 24);
+
+ WFIFOB(s, 2 + 98) = min(cd->attrs[ATTR::STR], 255);
+ WFIFOB(s, 2 + 99) = min(cd->attrs[ATTR::AGI], 255);
+ WFIFOB(s, 2 + 100) = min(cd->attrs[ATTR::VIT], 255);
+ WFIFOB(s, 2 + 101) = min(cd->attrs[ATTR::INT], 255);
+ WFIFOB(s, 2 + 102) = min(cd->attrs[ATTR::DEX], 255);
+ WFIFOB(s, 2 + 103) = min(cd->attrs[ATTR::LUK], 255);
+ WFIFOB(s, 2 + 104) = cd->char_num;
+
+ WFIFOSET(s, 108);
}
- RFIFOSKIP(fd, 37);
+ RFIFOSKIP(s, 37);
break;
case 0x68: // delete char //Yor's Fix
- if (!sd || RFIFOREST(fd) < 46)
+ if (!sd || RFIFOREST(s) < 46)
return;
{
- AccountEmail email = stringish<AccountEmail>(RFIFO_STRING<40>(fd, 6));
+ AccountEmail email = stringish<AccountEmail>(RFIFO_STRING<40>(s, 6));
if (!e_mail_check(email))
email = DEFAULT_EMAIL;
@@ -2319,7 +2355,7 @@ void parse_char(int fd)
struct mmo_charstatus *cs = nullptr;
for (mmo_charstatus& cd : char_data)
{
- if (cd.char_id == RFIFOL(fd, 2))
+ if (cd.char_id == RFIFOL(s, 2))
{
cs = &cd;
break;
@@ -2336,96 +2372,96 @@ void parse_char(int fd)
}
char_data.pop_back();
- WFIFOW(fd, 0) = 0x6f;
- WFIFOSET(fd, 2);
+ WFIFOW(s, 0) = 0x6f;
+ WFIFOSET(s, 2);
goto x68_out;
}
}
{
- WFIFOW(fd, 0) = 0x70;
- WFIFOB(fd, 2) = 0;
- WFIFOSET(fd, 3);
+ WFIFOW(s, 0) = 0x70;
+ WFIFOB(s, 2) = 0;
+ WFIFOSET(s, 3);
}
}
}
x68_out:
- RFIFOSKIP(fd, 46);
+ RFIFOSKIP(s, 46);
break;
case 0x2af8: // マップサーバーログイン
- if (RFIFOREST(fd) < 60)
+ if (RFIFOREST(s) < 60)
return;
{
int i;
- WFIFOW(fd, 0) = 0x2af9;
+ WFIFOW(s, 0) = 0x2af9;
for (i = 0; i < MAX_MAP_SERVERS; i++)
{
- if (server_fd[i] < 0)
+ if (!server_session[i])
break;
}
- AccountName userid_ = stringish<AccountName>(RFIFO_STRING<24>(fd, 2));
- AccountPass passwd_ = stringish<AccountPass>(RFIFO_STRING<24>(fd, 26));
+ AccountName userid_ = stringish<AccountName>(RFIFO_STRING<24>(s, 2));
+ AccountPass passwd_ = stringish<AccountPass>(RFIFO_STRING<24>(s, 26));
if (i == MAX_MAP_SERVERS || userid_ != userid
|| passwd_ != passwd)
{
- WFIFOB(fd, 2) = 3;
- WFIFOSET(fd, 3);
- RFIFOSKIP(fd, 60);
+ WFIFOB(s, 2) = 3;
+ WFIFOSET(s, 3);
+ RFIFOSKIP(s, 60);
}
else
{
int len;
- WFIFOB(fd, 2) = 0;
- session[fd]->func_parse = parse_frommap;
- server_fd[i] = fd;
+ WFIFOB(s, 2) = 0;
+ s->func_parse = parse_frommap;
+ server_session[i] = s;
if (anti_freeze_enable)
server_freezeflag[i] = 5; // Map anti-freeze system. Counter. 5 ok, 4...0 freezed
// ignore RFIFOL(fd, 50)
- server[i].ip = RFIFOIP(fd, 54);
- server[i].port = RFIFOW(fd, 58);
+ server[i].ip = RFIFOIP(s, 54);
+ server[i].port = RFIFOW(s, 58);
server[i].users = 0;
for (MapName& mapi : server[i].maps)
mapi = MapName();
- WFIFOSET(fd, 3);
- RFIFOSKIP(fd, 60);
- realloc_fifo(fd, FIFOSIZE_SERVERLINK,
+ WFIFOSET(s, 3);
+ RFIFOSKIP(s, 60);
+ realloc_fifo(s, FIFOSIZE_SERVERLINK,
FIFOSIZE_SERVERLINK);
// send gm acccounts level to map-servers
len = 4;
- WFIFOW(fd, 0) = 0x2b15;
+ WFIFOW(s, 0) = 0x2b15;
for (const GM_Account& gma : gm_accounts)
{
- WFIFOL(fd, len) = gma.account_id;
- WFIFOB(fd, len + 4) = gma.level;
+ WFIFOL(s, len) = gma.account_id;
+ WFIFOB(s, len + 4) = gma.level;
len += 5;
}
- WFIFOW(fd, 2) = len;
- WFIFOSET(fd, len);
+ WFIFOW(s, 2) = len;
+ WFIFOSET(s, len);
return;
}
}
break;
case 0x187: // Alive信号?
- if (RFIFOREST(fd) < 6)
+ if (RFIFOREST(s) < 6)
return;
- RFIFOSKIP(fd, 6);
+ RFIFOSKIP(s, 6);
break;
case 0x7530: // Athena情報所得
- WFIFOW(fd, 0) = 0x7531;
- WFIFO_STRUCT(fd, 2, CURRENT_CHAR_SERVER_VERSION);
- WFIFOSET(fd, 10);
- RFIFOSKIP(fd, 2);
+ WFIFOW(s, 0) = 0x7531;
+ WFIFO_STRUCT(s, 2, CURRENT_CHAR_SERVER_VERSION);
+ WFIFOSET(s, 10);
+ RFIFOSKIP(s, 2);
return;
case 0x7532: // 接続の切断(defaultと処理は一緒だが明示的にするため)
- session[fd]->eof = 1;
+ s->eof = 1;
return;
default:
- session[fd]->eof = 1;
+ s->eof = 1;
return;
}
}
@@ -2439,11 +2475,11 @@ int mapif_sendall(const uint8_t *buf, unsigned int len)
c = 0;
for (i = 0; i < MAX_MAP_SERVERS; i++)
{
- int fd;
- if ((fd = server_fd[i]) >= 0)
+ Session *s = server_session[i];
+ if (s)
{
- WFIFO_BUF_CLONE(fd, buf, len);
- WFIFOSET(fd, len);
+ WFIFO_BUF_CLONE(s, buf, len);
+ WFIFOSET(s, len);
c++;
}
}
@@ -2451,18 +2487,18 @@ int mapif_sendall(const uint8_t *buf, unsigned int len)
}
// 自分以外の全てのMAPサーバーにデータ送信(送信したmap鯖の数を返す)
-int mapif_sendallwos(int sfd, const uint8_t *buf, unsigned int len)
+int mapif_sendallwos(Session *ss, const uint8_t *buf, unsigned int len)
{
int i, c;
c = 0;
for (i = 0; i < MAX_MAP_SERVERS; i++)
{
- int fd;
- if ((fd = server_fd[i]) >= 0 && fd != sfd)
+ Session *s = server_session[i];
+ if (s && s != ss)
{
- WFIFO_BUF_CLONE(fd, buf, len);
- WFIFOSET(fd, len);
+ WFIFO_BUF_CLONE(s, buf, len);
+ WFIFOSET(s, len);
c++;
}
}
@@ -2470,18 +2506,18 @@ int mapif_sendallwos(int sfd, const uint8_t *buf, unsigned int len)
}
// MAPサーバーにデータ送信(map鯖生存確認有り)
-int mapif_send(int fd, const uint8_t *buf, unsigned int len)
+int mapif_send(Session *s, const uint8_t *buf, unsigned int len)
{
int i;
- if (fd >= 0)
+ if (s)
{
for (i = 0; i < MAX_MAP_SERVERS; i++)
{
- if (fd == server_fd[i])
+ if (s == server_session[i])
{
- WFIFO_BUF_CLONE(fd, buf, len);
- WFIFOSET(fd, len);
+ WFIFO_BUF_CLONE(s, buf, len);
+ WFIFOSET(s, len);
return 1;
}
}
@@ -2495,12 +2531,12 @@ void send_users_tologin(TimerData *, tick_t)
int users = count_users();
uint8_t buf[16];
- if (login_fd > 0 && session[login_fd])
+ if (login_session)
{
// send number of user to login server
- WFIFOW(login_fd, 0) = 0x2714;
- WFIFOL(login_fd, 2) = users;
- WFIFOSET(login_fd, 6);
+ WFIFOW(login_session, 0) = 0x2714;
+ WFIFOL(login_session, 2) = users;
+ WFIFOSET(login_session, 6);
}
// send number of players to all map-servers
WBUFW(buf, 0) = 0x2b00;
@@ -2511,25 +2547,26 @@ void send_users_tologin(TimerData *, tick_t)
static
void check_connect_login_server(TimerData *, tick_t)
{
- if (login_fd <= 0 || session[login_fd] == NULL)
+ if (!login_session)
{
PRINTF("Attempt to connect to login-server...\n");
- if ((login_fd = make_connection(login_ip, login_port)) < 0)
+ login_session = make_connection(login_ip, login_port);
+ if (!login_session)
return;
- session[login_fd]->func_parse = parse_tologin;
- realloc_fifo(login_fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
- WFIFOW(login_fd, 0) = 0x2710;
- WFIFO_ZERO(login_fd, 2, 24);
- WFIFO_STRING(login_fd, 2, userid, 24);
- WFIFO_STRING(login_fd, 26, passwd, 24);
- WFIFOL(login_fd, 50) = 0;
- WFIFOIP(login_fd, 54) = char_ip;
- WFIFOL(login_fd, 58) = char_port;
- WFIFO_STRING(login_fd, 60, server_name, 20);
- WFIFOW(login_fd, 80) = 0;
- WFIFOW(login_fd, 82) = 0; //char_maintenance;
- WFIFOW(login_fd, 84) = 0; //char_new;
- WFIFOSET(login_fd, 86);
+ login_session->func_parse = parse_tologin;
+ realloc_fifo(login_session, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
+ WFIFOW(login_session, 0) = 0x2710;
+ WFIFO_ZERO(login_session, 2, 24);
+ WFIFO_STRING(login_session, 2, userid, 24);
+ WFIFO_STRING(login_session, 26, passwd, 24);
+ WFIFOL(login_session, 50) = 0;
+ WFIFOIP(login_session, 54) = char_ip;
+ WFIFOL(login_session, 58) = char_port;
+ WFIFO_STRING(login_session, 60, server_name, 20);
+ WFIFOW(login_session, 80) = 0;
+ WFIFOW(login_session, 82) = 0; //char_maintenance;
+ WFIFOW(login_session, 84) = 0; //char_new;
+ WFIFOSET(login_session, 86);
}
}
@@ -2755,7 +2792,7 @@ bool char_config(XString w1, ZString w2)
void term_func(void)
{
// write online players files with no player
- std::fill(online_chars.begin(), online_chars.end(), -1);
+ std::fill(online_chars.begin(), online_chars.end(), nullptr);
create_online_files();
online_chars.clear();
@@ -2765,8 +2802,8 @@ void term_func(void)
gm_accounts.clear();
char_data.clear();
- delete_session(login_fd);
- delete_session(char_fd);
+ delete_session(login_session);
+ delete_session(char_session);
CHAR_LOG("----End of char-server (normal end with closing of all files).\n");
}
@@ -2785,12 +2822,6 @@ bool char_confs(XString key, ZString value)
int do_init(int argc, ZString *argv)
{
- for (int i = 0; i < MAX_MAP_SERVERS; i++)
- {
- server[i] = mmo_map_server{};
- server_fd[i] = -1;
- }
-
bool loaded_config_yet = false;
for (int i = 1; i < argc; ++i)
{
@@ -2838,7 +2869,7 @@ int do_init(int argc, ZString *argv)
// set_termfunc (do_final);
set_defaultparse(parse_char);
- char_fd = make_listen_port(char_port);
+ char_session = make_listen_port(char_port);
Timer(gettick() + std::chrono::seconds(1),
check_connect_login_server,
diff --git a/src/char/char.hpp b/src/char/char.hpp
index 27bdd36..cac060f 100644
--- a/src/char/char.hpp
+++ b/src/char/char.hpp
@@ -7,6 +7,8 @@
# include "../common/ip.hpp"
# include "../common/mmo.hpp"
+class Session;
+
constexpr int MAX_MAP_SERVERS = 30;
struct mmo_map_server
@@ -18,10 +20,12 @@ struct mmo_map_server
};
const mmo_charstatus *search_character(CharName character_name);
+const mmo_charstatus *search_character_id(int char_id);
+Session *server_for(const mmo_charstatus *mcs);
int mapif_sendall(const uint8_t *buf, unsigned int len);
-int mapif_sendallwos(int fd, const uint8_t *buf, unsigned int len);
-int mapif_send(int fd, const uint8_t *buf, unsigned int len);
+int mapif_sendallwos(Session *s, const uint8_t *buf, unsigned int len);
+int mapif_send(Session *s, const uint8_t *buf, unsigned int len);
void char_log(XString line);
diff --git a/src/char/int_party.cpp b/src/char/int_party.cpp
index d657a6c..79f24cb 100644
--- a/src/char/int_party.cpp
+++ b/src/char/int_party.cpp
@@ -33,7 +33,7 @@ void mapif_party_broken(int party_id, int flag);
static
int party_check_empty(struct party *p);
static
-void mapif_parse_PartyLeave(int fd, int party_id, int account_id);
+void mapif_parse_PartyLeave(Session *s, int party_id, int account_id);
// パーティデータの文字列への変換
static
@@ -264,7 +264,7 @@ void party_check_conflict_sub(struct party *p,
// 別のパーティに偽の所属データがあるので脱退
PRINTF("int_party: party conflict! %d %d %d\n", account_id,
party_id, p->party_id);
- mapif_parse_PartyLeave(-1, p->party_id, account_id);
+ mapif_parse_PartyLeave(nullptr, p->party_id, account_id);
}
}
}
@@ -283,67 +283,67 @@ void party_check_conflict(int party_id, int account_id, CharName nick)
// パーティ作成可否
static
-void mapif_party_created(int fd, int account_id, struct party *p)
+void mapif_party_created(Session *s, int account_id, struct party *p)
{
- WFIFOW(fd, 0) = 0x3820;
- WFIFOL(fd, 2) = account_id;
+ WFIFOW(s, 0) = 0x3820;
+ WFIFOL(s, 2) = account_id;
if (p != NULL)
{
- WFIFOB(fd, 6) = 0;
- WFIFOL(fd, 7) = p->party_id;
- WFIFO_STRING(fd, 11, p->name, 24);
+ WFIFOB(s, 6) = 0;
+ WFIFOL(s, 7) = p->party_id;
+ WFIFO_STRING(s, 11, p->name, 24);
PRINTF("int_party: created! %d %s\n", p->party_id, p->name);
}
else
{
- WFIFOB(fd, 6) = 1;
- WFIFOL(fd, 7) = 0;
- WFIFO_STRING(fd, 11, "error", 24);
+ WFIFOB(s, 6) = 1;
+ WFIFOL(s, 7) = 0;
+ WFIFO_STRING(s, 11, "error", 24);
}
- WFIFOSET(fd, 35);
+ WFIFOSET(s, 35);
}
// パーティ情報見つからず
static
-void mapif_party_noinfo(int fd, int party_id)
+void mapif_party_noinfo(Session *s, int party_id)
{
- WFIFOW(fd, 0) = 0x3821;
- WFIFOW(fd, 2) = 8;
- WFIFOL(fd, 4) = party_id;
- WFIFOSET(fd, 8);
+ WFIFOW(s, 0) = 0x3821;
+ WFIFOW(s, 2) = 8;
+ WFIFOL(s, 4) = party_id;
+ WFIFOSET(s, 8);
PRINTF("int_party: info not found %d\n", party_id);
}
// パーティ情報まとめ送り
static
-void mapif_party_info(int fd, struct party *p)
+void mapif_party_info(Session *s, struct party *p)
{
unsigned char buf[4 + sizeof(struct party)];
WBUFW(buf, 0) = 0x3821;
WBUF_STRUCT(buf, 4, *p);
WBUFW(buf, 2) = 4 + sizeof(struct party);
- if (fd < 0)
+ if (!s)
mapif_sendall(buf, WBUFW(buf, 2));
else
- mapif_send(fd, buf, WBUFW(buf, 2));
+ mapif_send(s, buf, WBUFW(buf, 2));
// PRINTF("int_party: info %d %s\n", p->party_id, p->name);
}
// パーティメンバ追加可否
static
-void mapif_party_memberadded(int fd, int party_id, int account_id, int flag)
+void mapif_party_memberadded(Session *s, int party_id, int account_id, int flag)
{
- WFIFOW(fd, 0) = 0x3822;
- WFIFOL(fd, 2) = party_id;
- WFIFOL(fd, 6) = account_id;
- WFIFOB(fd, 10) = flag;
- WFIFOSET(fd, 11);
+ WFIFOW(s, 0) = 0x3822;
+ WFIFOL(s, 2) = party_id;
+ WFIFOL(s, 6) = account_id;
+ WFIFOB(s, 10) = flag;
+ WFIFOSET(s, 11);
}
// パーティ設定変更通知
static
-void mapif_party_optionchanged(int fd, struct party *p, int account_id,
+void mapif_party_optionchanged(Session *s, struct party *p, int account_id,
int flag)
{
unsigned char buf[15];
@@ -357,7 +357,7 @@ void mapif_party_optionchanged(int fd, struct party *p, int account_id,
if (flag == 0)
mapif_sendall(buf, 15);
else
- mapif_send(fd, buf, 15);
+ mapif_send(s, buf, 15);
PRINTF("int_party: option changed %d %d %d %d %d\n", p->party_id,
account_id, p->exp, p->item, flag);
}
@@ -423,14 +423,14 @@ void mapif_party_message(int party_id, int account_id, XString mes)
// パーティ
static
-void mapif_parse_CreateParty(int fd, int account_id, PartyName name, CharName nick,
+void mapif_parse_CreateParty(Session *s, int account_id, PartyName name, CharName nick,
MapName map, int lv)
{
{
if (!name.is_print())
{
PRINTF("int_party: illegal party name [%s]\n", name);
- mapif_party_created(fd, account_id, NULL);
+ mapif_party_created(s, account_id, NULL);
return;
}
}
@@ -438,7 +438,7 @@ void mapif_parse_CreateParty(int fd, int account_id, PartyName name, CharName ni
if (search_partyname(name) != NULL)
{
PRINTF("int_party: same name party exists [%s]\n", name);
- mapif_party_created(fd, account_id, NULL);
+ mapif_party_created(s, account_id, NULL);
return;
}
struct party p {};
@@ -455,30 +455,30 @@ void mapif_parse_CreateParty(int fd, int account_id, PartyName name, CharName ni
party_db.insert(p.party_id, p);
- mapif_party_created(fd, account_id, &p);
- mapif_party_info(fd, &p);
+ mapif_party_created(s, account_id, &p);
+ mapif_party_info(s, &p);
}
// パーティ情報要求
static
-void mapif_parse_PartyInfo(int fd, int party_id)
+void mapif_parse_PartyInfo(Session *s, int party_id)
{
struct party *p = party_db.search(party_id);
if (p != NULL)
- mapif_party_info(fd, p);
+ mapif_party_info(s, p);
else
- mapif_party_noinfo(fd, party_id);
+ mapif_party_noinfo(s, party_id);
}
// パーティ追加要求
static
-void mapif_parse_PartyAddMember(int fd, int party_id, int account_id,
+void mapif_parse_PartyAddMember(Session *s, int party_id, int account_id,
CharName nick, MapName map, int lv)
{
struct party *p = party_db.search(party_id);
if (p == NULL)
{
- mapif_party_memberadded(fd, party_id, account_id, 1);
+ mapif_party_memberadded(s, party_id, account_id, 1);
return;
}
@@ -494,8 +494,8 @@ void mapif_parse_PartyAddMember(int fd, int party_id, int account_id,
p->member[i].leader = 0;
p->member[i].online = 1;
p->member[i].lv = lv;
- mapif_party_memberadded(fd, party_id, account_id, 0);
- mapif_party_info(-1, p);
+ mapif_party_memberadded(s, party_id, account_id, 0);
+ mapif_party_info(nullptr, p);
if (p->exp > 0 && !party_check_exp_share(p))
{
@@ -503,16 +503,16 @@ void mapif_parse_PartyAddMember(int fd, int party_id, int account_id,
flag = 0x01;
}
if (flag)
- mapif_party_optionchanged(fd, p, 0, 0);
+ mapif_party_optionchanged(s, p, 0, 0);
return;
}
}
- mapif_party_memberadded(fd, party_id, account_id, 1);
+ mapif_party_memberadded(s, party_id, account_id, 1);
}
// パーティー設定変更要求
static
-void mapif_parse_PartyChangeOption(int fd, int party_id, int account_id,
+void mapif_parse_PartyChangeOption(Session *s, int party_id, int account_id,
int exp, int item)
{
struct party *p = party_db.search(party_id);
@@ -529,11 +529,11 @@ void mapif_parse_PartyChangeOption(int fd, int party_id, int account_id,
p->item = item;
- mapif_party_optionchanged(fd, p, account_id, flag);
+ mapif_party_optionchanged(s, p, account_id, flag);
}
// パーティ脱退要求
-void mapif_parse_PartyLeave(int, int party_id, int account_id)
+void mapif_parse_PartyLeave(Session *, int party_id, int account_id)
{
struct party *p = party_db.search(party_id);
if (!p)
@@ -546,14 +546,14 @@ void mapif_parse_PartyLeave(int, int party_id, int account_id)
p->member[i] = party_member{};
if (party_check_empty(p) == 0)
- mapif_party_info(-1, p); // まだ人がいるのでデータ送信
+ mapif_party_info(nullptr, p); // まだ人がいるのでデータ送信
return;
}
}
// パーティマップ更新要求
static
-void mapif_parse_PartyChangeMap(int fd, int party_id, int account_id,
+void mapif_parse_PartyChangeMap(Session *s, int party_id, int account_id,
MapName map, int online, int lv)
{
struct party *p = party_db.search(party_id);
@@ -577,33 +577,33 @@ void mapif_parse_PartyChangeMap(int fd, int party_id, int account_id,
flag = 1;
}
if (flag)
- mapif_party_optionchanged(fd, p, 0, 0);
+ mapif_party_optionchanged(s, p, 0, 0);
return;
}
}
// パーティ解散要求
static
-void mapif_parse_BreakParty(int fd, int party_id)
+void mapif_parse_BreakParty(Session *, int party_id)
{
struct party *p = party_db.search(party_id);
if (p == NULL)
return;
party_db.erase(party_id);
- mapif_party_broken(fd, party_id);
+ mapif_party_broken(party_id, 0 /*unknown*/);
}
// パーティメッセージ送信
static
-void mapif_parse_PartyMessage(int, int party_id, int account_id, XString mes)
+void mapif_parse_PartyMessage(Session *, int party_id, int account_id, XString mes)
{
mapif_party_message(party_id, account_id, mes);
}
// パーティチェック要求
static
-void mapif_parse_PartyCheck(int, int party_id, int account_id, CharName nick)
+void mapif_parse_PartyCheck(Session *, int party_id, int account_id, CharName nick)
{
party_check_conflict(party_id, account_id, nick);
}
@@ -613,18 +613,18 @@ void mapif_parse_PartyCheck(int, int party_id, int account_id, CharName nick)
// ・パケット長データはinter.cにセットしておくこと
// ・パケット長チェックや、RFIFOSKIPは呼び出し元で行われるので行ってはならない
// ・エラーなら0(false)、そうでないなら1(true)をかえさなければならない
-int inter_party_parse_frommap(int fd)
+int inter_party_parse_frommap(Session *ms)
{
- switch (RFIFOW(fd, 0))
+ switch (RFIFOW(ms, 0))
{
case 0x3020:
{
- int account = RFIFOL(fd, 2);
- PartyName name = stringish<PartyName>(RFIFO_STRING<24>(fd, 6));
- CharName nick = stringish<CharName>(RFIFO_STRING<24>(fd, 30));
- MapName map = RFIFO_STRING<16>(fd, 54);
- uint16_t lv = RFIFOW(fd, 70);
- mapif_parse_CreateParty(fd,
+ int account = RFIFOL(ms, 2);
+ PartyName name = stringish<PartyName>(RFIFO_STRING<24>(ms, 6));
+ CharName nick = stringish<CharName>(RFIFO_STRING<24>(ms, 30));
+ MapName map = RFIFO_STRING<16>(ms, 54);
+ uint16_t lv = RFIFOW(ms, 70);
+ mapif_parse_CreateParty(ms,
account,
name,
nick,
@@ -634,18 +634,18 @@ int inter_party_parse_frommap(int fd)
break;
case 0x3021:
{
- int party_id = RFIFOL(fd, 2);
- mapif_parse_PartyInfo(fd, party_id);
+ int party_id = RFIFOL(ms, 2);
+ mapif_parse_PartyInfo(ms, party_id);
}
break;
case 0x3022:
{
- int party_id = RFIFOL(fd, 2);
- int account_id = RFIFOL(fd, 6);
- CharName nick = stringish<CharName>(RFIFO_STRING<24>(fd, 10));
- MapName map = RFIFO_STRING<16>(fd, 34);
- uint16_t lv = RFIFOW(fd, 50);
- mapif_parse_PartyAddMember(fd,
+ int party_id = RFIFOL(ms, 2);
+ int account_id = RFIFOL(ms, 6);
+ CharName nick = stringish<CharName>(RFIFO_STRING<24>(ms, 10));
+ MapName map = RFIFO_STRING<16>(ms, 34);
+ uint16_t lv = RFIFOW(ms, 50);
+ mapif_parse_PartyAddMember(ms,
party_id,
account_id,
nick,
@@ -655,11 +655,11 @@ int inter_party_parse_frommap(int fd)
break;
case 0x3023:
{
- int party_id = RFIFOL(fd, 2);
- int account_id = RFIFOL(fd, 6);
- uint16_t exp = RFIFOW(fd, 10);
- uint16_t item = RFIFOW(fd, 12);
- mapif_parse_PartyChangeOption(fd,
+ int party_id = RFIFOL(ms, 2);
+ int account_id = RFIFOL(ms, 6);
+ uint16_t exp = RFIFOW(ms, 10);
+ uint16_t item = RFIFOW(ms, 12);
+ mapif_parse_PartyChangeOption(ms,
party_id,
account_id,
exp,
@@ -668,21 +668,21 @@ int inter_party_parse_frommap(int fd)
break;
case 0x3024:
{
- int party_id = RFIFOL(fd, 2);
- int account_id = RFIFOL(fd, 6);
- mapif_parse_PartyLeave(fd,
+ int party_id = RFIFOL(ms, 2);
+ int account_id = RFIFOL(ms, 6);
+ mapif_parse_PartyLeave(ms,
party_id,
account_id);
}
break;
case 0x3025:
{
- int party_id = RFIFOL(fd, 2);
- int account_id = RFIFOL(fd, 6);
- MapName map = RFIFO_STRING<16>(fd, 10);
- uint8_t online = RFIFOB(fd, 26);
- uint16_t lv = RFIFOW(fd, 27);
- mapif_parse_PartyChangeMap(fd,
+ int party_id = RFIFOL(ms, 2);
+ int account_id = RFIFOL(ms, 6);
+ MapName map = RFIFO_STRING<16>(ms, 10);
+ uint8_t online = RFIFOB(ms, 26);
+ uint16_t lv = RFIFOW(ms, 27);
+ mapif_parse_PartyChangeMap(ms,
party_id,
account_id,
map,
@@ -692,17 +692,17 @@ int inter_party_parse_frommap(int fd)
break;
case 0x3026:
{
- int party_id = RFIFOL(fd, 2);
- mapif_parse_BreakParty(fd, party_id);
+ int party_id = RFIFOL(ms, 2);
+ mapif_parse_BreakParty(ms, party_id);
}
break;
case 0x3027:
{
- size_t len = RFIFOW(fd, 2) - 12;
- int party_id = RFIFOL(fd, 4);
- int account_id = RFIFOL(fd, 8);
- FString mes = RFIFO_STRING(fd, 12, len);
- mapif_parse_PartyMessage(fd,
+ size_t len = RFIFOW(ms, 2) - 12;
+ int party_id = RFIFOL(ms, 4);
+ int account_id = RFIFOL(ms, 8);
+ FString mes = RFIFO_STRING(ms, 12, len);
+ mapif_parse_PartyMessage(ms,
party_id,
account_id,
mes);
@@ -710,10 +710,10 @@ int inter_party_parse_frommap(int fd)
break;
case 0x3028:
{
- int party_id = RFIFOL(fd, 2);
- int account_id = RFIFOL(fd, 6);
- CharName nick = stringish<CharName>(RFIFO_STRING<24>(fd, 10));
- mapif_parse_PartyCheck(fd,
+ int party_id = RFIFOL(ms, 2);
+ int account_id = RFIFOL(ms, 6);
+ CharName nick = stringish<CharName>(RFIFO_STRING<24>(ms, 10));
+ mapif_parse_PartyCheck(ms,
party_id,
account_id,
nick);
@@ -729,5 +729,5 @@ int inter_party_parse_frommap(int fd)
// サーバーから脱退要求(キャラ削除用)
void inter_party_leave(int party_id, int account_id)
{
- mapif_parse_PartyLeave(-1, party_id, account_id);
+ mapif_parse_PartyLeave(nullptr, party_id, account_id);
}
diff --git a/src/char/int_party.hpp b/src/char/int_party.hpp
index 4e5547c..a5b6e8b 100644
--- a/src/char/int_party.hpp
+++ b/src/char/int_party.hpp
@@ -3,10 +3,12 @@
# include "../strings/fwd.hpp"
+class Session;
+
void inter_party_init(void);
int inter_party_save(void);
-int inter_party_parse_frommap(int fd);
+int inter_party_parse_frommap(Session *ms);
void inter_party_leave(int party_id, int account_id);
diff --git a/src/char/int_storage.cpp b/src/char/int_storage.cpp
index 323a451..c21da81 100644
--- a/src/char/int_storage.cpp
+++ b/src/char/int_storage.cpp
@@ -164,24 +164,24 @@ void inter_storage_delete(int account_id)
// 倉庫データの送信
static
-void mapif_load_storage(int fd, int account_id)
+void mapif_load_storage(Session *ss, int account_id)
{
- struct storage *s = account2storage(account_id);
- WFIFOW(fd, 0) = 0x3810;
- WFIFOW(fd, 2) = sizeof(struct storage) + 8;
- WFIFOL(fd, 4) = account_id;
- WFIFO_STRUCT(fd, 8, *s);
- WFIFOSET(fd, WFIFOW(fd, 2));
+ struct storage *st = account2storage(account_id);
+ WFIFOW(ss, 0) = 0x3810;
+ WFIFOW(ss, 2) = sizeof(struct storage) + 8;
+ WFIFOL(ss, 4) = account_id;
+ WFIFO_STRUCT(ss, 8, *st);
+ WFIFOSET(ss, WFIFOW(ss, 2));
}
// 倉庫データ保存完了送信
static
-void mapif_save_storage_ack(int fd, int account_id)
+void mapif_save_storage_ack(Session *ss, int account_id)
{
- WFIFOW(fd, 0) = 0x3811;
- WFIFOL(fd, 2) = account_id;
- WFIFOB(fd, 6) = 0;
- WFIFOSET(fd, 7);
+ WFIFOW(ss, 0) = 0x3811;
+ WFIFOL(ss, 2) = account_id;
+ WFIFOB(ss, 6) = 0;
+ WFIFOSET(ss, 7);
}
//---------------------------------------------------------
@@ -189,18 +189,18 @@ void mapif_save_storage_ack(int fd, int account_id)
// 倉庫データ要求受信
static
-void mapif_parse_LoadStorage(int fd)
+void mapif_parse_LoadStorage(Session *ss)
{
- mapif_load_storage(fd, RFIFOL(fd, 2));
+ mapif_load_storage(ss, RFIFOL(ss, 2));
}
// 倉庫データ受信&保存
static
-void mapif_parse_SaveStorage(int fd)
+void mapif_parse_SaveStorage(Session *ss)
{
- struct storage *s;
- int account_id = RFIFOL(fd, 4);
- int len = RFIFOW(fd, 2);
+ struct storage *st;
+ int account_id = RFIFOL(ss, 4);
+ int len = RFIFOW(ss, 2);
if (sizeof(struct storage) != len - 8)
{
PRINTF("inter storage: data size error %zu %d\n",
@@ -208,9 +208,9 @@ void mapif_parse_SaveStorage(int fd)
}
else
{
- s = account2storage(account_id);
- RFIFO_STRUCT(fd, 8, *s);
- mapif_save_storage_ack(fd, account_id);
+ st = account2storage(account_id);
+ RFIFO_STRUCT(ss, 8, *st);
+ mapif_save_storage_ack(ss, account_id);
}
}
@@ -219,15 +219,15 @@ void mapif_parse_SaveStorage(int fd)
// ・パケット長データはinter.cにセットしておくこと
// ・パケット長チェックや、RFIFOSKIPは呼び出し元で行われるので行ってはならない
// ・エラーなら0(false)、そうでないなら1(true)をかえさなければならない
-int inter_storage_parse_frommap(int fd)
+int inter_storage_parse_frommap(Session *ms)
{
- switch (RFIFOW(fd, 0))
+ switch (RFIFOW(ms, 0))
{
case 0x3010:
- mapif_parse_LoadStorage(fd);
+ mapif_parse_LoadStorage(ms);
break;
case 0x3011:
- mapif_parse_SaveStorage(fd);
+ mapif_parse_SaveStorage(ms);
break;
default:
return 0;
diff --git a/src/char/int_storage.hpp b/src/char/int_storage.hpp
index 23d7441..0790b6e 100644
--- a/src/char/int_storage.hpp
+++ b/src/char/int_storage.hpp
@@ -3,12 +3,14 @@
# include "../strings/fwd.hpp"
+class Session;
+
void inter_storage_init(void);
int inter_storage_save(void);
void inter_storage_delete(int account_id);
struct storage *account2storage(int account_id);
-int inter_storage_parse_frommap(int fd);
+int inter_storage_parse_frommap(Session *ms);
extern FString storage_txt;
diff --git a/src/char/inter.cpp b/src/char/inter.cpp
index a0569a7..19ba254 100644
--- a/src/char/inter.cpp
+++ b/src/char/inter.cpp
@@ -28,10 +28,6 @@
#include "../poison.hpp"
-// Existence time of Wisp/page data (60 seconds)
-// that is the waiting time of answers of all map-servers
-constexpr std::chrono::minutes WISDATA_TTL = std::chrono::minutes(1);
-
static
FString accreg_txt = "save/accreg.txt";
@@ -60,18 +56,6 @@ int inter_recv_packet_length[] =
48, 14, -1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
-struct WisData
-{
- int id, fd, count;
- tick_t tick;
- CharName src, dst;
- FString msg;
-};
-static
-Map<int, struct WisData> wis_db;
-static
-std::vector<int> wis_dellistv;
-
//--------------------------------------------------------
// アカウント変数を文字列へ変換
@@ -222,101 +206,71 @@ void mapif_GMmessage(XString mes)
mapif_sendall(buf, msg_len);
}
-// Wisp/page transmission to all map-server
+// Wisp/page transmission to correct map-server
static
-void mapif_wis_message(struct WisData *wd)
+void mapif_wis_message(Session *tms, CharName src, CharName dst, XString msg)
{
- size_t str_size = wd->msg.size() + 1;
+ const mmo_charstatus *mcs = search_character(src);
+ assert (mcs);
+
+ size_t str_size = msg.size() + 1;
uint8_t buf[56 + str_size];
WBUFW(buf, 0) = 0x3801;
WBUFW(buf, 2) = 56 + str_size;
- WBUFL(buf, 4) = wd->id;
- WBUF_STRING(buf, 8, wd->src.to__actual(), 24);
- WBUF_STRING(buf, 32, wd->dst.to__actual(), 24);
- WBUF_STRING(buf, 56, wd->msg, str_size);
- wd->count = mapif_sendall(buf, WBUFW(buf, 2));
+ WBUFL(buf, 4) = mcs->char_id; // formerly, whisper ID
+ WBUF_STRING(buf, 8, src.to__actual(), 24);
+ WBUF_STRING(buf, 32, dst.to__actual(), 24);
+ WBUF_STRING(buf, 56, msg, str_size);
+ mapif_send(tms, buf, WBUFW(buf, 2));
}
// Wisp/page transmission result to map-server
static
-void mapif_wis_end(struct WisData *wd, int flag)
+void mapif_wis_end(Session *sms, CharName sender, int flag)
{
uint8_t buf[27];
WBUFW(buf, 0) = 0x3802;
- WBUF_STRING(buf, 2, wd->src.to__actual(), 24);
+ WBUF_STRING(buf, 2, sender.to__actual(), 24);
WBUFB(buf, 26) = flag; // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
- mapif_send(wd->fd, buf, 27);
+ mapif_send(sms, buf, 27);
}
// アカウント変数送信
static
-void mapif_account_reg(int fd)
+void mapif_account_reg(Session *s)
{
- size_t len = RFIFOW(fd, 2);
+ size_t len = RFIFOW(s, 2);
uint8_t buf[len];
- RFIFO_BUF_CLONE(fd, buf, len);
+ RFIFO_BUF_CLONE(s, buf, len);
WBUFW(buf, 0) = 0x3804;
- mapif_sendallwos(fd, buf, WBUFW(buf, 2));
+ mapif_sendallwos(s, buf, WBUFW(buf, 2));
}
// アカウント変数要求返信
static
-void mapif_account_reg_reply(int fd, int account_id)
+void mapif_account_reg_reply(Session *s, int account_id)
{
struct accreg *reg = accreg_db.search(account_id);
- WFIFOW(fd, 0) = 0x3804;
- WFIFOL(fd, 4) = account_id;
+ WFIFOW(s, 0) = 0x3804;
+ WFIFOL(s, 4) = account_id;
if (reg == NULL)
{
- WFIFOW(fd, 2) = 8;
+ WFIFOW(s, 2) = 8;
}
else
{
int j, p;
for (j = 0, p = 8; j < reg->reg_num; j++, p += 36)
{
- WFIFO_STRING(fd, p, reg->reg[j].str, 32);
- WFIFOL(fd, p + 32) = reg->reg[j].value;
- }
- WFIFOW(fd, 2) = p;
- }
- WFIFOSET(fd, WFIFOW(fd, 2));
-}
-
-//--------------------------------------------------------
-
-// Existence check of WISP data
-static
-void check_ttl_wisdata_sub(struct WisData *wd, tick_t tick)
-{
- if (tick > wd->tick + WISDATA_TTL)
- wis_dellistv.push_back(wd->id);
-}
-
-static
-void check_ttl_wisdata(void)
-{
- tick_t tick = gettick();
-
- // this code looks silly now, but let's wait a bit to refactor properly
- {
- wis_dellistv.clear();
- for (auto& pair : wis_db)
- check_ttl_wisdata_sub(&pair.second, tick);
- for (int it : wis_dellistv)
- {
- struct WisData *wd = wis_db.search(it);
- assert (wd);
- PRINTF("inter: wis data id=%d time out : from %s to %s\n",
- wd->id, wd->src, wd->dst);
- // removed. not send information after a timeout. Just no answer for the player
- //mapif_wis_end(wd, 1); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
- wis_db.erase(wd->id);
+ WFIFO_STRING(s, p, reg->reg[j].str, 32);
+ WFIFOL(s, p + 32) = reg->reg[j].value;
}
+ WFIFOW(s, 2) = p;
}
+ WFIFOSET(s, WFIFOW(s, 2));
}
//--------------------------------------------------------
@@ -324,29 +278,27 @@ void check_ttl_wisdata(void)
// GMメッセージ送信
static
-void mapif_parse_GMmessage(int fd)
+void mapif_parse_GMmessage(Session *s)
{
- size_t msg_len = RFIFOW(fd, 2);
+ size_t msg_len = RFIFOW(s, 2);
size_t str_len = msg_len - 4;
- FString buf = RFIFO_STRING(fd, 4, str_len);
+ FString buf = RFIFO_STRING(s, 4, str_len);
mapif_GMmessage(buf);
}
// Wisp/page request to send
static
-void mapif_parse_WisRequest(int fd)
+void mapif_parse_WisRequest(Session *sms)
{
- static int wisid = 0;
-
- if (RFIFOW(fd, 2) - 52 <= 0)
+ if (RFIFOW(sms, 2) - 52 <= 0)
{ // normaly, impossible, but who knows...
PRINTF("inter: Wis message doesn't exist.\n");
return;
}
- CharName from = stringish<CharName>(RFIFO_STRING<24>(fd, 4));
- CharName to = stringish<CharName>(RFIFO_STRING<24>(fd, 28));
+ CharName from = stringish<CharName>(RFIFO_STRING<24>(sms, 4));
+ CharName to = stringish<CharName>(RFIFO_STRING<24>(sms, 28));
// search if character exists before to ask all map-servers
const mmo_charstatus *mcs = search_character(to);
@@ -356,7 +308,7 @@ void mapif_parse_WisRequest(int fd)
WBUFW(buf, 0) = 0x3802;
WBUF_STRING(buf, 2, from.to__actual(), 24);
WBUFB(buf, 26) = 1; // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
- mapif_send(fd, buf, 27);
+ mapif_send(sms, buf, 27);
// Character exists. So, ask all map-servers
}
else
@@ -370,42 +322,36 @@ void mapif_parse_WisRequest(int fd)
WBUFW(buf, 0) = 0x3802;
WBUF_STRING(buf, 2, from.to__actual(), 24);
WBUFB(buf, 26) = 1; // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
- mapif_send(fd, buf, 27);
+ mapif_send(sms, buf, 27);
}
else
{
- struct WisData wd {};
-
- // Whether the failure of previous wisp/page transmission (timeout)
- check_ttl_wisdata();
-
- wd.id = ++wisid;
- wd.fd = fd;
- size_t len = RFIFOW(fd, 2) - 52;
- wd.src = from;
- wd.dst = to;
- wd.msg = RFIFO_STRING(fd, 52, len);
- wd.tick = gettick();
- wis_db.insert(wd.id, wd);
- mapif_wis_message(&wd);
+ size_t len = RFIFOW(sms, 2) - 52;
+ Session *tms = server_for(mcs); // for to
+ FString msg = RFIFO_STRING(sms, 52, len);
+ if (tms)
+ {
+ mapif_wis_message(tms, from, to, msg);
+ }
+ else
+ {
+ mapif_wis_end(sms, from, 1);
+ }
}
}
}
// Wisp/page transmission result
static
-int mapif_parse_WisReply(int fd)
+int mapif_parse_WisReply(Session *tms)
{
- int id = RFIFOL(fd, 2), flag = RFIFOB(fd, 6);
- struct WisData *wd = wis_db.search(id);
-
- if (wd == NULL)
- return 0; // This wisp was probably suppress before, because it was timeout of because of target was found on another map-server
+ int id = RFIFOL(tms, 2), flag = RFIFOB(tms, 6);
- if ((--wd->count) <= 0 || flag != 1)
+ const mmo_charstatus *smcs = search_character_id(id);
+ CharName from = smcs->name;
+ Session *sms = server_for(smcs);
{
- mapif_wis_end(wd, flag); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
- wis_db.erase(id);
+ mapif_wis_end(sms, from, flag); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
}
return 0;
@@ -413,48 +359,48 @@ int mapif_parse_WisReply(int fd)
// Received wisp message from map-server for ALL gm (just copy the message and resends it to ALL map-servers)
static
-void mapif_parse_WisToGM(int fd)
+void mapif_parse_WisToGM(Session *s)
{
- size_t len = RFIFOW(fd, 2);
+ size_t len = RFIFOW(s, 2);
uint8_t buf[len];
// 0x3003/0x3803 <packet_len>.w <wispname>.24B <min_gm_level>.w <message>.?B
- RFIFO_BUF_CLONE(fd, buf, len);
+ RFIFO_BUF_CLONE(s, buf, len);
WBUFW(buf, 0) = 0x3803;
mapif_sendall(buf, len);
}
// アカウント変数保存要求
static
-void mapif_parse_AccReg(int fd)
+void mapif_parse_AccReg(Session *s)
{
int j, p;
- struct accreg *reg = accreg_db.search(RFIFOL(fd, 4));
+ struct accreg *reg = accreg_db.search(RFIFOL(s, 4));
if (reg == NULL)
{
- int account_id = RFIFOL(fd, 4);
+ int account_id = RFIFOL(s, 4);
reg = accreg_db.init(account_id);
reg->account_id = account_id;
}
- for (j = 0, p = 8; j < ACCOUNT_REG_NUM && p < RFIFOW(fd, 2);
+ for (j = 0, p = 8; j < ACCOUNT_REG_NUM && p < RFIFOW(s, 2);
j++, p += 36)
{
- reg->reg[j].str = stringish<VarName>(RFIFO_STRING<32>(fd, p));
- reg->reg[j].value = RFIFOL(fd, p + 32);
+ reg->reg[j].str = stringish<VarName>(RFIFO_STRING<32>(s, p));
+ reg->reg[j].value = RFIFOL(s, p + 32);
}
reg->reg_num = j;
// 他のMAPサーバーに送信
- mapif_account_reg(fd);
+ mapif_account_reg(s);
}
// アカウント変数送信要求
static
-void mapif_parse_AccRegRequest(int fd)
+void mapif_parse_AccRegRequest(Session *s)
{
- mapif_account_reg_reply(fd, RFIFOL(fd, 2));
+ mapif_account_reg_reply(s, RFIFOL(s, 2));
}
//--------------------------------------------------------
@@ -462,9 +408,9 @@ void mapif_parse_AccRegRequest(int fd)
// map server からの通信(1パケットのみ解析すること)
// エラーなら0(false)、処理できたなら1、
// パケット長が足りなければ2をかえさなければならない
-int inter_parse_frommap(int fd)
+int inter_parse_frommap(Session *ms)
{
- int cmd = RFIFOW(fd, 0);
+ int cmd = RFIFOW(ms, 0);
int len = 0;
// inter鯖管轄かを調べる
@@ -477,54 +423,54 @@ int inter_parse_frommap(int fd)
// パケット長を調べる
if ((len =
- inter_check_length(fd,
+ inter_check_length(ms,
inter_recv_packet_length[cmd - 0x3000])) == 0)
return 2;
switch (cmd)
{
case 0x3000:
- mapif_parse_GMmessage(fd);
+ mapif_parse_GMmessage(ms);
break;
case 0x3001:
- mapif_parse_WisRequest(fd);
+ mapif_parse_WisRequest(ms);
break;
case 0x3002:
- mapif_parse_WisReply(fd);
+ mapif_parse_WisReply(ms);
break;
case 0x3003:
- mapif_parse_WisToGM(fd);
+ mapif_parse_WisToGM(ms);
break;
case 0x3004:
- mapif_parse_AccReg(fd);
+ mapif_parse_AccReg(ms);
break;
case 0x3005:
- mapif_parse_AccRegRequest(fd);
+ mapif_parse_AccRegRequest(ms);
break;
default:
- if (inter_party_parse_frommap(fd))
+ if (inter_party_parse_frommap(ms))
break;
- if (inter_storage_parse_frommap(fd))
+ if (inter_storage_parse_frommap(ms))
break;
return 0;
}
- RFIFOSKIP(fd, len);
+ RFIFOSKIP(ms, len);
return 1;
}
// RFIFOのパケット長確認
// 必要パケット長があればパケット長、まだ足りなければ0
-int inter_check_length(int fd, int length)
+int inter_check_length(Session *s, int length)
{
if (length == -1)
{ // 可変パケット長
- if (RFIFOREST(fd) < 4) // パケット長が未着
+ if (RFIFOREST(s) < 4) // パケット長が未着
return 0;
- length = RFIFOW(fd, 2);
+ length = RFIFOW(s, 2);
}
- if (RFIFOREST(fd) < length) // パケットが未着
+ if (RFIFOREST(s) < length) // パケットが未着
return 0;
return length;
diff --git a/src/char/inter.hpp b/src/char/inter.hpp
index ae508f6..b566575 100644
--- a/src/char/inter.hpp
+++ b/src/char/inter.hpp
@@ -3,12 +3,14 @@
# include "../strings/fwd.hpp"
+class Session;
+
bool inter_config(XString key, ZString value);
void inter_init2();
void inter_save(void);
-int inter_parse_frommap(int fd);
+int inter_parse_frommap(Session *ms);
-int inter_check_length(int fd, int length);
+int inter_check_length(Session *ms, int length);
extern int party_share_level;
diff --git a/src/common/socket.cpp b/src/common/socket.cpp
index 61552c7..1c5bcbc 100644
--- a/src/common/socket.cpp
+++ b/src/common/socket.cpp
@@ -29,98 +29,98 @@ const uint32_t WFIFO_SIZE = 65536;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wold-style-cast"
-std::array<std::unique_ptr<struct socket_data>, FD_SETSIZE> session;
+std::array<std::unique_ptr<Session>, FD_SETSIZE> session;
#pragma GCC diagnostic pop
/// clean up by discarding handled bytes
inline
-void RFIFOFLUSH(int fd)
+void RFIFOFLUSH(Session *s)
{
- really_memmove(&session[fd]->rdata[0], &session[fd]->rdata[session[fd]->rdata_pos], RFIFOREST(fd));
- session[fd]->rdata_size = RFIFOREST(fd);
- session[fd]->rdata_pos = 0;
+ really_memmove(&s->rdata[0], &s->rdata[s->rdata_pos], RFIFOREST(s));
+ s->rdata_size = RFIFOREST(s);
+ s->rdata_pos = 0;
}
/// how much room there is to read more data
inline
-size_t RFIFOSPACE(int fd)
+size_t RFIFOSPACE(Session *s)
{
- return session[fd]->max_rdata - session[fd]->rdata_size;
+ return s->max_rdata - s->rdata_size;
}
/// Discard all input
static
-void null_parse(int fd);
+void null_parse(Session *s);
/// Default parser for new connections
static
-void (*default_func_parse)(int) = null_parse;
+void (*default_func_parse)(Session *) = null_parse;
-void set_defaultparse(void (*defaultparse)(int))
+void set_defaultparse(void (*defaultparse)(Session *))
{
default_func_parse = defaultparse;
}
/// Read from socket to the queue
static
-void recv_to_fifo(int fd)
+void recv_to_fifo(Session *s)
{
- if (session[fd]->eof)
+ if (s->eof)
return;
- ssize_t len = read(fd, &session[fd]->rdata[session[fd]->rdata_size],
- RFIFOSPACE(fd));
+ ssize_t len = read(s->fd, &s->rdata[s->rdata_size],
+ RFIFOSPACE(s));
if (len > 0)
{
- session[fd]->rdata_size += len;
- session[fd]->connected = 1;
+ s->rdata_size += len;
+ s->connected = 1;
}
else
{
- session[fd]->eof = 1;
+ s->eof = 1;
}
}
static
-void send_from_fifo(int fd)
+void send_from_fifo(Session *s)
{
- if (session[fd]->eof)
+ if (s->eof)
return;
- ssize_t len = write(fd, &session[fd]->wdata[0], session[fd]->wdata_size);
+ ssize_t len = write(s->fd, &s->wdata[0], s->wdata_size);
if (len > 0)
{
- session[fd]->wdata_size -= len;
- if (session[fd]->wdata_size)
+ s->wdata_size -= len;
+ if (s->wdata_size)
{
- really_memmove(&session[fd]->wdata[0], &session[fd]->wdata[len],
- session[fd]->wdata_size);
+ really_memmove(&s->wdata[0], &s->wdata[len],
+ s->wdata_size);
}
- session[fd]->connected = 1;
+ s->connected = 1;
}
else
{
- session[fd]->eof = 1;
+ s->eof = 1;
}
}
static
-void null_parse(int fd)
+void null_parse(Session *s)
{
- PRINTF("null_parse : %d\n", fd);
- RFIFOSKIP(fd, RFIFOREST(fd));
+ PRINTF("null_parse : %d\n", s);
+ RFIFOSKIP(s, RFIFOREST(s));
}
static
-void connect_client(int listen_fd)
+void connect_client(Session *ls)
{
struct sockaddr_in client_address;
socklen_t len = sizeof(client_address);
- int fd = accept(listen_fd, reinterpret_cast<struct sockaddr *>(&client_address), &len);
+ int fd = accept(ls->fd, reinterpret_cast<struct sockaddr *>(&client_address), &len);
if (fd == -1)
{
perror("accept");
@@ -165,28 +165,30 @@ void connect_client(int listen_fd)
fcntl(fd, F_SETFL, O_NONBLOCK);
- session[fd] = make_unique<socket_data>();
- session[fd]->rdata.new_(RFIFO_SIZE);
- session[fd]->wdata.new_(WFIFO_SIZE);
-
- session[fd]->max_rdata = RFIFO_SIZE;
- session[fd]->max_wdata = WFIFO_SIZE;
- session[fd]->func_recv = recv_to_fifo;
- session[fd]->func_send = send_from_fifo;
- session[fd]->func_parse = default_func_parse;
- session[fd]->client_ip = IP4Address(client_address.sin_addr);
- session[fd]->created = TimeT::now();
- session[fd]->connected = 0;
+ session[fd] = make_unique<Session>();
+ Session *s = session[fd].get();
+ s->fd = fd;
+ s->rdata.new_(RFIFO_SIZE);
+ s->wdata.new_(WFIFO_SIZE);
+
+ s->max_rdata = RFIFO_SIZE;
+ s->max_wdata = WFIFO_SIZE;
+ s->func_recv = recv_to_fifo;
+ s->func_send = send_from_fifo;
+ s->func_parse = default_func_parse;
+ s->client_ip = IP4Address(client_address.sin_addr);
+ s->created = TimeT::now();
+ s->connected = 0;
}
-int make_listen_port(uint16_t port)
+Session *make_listen_port(uint16_t port)
{
struct sockaddr_in server_address;
int fd = socket(AF_INET, SOCK_STREAM, 0);
if (fd == -1)
{
perror("socket");
- return -1;
+ return nullptr;
}
if (fd_max <= fd)
fd_max = fd + 1;
@@ -231,23 +233,25 @@ int make_listen_port(uint16_t port)
FD_SET(fd, &readfds);
#pragma GCC diagnostic pop
- session[fd] = make_unique<socket_data>();
+ session[fd] = make_unique<Session>();
+ Session *s = session[fd].get();
+ s->fd = fd;
- session[fd]->func_recv = connect_client;
- session[fd]->created = TimeT::now();
- session[fd]->connected = 1;
+ s->func_recv = connect_client;
+ s->created = TimeT::now();
+ s->connected = 1;
- return fd;
+ return s;
}
-int make_connection(IP4Address ip, uint16_t port)
+Session *make_connection(IP4Address ip, uint16_t port)
{
struct sockaddr_in server_address;
int fd = socket(AF_INET, SOCK_STREAM, 0);
if (fd == -1)
{
perror("socket");
- return -1;
+ return nullptr;
}
if (fd_max <= fd)
fd_max = fd + 1;
@@ -285,28 +289,29 @@ int make_connection(IP4Address ip, uint16_t port)
FD_SET(fd, &readfds);
#pragma GCC diagnostic pop
- session[fd] = make_unique<socket_data>();
- session[fd]->rdata.new_(RFIFO_SIZE);
- session[fd]->wdata.new_(WFIFO_SIZE);
-
- session[fd]->max_rdata = RFIFO_SIZE;
- session[fd]->max_wdata = WFIFO_SIZE;
- session[fd]->func_recv = recv_to_fifo;
- session[fd]->func_send = send_from_fifo;
- session[fd]->func_parse = default_func_parse;
- session[fd]->created = TimeT::now();
- session[fd]->connected = 1;
-
- return fd;
+ session[fd] = make_unique<Session>();
+ Session *s = session[fd].get();
+ s->fd = fd;
+ s->rdata.new_(RFIFO_SIZE);
+ s->wdata.new_(WFIFO_SIZE);
+
+ s->max_rdata = RFIFO_SIZE;
+ s->max_wdata = WFIFO_SIZE;
+ s->func_recv = recv_to_fifo;
+ s->func_send = send_from_fifo;
+ s->func_parse = default_func_parse;
+ s->created = TimeT::now();
+ s->connected = 1;
+
+ return s;
}
-void delete_session(int fd)
+void delete_session(Session *s)
{
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wold-style-cast"
- if (fd < 0 || fd >= FD_SETSIZE)
-#pragma GCC diagnostic pop
+ if (!s)
return;
+
+ int fd = s->fd;
// If this was the highest fd, decrease it
// We could add a loop to decrement fd_max further for every null session,
// but this is cheap and good enough for the typical case
@@ -316,11 +321,10 @@ void delete_session(int fd)
#pragma GCC diagnostic ignored "-Wold-style-cast"
FD_CLR(fd, &readfds);
#pragma GCC diagnostic pop
- if (session[fd])
{
- session[fd]->rdata.delete_();
- session[fd]->wdata.delete_();
- session[fd]->session_data.reset();
+ s->rdata.delete_();
+ s->wdata.delete_();
+ s->session_data.reset();
session[fd].reset();
}
@@ -329,9 +333,8 @@ void delete_session(int fd)
close(fd);
}
-void realloc_fifo(int fd, size_t rfifo_size, size_t wfifo_size)
+void realloc_fifo(Session *s, size_t rfifo_size, size_t wfifo_size)
{
- const std::unique_ptr<socket_data>& s = session[fd];
if (s->max_rdata != rfifo_size && s->rdata_size < rfifo_size)
{
s->rdata.resize(rfifo_size);
@@ -344,18 +347,17 @@ void realloc_fifo(int fd, size_t rfifo_size, size_t wfifo_size)
}
}
-void WFIFOSET(int fd, size_t len)
+void WFIFOSET(Session *s, size_t len)
{
- std::unique_ptr<socket_data>& s = session[fd];
if (s->wdata_size + len + 16384 > s->max_wdata)
{
- realloc_fifo(fd, s->max_rdata, s->max_wdata << 1);
- PRINTF("socket: %d wdata expanded to %zu bytes.\n", fd, s->max_wdata);
+ realloc_fifo(s, s->max_rdata, s->max_wdata << 1);
+ PRINTF("socket: %d wdata expanded to %zu bytes.\n", s, s->max_wdata);
}
if (s->wdata_size + len + 2048 < s->max_wdata)
s->wdata_size += len;
else
- FPRINTF(stderr, "socket: %d wdata lost !!\n", fd), abort();
+ FPRINTF(stderr, "socket: %d wdata lost !!\n", s), abort();
}
void do_sendrecv(interval_t next_ms)
@@ -384,26 +386,27 @@ void do_sendrecv(interval_t next_ms)
return;
for (int i = 0; i < fd_max; i++)
{
- if (!session[i])
+ Session *s = session[i].get();
+ if (!s)
continue;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wold-style-cast"
if (FD_ISSET(i, &wfd))
#pragma GCC diagnostic pop
{
- if (session[i]->func_send)
+ if (s->func_send)
//send_from_fifo(i);
- session[i]->func_send(i);
+ s->func_send(s);
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wold-style-cast"
if (FD_ISSET(i, &rfd))
#pragma GCC diagnostic pop
{
- if (session[i]->func_recv)
+ if (s->func_recv)
//recv_to_fifo(i);
//or connect_client(i);
- session[i]->func_recv(i);
+ s->func_recv(s);
}
}
}
@@ -412,25 +415,26 @@ void do_parsepacket(void)
{
for (int i = 0; i < fd_max; i++)
{
- if (!session[i])
+ Session *s = session[i].get();
+ if (!s)
continue;
- if (!session[i]->connected
- && static_cast<time_t>(TimeT::now()) - static_cast<time_t>(session[i]->created) > CONNECT_TIMEOUT)
+ if (!s->connected
+ && static_cast<time_t>(TimeT::now()) - static_cast<time_t>(s->created) > CONNECT_TIMEOUT)
{
PRINTF("Session #%d timed out\n", i);
- session[i]->eof = 1;
+ s->eof = 1;
}
- if (!session[i]->rdata_size && !session[i]->eof)
+ if (!s->rdata_size && !s->eof)
continue;
- if (session[i]->func_parse)
+ if (s->func_parse)
{
- session[i]->func_parse(i);
+ s->func_parse(s);
/// some func_parse may call delete_session
- if (!session[i])
+ if (!s)
continue;
}
/// Reclaim buffer space for what was read
- RFIFOFLUSH(i);
+ RFIFOFLUSH(s);
}
}
@@ -442,9 +446,8 @@ void do_socket(void)
#pragma GCC diagnostic pop
}
-void RFIFOSKIP(int fd, size_t len)
+void RFIFOSKIP(Session *s, size_t len)
{
- std::unique_ptr<socket_data>& s = session[fd];
s->rdata_pos += len;
if (s->rdata_size < s->rdata_pos)
diff --git a/src/common/socket.hpp b/src/common/socket.hpp
index 8a2ee3a..4d51604 100644
--- a/src/common/socket.hpp
+++ b/src/common/socket.hpp
@@ -29,7 +29,7 @@ struct SessionDeleter
// Struct declaration
-struct socket_data
+struct Session
{
/// Checks whether a newly-connected socket actually does anything
TimeT created;
@@ -54,17 +54,25 @@ struct socket_data
/// Only called when select() indicates the socket is ready
/// If, after that, nothing is read, it sets eof
// These could probably be hard-coded with a little work
- void (*func_recv)(int);
- void (*func_send)(int);
+ void (*func_recv)(Session *);
+ void (*func_send)(Session *);
/// This is the important one
/// Set to different functions depending on whether the connection
/// is a player or a server/ladmin
/// Can be set explicitly or via set_defaultparse
- void (*func_parse)(int);
+ void (*func_parse)(Session *);
/// Server-specific data type
std::unique_ptr<SessionData, SessionDeleter> session_data;
+
+ int fd;
};
+inline
+int convert_for_printf(Session *s)
+{
+ return s->fd;
+}
+
// save file descriptors for important stuff
constexpr int SOFT_LIMIT = FD_SETSIZE - 50;
@@ -73,21 +81,21 @@ constexpr int CONNECT_TIMEOUT = 15;
/// Everyone who has connected
// note: call delete_session(i) to null out an element
-extern std::array<std::unique_ptr<socket_data>, FD_SETSIZE> session;
+extern std::array<std::unique_ptr<Session>, FD_SETSIZE> session;
/// Maximum used FD, +1
extern int fd_max;
/// open a socket, bind, and listen. Return an fd, or -1 if socket() fails,
/// but exit if bind() or listen() fails
-int make_listen_port(uint16_t port);
+Session *make_listen_port(uint16_t port);
/// Connect to an address, return a connected socket or -1
// FIXME - this is IPv4 only!
-int make_connection(IP4Address ip, uint16_t port);
+Session *make_connection(IP4Address ip, uint16_t port);
/// free() the structure and close() the fd
-void delete_session(int);
+void delete_session(Session *);
/// Make a the internal queues bigger
-void realloc_fifo(int fd, size_t rfifo_size, size_t wfifo_size);
+void realloc_fifo(Session *s, size_t rfifo_size, size_t wfifo_size);
/// Update all sockets that can be read/written from the queues
void do_sendrecv(interval_t next);
/// Call the parser function for every socket that has read data
@@ -99,7 +107,7 @@ void do_socket(void);
/// Change the default parser for newly connected clients
// typically called once per server, but individual clients may identify
// themselves as servers
-void set_defaultparse(void(*defaultparse)(int));
+void set_defaultparse(void(*defaultparse)(Session *));
template<class T>
uint8_t *pod_addressof_m(T& structure)
@@ -118,68 +126,68 @@ const uint8_t *pod_addressof_c(const T& structure)
/// Check how much can be read
inline
-size_t RFIFOREST(int fd)
+size_t RFIFOREST(Session *s)
{
- return session[fd]->rdata_size - session[fd]->rdata_pos;
+ return s->rdata_size - s->rdata_pos;
}
/// Read from the queue
inline
-const void *RFIFOP(int fd, size_t pos)
+const void *RFIFOP(Session *s, size_t pos)
{
- return &session[fd]->rdata[session[fd]->rdata_pos + pos];
+ return &s->rdata[s->rdata_pos + pos];
}
inline
-uint8_t RFIFOB(int fd, size_t pos)
+uint8_t RFIFOB(Session *s, size_t pos)
{
- return *static_cast<const uint8_t *>(RFIFOP(fd, pos));
+ return *static_cast<const uint8_t *>(RFIFOP(s, pos));
}
inline
-uint16_t RFIFOW(int fd, size_t pos)
+uint16_t RFIFOW(Session *s, size_t pos)
{
- return *static_cast<const uint16_t *>(RFIFOP(fd, pos));
+ return *static_cast<const uint16_t *>(RFIFOP(s, pos));
}
inline
-uint32_t RFIFOL(int fd, size_t pos)
+uint32_t RFIFOL(Session *s, size_t pos)
{
- return *static_cast<const uint32_t *>(RFIFOP(fd, pos));
+ return *static_cast<const uint32_t *>(RFIFOP(s, pos));
}
template<class T>
-void RFIFO_STRUCT(int fd, size_t pos, T& structure)
+void RFIFO_STRUCT(Session *s, size_t pos, T& structure)
{
- really_memcpy(pod_addressof_m(structure), static_cast<const uint8_t *>(RFIFOP(fd, pos)), sizeof(T));
+ really_memcpy(pod_addressof_m(structure), static_cast<const uint8_t *>(RFIFOP(s, pos)), sizeof(T));
}
inline
-IP4Address RFIFOIP(int fd, size_t pos)
+IP4Address RFIFOIP(Session *s, size_t pos)
{
IP4Address o;
- RFIFO_STRUCT(fd, pos, o);
+ RFIFO_STRUCT(s, pos, o);
return o;
}
template<uint8_t len>
inline
-VString<len-1> RFIFO_STRING(int fd, size_t pos)
+VString<len-1> RFIFO_STRING(Session *s, size_t pos)
{
- const char *const begin = static_cast<const char *>(RFIFOP(fd, pos));
+ const char *const begin = static_cast<const char *>(RFIFOP(s, pos));
const char *const end = begin + len-1;
const char *const mid = std::find(begin, end, '\0');
return XString(begin, mid, nullptr);
}
inline
-FString RFIFO_STRING(int fd, size_t pos, size_t len)
+FString RFIFO_STRING(Session *s, size_t pos, size_t len)
{
- const char *const begin = static_cast<const char *>(RFIFOP(fd, pos));
+ const char *const begin = static_cast<const char *>(RFIFOP(s, pos));
const char *const end = begin + len;
const char *const mid = std::find(begin, end, '\0');
return XString(begin, mid, nullptr);
}
inline
-void RFIFO_BUF_CLONE(int fd, uint8_t *buf, size_t len)
+void RFIFO_BUF_CLONE(Session *s, uint8_t *buf, size_t len)
{
- really_memcpy(buf, static_cast<const uint8_t *>(RFIFOP(fd, 0)), len);
+ really_memcpy(buf, static_cast<const uint8_t *>(RFIFOP(s, 0)), len);
}
/// Done reading
-void RFIFOSKIP(int fd, size_t len);
+void RFIFOSKIP(Session *s, size_t len);
/// Read from an arbitrary buffer
inline
@@ -236,65 +244,65 @@ FString RBUF_STRING(const uint8_t *p, size_t pos, size_t len)
/// Unused - check how much data can be written
// the existence of this seems scary
inline
-size_t WFIFOSPACE(int fd)
+size_t WFIFOSPACE(Session *s)
{
- return session[fd]->max_wdata - session[fd]->wdata_size;
+ return s->max_wdata - s->wdata_size;
}
/// Write to the queue
inline
-void *WFIFOP(int fd, size_t pos)
+void *WFIFOP(Session *s, size_t pos)
{
- return &session[fd]->wdata[session[fd]->wdata_size + pos];
+ return &s->wdata[s->wdata_size + pos];
}
inline
-uint8_t& WFIFOB(int fd, size_t pos)
+uint8_t& WFIFOB(Session *s, size_t pos)
{
- return *static_cast<uint8_t *>(WFIFOP(fd, pos));
+ return *static_cast<uint8_t *>(WFIFOP(s, pos));
}
inline
-uint16_t& WFIFOW(int fd, size_t pos)
+uint16_t& WFIFOW(Session *s, size_t pos)
{
- return *static_cast<uint16_t *>(WFIFOP(fd, pos));
+ return *static_cast<uint16_t *>(WFIFOP(s, pos));
}
inline
-uint32_t& WFIFOL(int fd, size_t pos)
+uint32_t& WFIFOL(Session *s, size_t pos)
{
- return *static_cast<uint32_t *>(WFIFOP(fd, pos));
+ return *static_cast<uint32_t *>(WFIFOP(s, pos));
}
template<class T>
-void WFIFO_STRUCT(int fd, size_t pos, T& structure)
+void WFIFO_STRUCT(Session *s, size_t pos, T& structure)
{
- really_memcpy(static_cast<uint8_t *>(WFIFOP(fd, pos)), pod_addressof_c(structure), sizeof(T));
+ really_memcpy(static_cast<uint8_t *>(WFIFOP(s, pos)), pod_addressof_c(structure), sizeof(T));
}
inline
-IP4Address& WFIFOIP(int fd, size_t pos)
+IP4Address& WFIFOIP(Session *s, size_t pos)
{
static_assert(is_trivially_copyable<IP4Address>::value, "That was the whole point");
- return *static_cast<IP4Address *>(WFIFOP(fd, pos));
+ return *static_cast<IP4Address *>(WFIFOP(s, pos));
}
inline
-void WFIFO_STRING(int fd, size_t pos, XString s, size_t len)
+void WFIFO_STRING(Session *s, size_t pos, XString str, size_t len)
{
- char *const begin = static_cast<char *>(WFIFOP(fd, pos));
+ char *const begin = static_cast<char *>(WFIFOP(s, pos));
char *const end = begin + len;
- char *const mid = std::copy(s.begin(), s.end(), begin);
+ char *const mid = std::copy(str.begin(), str.end(), begin);
std::fill(mid, end, '\0');
}
inline
-void WFIFO_ZERO(int fd, size_t pos, size_t len)
+void WFIFO_ZERO(Session *s, size_t pos, size_t len)
{
- uint8_t *b = static_cast<uint8_t *>(WFIFOP(fd, pos));
+ uint8_t *b = static_cast<uint8_t *>(WFIFOP(s, pos));
uint8_t *e = b + len;
std::fill(b, e, '\0');
}
inline
-void WFIFO_BUF_CLONE(int fd, const uint8_t *buf, size_t len)
+void WFIFO_BUF_CLONE(Session *s, const uint8_t *buf, size_t len)
{
- really_memcpy(static_cast<uint8_t *>(WFIFOP(fd, 0)), buf, len);
+ really_memcpy(static_cast<uint8_t *>(WFIFOP(s, 0)), buf, len);
}
/// Finish writing
-void WFIFOSET(int fd, size_t len);
+void WFIFOSET(Session *s, size_t len);
/// Write to an arbitrary buffer
inline
@@ -344,10 +352,10 @@ void WBUF_ZERO(uint8_t *p, size_t pos, size_t len)
}
inline
-void RFIFO_WFIFO_CLONE(int rfd, int wfd, size_t len)
+void RFIFO_WFIFO_CLONE(Session *rs, Session *ws, size_t len)
{
- really_memcpy(static_cast<uint8_t *>(WFIFOP(wfd, 0)),
- static_cast<const uint8_t *>(RFIFOP(rfd, 0)), len);
+ really_memcpy(static_cast<uint8_t *>(WFIFOP(ws, 0)),
+ static_cast<const uint8_t *>(RFIFOP(rs, 0)), len);
}
#endif // SOCKET_HPP
diff --git a/src/login/login.cpp b/src/login/login.cpp
index beb09c2..ba247b6 100644
--- a/src/login/login.cpp
+++ b/src/login/login.cpp
@@ -112,7 +112,7 @@ int display_parse_fromchar = 0; // 0: no, 1: yes (without packet 0x2714), 2:
static
struct mmo_char_server server[MAX_SERVERS];
static
-int server_fd[MAX_SERVERS];
+Session *server_session[MAX_SERVERS];
static
int server_freezeflag[MAX_SERVERS]; // Char-server anti-freeze system. Counter. 5 ok, 4...0 freezed
static
@@ -121,7 +121,7 @@ static
std::chrono::seconds anti_freeze_interval = std::chrono::seconds(15);
static
-int login_fd;
+Session *login_session;
enum class ACO
{
@@ -664,15 +664,15 @@ void check_auth_sync(TimerData *, tick_t)
// Packet send to all char-servers, except one (wos: without our self)
//--------------------------------------------------------------------
static
-void charif_sendallwos(int sfd, const uint8_t *buf, size_t len)
+void charif_sendallwos(Session *ss, const uint8_t *buf, size_t len)
{
for (int i = 0; i < MAX_SERVERS; i++)
{
- int fd = server_fd[i];
- if (fd >= 0 && fd != sfd)
+ Session *s = server_session[i];
+ if (s && s != ss)
{
- WFIFO_BUF_CLONE(fd, buf, len);
- WFIFOSET(fd, len);
+ WFIFO_BUF_CLONE(s, buf, len);
+ WFIFOSET(s, len);
}
}
}
@@ -697,7 +697,7 @@ void send_GM_accounts(void)
len += 5;
}
WBUFW(buf, 2) = len;
- charif_sendallwos(-1, buf, len);
+ charif_sendallwos(nullptr, buf, len);
}
//-----------------------------------------------------
@@ -770,11 +770,11 @@ int mmo_auth_new(struct mmo_account *account, SEX sex, AccountEmail email)
// Check/authentification of a connection
//---------------------------------------
static
-int mmo_auth(struct mmo_account *account, int fd)
+int mmo_auth(struct mmo_account *account, Session *s)
{
char new_account_sex = '\0';
- IP4Address ip = session[fd]->client_ip;
+ IP4Address ip = s->client_ip;
// Account creation with _M/_F
if (account->passwdenc == 0
@@ -906,7 +906,7 @@ void char_anti_freeze_system(TimerData *, tick_t)
//PRINTF("Entering in char_anti_freeze_system function to check freeze of servers.\n");
for (i = 0; i < MAX_SERVERS; i++)
{
- if (server_fd[i] >= 0)
+ if (server_session[i])
{ // if char-server is online
//PRINTF("char_anti_freeze_system: server #%d '%s', flag: %d.\n", i, server[i].name, server_freezeflag[i]);
if (server_freezeflag[i]-- < 1)
@@ -915,7 +915,7 @@ void char_anti_freeze_system(TimerData *, tick_t)
i, server[i].name);
LOGIN_LOG("Char-server anti-freeze system: char-server #%d '%s' is freezed -> disconnection.\n",
i, server[i].name);
- session[server_fd[i]]->eof = 1;
+ server_session[i]->eof = 1;
}
}
}
@@ -925,35 +925,35 @@ void char_anti_freeze_system(TimerData *, tick_t)
// Packet parsing for char-servers
//--------------------------------
static
-void parse_fromchar(int fd)
+void parse_fromchar(Session *s)
{
- IP4Address ip = session[fd]->client_ip;
+ IP4Address ip = s->client_ip;
int id;
for (id = 0; id < MAX_SERVERS; id++)
- if (server_fd[id] == fd)
+ if (server_session[id] == s)
break;
- if (id == MAX_SERVERS || session[fd]->eof)
+ if (id == MAX_SERVERS || s->eof)
{
if (id < MAX_SERVERS)
{
PRINTF("Char-server '%s' has disconnected.\n", server[id].name);
LOGIN_LOG("Char-server '%s' has disconnected (ip: %s).\n",
server[id].name, ip);
- server_fd[id] = -1;
+ server_session[id] = nullptr;
server[id] = mmo_char_server{};
}
- delete_session(fd);
+ delete_session(s);
return;
}
- while (RFIFOREST(fd) >= 2)
+ while (RFIFOREST(s) >= 2)
{
- if (display_parse_fromchar == 2 || (display_parse_fromchar == 1 && RFIFOW(fd, 0) != 0x2714)) // 0x2714 is done very often (number of players)
+ if (display_parse_fromchar == 2 || (display_parse_fromchar == 1 && RFIFOW(s, 0) != 0x2714)) // 0x2714 is done very often (number of players)
PRINTF("parse_fromchar: connection #%d, packet: 0x%x (with being read: %zu bytes).\n",
- fd, RFIFOW(fd, 0), RFIFOREST(fd));
+ s, RFIFOW(s, 0), RFIFOREST(s));
- switch (RFIFOW(fd, 0))
+ switch (RFIFOW(s, 0))
{
// request from map-server via char-server to reload GM accounts (by Yor).
case 0x2709:
@@ -962,23 +962,23 @@ void parse_fromchar(int fd)
read_gm_account();
// send GM accounts to all char-servers
send_GM_accounts();
- RFIFOSKIP(fd, 2);
+ RFIFOSKIP(s, 2);
break;
case 0x2712: // request from char-server to authentify an account
- if (RFIFOREST(fd) < 19)
+ if (RFIFOREST(s) < 19)
return;
{
- int acc = RFIFOL(fd, 2);
+ int acc = RFIFOL(s, 2);
int i;
for (i = 0; i < AUTH_FIFO_SIZE; i++)
{
if (auth_fifo[i].account_id == acc &&
- auth_fifo[i].login_id1 == RFIFOL(fd, 6) &&
- auth_fifo[i].login_id2 == RFIFOL(fd, 10) && // relate to the versions higher than 18
- auth_fifo[i].sex == static_cast<SEX>(RFIFOB(fd, 14)) &&
+ auth_fifo[i].login_id1 == RFIFOL(s, 6) &&
+ auth_fifo[i].login_id2 == RFIFOL(s, 10) && // relate to the versions higher than 18
+ auth_fifo[i].sex == static_cast<SEX>(RFIFOB(s, 14)) &&
(!check_ip_flag
- || auth_fifo[i].ip == RFIFOIP(fd, 15))
+ || auth_fifo[i].ip == RFIFOIP(s, 15))
&& !auth_fifo[i].delflag)
{
int p;
@@ -989,25 +989,25 @@ void parse_fromchar(int fd)
{
if (ad.account_id == acc)
{
- WFIFOW(fd, 0) = 0x2729; // Sending of the account_reg2
- WFIFOL(fd, 4) = acc;
+ WFIFOW(s, 0) = 0x2729; // Sending of the account_reg2
+ WFIFOL(s, 4) = acc;
int j;
for (p = 8, j = 0;
j < ad.account_reg2_num;
p += 36, j++)
{
- WFIFO_STRING(fd, p, ad.account_reg2[j].str, 32);
- WFIFOL(fd, p + 32) = ad.account_reg2[j].value;
+ WFIFO_STRING(s, p, ad.account_reg2[j].str, 32);
+ WFIFOL(s, p + 32) = ad.account_reg2[j].value;
}
- WFIFOW(fd, 2) = p;
- WFIFOSET(fd, p);
+ WFIFOW(s, 2) = p;
+ WFIFOSET(s, p);
// PRINTF("parse_fromchar: Sending of account_reg2: login->char (auth fifo)\n");
- WFIFOW(fd, 0) = 0x2713;
- WFIFOL(fd, 2) = acc;
- WFIFOB(fd, 6) = 0;
- WFIFO_STRING(fd, 7, ad.email, 40);
- WFIFOL(fd, 47) = static_cast<time_t>(ad.connect_until_time);
- WFIFOSET(fd, 51);
+ WFIFOW(s, 0) = 0x2713;
+ WFIFOL(s, 2) = acc;
+ WFIFOB(s, 6) = 0;
+ WFIFO_STRING(s, 7, ad.email, 40);
+ WFIFOL(s, 47) = static_cast<time_t>(ad.connect_until_time);
+ WFIFOSET(s, 51);
break;
}
}
@@ -1019,34 +1019,34 @@ void parse_fromchar(int fd)
{
LOGIN_LOG("Char-server '%s': authentification of the account %d REFUSED (ip: %s).\n",
server[id].name, acc, ip);
- WFIFOW(fd, 0) = 0x2713;
- WFIFOL(fd, 2) = acc;
- WFIFOB(fd, 6) = 1;
+ WFIFOW(s, 0) = 0x2713;
+ WFIFOL(s, 2) = acc;
+ WFIFOB(s, 6) = 1;
// It is unnecessary to send email
// It is unnecessary to send validity date of the account
- WFIFOSET(fd, 51);
+ WFIFOSET(s, 51);
}
}
- RFIFOSKIP(fd, 19);
+ RFIFOSKIP(s, 19);
break;
case 0x2714:
- if (RFIFOREST(fd) < 6)
+ if (RFIFOREST(s) < 6)
return;
//PRINTF("parse_fromchar: Receiving of the users number of the server '%s': %d\n", server[id].name, RFIFOL(fd,2));
- server[id].users = RFIFOL(fd, 2);
+ server[id].users = RFIFOL(s, 2);
if (anti_freeze_enable)
server_freezeflag[id] = 5; // Char anti-freeze system. Counter. 5 ok, 4...0 freezed
- RFIFOSKIP(fd, 6);
+ RFIFOSKIP(s, 6);
break;
// we receive a e-mail creation of an account with a default e-mail (no answer)
case 0x2715:
- if (RFIFOREST(fd) < 46)
+ if (RFIFOREST(s) < 46)
return;
{
- int acc = RFIFOL(fd, 2);
- AccountEmail email = stringish<AccountEmail>(RFIFO_STRING<40>(fd, 6));
+ int acc = RFIFOL(s, 2);
+ AccountEmail email = stringish<AccountEmail>(RFIFO_STRING<40>(s, 6));
if (!e_mail_check(email))
LOGIN_LOG("Char-server '%s': Attempt to create an e-mail on an account with a default e-mail REFUSED - e-mail is invalid (account: %d, ip: %s)\n",
server[id].name, acc, ip);
@@ -1067,16 +1067,16 @@ void parse_fromchar(int fd)
server[id].name, acc, ip);
}
x2715_out:
- RFIFOSKIP(fd, 46);
+ RFIFOSKIP(s, 46);
break;
// We receive an e-mail/limited time request, because a player comes back from a map-server to the char-server
}
case 0x2716:
- if (RFIFOREST(fd) < 6)
+ if (RFIFOREST(s) < 6)
return;
{
- int account_id = RFIFOL(fd, 2);
+ int account_id = RFIFOL(s, 2);
//PRINTF("parse_fromchar: E-mail/limited time request from '%s' server (concerned account: %d)\n", server[id].name, RFIFOL(fd,2));
for (const AuthData& ad : auth_data)
{
@@ -1084,11 +1084,11 @@ void parse_fromchar(int fd)
{
LOGIN_LOG("Char-server '%s': e-mail of the account %d found (ip: %s).\n",
server[id].name, account_id, ip);
- WFIFOW(fd, 0) = 0x2717;
- WFIFOL(fd, 2) = account_id;
- WFIFO_STRING(fd, 6, ad.email, 40);
- WFIFOL(fd, 46) = static_cast<time_t>(ad.connect_until_time);
- WFIFOSET(fd, 50);
+ WFIFOW(s, 0) = 0x2717;
+ WFIFOL(s, 2) = account_id;
+ WFIFO_STRING(s, 6, ad.email, 40);
+ WFIFOL(s, 46) = static_cast<time_t>(ad.connect_until_time);
+ WFIFOSET(s, 50);
goto x2716_end;
}
}
@@ -1096,22 +1096,22 @@ void parse_fromchar(int fd)
server[id].name, account_id, ip);
}
x2716_end:
- RFIFOSKIP(fd, 6);
+ RFIFOSKIP(s, 6);
break;
case 0x2720: // To become GM request
- if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd, 2))
+ if (RFIFOREST(s) < 4 || RFIFOREST(s) < RFIFOW(s, 2))
return;
{
int acc;
unsigned char buf[10];
- acc = RFIFOL(fd, 4);
+ acc = RFIFOL(s, 4);
//PRINTF("parse_fromchar: Request to become a GM acount from %d account.\n", acc);
WBUFW(buf, 0) = 0x2721;
WBUFL(buf, 2) = acc;
WBUFL(buf, 6) = 0;
- size_t len = RFIFOW(fd, 2) - 8;
- FString pass = RFIFO_STRING(fd, 8, len);
+ size_t len = RFIFOW(s, 2) - 8;
+ FString pass = RFIFO_STRING(s, 8, len);
if (pass == gm_pass)
{
@@ -1175,19 +1175,19 @@ void parse_fromchar(int fd)
LOGIN_LOG("Char-server '%s': Error of GM change (suggested account: %d, invalid password, ip: %s).\n",
server[id].name, acc, ip);
}
- charif_sendallwos(-1, buf, 10);
+ charif_sendallwos(nullptr, buf, 10);
}
- RFIFOSKIP(fd, RFIFOW(fd, 2));
+ RFIFOSKIP(s, RFIFOW(s, 2));
return;
// Map server send information to change an email of an account via char-server
case 0x2722: // 0x2722 <account_id>.L <actual_e-mail>.40B <new_e-mail>.40B
- if (RFIFOREST(fd) < 86)
+ if (RFIFOREST(s) < 86)
return;
{
- int acc = RFIFOL(fd, 2);
- AccountEmail actual_email = stringish<AccountEmail>(RFIFO_STRING<40>(fd, 6).to_print());
- AccountEmail new_email = stringish<AccountEmail>(RFIFO_STRING<40>(fd, 46));
+ int acc = RFIFOL(s, 2);
+ AccountEmail actual_email = stringish<AccountEmail>(RFIFO_STRING<40>(s, 6).to_print());
+ AccountEmail new_email = stringish<AccountEmail>(RFIFO_STRING<40>(s, 46));
if (!e_mail_check(actual_email))
LOGIN_LOG("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but actual email is invalid (account: %d, ip: %s)\n",
server[id].name, acc, ip);
@@ -1223,17 +1223,17 @@ void parse_fromchar(int fd)
}
}
x2722_out:
- RFIFOSKIP(fd, 86);
+ RFIFOSKIP(s, 86);
break;
// Receiving of map-server via char-server a status change resquest (by Yor)
case 0x2724:
- if (RFIFOREST(fd) < 10)
+ if (RFIFOREST(s) < 10)
return;
{
int acc, statut;
- acc = RFIFOL(fd, 2);
- statut = RFIFOL(fd, 6);
+ acc = RFIFOL(s, 2);
+ statut = RFIFOL(s, 6);
for (AuthData& ad : auth_data)
{
if (ad.account_id == acc)
@@ -1250,7 +1250,7 @@ void parse_fromchar(int fd)
WBUFL(buf, 2) = acc;
WBUFB(buf, 6) = 0; // 0: change of statut, 1: ban
WBUFL(buf, 7) = statut; // status or final date of a banishment
- charif_sendallwos(-1, buf, 11);
+ charif_sendallwos(nullptr, buf, 11);
for (int j = 0; j < AUTH_FIFO_SIZE; j++)
if (auth_fifo[j].account_id == acc)
auth_fifo[j].login_id1++; // to avoid reconnection error when come back from map-server (char-server will ask again the authentification)
@@ -1267,16 +1267,16 @@ void parse_fromchar(int fd)
LOGIN_LOG("Char-server '%s': Error of Status change (account: %d not found, suggested status %d, ip: %s).\n",
server[id].name, acc, statut, ip);
x2724_out:
- RFIFOSKIP(fd, 10);
+ RFIFOSKIP(s, 10);
}
return;
case 0x2725: // Receiving of map-server via char-server a ban resquest (by Yor)
- if (RFIFOREST(fd) < 18)
+ if (RFIFOREST(s) < 18)
return;
{
int acc;
- acc = RFIFOL(fd, 2);
+ acc = RFIFOL(s, 2);
for (AuthData& ad : auth_data)
{
if (ad.account_id == acc)
@@ -1290,7 +1290,7 @@ void parse_fromchar(int fd)
timestamp = ad.ban_until_time;
struct tm tmtime = timestamp;
HumanTimeDiff ban_diff;
- RFIFO_STRUCT(fd, 6, ban_diff);
+ RFIFO_STRUCT(s, 6, ban_diff);
tmtime.tm_year += ban_diff.year;
tmtime.tm_mon += ban_diff.month;
tmtime.tm_mday += ban_diff.day;
@@ -1319,7 +1319,7 @@ void parse_fromchar(int fd)
WBUFL(buf, 2) = ad.account_id;
WBUFB(buf, 6) = 1; // 0: change of statut, 1: ban
WBUFL(buf, 7) = static_cast<time_t>(timestamp); // status or final date of a banishment
- charif_sendallwos(-1, buf, 11);
+ charif_sendallwos(nullptr, buf, 11);
for (int j = 0; j < AUTH_FIFO_SIZE; j++)
if (auth_fifo[j].account_id ==
acc)
@@ -1350,16 +1350,16 @@ void parse_fromchar(int fd)
LOGIN_LOG("Char-server '%s': Error of ban request (account: %d not found, ip: %s).\n",
server[id].name, acc, ip);
x2725_out:
- RFIFOSKIP(fd, 18);
+ RFIFOSKIP(s, 18);
}
return;
case 0x2727: // Change of sex (sex is reversed)
- if (RFIFOREST(fd) < 6)
+ if (RFIFOREST(s) < 6)
return;
{
int acc;
- acc = RFIFOL(fd, 2);
+ acc = RFIFOL(s, 2);
for (AuthData& ad : auth_data)
{
if (ad.account_id == acc)
@@ -1382,7 +1382,7 @@ void parse_fromchar(int fd)
WBUFW(buf, 0) = 0x2723;
WBUFL(buf, 2) = acc;
WBUFB(buf, 6) = static_cast<uint8_t>(sex);
- charif_sendallwos(-1, buf, 7);
+ charif_sendallwos(nullptr, buf, 7);
}
goto x2727_out;
}
@@ -1390,37 +1390,37 @@ void parse_fromchar(int fd)
LOGIN_LOG("Char-server '%s': Error of sex change (account: %d not found, sex would be reversed, ip: %s).\n",
server[id].name, acc, ip);
x2727_out:
- RFIFOSKIP(fd, 6);
+ RFIFOSKIP(s, 6);
}
return;
case 0x2728: // We receive account_reg2 from a char-server, and we send them to other char-servers.
- if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd, 2))
+ if (RFIFOREST(s) < 4 || RFIFOREST(s) < RFIFOW(s, 2))
return;
{
int acc, p;
- acc = RFIFOL(fd, 4);
+ acc = RFIFOL(s, 4);
for (AuthData& ad : auth_data)
{
if (ad.account_id == acc)
{
LOGIN_LOG("Char-server '%s': receiving (from the char-server) of account_reg2 (account: %d, ip: %s).\n",
server[id].name, acc, ip);
- size_t len = RFIFOW(fd, 2);
+ size_t len = RFIFOW(s, 2);
int j;
for (p = 8, j = 0;
p < len && j < ACCOUNT_REG2_NUM;
p += 36, j++)
{
- ad.account_reg2[j].str = stringish<VarName>(RFIFO_STRING<32>(fd, p).to_print());
- ad.account_reg2[j].value = RFIFOL(fd, p + 32);
+ ad.account_reg2[j].str = stringish<VarName>(RFIFO_STRING<32>(s, p).to_print());
+ ad.account_reg2[j].value = RFIFOL(s, p + 32);
}
ad.account_reg2_num = j;
// Sending information towards the other char-servers.
uint8_t buf[len];
- RFIFO_BUF_CLONE(fd, buf, len);
+ RFIFO_BUF_CLONE(s, buf, len);
WBUFW(buf, 0) = 0x2729;
- charif_sendallwos(fd, buf, WBUFW(buf, 2));
+ charif_sendallwos(s, buf, WBUFW(buf, 2));
// PRINTF("parse_fromchar: receiving (from the char-server) of account_reg2 (account id: %d).\n", acc);
goto x2728_out;
}
@@ -1429,14 +1429,14 @@ void parse_fromchar(int fd)
server[id].name, acc, ip);
}
x2728_out:
- RFIFOSKIP(fd, RFIFOW(fd, 2));
+ RFIFOSKIP(s, RFIFOW(s, 2));
break;
case 0x272a: // Receiving of map-server via char-server a unban resquest (by Yor)
- if (RFIFOREST(fd) < 6)
+ if (RFIFOREST(s) < 6)
return;
{
- int acc = RFIFOL(fd, 2);
+ int acc = RFIFOL(s, 2);
for (AuthData& ad : auth_data)
{
if (ad.account_id == acc)
@@ -1458,18 +1458,18 @@ void parse_fromchar(int fd)
LOGIN_LOG("Char-server '%s': Error of UnBan request (account: %d not found, ip: %s).\n",
server[id].name, acc, ip);
x272a_out:
- RFIFOSKIP(fd, 6);
+ RFIFOSKIP(s, 6);
}
return;
// request from char-server to change account password
case 0x2740: // 0x2740 <account_id>.L <actual_password>.24B <new_password>.24B
- if (RFIFOREST(fd) < 54)
+ if (RFIFOREST(s) < 54)
return;
{
- int acc = RFIFOL(fd, 2);
- AccountPass actual_pass = stringish<AccountPass>(RFIFO_STRING<24>(fd, 6).to_print());
- AccountPass new_pass = stringish<AccountPass>(RFIFO_STRING<24>(fd, 30).to_print());
+ int acc = RFIFOL(s, 2);
+ AccountPass actual_pass = stringish<AccountPass>(RFIFO_STRING<24>(s, 6).to_print());
+ AccountPass new_pass = stringish<AccountPass>(RFIFO_STRING<24>(s, 30).to_print());
int status = 0;
@@ -1501,13 +1501,13 @@ void parse_fromchar(int fd)
}
}
x2740_out:
- WFIFOW(fd, 0) = 0x2741;
- WFIFOL(fd, 2) = acc;
- WFIFOB(fd, 6) = status; // 0: acc not found, 1: success, 2: password mismatch, 3: pass too short
- WFIFOSET(fd, 7);
+ WFIFOW(s, 0) = 0x2741;
+ WFIFOL(s, 2) = acc;
+ WFIFOB(s, 6) = status; // 0: acc not found, 1: success, 2: password mismatch, 3: pass too short
+ WFIFOSET(s, 7);
}
- RFIFOSKIP(fd, 54);
+ RFIFOSKIP(s, 54);
break;
default:
@@ -1522,19 +1522,19 @@ void parse_fromchar(int fd)
timestr);
FPRINTF(logfp,
"parse_fromchar: connection #%d (ip: %s), packet: 0x%x (with being read: %zu).\n",
- fd, ip, RFIFOW(fd, 0), RFIFOREST(fd));
+ s, ip, RFIFOW(s, 0), RFIFOREST(s));
FPRINTF(logfp, "Detail (in hex):\n");
FPRINTF(logfp,
"---- 00-01-02-03-04-05-06-07 08-09-0A-0B-0C-0D-0E-0F\n");
char tmpstr[16 + 1] {};
int i;
- for (i = 0; i < RFIFOREST(fd); i++)
+ for (i = 0; i < RFIFOREST(s); i++)
{
if ((i & 15) == 0)
FPRINTF(logfp, "%04X ", i);
- FPRINTF(logfp, "%02x ", RFIFOB(fd, i));
- if (RFIFOB(fd, i) > 0x1f)
- tmpstr[i % 16] = RFIFOB(fd, i);
+ FPRINTF(logfp, "%02x ", RFIFOB(s, i));
+ if (RFIFOB(s, i) > 0x1f)
+ tmpstr[i % 16] = RFIFOB(s, i);
else
tmpstr[i % 16] = '.';
if ((i - 7) % 16 == 0) // -8 + 1
@@ -1559,8 +1559,8 @@ void parse_fromchar(int fd)
}
}
PRINTF("parse_fromchar: Unknown packet 0x%x (from a char-server)! -> disconnection.\n",
- RFIFOW(fd, 0));
- session[fd]->eof = 1;
+ RFIFOW(s, 0));
+ s->eof = 1;
PRINTF("Char-server has been disconnected (unknown packet).\n");
return;
}
@@ -1572,51 +1572,51 @@ void parse_fromchar(int fd)
// Packet parsing for administation login
//---------------------------------------
static
-void parse_admin(int fd)
+void parse_admin(Session *s)
{
- IP4Address ip = session[fd]->client_ip;
+ IP4Address ip = s->client_ip;
- if (session[fd]->eof)
+ if (s->eof)
{
- delete_session(fd);
+ delete_session(s);
PRINTF("Remote administration has disconnected (session #%d).\n",
- fd);
+ s);
return;
}
- while (RFIFOREST(fd) >= 2)
+ while (RFIFOREST(s) >= 2)
{
if (display_parse_admin == 1)
PRINTF("parse_admin: connection #%d, packet: 0x%x (with being read: %zu).\n",
- fd, RFIFOW(fd, 0), RFIFOREST(fd));
+ s, RFIFOW(s, 0), RFIFOREST(s));
- switch (RFIFOW(fd, 0))
+ switch (RFIFOW(s, 0))
{
case 0x7530: // Request of the server version
LOGIN_LOG("'ladmin': Sending of the server version (ip: %s)\n",
ip);
- WFIFOW(fd, 0) = 0x7531;
- WFIFO_STRUCT(fd, 2, CURRENT_LOGIN_SERVER_VERSION);
- WFIFOSET(fd, 10);
- RFIFOSKIP(fd, 2);
+ WFIFOW(s, 0) = 0x7531;
+ WFIFO_STRUCT(s, 2, CURRENT_LOGIN_SERVER_VERSION);
+ WFIFOSET(s, 10);
+ RFIFOSKIP(s, 2);
break;
case 0x7532: // Request of end of connection
LOGIN_LOG("'ladmin': End of connection (ip: %s)\n",
ip);
- RFIFOSKIP(fd, 2);
- session[fd]->eof = 1;
+ RFIFOSKIP(s, 2);
+ s->eof = 1;
break;
case 0x7920: // Request of an accounts list
- if (RFIFOREST(fd) < 10)
+ if (RFIFOREST(s) < 10)
return;
{
int st, ed, len;
- st = RFIFOL(fd, 2);
- ed = RFIFOL(fd, 6);
- RFIFOSKIP(fd, 10);
- WFIFOW(fd, 0) = 0x7921;
+ st = RFIFOL(s, 2);
+ ed = RFIFOL(s, 6);
+ RFIFOSKIP(s, 10);
+ WFIFOW(s, 0) = 0x7921;
if (st < 0)
st = 0;
if (ed > END_ACCOUNT_NUM || ed < st || ed <= 0)
@@ -1632,49 +1632,49 @@ void parse_admin(int fd)
int account_id = ad.account_id;
if (account_id >= st && account_id <= ed)
{
- WFIFOL(fd, len) = account_id;
- WFIFOB(fd, len + 4) = isGM(account_id);
- WFIFO_STRING(fd, len + 5, ad.userid, 24);
- WFIFOB(fd, len + 29) = static_cast<uint8_t>(ad.sex);
- WFIFOL(fd, len + 30) = ad.logincount;
+ WFIFOL(s, len) = account_id;
+ WFIFOB(s, len + 4) = isGM(account_id);
+ WFIFO_STRING(s, len + 5, ad.userid, 24);
+ WFIFOB(s, len + 29) = static_cast<uint8_t>(ad.sex);
+ WFIFOL(s, len + 30) = ad.logincount;
if (ad.state == 0 && ad.ban_until_time) // if no state and banished
- WFIFOL(fd, len + 34) = 7; // 6 = Your are Prohibited to log in until %s
+ WFIFOL(s, len + 34) = 7; // 6 = Your are Prohibited to log in until %s
else
- WFIFOL(fd, len + 34) = ad.state;
+ WFIFOL(s, len + 34) = ad.state;
len += 38;
}
}
- WFIFOW(fd, 2) = len;
- WFIFOSET(fd, len);
+ WFIFOW(s, 2) = len;
+ WFIFOSET(s, len);
}
break;
case 0x7924:
{ // [Fate] Itemfrob package: change item IDs
- if (RFIFOREST(fd) < 10)
+ if (RFIFOREST(s) < 10)
return;
uint8_t buf[10];
- RFIFO_BUF_CLONE(fd, buf, 10);
+ RFIFO_BUF_CLONE(s, buf, 10);
// forward package to char servers
- charif_sendallwos(-1, buf, 10);
- RFIFOSKIP(fd, 10);
- WFIFOW(fd, 0) = 0x7925;
- WFIFOSET(fd, 2);
+ charif_sendallwos(nullptr, buf, 10);
+ RFIFOSKIP(s, 10);
+ WFIFOW(s, 0) = 0x7925;
+ WFIFOSET(s, 2);
break;
}
case 0x7930: // Request for an account creation
- if (RFIFOREST(fd) < 91)
+ if (RFIFOREST(s) < 91)
return;
{
struct mmo_account ma;
- ma.userid = stringish<AccountName>(RFIFO_STRING<24>(fd, 2).to_print());
- ma.passwd = stringish<AccountPass>(RFIFO_STRING<24>(fd, 26).to_print());
+ ma.userid = stringish<AccountName>(RFIFO_STRING<24>(s, 2).to_print());
+ ma.passwd = stringish<AccountPass>(RFIFO_STRING<24>(s, 26).to_print());
ma.lastlogin = stringish<timestamp_milliseconds_buffer>("-");
- ma.sex = sex_from_char(RFIFOB(fd, 50));
- WFIFOW(fd, 0) = 0x7931;
- WFIFOL(fd, 2) = -1;
- WFIFO_STRING(fd, 6, ma.userid, 24);
+ ma.sex = sex_from_char(RFIFOB(s, 50));
+ WFIFOW(s, 0) = 0x7931;
+ WFIFOL(s, 2) = -1;
+ WFIFO_STRING(s, 6, ma.userid, 24);
if (ma.userid.size() < 4 || ma.passwd.size() < 4)
{
LOGIN_LOG("'ladmin': Attempt to create an invalid account (account or pass is too short, ip: %s)\n",
@@ -1702,27 +1702,27 @@ void parse_admin(int fd)
}
}
{
- AccountEmail email = stringish<AccountEmail>(RFIFO_STRING<40>(fd, 51));
+ AccountEmail email = stringish<AccountEmail>(RFIFO_STRING<40>(s, 51));
int new_id = mmo_auth_new(&ma, ma.sex, email);
LOGIN_LOG("'ladmin': Account creation (account: %s (id: %d), sex: %c, email: %s, ip: %s)\n",
ma.userid, new_id,
ma.sex, auth_data.back().email, ip);
- WFIFOL(fd, 2) = new_id;
+ WFIFOL(s, 2) = new_id;
}
}
x7930_out:
- WFIFOSET(fd, 30);
- RFIFOSKIP(fd, 91);
+ WFIFOSET(s, 30);
+ RFIFOSKIP(s, 91);
}
break;
case 0x7932: // Request for an account deletion
- if (RFIFOREST(fd) < 26)
+ if (RFIFOREST(s) < 26)
return;
{
- WFIFOW(fd, 0) = 0x7933;
- WFIFOL(fd, 2) = -1;
- AccountName account_name = stringish<AccountName>(RFIFO_STRING<24>(fd, 2).to_print());
+ WFIFOW(s, 0) = 0x7933;
+ WFIFOL(s, 2) = -1;
+ AccountName account_name = stringish<AccountName>(RFIFO_STRING<24>(s, 2).to_print());
AuthData *ad = search_account(account_name);
if (ad)
{
@@ -1730,10 +1730,10 @@ void parse_admin(int fd)
uint8_t buf[6];
WBUFW(buf, 0) = 0x2730;
WBUFL(buf, 2) = ad->account_id;
- charif_sendallwos(-1, buf, 6);
+ charif_sendallwos(nullptr, buf, 6);
// send answer
- WFIFO_STRING(fd, 6, ad->userid, 24);
- WFIFOL(fd, 2) = ad->account_id;
+ WFIFO_STRING(s, 6, ad->userid, 24);
+ WFIFOL(s, 2) = ad->account_id;
// save deleted account in log file
LOGIN_LOG("'ladmin': Account deletion (account: %s, id: %d, ip: %s) - saved in next line:\n",
ad->userid, ad->account_id,
@@ -1748,52 +1748,52 @@ void parse_admin(int fd)
}
else
{
- WFIFO_STRING(fd, 6, account_name, 24);
+ WFIFO_STRING(s, 6, account_name, 24);
LOGIN_LOG("'ladmin': Attempt to delete an unknown account (account: %s, ip: %s)\n",
account_name, ip);
}
- WFIFOSET(fd, 30);
+ WFIFOSET(s, 30);
}
- RFIFOSKIP(fd, 26);
+ RFIFOSKIP(s, 26);
break;
case 0x7934: // Request to change a password
- if (RFIFOREST(fd) < 50)
+ if (RFIFOREST(s) < 50)
return;
{
- WFIFOW(fd, 0) = 0x7935;
- WFIFOL(fd, 2) = -1;
- AccountName account_name = stringish<AccountName>(RFIFO_STRING<24>(fd, 2).to_print());
+ WFIFOW(s, 0) = 0x7935;
+ WFIFOL(s, 2) = -1;
+ AccountName account_name = stringish<AccountName>(RFIFO_STRING<24>(s, 2).to_print());
AuthData *ad = search_account(account_name);
if (ad)
{
- WFIFO_STRING(fd, 6, ad->userid, 24);
- AccountPass plain = stringish<AccountPass>(RFIFO_STRING<24>(fd, 26));
+ WFIFO_STRING(s, 6, ad->userid, 24);
+ AccountPass plain = stringish<AccountPass>(RFIFO_STRING<24>(s, 26));
ad->pass = MD5_saltcrypt(plain, make_salt());
- WFIFOL(fd, 2) = ad->account_id;
+ WFIFOL(s, 2) = ad->account_id;
LOGIN_LOG("'ladmin': Modification of a password (account: %s, new password: %s, ip: %s)\n",
ad->userid, ad->pass, ip);
}
else
{
- WFIFO_STRING(fd, 6, account_name, 24);
+ WFIFO_STRING(s, 6, account_name, 24);
LOGIN_LOG("'ladmin': Attempt to modify the password of an unknown account (account: %s, ip: %s)\n",
account_name, ip);
}
- WFIFOSET(fd, 30);
+ WFIFOSET(s, 30);
}
- RFIFOSKIP(fd, 50);
+ RFIFOSKIP(s, 50);
break;
case 0x7936: // Request to modify a state
- if (RFIFOREST(fd) < 50)
+ if (RFIFOREST(s) < 50)
return;
{
- WFIFOW(fd, 0) = 0x7937;
- WFIFOL(fd, 2) = -1;
- AccountName account_name = stringish<AccountName>(RFIFO_STRING<24>(fd, 2).to_print());
- int statut = RFIFOL(fd, 26);
- timestamp_seconds_buffer error_message = stringish<timestamp_seconds_buffer>(RFIFO_STRING<20>(fd, 30).to_print());
+ WFIFOW(s, 0) = 0x7937;
+ WFIFOL(s, 2) = -1;
+ AccountName account_name = stringish<AccountName>(RFIFO_STRING<24>(s, 2).to_print());
+ int statut = RFIFOL(s, 26);
+ timestamp_seconds_buffer error_message = stringish<timestamp_seconds_buffer>(RFIFO_STRING<20>(s, 30).to_print());
if (statut != 7 || !error_message)
{
// 7: // 6 = Your are Prohibited to log in until %s
@@ -1802,8 +1802,8 @@ void parse_admin(int fd)
AuthData *ad = search_account(account_name);
if (ad)
{
- WFIFO_STRING(fd, 6, ad->userid, 24);
- WFIFOL(fd, 2) = ad->account_id;
+ WFIFO_STRING(s, 6, ad->userid, 24);
+ WFIFOL(s, 2) = ad->account_id;
if (ad->state == statut
&& ad->error_message == error_message)
LOGIN_LOG("'ladmin': Modification of a state, but the state of the account is already the good state (account: %s, received state: %d, ip: %s)\n",
@@ -1824,7 +1824,7 @@ void parse_admin(int fd)
WBUFL(buf, 2) = ad->account_id;
WBUFB(buf, 6) = 0; // 0: change of statut, 1: ban
WBUFL(buf, 7) = statut; // status or final date of a banishment
- charif_sendallwos(-1, buf, 11);
+ charif_sendallwos(nullptr, buf, 11);
for (int j = 0; j < AUTH_FIFO_SIZE; j++)
if (auth_fifo[j].account_id ==
ad->account_id)
@@ -1836,14 +1836,14 @@ void parse_admin(int fd)
}
else
{
- WFIFO_STRING(fd, 6, account_name, 24);
+ WFIFO_STRING(s, 6, account_name, 24);
LOGIN_LOG("'ladmin': Attempt to modify the state of an unknown account (account: %s, received state: %d, ip: %s)\n",
account_name, statut, ip);
}
- WFIFOL(fd, 30) = statut;
+ WFIFOL(s, 30) = statut;
}
- WFIFOSET(fd, 34);
- RFIFOSKIP(fd, 50);
+ WFIFOSET(s, 34);
+ RFIFOSKIP(s, 50);
break;
case 0x7938: // Request for servers list and # of online players
@@ -1851,38 +1851,38 @@ void parse_admin(int fd)
server_num = 0;
for (int i = 0; i < MAX_SERVERS; i++)
{
- if (server_fd[i] >= 0)
+ if (server_session[i])
{
- WFIFOIP(fd, 4 + server_num * 32) = server[i].ip;
- WFIFOW(fd, 4 + server_num * 32 + 4) = server[i].port;
- WFIFO_STRING(fd, 4 + server_num * 32 + 6, server[i].name, 20);
- WFIFOW(fd, 4 + server_num * 32 + 26) = server[i].users;
- WFIFOW(fd, 4 + server_num * 32 + 28) = 0; //maintenance;
- WFIFOW(fd, 4 + server_num * 32 + 30) = 0; //is_new;
+ WFIFOIP(s, 4 + server_num * 32) = server[i].ip;
+ WFIFOW(s, 4 + server_num * 32 + 4) = server[i].port;
+ WFIFO_STRING(s, 4 + server_num * 32 + 6, server[i].name, 20);
+ WFIFOW(s, 4 + server_num * 32 + 26) = server[i].users;
+ WFIFOW(s, 4 + server_num * 32 + 28) = 0; //maintenance;
+ WFIFOW(s, 4 + server_num * 32 + 30) = 0; //is_new;
server_num++;
}
}
- WFIFOW(fd, 0) = 0x7939;
- WFIFOW(fd, 2) = 4 + 32 * server_num;
- WFIFOSET(fd, 4 + 32 * server_num);
- RFIFOSKIP(fd, 2);
+ WFIFOW(s, 0) = 0x7939;
+ WFIFOW(s, 2) = 4 + 32 * server_num;
+ WFIFOSET(s, 4 + 32 * server_num);
+ RFIFOSKIP(s, 2);
break;
case 0x793a: // Request to password check
- if (RFIFOREST(fd) < 50)
+ if (RFIFOREST(s) < 50)
return;
{
- WFIFOW(fd, 0) = 0x793b;
- WFIFOL(fd, 2) = -1;
- AccountName account_name = stringish<AccountName>(RFIFO_STRING<24>(fd, 2).to_print());
+ WFIFOW(s, 0) = 0x793b;
+ WFIFOL(s, 2) = -1;
+ AccountName account_name = stringish<AccountName>(RFIFO_STRING<24>(s, 2).to_print());
const AuthData *ad = search_account(account_name);
if (ad)
{
- WFIFO_STRING(fd, 6, ad->userid, 24);
- AccountPass pass = stringish<AccountPass>(RFIFO_STRING<24>(fd, 26));
+ WFIFO_STRING(s, 6, ad->userid, 24);
+ AccountPass pass = stringish<AccountPass>(RFIFO_STRING<24>(s, 26));
if (pass_ok(pass, ad->pass))
{
- WFIFOL(fd, 2) = ad->account_id;
+ WFIFOL(s, 2) = ad->account_id;
LOGIN_LOG("'ladmin': Check of password OK (account: %s, password: %s, ip: %s)\n",
ad->userid, ad->pass,
ip);
@@ -1895,25 +1895,25 @@ void parse_admin(int fd)
}
else
{
- WFIFO_STRING(fd, 6, account_name, 24);
+ WFIFO_STRING(s, 6, account_name, 24);
LOGIN_LOG("'ladmin': Attempt to check the password of an unknown account (account: %s, ip: %s)\n",
account_name, ip);
}
- WFIFOSET(fd, 30);
+ WFIFOSET(s, 30);
}
- RFIFOSKIP(fd, 50);
+ RFIFOSKIP(s, 50);
break;
case 0x793c: // Request to modify sex
- if (RFIFOREST(fd) < 27)
+ if (RFIFOREST(s) < 27)
return;
{
- WFIFOW(fd, 0) = 0x793d;
- WFIFOL(fd, 2) = -1;
- AccountName account_name = stringish<AccountName>(RFIFO_STRING<24>(fd, 2).to_print());
- WFIFO_STRING(fd, 6, account_name, 24);
+ WFIFOW(s, 0) = 0x793d;
+ WFIFOL(s, 2) = -1;
+ AccountName account_name = stringish<AccountName>(RFIFO_STRING<24>(s, 2).to_print());
+ WFIFO_STRING(s, 6, account_name, 24);
{
- SEX sex = sex_from_char(RFIFOB(fd, 26));
+ SEX sex = sex_from_char(RFIFOB(s, 26));
if (sex != SEX::FEMALE && sex != SEX::MALE)
{
LOGIN_LOG("'ladmin': Attempt to give an invalid sex (account: %s, received sex: %c, ip: %s)\n",
@@ -1924,11 +1924,11 @@ void parse_admin(int fd)
AuthData *ad = search_account(account_name);
if (ad)
{
- WFIFO_STRING(fd, 6, ad->userid, 24);
+ WFIFO_STRING(s, 6, ad->userid, 24);
if (ad->sex != sex)
{
unsigned char buf[16];
- WFIFOL(fd, 2) = ad->account_id;
+ WFIFOL(s, 2) = ad->account_id;
for (int j = 0; j < AUTH_FIFO_SIZE; j++)
if (auth_fifo[j].account_id ==
ad->account_id)
@@ -1940,7 +1940,7 @@ void parse_admin(int fd)
WBUFW(buf, 0) = 0x2723;
WBUFL(buf, 2) = ad->account_id;
WBUFB(buf, 6) = static_cast<uint8_t>(ad->sex);
- charif_sendallwos(-1, buf, 7);
+ charif_sendallwos(nullptr, buf, 7);
}
else
{
@@ -1955,23 +1955,23 @@ void parse_admin(int fd)
}
}
}
- WFIFOSET(fd, 30);
+ WFIFOSET(s, 30);
}
- RFIFOSKIP(fd, 27);
+ RFIFOSKIP(s, 27);
break;
case 0x793e: // Request to modify GM level
- if (RFIFOREST(fd) < 27)
+ if (RFIFOREST(s) < 27)
return;
{
- WFIFOW(fd, 0) = 0x793f;
- WFIFOL(fd, 2) = -1;
- AccountName account_name = stringish<AccountName>(RFIFO_STRING<24>(fd, 2).to_print());
- WFIFO_STRING(fd, 6, account_name, 24);
+ WFIFOW(s, 0) = 0x793f;
+ WFIFOL(s, 2) = -1;
+ AccountName account_name = stringish<AccountName>(RFIFO_STRING<24>(s, 2).to_print());
+ WFIFO_STRING(s, 6, account_name, 24);
bool reread = false;
{
char new_gm_level;
- new_gm_level = RFIFOB(fd, 26);
+ new_gm_level = RFIFOB(s, 26);
if (new_gm_level < 0 || new_gm_level > 99)
{
LOGIN_LOG("'ladmin': Attempt to give an invalid GM level (account: %s, received GM level: %d, ip: %s)\n",
@@ -1983,7 +1983,7 @@ void parse_admin(int fd)
if (ad)
{
int acc = ad->account_id;
- WFIFO_STRING(fd, 6, ad->userid, 24);
+ WFIFO_STRING(s, 6, ad->userid, 24);
if (isGM(acc) != new_gm_level)
{
// modification of the file
@@ -2047,7 +2047,7 @@ void parse_admin(int fd)
ad->userid, acc,
new_gm_level, ip);
}
- WFIFOL(fd, 2) = acc;
+ WFIFOL(s, 2) = acc;
LOGIN_LOG("'ladmin': Modification of a GM level (account: %s (%d), new GM level: %d, ip: %s)\n",
ad->userid, acc,
new_gm_level, ip);
@@ -2081,21 +2081,21 @@ void parse_admin(int fd)
read_gm_account();
send_GM_accounts();
}
- WFIFOSET(fd, 30);
+ WFIFOSET(s, 30);
}
- RFIFOSKIP(fd, 27);
+ RFIFOSKIP(s, 27);
break;
case 0x7940: // Request to modify e-mail
- if (RFIFOREST(fd) < 66)
+ if (RFIFOREST(s) < 66)
return;
{
- WFIFOW(fd, 0) = 0x7941;
- WFIFOL(fd, 2) = -1;
- AccountName account_name = stringish<AccountName>(RFIFO_STRING<24>(fd, 2).to_print());
- WFIFO_STRING(fd, 6, account_name, 24);
+ WFIFOW(s, 0) = 0x7941;
+ WFIFOL(s, 2) = -1;
+ AccountName account_name = stringish<AccountName>(RFIFO_STRING<24>(s, 2).to_print());
+ WFIFO_STRING(s, 6, account_name, 24);
{
- AccountEmail email = stringish<AccountEmail>(RFIFO_STRING<40>(fd, 26));
+ AccountEmail email = stringish<AccountEmail>(RFIFO_STRING<40>(s, 26));
if (!e_mail_check(email))
{
LOGIN_LOG("'ladmin': Attempt to give an invalid e-mail (account: %s, ip: %s)\n",
@@ -2106,9 +2106,9 @@ void parse_admin(int fd)
AuthData *ad = search_account(account_name);
if (ad)
{
- WFIFO_STRING(fd, 6, ad->userid, 24);
+ WFIFO_STRING(s, 6, ad->userid, 24);
ad->email = email;
- WFIFOL(fd, 2) = ad->account_id;
+ WFIFOL(s, 2) = ad->account_id;
LOGIN_LOG("'ladmin': Modification of an email (account: %s, new e-mail: %s, ip: %s)\n",
ad->userid, email, ip);
}
@@ -2119,90 +2119,90 @@ void parse_admin(int fd)
}
}
}
- WFIFOSET(fd, 30);
+ WFIFOSET(s, 30);
}
- RFIFOSKIP(fd, 66);
+ RFIFOSKIP(s, 66);
break;
case 0x7942: // Request to modify memo field
- if (RFIFOREST(fd) < 28
- || RFIFOREST(fd) < (28 + RFIFOW(fd, 26)))
+ if (RFIFOREST(s) < 28
+ || RFIFOREST(s) < (28 + RFIFOW(s, 26)))
return;
{
- WFIFOW(fd, 0) = 0x7943;
- WFIFOL(fd, 2) = -1;
- AccountName account_name = stringish<AccountName>(RFIFO_STRING<24>(fd, 2).to_print());
+ WFIFOW(s, 0) = 0x7943;
+ WFIFOL(s, 2) = -1;
+ AccountName account_name = stringish<AccountName>(RFIFO_STRING<24>(s, 2).to_print());
AuthData *ad = search_account(account_name);
if (ad)
{
- WFIFO_STRING(fd, 6, ad->userid, 24);
+ WFIFO_STRING(s, 6, ad->userid, 24);
ad->memo = "";
- if (RFIFOW(fd, 26) == 0)
+ if (RFIFOW(s, 26) == 0)
{
ad->memo = "!";
}
else
{
- size_t len = RFIFOW(fd, 26);
+ size_t len = RFIFOW(s, 26);
// may truncate
- ad->memo = RFIFO_STRING(fd, 28, len);
+ ad->memo = RFIFO_STRING(s, 28, len);
}
ad->memo = ad->memo.to_print();
- WFIFOL(fd, 2) = ad->account_id;
+ WFIFOL(s, 2) = ad->account_id;
LOGIN_LOG("'ladmin': Modification of a memo field (account: %s, new memo: %s, ip: %s)\n",
ad->userid, ad->memo, ip);
}
else
{
- WFIFO_STRING(fd, 6, account_name, 24);
+ WFIFO_STRING(s, 6, account_name, 24);
LOGIN_LOG("'ladmin': Attempt to modify the memo field of an unknown account (account: %s, ip: %s)\n",
account_name, ip);
}
- WFIFOSET(fd, 30);
+ WFIFOSET(s, 30);
}
- RFIFOSKIP(fd, 28 + RFIFOW(fd, 26));
+ RFIFOSKIP(s, 28 + RFIFOW(s, 26));
break;
case 0x7944: // Request to found an account id
- if (RFIFOREST(fd) < 26)
+ if (RFIFOREST(s) < 26)
return;
{
- WFIFOW(fd, 0) = 0x7945;
- WFIFOL(fd, 2) = -1;
- AccountName account_name = stringish<AccountName>(RFIFO_STRING<24>(fd, 2).to_print());
+ WFIFOW(s, 0) = 0x7945;
+ WFIFOL(s, 2) = -1;
+ AccountName account_name = stringish<AccountName>(RFIFO_STRING<24>(s, 2).to_print());
const AuthData *ad = search_account(account_name);
if (ad)
{
- WFIFO_STRING(fd, 6, ad->userid, 24);
- WFIFOL(fd, 2) = ad->account_id;
+ WFIFO_STRING(s, 6, ad->userid, 24);
+ WFIFOL(s, 2) = ad->account_id;
LOGIN_LOG("'ladmin': Request (by the name) of an account id (account: %s, id: %d, ip: %s)\n",
ad->userid, ad->account_id,
ip);
}
else
{
- WFIFO_STRING(fd, 6, account_name, 24);
+ WFIFO_STRING(s, 6, account_name, 24);
LOGIN_LOG("'ladmin': ID request (by the name) of an unknown account (account: %s, ip: %s)\n",
account_name, ip);
}
- WFIFOSET(fd, 30);
+ WFIFOSET(s, 30);
}
- RFIFOSKIP(fd, 26);
+ RFIFOSKIP(s, 26);
break;
case 0x7946: // Request to found an account name
- if (RFIFOREST(fd) < 6)
+ if (RFIFOREST(s) < 6)
return;
{
- int account_id = RFIFOL(fd, 2);
- WFIFOW(fd, 0) = 0x7947;
- WFIFOL(fd, 2) = account_id;
- WFIFO_ZERO(fd, 6, 24);
+ int account_id = RFIFOL(s, 2);
+ WFIFOW(s, 0) = 0x7947;
+ WFIFOL(s, 2) = account_id;
+ WFIFO_ZERO(s, 6, 24);
for (const AuthData& ad : auth_data)
{
if (ad.account_id == account_id)
{
- WFIFO_STRING(fd, 6, ad.userid, 24);
+ WFIFO_STRING(s, 6, ad.userid, 24);
LOGIN_LOG("'ladmin': Request (by id) of an account name (account: %s, id: %d, ip: %s)\n",
ad.userid, account_id, ip);
goto x7946_out;
@@ -2210,59 +2210,59 @@ void parse_admin(int fd)
}
LOGIN_LOG("'ladmin': Name request (by id) of an unknown account (id: %d, ip: %s)\n",
account_id, ip);
- WFIFO_STRING(fd, 6, "", 24);
+ WFIFO_STRING(s, 6, "", 24);
x7946_out:
- WFIFOSET(fd, 30);
+ WFIFOSET(s, 30);
}
- RFIFOSKIP(fd, 6);
+ RFIFOSKIP(s, 6);
break;
case 0x7948: // Request to change the validity limit (timestamp) (absolute value)
- if (RFIFOREST(fd) < 30)
+ if (RFIFOREST(s) < 30)
return;
{
- WFIFOW(fd, 0) = 0x7949;
- WFIFOL(fd, 2) = -1;
- AccountName account_name = stringish<AccountName>(RFIFO_STRING<24>(fd, 2).to_print());
- TimeT timestamp = static_cast<time_t>(RFIFOL(fd, 26));
+ WFIFOW(s, 0) = 0x7949;
+ WFIFOL(s, 2) = -1;
+ AccountName account_name = stringish<AccountName>(RFIFO_STRING<24>(s, 2).to_print());
+ TimeT timestamp = static_cast<time_t>(RFIFOL(s, 26));
timestamp_seconds_buffer tmpstr = stringish<timestamp_seconds_buffer>("unlimited");
if (timestamp)
stamp_time(tmpstr, &timestamp);
AuthData *ad = search_account(account_name);
if (ad)
{
- WFIFO_STRING(fd, 6, ad->userid, 24);
+ WFIFO_STRING(s, 6, ad->userid, 24);
LOGIN_LOG("'ladmin': Change of a validity limit (account: %s, new validity: %lld (%s), ip: %s)\n",
ad->userid,
timestamp,
tmpstr,
ip);
ad->connect_until_time = timestamp;
- WFIFOL(fd, 2) = ad->account_id;
+ WFIFOL(s, 2) = ad->account_id;
}
else
{
- WFIFO_STRING(fd, 6, account_name, 24);
+ WFIFO_STRING(s, 6, account_name, 24);
LOGIN_LOG("'ladmin': Attempt to change the validity limit of an unknown account (account: %s, received validity: %lld (%s), ip: %s)\n",
account_name,
timestamp,
tmpstr,
ip);
}
- WFIFOL(fd, 30) = static_cast<time_t>(timestamp);
+ WFIFOL(s, 30) = static_cast<time_t>(timestamp);
}
- WFIFOSET(fd, 34);
- RFIFOSKIP(fd, 30);
+ WFIFOSET(s, 34);
+ RFIFOSKIP(s, 30);
break;
case 0x794a: // Request to change the final date of a banishment (timestamp) (absolute value)
- if (RFIFOREST(fd) < 30)
+ if (RFIFOREST(s) < 30)
return;
{
- WFIFOW(fd, 0) = 0x794b;
- WFIFOL(fd, 2) = -1;
- AccountName account_name = stringish<AccountName>(RFIFO_STRING<24>(fd, 2).to_print());
- TimeT timestamp = static_cast<time_t>(RFIFOL(fd, 26));
+ WFIFOW(s, 0) = 0x794b;
+ WFIFOL(s, 2) = -1;
+ AccountName account_name = stringish<AccountName>(RFIFO_STRING<24>(s, 2).to_print());
+ TimeT timestamp = static_cast<time_t>(RFIFOL(s, 26));
if (timestamp <= TimeT::now())
timestamp = TimeT();
timestamp_seconds_buffer tmpstr = stringish<timestamp_seconds_buffer>("no banishment");
@@ -2271,8 +2271,8 @@ void parse_admin(int fd)
AuthData *ad = search_account(account_name);
if (ad)
{
- WFIFO_STRING(fd, 6, ad->userid, 24);
- WFIFOL(fd, 2) = ad->account_id;
+ WFIFO_STRING(s, 6, ad->userid, 24);
+ WFIFOL(s, 2) = ad->account_id;
LOGIN_LOG("'ladmin': Change of the final date of a banishment (account: %s, new final date of banishment: %lld (%s), ip: %s)\n",
ad->userid, timestamp,
tmpstr,
@@ -2286,7 +2286,7 @@ void parse_admin(int fd)
WBUFL(buf, 2) = ad->account_id;
WBUFB(buf, 6) = 1; // 0: change of statut, 1: ban
WBUFL(buf, 7) = static_cast<time_t>(timestamp); // status or final date of a banishment
- charif_sendallwos(-1, buf, 11);
+ charif_sendallwos(nullptr, buf, 11);
for (int j = 0; j < AUTH_FIFO_SIZE; j++)
if (auth_fifo[j].account_id ==
ad->account_id)
@@ -2297,30 +2297,30 @@ void parse_admin(int fd)
}
else
{
- WFIFO_STRING(fd, 6, account_name, 24);
+ WFIFO_STRING(s, 6, account_name, 24);
LOGIN_LOG("'ladmin': Attempt to change the final date of a banishment of an unknown account (account: %s, received final date of banishment: %lld (%s), ip: %s)\n",
account_name, timestamp,
tmpstr,
ip);
}
- WFIFOL(fd, 30) = static_cast<time_t>(timestamp);
+ WFIFOL(s, 30) = static_cast<time_t>(timestamp);
}
- WFIFOSET(fd, 34);
- RFIFOSKIP(fd, 30);
+ WFIFOSET(s, 34);
+ RFIFOSKIP(s, 30);
break;
case 0x794c: // Request to change the final date of a banishment (timestamp) (relative change)
- if (RFIFOREST(fd) < 38)
+ if (RFIFOREST(s) < 38)
return;
{
- WFIFOW(fd, 0) = 0x794d;
- WFIFOL(fd, 2) = -1;
- AccountName account_name = stringish<AccountName>(RFIFO_STRING<24>(fd, 2).to_print());
+ WFIFOW(s, 0) = 0x794d;
+ WFIFOL(s, 2) = -1;
+ AccountName account_name = stringish<AccountName>(RFIFO_STRING<24>(s, 2).to_print());
AuthData *ad = search_account(account_name);
if (ad)
{
- WFIFOL(fd, 2) = ad->account_id;
- WFIFO_STRING(fd, 6, ad->userid, 24);
+ WFIFOL(s, 2) = ad->account_id;
+ WFIFO_STRING(s, 6, ad->userid, 24);
TimeT timestamp;
TimeT now = TimeT::now();
if (!ad->ban_until_time
@@ -2330,7 +2330,7 @@ void parse_admin(int fd)
timestamp = ad->ban_until_time;
struct tm tmtime = timestamp;
HumanTimeDiff ban_diff;
- RFIFO_STRUCT(fd, 26, ban_diff);
+ RFIFO_STRUCT(s, 26, ban_diff);
tmtime.tm_year += ban_diff.year;
tmtime.tm_mon += ban_diff.month;
tmtime.tm_mday += ban_diff.day;
@@ -2362,7 +2362,7 @@ void parse_admin(int fd)
WBUFL(buf, 2) = ad->account_id;
WBUFB(buf, 6) = 1; // 0: change of statut, 1: ban
WBUFL(buf, 7) = static_cast<time_t>(timestamp); // status or final date of a banishment
- charif_sendallwos(-1, buf, 11);
+ charif_sendallwos(nullptr, buf, 11);
for (int j = 0; j < AUTH_FIFO_SIZE; j++)
if (auth_fifo[j].account_id ==
ad->account_id)
@@ -2385,27 +2385,27 @@ void parse_admin(int fd)
ban_diff.minute, ban_diff.second,
ip);
}
- WFIFOL(fd, 30) = static_cast<time_t>(ad->ban_until_time);
+ WFIFOL(s, 30) = static_cast<time_t>(ad->ban_until_time);
}
else
{
- WFIFO_STRING(fd, 6, account_name, 24);
+ WFIFO_STRING(s, 6, account_name, 24);
LOGIN_LOG("'ladmin': Attempt to adjust the final date of a banishment of an unknown account (account: %s, ip: %s)\n",
account_name, ip);
- WFIFOL(fd, 30) = 0;
+ WFIFOL(s, 30) = 0;
}
}
- WFIFOSET(fd, 34);
- RFIFOSKIP(fd, 38);
+ WFIFOSET(s, 34);
+ RFIFOSKIP(s, 38);
break;
case 0x794e: // Request to send a broadcast message
- if (RFIFOREST(fd) < 8
- || RFIFOREST(fd) < (8 + RFIFOL(fd, 4)))
+ if (RFIFOREST(s) < 8
+ || RFIFOREST(s) < (8 + RFIFOL(s, 4)))
return;
- WFIFOW(fd, 0) = 0x794f;
- WFIFOW(fd, 2) = -1;
- if (RFIFOL(fd, 4) < 1)
+ WFIFOW(s, 0) = 0x794f;
+ WFIFOW(s, 2) = -1;
+ if (RFIFOL(s, 4) < 1)
{
LOGIN_LOG("'ladmin': Receiving a message for broadcast, but message is void (ip: %s)\n",
ip);
@@ -2414,7 +2414,7 @@ void parse_admin(int fd)
{
// at least 1 char-server
for (int i = 0; i < MAX_SERVERS; i++)
- if (server_fd[i] >= 0)
+ if (server_session[i])
goto x794e_have_server;
LOGIN_LOG("'ladmin': Receiving a message for broadcast, but no char-server is online (ip: %s)\n",
ip);
@@ -2422,41 +2422,41 @@ void parse_admin(int fd)
{
x794e_have_server:
// overwrite the -1
- WFIFOW(fd, 2) = 0;
+ WFIFOW(s, 2) = 0;
- size_t len = RFIFOL(fd, 4);
- FString message = RFIFO_STRING(fd, 8, len).to_print();
+ size_t len = RFIFOL(s, 4);
+ FString message = RFIFO_STRING(s, 8, len).to_print();
LOGIN_LOG("'ladmin': Receiving a message for broadcast (message: %s, ip: %s)\n",
message, ip);
// send same message to all char-servers (no answer)
uint8_t buf[len + 8];
- RFIFO_BUF_CLONE(fd, buf, 8 + len);
+ RFIFO_BUF_CLONE(s, buf, 8 + len);
WBUFW(buf, 0) = 0x2726;
- charif_sendallwos(-1, buf, 8 + len);
+ charif_sendallwos(nullptr, buf, 8 + len);
}
}
x794e_have_no_server:
- WFIFOSET(fd, 4);
- RFIFOSKIP(fd, 8 + RFIFOL(fd, 4));
+ WFIFOSET(s, 4);
+ RFIFOSKIP(s, 8 + RFIFOL(s, 4));
break;
case 0x7950: // Request to change the validity limite (timestamp) (relative change)
- if (RFIFOREST(fd) < 38)
+ if (RFIFOREST(s) < 38)
return;
{
- WFIFOW(fd, 0) = 0x7951;
- WFIFOL(fd, 2) = -1;
- AccountName account_name = stringish<AccountName>(RFIFO_STRING<24>(fd, 2).to_print());
+ WFIFOW(s, 0) = 0x7951;
+ WFIFOL(s, 2) = -1;
+ AccountName account_name = stringish<AccountName>(RFIFO_STRING<24>(s, 2).to_print());
AuthData *ad = search_account(account_name);
if (ad)
{
- WFIFOL(fd, 2) = ad->account_id;
- WFIFO_STRING(fd, 6, ad->userid, 24);
+ WFIFOL(s, 2) = ad->account_id;
+ WFIFO_STRING(s, 6, ad->userid, 24);
if (add_to_unlimited_account == 0 && !ad->connect_until_time)
{
LOGIN_LOG("'ladmin': Attempt to adjust the validity limit of an unlimited account (account: %s, ip: %s)\n",
ad->userid, ip);
- WFIFOL(fd, 30) = 0;
+ WFIFOL(s, 30) = 0;
}
else
{
@@ -2466,7 +2466,7 @@ void parse_admin(int fd)
timestamp = now;
struct tm tmtime = timestamp;
HumanTimeDiff v_diff;
- RFIFO_STRUCT(fd, 26, v_diff);
+ RFIFO_STRUCT(s, 26, v_diff);
tmtime.tm_year += v_diff.year;
tmtime.tm_mon += v_diff.month;
tmtime.tm_mday += v_diff.day;
@@ -2496,7 +2496,7 @@ void parse_admin(int fd)
tmpstr2,
ip);
ad->connect_until_time = timestamp;
- WFIFOL(fd, 30) = static_cast<time_t>(timestamp);
+ WFIFOL(s, 30) = static_cast<time_t>(timestamp);
}
else
{
@@ -2514,106 +2514,106 @@ void parse_admin(int fd)
v_diff.minute,
v_diff.second,
ip);
- WFIFOL(fd, 30) = 0;
+ WFIFOL(s, 30) = 0;
}
}
}
else
{
- WFIFO_STRING(fd, 6, account_name, 24);
+ WFIFO_STRING(s, 6, account_name, 24);
LOGIN_LOG("'ladmin': Attempt to adjust the validity limit of an unknown account (account: %s, ip: %s)\n",
account_name, ip);
- WFIFOL(fd, 30) = 0;
+ WFIFOL(s, 30) = 0;
}
}
- WFIFOSET(fd, 34);
- RFIFOSKIP(fd, 38);
+ WFIFOSET(s, 34);
+ RFIFOSKIP(s, 38);
break;
case 0x7952: // Request about informations of an account (by account name)
- if (RFIFOREST(fd) < 26)
+ if (RFIFOREST(s) < 26)
return;
{
- WFIFOW(fd, 0) = 0x7953;
- WFIFOL(fd, 2) = -1;
- AccountName account_name = stringish<AccountName>(RFIFO_STRING<24>(fd, 2).to_print());
+ WFIFOW(s, 0) = 0x7953;
+ WFIFOL(s, 2) = -1;
+ AccountName account_name = stringish<AccountName>(RFIFO_STRING<24>(s, 2).to_print());
const AuthData *ad = search_account(account_name);
if (ad)
{
- WFIFOL(fd, 2) = ad->account_id;
- WFIFOB(fd, 6) = isGM(ad->account_id);
- WFIFO_STRING(fd, 7, ad->userid, 24);
- WFIFOB(fd, 31) = static_cast<uint8_t>(ad->sex);
- WFIFOL(fd, 32) = ad->logincount;
- WFIFOL(fd, 36) = ad->state;
- WFIFO_STRING(fd, 40, ad->error_message, 20);
- WFIFO_STRING(fd, 60, ad->lastlogin, 24);
- WFIFO_STRING(fd, 84, convert_for_printf(ad->last_ip), 16);
- WFIFO_STRING(fd, 100, ad->email, 40);
- WFIFOL(fd, 140) = static_cast<time_t>(ad->connect_until_time);
- WFIFOL(fd, 144) = static_cast<time_t>(ad->ban_until_time);
+ WFIFOL(s, 2) = ad->account_id;
+ WFIFOB(s, 6) = isGM(ad->account_id);
+ WFIFO_STRING(s, 7, ad->userid, 24);
+ WFIFOB(s, 31) = static_cast<uint8_t>(ad->sex);
+ WFIFOL(s, 32) = ad->logincount;
+ WFIFOL(s, 36) = ad->state;
+ WFIFO_STRING(s, 40, ad->error_message, 20);
+ WFIFO_STRING(s, 60, ad->lastlogin, 24);
+ WFIFO_STRING(s, 84, convert_for_printf(ad->last_ip), 16);
+ WFIFO_STRING(s, 100, ad->email, 40);
+ WFIFOL(s, 140) = static_cast<time_t>(ad->connect_until_time);
+ WFIFOL(s, 144) = static_cast<time_t>(ad->ban_until_time);
size_t len = ad->memo.size() + 1;
- WFIFOW(fd, 148) = len;
- WFIFO_STRING(fd, 150, ad->memo, len);
+ WFIFOW(s, 148) = len;
+ WFIFO_STRING(s, 150, ad->memo, len);
LOGIN_LOG("'ladmin': Sending information of an account (request by the name; account: %s, id: %d, ip: %s)\n",
ad->userid, ad->account_id,
ip);
- WFIFOSET(fd, 150 + len);
+ WFIFOSET(s, 150 + len);
}
else
{
- WFIFO_STRING(fd, 7, account_name, 24);
- WFIFOW(fd, 148) = 0;
+ WFIFO_STRING(s, 7, account_name, 24);
+ WFIFOW(s, 148) = 0;
LOGIN_LOG("'ladmin': Attempt to obtain information (by the name) of an unknown account (account: %s, ip: %s)\n",
account_name, ip);
- WFIFOSET(fd, 150);
+ WFIFOSET(s, 150);
}
}
- RFIFOSKIP(fd, 26);
+ RFIFOSKIP(s, 26);
break;
case 0x7954: // Request about information of an account (by account id)
- if (RFIFOREST(fd) < 6)
+ if (RFIFOREST(s) < 6)
return;
{
- int account_id = RFIFOL(fd, 2);
- WFIFOW(fd, 0) = 0x7953;
- WFIFOL(fd, 2) = account_id;
- WFIFO_ZERO(fd, 7, 24);
+ int account_id = RFIFOL(s, 2);
+ WFIFOW(s, 0) = 0x7953;
+ WFIFOL(s, 2) = account_id;
+ WFIFO_ZERO(s, 7, 24);
for (const AuthData& ad : auth_data)
{
if (ad.account_id == account_id)
{
LOGIN_LOG("'ladmin': Sending information of an account (request by the id; account: %s, id: %d, ip: %s)\n",
- ad.userid, RFIFOL(fd, 2), ip);
- WFIFOB(fd, 6) = isGM(ad.account_id);
- WFIFO_STRING(fd, 7, ad.userid, 24);
- WFIFOB(fd, 31) = static_cast<uint8_t>(ad.sex);
- WFIFOL(fd, 32) = ad.logincount;
- WFIFOL(fd, 36) = ad.state;
- WFIFO_STRING(fd, 40, ad.error_message, 20);
- WFIFO_STRING(fd, 60, ad.lastlogin, 24);
- WFIFO_STRING(fd, 84, convert_for_printf(ad.last_ip), 16);
- WFIFO_STRING(fd, 100, ad.email, 40);
- WFIFOL(fd, 140) = static_cast<time_t>(ad.connect_until_time);
- WFIFOL(fd, 144) = static_cast<time_t>(ad.ban_until_time);
+ ad.userid, RFIFOL(s, 2), ip);
+ WFIFOB(s, 6) = isGM(ad.account_id);
+ WFIFO_STRING(s, 7, ad.userid, 24);
+ WFIFOB(s, 31) = static_cast<uint8_t>(ad.sex);
+ WFIFOL(s, 32) = ad.logincount;
+ WFIFOL(s, 36) = ad.state;
+ WFIFO_STRING(s, 40, ad.error_message, 20);
+ WFIFO_STRING(s, 60, ad.lastlogin, 24);
+ WFIFO_STRING(s, 84, convert_for_printf(ad.last_ip), 16);
+ WFIFO_STRING(s, 100, ad.email, 40);
+ WFIFOL(s, 140) = static_cast<time_t>(ad.connect_until_time);
+ WFIFOL(s, 144) = static_cast<time_t>(ad.ban_until_time);
size_t len = ad.memo.size() + 1;
- WFIFOW(fd, 148) = len;
- WFIFO_STRING(fd, 150, ad.memo, len);
- WFIFOSET(fd, 150 + len);
+ WFIFOW(s, 148) = len;
+ WFIFO_STRING(s, 150, ad.memo, len);
+ WFIFOSET(s, 150 + len);
goto x7954_out;
}
}
{
LOGIN_LOG("'ladmin': Attempt to obtain information (by the id) of an unknown account (id: %d, ip: %s)\n",
- RFIFOL(fd, 2), ip);
- WFIFO_STRING(fd, 7, "", 24);
- WFIFOW(fd, 148) = 0;
- WFIFOSET(fd, 150);
+ RFIFOL(s, 2), ip);
+ WFIFO_STRING(s, 7, "", 24);
+ WFIFOW(s, 148) = 0;
+ WFIFOSET(s, 150);
}
}
x7954_out:
- RFIFOSKIP(fd, 6);
+ RFIFOSKIP(s, 6);
break;
case 0x7955: // Request to reload GM file (no answer)
@@ -2622,7 +2622,7 @@ void parse_admin(int fd)
read_gm_account();
// send GM accounts to all char-servers
send_GM_accounts();
- RFIFOSKIP(fd, 2);
+ RFIFOSKIP(s, 2);
break;
default:
@@ -2637,19 +2637,19 @@ void parse_admin(int fd)
timestr);
FPRINTF(logfp,
"parse_admin: connection #%d (ip: %s), packet: 0x%x (with being read: %zu).\n",
- fd, ip, RFIFOW(fd, 0), RFIFOREST(fd));
+ s, ip, RFIFOW(s, 0), RFIFOREST(s));
FPRINTF(logfp, "Detail (in hex):\n");
FPRINTF(logfp,
"---- 00-01-02-03-04-05-06-07 08-09-0A-0B-0C-0D-0E-0F\n");
char tmpstr[16 + 1] {};
int i;
- for (i = 0; i < RFIFOREST(fd); i++)
+ for (i = 0; i < RFIFOREST(s); i++)
{
if ((i & 15) == 0)
FPRINTF(logfp, "%04X ", i);
- FPRINTF(logfp, "%02x ", RFIFOB (fd, i));
- if (RFIFOB(fd, i) > 0x1f)
- tmpstr[i % 16] = RFIFOB(fd, i);
+ FPRINTF(logfp, "%02x ", RFIFOB (s, i));
+ if (RFIFOB(s, i) > 0x1f)
+ tmpstr[i % 16] = RFIFOB(s, i);
else
tmpstr[i % 16] = '.';
if ((i - 7) % 16 == 0) // -8 + 1
@@ -2675,7 +2675,7 @@ void parse_admin(int fd)
}
LOGIN_LOG("'ladmin': End of connection, unknown packet (ip: %s)\n",
ip);
- session[fd]->eof = 1;
+ s->eof = 1;
PRINTF("Remote administration has been disconnected (unknown packet).\n");
return;
}
@@ -2702,68 +2702,68 @@ bool lan_ip_check(IP4Address p)
// Default packet parsing (normal players or administation/char-server connexion requests)
//----------------------------------------------------------------------------------------
static
-void parse_login(int fd)
+void parse_login(Session *s)
{
struct mmo_account account;
int result, j;
- IP4Address ip = session[fd]->client_ip;
+ IP4Address ip = s->client_ip;
- if (session[fd]->eof)
+ if (s->eof)
{
- delete_session(fd);
+ delete_session(s);
return;
}
- while (RFIFOREST(fd) >= 2)
+ while (RFIFOREST(s) >= 2)
{
if (display_parse_login == 1)
{
- if (RFIFOW(fd, 0) == 0x64 || RFIFOW(fd, 0) == 0x01dd)
+ if (RFIFOW(s, 0) == 0x64 || RFIFOW(s, 0) == 0x01dd)
{
- if (RFIFOREST(fd) >= ((RFIFOW(fd, 0) == 0x64) ? 55 : 47))
+ if (RFIFOREST(s) >= ((RFIFOW(s, 0) == 0x64) ? 55 : 47))
{
- AccountName account_name = stringish<AccountName>(RFIFO_STRING<24>(fd, 6));
+ AccountName account_name = stringish<AccountName>(RFIFO_STRING<24>(s, 6));
PRINTF("parse_login: connection #%d, packet: 0x%x (with being read: %zu), account: %s.\n",
- fd, RFIFOW(fd, 0), RFIFOREST(fd),
+ s, RFIFOW(s, 0), RFIFOREST(s),
account_name);
}
}
- else if (RFIFOW(fd, 0) == 0x2710)
+ else if (RFIFOW(s, 0) == 0x2710)
{
- if (RFIFOREST(fd) >= 86)
+ if (RFIFOREST(s) >= 86)
{
- ServerName server_name = stringish<ServerName>(RFIFO_STRING<20>(fd, 60));
+ ServerName server_name = stringish<ServerName>(RFIFO_STRING<20>(s, 60));
PRINTF("parse_login: connection #%d, packet: 0x%x (with being read: %zu), server: %s.\n",
- fd, RFIFOW(fd, 0), RFIFOREST(fd),
+ s, RFIFOW(s, 0), RFIFOREST(s),
server_name);
}
}
else
PRINTF("parse_login: connection #%d, packet: 0x%x (with being read: %zu).\n",
- fd, RFIFOW(fd, 0), RFIFOREST(fd));
+ s, RFIFOW(s, 0), RFIFOREST(s));
}
- switch (RFIFOW(fd, 0))
+ switch (RFIFOW(s, 0))
{
case 0x200: // New alive packet: structure: 0x200 <account.userid>.24B. used to verify if client is always alive.
- if (RFIFOREST(fd) < 26)
+ if (RFIFOREST(s) < 26)
return;
- RFIFOSKIP(fd, 26);
+ RFIFOSKIP(s, 26);
break;
case 0x204: // New alive packet: structure: 0x204 <encrypted.account.userid>.16B. (new ragexe from 22 june 2004)
- if (RFIFOREST(fd) < 18)
+ if (RFIFOREST(s) < 18)
return;
- RFIFOSKIP(fd, 18);
+ RFIFOSKIP(s, 18);
break;
case 0x64: // Ask connection of a client
- if (RFIFOREST(fd) < 55)
+ if (RFIFOREST(s) < 55)
return;
- account.userid = stringish<AccountName>(RFIFO_STRING<24>(fd, 6).to_print());
- account.passwd = stringish<AccountPass>(RFIFO_STRING<24>(fd, 30).to_print());
+ account.userid = stringish<AccountName>(RFIFO_STRING<24>(s, 6).to_print());
+ account.passwd = stringish<AccountPass>(RFIFO_STRING<24>(s, 30).to_print());
account.passwdenc = 0;
LOGIN_LOG("Request for connection (non encryption mode) of %s (ip: %s).\n",
@@ -2773,18 +2773,18 @@ void parse_login(int fd)
{
LOGIN_LOG("Connection refused: IP isn't authorised (deny/allow, ip: %s).\n",
ip);
- WFIFOW(fd, 0) = 0x6a;
- WFIFOB(fd, 2) = 0x03;
- WFIFO_ZERO(fd, 3, 20);
- WFIFOSET(fd, 23);
- RFIFOSKIP(fd, 55);
+ WFIFOW(s, 0) = 0x6a;
+ WFIFOB(s, 2) = 0x03;
+ WFIFO_ZERO(s, 3, 20);
+ WFIFOSET(s, 23);
+ RFIFOSKIP(s, 55);
break;
}
- result = mmo_auth(&account, fd);
+ result = mmo_auth(&account, s);
if (result == -1)
{
- VERSION_2 version_2 = static_cast<VERSION_2>(RFIFOB(fd, 54));
+ VERSION_2 version_2 = static_cast<VERSION_2>(RFIFOB(s, 54));
if (!bool(version_2 & VERSION_2::UPDATEHOST)
|| !bool(version_2 & VERSION_2::SERVERORDER))
result = 5; // client too old
@@ -2797,9 +2797,9 @@ void parse_login(int fd)
LOGIN_LOG("Connection refused: the minimum GM level for connection is %d (account: %s, GM level: %d, ip: %s).\n",
min_level_to_connect, account.userid,
gm_level, ip);
- WFIFOW(fd, 0) = 0x81;
- WFIFOB(fd, 2) = 1; // 01 = Server closed
- WFIFOSET(fd, 3);
+ WFIFOW(s, 0) = 0x81;
+ WFIFOB(s, 2) = 1; // 01 = Server closed
+ WFIFOSET(s, 3);
}
else
{
@@ -2828,10 +2828,10 @@ void parse_login(int fd)
if (update_host)
{
size_t host_len = update_host.size() + 1;
- WFIFOW(fd, 0) = 0x63;
- WFIFOW(fd, 2) = 4 + host_len;
- WFIFO_STRING(fd, 4, update_host, host_len);
- WFIFOSET(fd, 4 + host_len);
+ WFIFOW(s, 0) = 0x63;
+ WFIFOW(s, 2) = 4 + host_len;
+ WFIFO_STRING(s, 4, update_host, host_len);
+ WFIFOSET(s, 4 + host_len);
}
}
@@ -2840,32 +2840,32 @@ void parse_login(int fd)
// if (version_2 & VERSION_2_SERVERORDER)
for (int i = 0; i < MAX_SERVERS; i++)
{
- if (server_fd[i] >= 0)
+ if (server_session[i])
{
if (lan_ip_check(ip))
- WFIFOIP(fd, 47 + server_num * 32) = lan_char_ip;
+ WFIFOIP(s, 47 + server_num * 32) = lan_char_ip;
else
- WFIFOIP(fd, 47 + server_num * 32) = server[i].ip;
- WFIFOW(fd, 47 + server_num * 32 + 4) = server[i].port;
- WFIFO_STRING(fd, 47 + server_num * 32 + 6, server[i].name, 20);
- WFIFOW(fd, 47 + server_num * 32 + 26) = server[i].users;
- WFIFOW(fd, 47 + server_num * 32 + 28) = 0; //maintenance;
- WFIFOW(fd, 47 + server_num * 32 + 30) = 0; //is_new;
+ WFIFOIP(s, 47 + server_num * 32) = server[i].ip;
+ WFIFOW(s, 47 + server_num * 32 + 4) = server[i].port;
+ WFIFO_STRING(s, 47 + server_num * 32 + 6, server[i].name, 20);
+ WFIFOW(s, 47 + server_num * 32 + 26) = server[i].users;
+ WFIFOW(s, 47 + server_num * 32 + 28) = 0; //maintenance;
+ WFIFOW(s, 47 + server_num * 32 + 30) = 0; //is_new;
server_num++;
}
}
// if at least 1 char-server
if (server_num > 0)
{
- WFIFOW(fd, 0) = 0x69;
- WFIFOW(fd, 2) = 47 + 32 * server_num;
- WFIFOL(fd, 4) = account.login_id1;
- WFIFOL(fd, 8) = account.account_id;
- WFIFOL(fd, 12) = account.login_id2;
- WFIFOL(fd, 16) = 0; // in old version, that was for ip (not more used)
- WFIFO_STRING(fd, 20, account.lastlogin, 24); // in old version, that was for name (not more used)
- WFIFOB(fd, 46) = static_cast<uint8_t>(account.sex);
- WFIFOSET(fd, 47 + 32 * server_num);
+ WFIFOW(s, 0) = 0x69;
+ WFIFOW(s, 2) = 47 + 32 * server_num;
+ WFIFOL(s, 4) = account.login_id1;
+ WFIFOL(s, 8) = account.account_id;
+ WFIFOL(s, 12) = account.login_id2;
+ WFIFOL(s, 16) = 0; // in old version, that was for ip (not more used)
+ WFIFO_STRING(s, 20, account.lastlogin, 24); // in old version, that was for name (not more used)
+ WFIFOB(s, 46) = static_cast<uint8_t>(account.sex);
+ WFIFOSET(s, 47 + 32 * server_num);
if (auth_fifo_pos >= AUTH_FIFO_SIZE)
auth_fifo_pos = 0;
auth_fifo[auth_fifo_pos].account_id =
@@ -2877,7 +2877,7 @@ void parse_login(int fd)
auth_fifo[auth_fifo_pos].sex = account.sex;
auth_fifo[auth_fifo_pos].delflag = 0;
auth_fifo[auth_fifo_pos].ip =
- session[fd]->client_ip;
+ s->client_ip;
auth_fifo_pos++;
// if no char-server, don't send void list of servers, just disconnect the player with proper message
}
@@ -2885,17 +2885,17 @@ void parse_login(int fd)
{
LOGIN_LOG("Connection refused: there is no char-server online (account: %s, ip: %s).\n",
account.userid, ip);
- WFIFOW(fd, 0) = 0x81;
- WFIFOB(fd, 2) = 1; // 01 = Server closed
- WFIFOSET(fd, 3);
+ WFIFOW(s, 0) = 0x81;
+ WFIFOB(s, 2) = 1; // 01 = Server closed
+ WFIFOSET(s, 3);
}
}
}
else
{
- WFIFO_ZERO(fd, 0, 23);
- WFIFOW(fd, 0) = 0x6a;
- WFIFOB(fd, 2) = result;
+ WFIFO_ZERO(s, 0, 23);
+ WFIFOW(s, 0) = 0x6a;
+ WFIFOB(s, 2) = result;
if (result == 6)
{
// 6 = Your are Prohibited to log in until %s
@@ -2907,34 +2907,34 @@ void parse_login(int fd)
// if account is banned, we send ban timestamp
timestamp_seconds_buffer tmpstr;
stamp_time(tmpstr, &ad->ban_until_time);
- WFIFO_STRING(fd, 3, tmpstr, 20);
+ WFIFO_STRING(s, 3, tmpstr, 20);
}
else
{ // we send error message
- WFIFO_STRING(fd, 3, ad->error_message, 20);
+ WFIFO_STRING(s, 3, ad->error_message, 20);
}
}
}
- WFIFOSET(fd, 23);
+ WFIFOSET(s, 23);
}
- RFIFOSKIP(fd, (RFIFOW(fd, 0) == 0x64) ? 55 : 47);
+ RFIFOSKIP(s, (RFIFOW(s, 0) == 0x64) ? 55 : 47);
break;
case 0x2710: // Connection request of a char-server
- if (RFIFOREST(fd) < 86)
+ if (RFIFOREST(s) < 86)
return;
{
int len;
- account.userid = stringish<AccountName>(RFIFO_STRING<24>(fd, 2).to_print());
- account.passwd = stringish<AccountPass>(RFIFO_STRING<24>(fd, 26).to_print());
+ account.userid = stringish<AccountName>(RFIFO_STRING<24>(s, 2).to_print());
+ account.passwd = stringish<AccountPass>(RFIFO_STRING<24>(s, 26).to_print());
account.passwdenc = 0;
- ServerName server_name = stringish<ServerName>(RFIFO_STRING<20>(fd, 60).to_print());
+ ServerName server_name = stringish<ServerName>(RFIFO_STRING<20>(s, 60).to_print());
LOGIN_LOG("Connection request of the char-server '%s' @ %s:%d (ip: %s)\n",
- server_name, RFIFOIP(fd, 54), RFIFOW(fd, 58), ip);
+ server_name, RFIFOIP(s, 54), RFIFOW(s, 58), ip);
if (account.userid == userid && account.passwd == passwd)
{
// If this is the main server, and we don't already have a main server
- if (server_fd[0] <= 0
+ if (!server_session[0]
&& server_name == main_server)
{
account.account_id = 0;
@@ -2945,7 +2945,7 @@ void parse_login(int fd)
int i;
for (i = 1; i < MAX_SERVERS; i++)
{
- if (server_fd[i] <= 0)
+ if (!server_session[i])
{
account.account_id = i;
goto x2710_okay;
@@ -2963,33 +2963,33 @@ void parse_login(int fd)
PRINTF("Connection of the char-server '%s' accepted.\n",
server_name);
server[account.account_id] = mmo_char_server{};
- server[account.account_id].ip = RFIFOIP(fd, 54);
- server[account.account_id].port = RFIFOW(fd, 58);
+ server[account.account_id].ip = RFIFOIP(s, 54);
+ server[account.account_id].port = RFIFOW(s, 58);
server[account.account_id].name = server_name;
server[account.account_id].users = 0;
//maintenance = RFIFOW(fd, 82);
//is_new = RFIFOW(fd, 84);
- server_fd[account.account_id] = fd;
+ server_session[account.account_id] = s;
if (anti_freeze_enable)
server_freezeflag[account.account_id] = 5; // Char-server anti-freeze system. Counter. 5 ok, 4...0 freezed
- WFIFOW(fd, 0) = 0x2711;
- WFIFOB(fd, 2) = 0;
- WFIFOSET(fd, 3);
- session[fd]->func_parse = parse_fromchar;
- realloc_fifo(fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
+ WFIFOW(s, 0) = 0x2711;
+ WFIFOB(s, 2) = 0;
+ WFIFOSET(s, 3);
+ s->func_parse = parse_fromchar;
+ realloc_fifo(s, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
// send GM account to char-server
len = 4;
- WFIFOW(fd, 0) = 0x2732;
+ WFIFOW(s, 0) = 0x2732;
for (const AuthData& ad : auth_data)
// send only existing accounts. We can not create a GM account when server is online.
if (uint8_t GM_value = isGM(ad.account_id))
{
- WFIFOL(fd, len) = ad.account_id;
- WFIFOB(fd, len + 4) = GM_value;
+ WFIFOL(s, len) = ad.account_id;
+ WFIFOB(s, len + 4) = GM_value;
len += 5;
}
- WFIFOW(fd, 2) = len;
- WFIFOSET(fd, len);
+ WFIFOW(s, 2) = len;
+ WFIFOSET(s, len);
goto x2710_done;
}
{
@@ -2997,50 +2997,50 @@ void parse_login(int fd)
LOGIN_LOG("Connexion of the char-server '%s' REFUSED (account: %s, pass: %s, ip: %s)\n",
server_name, account.userid,
account.passwd, ip);
- WFIFOW(fd, 0) = 0x2711;
- WFIFOB(fd, 2) = 3;
- WFIFOSET(fd, 3);
+ WFIFOW(s, 0) = 0x2711;
+ WFIFOB(s, 2) = 3;
+ WFIFOSET(s, 3);
}
}
x2710_done:
- RFIFOSKIP(fd, 86);
+ RFIFOSKIP(s, 86);
return;
case 0x7530: // Request of the server version
LOGIN_LOG("Sending of the server version (ip: %s)\n",
ip);
- WFIFOW(fd, 0) = 0x7531;
+ WFIFOW(s, 0) = 0x7531;
{
Version version = CURRENT_LOGIN_SERVER_VERSION;
version.flags = new_account ? 1 : 0;
- WFIFO_STRUCT(fd, 2, version);
- WFIFOSET(fd, 10);
+ WFIFO_STRUCT(s, 2, version);
+ WFIFOSET(s, 10);
}
- RFIFOSKIP(fd, 2);
+ RFIFOSKIP(s, 2);
break;
case 0x7532: // Request to end connection
LOGIN_LOG("End of connection (ip: %s)\n", ip);
- session[fd]->eof = 1;
+ s->eof = 1;
return;
case 0x7918: // Request for administation login
- if (RFIFOREST(fd) < 4
- || RFIFOREST(fd) < ((RFIFOW(fd, 2) == 0) ? 28 : 20))
+ if (RFIFOREST(s) < 4
+ || RFIFOREST(s) < ((RFIFOW(s, 2) == 0) ? 28 : 20))
return;
- WFIFOW(fd, 0) = 0x7919;
- WFIFOB(fd, 2) = 1;
- if (!check_ladminip(session[fd]->client_ip))
+ WFIFOW(s, 0) = 0x7919;
+ WFIFOB(s, 2) = 1;
+ if (!check_ladminip(s->client_ip))
{
LOGIN_LOG("'ladmin'-login: Connection in administration mode refused: IP isn't authorised (ladmin_allow, ip: %s).\n",
ip);
}
else
{
- if (RFIFOW(fd, 2) == 0)
+ if (RFIFOW(s, 2) == 0)
{
// non encrypted password
- AccountPass password = stringish<AccountPass>(RFIFO_STRING<24>(fd, 4).to_print());
+ AccountPass password = stringish<AccountPass>(RFIFO_STRING<24>(s, 4).to_print());
// If remote administration is enabled and password sent by client matches password read from login server configuration file
if ((admin_state == 1)
&& (password == admin_pass))
@@ -3048,8 +3048,8 @@ void parse_login(int fd)
LOGIN_LOG("'ladmin'-login: Connection in administration mode accepted (non encrypted password: %s, ip: %s)\n",
password, ip);
PRINTF("Connection of a remote administration accepted (non encrypted password).\n");
- WFIFOB(fd, 2) = 0;
- session[fd]->func_parse = parse_admin;
+ WFIFOB(s, 2) = 0;
+ s->func_parse = parse_admin;
}
else if (admin_state != 1)
LOGIN_LOG("'ladmin'-login: Connection in administration mode REFUSED - remote administration is disabled (non encrypted password: %s, ip: %s)\n",
@@ -3067,8 +3067,8 @@ void parse_login(int fd)
}
}
}
- WFIFOSET(fd, 3);
- RFIFOSKIP(fd, (RFIFOW(fd, 2) == 0) ? 28 : 20);
+ WFIFOSET(s, 3);
+ RFIFOSKIP(s, (RFIFOW(s, 2) == 0) ? 28 : 20);
break;
default:
@@ -3084,8 +3084,8 @@ void parse_login(int fd)
timestr);
FPRINTF(logfp,
"parse_login: connection #%d (ip: %s), packet: 0x%x (with being read: %zu).\n",
- fd, ip, RFIFOW(fd, 0),
- RFIFOREST(fd));
+ s, ip, RFIFOW(s, 0),
+ RFIFOREST(s));
FPRINTF(logfp, "Detail (in hex):\n");
FPRINTF(logfp,
"---- 00-01-02-03-04-05-06-07 08-09-0A-0B-0C-0D-0E-0F\n");
@@ -3093,13 +3093,13 @@ void parse_login(int fd)
char tmpstr[16 + 1] {};
int i;
- for (i = 0; i < RFIFOREST(fd); i++)
+ for (i = 0; i < RFIFOREST(s); i++)
{
if ((i & 15) == 0)
FPRINTF(logfp, "%04X ", i);
- FPRINTF(logfp, "%02x ", RFIFOB(fd, i));
- if (RFIFOB(fd, i) > 0x1f)
- tmpstr[i % 16] = RFIFOB(fd, i);
+ FPRINTF(logfp, "%02x ", RFIFOB(s, i));
+ if (RFIFOB(s, i) > 0x1f)
+ tmpstr[i % 16] = RFIFOB(s, i);
else
tmpstr[i % 16] = '.';
if ((i - 7) % 16 == 0) // -8 + 1
@@ -3124,7 +3124,7 @@ void parse_login(int fd)
}
}
LOGIN_LOG("End of connection, unknown packet (ip: %s)\n", ip);
- session[fd]->eof = 1;
+ s->eof = 1;
return;
}
}
@@ -3790,18 +3790,17 @@ void save_config_in_log(void)
//--------------------------------------
void term_func(void)
{
- int i, fd;
-
mmo_auth_sync();
auth_data.clear();
gm_account_db.clear();
- for (i = 0; i < MAX_SERVERS; i++)
+ for (int i = 0; i < MAX_SERVERS; i++)
{
- if ((fd = server_fd[i]) >= 0)
- delete_session(fd);
+ Session *s = server_session[i];
+ if (s)
+ delete_session(s);
}
- delete_session(login_fd);
+ delete_session(login_session);
LOGIN_LOG("----End of login-server (normal end with closing of all files).\n");
}
@@ -3865,13 +3864,13 @@ int do_init(int argc, ZString *argv)
for (int i = 0; i < AUTH_FIFO_SIZE; i++)
auth_fifo[i].delflag = 1;
for (int i = 0; i < MAX_SERVERS; i++)
- server_fd[i] = -1;
+ server_session[i] = nullptr;
read_gm_account();
mmo_auth_init();
// set_termfunc (mmo_auth_sync);
set_defaultparse(parse_login);
- login_fd = make_listen_port(login_port);
+ login_session = make_listen_port(login_port);
Timer(gettick() + std::chrono::minutes(5),
diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp
index 9687968..931a4d0 100644
--- a/src/map/atcommand.cpp
+++ b/src/map/atcommand.cpp
@@ -58,10 +58,10 @@ struct AtCommandInfo
{
ZString args;
int level;
- ATCE (*proc)(const int fd, dumb_ptr<map_session_data> sd, ZString message);
+ ATCE (*proc)(Session *s, dumb_ptr<map_session_data> sd, ZString message);
ZString help;
- AtCommandInfo(ZString a, int l, ATCE (*p)(const int, dumb_ptr<map_session_data>, ZString), ZString h)
+ AtCommandInfo(ZString a, int l, ATCE (*p)(Session *s, dumb_ptr<map_session_data>, ZString), ZString h)
: args(a), level(l), proc(p), help(h)
{}
};
@@ -78,16 +78,16 @@ AtCommandInfo *atcommand(XString cmd);
// These @commands are used within other @commands.
static
-ATCE atcommand_character_baselevel(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_character_baselevel(Session *s, dumb_ptr<map_session_data> sd,
ZString message);
static
-ATCE atcommand_skill_learn(const int fd, dumb_ptr<map_session_data>,
+ATCE atcommand_skill_learn(Session *s, dumb_ptr<map_session_data>,
ZString message);
static
-ATCE atcommand_charwarp(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_charwarp(Session *s, dumb_ptr<map_session_data> sd,
ZString message);
static
-ATCE atcommand_charstreset(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_charstreset(Session *s, dumb_ptr<map_session_data> sd,
ZString message);
@@ -217,7 +217,7 @@ io::AppendFile *get_gm_log()
return gm_logfile.get();
}
-bool is_atcommand(const int fd, dumb_ptr<map_session_data> sd,
+bool is_atcommand(Session *s, dumb_ptr<map_session_data> sd,
ZString message, int gmlvl)
{
nullpo_retr(false, sd);
@@ -237,14 +237,14 @@ bool is_atcommand(const int fd, dumb_ptr<map_session_data> sd,
{
FString output = STRPRINTF("GM command is level 0, but this server disables level 0 commands: %s",
FString(command));
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
return true;
}
if (!info)
{
FString output = STRPRINTF("GM command not found: %s",
FString(command));
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
return true;
// don't show in chat
}
@@ -253,13 +253,13 @@ bool is_atcommand(const int fd, dumb_ptr<map_session_data> sd,
FString output = STRPRINTF("GM command is level %d, but you are level %d: %s",
info->level, gmlvl,
FString(command));
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
return true;
}
{
{
- ATCE err = info->proc(fd, sd, arg);
+ ATCE err = info->proc(s, sd, arg);
switch (err)
{
case ATCE::OKAY:
@@ -268,17 +268,17 @@ bool is_atcommand(const int fd, dumb_ptr<map_session_data> sd,
log_atcommand(sd, message);
break;
case ATCE::USAGE:
- clif_displaymessage(fd, "Command failed: usage error");
- clif_displaymessage(fd, STRPRINTF("Usage: %s %s", FString(command), info->args));
+ clif_displaymessage(s, "Command failed: usage error");
+ clif_displaymessage(s, STRPRINTF("Usage: %s %s", FString(command), info->args));
break;
case ATCE::EXIST:
- clif_displaymessage(fd, "Command failed: something does not exist (or already exists)");
+ clif_displaymessage(s, "Command failed: something does not exist (or already exists)");
break;
case ATCE::RANGE:
- clif_displaymessage(fd, "Command failed: value out of range");
+ clif_displaymessage(s, "Command failed: value out of range");
break;
case ATCE::PERM:
- clif_displaymessage(fd, "Command failed: permission denied");
+ clif_displaymessage(s, "Command failed: permission denied");
break;
default:
abort();
@@ -365,7 +365,7 @@ bool atcommand_config_read(ZString cfgName)
/// @ command processing functions
static
-void atc_do_help(const int fd, const char *cmd, const AtCommandInfo& info)
+void atc_do_help(Session *s, const char *cmd, const AtCommandInfo& info)
{
auto msg = STRPRINTF("\u2007\u2007%d: @%s %s", info.level, cmd, info.args);
// manually padding because *space*
@@ -374,18 +374,18 @@ void atc_do_help(const int fd, const char *cmd, const AtCommandInfo& info)
++ll;
if (info.level >= 100)
++ll;
- clif_displaymessage(fd, msg.xslice_t((ll - 1) * 3));
+ clif_displaymessage(s, msg.xslice_t((ll - 1) * 3));
}
static
-ATCE atcommand_help(const int fd, dumb_ptr<map_session_data>,
+ATCE atcommand_help(Session *s, dumb_ptr<map_session_data>,
ZString message)
{
if (!message)
{
- clif_displaymessage(fd, "There is too much help to display it all at once");
- clif_displaymessage(fd, "Try @help <@command> or @help <category> or @help <level[-level]>");
- clif_displaymessage(fd, "Right now the only category is 'all'");
+ clif_displaymessage(s, "There is too much help to display it all at once");
+ clif_displaymessage(s, "Try @help <@command> or @help <category> or @help <level[-level]>");
+ clif_displaymessage(s, "Right now the only category is 'all'");
return ATCE::OKAY;
}
@@ -395,19 +395,19 @@ ATCE atcommand_help(const int fd, dumb_ptr<map_session_data>,
const AtCommandInfo *info = atcommand_info.search(cmd);
if (!info)
return ATCE::EXIST;
- clif_displaymessage(fd, STRPRINTF("Usage: @%s %s", cmd, info->args));
- clif_displaymessage(fd, info->help);
+ clif_displaymessage(s, STRPRINTF("Usage: @%s %s", cmd, info->args));
+ clif_displaymessage(s, info->help);
return ATCE::OKAY;
}
if (message == "all")
{
- clif_displaymessage(fd, "Synopses of GM commands in category 'all':");
+ clif_displaymessage(s, "Synopses of GM commands in category 'all':");
for (const auto& pair : atcommand_info)
{
const char *cmd = &*pair.first.begin();
const AtCommandInfo& info = pair.second;
- atc_do_help(fd, cmd, info);
+ atc_do_help(s, cmd, info);
}
return ATCE::OKAY;
}
@@ -420,19 +420,19 @@ ATCE atcommand_help(const int fd, dumb_ptr<map_session_data>,
if (low < 0 || high > 100 || low >= high)
return ATCE::RANGE;
- clif_displaymessage(fd, STRPRINTF("Synopses of GM commands in level [%d, %d):", low, high));
+ clif_displaymessage(s, STRPRINTF("Synopses of GM commands in level [%d, %d):", low, high));
for (const auto& pair : atcommand_info)
{
const char *cmd = &*pair.first.begin();
const AtCommandInfo& info = pair.second;
if (low <= info.level && info.level < high)
- atc_do_help(fd, cmd, info);
+ atc_do_help(s, cmd, info);
}
return ATCE::OKAY;
}
static
-ATCE atcommand_setup(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_setup(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
int level = 1;
@@ -444,31 +444,31 @@ ATCE atcommand_setup(const int fd, dumb_ptr<map_session_data> sd,
FString buf;
buf = STRPRINTF("-255 %s", character);
- atcommand_character_baselevel(fd, sd, buf);
+ atcommand_character_baselevel(s, sd, buf);
buf = STRPRINTF("%d %s", level, character);
- atcommand_character_baselevel(fd, sd, buf);
+ atcommand_character_baselevel(s, sd, buf);
// Emote skill
buf = STRPRINTF("1 1 %s", character);
- atcommand_skill_learn(fd, sd, buf);
+ atcommand_skill_learn(s, sd, buf);
// Trade skill
buf = STRPRINTF("2 1 %s", character);
- atcommand_skill_learn(fd, sd, buf);
+ atcommand_skill_learn(s, sd, buf);
// Party skill
STRPRINTF("2 2 %s", character);
- atcommand_skill_learn(fd, sd, buf);
+ atcommand_skill_learn(s, sd, buf);
STRPRINTF("018-1.gat 24 98 %s", character);
- atcommand_charwarp(fd, sd, buf);
+ atcommand_charwarp(s, sd, buf);
return ATCE::OKAY;
}
//static
-ATCE atcommand_charwarp(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_charwarp(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
MapName map_name;
@@ -495,43 +495,43 @@ ATCE atcommand_charwarp(const int fd, dumb_ptr<map_session_data> sd,
if (m != nullptr && m->flag.nowarpto
&& battle_config.any_warp_GM_min_level > pc_isGM(sd))
{
- clif_displaymessage(fd,
+ clif_displaymessage(s,
"You are not authorised to warp someone to this map.");
return ATCE::PERM;
}
if (pl_sd->bl_m && pl_sd->bl_m->flag.nowarp
&& battle_config.any_warp_GM_min_level > pc_isGM(sd))
{
- clif_displaymessage(fd,
+ clif_displaymessage(s,
"You are not authorised to warp this player from its actual map.");
return ATCE::PERM;
}
if (pc_setpos(pl_sd, map_name, x, y, BeingRemoveWhy::WARPED) == 0)
{
- clif_displaymessage(pl_sd->fd, "Warped.");
- clif_displaymessage(fd, "Player warped (message sends to player too).");
+ clif_displaymessage(pl_sd->sess, "Warped.");
+ clif_displaymessage(s, "Player warped (message sends to player too).");
}
else
{
- clif_displaymessage(fd, "Map not found.");
+ clif_displaymessage(s, "Map not found.");
return ATCE::EXIST;
}
}
else
{
- clif_displaymessage(fd, "Coordinates out of range.");
+ clif_displaymessage(s, "Coordinates out of range.");
return ATCE::RANGE;
}
}
else
{
- clif_displaymessage(fd, "Your GM level don't authorise you to do this action on this player.");
+ clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player.");
return ATCE::PERM;
}
}
else
{
- clif_displaymessage(fd, "Character not found.");
+ clif_displaymessage(s, "Character not found.");
return ATCE::EXIST;
}
@@ -539,7 +539,7 @@ ATCE atcommand_charwarp(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_warp(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_warp(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
MapName map_name;
@@ -548,7 +548,7 @@ ATCE atcommand_warp(const int fd, dumb_ptr<map_session_data> sd,
if (!message
|| !extract(message, record<' ', 1>(&map_name, &x, &y)))
{
- clif_displaymessage(fd,
+ clif_displaymessage(s,
"Please, enter a map (usage: @warp <mapname> <x> <y>).");
return ATCE::USAGE;
}
@@ -564,28 +564,28 @@ ATCE atcommand_warp(const int fd, dumb_ptr<map_session_data> sd,
if (m != nullptr && m->flag.nowarpto
&& battle_config.any_warp_GM_min_level > pc_isGM(sd))
{
- clif_displaymessage(fd,
+ clif_displaymessage(s,
"You are not authorised to warp you to this map.");
return ATCE::PERM;
}
if (sd->bl_m && sd->bl_m->flag.nowarp
&& battle_config.any_warp_GM_min_level > pc_isGM(sd))
{
- clif_displaymessage(fd,
+ clif_displaymessage(s,
"You are not authorised to warp you from your actual map.");
return ATCE::PERM;
}
if (pc_setpos(sd, map_name, x, y, BeingRemoveWhy::WARPED) == 0)
- clif_displaymessage(fd, "Warped.");
+ clif_displaymessage(s, "Warped.");
else
{
- clif_displaymessage(fd, "Map not found.");
+ clif_displaymessage(s, "Map not found.");
return ATCE::EXIST;
}
}
else
{
- clif_displaymessage(fd, "Coordinates out of range.");
+ clif_displaymessage(s, "Coordinates out of range.");
return ATCE::RANGE;
}
@@ -593,7 +593,7 @@ ATCE atcommand_warp(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_where(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_where(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
CharName character;
@@ -609,11 +609,11 @@ ATCE atcommand_where(const int fd, dumb_ptr<map_session_data> sd,
FString output = STRPRINTF("%s: %s (%d,%d)",
pl_sd->status.name,
pl_sd->mapname_, pl_sd->bl_x, pl_sd->bl_y);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
}
else
{
- clif_displaymessage(fd, "Character not found.");
+ clif_displaymessage(s, "Character not found.");
return ATCE::EXIST;
}
@@ -621,14 +621,14 @@ ATCE atcommand_where(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_goto(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_goto(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
CharName character;
if (!asplit(message, &character))
{
- clif_displaymessage(fd,
+ clif_displaymessage(s,
"Please, enter a player name (usage: @jumpto/@warpto/@goto <char name>).");
return ATCE::USAGE;
}
@@ -639,24 +639,24 @@ ATCE atcommand_goto(const int fd, dumb_ptr<map_session_data> sd,
if (pl_sd->bl_m && pl_sd->bl_m->flag.nowarpto
&& battle_config.any_warp_GM_min_level > pc_isGM(sd))
{
- clif_displaymessage(fd,
+ clif_displaymessage(s,
"You are not authorised to warp you to the map of this player.");
return ATCE::PERM;
}
if (sd->bl_m && sd->bl_m->flag.nowarp
&& battle_config.any_warp_GM_min_level > pc_isGM(sd))
{
- clif_displaymessage(fd,
+ clif_displaymessage(s,
"You are not authorised to warp you from your actual map.");
return ATCE::PERM;
}
pc_setpos(sd, pl_sd->mapname_, pl_sd->bl_x, pl_sd->bl_y, BeingRemoveWhy::WARPED);
FString output = STRPRINTF("Jump to %s", character);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
}
else
{
- clif_displaymessage(fd, "Character not found.");
+ clif_displaymessage(s, "Character not found.");
return ATCE::EXIST;
}
@@ -664,7 +664,7 @@ ATCE atcommand_goto(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_jump(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_jump(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
int x = 0, y = 0;
@@ -680,24 +680,24 @@ ATCE atcommand_jump(const int fd, dumb_ptr<map_session_data> sd,
if (sd->bl_m && sd->bl_m->flag.nowarpto
&& battle_config.any_warp_GM_min_level > pc_isGM(sd))
{
- clif_displaymessage(fd,
+ clif_displaymessage(s,
"You are not authorised to warp you to your actual map.");
return ATCE::PERM;
}
if (sd->bl_m && sd->bl_m->flag.nowarp
&& battle_config.any_warp_GM_min_level > pc_isGM(sd))
{
- clif_displaymessage(fd,
+ clif_displaymessage(s,
"You are not authorised to warp you from your actual map.");
return ATCE::PERM;
}
pc_setpos(sd, sd->mapname_, x, y, BeingRemoveWhy::WARPED);
FString output = STRPRINTF("Jump to %d %d", x, y);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
}
else
{
- clif_displaymessage(fd, "Coordinates out of range.");
+ clif_displaymessage(s, "Coordinates out of range.");
return ATCE::RANGE;
}
@@ -705,7 +705,7 @@ ATCE atcommand_jump(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_who(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_who(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
int count;
@@ -717,9 +717,10 @@ ATCE atcommand_who(const int fd, dumb_ptr<map_session_data> sd,
GM_level = pc_isGM(sd);
for (int i = 0; i < fd_max; i++)
{
- if (!session[i])
+ Session *s2 = session[i].get();
+ if (!s2)
continue;
- dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[i]->session_data.get()));
+ dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
if (pl_sd && pl_sd->state.auth)
{
pl_GM_level = pc_isGM(pl_sd);
@@ -744,7 +745,7 @@ ATCE atcommand_who(const int fd, dumb_ptr<map_session_data> sd,
"Name: %s | Location: %s %d %d",
pl_sd->status.name, pl_sd->mapname_,
pl_sd->bl_x, pl_sd->bl_y);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
count++;
}
}
@@ -752,20 +753,20 @@ ATCE atcommand_who(const int fd, dumb_ptr<map_session_data> sd,
}
if (count == 0)
- clif_displaymessage(fd, "No player found.");
+ clif_displaymessage(s, "No player found.");
else if (count == 1)
- clif_displaymessage(fd, "1 player found.");
+ clif_displaymessage(s, "1 player found.");
else
{
FString output = STRPRINTF("%d players found.", count);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
}
return ATCE::OKAY;
}
static
-ATCE atcommand_whogroup(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_whogroup(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
int count;
@@ -779,9 +780,10 @@ ATCE atcommand_whogroup(const int fd, dumb_ptr<map_session_data> sd,
GM_level = pc_isGM(sd);
for (int i = 0; i < fd_max; i++)
{
- if (!session[i])
+ Session *s2 = session[i].get();
+ if (!s2)
continue;
- dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[i]->session_data.get()));
+ dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
if (pl_sd && pl_sd->state.auth)
{
pl_GM_level = pc_isGM(pl_sd);
@@ -802,7 +804,7 @@ ATCE atcommand_whogroup(const int fd, dumb_ptr<map_session_data> sd,
output = STRPRINTF(
"Name: %s (GM:%d) | Party: '%s'",
pl_sd->status.name, pl_GM_level, temp0);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
count++;
}
}
@@ -810,20 +812,20 @@ ATCE atcommand_whogroup(const int fd, dumb_ptr<map_session_data> sd,
}
if (count == 0)
- clif_displaymessage(fd, "No player found.");
+ clif_displaymessage(s, "No player found.");
else if (count == 1)
- clif_displaymessage(fd, "1 player found.");
+ clif_displaymessage(s, "1 player found.");
else
{
FString output = STRPRINTF("%d players found.", count);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
}
return ATCE::OKAY;
}
static
-ATCE atcommand_whomap(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_whomap(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
int count;
@@ -842,9 +844,10 @@ ATCE atcommand_whomap(const int fd, dumb_ptr<map_session_data> sd,
GM_level = pc_isGM(sd);
for (int i = 0; i < fd_max; i++)
{
- if (!session[i])
+ Session *s2 = session[i].get();
+ if (!s2)
continue;
- dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[i]->session_data.get()));
+ dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
if (pl_sd && pl_sd->state.auth)
{
pl_GM_level = pc_isGM(pl_sd);
@@ -867,7 +870,7 @@ ATCE atcommand_whomap(const int fd, dumb_ptr<map_session_data> sd,
"Name: %s | Location: %s %d %d",
pl_sd->status.name, pl_sd->mapname_,
pl_sd->bl_x, pl_sd->bl_y);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
count++;
}
}
@@ -876,13 +879,13 @@ ATCE atcommand_whomap(const int fd, dumb_ptr<map_session_data> sd,
FString output = STRPRINTF("%d players found in map '%s'.",
count, map_id->name_);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
return ATCE::OKAY;
}
static
-ATCE atcommand_whomapgroup(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_whomapgroup(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
int count;
@@ -902,9 +905,10 @@ ATCE atcommand_whomapgroup(const int fd, dumb_ptr<map_session_data> sd,
GM_level = pc_isGM(sd);
for (int i = 0; i < fd_max; i++)
{
- if (!session[i])
+ Session *s2 = session[i].get();
+ if (!s2)
continue;
- dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[i]->session_data.get()));
+ dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
if (pl_sd && pl_sd->state.auth)
{
pl_GM_level = pc_isGM(pl_sd);
@@ -925,7 +929,7 @@ ATCE atcommand_whomapgroup(const int fd, dumb_ptr<map_session_data> sd,
else
output = STRPRINTF("Name: %s | Party: '%s'",
pl_sd->status.name, temp0);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
count++;
}
}
@@ -941,13 +945,13 @@ ATCE atcommand_whomapgroup(const int fd, dumb_ptr<map_session_data> sd,
{
output = STRPRINTF("%d players found in map '%s'.", count, map_id->name_);
}
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
return ATCE::OKAY;
}
static
-ATCE atcommand_whogm(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_whogm(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
int count;
@@ -961,9 +965,10 @@ ATCE atcommand_whogm(const int fd, dumb_ptr<map_session_data> sd,
GM_level = pc_isGM(sd);
for (int i = 0; i < fd_max; i++)
{
- if (!session[i])
+ Session *s2 = session[i].get();
+ if (!s2)
continue;
- dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[i]->session_data.get()));
+ dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
if (pl_sd && pl_sd->state.auth)
{
pl_GM_level = pc_isGM(pl_sd);
@@ -984,19 +989,19 @@ ATCE atcommand_whogm(const int fd, dumb_ptr<map_session_data> sd,
"Name: %s (GM:%d) | Location: %s %d %d",
pl_sd->status.name, pl_GM_level,
pl_sd->mapname_, pl_sd->bl_x, pl_sd->bl_y);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
output = STRPRINTF(
" BLvl: %d | Job: %s (Lvl: %d)",
pl_sd->status.base_level,
"Novice/Human",
pl_sd->status.job_level);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
p = party_search(pl_sd->status.party_id);
PartyName temp0 = p ? p->name : stringish<PartyName>("None");
output = STRPRINTF(
" Party: '%s'",
temp0);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
count++;
}
}
@@ -1005,59 +1010,59 @@ ATCE atcommand_whogm(const int fd, dumb_ptr<map_session_data> sd,
}
if (count == 0)
- clif_displaymessage(fd, "No GM found.");
+ clif_displaymessage(s, "No GM found.");
else if (count == 1)
- clif_displaymessage(fd, "1 GM found.");
+ clif_displaymessage(s, "1 GM found.");
else
{
FString output = STRPRINTF("%d GMs found.", count);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
}
return ATCE::OKAY;
}
static
-ATCE atcommand_save(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_save(Session *s, dumb_ptr<map_session_data> sd,
ZString)
{
pc_setsavepoint(sd, sd->mapname_, sd->bl_x, sd->bl_y);
pc_makesavestatus(sd);
chrif_save(sd);
- clif_displaymessage(fd, "Character data respawn point saved.");
+ clif_displaymessage(s, "Character data respawn point saved.");
return ATCE::OKAY;
}
static
-ATCE atcommand_load(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_load(Session *s, dumb_ptr<map_session_data> sd,
ZString)
{
map_local *m = map_mapname2mapid(sd->status.save_point.map_);
if (m != nullptr && m->flag.nowarpto
&& battle_config.any_warp_GM_min_level > pc_isGM(sd))
{
- clif_displaymessage(fd,
+ clif_displaymessage(s,
"You are not authorised to warp you to your save map.");
return ATCE::PERM;
}
if (sd->bl_m && sd->bl_m->flag.nowarp
&& battle_config.any_warp_GM_min_level > pc_isGM(sd))
{
- clif_displaymessage(fd,
+ clif_displaymessage(s,
"You are not authorised to warp you from your actual map.");
return ATCE::PERM;
}
pc_setpos(sd, sd->status.save_point.map_, sd->status.save_point.x,
sd->status.save_point.y, BeingRemoveWhy::GONE);
- clif_displaymessage(fd, "Warping to respawn point.");
+ clif_displaymessage(s, "Warping to respawn point.");
return ATCE::OKAY;
}
static
-ATCE atcommand_speed(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_speed(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
if (!message)
@@ -1066,7 +1071,7 @@ ATCE atcommand_speed(const int fd, dumb_ptr<map_session_data> sd,
"Please, enter a speed value (usage: @speed <%d-%d>).",
static_cast<uint32_t>(MIN_WALK_SPEED.count()),
static_cast<uint32_t>(MAX_WALK_SPEED.count()));
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
return ATCE::USAGE;
}
@@ -1077,7 +1082,7 @@ ATCE atcommand_speed(const int fd, dumb_ptr<map_session_data> sd,
//sd->walktimer = x;
//この文を追加 by れ
clif_updatestatus(sd, SP::SPEED);
- clif_displaymessage(fd, "Speed changed.");
+ clif_displaymessage(s, "Speed changed.");
}
else
{
@@ -1085,7 +1090,7 @@ ATCE atcommand_speed(const int fd, dumb_ptr<map_session_data> sd,
"Please, enter a valid speed value (usage: @speed <%d-%d>).",
static_cast<uint32_t>(MIN_WALK_SPEED.count()),
static_cast<uint32_t>(MAX_WALK_SPEED.count()));
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
return ATCE::RANGE;
}
@@ -1093,21 +1098,21 @@ ATCE atcommand_speed(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_storage(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_storage(Session *s, dumb_ptr<map_session_data> sd,
ZString)
{
struct storage *stor;
if (sd->state.storage_open)
{
- clif_displaymessage(fd, "msg_table[250]");
+ clif_displaymessage(s, "msg_table[250]");
return ATCE::EXIST;
}
if ((stor = account2storage2(sd->status.account_id)) != NULL
&& stor->storage_status == 1)
{
- clif_displaymessage(fd, "msg_table[250]");
+ clif_displaymessage(s, "msg_table[250]");
return ATCE::EXIST;
}
@@ -1117,7 +1122,7 @@ ATCE atcommand_storage(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_option(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_option(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
Opt1 param1 = Opt1::ZERO;
@@ -1133,24 +1138,24 @@ ATCE atcommand_option(const int fd, dumb_ptr<map_session_data> sd,
clif_changeoption(sd);
pc_calcstatus(sd, 0);
- clif_displaymessage(fd, "Options changed.");
+ clif_displaymessage(s, "Options changed.");
return ATCE::OKAY;
}
static
-ATCE atcommand_hide(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_hide(Session *s, dumb_ptr<map_session_data> sd,
ZString)
{
if (bool(sd->status.option & Option::HIDE))
{
sd->status.option &= ~Option::HIDE;
- clif_displaymessage(fd, "Invisible: Off.");
+ clif_displaymessage(s, "Invisible: Off.");
}
else
{
sd->status.option |= Option::HIDE;
- clif_displaymessage(fd, "Invisible: On.");
+ clif_displaymessage(s, "Invisible: On.");
}
clif_changeoption(sd);
@@ -1158,17 +1163,17 @@ ATCE atcommand_hide(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_die(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_die(Session *s, dumb_ptr<map_session_data> sd,
ZString)
{
pc_damage(NULL, sd, sd->status.hp + 1);
- clif_displaymessage(fd, "A pity! You've died.");
+ clif_displaymessage(s, "A pity! You've died.");
return ATCE::OKAY;
}
static
-ATCE atcommand_kill(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_kill(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
CharName character;
@@ -1183,17 +1188,17 @@ ATCE atcommand_kill(const int fd, dumb_ptr<map_session_data> sd,
{
// you can kill only lower or same level
pc_damage(NULL, pl_sd, pl_sd->status.hp + 1);
- clif_displaymessage(fd, "Character killed.");
+ clif_displaymessage(s, "Character killed.");
}
else
{
- clif_displaymessage(fd, "Your GM level don't authorise you to do this action on this player.");
+ clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player.");
return ATCE::PERM;
}
}
else
{
- clif_displaymessage(fd, "Character not found.");
+ clif_displaymessage(s, "Character not found.");
return ATCE::EXIST;
}
@@ -1201,7 +1206,7 @@ ATCE atcommand_kill(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_alive(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_alive(Session *s, dumb_ptr<map_session_data> sd,
ZString)
{
sd->status.hp = sd->status.max_hp;
@@ -1212,13 +1217,13 @@ ATCE atcommand_alive(const int fd, dumb_ptr<map_session_data> sd,
clif_updatestatus(sd, SP::HP);
clif_updatestatus(sd, SP::SP);
clif_resurrection(sd, 1);
- clif_displaymessage(fd, "You've been revived! It's a miracle!");
+ clif_displaymessage(s, "You've been revived! It's a miracle!");
return ATCE::OKAY;
}
static
-ATCE atcommand_kami(const int, dumb_ptr<map_session_data>,
+ATCE atcommand_kami(Session *, dumb_ptr<map_session_data>,
ZString message)
{
if (!message)
@@ -1230,7 +1235,7 @@ ATCE atcommand_kami(const int, dumb_ptr<map_session_data>,
}
static
-ATCE atcommand_heal(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_heal(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
int hp = 0, sp = 0;
@@ -1266,13 +1271,13 @@ ATCE atcommand_heal(const int fd, dumb_ptr<map_session_data> sd,
{
pc_heal(sd, hp, sp);
if (hp >= 0 && sp >= 0)
- clif_displaymessage(fd, "HP, SP recovered.");
+ clif_displaymessage(s, "HP, SP recovered.");
else
- clif_displaymessage(fd, "HP or/and SP modified.");
+ clif_displaymessage(s, "HP or/and SP modified.");
}
else
{
- clif_displaymessage(fd, "HP and SP are already with the good value.");
+ clif_displaymessage(s, "HP and SP are already with the good value.");
return ATCE::RANGE;
}
@@ -1280,7 +1285,7 @@ ATCE atcommand_heal(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_item(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_item(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
ItemName item_name;
@@ -1290,7 +1295,7 @@ ATCE atcommand_item(const int fd, dumb_ptr<map_session_data> sd,
if (!extract(message, record<' ', 1>(&item_name, &number)))
{
- clif_displaymessage(fd,
+ clif_displaymessage(s,
"Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
return ATCE::USAGE;
}
@@ -1323,11 +1328,11 @@ ATCE atcommand_item(const int fd, dumb_ptr<map_session_data> sd,
!= PickupFail::OKAY)
clif_additem(sd, 0, 0, flag);
}
- clif_displaymessage(fd, "Item created.");
+ clif_displaymessage(s, "Item created.");
}
else
{
- clif_displaymessage(fd, "Invalid item ID or name.");
+ clif_displaymessage(s, "Invalid item ID or name.");
return ATCE::EXIST;
}
@@ -1335,7 +1340,7 @@ ATCE atcommand_item(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_itemreset(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_itemreset(Session *s, dumb_ptr<map_session_data> sd,
ZString)
{
int i;
@@ -1346,13 +1351,13 @@ ATCE atcommand_itemreset(const int fd, dumb_ptr<map_session_data> sd,
&& sd->status.inventory[i].equip == EPOS::ZERO)
pc_delitem(sd, i, sd->status.inventory[i].amount, 0);
}
- clif_displaymessage(fd, "All of your items have been removed.");
+ clif_displaymessage(s, "All of your items have been removed.");
return ATCE::OKAY;
}
static
-ATCE atcommand_itemcheck(const int, dumb_ptr<map_session_data> sd,
+ATCE atcommand_itemcheck(Session *, dumb_ptr<map_session_data> sd,
ZString)
{
pc_checkitem(sd);
@@ -1361,14 +1366,14 @@ ATCE atcommand_itemcheck(const int, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_baselevelup(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_baselevelup(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
int level, i;
if (!extract(message, &level) || !level)
{
- clif_displaymessage(fd,
+ clif_displaymessage(s,
"Please, enter a level adjustement (usage: @blvl <number of levels>).");
return ATCE::USAGE;
}
@@ -1377,7 +1382,7 @@ ATCE atcommand_baselevelup(const int fd, dumb_ptr<map_session_data> sd,
{
if (sd->status.base_level == battle_config.maximum_level)
{
- clif_displaymessage(fd, "Base level can't go any higher.");
+ clif_displaymessage(s, "Base level can't go any higher.");
return ATCE::RANGE;
}
if (level > battle_config.maximum_level || level > (battle_config.maximum_level - sd->status.base_level))
@@ -1392,13 +1397,13 @@ ATCE atcommand_baselevelup(const int fd, dumb_ptr<map_session_data> sd,
pc_calcstatus(sd, 0);
pc_heal(sd, sd->status.max_hp, sd->status.max_sp);
clif_misceffect(sd, 0);
- clif_displaymessage(fd, "Base level raised.");
+ clif_displaymessage(s, "Base level raised.");
}
else
{
if (sd->status.base_level == 1)
{
- clif_displaymessage(fd, "Base level can't go any lower.");
+ clif_displaymessage(s, "Base level can't go any lower.");
return ATCE::USAGE;
}
if (level < -battle_config.maximum_level || level < (1 - sd->status.base_level))
@@ -1418,7 +1423,7 @@ ATCE atcommand_baselevelup(const int fd, dumb_ptr<map_session_data> sd,
clif_updatestatus(sd, SP::BASELEVEL);
clif_updatestatus(sd, SP::NEXTBASEEXP);
pc_calcstatus(sd, 0);
- clif_displaymessage(fd, "Base level lowered.");
+ clif_displaymessage(s, "Base level lowered.");
}
return ATCE::OKAY;
@@ -1427,7 +1432,7 @@ ATCE atcommand_baselevelup(const int fd, dumb_ptr<map_session_data> sd,
// TODO: merge this with pc_setparam(SP::JOBLEVEL)
// then fix the funny 50 and/or 10 limitation.
static
-ATCE atcommand_joblevelup(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_joblevelup(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
int up_level = 50, level;
@@ -1441,7 +1446,7 @@ ATCE atcommand_joblevelup(const int fd, dumb_ptr<map_session_data> sd,
{
if (sd->status.job_level == up_level)
{
- clif_displaymessage(fd, "Job level can't go any higher.");
+ clif_displaymessage(s, "Job level can't go any higher.");
return ATCE::RANGE;
}
if (level > up_level || level > (up_level - sd->status.job_level))
@@ -1454,13 +1459,13 @@ ATCE atcommand_joblevelup(const int fd, dumb_ptr<map_session_data> sd,
clif_updatestatus(sd, SP::SKILLPOINT);
pc_calcstatus(sd, 0);
clif_misceffect(sd, 1);
- clif_displaymessage(fd, "Job level raised.");
+ clif_displaymessage(s, "Job level raised.");
}
else
{
if (sd->status.job_level == 1)
{
- clif_displaymessage(fd, "Job level can't go any lower.");
+ clif_displaymessage(s, "Job level can't go any lower.");
return ATCE::RANGE;
}
if (level < -up_level || level < (1 - sd->status.job_level))
@@ -1478,14 +1483,14 @@ ATCE atcommand_joblevelup(const int fd, dumb_ptr<map_session_data> sd,
}
// to add: remove status points from skills
pc_calcstatus(sd, 0);
- clif_displaymessage(fd, "Job level lowered.");
+ clif_displaymessage(s, "Job level lowered.");
}
return ATCE::OKAY;
}
static
-ATCE atcommand_gm(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_gm(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
if (!message)
@@ -1494,7 +1499,7 @@ ATCE atcommand_gm(const int fd, dumb_ptr<map_session_data> sd,
if (pc_isGM(sd))
{
// a GM can not use this function. only a normal player (become gm is not for gm!)
- clif_displaymessage(fd, "You already have some GM powers.");
+ clif_displaymessage(s, "You already have some GM powers.");
return ATCE::PERM;
}
else
@@ -1504,13 +1509,13 @@ ATCE atcommand_gm(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_pvpoff(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_pvpoff(Session *s, dumb_ptr<map_session_data> sd,
ZString)
{
if (battle_config.pk_mode)
{
//disable command if server is in PK mode [Valaris]
- clif_displaymessage(fd, "This option cannot be used in PK Mode.");
+ clif_displaymessage(s, "This option cannot be used in PK Mode.");
return ATCE::EXIST;
}
@@ -1519,9 +1524,10 @@ ATCE atcommand_pvpoff(const int fd, dumb_ptr<map_session_data> sd,
sd->bl_m->flag.pvp = 0;
for (int i = 0; i < fd_max; i++)
{
- if (!session[i])
+ Session *s2 = session[i].get();
+ if (!s2)
continue;
- dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[i]->session_data.get()));
+ dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
if (pl_sd && pl_sd->state.auth)
{
if (sd->bl_m == pl_sd->bl_m)
@@ -1530,11 +1536,11 @@ ATCE atcommand_pvpoff(const int fd, dumb_ptr<map_session_data> sd,
}
}
}
- clif_displaymessage(fd, "PvP: Off.");
+ clif_displaymessage(s, "PvP: Off.");
}
else
{
- clif_displaymessage(fd, "PvP is already Off.");
+ clif_displaymessage(s, "PvP is already Off.");
return ATCE::EXIST;
}
@@ -1542,13 +1548,13 @@ ATCE atcommand_pvpoff(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_pvpon(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_pvpon(Session *s, dumb_ptr<map_session_data> sd,
ZString)
{
if (battle_config.pk_mode)
{
//disable command if server is in PK mode [Valaris]
- clif_displaymessage(fd, "This option cannot be used in PK Mode.");
+ clif_displaymessage(s, "This option cannot be used in PK Mode.");
return ATCE::EXIST;
}
@@ -1557,9 +1563,10 @@ ATCE atcommand_pvpon(const int fd, dumb_ptr<map_session_data> sd,
sd->bl_m->flag.pvp = 1;
for (int i = 0; i < fd_max; i++)
{
- if (!session[i])
+ Session *s2 = session[i].get();
+ if (!s2)
continue;
- dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[i]->session_data.get()));
+ dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
if (pl_sd && pl_sd->state.auth)
{
if (sd->bl_m == pl_sd->bl_m && !pl_sd->pvp_timer)
@@ -1572,11 +1579,11 @@ ATCE atcommand_pvpon(const int fd, dumb_ptr<map_session_data> sd,
}
}
}
- clif_displaymessage(fd, "PvP: On.");
+ clif_displaymessage(s, "PvP: On.");
}
else
{
- clif_displaymessage(fd, "PvP is already On.");
+ clif_displaymessage(s, "PvP is already On.");
return ATCE::EXIST;
}
@@ -1584,7 +1591,7 @@ ATCE atcommand_pvpon(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_model(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_model(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
int hair_style = 0, hair_color = 0, cloth_color = 0;
@@ -1600,7 +1607,7 @@ ATCE atcommand_model(const int fd, dumb_ptr<map_session_data> sd,
pc_changelook(sd, LOOK::HAIR, hair_style);
pc_changelook(sd, LOOK::HAIR_COLOR, hair_color);
pc_changelook(sd, LOOK::CLOTHES_COLOR, cloth_color);
- clif_displaymessage(fd, "Appearence changed.");
+ clif_displaymessage(s, "Appearence changed.");
}
}
else
@@ -1610,7 +1617,7 @@ ATCE atcommand_model(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_dye(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_dye(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
int cloth_color = 0;
@@ -1622,7 +1629,7 @@ ATCE atcommand_dye(const int fd, dumb_ptr<map_session_data> sd,
{
{
pc_changelook(sd, LOOK::CLOTHES_COLOR, cloth_color);
- clif_displaymessage(fd, "Appearence changed.");
+ clif_displaymessage(s, "Appearence changed.");
}
}
else
@@ -1632,7 +1639,7 @@ ATCE atcommand_dye(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_hair_style(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_hair_style(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
int hair_style = 0;
@@ -1644,7 +1651,7 @@ ATCE atcommand_hair_style(const int fd, dumb_ptr<map_session_data> sd,
{
{
pc_changelook(sd, LOOK::HAIR, hair_style);
- clif_displaymessage(fd, "Appearence changed.");
+ clif_displaymessage(s, "Appearence changed.");
}
}
else
@@ -1654,7 +1661,7 @@ ATCE atcommand_hair_style(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_hair_color(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_hair_color(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
int hair_color = 0;
@@ -1666,7 +1673,7 @@ ATCE atcommand_hair_color(const int fd, dumb_ptr<map_session_data> sd,
{
{
pc_changelook(sd, LOOK::HAIR_COLOR, hair_color);
- clif_displaymessage(fd, "Appearence changed.");
+ clif_displaymessage(s, "Appearence changed.");
}
}
else
@@ -1676,7 +1683,7 @@ ATCE atcommand_hair_color(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_spawn(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_spawn(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
MobName monster;
@@ -1736,16 +1743,16 @@ ATCE atcommand_spawn(const int fd, dumb_ptr<map_session_data> sd,
if (count != 0)
if (number == count)
- clif_displaymessage(fd, "All monster summoned!");
+ clif_displaymessage(s, "All monster summoned!");
else
{
FString output = STRPRINTF("%d monster(s) summoned!",
count);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
}
else
{
- clif_displaymessage(fd, "Invalid monster ID or name.");
+ clif_displaymessage(s, "Invalid monster ID or name.");
return ATCE::EXIST;
}
@@ -1753,7 +1760,7 @@ ATCE atcommand_spawn(const int fd, dumb_ptr<map_session_data> sd,
}
static
-void atcommand_killmonster_sub(const int fd, dumb_ptr<map_session_data> sd,
+void atcommand_killmonster_sub(Session *s, dumb_ptr<map_session_data> sd,
ZString message, const int drop)
{
map_local *map_id;
@@ -1771,34 +1778,34 @@ void atcommand_killmonster_sub(const int fd, dumb_ptr<map_session_data> sd,
map_id->xs, map_id->ys,
BL::MOB);
- clif_displaymessage(fd, "All monsters killed!");
+ clif_displaymessage(s, "All monsters killed!");
}
static
-ATCE atcommand_killmonster(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_killmonster(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
- atcommand_killmonster_sub(fd, sd, message, 1);
+ atcommand_killmonster_sub(s, sd, message, 1);
return ATCE::OKAY;
}
static
-void atlist_nearby_sub(dumb_ptr<block_list> bl, int fd)
+void atlist_nearby_sub(dumb_ptr<block_list> bl, Session *s)
{
nullpo_retv(bl);
FString buf = STRPRINTF(" - \"%s\"",
bl->is_player()->status.name);
- clif_displaymessage(fd, buf);
+ clif_displaymessage(s, buf);
}
static
-ATCE atcommand_list_nearby(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_list_nearby(Session *s, dumb_ptr<map_session_data> sd,
ZString)
{
- clif_displaymessage(fd, "Nearby players:");
- map_foreachinarea(std::bind(atlist_nearby_sub, ph::_1, fd),
+ clif_displaymessage(s, "Nearby players:");
+ map_foreachinarea(std::bind(atlist_nearby_sub, ph::_1, s),
sd->bl_m,
sd->bl_x - 1, sd->bl_y - 1,
sd->bl_x + 1, sd->bl_x + 1,
@@ -1808,16 +1815,16 @@ ATCE atcommand_list_nearby(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_killmonster2(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_killmonster2(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
- atcommand_killmonster_sub(fd, sd, message, 0);
+ atcommand_killmonster_sub(s, sd, message, 0);
return ATCE::OKAY;
}
static
-ATCE atcommand_gat(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_gat(Session *s, dumb_ptr<map_session_data> sd,
ZString)
{
int y;
@@ -1832,14 +1839,14 @@ ATCE atcommand_gat(const int fd, dumb_ptr<map_session_data> sd,
map_getcell(sd->bl_m, sd->bl_x, sd->bl_y + y),
map_getcell(sd->bl_m, sd->bl_x + 1, sd->bl_y + y),
map_getcell(sd->bl_m, sd->bl_x + 2, sd->bl_y + y));
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
}
return ATCE::OKAY;
}
static
-ATCE atcommand_packet(const int, dumb_ptr<map_session_data> sd,
+ATCE atcommand_packet(Session *, dumb_ptr<map_session_data> sd,
ZString message)
{
StatusChange type {};
@@ -1854,7 +1861,7 @@ ATCE atcommand_packet(const int, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_statuspoint(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_statuspoint(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
int point, new_status_point;
@@ -1874,7 +1881,7 @@ ATCE atcommand_statuspoint(const int fd, dumb_ptr<map_session_data> sd,
{
sd->status.status_point = new_status_point;
clif_updatestatus(sd, SP::STATUSPOINT);
- clif_displaymessage(fd, "Number of status points changed!");
+ clif_displaymessage(s, "Number of status points changed!");
}
else
return ATCE::RANGE;
@@ -1883,7 +1890,7 @@ ATCE atcommand_statuspoint(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_skillpoint(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_skillpoint(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
int point, new_skill_point;
@@ -1903,7 +1910,7 @@ ATCE atcommand_skillpoint(const int fd, dumb_ptr<map_session_data> sd,
{
sd->status.skill_point = new_skill_point;
clif_updatestatus(sd, SP::SKILLPOINT);
- clif_displaymessage(fd, "Number of skill points changed!");
+ clif_displaymessage(s, "Number of skill points changed!");
}
else
return ATCE::RANGE;
@@ -1912,7 +1919,7 @@ ATCE atcommand_skillpoint(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_zeny(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_zeny(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
int zeny, new_zeny;
@@ -1932,7 +1939,7 @@ ATCE atcommand_zeny(const int fd, dumb_ptr<map_session_data> sd,
{
sd->status.zeny = new_zeny;
clif_updatestatus(sd, SP::ZENY);
- clif_displaymessage(fd, "Number of zenys changed!");
+ clif_displaymessage(s, "Number of zenys changed!");
}
else
return ATCE::RANGE;
@@ -1941,7 +1948,7 @@ ATCE atcommand_zeny(const int fd, dumb_ptr<map_session_data> sd,
}
template<ATTR attr>
-ATCE atcommand_param(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_param(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
int value = 0, new_value;
@@ -1964,7 +1971,7 @@ ATCE atcommand_param(const int fd, dumb_ptr<map_session_data> sd,
clif_updatestatus(sd, attr_to_sp(attr));
clif_updatestatus(sd, attr_to_usp(attr));
pc_calcstatus(sd, 0);
- clif_displaymessage(fd, "Stat changed.");
+ clif_displaymessage(s, "Stat changed.");
}
else
return ATCE::RANGE;
@@ -1973,7 +1980,7 @@ ATCE atcommand_param(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_all_stats(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_all_stats(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
int count, value = 0, new_value;
@@ -2005,7 +2012,7 @@ ATCE atcommand_all_stats(const int fd, dumb_ptr<map_session_data> sd,
if (count > 0)
// if at least 1 stat modified
- clif_displaymessage(fd, "All stats changed!");
+ clif_displaymessage(s, "All stats changed!");
else
return ATCE::RANGE;
@@ -2013,7 +2020,7 @@ ATCE atcommand_all_stats(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_recall(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_recall(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
CharName character;
@@ -2030,30 +2037,30 @@ ATCE atcommand_recall(const int fd, dumb_ptr<map_session_data> sd,
if (sd->bl_m && sd->bl_m->flag.nowarpto
&& battle_config.any_warp_GM_min_level > pc_isGM(sd))
{
- clif_displaymessage(fd,
+ clif_displaymessage(s,
"You are not authorised to warp somenone to your actual map.");
return ATCE::PERM;
}
if (pl_sd->bl_m && pl_sd->bl_m->flag.nowarp
&& battle_config.any_warp_GM_min_level > pc_isGM(sd))
{
- clif_displaymessage(fd,
+ clif_displaymessage(s,
"You are not authorised to warp this player from its actual map.");
return ATCE::PERM;
}
pc_setpos(pl_sd, sd->mapname_, sd->bl_x, sd->bl_y, BeingRemoveWhy::QUIT);
FString output = STRPRINTF("%s recalled!", character);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
}
else
{
- clif_displaymessage(fd, "Your GM level don't authorise you to do this action on this player.");
+ clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player.");
return ATCE::PERM;
}
}
else
{
- clif_displaymessage(fd, "Character not found.");
+ clif_displaymessage(s, "Character not found.");
return ATCE::EXIST;
}
@@ -2061,7 +2068,7 @@ ATCE atcommand_recall(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_revive(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_revive(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
CharName character;
@@ -2079,11 +2086,11 @@ ATCE atcommand_revive(const int fd, dumb_ptr<map_session_data> sd,
clif_updatestatus(pl_sd, SP::HP);
clif_updatestatus(pl_sd, SP::SP);
clif_resurrection(pl_sd, 1);
- clif_displaymessage(fd, "Character revived.");
+ clif_displaymessage(s, "Character revived.");
}
else
{
- clif_displaymessage(fd, "Character not found.");
+ clif_displaymessage(s, "Character not found.");
return ATCE::EXIST;
}
@@ -2091,7 +2098,7 @@ ATCE atcommand_revive(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_character_stats(const int fd, dumb_ptr<map_session_data>,
+ATCE atcommand_character_stats(Session *s, dumb_ptr<map_session_data>,
ZString message)
{
CharName character;
@@ -2104,37 +2111,37 @@ ATCE atcommand_character_stats(const int fd, dumb_ptr<map_session_data>,
{
FString output;
output = STRPRINTF("'%s' stats:", pl_sd->status.name);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
output = STRPRINTF("Base Level - %d", pl_sd->status.base_level),
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
output = STRPRINTF("Job - Novice/Human (level %d)", pl_sd->status.job_level);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
output = STRPRINTF("Hp - %d", pl_sd->status.hp);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
output = STRPRINTF("MaxHp - %d", pl_sd->status.max_hp);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
output = STRPRINTF("Sp - %d", pl_sd->status.sp);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
output = STRPRINTF("MaxSp - %d", pl_sd->status.max_sp);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
output = STRPRINTF("Str - %3d", pl_sd->status.attrs[ATTR::STR]);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
output = STRPRINTF("Agi - %3d", pl_sd->status.attrs[ATTR::AGI]);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
output = STRPRINTF("Vit - %3d", pl_sd->status.attrs[ATTR::VIT]);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
output = STRPRINTF("Int - %3d", pl_sd->status.attrs[ATTR::INT]);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
output = STRPRINTF("Dex - %3d", pl_sd->status.attrs[ATTR::DEX]);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
output = STRPRINTF("Luk - %3d", pl_sd->status.attrs[ATTR::LUK]);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
output = STRPRINTF("Zeny - %d", pl_sd->status.zeny);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
}
else
{
- clif_displaymessage(fd, "Character not found.");
+ clif_displaymessage(s, "Character not found.");
return ATCE::EXIST;
}
@@ -2142,7 +2149,7 @@ ATCE atcommand_character_stats(const int fd, dumb_ptr<map_session_data>,
}
static
-ATCE atcommand_character_stats_all(const int fd, dumb_ptr<map_session_data>,
+ATCE atcommand_character_stats_all(Session *s, dumb_ptr<map_session_data>,
ZString)
{
int count;
@@ -2150,9 +2157,10 @@ ATCE atcommand_character_stats_all(const int fd, dumb_ptr<map_session_data>,
count = 0;
for (int i = 0; i < fd_max; i++)
{
- if (!session[i])
+ Session *s2 = session[i].get();
+ if (!s2)
continue;
- dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[i]->session_data.get()));
+ dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
if (pl_sd && pl_sd->state.auth)
{
FString gmlevel;
@@ -2168,7 +2176,7 @@ ATCE atcommand_character_stats_all(const int fd, dumb_ptr<map_session_data>,
pl_sd->status.job_level,
pl_sd->status.hp, pl_sd->status.max_hp,
pl_sd->status.sp, pl_sd->status.max_sp);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
output = STRPRINTF("STR: %d | AGI: %d | VIT: %d | INT: %d | DEX: %d | LUK: %d | Zeny: %d %s",
pl_sd->status.attrs[ATTR::STR],
pl_sd->status.attrs[ATTR::AGI],
@@ -2178,27 +2186,27 @@ ATCE atcommand_character_stats_all(const int fd, dumb_ptr<map_session_data>,
pl_sd->status.attrs[ATTR::LUK],
pl_sd->status.zeny,
gmlevel);
- clif_displaymessage(fd, output);
- clif_displaymessage(fd, "--------");
+ clif_displaymessage(s, output);
+ clif_displaymessage(s, "--------");
count++;
}
}
if (count == 0)
- clif_displaymessage(fd, "No player found.");
+ clif_displaymessage(s, "No player found.");
else if (count == 1)
- clif_displaymessage(fd, "1 player found.");
+ clif_displaymessage(s, "1 player found.");
else
{
FString output = STRPRINTF("%d players found.", count);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
}
return ATCE::OKAY;
}
static
-ATCE atcommand_character_option(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_character_option(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
Opt1 opt1;
@@ -2220,17 +2228,17 @@ ATCE atcommand_character_option(const int fd, dumb_ptr<map_session_data> sd,
clif_changeoption(pl_sd);
pc_calcstatus(pl_sd, 0);
- clif_displaymessage(fd, "Character's options changed.");
+ clif_displaymessage(s, "Character's options changed.");
}
else
{
- clif_displaymessage(fd, "Your GM level don't authorise you to do this action on this player.");
+ clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player.");
return ATCE::PERM;
}
}
else
{
- clif_displaymessage(fd, "Character not found.");
+ clif_displaymessage(s, "Character not found.");
return ATCE::EXIST;
}
@@ -2238,7 +2246,7 @@ ATCE atcommand_character_option(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_char_change_sex(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_char_change_sex(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
CharName character;
@@ -2249,14 +2257,14 @@ ATCE atcommand_char_change_sex(const int fd, dumb_ptr<map_session_data> sd,
{
chrif_char_ask_name(sd->status.account_id, character, 5, HumanTimeDiff());
// type: 5 - changesex
- clif_displaymessage(fd, "Character name sends to char-server to ask it.");
+ clif_displaymessage(s, "Character name sends to char-server to ask it.");
}
return ATCE::OKAY;
}
static
-ATCE atcommand_char_block(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_char_block(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
CharName character;
@@ -2267,14 +2275,14 @@ ATCE atcommand_char_block(const int fd, dumb_ptr<map_session_data> sd,
{
chrif_char_ask_name(sd->status.account_id, character, 1, HumanTimeDiff());
// type: 1 - block
- clif_displaymessage(fd, "Character name sends to char-server to ask it.");
+ clif_displaymessage(s, "Character name sends to char-server to ask it.");
}
return ATCE::OKAY;
}
static
-ATCE atcommand_char_ban(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_char_ban(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
HumanTimeDiff modif;
@@ -2287,14 +2295,14 @@ ATCE atcommand_char_ban(const int fd, dumb_ptr<map_session_data> sd,
{
chrif_char_ask_name(sd->status.account_id, character, 2, modif);
// type: 2 - ban
- clif_displaymessage(fd, "Character name sends to char-server to ask it.");
+ clif_displaymessage(s, "Character name sends to char-server to ask it.");
}
return ATCE::OKAY;
}
static
-ATCE atcommand_char_unblock(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_char_unblock(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
CharName character;
@@ -2306,14 +2314,14 @@ ATCE atcommand_char_unblock(const int fd, dumb_ptr<map_session_data> sd,
// send answer to login server via char-server
chrif_char_ask_name(sd->status.account_id, character, 3, HumanTimeDiff());
// type: 3 - unblock
- clif_displaymessage(fd, "Character name sends to char-server to ask it.");
+ clif_displaymessage(s, "Character name sends to char-server to ask it.");
}
return ATCE::OKAY;
}
static
-ATCE atcommand_char_unban(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_char_unban(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
CharName character;
@@ -2325,14 +2333,14 @@ ATCE atcommand_char_unban(const int fd, dumb_ptr<map_session_data> sd,
// send answer to login server via char-server
chrif_char_ask_name(sd->status.account_id, character, 4, HumanTimeDiff());
// type: 4 - unban
- clif_displaymessage(fd, "Character name sends to char-server to ask it.");
+ clif_displaymessage(s, "Character name sends to char-server to ask it.");
}
return ATCE::OKAY;
}
static
-ATCE atcommand_character_save(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_character_save(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
MapName map_name;
@@ -2352,7 +2360,7 @@ ATCE atcommand_character_save(const int fd, dumb_ptr<map_session_data> sd,
map_local *m = map_mapname2mapid(map_name);
if (m == nullptr)
{
- clif_displaymessage(fd, "Map not found.");
+ clif_displaymessage(s, "Map not found.");
return ATCE::EXIST;
}
else
@@ -2360,23 +2368,23 @@ ATCE atcommand_character_save(const int fd, dumb_ptr<map_session_data> sd,
if (m != nullptr && m->flag.nowarpto
&& battle_config.any_warp_GM_min_level > pc_isGM(sd))
{
- clif_displaymessage(fd,
+ clif_displaymessage(s,
"You are not authorised to set this map as a save map.");
return ATCE::PERM;
}
pc_setsavepoint(pl_sd, map_name, x, y);
- clif_displaymessage(fd, "Character's respawn point changed.");
+ clif_displaymessage(s, "Character's respawn point changed.");
}
}
else
{
- clif_displaymessage(fd, "Your GM level don't authorise you to do this action on this player.");
+ clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player.");
return ATCE::PERM;
}
}
else
{
- clif_displaymessage(fd, "Character not found.");
+ clif_displaymessage(s, "Character not found.");
return ATCE::EXIST;
}
@@ -2384,47 +2392,49 @@ ATCE atcommand_character_save(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_doom(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_doom(Session *s, dumb_ptr<map_session_data> sd,
ZString)
{
for (int i = 0; i < fd_max; i++)
{
- if (!session[i])
+ Session *s2 = session[i].get();
+ if (!s2)
continue;
- dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[i]->session_data.get()));
+ dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
if (pl_sd
- && pl_sd->state.auth && i != fd
+ && pl_sd->state.auth && s2 != s
&& pc_isGM(sd) >= pc_isGM(pl_sd))
{
// you can doom only lower or same gm level
pc_damage(NULL, pl_sd, pl_sd->status.hp + 1);
- clif_displaymessage(pl_sd->fd, "The holy messenger has given judgement.");
+ clif_displaymessage(pl_sd->sess, "The holy messenger has given judgement.");
}
}
- clif_displaymessage(fd, "Judgement was made.");
+ clif_displaymessage(s, "Judgement was made.");
return ATCE::OKAY;
}
static
-ATCE atcommand_doommap(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_doommap(Session *s, dumb_ptr<map_session_data> sd,
ZString)
{
for (int i = 0; i < fd_max; i++)
{
- if (!session[i])
+ Session *s2 = session[i].get();
+ if (!s2)
continue;
- dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[i]->session_data.get()));
+ dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
if (pl_sd
- && pl_sd->state.auth && i != fd && sd->bl_m == pl_sd->bl_m
+ && pl_sd->state.auth && s2 != s && sd->bl_m == pl_sd->bl_m
&& pc_isGM(sd) >= pc_isGM(pl_sd))
{
// you can doom only lower or same gm level
pc_damage(NULL, pl_sd, pl_sd->status.hp + 1);
- clif_displaymessage(pl_sd->fd, "The holy messenger has given judgement.");
+ clif_displaymessage(pl_sd->sess, "The holy messenger has given judgement.");
}
}
- clif_displaymessage(fd, "Judgement was made.");
+ clif_displaymessage(s, "Judgement was made.");
return ATCE::OKAY;
}
@@ -2440,46 +2450,48 @@ void atcommand_raise_sub(dumb_ptr<map_session_data> sd)
clif_updatestatus(sd, SP::HP);
clif_updatestatus(sd, SP::SP);
clif_resurrection(sd, 1);
- clif_displaymessage(sd->fd, "Mercy has been shown.");
+ clif_displaymessage(sd->sess, "Mercy has been shown.");
}
}
static
-ATCE atcommand_raise(const int fd, dumb_ptr<map_session_data>,
+ATCE atcommand_raise(Session *s, dumb_ptr<map_session_data>,
ZString)
{
for (int i = 0; i < fd_max; i++)
{
- if (!session[i])
+ Session *s2 = session[i].get();
+ if (!s2)
continue;
- dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[i]->session_data.get()));
+ dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
atcommand_raise_sub(pl_sd);
}
- clif_displaymessage(fd, "Mercy has been granted.");
+ clif_displaymessage(s, "Mercy has been granted.");
return ATCE::OKAY;
}
static
-ATCE atcommand_raisemap(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_raisemap(Session *s, dumb_ptr<map_session_data> sd,
ZString)
{
for (int i = 0; i < fd_max; i++)
{
- if (!session[i])
+ Session *s2 = session[i].get();
+ if (!s2)
continue;
- dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[i]->session_data.get()));
+ dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
if (pl_sd
&& pl_sd->state.auth && sd->bl_m == pl_sd->bl_m)
atcommand_raise_sub(pl_sd);
}
- clif_displaymessage(fd, "Mercy has been granted.");
+ clif_displaymessage(s, "Mercy has been granted.");
return ATCE::OKAY;
}
//static
-ATCE atcommand_character_baselevel(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_character_baselevel(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
CharName character;
@@ -2499,7 +2511,7 @@ ATCE atcommand_character_baselevel(const int fd, dumb_ptr<map_session_data> sd,
{
if (pl_sd->status.base_level == battle_config.maximum_level)
{
- clif_displaymessage(fd, "Character's base level can't go any higher.");
+ clif_displaymessage(s, "Character's base level can't go any higher.");
return ATCE::RANGE;
}
if (level > battle_config.maximum_level || level > (battle_config.maximum_level - pl_sd->status.base_level))
@@ -2517,13 +2529,13 @@ ATCE atcommand_character_baselevel(const int fd, dumb_ptr<map_session_data> sd,
pc_calcstatus(pl_sd, 0);
pc_heal(pl_sd, pl_sd->status.max_hp, pl_sd->status.max_sp);
clif_misceffect(pl_sd, 0);
- clif_displaymessage(fd, "Character's base level raised.");
+ clif_displaymessage(s, "Character's base level raised.");
}
else
{
if (pl_sd->status.base_level == 1)
{
- clif_displaymessage(fd, "Character's base level can't go any lower.");
+ clif_displaymessage(s, "Character's base level can't go any lower.");
return ATCE::RANGE;
}
if (level < -battle_config.maximum_level || level < (1 - pl_sd->status.base_level))
@@ -2545,20 +2557,20 @@ ATCE atcommand_character_baselevel(const int fd, dumb_ptr<map_session_data> sd,
clif_updatestatus(pl_sd, SP::NEXTBASEEXP);
clif_updatestatus(pl_sd, SP::BASEEXP);
pc_calcstatus(pl_sd, 0);
- clif_displaymessage(fd, "Character's base level lowered.");
+ clif_displaymessage(s, "Character's base level lowered.");
}
// Reset their stat points to prevent extra points from stacking
- atcommand_charstreset(fd, sd, character.to__actual());
+ atcommand_charstreset(s, sd, character.to__actual());
}
else
{
- clif_displaymessage(fd, "Your GM level don't authorise you to do this action on this player.");
+ clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player.");
return ATCE::PERM;
}
}
else
{
- clif_displaymessage(fd, "Character not found.");
+ clif_displaymessage(s, "Character not found.");
return ATCE::EXIST;
}
@@ -2566,7 +2578,7 @@ ATCE atcommand_character_baselevel(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_character_joblevel(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_character_joblevel(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
CharName character;
@@ -2588,7 +2600,7 @@ ATCE atcommand_character_joblevel(const int fd, dumb_ptr<map_session_data> sd,
{
if (pl_sd->status.job_level == max_level)
{
- clif_displaymessage(fd, "Character's job level can't go any higher.");
+ clif_displaymessage(s, "Character's job level can't go any higher.");
return ATCE::RANGE;
}
if (pl_sd->status.job_level + level > max_level)
@@ -2600,13 +2612,13 @@ ATCE atcommand_character_joblevel(const int fd, dumb_ptr<map_session_data> sd,
clif_updatestatus(pl_sd, SP::SKILLPOINT);
pc_calcstatus(pl_sd, 0);
clif_misceffect(pl_sd, 1);
- clif_displaymessage(fd, "character's job level raised.");
+ clif_displaymessage(s, "character's job level raised.");
}
else
{
if (pl_sd->status.job_level == 1)
{
- clif_displaymessage(fd, "Character's job level can't go any lower.");
+ clif_displaymessage(s, "Character's job level can't go any lower.");
return ATCE::RANGE;
}
if (pl_sd->status.job_level + level < 1)
@@ -2623,18 +2635,18 @@ ATCE atcommand_character_joblevel(const int fd, dumb_ptr<map_session_data> sd,
}
// to add: remove status points from skills
pc_calcstatus(pl_sd, 0);
- clif_displaymessage(fd, "Character's job level lowered.");
+ clif_displaymessage(s, "Character's job level lowered.");
}
}
else
{
- clif_displaymessage(fd, "Your GM level don't authorise you to do this action on this player.");
+ clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player.");
return ATCE::PERM;
}
}
else
{
- clif_displaymessage(fd, "Character not found.");
+ clif_displaymessage(s, "Character not found.");
return ATCE::EXIST;
}
@@ -2642,7 +2654,7 @@ ATCE atcommand_character_joblevel(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_kick(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_kick(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
CharName character;
@@ -2658,13 +2670,13 @@ ATCE atcommand_kick(const int fd, dumb_ptr<map_session_data> sd,
clif_GM_kick(sd, pl_sd, 1);
else
{
- clif_displaymessage(fd, "Your GM level don't authorise you to do this action on this player.");
+ clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player.");
return ATCE::PERM;
}
}
else
{
- clif_displaymessage(fd, "Character not found.");
+ clif_displaymessage(s, "Character not found.");
return ATCE::EXIST;
}
@@ -2672,14 +2684,15 @@ ATCE atcommand_kick(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_kickall(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_kickall(Session *s, dumb_ptr<map_session_data> sd,
ZString)
{
for (int i = 0; i < fd_max; i++)
{
- if (!session[i])
+ Session *s2 = session[i].get();
+ if (!s2)
continue;
- dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[i]->session_data.get()));
+ dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
if (pl_sd
&& pl_sd->state.auth && pc_isGM(sd) >= pc_isGM(pl_sd))
{
@@ -2689,13 +2702,13 @@ ATCE atcommand_kickall(const int fd, dumb_ptr<map_session_data> sd,
}
}
- clif_displaymessage(fd, "All players have been kicked!");
+ clif_displaymessage(s, "All players have been kicked!");
return ATCE::OKAY;
}
static
-ATCE atcommand_questskill(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_questskill(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
SkillID skill_id;
@@ -2710,23 +2723,23 @@ ATCE atcommand_questskill(const int fd, dumb_ptr<map_session_data> sd,
if (pc_checkskill(sd, skill_id) == 0)
{
pc_skill(sd, skill_id, 1, 0);
- clif_displaymessage(fd, "You have learned the skill.");
+ clif_displaymessage(s, "You have learned the skill.");
}
else
{
- clif_displaymessage(fd, "You already have this quest skill.");
+ clif_displaymessage(s, "You already have this quest skill.");
return ATCE::EXIST;
}
}
else
{
- clif_displaymessage(fd, "This skill number doesn't exist or isn't a quest skill.");
+ clif_displaymessage(s, "This skill number doesn't exist or isn't a quest skill.");
return ATCE::RANGE;
}
}
else
{
- clif_displaymessage(fd, "This skill number doesn't exist.");
+ clif_displaymessage(s, "This skill number doesn't exist.");
return ATCE::RANGE;
}
@@ -2734,7 +2747,7 @@ ATCE atcommand_questskill(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_charquestskill(const int fd, dumb_ptr<map_session_data>,
+ATCE atcommand_charquestskill(Session *s, dumb_ptr<map_session_data>,
ZString message)
{
CharName character;
@@ -2753,29 +2766,29 @@ ATCE atcommand_charquestskill(const int fd, dumb_ptr<map_session_data>,
if (pc_checkskill(pl_sd, skill_id) == 0)
{
pc_skill(pl_sd, skill_id, 1, 0);
- clif_displaymessage(fd, "This player has learned the skill.");
+ clif_displaymessage(s, "This player has learned the skill.");
}
else
{
- clif_displaymessage(fd, "This player already has this quest skill.");
+ clif_displaymessage(s, "This player already has this quest skill.");
return ATCE::EXIST;
}
}
else
{
- clif_displaymessage(fd, "Character not found.");
+ clif_displaymessage(s, "Character not found.");
return ATCE::EXIST;
}
}
else
{
- clif_displaymessage(fd, "This skill number doesn't exist or isn't a quest skill.");
+ clif_displaymessage(s, "This skill number doesn't exist or isn't a quest skill.");
return ATCE::RANGE;
}
}
else
{
- clif_displaymessage(fd, "This skill number doesn't exist.");
+ clif_displaymessage(s, "This skill number doesn't exist.");
return ATCE::RANGE;
}
@@ -2783,7 +2796,7 @@ ATCE atcommand_charquestskill(const int fd, dumb_ptr<map_session_data>,
}
static
-ATCE atcommand_lostskill(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_lostskill(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
SkillID skill_id;
@@ -2800,23 +2813,23 @@ ATCE atcommand_lostskill(const int fd, dumb_ptr<map_session_data> sd,
sd->status.skill[skill_id].lv = 0;
sd->status.skill[skill_id].flags = SkillFlags::ZERO;
clif_skillinfoblock(sd);
- clif_displaymessage(fd, "You have forgotten the skill.");
+ clif_displaymessage(s, "You have forgotten the skill.");
}
else
{
- clif_displaymessage(fd, "You don't have this quest skill.");
+ clif_displaymessage(s, "You don't have this quest skill.");
return ATCE::EXIST;
}
}
else
{
- clif_displaymessage(fd, "This skill number doesn't exist or isn't a quest skill.");
+ clif_displaymessage(s, "This skill number doesn't exist or isn't a quest skill.");
return ATCE::RANGE;
}
}
else
{
- clif_displaymessage(fd, "This skill number doesn't exist.");
+ clif_displaymessage(s, "This skill number doesn't exist.");
return ATCE::RANGE;
}
@@ -2824,7 +2837,7 @@ ATCE atcommand_lostskill(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_charlostskill(const int fd, dumb_ptr<map_session_data>,
+ATCE atcommand_charlostskill(Session *s, dumb_ptr<map_session_data>,
ZString message)
{
CharName character;
@@ -2845,29 +2858,29 @@ ATCE atcommand_charlostskill(const int fd, dumb_ptr<map_session_data>,
pl_sd->status.skill[skill_id].lv = 0;
pl_sd->status.skill[skill_id].flags = SkillFlags::ZERO;
clif_skillinfoblock(pl_sd);
- clif_displaymessage(fd, "This player has forgotten the skill.");
+ clif_displaymessage(s, "This player has forgotten the skill.");
}
else
{
- clif_displaymessage(fd, "This player doesn't have this quest skill.");
+ clif_displaymessage(s, "This player doesn't have this quest skill.");
return ATCE::EXIST;
}
}
else
{
- clif_displaymessage(fd, "Character not found.");
+ clif_displaymessage(s, "Character not found.");
return ATCE::EXIST;
}
}
else
{
- clif_displaymessage(fd, "This skill number doesn't exist or isn't a quest skill.");
+ clif_displaymessage(s, "This skill number doesn't exist or isn't a quest skill.");
return ATCE::RANGE;
}
}
else
{
- clif_displaymessage(fd, "This skill number doesn't exist.");
+ clif_displaymessage(s, "This skill number doesn't exist.");
return ATCE::RANGE;
}
@@ -2875,7 +2888,7 @@ ATCE atcommand_charlostskill(const int fd, dumb_ptr<map_session_data>,
}
static
-ATCE atcommand_party(const int, dumb_ptr<map_session_data> sd,
+ATCE atcommand_party(Session *, dumb_ptr<map_session_data> sd,
ZString message)
{
PartyName party;
@@ -2889,14 +2902,15 @@ ATCE atcommand_party(const int, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_mapexit(const int, dumb_ptr<map_session_data> sd,
+ATCE atcommand_mapexit(Session *, dumb_ptr<map_session_data> sd,
ZString)
{
for (int i = 0; i < fd_max; i++)
{
- if (!session[i])
+ Session *s2 = session[i].get();
+ if (!s2)
continue;
- dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[i]->session_data.get()));
+ dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
if (pl_sd && pl_sd->state.auth)
{
if (sd->status.account_id != pl_sd->status.account_id)
@@ -2911,7 +2925,7 @@ ATCE atcommand_mapexit(const int, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_idsearch(const int fd, dumb_ptr<map_session_data>,
+ATCE atcommand_idsearch(Session *s, dumb_ptr<map_session_data>,
ZString message)
{
ItemName item_name;
@@ -2922,7 +2936,7 @@ ATCE atcommand_idsearch(const int fd, dumb_ptr<map_session_data>,
return ATCE::USAGE;
FString output = STRPRINTF("The reference result of '%s' (name: id):", item_name);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
match = 0;
for (i = 0; i < 20000; i++)
{
@@ -2931,17 +2945,17 @@ ATCE atcommand_idsearch(const int fd, dumb_ptr<map_session_data>,
{
match++;
output = STRPRINTF("%s: %d", item->jname, item->nameid);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
}
}
output = STRPRINTF("It is %d affair above.", match);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
return ATCE::OKAY;
}
static
-ATCE atcommand_charskreset(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_charskreset(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
CharName character;
@@ -2958,17 +2972,17 @@ ATCE atcommand_charskreset(const int fd, dumb_ptr<map_session_data> sd,
pc_resetskill(pl_sd);
FString output = STRPRINTF(
"'%s' skill points reseted!", character);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
}
else
{
- clif_displaymessage(fd, "Your GM level don't authorise you to do this action on this player.");
+ clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player.");
return ATCE::PERM;
}
}
else
{
- clif_displaymessage(fd, "Character not found.");
+ clif_displaymessage(s, "Character not found.");
return ATCE::EXIST;
}
@@ -2976,7 +2990,7 @@ ATCE atcommand_charskreset(const int fd, dumb_ptr<map_session_data> sd,
}
//static
-ATCE atcommand_charstreset(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_charstreset(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
CharName character;
@@ -2994,17 +3008,17 @@ ATCE atcommand_charstreset(const int fd, dumb_ptr<map_session_data> sd,
FString output = STRPRINTF(
"'%s' stats points reseted!",
character);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
}
else
{
- clif_displaymessage(fd, "Your GM level don't authorise you to do this action on this player.");
+ clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player.");
return ATCE::PERM;
}
}
else
{
- clif_displaymessage(fd, "Character not found.");
+ clif_displaymessage(s, "Character not found.");
return ATCE::EXIST;
}
@@ -3012,7 +3026,7 @@ ATCE atcommand_charstreset(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_charreset(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_charreset(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
CharName character;
@@ -3034,17 +3048,17 @@ ATCE atcommand_charreset(const int fd, dumb_ptr<map_session_data> sd,
// [Fate] Reset magic experience
FString output = STRPRINTF(
"'%s' skill and stats points reseted!", character);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
}
else
{
- clif_displaymessage(fd, "Your GM level don't authorise you to do this action on this player.");
+ clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player.");
return ATCE::PERM;
}
}
else
{
- clif_displaymessage(fd, "Character not found.");
+ clif_displaymessage(s, "Character not found.");
return ATCE::EXIST;
}
@@ -3052,7 +3066,7 @@ ATCE atcommand_charreset(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_char_wipe(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_char_wipe(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
CharName character;
@@ -3118,17 +3132,17 @@ ATCE atcommand_char_wipe(const int fd, dumb_ptr<map_session_data> sd,
// [Fate] Reset magic experience
FString output = STRPRINTF("%s: wiped.", character);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
}
else
{
- clif_displaymessage(fd, "Your GM level don't authorise you to do this action on this player.");
+ clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player.");
return ATCE::PERM;
}
}
else
{
- clif_displaymessage(fd, "Character not found.");
+ clif_displaymessage(s, "Character not found.");
return ATCE::EXIST;
}
@@ -3136,7 +3150,7 @@ ATCE atcommand_char_wipe(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_charmodel(const int fd, dumb_ptr<map_session_data>,
+ATCE atcommand_charmodel(Session *s, dumb_ptr<map_session_data>,
ZString message)
{
unsigned hair_style = 0, hair_color = 0, cloth_color = 0;
@@ -3156,7 +3170,7 @@ ATCE atcommand_charmodel(const int fd, dumb_ptr<map_session_data>,
pc_changelook(pl_sd, LOOK::HAIR, hair_style);
pc_changelook(pl_sd, LOOK::HAIR_COLOR, hair_color);
pc_changelook(pl_sd, LOOK::CLOTHES_COLOR, cloth_color);
- clif_displaymessage(fd, "Appearence changed.");
+ clif_displaymessage(s, "Appearence changed.");
}
}
else
@@ -3164,7 +3178,7 @@ ATCE atcommand_charmodel(const int fd, dumb_ptr<map_session_data>,
}
else
{
- clif_displaymessage(fd, "Character not found.");
+ clif_displaymessage(s, "Character not found.");
return ATCE::EXIST;
}
@@ -3172,7 +3186,7 @@ ATCE atcommand_charmodel(const int fd, dumb_ptr<map_session_data>,
}
static
-ATCE atcommand_charskpoint(const int fd, dumb_ptr<map_session_data>,
+ATCE atcommand_charskpoint(Session *s, dumb_ptr<map_session_data>,
ZString message)
{
CharName character;
@@ -3197,14 +3211,14 @@ ATCE atcommand_charskpoint(const int fd, dumb_ptr<map_session_data>,
{
pl_sd->status.skill_point = new_skill_point;
clif_updatestatus(pl_sd, SP::SKILLPOINT);
- clif_displaymessage(fd, "Character's number of skill points changed!");
+ clif_displaymessage(s, "Character's number of skill points changed!");
}
else
return ATCE::RANGE;
}
else
{
- clif_displaymessage(fd, "Character not found.");
+ clif_displaymessage(s, "Character not found.");
return ATCE::EXIST;
}
@@ -3212,7 +3226,7 @@ ATCE atcommand_charskpoint(const int fd, dumb_ptr<map_session_data>,
}
static
-ATCE atcommand_charstpoint(const int fd, dumb_ptr<map_session_data>,
+ATCE atcommand_charstpoint(Session *s, dumb_ptr<map_session_data>,
ZString message)
{
CharName character;
@@ -3237,14 +3251,14 @@ ATCE atcommand_charstpoint(const int fd, dumb_ptr<map_session_data>,
{
pl_sd->status.status_point = new_status_point;
clif_updatestatus(pl_sd, SP::STATUSPOINT);
- clif_displaymessage(fd, "Character's number of status points changed!");
+ clif_displaymessage(s, "Character's number of status points changed!");
}
else
return ATCE::RANGE;
}
else
{
- clif_displaymessage(fd, "Character not found.");
+ clif_displaymessage(s, "Character not found.");
return ATCE::EXIST;
}
@@ -3252,7 +3266,7 @@ ATCE atcommand_charstpoint(const int fd, dumb_ptr<map_session_data>,
}
static
-ATCE atcommand_charzeny(const int fd, dumb_ptr<map_session_data>,
+ATCE atcommand_charzeny(Session *s, dumb_ptr<map_session_data>,
ZString message)
{
CharName character;
@@ -3275,14 +3289,14 @@ ATCE atcommand_charzeny(const int fd, dumb_ptr<map_session_data>,
{
pl_sd->status.zeny = new_zeny;
clif_updatestatus(pl_sd, SP::ZENY);
- clif_displaymessage(fd, "Character's number of zenys changed!");
+ clif_displaymessage(s, "Character's number of zenys changed!");
}
else
return ATCE::RANGE;
}
else
{
- clif_displaymessage(fd, "Character not found.");
+ clif_displaymessage(s, "Character not found.");
return ATCE::EXIST;
}
@@ -3290,7 +3304,7 @@ ATCE atcommand_charzeny(const int fd, dumb_ptr<map_session_data>,
}
static
-ATCE atcommand_recallall(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_recallall(Session *s, dumb_ptr<map_session_data> sd,
ZString)
{
int count;
@@ -3298,7 +3312,7 @@ ATCE atcommand_recallall(const int fd, dumb_ptr<map_session_data> sd,
if (sd->bl_m && sd->bl_m->flag.nowarpto
&& battle_config.any_warp_GM_min_level > pc_isGM(sd))
{
- clif_displaymessage(fd,
+ clif_displaymessage(s,
"You are not authorised to warp somenone to your actual map.");
return ATCE::PERM;
}
@@ -3306,9 +3320,10 @@ ATCE atcommand_recallall(const int fd, dumb_ptr<map_session_data> sd,
count = 0;
for (int i = 0; i < fd_max; i++)
{
- if (!session[i])
+ Session *s2 = session[i].get();
+ if (!s2)
continue;
- dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[i]->session_data.get()));
+ dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
if (pl_sd
&& pl_sd->state.auth
&& sd->status.account_id != pl_sd->status.account_id
@@ -3323,20 +3338,20 @@ ATCE atcommand_recallall(const int fd, dumb_ptr<map_session_data> sd,
}
}
- clif_displaymessage(fd, "All characters recalled!");
+ clif_displaymessage(s, "All characters recalled!");
if (count)
{
FString output = STRPRINTF(
"Because you are not authorised to warp from some maps, %d player(s) have not been recalled.",
count);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
}
return ATCE::OKAY;
}
static
-ATCE atcommand_partyrecall(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_partyrecall(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
PartyName party_name;
@@ -3349,7 +3364,7 @@ ATCE atcommand_partyrecall(const int fd, dumb_ptr<map_session_data> sd,
if (sd->bl_m && sd->bl_m->flag.nowarpto
&& battle_config.any_warp_GM_min_level > pc_isGM(sd))
{
- clif_displaymessage(fd,
+ clif_displaymessage(s,
"You are not authorised to warp somenone to your actual map.");
return ATCE::PERM;
}
@@ -3361,9 +3376,10 @@ ATCE atcommand_partyrecall(const int fd, dumb_ptr<map_session_data> sd,
count = 0;
for (int i = 0; i < fd_max; i++)
{
- if (!session[i])
+ Session *s2 = session[i].get();
+ if (!s2)
continue;
- dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[i]->session_data.get()));
+ dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
if (pl_sd && pl_sd->state.auth
&& sd->status.account_id != pl_sd->status.account_id
&& pl_sd->status.party_id == p->party_id)
@@ -3376,18 +3392,18 @@ ATCE atcommand_partyrecall(const int fd, dumb_ptr<map_session_data> sd,
}
}
FString output = STRPRINTF("All online characters of the %s party are near you.", p->name);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
if (count)
{
output = STRPRINTF(
"Because you are not authorised to warp from some maps, %d player(s) have not been recalled.",
count);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
}
}
else
{
- clif_displaymessage(fd, "Incorrect name or ID, or no one from the party is online.");
+ clif_displaymessage(s, "Incorrect name or ID, or no one from the party is online.");
return ATCE::EXIST;
}
@@ -3395,7 +3411,7 @@ ATCE atcommand_partyrecall(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_mapinfo(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_mapinfo(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
dumb_ptr<npc_data> nd = NULL;
@@ -3415,42 +3431,42 @@ ATCE atcommand_mapinfo(const int fd, dumb_ptr<map_session_data> sd,
if (m_id != nullptr)
return ATCE::EXIST;
- clif_displaymessage(fd, "------ Map Info ------");
+ clif_displaymessage(s, "------ Map Info ------");
FString output = STRPRINTF("Map Name: %s", map_name);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
output = STRPRINTF("Players In Map: %d", m_id->users);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
output = STRPRINTF("NPCs In Map: %d", m_id->npc_num);
- clif_displaymessage(fd, output);
- clif_displaymessage(fd, "------ Map Flags ------");
+ clif_displaymessage(s, output);
+ clif_displaymessage(s, "------ Map Flags ------");
output = STRPRINTF("Player vs Player: %s | No Party: %s",
(m_id->flag.pvp) ? "True" : "False",
(m_id->flag.pvp_noparty) ? "True" : "False");
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
output = STRPRINTF("No Dead Branch: %s",
(m_id->flag.nobranch) ? "True" : "False");
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
output = STRPRINTF("No Memo: %s",
(m_id->flag.nomemo) ? "True" : "False");
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
output = STRPRINTF("No Penalty: %s",
(m_id->flag.nopenalty) ? "True" : "False");
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
output = STRPRINTF("No Return: %s",
(m_id->flag.noreturn) ? "True" : "False");
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
output = STRPRINTF("No Save: %s",
(m_id->flag.nosave) ? "True" : "False");
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
output = STRPRINTF("No Teleport: %s",
(m_id->flag.noteleport) ? "True" : "False");
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
output = STRPRINTF("No Monster Teleport: %s",
(m_id->flag.monster_noteleport) ? "True" : "False");
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
output = STRPRINTF("No Zeny Penalty: %s",
(m_id->flag.nozenypenalty) ? "True" : "False");
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
switch (list)
{
@@ -3458,24 +3474,25 @@ ATCE atcommand_mapinfo(const int fd, dumb_ptr<map_session_data> sd,
// Do nothing. It's list 0, no additional display.
break;
case 1:
- clif_displaymessage(fd, "----- Players in Map -----");
+ clif_displaymessage(s, "----- Players in Map -----");
for (int i = 0; i < fd_max; i++)
{
- if (!session[i])
+ Session *s2 = session[i].get();
+ if (!s2)
continue;
- dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[i]->session_data.get()));
+ dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
if (pl_sd && pl_sd->state.auth
&& pl_sd->mapname_ == map_name)
{
output = STRPRINTF(
"Player '%s' (session #%d) | Location: %d,%d",
pl_sd->status.name, i, pl_sd->bl_x, pl_sd->bl_y);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
}
}
break;
case 2:
- clif_displaymessage(fd, "----- NPCs in Map -----");
+ clif_displaymessage(s, "----- NPCs in Map -----");
for (int i = 0; i < m_id->npc_num;)
{
nd = m_id->npc[i];
@@ -3518,12 +3535,12 @@ ATCE atcommand_mapinfo(const int fd, dumb_ptr<map_session_data> sd,
"NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
++i, nd->name, direction, nd->npc_class, nd->bl_x,
nd->bl_y);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
}
break;
default:
// normally impossible to arrive here
- clif_displaymessage(fd,
+ clif_displaymessage(s,
"Please, enter at least a valid list number (usage: @mapinfo <0-2> [map]).");
return ATCE::USAGE;
}
@@ -3532,7 +3549,7 @@ ATCE atcommand_mapinfo(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_partyspy(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_partyspy(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
PartyName party_name;
@@ -3549,18 +3566,18 @@ ATCE atcommand_partyspy(const int fd, dumb_ptr<map_session_data> sd,
{
sd->partyspy = 0;
FString output = STRPRINTF("No longer spying on the %s party.", p->name);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
}
else
{
sd->partyspy = p->party_id;
FString output = STRPRINTF("Spying on the %s party.", p->name);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
}
}
else
{
- clif_displaymessage(fd, "Incorrect name or ID, or no one from the party is online.");
+ clif_displaymessage(s, "Incorrect name or ID, or no one from the party is online.");
return ATCE::EXIST;
}
@@ -3568,7 +3585,7 @@ ATCE atcommand_partyspy(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_enablenpc(const int fd, dumb_ptr<map_session_data>,
+ATCE atcommand_enablenpc(Session *s, dumb_ptr<map_session_data>,
ZString message)
{
NpcName NPCname;
@@ -3579,11 +3596,11 @@ ATCE atcommand_enablenpc(const int fd, dumb_ptr<map_session_data>,
if (npc_name2id(NPCname) != NULL)
{
npc_enable(NPCname, 1);
- clif_displaymessage(fd, "Npc Enabled.");
+ clif_displaymessage(s, "Npc Enabled.");
}
else
{
- clif_displaymessage(fd, "This NPC doesn't exist.");
+ clif_displaymessage(s, "This NPC doesn't exist.");
return ATCE::EXIST;
}
@@ -3591,7 +3608,7 @@ ATCE atcommand_enablenpc(const int fd, dumb_ptr<map_session_data>,
}
static
-ATCE atcommand_disablenpc(const int fd, dumb_ptr<map_session_data>,
+ATCE atcommand_disablenpc(Session *s, dumb_ptr<map_session_data>,
ZString message)
{
NpcName NPCname;
@@ -3602,11 +3619,11 @@ ATCE atcommand_disablenpc(const int fd, dumb_ptr<map_session_data>,
if (npc_name2id(NPCname) != NULL)
{
npc_enable(NPCname, 0);
- clif_displaymessage(fd, "Npc Disabled.");
+ clif_displaymessage(s, "Npc Disabled.");
}
else
{
- clif_displaymessage(fd, "This NPC doesn't exist.");
+ clif_displaymessage(s, "This NPC doesn't exist.");
return ATCE::EXIST;
}
@@ -3614,19 +3631,19 @@ ATCE atcommand_disablenpc(const int fd, dumb_ptr<map_session_data>,
}
static
-ATCE atcommand_servertime(const int fd, dumb_ptr<map_session_data>,
+ATCE atcommand_servertime(Session *s, dumb_ptr<map_session_data>,
ZString)
{
timestamp_seconds_buffer tsbuf;
stamp_time(tsbuf);
FString temp = STRPRINTF("Server time: %s", tsbuf);
- clif_displaymessage(fd, temp);
+ clif_displaymessage(s, temp);
return ATCE::OKAY;
}
static
-ATCE atcommand_chardelitem(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_chardelitem(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
CharName character;
@@ -3664,35 +3681,35 @@ ATCE atcommand_chardelitem(const int fd, dumb_ptr<map_session_data> sd,
FString output = STRPRINTF(
"%d item(s) removed by a GM.",
count);
- clif_displaymessage(pl_sd->fd, output);
+ clif_displaymessage(pl_sd->sess, output);
if (number == count)
output = STRPRINTF("%d item(s) removed from the player.", count);
else
output = STRPRINTF("%d item(s) removed. Player had only %d on %d items.", count, count, number);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
}
else
{
- clif_displaymessage(fd, "Character does not have the item.");
+ clif_displaymessage(s, "Character does not have the item.");
return ATCE::EXIST;
}
}
else
{
- clif_displaymessage(fd, "Your GM level don't authorise you to do this action on this player.");
+ clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player.");
return ATCE::PERM;
}
}
else
{
- clif_displaymessage(fd, "Character not found.");
+ clif_displaymessage(s, "Character not found.");
return ATCE::EXIST;
}
}
else
{
- clif_displaymessage(fd, "Invalid item ID or name.");
+ clif_displaymessage(s, "Invalid item ID or name.");
return ATCE::RANGE;
}
@@ -3700,7 +3717,7 @@ ATCE atcommand_chardelitem(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_broadcast(const int, dumb_ptr<map_session_data> sd,
+ATCE atcommand_broadcast(Session *, dumb_ptr<map_session_data> sd,
ZString message)
{
if (!message)
@@ -3713,7 +3730,7 @@ ATCE atcommand_broadcast(const int, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_localbroadcast(const int, dumb_ptr<map_session_data> sd,
+ATCE atcommand_localbroadcast(Session *, dumb_ptr<map_session_data> sd,
ZString message)
{
if (!message)
@@ -3727,7 +3744,7 @@ ATCE atcommand_localbroadcast(const int, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_email(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_email(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
AccountEmail actual_email;
@@ -3738,35 +3755,35 @@ ATCE atcommand_email(const int fd, dumb_ptr<map_session_data> sd,
if (!e_mail_check(actual_email))
{
- clif_displaymessage(fd, "Invalid actual email. If you have default e-mail, type a@a.com.");
+ clif_displaymessage(s, "Invalid actual email. If you have default e-mail, type a@a.com.");
return ATCE::RANGE;
}
else if (!e_mail_check(new_email))
{
- clif_displaymessage(fd, "Invalid new email. Please enter a real e-mail.");
+ clif_displaymessage(s, "Invalid new email. Please enter a real e-mail.");
return ATCE::RANGE;
}
else if (new_email == DEFAULT_EMAIL)
{
- clif_displaymessage(fd, "New email must be a real e-mail.");
+ clif_displaymessage(s, "New email must be a real e-mail.");
return ATCE::RANGE;
}
else if (actual_email == new_email)
{
- clif_displaymessage(fd, "New email must be different of the actual e-mail.");
+ clif_displaymessage(s, "New email must be different of the actual e-mail.");
return ATCE::RANGE;
}
else
{
chrif_changeemail(sd->status.account_id, actual_email, new_email);
- clif_displaymessage(fd, "Information sended to login-server via char-server.");
+ clif_displaymessage(s, "Information sended to login-server via char-server.");
}
return ATCE::OKAY;
}
static
-ATCE atcommand_effect(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_effect(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
int type = 0, flag = 0;
@@ -3776,19 +3793,20 @@ ATCE atcommand_effect(const int fd, dumb_ptr<map_session_data> sd,
if (flag <= 0)
{
clif_specialeffect(sd, type, flag);
- clif_displaymessage(fd, "Your Effect Has Changed.");
+ clif_displaymessage(s, "Your Effect Has Changed.");
}
else
{
for (int i = 0; i < fd_max; i++)
{
- if (!session[i])
+ Session *s2 = session[i].get();
+ if (!s2)
continue;
- dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[i]->session_data.get()));
+ dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
if (pl_sd && pl_sd->state.auth)
{
clif_specialeffect(pl_sd, type, flag);
- clif_displaymessage(pl_sd->fd, "Your Effect Has Changed.");
+ clif_displaymessage(pl_sd->sess, "Your Effect Has Changed.");
}
}
}
@@ -3797,7 +3815,7 @@ ATCE atcommand_effect(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_character_item_list(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_character_item_list(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
struct item_data *item_data = NULL, *item_temp;
@@ -3829,7 +3847,7 @@ ATCE atcommand_character_item_list(const int fd, dumb_ptr<map_session_data> sd,
FString output = STRPRINTF(
"------ Items list of '%s' ------",
pl_sd->status.name);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
}
EPOS equip = pl_sd->status.inventory[i].equip;
MString equipstr;
@@ -3886,7 +3904,7 @@ ATCE atcommand_character_item_list(const int fd, dumb_ptr<map_session_data> sd,
item_data->name, item_data->jname,
pl_sd->status.inventory[i].nameid,
FString(equipstr));
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
MString voutput;
counter2 = 0;
@@ -3920,29 +3938,29 @@ ATCE atcommand_character_item_list(const int fd, dumb_ptr<map_session_data> sd,
// replace trailing ", "
voutput.pop_back();
voutput.back() = ')';
- clif_displaymessage(fd, FString(voutput));
+ clif_displaymessage(s, FString(voutput));
}
}
}
if (count == 0)
- clif_displaymessage(fd, "No item found on this player.");
+ clif_displaymessage(s, "No item found on this player.");
else
{
FString output = STRPRINTF(
"%d item(s) found in %d kind(s) of items.",
counter, count);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
}
}
else
{
- clif_displaymessage(fd, "Your GM level don't authorise you to do this action on this player.");
+ clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player.");
return ATCE::PERM;
}
}
else
{
- clif_displaymessage(fd, "Character not found.");
+ clif_displaymessage(s, "Character not found.");
return ATCE::EXIST;
}
@@ -3950,7 +3968,7 @@ ATCE atcommand_character_item_list(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_character_storage_list(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_character_storage_list(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
struct storage *stor;
@@ -3984,7 +4002,7 @@ ATCE atcommand_character_storage_list(const int fd, dumb_ptr<map_session_data> s
FString output = STRPRINTF(
"------ Storage items list of '%s' ------",
pl_sd->status.name);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
}
FString output;
if (stor->storage_[i].refine)
@@ -4000,7 +4018,7 @@ ATCE atcommand_character_storage_list(const int fd, dumb_ptr<map_session_data> s
stor->storage_[i].amount,
item_data->name, item_data->jname,
stor->storage_[i].nameid);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
MString voutput;
counter2 = 0;
@@ -4034,36 +4052,36 @@ ATCE atcommand_character_storage_list(const int fd, dumb_ptr<map_session_data> s
// replace last ", "
voutput.pop_back();
voutput.back() = ')';
- clif_displaymessage(fd, FString(voutput));
+ clif_displaymessage(s, FString(voutput));
}
}
}
if (count == 0)
- clif_displaymessage(fd,
+ clif_displaymessage(s,
"No item found in the storage of this player.");
else
{
FString output = STRPRINTF(
"%d item(s) found in %d kind(s) of items.",
counter, count);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
}
}
else
{
- clif_displaymessage(fd, "This player has no storage.");
+ clif_displaymessage(s, "This player has no storage.");
return ATCE::OKAY;
}
}
else
{
- clif_displaymessage(fd, "Your GM level don't authorise you to do this action on this player.");
+ clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player.");
return ATCE::PERM;
}
}
else
{
- clif_displaymessage(fd, "Character not found.");
+ clif_displaymessage(s, "Character not found.");
return ATCE::EXIST;
}
@@ -4071,7 +4089,7 @@ ATCE atcommand_character_storage_list(const int fd, dumb_ptr<map_session_data> s
}
static
-ATCE atcommand_character_cart_list(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_character_cart_list(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
struct item_data *item_data = NULL, *item_temp;
@@ -4102,7 +4120,7 @@ ATCE atcommand_character_cart_list(const int fd, dumb_ptr<map_session_data> sd,
FString output = STRPRINTF(
"------ Cart items list of '%s' ------",
pl_sd->status.name);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
}
FString output;
@@ -4120,7 +4138,7 @@ ATCE atcommand_character_cart_list(const int fd, dumb_ptr<map_session_data> sd,
pl_sd->status.cart[i].amount,
item_data->name, item_data->jname,
pl_sd->status.cart[i].nameid);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
MString voutput;
counter2 = 0;
@@ -4152,29 +4170,29 @@ ATCE atcommand_character_cart_list(const int fd, dumb_ptr<map_session_data> sd,
{
voutput.pop_back();
voutput.back() = '0';
- clif_displaymessage(fd, FString(voutput));
+ clif_displaymessage(s, FString(voutput));
}
}
}
if (count == 0)
- clif_displaymessage(fd,
+ clif_displaymessage(s,
"No item found in the cart of this player.");
else
{
FString output = STRPRINTF("%d item(s) found in %d kind(s) of items.",
counter, count);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
}
}
else
{
- clif_displaymessage(fd, "Your GM level don't authorise you to do this action on this player.");
+ clif_displaymessage(s, "Your GM level don't authorise you to do this action on this player.");
return ATCE::PERM;
}
}
else
{
- clif_displaymessage(fd, "Character not found.");
+ clif_displaymessage(s, "Character not found.");
return ATCE::EXIST;
}
@@ -4182,21 +4200,21 @@ ATCE atcommand_character_cart_list(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_killer(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_killer(Session *s, dumb_ptr<map_session_data> sd,
ZString)
{
sd->special_state.killer = !sd->special_state.killer;
if (sd->special_state.killer)
- clif_displaymessage(fd, "You be a killa...");
+ clif_displaymessage(s, "You be a killa...");
else
- clif_displaymessage(fd, "You gonna be own3d...");
+ clif_displaymessage(s, "You gonna be own3d...");
return ATCE::OKAY;
}
static
-ATCE atcommand_charkiller(const int fd, dumb_ptr<map_session_data>,
+ATCE atcommand_charkiller(Session *s, dumb_ptr<map_session_data>,
ZString message)
{
CharName character;
@@ -4212,34 +4230,34 @@ ATCE atcommand_charkiller(const int fd, dumb_ptr<map_session_data>,
if (pl_sd->special_state.killer)
{
- clif_displaymessage(fd, "The player is now a killer");
- clif_displaymessage(pl_sd->fd, "You are now a killer");
+ clif_displaymessage(s, "The player is now a killer");
+ clif_displaymessage(pl_sd->sess, "You are now a killer");
}
else
{
- clif_displaymessage(fd, "The player is no longer a killer");
- clif_displaymessage(pl_sd->fd, "You are no longer a killer");
+ clif_displaymessage(s, "The player is no longer a killer");
+ clif_displaymessage(pl_sd->sess, "You are no longer a killer");
}
return ATCE::OKAY;
}
static
-ATCE atcommand_killable(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_killable(Session *s, dumb_ptr<map_session_data> sd,
ZString)
{
sd->special_state.killable = !sd->special_state.killable;
if (sd->special_state.killable)
- clif_displaymessage(fd, "You gonna be own3d...");
+ clif_displaymessage(s, "You gonna be own3d...");
else
- clif_displaymessage(fd, "You be a killa...");
+ clif_displaymessage(s, "You be a killa...");
return ATCE::OKAY;
}
static
-ATCE atcommand_charkillable(const int fd, dumb_ptr<map_session_data>,
+ATCE atcommand_charkillable(Session *s, dumb_ptr<map_session_data>,
ZString message)
{
CharName character;
@@ -4254,15 +4272,15 @@ ATCE atcommand_charkillable(const int fd, dumb_ptr<map_session_data>,
pl_sd->special_state.killable = !pl_sd->special_state.killable;
if (pl_sd->special_state.killable)
- clif_displaymessage(fd, "The player is now killable");
+ clif_displaymessage(s, "The player is now killable");
else
- clif_displaymessage(fd, "The player is no longer killable");
+ clif_displaymessage(s, "The player is no longer killable");
return ATCE::OKAY;
}
static
-ATCE atcommand_npcmove(const int, dumb_ptr<map_session_data>,
+ATCE atcommand_npcmove(Session *, dumb_ptr<map_session_data>,
ZString message)
{
NpcName character;
@@ -4285,7 +4303,7 @@ ATCE atcommand_npcmove(const int, dumb_ptr<map_session_data>,
}
static
-ATCE atcommand_addwarp(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_addwarp(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
MapName mapname;
@@ -4305,13 +4323,13 @@ ATCE atcommand_addwarp(const int fd, dumb_ptr<map_session_data> sd,
return ATCE::RANGE;
FString output = STRPRINTF("New warp NPC => %s", w3);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
return ATCE::OKAY;
}
static
-ATCE atcommand_chareffect(const int fd, dumb_ptr<map_session_data>,
+ATCE atcommand_chareffect(Session *s, dumb_ptr<map_session_data>,
ZString message)
{
CharName target;
@@ -4325,13 +4343,13 @@ ATCE atcommand_chareffect(const int fd, dumb_ptr<map_session_data>,
return ATCE::EXIST;
clif_specialeffect(pl_sd, type, 0);
- clif_displaymessage(fd, "Your Effect Has Changed.");
+ clif_displaymessage(s, "Your Effect Has Changed.");
return ATCE::OKAY;
}
static
-ATCE atcommand_dropall(const int, dumb_ptr<map_session_data> sd,
+ATCE atcommand_dropall(Session *, dumb_ptr<map_session_data> sd,
ZString)
{
int i;
@@ -4348,7 +4366,7 @@ ATCE atcommand_dropall(const int, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_chardropall(const int fd, dumb_ptr<map_session_data>,
+ATCE atcommand_chardropall(Session *s, dumb_ptr<map_session_data>,
ZString message)
{
CharName character;
@@ -4368,15 +4386,15 @@ ATCE atcommand_chardropall(const int fd, dumb_ptr<map_session_data>,
}
}
- clif_displaymessage(pl_sd->fd, "Ever play 52 card pickup?");
- clif_displaymessage(fd, "It is done");
- //clif_displaymessage(fd, "It is offical.. your a jerk");
+ clif_displaymessage(pl_sd->sess, "Ever play 52 card pickup?");
+ clif_displaymessage(s, "It is done");
+ //clif_displaymessage(s, "It is offical.. your a jerk");
return ATCE::OKAY;
}
static
-ATCE atcommand_storeall(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_storeall(Session *s, dumb_ptr<map_session_data> sd,
ZString)
{
int i;
@@ -4388,11 +4406,11 @@ ATCE atcommand_storeall(const int fd, dumb_ptr<map_session_data> sd,
{
case 2:
//Try again
- clif_displaymessage(fd, "run this command again..");
+ clif_displaymessage(s, "run this command again..");
return ATCE::OKAY;
case 1:
//Failure
- clif_displaymessage(fd,
+ clif_displaymessage(s,
"You can't open the storage currently.");
return ATCE::EXIST;
}
@@ -4408,12 +4426,12 @@ ATCE atcommand_storeall(const int fd, dumb_ptr<map_session_data> sd,
}
storage_storageclose(sd);
- clif_displaymessage(fd, "It is done");
+ clif_displaymessage(s, "It is done");
return ATCE::OKAY;
}
static
-ATCE atcommand_charstoreall(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_charstoreall(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
CharName character;
@@ -4428,9 +4446,9 @@ ATCE atcommand_charstoreall(const int fd, dumb_ptr<map_session_data> sd,
{
// TODO figure out what the hell this is talking about,
// and especially why it's different from the other one.
- clif_displaymessage(fd,
+ clif_displaymessage(s,
"Had to open the characters storage window...");
- clif_displaymessage(fd, "run this command again..");
+ clif_displaymessage(s, "run this command again..");
return ATCE::OKAY;
}
for (int i = 0; i < MAX_INVENTORY; i++)
@@ -4444,19 +4462,19 @@ ATCE atcommand_charstoreall(const int fd, dumb_ptr<map_session_data> sd,
}
storage_storageclose(pl_sd);
- clif_displaymessage(pl_sd->fd,
+ clif_displaymessage(pl_sd->sess,
"Everything you own has been put away for safe keeping.");
- clif_displaymessage(pl_sd->fd,
+ clif_displaymessage(pl_sd->sess,
"go to the nearest kafka to retrieve it..");
- clif_displaymessage(pl_sd->fd, " -- the management");
+ clif_displaymessage(pl_sd->sess, " -- the management");
- clif_displaymessage(fd, "It is done");
+ clif_displaymessage(s, "It is done");
return ATCE::OKAY;
}
static
-ATCE atcommand_rain(const int, dumb_ptr<map_session_data> sd,
+ATCE atcommand_rain(Session *, dumb_ptr<map_session_data> sd,
ZString)
{
int effno = 0;
@@ -4470,7 +4488,7 @@ ATCE atcommand_rain(const int, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_snow(const int, dumb_ptr<map_session_data> sd,
+ATCE atcommand_snow(Session *, dumb_ptr<map_session_data> sd,
ZString)
{
int effno = 0;
@@ -4484,7 +4502,7 @@ ATCE atcommand_snow(const int, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_sakura(const int, dumb_ptr<map_session_data> sd,
+ATCE atcommand_sakura(Session *, dumb_ptr<map_session_data> sd,
ZString)
{
int effno = 0;
@@ -4498,7 +4516,7 @@ ATCE atcommand_sakura(const int, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_fog(const int, dumb_ptr<map_session_data> sd,
+ATCE atcommand_fog(Session *, dumb_ptr<map_session_data> sd,
ZString)
{
int effno = 0;
@@ -4513,7 +4531,7 @@ ATCE atcommand_fog(const int, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_leaves(const int, dumb_ptr<map_session_data> sd,
+ATCE atcommand_leaves(Session *, dumb_ptr<map_session_data> sd,
ZString)
{
int effno = 0;
@@ -4527,7 +4545,7 @@ ATCE atcommand_leaves(const int, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_summon(const int, dumb_ptr<map_session_data> sd,
+ATCE atcommand_summon(Session *, dumb_ptr<map_session_data> sd,
ZString message)
{
MobName name;
@@ -4565,7 +4583,7 @@ ATCE atcommand_summon(const int, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_adjcmdlvl(const int fd, dumb_ptr<map_session_data>,
+ATCE atcommand_adjcmdlvl(Session *s, dumb_ptr<map_session_data>,
ZString message)
{
int newlev;
@@ -4573,7 +4591,7 @@ ATCE atcommand_adjcmdlvl(const int fd, dumb_ptr<map_session_data>,
if (!extract(message, record<' '>(&newlev, &cmd)))
{
- clif_displaymessage(fd, "usage: @adjcmdlvl <lvl> <command>.");
+ clif_displaymessage(s, "usage: @adjcmdlvl <lvl> <command>.");
return ATCE::USAGE;
}
@@ -4582,17 +4600,17 @@ ATCE atcommand_adjcmdlvl(const int fd, dumb_ptr<map_session_data>,
if (it)
{
it->level = newlev;
- clif_displaymessage(fd, "@command level changed.");
+ clif_displaymessage(s, "@command level changed.");
return ATCE::OKAY;
}
}
- clif_displaymessage(fd, "@command not found.");
+ clif_displaymessage(s, "@command not found.");
return ATCE::EXIST;
}
static
-ATCE atcommand_adjgmlvl(const int fd, dumb_ptr<map_session_data>,
+ATCE atcommand_adjgmlvl(Session *s, dumb_ptr<map_session_data>,
ZString message)
{
int newlev;
@@ -4601,7 +4619,7 @@ ATCE atcommand_adjgmlvl(const int fd, dumb_ptr<map_session_data>,
if (!asplit(message, &newlev, &user)
|| newlev < 0 || newlev > 99)
{
- clif_displaymessage(fd, "usage: @adjgmlvl <lvl> <user>.");
+ clif_displaymessage(s, "usage: @adjgmlvl <lvl> <user>.");
return ATCE::USAGE;
}
@@ -4615,7 +4633,7 @@ ATCE atcommand_adjgmlvl(const int fd, dumb_ptr<map_session_data>,
}
static
-ATCE atcommand_trade(const int, dumb_ptr<map_session_data> sd,
+ATCE atcommand_trade(Session *, dumb_ptr<map_session_data> sd,
ZString message)
{
CharName character;
@@ -4660,7 +4678,7 @@ ZString magic_skill_names[magic_skills_nr] =
};
static
-ATCE atcommand_magic_info(const int fd, dumb_ptr<map_session_data>,
+ATCE atcommand_magic_info(Session *s, dumb_ptr<map_session_data>,
ZString message)
{
CharName character;
@@ -4674,7 +4692,7 @@ ATCE atcommand_magic_info(const int fd, dumb_ptr<map_session_data>,
FString buf = STRPRINTF(
"`%s' has the following magic skills:",
character);
- clif_displaymessage(fd, buf);
+ clif_displaymessage(s, buf);
for (size_t i = 0; i < magic_skills_nr; i++)
{
@@ -4684,13 +4702,13 @@ ATCE atcommand_magic_info(const int fd, dumb_ptr<map_session_data>,
pl_sd->status.skill[sk].lv,
magic_skill_names[i]);
if (pl_sd->status.skill[sk].lv)
- clif_displaymessage(fd, buf);
+ clif_displaymessage(s, buf);
}
return ATCE::OKAY;
}
- clif_displaymessage(fd, "Character not found.");
+ clif_displaymessage(s, "Character not found.");
return ATCE::EXIST;
}
@@ -4701,7 +4719,7 @@ void set_skill(dumb_ptr<map_session_data> sd, SkillID i, int level)
}
static
-ATCE atcommand_set_magic(const int fd, dumb_ptr<map_session_data>,
+ATCE atcommand_set_magic(Session *s, dumb_ptr<map_session_data>,
ZString message)
{
CharName character;
@@ -4710,7 +4728,7 @@ ATCE atcommand_set_magic(const int fd, dumb_ptr<map_session_data>,
if (!asplit(message, &magic_type, &value, &character))
{
- clif_displaymessage(fd,
+ clif_displaymessage(s,
"Usage: @setmagic <school> <value> <char-name>, where <school> is either `magic', one of the school names, or `all'.");
return ATCE::USAGE;
}
@@ -4732,7 +4750,7 @@ ATCE atcommand_set_magic(const int fd, dumb_ptr<map_session_data>,
if (skill_index == SkillID::NEGATIVE)
{
- clif_displaymessage(fd,
+ clif_displaymessage(s,
"Incorrect school of magic. Use `magic', `nature', `life', `war', `transmute', `ether', or `all'.");
return ATCE::RANGE;
}
@@ -4750,12 +4768,12 @@ ATCE atcommand_set_magic(const int fd, dumb_ptr<map_session_data>,
return ATCE::OKAY;
}
- clif_displaymessage(fd, "Character not found.");
+ clif_displaymessage(s, "Character not found.");
return ATCE::EXIST;
}
static
-ATCE atcommand_log(const int, dumb_ptr<map_session_data>,
+ATCE atcommand_log(Session *, dumb_ptr<map_session_data>,
ZString)
{
return ATCE::OKAY;
@@ -4763,7 +4781,7 @@ ATCE atcommand_log(const int, dumb_ptr<map_session_data>,
}
static
-ATCE atcommand_tee(const int, dumb_ptr<map_session_data> sd,
+ATCE atcommand_tee(Session *, dumb_ptr<map_session_data> sd,
ZString message)
{
MString data;
@@ -4775,7 +4793,7 @@ ATCE atcommand_tee(const int, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_invisible(const int, dumb_ptr<map_session_data> sd,
+ATCE atcommand_invisible(Session *, dumb_ptr<map_session_data> sd,
ZString)
{
pc_invisibility(sd, 1);
@@ -4783,7 +4801,7 @@ ATCE atcommand_invisible(const int, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_visible(const int, dumb_ptr<map_session_data> sd,
+ATCE atcommand_visible(Session *, dumb_ptr<map_session_data> sd,
ZString)
{
pc_invisibility(sd, 0);
@@ -4791,7 +4809,7 @@ ATCE atcommand_visible(const int, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_jump_iterate(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_jump_iterate(Session *s, dumb_ptr<map_session_data> sd,
dumb_ptr<map_session_data> (*get_start)(void),
dumb_ptr<map_session_data> (*get_next)(dumb_ptr<map_session_data>))
{
@@ -4815,20 +4833,20 @@ ATCE atcommand_jump_iterate(const int fd, dumb_ptr<map_session_data> sd,
if (pl_sd->bl_m && pl_sd->bl_m->flag.nowarpto
&& battle_config.any_warp_GM_min_level > pc_isGM(sd))
{
- clif_displaymessage(fd,
+ clif_displaymessage(s,
"You are not authorised to warp you to the map of this player.");
return ATCE::PERM;
}
if (sd->bl_m && sd->bl_m->flag.nowarp
&& battle_config.any_warp_GM_min_level > pc_isGM(sd))
{
- clif_displaymessage(fd,
+ clif_displaymessage(s,
"You are not authorised to warp you from your actual map.");
return ATCE::PERM;
}
pc_setpos(sd, pl_sd->bl_m->name_, pl_sd->bl_x, pl_sd->bl_y, BeingRemoveWhy::WARPED);
FString output = STRPRINTF("Jump to %s", pl_sd->status.name);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
sd->followtarget = pl_sd->bl_id;
@@ -4836,19 +4854,19 @@ ATCE atcommand_jump_iterate(const int fd, dumb_ptr<map_session_data> sd,
}
static
-ATCE atcommand_iterate_forward_over_players(const int fd, dumb_ptr<map_session_data> sd, ZString)
+ATCE atcommand_iterate_forward_over_players(Session *s, dumb_ptr<map_session_data> sd, ZString)
{
- return atcommand_jump_iterate(fd, sd, map_get_first_session, map_get_next_session);
+ return atcommand_jump_iterate(s, sd, map_get_first_session, map_get_next_session);
}
static
-ATCE atcommand_iterate_backwards_over_players(const int fd, dumb_ptr<map_session_data> sd, ZString)
+ATCE atcommand_iterate_backwards_over_players(Session *s, dumb_ptr<map_session_data> sd, ZString)
{
- return atcommand_jump_iterate(fd, sd, map_get_last_session, map_get_prev_session);
+ return atcommand_jump_iterate(s, sd, map_get_last_session, map_get_prev_session);
}
static
-ATCE atcommand_wgm(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_wgm(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
if (tmw_CheckChatSpam(sd, message))
@@ -4856,14 +4874,14 @@ ATCE atcommand_wgm(const int fd, dumb_ptr<map_session_data> sd,
tmw_GmHackMsg(STRPRINTF("[GM] %s: %s", sd->status.name, message));
if (!pc_isGM(sd))
- clif_displaymessage(fd, "Message sent.");
+ clif_displaymessage(s, "Message sent.");
return ATCE::OKAY;
}
static
-ATCE atcommand_skillpool_info(const int fd, dumb_ptr<map_session_data>,
+ATCE atcommand_skillpool_info(Session *s, dumb_ptr<map_session_data>,
ZString message)
{
CharName character;
@@ -4881,19 +4899,19 @@ ATCE atcommand_skillpool_info(const int fd, dumb_ptr<map_session_data>,
FString buf = STRPRINTF(
"Active skills %d out of %d for %s:",
pool_skills_nr, skill_pool_max(pl_sd), character);
- clif_displaymessage(fd, buf);
+ clif_displaymessage(s, buf);
for (i = 0; i < pool_skills_nr; ++i)
{
buf = STRPRINTF(" - %s [%d]: power %d",
skill_name(pool_skills[i]),
pool_skills[i],
skill_power(pl_sd, pool_skills[i]));
- clif_displaymessage(fd, buf);
+ clif_displaymessage(s, buf);
}
buf = STRPRINTF("Learned skills out of %d for %s:",
skill_pool_skills_size, character);
- clif_displaymessage(fd, buf);
+ clif_displaymessage(s, buf);
for (i = 0; i < skill_pool_skills_size; ++i)
{
@@ -4904,14 +4922,14 @@ ATCE atcommand_skillpool_info(const int fd, dumb_ptr<map_session_data>,
{
buf = STRPRINTF(" - %s [%d]: lvl %d",
name, skill_pool_skills[i], lvl);
- clif_displaymessage(fd, buf);
+ clif_displaymessage(s, buf);
}
}
}
else
{
- clif_displaymessage(fd, "Character not found.");
+ clif_displaymessage(s, "Character not found.");
return ATCE::EXIST;
}
@@ -4919,7 +4937,7 @@ ATCE atcommand_skillpool_info(const int fd, dumb_ptr<map_session_data>,
}
static
-ATCE atcommand_skillpool_focus(const int fd, dumb_ptr<map_session_data>,
+ATCE atcommand_skillpool_focus(Session *s, dumb_ptr<map_session_data>,
ZString message)
{
CharName character;
@@ -4927,7 +4945,7 @@ ATCE atcommand_skillpool_focus(const int fd, dumb_ptr<map_session_data>,
if (!asplit(message, &skill, &character))
{
- clif_displaymessage(fd, "Usage: @sp-focus <skill-nr> <char_name>");
+ clif_displaymessage(s, "Usage: @sp-focus <skill-nr> <char_name>");
return ATCE::USAGE;
}
@@ -4935,18 +4953,18 @@ ATCE atcommand_skillpool_focus(const int fd, dumb_ptr<map_session_data>,
if (pl_sd != NULL)
{
if (skill_pool_activate(pl_sd, skill))
- clif_displaymessage(fd, "Activation failed.");
+ clif_displaymessage(s, "Activation failed.");
else
- clif_displaymessage(fd, "Activation successful.");
+ clif_displaymessage(s, "Activation successful.");
}
else
- clif_displaymessage(fd, "Character not found.");
+ clif_displaymessage(s, "Character not found.");
return ATCE::OKAY;
}
static
-ATCE atcommand_skillpool_unfocus(const int fd, dumb_ptr<map_session_data>,
+ATCE atcommand_skillpool_unfocus(Session *s, dumb_ptr<map_session_data>,
ZString message)
{
CharName character;
@@ -4959,18 +4977,18 @@ ATCE atcommand_skillpool_unfocus(const int fd, dumb_ptr<map_session_data>,
if (pl_sd != NULL)
{
if (skill_pool_deactivate(pl_sd, skill))
- clif_displaymessage(fd, "Deactivation failed.");
+ clif_displaymessage(s, "Deactivation failed.");
else
- clif_displaymessage(fd, "Deactivation successful.");
+ clif_displaymessage(s, "Deactivation successful.");
}
else
- clif_displaymessage(fd, "Character not found.");
+ clif_displaymessage(s, "Character not found.");
return ATCE::OKAY;
}
//static
-ATCE atcommand_skill_learn(const int fd, dumb_ptr<map_session_data>,
+ATCE atcommand_skill_learn(Session *s, dumb_ptr<map_session_data>,
ZString message)
{
CharName character;
@@ -4987,13 +5005,13 @@ ATCE atcommand_skill_learn(const int fd, dumb_ptr<map_session_data>,
clif_skillinfoblock(pl_sd);
}
else
- clif_displaymessage(fd, "Character not found.");
+ clif_displaymessage(s, "Character not found.");
return ATCE::OKAY;
}
static
-ATCE atcommand_ipcheck(const int fd, dumb_ptr<map_session_data>,
+ATCE atcommand_ipcheck(Session *s, dumb_ptr<map_session_data>,
ZString message)
{
CharName character;
@@ -5004,7 +5022,7 @@ ATCE atcommand_ipcheck(const int fd, dumb_ptr<map_session_data>,
dumb_ptr<map_session_data> pl_sd = map_nick2sd(character);
if (pl_sd == NULL)
{
- clif_displaymessage(fd, "Character not found.");
+ clif_displaymessage(s, "Character not found.");
return ATCE::EXIST;
}
@@ -5015,9 +5033,10 @@ ATCE atcommand_ipcheck(const int fd, dumb_ptr<map_session_data>,
for (int i = 0; i < fd_max; i++)
{
- if (!session[i])
+ Session *s2 = session[i].get();
+ if (!s2)
continue;
- pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[i]->session_data.get()));
+ pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
if (pl_sd && pl_sd->state.auth)
{
// Is checking GM levels really needed here?
@@ -5027,35 +5046,36 @@ ATCE atcommand_ipcheck(const int fd, dumb_ptr<map_session_data>,
"Name: %s | Location: %s %d %d",
pl_sd->status.name, pl_sd->mapname_,
pl_sd->bl_x, pl_sd->bl_y);
- clif_displaymessage(fd, output);
+ clif_displaymessage(s, output);
}
}
}
- clif_displaymessage(fd, "End of list");
+ clif_displaymessage(s, "End of list");
return ATCE::OKAY;
}
static
-ATCE atcommand_doomspot(const int fd, dumb_ptr<map_session_data> sd,
+ATCE atcommand_doomspot(Session *s, dumb_ptr<map_session_data> sd,
ZString)
{
for (int i = 0; i < fd_max; i++)
{
- if (!session[i])
+ Session *s2 = session[i].get();
+ if (!s2)
continue;
- dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[i]->session_data.get()));
+ dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
if (pl_sd
- && pl_sd->state.auth && i != fd && sd->bl_m == pl_sd->bl_m
+ && pl_sd->state.auth && s2 != s && sd->bl_m == pl_sd->bl_m
&& sd->bl_x == pl_sd->bl_x && sd->bl_y == pl_sd->bl_y
&& pc_isGM(sd) >= pc_isGM(pl_sd))
{
// you can doom only lower or same gm level
pc_damage(NULL, pl_sd, pl_sd->status.hp + 1);
- clif_displaymessage(pl_sd->fd, "The holy messenger has given judgement.");
+ clif_displaymessage(pl_sd->sess, "The holy messenger has given judgement.");
}
}
- clif_displaymessage(fd, "Judgement was made.");
+ clif_displaymessage(s, "Judgement was made.");
return ATCE::OKAY;
}
diff --git a/src/map/atcommand.hpp b/src/map/atcommand.hpp
index b494a25..a18b035 100644
--- a/src/map/atcommand.hpp
+++ b/src/map/atcommand.hpp
@@ -7,7 +7,7 @@
# include "map.hpp"
-bool is_atcommand(const int fd, dumb_ptr<map_session_data> sd,
+bool is_atcommand(Session *s, dumb_ptr<map_session_data> sd,
ZString message, int gmlvl);
bool atcommand_config_read(ZString cfgName);
diff --git a/src/map/chrif.cpp b/src/map/chrif.cpp
index 5b9f96f..959186c 100644
--- a/src/map/chrif.cpp
+++ b/src/map/chrif.cpp
@@ -34,7 +34,7 @@ const int packet_len_table[0x20] =
-1, -1, 10, 6, 11, -1, 0, 0, // 2b10-2b17
};
-int char_fd;
+Session *char_session;
static
IP4Address char_ip;
static
@@ -105,17 +105,17 @@ int chrif_save(dumb_ptr<map_session_data> sd)
{
nullpo_retr(-1, sd);
- if (char_fd < 0)
+ if (!char_session)
return -1;
pc_makesavestatus(sd);
- WFIFOW(char_fd, 0) = 0x2b01;
- WFIFOW(char_fd, 2) = sizeof(sd->status) + 12;
- WFIFOL(char_fd, 4) = sd->bl_id;
- WFIFOL(char_fd, 8) = sd->char_id;
- WFIFO_STRUCT(char_fd, 12, sd->status);
- WFIFOSET(char_fd, WFIFOW(char_fd, 2));
+ WFIFOW(char_session, 0) = 0x2b01;
+ WFIFOW(char_session, 2) = sizeof(sd->status) + 12;
+ WFIFOL(char_session, 4) = sd->bl_id;
+ WFIFOL(char_session, 8) = sd->char_id;
+ WFIFO_STRUCT(char_session, 12, sd->status);
+ WFIFOSET(char_session, WFIFOW(char_session, 2));
//For data sync
if (sd->state.storage_open)
@@ -129,15 +129,15 @@ int chrif_save(dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-int chrif_connect(int fd)
+int chrif_connect(Session *s)
{
- WFIFOW(fd, 0) = 0x2af8;
- WFIFO_STRING(fd, 2, userid, 24);
- WFIFO_STRING(fd, 26, passwd, 24);
- WFIFOL(fd, 50) = 0;
- WFIFOIP(fd, 54) = clif_getip();
- WFIFOW(fd, 58) = clif_getport(); // [Valaris] thanks to fov
- WFIFOSET(fd, 60);
+ WFIFOW(s, 0) = 0x2af8;
+ WFIFO_STRING(s, 2, userid, 24);
+ WFIFO_STRING(s, 26, passwd, 24);
+ WFIFOL(s, 50) = 0;
+ WFIFOIP(s, 54) = clif_getip();
+ WFIFOW(s, 58) = clif_getport(); // [Valaris] thanks to fov
+ WFIFOSET(s, 60);
return 0;
}
@@ -147,21 +147,21 @@ int chrif_connect(int fd)
*------------------------------------------
*/
static
-int chrif_sendmap(int fd)
+int chrif_sendmap(Session *s)
{
int i = 0;
- WFIFOW(fd, 0) = 0x2afa;
+ WFIFOW(s, 0) = 0x2afa;
for (auto& pair : maps_db)
{
map_abstract *ma = pair.second.get();
if (!ma->gat)
continue;
- WFIFO_STRING(fd, 4 + i * 16, ma->name_, 16);
+ WFIFO_STRING(s, 4 + i * 16, ma->name_, 16);
i++;
}
- WFIFOW(fd, 2) = 4 + i * 16;
- WFIFOSET(fd, WFIFOW(fd, 2));
+ WFIFOW(s, 2) = 4 + i * 16;
+ WFIFOSET(s, WFIFOW(s, 2));
return 0;
}
@@ -171,18 +171,18 @@ int chrif_sendmap(int fd)
*------------------------------------------
*/
static
-int chrif_recvmap(int fd)
+int chrif_recvmap(Session *s)
{
int i, j;
if (chrif_state < 2) // まだ準備中
return -1;
- IP4Address ip = RFIFOIP(fd, 4);
- uint16_t port = RFIFOW(fd, 8);
- for (i = 10, j = 0; i < RFIFOW(fd, 2); i += 16, j++)
+ IP4Address ip = RFIFOIP(s, 4);
+ uint16_t port = RFIFOW(s, 8);
+ for (i = 10, j = 0; i < RFIFOW(s, 2); i += 16, j++)
{
- MapName map = RFIFO_STRING<16>(fd, i);
+ MapName map = RFIFO_STRING<16>(s, i);
map_setipport(map, ip, port);
}
if (battle_config.etc_log)
@@ -203,26 +203,31 @@ int chrif_changemapserver(dumb_ptr<map_session_data> sd,
IP4Address s_ip;
for (int i = 0; i < fd_max; i++)
- if (session[i] && dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[i]->session_data.get())) == sd)
+ {
+ Session *s = session[i].get();
+ if (!s)
+ continue;
+ if (dumb_ptr<map_session_data>(static_cast<map_session_data *>(s->session_data.get())) == sd)
{
- assert (i == sd->fd);
+ assert (s == sd->sess);
s_ip = session[i]->client_ip;
break;
}
+ }
- WFIFOW(char_fd, 0) = 0x2b05;
- WFIFOL(char_fd, 2) = sd->bl_id;
- WFIFOL(char_fd, 6) = sd->login_id1;
- WFIFOL(char_fd, 10) = sd->login_id2;
- WFIFOL(char_fd, 14) = sd->status.char_id;
- WFIFO_STRING(char_fd, 18, name, 16);
- WFIFOW(char_fd, 34) = x;
- WFIFOW(char_fd, 36) = y;
- WFIFOIP(char_fd, 38) = ip;
- WFIFOL(char_fd, 42) = port;
- WFIFOB(char_fd, 44) = static_cast<uint8_t>(sd->status.sex);
- WFIFOIP(char_fd, 45) = s_ip;
- WFIFOSET(char_fd, 49);
+ WFIFOW(char_session, 0) = 0x2b05;
+ WFIFOL(char_session, 2) = sd->bl_id;
+ WFIFOL(char_session, 6) = sd->login_id1;
+ WFIFOL(char_session, 10) = sd->login_id2;
+ WFIFOL(char_session, 14) = sd->status.char_id;
+ WFIFO_STRING(char_session, 18, name, 16);
+ WFIFOW(char_session, 34) = x;
+ WFIFOW(char_session, 36) = y;
+ WFIFOIP(char_session, 38) = ip;
+ WFIFOL(char_session, 42) = port;
+ WFIFOB(char_session, 44) = static_cast<uint8_t>(sd->status.sex);
+ WFIFOIP(char_session, 45) = s_ip;
+ WFIFOSET(char_session, 49);
return 0;
}
@@ -232,25 +237,25 @@ int chrif_changemapserver(dumb_ptr<map_session_data> sd,
*------------------------------------------
*/
static
-int chrif_changemapserverack(int fd)
+int chrif_changemapserverack(Session *s)
{
- dumb_ptr<map_session_data> sd = map_id2sd(RFIFOL(fd, 2));
+ dumb_ptr<map_session_data> sd = map_id2sd(RFIFOL(s, 2));
- if (sd == NULL || sd->status.char_id != RFIFOL(fd, 14))
+ if (sd == NULL || sd->status.char_id != RFIFOL(s, 14))
return -1;
- if (RFIFOL(fd, 6) == 1)
+ if (RFIFOL(s, 6) == 1)
{
if (battle_config.error_log)
PRINTF("map server change failed.\n");
- pc_authfail(sd->fd);
+ pc_authfail(sd->status.account_id);
return 0;
}
- MapName mapname = RFIFO_STRING<16>(fd, 18);
- uint16_t x = RFIFOW(fd, 34);
- uint16_t y = RFIFOW(fd, 36);
- IP4Address ip = RFIFOIP(fd, 38);
- uint16_t port = RFIFOW(fd, 42);
+ MapName mapname = RFIFO_STRING<16>(s, 18);
+ uint16_t x = RFIFOW(s, 34);
+ uint16_t y = RFIFOW(s, 36);
+ IP4Address ip = RFIFOIP(s, 38);
+ uint16_t port = RFIFOW(s, 42);
clif_changemapserver(sd, mapname, x, y, ip, port);
return 0;
@@ -261,17 +266,17 @@ int chrif_changemapserverack(int fd)
*------------------------------------------
*/
static
-int chrif_connectack(int fd)
+int chrif_connectack(Session *s)
{
- if (RFIFOB(fd, 2))
+ if (RFIFOB(s, 2))
{
- PRINTF("Connected to char-server failed %d.\n", RFIFOB(fd, 2));
+ PRINTF("Connected to char-server failed %d.\n", RFIFOB(s, 2));
exit(1);
}
- PRINTF("Connected to char-server (connection #%d).\n", fd);
+ PRINTF("Connected to char-server (connection #%d).\n", s);
chrif_state = 1;
- chrif_sendmap(fd);
+ chrif_sendmap(s);
PRINTF("chrif: OnCharIfInit event done. (%d events)\n",
npc_event_doall(stringish<ScriptLabel>("OnCharIfInit")));
@@ -289,16 +294,16 @@ int chrif_connectack(int fd)
*------------------------------------------
*/
static
-int chrif_sendmapack(int fd)
+int chrif_sendmapack(Session *s)
{
- if (RFIFOB(fd, 2))
+ if (RFIFOB(s, 2))
{
PRINTF("chrif : send map list to char server failed %d\n",
- RFIFOB(fd, 2));
+ RFIFOB(s, 2));
exit(1);
}
- wisp_server_name = stringish<CharName>(RFIFO_STRING<24>(fd, 3));
+ wisp_server_name = stringish<CharName>(RFIFO_STRING<24>(s, 3));
chrif_state = 2;
@@ -313,22 +318,27 @@ int chrif_authreq(dumb_ptr<map_session_data> sd)
{
nullpo_retr(-1, sd);
- if (!sd || !char_fd || !sd->bl_id || !sd->login_id1)
+ if (!sd || !char_session || !sd->bl_id || !sd->login_id1)
return -1;
for (int i = 0; i < fd_max; i++)
- if (session[i] && dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[i]->session_data.get())) == sd)
+ {
+ Session *s = session[i].get();
+ if (!s)
+ continue;
+ if (dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[i]->session_data.get())) == sd)
{
- assert (i == sd->fd);
- WFIFOW(char_fd, 0) = 0x2afc;
- WFIFOL(char_fd, 2) = sd->bl_id;
- WFIFOL(char_fd, 6) = sd->char_id;
- WFIFOL(char_fd, 10) = sd->login_id1;
- WFIFOL(char_fd, 14) = sd->login_id2;
- WFIFOIP(char_fd, 18) = session[i]->client_ip;
- WFIFOSET(char_fd, 22);
+ assert (s == sd->sess);
+ WFIFOW(char_session, 0) = 0x2afc;
+ WFIFOL(char_session, 2) = sd->bl_id;
+ WFIFOL(char_session, 6) = sd->char_id;
+ WFIFOL(char_session, 10) = sd->login_id1;
+ WFIFOL(char_session, 14) = sd->login_id2;
+ WFIFOIP(char_session, 18) = session[i]->client_ip;
+ WFIFOSET(char_session, 22);
break;
}
+ }
return 0;
}
@@ -341,24 +351,29 @@ int chrif_charselectreq(dumb_ptr<map_session_data> sd)
{
nullpo_retr(-1, sd);
- if (!sd || !char_fd || !sd->bl_id || !sd->login_id1)
+ if (!sd || !char_session || !sd->bl_id || !sd->login_id1)
return -1;
IP4Address s_ip;
for (int i = 0; i < fd_max; i++)
- if (session[i] && dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[i]->session_data.get())) == sd)
+ {
+ Session *s = session[i].get();
+ if (!s)
+ continue;
+ if (dumb_ptr<map_session_data>(static_cast<map_session_data *>(s->session_data.get())) == sd)
{
- assert (i == sd->fd);
- s_ip = session[i]->client_ip;
+ assert (s == sd->sess);
+ s_ip = s->client_ip;
break;
}
+ }
- WFIFOW(char_fd, 0) = 0x2b02;
- WFIFOL(char_fd, 2) = sd->bl_id;
- WFIFOL(char_fd, 6) = sd->login_id1;
- WFIFOL(char_fd, 10) = sd->login_id2;
- WFIFOIP(char_fd, 14) = s_ip;
- WFIFOSET(char_fd, 18);
+ WFIFOW(char_session, 0) = 0x2b02;
+ WFIFOL(char_session, 2) = sd->bl_id;
+ WFIFOL(char_session, 6) = sd->login_id1;
+ WFIFOL(char_session, 10) = sd->login_id2;
+ WFIFOIP(char_session, 14) = s_ip;
+ WFIFOSET(char_session, 18);
return 0;
}
@@ -373,11 +388,11 @@ void chrif_changegm(int id, ZString pass)
PRINTF("chrif_changegm: account: %d, password: '%s'.\n", id, pass);
size_t len = pass.size() + 1;
- WFIFOW(char_fd, 0) = 0x2b0a;
- WFIFOW(char_fd, 2) = len + 8;
- WFIFOL(char_fd, 4) = id;
- WFIFO_STRING(char_fd, 8, pass, len);
- WFIFOSET(char_fd, len + 8);
+ WFIFOW(char_session, 0) = 0x2b0a;
+ WFIFOW(char_session, 2) = len + 8;
+ WFIFOL(char_session, 4) = id;
+ WFIFO_STRING(char_session, 8, pass, len);
+ WFIFOSET(char_session, len + 8);
}
/*==========================================
@@ -391,11 +406,11 @@ void chrif_changeemail(int id, AccountEmail actual_email,
PRINTF("chrif_changeemail: account: %d, actual_email: '%s', new_email: '%s'.\n",
id, actual_email, new_email);
- WFIFOW(char_fd, 0) = 0x2b0c;
- WFIFOL(char_fd, 2) = id;
- WFIFO_STRING(char_fd, 6, actual_email, 40);
- WFIFO_STRING(char_fd, 46, new_email, 40);
- WFIFOSET(char_fd, 86);
+ WFIFOW(char_session, 0) = 0x2b0c;
+ WFIFOL(char_session, 2) = id;
+ WFIFO_STRING(char_session, 6, actual_email, 40);
+ WFIFO_STRING(char_session, 46, new_email, 40);
+ WFIFOSET(char_session, 86);
}
/*==========================================
@@ -412,14 +427,14 @@ void chrif_changeemail(int id, AccountEmail actual_email,
void chrif_char_ask_name(int id, CharName character_name, short operation_type,
HumanTimeDiff modif)
{
- WFIFOW(char_fd, 0) = 0x2b0e;
- WFIFOL(char_fd, 2) = id; // account_id of who ask (for answer) -1 if nobody
- WFIFO_STRING(char_fd, 6, character_name.to__actual(), 24);
- WFIFOW(char_fd, 30) = operation_type; // type of operation
+ WFIFOW(char_session, 0) = 0x2b0e;
+ WFIFOL(char_session, 2) = id; // account_id of who ask (for answer) -1 if nobody
+ WFIFO_STRING(char_session, 6, character_name.to__actual(), 24);
+ WFIFOW(char_session, 30) = operation_type; // type of operation
if (operation_type == 2)
- WFIFO_STRUCT(char_fd, 32, modif);
+ WFIFO_STRUCT(char_session, 32, modif);
PRINTF("chrif : sended 0x2b0e\n");
- WFIFOSET(char_fd, 44);
+ WFIFOSET(char_session, 44);
}
/*==========================================
@@ -439,24 +454,24 @@ void chrif_char_ask_name(int id, CharName character_name, short operation_type,
*------------------------------------------
*/
static
-int chrif_char_ask_name_answer(int fd)
+int chrif_char_ask_name_answer(Session *s)
{
- int acc = RFIFOL(fd, 2); // account_id of who has asked (-1 if nobody)
- CharName player_name = stringish<CharName>(RFIFO_STRING<24>(fd, 6));
+ int acc = RFIFOL(s, 2); // account_id of who has asked (-1 if nobody)
+ CharName player_name = stringish<CharName>(RFIFO_STRING<24>(s, 6));
dumb_ptr<map_session_data> sd = map_id2sd(acc);
if (acc >= 0 && sd != NULL)
{
FString output;
- if (RFIFOW(fd, 32) == 1) // player not found
+ if (RFIFOW(s, 32) == 1) // player not found
output = STRPRINTF("The player '%s' doesn't exist.",
player_name);
else
{
- switch (RFIFOW(fd, 30))
+ switch (RFIFOW(s, 30))
{
case 1: // block
- switch (RFIFOW(fd, 32))
+ switch (RFIFOW(s, 32))
{
case 0: // login-server resquest done
output = STRPRINTF(
@@ -477,7 +492,7 @@ int chrif_char_ask_name_answer(int fd)
}
break;
case 2: // ban
- switch (RFIFOW(fd, 32))
+ switch (RFIFOW(s, 32))
{
case 0: // login-server resquest done
output = STRPRINTF(
@@ -498,7 +513,7 @@ int chrif_char_ask_name_answer(int fd)
}
break;
case 3: // unblock
- switch (RFIFOW(fd, 32))
+ switch (RFIFOW(s, 32))
{
case 0: // login-server resquest done
output = STRPRINTF(
@@ -519,7 +534,7 @@ int chrif_char_ask_name_answer(int fd)
}
break;
case 4: // unban
- switch (RFIFOW(fd, 32))
+ switch (RFIFOW(s, 32))
{
case 0: // login-server resquest done
output = STRPRINTF(
@@ -540,7 +555,7 @@ int chrif_char_ask_name_answer(int fd)
}
break;
case 5: // changesex
- switch (RFIFOW(fd, 32))
+ switch (RFIFOW(s, 32))
{
case 0: // login-server resquest done
output = STRPRINTF(
@@ -563,7 +578,7 @@ int chrif_char_ask_name_answer(int fd)
}
}
if (output)
- clif_displaymessage(sd->fd, output);
+ clif_displaymessage(sd->sess, output);
}
else
PRINTF("chrif_char_ask_name_answer failed - player not online.\n");
@@ -576,13 +591,13 @@ int chrif_char_ask_name_answer(int fd)
*------------------------------------------
*/
static
-void chrif_changedgm(int fd)
+void chrif_changedgm(Session *s)
{
int acc, level;
dumb_ptr<map_session_data> sd = NULL;
- acc = RFIFOL(fd, 2);
- level = RFIFOL(fd, 6);
+ acc = RFIFOL(s, 2);
+ level = RFIFOL(s, 6);
sd = map_id2sd(acc);
@@ -592,9 +607,9 @@ void chrif_changedgm(int fd)
if (sd != NULL)
{
if (level > 0)
- clif_displaymessage(sd->fd, "GM modification success.");
+ clif_displaymessage(sd->sess, "GM modification success.");
else
- clif_displaymessage(sd->fd, "Failure of GM modification.");
+ clif_displaymessage(sd->sess, "Failure of GM modification.");
}
}
@@ -603,13 +618,13 @@ void chrif_changedgm(int fd)
*------------------------------------------
*/
static
-void chrif_changedsex(int fd)
+void chrif_changedsex(Session *s)
{
int acc, i;
dumb_ptr<map_session_data> sd;
- acc = RFIFOL(fd, 2);
- SEX sex = static_cast<SEX>(RFIFOB(fd, 6));
+ acc = RFIFOL(s, 2);
+ SEX sex = static_cast<SEX>(RFIFOB(s, 6));
if (battle_config.etc_log)
PRINTF("chrif_changedsex %d.\n", acc);
sd = map_id2sd(acc);
@@ -632,9 +647,9 @@ void chrif_changedsex(int fd)
chrif_save(sd);
sd->login_id1++; // change identify, because if player come back in char within the 5 seconds, he can change its characters
// do same modify in login-server for the account, but no in char-server (it ask again login_id1 to login, and don't remember it)
- clif_displaymessage(sd->fd,
+ clif_displaymessage(sd->sess,
"Your sex has been changed (need disconexion by the server)...");
- clif_setwaitclose(sd->fd); // forced to disconnect for the change
+ clif_setwaitclose(sd->sess); // forced to disconnect for the change
}
}
else
@@ -661,15 +676,15 @@ int chrif_saveaccountreg2(dumb_ptr<map_session_data> sd)
struct global_reg *reg = &sd->status.account_reg2[j];
if (reg->str && reg->value != 0)
{
- WFIFO_STRING(char_fd, p, reg->str, 32);
- WFIFOL(char_fd, p + 32) = reg->value;
+ WFIFO_STRING(char_session, p, reg->str, 32);
+ WFIFOL(char_session, p + 32) = reg->value;
p += 36;
}
}
- WFIFOW(char_fd, 0) = 0x2b10;
- WFIFOW(char_fd, 2) = p;
- WFIFOL(char_fd, 4) = sd->bl_id;
- WFIFOSET(char_fd, p);
+ WFIFOW(char_session, 0) = 0x2b10;
+ WFIFOW(char_session, 2) = p;
+ WFIFOL(char_session, 4) = sd->bl_id;
+ WFIFOSET(char_session, p);
return 0;
}
@@ -679,19 +694,18 @@ int chrif_saveaccountreg2(dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-int chrif_accountreg2(int fd)
+int chrif_accountreg2(Session *s)
{
int j, p;
- dumb_ptr<map_session_data> sd;
-
- if ((sd = map_id2sd(RFIFOL(fd, 4))) == NULL)
+ dumb_ptr<map_session_data> sd = map_id2sd(RFIFOL(s, 4));
+ if (sd == NULL)
return 1;
- for (p = 8, j = 0; p < RFIFOW(fd, 2) && j < ACCOUNT_REG2_NUM;
+ for (p = 8, j = 0; p < RFIFOW(s, 2) && j < ACCOUNT_REG2_NUM;
p += 36, j++)
{
- sd->status.account_reg2[j].str = stringish<VarName>(RFIFO_STRING<32>(fd, p));
- sd->status.account_reg2[j].value = RFIFOL(fd, p + 32);
+ sd->status.account_reg2[j].str = stringish<VarName>(RFIFO_STRING<32>(s, p));
+ sd->status.account_reg2[j].value = RFIFOL(s, p + 32);
}
sd->status.account_reg2_num = j;
@@ -739,12 +753,12 @@ int chrif_divorce(int char_id, int partner_id)
*/
int chrif_send_divorce(int char_id)
{
- if (char_fd < 0)
+ if (!char_session)
return -1;
- WFIFOW(char_fd, 0) = 0x2b16;
- WFIFOL(char_fd, 2) = char_id;
- WFIFOSET(char_fd, 6);
+ WFIFOW(char_session, 0) = 0x2b16;
+ WFIFOL(char_session, 2) = char_id;
+ WFIFOSET(char_session, 6);
return 0;
}
@@ -753,12 +767,12 @@ int chrif_send_divorce(int char_id)
*------------------------------------------
*/
static
-int chrif_accountdeletion(int fd)
+int chrif_accountdeletion(Session *s)
{
int acc;
dumb_ptr<map_session_data> sd;
- acc = RFIFOL(fd, 2);
+ acc = RFIFOL(s, 2);
if (battle_config.etc_log)
PRINTF("chrif_accountdeletion %d.\n", acc);
sd = map_id2sd(acc);
@@ -767,9 +781,9 @@ int chrif_accountdeletion(int fd)
if (sd != NULL)
{
sd->login_id1++; // change identify, because if player come back in char within the 5 seconds, he can change its characters
- clif_displaymessage(sd->fd,
+ clif_displaymessage(sd->sess,
"Your account has been deleted (disconnection)...");
- clif_setwaitclose(sd->fd); // forced to disconnect for the change
+ clif_setwaitclose(sd->sess); // forced to disconnect for the change
}
}
else
@@ -786,12 +800,12 @@ int chrif_accountdeletion(int fd)
*------------------------------------------
*/
static
-int chrif_accountban(int fd)
+int chrif_accountban(Session *s)
{
int acc;
dumb_ptr<map_session_data> sd;
- acc = RFIFOL(fd, 2);
+ acc = RFIFOL(s, 2);
if (battle_config.etc_log)
PRINTF("chrif_accountban %d.\n", acc);
sd = map_id2sd(acc);
@@ -800,65 +814,65 @@ int chrif_accountban(int fd)
if (sd != NULL)
{
sd->login_id1++; // change identify, because if player come back in char within the 5 seconds, he can change its characters
- if (RFIFOB(fd, 6) == 0)
+ if (RFIFOB(s, 6) == 0)
{ // 0: change of statut, 1: ban
- switch (RFIFOL(fd, 7))
+ switch (RFIFOL(s, 7))
{ // status or final date of a banishment
case 1: // 0 = Unregistered ID
- clif_displaymessage(sd->fd,
+ clif_displaymessage(sd->sess,
"Your account has 'Unregistered'.");
break;
case 2: // 1 = Incorrect Password
- clif_displaymessage(sd->fd,
+ clif_displaymessage(sd->sess,
"Your account has an 'Incorrect Password'...");
break;
case 3: // 2 = This ID is expired
- clif_displaymessage(sd->fd,
+ clif_displaymessage(sd->sess,
"Your account has expired.");
break;
case 4: // 3 = Rejected from Server
- clif_displaymessage(sd->fd,
+ clif_displaymessage(sd->sess,
"Your account has been rejected from server.");
break;
case 5: // 4 = You have been blocked by the GM Team
- clif_displaymessage(sd->fd,
+ clif_displaymessage(sd->sess,
"Your account has been blocked by the GM Team.");
break;
case 6: // 5 = Your Game's EXE file is not the latest version
- clif_displaymessage(sd->fd,
+ clif_displaymessage(sd->sess,
"Your Game's EXE file is not the latest version.");
break;
case 7: // 6 = Your are Prohibited to log in until %s
- clif_displaymessage(sd->fd,
+ clif_displaymessage(sd->sess,
"Your account has been prohibited to log in.");
break;
case 8: // 7 = Server is jammed due to over populated
- clif_displaymessage(sd->fd,
+ clif_displaymessage(sd->sess,
"Server is jammed due to over populated.");
break;
case 9: // 8 = No MSG (actually, all states after 9 except 99 are No MSG, use only this)
- clif_displaymessage(sd->fd,
+ clif_displaymessage(sd->sess,
"Your account has not more authorised.");
break;
case 100: // 99 = This ID has been totally erased
- clif_displaymessage(sd->fd,
+ clif_displaymessage(sd->sess,
"Your account has been totally erased.");
break;
default:
- clif_displaymessage(sd->fd,
+ clif_displaymessage(sd->sess,
"Your account has not more authorised.");
break;
}
}
- else if (RFIFOB(fd, 6) == 1)
+ else if (RFIFOB(s, 6) == 1)
{
// 0: change of statut, 1: ban
- TimeT timestamp = static_cast<time_t>(RFIFOL(fd, 7)); // status or final date of a banishment
+ TimeT timestamp = static_cast<time_t>(RFIFOL(s, 7)); // status or final date of a banishment
char tmpstr[] = WITH_TIMESTAMP("Your account has been banished until ");
REPLACE_TIMESTAMP(tmpstr, timestamp);
- clif_displaymessage(sd->fd, const_(tmpstr));
+ clif_displaymessage(sd->sess, const_(tmpstr));
}
- clif_setwaitclose(sd->fd); // forced to disconnect for the change
+ clif_setwaitclose(sd->sess); // forced to disconnect for the change
}
}
else
@@ -875,10 +889,10 @@ int chrif_accountban(int fd)
*------------------------------------------
*/
static
-int chrif_recvgmaccounts(int fd)
+int chrif_recvgmaccounts(Session *s)
{
PRINTF("From login-server: receiving of %d GM accounts information.\n",
- pc_read_gm_account(fd));
+ pc_read_gm_account(s));
return 0;
}
@@ -890,8 +904,8 @@ int chrif_recvgmaccounts(int fd)
int chrif_reloadGMdb(void)
{
- WFIFOW(char_fd, 0) = 0x2af7;
- WFIFOSET(char_fd, 2);
+ WFIFOW(char_session, 0) = 0x2af7;
+ WFIFOSET(char_session, 2);
return 0;
}
@@ -983,10 +997,10 @@ void ladmin_itemfrob_c(dumb_ptr<block_list> bl, int source_id, int dest_id)
}
static
-void ladmin_itemfrob(int fd)
+void ladmin_itemfrob(Session *s)
{
- int source_id = RFIFOL(fd, 2);
- int dest_id = RFIFOL(fd, 6);
+ int source_id = RFIFOL(s, 2);
+ int dest_id = RFIFOL(s, 6);
dumb_ptr<block_list> bl = map_get_first_session();
// flooritems
@@ -1006,27 +1020,27 @@ void ladmin_itemfrob(int fd)
*------------------------------------------
*/
static
-void chrif_parse(int fd)
+void chrif_parse(Session *s)
{
int packet_len, cmd;
// only char-server can have an access to here.
// so, if it isn't the char-server, we disconnect the session (fd != char_fd).
- if (fd != char_fd || session[fd]->eof)
+ if (s != char_session || s->eof)
{
- if (fd == char_fd)
+ if (s == char_session)
{
PRINTF("Map-server can't connect to char-server (connection #%d).\n",
- fd);
- char_fd = -1;
+ s);
+ char_session = nullptr;
}
- delete_session(fd);
+ delete_session(s);
return;
}
- while (RFIFOREST(fd) >= 2)
+ while (RFIFOREST(s) >= 2)
{
- cmd = RFIFOW(fd, 0);
+ cmd = RFIFOW(s, 0);
if (cmd < 0x2af8
|| cmd >=
0x2af8 +
@@ -1034,98 +1048,98 @@ void chrif_parse(int fd)
|| packet_len_table[cmd - 0x2af8] == 0)
{
- int r = intif_parse(fd); // intifに渡す
+ int r = intif_parse(s); // intifに渡す
if (r == 1)
continue; // intifで処理した
if (r == 2)
return; // intifで処理したが、データが足りない
- session[fd]->eof = 1;
+ s->eof = 1;
return;
}
packet_len = packet_len_table[cmd - 0x2af8];
if (packet_len == -1)
{
- if (RFIFOREST(fd) < 4)
+ if (RFIFOREST(s) < 4)
return;
- packet_len = RFIFOW(fd, 2);
+ packet_len = RFIFOW(s, 2);
}
- if (RFIFOREST(fd) < packet_len)
+ if (RFIFOREST(s) < packet_len)
return;
switch (cmd)
{
case 0x2af9:
- chrif_connectack(fd);
+ chrif_connectack(s);
break;
case 0x2afa:
- ladmin_itemfrob(fd);
+ ladmin_itemfrob(s);
break;
case 0x2afb:
- chrif_sendmapack(fd);
+ chrif_sendmapack(s);
break;
case 0x2afd:
{
- int id = RFIFOL(fd, 4);
- int login_id2 = RFIFOL(fd, 8);
- TimeT connect_until_time = static_cast<time_t>(RFIFOL(fd, 12));
- short tmw_version = RFIFOW(fd, 16);
+ int id = RFIFOL(s, 4);
+ int login_id2 = RFIFOL(s, 8);
+ TimeT connect_until_time = static_cast<time_t>(RFIFOL(s, 12));
+ short tmw_version = RFIFOW(s, 16);
struct mmo_charstatus st {};
- RFIFO_STRUCT(fd, 18, st);
+ RFIFO_STRUCT(s, 18, st);
pc_authok(id, login_id2,
connect_until_time, tmw_version,
&st);
}
break;
case 0x2afe:
- pc_authfail(RFIFOL(fd, 2));
+ pc_authfail(RFIFOL(s, 2));
break;
case 0x2b00:
- map_setusers(RFIFOL(fd, 2));
+ map_setusers(RFIFOL(s, 2));
break;
case 0x2b03:
- clif_charselectok(RFIFOL(fd, 2));
+ clif_charselectok(RFIFOL(s, 2));
break;
case 0x2b04:
- chrif_recvmap(fd);
+ chrif_recvmap(s);
break;
case 0x2b06:
- chrif_changemapserverack(fd);
+ chrif_changemapserverack(s);
break;
case 0x2b0b:
- chrif_changedgm(fd);
+ chrif_changedgm(s);
break;
case 0x2b0d:
- chrif_changedsex(fd);
+ chrif_changedsex(s);
break;
case 0x2b0f:
- chrif_char_ask_name_answer(fd);
+ chrif_char_ask_name_answer(s);
break;
case 0x2b11:
- chrif_accountreg2(fd);
+ chrif_accountreg2(s);
break;
case 0x2b12:
- chrif_divorce(RFIFOL(fd, 2), RFIFOL(fd, 6));
+ chrif_divorce(RFIFOL(s, 2), RFIFOL(s, 6));
break;
case 0x2b13:
- chrif_accountdeletion(fd);
+ chrif_accountdeletion(s);
break;
case 0x2b14:
- chrif_accountban(fd);
+ chrif_accountban(s);
break;
case 0x2b15:
- chrif_recvgmaccounts(fd);
+ chrif_recvgmaccounts(s);
break;
default:
if (battle_config.error_log)
- PRINTF("chrif_parse : unknown packet %d %d\n", fd,
- RFIFOW(fd, 0));
- session[fd]->eof = 1;
+ PRINTF("chrif_parse : unknown packet %d %d\n", s,
+ RFIFOW(s, 0));
+ s->eof = 1;
return;
}
- RFIFOSKIP(fd, packet_len);
+ RFIFOSKIP(s, packet_len);
}
}
@@ -1139,10 +1153,10 @@ void send_users_tochar(TimerData *, tick_t)
{
int users = 0;
- if (char_fd <= 0 || session[char_fd] == NULL)
+ if (!char_session)
return;
- WFIFOW(char_fd, 0) = 0x2aff;
+ WFIFOW(char_session, 0) = 0x2aff;
for (int i = 0; i < fd_max; i++)
{
if (!session[i])
@@ -1153,13 +1167,13 @@ void send_users_tochar(TimerData *, tick_t)
|| sd->state.shroud_active
|| bool(sd->status.option & Option::HIDE)) && pc_isGM(sd)))
{
- WFIFOL(char_fd, 6 + 4 * users) = sd->status.char_id;
+ WFIFOL(char_session, 6 + 4 * users) = sd->status.char_id;
users++;
}
}
- WFIFOW(char_fd, 2) = 6 + 4 * users;
- WFIFOW(char_fd, 4) = users;
- WFIFOSET(char_fd, 6 + 4 * users);
+ WFIFOW(char_session, 2) = 6 + 4 * users;
+ WFIFOW(char_session, 4) = users;
+ WFIFOSET(char_session, 6 + 4 * users);
}
/*==========================================
@@ -1170,16 +1184,17 @@ void send_users_tochar(TimerData *, tick_t)
static
void check_connect_char_server(TimerData *, tick_t)
{
- if (char_fd <= 0 || session[char_fd] == NULL)
+ if (!char_session)
{
PRINTF("Attempt to connect to char-server...\n");
chrif_state = 0;
- if ((char_fd = make_connection(char_ip, char_port)) < 0)
+ char_session = make_connection(char_ip, char_port);
+ if (!char_session)
return;
- session[char_fd]->func_parse = chrif_parse;
- realloc_fifo(char_fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
+ char_session->func_parse = chrif_parse;
+ realloc_fifo(char_session, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
- chrif_connect(char_fd);
+ chrif_connect(char_session);
}
}
diff --git a/src/map/chrif.hpp b/src/map/chrif.hpp
index dfa2d35..734f1ac 100644
--- a/src/map/chrif.hpp
+++ b/src/map/chrif.hpp
@@ -37,6 +37,6 @@ int chrif_send_divorce(int char_id);
void do_init_chrif(void);
// only used by intif.cpp
-extern int char_fd;
+extern Session *char_session;
#endif // CHRIF_HPP
diff --git a/src/map/clif.cpp b/src/map/clif.cpp
index b4ac24a..0429600 100644
--- a/src/map/clif.cpp
+++ b/src/map/clif.cpp
@@ -46,7 +46,7 @@ constexpr int EMOTE_IGNORED = 0x0e;
// map.h must be the same length as this table. rate 0 is default
// rate -1 is unlimited
-typedef void (*clif_func)(int fd, dumb_ptr<map_session_data> sd);
+typedef void (*clif_func)(Session *s, dumb_ptr<map_session_data> sd);
struct func_table
{
interval_t rate;
@@ -102,14 +102,14 @@ void WBUFPOS2(uint8_t *p, size_t pos, uint16_t x0, uint16_t y0, uint16_t x1, uin
}
inline
-void WFIFOPOS(int fd, size_t pos, uint16_t x, uint16_t y)
+void WFIFOPOS(Session *s, size_t pos, uint16_t x, uint16_t y)
{
- WBUFPOS(static_cast<uint8_t *>(WFIFOP(fd, pos)), 0, x, y);
+ WBUFPOS(static_cast<uint8_t *>(WFIFOP(s, pos)), 0, x, y);
}
inline
-void WFIFOPOS2(int fd, size_t pos, uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1)
+void WFIFOPOS2(Session *s, size_t pos, uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1)
{
- WBUFPOS2(static_cast<uint8_t *>(WFIFOP(fd, pos)), 0, x0, y0, x1, y1);
+ WBUFPOS2(static_cast<uint8_t *>(WFIFOP(s, pos)), 0, x0, y0, x1, y1);
}
static
@@ -249,14 +249,14 @@ void clif_send_sub(dumb_ptr<block_list> bl, const unsigned char *buf, int len,
break;
}
- if (session[sd->fd] != NULL)
+ if (sd->sess != NULL)
{
{
if (clif_parse_func_table[RBUFW(buf, 0)].len)
{
// packet must exist
- WFIFO_BUF_CLONE(sd->fd, buf, len);
- WFIFOSET(sd->fd, len);
+ WFIFO_BUF_CLONE(sd->sess, buf, len);
+ WFIFOSET(sd->sess, len);
}
}
}
@@ -304,16 +304,17 @@ int clif_send(const uint8_t *buf, int len, dumb_ptr<block_list> bl, SendWho type
case SendWho::ALL_CLIENT: // 全クライアントに送信
for (int i = 0; i < fd_max; i++)
{
- if (!session[i])
+ Session *s = session[i].get();
+ if (!s)
continue;
- dumb_ptr<map_session_data> sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[i]->session_data.get()));
+ dumb_ptr<map_session_data> sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s->session_data.get()));
if (sd && sd->state.auth)
{
if (clif_parse_func_table[RBUFW(buf, 0)].len)
{
// packet must exist
- WFIFO_BUF_CLONE(i, buf, len);
- WFIFOSET(i, len);
+ WFIFO_BUF_CLONE(s, buf, len);
+ WFIFOSET(s, len);
}
}
}
@@ -321,16 +322,17 @@ int clif_send(const uint8_t *buf, int len, dumb_ptr<block_list> bl, SendWho type
case SendWho::ALL_SAMEMAP: // 同じマップの全クライアントに送信
for (int i = 0; i < fd_max; i++)
{
- if (!session[i])
+ Session *s = session[i].get();
+ if (!s)
continue;
- dumb_ptr<map_session_data> sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[i]->session_data.get()));
+ dumb_ptr<map_session_data> sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s->session_data.get()));
if (sd && sd->state.auth && sd->bl_m == bl->bl_m)
{
if (clif_parse_func_table[RBUFW(buf, 0)].len)
{
// packet must exist
- WFIFO_BUF_CLONE(i, buf, len);
- WFIFOSET(i, len);
+ WFIFO_BUF_CLONE(s, buf, len);
+ WFIFOSET(s, len);
}
}
}
@@ -395,16 +397,17 @@ int clif_send(const uint8_t *buf, int len, dumb_ptr<block_list> bl, SendWho type
if (clif_parse_func_table[RBUFW(buf, 0)].len)
{
// packet must exist
- WFIFO_BUF_CLONE(sd->fd, buf, len);
- WFIFOSET(sd->fd, len);
+ WFIFO_BUF_CLONE(sd->sess, buf, len);
+ WFIFOSET(sd->sess, len);
}
}
}
for (int i = 0; i < fd_max; i++)
{
- if (!session[i])
+ Session *s = session[i].get();
+ if (!s)
continue;
- dumb_ptr<map_session_data> sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[i]->session_data.get()));
+ dumb_ptr<map_session_data> sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s->session_data.get()));
if (sd && sd->state.auth)
{
if (sd->partyspy == p->party_id)
@@ -412,8 +415,8 @@ int clif_send(const uint8_t *buf, int len, dumb_ptr<block_list> bl, SendWho type
if (clif_parse_func_table[RBUFW(buf, 0)].len)
{
// packet must exist
- WFIFO_BUF_CLONE(sd->fd, buf, len);
- WFIFOSET(sd->fd, len);
+ WFIFO_BUF_CLONE(sd->sess, buf, len);
+ WFIFOSET(sd->sess, len);
}
}
}
@@ -426,8 +429,8 @@ int clif_send(const uint8_t *buf, int len, dumb_ptr<block_list> bl, SendWho type
if (clif_parse_func_table[RBUFW(buf, 0)].len)
{
// packet must exist
- WFIFO_BUF_CLONE(sd->fd, buf, len);
- WFIFOSET(sd->fd, len);
+ WFIFO_BUF_CLONE(sd->sess, buf, len);
+ WFIFOSET(sd->sess, len);
}
}
break;
@@ -450,24 +453,22 @@ int clif_send(const uint8_t *buf, int len, dumb_ptr<block_list> bl, SendWho type
*/
int clif_authok(dumb_ptr<map_session_data> sd)
{
- int fd;
-
nullpo_ret(sd);
if (!sd)
return 0;
- if (!sd->fd)
+ if (!sd->sess)
return 0;
- fd = sd->fd;
+ Session *s = sd->sess;
- WFIFOW(fd, 0) = 0x73;
- WFIFOL(fd, 2) = gettick().time_since_epoch().count();
- WFIFOPOS(fd, 6, sd->bl_x, sd->bl_y);
- WFIFOB(fd, 9) = 5;
- WFIFOB(fd, 10) = 5;
- WFIFOSET(fd, clif_parse_func_table[0x73].len);
+ WFIFOW(s, 0) = 0x73;
+ WFIFOL(s, 2) = gettick().time_since_epoch().count();
+ WFIFOPOS(s, 6, sd->bl_x, sd->bl_y);
+ WFIFOB(s, 9) = 5;
+ WFIFOB(s, 10) = 5;
+ WFIFOSET(s, clif_parse_func_table[0x73].len);
return 0;
}
@@ -476,16 +477,16 @@ int clif_authok(dumb_ptr<map_session_data> sd)
*
*------------------------------------------
*/
-int clif_authfail_fd(int fd, int type)
+int clif_authfail_fd(Session *s, int type)
{
- if (!fd || !session[fd])
+ if (!s)
return 0;
- WFIFOW(fd, 0) = 0x81;
- WFIFOL(fd, 2) = type;
- WFIFOSET(fd, clif_parse_func_table[0x81].len);
+ WFIFOW(s, 0) = 0x81;
+ WFIFOL(s, 2) = type;
+ WFIFOSET(s, clif_parse_func_table[0x81].len);
- clif_setwaitclose(fd);
+ clif_setwaitclose(s);
return 0;
}
@@ -497,18 +498,17 @@ int clif_authfail_fd(int fd, int type)
int clif_charselectok(int id)
{
dumb_ptr<map_session_data> sd;
- int fd;
if ((sd = map_id2sd(id)) == NULL)
return 1;
- if (!sd->fd)
+ if (!sd->sess)
return 1;
- fd = sd->fd;
- WFIFOW(fd, 0) = 0xb3;
- WFIFOB(fd, 2) = 1;
- WFIFOSET(fd, clif_parse_func_table[0xb3].len);
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0xb3;
+ WFIFOB(s, 2) = 1;
+ WFIFOSET(s, clif_parse_func_table[0xb3].len);
return 0;
}
@@ -558,7 +558,7 @@ int clif_dropflooritem(dumb_ptr<flooritem_data> fitem)
*
*------------------------------------------
*/
-int clif_clearflooritem(dumb_ptr<flooritem_data> fitem, int fd)
+int clif_clearflooritem(dumb_ptr<flooritem_data> fitem, Session *s)
{
unsigned char buf[16];
@@ -567,14 +567,14 @@ int clif_clearflooritem(dumb_ptr<flooritem_data> fitem, int fd)
WBUFW(buf, 0) = 0xa1;
WBUFL(buf, 2) = fitem->bl_id;
- if (fd == 0)
+ if (!s)
{
clif_send(buf, clif_parse_func_table[0xa1].len, fitem, SendWho::AREA);
}
else
{
- WFIFO_BUF_CLONE(fd, buf, 6);
- WFIFOSET(fd, clif_parse_func_table[0xa1].len);
+ WFIFO_BUF_CLONE(s, buf, 6);
+ WFIFOSET(s, clif_parse_func_table[0xa1].len);
}
return 0;
@@ -642,12 +642,12 @@ int clif_clearchar_delay(tick_t tick,
*
*------------------------------------------
*/
-void clif_clearchar_id(int id, BeingRemoveWhy type, int fd)
+void clif_clearchar_id(int id, BeingRemoveWhy type, Session *s)
{
- WFIFOW(fd, 0) = 0x80;
- WFIFOL(fd, 2) = id;
- WFIFOB(fd, 6) = static_cast<uint8_t>(type);
- WFIFOSET(fd, clif_parse_func_table[0x80].len);
+ WFIFOW(s, 0) = 0x80;
+ WFIFOL(s, 2) = id;
+ WFIFOB(s, 6) = static_cast<uint8_t>(type);
+ WFIFOSET(s, clif_parse_func_table[0x80].len);
}
/*==========================================
@@ -933,37 +933,36 @@ int clif_spawnnpc(dumb_ptr<npc_data> nd)
int clif_spawn_fake_npc_for_player(dumb_ptr<map_session_data> sd, int fake_npc_id)
{
- int fd;
-
nullpo_ret(sd);
- fd = sd->fd;
- if (!fd)
+ Session *s = sd->sess;
+
+ if (!s)
return 0;
- WFIFOW(fd, 0) = 0x7c;
- WFIFOL(fd, 2) = fake_npc_id;
- WFIFOW(fd, 6) = 0;
- WFIFOW(fd, 8) = 0;
- WFIFOW(fd, 10) = 0;
- WFIFOW(fd, 12) = 0;
- WFIFOW(fd, 20) = 127;
- WFIFOPOS(fd, 36, sd->bl_x, sd->bl_y);
- WFIFOSET(fd, clif_parse_func_table[0x7c].len);
-
- WFIFOW(fd, 0) = 0x78;
- WFIFOL(fd, 2) = fake_npc_id;
- WFIFOW(fd, 6) = 0;
- WFIFOW(fd, 8) = 0;
- WFIFOW(fd, 10) = 0;
- WFIFOW(fd, 12) = 0;
- WFIFOW(fd, 14) = 127; // identifies as NPC
- WFIFOW(fd, 20) = 127;
- WFIFOPOS(fd, 46, sd->bl_x, sd->bl_y);
- WFIFOPOS(fd, 36, sd->bl_x, sd->bl_y);
- WFIFOB(fd, 49) = 5;
- WFIFOB(fd, 50) = 5;
- WFIFOSET(fd, clif_parse_func_table[0x78].len);
+ WFIFOW(s, 0) = 0x7c;
+ WFIFOL(s, 2) = fake_npc_id;
+ WFIFOW(s, 6) = 0;
+ WFIFOW(s, 8) = 0;
+ WFIFOW(s, 10) = 0;
+ WFIFOW(s, 12) = 0;
+ WFIFOW(s, 20) = 127;
+ WFIFOPOS(s, 36, sd->bl_x, sd->bl_y);
+ WFIFOSET(s, clif_parse_func_table[0x7c].len);
+
+ WFIFOW(s, 0) = 0x78;
+ WFIFOL(s, 2) = fake_npc_id;
+ WFIFOW(s, 6) = 0;
+ WFIFOW(s, 8) = 0;
+ WFIFOW(s, 10) = 0;
+ WFIFOW(s, 12) = 0;
+ WFIFOW(s, 14) = 127; // identifies as NPC
+ WFIFOW(s, 20) = 127;
+ WFIFOPOS(s, 46, sd->bl_x, sd->bl_y);
+ WFIFOPOS(s, 36, sd->bl_x, sd->bl_y);
+ WFIFOB(s, 49) = 5;
+ WFIFOB(s, 50) = 5;
+ WFIFOSET(s, clif_parse_func_table[0x78].len);
return 0;
}
@@ -1006,14 +1005,12 @@ int clif_spawnmob(dumb_ptr<mob_data> md)
static
int clif_servertick(dumb_ptr<map_session_data> sd)
{
- int fd;
-
nullpo_ret(sd);
- fd = sd->fd;
- WFIFOW(fd, 0) = 0x7f;
- WFIFOL(fd, 2) = sd->server_tick.time_since_epoch().count();
- WFIFOSET(fd, clif_parse_func_table[0x7f].len);
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0x7f;
+ WFIFOL(s, 2) = sd->server_tick.time_since_epoch().count();
+ WFIFOSET(s, clif_parse_func_table[0x7f].len);
return 0;
}
@@ -1024,16 +1021,14 @@ int clif_servertick(dumb_ptr<map_session_data> sd)
*/
int clif_walkok(dumb_ptr<map_session_data> sd)
{
- int fd;
-
nullpo_ret(sd);
- fd = sd->fd;
- WFIFOW(fd, 0) = 0x87;
- WFIFOL(fd, 2) = gettick().time_since_epoch().count();
- WFIFOPOS2(fd, 6, sd->bl_x, sd->bl_y, sd->to_x, sd->to_y);
- WFIFOB(fd, 11) = 0;
- WFIFOSET(fd, clif_parse_func_table[0x87].len);
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0x87;
+ WFIFOL(s, 2) = gettick().time_since_epoch().count();
+ WFIFOPOS2(s, 6, sd->bl_x, sd->bl_y, sd->to_x, sd->to_y);
+ WFIFOB(s, 11) = 0;
+ WFIFOSET(s, clif_parse_func_table[0x87].len);
return 0;
}
@@ -1065,7 +1060,7 @@ int clif_movechar(dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_quitsave(int, dumb_ptr<map_session_data> sd)
+void clif_quitsave(Session *, dumb_ptr<map_session_data> sd)
{
map_quit(sd);
}
@@ -1075,23 +1070,23 @@ void clif_quitsave(int, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_waitclose(TimerData *, tick_t, int id)
+void clif_waitclose(TimerData *, tick_t, Session *s)
{
// TODO: what happens if the player disconnects
// and someone else connects?
- if (session[id])
- session[id]->eof = 1;
+ if (s)
+ s->eof = 1;
}
/*==========================================
*
*------------------------------------------
*/
-void clif_setwaitclose(int fd)
+void clif_setwaitclose(Session *s)
{
Timer(gettick() + std::chrono::seconds(5),
std::bind(clif_waitclose, ph::_1, ph::_2,
- fd)
+ s)
).detach();
}
@@ -1103,13 +1098,13 @@ void clif_changemap(dumb_ptr<map_session_data> sd, MapName mapname, int x, int y
{
nullpo_retv(sd);
- int fd = sd->fd;
+ Session *s = sd->sess;
- WFIFOW(fd, 0) = 0x91;
- WFIFO_STRING(fd, 2, mapname, 16);
- WFIFOW(fd, 18) = x;
- WFIFOW(fd, 20) = y;
- WFIFOSET(fd, clif_parse_func_table[0x91].len);
+ WFIFOW(s, 0) = 0x91;
+ WFIFO_STRING(s, 2, mapname, 16);
+ WFIFOW(s, 18) = x;
+ WFIFOW(s, 20) = y;
+ WFIFOSET(s, clif_parse_func_table[0x91].len);
}
/*==========================================
@@ -1121,14 +1116,14 @@ void clif_changemapserver(dumb_ptr<map_session_data> sd,
{
nullpo_retv(sd);
- int fd = sd->fd;
- WFIFOW(fd, 0) = 0x92;
- WFIFO_STRING(fd, 2, mapname, 16);
- WFIFOW(fd, 18) = x;
- WFIFOW(fd, 20) = y;
- WFIFOIP(fd, 22) = ip;
- WFIFOW(fd, 26) = port;
- WFIFOSET(fd, clif_parse_func_table[0x92].len);
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0x92;
+ WFIFO_STRING(s, 2, mapname, 16);
+ WFIFOW(s, 18) = x;
+ WFIFOW(s, 20) = y;
+ WFIFOIP(s, 22) = ip;
+ WFIFOW(s, 26) = port;
+ WFIFOSET(s, clif_parse_func_table[0x92].len);
}
/*==========================================
@@ -1155,14 +1150,12 @@ void clif_fixpos(dumb_ptr<block_list> bl)
*/
int clif_npcbuysell(dumb_ptr<map_session_data> sd, int id)
{
- int fd;
-
nullpo_ret(sd);
- fd = sd->fd;
- WFIFOW(fd, 0) = 0xc4;
- WFIFOL(fd, 2) = id;
- WFIFOSET(fd, clif_parse_func_table[0xc4].len);
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0xc4;
+ WFIFOL(s, 2) = id;
+ WFIFOSET(s, clif_parse_func_table[0xc4].len);
return 0;
}
@@ -1174,24 +1167,24 @@ int clif_npcbuysell(dumb_ptr<map_session_data> sd, int id)
int clif_buylist(dumb_ptr<map_session_data> sd, dumb_ptr<npc_data_shop> nd)
{
struct item_data *id;
- int fd, i, val;
+ int i, val;
nullpo_ret(sd);
nullpo_ret(nd);
- fd = sd->fd;
- WFIFOW(fd, 0) = 0xc6;
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0xc6;
for (i = 0; i < nd->shop_items.size(); i++)
{
id = itemdb_search(nd->shop_items[i].nameid);
val = nd->shop_items[i].value;
- WFIFOL(fd, 4 + i * 11) = val; // base price
- WFIFOL(fd, 8 + i * 11) = val; // actual price
- WFIFOB(fd, 12 + i * 11) = uint8_t(id->type);
- WFIFOW(fd, 13 + i * 11) = nd->shop_items[i].nameid;
+ WFIFOL(s, 4 + i * 11) = val; // base price
+ WFIFOL(s, 8 + i * 11) = val; // actual price
+ WFIFOB(s, 12 + i * 11) = uint8_t(id->type);
+ WFIFOW(s, 13 + i * 11) = nd->shop_items[i].nameid;
}
- WFIFOW(fd, 2) = i * 11 + 4;
- WFIFOSET(fd, WFIFOW(fd, 2));
+ WFIFOW(s, 2) = i * 11 + 4;
+ WFIFOSET(s, WFIFOW(s, 2));
return 0;
}
@@ -1202,12 +1195,12 @@ int clif_buylist(dumb_ptr<map_session_data> sd, dumb_ptr<npc_data_shop> nd)
*/
int clif_selllist(dumb_ptr<map_session_data> sd)
{
- int fd, i, c = 0, val;
+ int i, c = 0, val;
nullpo_ret(sd);
- fd = sd->fd;
- WFIFOW(fd, 0) = 0xc7;
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0xc7;
for (i = 0; i < MAX_INVENTORY; i++)
{
if (sd->status.inventory[i].nameid > 0 && sd->inventory_data[i])
@@ -1215,14 +1208,14 @@ int clif_selllist(dumb_ptr<map_session_data> sd)
val = sd->inventory_data[i]->value_sell;
if (val < 0)
continue;
- WFIFOW(fd, 4 + c * 10) = i + 2;
- WFIFOL(fd, 6 + c * 10) = val; // base price
- WFIFOL(fd, 10 + c * 10) = val; // actual price
+ WFIFOW(s, 4 + c * 10) = i + 2;
+ WFIFOL(s, 6 + c * 10) = val; // base price
+ WFIFOL(s, 10 + c * 10) = val; // actual price
c++;
}
}
- WFIFOW(fd, 2) = c * 10 + 4;
- WFIFOSET(fd, WFIFOW(fd, 2));
+ WFIFOW(s, 2) = c * 10 + 4;
+ WFIFOSET(s, WFIFOW(s, 2));
return 0;
}
@@ -1235,14 +1228,14 @@ void clif_scriptmes(dumb_ptr<map_session_data> sd, int npcid, XString mes)
{
nullpo_retv(sd);
- int fd = sd->fd;
+ Session *s = sd->sess;
size_t len = mes.size() + 1;
- WFIFOW(fd, 0) = 0xb4;
- WFIFOW(fd, 2) = len + 8;
- WFIFOL(fd, 4) = npcid;
- WFIFO_STRING(fd, 8, mes, len);
- WFIFOSET(fd, WFIFOW(fd, 2));
+ WFIFOW(s, 0) = 0xb4;
+ WFIFOW(s, 2) = len + 8;
+ WFIFOL(s, 4) = npcid;
+ WFIFO_STRING(s, 8, mes, len);
+ WFIFOSET(s, WFIFOW(s, 2));
}
/*==========================================
@@ -1253,10 +1246,10 @@ void clif_scriptnext(dumb_ptr<map_session_data> sd, int npcid)
{
nullpo_retv(sd);
- int fd = sd->fd;
- WFIFOW(fd, 0) = 0xb5;
- WFIFOL(fd, 2) = npcid;
- WFIFOSET(fd, clif_parse_func_table[0xb5].len);
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0xb5;
+ WFIFOL(s, 2) = npcid;
+ WFIFOSET(s, clif_parse_func_table[0xb5].len);
}
/*==========================================
@@ -1267,10 +1260,10 @@ void clif_scriptclose(dumb_ptr<map_session_data> sd, int npcid)
{
nullpo_retv(sd);
- int fd = sd->fd;
- WFIFOW(fd, 0) = 0xb6;
- WFIFOL(fd, 2) = npcid;
- WFIFOSET(fd, clif_parse_func_table[0xb6].len);
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0xb6;
+ WFIFOL(s, 2) = npcid;
+ WFIFOSET(s, clif_parse_func_table[0xb6].len);
}
/*==========================================
@@ -1281,13 +1274,13 @@ void clif_scriptmenu(dumb_ptr<map_session_data> sd, int npcid, XString mes)
{
nullpo_retv(sd);
- int fd = sd->fd;
+ Session *s = sd->sess;
size_t len = mes.size() + 1;
- WFIFOW(fd, 0) = 0xb7;
- WFIFOW(fd, 2) = len + 8;
- WFIFOL(fd, 4) = npcid;
- WFIFO_STRING(fd, 8, mes, len);
- WFIFOSET(fd, WFIFOW(fd, 2));
+ WFIFOW(s, 0) = 0xb7;
+ WFIFOW(s, 2) = len + 8;
+ WFIFOL(s, 4) = npcid;
+ WFIFO_STRING(s, 8, mes, len);
+ WFIFOSET(s, WFIFOW(s, 2));
}
/*==========================================
@@ -1298,10 +1291,10 @@ void clif_scriptinput(dumb_ptr<map_session_data> sd, int npcid)
{
nullpo_retv(sd);
- int fd = sd->fd;
- WFIFOW(fd, 0) = 0x142;
- WFIFOL(fd, 2) = npcid;
- WFIFOSET(fd, clif_parse_func_table[0x142].len);
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0x142;
+ WFIFOL(s, 2) = npcid;
+ WFIFOSET(s, clif_parse_func_table[0x142].len);
}
/*==========================================
@@ -1312,10 +1305,10 @@ void clif_scriptinputstr(dumb_ptr<map_session_data> sd, int npcid)
{
nullpo_retv(sd);
- int fd = sd->fd;
- WFIFOW(fd, 0) = 0x1d4;
- WFIFOL(fd, 2) = npcid;
- WFIFOSET(fd, clif_parse_func_table[0x1d4].len);
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0x1d4;
+ WFIFOL(s, 2) = npcid;
+ WFIFOSET(s, clif_parse_func_table[0x1d4].len);
}
/*==========================================
@@ -1327,15 +1320,15 @@ void clif_viewpoint(dumb_ptr<map_session_data> sd, int npc_id, int type,
{
nullpo_retv(sd);
- int fd = sd->fd;
- WFIFOW(fd, 0) = 0x144;
- WFIFOL(fd, 2) = npc_id;
- WFIFOL(fd, 6) = type;
- WFIFOL(fd, 10) = x;
- WFIFOL(fd, 14) = y;
- WFIFOB(fd, 18) = id;
- WFIFOL(fd, 19) = color;
- WFIFOSET(fd, clif_parse_func_table[0x144].len);
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0x144;
+ WFIFOL(s, 2) = npc_id;
+ WFIFOL(s, 6) = type;
+ WFIFOL(s, 10) = x;
+ WFIFOL(s, 14) = y;
+ WFIFOB(s, 18) = id;
+ WFIFOL(s, 19) = color;
+ WFIFOSET(s, clif_parse_func_table[0x144].len);
}
/*==========================================
@@ -1346,23 +1339,23 @@ int clif_additem(dumb_ptr<map_session_data> sd, int n, int amount, PickupFail fa
{
nullpo_ret(sd);
- int fd = sd->fd;
+ Session *s = sd->sess;
if (fail != PickupFail::OKAY)
{
- WFIFOW(fd, 0) = 0xa0;
- WFIFOW(fd, 2) = n + 2;
- WFIFOW(fd, 4) = amount;
- WFIFOW(fd, 6) = 0;
- WFIFOB(fd, 8) = 0;
- WFIFOB(fd, 9) = 0;
- WFIFOB(fd, 10) = 0;
- WFIFOW(fd, 11) = 0;
- WFIFOW(fd, 13) = 0;
- WFIFOW(fd, 15) = 0;
- WFIFOW(fd, 17) = 0;
- WFIFOW(fd, 19) = 0;
- WFIFOB(fd, 21) = 0;
- WFIFOB(fd, 22) = uint8_t(fail);
+ WFIFOW(s, 0) = 0xa0;
+ WFIFOW(s, 2) = n + 2;
+ WFIFOW(s, 4) = amount;
+ WFIFOW(s, 6) = 0;
+ WFIFOB(s, 8) = 0;
+ WFIFOB(s, 9) = 0;
+ WFIFOB(s, 10) = 0;
+ WFIFOW(s, 11) = 0;
+ WFIFOW(s, 13) = 0;
+ WFIFOW(s, 15) = 0;
+ WFIFOW(s, 17) = 0;
+ WFIFOW(s, 19) = 0;
+ WFIFOB(s, 21) = 0;
+ WFIFOB(s, 22) = uint8_t(fail);
}
else
{
@@ -1370,40 +1363,40 @@ int clif_additem(dumb_ptr<map_session_data> sd, int n, int amount, PickupFail fa
|| sd->inventory_data[n] == NULL)
return 1;
- WFIFOW(fd, 0) = 0xa0;
- WFIFOW(fd, 2) = n + 2;
- WFIFOW(fd, 4) = amount;
- WFIFOW(fd, 6) = sd->status.inventory[n].nameid;
- WFIFOB(fd, 8) = sd->status.inventory[n].identify;
+ WFIFOW(s, 0) = 0xa0;
+ WFIFOW(s, 2) = n + 2;
+ WFIFOW(s, 4) = amount;
+ WFIFOW(s, 6) = sd->status.inventory[n].nameid;
+ WFIFOB(s, 8) = sd->status.inventory[n].identify;
if (sd->status.inventory[n].broken == 1)
- WFIFOB(fd, 9) = 1; // is weapon broken [Valaris]
+ WFIFOB(s, 9) = 1; // is weapon broken [Valaris]
else
- WFIFOB(fd, 9) = sd->status.inventory[n].attribute;
- WFIFOB(fd, 10) = sd->status.inventory[n].refine;
+ WFIFOB(s, 9) = sd->status.inventory[n].attribute;
+ WFIFOB(s, 10) = sd->status.inventory[n].refine;
if (sd->status.inventory[n].card[0] == 0x00ff
|| sd->status.inventory[n].card[0] == 0x00fe
|| sd->status.inventory[n].card[0] == static_cast<short>(0xff00))
{
- WFIFOW(fd, 11) = sd->status.inventory[n].card[0];
- WFIFOW(fd, 13) = sd->status.inventory[n].card[1];
- WFIFOW(fd, 15) = sd->status.inventory[n].card[2];
- WFIFOW(fd, 17) = sd->status.inventory[n].card[3];
+ WFIFOW(s, 11) = sd->status.inventory[n].card[0];
+ WFIFOW(s, 13) = sd->status.inventory[n].card[1];
+ WFIFOW(s, 15) = sd->status.inventory[n].card[2];
+ WFIFOW(s, 17) = sd->status.inventory[n].card[3];
}
else
{
- WFIFOW(fd, 11) = sd->status.inventory[n].card[0];
- WFIFOW(fd, 13) = sd->status.inventory[n].card[1];
- WFIFOW(fd, 15) = sd->status.inventory[n].card[2];
- WFIFOW(fd, 17) = sd->status.inventory[n].card[3];
+ WFIFOW(s, 11) = sd->status.inventory[n].card[0];
+ WFIFOW(s, 13) = sd->status.inventory[n].card[1];
+ WFIFOW(s, 15) = sd->status.inventory[n].card[2];
+ WFIFOW(s, 17) = sd->status.inventory[n].card[3];
}
- WFIFOW(fd, 19) = uint16_t(pc_equippoint(sd, n));
- WFIFOB(fd, 21) = uint8_t(sd->inventory_data[n]->type == ItemType::_7
+ WFIFOW(s, 19) = uint16_t(pc_equippoint(sd, n));
+ WFIFOB(s, 21) = uint8_t(sd->inventory_data[n]->type == ItemType::_7
? ItemType::WEAPON
: sd->inventory_data[n]->type);
- WFIFOB(fd, 22) = uint8_t(fail);
+ WFIFOB(s, 22) = uint8_t(fail);
}
- WFIFOSET(fd, clif_parse_func_table[0xa0].len);
+ WFIFOSET(s, clif_parse_func_table[0xa0].len);
return 0;
}
@@ -1415,12 +1408,12 @@ void clif_delitem(dumb_ptr<map_session_data> sd, int n, int amount)
{
nullpo_retv(sd);
- int fd = sd->fd;
- WFIFOW(fd, 0) = 0xaf;
- WFIFOW(fd, 2) = n + 2;
- WFIFOW(fd, 4) = amount;
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0xaf;
+ WFIFOW(s, 2) = n + 2;
+ WFIFOW(s, 4) = amount;
- WFIFOSET(fd, clif_parse_func_table[0xaf].len);
+ WFIFOSET(s, clif_parse_func_table[0xaf].len);
}
/*==========================================
@@ -1433,37 +1426,37 @@ void clif_itemlist(dumb_ptr<map_session_data> sd)
int n = 0;
int arrow = -1;
- int fd = sd->fd;
- WFIFOW(fd, 0) = 0x1ee;
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0x1ee;
for (int i = 0; i < MAX_INVENTORY; i++)
{
if (sd->status.inventory[i].nameid <= 0
|| sd->inventory_data[i] == NULL
|| itemdb_isequip2(sd->inventory_data[i]))
continue;
- WFIFOW(fd, n * 18 + 4) = i + 2;
- WFIFOW(fd, n * 18 + 6) = sd->status.inventory[i].nameid;
- WFIFOB(fd, n * 18 + 8) = uint8_t(sd->inventory_data[i]->type);
- WFIFOB(fd, n * 18 + 9) = sd->status.inventory[i].identify;
- WFIFOW(fd, n * 18 + 10) = sd->status.inventory[i].amount;
+ WFIFOW(s, n * 18 + 4) = i + 2;
+ WFIFOW(s, n * 18 + 6) = sd->status.inventory[i].nameid;
+ WFIFOB(s, n * 18 + 8) = uint8_t(sd->inventory_data[i]->type);
+ WFIFOB(s, n * 18 + 9) = sd->status.inventory[i].identify;
+ WFIFOW(s, n * 18 + 10) = sd->status.inventory[i].amount;
if (sd->inventory_data[i]->equip == EPOS::ARROW)
{
- WFIFOW(fd, n * 18 + 12) = uint16_t(EPOS::ARROW);
+ WFIFOW(s, n * 18 + 12) = uint16_t(EPOS::ARROW);
if (bool(sd->status.inventory[i].equip))
arrow = i; // ついでに矢装備チェック
}
else
- WFIFOW(fd, n * 18 + 12) = uint16_t(EPOS::ZERO);
- WFIFOW(fd, n * 18 + 14) = sd->status.inventory[i].card[0];
- WFIFOW(fd, n * 18 + 16) = sd->status.inventory[i].card[1];
- WFIFOW(fd, n * 18 + 18) = sd->status.inventory[i].card[2];
- WFIFOW(fd, n * 18 + 20) = sd->status.inventory[i].card[3];
+ WFIFOW(s, n * 18 + 12) = uint16_t(EPOS::ZERO);
+ WFIFOW(s, n * 18 + 14) = sd->status.inventory[i].card[0];
+ WFIFOW(s, n * 18 + 16) = sd->status.inventory[i].card[1];
+ WFIFOW(s, n * 18 + 18) = sd->status.inventory[i].card[2];
+ WFIFOW(s, n * 18 + 20) = sd->status.inventory[i].card[3];
n++;
}
if (n)
{
- WFIFOW(fd, 2) = 4 + n * 18;
- WFIFOSET(fd, WFIFOW(fd, 2));
+ WFIFOW(s, 2) = 4 + n * 18;
+ WFIFOSET(s, WFIFOW(s, 2));
}
if (arrow >= 0)
clif_arrowequip(sd, arrow);
@@ -1477,8 +1470,8 @@ void clif_equiplist(dumb_ptr<map_session_data> sd)
{
nullpo_retv(sd);
- int fd = sd->fd;
- WFIFOW(fd, 0) = 0xa4;
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0xa4;
int n = 0;
for (int i = 0; i < MAX_INVENTORY; i++)
{
@@ -1486,42 +1479,42 @@ void clif_equiplist(dumb_ptr<map_session_data> sd)
|| sd->inventory_data[i] == NULL
|| !itemdb_isequip2(sd->inventory_data[i]))
continue;
- WFIFOW(fd, n * 20 + 4) = i + 2;
- WFIFOW(fd, n * 20 + 6) = sd->status.inventory[i].nameid;
- WFIFOB(fd, n * 20 + 8) = uint8_t(
+ WFIFOW(s, n * 20 + 4) = i + 2;
+ WFIFOW(s, n * 20 + 6) = sd->status.inventory[i].nameid;
+ WFIFOB(s, n * 20 + 8) = uint8_t(
sd->inventory_data[i]->type == ItemType::_7
? ItemType::WEAPON
: sd->inventory_data[i]->type);
- WFIFOB(fd, n * 20 + 9) = sd->status.inventory[i].identify;
- WFIFOW(fd, n * 20 + 10) = uint16_t(pc_equippoint(sd, i));
- WFIFOW(fd, n * 20 + 12) = uint16_t(sd->status.inventory[i].equip);
+ WFIFOB(s, n * 20 + 9) = sd->status.inventory[i].identify;
+ WFIFOW(s, n * 20 + 10) = uint16_t(pc_equippoint(sd, i));
+ WFIFOW(s, n * 20 + 12) = uint16_t(sd->status.inventory[i].equip);
if (sd->status.inventory[i].broken == 1)
- WFIFOB(fd, n * 20 + 14) = 1; // is weapon broken [Valaris]
+ WFIFOB(s, n * 20 + 14) = 1; // is weapon broken [Valaris]
else
- WFIFOB(fd, n * 20 + 14) = sd->status.inventory[i].attribute;
- WFIFOB(fd, n * 20 + 15) = sd->status.inventory[i].refine;
+ WFIFOB(s, n * 20 + 14) = sd->status.inventory[i].attribute;
+ WFIFOB(s, n * 20 + 15) = sd->status.inventory[i].refine;
if (sd->status.inventory[i].card[0] == 0x00ff
|| sd->status.inventory[i].card[0] == 0x00fe
|| sd->status.inventory[i].card[0] == static_cast<short>(0xff00))
{
- WFIFOW(fd, n * 20 + 16) = sd->status.inventory[i].card[0];
- WFIFOW(fd, n * 20 + 18) = sd->status.inventory[i].card[1];
- WFIFOW(fd, n * 20 + 20) = sd->status.inventory[i].card[2];
- WFIFOW(fd, n * 20 + 22) = sd->status.inventory[i].card[3];
+ WFIFOW(s, n * 20 + 16) = sd->status.inventory[i].card[0];
+ WFIFOW(s, n * 20 + 18) = sd->status.inventory[i].card[1];
+ WFIFOW(s, n * 20 + 20) = sd->status.inventory[i].card[2];
+ WFIFOW(s, n * 20 + 22) = sd->status.inventory[i].card[3];
}
else
{
- WFIFOW(fd, n * 20 + 16) = sd->status.inventory[i].card[0];
- WFIFOW(fd, n * 20 + 18) = sd->status.inventory[i].card[1];
- WFIFOW(fd, n * 20 + 20) = sd->status.inventory[i].card[2];
- WFIFOW(fd, n * 20 + 22) = sd->status.inventory[i].card[3];
+ WFIFOW(s, n * 20 + 16) = sd->status.inventory[i].card[0];
+ WFIFOW(s, n * 20 + 18) = sd->status.inventory[i].card[1];
+ WFIFOW(s, n * 20 + 20) = sd->status.inventory[i].card[2];
+ WFIFOW(s, n * 20 + 22) = sd->status.inventory[i].card[3];
}
n++;
}
if (n)
{
- WFIFOW(fd, 2) = 4 + n * 20;
- WFIFOSET(fd, WFIFOW(fd, 2));
+ WFIFOW(s, 2) = 4 + n * 20;
+ WFIFOSET(s, WFIFOW(s, 2));
}
}
@@ -1534,8 +1527,8 @@ int clif_storageitemlist(dumb_ptr<map_session_data> sd, struct storage *stor)
nullpo_ret(sd);
nullpo_ret(stor);
- int fd = sd->fd;
- WFIFOW(fd, 0) = 0x1f0;
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0x1f0;
int n = 0;
for (int i = 0; i < MAX_STORAGE; i++)
{
@@ -1548,22 +1541,22 @@ int clif_storageitemlist(dumb_ptr<map_session_data> sd, struct storage *stor)
if (itemdb_isequip2(id))
continue;
- WFIFOW(fd, n * 18 + 4) = i + 1;
- WFIFOW(fd, n * 18 + 6) = stor->storage_[i].nameid;
- WFIFOB(fd, n * 18 + 8) = uint8_t(id->type);
- WFIFOB(fd, n * 18 + 9) = stor->storage_[i].identify;
- WFIFOW(fd, n * 18 + 10) = stor->storage_[i].amount;
- WFIFOW(fd, n * 18 + 12) = 0;
- WFIFOW(fd, n * 18 + 14) = stor->storage_[i].card[0];
- WFIFOW(fd, n * 18 + 16) = stor->storage_[i].card[1];
- WFIFOW(fd, n * 18 + 18) = stor->storage_[i].card[2];
- WFIFOW(fd, n * 18 + 20) = stor->storage_[i].card[3];
+ WFIFOW(s, n * 18 + 4) = i + 1;
+ WFIFOW(s, n * 18 + 6) = stor->storage_[i].nameid;
+ WFIFOB(s, n * 18 + 8) = uint8_t(id->type);
+ WFIFOB(s, n * 18 + 9) = stor->storage_[i].identify;
+ WFIFOW(s, n * 18 + 10) = stor->storage_[i].amount;
+ WFIFOW(s, n * 18 + 12) = 0;
+ WFIFOW(s, n * 18 + 14) = stor->storage_[i].card[0];
+ WFIFOW(s, n * 18 + 16) = stor->storage_[i].card[1];
+ WFIFOW(s, n * 18 + 18) = stor->storage_[i].card[2];
+ WFIFOW(s, n * 18 + 20) = stor->storage_[i].card[3];
n++;
}
if (n)
{
- WFIFOW(fd, 2) = 4 + n * 18;
- WFIFOSET(fd, WFIFOW(fd, 2));
+ WFIFOW(s, 2) = 4 + n * 18;
+ WFIFOSET(s, WFIFOW(s, 2));
}
return 0;
}
@@ -1577,8 +1570,8 @@ int clif_storageequiplist(dumb_ptr<map_session_data> sd, struct storage *stor)
nullpo_ret(sd);
nullpo_ret(stor);
- int fd = sd->fd;
- WFIFOW(fd, 0) = 0xa6;
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0xa6;
int n = 0;
for (int i = 0; i < MAX_STORAGE; i++)
{
@@ -1590,39 +1583,39 @@ int clif_storageequiplist(dumb_ptr<map_session_data> sd, struct storage *stor)
nullpo_ret(id);
if (!itemdb_isequip2(id))
continue;
- WFIFOW(fd, n * 20 + 4) = i + 1;
- WFIFOW(fd, n * 20 + 6) = stor->storage_[i].nameid;
- WFIFOB(fd, n * 20 + 8) = uint8_t(id->type);
- WFIFOB(fd, n * 20 + 9) = stor->storage_[i].identify;
- WFIFOW(fd, n * 20 + 10) = uint16_t(id->equip);
- WFIFOW(fd, n * 20 + 12) = uint16_t(stor->storage_[i].equip);
+ WFIFOW(s, n * 20 + 4) = i + 1;
+ WFIFOW(s, n * 20 + 6) = stor->storage_[i].nameid;
+ WFIFOB(s, n * 20 + 8) = uint8_t(id->type);
+ WFIFOB(s, n * 20 + 9) = stor->storage_[i].identify;
+ WFIFOW(s, n * 20 + 10) = uint16_t(id->equip);
+ WFIFOW(s, n * 20 + 12) = uint16_t(stor->storage_[i].equip);
if (stor->storage_[i].broken == 1)
- WFIFOB(fd, n * 20 + 14) = 1; //is weapon broken [Valaris]
+ WFIFOB(s, n * 20 + 14) = 1; //is weapon broken [Valaris]
else
- WFIFOB(fd, n * 20 + 14) = stor->storage_[i].attribute;
- WFIFOB(fd, n * 20 + 15) = stor->storage_[i].refine;
+ WFIFOB(s, n * 20 + 14) = stor->storage_[i].attribute;
+ WFIFOB(s, n * 20 + 15) = stor->storage_[i].refine;
if (stor->storage_[i].card[0] == 0x00ff
|| stor->storage_[i].card[0] == 0x00fe
|| stor->storage_[i].card[0] == static_cast<short>(0xff00))
{
- WFIFOW(fd, n * 20 + 16) = stor->storage_[i].card[0];
- WFIFOW(fd, n * 20 + 18) = stor->storage_[i].card[1];
- WFIFOW(fd, n * 20 + 20) = stor->storage_[i].card[2];
- WFIFOW(fd, n * 20 + 22) = stor->storage_[i].card[3];
+ WFIFOW(s, n * 20 + 16) = stor->storage_[i].card[0];
+ WFIFOW(s, n * 20 + 18) = stor->storage_[i].card[1];
+ WFIFOW(s, n * 20 + 20) = stor->storage_[i].card[2];
+ WFIFOW(s, n * 20 + 22) = stor->storage_[i].card[3];
}
else
{
- WFIFOW(fd, n * 20 + 16) = stor->storage_[i].card[0];
- WFIFOW(fd, n * 20 + 18) = stor->storage_[i].card[1];
- WFIFOW(fd, n * 20 + 20) = stor->storage_[i].card[2];
- WFIFOW(fd, n * 20 + 22) = stor->storage_[i].card[3];
+ WFIFOW(s, n * 20 + 16) = stor->storage_[i].card[0];
+ WFIFOW(s, n * 20 + 18) = stor->storage_[i].card[1];
+ WFIFOW(s, n * 20 + 20) = stor->storage_[i].card[2];
+ WFIFOW(s, n * 20 + 22) = stor->storage_[i].card[3];
}
n++;
}
if (n)
{
- WFIFOW(fd, 2) = 4 + n * 20;
- WFIFOSET(fd, WFIFOW(fd, 2));
+ WFIFOW(s, 2) = 4 + n * 20;
+ WFIFOSET(s, WFIFOW(s, 2));
}
return 0;
}
@@ -1634,117 +1627,117 @@ int clif_storageequiplist(dumb_ptr<map_session_data> sd, struct storage *stor)
*/
int clif_updatestatus(dumb_ptr<map_session_data> sd, SP type)
{
- int fd, len = 8;
+ int len = 8;
nullpo_ret(sd);
- fd = sd->fd;
+ Session *s = sd->sess;
- WFIFOW(fd, 0) = 0xb0;
- WFIFOW(fd, 2) = static_cast<uint16_t>(type);
+ WFIFOW(s, 0) = 0xb0;
+ WFIFOW(s, 2) = static_cast<uint16_t>(type);
switch (type)
{
// 00b0
case SP::WEIGHT:
pc_checkweighticon(sd);
// is this because pc_checkweighticon can send other packets?
- WFIFOW(fd, 0) = 0xb0;
- WFIFOW(fd, 2) = static_cast<uint16_t>(type);
- WFIFOL(fd, 4) = sd->weight;
+ WFIFOW(s, 0) = 0xb0;
+ WFIFOW(s, 2) = static_cast<uint16_t>(type);
+ WFIFOL(s, 4) = sd->weight;
break;
case SP::MAXWEIGHT:
- WFIFOL(fd, 4) = sd->max_weight;
+ WFIFOL(s, 4) = sd->max_weight;
break;
case SP::SPEED:
// ...
- WFIFOL(fd, 4) = static_cast<uint16_t>(sd->speed.count());
+ WFIFOL(s, 4) = static_cast<uint16_t>(sd->speed.count());
break;
case SP::BASELEVEL:
- WFIFOL(fd, 4) = sd->status.base_level;
+ WFIFOL(s, 4) = sd->status.base_level;
break;
case SP::JOBLEVEL:
- WFIFOL(fd, 4) = 0;
+ WFIFOL(s, 4) = 0;
break;
case SP::STATUSPOINT:
- WFIFOL(fd, 4) = sd->status.status_point;
+ WFIFOL(s, 4) = sd->status.status_point;
break;
case SP::SKILLPOINT:
- WFIFOL(fd, 4) = sd->status.skill_point;
+ WFIFOL(s, 4) = sd->status.skill_point;
break;
case SP::HIT:
- WFIFOL(fd, 4) = sd->hit;
+ WFIFOL(s, 4) = sd->hit;
break;
case SP::FLEE1:
- WFIFOL(fd, 4) = sd->flee;
+ WFIFOL(s, 4) = sd->flee;
break;
case SP::FLEE2:
- WFIFOL(fd, 4) = sd->flee2 / 10;
+ WFIFOL(s, 4) = sd->flee2 / 10;
break;
case SP::MAXHP:
- WFIFOL(fd, 4) = sd->status.max_hp;
+ WFIFOL(s, 4) = sd->status.max_hp;
break;
case SP::MAXSP:
- WFIFOL(fd, 4) = sd->status.max_sp;
+ WFIFOL(s, 4) = sd->status.max_sp;
break;
case SP::HP:
- WFIFOL(fd, 4) = sd->status.hp;
+ WFIFOL(s, 4) = sd->status.hp;
break;
case SP::SP:
- WFIFOL(fd, 4) = sd->status.sp;
+ WFIFOL(s, 4) = sd->status.sp;
break;
case SP::ASPD:
- WFIFOL(fd, 4) = static_cast<uint16_t>(sd->aspd.count());
+ WFIFOL(s, 4) = static_cast<uint16_t>(sd->aspd.count());
break;
case SP::ATK1:
- WFIFOL(fd, 4) = sd->base_atk + sd->watk;
+ WFIFOL(s, 4) = sd->base_atk + sd->watk;
break;
case SP::DEF1:
- WFIFOL(fd, 4) = sd->def;
+ WFIFOL(s, 4) = sd->def;
break;
case SP::MDEF1:
- WFIFOL(fd, 4) = sd->mdef;
+ WFIFOL(s, 4) = sd->mdef;
break;
case SP::ATK2:
- WFIFOL(fd, 4) = sd->watk2;
+ WFIFOL(s, 4) = sd->watk2;
break;
case SP::DEF2:
- WFIFOL(fd, 4) = sd->def2;
+ WFIFOL(s, 4) = sd->def2;
break;
case SP::MDEF2:
- WFIFOL(fd, 4) = sd->mdef2;
+ WFIFOL(s, 4) = sd->mdef2;
break;
case SP::CRITICAL:
- WFIFOL(fd, 4) = sd->critical / 10;
+ WFIFOL(s, 4) = sd->critical / 10;
break;
case SP::MATK1:
- WFIFOL(fd, 4) = sd->matk1;
+ WFIFOL(s, 4) = sd->matk1;
break;
case SP::MATK2:
- WFIFOL(fd, 4) = sd->matk2;
+ WFIFOL(s, 4) = sd->matk2;
break;
case SP::ZENY:
trade_verifyzeny(sd);
- WFIFOW(fd, 0) = 0xb1;
+ WFIFOW(s, 0) = 0xb1;
if (sd->status.zeny < 0)
sd->status.zeny = 0;
- WFIFOL(fd, 4) = sd->status.zeny;
+ WFIFOL(s, 4) = sd->status.zeny;
break;
case SP::BASEEXP:
- WFIFOW(fd, 0) = 0xb1;
- WFIFOL(fd, 4) = sd->status.base_exp;
+ WFIFOW(s, 0) = 0xb1;
+ WFIFOL(s, 4) = sd->status.base_exp;
break;
case SP::JOBEXP:
- WFIFOW(fd, 0) = 0xb1;
- WFIFOL(fd, 4) = sd->status.job_exp;
+ WFIFOW(s, 0) = 0xb1;
+ WFIFOL(s, 4) = sd->status.job_exp;
break;
case SP::NEXTBASEEXP:
- WFIFOW(fd, 0) = 0xb1;
- WFIFOL(fd, 4) = pc_nextbaseexp(sd);
+ WFIFOW(s, 0) = 0xb1;
+ WFIFOL(s, 4) = pc_nextbaseexp(sd);
break;
case SP::NEXTJOBEXP:
- WFIFOW(fd, 0) = 0xb1;
- WFIFOL(fd, 4) = pc_nextjobexp(sd);
+ WFIFOW(s, 0) = 0xb1;
+ WFIFOL(s, 4) = pc_nextjobexp(sd);
break;
// 00be 終了
@@ -1754,15 +1747,15 @@ int clif_updatestatus(dumb_ptr<map_session_data> sd, SP type)
case SP::UINT:
case SP::UDEX:
case SP::ULUK:
- WFIFOW(fd, 0) = 0xbe;
- WFIFOB(fd, 4) = pc_need_status_point(sd, usp_to_sp(type));
+ WFIFOW(s, 0) = 0xbe;
+ WFIFOB(s, 4) = pc_need_status_point(sd, usp_to_sp(type));
len = 5;
break;
// 013a 終了
case SP::ATTACKRANGE:
- WFIFOW(fd, 0) = 0x13a;
- WFIFOW(fd, 2) = (sd->attack_spell_override)
+ WFIFOW(s, 0) = 0x13a;
+ WFIFOW(s, 2) = (sd->attack_spell_override)
? sd->attack_spell_range : sd->attackrange;
len = 4;
break;
@@ -1776,16 +1769,16 @@ int clif_updatestatus(dumb_ptr<map_session_data> sd, SP type)
case SP::LUK:
{
ATTR attr = sp_to_attr(type);
- WFIFOW(fd, 0) = 0x141;
- WFIFOL(fd, 2) = uint16_t(type);
- WFIFOL(fd, 6) = sd->status.attrs[attr];
- WFIFOL(fd, 10) = sd->paramb[attr] + sd->parame[attr];
+ WFIFOW(s, 0) = 0x141;
+ WFIFOL(s, 2) = uint16_t(type);
+ WFIFOL(s, 6) = sd->status.attrs[attr];
+ WFIFOL(s, 10) = sd->paramb[attr] + sd->parame[attr];
len = 14;
}
break;
case SP::GM:
- WFIFOL(fd, 4) = pc_isGM(sd);
+ WFIFOL(s, 4) = pc_isGM(sd);
break;
default:
@@ -1794,7 +1787,7 @@ int clif_updatestatus(dumb_ptr<map_session_data> sd, SP type)
type);
return 1;
}
- WFIFOSET(fd, len);
+ WFIFOSET(s, len);
return 0;
}
@@ -1894,40 +1887,40 @@ int clif_initialstatus(dumb_ptr<map_session_data> sd)
{
nullpo_ret(sd);
- int fd = sd->fd;
-
- WFIFOW(fd, 0) = 0xbd;
- WFIFOW(fd, 2) = sd->status.status_point;
-
- WFIFOB(fd, 4) = min(sd->status.attrs[ATTR::STR], 255);
- WFIFOB(fd, 5) = pc_need_status_point(sd, SP::STR);
- WFIFOB(fd, 6) = min(sd->status.attrs[ATTR::AGI], 255);
- WFIFOB(fd, 7) = pc_need_status_point(sd, SP::AGI);
- WFIFOB(fd, 8) = min(sd->status.attrs[ATTR::VIT], 255);
- WFIFOB(fd, 9) = pc_need_status_point(sd, SP::VIT);
- WFIFOB(fd, 10) = min(sd->status.attrs[ATTR::INT], 255);
- WFIFOB(fd, 11) = pc_need_status_point(sd, SP::INT);
- WFIFOB(fd, 12) = min(sd->status.attrs[ATTR::DEX], 255);
- WFIFOB(fd, 13) = pc_need_status_point(sd, SP::DEX);
- WFIFOB(fd, 14) = min(sd->status.attrs[ATTR::LUK], 255);
- WFIFOB(fd, 15) = pc_need_status_point(sd, SP::LUK);
-
- WFIFOW(fd, 16) = sd->base_atk + sd->watk;
- WFIFOW(fd, 18) = sd->watk2; //atk bonus
- WFIFOW(fd, 20) = sd->matk1;
- WFIFOW(fd, 22) = sd->matk2;
- WFIFOW(fd, 24) = sd->def; // def
- WFIFOW(fd, 26) = sd->def2;
- WFIFOW(fd, 28) = sd->mdef; // mdef
- WFIFOW(fd, 30) = sd->mdef2;
- WFIFOW(fd, 32) = sd->hit;
- WFIFOW(fd, 34) = sd->flee;
- WFIFOW(fd, 36) = sd->flee2 / 10;
- WFIFOW(fd, 38) = sd->critical / 10;
- WFIFOW(fd, 40) = sd->status.karma;
- WFIFOW(fd, 42) = sd->status.manner;
-
- WFIFOSET(fd, clif_parse_func_table[0xbd].len);
+ Session *s = sd->sess;
+
+ WFIFOW(s, 0) = 0xbd;
+ WFIFOW(s, 2) = sd->status.status_point;
+
+ WFIFOB(s, 4) = min(sd->status.attrs[ATTR::STR], 255);
+ WFIFOB(s, 5) = pc_need_status_point(sd, SP::STR);
+ WFIFOB(s, 6) = min(sd->status.attrs[ATTR::AGI], 255);
+ WFIFOB(s, 7) = pc_need_status_point(sd, SP::AGI);
+ WFIFOB(s, 8) = min(sd->status.attrs[ATTR::VIT], 255);
+ WFIFOB(s, 9) = pc_need_status_point(sd, SP::VIT);
+ WFIFOB(s, 10) = min(sd->status.attrs[ATTR::INT], 255);
+ WFIFOB(s, 11) = pc_need_status_point(sd, SP::INT);
+ WFIFOB(s, 12) = min(sd->status.attrs[ATTR::DEX], 255);
+ WFIFOB(s, 13) = pc_need_status_point(sd, SP::DEX);
+ WFIFOB(s, 14) = min(sd->status.attrs[ATTR::LUK], 255);
+ WFIFOB(s, 15) = pc_need_status_point(sd, SP::LUK);
+
+ WFIFOW(s, 16) = sd->base_atk + sd->watk;
+ WFIFOW(s, 18) = sd->watk2; //atk bonus
+ WFIFOW(s, 20) = sd->matk1;
+ WFIFOW(s, 22) = sd->matk2;
+ WFIFOW(s, 24) = sd->def; // def
+ WFIFOW(s, 26) = sd->def2;
+ WFIFOW(s, 28) = sd->mdef; // mdef
+ WFIFOW(s, 30) = sd->mdef2;
+ WFIFOW(s, 32) = sd->hit;
+ WFIFOW(s, 34) = sd->flee;
+ WFIFOW(s, 36) = sd->flee2 / 10;
+ WFIFOW(s, 38) = sd->critical / 10;
+ WFIFOW(s, 40) = sd->status.karma;
+ WFIFOW(s, 42) = sd->status.manner;
+
+ WFIFOSET(s, clif_parse_func_table[0xbd].len);
clif_updatestatus(sd, SP::STR);
clif_updatestatus(sd, SP::AGI);
@@ -1948,18 +1941,16 @@ int clif_initialstatus(dumb_ptr<map_session_data> sd)
*/
int clif_arrowequip(dumb_ptr<map_session_data> sd, int val)
{
- int fd;
-
nullpo_ret(sd);
if (sd->attacktarget && sd->attacktarget > 0) // [Valaris]
sd->attacktarget = 0;
- fd = sd->fd;
- WFIFOW(fd, 0) = 0x013c;
- WFIFOW(fd, 2) = val + 2; //矢のアイテムID
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0x013c;
+ WFIFOW(s, 2) = val + 2; //矢のアイテムID
- WFIFOSET(fd, clif_parse_func_table[0x013c].len);
+ WFIFOSET(s, clif_parse_func_table[0x013c].len);
return 0;
}
@@ -1970,15 +1961,14 @@ int clif_arrowequip(dumb_ptr<map_session_data> sd, int val)
*/
int clif_arrow_fail(dumb_ptr<map_session_data> sd, int type)
{
- int fd;
-
nullpo_ret(sd);
- fd = sd->fd;
- WFIFOW(fd, 0) = 0x013b;
- WFIFOW(fd, 2) = type;
+ Session *s = sd->sess;
+
+ WFIFOW(s, 0) = 0x013b;
+ WFIFOW(s, 2) = type;
- WFIFOSET(fd, clif_parse_func_table[0x013b].len);
+ WFIFOSET(s, clif_parse_func_table[0x013b].len);
return 0;
}
@@ -1989,16 +1979,14 @@ int clif_arrow_fail(dumb_ptr<map_session_data> sd, int type)
*/
int clif_statusupack(dumb_ptr<map_session_data> sd, SP type, int ok, int val)
{
- int fd;
-
nullpo_ret(sd);
- fd = sd->fd;
- WFIFOW(fd, 0) = 0xbc;
- WFIFOW(fd, 2) = uint16_t(type);
- WFIFOB(fd, 4) = ok;
- WFIFOB(fd, 5) = val;
- WFIFOSET(fd, clif_parse_func_table[0xbc].len);
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0xbc;
+ WFIFOW(s, 2) = uint16_t(type);
+ WFIFOB(s, 4) = ok;
+ WFIFOB(s, 5) = val;
+ WFIFOSET(s, clif_parse_func_table[0xbc].len);
return 0;
}
@@ -2009,16 +1997,14 @@ int clif_statusupack(dumb_ptr<map_session_data> sd, SP type, int ok, int val)
*/
int clif_equipitemack(dumb_ptr<map_session_data> sd, int n, EPOS pos, int ok)
{
- int fd;
-
nullpo_ret(sd);
- fd = sd->fd;
- WFIFOW(fd, 0) = 0xaa;
- WFIFOW(fd, 2) = n + 2;
- WFIFOW(fd, 4) = uint16_t(pos);
- WFIFOB(fd, 6) = ok;
- WFIFOSET(fd, clif_parse_func_table[0xaa].len);
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0xaa;
+ WFIFOW(s, 2) = n + 2;
+ WFIFOW(s, 4) = uint16_t(pos);
+ WFIFOB(s, 6) = ok;
+ WFIFOSET(s, clif_parse_func_table[0xaa].len);
return 0;
}
@@ -2029,16 +2015,14 @@ int clif_equipitemack(dumb_ptr<map_session_data> sd, int n, EPOS pos, int ok)
*/
int clif_unequipitemack(dumb_ptr<map_session_data> sd, int n, EPOS pos, int ok)
{
- int fd;
-
nullpo_ret(sd);
- fd = sd->fd;
- WFIFOW(fd, 0) = 0xac;
- WFIFOW(fd, 2) = n + 2;
- WFIFOW(fd, 4) = uint16_t(pos);
- WFIFOB(fd, 6) = ok;
- WFIFOSET(fd, clif_parse_func_table[0xac].len);
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0xac;
+ WFIFOW(s, 2) = n + 2;
+ WFIFOW(s, 4) = uint16_t(pos);
+ WFIFOB(s, 6) = ok;
+ WFIFOSET(s, clif_parse_func_table[0xac].len);
return 0;
}
@@ -2099,12 +2083,12 @@ int clif_useitemack(dumb_ptr<map_session_data> sd, int index, int amount,
if (!ok)
{
- int fd = sd->fd;
- WFIFOW(fd, 0) = 0xa8;
- WFIFOW(fd, 2) = index + 2;
- WFIFOW(fd, 4) = amount;
- WFIFOB(fd, 6) = ok;
- WFIFOSET(fd, clif_parse_func_table[0xa8].len);
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0xa8;
+ WFIFOW(s, 2) = index + 2;
+ WFIFOW(s, 4) = amount;
+ WFIFOB(s, 6) = ok;
+ WFIFOSET(s, clif_parse_func_table[0xa8].len);
}
else
{
@@ -2130,10 +2114,10 @@ void clif_traderequest(dumb_ptr<map_session_data> sd, CharName name)
{
nullpo_retv(sd);
- int fd = sd->fd;
- WFIFOW(fd, 0) = 0xe5;
- WFIFO_STRING(fd, 2, name.to__actual(), 24);
- WFIFOSET(fd, clif_parse_func_table[0xe5].len);
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0xe5;
+ WFIFO_STRING(s, 2, name.to__actual(), 24);
+ WFIFOSET(s, clif_parse_func_table[0xe5].len);
}
/*==========================================
@@ -2144,10 +2128,10 @@ void clif_tradestart(dumb_ptr<map_session_data> sd, int type)
{
nullpo_retv(sd);
- int fd = sd->fd;
- WFIFOW(fd, 0) = 0xe7;
- WFIFOB(fd, 2) = type;
- WFIFOSET(fd, clif_parse_func_table[0xe7].len);
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0xe7;
+ WFIFOB(s, 2) = type;
+ WFIFOSET(s, clif_parse_func_table[0xe7].len);
}
/*==========================================
@@ -2160,48 +2144,48 @@ void clif_tradeadditem(dumb_ptr<map_session_data> sd,
nullpo_retv(sd);
nullpo_retv(tsd);
- int fd = tsd->fd;
- WFIFOW(fd, 0) = 0xe9;
- WFIFOL(fd, 2) = amount;
+ Session *s = tsd->sess;
+ WFIFOW(s, 0) = 0xe9;
+ WFIFOL(s, 2) = amount;
if (index == 0)
{
- WFIFOW(fd, 6) = 0; // type id
- WFIFOB(fd, 8) = 0; //identify flag
- WFIFOB(fd, 9) = 0; // attribute
- WFIFOB(fd, 10) = 0; //refine
- WFIFOW(fd, 11) = 0; //card (4w)
- WFIFOW(fd, 13) = 0; //card (4w)
- WFIFOW(fd, 15) = 0; //card (4w)
- WFIFOW(fd, 17) = 0; //card (4w)
+ WFIFOW(s, 6) = 0; // type id
+ WFIFOB(s, 8) = 0; //identify flag
+ WFIFOB(s, 9) = 0; // attribute
+ WFIFOB(s, 10) = 0; //refine
+ WFIFOW(s, 11) = 0; //card (4w)
+ WFIFOW(s, 13) = 0; //card (4w)
+ WFIFOW(s, 15) = 0; //card (4w)
+ WFIFOW(s, 17) = 0; //card (4w)
}
else
{
index -= 2;
- WFIFOW(fd, 6) = sd->status.inventory[index].nameid; // type id
- WFIFOB(fd, 8) = sd->status.inventory[index].identify; //identify flag
+ WFIFOW(s, 6) = sd->status.inventory[index].nameid; // type id
+ WFIFOB(s, 8) = sd->status.inventory[index].identify; //identify flag
if (sd->status.inventory[index].broken == 1)
- WFIFOB(fd, 9) = 1; // is broke weapon [Valaris]
+ WFIFOB(s, 9) = 1; // is broke weapon [Valaris]
else
- WFIFOB(fd, 9) = sd->status.inventory[index].attribute; // attribute
- WFIFOB(fd, 10) = sd->status.inventory[index].refine; //refine
+ WFIFOB(s, 9) = sd->status.inventory[index].attribute; // attribute
+ WFIFOB(s, 10) = sd->status.inventory[index].refine; //refine
if (sd->status.inventory[index].card[0] == 0x00ff
|| sd->status.inventory[index].card[0] == 0x00fe
|| sd->status.inventory[index].card[0] == static_cast<short>(0xff00))
{
- WFIFOW(fd, 11) = sd->status.inventory[index].card[0]; //card (4w)
- WFIFOW(fd, 13) = sd->status.inventory[index].card[1]; //card (4w)
- WFIFOW(fd, 15) = sd->status.inventory[index].card[2]; //card (4w)
- WFIFOW(fd, 17) = sd->status.inventory[index].card[3]; //card (4w)
+ WFIFOW(s, 11) = sd->status.inventory[index].card[0]; //card (4w)
+ WFIFOW(s, 13) = sd->status.inventory[index].card[1]; //card (4w)
+ WFIFOW(s, 15) = sd->status.inventory[index].card[2]; //card (4w)
+ WFIFOW(s, 17) = sd->status.inventory[index].card[3]; //card (4w)
}
else
{
- WFIFOW(fd, 11) = sd->status.inventory[index].card[0];
- WFIFOW(fd, 13) = sd->status.inventory[index].card[1];
- WFIFOW(fd, 15) = sd->status.inventory[index].card[2];
- WFIFOW(fd, 17) = sd->status.inventory[index].card[3];
+ WFIFOW(s, 11) = sd->status.inventory[index].card[0];
+ WFIFOW(s, 13) = sd->status.inventory[index].card[1];
+ WFIFOW(s, 15) = sd->status.inventory[index].card[2];
+ WFIFOW(s, 17) = sd->status.inventory[index].card[3];
}
}
- WFIFOSET(fd, clif_parse_func_table[0xe9].len);
+ WFIFOSET(s, clif_parse_func_table[0xe9].len);
}
/*==========================================
@@ -2211,16 +2195,14 @@ void clif_tradeadditem(dumb_ptr<map_session_data> sd,
int clif_tradeitemok(dumb_ptr<map_session_data> sd, int index, int amount,
int fail)
{
- int fd;
-
nullpo_ret(sd);
- fd = sd->fd;
- WFIFOW(fd, 0) = 0x1b1;
- WFIFOW(fd, 2) = index;
- WFIFOW(fd, 4) = amount;
- WFIFOB(fd, 6) = fail;
- WFIFOSET(fd, clif_parse_func_table[0x1b1].len);
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0x1b1;
+ WFIFOW(s, 2) = index;
+ WFIFOW(s, 4) = amount;
+ WFIFOB(s, 6) = fail;
+ WFIFOSET(s, clif_parse_func_table[0x1b1].len);
return 0;
}
@@ -2231,14 +2213,12 @@ int clif_tradeitemok(dumb_ptr<map_session_data> sd, int index, int amount,
*/
int clif_tradedeal_lock(dumb_ptr<map_session_data> sd, int fail)
{
- int fd;
-
nullpo_ret(sd);
- fd = sd->fd;
- WFIFOW(fd, 0) = 0xec;
- WFIFOB(fd, 2) = fail; // 0=you 1=the other person
- WFIFOSET(fd, clif_parse_func_table[0xec].len);
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0xec;
+ WFIFOB(s, 2) = fail; // 0=you 1=the other person
+ WFIFOSET(s, clif_parse_func_table[0xec].len);
return 0;
}
@@ -2249,13 +2229,11 @@ int clif_tradedeal_lock(dumb_ptr<map_session_data> sd, int fail)
*/
int clif_tradecancelled(dumb_ptr<map_session_data> sd)
{
- int fd;
-
nullpo_ret(sd);
- fd = sd->fd;
- WFIFOW(fd, 0) = 0xee;
- WFIFOSET(fd, clif_parse_func_table[0xee].len);
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0xee;
+ WFIFOSET(s, clif_parse_func_table[0xee].len);
return 0;
}
@@ -2266,14 +2244,12 @@ int clif_tradecancelled(dumb_ptr<map_session_data> sd)
*/
int clif_tradecompleted(dumb_ptr<map_session_data> sd, int fail)
{
- int fd;
-
nullpo_ret(sd);
- fd = sd->fd;
- WFIFOW(fd, 0) = 0xf0;
- WFIFOB(fd, 2) = fail;
- WFIFOSET(fd, clif_parse_func_table[0xf0].len);
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0xf0;
+ WFIFOB(s, 2) = fail;
+ WFIFOSET(s, clif_parse_func_table[0xf0].len);
return 0;
}
@@ -2285,16 +2261,14 @@ int clif_tradecompleted(dumb_ptr<map_session_data> sd, int fail)
int clif_updatestorageamount(dumb_ptr<map_session_data> sd,
struct storage *stor)
{
- int fd;
-
nullpo_ret(sd);
nullpo_ret(stor);
- fd = sd->fd;
- WFIFOW(fd, 0) = 0xf2; // update storage amount
- WFIFOW(fd, 2) = stor->storage_amount; //items
- WFIFOW(fd, 4) = MAX_STORAGE; //items max
- WFIFOSET(fd, clif_parse_func_table[0xf2].len);
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0xf2; // update storage amount
+ WFIFOW(s, 2) = stor->storage_amount; //items
+ WFIFOW(s, 4) = MAX_STORAGE; //items max
+ WFIFOSET(s, clif_parse_func_table[0xf2].len);
return 0;
}
@@ -2309,37 +2283,37 @@ int clif_storageitemadded(dumb_ptr<map_session_data> sd, struct storage *stor,
nullpo_ret(sd);
nullpo_ret(stor);
- int fd = sd->fd;
- WFIFOW(fd, 0) = 0xf4; // Storage item added
- WFIFOW(fd, 2) = index + 1; // index
- WFIFOL(fd, 4) = amount; // amount
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0xf4; // Storage item added
+ WFIFOW(s, 2) = index + 1; // index
+ WFIFOL(s, 4) = amount; // amount
/* if ((view = itemdb_viewid(stor->storage_[index].nameid)) > 0)
WFIFOW(fd,8) =view;
else*/
- WFIFOW(fd, 8) = stor->storage_[index].nameid;
- WFIFOB(fd, 10) = stor->storage_[index].identify; //identify flag
+ WFIFOW(s, 8) = stor->storage_[index].nameid;
+ WFIFOB(s, 10) = stor->storage_[index].identify; //identify flag
if (stor->storage_[index].broken == 1)
- WFIFOB(fd, 11) = 1; // is weapon broken [Valaris]
+ WFIFOB(s, 11) = 1; // is weapon broken [Valaris]
else
- WFIFOB(fd, 11) = stor->storage_[index].attribute; // attribute
- WFIFOB(fd, 12) = stor->storage_[index].refine; //refine
+ WFIFOB(s, 11) = stor->storage_[index].attribute; // attribute
+ WFIFOB(s, 12) = stor->storage_[index].refine; //refine
if (stor->storage_[index].card[0] == 0x00ff
|| stor->storage_[index].card[0] == 0x00fe
|| stor->storage_[index].card[0] == static_cast<short>(0xff00))
{
- WFIFOW(fd, 13) = stor->storage_[index].card[0]; //card (4w)
- WFIFOW(fd, 15) = stor->storage_[index].card[1]; //card (4w)
- WFIFOW(fd, 17) = stor->storage_[index].card[2]; //card (4w)
- WFIFOW(fd, 19) = stor->storage_[index].card[3]; //card (4w)
+ WFIFOW(s, 13) = stor->storage_[index].card[0]; //card (4w)
+ WFIFOW(s, 15) = stor->storage_[index].card[1]; //card (4w)
+ WFIFOW(s, 17) = stor->storage_[index].card[2]; //card (4w)
+ WFIFOW(s, 19) = stor->storage_[index].card[3]; //card (4w)
}
else
{
- WFIFOW(fd, 13) = stor->storage_[index].card[0];
- WFIFOW(fd, 15) = stor->storage_[index].card[1];
- WFIFOW(fd, 17) = stor->storage_[index].card[2];
- WFIFOW(fd, 19) = stor->storage_[index].card[3];
+ WFIFOW(s, 13) = stor->storage_[index].card[0];
+ WFIFOW(s, 15) = stor->storage_[index].card[1];
+ WFIFOW(s, 17) = stor->storage_[index].card[2];
+ WFIFOW(s, 19) = stor->storage_[index].card[3];
}
- WFIFOSET(fd, clif_parse_func_table[0xf4].len);
+ WFIFOSET(s, clif_parse_func_table[0xf4].len);
return 0;
}
@@ -2351,15 +2325,13 @@ int clif_storageitemadded(dumb_ptr<map_session_data> sd, struct storage *stor,
int clif_storageitemremoved(dumb_ptr<map_session_data> sd, int index,
int amount)
{
- int fd;
-
nullpo_ret(sd);
- fd = sd->fd;
- WFIFOW(fd, 0) = 0xf6; // Storage item removed
- WFIFOW(fd, 2) = index + 1;
- WFIFOL(fd, 4) = amount;
- WFIFOSET(fd, clif_parse_func_table[0xf6].len);
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0xf6; // Storage item removed
+ WFIFOW(s, 2) = index + 1;
+ WFIFOL(s, 4) = amount;
+ WFIFOSET(s, clif_parse_func_table[0xf6].len);
return 0;
}
@@ -2370,13 +2342,11 @@ int clif_storageitemremoved(dumb_ptr<map_session_data> sd, int index,
*/
int clif_storageclose(dumb_ptr<map_session_data> sd)
{
- int fd;
-
nullpo_ret(sd);
- fd = sd->fd;
- WFIFOW(fd, 0) = 0xf8; // Storage Closed
- WFIFOSET(fd, clif_parse_func_table[0xf8].len);
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0xf8; // Storage Closed
+ WFIFOSET(s, clif_parse_func_table[0xf8].len);
return 0;
}
@@ -2416,8 +2386,8 @@ void clif_getareachar_pc(dumb_ptr<map_session_data> sd,
{
len = clif_set0078(dstsd, buf);
}
- WFIFO_BUF_CLONE(sd->fd, buf, len);
- WFIFOSET(sd->fd, len);
+ WFIFO_BUF_CLONE(sd->sess, buf, len);
+ WFIFOSET(sd->sess, len);
if (battle_config.save_clothcolor == 1 && dstsd->status.clothes_color > 0)
clif_changelook(dstsd, LOOK::CLOTHES_COLOR,
@@ -2442,8 +2412,8 @@ void clif_getareachar_npc(dumb_ptr<map_session_data> sd, dumb_ptr<npc_data> nd)
if (nd->npc_class < 0 || nd->flag & 1 || nd->npc_class == INVISIBLE_CLASS)
return;
- len = clif_npc0078(nd, static_cast<uint8_t *>(WFIFOP(sd->fd, 0)));
- WFIFOSET(sd->fd, len);
+ len = clif_npc0078(nd, static_cast<uint8_t *>(WFIFOP(sd->sess, 0)));
+ WFIFOSET(sd->sess, len);
}
/*==========================================
@@ -2558,13 +2528,13 @@ void clif_getareachar_mob(dumb_ptr<map_session_data> sd, dumb_ptr<mob_data> md)
if (md->state.state == MS::WALK)
{
- len = clif_mob007b(md, static_cast<uint8_t *>(WFIFOP(sd->fd, 0)));
- WFIFOSET(sd->fd, len);
+ len = clif_mob007b(md, static_cast<uint8_t *>(WFIFOP(sd->sess, 0)));
+ WFIFOSET(sd->sess, len);
}
else
{
- len = clif_mob0078(md, static_cast<uint8_t *>(WFIFOP(sd->fd, 0)));
- WFIFOSET(sd->fd, len);
+ len = clif_mob0078(md, static_cast<uint8_t *>(WFIFOP(sd->sess, 0)));
+ WFIFOSET(sd->sess, len);
}
}
@@ -2579,19 +2549,19 @@ void clif_getareachar_item(dumb_ptr<map_session_data> sd,
nullpo_retv(sd);
nullpo_retv(fitem);
- int fd = sd->fd;
+ Session *s = sd->sess;
//009d <ID>.l <item ID>.w <identify flag>.B <X>.w <Y>.w <amount>.w <subX>.B <subY>.B
- WFIFOW(fd, 0) = 0x9d;
- WFIFOL(fd, 2) = fitem->bl_id;
- WFIFOW(fd, 6) = fitem->item_data.nameid;
- WFIFOB(fd, 8) = fitem->item_data.identify;
- WFIFOW(fd, 9) = fitem->bl_x;
- WFIFOW(fd, 11) = fitem->bl_y;
- WFIFOW(fd, 13) = fitem->item_data.amount;
- WFIFOB(fd, 15) = fitem->subx;
- WFIFOB(fd, 16) = fitem->suby;
+ WFIFOW(s, 0) = 0x9d;
+ WFIFOL(s, 2) = fitem->bl_id;
+ WFIFOW(s, 6) = fitem->item_data.nameid;
+ WFIFOB(s, 8) = fitem->item_data.identify;
+ WFIFOW(s, 9) = fitem->bl_x;
+ WFIFOW(s, 11) = fitem->bl_y;
+ WFIFOW(s, 13) = fitem->item_data.amount;
+ WFIFOB(s, 15) = fitem->subx;
+ WFIFOB(s, 16) = fitem->suby;
- WFIFOSET(fd, clif_parse_func_table[0x9d].len);
+ WFIFOSET(s, clif_parse_func_table[0x9d].len);
}
/*==========================================
@@ -2650,19 +2620,19 @@ void clif_pcoutsight(dumb_ptr<block_list> bl, dumb_ptr<map_session_data> sd)
dstsd = bl->is_player();
if (sd != dstsd)
{
- clif_clearchar_id(dstsd->bl_id, BeingRemoveWhy::GONE, sd->fd);
- clif_clearchar_id(sd->bl_id, BeingRemoveWhy::GONE, dstsd->fd);
+ clif_clearchar_id(dstsd->bl_id, BeingRemoveWhy::GONE, sd->sess);
+ clif_clearchar_id(sd->bl_id, BeingRemoveWhy::GONE, dstsd->sess);
}
break;
case BL::NPC:
if (bl->is_npc()->npc_class != INVISIBLE_CLASS)
- clif_clearchar_id(bl->bl_id, BeingRemoveWhy::GONE, sd->fd);
+ clif_clearchar_id(bl->bl_id, BeingRemoveWhy::GONE, sd->sess);
break;
case BL::MOB:
- clif_clearchar_id(bl->bl_id, BeingRemoveWhy::GONE, sd->fd);
+ clif_clearchar_id(bl->bl_id, BeingRemoveWhy::GONE, sd->sess);
break;
case BL::ITEM:
- clif_clearflooritem(bl->is_item(), sd->fd);
+ clif_clearflooritem(bl->is_item(), sd->sess);
break;
}
}
@@ -2714,7 +2684,7 @@ void clif_moboutsight(dumb_ptr<block_list> bl, dumb_ptr<mob_data> md)
if (bl->bl_type == BL::PC)
{
sd = bl->is_player();
- clif_clearchar_id(md->bl_id, BeingRemoveWhy::GONE, sd->fd);
+ clif_clearchar_id(md->bl_id, BeingRemoveWhy::GONE, sd->sess);
}
}
@@ -2743,34 +2713,32 @@ void clif_mobinsight(dumb_ptr<block_list> bl, dumb_ptr<mob_data> md)
int clif_skillinfo(dumb_ptr<map_session_data> sd, SkillID skillid, int type,
int range)
{
- int fd;
-
nullpo_ret(sd);
- fd = sd->fd;
+ Session *s = sd->sess;
if (!sd->status.skill[skillid].lv)
return 0;
- WFIFOW(fd, 0) = 0x147;
- WFIFOW(fd, 2) = static_cast<uint16_t>(skillid);
+ WFIFOW(s, 0) = 0x147;
+ WFIFOW(s, 2) = static_cast<uint16_t>(skillid);
if (type < 0)
- WFIFOW(fd, 4) = skill_get_inf(skillid);
+ WFIFOW(s, 4) = skill_get_inf(skillid);
else
- WFIFOW(fd, 4) = type;
- WFIFOW(fd, 6) = 0;
- WFIFOW(fd, 8) = sd->status.skill[skillid].lv;
- WFIFOW(fd, 10) = skill_get_sp(skillid, sd->status.skill[skillid].lv);
+ WFIFOW(s, 4) = type;
+ WFIFOW(s, 6) = 0;
+ WFIFOW(s, 8) = sd->status.skill[skillid].lv;
+ WFIFOW(s, 10) = skill_get_sp(skillid, sd->status.skill[skillid].lv);
if (range < 0)
{
range = skill_get_range(skillid, sd->status.skill[skillid].lv);
if (range < 0)
range = battle_get_range(sd) - (range + 1);
- WFIFOW(fd, 12) = range;
+ WFIFOW(s, 12) = range;
}
else
- WFIFOW(fd, 12) = range;
- WFIFO_ZERO(fd, 14, 24);
- WFIFOB(fd, 38) = sd->status.skill[skillid].lv < skill_get_max_raise(skillid);
- WFIFOSET(fd, clif_parse_func_table[0x147].len);
+ WFIFOW(s, 12) = range;
+ WFIFO_ZERO(s, 14, 24);
+ WFIFOB(s, 38) = sd->status.skill[skillid].lv < skill_get_max_raise(skillid);
+ WFIFOSET(s, clif_parse_func_table[0x147].len);
return 0;
}
@@ -2781,36 +2749,35 @@ int clif_skillinfo(dumb_ptr<map_session_data> sd, SkillID skillid, int type,
*/
void clif_skillinfoblock(dumb_ptr<map_session_data> sd)
{
- int fd;
int len = 4, range;
nullpo_retv(sd);
- fd = sd->fd;
- WFIFOW(fd, 0) = 0x10f;
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0x10f;
for (SkillID i : erange(SkillID(), MAX_SKILL))
{
if (sd->status.skill[i].lv && sd->tmw_version >= 1)
{
// [Fate] Version 1 and later don't crash because of bad skill IDs anymore
- WFIFOW(fd, len) = static_cast<uint16_t>(i);
- WFIFOW(fd, len + 2) = skill_get_inf(i);
- WFIFOW(fd, len + 4) = static_cast<uint16_t>(
+ WFIFOW(s, len) = static_cast<uint16_t>(i);
+ WFIFOW(s, len + 2) = skill_get_inf(i);
+ WFIFOW(s, len + 4) = static_cast<uint16_t>(
skill_db[i].poolflags
| (sd->status.skill[i].flags & SkillFlags::POOL_ACTIVATED));
- WFIFOW(fd, len + 6) = sd->status.skill[i].lv;
- WFIFOW(fd, len + 8) = skill_get_sp(i, sd->status.skill[i].lv);
+ WFIFOW(s, len + 6) = sd->status.skill[i].lv;
+ WFIFOW(s, len + 8) = skill_get_sp(i, sd->status.skill[i].lv);
range = skill_get_range(i, sd->status.skill[i].lv);
if (range < 0)
range = battle_get_range(sd) - (range + 1);
- WFIFOW(fd, len + 10) = range;
- WFIFO_ZERO(fd, len + 12, 24);
- WFIFOB(fd, len + 36) = sd->status.skill[i].lv < skill_get_max_raise(i);
+ WFIFOW(s, len + 10) = range;
+ WFIFO_ZERO(s, len + 12, 24);
+ WFIFOB(s, len + 36) = sd->status.skill[i].lv < skill_get_max_raise(i);
len += 37;
}
}
- WFIFOW(fd, 2) = len;
- WFIFOSET(fd, len);
+ WFIFOW(s, 2) = len;
+ WFIFOSET(s, len);
}
/*==========================================
@@ -2819,21 +2786,21 @@ void clif_skillinfoblock(dumb_ptr<map_session_data> sd)
*/
int clif_skillup(dumb_ptr<map_session_data> sd, SkillID skill_num)
{
- int range, fd;
+ int range;
nullpo_ret(sd);
- fd = sd->fd;
- WFIFOW(fd, 0) = 0x10e;
- WFIFOW(fd, 2) = uint16_t(skill_num);
- WFIFOW(fd, 4) = sd->status.skill[skill_num].lv;
- WFIFOW(fd, 6) = skill_get_sp(skill_num, sd->status.skill[skill_num].lv);
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0x10e;
+ WFIFOW(s, 2) = uint16_t(skill_num);
+ WFIFOW(s, 4) = sd->status.skill[skill_num].lv;
+ WFIFOW(s, 6) = skill_get_sp(skill_num, sd->status.skill[skill_num].lv);
range = skill_get_range(skill_num, sd->status.skill[skill_num].lv);
if (range < 0)
range = battle_get_range(sd) - (range + 1);
- WFIFOW(fd, 8) = range;
- WFIFOB(fd, 10) = sd->status.skill[skill_num].lv < skill_get_max_raise(skill_num);
- WFIFOSET(fd, clif_parse_func_table[0x10e].len);
+ WFIFOW(s, 8) = range;
+ WFIFOB(s, 10) = sd->status.skill[skill_num].lv < skill_get_max_raise(skill_num);
+ WFIFOSET(s, clif_parse_func_table[0x10e].len);
return 0;
}
@@ -2862,24 +2829,22 @@ int clif_skillcastcancel(dumb_ptr<block_list> bl)
int clif_skill_fail(dumb_ptr<map_session_data> sd, SkillID skill_id, int type,
int btype)
{
- int fd;
-
nullpo_ret(sd);
- fd = sd->fd;
+ Session *s = sd->sess;
if (type == 0x4 && battle_config.display_delay_skill_fail == 0)
{
return 0;
}
- WFIFOW(fd, 0) = 0x110;
- WFIFOW(fd, 2) = uint16_t(skill_id);
- WFIFOW(fd, 4) = btype;
- WFIFOW(fd, 6) = 0;
- WFIFOB(fd, 8) = 0;
- WFIFOB(fd, 9) = type;
- WFIFOSET(fd, clif_parse_func_table[0x110].len);
+ WFIFOW(s, 0) = 0x110;
+ WFIFOW(s, 2) = uint16_t(skill_id);
+ WFIFOW(s, 4) = btype;
+ WFIFOW(s, 6) = 0;
+ WFIFOB(s, 8) = 0;
+ WFIFOB(s, 9) = type;
+ WFIFOSET(s, clif_parse_func_table[0x110].len);
return 0;
}
@@ -2938,16 +2903,16 @@ int clif_status_change(dumb_ptr<block_list> bl, StatusChange type, int flag)
* Send message (modified by [Yor])
*------------------------------------------
*/
-void clif_displaymessage(int fd, XString mes)
+void clif_displaymessage(Session *s, XString mes)
{
if (mes)
{
// don't send a void message (it's not displaying on the client chat). @help can send void line.
- WFIFOW(fd, 0) = 0x8e;
+ WFIFOW(s, 0) = 0x8e;
size_t str_len = mes.size() + 1; // NUL (might not be NUL yet)
- WFIFOW(fd, 2) = 4 + str_len;
- WFIFO_STRING(fd, 4, mes, str_len);
- WFIFOSET(fd, 4 + str_len);
+ WFIFOW(s, 2) = 4 + str_len;
+ WFIFO_STRING(s, 4, mes, str_len);
+ WFIFOSET(s, 4 + str_len);
}
}
@@ -2993,25 +2958,25 @@ void clif_resurrection(dumb_ptr<block_list> bl, int type)
* Wisp/page is transmitted to the destination player
*------------------------------------------
*/
-void clif_wis_message(int fd, CharName nick, XString mes) // R 0097 <len>.w <nick>.24B <message>.?B
+void clif_wis_message(Session *s, CharName nick, XString mes) // R 0097 <len>.w <nick>.24B <message>.?B
{
size_t mes_len = mes.size() + 1;
- WFIFOW(fd, 0) = 0x97;
- WFIFOW(fd, 2) = mes_len + 24 + 4;
- WFIFO_STRING(fd, 4, nick.to__actual(), 24);
- WFIFO_STRING(fd, 28, mes, mes_len);
- WFIFOSET(fd, WFIFOW(fd, 2));
+ WFIFOW(s, 0) = 0x97;
+ WFIFOW(s, 2) = mes_len + 24 + 4;
+ WFIFO_STRING(s, 4, nick.to__actual(), 24);
+ WFIFO_STRING(s, 28, mes, mes_len);
+ WFIFOSET(s, WFIFOW(s, 2));
}
/*==========================================
* The transmission result of Wisp/page is transmitted to the source player
*------------------------------------------
*/
-void clif_wis_end(int fd, int flag) // R 0098 <type>.B: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
+void clif_wis_end(Session *s, int flag) // R 0098 <type>.B: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
{
- WFIFOW(fd, 0) = 0x98;
- WFIFOW(fd, 2) = flag;
- WFIFOSET(fd, clif_parse_func_table[0x98].len);
+ WFIFOW(s, 0) = 0x98;
+ WFIFOW(s, 2) = flag;
+ WFIFOSET(s, clif_parse_func_table[0x98].len);
}
/*==========================================
@@ -3028,14 +2993,12 @@ void clif_wis_end(int fd, int flag) // R 0098 <type>.B: 0: success to send wispe
*/
int clif_party_created(dumb_ptr<map_session_data> sd, int flag)
{
- int fd;
-
nullpo_ret(sd);
- fd = sd->fd;
- WFIFOW(fd, 0) = 0xfa;
- WFIFOB(fd, 2) = flag;
- WFIFOSET(fd, clif_parse_func_table[0xfa].len);
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0xfa;
+ WFIFOB(s, 2) = flag;
+ WFIFOSET(s, clif_parse_func_table[0xfa].len);
return 0;
}
@@ -3043,7 +3006,7 @@ int clif_party_created(dumb_ptr<map_session_data> sd, int flag)
* パーティ情報送信
*------------------------------------------
*/
-int clif_party_info(struct party *p, int fd)
+int clif_party_info(struct party *p, Session *s)
{
unsigned char buf[1024];
int i, c;
@@ -3070,11 +3033,11 @@ int clif_party_info(struct party *p, int fd)
}
size_t len = 28 + c * 46;
WBUFW(buf, 2) = len;
- if (fd >= 0)
+ if (s)
{
// If set, send only to fd.
- WFIFO_BUF_CLONE(fd, buf, len);
- WFIFOSET(fd, len);
+ WFIFO_BUF_CLONE(s, buf, len);
+ WFIFOSET(s, len);
return 9;
}
// else, send it to all the party, if they exist.
@@ -3093,21 +3056,20 @@ int clif_party_info(struct party *p, int fd)
void clif_party_invite(dumb_ptr<map_session_data> sd,
dumb_ptr<map_session_data> tsd)
{
- int fd;
struct party *p;
nullpo_retv(sd);
nullpo_retv(tsd);
- fd = tsd->fd;
+ Session *s = tsd->sess;
if (!(p = party_search(sd->status.party_id)))
return;
- WFIFOW(fd, 0) = 0xfe;
- WFIFOL(fd, 2) = sd->status.account_id;
- WFIFO_STRING(fd, 6, p->name, 24);
- WFIFOSET(fd, clif_parse_func_table[0xfe].len);
+ WFIFOW(s, 0) = 0xfe;
+ WFIFOL(s, 2) = sd->status.account_id;
+ WFIFO_STRING(s, 6, p->name, 24);
+ WFIFOSET(s, clif_parse_func_table[0xfe].len);
}
/*==========================================
@@ -3128,11 +3090,11 @@ void clif_party_inviteack(dumb_ptr<map_session_data> sd, CharName nick, int flag
{
nullpo_retv(sd);
- int fd = sd->fd;
- WFIFOW(fd, 0) = 0xfd;
- WFIFO_STRING(fd, 2, nick.to__actual(), 24);
- WFIFOB(fd, 26) = flag;
- WFIFOSET(fd, clif_parse_func_table[0xfd].len);
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0xfd;
+ WFIFO_STRING(s, 2, nick.to__actual(), 24);
+ WFIFOB(s, 26) = flag;
+ WFIFOSET(s, clif_parse_func_table[0xfd].len);
}
/*==========================================
@@ -3166,8 +3128,8 @@ void clif_party_option(struct party *p, dumb_ptr<map_session_data> sd, int flag)
clif_send(buf, clif_parse_func_table[0x101].len, sd, SendWho::PARTY);
else
{
- WFIFO_BUF_CLONE(sd->fd, buf, clif_parse_func_table[0x101].len);
- WFIFOSET(sd->fd, clif_parse_func_table[0x101].len);
+ WFIFO_BUF_CLONE(sd->sess, buf, clif_parse_func_table[0x101].len);
+ WFIFOSET(sd->sess, clif_parse_func_table[0x101].len);
}
}
@@ -3202,8 +3164,8 @@ void clif_party_leaved(struct party *p, dumb_ptr<map_session_data> sd,
}
else if (sd != NULL)
{
- WFIFO_BUF_CLONE(sd->fd, buf, clif_parse_func_table[0x105].len);
- WFIFOSET(sd->fd, clif_parse_func_table[0x105].len);
+ WFIFO_BUF_CLONE(sd->sess, buf, clif_parse_func_table[0x105].len);
+ WFIFOSET(sd->sess, clif_parse_func_table[0x105].len);
}
}
@@ -3284,20 +3246,18 @@ int clif_party_hp(struct party *, dumb_ptr<map_session_data> sd)
*/
int clif_movetoattack(dumb_ptr<map_session_data> sd, dumb_ptr<block_list> bl)
{
- int fd;
-
nullpo_ret(sd);
nullpo_ret(bl);
- fd = sd->fd;
- WFIFOW(fd, 0) = 0x139;
- WFIFOL(fd, 2) = bl->bl_id;
- WFIFOW(fd, 6) = bl->bl_x;
- WFIFOW(fd, 8) = bl->bl_y;
- WFIFOW(fd, 10) = sd->bl_x;
- WFIFOW(fd, 12) = sd->bl_y;
- WFIFOW(fd, 14) = sd->attackrange;
- WFIFOSET(fd, clif_parse_func_table[0x139].len);
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0x139;
+ WFIFOL(s, 2) = bl->bl_id;
+ WFIFOW(s, 6) = bl->bl_x;
+ WFIFOW(s, 8) = bl->bl_y;
+ WFIFOW(s, 10) = sd->bl_x;
+ WFIFOW(s, 12) = sd->bl_y;
+ WFIFOW(s, 14) = sd->attackrange;
+ WFIFOSET(s, clif_parse_func_table[0x139].len);
return 0;
}
@@ -3351,15 +3311,15 @@ void clif_emotion_towards(dumb_ptr<block_list> bl,
WBUFL(buf, 2) = bl->bl_id;
WBUFB(buf, 6) = type;
- WFIFO_BUF_CLONE(sd->fd, buf, len);
- WFIFOSET(sd->fd, len);
+ WFIFO_BUF_CLONE(sd->sess, buf, len);
+ WFIFOSET(sd->sess, len);
}
/*==========================================
* 座る
*------------------------------------------
*/
-void clif_sitting(int, dumb_ptr<map_session_data> sd)
+void clif_sitting(Session *, dumb_ptr<map_session_data> sd)
{
unsigned char buf[64];
@@ -3378,19 +3338,17 @@ void clif_sitting(int, dumb_ptr<map_session_data> sd)
static
int clif_GM_kickack(dumb_ptr<map_session_data> sd, int id)
{
- int fd;
-
nullpo_ret(sd);
- fd = sd->fd;
- WFIFOW(fd, 0) = 0xcd;
- WFIFOL(fd, 2) = id;
- WFIFOSET(fd, clif_parse_func_table[0xcd].len);
+ Session *s = sd->sess;
+ WFIFOW(s, 0) = 0xcd;
+ WFIFOL(s, 2) = id;
+ WFIFOSET(s, clif_parse_func_table[0xcd].len);
return 0;
}
static
-void clif_parse_QuitGame(int fd, dumb_ptr<map_session_data> sd);
+void clif_parse_QuitGame(Session *s, dumb_ptr<map_session_data> sd);
int clif_GM_kick(dumb_ptr<map_session_data> sd, dumb_ptr<map_session_data> tsd,
int type)
@@ -3401,7 +3359,7 @@ int clif_GM_kick(dumb_ptr<map_session_data> sd, dumb_ptr<map_session_data> tsd,
clif_GM_kickack(sd, tsd->status.account_id);
tsd->opt1 = Opt1::ZERO;
tsd->opt2 = Opt2::ZERO;
- clif_parse_QuitGame(tsd->fd, tsd);
+ clif_parse_QuitGame(tsd->sess, tsd);
return 0;
}
@@ -3448,7 +3406,7 @@ int clif_specialeffect(dumb_ptr<block_list> bl, int type, int flag)
*------------------------------------------
*/
static
-void clif_parse_WantToConnection(int fd, dumb_ptr<map_session_data> sd)
+void clif_parse_WantToConnection(Session *s, dumb_ptr<map_session_data> sd)
{
int account_id; // account_id in the packet
@@ -3459,34 +3417,34 @@ void clif_parse_WantToConnection(int fd, dumb_ptr<map_session_data> sd)
return;
}
- if (RFIFOW(fd, 0) == 0x72)
+ if (RFIFOW(s, 0) == 0x72)
{
- account_id = RFIFOL(fd, 2);
+ account_id = RFIFOL(s, 2);
}
else
return; // Not the auth packet
- WFIFOL(fd, 0) = account_id;
- WFIFOSET(fd, 4);
+ WFIFOL(s, 0) = account_id;
+ WFIFOSET(s, 4);
// if same account already connected, we disconnect the 2 sessions
dumb_ptr<map_session_data> old_sd = map_id2sd(account_id);
if (old_sd)
{
- clif_authfail_fd(fd, 2); // same id
- clif_authfail_fd(old_sd->fd, 2); // same id
+ clif_authfail_fd(s, 2); // same id
+ clif_authfail_fd(old_sd->sess, 2); // same id
PRINTF("clif_parse_WantToConnection: Double connection for account %d (sessions: #%d (new) and #%d (old)).\n",
- account_id, fd, old_sd->fd);
+ account_id, s, old_sd->sess);
}
else
{
sd.new_();
- session[fd]->session_data.reset(sd.operator->());
- sd->fd = fd;
+ s->session_data.reset(sd.operator->());
+ sd->sess = s;
- pc_setnewpc(sd, account_id, RFIFOL(fd, 6), RFIFOL(fd, 10),
- tick_t(static_cast<interval_t>(RFIFOL(fd, 14))),
- static_cast<SEX>(RFIFOB(fd, 18)));
+ pc_setnewpc(sd, account_id, RFIFOL(s, 6), RFIFOL(s, 10),
+ tick_t(static_cast<interval_t>(RFIFOL(s, 14))),
+ static_cast<SEX>(RFIFOB(s, 18)));
map_addiddb(sd);
@@ -3502,7 +3460,7 @@ void clif_parse_WantToConnection(int fd, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_LoadEndAck(int, dumb_ptr<map_session_data> sd)
+void clif_parse_LoadEndAck(Session *, dumb_ptr<map_session_data> sd)
{
// struct item_data* item;
int i;
@@ -3608,11 +3566,11 @@ void clif_parse_LoadEndAck(int, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_TickSend(int fd, dumb_ptr<map_session_data> sd)
+void clif_parse_TickSend(Session *s, dumb_ptr<map_session_data> sd)
{
nullpo_retv(sd);
- sd->client_tick = tick_t(static_cast<interval_t>(RFIFOL(fd, 2)));
+ sd->client_tick = tick_t(static_cast<interval_t>(RFIFOL(s, 2)));
sd->server_tick = gettick();
clif_servertick(sd);
}
@@ -3622,7 +3580,7 @@ void clif_parse_TickSend(int fd, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_WalkToXY(int fd, dumb_ptr<map_session_data> sd)
+void clif_parse_WalkToXY(Session *s, dumb_ptr<map_session_data> sd)
{
int x, y;
@@ -3649,8 +3607,8 @@ void clif_parse_WalkToXY(int fd, dumb_ptr<map_session_data> sd)
pc_stopattack(sd);
- x = RFIFOB(fd, 2) * 4 + (RFIFOB(fd, 3) >> 6);
- y = ((RFIFOB(fd, 3) & 0x3f) << 4) + (RFIFOB(fd, 4) >> 4);
+ x = RFIFOB(s, 2) * 4 + (RFIFOB(s, 3) >> 6);
+ y = ((RFIFOB(s, 3) & 0x3f) << 4) + (RFIFOB(s, 4) >> 4);
pc_walktoxy(sd, x, y);
}
@@ -3659,18 +3617,18 @@ void clif_parse_WalkToXY(int fd, dumb_ptr<map_session_data> sd)
*
*------------------------------------------
*/
-void clif_parse_QuitGame(int fd, dumb_ptr<map_session_data> sd)
+void clif_parse_QuitGame(Session *s, dumb_ptr<map_session_data> sd)
{
tick_t tick = gettick();
nullpo_retv(sd);
- WFIFOW(fd, 0) = 0x18b;
+ WFIFOW(s, 0) = 0x18b;
if ((!pc_isdead(sd) && (sd->opt1 != Opt1::ZERO || sd->opt2 != Opt2::ZERO))
|| (tick < sd->canact_tick))
{
- WFIFOW(fd, 2) = 1;
- WFIFOSET(fd, clif_parse_func_table[0x18b].len);
+ WFIFOW(s, 2) = 1;
+ WFIFOSET(s, clif_parse_func_table[0x18b].len);
return;
}
@@ -3678,14 +3636,14 @@ void clif_parse_QuitGame(int fd, dumb_ptr<map_session_data> sd)
if (!battle_config.prevent_logout
|| tick >= sd->canlog_tick + std::chrono::seconds(10))
{
- clif_setwaitclose(fd);
- WFIFOW(fd, 2) = 0;
+ clif_setwaitclose(s);
+ WFIFOW(s, 2) = 0;
}
else
{
- WFIFOW(fd, 2) = 1;
+ WFIFOW(s, 2) = 1;
}
- WFIFOSET(fd, clif_parse_func_table[0x18b].len);
+ WFIFOSET(s, clif_parse_func_table[0x18b].len);
}
@@ -3694,18 +3652,18 @@ void clif_parse_QuitGame(int fd, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_GetCharNameRequest(int fd, dumb_ptr<map_session_data> sd)
+void clif_parse_GetCharNameRequest(Session *s, dumb_ptr<map_session_data> sd)
{
dumb_ptr<block_list> bl;
int account_id;
- account_id = RFIFOL(fd, 2);
+ account_id = RFIFOL(s, 2);
bl = map_id2bl(account_id);
if (bl == NULL)
return;
- WFIFOW(fd, 0) = 0x95;
- WFIFOL(fd, 2) = account_id;
+ WFIFOW(s, 0) = 0x95;
+ WFIFOL(s, 2) = account_id;
switch (bl->bl_type)
{
@@ -3716,10 +3674,10 @@ void clif_parse_GetCharNameRequest(int fd, dumb_ptr<map_session_data> sd)
nullpo_retv(ssd);
if (ssd->state.shroud_active)
- WFIFO_STRING(fd, 6, "", 24);
+ WFIFO_STRING(s, 6, "", 24);
else
- WFIFO_STRING(fd, 6, ssd->status.name.to__actual(), 24);
- WFIFOSET(fd, clif_parse_func_table[0x95].len);
+ WFIFO_STRING(s, 6, ssd->status.name.to__actual(), 24);
+ WFIFOSET(s, clif_parse_func_table[0x95].len);
struct party *p = NULL;
@@ -3735,28 +3693,28 @@ void clif_parse_GetCharNameRequest(int fd, dumb_ptr<map_session_data> sd)
if (send)
{
- WFIFOW(fd, 0) = 0x195;
- WFIFOL(fd, 2) = account_id;
- WFIFO_STRING(fd, 6, party_name, 24);
- WFIFO_STRING(fd, 30, "", 24);
- WFIFO_STRING(fd, 54, "", 24);
- WFIFO_STRING(fd, 78, "", 24); // We send this value twice because the client expects it
- WFIFOSET(fd, clif_parse_func_table[0x195].len);
+ WFIFOW(s, 0) = 0x195;
+ WFIFOL(s, 2) = account_id;
+ WFIFO_STRING(s, 6, party_name, 24);
+ WFIFO_STRING(s, 30, "", 24);
+ WFIFO_STRING(s, 54, "", 24);
+ WFIFO_STRING(s, 78, "", 24); // We send this value twice because the client expects it
+ WFIFOSET(s, clif_parse_func_table[0x195].len);
}
if (pc_isGM(sd) >= battle_config.hack_info_GM_level)
{
IP4Address ip = ssd->get_ip();
- WFIFOW(fd, 0) = 0x20C;
+ WFIFOW(s, 0) = 0x20C;
// Mask the IP using the char-server password
if (battle_config.mask_ip_gms)
ip = MD5_ip(ip);
- WFIFOL(fd, 2) = account_id;
- WFIFOIP(fd, 6) = ip;
- WFIFOSET(fd, clif_parse_func_table[0x20C].len);
+ WFIFOL(s, 2) = account_id;
+ WFIFOIP(s, 6) = ip;
+ WFIFOSET(s, clif_parse_func_table[0x20C].len);
}
}
@@ -3766,8 +3724,8 @@ void clif_parse_GetCharNameRequest(int fd, dumb_ptr<map_session_data> sd)
NpcName name = bl->is_npc()->name;
// [fate] elim hashed out/invisible names for the client
auto it = std::find(name.begin(), name.end(), '#');
- WFIFO_STRING(fd, 6, name.xislice_h(it), 24);
- WFIFOSET(fd, clif_parse_func_table[0x95].len);
+ WFIFO_STRING(s, 6, name.xislice_h(it), 24);
+ WFIFOSET(s, clif_parse_func_table[0x95].len);
}
break;
case BL::MOB:
@@ -3776,8 +3734,8 @@ void clif_parse_GetCharNameRequest(int fd, dumb_ptr<map_session_data> sd)
nullpo_retv(md);
- WFIFO_STRING(fd, 6, md->name, 24);
- WFIFOSET(fd, clif_parse_func_table[0x95].len);
+ WFIFO_STRING(s, 6, md->name, 24);
+ WFIFOSET(s, clif_parse_func_table[0x95].len);
}
break;
default:
@@ -3796,18 +3754,18 @@ void clif_parse_GetCharNameRequest(int fd, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_GlobalMessage(int fd, dumb_ptr<map_session_data> sd)
+void clif_parse_GlobalMessage(Session *s, dumb_ptr<map_session_data> sd)
{
nullpo_retv(sd);
FString mbuf = clif_validate_chat(sd, ChatType::Global);
if (!mbuf)
{
- clif_displaymessage(fd, "Your message could not be sent.");
+ clif_displaymessage(s, "Your message could not be sent.");
return;
}
- if (is_atcommand(fd, sd, mbuf, 0))
+ if (is_atcommand(s, sd, mbuf, 0))
return;
if (!magic_message(sd, mbuf))
@@ -3815,7 +3773,7 @@ void clif_parse_GlobalMessage(int fd, dumb_ptr<map_session_data> sd)
/* Don't send chat that results in an automatic ban. */
if (tmw_CheckChatSpam(sd, mbuf))
{
- clif_displaymessage(fd, "Your message could not be sent.");
+ clif_displaymessage(s, "Your message could not be sent.");
return;
}
@@ -3831,10 +3789,10 @@ void clif_parse_GlobalMessage(int fd, dumb_ptr<map_session_data> sd)
}
/* Send the message back to the speaker. */
- size_t len = RFIFOW(fd, 2);
- RFIFO_WFIFO_CLONE(fd, fd, len);
- WFIFOW(fd, 0) = 0x8e;
- WFIFOSET(fd, len);
+ size_t len = RFIFOW(s, 2);
+ RFIFO_WFIFO_CLONE(s, s, len);
+ WFIFOW(s, 0) = 0x8e;
+ WFIFOSET(s, len);
}
void clif_message(dumb_ptr<block_list> bl, XString msg)
@@ -3860,7 +3818,7 @@ void clif_message(dumb_ptr<block_list> bl, XString msg)
*------------------------------------------
*/
static
-void clif_parse_ChangeDir(int fd, dumb_ptr<map_session_data> sd)
+void clif_parse_ChangeDir(Session *s, dumb_ptr<map_session_data> sd)
{
unsigned char buf[64];
@@ -3869,7 +3827,7 @@ void clif_parse_ChangeDir(int fd, dumb_ptr<map_session_data> sd)
// RFIFOW(fd, 2) and WBUFW(buf, 6) are always 0
// TODO perhaps we could use that to remove this hack?
DIR dir;
- uint8_t client_dir = RFIFOB(fd, 4);
+ uint8_t client_dir = RFIFOB(s, 4);
// the client uses a diffenent direction enum ... ugh
switch (client_dir)
{
@@ -3904,7 +3862,7 @@ void clif_parse_ChangeDir(int fd, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_Emotion(int fd, dumb_ptr<map_session_data> sd)
+void clif_parse_Emotion(Session *s, dumb_ptr<map_session_data> sd)
{
unsigned char buf[64];
@@ -3913,7 +3871,7 @@ void clif_parse_Emotion(int fd, dumb_ptr<map_session_data> sd)
if (battle_config.basic_skill_check == 0
|| pc_checkskill(sd, SkillID::NV_EMOTE) >= 1)
{
- uint8_t emote = RFIFOB(fd, 2);
+ uint8_t emote = RFIFOB(s, 2);
WBUFW(buf, 0) = 0xc0;
WBUFL(buf, 2) = sd->bl_id;
WBUFB(buf, 6) = emote;
@@ -3928,11 +3886,11 @@ void clif_parse_Emotion(int fd, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_HowManyConnections(int fd, dumb_ptr<map_session_data>)
+void clif_parse_HowManyConnections(Session *s, dumb_ptr<map_session_data>)
{
- WFIFOW(fd, 0) = 0xc2;
- WFIFOL(fd, 2) = map_getusers();
- WFIFOSET(fd, clif_parse_func_table[0xc2].len);
+ WFIFOW(s, 0) = 0xc2;
+ WFIFOL(s, 2) = map_getusers();
+ WFIFOSET(s, clif_parse_func_table[0xc2].len);
}
/*==========================================
@@ -3940,7 +3898,7 @@ void clif_parse_HowManyConnections(int fd, dumb_ptr<map_session_data>)
*------------------------------------------
*/
static
-void clif_parse_ActionRequest(int fd, dumb_ptr<map_session_data> sd)
+void clif_parse_ActionRequest(Session *s, dumb_ptr<map_session_data> sd)
{
unsigned char buf[64];
int action_type, target_id;
@@ -3962,8 +3920,8 @@ void clif_parse_ActionRequest(int fd, dumb_ptr<map_session_data> sd)
pc_stop_walking(sd, 0);
pc_stopattack(sd);
- target_id = RFIFOL(fd, 2);
- action_type = RFIFOB(fd, 6);
+ target_id = RFIFOL(s, 2);
+ action_type = RFIFOB(s, 6);
switch (action_type)
{
@@ -3988,7 +3946,7 @@ void clif_parse_ActionRequest(int fd, dumb_ptr<map_session_data> sd)
case 0x02: // sitdown
pc_stop_walking(sd, 1);
pc_setsit(sd);
- clif_sitting(fd, sd);
+ clif_sitting(s, sd);
break;
case 0x03: // standup
pc_setstand(sd);
@@ -4005,11 +3963,11 @@ void clif_parse_ActionRequest(int fd, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_Restart(int fd, dumb_ptr<map_session_data> sd)
+void clif_parse_Restart(Session *s, dumb_ptr<map_session_data> sd)
{
nullpo_retv(sd);
- switch (RFIFOB(fd, 2))
+ switch (RFIFOB(s, 2))
{
case 0x00:
if (pc_isdead(sd))
@@ -4030,10 +3988,10 @@ void clif_parse_Restart(int fd, dumb_ptr<map_session_data> sd)
}
else
{
- WFIFOW(fd, 0) = 0x18b;
- WFIFOW(fd, 2) = 1;
+ WFIFOW(s, 0) = 0x18b;
+ WFIFOW(s, 2) = 1;
- WFIFOSET(fd, clif_parse_func_table[0x018b].len);
+ WFIFOSET(s, clif_parse_func_table[0x018b].len);
}
break;
}
@@ -4050,7 +4008,7 @@ void clif_parse_Restart(int fd, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_Wis(int fd, dumb_ptr<map_session_data> sd)
+void clif_parse_Wis(Session *s, dumb_ptr<map_session_data> sd)
{
dumb_ptr<map_session_data> dstsd = NULL;
@@ -4059,11 +4017,11 @@ void clif_parse_Wis(int fd, dumb_ptr<map_session_data> sd)
FString mbuf = clif_validate_chat(sd, ChatType::Whisper);
if (!mbuf)
{
- clif_displaymessage(fd, "Your message could not be sent.");
+ clif_displaymessage(s, "Your message could not be sent.");
return;
}
- if (is_atcommand(fd, sd, mbuf, 0))
+ if (is_atcommand(s, sd, mbuf, 0))
{
return;
}
@@ -4071,7 +4029,7 @@ void clif_parse_Wis(int fd, dumb_ptr<map_session_data> sd)
/* Don't send chat that results in an automatic ban. */
if (tmw_CheckChatSpam(sd, mbuf))
{
- clif_displaymessage(fd, "Your message could not be sent.");
+ clif_displaymessage(s, "Your message could not be sent.");
return;
}
@@ -4081,26 +4039,26 @@ void clif_parse_Wis(int fd, dumb_ptr<map_session_data> sd)
* conflict (for instance, "Test" versus "test"), the char-server must
* settle the discrepancy.
*/
- CharName tname = stringish<CharName>(RFIFO_STRING<24>(fd, 4));
+ CharName tname = stringish<CharName>(RFIFO_STRING<24>(s, 4));
if (!(dstsd = map_nick2sd(tname))
|| dstsd->status.name != tname)
intif_wis_message(sd, tname, mbuf);
else
{
/* Refuse messages addressed to self. */
- if (dstsd->fd == fd)
+ if (dstsd->sess == s)
{
ZString mes = "You cannot page yourself.";
- clif_wis_message(fd, wisp_server_name, mes);
+ clif_wis_message(s, wisp_server_name, mes);
}
else
{
{
/* The player is not being ignored. */
{
- clif_wis_message(dstsd->fd, sd->status.name, mbuf);
+ clif_wis_message(dstsd->sess, sd->status.name, mbuf);
/* The whisper was sent successfully. */
- clif_wis_end(fd, 0);
+ clif_wis_end(s, 0);
}
}
}
@@ -4112,14 +4070,14 @@ void clif_parse_Wis(int fd, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_TakeItem(int fd, dumb_ptr<map_session_data> sd)
+void clif_parse_TakeItem(Session *s, dumb_ptr<map_session_data> sd)
{
dumb_ptr<flooritem_data> fitem;
int map_object_id;
nullpo_retv(sd);
- map_object_id = RFIFOL(fd, 2);
+ map_object_id = RFIFOL(s, 2);
fitem = map_id_is_item(map_object_id);
if (pc_isdead(sd))
@@ -4150,7 +4108,7 @@ void clif_parse_TakeItem(int fd, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_DropItem(int fd, dumb_ptr<map_session_data> sd)
+void clif_parse_DropItem(Session *s, dumb_ptr<map_session_data> sd)
{
int item_index, item_amount;
@@ -4163,18 +4121,18 @@ void clif_parse_DropItem(int fd, dumb_ptr<map_session_data> sd)
}
if (sd->bl_m->flag.no_player_drops)
{
- clif_displaymessage(sd->fd, "Can't drop items here.");
+ clif_displaymessage(sd->sess, "Can't drop items here.");
return;
}
if (sd->npc_id != 0
|| sd->opt1 != Opt1::ZERO)
{
- clif_displaymessage(sd->fd, "Can't drop items right now.");
+ clif_displaymessage(sd->sess, "Can't drop items right now.");
return;
}
- item_index = RFIFOW(fd, 2) - 2;
- item_amount = RFIFOW(fd, 4);
+ item_index = RFIFOW(s, 2) - 2;
+ item_amount = RFIFOW(s, 4);
pc_dropitem(sd, item_index, item_amount);
}
@@ -4184,7 +4142,7 @@ void clif_parse_DropItem(int fd, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_UseItem(int fd, dumb_ptr<map_session_data> sd)
+void clif_parse_UseItem(Session *s, dumb_ptr<map_session_data> sd)
{
nullpo_retv(sd);
@@ -4200,7 +4158,7 @@ void clif_parse_UseItem(int fd, dumb_ptr<map_session_data> sd)
if (sd->invincible_timer)
pc_delinvincibletimer(sd);
- pc_useitem(sd, RFIFOW(fd, 2) - 2);
+ pc_useitem(sd, RFIFOW(s, 2) - 2);
}
/*==========================================
@@ -4208,7 +4166,7 @@ void clif_parse_UseItem(int fd, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_EquipItem(int fd, dumb_ptr<map_session_data> sd)
+void clif_parse_EquipItem(Session *s, dumb_ptr<map_session_data> sd)
{
int index;
@@ -4219,7 +4177,7 @@ void clif_parse_EquipItem(int fd, dumb_ptr<map_session_data> sd)
clif_clearchar(sd, BeingRemoveWhy::DEAD);
return;
}
- index = RFIFOW(fd, 2) - 2;
+ index = RFIFOW(s, 2) - 2;
if (sd->npc_id != 0)
return;
@@ -4234,7 +4192,7 @@ void clif_parse_EquipItem(int fd, dumb_ptr<map_session_data> sd)
//ペット用装備であるかないか
if (sd->inventory_data[index])
{
- EPOS epos = EPOS(RFIFOW(fd, 4));
+ EPOS epos = EPOS(RFIFOW(s, 4));
if (sd->inventory_data[index]->type == ItemType::ARROW)
// 矢を無理やり装備できるように(−−;
epos = EPOS::ARROW;
@@ -4249,7 +4207,7 @@ void clif_parse_EquipItem(int fd, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_UnequipItem(int fd, dumb_ptr<map_session_data> sd)
+void clif_parse_UnequipItem(Session *s, dumb_ptr<map_session_data> sd)
{
int index;
@@ -4260,7 +4218,7 @@ void clif_parse_UnequipItem(int fd, dumb_ptr<map_session_data> sd)
clif_clearchar(sd, BeingRemoveWhy::DEAD);
return;
}
- index = RFIFOW(fd, 2) - 2;
+ index = RFIFOW(s, 2) - 2;
if (sd->status.inventory[index].broken == 1 && sd->sc_data[StatusChange::SC_BROKNWEAPON].timer)
skill_status_change_end(sd, StatusChange::SC_BROKNWEAPON, nullptr);
if (sd->status.inventory[index].broken == 1 && sd->sc_data[StatusChange::SC_BROKNARMOR].timer)
@@ -4277,7 +4235,7 @@ void clif_parse_UnequipItem(int fd, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_NpcClicked(int fd, dumb_ptr<map_session_data> sd)
+void clif_parse_NpcClicked(Session *s, dumb_ptr<map_session_data> sd)
{
nullpo_retv(sd);
@@ -4288,7 +4246,7 @@ void clif_parse_NpcClicked(int fd, dumb_ptr<map_session_data> sd)
}
if (sd->npc_id != 0)
return;
- npc_click(sd, RFIFOL(fd, 2));
+ npc_click(sd, RFIFOL(s, 2));
}
/*==========================================
@@ -4296,9 +4254,9 @@ void clif_parse_NpcClicked(int fd, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_NpcBuySellSelected(int fd, dumb_ptr<map_session_data> sd)
+void clif_parse_NpcBuySellSelected(Session *s, dumb_ptr<map_session_data> sd)
{
- npc_buysellsel(sd, RFIFOL(fd, 2), RFIFOB(fd, 6));
+ npc_buysellsel(sd, RFIFOL(s, 2), RFIFOB(s, 6));
}
/*==========================================
@@ -4306,17 +4264,17 @@ void clif_parse_NpcBuySellSelected(int fd, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_NpcBuyListSend(int fd, dumb_ptr<map_session_data> sd)
+void clif_parse_NpcBuyListSend(Session *s, dumb_ptr<map_session_data> sd)
{
- int n = (RFIFOW(fd, 2) - 4) / 4;
+ int n = (RFIFOW(s, 2) - 4) / 4;
// really an array of pairs of uint16_t
- const uint16_t *item_list = static_cast<const uint16_t *>(RFIFOP(fd, 4));
+ const uint16_t *item_list = static_cast<const uint16_t *>(RFIFOP(s, 4));
int fail = npc_buylist(sd, n, item_list);
- WFIFOW(fd, 0) = 0xca;
- WFIFOB(fd, 2) = fail;
- WFIFOSET(fd, clif_parse_func_table[0xca].len);
+ WFIFOW(s, 0) = 0xca;
+ WFIFOB(s, 2) = fail;
+ WFIFOSET(s, clif_parse_func_table[0xca].len);
}
/*==========================================
@@ -4324,17 +4282,17 @@ void clif_parse_NpcBuyListSend(int fd, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_NpcSellListSend(int fd, dumb_ptr<map_session_data> sd)
+void clif_parse_NpcSellListSend(Session *s, dumb_ptr<map_session_data> sd)
{
- int n = (RFIFOW(fd, 2) - 4) / 4;
+ int n = (RFIFOW(s, 2) - 4) / 4;
// really an array of pairs of uint16_t
- const uint16_t *item_list = static_cast<const uint16_t *>(RFIFOP(fd, 4));
+ const uint16_t *item_list = static_cast<const uint16_t *>(RFIFOP(s, 4));
int fail = npc_selllist(sd, n, item_list);
- WFIFOW(fd, 0) = 0xcb;
- WFIFOB(fd, 2) = fail;
- WFIFOSET(fd, clif_parse_func_table[0xcb].len);
+ WFIFOW(s, 0) = 0xcb;
+ WFIFOB(s, 2) = fail;
+ WFIFOSET(s, clif_parse_func_table[0xcb].len);
}
/*==========================================
@@ -4342,14 +4300,14 @@ void clif_parse_NpcSellListSend(int fd, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_TradeRequest(int, dumb_ptr<map_session_data> sd)
+void clif_parse_TradeRequest(Session *, dumb_ptr<map_session_data> sd)
{
nullpo_retv(sd);
if (battle_config.basic_skill_check == 0
|| pc_checkskill(sd, SkillID::NV_TRADE) >= 1)
{
- trade_traderequest(sd, RFIFOL(sd->fd, 2));
+ trade_traderequest(sd, RFIFOL(sd->sess, 2));
}
else
clif_skill_fail(sd, SkillID::ONE, 0, 0);
@@ -4360,11 +4318,11 @@ void clif_parse_TradeRequest(int, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_TradeAck(int, dumb_ptr<map_session_data> sd)
+void clif_parse_TradeAck(Session *, dumb_ptr<map_session_data> sd)
{
nullpo_retv(sd);
- trade_tradeack(sd, RFIFOB(sd->fd, 2));
+ trade_tradeack(sd, RFIFOB(sd->sess, 2));
}
/*==========================================
@@ -4372,11 +4330,11 @@ void clif_parse_TradeAck(int, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_TradeAddItem(int, dumb_ptr<map_session_data> sd)
+void clif_parse_TradeAddItem(Session *, dumb_ptr<map_session_data> sd)
{
nullpo_retv(sd);
- trade_tradeadditem(sd, RFIFOW(sd->fd, 2), RFIFOL(sd->fd, 4));
+ trade_tradeadditem(sd, RFIFOW(sd->sess, 2), RFIFOL(sd->sess, 4));
}
/*==========================================
@@ -4384,7 +4342,7 @@ void clif_parse_TradeAddItem(int, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_TradeOk(int, dumb_ptr<map_session_data> sd)
+void clif_parse_TradeOk(Session *, dumb_ptr<map_session_data> sd)
{
trade_tradeok(sd);
}
@@ -4394,7 +4352,7 @@ void clif_parse_TradeOk(int, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_TradeCansel(int, dumb_ptr<map_session_data> sd)
+void clif_parse_TradeCansel(Session *, dumb_ptr<map_session_data> sd)
{
trade_tradecancel(sd);
}
@@ -4404,7 +4362,7 @@ void clif_parse_TradeCansel(int, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_TradeCommit(int, dumb_ptr<map_session_data> sd)
+void clif_parse_TradeCommit(Session *, dumb_ptr<map_session_data> sd)
{
trade_tradecommit(sd);
}
@@ -4414,7 +4372,7 @@ void clif_parse_TradeCommit(int, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_StopAttack(int, dumb_ptr<map_session_data> sd)
+void clif_parse_StopAttack(Session *, dumb_ptr<map_session_data> sd)
{
pc_stopattack(sd);
}
@@ -4424,9 +4382,9 @@ void clif_parse_StopAttack(int, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_StatusUp(int fd, dumb_ptr<map_session_data> sd)
+void clif_parse_StatusUp(Session *s, dumb_ptr<map_session_data> sd)
{
- pc_statusup(sd, SP(RFIFOW(fd, 2)));
+ pc_statusup(sd, SP(RFIFOW(s, 2)));
}
/*==========================================
@@ -4434,9 +4392,9 @@ void clif_parse_StatusUp(int fd, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_SkillUp(int fd, dumb_ptr<map_session_data> sd)
+void clif_parse_SkillUp(Session *s, dumb_ptr<map_session_data> sd)
{
- pc_skillup(sd, SkillID(RFIFOW(fd, 2)));
+ pc_skillup(sd, SkillID(RFIFOW(s, 2)));
}
/*==========================================
@@ -4444,12 +4402,12 @@ void clif_parse_SkillUp(int fd, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_NpcSelectMenu(int fd, dumb_ptr<map_session_data> sd)
+void clif_parse_NpcSelectMenu(Session *s, dumb_ptr<map_session_data> sd)
{
nullpo_retv(sd);
- sd->npc_menu = RFIFOB(fd, 6);
- map_scriptcont(sd, RFIFOL(fd, 2));
+ sd->npc_menu = RFIFOB(s, 6);
+ map_scriptcont(sd, RFIFOL(s, 2));
}
/*==========================================
@@ -4457,9 +4415,9 @@ void clif_parse_NpcSelectMenu(int fd, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_NpcNextClicked(int fd, dumb_ptr<map_session_data> sd)
+void clif_parse_NpcNextClicked(Session *s, dumb_ptr<map_session_data> sd)
{
- map_scriptcont(sd, RFIFOL(fd, 2));
+ map_scriptcont(sd, RFIFOL(s, 2));
}
/*==========================================
@@ -4467,12 +4425,12 @@ void clif_parse_NpcNextClicked(int fd, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_NpcAmountInput(int fd, dumb_ptr<map_session_data> sd)
+void clif_parse_NpcAmountInput(Session *s, dumb_ptr<map_session_data> sd)
{
nullpo_retv(sd);
- sd->npc_amount = RFIFOL(fd, 6);
- map_scriptcont(sd, RFIFOL(fd, 2));
+ sd->npc_amount = RFIFOL(s, 6);
+ map_scriptcont(sd, RFIFOL(s, 2));
}
/*==========================================
@@ -4482,12 +4440,12 @@ void clif_parse_NpcAmountInput(int fd, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_NpcStringInput(int fd, dumb_ptr<map_session_data> sd)
+void clif_parse_NpcStringInput(Session *s, dumb_ptr<map_session_data> sd)
{
int len;
nullpo_retv(sd);
- len = RFIFOW(fd, 2) - 8;
+ len = RFIFOW(s, 2) - 8;
/*
* If we check for equal to 0, too, we'll freeze clients that send (or
@@ -4495,9 +4453,9 @@ void clif_parse_NpcStringInput(int fd, dumb_ptr<map_session_data> sd)
*/
if (len < 0)
return;
- sd->npc_str = RFIFO_STRING(fd, 8, len);
+ sd->npc_str = RFIFO_STRING(s, 8, len);
- map_scriptcont(sd, RFIFOL(fd, 4));
+ map_scriptcont(sd, RFIFOL(s, 4));
}
/*==========================================
@@ -4505,9 +4463,9 @@ void clif_parse_NpcStringInput(int fd, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_NpcCloseClicked(int fd, dumb_ptr<map_session_data> sd)
+void clif_parse_NpcCloseClicked(Session *s, dumb_ptr<map_session_data> sd)
{
- map_scriptcont(sd, RFIFOL(fd, 2));
+ map_scriptcont(sd, RFIFOL(s, 2));
}
/*==========================================
@@ -4515,14 +4473,14 @@ void clif_parse_NpcCloseClicked(int fd, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_MoveToKafra(int fd, dumb_ptr<map_session_data> sd)
+void clif_parse_MoveToKafra(Session *s, dumb_ptr<map_session_data> sd)
{
int item_index, item_amount;
nullpo_retv(sd);
- item_index = RFIFOW(fd, 2) - 2;
- item_amount = RFIFOL(fd, 4);
+ item_index = RFIFOW(s, 2) - 2;
+ item_amount = RFIFOL(s, 4);
if ((sd->npc_id != 0 && !sd->npc_flags.storage) || sd->trade_partner != 0
|| !sd->state.storage_open)
@@ -4537,14 +4495,14 @@ void clif_parse_MoveToKafra(int fd, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_MoveFromKafra(int fd, dumb_ptr<map_session_data> sd)
+void clif_parse_MoveFromKafra(Session *s, dumb_ptr<map_session_data> sd)
{
int item_index, item_amount;
nullpo_retv(sd);
- item_index = RFIFOW(fd, 2) - 1;
- item_amount = RFIFOL(fd, 4);
+ item_index = RFIFOW(s, 2) - 1;
+ item_amount = RFIFOL(s, 4);
if ((sd->npc_id != 0 && !sd->npc_flags.storage) || sd->trade_partner != 0
|| !sd->state.storage_open)
@@ -4559,7 +4517,7 @@ void clif_parse_MoveFromKafra(int fd, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_CloseKafra(int, dumb_ptr<map_session_data> sd)
+void clif_parse_CloseKafra(Session *, dumb_ptr<map_session_data> sd)
{
nullpo_retv(sd);
@@ -4575,12 +4533,12 @@ void clif_parse_CloseKafra(int, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_CreateParty(int fd, dumb_ptr<map_session_data> sd)
+void clif_parse_CreateParty(Session *s, dumb_ptr<map_session_data> sd)
{
if (battle_config.basic_skill_check == 0
|| pc_checkskill(sd, SkillID::NV_PARTY) >= 2)
{
- PartyName name = stringish<PartyName>(RFIFO_STRING<24>(fd, 2));
+ PartyName name = stringish<PartyName>(RFIFO_STRING<24>(s, 2));
party_create(sd, name);
}
else
@@ -4595,9 +4553,9 @@ void clif_parse_CreateParty(int fd, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_PartyInvite(int fd, dumb_ptr<map_session_data> sd)
+void clif_parse_PartyInvite(Session *s, dumb_ptr<map_session_data> sd)
{
- party_invite(sd, RFIFOL(fd, 2));
+ party_invite(sd, RFIFOL(s, 2));
}
/*==========================================
@@ -4608,16 +4566,16 @@ void clif_parse_PartyInvite(int fd, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_ReplyPartyInvite(int fd, dumb_ptr<map_session_data> sd)
+void clif_parse_ReplyPartyInvite(Session *s, dumb_ptr<map_session_data> sd)
{
if (battle_config.basic_skill_check == 0
|| pc_checkskill(sd, SkillID::NV_PARTY) >= 1)
{
- party_reply_invite(sd, RFIFOL(fd, 2), RFIFOL(fd, 6));
+ party_reply_invite(sd, RFIFOL(s, 2), RFIFOL(s, 6));
}
else
{
- party_reply_invite(sd, RFIFOL(fd, 2), 0);
+ party_reply_invite(sd, RFIFOL(s, 2), 0);
clif_skill_fail(sd, SkillID::ONE, 0, 4);
}
}
@@ -4627,7 +4585,7 @@ void clif_parse_ReplyPartyInvite(int fd, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_LeaveParty(int, dumb_ptr<map_session_data> sd)
+void clif_parse_LeaveParty(Session *, dumb_ptr<map_session_data> sd)
{
party_leave(sd);
}
@@ -4637,9 +4595,9 @@ void clif_parse_LeaveParty(int, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_RemovePartyMember(int fd, dumb_ptr<map_session_data> sd)
+void clif_parse_RemovePartyMember(Session *s, dumb_ptr<map_session_data> sd)
{
- int account_id = RFIFOL(fd, 2);
+ int account_id = RFIFOL(s, 2);
// unused RFIFO_STRING<24>(fd, 6);
party_removemember(sd, account_id);
}
@@ -4649,9 +4607,9 @@ void clif_parse_RemovePartyMember(int fd, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_PartyChangeOption(int fd, dumb_ptr<map_session_data> sd)
+void clif_parse_PartyChangeOption(Session *s, dumb_ptr<map_session_data> sd)
{
- party_changeoption(sd, RFIFOW(fd, 2), RFIFOW(fd, 4));
+ party_changeoption(sd, RFIFOW(s, 2), RFIFOW(s, 4));
}
/*==========================================
@@ -4663,24 +4621,24 @@ void clif_parse_PartyChangeOption(int fd, dumb_ptr<map_session_data> sd)
*------------------------------------------
*/
static
-void clif_parse_PartyMessage(int fd, dumb_ptr<map_session_data> sd)
+void clif_parse_PartyMessage(Session *s, dumb_ptr<map_session_data> sd)
{
nullpo_retv(sd);
FString mbuf = clif_validate_chat(sd, ChatType::Party);
if (!mbuf)
{
- clif_displaymessage(fd, "Your message could not be sent.");
+ clif_displaymessage(s, "Your message could not be sent.");
return;
}
- if (is_atcommand(fd, sd, mbuf, 0))
+ if (is_atcommand(s, sd, mbuf, 0))
return;
/* Don't send chat that results in an automatic ban. */
if (tmw_CheckChatSpam(sd, mbuf))
{
- clif_displaymessage(fd, "Your message could not be sent.");
+ clif_displaymessage(s, "Your message could not be sent.");
return;
}
@@ -5237,9 +5195,9 @@ func_table clif_parse_func_table[0x0220] =
// Checks for packet flooding
static
-int clif_check_packet_flood(int fd, int cmd)
+int clif_check_packet_flood(Session *s, int cmd)
{
- dumb_ptr<map_session_data> sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[fd]->session_data.get()));
+ dumb_ptr<map_session_data> sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s->session_data.get()));
tick_t tick = gettick();
// sd will not be set if the client hasn't requested
@@ -5264,7 +5222,7 @@ int clif_check_packet_flood(int fd, int cmd)
// ActionRequest - attacks are allowed a faster rate than sit/stand
if (cmd == 0x89)
{
- int action_type = RFIFOB(fd, 6);
+ int action_type = RFIFOB(s, 6);
if (action_type == 0x00 || action_type == 0x07)
rate = std::chrono::milliseconds(20);
else
@@ -5303,7 +5261,7 @@ int clif_check_packet_flood(int fd, int cmd)
PRINTF("packet flood detected from %s [0x%x]\n", sd->status.name, cmd);
if (battle_config.packet_spam_kick)
{
- session[fd]->eof = 1; // Kick
+ s->eof = 1; // Kick
return 1;
}
sd->packet_flood_in = 0;
@@ -5343,8 +5301,8 @@ FString clif_validate_chat(dumb_ptr<map_session_data> sd, ChatType type)
if (sd->auto_ban_info.in_progress)
return FString();
- int fd = sd->fd;
- size_t msg_len = RFIFOW(fd, 2) - 4;
+ Session *s = sd->sess;
+ size_t msg_len = RFIFOW(s, 2) - 4;
size_t name_len = sd->status.name.to__actual().size();
/*
* At least one character is required in all instances.
@@ -5379,7 +5337,7 @@ FString clif_validate_chat(dumb_ptr<map_session_data> sd, ChatType type)
if (type == ChatType::Whisper && msg_len < min_len)
{
/* Disallow malformed messages. */
- clif_setwaitclose(fd);
+ clif_setwaitclose(s);
WARN_MALFORMED_MSG(sd, "illegal target name");
return FString();
}
@@ -5391,7 +5349,7 @@ FString clif_validate_chat(dumb_ptr<map_session_data> sd, ChatType type)
pstart += 24;
buf_len -= 24;
}
- FString pbuf = RFIFO_STRING(fd, pstart, buf_len);
+ FString pbuf = RFIFO_STRING(s, pstart, buf_len);
/*
* The client attempted to exceed the maximum message length.
@@ -5412,7 +5370,7 @@ FString clif_validate_chat(dumb_ptr<map_session_data> sd, ChatType type)
if (!(p.startswith(sd->status.name.to__actual()) && p.xslice_t(name_len).startswith(" : ")))
{
/* Disallow malformed/spoofed messages. */
- clif_setwaitclose(fd);
+ clif_setwaitclose(s);
WARN_MALFORMED_MSG(sd, "spoofed name/invalid format");
return FString();
}
@@ -5429,31 +5387,31 @@ FString clif_validate_chat(dumb_ptr<map_session_data> sd, ChatType type)
*------------------------------------------
*/
static
-void clif_parse(int fd)
+void clif_parse(Session *s)
{
int packet_len = 0, cmd = 0;
- dumb_ptr<map_session_data> sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[fd]->session_data.get()));
+ dumb_ptr<map_session_data> sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s->session_data.get()));
if (!sd || (sd && !sd->state.auth))
{
- if (RFIFOREST(fd) < 2)
+ if (RFIFOREST(s) < 2)
{ // too small a packet disconnect
- session[fd]->eof = 1;
+ s->eof = 1;
}
- if (RFIFOW(fd, 0) != 0x72 && RFIFOW(fd, 0) != 0x7530)
+ if (RFIFOW(s, 0) != 0x72 && RFIFOW(s, 0) != 0x7530)
{
// first packet must be auth or finger
- session[fd]->eof = 1;
+ s->eof = 1;
}
}
// 接続が切れてるので後始末
- if (!chrif_isconnect() || session[fd]->eof)
+ if (!chrif_isconnect() || s->eof)
{ // char鯖に繋がってない間は接続禁止 (!chrif_isconnect())
if (sd && sd->state.auth)
{
pc_logout(sd);
- clif_quitsave(fd, sd);
+ clif_quitsave(s, sd);
PRINTF("Player [%s] has logged off your server.\n", sd->status.name); // Player logout display [Valaris]
}
@@ -5462,15 +5420,15 @@ void clif_parse(int fd)
PRINTF("Player with account [%d] has logged off your server (not auth account).\n", sd->bl_id); // Player logout display [Yor]
map_deliddb(sd); // account_id has been included in the DB before auth answer
}
- if (fd)
- delete_session(fd);
+ if (s)
+ delete_session(s);
return;
}
- if (RFIFOREST(fd) < 2)
+ if (RFIFOREST(s) < 2)
return; // Too small (no packet number)
- cmd = RFIFOW(fd, 0);
+ cmd = RFIFOW(s, 0);
// 管理用パケット処理
if (cmd >= 30000)
@@ -5478,13 +5436,13 @@ void clif_parse(int fd)
switch (cmd)
{
case 0x7530: // Athena情報所得
- WFIFOW(fd, 0) = 0x7531;
- WFIFO_STRUCT(fd, 2, CURRENT_MAP_SERVER_VERSION);
- WFIFOSET(fd, 10);
- RFIFOSKIP(fd, 2);
+ WFIFOW(s, 0) = 0x7531;
+ WFIFO_STRUCT(s, 2, CURRENT_MAP_SERVER_VERSION);
+ WFIFOSET(s, 10);
+ RFIFOSKIP(s, 2);
break;
case 0x7532: // 接続の切断
- session[fd]->eof = 1;
+ s->eof = 1;
break;
}
return;
@@ -5496,19 +5454,19 @@ void clif_parse(int fd)
packet_len = clif_parse_func_table[cmd].len;
if (packet_len == VAR)
{
- if (RFIFOREST(fd) < 4)
+ if (RFIFOREST(s) < 4)
{
return; // Runt packet (variable length without a length sent)
}
- packet_len = RFIFOW(fd, 2);
+ packet_len = RFIFOW(s, 2);
if (packet_len < 4 || packet_len > 32768)
{
- session[fd]->eof = 1;
+ s->eof = 1;
return; // Runt packet (variable out of bounds)
}
}
- if (RFIFOREST(fd) < packet_len)
+ if (RFIFOREST(s) < packet_len)
{
return; // Runt packet (sent legnth is too small)
}
@@ -5519,23 +5477,23 @@ void clif_parse(int fd)
}
else if (clif_parse_func_table[cmd].func)
{
- if (clif_check_packet_flood(fd, cmd))
+ if (clif_check_packet_flood(s, cmd))
{
// Flood triggered. Skip packet.
- RFIFOSKIP(sd->fd, packet_len);
+ RFIFOSKIP(sd->sess, packet_len);
return;
}
- clif_parse_func_table[cmd].func(fd, sd);
+ clif_parse_func_table[cmd].func(s, sd);
}
else
{
// 不明なパケット
if (battle_config.error_log)
{
- if (fd)
+ if (s)
PRINTF("\nclif_parse: session #%d, packet 0x%x, lenght %d\n",
- fd, cmd, packet_len);
+ s, cmd, packet_len);
#ifdef DUMP_UNKNOWN_PACKET
{
int i;
@@ -5545,7 +5503,7 @@ void clif_parse(int fd)
{
if ((i & 15) == 0)
PRINTF("\n%04X ", i);
- PRINTF("%02X ", RFIFOB(fd, i));
+ PRINTF("%02X ", RFIFOB(s, i));
}
if (sd && sd->state.auth)
{
@@ -5586,7 +5544,7 @@ void clif_parse(int fd)
{
if ((i & 15) == 0)
FPRINTF(fp, "\n\t%04X ", i);
- FPRINTF(fp, "%02X ", RFIFOB(fd, i));
+ FPRINTF(fp, "%02X ", RFIFOB(s, i));
}
FPRINTF(fp, "\n\n");
}
@@ -5594,7 +5552,7 @@ void clif_parse(int fd)
#endif
}
}
- RFIFOSKIP(fd, packet_len);
+ RFIFOSKIP(s, packet_len);
}
void do_init_clif(void)
diff --git a/src/map/clif.hpp b/src/map/clif.hpp
index ad51fc8..e84adf3 100644
--- a/src/map/clif.hpp
+++ b/src/map/clif.hpp
@@ -22,16 +22,16 @@ void clif_setport(int);
IP4Address clif_getip(void);
int clif_getport(void);
int clif_countusers(void);
-void clif_setwaitclose(int);
+void clif_setwaitclose(Session *);
int clif_authok(dumb_ptr<map_session_data>);
-int clif_authfail_fd(int, int);
+int clif_authfail_fd(Session *, int);
int clif_charselectok(int);
int clif_dropflooritem(dumb_ptr<flooritem_data>);
-int clif_clearflooritem(dumb_ptr<flooritem_data>, int);
+int clif_clearflooritem(dumb_ptr<flooritem_data>, Session *);
int clif_clearchar(dumb_ptr<block_list>, BeingRemoveWhy); // area or fd
int clif_clearchar_delay(tick_t, dumb_ptr<block_list>, BeingRemoveWhy);
-void clif_clearchar_id(int, BeingRemoveWhy, int);
+void clif_clearchar_id(int, BeingRemoveWhy, Session *);
int clif_spawnpc(dumb_ptr<map_session_data>); //area
int clif_spawnnpc(dumb_ptr<npc_data>); // area
int clif_spawn_fake_npc_for_player(dumb_ptr<map_session_data> sd,
@@ -78,7 +78,7 @@ int clif_changeoption(dumb_ptr<block_list>); // area
int clif_useitemack(dumb_ptr<map_session_data>, int, int, int); // self
void clif_emotion(dumb_ptr<block_list> bl, int type);
-void clif_sitting(int fd, dumb_ptr<map_session_data> sd);
+void clif_sitting(Session *, dumb_ptr<map_session_data> sd);
// trade
void clif_traderequest(dumb_ptr<map_session_data> sd, CharName name);
@@ -124,8 +124,8 @@ int clif_skill_damage(dumb_ptr<block_list> src, dumb_ptr<block_list> dst,
int clif_status_change(dumb_ptr<block_list> bl,
StatusChange type, int flag);
-void clif_wis_message(int fd, CharName nick, XString mes);
-void clif_wis_end(int fd, int flag);
+void clif_wis_message(Session *s, CharName nick, XString mes);
+void clif_wis_end(Session *s, int flag);
void clif_itemlist(dumb_ptr<map_session_data> sd);
void clif_equiplist(dumb_ptr<map_session_data> sd);
@@ -136,7 +136,7 @@ int clif_movetoattack(dumb_ptr<map_session_data> sd, dumb_ptr<block_list> bl);
// party
int clif_party_created(dumb_ptr<map_session_data> sd, int flag);
-int clif_party_info(struct party *p, int fd);
+int clif_party_info(struct party *p, Session *s);
void clif_party_invite(dumb_ptr<map_session_data> sd,
dumb_ptr<map_session_data> tsd);
void clif_party_inviteack(dumb_ptr<map_session_data> sd, CharName nick, int flag);
@@ -149,7 +149,7 @@ int clif_party_xy(struct party *p, dumb_ptr<map_session_data> sd);
int clif_party_hp(struct party *p, dumb_ptr<map_session_data> sd);
// atcommand
-void clif_displaymessage(int fd, XString mes);
+void clif_displaymessage(Session *s, XString mes);
void clif_GMmessage(dumb_ptr<block_list> bl, XString mes, int flag);
void clif_resurrection(dumb_ptr<block_list> bl, int type);
diff --git a/src/map/intif.cpp b/src/map/intif.cpp
index 8673aef..006be1c 100644
--- a/src/map/intif.cpp
+++ b/src/map/intif.cpp
@@ -43,11 +43,11 @@ const int packet_len_table[] =
// Message for all GMs on all map servers
void intif_GMmessage(XString mes)
{
- WFIFOW(char_fd, 0) = 0x3000;
+ WFIFOW(char_session, 0) = 0x3000;
size_t len = mes.size() + 1;
- WFIFOW(char_fd, 2) = 4 + len;
- WFIFO_STRING(char_fd, 4, mes, len);
- WFIFOSET(char_fd, WFIFOW(char_fd, 2));
+ WFIFOW(char_session, 2) = 4 + len;
+ WFIFO_STRING(char_session, 4, mes, len);
+ WFIFOSET(char_session, WFIFOW(char_session, 2));
}
// The transmission of Wisp/Page to inter-server (player not found on this server)
@@ -56,12 +56,12 @@ void intif_wis_message(dumb_ptr<map_session_data> sd, CharName nick, ZString mes
nullpo_retv(sd);
size_t mes_len = mes.size() + 1;
- WFIFOW(char_fd, 0) = 0x3001;
- WFIFOW(char_fd, 2) = mes_len + 52;
- WFIFO_STRING(char_fd, 4, sd->status.name.to__actual(), 24);
- WFIFO_STRING(char_fd, 28, nick.to__actual(), 24);
- WFIFO_STRING(char_fd, 52, mes, mes_len);
- WFIFOSET(char_fd, WFIFOW(char_fd, 2));
+ WFIFOW(char_session, 0) = 0x3001;
+ WFIFOW(char_session, 2) = mes_len + 52;
+ WFIFO_STRING(char_session, 4, sd->status.name.to__actual(), 24);
+ WFIFO_STRING(char_session, 28, nick.to__actual(), 24);
+ WFIFO_STRING(char_session, 52, mes, mes_len);
+ WFIFOSET(char_session, WFIFOW(char_session, 2));
if (battle_config.etc_log)
PRINTF("intif_wis_message from %s to %s)\n",
@@ -72,10 +72,10 @@ void intif_wis_message(dumb_ptr<map_session_data> sd, CharName nick, ZString mes
static
void intif_wis_replay(int id, int flag)
{
- WFIFOW(char_fd, 0) = 0x3002;
- WFIFOL(char_fd, 2) = id;
- WFIFOB(char_fd, 6) = flag; // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
- WFIFOSET(char_fd, 7);
+ WFIFOW(char_session, 0) = 0x3002;
+ WFIFOL(char_session, 2) = id;
+ WFIFOB(char_session, 6) = flag; // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
+ WFIFOSET(char_session, 7);
if (battle_config.etc_log)
PRINTF("intif_wis_replay: id: %d, flag:%d\n", id, flag);
@@ -85,12 +85,12 @@ void intif_wis_replay(int id, int flag)
void intif_wis_message_to_gm(CharName Wisp_name, int min_gm_level, ZString mes)
{
size_t mes_len = mes.size() + 1;
- WFIFOW(char_fd, 0) = 0x3003;
- WFIFOW(char_fd, 2) = mes_len + 30;
- WFIFO_STRING(char_fd, 4, Wisp_name.to__actual(), 24);
- WFIFOW(char_fd, 28) = min_gm_level;
- WFIFO_STRING(char_fd, 30, mes, mes_len);
- WFIFOSET(char_fd, WFIFOW(char_fd, 2));
+ WFIFOW(char_session, 0) = 0x3003;
+ WFIFOW(char_session, 2) = mes_len + 30;
+ WFIFO_STRING(char_session, 4, Wisp_name.to__actual(), 24);
+ WFIFOW(char_session, 28) = min_gm_level;
+ WFIFO_STRING(char_session, 30, mes, mes_len);
+ WFIFOSET(char_session, WFIFOW(char_session, 2));
if (battle_config.etc_log)
PRINTF("intif_wis_message_to_gm: from: '%s', min level: %d, message: '%s'.\n",
@@ -104,15 +104,15 @@ void intif_saveaccountreg(dumb_ptr<map_session_data> sd)
nullpo_retv(sd);
- WFIFOW(char_fd, 0) = 0x3004;
- WFIFOL(char_fd, 4) = sd->bl_id;
+ WFIFOW(char_session, 0) = 0x3004;
+ WFIFOL(char_session, 4) = sd->bl_id;
for (j = 0, p = 8; j < sd->status.account_reg_num; j++, p += 36)
{
- WFIFO_STRING(char_fd, p, sd->status.account_reg[j].str, 32);
- WFIFOL(char_fd, p + 32) = sd->status.account_reg[j].value;
+ WFIFO_STRING(char_session, p, sd->status.account_reg[j].str, 32);
+ WFIFOL(char_session, p + 32) = sd->status.account_reg[j].value;
}
- WFIFOW(char_fd, 2) = p;
- WFIFOSET(char_fd, p);
+ WFIFOW(char_session, 2) = p;
+ WFIFOSET(char_session, p);
}
// アカウント変数要求
@@ -120,28 +120,28 @@ void intif_request_accountreg(dumb_ptr<map_session_data> sd)
{
nullpo_retv(sd);
- WFIFOW(char_fd, 0) = 0x3005;
- WFIFOL(char_fd, 2) = sd->bl_id;
- WFIFOSET(char_fd, 6);
+ WFIFOW(char_session, 0) = 0x3005;
+ WFIFOL(char_session, 2) = sd->bl_id;
+ WFIFOSET(char_session, 6);
}
// 倉庫データ要求
void intif_request_storage(int account_id)
{
- WFIFOW(char_fd, 0) = 0x3010;
- WFIFOL(char_fd, 2) = account_id;
- WFIFOSET(char_fd, 6);
+ WFIFOW(char_session, 0) = 0x3010;
+ WFIFOL(char_session, 2) = account_id;
+ WFIFOSET(char_session, 6);
}
// 倉庫データ送信
void intif_send_storage(struct storage *stor)
{
nullpo_retv(stor);
- WFIFOW(char_fd, 0) = 0x3011;
- WFIFOW(char_fd, 2) = sizeof(struct storage) + 8;
- WFIFOL(char_fd, 4) = stor->account_id;
- WFIFO_STRUCT(char_fd, 8, *stor);
- WFIFOSET(char_fd, WFIFOW(char_fd, 2));
+ WFIFOW(char_session, 0) = 0x3011;
+ WFIFOW(char_session, 2) = sizeof(struct storage) + 8;
+ WFIFOL(char_session, 4) = stor->account_id;
+ WFIFO_STRUCT(char_session, 8, *stor);
+ WFIFOSET(char_session, WFIFOW(char_session, 2));
}
// パーティ作成要求
@@ -149,21 +149,21 @@ void intif_create_party(dumb_ptr<map_session_data> sd, PartyName name)
{
nullpo_retv(sd);
- WFIFOW(char_fd, 0) = 0x3020;
- WFIFOL(char_fd, 2) = sd->status.account_id;
- WFIFO_STRING(char_fd, 6, name, 24);
- WFIFO_STRING(char_fd, 30, sd->status.name.to__actual(), 24);
- WFIFO_STRING(char_fd, 54, sd->bl_m->name_, 16);
- WFIFOW(char_fd, 70) = sd->status.base_level;
- WFIFOSET(char_fd, 72);
+ WFIFOW(char_session, 0) = 0x3020;
+ WFIFOL(char_session, 2) = sd->status.account_id;
+ WFIFO_STRING(char_session, 6, name, 24);
+ WFIFO_STRING(char_session, 30, sd->status.name.to__actual(), 24);
+ WFIFO_STRING(char_session, 54, sd->bl_m->name_, 16);
+ WFIFOW(char_session, 70) = sd->status.base_level;
+ WFIFOSET(char_session, 72);
}
// パーティ情報要求
void intif_request_partyinfo(int party_id)
{
- WFIFOW(char_fd, 0) = 0x3021;
- WFIFOL(char_fd, 2) = party_id;
- WFIFOSET(char_fd, 6);
+ WFIFOW(char_session, 0) = 0x3021;
+ WFIFOL(char_session, 2) = party_id;
+ WFIFOSET(char_session, 6);
}
// パーティ追加要求
@@ -173,34 +173,34 @@ void intif_party_addmember(int party_id, int account_id)
sd = map_id2sd(account_id);
if (sd != NULL)
{
- WFIFOW(char_fd, 0) = 0x3022;
- WFIFOL(char_fd, 2) = party_id;
- WFIFOL(char_fd, 6) = account_id;
- WFIFO_STRING(char_fd, 10, sd->status.name.to__actual(), 24);
- WFIFO_STRING(char_fd, 34, sd->bl_m->name_, 16);
- WFIFOW(char_fd, 50) = sd->status.base_level;
- WFIFOSET(char_fd, 52);
+ WFIFOW(char_session, 0) = 0x3022;
+ WFIFOL(char_session, 2) = party_id;
+ WFIFOL(char_session, 6) = account_id;
+ WFIFO_STRING(char_session, 10, sd->status.name.to__actual(), 24);
+ WFIFO_STRING(char_session, 34, sd->bl_m->name_, 16);
+ WFIFOW(char_session, 50) = sd->status.base_level;
+ WFIFOSET(char_session, 52);
}
}
// パーティ設定変更
void intif_party_changeoption(int party_id, int account_id, int exp, int item)
{
- WFIFOW(char_fd, 0) = 0x3023;
- WFIFOL(char_fd, 2) = party_id;
- WFIFOL(char_fd, 6) = account_id;
- WFIFOW(char_fd, 10) = exp;
- WFIFOW(char_fd, 12) = item;
- WFIFOSET(char_fd, 14);
+ WFIFOW(char_session, 0) = 0x3023;
+ WFIFOL(char_session, 2) = party_id;
+ WFIFOL(char_session, 6) = account_id;
+ WFIFOW(char_session, 10) = exp;
+ WFIFOW(char_session, 12) = item;
+ WFIFOSET(char_session, 14);
}
// パーティ脱退要求
void intif_party_leave(int party_id, int account_id)
{
- WFIFOW(char_fd, 0) = 0x3024;
- WFIFOL(char_fd, 2) = party_id;
- WFIFOL(char_fd, 6) = account_id;
- WFIFOSET(char_fd, 10);
+ WFIFOW(char_session, 0) = 0x3024;
+ WFIFOL(char_session, 2) = party_id;
+ WFIFOL(char_session, 6) = account_id;
+ WFIFOSET(char_session, 10);
}
// パーティ移動要求
@@ -208,13 +208,13 @@ void intif_party_changemap(dumb_ptr<map_session_data> sd, int online)
{
if (sd != NULL)
{
- WFIFOW(char_fd, 0) = 0x3025;
- WFIFOL(char_fd, 2) = sd->status.party_id;
- WFIFOL(char_fd, 6) = sd->status.account_id;
- WFIFO_STRING(char_fd, 10, sd->bl_m->name_, 16);
- WFIFOB(char_fd, 26) = online;
- WFIFOW(char_fd, 27) = sd->status.base_level;
- WFIFOSET(char_fd, 29);
+ WFIFOW(char_session, 0) = 0x3025;
+ WFIFOL(char_session, 2) = sd->status.party_id;
+ WFIFOL(char_session, 6) = sd->status.account_id;
+ WFIFO_STRING(char_session, 10, sd->bl_m->name_, 16);
+ WFIFOB(char_session, 26) = online;
+ WFIFOW(char_session, 27) = sd->status.base_level;
+ WFIFOSET(char_session, 29);
}
}
@@ -222,22 +222,22 @@ void intif_party_changemap(dumb_ptr<map_session_data> sd, int online)
void intif_party_message(int party_id, int account_id, XString mes)
{
size_t len = mes.size() + 1;
- WFIFOW(char_fd, 0) = 0x3027;
- WFIFOW(char_fd, 2) = len + 12;
- WFIFOL(char_fd, 4) = party_id;
- WFIFOL(char_fd, 8) = account_id;
- WFIFO_STRING(char_fd, 12, mes, len);
- WFIFOSET(char_fd, len + 12);
+ WFIFOW(char_session, 0) = 0x3027;
+ WFIFOW(char_session, 2) = len + 12;
+ WFIFOL(char_session, 4) = party_id;
+ WFIFOL(char_session, 8) = account_id;
+ WFIFO_STRING(char_session, 12, mes, len);
+ WFIFOSET(char_session, len + 12);
}
// パーティ競合チェック要求
void intif_party_checkconflict(int party_id, int account_id, CharName nick)
{
- WFIFOW(char_fd, 0) = 0x3028;
- WFIFOL(char_fd, 2) = party_id;
- WFIFOL(char_fd, 6) = account_id;
- WFIFO_STRING(char_fd, 10, nick.to__actual(), 24);
- WFIFOSET(char_fd, 34);
+ WFIFOW(char_session, 0) = 0x3028;
+ WFIFOL(char_session, 2) = party_id;
+ WFIFOL(char_session, 6) = account_id;
+ WFIFO_STRING(char_session, 10, nick.to__actual(), 24);
+ WFIFOSET(char_session, 34);
}
//-----------------------------------------------------------------
@@ -245,21 +245,21 @@ void intif_party_checkconflict(int party_id, int account_id, CharName nick)
// Wisp/Page reception
static
-int intif_parse_WisMessage(int fd)
+int intif_parse_WisMessage(Session *s)
{
// rewritten by [Yor]
dumb_ptr<map_session_data> sd;
- CharName from = stringish<CharName>(RFIFO_STRING<24>(fd, 8));
- CharName to = stringish<CharName>(RFIFO_STRING<24>(fd, 32));
+ CharName from = stringish<CharName>(RFIFO_STRING<24>(s, 8));
+ CharName to = stringish<CharName>(RFIFO_STRING<24>(s, 32));
- size_t len = RFIFOW(fd, 2) - 56;
- FString buf = RFIFO_STRING(fd, 56, len);
+ size_t len = RFIFOW(s, 2) - 56;
+ FString buf = RFIFO_STRING(s, 56, len);
if (battle_config.etc_log)
{
PRINTF("intif_parse_wismessage: id: %d, from: %s, to: %s\n",
- RFIFOL(fd, 4),
+ RFIFOL(s, 4),
from,
to);
}
@@ -270,76 +270,78 @@ int intif_parse_WisMessage(int fd)
{
// if source player not found in ignore list
{
- clif_wis_message(sd->fd, from, buf);
- intif_wis_replay(RFIFOL(fd, 4), 0); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
+ clif_wis_message(sd->sess, from, buf);
+ intif_wis_replay(RFIFOL(s, 4), 0); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
}
}
}
else
- intif_wis_replay(RFIFOL(fd, 4), 1); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
+ intif_wis_replay(RFIFOL(s, 4), 1); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
return 0;
}
// Wisp/page transmission result reception
static
-int intif_parse_WisEnd(int fd)
+int intif_parse_WisEnd(Session *s)
{
dumb_ptr<map_session_data> sd;
- CharName name = stringish<CharName>(RFIFO_STRING<24>(fd, 2));
- uint8_t flag = RFIFOB(fd, 26);
+ CharName name = stringish<CharName>(RFIFO_STRING<24>(s, 2));
+ uint8_t flag = RFIFOB(s, 26);
if (battle_config.etc_log)
// flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
PRINTF("intif_parse_wisend: player: %s, flag: %d\n",
name, flag);
sd = map_nick2sd(name);
if (sd != NULL)
- clif_wis_end(sd->fd, flag);
+ clif_wis_end(sd->sess, flag);
return 0;
}
// Received wisp message from map-server via char-server for ALL gm
static
-void mapif_parse_WisToGM(int fd)
+void mapif_parse_WisToGM(Session *s)
{
// 0x3003/0x3803 <packet_len>.w <wispname>.24B <min_gm_level>.w <message>.?B
int min_gm_level, len;
- if (RFIFOW(fd, 2) - 30 <= 0)
+ if (RFIFOW(s, 2) - 30 <= 0)
return;
- len = RFIFOW(fd, 2) - 30;
+ len = RFIFOW(s, 2) - 30;
- min_gm_level = RFIFOW(fd, 28);
- CharName Wisp_name = stringish<CharName>(RFIFO_STRING<24>(fd, 4));
- FString message = RFIFO_STRING(fd, 30, len);
+ min_gm_level = RFIFOW(s, 28);
+ CharName Wisp_name = stringish<CharName>(RFIFO_STRING<24>(s, 4));
+ FString message = RFIFO_STRING(s, 30, len);
// information is sended to all online GM
for (int i = 0; i < fd_max; i++)
{
- if (!session[i])
+ Session *s2 = session[i].get();
+ if (!s2)
continue;
- dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(session[i]->session_data.get()));
+ dumb_ptr<map_session_data> pl_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s2->session_data.get()));
if (pl_sd && pl_sd->state.auth)
+ {
if (pc_isGM(pl_sd) >= min_gm_level)
- clif_wis_message(i, Wisp_name, message);
+ clif_wis_message(s2, Wisp_name, message);
+ }
}
}
// アカウント変数通知
static
-int intif_parse_AccountReg(int fd)
+int intif_parse_AccountReg(Session *s)
{
int j, p;
- dumb_ptr<map_session_data> sd;
-
- if ((sd = map_id2sd(RFIFOL(fd, 4))) == NULL)
+ dumb_ptr<map_session_data> sd = map_id2sd(RFIFOL(s, 4));
+ if (sd == NULL)
return 1;
- for (p = 8, j = 0; p < RFIFOW(fd, 2) && j < ACCOUNT_REG_NUM;
+ for (p = 8, j = 0; p < RFIFOW(s, 2) && j < ACCOUNT_REG_NUM;
p += 36, j++)
{
- sd->status.account_reg[j].str = stringish<VarName>(RFIFO_STRING<32>(fd, p));
- sd->status.account_reg[j].value = RFIFOL(fd, p + 32);
+ sd->status.account_reg[j].str = stringish<VarName>(RFIFO_STRING<32>(s, p));
+ sd->status.account_reg[j].value = RFIFOL(s, p + 32);
}
sd->status.account_reg_num = j;
// PRINTF("intif: accountreg\n");
@@ -349,20 +351,20 @@ int intif_parse_AccountReg(int fd)
// 倉庫データ受信
static
-int intif_parse_LoadStorage(int fd)
+int intif_parse_LoadStorage(Session *s)
{
struct storage *stor;
dumb_ptr<map_session_data> sd;
- sd = map_id2sd(RFIFOL(fd, 4));
+ sd = map_id2sd(RFIFOL(s, 4));
if (sd == NULL)
{
if (battle_config.error_log)
PRINTF("intif_parse_LoadStorage: user not found %d\n",
- RFIFOL(fd, 4));
+ RFIFOL(s, 4));
return 1;
}
- stor = account2storage(RFIFOL(fd, 4));
+ stor = account2storage(RFIFOL(s, 4));
if (stor->storage_status == 1)
{ // Already open.. lets ignore this update
if (battle_config.error_log)
@@ -378,16 +380,16 @@ int intif_parse_LoadStorage(int fd)
return 1;
}
- if (RFIFOW(fd, 2) - 8 != sizeof(struct storage))
+ if (RFIFOW(s, 2) - 8 != sizeof(struct storage))
{
if (battle_config.error_log)
PRINTF("intif_parse_LoadStorage: data size error %d %zu\n",
- RFIFOW(fd, 2) - 8, sizeof(struct storage));
+ RFIFOW(s, 2) - 8, sizeof(struct storage));
return 1;
}
if (battle_config.save_log)
- PRINTF("intif_openstorage: %d\n", RFIFOL(fd, 4));
- RFIFO_STRUCT(fd, 8, *stor);
+ PRINTF("intif_openstorage: %d\n", RFIFOL(s, 4));
+ RFIFO_STRUCT(s, 8, *stor);
stor->dirty = 0;
stor->storage_status = 1;
sd->state.storage_open = 1;
@@ -400,77 +402,77 @@ int intif_parse_LoadStorage(int fd)
// 倉庫データ送信成功
static
-void intif_parse_SaveStorage(int fd)
+void intif_parse_SaveStorage(Session *s)
{
if (battle_config.save_log)
- PRINTF("intif_savestorage: done %d %d\n", RFIFOL(fd, 2),
- RFIFOB(fd, 6));
- storage_storage_saved(RFIFOL(fd, 2));
+ PRINTF("intif_savestorage: done %d %d\n", RFIFOL(s, 2),
+ RFIFOB(s, 6));
+ storage_storage_saved(RFIFOL(s, 2));
}
// パーティ作成可否
static
-void intif_parse_PartyCreated(int fd)
+void intif_parse_PartyCreated(Session *s)
{
if (battle_config.etc_log)
PRINTF("intif: party created\n");
- int account_id = RFIFOL(fd, 2);
- int fail = RFIFOB(fd, 6);
- int party_id = RFIFOL(fd, 7);
- PartyName name = stringish<PartyName>(RFIFO_STRING<24>(fd, 11));
+ int account_id = RFIFOL(s, 2);
+ int fail = RFIFOB(s, 6);
+ int party_id = RFIFOL(s, 7);
+ PartyName name = stringish<PartyName>(RFIFO_STRING<24>(s, 11));
party_created(account_id, fail, party_id, name);
}
// パーティ情報
static
-void intif_parse_PartyInfo(int fd)
+void intif_parse_PartyInfo(Session *s)
{
- if (RFIFOW(fd, 2) == 8)
+ if (RFIFOW(s, 2) == 8)
{
if (battle_config.error_log)
- PRINTF("intif: party noinfo %d\n", RFIFOL(fd, 4));
- party_recv_noinfo(RFIFOL(fd, 4));
+ PRINTF("intif: party noinfo %d\n", RFIFOL(s, 4));
+ party_recv_noinfo(RFIFOL(s, 4));
return;
}
// PRINTF("intif: party info %d\n",RFIFOL(fd,4));
- if (RFIFOW(fd, 2) != sizeof(struct party) + 4)
+ if (RFIFOW(s, 2) != sizeof(struct party) + 4)
{
if (battle_config.error_log)
PRINTF("intif: party info : data size error %d %d %zu\n",
- RFIFOL(fd, 4), RFIFOW(fd, 2),
+ RFIFOL(s, 4), RFIFOW(s, 2),
sizeof(struct party) + 4);
}
party p {};
- RFIFO_STRUCT(fd, 4, p);
+ RFIFO_STRUCT(s, 4, p);
party_recv_info(&p);
}
// パーティ追加通知
static
-void intif_parse_PartyMemberAdded(int fd)
+void intif_parse_PartyMemberAdded(Session *s)
{
if (battle_config.etc_log)
- PRINTF("intif: party member added %d %d %d\n", RFIFOL(fd, 2),
- RFIFOL(fd, 6), RFIFOB(fd, 10));
- party_member_added(RFIFOL(fd, 2), RFIFOL(fd, 6), RFIFOB(fd, 10));
+ PRINTF("intif: party member added %d %d %d\n", RFIFOL(s, 2),
+ RFIFOL(s, 6), RFIFOB(s, 10));
+ party_member_added(RFIFOL(s, 2), RFIFOL(s, 6), RFIFOB(s, 10));
}
// パーティ設定変更通知
static
-void intif_parse_PartyOptionChanged(int fd)
+void intif_parse_PartyOptionChanged(Session *s)
{
- party_optionchanged(RFIFOL(fd, 2), RFIFOL(fd, 6), RFIFOW(fd, 10),
- RFIFOW(fd, 12), RFIFOB(fd, 14));
+ party_optionchanged(RFIFOL(s, 2), RFIFOL(s, 6), RFIFOW(s, 10),
+ RFIFOW(s, 12), RFIFOB(s, 14));
}
// パーティ脱退通知
static
-void intif_parse_PartyMemberLeaved(int fd)
+void intif_parse_PartyMemberLeaved(Session *s)
{
- int party_id = RFIFOL(fd, 2);
- int account_id = RFIFOL(fd, 6);
- CharName name = stringish<CharName>(RFIFO_STRING<24>(fd, 10));
+ int party_id = RFIFOL(s, 2);
+ int account_id = RFIFOL(s, 6);
+ CharName name = stringish<CharName>(RFIFO_STRING<24>(s, 10));
if (battle_config.etc_log)
PRINTF("intif: party member leaved %d %d %s\n",
party_id, account_id, name);
@@ -479,40 +481,40 @@ void intif_parse_PartyMemberLeaved(int fd)
// パーティ解散通知
static
-void intif_parse_PartyBroken(int fd)
+void intif_parse_PartyBroken(Session *s)
{
- party_broken(RFIFOL(fd, 2));
+ party_broken(RFIFOL(s, 2));
}
// パーティ移動通知
static
-void intif_parse_PartyMove(int fd)
+void intif_parse_PartyMove(Session *s)
{
- int party_id = RFIFOL(fd, 2);
- int account_id = RFIFOL(fd, 6);
- MapName map = stringish<MapName>(RFIFO_STRING<16>(fd, 10));
- uint8_t online = RFIFOB(fd, 26);
- uint16_t lv = RFIFOW(fd, 27);
+ int party_id = RFIFOL(s, 2);
+ int account_id = RFIFOL(s, 6);
+ MapName map = stringish<MapName>(RFIFO_STRING<16>(s, 10));
+ uint8_t online = RFIFOB(s, 26);
+ uint16_t lv = RFIFOW(s, 27);
party_recv_movemap(party_id, account_id, map, online, lv);
}
// パーティメッセージ
static
-void intif_parse_PartyMessage(int fd)
+void intif_parse_PartyMessage(Session *s)
{
- size_t len = RFIFOW(fd, 2) - 12;
- FString buf = RFIFO_STRING(fd, 12, len);
- party_recv_message(RFIFOL(fd, 4), RFIFOL(fd, 8), buf);
+ size_t len = RFIFOW(s, 2) - 12;
+ FString buf = RFIFO_STRING(s, 12, len);
+ party_recv_message(RFIFOL(s, 4), RFIFOL(s, 8), buf);
}
//-----------------------------------------------------------------
// inter serverからの通信
// エラーがあれば0(false)を返すこと
// パケットが処理できれば1,パケット長が足りなければ2を返すこと
-int intif_parse(int fd)
+int intif_parse(Session *s)
{
int packet_len;
- int cmd = RFIFOW(fd, 0);
+ int cmd = RFIFOW(s, 0);
// パケットのID確認
if (cmd < 0x3800
|| cmd >=
@@ -525,13 +527,13 @@ int intif_parse(int fd)
packet_len = packet_len_table[cmd - 0x3800];
if (packet_len == -1)
{
- if (RFIFOREST(fd) < 4)
+ if (RFIFOREST(s) < 4)
return 2;
- packet_len = RFIFOW(fd, 2);
+ packet_len = RFIFOW(s, 2);
}
// if(battle_config.etc_log)
// PRINTF("intif_parse %d %x %d %d\n",fd,cmd,packet_len,RFIFOREST(fd));
- if (RFIFOREST(fd) < packet_len)
+ if (RFIFOREST(s) < packet_len)
{
return 2;
}
@@ -540,59 +542,59 @@ int intif_parse(int fd)
{
case 0x3800:
{
- FString mes = RFIFO_STRING(fd, 4, packet_len - 4);
+ FString mes = RFIFO_STRING(s, 4, packet_len - 4);
clif_GMmessage(NULL, mes, 0);
}
break;
case 0x3801:
- intif_parse_WisMessage(fd);
+ intif_parse_WisMessage(s);
break;
case 0x3802:
- intif_parse_WisEnd(fd);
+ intif_parse_WisEnd(s);
break;
case 0x3803:
- mapif_parse_WisToGM(fd);
+ mapif_parse_WisToGM(s);
break;
case 0x3804:
- intif_parse_AccountReg(fd);
+ intif_parse_AccountReg(s);
break;
case 0x3810:
- intif_parse_LoadStorage(fd);
+ intif_parse_LoadStorage(s);
break;
case 0x3811:
- intif_parse_SaveStorage(fd);
+ intif_parse_SaveStorage(s);
break;
case 0x3820:
- intif_parse_PartyCreated(fd);
+ intif_parse_PartyCreated(s);
break;
case 0x3821:
- intif_parse_PartyInfo(fd);
+ intif_parse_PartyInfo(s);
break;
case 0x3822:
- intif_parse_PartyMemberAdded(fd);
+ intif_parse_PartyMemberAdded(s);
break;
case 0x3823:
- intif_parse_PartyOptionChanged(fd);
+ intif_parse_PartyOptionChanged(s);
break;
case 0x3824:
- intif_parse_PartyMemberLeaved(fd);
+ intif_parse_PartyMemberLeaved(s);
break;
case 0x3825:
- intif_parse_PartyMove(fd);
+ intif_parse_PartyMove(s);
break;
case 0x3826:
- intif_parse_PartyBroken(fd);
+ intif_parse_PartyBroken(s);
break;
case 0x3827:
- intif_parse_PartyMessage(fd);
+ intif_parse_PartyMessage(s);
break;
default:
if (battle_config.error_log)
- PRINTF("intif_parse : unknown packet %d %x\n", fd,
- RFIFOW(fd, 0));
+ PRINTF("intif_parse : unknown packet %d %x\n", s,
+ RFIFOW(s, 0));
return 0;
}
// パケット読み飛ばし
- RFIFOSKIP(fd, packet_len);
+ RFIFOSKIP(s, packet_len);
return 1;
}
diff --git a/src/map/intif.hpp b/src/map/intif.hpp
index 244c230..0fe7182 100644
--- a/src/map/intif.hpp
+++ b/src/map/intif.hpp
@@ -7,7 +7,7 @@
# include "map.hpp"
-int intif_parse(int fd);
+int intif_parse(Session *);
void intif_GMmessage(XString mes);
diff --git a/src/map/magic-stmt.cpp b/src/map/magic-stmt.cpp
index 682d9bc..945faa9 100644
--- a/src/map/magic-stmt.cpp
+++ b/src/map/magic-stmt.cpp
@@ -263,7 +263,7 @@ void magic_unshroud(dumb_ptr<map_session_data> other_char)
other_char->state.shroud_active = 0;
// Now warp the caster out of and back into here to refresh everyone's display
char_update(other_char);
- clif_displaymessage(other_char->fd, "Your shroud has been dispelled!");
+ clif_displaymessage(other_char->sess, "Your shroud has been dispelled!");
// entity_effect(other_char, MAGIC_EFFECT_REVEAL);
}
@@ -401,7 +401,7 @@ int op_message(dumb_ptr<env_t>, const_array<val_t> args)
dumb_ptr<map_session_data> subject = ARGCHAR(0);
if (subject)
- clif_displaymessage(subject->fd, ARGSTR(1));
+ clif_displaymessage(subject->sess, ARGSTR(1));
return 0;
}
@@ -1458,7 +1458,7 @@ interval_t spell_run(dumb_ptr<invocation> invocation_, int allow_delete)
}
else
invocation_->script_pos = 0;
- clif_clearchar_id(invocation_->bl_id, BeingRemoveWhy::DEAD, caster->fd);
+ clif_clearchar_id(invocation_->bl_id, BeingRemoveWhy::DEAD, caster->sess);
}
REFRESH_INVOCATION; // Script may have killed the caster
break;
diff --git a/src/map/map.cpp b/src/map/map.cpp
index d2b604f..3817422 100644
--- a/src/map/map.cpp
+++ b/src/map/map.cpp
@@ -953,7 +953,7 @@ dumb_ptr<map_session_data> map_get_first_session(void)
dumb_ptr<map_session_data> map_get_next_session(dumb_ptr<map_session_data> d)
{
- return map_get_session_forward(d->fd + 1);
+ return map_get_session_forward(d->sess->fd + 1);
}
dumb_ptr<map_session_data> map_get_last_session(void)
@@ -963,7 +963,7 @@ dumb_ptr<map_session_data> map_get_last_session(void)
dumb_ptr<map_session_data> map_get_prev_session(dumb_ptr<map_session_data> d)
{
- return map_get_session_backward(d->fd - 1);
+ return map_get_session_backward(d->sess->fd - 1);
}
/*==========================================
@@ -1612,7 +1612,7 @@ void term_func(void)
}
for (int i = 0; i < fd_max; i++)
- delete_session(i);
+ delete_session(session[i].get());
map_removenpc();
diff --git a/src/map/map.hpp b/src/map/map.hpp
index 0038e67..897c619 100644
--- a/src/map/map.hpp
+++ b/src/map/map.hpp
@@ -174,7 +174,7 @@ struct map_session_data : block_list, SessionData
int weight, max_weight;
int cart_weight, cart_max_weight, cart_num, cart_max_num;
MapName mapname_;
- int fd; // use this, you idiots!
+ Session *sess; // use this, you idiots!
short to_x, to_y;
interval_t speed;
Opt1 opt1;
@@ -310,7 +310,7 @@ struct map_session_data : block_list, SessionData
IP4Address get_ip()
{
- return session[fd]->client_ip;
+ return sess->client_ip;
}
};
diff --git a/src/map/party.cpp b/src/map/party.cpp
index 9d7cae2..09f103e 100644
--- a/src/map/party.cpp
+++ b/src/map/party.cpp
@@ -205,7 +205,7 @@ int party_recv_info(const struct party *sp)
&& sd->status.party_id == p->party_id) ? sd.operator->() : NULL;
}
- clif_party_info(p, -1);
+ clif_party_info(p, nullptr);
for (i = 0; i < MAX_PARTY; i++)
{ // 設定情報の送信
@@ -231,7 +231,7 @@ int party_invite(dumb_ptr<map_session_data> sd, int account_id)
nullpo_ret(sd);
- if (!tsd || !p || !tsd->fd)
+ if (!tsd || !p || !tsd->sess)
return 0;
if (!battle_config.invite_request_check)
@@ -540,7 +540,7 @@ void party_recv_movemap(int party_id, int account_id, MapName mapname,
party_send_xy_clear(p); // 座標再通知要請
- clif_party_info(p, -1);
+ clif_party_info(p, nullptr);
}
// パーティメンバの移動
@@ -566,7 +566,7 @@ int party_send_movemap(dumb_ptr<map_session_data> sd)
party_check_member(p); // 所属を確認する
if (sd->status.party_id == p->party_id)
{
- clif_party_info(p, sd->fd);
+ clif_party_info(p, sd->sess);
clif_party_option(p, sd, 0x100);
sd->party_sended = 1;
}
diff --git a/src/map/pc.cpp b/src/map/pc.cpp
index 73639dd..168d124 100644
--- a/src/map/pc.cpp
+++ b/src/map/pc.cpp
@@ -623,7 +623,7 @@ int pc_authok(int id, int login_id2, TimeT connect_until_time,
if (sd->status.sex != sd->sex)
{
- clif_authfail_fd(sd->fd, 0);
+ clif_authfail_fd(sd->sess, 0);
return 1;
}
@@ -690,10 +690,10 @@ int pc_authok(int id, int login_id2, TimeT connect_until_time,
// This would leak information.
// It's better to make it obvious that players can see you.
if (false && bool(old_option & Option::INVISIBILITY))
- is_atcommand(sd->fd, sd, "@invisible", 0);
+ is_atcommand(sd->sess, sd, "@invisible", 0);
if (bool(old_option & Option::HIDE))
- is_atcommand(sd->fd, sd, "@hide", 0);
+ is_atcommand(sd->sess, sd, "@hide", 0);
// atcommand_hide might already send it, but also might not
clif_changeoption(sd);
}
@@ -765,7 +765,7 @@ int pc_authok(int id, int login_id2, TimeT connect_until_time,
char tmpstr[] = WITH_TIMESTAMP("Your account time limit is: ");
REPLACE_TIMESTAMP(tmpstr, connect_until_time);
- clif_wis_message(sd->fd, wisp_server_name, const_(tmpstr));
+ clif_wis_message(sd->sess, wisp_server_name, const_(tmpstr));
}
pc_calcstatus(sd, 1);
@@ -783,7 +783,7 @@ void pc_show_motd(dumb_ptr<map_session_data> sd)
FString buf;
while (in.getline(buf))
{
- clif_displaymessage(sd->fd, buf);
+ clif_displaymessage(sd->sess, buf);
}
}
}
@@ -800,7 +800,7 @@ int pc_authfail(int id)
if (sd == NULL)
return 1;
- clif_authfail_fd(sd->fd, 0);
+ clif_authfail_fd(sd->sess, 0);
return 0;
}
@@ -2890,7 +2890,7 @@ int pc_attack(dumb_ptr<map_session_data> sd, int target_id, int type)
if (bl->bl_type == BL::NPC)
{ // monster npcs [Valaris]
- npc_click(sd, RFIFOL(sd->fd, 2));
+ npc_click(sd, RFIFOL(sd->sess, 2));
return 0;
}
@@ -3097,7 +3097,7 @@ int pc_gainexp_reason(dumb_ptr<map_session_data> sd, int base_exp, int job_exp,
FString output = STRPRINTF(
"Experienced Gained Base:%d Job:%d",
base_exp, job_exp);
- clif_displaymessage(sd->fd, output);
+ clif_displaymessage(sd->sess, output);
}
return 0;
@@ -5201,13 +5201,13 @@ void pc_autosave_sub(dumb_ptr<map_session_data> sd)
{
nullpo_retv(sd);
- if (save_flag == 0 && sd->fd > last_save_fd)
+ if (save_flag == 0 && sd->sess->fd > last_save_fd)
{
pc_makesavestatus(sd);
chrif_save(sd);
save_flag = 1;
- last_save_fd = sd->fd;
+ last_save_fd = sd->sess->fd;
}
}
@@ -5221,7 +5221,7 @@ void pc_autosave(TimerData *, tick_t)
save_flag = 0;
clif_foreachclient(pc_autosave_sub);
if (save_flag == 0)
- last_save_fd = 0;
+ last_save_fd = -1;
interval_t interval = autosave_time / (clif_countusers() + 1);
if (interval <= interval_t::zero())
@@ -5231,15 +5231,15 @@ void pc_autosave(TimerData *, tick_t)
).detach();
}
-int pc_read_gm_account(int fd)
+int pc_read_gm_account(Session *s)
{
gm_accountm.clear();
// (RFIFOW(fd, 2) - 4) / 5
- for (int i = 4; i < RFIFOW(fd, 2); i += 5)
+ for (int i = 4; i < RFIFOW(s, 2); i += 5)
{
- int account_id = RFIFOL(fd, i);
- uint8_t level = RFIFOB(fd, i + 4);
+ int account_id = RFIFOL(s, i);
+ uint8_t level = RFIFOB(s, i + 4);
gm_accountm[account_id] = level;
}
return gm_accountm.size();
diff --git a/src/map/pc.hpp b/src/map/pc.hpp
index 54394a2..48ba8f3 100644
--- a/src/map/pc.hpp
+++ b/src/map/pc.hpp
@@ -54,7 +54,7 @@ int pc_setrestartvalue(dumb_ptr<map_session_data> sd, int type);
void pc_makesavestatus(dumb_ptr<map_session_data>);
int pc_setnewpc(dumb_ptr<map_session_data>, int, int, int, tick_t, SEX);
int pc_authok(int, int, TimeT, short tmw_version, const struct mmo_charstatus *);
-int pc_authfail(int);
+int pc_authfail(int accid);
EPOS pc_equippoint(dumb_ptr<map_session_data> sd, int n);
@@ -146,7 +146,7 @@ void pc_set_gm_level(int account_id, uint8_t level);
void pc_setstand(dumb_ptr<map_session_data> sd);
void pc_cleanup(dumb_ptr<map_session_data> sd); // [Fate] Clean up after a logged-out PC
-int pc_read_gm_account(int fd);
+int pc_read_gm_account(Session *);
int pc_setinvincibletimer(dumb_ptr<map_session_data> sd, interval_t);
int pc_delinvincibletimer(dumb_ptr<map_session_data> sd);
int pc_logout(dumb_ptr<map_session_data> sd); // [fate] Player logs out
diff --git a/src/map/script.cpp b/src/map/script.cpp
index 279e541..6bd4543 100644
--- a/src/map/script.cpp
+++ b/src/map/script.cpp
@@ -3857,7 +3857,7 @@ void builtin_gmcommand(ScriptState *st)
sd = script_rid2sd(st);
dumb_string cmd = conv_str(st, &AARGO2(2));
- is_atcommand(sd->fd, sd, cmd, 99);
+ is_atcommand(sd->sess, sd, cmd, 99);
}
@@ -3914,7 +3914,7 @@ void builtin_message(ScriptState *st)
dumb_ptr<map_session_data> pl_sd = map_nick2sd(player);
if (pl_sd == NULL)
return;
- clif_displaymessage(pl_sd->fd, msg);
+ clif_displaymessage(pl_sd->sess, msg);
}
diff --git a/src/map/tmw.cpp b/src/map/tmw.cpp
index 9841a75..7e661bb 100644
--- a/src/map/tmw.cpp
+++ b/src/map/tmw.cpp
@@ -81,8 +81,8 @@ int tmw_CheckChatSpam(dumb_ptr<map_session_data> sd, XString message)
(sd->chat_lines_in >= battle_config.chat_spam_warn
|| sd->chat_total_repeats >= battle_config.chat_spam_warn))
{
- clif_displaymessage(sd->fd, "WARNING: You are about to be automatically banned for spam!");
- clif_displaymessage(sd->fd, "WARNING: Please slow down, do not repeat, and do not SHOUT!");
+ clif_displaymessage(sd->sess, "WARNING: You are about to be automatically banned for spam!");
+ clif_displaymessage(sd->sess, "WARNING: Please slow down, do not repeat, and do not SHOUT!");
}
return 0;
@@ -107,12 +107,12 @@ void tmw_AutoBan(dumb_ptr<map_session_data> sd, ZString reason, int length)
FString anotherbuf = STRPRINTF("You have been banned for %s spamming. Please do not spam.",
reason);
- clif_displaymessage(sd->fd, anotherbuf);
+ clif_displaymessage(sd->sess, anotherbuf);
/* type: 2 - ban(year, month, day, hour, minute, second) */
HumanTimeDiff ban_len {};
ban_len.hour = length;
chrif_char_ask_name(-1, sd->status.name, 2, ban_len);
- clif_setwaitclose(sd->fd);
+ clif_setwaitclose(sd->sess);
}
// Returns true if more than 50% of input message is caps or punctuation