--- deliantra/server/server/move.C 2009/11/15 19:13:01 1.34 +++ deliantra/server/server/move.C 2012/10/29 23:55:55 1.46 @@ -1,24 +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 - * + * + * 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 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 */ @@ -27,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) { @@ -105,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; @@ -134,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); @@ -185,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); @@ -206,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 @@ -282,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 +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; @@ -355,7 +328,7 @@ return; } - move_ob (pusher, dir, pusher); + pusher->move (dir); new_draw_info_format (NDI_BLACK, 0, pusher, "You move the %s.", query_name (op)); return; } @@ -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,12 +382,12 @@ /* 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; } @@ -423,7 +396,7 @@ } /* now, let's test stand still. we NEVER can push stand_still monsters. */ - if (QUERY_FLAG (who, FLAG_STAND_STILL)) + if (who->flag [FLAG_STAND_STILL]) { 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; }