… | |
… | |
733 | void |
733 | void |
734 | object::activate_recursive () |
734 | object::activate_recursive () |
735 | { |
735 | { |
736 | activate (); |
736 | activate (); |
737 | |
737 | |
738 | for (object *op = inv; op; op = op->above) |
738 | for (object *op = inv; op; op = op->below) |
739 | op->activate_recursive (); |
739 | op->activate_recursive (); |
740 | } |
740 | } |
741 | |
741 | |
742 | /* This function removes object 'op' from the list of active |
742 | /* This function removes object 'op' from the list of active |
743 | * objects. |
743 | * objects. |
… | |
… | |
772 | } |
772 | } |
773 | |
773 | |
774 | void |
774 | void |
775 | object::deactivate_recursive () |
775 | object::deactivate_recursive () |
776 | { |
776 | { |
777 | for (object *op = inv; op; op = op->above) |
777 | for (object *op = inv; op; op = op->below) |
778 | op->deactivate_recursive (); |
778 | op->deactivate_recursive (); |
779 | |
779 | |
780 | deactivate (); |
780 | deactivate (); |
|
|
781 | } |
|
|
782 | |
|
|
783 | void |
|
|
784 | object::set_flag_inv (int flag, int value) |
|
|
785 | { |
|
|
786 | for (object *op = inv; op; op = op->below) |
|
|
787 | { |
|
|
788 | op->flag [flag] = value; |
|
|
789 | op->set_flag_inv (flag, value); |
|
|
790 | } |
781 | } |
791 | } |
782 | |
792 | |
783 | /* |
793 | /* |
784 | * Remove and free all objects in the inventory of the given object. |
794 | * Remove and free all objects in the inventory of the given object. |
785 | * object.c ? |
795 | * object.c ? |
… | |
… | |
870 | freed_map->name = "/internal/freed_objects_map"; |
880 | freed_map->name = "/internal/freed_objects_map"; |
871 | freed_map->width = 3; |
881 | freed_map->width = 3; |
872 | freed_map->height = 3; |
882 | freed_map->height = 3; |
873 | |
883 | |
874 | freed_map->alloc (); |
884 | freed_map->alloc (); |
|
|
885 | freed_map->in_memory = MAP_IN_MEMORY; |
875 | } |
886 | } |
876 | |
887 | |
877 | map = freed_map; |
888 | map = freed_map; |
878 | x = 1; |
889 | x = 1; |
879 | y = 1; |
890 | y = 1; |
… | |
… | |
1203 | { |
1214 | { |
1204 | /* The part may be on a different map. */ |
1215 | /* The part may be on a different map. */ |
1205 | |
1216 | |
1206 | object *more = op->more; |
1217 | object *more = op->more; |
1207 | |
1218 | |
1208 | /* We really need the caller to normalize coordinates - if |
1219 | /* We really need the caller to normalise coordinates - if |
1209 | * we set the map, that doesn't work if the location is within |
1220 | * we set the map, that doesn't work if the location is within |
1210 | * a map and this is straddling an edge. So only if coordinate |
1221 | * a map and this is straddling an edge. So only if coordinate |
1211 | * is clear wrong do we normalize it. |
1222 | * is clear wrong do we normalise it. |
1212 | */ |
1223 | */ |
1213 | if (OUT_OF_REAL_MAP (more->map, more->x, more->y)) |
1224 | if (OUT_OF_REAL_MAP (more->map, more->x, more->y)) |
1214 | more->map = get_map_from_coord (m, &more->x, &more->y); |
1225 | more->map = get_map_from_coord (m, &more->x, &more->y); |
1215 | else if (!more->map) |
1226 | else if (!more->map) |
1216 | { |
1227 | { |
… | |
… | |
1443 | { |
1454 | { |
1444 | object *tmp, *tmp1; |
1455 | object *tmp, *tmp1; |
1445 | |
1456 | |
1446 | /* first search for itself and remove any old instances */ |
1457 | /* first search for itself and remove any old instances */ |
1447 | |
1458 | |
1448 | for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) |
1459 | for (tmp = op->ms ().bot; tmp; tmp = tmp->above) |
1449 | if (!strcmp (tmp->arch->name, arch_string)) /* same archetype */ |
1460 | if (!strcmp (tmp->arch->name, arch_string)) /* same archetype */ |
1450 | tmp->destroy (); |
1461 | tmp->destroy (); |
1451 | |
1462 | |
1452 | tmp1 = arch_to_object (archetype::find (arch_string)); |
1463 | tmp1 = arch_to_object (archetype::find (arch_string)); |
1453 | |
1464 | |
… | |
… | |
1776 | |
1787 | |
1777 | /* The objects have to be checked from top to bottom. |
1788 | /* The objects have to be checked from top to bottom. |
1778 | * Hence, we first go to the top: |
1789 | * Hence, we first go to the top: |
1779 | */ |
1790 | */ |
1780 | |
1791 | |
1781 | for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp && tmp->above; tmp = tmp->above) |
1792 | for (tmp = op->ms ().bot; tmp && tmp->above; tmp = tmp->above) |
1782 | { |
1793 | { |
1783 | /* Trim the search when we find the first other spell effect |
1794 | /* Trim the search when we find the first other spell effect |
1784 | * this helps performance so that if a space has 50 spell objects, |
1795 | * this helps performance so that if a space has 50 spell objects, |
1785 | * we don't need to check all of them. |
1796 | * we don't need to check all of them. |
1786 | */ |
1797 | */ |
… | |
… | |
1844 | * The first matching object is returned, or NULL if none. |
1855 | * The first matching object is returned, or NULL if none. |
1845 | */ |
1856 | */ |
1846 | object * |
1857 | object * |
1847 | present_arch (const archetype *at, maptile *m, int x, int y) |
1858 | present_arch (const archetype *at, maptile *m, int x, int y) |
1848 | { |
1859 | { |
1849 | if (m == NULL || out_of_map (m, x, y)) |
1860 | if (!m || out_of_map (m, x, y)) |
1850 | { |
1861 | { |
1851 | LOG (llevError, "Present_arch called outside map.\n"); |
1862 | LOG (llevError, "Present_arch called outside map.\n"); |
1852 | return NULL; |
1863 | return NULL; |
1853 | } |
1864 | } |
1854 | |
1865 | |
1855 | for (object *tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above) |
1866 | for (object *tmp = m->at (x, y).bot; tmp; tmp = tmp->above) |
1856 | if (tmp->arch == at) |
1867 | if (tmp->arch == at) |
1857 | return tmp; |
1868 | return tmp; |
1858 | |
1869 | |
1859 | return NULL; |
1870 | return NULL; |
1860 | } |
1871 | } |
… | |
… | |
1871 | { |
1882 | { |
1872 | LOG (llevError, "Present called outside map.\n"); |
1883 | LOG (llevError, "Present called outside map.\n"); |
1873 | return NULL; |
1884 | return NULL; |
1874 | } |
1885 | } |
1875 | |
1886 | |
1876 | for (object *tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above) |
1887 | for (object *tmp = m->at (x, y).bot; tmp; tmp = tmp->above) |
1877 | if (tmp->type == type) |
1888 | if (tmp->type == type) |
1878 | return tmp; |
1889 | return tmp; |
1879 | |
1890 | |
1880 | return NULL; |
1891 | return NULL; |
1881 | } |
1892 | } |
… | |
… | |
2613 | object::flag_desc (char *desc, int len) const |
2624 | object::flag_desc (char *desc, int len) const |
2614 | { |
2625 | { |
2615 | char *p = desc; |
2626 | char *p = desc; |
2616 | bool first = true; |
2627 | bool first = true; |
2617 | |
2628 | |
|
|
2629 | *p = 0; |
|
|
2630 | |
2618 | for (int i = 0; i < NUM_FLAGS; i++) |
2631 | for (int i = 0; i < NUM_FLAGS; i++) |
2619 | { |
2632 | { |
2620 | if (len <= 10) // magic constant! |
2633 | if (len <= 10) // magic constant! |
2621 | { |
2634 | { |
2622 | snprintf (p, len, ",..."); |
2635 | snprintf (p, len, ",..."); |
2623 | break; |
2636 | break; |
2624 | } |
2637 | } |
2625 | |
2638 | |
2626 | if (flag[i]) |
2639 | if (flag [i]) |
2627 | { |
2640 | { |
2628 | int cnt = snprintf (p, len, "%s%d", first ? "" : ",", i); |
2641 | int cnt = snprintf (p, len, "%s%d", first ? "" : ",", i); |
2629 | len -= cnt; |
2642 | len -= cnt; |
2630 | p += cnt; |
2643 | p += cnt; |
2631 | first = false; |
2644 | first = false; |
… | |
… | |
2633 | } |
2646 | } |
2634 | |
2647 | |
2635 | return desc; |
2648 | return desc; |
2636 | } |
2649 | } |
2637 | |
2650 | |
2638 | // return a suitable string describing an objetc in enough detail to find it |
2651 | // return a suitable string describing an object in enough detail to find it |
2639 | const char * |
2652 | const char * |
2640 | object::debug_desc (char *info) const |
2653 | object::debug_desc (char *info) const |
2641 | { |
2654 | { |
2642 | char flagdesc[512]; |
2655 | char flagdesc[512]; |
2643 | char info2[256 * 4]; |
2656 | char info2[256 * 4]; |
… | |
… | |
2660 | } |
2673 | } |
2661 | |
2674 | |
2662 | const char * |
2675 | const char * |
2663 | object::debug_desc () const |
2676 | object::debug_desc () const |
2664 | { |
2677 | { |
2665 | static char info[256 * 3]; |
2678 | static char info[256 * 4]; |
2666 | return debug_desc (info); |
2679 | return debug_desc (info); |
2667 | } |
2680 | } |
2668 | |
2681 | |