ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/player.C
(Generate patch)

Comparing deliantra/server/server/player.C (file contents):
Revision 1.231 by root, Sat Oct 3 18:46:26 2009 UTC vs.
Revision 1.232 by root, Sat Oct 3 20:11:12 2009 UTC

1790 /* First, lets try to find a key in the top level inventory */ 1790 /* First, lets try to find a key in the top level inventory */
1791 for (tmp = container->inv; tmp; tmp = tmp->below) 1791 for (tmp = container->inv; tmp; tmp = tmp->below)
1792 { 1792 {
1793 if (door->type == DOOR && tmp->type == KEY) 1793 if (door->type == DOOR && tmp->type == KEY)
1794 break; 1794 break;
1795
1795 /* For sanity, we should really check door type, but other stuff 1796 /* For sanity, we should really check door type, but other stuff
1796 * (like containers) can be locked with special keys 1797 * (like containers) can be locked with special keys
1797 */ 1798 */
1798 if (tmp->slaying && tmp->type == SPECIAL_KEY && tmp->slaying == door->slaying) 1799 if (tmp->slaying && tmp->type == SPECIAL_KEY && tmp->slaying == door->slaying)
1799 break; 1800 break;
1805 * a key, return 1806 * a key, return
1806 */ 1807 */
1807 if (!tmp) 1808 if (!tmp)
1808 { 1809 {
1809 for (tmp = container->inv; tmp; tmp = tmp->below) 1810 for (tmp = container->inv; tmp; tmp = tmp->below)
1810 {
1811 /* No reason to search empty containers */ 1811 /* No reason to search empty containers */
1812 if (tmp->type == CONTAINER && tmp->inv) 1812 if (tmp->type == CONTAINER && tmp->inv)
1813 {
1814 if ((key = find_key (pl, tmp, door))) 1813 if ((key = find_key (pl, tmp, door)))
1815 return key; 1814 return key;
1816 }
1817 }
1818 1815
1819 if (!tmp) 1816 if (!tmp)
1820 return NULL; 1817 return 0;
1821 } 1818 }
1822 1819
1823 /* We get down here if we have found a key. Now if its in a container, 1820 /* We get down here if we have found a key. Now if its in a container,
1824 * see if we actually want to use it 1821 * see if we actually want to use it
1825 */ 1822 */
1826 if (pl != container) 1823 if (pl != container)
1827 { 1824 {
1828 /* Only let players use keys in containers */ 1825 /* Only let players use keys in containers */
1829 if (!pl->contr) 1826 if (!pl->contr)
1830 return NULL; 1827 return 0;
1828
1831 /* cases where this fails: 1829 /* cases where this fails:
1832 * If we only search the player inventory, return now since we 1830 * If we only search the player inventory, return now since we
1833 * are not in the players inventory. 1831 * are not in the players inventory.
1834 * If the container is not active, return now since only active 1832 * If the container is not active, return now since only active
1835 * containers can be used. 1833 * containers can be used.
1909 * going to try and move (not fire weapons). 1907 * going to try and move (not fire weapons).
1910 */ 1908 */
1911bool 1909bool
1912move_player_attack (object *op, int dir) 1910move_player_attack (object *op, int dir)
1913{ 1911{
1912 if (!op->contr->braced && op->speed_left > 0.f && move_ob (op, dir, op))
1913 {
1914 --op->speed_left;
1915 return true;
1916 }
1917
1914 int on_battleground; 1918 int on_battleground;
1915 1919
1916 sint16 nx = freearr_x[dir] + op->x; 1920 sint16 nx = freearr_x[dir] + op->x;
1917 sint16 ny = freearr_y[dir] + op->y; 1921 sint16 ny = freearr_y[dir] + op->y;
1918 1922
1919 on_battleground = op_on_battleground (op, 0, 0); 1923 on_battleground = op_on_battleground (op, 0, 0);
1920 1924
1921 if (out_of_map (op->map, nx, ny)) 1925 if (out_of_map (op->map, nx, ny))
1922 return false; 1926 return false;
1923
1924 if (!op->contr->braced && op->speed_left > 0.f && move_ob (op, dir, op))
1925 {
1926 --op->speed_left;
1927 return true;
1928 }
1929 1927
1930 /* If braced, or can't move to the square, and it is not out of the 1928 /* If braced, or can't move to the square, and it is not out of the
1931 * map, attack it. Note order of if statement is important - don't 1929 * map, attack it. Note order of if statement is important - don't
1932 * want to be calling move_ob if braced, because move_ob will move the 1930 * want to be calling move_ob if braced, because move_ob will move the
1933 * player. This is a pretty nasty hack, because if we could 1931 * player. This is a pretty nasty hack, because if we could

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines