Skip to content

Commit

Permalink
Convert CHARLOGIN_SET_ACCOUNT_ONLINE to struct format
Browse files Browse the repository at this point in the history
  • Loading branch information
guilherme-gm committed Aug 3, 2024
1 parent 8831646 commit 73da955
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
11 changes: 7 additions & 4 deletions src/char/char.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,13 @@ static struct DBData char_create_online_char_data(union DBKey key, va_list args)

static void char_set_account_online(int account_id)
{
WFIFOHEAD(chr->login_fd,6);
WFIFOW(chr->login_fd,0) = 0x272b;
WFIFOL(chr->login_fd,2) = account_id;
WFIFOSET(chr->login_fd,6);
WFIFOHEAD(chr->login_fd, sizeof(struct PACKET_CHARLOGIN_SET_ACCOUNT_ONLINE));

struct PACKET_CHARLOGIN_SET_ACCOUNT_ONLINE *p = WFIFOP(chr->login_fd, 0);
p->packetType = HEADER_CHARLOGIN_SET_ACCOUNT_ONLINE;
p->account_id = account_id;

WFIFOSET(chr->login_fd, sizeof(*p));
}

static void char_set_account_offline(int account_id)
Expand Down
6 changes: 6 additions & 0 deletions src/common/charloginpackets.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
#pragma pack(push, 1)
#endif // not NetBSD < 6 / Solaris

struct PACKET_CHARLOGIN_SET_ACCOUNT_ONLINE {
int16 packetType;
int account_id;
} __attribute__((packed));
DEFINE_PACKET_ID(CHARLOGIN_SET_ACCOUNT_ONLINE, 0x272b)

struct PACKET_CHARLOGIN_ONLINE_ACCOUNTS {
int16 packetType;
uint16 packetLength;
Expand Down
13 changes: 8 additions & 5 deletions src/login/login.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,9 +663,12 @@ static void login_fromchar_parse_unban(int fd, int id, const char *const ip)

static void login_fromchar_parse_account_online(int fd, int id)
{
login->add_online_user(id, RFIFOL(fd,2));
lapiif->connect_user_char(id, RFIFOL(fd, 2));
RFIFOSKIP(fd, 6);
const struct PACKET_CHARLOGIN_SET_ACCOUNT_ONLINE *p = RFIFOP(fd, 0);

login->add_online_user(id, p->account_id);
lapiif->connect_user_char(id, p->account_id);

RFIFOSKIP(fd, sizeof(*p));
}

static void login_fromchar_parse_account_offline(int fd)
Expand Down Expand Up @@ -939,8 +942,8 @@ static int login_parse_fromchar(int fd)
}
break;

case 0x272b: // Set account_id to online [Wizputer]
if( RFIFOREST(fd) < 6 )
case HEADER_CHARLOGIN_SET_ACCOUNT_ONLINE: // Set account_id to online [Wizputer]
if (RFIFOREST(fd) < sizeof(struct PACKET_CHARLOGIN_SET_ACCOUNT_ONLINE))
return 0;
login->fromchar_parse_account_online(fd, id);
break;
Expand Down

0 comments on commit 73da955

Please sign in to comment.