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

Comparing deliantra/server/common/living.C (file contents):
Revision 1.5 by root, Sun Sep 3 00:18:40 2006 UTC vs.
Revision 1.7 by root, Sat Sep 9 21:48:28 2006 UTC

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.7 2006/09/09 21:48:28 root 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
368 * will clear the bits, but the player may still have some other object 368 * will clear the bits, but the player may still have some other object
369 * that gives them that ability. 369 * that gives them that ability.
370 */ 370 */
371int change_abil(object *op, object *tmp) { 371int change_abil(object *op, object *tmp) {
372 int flag=QUERY_FLAG(tmp,FLAG_APPLIED)?1:-1,i,j,success=0; 372 int flag=QUERY_FLAG(tmp,FLAG_APPLIED)?1:-1,i,j,success=0;
373 object refop;
374 char message[MAX_BUF]; 373 char message[MAX_BUF];
375 int potion_max=0; 374 int potion_max=0;
376 375
377 /* remember what object was like before it was changed. note that 376 /* remember what object was like before it was changed. note that
378 * refop is a local copy of op only to be used for detecting changes 377 * refop is a local copy of op only to be used for detecting changes
379 * found by fix_player. refop is not a real object 378 * found by fix_player. refop is not a real object
380 */ 379 */
381 memcpy(&refop, op, sizeof(object)); 380 object_pod refop;
381 memcpy (&refop, static_cast<object_pod *>(op), sizeof (object_pod));
382 382
383 if(op->type==PLAYER) { 383 if(op->type==PLAYER) {
384 if (tmp->type==POTION) { 384 if (tmp->type==POTION) {
385 potion_max=1; 385 potion_max=1;
386 for(j=0;j<NUM_STATS;j++) { 386 for(j=0;j<NUM_STATS;j++) {
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
1709sint64 check_exp_adjust(const object *op, sint64 exp) 1709sint64 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;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines