diff options
author | ai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2010-12-22 23:05:50 +0000 |
---|---|---|
committer | ai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2010-12-22 23:05:50 +0000 |
commit | 4b60855ad391b0b827d76773dcacb69f8baa8729 (patch) | |
tree | 94b6241e7608abfa0751f0a430ee4081fd5f4a1a | |
parent | 7e475e75934820e41b9cdff14d69ef75ad446da5 (diff) | |
download | hercules-4b60855ad391b0b827d76773dcacb69f8baa8729.tar.gz hercules-4b60855ad391b0b827d76773dcacb69f8baa8729.tar.bz2 hercules-4b60855ad391b0b827d76773dcacb69f8baa8729.tar.xz hercules-4b60855ad391b0b827d76773dcacb69f8baa8729.zip |
* NPC shop buy list received from the client is now validated for scripted shops (OnBuyItem), before the control is transfered to the script, as well (bugreport:3680, since r5841, related r8525).
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14616 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r-- | Changelog-Trunk.txt | 1 | ||||
-rw-r--r-- | src/map/npc.c | 10 |
2 files changed, 9 insertions, 2 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 3f595f1c5..21f369862 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -1,6 +1,7 @@ Date Added 2010/12/22 + * NPC shop buy list received from the client is now validated for scripted shops (OnBuyItem), before the control is transfered to the script, as well (bugreport:3680, since r5841, related r8525). [Ai4rei] * Resolved random compiler warnings. [Ai4rei] - Silenced pointer size mismatch gcc warning for variables passed to script_setarray_pc (bugreport:4661, since r14613). * Fixed sql mapreg loading code specifying output buffer size for SqlStmt_BindColumn without zero-terminator, leading to truncations of variable names and/or their values when using the maximum length (bugreport:1939, since r11245). [Ai4rei] diff --git a/src/map/npc.c b/src/map/npc.c index 545ec9add..ca49c084f 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -1261,8 +1261,6 @@ int npc_buylist(struct map_session_data* sd, int n, unsigned short* item_list) nd = npc_checknear(sd,map_id2bl(sd->npc_shopid)); if( nd == NULL ) return 3; - if( nd->master_nd != NULL ) //Script-based shops. - return npc_buylist_sub(sd,n,item_list,nd->master_nd); if( nd->subtype != SHOP ) return 3; @@ -1297,6 +1295,11 @@ int npc_buylist(struct map_session_data* sd, int n, unsigned short* item_list) amount = item_list[i*2+0] = 1; } + if( nd->master_nd ) + {// Script-controlled shops decide by themselves, what can be bought and for what price. + continue; + } + switch( pc_checkadditem(sd,nameid,amount) ) { case ADDITEM_EXIST: @@ -1316,6 +1319,9 @@ int npc_buylist(struct map_session_data* sd, int n, unsigned short* item_list) w += itemdb_weight(nameid) * amount; } + if( nd->master_nd != NULL ) //Script-based shops. + return npc_buylist_sub(sd,n,item_list,nd->master_nd); + if( z > (double)sd->status.zeny ) return 1; // Not enough Zeny if( w + sd->weight > sd->max_weight ) |