[CF-Devel] Path: some more warning cleaning

crossfire-devel at archives.real-time.com crossfire-devel at archives.real-time.com
Tue Dec 30 13:16:16 CST 2003


Before the year ends, time to clean some more warnings :)

Quick overview of (proposed) changes:

* include/player.h: last_save_tick changed to long, for coherence with common/time.c

* include/define.h: explicit cast to sint64 for slow penality (uses exp field)

* common/loader.l: some explicit double-to-float casts, casting_time is integer, 
not float

* server/disease.c: explicit float-to-int casts

* server/egoitem.c: explicit cast to int

* server/gods.c: strlen & strncmp use size_t, some explicit float-to-int casts

* server/hiscore.c: strlen uses size_t

* server/init.c: explicit double-to-float cast

* server/monster.c: radius is unsigned int

* server/move.c: explicit casts to sint16

* server/pets.c: added f at end of float constants

Have a nice end of year!

Nicolas 'Ryo'
-------------- next part --------------
Index: include/player.h
===================================================================
RCS file: /cvsroot/crossfire/crossfire/include/player.h,v
retrieving revision 1.33
diff -u -r1.33 player.h
--- include/player.h	13 Sep 2003 05:01:34 -0000	1.33
+++ include/player.h	30 Dec 2003 19:04:50 -0000
@@ -170,7 +170,7 @@
     time_t	last_save_time;
 #endif /* SAVE_INTERVAL */
 #ifdef AUTOSAVE
-    uint32	last_save_tick;
+    long	last_save_tick;
 #endif
     sint16    party_number;	    /* Party number this player is part of */
     sint16    party_number_to_join; /* used when player wants to join a party */
Index: include/define.h
===================================================================
RCS file: /cvsroot/crossfire/crossfire/include/define.h,v
retrieving revision 1.70
diff -u -r1.70 define.h
--- include/define.h	18 Dec 2003 20:39:45 -0000	1.70
+++ include/define.h	30 Dec 2003 19:04:53 -0000
@@ -559,7 +559,7 @@
 #define NROFNEWOBJS(xyz)	((xyz)->stats.food)
 
 #define SLOW_PENALTY(xyz)	((xyz)->stats.exp)/1000.0
-#define SET_SLOW_PENALTY(xyz,fl)	(xyz)->stats.exp=(fl)*1000
+#define SET_SLOW_PENALTY(xyz,fl)	(xyz)->stats.exp=( sint64 )( (fl)*1000 )
 #define SET_GENERATE_TYPE(xyz,va)	(xyz)->stats.sp=(va)
 #define GENERATE_TYPE(xyz)	((xyz)->stats.sp)
 #define GENERATE_SPEED(xyz)	((xyz)->stats.maxsp) /* if(!RANDOM()%<speed>) */
Index: common/loader.l
===================================================================
RCS file: /cvsroot/crossfire/crossfire/common/loader.l,v
retrieving revision 1.55
diff -u -r1.55 loader.l
--- common/loader.l	11 Nov 2003 07:58:30 -0000	1.55
+++ common/loader.l	30 Dec 2003 19:05:44 -0000
@@ -603,13 +603,13 @@
 ^last_sp{S}	    op->last_sp = IVAL;
 ^last_grace{S}	    op->last_grace = IVAL;
 ^last_eat{S}	    op->last_eat = IVAL;
-^speed{S}	    {	op->speed = FVAL;
+^speed{S}	    {	op->speed = ( float )FVAL;
 			if (!(map_flags & MAP_STYLE)) {
-			    if (op->speed<0) op->speed_left = op->speed_left-RANDOM()%100/100.0;
+			    if (op->speed<0) op->speed_left = op->speed_left-RANDOM()%100/100.0f;
 			    update_ob_speed(op);
 			}
 		    }
-^speed_left{S}    op->speed_left = FVAL;
+^speed_left{S}    op->speed_left = ( float )FVAL;
 ^slow_move{S}	    {	SET_SLOW_PENALTY(op,FVAL);
 			SET_FLAG(op, FLAG_SLOW_MOVE);
 		    }
@@ -851,7 +851,7 @@
 ^can_dam_armour{S}	{ }
 ^weapontype{S}		op->weapontype = IVAL;
 ^tooltype{S}            op->tooltype = IVAL;
-^casting_time{S}	op->casting_time = FVAL;
+^casting_time{S}	op->casting_time = IVAL;
 ^elevation{S}		op->elevation = IVAL;
 ^smoothlevel{S}		op->smoothlevel = IVAL;
 ^client_type{S}		op->client_type = IVAL;
Index: server/disease.c
===================================================================
RCS file: /cvsroot/crossfire/crossfire/server/disease.c,v
retrieving revision 1.27
diff -u -r1.27 disease.c
--- server/disease.c	13 Sep 2003 05:02:09 -0000	1.27
+++ server/disease.c	30 Dec 2003 19:06:35 -0000
@@ -458,7 +458,7 @@
 	float scale;
 
 	symptom->value += disease->stats.ac;
-	scale = 1.0 + symptom->value/100.0;
+	scale = 1.0f + symptom->value/100.0f;
 	/* now rescale all the debilities */
 	symptom->stats.Str = (int) (scale*disease->stats.Str);
 	symptom->stats.Dex = (int) (scale*disease->stats.Dex);
@@ -521,10 +521,10 @@
     }
 
     if(symptom->stats.dam > 0)  hit_player(victim,symptom->stats.dam,symptom,symptom->attacktype);
-    else hit_player(victim,MAX(1,-victim->stats.maxhp * symptom->stats.dam / 100.0),symptom,symptom->attacktype);
+    else hit_player(victim,( int )MAX(1,-victim->stats.maxhp * symptom->stats.dam / 100.0),symptom,symptom->attacktype);
 
     if(symptom->stats.maxsp>0) sp_reduce = symptom->stats.maxsp;
-    else sp_reduce = MAX(1,victim->stats.maxsp * symptom->stats.maxsp/100.0);
+    else sp_reduce = ( int )MAX(1,( victim->stats.maxsp * symptom->stats.maxsp/100.0 ));
     victim->stats.sp = MAX(0,victim->stats.sp - sp_reduce);
 
     /* create the symptom "other arch" object and drop it here 
Index: server/egoitem.c
===================================================================
RCS file: /cvsroot/crossfire/crossfire/server/egoitem.c,v
retrieving revision 1.4
diff -u -r1.4 egoitem.c
--- server/egoitem.c	14 Oct 2001 07:57:14 -0000	1.4
+++ server/egoitem.c	30 Dec 2003 19:06:35 -0000
@@ -54,7 +54,7 @@
   power_space = crystal->stats.maxsp - crystal->stats.sp;
   power_grab = 0;
   if(available_power>=0 && power_space> 0 )  
-        power_grab = MIN ( power_space, 0.5 * op->stats.sp );
+        power_grab = ( int )MIN ( power_space, 0.5 * op->stats.sp );
   if(available_power < 0 && crystal->stats.sp >0 ) 
         power_grab = - MIN( -available_power, crystal->stats.sp);
 
Index: server/gods.c
===================================================================
RCS file: /cvsroot/crossfire/crossfire/server/gods.c,v
retrieving revision 1.38
diff -u -r1.38 gods.c
--- server/gods.c	10 Nov 2003 05:39:50 -0000	1.38
+++ server/gods.c	30 Dec 2003 19:06:39 -0000
@@ -43,7 +43,8 @@
 #endif
 
 int lookup_god_by_name(char *name) {
-    int godnr=-1,nmlen = strlen(name);
+    int godnr=-1;
+    size_t nmlen = strlen(name);
  
     if(name && strcmp(name,"none")) { 
 	godlink *gl;
@@ -782,9 +783,9 @@
         if (item->type == BOOK && item->invisible
             && strcmp (item->name, "restore spellpoints") == 0)
         {
-            int max = op->stats.maxsp * (item->stats.maxsp / 100.0);
+            int max = ( int )( op->stats.maxsp * (item->stats.maxsp / 100.0) );
             /* Restore to 50 .. 100%, if sp < 50% */
-            int new_sp = random_roll(1000, 1999, op, PREFER_HIGH) / 2000.0 * max;
+            int new_sp = ( int )( random_roll(1000, 1999, op, PREFER_HIGH) / 2000.0 * max );
             if (op->stats.sp >= max / 2)
                 continue;
             new_draw_info (NDI_UNIQUE, 0, op, "A blue lightning strikes "
@@ -930,7 +931,7 @@
 	    if (skop->type == SKILL && skop->subtype == SK_PRAYING) break;
 
 	if (skop)
-	    loss = 0.05 * (float) skop->stats.exp;
+	    loss = ( int )( 0.05 * (float) skop->stats.exp );
 	change_exp(op, -random_roll(0, loss*angry-1, op, PREFER_LOW),
 		   skop?skop->skill:"none", SK_SUBTRACT_SKILL_EXP);
 	if(random_roll(0, angry, op, PREFER_LOW)) {
Index: server/hiscore.c
===================================================================
RCS file: /cvsroot/crossfire/crossfire/server/hiscore.c,v
retrieving revision 1.9
diff -u -r1.9 hiscore.c
--- server/hiscore.c	8 Mar 2003 05:35:32 -0000	1.9
+++ server/hiscore.c	30 Dec 2003 19:06:40 -0000
@@ -314,7 +314,8 @@
 void display_high_score(object *op,int max, char *match) {
     FILE *fp;
     char buf[MAX_BUF],*scorebuf, *bp, *cp;
-    int i=0,j=0,maxchar=80,comp;
+    int i=0,j=0,comp;
+    size_t maxchar=80;
     score *sc;
 
     sprintf(buf,"%s/%s",settings.localdir,HIGHSCORE);
Index: server/init.c
===================================================================
RCS file: /cvsroot/crossfire/crossfire/server/init.c,v
retrieving revision 1.53
diff -u -r1.53 init.c
--- server/init.c	27 Oct 2003 03:44:33 -0000	1.53
+++ server/init.c	30 Dec 2003 19:06:42 -0000
@@ -584,7 +584,7 @@
 		    cp);
 	    }
 	} else if (!strcasecmp(buf, "item_power_factor")) {
-	    float tmp = atof(cp);
+	    float tmp = ( float )atof(cp);
 	    if (tmp < 0)
 		LOG(llevError, "load_settings: item_power_factor must be a postive number (%f < 0)\n",
 		    tmp);
Index: server/monster.c
===================================================================
RCS file: /cvsroot/crossfire/crossfire/server/monster.c,v
retrieving revision 1.67
diff -u -r1.67 monster.c
--- server/monster.c	26 Oct 2003 06:56:57 -0000	1.67
+++ server/monster.c	30 Dec 2003 19:06:46 -0000
@@ -241,7 +241,7 @@
  */
 
 int check_wakeup(object *op, object *enemy, rv_vector *rv) {
-    int radius = op->stats.Wis>MIN_MON_RADIUS?op->stats.Wis:MIN_MON_RADIUS;
+    unsigned int radius = op->stats.Wis>MIN_MON_RADIUS?op->stats.Wis:MIN_MON_RADIUS;
 
     /* Trim work - if no enemy, no need to do anything below */
     if (!enemy) return 0;
Index: server/move.c
===================================================================
RCS file: /cvsroot/crossfire/crossfire/server/move.c,v
retrieving revision 1.29
diff -u -r1.29 move.c
--- server/move.c	4 Sep 2003 06:25:32 -0000	1.29
+++ server/move.c	30 Dec 2003 19:06:47 -0000
@@ -232,8 +232,8 @@
 	if (tele_type == SHOP_MAT && user->type == PLAYER) {
 	    for (k=1; k<9; k++) {
 		if (!(get_map_flags(other_teleporter->map, NULL, 
-			other_teleporter->x + freearr_x[k],
-			other_teleporter->y + freearr_y[k], NULL,NULL) &
+			( sint16 )( other_teleporter->x + freearr_x[k] ),
+			( sint16 )( other_teleporter->y + freearr_y[k] ), NULL,NULL) &
 		      (P_NO_PASS | P_OUT_OF_MAP))) break;
 	    }
 	    if (k==9) {
Index: server/pets.c
===================================================================
RCS file: /cvsroot/crossfire/crossfire/server/pets.c,v
retrieving revision 1.18
diff -u -r1.18 pets.c
--- server/pets.c	13 Sep 2003 05:02:11 -0000	1.18
+++ server/pets.c	30 Dec 2003 19:06:49 -0000
@@ -640,8 +640,8 @@
 	else
 	    tmp->stats.dam= spob->stats.dam +
                     SP_level_dam_adjust(caster,spob);
-	tmp->speed += .02 * SP_level_range_adjust(caster,spob);
-	tmp->speed = MIN(tmp->speed, 1.0);
+	tmp->speed += .02f * SP_level_range_adjust(caster,spob);
+	tmp->speed = MIN(tmp->speed, 1.0f);
 	if (spob->attacktype) tmp->attacktype = spob->attacktype;
     }
     tmp->stats.wc -= SP_level_range_adjust(caster,spob);
-------------- next part --------------
_______________________________________________
crossfire-devel mailing list
     
     crossfire-devel at lists.real-time.com
     
     
     https://mailman.real-time.com/mailman/listinfo/crossfire-devel
     
     
    


More information about the crossfire mailing list