Crossfire Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

skill identification name bug & fix



I have identified a bug (patch attached) in the server code that causes skill
identifications to make the client display incorrectly (ie: "a a orc chop" or
"two two swords").

The cause is that esrv_update_item, when used to update an item's name, calls
query_short_name(), which tags nrof before the name.  I believe the clients
are never expecting nrof to already be in the name, and so the client
displays incorrectly.

I switched the offending esrv_update_item() with an esrv_send_item() call. 
This sort of skirts the issue, as I'm not totally sure what the correct
behavior of esrv_update_item() is supposed to be.

I also cleaned up a redundant call to esrv_send_item() that will be
causing unnecessary traffic.

        Kurt.

diff -u5r ../server-clean/server/skills.c server/skills.c
--- ../server-clean/server/skills.c	Mon Jul 12 23:42:16 1999
+++ server/skills.c	Sat Jan 29 20:02:20 2000
@@ -611,11 +611,11 @@
     return success;
 }
 
 /* Helper function for do_skill_ident, so that we can loop
 over inventory AND objects on the ground conveniently.  */
-int do_skill_ident2(object *tmp,object *pl, int obj_class) 
+int do_skill_ident2(object *tmp,object *pl, int obj_class, int needsend) 
 {
    int success=0,chance;
   int skill_value = SK_level(pl) + get_weighted_skill_stats(pl);
 
 	if(!QUERY_FLAG(tmp,FLAG_IDENTIFIED) && !QUERY_FLAG(tmp,FLAG_NO_SKILL_IDENT) 
@@ -630,11 +630,14 @@
                       "You identify %s.", long_desc(tmp));
         	    if (tmp->msg) {
           		new_draw_info(NDI_UNIQUE, 0,pl, "The item has a story:");
           		new_draw_info(NDI_UNIQUE, 0,pl, tmp->msg);
         	    }
-		    esrv_update_item(UPD_NAME, pl, tmp);
+		    /* we only need to send the item if identify() didn't. */
+		    if (needsend) {
+			esrv_send_item(pl, tmp);
+		    }
 		  }
 	          success += calc_skill_exp(pl,tmp);
         	} else 
 		  SET_FLAG(tmp, FLAG_NO_SKILL_IDENT);
         }
@@ -647,14 +650,14 @@
 int do_skill_ident(object *pl, int obj_class) {
   object *tmp;
   int success=0; 
 /* check the player inventory */
     for(tmp=pl->inv;tmp;tmp=tmp->below)
-		success+=do_skill_ident2(tmp,pl,obj_class);
+		success+=do_skill_ident2(tmp,pl,obj_class,0);
 	 /*  check the ground */
 	 for(tmp=get_map_ob(pl->map,pl->x,pl->y);tmp;tmp=tmp->above)
-		success+=do_skill_ident2(tmp,pl,obj_class);
+		success+=do_skill_ident2(tmp,pl,obj_class,1);
 		  
     return success;
 }  
 
 /* players using this skill can 'charm' a monster --
diff -u5r ../server-clean/server/spell_effect.c server/spell_effect.c
--- ../server-clean/server/spell_effect.c	Mon Jul 12 23:42:16 1999
+++ server/spell_effect.c	Sat Jan 29 19:03:00 2000
@@ -1931,11 +1931,14 @@
 		"You have %s.", long_desc(tmp));
 	if (tmp->msg) {
 	  new_draw_info(NDI_UNIQUE, 0,op, "The item has a story:");
 	  new_draw_info(NDI_UNIQUE, 0,op, tmp->msg);
 	}
-	esrv_send_item(op, tmp);
+	/* Why is the following line here?  identify() in item.c
+	   calls esrv_send_item_func() if the item is in someone's
+	   inventory - kf 29 Jan 2000
+	esrv_send_item(op, tmp);   */
       }
 
       if ((random_val=RANDOM()%chance) > (chance - ++success - 2))
         break;
     }
@@ -1954,10 +1957,12 @@
 		"On the ground is %s.", long_desc(tmp));
 	if (tmp->msg) {
 	  new_draw_info(NDI_UNIQUE, 0,op, "The item has a story:");
 	  new_draw_info(NDI_UNIQUE, 0,op, tmp->msg);
 	}
+	/* We need to send the item to the client, because identify()
+	   only sends it if the item is in someone's inventory */
 	esrv_send_item(op, tmp);
       }
       if (RANDOM() %chance > (chance - ++success - 2))
 	break;
     }
diff -u5r ../server-clean/include/sproto.h include/sproto.h
--- ../server-clean/include/sproto.h	Mon Jul 12 23:42:16 1999
+++ include/sproto.h	Sat Jan 29 20:00:15 2000
@@ -443,11 +443,11 @@
 extern int attempt_hide ( object *op );
 extern int jump ( object *pl, int dir );
 extern int skill_ident ( object *pl );
 extern int do_skill_detect_curse ( object *pl );
 extern int do_skill_detect_magic ( object *pl );
-extern int do_skill_ident2 ( object *tmp, object *pl, int obj_class );
+extern int do_skill_ident2 ( object *tmp, object *pl, int obj_class, int needse
nd );
 extern int do_skill_ident ( object *pl, int obj_class );
 extern int use_oratory ( object *pl, int dir );
 extern int singing ( object *pl, int dir );
 extern int find_traps ( object *pl );
 extern int pray ( object *pl );