ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/button.C
(Generate patch)

Comparing deliantra/server/common/button.C (file contents):
Revision 1.24 by elmex, Tue Jan 9 16:38:23 2007 UTC vs.
Revision 1.27 by pippijn, Mon Jan 15 21:06:18 2007 UTC

1/* 1/*
2 CrossFire, A Multiplayer game for X-windows 2 * CrossFire, A Multiplayer game for X-windows
3 3 *
4 Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team 4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
5 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team
6 Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (C) 1992 Frank Tore Johansen
7 7 *
8 This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version. 11 * (at your option) any later version.
12 12 *
13 This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details. 16 * GNU General Public License for more details.
17 17 *
18 You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 21 *
22 The authors can be reached via e-mail at <crossfire@schmorp.de> 22 * The authors can be reached via e-mail at <crossfire@schmorp.de>
23*/ 23 */
24 24
25#include <global.h> 25#include <global.h>
26#include <funcpoint.h> 26#include <funcpoint.h>
27 27
28/* 28/*
828 * and has a matching item. Imagine what happens if someone steps on the inventory 828 * and has a matching item. Imagine what happens if someone steps on the inventory
829 * checker with a matching item, has it, activates the connection, throws the item 829 * checker with a matching item, has it, activates the connection, throws the item
830 * away, and then leaves the inventory checker. That would've caused an always-enabled 830 * away, and then leaves the inventory checker. That would've caused an always-enabled
831 * state in the inventory checker. This won't happen anymore now. 831 * state in the inventory checker. This won't happen anymore now.
832 * 832 *
833 * Wed Jan 10 11:34:26 CET 2007 elmex: fixed this function, we now check
834 * whether op is on this mapspace or not, because the value (1|0) depends
835 * on this information. also make sure to only push_button if op has
836 * a matching item (because when we do a push_button with value=0 timed gates
837 * will still open)! (i hope i got the semantics right this time)
838 *
833 */ 839 */
834void 840void
835check_inv (object *op, object *trig) 841check_inv (object *op, object *trig)
836{ 842{
837 sint32 prev_state = trig->value;
838 trig->value = 0; // deactivate if none of the following conditions apply 843 trig->value = 0; // deactivate if none of the following conditions apply
839 844
840 if (object *pl = trig->ms ().player ()) 845 object *pl = trig->ms ().player ();
841 {
842 object *match = check_inv_recursive (pl, trig); 846 object *match = check_inv_recursive (op, trig);
843 847
848 // elmex: a note about (pl == op):
849 // if pl == 0 then the player has left this space
850 // if pl != 0 then a player is on this mapspace, but then
851 // we still have to check whether it's the player that triggered
852 // this inv-checker, because if not, then the op left this inv-checker
853 // and we have to set the value to 0
854
844 if (match && trig->last_sp) // match == having 855 if (match && trig->last_sp) // match == having
845 { 856 {
846 if (trig->last_heal) 857 if (trig->last_heal)
847 decrease_ob (match); 858 decrease_ob (match);
848 859
849 trig->value = 1; 860 trig->value = (pl == op ? 1 : 0); // 1 if matching player entered, and 0 if he left
850 } 861 push_button (trig);
862 }
851 else if (!match && !trig->last_sp) // match == not having 863 else if (!match && !trig->last_sp) // match == not having
852 trig->value = 1;
853 } 864 {
854 865 trig->value = (pl == op ? 1 : 0); // 1 if matching player entered, and 0 if he left
855 if (prev_state != trig->value)
856 push_button (trig); 866 push_button (trig);
867 }
857} 868}
858 869

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines