Difference for socket/item.c from version 1.22 to 1.23


version 1.22 version 1.23
Line 1
 
Line 1
   
 /*  /*
  * static char *rcsid_item_c =   * static char *rcsid_item_c =
  *    "$Id: item.c,v 1.22 2002/04/19 05:28:13 mwedel Exp $";   *    "$Id: item.c,v 1.23 2002/05/31 04:18:39 mwedel Exp $";
  */   */
   
 /*  /*
Line 135
 
Line 135
 void esrv_draw_look(object *pl)  void esrv_draw_look(object *pl)
 {  {
     object *tmp, *last;      object *tmp, *last;
     int flags, got_one=0,anim_speed, start_look=0, end_look=0;      int flags, got_one=0,anim_speed, start_look=0, end_look=0, len;
     SockList sl;      SockList sl;
     char buf[MAX_BUF];      char buf[MAX_BUF], *item_p,item_n[MAX_BUF];
   
     if (!pl->contr->socket.update_look) {      if (!pl->contr->socket.update_look) {
  LOG(llevDebug,"esrv_draw_look called when update_look was not set\n");   LOG(llevDebug,"esrv_draw_look called when update_look was not set\n");
Line 156
 
Line 156
     sl.buf=malloc(MAXSOCKBUF);      sl.buf=malloc(MAXSOCKBUF);
   
     Write_String_To_Socket(&pl->contr->socket, "delinv 0", strlen("delinv 0"));      Write_String_To_Socket(&pl->contr->socket, "delinv 0", strlen("delinv 0"));
     strcpy((char*)sl.buf,"item1 ");      sprintf((char*)sl.buf,"item%d ", pl->contr->socket.itemcmd);
     sl.len=strlen((char*)sl.buf);      sl.len=strlen((char*)sl.buf);
   
     SockList_AddInt(&sl, 0);      SockList_AddInt(&sl, 0);
Line 212
 
Line 212
      SockList_AddInt(&sl, flags);       SockList_AddInt(&sl, flags);
      SockList_AddInt(&sl, QUERY_FLAG(tmp, FLAG_NO_PICK) ? -1 : WEIGHT(tmp));       SockList_AddInt(&sl, QUERY_FLAG(tmp, FLAG_NO_PICK) ? -1 : WEIGHT(tmp));
      SockList_AddInt(&sl, tmp->face->number);       SockList_AddInt(&sl, tmp->face->number);
         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);   strncpy(item_n,query_base_name(tmp, 0),127);
  item_n[127]=0;   item_n[127]=0;
Line 226
 
Line 223
  SockList_AddChar(&sl, (char ) len);   SockList_AddChar(&sl, (char ) len);
  memcpy(sl.buf+sl.len, item_n, len);   memcpy(sl.buf+sl.len, item_n, len);
  sl.len += len;   sl.len += len;
      } else  
  add_stringlen_to_sockbuf(query_base_name(tmp,0), &sl);  
   
      SockList_AddShort(&sl,tmp->animation_id);       SockList_AddShort(&sl,tmp->animation_id);
      anim_speed=0;       anim_speed=0;
Line 242
 
Line 237
      }       }
      SockList_AddChar(&sl, (char) anim_speed);       SockList_AddChar(&sl, (char) anim_speed);
      SockList_AddInt(&sl, tmp->nrof);       SockList_AddInt(&sl, tmp->nrof);
   
        if (pl->contr->socket.itemcmd == 2)
    SockList_AddShort(&sl, tmp->client_type);
   
      SET_FLAG(tmp, FLAG_CLIENT_SENT);       SET_FLAG(tmp, FLAG_CLIENT_SENT);
      got_one++;       got_one++;
   
      if (sl.len > (MAXSOCKBUF-MAXITEMLEN)) {       if (sl.len > (MAXSOCKBUF-MAXITEMLEN)) {
  Send_With_Handling(&pl->contr->socket, &sl);   Send_With_Handling(&pl->contr->socket, &sl);
  strcpy((char*)sl.buf,"item1 ");   sprintf((char*)sl.buf,"item%d ", pl->contr->socket.itemcmd);
  sl.len=strlen((char*)sl.buf);   sl.len=strlen((char*)sl.buf);
  SockList_AddInt(&sl, 0);   SockList_AddInt(&sl, 0);
  got_one=0;   got_one=0;
Line 263
 
Line 262
 void esrv_send_inventory(object *pl, object *op)  void esrv_send_inventory(object *pl, object *op)
 {  {
     object *tmp;      object *tmp;
     int flags, got_one=0, anim_speed;      int flags, got_one=0, anim_speed, len;
     SockList sl;      SockList sl;
     char item_n[MAX_BUF];      char item_n[MAX_BUF], *item_p;
          
     sl.buf=malloc(MAXSOCKBUF);      sl.buf=malloc(MAXSOCKBUF);
   
Line 273
 
Line 272
     sl.len=strlen((char*)sl.buf);      sl.len=strlen((char*)sl.buf);
     Send_With_Handling(&pl->contr->socket, &sl);      Send_With_Handling(&pl->contr->socket, &sl);
   
     strcpy((char*)sl.buf,"item1 ");      sprintf((char*)sl.buf,"item%d ", pl->contr->socket.itemcmd);
     sl.len=strlen((char*)sl.buf);      sl.len=strlen((char*)sl.buf);
   
     SockList_AddInt(&sl, op->count);      SockList_AddInt(&sl, op->count);
Line 293
 
Line 292
      SockList_AddInt(&sl, QUERY_FLAG(tmp, FLAG_NO_PICK) ? -1 : WEIGHT(tmp));       SockList_AddInt(&sl, QUERY_FLAG(tmp, FLAG_NO_PICK) ? -1 : WEIGHT(tmp));
      SockList_AddInt(&sl, tmp->face->number);       SockList_AddInt(&sl, tmp->face->number);
                  
      if (pl->contr->socket.sc_version>=1024) {  
  int len;  
  char *item_p;  
   
  strncpy(item_n,query_base_name(tmp, 0),127);   strncpy(item_n,query_base_name(tmp, 0),127);
  item_n[127]=0;   item_n[127]=0;
  len=strlen(item_n);   len=strlen(item_n);
Line 307
 
Line 302
  SockList_AddChar(&sl, (char) len);   SockList_AddChar(&sl, (char) len);
  memcpy(sl.buf+sl.len, item_n, len);   memcpy(sl.buf+sl.len, item_n, len);
  sl.len += len;   sl.len += len;
      } else  
  add_stringlen_to_sockbuf(query_base_name(tmp,0), &sl);  
   
      SockList_AddShort(&sl,tmp->animation_id);       SockList_AddShort(&sl,tmp->animation_id);
      anim_speed=0;       anim_speed=0;
Line 323
 
Line 316
      }       }
      SockList_AddChar(&sl, (char)anim_speed);       SockList_AddChar(&sl, (char)anim_speed);
      SockList_AddInt(&sl, tmp->nrof);       SockList_AddInt(&sl, tmp->nrof);
        if (pl->contr->socket.itemcmd == 2)
    SockList_AddShort(&sl, tmp->client_type);
      SET_FLAG(tmp, FLAG_CLIENT_SENT);       SET_FLAG(tmp, FLAG_CLIENT_SENT);
      got_one++;       got_one++;
   
      /* IT is possible for players to accumulate a huge amount of       /* IT is possible for players to accumulate a huge amount of
       * items (especially with some of the bags out there) to        * items (especially with some of the bags out there) to
       * overflow the buffer.  IF so, send multiple item1 commands.        * overflow the buffer.  IF so, send multiple item commands.
       */        */
      if (sl.len > (MAXSOCKBUF-MAXITEMLEN)) {       if (sl.len > (MAXSOCKBUF-MAXITEMLEN)) {
  Send_With_Handling(&pl->contr->socket, &sl);   Send_With_Handling(&pl->contr->socket, &sl);
  strcpy((char*)sl.buf,"item1 ");   sprintf((char*)sl.buf,"item%d ", pl->contr->socket.itemcmd);
  sl.len=strlen((char*)sl.buf);   sl.len=strlen((char*)sl.buf);
  SockList_AddInt(&sl, op->count);   SockList_AddInt(&sl, op->count);
  got_one=0;   got_one=0;
Line 392
 
Line 387
  SockList_AddInt(&sl, op->face->number);   SockList_AddInt(&sl, op->face->number);
     }      }
     if (flags & UPD_NAME) {      if (flags & UPD_NAME) {
  if (pl->contr->socket.sc_version>=1024) {  
      int len;       int len;
      char *item_p, item_n[MAX_BUF];       char *item_p, item_n[MAX_BUF];
   
Line 406
 
Line 400
      SockList_AddChar(&sl, (char)len);       SockList_AddChar(&sl, (char)len);
      memcpy(sl.buf+sl.len, item_n, len);       memcpy(sl.buf+sl.len, item_n, len);
      sl.len += len;       sl.len += len;
  } else  
      add_stringlen_to_sockbuf(query_base_name(op,0), &sl);  
     }      }
     if (flags & UPD_ANIM)       if (flags & UPD_ANIM)
      SockList_AddShort(&sl,op->animation_id);       SockList_AddShort(&sl,op->animation_id);
Line 434
 
Line 426
   
 void esrv_send_item(object *pl, object*op)  void esrv_send_item(object *pl, object*op)
 {  {
     int anim_speed;      int anim_speed, len;
     SockList sl;      SockList sl;
     char item_n[MAX_BUF];      char item_n[MAX_BUF], *item_p;
          
     /* If this is not the player object, do some more checks */      /* If this is not the player object, do some more checks */
     if (op!=pl) {      if (op!=pl) {
Line 454
 
Line 446
   
     sl.buf=malloc(MAXSOCKBUF);      sl.buf=malloc(MAXSOCKBUF);
   
     strcpy((char*)sl.buf,"item1 ");      sprintf((char*)sl.buf,"item%d ", pl->contr->socket.itemcmd);
     sl.len=strlen((char*)sl.buf);      sl.len=strlen((char*)sl.buf);
   
     SockList_AddInt(&sl, op->env? op->env->count:0);      SockList_AddInt(&sl, op->env? op->env->count:0);
Line 470
 
Line 462
     SockList_AddInt(&sl, WEIGHT(op));      SockList_AddInt(&sl, WEIGHT(op));
     SockList_AddInt(&sl, op->face->number);      SockList_AddInt(&sl, op->face->number);
          
     if (pl->contr->socket.sc_version>=1024) {  
  int len;  
  char *item_p;  
   
  strncpy(item_n,query_base_name(op, 0),127);   strncpy(item_n,query_base_name(op, 0),127);
  item_n[127]=0;   item_n[127]=0;
  len=strlen(item_n);   len=strlen(item_n);
Line 484
 
Line 472
  SockList_AddChar(&sl, (char)len);   SockList_AddChar(&sl, (char)len);
  memcpy(sl.buf+sl.len, item_n, len);   memcpy(sl.buf+sl.len, item_n, len);
  sl.len += len;   sl.len += len;
     } else  
  add_stringlen_to_sockbuf(query_base_name(op,0), &sl);  
   
     SockList_AddShort(&sl,op->animation_id);      SockList_AddShort(&sl,op->animation_id);
     anim_speed=0;      anim_speed=0;
Line 500
 
Line 486
     }      }
     SockList_AddChar(&sl, (char)anim_speed);      SockList_AddChar(&sl, (char)anim_speed);
     SockList_AddInt(&sl, op->nrof);      SockList_AddInt(&sl, op->nrof);
       if (pl->contr->socket.itemcmd == 2)
    SockList_AddShort(&sl, op->client_type);
   
     Send_With_Handling(&pl->contr->socket, &sl);      Send_With_Handling(&pl->contr->socket, &sl);
     SET_FLAG(op, FLAG_CLIENT_SENT);      SET_FLAG(op, FLAG_CLIENT_SENT);
     free(sl.buf);      free(sl.buf);


Legend:
line(s) removed in v.1.22 
line(s) changed
 line(s) added in v.1.23

File made using version 1.98 of cvs2html by leaf at 2011-07-21 19:35