… | |
… | |
352 | op = op->env; |
352 | op = op->env; |
353 | return op; |
353 | return op; |
354 | } |
354 | } |
355 | |
355 | |
356 | /* |
356 | /* |
357 | * Eneq(@csd.uu.se): Since we can have items buried in a character we need |
|
|
358 | * a better check. We basically keeping traversing up until we can't |
|
|
359 | * or find a player. |
|
|
360 | */ |
|
|
361 | |
|
|
362 | object * |
|
|
363 | is_player_inv (object *op) |
|
|
364 | { |
|
|
365 | for (; op != NULL && op->type != PLAYER; op = op->env) |
|
|
366 | if (op->env == op) |
|
|
367 | op->env = NULL; |
|
|
368 | return op; |
|
|
369 | } |
|
|
370 | |
|
|
371 | /* |
|
|
372 | * Used by: Crossedit: dump. Server DM commands: dumpbelow, dump. |
357 | * Used by: Crossedit: dump. Server DM commands: dumpbelow, dump. |
373 | * Some error messages. |
358 | * Some error messages. |
374 | * The result of the dump is stored in the static global errmsg array. |
359 | * The result of the dump is stored in the static global errmsg array. |
375 | */ |
360 | */ |
376 | |
361 | |
… | |
… | |
1055 | |
1040 | |
1056 | /* NO_FIX_PLAYER is set when a great many changes are being |
1041 | /* NO_FIX_PLAYER is set when a great many changes are being |
1057 | * made to players inventory. If set, avoiding the call |
1042 | * made to players inventory. If set, avoiding the call |
1058 | * to save cpu time. |
1043 | * to save cpu time. |
1059 | */ |
1044 | */ |
1060 | if ((otmp = is_player_inv (env)) != NULL && otmp->contr && !QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) |
1045 | if ((otmp = in_player ()) && otmp->contr && !QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) |
1061 | fix_player (otmp); |
1046 | fix_player (otmp); |
1062 | |
1047 | |
1063 | if (above != NULL) |
1048 | if (above != NULL) |
1064 | above->below = below; |
1049 | above->below = below; |
1065 | else |
1050 | else |
… | |
… | |
1619 | else if (op->env) |
1604 | else if (op->env) |
1620 | { |
1605 | { |
1621 | /* is this object in the players inventory, or sub container |
1606 | /* is this object in the players inventory, or sub container |
1622 | * therein? |
1607 | * therein? |
1623 | */ |
1608 | */ |
1624 | tmp = is_player_inv (op->env); |
1609 | tmp = op->in_player (); |
1625 | /* nope. Is this a container the player has opened? |
1610 | /* nope. Is this a container the player has opened? |
1626 | * If so, set tmp to that player. |
1611 | * If so, set tmp to that player. |
1627 | * IMO, searching through all the players will mostly |
1612 | * IMO, searching through all the players will mostly |
1628 | * likely be quicker than following op->env to the map, |
1613 | * likely be quicker than following op->env to the map, |
1629 | * and then searching the map for a player. |
1614 | * and then searching the map for a player. |
… | |
… | |
1777 | add_weight (this, op->weight * op->nrof); |
1762 | add_weight (this, op->weight * op->nrof); |
1778 | } |
1763 | } |
1779 | else |
1764 | else |
1780 | add_weight (this, (op->weight + op->carrying)); |
1765 | add_weight (this, (op->weight + op->carrying)); |
1781 | |
1766 | |
1782 | otmp = is_player_inv (this); |
1767 | otmp = this->in_player (); |
1783 | if (otmp && otmp->contr) |
1768 | if (otmp && otmp->contr) |
1784 | if (!QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) |
1769 | if (!QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) |
1785 | fix_player (otmp); |
1770 | fix_player (otmp); |
1786 | |
1771 | |
1787 | op->map = NULL; |
1772 | op->map = 0; |
1788 | op->env = this; |
1773 | op->env = this; |
1789 | op->above = NULL; |
1774 | op->above = 0; |
1790 | op->below = NULL; |
1775 | op->below = 0; |
1791 | op->x = 0, op->y = 0; |
1776 | op->x = 0, op->y = 0; |
1792 | |
1777 | |
1793 | /* reset the light list and los of the players on the map */ |
1778 | /* reset the light list and los of the players on the map */ |
1794 | if ((op->glow_radius != 0) && map) |
1779 | if ((op->glow_radius != 0) && map) |
1795 | { |
1780 | { |
… | |
… | |
2132 | * if the space being examined only has a wall to the north and empty |
2117 | * if the space being examined only has a wall to the north and empty |
2133 | * spaces in all the other directions, this will reduce the search space |
2118 | * spaces in all the other directions, this will reduce the search space |
2134 | * to only the spaces immediately surrounding the target area, and |
2119 | * to only the spaces immediately surrounding the target area, and |
2135 | * won't look 2 spaces south of the target space. |
2120 | * won't look 2 spaces south of the target space. |
2136 | */ |
2121 | */ |
2137 | else if ((flag & AB_NO_PASS) && maxfree[i] < stop) |
2122 | else if ((flag & P_NO_PASS) && maxfree[i] < stop) |
2138 | stop = maxfree[i]; |
2123 | stop = maxfree[i]; |
2139 | } |
2124 | } |
|
|
2125 | |
2140 | if (!index) |
2126 | if (!index) |
2141 | return -1; |
2127 | return -1; |
|
|
2128 | |
2142 | return altern[RANDOM () % index]; |
2129 | return altern[RANDOM () % index]; |
2143 | } |
2130 | } |
2144 | |
2131 | |
2145 | /* |
2132 | /* |
2146 | * find_first_free_spot(archetype, maptile, x, y) works like |
2133 | * find_first_free_spot(archetype, maptile, x, y) works like |