Difference for socket/request.c from version 1.85 to 1.86


version 1.85 version 1.86
Line 1
 
Line 1
 /*  /*
  * static char *rcsid_init_c =   * static char *rcsid_init_c =
  *    "$Id: request.c,v 1.85 2006/02/20 23:35:31 cavesomething Exp $";   *    "$Id: request.c,v 1.86 2006/03/14 07:41:49 mwedel Exp $";
  */   */
   
 /*  /*
Line 109
 
Line 109
 /** This is the Setup cmd - easy first implementation */  /** This is the Setup cmd - easy first implementation */
 void SetUp(char *buf, int len, NewSocket *ns)  void SetUp(char *buf, int len, NewSocket *ns)
 {  {
     int s;      int s, slen;
     char *cmd, *param, cmdback[HUGE_BUF];      char *cmd, *param, cmdback[HUGE_BUF];
   
     /* run through the cmds of setup      /* run through the cmds of setup
Line 139
 
Line 139
  buf[s++]=0;   buf[s++]=0;
  while (buf[s] == ' ') s++;   while (buf[s] == ' ') s++;
    
  strcat(cmdback, " ");   slen = strlen(cmdback);
  strcat(cmdback, cmd);   safe_strcat(cmdback, " ", &slen, HUGE_BUF);
  strcat(cmdback, " ");   safe_strcat(cmdback, cmd, &slen, HUGE_BUF);
    safe_strcat(cmdback, " ", &slen, HUGE_BUF);
    
  if (!strcmp(cmd,"sound")) {   if (!strcmp(cmd,"sound")) {
      ns->sound = atoi(param);       ns->sound = atoi(param);
      strcat(cmdback, param);       safe_strcat(cmdback, param, &slen, HUGE_BUF);
  }   }
  else if (!strcmp(cmd,"exp64")) {   else if (!strcmp(cmd,"exp64")) {
      ns->exp64 = atoi(param);       ns->exp64 = atoi(param);
      strcat(cmdback, param);       safe_strcat(cmdback, param, &slen, HUGE_BUF);
  } else if (!strcmp(cmd, "spellmon")) {   } else if (!strcmp(cmd, "spellmon")) {
      ns->monitor_spells = atoi(param);       ns->monitor_spells = atoi(param);
      strcat(cmdback, param);       safe_strcat(cmdback, param, &slen, HUGE_BUF);
  }  else if (!strcmp(cmd,"darkness")) {   }  else if (!strcmp(cmd,"darkness")) {
      ns->darkness = atoi(param);       ns->darkness = atoi(param);
      strcat(cmdback, param);       safe_strcat(cmdback, param, &slen, HUGE_BUF);
  } else if (!strcmp(cmd,"map1cmd")) {   } else if (!strcmp(cmd,"map1cmd")) {
      if (atoi(param)) ns->mapmode = Map1Cmd;       if (atoi(param)) ns->mapmode = Map1Cmd;
      /* if beyond this size, need to use map1cmd no matter what */       /* if beyond this size, need to use map1cmd no matter what */
      if (ns->mapx>11 || ns->mapy>11) ns->mapmode = Map1Cmd;       if (ns->mapx>11 || ns->mapy>11) ns->mapmode = Map1Cmd;
      strcat(cmdback, ns->mapmode == Map1Cmd?"1":"0");       safe_strcat(cmdback, ns->mapmode == Map1Cmd?"1":"0", &slen, HUGE_BUF);
  } else if (!strcmp(cmd,"map1acmd")) {   } else if (!strcmp(cmd,"map1acmd")) {
      if (atoi(param)) ns->mapmode = Map1aCmd;       if (atoi(param)) ns->mapmode = Map1aCmd;
      /* if beyond this size, need to use map1acmd no matter what */       /* if beyond this size, need to use map1acmd no matter what */
      if (ns->mapx>11 || ns->mapy>11) ns->mapmode = Map1aCmd;       if (ns->mapx>11 || ns->mapy>11) ns->mapmode = Map1aCmd;
      strcat(cmdback, ns->mapmode == Map1aCmd?"1":"0");       safe_strcat(cmdback, ns->mapmode == Map1aCmd?"1":"0", &slen, HUGE_BUF);
         } else if (!strcmp(cmd,"newmapcmd")) {          } else if (!strcmp(cmd,"newmapcmd")) {
             ns->newmapcmd= atoi(param);              ns->newmapcmd= atoi(param);
             strcat(cmdback, param);       safe_strcat(cmdback, param, &slen, HUGE_BUF);
  } else if (!strcmp(cmd,"facecache")) {   } else if (!strcmp(cmd,"facecache")) {
      ns->facecache = atoi(param);       ns->facecache = atoi(param);
             strcat(cmdback, param);       safe_strcat(cmdback, param, &slen, HUGE_BUF);
  } else if (!strcmp(cmd,"faceset")) {   } else if (!strcmp(cmd,"faceset")) {
      char tmpbuf[20];       char tmpbuf[20];
      int q = atoi(param);       int q = atoi(param);
Line 180
 
Line 180
      if (is_valid_faceset(q))       if (is_valid_faceset(q))
  ns->faceset=q;   ns->faceset=q;
      sprintf(tmpbuf,"%d", ns->faceset);       sprintf(tmpbuf,"%d", ns->faceset);
      strcat(cmdback, tmpbuf);       safe_strcat(cmdback, tmpbuf, &slen, HUGE_BUF);
      /* if the client is using faceset, it knows about image2 command */       /* if the client is using faceset, it knows about image2 command */
      ns->image2=1;       ns->image2=1;
  } else if (!strcmp(cmd,"itemcmd")) {   } else if (!strcmp(cmd,"itemcmd")) {
Line 196
 
Line 196
  ns->itemcmd = q;   ns->itemcmd = q;
  sprintf(tmpbuf,"%d", ns->itemcmd);   sprintf(tmpbuf,"%d", ns->itemcmd);
      }       }
      strcat(cmdback, tmpbuf);       safe_strcat(cmdback, tmpbuf, &slen, HUGE_BUF);
         } else if (!strcmp(cmd,"mapsize")) {          } else if (!strcmp(cmd,"mapsize")) {
      int x, y=0;       int x, y=0;
      char tmpbuf[MAX_BUF], *cp;       char tmpbuf[MAX_BUF], *cp;
Line 209
 
Line 209
  }   }
      if (x < 9 || y < 9 || x>MAP_CLIENT_X || y > MAP_CLIENT_Y) {       if (x < 9 || y < 9 || x>MAP_CLIENT_X || y > MAP_CLIENT_Y) {
  sprintf(tmpbuf," %dx%d", MAP_CLIENT_X, MAP_CLIENT_Y);   sprintf(tmpbuf," %dx%d", MAP_CLIENT_X, MAP_CLIENT_Y);
  strcat(cmdback, tmpbuf);   safe_strcat(cmdback, tmpbuf, &slen, HUGE_BUF);
      } else {       } else {
  ns->mapx = x;   ns->mapx = x;
  ns->mapy = y;   ns->mapy = y;
Line 217
 
Line 217
  * param as given to us in case it gets parsed differently.   * param as given to us in case it gets parsed differently.
  */   */
  sprintf(tmpbuf,"%dx%d", x,y);   sprintf(tmpbuf,"%dx%d", x,y);
  strcat(cmdback, tmpbuf);   safe_strcat(cmdback, tmpbuf, &slen, HUGE_BUF);
  /* If beyond this size and still using orig map command, need to   /* If beyond this size and still using orig map command, need to
  * go to map1cmd.   * go to map1cmd.
  */   */
Line 230
 
Line 230
      char tmpbuf[20];       char tmpbuf[20];
         ns->ext_mapinfos = (atoi(param));          ns->ext_mapinfos = (atoi(param));
      sprintf(tmpbuf,"%d", ns->ext_mapinfos);       sprintf(tmpbuf,"%d", ns->ext_mapinfos);
      strcat(cmdback, tmpbuf);       safe_strcat(cmdback, tmpbuf, &slen, HUGE_BUF);
  } else if (!strcmp(cmd,"extendedTextInfos")) {   } else if (!strcmp(cmd,"extendedTextInfos")) {
         /* Added by tchize          /* Added by tchize
          * prepare to use the extended text commands           * prepare to use the extended text commands
          * Client toggle this to non zero to get exttext           * Client toggle this to non zero to get exttext
          */           */
      char tmpbuf[20];       char tmpbuf[20];
   
         ns->has_readable_type = (atoi(param));          ns->has_readable_type = (atoi(param));
      sprintf(tmpbuf,"%d", ns->has_readable_type);       sprintf(tmpbuf,"%d", ns->has_readable_type);
      strcat(cmdback, tmpbuf);       safe_strcat(cmdback, tmpbuf, &slen, HUGE_BUF);
  } else {   } else {
      /* Didn't get a setup command we understood -       /* Didn't get a setup command we understood -
       * report a failure to the client.        * report a failure to the client.
       */        */
      strcat(cmdback, "FALSE");       safe_strcat(cmdback, "FALSE", &slen, HUGE_BUF);
  }   }
     } /* for processing all the setup commands */      } /* for processing all the setup commands */
     LOG(llevInfo,"SendBack SetupCmd:: %s\n", cmdback);      LOG(llevInfo,"SendBack SetupCmd:: %s\n", cmdback);
Line 619
 
Line 620
     }      }
     cp = strchr(cp+1, ' ');      cp = strchr(cp+1, ' ');
     if (cp) {      if (cp) {
  LOG(llevDebug,"CS: connection from client of type <%s>\n", cp);   LOG(llevDebug,"CS: connection from client of type <%s>, ip %s\n", cp, ns->host);
   
  /* This is first implementation - i skip all beta DX clients with it    /* This is first implementation - i skip all beta DX clients with it
  * Add later stuff here for other clients    * Add later stuff here for other clients
Line 1925
 
Line 1926
     int i;      int i;
   
     sl.buf = malloc(MAXSOCKBUF);      sl.buf = malloc(MAXSOCKBUF);
     strcpy(sl.buf,"replyinfo skill_info\n");      strcpy((char*)sl.buf,"replyinfo skill_info\n");
     for (i=1; i< NUM_SKILLS; i++) {      for (i=1; i< NUM_SKILLS; i++) {
  sprintf(sl.buf + strlen(sl.buf), "%d:%s\n", i + CS_STAT_SKILLINFO,   sprintf((char*)sl.buf + strlen((char*)sl.buf), "%d:%s\n", i + CS_STAT_SKILLINFO,
  skill_names[i]);   skill_names[i]);
     }      }
     sl.len = strlen(sl.buf);      sl.len = strlen((char*)sl.buf);
     if (sl.len > MAXSOCKBUF) {      if (sl.len > MAXSOCKBUF) {
  LOG(llevError,"Buffer overflow in send_skill_info!\n");   LOG(llevError,"Buffer overflow in send_skill_info!\n");
  fatal(0);   fatal(0);
Line 1948
 
Line 1949
     int i;      int i;
   
     sl.buf = malloc(MAXSOCKBUF);      sl.buf = malloc(MAXSOCKBUF);
     strcpy(sl.buf,"replyinfo spell_paths\n");      strcpy((char*)sl.buf,"replyinfo spell_paths\n");
     for(i=0; i<NRSPELLPATHS; i++)      for(i=0; i<NRSPELLPATHS; i++)
  sprintf(sl.buf + strlen(sl.buf), "%d:%s\n", 1<<i, spellpathnames[i]);   sprintf((char*)sl.buf + strlen((char*)sl.buf), "%d:%s\n", 1<<i, spellpathnames[i]);
     sl.len = strlen(sl.buf);      sl.len = strlen((char*)sl.buf);
     if (sl.len > MAXSOCKBUF) {      if (sl.len > MAXSOCKBUF) {
  LOG(llevError,"Buffer overflow in send_spell_paths!\n");   LOG(llevError,"Buffer overflow in send_spell_paths!\n");
  fatal(0);   fatal(0);
Line 1986
 
Line 1987
      }       }
      if (flags !=0) {       if (flags !=0) {
  sl.buf = malloc(MAXSOCKBUF);   sl.buf = malloc(MAXSOCKBUF);
  strcpy(sl.buf,"updspell ");   strcpy((char*)sl.buf,"updspell ");
  sl.len=strlen((char*)sl.buf);   sl.len=strlen((char*)sl.buf);
  SockList_AddChar(&sl, flags);   SockList_AddChar(&sl, flags);
  SockList_AddInt(&sl, spell->count);   SockList_AddInt(&sl, spell->count);
Line 2010
 
Line 2011
  return;   return;
     }      }
     sl.buf = malloc(MAXSOCKBUF);      sl.buf = malloc(MAXSOCKBUF);
     strcpy(sl.buf,"delspell ");      strcpy((char*)sl.buf,"delspell ");
     sl.len=strlen((char*)sl.buf);      sl.len=strlen((char*)sl.buf);
     SockList_AddInt(&sl, spell->count);      SockList_AddInt(&sl, spell->count);
     Send_With_Handling(&pl->socket, &sl);      Send_With_Handling(&pl->socket, &sl);
Line 2078
 
Line 2079
     }      }
     if (!pl->socket.monitor_spells) return;      if (!pl->socket.monitor_spells) return;
     sl.buf = malloc(MAXSOCKBUF);      sl.buf = malloc(MAXSOCKBUF);
     strcpy(sl.buf,"addspell ");      strcpy((char*)sl.buf,"addspell ");
     sl.len=strlen((char*)sl.buf);      sl.len=strlen((char*)sl.buf);
     if (!spell) {      if (!spell) {
  for (spell=pl->ob->inv; spell!=NULL; spell=spell->below) {   for (spell=pl->ob->inv; spell!=NULL; spell=spell->below) {
Line 2099
 
Line 2100
      if (sl.len > (MAXSOCKBUF - (26 + strlen(spell->name) +        if (sl.len > (MAXSOCKBUF - (26 + strlen(spell->name) +
  (spell->msg?strlen(spell->msg):0)))) {   (spell->msg?strlen(spell->msg):0)))) {
  Send_With_Handling(&pl->socket, &sl);   Send_With_Handling(&pl->socket, &sl);
  strcpy(sl.buf,"addspell ");   strcpy((char*)sl.buf,"addspell ");
  sl.len=strlen((char*)sl.buf);   sl.len=strlen((char*)sl.buf);
      }       }
      append_spell(pl, &sl, spell);       append_spell(pl, &sl, spell);


Legend:
line(s) removed in v.1.85 
line(s) changed
 line(s) added in v.1.86

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