Example #1
0
/* this procedure handles the input parsing for the skill generator */
bool parse_gen_groups(CHAR_DATA *ch,const char *argument) {
  char arg[MAX_INPUT_LENGTH];
  char buf[100];
  int gn,sn,i;

  if (argument[0] == '\0')
    return FALSE;

  argument = one_argument(argument,arg);

  if (!str_prefix(arg,"help")) {
    if (argument[0] == '\0') {
      do_help(ch,"group help");
      return TRUE;
    }
    
    do_help(ch,argument);
    return TRUE;
  }

  // Removed by SinaC 2001, replaced with help
  /*
  // Added by Sinac 1997
  if (!str_prefix(arg,"level")) {
    do_level(ch,argument);
    return TRUE;
  }
  */

  // Added by SinaC 2001, so spells can be gained one by one not only by group
  if (!str_prefix(arg,"spell")) {
    list_spell_costs(ch);
    return TRUE;
  }

  // Added by SinaC 2001, so powers can be gained one by one not only by group
  if (!str_prefix(arg,"power")) {
    list_power_costs(ch);
    return TRUE;
  }

  // Added by SinaC 2003
  if (!str_prefix(arg,"song")) {
    list_song_costs(ch);
    return TRUE;
  }

  if (!str_prefix(arg,"add")) {
    if (argument[0] == '\0') {
      send_to_char("You must provide a skill/spell or group name.\n\r",ch);
      return TRUE;
    }
    
    gn = group_lookup(argument);
    if (gn != -1) {
      if (ch->gen_data->group_chosen[gn]
	  ||  ch->pcdata->group_known[gn]) {
	send_to_char("You already know that group!\n\r",ch);
	return TRUE;
      }
      
      if (class_grouprating( ch->bstat(classes), gn ) <= 0
	  || god_grouprating( ch, gn ) <= 0 ) {
	send_to_char("That group is not available.\n\r",ch);
	return TRUE;
      }
    
      sprintf(buf,"{W%s group added.{x\n\r",group_table[gn].name);
      send_to_char(buf,ch);
      ch->gen_data->group_chosen[gn] = TRUE;
      ch->gen_data->points_chosen += class_grouprating( ch->bstat(classes), gn );
      gn_add(ch,gn);
      ch->pcdata->points += class_grouprating( ch->bstat(classes), gn );
      return TRUE;
    }
    
    sn = ability_lookup(argument);
    if (sn != -1) {
      // Modified by SinaC 2001 for god skill
      if (ch->gen_data->ability_chosen[sn]
	  || get_raceability( ch, sn )
	  || get_clanability( ch, sn )
	  /*|| get_godskill( ch, sn )  removed by SinaC 2003*/
	  ||  ch->pcdata->ability_info[sn].learned > 0) {
	send_to_char("You already know that skill/spell/power/song!\n\r",ch);
	return TRUE;
      }
      
      // Modified by SinaC 2003
      if (class_gainabilityrating(ch, sn, ch->pcdata->ability_info[sn].casting_level ) <= 0
	  // Removed by SinaC 2001 so spells can be gained one by one
	  //  not only by group
	  /*||  ability_table[sn].spell_fun != spell_null*/) {
	send_to_char("That skill/spell/power/song is not available.\n\r",ch);
	return TRUE;
      }

      // Added by SinaC 2001
      if ( !can_gain_creation( ch, sn ) ) {
 	send_to_charf( ch, "You don't fit the prereqs for %s.\n\r",
		       ability_table[sn].name);
	return TRUE;
      }


      sprintf(buf, "{W%s skill/spell/power/song added.{x\n\r",ability_table[sn].name);
      send_to_char(buf,ch);
      ch->gen_data->ability_chosen[sn] = TRUE;
      ch->gen_data->points_chosen += class_abilityrating( ch, sn, ch->pcdata->ability_info[sn].casting_level );
      //ch->pcdata->ability_info[sn].learned = 1;  SinaC 2003, casting level need to be set
      group_add( ch, ability_table[sn].name, FALSE );
      ch->pcdata->points += class_abilityrating( ch, sn, ch->pcdata->ability_info[sn].casting_level );
      return TRUE;
    }
    
    send_to_char("No skills/spells/powers/songs or groups by that name...\n\r",ch);
    return TRUE;
  }
  
  if (!str_cmp(arg,"drop")) {
    if (argument[0] == '\0') {
      send_to_char("You must provide a skill/spell/power/song or group to drop.\n\r",ch);
      return TRUE;
    }

    gn = group_lookup(argument);
    if (gn != -1 && ch->gen_data->group_chosen[gn]) {
      send_to_char("{WGroup dropped.{x\n\r",ch);
      ch->gen_data->group_chosen[gn] = FALSE;
      ch->gen_data->points_chosen -= class_grouprating( ch->bstat(classes), gn );
      gn_remove(ch,gn);
      for (i = 0; i < MAX_GROUP; i++) {
	if (ch->gen_data->group_chosen[gn])
	  gn_add(ch,gn);
      }
      ch->pcdata->points -= class_grouprating( ch->bstat(classes), gn );
      // To avoid losing basic abilities which would be included in the group we just removed
      //  we re-add basics
      group_add( ch, class_table[ class_firstclass( ch->bstat(classes) ) ].base_group, FALSE );
      return TRUE;
    }
    
    sn = ability_lookup(argument);
    if (sn != -1 && ch->gen_data->ability_chosen[sn]) {
      send_to_char("{WSkill/spell/power/song dropped.{x\n\r",ch);
      ch->gen_data->ability_chosen[sn] = FALSE;
      ch->gen_data->points_chosen -= class_abilityrating( ch, sn, ch->pcdata->ability_info[sn].casting_level );
      ch->pcdata->ability_info[sn].learned = 0;
      ch->pcdata->points -= class_abilityrating( ch, sn, ch->pcdata->ability_info[sn].casting_level );
      return TRUE;
    }
    
    send_to_char("You haven't bought any such skill/spell/power/song or group.\n\r",ch);
    return TRUE;
  }
  
  if (!str_prefix(arg,"premise")) {
    do_help(ch,"premise");
    return TRUE;
  }
  
  if (!str_prefix(arg,"list")) {
    list_group_costs(ch);
    return TRUE;
  }
  
  if (!str_prefix(arg,"learned")) {
    list_group_chosen(ch);
    return TRUE;
  }

  // Added by SinaC 2000
  if (!str_prefix(arg,"known")){
    list_group_known(ch);
  }
  
  if (!str_prefix(arg,"info")) {
    do_groups(ch,argument);
    return TRUE;
  }

  return FALSE;
}
Example #2
0
int main(void) 
{
 int32 sd1_id;        /* SD interface identifier */
 int32 sd2_id;        /* SD interface identifier */
 int32 sds1_id;       /* SDS identifier */
 int32 sds2_id;       /* SDS identifier */
 int32 dim_sizes[2];  /* sizes of the SDS dimensions */
 int32 start[2];      /* start location to write */
 int32 edges[2];      /* number of elements to write */
 int32 n_values;
 int32 buf1a[Y_LENGTH][X_LENGTH] = {{1,1},{1,1},{5,6}};
 int32 buf1b[Y_LENGTH][X_LENGTH] = {{1,2},{3,4},{5,6}};

 /* percent test: compare divide by zero, both zero */
 int32 buf2a[Y_LENGTH][X_LENGTH] = {{100,100},{100,0},{0,100}}; 
 int32 buf2b[Y_LENGTH][X_LENGTH] = {{120,80},{0,100},{0,50}};

 /* global attributes */
 char8 bufga1[] = "Storm_track_data1"; 
 char8 bufga2[] = "Storm_track_data2"; 
 float32 bufa1[2] = {1., 1.};
 float32 bufa2[2] = {1., 2.};

 /*vdata*/
 int32 file1_id; 
 int32 file2_id; 
 int32 vdata1_id;
 int32 vdata2_id;
 char8 vdata1_buf1 [N_RECORDS_1] = {'V', 'D', 'A', 'T', 'A'};
 char8 vdata1_buf2 [N_RECORDS_1] = {'X', 'D', 'A', 'T', 'A'};
 int32 vdata2_buf1  [N_RECORDS_2][ORDER_2] = {{1, 2, 3, 4}, {5, 6, 7, 8}};
 int32 vdata2_buf2  [N_RECORDS_2][ORDER_2] = {{1, 1, 1, 1}, {5, 6, 7, 8}};
 float32 vdata3_buf1[N_RECORDS_2][N_VALS_PER_REC]={{1,2,3,4,5,6},{7,8,9,10,11,12}}; 
 float32 vdata3_buf2[N_RECORDS_2][N_VALS_PER_REC]={{1,1,1,1,1,1},{7,8,9,10,11,12}}; 
 
/* Define the location and size of the data to be written to the data set*/
 start[0] = 0;
 start[1] = 0;
 edges[0] = Y_LENGTH;
 edges[1] = X_LENGTH;

/* Define the dimensions of the array to be created */
 dim_sizes[0] = Y_LENGTH;
 dim_sizes[1] = X_LENGTH;

/*-------------------------------------------------------------------------
 * SD data
 *-------------------------------------------------------------------------
 */

 
/* Create the files and initialize the SD interface */
 if ((sd1_id = SDstart (FILE1_NAME, DFACC_CREATE))==FAIL) 
     goto error;
 if ((sd2_id = SDstart (FILE2_NAME, DFACC_CREATE))==FAIL) 
     goto error;

/* Set a global attribute */
 n_values  = sizeof(bufga1);
 if ( SDsetattr (sd1_id, FILE_ATTR_NAME, DFNT_CHAR8, n_values, (VOIDP)bufga1)==FAIL) 
     goto error;
 if ( SDsetattr (sd2_id, FILE_ATTR_NAME, DFNT_CHAR8, n_values, (VOIDP)bufga2)==FAIL) 
     goto error;
  
/* Create the data sets */ 
 if ((sds1_id = SDcreate (sd1_id, "dset1", DFNT_INT32, RANK, dim_sizes))==FAIL) 
     goto error;
 if ((sds2_id = SDcreate (sd2_id, "dset1", DFNT_INT32, RANK, dim_sizes))==FAIL) 
     goto error;

/* Assign attribute */
 n_values  = 2;
 if ( SDsetattr (sds1_id, SDS_ATTR_NAME, DFNT_FLOAT32, n_values, (VOIDP)bufa1)==FAIL) 
     goto error;
 if ( SDsetattr (sds2_id, SDS_ATTR_NAME, DFNT_FLOAT32, n_values, (VOIDP)bufa2)==FAIL) 
     goto error;
 
/* Write the stored data to the data set */
 if ( SDwritedata (sds1_id, start, NULL, edges, (VOIDP)buf1a)==FAIL) 
     goto error;
 if ( SDwritedata (sds2_id, start, NULL, edges, (VOIDP)buf1b)==FAIL) 
     goto error;
 
/* Terminate access to the data set */
 if ( SDendaccess (sds1_id)==FAIL) 
     goto error;
 if ( SDendaccess (sds2_id)==FAIL) 
     goto error;

 /* Create another data set */ 
 if (( sds1_id = SDcreate (sd1_id, "dset2", DFNT_INT32, RANK, dim_sizes))==FAIL) 
     goto error;
 if (( sds2_id = SDcreate (sd2_id, "dset2", DFNT_INT32, RANK, dim_sizes))==FAIL) 
     goto error;
 if ( SDwritedata (sds1_id, start, NULL, edges, (VOIDP)buf1a)==FAIL) 
     goto error;
 if ( SDwritedata (sds2_id, start, NULL, edges, (VOIDP)buf1b)==FAIL) 
     goto error;
 if ( SDendaccess (sds1_id)==FAIL) 
     goto error;
 if ( SDendaccess (sds2_id)==FAIL) 
     goto error;

 /* data sets for -p test */ 
 if (( sds1_id = SDcreate (sd1_id, "dset3", DFNT_INT32, RANK, dim_sizes))==FAIL) 
     goto error;
 if (( sds2_id = SDcreate (sd2_id, "dset3", DFNT_INT32, RANK, dim_sizes))==FAIL) 
     goto error;
 if ( SDwritedata (sds1_id, start, NULL, edges, (VOIDP)buf2a)==FAIL) 
     goto error;
 if ( SDwritedata (sds2_id, start, NULL, edges, (VOIDP)buf2b)==FAIL) 
     goto error;
 if ( SDendaccess (sds1_id)==FAIL) 
     goto error;
 if ( SDendaccess (sds2_id)==FAIL) 
     goto error;


/*-------------------------------------------------------------------------
 * end SD 
 *-------------------------------------------------------------------------
 */
 
 /* Terminate access to the SD interface and close the file */
 if ( SDend (sd1_id)==FAIL) 
     goto error;
 if ( SDend (sd2_id)==FAIL) 
     goto error;



/*-------------------------------------------------------------------------
 * VD data 
 *-------------------------------------------------------------------------
 */

/* Open the HDF file for writing */
 if ((file1_id = Hopen (FILE1_NAME, DFACC_WRITE, 0))==FAIL) 
     goto error;
 if ((file2_id = Hopen (FILE2_NAME, DFACC_WRITE, 0))==FAIL) 
     goto error;
 
/* Initialize the VS interface */
 if ( Vstart (file1_id)==FAIL) 
     goto error;
 if ( Vstart (file2_id)==FAIL) 
     goto error;

/*-------------------------------------------------------------------------
 * VD data one field
 *-------------------------------------------------------------------------
 */
 
/* Create the first vdata and populate it with data from vdata1_buf */
 if (VHstoredata (file1_id, FIELD1_NAME, (uint8 *)vdata1_buf1, 
  N_RECORDS_1, DFNT_CHAR8, VDATA1_NAME, CLASS1_NAME)==FAIL) 
     goto error; 
 if (VHstoredata (file2_id, FIELD1_NAME, (uint8 *)vdata1_buf2, 
  N_RECORDS_1, DFNT_CHAR8, VDATA1_NAME, CLASS1_NAME)==FAIL) 
     goto error; 

/*-------------------------------------------------------------------------
 * VD data one field, order 4
 *-------------------------------------------------------------------------
 */
 
/* Create the second vdata and populate it with data from vdata2_buf */
 if ( VHstoredatam (file1_id, FIELD2_NAME, (uint8 *)vdata2_buf1, 
  N_RECORDS_2, DFNT_INT32, VDATA2_NAME, CLASS2_NAME, ORDER_2)==FAIL) 
     goto error;  
 if ( VHstoredatam (file2_id, FIELD2_NAME, (uint8 *)vdata2_buf2, 
  N_RECORDS_2, DFNT_INT32, VDATA2_NAME, CLASS2_NAME, ORDER_2)==FAIL) 
     goto error;   

/*-------------------------------------------------------------------------
 * VD data several fields
 *-------------------------------------------------------------------------
 */

/* Create a new vdata */
 if ((vdata1_id = VSattach (file1_id, -1, "w"))==FAIL) 
     goto error;
 if ((vdata2_id = VSattach (file2_id, -1, "w"))==FAIL) 
     goto error;

/* Set name and class name of the vdata */
 if ( VSsetname (vdata1_id, VDATA3_NAME)==FAIL) 
     goto error;
 if ( VSsetclass (vdata1_id, CLASS3_NAME)==FAIL) 
     goto error;
 if ( VSsetname (vdata2_id, VDATA3_NAME)==FAIL) 
     goto error;
 if ( VSsetclass (vdata2_id, CLASS3_NAME)==FAIL) 
     goto error;

/* Define fields */
 if ( VSfdefine (vdata1_id, FIELD3_NAME1, DFNT_FLOAT32, ORDER3_1 )==FAIL) 
     goto error;
 if ( VSfdefine (vdata1_id, FIELD3_NAME2, DFNT_FLOAT32, ORDER3_2 )==FAIL) 
     goto error;
 if ( VSfdefine (vdata1_id, FIELD3_NAME3, DFNT_FLOAT32, ORDER3_3 )==FAIL) 
     goto error;
 if ( VSsetfields (vdata1_id, FIELDNAME3_LIST )==FAIL) 
     goto error;
 if ( VSfdefine (vdata2_id, FIELD3_NAME1, DFNT_FLOAT32, ORDER3_1 )==FAIL) 
     goto error;
 if ( VSfdefine (vdata2_id, FIELD3_NAME2, DFNT_FLOAT32, ORDER3_2 )==FAIL) 
     goto error;
 if ( VSfdefine (vdata2_id, FIELD3_NAME3, DFNT_FLOAT32, ORDER3_3 )==FAIL) 
     goto error;
 if ( VSsetfields (vdata2_id, FIELDNAME3_LIST)==FAIL) 
     goto error;

/* Write the data with full interlacing mode */
 if ( VSwrite (vdata1_id, (uint8 *)vdata3_buf1, N_RECORDS_2, FULL_INTERLACE)==FAIL) 
     goto error;
 if ( VSwrite (vdata2_id, (uint8 *)vdata3_buf2, N_RECORDS_2, FULL_INTERLACE)==FAIL) 
     goto error;

 if ( VSdetach (vdata1_id)==FAIL) 
     goto error;
 if ( VSdetach (vdata2_id)==FAIL) 
     goto error;

/*-------------------------------------------------------------------------
 * end VD data 
 *-------------------------------------------------------------------------
 */
 
/* Terminate access to the VS interface and close the HDF file */
 if ( Vend (file1_id)==FAIL) 
     goto error;
 if ( Vend (file2_id)==FAIL) 
     goto error;
 if ( Hclose (file1_id)==FAIL) 
     goto error;
 if ( Hclose (file2_id)==FAIL) 
     goto error;

/*-------------------------------------------------------------------------
 * write 2 big files for hyperslab reading
 *-------------------------------------------------------------------------
 */
 if (do_big_file()==FAIL) 
     goto error;

/*-------------------------------------------------------------------------
 * groups
 *-------------------------------------------------------------------------
 */
 if (do_groups()==FAIL) 
     goto error;

 
 return 0;

error:

 printf("Error...Exiting...\n");

 return 1;

}