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


version 1.86 version 1.87
Line 1
 
Line 1
 /*  /*
  * static char *rcsid_init_c =   * static char *rcsid_init_c =
  *    "$Id: request.c,v 1.86 2006/03/14 07:41:49 mwedel Exp $";   *    "$Id: request.c,v 1.87 2006/03/18 15:05:37 ryo_saeba Exp $";
  */   */
   
 /*  /*
Line 107
 
Line 107
 };  };
   
 /** 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 set_up_cmd(char *buf, int len, socket_struct *ns)
 {  {
     int s, slen;      int s, slen;
     char *cmd, *param, cmdback[HUGE_BUF];      char *cmd, *param, cmdback[HUGE_BUF];
Line 258
 
Line 258
  * I am not sure if this file is the best place for this function.  however,   * I am not sure if this file is the best place for this function.  however,
  * it either has to be here or init_sockets needs to be exported.   * it either has to be here or init_sockets needs to be exported.
  */   */
 void AddMeCmd(char *buf, int len, NewSocket *ns)  void add_me_cmd(char *buf, int len, socket_struct *ns)
 {  {
     Settings oldsettings;      Settings oldsettings;
     oldsettings=settings;      oldsettings=settings;
Line 278
 
Line 278
 }  }
   
 /** Reply to ExtendedInfos command */  /** Reply to ExtendedInfos command */
 void ToggleExtendedInfos (char *buf, int len, NewSocket *ns){  void toggle_extended_infos_cmd(char *buf, int len, socket_struct *ns)
   {
      char cmdback[MAX_BUF];       char cmdback[MAX_BUF];
      char command[50];       char command[50];
      int info,nextinfo;       int info,nextinfo;
Line 321
 
Line 322
 #define MSG_TYPE_MONUMENT        5  #define MSG_TYPE_MONUMENT        5
 #define MSG_TYPE_SCRIPTED_DIALOG 6*/  #define MSG_TYPE_SCRIPTED_DIALOG 6*/
 /** Reply to ExtendedInfos command */  /** Reply to ExtendedInfos command */
 void ToggleExtendedText (char *buf, int len, NewSocket *ns){  void toggle_extended_text_cmd(char *buf, int len, socket_struct *ns)
   {
      char cmdback[MAX_BUF];       char cmdback[MAX_BUF];
      char temp[10];       char temp[10];
      char command[50];       char command[50];
Line 365
 
Line 367
  * if we know the client wants it, might as well push it to the   * if we know the client wants it, might as well push it to the
  * client.   * client.
  */   */
 static void SendSmooth(NewSocket *ns, uint16 face) {  static void send_smooth(socket_struct *ns, uint16 face) {
      uint16 smoothface;       uint16 smoothface;
      uint8 reply[MAX_BUF];       uint8 reply[MAX_BUF];
      SockList sl;       SockList sl;
Line 373
 
Line 375
     /* If we can't find a face, return and set it so we won't try to send this      /* If we can't find a face, return and set it so we won't try to send this
      * again.       * again.
      */       */
     if ((!FindSmooth (face, &smoothface)) &&      if ((!find_smooth(face, &smoothface)) &&
          (!FindSmooth ( smooth_face->number, &smoothface))) {           (!find_smooth( smooth_face->number, &smoothface))) {
   
         LOG(llevError,"could not findsmooth for %d. Neither default (%s)\n",face,smooth_face->name);          LOG(llevError,"could not findsmooth for %d. Neither default (%s)\n",face,smooth_face->name);
  ns->faces_sent[face] |= NS_FACESENT_SMOOTH;   ns->faces_sent[face] |= NS_FACESENT_SMOOTH;
Line 398
 
Line 400
   * Tells client the picture it has to use     * Tells client the picture it has to use
   * to smooth a picture number given as argument.    * to smooth a picture number given as argument.
   */    */
 void AskSmooth (char *buf, int len, NewSocket *ns){  void ask_smooth_cmd(char *buf, int len, socket_struct *ns){
     uint16 facenbr;      uint16 facenbr;
   
     facenbr=atoi (buf);      facenbr=atoi (buf);
     SendSmooth(ns, facenbr);      send_smooth(ns, facenbr);
 }  }
   
   
Line 413
 
Line 415
  * This handles the general commands from the client (ie, north, fire, cast,   * This handles the general commands from the client (ie, north, fire, cast,
  * etc.)   * etc.)
  */   */
 void PlayerCmd(char *buf, int len, player *pl)  void player_cmd(char *buf, int len, player *pl)
 {  {
   
     /* The following should never happen with a proper or honest client.      /* The following should never happen with a proper or honest client.
Line 434
 
Line 436
  buf=strchr(buf,' '); /* advance beyond the numbers */   buf=strchr(buf,' '); /* advance beyond the numbers */
  if (!buf) {   if (!buf) {
 #ifdef ESRV_DEBUG  #ifdef ESRV_DEBUG
      LOG(llevDebug,"PlayerCmd: Got count but no command.\n");       LOG(llevDebug,"player_cmd: Got count but no command.\n");
 #endif  #endif
      return;       return;
  }   }
Line 459
 
Line 461
   
 /**  /**
  * This handles the general commands from the client (ie, north, fire, cast,   * This handles the general commands from the client (ie, north, fire, cast,
  * etc.).  It is a lot like PlayerCmd above, but is called with the   * etc.).  It is a lot like player_cmd above, but is called with the
  * 'ncom' method which gives more information back to the client so it   * 'ncom' method which gives more information back to the client so it
  * can throttle.   * can throttle.
  */   */
 void NewPlayerCmd(uint8 *buf, int len, player *pl)  void new_player_cmd(uint8 *buf, int len, player *pl)
 {  {
     int time,repeat;      int time,repeat;
     short packet;      short packet;
Line 524
 
Line 526
   
   
 /** This is a reply to a previous query. */  /** This is a reply to a previous query. */
 void ReplyCmd(char *buf, int len, player *pl)  void reply_cmd(char *buf, int len, player *pl)
 {  {
     /* This is to synthesize how the data would be stored if it      /* This is to synthesize how the data would be stored if it
      * was normally entered.  A bit of a hack, and should be cleaned up       * was normally entered.  A bit of a hack, and should be cleaned up
Line 593
 
Line 595
  * backwards compatible, having it be a later version should not be a    * backwards compatible, having it be a later version should not be a
  * problem.   * problem.
  */   */
 void VersionCmd(char *buf, int len,NewSocket *ns)  void version_cmd(char *buf, int len,socket_struct *ns)
 {  {
     char *cp;      char *cp;
     char version_warning[256];      char version_warning[256];
Line 642
 
Line 644
   
 /** sound related functions. */  /** sound related functions. */
    
 void SetSound(char *buf, int len, NewSocket *ns)  void set_sound_cmd(char *buf, int len, socket_struct *ns)
 {  {
     ns->sound = atoi(buf);      ns->sound = atoi(buf);
 }  }
   
 /** client wants the map resent */  /** client wants the map resent */
   
 void MapRedrawCmd(char *buf, int len, player *pl)  void map_redraw_cmd(char *buf, int len, player *pl)
 {  {
 /* This function is currently disabled; just clearing the map state results in  /* This function is currently disabled; just clearing the map state results in
  * display errors. It should clear the cache and send a newmap command.   * display errors. It should clear the cache and send a newmap command.
Line 666
 
Line 668
 }  }
   
 /** Newmap command */  /** Newmap command */
 void MapNewmapCmd( player *pl)  void map_newmap_cmd( player *pl)
 {  {
     if( pl->socket.newmapcmd == 1) {      if( pl->socket.newmapcmd == 1) {
         memset(&pl->socket.lastmap, 0, sizeof(pl->socket.lastmap));          memset(&pl->socket.lastmap, 0, sizeof(pl->socket.lastmap));
Line 680
 
Line 682
  * Moves an object (typically, container to inventory).   * Moves an object (typically, container to inventory).
  * syntax is: move (to) (tag) (nrof)   * syntax is: move (to) (tag) (nrof)
  */   */
 void MoveCmd(char *buf, int len,player *pl)  void move_cmd(char *buf, int len,player *pl)
 {  {
     int vals[3], i;      int vals[3], i;
   
Line 715
 
Line 717
  * Asks the client to query the user.  This way, the client knows   * Asks the client to query the user.  This way, the client knows
  * it needs to send something back (vs just printing out a message)   * it needs to send something back (vs just printing out a message)
  */   */
 void send_query(NewSocket *ns, uint8 flags, char *text)  void send_query(socket_struct *ns, uint8 flags, char *text)
 {  {
     char buf[MAX_BUF];      char buf[MAX_BUF];
   
Line 888
 
Line 890
  * how much we are sending - on the other hand, this should only happen   * how much we are sending - on the other hand, this should only happen
  * when the player logs in and picks stuff up.   * when the player logs in and picks stuff up.
  */   */
 void esrv_send_animation(NewSocket *ns, short anim_num)  void esrv_send_animation(socket_struct *ns, short anim_num)
 {  {
     SockList sl;      SockList sl;
     int i;      int i;
Line 931
 
Line 933
  * This adds face_num to a map cell at x,y.  If the client doesn't have   * This adds face_num to a map cell at x,y.  If the client doesn't have
  * the face yet, we will also send it.   * the face yet, we will also send it.
  */   */
 static void esrv_map_setbelow(NewSocket *ns, int x,int y,  static void esrv_map_setbelow(socket_struct *ns, int x,int y,
        short face_num, struct Map *newmap)         short face_num, struct Map *newmap)
 {  {
     if(newmap->cells[x][y].count >= MAP_LAYERS) {      if(newmap->cells[x][y].count >= MAP_LAYERS) {
Line 956
 
Line 958
 };  };
   
 /** Checkes if map cells have changed */  /** Checkes if map cells have changed */
 static int mapcellchanged(NewSocket *ns,int i,int j, struct Map *newmap)  static int mapcellchanged(socket_struct *ns,int i,int j, struct Map *newmap)
 {  {
   int k;    int k;
   
Line 977
 
Line 979
  * this data into.  we return the end of the data.  layers is   * this data into.  we return the end of the data.  layers is
  * how many layers of data we should back.   * how many layers of data we should back.
  */     */ 
 static uint8 *compactlayer(NewSocket *ns, unsigned char *cur, int numlayers,   static uint8 *compactlayer(socket_struct *ns, unsigned char *cur, int numlayers,
     struct Map *newmap)      struct Map *newmap)
 {  {
     int x,y,k;      int x,y,k;
Line 1042
 
Line 1044
     return cur;      return cur;
 }  }
   
 static void esrv_map_doneredraw(NewSocket *ns, struct Map *newmap)  static void esrv_map_doneredraw(socket_struct *ns, struct Map *newmap)
 {  {
     static long frames,bytes,tbytes,tframes;      static long frames,bytes,tbytes,tframes;
     uint8 *cur;      uint8 *cur;
Line 1076
 
Line 1078
   
   
 /** Clears a map cell */  /** Clears a map cell */
 static void map_clearcell(struct MapCell *cell, int face0, int face1, int face2, int count)  static void map_clearcell(struct map_cell_struct *cell, int face0, int face1, int face2, int count)
 {  {
     cell->count=count;      cell->count=count;
     cell->faces[0] = face0;      cell->faces[0] = face0;
Line 1116
 
Line 1118
  * if needed, and returning 1.  If this no data needs to get   * if needed, and returning 1.  If this no data needs to get
  * sent, it returns zero.   * sent, it returns zero.
  */   */
 static inline int check_head(SockList *sl, NewSocket *ns, int ax, int ay, int layer)  static inline int check_head(SockList *sl, socket_struct *ns, int ax, int ay, int layer)
 {  {
     short face_num;      short face_num;
   
Line 1157
 
Line 1159
  * actually match.   * actually match.
  */   */
   
 static inline int update_space(SockList *sl, NewSocket *ns, mapstruct  *mp, int mx, int my, int sx, int sy, int layer)  static inline int update_space(SockList *sl, socket_struct *ns, mapstruct  *mp, int mx, int my, int sx, int sy, int layer)
 {  {
     object *ob, *head;      object *ob, *head;
     uint16 face_num;      uint16 face_num;
Line 1356
 
Line 1358
  * take.     * take. 
  */   */
   
 static inline int update_smooth(SockList *sl, NewSocket *ns, mapstruct  *mp, int mx, int my, int sx, int sy, int layer)  static inline int update_smooth(SockList *sl, socket_struct *ns, mapstruct  *mp, int mx, int my, int sx, int sy, int layer)
 {  {
     object *ob;      object *ob;
     int smoothlevel; /* old face_num;*/      int smoothlevel; /* old face_num;*/
Line 1370
 
Line 1372
     else {      else {
  smoothlevel = ob->smoothlevel;   smoothlevel = ob->smoothlevel;
  if (smoothlevel && !(ns->faces_sent[ob->face->number] & NS_FACESENT_SMOOTH))   if (smoothlevel && !(ns->faces_sent[ob->face->number] & NS_FACESENT_SMOOTH))
      SendSmooth(ns, ob->face->number);          send_smooth(ns, ob->face->number);
     } /* else not already head object or blank face */      } /* else not already head object or blank face */
   
     /* We've gotten what face we want to use for the object.  Now see if      /* We've gotten what face we want to use for the object.  Now see if
Line 1394
 
Line 1396
  * mapextended. There are CLIENTMAPX*CLIENTMAPY*LAYERS entries   * mapextended. There are CLIENTMAPX*CLIENTMAPY*LAYERS entries
  * available.   * available.
  */   */
 int getExtendedMapInfoSize(NewSocket* ns){  static int get_extended_mapinfo_size(socket_struct* ns){
     int result=0;      int result=0;
     if (ns->ext_mapinfos){      if (ns->ext_mapinfos){
         if (ns->EMI_smooth)          if (ns->EMI_smooth)
Line 1456
 
Line 1458
         ewhatflag=extendedinfos; /*The EMI_NOREDRAW bit          ewhatflag=extendedinfos; /*The EMI_NOREDRAW bit
                                    could need to be taken away*/                                     could need to be taken away*/
         SockList_AddChar(&esl, extendedinfos);          SockList_AddChar(&esl, extendedinfos);
         eentrysize=getExtendedMapInfoSize(&(pl->contr->socket));          eentrysize=get_extended_mapinfo_size(&(pl->contr->socket));
         SockList_AddChar(&esl, eentrysize);          SockList_AddChar(&esl, eentrysize);
         estartlen = esl.len;          estartlen = esl.len;
     } else {      } else {
Line 1591
 
Line 1593
      pl->contr->socket.lastmap.cells[ax][ay].count = count;       pl->contr->socket.lastmap.cells[ax][ay].count = count;
   
  } else {   } else {
      struct MapCell *cell = &pl->contr->socket.lastmap.cells[ax][ay];       struct map_cell_struct *cell = &pl->contr->socket.lastmap.cells[ax][ay];
      /* properly clear a previously sent big face */       /* properly clear a previously sent big face */
      if(cell->faces[0] != 0       if(cell->faces[0] != 0
      || cell->faces[1] != 0       || cell->faces[1] != 0
Line 1851
 
Line 1853
 }  }
   
   
 void esrv_map_scroll(NewSocket *ns,int dx,int dy)  void esrv_map_scroll(socket_struct *ns,int dx,int dy)
 {  {
     struct Map newmap;      struct Map newmap;
     int x,y, mx, my;      int x,y, mx, my;
Line 1885
 
Line 1887
  for(y=0; y<my; y++) {   for(y=0; y<my; y++) {
      if(x >= ns->mapx || y >= ns->mapy) {       if(x >= ns->mapx || y >= ns->mapy) {
  /* clear cells outside the viewable area */   /* clear cells outside the viewable area */
  memset(&newmap.cells[x][y], 0, sizeof(struct MapCell));   memset(&newmap.cells[x][y], 0, sizeof(struct map_cell_struct));
      }       }
      else if ((x+dx) < 0 || (x+dx) >= ns->mapx || (y+dy) < 0 || (y + dy) >= ns->mapy) {       else if ((x+dx) < 0 || (x+dx) >= ns->mapx || (y+dy) < 0 || (y + dy) >= ns->mapy) {
  /* clear newly visible tiles within the viewable area */   /* clear newly visible tiles within the viewable area */
  memset(&(newmap.cells[x][y]), 0, sizeof(struct MapCell));   memset(&(newmap.cells[x][y]), 0, sizeof(struct map_cell_struct));
      }       }
      else {       else {
  memcpy(&(newmap.cells[x][y]),   memcpy(&(newmap.cells[x][y]),
     &(ns->lastmap.cells[x+dx][y+dy]),sizeof(struct MapCell));             &(ns->lastmap.cells[x+dx][y+dy]),sizeof(struct map_cell_struct));
      }       }
  }   }
     }      }
Line 1906
 
Line 1908
     ns->sent_scroll = 1;      ns->sent_scroll = 1;
 }  }
   
 /*****************************************************************************/  /**
 /* GROS: The following one is used to allow a plugin to send a generic cmd to*/   * GROS: The following one is used to allow a plugin to send a generic cmd to
 /* a player. Of course, the client need to know the command to be able to    */   * a player. Of course, the client need to know the command to be able to
 /* manage it !                                                               */   * manage it !
 /*****************************************************************************/   */
 void send_plugin_custom_message(object *pl, char *buf)  void send_plugin_custom_message(object *pl, char *buf)
 {  {
     cs_write_string(&pl->contr->socket,buf,strlen(buf));      cs_write_string(&pl->contr->socket,buf,strlen(buf));
Line 1920
 
Line 1922
  * This sends the skill number to name mapping.  We ignore   * This sends the skill number to name mapping.  We ignore
  * the params - we always send the same info no matter what.   * the params - we always send the same info no matter what.
  */   */
 void send_skill_info(NewSocket *ns, char *params)  void send_skill_info(socket_struct *ns, char *params)
 {  {
     SockList sl;      SockList sl;
     int i;      int i;
Line 1944
 
Line 1946
  * This sends the spell path to name mapping.  We ignore   * This sends the spell path to name mapping.  We ignore
  * the params - we always send the same info no matter what.   * the params - we always send the same info no matter what.
  */   */
 void send_spell_paths (NewSocket *ns, char *params) {  void send_spell_paths (socket_struct *ns, char *params) {
     SockList sl;      SockList sl;
     int i;      int i;
   
Line 2018
 
Line 2020
     free(sl.buf);      free(sl.buf);
 }  }
   
 /* appends the spell *spell to the Socklist we will send the data to. */  /** appends the spell *spell to the Socklist we will send the data to. */
 static void append_spell (player *pl, SockList *sl, object *spell) {  static void append_spell (player *pl, SockList *sl, object *spell) {
     int len, i, skill=0;       int len, i, skill=0;
   


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

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