… | |
… | |
276 | |
276 | |
277 | /* Note sure why the following is the case - either the object has to |
277 | /* Note sure why the following is the case - either the object has to |
278 | * be animated or have a very low speed. Is this an attempted monster |
278 | * be animated or have a very low speed. Is this an attempted monster |
279 | * check? |
279 | * check? |
280 | */ |
280 | */ |
281 | if (!QUERY_FLAG (ob1, FLAG_ANIMATE) && FABS ((ob1)->speed) > MIN_ACTIVE_SPEED) |
281 | if (!QUERY_FLAG (ob1, FLAG_ANIMATE) && ob1->has_active_speed ()) |
282 | return 0; |
282 | return 0; |
283 | |
283 | |
284 | switch (ob1->type) |
284 | switch (ob1->type) |
285 | { |
285 | { |
286 | case SCROLL: |
286 | case SCROLL: |
… | |
… | |
563 | speed = 0; |
563 | speed = 0; |
564 | } |
564 | } |
565 | |
565 | |
566 | this->speed = speed; |
566 | this->speed = speed; |
567 | |
567 | |
568 | if (FABS (speed) > MIN_ACTIVE_SPEED) |
568 | if (has_active_speed ()) |
569 | { |
569 | activate (false); |
570 | /* If already on active list, don't do anything */ |
|
|
571 | if (active_next || active_prev || this == active_objects) |
|
|
572 | return; |
|
|
573 | |
|
|
574 | /* process_events() expects us to insert the object at the beginning |
|
|
575 | * of the list. */ |
|
|
576 | active_next = active_objects; |
|
|
577 | |
|
|
578 | if (active_next) |
|
|
579 | active_next->active_prev = this; |
|
|
580 | |
|
|
581 | active_objects = this; |
|
|
582 | } |
|
|
583 | else |
570 | else |
584 | { |
571 | deactivate (false); |
585 | /* If not on the active list, nothing needs to be done */ |
|
|
586 | if (!active_next && !active_prev && this != active_objects) |
|
|
587 | return; |
|
|
588 | |
|
|
589 | if (!active_prev) |
|
|
590 | { |
|
|
591 | active_objects = active_next; |
|
|
592 | |
|
|
593 | if (active_next) |
|
|
594 | active_next->active_prev = 0; |
|
|
595 | } |
|
|
596 | else |
|
|
597 | { |
|
|
598 | active_prev->active_next = active_next; |
|
|
599 | |
|
|
600 | if (active_next) |
|
|
601 | active_next->active_prev = active_prev; |
|
|
602 | } |
|
|
603 | |
|
|
604 | active_next = 0; |
|
|
605 | active_prev = 0; |
|
|
606 | } |
|
|
607 | } |
572 | } |
608 | |
573 | |
609 | /* |
574 | /* |
610 | * update_object() updates the the map. |
575 | * update_object() updates the the map. |
611 | * It takes into account invisible objects (and represent squares covered |
576 | * It takes into account invisible objects (and represent squares covered |
… | |
… | |
741 | } |
706 | } |
742 | |
707 | |
743 | void |
708 | void |
744 | object::activate (bool recursive) |
709 | object::activate (bool recursive) |
745 | { |
710 | { |
746 | // uh, hack |
711 | if (has_active_speed ()) |
747 | set_speed (speed); |
712 | { |
|
|
713 | /* If already on active list, don't do anything */ |
|
|
714 | if (active_next || active_prev || this == active_objects) |
|
|
715 | return; |
|
|
716 | |
|
|
717 | /* process_events() expects us to insert the object at the beginning |
|
|
718 | * of the list. */ |
|
|
719 | active_next = active_objects; |
|
|
720 | |
|
|
721 | if (active_next) |
|
|
722 | active_next->active_prev = this; |
|
|
723 | |
|
|
724 | active_objects = this; |
|
|
725 | } |
748 | |
726 | |
749 | if (recursive) |
727 | if (recursive) |
750 | for (object *op = inv; op; op = op->above) |
728 | for (object *op = inv; op; op = op->above) |
751 | op->activate (1); |
729 | op->activate (1); |
752 | } |
730 | } |
… | |
… | |
2610 | } |
2588 | } |
2611 | else |
2589 | else |
2612 | item = item->env; |
2590 | item = item->env; |
2613 | } |
2591 | } |
2614 | |
2592 | |
|
|
2593 | |
|
|
2594 | const char * |
|
|
2595 | object::flag_desc (char *desc, int len) const |
|
|
2596 | { |
|
|
2597 | char *p = desc; |
|
|
2598 | bool first = true; |
|
|
2599 | |
|
|
2600 | for (int i = 0; i < NUM_FLAGS; i++) |
|
|
2601 | { |
|
|
2602 | if (len <= 10) // magic constant! |
|
|
2603 | { |
|
|
2604 | snprintf (p, len, ",..."); |
|
|
2605 | break; |
|
|
2606 | } |
|
|
2607 | |
|
|
2608 | if (flag[i]) |
|
|
2609 | { |
|
|
2610 | int cnt = snprintf (p, len, "%s%d", first ? "" : ",", i); |
|
|
2611 | len -= cnt; |
|
|
2612 | p += cnt; |
|
|
2613 | first = false; |
|
|
2614 | } |
|
|
2615 | } |
|
|
2616 | |
|
|
2617 | return desc; |
|
|
2618 | } |
|
|
2619 | |
2615 | // return a suitable string describing an objetc in enough detail to find it |
2620 | // return a suitable string describing an objetc in enough detail to find it |
2616 | const char * |
2621 | const char * |
2617 | object::debug_desc (char *info) const |
2622 | object::debug_desc (char *info) const |
2618 | { |
2623 | { |
|
|
2624 | char flagdesc[512]; |
2619 | char info2[256 * 3]; |
2625 | char info2[256 * 4]; |
2620 | char *p = info; |
2626 | char *p = info; |
2621 | |
2627 | |
2622 | p += snprintf (p, 256, "%d=\"%s%s%s\"", |
2628 | p += snprintf (p, 512, "{cnt:%d,uuid:<1,%" PRIx64 ">,name:\"%s%s%s\",flags:[%s],type:%d}", |
2623 | count, |
2629 | count, uuid.seq, |
2624 | &name, |
2630 | &name, |
2625 | title ? " " : "", |
2631 | title ? "\",title:" : "", |
2626 | title ? (const char *)title : ""); |
2632 | title ? (const char *)title : "", |
|
|
2633 | flag_desc (flagdesc, 512), type); |
2627 | |
2634 | |
2628 | if (env) |
2635 | if (env) |
2629 | p += snprintf (p, 256, "(in %s)", env->debug_desc (info2)); |
2636 | p += snprintf (p, 256, "(in %s)", env->debug_desc (info2)); |
2630 | |
2637 | |
2631 | if (map) |
2638 | if (map) |