--- deliantra/server/common/object.C 2007/06/05 13:05:02 1.160
+++ deliantra/server/common/object.C 2007/07/21 18:01:25 1.167
@@ -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
*/
@@ -302,14 +301,14 @@
return 0;
}
- //TODO: generate an event or call into perl for additional checks
if (ob1->self || ob2->self)
{
ob1->optimise ();
ob2->optimise ();
if (ob1->self || ob2->self)
- return 0;
+ if (!cfperl_can_merge (ob1, ob2))
+ return 0;
}
/* Everything passes, must be OK. */
@@ -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;
}
@@ -1382,7 +1377,6 @@
top = last->below;
}
} /* If objects on this space */
-
if (flag & INS_MAP_LOAD)
top = ms.top;
@@ -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);
+}
+