--- deliantra/server/server/move.C 2007/01/15 21:06:20 1.15 +++ deliantra/server/server/move.C 2008/12/27 02:31:19 1.28 @@ -1,25 +1,24 @@ /* - * CrossFire, A Multiplayer game for X-windows + * 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 @@ -27,11 +26,6 @@ # include #endif -#ifdef COZY_SERVER -// use a ptotoype -extern int same_party (partylist *a, partylist *b); -#endif - /* * move_object() tries to move object op in the direction "dir". * If it fails (something blocks the passage), it returns 0, @@ -46,7 +40,6 @@ return move_ob (op, dir, op); } - /* 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 @@ -184,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; } /* @@ -233,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) @@ -244,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; } @@ -292,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 @@ -381,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; @@ -430,11 +430,8 @@ /* player change place with his pets or summoned creature */ /* TODO: allow multi arch pushing. Can't be very difficult */ if (who->more == NULL -#ifdef COZY_SERVER - && ((owner && owner->contr && pusher->contr && same_party (owner->contr->party, pusher->contr->party)) || owner == pusher) -#else - && owner == pusher -#endif + && ((owner && owner->contr && pusher->contr && same_party (owner->contr->party, pusher->contr->party)) + || owner == pusher) ) { int temp; @@ -459,26 +456,22 @@ return 0; } - /* We want ONLY become enemy of evil, unaggressive monster. We must RUN in them */ /* In original we have here a unaggressive check only - that was the reason why */ /* 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)) { if (pusher->contr->run_on) /* only when we run */ { - new_draw_info_format (NDI_UNIQUE, 0, pusher, "You start to attack %s !!", &who->name); + 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->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.", &who->name); } /* now, lets test stand still. we NEVER can push stand_still monsters. */ @@ -498,13 +491,12 @@ 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) || - random_roll (str1, str1 / 2 + str1 * 2, who, PREFER_HIGH) >= - random_roll (str2, str2 / 2 + str2 * 2, pusher, PREFER_HIGH) || !move_object (who, dir)) + random_roll (str1, str1 * 5 / 2, who, PREFER_HIGH) >= + random_roll (str2, str2 * 5 / 2, pusher, PREFER_HIGH) || !move_object (who, dir)) { if (who->type == PLAYER) - { - new_draw_info_format (NDI_UNIQUE, 0, who, "%s tried to push you.", &pusher->name); - } + new_draw_info_format (NDI_UNIQUE, 0, who, "%s tried to push you.", &pusher->name); + return 0; }