Skip to content

Commit

Permalink
Convert PACKET_MAPCHAR_AUTH_REQ 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 216c752 commit 8831646
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 18 deletions.
22 changes: 13 additions & 9 deletions src/char/char.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#include "common/apipackets.h"
#include "common/cbasetypes.h"
#include "common/charloginpackets.h"
#include "common/mapcharpackets.h"
#include "common/chunked.h"
#include "common/conf.h"
#include "common/console.h"
Expand Down Expand Up @@ -3781,13 +3782,16 @@ static void char_parse_frommap_auth_request(int fd)
struct char_auth_node* node;
struct mmo_charstatus* cd;

int account_id = RFIFOL(fd,2);
int char_id = RFIFOL(fd,6);
int login_id1 = RFIFOL(fd,10);
char sex = RFIFOB(fd,14);
uint32 ip = ntohl(RFIFOL(fd,15));
char standalone = RFIFOB(fd, 19);
RFIFOSKIP(fd,20);
const struct PACKET_MAPCHAR_AUTH_REQ *p = RFIFOP(fd, 0);

int account_id = p->account_id;
int char_id = p->char_id;
int login_id1 = p->login_id1;
char sex = p->sex;
uint32 ip = ntohl(p->client_addr);
char standalone = p->standalone;

RFIFOSKIP(fd, sizeof(struct PACKET_MAPCHAR_AUTH_REQ));

node = (struct char_auth_node*)idb_get(auth_db, account_id);
cd = (struct mmo_charstatus*)uidb_get(chr->char_db_,char_id);
Expand Down Expand Up @@ -4040,8 +4044,8 @@ static int char_parse_frommap(int fd)
chr->parse_frommap_ping(fd);
break;

case 0x2b26: // auth request from map-server
if (RFIFOREST(fd) < 20)
case HEADER_MAPCHAR_AUTH_REQ: // auth request from map-server
if (RFIFOREST(fd) < sizeof(struct PACKET_MAPCHAR_AUTH_REQ))
return 0;

{
Expand Down
11 changes: 11 additions & 0 deletions src/common/mapcharpackets.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@
#pragma pack(push, 1)
#endif // not NetBSD < 6 / Solaris

struct PACKET_MAPCHAR_AUTH_REQ {
int16 packetType;
int account_id;
int char_id;
int login_id1;
uint8 sex;
int client_addr;
uint8 standalone; // 0 - real player (false) / 1 - standalone/server generated (true)
} __attribute__((packed));
DEFINE_PACKET_ID(MAPCHAR_AUTH_REQ, 0x2b26)

struct PACKET_MAPCHAR_AGENCY_JOIN_PARTY_REQ {
int16 packetType;
int char_id;
Expand Down
21 changes: 12 additions & 9 deletions src/map/chrif.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "common/HPM.h"
#include "common/cbasetypes.h"
#include "common/ers.h"
#include "common/mapcharpackets.h"
#include "common/memmgr.h"
#include "common/msgtable.h"
#include "common/nullpo.h"
Expand Down Expand Up @@ -470,15 +471,17 @@ static void chrif_authreq(struct map_session_data *sd, bool hstandalone)
return;
}

WFIFOHEAD(chrif->fd,20);
WFIFOW(chrif->fd,0) = 0x2b26;
WFIFOL(chrif->fd,2) = sd->status.account_id;
WFIFOL(chrif->fd,6) = sd->status.char_id;
WFIFOL(chrif->fd,10) = sd->login_id1;
WFIFOB(chrif->fd,14) = sd->status.sex;
WFIFOL(chrif->fd,15) = htonl(sockt->session[sd->fd]->client_addr);
WFIFOB(chrif->fd,19) = hstandalone ? 1 : 0;
WFIFOSET(chrif->fd,20);
WFIFOHEAD(chrif->fd, sizeof(struct PACKET_MAPCHAR_AUTH_REQ));
struct PACKET_MAPCHAR_AUTH_REQ *p = WFIFOP(chrif->fd, 0);
p->packetType = HEADER_MAPCHAR_AUTH_REQ;
p->account_id = sd->status.account_id;
p->char_id = sd->status.char_id;
p->login_id1 = sd->login_id1;
p->sex = sd->status.sex;
p->client_addr = htonl(sockt->session[sd->fd]->client_addr);
p->standalone = hstandalone ? 1 : 0;
WFIFOSET(chrif->fd, sizeof(struct PACKET_MAPCHAR_AUTH_REQ));

chrif->sd_to_auth(sd, ST_LOGIN);
}

Expand Down

0 comments on commit 8831646

Please sign in to comment.