Skip to content

Commit

Permalink
Fix trade issue where items would not be sent to storage as expected.
Browse files Browse the repository at this point in the history
The storage or inventory destination is included in the ACCEPT_TRADE
message from the client.  It was previously, only sent after the client
had received acknowledgement from the server that the first accept
had been received.  If a player clicked the accept button the second time
very quickly, before the receipt, the destination would not be included in
the message. - nor would the trade log get set.
This fix sends the destination information with all ACCEPT_TRADE
messages, and also sets the trade log.  All ACCEPT_TRADE messages always
included the bytes but just did not set them unless it had had the receipt.
I did try a different fix that prevented sending the second
ACCEPT_TRADE message until the receipt was received, it was just overly
complex due to the vast range of possible states and messages.
  • Loading branch information
pjbroad committed Feb 26, 2022
1 parent ecff412 commit 75ddf71
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions trade.c
Expand Up @@ -362,14 +362,11 @@ static int click_trade_handler(window_info *win, int mx, int my, Uint32 flags)
my_tcp_send(str, 1);
do_click_sound();
} else {
str[0]= ACCEPT_TRADE;
if(trade_you_accepted==1){
int i;
for(i=0;i<MAX_ITEMS;i++){
str[i+1]=(others_trade_list[i].quantity>0)*others_trade_list[i].type;
}
trade_accepted(other_player_trade_name, your_trade_list, others_trade_list, MAX_ITEMS);
}
int i;
str[0] = ACCEPT_TRADE;
for(i = 0; i < MAX_ITEMS; i++)
str[i + 1] = (others_trade_list[i].quantity > 0) * others_trade_list[i].type;
trade_accepted(other_player_trade_name, your_trade_list, others_trade_list, MAX_ITEMS);
my_tcp_send(str, MAX_ITEMS + 1);
do_click_sound();
}
Expand Down

0 comments on commit 75ddf71

Please sign in to comment.