예제 #1
0
파일: race.c 프로젝트: Shea690901/gurbalib
void set_race( string name )
{
   race = name;
   race_object = RACE_D->query_race_object( name );
   initialize_stats();  /* set up stat/race bonus here */
   /* temp removal of min and max damage satch */
}
예제 #2
0
파일: race.c 프로젝트: bbailey/gurbalib
void set_race(string name, varargs int is_new_player) {
   if (!name || name == "") {
      race = "human";
   } else {
      race = name;
      race_object = RACE_D->query_race_object(name);
   }
   if (!race_object) {
      race_object = RACE_D->query_race_object("human");
   }

   if (is_new_player) {
      initialize_stats();            /* set up stat/race bonus here */
   }
}
예제 #3
0
void set_race(string name, varargs int is_new_player) {
   if (!name || name == "") {
      race = "human";
   } else {
      race = name;
      race_object = RACE_D->query_race_object(name);
   }
   if (!race_object) 
      race_object = RACE_D->query_race_object("human");

	if (is_new_player) {
   	initialize_stats();		/* set up stat/race bonus here */
	}
   /* temp removal of min and max damage satch */
}
예제 #4
0
파일: fer_sim.c 프로젝트: RupW/celp13k
/*-------------------------------------------------------------------*/
void fer_sim(int *rate)
{
    int     i,j,k,ix;
    short   fer_flag;

    static short    first_time = 1;


    if( first_time )
    {
        first_time = 0;

        /*...initialize data...*/
        initialize_data();

        /*...set seed...*/
        if (fer_sim_seed == 0) {
            fer_sim_seed = (int)(time(NULL) & 0x0fff);
        }

        if ((trans_fp=fopen(trans_fname,"r")) == NULL)
        {
            fprintf(stderr,"ERROR:  Cannot open file \"%s\" for reading.\n",trans_fname );
            fprintf(log_fp,"ERROR:  Cannot open file \"%s\" for reading.\n",trans_fname );
            exit(1);
        }
        else
        {
            fprintf(log_fp,"FER Transition Prob. File              : \"%s\"\n\n",trans_fname);
        }
	
        /* record initial parameters in log file */
        fprintf(log_fp,"Random number generator initial seed : %d\n",fer_sim_seed);

        /* read transition probability matrices */
        for(i=0;i<NSTATES;i++)
        {
            for(j=0;j<NRATES_IN;j++)
            {
                for(k=0;k<NRATES_OUT;k++)
                {
                    ix = fscanf(trans_fp,"%lf",&p[i][j][k]);
                    if(ix!=1)
                    {
                        printf("Error in read of transition matrices file\n");
                        fprintf(log_fp,"Error in read of transition matrices file\n");
                        exit(1);
                    }
                }
            }
        }
	
        /* convert probability transition matrices to cumulative values */
        if(!prob_to_cum())
        {
            fprintf(stderr,"Problem with prob_to_cum()\n");
            fprintf(log_fp,"Problem with prob_to_cum()\n");
        }

	
        /* clear rate and transition stat matrices */
        initialize_stats();

    } /* end if( first_time ) */
	


    /* read encoded data */
    /* convert code to internal value */
    if(*rate==fullRate) rate_in = FULL;
    else if(*rate==halfRate) rate_in = HALF;
    else if(*rate==quarRate) rate_in = QUARTER;
    else if(*rate==eighRate) rate_in = EIGHTH;
    else if(*rate==fullProb) rate_in = FULL_ERRS;
    else rate_in = -1;   /* other codes invalid */

    fer_flag = 0;

    if (rate_in == -1)
    {
        fer_flag = 1;
    }
    else if (rate_in == -2)
    {
        fer_flag = 1;
        fprintf(stderr,"Encoded data file format error -- invalid rate specified in %d-th frame\n",frame_cnt);
        fprintf(log_fp,"Encoded data file format error -- invalid rate specified in %d-th frame\n",frame_cnt);
    }

		
    trans(rate_in);  /* determine rate_out, event from random number and  */
		                 /* transition probability matrix */

    /* Force RANDOM and MODIFIED to be an ERASURE (for simplicity) */
    if(event==RANDOM)           /* random data for the given frame length */
    {
        event = ERASURE;
    }
    else if(event==MODIFIED)    /* XOR data with a randomly selected mask */
    {
        event = ERASURE;
    }
    else if( fer_flag == 1 )
    {
        event = ERASURE;
    }

		
    /* determine output rate code */
    if(event==ERASURE) rate_code = erasRate;
    else if(rate_out==FULL) rate_code = fullRate;
    else if(rate_out==HALF) rate_code = halfRate;
    else if(rate_out==QUARTER) rate_code = quarRate;
    else if(rate_out==EIGHTH) rate_code = eighRate;
    else if(rate_out==FULL_ERRS) rate_code = fullProb;

    *rate = rate_code;

}