Issue information

Issue ID
#6870
Status
Fixed
Severity
None
Started
Hercules Elf Bot
Nov 7, 2012 22:25
Last Post
Hercules Elf Bot
Nov 8, 2012 0:50
Confirmation
Yes (1)
No (0)

Hercules Elf Bot - Nov 7, 2012 22:25

Originally posted by [b]Napster[/b]
i have test on client 2010 2011 2012
and rA last SVN


i found problem about zeny limit show wrong display update

when player limit upto 100,000 z

1. create buying shop and limit zeny [b][color=#ff0000]100,000 z[/color][/b]

[img]https://dl.dropbox.com/u/16689832/buying/1.jpg[/img]

2. ok ! build shop now (display player 1)

[img]https://dl.dropbox.com/u/16689832/buying/2.jpg[/img]

3. player to selling item update itemlist and zeny limit

[img]https://dl.dropbox.com/u/16689832/buying/3.jpg[/img]

selling green potion 1 ea but wrong zenylimit update when limit upto [color=#ff0000][b]100,000 z[/b][/color]

[b]PS. if zenylimit around 1~80000 not found problem this[/b]

[CODE]
/// Updates the zeny limit and an item in the buying store item list (ZC_UPDATE_ITEM_FROM_BUYING_STORE).
/// 081b <name id>.W <amount>.W <limit zeny>.L
void clif_buyingstore_update_item(struct map_session_data* sd, unsigned short nameid, unsigned short amount)
{
int fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x81b));
WFIFOW(fd,0) = 0x81b;
WFIFOW(fd,2) = nameid;
WFIFOW(fd,4) = amount; // amount of nameid received
WFIFOW(fd,6) = sd->buyingstore.zenylimit;
WFIFOSET(fd,packet_len(0x81b));
}
[/CODE]

this code update client and buying progress

[CODE]
// process item list
for( i = 0; i < count; i++ )
{// itemlist: <index>.W <name id>.W <amount>.W
unsigned short nameid, amount;
int index;
index = RBUFW(itemlist,i*6+0)-2;
nameid = RBUFW(itemlist,i*6+2);
amount = RBUFW(itemlist,i*6+4);
ARR_FIND( 0, pl_sd->buyingstore.slots, listidx, pl_sd->buyingstore.items[listidx].nameid == nameid );
zeny = amount*pl_sd->buyingstore.items[listidx].price;
// log
log_zeny(sd, LOG_TYPE_BUYING_STORE, pl_sd, zeny);
// move item
pc_additem(pl_sd, &sd->status.inventory[index], amount, LOG_TYPE_BUYING_STORE);
pc_delitem(sd, index, amount, 1, 0, LOG_TYPE_BUYING_STORE);
pl_sd->buyingstore.items[listidx].amount-= amount;
// pay up
pc_payzeny(pl_sd, zeny);
pc_getzeny(sd, zeny);
pl_sd->buyingstore.zenylimit-= zeny;
// notify clients
clif_buyingstore_delete_item(sd, index, amount, pl_sd->buyingstore.items[listidx].price);
clif_buyingstore_update_item(pl_sd, nameid, amount);
}
[/CODE]

please confirm this problem thankyou

Hercules Elf Bot - Nov 7, 2012 22:59

Originally posted by [b]Ind[/b]
according to the description the zeny is supposed to be long
[code]
/// 081b <name id>.W <amount>.W <limit zeny>.L
[/code]
but the code sends it as short
[code]
WFIFOW(fd,6) = sd->buyingstore.zenylimit;
[/code]
since the length of packet 0x81b is 10 i'd say its that WFIFOW that should be WFIFOL

Hercules Elf Bot - Nov 7, 2012 23:11

Originally posted by [b]Napster[/b]
Oh! i see

fix this ?
[CODE]
WFIFOL(fd,6) = sd->buyingstore.zenylimit;
[/CODE]

Hercules Elf Bot - Nov 7, 2012 23:23

Originally posted by [b]Ind[/b]
I'm not sure if thats it, and I cant test atm, can you try? (yes that as you highlighted)

Hercules Elf Bot - Nov 7, 2012 23:32

Originally posted by [b]mkbu95[/b]
I can confirm this, and I think I know why the problem exists.
Take a look on the capture from WPE:
[quote][color="blue"]15 08[/color] [color="red"]61 00[/color] [color="green"]A0 86 [b]01 00[/b][/color] 01 61 65 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5F 02 0A 00 E8 03 00
00[/quote]

Now, i'll try to explain but I'm not totally sure of some things.
You read the number backwards, like instead of 15 08, you do 08 15.

[color="blue"]blue color[/color] - packet header, 0x0815
[color="red"]red color[/color] - packet length, 97
[color="green"]green color[/color] - here is the tricky thing. [b]86A0[/b]=34464 which was the value I was getting. but, [b]186A0[/b]=100000 which is the actual zeny limit.

My conclusion is that a WORD (2 bytes) is not being sent correctly, meaning that it is LONG (4 bytes).

@edit
Ind, changing to WFIFOL fixes.

This post has been edited by mkbu95 on Nov 7, 2012 23:39

Hercules Elf Bot - Nov 7, 2012 23:46

Originally posted by [b]Napster[/b]
Confirm fix [color=#282828][font=helvetica, arial, sans-serif][size=3]WFIFOL [/size][/font][/color]ok :)

Hercules Elf Bot - Nov 8, 2012 0:50

Originally posted by [b]Ind[/b]
Fixed in [rev=16869] thank you all