[CF-Devel] CVS update: crossfire/socket

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/socket
In directory boltzmann.eecs.berkeley.edu:/tmp/cvs-serv6595/socket

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/socket/item.c
diff -u crossfire/socket/item.c:1.4 crossfire/socket/item.c:1.5
--- crossfire/socket/item.c:1.4	Fri May 26 02:50:53 2000
+++ crossfire/socket/item.c	Sun Aug  6 22:16:34 2000
@@ -1,7 +1,7 @@
 
 /*
  * static char *rcsid_item_c =
- *    "$Id: item.c,v 1.4 2000/05/26 09:50:53 jec Exp $";
+ *    "$Id: item.c,v 1.5 2000/08/07 05:16:34 cvs Exp $";
  */
 
 /*
@@ -135,7 +135,7 @@
 void esrv_draw_look(object *pl)
 {
     object *tmp, *last;
-    int flags, got_one=0,len;
+    int flags, got_one=0,len,anim_speed;
     SockList sl;
     char *buf;
 
@@ -156,7 +156,7 @@
     sl.buf=malloc(MAXSOCKBUF);
 
     Write_String_To_Socket(&pl->contr->socket, "delinv 0", strlen("delinv 0"));
-    strcpy((char*)sl.buf,"item ");
+    strcpy((char*)sl.buf,"item1 ");
     sl.len=strlen((char*)sl.buf);
 
     SockList_AddInt(&sl, 0);
@@ -174,13 +174,47 @@
 	    if (!pl->contr->socket.faces_sent[tmp->face->number])
 		esrv_send_face(&pl->contr->socket, tmp->face->number,0);
 
+	    if (QUERY_FLAG(tmp,FLAG_ANIMATE) && 
+			   !pl->contr->socket.anims_sent[tmp->animation_id])
+		esrv_send_animation(&pl->contr->socket, tmp->animation_id);
+
 	    SockList_AddInt(&sl, tmp->count);
 	    SockList_AddInt(&sl, flags);
 	    SockList_AddInt(&sl, QUERY_FLAG(tmp, FLAG_NO_PICK) ? -1 : WEIGHT(tmp));
 	    SockList_AddInt(&sl, tmp->face->number);
-	    add_stringlen_to_sockbuf(query_short_name(tmp), &sl);
-	    got_one++;
+	    if (pl->contr->socket.sc_version>=1024) {
+		int len;
+		char *item_p,item_n[MAX_BUF];
+
+		strncpy(item_n,query_base_name(tmp, 0),127);
+		item_n[127]=0;
+		len=strlen(item_n);
+		item_p=query_base_name(tmp, 1);
+		strncpy(item_n+len+1, item_p, 127);
+		item_n[254]=0;
+		len += strlen(item_p) + 1;
+		SockList_AddChar(&sl, len);
+		memcpy(sl.buf+sl.len, item_n, len);
+		sl.len += len;
+	    } else
+		add_stringlen_to_sockbuf(query_base_name(tmp,0), &sl);
+
+	    SockList_AddShort(&sl,tmp->animation_id);
+	    anim_speed=0;
+	    if (QUERY_FLAG(tmp,FLAG_ANIMATE)) {
+		if (tmp->anim_speed) anim_speed=tmp->anim_speed;
+		else {
+		    if (FABS(tmp->speed)<0.001) anim_speed=255;
+		    else if (FABS(tmp->speed)>=1.0) anim_speed=1;
+		    else anim_speed = (1.0/FABS(tmp->speed));
+		}
+		if (anim_speed>255) anim_speed=255;
+	    }
+	    SockList_AddChar(&sl, anim_speed);
+	    SockList_AddInt(&sl, tmp->nrof);
 	    SET_FLAG(tmp, FLAG_CLIENT_SENT);
+	    got_one++;
+
 	    if (sl.len > (MAXSOCKBUF-MAXITEMLEN)) {
 		Send_With_Handling(&pl->contr->socket, &sl);
 		strcpy((char*)sl.buf,"item ");
@@ -201,7 +235,7 @@
     object *tmp;
     int flags, got_one=0, anim_speed,len;
     SockList sl;
-    char *buf;
+    char *buf, item_n[MAX_BUF];
     
     sl.buf=malloc(MAXSOCKBUF);
 
@@ -229,7 +263,22 @@
 	    SockList_AddInt(&sl, QUERY_FLAG(tmp, FLAG_NO_PICK) ? -1 : WEIGHT(tmp));
 	    SockList_AddInt(&sl, tmp->face->number);
 
-	    add_stringlen_to_sockbuf(query_base_name(tmp), &sl);
+	    if (pl->contr->socket.sc_version>=1024) {
+		int len;
+		char *item_p;
+
+		strncpy(item_n,query_base_name(tmp, 0),127);
+		item_n[127]=0;
+		len=strlen(item_n);
+		item_p=query_base_name(tmp, 1);
+		strncpy(item_n+len+1, item_p, 127);
+		item_n[254]=0;
+		len += strlen(item_p) + 1;
+		SockList_AddChar(&sl, len);
+		memcpy(sl.buf+sl.len, item_n, len);
+		sl.len += len;
+	    } else
+		add_stringlen_to_sockbuf(query_base_name(tmp,0), &sl);
 
 	    SockList_AddShort(&sl,tmp->animation_id);
 	    anim_speed=0;
@@ -314,8 +363,22 @@
 	SockList_AddInt(&sl, op->face->number);
     }
     if (flags & UPD_NAME) {
-	add_stringlen_to_sockbuf(query_short_name(op), &sl);
-
+	if (pl->contr->socket.sc_version>=1024) {
+	    int len;
+	    char *item_p, item_n[MAX_BUF];
+
+	    strncpy(item_n,query_base_name(op, 0),127);
+	    item_n[127]=0;
+	    len=strlen(item_n);
+	    item_p=query_base_name(op, 1);
+	    strncpy(item_n+len+1, item_p, 127);
+	    item_n[254]=0;
+	    len += strlen(item_p) + 1;
+	    SockList_AddChar(&sl, len);
+	    memcpy(sl.buf+sl.len, item_n, len);
+	    sl.len += len;
+	} else
+	    add_stringlen_to_sockbuf(query_base_name(op,0), &sl);
     }
     if (flags & UPD_ANIM) 
 	    SockList_AddShort(&sl,op->animation_id);
@@ -344,7 +407,7 @@
 {
     int anim_speed,len;
     SockList sl;
-    char *buf;
+    char *buf, item_n[MAX_BUF];
     
     /* If this is not the player object, do some more checks */
     if (op!=pl) {
@@ -377,7 +440,23 @@
     SockList_AddInt(&sl, query_flags(op));
     SockList_AddInt(&sl, WEIGHT(op));
     SockList_AddInt(&sl, op->face->number);
-    add_stringlen_to_sockbuf(query_base_name(op), &sl);
+
+    if (pl->contr->socket.sc_version>=1024) {
+	int len;
+	char *item_p;
+
+	strncpy(item_n,query_base_name(op, 0),127);
+	item_n[127]=0;
+	len=strlen(item_n);
+	item_p=query_base_name(op, 1);
+	strncpy(item_n+len+1, item_p, 127);
+	item_n[254]=0;
+	len += strlen(item_p) + 1;
+	SockList_AddChar(&sl, len);
+	memcpy(sl.buf+sl.len, item_n, len);
+	sl.len += len;
+    } else
+	add_stringlen_to_sockbuf(query_base_name(op,0), &sl);
 
     SockList_AddShort(&sl,op->animation_id);
     anim_speed=0;

    
    


More information about the crossfire mailing list