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.40 by root, Thu Nov 8 19:43:23 2007 UTC vs.
Revision 1.43 by root, Mon Apr 21 06:35:26 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)
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)
382 number++; 379 number++;
383 380
384 *sacrifice = decrease_ob_nr (*sacrifice, number); 381 if (!(*sacrifice)->decrease (number))
382 *sacrifice = 0;
385 } 383 }
386 else 384 else
387 *sacrifice = decrease_ob_nr (*sacrifice, NROF_SACRIFICE (altar)); 385 if (!(*sacrifice)->decrease (NROF_SACRIFICE (altar)))
386 *sacrifice = 0;
388 387
389 if (altar->msg) 388 if (altar->msg)
390 new_info_map (NDI_BLACK, altar->map, altar->msg); 389 new_info_map (NDI_BLACK, altar->map, altar->msg);
391 390
392 return 1; 391 return 1;
442 * button wants, we count it. The second check is so that 441 * button wants, we count it. The second check is so that
443 * objects that don't move (swords, etc) will count. Note that 442 * objects that don't move (swords, etc) will count. Note that
444 * this means that more work is needed to make buttons 443 * this means that more work is needed to make buttons
445 * that are only triggered by flying objects. 444 * that are only triggered by flying objects.
446 */ 445 */
447
448 if ((tmp->move_type & op->move_on) || tmp->move_type == 0) 446 if ((tmp->move_type & op->move_on) || tmp->move_type == 0)
449 { 447 tot += tmp->head_ ()->total_weight ();
450 tot += tmp->weight * (tmp->nrof ? tmp->nrof : 1) + tmp->carrying; 448
451 }
452 if (tot >= op->weight) 449 if (tot >= op->weight)
453 push = 1; 450 push = 1;
451
454 if (op->stats.ac == push) 452 if (op->stats.ac == push)
455 return 0; 453 return 0;
454
456 op->stats.ac = push; 455 op->stats.ac = push;
457 if (NUM_ANIMATIONS (op) > 1) 456 if (NUM_ANIMATIONS (op) > 1)
458 { 457 {
459 SET_ANIMATION (op, push); 458 SET_ANIMATION (op, push);
460 update_object (op, UP_OBJ_FACE); 459 update_object (op, UP_OBJ_FACE);
461 } 460 }
461
462 if (in_movement || !push) 462 if (in_movement || !push)
463 return 0; 463 return 0;
464 } 464 }
465 trigger_move (op, push); 465 trigger_move (op, push);
466 } 466 }
467
467 return 0; 468 return 0;
468 469
469 case TRIGGER_PEDESTAL: 470 case TRIGGER_PEDESTAL:
470 if (cause) 471 if (cause)
471 { 472 {
894 // and we have to set the value to 0 895 // and we have to set the value to 0
895 896
896 if (match && trig->last_sp) // match == having 897 if (match && trig->last_sp) // match == having
897 { 898 {
898 if (trig->last_heal) 899 if (trig->last_heal)
899 decrease_ob (match); 900 match->decrease ();
900 901
901 trig->value = (pl == op ? 1 : 0); // 1 if matching player entered, and 0 if he left 902 trig->value = (pl == op ? 1 : 0); // 1 if matching player entered, and 0 if he left
902 push_button (trig); 903 push_button (trig);
903 } 904 }
904 else if (!match && !trig->last_sp) // match == not having 905 else if (!match && !trig->last_sp) // match == not having

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines