summaryrefslogtreecommitdiff
path: root/src/map/pc.c
diff options
context:
space:
mode:
authorDennis Friis <peavey@placid.dk>2008-10-04 18:38:21 +0000
committerDennis Friis <peavey@placid.dk>2008-10-04 18:38:21 +0000
commita98907850bccc14fbdbe0eca1e99433f905119a6 (patch)
tree9b43dbc7ed3debdf0235b173f8051ec37699afec /src/map/pc.c
parentf607d15aca6a0eefd350b0643e42180625310967 (diff)
downloadtmwa-a98907850bccc14fbdbe0eca1e99433f905119a6.tar.gz
tmwa-a98907850bccc14fbdbe0eca1e99433f905119a6.tar.bz2
tmwa-a98907850bccc14fbdbe0eca1e99433f905119a6.tar.xz
tmwa-a98907850bccc14fbdbe0eca1e99433f905119a6.zip
relax dropstealing protection. Mantis #429, patch by fate.
Diffstat (limited to 'src/map/pc.c')
-rw-r--r--src/map/pc.c92
1 files changed, 53 insertions, 39 deletions
diff --git a/src/map/pc.c b/src/map/pc.c
index f9e564e..6d7d3f3 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -2932,53 +2932,67 @@ int pc_dropitem(struct map_session_data *sd,int n,int amount)
* アイテムを拾う
*------------------------------------------
*/
+
+static int
+can_pick_item_up_from(struct map_session_data *self, int other_id)
+{
+ /* From ourselves or from no-one? */
+ if (!self
+ || self->bl.id == other_id
+ || !other_id)
+ return 1;
+
+ struct map_session_data *other = map_id2sd(other_id);
+
+ /* From our partner? */
+ if (other && self->status.partner_id == other->status.char_id)
+ return 1;
+
+ /* From someone who is far away? */
+ /* On another map? */
+ if (other->bl.m != self->bl.m)
+ return 1;
+ else {
+ int distance_x = abs(other->bl.x - self->bl.x);
+ int distance_y = abs(other->bl.y - self->bl.y);
+ int distance = (distance_x > distance_y) ? distance_x : distance_y;
+
+ return distance > battle_config.drop_pickup_safety_zone;
+ }
+}
+
int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem)
{
int flag;
unsigned int tick = gettick();
- struct map_session_data *first_sd = NULL,*second_sd = NULL,*third_sd = NULL;
nullpo_retr(0, sd);
nullpo_retr(0, fitem);
- if(fitem->first_get_id > 0) {
- first_sd = map_id2sd(fitem->first_get_id);
- if(tick < fitem->first_get_tick) {
- if(fitem->first_get_id != sd->bl.id) {
- clif_additem(sd,0,0,6);
- return 0;
- }
- }
- else if(fitem->second_get_id > 0) {
- second_sd = map_id2sd(fitem->second_get_id);
- if(tick < fitem->second_get_tick) {
- if(fitem->first_get_id != sd->bl.id && fitem->second_get_id != sd->bl.id) {
- clif_additem(sd,0,0,6);
- return 0;
- }
- }
- else if(fitem->third_get_id > 0) {
- third_sd = map_id2sd(fitem->third_get_id);
- if(tick < fitem->third_get_tick) {
- if(fitem->first_get_id != sd->bl.id) {
- clif_additem(sd,0,0,6);
- return 0;
- }
- }
- }
- }
- }
- if((flag = pc_additem(sd,&fitem->item_data,fitem->item_data.amount)))
- // 重量overで取得失敗
- clif_additem(sd,0,0,flag);
- else {
- /* 取得成功 */
- if(sd->attacktimer != -1)
- pc_stopattack(sd);
- clif_takeitem(&sd->bl,&fitem->bl);
- map_clearflooritem(fitem->bl.id);
- }
- return 0;
+ if (can_pick_item_up_from (sd, fitem->first_get_id)
+ || fitem->first_get_tick <= tick)
+ if (can_pick_item_up_from (sd, fitem->second_get_id)
+ || fitem->second_get_tick <= tick)
+ if (can_pick_item_up_from (sd, fitem->third_get_id)
+ || fitem->third_get_tick <= tick) {
+ /* Can pick up */
+
+ if((flag = pc_additem(sd,&fitem->item_data,fitem->item_data.amount)))
+ // 重量overで取得失敗
+ clif_additem(sd,0,0,flag);
+ else {
+ /* 取得成功 */
+ if(sd->attacktimer != -1)
+ pc_stopattack(sd);
+ clif_takeitem(&sd->bl,&fitem->bl);
+ map_clearflooritem(fitem->bl.id);
+ }
+ return 0;
+ }
+
+ /* Otherwise, we can't pick up */
+ clif_additem(sd,0,0,6);
+ return 0;
}
int pc_isUseitem(struct map_session_data *sd,int n)