--- deliantra/server/server/spell_attack.C 2009/03/02 11:45:19 1.83
+++ deliantra/server/server/spell_attack.C 2009/11/07 18:30:06 1.91
@@ -1,22 +1,23 @@
/*
* This file is part of Deliantra, the Roguelike Realtime MMORPG.
*
- * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
+ * Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
* Copyright (©) 2002-2003,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
*/
@@ -38,7 +39,7 @@
* but moved here so it could be applied to bolts too
* op is the spell object.
*/
-void
+static void
check_spell_knockback (object *op)
{
int weight_move;
@@ -109,7 +110,7 @@
/* Causes op to fork. op is the original bolt, tmp
* is the first piece of the fork.
*/
-void
+static void
forklightning (object *op, object *tmp)
{
int new_dir = 1; /* direction or -1 for left, +1 for right 0 if no new bolt */
@@ -390,7 +391,7 @@
* poison cloud ball, etc. op is the object to
* explode.
*/
-void
+static void
explode_bullet (object *op)
{
object *tmp, *owner;
@@ -547,10 +548,6 @@
void
move_bullet (object *op)
{
- sint16 new_x, new_y;
- int mflags;
- maptile *m;
-
#if 0
/* We need a better general purpose way to do this */
@@ -575,18 +572,20 @@
return;
}
- new_x = op->x + DIRX (op);
- new_y = op->y + DIRY (op);
- m = op->map;
- mflags = get_map_flags (m, &m, new_x, new_y, &new_x, &new_y);
+ mapxy pos (op);
+ pos.move (op->direction);
- if (mflags & P_OUT_OF_MAP)
+ if (!pos.normalise ())
{
op->destroy ();
return;
}
- if (!op->direction || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y)))
+ mapspace &ms = pos.ms ();
+
+ ms.update ();
+
+ if (!op->direction || OB_TYPE_MOVE_BLOCK (op, ms.move_block))
{
if (op->other_arch)
explode_bullet (op);
@@ -596,7 +595,7 @@
return;
}
- if (!(op = m->insert (op, new_x, new_y, op)))
+ if (!(op = pos.insert (op, op)))
return;
if (reflwall (op->map, op->x, op->y, op))
@@ -690,7 +689,7 @@
*****************************************************************************/
/* drops an object based on what is in the cone's "other_arch" */
-void
+static void
cone_drop (object *op)
{
object *new_ob = arch_to_object (op->other_arch);
@@ -949,7 +948,7 @@
if (op->env)
{
- if (env->map == NULL)
+ if (!env->map)
return;
if (!(op = op->insert_at (env, op)))
@@ -959,7 +958,7 @@
// elmex Tue Aug 15 17:46:51 CEST 2006: Prevent bomb from exploding
// on a safe map. I don't like this special casing, but it seems to be neccessary
// as bombs can be carried.
- if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE)
+ if (op->ms ().flags () & P_SAFE)
{
op->destroy ();
return;
@@ -1050,7 +1049,7 @@
* type is the type of spell - either SPELL_MANA or SPELL_GRACE.
* this info is used for blocked magic/unholy spaces.
*/
-object *
+static object *
get_pointed_target (object *op, int dir, int range, int type)
{
object *target;
@@ -1247,7 +1246,7 @@
* make this work for non-living objects, we would have to
* give them the capability to have an inventory. b.t.
*/
-int
+static int
make_object_glow (object *op, int radius, int time)
{
/* some things are unaffected... */
@@ -1528,7 +1527,7 @@
if (head->level > level)
continue;
- if (random_roll (0, 100, caster, PREFER_LOW) >= (20 + MIN (50, 2 * (level - head->level))))
+ if (random_roll (0, 100, caster, PREFER_LOW) >= (20 + min (50, 2 * (level - head->level))))
/* Failed, no effect */
continue;
}
@@ -1910,12 +1909,13 @@
if (tmp->glow_radius)
tmp->set_glow_radius (
- min (MAX_LIGHT_RADIUS, spell->range + SP_level_range_adjust (caster, spell)));
+ clamp (spell->range + SP_level_range_adjust (caster, spell), 1, MAX_LIGHT_RADIUS)
+ );
if (dir)
m->insert (tmp, x, y, op);
else
- caster->outer_env ()->insert (tmp);
+ caster->outer_env_or_self ()->insert (tmp);
return 1;
}
@@ -2034,7 +2034,7 @@
new_draw_info_format (NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name);
disease->destroy (); /* don't need this one anymore */
- walk->map->insert (get_archetype ("detect_magic"), x, y, op);
+ walk->map->insert (get_archetype (shstr_detect_magic), x, y, op);
return 1;
}