Originally posted by [b]Paradox924X[/b]
http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=4544
trade_traderequest() makes several calls to clif_tradestart(), as seen in the code copied below:
CODE
void trade_traderequest(struct map_session_data *sd, struct map_session_data *target_sd)
{
int level;
nullpo_retv(sd);
if (map[sd->bl.m].flag.notrade) {
clif_displaymessage (sd->fd, msg_txt(272));
return; //Can't trade in notrade mapflag maps.
}
if (target_sd == NULL || sd == target_sd) {
clif_tradestart(sd, 1); // character does not exist
return;
}
if (target_sd->npc_id)
{ //Trade fails if you are using an NPC.
clif_tradestart(sd, 2);
return;
}
if (!battle_config.invite_request_check) {
if (target_sd->guild_invite > 0 || target_sd->party_invite > 0 || target_sd->adopt_invite) {
clif_tradestart(sd, 2);
return;
}
}
if ((target_sd->trade_partner != 0) || (sd->trade_partner != 0)) {
clif_tradestart(sd, 2); // person is in another trade
return;
}
level = pc_isGM(sd);
if ( !pc_can_give_items(level) || !pc_can_give_items(pc_isGM(target_sd)) ) //check if both GMs are allowed to trade
{
clif_displaymessage(sd->fd, msg_txt(246));
clif_tradestart(sd, 2); // GM is not allowed to trade
return;
}
//Fixed. Only real GMs can request trade from far away! [Lupus]
if (level < battle_config.lowest_gm_level && (sd->bl.m != target_sd->bl.m ||
!check_distance_bl(&sd->bl, &target_sd->bl, TRADE_DISTANCE)
)) {
clif_tradestart(sd, 0); // too far
return;
}
target_sd->trade_partner = sd->status.account_id;
sd->trade_partner = target_sd->status.account_id;
clif_traderequest(target_sd, sd->status.name);
}
Unfortunately, the way clif_tradestart() is written requires a trade partner before it actually sends anything:
CODE
void clif_tradestart(struct map_session_data* sd, uint8 type)
{
int fd = sd->fd;
#if PACKETVER < 6
WFIFOHEAD(fd,packet_len(0xe7));
WFIFOW(fd,0) = 0xe7;
WFIFOB(fd,2) = type;
WFIFOSET(fd,packet_len(0xe7));
#else
struct map_session_data* tsd = map_id2sd(sd->trade_partner);
if( !tsd ) return;
WFIFOHEAD(fd,packet_len(0x1f5));
WFIFOW(fd,0) = 0x1f5;
WFIFOB(fd,2) = type;
WFIFOL(fd,3) = tsd->status.char_id;
WFIFOW(fd,7) = tsd->status.base_level;
WFIFOSET(fd,packet_len(0x1f5));
#endif
}
As seen in the code for trade_traderequest() at the top, the value of sd->trade_partner is not set until the very end, when all the other checks have failed.
Thus, none of the clif_tradestart() requests display any messages because sd->trade_partner will be empty (0).
This post has been edited by Paradox924X: Nov 9 2010, 02:43 PM