Difference for socket/request.c from version 1.11 to 1.12


version 1.11 version 1.12
Line 1
 
Line 1
 /*  /*
  * static char *rcsid_init_c =   * static char *rcsid_init_c =
  *    "$Id: request.c,v 1.11 2001/04/09 06:59:46 mwedel Exp $";   *    "$Id: request.c,v 1.12 2001/05/29 04:41:54 mwedel Exp $";
  */   */
   
 /*  /*
Line 79
 
Line 79
   
 #include "sounds.h"  #include "sounds.h"
   
 /* Tis is the table and cmd IDs for the setup cmd.   
  * Add new commands here and include the 'case SETUP_xxx'   
  * to the switch cmd in the SetUp function   
  */   
    
 typedef struct _setup_map {   
   char *cmdname;   
   int cmdnr;   
 }_setup_map;   
    
 enum {   
  SETUP_SOUND, /* Parameter: 1= sound cmd will send, 0= no sound cmds */   
  SETUP_SKILLEXP, /* Default=0 :: 1= send skill experience, 0= don't */   
 };   
    
 _setup_map setup_map[] = {   
  {"sound", SETUP_SOUND},   
  {"",-1} /* end marker */   
 };   
   
 /* This table translates the attack numbers as used within the  /* This table translates the attack numbers as used within the
  * program to the value we use when sending STATS command to the   * program to the value we use when sending STATS command to the
  * client.  IF a value is -1, then we don't send that to the   * client.  IF a value is -1, then we don't send that to the
Line 120
 
Line 100
 /* 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)
 {   {
  register int s, c;       int s;
  register char *cmd, *param;       char *cmd, *param, cmdback[HUGE_BUF];
  char cmdback[256];   
    
    
  /* run through the cmds of setup    /* run through the cmds of setup
  * syntax is setup <cmdname1> <parameter> <cmdname2> <parameter> ...    * syntax is setup <cmdname1> <parameter> <cmdname2> <parameter> ...
Line 134
 
Line 112
    
  LOG(llevInfo,"Get SetupCmd:: %s\n", buf);    LOG(llevInfo,"Get SetupCmd:: %s\n", buf);
  strcpy(cmdback,"setup");    strcpy(cmdback,"setup");
  for(s=0;;)       for(s=0;;) {
  {   
  if(s>=len) /* ugly, but for secure...*/    if(s>=len) /* ugly, but for secure...*/
  break;    break;
   
  cmd = &buf[s];    cmd = &buf[s];
  for(;buf[s] && buf[s] != ' ';s++)   
  ;    /* find the next space, and put a null there */
    for(;buf[s] && buf[s] != ' ';s++) ;
  buf[s++]=0;    buf[s++]=0;
   
  if(s>=len)    if(s>=len)
  break;    break;
   
  param = &buf[s];    param = &buf[s];
  for(;buf[s] && buf[s] != ' ';s++)   
  ;    for(;buf[s] && buf[s] != ' ';s++) ;
  buf[s++]=0;    buf[s++]=0;
    
  for(c=0;setup_map[c].cmdnr != -1;c++) /* go through cmd table */   
  {   
  if(!strcmp(setup_map[c].cmdname, cmd) )   
  {   
  strcat(cmdback, " ");    strcat(cmdback, " ");
  strcat(cmdback, cmd);    strcat(cmdback, cmd);
  strcat(cmdback, " ");    strcat(cmdback, " ");
  switch(setup_map[c].cmdnr) /* this should be valid all times */   
  {    if (!strcmp(cmd,"sound")) {
  case SETUP_SOUND:   
  ns->sound = atoi(param);    ns->sound = atoi(param);
  strcat(cmdback, param);    strcat(cmdback, param);
  break;   
  };   
  break; /* we have found cmd, fetch next from setup buffer */   
    
  }    }
  }    else if (!strcmp(cmd,"sexp")) {
  /* if setup_map[c].cmdnr == -1 here        ns->skillexp = atoi(param);
  * we had found a cmd this server don't know, send a FALSE back - cmd unknown        strcat(cmdback, param);
    } else {
        /* Didn't get a setup command we understood -
         * report a failure to the client.
  */    */
  if(setup_map[c].cmdnr == -1)   
  {   
  strcat(cmdback, " ");   
  strcat(cmdback, cmd);   
  strcat(cmdback, " FALSE");    strcat(cmdback, " FALSE");
  }    }
        } /* for processing all the setup commands */
  }   
  LOG(llevInfo,"SendBack SetupCmd:: %s\n", cmdback);    LOG(llevInfo,"SendBack SetupCmd:: %s\n", cmdback);
  Write_String_To_Socket(ns, cmdback, strlen(cmdback));    Write_String_To_Socket(ns, cmdback, strlen(cmdback));
 }   }
Line 191
 
Line 161
 {  {
     Settings oldsettings;      Settings oldsettings;
     oldsettings=settings;      oldsettings=settings;
   
     if (ns->status != Ns_Add || add_player(ns)) {      if (ns->status != Ns_Add || add_player(ns)) {
  Write_String_To_Socket(ns, "addme_failed",12);   Write_String_To_Socket(ns, "addme_failed",12);
     } else {      } else {
Line 396
 
Line 365
 void VersionCmd(char *buf, int len,NewSocket *ns)  void VersionCmd(char *buf, int len,NewSocket *ns)
 {  {
     char *cp;      char *cp;
       char version_warning[256];
   
     if (!buf) {      if (!buf) {
  LOG(llevError, "CS: received corrupted version command\n");   LOG(llevError, "CS: received corrupted version command\n");
Line 418
 
Line 388
 #endif  #endif
     }      }
     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>\n", cp);
   
    /* This is first implementation - i skip all beta DX clients with it
    * Add later stuff here for other clients
    */
   
    if(!strcmp(" CF DX CLIENT", cp)) /* these are old dxclients */
    {
        sprintf(version_warning,"drawinfo %d %s", NDI_RED, "**** VERSION WARNING ****\n**** CLIENT IS TO OLD!! UPDATE THE CLIENT!! ****");
        Write_String_To_Socket(ns, version_warning, strlen(version_warning));
    }
       }
 }  }
   
 /*  /*
Line 584
 
Line 565
     AddIfShort(pl->last_stats.maxgrace, pl->ob->stats.maxgrace, CS_STAT_MAXGRACE);      AddIfShort(pl->last_stats.maxgrace, pl->ob->stats.maxgrace, CS_STAT_MAXGRACE);
     AddIfShort(pl->last_stats.Str, pl->ob->stats.Str, CS_STAT_STR);      AddIfShort(pl->last_stats.Str, pl->ob->stats.Str, CS_STAT_STR);
     AddIfShort(pl->last_stats.Int, pl->ob->stats.Int, CS_STAT_INT);      AddIfShort(pl->last_stats.Int, pl->ob->stats.Int, CS_STAT_INT);
 /* added this to allow Pow stat - b.t. */  
     AddIfShort(pl->last_stats.Pow, pl->ob->stats.Pow, CS_STAT_POW);      AddIfShort(pl->last_stats.Pow, pl->ob->stats.Pow, CS_STAT_POW);
     AddIfShort(pl->last_stats.Wis, pl->ob->stats.Wis, CS_STAT_WIS);      AddIfShort(pl->last_stats.Wis, pl->ob->stats.Wis, CS_STAT_WIS);
     AddIfShort(pl->last_stats.Dex, pl->ob->stats.Dex, CS_STAT_DEX);      AddIfShort(pl->last_stats.Dex, pl->ob->stats.Dex, CS_STAT_DEX);
     AddIfShort(pl->last_stats.Con, pl->ob->stats.Con, CS_STAT_CON);      AddIfShort(pl->last_stats.Con, pl->ob->stats.Con, CS_STAT_CON);
     AddIfShort(pl->last_stats.Cha, pl->ob->stats.Cha, CS_STAT_CHA);      AddIfShort(pl->last_stats.Cha, pl->ob->stats.Cha, CS_STAT_CHA);
       if(pl->last_stats.exp != pl->ob->stats.exp && pl->socket.skillexp)
       {
    int s;
    for(s=0;s<pl->last_skill_index;s++)
           {
        AddIfInt(pl->last_skill_exp[s],pl->last_skill_ob[s]->stats.exp , pl->last_skill_id[s]);
        AddIfShort(pl->last_skill_level[s],pl->last_skill_ob[s]->level , pl->last_skill_id[s]+1);
           }
       }
     AddIfInt(pl->last_stats.exp, pl->ob->stats.exp, CS_STAT_EXP);      AddIfInt(pl->last_stats.exp, pl->ob->stats.exp, CS_STAT_EXP);
     AddIfShort(pl->last_level, pl->ob->level, CS_STAT_LEVEL);      AddIfShort(pl->last_level, pl->ob->level, CS_STAT_LEVEL);
     AddIfShort(pl->last_stats.wc, pl->ob->stats.wc, CS_STAT_WC);      AddIfShort(pl->last_stats.wc, pl->ob->stats.wc, CS_STAT_WC);


Legend:
line(s) removed in v.1.11 
line(s) changed
 line(s) added in v.1.12

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