--- deliantra/server/common/button.C 2006/09/10 16:00:23 1.7 +++ deliantra/server/common/button.C 2006/09/16 22:24:12 1.11 @@ -1,9 +1,3 @@ - -/* - * static char *rcsid_button_c = - * "$Id: button.C,v 1.7 2006/09/10 16:00:23 root Exp $"; - */ - /* CrossFire, A Multiplayer game for X-windows @@ -24,7 +18,7 @@ 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 crossfire-devel@real-time.com + The authors can be reached via e-mail at */ #include @@ -195,7 +189,7 @@ * */ void -activate_connection (mapstruct *map, long connection, bool state) +activate_connection (maptile *map, long connection, bool state) { if (INVOKE_MAP (TRIGGER, map, ARG_INT64 (connection), ARG_INT (state))) return; @@ -289,7 +283,7 @@ */ void -update_buttons (mapstruct *m) +update_buttons (maptile *m) { objectlink *ol; oblinkpt *obp; @@ -366,7 +360,6 @@ return 0; } - /* * operate_altar checks if sacrifice was accepted and removes sacrificed * objects. If sacrifice was succeed return 1 else 0. Might be better to @@ -376,11 +369,9 @@ * If this function returns 1, '*sacrifice' is modified to point to the * remaining sacrifice, or is set to NULL if the sacrifice was used up. */ - int operate_altar (object *altar, object **sacrifice) { - if (!altar->map) { LOG (llevError, "BUG: operate_altar(): altar has no map\n"); @@ -403,6 +394,7 @@ /* Round up any sacrifices. Altars don't make change either */ if (NROF_SACRIFICE (altar) % (*sacrifice)->value) number++; + *sacrifice = decrease_ob_nr (*sacrifice, number); } else @@ -410,6 +402,7 @@ if (altar->msg) new_info_map (NDI_BLACK, altar->map, altar->msg); + return 1; } @@ -604,7 +597,7 @@ } void -add_button_link (object *button, mapstruct *map, int connected) +add_button_link (object *button, maptile *map, int connected) { oblinkpt *obp; objectlink *ol = get_objectlink (); @@ -684,7 +677,7 @@ * Gets the objectlink for this connection from the map. */ oblinkpt * -get_connection_links (mapstruct *map, long connection) +get_connection_links (maptile *map, long connection) { for (oblinkpt * obp = map->buttons; obp; obp = obp->next) if (obp->value == connection) @@ -760,59 +753,58 @@ switch (op->last_sp) { - case 0: /* furious--make all monsters mad */ - if (QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE)) - CLEAR_FLAG (tmp, FLAG_UNAGGRESSIVE); - if (QUERY_FLAG (tmp, FLAG_FRIENDLY)) - { - CLEAR_FLAG (tmp, FLAG_FRIENDLY); - remove_friendly_object (tmp); - tmp->attack_movement = 0; - /* lots of checks here, but want to make sure we don't - * dereference a null value - */ - if (tmp->type == GOLEM && tmp->owner && tmp->owner->type == PLAYER && tmp->owner->contr->ranges[range_golem] == tmp) - { - tmp->owner->contr->ranges[range_golem] = NULL; - tmp->owner->contr->golem_count = 0; - } - tmp->owner = 0; - } - break; - case 1: /* angry -- get neutral monsters mad */ - if (QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE) && !QUERY_FLAG (tmp, FLAG_FRIENDLY)) - CLEAR_FLAG (tmp, FLAG_UNAGGRESSIVE); - break; - case 2: /* calm -- pacify unfriendly monsters */ - if (!QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE)) - SET_FLAG (tmp, FLAG_UNAGGRESSIVE); - break; - case 3: /* make all monsters fall asleep */ - if (!QUERY_FLAG (tmp, FLAG_SLEEP)) - SET_FLAG (tmp, FLAG_SLEEP); - break; - case 4: /* charm all monsters */ - if (op == source) - break; /* only if 'connected' */ - - for (tmp2 = get_map_ob (source->map, source->x, source->y); /* finding an owner */ - tmp2->type != PLAYER; tmp2 = tmp2->above) - if (tmp2->above == NULL) - break; - - if (tmp2->type != PLAYER) + case 0: /* furious--make all monsters mad */ + if (QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE)) + CLEAR_FLAG (tmp, FLAG_UNAGGRESSIVE); + if (QUERY_FLAG (tmp, FLAG_FRIENDLY)) + { + CLEAR_FLAG (tmp, FLAG_FRIENDLY); + remove_friendly_object (tmp); + tmp->attack_movement = 0; + /* lots of checks here, but want to make sure we don't + * dereference a null value + */ + if (tmp->type == GOLEM && tmp->owner && tmp->owner->type == PLAYER && tmp->owner->contr->ranges[range_golem] == tmp) + { + tmp->owner->contr->ranges[range_golem] = NULL; + tmp->owner->contr->golem_count = 0; + } + tmp->owner = 0; + } + break; + case 1: /* angry -- get neutral monsters mad */ + if (QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE) && !QUERY_FLAG (tmp, FLAG_FRIENDLY)) + CLEAR_FLAG (tmp, FLAG_UNAGGRESSIVE); + break; + case 2: /* calm -- pacify unfriendly monsters */ + if (!QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE)) + SET_FLAG (tmp, FLAG_UNAGGRESSIVE); + break; + case 3: /* make all monsters fall asleep */ + if (!QUERY_FLAG (tmp, FLAG_SLEEP)) + SET_FLAG (tmp, FLAG_SLEEP); + break; + case 4: /* charm all monsters */ + if (op == source) + break; /* only if 'connected' */ + + for (tmp2 = get_map_ob (source->map, source->x, source->y); /* finding an owner */ + tmp2->type != PLAYER; tmp2 = tmp2->above) + if (tmp2->above == NULL) break; - set_owner (tmp, tmp2); - SET_FLAG (tmp, FLAG_MONSTER); - tmp->stats.exp = 0; - SET_FLAG (tmp, FLAG_FRIENDLY); - add_friendly_object (tmp); - tmp->attack_movement = PETMOVE; - break; - default: + if (tmp2->type != PLAYER) break; + set_owner (tmp, tmp2); + SET_FLAG (tmp, FLAG_MONSTER); + tmp->stats.exp = 0; + SET_FLAG (tmp, FLAG_FRIENDLY); + add_friendly_object (tmp); + tmp->attack_movement = PETMOVE; + break; + default: + break; } } @@ -881,7 +873,7 @@ * matches what the object has. */ void -verify_button_links (const mapstruct *map) +verify_button_links (const maptile *map) { oblinkpt *obp; objectlink *ol;