--- deliantra/server/server/move.C 2009/09/02 22:52:36 1.31
+++ deliantra/server/server/move.C 2012/10/29 23:55:55 1.46
@@ -1,23 +1,24 @@
/*
* This file is part of Deliantra, the Roguelike Realtime MMORPG.
- *
- * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
- * 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.
- *
+ *
+ * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
+ * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
+ * Copyright (©) 1992 Frank Tore Johansen
+ *
+ * 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
*/
@@ -26,34 +27,6 @@
# include
#endif
-/*
- * move_object() tries to move object op in the direction "dir".
- * If it fails (something blocks the passage), it returns 0,
- * otherwise 1.
- * This is an improvement from the previous move_ob(), which
- * removed and inserted objects even if they were unable to move.
- */
-int
-move_object (object *op, int dir)
-{
- return op->move (dir);
-}
-
-/* object op is trying to move in direction dir.
- * originator is typically the same as op, but
- * can be different if originator is causing op to
- * move (originator is pushing op)
- * returns 0 if the object is not able to move to the
- * desired space, 1 otherwise (in which case we also
- * move the object accordingly. This function is
- * very similiar to move_object.
- */
-int
-move_ob (object *op, int dir, object *originator)
-{
- return op->move (dir, originator);
-}
-
int
object::move (int dir, object *originator)
{
@@ -104,6 +77,8 @@
remove ();
+ pos.m->activate ();
+
if (INVOKE_PLAYER (MAP_CHANGE, contr, ARG_MAP (pos.m), ARG_INT (pos.x), ARG_INT (pos.y)))
return 0;
@@ -133,7 +108,6 @@
transfer_ob (object *op, int x, int y, int randomly, object *originator)
{
int i;
- object *tmp;
if (randomly)
i = find_free_spot (op, op->map, x, y, 0, SIZEOFFREE);
@@ -184,7 +158,7 @@
* should really be setable by some object attribute instead of
* using hard coded values.
*/
- unordered_mapwalk (teleporter, -5, -5, 5, 5)
+ unordered_mapwalk (mapwalk_buf, teleporter, -5, -5, 5, 5)
{
mapspace &ms = m->at (nx, ny);
@@ -205,7 +179,7 @@
return 0;
}
- int k = find_free_spot (user, other_teleporter->map, other_teleporter->x, other_teleporter->y, 1, 9);
+ int k = find_free_spot (user, other_teleporter->map, other_teleporter->x, other_teleporter->y, 1, SIZEOFFREE1 + 1);
/* if k==-1, unable to find a free spot. If this is shop
* mat that the player is using, find someplace to move
@@ -247,20 +221,6 @@
);
}
-void
-recursive_roll (object *op, int dir, object *pusher)
-{
- if (!roll_ob (op, dir, pusher))
- {
- new_draw_info_format (NDI_UNIQUE, 0, pusher, "You fail to push the %s.", query_name (op));
- return;
- }
-
- move_ob (pusher, dir, pusher);
- new_draw_info_format (NDI_BLACK, 0, pusher, "You move the %s.", query_name (op));
- return;
-}
-
/*
* This is a new version of blocked, this one handles objects
* that can be passed through by monsters with the CAN_PASS_THRU defined.
@@ -269,8 +229,7 @@
* This is currently only used for the boulder roll code.
* Returns 1 if object does not fit, 0 if it does.
*/
-
-int
+static int
try_fit (object *op, maptile *m, int x, int y)
{
object *tmp, *more;
@@ -296,7 +255,7 @@
if (tmp->head == op || tmp == op)
continue;
- if ((QUERY_FLAG (tmp, FLAG_ALIVE) && tmp->type != DOOR))
+ if ((tmp->flag [FLAG_ALIVE] && tmp->type != DOOR))
return 1;
if (OB_MOVE_BLOCK (op, tmp))
@@ -312,7 +271,7 @@
* it does not roll objects behind multipart objects properly.
* Support for rolling multipart objects is questionable.
*/
-int
+static int
roll_ob (object *op, int dir, object *pusher)
{
sint16 x, y;
@@ -326,7 +285,7 @@
x = op->x + freearr_x[dir];
y = op->y + freearr_y[dir];
- if (!QUERY_FLAG (op, FLAG_CAN_ROLL)
+ if (!op->flag [FLAG_CAN_ROLL]
|| (op->weight && random_roll (0, op->weight / 50000 - 1, pusher, PREFER_LOW)
> pusher->stats.Str))
return 0;
@@ -360,6 +319,20 @@
return 1;
}
+void
+recursive_roll (object *op, int dir, object *pusher)
+{
+ if (!roll_ob (op, dir, pusher))
+ {
+ new_draw_info_format (NDI_UNIQUE, 0, pusher, "You fail to push the %s.", query_name (op));
+ return;
+ }
+
+ pusher->move (dir);
+ new_draw_info_format (NDI_BLACK, 0, pusher, "You move the %s.", query_name (op));
+ return;
+}
+
/* returns 1 if pushing invokes a attack, 0 when not */
int
push_ob (object *who, int dir, object *pusher)
@@ -372,7 +345,7 @@
owner = who->owner;
/* Wake up sleeping monsters that may be pushed */
- CLEAR_FLAG (who, FLAG_SLEEP);
+ who->clr_flag (FLAG_SLEEP);
/* player change place with his pets or summoned creature */
/* TODO: allow multi arch pushing. Can't be very difficult */
@@ -409,23 +382,23 @@
/* we so often become an enemy of friendly monsters... */
/* funny: was they set to unaggressive 0 (= not so nice) they don't attack */
if (owner != pusher && pusher->type == PLAYER && who->type != PLAYER &&
- !QUERY_FLAG (who, FLAG_FRIENDLY) && !QUERY_FLAG (who, FLAG_NEUTRAL))
+ !who->flag [FLAG_FRIENDLY] && !who->flag [FLAG_NEUTRAL])
{
if (pusher->contr->run_on) /* only when we run */
{
new_draw_info_format (NDI_UNIQUE, 0, pusher, "You start to attack %s!!", &who->name);
- CLEAR_FLAG (who, FLAG_UNAGGRESSIVE); /* the sucker don't like you anymore */
+ who->clr_flag (FLAG_UNAGGRESSIVE); /* the sucker don't like you anymore */
who->enemy = pusher;
return 1;
}
else
- new_draw_info_format (NDI_UNIQUE, 0, pusher, "You avoid attacking %s.", &who->name);
+ new_draw_info_format (NDI_UNIQUE, 0, pusher, "You avoid attacking %s. H", &who->name);
}
- /* now, lets test stand still. we NEVER can push stand_still monsters. */
- if (QUERY_FLAG (who, FLAG_STAND_STILL))
+ /* now, let's test stand still. we NEVER can push stand_still monsters. */
+ if (who->flag [FLAG_STAND_STILL])
{
- new_draw_info_format (NDI_UNIQUE, 0, pusher, "You can't push %s.", &who->name);
+ new_draw_info_format (NDI_UNIQUE, 0, pusher, "You can't push %s. H", &who->name);
return 0;
}
@@ -438,9 +411,9 @@
str1 = (who->stats.Str > 0 ? who->stats.Str : who->level);
str2 = (pusher->stats.Str > 0 ? pusher->stats.Str : pusher->level);
- if (QUERY_FLAG (who, FLAG_WIZ) ||
+ if (who->flag [FLAG_WIZ] ||
random_roll (str1, str1 * 5 / 2, who, PREFER_HIGH) >=
- random_roll (str2, str2 * 5 / 2, pusher, PREFER_HIGH) || !move_object (who, dir))
+ random_roll (str2, str2 * 5 / 2, pusher, PREFER_HIGH) || !who->move (dir))
{
if (who->type == PLAYER)
new_draw_info_format (NDI_UNIQUE, 0, who, "%s tried to push you.", &pusher->name);
@@ -452,13 +425,10 @@
* Let everyone know the status.
*/
if (who->type == PLAYER)
- {
- new_draw_info_format (NDI_UNIQUE, 0, who, "%s pushed you.", &pusher->name);
- }
+ new_draw_info_format (NDI_UNIQUE, 0, who, "%s pushed you.", &pusher->name);
+
if (pusher->type == PLAYER)
- {
- new_draw_info_format (NDI_UNIQUE, 0, pusher, "You pushed %s back.", &who->name);
- }
+ new_draw_info_format (NDI_UNIQUE, 0, pusher, "You pushed %s back.", &who->name);
return 1;
}