summaryrefslogtreecommitdiff
path: root/src
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
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')
-rw-r--r--src/map/battle.c2
-rw-r--r--src/map/battle.h2
-rw-r--r--src/map/pc.c92
3 files changed, 57 insertions, 39 deletions
diff --git a/src/map/battle.c b/src/map/battle.c
index 8577a29..1a954f3 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -4830,6 +4830,7 @@ int battle_config_read(const char *cfgName)
battle_config.attr_recover=1;
battle_config.flooritem_lifetime=LIFETIME_FLOORITEM*1000;
battle_config.item_auto_get=0;
+ battle_config.drop_pickup_safety_zone = 20;
battle_config.item_first_get_time=3000;
battle_config.item_second_get_time=1000;
battle_config.item_third_get_time=1000;
@@ -5059,6 +5060,7 @@ int battle_config_read(const char *cfgName)
{ "attribute_recover", &battle_config.attr_recover },
{ "flooritem_lifetime", &battle_config.flooritem_lifetime },
{ "item_auto_get", &battle_config.item_auto_get },
+ { "drop_pickup_safety_zone", &battle_config.drop_pickup_safety_zone },
{ "item_first_get_time", &battle_config.item_first_get_time },
{ "item_second_get_time", &battle_config.item_second_get_time },
{ "item_third_get_time", &battle_config.item_third_get_time },
diff --git a/src/map/battle.h b/src/map/battle.h
index 27e1e6f..02283c9 100644
--- a/src/map/battle.h
+++ b/src/map/battle.h
@@ -336,6 +336,8 @@ extern struct Battle_Config {
int spam_threshold;
int chat_maxline;
+ int drop_pickup_safety_zone; // [Fate] Max. distance to an object dropped by a kill by self in which dropsteal protection works
+
#ifndef TXT_ONLY /* SQL-only options */
int mail_system; // [Valaris]
#endif
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)