--- deliantra/server/server/move.C 2007/05/17 14:14:55 1.18 +++ deliantra/server/server/move.C 2008/12/27 02:31:19 1.28 @@ -1,25 +1,24 @@ /* - * CrossFire, A Multiplayer game + * This file is part of Deliantra, the Roguelike Realtime MMORPG. * - * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team - * Copyright (C) 2002 Mark Wedel & Crossfire Development Team - * Copyright (C) 1992 Frank Tore Johansen + * 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 * - * This program is free software; you can redistribute it and/or modify + * 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 2 of the License, or + * 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 + * 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, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * The author can be reached via e-mail to + * along with this program. If not, see . + * + * The authors can be reached via e-mail to */ #include @@ -178,18 +177,18 @@ if (i == -1) return 0; /* No free spot */ - if (op->head != NULL) - op = op->head; + op = op->head_ (); op->remove (); - for (tmp = op; tmp != NULL; tmp = tmp->more) - tmp->x = x + freearr_x[i] + (tmp->arch == NULL ? 0 : tmp->arch->clone.x), - tmp->y = y + freearr_y[i] + (tmp->arch == NULL ? 0 : tmp->arch->clone.y); - tmp = insert_ob_in_map (op, op->map, originator, 0); - if (tmp) - return 0; - else - return 1; + for (object *tmp = op; tmp; tmp = tmp->more) + { + tmp->x = x + freearr_x[i] + (!tmp->arch ? 0 : tmp->arch->x); + tmp->y = y + freearr_y[i] + (!tmp->arch ? 0 : tmp->arch->y); + } + + op = insert_ob_in_map (op, op->map, originator, 0); + + return !op; } /* @@ -227,9 +226,11 @@ { if (i == 0 && j == 0) continue; + /* Perhaps this should be extended to support tiled maps */ if (OUT_OF_REAL_MAP (teleporter->map, teleporter->x + i, teleporter->y + j)) continue; + other_teleporter = GET_MAP_OB (teleporter->map, teleporter->x + i, teleporter->y + j); while (other_teleporter) @@ -238,13 +239,15 @@ break; other_teleporter = other_teleporter->above; } - if (other_teleporter && !(RANDOM () % ++nrofalt)) + + if (other_teleporter && !rndm (++nrofalt)) altern = other_teleporter; } if (!nrofalt) { - LOG (llevError, "No alternative teleporters around!\n"); + LOG (llevError, "%s: no alternative teleporters around (user %s).\n", + teleporter->debug_desc (), user->debug_desc ()); return 0; } @@ -286,13 +289,14 @@ user->remove (); /* Update location for the object */ - for (tmp = user; tmp != NULL; tmp = tmp->more) + for (tmp = user; tmp; tmp = tmp->more) { - tmp->x = other_teleporter->x + freearr_x[k] + (tmp->arch == NULL ? 0 : tmp->arch->clone.x); - tmp->y = other_teleporter->y + freearr_y[k] + (tmp->arch == NULL ? 0 : tmp->arch->clone.y); + tmp->x = other_teleporter->x + freearr_x[k] + (tmp->arch ? tmp->arch->x : 0); + tmp->y = other_teleporter->y + freearr_y[k] + (tmp->arch ? tmp->arch->y : 0); } + tmp = insert_ob_in_map (user, other_teleporter->map, NULL, 0); - return (tmp == NULL); + return !tmp; } void @@ -375,7 +379,9 @@ x = op->x + freearr_x[dir]; y = op->y + freearr_y[dir]; - if (!QUERY_FLAG (op, FLAG_CAN_ROLL) || (op->weight && random_roll (0, op->weight / 50000 - 1, pusher, PREFER_LOW) > pusher->stats.Str)) + if (!QUERY_FLAG (op, FLAG_CAN_ROLL) + || (op->weight && random_roll (0, op->weight / 50000 - 1, pusher, PREFER_LOW) + > pusher->stats.Str)) return 0; m = op->map;