… | |
… | |
141 | * objects with lists are rare, and lists stay short. If not, use a |
141 | * objects with lists are rare, and lists stay short. If not, use a |
142 | * different structure or at least keep the lists sorted... |
142 | * different structure or at least keep the lists sorted... |
143 | */ |
143 | */ |
144 | |
144 | |
145 | /* For each field in wants, */ |
145 | /* For each field in wants, */ |
146 | for (wants_field = wants->key_values; wants_field != NULL; wants_field = wants_field->next) |
146 | for (wants_field = wants->key_values; wants_field; wants_field = wants_field->next) |
147 | { |
147 | { |
148 | key_value *has_field; |
148 | key_value *has_field; |
149 | |
149 | |
150 | /* Look for a field in has with the same key. */ |
150 | /* Look for a field in has with the same key. */ |
151 | has_field = get_ob_key_link (has, wants_field->key); |
151 | has_field = get_ob_key_link (has, wants_field->key); |
… | |
… | |
364 | { |
364 | { |
365 | if (!op) |
365 | if (!op) |
366 | return strdup ("[NULLOBJ]"); |
366 | return strdup ("[NULLOBJ]"); |
367 | |
367 | |
368 | object_freezer freezer; |
368 | object_freezer freezer; |
369 | save_object (freezer, op, 3); |
369 | save_object (freezer, op, 1); |
370 | return freezer.as_string (); |
370 | return freezer.as_string (); |
371 | } |
371 | } |
372 | |
372 | |
373 | /* |
373 | /* |
374 | * get_nearest_part(multi-object, object 2) returns the part of the |
374 | * get_nearest_part(multi-object, object 2) returns the part of the |
… | |
… | |
561 | extern int arch_init; |
561 | extern int arch_init; |
562 | |
562 | |
563 | /* No reason putting the archetypes objects on the speed list, |
563 | /* No reason putting the archetypes objects on the speed list, |
564 | * since they never really need to be updated. |
564 | * since they never really need to be updated. |
565 | */ |
565 | */ |
566 | |
|
|
567 | if (QUERY_FLAG (op, FLAG_FREED) && op->speed) |
566 | if (QUERY_FLAG (op, FLAG_FREED) && op->speed) |
568 | { |
567 | { |
569 | LOG (llevError, "Object %s is freed but has speed.\n", &op->name); |
568 | LOG (llevError, "Object %s is freed but has speed.\n", &op->name); |
570 | #ifdef MANY_CORES |
|
|
571 | abort (); |
|
|
572 | #else |
|
|
573 | op->speed = 0; |
569 | op->speed = 0; |
574 | #endif |
|
|
575 | } |
570 | } |
576 | |
571 | |
577 | if (arch_init) |
572 | if (arch_init) |
578 | return; |
573 | return; |
579 | |
574 | |
… | |
… | |
691 | */ |
686 | */ |
692 | if (!op->map || op->map->in_memory == MAP_SAVING) |
687 | if (!op->map || op->map->in_memory == MAP_SAVING) |
693 | return; |
688 | return; |
694 | |
689 | |
695 | /* make sure the object is within map boundaries */ |
690 | /* make sure the object is within map boundaries */ |
696 | if (op->x < 0 || op->x >= MAP_WIDTH (op->map) || op->y < 0 || op->y >= MAP_HEIGHT (op->map)) |
691 | if (op->x < 0 || op->x >= op->map->width || op->y < 0 || op->y >= op->map->height) |
697 | { |
692 | { |
698 | LOG (llevError, "update_object() called for object out of map!\n"); |
693 | LOG (llevError, "update_object() called for object out of map!\n"); |
699 | #ifdef MANY_CORES |
694 | #ifdef MANY_CORES |
700 | abort (); |
695 | abort (); |
701 | #endif |
696 | #endif |
… | |
… | |
1027 | dump = dump_object (GET_MAP_OB (map, x, y)); |
1022 | dump = dump_object (GET_MAP_OB (map, x, y)); |
1028 | LOG (llevError, "%s\n", dump); |
1023 | LOG (llevError, "%s\n", dump); |
1029 | free (dump); |
1024 | free (dump); |
1030 | } |
1025 | } |
1031 | |
1026 | |
1032 | map->at (x, y).bottom = above; /* goes on above it. */ |
1027 | map->at (x, y).bot = above; /* goes on above it. */ |
1033 | } |
1028 | } |
1034 | |
1029 | |
1035 | above = 0; |
1030 | above = 0; |
1036 | below = 0; |
1031 | below = 0; |
1037 | |
1032 | |
… | |
… | |
1281 | op->below = originator->below; |
1276 | op->below = originator->below; |
1282 | |
1277 | |
1283 | if (op->below) |
1278 | if (op->below) |
1284 | op->below->above = op; |
1279 | op->below->above = op; |
1285 | else |
1280 | else |
1286 | op->ms ().bottom = op; |
1281 | op->ms ().bot = op; |
1287 | |
1282 | |
1288 | /* since *below* originator, no need to update top */ |
1283 | /* since *below* originator, no need to update top */ |
1289 | originator->below = op; |
1284 | originator->below = op; |
1290 | } |
1285 | } |
1291 | else |
1286 | else |
… | |
… | |
1370 | |
1365 | |
1371 | if (op->above) |
1366 | if (op->above) |
1372 | op->above->below = op; |
1367 | op->above->below = op; |
1373 | |
1368 | |
1374 | op->below = NULL; |
1369 | op->below = NULL; |
1375 | op->ms ().bottom = op; |
1370 | op->ms ().bot = op; |
1376 | } |
1371 | } |
1377 | else |
1372 | else |
1378 | { /* get inserted into the stack above top */ |
1373 | { /* get inserted into the stack above top */ |
1379 | op->above = top->above; |
1374 | op->above = top->above; |
1380 | |
1375 | |
… | |
… | |
1407 | * be far away from this change and not affected in any way - |
1402 | * be far away from this change and not affected in any way - |
1408 | * this should get redone to only look for players within range, |
1403 | * this should get redone to only look for players within range, |
1409 | * or just updating the P_NEED_UPDATE for spaces within this area |
1404 | * or just updating the P_NEED_UPDATE for spaces within this area |
1410 | * of effect may be sufficient. |
1405 | * of effect may be sufficient. |
1411 | */ |
1406 | */ |
1412 | if (MAP_DARKNESS (op->map) && (op->glow_radius != 0)) |
1407 | if (op->map->darkness && (op->glow_radius != 0)) |
1413 | update_all_los (op->map, op->x, op->y); |
1408 | update_all_los (op->map, op->x, op->y); |
1414 | |
1409 | |
1415 | /* updates flags (blocked, alive, no magic, etc) for this map space */ |
1410 | /* updates flags (blocked, alive, no magic, etc) for this map space */ |
1416 | update_object (op, UP_OBJ_INSERT); |
1411 | update_object (op, UP_OBJ_INSERT); |
1417 | |
1412 | |
… | |
… | |
1703 | if ((op->glow_radius != 0) && map) |
1698 | if ((op->glow_radius != 0) && map) |
1704 | { |
1699 | { |
1705 | #ifdef DEBUG_LIGHTS |
1700 | #ifdef DEBUG_LIGHTS |
1706 | LOG (llevDebug, " insert_ob_in_ob(): got %s to insert in map/op\n", op->name); |
1701 | LOG (llevDebug, " insert_ob_in_ob(): got %s to insert in map/op\n", op->name); |
1707 | #endif /* DEBUG_LIGHTS */ |
1702 | #endif /* DEBUG_LIGHTS */ |
1708 | if (MAP_DARKNESS (map)) |
1703 | if (map->darkness) |
1709 | update_all_los (map, x, y); |
1704 | update_all_los (map, x, y); |
1710 | } |
1705 | } |
1711 | |
1706 | |
1712 | /* Client has no idea of ordering so lets not bother ordering it here. |
1707 | /* Client has no idea of ordering so lets not bother ordering it here. |
1713 | * It sure simplifies this function... |
1708 | * It sure simplifies this function... |
… | |
… | |
1781 | |
1776 | |
1782 | /* The objects have to be checked from top to bottom. |
1777 | /* The objects have to be checked from top to bottom. |
1783 | * Hence, we first go to the top: |
1778 | * Hence, we first go to the top: |
1784 | */ |
1779 | */ |
1785 | |
1780 | |
1786 | for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL && tmp->above != NULL; tmp = tmp->above) |
1781 | for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp && tmp->above; tmp = tmp->above) |
1787 | { |
1782 | { |
1788 | /* Trim the search when we find the first other spell effect |
1783 | /* Trim the search when we find the first other spell effect |
1789 | * this helps performance so that if a space has 50 spell objects, |
1784 | * this helps performance so that if a space has 50 spell objects, |
1790 | * we don't need to check all of them. |
1785 | * we don't need to check all of them. |
1791 | */ |
1786 | */ |
… | |
… | |
1846 | /* |
1841 | /* |
1847 | * present_arch(arch, map, x, y) searches for any objects with |
1842 | * present_arch(arch, map, x, y) searches for any objects with |
1848 | * a matching archetype at the given map and coordinates. |
1843 | * a matching archetype at the given map and coordinates. |
1849 | * The first matching object is returned, or NULL if none. |
1844 | * The first matching object is returned, or NULL if none. |
1850 | */ |
1845 | */ |
1851 | |
|
|
1852 | object * |
1846 | object * |
1853 | present_arch (const archetype *at, maptile *m, int x, int y) |
1847 | present_arch (const archetype *at, maptile *m, int x, int y) |
1854 | { |
1848 | { |
1855 | object * |
|
|
1856 | tmp; |
|
|
1857 | |
|
|
1858 | if (m == NULL || out_of_map (m, x, y)) |
1849 | if (m == NULL || out_of_map (m, x, y)) |
1859 | { |
1850 | { |
1860 | LOG (llevError, "Present_arch called outside map.\n"); |
1851 | LOG (llevError, "Present_arch called outside map.\n"); |
1861 | return NULL; |
1852 | return NULL; |
1862 | } |
1853 | } |
|
|
1854 | |
1863 | for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above) |
1855 | for (object *tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above) |
1864 | if (tmp->arch == at) |
1856 | if (tmp->arch == at) |
1865 | return tmp; |
1857 | return tmp; |
|
|
1858 | |
1866 | return NULL; |
1859 | return NULL; |
1867 | } |
1860 | } |
1868 | |
1861 | |
1869 | /* |
1862 | /* |
1870 | * present(type, map, x, y) searches for any objects with |
1863 | * present(type, map, x, y) searches for any objects with |
1871 | * a matching type variable at the given map and coordinates. |
1864 | * a matching type variable at the given map and coordinates. |
1872 | * The first matching object is returned, or NULL if none. |
1865 | * The first matching object is returned, or NULL if none. |
1873 | */ |
1866 | */ |
1874 | |
|
|
1875 | object * |
1867 | object * |
1876 | present (unsigned char type, maptile *m, int x, int y) |
1868 | present (unsigned char type, maptile *m, int x, int y) |
1877 | { |
1869 | { |
1878 | object * |
|
|
1879 | tmp; |
|
|
1880 | |
|
|
1881 | if (out_of_map (m, x, y)) |
1870 | if (out_of_map (m, x, y)) |
1882 | { |
1871 | { |
1883 | LOG (llevError, "Present called outside map.\n"); |
1872 | LOG (llevError, "Present called outside map.\n"); |
1884 | return NULL; |
1873 | return NULL; |
1885 | } |
1874 | } |
|
|
1875 | |
1886 | for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above) |
1876 | for (object *tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above) |
1887 | if (tmp->type == type) |
1877 | if (tmp->type == type) |
1888 | return tmp; |
1878 | return tmp; |
|
|
1879 | |
1889 | return NULL; |
1880 | return NULL; |
1890 | } |
1881 | } |
1891 | |
1882 | |
1892 | /* |
1883 | /* |
1893 | * present_in_ob(type, object) searches for any objects with |
1884 | * present_in_ob(type, object) searches for any objects with |
1894 | * a matching type variable in the inventory of the given object. |
1885 | * a matching type variable in the inventory of the given object. |
1895 | * The first matching object is returned, or NULL if none. |
1886 | * The first matching object is returned, or NULL if none. |
1896 | */ |
1887 | */ |
1897 | |
|
|
1898 | object * |
1888 | object * |
1899 | present_in_ob (unsigned char type, const object *op) |
1889 | present_in_ob (unsigned char type, const object *op) |
1900 | { |
1890 | { |
1901 | object * |
|
|
1902 | tmp; |
|
|
1903 | |
|
|
1904 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
1891 | for (object *tmp = op->inv; tmp != NULL; tmp = tmp->below) |
1905 | if (tmp->type == type) |
1892 | if (tmp->type == type) |
1906 | return tmp; |
1893 | return tmp; |
|
|
1894 | |
1907 | return NULL; |
1895 | return NULL; |
1908 | } |
1896 | } |
1909 | |
1897 | |
1910 | /* |
1898 | /* |
1911 | * present_in_ob (type, str, object) searches for any objects with |
1899 | * present_in_ob (type, str, object) searches for any objects with |
… | |
… | |
1922 | * to be unique. |
1910 | * to be unique. |
1923 | */ |
1911 | */ |
1924 | object * |
1912 | object * |
1925 | present_in_ob_by_name (int type, const char *str, const object *op) |
1913 | present_in_ob_by_name (int type, const char *str, const object *op) |
1926 | { |
1914 | { |
1927 | object *tmp; |
|
|
1928 | |
|
|
1929 | for (tmp = op->inv; tmp; tmp = tmp->below) |
1915 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
1930 | if ((type == -1 || tmp->type == type) && (!strcmp (str, tmp->name))) |
1916 | if ((type == -1 || tmp->type == type) && (!strcmp (str, tmp->name))) |
1931 | return tmp; |
1917 | return tmp; |
1932 | |
1918 | |
1933 | return 0; |
1919 | return 0; |
1934 | } |
1920 | } |
… | |
… | |
2143 | |
2129 | |
2144 | if ((move_type & blocked) == move_type) |
2130 | if ((move_type & blocked) == move_type) |
2145 | max = maxfree[i]; |
2131 | max = maxfree[i]; |
2146 | else if (mflags & P_IS_ALIVE) |
2132 | else if (mflags & P_IS_ALIVE) |
2147 | { |
2133 | { |
2148 | for (tmp = ms.bottom; tmp; tmp = tmp->above) |
2134 | for (tmp = ms.bot; tmp; tmp = tmp->above) |
2149 | if ((tmp->flag [FLAG_MONSTER] || tmp->type == PLAYER) |
2135 | if ((tmp->flag [FLAG_MONSTER] || tmp->type == PLAYER) |
2150 | && (tmp != exclude || (tmp->head && tmp->head != exclude))) |
2136 | && (tmp != exclude || (tmp->head && tmp->head != exclude))) |
2151 | break; |
2137 | break; |
2152 | |
2138 | |
2153 | if (tmp) |
2139 | if (tmp) |