--- deliantra/server/common/button.C 2009/10/26 03:43:22 1.60
+++ deliantra/server/common/button.C 2017/01/29 02:47:04 1.73
@@ -1,24 +1,24 @@
/*
* This file is part of Deliantra, the Roguelike Realtime MMORPG.
- *
- * Copyright (©) 2005,2006,2007,2008,2009 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,2013,2014,2015,2016 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
*/
@@ -54,16 +54,16 @@
* re-loaded. As such, just exit this function if that is the case.
*/
- if (QUERY_FLAG (ol->ob, FLAG_FREED))
+ if (ol->ob->flag [FLAG_FREED])
return;
object *tmp = ol->ob;
/* if the criteria isn't appropriate, don't do anything */
- if (state && !QUERY_FLAG (tmp, FLAG_ACTIVATE_ON_PUSH))
+ if (state && !tmp->flag [FLAG_ACTIVATE_ON_PUSH])
continue;
- if (!state && !QUERY_FLAG (tmp, FLAG_ACTIVATE_ON_RELEASE))
+ if (!state && !tmp->flag [FLAG_ACTIVATE_ON_RELEASE])
continue;
switch (tmp->type)
@@ -139,7 +139,7 @@
case DIRECTOR:
case FIREWALL:
- if (!QUERY_FLAG (tmp, FLAG_ANIMATE) && tmp->type == FIREWALL)
+ if (!tmp->flag [FLAG_ANIMATE] && tmp->type == FIREWALL)
move_firewall (tmp);
else
{
@@ -238,7 +238,7 @@
if (tmp->type == BUTTON)
{
- sint32 total = 0;
+ weight_t total = 0;
for (object *ab = tmp->above; ab; ab = ab->above)
/* Basically, if the move_type matches that on what the
@@ -348,19 +348,18 @@
* sacrificed. This fixes a bug of trying to put multiple altars/related
* objects on the same space that take the same sacrifice.
*/
-
int
check_altar_sacrifice (object *altar, object *sacrifice, object *originator)
{
- if (sacrifice->flag [FLAG_UNPAID])
+ if (sacrifice->flag [FLAG_UNPAID]
+ || sacrifice->flag [FLAG_IS_LINKED]
+ || sacrifice->is_player ())
return 0;
if (is_match_expr (ARCH_SACRIFICE (altar)))
- return match (ARCH_SACRIFICE (altar), altar, originator);
+ return match (ARCH_SACRIFICE (altar), sacrifice, altar, originator);
- if (!QUERY_FLAG (sacrifice, FLAG_ALIVE)
- && !QUERY_FLAG (sacrifice, FLAG_IS_LINKED)
- && sacrifice->type != PLAYER)
+ if (!sacrifice->flag [FLAG_ALIVE])
{
if (ARCH_SACRIFICE (altar) == shstr_money
&& sacrifice->type == MONEY
@@ -426,7 +425,7 @@
return 1;
}
-void
+static void
trigger_move (object *op, int state, object *originator) /* 1 down and 0 up */
{
op->stats.wc = state;
@@ -462,7 +461,7 @@
{
object *tmp;
int push = 0, tot = 0;
- int in_movement = op->stats.wc || op->speed;
+ int in_movement = op->stats.wc || op->has_active_speed ();
switch (op->type)
{
@@ -564,7 +563,7 @@
else
{
/* for trigger altar with last_sp, the ON/OFF
- * status (-> +/- value) is "simulated":
+ * status (-> +/- value) is "simulated":
*/
op->value = !op->value;
trigger_move (op, 1, cause);
@@ -588,7 +587,7 @@
/* If trigger_altar has "last_sp > 0" set on the map,
* it will push the connected value only once per sacrifice.
* Otherwise (default), the connected value will be
- * pushed twice: First by sacrifice, second by reset! -AV
+ * pushed twice: First by sacrifice, second by reset! -AV
*/
if (!op->last_sp)
trigger_move (op, 0, cause);
@@ -741,9 +740,9 @@
return 0;
}
-/* This routine makes monsters who are
+/* This routine makes monsters who are
* standing on the 'mood floor' change their
- * disposition if it is different.
+ * disposition if it is different.
* If floor is to be triggered must have
* a speed of zero (default is 1 for all
* but the charm floor type).
@@ -763,7 +762,7 @@
object *tmp;
for (tmp = ms.top; tmp; tmp = tmp->below)
- if (QUERY_FLAG (tmp, FLAG_MONSTER))
+ if (tmp->flag [FLAG_MONSTER])
break;
/* doesn't effect players, and if there is a player on this space, won't also
@@ -776,10 +775,10 @@
switch (op->last_sp)
{
case 0: /* furious--make all monsters mad */
- if (QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE))
- CLEAR_FLAG (tmp, FLAG_UNAGGRESSIVE);
+ if (tmp->flag [FLAG_UNAGGRESSIVE])
+ tmp->clr_flag (FLAG_UNAGGRESSIVE);
- if (QUERY_FLAG (tmp, FLAG_FRIENDLY))
+ if (tmp->flag [FLAG_FRIENDLY])
{
tmp->attack_movement = 0;
/* lots of checks here, but want to make sure we don't
@@ -798,16 +797,16 @@
break;
case 1: /* angry -- get neutral monsters mad */
- if (QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE) && !QUERY_FLAG (tmp, FLAG_FRIENDLY))
- CLEAR_FLAG (tmp, FLAG_UNAGGRESSIVE);
+ if (tmp->flag [FLAG_UNAGGRESSIVE] && !tmp->flag [FLAG_FRIENDLY])
+ tmp->clr_flag (FLAG_UNAGGRESSIVE);
break;
case 2: /* calm -- pacify unfriendly monsters */
- SET_FLAG (tmp, FLAG_UNAGGRESSIVE);
+ tmp->set_flag (FLAG_UNAGGRESSIVE);
break;
case 3: /* make all monsters fall asleep */
- SET_FLAG (tmp, FLAG_SLEEP);
+ tmp->set_flag (FLAG_SLEEP);
break;
case 4: /* charm all monsters */
@@ -817,7 +816,7 @@
if (object *pl = source->ms ().player ())
{
tmp->set_owner (pl);
- SET_FLAG (tmp, FLAG_MONSTER);
+ tmp->set_flag (FLAG_MONSTER);
tmp->stats.exp = 0;
@@ -827,7 +826,7 @@
break;
case 6: // kill monsters
- if (!QUERY_FLAG (tmp, FLAG_FRIENDLY))
+ if (!tmp->flag [FLAG_FRIENDLY])
break;
// FALL THROUGH
@@ -877,13 +876,13 @@
return NULL;
}
-/* check_inv(), a function to search the inventory,
+/* check_inv(), a function to search the inventory,
* of a player and then based on a set of conditions,
- * the square will activate connected items.
+ * the square will activate connected items.
* Monsters can't trigger this square (for now)
- * Values are: last_sp = 1/0 obj/no obj triggers
+ * Values are: last_sp = 1/0 obj/no obj triggers
* last_heal = 1/0 remove/dont remove obj if triggered
- * -b.t. (thomas@nomad.astro.psu.edu
+ * -b.t. (thomas@nomad.astro.psu.edu
*
* Tue Dec 19 15:34:00 CET 2006 elmex: changed the function to ignore op
* because the check-inventory semantic essentially only applies when
@@ -896,7 +895,7 @@
*
* Wed Jan 10 11:34:26 CET 2007 elmex: fixed this function, we now check
* whether op is on this mapspace or not, because the value (1|0) depends
- * on this information. also make sure to only push_button if op has
+ * on this information. also make sure to only push_button if op has
* a matching item (because when we do a push_button with value=0 timed gates
* will still open)! (i hope i got the semantics right this time)
*