Difference for server/c_party.c from version 1.15 to 1.16


version 1.15 version 1.16
Line 1
 
Line 1
 /*  /*
  * static char *rcsid_c_party_c =   * static char *rcsid_c_party_c =
  *   "$Id: c_party.c,v 1.15 2005/09/25 09:47:23 ryo_saeba Exp $";   *   "$Id: c_party.c,v 1.16 2005/09/25 14:31:20 cavesomething Exp $";
  */   */
   
 /*  /*
Line 40
 
Line 40
 /* Forms the party struct for a party called 'params'. it is the responsibility  /* Forms the party struct for a party called 'params'. it is the responsibility
  * of the caller to ensure that the name is unique, and that it is placed in the    * of the caller to ensure that the name is unique, and that it is placed in the
  * main party list correctly */   * main party list correctly */
 static partylist *form_party(object *op, const char *params, partylist *firstparty, partylist *lastparty) {  static partylist *form_party(object *op, const char *params) {
   
     partylist * newparty;      partylist * newparty;
     int player_count;  
     player *pl;  
   
     newparty = (partylist *)malloc(sizeof(partylist));      newparty = (partylist *)malloc(sizeof(partylist));
     newparty->partyname = strdup_local(params);      newparty->partyname = strdup_local(params);
Line 53
 
Line 51
     newparty->passwd[0] = '\0';      newparty->passwd[0] = '\0';
     newparty->next = NULL;      newparty->next = NULL;
     newparty->partyleader = strdup_local(op->name);      newparty->partyleader = strdup_local(op->name);
     if(firstparty && lastparty)  
         lastparty->next = newparty;  
     else firstparty=newparty;  
     /*   
      * The player might already be a member of a party, if so, he will be leaving  
      * it, so check if there are any other members and if not, delete the party  
      */  
     player_count=0;   
     if (op->contr->party!=NULL) {  
     for (pl=first_player;pl->next!=NULL;pl=pl->next) {  
      if (pl->party==op->contr->party && op->contr!=pl)  
      player_count++;  
  }  
  if (player_count <= 0)  
      remove_party(op->contr->party);  
     }  
     new_draw_info_format(NDI_UNIQUE, 0, op,      new_draw_info_format(NDI_UNIQUE, 0, op,
  "You have formed party: %s",newparty->partyname);    "You have formed party: %s",newparty->partyname);
     op->contr->party=newparty;      op->contr->party=newparty;
Line 98
 
Line 80
  return;    return;
     }      }
     else if (target_party == lastparty) {      else if (target_party == lastparty) {
  for (tmpparty=firstparty;tmpparty->next!=NULL;tmpparty->next) {   for (tmpparty=firstparty;tmpparty->next!=NULL;tmpparty=tmpparty->next) {
      if (tmpparty->next=target_party) {       if (tmpparty->next=target_party) {
  lastparty=tmpparty;   lastparty=tmpparty;
  if (target_party->partyleader) free(target_party->partyleader);   if (target_party->partyleader) free(target_party->partyleader);
Line 108
 
Line 90
      }       }
  }   }
     }      }
     for (tmpparty=firstparty;tmpparty->next!=NULL;tmpparty->next)      for (tmpparty=firstparty;tmpparty->next!=NULL;tmpparty=tmpparty->next)
  if (tmpparty->next == target_party) {   if (tmpparty->next == target_party) {
      previousparty=tmpparty;       previousparty=tmpparty;
      nextparty=tmpparty->next->next;        nextparty=tmpparty->next->next;
Line 222
 
Line 204
 int command_party (object *op, char *params)  int command_party (object *op, char *params)
 {  {
   char buf[MAX_BUF];    char buf[MAX_BUF];
   partylist * tmpparty;  /* For iterating over linked list */    partylist *tmpparty, *oldparty;  /* For iterating over linked list */
   char * currentparty; /* For iterating over linked list */    char * currentparty; /* For iterating over linked list */
   
   if(params == NULL) {    if(params == NULL) {
Line 318
 
Line 300
     }      }
   
   if(strncmp(params, "form ",5) == 0) {    if(strncmp(params, "form ",5) == 0) {
       int player_count;
       player *pl;
   
     params += 5;      params += 5;
       if (op->contr->party) oldparty = op->contr->party;
   
     if(firstparty == NULL) {      if (firstparty) {
       firstparty = form_party(op, params, firstparty, lastparty);   for (tmpparty = firstparty; tmpparty != NULL;tmpparty = tmpparty->next) {
       lastparty = firstparty;       if (!strcmp(tmpparty->partyname, params)) {
       return 0;  
     }  
     else  
       tmpparty = firstparty->next;  
   
     if(tmpparty == NULL) {  
       if(strcmp(firstparty->partyname, params) != 0) {  
         lastparty = form_party(op, params, firstparty, lastparty);  
         return 0;  
       }  
       else {  
  new_draw_info_format(NDI_UNIQUE, 0,op,   new_draw_info_format(NDI_UNIQUE, 0,op,
  "The party %s already exists, pick another name",params);   "The party %s already exists, pick another name",params);
         return 1;          return 1;
       }        }
     }      }
     tmpparty=firstparty;      lastparty->next=form_party(op, params);
     while(tmpparty != NULL) {      lastparty = lastparty->next;
       if(strcmp(tmpparty->partyname,params) == 0) {  
         new_draw_info_format(NDI_UNIQUE, 0, op,  
  "The party %s already exists, pick a new name",params);  
         return 1;  
       }        }
       tmpparty = tmpparty->next;      else {
    firstparty=form_party(op, params);
    lastparty=firstparty;
       }
       /*
        * The player might have previously been a member of a party, if so, he will be leaving
        * it, so check if there are any other members and if not, delete the party
        */
       player_count=0;
       if (oldparty) {
       for (pl=first_player;pl->next!=NULL;pl=pl->next) {
        if (pl->party==oldparty) player_count++;
    }
    if (player_count == 0)
        remove_party(oldparty);
     }      }
   
     lastparty = form_party(op, params, firstparty, lastparty);  
     return 0;      return 0;
   } /* form */    } /* form */
   


Legend:
line(s) removed in v.1.15 
line(s) changed
 line(s) added in v.1.16

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