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.39 by root, Mon Aug 27 01:13:48 2007 UTC vs.
Revision 1.42 by root, Sun Apr 20 22:03:21 2008 UTC

1/* 1/*
2 * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team 4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * Crossfire TRT is free software: you can redistribute it and/or modify 8 * Deliantra 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 3 of the License, or 10 * the Free Software Foundation, either version 3 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,
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, see <http://www.gnu.org/licenses/>. 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * 20 *
21 * The authors can be reached via e-mail to <crossfire@schmorp.de> 21 * The authors can be reached via e-mail to <support@deliantra.net>
22 */ 22 */
23 23
24#include <global.h> 24#include <global.h>
25#include <funcpoint.h> 25#include <funcpoint.h>
26 26
235 } 235 }
236 236
237 tmp = ol->ob; 237 tmp = ol->ob;
238 if (tmp->type == BUTTON) 238 if (tmp->type == BUTTON)
239 { 239 {
240 for (ab = tmp->above, tot = 0; ab != NULL; ab = ab->above) 240 for (ab = tmp->above, tot = 0; ab; ab = ab->above)
241 /* Bug? The pedestal code below looks for the head of
242 * the object, this bit doesn't. I'd think we should check
243 * for head here also. Maybe it also makese sense to
244 * make the for ab=tmp->above loop common, and alter
245 * behaviour based on object within that loop?
246 */ 241 {
242 head = ab->head_ ();
247 243
248 /* Basically, if the move_type matches that on what the 244 /* Basically, if the move_type matches that on what the
249 * button wants, we count it. The second check is so that 245 * button wants, we count it. The second check is so that
250 * objects don't move (swords, etc) will count. Note that 246 * objects who don't move (swords, etc) will count. Note that
251 * this means that more work is needed to make buttons 247 * this means that more work is needed to make buttons
252 * that are only triggered by flying objects. 248 * that are only triggered by flying objects.
253 */ 249 */
254 if ((ab->move_type & tmp->move_on) || ab->move_type == 0) 250 if ((head->move_type & tmp->move_on) || head->move_type == 0)
255 tot += ab->weight * (ab->nrof ? ab->nrof : 1) + ab->carrying; 251 tot += head->total_weight ();
252 }
256 253
257 tmp->value = (tot >= tmp->weight) ? 1 : 0; 254 tmp->value = tot >= tmp->weight ? 1 : 0;
258 if (tmp->value)
259 any_down = 1;
260 } 255 }
261 else if (tmp->type == PEDESTAL) 256 else if (tmp->type == PEDESTAL)
262 { 257 {
263 tmp->value = 0; 258 tmp->value = 0;
259
264 for (ab = tmp->above; ab != NULL; ab = ab->above) 260 for (ab = tmp->above; ab; ab = ab->above)
265 { 261 {
266 head = ab->head_ (); 262 head = ab->head_ ();
263
267 /* Same note regarding move_type for buttons above apply here. */ 264 /* Same note regarding move_type for buttons above apply here. */
268 if (((head->move_type & tmp->move_on) || ab->move_type == 0) && 265 if (((head->move_type & tmp->move_on) || ab->move_type == 0) &&
269 (head->race == tmp->slaying || 266 (head->race == tmp->slaying ||
270 ((head->type == SPECIAL_KEY) && (head->slaying == tmp->slaying)) || 267 ((head->type == SPECIAL_KEY) && (head->slaying == tmp->slaying)) ||
271 (!strcmp (tmp->slaying, "player") && head->type == PLAYER))) 268 (!strcmp (tmp->slaying, "player") && head->type == PLAYER)))
272 tmp->value = 1; 269 tmp->value = 1;
273 } 270 }
274
275 if (tmp->value)
276 any_down = 1;
277 } 271 }
272
273 any_down = any_down || tmp->value;
278 } 274 }
275
279 if (any_down) /* If any other buttons were down, force this to remain down */ 276 if (any_down) /* If any other buttons were down, force this to remain down */
280 op->value = 1; 277 op->value = 1;
281 278
282 /* If this button hasn't changed, don't do anything */ 279 /* If this button hasn't changed, don't do anything */
283 if (op->value != old_value) 280 if (op->value != old_value)
328{ 325{
329 if (!QUERY_FLAG (sacrifice, FLAG_ALIVE) 326 if (!QUERY_FLAG (sacrifice, FLAG_ALIVE)
330 && !QUERY_FLAG (sacrifice, FLAG_IS_LINKED) 327 && !QUERY_FLAG (sacrifice, FLAG_IS_LINKED)
331 && sacrifice->type != PLAYER) 328 && sacrifice->type != PLAYER)
332 { 329 {
333 if (strcmp (ARCH_SACRIFICE (altar), "money") == 0 330 if (ARCH_SACRIFICE (altar) == shstr_money
334 && sacrifice->type == MONEY 331 && sacrifice->type == MONEY
335 && sacrifice->nrof * sacrifice->value >= NROF_SACRIFICE (altar)) 332 && sacrifice->nrof * sacrifice->value >= NROF_SACRIFICE (altar))
336 return 1; 333 return 1;
337 334
338 if ((ARCH_SACRIFICE (altar) == sacrifice->arch->archname 335 if ((ARCH_SACRIFICE (altar) == sacrifice->arch->archname
339 || ARCH_SACRIFICE (altar) == sacrifice->name 336 || ARCH_SACRIFICE (altar) == sacrifice->name
340 || ARCH_SACRIFICE (altar) == sacrifice->slaying 337 || ARCH_SACRIFICE (altar) == sacrifice->slaying
341 || strstr (query_base_name (sacrifice, 0), ARCH_SACRIFICE (altar))) 338 || strstr (query_base_name (sacrifice, 0), ARCH_SACRIFICE (altar)))
342 && NROF_SACRIFICE (altar) <= (sacrifice->nrof ? sacrifice->nrof : 1)) 339 && NROF_SACRIFICE (altar) <= sacrifice->number_of ())
343 return 1; 340 return 1;
344 } 341 }
345 342
346 return 0; 343 return 0;
347} 344}
371 return 0; 368 return 0;
372 369
373 /* check_altar_sacrifice should have already verified that enough money 370 /* check_altar_sacrifice should have already verified that enough money
374 * has been dropped. 371 * has been dropped.
375 */ 372 */
376 if (!strcmp (ARCH_SACRIFICE (altar), "money")) 373 if (ARCH_SACRIFICE (altar) == shstr_money)
377 { 374 {
378 int number = NROF_SACRIFICE (altar) / (*sacrifice)->value; 375 int number = NROF_SACRIFICE (altar) / (*sacrifice)->value;
379 376
380 /* Round up any sacrifices. Altars don't make change either */ 377 /* Round up any sacrifices. Altars don't make change either */
381 if (NROF_SACRIFICE (altar) % (*sacrifice)->value) 378 if (NROF_SACRIFICE (altar) % (*sacrifice)->value)
442 * button wants, we count it. The second check is so that 439 * button wants, we count it. The second check is so that
443 * objects that don't move (swords, etc) will count. Note that 440 * objects that don't move (swords, etc) will count. Note that
444 * this means that more work is needed to make buttons 441 * this means that more work is needed to make buttons
445 * that are only triggered by flying objects. 442 * that are only triggered by flying objects.
446 */ 443 */
447
448 if ((tmp->move_type & op->move_on) || tmp->move_type == 0) 444 if ((tmp->move_type & op->move_on) || tmp->move_type == 0)
449 { 445 tot += tmp->head_ ()->total_weight ();
450 tot += tmp->weight * (tmp->nrof ? tmp->nrof : 1) + tmp->carrying; 446
451 }
452 if (tot >= op->weight) 447 if (tot >= op->weight)
453 push = 1; 448 push = 1;
449
454 if (op->stats.ac == push) 450 if (op->stats.ac == push)
455 return 0; 451 return 0;
452
456 op->stats.ac = push; 453 op->stats.ac = push;
457 if (NUM_ANIMATIONS (op) > 1) 454 if (NUM_ANIMATIONS (op) > 1)
458 { 455 {
459 SET_ANIMATION (op, push); 456 SET_ANIMATION (op, push);
460 update_object (op, UP_OBJ_FACE); 457 update_object (op, UP_OBJ_FACE);
461 } 458 }
459
462 if (in_movement || !push) 460 if (in_movement || !push)
463 return 0; 461 return 0;
464 } 462 }
465 trigger_move (op, push); 463 trigger_move (op, push);
466 } 464 }
465
467 return 0; 466 return 0;
468 467
469 case TRIGGER_PEDESTAL: 468 case TRIGGER_PEDESTAL:
470 if (cause) 469 if (cause)
471 { 470 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines