[CF-Devel] CVS update: crossfire/common

Crossfire CVS devel mwedel at scruznet.com
Mon Aug 7 00:16:34 CDT 2000


Date:	Sunday August 6, 2000 @ 22:16
Author:	cvs

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

Modified Files:
	item.c 
Log Message:
The following change basically does the following:  When the server sends an
item name to the client, this item name is now two pieces - the first piece
of the name is its singular form, the second piece is the plural name.  This
now makes items in the inventory appear more proper in terms of pluralization
and just normal English.  I did notice that the server does not know how
to properly make 'torch' plural - it turns it into torchs.  A matching
check in for the client has also been done.
include/newserver.h:  Update VERSION_SC to 1024
common/item.c: Change query_base_name to take a second option on whether
  we should generate a plural version of the name or not.
socket/item.c: Modify functions to use second argument on the query_base_name
  function.  Update item commands to send two part names (singular & plural).
  Modify esrv_send_look to use item1 protocol command instead of item command.
server/c_object.c: Update item_matched_string to use second option to
  query_base_name.  Modify function to check against both singular and
  plural versions of name.
server/shop.c: Modify shop_listing command usage in query_basename to use
  second option.  It will also generate the singular name, but that is only
  used on sorting, so I don't think it will generally cause any problems.
include/libproto.h:  rebuilt because query_base_name has an addition opt.
Mark Wedel 8/13/2000




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

Index: crossfire/common/item.c
diff -u crossfire/common/item.c:1.8 crossfire/common/item.c:1.9
--- crossfire/common/item.c:1.8	Sat May 27 00:08:12 2000
+++ crossfire/common/item.c	Sun Aug  6 22:16:34 2000
@@ -1,6 +1,6 @@
 /*
  * static char *rcsid_item_c =
- *   "$Id: item.c,v 1.8 2000/05/27 07:08:12 cvs Exp $";
+ *   "$Id: item.c,v 1.9 2000/08/07 05:16:34 cvs Exp $";
  */
 
 /*
@@ -207,8 +207,8 @@
 	    if (buf3!=NULL) {
 		strcpy(buf2, buf3);
 		*buf3 = '\0';	/* also changes value in buf */
-		len=strlen(buf);
 	    }
+	    len=strlen(buf);
 	    if(QUERY_FLAG(op,FLAG_NEED_IE)) {
 		char *cp=strrchr(buf,'y');
 
@@ -372,9 +372,12 @@
  * call to query_base_name().   This is a lot like query_name, but we
  * don't include the item count or item status.  Used for inventory sorting
  * and sending to client.
+ * If plural is set, we generate the plural name of this.
  */
-char *query_base_name(object *op) {
+char *query_base_name(object *op, int plural) {
     static char buf[MAX_BUF];
+    char buf2[MAX_BUF];
+    int len;
 
     if(op->name == NULL)
 	return "(null)";
@@ -382,6 +385,42 @@
 	return op->name; /* To speed things up (or make things slower?) */
 
     strcpy(buf,op->name);
+
+    /* This code pretty much taken directly from query_short_name */
+    if (plural) {
+	char *buf3 = strstr(buf, " of ");
+	if (buf3!=NULL) {
+	    strcpy(buf2, buf3);
+	    *buf3 = '\0';   /* also changes value in buf */
+	}
+	len=strlen(buf);
+
+	if(QUERY_FLAG(op,FLAG_NEED_IE)) {
+	    char *cp=strrchr(buf,'y');
+
+	    if(cp!=NULL) {
+		*cp='\0'; /* Strip the 'y' */
+		len--;
+	    }
+	    safe_strcat(buf,"ies", &len, MAX_BUF);
+	} else if (buf[strlen(buf)-1]!='s') 
+	    /* if the item ends in 's', then adding another one is
+	     * not the way to pluralize it.  The only item where this
+	     * matters (that I know of) is bracers, as they start of
+	     * plural
+	     */
+	    safe_strcat(buf,"s", &len, MAX_BUF);
+
+	/* If buf3 is set, then this was a string that contained
+	 * something of something (potion of dexterity.)  The part before
+	 * the of gets made plural, so now we need to copy the rest
+	 * (after and including the " of "), to the buffer string.
+	 */
+	if (buf3)
+	    safe_strcat(buf, buf2, &len, MAX_BUF);
+    }
+
+
     if (op->title && QUERY_FLAG(op,FLAG_IDENTIFIED)) {
 	strcat(buf, " ");
 	strcat(buf, op->title);

    
    


More information about the crossfire mailing list