--- deliantra/server/common/treasure.C 2008/09/29 10:31:32 1.81
+++ deliantra/server/common/treasure.C 2009/11/06 13:45:28 1.91
@@ -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
*/
@@ -52,6 +53,20 @@
static tl_map_t tl_map;
+//TODO: class method
+static void free_treasurestruct (treasure *t); // bleh desu
+static void
+clear (treasurelist *tl)
+{
+ if (tl->items)
+ {
+ free_treasurestruct (tl->items);
+ tl->items = 0;
+ }
+
+ tl->total_chance = 0;
+}
+
/*
* Searches for the given treasurelist
*/
@@ -92,19 +107,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
@@ -250,14 +252,14 @@
//TODO: flag such as objects... as such (no drop, anybody?)
if (op->type == SPELL)
{
- op->destroy (true);
+ op->destroy ();
return;
}
op->expand_tail ();
if (!creator->is_on_map () || op->blocked (creator->map, creator->x, creator->y))
- op->destroy (true);
+ op->destroy ();
else
{
SET_FLAG (op, FLAG_OBJ_ORIGINAL);
@@ -442,7 +444,7 @@
if (ob->inv)
LOG (llevError, "In generate treasure, created multiple objects.\n");
- ob->destroy (true);
+ ob->destroy ();
return tmp;
}
@@ -496,7 +498,7 @@
* elmex Wed Aug 9 17:44:59 CEST 2006:
* Removed multiplicator, too many high-level items were generated on low-difficulty maps.
*/
-int
+static int
level_for_item (const object *op, int difficulty)
{
if (!op->inv)
@@ -523,7 +525,7 @@
* weird integer between 1-31.
*
*/
-int
+static int
magic_from_difficulty (int difficulty)
{
int percent = 0, magic = 0;
@@ -623,10 +625,9 @@
* other bonuses previously rolled and ones the item might natively have.
* 2) Add code to deal with new PR method.
*/
-void
+static void
set_ring_bonus (object *op, int bonus)
{
-
int r = rndm (bonus > 0 ? 25 : 11);
if (op->type == AMULET)
@@ -759,7 +760,7 @@
* rings and amulets.
* Another scheme is used to calculate the magic of weapons and armours.
*/
-int
+static int
get_magic (int diff)
{
int i;
@@ -774,6 +775,23 @@
return 4;
}
+/* special_potion() - so that old potion code is still done right. */
+static 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))
@@ -998,8 +1016,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;
@@ -1024,19 +1042,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:
@@ -1568,9 +1587,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 */
@@ -1631,30 +1652,15 @@
/* 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
+static void
free_treasurestruct (treasure *t)
{
if (t->next) free_treasurestruct (t->next);
@@ -1664,7 +1670,7 @@
delete t;
}
-void
+static void
free_charlinks (linked_char *lc)
{
if (lc->next)
@@ -1673,45 +1679,14 @@
delete lc;
}
-void
+static void
free_artifact (artifact *at)
{
if (at->next) free_artifact (at->next);
if (at->allowed) free_charlinks (at->allowed);
- at->item->destroy (true);
+ at->item->destroy ();
sfree (at);
}
-void
-free_artifactlist (artifactlist *al)
-{
- artifactlist *nextal;
-
- for (al = first_artifactlist; al; al = nextal)
- {
- nextal = al->next;
-
- if (al->items)
- free_artifact (al->items);
-
- sfree (al);
- }
-}
-
-void
-free_all_treasures (void)
-{
- treasurelist *tl, *next;
-
- for (tl = first_treasurelist; tl; tl = next)
- {
- clear (tl);
-
- next = tl->next;
- delete tl;
- }
-
- free_artifactlist (first_artifactlist);
-}