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.20 by root, Tue Dec 26 08:54:58 2006 UTC vs.
Revision 1.24 by elmex, Tue Jan 9 16:38:23 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) 2002 Mark Wedel & Crossfire Development Team 5 Copyright (C) 2002 Mark Wedel & Crossfire Development Team
5 Copyright (C) 1992 Frank Tore Johansen 6 Copyright (C) 1992 Frank Tore Johansen
6 7
7 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
8 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
273 update_object (op, UP_OBJ_FACE); 274 update_object (op, UP_OBJ_FACE);
274 push_button (op); /* Make all other buttons the same */ 275 push_button (op); /* Make all other buttons the same */
275 } 276 }
276} 277}
277 278
278/*
279 * Updates every button on the map (by calling update_button() for them).
280 */
281
282void
283update_buttons (maptile *m)
284{
285 objectlink *ol;
286 oblinkpt *obp;
287
288 for (obp = m->buttons; obp; obp = obp->next)
289 for (ol = obp->link; ol; ol = ol->next)
290 {
291 if (!ol->ob)
292 {
293 LOG (llevError, "Internal error in update_button (%s (%dx%d), connected %ld).\n",
294 ol->ob ? (const char *) ol->ob->name : "null", ol->ob ? ol->ob->x : -1, ol->ob ? ol->ob->y : -1, obp->value);
295 continue;
296 }
297
298 if (ol->ob->type == BUTTON || ol->ob->type == PEDESTAL)
299 {
300 update_button (ol->ob);
301 break;
302 }
303 }
304}
305
306void 279void
307use_trigger (object *op) 280use_trigger (object *op)
308{ 281{
309
310 /* Toggle value */ 282 /* Toggle value */
311 op->value = !op->value; 283 op->value = !op->value;
312 push_button (op); 284 push_button (op);
313} 285}
314 286
315/* 287/*
316 * Note: animate_object should be used instead of this, 288 * Note: animate_object should be used instead of this,
317 * but it can't handle animations in the 8 directions 289 * but it can't handle animations in the 8 directions
318 */ 290 */
319
320void 291void
321animate_turning (object *op) /* only one part objects */ 292animate_turning (object *op) /* only one part objects */
322{ 293{
323 if (++op->state >= NUM_ANIMATIONS (op) / 8) 294 if (++op->state >= NUM_ANIMATIONS (op) / 8)
324 op->state = 0; 295 op->state = 0;
797 768
798 tmp->set_owner (tmp2); 769 tmp->set_owner (tmp2);
799 SET_FLAG (tmp, FLAG_MONSTER); 770 SET_FLAG (tmp, FLAG_MONSTER);
800 771
801 tmp->stats.exp = 0; 772 tmp->stats.exp = 0;
802 SET_FLAG (tmp, FLAG_FRIENDLY);
803 773
804 add_friendly_object (tmp); 774 add_friendly_object (tmp);
805 tmp->attack_movement = PETMOVE; 775 tmp->attack_movement = PETMOVE;
806 break; 776 break;
807 777
862 * 832 *
863 */ 833 */
864void 834void
865check_inv (object *op, object *trig) 835check_inv (object *op, object *trig)
866{ 836{
837 sint32 prev_state = trig->value;
867 trig->value = 0; // deactivate if none of the following conditions apply 838 trig->value = 0; // deactivate if none of the following conditions apply
868 839
869 if (object *pl = trig->ms ().player ()) 840 if (object *pl = trig->ms ().player ())
870 { 841 {
871 object *match = check_inv_recursive (pl, trig); 842 object *match = check_inv_recursive (pl, trig);
879 } 850 }
880 else if (!match && !trig->last_sp) // match == not having 851 else if (!match && !trig->last_sp) // match == not having
881 trig->value = 1; 852 trig->value = 1;
882 } 853 }
883 854
855 if (prev_state != trig->value)
884 push_button (trig); 856 push_button (trig);
885} 857}
886 858

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines