1 | /* |
1 | /* |
2 | * static char *rcsid_living_c = |
2 | * static char *rcsid_living_c = |
3 | * "$Id: living.C,v 1.5 2006/09/03 00:18:40 root Exp $"; |
3 | * "$Id: living.C,v 1.6 2006/09/07 09:37:12 pippijn Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
1584 | op->perm_exp = p_exp_min; |
1584 | op->perm_exp = p_exp_min; |
1585 | |
1585 | |
1586 | /* Cap permanent experience. */ |
1586 | /* Cap permanent experience. */ |
1587 | if (op->perm_exp < 0) |
1587 | if (op->perm_exp < 0) |
1588 | op->perm_exp = 0; |
1588 | op->perm_exp = 0; |
1589 | else if (op->perm_exp > MAX_EXPERIENCE) |
1589 | else if (op->perm_exp > (sint64) MAX_EXPERIENCE) |
1590 | op->perm_exp = MAX_EXPERIENCE; |
1590 | op->perm_exp = MAX_EXPERIENCE; |
1591 | } |
1591 | } |
1592 | |
1592 | |
1593 | |
1593 | |
1594 | /* Add experience to a player - exp should only be positive. |
1594 | /* Add experience to a player - exp should only be positive. |
… | |
… | |
1707 | } |
1707 | } |
1708 | |
1708 | |
1709 | sint64 check_exp_adjust(const object *op, sint64 exp) |
1709 | sint64 check_exp_adjust(const object *op, sint64 exp) |
1710 | { |
1710 | { |
1711 | if (exp<0) return check_exp_loss(op, exp); |
1711 | if (exp<0) return check_exp_loss(op, exp); |
1712 | else return MIN(exp, MAX_EXPERIENCE - op->stats.exp); |
1712 | else return MIN(exp, (sint64) MAX_EXPERIENCE - op->stats.exp); |
1713 | } |
1713 | } |
1714 | |
1714 | |
1715 | |
1715 | |
1716 | /* Subtracts experience from player. |
1716 | /* Subtracts experience from player. |
1717 | * if skill is set and flag == SK_SUBTRACT_SKILL_EXP, then we |
1717 | * if skill is set and flag == SK_SUBTRACT_SKILL_EXP, then we |
… | |
… | |
1797 | |
1797 | |
1798 | /* reset exp to max allowed value. We subtract from |
1798 | /* reset exp to max allowed value. We subtract from |
1799 | * MAX_EXPERIENCE to prevent overflows. If the player somehow has |
1799 | * MAX_EXPERIENCE to prevent overflows. If the player somehow has |
1800 | * more than max exp, just return. |
1800 | * more than max exp, just return. |
1801 | */ |
1801 | */ |
1802 | if (exp > 0 && ( op->stats.exp > (MAX_EXPERIENCE - exp))) { |
1802 | if (exp > 0 && ( op->stats.exp > (sint64) (MAX_EXPERIENCE - exp))) { |
1803 | exp = MAX_EXPERIENCE - op->stats.exp; |
1803 | exp = MAX_EXPERIENCE - op->stats.exp; |
1804 | if (exp < 0) return; |
1804 | if (exp < 0) return; |
1805 | } |
1805 | } |
1806 | |
1806 | |
1807 | op->stats.exp += exp; |
1807 | op->stats.exp += exp; |