--- deliantra/server/common/treasure.C 2007/06/04 12:19:08 1.62
+++ deliantra/server/common/treasure.C 2008/04/02 11:13:52 1.70
@@ -1,25 +1,24 @@
/*
- * This file is part of Crossfire TRT, the Multiplayer Online Role Playing Game.
+ * This file is part of Deliantra, the Roguelike Realtime MMORPG.
*
- * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team
+ * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
* Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
* Copyright (©) 1992,2007 Frank Tore Johansen
*
- * Crossfire TRT 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 2 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 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.
+ * 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 Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*
- * The authors can be reached via e-mail to
+ * The authors can be reached via e-mail to
*/
/* TREASURE_DEBUG does some checking on the treasurelists after loading.
@@ -142,7 +141,7 @@
for (;;)
{
- coroapi::cede_to_tick_every (10);
+ coroapi::cede_to_tick ();
switch (f.kw)
{
@@ -246,7 +245,7 @@
op->expand_tail ();
- if (ob_blocked (op, creator->map, creator->x, creator->y))
+ if (op->blocked (creator->map, creator->x, creator->y))
op->destroy ();
else
{
@@ -302,7 +301,7 @@
}
else
{
- if (t->item && (t->item->clone.invisible != 0 || !(flag & GT_INVISIBLE)))
+ if (t->item && (t->item->invisible != 0 || !(flag & GT_INVISIBLE)))
{
object *tmp = arch_to_object (t->item);
@@ -359,7 +358,7 @@
else if (t->nrof)
create_one_treasure (tl, op, flag, difficulty, tries);
}
- else if (t->item && (t->item->clone.invisible != 0 || flag != GT_INVISIBLE))
+ else if (t->item && (t->item->invisible != 0 || flag != GT_INVISIBLE))
{
if (object *tmp = arch_to_object (t->item))
{
@@ -492,23 +491,18 @@
int
level_for_item (const object *op, int difficulty)
{
- int olevel = 0;
-
if (!op->inv)
{
LOG (llevError, "level_for_item: Object %s has no inventory!\n", &op->name);
return 0;
}
- olevel = (int) (op->inv->level + (double) difficulty * (1 - drand48 () * drand48 () * 2));
+ int olevel = op->inv->level + int (difficulty * (1. - rndm () * rndm () * 2.));
if (olevel <= 0)
- olevel = rndm (1, MIN (op->inv->level, 1));
-
- if (olevel > MAXLEVEL)
- olevel = MAXLEVEL;
+ olevel = rndm (1, op->inv->level);
- return olevel;
+ return min (olevel, MAXLEVEL);
}
/*
@@ -574,11 +568,11 @@
if (op->arch)
{
if (op->type == ARMOUR)
- ARMOUR_SPEED (op) = (ARMOUR_SPEED (&op->arch->clone) * (100 + magic * 10)) / 100;
+ ARMOUR_SPEED (op) = (ARMOUR_SPEED (op->arch) * (100 + magic * 10)) / 100;
if (magic < 0 && !(rndm (3))) /* You can't just check the weight always */
magic = (-magic);
- op->weight = (op->arch->clone.weight * (100 - magic * 10)) / 100;
+ op->weight = (op->arch->weight * (100 - magic * 10)) / 100;
}
else
{
@@ -1136,7 +1130,7 @@
static artifactlist *
get_empty_artifactlist (void)
{
- return salloc0 ();
+ return salloc0 ();
}
/*
@@ -1145,7 +1139,7 @@
static artifact *
get_empty_artifact (void)
{
- return salloc0 ();
+ return salloc0 ();
}
/*
@@ -1226,10 +1220,10 @@
for (i = 0; i < depth; i++)
fprintf (logfile, " ");
- if (t->item && t->item->clone.type == FLESH)
- fprintf (logfile, "%s's %s\n", name, &t->item->clone.name);
+ if (t->item && t->item->type == FLESH)
+ fprintf (logfile, "%s's %s\n", name, &t->item->object::name);
else
- fprintf (logfile, "%s\n", &t->item->clone.name);
+ fprintf (logfile, "%s\n", &t->item->object::name);
}
if (t->next_yes)
@@ -1267,12 +1261,12 @@
found = 0;
fprintf (logfile, "\n");
- for (at = first_archetype; at != NULL; at = at->next)
- if (!strcasecmp (at->clone.name, name) && at->clone.title == NULL)
+ for_all_archetypes (at)
+ if (!strcasecmp (at->object::name, name) && at->title == NULL)
{
- fprintf (logfile, "treasures for %s (arch: %s)\n", &at->clone.name, &at->archname);
- if (at->clone.randomitems != NULL)
- dump_monster_treasure_rec (at->clone.name, at->clone.randomitems->items, 1);
+ fprintf (logfile, "treasures for %s (arch: %s)\n", &at->object::name, &at->archname);
+ if (at->randomitems != NULL)
+ dump_monster_treasure_rec (at->object::name, at->randomitems->items, 1);
else
fprintf (logfile, "(nothing)\n");
@@ -1306,8 +1300,6 @@
if (!f)
return;
- f.next ();
-
for (;;)
{
switch (f.kw)