summaryrefslogtreecommitdiff
path: root/src/map/clif.c
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2016-02-22 02:46:55 +0100
committerHaru <haru@dotalux.com>2016-02-24 21:00:33 +0100
commitc1ab5a9db773d399c86eb59a3dded649387480c0 (patch)
tree2dda8a10f9c555c3cbeb29cf99de7f68706f2ba0 /src/map/clif.c
parenta3977169437e507b963a0abc2ede5478cc1be320 (diff)
downloadhercules-c1ab5a9db773d399c86eb59a3dded649387480c0.tar.gz
hercules-c1ab5a9db773d399c86eb59a3dded649387480c0.tar.bz2
hercules-c1ab5a9db773d399c86eb59a3dded649387480c0.tar.xz
hercules-c1ab5a9db773d399c86eb59a3dded649387480c0.zip
Edited npc->cashshop_buylist() to use the new struct itemlist
- The npc-side code no longer depends on the client packet data layout. Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map/clif.c')
-rw-r--r--src/map/clif.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 5e0c6f568..9e0977cc4 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -15434,16 +15434,25 @@ void clif_parse_cashshop_buy(int fd, struct map_session_data *sd)
int len = RFIFOW(fd,2);
int points = RFIFOL(fd,4);
int count = RFIFOW(fd,8);
- unsigned short *item_list = NULL;
+ struct itemlist item_list = { 0 };
+ int i;
if( len < 10 || len != 10 + count * 4) {
ShowWarning("Player %d sent incorrect cash shop buy packet (len %d:%d)!\n", sd->status.char_id, len, 10 + count * 4);
return;
}
- item_list = aMalloc(sizeof(*item_list) * 2 * count);
- memcpy(item_list, RFIFOP(fd,10), sizeof(*item_list) * 2 * count);
- fail = npc->cashshop_buylist(sd,points,count,item_list);
- aFree(item_list);
+ VECTOR_INIT(item_list);
+ VECTOR_ENSURE(item_list, count, 1);
+ for (i = 0; i < count; i++) {
+ struct itemlist_entry entry = { 0 };
+
+ entry.amount = RFIFOW(fd, 10 + 4 * i);
+ entry.id = RFIFOW(fd, 10 + 4 * i + 2); // Nameid
+
+ VECTOR_PUSH(item_list, entry);
+ }
+ fail = npc->cashshop_buylist(sd, points, &item_list);
+ VECTOR_CLEAR(item_list);
#endif
}