… | |
… | |
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 |
… | |
… | |
1027 | dump = dump_object (GET_MAP_OB (map, x, y)); |
1027 | dump = dump_object (GET_MAP_OB (map, x, y)); |
1028 | LOG (llevError, "%s\n", dump); |
1028 | LOG (llevError, "%s\n", dump); |
1029 | free (dump); |
1029 | free (dump); |
1030 | } |
1030 | } |
1031 | |
1031 | |
1032 | map->at (x, y).bottom = above; /* goes on above it. */ |
1032 | map->at (x, y).bot = above; /* goes on above it. */ |
1033 | } |
1033 | } |
1034 | |
1034 | |
1035 | above = 0; |
1035 | above = 0; |
1036 | below = 0; |
1036 | below = 0; |
1037 | |
1037 | |
… | |
… | |
1281 | op->below = originator->below; |
1281 | op->below = originator->below; |
1282 | |
1282 | |
1283 | if (op->below) |
1283 | if (op->below) |
1284 | op->below->above = op; |
1284 | op->below->above = op; |
1285 | else |
1285 | else |
1286 | op->ms ().bottom = op; |
1286 | op->ms ().bot = op; |
1287 | |
1287 | |
1288 | /* since *below* originator, no need to update top */ |
1288 | /* since *below* originator, no need to update top */ |
1289 | originator->below = op; |
1289 | originator->below = op; |
1290 | } |
1290 | } |
1291 | else |
1291 | else |
… | |
… | |
1370 | |
1370 | |
1371 | if (op->above) |
1371 | if (op->above) |
1372 | op->above->below = op; |
1372 | op->above->below = op; |
1373 | |
1373 | |
1374 | op->below = NULL; |
1374 | op->below = NULL; |
1375 | op->ms ().bottom = op; |
1375 | op->ms ().bot = op; |
1376 | } |
1376 | } |
1377 | else |
1377 | else |
1378 | { /* get inserted into the stack above top */ |
1378 | { /* get inserted into the stack above top */ |
1379 | op->above = top->above; |
1379 | op->above = top->above; |
1380 | |
1380 | |
… | |
… | |
1407 | * be far away from this change and not affected in any way - |
1407 | * be far away from this change and not affected in any way - |
1408 | * this should get redone to only look for players within range, |
1408 | * this should get redone to only look for players within range, |
1409 | * or just updating the P_NEED_UPDATE for spaces within this area |
1409 | * or just updating the P_NEED_UPDATE for spaces within this area |
1410 | * of effect may be sufficient. |
1410 | * of effect may be sufficient. |
1411 | */ |
1411 | */ |
1412 | if (MAP_DARKNESS (op->map) && (op->glow_radius != 0)) |
1412 | if (op->map->darkness && (op->glow_radius != 0)) |
1413 | update_all_los (op->map, op->x, op->y); |
1413 | update_all_los (op->map, op->x, op->y); |
1414 | |
1414 | |
1415 | /* updates flags (blocked, alive, no magic, etc) for this map space */ |
1415 | /* updates flags (blocked, alive, no magic, etc) for this map space */ |
1416 | update_object (op, UP_OBJ_INSERT); |
1416 | update_object (op, UP_OBJ_INSERT); |
1417 | |
1417 | |
… | |
… | |
1703 | if ((op->glow_radius != 0) && map) |
1703 | if ((op->glow_radius != 0) && map) |
1704 | { |
1704 | { |
1705 | #ifdef DEBUG_LIGHTS |
1705 | #ifdef DEBUG_LIGHTS |
1706 | LOG (llevDebug, " insert_ob_in_ob(): got %s to insert in map/op\n", op->name); |
1706 | LOG (llevDebug, " insert_ob_in_ob(): got %s to insert in map/op\n", op->name); |
1707 | #endif /* DEBUG_LIGHTS */ |
1707 | #endif /* DEBUG_LIGHTS */ |
1708 | if (MAP_DARKNESS (map)) |
1708 | if (map->darkness) |
1709 | update_all_los (map, x, y); |
1709 | update_all_los (map, x, y); |
1710 | } |
1710 | } |
1711 | |
1711 | |
1712 | /* Client has no idea of ordering so lets not bother ordering it here. |
1712 | /* Client has no idea of ordering so lets not bother ordering it here. |
1713 | * It sure simplifies this function... |
1713 | * It sure simplifies this function... |
… | |
… | |
1781 | |
1781 | |
1782 | /* The objects have to be checked from top to bottom. |
1782 | /* The objects have to be checked from top to bottom. |
1783 | * Hence, we first go to the top: |
1783 | * Hence, we first go to the top: |
1784 | */ |
1784 | */ |
1785 | |
1785 | |
1786 | for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL && tmp->above != NULL; tmp = tmp->above) |
1786 | for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp && tmp->above; tmp = tmp->above) |
1787 | { |
1787 | { |
1788 | /* Trim the search when we find the first other spell effect |
1788 | /* Trim the search when we find the first other spell effect |
1789 | * this helps performance so that if a space has 50 spell objects, |
1789 | * this helps performance so that if a space has 50 spell objects, |
1790 | * we don't need to check all of them. |
1790 | * we don't need to check all of them. |
1791 | */ |
1791 | */ |
… | |
… | |
1846 | /* |
1846 | /* |
1847 | * present_arch(arch, map, x, y) searches for any objects with |
1847 | * present_arch(arch, map, x, y) searches for any objects with |
1848 | * a matching archetype at the given map and coordinates. |
1848 | * a matching archetype at the given map and coordinates. |
1849 | * The first matching object is returned, or NULL if none. |
1849 | * The first matching object is returned, or NULL if none. |
1850 | */ |
1850 | */ |
1851 | |
|
|
1852 | object * |
1851 | object * |
1853 | present_arch (const archetype *at, maptile *m, int x, int y) |
1852 | present_arch (const archetype *at, maptile *m, int x, int y) |
1854 | { |
1853 | { |
1855 | object * |
|
|
1856 | tmp; |
|
|
1857 | |
|
|
1858 | if (m == NULL || out_of_map (m, x, y)) |
1854 | if (m == NULL || out_of_map (m, x, y)) |
1859 | { |
1855 | { |
1860 | LOG (llevError, "Present_arch called outside map.\n"); |
1856 | LOG (llevError, "Present_arch called outside map.\n"); |
1861 | return NULL; |
1857 | return NULL; |
1862 | } |
1858 | } |
|
|
1859 | |
1863 | for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above) |
1860 | for (object *tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above) |
1864 | if (tmp->arch == at) |
1861 | if (tmp->arch == at) |
1865 | return tmp; |
1862 | return tmp; |
|
|
1863 | |
1866 | return NULL; |
1864 | return NULL; |
1867 | } |
1865 | } |
1868 | |
1866 | |
1869 | /* |
1867 | /* |
1870 | * present(type, map, x, y) searches for any objects with |
1868 | * present(type, map, x, y) searches for any objects with |
1871 | * a matching type variable at the given map and coordinates. |
1869 | * a matching type variable at the given map and coordinates. |
1872 | * The first matching object is returned, or NULL if none. |
1870 | * The first matching object is returned, or NULL if none. |
1873 | */ |
1871 | */ |
1874 | |
|
|
1875 | object * |
1872 | object * |
1876 | present (unsigned char type, maptile *m, int x, int y) |
1873 | present (unsigned char type, maptile *m, int x, int y) |
1877 | { |
1874 | { |
1878 | object * |
|
|
1879 | tmp; |
|
|
1880 | |
|
|
1881 | if (out_of_map (m, x, y)) |
1875 | if (out_of_map (m, x, y)) |
1882 | { |
1876 | { |
1883 | LOG (llevError, "Present called outside map.\n"); |
1877 | LOG (llevError, "Present called outside map.\n"); |
1884 | return NULL; |
1878 | return NULL; |
1885 | } |
1879 | } |
|
|
1880 | |
1886 | for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above) |
1881 | for (object *tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above) |
1887 | if (tmp->type == type) |
1882 | if (tmp->type == type) |
1888 | return tmp; |
1883 | return tmp; |
|
|
1884 | |
1889 | return NULL; |
1885 | return NULL; |
1890 | } |
1886 | } |
1891 | |
1887 | |
1892 | /* |
1888 | /* |
1893 | * present_in_ob(type, object) searches for any objects with |
1889 | * present_in_ob(type, object) searches for any objects with |
1894 | * a matching type variable in the inventory of the given object. |
1890 | * a matching type variable in the inventory of the given object. |
1895 | * The first matching object is returned, or NULL if none. |
1891 | * The first matching object is returned, or NULL if none. |
1896 | */ |
1892 | */ |
1897 | |
|
|
1898 | object * |
1893 | object * |
1899 | present_in_ob (unsigned char type, const object *op) |
1894 | present_in_ob (unsigned char type, const object *op) |
1900 | { |
1895 | { |
1901 | object * |
|
|
1902 | tmp; |
|
|
1903 | |
|
|
1904 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
1896 | for (object *tmp = op->inv; tmp != NULL; tmp = tmp->below) |
1905 | if (tmp->type == type) |
1897 | if (tmp->type == type) |
1906 | return tmp; |
1898 | return tmp; |
|
|
1899 | |
1907 | return NULL; |
1900 | return NULL; |
1908 | } |
1901 | } |
1909 | |
1902 | |
1910 | /* |
1903 | /* |
1911 | * present_in_ob (type, str, object) searches for any objects with |
1904 | * present_in_ob (type, str, object) searches for any objects with |
… | |
… | |
1922 | * to be unique. |
1915 | * to be unique. |
1923 | */ |
1916 | */ |
1924 | object * |
1917 | object * |
1925 | present_in_ob_by_name (int type, const char *str, const object *op) |
1918 | present_in_ob_by_name (int type, const char *str, const object *op) |
1926 | { |
1919 | { |
1927 | object *tmp; |
|
|
1928 | |
|
|
1929 | for (tmp = op->inv; tmp; tmp = tmp->below) |
1920 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
1930 | if ((type == -1 || tmp->type == type) && (!strcmp (str, tmp->name))) |
1921 | if ((type == -1 || tmp->type == type) && (!strcmp (str, tmp->name))) |
1931 | return tmp; |
1922 | return tmp; |
1932 | |
1923 | |
1933 | return 0; |
1924 | return 0; |
1934 | } |
1925 | } |
… | |
… | |
2143 | |
2134 | |
2144 | if ((move_type & blocked) == move_type) |
2135 | if ((move_type & blocked) == move_type) |
2145 | max = maxfree[i]; |
2136 | max = maxfree[i]; |
2146 | else if (mflags & P_IS_ALIVE) |
2137 | else if (mflags & P_IS_ALIVE) |
2147 | { |
2138 | { |
2148 | for (tmp = ms.bottom; tmp; tmp = tmp->above) |
2139 | for (tmp = ms.bot; tmp; tmp = tmp->above) |
2149 | if ((tmp->flag [FLAG_MONSTER] || tmp->type == PLAYER) |
2140 | if ((tmp->flag [FLAG_MONSTER] || tmp->type == PLAYER) |
2150 | && (tmp != exclude || (tmp->head && tmp->head != exclude))) |
2141 | && (tmp != exclude || (tmp->head && tmp->head != exclude))) |
2151 | break; |
2142 | break; |
2152 | |
2143 | |
2153 | if (tmp) |
2144 | if (tmp) |