Difference for server/move.c from version 1.2 to 1.3


version 1.2 version 1.3
Line 1
 
Line 1
 /*  /*
  * static char *rcsid_move_c =   * static char *rcsid_move_c =
  *    "$Id: move.c,v 1.2 1999/07/13 06:03:04 cvs Exp $";   *    "$Id: move.c,v 1.3 2000/05/26 09:50:49 jec Exp $";
  */   */
   
 /*  /*
Line 31
 
Line 31
 #include <sproto.h>  #include <sproto.h>
 #endif  #endif
   
 int move_ob(object *op,int dir) {  int move_ob (object *op, int dir, object *originator)
   {
   object *tmp=NULL;    object *tmp=NULL;
   object *tmp_ob=NULL;    object *tmp_ob=NULL;
   
Line 96
 
Line 97
   
     /* Re insert object if we removed it above */      /* Re insert object if we removed it above */
     if(op->more!=NULL && op->head==NULL)      if(op->more!=NULL && op->head==NULL)
       insert_ob_in_map(op,op->map);        insert_ob_in_map(op,op->map,originator);
     return 0;      return 0;
   }    }
   
Line 119
 
Line 120
    */     */
   if(op->more!=NULL) {    if(op->more!=NULL) {
     tmp=op->more,op->more=NULL;      tmp=op->more,op->more=NULL;
     if(!move_ob(tmp,dir)) {      if(!move_ob(tmp,dir,originator)) {
       op->more=tmp;        op->more=tmp;
       if(op->head==NULL)        if(op->head==NULL)
         insert_ob_in_map(op,op->map);          insert_ob_in_map(op,op->map,originator);
       return 0;        return 0;
     }      }
     else op->more=tmp;      else op->more=tmp;
Line 131
 
Line 132
   
   /* If head of object (or single part object), reinsert into map. */    /* If head of object (or single part object), reinsert into map. */
   if(op->head==NULL)    if(op->head==NULL)
     insert_ob_in_map(op,op->map);      insert_ob_in_map(op,op->map,originator);
   
   if (op->type==PLAYER) {    if (op->type==PLAYER) {
     esrv_map_scroll(&op->contr->socket, freearr_x[dir],freearr_y[dir]);      esrv_map_scroll(&op->contr->socket, freearr_x[dir],freearr_y[dir]);
Line 144
 
Line 145
 /*  /*
  * transfer_ob(): Move an object (even linked objects) to another spot   * transfer_ob(): Move an object (even linked objects) to another spot
  * on the same map.   * on the same map.
    *
    * Does nothing if there is no free spot.
    *
    * randomly: If true, use find_free_spot() to find the destination, otherwise
    * use find_first_free_spot().
    *
    * Return value: 1 if object was destroyed, 0 otherwise.
  */   */
   
 void transfer_ob(object *op,int x,int y) {  int transfer_ob (object *op, int x, int y, int randomly, object *originator)
   int i=find_first_free_spot(op->arch,op->map,x,y);  {
     int i;
   object *tmp;    object *tmp;
   if (i==-1) return; /* No free spot */  
     if (randomly)
       i = find_free_spot (op->arch,op->map,x,y,0,SIZEOFFREE);
     else
       i = find_first_free_spot(op->arch,op->map,x,y);
     if (i==-1)
       return 0; /* No free spot */
   
   if(op->head!=NULL)    if(op->head!=NULL)
     op=op->head;      op=op->head;
   remove_ob(op);    remove_ob(op);
   for(tmp=op;tmp!=NULL;tmp=tmp->more)    for(tmp=op;tmp!=NULL;tmp=tmp->more)
     tmp->x=x+freearr_x[i]+(tmp->arch==NULL?0:tmp->arch->clone.x),      tmp->x=x+freearr_x[i]+(tmp->arch==NULL?0:tmp->arch->clone.x),
     tmp->y=y+freearr_y[i]+(tmp->arch==NULL?0:tmp->arch->clone.y);      tmp->y=y+freearr_y[i]+(tmp->arch==NULL?0:tmp->arch->clone.y);
   insert_ob_in_map(op,op->map);    return insert_ob_in_map(op,op->map,originator) == NULL;
 }  }
   
 void teleport(object *teleporter,unsigned char tele_type) {  /*
    * Return value: 1 if object was destroyed, 0 otherwise.
    */
   int teleport (object *teleporter, unsigned char tele_type, object *originator)
   {
   object *altern[120]; /* Better use c/malloc here in the future */    object *altern[120]; /* Better use c/malloc here in the future */
   int i,j,k,nrofalt=0;    int i,j,k,nrofalt=0;
   object *other_teleporter,*teleported=teleporter->above,*tmp;    object *other_teleporter,*teleported=teleporter->above,*tmp;
   
   if(teleported==NULL) return;    if(teleported==NULL) return 0;
   if(teleported->head!=NULL)    if(teleported->head!=NULL)
     teleported=teleported->head;      teleported=teleported->head;
   for(i= -5;i<6;i++)    for(i= -5;i<6;i++)
Line 184
 
Line 204
     }      }
   if(!nrofalt) {    if(!nrofalt) {
     LOG(llevError,"No alternative teleporters around!\n");      LOG(llevError,"No alternative teleporters around!\n");
     return;      return 0;
   }    }
   other_teleporter=altern[RANDOM()%nrofalt];    other_teleporter=altern[RANDOM()%nrofalt];
   k=find_free_spot(teleported->arch,other_teleporter->map,    k=find_free_spot(teleported->arch,other_teleporter->map,
                         other_teleporter->x,other_teleporter->y,1,9);                          other_teleporter->x,other_teleporter->y,1,9);
   if (k==-1)    if (k==-1)
     return;      return 0;
   remove_ob(teleported);    remove_ob(teleported);
   for(tmp=teleported;tmp!=NULL;tmp=tmp->more)    for(tmp=teleported;tmp!=NULL;tmp=tmp->more)
     tmp->x=other_teleporter->x+freearr_x[k]+      tmp->x=other_teleporter->x+freearr_x[k]+
            (tmp->arch==NULL?0:tmp->arch->clone.x),             (tmp->arch==NULL?0:tmp->arch->clone.x),
     tmp->y=other_teleporter->y+freearr_y[k]+      tmp->y=other_teleporter->y+freearr_y[k]+
            (tmp->arch==NULL?0:tmp->arch->clone.y);             (tmp->arch==NULL?0:tmp->arch->clone.y);
   insert_ob_in_map(teleported,other_teleporter->map);    return insert_ob_in_map(teleported,other_teleporter->map,originator) == NULL;
 }  }
   
 void recursive_roll(object *op,int dir,object *pusher) {  void recursive_roll(object *op,int dir,object *pusher) {
Line 206
 
Line 226
  "You fail to push the %s.",query_name(op));   "You fail to push the %s.",query_name(op));
     return;      return;
   }    }
   (void) move_ob(pusher,dir);    (void) move_ob(pusher,dir,pusher);
   new_draw_info_format(NDI_BLACK, 0, pusher,    new_draw_info_format(NDI_BLACK, 0, pusher,
  "You roll the %s.",query_name(op));   "You roll the %s.",query_name(op));
   return;    return;
Line 282
 
Line 302
     remove_ob(op);      remove_ob(op);
     for(tmp=op; tmp!=NULL; tmp=tmp->more)      for(tmp=op; tmp!=NULL; tmp=tmp->more)
  tmp->x+=freearr_x[dir],tmp->y+=freearr_y[dir];   tmp->x+=freearr_x[dir],tmp->y+=freearr_y[dir];
     insert_ob_in_map(op,op->map);      insert_ob_in_map(op,op->map,pusher);
     return 1;      return 1;
 }  }
   
Line 303
 
Line 323
     temp = pusher->y;      temp = pusher->y;
     pusher->y = who->y;      pusher->y = who->y;
     who->y = temp;      who->y = temp;
     insert_ob_in_map (who,who->map);      insert_ob_in_map (who,who->map,pusher);
     insert_ob_in_map (pusher,pusher->map);      insert_ob_in_map (pusher,pusher->map,pusher);
     return 0;      return 0;
   }    }
   if(QUERY_FLAG(who,FLAG_UNAGGRESSIVE) && owner != pusher)    if(QUERY_FLAG(who,FLAG_UNAGGRESSIVE) && owner != pusher)
Line 312
 
Line 332
   str1 = (who->stats.Str>0?who->stats.Str:who->level);    str1 = (who->stats.Str>0?who->stats.Str:who->level);
   str2 = (pusher->stats.Str>0?pusher->stats.Str:pusher->level);    str2 = (pusher->stats.Str>0?pusher->stats.Str:pusher->level);
   if(QUERY_FLAG(who,FLAG_WIZ) || RANDOM()%(str1/2+1) + str1 >= RANDOM()%(str2/2+1) + str2 ||    if(QUERY_FLAG(who,FLAG_WIZ) || RANDOM()%(str1/2+1) + str1 >= RANDOM()%(str2/2+1) + str2 ||
      !move_ob(who,dir))       !move_ob(who,dir,pusher))
   {    {
     if (who ->type == PLAYER) {      if (who ->type == PLAYER) {
       new_draw_info_format(NDI_UNIQUE, 0, who,        new_draw_info_format(NDI_UNIQUE, 0, who,


Legend:
line(s) removed in v.1.2 
line(s) changed
 line(s) added in v.1.3

File made using version 1.98 of cvs2html by leaf at 2011-07-21 17:38