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.41 by root, Wed Apr 9 14:36:47 2008 UTC vs.
Revision 1.42 by root, Sun Apr 20 22:03:21 2008 UTC

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)
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}
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