--- deliantra/server/common/treasure.C 2008/04/21 23:35:24 1.74
+++ deliantra/server/common/treasure.C 2009/11/06 12:27:05 1.88
@@ -5,18 +5,19 @@
* Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
* Copyright (©) 1992,2007 Frank Tore Johansen
*
- * Deliantra is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * Deliantra is free software: you can redistribute it and/or modify it under
+ * the terms of the Affero GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the Affero GNU General Public License
+ * and the GNU General Public License along with this program. If not, see
+ * .
*
* The authors can be reached via e-mail to
*/
@@ -47,12 +48,26 @@
treasurelist *,
str_hash,
str_equal,
- slice_allocator< std::pair >,
- true
+ slice_allocator< std::pair >
> tl_map_t;
static tl_map_t tl_map;
+//TODO: class method
+static void
+clear (treasurelist *tl)
+{
+ void free_treasurestruct (treasure *t);
+
+ if (tl->items)
+ {
+ free_treasurestruct (tl->items);
+ tl->items = 0;
+ }
+
+ tl->total_chance = 0;
+}
+
/*
* Searches for the given treasurelist
*/
@@ -93,19 +108,6 @@
return tl;
}
-//TODO: class method
-void
-clear (treasurelist *tl)
-{
- if (tl->items)
- {
- free_treasurestruct (tl->items);
- tl->items = 0;
- }
-
- tl->total_chance = 0;
-}
-
#ifdef TREASURE_DEBUG
/* recursived checks the linked list. Treasurelist is passed only
* so that the treasure name can be printed out
@@ -257,7 +259,7 @@
op->expand_tail ();
- if (op->blocked (creator->map, creator->x, creator->y))
+ if (!creator->is_on_map () || op->blocked (creator->map, creator->x, creator->y))
op->destroy ();
else
{
@@ -271,10 +273,6 @@
if ((flags & GT_APPLY) && QUERY_FLAG (creator, FLAG_MONSTER))
monster_check_apply (creator, op);
-
- if (flags & GT_UPDATE_INV)
- if (object *tmp = creator->in_player ())
- esrv_send_item (tmp, op);
}
}
@@ -448,6 +446,7 @@
LOG (llevError, "In generate treasure, created multiple objects.\n");
ob->destroy ();
+
return tmp;
}
@@ -584,14 +583,17 @@
if (magic < 0 && !(rndm (3))) /* You can't just check the weight always */
magic = (-magic);
+
op->weight = (op->arch->weight * (100 - magic * 10)) / 100;
}
else
{
if (op->type == ARMOUR)
ARMOUR_SPEED (op) = (ARMOUR_SPEED (op) * (100 + magic * 10)) / 100;
+
if (magic < 0 && !(rndm (3))) /* You can't just check the weight always */
magic = (-magic);
+
op->weight = (op->weight * (100 - magic * 10)) / 100;
}
}
@@ -775,6 +777,23 @@
return 4;
}
+/* special_potion() - so that old potion code is still done right. */
+int
+special_potion (object *op)
+{
+ if (op->attacktype)
+ return 1;
+
+ if (op->stats.Str || op->stats.Dex || op->stats.Con || op->stats.Pow || op->stats.Wis || op->stats.Int || op->stats.Cha)
+ return 1;
+
+ for (int i = 0; i < NROFATTACKS; i++)
+ if (op->resist[i])
+ return 1;
+
+ return 0;
+}
+
#define DICE2 (get_magic(2)==2?2:1)
#define DICESPELL (rndm (3) + rndm (3) + rndm (3) + rndm (3) + rndm (3))
@@ -969,13 +988,6 @@
op->value *= 5; /* Since it's not just decoration */
case RING:
- if (!op->arch) // wtf? schmorp
- {
- op->destroy ();
- op = 0;
- break;
- }
-
if (!IS_ARCH (op->arch, ring) && !IS_ARCH (op->arch, amulet)) /* It's a special artifact! */
break;
@@ -1006,8 +1018,8 @@
}
}
- if (GET_ANIM_ID (op))
- SET_ANIMATION (op, rndm (NUM_ANIMATIONS (op)));
+ if (op->animation_id)
+ op->set_anim_frame (rndm (op->anim_frames ()));
break;
@@ -1032,19 +1044,20 @@
tailor_readable_ob (op, (creator && creator->stats.sp) ? creator->stats.sp : -1);
/* books w/ info are worth more! */
op->value *= ((op->level > 10 ? op->level : (op->level + 1) / 2) * ((strlen (op->msg) / 250) + 1));
- /* creator related stuff */
-
- /* for library, chained books. Note that some monsters have no_pick
- * set - we don't want to set no pick in that case.
- */
- if (QUERY_FLAG (creator, FLAG_NO_PICK) && !QUERY_FLAG (creator, FLAG_MONSTER))
- SET_FLAG (op, FLAG_NO_PICK);
- if (creator->slaying && !op->slaying) /* for check_inv floors */
- op->slaying = creator->slaying;
/* add exp so reading it gives xp (once) */
op->stats.exp = op->value > 10000 ? op->value / 5 : op->value / 10;
}
+
+ /* creator related stuff */
+
+ /* for library, chained books. Note that some monsters have no_pick
+ * set - we don't want to set no pick in that case.
+ */
+ if (QUERY_FLAG (creator, FLAG_NO_PICK) && !QUERY_FLAG (creator, FLAG_MONSTER))
+ SET_FLAG (op, FLAG_NO_PICK);
+ if (creator->slaying && !op->slaying) /* for check_inv floors */
+ op->slaying = creator->slaying;
break;
case SPELLBOOK:
@@ -1357,14 +1370,11 @@
*/
if (op->type == HORN || op->type == POTION)
{
- object *tmp_obj;
-
/* Remove any spells this object currently has in it */
- while (op->inv)
- op->inv->destroy ();
+ op->destroy_inv (false);
- tmp_obj = arch_to_object (change->other_arch);
- insert_ob_in_ob (tmp_obj, op);
+ object *tmp = arch_to_object (change->other_arch);
+ insert_ob_in_ob (tmp, op);
}
/* No harm setting this for potions/horns */
op->other_arch = change->other_arch;
@@ -1579,9 +1589,11 @@
#endif
return;
}
- if (!strcmp (art->item->name, "NONE"))
+
+ if (art->item->name == shstr_NONE)
return;
- if (FABS (op->magic) < art->item->magic)
+
+ if (fabs (op->magic) < art->item->magic)
continue; /* Not magic enough to be this item */
/* Map difficulty not high enough */
@@ -1642,29 +1654,14 @@
/* if donor has some attacktypes, the flesh is poisonous */
if (donor->attacktype & AT_POISON)
item->type = POISON;
+
if (donor->attacktype & AT_ACID)
item->stats.hp = -1 * item->stats.food;
+
SET_FLAG (item, FLAG_NO_STEAL);
}
}
-/* special_potion() - so that old potion code is still done right. */
-int
-special_potion (object *op)
-{
- if (op->attacktype)
- return 1;
-
- if (op->stats.Str || op->stats.Dex || op->stats.Con || op->stats.Pow || op->stats.Wis || op->stats.Int || op->stats.Cha)
- return 1;
-
- for (int i = 0; i < NROFATTACKS; i++)
- if (op->resist[i])
- return 1;
-
- return 0;
-}
-
void
free_treasurestruct (treasure *t)
{
@@ -1690,7 +1687,7 @@
if (at->next) free_artifact (at->next);
if (at->allowed) free_charlinks (at->allowed);
- at->item->destroy (1);
+ at->item->destroy ();
sfree (at);
}