[CF-Devel] CVS update: crossfire/common

Crossfire CVS devel mwedel at scruznet.com
Fri Aug 25 01:23:28 CDT 2000


Date:	Thursday August 24, 2000 @ 23:23
Author:	cvs

Update of /home/cvs/CVS/crossfire/common
In directory boltzmann.eecs.berkeley.edu:/tmp/cvs-serv13404/common

Modified Files:
	living.c 
Log Message:
common/living.c, server/skill_util.c:  Patches by Garth Denley:
Fixes divide by zero crash, sets up perm exp when a new player is loaded,
seperates permanent exp code/calculations into another function.
checked in by MSW, 8/24/2000



****************************************

Index: crossfire/common/living.c
diff -u crossfire/common/living.c:1.10 crossfire/common/living.c:1.11
--- crossfire/common/living.c:1.10	Mon Aug  7 23:57:57 2000
+++ crossfire/common/living.c	Thu Aug 24 23:23:28 2000
@@ -1,6 +1,6 @@
 /*
  * static char *rcsid_living_c =
- *   "$Id: living.c,v 1.10 2000/08/08 06:57:57 cvs Exp $";
+ *   "$Id: living.c,v 1.11 2000/08/25 06:23:28 cvs Exp $";
  */
 
 /*
@@ -1586,6 +1586,39 @@
     }
 }
 
+/* Ensure that the permanent experience requirements in an exp object are met. */
+/* GD */
+void calc_perm_exp(object *op)
+{
+    int p_exp_min;
+
+    /* Sanity checks. */
+    if (op->type != EXPERIENCE) {
+        LOG(llevError, "calc_minimum_perm_exp called on a non-experience object!");
+        return;
+    }
+    if (!(settings.use_permanent_experience)) {
+        LOG(llevError, "calc_minimum_perm_exp called whilst permanent experience disabled!");
+        return;
+    }
+
+    /* The following fields are used: */
+    /* stats.exp: Current exp in experience object. */
+    /* last_heal: Permanent experience earnt. */
+    
+    /* Ensure that our permanent experience minimum is met. */
+    p_exp_min = (int)(PERM_EXP_MINIMUM_RATIO * (float)(op->stats.exp));
+    /*LOG(llevError, "Experience minimum check: %d p-min %d p-curr %d curr.\n", p_exp_min, op->last_heal, op->stats.exp);*/
+    if (op->last_heal < p_exp_min)
+        op->last_heal = p_exp_min;
+
+    /* Cap permanent experience. */
+    if (op->last_heal < 0)
+        op->last_heal = 0;
+    else if (op->last_heal > MAX_EXP_IN_OBJ)
+        op->last_heal = MAX_EXP_IN_OBJ;
+}
+
 /* adjust_exp() - make sure that we don't exceed max or min set on
  * experience
  */
@@ -1598,27 +1631,20 @@
         /* This code _only_ affects experience objects. */
         /* GD */
         if (op->type == EXPERIENCE) {
-            int p_exp_min;
             int p_exp_gain;
             int max_loss;
 
-            /* The following fields are used: */
-            /* stats.exp: Current exp in experience object. */
-            /* last_heal: Permanent experience earnt. */
-            
             /* Ensure that our permanent experience minimum is met. */
-            p_exp_min = (int)(PERM_EXP_MINIMUM_RATIO * (float)(op->stats.exp));
-            /*LOG(llevError, "Experience minimum check: %d p-min %d p-curr %d curr.\n", p_exp_min, op->last_heal, op->stats.exp);*/
-            if (op->last_heal < p_exp_min)
-                op->last_heal = p_exp_min;
-
+            calc_perm_exp(op);            
+            
             /* Experience gain: We get a ratio of the gain as permanent experience. */
             if (exp > 0) {
                 p_exp_gain = (int)(PERM_EXP_GAIN_RATIO * exp);
                 op->last_heal += p_exp_gain;
-                /* Cap permanent experience. */
-                if (op->last_heal > MAX_EXP_IN_OBJ)
-                    op->last_heal = MAX_EXP_IN_OBJ;
+
+                /* Update our new perm exp (so we display the right amount when asked. */
+                calc_perm_exp(op);
+                
                 /*LOG(llevError, "Gaining %d experience results in %d permanent exp (now %d).\n", exp, p_exp_gain, op->last_heal); */
             }
 

    
    


More information about the crossfire mailing list