MCPcopy Create free account
hub / github.com/NetHack/NetHack / obj_delivery

Function obj_delivery

src/dokick.c:1768–1851  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1766}
1767
1768void
1769obj_delivery(boolean near_hero)
1770{
1771 struct obj *otmp, *otmp2;
1772 int nx = 0, ny = 0;
1773 int where;
1774 boolean nobreak, noscatter;
1775 stairway *stway;
1776 d_level fromdlev;
1777 boolean isladder;
1778
1779 for (otmp = gm.migrating_objs; otmp; otmp = otmp2) {
1780 otmp2 = otmp->nobj;
1781 if (otmp->ox != u.uz.dnum || otmp->oy != u.uz.dlevel)
1782 continue;
1783
1784 where = (int) (otmp->owornmask & 0x7fffL); /* destination code */
1785 if ((where & MIGR_TO_SPECIES) != 0)
1786 continue;
1787
1788 nobreak = (where & MIGR_NOBREAK) != 0;
1789 noscatter = (where & MIGR_WITH_HERO) != 0;
1790 where &= ~(MIGR_NOBREAK | MIGR_NOSCATTER);
1791
1792 if (!near_hero ^ (where == MIGR_WITH_HERO))
1793 continue;
1794
1795 obj_extract_self(otmp);
1796 otmp->owornmask = 0L;
1797 fromdlev.dnum = otmp->omigr_from_dnum;
1798 fromdlev.dlevel = otmp->omigr_from_dlevel;
1799
1800 isladder = FALSE;
1801
1802 switch (where) {
1803 case MIGR_LADDER_UP:
1804 isladder = TRUE;
1805 FALLTHROUGH;
1806 /*FALLTHRU*/
1807 case MIGR_STAIRS_UP:
1808 case MIGR_SSTAIRS:
1809 if ((stway = stairway_find_from(&fromdlev, isladder)) != 0) {
1810 nx = stway->sx;
1811 ny = stway->sy;
1812 }
1813 break;
1814 case MIGR_WITH_HERO:
1815 nx = u.ux, ny = u.uy;
1816 break;
1817 default:
1818 case MIGR_RANDOM:
1819 nx = ny = 0;
1820 break;
1821 }
1822 otmp->omigr_from_dnum = 0;
1823 otmp->omigr_from_dlevel = 0;
1824 if (nx > 0) {
1825 place_object(otmp, nx, ny);

Callers 2

newgameFunction · 0.85
goto_levelFunction · 0.85

Calls 11

obj_extract_selfFunction · 0.85
stairway_find_fromFunction · 0.85
place_objectFunction · 0.85
breaksFunction · 0.85
breaktestFunction · 0.85
delobjFunction · 0.85
stackobjFunction · 0.85
scatterFunction · 0.85
rndFunction · 0.85
newsymFunction · 0.85
rlocoFunction · 0.85

Tested by

no test coverage detected