--- deliantra/server/common/object.C 2007/06/04 12:19:08 1.158
+++ deliantra/server/common/object.C 2007/07/16 14:49:01 1.166
@@ -1,23 +1,22 @@
/*
- * This file is part of Crossfire TRT, the Multiplayer Online Role Playing Game.
+ * This file is part of Crossfire TRT, the Roguelike Realtime MORPG.
*
* Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team
* Copyright (©) 2001,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.
+ * 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 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
*/
@@ -939,18 +938,19 @@
y = 1;
}
- head = 0;
-
if (more)
{
more->destroy ();
more = 0;
}
- // clear those pointers that likely might have circular references to us
- owner = 0;
- enemy = 0;
- attacked_by = 0;
+ head = 0;
+
+ // clear those pointers that likely might cause circular references
+ owner = 0;
+ enemy = 0;
+ attacked_by = 0;
+ current_weapon = 0;
}
void
@@ -1118,11 +1118,6 @@
LOG (llevError, "BUG: remove_ob(): name %s, destroyed leaving object\n", tmp->debug_desc ());
}
- /* Eneq(@csd.uu.se): Fixed this to skip tmp->above=tmp */
- //TODO: why is this horrible hacka fix? get rid of this code=bug! (schmorp)
- if (tmp->above == tmp)
- tmp->above = 0;
-
last = tmp;
}
@@ -1183,7 +1178,7 @@
object *prev = this;
- for (archetype *at = arch->more; at; at = at->more)
+ for (archetype *at = (archetype *)arch->more; at; at = (archetype *)at->more)
{
object *op = arch_to_object (at);
@@ -1207,8 +1202,8 @@
{
for (object *tmp = op->head_ (); tmp; tmp = tmp->more)
{
- tmp->x = x + tmp->arch->clone.x;
- tmp->y = y + tmp->arch->clone.y;
+ tmp->x = x + tmp->arch->x;
+ tmp->y = y + tmp->arch->y;
}
return insert_ob_in_map (op, m, originator, flag);
@@ -1382,7 +1377,6 @@
top = last->below;
}
} /* If objects on this space */
-
if (flag & INS_MAP_LOAD)
top = ms.top;
@@ -2497,7 +2491,7 @@
* it, we save the empty value so that when we load,
* we get this value back again.
*/
- if (get_ob_key_link (&op->arch->clone, canonical_key))
+ if (get_ob_key_link (op->arch, canonical_key))
field->value = 0;
else
{
@@ -2576,7 +2570,6 @@
item = item->env;
}
-
const char *
object::flag_desc (char *desc, int len) const
{
@@ -2648,13 +2641,10 @@
const materialtype_t *
object::dominant_material () const
{
- if (materialtype_t *mat = name_to_material (materialname))
- return mat;
-
- // omfg this is slow, this has to be temporary :)
- shstr unknown ("unknown");
+ if (materialtype_t *mt = name_to_material (materialname))
+ return mt;
- return name_to_material (unknown);
+ return name_to_material (shstr_unknown);
}
void
@@ -2708,4 +2698,36 @@
}
}
+object *
+object::force_find (const shstr name)
+{
+ /* cycle through his inventory to look for the MARK we want to
+ * place
+ */
+ for (object *tmp = inv; tmp; tmp = tmp->below)
+ if (tmp->type == FORCE && tmp->slaying == name)
+ return splay (tmp);
+
+ return 0;
+}
+
+void
+object::force_add (const shstr name, int duration)
+{
+ if (object *force = force_find (name))
+ force->destroy ();
+
+ object *force = get_archetype (FORCE_NAME);
+
+ force->slaying = name;
+ force->stats.food = 1;
+ force->speed_left = -1.f;
+
+ force->set_speed (duration ? 1.f / duration : 0.f);
+ force->flag [FLAG_IS_USED_UP] = true;
+ force->flag [FLAG_APPLIED] = true;
+
+ insert (force);
+}
+