--- deliantra/server/common/button.C 2007/04/30 04:25:29 1.31 +++ deliantra/server/common/button.C 2007/07/31 18:28:46 1.38 @@ -1,25 +1,24 @@ /* - * CrossFire, A Multiplayer game + * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. * - * 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 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT 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 + * Crossfire TRT 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 authors can be reached via e-mail at + * along with this program. If not, see . + * + * The authors can be reached via e-mail to */ #include @@ -62,6 +61,7 @@ /* if the criteria isn't appropriate, don't do anything */ if (state && !QUERY_FLAG (tmp, FLAG_ACTIVATE_ON_PUSH)) continue; + if (!state && !QUERY_FLAG (tmp, FLAG_ACTIVATE_ON_RELEASE)) continue; @@ -81,6 +81,7 @@ case SIGN: if (!tmp->stats.food || tmp->last_eat < tmp->stats.food) { + tmp->play_sound (tmp->sound); new_info_map (NDI_UNIQUE | NDI_NAVY, tmp->map, tmp->msg); if (tmp->stats.food) tmp->last_eat++; @@ -105,19 +106,19 @@ break; case TIMED_GATE: - tmp->set_speed (tmp->arch->clone.speed); - tmp->value = tmp->arch->clone.value; + tmp->set_speed (tmp->arch->speed); + tmp->value = tmp->arch->value; tmp->stats.sp = 1; tmp->stats.hp = tmp->stats.maxhp; /* Handle multipart gates. We copy the value for the other parts * from the head - this ensures that the data will consistent */ - for (tmp = tmp->more; tmp; tmp = tmp->more) + for (object *part = tmp->more; part; part = part->more) { - tmp->value = tmp->head->value; - tmp->stats.sp = tmp->head->stats.sp; - tmp->stats.hp = tmp->head->stats.hp; - tmp->set_speed (tmp->head->speed); + part->value = tmp->value; + part->stats.sp = tmp->stats.sp; + part->stats.hp = tmp->stats.hp; + part->set_speed (tmp->speed); } break; @@ -129,6 +130,7 @@ { if ((tmp->stats.sp += tmp->stats.maxsp) > 8) /* next direction */ tmp->stats.sp = ((tmp->stats.sp - 1) % 8) + 1; + animate_turning (tmp); } break; @@ -252,7 +254,7 @@ tmp->value = 0; for (ab = tmp->above; ab != NULL; ab = ab->above) { - head = ab->head ? ab->head : ab; + head = ab->head_ (); /* Same note regarding move_type for buttons above apply here. */ if (((head->move_type & tmp->move_on) || ab->move_type == 0) && (head->race == tmp->slaying || @@ -260,6 +262,7 @@ (!strcmp (tmp->slaying, "player") && head->type == PLAYER))) tmp->value = 1; } + if (tmp->value) any_down = 1; } @@ -314,17 +317,20 @@ int check_altar_sacrifice (const object *altar, const object *sacrifice) { - if (!QUERY_FLAG (sacrifice, FLAG_ALIVE) && !QUERY_FLAG (sacrifice, FLAG_IS_LINKED) && sacrifice->type != PLAYER) + if (!QUERY_FLAG (sacrifice, FLAG_ALIVE) + && !QUERY_FLAG (sacrifice, FLAG_IS_LINKED) + && sacrifice->type != PLAYER) { - if ((ARCH_SACRIFICE (altar) == sacrifice->arch->name || - ARCH_SACRIFICE (altar) == sacrifice->name || - ARCH_SACRIFICE (altar) == sacrifice->slaying || - (!strcmp (ARCH_SACRIFICE (altar), query_base_name (sacrifice, 0)))) - && NROF_SACRIFICE (altar) <= (sacrifice->nrof ? sacrifice->nrof : 1)) + if (strcmp (ARCH_SACRIFICE (altar), "money") == 0 + && sacrifice->type == MONEY + && sacrifice->nrof * sacrifice->value >= NROF_SACRIFICE (altar)) return 1; - if (strcmp (ARCH_SACRIFICE (altar), "money") == 0 - && sacrifice->type == MONEY && sacrifice->nrof * sacrifice->value >= NROF_SACRIFICE (altar)) + if ((ARCH_SACRIFICE (altar) == sacrifice->arch->archname + || ARCH_SACRIFICE (altar) == sacrifice->name + || ARCH_SACRIFICE (altar) == sacrifice->slaying + || strstr (query_base_name (sacrifice, 0), ARCH_SACRIFICE (altar))) + && NROF_SACRIFICE (altar) <= (sacrifice->nrof ? sacrifice->nrof : 1)) return 1; } @@ -456,7 +462,7 @@ { for (tmp = op->above; tmp; tmp = tmp->above) { - object *head = tmp->head ? tmp->head : tmp; + object *head = tmp->head_ (); /* See comment in TRIGGER_BUTTON about move_types */ if (((head->move_type & op->move_on) || head->move_type == 0) @@ -466,18 +472,24 @@ break; } } + if (op->stats.ac == push) return 0; + op->stats.ac = push; + if (NUM_ANIMATIONS (op) > 1) { SET_ANIMATION (op, push); update_object (op, UP_OBJ_FACE); } + update_object (op, UP_OBJ_FACE); + if (in_movement || !push) return 0; } + trigger_move (op, push); return 0; @@ -486,6 +498,7 @@ { if (in_movement) return 0; + if (operate_altar (op, &cause)) { if (NUM_ANIMATIONS (op) > 1) @@ -493,6 +506,7 @@ SET_ANIMATION (op, 1); update_object (op, UP_OBJ_FACE); } + if (op->last_sp >= 0) { trigger_move (op, 1); @@ -509,12 +523,11 @@ op->last_sp = -op->last_sp; op->value = !op->value; } + return cause == NULL; } else - { - return 0; - } + return 0; } else { @@ -813,7 +826,7 @@ /* First check the object itself. */ if ((trig->stats.hp && (op->type == trig->stats.hp)) || (trig->slaying && (op->slaying == trig->slaying)) - || (trig->race && (op->arch->name == trig->race))) + || (trig->race && (op->arch->archname == trig->race))) return op; for (tmp = op->inv; tmp; tmp = tmp->below) @@ -826,7 +839,7 @@ } else if ((trig->stats.hp && (tmp->type == trig->stats.hp)) || (trig->slaying && (tmp->slaying == trig->slaying)) - || (trig->race && (tmp->arch->name == trig->race))) + || (trig->race && (tmp->arch->archname == trig->race))) return tmp; } return NULL;